@atproto/bsky 0.0.243 → 0.0.244

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 (272) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/api/app/bsky/actor/searchActorsTypeahead.js +5 -3
  3. package/dist/api/app/bsky/actor/searchActorsTypeahead.js.map +1 -1
  4. package/dist/api/app/bsky/notification/putPreferencesV2.js +4 -1
  5. package/dist/api/app/bsky/notification/putPreferencesV2.js.map +1 -1
  6. package/dist/api/app/bsky/notification/util.d.ts +1 -0
  7. package/dist/api/app/bsky/notification/util.d.ts.map +1 -1
  8. package/dist/api/app/bsky/notification/util.js +7 -7
  9. package/dist/api/app/bsky/notification/util.js.map +1 -1
  10. package/dist/api/blob-dispatcher.d.ts.map +1 -1
  11. package/dist/api/blob-dispatcher.js +9 -8
  12. package/dist/api/blob-dispatcher.js.map +1 -1
  13. package/dist/api/blob-resolver.d.ts +1 -1
  14. package/dist/api/blob-resolver.d.ts.map +1 -1
  15. package/dist/api/blob-resolver.js +0 -1
  16. package/dist/api/blob-resolver.js.map +1 -1
  17. package/dist/data-plane/bsync/index.d.ts +2 -0
  18. package/dist/data-plane/bsync/index.d.ts.map +1 -1
  19. package/dist/data-plane/bsync/index.js +7 -10
  20. package/dist/data-plane/bsync/index.js.map +1 -1
  21. package/dist/data-plane/server/background.d.ts +12 -8
  22. package/dist/data-plane/server/background.d.ts.map +1 -1
  23. package/dist/data-plane/server/background.js +32 -14
  24. package/dist/data-plane/server/background.js.map +1 -1
  25. package/dist/data-plane/server/index.d.ts +2 -0
  26. package/dist/data-plane/server/index.d.ts.map +1 -1
  27. package/dist/data-plane/server/index.js +7 -10
  28. package/dist/data-plane/server/index.js.map +1 -1
  29. package/dist/data-plane/server/indexing/index.d.ts +2 -2
  30. package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
  31. package/dist/data-plane/server/indexing/index.js.map +1 -1
  32. package/dist/data-plane/server/indexing/plugins/block.d.ts +1 -1
  33. package/dist/data-plane/server/indexing/plugins/block.d.ts.map +1 -1
  34. package/dist/data-plane/server/indexing/plugins/block.js.map +1 -1
  35. package/dist/data-plane/server/indexing/plugins/chat-declaration.d.ts +1 -1
  36. package/dist/data-plane/server/indexing/plugins/chat-declaration.d.ts.map +1 -1
  37. package/dist/data-plane/server/indexing/plugins/chat-declaration.js.map +1 -1
  38. package/dist/data-plane/server/indexing/plugins/feed-generator.d.ts +1 -1
  39. package/dist/data-plane/server/indexing/plugins/feed-generator.d.ts.map +1 -1
  40. package/dist/data-plane/server/indexing/plugins/feed-generator.js.map +1 -1
  41. package/dist/data-plane/server/indexing/plugins/follow.d.ts +1 -1
  42. package/dist/data-plane/server/indexing/plugins/follow.d.ts.map +1 -1
  43. package/dist/data-plane/server/indexing/plugins/follow.js.map +1 -1
  44. package/dist/data-plane/server/indexing/plugins/germ-declaration.d.ts +1 -1
  45. package/dist/data-plane/server/indexing/plugins/germ-declaration.d.ts.map +1 -1
  46. package/dist/data-plane/server/indexing/plugins/germ-declaration.js.map +1 -1
  47. package/dist/data-plane/server/indexing/plugins/labeler.d.ts +1 -1
  48. package/dist/data-plane/server/indexing/plugins/labeler.d.ts.map +1 -1
  49. package/dist/data-plane/server/indexing/plugins/labeler.js.map +1 -1
  50. package/dist/data-plane/server/indexing/plugins/like.d.ts +1 -1
  51. package/dist/data-plane/server/indexing/plugins/like.d.ts.map +1 -1
  52. package/dist/data-plane/server/indexing/plugins/like.js.map +1 -1
  53. package/dist/data-plane/server/indexing/plugins/list-block.d.ts +1 -1
  54. package/dist/data-plane/server/indexing/plugins/list-block.d.ts.map +1 -1
  55. package/dist/data-plane/server/indexing/plugins/list-block.js.map +1 -1
  56. package/dist/data-plane/server/indexing/plugins/list-item.d.ts +1 -1
  57. package/dist/data-plane/server/indexing/plugins/list-item.d.ts.map +1 -1
  58. package/dist/data-plane/server/indexing/plugins/list-item.js.map +1 -1
  59. package/dist/data-plane/server/indexing/plugins/list.d.ts +1 -1
  60. package/dist/data-plane/server/indexing/plugins/list.d.ts.map +1 -1
  61. package/dist/data-plane/server/indexing/plugins/list.js.map +1 -1
  62. package/dist/data-plane/server/indexing/plugins/notif-declaration.d.ts +1 -1
  63. package/dist/data-plane/server/indexing/plugins/notif-declaration.d.ts.map +1 -1
  64. package/dist/data-plane/server/indexing/plugins/notif-declaration.js.map +1 -1
  65. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts +1 -1
  66. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts.map +1 -1
  67. package/dist/data-plane/server/indexing/plugins/post-gate.js.map +1 -1
  68. package/dist/data-plane/server/indexing/plugins/post.d.ts +1 -1
  69. package/dist/data-plane/server/indexing/plugins/post.d.ts.map +1 -1
  70. package/dist/data-plane/server/indexing/plugins/post.js.map +1 -1
  71. package/dist/data-plane/server/indexing/plugins/profile.d.ts +1 -1
  72. package/dist/data-plane/server/indexing/plugins/profile.d.ts.map +1 -1
  73. package/dist/data-plane/server/indexing/plugins/profile.js.map +1 -1
  74. package/dist/data-plane/server/indexing/plugins/repost.d.ts +1 -1
  75. package/dist/data-plane/server/indexing/plugins/repost.d.ts.map +1 -1
  76. package/dist/data-plane/server/indexing/plugins/repost.js.map +1 -1
  77. package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts +1 -1
  78. package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts.map +1 -1
  79. package/dist/data-plane/server/indexing/plugins/starter-pack.js.map +1 -1
  80. package/dist/data-plane/server/indexing/plugins/status.d.ts +1 -1
  81. package/dist/data-plane/server/indexing/plugins/status.d.ts.map +1 -1
  82. package/dist/data-plane/server/indexing/plugins/status.js.map +1 -1
  83. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts +1 -1
  84. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts.map +1 -1
  85. package/dist/data-plane/server/indexing/plugins/thread-gate.js.map +1 -1
  86. package/dist/data-plane/server/indexing/plugins/verification.d.ts +1 -1
  87. package/dist/data-plane/server/indexing/plugins/verification.d.ts.map +1 -1
  88. package/dist/data-plane/server/indexing/plugins/verification.js.map +1 -1
  89. package/dist/data-plane/server/indexing/processor.d.ts +1 -1
  90. package/dist/data-plane/server/indexing/processor.d.ts.map +1 -1
  91. package/dist/data-plane/server/indexing/processor.js.map +1 -1
  92. package/dist/data-plane/server/routes/notifs.d.ts.map +1 -1
  93. package/dist/data-plane/server/routes/notifs.js +1 -8
  94. package/dist/data-plane/server/routes/notifs.js.map +1 -1
  95. package/dist/data-plane/server/routes/search.js +2 -2
  96. package/dist/data-plane/server/routes/search.js.map +1 -1
  97. package/dist/data-plane/server/subscription.d.ts +13 -12
  98. package/dist/data-plane/server/subscription.d.ts.map +1 -1
  99. package/dist/data-plane/server/subscription.js +59 -26
  100. package/dist/data-plane/server/subscription.js.map +1 -1
  101. package/dist/feature-gates/index.d.ts +2 -1
  102. package/dist/feature-gates/index.d.ts.map +1 -1
  103. package/dist/feature-gates/index.js +9 -6
  104. package/dist/feature-gates/index.js.map +1 -1
  105. package/dist/feature-gates/metrics.d.ts +3 -3
  106. package/dist/feature-gates/metrics.d.ts.map +1 -1
  107. package/dist/feature-gates/metrics.js +8 -8
  108. package/dist/feature-gates/metrics.js.map +1 -1
  109. package/dist/index.d.ts +1 -0
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +16 -7
  112. package/dist/index.js.map +1 -1
  113. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts +5 -0
  114. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts.map +1 -1
  115. package/dist/lexicons/app/bsky/notification/defs.defs.js +1 -0
  116. package/dist/lexicons/app/bsky/notification/defs.defs.js.map +1 -1
  117. package/dist/lexicons/chat/bsky/notification/defs.d.ts +2 -0
  118. package/dist/lexicons/chat/bsky/notification/defs.d.ts.map +1 -0
  119. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts +20 -0
  120. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts.map +1 -0
  121. package/dist/lexicons/chat/bsky/notification/defs.defs.js +19 -0
  122. package/dist/lexicons/chat/bsky/notification/defs.defs.js.map +1 -0
  123. package/dist/lexicons/chat/bsky/notification/defs.js +5 -0
  124. package/dist/lexicons/chat/bsky/notification/defs.js.map +1 -0
  125. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts +3 -0
  126. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts.map +1 -0
  127. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts +18 -0
  128. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts.map +1 -0
  129. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js +16 -0
  130. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js.map +1 -0
  131. package/dist/lexicons/chat/bsky/notification/getPreferences.js +6 -0
  132. package/dist/lexicons/chat/bsky/notification/getPreferences.js.map +1 -0
  133. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts +3 -0
  134. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts.map +1 -0
  135. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts +27 -0
  136. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts.map +1 -0
  137. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js +22 -0
  138. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js.map +1 -0
  139. package/dist/lexicons/chat/bsky/notification/putPreferences.js +6 -0
  140. package/dist/lexicons/chat/bsky/notification/putPreferences.js.map +1 -0
  141. package/dist/lexicons/chat/bsky/notification.d.ts +4 -0
  142. package/dist/lexicons/chat/bsky/notification.d.ts.map +1 -0
  143. package/dist/lexicons/chat/bsky/notification.js +7 -0
  144. package/dist/lexicons/chat/bsky/notification.js.map +1 -0
  145. package/dist/lexicons/chat/bsky.d.ts +1 -0
  146. package/dist/lexicons/chat/bsky.d.ts.map +1 -1
  147. package/dist/lexicons/chat/bsky.js +1 -0
  148. package/dist/lexicons/chat/bsky.js.map +1 -1
  149. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +4 -0
  150. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
  151. package/dist/lexicons/tools/ozone/report/defs.defs.js +2 -0
  152. package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
  153. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts +3 -0
  154. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts.map +1 -0
  155. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts +42 -0
  156. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts.map +1 -0
  157. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js +31 -0
  158. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js.map +1 -0
  159. package/dist/lexicons/tools/ozone/report/queryActivities.js +6 -0
  160. package/dist/lexicons/tools/ozone/report/queryActivities.js.map +1 -0
  161. package/dist/lexicons/tools/ozone/report.d.ts +1 -0
  162. package/dist/lexicons/tools/ozone/report.d.ts.map +1 -1
  163. package/dist/lexicons/tools/ozone/report.js +1 -0
  164. package/dist/lexicons/tools/ozone/report.js.map +1 -1
  165. package/dist/proto/bsky_pb.d.ts +47 -53
  166. package/dist/proto/bsky_pb.d.ts.map +1 -1
  167. package/dist/proto/bsky_pb.js +62 -71
  168. package/dist/proto/bsky_pb.js.map +1 -1
  169. package/package.json +10 -10
  170. package/proto/bsky.proto +19 -17
  171. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +5 -3
  172. package/src/api/app/bsky/notification/putPreferencesV2.ts +4 -1
  173. package/src/api/app/bsky/notification/util.ts +7 -11
  174. package/src/api/blob-dispatcher.ts +12 -8
  175. package/src/api/blob-resolver.ts +0 -1
  176. package/src/data-plane/bsync/index.ts +12 -10
  177. package/src/data-plane/server/background.ts +49 -18
  178. package/src/data-plane/server/index.ts +12 -10
  179. package/src/data-plane/server/indexing/index.ts +1 -1
  180. package/src/data-plane/server/indexing/plugins/block.ts +4 -1
  181. package/src/data-plane/server/indexing/plugins/chat-declaration.ts +4 -1
  182. package/src/data-plane/server/indexing/plugins/feed-generator.ts +4 -1
  183. package/src/data-plane/server/indexing/plugins/follow.ts +4 -1
  184. package/src/data-plane/server/indexing/plugins/germ-declaration.ts +4 -1
  185. package/src/data-plane/server/indexing/plugins/labeler.ts +4 -1
  186. package/src/data-plane/server/indexing/plugins/like.ts +4 -1
  187. package/src/data-plane/server/indexing/plugins/list-block.ts +4 -1
  188. package/src/data-plane/server/indexing/plugins/list-item.ts +4 -1
  189. package/src/data-plane/server/indexing/plugins/list.ts +4 -1
  190. package/src/data-plane/server/indexing/plugins/notif-declaration.ts +4 -1
  191. package/src/data-plane/server/indexing/plugins/post-gate.ts +4 -1
  192. package/src/data-plane/server/indexing/plugins/post.ts +4 -1
  193. package/src/data-plane/server/indexing/plugins/profile.ts +4 -1
  194. package/src/data-plane/server/indexing/plugins/repost.ts +4 -1
  195. package/src/data-plane/server/indexing/plugins/starter-pack.ts +4 -1
  196. package/src/data-plane/server/indexing/plugins/status.ts +4 -1
  197. package/src/data-plane/server/indexing/plugins/thread-gate.ts +4 -1
  198. package/src/data-plane/server/indexing/plugins/verification.ts +4 -1
  199. package/src/data-plane/server/indexing/processor.ts +1 -1
  200. package/src/data-plane/server/routes/notifs.ts +0 -14
  201. package/src/data-plane/server/routes/search.ts +2 -2
  202. package/src/data-plane/server/subscription.ts +74 -31
  203. package/src/feature-gates/index.ts +10 -6
  204. package/src/feature-gates/metrics.test.ts +12 -12
  205. package/src/feature-gates/metrics.ts +8 -8
  206. package/src/index.ts +16 -9
  207. package/tests/_util.ts +8 -25
  208. package/tests/admin/admin-auth.test.ts +2 -2
  209. package/tests/admin/moderation.test.ts +1 -1
  210. package/tests/auth.test.ts +4 -6
  211. package/tests/blob-resolver.test.ts +4 -5
  212. package/tests/data-plane/db.test.ts +1 -1
  213. package/tests/data-plane/duplicate-records.test.ts +1 -1
  214. package/tests/data-plane/handle-invalidation.test.ts +2 -2
  215. package/tests/data-plane/indexing.test.ts +24 -21
  216. package/tests/data-plane/subscription.test.ts +1 -1
  217. package/tests/data-plane/thread-mutes.test.ts +2 -2
  218. package/tests/entryway-auth.test.ts +4 -5
  219. package/tests/feed-generation.test.ts +5 -5
  220. package/tests/image/server.test.ts +1 -1
  221. package/tests/label-hydration.test.ts +3 -5
  222. package/tests/postgates.test.ts +3 -6
  223. package/tests/query-labels.test.ts +3 -5
  224. package/tests/redis-cache.test.ts +1 -3
  225. package/tests/server.test.ts +11 -16
  226. package/tests/sitemap.test.ts +3 -4
  227. package/tests/stash.test.ts +12 -8
  228. package/tests/utils.test.ts +3 -13
  229. package/tests/views/account-deactivation.test.ts +3 -5
  230. package/tests/views/actor-likes.test.ts +3 -5
  231. package/tests/views/actor-search.test.ts +6 -7
  232. package/tests/views/age-assurance-v2.test.ts +9 -6
  233. package/tests/views/age-assurance.test.ts +30 -36
  234. package/tests/views/author-feed.test.ts +4 -6
  235. package/tests/views/block-lists.test.ts +3 -5
  236. package/tests/views/blocks.test.ts +3 -5
  237. package/tests/views/bookmarks.test.ts +4 -4
  238. package/tests/views/drafts.test.ts +7 -14
  239. package/tests/views/feed-hidden-replies.test.ts +3 -6
  240. package/tests/views/feed-view-post.test.ts +3 -6
  241. package/tests/views/follows.test.ts +4 -6
  242. package/tests/views/get-config.test.ts +4 -7
  243. package/tests/views/get-suggested-onboarding-users.test.ts +11 -9
  244. package/tests/views/get-suggested-starter-packs.test.ts +11 -9
  245. package/tests/views/get-trends.test.ts +15 -9
  246. package/tests/views/internal-actor.test.ts +3 -6
  247. package/tests/views/known-followers.test.ts +3 -6
  248. package/tests/views/labeler-service.test.ts +3 -5
  249. package/tests/views/labels-needs-review.test.ts +3 -6
  250. package/tests/views/labels-takedown.test.ts +3 -4
  251. package/tests/views/likes.test.ts +4 -6
  252. package/tests/views/list-feed.test.ts +3 -5
  253. package/tests/views/lists.test.ts +3 -5
  254. package/tests/views/mute-lists.test.ts +3 -5
  255. package/tests/views/mutes.test.ts +4 -5
  256. package/tests/views/notifications.test.ts +12 -11
  257. package/tests/views/post-search.test.ts +3 -24
  258. package/tests/views/posts-debug.test.ts +11 -6
  259. package/tests/views/posts.test.ts +3 -4
  260. package/tests/views/profile-debug.test.ts +11 -5
  261. package/tests/views/profile.test.ts +11 -5
  262. package/tests/views/quotes.test.ts +4 -6
  263. package/tests/views/reposts.test.ts +4 -6
  264. package/tests/views/starter-packs.test.ts +3 -6
  265. package/tests/views/suggestions.test.ts +9 -13
  266. package/tests/views/thread-v2.test.ts +3 -5
  267. package/tests/views/thread.test.ts +3 -7
  268. package/tests/views/threadgating.test.ts +3 -5
  269. package/tests/views/timeline.test.ts +4 -5
  270. package/tests/views/verification.test.ts +4 -6
  271. package/tsconfig.build.tsbuildinfo +1 -1
  272. package/vitest.config.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/bsky",
