@coursebuilder/adapter-drizzle 2.1.1 → 3.0.0-canary.0.1de808999

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 (329) hide show
  1. package/dist/chunk-2CTSX6SR.js +145 -0
  2. package/dist/chunk-2M2XM4EQ.js +397 -0
  3. package/dist/chunk-2TFZWYLS.js +263 -0
  4. package/dist/chunk-3TRWZHL3.js +243 -0
  5. package/dist/chunk-4N2ECEUV.js +69 -0
  6. package/dist/{chunk-F56AI52P.js → chunk-63MYTNFA.js} +3 -3
  7. package/dist/{chunk-SIZFEXIS.js → chunk-6MRFUIH5.js} +2 -2
  8. package/dist/chunk-6WHKVXPL.js +109 -0
  9. package/dist/{chunk-WMCZWSAG.js → chunk-6YPHJWS2.js} +2 -2
  10. package/dist/{chunk-7FBSP3VD.js → chunk-AQKB7NUY.js} +4 -4
  11. package/dist/{chunk-PJORQUQP.js → chunk-BD3J6TQ5.js} +3 -3
  12. package/dist/{chunk-5NNBQJUP.js → chunk-BLDW3QUS.js} +2 -2
  13. package/dist/chunk-CN5LXLHU.js +252 -0
  14. package/dist/{chunk-M3WM5Q7W.js → chunk-CXNZM7MC.js} +3 -3
  15. package/dist/{chunk-DNBW5D64.js → chunk-DKJO4Y3K.js} +2 -2
  16. package/dist/chunk-DXAZKOCF.js +173 -0
  17. package/dist/{chunk-QKFITIXC.js → chunk-EHRARBRS.js} +2 -2
  18. package/dist/{chunk-CCXVDMTA.js → chunk-ET3QAIY7.js} +2 -2
  19. package/dist/chunk-H5REZLWW.js +63 -0
  20. package/dist/chunk-H736K5TN.js +7 -0
  21. package/dist/{chunk-WWBSNLRC.js → chunk-HJNM3PFW.js} +3 -3
  22. package/dist/chunk-JNPUM2MI.js +156 -0
  23. package/dist/{chunk-2I7NIOKI.js → chunk-KPBVZ44W.js} +2 -2
  24. package/dist/{chunk-OUJPUONP.js → chunk-LERR6HQ3.js} +2 -2
  25. package/dist/chunk-LSWGCJWO.js +328 -0
  26. package/dist/{chunk-UWUDJCJM.js → chunk-LZHZDFNZ.js} +2 -2
  27. package/dist/{chunk-PMCOC5PM.js → chunk-MGZMGDQ5.js} +2 -2
  28. package/dist/chunk-MINB3V5K.js +237 -0
  29. package/dist/{chunk-6SJORFGN.js → chunk-MP4CUWYC.js} +2 -2
  30. package/dist/{chunk-EZEQQJNH.js → chunk-MWYKBCT2.js} +3 -3
  31. package/dist/{chunk-SOOAUY4E.js → chunk-OCUEDXGE.js} +3 -3
  32. package/dist/{chunk-OFZECDCQ.js → chunk-ORRM7KVW.js} +2 -2
  33. package/dist/chunk-OWBFASNN.js +18 -0
  34. package/dist/chunk-P6G7UV6U.js +139 -0
  35. package/dist/{chunk-PNPTKVJ4.js → chunk-QGSAYLPA.js} +32 -23
  36. package/dist/chunk-QZ54UPHQ.js +300 -0
  37. package/dist/{chunk-NON5CXDH.js → chunk-RKGBBEVO.js} +2 -2
  38. package/dist/chunk-TCZZ6OTH.js +20 -0
  39. package/dist/{chunk-KIQLUFJX.js → chunk-U3YWHQZO.js} +3 -3
  40. package/dist/chunk-UKCW6T74.js +146 -0
  41. package/dist/chunk-UP5SZ5I4.js +55 -0
  42. package/dist/chunk-W5UWIWMA.js +74 -0
  43. package/dist/{chunk-65H5Y4PD.js → chunk-WJWJ6E5Y.js} +2 -2
  44. package/dist/chunk-WLL6VIPA.js +248 -0
  45. package/dist/chunk-XM6ULED3.js +210 -0
  46. package/dist/{chunk-2AW5KYAK.js → chunk-XYWXGVIK.js} +3 -3
  47. package/dist/{chunk-AP5HBIV4.js → chunk-Y7JBZEE3.js} +3 -3
  48. package/dist/chunk-YQS2KPYC.js +249 -0
  49. package/dist/chunk-ZDYVAW2C.js +133 -0
  50. package/dist/index.d.ts +5 -11
  51. package/dist/index.js +51 -29
  52. package/dist/lib/mysql/cms-resource-actions.cjs +15 -4490
  53. package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -1
  54. package/dist/lib/mysql/cms-resource-actions.d.cts +8 -38
  55. package/dist/lib/mysql/cms-resource-actions.d.ts +8 -38
  56. package/dist/lib/mysql/cms-resource-actions.js +2 -2
  57. package/dist/lib/mysql/context.cjs +3380 -0
  58. package/dist/lib/mysql/context.cjs.map +1 -0
  59. package/dist/lib/mysql/context.d.cts +15 -0
  60. package/dist/lib/mysql/context.d.ts +15 -0
  61. package/dist/lib/mysql/context.js +34 -0
  62. package/dist/lib/mysql/context.js.map +1 -0
  63. package/dist/lib/mysql/index.cjs +3340 -12980
  64. package/dist/lib/mysql/index.cjs.map +1 -1
  65. package/dist/lib/mysql/index.d.cts +24 -14300
  66. package/dist/lib/mysql/index.d.ts +24 -14300
  67. package/dist/lib/mysql/index.js +54 -31
  68. package/dist/lib/mysql/ports/auth-storage.cjs +84 -0
  69. package/dist/lib/mysql/ports/auth-storage.cjs.map +1 -0
  70. package/dist/lib/mysql/ports/auth-storage.d.cts +22 -0
  71. package/dist/lib/mysql/ports/auth-storage.d.ts +22 -0
  72. package/dist/lib/mysql/ports/auth-storage.js +8 -0
  73. package/dist/lib/mysql/ports/auth-storage.js.map +1 -0
  74. package/dist/lib/mysql/ports/catalog.cjs +428 -0
  75. package/dist/lib/mysql/ports/catalog.cjs.map +1 -0
  76. package/dist/lib/mysql/ports/catalog.d.cts +24 -0
  77. package/dist/lib/mysql/ports/catalog.d.ts +24 -0
  78. package/dist/lib/mysql/ports/catalog.js +8 -0
  79. package/dist/lib/mysql/ports/catalog.js.map +1 -0
  80. package/dist/lib/mysql/ports/content-resource.cjs +321 -0
  81. package/dist/lib/mysql/ports/content-resource.cjs.map +1 -0
  82. package/dist/lib/mysql/ports/content-resource.d.cts +23 -0
  83. package/dist/lib/mysql/ports/content-resource.d.ts +23 -0
  84. package/dist/lib/mysql/ports/content-resource.js +8 -0
  85. package/dist/lib/mysql/ports/content-resource.js.map +1 -0
  86. package/dist/lib/mysql/ports/coupon.cjs +264 -0
  87. package/dist/lib/mysql/ports/coupon.cjs.map +1 -0
  88. package/dist/lib/mysql/ports/coupon.d.cts +22 -0
  89. package/dist/lib/mysql/ports/coupon.d.ts +22 -0
  90. package/dist/lib/mysql/ports/coupon.js +8 -0
  91. package/dist/lib/mysql/ports/coupon.js.map +1 -0
  92. package/dist/lib/mysql/ports/entitlement.cjs +90 -0
  93. package/dist/lib/mysql/ports/entitlement.cjs.map +1 -0
  94. package/dist/lib/mysql/ports/entitlement.d.cts +22 -0
  95. package/dist/lib/mysql/ports/entitlement.d.ts +22 -0
  96. package/dist/lib/mysql/ports/entitlement.js +8 -0
  97. package/dist/lib/mysql/ports/entitlement.js.map +1 -0
  98. package/dist/lib/mysql/ports/identity.cjs +154 -0
  99. package/dist/lib/mysql/ports/identity.cjs.map +1 -0
  100. package/dist/lib/mysql/ports/identity.d.cts +22 -0
  101. package/dist/lib/mysql/ports/identity.d.ts +22 -0
  102. package/dist/lib/mysql/ports/identity.js +8 -0
  103. package/dist/lib/mysql/ports/identity.js.map +1 -0
  104. package/dist/lib/mysql/ports/merchant.cjs +194 -0
  105. package/dist/lib/mysql/ports/merchant.cjs.map +1 -0
  106. package/dist/lib/mysql/ports/merchant.d.cts +22 -0
  107. package/dist/lib/mysql/ports/merchant.d.ts +22 -0
  108. package/dist/lib/mysql/ports/merchant.js +8 -0
  109. package/dist/lib/mysql/ports/merchant.js.map +1 -0
  110. package/dist/lib/mysql/ports/organization.cjs +166 -0
  111. package/dist/lib/mysql/ports/organization.cjs.map +1 -0
  112. package/dist/lib/mysql/ports/organization.d.cts +22 -0
  113. package/dist/lib/mysql/ports/organization.d.ts +22 -0
  114. package/dist/lib/mysql/ports/organization.js +8 -0
  115. package/dist/lib/mysql/ports/organization.js.map +1 -0
  116. package/dist/lib/mysql/ports/progress.cjs +284 -0
  117. package/dist/lib/mysql/ports/progress.cjs.map +1 -0
  118. package/dist/lib/mysql/ports/progress.d.cts +22 -0
  119. package/dist/lib/mysql/ports/progress.d.ts +22 -0
  120. package/dist/lib/mysql/ports/progress.js +8 -0
  121. package/dist/lib/mysql/ports/progress.js.map +1 -0
  122. package/dist/lib/mysql/ports/purchase.cjs +349 -0
  123. package/dist/lib/mysql/ports/purchase.cjs.map +1 -0
  124. package/dist/lib/mysql/ports/purchase.d.cts +23 -0
  125. package/dist/lib/mysql/ports/purchase.d.ts +23 -0
  126. package/dist/lib/mysql/ports/purchase.js +8 -0
  127. package/dist/lib/mysql/ports/purchase.js.map +1 -0
  128. package/dist/lib/mysql/ports/subscription.cjs +76 -0
  129. package/dist/lib/mysql/ports/subscription.cjs.map +1 -0
  130. package/dist/lib/mysql/ports/subscription.d.cts +22 -0
  131. package/dist/lib/mysql/ports/subscription.d.ts +22 -0
  132. package/dist/lib/mysql/ports/subscription.js +8 -0
  133. package/dist/lib/mysql/ports/subscription.js.map +1 -0
  134. package/dist/lib/mysql/schema.cjs +3373 -0
  135. package/dist/lib/mysql/schema.cjs.map +1 -0
  136. package/dist/lib/mysql/schema.d.cts +14385 -0
  137. package/dist/lib/mysql/schema.d.ts +14385 -0
  138. package/dist/lib/mysql/schema.js +35 -0
  139. package/dist/lib/mysql/schema.js.map +1 -0
  140. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  141. package/dist/lib/mysql/schemas/auth/accounts.js +12 -12
  142. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  143. package/dist/lib/mysql/schemas/auth/device-access-token.js +13 -13
  144. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  145. package/dist/lib/mysql/schemas/auth/device-verification.js +13 -13
  146. package/dist/lib/mysql/schemas/auth/permissions.js +2 -2
  147. package/dist/lib/mysql/schemas/auth/personal-access-token.cjs.map +1 -1
  148. package/dist/lib/mysql/schemas/auth/personal-access-token.js +13 -13
  149. package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
  150. package/dist/lib/mysql/schemas/auth/profiles.js +12 -12
  151. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  152. package/dist/lib/mysql/schemas/auth/role-permissions.js +13 -13
  153. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  154. package/dist/lib/mysql/schemas/auth/roles.js +12 -12
  155. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  156. package/dist/lib/mysql/schemas/auth/sessions.js +13 -13
  157. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  158. package/dist/lib/mysql/schemas/auth/user-permissions.js +12 -12
  159. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  160. package/dist/lib/mysql/schemas/auth/user-prefs.js +12 -12
  161. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  162. package/dist/lib/mysql/schemas/auth/user-roles.js +12 -12
  163. package/dist/lib/mysql/schemas/auth/users.cjs +5 -1
  164. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  165. package/dist/lib/mysql/schemas/auth/users.js +12 -12
  166. package/dist/lib/mysql/schemas/auth/verification-tokens.js +2 -2
  167. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  168. package/dist/lib/mysql/schemas/commerce/coupon.js +12 -12
  169. package/dist/lib/mysql/schemas/commerce/merchant-account.js +2 -2
  170. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  171. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +12 -12
  172. package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +2 -2
  173. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +2 -2
  174. package/dist/lib/mysql/schemas/commerce/merchant-events.js +3 -3
  175. package/dist/lib/mysql/schemas/commerce/merchant-price.js +2 -2
  176. package/dist/lib/mysql/schemas/commerce/merchant-product.js +2 -2
  177. package/dist/lib/mysql/schemas/commerce/merchant-session.js +2 -2
  178. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
  179. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +12 -12
  180. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  181. package/dist/lib/mysql/schemas/commerce/price.js +12 -12
  182. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  183. package/dist/lib/mysql/schemas/commerce/product.js +12 -12
  184. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  185. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +13 -13
  186. package/dist/lib/mysql/schemas/commerce/purchase.cjs +11 -2
  187. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  188. package/dist/lib/mysql/schemas/commerce/purchase.js +12 -12
  189. package/dist/lib/mysql/schemas/commerce/subscription.cjs +6 -1
  190. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
  191. package/dist/lib/mysql/schemas/commerce/subscription.js +12 -12
  192. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  193. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +13 -13
  194. package/dist/lib/mysql/schemas/communication/comment.cjs +5 -1
  195. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  196. package/dist/lib/mysql/schemas/communication/comment.js +12 -12
  197. package/dist/lib/mysql/schemas/communication/communication-channel.js +2 -2
  198. package/dist/lib/mysql/schemas/communication/communication-preference-types.js +2 -2
  199. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +5 -1
  200. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  201. package/dist/lib/mysql/schemas/communication/communication-preferences.js +12 -12
  202. package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -1
  203. package/dist/lib/mysql/schemas/communication/question-response.js +13 -13
  204. package/dist/lib/mysql/schemas/content/content-contributions.cjs +5 -1
  205. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  206. package/dist/lib/mysql/schemas/content/content-contributions.js +12 -12
  207. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  208. package/dist/lib/mysql/schemas/content/content-resource-product.js +12 -12
  209. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  210. package/dist/lib/mysql/schemas/content/content-resource-resource.js +12 -12
  211. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  212. package/dist/lib/mysql/schemas/content/content-resource-tag.js +12 -12
  213. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  214. package/dist/lib/mysql/schemas/content/content-resource-version.js +12 -12
  215. package/dist/lib/mysql/schemas/content/content-resource.cjs +5 -1
  216. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  217. package/dist/lib/mysql/schemas/content/content-resource.js +12 -12
  218. package/dist/lib/mysql/schemas/content/contribution-types.js +2 -2
  219. package/dist/lib/mysql/schemas/content/lesson-progress.js +2 -2
  220. package/dist/lib/mysql/schemas/content/resource-progress.js +2 -2
  221. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  222. package/dist/lib/mysql/schemas/content/tag-tag.js +12 -12
  223. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  224. package/dist/lib/mysql/schemas/content/tag.js +12 -12
  225. package/dist/lib/mysql/schemas/entitlements/entitlement-type.js +2 -2
  226. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +11 -2
  227. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
  228. package/dist/lib/mysql/schemas/entitlements/entitlement.js +13 -13
  229. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +11 -2
  230. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
  231. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +12 -12
  232. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +11 -2
  233. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
  234. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +16 -0
  235. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +16 -0
  236. package/dist/lib/mysql/schemas/org/organization-memberships.js +12 -12
  237. package/dist/lib/mysql/schemas/org/organizations.cjs +11 -2
  238. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
  239. package/dist/lib/mysql/schemas/org/organizations.d.cts +16 -0
  240. package/dist/lib/mysql/schemas/org/organizations.d.ts +16 -0
  241. package/dist/lib/mysql/schemas/org/organizations.js +12 -12
  242. package/dist/lib/mysql/utils.js +1 -1
  243. package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs +40 -0
  244. package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs.map +1 -0
  245. package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.cts +4 -0
  246. package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.ts +4 -0
  247. package/dist/lib/mysql/workflows/content-resource-workflow-utils.js +10 -0
  248. package/dist/lib/mysql/workflows/content-resource-workflow-utils.js.map +1 -0
  249. package/dist/lib/mysql/workflows/create-cohort.cjs +184 -0
  250. package/dist/lib/mysql/workflows/create-cohort.cjs.map +1 -0
  251. package/dist/lib/mysql/workflows/create-cohort.d.cts +24 -0
  252. package/dist/lib/mysql/workflows/create-cohort.d.ts +24 -0
  253. package/dist/lib/mysql/workflows/create-cohort.js +9 -0
  254. package/dist/lib/mysql/workflows/create-cohort.js.map +1 -0
  255. package/dist/lib/mysql/workflows/create-event-series.cjs +283 -0
  256. package/dist/lib/mysql/workflows/create-event-series.cjs.map +1 -0
  257. package/dist/lib/mysql/workflows/create-event-series.d.cts +24 -0
  258. package/dist/lib/mysql/workflows/create-event-series.d.ts +24 -0
  259. package/dist/lib/mysql/workflows/create-event-series.js +9 -0
  260. package/dist/lib/mysql/workflows/create-event-series.js.map +1 -0
  261. package/dist/lib/mysql/workflows/create-event.cjs +194 -0
  262. package/dist/lib/mysql/workflows/create-event.cjs.map +1 -0
  263. package/dist/lib/mysql/workflows/create-event.d.cts +24 -0
  264. package/dist/lib/mysql/workflows/create-event.d.ts +24 -0
  265. package/dist/lib/mysql/workflows/create-event.js +9 -0
  266. package/dist/lib/mysql/workflows/create-event.js.map +1 -0
  267. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs +231 -0
  268. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs.map +1 -0
  269. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.cts +22 -0
  270. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.ts +22 -0
  271. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js +8 -0
  272. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js.map +1 -0
  273. package/dist/lib/mysql/workflows/create-workshop.cjs +286 -0
  274. package/dist/lib/mysql/workflows/create-workshop.cjs.map +1 -0
  275. package/dist/lib/mysql/workflows/create-workshop.d.cts +24 -0
  276. package/dist/lib/mysql/workflows/create-workshop.d.ts +24 -0
  277. package/dist/lib/mysql/workflows/create-workshop.js +9 -0
  278. package/dist/lib/mysql/workflows/create-workshop.js.map +1 -0
  279. package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs +130 -0
  280. package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs.map +1 -0
  281. package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.cts +24 -0
  282. package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.ts +24 -0
  283. package/dist/lib/mysql/workflows/redeem-full-price-coupon.js +8 -0
  284. package/dist/lib/mysql/workflows/redeem-full-price-coupon.js.map +1 -0
  285. package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs +95 -0
  286. package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs.map +1 -0
  287. package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.cts +30 -0
  288. package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.ts +30 -0
  289. package/dist/lib/mysql/workflows/transfer-purchase-to-user.js +8 -0
  290. package/dist/lib/mysql/workflows/transfer-purchase-to-user.js.map +1 -0
  291. package/dist/lib/utils.d.cts +1 -10
  292. package/dist/lib/utils.d.ts +1 -10
  293. package/dist/lib/utils.js +1 -1
  294. package/dist/types.d.ts +14 -0
  295. package/dist/types.js +1 -0
  296. package/package.json +10 -6
  297. package/src/index.ts +3 -2
  298. package/src/lib/mysql/context.ts +20 -0
  299. package/src/lib/mysql/index.ts +118 -4873
  300. package/src/lib/mysql/ports/auth-storage.ts +139 -0
  301. package/src/lib/mysql/ports/catalog.ts +610 -0
  302. package/src/lib/mysql/ports/content-resource.ts +442 -0
  303. package/src/lib/mysql/ports/coupon.ts +387 -0
  304. package/src/lib/mysql/ports/entitlement.ts +96 -0
  305. package/src/lib/mysql/ports/identity.ts +160 -0
  306. package/src/lib/mysql/ports/merchant.ts +274 -0
  307. package/src/lib/mysql/ports/organization.ts +216 -0
  308. package/src/lib/mysql/ports/progress.ts +366 -0
  309. package/src/lib/mysql/ports/purchase.ts +517 -0
  310. package/src/lib/mysql/ports/subscription.ts +93 -0
  311. package/src/lib/mysql/schema.ts +374 -0
  312. package/src/lib/mysql/schemas/org/organization-memberships.ts +7 -0
  313. package/src/lib/mysql/schemas/org/organizations.ts +8 -0
  314. package/src/lib/mysql/workflows/content-resource-workflow-utils.ts +22 -0
  315. package/src/lib/mysql/workflows/create-cohort.ts +239 -0
  316. package/src/lib/mysql/workflows/create-event-series.ts +384 -0
  317. package/src/lib/mysql/workflows/create-event.ts +232 -0
  318. package/src/lib/mysql/workflows/create-merchant-charge-and-purchase.ts +365 -0
  319. package/src/lib/mysql/workflows/create-workshop.ts +372 -0
  320. package/src/lib/mysql/workflows/redeem-full-price-coupon.ts +179 -0
  321. package/src/lib/mysql/workflows/transfer-purchase-to-user.ts +142 -0
  322. package/src/types.ts +33 -0
  323. package/dist/authjs.d.ts +0 -27
  324. package/dist/authjs.js +0 -1
  325. package/dist/chunk-2X5XVNDN.js +0 -12
  326. package/dist/chunk-62VSIVME.js +0 -4714
  327. package/dist/chunk-RVXF3JZ7.js +0 -8732
  328. package/dist/chunk-WEJL5OFI.js +0 -8732
  329. package/src/authjs.ts +0 -34
