@atproto/bsky 0.0.243 → 0.0.245

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 (405) hide show
  1. package/CHANGELOG.md +28 -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/feed/searchPostsV2.d.ts +4 -0
  5. package/dist/api/app/bsky/feed/searchPostsV2.d.ts.map +1 -0
  6. package/dist/api/app/bsky/feed/searchPostsV2.js +169 -0
  7. package/dist/api/app/bsky/feed/searchPostsV2.js.map +1 -0
  8. package/dist/api/app/bsky/notification/putPreferencesV2.js +4 -1
  9. package/dist/api/app/bsky/notification/putPreferencesV2.js.map +1 -1
  10. package/dist/api/app/bsky/notification/util.d.ts +1 -0
  11. package/dist/api/app/bsky/notification/util.d.ts.map +1 -1
  12. package/dist/api/app/bsky/notification/util.js +7 -7
  13. package/dist/api/app/bsky/notification/util.js.map +1 -1
  14. package/dist/api/blob-dispatcher.d.ts.map +1 -1
  15. package/dist/api/blob-dispatcher.js +9 -8
  16. package/dist/api/blob-dispatcher.js.map +1 -1
  17. package/dist/api/blob-resolver.d.ts +1 -1
  18. package/dist/api/blob-resolver.d.ts.map +1 -1
  19. package/dist/api/blob-resolver.js +0 -1
  20. package/dist/api/blob-resolver.js.map +1 -1
  21. package/dist/api/index.d.ts.map +1 -1
  22. package/dist/api/index.js +2 -0
  23. package/dist/api/index.js.map +1 -1
  24. package/dist/data-plane/bsync/index.d.ts +2 -0
  25. package/dist/data-plane/bsync/index.d.ts.map +1 -1
  26. package/dist/data-plane/bsync/index.js +7 -10
  27. package/dist/data-plane/bsync/index.js.map +1 -1
  28. package/dist/data-plane/server/background.d.ts +12 -8
  29. package/dist/data-plane/server/background.d.ts.map +1 -1
  30. package/dist/data-plane/server/background.js +32 -14
  31. package/dist/data-plane/server/background.js.map +1 -1
  32. package/dist/data-plane/server/index.d.ts +2 -0
  33. package/dist/data-plane/server/index.d.ts.map +1 -1
  34. package/dist/data-plane/server/index.js +7 -10
  35. package/dist/data-plane/server/index.js.map +1 -1
  36. package/dist/data-plane/server/indexing/index.d.ts +2 -2
  37. package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
  38. package/dist/data-plane/server/indexing/index.js.map +1 -1
  39. package/dist/data-plane/server/indexing/plugins/block.d.ts +1 -1
  40. package/dist/data-plane/server/indexing/plugins/block.d.ts.map +1 -1
  41. package/dist/data-plane/server/indexing/plugins/block.js.map +1 -1
  42. package/dist/data-plane/server/indexing/plugins/chat-declaration.d.ts +1 -1
  43. package/dist/data-plane/server/indexing/plugins/chat-declaration.d.ts.map +1 -1
  44. package/dist/data-plane/server/indexing/plugins/chat-declaration.js.map +1 -1
  45. package/dist/data-plane/server/indexing/plugins/feed-generator.d.ts +1 -1
  46. package/dist/data-plane/server/indexing/plugins/feed-generator.d.ts.map +1 -1
  47. package/dist/data-plane/server/indexing/plugins/feed-generator.js.map +1 -1
  48. package/dist/data-plane/server/indexing/plugins/follow.d.ts +1 -1
  49. package/dist/data-plane/server/indexing/plugins/follow.d.ts.map +1 -1
  50. package/dist/data-plane/server/indexing/plugins/follow.js.map +1 -1
  51. package/dist/data-plane/server/indexing/plugins/germ-declaration.d.ts +1 -1
  52. package/dist/data-plane/server/indexing/plugins/germ-declaration.d.ts.map +1 -1
  53. package/dist/data-plane/server/indexing/plugins/germ-declaration.js.map +1 -1
  54. package/dist/data-plane/server/indexing/plugins/labeler.d.ts +1 -1
  55. package/dist/data-plane/server/indexing/plugins/labeler.d.ts.map +1 -1
  56. package/dist/data-plane/server/indexing/plugins/labeler.js.map +1 -1
  57. package/dist/data-plane/server/indexing/plugins/like.d.ts +1 -1
  58. package/dist/data-plane/server/indexing/plugins/like.d.ts.map +1 -1
  59. package/dist/data-plane/server/indexing/plugins/like.js.map +1 -1
  60. package/dist/data-plane/server/indexing/plugins/list-block.d.ts +1 -1
  61. package/dist/data-plane/server/indexing/plugins/list-block.d.ts.map +1 -1
  62. package/dist/data-plane/server/indexing/plugins/list-block.js.map +1 -1
  63. package/dist/data-plane/server/indexing/plugins/list-item.d.ts +1 -1
  64. package/dist/data-plane/server/indexing/plugins/list-item.d.ts.map +1 -1
  65. package/dist/data-plane/server/indexing/plugins/list-item.js.map +1 -1
  66. package/dist/data-plane/server/indexing/plugins/list.d.ts +1 -1
  67. package/dist/data-plane/server/indexing/plugins/list.d.ts.map +1 -1
  68. package/dist/data-plane/server/indexing/plugins/list.js.map +1 -1
  69. package/dist/data-plane/server/indexing/plugins/notif-declaration.d.ts +1 -1
  70. package/dist/data-plane/server/indexing/plugins/notif-declaration.d.ts.map +1 -1
  71. package/dist/data-plane/server/indexing/plugins/notif-declaration.js.map +1 -1
  72. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts +1 -1
  73. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts.map +1 -1
  74. package/dist/data-plane/server/indexing/plugins/post-gate.js.map +1 -1
  75. package/dist/data-plane/server/indexing/plugins/post.d.ts +1 -1
  76. package/dist/data-plane/server/indexing/plugins/post.d.ts.map +1 -1
  77. package/dist/data-plane/server/indexing/plugins/post.js.map +1 -1
  78. package/dist/data-plane/server/indexing/plugins/profile.d.ts +1 -1
  79. package/dist/data-plane/server/indexing/plugins/profile.d.ts.map +1 -1
  80. package/dist/data-plane/server/indexing/plugins/profile.js.map +1 -1
  81. package/dist/data-plane/server/indexing/plugins/repost.d.ts +1 -1
  82. package/dist/data-plane/server/indexing/plugins/repost.d.ts.map +1 -1
  83. package/dist/data-plane/server/indexing/plugins/repost.js.map +1 -1
  84. package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts +1 -1
  85. package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts.map +1 -1
  86. package/dist/data-plane/server/indexing/plugins/starter-pack.js.map +1 -1
  87. package/dist/data-plane/server/indexing/plugins/status.d.ts +1 -1
  88. package/dist/data-plane/server/indexing/plugins/status.d.ts.map +1 -1
  89. package/dist/data-plane/server/indexing/plugins/status.js.map +1 -1
  90. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts +1 -1
  91. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts.map +1 -1
  92. package/dist/data-plane/server/indexing/plugins/thread-gate.js.map +1 -1
  93. package/dist/data-plane/server/indexing/plugins/verification.d.ts +1 -1
  94. package/dist/data-plane/server/indexing/plugins/verification.d.ts.map +1 -1
  95. package/dist/data-plane/server/indexing/plugins/verification.js.map +1 -1
  96. package/dist/data-plane/server/indexing/processor.d.ts +1 -1
  97. package/dist/data-plane/server/indexing/processor.d.ts.map +1 -1
  98. package/dist/data-plane/server/indexing/processor.js.map +1 -1
  99. package/dist/data-plane/server/routes/notifs.d.ts.map +1 -1
  100. package/dist/data-plane/server/routes/notifs.js +1 -8
  101. package/dist/data-plane/server/routes/notifs.js.map +1 -1
  102. package/dist/data-plane/server/routes/search.js +3 -2
  103. package/dist/data-plane/server/routes/search.js.map +1 -1
  104. package/dist/data-plane/server/subscription.d.ts +13 -12
  105. package/dist/data-plane/server/subscription.d.ts.map +1 -1
  106. package/dist/data-plane/server/subscription.js +59 -26
  107. package/dist/data-plane/server/subscription.js.map +1 -1
  108. package/dist/feature-gates/index.d.ts +2 -1
  109. package/dist/feature-gates/index.d.ts.map +1 -1
  110. package/dist/feature-gates/index.js +9 -6
  111. package/dist/feature-gates/index.js.map +1 -1
  112. package/dist/feature-gates/metrics.d.ts +3 -3
  113. package/dist/feature-gates/metrics.d.ts.map +1 -1
  114. package/dist/feature-gates/metrics.js +8 -8
  115. package/dist/feature-gates/metrics.js.map +1 -1
  116. package/dist/index.d.ts +1 -0
  117. package/dist/index.d.ts.map +1 -1
  118. package/dist/index.js +16 -7
  119. package/dist/index.js.map +1 -1
  120. package/dist/lexicons/app/bsky/authFullApp.defs.d.ts.map +1 -1
  121. package/dist/lexicons/app/bsky/authFullApp.defs.js +1 -0
  122. package/dist/lexicons/app/bsky/authFullApp.defs.js.map +1 -1
  123. package/dist/lexicons/app/bsky/authViewAll.defs.d.ts.map +1 -1
  124. package/dist/lexicons/app/bsky/authViewAll.defs.js +1 -0
  125. package/dist/lexicons/app/bsky/authViewAll.defs.js.map +1 -1
  126. package/dist/lexicons/app/bsky/feed/searchPostsV2.d.ts +3 -0
  127. package/dist/lexicons/app/bsky/feed/searchPostsV2.d.ts.map +1 -0
  128. package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.d.ts +158 -0
  129. package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.d.ts.map +1 -0
  130. package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.js +73 -0
  131. package/dist/lexicons/app/bsky/feed/searchPostsV2.defs.js.map +1 -0
  132. package/dist/lexicons/app/bsky/feed/searchPostsV2.js +6 -0
  133. package/dist/lexicons/app/bsky/feed/searchPostsV2.js.map +1 -0
  134. package/dist/lexicons/app/bsky/feed.d.ts +1 -0
  135. package/dist/lexicons/app/bsky/feed.d.ts.map +1 -1
  136. package/dist/lexicons/app/bsky/feed.js +1 -0
  137. package/dist/lexicons/app/bsky/feed.js.map +1 -1
  138. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts +5 -0
  139. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts.map +1 -1
  140. package/dist/lexicons/app/bsky/notification/defs.defs.js +1 -0
  141. package/dist/lexicons/app/bsky/notification/defs.defs.js.map +1 -1
  142. package/dist/lexicons/chat/bsky/actor/declaration.defs.d.ts +1 -1
  143. package/dist/lexicons/chat/bsky/actor/declaration.defs.js.map +1 -1
  144. package/dist/lexicons/chat/bsky/actor/defs.defs.d.ts +4 -6
  145. package/dist/lexicons/chat/bsky/actor/defs.defs.d.ts.map +1 -1
  146. package/dist/lexicons/chat/bsky/actor/defs.defs.js +2 -3
  147. package/dist/lexicons/chat/bsky/actor/defs.defs.js.map +1 -1
  148. package/dist/lexicons/chat/bsky/convo/defs.defs.d.ts +64 -70
  149. package/dist/lexicons/chat/bsky/convo/defs.defs.d.ts.map +1 -1
  150. package/dist/lexicons/chat/bsky/convo/defs.defs.js +32 -35
  151. package/dist/lexicons/chat/bsky/convo/defs.defs.js.map +1 -1
  152. package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.d.ts +1 -1
  153. package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.d.ts.map +1 -1
  154. package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.js +1 -1
  155. package/dist/lexicons/chat/bsky/convo/getUnreadCounts.defs.js.map +1 -1
  156. package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.d.ts +1 -1
  157. package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.d.ts.map +1 -1
  158. package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.js +1 -1
  159. package/dist/lexicons/chat/bsky/convo/listConvoRequests.defs.js.map +1 -1
  160. package/dist/lexicons/chat/bsky/convo/lockConvo.defs.d.ts +1 -1
  161. package/dist/lexicons/chat/bsky/convo/lockConvo.defs.d.ts.map +1 -1
  162. package/dist/lexicons/chat/bsky/convo/lockConvo.defs.js +1 -1
  163. package/dist/lexicons/chat/bsky/convo/lockConvo.defs.js.map +1 -1
  164. package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.d.ts +1 -1
  165. package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.d.ts.map +1 -1
  166. package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.js +1 -1
  167. package/dist/lexicons/chat/bsky/convo/unlockConvo.defs.js.map +1 -1
  168. package/dist/lexicons/chat/bsky/group/addMembers.defs.d.ts +1 -1
  169. package/dist/lexicons/chat/bsky/group/addMembers.defs.d.ts.map +1 -1
  170. package/dist/lexicons/chat/bsky/group/addMembers.defs.js +1 -1
  171. package/dist/lexicons/chat/bsky/group/addMembers.defs.js.map +1 -1
  172. package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.d.ts +1 -1
  173. package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.d.ts.map +1 -1
  174. package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.js +1 -1
  175. package/dist/lexicons/chat/bsky/group/approveJoinRequest.defs.js.map +1 -1
  176. package/dist/lexicons/chat/bsky/group/createGroup.defs.d.ts +1 -1
  177. package/dist/lexicons/chat/bsky/group/createGroup.defs.d.ts.map +1 -1
  178. package/dist/lexicons/chat/bsky/group/createGroup.defs.js +1 -1
  179. package/dist/lexicons/chat/bsky/group/createGroup.defs.js.map +1 -1
  180. package/dist/lexicons/chat/bsky/group/createJoinLink.defs.d.ts +1 -1
  181. package/dist/lexicons/chat/bsky/group/createJoinLink.defs.d.ts.map +1 -1
  182. package/dist/lexicons/chat/bsky/group/createJoinLink.defs.js +1 -1
  183. package/dist/lexicons/chat/bsky/group/createJoinLink.defs.js.map +1 -1
  184. package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.d.ts +1 -1
  185. package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.d.ts.map +1 -1
  186. package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.js +1 -1
  187. package/dist/lexicons/chat/bsky/group/disableJoinLink.defs.js.map +1 -1
  188. package/dist/lexicons/chat/bsky/group/editGroup.defs.d.ts +1 -1
  189. package/dist/lexicons/chat/bsky/group/editGroup.defs.d.ts.map +1 -1
  190. package/dist/lexicons/chat/bsky/group/editGroup.defs.js +1 -1
  191. package/dist/lexicons/chat/bsky/group/editGroup.defs.js.map +1 -1
  192. package/dist/lexicons/chat/bsky/group/editJoinLink.defs.d.ts +1 -1
  193. package/dist/lexicons/chat/bsky/group/editJoinLink.defs.d.ts.map +1 -1
  194. package/dist/lexicons/chat/bsky/group/editJoinLink.defs.js +1 -1
  195. package/dist/lexicons/chat/bsky/group/editJoinLink.defs.js.map +1 -1
  196. package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.d.ts +1 -1
  197. package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.d.ts.map +1 -1
  198. package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.js +1 -1
  199. package/dist/lexicons/chat/bsky/group/enableJoinLink.defs.js.map +1 -1
  200. package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.d.ts +1 -1
  201. package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.d.ts.map +1 -1
  202. package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.js +1 -1
  203. package/dist/lexicons/chat/bsky/group/getJoinLinkPreviews.defs.js.map +1 -1
  204. package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.d.ts +1 -1
  205. package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.d.ts.map +1 -1
  206. package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.js +1 -1
  207. package/dist/lexicons/chat/bsky/group/listJoinRequests.defs.js.map +1 -1
  208. package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.d.ts +1 -1
  209. package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.d.ts.map +1 -1
  210. package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.js +1 -1
  211. package/dist/lexicons/chat/bsky/group/listMutualGroups.defs.js.map +1 -1
  212. package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.d.ts +1 -1
  213. package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.d.ts.map +1 -1
  214. package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.js +1 -1
  215. package/dist/lexicons/chat/bsky/group/rejectJoinRequest.defs.js.map +1 -1
  216. package/dist/lexicons/chat/bsky/group/removeMembers.defs.d.ts +1 -1
  217. package/dist/lexicons/chat/bsky/group/removeMembers.defs.d.ts.map +1 -1
  218. package/dist/lexicons/chat/bsky/group/removeMembers.defs.js +1 -1
  219. package/dist/lexicons/chat/bsky/group/removeMembers.defs.js.map +1 -1
  220. package/dist/lexicons/chat/bsky/group/requestJoin.defs.d.ts +1 -1
  221. package/dist/lexicons/chat/bsky/group/requestJoin.defs.d.ts.map +1 -1
  222. package/dist/lexicons/chat/bsky/group/requestJoin.defs.js +1 -1
  223. package/dist/lexicons/chat/bsky/group/requestJoin.defs.js.map +1 -1
  224. package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.d.ts +1 -1
  225. package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.d.ts.map +1 -1
  226. package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.js +1 -1
  227. package/dist/lexicons/chat/bsky/group/updateJoinRequestsRead.defs.js.map +1 -1
  228. package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.d.ts +1 -1
  229. package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.d.ts.map +1 -1
  230. package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.js +1 -1
  231. package/dist/lexicons/chat/bsky/group/withdrawJoinRequest.defs.js.map +1 -1
  232. package/dist/lexicons/chat/bsky/moderation/defs.defs.d.ts +6 -6
  233. package/dist/lexicons/chat/bsky/moderation/defs.defs.d.ts.map +1 -1
  234. package/dist/lexicons/chat/bsky/moderation/defs.defs.js +3 -3
  235. package/dist/lexicons/chat/bsky/moderation/defs.defs.js.map +1 -1
  236. package/dist/lexicons/chat/bsky/moderation/getConvo.defs.d.ts +1 -1
  237. package/dist/lexicons/chat/bsky/moderation/getConvo.defs.d.ts.map +1 -1
  238. package/dist/lexicons/chat/bsky/moderation/getConvo.defs.js +1 -1
  239. package/dist/lexicons/chat/bsky/moderation/getConvo.defs.js.map +1 -1
  240. package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.d.ts +1 -1
  241. package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.d.ts.map +1 -1
  242. package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.js +1 -1
  243. package/dist/lexicons/chat/bsky/moderation/getConvoMembers.defs.js.map +1 -1
  244. package/dist/lexicons/chat/bsky/moderation/getConvos.defs.d.ts +1 -1
  245. package/dist/lexicons/chat/bsky/moderation/getConvos.defs.d.ts.map +1 -1
  246. package/dist/lexicons/chat/bsky/moderation/getConvos.defs.js +1 -1
  247. package/dist/lexicons/chat/bsky/moderation/getConvos.defs.js.map +1 -1
  248. package/dist/lexicons/chat/bsky/notification/defs.d.ts +2 -0
  249. package/dist/lexicons/chat/bsky/notification/defs.d.ts.map +1 -0
  250. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts +20 -0
  251. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts.map +1 -0
  252. package/dist/lexicons/chat/bsky/notification/defs.defs.js +19 -0
  253. package/dist/lexicons/chat/bsky/notification/defs.defs.js.map +1 -0
  254. package/dist/lexicons/chat/bsky/notification/defs.js +5 -0
  255. package/dist/lexicons/chat/bsky/notification/defs.js.map +1 -0
  256. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts +3 -0
  257. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts.map +1 -0
  258. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts +18 -0
  259. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts.map +1 -0
  260. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js +16 -0
  261. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js.map +1 -0
  262. package/dist/lexicons/chat/bsky/notification/getPreferences.js +6 -0
  263. package/dist/lexicons/chat/bsky/notification/getPreferences.js.map +1 -0
  264. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts +3 -0
  265. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts.map +1 -0
  266. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts +27 -0
  267. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts.map +1 -0
  268. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js +22 -0
  269. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js.map +1 -0
  270. package/dist/lexicons/chat/bsky/notification/putPreferences.js +6 -0
  271. package/dist/lexicons/chat/bsky/notification/putPreferences.js.map +1 -0
  272. package/dist/lexicons/chat/bsky/notification.d.ts +4 -0
  273. package/dist/lexicons/chat/bsky/notification.d.ts.map +1 -0
  274. package/dist/lexicons/chat/bsky/notification.js +7 -0
  275. package/dist/lexicons/chat/bsky/notification.js.map +1 -0
  276. package/dist/lexicons/chat/bsky.d.ts +1 -0
  277. package/dist/lexicons/chat/bsky.d.ts.map +1 -1
  278. package/dist/lexicons/chat/bsky.js +1 -0
  279. package/dist/lexicons/chat/bsky.js.map +1 -1
  280. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +4 -0
  281. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
  282. package/dist/lexicons/tools/ozone/report/defs.defs.js +2 -0
  283. package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
  284. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts +3 -0
  285. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts.map +1 -0
  286. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts +42 -0
  287. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts.map +1 -0
  288. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js +31 -0
  289. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js.map +1 -0
  290. package/dist/lexicons/tools/ozone/report/queryActivities.js +6 -0
  291. package/dist/lexicons/tools/ozone/report/queryActivities.js.map +1 -0
  292. package/dist/lexicons/tools/ozone/report.d.ts +1 -0
  293. package/dist/lexicons/tools/ozone/report.d.ts.map +1 -1
  294. package/dist/lexicons/tools/ozone/report.js +1 -0
  295. package/dist/lexicons/tools/ozone/report.js.map +1 -1
  296. package/dist/proto/bsky_pb.d.ts +51 -55
  297. package/dist/proto/bsky_pb.d.ts.map +1 -1
  298. package/dist/proto/bsky_pb.js +67 -74
  299. package/dist/proto/bsky_pb.js.map +1 -1
  300. package/package.json +9 -9
  301. package/proto/bsky.proto +21 -18
  302. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +5 -3
  303. package/src/api/app/bsky/feed/searchPostsV2.ts +232 -0
  304. package/src/api/app/bsky/notification/putPreferencesV2.ts +4 -1
  305. package/src/api/app/bsky/notification/util.ts +7 -11
  306. package/src/api/blob-dispatcher.ts +12 -8
  307. package/src/api/blob-resolver.ts +0 -1
  308. package/src/api/index.ts +2 -0
  309. package/src/data-plane/bsync/index.ts +12 -10
  310. package/src/data-plane/server/background.ts +49 -18
  311. package/src/data-plane/server/index.ts +12 -10
  312. package/src/data-plane/server/indexing/index.ts +1 -1
  313. package/src/data-plane/server/indexing/plugins/block.ts +4 -1
  314. package/src/data-plane/server/indexing/plugins/chat-declaration.ts +4 -1
  315. package/src/data-plane/server/indexing/plugins/feed-generator.ts +4 -1
  316. package/src/data-plane/server/indexing/plugins/follow.ts +4 -1
  317. package/src/data-plane/server/indexing/plugins/germ-declaration.ts +4 -1
  318. package/src/data-plane/server/indexing/plugins/labeler.ts +4 -1
  319. package/src/data-plane/server/indexing/plugins/like.ts +4 -1
  320. package/src/data-plane/server/indexing/plugins/list-block.ts +4 -1
  321. package/src/data-plane/server/indexing/plugins/list-item.ts +4 -1
  322. package/src/data-plane/server/indexing/plugins/list.ts +4 -1
  323. package/src/data-plane/server/indexing/plugins/notif-declaration.ts +4 -1
  324. package/src/data-plane/server/indexing/plugins/post-gate.ts +4 -1
  325. package/src/data-plane/server/indexing/plugins/post.ts +4 -1
  326. package/src/data-plane/server/indexing/plugins/profile.ts +4 -1
  327. package/src/data-plane/server/indexing/plugins/repost.ts +4 -1
  328. package/src/data-plane/server/indexing/plugins/starter-pack.ts +4 -1
  329. package/src/data-plane/server/indexing/plugins/status.ts +4 -1
  330. package/src/data-plane/server/indexing/plugins/thread-gate.ts +4 -1
  331. package/src/data-plane/server/indexing/plugins/verification.ts +4 -1
  332. package/src/data-plane/server/indexing/processor.ts +1 -1
  333. package/src/data-plane/server/routes/notifs.ts +0 -14
  334. package/src/data-plane/server/routes/search.ts +3 -2
  335. package/src/data-plane/server/subscription.ts +74 -31
  336. package/src/feature-gates/index.ts +10 -6
  337. package/src/feature-gates/metrics.test.ts +12 -12
  338. package/src/feature-gates/metrics.ts +8 -8
  339. package/src/index.ts +16 -9
  340. package/tests/_util.ts +8 -25
  341. package/tests/admin/admin-auth.test.ts +2 -2
  342. package/tests/admin/moderation.test.ts +1 -1
  343. package/tests/auth.test.ts +4 -6
  344. package/tests/blob-resolver.test.ts +4 -5
  345. package/tests/data-plane/db.test.ts +1 -1
  346. package/tests/data-plane/duplicate-records.test.ts +1 -1
  347. package/tests/data-plane/handle-invalidation.test.ts +2 -2
  348. package/tests/data-plane/indexing.test.ts +24 -21
  349. package/tests/data-plane/subscription.test.ts +1 -1
  350. package/tests/data-plane/thread-mutes.test.ts +2 -2
  351. package/tests/entryway-auth.test.ts +4 -5
  352. package/tests/feed-generation.test.ts +5 -5
  353. package/tests/image/server.test.ts +1 -1
  354. package/tests/label-hydration.test.ts +3 -5
  355. package/tests/postgates.test.ts +3 -6
  356. package/tests/query-labels.test.ts +3 -5
  357. package/tests/redis-cache.test.ts +1 -3
  358. package/tests/server.test.ts +11 -16
  359. package/tests/sitemap.test.ts +3 -4
  360. package/tests/stash.test.ts +12 -8
  361. package/tests/utils.test.ts +3 -13
  362. package/tests/views/account-deactivation.test.ts +3 -5
  363. package/tests/views/actor-likes.test.ts +3 -5
  364. package/tests/views/actor-search.test.ts +6 -7
  365. package/tests/views/age-assurance-v2.test.ts +9 -6
  366. package/tests/views/age-assurance.test.ts +30 -36
  367. package/tests/views/author-feed.test.ts +4 -6
  368. package/tests/views/block-lists.test.ts +3 -5
  369. package/tests/views/blocks.test.ts +3 -5
  370. package/tests/views/bookmarks.test.ts +4 -4
  371. package/tests/views/drafts.test.ts +7 -14
  372. package/tests/views/feed-hidden-replies.test.ts +3 -6
  373. package/tests/views/feed-view-post.test.ts +3 -6
  374. package/tests/views/follows.test.ts +4 -6
  375. package/tests/views/get-config.test.ts +4 -7
  376. package/tests/views/get-suggested-onboarding-users.test.ts +11 -9
  377. package/tests/views/get-suggested-starter-packs.test.ts +11 -9
  378. package/tests/views/get-trends.test.ts +15 -9
  379. package/tests/views/internal-actor.test.ts +3 -6
  380. package/tests/views/known-followers.test.ts +3 -6
  381. package/tests/views/labeler-service.test.ts +3 -5
  382. package/tests/views/labels-needs-review.test.ts +3 -6
  383. package/tests/views/labels-takedown.test.ts +3 -4
  384. package/tests/views/likes.test.ts +4 -6
  385. package/tests/views/list-feed.test.ts +3 -5
  386. package/tests/views/lists.test.ts +3 -5
  387. package/tests/views/mute-lists.test.ts +3 -5
  388. package/tests/views/mutes.test.ts +4 -5
  389. package/tests/views/notifications.test.ts +12 -11
  390. package/tests/views/post-search.test.ts +3 -24
  391. package/tests/views/posts-debug.test.ts +11 -6
  392. package/tests/views/posts.test.ts +3 -4
  393. package/tests/views/profile-debug.test.ts +11 -5
  394. package/tests/views/profile.test.ts +11 -5
  395. package/tests/views/quotes.test.ts +4 -6
  396. package/tests/views/reposts.test.ts +4 -6
  397. package/tests/views/starter-packs.test.ts +3 -6
  398. package/tests/views/suggestions.test.ts +9 -13
  399. package/tests/views/thread-v2.test.ts +3 -5
  400. package/tests/views/thread.test.ts +3 -7
  401. package/tests/views/threadgating.test.ts +3 -5
  402. package/tests/views/timeline.test.ts +4 -5
  403. package/tests/views/verification.test.ts +4 -6
  404. package/tsconfig.build.tsbuildinfo +1 -1
  405. package/vitest.config.ts +1 -0
