@atproto/bsky 0.0.251 → 0.0.254
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 +50 -0
- package/dist/api/age-assurance/const.js +19 -19
- package/dist/api/age-assurance/const.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/dist/lexicons/app/bsky/actor/defs.defs.d.ts +6 -0
- package/dist/lexicons/app/bsky/actor/defs.defs.d.ts.map +1 -1
- package/dist/lexicons/app/bsky/actor/defs.defs.js +1 -0
- package/dist/lexicons/app/bsky/actor/defs.defs.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 -282
- 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 -274
- package/src/api/app/bsky/feed/searchPostsV2.ts +0 -243
- 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 -719
- 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 -455
- 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 -2510
- 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 -965
- 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 -281
- 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,135 +0,0 @@
|
|
|
1
|
-
import crypto from 'node:crypto'
|
|
2
|
-
import { type UserContext as GrowthBookUserContext } from '@growthbook/growthbook'
|
|
3
|
-
import {
|
|
4
|
-
NormalizedUserContext,
|
|
5
|
-
TrackingMetadata,
|
|
6
|
-
UserContext,
|
|
7
|
-
} from './types.js'
|
|
8
|
-
|
|
9
|
-
export function normalizeUserContext(
|
|
10
|
-
userContext: UserContext,
|
|
11
|
-
): NormalizedUserContext {
|
|
12
|
-
const did = userContext.did ?? undefined
|
|
13
|
-
let deviceId = userContext.deviceId
|
|
14
|
-
let sessionId = userContext.sessionId
|
|
15
|
-
|
|
16
|
-
if (!deviceId) {
|
|
17
|
-
/*
|
|
18
|
-
* If we don't have a deviceId by other means, such as a request header,
|
|
19
|
-
* fall back to the DID. Our event proxy ensures ordering based on this
|
|
20
|
-
* deviceId (also called a stableId in the proxy), so if we have a DID, we
|
|
21
|
-
* want to use it to ensure client and server events are properly ordered.
|
|
22
|
-
*
|
|
23
|
-
* Without any better option for identifying the user, we generate a
|
|
24
|
-
* random deviceId.
|
|
25
|
-
*/
|
|
26
|
-
deviceId = did ?? `anon-${crypto.randomUUID()}`
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!sessionId) {
|
|
30
|
-
/*
|
|
31
|
-
* If we don't have a sessionId by other means, such as a request header,
|
|
32
|
-
* generate a random sessionId.
|
|
33
|
-
*/
|
|
34
|
-
sessionId = `anon-${crypto.randomUUID()}`
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
did,
|
|
39
|
-
deviceId,
|
|
40
|
-
sessionId,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Merge the base user context with any overrides provided at check time. This
|
|
46
|
-
* allows us to set a base context for the request, but also override or add
|
|
47
|
-
* properties for specific gate checks if needed.
|
|
48
|
-
*/
|
|
49
|
-
export function mergeUserContexts(
|
|
50
|
-
base: NormalizedUserContext,
|
|
51
|
-
overrides?: UserContext,
|
|
52
|
-
): NormalizedUserContext {
|
|
53
|
-
const did = overrides?.did ?? base.did ?? undefined
|
|
54
|
-
let deviceId = overrides?.deviceId ?? base.deviceId
|
|
55
|
-
let sessionId = overrides?.sessionId ?? base.sessionId
|
|
56
|
-
|
|
57
|
-
let isDifferentDid = false
|
|
58
|
-
|
|
59
|
-
if (did && deviceId.startsWith('anon-')) {
|
|
60
|
-
/*
|
|
61
|
-
* If we have a DID, but the existing deviceId is anonymous, use the DID as
|
|
62
|
-
* the deviceId to ensure proper ordering of events in our event proxy.
|
|
63
|
-
* This matches the logic in `normalizeUserContext` where we fall back to
|
|
64
|
-
* the DID for the deviceId if we don't have a deviceId from other means.
|
|
65
|
-
*/
|
|
66
|
-
deviceId = did
|
|
67
|
-
} else if (did && deviceId !== did) {
|
|
68
|
-
/*
|
|
69
|
-
* If we have both a DID and a deviceId, but they don't match, we may be
|
|
70
|
-
* overriding context to check a feature that is independent of a single
|
|
71
|
-
* request handler lifecycle.
|
|
72
|
-
*
|
|
73
|
-
* Example: a ScopedFeatureGatesClient was created in the root request
|
|
74
|
-
* handler with a user context that has a DID, but later on in the request
|
|
75
|
-
* lifecycle we may check a gate using the DID of the author of the image
|
|
76
|
-
* we're returning as part of the response.
|
|
77
|
-
*/
|
|
78
|
-
deviceId = did
|
|
79
|
-
isDifferentDid = true
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isDifferentDid) {
|
|
83
|
-
/*
|
|
84
|
-
* If we're merging in a different DID, we should also generate a new
|
|
85
|
-
* sessionId to avoid mixing events from different users under the same
|
|
86
|
-
* session.
|
|
87
|
-
*/
|
|
88
|
-
sessionId = `anon-${crypto.randomUUID()}`
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
did,
|
|
93
|
-
deviceId,
|
|
94
|
-
sessionId,
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Extract the `UserContext` from GrowthBook's own `UserContext`, which we
|
|
100
|
-
* passed into `isOn` as `attributes`.
|
|
101
|
-
*/
|
|
102
|
-
export function extractUserContextFromGrowthbookUserContext(
|
|
103
|
-
userContext: GrowthBookUserContext,
|
|
104
|
-
): NormalizedUserContext {
|
|
105
|
-
/*
|
|
106
|
-
* The values passed to Growthbook already should have been
|
|
107
|
-
* `NormalizedUserContext`, but for type safety we run them through the
|
|
108
|
-
* normalizer again to ensure we have all the required properties and
|
|
109
|
-
* fallbacks in place.
|
|
110
|
-
*/
|
|
111
|
-
return normalizeUserContext({
|
|
112
|
-
did: userContext.attributes?.did,
|
|
113
|
-
deviceId: userContext.attributes?.deviceId,
|
|
114
|
-
sessionId: userContext.attributes?.sessionId,
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Convert the `UserContext` into the `TrackingMetadata` format that we
|
|
120
|
-
* use for our analytics events. This ensures that we have the same user
|
|
121
|
-
* properties as we do for events from our client app.
|
|
122
|
-
*/
|
|
123
|
-
export function parsedUserContextToTrackingMetadata(
|
|
124
|
-
userContext: NormalizedUserContext,
|
|
125
|
-
): TrackingMetadata {
|
|
126
|
-
return {
|
|
127
|
-
base: {
|
|
128
|
-
deviceId: userContext.deviceId,
|
|
129
|
-
sessionId: userContext.sessionId,
|
|
130
|
-
},
|
|
131
|
-
session: {
|
|
132
|
-
did: userContext.did ?? undefined,
|
|
133
|
-
},
|
|
134
|
-
}
|
|
135
|
-
}
|
package/src/hydration/actor.ts
DELETED
|
@@ -1,578 +0,0 @@
|
|
|
1
|
-
import { mapDefined } from '@atproto/common'
|
|
2
|
-
import {
|
|
3
|
-
AtIdentifierString,
|
|
4
|
-
AtUriString,
|
|
5
|
-
DatetimeString,
|
|
6
|
-
DidString,
|
|
7
|
-
HandleString,
|
|
8
|
-
isDidIdentifier,
|
|
9
|
-
isHandleIdentifier,
|
|
10
|
-
normalizeHandle,
|
|
11
|
-
} from '@atproto/syntax'
|
|
12
|
-
import { DataPlaneClient } from '../data-plane/client/index.js'
|
|
13
|
-
import { app, chat, com } from '../lexicons/index.js'
|
|
14
|
-
import { ActivitySubscription, VerificationMeta } from '../proto/bsky_pb.js'
|
|
15
|
-
import {
|
|
16
|
-
ChatDeclarationRecord,
|
|
17
|
-
GermDeclarationRecord,
|
|
18
|
-
NotificationDeclarationRecord,
|
|
19
|
-
ProfileRecord,
|
|
20
|
-
StatusRecord,
|
|
21
|
-
} from '../views/types.js'
|
|
22
|
-
import {
|
|
23
|
-
HydrationMap,
|
|
24
|
-
RecordInfo,
|
|
25
|
-
isActivitySubscriptionEnabled,
|
|
26
|
-
parseDate,
|
|
27
|
-
parseRecord,
|
|
28
|
-
parseString,
|
|
29
|
-
safeTakedownRef,
|
|
30
|
-
} from './util.js'
|
|
31
|
-
|
|
32
|
-
type AllowActivitySubscriptions = Extract<
|
|
33
|
-
app.bsky.notification.declaration.Main['allowSubscriptions'],
|
|
34
|
-
'followers' | 'mutuals' | 'none'
|
|
35
|
-
>
|
|
36
|
-
|
|
37
|
-
export type Actor = {
|
|
38
|
-
did: DidString
|
|
39
|
-
handle?: HandleString
|
|
40
|
-
profile?: ProfileRecord
|
|
41
|
-
profileCid?: string
|
|
42
|
-
profileTakedownRef?: string
|
|
43
|
-
sortedAt?: Date
|
|
44
|
-
indexedAt?: Date
|
|
45
|
-
takedownRef?: string
|
|
46
|
-
isLabeler: boolean
|
|
47
|
-
allowIncomingChatsFrom?: string
|
|
48
|
-
allowGroupChatInvitesFrom?: string
|
|
49
|
-
upstreamStatus?: string
|
|
50
|
-
createdAt?: Date
|
|
51
|
-
priorityNotifications: boolean
|
|
52
|
-
trustedVerifier?: boolean
|
|
53
|
-
verifications: VerificationHydrationState[]
|
|
54
|
-
status?: RecordInfo<StatusRecord>
|
|
55
|
-
germ?: RecordInfo<GermDeclarationRecord>
|
|
56
|
-
allowActivitySubscriptionsFrom: AllowActivitySubscriptions
|
|
57
|
-
/**
|
|
58
|
-
* Debug information for internal development
|
|
59
|
-
*/
|
|
60
|
-
debug?: {
|
|
61
|
-
pagerank?: string
|
|
62
|
-
accountTags?: string[]
|
|
63
|
-
profileTags?: string[]
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type VerificationHydrationState = {
|
|
68
|
-
issuer: DidString
|
|
69
|
-
uri: AtUriString
|
|
70
|
-
handle: HandleString
|
|
71
|
-
displayName: string
|
|
72
|
-
createdAt: DatetimeString
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export type VerificationMetaRequired = Required<VerificationMeta>
|
|
76
|
-
|
|
77
|
-
export type Actors = HydrationMap<DidString, Actor>
|
|
78
|
-
|
|
79
|
-
export type ChatDeclaration = RecordInfo<ChatDeclarationRecord>
|
|
80
|
-
export type ChatDeclarations = HydrationMap<AtUriString, ChatDeclaration>
|
|
81
|
-
|
|
82
|
-
export type GermDeclaration = RecordInfo<GermDeclarationRecord>
|
|
83
|
-
export type GermDeclarations = HydrationMap<AtUriString, GermDeclaration>
|
|
84
|
-
|
|
85
|
-
export type NotificationDeclaration = RecordInfo<NotificationDeclarationRecord>
|
|
86
|
-
export type NotificationDeclarations = HydrationMap<
|
|
87
|
-
AtUriString,
|
|
88
|
-
NotificationDeclaration
|
|
89
|
-
>
|
|
90
|
-
|
|
91
|
-
export type Status = RecordInfo<StatusRecord>
|
|
92
|
-
export type Statuses = HydrationMap<AtUriString, Status>
|
|
93
|
-
|
|
94
|
-
export type ProfileViewerState = {
|
|
95
|
-
did: DidString
|
|
96
|
-
muted?: boolean
|
|
97
|
-
mutedByList?: AtUriString
|
|
98
|
-
blockedBy?: AtUriString
|
|
99
|
-
blocking?: AtUriString
|
|
100
|
-
blockedByList?: AtUriString
|
|
101
|
-
blockingByList?: AtUriString
|
|
102
|
-
following?: AtUriString
|
|
103
|
-
followedBy?: AtUriString
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ProfileViewerStates = HydrationMap<
|
|
107
|
-
AtIdentifierString,
|
|
108
|
-
ProfileViewerState
|
|
109
|
-
>
|
|
110
|
-
|
|
111
|
-
type ActivitySubscriptionState = {
|
|
112
|
-
post: boolean
|
|
113
|
-
reply: boolean
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export type ActivitySubscriptionStates = HydrationMap<
|
|
117
|
-
DidString,
|
|
118
|
-
ActivitySubscriptionState | undefined
|
|
119
|
-
>
|
|
120
|
-
|
|
121
|
-
type KnownFollowersState = {
|
|
122
|
-
count: number
|
|
123
|
-
followers: DidString[]
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export type KnownFollowersStates = HydrationMap<
|
|
127
|
-
DidString,
|
|
128
|
-
KnownFollowersState | undefined
|
|
129
|
-
>
|
|
130
|
-
|
|
131
|
-
export type ProfileAgg = {
|
|
132
|
-
followers: number
|
|
133
|
-
follows: number
|
|
134
|
-
posts: number
|
|
135
|
-
lists: number
|
|
136
|
-
feeds: number
|
|
137
|
-
starterPacks: number
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export type ProfileAggs = HydrationMap<DidString, ProfileAgg>
|
|
141
|
-
|
|
142
|
-
export class ActorHydrator {
|
|
143
|
-
constructor(public dataplane: DataPlaneClient) {}
|
|
144
|
-
|
|
145
|
-
async getRepoRevSafe(did: string | null): Promise<string | null> {
|
|
146
|
-
if (!did) return null
|
|
147
|
-
try {
|
|
148
|
-
const res = await this.dataplane.getLatestRev({ actorDid: did })
|
|
149
|
-
return parseString(res.rev) ?? null
|
|
150
|
-
} catch {
|
|
151
|
-
return null
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @note handles do not need to be normalized
|
|
157
|
-
*/
|
|
158
|
-
async getDids(
|
|
159
|
-
handleOrDids: AtIdentifierString[],
|
|
160
|
-
opts?: { lookupUnidirectional?: boolean },
|
|
161
|
-
): Promise<(DidString | undefined)[]> {
|
|
162
|
-
const didByHandle = new Map<HandleString, DidString>()
|
|
163
|
-
|
|
164
|
-
const handles = handleOrDids.filter(isHandleIdentifier)
|
|
165
|
-
if (handles.length) {
|
|
166
|
-
const { dids } = await this.dataplane.getDidsByHandles({
|
|
167
|
-
handles: handles.map(normalizeHandle),
|
|
168
|
-
lookupUnidirectional: opts?.lookupUnidirectional,
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
for (let i = 0; i < handles.length; i++) {
|
|
172
|
-
const did = parseString<DidString>(dids[i])
|
|
173
|
-
if (did) didByHandle.set(handles[i], did)
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return handleOrDids.map((id) =>
|
|
178
|
-
isDidIdentifier(id) ? id : didByHandle.get(id),
|
|
179
|
-
)
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async getDidsDefined(
|
|
183
|
-
handleOrDids: AtIdentifierString[],
|
|
184
|
-
): Promise<DidString[]> {
|
|
185
|
-
const res = await this.getDids(handleOrDids)
|
|
186
|
-
return res.filter((v) => v != null)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
async getActors(
|
|
190
|
-
dids: DidString[],
|
|
191
|
-
opts: {
|
|
192
|
-
includeTakedowns?: boolean
|
|
193
|
-
skipCacheForDids?: DidString[]
|
|
194
|
-
} = {},
|
|
195
|
-
): Promise<Actors> {
|
|
196
|
-
const map: Actors = new HydrationMap()
|
|
197
|
-
if (!dids.length) return map
|
|
198
|
-
|
|
199
|
-
const { includeTakedowns = false, skipCacheForDids } = opts
|
|
200
|
-
|
|
201
|
-
const res = await this.dataplane.getActors({ dids, skipCacheForDids })
|
|
202
|
-
for (let i = 0; i < dids.length; i++) {
|
|
203
|
-
const did = dids[i]
|
|
204
|
-
|
|
205
|
-
const actor = res.actors[i]
|
|
206
|
-
const isNoHosted =
|
|
207
|
-
actor.takenDown ||
|
|
208
|
-
(actor.upstreamStatus && actor.upstreamStatus !== 'active')
|
|
209
|
-
if (
|
|
210
|
-
!actor.exists ||
|
|
211
|
-
(isNoHosted && !includeTakedowns) ||
|
|
212
|
-
!!actor.tombstonedAt
|
|
213
|
-
) {
|
|
214
|
-
map.set(did, null)
|
|
215
|
-
continue
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const profile = actor.profile?.record
|
|
219
|
-
? parseRecord(
|
|
220
|
-
app.bsky.actor.profile.main,
|
|
221
|
-
actor.profile,
|
|
222
|
-
includeTakedowns,
|
|
223
|
-
)
|
|
224
|
-
: undefined
|
|
225
|
-
|
|
226
|
-
const status = actor.statusRecord
|
|
227
|
-
? parseRecord(
|
|
228
|
-
app.bsky.actor.status.main,
|
|
229
|
-
actor.statusRecord,
|
|
230
|
-
/*
|
|
231
|
-
* Always true, we filter this out in the `Views.status()`. If we
|
|
232
|
-
* ever remove that filter, we'll want to reinstate this here.
|
|
233
|
-
*/
|
|
234
|
-
true,
|
|
235
|
-
)
|
|
236
|
-
: undefined
|
|
237
|
-
|
|
238
|
-
const germ = actor.germRecord
|
|
239
|
-
? parseRecord(
|
|
240
|
-
com.germnetwork.declaration.main,
|
|
241
|
-
actor.germRecord,
|
|
242
|
-
includeTakedowns,
|
|
243
|
-
)
|
|
244
|
-
: undefined
|
|
245
|
-
|
|
246
|
-
const verifications = mapDefined(
|
|
247
|
-
Object.entries(actor.verifiedBy) as [DidString, VerificationMeta][],
|
|
248
|
-
([actorDid, verificationMeta]):
|
|
249
|
-
| VerificationHydrationState
|
|
250
|
-
| undefined => {
|
|
251
|
-
if (
|
|
252
|
-
verificationMeta.handle &&
|
|
253
|
-
verificationMeta.rkey &&
|
|
254
|
-
verificationMeta.sortedAt
|
|
255
|
-
) {
|
|
256
|
-
return {
|
|
257
|
-
issuer: actorDid,
|
|
258
|
-
uri: `at://${actorDid}/app.bsky.graph.verification/${verificationMeta.rkey}`,
|
|
259
|
-
handle: verificationMeta.handle as HandleString,
|
|
260
|
-
displayName: verificationMeta.displayName,
|
|
261
|
-
createdAt: (
|
|
262
|
-
parseDate(verificationMeta.sortedAt) ?? new Date(0)
|
|
263
|
-
).toISOString() as DatetimeString,
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
// Filter out the verification meta that doesn't contain all info.
|
|
267
|
-
return undefined
|
|
268
|
-
},
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
const allowActivitySubscriptionsFrom = (
|
|
272
|
-
val: string,
|
|
273
|
-
): AllowActivitySubscriptions => {
|
|
274
|
-
switch (val) {
|
|
275
|
-
case 'followers':
|
|
276
|
-
case 'mutuals':
|
|
277
|
-
case 'none':
|
|
278
|
-
return val
|
|
279
|
-
default:
|
|
280
|
-
// The dataplane should set the default of "FOLLOWERS". Just in case.
|
|
281
|
-
return 'followers'
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
const debug = {
|
|
286
|
-
pagerank: actor.pagerank ? actor.pagerank.toString() : undefined,
|
|
287
|
-
accountTags: actor.tags,
|
|
288
|
-
profileTags: actor.profileTags,
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
map.set(did, {
|
|
292
|
-
did,
|
|
293
|
-
handle: parseString<HandleString>(actor.handle),
|
|
294
|
-
profile: profile?.record,
|
|
295
|
-
profileCid: profile?.cid,
|
|
296
|
-
profileTakedownRef: profile?.takedownRef,
|
|
297
|
-
sortedAt: profile?.sortedAt,
|
|
298
|
-
indexedAt: profile?.indexedAt,
|
|
299
|
-
takedownRef: safeTakedownRef(actor),
|
|
300
|
-
isLabeler: actor.labeler ?? false,
|
|
301
|
-
allowIncomingChatsFrom: actor.allowIncomingChatsFrom || undefined,
|
|
302
|
-
allowGroupChatInvitesFrom: actor.allowGroupChatInvitesFrom || undefined,
|
|
303
|
-
upstreamStatus: actor.upstreamStatus || undefined,
|
|
304
|
-
createdAt: parseDate(actor.createdAt),
|
|
305
|
-
priorityNotifications: actor.priorityNotifications,
|
|
306
|
-
trustedVerifier: actor.trustedVerifier,
|
|
307
|
-
verifications,
|
|
308
|
-
status: status,
|
|
309
|
-
germ: germ,
|
|
310
|
-
allowActivitySubscriptionsFrom: allowActivitySubscriptionsFrom(
|
|
311
|
-
actor.allowActivitySubscriptionsFrom,
|
|
312
|
-
),
|
|
313
|
-
debug,
|
|
314
|
-
})
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return map
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
async getChatDeclarations(
|
|
321
|
-
uris: AtUriString[],
|
|
322
|
-
includeTakedowns = false,
|
|
323
|
-
): Promise<ChatDeclarations> {
|
|
324
|
-
const map: ChatDeclarations = new HydrationMap()
|
|
325
|
-
if (!uris.length) return map
|
|
326
|
-
|
|
327
|
-
const res = await this.dataplane.getActorChatDeclarationRecords({ uris })
|
|
328
|
-
for (let i = 0; i < uris.length; i++) {
|
|
329
|
-
const uri = uris[i]
|
|
330
|
-
const record = parseRecord(
|
|
331
|
-
chat.bsky.actor.declaration.main,
|
|
332
|
-
res.records[i],
|
|
333
|
-
includeTakedowns,
|
|
334
|
-
)
|
|
335
|
-
map.set(uri, record ?? null)
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return map
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
async getGermDeclarations(
|
|
342
|
-
uris: AtUriString[],
|
|
343
|
-
includeTakedowns = false,
|
|
344
|
-
): Promise<GermDeclarations> {
|
|
345
|
-
const map: GermDeclarations = new HydrationMap()
|
|
346
|
-
if (!uris.length) return map
|
|
347
|
-
|
|
348
|
-
const res = await this.dataplane.getGermDeclarationRecords({ uris })
|
|
349
|
-
for (let i = 0; i < uris.length; i++) {
|
|
350
|
-
const record = parseRecord(
|
|
351
|
-
com.germnetwork.declaration.main,
|
|
352
|
-
res.records[i],
|
|
353
|
-
includeTakedowns,
|
|
354
|
-
)
|
|
355
|
-
map.set(uris[i], record ?? null)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return map
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
async getNotificationDeclarations(
|
|
362
|
-
uris: AtUriString[],
|
|
363
|
-
includeTakedowns = false,
|
|
364
|
-
): Promise<NotificationDeclarations> {
|
|
365
|
-
const map: NotificationDeclarations = new HydrationMap()
|
|
366
|
-
if (!uris.length) return map
|
|
367
|
-
|
|
368
|
-
const res = await this.dataplane.getNotificationDeclarationRecords({
|
|
369
|
-
uris,
|
|
370
|
-
})
|
|
371
|
-
for (let i = 0; i < uris.length; i++) {
|
|
372
|
-
const uri = uris[i]
|
|
373
|
-
const record = parseRecord(
|
|
374
|
-
app.bsky.notification.declaration.main,
|
|
375
|
-
res.records[i],
|
|
376
|
-
includeTakedowns,
|
|
377
|
-
)
|
|
378
|
-
map.set(uri, record ?? null)
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
return map
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
async getStatus(
|
|
385
|
-
uris: AtUriString[],
|
|
386
|
-
includeTakedowns = false,
|
|
387
|
-
): Promise<Statuses> {
|
|
388
|
-
const map: Statuses = new HydrationMap()
|
|
389
|
-
if (!uris.length) return map
|
|
390
|
-
|
|
391
|
-
const res = await this.dataplane.getStatusRecords({ uris })
|
|
392
|
-
for (let i = 0; i < uris.length; i++) {
|
|
393
|
-
const uri = uris[i]
|
|
394
|
-
const record = parseRecord(
|
|
395
|
-
app.bsky.actor.status.main,
|
|
396
|
-
res.records[i],
|
|
397
|
-
includeTakedowns,
|
|
398
|
-
)
|
|
399
|
-
map.set(uri, record ?? null)
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return map
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// "naive" because this method does not verify the existence of the list itself
|
|
406
|
-
// a later check in the main hydrator will remove list uris that have been deleted or
|
|
407
|
-
// repurposed to "curate lists"
|
|
408
|
-
async getProfileViewerStatesNaive(
|
|
409
|
-
actors: AtIdentifierString[],
|
|
410
|
-
viewer: DidString,
|
|
411
|
-
): Promise<ProfileViewerStates> {
|
|
412
|
-
const map: ProfileViewerStates = new HydrationMap()
|
|
413
|
-
if (!actors.length) return map
|
|
414
|
-
|
|
415
|
-
// @TODO we could use "await this.getDids(actors)" here to resolve the
|
|
416
|
-
// handles (no other code change should be needed). This was not done as
|
|
417
|
-
// part of this PR to avoid changing the behavior of this method.
|
|
418
|
-
const actorDids = actors.map((a) => (isDidIdentifier(a) ? a : undefined))
|
|
419
|
-
|
|
420
|
-
// getRelationships requires DidString so we remove anything that isn't one
|
|
421
|
-
const actorDidsDefined = Array.from(
|
|
422
|
-
new Set(
|
|
423
|
-
actorDids
|
|
424
|
-
.filter((did) => did != null)
|
|
425
|
-
// Since we special case self-relationship below, we can skip querying
|
|
426
|
-
// the dataplane for the viewer's own DID if it's included in the
|
|
427
|
-
// input.
|
|
428
|
-
.filter((did) => did !== viewer),
|
|
429
|
-
),
|
|
430
|
-
)
|
|
431
|
-
|
|
432
|
-
const res = await this.dataplane.getRelationships({
|
|
433
|
-
actorDid: viewer,
|
|
434
|
-
targetDids: actorDidsDefined,
|
|
435
|
-
})
|
|
436
|
-
|
|
437
|
-
const actorToDid = new Map<AtIdentifierString, DidString | undefined>(
|
|
438
|
-
actors.map((actor, i) => [actor, actorDids[i]]),
|
|
439
|
-
)
|
|
440
|
-
|
|
441
|
-
for (let i = 0; i < actors.length; i++) {
|
|
442
|
-
const actor = actors[i]
|
|
443
|
-
|
|
444
|
-
const did = actorToDid.get(actor)
|
|
445
|
-
// ignore unresolved handles
|
|
446
|
-
if (!did) continue
|
|
447
|
-
|
|
448
|
-
if (did === viewer) {
|
|
449
|
-
// ignore self-follows, self-mutes, self-blocks, self-activity-subscriptions
|
|
450
|
-
map.set(actor, { did })
|
|
451
|
-
continue
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// Get the index that was used to query the relationships for this actor
|
|
455
|
-
const index = actorDidsDefined.indexOf(did)
|
|
456
|
-
if (index === -1) continue
|
|
457
|
-
|
|
458
|
-
const rels = res.relationships[index]
|
|
459
|
-
map.set(actor, {
|
|
460
|
-
did,
|
|
461
|
-
muted: rels.muted ?? false,
|
|
462
|
-
mutedByList: parseString(rels.mutedByList),
|
|
463
|
-
blockedBy: parseString(rels.blockedBy),
|
|
464
|
-
blocking: parseString<AtUriString>(rels.blocking),
|
|
465
|
-
blockedByList: parseString(rels.blockedByList),
|
|
466
|
-
blockingByList: parseString(rels.blockingByList),
|
|
467
|
-
following: parseString<AtUriString>(rels.following),
|
|
468
|
-
followedBy: parseString(rels.followedBy),
|
|
469
|
-
})
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
return map
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
async getKnownFollowers(
|
|
476
|
-
dids: DidString[],
|
|
477
|
-
viewer: DidString | null,
|
|
478
|
-
): Promise<KnownFollowersStates> {
|
|
479
|
-
const map: KnownFollowersStates = new HydrationMap()
|
|
480
|
-
if (!viewer) return map
|
|
481
|
-
if (!dids.length) return map
|
|
482
|
-
|
|
483
|
-
try {
|
|
484
|
-
const { results: knownFollowersResults } =
|
|
485
|
-
await this.dataplane.getFollowsFollowing(
|
|
486
|
-
{
|
|
487
|
-
actorDid: viewer,
|
|
488
|
-
targetDids: dids,
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
signal: AbortSignal.timeout(100),
|
|
492
|
-
},
|
|
493
|
-
)
|
|
494
|
-
|
|
495
|
-
for (let i = 0; i < dids.length; i++) {
|
|
496
|
-
const did = dids[i]
|
|
497
|
-
|
|
498
|
-
const result = knownFollowersResults[i]?.dids
|
|
499
|
-
|
|
500
|
-
map.set(
|
|
501
|
-
did,
|
|
502
|
-
result && result.length > 0
|
|
503
|
-
? {
|
|
504
|
-
count: result.length,
|
|
505
|
-
followers: result.slice(0, 5) as DidString[],
|
|
506
|
-
}
|
|
507
|
-
: undefined,
|
|
508
|
-
)
|
|
509
|
-
}
|
|
510
|
-
} catch {
|
|
511
|
-
// ignore errors and return empty map
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
return map
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
async getActivitySubscriptions(
|
|
518
|
-
dids: DidString[],
|
|
519
|
-
viewer: DidString | null,
|
|
520
|
-
): Promise<ActivitySubscriptionStates> {
|
|
521
|
-
const map: ActivitySubscriptionStates = new HydrationMap()
|
|
522
|
-
if (!viewer) return map
|
|
523
|
-
if (!dids.length) return map
|
|
524
|
-
|
|
525
|
-
try {
|
|
526
|
-
const { subscriptions } =
|
|
527
|
-
await this.dataplane.getActivitySubscriptionsByActorAndSubjects(
|
|
528
|
-
{ actorDid: viewer, subjectDids: dids },
|
|
529
|
-
{ signal: AbortSignal.timeout(100) },
|
|
530
|
-
)
|
|
531
|
-
|
|
532
|
-
for (let i = 0; i < dids.length; i++) {
|
|
533
|
-
// @NOTE Although not typed as nullable, the code here used to defend
|
|
534
|
-
// against potentially missing subscription objects in the response, so
|
|
535
|
-
// we keep that defense in place.
|
|
536
|
-
const subscription = subscriptions[i] as
|
|
537
|
-
| ActivitySubscription
|
|
538
|
-
| undefined
|
|
539
|
-
|
|
540
|
-
const state = {
|
|
541
|
-
post: subscription?.post != null,
|
|
542
|
-
reply: subscription?.reply != null,
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
const did = dids[i]!
|
|
546
|
-
if (isActivitySubscriptionEnabled(state)) {
|
|
547
|
-
map.set(did, state)
|
|
548
|
-
} else {
|
|
549
|
-
map.set(did, undefined)
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
} catch {
|
|
553
|
-
// ignore errors and return empty map
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
return map
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
async getProfileAggregates(dids: DidString[]): Promise<ProfileAggs> {
|
|
560
|
-
const map: ProfileAggs = new HydrationMap()
|
|
561
|
-
if (!dids.length) return map
|
|
562
|
-
|
|
563
|
-
const counts = await this.dataplane.getCountsForUsers({ dids })
|
|
564
|
-
for (let i = 0; i < dids.length; i++) {
|
|
565
|
-
const did = dids[i]
|
|
566
|
-
map.set(did, {
|
|
567
|
-
followers: counts.followers[i] ?? 0,
|
|
568
|
-
follows: counts.following[i] ?? 0,
|
|
569
|
-
posts: counts.posts[i] ?? 0,
|
|
570
|
-
lists: counts.lists[i] ?? 0,
|
|
571
|
-
feeds: counts.feeds[i] ?? 0,
|
|
572
|
-
starterPacks: counts.starterPacks[i] ?? 0,
|
|
573
|
-
})
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return map
|
|
577
|
-
}
|
|
578
|
-
}
|