@clioplaylists/clio 0.1.4 → 0.1.6

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