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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/dist/{chunk-KIQLUFJX.js → chunk-2GW3BJE2.js} +2 -2
  2. package/dist/{chunk-M3WM5Q7W.js → chunk-33ZN7FN7.js} +2 -2
  3. package/dist/chunk-4VZJQAPV.js +74 -0
  4. package/dist/chunk-5FLS4ZBX.js +109 -0
  5. package/dist/chunk-5YR5M22S.js +147 -0
  6. package/dist/chunk-6XQ6C3IX.js +18 -0
  7. package/dist/chunk-AIDM2CH6.js +146 -0
  8. package/dist/chunk-ALTODDUX.js +173 -0
  9. package/dist/chunk-AZY2VRAE.js +63 -0
  10. package/dist/chunk-BS7T27VL.js +239 -0
  11. package/dist/chunk-CN3FCRLR.js +55 -0
  12. package/dist/chunk-EAXC4CQD.js +245 -0
  13. package/dist/chunk-EDDG2YFS.js +249 -0
  14. package/dist/chunk-EDKWCMA7.js +210 -0
  15. package/dist/{chunk-CFSRMUNC.js → chunk-EDM6DKA5.js} +2 -2
  16. package/dist/{chunk-EZEQQJNH.js → chunk-EIQBTF5J.js} +2 -2
  17. package/dist/chunk-FYT7RTVW.js +248 -0
  18. package/dist/{chunk-DUFH5L2F.js → chunk-INZTF6QV.js} +2 -2
  19. package/dist/{chunk-3AF6MZQ7.js → chunk-JVHX4JHA.js} +2 -2
  20. package/dist/chunk-LWEKWDLC.js +300 -0
  21. package/dist/chunk-OJPEBGGE.js +139 -0
  22. package/dist/chunk-QKOSV34V.js +16268 -0
  23. package/dist/chunk-QO3QE3LE.js +330 -0
  24. package/dist/chunk-QQKNNFFB.js +399 -0
  25. package/dist/chunk-RBHCV3UW.js +20 -0
  26. package/dist/chunk-TNH2C27F.js +252 -0
  27. package/dist/chunk-TNWNW666.js +133 -0
  28. package/dist/chunk-VBEXYQ6L.js +156 -0
  29. package/dist/chunk-W3ILNMLD.js +265 -0
  30. package/dist/chunk-WJ2ZUXL3.js +71 -0
  31. package/dist/{chunk-4SWTV7Z3.js → chunk-WUMDFFN3.js} +2 -2
  32. package/dist/{chunk-FJGNLVE4.js → chunk-X7DRYXB7.js} +2 -2
  33. package/dist/{chunk-PNPTKVJ4.js → chunk-XUBZKYH6.js} +24 -15
  34. package/dist/{chunk-MYG6PCE3.js → chunk-ZY4AFKUQ.js} +2 -2
  35. package/dist/index.d.ts +5 -11
  36. package/dist/index.js +42 -19
  37. package/dist/lib/mysql/cms-resource-actions.cjs +15932 -4129
  38. package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -1
  39. package/dist/lib/mysql/cms-resource-actions.d.cts +10 -25
  40. package/dist/lib/mysql/cms-resource-actions.d.ts +10 -25
  41. package/dist/lib/mysql/cms-resource-actions.js +2 -1
  42. package/dist/lib/mysql/context.cjs +3380 -0
  43. package/dist/lib/mysql/context.cjs.map +1 -0
  44. package/dist/lib/mysql/context.d.cts +15 -0
  45. package/dist/lib/mysql/context.d.ts +15 -0
  46. package/dist/lib/mysql/context.js +34 -0
  47. package/dist/lib/mysql/context.js.map +1 -0
  48. package/dist/lib/mysql/index.cjs +21648 -15013
  49. package/dist/lib/mysql/index.cjs.map +1 -1
  50. package/dist/lib/mysql/index.d.cts +24 -14300
  51. package/dist/lib/mysql/index.d.ts +24 -14300
  52. package/dist/lib/mysql/index.js +47 -23
  53. package/dist/lib/mysql/ports/auth-storage.cjs +84 -0
  54. package/dist/lib/mysql/ports/auth-storage.cjs.map +1 -0
  55. package/dist/lib/mysql/ports/auth-storage.d.cts +22 -0
  56. package/dist/lib/mysql/ports/auth-storage.d.ts +22 -0
  57. package/dist/lib/mysql/ports/auth-storage.js +8 -0
  58. package/dist/lib/mysql/ports/auth-storage.js.map +1 -0
  59. package/dist/lib/mysql/ports/catalog.cjs +16688 -0
  60. package/dist/lib/mysql/ports/catalog.cjs.map +1 -0
  61. package/dist/lib/mysql/ports/catalog.d.cts +24 -0
  62. package/dist/lib/mysql/ports/catalog.d.ts +24 -0
  63. package/dist/lib/mysql/ports/catalog.js +9 -0
  64. package/dist/lib/mysql/ports/catalog.js.map +1 -0
  65. package/dist/lib/mysql/ports/content-resource.cjs +321 -0
  66. package/dist/lib/mysql/ports/content-resource.cjs.map +1 -0
  67. package/dist/lib/mysql/ports/content-resource.d.cts +23 -0
  68. package/dist/lib/mysql/ports/content-resource.d.ts +23 -0
  69. package/dist/lib/mysql/ports/content-resource.js +8 -0
  70. package/dist/lib/mysql/ports/content-resource.js.map +1 -0
  71. package/dist/lib/mysql/ports/coupon.cjs +16524 -0
  72. package/dist/lib/mysql/ports/coupon.cjs.map +1 -0
  73. package/dist/lib/mysql/ports/coupon.d.cts +22 -0
  74. package/dist/lib/mysql/ports/coupon.d.ts +22 -0
  75. package/dist/lib/mysql/ports/coupon.js +9 -0
  76. package/dist/lib/mysql/ports/coupon.js.map +1 -0
  77. package/dist/lib/mysql/ports/entitlement.cjs +16350 -0
  78. package/dist/lib/mysql/ports/entitlement.cjs.map +1 -0
  79. package/dist/lib/mysql/ports/entitlement.d.cts +22 -0
  80. package/dist/lib/mysql/ports/entitlement.d.ts +22 -0
  81. package/dist/lib/mysql/ports/entitlement.js +9 -0
  82. package/dist/lib/mysql/ports/entitlement.js.map +1 -0
  83. package/dist/lib/mysql/ports/identity.cjs +154 -0
  84. package/dist/lib/mysql/ports/identity.cjs.map +1 -0
  85. package/dist/lib/mysql/ports/identity.d.cts +22 -0
  86. package/dist/lib/mysql/ports/identity.d.ts +22 -0
  87. package/dist/lib/mysql/ports/identity.js +8 -0
  88. package/dist/lib/mysql/ports/identity.js.map +1 -0
  89. package/dist/lib/mysql/ports/merchant.cjs +194 -0
  90. package/dist/lib/mysql/ports/merchant.cjs.map +1 -0
  91. package/dist/lib/mysql/ports/merchant.d.cts +22 -0
  92. package/dist/lib/mysql/ports/merchant.d.ts +22 -0
  93. package/dist/lib/mysql/ports/merchant.js +8 -0
  94. package/dist/lib/mysql/ports/merchant.js.map +1 -0
  95. package/dist/lib/mysql/ports/organization.cjs +16426 -0
  96. package/dist/lib/mysql/ports/organization.cjs.map +1 -0
  97. package/dist/lib/mysql/ports/organization.d.cts +22 -0
  98. package/dist/lib/mysql/ports/organization.d.ts +22 -0
  99. package/dist/lib/mysql/ports/organization.js +9 -0
  100. package/dist/lib/mysql/ports/organization.js.map +1 -0
  101. package/dist/lib/mysql/ports/progress.cjs +16544 -0
  102. package/dist/lib/mysql/ports/progress.cjs.map +1 -0
  103. package/dist/lib/mysql/ports/progress.d.cts +22 -0
  104. package/dist/lib/mysql/ports/progress.d.ts +22 -0
  105. package/dist/lib/mysql/ports/progress.js +9 -0
  106. package/dist/lib/mysql/ports/progress.js.map +1 -0
  107. package/dist/lib/mysql/ports/purchase.cjs +16609 -0
  108. package/dist/lib/mysql/ports/purchase.cjs.map +1 -0
  109. package/dist/lib/mysql/ports/purchase.d.cts +23 -0
  110. package/dist/lib/mysql/ports/purchase.d.ts +23 -0
  111. package/dist/lib/mysql/ports/purchase.js +9 -0
  112. package/dist/lib/mysql/ports/purchase.js.map +1 -0
  113. package/dist/lib/mysql/ports/subscription.cjs +76 -0
  114. package/dist/lib/mysql/ports/subscription.cjs.map +1 -0
  115. package/dist/lib/mysql/ports/subscription.d.cts +22 -0
  116. package/dist/lib/mysql/ports/subscription.d.ts +22 -0
  117. package/dist/lib/mysql/ports/subscription.js +8 -0
  118. package/dist/lib/mysql/ports/subscription.js.map +1 -0
  119. package/dist/lib/mysql/schema.cjs +3373 -0
  120. package/dist/lib/mysql/schema.cjs.map +1 -0
  121. package/dist/lib/mysql/schema.d.cts +14385 -0
  122. package/dist/lib/mysql/schema.d.ts +14385 -0
  123. package/dist/lib/mysql/schema.js +35 -0
  124. package/dist/lib/mysql/schema.js.map +1 -0
  125. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  126. package/dist/lib/mysql/schemas/auth/accounts.js +6 -6
  127. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  128. package/dist/lib/mysql/schemas/auth/device-access-token.js +7 -7
  129. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  130. package/dist/lib/mysql/schemas/auth/device-verification.js +7 -7
  131. package/dist/lib/mysql/schemas/auth/personal-access-token.cjs.map +1 -1
  132. package/dist/lib/mysql/schemas/auth/personal-access-token.js +7 -7
  133. package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
  134. package/dist/lib/mysql/schemas/auth/profiles.js +6 -6
  135. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  136. package/dist/lib/mysql/schemas/auth/role-permissions.js +7 -7
  137. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  138. package/dist/lib/mysql/schemas/auth/roles.js +6 -6
  139. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  140. package/dist/lib/mysql/schemas/auth/sessions.js +7 -7
  141. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  142. package/dist/lib/mysql/schemas/auth/user-permissions.js +6 -6
  143. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  144. package/dist/lib/mysql/schemas/auth/user-prefs.js +6 -6
  145. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  146. package/dist/lib/mysql/schemas/auth/user-roles.js +6 -6
  147. package/dist/lib/mysql/schemas/auth/users.cjs +5 -1
  148. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  149. package/dist/lib/mysql/schemas/auth/users.js +6 -6
  150. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  151. package/dist/lib/mysql/schemas/commerce/coupon.js +6 -6
  152. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  153. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +6 -6
  154. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
  155. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +6 -6
  156. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  157. package/dist/lib/mysql/schemas/commerce/price.js +6 -6
  158. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  159. package/dist/lib/mysql/schemas/commerce/product.js +6 -6
  160. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  161. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +7 -7
  162. package/dist/lib/mysql/schemas/commerce/purchase.cjs +11 -2
  163. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  164. package/dist/lib/mysql/schemas/commerce/purchase.js +6 -6
  165. package/dist/lib/mysql/schemas/commerce/subscription.cjs +6 -1
  166. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
  167. package/dist/lib/mysql/schemas/commerce/subscription.js +6 -6
  168. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  169. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +7 -7
  170. package/dist/lib/mysql/schemas/communication/comment.cjs +5 -1
  171. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  172. package/dist/lib/mysql/schemas/communication/comment.js +6 -6
  173. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +5 -1
  174. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  175. package/dist/lib/mysql/schemas/communication/communication-preferences.js +6 -6
  176. package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -1
  177. package/dist/lib/mysql/schemas/communication/question-response.js +7 -7
  178. package/dist/lib/mysql/schemas/content/content-contributions.cjs +5 -1
  179. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  180. package/dist/lib/mysql/schemas/content/content-contributions.js +6 -6
  181. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  182. package/dist/lib/mysql/schemas/content/content-resource-product.js +6 -6
  183. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  184. package/dist/lib/mysql/schemas/content/content-resource-resource.js +6 -6
  185. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  186. package/dist/lib/mysql/schemas/content/content-resource-tag.js +6 -6
  187. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  188. package/dist/lib/mysql/schemas/content/content-resource-version.js +6 -6
  189. package/dist/lib/mysql/schemas/content/content-resource.cjs +5 -1
  190. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  191. package/dist/lib/mysql/schemas/content/content-resource.js +6 -6
  192. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  193. package/dist/lib/mysql/schemas/content/tag-tag.js +6 -6
  194. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  195. package/dist/lib/mysql/schemas/content/tag.js +6 -6
  196. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +11 -2
  197. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
  198. package/dist/lib/mysql/schemas/entitlements/entitlement.js +7 -7
  199. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +11 -2
  200. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
  201. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +6 -6
  202. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +11 -2
  203. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
  204. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +16 -0
  205. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +16 -0
  206. package/dist/lib/mysql/schemas/org/organization-memberships.js +6 -6
  207. package/dist/lib/mysql/schemas/org/organizations.cjs +11 -2
  208. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
  209. package/dist/lib/mysql/schemas/org/organizations.d.cts +16 -0
  210. package/dist/lib/mysql/schemas/org/organizations.d.ts +16 -0
  211. package/dist/lib/mysql/schemas/org/organizations.js +6 -6
  212. package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs +40 -0
  213. package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs.map +1 -0
  214. package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.cts +4 -0
  215. package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.ts +4 -0
  216. package/dist/lib/mysql/workflows/content-resource-workflow-utils.js +10 -0
  217. package/dist/lib/mysql/workflows/content-resource-workflow-utils.js.map +1 -0
  218. package/dist/lib/mysql/workflows/create-cohort.cjs +184 -0
  219. package/dist/lib/mysql/workflows/create-cohort.cjs.map +1 -0
  220. package/dist/lib/mysql/workflows/create-cohort.d.cts +24 -0
  221. package/dist/lib/mysql/workflows/create-cohort.d.ts +24 -0
  222. package/dist/lib/mysql/workflows/create-cohort.js +9 -0
  223. package/dist/lib/mysql/workflows/create-cohort.js.map +1 -0
  224. package/dist/lib/mysql/workflows/create-event-series.cjs +283 -0
  225. package/dist/lib/mysql/workflows/create-event-series.cjs.map +1 -0
  226. package/dist/lib/mysql/workflows/create-event-series.d.cts +24 -0
  227. package/dist/lib/mysql/workflows/create-event-series.d.ts +24 -0
  228. package/dist/lib/mysql/workflows/create-event-series.js +9 -0
  229. package/dist/lib/mysql/workflows/create-event-series.js.map +1 -0
  230. package/dist/lib/mysql/workflows/create-event.cjs +194 -0
  231. package/dist/lib/mysql/workflows/create-event.cjs.map +1 -0
  232. package/dist/lib/mysql/workflows/create-event.d.cts +24 -0
  233. package/dist/lib/mysql/workflows/create-event.d.ts +24 -0
  234. package/dist/lib/mysql/workflows/create-event.js +9 -0
  235. package/dist/lib/mysql/workflows/create-event.js.map +1 -0
  236. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs +231 -0
  237. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs.map +1 -0
  238. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.cts +22 -0
  239. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.ts +22 -0
  240. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js +8 -0
  241. package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js.map +1 -0
  242. package/dist/lib/mysql/workflows/create-workshop.cjs +286 -0
  243. package/dist/lib/mysql/workflows/create-workshop.cjs.map +1 -0
  244. package/dist/lib/mysql/workflows/create-workshop.d.cts +24 -0
  245. package/dist/lib/mysql/workflows/create-workshop.d.ts +24 -0
  246. package/dist/lib/mysql/workflows/create-workshop.js +9 -0
  247. package/dist/lib/mysql/workflows/create-workshop.js.map +1 -0
  248. package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs +130 -0
  249. package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs.map +1 -0
  250. package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.cts +24 -0
  251. package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.ts +24 -0
  252. package/dist/lib/mysql/workflows/redeem-full-price-coupon.js +8 -0
  253. package/dist/lib/mysql/workflows/redeem-full-price-coupon.js.map +1 -0
  254. package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs +95 -0
  255. package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs.map +1 -0
  256. package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.cts +30 -0
  257. package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.ts +30 -0
  258. package/dist/lib/mysql/workflows/transfer-purchase-to-user.js +8 -0
  259. package/dist/lib/mysql/workflows/transfer-purchase-to-user.js.map +1 -0
  260. package/dist/lib/utils.d.cts +1 -10
  261. package/dist/lib/utils.d.ts +1 -10
  262. package/dist/types.d.ts +14 -0
  263. package/dist/types.js +1 -0
  264. package/package.json +9 -5
  265. package/src/index.ts +3 -2
  266. package/src/lib/mysql/cms-resource-actions.ts +37 -0
  267. package/src/lib/mysql/context.ts +20 -0
  268. package/src/lib/mysql/index.ts +118 -4872
  269. package/src/lib/mysql/ports/auth-storage.ts +139 -0
  270. package/src/lib/mysql/ports/catalog.ts +610 -0
  271. package/src/lib/mysql/ports/content-resource.ts +442 -0
  272. package/src/lib/mysql/ports/coupon.ts +387 -0
  273. package/src/lib/mysql/ports/entitlement.ts +96 -0
  274. package/src/lib/mysql/ports/identity.ts +160 -0
  275. package/src/lib/mysql/ports/merchant.ts +274 -0
  276. package/src/lib/mysql/ports/organization.ts +216 -0
  277. package/src/lib/mysql/ports/progress.ts +366 -0
  278. package/src/lib/mysql/ports/purchase.ts +517 -0
  279. package/src/lib/mysql/ports/subscription.ts +93 -0
  280. package/src/lib/mysql/schema.ts +374 -0
  281. package/src/lib/mysql/schemas/org/organization-memberships.ts +7 -0
  282. package/src/lib/mysql/schemas/org/organizations.ts +8 -0
  283. package/src/lib/mysql/workflows/content-resource-workflow-utils.ts +22 -0
  284. package/src/lib/mysql/workflows/create-cohort.ts +239 -0
  285. package/src/lib/mysql/workflows/create-event-series.ts +384 -0
  286. package/src/lib/mysql/workflows/create-event.ts +232 -0
  287. package/src/lib/mysql/workflows/create-merchant-charge-and-purchase.ts +365 -0
  288. package/src/lib/mysql/workflows/create-workshop.ts +372 -0
  289. package/src/lib/mysql/workflows/redeem-full-price-coupon.ts +179 -0
  290. package/src/lib/mysql/workflows/transfer-purchase-to-user.ts +142 -0
  291. package/src/types.ts +33 -0
  292. package/dist/authjs.d.ts +0 -27
  293. package/dist/authjs.js +0 -1
  294. package/dist/chunk-25RKHMRM.js +0 -8729
  295. package/dist/chunk-2AW5KYAK.js +0 -101
  296. package/dist/chunk-3EF5ZXLG.js +0 -101
  297. package/dist/chunk-7FBSP3VD.js +0 -78
  298. package/dist/chunk-AP5HBIV4.js +0 -112
  299. package/dist/chunk-F56AI52P.js +0 -49
  300. package/dist/chunk-HAQZSRJL.js +0 -4696
  301. package/dist/chunk-I2U5PTWN.js +0 -79
  302. package/dist/chunk-IBQGXFEX.js +0 -8729
  303. package/dist/chunk-PJORQUQP.js +0 -58
  304. package/dist/chunk-W6RPAAKG.js +0 -2144
  305. package/dist/chunk-WKJTU24D.js +0 -88
  306. package/dist/chunk-WWBSNLRC.js +0 -63
  307. package/src/authjs.ts +0 -34
