@coursebuilder/adapter-drizzle 0.3.0 → 0.5.0

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 (251) hide show
  1. package/dist/{chunk-57CX5SOI.js → chunk-2UU2F4DM.js} +5 -4
  2. package/dist/{chunk-V23SCQL7.js → chunk-3NUCFLQJ.js} +2 -2
  3. package/dist/{chunk-Y7QZGEPT.js → chunk-4ZWS76VQ.js} +2 -2
  4. package/dist/{chunk-PPBEA4EM.js → chunk-6ON2O6UD.js} +2 -2
  5. package/dist/{chunk-QY4TPO7D.js → chunk-BM5UKWXI.js} +3 -3
  6. package/dist/{chunk-QMDE6HUA.js → chunk-CQNKTFXE.js} +3 -3
  7. package/dist/{chunk-4PJWD6YK.js → chunk-FRA4ZCRA.js} +462 -336
  8. package/dist/{chunk-J4LBG2TH.js → chunk-GINRTL6J.js} +2 -2
  9. package/dist/chunk-JZQ666KH.js +62 -0
  10. package/dist/{chunk-GLPDG7UE.js → chunk-KDEWFXEP.js} +2 -2
  11. package/dist/{chunk-MBB4GIJI.js → chunk-LERR6HQ3.js} +2 -2
  12. package/dist/{chunk-VDVCCU7D.js → chunk-LZHZDFNZ.js} +2 -2
  13. package/dist/{chunk-MCARHGE5.js → chunk-O6JECJRY.js} +4 -4
  14. package/dist/{chunk-BX5SO2JG.js → chunk-P4VXXTVA.js} +2 -2
  15. package/dist/{chunk-VXZRMVNY.js → chunk-QP6YMUQX.js} +2 -2
  16. package/dist/chunk-QTGVGIRO.js +54 -0
  17. package/dist/{chunk-ZD3R6UPJ.js → chunk-SRTIWWLG.js} +7 -7
  18. package/dist/{chunk-PIQXK2CY.js → chunk-TBM3AK3P.js} +3 -3
  19. package/dist/{chunk-FNYW3XKR.js → chunk-XIGJFVUM.js} +8 -8
  20. package/dist/{chunk-JKOYOL7A.js → chunk-YGRYHMCG.js} +2 -2
  21. package/dist/chunk-YVVXDJHI.js +56 -0
  22. package/dist/{chunk-J63FMGT7.js → chunk-Z245DYMP.js} +314 -190
  23. package/dist/index.js +22 -19
  24. package/dist/lib/mysql/index.cjs +1144 -774
  25. package/dist/lib/mysql/index.cjs.map +1 -1
  26. package/dist/lib/mysql/index.d.cts +2064 -1148
  27. package/dist/lib/mysql/index.d.ts +2064 -1148
  28. package/dist/lib/mysql/index.js +22 -19
  29. package/dist/lib/mysql/schemas/auth/accounts.cjs +85 -77
  30. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  31. package/dist/lib/mysql/schemas/auth/accounts.d.cts +17 -17
  32. package/dist/lib/mysql/schemas/auth/accounts.d.ts +17 -17
  33. package/dist/lib/mysql/schemas/auth/accounts.js +12 -12
  34. package/dist/lib/mysql/schemas/auth/device-access-token.cjs +214 -0
  35. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -0
  36. package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +52 -0
  37. package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +52 -0
  38. package/dist/lib/mysql/schemas/auth/device-access-token.js +22 -0
  39. package/dist/lib/mysql/schemas/auth/device-access-token.js.map +1 -0
  40. package/dist/lib/mysql/schemas/auth/device-verification.cjs +222 -0
  41. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -0
  42. package/dist/lib/mysql/schemas/auth/device-verification.d.cts +88 -0
  43. package/dist/lib/mysql/schemas/auth/device-verification.d.ts +88 -0
  44. package/dist/lib/mysql/schemas/auth/device-verification.js +22 -0
  45. package/dist/lib/mysql/schemas/auth/device-verification.js.map +1 -0
  46. package/dist/lib/mysql/schemas/auth/permissions.cjs +1 -1
  47. package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/auth/permissions.d.cts +9 -9
  49. package/dist/lib/mysql/schemas/auth/permissions.d.ts +9 -9
  50. package/dist/lib/mysql/schemas/auth/permissions.js +1 -1
  51. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +74 -66
  52. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  53. package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +10 -10
  54. package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +10 -10
  55. package/dist/lib/mysql/schemas/auth/role-permissions.js +13 -13
  56. package/dist/lib/mysql/schemas/auth/roles.cjs +72 -64
  57. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/auth/roles.d.cts +10 -10
  59. package/dist/lib/mysql/schemas/auth/roles.d.ts +10 -10
  60. package/dist/lib/mysql/schemas/auth/roles.js +12 -12
  61. package/dist/lib/mysql/schemas/auth/sessions.cjs +75 -67
  62. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  63. package/dist/lib/mysql/schemas/auth/sessions.d.cts +6 -6
  64. package/dist/lib/mysql/schemas/auth/sessions.d.ts +6 -6
  65. package/dist/lib/mysql/schemas/auth/sessions.js +13 -13
  66. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +77 -69
  67. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  68. package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +10 -10
  69. package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +10 -10
  70. package/dist/lib/mysql/schemas/auth/user-permissions.js +12 -12
  71. package/dist/lib/mysql/schemas/auth/user-prefs.cjs +222 -0
  72. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -0
  73. package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +100 -0
  74. package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +100 -0
  75. package/dist/lib/mysql/schemas/auth/user-prefs.js +21 -0
  76. package/dist/lib/mysql/schemas/auth/user-prefs.js.map +1 -0
  77. package/dist/lib/mysql/schemas/auth/user-roles.cjs +77 -69
  78. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  79. package/dist/lib/mysql/schemas/auth/user-roles.d.cts +10 -10
  80. package/dist/lib/mysql/schemas/auth/user-roles.d.ts +10 -10
  81. package/dist/lib/mysql/schemas/auth/user-roles.js +12 -12
  82. package/dist/lib/mysql/schemas/auth/users.cjs +263 -180
  83. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  84. package/dist/lib/mysql/schemas/auth/users.d.cts +35 -21
  85. package/dist/lib/mysql/schemas/auth/users.d.ts +35 -21
  86. package/dist/lib/mysql/schemas/auth/users.js +12 -12
  87. package/dist/lib/mysql/schemas/auth/verification-tokens.cjs +1 -1
  88. package/dist/lib/mysql/schemas/auth/verification-tokens.cjs.map +1 -1
  89. package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +5 -5
  90. package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +5 -5
  91. package/dist/lib/mysql/schemas/auth/verification-tokens.js +1 -1
  92. package/dist/lib/mysql/schemas/commerce/coupon.cjs +75 -65
  93. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  94. package/dist/lib/mysql/schemas/commerce/coupon.d.cts +19 -19
  95. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +19 -19
  96. package/dist/lib/mysql/schemas/commerce/coupon.js +12 -12
  97. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +1 -1
  98. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
  99. package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +6 -6
  100. package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +6 -6
  101. package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
  102. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +6 -5
  103. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  104. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +13 -13
  105. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +13 -13
  106. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +4 -4
  107. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +1 -1
  108. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
  109. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +7 -7
  110. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +7 -7
  111. package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
  112. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +3 -2
  113. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
  114. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +7 -7
  115. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +7 -7
  116. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
  117. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +1 -1
  118. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
  119. package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +8 -8
  120. package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +8 -8
  121. package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
  122. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +1 -1
  123. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
  124. package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +7 -7
  125. package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +7 -7
  126. package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
  127. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +1 -1
  128. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
  129. package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +4 -4
  130. package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +4 -4
  131. package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
  132. package/dist/lib/mysql/schemas/commerce/price.cjs +60 -52
  133. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  134. package/dist/lib/mysql/schemas/commerce/price.d.cts +11 -11
  135. package/dist/lib/mysql/schemas/commerce/price.d.ts +11 -11
  136. package/dist/lib/mysql/schemas/commerce/price.js +12 -12
  137. package/dist/lib/mysql/schemas/commerce/product.cjs +75 -67
  138. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  139. package/dist/lib/mysql/schemas/commerce/product.d.cts +13 -13
  140. package/dist/lib/mysql/schemas/commerce/product.d.ts +13 -13
  141. package/dist/lib/mysql/schemas/commerce/product.js +12 -12
  142. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +105 -96
  143. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  144. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +15 -15
  145. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +15 -15
  146. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +13 -13
  147. package/dist/lib/mysql/schemas/commerce/purchase.cjs +138 -128
  148. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  149. package/dist/lib/mysql/schemas/commerce/purchase.d.cts +25 -25
  150. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +25 -25
  151. package/dist/lib/mysql/schemas/commerce/purchase.js +12 -12
  152. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +66 -58
  153. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  154. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +11 -11
  155. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +11 -11
  156. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +13 -13
  157. package/dist/lib/mysql/schemas/communication/comment.cjs +220 -0
  158. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -0
  159. package/dist/lib/mysql/schemas/communication/comment.d.cts +100 -0
  160. package/dist/lib/mysql/schemas/communication/comment.d.ts +100 -0
  161. package/dist/lib/mysql/schemas/communication/comment.js +21 -0
  162. package/dist/lib/mysql/schemas/communication/comment.js.map +1 -0
  163. package/dist/lib/mysql/schemas/communication/communication-channel.cjs +1 -1
  164. package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
  165. package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +8 -8
  166. package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +8 -8
  167. package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
  168. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +1 -1
  169. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
  170. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +8 -8
  171. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +8 -8
  172. package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
  173. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +99 -91
  174. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  175. package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +16 -16
  176. package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +16 -16
  177. package/dist/lib/mysql/schemas/communication/communication-preferences.js +12 -12
  178. package/dist/lib/mysql/schemas/content/content-contributions.cjs +67 -59
  179. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  180. package/dist/lib/mysql/schemas/content/content-contributions.d.cts +13 -13
  181. package/dist/lib/mysql/schemas/content/content-contributions.d.ts +13 -13
  182. package/dist/lib/mysql/schemas/content/content-contributions.js +12 -12
  183. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +61 -53
  184. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  185. package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +11 -11
  186. package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +11 -11
  187. package/dist/lib/mysql/schemas/content/content-resource-product.js +12 -12
  188. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +58 -50
  189. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  190. package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +11 -11
  191. package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +11 -11
  192. package/dist/lib/mysql/schemas/content/content-resource-resource.js +12 -12
  193. package/dist/lib/mysql/schemas/content/content-resource.cjs +114 -66
  194. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  195. package/dist/lib/mysql/schemas/content/content-resource.d.cts +14 -13
  196. package/dist/lib/mysql/schemas/content/content-resource.d.ts +14 -13
  197. package/dist/lib/mysql/schemas/content/content-resource.js +12 -12
  198. package/dist/lib/mysql/schemas/content/contribution-types.cjs +1 -1
  199. package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
  200. package/dist/lib/mysql/schemas/content/contribution-types.d.cts +10 -10
  201. package/dist/lib/mysql/schemas/content/contribution-types.d.ts +10 -10
  202. package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
  203. package/dist/lib/mysql/schemas/content/lesson-progress.cjs +77 -0
  204. package/dist/lib/mysql/schemas/content/lesson-progress.cjs.map +1 -0
  205. package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +132 -0
  206. package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +132 -0
  207. package/dist/lib/mysql/schemas/content/lesson-progress.js +8 -0
  208. package/dist/lib/mysql/schemas/content/lesson-progress.js.map +1 -0
  209. package/dist/lib/mysql/schemas/content/resource-progress.cjs +7 -7
  210. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  211. package/dist/lib/mysql/schemas/content/resource-progress.d.cts +9 -9
  212. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +9 -9
  213. package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
  214. package/package.json +5 -5
  215. package/src/lib/mysql/index.ts +186 -54
  216. package/src/lib/mysql/schemas/auth/accounts.ts +1 -1
  217. package/src/lib/mysql/schemas/auth/device-access-token.ts +40 -0
  218. package/src/lib/mysql/schemas/auth/device-verification.ts +48 -0
  219. package/src/lib/mysql/schemas/auth/permissions.ts +1 -1
  220. package/src/lib/mysql/schemas/auth/role-permissions.ts +1 -1
  221. package/src/lib/mysql/schemas/auth/roles.ts +1 -1
  222. package/src/lib/mysql/schemas/auth/sessions.ts +1 -1
  223. package/src/lib/mysql/schemas/auth/user-permissions.ts +1 -1
  224. package/src/lib/mysql/schemas/auth/user-prefs.ts +52 -0
  225. package/src/lib/mysql/schemas/auth/user-roles.ts +1 -1
  226. package/src/lib/mysql/schemas/auth/users.ts +14 -2
  227. package/src/lib/mysql/schemas/auth/verification-tokens.ts +1 -1
  228. package/src/lib/mysql/schemas/commerce/coupon.ts +6 -4
  229. package/src/lib/mysql/schemas/commerce/merchant-account.ts +1 -1
  230. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +1 -1
  231. package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +1 -1
  232. package/src/lib/mysql/schemas/commerce/merchant-customer.ts +3 -1
  233. package/src/lib/mysql/schemas/commerce/merchant-price.ts +1 -1
  234. package/src/lib/mysql/schemas/commerce/merchant-product.ts +1 -1
  235. package/src/lib/mysql/schemas/commerce/merchant-session.ts +1 -1
  236. package/src/lib/mysql/schemas/commerce/price.ts +1 -1
  237. package/src/lib/mysql/schemas/commerce/product.ts +1 -1
  238. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +1 -1
  239. package/src/lib/mysql/schemas/commerce/purchase.ts +5 -4
  240. package/src/lib/mysql/schemas/commerce/upgradable-products.ts +1 -1
  241. package/src/lib/mysql/schemas/communication/comment.ts +52 -0
  242. package/src/lib/mysql/schemas/communication/communication-channel.ts +1 -1
  243. package/src/lib/mysql/schemas/communication/communication-preference-types.ts +1 -1
  244. package/src/lib/mysql/schemas/communication/communication-preferences.ts +1 -1
  245. package/src/lib/mysql/schemas/content/content-contributions.ts +1 -1
  246. package/src/lib/mysql/schemas/content/content-resource-product.ts +1 -1
  247. package/src/lib/mysql/schemas/content/content-resource-resource.ts +1 -1
  248. package/src/lib/mysql/schemas/content/content-resource.ts +6 -2
  249. package/src/lib/mysql/schemas/content/contribution-types.ts +1 -1
  250. package/src/lib/mysql/schemas/content/lesson-progress.ts +39 -0
  251. package/src/lib/mysql/schemas/content/resource-progress.ts +6 -8