@@ -0,0 +1,109 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-H736K5TN.js";
4
+
5
+ // src/lib/mysql/workflows/redeem-full-price-coupon.ts
6
+ import { and, eq } from "drizzle-orm";
7
+ import { v4 } from "uuid";
8
+ import { logger } from "@coursebuilder/utils/logger";
9
+ import { validateCoupon } from "@coursebuilder/commerce/validate-coupon";
10
+ var normalizeLearnerEmail = /* @__PURE__ */ __name((email) => email.trim().toLowerCase().replace(/\s+/g, "+"), "normalizeLearnerEmail");
11
+ function createRedeemFullPriceCouponWorkflow({ client, tables }, operations) {
12
+ const { purchases: purchaseTable } = tables;
13
+ return {
14
+ async redeemFullPriceCoupon(options) {
15
+ const { email: baseEmail, couponId, productIds, currentUserId, redeemingProductId } = options;
16
+ const email = normalizeLearnerEmail(String(baseEmail));
17
+ const coupon = await operations.getCouponWithBulkPurchases(couponId);
18
+ const productId = coupon && coupon.restrictedToProductId || redeemingProductId;
19
+ if (!productId)
20
+ throw new Error(`unable-to-find-any-product-id`);
21
+ const couponValidation = validateCoupon(coupon, productIds);
22
+ if (coupon && couponValidation.isRedeemable) {
23
+ const bulkCouponRedemption = Boolean(coupon.maxUses > 1);
24
+ const { user } = await operations.findOrCreateUser(email);
25
+ if (!user)
26
+ throw new Error(`unable-to-create-user-${email}`);
27
+ const currentUser = currentUserId ? await operations.getUserById(currentUserId) : null;
28
+ const redeemingForCurrentUser = currentUser?.id === user.id;
29
+ if (bulkCouponRedemption) {
30
+ const existingValidRedemption = await client.query.purchases.findFirst({
31
+ where: and(eq(purchaseTable.redeemedBulkCouponId, coupon.id), eq(purchaseTable.userId, user.id), eq(purchaseTable.status, "Valid"))
32
+ });
33
+ if (existingValidRedemption) {
34
+ logger.info("adapter.coupon.redeem.duplicate_team_seat", {
35
+ couponId: coupon.id,
36
+ currentUserId,
37
+ email,
38
+ productId,
39
+ purchaseId: existingValidRedemption.id,
40
+ userId: user.id
41
+ });
42
+ return {
43
+ error: {
44
+ message: "team-seat-redemption-already-claimed"
45
+ },
46
+ redeemingForCurrentUser,
47
+ purchase: null
48
+ };
49
+ }
50
+ }
51
+ const existingPurchases = await operations.getExistingNonBulkValidPurchasesOfProduct({
52
+ userId: user.id,
53
+ productId
54
+ });
55
+ if (existingPurchases.length > 0) {
56
+ const errorMessage = `already-purchased-${email}`;
57
+ logger.info("adapter.coupon.redeem.already_purchased", {
58
+ couponId: coupon.id,
59
+ currentUserId,
60
+ email,
61
+ productId,
62
+ userId: user.id
63
+ });
64
+ return {
65
+ error: {
66
+ message: errorMessage
67
+ },
68
+ redeemingForCurrentUser,
69
+ purchase: null
70
+ };
71
+ throw new Error(errorMessage);
72
+ }
73
+ const purchaseId = `purchase-${v4()}`;
74
+ const userMemberships = await operations.getMembershipsForUser(user.id);
75
+ const organizationId = coupon.organizationId || userMemberships.find((m) => m.organization.name?.includes(user.email))?.organizationId;
76
+ await operations.createPurchase({
77
+ id: purchaseId,
78
+ userId: user.id,
79
+ couponId: bulkCouponRedemption ? null : coupon.id,
80
+ redeemedBulkCouponId: bulkCouponRedemption ? coupon.id : null,
81
+ productId,
82
+ totalAmount: "0",
83
+ organizationId,
84
+ metadata: {
85
+ couponUsedId: bulkCouponRedemption ? null : coupon.id
86
+ }
87
+ });
88
+ const newPurchase = await operations.getPurchase(purchaseId);
89
+ await operations.incrementCouponUsedCount(coupon.id);
90
+ await operations.createPurchaseTransfer({
91
+ sourceUserId: user.id,
92
+ purchaseId,
93
+ expiresAt: new Date(Date.now() + 1e3 * 60 * 60 * 24 * 7)
94
+ });
95
+ return {
96
+ purchase: newPurchase,
97
+ redeemingForCurrentUser
98
+ };
99
+ }
100
+ return null;
101
+ }
102
+ };
103
+ }
104
+ __name(createRedeemFullPriceCouponWorkflow, "createRedeemFullPriceCouponWorkflow");
105
+
106
+ export {
107
+ createRedeemFullPriceCouponWorkflow
108
+ };
109
+ //# sourceMappingURL=chunk-6WHKVXPL.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-2X5XVNDN.js";
3
+ } from "./chunk-H736K5TN.js";
4
4
 