3
- "version": "0.0.243",
3
+ "version": "0.0.244",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of app.bsky App View (Bluesky API)",
6
6
  "keywords": [
@@ -46,18 +46,18 @@
46
46
  "structured-headers": "^1.0.1",
47
47
  "typed-emitter": "^2.1.0",
48
48
  "uint8arrays": "^5.0.0",
49
- "undici": "^6.19.8",
49
+ "undici": "^8.5.0",
50
50
  "zod": "3.23.8",
51
- "@atproto-labs/xrpc-utils": "^0.1.1",
52
- "@atproto/api": "^0.20.16",
53
- "@atproto/common": "^0.6.3",
54
- "@atproto-labs/fetch-node": "^0.3.1",
51
+ "@atproto-labs/fetch-node": "^0.3.2",
52
+ "@atproto/api": "^0.20.17",
55
53
  "@atproto/crypto": "^0.5.1",
54
+ "@atproto/common": "^0.6.3",
56
55
  "@atproto/did": "^0.5.1",
57
- "@atproto/identity": "^0.5.1",
58
- "@atproto/repo": "^0.10.1",
56
+ "@atproto-labs/xrpc-utils": "^0.1.1",
59
57
  "@atproto/lex": "^0.1.4",
60
- "@atproto/sync": "^0.3.2",
58
+ "@atproto/repo": "^0.10.1",
59
+ "@atproto/identity": "^0.5.1",
60
+ "@atproto/sync": "^0.3.3",
61
61
  "@atproto/syntax": "^0.6.2",
62
62
  "@atproto/xrpc-server": "^0.11.2"
63
63
  },
