@atproto/pds 0.4.91 → 0.4.92

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 (762) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/bin/migration-create.ts +2 -2
  3. package/dist/account-manager/db/index.d.ts.map +1 -1
  4. package/dist/account-manager/db/index.js.map +1 -1
  5. package/dist/account-manager/db/schema/authorization-request.d.ts +1 -1
  6. package/dist/account-manager/db/schema/authorization-request.d.ts.map +1 -1
  7. package/dist/account-manager/db/schema/device.d.ts +1 -1
  8. package/dist/account-manager/db/schema/device.d.ts.map +1 -1
  9. package/dist/account-manager/db/schema/index.d.ts +7 -7
  10. package/dist/account-manager/db/schema/index.d.ts.map +1 -1
  11. package/dist/account-manager/db/schema/token.d.ts +1 -1
  12. package/dist/account-manager/db/schema/token.d.ts.map +1 -1
  13. package/dist/account-manager/db/schema/token.js.map +1 -1
  14. package/dist/account-manager/db/schema/used-refresh-token.d.ts +1 -1
  15. package/dist/account-manager/db/schema/used-refresh-token.d.ts.map +1 -1
  16. package/dist/account-manager/helpers/account.d.ts +8 -8
  17. package/dist/account-manager/helpers/account.d.ts.map +1 -1
  18. package/dist/account-manager/helpers/account.js +1 -1
  19. package/dist/account-manager/helpers/account.js.map +1 -1
  20. package/dist/account-manager/helpers/authorization-request.d.ts +1 -1
  21. package/dist/account-manager/helpers/authorization-request.d.ts.map +1 -1
  22. package/dist/account-manager/helpers/device-account.d.ts +37 -37
  23. package/dist/account-manager/helpers/device-account.d.ts.map +1 -1
  24. package/dist/account-manager/helpers/device-account.js.map +1 -1
  25. package/dist/account-manager/helpers/device.d.ts +2 -2
  26. package/dist/account-manager/helpers/device.d.ts.map +1 -1
  27. package/dist/account-manager/helpers/email-token.js +1 -1
  28. package/dist/account-manager/helpers/email-token.js.map +1 -1
  29. package/dist/account-manager/helpers/invite.d.ts.map +1 -1
  30. package/dist/account-manager/helpers/invite.js.map +1 -1
  31. package/dist/account-manager/helpers/password.d.ts +1 -1
  32. package/dist/account-manager/helpers/password.d.ts.map +1 -1
  33. package/dist/account-manager/helpers/password.js.map +1 -1
  34. package/dist/account-manager/helpers/scrypt.js +6 -6
  35. package/dist/account-manager/helpers/scrypt.js.map +1 -1
  36. package/dist/account-manager/helpers/token.d.ts +201 -201
  37. package/dist/account-manager/helpers/token.d.ts.map +1 -1
  38. package/dist/account-manager/index.d.ts +8 -3
  39. package/dist/account-manager/index.d.ts.map +1 -1
  40. package/dist/account-manager/index.js +34 -5
  41. package/dist/account-manager/index.js.map +1 -1
  42. package/dist/actor-store/actor-store-reader.d.ts +19 -0
  43. package/dist/actor-store/actor-store-reader.d.ts.map +1 -0
  44. package/dist/actor-store/actor-store-reader.js +69 -0
  45. package/dist/actor-store/actor-store-reader.js.map +1 -0
  46. package/dist/actor-store/actor-store-resources.d.ts +8 -0
  47. package/dist/actor-store/actor-store-resources.d.ts.map +1 -0
  48. package/dist/actor-store/actor-store-resources.js +3 -0
  49. package/dist/actor-store/actor-store-resources.js.map +1 -0
  50. package/dist/actor-store/actor-store-transactor.d.ts +17 -0
  51. package/dist/actor-store/actor-store-transactor.d.ts.map +1 -0
  52. package/dist/actor-store/actor-store-transactor.js +58 -0
  53. package/dist/actor-store/actor-store-transactor.js.map +1 -0
  54. package/dist/actor-store/actor-store-writer.d.ts +5 -0
  55. package/dist/actor-store/actor-store-writer.d.ts.map +1 -0
  56. package/dist/actor-store/actor-store-writer.js +14 -0
  57. package/dist/actor-store/actor-store-writer.js.map +1 -0
  58. package/dist/actor-store/actor-store.d.ts +33 -0
  59. package/dist/actor-store/actor-store.d.ts.map +1 -0
  60. package/dist/actor-store/{index.js → actor-store.js} +37 -82
  61. package/dist/actor-store/actor-store.js.map +1 -0
  62. package/dist/actor-store/blob/reader.d.ts +4 -2
  63. package/dist/actor-store/blob/reader.d.ts.map +1 -1
  64. package/dist/actor-store/blob/reader.js +14 -0
  65. package/dist/actor-store/blob/reader.js.map +1 -1
  66. package/dist/actor-store/blob/transactor.d.ts +6 -5
  67. package/dist/actor-store/blob/transactor.d.ts.map +1 -1
  68. package/dist/actor-store/blob/transactor.js +18 -5
  69. package/dist/actor-store/blob/transactor.js.map +1 -1
  70. package/dist/actor-store/db/index.d.ts +1 -1
  71. package/dist/actor-store/db/index.d.ts.map +1 -1
  72. package/dist/actor-store/db/index.js.map +1 -1
  73. package/dist/actor-store/db/schema/index.d.ts +3 -3
  74. package/dist/actor-store/db/schema/index.d.ts.map +1 -1
  75. package/dist/actor-store/migrate.d.ts +1 -1
  76. package/dist/actor-store/migrate.d.ts.map +1 -1
  77. package/dist/actor-store/migrate.js.map +1 -1
  78. package/dist/actor-store/preference/transactor.d.ts +1 -1
  79. package/dist/actor-store/preference/transactor.d.ts.map +1 -1
  80. package/dist/actor-store/preference/transactor.js.map +1 -1
  81. package/dist/actor-store/record/reader.d.ts +18 -6
  82. package/dist/actor-store/record/reader.d.ts.map +1 -1
  83. package/dist/actor-store/record/reader.js +104 -2
  84. package/dist/actor-store/record/reader.js.map +1 -1
  85. package/dist/actor-store/record/transactor.d.ts +3 -3
  86. package/dist/actor-store/record/transactor.d.ts.map +1 -1
  87. package/dist/actor-store/record/transactor.js.map +1 -1
  88. package/dist/actor-store/repo/reader.d.ts +1 -1
  89. package/dist/actor-store/repo/reader.d.ts.map +1 -1
  90. package/dist/actor-store/repo/reader.js +1 -1
  91. package/dist/actor-store/repo/reader.js.map +1 -1
  92. package/dist/actor-store/repo/sql-repo-reader.d.ts +2 -2
  93. package/dist/actor-store/repo/sql-repo-reader.d.ts.map +1 -1
  94. package/dist/actor-store/repo/sql-repo-reader.js +6 -5
  95. package/dist/actor-store/repo/sql-repo-reader.js.map +1 -1
  96. package/dist/actor-store/repo/sql-repo-transactor.d.ts +1 -1
  97. package/dist/actor-store/repo/sql-repo-transactor.d.ts.map +1 -1
  98. package/dist/actor-store/repo/sql-repo-transactor.js +2 -2
  99. package/dist/actor-store/repo/sql-repo-transactor.js.map +1 -1
  100. package/dist/actor-store/repo/transactor.d.ts +7 -6
  101. package/dist/actor-store/repo/transactor.d.ts.map +1 -1
  102. package/dist/actor-store/repo/transactor.js +22 -15
  103. package/dist/actor-store/repo/transactor.js.map +1 -1
  104. package/dist/api/app/bsky/actor/getPreferences.d.ts +1 -1
  105. package/dist/api/app/bsky/actor/getPreferences.d.ts.map +1 -1
  106. package/dist/api/app/bsky/actor/getPreferences.js +1 -1
  107. package/dist/api/app/bsky/actor/getPreferences.js.map +1 -1
  108. package/dist/api/app/bsky/actor/getProfile.d.ts +1 -1
  109. package/dist/api/app/bsky/actor/getProfile.d.ts.map +1 -1
  110. package/dist/api/app/bsky/actor/getProfile.js +1 -2
  111. package/dist/api/app/bsky/actor/getProfile.js.map +1 -1
  112. package/dist/api/app/bsky/actor/getProfiles.d.ts +1 -1
  113. package/dist/api/app/bsky/actor/getProfiles.d.ts.map +1 -1
  114. package/dist/api/app/bsky/actor/getProfiles.js +1 -2
  115. package/dist/api/app/bsky/actor/getProfiles.js.map +1 -1
  116. package/dist/api/app/bsky/actor/index.d.ts +1 -1
  117. package/dist/api/app/bsky/actor/index.d.ts.map +1 -1
  118. package/dist/api/app/bsky/actor/index.js.map +1 -1
  119. package/dist/api/app/bsky/actor/putPreferences.d.ts +1 -1
  120. package/dist/api/app/bsky/actor/putPreferences.d.ts.map +1 -1
  121. package/dist/api/app/bsky/actor/putPreferences.js +1 -1
  122. package/dist/api/app/bsky/actor/putPreferences.js.map +1 -1
  123. package/dist/api/app/bsky/feed/getActorLikes.d.ts +1 -1
  124. package/dist/api/app/bsky/feed/getActorLikes.d.ts.map +1 -1
  125. package/dist/api/app/bsky/feed/getActorLikes.js +1 -2
  126. package/dist/api/app/bsky/feed/getActorLikes.js.map +1 -1
  127. package/dist/api/app/bsky/feed/getAuthorFeed.d.ts +1 -1
  128. package/dist/api/app/bsky/feed/getAuthorFeed.d.ts.map +1 -1
  129. package/dist/api/app/bsky/feed/getAuthorFeed.js +1 -2
  130. package/dist/api/app/bsky/feed/getAuthorFeed.js.map +1 -1
  131. package/dist/api/app/bsky/feed/getFeed.d.ts +1 -1
  132. package/dist/api/app/bsky/feed/getFeed.d.ts.map +1 -1
  133. package/dist/api/app/bsky/feed/getFeed.js +6 -7
  134. package/dist/api/app/bsky/feed/getFeed.js.map +1 -1
  135. package/dist/api/app/bsky/feed/getPostThread.d.ts +1 -1
  136. package/dist/api/app/bsky/feed/getPostThread.d.ts.map +1 -1
  137. package/dist/api/app/bsky/feed/getPostThread.js +4 -5
  138. package/dist/api/app/bsky/feed/getPostThread.js.map +1 -1
  139. package/dist/api/app/bsky/feed/getTimeline.d.ts +1 -1
  140. package/dist/api/app/bsky/feed/getTimeline.d.ts.map +1 -1
  141. package/dist/api/app/bsky/feed/getTimeline.js +1 -2
  142. package/dist/api/app/bsky/feed/getTimeline.js.map +1 -1
  143. package/dist/api/app/bsky/feed/index.d.ts +1 -1
  144. package/dist/api/app/bsky/feed/index.d.ts.map +1 -1
  145. package/dist/api/app/bsky/index.d.ts +1 -1
  146. package/dist/api/app/bsky/index.d.ts.map +1 -1
  147. package/dist/api/app/bsky/notification/index.d.ts +1 -1
  148. package/dist/api/app/bsky/notification/index.d.ts.map +1 -1
  149. package/dist/api/app/bsky/notification/registerPush.d.ts +1 -1
  150. package/dist/api/app/bsky/notification/registerPush.d.ts.map +1 -1
  151. package/dist/api/app/bsky/notification/registerPush.js +6 -6
  152. package/dist/api/app/bsky/notification/registerPush.js.map +1 -1
  153. package/dist/api/app/bsky/util/resolver.d.ts +1 -1
  154. package/dist/api/app/bsky/util/resolver.d.ts.map +1 -1
  155. package/dist/api/app/bsky/util/resolver.js.map +1 -1
  156. package/dist/api/com/atproto/admin/deleteAccount.d.ts +1 -1
  157. package/dist/api/com/atproto/admin/deleteAccount.d.ts.map +1 -1
  158. package/dist/api/com/atproto/admin/deleteAccount.js.map +1 -1
  159. package/dist/api/com/atproto/admin/disableAccountInvites.d.ts +1 -1
  160. package/dist/api/com/atproto/admin/disableAccountInvites.d.ts.map +1 -1
  161. package/dist/api/com/atproto/admin/disableInviteCodes.d.ts +1 -1
  162. package/dist/api/com/atproto/admin/disableInviteCodes.d.ts.map +1 -1
  163. package/dist/api/com/atproto/admin/enableAccountInvites.d.ts +1 -1
  164. package/dist/api/com/atproto/admin/enableAccountInvites.d.ts.map +1 -1
  165. package/dist/api/com/atproto/admin/getAccountInfo.d.ts +1 -1
  166. package/dist/api/com/atproto/admin/getAccountInfo.d.ts.map +1 -1
  167. package/dist/api/com/atproto/admin/getAccountInfo.js.map +1 -1
  168. package/dist/api/com/atproto/admin/getAccountInfos.d.ts +1 -1
  169. package/dist/api/com/atproto/admin/getAccountInfos.d.ts.map +1 -1
  170. package/dist/api/com/atproto/admin/getInviteCodes.d.ts +2 -2
  171. package/dist/api/com/atproto/admin/getInviteCodes.d.ts.map +1 -1
  172. package/dist/api/com/atproto/admin/getInviteCodes.js +1 -1
  173. package/dist/api/com/atproto/admin/getInviteCodes.js.map +1 -1
  174. package/dist/api/com/atproto/admin/getSubjectStatus.d.ts +1 -1
  175. package/dist/api/com/atproto/admin/getSubjectStatus.d.ts.map +1 -1
  176. package/dist/api/com/atproto/admin/index.d.ts +1 -1
  177. package/dist/api/com/atproto/admin/index.d.ts.map +1 -1
  178. package/dist/api/com/atproto/admin/index.js +8 -8
  179. package/dist/api/com/atproto/admin/index.js.map +1 -1
  180. package/dist/api/com/atproto/admin/sendEmail.d.ts +1 -1
  181. package/dist/api/com/atproto/admin/sendEmail.d.ts.map +1 -1
  182. package/dist/api/com/atproto/admin/sendEmail.js +1 -1
  183. package/dist/api/com/atproto/admin/sendEmail.js.map +1 -1
  184. package/dist/api/com/atproto/admin/updateAccountEmail.d.ts +1 -1
  185. package/dist/api/com/atproto/admin/updateAccountEmail.d.ts.map +1 -1
  186. package/dist/api/com/atproto/admin/updateAccountHandle.d.ts +1 -1
  187. package/dist/api/com/atproto/admin/updateAccountHandle.d.ts.map +1 -1
  188. package/dist/api/com/atproto/admin/updateAccountHandle.js.map +1 -1
  189. package/dist/api/com/atproto/admin/updateAccountPassword.d.ts +1 -1
  190. package/dist/api/com/atproto/admin/updateAccountPassword.d.ts.map +1 -1
  191. package/dist/api/com/atproto/admin/updateSubjectStatus.d.ts +1 -1
  192. package/dist/api/com/atproto/admin/updateSubjectStatus.d.ts.map +1 -1
  193. package/dist/api/com/atproto/admin/updateSubjectStatus.js +1 -1
  194. package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
  195. package/dist/api/com/atproto/admin/util.d.ts.map +1 -1
  196. package/dist/api/com/atproto/admin/util.js.map +1 -1
  197. package/dist/api/com/atproto/identity/getRecommendedDidCredentials.d.ts +1 -1
  198. package/dist/api/com/atproto/identity/getRecommendedDidCredentials.d.ts.map +1 -1
  199. package/dist/api/com/atproto/identity/index.d.ts +1 -1
  200. package/dist/api/com/atproto/identity/index.d.ts.map +1 -1
  201. package/dist/api/com/atproto/identity/index.js +2 -2
  202. package/dist/api/com/atproto/identity/index.js.map +1 -1
  203. package/dist/api/com/atproto/identity/requestPlcOperationSignature.d.ts +1 -1
  204. package/dist/api/com/atproto/identity/requestPlcOperationSignature.d.ts.map +1 -1
  205. package/dist/api/com/atproto/identity/requestPlcOperationSignature.js +1 -1
  206. package/dist/api/com/atproto/identity/requestPlcOperationSignature.js.map +1 -1
  207. package/dist/api/com/atproto/identity/resolveHandle.d.ts +1 -1
  208. package/dist/api/com/atproto/identity/resolveHandle.d.ts.map +1 -1
  209. package/dist/api/com/atproto/identity/resolveHandle.js +11 -14
  210. package/dist/api/com/atproto/identity/resolveHandle.js.map +1 -1
  211. package/dist/api/com/atproto/identity/signPlcOperation.d.ts +1 -1
  212. package/dist/api/com/atproto/identity/signPlcOperation.d.ts.map +1 -1
  213. package/dist/api/com/atproto/identity/signPlcOperation.js +1 -1
  214. package/dist/api/com/atproto/identity/signPlcOperation.js.map +1 -1
  215. package/dist/api/com/atproto/identity/submitPlcOperation.d.ts +1 -1
  216. package/dist/api/com/atproto/identity/submitPlcOperation.d.ts.map +1 -1
  217. package/dist/api/com/atproto/identity/submitPlcOperation.js.map +1 -1
  218. package/dist/api/com/atproto/identity/updateHandle.d.ts +1 -1
  219. package/dist/api/com/atproto/identity/updateHandle.d.ts.map +1 -1
  220. package/dist/api/com/atproto/identity/updateHandle.js +2 -2
  221. package/dist/api/com/atproto/identity/updateHandle.js.map +1 -1
  222. package/dist/api/com/atproto/index.d.ts +1 -1
  223. package/dist/api/com/atproto/index.d.ts.map +1 -1
  224. package/dist/api/com/atproto/moderation/createReport.d.ts +1 -1
  225. package/dist/api/com/atproto/moderation/createReport.d.ts.map +1 -1
  226. package/dist/api/com/atproto/moderation/createReport.js +2 -2
  227. package/dist/api/com/atproto/moderation/createReport.js.map +1 -1
  228. package/dist/api/com/atproto/moderation/index.d.ts +1 -1
  229. package/dist/api/com/atproto/moderation/index.d.ts.map +1 -1
  230. package/dist/api/com/atproto/repo/applyWrites.d.ts +1 -1
  231. package/dist/api/com/atproto/repo/applyWrites.d.ts.map +1 -1
  232. package/dist/api/com/atproto/repo/applyWrites.js +4 -5
  233. package/dist/api/com/atproto/repo/applyWrites.js.map +1 -1
  234. package/dist/api/com/atproto/repo/createRecord.d.ts +1 -1
  235. package/dist/api/com/atproto/repo/createRecord.d.ts.map +1 -1
  236. package/dist/api/com/atproto/repo/createRecord.js +3 -4
  237. package/dist/api/com/atproto/repo/createRecord.js.map +1 -1
  238. package/dist/api/com/atproto/repo/deleteRecord.d.ts +1 -1
  239. package/dist/api/com/atproto/repo/deleteRecord.d.ts.map +1 -1
  240. package/dist/api/com/atproto/repo/deleteRecord.js +3 -4
  241. package/dist/api/com/atproto/repo/deleteRecord.js.map +1 -1
  242. package/dist/api/com/atproto/repo/describeRepo.d.ts +1 -1
  243. package/dist/api/com/atproto/repo/describeRepo.d.ts.map +1 -1
  244. package/dist/api/com/atproto/repo/describeRepo.js +1 -1
  245. package/dist/api/com/atproto/repo/describeRepo.js.map +1 -1
  246. package/dist/api/com/atproto/repo/getRecord.d.ts +1 -1
  247. package/dist/api/com/atproto/repo/getRecord.d.ts.map +1 -1
  248. package/dist/api/com/atproto/repo/getRecord.js.map +1 -1
  249. package/dist/api/com/atproto/repo/importRepo.d.ts +2 -2
  250. package/dist/api/com/atproto/repo/importRepo.d.ts.map +1 -1
  251. package/dist/api/com/atproto/repo/importRepo.js +6 -22
  252. package/dist/api/com/atproto/repo/importRepo.js.map +1 -1
  253. package/dist/api/com/atproto/repo/index.d.ts +1 -1
  254. package/dist/api/com/atproto/repo/index.d.ts.map +1 -1
  255. package/dist/api/com/atproto/repo/index.js +2 -2
  256. package/dist/api/com/atproto/repo/index.js.map +1 -1
  257. package/dist/api/com/atproto/repo/listMissingBlobs.d.ts +1 -1
  258. package/dist/api/com/atproto/repo/listMissingBlobs.d.ts.map +1 -1
  259. package/dist/api/com/atproto/repo/listRecords.d.ts +1 -1
  260. package/dist/api/com/atproto/repo/listRecords.d.ts.map +1 -1
  261. package/dist/api/com/atproto/repo/listRecords.js +1 -1
  262. package/dist/api/com/atproto/repo/listRecords.js.map +1 -1
  263. package/dist/api/com/atproto/repo/putRecord.d.ts +1 -1
  264. package/dist/api/com/atproto/repo/putRecord.d.ts.map +1 -1
  265. package/dist/api/com/atproto/repo/putRecord.js +5 -6
  266. package/dist/api/com/atproto/repo/putRecord.js.map +1 -1
  267. package/dist/api/com/atproto/repo/uploadBlob.d.ts +1 -1
  268. package/dist/api/com/atproto/repo/uploadBlob.d.ts.map +1 -1
  269. package/dist/api/com/atproto/server/activateAccount.d.ts +1 -1
  270. package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
  271. package/dist/api/com/atproto/server/activateAccount.js +1 -1
  272. package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
  273. package/dist/api/com/atproto/server/checkAccountStatus.d.ts +1 -1
  274. package/dist/api/com/atproto/server/checkAccountStatus.d.ts.map +1 -1
  275. package/dist/api/com/atproto/server/confirmEmail.d.ts +1 -1
  276. package/dist/api/com/atproto/server/confirmEmail.d.ts.map +1 -1
  277. package/dist/api/com/atproto/server/confirmEmail.js.map +1 -1
  278. package/dist/api/com/atproto/server/createAccount.d.ts +1 -1
  279. package/dist/api/com/atproto/server/createAccount.d.ts.map +1 -1
  280. package/dist/api/com/atproto/server/createAccount.js +5 -5
  281. package/dist/api/com/atproto/server/createAccount.js.map +1 -1
  282. package/dist/api/com/atproto/server/createAppPassword.d.ts +1 -1
  283. package/dist/api/com/atproto/server/createAppPassword.d.ts.map +1 -1
  284. package/dist/api/com/atproto/server/createAppPassword.js.map +1 -1
  285. package/dist/api/com/atproto/server/createInviteCode.d.ts +1 -1
  286. package/dist/api/com/atproto/server/createInviteCode.d.ts.map +1 -1
  287. package/dist/api/com/atproto/server/createInviteCodes.d.ts +1 -1
  288. package/dist/api/com/atproto/server/createInviteCodes.d.ts.map +1 -1
  289. package/dist/api/com/atproto/server/createInviteCodes.js.map +1 -1
  290. package/dist/api/com/atproto/server/createSession.d.ts +1 -1
  291. package/dist/api/com/atproto/server/createSession.d.ts.map +1 -1
  292. package/dist/api/com/atproto/server/createSession.js.map +1 -1
  293. package/dist/api/com/atproto/server/deactivateAccount.d.ts +1 -1
  294. package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
  295. package/dist/api/com/atproto/server/deleteAccount.d.ts +1 -1
  296. package/dist/api/com/atproto/server/deleteAccount.d.ts.map +1 -1
  297. package/dist/api/com/atproto/server/deleteAccount.js +1 -1
  298. package/dist/api/com/atproto/server/deleteAccount.js.map +1 -1
  299. package/dist/api/com/atproto/server/deleteSession.d.ts +1 -1
  300. package/dist/api/com/atproto/server/deleteSession.d.ts.map +1 -1
  301. package/dist/api/com/atproto/server/describeServer.d.ts +1 -1
  302. package/dist/api/com/atproto/server/describeServer.d.ts.map +1 -1
  303. package/dist/api/com/atproto/server/getAccountInviteCodes.d.ts +1 -1
  304. package/dist/api/com/atproto/server/getAccountInviteCodes.d.ts.map +1 -1
  305. package/dist/api/com/atproto/server/getAccountInviteCodes.js +1 -1
  306. package/dist/api/com/atproto/server/getAccountInviteCodes.js.map +1 -1
  307. package/dist/api/com/atproto/server/getServiceAuth.d.ts +1 -1
  308. package/dist/api/com/atproto/server/getServiceAuth.d.ts.map +1 -1
  309. package/dist/api/com/atproto/server/getServiceAuth.js +2 -2
  310. package/dist/api/com/atproto/server/getServiceAuth.js.map +1 -1
  311. package/dist/api/com/atproto/server/getSession.d.ts +1 -1
  312. package/dist/api/com/atproto/server/getSession.d.ts.map +1 -1
  313. package/dist/api/com/atproto/server/getSession.js +2 -2
  314. package/dist/api/com/atproto/server/getSession.js.map +1 -1
  315. package/dist/api/com/atproto/server/index.d.ts +1 -1
  316. package/dist/api/com/atproto/server/index.d.ts.map +1 -1
  317. package/dist/api/com/atproto/server/index.js +17 -17
  318. package/dist/api/com/atproto/server/index.js.map +1 -1
  319. package/dist/api/com/atproto/server/listAppPasswords.d.ts +1 -1
  320. package/dist/api/com/atproto/server/listAppPasswords.d.ts.map +1 -1
  321. package/dist/api/com/atproto/server/listAppPasswords.js.map +1 -1
  322. package/dist/api/com/atproto/server/refreshSession.d.ts +1 -1
  323. package/dist/api/com/atproto/server/refreshSession.d.ts.map +1 -1
  324. package/dist/api/com/atproto/server/refreshSession.js +1 -1
  325. package/dist/api/com/atproto/server/refreshSession.js.map +1 -1
  326. package/dist/api/com/atproto/server/requestAccountDelete.d.ts +1 -1
  327. package/dist/api/com/atproto/server/requestAccountDelete.d.ts.map +1 -1
  328. package/dist/api/com/atproto/server/requestAccountDelete.js.map +1 -1
  329. package/dist/api/com/atproto/server/requestEmailConfirmation.d.ts +1 -1
  330. package/dist/api/com/atproto/server/requestEmailConfirmation.d.ts.map +1 -1
  331. package/dist/api/com/atproto/server/requestEmailConfirmation.js.map +1 -1
  332. package/dist/api/com/atproto/server/requestEmailUpdate.d.ts +1 -1
  333. package/dist/api/com/atproto/server/requestEmailUpdate.d.ts.map +1 -1
  334. package/dist/api/com/atproto/server/requestEmailUpdate.js +1 -1
  335. package/dist/api/com/atproto/server/requestEmailUpdate.js.map +1 -1
  336. package/dist/api/com/atproto/server/requestPasswordReset.d.ts +1 -1
  337. package/dist/api/com/atproto/server/requestPasswordReset.d.ts.map +1 -1
  338. package/dist/api/com/atproto/server/reserveSigningKey.d.ts +1 -1
  339. package/dist/api/com/atproto/server/reserveSigningKey.d.ts.map +1 -1
  340. package/dist/api/com/atproto/server/resetPassword.d.ts +1 -1
  341. package/dist/api/com/atproto/server/resetPassword.d.ts.map +1 -1
  342. package/dist/api/com/atproto/server/resetPassword.js.map +1 -1
  343. package/dist/api/com/atproto/server/revokeAppPassword.d.ts +1 -1
  344. package/dist/api/com/atproto/server/revokeAppPassword.d.ts.map +1 -1
  345. package/dist/api/com/atproto/server/revokeAppPassword.js.map +1 -1
  346. package/dist/api/com/atproto/server/updateEmail.d.ts +1 -1
  347. package/dist/api/com/atproto/server/updateEmail.d.ts.map +1 -1
  348. package/dist/api/com/atproto/server/updateEmail.js +1 -1
  349. package/dist/api/com/atproto/server/updateEmail.js.map +1 -1
  350. package/dist/api/com/atproto/server/util.d.ts +1 -1
  351. package/dist/api/com/atproto/server/util.d.ts.map +1 -1
  352. package/dist/api/com/atproto/server/util.js +2 -2
  353. package/dist/api/com/atproto/server/util.js.map +1 -1
  354. package/dist/api/com/atproto/sync/deprecated/getCheckout.d.ts +1 -1
  355. package/dist/api/com/atproto/sync/deprecated/getCheckout.d.ts.map +1 -1
  356. package/dist/api/com/atproto/sync/deprecated/getHead.d.ts +1 -1
  357. package/dist/api/com/atproto/sync/deprecated/getHead.d.ts.map +1 -1
  358. package/dist/api/com/atproto/sync/getBlob.d.ts +1 -1
  359. package/dist/api/com/atproto/sync/getBlob.d.ts.map +1 -1
  360. package/dist/api/com/atproto/sync/getBlob.js +2 -2
  361. package/dist/api/com/atproto/sync/getBlob.js.map +1 -1
  362. package/dist/api/com/atproto/sync/getBlocks.d.ts +1 -1
  363. package/dist/api/com/atproto/sync/getBlocks.d.ts.map +1 -1
  364. package/dist/api/com/atproto/sync/getBlocks.js +1 -1
  365. package/dist/api/com/atproto/sync/getBlocks.js.map +1 -1
  366. package/dist/api/com/atproto/sync/getLatestCommit.d.ts +1 -1
  367. package/dist/api/com/atproto/sync/getLatestCommit.d.ts.map +1 -1
  368. package/dist/api/com/atproto/sync/getRecord.d.ts +1 -1
  369. package/dist/api/com/atproto/sync/getRecord.d.ts.map +1 -1
  370. package/dist/api/com/atproto/sync/getRecord.js +1 -1
  371. package/dist/api/com/atproto/sync/getRecord.js.map +1 -1
  372. package/dist/api/com/atproto/sync/getRepo.d.ts +2 -2
  373. package/dist/api/com/atproto/sync/getRepo.d.ts.map +1 -1
  374. package/dist/api/com/atproto/sync/getRepo.js +1 -1
  375. package/dist/api/com/atproto/sync/getRepo.js.map +1 -1
  376. package/dist/api/com/atproto/sync/getRepoStatus.d.ts +1 -1
  377. package/dist/api/com/atproto/sync/getRepoStatus.d.ts.map +1 -1
  378. package/dist/api/com/atproto/sync/getRepoStatus.js +1 -1
  379. package/dist/api/com/atproto/sync/getRepoStatus.js.map +1 -1
  380. package/dist/api/com/atproto/sync/index.d.ts +1 -1
  381. package/dist/api/com/atproto/sync/index.d.ts.map +1 -1
  382. package/dist/api/com/atproto/sync/index.js +4 -4
  383. package/dist/api/com/atproto/sync/index.js.map +1 -1
  384. package/dist/api/com/atproto/sync/listBlobs.d.ts +1 -1
  385. package/dist/api/com/atproto/sync/listBlobs.d.ts.map +1 -1
  386. package/dist/api/com/atproto/sync/listBlobs.js +1 -1
  387. package/dist/api/com/atproto/sync/listBlobs.js.map +1 -1
  388. package/dist/api/com/atproto/sync/listRepos.d.ts +2 -2
  389. package/dist/api/com/atproto/sync/listRepos.d.ts.map +1 -1
  390. package/dist/api/com/atproto/sync/listRepos.js +1 -1
  391. package/dist/api/com/atproto/sync/listRepos.js.map +1 -1
  392. package/dist/api/com/atproto/sync/subscribeRepos.d.ts +1 -1
  393. package/dist/api/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
  394. package/dist/api/com/atproto/sync/subscribeRepos.js +2 -5
  395. package/dist/api/com/atproto/sync/subscribeRepos.js.map +1 -1
  396. package/dist/api/com/atproto/sync/util.d.ts +1 -1
  397. package/dist/api/com/atproto/sync/util.d.ts.map +1 -1
  398. package/dist/api/com/atproto/temp/checkSignupQueue.d.ts +1 -1
  399. package/dist/api/com/atproto/temp/checkSignupQueue.d.ts.map +1 -1
  400. package/dist/api/com/atproto/temp/checkSignupQueue.js +1 -1
  401. package/dist/api/com/atproto/temp/checkSignupQueue.js.map +1 -1
  402. package/dist/api/com/atproto/temp/index.d.ts +1 -1
  403. package/dist/api/com/atproto/temp/index.d.ts.map +1 -1
  404. package/dist/api/index.d.ts +1 -1
  405. package/dist/api/index.d.ts.map +1 -1
  406. package/dist/api/index.js +1 -1
  407. package/dist/api/index.js.map +1 -1
  408. package/dist/api/proxy.d.ts +1 -1
  409. package/dist/api/proxy.d.ts.map +1 -1
  410. package/dist/api/proxy.js.map +1 -1
  411. package/dist/auth-routes.d.ts +1 -1
  412. package/dist/auth-routes.d.ts.map +1 -1
  413. package/dist/auth-routes.js +1 -1
  414. package/dist/auth-routes.js.map +1 -1
  415. package/dist/auth-verifier.d.ts +1 -1
  416. package/dist/auth-verifier.d.ts.map +1 -1
  417. package/dist/auth-verifier.js +2 -2
  418. package/dist/auth-verifier.js.map +1 -1
  419. package/dist/basic-routes.d.ts +3 -3
  420. package/dist/basic-routes.d.ts.map +1 -1
  421. package/dist/basic-routes.js +2 -5
  422. package/dist/basic-routes.js.map +1 -1
  423. package/dist/bsky-app-view.d.ts +15 -0
  424. package/dist/bsky-app-view.d.ts.map +1 -0
  425. package/dist/bsky-app-view.js +43 -0
  426. package/dist/bsky-app-view.js.map +1 -0
  427. package/dist/config/config.js +1 -1
  428. package/dist/config/config.js.map +1 -1
  429. package/dist/context.d.ts +15 -15
  430. package/dist/context.d.ts.map +1 -1
  431. package/dist/context.js +30 -36
  432. package/dist/context.js.map +1 -1
  433. package/dist/crawlers.d.ts.map +1 -1
  434. package/dist/crawlers.js +1 -1
  435. package/dist/crawlers.js.map +1 -1
  436. package/dist/db/db.d.ts +2 -2
  437. package/dist/db/db.d.ts.map +1 -1
  438. package/dist/db/db.js +4 -4
  439. package/dist/db/db.js.map +1 -1
  440. package/dist/db/migrator.d.ts +1 -1
  441. package/dist/db/migrator.d.ts.map +1 -1
  442. package/dist/db/tables/moderation.d.ts +1 -1
  443. package/dist/db/tables/moderation.d.ts.map +1 -1
  444. package/dist/db/util.d.ts.map +1 -1
  445. package/dist/db/util.js +1 -1
  446. package/dist/db/util.js.map +1 -1
  447. package/dist/did-cache/db/index.d.ts.map +1 -1
  448. package/dist/did-cache/db/index.js.map +1 -1
  449. package/dist/disk-blobstore.d.ts +1 -2
  450. package/dist/disk-blobstore.d.ts.map +1 -1
  451. package/dist/disk-blobstore.js +17 -18
  452. package/dist/disk-blobstore.js.map +1 -1
  453. package/dist/error.d.ts.map +1 -1
  454. package/dist/error.js +1 -1
  455. package/dist/error.js.map +1 -1
  456. package/dist/handle/index.d.ts +1 -1
  457. package/dist/handle/index.d.ts.map +1 -1
  458. package/dist/handle/index.js +1 -1
  459. package/dist/handle/index.js.map +1 -1
  460. package/dist/image/image-url-builder.d.ts +8 -0
  461. package/dist/image/image-url-builder.d.ts.map +1 -0
  462. package/dist/image/image-url-builder.js +26 -0
  463. package/dist/image/image-url-builder.js.map +1 -0
  464. package/dist/image/index.d.ts +1 -1
  465. package/dist/image/index.d.ts.map +1 -1
  466. package/dist/image/index.js +1 -1
  467. package/dist/image/index.js.map +1 -1
  468. package/dist/index.d.ts +2 -2
  469. package/dist/index.d.ts.map +1 -1
  470. package/dist/index.js +10 -10
  471. package/dist/index.js.map +1 -1
  472. package/dist/lexicon/lexicons.d.ts +56 -2
  473. package/dist/lexicon/lexicons.d.ts.map +1 -1
  474. package/dist/lexicon/lexicons.js +32 -0
  475. package/dist/lexicon/lexicons.js.map +1 -1
  476. package/dist/lexicon/types/app/bsky/actor/defs.d.ts +19 -1
  477. package/dist/lexicon/types/app/bsky/actor/defs.d.ts.map +1 -1
  478. package/dist/lexicon/types/app/bsky/actor/defs.js +10 -0
  479. package/dist/lexicon/types/app/bsky/actor/defs.js.map +1 -1
  480. package/dist/lexicon/types/app/bsky/feed/postgate.d.ts +1 -0
  481. package/dist/lexicon/types/app/bsky/feed/postgate.d.ts.map +1 -1
  482. package/dist/lexicon/types/app/bsky/feed/postgate.js.map +1 -1
  483. package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts +1 -0
  484. package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts.map +1 -1
  485. package/dist/lexicon/types/app/bsky/feed/threadgate.js.map +1 -1
  486. package/dist/logger.js +2 -5
  487. package/dist/logger.js.map +1 -1
  488. package/dist/mailer/index.d.ts.map +1 -1
  489. package/dist/mailer/index.js.map +1 -1
  490. package/dist/mailer/moderation.d.ts.map +1 -1
  491. package/dist/mailer/moderation.js.map +1 -1
  492. package/dist/oauth/provider.d.ts +1 -5
  493. package/dist/oauth/provider.d.ts.map +1 -1
  494. package/dist/oauth/provider.js +2 -6
  495. package/dist/oauth/provider.js.map +1 -1
  496. package/dist/pipethrough.d.ts +2 -2
  497. package/dist/pipethrough.d.ts.map +1 -1
  498. package/dist/pipethrough.js +1 -1
  499. package/dist/pipethrough.js.map +1 -1
  500. package/dist/read-after-write/types.d.ts +3 -3
  501. package/dist/read-after-write/types.d.ts.map +1 -1
  502. package/dist/read-after-write/util.d.ts +2 -2
  503. package/dist/read-after-write/util.d.ts.map +1 -1
  504. package/dist/read-after-write/util.js +1 -2
  505. package/dist/read-after-write/util.js.map +1 -1
  506. package/dist/read-after-write/viewer.d.ts +16 -31
  507. package/dist/read-after-write/viewer.d.ts.map +1 -1
  508. package/dist/read-after-write/viewer.js +28 -110
  509. package/dist/read-after-write/viewer.js.map +1 -1
  510. package/dist/redis.js +2 -2
  511. package/dist/redis.js.map +1 -1
  512. package/dist/repo/prepare.d.ts +2 -2
  513. package/dist/repo/prepare.d.ts.map +1 -1
  514. package/dist/repo/prepare.js +6 -6
  515. package/dist/repo/prepare.js.map +1 -1
  516. package/dist/repo/types.d.ts +2 -2
  517. package/dist/repo/types.d.ts.map +1 -1
  518. package/dist/scripts/rebuild-repo.d.ts +1 -1
  519. package/dist/scripts/rebuild-repo.d.ts.map +1 -1
  520. package/dist/scripts/rebuild-repo.js +3 -46
  521. package/dist/scripts/rebuild-repo.js.map +1 -1
  522. package/dist/sequencer/db/index.d.ts.map +1 -1
  523. package/dist/sequencer/db/index.js.map +1 -1
  524. package/dist/sequencer/events.d.ts +7 -7
  525. package/dist/sequencer/events.d.ts.map +1 -1
  526. package/dist/sequencer/events.js.map +1 -1
  527. package/dist/sequencer/outbox.d.ts +1 -2
  528. package/dist/sequencer/outbox.d.ts.map +1 -1
  529. package/dist/sequencer/outbox.js +0 -1
  530. package/dist/sequencer/outbox.js.map +1 -1
  531. package/dist/sequencer/sequencer.d.ts +4 -4
  532. package/dist/sequencer/sequencer.d.ts.map +1 -1
  533. package/dist/sequencer/sequencer.js +9 -9
  534. package/dist/sequencer/sequencer.js.map +1 -1
  535. package/dist/util/compression.js.map +1 -1
  536. package/dist/util/params.d.ts.map +1 -1
  537. package/dist/util/params.js +1 -1
  538. package/dist/util/params.js.map +1 -1
  539. package/dist/well-known.d.ts +3 -3
  540. package/dist/well-known.d.ts.map +1 -1
  541. package/dist/well-known.js +2 -5
  542. package/dist/well-known.js.map +1 -1
  543. package/package.json +21 -18
  544. package/src/account-manager/db/index.ts +1 -1
  545. package/src/account-manager/db/schema/authorization-request.ts +1 -1
  546. package/src/account-manager/db/schema/device.ts +1 -1
  547. package/src/account-manager/db/schema/index.ts +7 -7
  548. package/src/account-manager/db/schema/token.ts +1 -2
  549. package/src/account-manager/db/schema/used-refresh-token.ts +1 -1
  550. package/src/account-manager/helpers/account.ts +2 -2
  551. package/src/account-manager/helpers/authorization-request.ts +2 -2
  552. package/src/account-manager/helpers/device-account.ts +1 -2
  553. package/src/account-manager/helpers/device.ts +3 -3
  554. package/src/account-manager/helpers/email-token.ts +1 -1
  555. package/src/account-manager/helpers/invite.ts +1 -1
  556. package/src/account-manager/helpers/password.ts +2 -2
  557. package/src/account-manager/helpers/scrypt.ts +2 -2
  558. package/src/account-manager/helpers/token.ts +1 -1
  559. package/src/account-manager/index.ts +38 -8
  560. package/src/actor-store/actor-store-reader.ts +45 -0
  561. package/src/actor-store/actor-store-resources.ts +8 -0
  562. package/src/actor-store/actor-store-transactor.ts +31 -0
  563. package/src/actor-store/actor-store-writer.ts +17 -0
  564. package/src/actor-store/{index.ts → actor-store.ts} +26 -117
  565. package/src/actor-store/blob/reader.ts +17 -2
  566. package/src/actor-store/blob/transactor.ts +25 -10
  567. package/src/actor-store/db/index.ts +1 -1
  568. package/src/actor-store/db/schema/index.ts +3 -3
  569. package/src/actor-store/migrate.ts +1 -1
  570. package/src/actor-store/preference/transactor.ts +2 -2
  571. package/src/actor-store/record/reader.ts +125 -4
  572. package/src/actor-store/record/transactor.ts +3 -3
  573. package/src/actor-store/repo/reader.ts +1 -1
  574. package/src/actor-store/repo/sql-repo-reader.ts +7 -6
  575. package/src/actor-store/repo/sql-repo-transactor.ts +2 -2
  576. package/src/actor-store/repo/transactor.ts +16 -9
  577. package/src/api/app/bsky/actor/getPreferences.ts +4 -3
  578. package/src/api/app/bsky/actor/getProfile.ts +4 -4
  579. package/src/api/app/bsky/actor/getProfiles.ts +4 -4
  580. package/src/api/app/bsky/actor/index.ts +1 -2
  581. package/src/api/app/bsky/actor/putPreferences.ts +4 -3
  582. package/src/api/app/bsky/feed/getActorLikes.ts +4 -4
  583. package/src/api/app/bsky/feed/getAuthorFeed.ts +5 -5
  584. package/src/api/app/bsky/feed/getFeed.ts +8 -8
  585. package/src/api/app/bsky/feed/getPostThread.ts +14 -14
  586. package/src/api/app/bsky/feed/getTimeline.ts +4 -4
  587. package/src/api/app/bsky/feed/index.ts +1 -1
  588. package/src/api/app/bsky/index.ts +1 -1
  589. package/src/api/app/bsky/notification/index.ts +1 -1
  590. package/src/api/app/bsky/notification/registerPush.ts +9 -8
  591. package/src/api/app/bsky/util/resolver.ts +1 -1
  592. package/src/api/com/atproto/admin/deleteAccount.ts +2 -2
  593. package/src/api/com/atproto/admin/disableAccountInvites.ts +1 -1
  594. package/src/api/com/atproto/admin/disableInviteCodes.ts +1 -1
  595. package/src/api/com/atproto/admin/enableAccountInvites.ts +1 -1
  596. package/src/api/com/atproto/admin/getAccountInfo.ts +2 -3
  597. package/src/api/com/atproto/admin/getAccountInfos.ts +1 -1
  598. package/src/api/com/atproto/admin/getInviteCodes.ts +4 -4
  599. package/src/api/com/atproto/admin/getSubjectStatus.ts +1 -1
  600. package/src/api/com/atproto/admin/index.ts +9 -9
  601. package/src/api/com/atproto/admin/sendEmail.ts +2 -2
  602. package/src/api/com/atproto/admin/updateAccountEmail.ts +1 -1
  603. package/src/api/com/atproto/admin/updateAccountHandle.ts +1 -1
  604. package/src/api/com/atproto/admin/updateAccountPassword.ts +1 -1
  605. package/src/api/com/atproto/admin/updateSubjectStatus.ts +3 -3
  606. package/src/api/com/atproto/admin/util.ts +1 -1
  607. package/src/api/com/atproto/identity/getRecommendedDidCredentials.ts +1 -1
  608. package/src/api/com/atproto/identity/index.ts +3 -3
  609. package/src/api/com/atproto/identity/requestPlcOperationSignature.ts +2 -4
  610. package/src/api/com/atproto/identity/resolveHandle.ts +12 -16
  611. package/src/api/com/atproto/identity/signPlcOperation.ts +2 -4
  612. package/src/api/com/atproto/identity/submitPlcOperation.ts +2 -2
  613. package/src/api/com/atproto/identity/updateHandle.ts +3 -3
  614. package/src/api/com/atproto/index.ts +1 -1
  615. package/src/api/com/atproto/moderation/createReport.ts +4 -4
  616. package/src/api/com/atproto/moderation/index.ts +1 -1
  617. package/src/api/com/atproto/repo/applyWrites.ts +9 -7
  618. package/src/api/com/atproto/repo/createRecord.ts +4 -3
  619. package/src/api/com/atproto/repo/deleteRecord.ts +7 -4
  620. package/src/api/com/atproto/repo/describeRepo.ts +3 -3
  621. package/src/api/com/atproto/repo/getRecord.ts +2 -2
  622. package/src/api/com/atproto/repo/importRepo.ts +12 -27
  623. package/src/api/com/atproto/repo/index.ts +3 -3
  624. package/src/api/com/atproto/repo/listMissingBlobs.ts +1 -1
  625. package/src/api/com/atproto/repo/listRecords.ts +2 -2
  626. package/src/api/com/atproto/repo/putRecord.ts +8 -7
  627. package/src/api/com/atproto/repo/uploadBlob.ts +2 -2
  628. package/src/api/com/atproto/server/activateAccount.ts +2 -3
  629. package/src/api/com/atproto/server/checkAccountStatus.ts +1 -1
  630. package/src/api/com/atproto/server/confirmEmail.ts +1 -3
  631. package/src/api/com/atproto/server/createAccount.ts +6 -7
  632. package/src/api/com/atproto/server/createAppPassword.ts +1 -2
  633. package/src/api/com/atproto/server/createInviteCode.ts +1 -1
  634. package/src/api/com/atproto/server/createInviteCodes.ts +2 -2
  635. package/src/api/com/atproto/server/createSession.ts +1 -2
  636. package/src/api/com/atproto/server/deactivateAccount.ts +1 -1
  637. package/src/api/com/atproto/server/deleteAccount.ts +2 -2
  638. package/src/api/com/atproto/server/deleteSession.ts +1 -1
  639. package/src/api/com/atproto/server/describeServer.ts +1 -1
  640. package/src/api/com/atproto/server/getAccountInviteCodes.ts +2 -4
  641. package/src/api/com/atproto/server/getServiceAuth.ts +4 -4
  642. package/src/api/com/atproto/server/getSession.ts +3 -4
  643. package/src/api/com/atproto/server/index.ts +18 -27
  644. package/src/api/com/atproto/server/listAppPasswords.ts +1 -2
  645. package/src/api/com/atproto/server/refreshSession.ts +2 -3
  646. package/src/api/com/atproto/server/requestAccountDelete.ts +1 -3
  647. package/src/api/com/atproto/server/requestEmailConfirmation.ts +1 -3
  648. package/src/api/com/atproto/server/requestEmailUpdate.ts +2 -4
  649. package/src/api/com/atproto/server/requestPasswordReset.ts +1 -1
  650. package/src/api/com/atproto/server/reserveSigningKey.ts +1 -1
  651. package/src/api/com/atproto/server/resetPassword.ts +2 -2
  652. package/src/api/com/atproto/server/revokeAppPassword.ts +1 -2
  653. package/src/api/com/atproto/server/updateEmail.ts +2 -4
  654. package/src/api/com/atproto/server/util.ts +3 -3
  655. package/src/api/com/atproto/sync/deprecated/getCheckout.ts +1 -1
  656. package/src/api/com/atproto/sync/deprecated/getHead.ts +1 -1
  657. package/src/api/com/atproto/sync/getBlob.ts +4 -4
  658. package/src/api/com/atproto/sync/getBlocks.ts +2 -2
  659. package/src/api/com/atproto/sync/getLatestCommit.ts +1 -1
  660. package/src/api/com/atproto/sync/getRecord.ts +4 -4
  661. package/src/api/com/atproto/sync/getRepo.ts +4 -4
  662. package/src/api/com/atproto/sync/getRepoStatus.ts +2 -2
  663. package/src/api/com/atproto/sync/index.ts +5 -5
  664. package/src/api/com/atproto/sync/listBlobs.ts +2 -2
  665. package/src/api/com/atproto/sync/listRepos.ts +3 -3
  666. package/src/api/com/atproto/sync/subscribeRepos.ts +2 -2
  667. package/src/api/com/atproto/sync/util.ts +1 -1
  668. package/src/api/com/atproto/temp/checkSignupQueue.ts +2 -2
  669. package/src/api/com/atproto/temp/index.ts +1 -1
  670. package/src/api/index.ts +2 -2
  671. package/src/api/proxy.ts +1 -1
  672. package/src/auth-routes.ts +2 -3
  673. package/src/auth-verifier.ts +2 -3
  674. package/src/basic-routes.ts +4 -4
  675. package/src/bsky-app-view.ts +26 -0
  676. package/src/config/config.ts +1 -1
  677. package/src/config/env.ts +1 -1
  678. package/src/context.ts +49 -46
  679. package/src/crawlers.ts +1 -1
  680. package/src/db/db.ts +7 -7
  681. package/src/db/migrator.ts +1 -1
  682. package/src/db/tables/moderation.ts +2 -2
  683. package/src/db/util.ts +2 -2
  684. package/src/did-cache/db/index.ts +1 -1
  685. package/src/did-cache/index.ts +1 -1
  686. package/src/disk-blobstore.ts +6 -8
  687. package/src/error.ts +2 -2
  688. package/src/handle/index.ts +2 -2
  689. package/src/image/image-url-builder.ts +16 -0
  690. package/src/image/index.ts +2 -2
  691. package/src/index.ts +15 -13
  692. package/src/lexicon/lexicons.ts +37 -0
  693. package/src/lexicon/types/app/bsky/actor/defs.ts +36 -0
  694. package/src/lexicon/types/app/bsky/feed/postgate.ts +1 -0
  695. package/src/lexicon/types/app/bsky/feed/threadgate.ts +1 -0
  696. package/src/logger.ts +1 -1
  697. package/src/mailer/index.ts +1 -2
  698. package/src/mailer/moderation.ts +1 -1
  699. package/src/mailer/templates/confirm-email.d.ts +1 -1
  700. package/src/mailer/templates/delete-account.d.ts +1 -1
  701. package/src/mailer/templates/plc-operation.d.ts +1 -1
  702. package/src/mailer/templates/reset-password.d.ts +1 -1
  703. package/src/mailer/templates/update-email.d.ts +1 -1
  704. package/src/oauth/provider.ts +1 -17
  705. package/src/pipethrough.ts +4 -6
  706. package/src/read-after-write/types.ts +3 -3
  707. package/src/read-after-write/util.ts +3 -5
  708. package/src/read-after-write/viewer.ts +50 -124
  709. package/src/redis.ts +1 -1
  710. package/src/repo/prepare.ts +18 -18
  711. package/src/repo/types.ts +2 -2
  712. package/src/scripts/rebuild-repo.ts +4 -61
  713. package/src/sequencer/db/index.ts +1 -1
  714. package/src/sequencer/events.ts +3 -3
  715. package/src/sequencer/outbox.ts +1 -3
  716. package/src/sequencer/sequencer.ts +12 -12
  717. package/src/util/compression.ts +1 -1
  718. package/src/util/params.ts +1 -1
  719. package/src/well-known.ts +4 -4
  720. package/tests/_util.ts +5 -5
  721. package/tests/account-deletion.test.ts +7 -7
  722. package/tests/account-migration.test.ts +3 -3
  723. package/tests/account.test.ts +2 -2
  724. package/tests/app-passwords.test.ts +1 -1
  725. package/tests/blob-deletes.test.ts +4 -6
  726. package/tests/create-post.test.ts +3 -3
  727. package/tests/crud.test.ts +12 -16
  728. package/tests/email-confirmation.test.ts +5 -5
  729. package/tests/entryway.test.ts +5 -5
  730. package/tests/file-uploads.test.ts +7 -7
  731. package/tests/handles.test.ts +3 -3
  732. package/tests/invites-admin.test.ts +1 -1
  733. package/tests/moderation.test.ts +2 -2
  734. package/tests/moderator-auth.test.ts +4 -4
  735. package/tests/oauth.test.ts +4 -4
  736. package/tests/plc-operations.test.ts +6 -6
  737. package/tests/preferences.test.ts +2 -2
  738. package/tests/proxied/admin.test.ts +2 -2
  739. package/tests/proxied/feedgen.test.ts +4 -4
  740. package/tests/proxied/notif.test.ts +5 -5
  741. package/tests/proxied/procedures.test.ts +1 -1
  742. package/tests/proxied/proxy-catchall.test.ts +6 -6
  743. package/tests/proxied/proxy-header.test.ts +5 -5
  744. package/tests/proxied/read-after-write.test.ts +6 -6
  745. package/tests/proxied/views.test.ts +3 -3
  746. package/tests/races.test.ts +2 -2
  747. package/tests/rate-limits.test.ts +1 -1
  748. package/tests/sequencer.test.ts +7 -7
  749. package/tests/server.test.ts +4 -4
  750. package/tests/sync/list.test.ts +1 -1
  751. package/tests/sync/subscribe-repos.test.ts +9 -9
  752. package/tests/sync/sync.test.ts +3 -3
  753. package/tests/takedown-appeal.test.ts +1 -1
  754. package/tsconfig.build.tsbuildinfo +1 -1
  755. package/dist/actor-store/index.d.ts +0 -65
  756. package/dist/actor-store/index.d.ts.map +0 -1
  757. package/dist/actor-store/index.js.map +0 -1
  758. package/dist/oauth/detailed-account-store.d.ts +0 -27
  759. package/dist/oauth/detailed-account-store.d.ts.map +0 -1
  760. package/dist/oauth/detailed-account-store.js +0 -76
  761. package/dist/oauth/detailed-account-store.js.map +0 -1
  762. package/src/oauth/detailed-account-store.ts +0 -96