@@ -0,0 +1,3373 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/lib/mysql/schema.ts
22
+ var schema_exports = {};
23
+ __export(schema_exports, {
24
+ createTables: () => createTables,
25
+ getCourseBuilderSchema: () => getCourseBuilderSchema
26
+ });
27
+ module.exports = __toCommonJS(schema_exports);
28
+
29
+ // src/lib/mysql/schemas/auth/accounts.ts
30
+ var import_drizzle_orm33 = require("drizzle-orm");
31
+ var import_mysql_core37 = require("drizzle-orm/mysql-core");
32
+
33
+ // src/lib/mysql/schemas/auth/users.ts
34
+ var import_drizzle_orm32 = require("drizzle-orm");
35
+ var import_mysql_core36 = require("drizzle-orm/mysql-core");
36
+
37
+ // src/lib/mysql/schemas/commerce/purchase.ts
38
+ var import_drizzle_orm25 = require("drizzle-orm");
39
+ var import_mysql_core27 = require("drizzle-orm/mysql-core");
40
+
41
+ // src/lib/mysql/schemas/org/organization-memberships.ts
42
+ var import_drizzle_orm23 = require("drizzle-orm");
43
+ var import_mysql_core23 = require("drizzle-orm/mysql-core");
44
+
45
+ // src/lib/mysql/schemas/org/organization-membership-roles.ts
46
+ var import_drizzle_orm22 = require("drizzle-orm");
47
+ var import_mysql_core22 = require("drizzle-orm/mysql-core");
48
+
49
+ // src/lib/mysql/schemas/auth/roles.ts
50
+ var import_drizzle_orm2 = require("drizzle-orm");
51
+ var import_mysql_core2 = require("drizzle-orm/mysql-core");
52
+
53
+ // src/lib/mysql/schemas/auth/user-roles.ts
54
+ var import_drizzle_orm = require("drizzle-orm");
55
+ var import_mysql_core = require("drizzle-orm/mysql-core");
56
+ function getUserRolesSchema(mysqlTable) {
57
+ return mysqlTable("UserRole", {
58
+ userId: (0, import_mysql_core.varchar)("userId", {
59
+ length: 255
60
+ }).notNull(),
61
+ roleId: (0, import_mysql_core.varchar)("roleId", {
62
+ length: 255
63
+ }).notNull(),
64
+ active: (0, import_mysql_core.boolean)("active").notNull().default(true),
65
+ organizationId: (0, import_mysql_core.varchar)("organizationId", {
66
+ length: 191
67
+ }),
68
+ createdAt: (0, import_mysql_core.timestamp)("createdAt", {
69
+ mode: "date",
70
+ fsp: 3
71
+ }).defaultNow(),
72
+ updatedAt: (0, import_mysql_core.timestamp)("updatedAt", {
73
+ mode: "date",
74
+ fsp: 3
75
+ }).defaultNow(),
76
+ deletedAt: (0, import_mysql_core.timestamp)("deletedAt", {
77
+ mode: "date",
78
+ fsp: 3
79
+ })
80
+ }, (ur) => ({
81
+ pk: (0, import_mysql_core.primaryKey)({
82
+ columns: [
83
+ ur.userId,
84
+ ur.roleId
85
+ ]
86
+ }),
87
+ userIdIdx: (0, import_mysql_core.index)("userId_idx").on(ur.userId),
88
+ roleIdIdx: (0, import_mysql_core.index)("roleId_idx").on(ur.roleId),
89
+ organizationIdIdx: (0, import_mysql_core.index)("organizationId_idx").on(ur.organizationId)
90
+ }));
91
+ }
92
+ __name(getUserRolesSchema, "getUserRolesSchema");
93
+ function getUserRolesRelationsSchema(mysqlTable, overrides = {}) {
94
+ const userRoles = getUserRolesSchema(mysqlTable);
95
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
96
+ const users = resolveUsersSchema(mysqlTable);
97
+ const roles = getRolesSchema(mysqlTable);
98
+ return (0, import_drizzle_orm.relations)(userRoles, ({ one }) => ({
99
+ user: one(users, {
100
+ fields: [
101
+ userRoles.userId
102
+ ],
103
+ references: [
104
+ users.id
105
+ ],
106
+ relationName: "user"
107
+ }),
108
+ role: one(roles, {
109
+ fields: [
110
+ userRoles.roleId
111
+ ],
112
+ references: [
113
+ roles.id
114
+ ],
115
+ relationName: "role"
116
+ })
117
+ }));
118
+ }
119
+ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
120
+
121
+ // src/lib/mysql/schemas/auth/roles.ts
122
+ function getRolesSchema(mysqlTable) {
123
+ return mysqlTable("Role", {
124
+ id: (0, import_mysql_core2.varchar)("id", {
125
+ length: 255
126
+ }).notNull().primaryKey(),
127
+ organizationId: (0, import_mysql_core2.varchar)("organizationId", {
128
+ length: 191
129
+ }),
130
+ name: (0, import_mysql_core2.varchar)("name", {
131
+ length: 255
132
+ }).notNull(),
133
+ description: (0, import_mysql_core2.text)("description"),
134
+ active: (0, import_mysql_core2.boolean)("active").notNull().default(true),
135
+ createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
136
+ mode: "date",
137
+ fsp: 3
138
+ }).defaultNow(),
139
+ updatedAt: (0, import_mysql_core2.timestamp)("updatedAt", {
140
+ mode: "date",
141
+ fsp: 3
142
+ }).defaultNow(),
143
+ deletedAt: (0, import_mysql_core2.timestamp)("deletedAt", {
144
+ mode: "date",
145
+ fsp: 3
146
+ })
147
+ }, (role) => ({
148
+ nameIdx: (0, import_mysql_core2.index)("name_idx").on(role.name),
149
+ organizationIdIdx: (0, import_mysql_core2.index)("organizationId_idx").on(role.organizationId),
150
+ uniqueNamePerOrg: (0, import_mysql_core2.uniqueIndex)("unique_name_per_org").on(role.organizationId, role.name)
151
+ }));
152
+ }
153
+ __name(getRolesSchema, "getRolesSchema");
154
+ function getRolesRelationsSchema(mysqlTable) {
155
+ const roles = getRolesSchema(mysqlTable);
156
+ const userRoles = getUserRolesSchema(mysqlTable);
157
+ return (0, import_drizzle_orm2.relations)(roles, ({ many }) => ({
158
+ userRoles: many(userRoles, {
159
+ relationName: "role"
160
+ })
161
+ }));
162
+ }
163
+ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
164
+
165
+ // src/lib/mysql/schemas/org/organizations.ts
166
+ var import_drizzle_orm21 = require("drizzle-orm");
167
+ var import_mysql_core21 = require("drizzle-orm/mysql-core");
168
+
169
+ // src/lib/mysql/schemas/commerce/subscription.ts
170
+ var import_drizzle_orm20 = require("drizzle-orm");
171
+ var import_mysql_core20 = require("drizzle-orm/mysql-core");
172
+
173
+ // src/lib/mysql/schemas/commerce/merchant-subscription.ts
174
+ var import_drizzle_orm7 = require("drizzle-orm");
175
+ var import_mysql_core7 = require("drizzle-orm/mysql-core");
176
+
177
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
178
+ var import_drizzle_orm6 = require("drizzle-orm");
179
+ var import_mysql_core6 = require("drizzle-orm/mysql-core");
180
+
181
+ // src/lib/mysql/schemas/commerce/merchant-account.ts
182
+ var import_drizzle_orm3 = require("drizzle-orm");
183
+ var import_mysql_core3 = require("drizzle-orm/mysql-core");
184
+ function getMerchantAccountSchema(mysqlTable) {
185
+ return mysqlTable("MerchantAccount", {
186
+ id: (0, import_mysql_core3.varchar)("id", {
187
+ length: 191
188
+ }).notNull(),
189
+ organizationId: (0, import_mysql_core3.varchar)("organizationId", {
190
+ length: 191
191
+ }),
192
+ status: (0, import_mysql_core3.int)("status").default(0).notNull(),
193
+ createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
194
+ mode: "date",
195
+ fsp: 3
196
+ }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`).notNull(),
197
+ label: (0, import_mysql_core3.varchar)("label", {
198
+ length: 191
199
+ }),
200
+ identifier: (0, import_mysql_core3.varchar)("identifier", {
201
+ length: 191
202
+ })
203
+ }, (table) => {
204
+ return {
205
+ merchantAccountId: (0, import_mysql_core3.primaryKey)({
206
+ columns: [
207
+ table.id
208
+ ],
209
+ name: "MerchantAccount_id"
210
+ }),
211
+ organizationIdIdx: (0, import_mysql_core3.index)("organizationId_idx").on(table.organizationId)
212
+ };
213
+ });
214
+ }
215
+ __name(getMerchantAccountSchema, "getMerchantAccountSchema");
216
+
217
+ // src/lib/mysql/schemas/commerce/merchant-customer.ts
218
+ var import_drizzle_orm4 = require("drizzle-orm");
219
+ var import_mysql_core4 = require("drizzle-orm/mysql-core");
220
+ function getMerchantCustomerSchema(mysqlTable) {
221
+ return mysqlTable("MerchantCustomer", {
222
+ id: (0, import_mysql_core4.varchar)("id", {
223
+ length: 191
224
+ }).notNull(),
225
+ organizationId: (0, import_mysql_core4.varchar)("organizationId", {
226
+ length: 191
227
+ }),
228
+ userId: (0, import_mysql_core4.varchar)("userId", {
229
+ length: 191
230
+ }).notNull(),
231
+ merchantAccountId: (0, import_mysql_core4.varchar)("merchantAccountId", {
232
+ length: 191
233
+ }).notNull(),
234
+ identifier: (0, import_mysql_core4.varchar)("identifier", {
235
+ length: 191
236
+ }).notNull(),
237
+ createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
238
+ mode: "date",
239
+ fsp: 3
240
+ }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`).notNull(),
241
+ status: (0, import_mysql_core4.int)("status").default(0)
242
+ }, (table) => {
243
+ return {
244
+ merchantCustomerId: (0, import_mysql_core4.primaryKey)({
245
+ columns: [
246
+ table.id
247
+ ],
248
+ name: "MerchantCustomer_id"
249
+ }),
250
+ merchantCustomerIdentifierKey: (0, import_mysql_core4.unique)("MerchantCustomer_identifier_key").on(table.identifier),
251
+ userIdIdx: (0, import_mysql_core4.index)("idx_MerchantCustomer_on_userId").on(table.userId),
252
+ organizationIdIdx: (0, import_mysql_core4.index)("organizationId_idx").on(table.organizationId)
253
+ };
254
+ });
255
+ }
256
+ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
257
+
258
+ // src/lib/mysql/schemas/commerce/merchant-product.ts
259
+ var import_drizzle_orm5 = require("drizzle-orm");
260
+ var import_mysql_core5 = require("drizzle-orm/mysql-core");
261
+ function getMerchantProductSchema(mysqlTable) {
262
+ return mysqlTable("MerchantProduct", {
263
+ id: (0, import_mysql_core5.varchar)("id", {
264
+ length: 191
265
+ }).notNull(),
266
+ organizationId: (0, import_mysql_core5.varchar)("organizationId", {
267
+ length: 191
268
+ }),
269
+ merchantAccountId: (0, import_mysql_core5.varchar)("merchantAccountId", {
270
+ length: 191
271
+ }).notNull(),
272
+ productId: (0, import_mysql_core5.varchar)("productId", {
273
+ length: 191
274
+ }).notNull(),
275
+ status: (0, import_mysql_core5.int)("status").default(0).notNull(),
276
+ identifier: (0, import_mysql_core5.varchar)("identifier", {
277
+ length: 191
278
+ }),
279
+ createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
280
+ mode: "date",
281
+ fsp: 3
282
+ }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`).notNull()
283
+ }, (table) => {
284
+ return {
285
+ merchantProductId: (0, import_mysql_core5.primaryKey)({
286
+ columns: [
287
+ table.id
288
+ ],
289
+ name: "MerchantProduct_id"
290
+ }),
291
+ merchantProductIdentifierKey: (0, import_mysql_core5.unique)("MerchantProduct_identifier_key").on(table.identifier),
292
+ organizationIdIdx: (0, import_mysql_core5.index)("organizationId_idx").on(table.organizationId)
293
+ };
294
+ });
295
+ }
296
+ __name(getMerchantProductSchema, "getMerchantProductSchema");
297
+
298
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
299
+ function getMerchantChargeSchema(mysqlTable) {
300
+ return mysqlTable("MerchantCharge", {
301
+ id: (0, import_mysql_core6.varchar)("id", {
302
+ length: 191
303
+ }).notNull(),
304
+ organizationId: (0, import_mysql_core6.varchar)("organizationId", {
305
+ length: 191
306
+ }),
307
+ status: (0, import_mysql_core6.int)("status").default(0).notNull(),
308
+ identifier: (0, import_mysql_core6.varchar)("identifier", {
309
+ length: 191
310
+ }).notNull(),
311
+ userId: (0, import_mysql_core6.varchar)("userId", {
312
+ length: 191
313
+ }).notNull(),
314
+ merchantAccountId: (0, import_mysql_core6.varchar)("merchantAccountId", {
315
+ length: 191
316
+ }).notNull(),
317
+ merchantProductId: (0, import_mysql_core6.varchar)("merchantProductId", {
318
+ length: 191
319
+ }).notNull(),
320
+ merchantSubscriptionId: (0, import_mysql_core6.varchar)("merchantSubscriptionId", {
321
+ length: 191
322
+ }),
323
+ createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
324
+ mode: "date",
325
+ fsp: 3
326
+ }).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull(),
327
+ merchantCustomerId: (0, import_mysql_core6.varchar)("merchantCustomerId", {
328
+ length: 191
329
+ }).notNull()
330
+ }, (table) => {
331
+ return {
332
+ merchantChargeId: (0, import_mysql_core6.primaryKey)({
333
+ columns: [
334
+ table.id
335
+ ],
336
+ name: "MerchantCharge_id"
337
+ }),
338
+ merchantChargeIdentifierKey: (0, import_mysql_core6.unique)("MerchantCharge_identifier_key").on(table.identifier),
339
+ merchantSubscriptionIdIdx: (0, import_mysql_core6.index)("merchantSubscriptionId_idx").on(table.merchantSubscriptionId),
340
+ organizationIdIdx: (0, import_mysql_core6.index)("organizationId_idx").on(table.organizationId)
341
+ };
342
+ });
343
+ }
344
+ __name(getMerchantChargeSchema, "getMerchantChargeSchema");
345
+ function getMerchantChargeRelationsSchema(mysqlTable) {
346
+ const merchantCharge = getMerchantChargeSchema(mysqlTable);
347
+ const merchantAccount = getMerchantAccountSchema(mysqlTable);
348
+ const merchantProduct = getMerchantProductSchema(mysqlTable);
349
+ const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
350
+ const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
351
+ return (0, import_drizzle_orm6.relations)(merchantCharge, ({ one }) => ({
352
+ merchantAccount: one(merchantAccount, {
353
+ fields: [
354
+ merchantCharge.merchantAccountId
355
+ ],
356
+ references: [
357
+ merchantAccount.id
358
+ ],
359
+ relationName: "merchantAccount"
360
+ }),
361
+ merchantProduct: one(merchantProduct, {
362
+ fields: [
363
+ merchantCharge.merchantProductId
364
+ ],
365
+ references: [
366
+ merchantProduct.id
367
+ ],
368
+ relationName: "merchantProduct"
369
+ }),
370
+ merchantCustomer: one(merchantCustomer, {
371
+ fields: [
372
+ merchantCharge.merchantCustomerId
373
+ ],
374
+ references: [
375
+ merchantCustomer.id
376
+ ],
377
+ relationName: "merchantCustomer"
378
+ }),
379
+ merchantSubscription: one(merchantSubscription, {
380
+ fields: [
381
+ merchantCharge.merchantSubscriptionId
382
+ ],
383
+ references: [
384
+ merchantSubscription.id
385
+ ],
386
+ relationName: "merchantSubscription"
387
+ })
388
+ }));
389
+ }
390
+ __name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
391
+
392
+ // src/lib/mysql/schemas/commerce/merchant-subscription.ts
393
+ function getMerchantSubscriptionSchema(mysqlTable) {
394
+ return mysqlTable("MerchantSubscription", {
395
+ id: (0, import_mysql_core7.varchar)("id", {
396
+ length: 191
397
+ }).notNull(),
398
+ organizationId: (0, import_mysql_core7.varchar)("organizationId", {
399
+ length: 191
400
+ }),
401
+ merchantAccountId: (0, import_mysql_core7.varchar)("merchantAccountId", {
402
+ length: 191
403
+ }).notNull(),
404
+ status: (0, import_mysql_core7.int)("status").default(0).notNull(),
405
+ createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
406
+ mode: "date",
407
+ fsp: 3
408
+ }).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
409
+ label: (0, import_mysql_core7.varchar)("label", {
410
+ length: 191
411
+ }),
412
+ identifier: (0, import_mysql_core7.varchar)("identifier", {
413
+ length: 191
414
+ }),
415
+ merchantCustomerId: (0, import_mysql_core7.varchar)("merchantCustomerId", {
416
+ length: 191
417
+ }).notNull(),
418
+ merchantProductId: (0, import_mysql_core7.varchar)("merchantProductId", {
419
+ length: 191
420
+ }).notNull()
421
+ }, (table) => {
422
+ return {
423
+ merchantSubscriptionId: (0, import_mysql_core7.primaryKey)({
424
+ columns: [
425
+ table.id
426
+ ],
427
+ name: "MerchantSubscription_id"
428
+ }),
429
+ organizationIdIdx: (0, import_mysql_core7.index)("organizationId_idx").on(table.organizationId)
430
+ };
431
+ });
432
+ }
433
+ __name(getMerchantSubscriptionSchema, "getMerchantSubscriptionSchema");
434
+ function getMerchantSubscriptionRelationsSchema(mysqlTable) {
435
+ const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
436
+ const merchantCharge = getMerchantChargeSchema(mysqlTable);
437
+ const subscription = getSubscriptionSchema(mysqlTable);
438
+ return (0, import_drizzle_orm7.relations)(merchantSubscription, ({ many, one }) => ({
439
+ merchantCharges: many(merchantCharge, {
440
+ relationName: "merchantSubscription"
441
+ }),
442
+ subscription: one(subscription, {
443
+ fields: [
444
+ merchantSubscription.id
445
+ ],
446
+ references: [
447
+ subscription.merchantSubscriptionId
448
+ ],
449
+ relationName: "subscription"
450
+ })
451
+ }));
452
+ }
453
+ __name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
454
+
455
+ // src/lib/mysql/schemas/commerce/product.ts
456
+ var import_drizzle_orm19 = require("drizzle-orm");
457
+ var import_mysql_core19 = require("drizzle-orm/mysql-core");
458
+
459
+ // src/lib/mysql/schemas/content/content-resource-product.ts
460
+ var import_drizzle_orm16 = require("drizzle-orm");
461
+ var import_mysql_core16 = require("drizzle-orm/mysql-core");
462
+
463
+ // src/lib/mysql/schemas/content/content-resource.ts
464
+ var import_drizzle_orm15 = require("drizzle-orm");
465
+ var import_mysql_core15 = require("drizzle-orm/mysql-core");
466
+
467
+ // src/lib/mysql/schemas/content/content-contributions.ts
468
+ var import_drizzle_orm9 = require("drizzle-orm");
469
+ var import_mysql_core9 = require("drizzle-orm/mysql-core");
470
+
471
+ // src/lib/mysql/schemas/content/contribution-types.ts
472
+ var import_drizzle_orm8 = require("drizzle-orm");
473
+ var import_mysql_core8 = require("drizzle-orm/mysql-core");
474
+ function getContributionTypesSchema(mysqlTable) {
475
+ return mysqlTable("ContributionType", {
476
+ id: (0, import_mysql_core8.varchar)("id", {
477
+ length: 255
478
+ }).notNull().primaryKey(),
479
+ organizationId: (0, import_mysql_core8.varchar)("organizationId", {
480
+ length: 191
481
+ }),
482
+ slug: (0, import_mysql_core8.varchar)("slug", {
483
+ length: 255
484
+ }).notNull().unique(),
485
+ name: (0, import_mysql_core8.varchar)("name", {
486
+ length: 255
487
+ }).notNull(),
488
+ description: (0, import_mysql_core8.text)("description"),
489
+ active: (0, import_mysql_core8.boolean)("active").notNull().default(true),
490
+ createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
491
+ mode: "date",
492
+ fsp: 3
493
+ }).defaultNow(),
494
+ updatedAt: (0, import_mysql_core8.timestamp)("updatedAt", {
495
+ mode: "date",
496
+ fsp: 3
497
+ }).defaultNow(),
498
+ deletedAt: (0, import_mysql_core8.timestamp)("deletedAt", {
499
+ mode: "date",
500
+ fsp: 3
501
+ })
502
+ }, (ct) => ({
503
+ nameIdx: (0, import_mysql_core8.index)("name_idx").on(ct.name),
504
+ slugIdx: (0, import_mysql_core8.index)("slug_idx").on(ct.slug),
505
+ organizationIdIdx: (0, import_mysql_core8.index)("organizationId_idx").on(ct.organizationId)
506
+ }));
507
+ }
508
+ __name(getContributionTypesSchema, "getContributionTypesSchema");
509
+ function getContributionTypesRelationsSchema(mysqlTable) {
510
+ const contributionTypes = getContributionTypesSchema(mysqlTable);
511
+ return (0, import_drizzle_orm8.relations)(contributionTypes, ({ many }) => ({}));
512
+ }
513
+ __name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
514
+
515
+ // src/lib/mysql/schemas/content/content-contributions.ts
516
+ function getContentContributionsSchema(mysqlTable) {
517
+ return mysqlTable("ContentContribution", {
518
+ id: (0, import_mysql_core9.varchar)("id", {
519
+ length: 255
520
+ }).notNull().primaryKey(),
521
+ userId: (0, import_mysql_core9.varchar)("userId", {
522
+ length: 255
523
+ }).notNull(),
524
+ organizationId: (0, import_mysql_core9.varchar)("organizationId", {
525
+ length: 191
526
+ }),
527
+ organizationMembershipId: (0, import_mysql_core9.varchar)("organizationMembershipId", {
528
+ length: 255
529
+ }),
530
+ contentId: (0, import_mysql_core9.varchar)("contentId", {
531
+ length: 255
532
+ }).notNull(),
533
+ contributionTypeId: (0, import_mysql_core9.varchar)("contributionTypeId", {
534
+ length: 255
535
+ }).notNull(),
536
+ active: (0, import_mysql_core9.boolean)("active").notNull().default(true),
537
+ createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
538
+ mode: "date",
539
+ fsp: 3
540
+ }).defaultNow(),
541
+ updatedAt: (0, import_mysql_core9.timestamp)("updatedAt", {
542
+ mode: "date",
543
+ fsp: 3
544
+ }).defaultNow(),
545
+ deletedAt: (0, import_mysql_core9.timestamp)("deletedAt", {
546
+ mode: "date",
547
+ fsp: 3
548
+ })
549
+ }, (cc) => ({
550
+ userIdIdx: (0, import_mysql_core9.index)("userId_idx").on(cc.userId),
551
+ contentIdIdx: (0, import_mysql_core9.index)("contentId_idx").on(cc.contentId),
552
+ contributionTypeIdIdx: (0, import_mysql_core9.index)("contributionTypeId_idx").on(cc.contributionTypeId),
553
+ organizationMembershipIdIdx: (0, import_mysql_core9.index)("organizationMembershipId_idx").on(cc.organizationMembershipId)
554
+ }));
555
+ }
556
+ __name(getContentContributionsSchema, "getContentContributionsSchema");
557
+ function getContentContributionRelationsSchema(mysqlTable, overrides = {}) {
558
+ const contentContributions = getContentContributionsSchema(mysqlTable);
559
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
560
+ const users = resolveUsersSchema(mysqlTable);
561
+ const contentResource = getContentResourceSchema(mysqlTable);
562
+ const contributionTypes = getContributionTypesSchema(mysqlTable);
563
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
564
+ return (0, import_drizzle_orm9.relations)(contentContributions, ({ one }) => ({
565
+ user: one(users, {
566
+ fields: [
567
+ contentContributions.userId
568
+ ],
569
+ references: [
570
+ users.id
571
+ ],
572
+ relationName: "user"
573
+ }),
574
+ content: one(contentResource, {
575
+ fields: [
576
+ contentContributions.contentId
577
+ ],
578
+ references: [
579
+ contentResource.id
580
+ ],
581
+ relationName: "contributions"
582
+ }),
583
+ contributionType: one(contributionTypes, {
584
+ fields: [
585
+ contentContributions.contributionTypeId
586
+ ],
587
+ references: [
588
+ contributionTypes.id
589
+ ],
590
+ relationName: "contributionType"
591
+ }),
592
+ organizationMembership: one(organizationMemberships, {
593
+ fields: [
594
+ contentContributions.organizationMembershipId
595
+ ],
596
+ references: [
597
+ organizationMemberships.id
598
+ ],
599
+ relationName: "organizationMembership"
600
+ })
601
+ }));
602
+ }
603
+ __name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
604
+
605
+ // src/lib/mysql/schemas/content/content-resource-resource.ts
606
+ var import_drizzle_orm10 = require("drizzle-orm");
607
+ var import_mysql_core10 = require("drizzle-orm/mysql-core");
608
+ function getContentResourceResourceSchema(mysqlTable) {
609
+ return mysqlTable("ContentResourceResource", {
610
+ resourceOfId: (0, import_mysql_core10.varchar)("resourceOfId", {
611
+ length: 255
612
+ }).notNull(),
613
+ resourceId: (0, import_mysql_core10.varchar)("resourceId", {
614
+ length: 255
615
+ }).notNull(),
616
+ position: (0, import_mysql_core10.double)("position").notNull().default(0),
617
+ metadata: (0, import_mysql_core10.json)("metadata").$type().default({}),
618
+ organizationId: (0, import_mysql_core10.varchar)("organizationId", {
619
+ length: 191
620
+ }),
621
+ createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
622
+ mode: "date",
623
+ fsp: 3
624
+ }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
625
+ updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
626
+ mode: "date",
627
+ fsp: 3
628
+ }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
629
+ deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
630
+ mode: "date",
631
+ fsp: 3
632
+ })
633
+ }, (crr) => ({
634
+ pk: (0, import_mysql_core10.primaryKey)({
635
+ columns: [
636
+ crr.resourceOfId,
637
+ crr.resourceId
638
+ ]
639
+ }),
640
+ contentResourceIdIdx: (0, import_mysql_core10.index)("contentResourceId_idx").on(crr.resourceOfId),
641
+ resourceIdIdx: (0, import_mysql_core10.index)("resourceId_idx").on(crr.resourceId),
642
+ organizationIdIdx: (0, import_mysql_core10.index)("organizationId_idx").on(crr.organizationId)
643
+ }));
644
+ }
645
+ __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
646
+ function getContentResourceResourceRelationsSchema(mysqlTable) {
647
+ const contentResource = getContentResourceSchema(mysqlTable);
648
+ const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
649
+ return (0, import_drizzle_orm10.relations)(contentResourceResource, ({ one }) => ({
650
+ resourceOf: one(contentResource, {
651
+ fields: [
652
+ contentResourceResource.resourceOfId
653
+ ],
654
+ references: [
655
+ contentResource.id
656
+ ],
657
+ relationName: "resourceOf"
658
+ }),
659
+ resource: one(contentResource, {
660
+ fields: [
661
+ contentResourceResource.resourceId
662
+ ],
663
+ references: [
664
+ contentResource.id
665
+ ],
666
+ relationName: "resource"
667
+ })
668
+ }));
669
+ }
670
+ __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
671
+
672
+ // src/lib/mysql/schemas/content/content-resource-tag.ts
673
+ var import_drizzle_orm13 = require("drizzle-orm");
674
+ var import_mysql_core13 = require("drizzle-orm/mysql-core");
675
+
676
+ // src/lib/mysql/schemas/content/tag.ts
677
+ var import_drizzle_orm12 = require("drizzle-orm");
678
+ var import_mysql_core12 = require("drizzle-orm/mysql-core");
679
+
680
+ // src/lib/mysql/schemas/content/tag-tag.ts
681
+ var import_drizzle_orm11 = require("drizzle-orm");
682
+ var import_mysql_core11 = require("drizzle-orm/mysql-core");
683
+ function getTagTagSchema(mysqlTable) {
684
+ return mysqlTable("TagTag", {
685
+ parentTagId: (0, import_mysql_core11.varchar)("parentTagId", {
686
+ length: 255
687
+ }).notNull(),
688
+ childTagId: (0, import_mysql_core11.varchar)("childTagId", {
689
+ length: 255
690
+ }).notNull(),
691
+ position: (0, import_mysql_core11.double)("position").notNull().default(0),
692
+ metadata: (0, import_mysql_core11.json)("metadata").$type().default({}),
693
+ organizationId: (0, import_mysql_core11.varchar)("organizationId", {
694
+ length: 191
695
+ }),
696
+ createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
697
+ mode: "date",
698
+ fsp: 3
699
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
700
+ updatedAt: (0, import_mysql_core11.timestamp)("updatedAt", {
701
+ mode: "date",
702
+ fsp: 3
703
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
704
+ deletedAt: (0, import_mysql_core11.timestamp)("deletedAt", {
705
+ mode: "date",
706
+ fsp: 3
707
+ })
708
+ }, (tt) => ({
709
+ pk: (0, import_mysql_core11.primaryKey)({
710
+ columns: [
711
+ tt.parentTagId,
712
+ tt.childTagId
713
+ ]
714
+ }),
715
+ parentTagIdIdx: (0, import_mysql_core11.index)("parentTagId_idx").on(tt.parentTagId),
716
+ childTagIdIdx: (0, import_mysql_core11.index)("childTagId_idx").on(tt.childTagId),
717
+ positionIdx: (0, import_mysql_core11.index)("position_idx").on(tt.position),
718
+ organizationIdIdx: (0, import_mysql_core11.index)("organizationId_idx").on(tt.organizationId)
719
+ }));
720
+ }
721
+ __name(getTagTagSchema, "getTagTagSchema");
722
+ function getTagTagRelationsSchema(mysqlTable) {
723
+ const tag = getTagSchema(mysqlTable);
724
+ const tagTag = getTagTagSchema(mysqlTable);
725
+ return (0, import_drizzle_orm11.relations)(tagTag, ({ one }) => ({
726
+ parentTag: one(tag, {
727
+ fields: [
728
+ tagTag.parentTagId
729
+ ],
730
+ references: [
731
+ tag.id
732
+ ],
733
+ relationName: "parentTag"
734
+ }),
735
+ childTag: one(tag, {
736
+ fields: [
737
+ tagTag.childTagId
738
+ ],
739
+ references: [
740
+ tag.id
741
+ ],
742
+ relationName: "childTag"
743
+ })
744
+ }));
745
+ }
746
+ __name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
747
+
748
+ // src/lib/mysql/schemas/content/tag.ts
749
+ function getTagSchema(mysqlTable) {
750
+ return mysqlTable("Tag", {
751
+ id: (0, import_mysql_core12.varchar)("id", {
752
+ length: 255
753
+ }).notNull().primaryKey(),
754
+ organizationId: (0, import_mysql_core12.varchar)("organizationId", {
755
+ length: 191
756
+ }),
757
+ type: (0, import_mysql_core12.varchar)("type", {
758
+ length: 255
759
+ }).notNull(),
760
+ fields: (0, import_mysql_core12.json)("fields").$type().default({}),
761
+ createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
762
+ mode: "date",
763
+ fsp: 3
764
+ }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
765
+ updatedAt: (0, import_mysql_core12.timestamp)("updatedAt", {
766
+ mode: "date",
767
+ fsp: 3
768
+ }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
769
+ deletedAt: (0, import_mysql_core12.timestamp)("deletedAt", {
770
+ mode: "date",
771
+ fsp: 3
772
+ })
773
+ }, (t) => ({
774
+ typeIdx: (0, import_mysql_core12.index)("type_idx").on(t.type),
775
+ organizationIdIdx: (0, import_mysql_core12.index)("organizationId_idx").on(t.organizationId)
776
+ }));
777
+ }
778
+ __name(getTagSchema, "getTagSchema");
779
+ function getTagRelationsSchema(mysqlTable) {
780
+ const tag = getTagSchema(mysqlTable);
781
+ const contentResourceTag = getContentResourceTagSchema(mysqlTable);
782
+ const tagTag = getTagTagSchema(mysqlTable);
783
+ return (0, import_drizzle_orm12.relations)(tag, ({ many }) => ({
784
+ resources: many(contentResourceTag, {
785
+ relationName: "contentResource"
786
+ }),
787
+ parentTags: many(tagTag, {
788
+ relationName: "childTag"
789
+ }),
790
+ childTags: many(tagTag, {
791
+ relationName: "parentTag"
792
+ })
793
+ }));
794
+ }
795
+ __name(getTagRelationsSchema, "getTagRelationsSchema");
796
+
797
+ // src/lib/mysql/schemas/content/content-resource-tag.ts
798
+ function getContentResourceTagSchema(mysqlTable) {
799
+ return mysqlTable("ContentResourceTag", {
800
+ contentResourceId: (0, import_mysql_core13.varchar)("contentResourceId", {
801
+ length: 255
802
+ }).notNull(),
803
+ organizationId: (0, import_mysql_core13.varchar)("organizationId", {
804
+ length: 191
805
+ }),
806
+ tagId: (0, import_mysql_core13.varchar)("tagId", {
807
+ length: 255
808
+ }).notNull(),
809
+ position: (0, import_mysql_core13.double)("position").notNull().default(0),
810
+ createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
811
+ mode: "date",
812
+ fsp: 3
813
+ }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
814
+ updatedAt: (0, import_mysql_core13.timestamp)("updatedAt", {
815
+ mode: "date",
816
+ fsp: 3
817
+ }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`)
818
+ }, (crt) => ({
819
+ pk: (0, import_mysql_core13.primaryKey)({
820
+ columns: [
821
+ crt.contentResourceId,
822
+ crt.tagId
823
+ ]
824
+ }),
825
+ contentResourceIdIdx: (0, import_mysql_core13.index)("contentResourceId_idx").on(crt.contentResourceId),
826
+ tagIdIdx: (0, import_mysql_core13.index)("tagId_idx").on(crt.tagId),
827
+ positionIdx: (0, import_mysql_core13.index)("position_idx").on(crt.position),
828
+ organizationIdIdx: (0, import_mysql_core13.index)("organizationId_idx").on(crt.organizationId)
829
+ }));
830
+ }
831
+ __name(getContentResourceTagSchema, "getContentResourceTagSchema");
832
+ function getContentResourceTagRelationsSchema(mysqlTable) {
833
+ const contentResource = getContentResourceSchema(mysqlTable);
834
+ const tag = getTagSchema(mysqlTable);
835
+ const contentResourceTag = getContentResourceTagSchema(mysqlTable);
836
+ return (0, import_drizzle_orm13.relations)(contentResourceTag, ({ one }) => ({
837
+ contentResource: one(contentResource, {
838
+ fields: [
839
+ contentResourceTag.contentResourceId
840
+ ],
841
+ references: [
842
+ contentResource.id
843
+ ],
844
+ relationName: "contentResource"
845
+ }),
846
+ tag: one(tag, {
847
+ fields: [
848
+ contentResourceTag.tagId
849
+ ],
850
+ references: [
851
+ tag.id
852
+ ],
853
+ relationName: "tag"
854
+ })
855
+ }));
856
+ }
857
+ __name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
858
+
859
+ // src/lib/mysql/schemas/content/content-resource-version.ts
860
+ var import_drizzle_orm14 = require("drizzle-orm");
861
+ var import_mysql_core14 = require("drizzle-orm/mysql-core");
862
+ function getContentResourceVersionSchema(mysqlTable) {
863
+ return mysqlTable("ContentResourceVersion", {
864
+ id: (0, import_mysql_core14.varchar)("id", {
865
+ length: 255
866
+ }).notNull().primaryKey(),
867
+ organizationId: (0, import_mysql_core14.varchar)("organizationId", {
868
+ length: 191
869
+ }),
870
+ resourceId: (0, import_mysql_core14.varchar)("resourceId", {
871
+ length: 255
872
+ }).notNull(),
873
+ parentVersionId: (0, import_mysql_core14.varchar)("parentVersionId", {
874
+ length: 255
875
+ }),
876
+ versionNumber: (0, import_mysql_core14.int)("versionNumber").notNull(),
877
+ fields: (0, import_mysql_core14.json)("fields").$type().default({}),
878
+ createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
879
+ mode: "date",
880
+ fsp: 3
881
+ }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
882
+ createdById: (0, import_mysql_core14.varchar)("createdById", {
883
+ length: 255
884
+ }).notNull()
885
+ }, (crv) => ({
886
+ resourceIdIdx: (0, import_mysql_core14.index)("resourceId_idx").on(crv.resourceId),
887
+ parentVersionIdIdx: (0, import_mysql_core14.index)("parentVersionId_idx").on(crv.parentVersionId),
888
+ resourceIdVersionNumberIdx: (0, import_mysql_core14.index)("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
889
+ uniqueResourceVersion: (0, import_mysql_core14.unique)("uq_resource_version_number").on(crv.resourceId, crv.versionNumber),
890
+ organizationIdIdx: (0, import_mysql_core14.index)("organizationId_idx").on(crv.organizationId)
891
+ }));
892
+ }
893
+ __name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
894
+ function getContentResourceVersionRelationsSchema(mysqlTable, overrides = {}) {
895
+ const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
896
+ const contentResource = getContentResourceSchema(mysqlTable);
897
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
898
+ const users = resolveUsersSchema(mysqlTable);
899
+ return (0, import_drizzle_orm14.relations)(contentResourceVersion, ({ one }) => ({
900
+ resource: one(contentResource, {
901
+ fields: [
902
+ contentResourceVersion.resourceId
903
+ ],
904
+ references: [
905
+ contentResource.id
906
+ ],
907
+ relationName: "versions"
908
+ }),
909
+ parentVersion: one(contentResourceVersion, {
910
+ fields: [
911
+ contentResourceVersion.parentVersionId
912
+ ],
913
+ references: [
914
+ contentResourceVersion.id
915
+ ],
916
+ relationName: "childVersions"
917
+ }),
918
+ createdBy: one(users, {
919
+ fields: [
920
+ contentResourceVersion.createdById
921
+ ],
922
+ references: [
923
+ users.id
924
+ ],
925
+ relationName: "createdVersions"
926
+ })
927
+ }));
928
+ }
929
+ __name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelationsSchema");
930
+
931
+ // src/lib/mysql/schemas/content/content-resource.ts
932
+ function getContentResourceSchema(mysqlTable) {
933
+ return mysqlTable("ContentResource", {
934
+ id: (0, import_mysql_core15.varchar)("id", {
935
+ length: 255
936
+ }).notNull().primaryKey(),
937
+ organizationId: (0, import_mysql_core15.varchar)("organizationId", {
938
+ length: 191
939
+ }),
940
+ createdByOrganizationMembershipId: (0, import_mysql_core15.varchar)("createdByOrganizationMembershipId", {
941
+ length: 191
942
+ }),
943
+ type: (0, import_mysql_core15.varchar)("type", {
944
+ length: 255
945
+ }).notNull(),
946
+ createdById: (0, import_mysql_core15.varchar)("createdById", {
947
+ length: 255
948
+ }).notNull(),
949
+ fields: (0, import_mysql_core15.json)("fields").$type().default({}),
950
+ // Generated column for indexing JSON slug field
951
+ slug: (0, import_mysql_core15.varchar)("slug", {
952
+ length: 255
953
+ }).generatedAlwaysAs(import_drizzle_orm15.sql`(fields->>'$.slug')`, {
954
+ mode: "stored"
955
+ }),
956
+ currentVersionId: (0, import_mysql_core15.varchar)("currentVersionId", {
957
+ length: 255
958
+ }),
959
+ createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
960
+ mode: "date",
961
+ fsp: 3
962
+ }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
963
+ updatedAt: (0, import_mysql_core15.timestamp)("updatedAt", {
964
+ mode: "date",
965
+ fsp: 3
966
+ }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
967
+ deletedAt: (0, import_mysql_core15.timestamp)("deletedAt", {
968
+ mode: "date",
969
+ fsp: 3
970
+ })
971
+ }, (cm) => ({
972
+ typeIdx: (0, import_mysql_core15.index)("type_idx").on(cm.type),
973
+ createdByIdx: (0, import_mysql_core15.index)("createdById_idx").on(cm.createdById),
974
+ createdAtIdx: (0, import_mysql_core15.index)("createdAt_idx").on(cm.createdAt),
975
+ currentVersionIdIdx: (0, import_mysql_core15.index)("currentVersionId_idx").on(cm.currentVersionId),
976
+ createdByOrganizationMembershipIdIdx: (0, import_mysql_core15.index)("createdByOrganizationMembershipId_idx").on(cm.createdByOrganizationMembershipId),
977
+ slugIdx: (0, import_mysql_core15.index)("slug_idx").on(cm.slug)
978
+ }));
979
+ }
980
+ __name(getContentResourceSchema, "getContentResourceSchema");
981
+ function getContentResourceRelationsSchema(mysqlTable, overrides = {}) {
982
+ const contentResource = getContentResourceSchema(mysqlTable);
983
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
984
+ const users = resolveUsersSchema(mysqlTable);
985
+ const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
986
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
987
+ const contentContributions = getContentContributionsSchema(mysqlTable);
988
+ const contentResourceTag = getContentResourceTagSchema(mysqlTable);
989
+ const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
990
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
991
+ const tag = getTagSchema(mysqlTable);
992
+ return (0, import_drizzle_orm15.relations)(contentResource, ({ one, many }) => ({
993
+ createdBy: one(users, {
994
+ fields: [
995
+ contentResource.createdById
996
+ ],
997
+ references: [
998
+ users.id
999
+ ],
1000
+ relationName: "creator"
1001
+ }),
1002
+ createdByOrganizationMembership: one(organizationMemberships, {
1003
+ fields: [
1004
+ contentResource.createdByOrganizationMembershipId
1005
+ ],
1006
+ references: [
1007
+ organizationMemberships.id
1008
+ ],
1009
+ relationName: "createdByOrganizationMembership"
1010
+ }),
1011
+ tags: many(contentResourceTag, {
1012
+ relationName: "contentResource"
1013
+ }),
1014
+ resources: many(contentResourceResource, {
1015
+ relationName: "resourceOf"
1016
+ }),
1017
+ resourceOf: many(contentResourceResource, {
1018
+ relationName: "resource"
1019
+ }),
1020
+ resourceProducts: many(contentResourceProduct, {
1021
+ relationName: "resource"
1022
+ }),
1023
+ contributions: many(contentContributions, {
1024
+ relationName: "contributions"
1025
+ }),
1026
+ currentVersion: one(contentResourceVersion, {
1027
+ fields: [
1028
+ contentResource.currentVersionId
1029
+ ],
1030
+ references: [
1031
+ contentResourceVersion.id
1032
+ ],
1033
+ relationName: "currentVersionResource"
1034
+ }),
1035
+ versions: many(contentResourceVersion, {
1036
+ relationName: "resource"
1037
+ })
1038
+ }));
1039
+ }
1040
+ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
1041
+
1042
+ // src/lib/mysql/schemas/content/content-resource-product.ts
1043
+ function getContentResourceProductSchema(mysqlTable) {
1044
+ return mysqlTable("ContentResourceProduct", {
1045
+ productId: (0, import_mysql_core16.varchar)("productId", {
1046
+ length: 255
1047
+ }).notNull(),
1048
+ resourceId: (0, import_mysql_core16.varchar)("resourceId", {
1049
+ length: 255
1050
+ }).notNull(),
1051
+ organizationId: (0, import_mysql_core16.varchar)("organizationId", {
1052
+ length: 191
1053
+ }),
1054
+ position: (0, import_mysql_core16.double)("position").notNull().default(0),
1055
+ metadata: (0, import_mysql_core16.json)("metadata").$type().default({}),
1056
+ createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
1057
+ mode: "date",
1058
+ fsp: 3
1059
+ }).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`),
1060
+ updatedAt: (0, import_mysql_core16.timestamp)("updatedAt", {
1061
+ mode: "date",
1062
+ fsp: 3
1063
+ }).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`),
1064
+ deletedAt: (0, import_mysql_core16.timestamp)("deletedAt", {
1065
+ mode: "date",
1066
+ fsp: 3
1067
+ })
1068
+ }, (crr) => ({
1069
+ pk: (0, import_mysql_core16.primaryKey)({
1070
+ columns: [
1071
+ crr.productId,
1072
+ crr.resourceId
1073
+ ]
1074
+ }),
1075
+ contentResourceIdIdx: (0, import_mysql_core16.index)("contentResourceId_idx").on(crr.productId),
1076
+ resourceIdIdx: (0, import_mysql_core16.index)("resourceId_idx").on(crr.resourceId),
1077
+ organizationIdIdx: (0, import_mysql_core16.index)("organizationId_idx").on(crr.organizationId)
1078
+ }));
1079
+ }
1080
+ __name(getContentResourceProductSchema, "getContentResourceProductSchema");
1081
+ function getContentResourceProductRelationsSchema(mysqlTable) {
1082
+ const contentResource = getContentResourceSchema(mysqlTable);
1083
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
1084
+ const product = getProductSchema(mysqlTable);
1085
+ return (0, import_drizzle_orm16.relations)(contentResourceProduct, ({ one }) => ({
1086
+ product: one(product, {
1087
+ fields: [
1088
+ contentResourceProduct.productId
1089
+ ],
1090
+ references: [
1091
+ product.id
1092
+ ],
1093
+ relationName: "product"
1094
+ }),
1095
+ resource: one(contentResource, {
1096
+ fields: [
1097
+ contentResourceProduct.resourceId
1098
+ ],
1099
+ references: [
1100
+ contentResource.id
1101
+ ],
1102
+ relationName: "resource"
1103
+ })
1104
+ }));
1105
+ }
1106
+ __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
1107
+
1108
+ // src/lib/mysql/schemas/commerce/price.ts
1109
+ var import_drizzle_orm18 = require("drizzle-orm");
1110
+ var import_mysql_core18 = require("drizzle-orm/mysql-core");
1111
+
1112
+ // src/lib/mysql/schemas/commerce/merchant-price.ts
1113
+ var import_drizzle_orm17 = require("drizzle-orm");
1114
+ var import_mysql_core17 = require("drizzle-orm/mysql-core");
1115
+ function getMerchantPriceSchema(mysqlTable) {
1116
+ return mysqlTable("MerchantPrice", {
1117
+ id: (0, import_mysql_core17.varchar)("id", {
1118
+ length: 191
1119
+ }).notNull(),
1120
+ organizationId: (0, import_mysql_core17.varchar)("organizationId", {
1121
+ length: 191
1122
+ }),
1123
+ merchantAccountId: (0, import_mysql_core17.varchar)("merchantAccountId", {
1124
+ length: 191
1125
+ }).notNull(),
1126
+ merchantProductId: (0, import_mysql_core17.varchar)("merchantProductId", {
1127
+ length: 191
1128
+ }).notNull(),
1129
+ status: (0, import_mysql_core17.int)("status").default(0),
1130
+ identifier: (0, import_mysql_core17.varchar)("identifier", {
1131
+ length: 191
1132
+ }),
1133
+ createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
1134
+ mode: "date",
1135
+ fsp: 3
1136
+ }).default(import_drizzle_orm17.sql`CURRENT_TIMESTAMP(3)`).notNull(),
1137
+ priceId: (0, import_mysql_core17.varchar)("priceId", {
1138
+ length: 191
1139
+ })
1140
+ }, (table) => {
1141
+ return {
1142
+ merchantPriceId: (0, import_mysql_core17.primaryKey)({
1143
+ columns: [
1144
+ table.id
1145
+ ],
1146
+ name: "MerchantPrice_id"
1147
+ }),
1148
+ merchantPriceIdentifierKey: (0, import_mysql_core17.unique)("MerchantPrice_identifier_key").on(table.identifier),
1149
+ organizationIdIdx: (0, import_mysql_core17.index)("organizationId_idx").on(table.organizationId)
1150
+ };
1151
+ });
1152
+ }
1153
+ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
1154
+
1155
+ // src/lib/mysql/schemas/commerce/price.ts
1156
+ function getPriceSchema(mysqlTable) {
1157
+ return mysqlTable("Price", {
1158
+ id: (0, import_mysql_core18.varchar)("id", {
1159
+ length: 191
1160
+ }).notNull(),
1161
+ productId: (0, import_mysql_core18.varchar)("productId", {
1162
+ length: 191
1163
+ }),
1164
+ organizationId: (0, import_mysql_core18.varchar)("organizationId", {
1165
+ length: 191
1166
+ }),
1167
+ nickname: (0, import_mysql_core18.varchar)("nickname", {
1168
+ length: 191
1169
+ }),
1170
+ status: (0, import_mysql_core18.int)("status").default(0).notNull(),
1171
+ unitAmount: (0, import_mysql_core18.decimal)("unitAmount", {
1172
+ precision: 10,
1173
+ scale: 2
1174
+ }).notNull(),
1175
+ createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
1176
+ mode: "date",
1177
+ fsp: 3
1178
+ }).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
1179
+ fields: (0, import_mysql_core18.json)("fields").$type().default({})
1180
+ }, (table) => {
1181
+ return {
1182
+ priceId: (0, import_mysql_core18.primaryKey)({
1183
+ columns: [
1184
+ table.id
1185
+ ],
1186
+ name: "Price_id"
1187
+ }),
1188
+ organizationIdIdx: (0, import_mysql_core18.index)("organizationId_idx").on(table.organizationId)
1189
+ };
1190
+ });
1191
+ }
1192
+ __name(getPriceSchema, "getPriceSchema");
1193
+
1194
+ // src/lib/mysql/schemas/commerce/product.ts
1195
+ function getProductSchema(mysqlTable) {
1196
+ return mysqlTable("Product", {
1197
+ id: (0, import_mysql_core19.varchar)("id", {
1198
+ length: 191
1199
+ }).notNull(),
1200
+ organizationId: (0, import_mysql_core19.varchar)("organizationId", {
1201
+ length: 191
1202
+ }),
1203
+ name: (0, import_mysql_core19.varchar)("name", {
1204
+ length: 191
1205
+ }).notNull(),
1206
+ key: (0, import_mysql_core19.varchar)("key", {
1207
+ length: 191
1208
+ }),
1209
+ type: (0, import_mysql_core19.varchar)("type", {
1210
+ length: 191
1211
+ }),
1212
+ fields: (0, import_mysql_core19.json)("fields").$type().default({}),
1213
+ createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
1214
+ mode: "date",
1215
+ fsp: 3
1216
+ }).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`).notNull(),
1217
+ status: (0, import_mysql_core19.int)("status").default(0).notNull(),
1218
+ quantityAvailable: (0, import_mysql_core19.int)("quantityAvailable").default(-1).notNull()
1219
+ }, (table) => {
1220
+ return {
1221
+ productId: (0, import_mysql_core19.primaryKey)({
1222
+ columns: [
1223
+ table.id
1224
+ ],
1225
+ name: "Product_id"
1226
+ }),
1227
+ organizationIdIdx: (0, import_mysql_core19.index)("organizationId_idx").on(table.organizationId)
1228
+ };
1229
+ });
1230
+ }
1231
+ __name(getProductSchema, "getProductSchema");
1232
+ function getProductRelationsSchema(mysqlTable) {
1233
+ const product = getProductSchema(mysqlTable);
1234
+ const price = getPriceSchema(mysqlTable);
1235
+ const merchantProduct = getMerchantProductSchema(mysqlTable);
1236
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
1237
+ return (0, import_drizzle_orm19.relations)(product, ({ one, many }) => ({
1238
+ price: one(price, {
1239
+ fields: [
1240
+ product.id
1241
+ ],
1242
+ references: [
1243
+ price.productId
1244
+ ],
1245
+ relationName: "price"
1246
+ }),
1247
+ resources: many(contentResourceProduct, {
1248
+ relationName: "product"
1249
+ }),
1250
+ merchantProduct: one(merchantProduct, {
1251
+ fields: [
1252
+ product.id
1253
+ ],
1254
+ references: [
1255
+ merchantProduct.productId
1256
+ ],
1257
+ relationName: "merchantProduct"
1258
+ })
1259
+ }));
1260
+ }
1261
+ __name(getProductRelationsSchema, "getProductRelationsSchema");
1262
+
1263
+ // src/lib/mysql/schemas/commerce/subscription.ts
1264
+ function getSubscriptionSchema(mysqlTable) {
1265
+ return mysqlTable("Subscription", {
1266
+ id: (0, import_mysql_core20.varchar)("id", {
1267
+ length: 191
1268
+ }).notNull(),
1269
+ organizationId: (0, import_mysql_core20.varchar)("organizationId", {
1270
+ length: 191
1271
+ }),
1272
+ productId: (0, import_mysql_core20.varchar)("productId", {
1273
+ length: 191
1274
+ }).notNull(),
1275
+ createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
1276
+ mode: "date",
1277
+ fsp: 3
1278
+ }).default(import_drizzle_orm20.sql`CURRENT_TIMESTAMP(3)`).notNull(),
1279
+ merchantSubscriptionId: (0, import_mysql_core20.varchar)("merchantSubscriptionId", {
1280
+ length: 191
1281
+ }).notNull(),
1282
+ status: (0, import_mysql_core20.varchar)("status", {
1283
+ length: 191
1284
+ }).default("active").notNull(),
1285
+ fields: (0, import_mysql_core20.json)("fields").$type().default({})
1286
+ }, (table) => {
1287
+ return {
1288
+ subscriptionId: (0, import_mysql_core20.primaryKey)({
1289
+ columns: [
1290
+ table.id
1291
+ ],
1292
+ name: "Subscription_id"
1293
+ }),
1294
+ organizationIdIdx: (0, import_mysql_core20.index)("organizationId_idx").on(table.organizationId)
1295
+ };
1296
+ });
1297
+ }
1298
+ __name(getSubscriptionSchema, "getSubscriptionSchema");
1299
+ function getSubscriptionRelationsSchema(mysqlTable) {
1300
+ const subscriptions = getSubscriptionSchema(mysqlTable);
1301
+ const products = getProductSchema(mysqlTable);
1302
+ const organizations = getOrganizationsSchema(mysqlTable);
1303
+ const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable);
1304
+ return (0, import_drizzle_orm20.relations)(subscriptions, ({ many, one }) => ({
1305
+ organization: one(organizations, {
1306
+ fields: [
1307
+ subscriptions.organizationId
1308
+ ],
1309
+ references: [
1310
+ organizations.id
1311
+ ],
1312
+ relationName: "organization"
1313
+ }),
1314
+ product: one(products, {
1315
+ fields: [
1316
+ subscriptions.productId
1317
+ ],
1318
+ references: [
1319
+ products.id
1320
+ ],
1321
+ relationName: "product"
1322
+ }),
1323
+ merchantSubscription: one(merchantSubscriptions, {
1324
+ fields: [
1325
+ subscriptions.merchantSubscriptionId
1326
+ ],
1327
+ references: [
1328
+ merchantSubscriptions.id
1329
+ ],
1330
+ relationName: "merchantSubscription"
1331
+ })
1332
+ }));
1333
+ }
1334
+ __name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
1335
+
1336
+ // src/lib/mysql/schemas/org/organizations.ts
1337
+ function getOrganizationsSchema(mysqlTable) {
1338
+ return mysqlTable("Organization", {
1339
+ id: (0, import_mysql_core21.varchar)("id", {
1340
+ length: 255
1341
+ }).notNull().primaryKey(),
1342
+ name: (0, import_mysql_core21.varchar)("name", {
1343
+ length: 255
1344
+ }),
1345
+ // ADR-0012 P3: identity is stable even when email/name presentation changes.
1346
+ personalOrganizationUserId: (0, import_mysql_core21.varchar)("personalOrganizationUserId", {
1347
+ length: 255
1348
+ }),
1349
+ fields: (0, import_mysql_core21.json)("fields").$type().default({}),
1350
+ image: (0, import_mysql_core21.varchar)("image", {
1351
+ length: 255
1352
+ }),
1353
+ createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
1354
+ mode: "date",
1355
+ fsp: 3
1356
+ }).default(import_drizzle_orm21.sql`CURRENT_TIMESTAMP(3)`)
1357
+ }, (organization) => ({
1358
+ createdAtIdx: (0, import_mysql_core21.index)("created_at_idx").on(organization.createdAt),
1359
+ personalOrganizationUserIdIdx: (0, import_mysql_core21.uniqueIndex)("personalOrganizationUserId_idx").on(organization.personalOrganizationUserId)
1360
+ }));
1361
+ }
1362
+ __name(getOrganizationsSchema, "getOrganizationsSchema");
1363
+ function getOrganizationsRelationsSchema(mysqlTable) {
1364
+ const organizations = getOrganizationsSchema(mysqlTable);
1365
+ const purchases = getPurchaseSchema(mysqlTable);
1366
+ const subscriptions = getSubscriptionSchema(mysqlTable);
1367
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
1368
+ return (0, import_drizzle_orm21.relations)(organizations, ({ many }) => ({
1369
+ purchases: many(purchases, {
1370
+ relationName: "organization"
1371
+ }),
1372
+ subscriptions: many(subscriptions, {
1373
+ relationName: "organization"
1374
+ }),
1375
+ members: many(organizationMemberships, {
1376
+ relationName: "organization"
1377
+ })
1378
+ }));
1379
+ }
1380
+ __name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
1381
+
1382
+ // src/lib/mysql/schemas/org/organization-membership-roles.ts
1383
+ function getOrganizationMembershipRolesSchema(mysqlTable) {
1384
+ return mysqlTable("OrganizationMembershipRole", {
1385
+ organizationMembershipId: (0, import_mysql_core22.varchar)("organizationMembershipId", {
1386
+ length: 255
1387
+ }).notNull(),
1388
+ roleId: (0, import_mysql_core22.varchar)("roleId", {
1389
+ length: 255
1390
+ }).notNull(),
1391
+ active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
1392
+ organizationId: (0, import_mysql_core22.varchar)("organizationId", {
1393
+ length: 191
1394
+ }),
1395
+ createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
1396
+ mode: "date",
1397
+ fsp: 3
1398
+ }).defaultNow(),
1399
+ updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
1400
+ mode: "date",
1401
+ fsp: 3
1402
+ }).defaultNow(),
1403
+ deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
1404
+ mode: "date",
1405
+ fsp: 3
1406
+ })
1407
+ }, (ur) => ({
1408
+ pk: (0, import_mysql_core22.primaryKey)({
1409
+ columns: [
1410
+ ur.organizationMembershipId,
1411
+ ur.roleId
1412
+ ],
1413
+ name: "pk"
1414
+ }),
1415
+ orgMemberIdIdx: (0, import_mysql_core22.index)("orgMemberId_idx").on(ur.organizationMembershipId),
1416
+ roleIdIdx: (0, import_mysql_core22.index)("roleId_idx").on(ur.roleId),
1417
+ organizationIdIdx: (0, import_mysql_core22.index)("organizationId_idx").on(ur.organizationId)
1418
+ }));
1419
+ }
1420
+ __name(getOrganizationMembershipRolesSchema, "getOrganizationMembershipRolesSchema");
1421
+ function getOrganizationMembershipRolesRelationsSchema(mysqlTable) {
1422
+ const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
1423
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
1424
+ const roles = getRolesSchema(mysqlTable);
1425
+ const organizations = getOrganizationsSchema(mysqlTable);
1426
+ return (0, import_drizzle_orm22.relations)(organizationMembershipRoles, ({ one }) => ({
1427
+ organizationMembership: one(organizationMemberships, {
1428
+ fields: [
1429
+ organizationMembershipRoles.organizationMembershipId
1430
+ ],
1431
+ references: [
1432
+ organizationMemberships.id
1433
+ ],
1434
+ relationName: "organizationMembership"
1435
+ }),
1436
+ role: one(roles, {
1437
+ fields: [
1438
+ organizationMembershipRoles.roleId
1439
+ ],
1440
+ references: [
1441
+ roles.id
1442
+ ],
1443
+ relationName: "role"
1444
+ }),
1445
+ organization: one(organizations, {
1446
+ fields: [
1447
+ organizationMembershipRoles.organizationId
1448
+ ],
1449
+ references: [
1450
+ organizations.id
1451
+ ],
1452
+ relationName: "organization"
1453
+ })
1454
+ }));
1455
+ }
1456
+ __name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
1457
+
1458
+ // src/lib/mysql/schemas/org/organization-memberships.ts
1459
+ function getOrganizationMembershipsSchema(mysqlTable) {
1460
+ return mysqlTable("OrganizationMembership", {
1461
+ id: (0, import_mysql_core23.varchar)("id", {
1462
+ length: 255
1463
+ }).notNull().primaryKey(),
1464
+ organizationId: (0, import_mysql_core23.varchar)("organizationId", {
1465
+ length: 191
1466
+ }),
1467
+ role: (0, import_mysql_core23.varchar)("role", {
1468
+ length: 191
1469
+ }).notNull().default("user"),
1470
+ invitedById: (0, import_mysql_core23.varchar)("invitedById", {
1471
+ length: 255
1472
+ }).notNull(),
1473
+ userId: (0, import_mysql_core23.varchar)("userId", {
1474
+ length: 255
1475
+ }).notNull(),
1476
+ personalOrganizationUserId: (0, import_mysql_core23.varchar)("personalOrganizationUserId", {
1477
+ length: 255
1478
+ }),
1479
+ fields: (0, import_mysql_core23.json)("fields").$type().default({}),
1480
+ createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
1481
+ mode: "date",
1482
+ fsp: 3
1483
+ }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`)
1484
+ }, (organizationMembership) => ({
1485
+ roleIdx: (0, import_mysql_core23.index)("role_idx").on(organizationMembership.role),
1486
+ createdAtIdx: (0, import_mysql_core23.index)("created_at_idx").on(organizationMembership.createdAt),
1487
+ organizationIdIdx: (0, import_mysql_core23.index)("organizationId_idx").on(organizationMembership.organizationId),
1488
+ personalOrganizationUserIdIdx: (0, import_mysql_core23.uniqueIndex)("personalOrganizationUserId_idx").on(organizationMembership.personalOrganizationUserId)
1489
+ }));
1490
+ }
1491
+ __name(getOrganizationMembershipsSchema, "getOrganizationMembershipsSchema");
1492
+ function getOrganizationMembershipsRelationsSchema(mysqlTable, overrides = {}) {
1493
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
1494
+ const users = resolveUsersSchema(mysqlTable);
1495
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
1496
+ const purchases = getPurchaseSchema(mysqlTable);
1497
+ const organizations = getOrganizationsSchema(mysqlTable);
1498
+ const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
1499
+ return (0, import_drizzle_orm23.relations)(organizationMemberships, ({ one, many }) => ({
1500
+ user: one(users, {
1501
+ fields: [
1502
+ organizationMemberships.userId
1503
+ ],
1504
+ references: [
1505
+ users.id
1506
+ ],
1507
+ relationName: "user"
1508
+ }),
1509
+ invitedBy: one(users, {
1510
+ fields: [
1511
+ organizationMemberships.invitedById
1512
+ ],
1513
+ references: [
1514
+ users.id
1515
+ ],
1516
+ relationName: "invitedBy"
1517
+ }),
1518
+ purchases: many(purchases),
1519
+ organization: one(organizations, {
1520
+ fields: [
1521
+ organizationMemberships.organizationId
1522
+ ],
1523
+ references: [
1524
+ organizations.id
1525
+ ],
1526
+ relationName: "organization"
1527
+ }),
1528
+ organizationMembershipRoles: many(organizationMembershipRoles, {
1529
+ relationName: "organizationMembership"
1530
+ })
1531
+ }));
1532
+ }
1533
+ __name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
1534
+
1535
+ // src/lib/mysql/schemas/commerce/coupon.ts
1536
+ var import_drizzle_orm24 = require("drizzle-orm");
1537
+ var import_mysql_core25 = require("drizzle-orm/mysql-core");
1538
+
1539
+ // src/lib/mysql/schemas/commerce/merchant-coupon.ts
1540
+ var import_mysql_core24 = require("drizzle-orm/mysql-core");
1541
+ function getMerchantCouponSchema(mysqlTable) {
1542
+ return mysqlTable("MerchantCoupon", {
1543
+ id: (0, import_mysql_core24.varchar)("id", {
1544
+ length: 191
1545
+ }).notNull(),
1546
+ identifier: (0, import_mysql_core24.varchar)("identifier", {
1547
+ length: 191
1548
+ }),
1549
+ organizationId: (0, import_mysql_core24.varchar)("organizationId", {
1550
+ length: 191
1551
+ }),
1552
+ status: (0, import_mysql_core24.int)("status").default(0).notNull(),
1553
+ merchantAccountId: (0, import_mysql_core24.varchar)("merchantAccountId", {
1554
+ length: 191
1555
+ }).notNull(),
1556
+ percentageDiscount: (0, import_mysql_core24.decimal)("percentageDiscount", {
1557
+ precision: 3,
1558
+ scale: 2
1559
+ }),
1560
+ amountDiscount: (0, import_mysql_core24.int)("amountDiscount"),
1561
+ type: (0, import_mysql_core24.varchar)("type", {
1562
+ length: 191
1563
+ })
1564
+ }, (table) => {
1565
+ return {
1566
+ merchantCouponId: (0, import_mysql_core24.primaryKey)({
1567
+ columns: [
1568
+ table.id
1569
+ ],
1570
+ name: "MerchantCoupon_id"
1571
+ }),
1572
+ merchantCouponIdentifierKey: (0, import_mysql_core24.unique)("MerchantCoupon_identifier_key").on(table.identifier),
1573
+ organizationIdIdx: (0, import_mysql_core24.index)("organizationId_idx").on(table.organizationId)
1574
+ };
1575
+ });
1576
+ }
1577
+ __name(getMerchantCouponSchema, "getMerchantCouponSchema");
1578
+
1579
+ // src/lib/mysql/schemas/commerce/coupon.ts
1580
+ function getCouponSchema(mysqlTable) {
1581
+ return mysqlTable("Coupon", {
1582
+ id: (0, import_mysql_core25.varchar)("id", {
1583
+ length: 191
1584
+ }).notNull(),
1585
+ organizationId: (0, import_mysql_core25.varchar)("organizationId", {
1586
+ length: 191
1587
+ }),
1588
+ code: (0, import_mysql_core25.varchar)("code", {
1589
+ length: 191
1590
+ }),
1591
+ createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
1592
+ mode: "date",
1593
+ fsp: 3
1594
+ }).default(import_drizzle_orm24.sql`CURRENT_TIMESTAMP(3)`).notNull(),
1595
+ expires: (0, import_mysql_core25.timestamp)("expires", {
1596
+ mode: "date",
1597
+ fsp: 3
1598
+ }),
1599
+ fields: (0, import_mysql_core25.json)("fields").$type().default({}),
1600
+ maxUses: (0, import_mysql_core25.int)("maxUses").default(-1).notNull(),
1601
+ default: (0, import_mysql_core25.boolean)("default").default(false).notNull(),
1602
+ merchantCouponId: (0, import_mysql_core25.varchar)("merchantCouponId", {
1603
+ length: 191
1604
+ }),
1605
+ status: (0, import_mysql_core25.int)("status").default(0).notNull(),
1606
+ usedCount: (0, import_mysql_core25.int)("usedCount").default(0).notNull(),
1607
+ percentageDiscount: (0, import_mysql_core25.decimal)("percentageDiscount", {
1608
+ precision: 3,
1609
+ scale: 2
1610
+ }),
1611
+ amountDiscount: (0, import_mysql_core25.int)("amountDiscount"),
1612
+ restrictedToProductId: (0, import_mysql_core25.varchar)("restrictedToProductId", {
1613
+ length: 191
1614
+ })
1615
+ }, (table) => {
1616
+ return {
1617
+ couponIdCodeIndex: (0, import_mysql_core25.index)("Coupon_id_code_index").on(table.id, table.code),
1618
+ couponId: (0, import_mysql_core25.primaryKey)({
1619
+ columns: [
1620
+ table.id
1621
+ ],
1622
+ name: "Coupon_id"
1623
+ }),
1624
+ couponCodeKey: (0, import_mysql_core25.unique)("Coupon_code_key").on(table.code),
1625
+ organizationIdIdx: (0, import_mysql_core25.index)("organizationId_idx").on(table.organizationId)
1626
+ };
1627
+ });
1628
+ }
1629
+ __name(getCouponSchema, "getCouponSchema");
1630
+ function getCouponRelationsSchema(mysqlTable) {
1631
+ const purchase = getPurchaseSchema(mysqlTable);
1632
+ const coupon = getCouponSchema(mysqlTable);
1633
+ const merchantCoupon = getMerchantCouponSchema(mysqlTable);
1634
+ return (0, import_drizzle_orm24.relations)(coupon, ({ many, one }) => ({
1635
+ redeemedBulkCouponPurchases: many(purchase, {
1636
+ relationName: "redeemedBulkCoupon"
1637
+ }),
1638
+ merchantCoupon: one(merchantCoupon, {
1639
+ fields: [
1640
+ coupon.merchantCouponId
1641
+ ],
1642
+ references: [
1643
+ merchantCoupon.id
1644
+ ],
1645
+ relationName: "merchantCoupon"
1646
+ }),
1647
+ product: one(getProductSchema(mysqlTable), {
1648
+ fields: [
1649
+ coupon.restrictedToProductId
1650
+ ],
1651
+ references: [
1652
+ getProductSchema(mysqlTable).id
1653
+ ],
1654
+ relationName: "product"
1655
+ }),
1656
+ bulkPurchases: many(purchase, {
1657
+ relationName: "bulkCoupon"
1658
+ })
1659
+ }));
1660
+ }
1661
+ __name(getCouponRelationsSchema, "getCouponRelationsSchema");
1662
+
1663
+ // src/lib/mysql/schemas/commerce/merchant-session.ts
1664
+ var import_mysql_core26 = require("drizzle-orm/mysql-core");
1665
+ function getMerchantSessionSchema(mysqlTable) {
1666
+ return mysqlTable("MerchantSession", {
1667
+ id: (0, import_mysql_core26.varchar)("id", {
1668
+ length: 191
1669
+ }).notNull(),
1670
+ organizationId: (0, import_mysql_core26.varchar)("organizationId", {
1671
+ length: 191
1672
+ }),
1673
+ identifier: (0, import_mysql_core26.varchar)("identifier", {
1674
+ length: 191
1675
+ }).notNull(),
1676
+ merchantAccountId: (0, import_mysql_core26.varchar)("merchantAccountId", {
1677
+ length: 191
1678
+ }).notNull()
1679
+ }, (table) => {
1680
+ return {
1681
+ merchantSessionId: (0, import_mysql_core26.primaryKey)({
1682
+ columns: [
1683
+ table.id
1684
+ ],
1685
+ name: "MerchantSession_id"
1686
+ }),
1687
+ organizationIdIdx: (0, import_mysql_core26.index)("organizationId_idx").on(table.organizationId)
1688
+ };
1689
+ });
1690
+ }
1691
+ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
1692
+
1693
+ // src/lib/mysql/schemas/commerce/purchase.ts
1694
+ function getPurchaseSchema(mysqlTable) {
1695
+ return mysqlTable("Purchase", {
1696
+ id: (0, import_mysql_core27.varchar)("id", {
1697
+ length: 191
1698
+ }).notNull(),
1699
+ userId: (0, import_mysql_core27.varchar)("userId", {
1700
+ length: 191
1701
+ }),
1702
+ purchasedByorganizationMembershipId: (0, import_mysql_core27.varchar)("organizationMembershipId", {
1703
+ length: 191
1704
+ }),
1705
+ organizationId: (0, import_mysql_core27.varchar)("organizationId", {
1706
+ length: 191
1707
+ }),
1708
+ createdAt: (0, import_mysql_core27.timestamp)("createdAt", {
1709
+ mode: "date",
1710
+ fsp: 3
1711
+ }).default(import_drizzle_orm25.sql`CURRENT_TIMESTAMP(3)`).notNull(),
1712
+ totalAmount: (0, import_mysql_core27.decimal)("totalAmount", {
1713
+ precision: 65,
1714
+ scale: 30
1715
+ }).notNull(),
1716
+ ipAddress: (0, import_mysql_core27.varchar)("ip_address", {
1717
+ length: 191
1718
+ }),
1719
+ city: (0, import_mysql_core27.varchar)("city", {
1720
+ length: 191
1721
+ }),
1722
+ state: (0, import_mysql_core27.varchar)("state", {
1723
+ length: 191
1724
+ }),
1725
+ country: (0, import_mysql_core27.varchar)("country", {
1726
+ length: 191
1727
+ }),
1728
+ couponId: (0, import_mysql_core27.varchar)("couponId", {
1729
+ length: 191
1730
+ }),
1731
+ productId: (0, import_mysql_core27.varchar)("productId", {
1732
+ length: 191
1733
+ }).notNull(),
1734
+ merchantChargeId: (0, import_mysql_core27.varchar)("merchantChargeId", {
1735
+ length: 191
1736
+ }),
1737
+ upgradedFromId: (0, import_mysql_core27.varchar)("upgradedFromId", {
1738
+ length: 191
1739
+ }),
1740
+ status: (0, import_mysql_core27.varchar)("status", {
1741
+ length: 191
1742
+ }).default("Valid").notNull(),
1743
+ bulkCouponId: (0, import_mysql_core27.varchar)("bulkCouponId", {
1744
+ length: 191
1745
+ }),
1746
+ merchantSessionId: (0, import_mysql_core27.varchar)("merchantSessionId", {
1747
+ length: 191
1748
+ }),
1749
+ redeemedBulkCouponId: (0, import_mysql_core27.varchar)("redeemedBulkCouponId", {
1750
+ length: 191
1751
+ }),
1752
+ fields: (0, import_mysql_core27.json)("fields").$type().default({})
1753
+ }, (table) => {
1754
+ return {
1755
+ purchaseId: (0, import_mysql_core27.primaryKey)({
1756
+ columns: [
1757
+ table.id
1758
+ ],
1759
+ name: "Purchase_id"
1760
+ }),
1761
+ merchantChargeIdIdx: (0, import_mysql_core27.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
1762
+ purchaseUpgradedFromIdKey: (0, import_mysql_core27.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId),
1763
+ organizationIdIdx: (0, import_mysql_core27.index)("organizationId_idx").on(table.organizationId),
1764
+ organizationMembershipIdIdx: (0, import_mysql_core27.index)("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId),
1765
+ userStatusProductIdx: (0, import_mysql_core27.index)("idx_Purchase_on_userId_status_productId").on(table.userId, table.status, table.productId)
1766
+ };
1767
+ });
1768
+ }
1769
+ __name(getPurchaseSchema, "getPurchaseSchema");
1770
+ function getPurchaseRelationsSchema(mysqlTable, overrides = {}) {
1771
+ const purchases = getPurchaseSchema(mysqlTable);
1772
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
1773
+ const users = resolveUsersSchema(mysqlTable);
1774
+ const products = getProductSchema(mysqlTable);
1775
+ const merchantCharges = getMerchantChargeSchema(mysqlTable);
1776
+ const merchantSessions = getMerchantSessionSchema(mysqlTable);
1777
+ const coupons = getCouponSchema(mysqlTable);
1778
+ const organizations = getOrganizationsSchema(mysqlTable);
1779
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
1780
+ return (0, import_drizzle_orm25.relations)(purchases, ({ many, one }) => ({
1781
+ redeemedBulkCoupon: one(coupons, {
1782
+ fields: [
1783
+ purchases.redeemedBulkCouponId
1784
+ ],
1785
+ references: [
1786
+ coupons.id
1787
+ ],
1788
+ relationName: "redeemedBulkCoupon"
1789
+ }),
1790
+ user: one(users, {
1791
+ fields: [
1792
+ purchases.userId
1793
+ ],
1794
+ references: [
1795
+ users.id
1796
+ ],
1797
+ relationName: "user"
1798
+ }),
1799
+ organization: one(organizations, {
1800
+ fields: [
1801
+ purchases.organizationId
1802
+ ],
1803
+ references: [
1804
+ organizations.id
1805
+ ],
1806
+ relationName: "organization"
1807
+ }),
1808
+ purchasedBy: one(organizationMemberships, {
1809
+ fields: [
1810
+ purchases.purchasedByorganizationMembershipId
1811
+ ],
1812
+ references: [
1813
+ organizationMemberships.id
1814
+ ],
1815
+ relationName: "organizationMembership"
1816
+ }),
1817
+ product: one(products, {
1818
+ fields: [
1819
+ purchases.productId
1820
+ ],
1821
+ references: [
1822
+ products.id
1823
+ ],
1824
+ relationName: "product"
1825
+ }),
1826
+ bulkCoupon: one(coupons, {
1827
+ fields: [
1828
+ purchases.bulkCouponId
1829
+ ],
1830
+ references: [
1831
+ coupons.id
1832
+ ],
1833
+ relationName: "bulkCoupon"
1834
+ }),
1835
+ merchantCharge: one(merchantCharges, {
1836
+ fields: [
1837
+ purchases.merchantChargeId
1838
+ ],
1839
+ references: [
1840
+ merchantCharges.id
1841
+ ],
1842
+ relationName: "merchantCharge"
1843
+ }),
1844
+ merchantSession: one(merchantSessions, {
1845
+ fields: [
1846
+ purchases.merchantSessionId
1847
+ ],
1848
+ references: [
1849
+ merchantSessions.id
1850
+ ],
1851
+ relationName: "merchantSession"
1852
+ })
1853
+ }));
1854
+ }
1855
+ __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
1856
+
1857
+ // src/lib/mysql/schemas/communication/comment.ts
1858
+ var import_drizzle_orm26 = require("drizzle-orm");
1859
+ var import_mysql_core28 = require("drizzle-orm/mysql-core");
1860
+ function getCommentsSchema(mysqlTable) {
1861
+ return mysqlTable("Comment", {
1862
+ id: (0, import_mysql_core28.varchar)("id", {
1863
+ length: 191
1864
+ }).notNull(),
1865
+ userId: (0, import_mysql_core28.varchar)("userId", {
1866
+ length: 255
1867
+ }).notNull(),
1868
+ organizationMembershipId: (0, import_mysql_core28.varchar)("organizationMembershipId", {
1869
+ length: 255
1870
+ }),
1871
+ context: (0, import_mysql_core28.json)("context").$type().default({}),
1872
+ text: (0, import_mysql_core28.text)("text").notNull(),
1873
+ createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
1874
+ mode: "date",
1875
+ fsp: 3
1876
+ }).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`),
1877
+ updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
1878
+ mode: "date",
1879
+ fsp: 3
1880
+ }).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`),
1881
+ deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
1882
+ mode: "date",
1883
+ fsp: 3
1884
+ })
1885
+ }, (crr) => ({
1886
+ pk: (0, import_mysql_core28.primaryKey)({
1887
+ columns: [
1888
+ crr.id
1889
+ ]
1890
+ }),
1891
+ crrUserIdIdKey: (0, import_mysql_core28.index)("crr_userIdId_idx").on(crr.userId),
1892
+ organizationMembershipIdIdx: (0, import_mysql_core28.index)("organizationMembershipId_idx").on(crr.organizationMembershipId)
1893
+ }));
1894
+ }
1895
+ __name(getCommentsSchema, "getCommentsSchema");
1896
+ function getCommentRelationsSchema(mysqlTable, overrides = {}) {
1897
+ const comment = getCommentsSchema(mysqlTable);
1898
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
1899
+ const user = resolveUsersSchema(mysqlTable);
1900
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
1901
+ return (0, import_drizzle_orm26.relations)(comment, ({ one }) => ({
1902
+ user: one(user, {
1903
+ fields: [
1904
+ comment.userId
1905
+ ],
1906
+ references: [
1907
+ user.id
1908
+ ],
1909
+ relationName: "user"
1910
+ }),
1911
+ organizationMembership: one(organizationMemberships, {
1912
+ fields: [
1913
+ comment.organizationMembershipId
1914
+ ],
1915
+ references: [
1916
+ organizationMemberships.id
1917
+ ],
1918
+ relationName: "organizationMembership"
1919
+ })
1920
+ }));
1921
+ }
1922
+ __name(getCommentRelationsSchema, "getCommentRelationsSchema");
1923
+
1924
+ // src/lib/mysql/schemas/communication/communication-preferences.ts
1925
+ var import_drizzle_orm27 = require("drizzle-orm");
1926
+ var import_mysql_core31 = require("drizzle-orm/mysql-core");
1927
+
1928
+ // src/lib/mysql/schemas/communication/communication-channel.ts
1929
+ var import_mysql_core29 = require("drizzle-orm/mysql-core");
1930
+ function getCommunicationChannelSchema(mysqlTable) {
1931
+ return mysqlTable("CommunicationChannel", {
1932
+ id: (0, import_mysql_core29.varchar)("id", {
1933
+ length: 255
1934
+ }).notNull().primaryKey(),
1935
+ organizationId: (0, import_mysql_core29.varchar)("organizationId", {
1936
+ length: 191
1937
+ }),
1938
+ name: (0, import_mysql_core29.varchar)("name", {
1939
+ length: 255
1940
+ }).notNull(),
1941
+ description: (0, import_mysql_core29.text)("description"),
1942
+ active: (0, import_mysql_core29.boolean)("active").notNull().default(true),
1943
+ createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
1944
+ mode: "date",
1945
+ fsp: 3
1946
+ }).defaultNow(),
1947
+ updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
1948
+ mode: "date",
1949
+ fsp: 3
1950
+ }).defaultNow(),
1951
+ deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
1952
+ mode: "date",
1953
+ fsp: 3
1954
+ })
1955
+ }, (cc) => ({
1956
+ nameIdx: (0, import_mysql_core29.index)("name_idx").on(cc.name),
1957
+ organizationIdIdx: (0, import_mysql_core29.index)("organizationId_idx").on(cc.organizationId)
1958
+ }));
1959
+ }
1960
+ __name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
1961
+
1962
+ // src/lib/mysql/schemas/communication/communication-preference-types.ts
1963
+ var import_mysql_core30 = require("drizzle-orm/mysql-core");
1964
+ function getCommunicationPreferenceTypesSchema(mysqlTable) {
1965
+ return mysqlTable("CommunicationPreferenceType", {
1966
+ id: (0, import_mysql_core30.varchar)("id", {
1967
+ length: 255
1968
+ }).notNull().primaryKey(),
1969
+ organizationId: (0, import_mysql_core30.varchar)("organizationId", {
1970
+ length: 191
1971
+ }),
1972
+ name: (0, import_mysql_core30.varchar)("name", {
1973
+ length: 255
1974
+ }).notNull(),
1975
+ description: (0, import_mysql_core30.text)("description"),
1976
+ active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
1977
+ createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
1978
+ mode: "date",
1979
+ fsp: 3
1980
+ }).defaultNow(),
1981
+ updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
1982
+ mode: "date",
1983
+ fsp: 3
1984
+ }),
1985
+ deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
1986
+ mode: "date",
1987
+ fsp: 3
1988
+ })
1989
+ });
1990
+ }
1991
+ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSchema");
1992
+
1993
+ // src/lib/mysql/schemas/communication/communication-preferences.ts
1994
+ function getCommunicationPreferencesSchema(mysqlTable) {
1995
+ return mysqlTable("CommunicationPreference", {
1996
+ id: (0, import_mysql_core31.varchar)("id", {
1997
+ length: 255
1998
+ }).notNull().primaryKey(),
1999
+ organizationId: (0, import_mysql_core31.varchar)("organizationId", {
2000
+ length: 191
2001
+ }),
2002
+ userId: (0, import_mysql_core31.varchar)("userId", {
2003
+ length: 255
2004
+ }).notNull(),
2005
+ organizationMembershipId: (0, import_mysql_core31.varchar)("organizationMembershipId", {
2006
+ length: 255
2007
+ }),
2008
+ channelId: (0, import_mysql_core31.varchar)("channelId", {
2009
+ length: 255
2010
+ }).notNull(),
2011
+ preferenceLevel: (0, import_mysql_core31.mysqlEnum)("preferenceLevel", [
2012
+ "low",
2013
+ "medium",
2014
+ "high"
2015
+ ]).notNull().default("medium"),
2016
+ preferenceTypeId: (0, import_mysql_core31.varchar)("preferenceTypeId", {
2017
+ length: 255
2018
+ }).notNull(),
2019
+ active: (0, import_mysql_core31.boolean)("active").notNull().default(true),
2020
+ createdAt: (0, import_mysql_core31.timestamp)("createdAt", {
2021
+ mode: "date",
2022
+ fsp: 3
2023
+ }).defaultNow(),
2024
+ optInAt: (0, import_mysql_core31.timestamp)("optInAt", {
2025
+ mode: "date",
2026
+ fsp: 3
2027
+ }),
2028
+ optOutAt: (0, import_mysql_core31.timestamp)("optOutAt", {
2029
+ mode: "date",
2030
+ fsp: 3
2031
+ }),
2032
+ updatedAt: (0, import_mysql_core31.timestamp)("updatedAt", {
2033
+ mode: "date",
2034
+ fsp: 3
2035
+ }).defaultNow(),
2036
+ deletedAt: (0, import_mysql_core31.timestamp)("deletedAt", {
2037
+ mode: "date",
2038
+ fsp: 3
2039
+ })
2040
+ }, (cp) => ({
2041
+ userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(cp.userId),
2042
+ preferenceTypeIdx: (0, import_mysql_core31.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
2043
+ channelIdIdx: (0, import_mysql_core31.index)("channelId_idx").on(cp.channelId),
2044
+ organizationMembershipIdIdx: (0, import_mysql_core31.index)("organizationMembershipId_idx").on(cp.organizationMembershipId)
2045
+ }));
2046
+ }
2047
+ __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
2048
+ function getCommunicationPreferencesRelationsSchema(mysqlTable, overrides = {}) {
2049
+ const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
2050
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2051
+ const users = resolveUsersSchema(mysqlTable);
2052
+ const communicationChannel = getCommunicationChannelSchema(mysqlTable);
2053
+ const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
2054
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
2055
+ return (0, import_drizzle_orm27.relations)(communicationPreferences, ({ one }) => ({
2056
+ user: one(users, {
2057
+ fields: [
2058
+ communicationPreferences.userId
2059
+ ],
2060
+ references: [
2061
+ users.id
2062
+ ],
2063
+ relationName: "user"
2064
+ }),
2065
+ organizationMembership: one(organizationMemberships, {
2066
+ fields: [
2067
+ communicationPreferences.organizationMembershipId
2068
+ ],
2069
+ references: [
2070
+ organizationMemberships.id
2071
+ ],
2072
+ relationName: "organizationMembership"
2073
+ }),
2074
+ channel: one(communicationChannel, {
2075
+ fields: [
2076
+ communicationPreferences.channelId
2077
+ ],
2078
+ references: [
2079
+ communicationChannel.id
2080
+ ],
2081
+ relationName: "channel"
2082
+ }),
2083
+ preferenceType: one(communicationPreferenceTypes, {
2084
+ fields: [
2085
+ communicationPreferences.preferenceTypeId
2086
+ ],
2087
+ references: [
2088
+ communicationPreferenceTypes.id
2089
+ ],
2090
+ relationName: "preferenceType"
2091
+ })
2092
+ }));
2093
+ }
2094
+ __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
2095
+
2096
+ // src/lib/mysql/schemas/auth/profiles.ts
2097
+ var import_drizzle_orm28 = require("drizzle-orm");
2098
+ var import_mysql_core32 = require("drizzle-orm/mysql-core");
2099
+ function getProfilesSchema(mysqlTable) {
2100
+ return mysqlTable("Profile", {
2101
+ id: (0, import_mysql_core32.varchar)("id", {
2102
+ length: 255
2103
+ }).notNull().primaryKey(),
2104
+ userId: (0, import_mysql_core32.varchar)("userId", {
2105
+ length: 255
2106
+ }).notNull(),
2107
+ type: (0, import_mysql_core32.varchar)("type", {
2108
+ length: 255
2109
+ }).notNull(),
2110
+ fields: (0, import_mysql_core32.json)("fields").$type().default({}),
2111
+ createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
2112
+ mode: "date",
2113
+ fsp: 3
2114
+ }).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`),
2115
+ updatedAt: (0, import_mysql_core32.timestamp)("updatedAt", {
2116
+ mode: "date",
2117
+ fsp: 3
2118
+ }).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`)
2119
+ }, (profile) => ({
2120
+ userIdIdx: (0, import_mysql_core32.index)("userId_idx").on(profile.userId),
2121
+ uniqueUserType: (0, import_mysql_core32.uniqueIndex)("unique_user_type_idx").on(profile.userId, profile.type)
2122
+ }));
2123
+ }
2124
+ __name(getProfilesSchema, "getProfilesSchema");
2125
+ function getProfilesRelationsSchema(mysqlTable, overrides = {}) {
2126
+ const profiles = getProfilesSchema(mysqlTable);
2127
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2128
+ const users = resolveUsersSchema(mysqlTable);
2129
+ return (0, import_drizzle_orm28.relations)(profiles, ({ one }) => ({
2130
+ user: one(users, {
2131
+ fields: [
2132
+ profiles.userId
2133
+ ],
2134
+ references: [
2135
+ users.id
2136
+ ],
2137
+ relationName: "profiles"
2138
+ })
2139
+ }));
2140
+ }
2141
+ __name(getProfilesRelationsSchema, "getProfilesRelationsSchema");
2142
+
2143
+ // src/lib/mysql/schemas/auth/user-permissions.ts
2144
+ var import_drizzle_orm30 = require("drizzle-orm");
2145
+ var import_mysql_core34 = require("drizzle-orm/mysql-core");
2146
+
2147
+ // src/lib/mysql/schemas/auth/permissions.ts
2148
+ var import_drizzle_orm29 = require("drizzle-orm");
2149
+ var import_mysql_core33 = require("drizzle-orm/mysql-core");
2150
+ function getPermissionsSchema(mysqlTable) {
2151
+ return mysqlTable("Permission", {
2152
+ id: (0, import_mysql_core33.varchar)("id", {
2153
+ length: 255
2154
+ }).notNull().primaryKey(),
2155
+ name: (0, import_mysql_core33.varchar)("name", {
2156
+ length: 255
2157
+ }).notNull().unique(),
2158
+ description: (0, import_mysql_core33.text)("description"),
2159
+ active: (0, import_mysql_core33.boolean)("active").notNull().default(true),
2160
+ createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
2161
+ mode: "date",
2162
+ fsp: 3
2163
+ }).defaultNow(),
2164
+ updatedAt: (0, import_mysql_core33.timestamp)("updatedAt", {
2165
+ mode: "date",
2166
+ fsp: 3
2167
+ }).defaultNow(),
2168
+ deletedAt: (0, import_mysql_core33.timestamp)("deletedAt", {
2169
+ mode: "date",
2170
+ fsp: 3
2171
+ })
2172
+ }, (permission) => ({
2173
+ nameIdx: (0, import_mysql_core33.index)("name_idx").on(permission.name)
2174
+ }));
2175
+ }
2176
+ __name(getPermissionsSchema, "getPermissionsSchema");
2177
+ function getPermissionsRelationsSchema(mysqlTable) {
2178
+ return (0, import_drizzle_orm29.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
2179
+ }
2180
+ __name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
2181
+
2182
+ // src/lib/mysql/schemas/auth/user-permissions.ts
2183
+ function getUserPermissionsSchema(mysqlTable) {
2184
+ return mysqlTable("UserPermission", {
2185
+ userId: (0, import_mysql_core34.varchar)("userId", {
2186
+ length: 255
2187
+ }).notNull(),
2188
+ organizationId: (0, import_mysql_core34.varchar)("organizationId", {
2189
+ length: 191
2190
+ }),
2191
+ permissionId: (0, import_mysql_core34.varchar)("permissionId", {
2192
+ length: 255
2193
+ }).notNull(),
2194
+ active: (0, import_mysql_core34.boolean)("active").notNull().default(true),
2195
+ createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
2196
+ mode: "date",
2197
+ fsp: 3
2198
+ }).defaultNow(),
2199
+ updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
2200
+ mode: "date",
2201
+ fsp: 3
2202
+ }).defaultNow(),
2203
+ deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
2204
+ mode: "date",
2205
+ fsp: 3
2206
+ })
2207
+ }, (up) => ({
2208
+ pk: (0, import_mysql_core34.primaryKey)({
2209
+ columns: [
2210
+ up.userId,
2211
+ up.permissionId
2212
+ ]
2213
+ }),
2214
+ userIdIdx: (0, import_mysql_core34.index)("userId_idx").on(up.userId),
2215
+ permissionIdIdx: (0, import_mysql_core34.index)("permissionId_idx").on(up.permissionId),
2216
+ organizationIdIdx: (0, import_mysql_core34.index)("organizationId_idx").on(up.organizationId)
2217
+ }));
2218
+ }
2219
+ __name(getUserPermissionsSchema, "getUserPermissionsSchema");
2220
+ function getUserPermissionsRelationsSchema(mysqlTable, overrides = {}) {
2221
+ const userPermissions = getUserPermissionsSchema(mysqlTable);
2222
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2223
+ const users = resolveUsersSchema(mysqlTable);
2224
+ const permissions = getPermissionsSchema(mysqlTable);
2225
+ return (0, import_drizzle_orm30.relations)(userPermissions, ({ one }) => ({
2226
+ user: one(users, {
2227
+ fields: [
2228
+ userPermissions.userId
2229
+ ],
2230
+ references: [
2231
+ users.id
2232
+ ],
2233
+ relationName: "user"
2234
+ }),
2235
+ permission: one(permissions, {
2236
+ fields: [
2237
+ userPermissions.permissionId
2238
+ ],
2239
+ references: [
2240
+ permissions.id
2241
+ ],
2242
+ relationName: "permission"
2243
+ })
2244
+ }));
2245
+ }
2246
+ __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
2247
+
2248
+ // src/lib/mysql/schemas/auth/user-prefs.ts
2249
+ var import_drizzle_orm31 = require("drizzle-orm");
2250
+ var import_mysql_core35 = require("drizzle-orm/mysql-core");
2251
+ function getUserPrefsSchema(mysqlTable) {
2252
+ return mysqlTable("UserPrefs", {
2253
+ id: (0, import_mysql_core35.varchar)("id", {
2254
+ length: 191
2255
+ }).notNull(),
2256
+ organizationId: (0, import_mysql_core35.varchar)("organizationId", {
2257
+ length: 191
2258
+ }),
2259
+ type: (0, import_mysql_core35.varchar)("type", {
2260
+ length: 191
2261
+ }).default("Global").notNull(),
2262
+ userId: (0, import_mysql_core35.varchar)("userId", {
2263
+ length: 255
2264
+ }).notNull(),
2265
+ fields: (0, import_mysql_core35.json)("fields").$type().default({}),
2266
+ createdAt: (0, import_mysql_core35.timestamp)("createdAt", {
2267
+ mode: "date",
2268
+ fsp: 3
2269
+ }).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`),
2270
+ updatedAt: (0, import_mysql_core35.timestamp)("updatedAt", {
2271
+ mode: "date",
2272
+ fsp: 3
2273
+ }).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`),
2274
+ deletedAt: (0, import_mysql_core35.timestamp)("deletedAt", {
2275
+ mode: "date",
2276
+ fsp: 3
2277
+ })
2278
+ }, (crr) => ({
2279
+ pk: (0, import_mysql_core35.primaryKey)({
2280
+ columns: [
2281
+ crr.id
2282
+ ]
2283
+ }),
2284
+ crrUserIdIdKey: (0, import_mysql_core35.index)("crr_userIdId_idx").on(crr.userId),
2285
+ organizationIdIdx: (0, import_mysql_core35.index)("organizationId_idx").on(crr.organizationId)
2286
+ }));
2287
+ }
2288
+ __name(getUserPrefsSchema, "getUserPrefsSchema");
2289
+ function getUserPrefsRelationsSchema(mysqlTable, overrides = {}) {
2290
+ const userPrefs = getUserPrefsSchema(mysqlTable);
2291
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2292
+ const user = resolveUsersSchema(mysqlTable);
2293
+ return (0, import_drizzle_orm31.relations)(userPrefs, ({ one }) => ({
2294
+ user: one(user, {
2295
+ fields: [
2296
+ userPrefs.userId
2297
+ ],
2298
+ references: [
2299
+ user.id
2300
+ ],
2301
+ relationName: "user"
2302
+ })
2303
+ }));
2304
+ }
2305
+ __name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
2306
+
2307
+ // src/lib/mysql/schemas/auth/users.ts
2308
+ function getUsersSchema(mysqlTable) {
2309
+ return mysqlTable("User", {
2310
+ id: (0, import_mysql_core36.varchar)("id", {
2311
+ length: 255
2312
+ }).notNull().primaryKey(),
2313
+ name: (0, import_mysql_core36.varchar)("name", {
2314
+ length: 255
2315
+ }),
2316
+ role: (0, import_mysql_core36.varchar)("role", {
2317
+ length: 191
2318
+ }).notNull().default("user"),
2319
+ email: (0, import_mysql_core36.varchar)("email", {
2320
+ length: 255
2321
+ }).notNull().unique(),
2322
+ fields: (0, import_mysql_core36.json)("fields").$type().default({}),
2323
+ emailVerified: (0, import_mysql_core36.timestamp)("emailVerified", {
2324
+ mode: "date",
2325
+ fsp: 3
2326
+ }),
2327
+ image: (0, import_mysql_core36.varchar)("image", {
2328
+ length: 255
2329
+ }),
2330
+ createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
2331
+ mode: "date",
2332
+ fsp: 3
2333
+ }).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`)
2334
+ }, (user) => ({
2335
+ emailIdx: (0, import_mysql_core36.index)("email_idx").on(user.email),
2336
+ roleIdx: (0, import_mysql_core36.index)("role_idx").on(user.role),
2337
+ createdAtIdx: (0, import_mysql_core36.index)("created_at_idx").on(user.createdAt)
2338
+ }));
2339
+ }
2340
+ __name(getUsersSchema, "getUsersSchema");
2341
+ function getUsersRelationsSchema(mysqlTable, overrides = {}) {
2342
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2343
+ const users = resolveUsersSchema(mysqlTable);
2344
+ const profiles = getProfilesSchema(mysqlTable);
2345
+ const accounts = getAccountsSchema(mysqlTable);
2346
+ const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
2347
+ const userRoles = getUserRolesSchema(mysqlTable);
2348
+ const userPermissions = getUserPermissionsSchema(mysqlTable);
2349
+ const contentContributions = getContentContributionsSchema(mysqlTable);
2350
+ const contentResource = getContentResourceSchema(mysqlTable);
2351
+ const purchases = getPurchaseSchema(mysqlTable);
2352
+ const comments = getCommentsSchema(mysqlTable);
2353
+ const userPrefs = getUserPrefsSchema(mysqlTable);
2354
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
2355
+ return (0, import_drizzle_orm32.relations)(users, ({ many, one }) => ({
2356
+ profiles: many(profiles, {
2357
+ relationName: "profiles"
2358
+ }),
2359
+ accounts: many(accounts, {
2360
+ relationName: "user"
2361
+ }),
2362
+ purchases: many(purchases, {
2363
+ relationName: "user"
2364
+ }),
2365
+ communicationPreferences: many(communicationPreferences, {
2366
+ relationName: "user"
2367
+ }),
2368
+ roles: many(userRoles, {
2369
+ relationName: "user"
2370
+ }),
2371
+ userPermissions: many(userPermissions, {
2372
+ relationName: "user"
2373
+ }),
2374
+ contributions: many(contentContributions, {
2375
+ relationName: "user"
2376
+ }),
2377
+ createdContent: many(contentResource, {
2378
+ relationName: "user"
2379
+ }),
2380
+ comments: many(comments, {
2381
+ relationName: "user"
2382
+ }),
2383
+ prefs: many(userPrefs, {
2384
+ relationName: "user"
2385
+ }),
2386
+ organizationMemberships: many(organizationMemberships, {
2387
+ relationName: "user"
2388
+ })
2389
+ }));
2390
+ }
2391
+ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
2392
+
2393
+ // src/lib/mysql/schemas/auth/accounts.ts
2394
+ function getAccountsSchema(mysqlTable) {
2395
+ return mysqlTable("Account", {
2396
+ userId: (0, import_mysql_core37.varchar)("userId", {
2397
+ length: 255
2398
+ }).notNull(),
2399
+ type: (0, import_mysql_core37.varchar)("type", {
2400
+ length: 255
2401
+ }).$type().notNull(),
2402
+ provider: (0, import_mysql_core37.varchar)("provider", {
2403
+ length: 255
2404
+ }).notNull(),
2405
+ providerAccountId: (0, import_mysql_core37.varchar)("providerAccountId", {
2406
+ length: 255
2407
+ }).notNull(),
2408
+ refresh_token: (0, import_mysql_core37.text)("refresh_token"),
2409
+ access_token: (0, import_mysql_core37.text)("access_token"),
2410
+ oauth_token: (0, import_mysql_core37.text)("oauth_token"),
2411
+ oauth_token_secret: (0, import_mysql_core37.text)("oauth_token_secret"),
2412
+ expires_at: (0, import_mysql_core37.int)("expires_at"),
2413
+ token_type: (0, import_mysql_core37.varchar)("token_type", {
2414
+ length: 255
2415
+ }),
2416
+ scope: (0, import_mysql_core37.varchar)("scope", {
2417
+ length: 255
2418
+ }),
2419
+ id_token: (0, import_mysql_core37.text)("id_token"),
2420
+ session_state: (0, import_mysql_core37.varchar)("session_state", {
2421
+ length: 255
2422
+ }),
2423
+ refresh_token_expires_in: (0, import_mysql_core37.int)("refresh_token_expires_in")
2424
+ }, (account) => ({
2425
+ pk: (0, import_mysql_core37.primaryKey)({
2426
+ columns: [
2427
+ account.provider,
2428
+ account.providerAccountId
2429
+ ]
2430
+ }),
2431
+ userIdIdx: (0, import_mysql_core37.index)("userId_idx").on(account.userId)
2432
+ }));
2433
+ }
2434
+ __name(getAccountsSchema, "getAccountsSchema");
2435
+ function getAccountsRelationsSchema(mysqlTable, overrides = {}) {
2436
+ const accounts = getAccountsSchema(mysqlTable);
2437
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2438
+ const users = resolveUsersSchema(mysqlTable);
2439
+ return (0, import_drizzle_orm33.relations)(accounts, ({ one }) => ({
2440
+ user: one(users, {
2441
+ fields: [
2442
+ accounts.userId
2443
+ ],
2444
+ references: [
2445
+ users.id
2446
+ ],
2447
+ relationName: "user"
2448
+ })
2449
+ }));
2450
+ }
2451
+ __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
2452
+
2453
+ // src/lib/mysql/schemas/auth/device-access-token.ts
2454
+ var import_drizzle_orm34 = require("drizzle-orm");
2455
+ var import_mysql_core38 = require("drizzle-orm/mysql-core");
2456
+ function getDeviceAccessTokenSchema(mysqlTable) {
2457
+ return mysqlTable("DeviceAccessToken", {
2458
+ token: (0, import_mysql_core38.varchar)("token", {
2459
+ length: 191
2460
+ }).notNull(),
2461
+ userId: (0, import_mysql_core38.varchar)("userId", {
2462
+ length: 191
2463
+ }).notNull(),
2464
+ organizationMembershipId: (0, import_mysql_core38.varchar)("organizationMembershipId", {
2465
+ length: 191
2466
+ }),
2467
+ createdAt: (0, import_mysql_core38.timestamp)("createdAt", {
2468
+ mode: "date",
2469
+ fsp: 3
2470
+ }).default(import_drizzle_orm34.sql`CURRENT_TIMESTAMP(3)`)
2471
+ }, (crr) => ({
2472
+ pk: (0, import_mysql_core38.primaryKey)({
2473
+ columns: [
2474
+ crr.token
2475
+ ]
2476
+ }),
2477
+ userIdIdx: (0, import_mysql_core38.index)("userId_idx").on(crr.userId)
2478
+ }));
2479
+ }
2480
+ __name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
2481
+ function getDeviceAccessTokenRelationsSchema(mysqlTable, overrides = {}) {
2482
+ const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
2483
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2484
+ const user = resolveUsersSchema(mysqlTable);
2485
+ return (0, import_drizzle_orm34.relations)(deviceAccessToken, ({ one }) => ({
2486
+ verifiedBy: one(user, {
2487
+ fields: [
2488
+ deviceAccessToken.userId
2489
+ ],
2490
+ references: [
2491
+ user.id
2492
+ ],
2493
+ relationName: "user"
2494
+ })
2495
+ }));
2496
+ }
2497
+ __name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
2498
+
2499
+ // src/lib/mysql/schemas/auth/device-verification.ts
2500
+ var import_drizzle_orm35 = require("drizzle-orm");
2501
+ var import_mysql_core39 = require("drizzle-orm/mysql-core");
2502
+ function getDeviceVerificationSchema(mysqlTable) {
2503
+ return mysqlTable("DeviceVerification", {
2504
+ verifiedByUserId: (0, import_mysql_core39.varchar)("verifiedByUserId", {
2505
+ length: 255
2506
+ }),
2507
+ deviceCode: (0, import_mysql_core39.varchar)("deviceCode", {
2508
+ length: 191
2509
+ }).notNull(),
2510
+ userCode: (0, import_mysql_core39.text)("userCode").notNull(),
2511
+ expires: (0, import_mysql_core39.timestamp)("expires", {
2512
+ mode: "date",
2513
+ fsp: 3
2514
+ }).notNull(),
2515
+ createdAt: (0, import_mysql_core39.timestamp)("createdAt", {
2516
+ mode: "date",
2517
+ fsp: 3
2518
+ }).default(import_drizzle_orm35.sql`CURRENT_TIMESTAMP(3)`),
2519
+ verifiedAt: (0, import_mysql_core39.timestamp)("verifiedAt", {
2520
+ mode: "date",
2521
+ fsp: 3
2522
+ })
2523
+ }, (crr) => ({
2524
+ pk: (0, import_mysql_core39.primaryKey)({
2525
+ columns: [
2526
+ crr.deviceCode
2527
+ ]
2528
+ })
2529
+ }));
2530
+ }
2531
+ __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
2532
+ function getDeviceVerificationRelationsSchema(mysqlTable, overrides = {}) {
2533
+ const deviceVerification = getDeviceVerificationSchema(mysqlTable);
2534
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2535
+ const user = resolveUsersSchema(mysqlTable);
2536
+ return (0, import_drizzle_orm35.relations)(deviceVerification, ({ one }) => ({
2537
+ verifiedBy: one(user, {
2538
+ fields: [
2539
+ deviceVerification.verifiedByUserId
2540
+ ],
2541
+ references: [
2542
+ user.id
2543
+ ],
2544
+ relationName: "user"
2545
+ })
2546
+ }));
2547
+ }
2548
+ __name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
2549
+
2550
+ // src/lib/mysql/schemas/auth/personal-access-token.ts
2551
+ var import_drizzle_orm36 = require("drizzle-orm");
2552
+ var import_mysql_core40 = require("drizzle-orm/mysql-core");
2553
+ function getPersonalAccessTokenSchema(mysqlTable) {
2554
+ return mysqlTable("PersonalAccessToken", {
2555
+ id: (0, import_mysql_core40.varchar)("id", {
2556
+ length: 191
2557
+ }).notNull(),
2558
+ userId: (0, import_mysql_core40.varchar)("userId", {
2559
+ length: 191
2560
+ }).notNull(),
2561
+ name: (0, import_mysql_core40.varchar)("name", {
2562
+ length: 255
2563
+ }).notNull(),
2564
+ publicId: (0, import_mysql_core40.varchar)("publicId", {
2565
+ length: 64
2566
+ }).notNull(),
2567
+ tokenPrefix: (0, import_mysql_core40.varchar)("tokenPrefix", {
2568
+ length: 128
2569
+ }).notNull(),
2570
+ tokenHash: (0, import_mysql_core40.varchar)("tokenHash", {
2571
+ length: 128
2572
+ }).notNull(),
2573
+ scopes: (0, import_mysql_core40.json)("scopes").$type().notNull(),
2574
+ expiresAt: (0, import_mysql_core40.timestamp)("expiresAt", {
2575
+ mode: "date",
2576
+ fsp: 3
2577
+ }),
2578
+ lastUsedAt: (0, import_mysql_core40.timestamp)("lastUsedAt", {
2579
+ mode: "date",
2580
+ fsp: 3
2581
+ }),
2582
+ revokedAt: (0, import_mysql_core40.timestamp)("revokedAt", {
2583
+ mode: "date",
2584
+ fsp: 3
2585
+ }),
2586
+ createdAt: (0, import_mysql_core40.timestamp)("createdAt", {
2587
+ mode: "date",
2588
+ fsp: 3
2589
+ }).default(import_drizzle_orm36.sql`CURRENT_TIMESTAMP(3)`),
2590
+ updatedAt: (0, import_mysql_core40.timestamp)("updatedAt", {
2591
+ mode: "date",
2592
+ fsp: 3
2593
+ }).default(import_drizzle_orm36.sql`CURRENT_TIMESTAMP(3)`).$onUpdate(() => /* @__PURE__ */ new Date())
2594
+ }, (pat) => ({
2595
+ pk: (0, import_mysql_core40.primaryKey)({
2596
+ columns: [
2597
+ pat.id
2598
+ ]
2599
+ }),
2600
+ publicIdIdx: (0, import_mysql_core40.uniqueIndex)("publicId_idx").on(pat.publicId),
2601
+ tokenHashIdx: (0, import_mysql_core40.uniqueIndex)("tokenHash_idx").on(pat.tokenHash),
2602
+ userIdIdx: (0, import_mysql_core40.index)("userId_idx").on(pat.userId),
2603
+ expiresAtIdx: (0, import_mysql_core40.index)("expiresAt_idx").on(pat.expiresAt),
2604
+ revokedAtIdx: (0, import_mysql_core40.index)("revokedAt_idx").on(pat.revokedAt)
2605
+ }));
2606
+ }
2607
+ __name(getPersonalAccessTokenSchema, "getPersonalAccessTokenSchema");
2608
+ function getPersonalAccessTokenRelationsSchema(mysqlTable, overrides = {}) {
2609
+ const personalAccessToken = getPersonalAccessTokenSchema(mysqlTable);
2610
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2611
+ const user = resolveUsersSchema(mysqlTable);
2612
+ return (0, import_drizzle_orm36.relations)(personalAccessToken, ({ one }) => ({
2613
+ user: one(user, {
2614
+ fields: [
2615
+ personalAccessToken.userId
2616
+ ],
2617
+ references: [
2618
+ user.id
2619
+ ],
2620
+ relationName: "user"
2621
+ })
2622
+ }));
2623
+ }
2624
+ __name(getPersonalAccessTokenRelationsSchema, "getPersonalAccessTokenRelationsSchema");
2625
+
2626
+ // src/lib/mysql/schemas/auth/role-permissions.ts
2627
+ var import_drizzle_orm37 = require("drizzle-orm");
2628
+ var import_mysql_core41 = require("drizzle-orm/mysql-core");
2629
+ function getRolePermissionsSchema(mysqlTable) {
2630
+ return mysqlTable("RolePermission", {
2631
+ roleId: (0, import_mysql_core41.varchar)("roleId", {
2632
+ length: 255
2633
+ }).notNull(),
2634
+ permissionId: (0, import_mysql_core41.varchar)("permissionId", {
2635
+ length: 255
2636
+ }).notNull(),
2637
+ active: (0, import_mysql_core41.boolean)("active").notNull().default(true),
2638
+ createdAt: (0, import_mysql_core41.timestamp)("createdAt", {
2639
+ mode: "date",
2640
+ fsp: 3
2641
+ }).defaultNow(),
2642
+ updatedAt: (0, import_mysql_core41.timestamp)("updatedAt", {
2643
+ mode: "date",
2644
+ fsp: 3
2645
+ }).defaultNow(),
2646
+ deletedAt: (0, import_mysql_core41.timestamp)("deletedAt", {
2647
+ mode: "date",
2648
+ fsp: 3
2649
+ })
2650
+ }, (rp) => ({
2651
+ pk: (0, import_mysql_core41.primaryKey)({
2652
+ columns: [
2653
+ rp.roleId,
2654
+ rp.permissionId
2655
+ ]
2656
+ }),
2657
+ roleIdIdx: (0, import_mysql_core41.index)("roleId_idx").on(rp.roleId),
2658
+ permissionIdIdx: (0, import_mysql_core41.index)("permissionId_idx").on(rp.permissionId)
2659
+ }));
2660
+ }
2661
+ __name(getRolePermissionsSchema, "getRolePermissionsSchema");
2662
+ function getRolePermissionsRelationsSchema(mysqlTable) {
2663
+ const permissions = getPermissionsSchema(mysqlTable);
2664
+ const roles = getRolesSchema(mysqlTable);
2665
+ const rolePermissions = getRolePermissionsSchema(mysqlTable);
2666
+ return (0, import_drizzle_orm37.relations)(rolePermissions, ({ one }) => ({
2667
+ role: one(roles, {
2668
+ fields: [
2669
+ rolePermissions.roleId
2670
+ ],
2671
+ references: [
2672
+ roles.id
2673
+ ],
2674
+ relationName: "role"
2675
+ }),
2676
+ permission: one(permissions, {
2677
+ fields: [
2678
+ rolePermissions.permissionId
2679
+ ],
2680
+ references: [
2681
+ permissions.id
2682
+ ],
2683
+ relationName: "permission"
2684
+ })
2685
+ }));
2686
+ }
2687
+ __name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
2688
+
2689
+ // src/lib/mysql/schemas/auth/sessions.ts
2690
+ var import_drizzle_orm38 = require("drizzle-orm");
2691
+ var import_mysql_core42 = require("drizzle-orm/mysql-core");
2692
+ function getSessionsSchema(mysqlTable) {
2693
+ return mysqlTable("Session", {
2694
+ sessionToken: (0, import_mysql_core42.varchar)("sessionToken", {
2695
+ length: 255
2696
+ }).notNull().primaryKey(),
2697
+ userId: (0, import_mysql_core42.varchar)("userId", {
2698
+ length: 255
2699
+ }).notNull(),
2700
+ expires: (0, import_mysql_core42.timestamp)("expires", {
2701
+ mode: "date"
2702
+ }).notNull()
2703
+ }, (session) => ({
2704
+ userIdIdx: (0, import_mysql_core42.index)("userId_idx").on(session.userId)
2705
+ }));
2706
+ }
2707
+ __name(getSessionsSchema, "getSessionsSchema");
2708
+ function getSessionRelationsSchema(mysqlTable, overrides = {}) {
2709
+ const sessions = getSessionsSchema(mysqlTable);
2710
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2711
+ const users = resolveUsersSchema(mysqlTable);
2712
+ return (0, import_drizzle_orm38.relations)(sessions, ({ one }) => ({
2713
+ user: one(users, {
2714
+ fields: [
2715
+ sessions.userId
2716
+ ],
2717
+ references: [
2718
+ users.id
2719
+ ],
2720
+ relationName: "user"
2721
+ })
2722
+ }));
2723
+ }
2724
+ __name(getSessionRelationsSchema, "getSessionRelationsSchema");
2725
+
2726
+ // src/lib/mysql/schemas/auth/verification-tokens.ts
2727
+ var import_mysql_core43 = require("drizzle-orm/mysql-core");
2728
+ function getVerificationTokensSchema(mysqlTable) {
2729
+ return mysqlTable("VerificationToken", {
2730
+ identifier: (0, import_mysql_core43.varchar)("identifier", {
2731
+ length: 255
2732
+ }).notNull(),
2733
+ token: (0, import_mysql_core43.varchar)("token", {
2734
+ length: 255
2735
+ }).notNull(),
2736
+ expires: (0, import_mysql_core43.timestamp)("expires", {
2737
+ mode: "date"
2738
+ }).notNull(),
2739
+ createdAt: (0, import_mysql_core43.timestamp)("createdAt", {
2740
+ mode: "date",
2741
+ fsp: 3
2742
+ }).defaultNow()
2743
+ }, (vt) => ({
2744
+ pk: (0, import_mysql_core43.primaryKey)({
2745
+ columns: [
2746
+ vt.identifier,
2747
+ vt.token
2748
+ ]
2749
+ })
2750
+ }));
2751
+ }
2752
+ __name(getVerificationTokensSchema, "getVerificationTokensSchema");
2753
+
2754
+ // src/lib/mysql/schemas/commerce/merchant-events.ts
2755
+ var import_drizzle_orm39 = require("drizzle-orm");
2756
+ var import_mysql_core44 = require("drizzle-orm/mysql-core");
2757
+ function getMerchantEventsSchema(mysqlTable) {
2758
+ return mysqlTable("MerchantEvents", {
2759
+ id: (0, import_mysql_core44.varchar)("id", {
2760
+ length: 191
2761
+ }).notNull(),
2762
+ merchantAccountId: (0, import_mysql_core44.varchar)("merchantAccountId", {
2763
+ length: 191
2764
+ }).notNull(),
2765
+ identifier: (0, import_mysql_core44.varchar)("identifier", {
2766
+ length: 191
2767
+ }).notNull(),
2768
+ payload: (0, import_mysql_core44.json)("payload").notNull(),
2769
+ createdAt: (0, import_mysql_core44.timestamp)("createdAt", {
2770
+ mode: "date",
2771
+ fsp: 3
2772
+ }).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`).notNull()
2773
+ }, (table) => {
2774
+ return {
2775
+ merchantEventsId: (0, import_mysql_core44.primaryKey)({
2776
+ columns: [
2777
+ table.id
2778
+ ],
2779
+ name: "MerchantEvents_id"
2780
+ }),
2781
+ merchantEventsIdentifierKey: (0, import_mysql_core44.unique)("MerchantEvents_identifier_key").on(table.identifier),
2782
+ merchantAccountIdIdx: (0, import_mysql_core44.index)("merchantAccountId_idx").on(table.merchantAccountId),
2783
+ createdAtIdx: (0, import_mysql_core44.index)("createdAt_idx").on(table.createdAt)
2784
+ };
2785
+ });
2786
+ }
2787
+ __name(getMerchantEventsSchema, "getMerchantEventsSchema");
2788
+ function getMerchantEventsRelationsSchema(mysqlTable) {
2789
+ const merchantEvents = getMerchantEventsSchema(mysqlTable);
2790
+ const merchantAccount = getMerchantAccountSchema(mysqlTable);
2791
+ return (0, import_drizzle_orm39.relations)(merchantEvents, ({ one }) => ({
2792
+ merchantAccount: one(merchantAccount, {
2793
+ fields: [
2794
+ merchantEvents.merchantAccountId
2795
+ ],
2796
+ references: [
2797
+ merchantAccount.id
2798
+ ],
2799
+ relationName: "merchantAccount"
2800
+ })
2801
+ }));
2802
+ }
2803
+ __name(getMerchantEventsRelationsSchema, "getMerchantEventsRelationsSchema");
2804
+
2805
+ // src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
2806
+ var import_drizzle_orm40 = require("drizzle-orm");
2807
+ var import_mysql_core45 = require("drizzle-orm/mysql-core");
2808
+ function getPurchaseUserTransferSchema(mysqlTable) {
2809
+ return mysqlTable("PurchaseUserTransfer", {
2810
+ id: (0, import_mysql_core45.varchar)("id", {
2811
+ length: 191
2812
+ }).notNull(),
2813
+ transferState: (0, import_mysql_core45.mysqlEnum)("transferState", [
2814
+ "AVAILABLE",
2815
+ "INITIATED",
2816
+ "VERIFIED",
2817
+ "CANCELED",
2818
+ "EXPIRED",
2819
+ "CONFIRMED",
2820
+ "COMPLETED"
2821
+ ]).default("AVAILABLE").notNull(),
2822
+ purchaseId: (0, import_mysql_core45.varchar)("purchaseId", {
2823
+ length: 191
2824
+ }).notNull(),
2825
+ organizationId: (0, import_mysql_core45.varchar)("organizationId", {
2826
+ length: 191
2827
+ }),
2828
+ sourceUserId: (0, import_mysql_core45.varchar)("sourceUserId", {
2829
+ length: 191
2830
+ }).notNull(),
2831
+ targetUserId: (0, import_mysql_core45.varchar)("targetUserId", {
2832
+ length: 191
2833
+ }),
2834
+ createdAt: (0, import_mysql_core45.timestamp)("createdAt", {
2835
+ mode: "date",
2836
+ fsp: 3
2837
+ }).default(import_drizzle_orm40.sql`CURRENT_TIMESTAMP(3)`).notNull(),
2838
+ expiresAt: (0, import_mysql_core45.timestamp)("expiresAt", {
2839
+ mode: "date",
2840
+ fsp: 3
2841
+ }),
2842
+ canceledAt: (0, import_mysql_core45.timestamp)("canceledAt", {
2843
+ mode: "date",
2844
+ fsp: 3
2845
+ }),
2846
+ confirmedAt: (0, import_mysql_core45.timestamp)("confirmedAt", {
2847
+ mode: "date",
2848
+ fsp: 3
2849
+ }),
2850
+ completedAt: (0, import_mysql_core45.timestamp)("completedAt", {
2851
+ mode: "date",
2852
+ fsp: 3
2853
+ })
2854
+ }, (table) => {
2855
+ return {
2856
+ purchaseUserTransferId: (0, import_mysql_core45.primaryKey)({
2857
+ columns: [
2858
+ table.id
2859
+ ],
2860
+ name: "PurchaseUserTransfer_id"
2861
+ }),
2862
+ organizationIdIdx: (0, import_mysql_core45.index)("organizationId_idx").on(table.organizationId)
2863
+ };
2864
+ });
2865
+ }
2866
+ __name(getPurchaseUserTransferSchema, "getPurchaseUserTransferSchema");
2867
+ function getPurchaseUserTransferRelationsSchema(mysqlTable, overrides = {}) {
2868
+ const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
2869
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
2870
+ const user = resolveUsersSchema(mysqlTable);
2871
+ const purchase = getPurchaseSchema(mysqlTable);
2872
+ return (0, import_drizzle_orm40.relations)(purchaseUserTransfer, ({ one }) => ({
2873
+ sourceUser: one(user, {
2874
+ fields: [
2875
+ purchaseUserTransfer.sourceUserId
2876
+ ],
2877
+ references: [
2878
+ user.id
2879
+ ],
2880
+ relationName: "sourceUser"
2881
+ }),
2882
+ targetUser: one(user, {
2883
+ fields: [
2884
+ purchaseUserTransfer.targetUserId
2885
+ ],
2886
+ references: [
2887
+ user.id
2888
+ ],
2889
+ relationName: "targetUser"
2890
+ }),
2891
+ purchase: one(purchase, {
2892
+ fields: [
2893
+ purchaseUserTransfer.purchaseId
2894
+ ],
2895
+ references: [
2896
+ purchase.id
2897
+ ],
2898
+ relationName: "purchase"
2899
+ })
2900
+ }));
2901
+ }
2902
+ __name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
2903
+
2904
+ // src/lib/mysql/schemas/commerce/upgradable-products.ts
2905
+ var import_drizzle_orm41 = require("drizzle-orm");
2906
+ var import_mysql_core46 = require("drizzle-orm/mysql-core");
2907
+ function getUpgradableProductsSchema(mysqlTable) {
2908
+ return mysqlTable("UpgradableProducts", {
2909
+ upgradableToId: (0, import_mysql_core46.varchar)("upgradableToId", {
2910
+ length: 255
2911
+ }).notNull(),
2912
+ upgradableFromId: (0, import_mysql_core46.varchar)("upgradableFrom", {
2913
+ length: 255
2914
+ }).notNull(),
2915
+ organizationId: (0, import_mysql_core46.varchar)("organizationId", {
2916
+ length: 191
2917
+ }),
2918
+ position: (0, import_mysql_core46.double)("position").notNull().default(0),
2919
+ metadata: (0, import_mysql_core46.json)("metadata").$type().default({}),
2920
+ createdAt: (0, import_mysql_core46.timestamp)("createdAt", {
2921
+ mode: "date",
2922
+ fsp: 3
2923
+ }).default(import_drizzle_orm41.sql`CURRENT_TIMESTAMP(3)`),
2924
+ updatedAt: (0, import_mysql_core46.timestamp)("updatedAt", {
2925
+ mode: "date",
2926
+ fsp: 3
2927
+ }).default(import_drizzle_orm41.sql`CURRENT_TIMESTAMP(3)`),
2928
+ deletedAt: (0, import_mysql_core46.timestamp)("deletedAt", {
2929
+ mode: "date",
2930
+ fsp: 3
2931
+ })
2932
+ }, (crr) => ({
2933
+ pk: (0, import_mysql_core46.primaryKey)({
2934
+ columns: [
2935
+ crr.upgradableToId,
2936
+ crr.upgradableFromId
2937
+ ]
2938
+ }),
2939
+ upgradableToIdIdx: (0, import_mysql_core46.index)("upgradableFromId_idx").on(crr.upgradableToId),
2940
+ upgradableFromIdIdx: (0, import_mysql_core46.index)("upgradableToId_idx").on(crr.upgradableFromId),
2941
+ organizationIdIdx: (0, import_mysql_core46.index)("organizationId_idx").on(crr.organizationId)
2942
+ }));
2943
+ }
2944
+ __name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
2945
+ function getUpgradableProductsRelationsSchema(mysqlTable) {
2946
+ const product = getProductSchema(mysqlTable);
2947
+ const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
2948
+ return (0, import_drizzle_orm41.relations)(upgradableProduct, ({ one }) => ({
2949
+ upgradableTo: one(product, {
2950
+ fields: [
2951
+ upgradableProduct.upgradableToId
2952
+ ],
2953
+ references: [
2954
+ product.id
2955
+ ],
2956
+ relationName: "upgradableTo"
2957
+ }),
2958
+ upgradableFrom: one(product, {
2959
+ fields: [
2960
+ upgradableProduct.upgradableFromId
2961
+ ],
2962
+ references: [
2963
+ product.id
2964
+ ],
2965
+ relationName: "upgradableFrom"
2966
+ })
2967
+ }));
2968
+ }
2969
+ __name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
2970
+
2971
+ // src/lib/mysql/schemas/communication/question-response.ts
2972
+ var import_drizzle_orm42 = require("drizzle-orm");
2973
+ var import_mysql_core47 = require("drizzle-orm/mysql-core");
2974
+ function getQuestionResponseSchema(mysqlTable) {
2975
+ return mysqlTable("QuestionResponse", {
2976
+ id: (0, import_mysql_core47.varchar)("id", {
2977
+ length: 255
2978
+ }).notNull().primaryKey(),
2979
+ surveyId: (0, import_mysql_core47.varchar)("surveyId", {
2980
+ length: 255
2981
+ }).notNull(),
2982
+ questionId: (0, import_mysql_core47.varchar)("questionId", {
2983
+ length: 255
2984
+ }).notNull(),
2985
+ respondentKey: (0, import_mysql_core47.varchar)("respondentKey", {
2986
+ length: 255
2987
+ }),
2988
+ surveySessionId: (0, import_mysql_core47.varchar)("surveySessionId", {
2989
+ length: 255
2990
+ }),
2991
+ userId: (0, import_mysql_core47.varchar)("userId", {
2992
+ length: 255
2993
+ }),
2994
+ emailListSubscriberId: (0, import_mysql_core47.varchar)("emailListSubscriberId", {
2995
+ length: 255
2996
+ }),
2997
+ fields: (0, import_mysql_core47.json)("fields").$type().default({}),
2998
+ createdAt: (0, import_mysql_core47.timestamp)("createdAt", {
2999
+ mode: "date",
3000
+ fsp: 3
3001
+ }).default(import_drizzle_orm42.sql`CURRENT_TIMESTAMP(3)`),
3002
+ updatedAt: (0, import_mysql_core47.timestamp)("updatedAt", {
3003
+ mode: "date",
3004
+ fsp: 3
3005
+ }).default(import_drizzle_orm42.sql`CURRENT_TIMESTAMP(3)`),
3006
+ deletedAt: (0, import_mysql_core47.timestamp)("deletedAt", {
3007
+ mode: "date",
3008
+ fsp: 3
3009
+ })
3010
+ }, (qr) => ({
3011
+ surveyIdIdx: (0, import_mysql_core47.index)("surveyId_idx").on(qr.surveyId),
3012
+ questionIdIdx: (0, import_mysql_core47.index)("questionId_idx").on(qr.questionId),
3013
+ respondentKeyIdx: (0, import_mysql_core47.index)("respondent_key_idx").on(qr.respondentKey),
3014
+ surveySessionIdIdx: (0, import_mysql_core47.index)("survey_session_id_idx").on(qr.surveySessionId),
3015
+ userIdIdx: (0, import_mysql_core47.index)("userId_idx").on(qr.userId),
3016
+ emailListSubscriberIdIdx: (0, import_mysql_core47.index)("emailListSubscriberId_idx").on(qr.emailListSubscriberId),
3017
+ surveySubscriberIdx: (0, import_mysql_core47.index)("survey_subscriber_idx").on(qr.surveyId, qr.emailListSubscriberId),
3018
+ surveyQuestionRespondentIdx: (0, import_mysql_core47.uniqueIndex)("survey_question_respondent_unique").on(qr.surveyId, qr.questionId, qr.respondentKey)
3019
+ }));
3020
+ }
3021
+ __name(getQuestionResponseSchema, "getQuestionResponseSchema");
3022
+ function getQuestionResponseRelationsSchema(mysqlTable, overrides = {}) {
3023
+ const questionResponse = getQuestionResponseSchema(mysqlTable);
3024
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
3025
+ const users = resolveUsersSchema(mysqlTable);
3026
+ const contentResource = getContentResourceSchema(mysqlTable);
3027
+ return (0, import_drizzle_orm42.relations)(questionResponse, ({ one }) => ({
3028
+ user: one(users, {
3029
+ fields: [
3030
+ questionResponse.userId
3031
+ ],
3032
+ references: [
3033
+ users.id
3034
+ ],
3035
+ relationName: "questionResponseUser"
3036
+ }),
3037
+ survey: one(contentResource, {
3038
+ fields: [
3039
+ questionResponse.surveyId
3040
+ ],
3041
+ references: [
3042
+ contentResource.id
3043
+ ],
3044
+ relationName: "questionResponseSurvey"
3045
+ }),
3046
+ question: one(contentResource, {
3047
+ fields: [
3048
+ questionResponse.questionId
3049
+ ],
3050
+ references: [
3051
+ contentResource.id
3052
+ ],
3053
+ relationName: "questionResponseQuestion"
3054
+ })
3055
+ }));
3056
+ }
3057
+ __name(getQuestionResponseRelationsSchema, "getQuestionResponseRelationsSchema");
3058
+
3059
+ // src/lib/mysql/schemas/content/lesson-progress.ts
3060
+ var import_drizzle_orm43 = require("drizzle-orm");
3061
+ var import_mysql_core48 = require("drizzle-orm/mysql-core");
3062
+ function getLessonProgressSchema(mysqlTable) {
3063
+ return mysqlTable("LessonProgress", {
3064
+ id: (0, import_mysql_core48.varchar)("id", {
3065
+ length: 191
3066
+ }).notNull().primaryKey(),
3067
+ userId: (0, import_mysql_core48.varchar)("userId", {
3068
+ length: 191
3069
+ }).notNull(),
3070
+ organizationId: (0, import_mysql_core48.varchar)("organizationId", {
3071
+ length: 191
3072
+ }),
3073
+ organizationMembershipId: (0, import_mysql_core48.varchar)("organizationMembershipId", {
3074
+ length: 191
3075
+ }),
3076
+ lessonId: (0, import_mysql_core48.varchar)("lessonId", {
3077
+ length: 191
3078
+ }),
3079
+ lessonSlug: (0, import_mysql_core48.varchar)("lessonSlug", {
3080
+ length: 191
3081
+ }),
3082
+ lessonVersion: (0, import_mysql_core48.varchar)("lessonVersion", {
3083
+ length: 191
3084
+ }),
3085
+ sectionId: (0, import_mysql_core48.varchar)("sectionId", {
3086
+ length: 191
3087
+ }),
3088
+ moduleId: (0, import_mysql_core48.varchar)("moduleId", {
3089
+ length: 191
3090
+ }),
3091
+ completedAt: (0, import_mysql_core48.datetime)("completedAt", {
3092
+ mode: "date",
3093
+ fsp: 3
3094
+ }),
3095
+ updatedAt: (0, import_mysql_core48.datetime)("updatedAt", {
3096
+ mode: "date",
3097
+ fsp: 3
3098
+ }),
3099
+ createdAt: (0, import_mysql_core48.datetime)("createdAt", {
3100
+ mode: "date",
3101
+ fsp: 3
3102
+ }).default(import_drizzle_orm43.sql`CURRENT_TIMESTAMP(3)`).notNull()
3103
+ }, (crp) => {
3104
+ return {
3105
+ userIdLessonIdIdx: (0, import_mysql_core48.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
3106
+ userIdIdx: (0, import_mysql_core48.index)("userId_idx").on(crp.userId),
3107
+ lessonIdIdx: (0, import_mysql_core48.index)("lessonId_idx").on(crp.lessonId),
3108
+ organizationMembershipIdIdx: (0, import_mysql_core48.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
3109
+ };
3110
+ });
3111
+ }
3112
+ __name(getLessonProgressSchema, "getLessonProgressSchema");
3113
+
3114
+ // src/lib/mysql/schemas/content/resource-progress.ts
3115
+ var import_drizzle_orm44 = require("drizzle-orm");
3116
+ var import_mysql_core49 = require("drizzle-orm/mysql-core");
3117
+ function getResourceProgressSchema(mysqlTable) {
3118
+ return mysqlTable("ResourceProgress", {
3119
+ userId: (0, import_mysql_core49.varchar)("userId", {
3120
+ length: 255
3121
+ }).notNull(),
3122
+ organizationId: (0, import_mysql_core49.varchar)("organizationId", {
3123
+ length: 191
3124
+ }),
3125
+ organizationMembershipId: (0, import_mysql_core49.varchar)("organizationMembershipId", {
3126
+ length: 191
3127
+ }),
3128
+ resourceId: (0, import_mysql_core49.varchar)("resourceId", {
3129
+ length: 255
3130
+ }),
3131
+ fields: (0, import_mysql_core49.json)("fields").$type().default({}),
3132
+ completedAt: (0, import_mysql_core49.datetime)("completedAt", {
3133
+ mode: "date",
3134
+ fsp: 3
3135
+ }),
3136
+ updatedAt: (0, import_mysql_core49.datetime)("updatedAt", {
3137
+ mode: "date",
3138
+ fsp: 3
3139
+ }),
3140
+ createdAt: (0, import_mysql_core49.datetime)("createdAt", {
3141
+ mode: "date",
3142
+ fsp: 3
3143
+ }).default(import_drizzle_orm44.sql`CURRENT_TIMESTAMP(3)`).notNull()
3144
+ }, (crp) => {
3145
+ return {
3146
+ userIdLessonIdIdx: (0, import_mysql_core49.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
3147
+ pk: (0, import_mysql_core49.primaryKey)({
3148
+ columns: [
3149
+ crp.userId,
3150
+ crp.resourceId
3151
+ ]
3152
+ }),
3153
+ contentResourceIdIdx: (0, import_mysql_core49.index)("contentResourceId_idx").on(crp.resourceId),
3154
+ userIdIdx: (0, import_mysql_core49.index)("resourceId_idx").on(crp.userId),
3155
+ organizationMembershipIdIdx: (0, import_mysql_core49.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
3156
+ };
3157
+ });
3158
+ }
3159
+ __name(getResourceProgressSchema, "getResourceProgressSchema");
3160
+
3161
+ // src/lib/mysql/schemas/entitlements/entitlement-type.ts
3162
+ var import_mysql_core50 = require("drizzle-orm/mysql-core");
3163
+ function getEntitlementTypesSchema(mysqlTable) {
3164
+ return mysqlTable("EntitlementType", {
3165
+ id: (0, import_mysql_core50.varchar)("id", {
3166
+ length: 191
3167
+ }).notNull().primaryKey(),
3168
+ name: (0, import_mysql_core50.varchar)("name", {
3169
+ length: 255
3170
+ }).notNull(),
3171
+ description: (0, import_mysql_core50.text)("description")
3172
+ }, (table) => ({
3173
+ uniqueName: (0, import_mysql_core50.uniqueIndex)("unique_name_idx").on(table.name)
3174
+ }));
3175
+ }
3176
+ __name(getEntitlementTypesSchema, "getEntitlementTypesSchema");
3177
+
3178
+ // src/lib/mysql/schemas/entitlements/entitlement.ts
3179
+ var import_drizzle_orm45 = require("drizzle-orm");
3180
+ var import_mysql_core51 = require("drizzle-orm/mysql-core");
3181
+ function getEntitlementsSchema(mysqlTable) {
3182
+ return mysqlTable("Entitlement", {
3183
+ id: (0, import_mysql_core51.varchar)("id", {
3184
+ length: 191
3185
+ }).notNull().primaryKey(),
3186
+ entitlementType: (0, import_mysql_core51.varchar)("entitlementType", {
3187
+ length: 255
3188
+ }).notNull(),
3189
+ userId: (0, import_mysql_core51.varchar)("userId", {
3190
+ length: 191
3191
+ }),
3192
+ organizationId: (0, import_mysql_core51.varchar)("organizationId", {
3193
+ length: 191
3194
+ }),
3195
+ organizationMembershipId: (0, import_mysql_core51.varchar)("organizationMembershipId", {
3196
+ length: 191
3197
+ }),
3198
+ sourceType: (0, import_mysql_core51.varchar)("sourceType", {
3199
+ length: 255
3200
+ }).notNull(),
3201
+ sourceId: (0, import_mysql_core51.varchar)("sourceId", {
3202
+ length: 191
3203
+ }).notNull(),
3204
+ metadata: (0, import_mysql_core51.json)("metadata").$type().default({}),
3205
+ expiresAt: (0, import_mysql_core51.timestamp)("expiresAt", {
3206
+ mode: "date",
3207
+ fsp: 3
3208
+ }),
3209
+ createdAt: (0, import_mysql_core51.timestamp)("createdAt", {
3210
+ mode: "date",
3211
+ fsp: 3
3212
+ }).default(import_drizzle_orm45.sql`CURRENT_TIMESTAMP(3)`).notNull(),
3213
+ updatedAt: (0, import_mysql_core51.timestamp)("updatedAt", {
3214
+ mode: "date",
3215
+ fsp: 3
3216
+ }).default(import_drizzle_orm45.sql`CURRENT_TIMESTAMP(3)`).notNull(),
3217
+ deletedAt: (0, import_mysql_core51.timestamp)("deletedAt", {
3218
+ mode: "date",
3219
+ fsp: 3
3220
+ })
3221
+ }, (table) => ({
3222
+ userIdIdx: (0, import_mysql_core51.index)("userId_idx").on(table.userId),
3223
+ orgIdIdx: (0, import_mysql_core51.index)("orgId_idx").on(table.organizationId),
3224
+ sourceIdx: (0, import_mysql_core51.index)("source_idx").on(table.sourceType, table.sourceId),
3225
+ typeIdx: (0, import_mysql_core51.index)("type_idx").on(table.entitlementType),
3226
+ userIdTypeDeletedAtIdx: (0, import_mysql_core51.index)("idx_Entitlement_on_userId_type_deletedAt").on(table.userId, table.entitlementType, table.deletedAt)
3227
+ }));
3228
+ }
3229
+ __name(getEntitlementsSchema, "getEntitlementsSchema");
3230
+ function getEntitlementRelationsSchema(mysqlTable, overrides = {}) {
3231
+ const entitlements = getEntitlementsSchema(mysqlTable);
3232
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
3233
+ const users = resolveUsersSchema(mysqlTable);
3234
+ const orgs = getOrganizationsSchema(mysqlTable);
3235
+ const memberships = getOrganizationMembershipsSchema(mysqlTable);
3236
+ return (0, import_drizzle_orm45.relations)(entitlements, ({ one }) => ({
3237
+ user: one(users, {
3238
+ fields: [
3239
+ entitlements.userId
3240
+ ],
3241
+ references: [
3242
+ users.id
3243
+ ]
3244
+ }),
3245
+ organization: one(orgs, {
3246
+ fields: [
3247
+ entitlements.organizationId
3248
+ ],
3249
+ references: [
3250
+ orgs.id
3251
+ ]
3252
+ }),
3253
+ membership: one(memberships, {
3254
+ fields: [
3255
+ entitlements.organizationMembershipId
3256
+ ],
3257
+ references: [
3258
+ memberships.id
3259
+ ]
3260
+ })
3261
+ }));
3262
+ }
3263
+ __name(getEntitlementRelationsSchema, "getEntitlementRelationsSchema");
3264
+
3265
+ // src/lib/mysql/schema.ts
3266
+ function getCourseBuilderSchema(mysqlTable, overrides = {}) {
3267
+ const resolvedGetUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
3268
+ const userRelationsOverrides = {
3269
+ getUsersSchema: resolvedGetUsersSchema
3270
+ };
3271
+ return {
3272
+ accounts: getAccountsSchema(mysqlTable),
3273
+ accountsRelations: getAccountsRelationsSchema(mysqlTable, userRelationsOverrides),
3274
+ permissions: getPermissionsSchema(mysqlTable),
3275
+ permissionsRelations: getPermissionsRelationsSchema(mysqlTable),
3276
+ rolePermissions: getRolePermissionsSchema(mysqlTable),
3277
+ rolePermissionsRelations: getRolePermissionsRelationsSchema(mysqlTable),
3278
+ roles: getRolesSchema(mysqlTable),
3279
+ rolesRelations: getRolesRelationsSchema(mysqlTable),
3280
+ sessions: getSessionsSchema(mysqlTable),
3281
+ sessionsRelations: getSessionRelationsSchema(mysqlTable, userRelationsOverrides),
3282
+ userPermissions: getUserPermissionsSchema(mysqlTable),
3283
+ userPermissionsRelations: getUserPermissionsRelationsSchema(mysqlTable, userRelationsOverrides),
3284
+ userRoles: getUserRolesSchema(mysqlTable),
3285
+ userRolesRelations: getUserRolesRelationsSchema(mysqlTable, userRelationsOverrides),
3286
+ users: resolvedGetUsersSchema(mysqlTable),
3287
+ usersRelations: getUsersRelationsSchema(mysqlTable, userRelationsOverrides),
3288
+ verificationTokens: getVerificationTokensSchema(mysqlTable),
3289
+ coupon: getCouponSchema(mysqlTable),
3290
+ couponRelations: getCouponRelationsSchema(mysqlTable),
3291
+ lessonProgress: getLessonProgressSchema(mysqlTable),
3292
+ merchantAccount: getMerchantAccountSchema(mysqlTable),
3293
+ merchantCharge: getMerchantChargeSchema(mysqlTable),
3294
+ merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
3295
+ merchantEvents: getMerchantEventsSchema(mysqlTable),
3296
+ merchantEventsRelations: getMerchantEventsRelationsSchema(mysqlTable),
3297
+ merchantCoupon: getMerchantCouponSchema(mysqlTable),
3298
+ merchantCustomer: getMerchantCustomerSchema(mysqlTable),
3299
+ merchantPrice: getMerchantPriceSchema(mysqlTable),
3300
+ merchantProduct: getMerchantProductSchema(mysqlTable),
3301
+ merchantSession: getMerchantSessionSchema(mysqlTable),
3302
+ prices: getPriceSchema(mysqlTable),
3303
+ products: getProductSchema(mysqlTable),
3304
+ purchases: getPurchaseSchema(mysqlTable),
3305
+ purchaseRelations: getPurchaseRelationsSchema(mysqlTable, userRelationsOverrides),
3306
+ purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
3307
+ purchaseUserTransferRelations: getPurchaseUserTransferRelationsSchema(mysqlTable, userRelationsOverrides),
3308
+ communicationChannel: getCommunicationChannelSchema(mysqlTable),
3309
+ communicationPreferenceTypes: getCommunicationPreferenceTypesSchema(mysqlTable),
3310
+ communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
3311
+ communicationPreferencesRelations: getCommunicationPreferencesRelationsSchema(mysqlTable, userRelationsOverrides),
3312
+ contentContributions: getContentContributionsSchema(mysqlTable),
3313
+ contentContributionRelations: getContentContributionRelationsSchema(mysqlTable, userRelationsOverrides),
3314
+ contentResource: getContentResourceSchema(mysqlTable),
3315
+ contentResourceVersion: getContentResourceVersionSchema(mysqlTable),
3316
+ contentResourceVersionRelations: getContentResourceVersionRelationsSchema(mysqlTable, userRelationsOverrides),
3317
+ contentResourceRelations: getContentResourceRelationsSchema(mysqlTable, userRelationsOverrides),
3318
+ contentResourceResource: getContentResourceResourceSchema(mysqlTable),
3319
+ contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
3320
+ contentResourceTag: getContentResourceTagSchema(mysqlTable),
3321
+ contentResourceTagRelations: getContentResourceTagRelationsSchema(mysqlTable),
3322
+ contributionTypes: getContributionTypesSchema(mysqlTable),
3323
+ contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
3324
+ resourceProgress: getResourceProgressSchema(mysqlTable),
3325
+ questionResponse: getQuestionResponseSchema(mysqlTable),
3326
+ questionResponseRelations: getQuestionResponseRelationsSchema(mysqlTable, userRelationsOverrides),
3327
+ upgradableProducts: getUpgradableProductsSchema(mysqlTable),
3328
+ upgradableProductsRelations: getUpgradableProductsRelationsSchema(mysqlTable),
3329
+ contentResourceProduct: getContentResourceProductSchema(mysqlTable),
3330
+ contentResourceProductRelations: getContentResourceProductRelationsSchema(mysqlTable),
3331
+ productRelations: getProductRelationsSchema(mysqlTable),
3332
+ comments: getCommentsSchema(mysqlTable),
3333
+ commentsRelations: getCommentRelationsSchema(mysqlTable, userRelationsOverrides),
3334
+ deviceVerifications: getDeviceVerificationSchema(mysqlTable),
3335
+ deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable, userRelationsOverrides),
3336
+ deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
3337
+ deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
3338
+ personalAccessToken: getPersonalAccessTokenSchema(mysqlTable),
3339
+ personalAccessTokenRelations: getPersonalAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
3340
+ tag: getTagSchema(mysqlTable),
3341
+ tagRelations: getTagRelationsSchema(mysqlTable),
3342
+ tagTag: getTagTagSchema(mysqlTable),
3343
+ tagTagRelations: getTagTagRelationsSchema(mysqlTable),
3344
+ userPrefs: getUserPrefsSchema(mysqlTable),
3345
+ userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable, userRelationsOverrides),
3346
+ organization: getOrganizationsSchema(mysqlTable),
3347
+ organizationRelations: getOrganizationsRelationsSchema(mysqlTable),
3348
+ organizationMemberships: getOrganizationMembershipsSchema(mysqlTable),
3349
+ organizationMembershipRelations: getOrganizationMembershipsRelationsSchema(mysqlTable, userRelationsOverrides),
3350
+ organizationMembershipRoles: getOrganizationMembershipRolesSchema(mysqlTable),
3351
+ organizationMembershipRolesRelations: getOrganizationMembershipRolesRelationsSchema(mysqlTable),
3352
+ merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
3353
+ merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
3354
+ subscription: getSubscriptionSchema(mysqlTable),
3355
+ subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
3356
+ profiles: getProfilesSchema(mysqlTable),
3357
+ profilesRelations: getProfilesRelationsSchema(mysqlTable, userRelationsOverrides),
3358
+ entitlementTypes: getEntitlementTypesSchema(mysqlTable),
3359
+ entitlements: getEntitlementsSchema(mysqlTable),
3360
+ entitlementsRelations: getEntitlementRelationsSchema(mysqlTable, userRelationsOverrides)
3361
+ };
3362
+ }
3363
+ __name(getCourseBuilderSchema, "getCourseBuilderSchema");
3364
+ function createTables(mySqlTable) {
3365
+ return getCourseBuilderSchema(mySqlTable);
3366
+ }
3367
+ __name(createTables, "createTables");
3368
+ // Annotate the CommonJS export names for ESM import in node:
3369
+ 0 && (module.exports = {
3370
+ createTables,
3371
+ getCourseBuilderSchema
3372
+ });
3373
+ //# sourceMappingURL=schema.cjs.map