@@ -1,28 +1,41 @@
1
+ import {
2
+ getLessonProgressSchema
3
+ } from "./chunk-YVVXDJHI.js";
1
4
  import {
2
5
  getResourceProgressSchema
3
- } from "./chunk-FNYW3XKR.js";
6
+ } from "./chunk-XIGJFVUM.js";
7
+ import {
8
+ getPurchaseUserTransferRelationsSchema,
9
+ getPurchaseUserTransferSchema
10
+ } from "./chunk-CQNKTFXE.js";
4
11
  import {
5
12
  getUpgradableProductsRelationsSchema,
6
13
  getUpgradableProductsSchema
7
- } from "./chunk-QY4TPO7D.js";
14
+ } from "./chunk-BM5UKWXI.js";
8
15
  import {
9
- getPurchaseUserTransferRelationsSchema,
10
- getPurchaseUserTransferSchema
11
- } from "./chunk-QMDE6HUA.js";
16
+ getRolePermissionsRelationsSchema,
17
+ getRolePermissionsSchema
18
+ } from "./chunk-O6JECJRY.js";
12
19
  import {
13
20
  getSessionRelationsSchema,
14
21
  getSessionsSchema
15
- } from "./chunk-PIQXK2CY.js";
22
+ } from "./chunk-TBM3AK3P.js";
16
23
  import {
17
24
  getVerificationTokensSchema
18
- } from "./chunk-MBB4GIJI.js";
25
+ } from "./chunk-LERR6HQ3.js";
19
26
  import {
20
- getRolePermissionsRelationsSchema,
21
- getRolePermissionsSchema
22
- } from "./chunk-MCARHGE5.js";
27
+ getDeviceAccessTokenRelationsSchema,
28
+ getDeviceAccessTokenSchema
29
+ } from "./chunk-QTGVGIRO.js";
30
+ import {
31
+ getDeviceVerificationRelationsSchema,
32
+ getDeviceVerificationSchema
33
+ } from "./chunk-JZQ666KH.js";
23
34
  import {
24
35
  getAccountsRelationsSchema,
25
36
  getAccountsSchema,
37
+ getCommentRelationsSchema,
38
+ getCommentsSchema,
26
39
  getCommunicationPreferencesRelationsSchema,
27
40
  getCommunicationPreferencesSchema,
28
41
  getContentContributionRelationsSchema,
@@ -44,47 +57,49 @@ import {
44
57
  getRolesSchema,
45
58
  getUserPermissionsRelationsSchema,
46
59
  getUserPermissionsSchema,
60
+ getUserPrefsRelationsSchema,
61
+ getUserPrefsSchema,
47
62
  getUserRolesRelationsSchema,
48
63
  getUserRolesSchema,
49
64
  getUsersRelationsSchema,
50
65
  getUsersSchema
51
- } from "./chunk-4PJWD6YK.js";
66
+ } from "./chunk-FRA4ZCRA.js";
52
67
  import {
53
68
  getContributionTypesRelationsSchema,
54
69
  getContributionTypesSchema
55
- } from "./chunk-GLPDG7UE.js";
70
+ } from "./chunk-KDEWFXEP.js";
56
71
  import {
57
72
  getCommunicationChannelSchema
58
- } from "./chunk-J4LBG2TH.js";
73
+ } from "./chunk-GINRTL6J.js";
59
74
  import {
60
75
  getCommunicationPreferenceTypesSchema
61
- } from "./chunk-BX5SO2JG.js";
62
- import {
63
- getMerchantCouponSchema
64
- } from "./chunk-JKOYOL7A.js";
65
- import {
66
- getMerchantPriceSchema
67
- } from "./chunk-PPBEA4EM.js";
68
- import {
69
- getMerchantSessionSchema
70
- } from "./chunk-V23SCQL7.js";
76
+ } from "./chunk-P4VXXTVA.js";
71
77
  import {
72
78
  getMerchantChargeRelationsSchema,
73
79
  getMerchantChargeSchema
74
- } from "./chunk-ZD3R6UPJ.js";
80
+ } from "./chunk-SRTIWWLG.js";
81
+ import {
82
+ getMerchantAccountSchema
83
+ } from "./chunk-QP6YMUQX.js";
84
+ import {
85
+ getMerchantCouponSchema
86
+ } from "./chunk-YGRYHMCG.js";
75
87
  import {
76
88
  getMerchantCustomerSchema
77
- } from "./chunk-57CX5SOI.js";
89
+ } from "./chunk-2UU2F4DM.js";
90
+ import {
91
+ getMerchantPriceSchema
92
+ } from "./chunk-6ON2O6UD.js";
78
93
  import {
79
94
  getMerchantProductSchema
80
- } from "./chunk-Y7QZGEPT.js";
95
+ } from "./chunk-4ZWS76VQ.js";
81
96
  import {
82
- getMerchantAccountSchema
83
- } from "./chunk-VXZRMVNY.js";
97
+ getMerchantSessionSchema
98
+ } from "./chunk-3NUCFLQJ.js";
84
99
  import {
85
100
  getPermissionsRelationsSchema,
86
101
  getPermissionsSchema
87
- } from "./chunk-VDVCCU7D.js";
102
+ } from "./chunk-LZHZDFNZ.js";
88
103
  import {
89
104
  __name
90
105
  } from "./chunk-H736K5TN.js";