@@ -0,0 +1,31 @@
1
+ import { Keypair } from '@atproto/crypto'
2
+ import { ActorStoreResources } from './actor-store-resources'
3
+ import { ActorDb } from './db'
4
+ import { PreferenceTransactor } from './preference/transactor'
5
+ import { RecordTransactor } from './record/transactor'
6
+ import { RepoTransactor } from './repo/transactor'
7
+
8
+ export class ActorStoreTransactor {
9
+ public readonly record: RecordTransactor
10
+ public readonly repo: RepoTransactor
11
+ public readonly pref: PreferenceTransactor
12
+
13
+ constructor(
14
+ public readonly did: string,
15
+ protected readonly db: ActorDb,
16
+ protected readonly keypair: Keypair,
17
+ protected readonly resources: ActorStoreResources,
18
+ ) {
19
+ const blobstore = resources.blobstore(did)
20
+
21
+ this.record = new RecordTransactor(db, blobstore)
22
+ this.pref = new PreferenceTransactor(db)
23
+ this.repo = new RepoTransactor(
24
+ db,
25
+ blobstore,
26
+ did,
27
+ keypair,
28
+ resources.backgroundQueue,
29
+ )
30
+ }
31
+ }
@@ -0,0 +1,17 @@
1
+ import { ActorStoreTransactor } from './actor-store-transactor'
2
+
3
+ export class ActorStoreWriter extends ActorStoreTransactor {
4
+ async transact<T>(
5
+ fn: (fn: ActorStoreTransactor) => T | PromiseLike<T>,
6
+ ): Promise<T> {
7
+ return this.db.transaction((dbTxn) => {
8
+ const transactor = new ActorStoreTransactor(
9
+ this.did,
10
+ dbTxn,
11
+ this.keypair,
12
+ this.resources,
13
+ )
14
+ return fn(transactor)
15
+ })
16
+ }
17
+ }
@@ -1,35 +1,23 @@
1
- import path from 'path'
2
- import assert from 'assert'
3
- import fs from 'fs/promises'
4
- import * as crypto from '@atproto/crypto'
5
- import { Keypair, ExportableKeypair } from '@atproto/crypto'
6
- import { BlobStore } from '@atproto/repo'
1
+ import assert from 'node:assert'
2
+ import fs, { mkdir } from 'node:fs/promises'
3
+ import path from 'node:path'
7
4
  import {
8
5
  chunkArray,
9
6
  fileExists,
10
7
  readIfExists,
11
8
  rmIfExists,
12
9
  } from '@atproto/common'
