@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,263 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-H736K5TN.js";
4
+
5
+ // src/lib/mysql/ports/progress.ts
6
+ import { and, eq, inArray, or, sql } from "drizzle-orm";
7
+ import { z } from "zod";
8
+ import { resourceProgressSchema } from "@coursebuilder/core/schemas";
9
+ import { logger as baseLogger } from "@coursebuilder/utils/logger";
10
+ var logger = baseLogger;
11
+ function createProgressPort({ client, tables }) {
12
+ const { contentResource, contentResourceResource, resourceProgress, users } = tables;
13
+ return {
14
+ async clearLessonProgressForUser(options) {
15
+ const lessonIds = options.lessons.map(({ id }) => id);
16
+ if (lessonIds.length === 0)
17
+ return;
18
+ await client.delete(resourceProgress).where(and(eq(resourceProgress.userId, options.userId), inArray(resourceProgress.resourceId, lessonIds)));
19
+ },
20
+ async completeLessonProgressForUser(options) {
21
+ if (!options.lessonId) {
22
+ throw new Error("No lessonId provided");
23
+ }
24
+ let lessonProgress = await client.query.resourceProgress.findFirst({
25
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
26
+ });
27
+ const now = /* @__PURE__ */ new Date();
28
+ if (lessonProgress) {
29
+ if (!lessonProgress.completedAt) {
30
+ await client.update(resourceProgress).set({
31
+ completedAt: now,
32
+ updatedAt: now
33
+ }).where(and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId)));
34
+ }
35
+ } else {
36
+ await client.insert(resourceProgress).values({
37
+ userId: options.userId,
38
+ resourceId: options.lessonId,
39
+ completedAt: now,
40
+ updatedAt: now
41
+ });
42
+ }
43
+ lessonProgress = await client.query.resourceProgress.findFirst({
44
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
45
+ });
46
+ const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
47
+ if (!parsedLessonProgress.success) {
48
+ logger.error(parsedLessonProgress.error, {
49
+ event: "adapter.lessonProgress.parse_failed",
50
+ lessonId: options.lessonId,
51
+ userId: options.userId
52
+ });
53
+ return null;
54
+ }
55
+ return parsedLessonProgress.data;
56
+ },
57
+ async getLessonProgressCountsByDate() {
58
+ const completed = await client.select({
59
+ completedAt: resourceProgress.completedAt
60
+ }).from(resourceProgress).where(sql`${resourceProgress.completedAt} IS NOT NULL`);
61
+ const counts = /* @__PURE__ */ new Map();
62
+ for (const { completedAt } of completed) {
63
+ if (!completedAt)
64
+ continue;
65
+ const date = completedAt.toISOString().slice(0, 10);
66
+ counts.set(date, (counts.get(date) ?? 0) + 1);
67
+ }
68
+ return Array.from(counts, ([completedAt, count]) => ({
69
+ count,
70
+ completedAt
71
+ })).sort((left, right) => left.completedAt.localeCompare(right.completedAt));
72
+ },
73
+ async getLessonProgressForUser(userId) {
74
+ const userProgress = await client.query.resourceProgress.findMany({
75
+ where: eq(resourceProgress.userId, userId)
76
+ });
77
+ const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
78
+ if (!parsed.success) {
79
+ logger.error(parsed.error, {
80
+ event: "adapter.userProgress.parse_failed",
81
+ userId
82
+ });
83
+ return [];
84
+ }
85
+ return parsed.data;
86
+ },
87
+ async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
88
+ const user = await client.query.users.findFirst({
89
+ where: or(eq(users.id, userIdOrEmail), eq(users.email, userIdOrEmail)),
90
+ columns: {
91
+ id: true
92
+ }
93
+ });
94
+ if (!user) {
95
+ return null;
96
+ }
97
+ const ResultRowSchema = z.object({
98
+ resource_id: z.string(),
99
+ resource_type: z.enum([
100
+ "lesson",
101
+ "exercise",
102
+ "post"
103
+ ]),
104
+ resource_slug: z.string().nullable(),
105
+ completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
106
+ });
107
+ const results = await client.execute(sql`
108
+ WITH RECURSIVE workshop AS (
109
+ SELECT id, fields->>'$.slug' AS slug
110
+ FROM ${contentResource}
111
+ WHERE id = ${moduleIdOrSlug} OR fields->>'$.slug' = ${moduleIdOrSlug}
112
+ ),
113
+ -- Get all workshop resources with their positions
114
+ workshop_structure AS (
115
+ SELECT
116
+ w.id AS workshop_id,
117
+ crr.resourceId,
118
+ crr.position AS position,
119
+ cr.type AS resource_type,
120
+ cr.fields->>'$.slug' AS resource_slug,
121
+ cr.id AS resource_content_id
122
+ FROM workshop w
123
+ JOIN ${contentResourceResource} crr ON w.id = crr.resourceOfId
124
+ JOIN ${contentResource} cr ON crr.resourceId = cr.id
125
+ ORDER BY crr.position
126
+ ),
127
+ -- Recursively expand sections and maintain global ordering
128
+ expanded_resources AS (
129
+ -- Base case: direct lessons/posts from workshop
130
+ SELECT
131
+ workshop_id,
132
+ position * 1000 AS global_order, -- Multiply by 1000 to leave room for section items
133
+ resource_content_id AS resource_id,
134
+ resource_type,
135
+ resource_slug
136
+ FROM workshop_structure
137
+ WHERE resource_type IN ('lesson', 'post')
138
+ UNION ALL
139
+ -- Recursive case: lessons within sections
140
+ SELECT
141
+ ws.workshop_id,
142
+ ws.position * 1000 + crr.position AS global_order, -- Section position * 1000 + lesson position
143
+ cr.id AS resource_id,
144
+ cr.type AS resource_type,
145
+ cr.fields->>'$.slug' AS resource_slug
146
+ FROM workshop_structure ws
147
+ JOIN ${contentResourceResource} crr ON ws.resource_content_id = crr.resourceOfId
148
+ JOIN ${contentResource} cr ON crr.resourceId = cr.id
149
+ WHERE ws.resource_type = 'section'
150
+ AND cr.type IN ('lesson', 'post')
151
+ )
152
+ SELECT
153
+ er.resource_id,
154
+ er.resource_type,
155
+ er.resource_slug,
156
+ rp.completedAt AS completed_at,
157
+ er.global_order
158
+ FROM expanded_resources er
159
+ LEFT JOIN ${resourceProgress} rp ON rp.resourceId = er.resource_id
160
+ AND rp.userId = ${user.id}
161
+ ORDER BY er.global_order ASC
162
+ `);
163
+ const rows = Array.isArray(results) ? results[0] : results.rows;
164
+ const completedLessons = [];
165
+ let nextResource = null;
166
+ let completedLessonsCount = 0;
167
+ let totalLessonsCount = rows.length;
168
+ const parsedRows = z.array(ResultRowSchema).safeParse(rows);
169
+ if (!parsedRows.success) {
170
+ logger.error(parsedRows.error, {
171
+ event: "adapter.moduleProgress.rows.parse_failed",
172
+ moduleIdOrSlug,
173
+ userId: user.id
174
+ });
175
+ return {
176
+ completedLessons: [],
177
+ nextResource: null,
178
+ percentCompleted: 0,
179
+ completedLessonsCount: 0,
180
+ totalLessonsCount
181
+ };
182
+ }
183
+ for (const row of parsedRows.data) {
184
+ if (row.completed_at) {
185
+ completedLessonsCount++;
186
+ completedLessons.push({
187
+ userId: user.id,
188
+ resourceId: row.resource_id,
189
+ completedAt: new Date(row.completed_at)
190
+ });
191
+ } else if (!nextResource) {
192
+ nextResource = {
193
+ id: row.resource_id,
194
+ type: row.resource_type,
195
+ fields: {
196
+ slug: row.resource_slug
197
+ }
198
+ };
199
+ }
200
+ }
201
+ const percentCompleted = totalLessonsCount > 0 ? Math.ceil(completedLessonsCount / totalLessonsCount * 100) : 0;
202
+ return {
203
+ completedLessons,
204
+ nextResource,
205
+ percentCompleted,
206
+ completedLessonsCount,
207
+ totalLessonsCount
208
+ };
209
+ },
210
+ async getLessonProgresses() {
211
+ const progresses = await client.query.resourceProgress.findMany();
212
+ const parsed = z.array(resourceProgressSchema).safeParse(progresses);
213
+ if (!parsed.success) {
214
+ logger.error(parsed.error, {
215
+ event: "adapter.lessonProgresses.parse_failed"
216
+ });
217
+ return [];
218
+ }
219
+ return parsed.data;
220
+ },
221
+ async toggleLessonProgressForUser(options) {
222
+ if (!options.lessonId) {
223
+ throw new Error("No lessonId provided");
224
+ }
225
+ let lessonProgress = await client.query.resourceProgress.findFirst({
226
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
227
+ });
228
+ const now = /* @__PURE__ */ new Date();
229
+ if (lessonProgress) {
230
+ await client.update(resourceProgress).set({
231
+ completedAt: lessonProgress.completedAt ? null : now,
232
+ updatedAt: now
233
+ }).where(and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId)));
234
+ } else {
235
+ await client.insert(resourceProgress).values({
236
+ userId: options.userId,
237
+ resourceId: options.lessonId,
238
+ completedAt: now,
239
+ updatedAt: now
240
+ });
241
+ }
242
+ lessonProgress = await client.query.resourceProgress.findFirst({
243
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
244
+ });
245
+ const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
246
+ if (!parsedLessonProgress.success) {
247
+ logger.error(parsedLessonProgress.error, {
248
+ event: "adapter.lessonProgress.parse_failed",
249
+ lessonId: options.lessonId,
250
+ userId: options.userId
251
+ });
252
+ return null;
253
+ }
254
+ return parsedLessonProgress.data;
255
+ }
256
+ };
257
+ }
258
+ __name(createProgressPort, "createProgressPort");
259
+
260
+ export {
261
+ createProgressPort
262
+ };
263
+ //# sourceMappingURL=chunk-2TFZWYLS.js.map
@@ -0,0 +1,243 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-H736K5TN.js";
4
+
5
+ // src/lib/mysql/ports/coupon.ts
6
+ import { and, desc, eq, gte, inArray, isNull, or, sql } from "drizzle-orm";
7
+ import { customAlphabet } from "nanoid";
8
+ import { v4 } from "uuid";
9
+ import { z } from "zod";
10
+ import { couponSchema, merchantCouponSchema, purchaseSchema } from "@coursebuilder/core/schemas";
11
+ import { logger as baseLogger } from "@coursebuilder/utils/logger";
12
+ var guid = customAlphabet("1234567890abcdefghijklmnopqrstuvwxyz", 5);
13
+ var logger = baseLogger;
14
+ function createCouponPort({ client, tables }) {
15
+ const { coupon, merchantCoupon, purchases: purchaseTable } = tables;
16
+ return {
17
+ incrementCouponUsedCount: async (couponId) => {
18
+ await client.update(coupon).set({
19
+ usedCount: sql`${coupon.usedCount} + 1`
20
+ }).where(eq(coupon.id, couponId));
21
+ },
22
+ createMerchantCoupon: async (options) => {
23
+ await client.insert(merchantCoupon).values({
24
+ id: `mcoupon_${v4()}`,
25
+ identifier: options.identifier,
26
+ merchantAccountId: options.merchantAccountId,
27
+ type: options.type,
28
+ amountDiscount: Math.floor(options.amountDiscount),
29
+ status: 1
30
+ });
31
+ return merchantCouponSchema.parse(await client.query.merchantCoupon.findFirst({
32
+ where: eq(merchantCoupon.identifier, options.identifier)
33
+ }));
34
+ },
35
+ async couponForIdOrCode(options) {
36
+ if (!options.couponId && !options.code)
37
+ return null;
38
+ const couponForIdOrCode = await client.query.coupon.findFirst({
39
+ where: or(and(or(options.code ? eq(coupon.code, options.code) : void 0, options.couponId ? eq(coupon.id, options.couponId) : void 0), gte(coupon.expires, /* @__PURE__ */ new Date())), and(or(options.code ? eq(coupon.code, options.code) : void 0, options.couponId ? eq(coupon.id, options.couponId) : void 0), isNull(coupon.expires))),
40
+ with: {
41
+ merchantCoupon: true
42
+ }
43
+ });
44
+ if (!couponForIdOrCode)
45
+ return null;
46
+ const parsedCoupon = couponSchema.extend({
47
+ merchantCoupon: merchantCouponSchema
48
+ }).safeParse(couponForIdOrCode);
49
+ if (!parsedCoupon.success) {
50
+ logger.error(parsedCoupon.error, {
51
+ code: options.code,
52
+ couponId: options.couponId,
53
+ event: "adapter.coupon.parse_failed"
54
+ });
55
+ return null;
56
+ }
57
+ return parsedCoupon.data;
58
+ },
59
+ async getCoupon(couponIdOrCode) {
60
+ const loadedCoupon = await client.query.coupon.findFirst({
61
+ where: or(eq(coupon.id, couponIdOrCode), eq(coupon.code, couponIdOrCode))
62
+ }) || null;
63
+ logger.debug("getCoupon", {
64
+ couponIdOrCode,
65
+ found: !!loadedCoupon
66
+ });
67
+ return couponSchema.nullable().parse(loadedCoupon);
68
+ },
69
+ async getCouponWithBulkPurchases(couponId) {
70
+ logger.debug("getCouponWithBulkPurchases", {
71
+ couponId
72
+ });
73
+ let couponData;
74
+ let bulkCouponPurchases = [];
75
+ try {
76
+ couponData = await client.query.coupon.findFirst({
77
+ where: eq(coupon.id, couponId),
78
+ with: {
79
+ bulkPurchases: true,
80
+ redeemedBulkCouponPurchases: true
81
+ }
82
+ }) || null;
83
+ } catch (e) {
84
+ logger.error(e, {
85
+ method: "getCouponWithBulkPurchases",
86
+ couponId,
87
+ step: "load-coupon"
88
+ });
89
+ }
90
+ try {
91
+ bulkCouponPurchases = await client.query.purchases.findMany({
92
+ where: eq(purchaseTable.redeemedBulkCouponId, couponId),
93
+ with: {
94
+ user: true
95
+ }
96
+ });
97
+ logger.debug("getCouponWithBulkPurchases.redeemed", {
98
+ couponId,
99
+ count: bulkCouponPurchases?.length ?? 0
100
+ });
101
+ } catch (e) {
102
+ logger.error(e, {
103
+ method: "getCouponWithBulkPurchases",
104
+ couponId,
105
+ step: "load-redeemed-purchases"
106
+ });
107
+ }
108
+ if (!couponData) {
109
+ logger.debug("getCouponWithBulkPurchases", {
110
+ couponId,
111
+ error: "no coupon found"
112
+ });
113
+ return null;
114
+ }
115
+ const couponWithBulkPurchases = {
116
+ ...couponData,
117
+ redeemedBulkCouponPurchases: bulkCouponPurchases || []
118
+ };
119
+ const parsedCoupon = couponSchema.merge(z.object({
120
+ redeemedBulkCouponPurchases: z.array(purchaseSchema)
121
+ })).nullable().safeParse(couponWithBulkPurchases);
122
+ if (!parsedCoupon.success) {
123
+ logger.error(parsedCoupon.error, {
124
+ couponId: couponData?.id ?? couponId,
125
+ event: "adapter.coupon.parse_failed",
126
+ redeemedBulkCouponPurchasesCount: bulkCouponPurchases?.length ?? 0
127
+ });
128
+ return null;
129
+ }
130
+ return parsedCoupon.data;
131
+ },
132
+ async getDefaultCoupon(productIds) {
133
+ const activeSaleCoupon = await client.query.coupon.findFirst({
134
+ where: and(eq(coupon.status, 1), eq(coupon.default, true), gte(coupon.expires, /* @__PURE__ */ new Date()), or(productIds ? inArray(coupon.restrictedToProductId, productIds) : void 0, isNull(coupon.restrictedToProductId))),
135
+ orderBy: desc(coupon.percentageDiscount),
136
+ with: {
137
+ merchantCoupon: true,
138
+ product: true
139
+ }
140
+ });
141
+ if (activeSaleCoupon) {
142
+ const { restrictedToProductId } = activeSaleCoupon;
143
+ const validForProdcutId = restrictedToProductId ? productIds?.includes(restrictedToProductId) : true;
144
+ const { merchantCoupon: defaultMerchantCoupon, ...defaultCoupon } = activeSaleCoupon;
145
+ if (validForProdcutId) {
146
+ return {
147
+ defaultMerchantCoupon: merchantCouponSchema.parse(defaultMerchantCoupon),
148
+ defaultCoupon: couponSchema.parse(defaultCoupon)
149
+ };
150
+ }
151
+ }
152
+ return null;
153
+ },
154
+ async getMerchantCouponsForTypeAndPercent(params) {
155
+ return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
156
+ where: and(eq(merchantCoupon.type, params.type), eq(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
157
+ }));
158
+ },
159
+ async getMerchantCouponForTypeAndPercent(params) {
160
+ const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
161
+ where: and(eq(merchantCoupon.type, params.type), eq(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
162
+ });
163
+ const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
164
+ if (parsed.success) {
165
+ return parsed.data;
166
+ }
167
+ return null;
168
+ },
169
+ async getMerchantCouponForTypeAndAmount(params) {
170
+ const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
171
+ where: and(eq(merchantCoupon.type, params.type), eq(merchantCoupon.amountDiscount, params.amountDiscount))
172
+ });
173
+ const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
174
+ if (parsed.success) {
175
+ return parsed.data;
176
+ }
177
+ return null;
178
+ },
179
+ async getMerchantCoupon(merchantCouponId) {
180
+ const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
181
+ where: eq(merchantCoupon.id, merchantCouponId)
182
+ });
183
+ const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
184
+ if (parsed.success) {
185
+ return parsed.data;
186
+ }
187
+ return null;
188
+ },
189
+ async createCoupon(input) {
190
+ function findClosestDiscount(percentOff) {
191
+ percentOff = percentOff <= 1 ? percentOff : percentOff / 100;
192
+ return [
193
+ 1,
194
+ 0.95,
195
+ 0.9,
196
+ 0.75,
197
+ 0.6,
198
+ 0.5,
199
+ 0.4,
200
+ 0.25,
201
+ 0.1
202
+ ].reduce((a, b) => {
203
+ let aDiff = Math.abs(a - percentOff);
204
+ let bDiff = Math.abs(b - percentOff);
205
+ if (aDiff === bDiff) {
206
+ return a > b ? a : b;
207
+ } else {
208
+ return bDiff < aDiff ? b : a;
209
+ }
210
+ });
211
+ }
212
+ __name(findClosestDiscount, "findClosestDiscount");
213
+ const percentageDiscount = findClosestDiscount(Number(input.percentageDiscount) * 100);
214
+ const merchantCouponResult = percentageDiscount < 1 ? await client.query.merchantCoupon.findFirst({
215
+ where: and(eq(merchantCoupon.percentageDiscount, percentageDiscount.toString()), eq(merchantCoupon.type, "special"))
216
+ }) : null;
217
+ if (!merchantCouponResult) {
218
+ return [];
219
+ }
220
+ const codesArray = [];
221
+ const requestedQuantity = Number(input.quantity);
222
+ const couponQuantity = requestedQuantity < 0 ? 1 : requestedQuantity;
223
+ await client.transaction(async (trx) => {
224
+ for (let i = 0; i < couponQuantity; i++) {
225
+ const id = `coupon_${guid()}`;
226
+ await trx.insert(coupon).values({
227
+ ...input,
228
+ merchantCouponId: merchantCouponResult.id,
229
+ id
230
+ });
231
+ codesArray.push(id);
232
+ }
233
+ });
234
+ return codesArray;
235
+ }
236
+ };
237
+ }
238
+ __name(createCouponPort, "createCouponPort");
239
+
240
+ export {
241
+ createCouponPort
242
+ };
243
+ //# sourceMappingURL=chunk-3TRWZHL3.js.map
@@ -0,0 +1,69 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-H736K5TN.js";
4
+
5
+ // src/lib/mysql/ports/entitlement.ts
6
+ import { and, asc, eq, gte, isNull, or, sql } from "drizzle-orm";
7
+ import { z } from "zod";
8
+ import { entitlementSchema } from "@coursebuilder/core/schemas";
9
+ import { logger as baseLogger } from "@coursebuilder/utils/logger";
10
+ var logger = baseLogger;
11
+ function createEntitlementPort({ client, tables }) {
12
+ const { entitlements: entitlementTable, entitlementTypes } = tables;
13
+ return {
14
+ async getEntitlementsForUser(params) {
15
+ const { userId, sourceType, entitlementType } = params;
16
+ if (!userId) {
17
+ return [];
18
+ }
19
+ const conditions = [
20
+ eq(entitlementTable.userId, userId)
21
+ ];
22
+ if (sourceType) {
23
+ conditions.push(eq(entitlementTable.sourceType, sourceType));
24
+ }
25
+ if (entitlementType) {
26
+ conditions.push(eq(entitlementTable.entitlementType, entitlementType));
27
+ }
28
+ conditions.push(isNull(entitlementTable.deletedAt));
29
+ const expiresCondition = or(isNull(entitlementTable.expiresAt), gte(entitlementTable.expiresAt, sql`CURRENT_TIMESTAMP`));
30
+ if (expiresCondition) {
31
+ conditions.push(expiresCondition);
32
+ }
33
+ const userEntitlements = await client.query.entitlements.findMany({
34
+ where: conditions.length > 0 ? and(...conditions) : void 0,
35
+ orderBy: asc(entitlementTable.createdAt)
36
+ });
37
+ const parsedEntitlements = z.array(entitlementSchema).safeParse(userEntitlements);
38
+ if (!parsedEntitlements.success) {
39
+ logger.error(parsedEntitlements.error, {
40
+ entitlementCount: userEntitlements.length,
41
+ entitlementType,
42
+ event: "adapter.entitlement.list.parse_failed",
43
+ sourceType,
44
+ userId
45
+ });
46
+ return [];
47
+ }
48
+ return parsedEntitlements.data;
49
+ },
50
+ async getEntitlementTypeByName(name) {
51
+ const entitlementType = await client.query.entitlementTypes.findFirst({
52
+ where: eq(entitlementTypes.name, name)
53
+ });
54
+ if (!entitlementType) {
55
+ return null;
56
+ }
57
+ return {
58
+ id: String(entitlementType.id),
59
+ name: String(entitlementType.name)
60
+ };
61
+ }
62
+ };
63
+ }
64
+ __name(createEntitlementPort, "createEntitlementPort");
65
+
66
+ export {
67
+ createEntitlementPort
68
+ };
69
+ //# sourceMappingURL=chunk-4N2ECEUV.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/sessions.ts
9
9
  import { relations } from "drizzle-orm";
@@ -46,4 +46,4 @@ export {
46
46
  getSessionsSchema,
47
47
  getSessionRelationsSchema
48
48
  };
49
- //# sourceMappingURL=chunk-F56AI52P.js.map
49
+ //# sourceMappingURL=chunk-63MYTNFA.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-customer.ts
6
6
  import { sql } from "drizzle-orm";
@@ -46,4 +46,4 @@ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
46
46
  export {
47
47
  getMerchantCustomerSchema
48
48
  };
49
- //# sourceMappingURL=chunk-SIZFEXIS.js.map
49
+ //# sourceMappingURL=chunk-6MRFUIH5.js.map