@@ -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,
@@ -37,7 +37,7 @@ type Notif = Insertable<Notification>
37
37
  export class RecordProcessor<TSchema extends l.RecordSchema, TRow> {
38
38
  constructor(
39
39
  private appDb: Database,
40
- private background: BackgroundQueue,
40
+ private background: BackgroundQueue<Database>,
41
41
  private options: RecordProcessorOptions<TSchema, TRow>,
42
42
  ) {}
43
43
 
@@ -6,8 +6,6 @@ import { lexParse } from '@atproto/lex'
6
6
  import { app } from '../../../lexicons/index.js'
7
7
  import { Service } from '../../../proto/bsky_connect.js'
8
8
  import {
9
- ChatNotificationInclude,
10
- ChatNotificationPreference,
11
9
  FilterableNotificationPreference,
12
10
  NotificationInclude,
13
11
  NotificationPreference,
@@ -203,17 +201,6 @@ export const notificationPreferencesLexToProtobuf = (
203
201
  p: app.bsky.notification.defs.Preferences,
204
202
  json: string,
205
203
  ): NotificationPreferences => {
206
- const lexChatPreferenceToProtobuf = (
207
- p: app.bsky.notification.defs.ChatPreference,
208
- ): ChatNotificationPreference =>
209
- new ChatNotificationPreference({
210
- include:
211
- p.include === 'accepted'
212
- ? ChatNotificationInclude.ACCEPTED
213
- : ChatNotificationInclude.ALL,
214
- push: { enabled: p.push ?? true },
215
- })
216
-
217
204
  const lexFilterablePreferenceToProtobuf = (
218
205
  p: app.bsky.notification.defs.FilterablePreference,
219
206
  ): FilterableNotificationPreference =>
@@ -236,7 +223,6 @@ export const notificationPreferencesLexToProtobuf = (
236
223
 
237
224
  return new NotificationPreferences({
238
225
  entry: Buffer.from(json),
239
- chat: lexChatPreferenceToProtobuf(p.chat),
240
226
  follow: lexFilterablePreferenceToProtobuf(p.follow),
241
227
  like: lexFilterablePreferenceToProtobuf(p.like),
242
228
  likeViaRepost: lexFilterablePreferenceToProtobuf(p.likeViaRepost),
@@ -139,8 +139,8 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => {
139
139
 
140
140
  async searchActorsTypeahead(req) {
141
141
  const { dids } = await searchActorsImpl({
142
- term: req.query,
143
- limit: req.limit || 10,
142
+ term: req.params?.query ?? '',
143
+ limit: req.params?.limit || 10,
144
144
  })
145
145
  return {
146
146
  actors: dids.map((did) => ({ did, score: 0 })),
@@ -159,6 +159,7 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => {
159
159
  return {
160
160
  posts: uris.map((uri) => ({ uri, score: 0 })),
161
161
  pageInfo: { cursor: cursor ?? '', hitsTotal: 0n },
162
+ detectedQueryLanguages: [],
162
163
  }
163
164
  },
164
165
 
@@ -7,52 +7,95 @@ import { Database } from './db/index.js'
7
7
  import { IndexingService } from './indexing/index.js'
8
8
 
9
9
  export class RepoSubscription {
10
- firehose: Firehose
11
- runner: MemoryRunner
12
- background: BackgroundQueue
13
- indexingSvc: IndexingService
10
+ private readonly abortController = new AbortController()
11
+ private current?: ReturnType<typeof createFirehose>
12
+ readonly background: BackgroundQueue<Database>
13
+ readonly indexingSvc: IndexingService
14
+ private readonly service: string
15
+ private readonly idResolver: IdResolver
14
16
 
15
- constructor(
16
- public opts: { service: string; db: Database; idResolver: IdResolver },
17
- ) {
18
- const { service, db, idResolver } = opts
19
- this.background = new BackgroundQueue(db)
17
+ constructor({
18
+ service,
19
+ db,
20
+ idResolver,
21
+ }: {
22
+ service: string
23
+ db: Database
24
+ idResolver: IdResolver
25
+ }) {
26
+ this.service = service
27
+ this.idResolver = idResolver
28
+ this.background = new BackgroundQueue(db, {
29
+ // @TODO This has historically been using the default concurrency
30
+ // (Infinity) but we may want to limit this in the future to avoid
31
+ // overloading the database with indexing tasks.
32
+ concurrency: Number.POSITIVE_INFINITY,
33
+ })
20
34
  this.indexingSvc = new IndexingService(db, idResolver, this.background)
35
+ }
21
36
 
22
- const { runner, firehose } = createFirehose({
23
- idResolver,
24
- service,
25
- indexingSvc: this.indexingSvc,
26
- })
27
- this.runner = runner
28
- this.firehose = firehose
37
+ get destroyed() {
38
+ return this.abortController.signal.aborted
29
39
  }
30
40
 
31
- start() {
32
- this.firehose.start()
41
+ get running() {
42
+ return this.current != null
43
+ }
44
+
45
+ getCursor() {
46
+ return this.current?.runner.getCursor()
47
+ }
48
+
49
+ async start() {
50
+ this.abortController.signal.throwIfAborted()
51
+
52
+ if (!this.current) {
53
+ this.current = createFirehose({
54
+ idResolver: this.idResolver,
55
+ service: this.service,
56
+ indexingSvc: this.indexingSvc,
57
+ })
58
+ void this.current.firehose.start()
59
+ }
60
+ }
61
+
62
+ async stop() {
63
+ try {
64
+ if (this.current) {
65
+ const { firehose, runner } = this.current
66
+ this.current = undefined
67
+ try {
68
+ await firehose.destroy()
69
+ } finally {
70
+ await runner.destroy()
71
+ }
72
+ }
73
+ } finally {
74
+ await this.background.processAll()
75
+ }
33
76
  }
34
77
 
35
78
  async restart() {
36
- await this.destroy()
37
- const { runner, firehose } = createFirehose({
38
- idResolver: this.opts.idResolver,
39
- service: this.opts.service,
40
- indexingSvc: this.indexingSvc,
41
- })
42
- this.runner = runner
43
- this.firehose = firehose
44
- this.start()
79
+ await this.stop()
80
+ void this.start()
45
81
  }
46
82
 
47
83
  async processAll() {
48
- await this.runner.processAll()
84
+ await this.current?.runner.processAll()
49
85
  await this.background.processAll()
50
86
  }
51
87
 
52
88
  async destroy() {
53
- await this.firehose.destroy()
54
- await this.runner.destroy()
55
- await this.background.processAll()
89
+ this.abortController.abort()
90
+ try {
91
+ await this.stop()
92
+ } finally {
93
+ await this.background.destroy()
94
+ }
95
+ }
96
+
97
+ async [Symbol.asyncDispose]() {
98
+ await this.destroy()
56
99
  }
57
100
  }
58
101
 
@@ -72,10 +72,10 @@ export class FeatureGatesClient {
72
72
  this.client = new GrowthBookClient({
73
73
  apiHost: this.config.growthBookApiHost,
74
74
  clientKey: this.config.growthBookClientKey,
75
- onFeatureUsage: (feature, result, userContext) => {
75
+ onFeatureUsage: async (feature, result, userContext) => {
76
76
  if (IGNORE_METRICS_FOR_GATES.has(feature as Gate)) return
77
77
 
78
- this.metrics.track(
78
+ await this.metrics.track(
79
79
  'feature:viewed',
80
80
  {
81
81
  featureId: feature,
@@ -88,7 +88,7 @@ export class FeatureGatesClient {
88
88
  ),
89
89
  )
90
90
  },
91
- trackingCallback: (experiment, result, userContext) => {
91
+ trackingCallback: async (experiment, result, userContext) => {
92
92
  /**
93
93
  * Experiments are only fired in a feature gate has an Experiment
94
94
  * attached in Growthbook. Howerver, we want to be extra sure that a
@@ -101,7 +101,7 @@ export class FeatureGatesClient {
101
101
  )
102
102
  return
103
103
 
104
- this.metrics.track(
104
+ await this.metrics.track(
105
105
  'experiment:viewed',
106
106
  {
107
107
  experimentId: experiment.key,
@@ -154,14 +154,18 @@ export class FeatureGatesClient {
154
154
  }
155
155
  }
156
156
 
157
- destroy() {
157
+ async destroy() {
158
158
  if (this.ready) {
159
159
  this.ready = false
160
160
  if (this.refreshInterval) {
161
161
  clearInterval(this.refreshInterval)
162
162
  }
163
163
  }
164
- this.metrics.stop()
164
+ await this.metrics.stop()
165
+ }
166
+
167
+ async [Symbol.asyncDispose]() {
168
+ await this.destroy()
165
169
  }
166
170
 
167
171
  /**
@@ -32,8 +32,8 @@ describe('MetricsClient', () => {
32
32
  global.fetch = fetchMock
33
33
  })
34
34
 
35
- afterEach(() => {
36
- client?.stop()
35
+ afterEach(async () => {
36
+ await client?.stop()
37
37
  vi.useRealTimers()
38
38
  vi.clearAllMocks()
39
39
  })
@@ -42,8 +42,8 @@ describe('MetricsClient', () => {
42
42
  client = new MetricsClient<TestEvents>({
43
43
  trackingEndpoint: 'https://test.metrics.api',
44
44
  })
45
- client.track('click', { button: 'submit' })
46
- client.track('view', { screen: 'home' })
45
+ await client.track('click', { button: 'submit' })
46
+ await client.track('view', { screen: 'home' })
47
47
 
48
48
  expect(fetchRequests).toHaveLength(0)
49
49
 
@@ -65,13 +65,13 @@ describe('MetricsClient', () => {
65
65
 
66
66
  // Add events up to maxBatchSize (should not flush yet)
67
67
  for (let i = 0; i < 5; i++) {
68
- client.track('click', { button: `btn-${i}` })
68
+ await client.track('click', { button: `btn-${i}` })
69
69
  }
70
70
 
71
71
  expect(fetchRequests).toHaveLength(0)
72
72
 
73
73
  // One more event should trigger flush (> maxBatchSize)
74
- client.track('click', { button: 'btn-trigger' })
74
+ await client.track('click', { button: 'btn-trigger' })
75
75
  await flushPromises()
76
76
 
77
77
  expect(fetchRequests).toHaveLength(1)
@@ -90,7 +90,7 @@ describe('MetricsClient', () => {
90
90
  client = new MetricsClient<TestEvents>({
91
91
  trackingEndpoint: 'https://test.metrics.api',
92
92
  })
93
- client.track('click', { button: 'submit' })
93
+ await client.track('click', { button: 'submit' })
94
94
 
95
95
  // Trigger flush via interval
96
96
  vi.advanceTimersByTime(10_000)
@@ -119,7 +119,7 @@ describe('MetricsClient', () => {
119
119
  client = new MetricsClient<TestEvents>({
120
120
  trackingEndpoint: 'https://test.metrics.api',
121
121
  })
122
- client.track('click', { button: 'submit' })
122
+ await client.track('click', { button: 'submit' })
123
123
 
124
124
  // Trigger flush - should not throw
125
125
  vi.advanceTimersByTime(10_000)
@@ -140,12 +140,12 @@ describe('MetricsClient', () => {
140
140
  client = new MetricsClient<TestEvents>({
141
141
  trackingEndpoint: 'https://test.metrics.api',
142
142
  })
143
- client.track('click', { button: 'submit' })
143
+ await client.track('click', { button: 'submit' })
144
144
 
145
145
  expect(fetchRequests).toHaveLength(0)
146
146
 
147
147
  // Stop should flush remaining events
148
- client.stop()
148
+ await client.stop()
149
149
  await flushPromises()
150
150
 
151
151
  expect(fetchRequests).toHaveLength(1)
@@ -155,7 +155,7 @@ describe('MetricsClient', () => {
155
155
 
156
156
  it('does not send if trackingEndpoint is not configured', async () => {
157
157
  client = new MetricsClient<TestEvents>({})
158
- client.track('click', { button: 'submit' })
158
+ await client.track('click', { button: 'submit' })
159
159
 
160
160
  // Trigger flush via interval
161
161
  vi.advanceTimersByTime(10_000)
@@ -170,7 +170,7 @@ describe('MetricsClient', () => {
170
170
  })
171
171
 
172
172
  // track() calls start() internally
173
- client.track('click', { button: 'submit' })
173
+ await client.track('click', { button: 'submit' })
174
174
  client.start()
175
175
  client.start()
176
176
 
@@ -38,24 +38,24 @@ export class MetricsClient<M extends Record<string, any> = Events> {
38
38
  if (this.started) return
39
39
  this.started = true
40
40
  this.flushInterval = setInterval(() => {
41
- this.flush()
41
+ void this.flush()
42
42
  }, 10_000)
43
43
  }
44
44
 
45
- stop() {
45
+ async stop() {
46
46
  if (this.flushInterval) {
47
47
  clearInterval(this.flushInterval)
48
48
  this.flushInterval = null
49
49
  }
50
- this.flush()
50
+ await this.flush()
51
51
  }
52
52
 
53
- track<E extends keyof M>(
53
+ async track<E extends keyof M>(
54
54
  event: E,
55
55
  payload: M[E],
56
56
  metadata: Record<string, any> = {},
57
57
  ) {
58
- this.start()
58
+ await this.start()
59
59
 
60
60
  const e = {
61
61
  source: 'appview',
@@ -67,14 +67,14 @@ export class MetricsClient<M extends Record<string, any> = Events> {
67
67
  this.queue.push(e)
68
68
 
69
69
  if (this.queue.length > this.maxBatchSize) {
70
- this.flush()
70
+ await this.flush()
71
71
  }
72
72
  }
73
73
 
74
- flush() {
74
+ async flush() {
75
75
  if (!this.queue.length) return
76
76
  const events = this.queue.splice(0, this.queue.length)
77
- this.sendBatch(events)
77
+ await this.sendBatch(events)
78
78
  }
79
79
 
80
80
  private async sendBatch(events: Event<M>[]) {
package/src/index.ts CHANGED
@@ -5,11 +5,8 @@ import compression from 'compression'
5
5
  import cors from 'cors'
6
6
  import { Etcd3 } from 'etcd3'
7
7
  import express from 'express'
8
- // eslint-disable-next-line import/default, import/no-named-as-default-member
8
+ // eslint-disable-next-line import/default
9
9
  import httpTerminator from 'http-terminator'
10
- // eslint-disable-next-line import/no-named-as-default-member
11
- const { createHttpTerminator } = httpTerminator
12
- type HttpTerminator = ReturnType<typeof createHttpTerminator>
13
10
  import { DAY, SECOND } from '@atproto/common'
14
11
  import { Keypair } from '@atproto/crypto'
15
12
  import { IdResolver } from '@atproto/identity'
@@ -63,7 +60,7 @@ export class BskyAppView {
63
60
  public ctx: AppContext
64
61
  public app: express.Application
65
62
  public server?: http.Server
66
- private terminator?: HttpTerminator
63
+ private terminator?: httpTerminator.HttpTerminator
67
64
 
68
65
  constructor(opts: { ctx: AppContext; app: express.Application }) {
69
66
  this.ctx = opts.ctx
@@ -288,7 +285,7 @@ export class BskyAppView {
288
285
  const server = this.app.listen(this.ctx.cfg.port)
289
286
  this.server = server
290
287
  server.keepAliveTimeout = 90000
291
- this.terminator = createHttpTerminator({ server })
288
+ this.terminator = httpTerminator.createHttpTerminator({ server })
292
289
  await events.once(server, 'listening')
293
290
  const { port } = server.address() as AddressInfo
294
291
  this.ctx.cfg.assignPort(port)
@@ -296,9 +293,19 @@ export class BskyAppView {
296
293
  }
297
294
 
298
295
  async destroy(): Promise<void> {
299
- this.ctx.featureGatesClient.destroy()
300
- await this.terminator?.terminate()
301
- await this.ctx.etcd?.close()
296
+ try {
297
+ await this.ctx.featureGatesClient.destroy()
298
+ } finally {
299
+ try {
300
+ await this.terminator?.terminate()
301
+ } finally {
302
+ await this.ctx.etcd?.close()
303
+ }
304
+ }
305
+ }
306
+
307
+ async [Symbol.asyncDispose]() {
308
+ await this.destroy()
302
309
  }
303
310
  }
304
311