13
- import { ActorDb, getDb, getMigrator } from './db'
14
- import { BackgroundQueue } from '../background'
15
- import { RecordReader } from './record/reader'
16
- import { PreferenceReader } from './preference/reader'
17
- import { RepoReader } from './repo/reader'
18
- import { RepoTransactor } from './repo/transactor'
19
- import { PreferenceTransactor } from './preference/transactor'
10
+ import * as crypto from '@atproto/crypto'
11
+ import { ExportableKeypair, Keypair } from '@atproto/crypto'
20
12
  import { InvalidRequestError } from '@atproto/xrpc-server'
21
- import { RecordTransactor } from './record/transactor'
22
- import { CID } from 'multiformats/cid'
23
- import DiskBlobStore from '../disk-blobstore'
24
- import { mkdir } from 'fs/promises'
25
13
  import { ActorStoreConfig } from '../config'
26
14
  import { retrySqlite } from '../db'
27
-
28
- type ActorStoreResources = {
29
- blobstore: (did: string) => BlobStore
30
- backgroundQueue: BackgroundQueue
31
- reservedKeyDir?: string
32
- }
15
+ import { DiskBlobStore } from '../disk-blobstore'
16
+ import { ActorStoreReader } from './actor-store-reader'
17
+ import { ActorStoreResources } from './actor-store-resources'
18
+ import { ActorStoreTransactor } from './actor-store-transactor'
19
+ import { ActorStoreWriter } from './actor-store-writer'
20
+ import { ActorDb, getDb, getMigrator } from './db'
33
21
 
