diff --git a/examples/node/scripts/feed/feed.ts b/examples/node/scripts/feed/feed.ts deleted file mode 100644 index cc7d5a1596..0000000000 --- a/examples/node/scripts/feed/feed.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { - FeedEventItemType, - LensClient, - PublicationMetadataMainFocusType, - development, -} from '@lens-protocol/client'; - -async function main() { - const client = new LensClient({ - environment: development, - }); - - const profileId = 'PROFILE_ID'; - - const feedResult = await client.feed.fetch({ - where: { - for: 'PROFILE_ID', - }, - }); - - console.log(`Feed for ${profileId}`); - feedResult.unwrap().items.map((item) => { - console.log(`Feed item ${item.id}`); - console.log(`>> Root publication ${JSON.stringify(item.root)}`); - console.log(`>> Comments ${JSON.stringify(item.comments)}`); - console.log(`>> Mirrors ${JSON.stringify(item.mirrors)}`); - console.log(`>> Reactions ${JSON.stringify(item.reactions)}`); - }); - - const articlePostOnlyFeedResult = await client.feed.fetch({ - where: { - for: 'PROFILE_ID', - metadata: { - mainContentFocus: [PublicationMetadataMainFocusType.Article], - }, - feedEventItemTypes: [FeedEventItemType.Post], - }, - }); - - console.log( - `Article post only feed for ${profileId}`, - JSON.stringify(articlePostOnlyFeedResult.unwrap()), - ); - - const actionOnlyFeed = await client.feed.fetch({ - where: { - feedEventItemTypes: [FeedEventItemType.Acted], - }, - }); - - console.log(`Action only feed for ${profileId}`, JSON.stringify(actionOnlyFeed.unwrap())); -} - -main(); diff --git a/examples/node/scripts/feed/feedHighlights.ts b/examples/node/scripts/feed/feedHighlights.ts deleted file mode 100644 index d0c815a28e..0000000000 --- a/examples/node/scripts/feed/feedHighlights.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { LensClient, LimitType, development } from '@lens-protocol/client'; - -async function main() { - const client = new LensClient({ - environment: development, - }); - - const profileId = 'PROFILE_ID'; - - const feedHighlights = await client.feed.highlights({ - where: { for: profileId }, - limit: LimitType.Fifty, - }); - - console.log(`Feed highlights for ${profileId}`); - feedHighlights.unwrap().items.map((item) => { - console.log('Feed highlight item', JSON.stringify(item)); - }); -} - -main(); diff --git a/examples/node/scripts/feed/fetch.ts b/examples/node/scripts/feed/fetch.ts new file mode 100644 index 0000000000..1f2da1c2b8 --- /dev/null +++ b/examples/node/scripts/feed/fetch.ts @@ -0,0 +1,29 @@ +import { + getAuthenticatedClientFromEthersWallet, + getOwnedProfileId, +} from '../shared/getAuthenticatedClient'; +import { setupWallet } from '../shared/setupWallet'; + +async function main() { + const wallet = setupWallet(); + const client = await getAuthenticatedClientFromEthersWallet(wallet); + const profileId = await getOwnedProfileId(client, wallet.address); + + const result = await client.feed.fetch({ + where: { + for: profileId, + }, + }); + + const value = result.unwrap(); + + console.log( + `Feed for ${profileId}`, + value.items.map((item) => ({ + id: item.root.id, + metadata: item.root.metadata, + })), + ); +} + +main(); diff --git a/examples/node/scripts/feed/forYou.ts b/examples/node/scripts/feed/forYou.ts deleted file mode 100644 index abc7381c43..0000000000 --- a/examples/node/scripts/feed/forYou.ts +++ /dev/null @@ -1,21 +0,0 @@ -// `forYou` not yet ready to be exposed on production -// import { LensClient, development } from '@lens-protocol/client'; -// -// async function main() { -// const client = new LensClient({ -// environment: development, -// }); -// -// const profileId = 'PROFILE_ID'; -// -// const forYouFeedResult = await client.feed.forYou({ -// for: profileId, -// }); -// -// console.log(`For you feed for ${profileId}`); -// forYouFeedResult.unwrap().items.map((item) => { -// console.log(`For you feed item`, JSON.stringify(item)); -// }); -// } -// -// main(); diff --git a/examples/node/scripts/feed/highlights.ts b/examples/node/scripts/feed/highlights.ts new file mode 100644 index 0000000000..af92217944 --- /dev/null +++ b/examples/node/scripts/feed/highlights.ts @@ -0,0 +1,29 @@ +import { + getAuthenticatedClientFromEthersWallet, + getOwnedProfileId, +} from '../shared/getAuthenticatedClient'; +import { setupWallet } from '../shared/setupWallet'; + +async function main() { + const wallet = setupWallet(); + const client = await getAuthenticatedClientFromEthersWallet(wallet); + const profileId = await getOwnedProfileId(client, wallet.address); + + const result = await client.feed.highlights({ + where: { + for: profileId, + }, + }); + + const value = result.unwrap(); + + console.log( + `Feed highlights for ${profileId}`, + value.items.map((item) => ({ + id: item.id, + metadata: item.metadata, + })), + ); +} + +main(); diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 3393bd5953..5387e11f40 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -92,6 +92,8 @@ export type { LensTransactionStatusRequest, ExploreProfilesRequest, ExplorePublicationRequest, + FeedHighlightsRequest, + FeedRequest, // options TypedDataOptions, diff --git a/packages/client/src/submodules/feed/Feed.ts b/packages/client/src/submodules/feed/Feed.ts index 403a8bd7d9..74495c2c4d 100644 --- a/packages/client/src/submodules/feed/Feed.ts +++ b/packages/client/src/submodules/feed/Feed.ts @@ -34,6 +34,23 @@ export class Feed { this.authentication = authentication; } + /** + * Fetch feed items. + * + * ⚠️ Requires authenticated LensClient. + * + * @param request - Request object for the query + * @returns Array of {@link FeedItemFragment} wrapped in {@link PaginatedResult} + * + * @example + * ```ts + * const result = await client.feed.fetch({ + * where: { + * for: '0x123', + * }, + * }); + * ``` + */ async fetch( request: FeedRequest, ): PromiseResult< @@ -55,6 +72,23 @@ export class Feed { }); } + /** + * Fetch feed highlights. + * + * ⚠️ Requires authenticated LensClient. + * + * @param request - Request object for the query + * @returns Array of publications wrapped in {@link PaginatedResult} + * + * @example + * ```ts + * const result = await client.feed.highlights({ + * where: { + * for: '0x123', + * }, + * }); + * ``` + */ async highlights( request: FeedHighlightsRequest, ): PromiseResult< diff --git a/packages/client/src/submodules/feed/index.ts b/packages/client/src/submodules/feed/index.ts index fa5ec43fc1..68d7cb2b1f 100644 --- a/packages/client/src/submodules/feed/index.ts +++ b/packages/client/src/submodules/feed/index.ts @@ -1,3 +1,3 @@ -export type { FeedItemFragment, ReactionEventFragment } from './graphql/feed.generated'; - export * from './Feed'; + +export type { FeedItemFragment, ReactionEventFragment } from './graphql/feed.generated';