@@ -8108,26 +8123,38 @@ var z2 = /* @__PURE__ */ Object.freeze({
8108
8123
  ZodError: ZodError2
8109
8124
  });
8110
8125
 
8111
- // ../core/dist/chunk-LMH5A7OR.js
8112
- var purchaseUserTransferSchema = z2.object({
8126
+ // ../core/dist/chunk-CHYUPSYW.js
8127
+ var userSchema = z2.object({
8128
+ id: z2.string().max(255),
8129
+ name: z2.string().max(255).optional().nullable(),
8130
+ role: z2.enum([
8131
+ "user",
8132
+ "admin"
8133
+ ]).default("user"),
8134
+ email: z2.string().max(255).email(),
8135
+ emailVerified: z2.coerce.date().nullable(),
8136
+ image: z2.string().max(255).optional().nullable(),
8137
+ createdAt: z2.coerce.date().nullable(),
8138
+ roles: z2.array(z2.object({
8139
+ id: z2.string(),
8140
+ name: z2.string(),
8141
+ description: z2.string().nullable(),
8142
+ active: z2.boolean()
8143
+ })).optional().default([])
8144
+ });
8145
+
8146
+ // ../core/dist/chunk-47RWEDJ6.js
8147
+ var priceSchema = z2.object({
8113
8148
  id: z2.string().max(191),
8114
- transferState: z2.enum([
8115
- "AVAILABLE",
8116
- "INITIATED",
8117
- "VERIFIED",
8118
- "CANCELED",
8119
- "EXPIRED",
8120
- "CONFIRMED",
8121
- "COMPLETED"
8122
- ]).default("AVAILABLE"),
8123
- purchaseId: z2.string().max(191),
8124
- sourceUserId: z2.string().max(191),
8125
- targetUserId: z2.string().max(191).optional().nullable(),
8149
+ productId: z2.string().max(191).optional().nullable(),
8150
+ nickname: z2.string().max(191).optional().nullable(),
8151
+ status: z2.number().int().default(0),
8152
+ unitAmount: z2.coerce.number().refine((value) => {
8153
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8154
+ return decimalPlaces <= 2;
8155
+ }),
8126
8156
  createdAt: z2.date().nullable(),
8127
- expiresAt: z2.date().nullable(),
8128
- canceledAt: z2.date().nullable(),
8129
- confirmedAt: z2.date().nullable(),
8130
- completedAt: z2.date().nullable()
8157
+ fields: z2.record(z2.any()).default({})
8131
8158
  });
8132
8159
 
8133
8160
  // ../core/dist/chunk-YYIPQN6H.js
@@ -8174,111 +8201,6 @@ var ResourceVisibilitySchema = z2.union([
8174
8201
  z2.literal("unlisted")
8175
8202
  ]);
8176
8203
 
8177
- // ../core/dist/chunk-GCYJ74DO.js
8178
- var resourceProgressSchema = z2.object({
8179
- userId: z2.string().max(191),
8180
- contentResourceId: z2.string().max(191).optional().nullable(),
8181
- fields: z2.record(z2.any()).default({}),
8182
- completedAt: z2.date().nullable(),
8183
- updatedAt: z2.date().nullable(),
8184
- createdAt: z2.date().nullable()
8185
- });
8186
- var moduleProgressSchema = z2.object({
8187
- completedLessons: z2.array(resourceProgressSchema),
8188
- nextResource: ContentResourceSchema.nullable(),
8189
- percentCompleted: z2.number().default(0),
8190
- completedLessonsCount: z2.number().default(0),
8191
- totalLessonsCount: z2.number().default(0)
8192
- });
8193
-
8194
- // ../core/dist/chunk-DLQA3JMA.js
8195
- var upgradableProductSchema = z2.object({
8196
- upgradableToId: z2.string().max(255),
8197
- upgradableFromId: z2.string().max(255),
8198
- position: z2.number().default(0),
8199
- metadata: z2.record(z2.any()).default({}),
8200
- createdAt: z2.date().nullable(),
8201
- updatedAt: z2.date().nullable(),
8202
- deletedAt: z2.date().nullable()
8203
- });
8204
-
8205
- // ../core/dist/chunk-G22WGQ3G.js
8206
- var VideoResourceSchema = z2.object({
8207
- id: z2.string(),
8208
- updatedAt: z2.string().optional(),
8209
- createdAt: z2.string().optional(),
8210
- title: z2.string().optional().nullable(),
8211
- duration: z2.number().optional().nullable(),
8212
- muxPlaybackId: z2.string().optional().nullable(),
8213
- muxAssetId: z2.string().optional().nullable(),
8214
- transcript: z2.string().optional().nullable(),
8215
- transcriptWithScreenshots: z2.string().optional().nullable(),
8216
- srt: z2.string().optional().nullable(),
8217
- wordLevelSrt: z2.string().optional().nullable(),
8218
- state: z2.enum([
8219
- "new",
8220
- "processing",
8221
- "preparing",
8222
- "ready",
8223
- "errored"
8224
- ])
8225
- });
8226
-
8227
- // ../core/dist/chunk-PS6USEN7.js
8228
- var merchantPriceSchema = z2.object({
8229
- id: z2.string().max(191),
8230
- merchantAccountId: z2.string().max(191),
8231
- merchantProductId: z2.string().max(191),
8232
- status: z2.number().int().default(0),
8233
- identifier: z2.string().max(191).optional().nullable(),
8234
- createdAt: z2.date(),
8235
- priceId: z2.string().max(191).optional().nullable()
8236
- });
8237
-
8238
- // ../core/dist/chunk-DAG4HKGL.js
8239
- var merchantProductSchema = z2.object({
8240
- id: z2.string().max(191),
8241
- merchantAccountId: z2.string().max(191),
8242
- productId: z2.string().max(191),
8243
- status: z2.number().int().default(0),
8244
- identifier: z2.string().max(191).optional().nullable(),
8245
- createdAt: z2.date().nullable()
8246
- });
8247
-
8248
- // ../core/dist/chunk-CHYUPSYW.js
8249
- var userSchema = z2.object({
8250
- id: z2.string().max(255),
8251
- name: z2.string().max(255).optional().nullable(),
8252
- role: z2.enum([
8253
- "user",
8254
- "admin"
8255
- ]).default("user"),
8256
- email: z2.string().max(255).email(),
8257
- emailVerified: z2.coerce.date().nullable(),
8258
- image: z2.string().max(255).optional().nullable(),
8259
- createdAt: z2.coerce.date().nullable(),
8260
- roles: z2.array(z2.object({
8261
- id: z2.string(),
8262
- name: z2.string(),
8263
- description: z2.string().nullable(),
8264
- active: z2.boolean()
8265
- })).optional().default([])
8266
- });
8267
-
8268
- // ../core/dist/chunk-47RWEDJ6.js
8269
- var priceSchema = z2.object({
8270
- id: z2.string().max(191),
8271
- productId: z2.string().max(191).optional().nullable(),
8272
- nickname: z2.string().max(191).optional().nullable(),
8273
- status: z2.number().int().default(0),
8274
- unitAmount: z2.coerce.number().refine((value) => {
8275
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8276
- return decimalPlaces <= 2;
8277
- }),
8278
- createdAt: z2.date().nullable(),
8279
- fields: z2.record(z2.any()).default({})
8280
- });
8281
-
8282
8204
  // ../core/dist/chunk-DGMGNBW7.js
8283
8205
  var productSchema = z2.object({
8284
8206
  id: z2.string().max(191),
@@ -8366,16 +8288,77 @@ var purchaseSchema = z2.object({
8366
8288
  product: productSchema.optional().nullable()
8367
8289
  });
8368
8290
 
8369
- // ../core/dist/chunk-SGE7BCRS.js
8370
- var merchantChargeSchema = z2.object({
8291
+ // ../core/dist/chunk-LMH5A7OR.js
8292
+ var purchaseUserTransferSchema = z2.object({
8371
8293
  id: z2.string().max(191),
8372
- status: z2.number().int().default(0),
8373
- identifier: z2.string().max(191),
8294
+ transferState: z2.enum([
8295
+ "AVAILABLE",
8296
+ "INITIATED",
8297
+ "VERIFIED",
8298
+ "CANCELED",
8299
+ "EXPIRED",
8300
+ "CONFIRMED",
8301
+ "COMPLETED"
8302
+ ]).default("AVAILABLE"),
8303
+ purchaseId: z2.string().max(191),
8304
+ sourceUserId: z2.string().max(191),
8305
+ targetUserId: z2.string().max(191).optional().nullable(),
8306
+ createdAt: z2.date().nullable(),
8307
+ expiresAt: z2.date().nullable(),
8308
+ canceledAt: z2.date().nullable(),
8309
+ confirmedAt: z2.date().nullable(),
8310
+ completedAt: z2.date().nullable()
8311
+ });
8312
+
8313
+ // ../core/dist/chunk-K6G2HAJT.js
8314
+ var resourceProgressSchema = z2.object({
8374
8315
  userId: z2.string().max(191),
8375
- merchantAccountId: z2.string().max(191),
8376
- merchantProductId: z2.string().max(191),
8316
+ resourceId: z2.string().max(191).optional().nullable(),
8317
+ fields: z2.record(z2.any()).default({}),
8318
+ completedAt: z2.date().nullable(),
8319
+ updatedAt: z2.date().nullable(),
8320
+ createdAt: z2.date().nullable()
8321
+ });
8322
+ var moduleProgressSchema = z2.object({
8323
+ completedLessons: z2.array(resourceProgressSchema),
8324
+ nextResource: ContentResourceSchema.nullable(),
8325
+ percentCompleted: z2.number().default(0),
8326
+ completedLessonsCount: z2.number().default(0),
8327
+ totalLessonsCount: z2.number().default(0)
8328
+ });
8329
+
8330
+ // ../core/dist/chunk-DLQA3JMA.js
8331
+ var upgradableProductSchema = z2.object({
8332
+ upgradableToId: z2.string().max(255),
8333
+ upgradableFromId: z2.string().max(255),
8334
+ position: z2.number().default(0),
8335
+ metadata: z2.record(z2.any()).default({}),
8377
8336
  createdAt: z2.date().nullable(),
8378
- merchantCustomerId: z2.string().max(191)
8337
+ updatedAt: z2.date().nullable(),
8338
+ deletedAt: z2.date().nullable()
8339
+ });
8340
+
8341
+ // ../core/dist/chunk-5QZXOTEH.js
8342
+ var VideoResourceSchema = z2.object({
8343
+ id: z2.string(),
8344
+ updatedAt: z2.string().optional(),
8345
+ createdAt: z2.string().optional(),
8346
+ title: z2.string().optional().nullable(),
8347
+ duration: z2.number().optional().nullable(),
8348
+ muxPlaybackId: z2.string().optional().nullable(),
8349
+ muxAssetId: z2.string().optional().nullable(),
8350
+ transcript: z2.string().optional().nullable(),
8351
+ transcriptWithScreenshots: z2.string().optional().nullable(),
8352
+ srt: z2.string().optional().nullable(),
8353
+ wordLevelSrt: z2.string().optional().nullable(),
8354
+ state: z2.enum([
8355
+ "new",
8356
+ "processing",
8357
+ "preparing",
8358
+ "ready",
8359
+ "errored",
8360
+ "deleted"
8361
+ ])
8379
8362
  });
8380
8363
 
8381
8364
  // ../core/dist/chunk-EDDT2FFU.js
@@ -8388,6 +8371,39 @@ var merchantCustomerSchema = z2.object({
8388
8371
  status: z2.number().int().default(0)
8389
8372
  });
8390
8373
 
8374
+ // ../core/dist/chunk-PS6USEN7.js
8375
+ var merchantPriceSchema = z2.object({
8376
+ id: z2.string().max(191),
8377
+ merchantAccountId: z2.string().max(191),
8378
+ merchantProductId: z2.string().max(191),
8379
+ status: z2.number().int().default(0),
8380
+ identifier: z2.string().max(191).optional().nullable(),
8381
+ createdAt: z2.date(),
8382
+ priceId: z2.string().max(191).optional().nullable()
8383
+ });
8384
+
8385
+ // ../core/dist/chunk-DAG4HKGL.js
8386
+ var merchantProductSchema = z2.object({
8387
+ id: z2.string().max(191),
8388
+ merchantAccountId: z2.string().max(191),
8389
+ productId: z2.string().max(191),
8390
+ status: z2.number().int().default(0),
8391
+ identifier: z2.string().max(191).optional().nullable(),
8392
+ createdAt: z2.date().nullable()
8393
+ });
8394
+
8395
+ // ../core/dist/chunk-SGE7BCRS.js
8396
+ var merchantChargeSchema = z2.object({
8397
+ id: z2.string().max(191),
8398
+ status: z2.number().int().default(0),
8399
+ identifier: z2.string().max(191),
8400
+ userId: z2.string().max(191),
8401
+ merchantAccountId: z2.string().max(191),
8402
+ merchantProductId: z2.string().max(191),
8403
+ createdAt: z2.date().nullable(),
8404
+ merchantCustomerId: z2.string().max(191)
8405
+ });
8406
+
8391
8407
  // ../core/dist/chunk-256SROW3.js
8392
8408
  var merchantCouponSchema = z2.object({
8393
8409
  id: z2.string().max(191),
@@ -8561,6 +8577,7 @@ function getCourseBuilderSchema(mysqlTable) {
8561
8577
  verificationTokens: getVerificationTokensSchema(mysqlTable),
8562
8578
  coupon: getCouponSchema(mysqlTable),
8563
8579
  couponRelations: getCouponRelationsSchema(mysqlTable),
8580
+ lessonProgress: getLessonProgressSchema(mysqlTable),
8564
8581
  merchantAccount: getMerchantAccountSchema(mysqlTable),
8565
8582
  merchantCharge: getMerchantChargeSchema(mysqlTable),
8566
8583
  merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
@@ -8592,7 +8609,15 @@ function getCourseBuilderSchema(mysqlTable) {
8592
8609
  upgradableProductsRelations: getUpgradableProductsRelationsSchema(mysqlTable),
8593
8610
  contentResourceProduct: getContentResourceProductSchema(mysqlTable),
8594
8611
  contentResourceProductRelations: getContentResourceProductRelationsSchema(mysqlTable),
8595
- productRelations: getProductRelationsSchema(mysqlTable)
8612
+ productRelations: getProductRelationsSchema(mysqlTable),
8613
+ comments: getCommentsSchema(mysqlTable),
8614
+ commentsRelations: getCommentRelationsSchema(mysqlTable),
8615
+ deviceVerifications: getDeviceVerificationSchema(mysqlTable),
8616
+ deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable),
8617
+ deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
8618
+ deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable),
8619
+ userPrefs: getUserPrefsSchema(mysqlTable),
8620
+ userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable)
8596
8621
  };
8597
8622
  }
8598
8623
  __name(getCourseBuilderSchema, "getCourseBuilderSchema");
@@ -8601,7 +8626,7 @@ function createTables(mySqlTable) {
8601
8626
  }
8602
8627
  __name(createTables, "createTables");
8603
8628
  function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
8604
- const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress } = createTables(tableFn);
8629
+ const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments } = createTables(tableFn);
8605
8630
  const adapter = {
8606
8631
  client,
8607
8632
  async redeemFullPriceCoupon(options) {
@@ -8738,7 +8763,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
8738
8763
  throw new Error("No lessonId provided");
8739
8764
  }
8740
8765
  let lessonProgress = await client.query.resourceProgress.findFirst({
8741
- where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.contentResourceId, options.lessonId))
8766
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
8742
8767
  });
8743
8768
  const now = /* @__PURE__ */ new Date();
8744
8769
  if (lessonProgress) {
@@ -8746,18 +8771,18 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
8746
8771
  await client.update(resourceProgress).set({
8747
8772
  completedAt: now,
8748
8773
  updatedAt: now
8749
- }).where(eq(resourceProgress.contentResourceId, options.lessonId));
8774
+ }).where(eq(resourceProgress.resourceId, options.lessonId));
8750
8775
  }
