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