@clioplaylists/clio 0.1.5 → 0.1.7

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 (294) hide show
  1. package/dist/.env +7 -0
  2. package/dist/api/com/clioplaylists/alpha/actor/getProfile.d.ts +0 -0
  3. package/dist/api/com/clioplaylists/alpha/actor/getProfile.js +37 -0
  4. package/dist/api/com/clioplaylists/alpha/feed/getSongs.d.ts +0 -0
  5. package/dist/api/com/clioplaylists/alpha/feed/getSongs.js +37 -0
  6. package/dist/api/health.d.ts +3 -0
  7. package/dist/api/health.js +25 -0
  8. package/dist/api/index.d.ts +4 -0
  9. package/dist/api/index.js +6 -0
  10. package/dist/api/util.d.ts +9 -0
  11. package/dist/api/util.js +13 -0
  12. package/dist/auth-verifier.d.ts +92 -0
  13. package/dist/auth-verifier.js +365 -0
  14. package/dist/client.d.ts +9 -0
  15. package/dist/client.js +33 -0
  16. package/dist/config.d.ts +21 -0
  17. package/dist/config.js +49 -0
  18. package/dist/context.d.ts +11 -0
  19. package/dist/context.js +12 -0
  20. package/dist/dataplane/client.d.ts +27 -0
  21. package/dist/dataplane/client.js +120 -0
  22. package/dist/dataplane/index.d.ts +2 -0
  23. package/dist/dataplane/index.js +2 -0
  24. package/dist/dataplane/server/background.d.ts +13 -0
  25. package/dist/dataplane/server/background.js +30 -0
  26. package/dist/dataplane/server/db/database-schema.d.ts +13 -0
  27. package/dist/dataplane/server/db/database-schema.js +1 -0
  28. package/dist/dataplane/server/db/db.d.ts +32 -0
  29. package/dist/dataplane/server/db/db.js +152 -0
  30. package/dist/dataplane/server/db/index.d.ts +1 -0
  31. package/dist/dataplane/server/db/index.js +1 -0
  32. package/dist/dataplane/server/db/migrations/20230309T045948368Z-init.d.ts +3 -0
  33. package/dist/dataplane/server/db/migrations/20230309T045948368Z-init.js +113 -0
  34. package/dist/dataplane/server/db/migrations/20230420T211446071Z-did-cache.d.ts +3 -0
  35. package/dist/dataplane/server/db/migrations/20230420T211446071Z-did-cache.js +11 -0
  36. package/dist/dataplane/server/db/migrations/index.d.ts +2 -0
  37. package/dist/dataplane/server/db/migrations/index.js +5 -0
  38. package/dist/dataplane/server/db/migrations/provider.d.ts +11 -0
  39. package/dist/dataplane/server/db/migrations/provider.js +19 -0
  40. package/dist/dataplane/server/db/pagination.d.ts +86 -0
  41. package/dist/dataplane/server/db/pagination.js +128 -0
  42. package/dist/dataplane/server/db/tables/actor-sync.d.ts +9 -0
  43. package/dist/dataplane/server/db/tables/actor-sync.js +1 -0
  44. package/dist/dataplane/server/db/tables/actor.d.ts +11 -0
  45. package/dist/dataplane/server/db/tables/actor.js +1 -0
  46. package/dist/dataplane/server/db/tables/artist-list-item.d.ts +11 -0
  47. package/dist/dataplane/server/db/tables/artist-list-item.js +1 -0
  48. package/dist/dataplane/server/db/tables/artist.d.ts +10 -0
  49. package/dist/dataplane/server/db/tables/artist.js +1 -0
  50. package/dist/dataplane/server/db/tables/playlist-idea.d.ts +14 -0
  51. package/dist/dataplane/server/db/tables/playlist-idea.js +1 -0
  52. package/dist/dataplane/server/db/tables/playlist-item.d.ts +11 -0
  53. package/dist/dataplane/server/db/tables/playlist-item.js +1 -0
  54. package/dist/dataplane/server/db/tables/playlist.d.ts +10 -0
  55. package/dist/dataplane/server/db/tables/playlist.js +1 -0
  56. package/dist/dataplane/server/db/tables/profile.d.ts +15 -0
  57. package/dist/dataplane/server/db/tables/profile.js +1 -0
  58. package/dist/dataplane/server/db/tables/record.d.ts +12 -0
  59. package/dist/dataplane/server/db/tables/record.js +1 -0
  60. package/dist/dataplane/server/db/tables/song.d.ts +12 -0
  61. package/dist/dataplane/server/db/tables/song.js +1 -0
  62. package/dist/dataplane/server/db/types.d.ts +9 -0
  63. package/dist/dataplane/server/db/types.js +1 -0
  64. package/dist/dataplane/server/db/util.d.ts +20 -0
  65. package/dist/dataplane/server/db/util.js +40 -0
  66. package/dist/dataplane/server/index.d.ts +11 -0
  67. package/dist/dataplane/server/index.js +36 -0
  68. package/dist/dataplane/server/indexing/index.d.ts +32 -0
  69. package/dist/dataplane/server/indexing/index.js +271 -0
  70. package/dist/dataplane/server/indexing/plugins/playlist-idea.d.ts +14 -0
  71. package/dist/dataplane/server/indexing/plugins/playlist-idea.js +126 -0
  72. package/dist/dataplane/server/indexing/plugins/profile.d.ts +8 -0
  73. package/dist/dataplane/server/indexing/plugins/profile.js +44 -0
  74. package/dist/dataplane/server/indexing/processor.d.ts +22 -0
  75. package/dist/dataplane/server/indexing/processor.js +72 -0
  76. package/dist/dataplane/server/routes/identity.d.ts +6 -0
  77. package/dist/dataplane/server/routes/identity.js +54 -0
  78. package/dist/dataplane/server/routes/index.d.ts +5 -0
  79. package/dist/dataplane/server/routes/index.js +14 -0
  80. package/dist/dataplane/server/routes/profile.d.ts +5 -0
  81. package/dist/dataplane/server/routes/profile.js +59 -0
  82. package/dist/dataplane/server/routes/records.d.ts +11 -0
  83. package/dist/dataplane/server/routes/records.js +51 -0
  84. package/dist/dataplane/server/routes/sync.d.ts +5 -0
  85. package/dist/dataplane/server/routes/sync.js +12 -0
  86. package/dist/dataplane/server/subscription.d.ts +25 -0
  87. package/dist/dataplane/server/subscription.js +86 -0
  88. package/dist/error.d.ts +2 -0
  89. package/dist/error.js +10 -0
  90. package/dist/index.d.ts +20 -0
  91. package/dist/index.js +55 -0
  92. package/dist/lexicons/index.d.ts +278 -0
  93. package/dist/lexicons/index.js +463 -0
  94. package/dist/lexicons/lexicons.d.ts +8466 -0
  95. package/dist/lexicons/lexicons.js +4548 -0
  96. package/dist/lexicons/types/com/atproto/admin/defs.d.ts +50 -0
  97. package/dist/lexicons/types/com/atproto/admin/defs.js +42 -0
  98. package/dist/lexicons/types/com/atproto/admin/deleteAccount.d.ts +29 -0
  99. package/dist/lexicons/types/com/atproto/admin/deleteAccount.js +1 -0
  100. package/dist/lexicons/types/com/atproto/admin/disableAccountInvites.d.ts +31 -0
  101. package/dist/lexicons/types/com/atproto/admin/disableAccountInvites.js +1 -0
  102. package/dist/lexicons/types/com/atproto/admin/disableInviteCodes.d.ts +30 -0
  103. package/dist/lexicons/types/com/atproto/admin/disableInviteCodes.js +1 -0
  104. package/dist/lexicons/types/com/atproto/admin/enableAccountInvites.d.ts +31 -0
  105. package/dist/lexicons/types/com/atproto/admin/enableAccountInvites.js +1 -0
  106. package/dist/lexicons/types/com/atproto/admin/getAccountInfo.d.ts +33 -0
  107. package/dist/lexicons/types/com/atproto/admin/getAccountInfo.js +1 -0
  108. package/dist/lexicons/types/com/atproto/admin/getAccountInfos.d.ts +36 -0
  109. package/dist/lexicons/types/com/atproto/admin/getAccountInfos.js +1 -0
  110. package/dist/lexicons/types/com/atproto/admin/getInviteCodes.d.ts +39 -0
  111. package/dist/lexicons/types/com/atproto/admin/getInviteCodes.js +1 -0
  112. package/dist/lexicons/types/com/atproto/admin/getSubjectStatus.d.ts +44 -0
  113. package/dist/lexicons/types/com/atproto/admin/getSubjectStatus.js +1 -0
  114. package/dist/lexicons/types/com/atproto/admin/searchAccounts.d.ts +39 -0
  115. package/dist/lexicons/types/com/atproto/admin/searchAccounts.js +1 -0
  116. package/dist/lexicons/types/com/atproto/admin/sendEmail.d.ts +45 -0
  117. package/dist/lexicons/types/com/atproto/admin/sendEmail.js +1 -0
  118. package/dist/lexicons/types/com/atproto/admin/updateAccountEmail.d.ts +31 -0
  119. package/dist/lexicons/types/com/atproto/admin/updateAccountEmail.js +1 -0
  120. package/dist/lexicons/types/com/atproto/admin/updateAccountHandle.d.ts +30 -0
  121. package/dist/lexicons/types/com/atproto/admin/updateAccountHandle.js +1 -0
  122. package/dist/lexicons/types/com/atproto/admin/updateAccountPassword.d.ts +30 -0
  123. package/dist/lexicons/types/com/atproto/admin/updateAccountPassword.js +1 -0
  124. package/dist/lexicons/types/com/atproto/admin/updateSubjectStatus.d.ts +51 -0
  125. package/dist/lexicons/types/com/atproto/admin/updateSubjectStatus.js +1 -0
  126. package/dist/lexicons/types/com/atproto/identity/defs.d.ts +14 -0
  127. package/dist/lexicons/types/com/atproto/identity/defs.js +10 -0
  128. package/dist/lexicons/types/com/atproto/identity/getRecommendedDidCredentials.d.ts +38 -0
  129. package/dist/lexicons/types/com/atproto/identity/getRecommendedDidCredentials.js +1 -0
  130. package/dist/lexicons/types/com/atproto/identity/refreshIdentity.d.ts +39 -0
  131. package/dist/lexicons/types/com/atproto/identity/refreshIdentity.js +1 -0
  132. package/dist/lexicons/types/com/atproto/identity/requestPlcOperationSignature.d.ts +23 -0
  133. package/dist/lexicons/types/com/atproto/identity/requestPlcOperationSignature.js +1 -0
  134. package/dist/lexicons/types/com/atproto/identity/resolveDid.d.ts +38 -0
  135. package/dist/lexicons/types/com/atproto/identity/resolveDid.js +1 -0
  136. package/dist/lexicons/types/com/atproto/identity/resolveHandle.d.ts +37 -0
  137. package/dist/lexicons/types/com/atproto/identity/resolveHandle.js +1 -0
  138. package/dist/lexicons/types/com/atproto/identity/resolveIdentity.d.ts +35 -0
  139. package/dist/lexicons/types/com/atproto/identity/resolveIdentity.js +1 -0
  140. package/dist/lexicons/types/com/atproto/identity/signPlcOperation.d.ts +46 -0
  141. package/dist/lexicons/types/com/atproto/identity/signPlcOperation.js +1 -0
  142. package/dist/lexicons/types/com/atproto/identity/submitPlcOperation.d.ts +29 -0
  143. package/dist/lexicons/types/com/atproto/identity/submitPlcOperation.js +1 -0
  144. package/dist/lexicons/types/com/atproto/identity/updateHandle.d.ts +30 -0
  145. package/dist/lexicons/types/com/atproto/identity/updateHandle.js +1 -0
  146. package/dist/lexicons/types/com/atproto/label/defs.d.ts +73 -0
  147. package/dist/lexicons/types/com/atproto/label/defs.js +42 -0
  148. package/dist/lexicons/types/com/atproto/label/queryLabels.d.ts +42 -0
  149. package/dist/lexicons/types/com/atproto/label/queryLabels.js +1 -0
  150. package/dist/lexicons/types/com/atproto/label/subscribeLabels.d.ts +38 -0
  151. package/dist/lexicons/types/com/atproto/label/subscribeLabels.js +18 -0
  152. package/dist/lexicons/types/com/atproto/lexicon/schema.d.ts +11 -0
  153. package/dist/lexicons/types/com/atproto/lexicon/schema.js +11 -0
  154. package/dist/lexicons/types/com/atproto/moderation/createReport.d.ts +57 -0
  155. package/dist/lexicons/types/com/atproto/moderation/createReport.js +1 -0
  156. package/dist/lexicons/types/com/atproto/moderation/defs.d.ts +20 -0
  157. package/dist/lexicons/types/com/atproto/moderation/defs.js +17 -0
  158. package/dist/lexicons/types/com/atproto/repo/applyWrites.d.ts +98 -0
  159. package/dist/lexicons/types/com/atproto/repo/applyWrites.js +50 -0
  160. package/dist/lexicons/types/com/atproto/repo/createRecord.d.ts +56 -0
  161. package/dist/lexicons/types/com/atproto/repo/createRecord.js +1 -0
  162. package/dist/lexicons/types/com/atproto/repo/defs.d.ts +11 -0
  163. package/dist/lexicons/types/com/atproto/repo/defs.js +10 -0
  164. package/dist/lexicons/types/com/atproto/repo/deleteRecord.d.ts +51 -0
  165. package/dist/lexicons/types/com/atproto/repo/deleteRecord.js +1 -0
  166. package/dist/lexicons/types/com/atproto/repo/describeRepo.d.ts +43 -0
  167. package/dist/lexicons/types/com/atproto/repo/describeRepo.js +1 -0
  168. package/dist/lexicons/types/com/atproto/repo/getRecord.d.ts +45 -0
  169. package/dist/lexicons/types/com/atproto/repo/getRecord.js +1 -0
  170. package/dist/lexicons/types/com/atproto/repo/importRepo.d.ts +27 -0
  171. package/dist/lexicons/types/com/atproto/repo/importRepo.js +1 -0
  172. package/dist/lexicons/types/com/atproto/repo/listMissingBlobs.d.ts +45 -0
  173. package/dist/lexicons/types/com/atproto/repo/listMissingBlobs.js +10 -0
  174. package/dist/lexicons/types/com/atproto/repo/listRecords.d.ts +53 -0
  175. package/dist/lexicons/types/com/atproto/repo/listRecords.js +10 -0
  176. package/dist/lexicons/types/com/atproto/repo/putRecord.d.ts +58 -0
  177. package/dist/lexicons/types/com/atproto/repo/putRecord.js +1 -0
  178. package/dist/lexicons/types/com/atproto/repo/strongRef.d.ts +11 -0
  179. package/dist/lexicons/types/com/atproto/repo/strongRef.js +11 -0
  180. package/dist/lexicons/types/com/atproto/repo/uploadBlob.d.ts +39 -0
  181. package/dist/lexicons/types/com/atproto/repo/uploadBlob.js +1 -0
  182. package/dist/lexicons/types/com/atproto/server/activateAccount.d.ts +23 -0
  183. package/dist/lexicons/types/com/atproto/server/activateAccount.js +1 -0
  184. package/dist/lexicons/types/com/atproto/server/checkAccountStatus.d.ts +42 -0
  185. package/dist/lexicons/types/com/atproto/server/checkAccountStatus.js +1 -0
  186. package/dist/lexicons/types/com/atproto/server/confirmEmail.d.ts +31 -0
  187. package/dist/lexicons/types/com/atproto/server/confirmEmail.js +1 -0
  188. package/dist/lexicons/types/com/atproto/server/createAccount.d.ts +61 -0
  189. package/dist/lexicons/types/com/atproto/server/createAccount.js +1 -0
  190. package/dist/lexicons/types/com/atproto/server/createAppPassword.d.ts +51 -0
  191. package/dist/lexicons/types/com/atproto/server/createAppPassword.js +10 -0
  192. package/dist/lexicons/types/com/atproto/server/createInviteCode.d.ts +41 -0
  193. package/dist/lexicons/types/com/atproto/server/createInviteCode.js +1 -0
  194. package/dist/lexicons/types/com/atproto/server/createInviteCodes.d.ts +50 -0
  195. package/dist/lexicons/types/com/atproto/server/createInviteCodes.js +10 -0
  196. package/dist/lexicons/types/com/atproto/server/createSession.d.ts +56 -0
  197. package/dist/lexicons/types/com/atproto/server/createSession.js +1 -0
  198. package/dist/lexicons/types/com/atproto/server/deactivateAccount.d.ts +30 -0
  199. package/dist/lexicons/types/com/atproto/server/deactivateAccount.js +1 -0
  200. package/dist/lexicons/types/com/atproto/server/defs.d.ts +23 -0
  201. package/dist/lexicons/types/com/atproto/server/defs.js +18 -0
  202. package/dist/lexicons/types/com/atproto/server/deleteAccount.d.ts +32 -0
  203. package/dist/lexicons/types/com/atproto/server/deleteAccount.js +1 -0
  204. package/dist/lexicons/types/com/atproto/server/deleteSession.d.ts +23 -0
  205. package/dist/lexicons/types/com/atproto/server/deleteSession.js +1 -0
  206. package/dist/lexicons/types/com/atproto/server/describeServer.d.ts +56 -0
  207. package/dist/lexicons/types/com/atproto/server/describeServer.js +18 -0
  208. package/dist/lexicons/types/com/atproto/server/getAccountInviteCodes.d.ts +39 -0
  209. package/dist/lexicons/types/com/atproto/server/getAccountInviteCodes.js +1 -0
  210. package/dist/lexicons/types/com/atproto/server/getServiceAuth.d.ts +41 -0
  211. package/dist/lexicons/types/com/atproto/server/getServiceAuth.js +1 -0
  212. package/dist/lexicons/types/com/atproto/server/getSession.d.ts +42 -0
  213. package/dist/lexicons/types/com/atproto/server/getSession.js +1 -0
  214. package/dist/lexicons/types/com/atproto/server/listAppPasswords.d.ts +44 -0
  215. package/dist/lexicons/types/com/atproto/server/listAppPasswords.js +10 -0
  216. package/dist/lexicons/types/com/atproto/server/refreshSession.d.ts +42 -0
  217. package/dist/lexicons/types/com/atproto/server/refreshSession.js +1 -0
  218. package/dist/lexicons/types/com/atproto/server/requestAccountDelete.d.ts +23 -0
  219. package/dist/lexicons/types/com/atproto/server/requestAccountDelete.js +1 -0
  220. package/dist/lexicons/types/com/atproto/server/requestEmailConfirmation.d.ts +23 -0
  221. package/dist/lexicons/types/com/atproto/server/requestEmailConfirmation.js +1 -0
  222. package/dist/lexicons/types/com/atproto/server/requestEmailUpdate.d.ts +34 -0
  223. package/dist/lexicons/types/com/atproto/server/requestEmailUpdate.js +1 -0
  224. package/dist/lexicons/types/com/atproto/server/requestPasswordReset.d.ts +29 -0
  225. package/dist/lexicons/types/com/atproto/server/requestPasswordReset.js +1 -0
  226. package/dist/lexicons/types/com/atproto/server/reserveSigningKey.d.ts +42 -0
  227. package/dist/lexicons/types/com/atproto/server/reserveSigningKey.js +1 -0
  228. package/dist/lexicons/types/com/atproto/server/resetPassword.d.ts +31 -0
  229. package/dist/lexicons/types/com/atproto/server/resetPassword.js +1 -0
  230. package/dist/lexicons/types/com/atproto/server/revokeAppPassword.d.ts +29 -0
  231. package/dist/lexicons/types/com/atproto/server/revokeAppPassword.js +1 -0
  232. package/dist/lexicons/types/com/atproto/server/updateEmail.d.ts +33 -0
  233. package/dist/lexicons/types/com/atproto/server/updateEmail.js +1 -0
  234. package/dist/lexicons/types/com/atproto/sync/getBlob.d.ts +36 -0
  235. package/dist/lexicons/types/com/atproto/sync/getBlob.js +1 -0
  236. package/dist/lexicons/types/com/atproto/sync/getBlocks.d.ts +35 -0
  237. package/dist/lexicons/types/com/atproto/sync/getBlocks.js +1 -0
  238. package/dist/lexicons/types/com/atproto/sync/getCheckout.d.ts +33 -0
  239. package/dist/lexicons/types/com/atproto/sync/getCheckout.js +1 -0
  240. package/dist/lexicons/types/com/atproto/sync/getHead.d.ts +37 -0
  241. package/dist/lexicons/types/com/atproto/sync/getHead.js +1 -0
  242. package/dist/lexicons/types/com/atproto/sync/getLatestCommit.d.ts +38 -0
  243. package/dist/lexicons/types/com/atproto/sync/getLatestCommit.js +1 -0
  244. package/dist/lexicons/types/com/atproto/sync/getRecord.d.ts +37 -0
  245. package/dist/lexicons/types/com/atproto/sync/getRecord.js +1 -0
  246. package/dist/lexicons/types/com/atproto/sync/getRepo.d.ts +36 -0
  247. package/dist/lexicons/types/com/atproto/sync/getRepo.js +1 -0
  248. package/dist/lexicons/types/com/atproto/sync/getRepoStatus.d.ts +42 -0
  249. package/dist/lexicons/types/com/atproto/sync/getRepoStatus.js +1 -0
  250. package/dist/lexicons/types/com/atproto/sync/listBlobs.d.ts +42 -0
  251. package/dist/lexicons/types/com/atproto/sync/listBlobs.js +1 -0
  252. package/dist/lexicons/types/com/atproto/sync/listRepos.d.ts +50 -0
  253. package/dist/lexicons/types/com/atproto/sync/listRepos.js +10 -0
  254. package/dist/lexicons/types/com/atproto/sync/listReposByCollection.d.ts +46 -0
  255. package/dist/lexicons/types/com/atproto/sync/listReposByCollection.js +10 -0
  256. package/dist/lexicons/types/com/atproto/sync/notifyOfUpdate.d.ts +30 -0
  257. package/dist/lexicons/types/com/atproto/sync/notifyOfUpdate.js +1 -0
  258. package/dist/lexicons/types/com/atproto/sync/requestCrawl.d.ts +30 -0
  259. package/dist/lexicons/types/com/atproto/sync/requestCrawl.js +1 -0
  260. package/dist/lexicons/types/com/atproto/sync/subscribeRepos.d.ts +111 -0
  261. package/dist/lexicons/types/com/atproto/sync/subscribeRepos.js +50 -0
  262. package/dist/lexicons/types/com/atproto/temp/addReservedHandle.d.ts +39 -0
  263. package/dist/lexicons/types/com/atproto/temp/addReservedHandle.js +1 -0
  264. package/dist/lexicons/types/com/atproto/temp/checkSignupQueue.d.ts +36 -0
  265. package/dist/lexicons/types/com/atproto/temp/checkSignupQueue.js +1 -0
  266. package/dist/lexicons/types/com/atproto/temp/fetchLabels.d.ts +37 -0
  267. package/dist/lexicons/types/com/atproto/temp/fetchLabels.js +1 -0
  268. package/dist/lexicons/types/com/atproto/temp/requestPhoneVerification.d.ts +29 -0
  269. package/dist/lexicons/types/com/atproto/temp/requestPhoneVerification.js +1 -0
  270. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.d.ts +19 -0
  271. package/dist/lexicons/types/com/clioplaylists/alpha/actor/profile.js +11 -0
  272. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.d.ts +32 -0
  273. package/dist/lexicons/types/com/clioplaylists/alpha/feed/defs.js +18 -0
  274. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getSongs.d.ts +37 -0
  275. package/dist/lexicons/types/com/clioplaylists/alpha/feed/getSongs.js +1 -0
  276. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.d.ts +32 -0
  277. package/dist/lexicons/types/com/clioplaylists/alpha/feed/playlistIdea.js +27 -0
  278. package/dist/lexicons/util.d.ts +5 -0
  279. package/dist/lexicons/util.js +9 -0
  280. package/dist/logger.d.ts +6 -0
  281. package/dist/logger.js +20 -0
  282. package/dist/rpc/clio_connect.d.ts +103 -0
  283. package/dist/rpc/clio_connect.js +107 -0
  284. package/dist/rpc/clio_pb.d.ts +457 -0
  285. package/dist/rpc/clio_pb.js +811 -0
  286. package/dist/start.d.ts +1 -0
  287. package/dist/util/retry.d.ts +2 -0
  288. package/dist/util/retry.js +13 -0
  289. package/dist/util/uris.d.ts +1 -0
  290. package/dist/util/uris.js +4 -0
  291. package/dist/util.d.ts +23 -0
  292. package/dist/util.js +76 -0
  293. package/package.json +7 -7
  294. /package/{start.js → dist/start.js} +0 -0
