@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
@@ -3,15 +3,13 @@ import { Kysely } from 'kysely'
3
3
  export async function up(db: Kysely<unknown>): Promise<void> {
4
4
  await db.schema
5
5
  .alterTable('actor')
6
- .alterColumn('handle')
7
- .dropNotNull()
6
+ .alterColumn('handle', (col) => col.dropNotNull())
8
7
  .execute()
9
8
  }
10
9
 
11
10
  export async function down(db: Kysely<unknown>): Promise<void> {
12
11
  await db.schema
13
12
  .alterTable('actor')
14
- .alterColumn('handle')
15
- .setNotNull()
13
+ .alterColumn('handle', (col) => col.setNotNull())
16
14
  .execute()
17
15
  }
@@ -1,4 +1,5 @@
1
- import { Kysely, Migration, MigrationProvider } from 'kysely'
1
+ import { Kysely } from 'kysely'
2
+ import { Migration, MigrationProvider } from 'kysely/migration'
2
3
 
3
4
  // Passes a context argument to migrations. We use this to thread the dialect into migrations
4
5
 
@@ -1,4 +1,4 @@
1
- import { sql } from 'kysely'
1
+ import { SqlBool, sql } from 'kysely'
2
2
  import { ensureValidRecordKey } from '@atproto/syntax'
3
3
  import { InvalidRequestError } from '@atproto/xrpc-server'
4
4
  import { AnyQb, DbRef } from './util.js'
@@ -67,16 +67,16 @@ export abstract class GenericKeyset<R, LR extends KeysetLabeledResult> {
67
67
  if (tryIndex) {
68
68
  // The tryIndex param will likely disappear and become the default implementation: here for now for gradual rollout query-by-query.
69
69
  if (direction === 'asc') {
70
- return sql`((${this.primary}, ${this.secondary}) > (${labeled.primary}, ${labeled.secondary}))`
70
+ return sql<SqlBool>`((${this.primary}, ${this.secondary}) > (${labeled.primary}, ${labeled.secondary}))`
71
71
  } else {
72
- return sql`((${this.primary}, ${this.secondary}) < (${labeled.primary}, ${labeled.secondary}))`
72
+ return sql<SqlBool>`((${this.primary}, ${this.secondary}) < (${labeled.primary}, ${labeled.secondary}))`
73
73
  }
74
74
  } else {
75
75
  // @NOTE this implementation can struggle to use an index on (primary, secondary) for pagination due to the "or" usage.
76
76
  if (direction === 'asc') {
77
- return sql`((${this.primary} > ${labeled.primary}) or (${this.primary} = ${labeled.primary} and ${this.secondary} > ${labeled.secondary}))`
77
+ return sql<SqlBool>`((${this.primary} > ${labeled.primary}) or (${this.primary} = ${labeled.primary} and ${this.secondary} > ${labeled.secondary}))`
78
78
  } else {
79
- return sql`((${this.primary} < ${labeled.primary}) or (${this.primary} = ${labeled.primary} and ${this.secondary} < ${labeled.secondary}))`
79
+ return sql<SqlBool>`((${this.primary} < ${labeled.primary}) or (${this.primary} = ${labeled.primary} and ${this.secondary} < ${labeled.secondary}))`
80
80
  }
81
81
  }
82
82
  }