5
5
  // src/lib/mysql/schemas/content/resource-progress.ts
6
6
  import { sql } from "drizzle-orm";
@@ -52,4 +52,4 @@ __name(getResourceProgressSchema, "getResourceProgressSchema");
52
52
  export {
53
53
  getResourceProgressSchema
54
54
  };
55
- //# sourceMappingURL=chunk-WMCZWSAG.js.map
55
+ //# sourceMappingURL=chunk-6YPHJWS2.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  getRolesSchema
3
- } from "./chunk-PNPTKVJ4.js";
3
+ } from "./chunk-QGSAYLPA.js";
4
4
  import {
5
5
  getPermissionsSchema
6
- } from "./chunk-UWUDJCJM.js";
6
+ } from "./chunk-LZHZDFNZ.js";
7
7
  import {
8
8
  __name
9
- } from "./chunk-2X5XVNDN.js";
9
+ } from "./chunk-H736K5TN.js";
10
10
 
11
11
  // src/lib/mysql/schemas/auth/role-permissions.ts
12
12
  import { relations } from "drizzle-orm";
@@ -75,4 +75,4 @@ export {
75
75
  getRolePermissionsSchema,
76
76
  getRolePermissionsRelationsSchema
77
77
  };
78
- //# sourceMappingURL=chunk-7FBSP3VD.js.map
78
+ //# sourceMappingURL=chunk-AQKB7NUY.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getUsersSchema
3
- } from "./chunk-PNPTKVJ4.js";
3
+ } from "./chunk-QGSAYLPA.js";
4
4
  import {
5
5
  __name
6
- } from "./chunk-2X5XVNDN.js";
6
+ } from "./chunk-H736K5TN.js";
7
7
 