8751
8776
  } else {
8752
8777
  await client.insert(resourceProgress).values({
8753
8778
  userId: options.userId,
8754
- contentResourceId: options.lessonId,
8779
+ resourceId: options.lessonId,
8755
8780
  completedAt: now,
8756
8781
  updatedAt: now
8757
8782
  });
8758
8783
  }
8759
8784
  lessonProgress = await client.query.resourceProgress.findFirst({
8760
- where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.contentResourceId, options.lessonId))
8785
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
8761
8786
  });
8762
8787
  const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
8763
8788
  if (!parsedLessonProgress.success) {
@@ -8777,9 +8802,14 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
8777
8802
  });
8778
8803
  if (!couponForIdOrCode)
8779
8804
  return null;
8780
- return couponSchema.extend({
8805
+ const parsedCoupon = couponSchema.extend({
8781
8806
  merchantCoupon: merchantCouponSchema
8782
- }).parse(couponForIdOrCode);
8807
+ }).safeParse(couponForIdOrCode);
8808
+ if (!parsedCoupon.success) {
8809
+ console.error("Error parsing coupon", JSON.stringify(parsedCoupon.error));
8810
+ return null;
8811
+ }
8812
+ return parsedCoupon.data;
8783
8813
  },
8784
8814
  async createMerchantChargeAndPurchase(options) {
8785
8815
  const purchaseId = await client.transaction(async (trx) => {
@@ -8816,7 +8846,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
8816
8846
  ]))
