@atproto/bsky 0.0.282 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/api/app/bsky/feed/getFeed.d.ts +8 -0
- package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.js +17 -0
- package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
- package/dist/api/app/bsky/feed/getListFeed.d.ts +2 -1
- package/dist/api/app/bsky/feed/getListFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getListFeed.js +17 -4
- package/dist/api/app/bsky/feed/getListFeed.js.map +1 -1
- package/dist/api/app/bsky/feed/getTimeline.d.ts +2 -1
- package/dist/api/app/bsky/feed/getTimeline.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getTimeline.js +17 -4
- package/dist/api/app/bsky/feed/getTimeline.js.map +1 -1
- package/dist/api/app/bsky/notification/constants.d.ts +37 -0
- package/dist/api/app/bsky/notification/constants.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/constants.js +24 -0
- package/dist/api/app/bsky/notification/constants.js.map +1 -0
- package/dist/api/app/bsky/notification/getGroupedNotifications.d.ts +5 -0
- package/dist/api/app/bsky/notification/getGroupedNotifications.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/getGroupedNotifications.js +349 -0
- package/dist/api/app/bsky/notification/getGroupedNotifications.js.map +1 -0
- package/dist/api/app/bsky/notification/grouping/algoGravity.d.ts +4 -0
- package/dist/api/app/bsky/notification/grouping/algoGravity.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/grouping/algoGravity.js +141 -0
- package/dist/api/app/bsky/notification/grouping/algoGravity.js.map +1 -0
- package/dist/api/app/bsky/notification/grouping/algoLookback.d.ts +4 -0
- package/dist/api/app/bsky/notification/grouping/algoLookback.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/grouping/algoLookback.js +61 -0
- package/dist/api/app/bsky/notification/grouping/algoLookback.js.map +1 -0
- package/dist/api/app/bsky/notification/grouping/grouping.d.ts +41 -0
- package/dist/api/app/bsky/notification/grouping/grouping.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/grouping/grouping.js +54 -0
- package/dist/api/app/bsky/notification/grouping/grouping.js.map +1 -0
- package/dist/api/app/bsky/notification/grouping/shared.d.ts +8 -0
- package/dist/api/app/bsky/notification/grouping/shared.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/grouping/shared.js +20 -0
- package/dist/api/app/bsky/notification/grouping/shared.js.map +1 -0
- package/dist/api/app/bsky/notification/grouping/spotlight.d.ts +3 -0
- package/dist/api/app/bsky/notification/grouping/spotlight.d.ts.map +1 -0
- package/dist/api/app/bsky/notification/grouping/spotlight.js +114 -0
- package/dist/api/app/bsky/notification/grouping/spotlight.js.map +1 -0
- package/dist/api/app/bsky/notification/listNotifications.d.ts +0 -7
- package/dist/api/app/bsky/notification/listNotifications.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/listNotifications.js +7 -59
- package/dist/api/app/bsky/notification/listNotifications.js.map +1 -1
- package/dist/api/app/bsky/notification/updateSeen.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/updateSeen.js +4 -3
- package/dist/api/app/bsky/notification/updateSeen.js.map +1 -1
- package/dist/api/app/bsky/notification/util.d.ts +8 -0
- package/dist/api/app/bsky/notification/util.d.ts.map +1 -1
- package/dist/api/app/bsky/notification/util.js +55 -0
- package/dist/api/app/bsky/notification/util.js.map +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/util.d.ts +5 -0
- package/dist/api/util.d.ts.map +1 -1
- package/dist/api/util.js +4 -1
- package/dist/api/util.js.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -1
- package/dist/data-plane/server/db/pagination.d.ts +7 -0
- package/dist/data-plane/server/db/pagination.d.ts.map +1 -1
- package/dist/data-plane/server/db/pagination.js +18 -2
- package/dist/data-plane/server/db/pagination.js.map +1 -1
- package/dist/data-plane/server/db/tables/notification.d.ts +2 -1
- package/dist/data-plane/server/db/tables/notification.d.ts.map +1 -1
- package/dist/data-plane/server/db/tables/notification.js.map +1 -1
- package/dist/data-plane/server/indexing/index.d.ts +2 -0
- package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/follow.d.ts +6 -9
- package/dist/data-plane/server/indexing/plugins/follow.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/follow.js +13 -2
- package/dist/data-plane/server/indexing/plugins/follow.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/like.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/like.js +3 -2
- package/dist/data-plane/server/indexing/plugins/like.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/post.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/post.js +5 -4
- package/dist/data-plane/server/indexing/plugins/post.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/profile.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/profile.js +2 -1
- package/dist/data-plane/server/indexing/plugins/profile.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/repost.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/repost.js +3 -2
- package/dist/data-plane/server/indexing/plugins/repost.js.map +1 -1
- package/dist/data-plane/server/indexing/plugins/verification.d.ts.map +1 -1
- package/dist/data-plane/server/indexing/plugins/verification.js +3 -2
- package/dist/data-plane/server/indexing/plugins/verification.js.map +1 -1
- package/dist/data-plane/server/routes/feeds.d.ts +1 -1
- package/dist/data-plane/server/routes/feeds.d.ts.map +1 -1
- package/dist/data-plane/server/routes/feeds.js +35 -7
- package/dist/data-plane/server/routes/feeds.js.map +1 -1
- package/dist/data-plane/server/routes/notifs.d.ts.map +1 -1
- package/dist/data-plane/server/routes/notifs.js +67 -2
- package/dist/data-plane/server/routes/notifs.js.map +1 -1
- package/dist/hydration/hydrator.d.ts +2 -0
- package/dist/hydration/hydrator.d.ts.map +1 -1
- package/dist/hydration/hydrator.js +69 -1
- package/dist/hydration/hydrator.js.map +1 -1
- package/dist/lexicons/app/bsky/authManageNotifications.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/authManageNotifications.defs.js +1 -0
- package/dist/lexicons/app/bsky/authManageNotifications.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/getListFeed.defs.d.ts +4 -0
- package/dist/lexicons/app/bsky/feed/getListFeed.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/getListFeed.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/getListFeed.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/feed/getTimeline.defs.d.ts +4 -0
- package/dist/lexicons/app/bsky/feed/getTimeline.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/feed/getTimeline.defs.js +2 -0
- package/dist/lexicons/app/bsky/feed/getTimeline.defs.js.map +1 -1
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.d.ts +3 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.d.ts.map +1 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.defs.d.ts +299 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.defs.d.ts.map +1 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.defs.js +231 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.defs.js.map +1 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.js +6 -0
- package/dist/lexicons/app/bsky/notification/getGroupedNotifications.js.map +1 -0
- package/dist/lexicons/app/bsky/notification.d.ts +1 -0
- package/dist/lexicons/app/bsky/notification.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/notification.js +1 -0
- package/dist/lexicons/app/bsky/notification.js.map +1 -1
- package/dist/proto/bsky_connect.d.ts +10 -1
- package/dist/proto/bsky_connect.d.ts.map +1 -1
- package/dist/proto/bsky_connect.js +10 -1
- package/dist/proto/bsky_connect.js.map +1 -1
- package/dist/proto/bsky_pb.d.ts +120 -25
- package/dist/proto/bsky_pb.d.ts.map +1 -1
- package/dist/proto/bsky_pb.js +166 -27
- package/dist/proto/bsky_pb.js.map +1 -1
- package/dist/views/index.d.ts +3 -0
- package/dist/views/index.d.ts.map +1 -1
- package/dist/views/index.js +133 -0
- package/dist/views/index.js.map +1 -1
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @atproto/bsky
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#5568](https://github.com/bluesky-social/atproto/pull/5568) [`61c915a`](https://github.com/bluesky-social/atproto/commit/61c915a4b7304720496975a07f2f35d38a23bcd4) Thanks [@rafaeleyng](https://github.com/rafaeleyng)! - Add `app.bsky.notification.getGroupedNotifications`.
|
|
8
|
+
|
|
9
|
+
- [#5577](https://github.com/bluesky-social/atproto/pull/5577) [`3cd9fa6`](https://github.com/bluesky-social/atproto/commit/3cd9fa6013efad3ab57704ae804952be097e5d26) Thanks [@rafaeleyng](https://github.com/rafaeleyng)! - Return grouped notification related views as a typed union array and include views for the first ten items per group.
|
|
10
|
+
|
|
11
|
+
Remove the `utcOffset` parameter and allow notifications to group across day boundaries.
|
|
12
|
+
|
|
13
|
+
Use one endpoint-supplied timestamp for grouping throughout each request.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#5493](https://github.com/bluesky-social/atproto/pull/5493) [`cd736b3`](https://github.com/bluesky-social/atproto/commit/cd736b3dbbec957cf4eaa7e67fa5b8be8f8ae04e) Thanks [@mozzius](https://github.com/mozzius)! - Add `since` and `startCursor` to `getTimeline` and `getListFeed`, for reading everything strictly newer than a previously returned position.
|
|
18
|
+
|
|
19
|
+
- [#5571](https://github.com/bluesky-social/atproto/pull/5571) [`9ce8595`](https://github.com/bluesky-social/atproto/commit/9ce85957ce98c4b8a4ab6b51e0c24c4cd213d464) Thanks [@cuducos](https://github.com/cuducos)! - Route configured trending feeds through AppView's local Iris endpoint.
|
|
20
|
+
- Updated dependencies [[`13b7cb0`](https://github.com/bluesky-social/atproto/commit/13b7cb000d7358a570be46854a93e441c8fa791e), [`cd736b3`](https://github.com/bluesky-social/atproto/commit/cd736b3dbbec957cf4eaa7e67fa5b8be8f8ae04e), [`f8ed258`](https://github.com/bluesky-social/atproto/commit/f8ed25853dc91a16639decfaee2e0dcbb60808cd), [`61c915a`](https://github.com/bluesky-social/atproto/commit/61c915a4b7304720496975a07f2f35d38a23bcd4), [`0593d81`](https://github.com/bluesky-social/atproto/commit/0593d818bc2b7f8a40c9d0fe036bf39c7a4eecda), [`a6561d5`](https://github.com/bluesky-social/atproto/commit/a6561d54227756876a0901e4a87675df17972d32)]:
|
|
21
|
+
- @atproto/repo@0.11.0
|
|
22
|
+
- @atproto/api@0.23.0
|
|
23
|
+
- @atproto/crypto@0.5.7
|
|
24
|
+
- @atproto-labs/opentelemetry-node@0.3.0
|
|
25
|
+
- @atproto/sync@0.4.13
|
|
26
|
+
- @atproto/identity@0.5.16
|
|
27
|
+
- @atproto/xrpc-server@0.13.4
|
|
28
|
+
- @atproto/common@0.8.5
|
|
29
|
+
- @atproto/lex@0.3.14
|
|
30
|
+
- @atproto-labs/xrpc-utils@0.1.25
|
|
31
|
+
|
|
3
32
|
## 0.0.282
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DidString } from '@atproto/lex';
|
|
1
2
|
import { type Headers as HeadersMap, type Server } from '@atproto/xrpc-server';
|
|
2
3
|
import type { ServerConfig } from '../../../../config.js';
|
|
3
4
|
import type { AppContext } from '../../../../context.js';
|
|
@@ -22,6 +23,13 @@ export declare const irisUrlForFeed: (cfg: Pick<ServerConfig, 'irisUrl' | 'irisF
|
|
|
22
23
|
export declare const irisStagingUrlForFeed: (cfg: Pick<ServerConfig, 'irisStagingUrl' | 'irisStagingFeedUris'>, params: {
|
|
23
24
|
feed: string;
|
|
24
25
|
}) => string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Iris' local endpoint for configured trending feeds registered to Iris.
|
|
28
|
+
*/
|
|
29
|
+
export declare function irisUrlForTrendingFeed(cfg: Pick<ServerConfig, 'irisUrl' | 'irisServiceDid' | 'trendingFeedDid'>, params: {
|
|
30
|
+
feed: string;
|
|
31
|
+
feedDid: DidString;
|
|
32
|
+
}): string | undefined;
|
|
25
33
|
export type AlgoResponse = {
|
|
26
34
|
feedItems: AlgoResponseItem[];
|
|
27
35
|
resHeaders?: HeadersMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeed.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getFeed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getFeed.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getFeed.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,SAAS,EAIf,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,KAAK,OAAO,IAAI,UAAU,EAE1B,KAAK,MAAM,EAKZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAOxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAanE,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA0DvD;AAwGD;;;GAGG;AACH,eAAO,MAAM,cAAc,QACpB,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,cAAc,CAAC,UAC3C;IACN,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE;QACV,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;QAC5B,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;KAC7D,CAAA;CACF,KACA,MAAM,GAAG,SAaX,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAC3B,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,qBAAqB,CAAC,UACzD;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,KACvB,MAAM,GAAG,SACgE,CAAA;AAE5E;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,EACzE,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,GAC3C,MAAM,GAAG,SAAS,CAMpB;AAyHD,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,gBAAgB,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mapDefined, noUndefinedVals } from '@atproto/common';
|
|
2
2
|
import { XrpcInvalidResponseError, XrpcResponseError, xrpcSafe, } from '@atproto/lex';
|
|
3
|
+
import { AtUri } from '@atproto/syntax';
|
|
3
4
|
import { InvalidRequestError, ServerTimer, UpstreamFailureError, XRPCError, serverTimingHeader, } from '@atproto/xrpc-server';
|
|
4
5
|
import { Code, getServiceEndpoint, isDataplaneError, unpackIdentityServices, } from '../../../../data-plane/index.js';
|
|
5
6
|
import { app } from '../../../../lexicons/index.js';
|
|
@@ -127,6 +128,19 @@ export const irisUrlForFeed = (cfg, params) => {
|
|
|
127
128
|
* feed's registered feed generator.
|
|
128
129
|
*/
|
|
129
130
|
export const irisStagingUrlForFeed = (cfg, params) => cfg.irisStagingFeedUris?.has(params.feed) ? cfg.irisStagingUrl : undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Iris' local endpoint for configured trending feeds registered to Iris.
|
|
133
|
+
*/
|
|
134
|
+
export function irisUrlForTrendingFeed(cfg, params) {
|
|
135
|
+
const { irisUrl, irisServiceDid, trendingFeedDid } = cfg;
|
|
136
|
+
if (!irisUrl || !irisServiceDid || !trendingFeedDid)
|
|
137
|
+
return;
|
|
138
|
+
if (params.feedDid !== irisServiceDid)
|
|
139
|
+
return;
|
|
140
|
+
if (new AtUri(params.feed).host !== trendingFeedDid)
|
|
141
|
+
return;
|
|
142
|
+
return irisUrl;
|
|
143
|
+
}
|
|
130
144
|
const resolveSkeletonEndpoint = async (ctx, params) => {
|
|
131
145
|
const irisUrl = irisUrlForFeed(ctx.cfg, params);
|
|
132
146
|
if (irisUrl)
|
|
@@ -140,6 +154,9 @@ const resolveSkeletonEndpoint = async (ctx, params) => {
|
|
|
140
154
|
if (!feedDid) {
|
|
141
155
|
throw new InvalidRequestError('could not find feed');
|
|
142
156
|
}
|
|
157
|
+
const trendingIrisUrl = irisUrlForTrendingFeed(ctx.cfg, { feed, feedDid });
|
|
158
|
+
if (trendingIrisUrl)
|
|
159
|
+
return trendingIrisUrl;
|
|
143
160
|
let identity;
|
|
144
161
|
try {
|
|
145
162
|
identity = await ctx.dataplane.getIdentityByDid({ did: feedDid });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFeed.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAA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CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE;QACxB,MAAM,EACJ,IAAI,CAAC,MAAM,IAAI,IAAI;YACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAC7B,CAAC,CAAC,SAAS;QACf,YAAY,EACV,IAAI,CAAC,MAAM,IAAI,IAAI;YACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YACzD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,SAAS;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAC,CAAC,CAAA;IAEH,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAE1D,OAAO;QACL,GAAG,KAAK;QACR,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QACzE,SAAS;QACT,6EAA6E;QAC7E,sEAAsE;QACtE,MAAM,EACJ,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;KAC1E,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { mapDefined, noUndefinedVals } from '@atproto/common'\nimport {\n XrpcInvalidResponseError,\n XrpcResponseError,\n xrpcSafe,\n} from '@atproto/lex'\nimport {\n type Headers as HeadersMap,\n InvalidRequestError,\n type Server,\n ServerTimer,\n UpstreamFailureError,\n XRPCError,\n serverTimingHeader,\n} from '@atproto/xrpc-server'\nimport type { ServerConfig } from '../../../../config.js'\nimport type { AppContext } from '../../../../context.js'\nimport {\n Code,\n getServiceEndpoint,\n isDataplaneError,\n unpackIdentityServices,\n} from '../../../../data-plane/index.js'\nimport type { FeedItem } from '../../../../hydration/feed.js'\nimport type { HydrateCtx } from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type RulesFnInput,\n type SkeletonFnInput,\n createPipeline,\n} from '../../../../pipeline.js'\nimport type { GetIdentityByDidResponse } from '../../../../proto/bsky_pb.js'\nimport { getAtprotoPassthroughHeaders } from '../../../../util/headers.js'\nimport { BSKY_USER_AGENT, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const getFeed = createPipeline(\n skeleton,\n hydration,\n noBlocksOrMutes,\n presentation,\n )\n server.add(app.bsky.feed.getFeed, {\n auth: ctx.authVerifier.standardOptionalParameterized({\n lxmCheck: (method) => {\n return (\n method === app.bsky.feed.getFeedSkeleton.$lxm ||\n method === app.bsky.feed.getFeed.$lxm\n )\n },\n skipAudCheck: true,\n }),\n handler: async ({ params, auth, req, signal }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({\n labelers,\n viewer,\n features: ctx.featureGatesClient.scope(\n ctx.featureGatesClient.parseUserContextFromHandler({ viewer, req }),\n ),\n })\n const headers = noUndefinedVals({\n 'user-agent': BSKY_USER_AGENT,\n authorization: req.headers['authorization'],\n 'accept-language': req.headers['accept-language'],\n ...getAtprotoPassthroughHeaders(req),\n })\n // @NOTE feed cursors should not be affected by appview swap\n // Do not refill filtered pages. Overfetching from algorithmic feeds can\n // advance their state and prevent omitted items from appearing later.\n const result = await getFeed(\n { ...params, hydrateCtx, headers, signal },\n ctx,\n )\n const {\n timerSkele,\n timerHydr,\n resHeaders: feedResHeaders,\n ...body\n } = result\n\n return {\n encoding: 'application/json',\n body,\n headers: {\n ...feedResHeaders,\n ...resHeaders({ labelers: hydrateCtx.labelers }),\n 'server-timing': serverTimingHeader([timerSkele, timerHydr]),\n },\n }\n },\n })\n}\n\nconst skeleton = async (\n inputs: SkeletonFnInput<Context, Params>,\n): Promise<Skeleton> => {\n const { ctx, params } = inputs\n const timerSkele = new ServerTimer('skele').start()\n const {\n feedItems: algoItems,\n reqId,\n cursor,\n resHeaders,\n ...passthrough\n } = await skeletonFromFeedGen(ctx, params)\n\n return {\n cursor,\n items: algoItems,\n reqId,\n timerSkele: timerSkele.stop(),\n timerHydr: new ServerTimer('hydr').start(),\n resHeaders,\n passthrough,\n }\n}\n\nconst hydration = async (\n inputs: HydrationFnInput<Context, Params, Skeleton>,\n) => {\n const { ctx, params, skeleton } = inputs\n const timerHydr = new ServerTimer('hydr').start()\n const hydration = await ctx.hydrator.hydrateFeedItems(\n skeleton.items,\n params.hydrateCtx,\n {\n knownLikers:\n !!params.hydrateCtx.viewer &&\n params.hydrateCtx.features.checkGate(\n params.hydrateCtx.features.Gate.KnownLikersFeedEnable,\n ),\n },\n )\n skeleton.timerHydr = timerHydr.stop()\n return hydration\n}\n\nconst noBlocksOrMutes = (inputs: RulesFnInput<Context, Params, Skeleton>) => {\n const { ctx, skeleton, hydration } = inputs\n skeleton.items = skeleton.items.filter((item) => {\n const bam = ctx.views.feedItemBlocksAndMutes(item, hydration)\n return (\n !bam.authorBlocked &&\n !bam.authorMuted &&\n !bam.authorQuotepostMuted &&\n !bam.originatorBlocked &&\n !bam.originatorMuted &&\n !bam.originatorRepostMuted &&\n !bam.ancestorAuthorBlocked\n )\n })\n\n return skeleton\n}\n\nconst presentation = (\n inputs: PresentationFnInput<Context, Params, Skeleton>,\n) => {\n const { ctx, skeleton, hydration } = inputs\n const feed = mapDefined(skeleton.items, (item) => {\n const post = ctx.views.feedViewPost(item, hydration)\n if (!post) return\n return {\n ...post,\n feedContext: item.feedContext,\n }\n })\n return {\n feed: feed.map((fi) => ({ ...fi, reqId: skeleton.reqId })),\n cursor: skeleton.cursor,\n timerSkele: skeleton.timerSkele,\n timerHydr: skeleton.timerHydr,\n resHeaders: skeleton.resHeaders,\n ...skeleton.passthrough,\n }\n}\n\ntype Context = AppContext\n\ntype Params = app.bsky.feed.getFeed.$Params & {\n hydrateCtx: HydrateCtx\n headers: HeadersMap\n signal: AbortSignal\n}\n\ntype Skeleton = {\n items: AlgoResponseItem[]\n reqId?: string\n passthrough: Record<string, unknown> // pass through additional items in feedgen response\n resHeaders?: HeadersMap\n cursor?: string\n timerSkele: ServerTimer\n timerHydr: ServerTimer\n}\n\n/**\n * Iris' endpoint, when it should serve this request in place of the feed's\n * registered feed generator (seeemore).\n */\nexport const irisUrlForFeed = (\n cfg: Pick<ServerConfig, 'irisUrl' | 'irisFeedUris'>,\n params: {\n feed: string\n hydrateCtx: {\n viewer: HydrateCtx['viewer']\n features: Pick<HydrateCtx['features'], 'Gate' | 'checkGate'>\n }\n },\n): string | undefined => {\n const { irisUrl } = cfg\n if (!irisUrl) return\n if (!cfg.irisFeedUris?.has(params.feed)) return\n if (!params.hydrateCtx.viewer) return\n if (\n !params.hydrateCtx.features.checkGate(\n params.hydrateCtx.features.Gate.IrisFeed,\n )\n ) {\n return\n }\n return irisUrl\n}\n\n/**\n * Iris staging's endpoint, when it should serve this request in place of the\n * feed's registered feed generator.\n */\nexport const irisStagingUrlForFeed = (\n cfg: Pick<ServerConfig, 'irisStagingUrl' | 'irisStagingFeedUris'>,\n params: { feed: string },\n): string | undefined =>\n cfg.irisStagingFeedUris?.has(params.feed) ? cfg.irisStagingUrl : undefined\n\nconst resolveSkeletonEndpoint = async (\n ctx: Context,\n params: Params,\n): Promise<string> => {\n const irisUrl = irisUrlForFeed(ctx.cfg, params)\n if (irisUrl) return irisUrl\n\n const irisStagingUrl = irisStagingUrlForFeed(ctx.cfg, params)\n if (irisStagingUrl) return irisStagingUrl\n\n const { feed } = params\n const found = await ctx.hydrator.feed.getFeedGens([feed], true)\n const feedDid = found.get(feed)?.record.did\n if (!feedDid) {\n throw new InvalidRequestError('could not find feed')\n }\n\n let identity: GetIdentityByDidResponse\n try {\n identity = await ctx.dataplane.getIdentityByDid({ did: feedDid })\n } catch (err) {\n if (isDataplaneError(err, Code.NotFound)) {\n throw new InvalidRequestError(`could not resolve identity: ${feedDid}`)\n }\n throw err\n }\n\n const services = unpackIdentityServices(identity.services)\n const fgEndpoint = getServiceEndpoint(services, {\n id: 'bsky_fg',\n type: 'BskyFeedGenerator',\n })\n if (!fgEndpoint) {\n throw new InvalidRequestError(\n `invalid feed generator service details in did document: ${feedDid}`,\n )\n }\n\n return fgEndpoint\n}\n\nconst skeletonFromFeedGen = async (\n ctx: Context,\n params: Params,\n): Promise<AlgoResponse> => {\n const { headers } = params\n const endpoint = await resolveSkeletonEndpoint(ctx, params)\n\n // @TODO currently passthrough auth headers from pds\n const result = await xrpcSafe(endpoint, app.bsky.feed.getFeedSkeleton, {\n strictResponseProcessing: false,\n signal: AbortSignal.any([\n params.signal,\n AbortSignal.timeout(ctx.cfg.feedGenSkeletonTimeout),\n ]),\n headers,\n params: {\n feed: params.feed,\n // The feedgen is not guaranteed to honor the limit, but we try it.\n limit: params.limit,\n cursor: params.cursor,\n },\n })\n\n if (!result.success) {\n const cause = result.reason\n\n // Pass through structurally valid XRPC error response (4xx/5xx), such as\n // auth errors\n if (cause instanceof XrpcResponseError) {\n const { status, body } = cause.toDownstreamError()\n throw new XRPCError(status, body.message, body.error, { cause })\n }\n\n // The response does not match the schema\n if (cause instanceof XrpcInvalidResponseError) {\n throw new UpstreamFailureError(\n 'feed provided an invalid response',\n 'InvalidFeedResponse',\n { cause },\n )\n }\n\n // Typically a network error.\n throw new UpstreamFailureError('feed unavailable', undefined, { cause })\n }\n\n const { feed: feedSkele, cursor, ...skele } = result.body\n const feedItems = feedSkele.slice(0, params.limit).map((item) => ({\n post: { uri: item.post },\n repost:\n item.reason != null &&\n app.bsky.feed.defs.skeletonReasonRepost.$isTypeOf(item.reason)\n ? { uri: item.reason.repost }\n : undefined,\n authorPinned:\n item.reason != null &&\n app.bsky.feed.defs.skeletonReasonPin.$isTypeOf(item.reason)\n ? true\n : undefined,\n feedContext: item.feedContext,\n }))\n\n const contentLang = result.headers.get('content-language')\n\n return {\n ...skele,\n resHeaders: contentLang ? { 'content-language': contentLang } : undefined,\n feedItems,\n // An empty feed-generator page ends pagination even if it includes a cursor.\n // Also prevent loops if the custom feed echoes the input cursor back.\n cursor:\n feedSkele.length === 0 || cursor === params.cursor ? undefined : cursor,\n }\n}\n\nexport type AlgoResponse = {\n feedItems: AlgoResponseItem[]\n resHeaders?: HeadersMap\n cursor?: string\n reqId?: string\n}\n\nexport type AlgoResponseItem = FeedItem & {\n feedContext?: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getFeed.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAEL,wBAAwB,EACxB,iBAAiB,EACjB,QAAQ,GACT,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAEL,mBAAmB,EAEnB,WAAW,EACX,oBAAoB,EACpB,SAAS,EACT,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,IAAI,EACJ,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iCAAiC,CAAA;AAGxC,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAKL,cAAc,GACf,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE9D,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,OAAO,GAAG,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GAAG,EAAE,IAAI,CAAC,IAAI,EAAE;QACxB,MAAM,EACJ,IAAI,CAAC,MAAM,IAAI,IAAI;YACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAC7B,CAAC,CAAC,SAAS;QACf,YAAY,EACV,IAAI,CAAC,MAAM,IAAI,IAAI;YACnB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YACzD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,SAAS;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;KAC9B,CAAC,CAAC,CAAA;IAEH,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAE1D,OAAO;QACL,GAAG,KAAK;QACR,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QACzE,SAAS;QACT,6EAA6E;QAC7E,sEAAsE;QACtE,MAAM,EACJ,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;KAC1E,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { mapDefined, noUndefinedVals } from '@atproto/common'\nimport {\n type DidString,\n XrpcInvalidResponseError,\n XrpcResponseError,\n xrpcSafe,\n} from '@atproto/lex'\nimport { AtUri } from '@atproto/syntax'\nimport {\n type Headers as HeadersMap,\n InvalidRequestError,\n type Server,\n ServerTimer,\n UpstreamFailureError,\n XRPCError,\n serverTimingHeader,\n} from '@atproto/xrpc-server'\nimport type { ServerConfig } from '../../../../config.js'\nimport type { AppContext } from '../../../../context.js'\nimport {\n Code,\n getServiceEndpoint,\n isDataplaneError,\n unpackIdentityServices,\n} from '../../../../data-plane/index.js'\nimport type { FeedItem } from '../../../../hydration/feed.js'\nimport type { HydrateCtx } from '../../../../hydration/hydrator.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n type HydrationFnInput,\n type PresentationFnInput,\n type RulesFnInput,\n type SkeletonFnInput,\n createPipeline,\n} from '../../../../pipeline.js'\nimport type { GetIdentityByDidResponse } from '../../../../proto/bsky_pb.js'\nimport { getAtprotoPassthroughHeaders } from '../../../../util/headers.js'\nimport { BSKY_USER_AGENT, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const getFeed = createPipeline(\n skeleton,\n hydration,\n noBlocksOrMutes,\n presentation,\n )\n server.add(app.bsky.feed.getFeed, {\n auth: ctx.authVerifier.standardOptionalParameterized({\n lxmCheck: (method) => {\n return (\n method === app.bsky.feed.getFeedSkeleton.$lxm ||\n method === app.bsky.feed.getFeed.$lxm\n )\n },\n skipAudCheck: true,\n }),\n handler: async ({ params, auth, req, signal }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({\n labelers,\n viewer,\n features: ctx.featureGatesClient.scope(\n ctx.featureGatesClient.parseUserContextFromHandler({ viewer, req }),\n ),\n })\n const headers = noUndefinedVals({\n 'user-agent': BSKY_USER_AGENT,\n authorization: req.headers['authorization'],\n 'accept-language': req.headers['accept-language'],\n ...getAtprotoPassthroughHeaders(req),\n })\n // @NOTE feed cursors should not be affected by appview swap\n // Do not refill filtered pages. Overfetching from algorithmic feeds can\n // advance their state and prevent omitted items from appearing later.\n const result = await getFeed(\n { ...params, hydrateCtx, headers, signal },\n ctx,\n )\n const {\n timerSkele,\n timerHydr,\n resHeaders: feedResHeaders,\n ...body\n } = result\n\n return {\n encoding: 'application/json',\n body,\n headers: {\n ...feedResHeaders,\n ...resHeaders({ labelers: hydrateCtx.labelers }),\n 'server-timing': serverTimingHeader([timerSkele, timerHydr]),\n },\n }\n },\n })\n}\n\nconst skeleton = async (\n inputs: SkeletonFnInput<Context, Params>,\n): Promise<Skeleton> => {\n const { ctx, params } = inputs\n const timerSkele = new ServerTimer('skele').start()\n const {\n feedItems: algoItems,\n reqId,\n cursor,\n resHeaders,\n ...passthrough\n } = await skeletonFromFeedGen(ctx, params)\n\n return {\n cursor,\n items: algoItems,\n reqId,\n timerSkele: timerSkele.stop(),\n timerHydr: new ServerTimer('hydr').start(),\n resHeaders,\n passthrough,\n }\n}\n\nconst hydration = async (\n inputs: HydrationFnInput<Context, Params, Skeleton>,\n) => {\n const { ctx, params, skeleton } = inputs\n const timerHydr = new ServerTimer('hydr').start()\n const hydration = await ctx.hydrator.hydrateFeedItems(\n skeleton.items,\n params.hydrateCtx,\n {\n knownLikers:\n !!params.hydrateCtx.viewer &&\n params.hydrateCtx.features.checkGate(\n params.hydrateCtx.features.Gate.KnownLikersFeedEnable,\n ),\n },\n )\n skeleton.timerHydr = timerHydr.stop()\n return hydration\n}\n\nconst noBlocksOrMutes = (inputs: RulesFnInput<Context, Params, Skeleton>) => {\n const { ctx, skeleton, hydration } = inputs\n skeleton.items = skeleton.items.filter((item) => {\n const bam = ctx.views.feedItemBlocksAndMutes(item, hydration)\n return (\n !bam.authorBlocked &&\n !bam.authorMuted &&\n !bam.authorQuotepostMuted &&\n !bam.originatorBlocked &&\n !bam.originatorMuted &&\n !bam.originatorRepostMuted &&\n !bam.ancestorAuthorBlocked\n )\n })\n\n return skeleton\n}\n\nconst presentation = (\n inputs: PresentationFnInput<Context, Params, Skeleton>,\n) => {\n const { ctx, skeleton, hydration } = inputs\n const feed = mapDefined(skeleton.items, (item) => {\n const post = ctx.views.feedViewPost(item, hydration)\n if (!post) return\n return {\n ...post,\n feedContext: item.feedContext,\n }\n })\n return {\n feed: feed.map((fi) => ({ ...fi, reqId: skeleton.reqId })),\n cursor: skeleton.cursor,\n timerSkele: skeleton.timerSkele,\n timerHydr: skeleton.timerHydr,\n resHeaders: skeleton.resHeaders,\n ...skeleton.passthrough,\n }\n}\n\ntype Context = AppContext\n\ntype Params = app.bsky.feed.getFeed.$Params & {\n hydrateCtx: HydrateCtx\n headers: HeadersMap\n signal: AbortSignal\n}\n\ntype Skeleton = {\n items: AlgoResponseItem[]\n reqId?: string\n passthrough: Record<string, unknown> // pass through additional items in feedgen response\n resHeaders?: HeadersMap\n cursor?: string\n timerSkele: ServerTimer\n timerHydr: ServerTimer\n}\n\n/**\n * Iris' endpoint, when it should serve this request in place of the feed's\n * registered feed generator (seeemore).\n */\nexport const irisUrlForFeed = (\n cfg: Pick<ServerConfig, 'irisUrl' | 'irisFeedUris'>,\n params: {\n feed: string\n hydrateCtx: {\n viewer: HydrateCtx['viewer']\n features: Pick<HydrateCtx['features'], 'Gate' | 'checkGate'>\n }\n },\n): string | undefined => {\n const { irisUrl } = cfg\n if (!irisUrl) return\n if (!cfg.irisFeedUris?.has(params.feed)) return\n if (!params.hydrateCtx.viewer) return\n if (\n !params.hydrateCtx.features.checkGate(\n params.hydrateCtx.features.Gate.IrisFeed,\n )\n ) {\n return\n }\n return irisUrl\n}\n\n/**\n * Iris staging's endpoint, when it should serve this request in place of the\n * feed's registered feed generator.\n */\nexport const irisStagingUrlForFeed = (\n cfg: Pick<ServerConfig, 'irisStagingUrl' | 'irisStagingFeedUris'>,\n params: { feed: string },\n): string | undefined =>\n cfg.irisStagingFeedUris?.has(params.feed) ? cfg.irisStagingUrl : undefined\n\n/**\n * Iris' local endpoint for configured trending feeds registered to Iris.\n */\nexport function irisUrlForTrendingFeed(\n cfg: Pick<ServerConfig, 'irisUrl' | 'irisServiceDid' | 'trendingFeedDid'>,\n params: { feed: string; feedDid: DidString },\n): string | undefined {\n const { irisUrl, irisServiceDid, trendingFeedDid } = cfg\n if (!irisUrl || !irisServiceDid || !trendingFeedDid) return\n if (params.feedDid !== irisServiceDid) return\n if (new AtUri(params.feed).host !== trendingFeedDid) return\n return irisUrl\n}\n\nconst resolveSkeletonEndpoint = async (\n ctx: Context,\n params: Params,\n): Promise<string> => {\n const irisUrl = irisUrlForFeed(ctx.cfg, params)\n if (irisUrl) return irisUrl\n\n const irisStagingUrl = irisStagingUrlForFeed(ctx.cfg, params)\n if (irisStagingUrl) return irisStagingUrl\n\n const { feed } = params\n const found = await ctx.hydrator.feed.getFeedGens([feed], true)\n const feedDid = found.get(feed)?.record.did\n if (!feedDid) {\n throw new InvalidRequestError('could not find feed')\n }\n\n const trendingIrisUrl = irisUrlForTrendingFeed(ctx.cfg, { feed, feedDid })\n if (trendingIrisUrl) return trendingIrisUrl\n\n let identity: GetIdentityByDidResponse\n try {\n identity = await ctx.dataplane.getIdentityByDid({ did: feedDid })\n } catch (err) {\n if (isDataplaneError(err, Code.NotFound)) {\n throw new InvalidRequestError(`could not resolve identity: ${feedDid}`)\n }\n throw err\n }\n\n const services = unpackIdentityServices(identity.services)\n const fgEndpoint = getServiceEndpoint(services, {\n id: 'bsky_fg',\n type: 'BskyFeedGenerator',\n })\n if (!fgEndpoint) {\n throw new InvalidRequestError(\n `invalid feed generator service details in did document: ${feedDid}`,\n )\n }\n\n return fgEndpoint\n}\n\nconst skeletonFromFeedGen = async (\n ctx: Context,\n params: Params,\n): Promise<AlgoResponse> => {\n const { headers } = params\n const endpoint = await resolveSkeletonEndpoint(ctx, params)\n\n // @TODO currently passthrough auth headers from pds\n const result = await xrpcSafe(endpoint, app.bsky.feed.getFeedSkeleton, {\n strictResponseProcessing: false,\n signal: AbortSignal.any([\n params.signal,\n AbortSignal.timeout(ctx.cfg.feedGenSkeletonTimeout),\n ]),\n headers,\n params: {\n feed: params.feed,\n // The feedgen is not guaranteed to honor the limit, but we try it.\n limit: params.limit,\n cursor: params.cursor,\n },\n })\n\n if (!result.success) {\n const cause = result.reason\n\n // Pass through structurally valid XRPC error response (4xx/5xx), such as\n // auth errors\n if (cause instanceof XrpcResponseError) {\n const { status, body } = cause.toDownstreamError()\n throw new XRPCError(status, body.message, body.error, { cause })\n }\n\n // The response does not match the schema\n if (cause instanceof XrpcInvalidResponseError) {\n throw new UpstreamFailureError(\n 'feed provided an invalid response',\n 'InvalidFeedResponse',\n { cause },\n )\n }\n\n // Typically a network error.\n throw new UpstreamFailureError('feed unavailable', undefined, { cause })\n }\n\n const { feed: feedSkele, cursor, ...skele } = result.body\n const feedItems = feedSkele.slice(0, params.limit).map((item) => ({\n post: { uri: item.post },\n repost:\n item.reason != null &&\n app.bsky.feed.defs.skeletonReasonRepost.$isTypeOf(item.reason)\n ? { uri: item.reason.repost }\n : undefined,\n authorPinned:\n item.reason != null &&\n app.bsky.feed.defs.skeletonReasonPin.$isTypeOf(item.reason)\n ? true\n : undefined,\n feedContext: item.feedContext,\n }))\n\n const contentLang = result.headers.get('content-language')\n\n return {\n ...skele,\n resHeaders: contentLang ? { 'content-language': contentLang } : undefined,\n feedItems,\n // An empty feed-generator page ends pagination even if it includes a cursor.\n // Also prevent loops if the custom feed echoes the input cursor back.\n cursor:\n feedSkele.length === 0 || cursor === params.cursor ? undefined : cursor,\n }\n}\n\nexport type AlgoResponse = {\n feedItems: AlgoResponseItem[]\n resHeaders?: HeadersMap\n cursor?: string\n reqId?: string\n}\n\nexport type AlgoResponseItem = FeedItem & {\n feedContext?: string\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Server } from '@atproto/xrpc-server';
|
|
2
2
|
import type { AppContext } from '../../../../context.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type DataPlaneClient } from '../../../../data-plane/index.js';
|
|
4
4
|
import type { FeedItem } from '../../../../hydration/feed.js';
|
|
5
5
|
import { type HydrateCtx, type Hydrator } from '../../../../hydration/hydrator.js';
|
|
6
6
|
import { app } from '../../../../lexicons/index.js';
|
|
@@ -21,6 +21,7 @@ type Params = app.bsky.feed.getListFeed.$Params & {
|
|
|
21
21
|
type Skeleton = {
|
|
22
22
|
items: FeedItem[];
|
|
23
23
|
cursor?: string;
|
|
24
|
+
startCursor?: string;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
|
26
27
|
//# sourceMappingURL=getListFeed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListFeed.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getListFeed.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"getListFeed.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getListFeed.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,QAAQ,EAEd,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAGnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAGvD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAyCvD;AAED,eAAO,MAAM,QAAQ,WAAkB;IACrC,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,KAAG,OAAO,CAAC,QAAQ,CAuBnB,CAAA;AAyED,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,eAAe,CAAA;CAC3B,CAAA;AAED,KAAK,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,CAAA;AAE5E,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mapDefined } from '@atproto/common';
|
|
2
|
+
import { asInvalidRequest, } from '../../../../data-plane/index.js';
|
|
2
3
|
import { mergeStates, } from '../../../../hydration/hydrator.js';
|
|
3
4
|
import { parseString } from '../../../../hydration/util.js';
|
|
4
5
|
import { app } from '../../../../lexicons/index.js';
|
|
@@ -20,6 +21,10 @@ export default function (server, ctx) {
|
|
|
20
21
|
const result = await fillPage({
|
|
21
22
|
cursor: params.cursor,
|
|
22
23
|
limit: params.limit,
|
|
24
|
+
// @NOTE the dataplane echoes `since` back as the cursor once the
|
|
25
|
+
// bounded range is exhausted. Refilling past it would read below the
|
|
26
|
+
// boundary.
|
|
27
|
+
terminalCursor: params.since,
|
|
23
28
|
fetch: ({ cursor, limit }) => getListFeed({ ...params, cursor, limit, hydrateCtx }, ctx),
|
|
24
29
|
items: (r) => r.feed,
|
|
25
30
|
});
|
|
@@ -35,13 +40,16 @@ export default function (server, ctx) {
|
|
|
35
40
|
export const skeleton = async (inputs) => {
|
|
36
41
|
const { ctx, params } = inputs;
|
|
37
42
|
if (clearlyBadCursor(params.cursor)) {
|
|
38
|
-
return { items: [] };
|
|
43
|
+
return { items: [], cursor: params.since };
|
|
39
44
|
}
|
|
40
|
-
const res = await ctx.dataplane
|
|
45
|
+
const res = await ctx.dataplane
|
|
46
|
+
.getListFeed({
|
|
41
47
|
listUri: params.list,
|
|
42
48
|
limit: params.limit,
|
|
43
49
|
cursor: params.cursor,
|
|
44
|
-
|
|
50
|
+
since: params.since,
|
|
51
|
+
})
|
|
52
|
+
.catch(asInvalidRequest());
|
|
45
53
|
return {
|
|
46
54
|
items: res.items.map((item) => ({
|
|
47
55
|
post: { uri: item.uri, cid: item.cid || undefined },
|
|
@@ -50,6 +58,7 @@ export const skeleton = async (inputs) => {
|
|
|
50
58
|
: undefined,
|
|
51
59
|
})),
|
|
52
60
|
cursor: parseString(res.cursor),
|
|
61
|
+
startCursor: parseString(res.startCursor),
|
|
53
62
|
};
|
|
54
63
|
};
|
|
55
64
|
const hydration = async (inputs) => {
|
|
@@ -81,7 +90,11 @@ const noBlocksOrMutes = (inputs) => {
|
|
|
81
90
|
const presentation = (inputs) => {
|
|
82
91
|
const { ctx, skeleton, hydration } = inputs;
|
|
83
92
|
const feed = mapDefined(skeleton.items, (item) => ctx.views.feedViewPost(item, hydration));
|
|
84
|
-
return {
|
|
93
|
+
return {
|
|
94
|
+
feed,
|
|
95
|
+
cursor: skeleton.cursor,
|
|
96
|
+
startCursor: skeleton.startCursor,
|
|
97
|
+
};
|
|
85
98
|
};
|
|
86
99
|
const getBlocks = async (input) => {
|
|
87
100
|
const { ctx, skeleton, params } = input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getListFeed.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getListFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"getListFeed.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getListFeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,EAEL,gBAAgB,GACjB,MAAM,iCAAiC,CAAA;AAExC,OAAO,EAIL,WAAW,GACZ,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,cAAc,E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UAAU,CAAC,CAAA;AAChF,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { AtUriString, DidString } from '@atproto/syntax'\nimport type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport {\n type DataPlaneClient,\n asInvalidRequest,\n} from '../../../../data-plane/index.js'\nimport type { FeedItem } from '../../../../hydration/feed.js'\nimport {\n type HydrateCtx,\n type HydrationState,\n type Hydrator,\n mergeStates,\n} from '../../../../hydration/hydrator.js'\nimport { parseString } from '../../../../hydration/util.js'\nimport { app } from '../../../../lexicons/index.js'\nimport { createPipeline } from '../../../../pipeline.js'\nimport { uriToDid } from '../../../../util/uris.js'\nimport type { Views } from '../../../../views/index.js'\nimport { clearlyBadCursor, fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const getListFeed = createPipeline(\n skeleton,\n hydration,\n noBlocksOrMutes,\n presentation,\n )\n server.add(app.bsky.feed.getListFeed, {\n auth: ctx.authVerifier.standardOptional,\n handler: async ({ params, auth, req }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({\n labelers,\n viewer,\n features: ctx.featureGatesClient.scope(\n ctx.featureGatesClient.parseUserContextFromHandler({ viewer, req }),\n ),\n })\n\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n // @NOTE the dataplane echoes `since` back as the cursor once the\n // bounded range is exhausted. Refilling past it would read below the\n // boundary.\n terminalCursor: params.since,\n fetch: ({ cursor, limit }) =>\n getListFeed({ ...params, cursor, limit, hydrateCtx }, ctx),\n items: (r) => r.feed,\n })\n\n const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)\n\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers, repoRev }),\n }\n },\n })\n}\n\nexport const skeleton = async (inputs: {\n ctx: Context\n params: Params\n}): Promise<Skeleton> => {\n const { ctx, params } = inputs\n if (clearlyBadCursor(params.cursor)) {\n return { items: [], cursor: params.since }\n }\n const res = await ctx.dataplane\n .getListFeed({\n listUri: params.list,\n limit: params.limit,\n cursor: params.cursor,\n since: params.since,\n })\n .catch(asInvalidRequest())\n return {\n items: res.items.map((item) => ({\n post: { uri: item.uri as AtUriString, cid: item.cid || undefined },\n repost: item.repost\n ? { uri: item.repost as AtUriString, cid: item.repostCid || undefined }\n : undefined,\n })),\n cursor: parseString(res.cursor),\n startCursor: parseString(res.startCursor),\n }\n}\n\nconst hydration = async (inputs: {\n ctx: Context\n params: Params\n skeleton: Skeleton\n}): Promise<HydrationState> => {\n const { ctx, params, skeleton } = inputs\n const [feedItemsState, bidirectionalBlocks] = await Promise.all([\n ctx.hydrator.hydrateFeedItems(skeleton.items, params.hydrateCtx),\n getBlocks({ ctx, params, skeleton }),\n ])\n return mergeStates(feedItemsState, {\n bidirectionalBlocks,\n })\n}\n\nconst noBlocksOrMutes = (inputs: {\n ctx: Context\n params: Params\n skeleton: Skeleton\n hydration: HydrationState\n}): Skeleton => {\n const { ctx, params, skeleton, hydration } = inputs\n skeleton.items = skeleton.items.filter((item) => {\n const bam = ctx.views.feedItemBlocksAndMutes(item, hydration)\n const creatorBlocks = hydration.bidirectionalBlocks?.get(\n uriToDid(params.list),\n )\n return (\n !bam.authorBlocked &&\n !bam.authorMuted &&\n !bam.authorQuotepostMuted &&\n !bam.originatorBlocked &&\n !bam.originatorMuted &&\n !bam.originatorRepostMuted &&\n !bam.ancestorAuthorBlocked &&\n !creatorBlocks?.get(uriToDid(item.post.uri))\n )\n })\n return skeleton\n}\n\nconst presentation = (inputs: {\n ctx: Context\n skeleton: Skeleton\n hydration: HydrationState\n}) => {\n const { ctx, skeleton, hydration } = inputs\n const feed = mapDefined(skeleton.items, (item) =>\n ctx.views.feedViewPost(item, hydration),\n )\n return {\n feed,\n cursor: skeleton.cursor,\n startCursor: skeleton.startCursor,\n }\n}\n\nconst getBlocks = async (input: {\n ctx: Context\n skeleton: Skeleton\n params: Params\n}) => {\n const { ctx, skeleton, params } = input\n const pairs: Map<DidString, DidString[]> = new Map()\n pairs.set(\n uriToDid(params.list),\n skeleton.items.map((item) => uriToDid(item.post.uri)),\n )\n return await ctx.hydrator.hydrateBidirectionalBlocks(pairs, params.hydrateCtx)\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n dataplane: DataPlaneClient\n}\n\ntype Params = app.bsky.feed.getListFeed.$Params & { hydrateCtx: HydrateCtx }\n\ntype Skeleton = {\n items: FeedItem[]\n cursor?: string\n startCursor?: string\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Server } from '@atproto/xrpc-server';
|
|
2
2
|
import type { AppContext } from '../../../../context.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type DataPlaneClient } from '../../../../data-plane/index.js';
|
|
4
4
|
import type { FeedItem } from '../../../../hydration/feed.js';
|
|
5
5
|
import type { HydrateCtxWithViewer, Hydrator } from '../../../../hydration/hydrator.js';
|
|
6
6
|
import { app } from '../../../../lexicons/index.js';
|
|
@@ -21,6 +21,7 @@ type Params = app.bsky.feed.getTimeline.$Params & {
|
|
|
21
21
|
type Skeleton = {
|
|
22
22
|
items: FeedItem[];
|
|
23
23
|
cursor?: string;
|
|
24
|
+
startCursor?: string;
|
|
24
25
|
};
|
|
25
26
|
export {};
|
|
26
27
|
//# sourceMappingURL=getTimeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeline.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getTimeline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"getTimeline.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getTimeline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,EACV,oBAAoB,EAEpB,QAAQ,EACT,MAAM,mCAAmC,CAAA;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAGvD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA8CvD;AAED,eAAO,MAAM,QAAQ,WAAkB;IACrC,GAAG,EAAE,OAAO,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,KAAG,OAAO,CAAC,QAAQ,CAuBnB,CAAA;AAsDD,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,eAAe,CAAA;CAC3B,CAAA;AAED,KAAK,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG;IAChD,UAAU,EAAE,oBAAoB,CAAA;CACjC,CAAA;AAED,KAAK,QAAQ,GAAG;IACd,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mapDefined } from '@atproto/common';
|
|
2
|
+
import { asInvalidRequest, } from '../../../../data-plane/index.js';
|
|
2
3
|
import { parseString } from '../../../../hydration/util.js';
|
|
3
4
|
import { app } from '../../../../lexicons/index.js';
|
|
4
5
|
import { createPipeline } from '../../../../pipeline.js';
|
|
@@ -23,6 +24,10 @@ export default function (server, ctx) {
|
|
|
23
24
|
const result = await fillPage({
|
|
24
25
|
cursor: params.cursor,
|
|
25
26
|
limit: params.limit,
|
|
27
|
+
// @NOTE the dataplane echoes `since` back as the cursor once the
|
|
28
|
+
// bounded range is exhausted. Refilling past it would read below the
|
|
29
|
+
// boundary.
|
|
30
|
+
terminalCursor: params.since,
|
|
26
31
|
fetch: ({ cursor, limit }) => getTimeline({ ...params, cursor, limit, hydrateCtx }, ctx),
|
|
27
32
|
items: (r) => r.feed,
|
|
28
33
|
});
|
|
@@ -38,13 +43,16 @@ export default function (server, ctx) {
|
|
|
38
43
|
export const skeleton = async (inputs) => {
|
|
39
44
|
const { ctx, params } = inputs;
|
|
40
45
|
if (clearlyBadCursor(params.cursor)) {
|
|
41
|
-
return { items: [] };
|
|
46
|
+
return { items: [], cursor: params.since };
|
|
42
47
|
}
|
|
43
|
-
const res = await ctx.dataplane
|
|
48
|
+
const res = await ctx.dataplane
|
|
49
|
+
.getTimeline({
|
|
44
50
|
actorDid: params.hydrateCtx.viewer,
|
|
45
51
|
limit: params.limit,
|
|
46
52
|
cursor: params.cursor,
|
|
47
|
-
|
|
53
|
+
since: params.since,
|
|
54
|
+
})
|
|
55
|
+
.catch(asInvalidRequest());
|
|
48
56
|
return {
|
|
49
57
|
items: res.items.map((item) => ({
|
|
50
58
|
post: { uri: item.uri, cid: item.cid || undefined },
|
|
@@ -53,6 +61,7 @@ export const skeleton = async (inputs) => {
|
|
|
53
61
|
: undefined,
|
|
54
62
|
})),
|
|
55
63
|
cursor: parseString(res.cursor),
|
|
64
|
+
startCursor: parseString(res.startCursor),
|
|
56
65
|
};
|
|
57
66
|
};
|
|
58
67
|
const hydration = async (inputs) => {
|
|
@@ -79,6 +88,10 @@ const noBlocksOrMutes = (inputs) => {
|
|
|
79
88
|
const presentation = (inputs) => {
|
|
80
89
|
const { ctx, skeleton, hydration } = inputs;
|
|
81
90
|
const feed = mapDefined(skeleton.items, (item) => ctx.views.feedViewPost(item, hydration));
|
|
82
|
-
return {
|
|
91
|
+
return {
|
|
92
|
+
feed,
|
|
93
|
+
cursor: skeleton.cursor,
|
|
94
|
+
startCursor: skeleton.startCursor,
|
|
95
|
+
};
|
|
83
96
|
};
|
|
84
97
|
//# sourceMappingURL=getTimeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeline.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getTimeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"getTimeline.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/feed/getTimeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,EAEL,gBAAgB,GACjB,MAAM,iCAAiC,CAAA;AAOxC,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEzE,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,WAAW,GAAG,cAAc,CAChC,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,CACb,CAAA;IACD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;QAC/B,IAAI,EAAE;YACJ,wEAAwE;YACxE,gHAAgH;YAChH,gBAAgB,EAAE,IAAI;SACvB;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EA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,WAAW;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { mapDefined } from '@atproto/common'\nimport type { AtUriString } from '@atproto/syntax'\nimport type { Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport {\n type DataPlaneClient,\n asInvalidRequest,\n} from '../../../../data-plane/index.js'\nimport type { FeedItem } from '../../../../hydration/feed.js'\nimport type {\n HydrateCtxWithViewer,\n HydrationState,\n Hydrator,\n} from '../../../../hydration/hydrator.js'\nimport { parseString } from '../../../../hydration/util.js'\nimport { app } from '../../../../lexicons/index.js'\nimport { createPipeline } from '../../../../pipeline.js'\nimport type { Views } from '../../../../views/index.js'\nimport { clearlyBadCursor, fillPage, resHeaders } from '../../../util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const getTimeline = createPipeline(\n skeleton,\n hydration,\n noBlocksOrMutes,\n presentation,\n )\n server.add(app.bsky.feed.getTimeline, {\n auth: ctx.authVerifier.standard,\n opts: {\n // @TODO remove after grace period has passed, behavior is non-standard.\n // temporarily added for compat w/ previous version of xrpc-server to avoid breakage of a few specified parties.\n paramsParseLoose: true,\n },\n handler: async ({ params, auth, req }) => {\n const viewer = auth.credentials.iss\n const labelers = ctx.reqLabelers(req)\n const hydrateCtx = await ctx.hydrator.createContext({\n labelers,\n viewer,\n features: ctx.featureGatesClient.scope(\n ctx.featureGatesClient.parseUserContextFromHandler({ viewer, req }),\n ),\n })\n\n const result = await fillPage({\n cursor: params.cursor,\n limit: params.limit,\n // @NOTE the dataplane echoes `since` back as the cursor once the\n // bounded range is exhausted. Refilling past it would read below the\n // boundary.\n terminalCursor: params.since,\n fetch: ({ cursor, limit }) =>\n getTimeline({ ...params, cursor, limit, hydrateCtx }, ctx),\n items: (r) => r.feed,\n })\n\n const repoRev = await ctx.hydrator.actor.getRepoRevSafe(viewer)\n\n return {\n encoding: 'application/json',\n body: result,\n headers: resHeaders({ labelers: hydrateCtx.labelers, repoRev }),\n }\n },\n })\n}\n\nexport const skeleton = async (inputs: {\n ctx: Context\n params: Params\n}): Promise<Skeleton> => {\n const { ctx, params } = inputs\n if (clearlyBadCursor(params.cursor)) {\n return { items: [], cursor: params.since }\n }\n const res = await ctx.dataplane\n .getTimeline({\n actorDid: params.hydrateCtx.viewer,\n limit: params.limit,\n cursor: params.cursor,\n since: params.since,\n })\n .catch(asInvalidRequest())\n return {\n items: res.items.map((item) => ({\n post: { uri: item.uri as AtUriString, cid: item.cid || undefined },\n repost: item.repost\n ? { uri: item.repost as AtUriString, cid: item.repostCid || undefined }\n : undefined,\n })),\n cursor: parseString(res.cursor),\n startCursor: parseString(res.startCursor),\n }\n}\n\nconst hydration = async (inputs: {\n ctx: Context\n params: Params\n skeleton: Skeleton\n}): Promise<HydrationState> => {\n const { ctx, params, skeleton } = inputs\n return ctx.hydrator.hydrateFeedItems(skeleton.items, params.hydrateCtx, {\n knownLikers:\n !!params.hydrateCtx.viewer &&\n params.hydrateCtx.features.checkGate(\n params.hydrateCtx.features.Gate.KnownLikersFeedEnable,\n ),\n })\n}\n\nconst noBlocksOrMutes = (inputs: {\n ctx: Context\n skeleton: Skeleton\n hydration: HydrationState\n}): Skeleton => {\n const { ctx, skeleton, hydration } = inputs\n skeleton.items = skeleton.items.filter((item) => {\n const bam = ctx.views.feedItemBlocksAndMutes(item, hydration)\n return (\n !bam.authorBlocked &&\n !bam.authorMuted &&\n !bam.authorQuotepostMuted &&\n !bam.originatorBlocked &&\n !bam.originatorMuted &&\n !bam.originatorRepostMuted &&\n !bam.ancestorAuthorBlocked\n )\n })\n return skeleton\n}\n\nconst presentation = (inputs: {\n ctx: Context\n skeleton: Skeleton\n hydration: HydrationState\n}) => {\n const { ctx, skeleton, hydration } = inputs\n const feed = mapDefined(skeleton.items, (item) =>\n ctx.views.feedViewPost(item, hydration),\n )\n return {\n feed,\n cursor: skeleton.cursor,\n startCursor: skeleton.startCursor,\n }\n}\n\ntype Context = {\n hydrator: Hydrator\n views: Views\n dataplane: DataPlaneClient\n}\n\ntype Params = app.bsky.feed.getTimeline.$Params & {\n hydrateCtx: HydrateCtxWithViewer\n}\n\ntype Skeleton = {\n items: FeedItem[]\n cursor?: string\n startCursor?: string\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare const NOTIFICATION_REASON: {
|
|
2
|
+
readonly CONTACT_MATCH: 'contact-match';
|
|
3
|
+
readonly FOLLOW: 'follow';
|
|
4
|
+
readonly FOLLOW_BACK: 'follow-back';
|
|
5
|
+
readonly LIKE: 'like';
|
|
6
|
+
readonly LIKE_VIA_REPOST: 'like-via-repost';
|
|
7
|
+
readonly MENTION: 'mention';
|
|
8
|
+
readonly QUOTE: 'quote';
|
|
9
|
+
readonly REPLY: 'reply';
|
|
10
|
+
readonly REPOST: 'repost';
|
|
11
|
+
readonly REPOST_VIA_REPOST: 'repost-via-repost';
|
|
12
|
+
readonly STARTERPACK_JOINED: 'starterpack-joined';
|
|
13
|
+
readonly SUBSCRIBED_POST: 'subscribed-post';
|
|
14
|
+
readonly UNVERIFIED: 'unverified';
|
|
15
|
+
readonly VERIFIED: 'verified';
|
|
16
|
+
};
|
|
17
|
+
export type DataplaneNotificationReason = (typeof NOTIFICATION_REASON)[keyof typeof NOTIFICATION_REASON];
|
|
18
|
+
export declare const APPVIEW_NOTIFICATION_REASON: {
|
|
19
|
+
readonly CONTACT_MATCH: 'contact-match';
|
|
20
|
+
readonly FOLLOW: 'follow';
|
|
21
|
+
readonly FOLLOW_BACK: 'follow-back';
|
|
22
|
+
readonly LIKE: 'like';
|
|
23
|
+
readonly LIKE_VIA_REPOST: 'like-via-repost';
|
|
24
|
+
readonly MENTION: 'mention';
|
|
25
|
+
readonly QUOTE: 'quote';
|
|
26
|
+
readonly REPLY: 'reply';
|
|
27
|
+
readonly REPOST: 'repost';
|
|
28
|
+
readonly REPOST_VIA_REPOST: 'repost-via-repost';
|
|
29
|
+
readonly STARTERPACK_JOINED: 'starterpack-joined';
|
|
30
|
+
readonly SUBSCRIBED_POST: 'subscribed-post';
|
|
31
|
+
readonly UNVERIFIED: 'unverified';
|
|
32
|
+
readonly VERIFIED: 'verified';
|
|
33
|
+
readonly MULTI_POST_LIKE: 'multi-post-like';
|
|
34
|
+
};
|
|
35
|
+
export type AppviewNotificationReason = DataplaneNotificationReason | typeof APPVIEW_NOTIFICATION_REASON.MULTI_POST_LIKE;
|
|
36
|
+
export declare const MARK_READ_GENERIC = "mark-read-generic";
|
|
37
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB;aAC9B,aAAa,EAAE,eAAe;aAC9B,MAAM,EAAE,QAAQ;aAChB,WAAW,EAAE,aAAa;aAC1B,IAAI,EAAE,MAAM;aACZ,eAAe,EAAE,iBAAiB;aAClC,OAAO,EAAE,SAAS;aAClB,KAAK,EAAE,OAAO;aACd,KAAK,EAAE,OAAO;aACd,MAAM,EAAE,QAAQ;aAChB,iBAAiB,EAAE,mBAAmB;aACtC,kBAAkB,EAAE,oBAAoB;aACxC,eAAe,EAAE,iBAAiB;aAClC,UAAU,EAAE,YAAY;aACxB,QAAQ,EAAE,UAAU;CACZ,CAAA;AAEV,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAA;AAEhE,eAAO,MAAM,2BAA2B;4BAnBvB,eAAe;qBACtB,QAAQ;0BACH,aAAa;mBACpB,MAAM;8BACK,iBAAiB;sBACzB,SAAS;oBACX,OAAO;oBACP,OAAO;qBACN,QAAQ;gCACG,mBAAmB;iCAClB,oBAAoB;8BACvB,iBAAiB;yBACtB,YAAY;uBACd,UAAU;8BAQH,iBAAiB;CAC1B,CAAA;AAEV,MAAM,MAAM,yBAAyB,GACjC,2BAA2B,GAC3B,OAAO,2BAA2B,CAAC,eAAe,CAAA;AAGtD,eAAO,MAAM,iBAAiB,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// As they come from the dataplane.
|
|
2
|
+
export const NOTIFICATION_REASON = {
|
|
3
|
+
CONTACT_MATCH: 'contact-match',
|
|
4
|
+
FOLLOW: 'follow',
|
|
5
|
+
FOLLOW_BACK: 'follow-back',
|
|
6
|
+
LIKE: 'like',
|
|
7
|
+
LIKE_VIA_REPOST: 'like-via-repost',
|
|
8
|
+
MENTION: 'mention',
|
|
9
|
+
QUOTE: 'quote',
|
|
10
|
+
REPLY: 'reply',
|
|
11
|
+
REPOST: 'repost',
|
|
12
|
+
REPOST_VIA_REPOST: 'repost-via-repost',
|
|
13
|
+
STARTERPACK_JOINED: 'starterpack-joined',
|
|
14
|
+
SUBSCRIBED_POST: 'subscribed-post',
|
|
15
|
+
UNVERIFIED: 'unverified',
|
|
16
|
+
VERIFIED: 'verified',
|
|
17
|
+
};
|
|
18
|
+
export const APPVIEW_NOTIFICATION_REASON = {
|
|
19
|
+
...NOTIFICATION_REASON,
|
|
20
|
+
MULTI_POST_LIKE: 'multi-post-like',
|
|
21
|
+
};
|
|
22
|
+
// Not a real notification the users see, but used to mark as read across user devices.
|
|
23
|
+
export const MARK_READ_GENERIC = 'mark-read-generic';
|
|
24
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/constants.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,MAAM;IACZ,eAAe,EAAE,iBAAiB;IAClC,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,iBAAiB,EAAE,mBAAmB;IACtC,kBAAkB,EAAE,oBAAoB;IACxC,eAAe,EAAE,iBAAiB;IAClC,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;CACZ,CAAA;AAKV,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,GAAG,mBAAmB;IACtB,eAAe,EAAE,iBAAiB;CAC1B,CAAA;AAMV,uFAAuF;AACvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAA","sourcesContent":["// As they come from the dataplane.\nexport const NOTIFICATION_REASON = {\n CONTACT_MATCH: 'contact-match',\n FOLLOW: 'follow',\n FOLLOW_BACK: 'follow-back',\n LIKE: 'like',\n LIKE_VIA_REPOST: 'like-via-repost',\n MENTION: 'mention',\n QUOTE: 'quote',\n REPLY: 'reply',\n REPOST: 'repost',\n REPOST_VIA_REPOST: 'repost-via-repost',\n STARTERPACK_JOINED: 'starterpack-joined',\n SUBSCRIBED_POST: 'subscribed-post',\n UNVERIFIED: 'unverified',\n VERIFIED: 'verified',\n} as const\n\nexport type DataplaneNotificationReason =\n (typeof NOTIFICATION_REASON)[keyof typeof NOTIFICATION_REASON]\n\nexport const APPVIEW_NOTIFICATION_REASON = {\n ...NOTIFICATION_REASON,\n MULTI_POST_LIKE: 'multi-post-like',\n} as const\n\nexport type AppviewNotificationReason =\n | DataplaneNotificationReason\n | typeof APPVIEW_NOTIFICATION_REASON.MULTI_POST_LIKE\n\n// Not a real notification the users see, but used to mark as read across user devices.\nexport const MARK_READ_GENERIC = 'mark-read-generic'\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Server } from '@atproto/xrpc-server';
|
|
2
|
+
import type { AppContext } from '../../../../context.js';
|
|
3
|
+
export declare const getNextRawLimit: (itemsFetched: number, groupsBuilt: number, groupsNeeded: number) => number;
|
|
4
|
+
export default function (server: Server, ctx: AppContext): void;
|
|
5
|
+
//# sourceMappingURL=getGroupedNotifications.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGroupedNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/notification/getGroupedNotifications.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AA2CxD,eAAO,MAAM,eAAe,iBACZ,MAAM,eACP,MAAM,gBACL,MAAM,KACnB,MAoBF,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAqCvD"}
|