@atproto/bsky 0.0.242 → 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 (344) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/api/app/bsky/actor/searchActors.d.ts.map +1 -1
  3. package/dist/api/app/bsky/actor/searchActors.js +7 -3
  4. package/dist/api/app/bsky/actor/searchActors.js.map +1 -1
  5. package/dist/api/app/bsky/actor/searchActorsTypeahead.d.ts.map +1 -1
  6. package/dist/api/app/bsky/actor/searchActorsTypeahead.js +12 -6
  7. package/dist/api/app/bsky/actor/searchActorsTypeahead.js.map +1 -1
  8. package/dist/api/app/bsky/feed/searchPosts.d.ts.map +1 -1
  9. package/dist/api/app/bsky/feed/searchPosts.js +8 -3
  10. package/dist/api/app/bsky/feed/searchPosts.js.map +1 -1
  11. package/dist/api/app/bsky/graph/searchStarterPacks.d.ts.map +1 -1
  12. package/dist/api/app/bsky/graph/searchStarterPacks.js +7 -3
  13. package/dist/api/app/bsky/graph/searchStarterPacks.js.map +1 -1
  14. package/dist/api/app/bsky/notification/putPreferencesV2.js +4 -1
  15. package/dist/api/app/bsky/notification/putPreferencesV2.js.map +1 -1
  16. package/dist/api/app/bsky/notification/util.d.ts +1 -0
  17. package/dist/api/app/bsky/notification/util.d.ts.map +1 -1
  18. package/dist/api/app/bsky/notification/util.js +7 -7
  19. package/dist/api/app/bsky/notification/util.js.map +1 -1
  20. package/dist/api/app/bsky/unspecced/getPopularFeedGenerators.d.ts.map +1 -1
  21. package/dist/api/app/bsky/unspecced/getPopularFeedGenerators.js +3 -2
  22. package/dist/api/app/bsky/unspecced/getPopularFeedGenerators.js.map +1 -1
  23. package/dist/api/blob-dispatcher.d.ts.map +1 -1
  24. package/dist/api/blob-dispatcher.js +9 -8
  25. package/dist/api/blob-dispatcher.js.map +1 -1
  26. package/dist/api/blob-resolver.d.ts +1 -1
  27. package/dist/api/blob-resolver.d.ts.map +1 -1
  28. package/dist/api/blob-resolver.js +0 -1
  29. package/dist/api/blob-resolver.js.map +1 -1
  30. package/dist/api/util.d.ts +5 -0
  31. package/dist/api/util.d.ts.map +1 -1
  32. package/dist/api/util.js +11 -0
  33. package/dist/api/util.js.map +1 -1
  34. package/dist/config.d.ts +2 -0
  35. package/dist/config.d.ts.map +1 -1
  36. package/dist/config.js +5 -0
  37. package/dist/config.js.map +1 -1
  38. package/dist/data-plane/bsync/index.d.ts +2 -0
  39. package/dist/data-plane/bsync/index.d.ts.map +1 -1
  40. package/dist/data-plane/bsync/index.js +7 -10
  41. package/dist/data-plane/bsync/index.js.map +1 -1
  42. package/dist/data-plane/server/background.d.ts +12 -8
  43. package/dist/data-plane/server/background.d.ts.map +1 -1
  44. package/dist/data-plane/server/background.js +32 -14
  45. package/dist/data-plane/server/background.js.map +1 -1
  46. package/dist/data-plane/server/db/db.d.ts +4 -5
  47. package/dist/data-plane/server/db/db.d.ts.map +1 -1
  48. package/dist/data-plane/server/db/db.js +2 -1
  49. package/dist/data-plane/server/db/db.js.map +1 -1
  50. package/dist/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.d.ts.map +1 -1
  51. package/dist/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.js +2 -4
  52. package/dist/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.js.map +1 -1
  53. package/dist/data-plane/server/db/migrations/provider.d.ts +2 -1
  54. package/dist/data-plane/server/db/migrations/provider.d.ts.map +1 -1
  55. package/dist/data-plane/server/db/migrations/provider.js.map +1 -1
  56. package/dist/data-plane/server/db/pagination.d.ts +3 -2
  57. package/dist/data-plane/server/db/pagination.d.ts.map +1 -1
  58. package/dist/data-plane/server/db/pagination.js +8 -8
  59. package/dist/data-plane/server/db/pagination.js.map +1 -1
  60. package/dist/data-plane/server/db/util.d.ts +5 -5
  61. package/dist/data-plane/server/db/util.d.ts.map +1 -1
  62. package/dist/data-plane/server/db/util.js.map +1 -1
  63. package/dist/data-plane/server/index.d.ts +2 -0
  64. package/dist/data-plane/server/index.d.ts.map +1 -1
  65. package/dist/data-plane/server/index.js +7 -10
  66. package/dist/data-plane/server/index.js.map +1 -1
  67. package/dist/data-plane/server/indexing/index.d.ts +2 -2
  68. package/dist/data-plane/server/indexing/index.d.ts.map +1 -1
  69. package/dist/data-plane/server/indexing/index.js.map +1 -1
  70. package/dist/data-plane/server/indexing/plugins/block.d.ts +9 -4
  71. package/dist/data-plane/server/indexing/plugins/block.d.ts.map +1 -1
  72. package/dist/data-plane/server/indexing/plugins/block.js.map +1 -1
  73. package/dist/data-plane/server/indexing/plugins/chat-declaration.d.ts +1 -1
  74. package/dist/data-plane/server/indexing/plugins/chat-declaration.d.ts.map +1 -1
  75. package/dist/data-plane/server/indexing/plugins/chat-declaration.js.map +1 -1
  76. package/dist/data-plane/server/indexing/plugins/feed-generator.d.ts +13 -4
  77. package/dist/data-plane/server/indexing/plugins/feed-generator.d.ts.map +1 -1
  78. package/dist/data-plane/server/indexing/plugins/feed-generator.js.map +1 -1
  79. package/dist/data-plane/server/indexing/plugins/follow.d.ts +9 -4
  80. package/dist/data-plane/server/indexing/plugins/follow.d.ts.map +1 -1
  81. package/dist/data-plane/server/indexing/plugins/follow.js.map +1 -1
  82. package/dist/data-plane/server/indexing/plugins/germ-declaration.d.ts +1 -1
  83. package/dist/data-plane/server/indexing/plugins/germ-declaration.d.ts.map +1 -1
  84. package/dist/data-plane/server/indexing/plugins/germ-declaration.js.map +1 -1
  85. package/dist/data-plane/server/indexing/plugins/labeler.d.ts +8 -4
  86. package/dist/data-plane/server/indexing/plugins/labeler.d.ts.map +1 -1
  87. package/dist/data-plane/server/indexing/plugins/labeler.js.map +1 -1
  88. package/dist/data-plane/server/indexing/plugins/like.d.ts +12 -4
  89. package/dist/data-plane/server/indexing/plugins/like.d.ts.map +1 -1
  90. package/dist/data-plane/server/indexing/plugins/like.js.map +1 -1
  91. package/dist/data-plane/server/indexing/plugins/list-block.d.ts +9 -4
  92. package/dist/data-plane/server/indexing/plugins/list-block.d.ts.map +1 -1
  93. package/dist/data-plane/server/indexing/plugins/list-block.js.map +1 -1
  94. package/dist/data-plane/server/indexing/plugins/list-item.d.ts +10 -4
  95. package/dist/data-plane/server/indexing/plugins/list-item.d.ts.map +1 -1
  96. package/dist/data-plane/server/indexing/plugins/list-item.js.map +1 -1
  97. package/dist/data-plane/server/indexing/plugins/list.d.ts +13 -4
  98. package/dist/data-plane/server/indexing/plugins/list.d.ts.map +1 -1
  99. package/dist/data-plane/server/indexing/plugins/list.js.map +1 -1
  100. package/dist/data-plane/server/indexing/plugins/notif-declaration.d.ts +1 -1
  101. package/dist/data-plane/server/indexing/plugins/notif-declaration.d.ts.map +1 -1
  102. package/dist/data-plane/server/indexing/plugins/notif-declaration.js.map +1 -1
  103. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts +1 -1
  104. package/dist/data-plane/server/indexing/plugins/post-gate.d.ts.map +1 -1
  105. package/dist/data-plane/server/indexing/plugins/post-gate.js.map +1 -1
  106. package/dist/data-plane/server/indexing/plugins/post.d.ts +1 -1
  107. package/dist/data-plane/server/indexing/plugins/post.d.ts.map +1 -1
  108. package/dist/data-plane/server/indexing/plugins/post.js +4 -3
  109. package/dist/data-plane/server/indexing/plugins/post.js.map +1 -1
  110. package/dist/data-plane/server/indexing/plugins/profile.d.ts +1 -1
  111. package/dist/data-plane/server/indexing/plugins/profile.d.ts.map +1 -1
  112. package/dist/data-plane/server/indexing/plugins/profile.js.map +1 -1
  113. package/dist/data-plane/server/indexing/plugins/repost.d.ts +12 -4
  114. package/dist/data-plane/server/indexing/plugins/repost.d.ts.map +1 -1
  115. package/dist/data-plane/server/indexing/plugins/repost.js.map +1 -1
  116. package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts +9 -4
  117. package/dist/data-plane/server/indexing/plugins/starter-pack.d.ts.map +1 -1
  118. package/dist/data-plane/server/indexing/plugins/starter-pack.js.map +1 -1
  119. package/dist/data-plane/server/indexing/plugins/status.d.ts +1 -1
  120. package/dist/data-plane/server/indexing/plugins/status.d.ts.map +1 -1
  121. package/dist/data-plane/server/indexing/plugins/status.js.map +1 -1
  122. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts +1 -1
  123. package/dist/data-plane/server/indexing/plugins/thread-gate.d.ts.map +1 -1
  124. package/dist/data-plane/server/indexing/plugins/thread-gate.js.map +1 -1
  125. package/dist/data-plane/server/indexing/plugins/verification.d.ts +12 -4
  126. package/dist/data-plane/server/indexing/plugins/verification.d.ts.map +1 -1
  127. package/dist/data-plane/server/indexing/plugins/verification.js.map +1 -1
  128. package/dist/data-plane/server/indexing/processor.d.ts +1 -1
  129. package/dist/data-plane/server/indexing/processor.d.ts.map +1 -1
  130. package/dist/data-plane/server/indexing/processor.js.map +1 -1
  131. package/dist/data-plane/server/routes/blocks.js +22 -14
  132. package/dist/data-plane/server/routes/blocks.js.map +1 -1
  133. package/dist/data-plane/server/routes/feed-gens.js +2 -2
  134. package/dist/data-plane/server/routes/feed-gens.js.map +1 -1
  135. package/dist/data-plane/server/routes/feeds.js +18 -16
  136. package/dist/data-plane/server/routes/feeds.js.map +1 -1
  137. package/dist/data-plane/server/routes/labels.js +1 -1
  138. package/dist/data-plane/server/routes/labels.js.map +1 -1
  139. package/dist/data-plane/server/routes/mutes.js +2 -2
  140. package/dist/data-plane/server/routes/mutes.js.map +1 -1
  141. package/dist/data-plane/server/routes/notifs.d.ts.map +1 -1
  142. package/dist/data-plane/server/routes/notifs.js +11 -17
  143. package/dist/data-plane/server/routes/notifs.js.map +1 -1
  144. package/dist/data-plane/server/routes/relationships.js.map +1 -1
  145. package/dist/data-plane/server/routes/search.js +2 -2
  146. package/dist/data-plane/server/routes/search.js.map +1 -1
  147. package/dist/data-plane/server/routes/suggestions.js +2 -2
  148. package/dist/data-plane/server/routes/suggestions.js.map +1 -1
  149. package/dist/data-plane/server/subscription.d.ts +13 -12
  150. package/dist/data-plane/server/subscription.d.ts.map +1 -1
  151. package/dist/data-plane/server/subscription.js +59 -26
  152. package/dist/data-plane/server/subscription.js.map +1 -1
  153. package/dist/data-plane/server/util.d.ts +31 -23
  154. package/dist/data-plane/server/util.d.ts.map +1 -1
  155. package/dist/feature-gates/index.d.ts +2 -1
  156. package/dist/feature-gates/index.d.ts.map +1 -1
  157. package/dist/feature-gates/index.js +9 -6
  158. package/dist/feature-gates/index.js.map +1 -1
  159. package/dist/feature-gates/metrics.d.ts +3 -3
  160. package/dist/feature-gates/metrics.d.ts.map +1 -1
  161. package/dist/feature-gates/metrics.js +8 -8
  162. package/dist/feature-gates/metrics.js.map +1 -1
  163. package/dist/index.d.ts +1 -0
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +16 -7
  166. package/dist/index.js.map +1 -1
  167. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts +5 -0
  168. package/dist/lexicons/app/bsky/notification/defs.defs.d.ts.map +1 -1
  169. package/dist/lexicons/app/bsky/notification/defs.defs.js +1 -0
  170. package/dist/lexicons/app/bsky/notification/defs.defs.js.map +1 -1
  171. package/dist/lexicons/chat/bsky/notification/defs.d.ts +2 -0
  172. package/dist/lexicons/chat/bsky/notification/defs.d.ts.map +1 -0
  173. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts +20 -0
  174. package/dist/lexicons/chat/bsky/notification/defs.defs.d.ts.map +1 -0
  175. package/dist/lexicons/chat/bsky/notification/defs.defs.js +19 -0
  176. package/dist/lexicons/chat/bsky/notification/defs.defs.js.map +1 -0
  177. package/dist/lexicons/chat/bsky/notification/defs.js +5 -0
  178. package/dist/lexicons/chat/bsky/notification/defs.js.map +1 -0
  179. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts +3 -0
  180. package/dist/lexicons/chat/bsky/notification/getPreferences.d.ts.map +1 -0
  181. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts +18 -0
  182. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.d.ts.map +1 -0
  183. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js +16 -0
  184. package/dist/lexicons/chat/bsky/notification/getPreferences.defs.js.map +1 -0
  185. package/dist/lexicons/chat/bsky/notification/getPreferences.js +6 -0
  186. package/dist/lexicons/chat/bsky/notification/getPreferences.js.map +1 -0
  187. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts +3 -0
  188. package/dist/lexicons/chat/bsky/notification/putPreferences.d.ts.map +1 -0
  189. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts +27 -0
  190. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.d.ts.map +1 -0
  191. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js +22 -0
  192. package/dist/lexicons/chat/bsky/notification/putPreferences.defs.js.map +1 -0
  193. package/dist/lexicons/chat/bsky/notification/putPreferences.js +6 -0
  194. package/dist/lexicons/chat/bsky/notification/putPreferences.js.map +1 -0
  195. package/dist/lexicons/chat/bsky/notification.d.ts +4 -0
  196. package/dist/lexicons/chat/bsky/notification.d.ts.map +1 -0
  197. package/dist/lexicons/chat/bsky/notification.js +7 -0
  198. package/dist/lexicons/chat/bsky/notification.js.map +1 -0
  199. package/dist/lexicons/chat/bsky.d.ts +1 -0
  200. package/dist/lexicons/chat/bsky.d.ts.map +1 -1
  201. package/dist/lexicons/chat/bsky.js +1 -0
  202. package/dist/lexicons/chat/bsky.js.map +1 -1
  203. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +4 -0
  204. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
  205. package/dist/lexicons/tools/ozone/report/defs.defs.js +2 -0
  206. package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
  207. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts +3 -0
  208. package/dist/lexicons/tools/ozone/report/queryActivities.d.ts.map +1 -0
  209. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts +42 -0
  210. package/dist/lexicons/tools/ozone/report/queryActivities.defs.d.ts.map +1 -0
  211. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js +31 -0
  212. package/dist/lexicons/tools/ozone/report/queryActivities.defs.js.map +1 -0
  213. package/dist/lexicons/tools/ozone/report/queryActivities.js +6 -0
  214. package/dist/lexicons/tools/ozone/report/queryActivities.js.map +1 -0
  215. package/dist/lexicons/tools/ozone/report.d.ts +1 -0
  216. package/dist/lexicons/tools/ozone/report.d.ts.map +1 -1
  217. package/dist/lexicons/tools/ozone/report.js +1 -0
  218. package/dist/lexicons/tools/ozone/report.js.map +1 -1
  219. package/dist/proto/bsky_pb.d.ts +47 -53
  220. package/dist/proto/bsky_pb.d.ts.map +1 -1
  221. package/dist/proto/bsky_pb.js +62 -71
  222. package/dist/proto/bsky_pb.js.map +1 -1
  223. package/package.json +13 -13
  224. package/proto/bsky.proto +19 -17
  225. package/src/api/app/bsky/actor/searchActors.ts +17 -6
  226. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +16 -8
  227. package/src/api/app/bsky/feed/searchPosts.ts +12 -5
  228. package/src/api/app/bsky/graph/searchStarterPacks.ts +14 -5
  229. package/src/api/app/bsky/notification/putPreferencesV2.ts +4 -1
  230. package/src/api/app/bsky/notification/util.ts +7 -11
  231. package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +9 -2
  232. package/src/api/blob-dispatcher.ts +12 -8
  233. package/src/api/blob-resolver.ts +0 -1
  234. package/src/api/util.ts +17 -0
  235. package/src/config.ts +9 -0
  236. package/src/data-plane/bsync/index.ts +12 -10
  237. package/src/data-plane/server/background.ts +49 -18
  238. package/src/data-plane/server/db/db.ts +1 -1
  239. package/src/data-plane/server/db/migrations/20230627T212437895Z-optional-handle.ts +2 -4
  240. package/src/data-plane/server/db/migrations/provider.ts +2 -1
  241. package/src/data-plane/server/db/pagination.ts +15 -15
  242. package/src/data-plane/server/db/util.ts +8 -5
  243. package/src/data-plane/server/index.ts +12 -10
  244. package/src/data-plane/server/indexing/index.ts +1 -1
  245. package/src/data-plane/server/indexing/plugins/block.ts +4 -1
  246. package/src/data-plane/server/indexing/plugins/chat-declaration.ts +4 -1
  247. package/src/data-plane/server/indexing/plugins/feed-generator.ts +4 -1
  248. package/src/data-plane/server/indexing/plugins/follow.ts +4 -1
  249. package/src/data-plane/server/indexing/plugins/germ-declaration.ts +4 -1
  250. package/src/data-plane/server/indexing/plugins/labeler.ts +4 -1
  251. package/src/data-plane/server/indexing/plugins/like.ts +4 -1
  252. package/src/data-plane/server/indexing/plugins/list-block.ts +4 -1
  253. package/src/data-plane/server/indexing/plugins/list-item.ts +4 -1
  254. package/src/data-plane/server/indexing/plugins/list.ts +4 -1
  255. package/src/data-plane/server/indexing/plugins/notif-declaration.ts +4 -1
  256. package/src/data-plane/server/indexing/plugins/post-gate.ts +4 -1
  257. package/src/data-plane/server/indexing/plugins/post.ts +9 -5
  258. package/src/data-plane/server/indexing/plugins/profile.ts +4 -1
  259. package/src/data-plane/server/indexing/plugins/repost.ts +4 -1
  260. package/src/data-plane/server/indexing/plugins/starter-pack.ts +4 -1
  261. package/src/data-plane/server/indexing/plugins/status.ts +4 -1
  262. package/src/data-plane/server/indexing/plugins/thread-gate.ts +4 -1
  263. package/src/data-plane/server/indexing/plugins/verification.ts +4 -1
  264. package/src/data-plane/server/indexing/processor.ts +1 -1
  265. package/src/data-plane/server/routes/blocks.ts +30 -24
  266. package/src/data-plane/server/routes/feed-gens.ts +2 -2
  267. package/src/data-plane/server/routes/feeds.ts +23 -19
  268. package/src/data-plane/server/routes/labels.ts +2 -2
  269. package/src/data-plane/server/routes/mutes.ts +8 -6
  270. package/src/data-plane/server/routes/notifs.ts +15 -26
  271. package/src/data-plane/server/routes/relationships.ts +4 -2
  272. package/src/data-plane/server/routes/search.ts +2 -2
  273. package/src/data-plane/server/routes/suggestions.ts +2 -2
  274. package/src/data-plane/server/subscription.ts +74 -31
  275. package/src/feature-gates/index.ts +10 -6
  276. package/src/feature-gates/metrics.test.ts +12 -12
  277. package/src/feature-gates/metrics.ts +8 -8
  278. package/src/index.ts +16 -9
  279. package/tests/_util.ts +8 -25
  280. package/tests/admin/admin-auth.test.ts +2 -2
  281. package/tests/admin/moderation.test.ts +1 -1
  282. package/tests/auth.test.ts +4 -6
  283. package/tests/blob-resolver.test.ts +4 -5
  284. package/tests/data-plane/db.test.ts +1 -1
  285. package/tests/data-plane/duplicate-records.test.ts +1 -1
  286. package/tests/data-plane/handle-invalidation.test.ts +2 -2
  287. package/tests/data-plane/indexing.test.ts +24 -21
  288. package/tests/data-plane/subscription.test.ts +3 -3
  289. package/tests/data-plane/thread-mutes.test.ts +2 -2
  290. package/tests/entryway-auth.test.ts +4 -5
  291. package/tests/feed-generation.test.ts +5 -5
  292. package/tests/image/server.test.ts +1 -1
  293. package/tests/label-hydration.test.ts +3 -5
  294. package/tests/postgates.test.ts +3 -6
  295. package/tests/query-labels.test.ts +3 -5
  296. package/tests/redis-cache.test.ts +1 -3
  297. package/tests/server.test.ts +11 -16
  298. package/tests/sitemap.test.ts +3 -4
  299. package/tests/stash.test.ts +12 -8
  300. package/tests/utils.test.ts +3 -13
  301. package/tests/views/account-deactivation.test.ts +3 -5
  302. package/tests/views/actor-likes.test.ts +3 -5
  303. package/tests/views/actor-search.test.ts +6 -7
  304. package/tests/views/age-assurance-v2.test.ts +9 -6
  305. package/tests/views/age-assurance.test.ts +30 -36
  306. package/tests/views/author-feed.test.ts +4 -6
  307. package/tests/views/block-lists.test.ts +3 -5
  308. package/tests/views/blocks.test.ts +3 -5
  309. package/tests/views/bookmarks.test.ts +4 -4
  310. package/tests/views/drafts.test.ts +7 -14
  311. package/tests/views/feed-hidden-replies.test.ts +3 -6
  312. package/tests/views/feed-view-post.test.ts +3 -6
  313. package/tests/views/follows.test.ts +4 -6
  314. package/tests/views/get-config.test.ts +4 -7
  315. package/tests/views/get-suggested-onboarding-users.test.ts +11 -9
  316. package/tests/views/get-suggested-starter-packs.test.ts +11 -9
  317. package/tests/views/get-trends.test.ts +15 -9
  318. package/tests/views/internal-actor.test.ts +3 -6
  319. package/tests/views/known-followers.test.ts +3 -6
  320. package/tests/views/labeler-service.test.ts +3 -5
  321. package/tests/views/labels-needs-review.test.ts +3 -6
  322. package/tests/views/labels-takedown.test.ts +3 -4
  323. package/tests/views/likes.test.ts +4 -6
  324. package/tests/views/list-feed.test.ts +3 -5
  325. package/tests/views/lists.test.ts +3 -5
  326. package/tests/views/mute-lists.test.ts +3 -5
  327. package/tests/views/mutes.test.ts +4 -5
  328. package/tests/views/notifications.test.ts +12 -11
  329. package/tests/views/post-search.test.ts +3 -24
  330. package/tests/views/posts-debug.test.ts +11 -6
  331. package/tests/views/posts.test.ts +3 -4
  332. package/tests/views/profile-debug.test.ts +11 -5
  333. package/tests/views/profile.test.ts +11 -5
  334. package/tests/views/quotes.test.ts +4 -6
  335. package/tests/views/reposts.test.ts +4 -6
  336. package/tests/views/starter-packs.test.ts +3 -6
  337. package/tests/views/suggestions.test.ts +9 -13
  338. package/tests/views/thread-v2.test.ts +3 -5
  339. package/tests/views/thread.test.ts +3 -7
  340. package/tests/views/threadgating.test.ts +3 -5
  341. package/tests/views/timeline.test.ts +4 -5
  342. package/tests/views/verification.test.ts +4 -6
  343. package/tsconfig.build.tsbuildinfo +1 -1
  344. package/vitest.config.ts +1 -0
