@atproto/bsky 0.0.250 → 0.0.253
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 +49 -0
- package/dist/api/age-assurance/const.js +19 -19
- package/dist/api/age-assurance/const.js.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
- package/dist/api/app/bsky/feed/getFeed.js +4 -0
- package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPosts.js +5 -0
- package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
- package/dist/api/app/bsky/feed/searchPostsV2.js +5 -0
- package/dist/api/app/bsky/feed/searchPostsV2.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -0
- package/dist/config.js.map +1 -1
- package/dist/hydration/feed.d.ts +1 -2
- package/dist/hydration/feed.d.ts.map +1 -1
- package/dist/hydration/feed.js.map +1 -1
- package/dist/kws.d.ts +8 -0
- package/dist/kws.d.ts.map +1 -1
- package/dist/kws.js +53 -4
- package/dist/kws.js.map +1 -1
- package/package.json +28 -23
- package/bin/migration-create.ts +0 -46
- package/buf.gen.yaml +0 -12
- package/proto/bsky.proto +0 -1907
- package/proto/courier.proto +0 -84
- package/proto/rolodex.proto +0 -116
- package/src/api/age-assurance/const.ts +0 -203
- package/src/api/age-assurance/index.ts +0 -34
- package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
- package/src/api/age-assurance/kws/age-verified.ts +0 -81
- package/src/api/age-assurance/kws/const.ts +0 -33
- package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
- package/src/api/age-assurance/kws/external-payload.ts +0 -149
- package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
- package/src/api/age-assurance/stash.ts +0 -23
- package/src/api/age-assurance/types.ts +0 -10
- package/src/api/age-assurance/util.ts +0 -68
- package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
- package/src/api/app/bsky/actor/getProfile.ts +0 -106
- package/src/api/app/bsky/actor/getProfiles.ts +0 -99
- package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
- package/src/api/app/bsky/actor/searchActors.ts +0 -171
- package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
- package/src/api/app/bsky/ageassurance/begin.ts +0 -175
- package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
- package/src/api/app/bsky/ageassurance/getState.ts +0 -58
- package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
- package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
- package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
- package/src/api/app/bsky/bookmark/util.ts +0 -13
- package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
- package/src/api/app/bsky/contact/getMatches.ts +0 -111
- package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
- package/src/api/app/bsky/contact/importContacts.ts +0 -119
- package/src/api/app/bsky/contact/removeData.ts +0 -25
- package/src/api/app/bsky/contact/sendNotification.ts +0 -33
- package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
- package/src/api/app/bsky/contact/util.ts +0 -92
- package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
- package/src/api/app/bsky/draft/createDraft.ts +0 -45
- package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
- package/src/api/app/bsky/draft/getDrafts.ts +0 -44
- package/src/api/app/bsky/draft/updateDraft.ts +0 -26
- package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
- package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
- package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
- package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
- package/src/api/app/bsky/feed/getFeed.ts +0 -277
- package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
- package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
- package/src/api/app/bsky/feed/getLikes.ts +0 -151
- package/src/api/app/bsky/feed/getListFeed.ts +0 -147
- package/src/api/app/bsky/feed/getPostThread.ts +0 -156
- package/src/api/app/bsky/feed/getPosts.ts +0 -100
- package/src/api/app/bsky/feed/getQuotes.ts +0 -122
- package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
- package/src/api/app/bsky/feed/getTimeline.ts +0 -127
- package/src/api/app/bsky/feed/searchPosts.ts +0 -267
- package/src/api/app/bsky/feed/searchPostsV2.ts +0 -236
- package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
- package/src/api/app/bsky/graph/getBlocks.ts +0 -94
- package/src/api/app/bsky/graph/getFollowers.ts +0 -153
- package/src/api/app/bsky/graph/getFollows.ts +0 -151
- package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
- package/src/api/app/bsky/graph/getList.ts +0 -152
- package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
- package/src/api/app/bsky/graph/getListMutes.ts +0 -87
- package/src/api/app/bsky/graph/getLists.ts +0 -125
- package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
- package/src/api/app/bsky/graph/getMutes.ts +0 -87
- package/src/api/app/bsky/graph/getRelationships.ts +0 -58
- package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
- package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
- package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
- package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
- package/src/api/app/bsky/graph/muteActor.ts +0 -24
- package/src/api/app/bsky/graph/muteActorList.ts +0 -19
- package/src/api/app/bsky/graph/muteThread.ts +0 -19
- package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
- package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
- package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
- package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
- package/src/api/app/bsky/labeler/getServices.ts +0 -41
- package/src/api/app/bsky/notification/getPreferences.ts +0 -49
- package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
- package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
- package/src/api/app/bsky/notification/listNotifications.ts +0 -272
- package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
- package/src/api/app/bsky/notification/putPreferences.ts +0 -17
- package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
- package/src/api/app/bsky/notification/registerPush.ts +0 -40
- package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
- package/src/api/app/bsky/notification/updateSeen.ts +0 -52
- package/src/api/app/bsky/notification/util.ts +0 -134
- package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
- package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
- package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
- package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
- package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
- package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
- package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
- package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
- package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
- package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
- package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
- package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
- package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
- package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
- package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
- package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
- package/src/api/blob-dispatcher.ts +0 -41
- package/src/api/blob-resolver.ts +0 -401
- package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
- package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
- package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
- package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
- package/src/api/com/atproto/label/queryLabels.ts +0 -42
- package/src/api/com/atproto/repo/getRecord.ts +0 -44
- package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
- package/src/api/external.ts +0 -15
- package/src/api/health.ts +0 -47
- package/src/api/index.ts +0 -216
- package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
- package/src/api/kws/api.ts +0 -113
- package/src/api/kws/index.ts +0 -29
- package/src/api/kws/types.ts +0 -78
- package/src/api/kws/util.test.ts +0 -50
- package/src/api/kws/util.ts +0 -109
- package/src/api/kws/webhook.ts +0 -134
- package/src/api/sitemap.ts +0 -76
- package/src/api/util.ts +0 -45
- package/src/api/well-known.ts +0 -44
- package/src/auth-verifier.ts +0 -522
- package/src/bsync.ts +0 -41
- package/src/cache/read-through.ts +0 -157
- package/src/config.ts +0 -710
- package/src/context.ts +0 -143
- package/src/courier.ts +0 -41
- package/src/data-plane/client/hosts.ts +0 -103
- package/src/data-plane/client/index.ts +0 -125
- package/src/data-plane/client/util.test.ts +0 -29
- package/src/data-plane/client/util.ts +0 -74
- package/src/data-plane/index.ts +0 -2
- package/src/data-plane/server/background.ts +0 -66
- package/src/data-plane/server/bsync-subscription.ts +0 -590
- package/src/data-plane/server/db/database-schema.ts +0 -90
- package/src/data-plane/server/db/db.ts +0 -204
- package/src/data-plane/server/db/index.ts +0 -2
- package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
- package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
- package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
- package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
- package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
- package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
- package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
- package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
- package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
- package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
- package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
- package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
- package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
- package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
- package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
- package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
- package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
- package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
- package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
- package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
- package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
- package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
- package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
- package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
- package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
- package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
- package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
- package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
- package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
- package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
- package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
- package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
- package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
- package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
- package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
- package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
- package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
- package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
- package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
- package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
- package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
- package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
- package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
- package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
- package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
- package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
- package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
- package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
- package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
- package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
- package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
- package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
- package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
- package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
- package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
- package/src/data-plane/server/db/migrations/index.ts +0 -60
- package/src/data-plane/server/db/migrations/provider.ts +0 -26
- package/src/data-plane/server/db/pagination.ts +0 -341
- package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
- package/src/data-plane/server/db/tables/actor-block.ts +0 -14
- package/src/data-plane/server/db/tables/actor-state.ts +0 -10
- package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
- package/src/data-plane/server/db/tables/actor.ts +0 -19
- package/src/data-plane/server/db/tables/algo.ts +0 -11
- package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
- package/src/data-plane/server/db/tables/bookmark.ts +0 -11
- package/src/data-plane/server/db/tables/did-cache.ts +0 -13
- package/src/data-plane/server/db/tables/draft.ts +0 -11
- package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
- package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
- package/src/data-plane/server/db/tables/feed-item.ts +0 -12
- package/src/data-plane/server/db/tables/follow.ts +0 -15
- package/src/data-plane/server/db/tables/label.ts +0 -13
- package/src/data-plane/server/db/tables/labeler.ts +0 -16
- package/src/data-plane/server/db/tables/like.ts +0 -18
- package/src/data-plane/server/db/tables/list-block.ts +0 -15
- package/src/data-plane/server/db/tables/list-item.ts +0 -16
- package/src/data-plane/server/db/tables/list-mute.ts +0 -9
- package/src/data-plane/server/db/tables/list.ts +0 -19
- package/src/data-plane/server/db/tables/mute.ts +0 -9
- package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
- package/src/data-plane/server/db/tables/notification.ts +0 -16
- package/src/data-plane/server/db/tables/post-agg.ts +0 -16
- package/src/data-plane/server/db/tables/post-embed.ts +0 -47
- package/src/data-plane/server/db/tables/post-gate.ts +0 -12
- package/src/data-plane/server/db/tables/post.ts +0 -28
- package/src/data-plane/server/db/tables/private-data.ts +0 -13
- package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
- package/src/data-plane/server/db/tables/profile.ts +0 -17
- package/src/data-plane/server/db/tables/quote.ts +0 -15
- package/src/data-plane/server/db/tables/record.ts +0 -15
- package/src/data-plane/server/db/tables/repost.ts +0 -18
- package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
- package/src/data-plane/server/db/tables/subscription.ts +0 -9
- package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
- package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
- package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
- package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
- package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
- package/src/data-plane/server/db/tables/verification.ts +0 -20
- package/src/data-plane/server/db/tables/view-param.ts +0 -12
- package/src/data-plane/server/db/types.ts +0 -12
- package/src/data-plane/server/db/util.ts +0 -67
- package/src/data-plane/server/index.ts +0 -44
- package/src/data-plane/server/indexing/index.ts +0 -458
- package/src/data-plane/server/indexing/plugins/block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
- package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
- package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
- package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
- package/src/data-plane/server/indexing/plugins/like.ts +0 -151
- package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
- package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
- package/src/data-plane/server/indexing/plugins/list.ts +0 -80
- package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
- package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/post.ts +0 -675
- package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
- package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
- package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
- package/src/data-plane/server/indexing/plugins/status.ts +0 -57
- package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
- package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
- package/src/data-plane/server/indexing/processor.ts +0 -292
- package/src/data-plane/server/routes/activity-subscription.ts +0 -84
- package/src/data-plane/server/routes/blocks.ts +0 -127
- package/src/data-plane/server/routes/bookmarks.ts +0 -83
- package/src/data-plane/server/routes/drafts.ts +0 -37
- package/src/data-plane/server/routes/feed-gens.ts +0 -89
- package/src/data-plane/server/routes/feeds.ts +0 -176
- package/src/data-plane/server/routes/follows.ts +0 -141
- package/src/data-plane/server/routes/identity.ts +0 -59
- package/src/data-plane/server/routes/index.ts +0 -67
- package/src/data-plane/server/routes/interactions.ts +0 -120
- package/src/data-plane/server/routes/labels.ts +0 -55
- package/src/data-plane/server/routes/likes.ts +0 -92
- package/src/data-plane/server/routes/lists.ts +0 -88
- package/src/data-plane/server/routes/moderation.ts +0 -102
- package/src/data-plane/server/routes/mutes.ts +0 -195
- package/src/data-plane/server/routes/notifs.ts +0 -239
- package/src/data-plane/server/routes/profile.ts +0 -220
- package/src/data-plane/server/routes/quotes.ts +0 -32
- package/src/data-plane/server/routes/records.ts +0 -119
- package/src/data-plane/server/routes/relationships.ts +0 -174
- package/src/data-plane/server/routes/reposts.ts +0 -76
- package/src/data-plane/server/routes/search.ts +0 -181
- package/src/data-plane/server/routes/site-standard.ts +0 -12
- package/src/data-plane/server/routes/sitemap.ts +0 -43
- package/src/data-plane/server/routes/starter-packs.ts +0 -32
- package/src/data-plane/server/routes/suggestions.ts +0 -175
- package/src/data-plane/server/routes/sync.ts +0 -16
- package/src/data-plane/server/routes/threads.ts +0 -33
- package/src/data-plane/server/subscription.ts +0 -152
- package/src/data-plane/server/util.ts +0 -202
- package/src/error.ts +0 -12
- package/src/etcd.ts +0 -90
- package/src/feature-gates/README.md +0 -83
- package/src/feature-gates/gates.ts +0 -25
- package/src/feature-gates/index.ts +0 -235
- package/src/feature-gates/metrics.test.ts +0 -196
- package/src/feature-gates/metrics.ts +0 -107
- package/src/feature-gates/types.ts +0 -62
- package/src/feature-gates/utils.test.ts +0 -66
- package/src/feature-gates/utils.ts +0 -135
- package/src/hydration/actor.ts +0 -578
- package/src/hydration/external.test.ts +0 -281
- package/src/hydration/external.ts +0 -268
- package/src/hydration/feed.ts +0 -456
- package/src/hydration/graph.ts +0 -354
- package/src/hydration/hydrator.ts +0 -1835
- package/src/hydration/label.ts +0 -207
- package/src/hydration/util.ts +0 -199
- package/src/image/index.ts +0 -2
- package/src/image/invalidator.ts +0 -33
- package/src/image/logger.ts +0 -6
- package/src/image/server.ts +0 -228
- package/src/image/sharp.ts +0 -89
- package/src/image/uri.ts +0 -114
- package/src/image/util.ts +0 -41
- package/src/index.ts +0 -312
- package/src/kws.ts +0 -197
- package/src/logger.ts +0 -40
- package/src/pipeline.ts +0 -60
- package/src/redis.ts +0 -205
- package/src/rolodex.ts +0 -42
- package/src/stash.ts +0 -76
- package/src/util/debug.ts +0 -10
- package/src/util/http.ts +0 -42
- package/src/util/retry.ts +0 -10
- package/src/util/standard-site.test.ts +0 -423
- package/src/util/standard-site.ts +0 -196
- package/src/util/uris.ts +0 -38
- package/src/util.ts +0 -48
- package/src/views/index.ts +0 -2783
- package/src/views/threads-v2.ts +0 -510
- package/src/views/types.ts +0 -193
- package/src/views/util.ts +0 -114
- package/test.env +0 -2
- package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2463
- package/tests/_util.ts +0 -292
- package/tests/admin/admin-auth.test.ts +0 -190
- package/tests/admin/moderation.test.ts +0 -222
- package/tests/auth.test.ts +0 -90
- package/tests/blob-resolver.test.ts +0 -125
- package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
- package/tests/data-plane/db.test.ts +0 -189
- package/tests/data-plane/duplicate-records.test.ts +0 -156
- package/tests/data-plane/handle-invalidation.test.ts +0 -153
- package/tests/data-plane/indexing.test.ts +0 -827
- package/tests/data-plane/subscription.test.ts +0 -128
- package/tests/data-plane/thread-mutes.test.ts +0 -175
- package/tests/entryway-auth.test.ts +0 -177
- package/tests/etcd.test.ts +0 -302
- package/tests/feed-generation.test.ts +0 -919
- package/tests/hydration/util.test.ts +0 -119
- package/tests/image/server.test.ts +0 -97
- package/tests/image/sharp.test.ts +0 -199
- package/tests/image/uri.test.ts +0 -106
- package/tests/label-hydration.test.ts +0 -245
- package/tests/postgates.test.ts +0 -182
- package/tests/query-labels.test.ts +0 -85
- package/tests/redis-cache.test.ts +0 -230
- package/tests/seed/feed-hidden-replies.ts +0 -63
- package/tests/seed/get-suggested-starter-packs.ts +0 -64
- package/tests/seed/get-trends.ts +0 -71
- package/tests/seed/known-followers.ts +0 -111
- package/tests/seed/postgates.ts +0 -57
- package/tests/server.test.ts +0 -115
- package/tests/sitemap.test.ts +0 -75
- package/tests/stash.test.ts +0 -180
- package/tests/utils.test.ts +0 -36
- package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
- package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
- package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
- package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
- package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
- package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
- package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
- package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
- package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
- package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
- package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
- package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
- package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
- package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
- package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
- package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
- package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
- package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
- package/tests/views/account-deactivation.test.ts +0 -81
- package/tests/views/actor-likes.test.ts +0 -138
- package/tests/views/actor-search.test.ts +0 -261
- package/tests/views/age-assurance-v2.test.ts +0 -823
- package/tests/views/age-assurance.test.ts +0 -479
- package/tests/views/author-feed.test.ts +0 -694
- package/tests/views/block-lists.test.ts +0 -661
- package/tests/views/blocks.test.ts +0 -889
- package/tests/views/bookmarks.test.ts +0 -345
- package/tests/views/drafts.test.ts +0 -430
- package/tests/views/feed-hidden-replies.test.ts +0 -243
- package/tests/views/feed-view-post.test.ts +0 -501
- package/tests/views/follows.test.ts +0 -372
- package/tests/views/get-config.test.ts +0 -64
- package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
- package/tests/views/get-suggested-starter-packs.test.ts +0 -137
- package/tests/views/get-trends.test.ts +0 -141
- package/tests/views/internal-actor.test.ts +0 -127
- package/tests/views/known-followers.test.ts +0 -193
- package/tests/views/labeler-service.test.ts +0 -242
- package/tests/views/labels-needs-review.test.ts +0 -316
- package/tests/views/labels-takedown.test.ts +0 -247
- package/tests/views/likes.test.ts +0 -192
- package/tests/views/list-feed.test.ts +0 -195
- package/tests/views/lists.test.ts +0 -412
- package/tests/views/mute-lists.test.ts +0 -509
- package/tests/views/mutes.test.ts +0 -308
- package/tests/views/notifications.test.ts +0 -1581
- package/tests/views/post-search.test.ts +0 -200
- package/tests/views/posts-debug.test.ts +0 -79
- package/tests/views/posts.test.ts +0 -427
- package/tests/views/profile-debug.test.ts +0 -75
- package/tests/views/profile.test.ts +0 -795
- package/tests/views/quotes.test.ts +0 -133
- package/tests/views/reposts.test.ts +0 -112
- package/tests/views/starter-packs.test.ts +0 -395
- package/tests/views/suggestions.test.ts +0 -145
- package/tests/views/thread-v2.test.ts +0 -2005
- package/tests/views/thread.test.ts +0 -637
- package/tests/views/threadgating.test.ts +0 -843
- package/tests/views/timeline.test.ts +0 -328
- package/tests/views/verification.test.ts +0 -296
- package/tsconfig.build.json +0 -10
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.tests.json +0 -8
- package/vitest.config.ts +0 -10
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import { siteStandardRecordKey } from '../util/standard-site.js'
|
|
3
|
-
import {
|
|
4
|
-
SiteStandardDocument,
|
|
5
|
-
SiteStandardDocuments,
|
|
6
|
-
SiteStandardPublication,
|
|
7
|
-
SiteStandardPublications,
|
|
8
|
-
getSiteStandardRecordsFromHydrationMapsByDocumentUri,
|
|
9
|
-
getSiteStandardRecordsFromHydrationMapsByRefs,
|
|
10
|
-
} from './external.js'
|
|
11
|
-
import { HydrationMap } from './util.js'
|
|
12
|
-
|
|
13
|
-
const docDid = 'did:plc:doc'
|
|
14
|
-
const pubDid = 'did:plc:pub'
|
|
15
|
-
const otherPubDid = 'did:plc:other'
|
|
16
|
-
|
|
17
|
-
const docUri = `at://${docDid}/site.standard.document/abc`
|
|
18
|
-
const pubUri = `at://${pubDid}/site.standard.publication/self`
|
|
19
|
-
const otherPubUri = `at://${otherPubDid}/site.standard.publication/self`
|
|
20
|
-
|
|
21
|
-
const docCid = 'bafydoc'
|
|
22
|
-
const pubCid = 'bafypub'
|
|
23
|
-
const otherPubCid = 'bafyother'
|
|
24
|
-
|
|
25
|
-
const makeDocInfo = (
|
|
26
|
-
record: { site: string; path?: string; title?: string },
|
|
27
|
-
cid = docCid,
|
|
28
|
-
): SiteStandardDocument =>
|
|
29
|
-
({
|
|
30
|
-
record,
|
|
31
|
-
cid,
|
|
32
|
-
sortedAt: new Date(0),
|
|
33
|
-
indexedAt: new Date(0),
|
|
34
|
-
takedownRef: undefined,
|
|
35
|
-
}) as unknown as SiteStandardDocument
|
|
36
|
-
|
|
37
|
-
const makePubInfo = (
|
|
38
|
-
record: { url: string; name?: string },
|
|
39
|
-
cid = pubCid,
|
|
40
|
-
): SiteStandardPublication =>
|
|
41
|
-
({
|
|
42
|
-
record,
|
|
43
|
-
cid,
|
|
44
|
-
sortedAt: new Date(0),
|
|
45
|
-
indexedAt: new Date(0),
|
|
46
|
-
takedownRef: undefined,
|
|
47
|
-
}) as unknown as SiteStandardPublication
|
|
48
|
-
|
|
49
|
-
const makeDocuments = (
|
|
50
|
-
entries: [uri: string, cid: string, info: SiteStandardDocument | null][] = [],
|
|
51
|
-
): SiteStandardDocuments => {
|
|
52
|
-
const map: SiteStandardDocuments = new HydrationMap()
|
|
53
|
-
for (const [uri, cid, info] of entries) {
|
|
54
|
-
map.set(siteStandardRecordKey(uri, cid), info)
|
|
55
|
-
}
|
|
56
|
-
return map
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const makePublications = (
|
|
60
|
-
entries: [
|
|
61
|
-
uri: string,
|
|
62
|
-
cid: string,
|
|
63
|
-
info: SiteStandardPublication | null,
|
|
64
|
-
][] = [],
|
|
65
|
-
): SiteStandardPublications => {
|
|
66
|
-
const map: SiteStandardPublications = new HydrationMap()
|
|
67
|
-
for (const [uri, cid, info] of entries) {
|
|
68
|
-
map.set(siteStandardRecordKey(uri, cid), info)
|
|
69
|
-
}
|
|
70
|
-
return map
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
describe(getSiteStandardRecordsFromHydrationMapsByRefs, () => {
|
|
74
|
-
it('returns both slots when refs resolve and doc.site matches the publication', () => {
|
|
75
|
-
const docs = makeDocuments([
|
|
76
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
77
|
-
])
|
|
78
|
-
const pubs = makePublications([
|
|
79
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
80
|
-
])
|
|
81
|
-
const { document, publication } =
|
|
82
|
-
getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
83
|
-
[
|
|
84
|
-
{ uri: docUri, cid: docCid },
|
|
85
|
-
{ uri: pubUri, cid: pubCid },
|
|
86
|
-
],
|
|
87
|
-
docs,
|
|
88
|
-
pubs,
|
|
89
|
-
)
|
|
90
|
-
expect(document?.ref).toEqual({ uri: docUri, cid: docCid })
|
|
91
|
-
expect(publication?.ref).toEqual({ uri: pubUri, cid: pubCid })
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
it('rejects the whole pair when doc.site does not match the resolved publication', () => {
|
|
95
|
-
const docs = makeDocuments([
|
|
96
|
-
[docUri, docCid, makeDocInfo({ site: otherPubUri })],
|
|
97
|
-
])
|
|
98
|
-
const pubs = makePublications([
|
|
99
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
100
|
-
])
|
|
101
|
-
const result = getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
102
|
-
[
|
|
103
|
-
{ uri: docUri, cid: docCid },
|
|
104
|
-
{ uri: pubUri, cid: pubCid },
|
|
105
|
-
],
|
|
106
|
-
docs,
|
|
107
|
-
pubs,
|
|
108
|
-
)
|
|
109
|
-
expect(result).toEqual({ document: undefined, publication: undefined })
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it('rejects the whole pair when doc declares an at-uri site but no publication ref was supplied', () => {
|
|
113
|
-
const docs = makeDocuments([
|
|
114
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
115
|
-
])
|
|
116
|
-
const pubs = makePublications()
|
|
117
|
-
const result = getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
118
|
-
[{ uri: docUri, cid: docCid }],
|
|
119
|
-
docs,
|
|
120
|
-
pubs,
|
|
121
|
-
)
|
|
122
|
-
expect(result).toEqual({ document: undefined, publication: undefined })
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it('returns only the doc when site is a web URL (loose doc)', () => {
|
|
126
|
-
const docs = makeDocuments([
|
|
127
|
-
[docUri, docCid, makeDocInfo({ site: 'https://example.com' })],
|
|
128
|
-
])
|
|
129
|
-
const pubs = makePublications()
|
|
130
|
-
const { document, publication } =
|
|
131
|
-
getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
132
|
-
[{ uri: docUri, cid: docCid }],
|
|
133
|
-
docs,
|
|
134
|
-
pubs,
|
|
135
|
-
)
|
|
136
|
-
expect(document?.ref).toEqual({ uri: docUri, cid: docCid })
|
|
137
|
-
expect(publication).toBeUndefined()
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('returns only the publication when no doc ref is supplied', () => {
|
|
141
|
-
const docs = makeDocuments()
|
|
142
|
-
const pubs = makePublications([
|
|
143
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
144
|
-
])
|
|
145
|
-
const { document, publication } =
|
|
146
|
-
getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
147
|
-
[{ uri: pubUri, cid: pubCid }],
|
|
148
|
-
docs,
|
|
149
|
-
pubs,
|
|
150
|
-
)
|
|
151
|
-
expect(document).toBeUndefined()
|
|
152
|
-
expect(publication?.ref).toEqual({ uri: pubUri, cid: pubCid })
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
it('returns nothing when the version-exact lookup misses', () => {
|
|
156
|
-
// Doc indexed at one cid; ref points at a different cid.
|
|
157
|
-
const docs = makeDocuments([
|
|
158
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
159
|
-
])
|
|
160
|
-
const pubs = makePublications()
|
|
161
|
-
const result = getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
162
|
-
[{ uri: docUri, cid: 'bafy-different' }],
|
|
163
|
-
docs,
|
|
164
|
-
pubs,
|
|
165
|
-
)
|
|
166
|
-
expect(result).toEqual({ document: undefined, publication: undefined })
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
it('returns nothing when associatedRefs is empty or undefined', () => {
|
|
170
|
-
const docs = makeDocuments([
|
|
171
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
172
|
-
])
|
|
173
|
-
const pubs = makePublications([
|
|
174
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
175
|
-
])
|
|
176
|
-
expect(
|
|
177
|
-
getSiteStandardRecordsFromHydrationMapsByRefs([], docs, pubs),
|
|
178
|
-
).toEqual({ document: undefined, publication: undefined })
|
|
179
|
-
expect(
|
|
180
|
-
getSiteStandardRecordsFromHydrationMapsByRefs(undefined, docs, pubs),
|
|
181
|
-
).toEqual({ document: undefined, publication: undefined })
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('skips null entries (taken-down records) and reports them as misses', () => {
|
|
185
|
-
const docs = makeDocuments([[docUri, docCid, null]])
|
|
186
|
-
const pubs = makePublications()
|
|
187
|
-
const result = getSiteStandardRecordsFromHydrationMapsByRefs(
|
|
188
|
-
[{ uri: docUri, cid: docCid }],
|
|
189
|
-
docs,
|
|
190
|
-
pubs,
|
|
191
|
-
)
|
|
192
|
-
expect(result).toEqual({ document: undefined, publication: undefined })
|
|
193
|
-
})
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
describe(getSiteStandardRecordsFromHydrationMapsByDocumentUri, () => {
|
|
197
|
-
it('pairs the first hydrated doc with the publication its site points to', () => {
|
|
198
|
-
const docs = makeDocuments([
|
|
199
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
200
|
-
])
|
|
201
|
-
const pubs = makePublications([
|
|
202
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
203
|
-
])
|
|
204
|
-
const { document, publication } =
|
|
205
|
-
getSiteStandardRecordsFromHydrationMapsByDocumentUri(docs, pubs)
|
|
206
|
-
expect(document?.ref).toEqual({ uri: docUri, cid: docCid })
|
|
207
|
-
expect(publication?.ref).toEqual({ uri: pubUri, cid: pubCid })
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('rejects the pair when the declared publication was not hydrated', () => {
|
|
211
|
-
const docs = makeDocuments([
|
|
212
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
213
|
-
])
|
|
214
|
-
const pubs = makePublications()
|
|
215
|
-
const result = getSiteStandardRecordsFromHydrationMapsByDocumentUri(
|
|
216
|
-
docs,
|
|
217
|
-
pubs,
|
|
218
|
-
)
|
|
219
|
-
expect(result).toEqual({ document: undefined, publication: undefined })
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
it('returns only the doc when site is a web URL (loose doc)', () => {
|
|
223
|
-
const docs = makeDocuments([
|
|
224
|
-
[docUri, docCid, makeDocInfo({ site: 'https://example.com' })],
|
|
225
|
-
])
|
|
226
|
-
const pubs = makePublications()
|
|
227
|
-
const { document, publication } =
|
|
228
|
-
getSiteStandardRecordsFromHydrationMapsByDocumentUri(docs, pubs)
|
|
229
|
-
expect(document?.ref).toEqual({ uri: docUri, cid: docCid })
|
|
230
|
-
expect(publication).toBeUndefined()
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
it('falls through to first hydrated publication when no doc was hydrated', () => {
|
|
234
|
-
const docs = makeDocuments()
|
|
235
|
-
const pubs = makePublications([
|
|
236
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
237
|
-
])
|
|
238
|
-
const { document, publication } =
|
|
239
|
-
getSiteStandardRecordsFromHydrationMapsByDocumentUri(docs, pubs)
|
|
240
|
-
expect(document).toBeUndefined()
|
|
241
|
-
expect(publication?.ref).toEqual({ uri: pubUri, cid: pubCid })
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
it('ignores extraneous publications not referenced by the doc', () => {
|
|
245
|
-
const docs = makeDocuments([
|
|
246
|
-
[docUri, docCid, makeDocInfo({ site: pubUri })],
|
|
247
|
-
])
|
|
248
|
-
const pubs = makePublications([
|
|
249
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
250
|
-
[
|
|
251
|
-
otherPubUri,
|
|
252
|
-
otherPubCid,
|
|
253
|
-
makePubInfo({ url: 'https://other.com' }, otherPubCid),
|
|
254
|
-
],
|
|
255
|
-
])
|
|
256
|
-
const { document, publication } =
|
|
257
|
-
getSiteStandardRecordsFromHydrationMapsByDocumentUri(docs, pubs)
|
|
258
|
-
expect(document?.ref.uri).toBe(docUri)
|
|
259
|
-
expect(publication?.ref.uri).toBe(pubUri)
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
it('returns nothing when both maps are empty', () => {
|
|
263
|
-
const result = getSiteStandardRecordsFromHydrationMapsByDocumentUri(
|
|
264
|
-
makeDocuments(),
|
|
265
|
-
makePublications(),
|
|
266
|
-
)
|
|
267
|
-
expect(result).toEqual({ document: undefined, publication: undefined })
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
it('skips null entries (taken-down records)', () => {
|
|
271
|
-
const docs = makeDocuments([[docUri, docCid, null]])
|
|
272
|
-
const pubs = makePublications([
|
|
273
|
-
[pubUri, pubCid, makePubInfo({ url: 'https://example.com' })],
|
|
274
|
-
])
|
|
275
|
-
// No live doc -> falls through to publication-only.
|
|
276
|
-
const { document, publication } =
|
|
277
|
-
getSiteStandardRecordsFromHydrationMapsByDocumentUri(docs, pubs)
|
|
278
|
-
expect(document).toBeUndefined()
|
|
279
|
-
expect(publication?.ref.uri).toBe(pubUri)
|
|
280
|
-
})
|
|
281
|
-
})
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { AtUriString } from '@atproto/syntax'
|
|
2
|
-
import { DataPlaneClient } from '../data-plane/client/index.js'
|
|
3
|
-
import { site } from '../lexicons/index.js'
|
|
4
|
-
import { hydrationLogger } from '../logger.js'
|
|
5
|
-
import {
|
|
6
|
-
GetSiteStandardRecordsByRefResponse,
|
|
7
|
-
GetSiteStandardRecordsByURIResponse,
|
|
8
|
-
} from '../proto/bsky_pb.js'
|
|
9
|
-
import {
|
|
10
|
-
parseSiteStandardRecordKey,
|
|
11
|
-
siteStandardRecordKey,
|
|
12
|
-
} from '../util/standard-site.js'
|
|
13
|
-
import {
|
|
14
|
-
SiteStandardDocumentRecord,
|
|
15
|
-
SiteStandardPublicationRecord,
|
|
16
|
-
} from '../views/types.js'
|
|
17
|
-
import { HydrationMap, ItemRef, RecordInfo, parseRecord } from './util.js'
|
|
18
|
-
|
|
19
|
-
export type SiteStandardDocument = RecordInfo<SiteStandardDocumentRecord>
|
|
20
|
-
export type SiteStandardPublication = RecordInfo<SiteStandardPublicationRecord>
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Keyed by `${uri}@${cid}` — see `siteStandardRecordKey`. A single hydration
|
|
24
|
-
* batch can pull more than one version of the same URI (different posts
|
|
25
|
-
* pinning different cids), so the composite key is needed for O(1)
|
|
26
|
-
* version-exact lookups.
|
|
27
|
-
*/
|
|
28
|
-
export type SiteStandardDocuments = HydrationMap<string, SiteStandardDocument>
|
|
29
|
-
/**
|
|
30
|
-
* Keyed by `${uri}@${cid}`. See `SiteStandardDocuments` for the rationale.
|
|
31
|
-
*/
|
|
32
|
-
export type SiteStandardPublications = HydrationMap<
|
|
33
|
-
string,
|
|
34
|
-
SiteStandardPublication
|
|
35
|
-
>
|
|
36
|
-
export type SiteStandardRecords = {
|
|
37
|
-
documents: SiteStandardDocuments
|
|
38
|
-
publications: SiteStandardPublications
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type AssociatedSiteStandardRecord<T> = {
|
|
42
|
-
ref: { uri: AtUriString; cid: string }
|
|
43
|
-
info: T
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class ExternalHydrator {
|
|
47
|
-
constructor(public dataplane: DataPlaneClient) {}
|
|
48
|
-
|
|
49
|
-
async getSiteStandardRecordsByRef(
|
|
50
|
-
refs: ItemRef[],
|
|
51
|
-
includeTakedowns = false,
|
|
52
|
-
): Promise<SiteStandardRecords> {
|
|
53
|
-
if (!refs.length) return emptySiteStandardRecords()
|
|
54
|
-
|
|
55
|
-
const res = await this.dataplane.getSiteStandardRecordsByRef({
|
|
56
|
-
refs: refs.map(({ uri, cid }) => ({ uri, cid: cid ?? '' })),
|
|
57
|
-
})
|
|
58
|
-
return buildSiteStandardRecordsHydrationMaps(res, includeTakedowns)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async getSiteStandardRecordsByURI(
|
|
62
|
-
uris: AtUriString[],
|
|
63
|
-
includeTakedowns = false,
|
|
64
|
-
): Promise<SiteStandardRecords> {
|
|
65
|
-
if (!uris.length) return emptySiteStandardRecords()
|
|
66
|
-
|
|
67
|
-
const res = await this.dataplane.getSiteStandardRecordsByURI({ uris })
|
|
68
|
-
return buildSiteStandardRecordsHydrationMaps(res, includeTakedowns)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const emptySiteStandardRecords = (): SiteStandardRecords => ({
|
|
73
|
-
documents: new HydrationMap(),
|
|
74
|
-
publications: new HydrationMap(),
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
const buildSiteStandardRecordsHydrationMaps = (
|
|
78
|
-
res:
|
|
79
|
-
| GetSiteStandardRecordsByURIResponse
|
|
80
|
-
| GetSiteStandardRecordsByRefResponse,
|
|
81
|
-
includeTakedowns: boolean,
|
|
82
|
-
): SiteStandardRecords => {
|
|
83
|
-
const documents: SiteStandardDocuments = new HydrationMap()
|
|
84
|
-
for (const { ref, record } of res.documents) {
|
|
85
|
-
if (!ref?.uri || !ref.cid || !record) continue
|
|
86
|
-
documents.set(
|
|
87
|
-
siteStandardRecordKey(ref.uri, ref.cid),
|
|
88
|
-
parseRecord(site.standard.document.main, record, includeTakedowns) ??
|
|
89
|
-
null,
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
const publications: SiteStandardPublications = new HydrationMap()
|
|
93
|
-
for (const { ref, record } of res.publications) {
|
|
94
|
-
if (!ref?.uri || !ref.cid || !record) continue
|
|
95
|
-
publications.set(
|
|
96
|
-
siteStandardRecordKey(ref.uri, ref.cid),
|
|
97
|
-
parseRecord(site.standard.publication.main, record, includeTakedowns) ??
|
|
98
|
-
null,
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
return { documents, publications }
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Read-path resolution: caller pinned a set of `(uri, cid)` strongRefs in
|
|
106
|
-
* the post at write time, and we honor those exact versions. Any pair
|
|
107
|
-
* that doesn't structurally agree is rejected, so downstream callers can
|
|
108
|
-
* trust the returned shape.
|
|
109
|
-
*
|
|
110
|
-
* Same observable contract as
|
|
111
|
-
* `getSiteStandardRecordsFromHydrationMapsByDocumentUri` (the compose-path
|
|
112
|
-
* sister) — both functions guarantee that a returned `(doc, pub)` pair
|
|
113
|
-
* has matching site/uri, and reject orphan docs that claim a
|
|
114
|
-
* non-hydrated publication. They differ only in how upstream availability
|
|
115
|
-
* is asserted: this one trusts caller-supplied refs; the sister derives
|
|
116
|
-
* everything from the dataplane response.
|
|
117
|
-
*
|
|
118
|
-
* Pairing rules:
|
|
119
|
-
* - Both slots referenced: `doc.site` must equal `publication.ref.uri`,
|
|
120
|
-
* else both come back `undefined`.
|
|
121
|
-
* - Doc with at-uri `site` referenced but no matching publication ref:
|
|
122
|
-
* reject the whole pairing (doc claims a publication that should have
|
|
123
|
-
* been pinned, but wasn't).
|
|
124
|
-
* - Loose doc (web-URL `site`) referenced: publication stays `undefined`.
|
|
125
|
-
* - Only a publication referenced: document stays `undefined`.
|
|
126
|
-
*
|
|
127
|
-
* Each returned slot carries the matching `ref` so callers can recover
|
|
128
|
-
* the owner DID for blob-cdn URL building, etc.
|
|
129
|
-
*/
|
|
130
|
-
export const getSiteStandardRecordsFromHydrationMapsByRefs = (
|
|
131
|
-
associatedRefs: readonly { uri: AtUriString; cid: string }[] | undefined,
|
|
132
|
-
documents: SiteStandardDocuments | undefined,
|
|
133
|
-
publications: SiteStandardPublications | undefined,
|
|
134
|
-
): {
|
|
135
|
-
document: AssociatedSiteStandardRecord<SiteStandardDocument> | undefined
|
|
136
|
-
publication: AssociatedSiteStandardRecord<SiteStandardPublication> | undefined
|
|
137
|
-
} => {
|
|
138
|
-
if (!associatedRefs?.length) {
|
|
139
|
-
return { document: undefined, publication: undefined }
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Resolve each ref against the hydration maps, taking the first hit on
|
|
143
|
-
// each side.
|
|
144
|
-
let document: AssociatedSiteStandardRecord<SiteStandardDocument> | undefined
|
|
145
|
-
let publication:
|
|
146
|
-
| AssociatedSiteStandardRecord<SiteStandardPublication>
|
|
147
|
-
| undefined
|
|
148
|
-
for (const ref of associatedRefs) {
|
|
149
|
-
const key = siteStandardRecordKey(ref.uri, ref.cid)
|
|
150
|
-
if (!document) {
|
|
151
|
-
const hit = documents?.get(key)
|
|
152
|
-
if (hit) document = { ref, info: hit }
|
|
153
|
-
}
|
|
154
|
-
if (!publication) {
|
|
155
|
-
const hit = publications?.get(key)
|
|
156
|
-
if (hit) publication = { ref, info: hit }
|
|
157
|
-
}
|
|
158
|
-
if (document && publication) break
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Both refs resolved: enforce that the doc's `site` actually points at
|
|
162
|
-
// the supplied publication. Mismatch means the post was misconstructed
|
|
163
|
-
// (or tampered with), so reject the whole pairing.
|
|
164
|
-
if (document && publication) {
|
|
165
|
-
if (document.info.record.site !== publication.ref.uri) {
|
|
166
|
-
hydrationLogger.warn(
|
|
167
|
-
{
|
|
168
|
-
documentUri: document.ref.uri,
|
|
169
|
-
documentSite: document.info.record.site,
|
|
170
|
-
publicationUri: publication.ref.uri,
|
|
171
|
-
},
|
|
172
|
-
'site.standard byRefs lookup failed: doc.site does not match hydrated publication.uri',
|
|
173
|
-
)
|
|
174
|
-
return { document: undefined, publication: undefined }
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Doc with at-uri `site` but no publication: the post should have
|
|
179
|
-
// pinned the publication too. Treat as misconstructed — same contract
|
|
180
|
-
// as the compose-path lookup.
|
|
181
|
-
if (document && !publication) {
|
|
182
|
-
const site = document.info.record.site
|
|
183
|
-
if (site && site.startsWith('at://')) {
|
|
184
|
-
hydrationLogger.warn(
|
|
185
|
-
{ documentUri: document.ref.uri, documentSite: site },
|
|
186
|
-
'site.standard byRefs lookup failed: document.site is AT URI but no matching publication was hydrated',
|
|
187
|
-
)
|
|
188
|
-
return { document: undefined, publication: undefined }
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return { document, publication }
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Compose-path resolution: no caller-supplied refs — the dataplane
|
|
197
|
-
* returned the latest version of each record (including any
|
|
198
|
-
* publications it auto-resolved from a document's `site` field). Take
|
|
199
|
-
* the first hydrated document and pair it with the publication its
|
|
200
|
-
* `site` field points at.
|
|
201
|
-
*
|
|
202
|
-
* Same observable contract as
|
|
203
|
-
* `getSiteStandardRecordsFromHydrationMapsByRefs` (the read-path
|
|
204
|
-
* sister) — both functions guarantee that a returned `(doc, pub)` pair
|
|
205
|
-
* has matching site/uri, and reject orphan docs that claim a
|
|
206
|
-
* non-hydrated publication. They differ only in how upstream
|
|
207
|
-
* availability is asserted: this one walks whatever was returned by the
|
|
208
|
-
* dataplane; the sister checks against caller-supplied refs.
|
|
209
|
-
*
|
|
210
|
-
* Pairing rules:
|
|
211
|
-
* - Doc with at-uri `site`: must find a hydrated publication at that
|
|
212
|
-
* URI. If none was hydrated, the doc/publication chain is incomplete
|
|
213
|
-
* and the function returns `undefined` for both slots; the doc alone
|
|
214
|
-
* isn't useful without its source (can't verify the pub)
|
|
215
|
-
* - Doc with web-URL `site` (loose): no publication.
|
|
216
|
-
* - No doc hydrated: fall through to the first hydrated publication for
|
|
217
|
-
* the publication-only resolution flow.
|
|
218
|
-
*/
|
|
219
|
-
export const getSiteStandardRecordsFromHydrationMapsByDocumentUri = (
|
|
220
|
-
documents: SiteStandardDocuments | undefined,
|
|
221
|
-
publications: SiteStandardPublications | undefined,
|
|
222
|
-
): {
|
|
223
|
-
document: AssociatedSiteStandardRecord<SiteStandardDocument> | undefined
|
|
224
|
-
publication: AssociatedSiteStandardRecord<SiteStandardPublication> | undefined
|
|
225
|
-
} => {
|
|
226
|
-
// First hydrated doc.
|
|
227
|
-
let document: AssociatedSiteStandardRecord<SiteStandardDocument> | undefined
|
|
228
|
-
for (const [key, info] of documents ?? []) {
|
|
229
|
-
if (!info) continue
|
|
230
|
-
document = { ref: parseSiteStandardRecordKey(key), info }
|
|
231
|
-
break
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
let publication:
|
|
235
|
-
| AssociatedSiteStandardRecord<SiteStandardPublication>
|
|
236
|
-
| undefined
|
|
237
|
-
if (document) {
|
|
238
|
-
const site = document.info.record.site
|
|
239
|
-
if (site && site.startsWith('at://')) {
|
|
240
|
-
// Doc declared an at-uri publication; we need it.
|
|
241
|
-
for (const [key, info] of publications ?? []) {
|
|
242
|
-
if (!info) continue
|
|
243
|
-
const ref = parseSiteStandardRecordKey(key)
|
|
244
|
-
if (ref.uri === site) {
|
|
245
|
-
publication = { ref, info }
|
|
246
|
-
break
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (!publication) {
|
|
250
|
-
hydrationLogger.warn(
|
|
251
|
-
{ documentUri: document.ref.uri, documentSite: site },
|
|
252
|
-
'site.standard byDocumentUri lookup failed: document.site is AT URI but no matching publication was hydrated',
|
|
253
|
-
)
|
|
254
|
-
return { document: undefined, publication: undefined }
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
// else: loose doc (web-URL site), no publication needed.
|
|
258
|
-
} else {
|
|
259
|
-
// Publication-only flow: no doc, take the first hydrated publication.
|
|
260
|
-
for (const [key, info] of publications ?? []) {
|
|
261
|
-
if (!info) continue
|
|
262
|
-
publication = { ref: parseSiteStandardRecordKey(key), info }
|
|
263
|
-
break
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return { document, publication }
|
|
268
|
-
}
|