8817
8847
  }) || null);
8818
8848
  const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, and(eq(coupon.id, purchaseTable.bulkCouponId), eq(purchaseTable.userId, userId))).where(and(eq(coupon.restrictedToProductId, productId), eq(purchaseTable.userId, userId))).then((res) => {
8819
- return res[0]?.coupons ?? null;
8849
+ return res[0]?.Coupon ?? null;
8820
8850
  }));
8821
8851
  const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
8822
8852
  let bulkCouponId = null;
@@ -8928,7 +8958,13 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
8928
8958
  };
8929
8959
  },
8930
8960
  async getCoupon(couponIdOrCode) {
8931
- return couponSchema.nullable().parse(await client.select().from(coupon).where(or(eq(coupon.id, couponIdOrCode), eq(coupon.code, couponIdOrCode))).then((res) => res[0] ?? null));
8961
+ const loadedCoupon = await client.query.coupon.findFirst({
8962
+ where: or(eq(coupon.id, couponIdOrCode), eq(coupon.code, couponIdOrCode))
8963
+ }) || null;
8964
+ logger.debug("loadedCoupon", {
8965
+ loadedCoupon
8966
+ });
8967
+ return couponSchema.nullable().parse(loadedCoupon);
8932
8968
  },
8933
8969
  async getCouponWithBulkPurchases(couponId) {
8934
8970
  logger.debug("getCouponWithBulkPurchases", {
@@ -9001,22 +9037,67 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9001
9037
  return parsed.data;
9002
9038
  },
9003
9039
  async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
9040
+ const ALLOWED_MODULE_RESOURCE_TYPES = [
9041
+ "lesson",
9042
+ "exercise",
9043
+ "solution"
9044
+ ];
9045
+ const COUNTABLE_MODULE_RESOURCE_TYPES = [
9046
+ "lesson",
9047
+ "exercise"
9048
+ ];
9004
9049
  const module = await client.query.contentResource.findFirst({
9005
9050
  where: or(eq(contentResource.id, moduleIdOrSlug), eq(sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, moduleIdOrSlug)),
9006
9051
  with: {
9007
9052
  resources: {
9053
+ with: {
9054
+ resource: {
9055
+ with: {
9056
+ resources: {
9057
+ with: {
9058
+ resource: {
9059
+ with: {
9060
+ resources: {
9061
+ with: {
9062
+ resource: true
9063
+ }
9064
+ }
9065
+ }
9066
+ }
9067
+ },
9068
+ orderBy: asc(contentResourceResource.position)
9069
+ }
9070
+ }
9071
+ }
9072
+ },
9008
9073
  orderBy: asc(contentResourceResource.position)
9009
9074
  }
9010
9075
  }
9011
9076
  });
9012
9077
  const parsedModule = ContentResourceSchema.parse(module);
9013
- const moduleResources = await client.query.contentResourceResource.findMany({
9014
- where: inArray(contentResourceResource.resourceOfId, parsedModule.resources?.map((r) => r.resourceId) ?? []),
9015
- orderBy: asc(contentResourceResource.position)
9078
+ function flattenResources(resources) {
9079
+ const result = [];
9080
+ function recurse(resources2) {
9081
+ for (const nestedResource of resources2) {
9082
+ const resource = nestedResource.resource;
9083
+ result.push(resource);
9084
+ if (resource.resources) {
9085
+ recurse(resource.resources);
9086
+ }
9087
+ }
9088
+ }
9089
+ __name(recurse, "recurse");
9090
+ recurse(resources);
9091
+ return result;
9092
+ }
9093
+ __name(flattenResources, "flattenResources");
9094
+ const allResources = parsedModule?.resources && flattenResources(parsedModule.resources);
9095
+ const filteredResources = allResources?.filter((resource) => {
9096
+ return ALLOWED_MODULE_RESOURCE_TYPES.includes(resource.type);
9016
9097
  });
9017
- const parsedModuleResources = z.array(ContentResourceResourceSchema).safeParse(moduleResources);
9018
- if (!parsedModuleResources.success) {
9019
- console.error("Error parsing module resources", parsedModuleResources.error);
9098
+ const parsedResources = z.array(ContentResourceSchema).safeParse(filteredResources);
9099
+ if (!parsedResources.success) {
9100
+ console.error("Error parsing module resources", parsedResources.error);
9020
9101
  return {
9021
9102
  completedLessons: [],
9022
9103
  nextResource: null,
@@ -9025,10 +9106,25 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9025
9106
  totalLessonsCount: 0
9026
9107
  };
9027
9108
  }
9109
+ const progressResources = parsedResources.data.filter((r) => {
9110
+ return COUNTABLE_MODULE_RESOURCE_TYPES.includes(r.type);
9111
+ });
9112
+ const totalLessonsCount = progressResources.length;
9028
9113
  const user = await client.query.users.findFirst({
9029
9114
  where: or(eq(users.id, userIdOrEmail), eq(users.email, userIdOrEmail)),
9030
9115
  with: {
9031
- roles: true
9116
+ roles: {
9117
+ with: {
9118
+ role: true
9119
+ }
9120
+ }
9121
+ }
9122
+ }).then(async (res) => {
9123
+ if (res) {
9124
+ return {
9125
+ ...res,
9126
+ roles: res.roles.map((r) => r.role)
9127
+ };
9032
9128
  }
9033
9129
  });
9034
9130
  if (!user) {
@@ -9038,15 +9134,27 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9038
9134
  nextResource: null,
9039
9135
  percentCompleted: 0,
9040
9136
  completedLessonsCount: 0,
9041
- totalLessonsCount: parsedModuleResources.data.length
9137
+ totalLessonsCount
9138
+ };
9139
+ }
9140
+ const parsedUser = userSchema.safeParse(user);
9141
+ if (!parsedUser.success) {
9142
+ console.error("Error parsing user", parsedUser.error);
9143
+ return {
9144
+ completedLessons: [],
9145
+ nextResource: null,
9146
+ percentCompleted: 0,
9147
+ completedLessonsCount: 0,
9148
+ totalLessonsCount
9042
9149
  };
9043
9150
  }
9044
- const parsedUser = userSchema.parse(user);
9045
9151
  const userProgress = await client.query.resourceProgress.findMany({
9046
- where: and(eq(resourceProgress.userId, parsedUser.id), isNotNull(resourceProgress.completedAt), inArray(resourceProgress.contentResourceId, parsedModuleResources.data.map((r) => r.resourceId))),
9152
+ where: and(eq(resourceProgress.userId, parsedUser.data.id), isNotNull(resourceProgress.completedAt), inArray(resourceProgress.resourceId, progressResources.map((r) => r.id))),
9047
9153
  orderBy: asc(resourceProgress.completedAt)
9048
9154
  });
9049
- const nextResourceId = moduleResources.find((r) => !userProgress.find((p) => p.contentResourceId === r.resourceId))?.resourceId;
9155
+ const nextResourceId = parsedResources.data.filter((r) => {
9156
+ return COUNTABLE_MODULE_RESOURCE_TYPES.includes(r.type);
9157
+ }).find((r) => !userProgress.find((p) => p.resourceId === r.id))?.id;
9050
9158
  const nextResource = await client.query.contentResource.findFirst({
9051
9159
  where: eq(contentResource.id, nextResourceId)
9052
9160
  });
@@ -9059,16 +9167,16 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9059
9167
  nextResource: null,
9060
9168
  percentCompleted: 0,
9061
9169
  completedLessonsCount: 0,
9062
- totalLessonsCount: parsedModuleResources.data.length
9170
+ totalLessonsCount
9063
9171
  };
9064
9172
  }
9065
- const percentCompleted = Math.round(parsedProgress.data.length / parsedModuleResources.data.length * 100);
9173
+ const percentCompleted = Math.round(parsedProgress.data.length / parsedResources.data.length * 100);
9066
9174
  return {
9067
9175
  completedLessons: parsedProgress.data,
9068
9176
  nextResource: parsedNextResource,
9069
9177
  percentCompleted,
9070
9178
  completedLessonsCount: parsedProgress.data.length,
9071
- totalLessonsCount: parsedModuleResources.data.length
9179
+ totalLessonsCount
9072
9180
  };
9073
9181
  },
9074
9182
  getLessonProgresses() {
@@ -9128,6 +9236,14 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9128
9236
  where: eq(products.id, productId)
9129
9237
  }));