@@ -19,8 +19,8 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
19
19
  .selectFrom('label')
20
20
  .where('uri', 'in', subjects)
21
21
  .where('src', 'in', issuers)
22
- .where((qb) =>
23
- qb.where('exp', 'is', null).orWhere(sql`exp::timestamp > now()`),
22
+ .where((eb) =>
23
+ eb.or([eb('exp', 'is', null), sql<boolean>`exp::timestamp > now()`]),
24
24
  )
25
25
  .selectAll()
26
26
  .execute()
@@ -88,12 +88,14 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
88
88
  const { ref } = db.db.dynamic
89
89
  let builder = db.db
90
90
  .selectFrom('list')
91
- .whereExists(
92
- db.db
93
- .selectFrom('list_mute')
94
- .where('list_mute.mutedByDid', '=', actorDid)
95
- .whereRef('list_mute.listUri', '=', ref('list.uri'))
96
- .selectAll(),
91
+ .where(({ exists }) =>
92
+ exists(
93
+ db.db
94
+ .selectFrom('list_mute')
95
+ .where('list_mute.mutedByDid', '=', actorDid)
96
+ .whereRef('list_mute.listUri', '=', ref('list.uri'))
97
+ .selectAll(),
98
+ ),
97
99
  )
98
100
  .selectAll('list')
99
101
 
@@ -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,
@@ -32,17 +30,18 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
32
30
  let builder = db.db
33
31
  .selectFrom('notification as notif')
34
32
  .where('notif.did', '=', actorDid)
35
- .where((clause) =>
36
- clause
37
- .where('reasonSubject', 'is', null)
38
- .orWhereExists(
33
+ .where((eb) =>
34
+ eb.or([
35
+ eb('reasonSubject', 'is', null),
36
+ eb.exists(
39
37
  db.db
40
38
  .selectFrom('record as subject')
41
39
  .selectAll()
42
40
  .whereRef('subject.uri', '=', ref('notif.reasonSubject')),
43
41
  ),
42
+ ]),
44
43
  )
45
- .if(priority, (qb) => qb.whereExists(priorityFollowQb))
44
+ .$if(priority, (qb) => qb.where(({ exists }) => exists(priorityFollowQb)))
46
45
  .select([
47
46
  'notif.author as authorDid',
48
47
  'notif.recordUri as uri',
@@ -117,13 +116,15 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
117
116
  // Ensure to hit notification_did_sortat_idx, handling case where lastSeenNotifs is null.
118
117
  .where('notification.did', '=', actorDid)
119
118
  .where('notification.sortAt', '>', lastSeen ?? '')
120
- .if(priority, (qb) =>
121
- qb.whereExists(
122
- db.db
123
- .selectFrom('follow')
124
- .select(sql<boolean>`${true}`.as('val'))
125
- .where('creator', '=', actorDid)
126
- .whereRef('subjectDid', '=', ref('notification.author')),
119
+ .$if(priority, (qb) =>
120
+ qb.where(({ exists }) =>
121
+ exists(
122
+ db.db
123
+ .selectFrom('follow')
124
+ .select(sql<boolean>`${true}`.as('val'))
125
+ .where('creator', '=', actorDid)
126
+ .whereRef('subjectDid', '=', ref('notification.author')),
127
+ ),
127
128
  ),
128
129
  )
129
130
  .executeTakeFirst()
@@ -200,17 +201,6 @@ export const notificationPreferencesLexToProtobuf = (
200
201
  p: app.bsky.notification.defs.Preferences,
201
202
  json: string,
202
203
  ): NotificationPreferences => {
203
- const lexChatPreferenceToProtobuf = (
204
- p: app.bsky.notification.defs.ChatPreference,
205
- ): ChatNotificationPreference =>
206
- new ChatNotificationPreference({
207
- include:
208
- p.include === 'accepted'
209
- ? ChatNotificationInclude.ACCEPTED
210
- : ChatNotificationInclude.ALL,
211
- push: { enabled: p.push ?? true },
212
- })
213
-
214
204
  const lexFilterablePreferenceToProtobuf = (
215
205
  p: app.bsky.notification.defs.FilterablePreference,
216
206
  ): FilterableNotificationPreference =>
@@ -233,7 +223,6 @@ export const notificationPreferencesLexToProtobuf = (
233
223
 
234
224
  return new NotificationPreferences({
235
225
  entry: Buffer.from(json),
236
- chat: lexChatPreferenceToProtobuf(p.chat),
237
226
  follow: lexFilterablePreferenceToProtobuf(p.follow),
238
227
  like: lexFilterablePreferenceToProtobuf(p.like),
239
228
  likeViaRepost: lexFilterablePreferenceToProtobuf(p.likeViaRepost),
@@ -95,9 +95,11 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
95
95
  const { ref } = db.db.dynamic
96
96
  const sourceRef = ref('pair.source')
97
97
  const targetRef = ref('pair.target')
98
- const values = valuesList(pairs.map((p) => sql`${p.a}, ${p.b}`))
98
+ const values = valuesList<{ source: string; target: string }>(
99
+ pairs.map((p) => sql`${p.a}, ${p.b}`),
100
+ )
99
101
  const res = await db.db
100
- .selectFrom(values.as(sql`pair (source, target)`))
102
+ .selectFrom(values.as<'pair'>(sql`pair (source, target)`))
101
103
  .select([
102
104
  sql<string>`${sourceRef}`.as('source'),
103
105
  sql<string>`${targetRef}`.as('target'),
@@ -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 })),
@@ -41,7 +41,7 @@ const getFollowSuggestionsGlobal = async (
41
41
  const suggestions = await db.db
42
42
  .selectFrom('suggested_follow')
43
43
  .innerJoin('actor', 'actor.did', 'suggested_follow.did')
44
- .if(alreadyIncluded.length > 0, (qb) =>
44
+ .$if(alreadyIncluded.length > 0, (qb) =>
45
45
  qb.where('suggested_follow.order', 'not in', alreadyIncluded),
46
46
  )
47
47
  .selectAll()
@@ -116,7 +116,7 @@ const getFollowSuggestionsRelativeTo = async (
116
116
  .where('follow.creator', '=', input.actorDid)
117
117
  .where('follow.subjectDid', '!=', input.relativeToDid)
118
118
  .where('follow.subjectDid', 'not in', actorsViewerFollows)
119
- .if(resultDids.length > 0, (qb) =>
119
+ .$if(resultDids.length > 0, (qb) =>
120
120
  qb.where(
121
121
  'subjectDid',
122
122
  'not in',
@@ -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
 
package/tests/_util.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Server } from 'node:http'
1
+ import { RequestListener, createServer } from 'node:http'
2
2
  import { AddressInfo } from 'node:net'
3
- import { type Express } from 'express'
3
+ // eslint-disable-next-line import/default
4
+ import httpTerminator from 'http-terminator'
4
5
  import { expect } from 'vitest'
5
6
  import {
6
7
  $Typed,
@@ -265,19 +266,11 @@ export const stripViewerFromLabeler = (
265
266
  return stripViewer(labeler)
266
267
  }
267
268
 
268
- export async function startServer(app: Express) {
269
- return new Promise<{
270
- origin: string
271
- server: Server
272
- stop: () => Promise<void>
273
- }>((resolve, reject) => {
269
+ export async function startServer(listener: RequestListener) {
270
+ return new Promise<AsyncDisposable & { port: number }>((resolve, reject) => {
274
271
  const onListen = () => {
275
272
  const port = (server.address() as AddressInfo).port
276
- resolve({
277
- server,
278
- origin: `http://localhost:${port}`,
279
- stop: () => stopServer(server),
280
- })
273
+ resolve({ port, [Symbol.asyncDispose]: () => terminator.terminate() })
281
274
  cleanup()
282
275
  }
283
276
  const onError = (err: Error) => {
@@ -289,21 +282,11 @@ export async function startServer(app: Express) {
289
282
  server.removeListener('error', onError)
290
283
  }
291
284
 
292
- const server = app
285
+ const server = createServer(listener)
293
286
  .listen(0)
294
287
  .once('listening', onListen)
295
288
  .once('error', onError)
296
- })
297
- }
298
289
 
299
- export async function stopServer(server: Server) {
300
- return new Promise<void>((resolve, reject) => {
301
- server.close((err) => {
302
- if (err) {
303
- reject(err)
304
- } else {
305
- resolve()
306
- }
307
- })
290
+ const terminator = httpTerminator.createHttpTerminator({ server })
308
291
  })
309
292
  }
@@ -62,10 +62,10 @@ describe('admin auth', () => {
62
62
  $type: 'com.atproto.admin.defs#repoRef',
63
63
  did: sc.dids.bob,
64
64
  }
65
- }, 20_000) // @NOTE seeding can take a while
65
+ })
66
66
 
67
67
  afterAll(async () => {
68
- await network.close()
68
+ await network?.close()
69
69
  })
70
70
 
71
71
  it('allows service auth requests from the configured appview did', async () => {
@@ -46,7 +46,7 @@ describe('moderation', () => {
46
46
  })
47
47
 
48
48
  afterAll(async () => {
49
- await network.close()
49
+ await network?.close()
50
50
  })
51
51
 
52
52
  it('takes down accounts', async () => {
@@ -1,4 +1,4 @@
1
- import { afterAll, beforeAll, describe, expect, it } from 'vitest'
1
+ import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'
2
2
  import { AtpAgent, ids } from '@atproto/api'
3
3
  import { Keypair, Secp256k1Keypair } from '@atproto/crypto'
4
4
  import { SeedClient, TestNetwork, usersSeed } from '@atproto/dev-env'
@@ -20,15 +20,13 @@ describe('auth', () => {
20
20
  agent = network.bsky.getAgent()
21
21
  sc = network.getSeedClient()
22
22
  await usersSeed(sc)
23
- await network.processAll()
24
23
  alice = sc.dids.alice
25
24
  bob = sc.dids.bob
26
- }, 20_000) // @NOTE seeding can take a while
27
-
28
- afterAll(async () => {
29
- await network.close()
30
25
  })
31
26
 
27
+ beforeEach(async () => network.processAll())
28
+ afterAll(async () => network?.close())
29
+
32
30
  // @TODO invalidations do not originate from appview frontends: requires identity event on the repo stream.
33
31
  it.skip('handles signing key change for service auth.', async () => {
34
32
  const issuer = sc.dids.alice
@@ -1,5 +1,5 @@
1
1
  import { request } from 'undici'
2
- import { afterAll, beforeAll, describe, expect, it } from 'vitest'
2
+ import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest'
3
3
  import { cidForCbor, verifyCidForBytes } from '@atproto/common'
4
4
  import { randomBytes } from '@atproto/crypto'
5
5
  import { TestNetwork, basicSeed } from '@atproto/dev-env'
@@ -17,15 +17,14 @@ describe('blob resolver', () => {
17
17
  })
18
18
  const sc = network.getSeedClient()
19
19
  await basicSeed(sc)
20
- await network.processAll()
20
+
21
21
  fileDid = sc.dids.carol
22
22
  fileCid = sc.posts[fileDid][0].images[0].image.ref
23
23
  fileSize = sc.posts[fileDid][0].images[0].image.size
24
24
  })
25
25
 
26
- afterAll(async () => {
27
- await network.close()
28
- })
26
+ beforeEach(async () => network.processAll())
27
+ afterAll(async () => network?.close())
29
28
 
30
29
  it('resolves blob with good signature check.', async () => {
31
30
  const response = await request(
@@ -16,7 +16,7 @@ describe('db', () => {
16
16
  })
17
17
 
18
18
  afterAll(async () => {
19
- await network.close()
19
+ await network?.close()
20
20
  })
21
21
 
22
22
  it('handles client errors without crashing.', async () => {