@coursebuilder/adapter-drizzle 2.1.0 → 3.0.0-canary.0.0c9beb2ae

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 (307) hide show
  1. package/dist/{chunk-KIQLUFJX.js → chunk-2GW3BJE2.js} +2 -2
  2. package/dist/{chunk-M3WM5Q7W.js → chunk-33ZN7FN7.js} +2 -2
  3. package/dist/chunk-4VZJQAPV.js +74 -0
  4. package/dist/chunk-5FLS4ZBX.js +109 -0
  5. package/dist/chunk-5YR5M22S.js +147 -0
  6. package/dist/chunk-6XQ6C3IX.js +18 -0
  7. package/dist/chunk-AIDM2CH6.js +146 -0
  8. package/dist/chunk-ALTODDUX.js +173 -0
  9. package/dist/chunk-AZY2VRAE.js +63 -0
  10. package/dist/chunk-BS7T27VL.js +239 -0
  11. package/dist/chunk-CN3FCRLR.js +55 -0
  12. package/dist/chunk-EAXC4CQD.js +245 -0
  13. package/dist/chunk-EDDG2YFS.js +249 -0
  14. package/dist/chunk-EDKWCMA7.js +210 -0
  15. package/dist/{chunk-CFSRMUNC.js → chunk-EDM6DKA5.js} +2 -2
  16. package/dist/{chunk-EZEQQJNH.js → chunk-EIQBTF5J.js} +2 -2
  17. package/dist/chunk-FYT7RTVW.js +248 -0
  18. package/dist/{chunk-DUFH5L2F.js → chunk-INZTF6QV.js} +2 -2
  19. package/dist/{chunk-3AF6MZQ7.js → chunk-JVHX4JHA.js} +2 -2
  20. package/dist/chunk-LWEKWDLC.js +300 -0
  21. package/dist/chunk-OJPEBGGE.js +139 -0
  22. package/dist/chunk-QKOSV34V.js +16268 -0
  23. package/dist/chunk-QO3QE3LE.js +330 -0
  24. package/dist/chunk-QQKNNFFB.js +399 -0
  25. package/dist/chunk-RBHCV3UW.js +20 -0
  26. package/dist/chunk-TNH2C27F.js +252 -0
  27. package/dist/chunk-TNWNW666.js +133 -0
  28. package/dist/chunk-VBEXYQ6L.js +156 -0
  29. package/dist/chunk-W3ILNMLD.js +265 -0
  30. package/dist/chunk-WJ2ZUXL3.js +71 -0
  31. package/dist/{chunk-4SWTV7Z3.js → chunk-WUMDFFN3.js} +2 -2
  32. package/dist/{chunk-FJGNLVE4.js → chunk-X7DRYXB7.js} +2 -2
  33. package/dist/{chunk-PNPTKVJ4.js → chunk-XUBZKYH6.js} +24 -15
  34. package/dist/{chunk-MYG6PCE3.js → chunk-ZY4AFKUQ.js} +2 -2
  35. package/dist/index.d.ts +5 -11
  36. package/dist/index.js +42 -19
  37. package/dist/lib/mysql/cms-resource-actions.cjs +15932 -4129
  38. package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -1
  39. package/dist/lib/mysql/cms-resource-actions.d.cts +10 -25
  40. package/dist/lib/mysql/cms-resource-actions.d.ts +10 -25
  41. package/dist/lib/mysql/cms-resource-actions.js +2 -1
  42. package/dist/lib/mysql/context.cjs +3380 -0
  43. package/dist/lib/mysql/context.cjs.map +1 -0
  44. package/dist/lib/mysql/context.d.cts +15 -0
  45. package/dist/lib/mysql/context.d.ts +15 -0
  46. package/dist/lib/mysql/context.js +34 -0
  47. package/dist/lib/mysql/context.js.map +1 -0
  48. package/dist/lib/mysql/index.cjs +21648 -15013
  49. package/dist/lib/mysql/index.cjs.map +1 -1
  50. package/dist/lib/mysql/index.d.cts +24 -14300
  51. package/dist/lib/mysql/index.d.ts +24 -14300
  52. package/dist/lib/mysql/index.js +47 -23
  53. package/dist/lib/mysql/ports/auth-storage.cjs +84 -0
  54. package/dist/lib/mysql/ports/auth-storage.cjs.map +1 -0
  55. package/dist/lib/mysql/ports/auth-storage.d.cts +22 -0
  56. package/dist/lib/mysql/ports/auth-storage.d.ts +22 -0
  57. package/dist/lib/mysql/ports/auth-storage.js +8 -0
  58. package/dist/lib/mysql/ports/auth-storage.js.map +1 -0
  59. package/dist/lib/mysql/ports/catalog.cjs +16688 -0
  60. package/dist/lib/mysql/ports/catalog.cjs.map +1 -0
  61. package/dist/lib/mysql/ports/catalog.d.cts +24 -0
  62. package/dist/lib/mysql/ports/catalog.d.ts +24 -0
  63. package/dist/lib/mysql/ports/catalog.js +9 -0
  64. package/dist/lib/mysql/ports/catalog.js.map +1 -0
  65. package/dist/lib/mysql/ports/content-resource.cjs +321 -0
  66. package/dist/lib/mysql/ports/content-resource.cjs.map +1 -0
  67. package/dist/lib/mysql/ports/content-resource.d.cts +23 -0
  68. package/dist/lib/mysql/ports/content-resource.d.ts +23 -0
  69. package/dist/lib/mysql/ports/content-resource.js +8 -0
  70. package/dist/lib/mysql/ports/content-resource.js.map +1 -0
  71. package/dist/lib/mysql/ports/coupon.cjs +16524 -0
  72. package/dist/lib/mysql/ports/coupon.cjs.map +1 -0
  73. package/dist/lib/mysql/ports/coupon.d.cts +22 -0
  74. package/dist/lib/mysql/ports/coupon.d.ts +22 -0
  75. package/dist/lib/mysql/ports/coupon.js +9 -0
  76. package/dist/lib/mysql/ports/coupon.js.map +1 -0
  77. package/dist/lib/mysql/ports/entitlement.cjs +16350 -0
  78. package/dist/lib/mysql/ports/entitlement.cjs.map +1 -0
  79. package/dist/lib/mysql/ports/entitlement.d.cts +22 -0
  80. package/dist/lib/mysql/ports/entitlement.d.ts +22 -0
  81. package/dist/lib/mysql/ports/entitlement.js +9 -0
  82. package/dist/lib/mysql/ports/entitlement.js.map +1 -0
  83. package/dist/lib/mysql/ports/identity.cjs +154 -0
  84. package/dist/lib/mysql/ports/identity.cjs.map +1 -0
  85. package/dist/lib/mysql/ports/identity.d.cts +22 -0
  86. package/dist/lib/mysql/ports/identity.d.ts +22 -0
  87. package/dist/lib/mysql/ports/identity.js +8 -0
  88. package/dist/lib/mysql/ports/identity.js.map +1 -0
  89. package/dist/lib/mysql/ports/merchant.cjs +194 -0
  90. package/dist/lib/mysql/ports/merchant.cjs.map +1 -0
  91. package/dist/lib/mysql/ports/merchant.d.cts +22 -0
  92. package/dist/lib/mysql/ports/merchant.d.ts +22 -0
  93. package/dist/lib/mysql/ports/merchant.js +8 -0
  94. package/dist/lib/mysql/ports/merchant.js.map +1 -0
  95. package/dist/lib/mysql/ports/organization.cjs +16426 -0
  96. package/dist/lib/mysql/ports/organization.cjs.map +1 -0
  97. package/dist/lib/mysql/ports/organization.d.cts +22 -0
  98. package/dist/lib/mysql/ports/organization.d.ts +22 -0
  99. package/dist/lib/mysql/ports/organization.js +9 -0
  100. package/dist/lib/mysql/ports/organization.js.map +1 -0
  101. package/dist/lib/mysql/ports/progress.cjs +16544 -0
  102. package/dist/lib/mysql/ports/progress.cjs.map +1 -0
  103. package/dist/lib/mysql/ports/progress.d.cts +22 -0
  104. package/dist/lib/mysql/ports/progress.d.ts +22 -0
  105. package/dist/lib/mysql/ports/progress.js +9 -0
  106. package/dist/lib/mysql/ports/progress.js.map +1 -0
  107. package/dist/lib/mysql/ports/purchase.cjs +16609 -0
  108. package/dist/lib/mysql/ports/purchase.cjs.map +1 -0
  109. package/dist/lib/mysql/ports/purchase.d.cts +23 -0
  110. package/dist/lib/mysql/ports/purchase.d.ts +23 -0
  111. package/dist/lib/mysql/ports/purchase.js +9 -0
  112. package/dist/lib/mysql/ports/purchase.js.map +1 -0
  113. package/dist/lib/mysql/ports/subscription.cjs +76 -0
  114. package/dist/lib/mysql/ports/subscription.cjs.map +1 -0
  115. package/dist/lib/mysql/ports/subscription.d.cts +22 -0
  116. package/dist/lib/mysql/ports/subscription.d.ts +22 -0
  117. package/dist/lib/mysql/ports/subscription.js +8 -0
  118. package/dist/lib/mysql/ports/subscription.js.map +1 -0
  119. package/dist/lib/mysql/schema.cjs +3373 -0
  120. package/dist/lib/mysql/schema.cjs.map +1 -0
  121. package/dist/lib/mysql/schema.d.cts +14385 -0
  122. package/dist/lib/mysql/schema.d.ts +14385 -0
  123. package/dist/lib/mysql/schema.js +35 -0
  124. package/dist/lib/mysql/schema.js.map +1 -0
  125. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  126. package/dist/lib/mysql/schemas/auth/accounts.js +6 -6
  127. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  128. package/dist/lib/mysql/schemas/auth/device-access-token.js +7 -7
  129. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  130. package/dist/lib/mysql/schemas/auth/device-verification.js +7 -7
  131. package/dist/lib/mysql/schemas/auth/personal-access-token.cjs.map +1 -1
  132. package/dist/lib/mysql/schemas/auth/personal-access-token.js +7 -7
  133. package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
  134. package/dist/lib/mysql/schemas/auth/profiles.js +6 -6
  135. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  136. package/dist/lib/mysql/schemas/auth/role-permissions.js +7 -7
  137. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  138. package/dist/lib/mysql/schemas/auth/roles.js +6 -6
  139. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  140. package/dist/lib/mysql/schemas/auth/sessions.js +7 -7
  141. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  142. package/dist/lib/mysql/schemas/auth/user-permissions.js +6 -6
  143. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  144. package/dist/lib/mysql/schemas/auth/user-prefs.js +6 -6
  145. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  146. package/dist/lib/mysql/schemas/auth/user-roles.js +6 -6
  147. package/dist/lib/mysql/schemas/auth/users.cjs +5 -1
  148. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  149. package/dist/lib/mysql/schemas/auth/users.js +6 -6
  150. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  151. package/dist/lib/mysql/schemas/commerce/coupon.js +6 -6
  152. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  153. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +6 -6
  154. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
  155. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +6 -6
  156. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  157. package/dist/lib/mysql/schemas/commerce/price.js +6 -6
  158. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  159. package/dist/lib/mysql/schemas/commerce/product.js +6 -6
  160. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  161. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +7 -7
  162. package/dist/lib/mysql/schemas/commerce/purchase.cjs +11 -2
  163. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  164. package/dist/lib/mysql/schemas/commerce/purchase.js +6 -6
  165. package/dist/lib/mysql/schemas/commerce/subscription.cjs +6 -1
  166. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
  167. package/dist/lib/mysql/schemas/commerce/subscription.js +6 -6
  168. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  169. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +7 -7
  170. package/dist/lib/mysql/schemas/communication/comment.cjs +5 -1
  171. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  172. package/dist/lib/mysql/schemas/communication/comment.js +6 -6
  173. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +5 -1
  174. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  175. package/dist/lib/mysql/schemas/communication/communication-preferences.js +6 -6
  176. package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -1
  177. package/dist/lib/mysql/schemas/communication/question-response.js +7 -7
  178. package/dist/lib/mysql/schemas/content/content-contributions.cjs +5 -1
  179. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  180. package/dist/lib/mysql/schemas/content/content-contributions.js +6 -6
  181. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  182. package/dist/lib/mysql/schemas/content/content-resource-product.js +6 -6
  183. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  184. package/dist/lib/mysql/schemas/content/content-resource-resource.js +6 -6
  185. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  186. package/dist/lib/mysql/schemas/content/content-resource-tag.js +6 -6
  187. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  188. package/dist/lib/mysql/schemas/content/content-resource-version.js +6 -6
  189. package/dist/lib/mysql/schemas/content/content-resource.cjs +5 -1
  190. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  191. package/dist/lib/mysql/schemas/content/content-resource.js +6 -6
  192. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  193. package/dist/lib/mysql/schemas/content/tag-tag.js +6 -6
  194. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  195. package/dist/lib/mysql/schemas/content/tag.js +6 -6
  196. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +11 -2
  197. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
  198. package/dist/lib/mysql/schemas/entitlements/entitlement.js +7 -7
  199. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +11 -2
  200. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
  201. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +6 -6
  202. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +11 -2
  203. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
  204. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +16 -0
  205. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +16 -0
  206. package/dist/lib/mysql/schemas/org/organization-memberships.js +6 -6
  207. package/dist/lib/mysql/schemas/org/organizations.cjs +11 -2
  208. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
  209. package/dist/lib/mysql/schemas/org/organizations.d.cts +16 -0
  210. package/dist/lib/mysql/schemas/org/organizations.d.ts +16 -0
  211. package/dist/lib/mysql/schemas/org/organizations.js +6 -6
  212. package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs +40 -0
  213. package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs.map +1 -0
  214. package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.cts +4 -0
  215. package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.ts +4 -0
  216. package/dist/lib/mysql/workflows/content-resource-workflow-utils.js +10 -0
  217. package/dist/lib/mysql/workflows/content-resource-workflow-utils.js.map +1 -0
  218. package/dist/lib/mysql/workflows/create-cohort.cjs +184 -0
  219. package/dist/lib/mysql/workflows/create-cohort.cjs.map +1 -0
  220. package/dist/lib/mysql/workflows/create-cohort.d.cts +24 -0
  221. package/dist/lib/mysql/workflows/create-cohort.d.ts +24 -0
  222. package/dist/lib/mysql/workflows/create-cohort.js +9 -0
  223. package/dist/lib/mysql/workflows/create-cohort.js.map +1 -0
  224. package/dist/lib/mysql/workflows/create-event-series.cjs +283 -0
  225. package/dist/lib/mysql/workflows/create-event-series.cjs.map +1 -0
  226. package/dist/lib/mysql/workflows/create-event-series.d.cts +24 -0
  227. package/dist/lib/mysql/workflows/create-event-series.d.ts +24 -0
  228. package/dist/lib/mysql/workflows/create-event-series.js +9 -0
  229. package/dist/lib/mysql/workflows/create-event-series.js.map +1 -0
  230. package/dist/lib/mysql/workflows/create-event.cjs +194 -0
  231. package/dist/lib/mysql/workflows/create-event.cjs.map +1 -0
  232. package/dist/lib/mysql/workflows/create-event.d.cts +24 -0
  233. package/dist/lib/mysql/workflows/create-event.d.ts +24 -0
  234. package/dist/lib/mysql/workflows/create-event.js +9 -0
  235. package/dist/lib/mysql/workflows/create-event.js.map +1 -0
  236. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs +231 -0
  237. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs.map +1 -0
  238. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.cts +22 -0
  239. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.ts +22 -0
  240. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js +8 -0
  241. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js.map +1 -0
  242. package/dist/lib/mysql/workflows/create-workshop.cjs +286 -0
  243. package/dist/lib/mysql/workflows/create-workshop.cjs.map +1 -0
  244. package/dist/lib/mysql/workflows/create-workshop.d.cts +24 -0
  245. package/dist/lib/mysql/workflows/create-workshop.d.ts +24 -0
  246. package/dist/lib/mysql/workflows/create-workshop.js +9 -0
  247. package/dist/lib/mysql/workflows/create-workshop.js.map +1 -0
  248. package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs +130 -0
  249. package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs.map +1 -0
  250. package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.cts +24 -0
  251. package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.ts +24 -0
  252. package/dist/lib/mysql/workflows/redeem-full-price-coupon.js +8 -0
  253. package/dist/lib/mysql/workflows/redeem-full-price-coupon.js.map +1 -0
  254. package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs +95 -0
  255. package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs.map +1 -0
  256. package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.cts +30 -0
  257. package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.ts +30 -0
  258. package/dist/lib/mysql/workflows/transfer-purchase-to-user.js +8 -0
  259. package/dist/lib/mysql/workflows/transfer-purchase-to-user.js.map +1 -0
  260. package/dist/lib/utils.d.cts +1 -10
  261. package/dist/lib/utils.d.ts +1 -10
  262. package/dist/types.d.ts +14 -0
  263. package/dist/types.js +1 -0
  264. package/package.json +9 -5
  265. package/src/index.ts +3 -2
  266. package/src/lib/mysql/cms-resource-actions.ts +37 -0
  267. package/src/lib/mysql/context.ts +20 -0
  268. package/src/lib/mysql/index.ts +118 -4872
  269. package/src/lib/mysql/ports/auth-storage.ts +139 -0
  270. package/src/lib/mysql/ports/catalog.ts +610 -0
  271. package/src/lib/mysql/ports/content-resource.ts +442 -0
  272. package/src/lib/mysql/ports/coupon.ts +387 -0
  273. package/src/lib/mysql/ports/entitlement.ts +96 -0
  274. package/src/lib/mysql/ports/identity.ts +160 -0
  275. package/src/lib/mysql/ports/merchant.ts +274 -0
  276. package/src/lib/mysql/ports/organization.ts +216 -0
  277. package/src/lib/mysql/ports/progress.ts +366 -0
  278. package/src/lib/mysql/ports/purchase.ts +517 -0
  279. package/src/lib/mysql/ports/subscription.ts +93 -0
  280. package/src/lib/mysql/schema.ts +374 -0
  281. package/src/lib/mysql/schemas/org/organization-memberships.ts +7 -0
  282. package/src/lib/mysql/schemas/org/organizations.ts +8 -0
  283. package/src/lib/mysql/workflows/content-resource-workflow-utils.ts +22 -0
  284. package/src/lib/mysql/workflows/create-cohort.ts +239 -0
  285. package/src/lib/mysql/workflows/create-event-series.ts +384 -0
  286. package/src/lib/mysql/workflows/create-event.ts +232 -0
  287. package/src/lib/mysql/workflows/create-merchant-charge-and-purchase.ts +365 -0
  288. package/src/lib/mysql/workflows/create-workshop.ts +372 -0
  289. package/src/lib/mysql/workflows/redeem-full-price-coupon.ts +179 -0
  290. package/src/lib/mysql/workflows/transfer-purchase-to-user.ts +142 -0
  291. package/src/types.ts +33 -0
  292. package/dist/authjs.d.ts +0 -27
  293. package/dist/authjs.js +0 -1
  294. package/dist/chunk-25RKHMRM.js +0 -8729
  295. package/dist/chunk-2AW5KYAK.js +0 -101
  296. package/dist/chunk-3EF5ZXLG.js +0 -101
  297. package/dist/chunk-7FBSP3VD.js +0 -78
  298. package/dist/chunk-AP5HBIV4.js +0 -112
  299. package/dist/chunk-F56AI52P.js +0 -49
  300. package/dist/chunk-HAQZSRJL.js +0 -4696
  301. package/dist/chunk-I2U5PTWN.js +0 -79
  302. package/dist/chunk-IBQGXFEX.js +0 -8729
  303. package/dist/chunk-PJORQUQP.js +0 -58
  304. package/dist/chunk-W6RPAAKG.js +0 -2144
  305. package/dist/chunk-WKJTU24D.js +0 -88
  306. package/dist/chunk-WWBSNLRC.js +0 -63
  307. package/src/authjs.ts +0 -34