34
22
  export class ActorStore {
35
23
  reservedKeyDir: string
@@ -82,50 +70,39 @@ export class ActorStore {
82
70
  return db
83
71
  }
84
72
 
85
- async read<T>(did: string, fn: ActorStoreReadFn<T>) {
73
+ async read<T>(did: string, fn: (fn: ActorStoreReader) => T | PromiseLike<T>) {
86
74
  const db = await this.openDb(did)
87
75
  try {
88
- const reader = createActorReader(did, db, this.resources, () =>
89
- this.keypair(did),
90
- )
91
- return await fn(reader)
76
+ const getKeypair = () => this.keypair(did)
77
+ return await fn(new ActorStoreReader(did, db, this.resources, getKeypair))
92
78
  } finally {
93
79
  db.close()
94
80
  }
95
81
  }
96
82
 
97
- async transact<T>(did: string, fn: ActorStoreTransactFn<T>) {
83
+ async transact<T>(
84
+ did: string,
85
+ fn: (fn: ActorStoreTransactor) => T | PromiseLike<T>,
86
+ ) {
98
87
  const keypair = await this.keypair(did)
99
88
  const db = await this.openDb(did)
100
89
  try {
101
90
  return await db.transaction((dbTxn) => {
102
- const store = createActorTransactor(did, dbTxn, keypair, this.resources)
103
- return fn(store)
91
+ return fn(new ActorStoreTransactor(did, dbTxn, keypair, this.resources))
104
92
  })
105
93
  } finally {
106
94
  db.close()
107
95
  }
108
96
  }
109
97
 
110
- async writeNoTransaction<T>(did: string, fn: ActorStoreWriterFn<T>) {
98
+ async writeNoTransaction<T>(
99
+ did: string,
100
+ fn: (fn: ActorStoreWriter) => T | PromiseLike<T>,
101
+ ) {
111
102
  const keypair = await this.keypair(did)
112
103
  const db = await this.openDb(did)
113
104
  try {
114
- const writer = createActorTransactor(did, db, keypair, this.resources)
115
- return await fn({
116
- ...writer,
117
- transact: async <T>(fn: ActorStoreTransactFn<T>): Promise<T> => {
118
- return db.transaction((dbTxn) => {
119
- const transactor = createActorTransactor(
120
- did,
121
- dbTxn,
122
- keypair,
123
- this.resources,
124
- )
125
- return fn(transactor)
126
- })
127
- },
128
- })
105
+ return await fn(new ActorStoreWriter(did, db, keypair, this.resources))
129
106
  } finally {
130
107
  db.close()
131
108
  }
@@ -157,10 +134,9 @@ export class ActorStore {
157
134
  if (blobstore instanceof DiskBlobStore) {
158
135
  await blobstore.deleteAll()
159
136
  } else {
160
- const blobRows = await this.read(did, (store) =>
161
- store.db.db.selectFrom('blob').select('cid').execute(),
137
+ const cids = await this.read(did, async (store) =>
138
+ store.repo.blob.getBlobCids(),
162
139
  )
163
- const cids = blobRows.map((row) => CID.parse(row.cid))
164
140
  await Promise.allSettled(
165
141
  chunkArray(cids, 500).map((chunk) => blobstore.deleteMany(chunk)),
166
142
  )
@@ -226,73 +202,6 @@ const loadKey = async (loc: string): Promise<ExportableKeypair | undefined> => {
226
202
  return crypto.Secp256k1Keypair.import(privKey, { exportable: true })
227
203
  }
228
204
 
229
- const createActorTransactor = (
230
- did: string,
231
- db: ActorDb,
232
- keypair: Keypair,
233
- resources: ActorStoreResources,
234
- ): ActorStoreTransactor => {
235
- const { blobstore, backgroundQueue } = resources
236
- const userBlobstore = blobstore(did)
237
- return {
238
- did,
239
- db,
240
- repo: new RepoTransactor(db, did, keypair, userBlobstore, backgroundQueue),
241
- record: new RecordTransactor(db, userBlobstore),
242
- pref: new PreferenceTransactor(db),
243
- }
244
- }
245
-
246
- const createActorReader = (
247
- did: string,
248
- db: ActorDb,
249
- resources: ActorStoreResources,
250
- getKeypair: () => Promise<Keypair>,
251
- ): ActorStoreReader => {
252
- const { blobstore } = resources
253
- return {
254
- did,
255
- db,
256
- repo: new RepoReader(db, blobstore(did)),
257
- record: new RecordReader(db),
258
- pref: new PreferenceReader(db),
259
- keypair: getKeypair,
260
- transact: async <T>(fn: ActorStoreTransactFn<T>): Promise<T> => {
261
- const keypair = await getKeypair()
262
- return db.transaction((dbTxn) => {
263
- const store = createActorTransactor(did, dbTxn, keypair, resources)
264
- return fn(store)
265
- })
266
- },
267
- }
268
- }
269
-
270
- export type ActorStoreReadFn<T> = (fn: ActorStoreReader) => Promise<T>
271
- export type ActorStoreTransactFn<T> = (fn: ActorStoreTransactor) => Promise<T>
272
- export type ActorStoreWriterFn<T> = (fn: ActorStoreWriter) => Promise<T>
273
-
274
- export type ActorStoreReader = {
275
- did: string
276
- db: ActorDb
277
- repo: RepoReader
278
- record: RecordReader
279
- pref: PreferenceReader
280
- keypair: () => Promise<Keypair>
281
- transact: <T>(fn: ActorStoreTransactFn<T>) => Promise<T>
282
- }
283
-
284
- export type ActorStoreTransactor = {
285
- did: string
286
- db: ActorDb
287
- repo: RepoTransactor
288
- record: RecordTransactor
289
- pref: PreferenceTransactor
290
- }
291
-
292
- export type ActorStoreWriter = ActorStoreTransactor & {
293
- transact: <T>(fn: ActorStoreTransactFn<T>) => Promise<T>
294
- }
295
-
296
205
  function assertSafePathPart(part: string) {
297
206
  const normalized = path.normalize(part)
298
207
  assert(
@@ -1,10 +1,10 @@
1
- import stream from 'stream'
1
+ import stream from 'node:stream'
2
2
  import { CID } from 'multiformats/cid'
3
3
  import { BlobNotFoundError, BlobStore } from '@atproto/repo'
4
4
  import { InvalidRequestError } from '@atproto/xrpc-server'
5
- import { ActorDb } from '../db'
6
5
  import { countAll, countDistinct, notSoftDeletedClause } from '../../db/util'
7
6
  import { StatusAttr } from '../../lexicon/types/com/atproto/admin/defs'
7
+ import { ActorDb } from '../db'
8
8
 
9
9
  export class BlobReader {
10
10
  constructor(
@@ -95,6 +95,16 @@ export class BlobReader {
95
95
  return res.map((row) => row.recordUri)
96
96
  }
97
97
 
98
+ async getBlobsForRecord(recordUri: string): Promise<string[]> {
99
+ const res = await this.db.db
100
+ .selectFrom('blob')
101
+ .innerJoin('record_blob', 'record_blob.blobCid', 'blob.cid')
102
+ .where('recordUri', '=', recordUri)
103
+ .select('blob.cid')
104
+ .execute()
105
+ return res.map((row) => row.cid)
106
+ }
107
+
98
108
  async blobCount(): Promise<number> {
99
109
  const res = await this.db.db
100
110
  .selectFrom('blob')
@@ -138,4 +148,9 @@ export class BlobReader {
138
148
  recordUri: row.recordUri,
139
149
  }))
140
150
  }
151
+
152
+ async getBlobCids() {
153
+ const blobRows = await this.db.db.selectFrom('blob').select('cid').execute()
154
+ return blobRows.map((row) => CID.parse(row.cid))
155
+ }
141
156
  }
@@ -1,24 +1,24 @@
1
- import stream from 'stream'
2
- import crypto from 'crypto'
3
- import { CID } from 'multiformats/cid'
1
+ import crypto from 'node:crypto'
2
+ import stream from 'node:stream'
4
3
  import bytes from 'bytes'
5
4
  import { fromStream as fileTypeFromStream } from 'file-type'
5
+ import { CID } from 'multiformats/cid'
6
+ import { cloneStream, sha256RawToCid, streamSize } from '@atproto/common'
7
+ import { BlobRef } from '@atproto/lexicon'
6
8
  import { BlobNotFoundError, BlobStore, WriteOpAction } from '@atproto/repo'
7
9
  import { AtUri } from '@atproto/syntax'
8
- import { cloneStream, sha256RawToCid, streamSize } from '@atproto/common'
9
10
  import { InvalidRequestError } from '@atproto/xrpc-server'
10
- import { BlobRef } from '@atproto/lexicon'
11
- import { ActorDb, Blob as BlobTable } from '../db'
11
+ import { BackgroundQueue } from '../../background'
12
+ import * as img from '../../image'
13
+ import { StatusAttr } from '../../lexicon/types/com/atproto/admin/defs'
12
14
  import {
13
15
  PreparedBlobRef,
14
- PreparedWrite,
15
16
  PreparedDelete,
16
17
  PreparedUpdate,
18
+ PreparedWrite,
17
19
  } from '../../repo/types'
18
- import * as img from '../../image'
19
- import { BackgroundQueue } from '../../background'
20
+ import { ActorDb, Blob as BlobTable } from '../db'
20
21
  import { BlobReader } from './reader'
21
- import { StatusAttr } from '../../lexicon/types/com/atproto/admin/defs'
22
22
 
23
23
  export type BlobMetadata = {
24
24
  tempKey: string
@@ -38,6 +38,21 @@ export class BlobTransactor extends BlobReader {
38
38
  super(db, blobstore)
39
39
  }
40
40
 
41
+ async insertBlobs(recordUri: string, blobs: Iterable<BlobRef>) {
42
+ const values = Array.from(blobs, (cid) => ({
43
+ recordUri,
44
+ blobCid: cid.ref.toString(),
45
+ }))
46
+
47
+ if (values.length) {
48
+ await this.db.db
49
+ .insertInto('record_blob')
50
+ .values(values)
51
+ .onConflict((oc) => oc.doNothing())
52
+ .execute()
53
+ }
54
+ }
55
+
41
56
  async uploadBlobAndGetMetadata(
42
57
  userSuggestedMime: string,
43
58
  blobStream: stream.Readable,
@@ -1,6 +1,6 @@
1
- import { DatabaseSchema } from './schema'
2
1
  import { Database, Migrator } from '../../db'
3
2
  import migrations from './migrations'
3
+ import { DatabaseSchema } from './schema'
4
4
  export * from './schema'
5
5
 
6
6
  export type ActorDb = Database<DatabaseSchema>
@@ -1,10 +1,10 @@
1
1
  import * as accountPref from './account-pref'
2
- import * as repoRoot from './repo-root'
3
- import * as record from './record'
4
2
  import * as backlink from './backlink'
5
- import * as repoBlock from './repo-block'
6
3
  import * as blob from './blob'
4
+ import * as record from './record'
7
5
  import * as recordBlob from './record-blob'
6
+ import * as repoBlock from './repo-block'
7
+ import * as repoRoot from './repo-root'
8
8
 
9
9
  export type DatabaseSchema = accountPref.PartialDB &
10
10
  repoRoot.PartialDB &
@@ -1,6 +1,6 @@
1
1
  import { sql } from 'kysely'
2
- import AppContext from '../context'
3
2
  import PQueue from 'p-queue'
3
+ import { AppContext } from '../context'
4
4
 
5
5
  export const forEachActorStore = async (
6
6
  ctx: AppContext,
@@ -1,10 +1,10 @@
1
1
  import { InvalidRequestError } from '@atproto/xrpc-server'
2
+ import { AuthScope } from '../../auth-verifier'
2
3
  import {
3
- PreferenceReader,
4
4
  AccountPreference,
5
+ PreferenceReader,
5
6
  prefMatchNamespace,
6
7
  } from './reader'
7
- import { AuthScope } from '../../auth-verifier'
8
8
  import { prefInScope } from './util'
9
9
 
10
10
  export class PreferenceTransactor extends PreferenceReader {
@@ -1,12 +1,21 @@
1
+ import { CID } from 'multiformats/cid'
2
+ import { RepoRecord } from '@atproto/lexicon'
3
+ import { CidSet, cborToLexRecord, formatDataKey } from '@atproto/repo'
1
4
  import * as syntax from '@atproto/syntax'
2
5
  import { AtUri, ensureValidAtUri } from '@atproto/syntax'
3
- import { cborToLexRecord } from '@atproto/repo'
4
- import { CID } from 'multiformats/cid'
5
6
  import { countAll, notSoftDeletedClause } from '../../db/util'
6
7
  import { ids } from '../../lexicon/lexicons'
7
- import { ActorDb, Backlink } from '../db'
8
+ import { Record as ProfileRecord } from '../../lexicon/types/app/bsky/actor/profile'
9
+ import { Record as PostRecord } from '../../lexicon/types/app/bsky/feed/post'
8
10
  import { StatusAttr } from '../../lexicon/types/com/atproto/admin/defs'
9
- import { RepoRecord } from '@atproto/lexicon'
11
+ import { LocalRecords } from '../../read-after-write/types'
12
+ import { ActorDb, Backlink } from '../db'
13
+
14
+ export type RecordDescript = {
15
+ uri: string
16
+ path: string
17
+ cid: CID
18
+ }
10
19
 
11
20
  export class RecordReader {
12
21
  constructor(public db: ActorDb) {}
@@ -19,6 +28,30 @@ export class RecordReader {
19
28
  return res?.count ?? 0
20
29
  }
21
30
 
31
+ async listAll(): Promise<RecordDescript[]> {
32
+ const records: RecordDescript[] = []
33
+ let cursor: string | undefined = ''
34
+ while (cursor !== undefined) {
35
+ const res = await this.db.db
36
+ .selectFrom('record')
37
+ .select(['uri', 'cid'])
38
+ .where('uri', '>', cursor)
39
+ .orderBy('uri', 'asc')
40
+ .limit(1000)
41
+ .execute()
42
+ for (const row of res) {
43
+ const parsed = new AtUri(row.uri)
44
+ records.push({
45
+ uri: row.uri,
46
+ path: formatDataKey(parsed.collection, parsed.rkey),
47
+ cid: CID.parse(row.cid),
48
+ })
49
+ }
50
+ cursor = res.at(-1)?.uri
51
+ }
52
+ return records
53
+ }
54
+
22
55
  async listCollections(): Promise<string[]> {
23
56
  const collections = await this.db.db
24
57
  .selectFrom('record')
@@ -194,6 +227,94 @@ export class RecordReader {
194
227
  .flat()
195
228
  .map(({ rkey }) => AtUri.make(uri.hostname, uri.collection, rkey))
196
229
  }
230
+
231
+ async listExistingBlocks(): Promise<CidSet> {
232
+ const cids = new CidSet()
233
+ let cursor: string | undefined = ''
234
+ while (cursor !== undefined) {
235
+ const res = await this.db.db
236
+ .selectFrom('repo_block')
237
+ .select('cid')
238
+ .where('cid', '>', cursor)
239
+ .orderBy('cid', 'asc')
240
+ .limit(1000)
241
+ .execute()
242
+ for (const row of res) {
243
+ cids.add(CID.parse(row.cid))
244
+ }
245
+ cursor = res.at(-1)?.cid
246
+ }
247
+ return cids
248
+ }
249
+
250
+ async getProfileRecord() {
251
+ const row = await this.db.db
252
+ .selectFrom('record')
253
+ .leftJoin('repo_block', 'repo_block.cid', 'record.cid')
254
+ .where('record.collection', '=', ids.AppBskyActorProfile)
255
+ .where('record.rkey', '=', 'self')
256
+ .selectAll()
257
+ .executeTakeFirst()
258
+
259
+ if (!row?.content) return null
260
+
261
+ return cborToLexRecord(row.content) as ProfileRecord
262
+ }
263
+
264
+ async getRecordsSinceRev(rev: string): Promise<LocalRecords> {
265
+ const result: LocalRecords = { count: 0, profile: null, posts: [] }
266
+
267
+ const res = await this.db.db
268
+ .selectFrom('record')
269
+ .innerJoin('repo_block', 'repo_block.cid', 'record.cid')
270
+ .select([
271
+ 'repo_block.content',
272
+ 'uri',
273
+ 'repo_block.cid',
274
+ 'record.indexedAt',
275
+ ])
276
+ .where('record.repoRev', '>', rev)
277
+ .limit(10)
278
+ .orderBy('record.repoRev', 'asc')
279
+ .execute()
280
+
281
+ // sanity check to ensure that the clock received is not before _all_ local records (for instance in case of account migration)
282
+ if (res.length > 0) {
283
+ const sanityCheckRes = await this.db.db
284
+ .selectFrom('record')
285
+ .selectAll()
286
+ .where('record.repoRev', '<=', rev)
287
+ .limit(1)
288
+ .executeTakeFirst()
289
+
290
+ if (!sanityCheckRes) {
291
+ return result
292
+ }
293
+ }
294
+
295
+ for (const cur of res) {
296
+ result.count++
297
+
298
+ const uri = new AtUri(cur.uri)
299
+ if (uri.collection === ids.AppBskyActorProfile && uri.rkey === 'self') {
300
+ result.profile = {
301
+ uri,
302
+ cid: CID.parse(cur.cid),
303
+ indexedAt: cur.indexedAt,
304
+ record: cborToLexRecord(cur.content) as ProfileRecord,
305
+ }
306
+ } else if (uri.collection === ids.AppBskyFeedPost) {
307
+ result.posts.push({
308
+ uri,
309
+ cid: CID.parse(cur.cid),
310
+ indexedAt: cur.indexedAt,
311
+ record: cborToLexRecord(cur.content) as PostRecord,
312
+ })
313
+ }
314
+ }
315
+
316
+ return result
317
+ }
197
318
  }
198
319
 
199
320
  // @NOTE in the future this can be replaced with a more generic routine that pulls backlinks based on lex docs.
@@ -1,11 +1,11 @@
1
1
  import { CID } from 'multiformats/cid'
2
- import { AtUri } from '@atproto/syntax'
2
+ import { RepoRecord } from '@atproto/lexicon'
3
3
  import { BlobStore, WriteOpAction } from '@atproto/repo'
4
+ import { AtUri } from '@atproto/syntax'
5
+ import { StatusAttr } from '../../lexicon/types/com/atproto/admin/defs'
4
6
  import { dbLogger as log } from '../../logger'
5
7
  import { ActorDb, Backlink } from '../db'
6
8
  import { RecordReader, getBacklinks } from './reader'
7
- import { StatusAttr } from '../../lexicon/types/com/atproto/admin/defs'
8
- import { RepoRecord } from '@atproto/lexicon'
9
9
 
10
10
  export class RecordTransactor extends RecordReader {
11
11
  constructor(
@@ -1,8 +1,8 @@
1
1
  import { BlobStore } from '@atproto/repo'
2
- import { SqlRepoReader } from './sql-repo-reader'
3
2
  import { BlobReader } from '../blob/reader'
4
3
  import { ActorDb } from '../db'
5
4
  import { RecordReader } from '../record/reader'
5
+ import { SqlRepoReader } from './sql-repo-reader'
6
6
 
7
7
  export class RepoReader {
8
8
  blob: BlobReader
@@ -1,14 +1,14 @@
1
+ import { sql } from 'kysely'
2
+ import { CID } from 'multiformats/cid'
3
+ import { chunkArray, wait } from '@atproto/common'
1
4
  import {
2
5
  BlockMap,
3
6
  CidSet,
4
7
  ReadableBlockstore,
5
8
  writeCarStream,
6
9
  } from '@atproto/repo'
7
- import { chunkArray, wait } from '@atproto/common'
8
- import { CID } from 'multiformats/cid'
9
- import { ActorDb } from '../db'
10
- import { sql } from 'kysely'
11
10
  import { countAll } from '../../db'
11
+ import { ActorDb } from '../db'
12
12
 
13
13
  export class SqlRepoReader extends ReadableBlockstore {
14
14
  cache: BlockMap = new BlockMap()
@@ -19,13 +19,14 @@ export class SqlRepoReader extends ReadableBlockstore {
19
19
 
20
20
  async getRoot(): Promise<CID> {
21
21
  const root = await this.getRootDetailed()
22
- return root?.cid ?? null
22
+ return root.cid
23
23
  }
24
24
 
25
25
  async getRootDetailed(): Promise<{ cid: CID; rev: string }> {
26
26
  const res = await this.db.db
27
27
  .selectFrom('repo_root')
28
- .selectAll()
28
+ .select(['cid', 'rev'])
29
+ .limit(1)
29
30
  .executeTakeFirstOrThrow()
30
31
  return {
31
32
  cid: CID.parse(res.cid),
@@ -1,6 +1,6 @@
1
- import { CommitData, RepoStorage, BlockMap } from '@atproto/repo'
2
- import { chunkArray } from '@atproto/common'
3
1
  import { CID } from 'multiformats/cid'
2
+ import { chunkArray } from '@atproto/common'
3
+ import { BlockMap, CommitData, RepoStorage } from '@atproto/repo'
4
4
  import { ActorDb, RepoBlock } from '../db'
5
5
  import { SqlRepoReader } from './sql-repo-reader'
6
6
 
@@ -1,9 +1,10 @@
1
1
  import { CID } from 'multiformats/cid'
2
2
  import * as crypto from '@atproto/crypto'
3
3
  import { BlobStore, CommitData, Repo, WriteOpAction } from '@atproto/repo'
4
- import { InvalidRequestError } from '@atproto/xrpc-server'
5
4
  import { AtUri } from '@atproto/syntax'
6
- import { SqlRepoTransactor } from './sql-repo-transactor'
5
+ import { InvalidRequestError } from '@atproto/xrpc-server'
6
+ import { BackgroundQueue } from '../../background'
7
+ import { createWriteToOp, writeToOp } from '../../repo'
7
8
  import {
8
9
  BadCommitSwapError,
9
10
  BadRecordSwapError,
@@ -11,31 +12,37 @@ import {
11
12
  PreparedWrite,
12
13
  } from '../../repo/types'
13
14
  import { BlobTransactor } from '../blob/transactor'
14
- import { createWriteToOp, writeToOp } from '../../repo'
15
- import { BackgroundQueue } from '../../background'
16
15
  import { ActorDb } from '../db'
17
16
  import { RecordTransactor } from '../record/transactor'
18
17
  import { RepoReader } from './reader'
18
+ import { SqlRepoTransactor } from './sql-repo-transactor'
19
19
 
20
20
  export class RepoTransactor extends RepoReader {
21
21
  blob: BlobTransactor
22
22
  record: RecordTransactor
23
23
  storage: SqlRepoTransactor
24
- now: string
25
24
 
26
25
  constructor(
27
26
  public db: ActorDb,
27
+ public blobstore: BlobStore,
28
28
  public did: string,
29
29
  public signingKey: crypto.Keypair,
30
- public blobstore: BlobStore,
31
30
  public backgroundQueue: BackgroundQueue,
32
- now?: string,
31
+ public now: string = new Date().toISOString(),
33
32
  ) {
34
33
  super(db, blobstore)
35
34
  this.blob = new BlobTransactor(db, blobstore, backgroundQueue)
36
35
  this.record = new RecordTransactor(db, blobstore)
37
- this.now = now ?? new Date().toISOString()
38
- this.storage = new SqlRepoTransactor(db, this.did, this.now)
36
+ this.storage = new SqlRepoTransactor(db, did, now)
37
+ }
38
+
39
+ async maybeLoadRepo(): Promise<Repo | null> {
40
+ const res = await this.db.db
41
+ .selectFrom('repo_root')
42
+ .select('cid')
43
+ .limit(1)
44
+ .executeTakeFirst()
45
+ return res ? Repo.load(this.storage, CID.parse(res.cid)) : null
39
46
  }
40
47
 
41
48
  async createRepo(writes: PreparedCreate[]): Promise<CommitData> {