Finish the upvote/downvote implementation

This commit is contained in:
Paul Frazee 2022-11-08 12:14:51 -06:00
parent e650d98924
commit 1fbc4cf1f2
32 changed files with 1207 additions and 587 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -21,25 +21,27 @@ import * as ComAtprotoSessionRefresh from './types/com/atproto/session/refresh';
import * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo';
import * as ComAtprotoSyncGetRoot from './types/com/atproto/sync/getRoot';
import * as ComAtprotoSyncUpdateRepo from './types/com/atproto/sync/updateRepo';
import * as AppBskyActorCreateScene from './types/app/bsky/actor/createScene';
import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile';
import * as AppBskyActorGetSuggestions from './types/app/bsky/actor/getSuggestions';
import * as AppBskyActorProfile from './types/app/bsky/actor/profile';
import * as AppBskyActorSearch from './types/app/bsky/actor/search';
import * as AppBskyActorSearchTypeahead from './types/app/bsky/actor/searchTypeahead';
import * as AppBskyActorProfile from './types/app/bsky/actor/profile';
import * as AppBskyActorUpdateProfile from './types/app/bsky/actor/updateProfile';
import * as AppBskyFeedGetAuthorFeed from './types/app/bsky/feed/getAuthorFeed';
import * as AppBskyFeedGetLikedBy from './types/app/bsky/feed/getLikedBy';
import * as AppBskyFeedGetPostThread from './types/app/bsky/feed/getPostThread';
import * as AppBskyFeedGetRepostedBy from './types/app/bsky/feed/getRepostedBy';
import * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline';
import * as AppBskyFeedLike from './types/app/bsky/feed/like';
import * as AppBskyFeedGetVotes from './types/app/bsky/feed/getVotes';
import * as AppBskyFeedMediaEmbed from './types/app/bsky/feed/mediaEmbed';
import * as AppBskyFeedPost from './types/app/bsky/feed/post';
import * as AppBskyFeedRepost from './types/app/bsky/feed/repost';
import * as AppBskyFeedVote from './types/app/bsky/feed/vote';
import * as AppBskyGraphAssertion from './types/app/bsky/graph/assertion';
import * as AppBskyGraphConfirmation from './types/app/bsky/graph/confirmation';
import * as AppBskyGraphFollow from './types/app/bsky/graph/follow';
import * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers';
import * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows';
import * as AppBskyGraphInvite from './types/app/bsky/graph/invite';
import * as AppBskyGraphInviteAccept from './types/app/bsky/graph/inviteAccept';
import * as AppBskyNotificationGetCount from './types/app/bsky/notification/getCount';
import * as AppBskyNotificationList from './types/app/bsky/notification/list';
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen';
@ -66,29 +68,35 @@ export * as ComAtprotoSessionRefresh from './types/com/atproto/session/refresh';
export * as ComAtprotoSyncGetRepo from './types/com/atproto/sync/getRepo';
export * as ComAtprotoSyncGetRoot from './types/com/atproto/sync/getRoot';
export * as ComAtprotoSyncUpdateRepo from './types/com/atproto/sync/updateRepo';
export * as AppBskyActorCreateScene from './types/app/bsky/actor/createScene';
export * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile';
export * as AppBskyActorGetSuggestions from './types/app/bsky/actor/getSuggestions';
export * as AppBskyActorProfile from './types/app/bsky/actor/profile';
export * as AppBskyActorSearch from './types/app/bsky/actor/search';
export * as AppBskyActorSearchTypeahead from './types/app/bsky/actor/searchTypeahead';
export * as AppBskyActorProfile from './types/app/bsky/actor/profile';
export * as AppBskyActorUpdateProfile from './types/app/bsky/actor/updateProfile';
export * as AppBskyFeedGetAuthorFeed from './types/app/bsky/feed/getAuthorFeed';
export * as AppBskyFeedGetLikedBy from './types/app/bsky/feed/getLikedBy';
export * as AppBskyFeedGetPostThread from './types/app/bsky/feed/getPostThread';
export * as AppBskyFeedGetRepostedBy from './types/app/bsky/feed/getRepostedBy';
export * as AppBskyFeedGetTimeline from './types/app/bsky/feed/getTimeline';
export * as AppBskyFeedLike from './types/app/bsky/feed/like';
export * as AppBskyFeedGetVotes from './types/app/bsky/feed/getVotes';
export * as AppBskyFeedMediaEmbed from './types/app/bsky/feed/mediaEmbed';
export * as AppBskyFeedPost from './types/app/bsky/feed/post';
export * as AppBskyFeedRepost from './types/app/bsky/feed/repost';
export * as AppBskyFeedVote from './types/app/bsky/feed/vote';
export * as AppBskyGraphAssertion from './types/app/bsky/graph/assertion';
export * as AppBskyGraphConfirmation from './types/app/bsky/graph/confirmation';
export * as AppBskyGraphFollow from './types/app/bsky/graph/follow';
export * as AppBskyGraphGetFollowers from './types/app/bsky/graph/getFollowers';
export * as AppBskyGraphGetFollows from './types/app/bsky/graph/getFollows';
export * as AppBskyGraphInvite from './types/app/bsky/graph/invite';
export * as AppBskyGraphInviteAccept from './types/app/bsky/graph/inviteAccept';
export * as AppBskyNotificationGetCount from './types/app/bsky/notification/getCount';
export * as AppBskyNotificationList from './types/app/bsky/notification/list';
export * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen';
export * as AppBskySystemDeclaration from './types/app/bsky/system/declaration';
export declare const APP_BSKY_GRAPH: {
AssertCreator: string;
AssertMember: string;
};
export declare const APP_BSKY_SYSTEM: {
ActorScene: string;
ActorUser: string;
@ -187,7 +195,9 @@ export declare class ActorNS {
_service: ServiceClient;
profile: ProfileRecord;
constructor(service: ServiceClient);
createScene(data?: AppBskyActorCreateScene.InputSchema, opts?: AppBskyActorCreateScene.CallOptions): Promise<AppBskyActorCreateScene.Response>;
getProfile(params?: AppBskyActorGetProfile.QueryParams, opts?: AppBskyActorGetProfile.CallOptions): Promise<AppBskyActorGetProfile.Response>;
getSuggestions(params?: AppBskyActorGetSuggestions.QueryParams, opts?: AppBskyActorGetSuggestions.CallOptions): Promise<AppBskyActorGetSuggestions.Response>;
search(params?: AppBskyActorSearch.QueryParams, opts?: AppBskyActorSearch.CallOptions): Promise<AppBskyActorSearch.Response>;
searchTypeahead(params?: AppBskyActorSearchTypeahead.QueryParams, opts?: AppBskyActorSearchTypeahead.CallOptions): Promise<AppBskyActorSearchTypeahead.Response>;
updateProfile(data?: AppBskyActorUpdateProfile.InputSchema, opts?: AppBskyActorUpdateProfile.CallOptions): Promise<AppBskyActorUpdateProfile.Response>;
@ -215,37 +225,16 @@ export declare class ProfileRecord {
}
export declare class FeedNS {
_service: ServiceClient;
like: LikeRecord;
mediaEmbed: MediaEmbedRecord;
post: PostRecord;
repost: RepostRecord;
vote: VoteRecord;
constructor(service: ServiceClient);
getAuthorFeed(params?: AppBskyFeedGetAuthorFeed.QueryParams, opts?: AppBskyFeedGetAuthorFeed.CallOptions): Promise<AppBskyFeedGetAuthorFeed.Response>;
getLikedBy(params?: AppBskyFeedGetLikedBy.QueryParams, opts?: AppBskyFeedGetLikedBy.CallOptions): Promise<AppBskyFeedGetLikedBy.Response>;
getPostThread(params?: AppBskyFeedGetPostThread.QueryParams, opts?: AppBskyFeedGetPostThread.CallOptions): Promise<AppBskyFeedGetPostThread.Response>;
getRepostedBy(params?: AppBskyFeedGetRepostedBy.QueryParams, opts?: AppBskyFeedGetRepostedBy.CallOptions): Promise<AppBskyFeedGetRepostedBy.Response>;
getTimeline(params?: AppBskyFeedGetTimeline.QueryParams, opts?: AppBskyFeedGetTimeline.CallOptions): Promise<AppBskyFeedGetTimeline.Response>;
}
export declare class LikeRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{
cursor?: string;
records: {
uri: string;
value: AppBskyFeedLike.Record;
}[];
}>;
get(params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>): Promise<{
uri: string;
cid: string;
value: AppBskyFeedLike.Record;
}>;
create(params: Omit<ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record'>, record: AppBskyFeedLike.Record, headers?: Record<string, string>): Promise<{
uri: string;
cid: string;
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
getVotes(params?: AppBskyFeedGetVotes.QueryParams, opts?: AppBskyFeedGetVotes.CallOptions): Promise<AppBskyFeedGetVotes.Response>;
}
export declare class MediaEmbedRecord {
_service: ServiceClient;
@ -310,15 +299,78 @@ export declare class RepostRecord {
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class VoteRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{
cursor?: string;
records: {
uri: string;
value: AppBskyFeedVote.Record;
}[];
}>;
get(params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>): Promise<{
uri: string;
cid: string;
value: AppBskyFeedVote.Record;
}>;
create(params: Omit<ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record'>, record: AppBskyFeedVote.Record, headers?: Record<string, string>): Promise<{
uri: string;
cid: string;
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class GraphNS {
_service: ServiceClient;
assertion: AssertionRecord;
confirmation: ConfirmationRecord;
follow: FollowRecord;
invite: InviteRecord;
inviteAccept: InviteAcceptRecord;
constructor(service: ServiceClient);
getFollowers(params?: AppBskyGraphGetFollowers.QueryParams, opts?: AppBskyGraphGetFollowers.CallOptions): Promise<AppBskyGraphGetFollowers.Response>;
getFollows(params?: AppBskyGraphGetFollows.QueryParams, opts?: AppBskyGraphGetFollows.CallOptions): Promise<AppBskyGraphGetFollows.Response>;
}
export declare class AssertionRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{
cursor?: string;
records: {
uri: string;
value: AppBskyGraphAssertion.Record;
}[];
}>;
get(params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>): Promise<{
uri: string;
cid: string;
value: AppBskyGraphAssertion.Record;
}>;
create(params: Omit<ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record'>, record: AppBskyGraphAssertion.Record, headers?: Record<string, string>): Promise<{
uri: string;
cid: string;
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class ConfirmationRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{
cursor?: string;
records: {
uri: string;
value: AppBskyGraphConfirmation.Record;
}[];
}>;
get(params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>): Promise<{
uri: string;
cid: string;
value: AppBskyGraphConfirmation.Record;
}>;
create(params: Omit<ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record'>, record: AppBskyGraphConfirmation.Record, headers?: Record<string, string>): Promise<{
uri: string;
cid: string;
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class FollowRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
@ -340,48 +392,6 @@ export declare class FollowRecord {
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class InviteRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{
cursor?: string;
records: {
uri: string;
value: AppBskyGraphInvite.Record;
}[];
}>;
get(params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>): Promise<{
uri: string;
cid: string;
value: AppBskyGraphInvite.Record;
}>;
create(params: Omit<ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record'>, record: AppBskyGraphInvite.Record, headers?: Record<string, string>): Promise<{
uri: string;
cid: string;
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class InviteAcceptRecord {
_service: ServiceClient;
constructor(service: ServiceClient);
list(params: Omit<ComAtprotoRepoListRecords.QueryParams, 'collection'>): Promise<{
cursor?: string;
records: {
uri: string;
value: AppBskyGraphInviteAccept.Record;
}[];
}>;
get(params: Omit<ComAtprotoRepoGetRecord.QueryParams, 'collection'>): Promise<{
uri: string;
cid: string;
value: AppBskyGraphInviteAccept.Record;
}>;
create(params: Omit<ComAtprotoRepoCreateRecord.InputSchema, 'collection' | 'record'>, record: AppBskyGraphInviteAccept.Record, headers?: Record<string, string>): Promise<{
uri: string;
cid: string;
}>;
delete(params: Omit<ComAtprotoRepoDeleteRecord.QueryParams, 'collection'>, headers?: Record<string, string>): Promise<void>;
}
export declare class NotificationNS {
_service: ServiceClient;
constructor(service: ServiceClient);

View file

@ -3,13 +3,13 @@ export declare const methodSchemaDict: Record<string, MethodSchema>;
export declare const methodSchemas: MethodSchema[];
export declare const ids: {
AppBskyActorProfile: string;
AppBskyFeedLike: string;
AppBskyFeedMediaEmbed: string;
AppBskyFeedPost: string;
AppBskyFeedRepost: string;
AppBskyFeedVote: string;
AppBskyGraphAssertion: string;
AppBskyGraphConfirmation: string;
AppBskyGraphFollow: string;
AppBskyGraphInvite: string;
AppBskyGraphInviteAccept: string;
AppBskySystemDeclaration: string;
};
export declare const recordSchemaDict: Record<string, RecordSchema>;

View file

@ -0,0 +1,29 @@
import { Headers, XRPCError } from '@atproto/xrpc';
export interface QueryParams {
}
export interface CallOptions {
headers?: Headers;
qp?: QueryParams;
encoding: 'application/json';
}
export interface InputSchema {
handle: string;
recoveryKey?: string;
}
export interface OutputSchema {
handle: string;
did: string;
declarationCid: string;
}
export interface Response {
success: boolean;
headers: Headers;
data: OutputSchema;
}
export declare class InvalidHandleError extends XRPCError {
constructor(src: XRPCError);
}
export declare class HandleNotAvailableError extends XRPCError {
constructor(src: XRPCError);
}
export declare function toKnownErr(e: any): any;

View file

@ -1,18 +1,23 @@
import { Headers } from '@atproto/xrpc';
export interface QueryParams {
user: string;
actor: string;
}
export interface CallOptions {
headers?: Headers;
}
export declare type InputSchema = undefined;
export declare type ActorKnown = 'app.bsky.system.actorUser' | 'app.bsky.system.actorScene';
export declare type ActorUnknown = string;
export interface OutputSchema {
did: string;
handle: string;
actorType: ActorKnown | ActorUnknown;
creator: string;
displayName?: string;
description?: string;
followersCount: number;
followsCount: number;
membersCount: number;
postsCount: number;
myState?: {
follow?: string;

View file

@ -0,0 +1,29 @@
import { Headers } from '@atproto/xrpc';
export interface QueryParams {
limit?: number;
cursor?: string;
}
export interface CallOptions {
headers?: Headers;
}
export declare type InputSchema = undefined;
export interface OutputSchema {
cursor?: string;
actors: {
did: string;
handle: string;
actorType: string;
displayName?: string;
description?: string;
indexedAt?: string;
myState?: {
follow?: string;
};
}[];
}
export interface Response {
success: boolean;
headers: Headers;
data: OutputSchema;
}
export declare function toKnownErr(e: any): any;

View file

@ -21,11 +21,13 @@ export interface FeedItem {
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
replyCount: number;
repostCount: number;
likeCount: number;
upvoteCount: number;
downvoteCount: number;
indexedAt: string;
myState?: {
repost?: string;
like?: string;
upvote?: string;
downvote?: string;
};
}
export interface User {

View file

@ -19,12 +19,14 @@ export interface Post {
parent?: Post;
replyCount: number;
replies?: Post[];
likeCount: number;
repostCount: number;
upvoteCount: number;
downvoteCount: number;
indexedAt: string;
myState?: {
repost?: string;
like?: string;
upvote?: string;
downvote?: string;
};
}
export interface User {

View file

@ -21,11 +21,13 @@ export interface FeedItem {
embed?: RecordEmbed | ExternalEmbed | UnknownEmbed;
replyCount: number;
repostCount: number;
likeCount: number;
upvoteCount: number;
downvoteCount: number;
indexedAt: string;
myState?: {
repost?: string;
like?: string;
upvote?: string;
downvote?: string;
};
}
export interface User {

View file

@ -0,0 +1,34 @@
import { Headers } from '@atproto/xrpc';
export interface QueryParams {
uri: string;
cid?: string;
direction?: string;
limit?: number;
before?: string;
}
export interface CallOptions {
headers?: Headers;
}
export declare type InputSchema = undefined;
export interface OutputSchema {
uri: string;
cid?: string;
cursor?: string;
votes: {
direction: 'up' | 'down';
indexedAt: string;
createdAt: string;
actor: Actor;
}[];
}
export interface Actor {
did: string;
handle: string;
displayName?: string;
}
export interface Response {
success: boolean;
headers: Headers;
data: OutputSchema;
}
export declare function toKnownErr(e: any): any;

View file

@ -0,0 +1,11 @@
export interface Record {
subject: Subject;
direction: 'up' | 'down';
createdAt: string;
[k: string]: unknown;
}
export interface Subject {
uri: string;
cid: string;
[k: string]: unknown;
}

View file

@ -0,0 +1,10 @@
export interface Record {
assertion: string;
subject: {
did: string;
declarationCid: string;
[k: string]: unknown;
};
createdAt: string;
[k: string]: unknown;
}

View file

@ -0,0 +1,14 @@
export interface Record {
originator: {
did: string;
declarationCid: string;
[k: string]: unknown;
};
assertion: {
uri: string;
cid: string;
[k: string]: unknown;
};
createdAt: string;
[k: string]: unknown;
}

File diff suppressed because one or more lines are too long