@@ -0,0 +1,173 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-2X5XVNDN.js";
4
+
5
+ // src/lib/mysql/ports/merchant.ts
6
+ import { and, desc, eq } from "drizzle-orm";
7
+ import { v4 } from "uuid";
8
+ import { merchantChargeSchema, merchantEventsSchema, merchantPriceSchema, merchantProductSchema } from "@coursebuilder/core/schemas";
9
+ import { merchantAccountSchema } from "@coursebuilder/core/schemas/merchant-account-schema";
10
+ import { merchantCustomerSchema } from "@coursebuilder/core/schemas/merchant-customer-schema";
11
+ import { MerchantSessionSchema } from "@coursebuilder/core/schemas/merchant-session";
12
+ import { MerchantSubscriptionSchema } from "@coursebuilder/core/schemas/merchant-subscription";
13
+ import { logger as baseLogger } from "@coursebuilder/utils/logger";
14
+ var logger = baseLogger;
15
+ function createMerchantPort({ client, tables }) {
16
+ const { merchantAccount, merchantCharge, merchantCustomer, merchantEvents, merchantPrice, merchantProduct, merchantSession, merchantSubscription: merchantSubscriptionTable } = tables;
17
+ const merchantPort = {
18
+ createMerchantCustomer: async (options) => {
19
+ await client.insert(merchantCustomer).values({
20
+ id: `mc_${v4()}`,
21
+ identifier: options.identifier,
22
+ merchantAccountId: options.merchantAccountId,
23
+ userId: options.userId,
24
+ status: 1
25
+ });
26
+ return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
27
+ where: eq(merchantCustomer.identifier, options.identifier)
28
+ }));
29
+ },
30
+ getMerchantAccount: async (options) => {
31
+ return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
32
+ where: eq(merchantAccount.label, options.provider)
33
+ }));
34
+ },
35
+ getMerchantPriceForProductId: async (productId) => {
36
+ const merchantPriceData = await client.query.merchantPrice.findFirst({
37
+ where: and(eq(merchantPrice.merchantProductId, productId), eq(merchantPrice.status, 1))
38
+ });
39
+ const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
40
+ if (!parsedMerchantPrice.success) {
41
+ logger.error(parsedMerchantPrice.error, {
42
+ event: "adapter.merchantPrice.parse_failed",
43
+ productId
44
+ });
45
+ return null;
46
+ }
47
+ return parsedMerchantPrice.data;
48
+ },
49
+ getMerchantProductForProductId: async (productId) => {
50
+ const merchantProductData = await client.query.merchantProduct.findFirst({
51
+ where: eq(merchantProduct.productId, productId)
52
+ });
53
+ if (!merchantProductData)
54
+ return null;
55
+ return merchantProductSchema.parse(merchantProductData);
56
+ },
57
+ getMerchantCustomerForUserId: async (userId) => {
58
+ const merchantCustomerData = await client.query.merchantCustomer.findFirst({
59
+ where: eq(merchantCustomer.userId, userId)
60
+ });
61
+ if (!merchantCustomerData)
62
+ return null;
63
+ return merchantCustomerSchema.parse(merchantCustomerData);
64
+ },
65
+ async createMerchantSession(options) {
66
+ const id = `ms_${v4()}`;
67
+ await client.insert(merchantSession).values({
68
+ id,
69
+ identifier: options.identifier,
70
+ merchantAccountId: options.merchantAccountId,
71
+ ...options.organizationId ? {
72
+ organizationId: options.organizationId
73
+ } : {}
74
+ });
75
+ return MerchantSessionSchema.parse(await client.query.merchantSession.findFirst({
76
+ where: eq(merchantSession.id, id)
77
+ }));
78
+ },
79
+ async findOrCreateMerchantCustomer(options) {
80
+ const merchantCustomer2 = merchantCustomerSchema.nullable().optional().parse(await client.query.merchantCustomer.findFirst({
81
+ where: (merchantCustomer3, { eq: eq2 }) => eq2(merchantCustomer3.identifier, options.identifier)
82
+ }));
83
+ if (merchantCustomer2) {
84
+ return merchantCustomer2;
85
+ }
86
+ return await merchantPort.createMerchantCustomer({
87
+ identifier: options.identifier,
88
+ merchantAccountId: options.merchantAccountId,
89
+ userId: options.user.id
90
+ });
91
+ },
92
+ async createMerchantEvent(options) {
93
+ const eventId = `me_${v4()}`;
94
+ await client.insert(merchantEvents).values({
95
+ id: eventId,
96
+ merchantAccountId: options.merchantAccountId,
97
+ identifier: options.identifier,
98
+ payload: options.payload
99
+ });
100
+ const createdEvent = await client.query.merchantEvents.findFirst({
101
+ where: eq(merchantEvents.id, eventId)
102
+ });
103
+ return merchantEventsSchema.parse(createdEvent);
104
+ },
105
+ async getMerchantEventByIdentifier(identifier) {
106
+ const event = await client.query.merchantEvents.findFirst({
107
+ where: eq(merchantEvents.identifier, identifier)
108
+ });
109
+ return event ? merchantEventsSchema.parse(event) : null;
110
+ },
111
+ async getMerchantEventsByAccount(merchantAccountId) {
112
+ const events = await client.query.merchantEvents.findMany({
113
+ where: eq(merchantEvents.merchantAccountId, merchantAccountId),
114
+ orderBy: [
115
+ desc(merchantEvents.createdAt)
116
+ ]
117
+ });
118
+ return events.map((event) => merchantEventsSchema.parse(event));
119
+ },
120
+ async getMerchantCharge(merchantChargeId) {
121
+ const mCharge = await client.query.merchantCharge.findFirst({
122
+ where: eq(merchantCharge.id, merchantChargeId)
123
+ });
124
+ const parsed = merchantChargeSchema.safeParse(mCharge);
125
+ if (!parsed.success) {
126
+ logger.error(parsed.error, {
127
+ event: "adapter.merchantCharge.parse_failed",
128
+ merchantChargeId
129
+ });
130
+ return null;
131
+ }
132
+ return parsed.data;
133
+ },
134
+ async getMerchantProduct(stripeProductId) {
135
+ return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
136
+ where: eq(merchantProduct.identifier, stripeProductId)
137
+ }));
138
+ },
139
+ getMerchantSubscription: async (merchantSubscriptionId) => {
140
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
141
+ where: eq(merchantSubscriptionTable.id, merchantSubscriptionId)
142
+ }));
143
+ },
144
+ createMerchantSubscription: async (options) => {
145
+ const id = crypto.randomUUID();
146
+ await client.insert(merchantSubscriptionTable).values({
147
+ ...options,
148
+ id
149
+ });
150
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
151
+ where: eq(merchantSubscriptionTable.id, id)
152
+ }));
153
+ },
154
+ updateMerchantSubscription: async (options) => {
155
+ await client.update(merchantSubscriptionTable).set({
156
+ status: Number(options.status)
157
+ }).where(eq(merchantSubscriptionTable.id, options.merchantSubscriptionId));
158
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
159
+ where: eq(merchantSubscriptionTable.id, options.merchantSubscriptionId)
160
+ }));
161
+ },
162
+ deleteMerchantSubscription: async (merchantSubscriptionId) => {
163
+ await client.delete(merchantSubscriptionTable).where(eq(merchantSubscriptionTable.id, merchantSubscriptionId));
164
+ }
165
+ };
166
+ return merchantPort;
167
+ }
168
+ __name(createMerchantPort, "createMerchantPort");
169
+
170
+ export {
171
+ createMerchantPort
172
+ };
173
+ //# sourceMappingURL=chunk-ALTODDUX.js.map
@@ -0,0 +1,63 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-2X5XVNDN.js";
4
+
5
+ // src/lib/mysql/ports/auth-storage.ts
6
+ import { addSeconds, isAfter } from "date-fns";
7
+ import { and, eq } from "drizzle-orm";
8
+ function createAuthStoragePort({ client, tables }) {
9
+ const { accounts, sessions, users, verificationTokens } = tables;
10
+ return {
11
+ createSession: async (data) => {
12
+ await client.insert(sessions).values(data);
13
+ return await client.select().from(sessions).where(eq(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
14
+ },
15
+ getSessionAndUser: async (data) => {
16
+ return await client.select({
17
+ session: sessions,
18
+ user: users
19
+ }).from(sessions).where(eq(sessions.sessionToken, data)).innerJoin(users, eq(users.id, sessions.userId)).then((res) => res[0]) ?? null;
20
+ },
21
+ updateSession: async (data) => {
22
+ await client.update(sessions).set(data).where(eq(sessions.sessionToken, data.sessionToken));
23
+ return await client.select().from(sessions).where(eq(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
24
+ },
25
+ deleteSession: async (sessionToken) => {
26
+ const session = await client.select().from(sessions).where(eq(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
27
+ await client.delete(sessions).where(eq(sessions.sessionToken, sessionToken));
28
+ return session;
29
+ },
30
+ useVerificationToken: async (token) => {
31
+ try {
32
+ const deletedToken = await client.select().from(verificationTokens).where(and(eq(verificationTokens.identifier, token.identifier), eq(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
33
+ if (deletedToken?.createdAt) {
34
+ const TIMEOUT_IN_SECONDS = 90;
35
+ const expireMultipleClicks = addSeconds(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
36
+ const now = /* @__PURE__ */ new Date();
37
+ if (isAfter(expireMultipleClicks, now)) {
38
+ const { id: _, ...verificationToken } = token;
39
+ return deletedToken;
40
+ }
41
+ await client.delete(verificationTokens).where(and(eq(verificationTokens.identifier, token.identifier), eq(verificationTokens.token, token.token)));
42
+ return deletedToken;
43
+ }
44
+ return deletedToken;
45
+ } catch (err) {
46
+ throw new Error("No verification token found.");
47
+ }
48
+ },
49
+ deleteUser: async (id) => {
50
+ const user = await client.select().from(users).where(eq(users.id, id)).then((res) => res[0] ?? null);
51
+ await client.delete(users).where(eq(users.id, id));
52
+ await client.delete(sessions).where(eq(sessions.userId, id));
53
+ await client.delete(accounts).where(eq(accounts.userId, id));
54
+ return user;
55
+ }
56
+ };
57
+ }
58
+ __name(createAuthStoragePort, "createAuthStoragePort");
59
+
60
+ export {
61
+ createAuthStoragePort
62
+ };
63
+ //# sourceMappingURL=chunk-AZY2VRAE.js.map
@@ -0,0 +1,239 @@
1
+ import {
2
+ external_exports
3
+ } from "./chunk-QKOSV34V.js";
4
+ import {
5
+ __name
6
+ } from "./chunk-2X5XVNDN.js";
7
+
8
+ // src/lib/mysql/cms-resource-actions.ts
9
+ import { and, asc, desc, eq, inArray, isNull, notInArray, sql } from "drizzle-orm";
10
+ var jsonNumber = external_exports.preprocess((value) => value == null ? null : Number(value), external_exports.number().nullable().optional());
11
+ var CmsImageResourceRowSchema = external_exports.object({
12
+ id: external_exports.string(),
13
+ url: external_exports.string(),
14
+ alt: external_exports.string().optional().nullable(),
15
+ // Human filename (the uploaded file's name) — the media grid prefers it
16
+ // over `alt` for the tile label; absent on older rows.
17
+ name: external_exports.string().optional().nullable(),
18
+ // Row creation time — the media tab's unified grid sorts by it.
19
+ createdAt: external_exports.coerce.date().optional().nullable(),
20
+ // Cloudinary metadata — optional/nullable so pre-metadata rows keep
21
+ // working (JSON_EXTRACT returns NULL when the key is absent). Numeric
22
+ // coercion preserves null (plain z.coerce.number() would turn it into 0);
23
+ // MySQL JSON numerics can arrive as strings through some drivers.
24
+ width: jsonNumber,
25
+ height: jsonNumber,
26
+ bytes: jsonNumber,
27
+ format: external_exports.string().optional().nullable()
28
+ });
29
+ var ListResourcesForPickerInputSchema = external_exports.object({
30
+ types: external_exports.array(external_exports.string()).min(1),
31
+ search: external_exports.string().trim().max(200).optional(),
32
+ excludeIds: external_exports.array(external_exports.string()).default([]),
33
+ limit: external_exports.number().int().min(1).max(100).default(20)
34
+ });
35
+ function createCmsResourceActions(options) {
36
+ const { db, contentResource, contentResourceResource, contentResourceProduct, getAuthContext, getEditHref } = options;
37
+ const dbQuery = db.query;
38
+ async function assertCanUpdateContent() {
39
+ const { session, ability } = await getAuthContext();
40
+ if (!session?.user || !ability.can("update", "Content")) {
41
+ throw new Error("Unauthorized");
42
+ }
43
+ }
44
+ __name(assertCanUpdateContent, "assertCanUpdateContent");
45
+ async function listResourcesForPicker(input) {
46
+ await assertCanUpdateContent();
47
+ const { types, search, excludeIds, limit } = ListResourcesForPickerInputSchema.parse(input);
48
+ const conditions = [
49
+ inArray(contentResource.type, types),
50
+ isNull(contentResource.deletedAt)
51
+ ];
52
+ if (excludeIds.length > 0) {
53
+ conditions.push(notInArray(contentResource.id, excludeIds));
54
+ }
55
+ if (search) {
56
+ const escaped = search.replace(/[\\%_]/g, "\\$&");
57
+ conditions.push(sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.title')) LIKE ${`%${escaped}%`}`);
58
+ }
59
+ const rows = await db.select({
60
+ id: contentResource.id,
61
+ type: contentResource.type,
62
+ title: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.title'))`,
63
+ // Generated (indexed) column — cheaper than a JSON_EXTRACT here.
64
+ slug: contentResource.slug,
65
+ state: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.state'))`,
66
+ postType: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.postType'))`,
67
+ updatedAt: contentResource.updatedAt
68
+ }).from(contentResource).where(and(...conditions)).orderBy(desc(contentResource.updatedAt)).limit(limit);
69
+ return rows.map((row) => ({
70
+ id: row.id,
71
+ type: row.type,
72
+ title: row.title ?? row.slug ?? row.id,
73
+ slug: row.slug ?? "",
74
+ state: row.state ?? "draft",
75
+ detail: row.postType ?? void 0,
76
+ updatedAt: row.updatedAt ?? void 0
77
+ }));
78
+ }
79
+ __name(listResourcesForPicker, "listResourcesForPicker");
80
+ async function listVideoResourcesForPicker(input) {
81
+ await assertCanUpdateContent();
82
+ const excludeIds = input.excludeIds ?? [];
83
+ const limit = Math.min(Math.max(input.limit ?? 20, 1), 200);
84
+ const offset = Math.max(0, Math.floor(input.offset ?? 0));
85
+ const conditions = [
86
+ eq(contentResource.type, "videoResource"),
87
+ isNull(contentResource.deletedAt)
88
+ ];
89
+ if (excludeIds.length > 0) {
90
+ conditions.push(notInArray(contentResource.id, excludeIds));
91
+ }
92
+ if (input.search) {
93
+ const escaped = input.search.replace(/[\\%_]/g, "\\$&");
94
+ conditions.push(sql`${contentResource.id} LIKE ${`%${escaped}%`}`);
95
+ }
96
+ const pageRows = await db.select({
97
+ id: contentResource.id,
98
+ createdAt: contentResource.createdAt
99
+ }).from(contentResource).where(and(...conditions)).orderBy(desc(contentResource.createdAt)).limit(offset + limit + 50);
100
+ if (pageRows.length === 0)
101
+ return [];
102
+ const detailRows = await db.select({
103
+ id: contentResource.id,
104
+ state: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.state'))`,
105
+ muxPlaybackId: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.muxPlaybackId'))`,
106
+ duration: sql`JSON_EXTRACT(${contentResource.fields}, '$.duration')`,
107
+ createdAt: contentResource.createdAt
108
+ }).from(contentResource).where(inArray(contentResource.id, pageRows.map((row) => row.id)));
109
+ const byId = new Map(detailRows.map((row) => [
110
+ row.id,
111
+ row
112
+ ]));
113
+ const rows = pageRows.flatMap((page) => byId.get(page.id) ?? []).filter((row) => row.state !== "deleted" && row.state !== "errored").slice(offset, offset + limit);
114
+ return rows.map((row) => ({
115
+ id: row.id,
116
+ // videoResources have no title/slug — the filename-derived id is the
117
+ // human-readable handle.
118
+ title: row.id,
119
+ state: row.state ?? "processing",
120
+ thumbnailUrl: row.muxPlaybackId ? `https://image.mux.com/${row.muxPlaybackId}/thumbnail.png?width=96&height=54&fit_mode=smartcrop` : void 0,
121
+ duration: row.duration != null ? Number(row.duration) : null,
122
+ createdAt: row.createdAt
123
+ }));
124
+ }
125
+ __name(listVideoResourcesForPicker, "listVideoResourcesForPicker");
126
+ async function listImageResources({ limit, offset = 0 }) {
127
+ const capped = Math.min(Math.max(1, Math.floor(limit)), 200);
128
+ const skip = Math.max(0, Math.floor(offset));
129
+ const rows = await db.select({
130
+ id: contentResource.id,
131
+ url: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.url'))`,
132
+ alt: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.alt'))`,
133
+ name: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.name'))`,
134
+ createdAt: contentResource.createdAt,
135
+ // Cloudinary metadata — NULL on pre-metadata rows (backfillable).
136
+ width: sql`JSON_EXTRACT(${contentResource.fields}, '$.width')`,
137
+ height: sql`JSON_EXTRACT(${contentResource.fields}, '$.height')`,
138
+ bytes: sql`JSON_EXTRACT(${contentResource.fields}, '$.bytes')`,
139
+ format: sql`JSON_UNQUOTE(JSON_EXTRACT(${contentResource.fields}, '$.format'))`
140
+ }).from(contentResource).where(eq(contentResource.type, "imageResource")).orderBy(desc(contentResource.createdAt)).limit(capped).offset(skip);
141
+ const parsed = external_exports.array(CmsImageResourceRowSchema).safeParse(rows);
142
+ return parsed.success ? parsed.data : [];
143
+ }
144
+ __name(listImageResources, "listImageResources");
145
+ async function getPostListMemberships(postId) {
146
+ await assertCanUpdateContent();
147
+ const links = await dbQuery.contentResourceResource.findMany({
148
+ where: and(eq(contentResourceResource.resourceId, postId), isNull(contentResourceResource.deletedAt)),
149
+ with: {
150
+ resourceOf: true
151
+ }
152
+ });
153
+ return links.filter((link) => link.resourceOf?.type === "list" && !link.resourceOf.deletedAt).map((link) => {
154
+ const fields = link.resourceOf.fields ?? {};
155
+ return {
156
+ listId: link.resourceOf.id,
157
+ title: fields.title ?? fields.slug ?? link.resourceOf.id,
158
+ slug: fields.slug ?? void 0,
159
+ href: fields.slug ? getEditHref("list", fields.slug) : void 0,
160
+ position: link.position
161
+ };
162
+ });
163
+ }
164
+ __name(getPostListMemberships, "getPostListMemberships");
165
+ async function getResourceParents(resourceId) {
166
+ await assertCanUpdateContent();
167
+ const [containerLinks, productLinks] = await Promise.all([
168
+ dbQuery.contentResourceResource.findMany({
169
+ where: eq(contentResourceResource.resourceId, resourceId),
170
+ with: {
171
+ resourceOf: {
172
+ with: {
173
+ // Sibling JOIN rows only (no nested resource objects) —
174
+ // cheap, and enough to compute this resource's ordinal.
175
+ resources: {
176
+ orderBy: asc(contentResourceResource.position)
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }),
182
+ dbQuery.contentResourceProduct.findMany({
183
+ where: and(eq(contentResourceProduct.resourceId, resourceId), isNull(contentResourceProduct.deletedAt)),
184
+ with: {
185
+ product: true
186
+ }
187
+ })
188
+ ]);
189
+ const parents = [];
190
+ for (const link of containerLinks) {
191
+ const parent = link.resourceOf;
192
+ if (!parent || parent.deletedAt)
193
+ continue;
194
+ if (parent.type === "videoResource")
195
+ continue;
196
+ const slug = parent.fields?.slug ?? "";
197
+ const siblings = parent.resources ?? [];
198
+ const index = siblings.findIndex((sibling) => sibling.resourceId === resourceId);
199
+ parents.push({
200
+ id: parent.id,
201
+ type: parent.type,
202
+ title: parent.fields?.title ?? (slug || parent.id),
203
+ href: getEditHref(parent.type, slug || parent.id),
204
+ ...index !== -1 && {
205
+ detail: `#${index + 1} of ${siblings.length}`
206
+ }
207
+ });
208
+ }
209
+ for (const link of productLinks) {
210
+ const product = link.product;
211
+ if (!product)
212
+ continue;
213
+ const slug = product.fields?.slug ?? "";
214
+ parents.push({
215
+ id: product.id,
216
+ type: "product",
217
+ title: product.name,
218
+ // Products aren't in the resource-paths registries; every app's
219
+ // product editor lives at /products/[slug]/edit.
220
+ href: `/products/${slug || product.id}/edit`
221
+ });
222
+ }
223
+ return parents;
224
+ }
225
+ __name(getResourceParents, "getResourceParents");
226
+ return {
227
+ listResourcesForPicker,
228
+ listVideoResourcesForPicker,
229
+ listImageResources,
230
+ getPostListMemberships,
231
+ getResourceParents
232
+ };
233
+ }
234
+ __name(createCmsResourceActions, "createCmsResourceActions");
235
+
236
+ export {
237
+ createCmsResourceActions
238
+ };
239
+ //# sourceMappingURL=chunk-BS7T27VL.js.map
@@ -0,0 +1,55 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-2X5XVNDN.js";
4
+
5
+ // src/lib/mysql/ports/subscription.ts
6
+ import { eq } from "drizzle-orm";
7
+ import { MerchantSubscriptionSchema } from "@coursebuilder/core/schemas/merchant-subscription";
8
+ import { SubscriptionSchema } from "@coursebuilder/core/schemas/subscription";
9
+ function createSubscriptionPort({ client, tables }) {
10
+ const { merchantSubscription: merchantSubscriptionTable, subscription: subscriptionTable } = tables;
11
+ return {
12
+ createSubscription: async (options) => {
13
+ const id = `sub_${crypto.randomUUID()}`;
14
+ await client.insert(subscriptionTable).values({
15
+ ...options,
16
+ id
17
+ });
18
+ return SubscriptionSchema.parse(await client.query.subscription.findFirst({
19
+ where: eq(subscriptionTable.id, id),
20
+ with: {
21
+ product: true
22
+ }
23
+ }));
24
+ },
25
+ getSubscriptionForStripeId: async (stripeSubscriptionId) => {
26
+ const merchantSubscriptionParsed = MerchantSubscriptionSchema.safeParse(await client.query.merchantSubscription.findFirst({
27
+ where: eq(merchantSubscriptionTable.identifier, stripeSubscriptionId)
28
+ }));
29
+ if (!merchantSubscriptionParsed.success) {
30
+ throw new Error(`No merchant subscription found for stripe id ${stripeSubscriptionId} ${merchantSubscriptionParsed.error}`);
31
+ }
32
+ const subscriptionParsed = SubscriptionSchema.safeParse(await client.query.subscription.findFirst({
33
+ where: eq(subscriptionTable.merchantSubscriptionId, merchantSubscriptionParsed.data.id),
34
+ with: {
35
+ product: true
36
+ }
37
+ }));
38
+ if (!subscriptionParsed.success) {
39
+ throw new Error(`No subscription found for merchant subscription ${merchantSubscriptionParsed.data.id} ${subscriptionParsed.error}`);
40
+ }
41
+ return subscriptionParsed.data;
42
+ },
43
+ updateSubscriptionStatus: async (subscriptionId, status) => {
44
+ await client.update(subscriptionTable).set({
45
+ status
46
+ }).where(eq(subscriptionTable.id, subscriptionId));
47
+ }
48
+ };
49
+ }
50
+ __name(createSubscriptionPort, "createSubscriptionPort");
51
+
52
+ export {
53
+ createSubscriptionPort
54
+ };
55
+ //# sourceMappingURL=chunk-CN3FCRLR.js.map