package/dist/config.js ADDED
@@ -0,0 +1,49 @@
1
+ import assert from 'node:assert';
2
+ export class ServerConfig {
3
+ cfg;
4
+ assignedPort;
5
+ constructor(cfg) {
6
+ this.cfg = cfg;
7
+ }
8
+ static readEnv(overrides) {
9
+ const version = overrides?.version || process.env.CLIO_VERSION || undefined;
10
+ const debugMode = overrides?.debugMode || process.env.NODE_ENV !== 'production';
11
+ const serverDid = overrides?.serverDid || process.env.CLIO_SERVER_DID || 'did:example:test';
12
+ const didPlcUrl = overrides?.didPlcUrl || process.env.DID_PLC_URL || 'http://localhost:2582';
13
+ // const handleResolverNameservers = process.env.BSKY_HANDLE_RESOLVER_NAMESERVERS
14
+ // ? process.env.BSKY_HANDLE_RESOLVER_NAMESERVERS.split(',')
15
+ // : []
16
+ const envPort = overrides?.port || parseInt(process.env.CLIO_PORT || '', 10);
17
+ const port = isNaN(envPort) ? 2635 : envPort;
18
+ return new ServerConfig({
19
+ version,
20
+ debugMode,
21
+ port,
22
+ serverDid,
23
+ didPlcUrl,
24
+ });
25
+ }
26
+ assignPort(port) {
27
+ assert(!this.cfg.port || this.cfg.port === port, 'Conflicting port in config');
28
+ this.assignedPort = port;
29
+ }
30
+ get version() {
31
+ return this.cfg.version;
32
+ }
33
+ get debugMode() {
34
+ return !!this.cfg.debugMode;
35
+ }
36
+ get port() {
37
+ return this.assignedPort || this.cfg.port;
38
+ }
39
+ get localUrl() {
40
+ assert(this.port, 'No port assigned');
41
+ return `http://localhost:${this.port}`;
42
+ }
43
+ get serverDid() {
44
+ return this.cfg.serverDid;
45
+ }
46
+ get didPlcUrl() {
47
+ return this.cfg.didPlcUrl;
48
+ }
49
+ }
@@ -0,0 +1,11 @@
1
+ import { DataPlaneClient } from './client';
2
+ import { ServerConfig } from './config';
3
+ export default class AppContext {
4
+ private opts;
5
+ constructor(opts: {
6
+ cfg: ServerConfig;
7
+ dataplane: DataPlaneClient;
8
+ });
9
+ get cfg(): ServerConfig;
10
+ get dataplane(): DataPlaneClient;
11
+ }
@@ -0,0 +1,12 @@
1
+ export default class AppContext {
2
+ opts;
3
+ constructor(opts) {
4
+ this.opts = opts;
5
+ }
6
+ get cfg() {
7
+ return this.opts.cfg;
8
+ }
9
+ get dataplane() {
10
+ return this.opts.dataplane;
11
+ }
12
+ }
@@ -0,0 +1,27 @@
1
+ import { Client, Code, ConnectError } from '@connectrpc/connect';
2
+ import { ClioService } from '../rpc/clio_connect';
3
+ export type DataPlaneClient = Client<typeof ClioService>;
4
+ type HttpVersion = '1.1' | '2';
5
+ export declare const createDataPlaneClient: (baseUrls: string[], opts: {
6
+ httpVersion?: HttpVersion;
7
+ rejectUnauthorized?: boolean;
8
+ }) => DataPlaneClient;
9
+ export { Code };
10
+ export declare const isDataplaneError: (err: unknown, code?: Code) => err is ConnectError;
11
+ export declare const unpackIdentityServices: (servicesBytes: Uint8Array) => UnpackedServices;
12
+ export declare const unpackIdentityKeys: (keysBytes: Uint8Array) => UnpackedKeys;
13
+ export declare const getServiceEndpoint: (services: UnpackedServices, opts: {
14
+ id: string;
15
+ type: string;
16
+ }) => string | undefined;
17
+ export declare const getKeyAsDidKey: (keys: UnpackedKeys, opts: {
18
+ id: string;
19
+ }) => string | undefined;
20
+ type UnpackedServices = Record<string, {
21
+ Type: string;
22
+ URL: string;
23
+ }>;
24
+ type UnpackedKeys = Record<string, {
25
+ Type: string;
26
+ PublicKeyMultibase: string;
27
+ }>;
@@ -0,0 +1,120 @@
1
+ import { getDidKeyFromMultibase } from '@atproto/identity';
2
+ import { Code, ConnectError, createClient, makeAnyClient, } from '@connectrpc/connect';
3
+ import { createGrpcTransport } from '@connectrpc/connect-node';
4
+ import assert from 'node:assert';
5
+ import { randomInt } from 'node:crypto';
6
+ import * as ui8 from 'uint8arrays';
7
+ import { ClioService } from '../rpc/clio_connect';
8
+ const MAX_RETRIES = 3;
9
+ export const createDataPlaneClient = (baseUrls, opts) => {
10
+ const clients = baseUrls.map((baseUrl) => createBaseClient(baseUrl, opts));
11
+ assert(clients.length > 0, 'no clients available');
12
+ return makeAnyClient(ClioService, (method) => {
13
+ return async (...args) => {
14
+ let tries = 0;
15
+ let error;
16
+ let remainingClients = clients;
17
+ while (tries < MAX_RETRIES) {
18
+ const client = randomElement(remainingClients);
19
+ assert(client, 'no clients available');
20
+ try {
21
+ return await client.lib[method.localName](...args);
22
+ }
23
+ catch (err) {
24
+ if (err instanceof ConnectError &&
25
+ (err.code === Code.Unavailable || err.code === Code.Aborted)) {
26
+ tries++;
27
+ error = err;
28
+ remainingClients = getRemainingClients(remainingClients, client);
29
+ }
30
+ else {
31
+ throw err;
32
+ }
33
+ }
34
+ }
35
+ assert(error);
36
+ throw error;
37
+ };
38
+ });
39
+ };
40
+ export { Code };
41
+ export const isDataplaneError = (err, code) => {
42
+ if (err instanceof ConnectError) {
43
+ return !code || err.code === code;
44
+ }
45
+ return false;
46
+ };
47
+ const createBaseClient = (baseUrl, opts) => {
48
+ const { httpVersion = '2', rejectUnauthorized = true } = opts;
49
+ const transport = createGrpcTransport({
50
+ baseUrl,
51
+ httpVersion,
52
+ acceptCompression: [],
53
+ nodeOptions: { rejectUnauthorized },
54
+ });
55
+ return {
56
+ lib: createClient(ClioService, transport),
57
+ url: new URL(baseUrl),
58
+ };
59
+ };
60
+ const getRemainingClients = (clients, lastClient) => {
61
+ if (clients.length < 2)
62
+ return clients; // no clients to choose from
63
+ if (lastClient.url.port) {
64
+ // if the last client had a port, we attempt to exclude its whole host.
65
+ const maybeRemaining = clients.filter((c) => c.url.hostname !== lastClient.url.hostname);
66
+ if (maybeRemaining.length) {
67
+ return maybeRemaining;
68
+ }
69
+ }
70
+ return clients.filter((c) => c !== lastClient);
71
+ };
72
+ const randomElement = (arr) => {
73
+ if (arr.length === 0)
74
+ return;
75
+ return arr[randomInt(arr.length)];
76
+ };
77
+ export const unpackIdentityServices = (servicesBytes) => {
78
+ const servicesStr = ui8.toString(servicesBytes, 'utf8');
79
+ if (!servicesStr)
80
+ return {};
81
+ return JSON.parse(servicesStr);
82
+ };
83
+ export const unpackIdentityKeys = (keysBytes) => {
84
+ const keysStr = ui8.toString(keysBytes, 'utf8');
85
+ if (!keysStr)
86
+ return {};
87
+ return JSON.parse(keysStr);
88
+ };
89
+ export const getServiceEndpoint = (services, opts) => {
90
+ const endpoint = services[opts.id] &&
91
+ services[opts.id].Type === opts.type &&
92
+ validateUrl(services[opts.id].URL);
93
+ return endpoint || undefined;
94
+ };
95
+ export const getKeyAsDidKey = (keys, opts) => {
96
+ const key = keys[opts.id] &&
97
+ getDidKeyFromMultibase({
98
+ type: keys[opts.id].Type,
99
+ publicKeyMultibase: keys[opts.id].PublicKeyMultibase,
100
+ });
101
+ return key || undefined;
102
+ };
103
+ const validateUrl = (urlStr) => {
104
+ let url;
105
+ try {
106
+ url = new URL(urlStr);
107
+ }
108
+ catch {
109
+ return undefined;
110
+ }
111
+ if (!['http:', 'https:'].includes(url.protocol)) {
112
+ return undefined;
113
+ }
114
+ else if (!url.hostname) {
115
+ return undefined;
116
+ }
117
+ else {
118
+ return urlStr;
119
+ }
120
+ };
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ export * from './server';
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ export * from './server';
@@ -0,0 +1,13 @@
1
+ import PQueue from 'p-queue';
2
+ import { Database } from './db';
3
+ export declare class BackgroundQueue {
4
+ db: Database;
5
+ queue: PQueue<import("p-queue/dist/priority-queue").default, import("p-queue").DefaultAddOptions>;
6
+ destroyed: boolean;
7
+ constructor(db: Database);
8
+ add(task: Task): void;
9
+ processAll(): Promise<void>;
10
+ destroy(): Promise<void>;
11
+ }
12
+ type Task = (db: Database) => Promise<void>;
13
+ export {};
@@ -0,0 +1,30 @@
1
+ import PQueue from 'p-queue';
2
+ import { dbLogger } from '../../logger';
3
+ // A simple queue for in-process, out-of-band/backgrounded work
4
+ export class BackgroundQueue {
5
+ db;
6
+ queue = new PQueue();
7
+ destroyed = false;
8
+ constructor(db) {
9
+ this.db = db;
10
+ }
11
+ add(task) {
12
+ if (this.destroyed) {
13
+ return;
14
+ }
15
+ this.queue
16
+ .add(() => task(this.db))
17
+ .catch((err) => {
18
+ dbLogger.error(err, 'background queue task failed');
19
+ });
20
+ }
21
+ async processAll() {
22
+ await this.queue.onIdle();
23
+ }
24
+ // On destroy we stop accepting new tasks, but complete all pending/in-progress tasks.
25
+ // The application calls this only once http connections have drained (tasks no longer being added).
26
+ async destroy() {
27
+ this.destroyed = true;
28
+ await this.queue.onIdle();
29
+ }
30
+ }
@@ -0,0 +1,13 @@
1
+ import { Kysely } from 'kysely';
2
+ import * as actorTable from './tables/actor';
3
+ import * as actorSyncTable from './tables/actor-sync';
4
+ import * as artistTable from './tables/artist';
5
+ import * as artistListItemTable from './tables/artist-list-item';
6
+ import * as playlistTable from './tables/playlist';
7
+ import * as playlistIdeaTable from './tables/playlist-idea';
8
+ import * as playlistItemTable from './tables/playlist-item';
9
+ import * as profileTable from './tables/profile';
10
+ import * as recordTable from './tables/record';
11
+ import * as songTable from './tables/song';
12
+ export type DatabaseSchemaType = actorTable.PartialDB & actorSyncTable.PartialDB & artistTable.PartialDB & artistListItemTable.PartialDB & playlistTable.PartialDB & playlistIdeaTable.PartialDB & playlistItemTable.PartialDB & profileTable.PartialDB & recordTable.PartialDB & songTable.PartialDB;
13
+ export type DatabaseSchema = Kysely<DatabaseSchemaType>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { Migrator } from 'kysely';
2
+ import { Pool as PgPool } from 'pg';
3
+ import TypedEmitter from 'typed-emitter';
4
+ import { DatabaseSchema } from './database-schema';
5
+ import { PgOptions } from './types';
6
+ export declare class Database {
7
+ opts: PgOptions;
8
+ pool: PgPool;
9
+ db: DatabaseSchema;
10
+ migrator: Migrator;
11
+ txEvt: TxnEmitter;
12
+ destroyed: boolean;
13
+ constructor(opts: PgOptions, instances?: {
14
+ db: DatabaseSchema;
15
+ pool: PgPool;
16
+ migrator: Migrator;
17
+ });
18
+ get schema(): string | undefined;
19
+ transaction<T>(fn: (db: Database) => Promise<T>): Promise<T>;
20
+ get isTransaction(): boolean;
21
+ assertTransaction(): void;
22
+ assertNotTransaction(): void;
23
+ onCommit(fn: () => void): void;
24
+ migrateToOrThrow(migration: string): Promise<import("kysely").MigrationResult[]>;
25
+ migrateToLatestOrThrow(): Promise<import("kysely").MigrationResult[]>;
26
+ close(): Promise<void>;
27
+ }
28
+ export default Database;
29
+ type TxnEmitter = TypedEmitter<TxnEvents>;
30
+ type TxnEvents = {
31
+ commit: () => void;
32
+ };
@@ -0,0 +1,152 @@
1
+ import { Kysely, Migrator, PostgresDialect, } from 'kysely';
2
+ import assert from 'node:assert';
3
+ import EventEmitter from 'node:events';
4
+ import { Pool as PgPool, types as pgTypes } from 'pg';
5
+ import { dbLogger } from '../../../logger';
6
+ import * as migrations from './migrations';
7
+ import { CtxMigrationProvider } from './migrations/provider';
8
+ export class Database {
9
+ opts;
10
+ pool;
11
+ db;
12
+ migrator;
13
+ txEvt = new EventEmitter();
14
+ destroyed = false;
15
+ constructor(opts, instances) {
16
+ this.opts = opts;
17
+ // if instances are provided, use those
18
+ if (instances) {
19
+ this.db = instances.db;
20
+ this.pool = instances.pool;
21
+ this.migrator = instances.migrator;
22
+ return;
23
+ }
24
+ // else create a pool & connect
25
+ const { schema, url } = opts;
26
+ const pool = opts.pool ??
27
+ new PgPool({
28
+ connectionString: url,
29
+ max: opts.poolSize,
30
+ maxUses: opts.poolMaxUses,
31
+ idleTimeoutMillis: opts.poolIdleTimeoutMs,
32
+ });
33
+ // Select count(*) and other pg bigints as js integer
34
+ pgTypes.setTypeParser(pgTypes.builtins.INT8, (n) => parseInt(n, 10));
35
+ // Setup schema usage, primarily for test parallelism (each test suite runs in its own pg schema)
36
+ if (schema && !/^[a-z_]+$/i.test(schema)) {
37
+ throw new Error(`Postgres schema must only contain [A-Za-z_]: ${schema}`);
38
+ }
39
+ pool.on('error', onPoolError);
40
+ pool.on('connect', (client) => {
41
+ client.on('error', onClientError);
42
+ // Used for trigram indexes, e.g. on actor search
43
+ client.query('SET pg_trgm.word_similarity_threshold TO .4;');
44
+ if (schema) {
45
+ // Shared objects such as extensions will go in the public schema
46
+ client.query(`SET search_path TO "${schema}",public;`);
47
+ }
48
+ });
49
+ this.pool = pool;
50
+ this.db = new Kysely({
51
+ dialect: new PostgresDialect({ pool }),
52
+ });
53
+ this.migrator = new Migrator({
54
+ db: this.db,
55
+ migrationTableSchema: opts.schema,
56
+ provider: new CtxMigrationProvider(migrations, 'pg'),
57
+ });
58
+ }
59
+ get schema() {
60
+ return this.opts.schema;
61
+ }
62
+ async transaction(fn) {
63
+ const leakyTxPlugin = new LeakyTxPlugin();
64
+ const { dbTxn, txRes } = await this.db
65
+ .withPlugin(leakyTxPlugin)
66
+ .transaction()
67
+ .execute(async (txn) => {
68
+ const dbTxn = new Database(this.opts, {
69
+ db: txn,
70
+ pool: this.pool,
71
+ migrator: this.migrator,
72
+ });
73
+ const txRes = await fn(dbTxn)
74
+ .catch(async (err) => {
75
+ leakyTxPlugin.endTx();
76
+ // ensure that all in-flight queries are flushed & the connection is open
77
+ await dbTxn.db.getExecutor().provideConnection(noopAsync);
78
+ throw err;
79
+ })
80
+ .finally(() => leakyTxPlugin.endTx());
81
+ return { dbTxn, txRes };
82
+ });
83
+ dbTxn?.txEvt.emit('commit');
84
+ return txRes;
85
+ }
86
+ get isTransaction() {
87
+ return this.db.isTransaction;
88
+ }
89
+ assertTransaction() {
90
+ assert(this.isTransaction, 'Transaction required');
91
+ }
92
+ assertNotTransaction() {
93
+ assert(!this.isTransaction, 'Cannot be in a transaction');
94
+ }
95
+ onCommit(fn) {
96
+ this.assertTransaction();
97
+ this.txEvt.once('commit', fn);
98
+ }
99
+ async migrateToOrThrow(migration) {
100
+ if (this.schema) {
101
+ await this.db.schema.createSchema(this.schema).ifNotExists().execute();
102
+ }
103
+ const { error, results } = await this.migrator.migrateTo(migration);
104
+ if (error) {
105
+ throw error;
106
+ }
107
+ if (!results) {
108
+ throw new Error('An unknown failure occurred while migrating');
109
+ }
110
+ return results;
111
+ }
112
+ async migrateToLatestOrThrow() {
113
+ if (this.schema) {
114
+ await this.db.schema.createSchema(this.schema).ifNotExists().execute();
115
+ }
116
+ const { error, results } = await this.migrator.migrateToLatest();
117
+ if (error) {
118
+ throw error;
119
+ }
120
+ if (!results) {
121
+ throw new Error('An unknown failure occurred while migrating');
122
+ }
123
+ return results;
124
+ }
125
+ async close() {
126
+ if (this.destroyed)
127
+ return;
128
+ await this.db.destroy();
129
+ this.destroyed = true;
130
+ }
131
+ }
132
+ export default Database;
133
+ const onPoolError = (err) => dbLogger.error({ err }, 'db pool error');
134
+ const onClientError = (err) => dbLogger.error({ err }, 'db client error');
135
+ // utils
136
+ // -------
137
+ class LeakyTxPlugin {
138
+ txOver = false;
139
+ endTx() {
140
+ this.txOver = true;
141
+ }
142
+ transformQuery(args) {
143
+ if (this.txOver) {
144
+ throw new Error('tx already failed');
145
+ }
146
+ return args.node;
147
+ }
148
+ async transformResult(args) {
149
+ return args.result;
150
+ }
151
+ }
152
+ const noopAsync = async () => { };
@@ -0,0 +1 @@
1
+ export * from './db';
@@ -0,0 +1 @@
1
+ export * from './db';
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<unknown>): Promise<void>;
3
+ export declare function down(db: Kysely<unknown>): Promise<void>;
@@ -0,0 +1,113 @@
1
+ import { sql } from 'kysely';
2
+ // @TODO subject indexes, naming?
3
+ // @TODO drop indexes in down()?
4
+ export async function up(db) {
5
+ try {
6
+ // Add trigram support, supporting user search.
7
+ // Explicitly add to public schema, so the extension can be seen in all schemas.
8
+ await sql `create extension if not exists pg_trgm with schema public`.execute(db);
9
+ }
10
+ catch (err) {
11
+ // The "if not exists" isn't bulletproof against races, and we see test suites racing to
12
+ // create the extension. So we can just ignore errors indicating the extension already exists.
13
+ if (!err?.['detail']?.includes?.('(pg_trgm) already exists'))
14
+ throw err;
15
+ }
16
+ // profile
17
+ await db.schema
18
+ .createTable('profile')
19
+ .addColumn('uri', 'varchar', (col) => col.primaryKey())
20
+ .addColumn('cid', 'varchar', (col) => col.notNull())
21
+ .addColumn('creator_did', 'varchar', (col) => col.notNull())
22
+ .addColumn('display_name', 'varchar')
23
+ .addColumn('description', 'varchar')
24
+ .addColumn('avatar_cid', 'varchar')
25
+ .addColumn('banner_cid', 'varchar')
26
+ .addColumn('indexed_at', 'varchar', (col) => col.notNull())
27
+ .execute();
28
+ // follow
29
+ await db.schema
30
+ .createTable('follow')
31
+ .addColumn('uri', 'varchar', (col) => col.primaryKey())
32
+ .addColumn('cid', 'varchar', (col) => col.notNull())
33
+ .addColumn('creator', 'varchar', (col) => col.notNull())
34
+ .addColumn('subjectDid', 'varchar', (col) => col.notNull())
35
+ .addColumn('createdAt', 'varchar', (col) => col.notNull())
36
+ .addColumn('indexedAt', 'varchar', (col) => col.notNull())
37
+ .addColumn('sortAt', 'varchar', (col) => col
38
+ .generatedAlwaysAs(sql `least("createdAt", "indexedAt")`)
39
+ .stored()
40
+ .notNull())
41
+ .addUniqueConstraint('follow_unique_subject', ['creator', 'subjectDid'])
42
+ .execute();
43
+ // for, eg, "followersCount" on profile views
44
+ await db.schema
45
+ .createIndex('follow_subjectdid_idx')
46
+ .on('follow')
47
+ .column('subjectDid')
48
+ .execute();
49
+ // like
50
+ await db.schema
51
+ .createTable('like')
52
+ .addColumn('uri', 'varchar', (col) => col.primaryKey())
53
+ .addColumn('cid', 'varchar', (col) => col.notNull())
54
+ .addColumn('creator', 'varchar', (col) => col.notNull())
55
+ .addColumn('subject', 'varchar', (col) => col.notNull())
56
+ .addColumn('subjectCid', 'varchar', (col) => col.notNull())
57
+ .addColumn('createdAt', 'varchar', (col) => col.notNull())
58
+ .addColumn('indexedAt', 'varchar', (col) => col.notNull())
59
+ .addColumn('sortAt', 'varchar', (col) => col
60
+ .generatedAlwaysAs(sql `least("createdAt", "indexedAt")`)
61
+ .stored()
62
+ .notNull())
63
+ // Aids in index uniqueness plus post like counts
64
+ .addUniqueConstraint('like_unique_subject', ['subject', 'creator'])
65
+ .execute();
66
+ // subscription
67
+ await db.schema
68
+ .createTable('subscription')
69
+ .addColumn('service', 'varchar', (col) => col.notNull())
70
+ .addColumn('method', 'varchar', (col) => col.notNull())
71
+ .addColumn('state', 'varchar', (col) => col.notNull())
72
+ .addPrimaryKeyConstraint('subscription_pkey', ['service', 'method'])
73
+ .execute();
74
+ // actor
75
+ await db.schema
76
+ .createTable('actor')
77
+ .addColumn('did', 'varchar', (col) => col.primaryKey())
78
+ .addColumn('handle', 'varchar', (col) => col.unique())
79
+ .addColumn('indexedAt', 'varchar', (col) => col.notNull())
80
+ .execute();
81
+ await db.schema // Supports user search
82
+ .createIndex(`actor_handle_tgrm_idx`)
83
+ .on('actor')
84
+ .using('gist')
85
+ .expression(sql `"handle" gist_trgm_ops`)
86
+ .execute();
87
+ //record
88
+ await db.schema
89
+ .createTable('record')
90
+ .addColumn('uri', 'varchar', (col) => col.primaryKey())
91
+ .addColumn('cid', 'varchar', (col) => col.notNull())
92
+ .addColumn('did', 'varchar', (col) => col.notNull())
93
+ .addColumn('json', 'text', (col) => col.notNull())
94
+ .addColumn('indexedAt', 'varchar', (col) => col.notNull())
95
+ .addColumn('takedownId', 'integer') // foreign key created in moderation-init migration
96
+ .execute();
97
+ }
98
+ export async function down(db) {
99
+ // record
100
+ await db.schema.dropTable('record').execute();
101
+ // actor
102
+ await db.schema.dropTable('actor').execute();
103
+ // subscription
104
+ await db.schema.dropTable('subscription').execute();
105
+ // like
106
+ await db.schema.dropTable('like').execute();
107
+ // follow
108
+ await db.schema.dropTable('follow').execute();
109
+ // post
110
+ await db.schema.dropTable('post').execute();
111
+ // profile
112
+ await db.schema.dropTable('profile').execute();
113
+ }
@@ -0,0 +1,3 @@
1
+ import { Kysely } from 'kysely';
2
+ export declare function up(db: Kysely<unknown>): Promise<void>;
3
+ export declare function down(db: Kysely<unknown>): Promise<void>;
@@ -0,0 +1,11 @@
1
+ export async function up(db) {
2
+ await db.schema
3
+ .createTable('did_cache')
4
+ .addColumn('did', 'varchar', (col) => col.primaryKey())
5
+ .addColumn('doc', 'jsonb', (col) => col.notNull())
6
+ .addColumn('updatedAt', 'bigint', (col) => col.notNull())
7
+ .execute();
8
+ }
9
+ export async function down(db) {
10
+ await db.schema.dropTable('did_cache').execute();
11
+ }
@@ -0,0 +1,2 @@
1
+ export * as _20230309T045948368Z from './20230309T045948368Z-init';
2
+ export * as _20230420T211446071Z from './20230420T211446071Z-did-cache';
@@ -0,0 +1,5 @@
1
+ // NOTE this file can be edited by hand, but it is also appended to by the migration:create command.
2
+ // It's important that every migration is exported from here with the proper name. We'd simplify
3
+ // this with kysely's FileMigrationProvider, but it doesn't play nicely with the build process.
4
+ export * as _20230309T045948368Z from './20230309T045948368Z-init';
5
+ export * as _20230420T211446071Z from './20230420T211446071Z-did-cache';
@@ -0,0 +1,11 @@
1
+ import { Kysely, Migration, MigrationProvider } from 'kysely';
2
+ export declare class CtxMigrationProvider<T> implements MigrationProvider {
3
+ private migrations;
4
+ private ctx;
5
+ constructor(migrations: Record<string, CtxMigration<T>>, ctx: T);
6
+ getMigrations(): Promise<Record<string, Migration>>;
7
+ }
8
+ export interface CtxMigration<T> {
9
+ up(db: Kysely<unknown>, ctx: T): Promise<void>;
10
+ down?(db: Kysely<unknown>, ctx: T): Promise<void>;
11
+ }
@@ -0,0 +1,19 @@
1
+ // Passes a context argument to migrations. We use this to thread the dialect into migrations
2
+ export class CtxMigrationProvider {
3
+ migrations;
4
+ ctx;
5
+ constructor(migrations, ctx) {
6
+ this.migrations = migrations;
7
+ this.ctx = ctx;
8
+ }
9
+ async getMigrations() {
10
+ const ctxMigrations = {};
11
+ Object.entries(this.migrations).forEach(([name, migration]) => {
12
+ ctxMigrations[name] = {
13
+ up: async (db) => await migration.up(db, this.ctx),
14
+ down: async (db) => await migration.down?.(db, this.ctx),
15
+ };
16
+ });
17
+ return ctxMigrations;
18
+ }
19
+ }