@atproto/bsky 0.0.251 → 0.0.253

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (459) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/api/age-assurance/const.js +19 -19
  3. package/dist/api/age-assurance/const.js.map +1 -1
  4. package/dist/kws.d.ts +8 -0
  5. package/dist/kws.d.ts.map +1 -1
  6. package/dist/kws.js +53 -4
  7. package/dist/kws.js.map +1 -1
  8. package/package.json +28 -23
  9. package/bin/migration-create.ts +0 -46
  10. package/buf.gen.yaml +0 -12
  11. package/proto/bsky.proto +0 -1907
  12. package/proto/courier.proto +0 -84
  13. package/proto/rolodex.proto +0 -116
  14. package/src/api/age-assurance/const.ts +0 -203
  15. package/src/api/age-assurance/index.ts +0 -34
  16. package/src/api/age-assurance/kws/age-verified.test.ts +0 -98
  17. package/src/api/age-assurance/kws/age-verified.ts +0 -81
  18. package/src/api/age-assurance/kws/const.ts +0 -33
  19. package/src/api/age-assurance/kws/external-payload.test.ts +0 -72
  20. package/src/api/age-assurance/kws/external-payload.ts +0 -149
  21. package/src/api/age-assurance/redirects/kws-age-verified.ts +0 -107
  22. package/src/api/age-assurance/stash.ts +0 -23
  23. package/src/api/age-assurance/types.ts +0 -10
  24. package/src/api/age-assurance/util.ts +0 -68
  25. package/src/api/age-assurance/webhooks/kws-age-verified.ts +0 -75
  26. package/src/api/app/bsky/actor/getProfile.ts +0 -106
  27. package/src/api/app/bsky/actor/getProfiles.ts +0 -99
  28. package/src/api/app/bsky/actor/getSuggestions.ts +0 -163
  29. package/src/api/app/bsky/actor/searchActors.ts +0 -171
  30. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +0 -164
  31. package/src/api/app/bsky/ageassurance/begin.ts +0 -175
  32. package/src/api/app/bsky/ageassurance/getConfig.ts +0 -16
  33. package/src/api/app/bsky/ageassurance/getState.ts +0 -58
  34. package/src/api/app/bsky/bookmark/createBookmark.ts +0 -39
  35. package/src/api/app/bsky/bookmark/deleteBookmark.ts +0 -32
  36. package/src/api/app/bsky/bookmark/getBookmarks.ts +0 -97
  37. package/src/api/app/bsky/bookmark/util.ts +0 -13
  38. package/src/api/app/bsky/contact/dismissMatch.ts +0 -26
  39. package/src/api/app/bsky/contact/getMatches.ts +0 -111
  40. package/src/api/app/bsky/contact/getSyncStatus.ts +0 -38
  41. package/src/api/app/bsky/contact/importContacts.ts +0 -119
  42. package/src/api/app/bsky/contact/removeData.ts +0 -25
  43. package/src/api/app/bsky/contact/sendNotification.ts +0 -33
  44. package/src/api/app/bsky/contact/startPhoneVerification.ts +0 -26
  45. package/src/api/app/bsky/contact/util.ts +0 -92
  46. package/src/api/app/bsky/contact/verifyPhone.ts +0 -29
  47. package/src/api/app/bsky/draft/createDraft.ts +0 -45
  48. package/src/api/app/bsky/draft/deleteDraft.ts +0 -20
  49. package/src/api/app/bsky/draft/getDrafts.ts +0 -44
  50. package/src/api/app/bsky/draft/updateDraft.ts +0 -26
  51. package/src/api/app/bsky/embed/getEmbedExternalView.ts +0 -154
  52. package/src/api/app/bsky/feed/getActorFeeds.ts +0 -101
  53. package/src/api/app/bsky/feed/getActorLikes.ts +0 -128
  54. package/src/api/app/bsky/feed/getAuthorFeed.ts +0 -279
  55. package/src/api/app/bsky/feed/getFeed.ts +0 -282
  56. package/src/api/app/bsky/feed/getFeedGenerator.ts +0 -68
  57. package/src/api/app/bsky/feed/getFeedGenerators.ts +0 -86
  58. package/src/api/app/bsky/feed/getLikes.ts +0 -151
  59. package/src/api/app/bsky/feed/getListFeed.ts +0 -147
  60. package/src/api/app/bsky/feed/getPostThread.ts +0 -156
  61. package/src/api/app/bsky/feed/getPosts.ts +0 -100
  62. package/src/api/app/bsky/feed/getQuotes.ts +0 -122
  63. package/src/api/app/bsky/feed/getRepostedBy.ts +0 -121
  64. package/src/api/app/bsky/feed/getSuggestedFeeds.ts +0 -39
  65. package/src/api/app/bsky/feed/getTimeline.ts +0 -127
  66. package/src/api/app/bsky/feed/searchPosts.ts +0 -274
  67. package/src/api/app/bsky/feed/searchPostsV2.ts +0 -243
  68. package/src/api/app/bsky/graph/getActorStarterPacks.ts +0 -103
  69. package/src/api/app/bsky/graph/getBlocks.ts +0 -94
  70. package/src/api/app/bsky/graph/getFollowers.ts +0 -153
  71. package/src/api/app/bsky/graph/getFollows.ts +0 -151
  72. package/src/api/app/bsky/graph/getKnownFollowers.ts +0 -123
  73. package/src/api/app/bsky/graph/getList.ts +0 -152
  74. package/src/api/app/bsky/graph/getListBlocks.ts +0 -87
  75. package/src/api/app/bsky/graph/getListMutes.ts +0 -87
  76. package/src/api/app/bsky/graph/getLists.ts +0 -125
  77. package/src/api/app/bsky/graph/getListsWithMembership.ts +0 -146
  78. package/src/api/app/bsky/graph/getMutes.ts +0 -87
  79. package/src/api/app/bsky/graph/getRelationships.ts +0 -58
  80. package/src/api/app/bsky/graph/getStarterPack.ts +0 -82
  81. package/src/api/app/bsky/graph/getStarterPacks.ts +0 -86
  82. package/src/api/app/bsky/graph/getStarterPacksWithMembership.ts +0 -136
  83. package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +0 -171
  84. package/src/api/app/bsky/graph/muteActor.ts +0 -24
  85. package/src/api/app/bsky/graph/muteActorList.ts +0 -19
  86. package/src/api/app/bsky/graph/muteThread.ts +0 -19
  87. package/src/api/app/bsky/graph/searchStarterPacks.ts +0 -169
  88. package/src/api/app/bsky/graph/unmuteActor.ts +0 -21
  89. package/src/api/app/bsky/graph/unmuteActorList.ts +0 -19
  90. package/src/api/app/bsky/graph/unmuteThread.ts +0 -19
  91. package/src/api/app/bsky/labeler/getServices.ts +0 -41
  92. package/src/api/app/bsky/notification/getPreferences.ts +0 -49
  93. package/src/api/app/bsky/notification/getUnreadCount.ts +0 -83
  94. package/src/api/app/bsky/notification/listActivitySubscriptions.ts +0 -116
  95. package/src/api/app/bsky/notification/listNotifications.ts +0 -272
  96. package/src/api/app/bsky/notification/putActivitySubscription.ts +0 -69
  97. package/src/api/app/bsky/notification/putPreferences.ts +0 -17
  98. package/src/api/app/bsky/notification/putPreferencesV2.ts +0 -64
  99. package/src/api/app/bsky/notification/registerPush.ts +0 -40
  100. package/src/api/app/bsky/notification/unregisterPush.ts +0 -39
  101. package/src/api/app/bsky/notification/updateSeen.ts +0 -52
  102. package/src/api/app/bsky/notification/util.ts +0 -134
  103. package/src/api/app/bsky/unspecced/getAgeAssuranceState.ts +0 -48
  104. package/src/api/app/bsky/unspecced/getConfig.ts +0 -20
  105. package/src/api/app/bsky/unspecced/getOnboardingSuggestedStarterPacks.ts +0 -162
  106. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +0 -91
  107. package/src/api/app/bsky/unspecced/getPostThreadOtherV2.ts +0 -126
  108. package/src/api/app/bsky/unspecced/getPostThreadV2.ts +0 -148
  109. package/src/api/app/bsky/unspecced/getSuggestedFeeds.ts +0 -100
  110. package/src/api/app/bsky/unspecced/getSuggestedOnboardingUsers.ts +0 -143
  111. package/src/api/app/bsky/unspecced/getSuggestedStarterPacks.ts +0 -165
  112. package/src/api/app/bsky/unspecced/getSuggestedUsers.ts +0 -183
  113. package/src/api/app/bsky/unspecced/getSuggestedUsersForDiscover.ts +0 -175
  114. package/src/api/app/bsky/unspecced/getSuggestedUsersForExplore.ts +0 -178
  115. package/src/api/app/bsky/unspecced/getSuggestedUsersForSeeMore.ts +0 -178
  116. package/src/api/app/bsky/unspecced/getTaggedSuggestions.ts +0 -27
  117. package/src/api/app/bsky/unspecced/getTrendingTopics.ts +0 -96
  118. package/src/api/app/bsky/unspecced/getTrends.ts +0 -162
  119. package/src/api/app/bsky/unspecced/initAgeAssurance.ts +0 -150
  120. package/src/api/blob-dispatcher.ts +0 -41
  121. package/src/api/blob-resolver.ts +0 -401
  122. package/src/api/com/atproto/admin/getAccountInfos.ts +0 -49
  123. package/src/api/com/atproto/admin/getSubjectStatus.ts +0 -79
  124. package/src/api/com/atproto/admin/updateSubjectStatus.ts +0 -80
  125. package/src/api/com/atproto/identity/resolveHandle.ts +0 -19
  126. package/src/api/com/atproto/label/queryLabels.ts +0 -42
  127. package/src/api/com/atproto/repo/getRecord.ts +0 -44
  128. package/src/api/com/atproto/temp/fetchLabels.ts +0 -9
  129. package/src/api/external.ts +0 -15
  130. package/src/api/health.ts +0 -47
  131. package/src/api/index.ts +0 -216
  132. package/src/api/internal/bsky/actor/getProfiles.ts +0 -87
  133. package/src/api/kws/api.ts +0 -113
  134. package/src/api/kws/index.ts +0 -29
  135. package/src/api/kws/types.ts +0 -78
  136. package/src/api/kws/util.test.ts +0 -50
  137. package/src/api/kws/util.ts +0 -109
  138. package/src/api/kws/webhook.ts +0 -134
  139. package/src/api/sitemap.ts +0 -76
  140. package/src/api/util.ts +0 -45
  141. package/src/api/well-known.ts +0 -44
  142. package/src/auth-verifier.ts +0 -522
  143. package/src/bsync.ts +0 -41
  144. package/src/cache/read-through.ts +0 -157
  145. package/src/config.ts +0 -719
  146. package/src/context.ts +0 -143
  147. package/src/courier.ts +0 -41
  148. package/src/data-plane/client/hosts.ts +0 -103
  149. package/src/data-plane/client/index.ts +0 -125
  150. package/src/data-plane/client/util.test.ts +0 -29
  151. package/src/data-plane/client/util.ts +0 -74
  152. package/src/data-plane/index.ts +0 -2
  153. package/src/data-plane/server/background.ts +0 -66
  154. package/src/data-plane/server/bsync-subscription.ts +0 -590
  155. package/src/data-plane/server/db/database-schema.ts +0 -90
  156. package/src/data-plane/server/db/db.ts +0 -204
  157. package/src/data-plane/server/db/index.ts +0 -2
  158. package/src/data-plane/server/db/migrations/20230309T045948368Z-init.ts +0 -305
  159. package/src/data-plane/server/db/migrations/20230408T152211201Z-notification-init.ts +0 -25
  160. package/src/data-plane/server/db/migrations/20230417T210628672Z-moderation-init.ts +0 -127
  161. package/src/data-plane/server/db/migrations/20230420T211446071Z-did-cache.ts +0 -14
  162. package/src/data-plane/server/db/migrations/20230427T194702079Z-notif-record-index.ts +0 -14
  163. package/src/data-plane/server/db/migrations/20230605T144730094Z-post-profile-aggs.ts +0 -23
  164. package/src/data-plane/server/db/migrations/20230607T211442112Z-feed-generator-init.ts +0 -34
  165. package/src/data-plane/server/db/migrations/20230608T155101190Z-algo-whats-hot-view.ts +0 -85
  166. package/src/data-plane/server/db/migrations/20230608T201813132Z-mute-lists.ts +0 -78
  167. package/src/data-plane/server/db/migrations/20230608T205147239Z-mutes.ts +0 -15
  168. package/src/data-plane/server/db/migrations/20230609T153623961Z-blocks.ts +0 -33
  169. package/src/data-plane/server/db/migrations/20230609T232122649Z-actor-deletion-indexes.ts +0 -27
  170. package/src/data-plane/server/db/migrations/20230610T203555962Z-suggested-follows.ts +0 -13
  171. package/src/data-plane/server/db/migrations/20230611T215300060Z-actor-state.ts +0 -13
  172. package/src/data-plane/server/db/migrations/20230620T161134972Z-post-langs.ts +0 -9
  173. package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +0 -15
  174. package/src/data-plane/server/db/migrations/20230629T220835893Z-remove-post-hierarchy.ts +0 -32
  175. package/src/data-plane/server/db/migrations/20230703T045536691Z-feed-and-label-indices.ts +0 -31
  176. package/src/data-plane/server/db/migrations/20230720T164800037Z-posts-cursor-idx.ts +0 -19
  177. package/src/data-plane/server/db/migrations/20230807T035309811Z-feed-item-delete-invite-for-user-idx.ts +0 -14
  178. package/src/data-plane/server/db/migrations/20230808T172902639Z-repo-rev.ts +0 -12
  179. package/src/data-plane/server/db/migrations/20230810T203349843Z-action-duration.ts +0 -23
  180. package/src/data-plane/server/db/migrations/20230817T195936007Z-native-notifications.ts +0 -16
  181. package/src/data-plane/server/db/migrations/20230830T205507322Z-suggested-feeds.ts +0 -13
  182. package/src/data-plane/server/db/migrations/20230904T211011773Z-block-lists.ts +0 -24
  183. package/src/data-plane/server/db/migrations/20230906T222220386Z-thread-gating.ts +0 -27
  184. package/src/data-plane/server/db/migrations/20230920T213858047Z-add-tags-to-post.ts +0 -9
  185. package/src/data-plane/server/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +0 -40
  186. package/src/data-plane/server/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +0 -123
  187. package/src/data-plane/server/db/migrations/20231220T225126090Z-blob-takedowns.ts +0 -66
  188. package/src/data-plane/server/db/migrations/20240124T023719200Z-tagged-suggestions.ts +0 -15
  189. package/src/data-plane/server/db/migrations/20240226T225725627Z-labelers.ts +0 -27
  190. package/src/data-plane/server/db/migrations/20240530T170337073Z-account-deactivation.ts +0 -12
  191. package/src/data-plane/server/db/migrations/20240606T171229898Z-thread-mutes.ts +0 -15
  192. package/src/data-plane/server/db/migrations/20240606T222548219Z-starter-packs.ts +0 -45
  193. package/src/data-plane/server/db/migrations/20240719T203853939Z-priority-notifs.ts +0 -25
  194. package/src/data-plane/server/db/migrations/20240723T220700077Z-quotes-post-aggs.ts +0 -12
  195. package/src/data-plane/server/db/migrations/20240723T220703655Z-quotes.ts +0 -28
  196. package/src/data-plane/server/db/migrations/20240801T193939827Z-post-gate.ts +0 -17
  197. package/src/data-plane/server/db/migrations/20240808T224251220Z-post-gate-flags.ts +0 -25
  198. package/src/data-plane/server/db/migrations/20240829T211238293Z-simplify-actor-sync.ts +0 -23
  199. package/src/data-plane/server/db/migrations/20240831T134810923Z-pinned-posts.ts +0 -17
  200. package/src/data-plane/server/db/migrations/20241114T153108102Z-add-starter-packs-name.ts +0 -19
  201. package/src/data-plane/server/db/migrations/20250116T222618297Z-post-embed-video.ts +0 -17
  202. package/src/data-plane/server/db/migrations/20250207T174822012Z-add-label-exp.ts +0 -9
  203. package/src/data-plane/server/db/migrations/20250404T163421487Z-verifications.ts +0 -39
  204. package/src/data-plane/server/db/migrations/20250526T023712742Z-like-repost-via.ts +0 -17
  205. package/src/data-plane/server/db/migrations/20250528T221913281Z-add-record-tags.ts +0 -9
  206. package/src/data-plane/server/db/migrations/20250602T190357447Z-add-private-data.ts +0 -22
  207. package/src/data-plane/server/db/migrations/20250611T140649895Z-add-activity-subscription.ts +0 -22
  208. package/src/data-plane/server/db/migrations/20250627T025331240Z-add-actor-age-assurance-columns.ts +0 -22
  209. package/src/data-plane/server/db/migrations/20250812T183735692Z-add-bookmarks.ts +0 -23
  210. package/src/data-plane/server/db/migrations/20250813T174955711Z-add-post-agg-bookmarks.ts +0 -12
  211. package/src/data-plane/server/db/migrations/20251120T004738098Z-update-actor-age-assurance-v2.ts +0 -28
  212. package/src/data-plane/server/db/migrations/20260112T133951271Z-add-drafts.ts +0 -24
  213. package/src/data-plane/server/db/migrations/20260604T224952774Z-post-embed-gallery-image.ts +0 -19
  214. package/src/data-plane/server/db/migrations/index.ts +0 -60
  215. package/src/data-plane/server/db/migrations/provider.ts +0 -26
  216. package/src/data-plane/server/db/pagination.ts +0 -341
  217. package/src/data-plane/server/db/tables/activity-subscription.ts +0 -12
  218. package/src/data-plane/server/db/tables/actor-block.ts +0 -14
  219. package/src/data-plane/server/db/tables/actor-state.ts +0 -10
  220. package/src/data-plane/server/db/tables/actor-sync.ts +0 -9
  221. package/src/data-plane/server/db/tables/actor.ts +0 -19
  222. package/src/data-plane/server/db/tables/algo.ts +0 -11
  223. package/src/data-plane/server/db/tables/blob-takedown.ts +0 -9
  224. package/src/data-plane/server/db/tables/bookmark.ts +0 -11
  225. package/src/data-plane/server/db/tables/did-cache.ts +0 -13
  226. package/src/data-plane/server/db/tables/draft.ts +0 -11
  227. package/src/data-plane/server/db/tables/duplicate-record.ts +0 -12
  228. package/src/data-plane/server/db/tables/feed-generator.ts +0 -21
  229. package/src/data-plane/server/db/tables/feed-item.ts +0 -12
  230. package/src/data-plane/server/db/tables/follow.ts +0 -15
  231. package/src/data-plane/server/db/tables/label.ts +0 -13
  232. package/src/data-plane/server/db/tables/labeler.ts +0 -16
  233. package/src/data-plane/server/db/tables/like.ts +0 -18
  234. package/src/data-plane/server/db/tables/list-block.ts +0 -15
  235. package/src/data-plane/server/db/tables/list-item.ts +0 -16
  236. package/src/data-plane/server/db/tables/list-mute.ts +0 -9
  237. package/src/data-plane/server/db/tables/list.ts +0 -19
  238. package/src/data-plane/server/db/tables/mute.ts +0 -9
  239. package/src/data-plane/server/db/tables/notification-push-token.ts +0 -10
  240. package/src/data-plane/server/db/tables/notification.ts +0 -16
  241. package/src/data-plane/server/db/tables/post-agg.ts +0 -16
  242. package/src/data-plane/server/db/tables/post-embed.ts +0 -47
  243. package/src/data-plane/server/db/tables/post-gate.ts +0 -12
  244. package/src/data-plane/server/db/tables/post.ts +0 -28
  245. package/src/data-plane/server/db/tables/private-data.ts +0 -13
  246. package/src/data-plane/server/db/tables/profile-agg.ts +0 -14
  247. package/src/data-plane/server/db/tables/profile.ts +0 -17
  248. package/src/data-plane/server/db/tables/quote.ts +0 -15
  249. package/src/data-plane/server/db/tables/record.ts +0 -15
  250. package/src/data-plane/server/db/tables/repost.ts +0 -18
  251. package/src/data-plane/server/db/tables/starter-pack.ts +0 -17
  252. package/src/data-plane/server/db/tables/subscription.ts +0 -9
  253. package/src/data-plane/server/db/tables/suggested-feed.ts +0 -10
  254. package/src/data-plane/server/db/tables/suggested-follow.ts +0 -10
  255. package/src/data-plane/server/db/tables/tagged-suggestion.ts +0 -11
  256. package/src/data-plane/server/db/tables/thread-gate.ts +0 -12
  257. package/src/data-plane/server/db/tables/thread-mute.ts +0 -9
  258. package/src/data-plane/server/db/tables/verification.ts +0 -20
  259. package/src/data-plane/server/db/tables/view-param.ts +0 -12
  260. package/src/data-plane/server/db/types.ts +0 -12
  261. package/src/data-plane/server/db/util.ts +0 -67
  262. package/src/data-plane/server/index.ts +0 -44
  263. package/src/data-plane/server/indexing/index.ts +0 -458
  264. package/src/data-plane/server/indexing/plugins/block.ts +0 -84
  265. package/src/data-plane/server/indexing/plugins/chat-declaration.ts +0 -60
  266. package/src/data-plane/server/indexing/plugins/feed-generator.ts +0 -80
  267. package/src/data-plane/server/indexing/plugins/follow.ts +0 -132
  268. package/src/data-plane/server/indexing/plugins/germ-declaration.ts +0 -57
  269. package/src/data-plane/server/indexing/plugins/labeler.ts +0 -74
  270. package/src/data-plane/server/indexing/plugins/like.ts +0 -151
  271. package/src/data-plane/server/indexing/plugins/list-block.ts +0 -84
  272. package/src/data-plane/server/indexing/plugins/list-item.ts +0 -92
  273. package/src/data-plane/server/indexing/plugins/list.ts +0 -80
  274. package/src/data-plane/server/indexing/plugins/notif-declaration.ts +0 -57
  275. package/src/data-plane/server/indexing/plugins/post-gate.ts +0 -101
  276. package/src/data-plane/server/indexing/plugins/post.ts +0 -675
  277. package/src/data-plane/server/indexing/plugins/profile.ts +0 -90
  278. package/src/data-plane/server/indexing/plugins/repost.ts +0 -176
  279. package/src/data-plane/server/indexing/plugins/starter-pack.ts +0 -74
  280. package/src/data-plane/server/indexing/plugins/status.ts +0 -57
  281. package/src/data-plane/server/indexing/plugins/thread-gate.ts +0 -101
  282. package/src/data-plane/server/indexing/plugins/verification.ts +0 -113
  283. package/src/data-plane/server/indexing/processor.ts +0 -292
  284. package/src/data-plane/server/routes/activity-subscription.ts +0 -84
  285. package/src/data-plane/server/routes/blocks.ts +0 -127
  286. package/src/data-plane/server/routes/bookmarks.ts +0 -83
  287. package/src/data-plane/server/routes/drafts.ts +0 -37
  288. package/src/data-plane/server/routes/feed-gens.ts +0 -89
  289. package/src/data-plane/server/routes/feeds.ts +0 -176
  290. package/src/data-plane/server/routes/follows.ts +0 -141
  291. package/src/data-plane/server/routes/identity.ts +0 -59
  292. package/src/data-plane/server/routes/index.ts +0 -67
  293. package/src/data-plane/server/routes/interactions.ts +0 -120
  294. package/src/data-plane/server/routes/labels.ts +0 -55
  295. package/src/data-plane/server/routes/likes.ts +0 -92
  296. package/src/data-plane/server/routes/lists.ts +0 -88
  297. package/src/data-plane/server/routes/moderation.ts +0 -102
  298. package/src/data-plane/server/routes/mutes.ts +0 -195
  299. package/src/data-plane/server/routes/notifs.ts +0 -239
  300. package/src/data-plane/server/routes/profile.ts +0 -220
  301. package/src/data-plane/server/routes/quotes.ts +0 -32
  302. package/src/data-plane/server/routes/records.ts +0 -119
  303. package/src/data-plane/server/routes/relationships.ts +0 -174
  304. package/src/data-plane/server/routes/reposts.ts +0 -76
  305. package/src/data-plane/server/routes/search.ts +0 -181
  306. package/src/data-plane/server/routes/site-standard.ts +0 -12
  307. package/src/data-plane/server/routes/sitemap.ts +0 -43
  308. package/src/data-plane/server/routes/starter-packs.ts +0 -32
  309. package/src/data-plane/server/routes/suggestions.ts +0 -175
  310. package/src/data-plane/server/routes/sync.ts +0 -16
  311. package/src/data-plane/server/routes/threads.ts +0 -33
  312. package/src/data-plane/server/subscription.ts +0 -152
  313. package/src/data-plane/server/util.ts +0 -202
  314. package/src/error.ts +0 -12
  315. package/src/etcd.ts +0 -90
  316. package/src/feature-gates/README.md +0 -83
  317. package/src/feature-gates/gates.ts +0 -25
  318. package/src/feature-gates/index.ts +0 -235
  319. package/src/feature-gates/metrics.test.ts +0 -196
  320. package/src/feature-gates/metrics.ts +0 -107
  321. package/src/feature-gates/types.ts +0 -62
  322. package/src/feature-gates/utils.test.ts +0 -66
  323. package/src/feature-gates/utils.ts +0 -135
  324. package/src/hydration/actor.ts +0 -578
  325. package/src/hydration/external.test.ts +0 -281
  326. package/src/hydration/external.ts +0 -268
  327. package/src/hydration/feed.ts +0 -455
  328. package/src/hydration/graph.ts +0 -354
  329. package/src/hydration/hydrator.ts +0 -1835
  330. package/src/hydration/label.ts +0 -207
  331. package/src/hydration/util.ts +0 -199
  332. package/src/image/index.ts +0 -2
  333. package/src/image/invalidator.ts +0 -33
  334. package/src/image/logger.ts +0 -6
  335. package/src/image/server.ts +0 -228
  336. package/src/image/sharp.ts +0 -89
  337. package/src/image/uri.ts +0 -114
  338. package/src/image/util.ts +0 -41
  339. package/src/index.ts +0 -312
  340. package/src/kws.ts +0 -197
  341. package/src/logger.ts +0 -40
  342. package/src/pipeline.ts +0 -60
  343. package/src/redis.ts +0 -205
  344. package/src/rolodex.ts +0 -42
  345. package/src/stash.ts +0 -76
  346. package/src/util/debug.ts +0 -10
  347. package/src/util/http.ts +0 -42
  348. package/src/util/retry.ts +0 -10
  349. package/src/util/standard-site.test.ts +0 -423
  350. package/src/util/standard-site.ts +0 -196
  351. package/src/util/uris.ts +0 -38
  352. package/src/util.ts +0 -48
  353. package/src/views/index.ts +0 -2783
  354. package/src/views/threads-v2.ts +0 -510
  355. package/src/views/types.ts +0 -193
  356. package/src/views/util.ts +0 -114
  357. package/test.env +0 -2
  358. package/tests/__snapshots__/feed-generation.test.ts.snap +0 -2510
  359. package/tests/_util.ts +0 -292
  360. package/tests/admin/admin-auth.test.ts +0 -190
  361. package/tests/admin/moderation.test.ts +0 -222
  362. package/tests/auth.test.ts +0 -90
  363. package/tests/blob-resolver.test.ts +0 -125
  364. package/tests/data-plane/__snapshots__/indexing.test.ts.snap +0 -887
  365. package/tests/data-plane/db.test.ts +0 -189
  366. package/tests/data-plane/duplicate-records.test.ts +0 -156
  367. package/tests/data-plane/handle-invalidation.test.ts +0 -153
  368. package/tests/data-plane/indexing.test.ts +0 -827
  369. package/tests/data-plane/subscription.test.ts +0 -128
  370. package/tests/data-plane/thread-mutes.test.ts +0 -175
  371. package/tests/entryway-auth.test.ts +0 -177
  372. package/tests/etcd.test.ts +0 -302
  373. package/tests/feed-generation.test.ts +0 -965
  374. package/tests/hydration/util.test.ts +0 -119
  375. package/tests/image/server.test.ts +0 -97
  376. package/tests/image/sharp.test.ts +0 -199
  377. package/tests/image/uri.test.ts +0 -106
  378. package/tests/label-hydration.test.ts +0 -245
  379. package/tests/postgates.test.ts +0 -182
  380. package/tests/query-labels.test.ts +0 -85
  381. package/tests/redis-cache.test.ts +0 -230
  382. package/tests/seed/feed-hidden-replies.ts +0 -63
  383. package/tests/seed/get-suggested-starter-packs.ts +0 -64
  384. package/tests/seed/get-trends.ts +0 -71
  385. package/tests/seed/known-followers.ts +0 -111
  386. package/tests/seed/postgates.ts +0 -57
  387. package/tests/server.test.ts +0 -115
  388. package/tests/sitemap.test.ts +0 -75
  389. package/tests/stash.test.ts +0 -180
  390. package/tests/utils.test.ts +0 -36
  391. package/tests/views/__snapshots__/actor-search.test.ts.snap +0 -155
  392. package/tests/views/__snapshots__/author-feed.test.ts.snap +0 -6301
  393. package/tests/views/__snapshots__/block-lists.test.ts.snap +0 -690
  394. package/tests/views/__snapshots__/blocks.test.ts.snap +0 -462
  395. package/tests/views/__snapshots__/bookmarks.test.ts.snap +0 -379
  396. package/tests/views/__snapshots__/follows.test.ts.snap +0 -798
  397. package/tests/views/__snapshots__/labeler-service.test.ts.snap +0 -233
  398. package/tests/views/__snapshots__/likes.test.ts.snap +0 -124
  399. package/tests/views/__snapshots__/list-feed.test.ts.snap +0 -883
  400. package/tests/views/__snapshots__/lists.test.ts.snap +0 -650
  401. package/tests/views/__snapshots__/mute-lists.test.ts.snap +0 -705
  402. package/tests/views/__snapshots__/mutes.test.ts.snap +0 -353
  403. package/tests/views/__snapshots__/notifications.test.ts.snap +0 -3074
  404. package/tests/views/__snapshots__/posts.test.ts.snap +0 -1019
  405. package/tests/views/__snapshots__/profile.test.ts.snap +0 -811
  406. package/tests/views/__snapshots__/quotes.test.ts.snap +0 -445
  407. package/tests/views/__snapshots__/reposts.test.ts.snap +0 -112
  408. package/tests/views/__snapshots__/starter-packs.test.ts.snap +0 -836
  409. package/tests/views/__snapshots__/thread-v2.test.ts.snap +0 -1298
  410. package/tests/views/__snapshots__/thread.test.ts.snap +0 -2051
  411. package/tests/views/__snapshots__/threadgating.test.ts.snap +0 -189
  412. package/tests/views/__snapshots__/timeline.test.ts.snap +0 -7252
  413. package/tests/views/account-deactivation.test.ts +0 -81
  414. package/tests/views/actor-likes.test.ts +0 -138
  415. package/tests/views/actor-search.test.ts +0 -261
  416. package/tests/views/age-assurance-v2.test.ts +0 -823
  417. package/tests/views/age-assurance.test.ts +0 -479
  418. package/tests/views/author-feed.test.ts +0 -694
  419. package/tests/views/block-lists.test.ts +0 -661
  420. package/tests/views/blocks.test.ts +0 -889
  421. package/tests/views/bookmarks.test.ts +0 -345
  422. package/tests/views/drafts.test.ts +0 -430
  423. package/tests/views/feed-hidden-replies.test.ts +0 -243
  424. package/tests/views/feed-view-post.test.ts +0 -501
  425. package/tests/views/follows.test.ts +0 -372
  426. package/tests/views/get-config.test.ts +0 -64
  427. package/tests/views/get-suggested-onboarding-users.test.ts +0 -193
  428. package/tests/views/get-suggested-starter-packs.test.ts +0 -137
  429. package/tests/views/get-trends.test.ts +0 -141
  430. package/tests/views/internal-actor.test.ts +0 -127
  431. package/tests/views/known-followers.test.ts +0 -193
  432. package/tests/views/labeler-service.test.ts +0 -242
  433. package/tests/views/labels-needs-review.test.ts +0 -316
  434. package/tests/views/labels-takedown.test.ts +0 -247
  435. package/tests/views/likes.test.ts +0 -192
  436. package/tests/views/list-feed.test.ts +0 -195
  437. package/tests/views/lists.test.ts +0 -412
  438. package/tests/views/mute-lists.test.ts +0 -509
  439. package/tests/views/mutes.test.ts +0 -308
  440. package/tests/views/notifications.test.ts +0 -1581
  441. package/tests/views/post-search.test.ts +0 -281
  442. package/tests/views/posts-debug.test.ts +0 -79
  443. package/tests/views/posts.test.ts +0 -427
  444. package/tests/views/profile-debug.test.ts +0 -75
  445. package/tests/views/profile.test.ts +0 -795
  446. package/tests/views/quotes.test.ts +0 -133
  447. package/tests/views/reposts.test.ts +0 -112
  448. package/tests/views/starter-packs.test.ts +0 -395
  449. package/tests/views/suggestions.test.ts +0 -145
  450. package/tests/views/thread-v2.test.ts +0 -2005
  451. package/tests/views/thread.test.ts +0 -637
  452. package/tests/views/threadgating.test.ts +0 -843
  453. package/tests/views/timeline.test.ts +0 -328
  454. package/tests/views/verification.test.ts +0 -296
  455. package/tsconfig.build.json +0 -10
  456. package/tsconfig.build.tsbuildinfo +0 -1
  457. package/tsconfig.json +0 -7
  458. package/tsconfig.tests.json +0 -8
  459. package/vitest.config.ts +0 -10