9130
9238
  },
9239
+ async getPurchaseCountForProduct(productId) {
9240
+ return await client.query.purchases.findMany({
9241
+ where: and(eq(purchaseTable.productId, productId), inArray(purchaseTable.status, [
9242
+ "Valid",
9243
+ "Restricted"
9244
+ ]))
9245
+ }).then((res) => res.length);
9246
+ },
9131
9247
  async getPurchase(purchaseId) {
9132
9248
  const purchase = await client.query.purchases.findFirst({
9133
9249
  where: eq(purchaseTable.id, purchaseId)
@@ -9333,24 +9449,24 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9333
9449
  throw new Error("No lessonId provided");
9334
9450
  }
9335
9451
  let lessonProgress = await client.query.resourceProgress.findFirst({
9336
- where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.contentResourceId, options.lessonId))
9452
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
9337
9453
  });
9338
9454
  const now = /* @__PURE__ */ new Date();
9339
9455
  if (lessonProgress) {
9340
9456
  await client.update(resourceProgress).set({
9341
9457
  completedAt: lessonProgress.completedAt ? null : now,
9342
9458
  updatedAt: now
9343
- }).where(eq(resourceProgress.contentResourceId, options.lessonId));
9459
+ }).where(eq(resourceProgress.resourceId, options.lessonId));
9344
9460
  } else {
9345
9461
  await client.insert(resourceProgress).values({
9346
9462
  userId: options.userId,
9347
- contentResourceId: options.lessonId,
9463
+ resourceId: options.lessonId,
9348
9464
  completedAt: now,
9349
9465
  updatedAt: now
9350
9466
  });
9351
9467
  }
