@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,44 +0,0 @@
|
|
|
1
|
-
import events from 'node:events'
|
|
2
|
-
import http from 'node:http'
|
|
3
|
-
import { expressConnectMiddleware } from '@connectrpc/connect-express'
|
|
4
|
-
import express from 'express'
|
|
5
|
-
// eslint-disable-next-line import/default
|
|
6
|
-
import httpTerminator from 'http-terminator'
|
|
7
|
-
import { IdResolver, MemoryCache } from '@atproto/identity'
|
|
8
|
-
import { Database, DatabaseSchema } from './db/index.js'
|
|
9
|
-
import createRoutes from './routes/index.js'
|
|
10
|
-
|
|
11
|
-
export type { DatabaseSchema }
|
|
12
|
-
|
|
13
|
-
export { BsyncSubscription } from './bsync-subscription.js'
|
|
14
|
-
export { RepoSubscription } from './subscription.js'
|
|
15
|
-
|
|
16
|
-
export class DataPlaneServer {
|
|
17
|
-
private terminator: httpTerminator.HttpTerminator
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
20
|
-
public server: http.Server,
|
|
21
|
-
public idResolver: IdResolver,
|
|
22
|
-
) {
|
|
23
|
-
this.terminator = httpTerminator.createHttpTerminator({ server })
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static async create(db: Database, port: number, plcUrl?: string) {
|
|
27
|
-
const app = express()
|
|
28
|
-
const didCache = new MemoryCache()
|
|
29
|
-
const idResolver = new IdResolver({ plcUrl, didCache })
|
|
30
|
-
const routes = createRoutes(db, idResolver)
|
|
31
|
-
app.use(expressConnectMiddleware({ routes }))
|
|
32
|
-
const server = app.listen(port)
|
|
33
|
-
await events.once(server, 'listening')
|
|
34
|
-
return new DataPlaneServer(server, idResolver)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async destroy() {
|
|
38
|
-
await this.terminator.terminate()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async [Symbol.asyncDispose]() {
|
|
42
|
-
await this.destroy()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import { Selectable, sql } from 'kysely'
|
|
2
|
-
import { DAY, HOUR } from '@atproto/common'
|
|
3
|
-
import { IdResolver, getPds } from '@atproto/identity'
|
|
4
|
-
import { Cid, l, parseCid, xrpc, xrpcSafe } from '@atproto/lex'
|
|
5
|
-
import {
|
|
6
|
-
VerifiedRepo,
|
|
7
|
-
WriteOpAction,
|
|
8
|
-
getAndParseRecord,
|
|
9
|
-
readCarWithRoot,
|
|
10
|
-
verifyRepo,
|
|
11
|
-
} from '@atproto/repo'
|
|
12
|
-
import { AtUri, DidString } from '@atproto/syntax'
|
|
13
|
-
import { com } from '../../../lexicons/index.js'
|
|
14
|
-
import { subLogger } from '../../../logger.js'
|
|
15
|
-
import { retryXrpc } from '../../../util/retry.js'
|
|
16
|
-
import { BackgroundQueue } from '../background.js'
|
|
17
|
-
import { Database } from '../db/index.js'
|
|
18
|
-
import { Actor } from '../db/tables/actor.js'
|
|
19
|
-
import * as Block from './plugins/block.js'
|
|
20
|
-
import * as ChatDeclaration from './plugins/chat-declaration.js'
|
|
21
|
-
import * as FeedGenerator from './plugins/feed-generator.js'
|
|
22
|
-
import * as Follow from './plugins/follow.js'
|
|
23
|
-
import * as GermDeclaration from './plugins/germ-declaration.js'
|
|
24
|
-
import * as Labeler from './plugins/labeler.js'
|
|
25
|
-
import * as Like from './plugins/like.js'
|
|
26
|
-
import * as ListBlock from './plugins/list-block.js'
|
|
27
|
-
import * as ListItem from './plugins/list-item.js'
|
|
28
|
-
import * as List from './plugins/list.js'
|
|
29
|
-
import * as NotifDeclaration from './plugins/notif-declaration.js'
|
|
30
|
-
import * as Postgate from './plugins/post-gate.js'
|
|
31
|
-
import * as Post from './plugins/post.js'
|
|
32
|
-
import * as Profile from './plugins/profile.js'
|
|
33
|
-
import * as Repost from './plugins/repost.js'
|
|
34
|
-
import * as StarterPack from './plugins/starter-pack.js'
|
|
35
|
-
import * as Status from './plugins/status.js'
|
|
36
|
-
import * as Threadgate from './plugins/thread-gate.js'
|
|
37
|
-
import * as Verification from './plugins/verification.js'
|
|
38
|
-
|
|
39
|
-
export class IndexingService {
|
|
40
|
-
records: {
|
|
41
|
-
post: Post.PluginType
|
|
42
|
-
threadGate: Threadgate.PluginType
|
|
43
|
-
postGate: Postgate.PluginType
|
|
44
|
-
like: Like.PluginType
|
|
45
|
-
repost: Repost.PluginType
|
|
46
|
-
follow: Follow.PluginType
|
|
47
|
-
profile: Profile.PluginType
|
|
48
|
-
list: List.PluginType
|
|
49
|
-
listItem: ListItem.PluginType
|
|
50
|
-
listBlock: ListBlock.PluginType
|
|
51
|
-
block: Block.PluginType
|
|
52
|
-
feedGenerator: FeedGenerator.PluginType
|
|
53
|
-
starterPack: StarterPack.PluginType
|
|
54
|
-
labeler: Labeler.PluginType
|
|
55
|
-
notifDeclaration: NotifDeclaration.PluginType
|
|
56
|
-
chatDeclaration: ChatDeclaration.PluginType
|
|
57
|
-
germDeclaration: GermDeclaration.PluginType
|
|
58
|
-
verification: Verification.PluginType
|
|
59
|
-
status: Status.PluginType
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
constructor(
|
|
63
|
-
public db: Database,
|
|
64
|
-
public idResolver: IdResolver,
|
|
65
|
-
public background: BackgroundQueue<Database>,
|
|
66
|
-
) {
|
|
67
|
-
this.records = {
|
|
68
|
-
post: Post.makePlugin(this.db, this.background),
|
|
69
|
-
threadGate: Threadgate.makePlugin(this.db, this.background),
|
|
70
|
-
postGate: Postgate.makePlugin(this.db, this.background),
|
|
71
|
-
like: Like.makePlugin(this.db, this.background),
|
|
72
|
-
repost: Repost.makePlugin(this.db, this.background),
|
|
73
|
-
follow: Follow.makePlugin(this.db, this.background),
|
|
74
|
-
profile: Profile.makePlugin(this.db, this.background),
|
|
75
|
-
list: List.makePlugin(this.db, this.background),
|
|
76
|
-
listItem: ListItem.makePlugin(this.db, this.background),
|
|
77
|
-
listBlock: ListBlock.makePlugin(this.db, this.background),
|
|
78
|
-
block: Block.makePlugin(this.db, this.background),
|
|
79
|
-
feedGenerator: FeedGenerator.makePlugin(this.db, this.background),
|
|
80
|
-
starterPack: StarterPack.makePlugin(this.db, this.background),
|
|
81
|
-
labeler: Labeler.makePlugin(this.db, this.background),
|
|
82
|
-
notifDeclaration: NotifDeclaration.makePlugin(this.db, this.background),
|
|
83
|
-
chatDeclaration: ChatDeclaration.makePlugin(this.db, this.background),
|
|
84
|
-
germDeclaration: GermDeclaration.makePlugin(this.db, this.background),
|
|
85
|
-
verification: Verification.makePlugin(this.db, this.background),
|
|
86
|
-
status: Status.makePlugin(this.db, this.background),
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
transact(txn: Database) {
|
|
91
|
-
txn.assertTransaction()
|
|
92
|
-
return new IndexingService(txn, this.idResolver, this.background)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async indexRecord(
|
|
96
|
-
uri: AtUri,
|
|
97
|
-
cid: Cid,
|
|
98
|
-
obj: unknown,
|
|
99
|
-
action: WriteOpAction.Create | WriteOpAction.Update,
|
|
100
|
-
timestamp: string,
|
|
101
|
-
opts?: { disableNotifs?: boolean; disableLabels?: boolean },
|
|
102
|
-
) {
|
|
103
|
-
this.db.assertNotTransaction()
|
|
104
|
-
return this.db.transaction(async (txn) => {
|
|
105
|
-
const indexingTx = this.transact(txn)
|
|
106
|
-
const indexer = indexingTx.findIndexerForCollection(uri.collection)
|
|
107
|
-
if (!indexer) return
|
|
108
|
-
if (action === WriteOpAction.Create) {
|
|
109
|
-
await indexer.insertRecord(uri, cid, obj, timestamp, opts)
|
|
110
|
-
} else {
|
|
111
|
-
await indexer.updateRecord(uri, cid, obj, timestamp)
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async deleteRecord(uri: AtUri, cascading = false) {
|
|
117
|
-
this.db.assertNotTransaction()
|
|
118
|
-
await this.db.transaction(async (txn) => {
|
|
119
|
-
const indexingTx = this.transact(txn)
|
|
120
|
-
const indexer = indexingTx.findIndexerForCollection(uri.collection)
|
|
121
|
-
if (!indexer) return
|
|
122
|
-
await indexer.deleteRecord(uri, cascading)
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async indexHandle(did: string, timestamp: string, force = false) {
|
|
127
|
-
this.db.assertNotTransaction()
|
|
128
|
-
const actor = await this.db.db
|
|
129
|
-
.selectFrom('actor')
|
|
130
|
-
.where('did', '=', did)
|
|
131
|
-
.selectAll()
|
|
132
|
-
.executeTakeFirst()
|
|
133
|
-
if (!force && !needsHandleReindex(actor, timestamp)) {
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
const atpData = await this.idResolver.did.resolveAtprotoData(did, true)
|
|
137
|
-
const handleToDid = await this.idResolver.handle.resolve(atpData.handle)
|
|
138
|
-
|
|
139
|
-
const handle: string | null =
|
|
140
|
-
did === handleToDid ? atpData.handle.toLowerCase() : null
|
|
141
|
-
|
|
142
|
-
const actorWithHandle =
|
|
143
|
-
handle !== null
|
|
144
|
-
? await this.db.db
|
|
145
|
-
.selectFrom('actor')
|
|
146
|
-
.where('handle', '=', handle)
|
|
147
|
-
.selectAll()
|
|
148
|
-
.executeTakeFirst()
|
|
149
|
-
: null
|
|
150
|
-
|
|
151
|
-
// handle contention
|
|
152
|
-
if (handle && actorWithHandle && did !== actorWithHandle.did) {
|
|
153
|
-
await this.db.db
|
|
154
|
-
.updateTable('actor')
|
|
155
|
-
.where('actor.did', '=', actorWithHandle.did)
|
|
156
|
-
.set({ handle: null })
|
|
157
|
-
.execute()
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const actorInfo = { handle, indexedAt: timestamp }
|
|
161
|
-
await this.db.db
|
|
162
|
-
.insertInto('actor')
|
|
163
|
-
.values({ did, ...actorInfo })
|
|
164
|
-
.onConflict((oc) => oc.column('did').doUpdateSet(actorInfo))
|
|
165
|
-
.returning('did')
|
|
166
|
-
.executeTakeFirst()
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async indexRepo(did: DidString, commit?: string) {
|
|
170
|
-
this.db.assertNotTransaction()
|
|
171
|
-
const now = new Date().toISOString()
|
|
172
|
-
const { pds, signingKey } = await this.idResolver.did.resolveAtprotoData(
|
|
173
|
-
did,
|
|
174
|
-
true,
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
const { body: car } = await retryXrpc(() => {
|
|
178
|
-
return xrpc(pds, com.atproto.sync.getRepo, { params: { did } })
|
|
179
|
-
})
|
|
180
|
-
const { root, blocks } = await readCarWithRoot(car)
|
|
181
|
-
const verifiedRepo = await verifyRepo(blocks, root, did, signingKey)
|
|
182
|
-
|
|
183
|
-
const currRecords = await this.getCurrentRecords(did)
|
|
184
|
-
const repoRecords = formatCheckout(did, verifiedRepo)
|
|
185
|
-
const diff = findDiffFromCheckout(currRecords, repoRecords)
|
|
186
|
-
|
|
187
|
-
await Promise.all(
|
|
188
|
-
diff.map(async (op) => {
|
|
189
|
-
const { uri, cid } = op
|
|
190
|
-
try {
|
|
191
|
-
if (op.op === 'delete') {
|
|
192
|
-
await this.deleteRecord(uri)
|
|
193
|
-
} else {
|
|
194
|
-
const parsed = await getAndParseRecord(blocks, cid)
|
|
195
|
-
await this.indexRecord(
|
|
196
|
-
uri,
|
|
197
|
-
cid,
|
|
198
|
-
parsed.record,
|
|
199
|
-
op.op === 'create' ? WriteOpAction.Create : WriteOpAction.Update,
|
|
200
|
-
now,
|
|
201
|
-
)
|
|
202
|
-
}
|
|
203
|
-
} catch (err) {
|
|
204
|
-
if (err instanceof l.LexValidationError) {
|
|
205
|
-
subLogger.warn(
|
|
206
|
-
{ did, commit, uri: uri.toString(), cid: cid.toString() },
|
|
207
|
-
'skipping indexing of invalid record',
|
|
208
|
-
)
|
|
209
|
-
} else {
|
|
210
|
-
subLogger.error(
|
|
211
|
-
{ err, did, commit, uri: uri.toString(), cid: cid.toString() },
|
|
212
|
-
'skipping indexing due to error processing record',
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}),
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
async getCurrentRecords(did: string) {
|
|
221
|
-
const res = await this.db.db
|
|
222
|
-
.selectFrom('record')
|
|
223
|
-
.where('did', '=', did)
|
|
224
|
-
.select(['uri', 'cid'])
|
|
225
|
-
.execute()
|
|
226
|
-
return res.reduce(
|
|
227
|
-
(acc, cur) => {
|
|
228
|
-
acc[cur.uri] = {
|
|
229
|
-
uri: new AtUri(cur.uri),
|
|
230
|
-
cid: parseCid(cur.cid),
|
|
231
|
-
}
|
|
232
|
-
return acc
|
|
233
|
-
},
|
|
234
|
-
{} as Record<string, { uri: AtUri; cid: Cid }>,
|
|
235
|
-
)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
async setCommitLastSeen(did: string, commit: Cid, rev: string) {
|
|
239
|
-
const { ref } = this.db.db.dynamic
|
|
240
|
-
await this.db.db
|
|
241
|
-
.insertInto('actor_sync')
|
|
242
|
-
.values({
|
|
243
|
-
did,
|
|
244
|
-
commitCid: commit.toString(),
|
|
245
|
-
repoRev: rev ?? null,
|
|
246
|
-
})
|
|
247
|
-
.onConflict((oc) => {
|
|
248
|
-
const excluded = (col: string) => ref(`excluded.${col}`)
|
|
249
|
-
return oc.column('did').doUpdateSet({
|
|
250
|
-
commitCid: sql`${excluded('commitCid')}`,
|
|
251
|
-
repoRev: sql`${excluded('repoRev')}`,
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
-
.execute()
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
findIndexerForCollection(collection: string) {
|
|
258
|
-
for (const indexer of Object.values(this.records)) {
|
|
259
|
-
if (indexer.collection === collection) {
|
|
260
|
-
return indexer
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async updateActorStatus(
|
|
266
|
-
did: DidString,
|
|
267
|
-
active: boolean,
|
|
268
|
-
status: string = '',
|
|
269
|
-
) {
|
|
270
|
-
let upstreamStatus: string | null
|
|
271
|
-
if (active) {
|
|
272
|
-
upstreamStatus = null
|
|
273
|
-
} else if (['deactivated', 'suspended', 'takendown'].includes(status)) {
|
|
274
|
-
upstreamStatus = status
|
|
275
|
-
} else {
|
|
276
|
-
throw new Error(`Unrecognized account status: ${status}`)
|
|
277
|
-
}
|
|
278
|
-
await this.db.db
|
|
279
|
-
.updateTable('actor')
|
|
280
|
-
.set({ upstreamStatus })
|
|
281
|
-
.where('did', '=', did)
|
|
282
|
-
.execute()
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async deleteActor(did: DidString) {
|
|
286
|
-
this.db.assertNotTransaction()
|
|
287
|
-
const actorIsHosted = await this.getActorIsHosted(did)
|
|
288
|
-
if (actorIsHosted === false) {
|
|
289
|
-
await this.db.db.deleteFrom('actor').where('did', '=', did).execute()
|
|
290
|
-
await this.unindexActor(did)
|
|
291
|
-
await this.db.db
|
|
292
|
-
.deleteFrom('notification')
|
|
293
|
-
.where('did', '=', did)
|
|
294
|
-
.execute()
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
private async getActorIsHosted(did: DidString): Promise<boolean> {
|
|
299
|
-
const doc = await this.idResolver.did.resolve(did, true)
|
|
300
|
-
const pds = doc && getPds(doc)
|
|
301
|
-
if (!pds) return false
|
|
302
|
-
|
|
303
|
-
return retryXrpc(async () => {
|
|
304
|
-
const res = await xrpcSafe(pds, com.atproto.sync.getLatestCommit, {
|
|
305
|
-
params: { did },
|
|
306
|
-
})
|
|
307
|
-
if (res.success) return true
|
|
308
|
-
if (res.error === 'RepoNotFound') return false
|
|
309
|
-
throw res.reason // let retryXrpc() handle retries for transient errors
|
|
310
|
-
})
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
async unindexActor(did: DidString) {
|
|
314
|
-
this.db.assertNotTransaction()
|
|
315
|
-
// per-record-type indexes
|
|
316
|
-
await this.db.db.deleteFrom('profile').where('creator', '=', did).execute()
|
|
317
|
-
await this.db.db.deleteFrom('follow').where('creator', '=', did).execute()
|
|
318
|
-
await this.db.db.deleteFrom('repost').where('creator', '=', did).execute()
|
|
319
|
-
await this.db.db.deleteFrom('like').where('creator', '=', did).execute()
|
|
320
|
-
await this.db.db
|
|
321
|
-
.deleteFrom('feed_generator')
|
|
322
|
-
.where('creator', '=', did)
|
|
323
|
-
.execute()
|
|
324
|
-
await this.db.db.deleteFrom('labeler').where('creator', '=', did).execute()
|
|
325
|
-
// lists
|
|
326
|
-
await this.db.db
|
|
327
|
-
.deleteFrom('list_item')
|
|
328
|
-
.where('creator', '=', did)
|
|
329
|
-
.execute()
|
|
330
|
-
await this.db.db.deleteFrom('list').where('creator', '=', did).execute()
|
|
331
|
-
// blocks
|
|
332
|
-
await this.db.db
|
|
333
|
-
.deleteFrom('actor_block')
|
|
334
|
-
.where('creator', '=', did)
|
|
335
|
-
.execute()
|
|
336
|
-
await this.db.db
|
|
337
|
-
.deleteFrom('list_block')
|
|
338
|
-
.where('creator', '=', did)
|
|
339
|
-
.execute()
|
|
340
|
-
// posts
|
|
341
|
-
const postByUser = (qb) =>
|
|
342
|
-
qb
|
|
343
|
-
.selectFrom('post')
|
|
344
|
-
.where('post.creator', '=', did)
|
|
345
|
-
.select('post.uri as uri')
|
|
346
|
-
await this.db.db
|
|
347
|
-
.deleteFrom('post_embed_image')
|
|
348
|
-
.where('post_embed_image.postUri', 'in', postByUser)
|
|
349
|
-
.execute()
|
|
350
|
-
await this.db.db
|
|
351
|
-
.deleteFrom('post_embed_external')
|
|
352
|
-
.where('post_embed_external.postUri', 'in', postByUser)
|
|
353
|
-
.execute()
|
|
354
|
-
await this.db.db
|
|
355
|
-
.deleteFrom('post_embed_record')
|
|
356
|
-
.where('post_embed_record.postUri', 'in', postByUser)
|
|
357
|
-
.execute()
|
|
358
|
-
await this.db.db
|
|
359
|
-
.deleteFrom('post_embed_video')
|
|
360
|
-
.where('post_embed_video.postUri', 'in', postByUser)
|
|
361
|
-
.execute()
|
|
362
|
-
await this.db.db
|
|
363
|
-
.deleteFrom('post_embed_gallery_image')
|
|
364
|
-
.where('post_embed_gallery_image.postUri', 'in', postByUser)
|
|
365
|
-
.execute()
|
|
366
|
-
await this.db.db.deleteFrom('post').where('creator', '=', did).execute()
|
|
367
|
-
await this.db.db
|
|
368
|
-
.deleteFrom('thread_gate')
|
|
369
|
-
.where('creator', '=', did)
|
|
370
|
-
.execute()
|
|
371
|
-
await this.db.db
|
|
372
|
-
.deleteFrom('post_gate')
|
|
373
|
-
.where('creator', '=', did)
|
|
374
|
-
.execute()
|
|
375
|
-
// notifications
|
|
376
|
-
await this.db.db
|
|
377
|
-
.deleteFrom('notification')
|
|
378
|
-
.where('notification.author', '=', did)
|
|
379
|
-
.execute()
|
|
380
|
-
// generic record indexes
|
|
381
|
-
await this.db.db
|
|
382
|
-
.deleteFrom('duplicate_record')
|
|
383
|
-
.where('duplicate_record.duplicateOf', 'in', (qb) =>
|
|
384
|
-
qb
|
|
385
|
-
.selectFrom('record')
|
|
386
|
-
.where('record.did', '=', did)
|
|
387
|
-
.select('record.uri as uri'),
|
|
388
|
-
)
|
|
389
|
-
.execute()
|
|
390
|
-
await this.db.db.deleteFrom('record').where('did', '=', did).execute()
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
type UriAndCid = {
|
|
395
|
-
uri: AtUri
|
|
396
|
-
cid: Cid
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
type IndexOp =
|
|
400
|
-
| ({
|
|
401
|
-
op: 'create' | 'update'
|
|
402
|
-
} & UriAndCid)
|
|
403
|
-
| ({ op: 'delete' } & UriAndCid)
|
|
404
|
-
|
|
405
|
-
const findDiffFromCheckout = (
|
|
406
|
-
curr: Record<string, UriAndCid>,
|
|
407
|
-
checkout: Record<string, UriAndCid>,
|
|
408
|
-
): IndexOp[] => {
|
|
409
|
-
const ops: IndexOp[] = []
|
|
410
|
-
for (const uri of Object.keys(checkout)) {
|
|
411
|
-
const record = checkout[uri]
|
|
412
|
-
if (!curr[uri]) {
|
|
413
|
-
ops.push({ op: 'create', ...record })
|
|
414
|
-
} else {
|
|
415
|
-
if (curr[uri].cid.equals(record.cid)) {
|
|
416
|
-
// no-op
|
|
417
|
-
continue
|
|
418
|
-
}
|
|
419
|
-
ops.push({ op: 'update', ...record })
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
for (const uri of Object.keys(curr)) {
|
|
423
|
-
const record = curr[uri]
|
|
424
|
-
if (!checkout[uri]) {
|
|
425
|
-
ops.push({ op: 'delete', ...record })
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
return ops
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const formatCheckout = (
|
|
432
|
-
did: string,
|
|
433
|
-
verifiedRepo: VerifiedRepo,
|
|
434
|
-
): Record<string, UriAndCid> => {
|
|
435
|
-
const records: Record<string, UriAndCid> = {}
|
|
436
|
-
for (const create of verifiedRepo.creates) {
|
|
437
|
-
const uri = AtUri.make(did, create.collection, create.rkey)
|
|
438
|
-
records[uri.toString()] = {
|
|
439
|
-
uri,
|
|
440
|
-
cid: create.cid,
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return records
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const needsHandleReindex = (
|
|
447
|
-
actor: Selectable<Actor> | undefined,
|
|
448
|
-
timestamp: string,
|
|
449
|
-
) => {
|
|
450
|
-
if (!actor) return true
|
|
451
|
-
const timeDiff =
|
|
452
|
-
new Date(timestamp).getTime() - new Date(actor.indexedAt).getTime()
|
|
453
|
-
// revalidate daily
|
|
454
|
-
if (timeDiff > DAY) return true
|
|
455
|
-
// revalidate more aggressively for invalidated handles
|
|
456
|
-
if (actor.handle === null && timeDiff > HOUR) return true
|
|
457
|
-
return false
|
|
458
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Selectable } from 'kysely'
|
|
2
|
-
import { Cid } from '@atproto/lex'
|
|
3
|
-
import { AtUri, normalizeDatetimeAlways } from '@atproto/syntax'
|
|
4
|
-
import { app } from '../../../../lexicons/index.js'
|
|
5
|
-
import { BackgroundQueue } from '../../background.js'
|
|
6
|
-
import { DatabaseSchema, DatabaseSchemaType } from '../../db/database-schema.js'
|
|
7
|
-
import { Database } from '../../db/index.js'
|
|
8
|
-
import { RecordProcessor } from '../processor.js'
|
|
9
|
-
|
|
10
|
-
type IndexedBlock = Selectable<DatabaseSchemaType['actor_block']>
|
|
11
|
-
|
|
12
|
-
const insertFn = async (
|
|
13
|
-
db: DatabaseSchema,
|
|
14
|
-
uri: AtUri,
|
|
15
|
-
cid: Cid,
|
|
16
|
-
obj: app.bsky.graph.block.Main,
|
|
17
|
-
timestamp: string,
|
|
18
|
-
): Promise<IndexedBlock | null> => {
|
|
19
|
-
const inserted = await db
|
|
20
|
-
.insertInto('actor_block')
|
|
21
|
-
.values({
|
|
22
|
-
uri: uri.toString(),
|
|
23
|
-
cid: cid.toString(),
|
|
24
|
-
creator: uri.host,
|
|
25
|
-
subjectDid: obj.subject,
|
|
26
|
-
createdAt: normalizeDatetimeAlways(obj.createdAt),
|
|
27
|
-
indexedAt: timestamp,
|
|
28
|
-
})
|
|
29
|
-
.onConflict((oc) => oc.doNothing())
|
|
30
|
-
.returningAll()
|
|
31
|
-
.executeTakeFirst()
|
|
32
|
-
return inserted || null
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const findDuplicate = async (
|
|
36
|
-
db: DatabaseSchema,
|
|
37
|
-
uri: AtUri,
|
|
38
|
-
obj: app.bsky.graph.block.Main,
|
|
39
|
-
): Promise<AtUri | null> => {
|
|
40
|
-
const found = await db
|
|
41
|
-
.selectFrom('actor_block')
|
|
42
|
-
.where('creator', '=', uri.host)
|
|
43
|
-
.where('subjectDid', '=', obj.subject)
|
|
44
|
-
.selectAll()
|
|
45
|
-
.executeTakeFirst()
|
|
46
|
-
return found ? new AtUri(found.uri) : null
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const notifsForInsert = () => {
|
|
50
|
-
return []
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const deleteFn = async (
|
|
54
|
-
db: DatabaseSchema,
|
|
55
|
-
uri: AtUri,
|
|
56
|
-
): Promise<IndexedBlock | null> => {
|
|
57
|
-
const deleted = await db
|
|
58
|
-
.deleteFrom('actor_block')
|
|
59
|
-
.where('uri', '=', uri.toString())
|
|
60
|
-
.returningAll()
|
|
61
|
-
.executeTakeFirst()
|
|
62
|
-
return deleted || null
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const notifsForDelete = () => {
|
|
66
|
-
return { notifs: [], toDelete: [] }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type PluginType = ReturnType<typeof makePlugin>
|
|
70
|
-
export const makePlugin = (
|
|
71
|
-
db: Database,
|
|
72
|
-
background: BackgroundQueue<Database>,
|
|
73
|
-
) => {
|
|
74
|
-
return new RecordProcessor(db, background, {
|
|
75
|
-
schema: app.bsky.graph.block.main,
|
|
76
|
-
insertFn,
|
|
77
|
-
findDuplicate,
|
|
78
|
-
deleteFn,
|
|
79
|
-
notifsForInsert,
|
|
80
|
-
notifsForDelete,
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default makePlugin
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Cid } from '@atproto/lex'
|
|
2
|
-
import { AtUri } from '@atproto/syntax'
|
|
3
|
-
import { chat } from '../../../../lexicons/index.js'
|
|
4
|
-
import { BackgroundQueue } from '../../background.js'
|
|
5
|
-
import { DatabaseSchema } from '../../db/database-schema.js'
|
|
6
|
-
import { Database } from '../../db/index.js'
|
|
7
|
-
import { RecordProcessor } from '../processor.js'
|
|
8
|
-
|
|
9
|
-
// @NOTE this indexer is a placeholder to ensure it gets indexed in the generic records table
|
|
10
|
-
|
|
11
|
-
const insertFn = async (
|
|
12
|
-
_db: DatabaseSchema,
|
|
13
|
-
uri: AtUri,
|
|
14
|
-
_cid: Cid,
|
|
15
|
-
_obj: unknown,
|
|
16
|
-
_timestamp: string,
|
|
17
|
-
): Promise<unknown | null> => {
|
|
18
|
-
if (uri.rkey !== 'self') return null
|
|
19
|
-
return true
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const findDuplicate = async (): Promise<AtUri | null> => {
|
|
23
|
-
return null
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const notifsForInsert = () => {
|
|
27
|
-
return []
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const deleteFn = async (
|
|
31
|
-
_db: DatabaseSchema,
|
|
32
|
-
uri: AtUri,
|
|
33
|
-
): Promise<unknown | null> => {
|
|
34
|
-
if (uri.rkey !== 'self') return null
|
|
35
|
-
return true
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const notifsForDelete = () => {
|
|
39
|
-
return { notifs: [], toDelete: [] }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type PluginType = ReturnType<typeof makePlugin>
|
|
43
|
-
export const makePlugin = (
|
|
44
|
-
db: Database,
|
|
45
|
-
background: BackgroundQueue<Database>,
|
|
46
|
-
) => {
|
|
47
|
-
const processor = new RecordProcessor(db, background, {
|
|
48
|
-
schema: chat.bsky.actor.declaration.main,
|
|
49
|
-
insertFn,
|
|
50
|
-
findDuplicate,
|
|
51
|
-
deleteFn,
|
|
52
|
-
notifsForInsert,
|
|
53
|
-
notifsForDelete,
|
|
54
|
-
})
|
|
55
|
-
// @TODO use lexicon validation
|
|
56
|
-
processor.assertValidRecord = () => null
|
|
57
|
-
return processor
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default makePlugin
|