@@ -1,292 +0,0 @@
1
- import { Insertable } from 'kysely'
2
- import { chunkArray } from '@atproto/common'
3
- import { Cid, l, lexParse, lexStringify, parseCid } from '@atproto/lex'
4
- import { AtUri } from '@atproto/syntax'
5
- import { BackgroundQueue } from '../background.js'
6
- import { DatabaseSchema } from '../db/database-schema.js'
7
- import { Database } from '../db/index.js'
8
- import { Notification } from '../db/tables/notification.js'
9
-
10
- // @NOTE re: insertions and deletions. Due to how record updates are handled,
11
- // (insertFn) should have the same effect as (insertFn -> deleteFn -> insertFn).
12
- type RecordProcessorOptions<TSchema extends l.RecordSchema, TRow> = {
13
- schema: TSchema
14
- insertFn: (
15
- db: DatabaseSchema,
16
- uri: AtUri,
17
- cid: Cid,
18
- obj: l.InferInput<TSchema>,
19
- timestamp: string,
20
- ) => Promise<TRow | null>
21
- findDuplicate: (
22
- db: DatabaseSchema,
23
- uri: AtUri,
24
- obj: l.InferInput<TSchema>,
25
- ) => Promise<AtUri | null>
26
- deleteFn: (db: DatabaseSchema, uri: AtUri) => Promise<TRow | null>
27
- notifsForInsert: (obj: TRow) => Notif[]
28
- notifsForDelete: (
29
- prev: TRow,
30
- replacedBy: TRow | null,
31
- ) => { notifs: Notif[]; toDelete: string[] }
32
- updateAggregates?: (db: DatabaseSchema, obj: TRow) => Promise<void>
33
- }
34
-
35
- type Notif = Insertable<Notification>
36
-
37
- export class RecordProcessor<TSchema extends l.RecordSchema, TRow> {
38
- constructor(
39
- private appDb: Database,
40
- private background: BackgroundQueue<Database>,
41
- private options: RecordProcessorOptions<TSchema, TRow>,
42
- ) {}
43
-
44
- get db() {
45
- return this.appDb.db
46
- }
47
-
48
- get collection(): TSchema['$type'] {
49
- return this.options.schema.$type
50
- }
51
-
52
- matchesSchema<I>(obj: I): obj is I & l.InferInput<TSchema> {
53
- return this.options.schema.matches(obj)
54
- }
55
-
56
- assertValidRecord(obj: unknown): asserts obj is l.InferInput<TSchema> {
57
- this.options.schema.check(obj)
58
- }
59
-
60
- async insertRecord(
61
- uri: AtUri,
62
- cid: Cid,
63
- obj: unknown,
64
- timestamp: string,
65
- opts?: { disableNotifs?: boolean },
66
- ) {
67
- this.assertValidRecord(obj)
68
- await this.db
69
- .insertInto('record')
70
- .values({
71
- uri: uri.toString(),
72
- cid: cid.toString(),
73
- did: uri.host,
74
- json: lexStringify(obj),
75
- indexedAt: timestamp,
76
- })
77
- .onConflict((oc) => oc.doNothing())
78
- .execute()
79
- const inserted = await this.options.insertFn(
80
- this.db,
81
- uri,
82
- cid,
83
- obj,
84
- timestamp,
85
- )
86
- if (inserted) {
87
- this.aggregateOnCommit(inserted)
88
- if (!opts?.disableNotifs) {
89
- await this.handleNotifs({ inserted })
90
- }
91
- return
92
- }
93
- // if duplicate, insert into duplicates table with no events
94
- const found = await this.options.findDuplicate(this.db, uri, obj)
95
- if (found && found.toString() !== uri.toString()) {
96
- await this.db
97
- .insertInto('duplicate_record')
98
- .values({
99
- uri: uri.toString(),
100
- cid: cid.toString(),
101
- duplicateOf: found.toString(),
102
- indexedAt: timestamp,
103
- })
104
- .onConflict((oc) => oc.doNothing())
105
- .execute()
106
- }
107
- }
108
-
109
- // Currently using a very simple strategy for updates: purge the existing index
110
- // for the uri then replace it. The main upside is that this allows the indexer
111
- // for each collection to avoid bespoke logic for in-place updates, which isn't
112
- // straightforward in the general case. We still get nice control over notifications.
113
- async updateRecord(
114
- uri: AtUri,
115
- cid: Cid,
116
- obj: unknown,
117
- timestamp: string,
118
- opts?: { disableNotifs?: boolean },
119
- ) {
120
- this.assertValidRecord(obj)
121
- await this.db
122
- .updateTable('record')
123
- .where('uri', '=', uri.toString())
124
- .set({
125
- cid: cid.toString(),
126
- json: lexStringify(obj),
127
- indexedAt: timestamp,
128
- })
129
- .execute()
130
- // If the updated record was a dupe, update dupe info for it
131
- const dupe = await this.options.findDuplicate(this.db, uri, obj)
132
- if (dupe) {
133
- await this.db
134
- .updateTable('duplicate_record')
135
- .where('uri', '=', uri.toString())
136
- .set({
137
- cid: cid.toString(),
138
- duplicateOf: dupe.toString(),
139
- indexedAt: timestamp,
140
- })
141
- .execute()
142
- } else {
143
- await this.db
144
- .deleteFrom('duplicate_record')
145
- .where('uri', '=', uri.toString())
146
- .execute()
147
- }
148
-
149
- const deleted = await this.options.deleteFn(this.db, uri)
150
- if (!deleted) {
151
- // If a record was updated but hadn't been indexed yet, treat it like a plain insert.
152
- return this.insertRecord(uri, cid, obj, timestamp)
153
- }
154
- this.aggregateOnCommit(deleted)
155
- const inserted = await this.options.insertFn(
156
- this.db,
157
- uri,
158
- cid,
159
- obj,
160
- timestamp,
161
- )
162
- if (!inserted) {
163
- throw new Error(
164
- 'Record update failed: removed from index but could not be replaced',
165
- )
166
- }
167
- this.aggregateOnCommit(inserted)
168
- if (!opts?.disableNotifs) {
169
- await this.handleNotifs({ inserted, deleted })
170
- }
171
- }
172
-
173
- async deleteRecord(uri: AtUri, cascading = false) {
174
- await this.db
175
- .deleteFrom('record')
176
- .where('uri', '=', uri.toString())
177
- .execute()
178
- await this.db
179
- .deleteFrom('duplicate_record')
180
- .where('uri', '=', uri.toString())
181
- .execute()
182
- const deleted = await this.options.deleteFn(this.db, uri)
183
- if (!deleted) return
184
- this.aggregateOnCommit(deleted)
185
- if (cascading) {
186
- await this.db
187
- .deleteFrom('duplicate_record')
188
- .where('duplicateOf', '=', uri.toString())
189
- .execute()
190
- return this.handleNotifs({ deleted })
191
- } else {
192
- const found = await this.db
193
- .selectFrom('duplicate_record')
194
- .innerJoin('record', 'record.uri', 'duplicate_record.uri')
195
- .where('duplicateOf', '=', uri.toString())
196
- .orderBy('duplicate_record.indexedAt', 'asc')
197
- .limit(1)
198
- .selectAll()
199
- .executeTakeFirst()
200
-
201
- if (!found) {
202
- return this.handleNotifs({ deleted })
203
- }
204
- const record = lexParse(found.json)
205
- if (!this.matchesSchema(record)) {
206
- return this.handleNotifs({ deleted })
207
- }
208
- const inserted = await this.options.insertFn(
209
- this.db,
210
- new AtUri(found.uri),
211
- parseCid(found.cid),
212
- record,
213
- found.indexedAt,
214
- )
215
- if (inserted) {
216
- this.aggregateOnCommit(inserted)
217
- }
218
- await this.handleNotifs({ deleted, inserted: inserted ?? undefined })
219
- }
220
- }
221
-
222
- async handleNotifs(op: { deleted?: TRow; inserted?: TRow }) {
223
- let notifs: Notif[] = []
224
- const runOnCommit: ((db: Database) => Promise<void>)[] = []
225
- if (op.deleted) {
226
- const forDelete = this.options.notifsForDelete(
227
- op.deleted,
228
- op.inserted ?? null,
229
- )
230
- if (forDelete.toDelete.length > 0) {
231
- // Notifs can be deleted in background: they are expensive to delete and
232
- // listNotifications already excludes notifs with missing records.
233
- runOnCommit.push(async (db) => {
234
- await db.db
235
- .deleteFrom('notification')
236
- .where('recordUri', 'in', forDelete.toDelete)
237
- .execute()
238
- })
239
- }
240
- notifs = forDelete.notifs
241
- } else if (op.inserted) {
242
- notifs = this.options.notifsForInsert(op.inserted)
243
- }
244
- for (const chunk of chunkArray(notifs, 500)) {
245
- runOnCommit.push(async (db) => {
246
- const filtered = await this.filterNotifsForThreadMutes(chunk)
247
- await db.db.insertInto('notification').values(filtered).execute()
248
- })
249
- }
250
- // Need to ensure notif deletion always happens before creation, otherwise delete may clobber in a race.
251
- for (const fn of runOnCommit) {
252
- await fn(this.appDb) // these could be backgrounded
253
- }
254
- }
255
-
256
- async filterNotifsForThreadMutes(notifs: Notif[]): Promise<Notif[]> {
257
- const isBlocked = await Promise.all(
258
- notifs.map((n) => this.isNotifBlockedByThreadMute(n)),
259
- )
260
- return notifs.filter((_, i) => !isBlocked[i])
261
- }
262
-
263
- async isNotifBlockedByThreadMute(notif: Notif): Promise<boolean> {
264
- const subject = notif.reasonSubject
265
- if (!subject) return false
266
- if (subject.startsWith('did:')) return false
267
- const post = await this.db
268
- .selectFrom('post')
269
- .select(['uri', 'replyRoot'])
270
- .where('uri', '=', subject)
271
- .executeTakeFirst()
272
- if (!post) return false
273
- const threadRoot = post.replyRoot ?? post.uri
274
- const threadMute = await this.db
275
- .selectFrom('thread_mute')
276
- .selectAll()
277
- .where('mutedByDid', '=', notif.did)
278
- .where('rootUri', '=', threadRoot)
279
- .executeTakeFirst()
280
- return !!threadMute
281
- }
282
-
283
- aggregateOnCommit(indexed: TRow) {
284
- const { updateAggregates } = this.options
285
- if (!updateAggregates) return
286
- this.appDb.onCommit(() => {
287
- this.background.add((db) => updateAggregates(db.db, indexed))
288
- })
289
- }
290
- }
291
-
292
- export default RecordProcessor
@@ -1,84 +0,0 @@
1
- import { PlainMessage } from '@bufbuild/protobuf'
2
- import { ServiceImpl } from '@connectrpc/connect'
3
- import { keyBy } from '@atproto/common'
4
- import { Service } from '../../../proto/bsky_connect.js'
5
- import {
6
- ActivitySubscription,
7
- GetActivitySubscriptionsByActorAndSubjectsResponse,
8
- } from '../../../proto/bsky_pb.js'
9
- import { Namespaces } from '../../../stash.js'
10
- import { Database } from '../db/index.js'
11
- import { StashKeyKey } from '../db/pagination.js'
12
-
13
- export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
14
- async getActivitySubscriptionsByActorAndSubjects(req) {
15
- const { actorDid, subjectDids } = req
16
- if (subjectDids.length === 0) {
17
- return new GetActivitySubscriptionsByActorAndSubjectsResponse({
18
- subscriptions: [],
19
- })
20
- }
21
-
22
- const res = await db.db
23
- .selectFrom('activity_subscription')
24
- .selectAll()
25
- .where('creator', '=', actorDid)
26
- .where('subjectDid', 'in', subjectDids)
27
- .execute()
28
-
29
- const bySubject = keyBy(res, 'subjectDid')
30
- const subscriptions = subjectDids.map(
31
- (did): PlainMessage<ActivitySubscription> => {
32
- const subject = bySubject.get(did)
33
- if (!subject) {
34
- return {
35
- actorDid,
36
- namespace:
37
- Namespaces.AppBskyNotificationDefsSubjectActivitySubscription
38
- .$type,
39
- key: '',
40
- post: undefined,
41
- reply: undefined,
42
- subjectDid: '',
43
- }
44
- }
45
-
46
- return {
47
- actorDid,
48
- namespace:
49
- Namespaces.AppBskyNotificationDefsSubjectActivitySubscription.$type,
50
- key: subject.key,
51
- post: subject.post ? {} : undefined,
52
- reply: subject.reply ? {} : undefined,
53
- subjectDid: subject.subjectDid,
54
- }
55
- },
56
- )
57
-
58
- return {
59
- subscriptions,
60
- }
61
- },
62
-
63
- async getActivitySubscriptionDids(req) {
64
- const { actorDid, cursor, limit } = req
65
-
66
- let builder = db.db
67
- .selectFrom('activity_subscription')
68
- .selectAll()
69
- .where('creator', '=', actorDid)
70
-
71
- const { ref } = db.db.dynamic
72
- const key = new StashKeyKey(ref('activity_subscription.key'))
73
- builder = key.paginate(builder, {
74
- cursor,
75
- limit,
76
- })
77
- const res = await builder.execute()
78
- const dids = res.map(({ subjectDid }) => subjectDid)
79
- return {
80
- dids,
81
- cursor: key.packFromResult(res),
82
- }
83
- },
84
- })
@@ -1,127 +0,0 @@
1
- import { ServiceImpl } from '@connectrpc/connect'
2
- import { Service } from '../../../proto/bsky_connect.js'
3
- import { Database } from '../db/index.js'
4
- import { TimeCidKeyset, paginate } from '../db/pagination.js'
5
-
6
- export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
7
- async getBidirectionalBlock(req) {
8
- const { actorDid, targetDid } = req
9
- const res = await db.db
10
- .selectFrom('actor_block')
11
- .where((eb) =>
12
- eb.or([
13
- eb.and([
14
- eb('actor_block.creator', '=', actorDid),
15
- eb('actor_block.subjectDid', '=', targetDid),
16
- ]),
17
- eb.and([
18
- eb('actor_block.creator', '=', targetDid),
19
- eb('actor_block.subjectDid', '=', actorDid),
20
- ]),
21
- ]),
22
- )
23
- .limit(1)
24
- .selectAll()
25
- .executeTakeFirst()
26
-
27
- return {
28
- blockUri: res?.uri,
29
- }
30
- },
31
-
32
- async getBlocks(req) {
33
- const { actorDid, cursor, limit } = req
34
- const { ref } = db.db.dynamic
35
-
36
- let builder = db.db
37
- .selectFrom('actor_block')
38
- .where('actor_block.creator', '=', actorDid)
39
- .selectAll()
40
-
41
- const keyset = new TimeCidKeyset(
42
- ref('actor_block.sortAt'),
43
- ref('actor_block.cid'),
44
- )
45
- builder = paginate(builder, {
46
- limit,
47
- cursor,
48
- keyset,
49
- })
50
-
51
- const blocks = await builder.execute()
52
- return {
53
- blockUris: blocks.map((b) => b.uri),
54
- cursor: keyset.packFromResult(blocks),
55
- }
56
- },
57
-
58
- async getBidirectionalBlockViaList(req) {
59
- const { actorDid, targetDid } = req
60
- const res = await db.db
61
- .selectFrom('list_block')
62
- .innerJoin('list_item', 'list_item.listUri', 'list_block.subjectUri')
63
- .where((eb) =>
64
- eb.or([
65
- eb.and([
66
- eb('list_block.creator', '=', actorDid),
67
- eb('list_item.subjectDid', '=', targetDid),
68
- ]),
69
- eb.and([
70
- eb('list_block.creator', '=', targetDid),
71
- eb('list_item.subjectDid', '=', actorDid),
72
- ]),
73
- ]),
74
- )
75
- .limit(1)
76
- .selectAll('list_block')
77
- .executeTakeFirst()
78
-
79
- return {
80
- listUri: res?.subjectUri,
81
- }
82
- },
83
-
84
- async getBlocklistSubscription(req) {
85
- const { actorDid, listUri } = req
86
- const res = await db.db
87
- .selectFrom('list_block')
88
- .where('creator', '=', actorDid)
89
- .where('subjectUri', '=', listUri)
90
- .selectAll()
91
- .limit(1)
92
- .executeTakeFirst()
93
- return {
94
- listblockUri: res?.uri,
95
- }
96
- },
97
-
98
- async getBlocklistSubscriptions(req) {
99
- const { actorDid, limit, cursor } = req
100
- const { ref } = db.db.dynamic
101
- let builder = db.db
102
- .selectFrom('list')
103
- .where(({ exists }) =>
104
- exists(
105
- db.db
106
- .selectFrom('list_block')
107
- .where('list_block.creator', '=', actorDid)
108
- .whereRef('list_block.subjectUri', '=', ref('list.uri'))
109
- .selectAll(),
110
- ),
111
- )
112
- .selectAll('list')
113
-
114
- const keyset = new TimeCidKeyset(ref('list.createdAt'), ref('list.cid'))
115
- builder = paginate(builder, {
116
- limit,
117
- cursor,
118
- keyset,
119
- })
120
- const lists = await builder.execute()
121
-
122
- return {
123
- listUris: lists.map((l) => l.uri),
124
- cursor: keyset.packFromResult(lists),
125
- }
126
- },
127
- })
@@ -1,83 +0,0 @@
1
- import { PlainMessage, Timestamp } from '@bufbuild/protobuf'
2
- import { ServiceImpl } from '@connectrpc/connect'
3
- import { keyBy } from '@atproto/common'
4
- import { Service } from '../../../proto/bsky_connect.js'
5
- import {
6
- Bookmark,
7
- GetBookmarksByActorAndSubjectsResponse,
8
- } from '../../../proto/bsky_pb.js'
9
- import { Namespaces } from '../../../stash.js'
10
- import { Database } from '../db/index.js'
11
- import { StashKeyKey } from '../db/pagination.js'
12
-
13
- export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
14
- async getActorBookmarks(req) {
15
- const { actorDid, cursor, limit } = req
16
- const { ref } = db.db.dynamic
17
-
18
- let builder = db.db
19
- .selectFrom('bookmark')
20
- .where('bookmark.creator', '=', actorDid)
21
- .selectAll()
22
-
23
- const key = new StashKeyKey(ref('bookmark.key'))
24
- builder = key.paginate(builder, {
25
- cursor,
26
- limit,
27
- })
28
-
29
- const res = await builder.execute()
30
- return {
31
- bookmarks: res.map((b) => ({
32
- key: b.key,
33
- subject: b.subjectUri,
34
- })),
35
- cursor: key.packFromResult(res),
36
- }
37
- },
38
-
39
- async getBookmarksByActorAndSubjects(req) {
40
- const { actorDid, uris } = req
41
-
42
- if (uris.length === 0) {
43
- return new GetBookmarksByActorAndSubjectsResponse({
44
- bookmarks: [],
45
- })
46
- }
47
-
48
- const res = await db.db
49
- .selectFrom('bookmark')
50
- .where('bookmark.creator', '=', actorDid)
51
- .where('bookmark.subjectUri', 'in', uris)
52
- .selectAll()
53
- .execute()
54
-
55
- const byUri = keyBy(res, 'subjectUri')
56
- const bookmarks = uris.map((did): PlainMessage<Bookmark> => {
57
- const bookmark = byUri.get(did)
58
- if (!bookmark) {
59
- return {
60
- ref: undefined,
61
- subjectUri: '',
62
- subjectCid: '',
63
- indexedAt: undefined,
64
- }
65
- }
66
-
67
- return {
68
- ref: {
69
- actorDid,
70
- namespace: Namespaces.AppBskyBookmarkDefsBookmark.$type,
71
- key: bookmark.key,
72
- },
73
- subjectUri: bookmark.subjectUri,
74
- subjectCid: bookmark.subjectCid,
75
- indexedAt: Timestamp.fromDate(new Date(bookmark.indexedAt)),
76
- }
77
- })
78
-
79
- return {
80
- bookmarks,
81
- }
82
- },
83
- })
@@ -1,37 +0,0 @@
1
- import { PlainMessage, Timestamp } from '@bufbuild/protobuf'
2
- import { ServiceImpl } from '@connectrpc/connect'
3
- import { Service } from '../../../proto/bsky_connect.js'
4
- import { DraftInfo } from '../../../proto/bsky_pb.js'
5
- import { Database } from '../db/index.js'
6
- import { IsoUpdatedAtKey } from '../db/pagination.js'
7
-
8
- export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
9
- async getActorDrafts(req) {
10
- const { actorDid, cursor, limit } = req
11
- const { ref } = db.db.dynamic
12
-
13
- let builder = db.db
14
- .selectFrom('draft')
15
- .where('draft.creator', '=', actorDid)
16
- .selectAll()
17
-
18
- const key = new IsoUpdatedAtKey(ref('draft.updatedAt'))
19
- builder = key.paginate(builder, {
20
- cursor,
21
- limit,
22
- })
23
-
24
- const res = await builder.execute()
25
- return {
26
- drafts: res.map(
27
- (d): PlainMessage<DraftInfo> => ({
28
- key: d.key,
29
- payload: Buffer.from(d.payload),
30
- createdAt: Timestamp.fromDate(new Date(d.createdAt)),
31
- updatedAt: Timestamp.fromDate(new Date(d.updatedAt)),
32
- }),
33
- ),
34
- cursor: key.packFromResult(res),
35
- }
36
- },
37
- })