Skip to content

Commit

Permalink
ref docs for feed module
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysu committed Sep 20, 2023
1 parent d9c2112 commit 5e475fe
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 98 deletions.
54 changes: 0 additions & 54 deletions examples/node/scripts/feed/feed.ts

This file was deleted.

21 changes: 0 additions & 21 deletions examples/node/scripts/feed/feedHighlights.ts

This file was deleted.

29 changes: 29 additions & 0 deletions examples/node/scripts/feed/fetch.ts
Original file line number Diff line number Diff line change
@@ -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();
21 changes: 0 additions & 21 deletions examples/node/scripts/feed/forYou.ts

This file was deleted.

29 changes: 29 additions & 0 deletions examples/node/scripts/feed/highlights.ts
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 2 additions & 0 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export type {
LensTransactionStatusRequest,
ExploreProfilesRequest,
ExplorePublicationRequest,
FeedHighlightsRequest,
FeedRequest,

// options
TypedDataOptions,
Expand Down
34 changes: 34 additions & 0 deletions packages/client/src/submodules/feed/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -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<
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/submodules/feed/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type { FeedItemFragment, ReactionEventFragment } from './graphql/feed.generated';

export * from './Feed';

export type { FeedItemFragment, ReactionEventFragment } from './graphql/feed.generated';

0 comments on commit 5e475fe

Please sign in to comment.