From 4cf1bcd927a729c87767e637033fb901fec26894 Mon Sep 17 00:00:00 2001 From: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com> Date: Sat, 8 Feb 2025 17:20:30 +0530 Subject: [PATCH 1/9] refactor(client): shifted search logic --- packages/client/src/agent/agent.ts | 6 +++- packages/client/src/post/post.ts | 18 ----------- packages/client/src/search/index.ts | 1 + packages/client/src/search/search.ts | 45 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 packages/client/src/search/index.ts create mode 100644 packages/client/src/search/search.ts diff --git a/packages/client/src/agent/agent.ts b/packages/client/src/agent/agent.ts index f1e3c00..3298760 100644 --- a/packages/client/src/agent/agent.ts +++ b/packages/client/src/agent/agent.ts @@ -3,7 +3,7 @@ import type { Queries } from '@tsky/lexicons'; import { Actor } from '~/actor'; import { Feed } from '~/feed'; import { List } from '~/list'; -import { StarterPack } from '~/starterpack'; +import { Search } from '~/search'; import { User } from '~/user'; import { Video } from '~/video'; import { Client } from './client'; @@ -33,6 +33,10 @@ export class Agent { return new Feed(this.client); } + get search() { + return new Search(this.client); + } + get user() { if (!this.session) { throw new Error('There is no active session'); diff --git a/packages/client/src/post/post.ts b/packages/client/src/post/post.ts index 5db0b25..31b36a4 100644 --- a/packages/client/src/post/post.ts +++ b/packages/client/src/post/post.ts @@ -72,24 +72,6 @@ export class Post { }); } - /** - * Find posts matching search criteria, returning views of those posts. - */ - static search( - client: Client, - params: AppBskyFeedSearchPosts.Params, - options: RPCOptions = {}, - ) { - return Paginator.init(async (cursor) => { - const res = await client.get('app.bsky.feed.searchPosts', { - params: { cursor, ...params }, - ...options, - }); - - return res.data; - }); - } - /** * Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'. */ diff --git a/packages/client/src/search/index.ts b/packages/client/src/search/index.ts new file mode 100644 index 0000000..5a2bdeb --- /dev/null +++ b/packages/client/src/search/index.ts @@ -0,0 +1 @@ +export * from './search'; diff --git a/packages/client/src/search/search.ts b/packages/client/src/search/search.ts new file mode 100644 index 0000000..bf1e346 --- /dev/null +++ b/packages/client/src/search/search.ts @@ -0,0 +1,45 @@ +import type { + AppBskyFeedSearchPosts, + AppBskyGraphSearchStarterPacks, +} from '@tsky/lexicons'; +import type { Client } from '~/agent/client'; +import type { RPCOptions } from '~/types'; +import { Paginator } from '~/utils'; + +export class Search { + constructor(private client: Client) {} + + /** + * Find posts matching search criteria, returning views of those posts. + */ + posts(params: AppBskyFeedSearchPosts.Params, options: RPCOptions = {}) { + return Paginator.init(async (cursor) => { + const res = await this.client.get('app.bsky.feed.searchPosts', { + params: { cursor, ...params }, + ...options, + }); + + return res.data; + }); + } + + /** + * Search for starter packs. + */ + starterpacks( + params: AppBskyGraphSearchStarterPacks.Params, + options?: RPCOptions, + ) { + return Paginator.init(async (cursor) => { + const res = await this.client.get('app.bsky.graph.searchStarterPacks', { + params: { + cursor, + ...params, + }, + ...options, + }); + + return res.data; + }); + } +} From 64b10eceef0e81f6c9b1f98a6b6269c5d9b4582a Mon Sep 17 00:00:00 2001 From: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com> Date: Sat, 8 Feb 2025 17:21:09 +0530 Subject: [PATCH 2/9] refactor(client): improved starterpacks api --- packages/client/src/agent/agent.ts | 42 ++++++++++++- packages/client/src/post/post.ts | 6 +- .../client/src/starterpack/starterpack.ts | 59 ------------------- 3 files changed, 43 insertions(+), 64 deletions(-) diff --git a/packages/client/src/agent/agent.ts b/packages/client/src/agent/agent.ts index 3298760..fe3bb69 100644 --- a/packages/client/src/agent/agent.ts +++ b/packages/client/src/agent/agent.ts @@ -1,9 +1,14 @@ import { type CredentialManager, XRPC } from '@atcute/client'; -import type { Queries } from '@tsky/lexicons'; +import type { + AppBskyGraphGetStarterPack, + AppBskyGraphGetStarterPacks, + Queries, +} from '@tsky/lexicons'; import { Actor } from '~/actor'; import { Feed } from '~/feed'; import { List } from '~/list'; import { Search } from '~/search'; +import type { RPCOptions } from '~/types'; import { User } from '~/user'; import { Video } from '~/video'; import { Client } from './client'; @@ -53,7 +58,38 @@ export class Agent { return new Video(this.client); } - get starterpack() { - return new StarterPack(this.client); + /** + * Gets a view of a starter pack. + */ + startpacks( + uri: string, + options?: RPCOptions, + ): Promise; + /** + * Get views for a list of starter packs. + */ + startpacks( + uris: string[], + options?: RPCOptions, + ): Promise; + + async startpacks(uris: string | string[], options: RPCOptions = {}) { + if (Array.isArray(uris)) { + const res = await this.client.get('app.bsky.graph.getStarterPacks', { + params: { + uris, + }, + ...options, + }); + + return res.data.starterPacks; + } + + const res = await this.client.get('app.bsky.graph.getStarterPack', { + params: { starterPack: uris }, + ...options, + }); + + return res.data; } } diff --git a/packages/client/src/post/post.ts b/packages/client/src/post/post.ts index 31b36a4..f7a9a06 100644 --- a/packages/client/src/post/post.ts +++ b/packages/client/src/post/post.ts @@ -3,14 +3,16 @@ import type { AppBskyFeedGetPostThread, AppBskyFeedGetQuotes, AppBskyFeedGetRepostedBy, - AppBskyFeedSearchPosts, } from '@tsky/lexicons'; import type { Client } from '~/agent/client'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; export class Post { - constructor(private client: Client) {} + constructor( + private client: Client, + private uri: string, + ) {} /** * Get posts in a thread. Does not require auth, but additional metadata and filtering will be applied for authed requests. diff --git a/packages/client/src/starterpack/starterpack.ts b/packages/client/src/starterpack/starterpack.ts index 8b35a0b..459ce5f 100644 --- a/packages/client/src/starterpack/starterpack.ts +++ b/packages/client/src/starterpack/starterpack.ts @@ -1,64 +1,5 @@ -import type { - AppBskyGraphGetStarterPack, - AppBskyGraphGetStarterPacks, -} from '@tsky/lexicons'; import type { Client } from '~/agent/client'; -import type { RPCOptions } from '~/types'; -import { Paginator } from '~/utils'; export class StarterPack { constructor(private client: Client) {} - - /** - * Gets a view of a starter pack. - */ - view( - uri: string, - options: RPCOptions, - ): Promise; - /** - * Get views for a list of starter packs. - */ - view( - uris: string[], - options: RPCOptions, - ): Promise; - - async view(uris: string | string[], options: RPCOptions) { - if (Array.isArray(uris)) { - const res = await this.client.get('app.bsky.graph.getStarterPacks', { - params: { - uris, - }, - ...options, - }); - - return res.data.starterPacks; - } - - const res = await this.client.get('app.bsky.graph.getStarterPack', { - params: { starterPack: uris }, - ...options, - }); - - return res.data; - } - - /** - * Search for starter packs. - */ - search(query: string, limit?: number, options?: RPCOptions) { - return Paginator.init(async (cursor) => { - const res = await this.client.get('app.bsky.graph.searchStarterPacks', { - params: { - cursor, - q: query, - limit, - }, - ...options, - }); - - return res.data; - }); - } } From 373d900b1f9a31c5fdb925fdf2e174b30e65703c Mon Sep 17 00:00:00 2001 From: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com> Date: Sat, 8 Feb 2025 18:10:39 +0530 Subject: [PATCH 3/9] chore(client): minor changes --- packages/client/src/agent/agent.ts | 2 +- packages/client/src/post/post.ts | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/client/src/agent/agent.ts b/packages/client/src/agent/agent.ts index fe3bb69..de89978 100644 --- a/packages/client/src/agent/agent.ts +++ b/packages/client/src/agent/agent.ts @@ -14,7 +14,7 @@ import { Video } from '~/video'; import { Client } from './client'; export class Agent { - private client: Client; + client: Client; constructor(private handler: CredentialManager) { // Initialize the client diff --git a/packages/client/src/post/post.ts b/packages/client/src/post/post.ts index f7a9a06..617c49f 100644 --- a/packages/client/src/post/post.ts +++ b/packages/client/src/post/post.ts @@ -18,11 +18,11 @@ export class Post { * Get posts in a thread. Does not require auth, but additional metadata and filtering will be applied for authed requests. */ async threads( - params: AppBskyFeedGetPostThread.Params, + params: Omit = {}, options: RPCOptions = {}, ) { const res = await this.client.get('app.bsky.feed.getPostThread', { - params, + params: { uri: this.uri, ...params }, ...options, }); @@ -32,10 +32,13 @@ export class Post { /** * Get like records which reference a subject (by AT-URI and CID). */ - likes(params: AppBskyFeedGetLikes.Params, options: RPCOptions = {}) { + likes( + params: Omit = {}, + options: RPCOptions = {}, + ) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.feed.getLikes', { - params: { cursor, ...params }, + params: { cursor, uri: this.uri, ...params }, ...options, }); @@ -46,10 +49,13 @@ export class Post { /** * Get a list of quotes for a given post. */ - quotes(params: AppBskyFeedGetQuotes.Params, options: RPCOptions = {}) { + quotes( + params: Omit = {}, + options: RPCOptions = {}, + ) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.feed.getQuotes', { - params: { cursor, ...params }, + params: { cursor, uri: this.uri, ...params }, ...options, }); @@ -61,12 +67,12 @@ export class Post { * Get a list of reposts for a given post. */ repostedBy( - params: AppBskyFeedGetRepostedBy.Params, + params: Omit = {}, options: RPCOptions = {}, ) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.feed.getRepostedBy', { - params: { cursor, ...params }, + params: { cursor, uri: this.uri, ...params }, ...options, }); From 3e0f2ef94bf341dabe746cf1886fc29bfe2ae6f1 Mon Sep 17 00:00:00 2001 From: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com> Date: Wed, 12 Feb 2025 08:38:06 +0530 Subject: [PATCH 4/9] feat: wip linking all classes --- packages/client/src/actor/actor.ts | 115 ++++++++++++++---- packages/client/src/agent/agent.ts | 18 ++- packages/client/src/agent/client.ts | 97 ++++++++++++++- packages/client/src/list/list.ts | 9 +- packages/client/src/post/post.ts | 51 +++++++- packages/client/src/search/search.ts | 14 ++- .../client/src/starterpack/starterpack.ts | 43 ++++++- packages/client/src/types.ts | 11 ++ packages/client/src/user/index.ts | 2 +- packages/client/src/utils/index.ts | 1 + packages/client/src/utils/parse.ts | 15 +++ 11 files changed, 332 insertions(+), 44 deletions(-) create mode 100644 packages/client/src/utils/parse.ts diff --git a/packages/client/src/actor/actor.ts b/packages/client/src/actor/actor.ts index 5d41e11..2c1bd13 100644 --- a/packages/client/src/actor/actor.ts +++ b/packages/client/src/actor/actor.ts @@ -1,29 +1,23 @@ import type { AppBskyActorDefs, AppBskyFeedGetAuthorFeed, + AppBskyGraphDefs, + At, + ComAtprotoLabelDefs, + ComAtprotoRepoStrongRef, } from '@tsky/lexicons'; import type { Client } from '~/agent/client'; +import { List } from '~/list'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; export class Actor { client: Client; - identifier: string; + did: At.DID; - constructor(client: Client, identifier: string) { + constructor(client: Client, did: At.DID) { this.client = client; - this.identifier = identifier; - } - - /** - * Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth. - */ - async profile(): Promise { - const res = await this.client.get('app.bsky.actor.getProfile', { - params: { actor: this.identifier }, - }); - - return res.data; + this.did = did; } /** @@ -32,7 +26,7 @@ export class Actor { starterPacks(limit?: number, options: RPCOptions = {}) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.graph.getActorStarterPacks', { - params: { cursor, actor: this.identifier, limit }, + params: { cursor, actor: this.did, limit }, ...options, }); @@ -48,13 +42,19 @@ export class Actor { const res = await this.client.get('app.bsky.graph.getFollowers', { params: { cursor, - actor: this.identifier, + actor: this.did, limit, }, ...options, }); - return res.data; + return { + ...res.data, + subject: new ActorProfile(this.client, res.data.subject), + followers: res.data.followers.map( + (follower) => new ActorProfile(this.client, follower), + ), + }; }); } @@ -66,13 +66,19 @@ export class Actor { const res = await this.client.get('app.bsky.graph.getFollows', { params: { cursor, - actor: this.identifier, + actor: this.did, limit, }, ...options, }); - return res.data; + return { + ...res.data, + subject: new ActorProfile(this.client, res.data.subject), + follows: res.data.follows.map( + (follow) => new ActorProfile(this.client, follow), + ), + }; }); } @@ -84,13 +90,17 @@ export class Actor { const res = await this.client.get('app.bsky.graph.getLists', { params: { cursor, - actor: this.identifier, + actor: this.did, limit, }, ...options, }); - return res.data; + return { + ...res.data, + // TODO: Solve this + // lists: res.data.lists.map((list) => new List(this.client, list)), + }; }); } @@ -100,13 +110,18 @@ export class Actor { async relationships(others?: string[], options?: RPCOptions) { const res = await this.client.get('app.bsky.graph.getRelationships', { params: { - actor: this.identifier, + actor: this.did, others, }, ...options, }); - return res.data; + return { + ...res.data, + actor: res.data.actor + ? new Actor(this.client, res.data.actor) + : undefined, + }; } /** @@ -115,7 +130,7 @@ export class Actor { feeds(limit?: number, options?: RPCOptions) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.feed.getActorFeeds', { - params: { cursor, actor: this.identifier, limit }, + params: { cursor, actor: this.did, limit }, ...options, }); @@ -132,7 +147,7 @@ export class Actor { ) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.feed.getAuthorFeed', { - params: { cursor, ...params, actor: this.identifier }, + params: { cursor, ...params, actor: this.did }, ...options, }); @@ -140,3 +155,53 @@ export class Actor { }); } } + +export class BasicActorProfile + extends Actor + implements AppBskyActorDefs.ProfileViewBasic +{ + // @ts-expect-error - We added this property with Object.assign + handle: string; + associated?: AppBskyActorDefs.ProfileAssociated; + avatar?: string; + createdAt?: string; + displayName?: string; + labels?: ComAtprotoLabelDefs.Label[]; + viewer?: AppBskyActorDefs.ViewerState; + $type?: string; + + constructor(client: Client, actor: AppBskyActorDefs.ProfileViewBasic) { + super(client, actor.did); + Object.assign(this, actor); + } +} + +export class ActorProfile + extends BasicActorProfile + implements AppBskyActorDefs.ProfileView +{ + description?: string; + indexedAt?: string; + + constructor(client: Client, actor: AppBskyActorDefs.ProfileViewDetailed) { + super(client, actor); + Object.assign(this, actor); + } +} + +export class DetailedActorProfile + extends ActorProfile + implements AppBskyActorDefs.ProfileViewDetailed +{ + banner?: string; + followersCount?: number; + followsCount?: number; + joinedViaStarterPack?: AppBskyGraphDefs.StarterPackViewBasic; + pinnedPost?: ComAtprotoRepoStrongRef.Main; + postsCount?: number; + + constructor(client: Client, actor: AppBskyActorDefs.ProfileViewDetailed) { + super(client, actor); + Object.assign(this, actor); + } +} diff --git a/packages/client/src/agent/agent.ts b/packages/client/src/agent/agent.ts index de89978..8b2007c 100644 --- a/packages/client/src/agent/agent.ts +++ b/packages/client/src/agent/agent.ts @@ -2,9 +2,10 @@ import { type CredentialManager, XRPC } from '@atcute/client'; import type { AppBskyGraphGetStarterPack, AppBskyGraphGetStarterPacks, + At, Queries, } from '@tsky/lexicons'; -import { Actor } from '~/actor'; +import { DetailedActorProfile } from '~/actor'; import { Feed } from '~/feed'; import { List } from '~/list'; import { Search } from '~/search'; @@ -19,15 +20,22 @@ export class Agent { constructor(private handler: CredentialManager) { // Initialize the client const xrpc = new XRPC({ handler: this.handler }); - this.client = new Client(xrpc); + this.client = new Client(xrpc, this.handler); } get session() { return this.handler.session; } - actor(identifier: string) { - return new Actor(this.client, identifier); + /** + * Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth. + */ + async actor(identifier: At.DID | At.Handle): Promise { + const res = await this.client.get('app.bsky.actor.getProfile', { + params: { actor: identifier }, + }); + + return new DetailedActorProfile(this.client, res.data); } list(uri: string) { @@ -47,7 +55,7 @@ export class Agent { throw new Error('There is no active session'); } - return new User(this.client, this.session.handle); + return new User(this.client, this.session.did); } get video() { diff --git a/packages/client/src/agent/client.ts b/packages/client/src/agent/client.ts index 34a017c..3ee3b3d 100644 --- a/packages/client/src/agent/client.ts +++ b/packages/client/src/agent/client.ts @@ -1,24 +1,31 @@ import type { + CredentialManager, RPCOptions, XRPC, XRPCRequestOptions, XRPCResponse, } from '@atcute/client'; -import type { Procedures, Queries } from '@tsky/lexicons'; +import type { At, Procedures, Queries } from '@tsky/lexicons'; +import { parseAtUri } from '~/utils'; +import type { RPCOptions as GenericReqOptions, StrongRef } from '../types'; // From @atcute/client type OutputOf = T extends { - // biome-ignore lint/suspicious/noExplicitAny: - output: any; + output: unknown; } ? T['output'] : never; +const NO_SESSION_ERROR = + 'No session found. Please login to perform this action.'; + export class Client { xrpc: XRPC; + crenditials: CredentialManager; - constructor(xrpc: XRPC) { + constructor(xrpc: XRPC, crenditials: CredentialManager) { this.xrpc = xrpc; + this.crenditials = crenditials; } /** @@ -53,4 +60,86 @@ export class Client { async request(options: XRPCRequestOptions): Promise { return this.xrpc.request(options); } + + /** + * Create a record. + * @param nsid The collection's NSID. + * @param record The record to create. + * @param rkey The rkey to use. + * @returns The record's AT URI and CID. + */ + async createRecord( + nsid: K, + record: Omit, '$type' | 'createdAt'>, + rkey?: string, + ): Promise { + if (!this.crenditials.session) throw new Error(NO_SESSION_ERROR); + const response = await this.call( + 'com.atproto.repo.createRecord' as keyof P, + { + data: { + collection: nsid, + record: { + $type: nsid, + createdAt: new Date().toISOString(), + ...record, + }, + repo: this.crenditials.session.did, + ...(rkey ? { rkey } : {}), + }, + } as unknown as RPCOptions, + ); + return response.data; + } + + /** + * Put a record in place of an existing record. + * @param nsid The collection's NSID. + * @param record The record to put. + * @param rkey The rkey to use. + * @returns The record's AT URI and CID. + */ + async putRecord( + nsid: string, + record: object, + rkey: string, + ): Promise { + if (!this.crenditials.session) throw new Error(NO_SESSION_ERROR); + const response = await this.call( + 'com.atproto.repo.putRecord' as keyof P, + { + data: { + collection: nsid, + record: { + $type: nsid, + createdAt: new Date().toISOString(), + ...record, + }, + repo: this.crenditials.session.did, + rkey, + }, + } as unknown as RPCOptions, + ); + return response.data; + } + + /** + * Delete a record. + * @param uri The record's AT URI. + */ + async deleteRecord( + uri: At.Uri, + options: GenericReqOptions = {}, + ): Promise { + const { host: repo, collection, rkey } = parseAtUri(uri); + if (repo !== this.crenditials.session?.did) + throw new Error('Can only delete own record.'); + await this.call( + 'com.atproto.repo.deleteRecord' as keyof P, + { + data: { collection, repo, rkey }, + ...options, + } as unknown as RPCOptions, + ); + } } diff --git a/packages/client/src/list/list.ts b/packages/client/src/list/list.ts index e036d6c..062fd1f 100644 --- a/packages/client/src/list/list.ts +++ b/packages/client/src/list/list.ts @@ -1,3 +1,4 @@ +import { ActorProfile } from '~/actor'; import type { Client } from '~/agent/client'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; @@ -22,7 +23,13 @@ export class List { ...options, }); - return res.data; + return { + ...res.data, + items: res.data.items.map((item) => ({ + ...item, + subject: new ActorProfile(this.client, item.subject), + })), + }; }); } diff --git a/packages/client/src/post/post.ts b/packages/client/src/post/post.ts index 617c49f..1357867 100644 --- a/packages/client/src/post/post.ts +++ b/packages/client/src/post/post.ts @@ -1,18 +1,61 @@ import type { + AppBskyEmbedExternal, + AppBskyEmbedImages, + AppBskyEmbedRecord, + AppBskyEmbedRecordWithMedia, + AppBskyEmbedVideo, + AppBskyFeedDefs, AppBskyFeedGetLikes, AppBskyFeedGetPostThread, AppBskyFeedGetQuotes, AppBskyFeedGetRepostedBy, + ComAtprotoLabelDefs, + Typed, } from '@tsky/lexicons'; +import { BasicActorProfile } from '~/actor'; import type { Client } from '~/agent/client'; import type { RPCOptions } from '~/types'; -import { Paginator } from '~/utils'; +import { Paginator, parseAtUri } from '~/utils'; + +export class Post implements AppBskyFeedDefs.PostView { + uri: string; + author: BasicActorProfile; + cid: string; + indexedAt: string; + record: unknown; + embed?: + | Typed + | Typed + | Typed + | Typed + | Typed; + labels?: ComAtprotoLabelDefs.Label[]; + likeCount?: number; + quoteCount?: number; + replyCount?: number; + repostCount?: number; + threadgate?: AppBskyFeedDefs.ThreadgateView; + viewer?: AppBskyFeedDefs.ViewerState; + $type?: string; -export class Post { constructor( private client: Client, - private uri: string, - ) {} + payload: AppBskyFeedDefs.PostView, + ) { + Object.assign(this, payload); + this.author = new BasicActorProfile(this.client, payload.author); + } + + isOfCurrentUser() { + const { host: repo } = parseAtUri(this.uri); + return repo !== this.client.crenditials.session?.did; + } + + remove(options: RPCOptions = {}) { + this.client.deleteRecord(this.uri, options); + } + + // TODO: method for liking, unliking, reposting, un-reposting, quoting, etc. /** * Get posts in a thread. Does not require auth, but additional metadata and filtering will be applied for authed requests. diff --git a/packages/client/src/search/search.ts b/packages/client/src/search/search.ts index bf1e346..a3c1b65 100644 --- a/packages/client/src/search/search.ts +++ b/packages/client/src/search/search.ts @@ -3,6 +3,8 @@ import type { AppBskyGraphSearchStarterPacks, } from '@tsky/lexicons'; import type { Client } from '~/agent/client'; +import { Post } from '~/post'; +import { BasicStarterPack } from '~/starterpack'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; @@ -19,7 +21,10 @@ export class Search { ...options, }); - return res.data; + return { + ...res.data, + posts: res.data.posts.map((post) => new Post(this.client, post)), + }; }); } @@ -39,7 +44,12 @@ export class Search { ...options, }); - return res.data; + return { + ...res.data, + starterPacks: res.data.starterPacks.map( + (starterPack) => new BasicStarterPack(this.client, starterPack), + ), + }; }); } } diff --git a/packages/client/src/starterpack/starterpack.ts b/packages/client/src/starterpack/starterpack.ts index 459ce5f..6785ccc 100644 --- a/packages/client/src/starterpack/starterpack.ts +++ b/packages/client/src/starterpack/starterpack.ts @@ -1,5 +1,44 @@ +import type { + AppBskyActorDefs, + AppBskyFeedDefs, + AppBskyGraphDefs, + ComAtprotoLabelDefs, +} from '@tsky/lexicons'; +import { BasicActorProfile } from '~/actor'; import type { Client } from '~/agent/client'; -export class StarterPack { - constructor(private client: Client) {} +class Starterpack { + cid: string; + creator: AppBskyActorDefs.ProfileViewBasic; + indexedAt: string; + record: unknown; + uri: string; + joinedAllTimeCount?: number | undefined; + joinedWeekCount?: number | undefined; + labels?: ComAtprotoLabelDefs.Label[] | undefined; + $type?: string | undefined; + + constructor( + private client: Client, + payload: AppBskyGraphDefs.StarterPackView, + ) { + Object.assign(this, payload); + this.creator = new BasicActorProfile(this.client, payload.creator); + } +} + +export class BasicStarterPack + extends Starterpack + implements AppBskyGraphDefs.StarterPackViewBasic +{ + listItemCount?: number | undefined; +} + +export class StarterPack + extends Starterpack + implements AppBskyGraphDefs.StarterPackView +{ + feeds?: AppBskyFeedDefs.GeneratorView[]; + list?: AppBskyGraphDefs.ListViewBasic; + listItemsSample?: AppBskyGraphDefs.ListItemView[]; } diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index 5819b72..5c54345 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -1 +1,12 @@ export type RPCOptions = { signal?: AbortSignal; headers?: HeadersInit }; + +/** + * A reference to a record. + */ +export interface StrongRef { + /** The record's AT URI. */ + uri: string; + + /** The record's CID. */ + cid: string; +} diff --git a/packages/client/src/user/index.ts b/packages/client/src/user/index.ts index 99e5101..c55caf6 100644 --- a/packages/client/src/user/index.ts +++ b/packages/client/src/user/index.ts @@ -39,7 +39,7 @@ export class User extends Actor { likes(limit?: number, options: RPCOptions = {}) { return Paginator.init(async (cursor) => { const res = await this.client.get('app.bsky.feed.getActorLikes', { - params: { cursor, actor: this.identifier, limit }, + params: { cursor, actor: this.did, limit }, ...options, }); diff --git a/packages/client/src/utils/index.ts b/packages/client/src/utils/index.ts index 544dc7f..98b9548 100644 --- a/packages/client/src/utils/index.ts +++ b/packages/client/src/utils/index.ts @@ -1 +1,2 @@ export * from './paginator'; +export * from './parse'; diff --git a/packages/client/src/utils/parse.ts b/packages/client/src/utils/parse.ts new file mode 100644 index 0000000..dc49221 --- /dev/null +++ b/packages/client/src/utils/parse.ts @@ -0,0 +1,15 @@ +const ATP_URI_REGEX = + // proto- --did-------------- --name---------------- --path---- --query-- --hash-- + /^(at:\/\/)?((?:did:[a-z0-9:%-]+)|(?:[a-z0-9][a-z0-9.:-]*))(\/[^?#\s]*)?(\?[^#\s]+)?(#[^\s]+)?$/i; + +export function parseAtUri(uri: string): { + host: string; + collection: string; + rkey: string; +} { + const match = uri.match(ATP_URI_REGEX); + if (!match) throw new Error(`Invalid AT URI: ${uri}`); + const [, _proto, host, pathname] = match; + const [collection = '', rkey = ''] = pathname.split('/').filter(Boolean); + return { host, collection, rkey }; +} From 55a5f37e5824358a68ef9e2bc0651bc87809c1c9 Mon Sep 17 00:00:00 2001 From: Aditya Mathur Date: Sat, 15 Feb 2025 09:57:17 +0530 Subject: [PATCH 5/9] fix: updated agent to have instance without auth --- packages/client/src/tsky/tsky.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/client/src/tsky/tsky.ts b/packages/client/src/tsky/tsky.ts index cebabfc..60a6ba9 100644 --- a/packages/client/src/tsky/tsky.ts +++ b/packages/client/src/tsky/tsky.ts @@ -6,17 +6,19 @@ import { Agent } from '~/agent'; import type { CreateAgentOptions } from './types'; export async function createAgent( - credentials: CreateAgentOptions, + credentials?: CreateAgentOptions, options?: CredentialManagerOptions, ) { const manager = new CredentialManager( options ?? { service: 'https://bsky.social' }, ); - if ('session' in credentials) { - await manager.resume(credentials.session); - } else { - await manager.login(credentials); + if (credentials) { + if ('session' in credentials) { + await manager.resume(credentials.session); + } else { + await manager.login(credentials); + } } return new Agent(manager); From d5d3815ae86358dd6191b7e5db9106f9362460f9 Mon Sep 17 00:00:00 2001 From: Aditya Mathur Date: Sat, 15 Feb 2025 11:10:47 +0530 Subject: [PATCH 6/9] feat: added rimraf --- package.json | 7 ++-- packages/lex-cli/package.json | 2 +- packages/lexicons/package.json | 2 +- pnpm-lock.yaml | 58 ++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fec2f64..f0a988b 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,12 @@ }, "devDependencies": { "@biomejs/biome": "^1.9.4", - "nano-staged": "^0.8.0" + "nano-staged": "^0.8.0", + "rimraf": "^6.0.1" }, "nano-staged": { - "*.{js,ts,cjs,mjs,json}": ["biome check --write --"] + "*.{js,ts,cjs,mjs,json}": [ + "biome check --write --" + ] } } diff --git a/packages/lex-cli/package.json b/packages/lex-cli/package.json index bfdac8c..dda3016 100644 --- a/packages/lex-cli/package.json +++ b/packages/lex-cli/package.json @@ -12,7 +12,7 @@ "bin": "./dist/index.js", "scripts": { "build": "tsc", - "clean": "rm -rf dist", + "clean": "rimraf dist", "prepare": "pnpm run clean && pnpm run build" }, "dependencies": { diff --git a/packages/lexicons/package.json b/packages/lexicons/package.json index 2e8adef..c7e382b 100644 --- a/packages/lexicons/package.json +++ b/packages/lexicons/package.json @@ -19,7 +19,7 @@ "scripts": { "build": "tsx ./scripts/generate-types.ts && tsc", "check-version-change": "tsx ./scripts/check-version-change.ts && tsc", - "clean": "rm -rf dist && rm -rf lexicons", + "clean": "rimraf dist && rimraf lexicons", "prepare": "pnpm run clean && pnpm run build" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1b42c11..ec776f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: nano-staged: specifier: ^0.8.0 version: 0.8.0 + rimraf: + specifier: ^6.0.1 + version: 6.0.1 docs: devDependencies: @@ -2251,6 +2254,11 @@ packages: resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} hasBin: true + glob@11.0.1: + resolution: {integrity: sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==} + engines: {node: 20 || >=22} + hasBin: true + globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -2411,6 +2419,10 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + jackspeak@4.0.3: + resolution: {integrity: sha512-oSwM7q8PTHQWuZAlp995iPpPJ4Vkl7qT0ZRD+9duL9j2oBy6KcTfyxc8mEuHJYC+z/kbps80aJLkaNzTOrf/kw==} + engines: {node: 20 || >=22} + jose@5.9.6: resolution: {integrity: sha512-AMlnetc9+CV9asI19zHmrgS/WYsWUwCn2R7RzlbJWD7F9eWYUTGyBmU9o6PxngtLGOiDGPRu+Uc4fhKzbpteZQ==} @@ -2457,6 +2469,10 @@ packages: lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@11.0.2: + resolution: {integrity: sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==} + engines: {node: 20 || >=22} + lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -2554,6 +2570,10 @@ packages: minimalistic-crypto-utils@1.0.1: resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} + minimatch@10.0.1: + resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} + engines: {node: 20 || >=22} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -2701,6 +2721,10 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} + path-scurry@2.0.0: + resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} + engines: {node: 20 || >=22} + path-to-regexp@0.1.12: resolution: {integrity: sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==} @@ -2926,6 +2950,11 @@ packages: resolution: {integrity: sha512-l0OE8wL34P4nJH/H2ffoaniAokM2qSmrtXHmlpvYr5AVVX8msAyW0l8NVJFDxlSK4u3Uh/f41cQheDVdnYijwQ==} hasBin: true + rimraf@6.0.1: + resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} + engines: {node: 20 || >=22} + hasBin: true + roarr@7.21.1: resolution: {integrity: sha512-3niqt5bXFY1InKU8HKWqqYTYjtrBaxBMnXELXCXUYgtNYGUtZM5rB46HIC430AyacL95iEniGf7RgqsesykLmQ==} engines: {node: '>=18.0'} @@ -6195,6 +6224,15 @@ snapshots: package-json-from-dist: 1.0.1 path-scurry: 1.11.1 + glob@11.0.1: + dependencies: + foreground-child: 3.3.0 + jackspeak: 4.0.3 + minimatch: 10.0.1 + minipass: 7.1.2 + package-json-from-dist: 1.0.1 + path-scurry: 2.0.0 + globals@11.12.0: {} globals@15.12.0: {} @@ -6379,6 +6417,10 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + jackspeak@4.0.3: + dependencies: + '@isaacs/cliui': 8.0.2 + jose@5.9.6: {} js-tokens@4.0.0: {} @@ -6414,6 +6456,8 @@ snapshots: lru-cache@10.4.3: {} + lru-cache@11.0.2: {} + lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -6511,6 +6555,10 @@ snapshots: minimalistic-crypto-utils@1.0.1: {} + minimatch@10.0.1: + dependencies: + brace-expansion: 2.0.1 + minimatch@9.0.5: dependencies: brace-expansion: 2.0.1 @@ -6623,6 +6671,11 @@ snapshots: lru-cache: 10.4.3 minipass: 7.1.2 + path-scurry@2.0.0: + dependencies: + lru-cache: 11.0.2 + minipass: 7.1.2 + path-to-regexp@0.1.12: {} pathe@2.0.2: {} @@ -6857,6 +6910,11 @@ snapshots: dependencies: glob: 10.4.5 + rimraf@6.0.1: + dependencies: + glob: 11.0.1 + package-json-from-dist: 1.0.1 + roarr@7.21.1: dependencies: fast-printf: 1.6.10 From 5165db2c0a83d23db9739a93c340e92a58d119d6 Mon Sep 17 00:00:00 2001 From: Aditya Mathur <57684218+MathurAditya724@users.noreply.github.com> Date: Thu, 20 Feb 2025 09:11:45 +0530 Subject: [PATCH 7/9] chore: minor changes in profile function --- packages/client/src/actor/actor.ts | 23 +++++++++++++++++++++++ packages/client/src/agent/agent.ts | 10 +++------- packages/client/src/user/index.ts | 4 ++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/packages/client/src/actor/actor.ts b/packages/client/src/actor/actor.ts index 2c1bd13..cb72128 100644 --- a/packages/client/src/actor/actor.ts +++ b/packages/client/src/actor/actor.ts @@ -156,6 +156,29 @@ export class Actor { } } +// TODO: we can give this a better name +export class ActorWithProfileFunction extends Actor { + async profile() { + const data = await this.client + .get('app.bsky.actor.getProfile', { + params: { actor: this.did }, + }) + .then((res) => res.data); + + if ( + data.viewer?.knownFollowers?.followers && + data.viewer?.knownFollowers?.followers.length > 0 + ) { + data.viewer.knownFollowers.followers = + data.viewer.knownFollowers.followers.map( + (follower) => new BasicActorProfile(this.client, follower), + ); + } + + return data; + } +} + export class BasicActorProfile extends Actor implements AppBskyActorDefs.ProfileViewBasic diff --git a/packages/client/src/agent/agent.ts b/packages/client/src/agent/agent.ts index 8b2007c..c9e8772 100644 --- a/packages/client/src/agent/agent.ts +++ b/packages/client/src/agent/agent.ts @@ -5,7 +5,7 @@ import type { At, Queries, } from '@tsky/lexicons'; -import { DetailedActorProfile } from '~/actor'; +import { ActorWithProfileFunction } from '~/actor'; import { Feed } from '~/feed'; import { List } from '~/list'; import { Search } from '~/search'; @@ -30,12 +30,8 @@ export class Agent { /** * Get detailed profile view of an actor. Does not require auth, but contains relevant metadata with auth. */ - async actor(identifier: At.DID | At.Handle): Promise { - const res = await this.client.get('app.bsky.actor.getProfile', { - params: { actor: identifier }, - }); - - return new DetailedActorProfile(this.client, res.data); + async actor(identifier: At.DID): Promise { + return new ActorWithProfileFunction(this.client, identifier); } list(uri: string) { diff --git a/packages/client/src/user/index.ts b/packages/client/src/user/index.ts index c55caf6..c47a4c0 100644 --- a/packages/client/src/user/index.ts +++ b/packages/client/src/user/index.ts @@ -1,5 +1,5 @@ import type { AppBskyFeedGetTimeline } from '@tsky/lexicons'; -import { Actor } from '~/actor'; +import { ActorWithProfileFunction } from '~/actor'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; import { Mute } from './mute'; @@ -8,7 +8,7 @@ import { Preferences } from './preferences'; import { Suggestion } from './suggestion'; import { Unmute } from './unmute'; -export class User extends Actor { +export class User extends ActorWithProfileFunction { get preferences() { return new Preferences(this.client); } From fd489cbd6bdd036b80c936b8031c386a560d3594 Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Tue, 25 Feb 2025 01:18:55 +0900 Subject: [PATCH 8/9] fix(client): attempt to fix type errors --- packages/client/src/actor/actor.ts | 1 - packages/client/src/agent/agent.ts | 3 +- packages/client/src/agent/client.ts | 96 ++++++++++++++--------------- packages/client/src/types.ts | 11 ---- 4 files changed, 47 insertions(+), 64 deletions(-) diff --git a/packages/client/src/actor/actor.ts b/packages/client/src/actor/actor.ts index cb72128..22a4d0d 100644 --- a/packages/client/src/actor/actor.ts +++ b/packages/client/src/actor/actor.ts @@ -7,7 +7,6 @@ import type { ComAtprotoRepoStrongRef, } from '@tsky/lexicons'; import type { Client } from '~/agent/client'; -import { List } from '~/list'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; diff --git a/packages/client/src/agent/agent.ts b/packages/client/src/agent/agent.ts index c9e8772..31e7bb1 100644 --- a/packages/client/src/agent/agent.ts +++ b/packages/client/src/agent/agent.ts @@ -3,7 +3,6 @@ import type { AppBskyGraphGetStarterPack, AppBskyGraphGetStarterPacks, At, - Queries, } from '@tsky/lexicons'; import { ActorWithProfileFunction } from '~/actor'; import { Feed } from '~/feed'; @@ -15,7 +14,7 @@ import { Video } from '~/video'; import { Client } from './client'; export class Agent { - client: Client; + client: Client; constructor(private handler: CredentialManager) { // Initialize the client diff --git a/packages/client/src/agent/client.ts b/packages/client/src/agent/client.ts index 3ee3b3d..81b59ad 100644 --- a/packages/client/src/agent/client.ts +++ b/packages/client/src/agent/client.ts @@ -7,7 +7,7 @@ import type { } from '@atcute/client'; import type { At, Procedures, Queries } from '@tsky/lexicons'; import { parseAtUri } from '~/utils'; -import type { RPCOptions as GenericReqOptions, StrongRef } from '../types'; +import type { RPCOptions as GenericReqOptions } from '../types'; // From @atcute/client type OutputOf = T extends { @@ -19,7 +19,7 @@ type OutputOf = T extends { const NO_SESSION_ERROR = 'No session found. Please login to perform this action.'; -export class Client { +export class Client { xrpc: XRPC; crenditials: CredentialManager; @@ -34,10 +34,10 @@ export class Client { * @param options Options to include like parameters * @returns The response of the request */ - async get( + async get( nsid: K, - options: RPCOptions, - ): Promise>> { + options: RPCOptions, + ): Promise>> { // biome-ignore lint/suspicious/noExplicitAny: return this.xrpc.get(nsid as any, options); } @@ -48,10 +48,10 @@ export class Client { * @param options Options to include like input body or parameters * @returns The response of the request */ - async call( + async call( nsid: K, - options: RPCOptions, - ): Promise>> { + options: RPCOptions, + ): Promise>> { // biome-ignore lint/suspicious/noExplicitAny: return this.xrpc.call(nsid as any, options); } @@ -68,27 +68,26 @@ export class Client { * @param rkey The rkey to use. * @returns The record's AT URI and CID. */ - async createRecord( + async createRecord( nsid: K, - record: Omit, '$type' | 'createdAt'>, + record: Omit, '$type' | 'createdAt'>, rkey?: string, - ): Promise { - if (!this.crenditials.session) throw new Error(NO_SESSION_ERROR); - const response = await this.call( - 'com.atproto.repo.createRecord' as keyof P, - { - data: { - collection: nsid, - record: { - $type: nsid, - createdAt: new Date().toISOString(), - ...record, - }, - repo: this.crenditials.session.did, - ...(rkey ? { rkey } : {}), + ): Promise> { + if (!this.crenditials.session) { + throw new Error(NO_SESSION_ERROR); + } + const response = await this.call('com.atproto.repo.createRecord', { + data: { + collection: nsid, + record: { + $type: nsid, + createdAt: new Date().toISOString(), + ...record, }, - } as unknown as RPCOptions, - ); + repo: this.crenditials.session.did, + ...(rkey ? { rkey } : {}), + }, + }); return response.data; } @@ -103,23 +102,22 @@ export class Client { nsid: string, record: object, rkey: string, - ): Promise { - if (!this.crenditials.session) throw new Error(NO_SESSION_ERROR); - const response = await this.call( - 'com.atproto.repo.putRecord' as keyof P, - { - data: { - collection: nsid, - record: { - $type: nsid, - createdAt: new Date().toISOString(), - ...record, - }, - repo: this.crenditials.session.did, - rkey, + ): Promise> { + if (!this.crenditials.session) { + throw new Error(NO_SESSION_ERROR); + } + const response = await this.call('com.atproto.repo.putRecord', { + data: { + collection: nsid, + record: { + $type: nsid, + createdAt: new Date().toISOString(), + ...record, }, - } as unknown as RPCOptions, - ); + repo: this.crenditials.session.did, + rkey, + }, + }); return response.data; } @@ -132,14 +130,12 @@ export class Client { options: GenericReqOptions = {}, ): Promise { const { host: repo, collection, rkey } = parseAtUri(uri); - if (repo !== this.crenditials.session?.did) + if (repo !== this.crenditials.session?.did) { throw new Error('Can only delete own record.'); - await this.call( - 'com.atproto.repo.deleteRecord' as keyof P, - { - data: { collection, repo, rkey }, - ...options, - } as unknown as RPCOptions, - ); + } + await this.call('com.atproto.repo.deleteRecord', { + data: { collection, repo, rkey }, + ...options, + }); } } diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index 5c54345..5819b72 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -1,12 +1 @@ export type RPCOptions = { signal?: AbortSignal; headers?: HeadersInit }; - -/** - * A reference to a record. - */ -export interface StrongRef { - /** The record's AT URI. */ - uri: string; - - /** The record's CID. */ - cid: string; -} From 99d77ddcaa4955082a8010a61609f6dee690b52e Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Tue, 25 Feb 2025 01:19:40 +0900 Subject: [PATCH 9/9] fix(client): temporarily fill cid, uri, indexAt value with empty string --- packages/client/src/post/post.ts | 3 +++ packages/client/src/starterpack/starterpack.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/client/src/post/post.ts b/packages/client/src/post/post.ts index 1357867..7a7b598 100644 --- a/packages/client/src/post/post.ts +++ b/packages/client/src/post/post.ts @@ -44,6 +44,9 @@ export class Post implements AppBskyFeedDefs.PostView { ) { Object.assign(this, payload); this.author = new BasicActorProfile(this.client, payload.author); + this.cid = ''; // TODO: temporary type fix + this.uri = ''; // TODO: temporary type fix + this.indexedAt = ''; // TODO: temporary type fix } isOfCurrentUser() { diff --git a/packages/client/src/starterpack/starterpack.ts b/packages/client/src/starterpack/starterpack.ts index 6785ccc..98e4ca4 100644 --- a/packages/client/src/starterpack/starterpack.ts +++ b/packages/client/src/starterpack/starterpack.ts @@ -24,6 +24,9 @@ class Starterpack { ) { Object.assign(this, payload); this.creator = new BasicActorProfile(this.client, payload.creator); + this.cid = ''; // TODO: temporary type fix + this.uri = ''; // TODO: temporary type fix + this.indexedAt = ''; // TODO: temporary type fix } }