@coursebuilder/adapter-drizzle 0.5.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/dist/{chunk-QPXUGIXO.js → chunk-3WYG5OE7.js} +2 -2
  2. package/dist/{chunk-UK6EHYS5.js → chunk-5XTOCFDB.js} +5 -2
  3. package/dist/{chunk-2UU2F4DM.js → chunk-6MRFUIH5.js} +6 -2
  4. package/dist/{chunk-XIGJFVUM.js → chunk-6YPHJWS2.js} +9 -2
  5. package/dist/{chunk-7X7TMG4A.js → chunk-A6XPL665.js} +2 -2
  6. package/dist/{chunk-3NUCFLQJ.js → chunk-BLDW3QUS.js} +7 -3
  7. package/dist/{chunk-QP6YMUQX.js → chunk-DKJO4Y3K.js} +7 -3
  8. package/dist/{chunk-P4VXXTVA.js → chunk-EHRARBRS.js} +4 -1
  9. package/dist/{chunk-YVVXDJHI.js → chunk-ET3QAIY7.js} +9 -2
  10. package/dist/{chunk-KDOSK7KN.js → chunk-GAKWXOAY.js} +2 -2
  11. package/dist/{chunk-4ZWS76VQ.js → chunk-KPBVZ44W.js} +7 -3
  12. package/dist/{chunk-VUS77FG3.js → chunk-L5ZAWSTN.js} +127 -29
  13. package/dist/{chunk-6ON2O6UD.js → chunk-MGZMGDQ5.js} +7 -3
  14. package/dist/{chunk-KDEWFXEP.js → chunk-MP4CUWYC.js} +6 -2
  15. package/dist/chunk-QGZ2F5SW.js +1987 -0
  16. package/dist/{chunk-DAP5KOAO.js → chunk-RCL6HPBL.js} +8 -4
  17. package/dist/chunk-RP66NZN3.js +81 -0
  18. package/dist/{chunk-7ISZNMPU.js → chunk-WFC55BSF.js} +7 -3
  19. package/dist/{chunk-GINRTL6J.js → chunk-WJWJ6E5Y.js} +6 -2
  20. package/dist/{chunk-YGRYHMCG.js → chunk-WPJZAYX7.js} +7 -3
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +20 -20
  23. package/dist/lib/mysql/index.cjs +1621 -721
  24. package/dist/lib/mysql/index.cjs.map +1 -1
  25. package/dist/lib/mysql/index.d.cts +7183 -1606
  26. package/dist/lib/mysql/index.d.ts +7183 -1606
  27. package/dist/lib/mysql/index.js +20 -20
  28. package/dist/lib/mysql/schemas/auth/accounts.cjs +117 -85
  29. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  30. package/dist/lib/mysql/schemas/auth/accounts.d.cts +58 -1
  31. package/dist/lib/mysql/schemas/auth/accounts.d.ts +58 -1
  32. package/dist/lib/mysql/schemas/auth/accounts.js +10 -11
  33. package/dist/lib/mysql/schemas/auth/device-access-token.cjs +112 -77
  34. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  35. package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +28 -0
  36. package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +28 -0
  37. package/dist/lib/mysql/schemas/auth/device-access-token.js +11 -12
  38. package/dist/lib/mysql/schemas/auth/device-verification.cjs +111 -79
  39. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/auth/device-verification.d.cts +24 -0
  41. package/dist/lib/mysql/schemas/auth/device-verification.d.ts +24 -0
  42. package/dist/lib/mysql/schemas/auth/device-verification.js +11 -12
  43. package/dist/lib/mysql/schemas/auth/permissions.d.cts +28 -0
  44. package/dist/lib/mysql/schemas/auth/permissions.d.ts +28 -0
  45. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +110 -74
  46. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  47. package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +24 -0
  48. package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +24 -0
  49. package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -12
  50. package/dist/lib/mysql/schemas/auth/roles.cjs +114 -74
  51. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  52. package/dist/lib/mysql/schemas/auth/roles.d.cts +44 -0
  53. package/dist/lib/mysql/schemas/auth/roles.d.ts +44 -0
  54. package/dist/lib/mysql/schemas/auth/roles.js +10 -11
  55. package/dist/lib/mysql/schemas/auth/sessions.cjs +107 -75
  56. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  57. package/dist/lib/mysql/schemas/auth/sessions.d.cts +12 -0
  58. package/dist/lib/mysql/schemas/auth/sessions.d.ts +12 -0
  59. package/dist/lib/mysql/schemas/auth/sessions.js +11 -12
  60. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +112 -76
  61. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  62. package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +40 -0
  63. package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +40 -0
  64. package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -11
  65. package/dist/lib/mysql/schemas/auth/user-prefs.cjs +116 -80
  66. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  67. package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +44 -0
  68. package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +44 -0
  69. package/dist/lib/mysql/schemas/auth/user-prefs.js +10 -11
  70. package/dist/lib/mysql/schemas/auth/user-roles.cjs +117 -77
  71. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  72. package/dist/lib/mysql/schemas/auth/user-roles.d.cts +40 -0
  73. package/dist/lib/mysql/schemas/auth/user-roles.d.ts +40 -0
  74. package/dist/lib/mysql/schemas/auth/user-roles.js +10 -11
  75. package/dist/lib/mysql/schemas/auth/users.cjs +299 -183
  76. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  77. package/dist/lib/mysql/schemas/auth/users.d.cts +33 -0
  78. package/dist/lib/mysql/schemas/auth/users.d.ts +33 -0
  79. package/dist/lib/mysql/schemas/auth/users.js +10 -11
  80. package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +16 -0
  81. package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +16 -0
  82. package/dist/lib/mysql/schemas/commerce/coupon.cjs +142 -90
  83. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  84. package/dist/lib/mysql/schemas/commerce/coupon.d.cts +64 -0
  85. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +64 -0
  86. package/dist/lib/mysql/schemas/commerce/coupon.js +10 -11
  87. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +5 -1
  88. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
  89. package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +36 -0
  90. package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +36 -0
  91. package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
  92. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +210 -17
  93. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  94. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +65 -0
  95. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +65 -0
  96. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +11 -4
  97. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +5 -1
  98. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
  99. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +40 -0
  100. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +40 -0
  101. package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
  102. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +5 -1
  103. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
  104. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +40 -0
  105. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +40 -0
  106. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
  107. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +5 -1
  108. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
  109. package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +44 -0
  110. package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +44 -0
  111. package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
  112. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +5 -1
  113. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
  114. package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +40 -0
  115. package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +40 -0
  116. package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
  117. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +5 -1
  118. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
  119. package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +28 -0
  120. package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +28 -0
  121. package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
  122. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +315 -0
  123. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -0
  124. package/dist/lib/mysql/schemas/commerce/merchant-subscription.d.cts +161 -0
  125. package/dist/lib/mysql/schemas/commerce/merchant-subscription.d.ts +161 -0
  126. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +20 -0
  127. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js.map +1 -0
  128. package/dist/lib/mysql/schemas/commerce/price.cjs +116 -72
  129. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  130. package/dist/lib/mysql/schemas/commerce/price.d.cts +44 -0
  131. package/dist/lib/mysql/schemas/commerce/price.d.ts +44 -0
  132. package/dist/lib/mysql/schemas/commerce/price.js +10 -11
  133. package/dist/lib/mysql/schemas/commerce/product.cjs +142 -94
  134. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  135. package/dist/lib/mysql/schemas/commerce/product.d.cts +48 -0
  136. package/dist/lib/mysql/schemas/commerce/product.d.ts +48 -0
  137. package/dist/lib/mysql/schemas/commerce/product.js +10 -11
  138. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +149 -105
  139. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  140. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +56 -0
  141. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +56 -0
  142. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +11 -12
  143. package/dist/lib/mysql/schemas/commerce/purchase.cjs +298 -164
  144. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  145. package/dist/lib/mysql/schemas/commerce/purchase.d.cts +102 -0
  146. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +102 -0
  147. package/dist/lib/mysql/schemas/commerce/purchase.js +10 -11
  148. package/dist/lib/mysql/schemas/commerce/subscription.cjs +343 -0
  149. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -0
  150. package/dist/lib/mysql/schemas/commerce/subscription.d.cts +130 -0
  151. package/dist/lib/mysql/schemas/commerce/subscription.d.ts +130 -0
  152. package/dist/lib/mysql/schemas/commerce/subscription.js +20 -0
  153. package/dist/lib/mysql/schemas/commerce/subscription.js.map +1 -0
  154. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +117 -77
  155. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  156. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +44 -0
  157. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +44 -0
  158. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -12
  159. package/dist/lib/mysql/schemas/communication/comment.cjs +156 -79
  160. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  161. package/dist/lib/mysql/schemas/communication/comment.d.cts +45 -0
  162. package/dist/lib/mysql/schemas/communication/comment.d.ts +45 -0
  163. package/dist/lib/mysql/schemas/communication/comment.js +10 -11
  164. package/dist/lib/mysql/schemas/communication/communication-channel.cjs +5 -1
  165. package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
  166. package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +44 -0
  167. package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +44 -0
  168. package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
  169. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +3 -0
  170. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
  171. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +44 -0
  172. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +44 -0
  173. package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
  174. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +183 -96
  175. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  176. package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +77 -0
  177. package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +77 -0
  178. package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -11
  179. package/dist/lib/mysql/schemas/content/content-contributions.cjs +197 -102
  180. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  181. package/dist/lib/mysql/schemas/content/content-contributions.d.cts +65 -0
  182. package/dist/lib/mysql/schemas/content/content-contributions.d.ts +65 -0
  183. package/dist/lib/mysql/schemas/content/content-contributions.js +10 -11
  184. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +120 -69
  185. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  186. package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +44 -0
  187. package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +44 -0
  188. package/dist/lib/mysql/schemas/content/content-resource-product.js +10 -11
  189. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +125 -78
  190. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  191. package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +44 -0
  192. package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +44 -0
  193. package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -11
  194. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +305 -0
  195. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -0
  196. package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +113 -0
  197. package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +113 -0
  198. package/dist/lib/mysql/schemas/content/content-resource-tag.js +20 -0
  199. package/dist/lib/mysql/schemas/content/content-resource-tag.js.map +1 -0
  200. package/dist/lib/mysql/schemas/content/content-resource-version.cjs +315 -0
  201. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -0
  202. package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +146 -0
  203. package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +146 -0
  204. package/dist/lib/mysql/schemas/content/content-resource-version.js +20 -0
  205. package/dist/lib/mysql/schemas/content/content-resource-version.js.map +1 -0
  206. package/dist/lib/mysql/schemas/content/content-resource.cjs +332 -115
  207. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  208. package/dist/lib/mysql/schemas/content/content-resource.d.cts +80 -0
  209. package/dist/lib/mysql/schemas/content/content-resource.d.ts +80 -0
  210. package/dist/lib/mysql/schemas/content/content-resource.js +10 -11
  211. package/dist/lib/mysql/schemas/content/contribution-types.cjs +5 -1
  212. package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
  213. package/dist/lib/mysql/schemas/content/contribution-types.d.cts +48 -0
  214. package/dist/lib/mysql/schemas/content/contribution-types.d.ts +48 -0
  215. package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
  216. package/dist/lib/mysql/schemas/content/lesson-progress.cjs +8 -1
  217. package/dist/lib/mysql/schemas/content/lesson-progress.cjs.map +1 -1
  218. package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +72 -0
  219. package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +72 -0
  220. package/dist/lib/mysql/schemas/content/lesson-progress.js +1 -1
  221. package/dist/lib/mysql/schemas/content/resource-progress.cjs +8 -1
  222. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  223. package/dist/lib/mysql/schemas/content/resource-progress.d.cts +56 -0
  224. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +56 -0
  225. package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
  226. package/dist/lib/mysql/schemas/content/tag-tag.cjs +265 -0
  227. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -0
  228. package/dist/lib/mysql/schemas/content/tag-tag.d.cts +145 -0
  229. package/dist/lib/mysql/schemas/content/tag-tag.d.ts +145 -0
  230. package/dist/lib/mysql/schemas/content/tag-tag.js +20 -0
  231. package/dist/lib/mysql/schemas/content/tag-tag.js.map +1 -0
  232. package/dist/lib/mysql/schemas/content/tag.cjs +291 -0
  233. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -0
  234. package/dist/lib/mysql/schemas/content/tag.d.cts +130 -0
  235. package/dist/lib/mysql/schemas/content/tag.d.ts +130 -0
  236. package/dist/lib/mysql/schemas/content/tag.js +20 -0
  237. package/dist/lib/mysql/schemas/content/tag.js.map +1 -0
  238. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +301 -0
  239. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -0
  240. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +129 -0
  241. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +129 -0
  242. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +21 -0
  243. package/dist/lib/mysql/schemas/org/organization-membership-roles.js.map +1 -0
  244. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +370 -0
  245. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -0
  246. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +131 -0
  247. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +131 -0
  248. package/dist/lib/mysql/schemas/org/organization-memberships.js +20 -0
  249. package/dist/lib/mysql/schemas/org/organization-memberships.js.map +1 -0
  250. package/dist/lib/mysql/schemas/org/organizations.cjs +349 -0
  251. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -0
  252. package/dist/lib/mysql/schemas/org/organizations.d.cts +98 -0
  253. package/dist/lib/mysql/schemas/org/organizations.d.ts +98 -0
  254. package/dist/lib/mysql/schemas/org/organizations.js +20 -0
  255. package/dist/lib/mysql/schemas/org/organizations.js.map +1 -0
  256. package/dist/lib/mysql/utils.d.cts +1 -0
  257. package/dist/lib/mysql/utils.d.ts +1 -0
  258. package/dist/lib/utils.d.cts +1 -0
  259. package/dist/lib/utils.d.ts +1 -0
  260. package/package.json +6 -6
  261. package/src/lib/mysql/index.ts +151 -0
  262. package/src/lib/mysql/schemas/auth/device-access-token.ts +3 -0
  263. package/src/lib/mysql/schemas/auth/roles.ts +3 -0
  264. package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -0
  265. package/src/lib/mysql/schemas/auth/user-prefs.ts +2 -0
  266. package/src/lib/mysql/schemas/auth/user-roles.ts +2 -0
  267. package/src/lib/mysql/schemas/auth/users.ts +5 -0
  268. package/src/lib/mysql/schemas/commerce/coupon.ts +2 -0
  269. package/src/lib/mysql/schemas/commerce/merchant-account.ts +3 -0
  270. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +16 -0
  271. package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +3 -0
  272. package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -0
  273. package/src/lib/mysql/schemas/commerce/merchant-price.ts +3 -0
  274. package/src/lib/mysql/schemas/commerce/merchant-product.ts +3 -0
  275. package/src/lib/mysql/schemas/commerce/merchant-session.ts +8 -1
  276. package/src/lib/mysql/schemas/commerce/merchant-subscription.ts +64 -0
  277. package/src/lib/mysql/schemas/commerce/price.ts +3 -0
  278. package/src/lib/mysql/schemas/commerce/product.ts +3 -0
  279. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +3 -0
  280. package/src/lib/mysql/schemas/commerce/purchase.ts +22 -0
  281. package/src/lib/mysql/schemas/commerce/subscription.ts +71 -0
  282. package/src/lib/mysql/schemas/commerce/upgradable-products.ts +2 -0
  283. package/src/lib/mysql/schemas/communication/comment.ts +13 -0
  284. package/src/lib/mysql/schemas/communication/communication-channel.ts +2 -0
  285. package/src/lib/mysql/schemas/communication/communication-preference-types.ts +1 -0
  286. package/src/lib/mysql/schemas/communication/communication-preferences.ts +14 -0
  287. package/src/lib/mysql/schemas/content/content-contributions.ts +14 -0
  288. package/src/lib/mysql/schemas/content/content-resource-product.ts +2 -0
  289. package/src/lib/mysql/schemas/content/content-resource-resource.ts +2 -0
  290. package/src/lib/mysql/schemas/content/content-resource-tag.ts +61 -0
  291. package/src/lib/mysql/schemas/content/content-resource-version.ts +71 -0
  292. package/src/lib/mysql/schemas/content/content-resource.ts +34 -0
  293. package/src/lib/mysql/schemas/content/contribution-types.ts +2 -0
  294. package/src/lib/mysql/schemas/content/lesson-progress.ts +7 -0
  295. package/src/lib/mysql/schemas/content/resource-progress.ts +7 -0
  296. package/src/lib/mysql/schemas/content/tag-tag.ts +61 -0
  297. package/src/lib/mysql/schemas/content/tag.ts +50 -0
  298. package/src/lib/mysql/schemas/org/organization-membership-roles.ts +68 -0
  299. package/src/lib/mysql/schemas/org/organization-memberships.ts +69 -0
  300. package/src/lib/mysql/schemas/org/organizations.ts +50 -0
  301. package/dist/chunk-SRTIWWLG.js +0 -96
  302. package/dist/chunk-UHH4OVKA.js +0 -1196
@@ -39,8 +39,8 @@ __export(mysql_exports, {
39
39
  module.exports = __toCommonJS(mysql_exports);
40
40
  var import_slugify = __toESM(require("@sindresorhus/slugify"), 1);
41
41
  var import_date_fns2 = require("date-fns");
42
- var import_drizzle_orm32 = require("drizzle-orm");
43
- var import_mysql_core37 = require("drizzle-orm/mysql-core");
42
+ var import_drizzle_orm41 = require("drizzle-orm");
43
+ var import_mysql_core46 = require("drizzle-orm/mysql-core");
44
44
  var import_nanoid = require("nanoid");
45
45
  var import_uuid = require("uuid");
46
46
 
@@ -198,8 +198,8 @@ var ZodIssueCode = util.arrayToEnum([
198
198
  "not_finite"
199
199
  ]);
200
200
  var quotelessJson = /* @__PURE__ */ __name((obj) => {
201
- const json13 = JSON.stringify(obj, null, 2);
202
- return json13.replace(/"([^"]+)":/g, "$1:");
201
+ const json19 = JSON.stringify(obj, null, 2);
202
+ return json19.replace(/"([^"]+)":/g, "$1:");
203
203
  }, "quotelessJson");
204
204
  var _ZodError = class _ZodError extends Error {
205
205
  constructor(issues) {
@@ -2318,10 +2318,10 @@ var _ZodObject = class _ZodObject extends ZodType {
2318
2318
  // }) as any;
2319
2319
  // return merged;
2320
2320
  // }
2321
- catchall(index25) {
2321
+ catchall(index43) {
2322
2322
  return new _ZodObject({
2323
2323
  ...this._def,
2324
- catchall: index25
2324
+ catchall: index43
2325
2325
  });
2326
2326
  }
2327
2327
  pick(mask) {
@@ -2636,9 +2636,9 @@ function mergeValues(a, b) {
2636
2636
  return { valid: false };
2637
2637
  }
2638
2638
  const newArray = [];
2639
- for (let index25 = 0; index25 < a.length; index25++) {
2640
- const itemA = a[index25];
2641
- const itemB = b[index25];
2639
+ for (let index43 = 0; index43 < a.length; index43++) {
2640
+ const itemA = a[index43];
2641
+ const itemB = b[index43];
2642
2642
  const sharedValue = mergeValues(itemA, itemB);
2643
2643
  if (!sharedValue.valid) {
2644
2644
  return { valid: false };
@@ -2850,10 +2850,10 @@ var _ZodMap = class _ZodMap extends ZodType {
2850
2850
  }
2851
2851
  const keyType = this._def.keyType;
2852
2852
  const valueType = this._def.valueType;
2853
- const pairs = [...ctx.data.entries()].map(([key, value], index25) => {
2853
+ const pairs = [...ctx.data.entries()].map(([key, value], index43) => {
2854
2854
  return {
2855
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index25, "key"])),
2856
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index25, "value"]))
2855
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index43, "key"])),
2856
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index43, "value"]))
2857
2857
  };
2858
2858
  });
2859
2859
  if (ctx.common.async) {
@@ -4046,8 +4046,8 @@ var ZodIssueCode2 = util2.arrayToEnum([
4046
4046
  "not_finite"
4047
4047
  ]);
4048
4048
  var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
4049
- const json13 = JSON.stringify(obj, null, 2);
4050
- return json13.replace(/"([^"]+)":/g, "$1:");
4049
+ const json19 = JSON.stringify(obj, null, 2);
4050
+ return json19.replace(/"([^"]+)":/g, "$1:");
4051
4051
  }, "quotelessJson");
4052
4052
  var _a;