@@ -94,11 +94,11 @@ export abstract class GenericKeyset<R, LR extends KeysetLabeledResult> {
94
94
  const { limit, cursor, direction = 'desc', tryIndex, nullsLast } = opts
95
95
  const keysetSql = this.getSql(this.unpack(cursor), direction, tryIndex)
96
96
  return qb
97
- .if(!!limit, (q) => q.limit(limit as number))
98
- .if(!nullsLast, (q) =>
97
+ .$if(!!limit, (q) => q.limit(limit as number))
98
+ .$if(!nullsLast, (q) =>
99
99
  q.orderBy(this.primary, direction).orderBy(this.secondary, direction),
100
100
  )
101
- .if(!!nullsLast, (q) =>
101
+ .$if(!!nullsLast, (q) =>
102
102
  q
103
103
  .orderBy(
104
104
  direction === 'asc'
@@ -111,7 +111,7 @@ export abstract class GenericKeyset<R, LR extends KeysetLabeledResult> {
111
111
  : sql`${this.secondary} desc nulls last`,
112
112
  ),
113
113
  )
114
- .if(!!keysetSql, (qb) => (keysetSql ? qb.where(keysetSql) : qb)) as QB
114
+ .$if(!!keysetSql, (qb) => (keysetSql ? qb.where(keysetSql) : qb)) as QB
115
115
  }
116
116
  }
117
117
 
@@ -231,9 +231,9 @@ export abstract class GenericSingleKey<R, LR extends SingleKeyLabeledResult> {
231
231
  getSql(labeled?: LR, direction?: 'asc' | 'desc') {
232
232
  if (labeled === undefined) return
233
233
  if (direction === 'asc') {
234
- return sql`${this.primary} > ${labeled.primary}`
234
+ return sql<SqlBool>`${this.primary} > ${labeled.primary}`
235
235
  }
236
- return sql`${this.primary} < ${labeled.primary}`
236
+ return sql<SqlBool>`${this.primary} < ${labeled.primary}`
237
237
  }
238
238
  paginate<QB extends AnyQb>(
239
239
  qb: QB,
@@ -248,16 +248,16 @@ export abstract class GenericSingleKey<R, LR extends SingleKeyLabeledResult> {
248
248
  const { limit, cursor, direction = 'desc', nullsLast } = opts
249
249
  const keySql = this.getSql(this.unpack(cursor), direction)
250
250
  return qb
251
- .if(!!limit, (q) => q.limit(limit as number))
252
- .if(!nullsLast, (q) => q.orderBy(this.primary, direction))
253
- .if(!!nullsLast, (q) =>
251
+ .$if(!!limit, (q) => q.limit(limit as number))
252
+ .$if(!nullsLast, (q) => q.orderBy(this.primary, direction))
253
+ .$if(!!nullsLast, (q) =>
254
254
  q.orderBy(
255
255
  direction === 'asc'
256
256
  ? sql`${this.primary} asc nulls last`
257
257
  : sql`${this.primary} desc nulls last`,
258
258
  ),
259
259
  )
260
- .if(!!keySql, (qb) => (keySql ? qb.where(keySql) : qb)) as QB
260
+ .$if(!!keySql, (qb) => (keySql ? qb.where(keySql) : qb)) as QB
261
261
  }
262
262
  }
263
263
 
@@ -4,6 +4,7 @@ import {
4
4
  ExpressionBuilder,
5
5
  RawBuilder,
6
6
  SelectQueryBuilder,
7
+ SqlBool,
7
8
  SqliteAdapter,
8
9
  SqliteIntrospector,
9
10
  SqliteQueryCompiler,
@@ -21,7 +22,7 @@ export const actorWhereClause = (actor: string) => {
21
22
 
22
23
  // Applies to actor or record table
23
24
  export const notSoftDeletedClause = (alias: DbRef) => {
24
- return sql`${alias}."takedownRef" is null`
25
+ return sql<SqlBool>`${alias}."takedownRef" is null`
25
26
  }
26
27
 
27
28
  export const softDeleted = (actorOrRecord: { takedownRef: string | null }) => {
@@ -35,11 +36,11 @@ export const excluded = <T>(db: DatabaseSchema, col) => {
35
36
  return sql<T>`${db.dynamic.ref(`excluded.${col}`)}`
36
37
  }
37
38
 
38
- export const noMatch = sql`1 = 0`
39
+ export const noMatch = sql<SqlBool>`1 = 0`
39
40
 
40
41
  // Can be useful for large where-in clauses, to get the db to use a hash lookup on the list
41
- export const valuesList = (vals: unknown[]) => {
42
- return sql`(values (${sql.join(vals, sql`), (`)}))`
42
+ export const valuesList = <T = unknown>(vals: unknown[]) => {
43
+ return sql<T>`(values (${sql.join(vals, sql`), (`)}))`
43
44
  }
44
45
 
45
46
  export const dummyDialect = {
@@ -57,7 +58,9 @@ export const dummyDialect = {
57
58
  },
58
59
  }
59
60
 
60
- export type DbRef = RawBuilder | ReturnType<DynamicModule['ref']>
61
+ export type DbRef =
62
+ | RawBuilder<unknown>
63
+ | ReturnType<DynamicModule<unknown>['ref']>
61
64
 
62
65
  export type Subquery = ExpressionBuilder<DatabaseSchemaType, any>
63
66
 
@@ -2,6 +2,8 @@ import events from 'node:events'
2
2
  import http from 'node:http'
3
3
  import { expressConnectMiddleware } from '@connectrpc/connect-express'
4
4
  import express from 'express'
5
+ // eslint-disable-next-line import/default
6
+ import httpTerminator from 'http-terminator'
5
7
  import { IdResolver, MemoryCache } from '@atproto/identity'
6
8
  import { Database, DatabaseSchema } from './db/index.js'
7
9
  import createRoutes from './routes/index.js'
@@ -11,10 +13,14 @@ export type { DatabaseSchema }
11
13
  export { RepoSubscription } from './subscription.js'
12
14
 
13
15
  export class DataPlaneServer {
16
+ private terminator: httpTerminator.HttpTerminator
17
+
14
18
  constructor(
15
19
  public server: http.Server,
16
20
  public idResolver: IdResolver,
17
- ) {}
21
+ ) {
22
+ this.terminator = httpTerminator.createHttpTerminator({ server })
23
+ }
18
24
 
19
25
  static async create(db: Database, port: number, plcUrl?: string) {
20
26
  const app = express()
@@ -28,14 +34,10 @@ export class DataPlaneServer {
28
34
  }
29
35
 
30
36
  async destroy() {
31
- return new Promise<void>((resolve, reject) => {
32
- this.server.close((err) => {
33
- if (err) {
34
- reject(err)
35
- } else {
36
- resolve()
37
- }
38
- })
39
- })
37
+ await this.terminator.terminate()
38
+ }
39
+
40
+ async [Symbol.asyncDispose]() {
41
+ await this.destroy()
40
42
  }
41
43
  }
@@ -62,7 +62,7 @@ export class IndexingService {
62
62
  constructor(
63
63
  public db: Database,
64
64
  public idResolver: IdResolver,
65
- public background: BackgroundQueue,
65
+ public background: BackgroundQueue<Database>,
66
66
  ) {
67
67
  this.records = {
68
68
  post: Post.makePlugin(this.db, this.background),
@@ -67,7 +67,10 @@ const notifsForDelete = () => {
67
67
  }
68
68
 
69
69
  export type PluginType = ReturnType<typeof makePlugin>
70
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
70
+ export const makePlugin = (
71
+ db: Database,
72
+ background: BackgroundQueue<Database>,
73
+ ) => {
71
74
  return new RecordProcessor(db, background, {
72
75
  schema: app.bsky.graph.block.main,
73
76
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  const processor = new RecordProcessor(db, background, {
45
48
  schema: chat.bsky.actor.declaration.main,
46
49
  insertFn,
@@ -63,7 +63,10 @@ const notifsForDelete = () => {
63
63
  }
64
64
 
65
65
  export type PluginType = ReturnType<typeof makePlugin>
66
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
66
+ export const makePlugin = (
67
+ db: Database,
68
+ background: BackgroundQueue<Database>,
69
+ ) => {
67
70
  return new RecordProcessor(db, background, {
68
71
  schema: app.bsky.feed.generator.main,
69
72
  insertFn,
@@ -114,7 +114,10 @@ const updateAggregates = async (db: DatabaseSchema, follow: IndexedFollow) => {
114
114
  }
115
115
 
116
116
  export type PluginType = ReturnType<typeof makePlugin>
117
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
117
+ export const makePlugin = (
118
+ db: Database,
119
+ background: BackgroundQueue<Database>,
120
+ ) => {
118
121
  return new RecordProcessor(db, background, {
119
122
  schema: app.bsky.graph.follow.main,
120
123
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  return new RecordProcessor(db, background, {
45
48
  schema: com.germnetwork.declaration.main,
46
49
  insertFn,
@@ -57,7 +57,10 @@ const notifsForDelete = () => {
57
57
  }
58
58
 
59
59
  export type PluginType = ReturnType<typeof makePlugin>
60
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
60
+ export const makePlugin = (
61
+ db: Database,
62
+ background: BackgroundQueue<Database>,
63
+ ) => {
61
64
  return new RecordProcessor(db, background, {
62
65
  schema: app.bsky.labeler.service.main,
63
66
  insertFn,
@@ -133,7 +133,10 @@ const updateAggregates = async (db: DatabaseSchema, like: IndexedLike) => {
133
133
  }
134
134
 
135
135
  export type PluginType = ReturnType<typeof makePlugin>
136
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
136
+ export const makePlugin = (
137
+ db: Database,
138
+ background: BackgroundQueue<Database>,
139
+ ) => {
137
140
  return new RecordProcessor(db, background, {
138
141
  schema: app.bsky.feed.like.main,
139
142
  insertFn,
@@ -67,7 +67,10 @@ const notifsForDelete = () => {
67
67
  }
68
68
 
69
69
  export type PluginType = ReturnType<typeof makePlugin>
70
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
70
+ export const makePlugin = (
71
+ db: Database,
72
+ background: BackgroundQueue<Database>,
73
+ ) => {
71
74
  return new RecordProcessor(db, background, {
72
75
  schema: app.bsky.graph.listblock.main,
73
76
  insertFn,
@@ -75,7 +75,10 @@ const notifsForDelete = () => {
75
75
  }
76
76
 
77
77
  export type PluginType = ReturnType<typeof makePlugin>
78
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
78
+ export const makePlugin = (
79
+ db: Database,
80
+ background: BackgroundQueue<Database>,
81
+ ) => {
79
82
  return new RecordProcessor(db, background, {
80
83
  schema: app.bsky.graph.listitem.main,
81
84
  insertFn,
@@ -63,7 +63,10 @@ const notifsForDelete = () => {
63
63
  }
64
64
 
65
65
  export type PluginType = ReturnType<typeof makePlugin>
66
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
66
+ export const makePlugin = (
67
+ db: Database,
68
+ background: BackgroundQueue<Database>,
69
+ ) => {
67
70
  return new RecordProcessor(db, background, {
68
71
  schema: app.bsky.graph.list.main,
69
72
  insertFn,
@@ -40,7 +40,10 @@ const notifsForDelete = () => {
40
40
  }
41
41
 
42
42
  export type PluginType = ReturnType<typeof makePlugin>
43
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
43
+ export const makePlugin = (
44
+ db: Database,
45
+ background: BackgroundQueue<Database>,
46
+ ) => {
44
47
  return new RecordProcessor(db, background, {
45
48
  schema: app.bsky.notification.declaration.main,
46
49
  insertFn,
@@ -84,7 +84,10 @@ const notifsForDelete = () => {
84
84
  }
85
85
 
86
86
  export type PluginType = ReturnType<typeof makePlugin>
87
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
87
+ export const makePlugin = (
88
+ db: Database,
89
+ background: BackgroundQueue<Database>,
90
+ ) => {
88
91
  return new RecordProcessor(db, background, {
89
92
  schema: app.bsky.feed.postgate.main,
90
93
  insertFn,
@@ -505,10 +505,11 @@ const updateAggregates = async (db: DatabaseSchema, postIdx: IndexedPost) => {
505
505
  replyCount: db
506
506
  .selectFrom('post')
507
507
  .where('post.replyParent', '=', postIdx.post.replyParent)
508
- .where((qb) =>
509
- qb
510
- .where('post.violatesThreadGate', 'is', null)
511
- .orWhere('post.violatesThreadGate', '=', false),
508
+ .where((eb) =>
509
+ eb.or([
510
+ eb('post.violatesThreadGate', 'is', null),
511
+ eb('post.violatesThreadGate', '=', false),
512
+ ]),
512
513
  )
513
514
  .select(countAll.as('count')),
514
515
  })
@@ -534,7 +535,10 @@ const updateAggregates = async (db: DatabaseSchema, postIdx: IndexedPost) => {
534
535
  }
535
536
 
536
537
  export type PluginType = ReturnType<typeof makePlugin>
537
- export const makePlugin = (db: Database, background: BackgroundQueue) => {
538
+ export const makePlugin = (
539
+ db: Database,
540
+ background: BackgroundQueue<Database>,
541
+ ) => {
538
542
  return new RecordProcessor(db, background, {
539
543
  schema: app.bsky.feed.post.main,
540
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
 
@@ -8,15 +8,17 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
8
8
  const { actorDid, targetDid } = req
9
9
  const res = await db.db
10
10
  .selectFrom('actor_block')
11
- .where((qb) =>
12
- qb
13
- .where('actor_block.creator', '=', actorDid)
14
- .where('actor_block.subjectDid', '=', targetDid),
15
- )
16
- .orWhere((qb) =>
17
- qb
18
- .where('actor_block.creator', '=', targetDid)
19
- .where('actor_block.subjectDid', '=', actorDid),
11
+ .where((eb) =>
12
+ eb.or([
13
+ eb.and([
14
+ eb('actor_block.creator', '=', actorDid),
15
+ eb('actor_block.subjectDid', '=', targetDid),
16
+ ]),
17
+ eb.and([
18
+ eb('actor_block.creator', '=', targetDid),
19
+ eb('actor_block.subjectDid', '=', actorDid),
20
+ ]),
21
+ ]),
20
22
  )
21
23
  .limit(1)
22
24
  .selectAll()
@@ -58,15 +60,17 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
58
60
  const res = await db.db
59
61
  .selectFrom('list_block')
60
62
  .innerJoin('list_item', 'list_item.listUri', 'list_block.subjectUri')
61
- .where((qb) =>
62
- qb
63
- .where('list_block.creator', '=', actorDid)
64
- .where('list_item.subjectDid', '=', targetDid),
65
- )
66
- .orWhere((qb) =>
67
- qb
68
- .where('list_block.creator', '=', targetDid)
69
- .where('list_item.subjectDid', '=', actorDid),
63
+ .where((eb) =>
64
+ eb.or([
65
+ eb.and([
66
+ eb('list_block.creator', '=', actorDid),
67
+ eb('list_item.subjectDid', '=', targetDid),
68
+ ]),
69
+ eb.and([
70
+ eb('list_block.creator', '=', targetDid),
71
+ eb('list_item.subjectDid', '=', actorDid),
72
+ ]),
73
+ ]),
70
74
  )
71
75
  .limit(1)
72
76
  .selectAll('list_block')
@@ -96,12 +100,14 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
96
100
  const { ref } = db.db.dynamic
97
101
  let builder = db.db
98
102
  .selectFrom('list')
99
- .whereExists(
100
- db.db
101
- .selectFrom('list_block')
102
- .where('list_block.creator', '=', actorDid)
103
- .whereRef('list_block.subjectUri', '=', ref('list.uri'))
104
- .selectAll(),
103
+ .where(({ exists }) =>
104
+ exists(
105
+ db.db
106
+ .selectFrom('list_block')
107
+ .where('list_block.creator', '=', actorDid)
108
+ .whereRef('list_block.subjectUri', '=', ref('list.uri'))
109
+ .selectAll(),
110
+ ),
105
111
  )
106
112
  .selectAll('list')
107
113
 
@@ -34,7 +34,7 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
34
34
  const feeds = await db.db
35
35
  .selectFrom('suggested_feed')
36
36
  .orderBy('suggested_feed.order', 'asc')
37
- .if(!!req.cursor, (q) => q.where('order', '>', parseInt(req.cursor, 10)))
37
+ .$if(!!req.cursor, (q) => q.where('order', '>', parseInt(req.cursor, 10)))
38
38
  .limit(req.limit || 50)
39
39
  .selectAll()
40
40
  .execute()
@@ -74,7 +74,7 @@ const searchFeedGeneratorsImpl = async (
74
74
  const trimmed = query.trim()
75
75
  let builder = db.db
76
76
  .selectFrom('feed_generator')
77
- .if(!!trimmed, (q) => q.where('displayName', 'ilike', `%${trimmed}%`))
77
+ .$if(!!trimmed, (q) => q.where('displayName', 'ilike', `%${trimmed}%`))
78
78
  .selectAll()
79
79
  const keyset = new TimeCidKeyset(
80
80
  ref('feed_generator.createdAt'),
@@ -21,16 +21,16 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
21
21
  // only your own posts
22
22
  .where('type', '=', 'post')
23
23
  // only posts with media
24
- .where((qb) =>
25
- qb
26
- .whereExists((iqb) =>
27
- iqb
24
+ .where((eb) =>
25
+ eb.or([
26
+ eb.exists(
27
+ eb
28
28
  .selectFrom('post_embed_image')
29
29
  .select('post_embed_image.postUri')
30
30
  .whereRef('post_embed_image.postUri', '=', 'feed_item.postUri'),
31
- )
32
- .orWhereExists((iqb) =>
33
- iqb
31
+ ),
32
+ eb.exists(
33
+ eb
34
34
  .selectFrom('post_embed_gallery_image')
35
35
  .select('post_embed_gallery_image.postUri')
36
36
  .whereRef(
@@ -39,28 +39,32 @@ export default (db: Database): Partial<ServiceImpl<typeof Service>> => ({
39
39
  'feed_item.postUri',
40
40
  ),
41
41
  ),
42
+ ]),
42
43
  )
43
44
  } else if (feedType === FeedType.POSTS_WITH_VIDEO) {
44
45
  builder = builder
45
46
  // only your own posts
46
47
  .where('type', '=', 'post')
47
48
  // only posts with video
48
- .whereExists((qb) =>
49
- qb
50
- .selectFrom('post_embed_video')
51
- .select('post_embed_video.postUri')
52
- .whereRef('post_embed_video.postUri', '=', 'feed_item.postUri'),
49
+ .where(({ eb, exists }) =>
50
+ exists(
51
+ eb
52
+ .selectFrom('post_embed_video')
53
+ .select('post_embed_video.postUri')
54
+ .whereRef('post_embed_video.postUri', '=', 'feed_item.postUri'),
55
+ ),
53
56
  )
54
57
  } else if (feedType === FeedType.POSTS_NO_REPLIES) {
55
- builder = builder.where((qb) =>
56
- qb.where('post.replyParent', 'is', null).orWhere('type', '=', 'repost'),
58
+ builder = builder.where((eb) =>
59
+ eb.or([eb('post.replyParent', 'is', null), eb('type', '=', 'repost')]),
57
60
  )
58
61
  } else if (feedType === FeedType.POSTS_AND_AUTHOR_THREADS) {
59
- builder = builder.where((qb) =>
60
- qb
61
- .where('type', '=', 'repost')
62
- .orWhere('post.replyParent', 'is', null)
63
- .orWhere('post.replyRoot', 'like', `at://${actorDid}/%`),
62
+ builder = builder.where((eb) =>
63
+ eb.or([
64
+ eb('type', '=', 'repost'),
65
+ eb('post.replyParent', 'is', null),
66
+ eb('post.replyRoot', 'like', `at://${actorDid}/%`),
67
+ ]),
64
68
  )
65
69
  }
66
70