@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,590 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert'
|
|
2
|
-
import { lexParse } from '@atproto/lex'
|
|
3
|
-
import { AtUri } from '@atproto/syntax'
|
|
4
|
-
import { BsyncClient, authWithApiKey, createBsyncClient } from '../../bsync.js'
|
|
5
|
-
import { ServerConfig } from '../../config.js'
|
|
6
|
-
import { app } from '../../lexicons/index.js'
|
|
7
|
-
import { subLogger as log } from '../../logger.js'
|
|
8
|
-
import {
|
|
9
|
-
Method,
|
|
10
|
-
MuteOperation,
|
|
11
|
-
MuteOperation_Type,
|
|
12
|
-
NotifOperation,
|
|
13
|
-
Operation,
|
|
14
|
-
} from '../../proto/bsync_pb.js'
|
|
15
|
-
import { Namespaces } from '../../stash.js'
|
|
16
|
-
import { Database } from './db/index.js'
|
|
17
|
-
import { countAll, excluded } from './db/util.js'
|
|
18
|
-
|
|
19
|
-
export type BsyncCursors = {
|
|
20
|
-
op?: string
|
|
21
|
-
mute?: string
|
|
22
|
-
notif?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class BsyncSubscription {
|
|
26
|
-
private ac: AbortController | undefined
|
|
27
|
-
private pendingScans = new Set<Promise<void>>()
|
|
28
|
-
private bsyncClient: BsyncClient
|
|
29
|
-
private db: Database
|
|
30
|
-
// Latest cursor processed for each stream, used to wait until caught up.
|
|
31
|
-
private cursors: BsyncCursors = {}
|
|
32
|
-
|
|
33
|
-
constructor(public opts: { db: Database; config: ServerConfig }) {
|
|
34
|
-
const { config, db } = opts
|
|
35
|
-
|
|
36
|
-
this.db = db
|
|
37
|
-
this.bsyncClient = createBsyncClient({
|
|
38
|
-
baseUrl: config.bsyncUrl,
|
|
39
|
-
httpVersion: config.bsyncHttpVersion ?? '2',
|
|
40
|
-
nodeOptions: { rejectUnauthorized: !config.bsyncIgnoreBadTls },
|
|
41
|
-
interceptors: config.bsyncApiKey
|
|
42
|
-
? [authWithApiKey(config.bsyncApiKey)]
|
|
43
|
-
: [],
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get running() {
|
|
48
|
-
return !!this.ac
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
start() {
|
|
52
|
-
if (this.ac) return
|
|
53
|
-
this.ac = new AbortController()
|
|
54
|
-
this.scanMuteOperations()
|
|
55
|
-
this.scanNotifOperations()
|
|
56
|
-
this.scanOperations()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Waits until the subscription has processed every operation that existed in
|
|
61
|
-
* bsync at the time `targets` was read (one cursor per stream). Returns as
|
|
62
|
-
* soon as the cursors catch up - it does not wait for the bsync long-poll
|
|
63
|
-
* timeout. Intended for tests/dev.
|
|
64
|
-
*/
|
|
65
|
-
async processAll(targets: BsyncCursors, timeout = 5000) {
|
|
66
|
-
if (!this.ac) return
|
|
67
|
-
const start = Date.now()
|
|
68
|
-
while (!this.isCaughtUp(targets)) {
|
|
69
|
-
if (Date.now() - start > timeout) {
|
|
70
|
-
throw new Error(
|
|
71
|
-
`bsync subscription was not caught up within ${timeout}ms`,
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
await wait(5)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private isCaughtUp(targets: BsyncCursors) {
|
|
79
|
-
return (
|
|
80
|
-
gteCursor(this.cursors.op, targets.op) &&
|
|
81
|
-
gteCursor(this.cursors.mute, targets.mute) &&
|
|
82
|
-
gteCursor(this.cursors.notif, targets.notif)
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async destroy() {
|
|
87
|
-
// Aborting cancels any in-flight long-poll scan immediately, so we don't
|
|
88
|
-
// have to wait for the bsync long-poll timeout to elapse.
|
|
89
|
-
this.ac?.abort()
|
|
90
|
-
this.ac = undefined
|
|
91
|
-
// Wait for the ongoing scans to unwind cleanly.
|
|
92
|
-
await Promise.all(this.pendingScans)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* starts a scanner in the background, killing it when this instance is
|
|
97
|
-
* destroyed, and storing its promise in `this.pendingScans` to allow
|
|
98
|
-
* awaiting.
|
|
99
|
-
*/
|
|
100
|
-
private startScanning(
|
|
101
|
-
scanner: (
|
|
102
|
-
cursor: undefined | string,
|
|
103
|
-
signal: AbortSignal,
|
|
104
|
-
) => Promise<string | undefined>,
|
|
105
|
-
) {
|
|
106
|
-
if (!this.ac) return
|
|
107
|
-
const signal = this.ac.signal
|
|
108
|
-
|
|
109
|
-
const scanPromise = this.runScanner(scanner, signal)
|
|
110
|
-
|
|
111
|
-
this.pendingScans.add(scanPromise)
|
|
112
|
-
void scanPromise
|
|
113
|
-
.catch(() => {})
|
|
114
|
-
.finally(() => {
|
|
115
|
-
this.pendingScans.delete(scanPromise)
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private async runScanner(
|
|
120
|
-
scanner: (
|
|
121
|
-
cursor: undefined | string,
|
|
122
|
-
signal: AbortSignal,
|
|
123
|
-
) => Promise<string | undefined>,
|
|
124
|
-
signal: AbortSignal,
|
|
125
|
-
) {
|
|
126
|
-
let cursor: undefined | string
|
|
127
|
-
|
|
128
|
-
while (!signal.aborted) {
|
|
129
|
-
try {
|
|
130
|
-
cursor = await scanner(cursor, signal)
|
|
131
|
-
} catch (err) {
|
|
132
|
-
if (signal.aborted) break
|
|
133
|
-
|
|
134
|
-
log.error({ err }, 'error in bsync scan')
|
|
135
|
-
|
|
136
|
-
// retry in a bit, but bail out early if we're shutting down
|
|
137
|
-
await wait(100, signal)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private scanMuteOperations() {
|
|
143
|
-
this.startScanning(async (cursor, signal) => {
|
|
144
|
-
const res = await this.bsyncClient.scanMuteOperations(
|
|
145
|
-
{ cursor },
|
|
146
|
-
{ signal },
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
await this.processMuteOperations(res.operations)
|
|
150
|
-
this.cursors.mute = res.cursor
|
|
151
|
-
|
|
152
|
-
return res.cursor
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private async processMuteOperations(operations: MuteOperation[]) {
|
|
157
|
-
for (const op of operations) {
|
|
158
|
-
const { type, actorDid, subject } = op
|
|
159
|
-
if (type === MuteOperation_Type.ADD) {
|
|
160
|
-
if (subject.startsWith('did:')) {
|
|
161
|
-
await this.db.db
|
|
162
|
-
.insertInto('mute')
|
|
163
|
-
.values({
|
|
164
|
-
mutedByDid: actorDid,
|
|
165
|
-
subjectDid: subject,
|
|
166
|
-
createdAt: new Date().toISOString(),
|
|
167
|
-
})
|
|
168
|
-
.onConflict((oc) => oc.doNothing())
|
|
169
|
-
.execute()
|
|
170
|
-
} else {
|
|
171
|
-
const uri = new AtUri(subject)
|
|
172
|
-
if (uri.collection === app.bsky.graph.list.$type) {
|
|
173
|
-
await this.db.db
|
|
174
|
-
.insertInto('list_mute')
|
|
175
|
-
.values({
|
|
176
|
-
mutedByDid: actorDid,
|
|
177
|
-
listUri: subject,
|
|
178
|
-
createdAt: new Date().toISOString(),
|
|
179
|
-
})
|
|
180
|
-
.onConflict((oc) => oc.doNothing())
|
|
181
|
-
.execute()
|
|
182
|
-
} else {
|
|
183
|
-
await this.db.db
|
|
184
|
-
.insertInto('thread_mute')
|
|
185
|
-
.values({
|
|
186
|
-
mutedByDid: actorDid,
|
|
187
|
-
rootUri: subject,
|
|
188
|
-
createdAt: new Date().toISOString(),
|
|
189
|
-
})
|
|
190
|
-
.onConflict((oc) => oc.doNothing())
|
|
191
|
-
.execute()
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
} else if (type === MuteOperation_Type.REMOVE) {
|
|
195
|
-
if (subject.startsWith('did:')) {
|
|
196
|
-
await this.db.db
|
|
197
|
-
.deleteFrom('mute')
|
|
198
|
-
.where('mutedByDid', '=', actorDid)
|
|
199
|
-
.where('subjectDid', '=', subject)
|
|
200
|
-
.execute()
|
|
201
|
-
} else {
|
|
202
|
-
const uri = new AtUri(subject)
|
|
203
|
-
if (uri.collection === app.bsky.graph.list.$type) {
|
|
204
|
-
await this.db.db
|
|
205
|
-
.deleteFrom('list_mute')
|
|
206
|
-
.where('mutedByDid', '=', actorDid)
|
|
207
|
-
.where('listUri', '=', subject)
|
|
208
|
-
.execute()
|
|
209
|
-
} else {
|
|
210
|
-
await this.db.db
|
|
211
|
-
.deleteFrom('thread_mute')
|
|
212
|
-
.where('mutedByDid', '=', actorDid)
|
|
213
|
-
.where('rootUri', '=', subject)
|
|
214
|
-
.execute()
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
} else if (type === MuteOperation_Type.CLEAR) {
|
|
218
|
-
await this.db.db
|
|
219
|
-
.deleteFrom('mute')
|
|
220
|
-
.where('mutedByDid', '=', actorDid)
|
|
221
|
-
.execute()
|
|
222
|
-
await this.db.db
|
|
223
|
-
.deleteFrom('list_mute')
|
|
224
|
-
.where('mutedByDid', '=', actorDid)
|
|
225
|
-
.execute()
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
private scanNotifOperations() {
|
|
231
|
-
this.startScanning(async (cursor, signal) => {
|
|
232
|
-
const res = await this.bsyncClient.scanNotifOperations(
|
|
233
|
-
{ cursor },
|
|
234
|
-
{ signal },
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
await this.processNotifOperations(res.operations)
|
|
238
|
-
this.cursors.notif = res.cursor
|
|
239
|
-
|
|
240
|
-
return res.cursor
|
|
241
|
-
})
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
private async processNotifOperations(operations: NotifOperation[]) {
|
|
245
|
-
for (const op of operations) {
|
|
246
|
-
const { actorDid, priority } = op
|
|
247
|
-
if (priority !== undefined) {
|
|
248
|
-
await this.db.db
|
|
249
|
-
.insertInto('actor_state')
|
|
250
|
-
.values({
|
|
251
|
-
did: actorDid,
|
|
252
|
-
priorityNotifs: priority,
|
|
253
|
-
lastSeenNotifs: new Date().toISOString(),
|
|
254
|
-
})
|
|
255
|
-
.onConflict((oc) =>
|
|
256
|
-
oc.column('did').doUpdateSet({ priorityNotifs: priority }),
|
|
257
|
-
)
|
|
258
|
-
.execute()
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private scanOperations() {
|
|
264
|
-
this.startScanning(async (cursor, signal) => {
|
|
265
|
-
const res = await this.bsyncClient.scanOperations({ cursor }, { signal })
|
|
266
|
-
|
|
267
|
-
await this.processOperations(res.operations)
|
|
268
|
-
this.cursors.op = res.cursor
|
|
269
|
-
|
|
270
|
-
return res.cursor
|
|
271
|
-
})
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
private async processOperations(operations: Operation[]) {
|
|
275
|
-
for (const op of operations) {
|
|
276
|
-
const { namespace } = op
|
|
277
|
-
|
|
278
|
-
const now = new Date().toISOString()
|
|
279
|
-
|
|
280
|
-
// Index all items into private_data.
|
|
281
|
-
await handleGenericOperation(this.db, op, now)
|
|
282
|
-
|
|
283
|
-
// Maintain bespoke indexes for certain namespaces. A failure here must
|
|
284
|
-
// not stall the stream, so log and move on (matching bsync behavior).
|
|
285
|
-
try {
|
|
286
|
-
if (
|
|
287
|
-
namespace ===
|
|
288
|
-
Namespaces.AppBskyNotificationDefsSubjectActivitySubscription.$type
|
|
289
|
-
) {
|
|
290
|
-
await handleSubjectActivitySubscriptionOperation(this.db, op, now)
|
|
291
|
-
} else if (
|
|
292
|
-
namespace === Namespaces.AppBskyUnspeccedDefsAgeAssuranceEvent.$type
|
|
293
|
-
) {
|
|
294
|
-
await handleAgeAssuranceEventOperation(this.db, op, now)
|
|
295
|
-
} else if (
|
|
296
|
-
namespace === Namespaces.AppBskyAgeassuranceDefsEvent.$type
|
|
297
|
-
) {
|
|
298
|
-
await handleAgeAssuranceV2EventOperation(this.db, op, now)
|
|
299
|
-
} else if (namespace === Namespaces.AppBskyBookmarkDefsBookmark.$type) {
|
|
300
|
-
await handleBookmarkOperation(this.db, op, now)
|
|
301
|
-
} else if (namespace === Namespaces.AppBskyDraftDefsDraftWithId.$type) {
|
|
302
|
-
await handleDraftOperation(this.db, op, now)
|
|
303
|
-
}
|
|
304
|
-
} catch (err) {
|
|
305
|
-
log.warn({ err, namespace }, 'bsync put operation indexing failed')
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
type HandleOperation = (
|
|
312
|
-
db: Database,
|
|
313
|
-
op: Operation,
|
|
314
|
-
now: string,
|
|
315
|
-
) => Promise<void>
|
|
316
|
-
|
|
317
|
-
// upsert into or remove from private_data
|
|
318
|
-
const handleGenericOperation: HandleOperation = async (
|
|
319
|
-
db: Database,
|
|
320
|
-
op: Operation,
|
|
321
|
-
now: string,
|
|
322
|
-
) => {
|
|
323
|
-
const { actorDid, namespace, key, method, payload } = op
|
|
324
|
-
if (method === Method.CREATE || method === Method.UPDATE) {
|
|
325
|
-
await db.db
|
|
326
|
-
.insertInto('private_data')
|
|
327
|
-
.values({
|
|
328
|
-
actorDid,
|
|
329
|
-
namespace,
|
|
330
|
-
key,
|
|
331
|
-
payload: Buffer.from(payload).toString('utf8'),
|
|
332
|
-
indexedAt: now,
|
|
333
|
-
updatedAt: now,
|
|
334
|
-
})
|
|
335
|
-
.onConflict((oc) =>
|
|
336
|
-
oc.columns(['actorDid', 'namespace', 'key']).doUpdateSet({
|
|
337
|
-
payload: excluded(db.db, 'payload'),
|
|
338
|
-
updatedAt: excluded(db.db, 'updatedAt'),
|
|
339
|
-
}),
|
|
340
|
-
)
|
|
341
|
-
.execute()
|
|
342
|
-
} else if (method === Method.DELETE) {
|
|
343
|
-
await db.db
|
|
344
|
-
.deleteFrom('private_data')
|
|
345
|
-
.where('actorDid', '=', actorDid)
|
|
346
|
-
.where('namespace', '=', namespace)
|
|
347
|
-
.where('key', '=', key)
|
|
348
|
-
.execute()
|
|
349
|
-
} else {
|
|
350
|
-
assert.fail(`unexpected method ${method}`)
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const handleSubjectActivitySubscriptionOperation: HandleOperation = async (
|
|
355
|
-
db: Database,
|
|
356
|
-
op: Operation,
|
|
357
|
-
now: string,
|
|
358
|
-
) => {
|
|
359
|
-
const { actorDid, key, method, payload } = op
|
|
360
|
-
|
|
361
|
-
if (method === Method.DELETE) {
|
|
362
|
-
await db.db
|
|
363
|
-
.deleteFrom('activity_subscription')
|
|
364
|
-
.where('creator', '=', actorDid)
|
|
365
|
-
.where('key', '=', key)
|
|
366
|
-
.execute()
|
|
367
|
-
return
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
const parsed =
|
|
371
|
-
lexParse<app.bsky.notification.defs.SubjectActivitySubscription>(
|
|
372
|
-
Buffer.from(payload).toString('utf8'),
|
|
373
|
-
)
|
|
374
|
-
const {
|
|
375
|
-
subject,
|
|
376
|
-
activitySubscription: { post, reply },
|
|
377
|
-
} = parsed
|
|
378
|
-
|
|
379
|
-
if (method === Method.CREATE) {
|
|
380
|
-
await db.db
|
|
381
|
-
.insertInto('activity_subscription')
|
|
382
|
-
.values({
|
|
383
|
-
creator: actorDid,
|
|
384
|
-
subjectDid: subject,
|
|
385
|
-
key,
|
|
386
|
-
indexedAt: now,
|
|
387
|
-
post,
|
|
388
|
-
reply,
|
|
389
|
-
})
|
|
390
|
-
.execute()
|
|
391
|
-
return
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
await db.db
|
|
395
|
-
.updateTable('activity_subscription')
|
|
396
|
-
.where('creator', '=', actorDid)
|
|
397
|
-
.where('key', '=', key)
|
|
398
|
-
.set({
|
|
399
|
-
indexedAt: now,
|
|
400
|
-
post,
|
|
401
|
-
reply,
|
|
402
|
-
})
|
|
403
|
-
.execute()
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const handleAgeAssuranceEventOperation: HandleOperation = async (
|
|
407
|
-
db: Database,
|
|
408
|
-
op: Operation,
|
|
409
|
-
) => {
|
|
410
|
-
const { actorDid, method, payload } = op
|
|
411
|
-
if (method !== Method.CREATE) return
|
|
412
|
-
|
|
413
|
-
const parsed = lexParse<app.bsky.unspecced.defs.AgeAssuranceEvent>(
|
|
414
|
-
Buffer.from(payload).toString('utf8'),
|
|
415
|
-
)
|
|
416
|
-
const { status, createdAt } = parsed
|
|
417
|
-
|
|
418
|
-
const update = {
|
|
419
|
-
ageAssuranceStatus: status,
|
|
420
|
-
ageAssuranceLastInitiatedAt: status === 'pending' ? createdAt : undefined,
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
await db.db
|
|
424
|
-
.updateTable('actor')
|
|
425
|
-
.set(update)
|
|
426
|
-
.where('did', '=', actorDid)
|
|
427
|
-
.execute()
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
const handleAgeAssuranceV2EventOperation: HandleOperation = async (
|
|
431
|
-
db: Database,
|
|
432
|
-
op: Operation,
|
|
433
|
-
) => {
|
|
434
|
-
const { actorDid, method, payload } = op
|
|
435
|
-
if (method !== Method.CREATE) return
|
|
436
|
-
|
|
437
|
-
const parsed = lexParse<app.bsky.ageassurance.defs.Event>(
|
|
438
|
-
Buffer.from(payload).toString('utf8'),
|
|
439
|
-
)
|
|
440
|
-
const { status, createdAt, access, countryCode, regionCode } = parsed
|
|
441
|
-
|
|
442
|
-
const update = {
|
|
443
|
-
ageAssuranceStatus: status,
|
|
444
|
-
ageAssuranceLastInitiatedAt: status === 'pending' ? createdAt : undefined,
|
|
445
|
-
ageAssuranceAccess: access,
|
|
446
|
-
ageAssuranceCountryCode: countryCode,
|
|
447
|
-
ageAssuranceRegionCode: regionCode,
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
await db.db
|
|
451
|
-
.updateTable('actor')
|
|
452
|
-
.set(update)
|
|
453
|
-
.where('did', '=', actorDid)
|
|
454
|
-
.execute()
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
const handleBookmarkOperation: HandleOperation = async (
|
|
458
|
-
db: Database,
|
|
459
|
-
op: Operation,
|
|
460
|
-
now: string,
|
|
461
|
-
) => {
|
|
462
|
-
const { actorDid, key, method, payload } = op
|
|
463
|
-
|
|
464
|
-
const updateAgg = (uri: string, dbTxn: Database) => {
|
|
465
|
-
return dbTxn.db
|
|
466
|
-
.insertInto('post_agg')
|
|
467
|
-
.values({
|
|
468
|
-
uri,
|
|
469
|
-
bookmarkCount: dbTxn.db
|
|
470
|
-
.selectFrom('bookmark')
|
|
471
|
-
.where('bookmark.subjectUri', '=', uri)
|
|
472
|
-
.select(countAll.as('count')),
|
|
473
|
-
})
|
|
474
|
-
.onConflict((oc) =>
|
|
475
|
-
oc
|
|
476
|
-
.column('uri')
|
|
477
|
-
.doUpdateSet({ bookmarkCount: excluded(dbTxn.db, 'bookmarkCount') }),
|
|
478
|
-
)
|
|
479
|
-
.execute()
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (method === Method.CREATE) {
|
|
483
|
-
const parsed = lexParse<app.bsky.bookmark.defs.Bookmark>(
|
|
484
|
-
Buffer.from(payload).toString('utf8'),
|
|
485
|
-
)
|
|
486
|
-
const {
|
|
487
|
-
subject: { uri, cid },
|
|
488
|
-
} = parsed
|
|
489
|
-
|
|
490
|
-
await db.transaction(async (dbTxn) => {
|
|
491
|
-
await dbTxn.db
|
|
492
|
-
.insertInto('bookmark')
|
|
493
|
-
.values({
|
|
494
|
-
creator: actorDid,
|
|
495
|
-
key,
|
|
496
|
-
indexedAt: now,
|
|
497
|
-
subjectUri: uri,
|
|
498
|
-
subjectCid: cid,
|
|
499
|
-
})
|
|
500
|
-
.execute()
|
|
501
|
-
|
|
502
|
-
await updateAgg(uri, dbTxn)
|
|
503
|
-
})
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if (method === Method.DELETE) {
|
|
507
|
-
await db.transaction(async (dbTxn) => {
|
|
508
|
-
const bookmark = await dbTxn.db
|
|
509
|
-
.selectFrom('bookmark')
|
|
510
|
-
.selectAll()
|
|
511
|
-
.where('creator', '=', actorDid)
|
|
512
|
-
.where('key', '=', key)
|
|
513
|
-
.executeTakeFirst()
|
|
514
|
-
|
|
515
|
-
if (bookmark) {
|
|
516
|
-
await dbTxn.db
|
|
517
|
-
.deleteFrom('bookmark')
|
|
518
|
-
.where('creator', '=', actorDid)
|
|
519
|
-
.where('key', '=', key)
|
|
520
|
-
.execute()
|
|
521
|
-
|
|
522
|
-
await updateAgg(bookmark.subjectUri, dbTxn)
|
|
523
|
-
}
|
|
524
|
-
})
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
const handleDraftOperation: HandleOperation = async (
|
|
529
|
-
db: Database,
|
|
530
|
-
op: Operation,
|
|
531
|
-
now: string,
|
|
532
|
-
) => {
|
|
533
|
-
const { actorDid, key, method, payload } = op
|
|
534
|
-
|
|
535
|
-
if (method === Method.CREATE) {
|
|
536
|
-
const payloadString = Buffer.from(payload).toString('utf8')
|
|
537
|
-
|
|
538
|
-
await db.db
|
|
539
|
-
.insertInto('draft')
|
|
540
|
-
.values({
|
|
541
|
-
creator: actorDid,
|
|
542
|
-
key,
|
|
543
|
-
createdAt: now,
|
|
544
|
-
updatedAt: now,
|
|
545
|
-
payload: payloadString,
|
|
546
|
-
})
|
|
547
|
-
.execute()
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
if (method === Method.UPDATE) {
|
|
551
|
-
const payloadString = Buffer.from(payload).toString('utf8')
|
|
552
|
-
|
|
553
|
-
await db.db
|
|
554
|
-
.updateTable('draft')
|
|
555
|
-
.where('creator', '=', actorDid)
|
|
556
|
-
.where('key', '=', key)
|
|
557
|
-
.set({
|
|
558
|
-
updatedAt: now,
|
|
559
|
-
payload: payloadString,
|
|
560
|
-
})
|
|
561
|
-
.execute()
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (method === Method.DELETE) {
|
|
565
|
-
await db.db
|
|
566
|
-
.deleteFrom('draft')
|
|
567
|
-
.where('creator', '=', actorDid)
|
|
568
|
-
.where('key', '=', key)
|
|
569
|
-
.execute()
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// compares numeric (bigint) cursor ids; an undefined target is always satisfied
|
|
574
|
-
const gteCursor = (current: string | undefined, target: string | undefined) => {
|
|
575
|
-
if (!target) return true
|
|
576
|
-
return BigInt(current || '0') >= BigInt(target)
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// resolves after `ms`, or early if `signal` aborts
|
|
580
|
-
const wait = (ms: number, signal?: AbortSignal) =>
|
|
581
|
-
new Promise<void>((resolve) => {
|
|
582
|
-
if (signal?.aborted) return resolve()
|
|
583
|
-
const done = () => {
|
|
584
|
-
clearTimeout(timer)
|
|
585
|
-
signal?.removeEventListener('abort', done)
|
|
586
|
-
resolve()
|
|
587
|
-
}
|
|
588
|
-
const timer = setTimeout(done, ms)
|
|
589
|
-
signal?.addEventListener('abort', done, { once: true })
|
|
590
|
-
})
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Kysely } from 'kysely'
|
|
2
|
-
import * as activitySubscription from './tables/activity-subscription.js'
|
|
3
|
-
import * as actorBlock from './tables/actor-block.js'
|
|
4
|
-
import * as actorState from './tables/actor-state.js'
|
|
5
|
-
import * as actorSync from './tables/actor-sync.js'
|
|
6
|
-
import * as actor from './tables/actor.js'
|
|
7
|
-
import * as algo from './tables/algo.js'
|
|
8
|
-
import * as blobTakedown from './tables/blob-takedown.js'
|
|
9
|
-
import * as bookmark from './tables/bookmark.js'
|
|
10
|
-
import * as didCache from './tables/did-cache.js'
|
|
11
|
-
import * as draft from './tables/draft.js'
|
|
12
|
-
import * as duplicateRecord from './tables/duplicate-record.js'
|
|
13
|
-
import * as feedGenerator from './tables/feed-generator.js'
|
|
14
|
-
import * as feedItem from './tables/feed-item.js'
|
|
15
|
-
import * as follow from './tables/follow.js'
|
|
16
|
-
import * as label from './tables/label.js'
|
|
17
|
-
import * as labeler from './tables/labeler.js'
|
|
18
|
-
import * as like from './tables/like.js'
|
|
19
|
-
import * as listBlock from './tables/list-block.js'
|
|
20
|
-
import * as listItem from './tables/list-item.js'
|
|
21
|
-
import * as listMute from './tables/list-mute.js'
|
|
22
|
-
import * as list from './tables/list.js'
|
|
23
|
-
import * as mute from './tables/mute.js'
|
|
24
|
-
import * as notificationPushToken from './tables/notification-push-token.js'
|
|
25
|
-
import * as notification from './tables/notification.js'
|
|
26
|
-
import * as postAgg from './tables/post-agg.js'
|
|
27
|
-
import * as postEmbed from './tables/post-embed.js'
|
|
28
|
-
import * as postgate from './tables/post-gate.js'
|
|
29
|
-
import * as post from './tables/post.js'
|
|
30
|
-
import * as privateData from './tables/private-data.js'
|
|
31
|
-
import * as profileAgg from './tables/profile-agg.js'
|
|
32
|
-
import * as profile from './tables/profile.js'
|
|
33
|
-
import * as quote from './tables/quote.js'
|
|
34
|
-
import * as record from './tables/record.js'
|
|
35
|
-
import * as repost from './tables/repost.js'
|
|
36
|
-
import * as starterPack from './tables/starter-pack.js'
|
|
37
|
-
import * as subscription from './tables/subscription.js'
|
|
38
|
-
import * as suggestedFeed from './tables/suggested-feed.js'
|
|
39
|
-
import * as suggestedFollow from './tables/suggested-follow.js'
|
|
40
|
-
import * as taggedSuggestion from './tables/tagged-suggestion.js'
|
|
41
|
-
import * as threadgate from './tables/thread-gate.js'
|
|
42
|
-
import * as threadMute from './tables/thread-mute.js'
|
|
43
|
-
import * as verification from './tables/verification.js'
|
|
44
|
-
import * as viewParam from './tables/view-param.js'
|
|
45
|
-
|
|
46
|
-
export type DatabaseSchemaType = duplicateRecord.PartialDB &
|
|
47
|
-
profile.PartialDB &
|
|
48
|
-
profileAgg.PartialDB &
|
|
49
|
-
post.PartialDB &
|
|
50
|
-
postEmbed.PartialDB &
|
|
51
|
-
postAgg.PartialDB &
|
|
52
|
-
repost.PartialDB &
|
|
53
|
-
threadgate.PartialDB &
|
|
54
|
-
postgate.PartialDB &
|
|
55
|
-
feedItem.PartialDB &
|
|
56
|
-
follow.PartialDB &
|
|
57
|
-
like.PartialDB &
|
|
58
|
-
list.PartialDB &
|
|
59
|
-
listItem.PartialDB &
|
|
60
|
-
listMute.PartialDB &
|
|
61
|
-
listBlock.PartialDB &
|
|
62
|
-
mute.PartialDB &
|
|
63
|
-
actorBlock.PartialDB &
|
|
64
|
-
threadMute.PartialDB &
|
|
65
|
-
feedGenerator.PartialDB &
|
|
66
|
-
subscription.PartialDB &
|
|
67
|
-
actor.PartialDB &
|
|
68
|
-
actorState.PartialDB &
|
|
69
|
-
actorSync.PartialDB &
|
|
70
|
-
record.PartialDB &
|
|
71
|
-
notification.PartialDB &
|
|
72
|
-
notificationPushToken.PartialDB &
|
|
73
|
-
didCache.PartialDB &
|
|
74
|
-
label.PartialDB &
|
|
75
|
-
algo.PartialDB &
|
|
76
|
-
viewParam.PartialDB &
|
|
77
|
-
suggestedFollow.PartialDB &
|
|
78
|
-
suggestedFeed.PartialDB &
|
|
79
|
-
blobTakedown.PartialDB &
|
|
80
|
-
labeler.PartialDB &
|
|
81
|
-
starterPack.PartialDB &
|
|
82
|
-
taggedSuggestion.PartialDB &
|
|
83
|
-
quote.PartialDB &
|
|
84
|
-
verification.PartialDB &
|
|
85
|
-
privateData.PartialDB &
|
|
86
|
-
activitySubscription.PartialDB &
|
|
87
|
-
bookmark.PartialDB &
|
|
88
|
-
draft.PartialDB
|
|
89
|
-
|
|
90
|
-
export type DatabaseSchema = Kysely<DatabaseSchemaType>
|