4053
4053
  var _ZodError2 = (_a = class extends Error {
@@ -6351,10 +6351,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
6351
6351
  // }) as any;
6352
6352
  // return merged;
6353
6353
  // }
6354
- catchall(index25) {
6354
+ catchall(index43) {
6355
6355
  return new _a18({
6356
6356
  ...this._def,
6357
- catchall: index25
6357
+ catchall: index43
6358
6358
  });
6359
6359
  }
6360
6360
  pick(mask) {
@@ -6696,9 +6696,9 @@ function mergeValues2(a, b) {
6696
6696
  };
6697
6697
  }
6698
6698
  const newArray = [];
6699
- for (let index25 = 0; index25 < a.length; index25++) {
6700
- const itemA = a[index25];
6701
- const itemB = b[index25];
6699
+ for (let index43 = 0; index43 < a.length; index43++) {
6700
+ const itemA = a[index43];
6701
+ const itemB = b[index43];
6702
6702
  const sharedValue = mergeValues2(itemA, itemB);
6703
6703
  if (!sharedValue.valid) {
6704
6704
  return {
@@ -6932,14 +6932,14 @@ var _ZodMap2 = (_a24 = class extends ZodType2 {
6932
6932
  const valueType = this._def.valueType;
6933
6933
  const pairs = [
6934
6934
  ...ctx.data.entries()
6935
- ].map(([key, value], index25) => {
6935
+ ].map(([key, value], index43) => {
6936
6936
  return {
6937
6937
  key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
6938
- index25,
6938
+ index43,
6939
6939
  "key"
6940
6940
  ])),
6941
6941
  value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
6942
- index25,
6942
+ index43,
6943
6943
  "value"
6944
6944
  ]))
6945
6945
  };
@@ -8114,7 +8114,7 @@ var priceSchema = z2.object({
8114
8114
  fields: z2.record(z2.any()).default({})
8115
8115
  });
8116
8116
 
8117
- // ../core/dist/chunk-5BAEWUNU.js
8117
+ // ../core/dist/chunk-SCKAG5RT.js
8118
8118
  var ContentResourceResourceSchema = z2.object({
8119
8119
  resourceId: z2.string(),
8120
8120
  resourceOfId: z2.string(),
@@ -8129,11 +8129,14 @@ var ContentResourceSchema = z2.object({
8129
8129
  id: z2.string(),
8130
8130
  type: z2.string(),
8131
8131
  createdById: z2.string(),
8132
+ currentVersionId: z2.string().nullish(),
8132
8133
  fields: z2.record(z2.string(), z2.any()).default({}).nullable().optional(),
8133
8134
  createdAt: z2.coerce.date().nullable(),
8134
8135
  updatedAt: z2.coerce.date().nullable(),
8135
8136
  deletedAt: z2.coerce.date().nullable(),
8136
- resources: z2.array(ContentResourceResourceSchema).default([]).nullable()
8137
+ resources: z2.array(ContentResourceResourceSchema).default([]).nullable(),
8138
+ organizationId: z2.string().nullable(),
8139
+ createdByOrganizationMembershipId: z2.string().nullable()
8137
8140
  });
8138
8141
  var ContentResourceProductSchema = z2.object({
8139
8142
  resourceId: z2.string(),
@@ -8158,7 +8161,7 @@ var ResourceVisibilitySchema = z2.union([
8158
8161
  z2.literal("unlisted")
8159
8162
  ]);
8160
8163
 
8161
- // ../core/dist/chunk-SVQMPVCK.js
8164
+ // ../core/dist/chunk-E56UB2X2.js
8162
8165
  var productSchema = z2.object({
8163
8166
  id: z2.string().max(191),
8164
8167
  name: z2.string().max(191),
@@ -8224,7 +8227,7 @@ var couponSchema = z2.object({
8224
8227
  bulkPurchaseId: z2.string().max(191).optional().nullable()
8225
8228
  });
8226
8229
 
8227
- // ../core/dist/chunk-5OFQV6YX.js
8230
+ // ../core/dist/chunk-GZ7YLWVN.js
8228
8231
  var purchaseSchema = z2.object({
8229
8232
  id: z2.string().max(191),
8230
8233
  userId: z2.string().max(191).optional().nullable(),
@@ -8273,7 +8276,7 @@ var purchaseUserTransferSchema = z2.object({
8273
8276
  completedAt: z2.date().nullable()
8274
8277
  });
8275
8278
 
8276
- // ../core/dist/chunk-CWQHSOPP.js
8279
+ // ../core/dist/chunk-PG6VF2O6.js
8277
8280
  var resourceProgressSchema = z2.object({
8278
8281
  userId: z2.string().max(191),
8279
8282
  resourceId: z2.string().max(191).optional().nullable(),
@@ -8493,144 +8496,410 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
8493
8496
  }, "validateCoupon");
8494
8497
 
8495
8498
  // src/lib/mysql/schemas/auth/accounts.ts
8496
- var import_drizzle_orm23 = require("drizzle-orm");
8497
- var import_mysql_core27 = require("drizzle-orm/mysql-core");
8499
+ var import_drizzle_orm31 = require("drizzle-orm");
8500
+ var import_mysql_core35 = require("drizzle-orm/mysql-core");
8498
8501
 
8499
8502
  // src/lib/mysql/schemas/auth/users.ts
8500
- var import_drizzle_orm22 = require("drizzle-orm");
8501
- var import_mysql_core26 = require("drizzle-orm/mysql-core");
8503
+ var import_drizzle_orm30 = require("drizzle-orm");
8504
+ var import_mysql_core34 = require("drizzle-orm/mysql-core");
8502
8505
 
8503
8506
  // src/lib/mysql/schemas/commerce/purchase.ts
8504
- var import_drizzle_orm14 = require("drizzle-orm");
8505
- var import_mysql_core16 = require("drizzle-orm/mysql-core");
8507
+ var import_drizzle_orm22 = require("drizzle-orm");
8508
+ var import_mysql_core24 = require("drizzle-orm/mysql-core");
8506
8509
 
8507
- // src/lib/mysql/schemas/commerce/coupon.ts
8508
- var import_drizzle_orm10 = require("drizzle-orm");
8509
- var import_mysql_core11 = require("drizzle-orm/mysql-core");
8510
+ // src/lib/mysql/schemas/org/organization-memberships.ts
8511
+ var import_drizzle_orm20 = require("drizzle-orm");
8512
+ var import_mysql_core20 = require("drizzle-orm/mysql-core");
8510
8513
 
8511
- // src/lib/mysql/schemas/commerce/merchant-coupon.ts
8514
+ // src/lib/mysql/schemas/org/organizations.ts
8515
+ var import_drizzle_orm19 = require("drizzle-orm");
8516
+ var import_mysql_core19 = require("drizzle-orm/mysql-core");
8517
+
8518
+ // src/lib/mysql/schemas/commerce/subscription.ts
8519
+ var import_drizzle_orm18 = require("drizzle-orm");
8520
+ var import_mysql_core18 = require("drizzle-orm/mysql-core");
8521
+
8522
+ // src/lib/mysql/schemas/commerce/merchant-subscription.ts
8523
+ var import_drizzle_orm5 = require("drizzle-orm");
8524
+ var import_mysql_core5 = require("drizzle-orm/mysql-core");
8525
+
8526
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
8527
+ var import_drizzle_orm4 = require("drizzle-orm");
8528
+ var import_mysql_core4 = require("drizzle-orm/mysql-core");
8529
+
8530
+ // src/lib/mysql/schemas/commerce/merchant-account.ts
8531
+ var import_drizzle_orm = require("drizzle-orm");
8512
8532
  var import_mysql_core = require("drizzle-orm/mysql-core");
8513
- function getMerchantCouponSchema(mysqlTable) {
8514
- return mysqlTable("MerchantCoupon", {
8533
+ function getMerchantAccountSchema(mysqlTable) {
8534
+ return mysqlTable("MerchantAccount", {
8515
8535
  id: (0, import_mysql_core.varchar)("id", {
8516
8536
  length: 191
8517
8537
  }).notNull(),
8518
- identifier: (0, import_mysql_core.varchar)("identifier", {
8538
+ organizationId: (0, import_mysql_core.varchar)("organizationId", {
8519
8539
  length: 191
8520
8540
  }),
8521
8541
  status: (0, import_mysql_core.int)("status").default(0).notNull(),
8522
- merchantAccountId: (0, import_mysql_core.varchar)("merchantAccountId", {
8542
+ createdAt: (0, import_mysql_core.timestamp)("createdAt", {
8543
+ mode: "date",
8544
+ fsp: 3
8545
+ }).default(import_drizzle_orm.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8546
+ label: (0, import_mysql_core.varchar)("label", {
8547
+ length: 191
8548
+ }),
8549
+ identifier: (0, import_mysql_core.varchar)("identifier", {
8550
+ length: 191
8551
+ })
8552
+ }, (table) => {
8553
+ return {
8554
+ merchantAccountId: (0, import_mysql_core.primaryKey)({
8555
+ columns: [
8556
+ table.id
8557
+ ],
8558
+ name: "MerchantAccount_id"
8559
+ }),
8560
+ organizationIdIdx: (0, import_mysql_core.index)("organizationId_idx").on(table.organizationId)
8561
+ };
8562
+ });
8563
+ }
8564
+ __name(getMerchantAccountSchema, "getMerchantAccountSchema");
8565
+
8566
+ // src/lib/mysql/schemas/commerce/merchant-customer.ts
8567
+ var import_drizzle_orm2 = require("drizzle-orm");
8568
+ var import_mysql_core2 = require("drizzle-orm/mysql-core");
8569
+ function getMerchantCustomerSchema(mysqlTable) {
8570
+ return mysqlTable("MerchantCustomer", {
8571
+ id: (0, import_mysql_core2.varchar)("id", {
8523
8572
  length: 191
8524
8573
  }).notNull(),
8525
- percentageDiscount: (0, import_mysql_core.decimal)("percentageDiscount", {
8526
- precision: 3,
8527
- scale: 2
8574
+ organizationId: (0, import_mysql_core2.varchar)("organizationId", {
8575
+ length: 191
8576
+ }),
8577
+ userId: (0, import_mysql_core2.varchar)("userId", {
8578
+ length: 191
8579
+ }).notNull(),
8580
+ merchantAccountId: (0, import_mysql_core2.varchar)("merchantAccountId", {
8581
+ length: 191
8582
+ }).notNull(),
8583
+ identifier: (0, import_mysql_core2.varchar)("identifier", {
8584
+ length: 191
8585
+ }).notNull(),
8586
+ createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
8587
+ mode: "date",
8588
+ fsp: 3
8589
+ }).default(import_drizzle_orm2.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8590
+ status: (0, import_mysql_core2.int)("status").default(0)
8591
+ }, (table) => {
8592
+ return {
8593
+ merchantCustomerId: (0, import_mysql_core2.primaryKey)({
8594
+ columns: [
8595
+ table.id
8596
+ ],
8597
+ name: "MerchantCustomer_id"
8598
+ }),
8599
+ merchantCustomerIdentifierKey: (0, import_mysql_core2.unique)("MerchantCustomer_identifier_key").on(table.identifier),
8600
+ userIdIdx: (0, import_mysql_core2.index)("idx_MerchantCustomer_on_userId").on(table.userId),
8601
+ organizationIdIdx: (0, import_mysql_core2.index)("organizationId_idx").on(table.organizationId)
8602
+ };
8603
+ });
8604
+ }
8605
+ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
8606
+
8607
+ // src/lib/mysql/schemas/commerce/merchant-product.ts
8608
+ var import_drizzle_orm3 = require("drizzle-orm");
8609
+ var import_mysql_core3 = require("drizzle-orm/mysql-core");
8610
+ function getMerchantProductSchema(mysqlTable) {
8611
+ return mysqlTable("MerchantProduct", {
8612
+ id: (0, import_mysql_core3.varchar)("id", {
8613
+ length: 191
8614
+ }).notNull(),
8615
+ organizationId: (0, import_mysql_core3.varchar)("organizationId", {
8616
+ length: 191
8617
+ }),
8618
+ merchantAccountId: (0, import_mysql_core3.varchar)("merchantAccountId", {
8619
+ length: 191
8620
+ }).notNull(),
8621
+ productId: (0, import_mysql_core3.varchar)("productId", {
8622
+ length: 191
8623
+ }).notNull(),
8624
+ status: (0, import_mysql_core3.int)("status").default(0).notNull(),
8625
+ identifier: (0, import_mysql_core3.varchar)("identifier", {
8626
+ length: 191
8627
+ }),
8628
+ createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
8629
+ mode: "date",
8630
+ fsp: 3
8631
+ }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`).notNull()
8632
+ }, (table) => {
8633
+ return {
8634
+ merchantProductId: (0, import_mysql_core3.primaryKey)({
8635
+ columns: [
8636
+ table.id
8637
+ ],
8638
+ name: "MerchantProduct_id"
8639
+ }),
8640
+ merchantProductIdentifierKey: (0, import_mysql_core3.unique)("MerchantProduct_identifier_key").on(table.identifier),
8641
+ organizationIdIdx: (0, import_mysql_core3.index)("organizationId_idx").on(table.organizationId)
8642
+ };
8643
+ });
8644
+ }
8645
+ __name(getMerchantProductSchema, "getMerchantProductSchema");
8646
+
8647
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
8648
+ function getMerchantChargeSchema(mysqlTable) {
8649
+ return mysqlTable("MerchantCharge", {
8650
+ id: (0, import_mysql_core4.varchar)("id", {
8651
+ length: 191
8652
+ }).notNull(),
8653
+ organizationId: (0, import_mysql_core4.varchar)("organizationId", {
8654
+ length: 191
8655
+ }),
8656
+ status: (0, import_mysql_core4.int)("status").default(0).notNull(),
8657
+ identifier: (0, import_mysql_core4.varchar)("identifier", {
8658
+ length: 191
8659
+ }).notNull(),
8660
+ userId: (0, import_mysql_core4.varchar)("userId", {
8661
+ length: 191
8662
+ }).notNull(),
8663
+ merchantAccountId: (0, import_mysql_core4.varchar)("merchantAccountId", {
8664
+ length: 191
8665
+ }).notNull(),
8666
+ merchantProductId: (0, import_mysql_core4.varchar)("merchantProductId", {
8667
+ length: 191
8528
8668
  }).notNull(),
8529
- type: (0, import_mysql_core.varchar)("type", {
8669
+ merchantSubscriptionId: (0, import_mysql_core4.varchar)("merchantSubscriptionId", {
8670
+ length: 191
8671
+ }),
8672
+ createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
8673
+ mode: "date",
8674
+ fsp: 3
8675
+ }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8676
+ merchantCustomerId: (0, import_mysql_core4.varchar)("merchantCustomerId", {
8530
8677
  length: 191
8678
+ }).notNull()
8679
+ }, (table) => {
8680
+ return {
8681
+ merchantChargeId: (0, import_mysql_core4.primaryKey)({
8682
+ columns: [
8683
+ table.id
8684
+ ],
8685
+ name: "MerchantCharge_id"
8686
+ }),
8687
+ merchantChargeIdentifierKey: (0, import_mysql_core4.unique)("MerchantCharge_identifier_key").on(table.identifier),
8688
+ merchantSubscriptionIdIdx: (0, import_mysql_core4.index)("merchantSubscriptionId_idx").on(table.merchantSubscriptionId),
8689
+ organizationIdIdx: (0, import_mysql_core4.index)("organizationId_idx").on(table.organizationId)
8690
+ };
8691
+ });
8692
+ }
8693
+ __name(getMerchantChargeSchema, "getMerchantChargeSchema");
8694
+ function getMerchantChargeRelationsSchema(mysqlTable) {
8695
+ const merchantCharge = getMerchantChargeSchema(mysqlTable);
8696
+ const merchantAccount = getMerchantAccountSchema(mysqlTable);
8697
+ const merchantProduct = getMerchantProductSchema(mysqlTable);
8698
+ const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
8699
+ const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
8700
+ return (0, import_drizzle_orm4.relations)(merchantCharge, ({ one }) => ({
8701
+ merchantAccount: one(merchantAccount, {
8702
+ fields: [
8703
+ merchantCharge.merchantAccountId
8704
+ ],
8705
+ references: [
8706
+ merchantAccount.id
8707
+ ],
8708
+ relationName: "merchantAccount"
8709
+ }),
8710
+ merchantProduct: one(merchantProduct, {
8711
+ fields: [
8712
+ merchantCharge.merchantProductId
8713
+ ],
8714
+ references: [
8715
+ merchantProduct.id
8716
+ ],
8717
+ relationName: "merchantProduct"
8718
+ }),
8719
+ merchantCustomer: one(merchantCustomer, {
8720
+ fields: [
8721
+ merchantCharge.merchantCustomerId
8722
+ ],
8723
+ references: [
8724
+ merchantCustomer.id
8725
+ ],
8726
+ relationName: "merchantCustomer"
8727
+ }),
8728
+ merchantSubscription: one(merchantSubscription, {
8729
+ fields: [
8730
+ merchantCharge.merchantSubscriptionId
8731
+ ],
8732
+ references: [
8733
+ merchantSubscription.id
8734
+ ],
8735
+ relationName: "merchantSubscription"
8531
8736
  })
8737
+ }));
8738
+ }
8739
+ __name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
8740
+
8741
+ // src/lib/mysql/schemas/commerce/merchant-subscription.ts
8742
+ function getMerchantSubscriptionSchema(mysqlTable) {
8743
+ return mysqlTable("MerchantSubscription", {
8744
+ id: (0, import_mysql_core5.varchar)("id", {
8745
+ length: 191
8746
+ }).notNull(),
8747
+ organizationId: (0, import_mysql_core5.varchar)("organizationId", {
8748
+ length: 191
8749
+ }),
8750
+ merchantAccountId: (0, import_mysql_core5.varchar)("merchantAccountId", {
8751
+ length: 191
8752
+ }).notNull(),
8753
+ status: (0, import_mysql_core5.int)("status").default(0).notNull(),
8754
+ createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
8755
+ mode: "date",
8756
+ fsp: 3
8757
+ }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8758
+ label: (0, import_mysql_core5.varchar)("label", {
8759
+ length: 191
8760
+ }),
8761
+ identifier: (0, import_mysql_core5.varchar)("identifier", {
8762
+ length: 191
8763
+ }),
8764
+ merchantCustomerId: (0, import_mysql_core5.varchar)("merchantCustomerId", {
8765
+ length: 191
8766
+ }).notNull(),
8767
+ merchantProductId: (0, import_mysql_core5.varchar)("merchantProductId", {
8768
+ length: 191
8769
+ }).notNull()
8532
8770
  }, (table) => {
8533
8771
  return {
8534
- merchantCouponId: (0, import_mysql_core.primaryKey)({
8772
+ merchantSubscriptionId: (0, import_mysql_core5.primaryKey)({
8535
8773
  columns: [
8536
8774
  table.id
8537
8775
  ],
8538
- name: "MerchantCoupon_id"
8776
+ name: "MerchantSubscription_id"
8539
8777
  }),
8540
- merchantCouponIdentifierKey: (0, import_mysql_core.unique)("MerchantCoupon_identifier_key").on(table.identifier)
8778
+ organizationIdIdx: (0, import_mysql_core5.index)("organizationId_idx").on(table.organizationId)
8541
8779
  };
8542
8780
  });
8543
8781
  }
8544
- __name(getMerchantCouponSchema, "getMerchantCouponSchema");
8782
+ __name(getMerchantSubscriptionSchema, "getMerchantSubscriptionSchema");
8783
+ function getMerchantSubscriptionRelationsSchema(mysqlTable) {
8784
+ const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
8785
+ const merchantCharge = getMerchantChargeSchema(mysqlTable);
8786
+ const subscription = getSubscriptionSchema(mysqlTable);
8787
+ return (0, import_drizzle_orm5.relations)(merchantSubscription, ({ many, one }) => ({
8788
+ merchantCharges: many(merchantCharge, {
8789
+ relationName: "merchantSubscription"
8790
+ }),
8791
+ subscription: one(subscription, {
8792
+ fields: [
8793
+ merchantSubscription.id
8794
+ ],
8795
+ references: [
8796
+ subscription.merchantSubscriptionId
8797
+ ],
8798
+ relationName: "subscription"
8799
+ })
8800
+ }));
8801
+ }
8802
+ __name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
8545
8803
 
8546
8804
  // src/lib/mysql/schemas/commerce/product.ts
8547
- var import_drizzle_orm9 = require("drizzle-orm");
8548
- var import_mysql_core10 = require("drizzle-orm/mysql-core");
8805
+ var import_drizzle_orm17 = require("drizzle-orm");
8806
+ var import_mysql_core17 = require("drizzle-orm/mysql-core");
8549
8807
 
8550
8808
  // src/lib/mysql/schemas/content/content-resource-product.ts
8551
- var import_drizzle_orm5 = require("drizzle-orm");
8552
- var import_mysql_core6 = require("drizzle-orm/mysql-core");
8809
+ var import_drizzle_orm14 = require("drizzle-orm");
8810
+ var import_mysql_core14 = require("drizzle-orm/mysql-core");
8553
8811
 
8554
8812
  // src/lib/mysql/schemas/content/content-resource.ts
8555
- var import_drizzle_orm4 = require("drizzle-orm");
8556
- var import_mysql_core5 = require("drizzle-orm/mysql-core");
8813
+ var import_drizzle_orm13 = require("drizzle-orm");
8814
+ var import_mysql_core13 = require("drizzle-orm/mysql-core");
8557
8815
 
8558
8816
  // src/lib/mysql/schemas/content/content-contributions.ts
8559
- var import_drizzle_orm2 = require("drizzle-orm");
8560
- var import_mysql_core3 = require("drizzle-orm/mysql-core");
8817
+ var import_drizzle_orm7 = require("drizzle-orm");
8818
+ var import_mysql_core7 = require("drizzle-orm/mysql-core");
8561
8819
 
8562
8820
  // src/lib/mysql/schemas/content/contribution-types.ts
8563
- var import_drizzle_orm = require("drizzle-orm");
8564
- var import_mysql_core2 = require("drizzle-orm/mysql-core");
8821
+ var import_drizzle_orm6 = require("drizzle-orm");
8822
+ var import_mysql_core6 = require("drizzle-orm/mysql-core");
8565
8823
  function getContributionTypesSchema(mysqlTable) {
8566
8824
  return mysqlTable("ContributionType", {
8567
- id: (0, import_mysql_core2.varchar)("id", {
8825
+ id: (0, import_mysql_core6.varchar)("id", {
8568
8826
  length: 255
8569
8827
  }).notNull().primaryKey(),
8570
- slug: (0, import_mysql_core2.varchar)("slug", {
8828
+ organizationId: (0, import_mysql_core6.varchar)("organizationId", {
8829
+ length: 191
8830
+ }),
8831
+ slug: (0, import_mysql_core6.varchar)("slug", {
8571
8832
  length: 255
8572
8833
  }).notNull().unique(),
8573
- name: (0, import_mysql_core2.varchar)("name", {
8834
+ name: (0, import_mysql_core6.varchar)("name", {
8574
8835
  length: 255
8575
8836
  }).notNull(),
8576
- description: (0, import_mysql_core2.text)("description"),
8577
- active: (0, import_mysql_core2.boolean)("active").notNull().default(true),
8578
- createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
8837
+ description: (0, import_mysql_core6.text)("description"),
8838
+ active: (0, import_mysql_core6.boolean)("active").notNull().default(true),
8839
+ createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
8579
8840
  mode: "date",
8580
8841
  fsp: 3
8581
8842
  }).defaultNow(),
8582
- updatedAt: (0, import_mysql_core2.timestamp)("updatedAt", {
8843
+ updatedAt: (0, import_mysql_core6.timestamp)("updatedAt", {
8583
8844
  mode: "date",
8584
8845
  fsp: 3
8585
8846
  }).defaultNow(),
8586
- deletedAt: (0, import_mysql_core2.timestamp)("deletedAt", {
8847
+ deletedAt: (0, import_mysql_core6.timestamp)("deletedAt", {
8587
8848
  mode: "date",
8588
8849
  fsp: 3
8589
8850
  })
8590
8851
  }, (ct) => ({
8591
- nameIdx: (0, import_mysql_core2.index)("name_idx").on(ct.name),
8592
- slugIdx: (0, import_mysql_core2.index)("slug_idx").on(ct.slug)
8852
+ nameIdx: (0, import_mysql_core6.index)("name_idx").on(ct.name),
8853
+ slugIdx: (0, import_mysql_core6.index)("slug_idx").on(ct.slug),
8854
+ organizationIdIdx: (0, import_mysql_core6.index)("organizationId_idx").on(ct.organizationId)
8593
8855
  }));
8594
8856
  }
8595
8857
  __name(getContributionTypesSchema, "getContributionTypesSchema");
8596
8858
  function getContributionTypesRelationsSchema(mysqlTable) {
8597
8859
  const contributionTypes = getContributionTypesSchema(mysqlTable);
8598
- return (0, import_drizzle_orm.relations)(contributionTypes, ({ many }) => ({}));
8860
+ return (0, import_drizzle_orm6.relations)(contributionTypes, ({ many }) => ({}));
8599
8861
  }
8600
8862
  __name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
8601
8863
 
8602
8864
  // src/lib/mysql/schemas/content/content-contributions.ts
8603
8865
  function getContentContributionsSchema(mysqlTable) {
8604
8866
  return mysqlTable("ContentContribution", {
8605
- id: (0, import_mysql_core3.varchar)("id", {
8867
+ id: (0, import_mysql_core7.varchar)("id", {
8606
8868
  length: 255
8607
8869
  }).notNull().primaryKey(),
8608
- userId: (0, import_mysql_core3.varchar)("userId", {
8870
+ userId: (0, import_mysql_core7.varchar)("userId", {
8609
8871
  length: 255
8610
8872
  }).notNull(),
8611
- contentId: (0, import_mysql_core3.varchar)("contentId", {
8873
+ organizationId: (0, import_mysql_core7.varchar)("organizationId", {
8874
+ length: 191
8875
+ }),
8876
+ organizationMembershipId: (0, import_mysql_core7.varchar)("organizationMembershipId", {
8877
+ length: 255
8878
+ }),
8879
+ contentId: (0, import_mysql_core7.varchar)("contentId", {
8612
8880
  length: 255
8613
8881
  }).notNull(),
8614
- contributionTypeId: (0, import_mysql_core3.varchar)("contributionTypeId", {
8882
+ contributionTypeId: (0, import_mysql_core7.varchar)("contributionTypeId", {
8615
8883
  length: 255
8616
8884
  }).notNull(),
8617
- active: (0, import_mysql_core3.boolean)("active").notNull().default(true),
8618
- createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
8885
+ active: (0, import_mysql_core7.boolean)("active").notNull().default(true),
8886
+ createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
8619
8887
  mode: "date",
8620
8888
  fsp: 3
8621
8889
  }).defaultNow(),
8622
- updatedAt: (0, import_mysql_core3.timestamp)("updatedAt", {
8890
+ updatedAt: (0, import_mysql_core7.timestamp)("updatedAt", {
8623
8891
  mode: "date",
8624
8892
  fsp: 3
8625
8893
  }).defaultNow(),
8626
- deletedAt: (0, import_mysql_core3.timestamp)("deletedAt", {
8894
+ deletedAt: (0, import_mysql_core7.timestamp)("deletedAt", {
8627
8895
  mode: "date",
8628
8896
  fsp: 3
8629
8897
  })
8630
8898
  }, (cc) => ({
8631
- userIdIdx: (0, import_mysql_core3.index)("userId_idx").on(cc.userId),
8632
- contentIdIdx: (0, import_mysql_core3.index)("contentId_idx").on(cc.contentId),
8633
- contributionTypeIdIdx: (0, import_mysql_core3.index)("contributionTypeId_idx").on(cc.contributionTypeId)
8899
+ userIdIdx: (0, import_mysql_core7.index)("userId_idx").on(cc.userId),
8900
+ contentIdIdx: (0, import_mysql_core7.index)("contentId_idx").on(cc.contentId),
8901
+ contributionTypeIdIdx: (0, import_mysql_core7.index)("contributionTypeId_idx").on(cc.contributionTypeId),
8902
+ organizationMembershipIdIdx: (0, import_mysql_core7.index)("organizationMembershipId_idx").on(cc.organizationMembershipId)
8634
8903
  }));
8635
8904
  }
8636
8905
  __name(getContentContributionsSchema, "getContentContributionsSchema");
@@ -8639,7 +8908,8 @@ function getContentContributionRelationsSchema(mysqlTable) {
8639
8908
  const users = getUsersSchema(mysqlTable);
8640
8909
  const contentResource = getContentResourceSchema(mysqlTable);
8641
8910
  const contributionTypes = getContributionTypesSchema(mysqlTable);
8642
- return (0, import_drizzle_orm2.relations)(contentContributions, ({ one }) => ({
8911
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
8912
+ return (0, import_drizzle_orm7.relations)(contentContributions, ({ one }) => ({
8643
8913
  user: one(users, {
8644
8914
  fields: [
8645
8915
  contentContributions.userId
@@ -8666,52 +8936,65 @@ function getContentContributionRelationsSchema(mysqlTable) {
8666
8936
  contributionTypes.id
8667
8937
  ],
8668
8938
  relationName: "contributionType"
8939
+ }),
8940
+ organizationMembership: one(organizationMemberships, {
8941
+ fields: [
8942
+ contentContributions.organizationMembershipId
8943
+ ],
8944
+ references: [
8945
+ organizationMemberships.id
8946
+ ],
8947
+ relationName: "organizationMembership"
8669
8948
  })
8670
8949
  }));
8671
8950
  }
8672
8951
  __name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
8673
8952
 
8674
8953
  // src/lib/mysql/schemas/content/content-resource-resource.ts
8675
- var import_drizzle_orm3 = require("drizzle-orm");
8676
- var import_mysql_core4 = require("drizzle-orm/mysql-core");
8954
+ var import_drizzle_orm8 = require("drizzle-orm");
8955
+ var import_mysql_core8 = require("drizzle-orm/mysql-core");
8677
8956
  function getContentResourceResourceSchema(mysqlTable) {
8678
8957
  return mysqlTable("ContentResourceResource", {
8679
- resourceOfId: (0, import_mysql_core4.varchar)("resourceOfId", {
8958
+ resourceOfId: (0, import_mysql_core8.varchar)("resourceOfId", {
8680
8959
  length: 255
8681
8960
  }).notNull(),
8682
- resourceId: (0, import_mysql_core4.varchar)("resourceId", {
8961
+ resourceId: (0, import_mysql_core8.varchar)("resourceId", {
8683
8962
  length: 255
8684
8963
  }).notNull(),
8685
- position: (0, import_mysql_core4.double)("position").notNull().default(0),
8686
- metadata: (0, import_mysql_core4.json)("metadata").$type().default({}),
8687
- createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
8964
+ position: (0, import_mysql_core8.double)("position").notNull().default(0),
8965
+ metadata: (0, import_mysql_core8.json)("metadata").$type().default({}),
8966
+ organizationId: (0, import_mysql_core8.varchar)("organizationId", {
8967
+ length: 191
8968
+ }),
8969
+ createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
8688
8970
  mode: "date",
8689
8971
  fsp: 3
8690
- }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
8691
- updatedAt: (0, import_mysql_core4.timestamp)("updatedAt", {
8972
+ }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`),
8973
+ updatedAt: (0, import_mysql_core8.timestamp)("updatedAt", {
8692
8974
  mode: "date",
8693
8975
  fsp: 3
8694
- }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
8695
- deletedAt: (0, import_mysql_core4.timestamp)("deletedAt", {
8976
+ }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`),
8977
+ deletedAt: (0, import_mysql_core8.timestamp)("deletedAt", {
8696
8978
  mode: "date",
8697
8979
  fsp: 3
8698
8980
  })
8699
8981
  }, (crr) => ({
8700
- pk: (0, import_mysql_core4.primaryKey)({
8982
+ pk: (0, import_mysql_core8.primaryKey)({
8701
8983
  columns: [
8702
8984
  crr.resourceOfId,
8703
8985
  crr.resourceId
8704
8986
  ]
8705
8987
  }),
8706
- contentResourceIdIdx: (0, import_mysql_core4.index)("contentResourceId_idx").on(crr.resourceOfId),
8707
- resourceIdIdx: (0, import_mysql_core4.index)("resourceId_idx").on(crr.resourceId)
8988
+ contentResourceIdIdx: (0, import_mysql_core8.index)("contentResourceId_idx").on(crr.resourceOfId),
8989
+ resourceIdIdx: (0, import_mysql_core8.index)("resourceId_idx").on(crr.resourceId),
8990
+ organizationIdIdx: (0, import_mysql_core8.index)("organizationId_idx").on(crr.organizationId)
8708
8991
  }));
8709
8992
  }
8710
8993
  __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
8711
8994
  function getContentResourceResourceRelationsSchema(mysqlTable) {
8712
8995
  const contentResource = getContentResourceSchema(mysqlTable);
8713
8996
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
8714
- return (0, import_drizzle_orm3.relations)(contentResourceResource, ({ one }) => ({
8997
+ return (0, import_drizzle_orm8.relations)(contentResourceResource, ({ one }) => ({
8715
8998
  resourceOf: one(contentResource, {
8716
8999
  fields: [
8717
9000
  contentResourceResource.resourceOfId
@@ -8734,35 +9017,304 @@ function getContentResourceResourceRelationsSchema(mysqlTable) {
8734
9017
  }
8735
9018
  __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
8736
9019
 
9020
+ // src/lib/mysql/schemas/content/content-resource-tag.ts
9021
+ var import_drizzle_orm11 = require("drizzle-orm");
9022
+ var import_mysql_core11 = require("drizzle-orm/mysql-core");
9023
+
9024
+ // src/lib/mysql/schemas/content/tag.ts
9025
+ var import_drizzle_orm10 = require("drizzle-orm");
9026
+ var import_mysql_core10 = require("drizzle-orm/mysql-core");
9027
+
9028
+ // src/lib/mysql/schemas/content/tag-tag.ts
9029
+ var import_drizzle_orm9 = require("drizzle-orm");
9030
+ var import_mysql_core9 = require("drizzle-orm/mysql-core");
9031
+ function getTagTagSchema(mysqlTable) {
9032
+ return mysqlTable("TagTag", {
9033
+ parentTagId: (0, import_mysql_core9.varchar)("parentTagId", {
9034
+ length: 255
9035
+ }).notNull(),
9036
+ childTagId: (0, import_mysql_core9.varchar)("childTagId", {
9037
+ length: 255
9038
+ }).notNull(),
9039
+ position: (0, import_mysql_core9.double)("position").notNull().default(0),
9040
+ metadata: (0, import_mysql_core9.json)("metadata").$type().default({}),
9041
+ organizationId: (0, import_mysql_core9.varchar)("organizationId", {
9042
+ length: 191
9043
+ }),
9044
+ createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
9045
+ mode: "date",
9046
+ fsp: 3
9047
+ }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
9048
+ updatedAt: (0, import_mysql_core9.timestamp)("updatedAt", {
9049
+ mode: "date",
9050
+ fsp: 3
9051
+ }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
9052
+ deletedAt: (0, import_mysql_core9.timestamp)("deletedAt", {
9053
+ mode: "date",
9054
+ fsp: 3
9055
+ })
9056
+ }, (tt) => ({
9057
+ pk: (0, import_mysql_core9.primaryKey)({
9058
+ columns: [
9059
+ tt.parentTagId,
9060
+ tt.childTagId
9061
+ ]
9062
+ }),
9063
+ parentTagIdIdx: (0, import_mysql_core9.index)("parentTagId_idx").on(tt.parentTagId),
9064
+ childTagIdIdx: (0, import_mysql_core9.index)("childTagId_idx").on(tt.childTagId),
9065
+ positionIdx: (0, import_mysql_core9.index)("position_idx").on(tt.position),
9066
+ organizationIdIdx: (0, import_mysql_core9.index)("organizationId_idx").on(tt.organizationId)
9067
+ }));
9068
+ }
9069
+ __name(getTagTagSchema, "getTagTagSchema");
9070
+ function getTagTagRelationsSchema(mysqlTable) {
9071
+ const tag = getTagSchema(mysqlTable);
9072
+ const tagTag = getTagTagSchema(mysqlTable);
9073
+ return (0, import_drizzle_orm9.relations)(tagTag, ({ one }) => ({
9074
+ parentTag: one(tag, {
9075
+ fields: [
9076
+ tagTag.parentTagId
9077
+ ],
9078
+ references: [
9079
+ tag.id
9080
+ ],
9081
+ relationName: "parentTag"
9082
+ }),
9083
+ childTag: one(tag, {
9084
+ fields: [
9085
+ tagTag.childTagId
9086
+ ],
9087
+ references: [
9088
+ tag.id
9089
+ ],
9090
+ relationName: "childTag"
9091
+ })
9092
+ }));
9093
+ }
9094
+ __name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
9095
+
9096
+ // src/lib/mysql/schemas/content/tag.ts
9097
+ function getTagSchema(mysqlTable) {
9098
+ return mysqlTable("Tag", {
9099
+ id: (0, import_mysql_core10.varchar)("id", {
9100
+ length: 255
9101
+ }).notNull().primaryKey(),
9102
+ organizationId: (0, import_mysql_core10.varchar)("organizationId", {
9103
+ length: 191
9104
+ }),
9105
+ type: (0, import_mysql_core10.varchar)("type", {
9106
+ length: 255
9107
+ }).notNull(),
9108
+ fields: (0, import_mysql_core10.json)("fields").$type().default({}),
9109
+ createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
9110
+ mode: "date",
9111
+ fsp: 3
9112
+ }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
9113
+ updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
9114
+ mode: "date",
9115
+ fsp: 3
9116
+ }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
9117
+ deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
9118
+ mode: "date",
9119
+ fsp: 3
9120
+ })
9121
+ }, (t) => ({
9122
+ typeIdx: (0, import_mysql_core10.index)("type_idx").on(t.type),
9123
+ organizationIdIdx: (0, import_mysql_core10.index)("organizationId_idx").on(t.organizationId)
9124
+ }));
9125
+ }
9126
+ __name(getTagSchema, "getTagSchema");
9127
+ function getTagRelationsSchema(mysqlTable) {
9128
+ const tag = getTagSchema(mysqlTable);
9129
+ const contentResourceTag = getContentResourceTagSchema(mysqlTable);
9130
+ const tagTag = getTagTagSchema(mysqlTable);
9131
+ return (0, import_drizzle_orm10.relations)(tag, ({ many }) => ({
9132
+ resources: many(contentResourceTag, {
9133
+ relationName: "contentResource"
9134
+ }),
9135
+ parentTags: many(tagTag, {
9136
+ relationName: "childTag"
9137
+ }),
9138
+ childTags: many(tagTag, {
9139
+ relationName: "parentTag"
9140
+ })
9141
+ }));
9142
+ }
9143
+ __name(getTagRelationsSchema, "getTagRelationsSchema");
9144
+
9145
+ // src/lib/mysql/schemas/content/content-resource-tag.ts
9146
+ function getContentResourceTagSchema(mysqlTable) {
9147
+ return mysqlTable("ContentResourceTag", {
9148
+ contentResourceId: (0, import_mysql_core11.varchar)("contentResourceId", {
9149
+ length: 255
9150
+ }).notNull(),
9151
+ organizationId: (0, import_mysql_core11.varchar)("organizationId", {
9152
+ length: 191
9153
+ }),
9154
+ tagId: (0, import_mysql_core11.varchar)("tagId", {
9155
+ length: 255
9156
+ }).notNull(),
9157
+ position: (0, import_mysql_core11.double)("position").notNull().default(0),
9158
+ createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
9159
+ mode: "date",
9160
+ fsp: 3
9161
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
9162
+ updatedAt: (0, import_mysql_core11.timestamp)("updatedAt", {
9163
+ mode: "date",
9164
+ fsp: 3
9165
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`)
9166
+ }, (crt) => ({
9167
+ pk: (0, import_mysql_core11.primaryKey)({
9168
+ columns: [
9169
+ crt.contentResourceId,
9170
+ crt.tagId
9171
+ ]
9172
+ }),
9173
+ contentResourceIdIdx: (0, import_mysql_core11.index)("contentResourceId_idx").on(crt.contentResourceId),
9174
+ tagIdIdx: (0, import_mysql_core11.index)("tagId_idx").on(crt.tagId),
9175
+ positionIdx: (0, import_mysql_core11.index)("position_idx").on(crt.position),
9176
+ organizationIdIdx: (0, import_mysql_core11.index)("organizationId_idx").on(crt.organizationId)
9177
+ }));
9178
+ }
9179
+ __name(getContentResourceTagSchema, "getContentResourceTagSchema");
9180
+ function getContentResourceTagRelationsSchema(mysqlTable) {
9181
+ const contentResource = getContentResourceSchema(mysqlTable);
9182
+ const tag = getTagSchema(mysqlTable);
9183
+ const contentResourceTag = getContentResourceTagSchema(mysqlTable);
9184
+ return (0, import_drizzle_orm11.relations)(contentResourceTag, ({ one }) => ({
9185
+ contentResource: one(contentResource, {
9186
+ fields: [
9187
+ contentResourceTag.contentResourceId
9188
+ ],
9189
+ references: [
9190
+ contentResource.id
9191
+ ],
9192
+ relationName: "contentResource"
9193
+ }),
9194
+ tag: one(tag, {
9195
+ fields: [
9196
+ contentResourceTag.tagId
9197
+ ],
9198
+ references: [
9199
+ tag.id
9200
+ ],
9201
+ relationName: "tag"
9202
+ })
9203
+ }));
9204
+ }
9205
+ __name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
9206
+
9207
+ // src/lib/mysql/schemas/content/content-resource-version.ts
9208
+ var import_drizzle_orm12 = require("drizzle-orm");
9209
+ var import_mysql_core12 = require("drizzle-orm/mysql-core");
9210
+ function getContentResourceVersionSchema(mysqlTable) {
9211
+ return mysqlTable("ContentResourceVersion", {
9212
+ id: (0, import_mysql_core12.varchar)("id", {
9213
+ length: 255
9214
+ }).notNull().primaryKey(),
9215
+ organizationId: (0, import_mysql_core12.varchar)("organizationId", {
9216
+ length: 191
9217
+ }),
9218
+ resourceId: (0, import_mysql_core12.varchar)("resourceId", {
9219
+ length: 255
9220
+ }).notNull(),
9221
+ parentVersionId: (0, import_mysql_core12.varchar)("parentVersionId", {
9222
+ length: 255
9223
+ }),
9224
+ versionNumber: (0, import_mysql_core12.int)("versionNumber").notNull(),
9225
+ fields: (0, import_mysql_core12.json)("fields").$type().default({}),
9226
+ createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
9227
+ mode: "date",
9228
+ fsp: 3
9229
+ }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
9230
+ createdById: (0, import_mysql_core12.varchar)("createdById", {
9231
+ length: 255
9232
+ }).notNull()
9233
+ }, (crv) => ({
9234
+ resourceIdIdx: (0, import_mysql_core12.index)("resourceId_idx").on(crv.resourceId),
9235
+ parentVersionIdIdx: (0, import_mysql_core12.index)("parentVersionId_idx").on(crv.parentVersionId),
9236
+ resourceIdVersionNumberIdx: (0, import_mysql_core12.index)("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
9237
+ uniqueResourceVersion: (0, import_mysql_core12.unique)("uq_resource_version_number").on(crv.resourceId, crv.versionNumber),
9238
+ organizationIdIdx: (0, import_mysql_core12.index)("organizationId_idx").on(crv.organizationId)
9239
+ }));
9240
+ }
9241
+ __name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
9242
+ function getContentResourceVersionRelationsSchema(mysqlTable) {
9243
+ const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
9244
+ const contentResource = getContentResourceSchema(mysqlTable);
9245
+ const users = getUsersSchema(mysqlTable);
9246
+ return (0, import_drizzle_orm12.relations)(contentResourceVersion, ({ one }) => ({
9247
+ resource: one(contentResource, {
9248
+ fields: [
9249
+ contentResourceVersion.resourceId
9250
+ ],
9251
+ references: [
9252
+ contentResource.id
9253
+ ],
9254
+ relationName: "versions"
9255
+ }),
9256
+ parentVersion: one(contentResourceVersion, {
9257
+ fields: [
9258
+ contentResourceVersion.parentVersionId
9259
+ ],
9260
+ references: [
9261
+ contentResourceVersion.id
9262
+ ],
9263
+ relationName: "childVersions"
9264
+ }),
9265
+ createdBy: one(users, {
9266
+ fields: [
9267
+ contentResourceVersion.createdById
9268
+ ],
9269
+ references: [
9270
+ users.id
9271
+ ],
9272
+ relationName: "createdVersions"
9273
+ })
9274
+ }));
9275
+ }
9276
+ __name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelationsSchema");
9277
+
8737
9278
  // src/lib/mysql/schemas/content/content-resource.ts
8738
9279
  function getContentResourceSchema(mysqlTable) {
8739
9280
  return mysqlTable("ContentResource", {
8740
- id: (0, import_mysql_core5.varchar)("id", {
9281
+ id: (0, import_mysql_core13.varchar)("id", {
8741
9282
  length: 255
8742
9283
  }).notNull().primaryKey(),
8743
- type: (0, import_mysql_core5.varchar)("type", {
9284
+ organizationId: (0, import_mysql_core13.varchar)("organizationId", {
9285
+ length: 191
9286
+ }),
9287
+ createdByOrganizationMembershipId: (0, import_mysql_core13.varchar)("createdByOrganizationMembershipId", {
9288
+ length: 191
9289
+ }),
9290
+ type: (0, import_mysql_core13.varchar)("type", {
8744
9291
  length: 255
8745
9292
  }).notNull(),
8746
- createdById: (0, import_mysql_core5.varchar)("createdById", {
9293
+ createdById: (0, import_mysql_core13.varchar)("createdById", {
8747
9294
  length: 255
8748
9295
  }).notNull(),
8749
- fields: (0, import_mysql_core5.json)("fields").$type().default({}),
8750
- createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
9296
+ fields: (0, import_mysql_core13.json)("fields").$type().default({}),
9297
+ currentVersionId: (0, import_mysql_core13.varchar)("currentVersionId", {
9298
+ length: 255
9299
+ }),
9300
+ createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
8751
9301
  mode: "date",
8752
9302
  fsp: 3
8753
- }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`),
8754
- updatedAt: (0, import_mysql_core5.timestamp)("updatedAt", {
9303
+ }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
9304
+ updatedAt: (0, import_mysql_core13.timestamp)("updatedAt", {
8755
9305
  mode: "date",
8756
9306
  fsp: 3
8757
- }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`),
8758
- deletedAt: (0, import_mysql_core5.timestamp)("deletedAt", {
9307
+ }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
9308
+ deletedAt: (0, import_mysql_core13.timestamp)("deletedAt", {
8759
9309
  mode: "date",
8760
9310
  fsp: 3
8761
9311
  })
8762
9312
  }, (cm) => ({
8763
- typeIdx: (0, import_mysql_core5.index)("type_idx").on(cm.type),
8764
- createdByIdx: (0, import_mysql_core5.index)("createdById_idx").on(cm.createdById),
8765
- createdAtIdx: (0, import_mysql_core5.index)("createdAt_idx").on(cm.createdAt)
9313
+ typeIdx: (0, import_mysql_core13.index)("type_idx").on(cm.type),
9314
+ createdByIdx: (0, import_mysql_core13.index)("createdById_idx").on(cm.createdById),
9315
+ createdAtIdx: (0, import_mysql_core13.index)("createdAt_idx").on(cm.createdAt),
9316
+ currentVersionIdIdx: (0, import_mysql_core13.index)("currentVersionId_idx").on(cm.currentVersionId),
9317
+ createdByOrganizationMembershipIdIdx: (0, import_mysql_core13.index)("createdByOrganizationMembershipId_idx").on(cm.createdByOrganizationMembershipId)
8766
9318
  }));
8767
9319
  }
8768
9320
  __name(getContentResourceSchema, "getContentResourceSchema");
@@ -8772,7 +9324,11 @@ function getContentResourceRelationsSchema(mysqlTable) {
8772
9324
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
8773
9325
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
8774
9326
  const contentContributions = getContentContributionsSchema(mysqlTable);
8775
- return (0, import_drizzle_orm4.relations)(contentResource, ({ one, many }) => ({
9327
+ const contentResourceTag = getContentResourceTagSchema(mysqlTable);
9328
+ const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
9329
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9330
+ const tag = getTagSchema(mysqlTable);
9331
+ return (0, import_drizzle_orm13.relations)(contentResource, ({ one, many }) => ({
8776
9332
  createdBy: one(users, {
8777
9333
  fields: [
8778
9334
  contentResource.createdById
@@ -8782,6 +9338,18 @@ function getContentResourceRelationsSchema(mysqlTable) {
8782
9338
  ],
8783
9339
  relationName: "creator"
8784
9340
  }),
9341
+ createdByOrganizationMembership: one(organizationMemberships, {
9342
+ fields: [
9343
+ contentResource.createdByOrganizationMembershipId
9344
+ ],
9345
+ references: [
9346
+ organizationMemberships.id
9347
+ ],
9348
+ relationName: "createdByOrganizationMembership"
9349
+ }),
9350
+ tags: many(contentResourceTag, {
9351
+ relationName: "contentResource"
9352
+ }),
8785
9353
  resources: many(contentResourceResource, {
8786
9354
  relationName: "resourceOf"
8787
9355
  }),
@@ -8793,6 +9361,18 @@ function getContentResourceRelationsSchema(mysqlTable) {
8793
9361
  }),
8794
9362
  contributions: many(contentContributions, {
8795
9363
  relationName: "contributions"
9364
+ }),
9365
+ currentVersion: one(contentResourceVersion, {
9366
+ fields: [
9367
+ contentResource.currentVersionId
9368
+ ],
9369
+ references: [
9370
+ contentResourceVersion.id
9371
+ ],
9372
+ relationName: "currentVersionResource"
9373
+ }),
9374
+ versions: many(contentResourceVersion, {
9375
+ relationName: "resource"
8796
9376
  })
8797
9377
  }));
8798
9378
  }
@@ -8801,35 +9381,39 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
8801
9381
  // src/lib/mysql/schemas/content/content-resource-product.ts
8802
9382
  function getContentResourceProductSchema(mysqlTable) {
8803
9383
  return mysqlTable("ContentResourceProduct", {
8804
- productId: (0, import_mysql_core6.varchar)("productId", {
9384
+ productId: (0, import_mysql_core14.varchar)("productId", {
8805
9385
  length: 255
8806
9386
  }).notNull(),
8807
- resourceId: (0, import_mysql_core6.varchar)("resourceId", {
9387
+ resourceId: (0, import_mysql_core14.varchar)("resourceId", {
8808
9388
  length: 255
8809
9389
  }).notNull(),
8810
- position: (0, import_mysql_core6.double)("position").notNull().default(0),
8811
- metadata: (0, import_mysql_core6.json)("metadata").$type().default({}),
8812
- createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
9390
+ organizationId: (0, import_mysql_core14.varchar)("organizationId", {
9391
+ length: 191
9392
+ }),
9393
+ position: (0, import_mysql_core14.double)("position").notNull().default(0),
9394
+ metadata: (0, import_mysql_core14.json)("metadata").$type().default({}),
9395
+ createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
8813
9396
  mode: "date",
8814
9397
  fsp: 3
8815
- }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
8816
- updatedAt: (0, import_mysql_core6.timestamp)("updatedAt", {
9398
+ }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
9399
+ updatedAt: (0, import_mysql_core14.timestamp)("updatedAt", {
8817
9400
  mode: "date",
8818
9401
  fsp: 3
8819
- }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
8820
- deletedAt: (0, import_mysql_core6.timestamp)("deletedAt", {
9402
+ }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
9403
+ deletedAt: (0, import_mysql_core14.timestamp)("deletedAt", {
8821
9404
  mode: "date",
8822
9405
  fsp: 3
8823
9406
  })
8824
9407
  }, (crr) => ({
8825
- pk: (0, import_mysql_core6.primaryKey)({
9408
+ pk: (0, import_mysql_core14.primaryKey)({
8826
9409
  columns: [
8827
9410
  crr.productId,
8828
9411
  crr.resourceId
8829
9412
  ]
8830
9413
  }),
8831
- contentResourceIdIdx: (0, import_mysql_core6.index)("contentResourceId_idx").on(crr.productId),
8832
- resourceIdIdx: (0, import_mysql_core6.index)("resourceId_idx").on(crr.resourceId)
9414
+ contentResourceIdIdx: (0, import_mysql_core14.index)("contentResourceId_idx").on(crr.productId),
9415
+ resourceIdIdx: (0, import_mysql_core14.index)("resourceId_idx").on(crr.resourceId),
9416
+ organizationIdIdx: (0, import_mysql_core14.index)("organizationId_idx").on(crr.organizationId)
8833
9417
  }));
8834
9418
  }
8835
9419
  __name(getContentResourceProductSchema, "getContentResourceProductSchema");
@@ -8837,7 +9421,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
8837
9421
  const contentResource = getContentResourceSchema(mysqlTable);
8838
9422
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
8839
9423
  const product = getProductSchema(mysqlTable);
8840
- return (0, import_drizzle_orm5.relations)(contentResourceProduct, ({ one }) => ({
9424
+ return (0, import_drizzle_orm14.relations)(contentResourceProduct, ({ one }) => ({
8841
9425
  product: one(product, {
8842
9426
  fields: [
8843
9427
  contentResourceProduct.productId
@@ -8860,80 +9444,48 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
8860
9444
  }
8861
9445
  __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
8862
9446
 
8863
- // src/lib/mysql/schemas/commerce/merchant-product.ts
8864
- var import_drizzle_orm6 = require("drizzle-orm");
8865
- var import_mysql_core7 = require("drizzle-orm/mysql-core");
8866
- function getMerchantProductSchema(mysqlTable) {
8867
- return mysqlTable("MerchantProduct", {
8868
- id: (0, import_mysql_core7.varchar)("id", {
8869
- length: 191
8870
- }).notNull(),
8871
- merchantAccountId: (0, import_mysql_core7.varchar)("merchantAccountId", {
8872
- length: 191
8873
- }).notNull(),
8874
- productId: (0, import_mysql_core7.varchar)("productId", {
8875
- length: 191
8876
- }).notNull(),
8877
- status: (0, import_mysql_core7.int)("status").default(0).notNull(),
8878
- identifier: (0, import_mysql_core7.varchar)("identifier", {
8879
- length: 191
8880
- }),
8881
- createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
8882
- mode: "date",
8883
- fsp: 3
8884
- }).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull()
8885
- }, (table) => {
8886
- return {
8887
- merchantProductId: (0, import_mysql_core7.primaryKey)({
8888
- columns: [
8889
- table.id
8890
- ],
8891
- name: "MerchantProduct_id"
8892
- }),
8893
- merchantProductIdentifierKey: (0, import_mysql_core7.unique)("MerchantProduct_identifier_key").on(table.identifier)
8894
- };
8895
- });
8896
- }
8897
- __name(getMerchantProductSchema, "getMerchantProductSchema");
8898
-
8899
9447
  // src/lib/mysql/schemas/commerce/price.ts
8900
- var import_drizzle_orm8 = require("drizzle-orm");
8901
- var import_mysql_core9 = require("drizzle-orm/mysql-core");
9448
+ var import_drizzle_orm16 = require("drizzle-orm");
9449
+ var import_mysql_core16 = require("drizzle-orm/mysql-core");
8902
9450
 
8903
9451
  // src/lib/mysql/schemas/commerce/merchant-price.ts
8904
- var import_drizzle_orm7 = require("drizzle-orm");
8905
- var import_mysql_core8 = require("drizzle-orm/mysql-core");
9452
+ var import_drizzle_orm15 = require("drizzle-orm");
9453
+ var import_mysql_core15 = require("drizzle-orm/mysql-core");
8906
9454
  function getMerchantPriceSchema(mysqlTable) {
8907
9455
  return mysqlTable("MerchantPrice", {
8908
- id: (0, import_mysql_core8.varchar)("id", {
9456
+ id: (0, import_mysql_core15.varchar)("id", {
8909
9457
  length: 191
8910
9458
  }).notNull(),
8911
- merchantAccountId: (0, import_mysql_core8.varchar)("merchantAccountId", {
9459
+ organizationId: (0, import_mysql_core15.varchar)("organizationId", {
9460
+ length: 191
9461
+ }),
9462
+ merchantAccountId: (0, import_mysql_core15.varchar)("merchantAccountId", {
8912
9463
  length: 191
8913
9464
  }).notNull(),
8914
- merchantProductId: (0, import_mysql_core8.varchar)("merchantProductId", {
9465
+ merchantProductId: (0, import_mysql_core15.varchar)("merchantProductId", {
8915
9466
  length: 191
8916
9467
  }).notNull(),
8917
- status: (0, import_mysql_core8.int)("status").default(0),
8918
- identifier: (0, import_mysql_core8.varchar)("identifier", {
9468
+ status: (0, import_mysql_core15.int)("status").default(0),
9469
+ identifier: (0, import_mysql_core15.varchar)("identifier", {
8919
9470
  length: 191
8920
9471
  }),
8921
- createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
9472
+ createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
8922
9473
  mode: "date",
8923
9474
  fsp: 3
8924
- }).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8925
- priceId: (0, import_mysql_core8.varchar)("priceId", {
9475
+ }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9476
+ priceId: (0, import_mysql_core15.varchar)("priceId", {
8926
9477
  length: 191
8927
9478
  })
8928
9479
  }, (table) => {
8929
9480
  return {
8930
- merchantPriceId: (0, import_mysql_core8.primaryKey)({
9481
+ merchantPriceId: (0, import_mysql_core15.primaryKey)({
8931
9482
  columns: [
8932
9483
  table.id
8933
9484
  ],
8934
9485
  name: "MerchantPrice_id"
8935
9486
  }),
8936
- merchantPriceIdentifierKey: (0, import_mysql_core8.unique)("MerchantPrice_identifier_key").on(table.identifier)
9487
+ merchantPriceIdentifierKey: (0, import_mysql_core15.unique)("MerchantPrice_identifier_key").on(table.identifier),
9488
+ organizationIdIdx: (0, import_mysql_core15.index)("organizationId_idx").on(table.organizationId)
8937
9489
  };
8938
9490
  });
8939
9491
  }
@@ -8942,33 +9494,37 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
8942
9494
  // src/lib/mysql/schemas/commerce/price.ts
8943
9495
  function getPriceSchema(mysqlTable) {
8944
9496
  return mysqlTable("Price", {
8945
- id: (0, import_mysql_core9.varchar)("id", {
9497
+ id: (0, import_mysql_core16.varchar)("id", {
8946
9498
  length: 191
8947
9499
  }).notNull(),
8948
- productId: (0, import_mysql_core9.varchar)("productId", {
9500
+ productId: (0, import_mysql_core16.varchar)("productId", {
8949
9501
  length: 191
8950
9502
  }),
8951
- nickname: (0, import_mysql_core9.varchar)("nickname", {
9503
+ organizationId: (0, import_mysql_core16.varchar)("organizationId", {
8952
9504
  length: 191
8953
9505
  }),
8954
- status: (0, import_mysql_core9.int)("status").default(0).notNull(),
8955
- unitAmount: (0, import_mysql_core9.decimal)("unitAmount", {
9506
+ nickname: (0, import_mysql_core16.varchar)("nickname", {
9507
+ length: 191
9508
+ }),
9509
+ status: (0, import_mysql_core16.int)("status").default(0).notNull(),
9510
+ unitAmount: (0, import_mysql_core16.decimal)("unitAmount", {
8956
9511
  precision: 10,
8957
9512
  scale: 2
8958
9513
  }).notNull(),
8959
- createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
9514
+ createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
8960
9515
  mode: "date",
8961
9516
  fsp: 3
8962
- }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8963
- fields: (0, import_mysql_core9.json)("fields").$type().default({})
9517
+ }).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9518
+ fields: (0, import_mysql_core16.json)("fields").$type().default({})
8964
9519
  }, (table) => {
8965
9520
  return {
8966
- priceId: (0, import_mysql_core9.primaryKey)({
9521
+ priceId: (0, import_mysql_core16.primaryKey)({
8967
9522
  columns: [
8968
9523
  table.id
8969
9524
  ],
8970
9525
  name: "Price_id"
8971
- })
9526
+ }),
9527
+ organizationIdIdx: (0, import_mysql_core16.index)("organizationId_idx").on(table.organizationId)
8972
9528
  };
8973
9529
  });
8974
9530
  }
@@ -8977,33 +9533,37 @@ __name(getPriceSchema, "getPriceSchema");
8977
9533
  // src/lib/mysql/schemas/commerce/product.ts
8978
9534
  function getProductSchema(mysqlTable) {
8979
9535
  return mysqlTable("Product", {
8980
- id: (0, import_mysql_core10.varchar)("id", {
9536
+ id: (0, import_mysql_core17.varchar)("id", {
8981
9537
  length: 191
8982
9538
  }).notNull(),
8983
- name: (0, import_mysql_core10.varchar)("name", {
9539
+ organizationId: (0, import_mysql_core17.varchar)("organizationId", {
9540
+ length: 191
9541
+ }),
9542
+ name: (0, import_mysql_core17.varchar)("name", {
8984
9543
  length: 191
8985
9544
  }).notNull(),
8986
- key: (0, import_mysql_core10.varchar)("key", {
9545
+ key: (0, import_mysql_core17.varchar)("key", {
8987
9546
  length: 191
8988
9547
  }),
8989
- type: (0, import_mysql_core10.varchar)("type", {
9548
+ type: (0, import_mysql_core17.varchar)("type", {
8990
9549
  length: 191
8991
9550
  }),
8992
- fields: (0, import_mysql_core10.json)("fields").$type().default({}),
8993
- createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
9551
+ fields: (0, import_mysql_core17.json)("fields").$type().default({}),
9552
+ createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
8994
9553
  mode: "date",
8995
9554
  fsp: 3
8996
- }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8997
- status: (0, import_mysql_core10.int)("status").default(0).notNull(),
8998
- quantityAvailable: (0, import_mysql_core10.int)("quantityAvailable").default(-1).notNull()
9555
+ }).default(import_drizzle_orm17.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9556
+ status: (0, import_mysql_core17.int)("status").default(0).notNull(),
9557
+ quantityAvailable: (0, import_mysql_core17.int)("quantityAvailable").default(-1).notNull()
8999
9558
  }, (table) => {
9000
9559
  return {
9001
- productId: (0, import_mysql_core10.primaryKey)({
9560
+ productId: (0, import_mysql_core17.primaryKey)({
9002
9561
  columns: [
9003
9562
  table.id
9004
9563
  ],
9005
9564
  name: "Product_id"
9006
- })
9565
+ }),
9566
+ organizationIdIdx: (0, import_mysql_core17.index)("organizationId_idx").on(table.organizationId)
9007
9567
  };
9008
9568
  });
9009
9569
  }
@@ -9013,7 +9573,7 @@ function getProductRelationsSchema(mysqlTable) {
9013
9573
  const price = getPriceSchema(mysqlTable);
9014
9574
  const merchantProduct = getMerchantProductSchema(mysqlTable);
9015
9575
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
9016
- return (0, import_drizzle_orm9.relations)(product, ({ one, many }) => ({
9576
+ return (0, import_drizzle_orm17.relations)(product, ({ one, many }) => ({
9017
9577
  price: one(price, {
9018
9578
  fields: [
9019
9579
  product.id
@@ -9039,255 +9599,339 @@ function getProductRelationsSchema(mysqlTable) {
9039
9599
  }
9040
9600
  __name(getProductRelationsSchema, "getProductRelationsSchema");
9041
9601
 
9042
- // src/lib/mysql/schemas/commerce/coupon.ts
9043
- function getCouponSchema(mysqlTable) {
9044
- return mysqlTable("Coupon", {
9045
- id: (0, import_mysql_core11.varchar)("id", {
9602
+ // src/lib/mysql/schemas/commerce/subscription.ts
9603
+ function getSubscriptionSchema(mysqlTable) {
9604
+ return mysqlTable("Subscription", {
9605
+ id: (0, import_mysql_core18.varchar)("id", {
9046
9606
  length: 191
9047
9607
  }).notNull(),
9048
- code: (0, import_mysql_core11.varchar)("code", {
9608
+ organizationId: (0, import_mysql_core18.varchar)("organizationId", {
9049
9609
  length: 191
9050
9610
  }),
9051
- createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
9052
- mode: "date",
9053
- fsp: 3
9054
- }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9055
- expires: (0, import_mysql_core11.timestamp)("expires", {
9611
+ productId: (0, import_mysql_core18.varchar)("productId", {
9612
+ length: 191
9613
+ }).notNull(),
9614
+ createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
9056
9615
  mode: "date",
9057
9616
  fsp: 3
9058
- }),
9059
- fields: (0, import_mysql_core11.json)("fields").$type().default({}),
9060
- maxUses: (0, import_mysql_core11.int)("maxUses").default(-1).notNull(),
9061
- default: (0, import_mysql_core11.boolean)("default").default(false).notNull(),
9062
- merchantCouponId: (0, import_mysql_core11.varchar)("merchantCouponId", {
9617
+ }).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9618
+ merchantSubscriptionId: (0, import_mysql_core18.varchar)("merchantSubscriptionId", {
9063
9619
  length: 191
9064
- }),
9065
- status: (0, import_mysql_core11.int)("status").default(0).notNull(),
9066
- usedCount: (0, import_mysql_core11.int)("usedCount").default(0).notNull(),
9067
- percentageDiscount: (0, import_mysql_core11.decimal)("percentageDiscount", {
9068
- precision: 3,
9069
- scale: 2
9070
9620
  }).notNull(),
9071
- restrictedToProductId: (0, import_mysql_core11.varchar)("restrictedToProductId", {
9621
+ status: (0, import_mysql_core18.varchar)("status", {
9072
9622
  length: 191
9073
- })
9623
+ }).default("Valid").notNull(),
9624
+ fields: (0, import_mysql_core18.json)("fields").$type().default({})
9074
9625
  }, (table) => {
9075
9626
  return {
9076
- couponIdCodeIndex: (0, import_mysql_core11.index)("Coupon_id_code_index").on(table.id, table.code),
9077
- couponId: (0, import_mysql_core11.primaryKey)({
9627
+ subscriptionId: (0, import_mysql_core18.primaryKey)({
9078
9628
  columns: [
9079
9629
  table.id
9080
9630
  ],
9081
- name: "Coupon_id"
9631
+ name: "Subscription_id"
9082
9632
  }),
9083
- couponCodeKey: (0, import_mysql_core11.unique)("Coupon_code_key").on(table.code)
9633
+ organizationIdIdx: (0, import_mysql_core18.index)("organizationId_idx").on(table.organizationId)
9084
9634
  };
9085
9635
  });
9086
9636
  }
9087
- __name(getCouponSchema, "getCouponSchema");
9088
- function getCouponRelationsSchema(mysqlTable) {
9089
- const purchase = getPurchaseSchema(mysqlTable);
9090
- const coupon = getCouponSchema(mysqlTable);
9091
- const merchantCoupon = getMerchantCouponSchema(mysqlTable);
9092
- return (0, import_drizzle_orm10.relations)(coupon, ({ many, one }) => ({
9093
- redeemedBulkCouponPurchases: many(purchase, {
9094
- relationName: "redeemedBulkCoupon"
9095
- }),
9096
- merchantCoupon: one(merchantCoupon, {
9637
+ __name(getSubscriptionSchema, "getSubscriptionSchema");
9638
+ function getSubscriptionRelationsSchema(mysqlTable) {
9639
+ const subscriptions = getSubscriptionSchema(mysqlTable);
9640
+ const products = getProductSchema(mysqlTable);
9641
+ const organizations = getOrganizationsSchema(mysqlTable);
9642
+ const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable);
9643
+ return (0, import_drizzle_orm18.relations)(subscriptions, ({ many, one }) => ({
9644
+ organization: one(organizations, {
9097
9645
  fields: [
9098
- coupon.merchantCouponId
9646
+ subscriptions.organizationId
9099
9647
  ],
9100
9648
  references: [
9101
- merchantCoupon.id
9649
+ organizations.id
9102
9650
  ],
9103
- relationName: "merchantCoupon"
9651
+ relationName: "organization"
9104
9652
  }),
9105
- product: one(getProductSchema(mysqlTable), {
9653
+ product: one(products, {
9106
9654
  fields: [
9107
- coupon.restrictedToProductId
9655
+ subscriptions.productId
9108
9656
  ],
9109
9657
  references: [
9110
- getProductSchema(mysqlTable).id
9658
+ products.id
9111
9659
  ],
9112
9660
  relationName: "product"
9113
9661
  }),
9114
- bulkPurchases: many(purchase, {
9115
- relationName: "bulkCoupon"
9662
+ merchantSubscription: one(merchantSubscriptions, {
9663
+ fields: [
9664
+ subscriptions.merchantSubscriptionId
9665
+ ],
9666
+ references: [
9667
+ merchantSubscriptions.id
9668
+ ],
9669
+ relationName: "merchantSubscription"
9116
9670
  })
9117
9671
  }));
9118
9672
  }
9119
- __name(getCouponRelationsSchema, "getCouponRelationsSchema");
9673
+ __name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
9120
9674
 
9121
- // src/lib/mysql/schemas/commerce/merchant-charge.ts
9122
- var import_drizzle_orm13 = require("drizzle-orm");
9123
- var import_mysql_core14 = require("drizzle-orm/mysql-core");
9675
+ // src/lib/mysql/schemas/org/organizations.ts
9676
+ function getOrganizationsSchema(mysqlTable) {
9677
+ return mysqlTable("Organization", {
9678
+ id: (0, import_mysql_core19.varchar)("id", {
9679
+ length: 255
9680
+ }).notNull().primaryKey(),
9681
+ name: (0, import_mysql_core19.varchar)("name", {
9682
+ length: 255
9683
+ }),
9684
+ fields: (0, import_mysql_core19.json)("fields").$type().default({}),
9685
+ image: (0, import_mysql_core19.varchar)("image", {
9686
+ length: 255
9687
+ }),
9688
+ createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
9689
+ mode: "date",
9690
+ fsp: 3
9691
+ }).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`)
9692
+ }, (organization) => ({
9693
+ createdAtIdx: (0, import_mysql_core19.index)("created_at_idx").on(organization.createdAt)
9694
+ }));
9695
+ }
9696
+ __name(getOrganizationsSchema, "getOrganizationsSchema");
9697
+ function getOrganizationsRelationsSchema(mysqlTable) {
9698
+ const organizations = getOrganizationsSchema(mysqlTable);
9699
+ const purchases = getPurchaseSchema(mysqlTable);
9700
+ const subscriptions = getSubscriptionSchema(mysqlTable);
9701
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9702
+ return (0, import_drizzle_orm19.relations)(organizations, ({ many }) => ({
9703
+ purchases: many(purchases, {
9704
+ relationName: "organization"
9705
+ }),
9706
+ subscriptions: many(subscriptions, {
9707
+ relationName: "organization"
9708
+ }),
9709
+ members: many(organizationMemberships, {
9710
+ relationName: "organization"
9711
+ })
9712
+ }));
9713
+ }
9714
+ __name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
9124
9715
 
9125
- // src/lib/mysql/schemas/commerce/merchant-account.ts
9126
- var import_drizzle_orm11 = require("drizzle-orm");
9127
- var import_mysql_core12 = require("drizzle-orm/mysql-core");
9128
- function getMerchantAccountSchema(mysqlTable) {
9129
- return mysqlTable("MerchantAccount", {
9130
- id: (0, import_mysql_core12.varchar)("id", {
9716
+ // src/lib/mysql/schemas/org/organization-memberships.ts
9717
+ function getOrganizationMembershipsSchema(mysqlTable) {
9718
+ return mysqlTable("OrganizationMembership", {
9719
+ id: (0, import_mysql_core20.varchar)("id", {
9720
+ length: 255
9721
+ }).notNull().primaryKey(),
9722
+ organizationId: (0, import_mysql_core20.varchar)("organizationId", {
9131
9723
  length: 191
9724
+ }),
9725
+ role: (0, import_mysql_core20.varchar)("role", {
9726
+ length: 191
9727
+ }).notNull().default("user"),
9728
+ invitedById: (0, import_mysql_core20.varchar)("invitedById", {
9729
+ length: 255
9132
9730
  }).notNull(),
9133
- status: (0, import_mysql_core12.int)("status").default(0).notNull(),
9134
- createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
9731
+ userId: (0, import_mysql_core20.varchar)("userId", {
9732
+ length: 255
9733
+ }).notNull(),
9734
+ fields: (0, import_mysql_core20.json)("fields").$type().default({}),
9735
+ createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
9135
9736
  mode: "date",
9136
9737
  fsp: 3
9137
- }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9138
- label: (0, import_mysql_core12.varchar)("label", {
9139
- length: 191
9738
+ }).default(import_drizzle_orm20.sql`CURRENT_TIMESTAMP(3)`)
9739
+ }, (organizationMembership) => ({
9740
+ roleIdx: (0, import_mysql_core20.index)("role_idx").on(organizationMembership.role),
9741
+ createdAtIdx: (0, import_mysql_core20.index)("created_at_idx").on(organizationMembership.createdAt),
9742
+ organizationIdIdx: (0, import_mysql_core20.index)("organizationId_idx").on(organizationMembership.organizationId)
9743
+ }));
9744
+ }
9745
+ __name(getOrganizationMembershipsSchema, "getOrganizationMembershipsSchema");
9746
+ function getOrganizationMembershipsRelationsSchema(mysqlTable) {
9747
+ const users = getUsersSchema(mysqlTable);
9748
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9749
+ const purchases = getPurchaseSchema(mysqlTable);
9750
+ const organizations = getOrganizationsSchema(mysqlTable);
9751
+ return (0, import_drizzle_orm20.relations)(organizationMemberships, ({ one, many }) => ({
9752
+ user: one(users, {
9753
+ fields: [
9754
+ organizationMemberships.userId
9755
+ ],
9756
+ references: [
9757
+ users.id
9758
+ ],
9759
+ relationName: "user"
9140
9760
  }),
9141
- identifier: (0, import_mysql_core12.varchar)("identifier", {
9142
- length: 191
9761
+ invitedBy: one(users, {
9762
+ fields: [
9763
+ organizationMemberships.invitedById
9764
+ ],
9765
+ references: [
9766
+ users.id
9767
+ ],
9768
+ relationName: "invitedBy"
9769
+ }),
9770
+ purchases: many(purchases),
9771
+ organization: one(organizations, {
9772
+ fields: [
9773
+ organizationMemberships.organizationId
9774
+ ],
9775
+ references: [
9776
+ organizations.id
9777
+ ],
9778
+ relationName: "organization"
9143
9779
  })
9144
- }, (table) => {
9145
- return {
9146
- merchantAccountId: (0, import_mysql_core12.primaryKey)({
9147
- columns: [
9148
- table.id
9149
- ],
9150
- name: "MerchantAccount_id"
9151
- })
9152
- };
9153
- });
9780
+ }));
9154
9781
  }
9155
- __name(getMerchantAccountSchema, "getMerchantAccountSchema");
9782
+ __name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
9156
9783
 
9157
- // src/lib/mysql/schemas/commerce/merchant-customer.ts
9158
- var import_drizzle_orm12 = require("drizzle-orm");
9159
- var import_mysql_core13 = require("drizzle-orm/mysql-core");
9160
- function getMerchantCustomerSchema(mysqlTable) {
9161
- return mysqlTable("MerchantCustomer", {
9162
- id: (0, import_mysql_core13.varchar)("id", {
9784
+ // src/lib/mysql/schemas/commerce/coupon.ts
9785
+ var import_drizzle_orm21 = require("drizzle-orm");
9786
+ var import_mysql_core22 = require("drizzle-orm/mysql-core");
9787
+
9788
+ // src/lib/mysql/schemas/commerce/merchant-coupon.ts
9789
+ var import_mysql_core21 = require("drizzle-orm/mysql-core");
9790
+ function getMerchantCouponSchema(mysqlTable) {
9791
+ return mysqlTable("MerchantCoupon", {
9792
+ id: (0, import_mysql_core21.varchar)("id", {
9163
9793
  length: 191
9164
9794
  }).notNull(),
9165
- userId: (0, import_mysql_core13.varchar)("userId", {
9795
+ identifier: (0, import_mysql_core21.varchar)("identifier", {
9166
9796
  length: 191
9167
- }).notNull(),
9168
- merchantAccountId: (0, import_mysql_core13.varchar)("merchantAccountId", {
9797
+ }),
9798
+ organizationId: (0, import_mysql_core21.varchar)("organizationId", {
9169
9799
  length: 191
9170
- }).notNull(),
9171
- identifier: (0, import_mysql_core13.varchar)("identifier", {
9800
+ }),
9801
+ status: (0, import_mysql_core21.int)("status").default(0).notNull(),
9802
+ merchantAccountId: (0, import_mysql_core21.varchar)("merchantAccountId", {
9172
9803
  length: 191
9173
9804
  }).notNull(),
9174
- createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
9175
- mode: "date",
9176
- fsp: 3
9177
- }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9178
- status: (0, import_mysql_core13.int)("status").default(0)
9805
+ percentageDiscount: (0, import_mysql_core21.decimal)("percentageDiscount", {
9806
+ precision: 3,
9807
+ scale: 2
9808
+ }).notNull(),
9809
+ type: (0, import_mysql_core21.varchar)("type", {
9810
+ length: 191
9811
+ })
9179
9812
  }, (table) => {
9180
9813
  return {
9181
- merchantCustomerId: (0, import_mysql_core13.primaryKey)({
9814
+ merchantCouponId: (0, import_mysql_core21.primaryKey)({
9182
9815
  columns: [
9183
9816
  table.id
9184
9817
  ],
9185
- name: "MerchantCustomer_id"
9818
+ name: "MerchantCoupon_id"
9186
9819
  }),
9187
- merchantCustomerIdentifierKey: (0, import_mysql_core13.unique)("MerchantCustomer_identifier_key").on(table.identifier),
9188
- userIdIdx: (0, import_mysql_core13.index)("idx_MerchantCustomer_on_userId").on(table.userId)
9820
+ merchantCouponIdentifierKey: (0, import_mysql_core21.unique)("MerchantCoupon_identifier_key").on(table.identifier),
9821
+ organizationIdIdx: (0, import_mysql_core21.index)("organizationId_idx").on(table.organizationId)
9189
9822
  };
9190
9823
  });
9191
9824
  }
9192
- __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
9825
+ __name(getMerchantCouponSchema, "getMerchantCouponSchema");
9193
9826
 
9194
- // src/lib/mysql/schemas/commerce/merchant-charge.ts
9195
- function getMerchantChargeSchema(mysqlTable) {
9196
- return mysqlTable("MerchantCharge", {
9197
- id: (0, import_mysql_core14.varchar)("id", {
9198
- length: 191
9199
- }).notNull(),
9200
- status: (0, import_mysql_core14.int)("status").default(0).notNull(),
9201
- identifier: (0, import_mysql_core14.varchar)("identifier", {
9202
- length: 191
9203
- }).notNull(),
9204
- userId: (0, import_mysql_core14.varchar)("userId", {
9827
+ // src/lib/mysql/schemas/commerce/coupon.ts
9828
+ function getCouponSchema(mysqlTable) {
9829
+ return mysqlTable("Coupon", {
9830
+ id: (0, import_mysql_core22.varchar)("id", {
9205
9831
  length: 191
9206
9832
  }).notNull(),
9207
- merchantAccountId: (0, import_mysql_core14.varchar)("merchantAccountId", {
9833
+ organizationId: (0, import_mysql_core22.varchar)("organizationId", {
9208
9834
  length: 191
9209
- }).notNull(),
9210
- merchantProductId: (0, import_mysql_core14.varchar)("merchantProductId", {
9835
+ }),
9836
+ code: (0, import_mysql_core22.varchar)("code", {
9211
9837
  length: 191
9212
- }).notNull(),
9213
- createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
9838
+ }),
9839
+ createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
9840
+ mode: "date",
9841
+ fsp: 3
9842
+ }).default(import_drizzle_orm21.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9843
+ expires: (0, import_mysql_core22.timestamp)("expires", {
9214
9844
  mode: "date",
9215
9845
  fsp: 3
9216
- }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9217
- merchantCustomerId: (0, import_mysql_core14.varchar)("merchantCustomerId", {
9846
+ }),
9847
+ fields: (0, import_mysql_core22.json)("fields").$type().default({}),
9848
+ maxUses: (0, import_mysql_core22.int)("maxUses").default(-1).notNull(),
9849
+ default: (0, import_mysql_core22.boolean)("default").default(false).notNull(),
9850
+ merchantCouponId: (0, import_mysql_core22.varchar)("merchantCouponId", {
9218
9851
  length: 191
9219
- }).notNull()
9852
+ }),
9853
+ status: (0, import_mysql_core22.int)("status").default(0).notNull(),
9854
+ usedCount: (0, import_mysql_core22.int)("usedCount").default(0).notNull(),
9855
+ percentageDiscount: (0, import_mysql_core22.decimal)("percentageDiscount", {
9856
+ precision: 3,
9857
+ scale: 2
9858
+ }).notNull(),
9859
+ restrictedToProductId: (0, import_mysql_core22.varchar)("restrictedToProductId", {
9860
+ length: 191
9861
+ })
9220
9862
  }, (table) => {
9221
9863
  return {
9222
- merchantChargeId: (0, import_mysql_core14.primaryKey)({
9864
+ couponIdCodeIndex: (0, import_mysql_core22.index)("Coupon_id_code_index").on(table.id, table.code),
9865
+ couponId: (0, import_mysql_core22.primaryKey)({
9223
9866
  columns: [
9224
9867
  table.id
9225
9868
  ],
9226
- name: "MerchantCharge_id"
9869
+ name: "Coupon_id"
9227
9870
  }),
9228
- merchantChargeIdentifierKey: (0, import_mysql_core14.unique)("MerchantCharge_identifier_key").on(table.identifier)
9871
+ couponCodeKey: (0, import_mysql_core22.unique)("Coupon_code_key").on(table.code),
9872
+ organizationIdIdx: (0, import_mysql_core22.index)("organizationId_idx").on(table.organizationId)
9229
9873
  };
9230
9874
  });
9231
9875
  }
9232
- __name(getMerchantChargeSchema, "getMerchantChargeSchema");
9233
- function getMerchantChargeRelationsSchema(mysqlTable) {
9234
- const merchantCharge = getMerchantChargeSchema(mysqlTable);
9235
- const merchantAccount = getMerchantAccountSchema(mysqlTable);
9236
- const merchantProduct = getMerchantProductSchema(mysqlTable);
9237
- const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
9238
- return (0, import_drizzle_orm13.relations)(merchantCharge, ({ one }) => ({
9239
- merchantAccount: one(merchantAccount, {
9240
- fields: [
9241
- merchantCharge.merchantAccountId
9242
- ],
9243
- references: [
9244
- merchantAccount.id
9245
- ],
9246
- relationName: "merchantAccount"
9876
+ __name(getCouponSchema, "getCouponSchema");
9877
+ function getCouponRelationsSchema(mysqlTable) {
9878
+ const purchase = getPurchaseSchema(mysqlTable);
9879
+ const coupon = getCouponSchema(mysqlTable);
9880
+ const merchantCoupon = getMerchantCouponSchema(mysqlTable);
9881
+ return (0, import_drizzle_orm21.relations)(coupon, ({ many, one }) => ({
9882
+ redeemedBulkCouponPurchases: many(purchase, {
9883
+ relationName: "redeemedBulkCoupon"
9247
9884
  }),
9248
- merchantProduct: one(merchantProduct, {
9885
+ merchantCoupon: one(merchantCoupon, {
9249
9886
  fields: [
9250
- merchantCharge.merchantProductId
9887
+ coupon.merchantCouponId
9251
9888
  ],
9252
9889
  references: [
9253
- merchantProduct.id
9890
+ merchantCoupon.id
9254
9891
  ],
9255
- relationName: "merchantProduct"
9892
+ relationName: "merchantCoupon"
9256
9893
  }),
9257
- merchantCustomer: one(merchantCustomer, {
9894
+ product: one(getProductSchema(mysqlTable), {
9258
9895
  fields: [
9259
- merchantCharge.merchantCustomerId
9896
+ coupon.restrictedToProductId
9260
9897
  ],
9261
9898
  references: [
9262
- merchantCustomer.id
9899
+ getProductSchema(mysqlTable).id
9263
9900
  ],
9264
- relationName: "merchantCustomer"
9901
+ relationName: "product"
9902
+ }),
9903
+ bulkPurchases: many(purchase, {
9904
+ relationName: "bulkCoupon"
9265
9905
  })
9266
9906
  }));
9267
9907
  }
9268
- __name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
9908
+ __name(getCouponRelationsSchema, "getCouponRelationsSchema");
9269
9909
 
9270
9910
  // src/lib/mysql/schemas/commerce/merchant-session.ts
9271
- var import_mysql_core15 = require("drizzle-orm/mysql-core");
9911
+ var import_mysql_core23 = require("drizzle-orm/mysql-core");
9272
9912
  function getMerchantSessionSchema(mysqlTable) {
9273
9913
  return mysqlTable("MerchantSession", {
9274
- id: (0, import_mysql_core15.varchar)("id", {
9914
+ id: (0, import_mysql_core23.varchar)("id", {
9275
9915
  length: 191
9276
9916
  }).notNull(),
9277
- identifier: (0, import_mysql_core15.varchar)("identifier", {
9917
+ organizationId: (0, import_mysql_core23.varchar)("organizationId", {
9918
+ length: 191
9919
+ }),
9920
+ identifier: (0, import_mysql_core23.varchar)("identifier", {
9278
9921
  length: 191
9279
9922
  }).notNull(),
9280
- merchantAccountId: (0, import_mysql_core15.varchar)("merchantAccountId", {
9923
+ merchantAccountId: (0, import_mysql_core23.varchar)("merchantAccountId", {
9281
9924
  length: 191
9282
9925
  }).notNull()
9283
9926
  }, (table) => {
9284
9927
  return {
9285
- merchantSessionId: (0, import_mysql_core15.primaryKey)({
9928
+ merchantSessionId: (0, import_mysql_core23.primaryKey)({
9286
9929
  columns: [
9287
9930
  table.id
9288
9931
  ],
9289
9932
  name: "MerchantSession_id"
9290
- })
9933
+ }),
9934
+ organizationIdIdx: (0, import_mysql_core23.index)("organizationId_idx").on(table.organizationId)
9291
9935
  };
9292
9936
  });
9293
9937
  }
@@ -9296,67 +9940,75 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
9296
9940
  // src/lib/mysql/schemas/commerce/purchase.ts
9297
9941
  function getPurchaseSchema(mysqlTable) {
9298
9942
  return mysqlTable("Purchase", {
9299
- id: (0, import_mysql_core16.varchar)("id", {
9943
+ id: (0, import_mysql_core24.varchar)("id", {
9300
9944
  length: 191
9301
9945
  }).notNull(),
9302
- userId: (0, import_mysql_core16.varchar)("userId", {
9946
+ userId: (0, import_mysql_core24.varchar)("userId", {
9303
9947
  length: 191
9304
9948
  }),
9305
- createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
9949
+ purchasedByorganizationMembershipId: (0, import_mysql_core24.varchar)("organizationMembershipId", {
9950
+ length: 191
9951
+ }),
9952
+ organizationId: (0, import_mysql_core24.varchar)("organizationId", {
9953
+ length: 191
9954
+ }),
9955
+ createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
9306
9956
  mode: "date",
9307
9957
  fsp: 3
9308
- }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9309
- totalAmount: (0, import_mysql_core16.decimal)("totalAmount", {
9958
+ }).default(import_drizzle_orm22.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9959
+ totalAmount: (0, import_mysql_core24.decimal)("totalAmount", {
9310
9960
  precision: 65,
9311
9961
  scale: 30
9312
9962
  }).notNull(),
9313
- ipAddress: (0, import_mysql_core16.varchar)("ip_address", {
9963
+ ipAddress: (0, import_mysql_core24.varchar)("ip_address", {
9314
9964
  length: 191
9315
9965
  }),
9316
- city: (0, import_mysql_core16.varchar)("city", {
9966
+ city: (0, import_mysql_core24.varchar)("city", {
9317
9967
  length: 191
9318
9968
  }),
9319
- state: (0, import_mysql_core16.varchar)("state", {
9969
+ state: (0, import_mysql_core24.varchar)("state", {
9320
9970
  length: 191
9321
9971
  }),
9322
- country: (0, import_mysql_core16.varchar)("country", {
9972
+ country: (0, import_mysql_core24.varchar)("country", {
9323
9973
  length: 191
9324
9974
  }),
9325
- couponId: (0, import_mysql_core16.varchar)("couponId", {
9975
+ couponId: (0, import_mysql_core24.varchar)("couponId", {
9326
9976
  length: 191
9327
9977
  }),
9328
- productId: (0, import_mysql_core16.varchar)("productId", {
9978
+ productId: (0, import_mysql_core24.varchar)("productId", {
9329
9979
  length: 191
9330
9980
  }).notNull(),
9331
- merchantChargeId: (0, import_mysql_core16.varchar)("merchantChargeId", {
9981
+ merchantChargeId: (0, import_mysql_core24.varchar)("merchantChargeId", {
9332
9982
  length: 191
9333
9983
  }),
9334
- upgradedFromId: (0, import_mysql_core16.varchar)("upgradedFromId", {
9984
+ upgradedFromId: (0, import_mysql_core24.varchar)("upgradedFromId", {
9335
9985
  length: 191
9336
9986
  }),
9337
- status: (0, import_mysql_core16.varchar)("status", {
9987
+ status: (0, import_mysql_core24.varchar)("status", {
9338
9988
  length: 191
9339
9989
  }).default("Valid").notNull(),
9340
- bulkCouponId: (0, import_mysql_core16.varchar)("bulkCouponId", {
9990
+ bulkCouponId: (0, import_mysql_core24.varchar)("bulkCouponId", {
9341
9991
  length: 191
9342
9992
  }),
9343
- merchantSessionId: (0, import_mysql_core16.varchar)("merchantSessionId", {
9993
+ merchantSessionId: (0, import_mysql_core24.varchar)("merchantSessionId", {
9344
9994
  length: 191
9345
9995
  }),
9346
- redeemedBulkCouponId: (0, import_mysql_core16.varchar)("redeemedBulkCouponId", {
9996
+ redeemedBulkCouponId: (0, import_mysql_core24.varchar)("redeemedBulkCouponId", {
9347
9997
  length: 191
9348
9998
  }),
9349
- fields: (0, import_mysql_core16.json)("fields").$type().default({})
9999
+ fields: (0, import_mysql_core24.json)("fields").$type().default({})
9350
10000
  }, (table) => {
9351
10001
  return {
9352
- purchaseId: (0, import_mysql_core16.primaryKey)({
10002
+ purchaseId: (0, import_mysql_core24.primaryKey)({
9353
10003
  columns: [
9354
10004
  table.id
9355
10005
  ],
9356
10006
  name: "Purchase_id"
9357
10007
  }),
9358
- merchantChargeIdIdx: (0, import_mysql_core16.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
9359
- purchaseUpgradedFromIdKey: (0, import_mysql_core16.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId)
10008
+ merchantChargeIdIdx: (0, import_mysql_core24.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
10009
+ purchaseUpgradedFromIdKey: (0, import_mysql_core24.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId),
10010
+ organizationIdIdx: (0, import_mysql_core24.index)("organizationId_idx").on(table.organizationId),
10011
+ organizationMembershipIdIdx: (0, import_mysql_core24.index)("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId)
9360
10012
  };
9361
10013
  });
9362
10014
  }
@@ -9368,7 +10020,9 @@ function getPurchaseRelationsSchema(mysqlTable) {
9368
10020
  const merchantCharges = getMerchantChargeSchema(mysqlTable);
9369
10021
  const merchantSessions = getMerchantSessionSchema(mysqlTable);
9370
10022
  const coupons = getCouponSchema(mysqlTable);
9371
- return (0, import_drizzle_orm14.relations)(purchases, ({ many, one }) => ({
10023
+ const organizations = getOrganizationsSchema(mysqlTable);
10024
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10025
+ return (0, import_drizzle_orm22.relations)(purchases, ({ many, one }) => ({
9372
10026
  redeemedBulkCoupon: one(coupons, {
9373
10027
  fields: [
9374
10028
  purchases.redeemedBulkCouponId
@@ -9387,6 +10041,24 @@ function getPurchaseRelationsSchema(mysqlTable) {
9387
10041
  ],
9388
10042
  relationName: "user"
9389
10043
  }),
10044
+ organization: one(organizations, {
10045
+ fields: [
10046
+ purchases.organizationId
10047
+ ],
10048
+ references: [
10049
+ organizations.id
10050
+ ],
10051
+ relationName: "organization"
10052
+ }),
10053
+ purchasedBy: one(organizationMemberships, {
10054
+ fields: [
10055
+ purchases.purchasedByorganizationMembershipId
10056
+ ],
10057
+ references: [
10058
+ organizationMemberships.id
10059
+ ],
10060
+ relationName: "organizationMembership"
10061
+ }),
9390
10062
  product: one(products, {
9391
10063
  fields: [
9392
10064
  purchases.productId
@@ -9428,44 +10100,49 @@ function getPurchaseRelationsSchema(mysqlTable) {
9428
10100
  __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
9429
10101
 
9430
10102
  // src/lib/mysql/schemas/communication/comment.ts
9431
- var import_drizzle_orm15 = require("drizzle-orm");
9432
- var import_mysql_core17 = require("drizzle-orm/mysql-core");
10103
+ var import_drizzle_orm23 = require("drizzle-orm");
10104
+ var import_mysql_core25 = require("drizzle-orm/mysql-core");
9433
10105
  function getCommentsSchema(mysqlTable) {
9434
10106
  return mysqlTable("Comment", {
9435
- id: (0, import_mysql_core17.varchar)("id", {
10107
+ id: (0, import_mysql_core25.varchar)("id", {
9436
10108
  length: 191
9437
10109
  }).notNull(),
9438
- userId: (0, import_mysql_core17.varchar)("userId", {
10110
+ userId: (0, import_mysql_core25.varchar)("userId", {
9439
10111
  length: 255
9440
10112
  }).notNull(),
9441
- context: (0, import_mysql_core17.json)("context").$type().default({}),
9442
- text: (0, import_mysql_core17.text)("text").notNull(),
9443
- createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
10113
+ organizationMembershipId: (0, import_mysql_core25.varchar)("organizationMembershipId", {
10114
+ length: 255
10115
+ }),
10116
+ context: (0, import_mysql_core25.json)("context").$type().default({}),
10117
+ text: (0, import_mysql_core25.text)("text").notNull(),
10118
+ createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
9444
10119
  mode: "date",
9445
10120
  fsp: 3
9446
- }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
9447
- updatedAt: (0, import_mysql_core17.timestamp)("updatedAt", {
10121
+ }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
10122
+ updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
9448
10123
  mode: "date",
9449
10124
  fsp: 3
9450
- }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
9451
- deletedAt: (0, import_mysql_core17.timestamp)("deletedAt", {
10125
+ }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
10126
+ deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
9452
10127
  mode: "date",
9453
10128
  fsp: 3
9454
10129
  })
9455
10130
  }, (crr) => ({
9456
- pk: (0, import_mysql_core17.primaryKey)({
10131
+ pk: (0, import_mysql_core25.primaryKey)({
9457
10132
  columns: [
9458
10133
  crr.id
9459
10134
  ]
9460
10135
  }),
9461
- crrUserIdIdKey: (0, import_mysql_core17.index)("crr_userIdId_idx").on(crr.userId)
10136
+ crrUserIdIdKey: (0, import_mysql_core25.index)("crr_userIdId_idx").on(crr.userId),
10137
+ organizationMembershipIdIdx: (0, import_mysql_core25.index)("organizationMembershipId_idx").on(crr.organizationMembershipId)
9462
10138
  }));
9463
10139
  }
9464
10140
  __name(getCommentsSchema, "getCommentsSchema");
9465
10141
  function getCommentRelationsSchema(mysqlTable) {
9466
10142
  const comment = getCommentsSchema(mysqlTable);
9467
10143
  const user = getUsersSchema(mysqlTable);
9468
- return (0, import_drizzle_orm15.relations)(comment, ({ one }) => ({
10144
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10145
+ return (0, import_drizzle_orm23.relations)(comment, ({ one }) => ({
9469
10146
  user: one(user, {
9470
10147
  fields: [
9471
10148
  comment.userId
@@ -9474,66 +10151,82 @@ function getCommentRelationsSchema(mysqlTable) {
9474
10151
  user.id
9475
10152
  ],
9476
10153
  relationName: "user"
10154
+ }),
10155
+ organizationMembership: one(organizationMemberships, {
10156
+ fields: [
10157
+ comment.organizationMembershipId
10158
+ ],
10159
+ references: [
10160
+ organizationMemberships.id
10161
+ ],
10162
+ relationName: "organizationMembership"
9477
10163
  })
9478
10164
  }));
9479
10165
  }
9480
10166
  __name(getCommentRelationsSchema, "getCommentRelationsSchema");
9481
10167
 
9482
10168
  // src/lib/mysql/schemas/communication/communication-preferences.ts
9483
- var import_drizzle_orm16 = require("drizzle-orm");
9484
- var import_mysql_core20 = require("drizzle-orm/mysql-core");
10169
+ var import_drizzle_orm24 = require("drizzle-orm");
10170
+ var import_mysql_core28 = require("drizzle-orm/mysql-core");
9485
10171
 
9486
10172
  // src/lib/mysql/schemas/communication/communication-channel.ts
9487
- var import_mysql_core18 = require("drizzle-orm/mysql-core");
10173
+ var import_mysql_core26 = require("drizzle-orm/mysql-core");
9488
10174
  function getCommunicationChannelSchema(mysqlTable) {
9489
10175
  return mysqlTable("CommunicationChannel", {
9490
- id: (0, import_mysql_core18.varchar)("id", {
10176
+ id: (0, import_mysql_core26.varchar)("id", {
9491
10177
  length: 255
9492
10178
  }).notNull().primaryKey(),
9493
- name: (0, import_mysql_core18.varchar)("name", {
10179
+ organizationId: (0, import_mysql_core26.varchar)("organizationId", {
10180
+ length: 191
10181
+ }),
10182
+ name: (0, import_mysql_core26.varchar)("name", {
9494
10183
  length: 255
9495
10184
  }).notNull(),
9496
- description: (0, import_mysql_core18.text)("description"),
9497
- active: (0, import_mysql_core18.boolean)("active").notNull().default(true),
9498
- createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
10185
+ description: (0, import_mysql_core26.text)("description"),
10186
+ active: (0, import_mysql_core26.boolean)("active").notNull().default(true),
10187
+ createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
9499
10188
  mode: "date",
9500
10189
  fsp: 3
9501
10190
  }).defaultNow(),
9502
- updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
10191
+ updatedAt: (0, import_mysql_core26.timestamp)("updatedAt", {
9503
10192
  mode: "date",
9504
10193
  fsp: 3
9505
10194
  }).defaultNow(),
9506
- deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
10195
+ deletedAt: (0, import_mysql_core26.timestamp)("deletedAt", {
9507
10196
  mode: "date",
9508
10197
  fsp: 3
9509
10198
  })
9510
10199
  }, (cc) => ({
9511
- nameIdx: (0, import_mysql_core18.index)("name_idx").on(cc.name)
10200
+ nameIdx: (0, import_mysql_core26.index)("name_idx").on(cc.name),
10201
+ organizationIdIdx: (0, import_mysql_core26.index)("organizationId_idx").on(cc.organizationId)
9512
10202
  }));
9513
10203
  }
9514
10204
  __name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
9515
10205
 
9516
10206
  // src/lib/mysql/schemas/communication/communication-preference-types.ts
9517
- var import_mysql_core19 = require("drizzle-orm/mysql-core");
10207
+ var import_mysql_core27 = require("drizzle-orm/mysql-core");
9518
10208
  function getCommunicationPreferenceTypesSchema(mysqlTable) {
9519
10209
  return mysqlTable("CommunicationPreferenceType", {
9520
- id: (0, import_mysql_core19.varchar)("id", {
10210
+ id: (0, import_mysql_core27.varchar)("id", {
9521
10211
  length: 255
9522
10212
  }).notNull().primaryKey(),
9523
- name: (0, import_mysql_core19.varchar)("name", {
10213
+ organizationId: (0, import_mysql_core27.varchar)("organizationId", {
10214
+ length: 191
10215
+ }),
10216
+ name: (0, import_mysql_core27.varchar)("name", {
9524
10217
  length: 255
9525
10218
  }).notNull(),
9526
- description: (0, import_mysql_core19.text)("description"),
9527
- active: (0, import_mysql_core19.boolean)("active").notNull().default(true),
9528
- createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
10219
+ description: (0, import_mysql_core27.text)("description"),
10220
+ active: (0, import_mysql_core27.boolean)("active").notNull().default(true),
10221
+ createdAt: (0, import_mysql_core27.timestamp)("createdAt", {
9529
10222
  mode: "date",
9530
10223
  fsp: 3
9531
10224
  }).defaultNow(),
9532
- updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
10225
+ updatedAt: (0, import_mysql_core27.timestamp)("updatedAt", {
9533
10226
  mode: "date",
9534
10227
  fsp: 3
9535
10228
  }),
9536
- deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
10229
+ deletedAt: (0, import_mysql_core27.timestamp)("deletedAt", {
9537
10230
  mode: "date",
9538
10231
  fsp: 3
9539
10232
  })
@@ -9544,48 +10237,55 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
9544
10237
  // src/lib/mysql/schemas/communication/communication-preferences.ts
9545
10238
  function getCommunicationPreferencesSchema(mysqlTable) {
9546
10239
  return mysqlTable("CommunicationPreference", {
9547
- id: (0, import_mysql_core20.varchar)("id", {
10240
+ id: (0, import_mysql_core28.varchar)("id", {
9548
10241
  length: 255
9549
10242
  }).notNull().primaryKey(),
9550
- userId: (0, import_mysql_core20.varchar)("userId", {
10243
+ organizationId: (0, import_mysql_core28.varchar)("organizationId", {
10244
+ length: 191
10245
+ }),
10246
+ userId: (0, import_mysql_core28.varchar)("userId", {
9551
10247
  length: 255
9552
10248
  }).notNull(),
9553
- channelId: (0, import_mysql_core20.varchar)("channelId", {
10249
+ organizationMembershipId: (0, import_mysql_core28.varchar)("organizationMembershipId", {
10250
+ length: 255
10251
+ }),
10252
+ channelId: (0, import_mysql_core28.varchar)("channelId", {
9554
10253
  length: 255
9555
10254
  }).notNull(),
9556
- preferenceLevel: (0, import_mysql_core20.mysqlEnum)("preferenceLevel", [
10255
+ preferenceLevel: (0, import_mysql_core28.mysqlEnum)("preferenceLevel", [
9557
10256
  "low",
9558
10257
  "medium",
9559
10258
  "high"
9560
10259
  ]).notNull().default("medium"),
9561
- preferenceTypeId: (0, import_mysql_core20.varchar)("preferenceTypeId", {
10260
+ preferenceTypeId: (0, import_mysql_core28.varchar)("preferenceTypeId", {
9562
10261
  length: 255
9563
10262
  }).notNull(),
9564
- active: (0, import_mysql_core20.boolean)("active").notNull().default(true),
9565
- createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
10263
+ active: (0, import_mysql_core28.boolean)("active").notNull().default(true),
10264
+ createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
9566
10265
  mode: "date",
9567
10266
  fsp: 3
9568
10267
  }).defaultNow(),
9569
- optInAt: (0, import_mysql_core20.timestamp)("optInAt", {
10268
+ optInAt: (0, import_mysql_core28.timestamp)("optInAt", {
9570
10269
  mode: "date",
9571
10270
  fsp: 3
9572
10271
  }),
9573
- optOutAt: (0, import_mysql_core20.timestamp)("optOutAt", {
10272
+ optOutAt: (0, import_mysql_core28.timestamp)("optOutAt", {
9574
10273
  mode: "date",
9575
10274
  fsp: 3
9576
10275
  }),
9577
- updatedAt: (0, import_mysql_core20.timestamp)("updatedAt", {
10276
+ updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
9578
10277
  mode: "date",
9579
10278
  fsp: 3
9580
10279
  }).defaultNow(),
9581
- deletedAt: (0, import_mysql_core20.timestamp)("deletedAt", {
10280
+ deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
9582
10281
  mode: "date",
9583
10282
  fsp: 3
9584
10283
  })
9585
10284
  }, (cp) => ({
9586
- userIdIdx: (0, import_mysql_core20.index)("userId_idx").on(cp.userId),
9587
- preferenceTypeIdx: (0, import_mysql_core20.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
9588
- channelIdIdx: (0, import_mysql_core20.index)("channelId_idx").on(cp.channelId)
10285
+ userIdIdx: (0, import_mysql_core28.index)("userId_idx").on(cp.userId),
10286
+ preferenceTypeIdx: (0, import_mysql_core28.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
10287
+ channelIdIdx: (0, import_mysql_core28.index)("channelId_idx").on(cp.channelId),
10288
+ organizationMembershipIdIdx: (0, import_mysql_core28.index)("organizationMembershipId_idx").on(cp.organizationMembershipId)
9589
10289
  }));
9590
10290
  }
9591
10291
  __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
@@ -9594,7 +10294,8 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
9594
10294
  const users = getUsersSchema(mysqlTable);
9595
10295
  const communicationChannel = getCommunicationChannelSchema(mysqlTable);
9596
10296
  const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
9597
- return (0, import_drizzle_orm16.relations)(communicationPreferences, ({ one }) => ({
10297
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10298
+ return (0, import_drizzle_orm24.relations)(communicationPreferences, ({ one }) => ({
9598
10299
  user: one(users, {
9599
10300
  fields: [
9600
10301
  communicationPreferences.userId
@@ -9604,6 +10305,15 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
9604
10305
  ],
9605
10306
  relationName: "user"
9606
10307
  }),
10308
+ organizationMembership: one(organizationMemberships, {
10309
+ fields: [
10310
+ communicationPreferences.organizationMembershipId
10311
+ ],
10312
+ references: [
10313
+ organizationMemberships.id
10314
+ ],
10315
+ relationName: "organizationMembership"
10316
+ }),
9607
10317
  channel: one(communicationChannel, {
9608
10318
  fields: [
9609
10319
  communicationPreferences.channelId
@@ -9627,75 +10337,79 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
9627
10337
  __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
9628
10338
 
9629
10339
  // src/lib/mysql/schemas/auth/user-permissions.ts
9630
- var import_drizzle_orm18 = require("drizzle-orm");
9631
- var import_mysql_core22 = require("drizzle-orm/mysql-core");
10340
+ var import_drizzle_orm26 = require("drizzle-orm");
10341
+ var import_mysql_core30 = require("drizzle-orm/mysql-core");
9632
10342
 
9633
10343
  // src/lib/mysql/schemas/auth/permissions.ts
9634
- var import_drizzle_orm17 = require("drizzle-orm");
9635
- var import_mysql_core21 = require("drizzle-orm/mysql-core");
10344
+ var import_drizzle_orm25 = require("drizzle-orm");
10345
+ var import_mysql_core29 = require("drizzle-orm/mysql-core");
9636
10346
  function getPermissionsSchema(mysqlTable) {
9637
10347
  return mysqlTable("Permission", {
9638
- id: (0, import_mysql_core21.varchar)("id", {
10348
+ id: (0, import_mysql_core29.varchar)("id", {
9639
10349
  length: 255
9640
10350
  }).notNull().primaryKey(),
9641
- name: (0, import_mysql_core21.varchar)("name", {
10351
+ name: (0, import_mysql_core29.varchar)("name", {
9642
10352
  length: 255
9643
10353
  }).notNull().unique(),
9644
- description: (0, import_mysql_core21.text)("description"),
9645
- active: (0, import_mysql_core21.boolean)("active").notNull().default(true),
9646
- createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
10354
+ description: (0, import_mysql_core29.text)("description"),
10355
+ active: (0, import_mysql_core29.boolean)("active").notNull().default(true),
10356
+ createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
9647
10357
  mode: "date",
9648
10358
  fsp: 3
9649
10359
  }).defaultNow(),
9650
- updatedAt: (0, import_mysql_core21.timestamp)("updatedAt", {
10360
+ updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
9651
10361
  mode: "date",
9652
10362
  fsp: 3
9653
10363
  }).defaultNow(),
9654
- deletedAt: (0, import_mysql_core21.timestamp)("deletedAt", {
10364
+ deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
9655
10365
  mode: "date",
9656
10366
  fsp: 3
9657
10367
  })
9658
10368
  }, (permission) => ({
9659
- nameIdx: (0, import_mysql_core21.index)("name_idx").on(permission.name)
10369
+ nameIdx: (0, import_mysql_core29.index)("name_idx").on(permission.name)
9660
10370
  }));
9661
10371
  }
9662
10372
  __name(getPermissionsSchema, "getPermissionsSchema");
9663
10373
  function getPermissionsRelationsSchema(mysqlTable) {
9664
- return (0, import_drizzle_orm17.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
10374
+ return (0, import_drizzle_orm25.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
9665
10375
  }
9666
10376
  __name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
9667
10377
 
9668
10378
  // src/lib/mysql/schemas/auth/user-permissions.ts
9669
10379
  function getUserPermissionsSchema(mysqlTable) {
9670
10380
  return mysqlTable("UserPermission", {
9671
- userId: (0, import_mysql_core22.varchar)("userId", {
10381
+ userId: (0, import_mysql_core30.varchar)("userId", {
9672
10382
  length: 255
9673
10383
  }).notNull(),
9674
- permissionId: (0, import_mysql_core22.varchar)("permissionId", {
10384
+ organizationId: (0, import_mysql_core30.varchar)("organizationId", {
10385
+ length: 191
10386
+ }),
10387
+ permissionId: (0, import_mysql_core30.varchar)("permissionId", {
9675
10388
  length: 255
9676
10389
  }).notNull(),
9677
- active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
9678
- createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
10390
+ active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
10391
+ createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
9679
10392
  mode: "date",
9680
10393
  fsp: 3
9681
10394
  }).defaultNow(),
9682
- updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
10395
+ updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
9683
10396
  mode: "date",
9684
10397
  fsp: 3
9685
10398
  }).defaultNow(),
9686
- deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
10399
+ deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
9687
10400
  mode: "date",
9688
10401
  fsp: 3
9689
10402
  })
9690
10403
  }, (up) => ({
9691
- pk: (0, import_mysql_core22.primaryKey)({
10404
+ pk: (0, import_mysql_core30.primaryKey)({
9692
10405
  columns: [
9693
10406
  up.userId,
9694
10407
  up.permissionId
9695
10408
  ]
9696
10409
  }),
9697
- userIdIdx: (0, import_mysql_core22.index)("userId_idx").on(up.userId),
9698
- permissionIdIdx: (0, import_mysql_core22.index)("permissionId_idx").on(up.permissionId)
10410
+ userIdIdx: (0, import_mysql_core30.index)("userId_idx").on(up.userId),
10411
+ permissionIdIdx: (0, import_mysql_core30.index)("permissionId_idx").on(up.permissionId),
10412
+ organizationIdIdx: (0, import_mysql_core30.index)("organizationId_idx").on(up.organizationId)
9699
10413
  }));
9700
10414
  }
9701
10415
  __name(getUserPermissionsSchema, "getUserPermissionsSchema");
@@ -9703,7 +10417,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
9703
10417
  const userPermissions = getUserPermissionsSchema(mysqlTable);
9704
10418
  const users = getUsersSchema(mysqlTable);
9705
10419
  const permissions = getPermissionsSchema(mysqlTable);
9706
- return (0, import_drizzle_orm18.relations)(userPermissions, ({ one }) => ({
10420
+ return (0, import_drizzle_orm26.relations)(userPermissions, ({ one }) => ({
9707
10421
  user: one(users, {
9708
10422
  fields: [
9709
10423
  userPermissions.userId
@@ -9727,46 +10441,50 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
9727
10441
  __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
9728
10442
 
9729
10443
  // src/lib/mysql/schemas/auth/user-prefs.ts
9730
- var import_drizzle_orm19 = require("drizzle-orm");
9731
- var import_mysql_core23 = require("drizzle-orm/mysql-core");
10444
+ var import_drizzle_orm27 = require("drizzle-orm");
10445
+ var import_mysql_core31 = require("drizzle-orm/mysql-core");
9732
10446
  function getUserPrefsSchema(mysqlTable) {
9733
10447
  return mysqlTable("UserPrefs", {
9734
- id: (0, import_mysql_core23.varchar)("id", {
10448
+ id: (0, import_mysql_core31.varchar)("id", {
9735
10449
  length: 191
9736
10450
  }).notNull(),
9737
- type: (0, import_mysql_core23.varchar)("type", {
10451
+ organizationId: (0, import_mysql_core31.varchar)("organizationId", {
10452
+ length: 191
10453
+ }),
10454
+ type: (0, import_mysql_core31.varchar)("type", {
9738
10455
  length: 191
9739
10456
  }).default("Global").notNull(),
9740
- userId: (0, import_mysql_core23.varchar)("userId", {
10457
+ userId: (0, import_mysql_core31.varchar)("userId", {
9741
10458
  length: 255
9742
10459
  }).notNull(),
9743
- fields: (0, import_mysql_core23.json)("fields").$type().default({}),
9744
- createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
10460
+ fields: (0, import_mysql_core31.json)("fields").$type().default({}),
10461
+ createdAt: (0, import_mysql_core31.timestamp)("createdAt", {
9745
10462
  mode: "date",
9746
10463
  fsp: 3
9747
- }).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
9748
- updatedAt: (0, import_mysql_core23.timestamp)("updatedAt", {
10464
+ }).default(import_drizzle_orm27.sql`CURRENT_TIMESTAMP(3)`),
10465
+ updatedAt: (0, import_mysql_core31.timestamp)("updatedAt", {
9749
10466
  mode: "date",
9750
10467
  fsp: 3
9751
- }).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
9752
- deletedAt: (0, import_mysql_core23.timestamp)("deletedAt", {
10468
+ }).default(import_drizzle_orm27.sql`CURRENT_TIMESTAMP(3)`),
10469
+ deletedAt: (0, import_mysql_core31.timestamp)("deletedAt", {
9753
10470
  mode: "date",
9754
10471
  fsp: 3
9755
10472
  })
9756
10473
  }, (crr) => ({
9757
- pk: (0, import_mysql_core23.primaryKey)({
10474
+ pk: (0, import_mysql_core31.primaryKey)({
9758
10475
  columns: [
9759
10476
  crr.id
9760
10477
  ]
9761
10478
  }),
9762
- crrUserIdIdKey: (0, import_mysql_core23.index)("crr_userIdId_idx").on(crr.userId)
10479
+ crrUserIdIdKey: (0, import_mysql_core31.index)("crr_userIdId_idx").on(crr.userId),
10480
+ organizationIdIdx: (0, import_mysql_core31.index)("organizationId_idx").on(crr.organizationId)
9763
10481
  }));
9764
10482
  }
9765
10483
  __name(getUserPrefsSchema, "getUserPrefsSchema");
9766
10484
  function getUserPrefsRelationsSchema(mysqlTable) {
9767
10485
  const userPrefs = getUserPrefsSchema(mysqlTable);
9768
10486
  const user = getUsersSchema(mysqlTable);
9769
- return (0, import_drizzle_orm19.relations)(userPrefs, ({ one }) => ({
10487
+ return (0, import_drizzle_orm27.relations)(userPrefs, ({ one }) => ({
9770
10488
  user: one(user, {
9771
10489
  fields: [
9772
10490
  userPrefs.userId
@@ -9781,43 +10499,47 @@ function getUserPrefsRelationsSchema(mysqlTable) {
9781
10499
  __name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
9782
10500
 
9783
10501
  // src/lib/mysql/schemas/auth/user-roles.ts
9784
- var import_drizzle_orm21 = require("drizzle-orm");
9785
- var import_mysql_core25 = require("drizzle-orm/mysql-core");
10502
+ var import_drizzle_orm29 = require("drizzle-orm");
10503
+ var import_mysql_core33 = require("drizzle-orm/mysql-core");
9786
10504
 
9787
10505
  // src/lib/mysql/schemas/auth/roles.ts
9788
- var import_drizzle_orm20 = require("drizzle-orm");
9789
- var import_mysql_core24 = require("drizzle-orm/mysql-core");
10506
+ var import_drizzle_orm28 = require("drizzle-orm");
10507
+ var import_mysql_core32 = require("drizzle-orm/mysql-core");
9790
10508
  function getRolesSchema(mysqlTable) {
9791
10509
  return mysqlTable("Role", {
9792
- id: (0, import_mysql_core24.varchar)("id", {
10510
+ id: (0, import_mysql_core32.varchar)("id", {
9793
10511
  length: 255
9794
10512
  }).notNull().primaryKey(),
9795
- name: (0, import_mysql_core24.varchar)("name", {
10513
+ organizationId: (0, import_mysql_core32.varchar)("organizationId", {
10514
+ length: 191
10515
+ }),
10516
+ name: (0, import_mysql_core32.varchar)("name", {
9796
10517
  length: 255
9797
10518
  }).notNull().unique(),
9798
- description: (0, import_mysql_core24.text)("description"),
9799
- active: (0, import_mysql_core24.boolean)("active").notNull().default(true),
9800
- createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
10519
+ description: (0, import_mysql_core32.text)("description"),
10520
+ active: (0, import_mysql_core32.boolean)("active").notNull().default(true),
10521
+ createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
9801
10522
  mode: "date",
9802
10523
  fsp: 3
9803
10524
  }).defaultNow(),
9804
- updatedAt: (0, import_mysql_core24.timestamp)("updatedAt", {
10525
+ updatedAt: (0, import_mysql_core32.timestamp)("updatedAt", {
9805
10526
  mode: "date",
9806
10527
  fsp: 3
9807
10528
  }).defaultNow(),
9808
- deletedAt: (0, import_mysql_core24.timestamp)("deletedAt", {
10529
+ deletedAt: (0, import_mysql_core32.timestamp)("deletedAt", {
9809
10530
  mode: "date",
9810
10531
  fsp: 3
9811
10532
  })
9812
10533
  }, (role) => ({
9813
- nameIdx: (0, import_mysql_core24.index)("name_idx").on(role.name)
10534
+ nameIdx: (0, import_mysql_core32.index)("name_idx").on(role.name),
10535
+ organizationIdIdx: (0, import_mysql_core32.index)("organizationId_idx").on(role.organizationId)
9814
10536
  }));
9815
10537
  }
9816
10538
  __name(getRolesSchema, "getRolesSchema");
9817
10539
  function getRolesRelationsSchema(mysqlTable) {
9818
10540
  const roles = getRolesSchema(mysqlTable);
9819
10541
  const userRoles = getUserRolesSchema(mysqlTable);
9820
- return (0, import_drizzle_orm20.relations)(roles, ({ many }) => ({
10542
+ return (0, import_drizzle_orm28.relations)(roles, ({ many }) => ({
9821
10543
  userRoles: many(userRoles, {
9822
10544
  relationName: "role"
9823
10545
  })
@@ -9828,34 +10550,38 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
9828
10550
  // src/lib/mysql/schemas/auth/user-roles.ts
9829
10551
  function getUserRolesSchema(mysqlTable) {
9830
10552
  return mysqlTable("UserRole", {
9831
- userId: (0, import_mysql_core25.varchar)("userId", {
10553
+ userId: (0, import_mysql_core33.varchar)("userId", {
9832
10554
  length: 255
9833
10555
  }).notNull(),
9834
- roleId: (0, import_mysql_core25.varchar)("roleId", {
10556
+ roleId: (0, import_mysql_core33.varchar)("roleId", {
9835
10557
  length: 255
9836
10558
  }).notNull(),
9837
- active: (0, import_mysql_core25.boolean)("active").notNull().default(true),
9838
- createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
10559
+ active: (0, import_mysql_core33.boolean)("active").notNull().default(true),
10560
+ organizationId: (0, import_mysql_core33.varchar)("organizationId", {
10561
+ length: 191
10562
+ }),
10563
+ createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
9839
10564
  mode: "date",
9840
10565
  fsp: 3
9841
10566
  }).defaultNow(),
9842
- updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
10567
+ updatedAt: (0, import_mysql_core33.timestamp)("updatedAt", {
9843
10568
  mode: "date",
9844
10569
  fsp: 3
9845
10570
  }).defaultNow(),
9846
- deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
10571
+ deletedAt: (0, import_mysql_core33.timestamp)("deletedAt", {
9847
10572
  mode: "date",
9848
10573
  fsp: 3
9849
10574
  })
9850
10575
  }, (ur) => ({
9851
- pk: (0, import_mysql_core25.primaryKey)({
10576
+ pk: (0, import_mysql_core33.primaryKey)({
9852
10577
  columns: [
9853
10578
  ur.userId,
9854
10579
  ur.roleId
9855
10580
  ]
9856
10581
  }),
9857
- userIdIdx: (0, import_mysql_core25.index)("userId_idx").on(ur.userId),
9858
- roleIdIdx: (0, import_mysql_core25.index)("roleId_idx").on(ur.roleId)
10582
+ userIdIdx: (0, import_mysql_core33.index)("userId_idx").on(ur.userId),
10583
+ roleIdIdx: (0, import_mysql_core33.index)("roleId_idx").on(ur.roleId),
10584
+ organizationIdIdx: (0, import_mysql_core33.index)("organizationId_idx").on(ur.organizationId)
9859
10585
  }));
9860
10586
  }
9861
10587
  __name(getUserRolesSchema, "getUserRolesSchema");
@@ -9863,7 +10589,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
9863
10589
  const userRoles = getUserRolesSchema(mysqlTable);
9864
10590
  const users = getUsersSchema(mysqlTable);
9865
10591
  const roles = getRolesSchema(mysqlTable);
9866
- return (0, import_drizzle_orm21.relations)(userRoles, ({ one }) => ({
10592
+ return (0, import_drizzle_orm29.relations)(userRoles, ({ one }) => ({
9867
10593
  user: one(users, {
9868
10594
  fields: [
9869
10595
  userRoles.userId
@@ -9889,34 +10615,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
9889
10615
  // src/lib/mysql/schemas/auth/users.ts
9890
10616
  function getUsersSchema(mysqlTable) {
9891
10617
  return mysqlTable("User", {
9892
- id: (0, import_mysql_core26.varchar)("id", {
10618
+ id: (0, import_mysql_core34.varchar)("id", {
9893
10619
  length: 255
9894
10620
  }).notNull().primaryKey(),
9895
- name: (0, import_mysql_core26.varchar)("name", {
10621
+ name: (0, import_mysql_core34.varchar)("name", {
9896
10622
  length: 255
9897
10623
  }),
9898
- role: (0, import_mysql_core26.varchar)("role", {
10624
+ role: (0, import_mysql_core34.varchar)("role", {
9899
10625
  length: 191
9900
10626
  }).notNull().default("user"),
9901
- email: (0, import_mysql_core26.varchar)("email", {
10627
+ email: (0, import_mysql_core34.varchar)("email", {
9902
10628
  length: 255
9903
10629
  }).notNull().unique(),
9904
- fields: (0, import_mysql_core26.json)("fields").$type().default({}),
9905
- emailVerified: (0, import_mysql_core26.timestamp)("emailVerified", {
10630
+ fields: (0, import_mysql_core34.json)("fields").$type().default({}),
10631
+ emailVerified: (0, import_mysql_core34.timestamp)("emailVerified", {
9906
10632
  mode: "date",
9907
10633
  fsp: 3
9908
10634
  }),
9909
- image: (0, import_mysql_core26.varchar)("image", {
10635
+ image: (0, import_mysql_core34.varchar)("image", {
9910
10636
  length: 255
9911
10637
  }),
9912
- createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
10638
+ createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
9913
10639
  mode: "date",
9914
10640
  fsp: 3
9915
- }).default(import_drizzle_orm22.sql`CURRENT_TIMESTAMP(3)`)
10641
+ }).default(import_drizzle_orm30.sql`CURRENT_TIMESTAMP(3)`)
9916
10642
  }, (user) => ({
9917
- emailIdx: (0, import_mysql_core26.index)("email_idx").on(user.email),
9918
- roleIdx: (0, import_mysql_core26.index)("role_idx").on(user.role),
9919
- createdAtIdx: (0, import_mysql_core26.index)("created_at_idx").on(user.createdAt)
10643
+ emailIdx: (0, import_mysql_core34.index)("email_idx").on(user.email),
10644
+ roleIdx: (0, import_mysql_core34.index)("role_idx").on(user.role),
10645
+ createdAtIdx: (0, import_mysql_core34.index)("created_at_idx").on(user.createdAt)
9920
10646
  }));
9921
10647
  }
9922
10648
  __name(getUsersSchema, "getUsersSchema");
@@ -9931,7 +10657,8 @@ function getUsersRelationsSchema(mysqlTable) {
9931
10657
  const purchases = getPurchaseSchema(mysqlTable);
9932
10658
  const comments = getCommentsSchema(mysqlTable);
9933
10659
  const userPrefs = getUserPrefsSchema(mysqlTable);
9934
- return (0, import_drizzle_orm22.relations)(users, ({ many }) => ({
10660
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10661
+ return (0, import_drizzle_orm30.relations)(users, ({ many }) => ({
9935
10662
  accounts: many(accounts, {
9936
10663
  relationName: "user"
9937
10664
  }),
@@ -9958,6 +10685,9 @@ function getUsersRelationsSchema(mysqlTable) {
9958
10685
  }),
9959
10686
  prefs: many(userPrefs, {
9960
10687
  relationName: "user"
10688
+ }),
10689
+ organizationMemberships: many(organizationMemberships, {
10690
+ relationName: "user"
9961
10691
  })
9962
10692
  }));
9963
10693
  }
@@ -9966,49 +10696,49 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
9966
10696
  // src/lib/mysql/schemas/auth/accounts.ts
9967
10697
  function getAccountsSchema(mysqlTable) {
9968
10698
  return mysqlTable("Account", {
9969
- userId: (0, import_mysql_core27.varchar)("userId", {
10699
+ userId: (0, import_mysql_core35.varchar)("userId", {
9970
10700
  length: 255
9971
10701
  }).notNull(),
9972
- type: (0, import_mysql_core27.varchar)("type", {
10702
+ type: (0, import_mysql_core35.varchar)("type", {
9973
10703
  length: 255
9974
10704
  }).$type().notNull(),
9975
- provider: (0, import_mysql_core27.varchar)("provider", {
10705
+ provider: (0, import_mysql_core35.varchar)("provider", {
9976
10706
  length: 255
9977
10707
  }).notNull(),
9978
- providerAccountId: (0, import_mysql_core27.varchar)("providerAccountId", {
10708
+ providerAccountId: (0, import_mysql_core35.varchar)("providerAccountId", {
9979
10709
  length: 255
9980
10710
  }).notNull(),
9981
- refresh_token: (0, import_mysql_core27.text)("refresh_token"),
9982
- access_token: (0, import_mysql_core27.text)("access_token"),
9983
- oauth_token: (0, import_mysql_core27.text)("oauth_token"),
9984
- oauth_token_secret: (0, import_mysql_core27.text)("oauth_token_secret"),
9985
- expires_at: (0, import_mysql_core27.int)("expires_at"),
9986
- token_type: (0, import_mysql_core27.varchar)("token_type", {
10711
+ refresh_token: (0, import_mysql_core35.text)("refresh_token"),
10712
+ access_token: (0, import_mysql_core35.text)("access_token"),
10713
+ oauth_token: (0, import_mysql_core35.text)("oauth_token"),
10714
+ oauth_token_secret: (0, import_mysql_core35.text)("oauth_token_secret"),
10715
+ expires_at: (0, import_mysql_core35.int)("expires_at"),
10716
+ token_type: (0, import_mysql_core35.varchar)("token_type", {
9987
10717
  length: 255
9988
10718
  }),
9989
- scope: (0, import_mysql_core27.varchar)("scope", {
10719
+ scope: (0, import_mysql_core35.varchar)("scope", {
9990
10720
  length: 255
9991
10721
  }),
9992
- id_token: (0, import_mysql_core27.text)("id_token"),
9993
- session_state: (0, import_mysql_core27.varchar)("session_state", {
10722
+ id_token: (0, import_mysql_core35.text)("id_token"),
10723
+ session_state: (0, import_mysql_core35.varchar)("session_state", {
9994
10724
  length: 255
9995
10725
  }),
9996
- refresh_token_expires_in: (0, import_mysql_core27.int)("refresh_token_expires_in")
10726
+ refresh_token_expires_in: (0, import_mysql_core35.int)("refresh_token_expires_in")
9997
10727
  }, (account) => ({
9998
- pk: (0, import_mysql_core27.primaryKey)({
10728
+ pk: (0, import_mysql_core35.primaryKey)({
9999
10729
  columns: [
10000
10730
  account.provider,
10001
10731
  account.providerAccountId
10002
10732
  ]
10003
10733
  }),
10004
- userIdIdx: (0, import_mysql_core27.index)("userId_idx").on(account.userId)
10734
+ userIdIdx: (0, import_mysql_core35.index)("userId_idx").on(account.userId)
10005
10735
  }));
10006
10736
  }
10007
10737
  __name(getAccountsSchema, "getAccountsSchema");
10008
10738
  function getAccountsRelationsSchema(mysqlTable) {
10009
10739
  const accounts = getAccountsSchema(mysqlTable);
10010
10740
  const users = getUsersSchema(mysqlTable);
10011
- return (0, import_drizzle_orm23.relations)(accounts, ({ one }) => ({
10741
+ return (0, import_drizzle_orm31.relations)(accounts, ({ one }) => ({
10012
10742
  user: one(users, {
10013
10743
  fields: [
10014
10744
  accounts.userId
@@ -10023,34 +10753,37 @@ function getAccountsRelationsSchema(mysqlTable) {
10023
10753
  __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
10024
10754
 
10025
10755
  // src/lib/mysql/schemas/auth/device-access-token.ts
10026
- var import_drizzle_orm24 = require("drizzle-orm");
10027
- var import_mysql_core28 = require("drizzle-orm/mysql-core");
10756
+ var import_drizzle_orm32 = require("drizzle-orm");
10757
+ var import_mysql_core36 = require("drizzle-orm/mysql-core");
10028
10758
  function getDeviceAccessTokenSchema(mysqlTable) {
10029
10759
  return mysqlTable("DeviceAccessToken", {
10030
- token: (0, import_mysql_core28.varchar)("token", {
10760
+ token: (0, import_mysql_core36.varchar)("token", {
10031
10761
  length: 191
10032
10762
  }).notNull(),
10033
- userId: (0, import_mysql_core28.varchar)("userId", {
10763
+ userId: (0, import_mysql_core36.varchar)("userId", {
10034
10764
  length: 191
10035
10765
  }).notNull(),
10036
- createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
10766
+ organizationMembershipId: (0, import_mysql_core36.varchar)("organizationMembershipId", {
10767
+ length: 191
10768
+ }),
10769
+ createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
10037
10770
  mode: "date",
10038
10771
  fsp: 3
10039
- }).default(import_drizzle_orm24.sql`CURRENT_TIMESTAMP(3)`)
10772
+ }).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`)
10040
10773
  }, (crr) => ({
10041
- pk: (0, import_mysql_core28.primaryKey)({
10774
+ pk: (0, import_mysql_core36.primaryKey)({
10042
10775
  columns: [
10043
10776
  crr.token
10044
10777
  ]
10045
10778
  }),
10046
- userIdIdx: (0, import_mysql_core28.index)("userId_idx").on(crr.userId)
10779
+ userIdIdx: (0, import_mysql_core36.index)("userId_idx").on(crr.userId)
10047
10780
  }));
10048
10781
  }
10049
10782
  __name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
10050
10783
  function getDeviceAccessTokenRelationsSchema(mysqlTable) {
10051
10784
  const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
10052
10785
  const user = getUsersSchema(mysqlTable);
10053
- return (0, import_drizzle_orm24.relations)(deviceAccessToken, ({ one }) => ({
10786
+ return (0, import_drizzle_orm32.relations)(deviceAccessToken, ({ one }) => ({
10054
10787
  verifiedBy: one(user, {
10055
10788
  fields: [
10056
10789
  deviceAccessToken.userId
@@ -10065,31 +10798,31 @@ function getDeviceAccessTokenRelationsSchema(mysqlTable) {
10065
10798
  __name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
10066
10799
 
10067
10800
  // src/lib/mysql/schemas/auth/device-verification.ts
10068
- var import_drizzle_orm25 = require("drizzle-orm");
10069
- var import_mysql_core29 = require("drizzle-orm/mysql-core");
10801
+ var import_drizzle_orm33 = require("drizzle-orm");
10802
+ var import_mysql_core37 = require("drizzle-orm/mysql-core");
10070
10803
  function getDeviceVerificationSchema(mysqlTable) {
10071
10804
  return mysqlTable("DeviceVerification", {
10072
- verifiedByUserId: (0, import_mysql_core29.varchar)("verifiedByUserId", {
10805
+ verifiedByUserId: (0, import_mysql_core37.varchar)("verifiedByUserId", {
10073
10806
  length: 255
10074
10807
  }),
10075
- deviceCode: (0, import_mysql_core29.varchar)("deviceCode", {
10808
+ deviceCode: (0, import_mysql_core37.varchar)("deviceCode", {
10076
10809
  length: 191
10077
10810
  }).notNull(),
10078
- userCode: (0, import_mysql_core29.text)("userCode").notNull(),
10079
- expires: (0, import_mysql_core29.timestamp)("expires", {
10811
+ userCode: (0, import_mysql_core37.text)("userCode").notNull(),
10812
+ expires: (0, import_mysql_core37.timestamp)("expires", {
10080
10813
  mode: "date",
10081
10814
  fsp: 3
10082
10815
  }).notNull(),
10083
- createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
10816
+ createdAt: (0, import_mysql_core37.timestamp)("createdAt", {
10084
10817
  mode: "date",
10085
10818
  fsp: 3
10086
- }).default(import_drizzle_orm25.sql`CURRENT_TIMESTAMP(3)`),
10087
- verifiedAt: (0, import_mysql_core29.timestamp)("verifiedAt", {
10819
+ }).default(import_drizzle_orm33.sql`CURRENT_TIMESTAMP(3)`),
10820
+ verifiedAt: (0, import_mysql_core37.timestamp)("verifiedAt", {
10088
10821
  mode: "date",
10089
10822
  fsp: 3
10090
10823
  })
10091
10824
  }, (crr) => ({
10092
- pk: (0, import_mysql_core29.primaryKey)({
10825
+ pk: (0, import_mysql_core37.primaryKey)({
10093
10826
  columns: [
10094
10827
  crr.deviceCode
10095
10828
  ]
@@ -10100,7 +10833,7 @@ __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
10100
10833
  function getDeviceVerificationRelationsSchema(mysqlTable) {
10101
10834
  const deviceVerification = getDeviceVerificationSchema(mysqlTable);
10102
10835
  const user = getUsersSchema(mysqlTable);
10103
- return (0, import_drizzle_orm25.relations)(deviceVerification, ({ one }) => ({
10836
+ return (0, import_drizzle_orm33.relations)(deviceVerification, ({ one }) => ({
10104
10837
  verifiedBy: one(user, {
10105
10838
  fields: [
10106
10839
  deviceVerification.verifiedByUserId
@@ -10115,38 +10848,38 @@ function getDeviceVerificationRelationsSchema(mysqlTable) {
10115
10848
  __name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
10116
10849
 
10117
10850
  // src/lib/mysql/schemas/auth/role-permissions.ts
10118
- var import_drizzle_orm26 = require("drizzle-orm");
10119
- var import_mysql_core30 = require("drizzle-orm/mysql-core");
10851
+ var import_drizzle_orm34 = require("drizzle-orm");
10852
+ var import_mysql_core38 = require("drizzle-orm/mysql-core");
10120
10853
  function getRolePermissionsSchema(mysqlTable) {
10121
10854
  return mysqlTable("RolePermission", {
10122
- roleId: (0, import_mysql_core30.varchar)("roleId", {
10855
+ roleId: (0, import_mysql_core38.varchar)("roleId", {
10123
10856
  length: 255
10124
10857
  }).notNull(),
10125
- permissionId: (0, import_mysql_core30.varchar)("permissionId", {
10858
+ permissionId: (0, import_mysql_core38.varchar)("permissionId", {
10126
10859
  length: 255
10127
10860
  }).notNull(),
10128
- active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
10129
- createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
10861
+ active: (0, import_mysql_core38.boolean)("active").notNull().default(true),
10862
+ createdAt: (0, import_mysql_core38.timestamp)("createdAt", {
10130
10863
  mode: "date",
10131
10864
  fsp: 3
10132
10865
  }).defaultNow(),
10133
- updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
10866
+ updatedAt: (0, import_mysql_core38.timestamp)("updatedAt", {
10134
10867
  mode: "date",
10135
10868
  fsp: 3
10136
10869
  }).defaultNow(),
10137
- deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
10870
+ deletedAt: (0, import_mysql_core38.timestamp)("deletedAt", {
10138
10871
  mode: "date",
10139
10872
  fsp: 3
10140
10873
  })
10141
10874
  }, (rp) => ({
10142
- pk: (0, import_mysql_core30.primaryKey)({
10875
+ pk: (0, import_mysql_core38.primaryKey)({
10143
10876
  columns: [
10144
10877
  rp.roleId,
10145
10878
  rp.permissionId
10146
10879
  ]
10147
10880
  }),
10148
- roleIdIdx: (0, import_mysql_core30.index)("roleId_idx").on(rp.roleId),
10149
- permissionIdIdx: (0, import_mysql_core30.index)("permissionId_idx").on(rp.permissionId)
10881
+ roleIdIdx: (0, import_mysql_core38.index)("roleId_idx").on(rp.roleId),
10882
+ permissionIdIdx: (0, import_mysql_core38.index)("permissionId_idx").on(rp.permissionId)
10150
10883
  }));
10151
10884
  }
10152
10885
  __name(getRolePermissionsSchema, "getRolePermissionsSchema");
@@ -10154,7 +10887,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
10154
10887
  const permissions = getPermissionsSchema(mysqlTable);
10155
10888
  const roles = getRolesSchema(mysqlTable);
10156
10889
  const rolePermissions = getRolePermissionsSchema(mysqlTable);
10157
- return (0, import_drizzle_orm26.relations)(rolePermissions, ({ one }) => ({
10890
+ return (0, import_drizzle_orm34.relations)(rolePermissions, ({ one }) => ({
10158
10891
  role: one(roles, {
10159
10892
  fields: [
10160
10893
  rolePermissions.roleId
@@ -10178,28 +10911,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
10178
10911
  __name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
10179
10912
 
10180
10913
  // src/lib/mysql/schemas/auth/sessions.ts
10181
- var import_drizzle_orm27 = require("drizzle-orm");
10182
- var import_mysql_core31 = require("drizzle-orm/mysql-core");
10914
+ var import_drizzle_orm35 = require("drizzle-orm");
10915
+ var import_mysql_core39 = require("drizzle-orm/mysql-core");
10183
10916
  function getSessionsSchema(mysqlTable) {
10184
10917
  return mysqlTable("Session", {
10185
- sessionToken: (0, import_mysql_core31.varchar)("sessionToken", {
10918
+ sessionToken: (0, import_mysql_core39.varchar)("sessionToken", {
10186
10919
  length: 255
10187
10920
  }).notNull().primaryKey(),
10188
- userId: (0, import_mysql_core31.varchar)("userId", {
10921
+ userId: (0, import_mysql_core39.varchar)("userId", {
10189
10922
  length: 255
10190
10923
  }).notNull(),
10191
- expires: (0, import_mysql_core31.timestamp)("expires", {
10924
+ expires: (0, import_mysql_core39.timestamp)("expires", {
10192
10925
  mode: "date"
10193
10926
  }).notNull()
10194
10927
  }, (session) => ({
10195
- userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(session.userId)
10928
+ userIdIdx: (0, import_mysql_core39.index)("userId_idx").on(session.userId)
10196
10929
  }));
10197
10930
  }
10198
10931
  __name(getSessionsSchema, "getSessionsSchema");
10199
10932
  function getSessionRelationsSchema(mysqlTable) {
10200
10933
  const sessions = getSessionsSchema(mysqlTable);
10201
10934
  const users = getUsersSchema(mysqlTable);
10202
- return (0, import_drizzle_orm27.relations)(sessions, ({ one }) => ({
10935
+ return (0, import_drizzle_orm35.relations)(sessions, ({ one }) => ({
10203
10936
  user: one(users, {
10204
10937
  fields: [
10205
10938
  sessions.userId
@@ -10214,24 +10947,24 @@ function getSessionRelationsSchema(mysqlTable) {
10214
10947
  __name(getSessionRelationsSchema, "getSessionRelationsSchema");
10215
10948
 
10216
10949
  // src/lib/mysql/schemas/auth/verification-tokens.ts
10217
- var import_mysql_core32 = require("drizzle-orm/mysql-core");
10950
+ var import_mysql_core40 = require("drizzle-orm/mysql-core");
10218
10951
  function getVerificationTokensSchema(mysqlTable) {
10219
10952
  return mysqlTable("VerificationToken", {
10220
- identifier: (0, import_mysql_core32.varchar)("identifier", {
10953
+ identifier: (0, import_mysql_core40.varchar)("identifier", {
10221
10954
  length: 255
10222
10955
  }).notNull(),
10223
- token: (0, import_mysql_core32.varchar)("token", {
10956
+ token: (0, import_mysql_core40.varchar)("token", {
10224
10957
  length: 255
10225
10958
  }).notNull(),
10226
- expires: (0, import_mysql_core32.timestamp)("expires", {
10959
+ expires: (0, import_mysql_core40.timestamp)("expires", {
10227
10960
  mode: "date"
10228
10961
  }).notNull(),
10229
- createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
10962
+ createdAt: (0, import_mysql_core40.timestamp)("createdAt", {
10230
10963
  mode: "date",
10231
10964
  fsp: 3
10232
10965
  }).defaultNow()
10233
10966
  }, (vt) => ({
10234
- pk: (0, import_mysql_core32.primaryKey)({
10967
+ pk: (0, import_mysql_core40.primaryKey)({
10235
10968
  columns: [
10236
10969
  vt.identifier,
10237
10970
  vt.token
@@ -10242,14 +10975,14 @@ function getVerificationTokensSchema(mysqlTable) {
10242
10975
  __name(getVerificationTokensSchema, "getVerificationTokensSchema");
10243
10976
 
10244
10977
  // src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
10245
- var import_drizzle_orm28 = require("drizzle-orm");
10246
- var import_mysql_core33 = require("drizzle-orm/mysql-core");
10978
+ var import_drizzle_orm36 = require("drizzle-orm");
10979
+ var import_mysql_core41 = require("drizzle-orm/mysql-core");
10247
10980
  function getPurchaseUserTransferSchema(mysqlTable) {
10248
10981
  return mysqlTable("PurchaseUserTransfer", {
10249
- id: (0, import_mysql_core33.varchar)("id", {
10982
+ id: (0, import_mysql_core41.varchar)("id", {
10250
10983
  length: 191
10251
10984
  }).notNull(),
10252
- transferState: (0, import_mysql_core33.mysqlEnum)("transferState", [
10985
+ transferState: (0, import_mysql_core41.mysqlEnum)("transferState", [
10253
10986
  "AVAILABLE",
10254
10987
  "INITIATED",
10255
10988
  "VERIFIED",
@@ -10258,43 +10991,47 @@ function getPurchaseUserTransferSchema(mysqlTable) {
10258
10991
  "CONFIRMED",
10259
10992
  "COMPLETED"
10260
10993
  ]).default("AVAILABLE").notNull(),
10261
- purchaseId: (0, import_mysql_core33.varchar)("purchaseId", {
10994
+ purchaseId: (0, import_mysql_core41.varchar)("purchaseId", {
10262
10995
  length: 191
10263
10996
  }).notNull(),
10264
- sourceUserId: (0, import_mysql_core33.varchar)("sourceUserId", {
10997
+ organizationId: (0, import_mysql_core41.varchar)("organizationId", {
10998
+ length: 191
10999
+ }),
11000
+ sourceUserId: (0, import_mysql_core41.varchar)("sourceUserId", {
10265
11001
  length: 191
10266
11002
  }).notNull(),
10267
- targetUserId: (0, import_mysql_core33.varchar)("targetUserId", {
11003
+ targetUserId: (0, import_mysql_core41.varchar)("targetUserId", {
10268
11004
  length: 191
10269
11005
  }),
10270
- createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
11006
+ createdAt: (0, import_mysql_core41.timestamp)("createdAt", {
10271
11007
  mode: "date",
10272
11008
  fsp: 3
10273
- }).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`).notNull(),
10274
- expiresAt: (0, import_mysql_core33.timestamp)("expiresAt", {
11009
+ }).default(import_drizzle_orm36.sql`CURRENT_TIMESTAMP(3)`).notNull(),
11010
+ expiresAt: (0, import_mysql_core41.timestamp)("expiresAt", {
10275
11011
  mode: "date",
10276
11012
  fsp: 3
10277
11013
  }),
10278
- canceledAt: (0, import_mysql_core33.timestamp)("canceledAt", {
11014
+ canceledAt: (0, import_mysql_core41.timestamp)("canceledAt", {
10279
11015
  mode: "date",
10280
11016
  fsp: 3
10281
11017
  }),
10282
- confirmedAt: (0, import_mysql_core33.timestamp)("confirmedAt", {
11018
+ confirmedAt: (0, import_mysql_core41.timestamp)("confirmedAt", {
10283
11019
  mode: "date",
10284
11020
  fsp: 3
10285
11021
  }),
10286
- completedAt: (0, import_mysql_core33.timestamp)("completedAt", {
11022
+ completedAt: (0, import_mysql_core41.timestamp)("completedAt", {
10287
11023
  mode: "date",
10288
11024
  fsp: 3
10289
11025
  })
10290
11026
  }, (table) => {
10291
11027
  return {
10292
- purchaseUserTransferId: (0, import_mysql_core33.primaryKey)({
11028
+ purchaseUserTransferId: (0, import_mysql_core41.primaryKey)({
10293
11029
  columns: [
10294
11030
  table.id
10295
11031
  ],
10296
11032
  name: "PurchaseUserTransfer_id"
10297
- })
11033
+ }),
11034
+ organizationIdIdx: (0, import_mysql_core41.index)("organizationId_idx").on(table.organizationId)
10298
11035
  };
10299
11036
  });
10300
11037
  }
@@ -10303,7 +11040,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
10303
11040
  const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
10304
11041
  const user = getUsersSchema(mysqlTable);
10305
11042
  const purchase = getPurchaseSchema(mysqlTable);
10306
- return (0, import_drizzle_orm28.relations)(purchaseUserTransfer, ({ one }) => ({
11043
+ return (0, import_drizzle_orm36.relations)(purchaseUserTransfer, ({ one }) => ({
10307
11044
  sourceUser: one(user, {
10308
11045
  fields: [
10309
11046
  purchaseUserTransfer.sourceUserId
@@ -10336,46 +11073,50 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
10336
11073
  __name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
10337
11074
 
10338
11075
  // src/lib/mysql/schemas/commerce/upgradable-products.ts
10339
- var import_drizzle_orm29 = require("drizzle-orm");
10340
- var import_mysql_core34 = require("drizzle-orm/mysql-core");
11076
+ var import_drizzle_orm37 = require("drizzle-orm");
11077
+ var import_mysql_core42 = require("drizzle-orm/mysql-core");
10341
11078
  function getUpgradableProductsSchema(mysqlTable) {
10342
11079
  return mysqlTable("UpgradableProducts", {
10343
- upgradableToId: (0, import_mysql_core34.varchar)("upgradableToId", {
11080
+ upgradableToId: (0, import_mysql_core42.varchar)("upgradableToId", {
10344
11081
  length: 255
10345
11082
  }).notNull(),
10346
- upgradableFromId: (0, import_mysql_core34.varchar)("upgradableFrom", {
11083
+ upgradableFromId: (0, import_mysql_core42.varchar)("upgradableFrom", {
10347
11084
  length: 255
10348
11085
  }).notNull(),
10349
- position: (0, import_mysql_core34.double)("position").notNull().default(0),
10350
- metadata: (0, import_mysql_core34.json)("metadata").$type().default({}),
10351
- createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
11086
+ organizationId: (0, import_mysql_core42.varchar)("organizationId", {
11087
+ length: 191
11088
+ }),
11089
+ position: (0, import_mysql_core42.double)("position").notNull().default(0),
11090
+ metadata: (0, import_mysql_core42.json)("metadata").$type().default({}),
11091
+ createdAt: (0, import_mysql_core42.timestamp)("createdAt", {
10352
11092
  mode: "date",
10353
11093
  fsp: 3
10354
- }).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
10355
- updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
11094
+ }).default(import_drizzle_orm37.sql`CURRENT_TIMESTAMP(3)`),
11095
+ updatedAt: (0, import_mysql_core42.timestamp)("updatedAt", {
10356
11096
  mode: "date",
10357
11097
  fsp: 3
10358
- }).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
10359
- deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
11098
+ }).default(import_drizzle_orm37.sql`CURRENT_TIMESTAMP(3)`),
11099
+ deletedAt: (0, import_mysql_core42.timestamp)("deletedAt", {
10360
11100
  mode: "date",
10361
11101
  fsp: 3
10362
11102
  })
10363
11103
  }, (crr) => ({
10364
- pk: (0, import_mysql_core34.primaryKey)({
11104
+ pk: (0, import_mysql_core42.primaryKey)({
10365
11105
  columns: [
10366
11106
  crr.upgradableToId,
10367
11107
  crr.upgradableFromId
10368
11108
  ]
10369
11109
  }),
10370
- upgradableToIdIdx: (0, import_mysql_core34.index)("upgradableFromId_idx").on(crr.upgradableToId),
10371
- upgradableFromIdIdx: (0, import_mysql_core34.index)("upgradableToId_idx").on(crr.upgradableFromId)
11110
+ upgradableToIdIdx: (0, import_mysql_core42.index)("upgradableFromId_idx").on(crr.upgradableToId),
11111
+ upgradableFromIdIdx: (0, import_mysql_core42.index)("upgradableToId_idx").on(crr.upgradableFromId),
11112
+ organizationIdIdx: (0, import_mysql_core42.index)("organizationId_idx").on(crr.organizationId)
10372
11113
  }));
10373
11114
  }
10374
11115
  __name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
10375
11116
  function getUpgradableProductsRelationsSchema(mysqlTable) {
10376
11117
  const product = getProductSchema(mysqlTable);
10377
11118
  const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
10378
- return (0, import_drizzle_orm29.relations)(upgradableProduct, ({ one }) => ({
11119
+ return (0, import_drizzle_orm37.relations)(upgradableProduct, ({ one }) => ({
10379
11120
  upgradableTo: one(product, {
10380
11121
  fields: [
10381
11122
  upgradableProduct.upgradableToId
@@ -10399,93 +11140,175 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
10399
11140
  __name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
10400
11141
 
10401
11142
  // src/lib/mysql/schemas/content/lesson-progress.ts
10402
- var import_drizzle_orm30 = require("drizzle-orm");
10403
- var import_mysql_core35 = require("drizzle-orm/mysql-core");
11143
+ var import_drizzle_orm38 = require("drizzle-orm");
11144
+ var import_mysql_core43 = require("drizzle-orm/mysql-core");
10404
11145
  function getLessonProgressSchema(mysqlTable) {
10405
11146
  return mysqlTable("LessonProgress", {
10406
- id: (0, import_mysql_core35.varchar)("id", {
11147
+ id: (0, import_mysql_core43.varchar)("id", {
10407
11148
  length: 191
10408
11149
  }).notNull().primaryKey(),
10409
- userId: (0, import_mysql_core35.varchar)("userId", {
11150
+ userId: (0, import_mysql_core43.varchar)("userId", {
10410
11151
  length: 191
10411
11152
  }).notNull(),
10412
- lessonId: (0, import_mysql_core35.varchar)("lessonId", {
11153
+ organizationId: (0, import_mysql_core43.varchar)("organizationId", {
11154
+ length: 191
11155
+ }),
11156
+ organizationMembershipId: (0, import_mysql_core43.varchar)("organizationMembershipId", {
11157
+ length: 191
11158
+ }),
11159
+ lessonId: (0, import_mysql_core43.varchar)("lessonId", {
10413
11160
  length: 191
10414
11161
  }),
10415
- lessonSlug: (0, import_mysql_core35.varchar)("lessonSlug", {
11162
+ lessonSlug: (0, import_mysql_core43.varchar)("lessonSlug", {
10416
11163
  length: 191
10417
11164
  }),
10418
- lessonVersion: (0, import_mysql_core35.varchar)("lessonVersion", {
11165
+ lessonVersion: (0, import_mysql_core43.varchar)("lessonVersion", {
10419
11166
  length: 191
10420
11167
  }),
10421
- sectionId: (0, import_mysql_core35.varchar)("sectionId", {
11168
+ sectionId: (0, import_mysql_core43.varchar)("sectionId", {
10422
11169
  length: 191
10423
11170
  }),
10424
- moduleId: (0, import_mysql_core35.varchar)("moduleId", {
11171
+ moduleId: (0, import_mysql_core43.varchar)("moduleId", {
10425
11172
  length: 191
10426
11173
  }),
10427
- completedAt: (0, import_mysql_core35.datetime)("completedAt", {
11174
+ completedAt: (0, import_mysql_core43.datetime)("completedAt", {
10428
11175
  mode: "date",
10429
11176
  fsp: 3
10430
11177
  }),
10431
- updatedAt: (0, import_mysql_core35.datetime)("updatedAt", {
11178
+ updatedAt: (0, import_mysql_core43.datetime)("updatedAt", {
10432
11179
  mode: "date",
10433
11180
  fsp: 3
10434
11181
  }),
10435
- createdAt: (0, import_mysql_core35.datetime)("createdAt", {
11182
+ createdAt: (0, import_mysql_core43.datetime)("createdAt", {
10436
11183
  mode: "date",
10437
11184
  fsp: 3
10438
- }).default(import_drizzle_orm30.sql`CURRENT_TIMESTAMP(3)`).notNull()
11185
+ }).default(import_drizzle_orm38.sql`CURRENT_TIMESTAMP(3)`).notNull()
10439
11186
  }, (crp) => {
10440
11187
  return {
10441
- userIdLessonIdIdx: (0, import_mysql_core35.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
10442
- userIdIdx: (0, import_mysql_core35.index)("userId_idx").on(crp.userId),
10443
- lessonIdIdx: (0, import_mysql_core35.index)("lessonId_idx").on(crp.lessonId)
11188
+ userIdLessonIdIdx: (0, import_mysql_core43.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
11189
+ userIdIdx: (0, import_mysql_core43.index)("userId_idx").on(crp.userId),
11190
+ lessonIdIdx: (0, import_mysql_core43.index)("lessonId_idx").on(crp.lessonId),
11191
+ organizationMembershipIdIdx: (0, import_mysql_core43.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
10444
11192
  };
10445
11193
  });
10446
11194
  }
10447
11195
  __name(getLessonProgressSchema, "getLessonProgressSchema");
10448
11196
 
10449
11197
  // src/lib/mysql/schemas/content/resource-progress.ts
10450
- var import_drizzle_orm31 = require("drizzle-orm");
10451
- var import_mysql_core36 = require("drizzle-orm/mysql-core");
11198
+ var import_drizzle_orm39 = require("drizzle-orm");
11199
+ var import_mysql_core44 = require("drizzle-orm/mysql-core");
10452
11200
  function getResourceProgressSchema(mysqlTable) {
10453
11201
  return mysqlTable("ResourceProgress", {
10454
- userId: (0, import_mysql_core36.varchar)("userId", {
11202
+ userId: (0, import_mysql_core44.varchar)("userId", {
10455
11203
  length: 255
10456
11204
  }).notNull(),
10457
- resourceId: (0, import_mysql_core36.varchar)("resourceId", {
11205
+ organizationId: (0, import_mysql_core44.varchar)("organizationId", {
11206
+ length: 191
11207
+ }),
11208
+ organizationMembershipId: (0, import_mysql_core44.varchar)("organizationMembershipId", {
11209
+ length: 191
11210
+ }),
11211
+ resourceId: (0, import_mysql_core44.varchar)("resourceId", {
10458
11212
  length: 255
10459
11213
  }),
10460
- fields: (0, import_mysql_core36.json)("fields").$type().default({}),
10461
- completedAt: (0, import_mysql_core36.datetime)("completedAt", {
11214
+ fields: (0, import_mysql_core44.json)("fields").$type().default({}),
11215
+ completedAt: (0, import_mysql_core44.datetime)("completedAt", {
10462
11216
  mode: "date",
10463
11217
  fsp: 3
10464
11218
  }),
10465
- updatedAt: (0, import_mysql_core36.datetime)("updatedAt", {
11219
+ updatedAt: (0, import_mysql_core44.datetime)("updatedAt", {
10466
11220
  mode: "date",
10467
11221
  fsp: 3
10468
11222
  }),
10469
- createdAt: (0, import_mysql_core36.datetime)("createdAt", {
11223
+ createdAt: (0, import_mysql_core44.datetime)("createdAt", {
10470
11224
  mode: "date",
10471
11225
  fsp: 3
10472
- }).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`).notNull()
11226
+ }).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`).notNull()
10473
11227
  }, (crp) => {
10474
11228
  return {
10475
- userIdLessonIdIdx: (0, import_mysql_core36.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
10476
- pk: (0, import_mysql_core36.primaryKey)({
11229
+ userIdLessonIdIdx: (0, import_mysql_core44.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
11230
+ pk: (0, import_mysql_core44.primaryKey)({
10477
11231
  columns: [
10478
11232
  crp.userId,
10479
11233
  crp.resourceId
10480
11234
  ]
10481
11235
  }),
10482
- contentResourceIdIdx: (0, import_mysql_core36.index)("contentResourceId_idx").on(crp.resourceId),
10483
- userIdIdx: (0, import_mysql_core36.index)("resourceId_idx").on(crp.userId)
11236
+ contentResourceIdIdx: (0, import_mysql_core44.index)("contentResourceId_idx").on(crp.resourceId),
11237
+ userIdIdx: (0, import_mysql_core44.index)("resourceId_idx").on(crp.userId),
11238
+ organizationMembershipIdIdx: (0, import_mysql_core44.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
10484
11239
  };
10485
11240
  });
10486
11241
  }
10487
11242
  __name(getResourceProgressSchema, "getResourceProgressSchema");
10488
11243
 
11244
+ // src/lib/mysql/schemas/org/organization-membership-roles.ts
11245
+ var import_drizzle_orm40 = require("drizzle-orm");
11246
+ var import_mysql_core45 = require("drizzle-orm/mysql-core");
11247
+ function getOrganizationMembershipRolesSchema(mysqlTable) {
11248
+ return mysqlTable("OrganizationMembershipRole", {
11249
+ organizationMembershipId: (0, import_mysql_core45.varchar)("organizationMembershipId", {
11250
+ length: 255
11251
+ }).notNull(),
11252
+ roleId: (0, import_mysql_core45.varchar)("roleId", {
11253
+ length: 255
11254
+ }).notNull(),
11255
+ active: (0, import_mysql_core45.boolean)("active").notNull().default(true),
11256
+ organizationId: (0, import_mysql_core45.varchar)("organizationId", {
11257
+ length: 191
11258
+ }),
11259
+ createdAt: (0, import_mysql_core45.timestamp)("createdAt", {
11260
+ mode: "date",
11261
+ fsp: 3
11262
+ }).defaultNow(),
11263
+ updatedAt: (0, import_mysql_core45.timestamp)("updatedAt", {
11264
+ mode: "date",
11265
+ fsp: 3
11266
+ }).defaultNow(),
11267
+ deletedAt: (0, import_mysql_core45.timestamp)("deletedAt", {
11268
+ mode: "date",
11269
+ fsp: 3
11270
+ })
11271
+ }, (ur) => ({
11272
+ pk: (0, import_mysql_core45.primaryKey)({
11273
+ columns: [
11274
+ ur.organizationMembershipId,
11275
+ ur.roleId
11276
+ ],
11277
+ name: "pk"
11278
+ }),
11279
+ orgMemberIdIdx: (0, import_mysql_core45.index)("orgMemberId_idx").on(ur.organizationMembershipId),
11280
+ roleIdIdx: (0, import_mysql_core45.index)("roleId_idx").on(ur.roleId),
11281
+ organizationIdIdx: (0, import_mysql_core45.index)("organizationId_idx").on(ur.organizationId)
11282
+ }));
11283
+ }
11284
+ __name(getOrganizationMembershipRolesSchema, "getOrganizationMembershipRolesSchema");
11285
+ function getOrganizationMembershipRolesRelationsSchema(mysqlTable) {
11286
+ const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
11287
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
11288
+ const roles = getRolesSchema(mysqlTable);
11289
+ return (0, import_drizzle_orm40.relations)(organizationMembershipRoles, ({ one }) => ({
11290
+ organizationMembership: one(organizationMemberships, {
11291
+ fields: [
11292
+ organizationMembershipRoles.organizationMembershipId
11293
+ ],
11294
+ references: [
11295
+ organizationMemberships.id
11296
+ ],
11297
+ relationName: "organizationMembership"
11298
+ }),
11299
+ role: one(roles, {
11300
+ fields: [
11301
+ organizationMembershipRoles.roleId
11302
+ ],
11303
+ references: [
11304
+ roles.id
11305
+ ],
11306
+ relationName: "role"
11307
+ })
11308
+ }));
11309
+ }
11310
+ __name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
11311
+
10489
11312
  // src/lib/mysql/index.ts
10490
11313
  var guid = (0, import_nanoid.customAlphabet)("1234567890abcdefghijklmnopqrstuvwxyz", 5);
10491
11314
  function getCourseBuilderSchema(mysqlTable) {
@@ -10531,9 +11354,13 @@ function getCourseBuilderSchema(mysqlTable) {
10531
11354
  contentContributions: getContentContributionsSchema(mysqlTable),
10532
11355
  contentContributionRelations: getContentContributionRelationsSchema(mysqlTable),
10533
11356
  contentResource: getContentResourceSchema(mysqlTable),
11357
+ contentResourceVersion: getContentResourceVersionSchema(mysqlTable),
11358
+ contentResourceVersionRelations: getContentResourceVersionRelationsSchema(mysqlTable),
10534
11359
  contentResourceRelations: getContentResourceRelationsSchema(mysqlTable),
10535
11360
  contentResourceResource: getContentResourceResourceSchema(mysqlTable),
10536
11361
  contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
11362
+ contentResourceTag: getContentResourceTagSchema(mysqlTable),
11363
+ contentResourceTagRelations: getContentResourceTagRelationsSchema(mysqlTable),
10537
11364
  contributionTypes: getContributionTypesSchema(mysqlTable),
10538
11365
  contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
10539
11366
  resourceProgress: getResourceProgressSchema(mysqlTable),
@@ -10548,8 +11375,22 @@ function getCourseBuilderSchema(mysqlTable) {
10548
11375
  deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable),
10549
11376
  deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
10550
11377
  deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable),
11378
+ tag: getTagSchema(mysqlTable),
11379
+ tagRelations: getTagRelationsSchema(mysqlTable),
11380
+ tagTag: getTagTagSchema(mysqlTable),
11381
+ tagTagRelations: getTagTagRelationsSchema(mysqlTable),
10551
11382
  userPrefs: getUserPrefsSchema(mysqlTable),
10552
- userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable)
11383
+ userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable),
11384
+ organization: getOrganizationsSchema(mysqlTable),
11385
+ organizationRelations: getOrganizationsRelationsSchema(mysqlTable),
11386
+ organizationMemberships: getOrganizationMembershipsSchema(mysqlTable),
11387
+ organizationMembershipRelations: getOrganizationMembershipsRelationsSchema(mysqlTable),
11388
+ organizationMembershipRoles: getOrganizationMembershipRolesSchema(mysqlTable),
11389
+ organizationMembershipRolesRelations: getOrganizationMembershipRolesRelationsSchema(mysqlTable),
11390
+ merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
11391
+ merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
11392
+ subscription: getSubscriptionSchema(mysqlTable),
11393
+ subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable)
10553
11394
  };
10554
11395
  }
10555
11396
  __name(getCourseBuilderSchema, "getCourseBuilderSchema");
@@ -10557,7 +11398,7 @@ function createTables(mySqlTable) {
10557
11398
  return getCourseBuilderSchema(mySqlTable);
10558
11399
  }
10559
11400
  __name(createTables, "createTables");
10560
- function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, paymentProvider) {
11401
+ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, paymentProvider) {
10561
11402
  const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments } = createTables(tableFn);
10562
11403
  const adapter = {
10563
11404
  client,
@@ -10629,12 +11470,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10629
11470
  },
10630
11471
  incrementCouponUsedCount: async (couponId) => {
10631
11472
  await client.update(coupon).set({
10632
- usedCount: import_drizzle_orm32.sql`${coupon.usedCount} + 1`
10633
- }).where((0, import_drizzle_orm32.eq)(coupon.id, couponId));
11473
+ usedCount: import_drizzle_orm41.sql`${coupon.usedCount} + 1`
11474
+ }).where((0, import_drizzle_orm41.eq)(coupon.id, couponId));
10634
11475
  },
10635
11476
  getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
10636
11477
  const existingPurchases = await client.query.purchases.findMany({
10637
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm32.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm32.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm32.isNull)(purchaseTable.bulkCouponId))
11478
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm41.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm41.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm41.isNull)(purchaseTable.bulkCouponId))
10638
11479
  });
10639
11480
  return z.array(purchaseSchema).parse(existingPurchases);
10640
11481
  },
@@ -10647,17 +11488,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10647
11488
  status: 1
10648
11489
  });
10649
11490
  return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
10650
- where: (0, import_drizzle_orm32.eq)(merchantCustomer.identifier, options.identifier)
11491
+ where: (0, import_drizzle_orm41.eq)(merchantCustomer.identifier, options.identifier)
10651
11492
  }));
10652
11493
  },
10653
11494
  getMerchantAccount: async (options) => {
10654
11495
  return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
10655
- where: (0, import_drizzle_orm32.eq)(merchantAccount.label, options.provider)
11496
+ where: (0, import_drizzle_orm41.eq)(merchantAccount.label, options.provider)
10656
11497
  }));
10657
11498
  },
10658
11499
  getMerchantPriceForProductId: async (productId) => {
10659
11500
  const merchantPriceData = await client.query.merchantPrice.findFirst({
10660
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm32.eq)(merchantPrice.status, 1))
11501
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm41.eq)(merchantPrice.status, 1))
10661
11502
  });
10662
11503
  const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
10663
11504
  if (!parsedMerchantPrice.success) {
@@ -10668,7 +11509,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10668
11509
  },
10669
11510
  getMerchantProductForProductId: async (productId) => {
10670
11511
  const merchantProductData = await client.query.merchantProduct.findFirst({
10671
- where: (0, import_drizzle_orm32.eq)(merchantProduct.productId, productId)
11512
+ where: (0, import_drizzle_orm41.eq)(merchantProduct.productId, productId)
10672
11513
  });
10673
11514
  if (!merchantProductData)
10674
11515
  return null;
@@ -10676,7 +11517,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10676
11517
  },
10677
11518
  getMerchantCustomerForUserId: async (userId) => {
10678
11519
  const merchantCustomerData = await client.query.merchantCustomer.findFirst({
10679
- where: (0, import_drizzle_orm32.eq)(merchantCustomer.userId, userId)
11520
+ where: (0, import_drizzle_orm41.eq)(merchantCustomer.userId, userId)
10680
11521
  });
10681
11522
  if (!merchantCustomerData)
10682
11523
  return null;
@@ -10685,14 +11526,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10685
11526
  getUpgradableProducts: async (options) => {
10686
11527
  const { upgradableFromId, upgradableToId } = options;
10687
11528
  return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
10688
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, upgradableToId))
11529
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm41.eq)(upgradableProducts.upgradableToId, upgradableToId))
10689
11530
  }));
10690
11531
  },
10691
11532
  async availableUpgradesForProduct(purchases, productId) {
10692
11533
  const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
10693
11534
  if (previousPurchaseProductIds.length > 0) {
10694
11535
  return client.query.upgradableProducts.findMany({
10695
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm32.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
11536
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm41.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
10696
11537
  });
10697
11538
  }
10698
11539
  return [];
@@ -10705,7 +11546,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10705
11546
  throw new Error("No lessonId provided");
10706
11547
  }
10707
11548
  let lessonProgress = await client.query.resourceProgress.findFirst({
10708
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
11549
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId))
10709
11550
  });
10710
11551
  const now = /* @__PURE__ */ new Date();
10711
11552
  if (lessonProgress) {
@@ -10713,7 +11554,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10713
11554
  await client.update(resourceProgress).set({
10714
11555
  completedAt: now,
10715
11556
  updatedAt: now
10716
- }).where((0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId));
11557
+ }).where((0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId));
10717
11558
  }
10718
11559
  } else {
10719
11560
  await client.insert(resourceProgress).values({
@@ -10724,7 +11565,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10724
11565
  });
10725
11566
  }
10726
11567
  lessonProgress = await client.query.resourceProgress.findFirst({
10727
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
11568
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId))
10728
11569
  });
10729
11570
  const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
10730
11571
  if (!parsedLessonProgress.success) {
@@ -10737,7 +11578,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10737
11578
  if (!options.couponId && !options.code)
10738
11579
  return null;
10739
11580
  const couponForIdOrCode = await client.query.coupon.findFirst({
10740
- where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.or)(options.code ? (0, import_drizzle_orm32.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm32.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm32.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.or)(options.code ? (0, import_drizzle_orm32.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm32.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm32.isNull)(coupon.expires))),
11581
+ where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.or)(options.code ? (0, import_drizzle_orm41.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm41.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm41.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.or)(options.code ? (0, import_drizzle_orm41.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm41.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm41.isNull)(coupon.expires))),
10741
11582
  with: {
10742
11583
  merchantCoupon: true
10743
11584
  }
@@ -10758,10 +11599,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10758
11599
  try {
10759
11600
  const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
10760
11601
  const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
10761
- where: (0, import_drizzle_orm32.eq)(merchantCharge.identifier, stripeChargeId)
11602
+ where: (0, import_drizzle_orm41.eq)(merchantCharge.identifier, stripeChargeId)
10762
11603
  }) || null);
10763
11604
  const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
10764
- where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
11605
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
10765
11606
  with: {
10766
11607
  user: true,
10767
11608
  product: true,
@@ -10782,12 +11623,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10782
11623
  merchantCustomerId
10783
11624
  });
10784
11625
  const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
10785
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, [
11626
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, [
10786
11627
  "Valid",
10787
11628
  "Restricted"
10788
11629
  ]))
10789
11630
  }) || null);
10790
- const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId))).then((res) => {
11631
+ const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm41.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm41.eq)(purchaseTable.userId, userId))).then((res) => {
10791
11632
  return res[0]?.Coupon ?? null;
10792
11633
  }));
10793
11634
  const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
@@ -10798,10 +11639,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10798
11639
  if (existingBulkCoupon !== null) {
10799
11640
  couponToUpdate = await client.update(coupon).set({
10800
11641
  maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
10801
- }).where((0, import_drizzle_orm32.eq)(coupon.id, bulkCouponId));
11642
+ }).where((0, import_drizzle_orm41.eq)(coupon.id, bulkCouponId));
10802
11643
  } else {
10803
11644
  const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
10804
- where: (0, import_drizzle_orm32.eq)(merchantCoupon.identifier, stripeCouponId)
11645
+ where: (0, import_drizzle_orm41.eq)(merchantCoupon.identifier, stripeCouponId)
10805
11646
  })) : null;
10806
11647
  couponToUpdate = await client.insert(coupon).values({
10807
11648
  id: bulkCouponId,
@@ -10822,10 +11663,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10822
11663
  merchantAccountId
10823
11664
  });
10824
11665
  const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
10825
- where: (0, import_drizzle_orm32.eq)(merchantCoupon.identifier, stripeCouponId)
11666
+ where: (0, import_drizzle_orm41.eq)(merchantCoupon.identifier, stripeCouponId)
10826
11667
  }) : null;
10827
11668
  const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
10828
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm32.eq)(merchantCoupon.type, "ppp"))
11669
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm41.eq)(merchantCoupon.type, "ppp"))
10829
11670
  }) : null;
10830
11671
  const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
10831
11672
  const newPurchase = await client.insert(purchaseTable).values({
@@ -10856,7 +11697,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10856
11697
  }
10857
11698
  });
10858
11699
  const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
10859
- where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId)
11700
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId)
10860
11701
  }));
10861
11702
  if (!parsedPurchase.success) {
10862
11703
  console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
@@ -10901,7 +11742,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10901
11742
  },
10902
11743
  async getCoupon(couponIdOrCode) {
10903
11744
  const loadedCoupon = await client.query.coupon.findFirst({
10904
- where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm32.eq)(coupon.code, couponIdOrCode))
11745
+ where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm41.eq)(coupon.code, couponIdOrCode))
10905
11746
  }) || null;
10906
11747
  logger.debug("loadedCoupon", {
10907
11748
  loadedCoupon
@@ -10916,7 +11757,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10916
11757
  let bulkCouponPurchases;
10917
11758
  try {
10918
11759
  couponData = await client.query.coupon.findFirst({
10919
- where: (0, import_drizzle_orm32.eq)(coupon.id, couponId),
11760
+ where: (0, import_drizzle_orm41.eq)(coupon.id, couponId),
10920
11761
  with: {
10921
11762
  bulkPurchases: true,
10922
11763
  redeemedBulkCouponPurchases: true
@@ -10928,7 +11769,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10928
11769
  }
10929
11770
  try {
10930
11771
  bulkCouponPurchases = await client.query.purchases.findMany({
10931
- where: (0, import_drizzle_orm32.eq)(purchaseTable.redeemedBulkCouponId, couponId),
11772
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.redeemedBulkCouponId, couponId),
10932
11773
  with: {
10933
11774
  user: true
10934
11775
  }
@@ -10960,8 +11801,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10960
11801
  },
10961
11802
  async getDefaultCoupon(productIds) {
10962
11803
  const activeSaleCoupon = await client.query.coupon.findFirst({
10963
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(coupon.status, 1), (0, import_drizzle_orm32.eq)(coupon.default, true), (0, import_drizzle_orm32.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm32.or)(productIds ? (0, import_drizzle_orm32.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm32.isNull)(coupon.restrictedToProductId))),
10964
- orderBy: (0, import_drizzle_orm32.desc)(coupon.percentageDiscount),
11804
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(coupon.status, 1), (0, import_drizzle_orm41.eq)(coupon.default, true), (0, import_drizzle_orm41.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm41.or)(productIds ? (0, import_drizzle_orm41.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm41.isNull)(coupon.restrictedToProductId))),
11805
+ orderBy: (0, import_drizzle_orm41.desc)(coupon.percentageDiscount),
10965
11806
  with: {
10966
11807
  merchantCoupon: true,
10967
11808
  product: true
@@ -10985,7 +11826,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10985
11826
  },
10986
11827
  async getLessonProgressForUser(userId) {
10987
11828
  const userProgress = await client.query.resourceProgress.findMany({
10988
- where: (0, import_drizzle_orm32.eq)(resourceProgress.userId, userId)
11829
+ where: (0, import_drizzle_orm41.eq)(resourceProgress.userId, userId)
10989
11830
  });
10990
11831
  const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
10991
11832
  if (!parsed.success) {
@@ -10996,7 +11837,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
10996
11837
  },
10997
11838
  async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
10998
11839
  const user = await client.query.users.findFirst({
10999
- where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm32.eq)(users.email, userIdOrEmail)),
11840
+ where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm41.eq)(users.email, userIdOrEmail)),
11000
11841
  columns: {
11001
11842
  id: true
11002
11843
  }
@@ -11013,7 +11854,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11013
11854
  resource_slug: z.string().nullable(),
11014
11855
  completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
11015
11856
  });
11016
- const results = await client.execute(import_drizzle_orm32.sql`
11857
+ const results = await client.execute(import_drizzle_orm41.sql`
11017
11858
  SELECT
11018
11859
  cr.id AS resource_id,
11019
11860
  cr.type AS resource_type,
@@ -11094,7 +11935,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11094
11935
  },
11095
11936
  async getMerchantCharge(merchantChargeId) {
11096
11937
  const mCharge = await client.query.merchantCharge.findFirst({
11097
- where: (0, import_drizzle_orm32.eq)(merchantCharge.id, merchantChargeId)
11938
+ where: (0, import_drizzle_orm41.eq)(merchantCharge.id, merchantChargeId)
11098
11939
  });
11099
11940
  const parsed = merchantChargeSchema.safeParse(mCharge);
11100
11941
  if (!parsed.success) {
@@ -11105,12 +11946,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11105
11946
  },
11106
11947
  async getMerchantCouponsForTypeAndPercent(params) {
11107
11948
  return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
11108
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm32.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
11949
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm41.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
11109
11950
  }));
11110
11951
  },
11111
11952
  async getMerchantCouponForTypeAndPercent(params) {
11112
11953
  const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
11113
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm32.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
11954
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm41.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
11114
11955
  });
11115
11956
  const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
11116
11957
  if (parsed.success) {
@@ -11120,7 +11961,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11120
11961
  },
11121
11962
  async getMerchantCoupon(merchantCouponId) {
11122
11963
  const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
11123
- where: (0, import_drizzle_orm32.eq)(merchantCoupon.id, merchantCouponId)
11964
+ where: (0, import_drizzle_orm41.eq)(merchantCoupon.id, merchantCouponId)
11124
11965
  });
11125
11966
  const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
11126
11967
  if (parsed.success) {
@@ -11130,7 +11971,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11130
11971
  },
11131
11972
  async getMerchantProduct(stripeProductId) {
11132
11973
  return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
11133
- where: (0, import_drizzle_orm32.eq)(merchantProduct.identifier, stripeProductId)
11974
+ where: (0, import_drizzle_orm41.eq)(merchantProduct.identifier, stripeProductId)
11134
11975
  }));
11135
11976
  },
11136
11977
  getPrice(productId) {
@@ -11138,7 +11979,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11138
11979
  },
11139
11980
  async getPriceForProduct(productId) {
11140
11981
  return priceSchema.nullable().parse(await client.query.prices.findFirst({
11141
- where: (0, import_drizzle_orm32.eq)(prices.productId, productId)
11982
+ where: (0, import_drizzle_orm41.eq)(prices.productId, productId)
11142
11983
  }));
11143
11984
  },
11144
11985
  async archiveProduct(productId) {
@@ -11154,19 +11995,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11154
11995
  await client.update(products).set({
11155
11996
  status: 0,
11156
11997
  name: `${product.name} (Archived)`
11157
- }).where((0, import_drizzle_orm32.eq)(products.id, productId));
11998
+ }).where((0, import_drizzle_orm41.eq)(products.id, productId));
11158
11999
  await client.update(prices).set({
11159
12000
  status: 0,
11160
12001
  nickname: `${product.name} (Archived)`
11161
- }).where((0, import_drizzle_orm32.eq)(prices.productId, productId));
12002
+ }).where((0, import_drizzle_orm41.eq)(prices.productId, productId));
11162
12003
  await client.update(merchantProduct).set({
11163
12004
  status: 0
11164
- }).where((0, import_drizzle_orm32.eq)(merchantProduct.productId, productId));
12005
+ }).where((0, import_drizzle_orm41.eq)(merchantProduct.productId, productId));
11165
12006
  await client.update(merchantPrice).set({
11166
12007
  status: 0
11167
- }).where((0, import_drizzle_orm32.eq)(merchantPrice.priceId, product.price.id));
12008
+ }).where((0, import_drizzle_orm41.eq)(merchantPrice.priceId, product.price.id));
11168
12009
  const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
11169
- where: (0, import_drizzle_orm32.eq)(merchantProduct.productId, productId)
12010
+ where: (0, import_drizzle_orm41.eq)(merchantProduct.productId, productId)
11170
12011
  }));
11171
12012
  if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
11172
12013
  throw new Error(`Merchant product not found for id (${productId})`);
@@ -11175,7 +12016,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11175
12016
  active: false
11176
12017
  });
11177
12018
  const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
11178
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantPrice.priceId, product.price.id), (0, import_drizzle_orm32.eq)(merchantPrice.status, 1))
12019
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantPrice.priceId, product.price.id), (0, import_drizzle_orm41.eq)(merchantPrice.status, 1))
11179
12020
  }));
11180
12021
  if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
11181
12022
  throw new Error(`Merchant price not found for id (${productId})`);
@@ -11235,12 +12076,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11235
12076
  if (currentMerchantPrice) {
11236
12077
  await client.update(merchantPrice).set({
11237
12078
  status: 0
11238
- }).where((0, import_drizzle_orm32.eq)(merchantPrice.id, currentMerchantPrice.id));
12079
+ }).where((0, import_drizzle_orm41.eq)(merchantPrice.id, currentMerchantPrice.id));
11239
12080
  }
11240
12081
  await client.update(prices).set({
11241
12082
  unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
11242
12083
  nickname: input.name
11243
- }).where((0, import_drizzle_orm32.eq)(prices.id, currentProduct.price.id));
12084
+ }).where((0, import_drizzle_orm41.eq)(prices.id, currentProduct.price.id));
11244
12085
  if (currentStripePrice) {
11245
12086
  await paymentProvider.updatePrice(currentStripePrice.id, {
11246
12087
  active: false
@@ -11269,7 +12110,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11269
12110
  image
11270
12111
  }
11271
12112
  }
11272
- }).where((0, import_drizzle_orm32.eq)(products.id, currentProduct.id));
12113
+ }).where((0, import_drizzle_orm41.eq)(products.id, currentProduct.id));
11273
12114
  return adapter.getProduct(currentProduct.id);
11274
12115
  },
11275
12116
  async createProduct(input) {
@@ -11345,7 +12186,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11345
12186
  }
11346
12187
  try {
11347
12188
  const productData = await client.query.products.findFirst({
11348
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(import_drizzle_orm32.sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), (0, import_drizzle_orm32.eq)(products.id, productSlugOrId))),
12189
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(import_drizzle_orm41.sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), (0, import_drizzle_orm41.eq)(products.id, productSlugOrId))),
11349
12190
  with: {
11350
12191
  price: true,
11351
12192
  ...withResources && {
@@ -11374,20 +12215,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11374
12215
  },
11375
12216
  async getProductResources(productId) {
11376
12217
  const contentResourceProductsForProduct = z.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
11377
- where: (0, import_drizzle_orm32.eq)(contentResourceProduct.productId, productId)
12218
+ where: (0, import_drizzle_orm41.eq)(contentResourceProduct.productId, productId)
11378
12219
  }));
11379
12220
  if (!contentResourceProductsForProduct) {
11380
12221
  return null;
11381
12222
  } else {
11382
12223
  const contentResources = z.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
11383
- where: (0, import_drizzle_orm32.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
12224
+ where: (0, import_drizzle_orm41.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
11384
12225
  }));
11385
12226
  return contentResources;
11386
12227
  }
11387
12228
  },
11388
12229
  async getPurchaseCountForProduct(productId) {
11389
12230
  return await client.query.purchases.findMany({
11390
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, [
12231
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, [
11391
12232
  "Valid",
11392
12233
  "Restricted"
11393
12234
  ]))
@@ -11395,7 +12236,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11395
12236
  },
11396
12237
  async getPurchase(purchaseId) {
11397
12238
  const purchase = await client.query.purchases.findFirst({
11398
- where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId)
12239
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId)
11399
12240
  });
11400
12241
  return purchase ? purchaseSchema.parse(purchase) : null;
11401
12242
  },
@@ -11413,14 +12254,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11413
12254
  stripeChargeId
11414
12255
  });
11415
12256
  const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
11416
- where: (0, import_drizzle_orm32.eq)(merchantCharge.identifier, stripeChargeId)
12257
+ where: (0, import_drizzle_orm41.eq)(merchantCharge.identifier, stripeChargeId)
11417
12258
  }) || null);
11418
12259
  if (!chargeForPurchase) {
11419
12260
  logger.error(new Error(`No charge found for purchase: Stripe Charge ID: ${stripeChargeId}`));
11420
12261
  return null;
11421
12262
  }
11422
12263
  const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
11423
- where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
12264
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
11424
12265
  with: {
11425
12266
  user: true,
11426
12267
  product: true,
@@ -11434,7 +12275,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11434
12275
  },
11435
12276
  async getPurchaseUserTransferById(options) {
11436
12277
  const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
11437
- where: (0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id),
12278
+ where: (0, import_drizzle_orm41.eq)(purchaseUserTransfer.id, options.id),
11438
12279
  with: {
11439
12280
  sourceUser: true,
11440
12281
  targetUser: true,
@@ -11449,7 +12290,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11449
12290
  },
11450
12291
  async getPurchaseWithUser(purchaseId) {
11451
12292
  const purchaseData = await client.query.purchases.findFirst({
11452
- where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId),
12293
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId),
11453
12294
  with: {
11454
12295
  user: true
11455
12296
  }
@@ -11473,13 +12314,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11473
12314
  "Restricted"
11474
12315
  ];
11475
12316
  const userPurchases = await client.query.purchases.findMany({
11476
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, visiblePurchaseStates)),
12317
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, visiblePurchaseStates)),
11477
12318
  with: {
11478
12319
  user: true,
11479
12320
  product: true,
11480
12321
  bulkCoupon: true
11481
12322
  },
11482
- orderBy: (0, import_drizzle_orm32.asc)(purchaseTable.createdAt)
12323
+ orderBy: (0, import_drizzle_orm41.asc)(purchaseTable.createdAt)
11483
12324
  });
11484
12325
  const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
11485
12326
  if (!parsedPurchases.success) {
@@ -11495,18 +12336,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11495
12336
  "Restricted"
11496
12337
  ];
11497
12338
  const userPurchases = await client.query.purchases.findMany({
11498
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, visiblePurchaseStates)),
12339
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, visiblePurchaseStates)),
11499
12340
  with: {
11500
12341
  user: true,
11501
12342
  product: true,
11502
12343
  bulkCoupon: true
11503
12344
  },
11504
- orderBy: (0, import_drizzle_orm32.asc)(purchaseTable.createdAt)
12345
+ orderBy: (0, import_drizzle_orm41.asc)(purchaseTable.createdAt)
11505
12346
  });
11506
12347
  const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
11507
12348
  const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
11508
12349
  const thePurchase = await client.query.purchases.findFirst({
11509
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId)),
12350
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm41.eq)(purchaseTable.userId, userId)),
11510
12351
  with: {
11511
12352
  user: true,
11512
12353
  product: true,
@@ -11527,7 +12368,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11527
12368
  let availableUpgrades = [];
11528
12369
  if (purchaseCanUpgrade) {
11529
12370
  availableUpgrades = await client.query.upgradableProducts.findMany({
11530
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm32.not)((0, import_drizzle_orm32.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
12371
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm41.not)((0, import_drizzle_orm41.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
11531
12372
  with: {
11532
12373
  upgradableTo: true,
11533
12374
  upgradableFrom: true
@@ -11535,10 +12376,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11535
12376
  });
11536
12377
  }
11537
12378
  const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
11538
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, [
12379
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, [
11539
12380
  "Valid",
11540
12381
  "Restricted"
11541
- ]), (0, import_drizzle_orm32.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm32.not)((0, import_drizzle_orm32.eq)(purchaseTable.id, parsedPurchase.data.id))),
12382
+ ]), (0, import_drizzle_orm41.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm41.not)((0, import_drizzle_orm41.eq)(purchaseTable.id, parsedPurchase.data.id))),
11542
12383
  with: {
11543
12384
  user: true,
11544
12385
  product: true,
@@ -11553,7 +12394,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11553
12394
  },
11554
12395
  async getUserWithPurchasersByEmail(email) {
11555
12396
  const user = await client.query.users.findFirst({
11556
- where: (0, import_drizzle_orm32.eq)(users.email, email.trim().toLowerCase()),
12397
+ where: (0, import_drizzle_orm41.eq)(users.email, email.trim().toLowerCase()),
11557
12398
  with: {
11558
12399
  // merchantCustomer: true,
11559
12400
  roles: {
@@ -11580,7 +12421,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11580
12421
  },
11581
12422
  async getUserById(userId) {
11582
12423
  const user = await client.query.users.findFirst({
11583
- where: (0, import_drizzle_orm32.eq)(users.id, userId),
12424
+ where: (0, import_drizzle_orm41.eq)(users.id, userId),
11584
12425
  with: {
11585
12426
  roles: {
11586
12427
  with: {
@@ -11602,13 +12443,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11602
12443
  if (userId === void 0)
11603
12444
  return [];
11604
12445
  const canUpgradeProducts = await client.query.upgradableProducts.findMany({
11605
- where: (0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, bundleId)
12446
+ where: (0, import_drizzle_orm41.eq)(upgradableProducts.upgradableToId, bundleId)
11606
12447
  });
11607
12448
  const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
11608
12449
  return product.upgradableFromId;
11609
12450
  }));
11610
12451
  const purchases = await client.query.purchases.findMany({
11611
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.productId, upgradableFrom))
12452
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.productId, upgradableFrom))
11612
12453
  });
11613
12454
  const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
11614
12455
  return purchase.productId;
@@ -11616,7 +12457,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11616
12457
  if (productsPurchased.length === 0)
11617
12458
  return [];
11618
12459
  const foundPrices = await client.query.prices.findMany({
11619
- where: (0, import_drizzle_orm32.inArray)(prices.productId, productsPurchased)
12460
+ where: (0, import_drizzle_orm41.inArray)(prices.productId, productsPurchased)
11620
12461
  });
11621
12462
  return z.array(priceSchema).parse(foundPrices);
11622
12463
  },
@@ -11625,14 +12466,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11625
12466
  throw new Error("No lessonId provided");
11626
12467
  }
11627
12468
  let lessonProgress = await client.query.resourceProgress.findFirst({
11628
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
12469
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId))
11629
12470
  });
11630
12471
  const now = /* @__PURE__ */ new Date();
11631
12472
  if (lessonProgress) {
11632
12473
  await client.update(resourceProgress).set({
11633
12474
  completedAt: lessonProgress.completedAt ? null : now,
11634
12475
  updatedAt: now
11635
- }).where((0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId));
12476
+ }).where((0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId));
11636
12477
  } else {
11637
12478
  await client.insert(resourceProgress).values({
11638
12479
  userId: options.userId,
@@ -11642,7 +12483,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11642
12483
  });
11643
12484
  }
11644
12485
  lessonProgress = await client.query.resourceProgress.findFirst({
11645
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
12486
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId))
11646
12487
  });
11647
12488
  const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
11648
12489
  if (!parsedLessonProgress.success) {
@@ -11651,6 +12492,65 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11651
12492
  }
11652
12493
  return parsedLessonProgress.data;
11653
12494
  },
12495
+ transferPurchaseToUser: async (options) => {
12496
+ const { purchaseId, targetUserId, sourceUserId } = options;
12497
+ const transferId = `put_${(0, import_uuid.v4)()}`;
12498
+ let purchase = await adapter.getPurchase(purchaseId);
12499
+ if (!purchase)
12500
+ throw new Error("No purchase found");
12501
+ if (purchase.userId !== sourceUserId)
12502
+ throw new Error("Invalid source user");
12503
+ await client.transaction(async (trx) => {
12504
+ if (!purchase)
12505
+ throw new Error("No purchase found");
12506
+ await trx.update(purchaseTable).set({
12507
+ userId: targetUserId
12508
+ }).where((0, import_drizzle_orm41.eq)(purchaseTable.id, purchase.id));
12509
+ await trx.insert(purchaseUserTransfer).values({
12510
+ id: transferId,
12511
+ purchaseId: purchase.id,
12512
+ sourceUserId,
12513
+ targetUserId,
12514
+ transferState: "COMPLETED",
12515
+ completedAt: /* @__PURE__ */ new Date()
12516
+ });
12517
+ purchase = await adapter.getPurchase(purchaseId);
12518
+ if (!purchase)
12519
+ throw new Error("No purchase found");
12520
+ if (paymentProvider && purchase.merchantChargeId) {
12521
+ await trx.update(merchantCharge).set({
12522
+ userId: targetUserId
12523
+ }).where((0, import_drizzle_orm41.eq)(merchantCharge.id, purchase.merchantChargeId));
12524
+ const updatedMerchantCharge = await adapter.getMerchantCharge(purchase.merchantChargeId);
12525
+ if (!updatedMerchantCharge)
12526
+ throw new Error("No merchant charge found");
12527
+ await trx.update(merchantCustomer).set({
12528
+ userId: targetUserId
12529
+ }).where((0, import_drizzle_orm41.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId));
12530
+ const updatedMerchantCustomer = merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
12531
+ where: (0, import_drizzle_orm41.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId)
12532
+ }));
12533
+ const targetUser = userSchema.parse(await client.query.users.findFirst({
12534
+ where: (0, import_drizzle_orm41.eq)(users.id, targetUserId)
12535
+ }));
12536
+ const sourceUser = userSchema.parse(await client.query.users.findFirst({
12537
+ where: (0, import_drizzle_orm41.eq)(users.id, sourceUserId)
12538
+ }));
12539
+ await paymentProvider.updateCustomer(updatedMerchantCustomer.identifier, {
12540
+ email: targetUser.email,
12541
+ name: targetUser.name || sourceUser.name || "",
12542
+ metadata: {
12543
+ transferId,
12544
+ transferredFrom: sourceUser.email,
12545
+ transferredOn: (/* @__PURE__ */ new Date()).toISOString()
12546
+ }
12547
+ });
12548
+ }
12549
+ });
12550
+ return await adapter.getPurchaseUserTransferById({
12551
+ id: transferId
12552
+ });
12553
+ },
11654
12554
  transferPurchasesToNewUser(options) {
11655
12555
  throw new Error("Method not implemented.");
11656
12556
  },
@@ -11661,7 +12561,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11661
12561
  status
11662
12562
  });
11663
12563
  const merchantChargeForPurchase = await client.query.merchantCharge.findFirst({
11664
- where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm32.eq)(merchantCharge.id, chargeId))
12564
+ where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm41.eq)(merchantCharge.id, chargeId))
11665
12565
  });
11666
12566
  console.log("merchantChargeForPurchase", {
11667
12567
  merchantChargeForPurchase
@@ -11670,15 +12570,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11670
12570
  if (!parsedMerchantChargeForPurchase)
11671
12571
  throw new Error(`no-charge-found-for-purchase ${chargeId}`);
11672
12572
  const purchase = await client.query.purchases.findFirst({
11673
- where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
12573
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
11674
12574
  });
11675
12575
  const parsedPurchase = purchaseSchema.nullable().parse(purchase);
11676
12576
  if (parsedPurchase) {
11677
12577
  await client.update(purchaseTable).set({
11678
12578
  status
11679
- }).where((0, import_drizzle_orm32.eq)(purchaseTable.id, parsedPurchase.id));
12579
+ }).where((0, import_drizzle_orm41.eq)(purchaseTable.id, parsedPurchase.id));
11680
12580
  const newPurchase = await client.query.purchases.findFirst({
11681
- where: (0, import_drizzle_orm32.eq)(purchaseTable.id, parsedPurchase.id)
12581
+ where: (0, import_drizzle_orm41.eq)(purchaseTable.id, parsedPurchase.id)
11682
12582
  });
11683
12583
  return purchaseSchema.optional().parse(newPurchase);
11684
12584
  } else {
@@ -11692,16 +12592,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11692
12592
  async updatePurchaseUserTransferTransferState(options) {
11693
12593
  await client.update(purchaseUserTransfer).set({
11694
12594
  transferState: options.transferState
11695
- }).where((0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id));
12595
+ }).where((0, import_drizzle_orm41.eq)(purchaseUserTransfer.id, options.id));
11696
12596
  const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
11697
- where: (0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id)
12597
+ where: (0, import_drizzle_orm41.eq)(purchaseUserTransfer.id, options.id)
11698
12598
  }) || null;
11699
12599
  return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
11700
12600
  },
11701
12601
  addResourceToResource: async function(options) {
11702
12602
  const { parentResourceId, childResourceId } = options;
11703
12603
  const parentResourceData = await client.query.contentResource.findFirst({
11704
- where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(import_drizzle_orm32.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm32.eq)(contentResource.id, parentResourceId)),
12604
+ where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(import_drizzle_orm41.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm41.eq)(contentResource.id, parentResourceId)),
11705
12605
  with: {
11706
12606
  resources: true
11707
12607
  }
@@ -11713,7 +12613,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11713
12613
  position: parentResource.resources?.length || 0
11714
12614
  });
11715
12615
  const resourceJoin = client.query.contentResourceResource.findFirst({
11716
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm32.eq)(contentResourceResource.resourceId, childResourceId)),
12616
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm41.eq)(contentResourceResource.resourceId, childResourceId)),
11717
12617
  with: {
11718
12618
  resource: true
11719
12619
  }
@@ -11727,28 +12627,28 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11727
12627
  async removeResourceFromResource(options) {
11728
12628
  const { childResourceId, parentResourceId } = options;
11729
12629
  const resourceJoin = await client.query.contentResourceResource.findFirst({
11730
- where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm32.eq)(contentResourceResource.resourceId, childResourceId))
12630
+ where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm41.eq)(contentResourceResource.resourceId, childResourceId))
11731
12631
  });
11732
12632
  const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
11733
12633
  if (!parsedResourceJoin.success) {
11734
12634
  return null;
11735
12635
  }
11736
- await client.delete(contentResourceResource).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm32.eq)(contentResourceResource.resourceId, childResourceId)));
12636
+ await client.delete(contentResourceResource).where((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm41.eq)(contentResourceResource.resourceId, childResourceId)));
11737
12637
  return parsedResourceJoin.data.resource;
11738
12638
  },
11739
12639
  async updateContentResourceFields(options) {
11740
12640
  if (!options.id) {
11741
12641
  throw new Error("No content resource id.");
11742
12642
  }
11743
- const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm32.eq)(contentResource.id, options.id)).then((res) => res[0]);
12643
+ const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm41.eq)(contentResource.id, options.id)).then((res) => res[0]);
11744
12644
  await client.update(contentResource).set({
11745
12645
  fields: {
11746
12646
  ...currentResource.fields,
11747
12647
  ...options.fields
11748
12648
  }
11749
- }).where((0, import_drizzle_orm32.eq)(contentResource.id, options.id));
12649
+ }).where((0, import_drizzle_orm41.eq)(contentResource.id, options.id));
11750
12650
  const resource = await client.query.contentResource.findFirst({
11751
- where: (0, import_drizzle_orm32.eq)(contentResource.id, options.id),
12651
+ where: (0, import_drizzle_orm41.eq)(contentResource.id, options.id),
11752
12652
  with: {
11753
12653
  resources: {
11754
12654
  with: {
@@ -11758,12 +12658,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11758
12658
  with: {
11759
12659
  resource: true
11760
12660
  },
11761
- orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
12661
+ orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
11762
12662
  }
11763
12663
  }
11764
12664
  }
11765
12665
  },
11766
- orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
12666
+ orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
11767
12667
  }
11768
12668
  }
11769
12669
  });
@@ -11778,7 +12678,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11778
12678
  if (!id) {
11779
12679
  return null;
11780
12680
  }
11781
- const query = import_drizzle_orm32.sql`
12681
+ const query = import_drizzle_orm41.sql`
11782
12682
  SELECT
11783
12683
  id as id,
11784
12684
  CAST(updatedAt AS DATETIME) as updatedAt,
@@ -11810,7 +12710,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11810
12710
  id
11811
12711
  });
11812
12712
  const resource = await client.query.contentResource.findFirst({
11813
- where: (0, import_drizzle_orm32.eq)(contentResource.id, id),
12713
+ where: (0, import_drizzle_orm41.eq)(contentResource.id, id),
11814
12714
  with: {
11815
12715
  resources: {
11816
12716
  with: {
@@ -11820,12 +12720,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11820
12720
  with: {
11821
12721
  resource: true
11822
12722
  },
11823
- orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
12723
+ orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
11824
12724
  }
11825
12725
  }
11826
12726
  }
11827
12727
  },
11828
- orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
12728
+ orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
11829
12729
  }
11830
12730
  }
11831
12731
  });
@@ -11838,7 +12738,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11838
12738
  },
11839
12739
  async getContentResource(data) {
11840
12740
  const resource = await client.query.contentResource.findFirst({
11841
- where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(contentResource.id, data), (0, import_drizzle_orm32.eq)(import_drizzle_orm32.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
12741
+ where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(contentResource.id, data), (0, import_drizzle_orm41.eq)(import_drizzle_orm41.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
11842
12742
  with: {
11843
12743
  resources: {
11844
12744
  with: {
@@ -11856,12 +12756,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11856
12756
  }
11857
12757
  }
11858
12758
  },
11859
- orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
12759
+ orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
11860
12760
  }
11861
12761
  }
11862
12762
  }
11863
12763
  },
11864
- orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
12764
+ orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
11865
12765
  }
11866
12766
  }
11867
12767
  });
@@ -11879,61 +12779,61 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11879
12779
  ...data,
11880
12780
  id
11881
12781
  });
11882
- return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, id)).then((res) => res[0]);
12782
+ return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.id, id)).then((res) => res[0]);
11883
12783
  } catch (error) {
11884
12784
  console.error(error);
11885
12785
  throw error;
11886
12786
  }
11887
12787
  },
11888
12788
  async getUser(data) {
11889
- return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, data)).then((res) => res[0]) ?? null;
12789
+ return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.id, data)).then((res) => res[0]) ?? null;
11890
12790
  },
11891
12791
  async getUserByEmail(data) {
11892
- return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.email, data)).then((res) => res[0]) ?? null;
12792
+ return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.email, data)).then((res) => res[0]) ?? null;
11893
12793
  },
11894
12794
  async createSession(data) {
11895
12795
  await client.insert(sessions).values(data);
11896
- return await client.select().from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
12796
+ return await client.select().from(sessions).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
11897
12797
  },
11898
12798
  async getSessionAndUser(data) {
11899
12799
  return await client.select({
11900
12800
  session: sessions,
11901
12801
  user: users
11902
- }).from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm32.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
12802
+ }).from(sessions).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm41.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
11903
12803
  },
11904
12804
  async updateUser(data) {
11905
12805
  if (!data.id) {
11906
12806
  throw new Error("No user id.");
11907
12807
  }
11908
- await client.update(users).set(data).where((0, import_drizzle_orm32.eq)(users.id, data.id));
11909
- return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, data.id)).then((res) => res[0]);
12808
+ await client.update(users).set(data).where((0, import_drizzle_orm41.eq)(users.id, data.id));
12809
+ return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.id, data.id)).then((res) => res[0]);
11910
12810
  },
11911
12811
  async updateSession(data) {
11912
- await client.update(sessions).set(data).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data.sessionToken));
11913
- return await client.select().from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
12812
+ await client.update(sessions).set(data).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, data.sessionToken));
12813
+ return await client.select().from(sessions).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
11914
12814
  },
11915
12815
  async linkAccount(rawAccount) {
11916
12816
  await client.insert(accounts).values(rawAccount);
11917
12817
  },
11918
12818
  async getUserByAccount(account) {
11919
- const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm32.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm32.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
12819
+ const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm41.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm41.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
11920
12820
  if (!dbAccount) {
11921
12821
  return null;
11922
12822
  }
11923
12823
  return dbAccount.User;
11924
12824
  },
11925
12825
  async deleteSession(sessionToken) {
11926
- const session = await client.select().from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
11927
- await client.delete(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, sessionToken));
12826
+ const session = await client.select().from(sessions).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
12827
+ await client.delete(sessions).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, sessionToken));
11928
12828
  return session;
11929
12829
  },
11930
12830
  async createVerificationToken(token) {
11931
12831
  await client.insert(verificationTokens).values(token);
11932
- return await client.select().from(verificationTokens).where((0, import_drizzle_orm32.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
12832
+ return await client.select().from(verificationTokens).where((0, import_drizzle_orm41.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
11933
12833
  },
11934
12834
  async useVerificationToken(token) {
11935
12835
  try {
11936
- const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm32.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
12836
+ const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm41.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
11937
12837
  if (deletedToken?.createdAt) {
11938
12838
  const TIMEOUT_IN_SECONDS = 90;
11939
12839
  const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
@@ -11942,7 +12842,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11942
12842
  const { id: _, ...verificationToken } = token;
11943
12843
  return deletedToken;
11944
12844
  } else {
11945
- await client.delete(verificationTokens).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm32.eq)(verificationTokens.token, token.token)));
12845
+ await client.delete(verificationTokens).where((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm41.eq)(verificationTokens.token, token.token)));
11946
12846
  return deletedToken;
11947
12847
  }
11948
12848
  }
@@ -11952,14 +12852,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
11952
12852
  }
11953
12853
  },
11954
12854
  async deleteUser(id) {
11955
- const user = await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, id)).then((res) => res[0] ?? null);
11956
- await client.delete(users).where((0, import_drizzle_orm32.eq)(users.id, id));
11957
- await client.delete(sessions).where((0, import_drizzle_orm32.eq)(sessions.userId, id));
11958
- await client.delete(accounts).where((0, import_drizzle_orm32.eq)(accounts.userId, id));
12855
+ const user = await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.id, id)).then((res) => res[0] ?? null);
12856
+ await client.delete(users).where((0, import_drizzle_orm41.eq)(users.id, id));
12857
+ await client.delete(sessions).where((0, import_drizzle_orm41.eq)(sessions.userId, id));
12858
+ await client.delete(accounts).where((0, import_drizzle_orm41.eq)(accounts.userId, id));
11959
12859
  return user;
11960
12860
  },
11961
12861
  async unlinkAccount(account) {
11962
- await client.delete(accounts).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm32.eq)(accounts.provider, account.provider)));
12862
+ await client.delete(accounts).where((0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm41.eq)(accounts.provider, account.provider)));
11963
12863
  return void 0;
11964
12864
  }
11965
12865
  };