9352
9468
  lessonProgress = await client.query.resourceProgress.findFirst({
9353
- where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.contentResourceId, options.lessonId))
9469
+ where: and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId))
9354
9470
  });
9355
9471
  const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
9356
9472
  if (!parsedLessonProgress.success) {
@@ -9510,7 +9626,15 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9510
9626
  with: {
9511
9627
  resources: {
9512
9628
  with: {
9513
- resource: true
9629
+ resource: {
9630
+ with: {
9631
+ resources: {
9632
+ with: {
9633
+ resource: true
9634
+ }
9635
+ }
9636
+ }
9637
+ }
9514
9638
  },
9515
9639
  orderBy: asc(contentResourceResource.position)
9516
9640
  }
@@ -9576,7 +9700,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
9576
9700
  if (!dbAccount) {
9577
9701
  return null;
9578
9702
  }
9579
- return dbAccount.user;
9703
+ return dbAccount.User;
9580
9704
  },
9581
9705
  async deleteSession(sessionToken) {
9582
9706
  const session = await client.select().from(sessions).where(eq(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
@@ -9628,4 +9752,4 @@ export {
9628
9752
  createTables,
9629
9753
  mySqlDrizzleAdapter
9630
9754
  };
9631
- //# sourceMappingURL=chunk-J63FMGT7.js.map
9755
+ //# sourceMappingURL=chunk-Z245DYMP.js.map