@@ -73,7 +73,7 @@
73
73
  "@types/qs": "^6.9.7",
74
74
  "ts-node": "^10.8.2",
75
75
  "vitest": "^4.0.16",
76
- "@atproto/pds": "^0.5.6"
76
+ "@atproto/pds": "^0.5.7"
77
77
  },
78
78
  "type": "module",
79
79
  "exports": {
package/proto/bsky.proto CHANGED
@@ -815,20 +815,12 @@ message NotificationPreference {
815
815
  NotificationChannelPush push = 2;
816
816
  }
817
817
 
818
- enum ChatNotificationInclude {
819
- CHAT_NOTIFICATION_INCLUDE_UNSPECIFIED = 0;
820
- CHAT_NOTIFICATION_INCLUDE_ALL = 1;
821
- CHAT_NOTIFICATION_INCLUDE_ACCEPTED = 2;
822
- }
823
-
824
- message ChatNotificationPreference {
825
- ChatNotificationInclude include = 1;
826
- NotificationChannelPush push = 2;
827
- }
828
-
829
818
  message NotificationPreferences {
830
819
  bytes entry = 1;
831
- ChatNotificationPreference chat = 2;
820
+
821
+ reserved 2; // formerly "chat". This is now stored on the chat service.
822
+ reserved "chat";
823
+
832
824
  FilterableNotificationPreference follow = 3;
833
825
  FilterableNotificationPreference like = 4;
834
826
  FilterableNotificationPreference like_via_repost = 5;
@@ -1144,10 +1136,10 @@ enum SearchQueryLanguage {
1144
1136
  SEARCH_QUERY_LANGUAGE_ZH = 2; // Chinese (smartcn)
1145
1137
  SEARCH_QUERY_LANGUAGE_KO = 3; // Korean (nori)
1146
1138
  SEARCH_QUERY_LANGUAGE_TH = 4; // Thai
1139
+ SEARCH_QUERY_LANGUAGE_AR = 5; // Arabic
1147
1140
  }
1148
1141
 
1149
- // Shared request params
1150
-
1142
+ // Shared request params for paginated methods
1151
1143
  message SearchParams {
1152
1144
  string query = 1;
1153
1145
  string viewer = 2;
@@ -1157,6 +1149,13 @@ message SearchParams {
1157
1149
  string cursor = 4;
1158
1150
  }
1159
1151
 
1152
+ // Shared params for typeahead-style searches, which aren't paginated.
1153
+ message SearchTypeaheadParams {
1154
+ string query = 1;
1155
+ string viewer = 2;
1156
+ int32 limit = 3;
1157
+ }
1158
+
1160
1159
  // Shared result types
1161
1160
 
1162
1161
  // SearchRecordResult represents a generic result hit corresponding to a record.
@@ -1246,6 +1245,11 @@ message SearchPostsV2Request {
1246
1245
  message SearchPostsV2Response {
1247
1246
  repeated SearchRecordResult posts = 1;
1248
1247
  PageInfo page_info = 2;
1248
+ // Detected CJK/Thai/Arabic languages of the query, usually one. Han-only text
1249
+ // returns ["zh", "ja"] since it's ambiguous between Chinese and Japanese.
1250
+ // set query_language on the request to disambiguate.
1251
+ // Currently left empty for other scripts (e.g. Latin-based languages like English).
1252
+ repeated string detected_query_languages = 3;
1249
1253
  }
1250
1254
 
1251
1255
  message SearchActorsV2Request {
@@ -1258,9 +1262,7 @@ message SearchActorsV2Response {
1258
1262
  }
1259
1263
 
1260
1264
  message SearchActorsTypeaheadRequest {
1261
- string viewer = 1;
1262
- string query = 2;
1263
- int32 limit = 3;
1265
+ SearchTypeaheadParams params = 1;
1264
1266
  }
1265
1267
 
1266
1268
  message SearchActorsTypeaheadResponse {
@@ -95,9 +95,11 @@ const skeletonV2 = async (
95
95
  const term = params.q ?? params.term ?? ''
96
96
 
97
97
  const res = await ctx.dataplane.searchActorsTypeahead({
98
- viewer: params.hydrateCtx.viewer ?? undefined,
99
- query: term,
100
- limit: params.limit,
98
+ params: {
99
+ query: term,
100
+ viewer: params.hydrateCtx.viewer ?? undefined,
101
+ limit: params.limit,
102
+ },
101
103
  })
102
104
  return {
103
105
  dids: res.actors.map(({ did }) => did as DidString),
@@ -5,7 +5,7 @@ import { AppContext } from '../../../../context.js'
5
5
  import { app } from '../../../../lexicons/index.js'
6
6
  import { GetNotificationPreferencesResponse } from '../../../../proto/bsky_pb.js'
7
7
  import { Namespaces } from '../../../../stash.js'
8
- import { protobufToLex } from './util.js'
8
+ import { DEFAULT_CHAT_PREFERENCE, protobufToLex } from './util.js'
9
9
 
10
10
  export default function (server: Server, ctx: AppContext) {
11
11
  server.add(app.bsky.notification.putPreferencesV2, {
@@ -57,5 +57,8 @@ const computePreferences = async (
57
57
 
58
58
  const currentPreferences = protobufToLex(res.preferences[0])
59
59
  const preferences = { ...currentPreferences, ...input.body }
60
+ // NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.
61
+ // Use the chat.bsky.notification.defs#preferences type instead.
62
+ preferences.chat = DEFAULT_CHAT_PREFERENCE
60
63
  return preferences
61
64
  }
@@ -1,7 +1,5 @@
1
1
  import { app } from '../../../../lexicons/index.js'
2
2
  import {
3
- ChatNotificationInclude,
4
- ChatNotificationPreference,
5
3
  FilterableNotificationPreference,
6
4
  NotificationInclude,
7
5
  NotificationPreference,
@@ -71,15 +69,11 @@ const ensurePreferences = (
71
69
  }
72
70
  }
73
71
 
74
- const protobufChatPreferenceToLex = (
75
- p?: DeepPartial<ChatNotificationPreference>,
76
- ): Partial<app.bsky.notification.defs.ChatPreference> => {
77
- return {
78
- include:
79
- p?.include === ChatNotificationInclude.ACCEPTED ? 'accepted' : 'all',
80
- push: p?.push?.enabled,
72
+ export const DEFAULT_CHAT_PREFERENCE: app.bsky.notification.defs.ChatPreference =
73
+ {
74
+ include: 'all',
75
+ push: true,
81
76
  }
82
- }
83
77
 
84
78
  const protobufFilterablePreferenceToLex = (
85
79
  p?: DeepPartial<FilterableNotificationPreference>,
@@ -104,7 +98,9 @@ export const protobufToLex = (
104
98
  res: DeepPartial<NotificationPreferences>,
105
99
  ): app.bsky.notification.defs.Preferences => {
106
100
  return ensurePreferences({
107
- chat: protobufChatPreferenceToLex(res.chat),
101
+ // NOTE: See the deprecation notice on the lexicon. This field returns a static default value and shouldn't be used.
102
+ // Use the chat.bsky.notification.defs#preferences type instead.
103
+ chat: DEFAULT_CHAT_PREFERENCE,
108
104
  follow: protobufFilterablePreferenceToLex(res.follow),
109
105
  like: protobufFilterablePreferenceToLex(res.like),
110
106
  likeViaRepost: protobufFilterablePreferenceToLex(res.likeViaRepost),
@@ -1,4 +1,4 @@
1
- import { Agent, Dispatcher, Pool, RetryAgent } from 'undici'
1
+ import { Agent, Dispatcher, Pool, interceptors } from 'undici'
2
2
  import { isUnicastIp, unicastLookup } from '@atproto-labs/fetch-node'
3
3
  import { ServerConfig } from '../config.js'
4
4
  import { RETRYABLE_HTTP_STATUS_CODES } from '../util/retry.js'
@@ -27,11 +27,15 @@ export function createBlobDispatcher(cfg: ServerConfig): Dispatcher {
27
27
  },
28
28
  })
29
29
 
30
- return cfg.proxyMaxRetries > 0
31
- ? new RetryAgent(baseDispatcher, {
32
- statusCodes: [...RETRYABLE_HTTP_STATUS_CODES],
33
- methods: ['GET', 'HEAD'],
34
- maxRetries: cfg.proxyMaxRetries,
35
- })
36
- : baseDispatcher
30
+ return baseDispatcher.compose(
31
+ interceptors.redirect({
32
+ maxRedirections: 10,
33
+ throwOnMaxRedirect: true,
34
+ }),
35
+ interceptors.retry({
36
+ statusCodes: [...RETRYABLE_HTTP_STATUS_CODES],
37
+ methods: ['GET', 'HEAD'],
38
+ maxRetries: cfg.proxyMaxRetries,
39
+ }),
40
+ )
37
41
  }
@@ -197,7 +197,6 @@ export async function streamBlob(
197
197
  path: url.pathname + url.search,
198
198
  headers,
199
199
  signal: options.signal,
200
- maxRedirections: 10,
201
200
  },
202
201
  (upstream) => {
203
202
  headersReceived = true
@@ -4,6 +4,8 @@ import http from 'node:http'
4
4
  import { ConnectRouter } from '@connectrpc/connect'
5
5
  import { expressConnectMiddleware } from '@connectrpc/connect-express'
6
6
  import express from 'express'
7
+ // eslint-disable-next-line import/default
8
+ import httpTerminator from 'http-terminator'
7
9
  import { TID } from '@atproto/common'
8
10
  import { lexParse } from '@atproto/lex'
9
11
  import { AtUri } from '@atproto/syntax'
@@ -20,7 +22,11 @@ import { Database } from '../server/db/index.js'
20
22
  import { countAll, excluded } from '../server/db/util.js'
21
23
 
22
24
  export class MockBsync {
23
- constructor(public server: http.Server) {}
25
+ private terminator: httpTerminator.HttpTerminator
26
+
27
+ constructor(public server: http.Server) {
28
+ this.terminator = httpTerminator.createHttpTerminator({ server })
29
+ }
24
30
 
25
31
  static async create(db: Database, port: number) {
26
32
  const app = express()
@@ -32,15 +38,11 @@ export class MockBsync {
32
38
  }
33
39
 
34
40
  async destroy() {
35
- return new Promise<void>((resolve, reject) => {
36
- this.server.close((err) => {
37
- if (err) {
38
- reject(err)
39
- } else {
40
- resolve()
41
- }
42
- })
43
- })
41
+ await this.terminator.terminate()
42
+ }
43
+
44
+ async [Symbol.asyncDispose]() {
45
+ await this.destroy()
44
46
  }
45
47
  }
46
48
 
@@ -1,35 +1,66 @@
1
1
  import PQueue from 'p-queue'
2
2
  import { dbLogger } from '../../logger.js'
3
- import { Database } from './db/index.js'
4
3
 
5
4
  // A simple queue for in-process, out-of-band/backgrounded work
6
5
 
7
- export class BackgroundQueue {
8
- queue: InstanceType<typeof PQueue> = new PQueue()
9
- destroyed = false
10
- constructor(public db: Database) {}
6
+ type Task<TContext> = (ctx: TContext, signal: AbortSignal) => Promise<void>
11
7
 
12
- add(task: Task) {
13
- if (this.destroyed) {
14
- return
15
- }
16
- this.queue
17
- .add(() => task(this.db))
18
- .catch((err) => {
8
+ export type BackgroundQueueOptions = NonNullable<
9
+ ConstructorParameters<typeof PQueue>[0]
10
+ > & {
11
+ concurrency: number
12
+ }
13
+
14
+ // @NOTE Keep this in sync with the BackgroundQueue in
15
+ // - packages/bsky/src/data-plane/server/background.ts
16
+ // - packages/ozone/src/background.ts
17
+ // - packages/pds/src/background.ts
18
+ export class BackgroundQueue<TContext = unknown> {
19
+ private abortController = new AbortController()
20
+ private queue: PQueue
21
+
22
+ public get signal(): AbortSignal {
23
+ return this.abortController.signal
24
+ }
25
+
26
+ public get destroyed() {
27
+ return this.signal.aborted
28
+ }
29
+
30
+ constructor(
31
+ private readonly context: TContext,
32
+ options?: BackgroundQueueOptions,
33
+ ) {
34
+ this.queue = new PQueue(options)
35
+ }
36
+
37
+ add(task: Task<TContext>) {
38
+ if (this.destroyed) return
39
+
40
+ this.queue.add<void>(async () => {
41
+ try {
42
+ // The task will receive a signal allowing it to abort if the
43
+ // backgroundQueue is destroyed.
44
+ await task(this.context, this.signal)
45
+ } catch (err) {
19
46
  dbLogger.error({ err }, 'background queue task failed')
20
- })
47
+ }
48
+ })
21
49
  }
22
50
 
23
51
  async processAll() {
24
- await this.queue.onIdle()
52
+ const { queue } = this
53
+ while (queue.size || queue.pending) await queue.onIdle()
25
54
  }
26
55
 
27
56
  // On destroy we stop accepting new tasks, but complete all pending/in-progress tasks.
28
57
  // The application calls this only once http connections have drained (tasks no longer being added).
29
58
  async destroy() {
30
- this.destroyed = true
31
- await this.queue.onIdle()
59
+ if (this.destroyed) {
60
+ dbLogger.warn('BackgroundQueue.destroy() called multiple times')
61
+ }
62
+
63
+ this.abortController.abort()
64
+ return this.processAll()
32
65
  }
33
66
  }
34
-
35
- type Task = (db: Database) => Promise<void>
@@ -2,6 +2,8 @@ import events from 'node:events'
2
2
  import http from 'node:http'
3
3
  import { expressConnectMiddleware } from '@connectrpc/connect-express'
4
4
  import express from 'express'
5
+ // eslint-disable-next-line import/default
6
+ import httpTerminator from 'http-terminator'
5
7
  import { IdResolver, MemoryCache } from '@atproto/identity'
6
8
  import { Database, DatabaseSchema } from './db/index.js'
7
9
  import createRoutes from './routes/index.js'
@@ -11,10 +13,14 @@ export type { DatabaseSchema }
11
13
  export { RepoSubscription } from './subscription.js'
12
14
 
13
15
  export class DataPlaneServer {
16
+ private terminator: httpTerminator.HttpTerminator
17
+
14
18
  constructor(
15
19
  public server: http.Server,
16
20
  public idResolver: IdResolver,
17
- ) {}
21
+ ) {
22
+ this.terminator = httpTerminator.createHttpTerminator({ server })
23
+ }
18
24
 
19
25
  static async create(db: Database, port: number, plcUrl?: string) {
20
26
  const app = express()
@@ -28,14 +34,10 @@ export class DataPlaneServer {
28
34
  }
29
35
 
30
36
  async destroy() {
31
- return new Promise<void>((resolve, reject) => {
32
- this.server.close((err) => {
33
- if (err) {
34
- reject(err)
35
- } else {
36
- resolve()
37
- }
38
- })
39
- })
37
+ await this.terminator.terminate()
38
+ }
39
+
40
+ async [Symbol.asyncDispose]() {
41
+ await this.destroy()
40
42
  }
41
43
  }
@@ -62,7 +62,7 @@ export class IndexingService {
62
62
  constructor(
63
63
  public db: Database,
64
64
  public idResolver: IdResolver,
65
- public background: BackgroundQueue,
65
+ public background: BackgroundQueue<Database>,
66
66
  ) {
67
67
  this.records = {
68
68
  post: Post.makePlugin(this.db, this.background),
@@ -67,7 +67,10 @@ const notifsForDelete = () => {
67
67
  }
68
68
 
69
69
  export type PluginType = ReturnType<typeof makePlugin>
70
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
70
+ export const makePlugin = (
71
+ db: Database,
72
+ background: BackgroundQueue<Database>,
73
+ ) => {
71
74
  return new RecordProcessor(db, background, {
72
75
  schema: app.bsky.graph.block.main,
73
76
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  const processor = new RecordProcessor(db, background, {
45
48
  schema: chat.bsky.actor.declaration.main,
46
49
  insertFn,
@@ -63,7 +63,10 @@ const notifsForDelete = () => {
63
63
  }
64
64
 
65
65
  export type PluginType = ReturnType<typeof makePlugin>
66
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
66
+ export const makePlugin = (
67
+ db: Database,
68
+ background: BackgroundQueue<Database>,
69
+ ) => {
67
70
  return new RecordProcessor(db, background, {
68
71
  schema: app.bsky.feed.generator.main,
69
72
  insertFn,
@@ -114,7 +114,10 @@ const updateAggregates = async (db: DatabaseSchema, follow: IndexedFollow) => {
114
114
  }
115
115
 
116
116
  export type PluginType = ReturnType<typeof makePlugin>
117
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
117
+ export const makePlugin = (
118
+ db: Database,
119
+ background: BackgroundQueue<Database>,
120
+ ) => {
118
121
  return new RecordProcessor(db, background, {
119
122
  schema: app.bsky.graph.follow.main,
120
123
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  return new RecordProcessor(db, background, {
45
48
  schema: com.germnetwork.declaration.main,
46
49
  insertFn,
@@ -57,7 +57,10 @@ const notifsForDelete = () => {
57
57
  }
58
58
 
59
59
  export type PluginType = ReturnType<typeof makePlugin>
60
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
60
+ export const makePlugin = (
61
+ db: Database,
62
+ background: BackgroundQueue<Database>,
63
+ ) => {
61
64
  return new RecordProcessor(db, background, {
62
65
  schema: app.bsky.labeler.service.main,
63
66
  insertFn,
@@ -133,7 +133,10 @@ const updateAggregates = async (db: DatabaseSchema, like: IndexedLike) => {
133
133
  }
134
134
 
135
135
  export type PluginType = ReturnType<typeof makePlugin>
136
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
136
+ export const makePlugin = (
137
+ db: Database,
138
+ background: BackgroundQueue<Database>,
139
+ ) => {
137
140
  return new RecordProcessor(db, background, {
138
141
  schema: app.bsky.feed.like.main,
139
142
  insertFn,
@@ -67,7 +67,10 @@ const notifsForDelete = () => {
67
67
  }
68
68
 
69
69
  export type PluginType = ReturnType<typeof makePlugin>
70
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
70
+ export const makePlugin = (
71
+ db: Database,
72
+ background: BackgroundQueue<Database>,
73
+ ) => {
71
74
  return new RecordProcessor(db, background, {
72
75
  schema: app.bsky.graph.listblock.main,
73
76
  insertFn,
@@ -75,7 +75,10 @@ const notifsForDelete = () => {
75
75
  }
76
76
 
77
77
  export type PluginType = ReturnType<typeof makePlugin>
78
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
78
+ export const makePlugin = (
79
+ db: Database,
80
+ background: BackgroundQueue<Database>,
81
+ ) => {
79
82
  return new RecordProcessor(db, background, {
80
83
  schema: app.bsky.graph.listitem.main,
81
84
  insertFn,
@@ -63,7 +63,10 @@ const notifsForDelete = () => {
63
63
  }
64
64
 
65
65
  export type PluginType = ReturnType<typeof makePlugin>
66
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
66
+ export const makePlugin = (
67
+ db: Database,
68
+ background: BackgroundQueue<Database>,
69
+ ) => {
67
70
  return new RecordProcessor(db, background, {
68
71
  schema: app.bsky.graph.list.main,
69
72
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  return new RecordProcessor(db, background, {
45
48
  schema: app.bsky.notification.declaration.main,
46
49
  insertFn,
@@ -84,7 +84,10 @@ const notifsForDelete = () => {
84
84
  }
85
85
 
86
86
  export type PluginType = ReturnType<typeof makePlugin>
87
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
87
+ export const makePlugin = (
88
+ db: Database,
89
+ background: BackgroundQueue<Database>,
90
+ ) => {
88
91
  return new RecordProcessor(db, background, {
89
92
  schema: app.bsky.feed.postgate.main,
90
93
  insertFn,
@@ -535,7 +535,10 @@ const updateAggregates = async (db: DatabaseSchema, postIdx: IndexedPost) => {
535
535
  }
536
536
 
537
537
  export type PluginType = ReturnType<typeof makePlugin>
538
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
538
+ export const makePlugin = (
539
+ db: Database,
540
+ background: BackgroundQueue<Database>,
541
+ ) => {
539
542
  return new RecordProcessor(db, background, {
540
543
  schema: app.bsky.feed.post.main,
541
544
  insertFn,
@@ -73,7 +73,10 @@ const notifsForDelete = () => {
73
73
  }
74
74
 
75
75
  export type PluginType = ReturnType<typeof makePlugin>
76
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
76
+ export const makePlugin = (
77
+ db: Database,
78
+ background: BackgroundQueue<Database>,
79
+ ) => {
77
80
  return new RecordProcessor(db, background, {
78
81
  schema: app.bsky.actor.profile.main,
79
82
  insertFn,
@@ -158,7 +158,10 @@ const updateAggregates = async (db: DatabaseSchema, repost: IndexedRepost) => {
158
158
  }
159
159
 
160
160
  export type PluginType = ReturnType<typeof makePlugin>
161
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
161
+ export const makePlugin = (
162
+ db: Database,
163
+ background: BackgroundQueue<Database>,
164
+ ) => {
162
165
  return new RecordProcessor(db, background, {
163
166
  schema: app.bsky.feed.repost.main,
164
167
  insertFn,
@@ -57,7 +57,10 @@ const notifsForDelete = () => {
57
57
  }
58
58
 
59
59
  export type PluginType = ReturnType<typeof makePlugin>
60
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
60
+ export const makePlugin = (
61
+ db: Database,
62
+ background: BackgroundQueue<Database>,
63
+ ) => {
61
64
  return new RecordProcessor(db, background, {
62
65
  schema: app.bsky.graph.starterpack.main,
63
66
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  return new RecordProcessor(db, background, {
45
48
  schema: app.bsky.actor.status.main,
46
49
  insertFn,
@@ -84,7 +84,10 @@ const notifsForDelete = () => {
84
84
  }
85
85
 
86
86
  export type PluginType = ReturnType<typeof makePlugin>
87
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
87
+ export const makePlugin = (
88
+ db: Database,
89
+ background: BackgroundQueue<Database>,
90
+ ) => {
88
91
  return new RecordProcessor(db, background, {
89
92
  schema: app.bsky.feed.threadgate.main,
90
93
  insertFn,
@@ -96,7 +96,10 @@ const notifsForDelete = (
96
96
  }
97
97
 
98
98
  export type PluginType = ReturnType<typeof makePlugin>
99
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
99
+ export const makePlugin = (
100
+ db: Database,
101
+ background: BackgroundQueue<Database>,
102
+ ) => {
100
103
  return new RecordProcessor(db, background, {
101
104
  schema: app.bsky.graph.verification.main,
102
105
  insertFn,