8
8
  // src/lib/mysql/schemas/auth/device-access-token.ts
9
9
  import { relations, sql } from "drizzle-orm";
@@ -55,4 +55,4 @@ export {
55
55
  getDeviceAccessTokenSchema,
56
56
  getDeviceAccessTokenRelationsSchema
57
57
  };
58
- //# sourceMappingURL=chunk-PJORQUQP.js.map
58
+ //# sourceMappingURL=chunk-BD3J6TQ5.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-2X5XVNDN.js";
3
+ } from "./chunk-H736K5TN.js";
4
4
 
5
5
  // src/lib/mysql/schemas/commerce/merchant-session.ts
6
6
  import { index, primaryKey, varchar } from "drizzle-orm/mysql-core";
@@ -35,4 +35,4 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
35
35
  export {
36
36
  getMerchantSessionSchema
37
37
  };
38
- //# sourceMappingURL=chunk-5NNBQJUP.js.map
38
+ //# sourceMappingURL=chunk-BLDW3QUS.js.map
@@ -0,0 +1,252 @@
1
+ import {
2
+ getEntitlementTypesSchema
3
+ } from "./chunk-ORRM7KVW.js";
4
+ import {
5
+ getEntitlementRelationsSchema,
6
+ getEntitlementsSchema
7
+ } from "./chunk-XYWXGVIK.js";
8
+ import {
9
+ getLessonProgressSchema
10
+ } from "./chunk-ET3QAIY7.js";
11
+ import {
12
+ getResourceProgressSchema
13
+ } from "./chunk-6YPHJWS2.js";
14
+ import {
15
+ getUpgradableProductsRelationsSchema,
16
+ getUpgradableProductsSchema
17
+ } from "./chunk-MWYKBCT2.js";
18
+ import {
19
+ getQuestionResponseRelationsSchema,
20
+ getQuestionResponseSchema
21
+ } from "./chunk-U3YWHQZO.js";
22
+ import {
23
+ getPurchaseUserTransferRelationsSchema,
24
+ getPurchaseUserTransferSchema
25
+ } from "./chunk-Y7JBZEE3.js";
26
+ import {
27
+ getVerificationTokensSchema
28
+ } from "./chunk-LERR6HQ3.js";
29
+ import {
30
+ getMerchantEventsRelationsSchema,
31
+ getMerchantEventsSchema
32
+ } from "./chunk-OCUEDXGE.js";
33
+ import {
34
+ getRolePermissionsRelationsSchema,
35
+ getRolePermissionsSchema
36
+ } from "./chunk-AQKB7NUY.js";
37
+ import {
38
+ getSessionRelationsSchema,
39
+ getSessionsSchema
40
+ } from "./chunk-63MYTNFA.js";
41
+ import {
42
+ getDeviceAccessTokenRelationsSchema,
43
+ getDeviceAccessTokenSchema
44
+ } from "./chunk-BD3J6TQ5.js";
45
+ import {
46
+ getDeviceVerificationRelationsSchema,
47
+ getDeviceVerificationSchema
48
+ } from "./chunk-HJNM3PFW.js";
49
+ import {
50
+ getPersonalAccessTokenRelationsSchema,
51
+ getPersonalAccessTokenSchema
52
+ } from "./chunk-CXNZM7MC.js";
53
+ import {
54
+ getAccountsRelationsSchema,
55
+ getAccountsSchema,
56
+ getCommentRelationsSchema,
57
+ getCommentsSchema,
58
+ getCommunicationPreferencesRelationsSchema,
59
+ getCommunicationPreferencesSchema,
60
+ getContentContributionRelationsSchema,
61
+ getContentContributionsSchema,
62
+ getContentResourceProductRelationsSchema,
63
+ getContentResourceProductSchema,
64
+ getContentResourceRelationsSchema,
65
+ getContentResourceResourceRelationsSchema,
66
+ getContentResourceResourceSchema,
67
+ getContentResourceSchema,
68
+ getContentResourceTagRelationsSchema,
69
+ getContentResourceTagSchema,
70
+ getContentResourceVersionRelationsSchema,
71
+ getContentResourceVersionSchema,
72
+ getCouponRelationsSchema,
73
+ getCouponSchema,
74
+ getMerchantChargeRelationsSchema,
75
+ getMerchantChargeSchema,
76
+ getMerchantSubscriptionRelationsSchema,
77
+ getMerchantSubscriptionSchema,
78
+ getOrganizationMembershipRolesRelationsSchema,
79
+ getOrganizationMembershipRolesSchema,
80
+ getOrganizationMembershipsRelationsSchema,
81
+ getOrganizationMembershipsSchema,
82
+ getOrganizationsRelationsSchema,
83
+ getOrganizationsSchema,
84
+ getPriceSchema,
85
+ getProductRelationsSchema2 as getProductRelationsSchema,
86
+ getProductSchema,
87
+ getProfilesRelationsSchema,
88
+ getProfilesSchema,
89
+ getPurchaseRelationsSchema,
90
+ getPurchaseSchema,
91
+ getRolesRelationsSchema,
92
+ getRolesSchema,
93
+ getSubscriptionRelationsSchema,
94
+ getSubscriptionSchema,
95
+ getTagRelationsSchema,
96
+ getTagSchema,
97
+ getTagTagRelationsSchema,
98
+ getTagTagSchema,
99
+ getUserPermissionsRelationsSchema,
100
+ getUserPermissionsSchema,
101
+ getUserPrefsRelationsSchema,
102
+ getUserPrefsSchema,
103
+ getUserRolesRelationsSchema,
104
+ getUserRolesSchema,
105
+ getUsersRelationsSchema,
106
+ getUsersSchema
107
+ } from "./chunk-QGSAYLPA.js";
108
+ import {
109
+ getContributionTypesRelationsSchema,
110
+ getContributionTypesSchema
111
+ } from "./chunk-MP4CUWYC.js";
112
+ import {
113
+ getCommunicationChannelSchema
114
+ } from "./chunk-WJWJ6E5Y.js";
115
+ import {
116
+ getCommunicationPreferenceTypesSchema
117
+ } from "./chunk-EHRARBRS.js";
118
+ import {
119
+ getMerchantProductSchema
120
+ } from "./chunk-KPBVZ44W.js";
121
+ import {
122
+ getMerchantSessionSchema
123
+ } from "./chunk-BLDW3QUS.js";
124
+ import {
125
+ getMerchantCouponSchema
126
+ } from "./chunk-RKGBBEVO.js";
127
+ import {
128
+ getMerchantCustomerSchema
129
+ } from "./chunk-6MRFUIH5.js";
130
+ import {
131
+ getMerchantAccountSchema
132
+ } from "./chunk-DKJO4Y3K.js";
133
+ import {
134
+ getMerchantPriceSchema
135
+ } from "./chunk-MGZMGDQ5.js";
136
+ import {
137
+ getPermissionsRelationsSchema,
138
+ getPermissionsSchema
139
+ } from "./chunk-LZHZDFNZ.js";
140
+ import {
141
+ __name
142
+ } from "./chunk-H736K5TN.js";
143
+
144
+ // src/lib/mysql/schema.ts
145
+ function getCourseBuilderSchema(mysqlTable, overrides = {}) {
146
+ const resolvedGetUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
147
+ const userRelationsOverrides = {
148
+ getUsersSchema: resolvedGetUsersSchema
149
+ };
150
+ return {
151
+ accounts: getAccountsSchema(mysqlTable),
152
+ accountsRelations: getAccountsRelationsSchema(mysqlTable, userRelationsOverrides),
153
+ permissions: getPermissionsSchema(mysqlTable),
154
+ permissionsRelations: getPermissionsRelationsSchema(mysqlTable),
155
+ rolePermissions: getRolePermissionsSchema(mysqlTable),
156
+ rolePermissionsRelations: getRolePermissionsRelationsSchema(mysqlTable),
157
+ roles: getRolesSchema(mysqlTable),
158
+ rolesRelations: getRolesRelationsSchema(mysqlTable),
159
+ sessions: getSessionsSchema(mysqlTable),
160
+ sessionsRelations: getSessionRelationsSchema(mysqlTable, userRelationsOverrides),
161
+ userPermissions: getUserPermissionsSchema(mysqlTable),
162
+ userPermissionsRelations: getUserPermissionsRelationsSchema(mysqlTable, userRelationsOverrides),
163
+ userRoles: getUserRolesSchema(mysqlTable),
164
+ userRolesRelations: getUserRolesRelationsSchema(mysqlTable, userRelationsOverrides),
165
+ users: resolvedGetUsersSchema(mysqlTable),
166
+ usersRelations: getUsersRelationsSchema(mysqlTable, userRelationsOverrides),
167
+ verificationTokens: getVerificationTokensSchema(mysqlTable),
168
+ coupon: getCouponSchema(mysqlTable),
169
+ couponRelations: getCouponRelationsSchema(mysqlTable),
170
+ lessonProgress: getLessonProgressSchema(mysqlTable),
171
+ merchantAccount: getMerchantAccountSchema(mysqlTable),
172
+ merchantCharge: getMerchantChargeSchema(mysqlTable),
173
+ merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
174
+ merchantEvents: getMerchantEventsSchema(mysqlTable),
175
+ merchantEventsRelations: getMerchantEventsRelationsSchema(mysqlTable),
176
+ merchantCoupon: getMerchantCouponSchema(mysqlTable),
177
+ merchantCustomer: getMerchantCustomerSchema(mysqlTable),
178
+ merchantPrice: getMerchantPriceSchema(mysqlTable),
179
+ merchantProduct: getMerchantProductSchema(mysqlTable),
180
+ merchantSession: getMerchantSessionSchema(mysqlTable),
181
+ prices: getPriceSchema(mysqlTable),
182
+ products: getProductSchema(mysqlTable),
183
+ purchases: getPurchaseSchema(mysqlTable),
184
+ purchaseRelations: getPurchaseRelationsSchema(mysqlTable, userRelationsOverrides),
185
+ purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
186
+ purchaseUserTransferRelations: getPurchaseUserTransferRelationsSchema(mysqlTable, userRelationsOverrides),
187
+ communicationChannel: getCommunicationChannelSchema(mysqlTable),
188
+ communicationPreferenceTypes: getCommunicationPreferenceTypesSchema(mysqlTable),
189
+ communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
190
+ communicationPreferencesRelations: getCommunicationPreferencesRelationsSchema(mysqlTable, userRelationsOverrides),
191
+ contentContributions: getContentContributionsSchema(mysqlTable),
192
+ contentContributionRelations: getContentContributionRelationsSchema(mysqlTable, userRelationsOverrides),
193
+ contentResource: getContentResourceSchema(mysqlTable),
194
+ contentResourceVersion: getContentResourceVersionSchema(mysqlTable),
195
+ contentResourceVersionRelations: getContentResourceVersionRelationsSchema(mysqlTable, userRelationsOverrides),
196
+ contentResourceRelations: getContentResourceRelationsSchema(mysqlTable, userRelationsOverrides),
197
+ contentResourceResource: getContentResourceResourceSchema(mysqlTable),
198
+ contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
199
+ contentResourceTag: getContentResourceTagSchema(mysqlTable),
200
+ contentResourceTagRelations: getContentResourceTagRelationsSchema(mysqlTable),
201
+ contributionTypes: getContributionTypesSchema(mysqlTable),
202
+ contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
203
+ resourceProgress: getResourceProgressSchema(mysqlTable),
204
+ questionResponse: getQuestionResponseSchema(mysqlTable),
205
+ questionResponseRelations: getQuestionResponseRelationsSchema(mysqlTable, userRelationsOverrides),
206
+ upgradableProducts: getUpgradableProductsSchema(mysqlTable),
207
+ upgradableProductsRelations: getUpgradableProductsRelationsSchema(mysqlTable),
208
+ contentResourceProduct: getContentResourceProductSchema(mysqlTable),
209
+ contentResourceProductRelations: getContentResourceProductRelationsSchema(mysqlTable),
210
+ productRelations: getProductRelationsSchema(mysqlTable),
211
+ comments: getCommentsSchema(mysqlTable),
212
+ commentsRelations: getCommentRelationsSchema(mysqlTable, userRelationsOverrides),
213
+ deviceVerifications: getDeviceVerificationSchema(mysqlTable),
214
+ deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable, userRelationsOverrides),
215
+ deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
216
+ deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
217
+ personalAccessToken: getPersonalAccessTokenSchema(mysqlTable),
218
+ personalAccessTokenRelations: getPersonalAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
219
+ tag: getTagSchema(mysqlTable),
220
+ tagRelations: getTagRelationsSchema(mysqlTable),
221
+ tagTag: getTagTagSchema(mysqlTable),
222
+ tagTagRelations: getTagTagRelationsSchema(mysqlTable),
223
+ userPrefs: getUserPrefsSchema(mysqlTable),
224
+ userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable, userRelationsOverrides),
225
+ organization: getOrganizationsSchema(mysqlTable),
226
+ organizationRelations: getOrganizationsRelationsSchema(mysqlTable),
227
+ organizationMemberships: getOrganizationMembershipsSchema(mysqlTable),
228
+ organizationMembershipRelations: getOrganizationMembershipsRelationsSchema(mysqlTable, userRelationsOverrides),
229
+ organizationMembershipRoles: getOrganizationMembershipRolesSchema(mysqlTable),
230
+ organizationMembershipRolesRelations: getOrganizationMembershipRolesRelationsSchema(mysqlTable),
231
+ merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
232
+ merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
233
+ subscription: getSubscriptionSchema(mysqlTable),
234
+ subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
235
+ profiles: getProfilesSchema(mysqlTable),
236
+ profilesRelations: getProfilesRelationsSchema(mysqlTable, userRelationsOverrides),
237
+ entitlementTypes: getEntitlementTypesSchema(mysqlTable),
238
+ entitlements: getEntitlementsSchema(mysqlTable),
239
+ entitlementsRelations: getEntitlementRelationsSchema(mysqlTable, userRelationsOverrides)
240
+ };
241
+ }
242
+ __name(getCourseBuilderSchema, "getCourseBuilderSchema");
243
+ function createTables(mySqlTable) {
244
+ return getCourseBuilderSchema(mySqlTable);
245
+ }
246
+ __name(createTables, "createTables");
247
+
248
+ export {
249
+ getCourseBuilderSchema,
250
+ createTables
251
+ };
252
+ //# sourceMappingURL=chunk-CN5LXLHU.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getUsersSchema
3
- } from "./chunk-PNPTKVJ4.js";
3
+ } from "./chunk-QGSAYLPA.js";
4
4
  import {
5
5
  __name
6
- } from "./chunk-2X5XVNDN.js";
6
+ } from "./chunk-H736K5TN.js";
7
7
 
8
8
  // src/lib/mysql/schemas/auth/personal-access-token.ts
9
9
  import { relations, sql } from "drizzle-orm";
@@ -85,4 +85,4 @@ export {
85
85
  getPersonalAccessTokenSchema,
86
86
  getPersonalAccessTokenRelationsSchema
87
87
  };
88
- //# sourceMappingURL=chunk-M3WM5Q7W.js.map
88
+ //# sourceMappingURL=chunk-CXNZM7MC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-2X5XVNDN.js";
3
+ } from "./chunk-H736K5TN.js";
4
4
 
5
5
  // src/lib/mysql/schemas/commerce/merchant-account.ts
6
6
  import { sql } from "drizzle-orm";
@@ -41,4 +41,4 @@ __name(getMerchantAccountSchema, "getMerchantAccountSchema");
41
41
  export {
42
42
  getMerchantAccountSchema
43
43
  };
44
- //# sourceMappingURL=chunk-DNBW5D64.js.map
44
+ //# sourceMappingURL=chunk-DKJO4Y3K.js.map
@@ -0,0 +1,173 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-H736K5TN.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-DXAZKOCF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-2X5XVNDN.js";
3
+ } from "./chunk-H736K5TN.js";
4
4
 
5
5
  // src/lib/mysql/schemas/communication/communication-preference-types.ts
6
6
  import { boolean, text, timestamp, varchar } from "drizzle-orm/mysql-core";
@@ -36,4 +36,4 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
36
36
  export {
37
37
  getCommunicationPreferenceTypesSchema
38
38
  };
39
- //# sourceMappingURL=chunk-QKFITIXC.js.map
39
+ //# sourceMappingURL=chunk-EHRARBRS.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-2X5XVNDN.js";
3
+ } from "./chunk-H736K5TN.js";
4
4
 
5
5
  // src/lib/mysql/schemas/content/lesson-progress.ts
6
6
  import { sql } from "drizzle-orm";
@@ -60,4 +60,4 @@ __name(getLessonProgressSchema, "getLessonProgressSchema");
60
60
  export {
61
61
  getLessonProgressSchema
62
62
  };
63
- //# sourceMappingURL=chunk-CCXVDMTA.js.map
63
+ //# sourceMappingURL=chunk-ET3QAIY7.js.map