@coursebuilder/adapter-drizzle 1.0.0 → 1.0.2

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 (147) hide show
  1. package/dist/chunk-253RMSB3.js +99 -0
  2. package/dist/{chunk-3WYG5OE7.js → chunk-3GONHHMY.js} +2 -2
  3. package/dist/{chunk-L5ZAWSTN.js → chunk-5QEGBX2O.js} +411 -120
  4. package/dist/{chunk-WFC55BSF.js → chunk-FPAQINSA.js} +2 -2
  5. package/dist/{chunk-RCL6HPBL.js → chunk-HWIQUI7O.js} +2 -2
  6. package/dist/{chunk-QGZ2F5SW.js → chunk-LPJ2P2KJ.js} +1162 -1027
  7. package/dist/{chunk-GAKWXOAY.js → chunk-OBUGOZKM.js} +2 -2
  8. package/dist/chunk-ORRM7KVW.js +25 -0
  9. package/dist/{chunk-A6XPL665.js → chunk-PBTEHA7F.js} +2 -2
  10. package/dist/{chunk-5XTOCFDB.js → chunk-YQNIXCD3.js} +2 -2
  11. package/dist/index.js +11 -10
  12. package/dist/lib/mysql/index.cjs +1513 -1060
  13. package/dist/lib/mysql/index.cjs.map +1 -1
  14. package/dist/lib/mysql/index.d.cts +2994 -2258
  15. package/dist/lib/mysql/index.d.ts +2994 -2258
  16. package/dist/lib/mysql/index.js +11 -10
  17. package/dist/lib/mysql/schemas/auth/accounts.cjs +106 -98
  18. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  19. package/dist/lib/mysql/schemas/auth/accounts.js +2 -2
  20. package/dist/lib/mysql/schemas/auth/device-access-token.cjs +99 -91
  21. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  22. package/dist/lib/mysql/schemas/auth/device-access-token.js +3 -3
  23. package/dist/lib/mysql/schemas/auth/device-verification.cjs +100 -92
  24. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  25. package/dist/lib/mysql/schemas/auth/device-verification.js +3 -3
  26. package/dist/lib/mysql/schemas/auth/profiles.cjs +254 -0
  27. package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -0
  28. package/dist/lib/mysql/schemas/auth/profiles.d.cts +112 -0
  29. package/dist/lib/mysql/schemas/auth/profiles.d.ts +112 -0
  30. package/dist/lib/mysql/schemas/auth/profiles.js +20 -0
  31. package/dist/lib/mysql/schemas/auth/profiles.js.map +1 -0
  32. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +55 -46
  33. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  34. package/dist/lib/mysql/schemas/auth/role-permissions.js +3 -3
  35. package/dist/lib/mysql/schemas/auth/roles.cjs +57 -48
  36. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  37. package/dist/lib/mysql/schemas/auth/roles.js +2 -2
  38. package/dist/lib/mysql/schemas/auth/sessions.cjs +96 -88
  39. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/auth/sessions.js +3 -3
  41. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +99 -91
  42. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  43. package/dist/lib/mysql/schemas/auth/user-permissions.js +2 -2
  44. package/dist/lib/mysql/schemas/auth/user-prefs.cjs +104 -96
  45. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  46. package/dist/lib/mysql/schemas/auth/user-prefs.js +2 -2
  47. package/dist/lib/mysql/schemas/auth/user-roles.cjs +58 -49
  48. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  49. package/dist/lib/mysql/schemas/auth/user-roles.js +2 -2
  50. package/dist/lib/mysql/schemas/auth/users.cjs +295 -259
  51. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  52. package/dist/lib/mysql/schemas/auth/users.d.cts +1 -0
  53. package/dist/lib/mysql/schemas/auth/users.d.ts +1 -0
  54. package/dist/lib/mysql/schemas/auth/users.js +2 -2
  55. package/dist/lib/mysql/schemas/commerce/coupon.cjs +131 -123
  56. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  57. package/dist/lib/mysql/schemas/commerce/coupon.js +2 -2
  58. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +96 -88
  59. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  60. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +2 -2
  61. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +90 -82
  62. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
  63. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +2 -2
  64. package/dist/lib/mysql/schemas/commerce/price.cjs +98 -90
  65. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  66. package/dist/lib/mysql/schemas/commerce/price.js +2 -2
  67. package/dist/lib/mysql/schemas/commerce/product.cjs +125 -117
  68. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  69. package/dist/lib/mysql/schemas/commerce/product.js +2 -2
  70. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +131 -123
  71. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  72. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +3 -3
  73. package/dist/lib/mysql/schemas/commerce/purchase.cjs +184 -176
  74. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  75. package/dist/lib/mysql/schemas/commerce/purchase.js +2 -2
  76. package/dist/lib/mysql/schemas/commerce/subscription.cjs +117 -109
  77. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
  78. package/dist/lib/mysql/schemas/commerce/subscription.js +2 -2
  79. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +105 -97
  80. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  81. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +3 -3
  82. package/dist/lib/mysql/schemas/communication/comment.cjs +114 -106
  83. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  84. package/dist/lib/mysql/schemas/communication/comment.js +2 -2
  85. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +136 -128
  86. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  87. package/dist/lib/mysql/schemas/communication/communication-preferences.js +2 -2
  88. package/dist/lib/mysql/schemas/content/content-contributions.cjs +144 -136
  89. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  90. package/dist/lib/mysql/schemas/content/content-contributions.js +2 -2
  91. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +99 -91
  92. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  93. package/dist/lib/mysql/schemas/content/content-resource-product.js +2 -2
  94. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +108 -100
  95. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  96. package/dist/lib/mysql/schemas/content/content-resource-resource.js +2 -2
  97. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +118 -110
  98. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  99. package/dist/lib/mysql/schemas/content/content-resource-tag.js +2 -2
  100. package/dist/lib/mysql/schemas/content/content-resource-version.cjs +121 -113
  101. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  102. package/dist/lib/mysql/schemas/content/content-resource-version.js +2 -2
  103. package/dist/lib/mysql/schemas/content/content-resource.cjs +198 -190
  104. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  105. package/dist/lib/mysql/schemas/content/content-resource.js +2 -2
  106. package/dist/lib/mysql/schemas/content/tag-tag.cjs +103 -95
  107. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  108. package/dist/lib/mysql/schemas/content/tag-tag.js +2 -2
  109. package/dist/lib/mysql/schemas/content/tag.cjs +116 -108
  110. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  111. package/dist/lib/mysql/schemas/content/tag.js +2 -2
  112. package/dist/lib/mysql/schemas/entitlements/entitlement-type.cjs +46 -0
  113. package/dist/lib/mysql/schemas/entitlements/entitlement-type.cjs.map +1 -0
  114. package/dist/lib/mysql/schemas/entitlements/entitlement-type.d.cts +60 -0
  115. package/dist/lib/mysql/schemas/entitlements/entitlement-type.d.ts +60 -0
  116. package/dist/lib/mysql/schemas/entitlements/entitlement-type.js +8 -0
  117. package/dist/lib/mysql/schemas/entitlements/entitlement-type.js.map +1 -0
  118. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +351 -0
  119. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -0
  120. package/dist/lib/mysql/schemas/entitlements/entitlement.d.cts +210 -0
  121. package/dist/lib/mysql/schemas/entitlements/entitlement.d.ts +210 -0
  122. package/dist/lib/mysql/schemas/entitlements/entitlement.js +21 -0
  123. package/dist/lib/mysql/schemas/entitlements/entitlement.js.map +1 -0
  124. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +73 -35
  125. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
  126. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +1 -0
  127. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +1 -0
  128. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +2 -3
  129. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +88 -38
  130. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
  131. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +1 -0
  132. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +1 -0
  133. package/dist/lib/mysql/schemas/org/organization-memberships.js +2 -2
  134. package/dist/lib/mysql/schemas/org/organizations.cjs +131 -121
  135. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
  136. package/dist/lib/mysql/schemas/org/organizations.js +2 -2
  137. package/package.json +4 -3
  138. package/src/lib/mysql/index.ts +349 -26
  139. package/src/lib/mysql/schemas/auth/profiles.ts +50 -0
  140. package/src/lib/mysql/schemas/auth/roles.ts +6 -1
  141. package/src/lib/mysql/schemas/auth/users.ts +6 -1
  142. package/src/lib/mysql/schemas/commerce/subscription.ts +3 -5
  143. package/src/lib/mysql/schemas/entitlements/entitlement-type.ts +21 -0
  144. package/src/lib/mysql/schemas/entitlements/entitlement.ts +66 -0
  145. package/src/lib/mysql/schemas/org/organization-membership-roles.ts +7 -0
  146. package/src/lib/mysql/schemas/org/organization-memberships.ts +6 -0
  147. package/dist/chunk-RP66NZN3.js +0 -81
@@ -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_orm41 = require("drizzle-orm");
43
- var import_mysql_core46 = require("drizzle-orm/mysql-core");
42
+ var import_drizzle_orm43 = require("drizzle-orm");
43
+ var import_mysql_core49 = 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 json19 = JSON.stringify(obj, null, 2);
202
- return json19.replace(/"([^"]+)":/g, "$1:");
201
+ const json21 = JSON.stringify(obj, null, 2);
202
+ return json21.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(index43) {
2321
+ catchall(index45) {
2322
2322
  return new _ZodObject({
2323
2323
  ...this._def,
2324
- catchall: index43
2324
+ catchall: index45
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 index43 = 0; index43 < a.length; index43++) {
2640
- const itemA = a[index43];
2641
- const itemB = b[index43];
2639
+ for (let index45 = 0; index45 < a.length; index45++) {
2640
+ const itemA = a[index45];
2641
+ const itemB = b[index45];
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], index43) => {
2853
+ const pairs = [...ctx.data.entries()].map(([key, value], index45) => {
2854
2854
  return {
2855
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index43, "key"])),
2856
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index43, "value"]))
2855
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index45, "key"])),
2856
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index45, "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 json19 = JSON.stringify(obj, null, 2);
4050
- return json19.replace(/"([^"]+)":/g, "$1:");
4049
+ const json21 = JSON.stringify(obj, null, 2);
4050
+ return json21.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(index43) {
6354
+ catchall(index45) {
6355
6355
  return new _a18({
6356
6356
  ...this._def,
6357
- catchall: index43
6357
+ catchall: index45
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 index43 = 0; index43 < a.length; index43++) {
6700
- const itemA = a[index43];
6701
- const itemB = b[index43];
6699
+ for (let index45 = 0; index45 < a.length; index45++) {
6700
+ const itemA = a[index45];
6701
+ const itemB = b[index45];
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], index43) => {
6935
+ ].map(([key, value], index45) => {
6936
6936
  return {
6937
6937
  key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
6938
- index43,
6938
+ index45,
6939
6939
  "key"
6940
6940
  ])),
6941
6941
  value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
6942
- index43,
6942
+ index45,
6943
6943
  "value"
6944
6944
  ]))
6945
6945
  };
@@ -8080,38 +8080,26 @@ var VideoResourceSchema = z2.object({
8080
8080
  ])
8081
8081
  });
8082
8082
 
8083
- // ../core/dist/chunk-CHYUPSYW.js
8084
- var userSchema = z2.object({
8085
- id: z2.string().max(255),
8086
- name: z2.string().max(255).optional().nullable(),
8087
- role: z2.enum([
8088
- "user",
8089
- "admin"
8090
- ]).default("user"),
8091
- email: z2.string().max(255).email(),
8092
- emailVerified: z2.coerce.date().nullable(),
8093
- image: z2.string().max(255).optional().nullable(),
8094
- createdAt: z2.coerce.date().nullable(),
8095
- roles: z2.array(z2.object({
8096
- id: z2.string(),
8097
- name: z2.string(),
8098
- description: z2.string().nullable(),
8099
- active: z2.boolean()
8100
- })).optional().default([])
8101
- });
8102
-
8103
- // ../core/dist/chunk-47RWEDJ6.js
8104
- var priceSchema = z2.object({
8083
+ // ../core/dist/chunk-LMH5A7OR.js
8084
+ var purchaseUserTransferSchema = z2.object({
8105
8085
  id: z2.string().max(191),
8106
- productId: z2.string().max(191).optional().nullable(),
8107
- nickname: z2.string().max(191).optional().nullable(),
8108
- status: z2.number().int().default(0),
8109
- unitAmount: z2.coerce.number().refine((value) => {
8110
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8111
- return decimalPlaces <= 2;
8112
- }),
8086
+ transferState: z2.enum([
8087
+ "AVAILABLE",
8088
+ "INITIATED",
8089
+ "VERIFIED",
8090
+ "CANCELED",
8091
+ "EXPIRED",
8092
+ "CONFIRMED",
8093
+ "COMPLETED"
8094
+ ]).default("AVAILABLE"),
8095
+ purchaseId: z2.string().max(191),
8096
+ sourceUserId: z2.string().max(191),
8097
+ targetUserId: z2.string().max(191).optional().nullable(),
8113
8098
  createdAt: z2.date().nullable(),
8114
- fields: z2.record(z2.any()).default({})
8099
+ expiresAt: z2.date().nullable(),
8100
+ canceledAt: z2.date().nullable(),
8101
+ confirmedAt: z2.date().nullable(),
8102
+ completedAt: z2.date().nullable()
8115
8103
  });
8116
8104
 
8117
8105
  // ../core/dist/chunk-SCKAG5RT.js
@@ -8161,14 +8149,94 @@ var ResourceVisibilitySchema = z2.union([
8161
8149
  z2.literal("unlisted")
8162
8150
  ]);
8163
8151
 
8164
- // ../core/dist/chunk-E56UB2X2.js
8152
+ // ../core/dist/chunk-PG6VF2O6.js
8153
+ var resourceProgressSchema = z2.object({
8154
+ userId: z2.string().max(191),
8155
+ resourceId: z2.string().max(191).optional().nullable(),
8156
+ completedAt: z2.date().nullable()
8157
+ });
8158
+ var moduleProgressSchema = z2.object({
8159
+ completedLessons: z2.array(resourceProgressSchema),
8160
+ nextResource: ContentResourceSchema.partial().nullable(),
8161
+ percentCompleted: z2.number().default(0),
8162
+ completedLessonsCount: z2.number().default(0),
8163
+ totalLessonsCount: z2.number().default(0)
8164
+ });
8165
+
8166
+ // ../core/dist/chunk-DLQA3JMA.js
8167
+ var upgradableProductSchema = z2.object({
8168
+ upgradableToId: z2.string().max(255),
8169
+ upgradableFromId: z2.string().max(255),
8170
+ position: z2.number().default(0),
8171
+ metadata: z2.record(z2.any()).default({}),
8172
+ createdAt: z2.date().nullable(),
8173
+ updatedAt: z2.date().nullable(),
8174
+ deletedAt: z2.date().nullable()
8175
+ });
8176
+
8177
+ // ../core/dist/chunk-JZBK2DS3.js
8178
+ var userSchema = z2.object({
8179
+ id: z2.string().max(255),
8180
+ name: z2.string().max(255).optional().nullable(),
8181
+ role: z2.enum([
8182
+ "user",
8183
+ "admin"
8184
+ ]).default("user"),
8185
+ email: z2.string().max(255).email(),
8186
+ emailVerified: z2.coerce.date().nullish(),
8187
+ image: z2.string().max(255).optional().nullable(),
8188
+ createdAt: z2.coerce.date().nullish(),
8189
+ memberships: z2.array(z2.object({
8190
+ id: z2.string(),
8191
+ organizationId: z2.string()
8192
+ })).nullish().default([]),
8193
+ roles: z2.array(z2.object({
8194
+ id: z2.string(),
8195
+ name: z2.string(),
8196
+ description: z2.string().nullable(),
8197
+ active: z2.boolean(),
8198
+ createdAt: z2.coerce.date().nullish(),
8199
+ updatedAt: z2.coerce.date().nullish(),
8200
+ deletedAt: z2.coerce.date().nullish()
8201
+ })).optional().default([]),
8202
+ organizationRoles: z2.array(z2.object({
8203
+ id: z2.string(),
8204
+ organizationId: z2.string(),
8205
+ name: z2.string(),
8206
+ description: z2.string().nullable(),
8207
+ active: z2.boolean(),
8208
+ createdAt: z2.coerce.date().nullish(),
8209
+ updatedAt: z2.coerce.date().nullish(),
8210
+ deletedAt: z2.coerce.date().nullish()
8211
+ })).optional().default([])
8212
+ });
8213
+
8214
+ // ../core/dist/chunk-M7IDYIVK.js
8215
+ var priceSchema = z2.object({
8216
+ id: z2.string().max(191),
8217
+ productId: z2.string().max(191).optional().nullable(),
8218
+ organizationId: z2.string().max(191).optional().nullable(),
8219
+ nickname: z2.string().max(191).optional().nullable(),
8220
+ status: z2.number().int().default(0),
8221
+ unitAmount: z2.coerce.number().refine((value) => {
8222
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8223
+ return decimalPlaces <= 2;
8224
+ }),
8225
+ createdAt: z2.date().nullable(),
8226
+ fields: z2.record(z2.any()).default({})
8227
+ });
8228
+
8229
+ // ../core/dist/chunk-FMAXYBP4.js
8165
8230
  var productSchema = z2.object({
8166
8231
  id: z2.string().max(191),
8232
+ organizationId: z2.string().max(191).optional().nullable(),
8167
8233
  name: z2.string().max(191),
8168
8234
  key: z2.string().max(191).optional().nullable(),
8169
8235
  type: z2.enum([
8170
8236
  "live",
8171
- "self-paced"
8237
+ "self-paced",
8238
+ "membership",
8239
+ "cohort"
8172
8240
  ]).default("self-paced"),
8173
8241
  fields: z2.object({
8174
8242
  body: z2.string().nullable().optional(),
@@ -8205,7 +8273,7 @@ var NewProductSchema = z2.object({
8205
8273
  price: z2.coerce.number().gte(0).default(0)
8206
8274
  });
8207
8275
 
8208
- // ../core/dist/chunk-RCFZC3SN.js
8276
+ // ../core/dist/chunk-K4MXE7BY.js
8209
8277
  var couponSchema = z2.object({
8210
8278
  id: z2.string(),
8211
8279
  code: z2.string().max(191).optional().nullable(),
@@ -8224,10 +8292,11 @@ var couponSchema = z2.object({
8224
8292
  restrictedToProductId: z2.string().max(191).optional().nullable(),
8225
8293
  bulkPurchases: z2.array(z2.any()).default([]),
8226
8294
  redeemedBulkCouponPurchases: z2.array(z2.any()).default([]),
8227
- bulkPurchaseId: z2.string().max(191).optional().nullable()
8295
+ bulkPurchaseId: z2.string().max(191).optional().nullable(),
8296
+ organizationId: z2.string().max(191).optional().nullable()
8228
8297
  });
8229
8298
 
8230
- // ../core/dist/chunk-GZ7YLWVN.js
8299
+ // ../core/dist/chunk-MDUGHSSW.js
8231
8300
  var purchaseSchema = z2.object({
8232
8301
  id: z2.string().max(191),
8233
8302
  userId: z2.string().max(191).optional().nullable(),
@@ -8251,54 +8320,21 @@ var purchaseSchema = z2.object({
8251
8320
  fields: z2.record(z2.any()).default({}),
8252
8321
  user: userSchema.optional().nullable(),
8253
8322
  bulkCoupon: couponSchema.optional().nullable(),
8254
- product: productSchema.optional().nullable()
8323
+ product: productSchema.optional().nullable(),
8324
+ purchasedByorganizationMembershipId: z2.string().max(191).optional().nullable(),
8325
+ organizationId: z2.string().max(191).optional().nullable()
8255
8326
  });
8256
8327
 
8257
- // ../core/dist/chunk-LMH5A7OR.js
8258
- var purchaseUserTransferSchema = z2.object({
8328
+ // ../core/dist/chunk-SGE7BCRS.js
8329
+ var merchantChargeSchema = z2.object({
8259
8330
  id: z2.string().max(191),
8260
- transferState: z2.enum([
8261
- "AVAILABLE",
8262
- "INITIATED",
8263
- "VERIFIED",
8264
- "CANCELED",
8265
- "EXPIRED",
8266
- "CONFIRMED",
8267
- "COMPLETED"
8268
- ]).default("AVAILABLE"),
8269
- purchaseId: z2.string().max(191),
8270
- sourceUserId: z2.string().max(191),
8271
- targetUserId: z2.string().max(191).optional().nullable(),
8272
- createdAt: z2.date().nullable(),
8273
- expiresAt: z2.date().nullable(),
8274
- canceledAt: z2.date().nullable(),
8275
- confirmedAt: z2.date().nullable(),
8276
- completedAt: z2.date().nullable()
8277
- });
8278
-
8279
- // ../core/dist/chunk-PG6VF2O6.js
8280
- var resourceProgressSchema = z2.object({
8331
+ status: z2.number().int().default(0),
8332
+ identifier: z2.string().max(191),
8281
8333
  userId: z2.string().max(191),
8282
- resourceId: z2.string().max(191).optional().nullable(),
8283
- completedAt: z2.date().nullable()
8284
- });
8285
- var moduleProgressSchema = z2.object({
8286
- completedLessons: z2.array(resourceProgressSchema),
8287
- nextResource: ContentResourceSchema.partial().nullable(),
8288
- percentCompleted: z2.number().default(0),
8289
- completedLessonsCount: z2.number().default(0),
8290
- totalLessonsCount: z2.number().default(0)
8291
- });
8292
-
8293
- // ../core/dist/chunk-DLQA3JMA.js
8294
- var upgradableProductSchema = z2.object({
8295
- upgradableToId: z2.string().max(255),
8296
- upgradableFromId: z2.string().max(255),
8297
- position: z2.number().default(0),
8298
- metadata: z2.record(z2.any()).default({}),
8334
+ merchantAccountId: z2.string().max(191),
8335
+ merchantProductId: z2.string().max(191),
8299
8336
  createdAt: z2.date().nullable(),
8300
- updatedAt: z2.date().nullable(),
8301
- deletedAt: z2.date().nullable()
8337
+ merchantCustomerId: z2.string().max(191)
8302
8338
  });
8303
8339
 
8304
8340
  // ../core/dist/chunk-EDDT2FFU.js
@@ -8332,18 +8368,6 @@ var merchantProductSchema = z2.object({
8332
8368
  createdAt: z2.date().nullable()
8333
8369
  });
8334
8370
 
8335
- // ../core/dist/chunk-SGE7BCRS.js
8336
- var merchantChargeSchema = z2.object({
8337
- id: z2.string().max(191),
8338
- status: z2.number().int().default(0),
8339
- identifier: z2.string().max(191),
8340
- userId: z2.string().max(191),
8341
- merchantAccountId: z2.string().max(191),
8342
- merchantProductId: z2.string().max(191),
8343
- createdAt: z2.date().nullable(),
8344
- merchantCustomerId: z2.string().max(191)
8345
- });
8346
-
8347
8371
  // ../core/dist/chunk-256SROW3.js
8348
8372
  var merchantCouponSchema = z2.object({
8349
8373
  id: z2.string().max(191),
@@ -8366,6 +8390,71 @@ var merchantAccountSchema = z2.object({
8366
8390
  status: z2.number().int().default(0)
8367
8391
  });
8368
8392
 
8393
+ // ../core/dist/schemas/merchant-session.js
8394
+ var MerchantSessionSchema = z2.object({
8395
+ id: z2.string(),
8396
+ organizationId: z2.string().nullable(),
8397
+ identifier: z2.string(),
8398
+ merchantAccountId: z2.string()
8399
+ });
8400
+
8401
+ // ../core/dist/chunk-NCUZHHRE.js
8402
+ var MerchantSubscriptionSchema = z2.object({
8403
+ id: z2.string(),
8404
+ organizationId: z2.string().nullable(),
8405
+ merchantAccountId: z2.string(),
8406
+ status: z2.number().default(0),
8407
+ createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
8408
+ label: z2.string().nullable(),
8409
+ identifier: z2.string().nullable(),
8410
+ merchantCustomerId: z2.string(),
8411
+ merchantProductId: z2.string()
8412
+ });
8413
+
8414
+ // ../core/dist/chunk-KQ3HQRWM.js
8415
+ var OrganizationSchema = z2.object({
8416
+ id: z2.string(),
8417
+ name: z2.string().nullable(),
8418
+ fields: z2.record(z2.any()).default({}),
8419
+ image: z2.string().nullable(),
8420
+ createdAt: z2.date()
8421
+ });
8422
+
8423
+ // ../core/dist/schemas/organization-member.js
8424
+ var OrganizationMemberSchema = z2.object({
8425
+ id: z2.string(),
8426
+ organizationId: z2.string().optional(),
8427
+ role: z2.string().default("user"),
8428
+ invitedById: z2.string(),
8429
+ userId: z2.string(),
8430
+ fields: z2.record(z2.any()).default({}),
8431
+ createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
8432
+ organization: OrganizationSchema,
8433
+ user: userSchema
8434
+ });
8435
+
8436
+ // ../core/dist/schemas/subscription.js
8437
+ var SubscriptionSchema = z2.object({
8438
+ id: z2.string(),
8439
+ organizationId: z2.string().optional(),
8440
+ productId: z2.string(),
8441
+ createdAt: z2.date(),
8442
+ merchantSubscriptionId: z2.string(),
8443
+ status: z2.enum([
8444
+ "incomplete",
8445
+ "incomplete_expired",
8446
+ "trialing",
8447
+ "active",
8448
+ "past_due",
8449
+ "canceled",
8450
+ "unpaid",
8451
+ "paused"
8452
+ ]).default("active"),
8453
+ fields: z2.record(z2.any()).default({}),
8454
+ product: productSchema,
8455
+ merchantSubscription: MerchantSubscriptionSchema.optional()
8456
+ });
8457
+
8369
8458
  // ../core/dist/chunk-F32UWPXN.js
8370
8459
  var _a41;
8371
8460
  var _CourseBuilderError = (_a41 = class extends Error {
@@ -8496,149 +8585,268 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
8496
8585
  }, "validateCoupon");
8497
8586
 
8498
8587
  // src/lib/mysql/schemas/auth/accounts.ts
8499
- var import_drizzle_orm31 = require("drizzle-orm");
8500
- var import_mysql_core35 = require("drizzle-orm/mysql-core");
8588
+ var import_drizzle_orm33 = require("drizzle-orm");
8589
+ var import_mysql_core37 = require("drizzle-orm/mysql-core");
8501
8590
 
8502
8591
  // src/lib/mysql/schemas/auth/users.ts
8503
- var import_drizzle_orm30 = require("drizzle-orm");
8504
- var import_mysql_core34 = require("drizzle-orm/mysql-core");
8592
+ var import_drizzle_orm32 = require("drizzle-orm");
8593
+ var import_mysql_core36 = require("drizzle-orm/mysql-core");
8505
8594
 
8506
8595
  // src/lib/mysql/schemas/commerce/purchase.ts
8507
- var import_drizzle_orm22 = require("drizzle-orm");
8508
- var import_mysql_core24 = require("drizzle-orm/mysql-core");
8596
+ var import_drizzle_orm25 = require("drizzle-orm");
8597
+ var import_mysql_core27 = require("drizzle-orm/mysql-core");
8509
8598
 
8510
8599
  // 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");
8513
-
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");
8600
+ var import_drizzle_orm23 = require("drizzle-orm");
8601
+ var import_mysql_core23 = require("drizzle-orm/mysql-core");
8521
8602
 
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");
8603
+ // src/lib/mysql/schemas/org/organization-membership-roles.ts
8604
+ var import_drizzle_orm22 = require("drizzle-orm");
8605
+ var import_mysql_core22 = require("drizzle-orm/mysql-core");
8525
8606
 
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");
8607
+ // src/lib/mysql/schemas/auth/roles.ts
8608
+ var import_drizzle_orm2 = require("drizzle-orm");
8609
+ var import_mysql_core2 = require("drizzle-orm/mysql-core");
8529
8610
 
8530
- // src/lib/mysql/schemas/commerce/merchant-account.ts
8611
+ // src/lib/mysql/schemas/auth/user-roles.ts
8531
8612
  var import_drizzle_orm = require("drizzle-orm");
8532
8613
  var import_mysql_core = require("drizzle-orm/mysql-core");
8533
- function getMerchantAccountSchema(mysqlTable) {
8534
- return mysqlTable("MerchantAccount", {
8535
- id: (0, import_mysql_core.varchar)("id", {
8536
- length: 191
8614
+ function getUserRolesSchema(mysqlTable) {
8615
+ return mysqlTable("UserRole", {
8616
+ userId: (0, import_mysql_core.varchar)("userId", {
8617
+ length: 255
8618
+ }).notNull(),
8619
+ roleId: (0, import_mysql_core.varchar)("roleId", {
8620
+ length: 255
8537
8621
  }).notNull(),
8622
+ active: (0, import_mysql_core.boolean)("active").notNull().default(true),
8538
8623
  organizationId: (0, import_mysql_core.varchar)("organizationId", {
8539
8624
  length: 191
8540
8625
  }),
8541
- status: (0, import_mysql_core.int)("status").default(0).notNull(),
8542
8626
  createdAt: (0, import_mysql_core.timestamp)("createdAt", {
8543
8627
  mode: "date",
8544
8628
  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
8629
+ }).defaultNow(),
8630
+ updatedAt: (0, import_mysql_core.timestamp)("updatedAt", {
8631
+ mode: "date",
8632
+ fsp: 3
8633
+ }).defaultNow(),
8634
+ deletedAt: (0, import_mysql_core.timestamp)("deletedAt", {
8635
+ mode: "date",
8636
+ fsp: 3
8551
8637
  })
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");
8638
+ }, (ur) => ({
8639
+ pk: (0, import_mysql_core.primaryKey)({
8640
+ columns: [
8641
+ ur.userId,
8642
+ ur.roleId
8643
+ ]
8644
+ }),
8645
+ userIdIdx: (0, import_mysql_core.index)("userId_idx").on(ur.userId),
8646
+ roleIdIdx: (0, import_mysql_core.index)("roleId_idx").on(ur.roleId),
8647
+ organizationIdIdx: (0, import_mysql_core.index)("organizationId_idx").on(ur.organizationId)
8648
+ }));
8649
+ }
8650
+ __name(getUserRolesSchema, "getUserRolesSchema");
8651
+ function getUserRolesRelationsSchema(mysqlTable) {
8652
+ const userRoles = getUserRolesSchema(mysqlTable);
8653
+ const users = getUsersSchema(mysqlTable);
8654
+ const roles = getRolesSchema(mysqlTable);
8655
+ return (0, import_drizzle_orm.relations)(userRoles, ({ one }) => ({
8656
+ user: one(users, {
8657
+ fields: [
8658
+ userRoles.userId
8659
+ ],
8660
+ references: [
8661
+ users.id
8662
+ ],
8663
+ relationName: "user"
8664
+ }),
8665
+ role: one(roles, {
8666
+ fields: [
8667
+ userRoles.roleId
8668
+ ],
8669
+ references: [
8670
+ roles.id
8671
+ ],
8672
+ relationName: "role"
8673
+ })
8674
+ }));
8675
+ }
8676
+ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
8677
+
8678
+ // src/lib/mysql/schemas/auth/roles.ts
8679
+ function getRolesSchema(mysqlTable) {
8680
+ return mysqlTable("Role", {
8681
+ id: (0, import_mysql_core2.varchar)("id", {
8682
+ length: 255
8683
+ }).notNull().primaryKey(),
8684
+ organizationId: (0, import_mysql_core2.varchar)("organizationId", {
8685
+ length: 191
8686
+ }),
8687
+ name: (0, import_mysql_core2.varchar)("name", {
8688
+ length: 255
8689
+ }).notNull(),
8690
+ description: (0, import_mysql_core2.text)("description"),
8691
+ active: (0, import_mysql_core2.boolean)("active").notNull().default(true),
8692
+ createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
8693
+ mode: "date",
8694
+ fsp: 3
8695
+ }).defaultNow(),
8696
+ updatedAt: (0, import_mysql_core2.timestamp)("updatedAt", {
8697
+ mode: "date",
8698
+ fsp: 3
8699
+ }).defaultNow(),
8700
+ deletedAt: (0, import_mysql_core2.timestamp)("deletedAt", {
8701
+ mode: "date",
8702
+ fsp: 3
8703
+ })
8704
+ }, (role) => ({
8705
+ nameIdx: (0, import_mysql_core2.index)("name_idx").on(role.name),
8706
+ organizationIdIdx: (0, import_mysql_core2.index)("organizationId_idx").on(role.organizationId),
8707
+ uniqueNamePerOrg: (0, import_mysql_core2.uniqueIndex)("unique_name_per_org").on(role.organizationId, role.name)
8708
+ }));
8709
+ }
8710
+ __name(getRolesSchema, "getRolesSchema");
8711
+ function getRolesRelationsSchema(mysqlTable) {
8712
+ const roles = getRolesSchema(mysqlTable);
8713
+ const userRoles = getUserRolesSchema(mysqlTable);
8714
+ return (0, import_drizzle_orm2.relations)(roles, ({ many }) => ({
8715
+ userRoles: many(userRoles, {
8716
+ relationName: "role"
8717
+ })
8718
+ }));
8719
+ }
8720
+ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
8721
+
8722
+ // src/lib/mysql/schemas/org/organizations.ts
8723
+ var import_drizzle_orm21 = require("drizzle-orm");
8724
+ var import_mysql_core21 = require("drizzle-orm/mysql-core");
8725
+
8726
+ // src/lib/mysql/schemas/commerce/subscription.ts
8727
+ var import_drizzle_orm20 = require("drizzle-orm");
8728
+ var import_mysql_core20 = require("drizzle-orm/mysql-core");
8729
+
8730
+ // src/lib/mysql/schemas/commerce/merchant-subscription.ts
8731
+ var import_drizzle_orm7 = require("drizzle-orm");
8732
+ var import_mysql_core7 = require("drizzle-orm/mysql-core");
8733
+
8734
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
8735
+ var import_drizzle_orm6 = require("drizzle-orm");
8736
+ var import_mysql_core6 = require("drizzle-orm/mysql-core");
8737
+
8738
+ // src/lib/mysql/schemas/commerce/merchant-account.ts
8739
+ var import_drizzle_orm3 = require("drizzle-orm");
8740
+ var import_mysql_core3 = require("drizzle-orm/mysql-core");
8741
+ function getMerchantAccountSchema(mysqlTable) {
8742
+ return mysqlTable("MerchantAccount", {
8743
+ id: (0, import_mysql_core3.varchar)("id", {
8744
+ length: 191
8745
+ }).notNull(),
8746
+ organizationId: (0, import_mysql_core3.varchar)("organizationId", {
8747
+ length: 191
8748
+ }),
8749
+ status: (0, import_mysql_core3.int)("status").default(0).notNull(),
8750
+ createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
8751
+ mode: "date",
8752
+ fsp: 3
8753
+ }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8754
+ label: (0, import_mysql_core3.varchar)("label", {
8755
+ length: 191
8756
+ }),
8757
+ identifier: (0, import_mysql_core3.varchar)("identifier", {
8758
+ length: 191
8759
+ })
8760
+ }, (table) => {
8761
+ return {
8762
+ merchantAccountId: (0, import_mysql_core3.primaryKey)({
8763
+ columns: [
8764
+ table.id
8765
+ ],
8766
+ name: "MerchantAccount_id"
8767
+ }),
8768
+ organizationIdIdx: (0, import_mysql_core3.index)("organizationId_idx").on(table.organizationId)
8769
+ };
8770
+ });
8771
+ }
8772
+ __name(getMerchantAccountSchema, "getMerchantAccountSchema");
8773
+
8774
+ // src/lib/mysql/schemas/commerce/merchant-customer.ts
8775
+ var import_drizzle_orm4 = require("drizzle-orm");
8776
+ var import_mysql_core4 = require("drizzle-orm/mysql-core");
8569
8777
  function getMerchantCustomerSchema(mysqlTable) {
8570
8778
  return mysqlTable("MerchantCustomer", {
8571
- id: (0, import_mysql_core2.varchar)("id", {
8779
+ id: (0, import_mysql_core4.varchar)("id", {
8572
8780
  length: 191
8573
8781
  }).notNull(),
8574
- organizationId: (0, import_mysql_core2.varchar)("organizationId", {
8782
+ organizationId: (0, import_mysql_core4.varchar)("organizationId", {
8575
8783
  length: 191
8576
8784
  }),
8577
- userId: (0, import_mysql_core2.varchar)("userId", {
8785
+ userId: (0, import_mysql_core4.varchar)("userId", {
8578
8786
  length: 191
8579
8787
  }).notNull(),
8580
- merchantAccountId: (0, import_mysql_core2.varchar)("merchantAccountId", {
8788
+ merchantAccountId: (0, import_mysql_core4.varchar)("merchantAccountId", {
8581
8789
  length: 191
8582
8790
  }).notNull(),
8583
- identifier: (0, import_mysql_core2.varchar)("identifier", {
8791
+ identifier: (0, import_mysql_core4.varchar)("identifier", {
8584
8792
  length: 191
8585
8793
  }).notNull(),
8586
- createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
8794
+ createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
8587
8795
  mode: "date",
8588
8796
  fsp: 3
8589
- }).default(import_drizzle_orm2.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8590
- status: (0, import_mysql_core2.int)("status").default(0)
8797
+ }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8798
+ status: (0, import_mysql_core4.int)("status").default(0)
8591
8799
  }, (table) => {
8592
8800
  return {
8593
- merchantCustomerId: (0, import_mysql_core2.primaryKey)({
8801
+ merchantCustomerId: (0, import_mysql_core4.primaryKey)({
8594
8802
  columns: [
8595
8803
  table.id
8596
8804
  ],
8597
8805
  name: "MerchantCustomer_id"
8598
8806
  }),
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)
8807
+ merchantCustomerIdentifierKey: (0, import_mysql_core4.unique)("MerchantCustomer_identifier_key").on(table.identifier),
8808
+ userIdIdx: (0, import_mysql_core4.index)("idx_MerchantCustomer_on_userId").on(table.userId),
8809
+ organizationIdIdx: (0, import_mysql_core4.index)("organizationId_idx").on(table.organizationId)
8602
8810
  };
8603
8811
  });
8604
8812
  }
8605
8813
  __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
8606
8814
 
8607
8815
  // 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");
8816
+ var import_drizzle_orm5 = require("drizzle-orm");
8817
+ var import_mysql_core5 = require("drizzle-orm/mysql-core");
8610
8818
  function getMerchantProductSchema(mysqlTable) {
8611
8819
  return mysqlTable("MerchantProduct", {
8612
- id: (0, import_mysql_core3.varchar)("id", {
8820
+ id: (0, import_mysql_core5.varchar)("id", {
8613
8821
  length: 191
8614
8822
  }).notNull(),
8615
- organizationId: (0, import_mysql_core3.varchar)("organizationId", {
8823
+ organizationId: (0, import_mysql_core5.varchar)("organizationId", {
8616
8824
  length: 191
8617
8825
  }),
8618
- merchantAccountId: (0, import_mysql_core3.varchar)("merchantAccountId", {
8826
+ merchantAccountId: (0, import_mysql_core5.varchar)("merchantAccountId", {
8619
8827
  length: 191
8620
8828
  }).notNull(),
8621
- productId: (0, import_mysql_core3.varchar)("productId", {
8829
+ productId: (0, import_mysql_core5.varchar)("productId", {
8622
8830
  length: 191
8623
8831
  }).notNull(),
8624
- status: (0, import_mysql_core3.int)("status").default(0).notNull(),
8625
- identifier: (0, import_mysql_core3.varchar)("identifier", {
8832
+ status: (0, import_mysql_core5.int)("status").default(0).notNull(),
8833
+ identifier: (0, import_mysql_core5.varchar)("identifier", {
8626
8834
  length: 191
8627
8835
  }),
8628
- createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
8836
+ createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
8629
8837
  mode: "date",
8630
8838
  fsp: 3
8631
- }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`).notNull()
8839
+ }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`).notNull()
8632
8840
  }, (table) => {
8633
8841
  return {
8634
- merchantProductId: (0, import_mysql_core3.primaryKey)({
8842
+ merchantProductId: (0, import_mysql_core5.primaryKey)({
8635
8843
  columns: [
8636
8844
  table.id
8637
8845
  ],
8638
8846
  name: "MerchantProduct_id"
8639
8847
  }),
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)
8848
+ merchantProductIdentifierKey: (0, import_mysql_core5.unique)("MerchantProduct_identifier_key").on(table.identifier),
8849
+ organizationIdIdx: (0, import_mysql_core5.index)("organizationId_idx").on(table.organizationId)
8642
8850
  };
8643
8851
  });
8644
8852
  }
@@ -8647,46 +8855,46 @@ __name(getMerchantProductSchema, "getMerchantProductSchema");
8647
8855
  // src/lib/mysql/schemas/commerce/merchant-charge.ts
8648
8856
  function getMerchantChargeSchema(mysqlTable) {
8649
8857
  return mysqlTable("MerchantCharge", {
8650
- id: (0, import_mysql_core4.varchar)("id", {
8858
+ id: (0, import_mysql_core6.varchar)("id", {
8651
8859
  length: 191
8652
8860
  }).notNull(),
8653
- organizationId: (0, import_mysql_core4.varchar)("organizationId", {
8861
+ organizationId: (0, import_mysql_core6.varchar)("organizationId", {
8654
8862
  length: 191
8655
8863
  }),
8656
- status: (0, import_mysql_core4.int)("status").default(0).notNull(),
8657
- identifier: (0, import_mysql_core4.varchar)("identifier", {
8864
+ status: (0, import_mysql_core6.int)("status").default(0).notNull(),
8865
+ identifier: (0, import_mysql_core6.varchar)("identifier", {
8658
8866
  length: 191
8659
8867
  }).notNull(),
8660
- userId: (0, import_mysql_core4.varchar)("userId", {
8868
+ userId: (0, import_mysql_core6.varchar)("userId", {
8661
8869
  length: 191
8662
8870
  }).notNull(),
8663
- merchantAccountId: (0, import_mysql_core4.varchar)("merchantAccountId", {
8871
+ merchantAccountId: (0, import_mysql_core6.varchar)("merchantAccountId", {
8664
8872
  length: 191
8665
8873
  }).notNull(),
8666
- merchantProductId: (0, import_mysql_core4.varchar)("merchantProductId", {
8874
+ merchantProductId: (0, import_mysql_core6.varchar)("merchantProductId", {
8667
8875
  length: 191
8668
8876
  }).notNull(),
8669
- merchantSubscriptionId: (0, import_mysql_core4.varchar)("merchantSubscriptionId", {
8877
+ merchantSubscriptionId: (0, import_mysql_core6.varchar)("merchantSubscriptionId", {
8670
8878
  length: 191
8671
8879
  }),
8672
- createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
8880
+ createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
8673
8881
  mode: "date",
8674
8882
  fsp: 3
8675
- }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8676
- merchantCustomerId: (0, import_mysql_core4.varchar)("merchantCustomerId", {
8883
+ }).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8884
+ merchantCustomerId: (0, import_mysql_core6.varchar)("merchantCustomerId", {
8677
8885
  length: 191
8678
8886
  }).notNull()
8679
8887
  }, (table) => {
8680
8888
  return {
8681
- merchantChargeId: (0, import_mysql_core4.primaryKey)({
8889
+ merchantChargeId: (0, import_mysql_core6.primaryKey)({
8682
8890
  columns: [
8683
8891
  table.id
8684
8892
  ],
8685
8893
  name: "MerchantCharge_id"
8686
8894
  }),
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)
8895
+ merchantChargeIdentifierKey: (0, import_mysql_core6.unique)("MerchantCharge_identifier_key").on(table.identifier),
8896
+ merchantSubscriptionIdIdx: (0, import_mysql_core6.index)("merchantSubscriptionId_idx").on(table.merchantSubscriptionId),
8897
+ organizationIdIdx: (0, import_mysql_core6.index)("organizationId_idx").on(table.organizationId)
8690
8898
  };
8691
8899
  });
8692
8900
  }
@@ -8697,7 +8905,7 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
8697
8905
  const merchantProduct = getMerchantProductSchema(mysqlTable);
8698
8906
  const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
8699
8907
  const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
8700
- return (0, import_drizzle_orm4.relations)(merchantCharge, ({ one }) => ({
8908
+ return (0, import_drizzle_orm6.relations)(merchantCharge, ({ one }) => ({
8701
8909
  merchantAccount: one(merchantAccount, {
8702
8910
  fields: [
8703
8911
  merchantCharge.merchantAccountId
@@ -8741,41 +8949,41 @@ __name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
8741
8949
  // src/lib/mysql/schemas/commerce/merchant-subscription.ts
8742
8950
  function getMerchantSubscriptionSchema(mysqlTable) {
8743
8951
  return mysqlTable("MerchantSubscription", {
8744
- id: (0, import_mysql_core5.varchar)("id", {
8952
+ id: (0, import_mysql_core7.varchar)("id", {
8745
8953
  length: 191
8746
8954
  }).notNull(),
8747
- organizationId: (0, import_mysql_core5.varchar)("organizationId", {
8955
+ organizationId: (0, import_mysql_core7.varchar)("organizationId", {
8748
8956
  length: 191
8749
8957
  }),
8750
- merchantAccountId: (0, import_mysql_core5.varchar)("merchantAccountId", {
8958
+ merchantAccountId: (0, import_mysql_core7.varchar)("merchantAccountId", {
8751
8959
  length: 191
8752
8960
  }).notNull(),
8753
- status: (0, import_mysql_core5.int)("status").default(0).notNull(),
8754
- createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
8961
+ status: (0, import_mysql_core7.int)("status").default(0).notNull(),
8962
+ createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
8755
8963
  mode: "date",
8756
8964
  fsp: 3
8757
- }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8758
- label: (0, import_mysql_core5.varchar)("label", {
8965
+ }).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8966
+ label: (0, import_mysql_core7.varchar)("label", {
8759
8967
  length: 191
8760
8968
  }),
8761
- identifier: (0, import_mysql_core5.varchar)("identifier", {
8969
+ identifier: (0, import_mysql_core7.varchar)("identifier", {
8762
8970
  length: 191
8763
8971
  }),
8764
- merchantCustomerId: (0, import_mysql_core5.varchar)("merchantCustomerId", {
8972
+ merchantCustomerId: (0, import_mysql_core7.varchar)("merchantCustomerId", {
8765
8973
  length: 191
8766
8974
  }).notNull(),
8767
- merchantProductId: (0, import_mysql_core5.varchar)("merchantProductId", {
8975
+ merchantProductId: (0, import_mysql_core7.varchar)("merchantProductId", {
8768
8976
  length: 191
8769
8977
  }).notNull()
8770
8978
  }, (table) => {
8771
8979
  return {
8772
- merchantSubscriptionId: (0, import_mysql_core5.primaryKey)({
8980
+ merchantSubscriptionId: (0, import_mysql_core7.primaryKey)({
8773
8981
  columns: [
8774
8982
  table.id
8775
8983
  ],
8776
8984
  name: "MerchantSubscription_id"
8777
8985
  }),
8778
- organizationIdIdx: (0, import_mysql_core5.index)("organizationId_idx").on(table.organizationId)
8986
+ organizationIdIdx: (0, import_mysql_core7.index)("organizationId_idx").on(table.organizationId)
8779
8987
  };
8780
8988
  });
8781
8989
  }
@@ -8784,7 +8992,7 @@ function getMerchantSubscriptionRelationsSchema(mysqlTable) {
8784
8992
  const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
8785
8993
  const merchantCharge = getMerchantChargeSchema(mysqlTable);
8786
8994
  const subscription = getSubscriptionSchema(mysqlTable);
8787
- return (0, import_drizzle_orm5.relations)(merchantSubscription, ({ many, one }) => ({
8995
+ return (0, import_drizzle_orm7.relations)(merchantSubscription, ({ many, one }) => ({
8788
8996
  merchantCharges: many(merchantCharge, {
8789
8997
  relationName: "merchantSubscription"
8790
8998
  }),
@@ -8802,104 +9010,104 @@ function getMerchantSubscriptionRelationsSchema(mysqlTable) {
8802
9010
  __name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
8803
9011
 
8804
9012
  // src/lib/mysql/schemas/commerce/product.ts
8805
- var import_drizzle_orm17 = require("drizzle-orm");
8806
- var import_mysql_core17 = require("drizzle-orm/mysql-core");
9013
+ var import_drizzle_orm19 = require("drizzle-orm");
9014
+ var import_mysql_core19 = require("drizzle-orm/mysql-core");
8807
9015
 
8808
9016
  // src/lib/mysql/schemas/content/content-resource-product.ts
8809
- var import_drizzle_orm14 = require("drizzle-orm");
8810
- var import_mysql_core14 = require("drizzle-orm/mysql-core");
9017
+ var import_drizzle_orm16 = require("drizzle-orm");
9018
+ var import_mysql_core16 = require("drizzle-orm/mysql-core");
8811
9019
 
8812
9020
  // src/lib/mysql/schemas/content/content-resource.ts
8813
- var import_drizzle_orm13 = require("drizzle-orm");
8814
- var import_mysql_core13 = require("drizzle-orm/mysql-core");
9021
+ var import_drizzle_orm15 = require("drizzle-orm");
9022
+ var import_mysql_core15 = require("drizzle-orm/mysql-core");
8815
9023
 
8816
9024
  // src/lib/mysql/schemas/content/content-contributions.ts
8817
- var import_drizzle_orm7 = require("drizzle-orm");
8818
- var import_mysql_core7 = require("drizzle-orm/mysql-core");
9025
+ var import_drizzle_orm9 = require("drizzle-orm");
9026
+ var import_mysql_core9 = require("drizzle-orm/mysql-core");
8819
9027
 
8820
9028
  // src/lib/mysql/schemas/content/contribution-types.ts
8821
- var import_drizzle_orm6 = require("drizzle-orm");
8822
- var import_mysql_core6 = require("drizzle-orm/mysql-core");
9029
+ var import_drizzle_orm8 = require("drizzle-orm");
9030
+ var import_mysql_core8 = require("drizzle-orm/mysql-core");
8823
9031
  function getContributionTypesSchema(mysqlTable) {
8824
9032
  return mysqlTable("ContributionType", {
8825
- id: (0, import_mysql_core6.varchar)("id", {
9033
+ id: (0, import_mysql_core8.varchar)("id", {
8826
9034
  length: 255
8827
9035
  }).notNull().primaryKey(),
8828
- organizationId: (0, import_mysql_core6.varchar)("organizationId", {
9036
+ organizationId: (0, import_mysql_core8.varchar)("organizationId", {
8829
9037
  length: 191
8830
9038
  }),
8831
- slug: (0, import_mysql_core6.varchar)("slug", {
9039
+ slug: (0, import_mysql_core8.varchar)("slug", {
8832
9040
  length: 255
8833
9041
  }).notNull().unique(),
8834
- name: (0, import_mysql_core6.varchar)("name", {
9042
+ name: (0, import_mysql_core8.varchar)("name", {
8835
9043
  length: 255
8836
9044
  }).notNull(),
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", {
9045
+ description: (0, import_mysql_core8.text)("description"),
9046
+ active: (0, import_mysql_core8.boolean)("active").notNull().default(true),
9047
+ createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
8840
9048
  mode: "date",
8841
9049
  fsp: 3
8842
9050
  }).defaultNow(),
8843
- updatedAt: (0, import_mysql_core6.timestamp)("updatedAt", {
9051
+ updatedAt: (0, import_mysql_core8.timestamp)("updatedAt", {
8844
9052
  mode: "date",
8845
9053
  fsp: 3
8846
9054
  }).defaultNow(),
8847
- deletedAt: (0, import_mysql_core6.timestamp)("deletedAt", {
9055
+ deletedAt: (0, import_mysql_core8.timestamp)("deletedAt", {
8848
9056
  mode: "date",
8849
9057
  fsp: 3
8850
9058
  })
8851
9059
  }, (ct) => ({
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)
9060
+ nameIdx: (0, import_mysql_core8.index)("name_idx").on(ct.name),
9061
+ slugIdx: (0, import_mysql_core8.index)("slug_idx").on(ct.slug),
9062
+ organizationIdIdx: (0, import_mysql_core8.index)("organizationId_idx").on(ct.organizationId)
8855
9063
  }));
8856
9064
  }
8857
9065
  __name(getContributionTypesSchema, "getContributionTypesSchema");
8858
9066
  function getContributionTypesRelationsSchema(mysqlTable) {
8859
9067
  const contributionTypes = getContributionTypesSchema(mysqlTable);
8860
- return (0, import_drizzle_orm6.relations)(contributionTypes, ({ many }) => ({}));
9068
+ return (0, import_drizzle_orm8.relations)(contributionTypes, ({ many }) => ({}));
8861
9069
  }
8862
9070
  __name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
8863
9071
 
8864
9072
  // src/lib/mysql/schemas/content/content-contributions.ts
8865
9073
  function getContentContributionsSchema(mysqlTable) {
8866
9074
  return mysqlTable("ContentContribution", {
8867
- id: (0, import_mysql_core7.varchar)("id", {
9075
+ id: (0, import_mysql_core9.varchar)("id", {
8868
9076
  length: 255
8869
9077
  }).notNull().primaryKey(),
8870
- userId: (0, import_mysql_core7.varchar)("userId", {
9078
+ userId: (0, import_mysql_core9.varchar)("userId", {
8871
9079
  length: 255
8872
9080
  }).notNull(),
8873
- organizationId: (0, import_mysql_core7.varchar)("organizationId", {
9081
+ organizationId: (0, import_mysql_core9.varchar)("organizationId", {
8874
9082
  length: 191
8875
9083
  }),
8876
- organizationMembershipId: (0, import_mysql_core7.varchar)("organizationMembershipId", {
9084
+ organizationMembershipId: (0, import_mysql_core9.varchar)("organizationMembershipId", {
8877
9085
  length: 255
8878
9086
  }),
8879
- contentId: (0, import_mysql_core7.varchar)("contentId", {
9087
+ contentId: (0, import_mysql_core9.varchar)("contentId", {
8880
9088
  length: 255
8881
9089
  }).notNull(),
8882
- contributionTypeId: (0, import_mysql_core7.varchar)("contributionTypeId", {
9090
+ contributionTypeId: (0, import_mysql_core9.varchar)("contributionTypeId", {
8883
9091
  length: 255
8884
9092
  }).notNull(),
8885
- active: (0, import_mysql_core7.boolean)("active").notNull().default(true),
8886
- createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
9093
+ active: (0, import_mysql_core9.boolean)("active").notNull().default(true),
9094
+ createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
8887
9095
  mode: "date",
8888
9096
  fsp: 3
8889
9097
  }).defaultNow(),
8890
- updatedAt: (0, import_mysql_core7.timestamp)("updatedAt", {
9098
+ updatedAt: (0, import_mysql_core9.timestamp)("updatedAt", {
8891
9099
  mode: "date",
8892
9100
  fsp: 3
8893
9101
  }).defaultNow(),
8894
- deletedAt: (0, import_mysql_core7.timestamp)("deletedAt", {
9102
+ deletedAt: (0, import_mysql_core9.timestamp)("deletedAt", {
8895
9103
  mode: "date",
8896
9104
  fsp: 3
8897
9105
  })
8898
9106
  }, (cc) => ({
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)
9107
+ userIdIdx: (0, import_mysql_core9.index)("userId_idx").on(cc.userId),
9108
+ contentIdIdx: (0, import_mysql_core9.index)("contentId_idx").on(cc.contentId),
9109
+ contributionTypeIdIdx: (0, import_mysql_core9.index)("contributionTypeId_idx").on(cc.contributionTypeId),
9110
+ organizationMembershipIdIdx: (0, import_mysql_core9.index)("organizationMembershipId_idx").on(cc.organizationMembershipId)
8903
9111
  }));
8904
9112
  }
8905
9113
  __name(getContentContributionsSchema, "getContentContributionsSchema");
@@ -8909,7 +9117,7 @@ function getContentContributionRelationsSchema(mysqlTable) {
8909
9117
  const contentResource = getContentResourceSchema(mysqlTable);
8910
9118
  const contributionTypes = getContributionTypesSchema(mysqlTable);
8911
9119
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
8912
- return (0, import_drizzle_orm7.relations)(contentContributions, ({ one }) => ({
9120
+ return (0, import_drizzle_orm9.relations)(contentContributions, ({ one }) => ({
8913
9121
  user: one(users, {
8914
9122
  fields: [
8915
9123
  contentContributions.userId
@@ -8951,50 +9159,50 @@ function getContentContributionRelationsSchema(mysqlTable) {
8951
9159
  __name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
8952
9160
 
8953
9161
  // src/lib/mysql/schemas/content/content-resource-resource.ts
8954
- var import_drizzle_orm8 = require("drizzle-orm");
8955
- var import_mysql_core8 = require("drizzle-orm/mysql-core");
9162
+ var import_drizzle_orm10 = require("drizzle-orm");
9163
+ var import_mysql_core10 = require("drizzle-orm/mysql-core");
8956
9164
  function getContentResourceResourceSchema(mysqlTable) {
8957
9165
  return mysqlTable("ContentResourceResource", {
8958
- resourceOfId: (0, import_mysql_core8.varchar)("resourceOfId", {
9166
+ resourceOfId: (0, import_mysql_core10.varchar)("resourceOfId", {
8959
9167
  length: 255
8960
9168
  }).notNull(),
8961
- resourceId: (0, import_mysql_core8.varchar)("resourceId", {
9169
+ resourceId: (0, import_mysql_core10.varchar)("resourceId", {
8962
9170
  length: 255
8963
9171
  }).notNull(),
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", {
9172
+ position: (0, import_mysql_core10.double)("position").notNull().default(0),
9173
+ metadata: (0, import_mysql_core10.json)("metadata").$type().default({}),
9174
+ organizationId: (0, import_mysql_core10.varchar)("organizationId", {
8967
9175
  length: 191
8968
9176
  }),
8969
- createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
9177
+ createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
8970
9178
  mode: "date",
8971
9179
  fsp: 3
8972
- }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`),
8973
- updatedAt: (0, import_mysql_core8.timestamp)("updatedAt", {
9180
+ }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
9181
+ updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
8974
9182
  mode: "date",
8975
9183
  fsp: 3
8976
- }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`),
8977
- deletedAt: (0, import_mysql_core8.timestamp)("deletedAt", {
9184
+ }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
9185
+ deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
8978
9186
  mode: "date",
8979
9187
  fsp: 3
8980
9188
  })
8981
9189
  }, (crr) => ({
8982
- pk: (0, import_mysql_core8.primaryKey)({
9190
+ pk: (0, import_mysql_core10.primaryKey)({
8983
9191
  columns: [
8984
9192
  crr.resourceOfId,
8985
9193
  crr.resourceId
8986
9194
  ]
8987
9195
  }),
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)
9196
+ contentResourceIdIdx: (0, import_mysql_core10.index)("contentResourceId_idx").on(crr.resourceOfId),
9197
+ resourceIdIdx: (0, import_mysql_core10.index)("resourceId_idx").on(crr.resourceId),
9198
+ organizationIdIdx: (0, import_mysql_core10.index)("organizationId_idx").on(crr.organizationId)
8991
9199
  }));
8992
9200
  }
8993
9201
  __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
8994
9202
  function getContentResourceResourceRelationsSchema(mysqlTable) {
8995
9203
  const contentResource = getContentResourceSchema(mysqlTable);
8996
9204
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
8997
- return (0, import_drizzle_orm8.relations)(contentResourceResource, ({ one }) => ({
9205
+ return (0, import_drizzle_orm10.relations)(contentResourceResource, ({ one }) => ({
8998
9206
  resourceOf: one(contentResource, {
8999
9207
  fields: [
9000
9208
  contentResourceResource.resourceOfId
@@ -9018,59 +9226,59 @@ function getContentResourceResourceRelationsSchema(mysqlTable) {
9018
9226
  __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
9019
9227
 
9020
9228
  // 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");
9229
+ var import_drizzle_orm13 = require("drizzle-orm");
9230
+ var import_mysql_core13 = require("drizzle-orm/mysql-core");
9023
9231
 
9024
9232
  // 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");
9233
+ var import_drizzle_orm12 = require("drizzle-orm");
9234
+ var import_mysql_core12 = require("drizzle-orm/mysql-core");
9027
9235
 
9028
9236
  // 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");
9237
+ var import_drizzle_orm11 = require("drizzle-orm");
9238
+ var import_mysql_core11 = require("drizzle-orm/mysql-core");
9031
9239
  function getTagTagSchema(mysqlTable) {
9032
9240
  return mysqlTable("TagTag", {
9033
- parentTagId: (0, import_mysql_core9.varchar)("parentTagId", {
9241
+ parentTagId: (0, import_mysql_core11.varchar)("parentTagId", {
9034
9242
  length: 255
9035
9243
  }).notNull(),
9036
- childTagId: (0, import_mysql_core9.varchar)("childTagId", {
9244
+ childTagId: (0, import_mysql_core11.varchar)("childTagId", {
9037
9245
  length: 255
9038
9246
  }).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", {
9247
+ position: (0, import_mysql_core11.double)("position").notNull().default(0),
9248
+ metadata: (0, import_mysql_core11.json)("metadata").$type().default({}),
9249
+ organizationId: (0, import_mysql_core11.varchar)("organizationId", {
9042
9250
  length: 191
9043
9251
  }),
9044
- createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
9252
+ createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
9045
9253
  mode: "date",
9046
9254
  fsp: 3
9047
- }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
9048
- updatedAt: (0, import_mysql_core9.timestamp)("updatedAt", {
9255
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
9256
+ updatedAt: (0, import_mysql_core11.timestamp)("updatedAt", {
9049
9257
  mode: "date",
9050
9258
  fsp: 3
9051
- }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
9052
- deletedAt: (0, import_mysql_core9.timestamp)("deletedAt", {
9259
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
9260
+ deletedAt: (0, import_mysql_core11.timestamp)("deletedAt", {
9053
9261
  mode: "date",
9054
9262
  fsp: 3
9055
9263
  })
9056
9264
  }, (tt) => ({
9057
- pk: (0, import_mysql_core9.primaryKey)({
9265
+ pk: (0, import_mysql_core11.primaryKey)({
9058
9266
  columns: [
9059
9267
  tt.parentTagId,
9060
9268
  tt.childTagId
9061
9269
  ]
9062
9270
  }),
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)
9271
+ parentTagIdIdx: (0, import_mysql_core11.index)("parentTagId_idx").on(tt.parentTagId),
9272
+ childTagIdIdx: (0, import_mysql_core11.index)("childTagId_idx").on(tt.childTagId),
9273
+ positionIdx: (0, import_mysql_core11.index)("position_idx").on(tt.position),
9274
+ organizationIdIdx: (0, import_mysql_core11.index)("organizationId_idx").on(tt.organizationId)
9067
9275
  }));
9068
9276
  }
9069
9277
  __name(getTagTagSchema, "getTagTagSchema");
9070
9278
  function getTagTagRelationsSchema(mysqlTable) {
9071
9279
  const tag = getTagSchema(mysqlTable);
9072
9280
  const tagTag = getTagTagSchema(mysqlTable);
9073
- return (0, import_drizzle_orm9.relations)(tagTag, ({ one }) => ({
9281
+ return (0, import_drizzle_orm11.relations)(tagTag, ({ one }) => ({
9074
9282
  parentTag: one(tag, {
9075
9283
  fields: [
9076
9284
  tagTag.parentTagId
@@ -9096,31 +9304,31 @@ __name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
9096
9304
  // src/lib/mysql/schemas/content/tag.ts
9097
9305
  function getTagSchema(mysqlTable) {
9098
9306
  return mysqlTable("Tag", {
9099
- id: (0, import_mysql_core10.varchar)("id", {
9307
+ id: (0, import_mysql_core12.varchar)("id", {
9100
9308
  length: 255
9101
9309
  }).notNull().primaryKey(),
9102
- organizationId: (0, import_mysql_core10.varchar)("organizationId", {
9310
+ organizationId: (0, import_mysql_core12.varchar)("organizationId", {
9103
9311
  length: 191
9104
9312
  }),
9105
- type: (0, import_mysql_core10.varchar)("type", {
9313
+ type: (0, import_mysql_core12.varchar)("type", {
9106
9314
  length: 255
9107
9315
  }).notNull(),
9108
- fields: (0, import_mysql_core10.json)("fields").$type().default({}),
9109
- createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
9316
+ fields: (0, import_mysql_core12.json)("fields").$type().default({}),
9317
+ createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
9110
9318
  mode: "date",
9111
9319
  fsp: 3
9112
- }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
9113
- updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
9320
+ }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
9321
+ updatedAt: (0, import_mysql_core12.timestamp)("updatedAt", {
9114
9322
  mode: "date",
9115
9323
  fsp: 3
9116
- }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
9117
- deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
9324
+ }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
9325
+ deletedAt: (0, import_mysql_core12.timestamp)("deletedAt", {
9118
9326
  mode: "date",
9119
9327
  fsp: 3
9120
9328
  })
9121
9329
  }, (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)
9330
+ typeIdx: (0, import_mysql_core12.index)("type_idx").on(t.type),
9331
+ organizationIdIdx: (0, import_mysql_core12.index)("organizationId_idx").on(t.organizationId)
9124
9332
  }));
9125
9333
  }
9126
9334
  __name(getTagSchema, "getTagSchema");
@@ -9128,7 +9336,7 @@ function getTagRelationsSchema(mysqlTable) {
9128
9336
  const tag = getTagSchema(mysqlTable);
9129
9337
  const contentResourceTag = getContentResourceTagSchema(mysqlTable);
9130
9338
  const tagTag = getTagTagSchema(mysqlTable);
9131
- return (0, import_drizzle_orm10.relations)(tag, ({ many }) => ({
9339
+ return (0, import_drizzle_orm12.relations)(tag, ({ many }) => ({
9132
9340
  resources: many(contentResourceTag, {
9133
9341
  relationName: "contentResource"
9134
9342
  }),
@@ -9145,35 +9353,35 @@ __name(getTagRelationsSchema, "getTagRelationsSchema");
9145
9353
  // src/lib/mysql/schemas/content/content-resource-tag.ts
9146
9354
  function getContentResourceTagSchema(mysqlTable) {
9147
9355
  return mysqlTable("ContentResourceTag", {
9148
- contentResourceId: (0, import_mysql_core11.varchar)("contentResourceId", {
9356
+ contentResourceId: (0, import_mysql_core13.varchar)("contentResourceId", {
9149
9357
  length: 255
9150
9358
  }).notNull(),
9151
- organizationId: (0, import_mysql_core11.varchar)("organizationId", {
9359
+ organizationId: (0, import_mysql_core13.varchar)("organizationId", {
9152
9360
  length: 191
9153
9361
  }),
9154
- tagId: (0, import_mysql_core11.varchar)("tagId", {
9362
+ tagId: (0, import_mysql_core13.varchar)("tagId", {
9155
9363
  length: 255
9156
9364
  }).notNull(),
9157
- position: (0, import_mysql_core11.double)("position").notNull().default(0),
9158
- createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
9365
+ position: (0, import_mysql_core13.double)("position").notNull().default(0),
9366
+ createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
9159
9367
  mode: "date",
9160
9368
  fsp: 3
9161
- }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
9162
- updatedAt: (0, import_mysql_core11.timestamp)("updatedAt", {
9369
+ }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
9370
+ updatedAt: (0, import_mysql_core13.timestamp)("updatedAt", {
9163
9371
  mode: "date",
9164
9372
  fsp: 3
9165
- }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`)
9373
+ }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`)
9166
9374
  }, (crt) => ({
9167
- pk: (0, import_mysql_core11.primaryKey)({
9375
+ pk: (0, import_mysql_core13.primaryKey)({
9168
9376
  columns: [
9169
9377
  crt.contentResourceId,
9170
9378
  crt.tagId
9171
9379
  ]
9172
9380
  }),
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)
9381
+ contentResourceIdIdx: (0, import_mysql_core13.index)("contentResourceId_idx").on(crt.contentResourceId),
9382
+ tagIdIdx: (0, import_mysql_core13.index)("tagId_idx").on(crt.tagId),
9383
+ positionIdx: (0, import_mysql_core13.index)("position_idx").on(crt.position),
9384
+ organizationIdIdx: (0, import_mysql_core13.index)("organizationId_idx").on(crt.organizationId)
9177
9385
  }));
9178
9386
  }
9179
9387
  __name(getContentResourceTagSchema, "getContentResourceTagSchema");
@@ -9181,7 +9389,7 @@ function getContentResourceTagRelationsSchema(mysqlTable) {
9181
9389
  const contentResource = getContentResourceSchema(mysqlTable);
9182
9390
  const tag = getTagSchema(mysqlTable);
9183
9391
  const contentResourceTag = getContentResourceTagSchema(mysqlTable);
9184
- return (0, import_drizzle_orm11.relations)(contentResourceTag, ({ one }) => ({
9392
+ return (0, import_drizzle_orm13.relations)(contentResourceTag, ({ one }) => ({
9185
9393
  contentResource: one(contentResource, {
9186
9394
  fields: [
9187
9395
  contentResourceTag.contentResourceId
@@ -9205,37 +9413,37 @@ function getContentResourceTagRelationsSchema(mysqlTable) {
9205
9413
  __name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
9206
9414
 
9207
9415
  // 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");
9416
+ var import_drizzle_orm14 = require("drizzle-orm");
9417
+ var import_mysql_core14 = require("drizzle-orm/mysql-core");
9210
9418
  function getContentResourceVersionSchema(mysqlTable) {
9211
9419
  return mysqlTable("ContentResourceVersion", {
9212
- id: (0, import_mysql_core12.varchar)("id", {
9420
+ id: (0, import_mysql_core14.varchar)("id", {
9213
9421
  length: 255
9214
9422
  }).notNull().primaryKey(),
9215
- organizationId: (0, import_mysql_core12.varchar)("organizationId", {
9423
+ organizationId: (0, import_mysql_core14.varchar)("organizationId", {
9216
9424
  length: 191
9217
9425
  }),
9218
- resourceId: (0, import_mysql_core12.varchar)("resourceId", {
9426
+ resourceId: (0, import_mysql_core14.varchar)("resourceId", {
9219
9427
  length: 255
9220
9428
  }).notNull(),
9221
- parentVersionId: (0, import_mysql_core12.varchar)("parentVersionId", {
9429
+ parentVersionId: (0, import_mysql_core14.varchar)("parentVersionId", {
9222
9430
  length: 255
9223
9431
  }),
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", {
9432
+ versionNumber: (0, import_mysql_core14.int)("versionNumber").notNull(),
9433
+ fields: (0, import_mysql_core14.json)("fields").$type().default({}),
9434
+ createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
9227
9435
  mode: "date",
9228
9436
  fsp: 3
9229
- }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
9230
- createdById: (0, import_mysql_core12.varchar)("createdById", {
9437
+ }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
9438
+ createdById: (0, import_mysql_core14.varchar)("createdById", {
9231
9439
  length: 255
9232
9440
  }).notNull()
9233
9441
  }, (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)
9442
+ resourceIdIdx: (0, import_mysql_core14.index)("resourceId_idx").on(crv.resourceId),
9443
+ parentVersionIdIdx: (0, import_mysql_core14.index)("parentVersionId_idx").on(crv.parentVersionId),
9444
+ resourceIdVersionNumberIdx: (0, import_mysql_core14.index)("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
9445
+ uniqueResourceVersion: (0, import_mysql_core14.unique)("uq_resource_version_number").on(crv.resourceId, crv.versionNumber),
9446
+ organizationIdIdx: (0, import_mysql_core14.index)("organizationId_idx").on(crv.organizationId)
9239
9447
  }));
9240
9448
  }
9241
9449
  __name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
@@ -9243,7 +9451,7 @@ function getContentResourceVersionRelationsSchema(mysqlTable) {
9243
9451
  const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
9244
9452
  const contentResource = getContentResourceSchema(mysqlTable);
9245
9453
  const users = getUsersSchema(mysqlTable);
9246
- return (0, import_drizzle_orm12.relations)(contentResourceVersion, ({ one }) => ({
9454
+ return (0, import_drizzle_orm14.relations)(contentResourceVersion, ({ one }) => ({
9247
9455
  resource: one(contentResource, {
9248
9456
  fields: [
9249
9457
  contentResourceVersion.resourceId
@@ -9278,43 +9486,43 @@ __name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelat
9278
9486
  // src/lib/mysql/schemas/content/content-resource.ts
9279
9487
  function getContentResourceSchema(mysqlTable) {
9280
9488
  return mysqlTable("ContentResource", {
9281
- id: (0, import_mysql_core13.varchar)("id", {
9489
+ id: (0, import_mysql_core15.varchar)("id", {
9282
9490
  length: 255
9283
9491
  }).notNull().primaryKey(),
9284
- organizationId: (0, import_mysql_core13.varchar)("organizationId", {
9492
+ organizationId: (0, import_mysql_core15.varchar)("organizationId", {
9285
9493
  length: 191
9286
9494
  }),
9287
- createdByOrganizationMembershipId: (0, import_mysql_core13.varchar)("createdByOrganizationMembershipId", {
9495
+ createdByOrganizationMembershipId: (0, import_mysql_core15.varchar)("createdByOrganizationMembershipId", {
9288
9496
  length: 191
9289
9497
  }),
9290
- type: (0, import_mysql_core13.varchar)("type", {
9498
+ type: (0, import_mysql_core15.varchar)("type", {
9291
9499
  length: 255
9292
9500
  }).notNull(),
9293
- createdById: (0, import_mysql_core13.varchar)("createdById", {
9501
+ createdById: (0, import_mysql_core15.varchar)("createdById", {
9294
9502
  length: 255
9295
9503
  }).notNull(),
9296
- fields: (0, import_mysql_core13.json)("fields").$type().default({}),
9297
- currentVersionId: (0, import_mysql_core13.varchar)("currentVersionId", {
9504
+ fields: (0, import_mysql_core15.json)("fields").$type().default({}),
9505
+ currentVersionId: (0, import_mysql_core15.varchar)("currentVersionId", {
9298
9506
  length: 255
9299
9507
  }),
9300
- createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
9508
+ createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
9301
9509
  mode: "date",
9302
9510
  fsp: 3
9303
- }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
9304
- updatedAt: (0, import_mysql_core13.timestamp)("updatedAt", {
9511
+ }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
9512
+ updatedAt: (0, import_mysql_core15.timestamp)("updatedAt", {
9305
9513
  mode: "date",
9306
9514
  fsp: 3
9307
- }).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
9308
- deletedAt: (0, import_mysql_core13.timestamp)("deletedAt", {
9515
+ }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
9516
+ deletedAt: (0, import_mysql_core15.timestamp)("deletedAt", {
9309
9517
  mode: "date",
9310
9518
  fsp: 3
9311
9519
  })
9312
9520
  }, (cm) => ({
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)
9521
+ typeIdx: (0, import_mysql_core15.index)("type_idx").on(cm.type),
9522
+ createdByIdx: (0, import_mysql_core15.index)("createdById_idx").on(cm.createdById),
9523
+ createdAtIdx: (0, import_mysql_core15.index)("createdAt_idx").on(cm.createdAt),
9524
+ currentVersionIdIdx: (0, import_mysql_core15.index)("currentVersionId_idx").on(cm.currentVersionId),
9525
+ createdByOrganizationMembershipIdIdx: (0, import_mysql_core15.index)("createdByOrganizationMembershipId_idx").on(cm.createdByOrganizationMembershipId)
9318
9526
  }));
9319
9527
  }
9320
9528
  __name(getContentResourceSchema, "getContentResourceSchema");
@@ -9328,7 +9536,7 @@ function getContentResourceRelationsSchema(mysqlTable) {
9328
9536
  const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
9329
9537
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9330
9538
  const tag = getTagSchema(mysqlTable);
9331
- return (0, import_drizzle_orm13.relations)(contentResource, ({ one, many }) => ({
9539
+ return (0, import_drizzle_orm15.relations)(contentResource, ({ one, many }) => ({
9332
9540
  createdBy: one(users, {
9333
9541
  fields: [
9334
9542
  contentResource.createdById
@@ -9381,39 +9589,39 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
9381
9589
  // src/lib/mysql/schemas/content/content-resource-product.ts
9382
9590
  function getContentResourceProductSchema(mysqlTable) {
9383
9591
  return mysqlTable("ContentResourceProduct", {
9384
- productId: (0, import_mysql_core14.varchar)("productId", {
9592
+ productId: (0, import_mysql_core16.varchar)("productId", {
9385
9593
  length: 255
9386
9594
  }).notNull(),
9387
- resourceId: (0, import_mysql_core14.varchar)("resourceId", {
9595
+ resourceId: (0, import_mysql_core16.varchar)("resourceId", {
9388
9596
  length: 255
9389
9597
  }).notNull(),
9390
- organizationId: (0, import_mysql_core14.varchar)("organizationId", {
9598
+ organizationId: (0, import_mysql_core16.varchar)("organizationId", {
9391
9599
  length: 191
9392
9600
  }),
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", {
9601
+ position: (0, import_mysql_core16.double)("position").notNull().default(0),
9602
+ metadata: (0, import_mysql_core16.json)("metadata").$type().default({}),
9603
+ createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
9396
9604
  mode: "date",
9397
9605
  fsp: 3
9398
- }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
9399
- updatedAt: (0, import_mysql_core14.timestamp)("updatedAt", {
9606
+ }).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`),
9607
+ updatedAt: (0, import_mysql_core16.timestamp)("updatedAt", {
9400
9608
  mode: "date",
9401
9609
  fsp: 3
9402
- }).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
9403
- deletedAt: (0, import_mysql_core14.timestamp)("deletedAt", {
9610
+ }).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`),
9611
+ deletedAt: (0, import_mysql_core16.timestamp)("deletedAt", {
9404
9612
  mode: "date",
9405
9613
  fsp: 3
9406
9614
  })
9407
9615
  }, (crr) => ({
9408
- pk: (0, import_mysql_core14.primaryKey)({
9616
+ pk: (0, import_mysql_core16.primaryKey)({
9409
9617
  columns: [
9410
9618
  crr.productId,
9411
9619
  crr.resourceId
9412
9620
  ]
9413
9621
  }),
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)
9622
+ contentResourceIdIdx: (0, import_mysql_core16.index)("contentResourceId_idx").on(crr.productId),
9623
+ resourceIdIdx: (0, import_mysql_core16.index)("resourceId_idx").on(crr.resourceId),
9624
+ organizationIdIdx: (0, import_mysql_core16.index)("organizationId_idx").on(crr.organizationId)
9417
9625
  }));
9418
9626
  }
9419
9627
  __name(getContentResourceProductSchema, "getContentResourceProductSchema");
@@ -9421,7 +9629,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
9421
9629
  const contentResource = getContentResourceSchema(mysqlTable);
9422
9630
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
9423
9631
  const product = getProductSchema(mysqlTable);
9424
- return (0, import_drizzle_orm14.relations)(contentResourceProduct, ({ one }) => ({
9632
+ return (0, import_drizzle_orm16.relations)(contentResourceProduct, ({ one }) => ({
9425
9633
  product: one(product, {
9426
9634
  fields: [
9427
9635
  contentResourceProduct.productId
@@ -9445,47 +9653,47 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
9445
9653
  __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
9446
9654
 
9447
9655
  // src/lib/mysql/schemas/commerce/price.ts
9448
- var import_drizzle_orm16 = require("drizzle-orm");
9449
- var import_mysql_core16 = require("drizzle-orm/mysql-core");
9656
+ var import_drizzle_orm18 = require("drizzle-orm");
9657
+ var import_mysql_core18 = require("drizzle-orm/mysql-core");
9450
9658
 
9451
9659
  // src/lib/mysql/schemas/commerce/merchant-price.ts
9452
- var import_drizzle_orm15 = require("drizzle-orm");
9453
- var import_mysql_core15 = require("drizzle-orm/mysql-core");
9660
+ var import_drizzle_orm17 = require("drizzle-orm");
9661
+ var import_mysql_core17 = require("drizzle-orm/mysql-core");
9454
9662
  function getMerchantPriceSchema(mysqlTable) {
9455
9663
  return mysqlTable("MerchantPrice", {
9456
- id: (0, import_mysql_core15.varchar)("id", {
9664
+ id: (0, import_mysql_core17.varchar)("id", {
9457
9665
  length: 191
9458
9666
  }).notNull(),
9459
- organizationId: (0, import_mysql_core15.varchar)("organizationId", {
9667
+ organizationId: (0, import_mysql_core17.varchar)("organizationId", {
9460
9668
  length: 191
9461
9669
  }),
9462
- merchantAccountId: (0, import_mysql_core15.varchar)("merchantAccountId", {
9670
+ merchantAccountId: (0, import_mysql_core17.varchar)("merchantAccountId", {
9463
9671
  length: 191
9464
9672
  }).notNull(),
9465
- merchantProductId: (0, import_mysql_core15.varchar)("merchantProductId", {
9673
+ merchantProductId: (0, import_mysql_core17.varchar)("merchantProductId", {
9466
9674
  length: 191
9467
9675
  }).notNull(),
9468
- status: (0, import_mysql_core15.int)("status").default(0),
9469
- identifier: (0, import_mysql_core15.varchar)("identifier", {
9676
+ status: (0, import_mysql_core17.int)("status").default(0),
9677
+ identifier: (0, import_mysql_core17.varchar)("identifier", {
9470
9678
  length: 191
9471
9679
  }),
9472
- createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
9680
+ createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
9473
9681
  mode: "date",
9474
9682
  fsp: 3
9475
- }).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9476
- priceId: (0, import_mysql_core15.varchar)("priceId", {
9683
+ }).default(import_drizzle_orm17.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9684
+ priceId: (0, import_mysql_core17.varchar)("priceId", {
9477
9685
  length: 191
9478
9686
  })
9479
9687
  }, (table) => {
9480
9688
  return {
9481
- merchantPriceId: (0, import_mysql_core15.primaryKey)({
9689
+ merchantPriceId: (0, import_mysql_core17.primaryKey)({
9482
9690
  columns: [
9483
9691
  table.id
9484
9692
  ],
9485
9693
  name: "MerchantPrice_id"
9486
9694
  }),
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)
9695
+ merchantPriceIdentifierKey: (0, import_mysql_core17.unique)("MerchantPrice_identifier_key").on(table.identifier),
9696
+ organizationIdIdx: (0, import_mysql_core17.index)("organizationId_idx").on(table.organizationId)
9489
9697
  };
9490
9698
  });
9491
9699
  }
@@ -9494,37 +9702,37 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
9494
9702
  // src/lib/mysql/schemas/commerce/price.ts
9495
9703
  function getPriceSchema(mysqlTable) {
9496
9704
  return mysqlTable("Price", {
9497
- id: (0, import_mysql_core16.varchar)("id", {
9705
+ id: (0, import_mysql_core18.varchar)("id", {
9498
9706
  length: 191
9499
9707
  }).notNull(),
9500
- productId: (0, import_mysql_core16.varchar)("productId", {
9708
+ productId: (0, import_mysql_core18.varchar)("productId", {
9501
9709
  length: 191
9502
9710
  }),
9503
- organizationId: (0, import_mysql_core16.varchar)("organizationId", {
9711
+ organizationId: (0, import_mysql_core18.varchar)("organizationId", {
9504
9712
  length: 191
9505
9713
  }),
9506
- nickname: (0, import_mysql_core16.varchar)("nickname", {
9714
+ nickname: (0, import_mysql_core18.varchar)("nickname", {
9507
9715
  length: 191
9508
9716
  }),
9509
- status: (0, import_mysql_core16.int)("status").default(0).notNull(),
9510
- unitAmount: (0, import_mysql_core16.decimal)("unitAmount", {
9717
+ status: (0, import_mysql_core18.int)("status").default(0).notNull(),
9718
+ unitAmount: (0, import_mysql_core18.decimal)("unitAmount", {
9511
9719
  precision: 10,
9512
9720
  scale: 2
9513
9721
  }).notNull(),
9514
- createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
9722
+ createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
9515
9723
  mode: "date",
9516
9724
  fsp: 3
9517
- }).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9518
- fields: (0, import_mysql_core16.json)("fields").$type().default({})
9725
+ }).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9726
+ fields: (0, import_mysql_core18.json)("fields").$type().default({})
9519
9727
  }, (table) => {
9520
9728
  return {
9521
- priceId: (0, import_mysql_core16.primaryKey)({
9729
+ priceId: (0, import_mysql_core18.primaryKey)({
9522
9730
  columns: [
9523
9731
  table.id
9524
9732
  ],
9525
9733
  name: "Price_id"
9526
9734
  }),
9527
- organizationIdIdx: (0, import_mysql_core16.index)("organizationId_idx").on(table.organizationId)
9735
+ organizationIdIdx: (0, import_mysql_core18.index)("organizationId_idx").on(table.organizationId)
9528
9736
  };
9529
9737
  });
9530
9738
  }
@@ -9533,37 +9741,37 @@ __name(getPriceSchema, "getPriceSchema");
9533
9741
  // src/lib/mysql/schemas/commerce/product.ts
9534
9742
  function getProductSchema(mysqlTable) {
9535
9743
  return mysqlTable("Product", {
9536
- id: (0, import_mysql_core17.varchar)("id", {
9744
+ id: (0, import_mysql_core19.varchar)("id", {
9537
9745
  length: 191
9538
9746
  }).notNull(),
9539
- organizationId: (0, import_mysql_core17.varchar)("organizationId", {
9747
+ organizationId: (0, import_mysql_core19.varchar)("organizationId", {
9540
9748
  length: 191
9541
9749
  }),
9542
- name: (0, import_mysql_core17.varchar)("name", {
9750
+ name: (0, import_mysql_core19.varchar)("name", {
9543
9751
  length: 191
9544
9752
  }).notNull(),
9545
- key: (0, import_mysql_core17.varchar)("key", {
9753
+ key: (0, import_mysql_core19.varchar)("key", {
9546
9754
  length: 191
9547
9755
  }),
9548
- type: (0, import_mysql_core17.varchar)("type", {
9756
+ type: (0, import_mysql_core19.varchar)("type", {
9549
9757
  length: 191
9550
9758
  }),
9551
- fields: (0, import_mysql_core17.json)("fields").$type().default({}),
9552
- createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
9759
+ fields: (0, import_mysql_core19.json)("fields").$type().default({}),
9760
+ createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
9553
9761
  mode: "date",
9554
9762
  fsp: 3
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()
9763
+ }).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9764
+ status: (0, import_mysql_core19.int)("status").default(0).notNull(),
9765
+ quantityAvailable: (0, import_mysql_core19.int)("quantityAvailable").default(-1).notNull()
9558
9766
  }, (table) => {
9559
9767
  return {
9560
- productId: (0, import_mysql_core17.primaryKey)({
9768
+ productId: (0, import_mysql_core19.primaryKey)({
9561
9769
  columns: [
9562
9770
  table.id
9563
9771
  ],
9564
9772
  name: "Product_id"
9565
9773
  }),
9566
- organizationIdIdx: (0, import_mysql_core17.index)("organizationId_idx").on(table.organizationId)
9774
+ organizationIdIdx: (0, import_mysql_core19.index)("organizationId_idx").on(table.organizationId)
9567
9775
  };
9568
9776
  });
9569
9777
  }
@@ -9573,7 +9781,7 @@ function getProductRelationsSchema(mysqlTable) {
9573
9781
  const price = getPriceSchema(mysqlTable);
9574
9782
  const merchantProduct = getMerchantProductSchema(mysqlTable);
9575
9783
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
9576
- return (0, import_drizzle_orm17.relations)(product, ({ one, many }) => ({
9784
+ return (0, import_drizzle_orm19.relations)(product, ({ one, many }) => ({
9577
9785
  price: one(price, {
9578
9786
  fields: [
9579
9787
  product.id
@@ -9602,35 +9810,35 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
9602
9810
  // src/lib/mysql/schemas/commerce/subscription.ts
9603
9811
  function getSubscriptionSchema(mysqlTable) {
9604
9812
  return mysqlTable("Subscription", {
9605
- id: (0, import_mysql_core18.varchar)("id", {
9813
+ id: (0, import_mysql_core20.varchar)("id", {
9606
9814
  length: 191
9607
9815
  }).notNull(),
9608
- organizationId: (0, import_mysql_core18.varchar)("organizationId", {
9816
+ organizationId: (0, import_mysql_core20.varchar)("organizationId", {
9609
9817
  length: 191
9610
9818
  }),
9611
- productId: (0, import_mysql_core18.varchar)("productId", {
9819
+ productId: (0, import_mysql_core20.varchar)("productId", {
9612
9820
  length: 191
9613
9821
  }).notNull(),
9614
- createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
9822
+ createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
9615
9823
  mode: "date",
9616
9824
  fsp: 3
9617
- }).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9618
- merchantSubscriptionId: (0, import_mysql_core18.varchar)("merchantSubscriptionId", {
9825
+ }).default(import_drizzle_orm20.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9826
+ merchantSubscriptionId: (0, import_mysql_core20.varchar)("merchantSubscriptionId", {
9619
9827
  length: 191
9620
9828
  }).notNull(),
9621
- status: (0, import_mysql_core18.varchar)("status", {
9829
+ status: (0, import_mysql_core20.varchar)("status", {
9622
9830
  length: 191
9623
- }).default("Valid").notNull(),
9624
- fields: (0, import_mysql_core18.json)("fields").$type().default({})
9831
+ }).default("active").notNull(),
9832
+ fields: (0, import_mysql_core20.json)("fields").$type().default({})
9625
9833
  }, (table) => {
9626
9834
  return {
9627
- subscriptionId: (0, import_mysql_core18.primaryKey)({
9835
+ subscriptionId: (0, import_mysql_core20.primaryKey)({
9628
9836
  columns: [
9629
9837
  table.id
9630
9838
  ],
9631
9839
  name: "Subscription_id"
9632
9840
  }),
9633
- organizationIdIdx: (0, import_mysql_core18.index)("organizationId_idx").on(table.organizationId)
9841
+ organizationIdIdx: (0, import_mysql_core20.index)("organizationId_idx").on(table.organizationId)
9634
9842
  };
9635
9843
  });
9636
9844
  }
@@ -9640,7 +9848,7 @@ function getSubscriptionRelationsSchema(mysqlTable) {
9640
9848
  const products = getProductSchema(mysqlTable);
9641
9849
  const organizations = getOrganizationsSchema(mysqlTable);
9642
9850
  const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable);
9643
- return (0, import_drizzle_orm18.relations)(subscriptions, ({ many, one }) => ({
9851
+ return (0, import_drizzle_orm20.relations)(subscriptions, ({ many, one }) => ({
9644
9852
  organization: one(organizations, {
9645
9853
  fields: [
9646
9854
  subscriptions.organizationId
@@ -9675,22 +9883,22 @@ __name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
9675
9883
  // src/lib/mysql/schemas/org/organizations.ts
9676
9884
  function getOrganizationsSchema(mysqlTable) {
9677
9885
  return mysqlTable("Organization", {
9678
- id: (0, import_mysql_core19.varchar)("id", {
9886
+ id: (0, import_mysql_core21.varchar)("id", {
9679
9887
  length: 255
9680
9888
  }).notNull().primaryKey(),
9681
- name: (0, import_mysql_core19.varchar)("name", {
9889
+ name: (0, import_mysql_core21.varchar)("name", {
9682
9890
  length: 255
9683
9891
  }),
9684
- fields: (0, import_mysql_core19.json)("fields").$type().default({}),
9685
- image: (0, import_mysql_core19.varchar)("image", {
9892
+ fields: (0, import_mysql_core21.json)("fields").$type().default({}),
9893
+ image: (0, import_mysql_core21.varchar)("image", {
9686
9894
  length: 255
9687
9895
  }),
9688
- createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
9896
+ createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
9689
9897
  mode: "date",
9690
9898
  fsp: 3
9691
- }).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`)
9899
+ }).default(import_drizzle_orm21.sql`CURRENT_TIMESTAMP(3)`)
9692
9900
  }, (organization) => ({
9693
- createdAtIdx: (0, import_mysql_core19.index)("created_at_idx").on(organization.createdAt)
9901
+ createdAtIdx: (0, import_mysql_core21.index)("created_at_idx").on(organization.createdAt)
9694
9902
  }));
9695
9903
  }
9696
9904
  __name(getOrganizationsSchema, "getOrganizationsSchema");
@@ -9699,47 +9907,123 @@ function getOrganizationsRelationsSchema(mysqlTable) {
9699
9907
  const purchases = getPurchaseSchema(mysqlTable);
9700
9908
  const subscriptions = getSubscriptionSchema(mysqlTable);
9701
9909
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9702
- return (0, import_drizzle_orm19.relations)(organizations, ({ many }) => ({
9910
+ return (0, import_drizzle_orm21.relations)(organizations, ({ many }) => ({
9703
9911
  purchases: many(purchases, {
9704
9912
  relationName: "organization"
9705
9913
  }),
9706
- subscriptions: many(subscriptions, {
9707
- relationName: "organization"
9914
+ subscriptions: many(subscriptions, {
9915
+ relationName: "organization"
9916
+ }),
9917
+ members: many(organizationMemberships, {
9918
+ relationName: "organization"
9919
+ })
9920
+ }));
9921
+ }
9922
+ __name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
9923
+
9924
+ // src/lib/mysql/schemas/org/organization-membership-roles.ts
9925
+ function getOrganizationMembershipRolesSchema(mysqlTable) {
9926
+ return mysqlTable("OrganizationMembershipRole", {
9927
+ organizationMembershipId: (0, import_mysql_core22.varchar)("organizationMembershipId", {
9928
+ length: 255
9929
+ }).notNull(),
9930
+ roleId: (0, import_mysql_core22.varchar)("roleId", {
9931
+ length: 255
9932
+ }).notNull(),
9933
+ active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
9934
+ organizationId: (0, import_mysql_core22.varchar)("organizationId", {
9935
+ length: 191
9936
+ }),
9937
+ createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
9938
+ mode: "date",
9939
+ fsp: 3
9940
+ }).defaultNow(),
9941
+ updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
9942
+ mode: "date",
9943
+ fsp: 3
9944
+ }).defaultNow(),
9945
+ deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
9946
+ mode: "date",
9947
+ fsp: 3
9948
+ })
9949
+ }, (ur) => ({
9950
+ pk: (0, import_mysql_core22.primaryKey)({
9951
+ columns: [
9952
+ ur.organizationMembershipId,
9953
+ ur.roleId
9954
+ ],
9955
+ name: "pk"
9956
+ }),
9957
+ orgMemberIdIdx: (0, import_mysql_core22.index)("orgMemberId_idx").on(ur.organizationMembershipId),
9958
+ roleIdIdx: (0, import_mysql_core22.index)("roleId_idx").on(ur.roleId),
9959
+ organizationIdIdx: (0, import_mysql_core22.index)("organizationId_idx").on(ur.organizationId)
9960
+ }));
9961
+ }
9962
+ __name(getOrganizationMembershipRolesSchema, "getOrganizationMembershipRolesSchema");
9963
+ function getOrganizationMembershipRolesRelationsSchema(mysqlTable) {
9964
+ const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
9965
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9966
+ const roles = getRolesSchema(mysqlTable);
9967
+ const organizations = getOrganizationsSchema(mysqlTable);
9968
+ return (0, import_drizzle_orm22.relations)(organizationMembershipRoles, ({ one }) => ({
9969
+ organizationMembership: one(organizationMemberships, {
9970
+ fields: [
9971
+ organizationMembershipRoles.organizationMembershipId
9972
+ ],
9973
+ references: [
9974
+ organizationMemberships.id
9975
+ ],
9976
+ relationName: "organizationMembership"
9977
+ }),
9978
+ role: one(roles, {
9979
+ fields: [
9980
+ organizationMembershipRoles.roleId
9981
+ ],
9982
+ references: [
9983
+ roles.id
9984
+ ],
9985
+ relationName: "role"
9708
9986
  }),
9709
- members: many(organizationMemberships, {
9987
+ organization: one(organizations, {
9988
+ fields: [
9989
+ organizationMembershipRoles.organizationId
9990
+ ],
9991
+ references: [
9992
+ organizations.id
9993
+ ],
9710
9994
  relationName: "organization"
9711
9995
  })
9712
9996
  }));
9713
9997
  }
9714
- __name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
9998
+ __name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
9715
9999
 
9716
10000
  // src/lib/mysql/schemas/org/organization-memberships.ts
9717
10001
  function getOrganizationMembershipsSchema(mysqlTable) {
9718
10002
  return mysqlTable("OrganizationMembership", {
9719
- id: (0, import_mysql_core20.varchar)("id", {
10003
+ id: (0, import_mysql_core23.varchar)("id", {
9720
10004
  length: 255
9721
10005
  }).notNull().primaryKey(),
9722
- organizationId: (0, import_mysql_core20.varchar)("organizationId", {
10006
+ organizationId: (0, import_mysql_core23.varchar)("organizationId", {
9723
10007
  length: 191
9724
10008
  }),
9725
- role: (0, import_mysql_core20.varchar)("role", {
10009
+ role: (0, import_mysql_core23.varchar)("role", {
9726
10010
  length: 191
9727
10011
  }).notNull().default("user"),
9728
- invitedById: (0, import_mysql_core20.varchar)("invitedById", {
10012
+ invitedById: (0, import_mysql_core23.varchar)("invitedById", {
9729
10013
  length: 255
9730
10014
  }).notNull(),
9731
- userId: (0, import_mysql_core20.varchar)("userId", {
10015
+ userId: (0, import_mysql_core23.varchar)("userId", {
9732
10016
  length: 255
9733
10017
  }).notNull(),
9734
- fields: (0, import_mysql_core20.json)("fields").$type().default({}),
9735
- createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
10018
+ fields: (0, import_mysql_core23.json)("fields").$type().default({}),
10019
+ createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
9736
10020
  mode: "date",
9737
10021
  fsp: 3
9738
- }).default(import_drizzle_orm20.sql`CURRENT_TIMESTAMP(3)`)
10022
+ }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`)
9739
10023
  }, (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)
10024
+ roleIdx: (0, import_mysql_core23.index)("role_idx").on(organizationMembership.role),
10025
+ createdAtIdx: (0, import_mysql_core23.index)("created_at_idx").on(organizationMembership.createdAt),
10026
+ organizationIdIdx: (0, import_mysql_core23.index)("organizationId_idx").on(organizationMembership.organizationId)
9743
10027
  }));
9744
10028
  }
9745
10029
  __name(getOrganizationMembershipsSchema, "getOrganizationMembershipsSchema");
@@ -9748,7 +10032,8 @@ function getOrganizationMembershipsRelationsSchema(mysqlTable) {
9748
10032
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
9749
10033
  const purchases = getPurchaseSchema(mysqlTable);
9750
10034
  const organizations = getOrganizationsSchema(mysqlTable);
9751
- return (0, import_drizzle_orm20.relations)(organizationMemberships, ({ one, many }) => ({
10035
+ const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
10036
+ return (0, import_drizzle_orm23.relations)(organizationMemberships, ({ one, many }) => ({
9752
10037
  user: one(users, {
9753
10038
  fields: [
9754
10039
  organizationMemberships.userId
@@ -9776,49 +10061,52 @@ function getOrganizationMembershipsRelationsSchema(mysqlTable) {
9776
10061
  organizations.id
9777
10062
  ],
9778
10063
  relationName: "organization"
10064
+ }),
10065
+ organizationMembershipRoles: many(organizationMembershipRoles, {
10066
+ relationName: "organizationMembership"
9779
10067
  })
9780
10068
  }));
9781
10069
  }
9782
10070
  __name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
9783
10071
 
9784
10072
  // 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");
10073
+ var import_drizzle_orm24 = require("drizzle-orm");
10074
+ var import_mysql_core25 = require("drizzle-orm/mysql-core");
9787
10075
 
9788
10076
  // src/lib/mysql/schemas/commerce/merchant-coupon.ts
9789
- var import_mysql_core21 = require("drizzle-orm/mysql-core");
10077
+ var import_mysql_core24 = require("drizzle-orm/mysql-core");
9790
10078
  function getMerchantCouponSchema(mysqlTable) {
9791
10079
  return mysqlTable("MerchantCoupon", {
9792
- id: (0, import_mysql_core21.varchar)("id", {
10080
+ id: (0, import_mysql_core24.varchar)("id", {
9793
10081
  length: 191
9794
10082
  }).notNull(),
9795
- identifier: (0, import_mysql_core21.varchar)("identifier", {
10083
+ identifier: (0, import_mysql_core24.varchar)("identifier", {
9796
10084
  length: 191
9797
10085
  }),
9798
- organizationId: (0, import_mysql_core21.varchar)("organizationId", {
10086
+ organizationId: (0, import_mysql_core24.varchar)("organizationId", {
9799
10087
  length: 191
9800
10088
  }),
9801
- status: (0, import_mysql_core21.int)("status").default(0).notNull(),
9802
- merchantAccountId: (0, import_mysql_core21.varchar)("merchantAccountId", {
10089
+ status: (0, import_mysql_core24.int)("status").default(0).notNull(),
10090
+ merchantAccountId: (0, import_mysql_core24.varchar)("merchantAccountId", {
9803
10091
  length: 191
9804
10092
  }).notNull(),
9805
- percentageDiscount: (0, import_mysql_core21.decimal)("percentageDiscount", {
10093
+ percentageDiscount: (0, import_mysql_core24.decimal)("percentageDiscount", {
9806
10094
  precision: 3,
9807
10095
  scale: 2
9808
10096
  }).notNull(),
9809
- type: (0, import_mysql_core21.varchar)("type", {
10097
+ type: (0, import_mysql_core24.varchar)("type", {
9810
10098
  length: 191
9811
10099
  })
9812
10100
  }, (table) => {
9813
10101
  return {
9814
- merchantCouponId: (0, import_mysql_core21.primaryKey)({
10102
+ merchantCouponId: (0, import_mysql_core24.primaryKey)({
9815
10103
  columns: [
9816
10104
  table.id
9817
10105
  ],
9818
10106
  name: "MerchantCoupon_id"
9819
10107
  }),
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)
10108
+ merchantCouponIdentifierKey: (0, import_mysql_core24.unique)("MerchantCoupon_identifier_key").on(table.identifier),
10109
+ organizationIdIdx: (0, import_mysql_core24.index)("organizationId_idx").on(table.organizationId)
9822
10110
  };
9823
10111
  });
9824
10112
  }
@@ -9827,49 +10115,49 @@ __name(getMerchantCouponSchema, "getMerchantCouponSchema");
9827
10115
  // src/lib/mysql/schemas/commerce/coupon.ts
9828
10116
  function getCouponSchema(mysqlTable) {
9829
10117
  return mysqlTable("Coupon", {
9830
- id: (0, import_mysql_core22.varchar)("id", {
10118
+ id: (0, import_mysql_core25.varchar)("id", {
9831
10119
  length: 191
9832
10120
  }).notNull(),
9833
- organizationId: (0, import_mysql_core22.varchar)("organizationId", {
10121
+ organizationId: (0, import_mysql_core25.varchar)("organizationId", {
9834
10122
  length: 191
9835
10123
  }),
9836
- code: (0, import_mysql_core22.varchar)("code", {
10124
+ code: (0, import_mysql_core25.varchar)("code", {
9837
10125
  length: 191
9838
10126
  }),
9839
- createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
10127
+ createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
9840
10128
  mode: "date",
9841
10129
  fsp: 3
9842
- }).default(import_drizzle_orm21.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9843
- expires: (0, import_mysql_core22.timestamp)("expires", {
10130
+ }).default(import_drizzle_orm24.sql`CURRENT_TIMESTAMP(3)`).notNull(),
10131
+ expires: (0, import_mysql_core25.timestamp)("expires", {
9844
10132
  mode: "date",
9845
10133
  fsp: 3
9846
10134
  }),
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", {
10135
+ fields: (0, import_mysql_core25.json)("fields").$type().default({}),
10136
+ maxUses: (0, import_mysql_core25.int)("maxUses").default(-1).notNull(),
10137
+ default: (0, import_mysql_core25.boolean)("default").default(false).notNull(),
10138
+ merchantCouponId: (0, import_mysql_core25.varchar)("merchantCouponId", {
9851
10139
  length: 191
9852
10140
  }),
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", {
10141
+ status: (0, import_mysql_core25.int)("status").default(0).notNull(),
10142
+ usedCount: (0, import_mysql_core25.int)("usedCount").default(0).notNull(),
10143
+ percentageDiscount: (0, import_mysql_core25.decimal)("percentageDiscount", {
9856
10144
  precision: 3,
9857
10145
  scale: 2
9858
10146
  }).notNull(),
9859
- restrictedToProductId: (0, import_mysql_core22.varchar)("restrictedToProductId", {
10147
+ restrictedToProductId: (0, import_mysql_core25.varchar)("restrictedToProductId", {
9860
10148
  length: 191
9861
10149
  })
9862
10150
  }, (table) => {
9863
10151
  return {
9864
- couponIdCodeIndex: (0, import_mysql_core22.index)("Coupon_id_code_index").on(table.id, table.code),
9865
- couponId: (0, import_mysql_core22.primaryKey)({
10152
+ couponIdCodeIndex: (0, import_mysql_core25.index)("Coupon_id_code_index").on(table.id, table.code),
10153
+ couponId: (0, import_mysql_core25.primaryKey)({
9866
10154
  columns: [
9867
10155
  table.id
9868
10156
  ],
9869
10157
  name: "Coupon_id"
9870
10158
  }),
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)
10159
+ couponCodeKey: (0, import_mysql_core25.unique)("Coupon_code_key").on(table.code),
10160
+ organizationIdIdx: (0, import_mysql_core25.index)("organizationId_idx").on(table.organizationId)
9873
10161
  };
9874
10162
  });
9875
10163
  }
@@ -9878,7 +10166,7 @@ function getCouponRelationsSchema(mysqlTable) {
9878
10166
  const purchase = getPurchaseSchema(mysqlTable);
9879
10167
  const coupon = getCouponSchema(mysqlTable);
9880
10168
  const merchantCoupon = getMerchantCouponSchema(mysqlTable);
9881
- return (0, import_drizzle_orm21.relations)(coupon, ({ many, one }) => ({
10169
+ return (0, import_drizzle_orm24.relations)(coupon, ({ many, one }) => ({
9882
10170
  redeemedBulkCouponPurchases: many(purchase, {
9883
10171
  relationName: "redeemedBulkCoupon"
9884
10172
  }),
@@ -9908,30 +10196,30 @@ function getCouponRelationsSchema(mysqlTable) {
9908
10196
  __name(getCouponRelationsSchema, "getCouponRelationsSchema");
9909
10197
 
9910
10198
  // src/lib/mysql/schemas/commerce/merchant-session.ts
9911
- var import_mysql_core23 = require("drizzle-orm/mysql-core");
10199
+ var import_mysql_core26 = require("drizzle-orm/mysql-core");
9912
10200
  function getMerchantSessionSchema(mysqlTable) {
9913
10201
  return mysqlTable("MerchantSession", {
9914
- id: (0, import_mysql_core23.varchar)("id", {
10202
+ id: (0, import_mysql_core26.varchar)("id", {
9915
10203
  length: 191
9916
10204
  }).notNull(),
9917
- organizationId: (0, import_mysql_core23.varchar)("organizationId", {
10205
+ organizationId: (0, import_mysql_core26.varchar)("organizationId", {
9918
10206
  length: 191
9919
10207
  }),
9920
- identifier: (0, import_mysql_core23.varchar)("identifier", {
10208
+ identifier: (0, import_mysql_core26.varchar)("identifier", {
9921
10209
  length: 191
9922
10210
  }).notNull(),
9923
- merchantAccountId: (0, import_mysql_core23.varchar)("merchantAccountId", {
10211
+ merchantAccountId: (0, import_mysql_core26.varchar)("merchantAccountId", {
9924
10212
  length: 191
9925
10213
  }).notNull()
9926
10214
  }, (table) => {
9927
10215
  return {
9928
- merchantSessionId: (0, import_mysql_core23.primaryKey)({
10216
+ merchantSessionId: (0, import_mysql_core26.primaryKey)({
9929
10217
  columns: [
9930
10218
  table.id
9931
10219
  ],
9932
10220
  name: "MerchantSession_id"
9933
10221
  }),
9934
- organizationIdIdx: (0, import_mysql_core23.index)("organizationId_idx").on(table.organizationId)
10222
+ organizationIdIdx: (0, import_mysql_core26.index)("organizationId_idx").on(table.organizationId)
9935
10223
  };
9936
10224
  });
9937
10225
  }
@@ -9940,75 +10228,75 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
9940
10228
  // src/lib/mysql/schemas/commerce/purchase.ts
9941
10229
  function getPurchaseSchema(mysqlTable) {
9942
10230
  return mysqlTable("Purchase", {
9943
- id: (0, import_mysql_core24.varchar)("id", {
10231
+ id: (0, import_mysql_core27.varchar)("id", {
9944
10232
  length: 191
9945
10233
  }).notNull(),
9946
- userId: (0, import_mysql_core24.varchar)("userId", {
10234
+ userId: (0, import_mysql_core27.varchar)("userId", {
9947
10235
  length: 191
9948
10236
  }),
9949
- purchasedByorganizationMembershipId: (0, import_mysql_core24.varchar)("organizationMembershipId", {
10237
+ purchasedByorganizationMembershipId: (0, import_mysql_core27.varchar)("organizationMembershipId", {
9950
10238
  length: 191
9951
10239
  }),
9952
- organizationId: (0, import_mysql_core24.varchar)("organizationId", {
10240
+ organizationId: (0, import_mysql_core27.varchar)("organizationId", {
9953
10241
  length: 191
9954
10242
  }),
9955
- createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
10243
+ createdAt: (0, import_mysql_core27.timestamp)("createdAt", {
9956
10244
  mode: "date",
9957
10245
  fsp: 3
9958
- }).default(import_drizzle_orm22.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9959
- totalAmount: (0, import_mysql_core24.decimal)("totalAmount", {
10246
+ }).default(import_drizzle_orm25.sql`CURRENT_TIMESTAMP(3)`).notNull(),
10247
+ totalAmount: (0, import_mysql_core27.decimal)("totalAmount", {
9960
10248
  precision: 65,
9961
10249
  scale: 30
9962
10250
  }).notNull(),
9963
- ipAddress: (0, import_mysql_core24.varchar)("ip_address", {
10251
+ ipAddress: (0, import_mysql_core27.varchar)("ip_address", {
9964
10252
  length: 191
9965
10253
  }),
9966
- city: (0, import_mysql_core24.varchar)("city", {
10254
+ city: (0, import_mysql_core27.varchar)("city", {
9967
10255
  length: 191
9968
10256
  }),
9969
- state: (0, import_mysql_core24.varchar)("state", {
10257
+ state: (0, import_mysql_core27.varchar)("state", {
9970
10258
  length: 191
9971
10259
  }),
9972
- country: (0, import_mysql_core24.varchar)("country", {
10260
+ country: (0, import_mysql_core27.varchar)("country", {
9973
10261
  length: 191
9974
10262
  }),
9975
- couponId: (0, import_mysql_core24.varchar)("couponId", {
10263
+ couponId: (0, import_mysql_core27.varchar)("couponId", {
9976
10264
  length: 191
9977
10265
  }),
9978
- productId: (0, import_mysql_core24.varchar)("productId", {
10266
+ productId: (0, import_mysql_core27.varchar)("productId", {
9979
10267
  length: 191
9980
10268
  }).notNull(),
9981
- merchantChargeId: (0, import_mysql_core24.varchar)("merchantChargeId", {
10269
+ merchantChargeId: (0, import_mysql_core27.varchar)("merchantChargeId", {
9982
10270
  length: 191
9983
10271
  }),
9984
- upgradedFromId: (0, import_mysql_core24.varchar)("upgradedFromId", {
10272
+ upgradedFromId: (0, import_mysql_core27.varchar)("upgradedFromId", {
9985
10273
  length: 191
9986
10274
  }),
9987
- status: (0, import_mysql_core24.varchar)("status", {
10275
+ status: (0, import_mysql_core27.varchar)("status", {
9988
10276
  length: 191
9989
10277
  }).default("Valid").notNull(),
9990
- bulkCouponId: (0, import_mysql_core24.varchar)("bulkCouponId", {
10278
+ bulkCouponId: (0, import_mysql_core27.varchar)("bulkCouponId", {
9991
10279
  length: 191
9992
10280
  }),
9993
- merchantSessionId: (0, import_mysql_core24.varchar)("merchantSessionId", {
10281
+ merchantSessionId: (0, import_mysql_core27.varchar)("merchantSessionId", {
9994
10282
  length: 191
9995
10283
  }),
9996
- redeemedBulkCouponId: (0, import_mysql_core24.varchar)("redeemedBulkCouponId", {
10284
+ redeemedBulkCouponId: (0, import_mysql_core27.varchar)("redeemedBulkCouponId", {
9997
10285
  length: 191
9998
10286
  }),
9999
- fields: (0, import_mysql_core24.json)("fields").$type().default({})
10287
+ fields: (0, import_mysql_core27.json)("fields").$type().default({})
10000
10288
  }, (table) => {
10001
10289
  return {
10002
- purchaseId: (0, import_mysql_core24.primaryKey)({
10290
+ purchaseId: (0, import_mysql_core27.primaryKey)({
10003
10291
  columns: [
10004
10292
  table.id
10005
10293
  ],
10006
10294
  name: "Purchase_id"
10007
10295
  }),
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)
10296
+ merchantChargeIdIdx: (0, import_mysql_core27.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
10297
+ purchaseUpgradedFromIdKey: (0, import_mysql_core27.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId),
10298
+ organizationIdIdx: (0, import_mysql_core27.index)("organizationId_idx").on(table.organizationId),
10299
+ organizationMembershipIdIdx: (0, import_mysql_core27.index)("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId)
10012
10300
  };
10013
10301
  });
10014
10302
  }
@@ -10022,7 +10310,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
10022
10310
  const coupons = getCouponSchema(mysqlTable);
10023
10311
  const organizations = getOrganizationsSchema(mysqlTable);
10024
10312
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10025
- return (0, import_drizzle_orm22.relations)(purchases, ({ many, one }) => ({
10313
+ return (0, import_drizzle_orm25.relations)(purchases, ({ many, one }) => ({
10026
10314
  redeemedBulkCoupon: one(coupons, {
10027
10315
  fields: [
10028
10316
  purchases.redeemedBulkCouponId
@@ -10100,41 +10388,41 @@ function getPurchaseRelationsSchema(mysqlTable) {
10100
10388
  __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
10101
10389
 
10102
10390
  // src/lib/mysql/schemas/communication/comment.ts
10103
- var import_drizzle_orm23 = require("drizzle-orm");
10104
- var import_mysql_core25 = require("drizzle-orm/mysql-core");
10391
+ var import_drizzle_orm26 = require("drizzle-orm");
10392
+ var import_mysql_core28 = require("drizzle-orm/mysql-core");
10105
10393
  function getCommentsSchema(mysqlTable) {
10106
10394
  return mysqlTable("Comment", {
10107
- id: (0, import_mysql_core25.varchar)("id", {
10395
+ id: (0, import_mysql_core28.varchar)("id", {
10108
10396
  length: 191
10109
10397
  }).notNull(),
10110
- userId: (0, import_mysql_core25.varchar)("userId", {
10398
+ userId: (0, import_mysql_core28.varchar)("userId", {
10111
10399
  length: 255
10112
10400
  }).notNull(),
10113
- organizationMembershipId: (0, import_mysql_core25.varchar)("organizationMembershipId", {
10401
+ organizationMembershipId: (0, import_mysql_core28.varchar)("organizationMembershipId", {
10114
10402
  length: 255
10115
10403
  }),
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", {
10404
+ context: (0, import_mysql_core28.json)("context").$type().default({}),
10405
+ text: (0, import_mysql_core28.text)("text").notNull(),
10406
+ createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
10119
10407
  mode: "date",
10120
10408
  fsp: 3
10121
- }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
10122
- updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
10409
+ }).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`),
10410
+ updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
10123
10411
  mode: "date",
10124
10412
  fsp: 3
10125
- }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
10126
- deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
10413
+ }).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`),
10414
+ deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
10127
10415
  mode: "date",
10128
10416
  fsp: 3
10129
10417
  })
10130
10418
  }, (crr) => ({
10131
- pk: (0, import_mysql_core25.primaryKey)({
10419
+ pk: (0, import_mysql_core28.primaryKey)({
10132
10420
  columns: [
10133
10421
  crr.id
10134
10422
  ]
10135
10423
  }),
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)
10424
+ crrUserIdIdKey: (0, import_mysql_core28.index)("crr_userIdId_idx").on(crr.userId),
10425
+ organizationMembershipIdIdx: (0, import_mysql_core28.index)("organizationMembershipId_idx").on(crr.organizationMembershipId)
10138
10426
  }));
10139
10427
  }
10140
10428
  __name(getCommentsSchema, "getCommentsSchema");
@@ -10142,7 +10430,7 @@ function getCommentRelationsSchema(mysqlTable) {
10142
10430
  const comment = getCommentsSchema(mysqlTable);
10143
10431
  const user = getUsersSchema(mysqlTable);
10144
10432
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10145
- return (0, import_drizzle_orm23.relations)(comment, ({ one }) => ({
10433
+ return (0, import_drizzle_orm26.relations)(comment, ({ one }) => ({
10146
10434
  user: one(user, {
10147
10435
  fields: [
10148
10436
  comment.userId
@@ -10166,67 +10454,67 @@ function getCommentRelationsSchema(mysqlTable) {
10166
10454
  __name(getCommentRelationsSchema, "getCommentRelationsSchema");
10167
10455
 
10168
10456
  // src/lib/mysql/schemas/communication/communication-preferences.ts
10169
- var import_drizzle_orm24 = require("drizzle-orm");
10170
- var import_mysql_core28 = require("drizzle-orm/mysql-core");
10457
+ var import_drizzle_orm27 = require("drizzle-orm");
10458
+ var import_mysql_core31 = require("drizzle-orm/mysql-core");
10171
10459
 
10172
10460
  // src/lib/mysql/schemas/communication/communication-channel.ts
10173
- var import_mysql_core26 = require("drizzle-orm/mysql-core");
10461
+ var import_mysql_core29 = require("drizzle-orm/mysql-core");
10174
10462
  function getCommunicationChannelSchema(mysqlTable) {
10175
10463
  return mysqlTable("CommunicationChannel", {
10176
- id: (0, import_mysql_core26.varchar)("id", {
10464
+ id: (0, import_mysql_core29.varchar)("id", {
10177
10465
  length: 255
10178
10466
  }).notNull().primaryKey(),
10179
- organizationId: (0, import_mysql_core26.varchar)("organizationId", {
10467
+ organizationId: (0, import_mysql_core29.varchar)("organizationId", {
10180
10468
  length: 191
10181
10469
  }),
10182
- name: (0, import_mysql_core26.varchar)("name", {
10470
+ name: (0, import_mysql_core29.varchar)("name", {
10183
10471
  length: 255
10184
10472
  }).notNull(),
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", {
10473
+ description: (0, import_mysql_core29.text)("description"),
10474
+ active: (0, import_mysql_core29.boolean)("active").notNull().default(true),
10475
+ createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
10188
10476
  mode: "date",
10189
10477
  fsp: 3
10190
10478
  }).defaultNow(),
10191
- updatedAt: (0, import_mysql_core26.timestamp)("updatedAt", {
10479
+ updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
10192
10480
  mode: "date",
10193
10481
  fsp: 3
10194
10482
  }).defaultNow(),
10195
- deletedAt: (0, import_mysql_core26.timestamp)("deletedAt", {
10483
+ deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
10196
10484
  mode: "date",
10197
10485
  fsp: 3
10198
10486
  })
10199
10487
  }, (cc) => ({
10200
- nameIdx: (0, import_mysql_core26.index)("name_idx").on(cc.name),
10201
- organizationIdIdx: (0, import_mysql_core26.index)("organizationId_idx").on(cc.organizationId)
10488
+ nameIdx: (0, import_mysql_core29.index)("name_idx").on(cc.name),
10489
+ organizationIdIdx: (0, import_mysql_core29.index)("organizationId_idx").on(cc.organizationId)
10202
10490
  }));
10203
10491
  }
10204
10492
  __name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
10205
10493
 
10206
10494
  // src/lib/mysql/schemas/communication/communication-preference-types.ts
10207
- var import_mysql_core27 = require("drizzle-orm/mysql-core");
10495
+ var import_mysql_core30 = require("drizzle-orm/mysql-core");
10208
10496
  function getCommunicationPreferenceTypesSchema(mysqlTable) {
10209
10497
  return mysqlTable("CommunicationPreferenceType", {
10210
- id: (0, import_mysql_core27.varchar)("id", {
10498
+ id: (0, import_mysql_core30.varchar)("id", {
10211
10499
  length: 255
10212
10500
  }).notNull().primaryKey(),
10213
- organizationId: (0, import_mysql_core27.varchar)("organizationId", {
10501
+ organizationId: (0, import_mysql_core30.varchar)("organizationId", {
10214
10502
  length: 191
10215
10503
  }),
10216
- name: (0, import_mysql_core27.varchar)("name", {
10504
+ name: (0, import_mysql_core30.varchar)("name", {
10217
10505
  length: 255
10218
10506
  }).notNull(),
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", {
10507
+ description: (0, import_mysql_core30.text)("description"),
10508
+ active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
10509
+ createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
10222
10510
  mode: "date",
10223
10511
  fsp: 3
10224
10512
  }).defaultNow(),
10225
- updatedAt: (0, import_mysql_core27.timestamp)("updatedAt", {
10513
+ updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
10226
10514
  mode: "date",
10227
10515
  fsp: 3
10228
10516
  }),
10229
- deletedAt: (0, import_mysql_core27.timestamp)("deletedAt", {
10517
+ deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
10230
10518
  mode: "date",
10231
10519
  fsp: 3
10232
10520
  })
@@ -10237,55 +10525,55 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
10237
10525
  // src/lib/mysql/schemas/communication/communication-preferences.ts
10238
10526
  function getCommunicationPreferencesSchema(mysqlTable) {
10239
10527
  return mysqlTable("CommunicationPreference", {
10240
- id: (0, import_mysql_core28.varchar)("id", {
10528
+ id: (0, import_mysql_core31.varchar)("id", {
10241
10529
  length: 255
10242
10530
  }).notNull().primaryKey(),
10243
- organizationId: (0, import_mysql_core28.varchar)("organizationId", {
10531
+ organizationId: (0, import_mysql_core31.varchar)("organizationId", {
10244
10532
  length: 191
10245
10533
  }),
10246
- userId: (0, import_mysql_core28.varchar)("userId", {
10534
+ userId: (0, import_mysql_core31.varchar)("userId", {
10247
10535
  length: 255
10248
10536
  }).notNull(),
10249
- organizationMembershipId: (0, import_mysql_core28.varchar)("organizationMembershipId", {
10537
+ organizationMembershipId: (0, import_mysql_core31.varchar)("organizationMembershipId", {
10250
10538
  length: 255
10251
10539
  }),
10252
- channelId: (0, import_mysql_core28.varchar)("channelId", {
10540
+ channelId: (0, import_mysql_core31.varchar)("channelId", {
10253
10541
  length: 255
10254
10542
  }).notNull(),
10255
- preferenceLevel: (0, import_mysql_core28.mysqlEnum)("preferenceLevel", [
10543
+ preferenceLevel: (0, import_mysql_core31.mysqlEnum)("preferenceLevel", [
10256
10544
  "low",
10257
10545
  "medium",
10258
10546
  "high"
10259
10547
  ]).notNull().default("medium"),
10260
- preferenceTypeId: (0, import_mysql_core28.varchar)("preferenceTypeId", {
10548
+ preferenceTypeId: (0, import_mysql_core31.varchar)("preferenceTypeId", {
10261
10549
  length: 255
10262
10550
  }).notNull(),
10263
- active: (0, import_mysql_core28.boolean)("active").notNull().default(true),
10264
- createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
10551
+ active: (0, import_mysql_core31.boolean)("active").notNull().default(true),
10552
+ createdAt: (0, import_mysql_core31.timestamp)("createdAt", {
10265
10553
  mode: "date",
10266
10554
  fsp: 3
10267
10555
  }).defaultNow(),
10268
- optInAt: (0, import_mysql_core28.timestamp)("optInAt", {
10556
+ optInAt: (0, import_mysql_core31.timestamp)("optInAt", {
10269
10557
  mode: "date",
10270
10558
  fsp: 3
10271
10559
  }),
10272
- optOutAt: (0, import_mysql_core28.timestamp)("optOutAt", {
10560
+ optOutAt: (0, import_mysql_core31.timestamp)("optOutAt", {
10273
10561
  mode: "date",
10274
10562
  fsp: 3
10275
10563
  }),
10276
- updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
10564
+ updatedAt: (0, import_mysql_core31.timestamp)("updatedAt", {
10277
10565
  mode: "date",
10278
10566
  fsp: 3
10279
10567
  }).defaultNow(),
10280
- deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
10568
+ deletedAt: (0, import_mysql_core31.timestamp)("deletedAt", {
10281
10569
  mode: "date",
10282
10570
  fsp: 3
10283
10571
  })
10284
10572
  }, (cp) => ({
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)
10573
+ userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(cp.userId),
10574
+ preferenceTypeIdx: (0, import_mysql_core31.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
10575
+ channelIdIdx: (0, import_mysql_core31.index)("channelId_idx").on(cp.channelId),
10576
+ organizationMembershipIdIdx: (0, import_mysql_core31.index)("organizationMembershipId_idx").on(cp.organizationMembershipId)
10289
10577
  }));
10290
10578
  }
10291
10579
  __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
@@ -10295,7 +10583,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
10295
10583
  const communicationChannel = getCommunicationChannelSchema(mysqlTable);
10296
10584
  const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
10297
10585
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10298
- return (0, import_drizzle_orm24.relations)(communicationPreferences, ({ one }) => ({
10586
+ return (0, import_drizzle_orm27.relations)(communicationPreferences, ({ one }) => ({
10299
10587
  user: one(users, {
10300
10588
  fields: [
10301
10589
  communicationPreferences.userId
@@ -10336,80 +10624,126 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
10336
10624
  }
10337
10625
  __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
10338
10626
 
10627
+ // src/lib/mysql/schemas/auth/profiles.ts
10628
+ var import_drizzle_orm28 = require("drizzle-orm");
10629
+ var import_mysql_core32 = require("drizzle-orm/mysql-core");
10630
+ function getProfilesSchema(mysqlTable) {
10631
+ return mysqlTable("Profile", {
10632
+ id: (0, import_mysql_core32.varchar)("id", {
10633
+ length: 255
10634
+ }).notNull().primaryKey(),
10635
+ userId: (0, import_mysql_core32.varchar)("userId", {
10636
+ length: 255
10637
+ }).notNull(),
10638
+ type: (0, import_mysql_core32.varchar)("type", {
10639
+ length: 255
10640
+ }).notNull(),
10641
+ fields: (0, import_mysql_core32.json)("fields").$type().default({}),
10642
+ createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
10643
+ mode: "date",
10644
+ fsp: 3
10645
+ }).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`),
10646
+ updatedAt: (0, import_mysql_core32.timestamp)("updatedAt", {
10647
+ mode: "date",
10648
+ fsp: 3
10649
+ }).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`)
10650
+ }, (profile) => ({
10651
+ userIdIdx: (0, import_mysql_core32.index)("userId_idx").on(profile.userId),
10652
+ uniqueUserType: (0, import_mysql_core32.uniqueIndex)("unique_user_type_idx").on(profile.userId, profile.type)
10653
+ }));
10654
+ }
10655
+ __name(getProfilesSchema, "getProfilesSchema");
10656
+ function getProfilesRelationsSchema(mysqlTable) {
10657
+ const profiles = getProfilesSchema(mysqlTable);
10658
+ const users = getUsersSchema(mysqlTable);
10659
+ return (0, import_drizzle_orm28.relations)(profiles, ({ one }) => ({
10660
+ user: one(users, {
10661
+ fields: [
10662
+ profiles.userId
10663
+ ],
10664
+ references: [
10665
+ users.id
10666
+ ],
10667
+ relationName: "profiles"
10668
+ })
10669
+ }));
10670
+ }
10671
+ __name(getProfilesRelationsSchema, "getProfilesRelationsSchema");
10672
+
10339
10673
  // src/lib/mysql/schemas/auth/user-permissions.ts
10340
- var import_drizzle_orm26 = require("drizzle-orm");
10341
- var import_mysql_core30 = require("drizzle-orm/mysql-core");
10674
+ var import_drizzle_orm30 = require("drizzle-orm");
10675
+ var import_mysql_core34 = require("drizzle-orm/mysql-core");
10342
10676
 
10343
10677
  // src/lib/mysql/schemas/auth/permissions.ts
10344
- var import_drizzle_orm25 = require("drizzle-orm");
10345
- var import_mysql_core29 = require("drizzle-orm/mysql-core");
10678
+ var import_drizzle_orm29 = require("drizzle-orm");
10679
+ var import_mysql_core33 = require("drizzle-orm/mysql-core");
10346
10680
  function getPermissionsSchema(mysqlTable) {
10347
10681
  return mysqlTable("Permission", {
10348
- id: (0, import_mysql_core29.varchar)("id", {
10682
+ id: (0, import_mysql_core33.varchar)("id", {
10349
10683
  length: 255
10350
10684
  }).notNull().primaryKey(),
10351
- name: (0, import_mysql_core29.varchar)("name", {
10685
+ name: (0, import_mysql_core33.varchar)("name", {
10352
10686
  length: 255
10353
10687
  }).notNull().unique(),
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", {
10688
+ description: (0, import_mysql_core33.text)("description"),
10689
+ active: (0, import_mysql_core33.boolean)("active").notNull().default(true),
10690
+ createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
10357
10691
  mode: "date",
10358
10692
  fsp: 3
10359
10693
  }).defaultNow(),
10360
- updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
10694
+ updatedAt: (0, import_mysql_core33.timestamp)("updatedAt", {
10361
10695
  mode: "date",
10362
10696
  fsp: 3
10363
10697
  }).defaultNow(),
10364
- deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
10698
+ deletedAt: (0, import_mysql_core33.timestamp)("deletedAt", {
10365
10699
  mode: "date",
10366
10700
  fsp: 3
10367
10701
  })
10368
10702
  }, (permission) => ({
10369
- nameIdx: (0, import_mysql_core29.index)("name_idx").on(permission.name)
10703
+ nameIdx: (0, import_mysql_core33.index)("name_idx").on(permission.name)
10370
10704
  }));
10371
10705
  }
10372
10706
  __name(getPermissionsSchema, "getPermissionsSchema");
10373
10707
  function getPermissionsRelationsSchema(mysqlTable) {
10374
- return (0, import_drizzle_orm25.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
10708
+ return (0, import_drizzle_orm29.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
10375
10709
  }
10376
10710
  __name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
10377
10711
 
10378
10712
  // src/lib/mysql/schemas/auth/user-permissions.ts
10379
10713
  function getUserPermissionsSchema(mysqlTable) {
10380
10714
  return mysqlTable("UserPermission", {
10381
- userId: (0, import_mysql_core30.varchar)("userId", {
10715
+ userId: (0, import_mysql_core34.varchar)("userId", {
10382
10716
  length: 255
10383
10717
  }).notNull(),
10384
- organizationId: (0, import_mysql_core30.varchar)("organizationId", {
10718
+ organizationId: (0, import_mysql_core34.varchar)("organizationId", {
10385
10719
  length: 191
10386
10720
  }),
10387
- permissionId: (0, import_mysql_core30.varchar)("permissionId", {
10721
+ permissionId: (0, import_mysql_core34.varchar)("permissionId", {
10388
10722
  length: 255
10389
10723
  }).notNull(),
10390
- active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
10391
- createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
10724
+ active: (0, import_mysql_core34.boolean)("active").notNull().default(true),
10725
+ createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
10392
10726
  mode: "date",
10393
10727
  fsp: 3
10394
10728
  }).defaultNow(),
10395
- updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
10729
+ updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
10396
10730
  mode: "date",
10397
10731
  fsp: 3
10398
10732
  }).defaultNow(),
10399
- deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
10733
+ deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
10400
10734
  mode: "date",
10401
10735
  fsp: 3
10402
10736
  })
10403
10737
  }, (up) => ({
10404
- pk: (0, import_mysql_core30.primaryKey)({
10738
+ pk: (0, import_mysql_core34.primaryKey)({
10405
10739
  columns: [
10406
10740
  up.userId,
10407
10741
  up.permissionId
10408
10742
  ]
10409
10743
  }),
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)
10744
+ userIdIdx: (0, import_mysql_core34.index)("userId_idx").on(up.userId),
10745
+ permissionIdIdx: (0, import_mysql_core34.index)("permissionId_idx").on(up.permissionId),
10746
+ organizationIdIdx: (0, import_mysql_core34.index)("organizationId_idx").on(up.organizationId)
10413
10747
  }));
10414
10748
  }
10415
10749
  __name(getUserPermissionsSchema, "getUserPermissionsSchema");
@@ -10417,7 +10751,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
10417
10751
  const userPermissions = getUserPermissionsSchema(mysqlTable);
10418
10752
  const users = getUsersSchema(mysqlTable);
10419
10753
  const permissions = getPermissionsSchema(mysqlTable);
10420
- return (0, import_drizzle_orm26.relations)(userPermissions, ({ one }) => ({
10754
+ return (0, import_drizzle_orm30.relations)(userPermissions, ({ one }) => ({
10421
10755
  user: one(users, {
10422
10756
  fields: [
10423
10757
  userPermissions.userId
@@ -10434,220 +10768,107 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
10434
10768
  references: [
10435
10769
  permissions.id
10436
10770
  ],
10437
- relationName: "permission"
10438
- })
10439
- }));
10440
- }
10441
- __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
10442
-
10443
- // src/lib/mysql/schemas/auth/user-prefs.ts
10444
- var import_drizzle_orm27 = require("drizzle-orm");
10445
- var import_mysql_core31 = require("drizzle-orm/mysql-core");
10446
- function getUserPrefsSchema(mysqlTable) {
10447
- return mysqlTable("UserPrefs", {
10448
- id: (0, import_mysql_core31.varchar)("id", {
10449
- length: 191
10450
- }).notNull(),
10451
- organizationId: (0, import_mysql_core31.varchar)("organizationId", {
10452
- length: 191
10453
- }),
10454
- type: (0, import_mysql_core31.varchar)("type", {
10455
- length: 191
10456
- }).default("Global").notNull(),
10457
- userId: (0, import_mysql_core31.varchar)("userId", {
10458
- length: 255
10459
- }).notNull(),
10460
- fields: (0, import_mysql_core31.json)("fields").$type().default({}),
10461
- createdAt: (0, import_mysql_core31.timestamp)("createdAt", {
10462
- mode: "date",
10463
- fsp: 3
10464
- }).default(import_drizzle_orm27.sql`CURRENT_TIMESTAMP(3)`),
10465
- updatedAt: (0, import_mysql_core31.timestamp)("updatedAt", {
10466
- mode: "date",
10467
- fsp: 3
10468
- }).default(import_drizzle_orm27.sql`CURRENT_TIMESTAMP(3)`),
10469
- deletedAt: (0, import_mysql_core31.timestamp)("deletedAt", {
10470
- mode: "date",
10471
- fsp: 3
10472
- })
10473
- }, (crr) => ({
10474
- pk: (0, import_mysql_core31.primaryKey)({
10475
- columns: [
10476
- crr.id
10477
- ]
10478
- }),
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)
10481
- }));
10482
- }
10483
- __name(getUserPrefsSchema, "getUserPrefsSchema");
10484
- function getUserPrefsRelationsSchema(mysqlTable) {
10485
- const userPrefs = getUserPrefsSchema(mysqlTable);
10486
- const user = getUsersSchema(mysqlTable);
10487
- return (0, import_drizzle_orm27.relations)(userPrefs, ({ one }) => ({
10488
- user: one(user, {
10489
- fields: [
10490
- userPrefs.userId
10491
- ],
10492
- references: [
10493
- user.id
10494
- ],
10495
- relationName: "user"
10496
- })
10497
- }));
10498
- }
10499
- __name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
10500
-
10501
- // src/lib/mysql/schemas/auth/user-roles.ts
10502
- var import_drizzle_orm29 = require("drizzle-orm");
10503
- var import_mysql_core33 = require("drizzle-orm/mysql-core");
10504
-
10505
- // src/lib/mysql/schemas/auth/roles.ts
10506
- var import_drizzle_orm28 = require("drizzle-orm");
10507
- var import_mysql_core32 = require("drizzle-orm/mysql-core");
10508
- function getRolesSchema(mysqlTable) {
10509
- return mysqlTable("Role", {
10510
- id: (0, import_mysql_core32.varchar)("id", {
10511
- length: 255
10512
- }).notNull().primaryKey(),
10513
- organizationId: (0, import_mysql_core32.varchar)("organizationId", {
10514
- length: 191
10515
- }),
10516
- name: (0, import_mysql_core32.varchar)("name", {
10517
- length: 255
10518
- }).notNull().unique(),
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", {
10522
- mode: "date",
10523
- fsp: 3
10524
- }).defaultNow(),
10525
- updatedAt: (0, import_mysql_core32.timestamp)("updatedAt", {
10526
- mode: "date",
10527
- fsp: 3
10528
- }).defaultNow(),
10529
- deletedAt: (0, import_mysql_core32.timestamp)("deletedAt", {
10530
- mode: "date",
10531
- fsp: 3
10532
- })
10533
- }, (role) => ({
10534
- nameIdx: (0, import_mysql_core32.index)("name_idx").on(role.name),
10535
- organizationIdIdx: (0, import_mysql_core32.index)("organizationId_idx").on(role.organizationId)
10536
- }));
10537
- }
10538
- __name(getRolesSchema, "getRolesSchema");
10539
- function getRolesRelationsSchema(mysqlTable) {
10540
- const roles = getRolesSchema(mysqlTable);
10541
- const userRoles = getUserRolesSchema(mysqlTable);
10542
- return (0, import_drizzle_orm28.relations)(roles, ({ many }) => ({
10543
- userRoles: many(userRoles, {
10544
- relationName: "role"
10771
+ relationName: "permission"
10545
10772
  })
10546
10773
  }));
10547
10774
  }
10548
- __name(getRolesRelationsSchema, "getRolesRelationsSchema");
10775
+ __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
10549
10776
 
10550
- // src/lib/mysql/schemas/auth/user-roles.ts
10551
- function getUserRolesSchema(mysqlTable) {
10552
- return mysqlTable("UserRole", {
10553
- userId: (0, import_mysql_core33.varchar)("userId", {
10554
- length: 255
10555
- }).notNull(),
10556
- roleId: (0, import_mysql_core33.varchar)("roleId", {
10557
- length: 255
10777
+ // src/lib/mysql/schemas/auth/user-prefs.ts
10778
+ var import_drizzle_orm31 = require("drizzle-orm");
10779
+ var import_mysql_core35 = require("drizzle-orm/mysql-core");
10780
+ function getUserPrefsSchema(mysqlTable) {
10781
+ return mysqlTable("UserPrefs", {
10782
+ id: (0, import_mysql_core35.varchar)("id", {
10783
+ length: 191
10558
10784
  }).notNull(),
10559
- active: (0, import_mysql_core33.boolean)("active").notNull().default(true),
10560
- organizationId: (0, import_mysql_core33.varchar)("organizationId", {
10785
+ organizationId: (0, import_mysql_core35.varchar)("organizationId", {
10561
10786
  length: 191
10562
10787
  }),
10563
- createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
10788
+ type: (0, import_mysql_core35.varchar)("type", {
10789
+ length: 191
10790
+ }).default("Global").notNull(),
10791
+ userId: (0, import_mysql_core35.varchar)("userId", {
10792
+ length: 255
10793
+ }).notNull(),
10794
+ fields: (0, import_mysql_core35.json)("fields").$type().default({}),
10795
+ createdAt: (0, import_mysql_core35.timestamp)("createdAt", {
10564
10796
  mode: "date",
10565
10797
  fsp: 3
10566
- }).defaultNow(),
10567
- updatedAt: (0, import_mysql_core33.timestamp)("updatedAt", {
10798
+ }).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`),
10799
+ updatedAt: (0, import_mysql_core35.timestamp)("updatedAt", {
10568
10800
  mode: "date",
10569
10801
  fsp: 3
10570
- }).defaultNow(),
10571
- deletedAt: (0, import_mysql_core33.timestamp)("deletedAt", {
10802
+ }).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`),
10803
+ deletedAt: (0, import_mysql_core35.timestamp)("deletedAt", {
10572
10804
  mode: "date",
10573
10805
  fsp: 3
10574
10806
  })
10575
- }, (ur) => ({
10576
- pk: (0, import_mysql_core33.primaryKey)({
10807
+ }, (crr) => ({
10808
+ pk: (0, import_mysql_core35.primaryKey)({
10577
10809
  columns: [
10578
- ur.userId,
10579
- ur.roleId
10810
+ crr.id
10580
10811
  ]
10581
10812
  }),
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)
10813
+ crrUserIdIdKey: (0, import_mysql_core35.index)("crr_userIdId_idx").on(crr.userId),
10814
+ organizationIdIdx: (0, import_mysql_core35.index)("organizationId_idx").on(crr.organizationId)
10585
10815
  }));
10586
10816
  }
10587
- __name(getUserRolesSchema, "getUserRolesSchema");
10588
- function getUserRolesRelationsSchema(mysqlTable) {
10589
- const userRoles = getUserRolesSchema(mysqlTable);
10590
- const users = getUsersSchema(mysqlTable);
10591
- const roles = getRolesSchema(mysqlTable);
10592
- return (0, import_drizzle_orm29.relations)(userRoles, ({ one }) => ({
10593
- user: one(users, {
10817
+ __name(getUserPrefsSchema, "getUserPrefsSchema");
10818
+ function getUserPrefsRelationsSchema(mysqlTable) {
10819
+ const userPrefs = getUserPrefsSchema(mysqlTable);
10820
+ const user = getUsersSchema(mysqlTable);
10821
+ return (0, import_drizzle_orm31.relations)(userPrefs, ({ one }) => ({
10822
+ user: one(user, {
10594
10823
  fields: [
10595
- userRoles.userId
10824
+ userPrefs.userId
10596
10825
  ],
10597
10826
  references: [
10598
- users.id
10827
+ user.id
10599
10828
  ],
10600
10829
  relationName: "user"
10601
- }),
10602
- role: one(roles, {
10603
- fields: [
10604
- userRoles.roleId
10605
- ],
10606
- references: [
10607
- roles.id
10608
- ],
10609
- relationName: "role"
10610
10830
  })
10611
10831
  }));
10612
10832
  }
10613
- __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
10833
+ __name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
10614
10834
 
10615
10835
  // src/lib/mysql/schemas/auth/users.ts
10616
10836
  function getUsersSchema(mysqlTable) {
10617
10837
  return mysqlTable("User", {
10618
- id: (0, import_mysql_core34.varchar)("id", {
10838
+ id: (0, import_mysql_core36.varchar)("id", {
10619
10839
  length: 255
10620
10840
  }).notNull().primaryKey(),
10621
- name: (0, import_mysql_core34.varchar)("name", {
10841
+ name: (0, import_mysql_core36.varchar)("name", {
10622
10842
  length: 255
10623
10843
  }),
10624
- role: (0, import_mysql_core34.varchar)("role", {
10844
+ role: (0, import_mysql_core36.varchar)("role", {
10625
10845
  length: 191
10626
10846
  }).notNull().default("user"),
10627
- email: (0, import_mysql_core34.varchar)("email", {
10847
+ email: (0, import_mysql_core36.varchar)("email", {
10628
10848
  length: 255
10629
10849
  }).notNull().unique(),
10630
- fields: (0, import_mysql_core34.json)("fields").$type().default({}),
10631
- emailVerified: (0, import_mysql_core34.timestamp)("emailVerified", {
10850
+ fields: (0, import_mysql_core36.json)("fields").$type().default({}),
10851
+ emailVerified: (0, import_mysql_core36.timestamp)("emailVerified", {
10632
10852
  mode: "date",
10633
10853
  fsp: 3
10634
10854
  }),
10635
- image: (0, import_mysql_core34.varchar)("image", {
10855
+ image: (0, import_mysql_core36.varchar)("image", {
10636
10856
  length: 255
10637
10857
  }),
10638
- createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
10858
+ createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
10639
10859
  mode: "date",
10640
10860
  fsp: 3
10641
- }).default(import_drizzle_orm30.sql`CURRENT_TIMESTAMP(3)`)
10861
+ }).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`)
10642
10862
  }, (user) => ({
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)
10863
+ emailIdx: (0, import_mysql_core36.index)("email_idx").on(user.email),
10864
+ roleIdx: (0, import_mysql_core36.index)("role_idx").on(user.role),
10865
+ createdAtIdx: (0, import_mysql_core36.index)("created_at_idx").on(user.createdAt)
10646
10866
  }));
10647
10867
  }
10648
10868
  __name(getUsersSchema, "getUsersSchema");
10649
10869
  function getUsersRelationsSchema(mysqlTable) {
10650
10870
  const users = getUsersSchema(mysqlTable);
10871
+ const profiles = getProfilesSchema(mysqlTable);
10651
10872
  const accounts = getAccountsSchema(mysqlTable);
10652
10873
  const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
10653
10874
  const userRoles = getUserRolesSchema(mysqlTable);
@@ -10658,7 +10879,10 @@ function getUsersRelationsSchema(mysqlTable) {
10658
10879
  const comments = getCommentsSchema(mysqlTable);
10659
10880
  const userPrefs = getUserPrefsSchema(mysqlTable);
10660
10881
  const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
10661
- return (0, import_drizzle_orm30.relations)(users, ({ many }) => ({
10882
+ return (0, import_drizzle_orm32.relations)(users, ({ many, one }) => ({
10883
+ profiles: many(profiles, {
10884
+ relationName: "profiles"
10885
+ }),
10662
10886
  accounts: many(accounts, {
10663
10887
  relationName: "user"
10664
10888
  }),
@@ -10696,49 +10920,49 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
10696
10920
  // src/lib/mysql/schemas/auth/accounts.ts
10697
10921
  function getAccountsSchema(mysqlTable) {
10698
10922
  return mysqlTable("Account", {
10699
- userId: (0, import_mysql_core35.varchar)("userId", {
10923
+ userId: (0, import_mysql_core37.varchar)("userId", {
10700
10924
  length: 255
10701
10925
  }).notNull(),
10702
- type: (0, import_mysql_core35.varchar)("type", {
10926
+ type: (0, import_mysql_core37.varchar)("type", {
10703
10927
  length: 255
10704
10928
  }).$type().notNull(),
10705
- provider: (0, import_mysql_core35.varchar)("provider", {
10929
+ provider: (0, import_mysql_core37.varchar)("provider", {
10706
10930
  length: 255
10707
10931
  }).notNull(),
10708
- providerAccountId: (0, import_mysql_core35.varchar)("providerAccountId", {
10932
+ providerAccountId: (0, import_mysql_core37.varchar)("providerAccountId", {
10709
10933
  length: 255
10710
10934
  }).notNull(),
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", {
10935
+ refresh_token: (0, import_mysql_core37.text)("refresh_token"),
10936
+ access_token: (0, import_mysql_core37.text)("access_token"),
10937
+ oauth_token: (0, import_mysql_core37.text)("oauth_token"),
10938
+ oauth_token_secret: (0, import_mysql_core37.text)("oauth_token_secret"),
10939
+ expires_at: (0, import_mysql_core37.int)("expires_at"),
10940
+ token_type: (0, import_mysql_core37.varchar)("token_type", {
10717
10941
  length: 255
10718
10942
  }),
10719
- scope: (0, import_mysql_core35.varchar)("scope", {
10943
+ scope: (0, import_mysql_core37.varchar)("scope", {
10720
10944
  length: 255
10721
10945
  }),
10722
- id_token: (0, import_mysql_core35.text)("id_token"),
10723
- session_state: (0, import_mysql_core35.varchar)("session_state", {
10946
+ id_token: (0, import_mysql_core37.text)("id_token"),
10947
+ session_state: (0, import_mysql_core37.varchar)("session_state", {
10724
10948
  length: 255
10725
10949
  }),
10726
- refresh_token_expires_in: (0, import_mysql_core35.int)("refresh_token_expires_in")
10950
+ refresh_token_expires_in: (0, import_mysql_core37.int)("refresh_token_expires_in")
10727
10951
  }, (account) => ({
10728
- pk: (0, import_mysql_core35.primaryKey)({
10952
+ pk: (0, import_mysql_core37.primaryKey)({
10729
10953
  columns: [
10730
10954
  account.provider,
10731
10955
  account.providerAccountId
10732
10956
  ]
10733
10957
  }),
10734
- userIdIdx: (0, import_mysql_core35.index)("userId_idx").on(account.userId)
10958
+ userIdIdx: (0, import_mysql_core37.index)("userId_idx").on(account.userId)
10735
10959
  }));
10736
10960
  }
10737
10961
  __name(getAccountsSchema, "getAccountsSchema");
10738
10962
  function getAccountsRelationsSchema(mysqlTable) {
10739
10963
  const accounts = getAccountsSchema(mysqlTable);
10740
10964
  const users = getUsersSchema(mysqlTable);
10741
- return (0, import_drizzle_orm31.relations)(accounts, ({ one }) => ({
10965
+ return (0, import_drizzle_orm33.relations)(accounts, ({ one }) => ({
10742
10966
  user: one(users, {
10743
10967
  fields: [
10744
10968
  accounts.userId
@@ -10753,37 +10977,37 @@ function getAccountsRelationsSchema(mysqlTable) {
10753
10977
  __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
10754
10978
 
10755
10979
  // src/lib/mysql/schemas/auth/device-access-token.ts
10756
- var import_drizzle_orm32 = require("drizzle-orm");
10757
- var import_mysql_core36 = require("drizzle-orm/mysql-core");
10980
+ var import_drizzle_orm34 = require("drizzle-orm");
10981
+ var import_mysql_core38 = require("drizzle-orm/mysql-core");
10758
10982
  function getDeviceAccessTokenSchema(mysqlTable) {
10759
10983
  return mysqlTable("DeviceAccessToken", {
10760
- token: (0, import_mysql_core36.varchar)("token", {
10984
+ token: (0, import_mysql_core38.varchar)("token", {
10761
10985
  length: 191
10762
10986
  }).notNull(),
10763
- userId: (0, import_mysql_core36.varchar)("userId", {
10987
+ userId: (0, import_mysql_core38.varchar)("userId", {
10764
10988
  length: 191
10765
10989
  }).notNull(),
10766
- organizationMembershipId: (0, import_mysql_core36.varchar)("organizationMembershipId", {
10990
+ organizationMembershipId: (0, import_mysql_core38.varchar)("organizationMembershipId", {
10767
10991
  length: 191
10768
10992
  }),
10769
- createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
10993
+ createdAt: (0, import_mysql_core38.timestamp)("createdAt", {
10770
10994
  mode: "date",
10771
10995
  fsp: 3
10772
- }).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`)
10996
+ }).default(import_drizzle_orm34.sql`CURRENT_TIMESTAMP(3)`)
10773
10997
  }, (crr) => ({
10774
- pk: (0, import_mysql_core36.primaryKey)({
10998
+ pk: (0, import_mysql_core38.primaryKey)({
10775
10999
  columns: [
10776
11000
  crr.token
10777
11001
  ]
10778
11002
  }),
10779
- userIdIdx: (0, import_mysql_core36.index)("userId_idx").on(crr.userId)
11003
+ userIdIdx: (0, import_mysql_core38.index)("userId_idx").on(crr.userId)
10780
11004
  }));
10781
11005
  }
10782
11006
  __name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
10783
11007
  function getDeviceAccessTokenRelationsSchema(mysqlTable) {
10784
11008
  const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
10785
11009
  const user = getUsersSchema(mysqlTable);
10786
- return (0, import_drizzle_orm32.relations)(deviceAccessToken, ({ one }) => ({
11010
+ return (0, import_drizzle_orm34.relations)(deviceAccessToken, ({ one }) => ({
10787
11011
  verifiedBy: one(user, {
10788
11012
  fields: [
10789
11013
  deviceAccessToken.userId
@@ -10798,31 +11022,31 @@ function getDeviceAccessTokenRelationsSchema(mysqlTable) {
10798
11022
  __name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
10799
11023
 
10800
11024
  // src/lib/mysql/schemas/auth/device-verification.ts
10801
- var import_drizzle_orm33 = require("drizzle-orm");
10802
- var import_mysql_core37 = require("drizzle-orm/mysql-core");
11025
+ var import_drizzle_orm35 = require("drizzle-orm");
11026
+ var import_mysql_core39 = require("drizzle-orm/mysql-core");
10803
11027
  function getDeviceVerificationSchema(mysqlTable) {
10804
11028
  return mysqlTable("DeviceVerification", {
10805
- verifiedByUserId: (0, import_mysql_core37.varchar)("verifiedByUserId", {
11029
+ verifiedByUserId: (0, import_mysql_core39.varchar)("verifiedByUserId", {
10806
11030
  length: 255
10807
11031
  }),
10808
- deviceCode: (0, import_mysql_core37.varchar)("deviceCode", {
11032
+ deviceCode: (0, import_mysql_core39.varchar)("deviceCode", {
10809
11033
  length: 191
10810
11034
  }).notNull(),
10811
- userCode: (0, import_mysql_core37.text)("userCode").notNull(),
10812
- expires: (0, import_mysql_core37.timestamp)("expires", {
11035
+ userCode: (0, import_mysql_core39.text)("userCode").notNull(),
11036
+ expires: (0, import_mysql_core39.timestamp)("expires", {
10813
11037
  mode: "date",
10814
11038
  fsp: 3
10815
11039
  }).notNull(),
10816
- createdAt: (0, import_mysql_core37.timestamp)("createdAt", {
11040
+ createdAt: (0, import_mysql_core39.timestamp)("createdAt", {
10817
11041
  mode: "date",
10818
11042
  fsp: 3
10819
- }).default(import_drizzle_orm33.sql`CURRENT_TIMESTAMP(3)`),
10820
- verifiedAt: (0, import_mysql_core37.timestamp)("verifiedAt", {
11043
+ }).default(import_drizzle_orm35.sql`CURRENT_TIMESTAMP(3)`),
11044
+ verifiedAt: (0, import_mysql_core39.timestamp)("verifiedAt", {
10821
11045
  mode: "date",
10822
11046
  fsp: 3
10823
11047
  })
10824
11048
  }, (crr) => ({
10825
- pk: (0, import_mysql_core37.primaryKey)({
11049
+ pk: (0, import_mysql_core39.primaryKey)({
10826
11050
  columns: [
10827
11051
  crr.deviceCode
10828
11052
  ]
@@ -10833,7 +11057,7 @@ __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
10833
11057
  function getDeviceVerificationRelationsSchema(mysqlTable) {
10834
11058
  const deviceVerification = getDeviceVerificationSchema(mysqlTable);
10835
11059
  const user = getUsersSchema(mysqlTable);
10836
- return (0, import_drizzle_orm33.relations)(deviceVerification, ({ one }) => ({
11060
+ return (0, import_drizzle_orm35.relations)(deviceVerification, ({ one }) => ({
10837
11061
  verifiedBy: one(user, {
10838
11062
  fields: [
10839
11063
  deviceVerification.verifiedByUserId
@@ -10848,38 +11072,38 @@ function getDeviceVerificationRelationsSchema(mysqlTable) {
10848
11072
  __name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
10849
11073
 
10850
11074
  // src/lib/mysql/schemas/auth/role-permissions.ts
10851
- var import_drizzle_orm34 = require("drizzle-orm");
10852
- var import_mysql_core38 = require("drizzle-orm/mysql-core");
11075
+ var import_drizzle_orm36 = require("drizzle-orm");
11076
+ var import_mysql_core40 = require("drizzle-orm/mysql-core");
10853
11077
  function getRolePermissionsSchema(mysqlTable) {
10854
11078
  return mysqlTable("RolePermission", {
10855
- roleId: (0, import_mysql_core38.varchar)("roleId", {
11079
+ roleId: (0, import_mysql_core40.varchar)("roleId", {
10856
11080
  length: 255
10857
11081
  }).notNull(),
10858
- permissionId: (0, import_mysql_core38.varchar)("permissionId", {
11082
+ permissionId: (0, import_mysql_core40.varchar)("permissionId", {
10859
11083
  length: 255
10860
11084
  }).notNull(),
10861
- active: (0, import_mysql_core38.boolean)("active").notNull().default(true),
10862
- createdAt: (0, import_mysql_core38.timestamp)("createdAt", {
11085
+ active: (0, import_mysql_core40.boolean)("active").notNull().default(true),
11086
+ createdAt: (0, import_mysql_core40.timestamp)("createdAt", {
10863
11087
  mode: "date",
10864
11088
  fsp: 3
10865
11089
  }).defaultNow(),
10866
- updatedAt: (0, import_mysql_core38.timestamp)("updatedAt", {
11090
+ updatedAt: (0, import_mysql_core40.timestamp)("updatedAt", {
10867
11091
  mode: "date",
10868
11092
  fsp: 3
10869
11093
  }).defaultNow(),
10870
- deletedAt: (0, import_mysql_core38.timestamp)("deletedAt", {
11094
+ deletedAt: (0, import_mysql_core40.timestamp)("deletedAt", {
10871
11095
  mode: "date",
10872
11096
  fsp: 3
10873
11097
  })
10874
11098
  }, (rp) => ({
10875
- pk: (0, import_mysql_core38.primaryKey)({
11099
+ pk: (0, import_mysql_core40.primaryKey)({
10876
11100
  columns: [
10877
11101
  rp.roleId,
10878
11102
  rp.permissionId
10879
11103
  ]
10880
11104
  }),
10881
- roleIdIdx: (0, import_mysql_core38.index)("roleId_idx").on(rp.roleId),
10882
- permissionIdIdx: (0, import_mysql_core38.index)("permissionId_idx").on(rp.permissionId)
11105
+ roleIdIdx: (0, import_mysql_core40.index)("roleId_idx").on(rp.roleId),
11106
+ permissionIdIdx: (0, import_mysql_core40.index)("permissionId_idx").on(rp.permissionId)
10883
11107
  }));
10884
11108
  }
10885
11109
  __name(getRolePermissionsSchema, "getRolePermissionsSchema");
@@ -10887,7 +11111,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
10887
11111
  const permissions = getPermissionsSchema(mysqlTable);
10888
11112
  const roles = getRolesSchema(mysqlTable);
10889
11113
  const rolePermissions = getRolePermissionsSchema(mysqlTable);
10890
- return (0, import_drizzle_orm34.relations)(rolePermissions, ({ one }) => ({
11114
+ return (0, import_drizzle_orm36.relations)(rolePermissions, ({ one }) => ({
10891
11115
  role: one(roles, {
10892
11116
  fields: [
10893
11117
  rolePermissions.roleId
@@ -10911,28 +11135,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
10911
11135
  __name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
10912
11136
 
10913
11137
  // src/lib/mysql/schemas/auth/sessions.ts
10914
- var import_drizzle_orm35 = require("drizzle-orm");
10915
- var import_mysql_core39 = require("drizzle-orm/mysql-core");
11138
+ var import_drizzle_orm37 = require("drizzle-orm");
11139
+ var import_mysql_core41 = require("drizzle-orm/mysql-core");
10916
11140
  function getSessionsSchema(mysqlTable) {
10917
11141
  return mysqlTable("Session", {
10918
- sessionToken: (0, import_mysql_core39.varchar)("sessionToken", {
11142
+ sessionToken: (0, import_mysql_core41.varchar)("sessionToken", {
10919
11143
  length: 255
10920
11144
  }).notNull().primaryKey(),
10921
- userId: (0, import_mysql_core39.varchar)("userId", {
11145
+ userId: (0, import_mysql_core41.varchar)("userId", {
10922
11146
  length: 255
10923
11147
  }).notNull(),
10924
- expires: (0, import_mysql_core39.timestamp)("expires", {
11148
+ expires: (0, import_mysql_core41.timestamp)("expires", {
10925
11149
  mode: "date"
10926
11150
  }).notNull()
10927
11151
  }, (session) => ({
10928
- userIdIdx: (0, import_mysql_core39.index)("userId_idx").on(session.userId)
11152
+ userIdIdx: (0, import_mysql_core41.index)("userId_idx").on(session.userId)
10929
11153
  }));
10930
11154
  }
10931
11155
  __name(getSessionsSchema, "getSessionsSchema");
10932
11156
  function getSessionRelationsSchema(mysqlTable) {
10933
11157
  const sessions = getSessionsSchema(mysqlTable);
10934
11158
  const users = getUsersSchema(mysqlTable);
10935
- return (0, import_drizzle_orm35.relations)(sessions, ({ one }) => ({
11159
+ return (0, import_drizzle_orm37.relations)(sessions, ({ one }) => ({
10936
11160
  user: one(users, {
10937
11161
  fields: [
10938
11162
  sessions.userId
@@ -10947,24 +11171,24 @@ function getSessionRelationsSchema(mysqlTable) {
10947
11171
  __name(getSessionRelationsSchema, "getSessionRelationsSchema");
10948
11172
 
10949
11173
  // src/lib/mysql/schemas/auth/verification-tokens.ts
10950
- var import_mysql_core40 = require("drizzle-orm/mysql-core");
11174
+ var import_mysql_core42 = require("drizzle-orm/mysql-core");
10951
11175
  function getVerificationTokensSchema(mysqlTable) {
10952
11176
  return mysqlTable("VerificationToken", {
10953
- identifier: (0, import_mysql_core40.varchar)("identifier", {
11177
+ identifier: (0, import_mysql_core42.varchar)("identifier", {
10954
11178
  length: 255
10955
11179
  }).notNull(),
10956
- token: (0, import_mysql_core40.varchar)("token", {
11180
+ token: (0, import_mysql_core42.varchar)("token", {
10957
11181
  length: 255
10958
11182
  }).notNull(),
10959
- expires: (0, import_mysql_core40.timestamp)("expires", {
11183
+ expires: (0, import_mysql_core42.timestamp)("expires", {
10960
11184
  mode: "date"
10961
11185
  }).notNull(),
10962
- createdAt: (0, import_mysql_core40.timestamp)("createdAt", {
11186
+ createdAt: (0, import_mysql_core42.timestamp)("createdAt", {
10963
11187
  mode: "date",
10964
11188
  fsp: 3
10965
11189
  }).defaultNow()
10966
11190
  }, (vt) => ({
10967
- pk: (0, import_mysql_core40.primaryKey)({
11191
+ pk: (0, import_mysql_core42.primaryKey)({
10968
11192
  columns: [
10969
11193
  vt.identifier,
10970
11194
  vt.token
@@ -10975,14 +11199,14 @@ function getVerificationTokensSchema(mysqlTable) {
10975
11199
  __name(getVerificationTokensSchema, "getVerificationTokensSchema");
10976
11200
 
10977
11201
  // src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
10978
- var import_drizzle_orm36 = require("drizzle-orm");
10979
- var import_mysql_core41 = require("drizzle-orm/mysql-core");
11202
+ var import_drizzle_orm38 = require("drizzle-orm");
11203
+ var import_mysql_core43 = require("drizzle-orm/mysql-core");
10980
11204
  function getPurchaseUserTransferSchema(mysqlTable) {
10981
11205
  return mysqlTable("PurchaseUserTransfer", {
10982
- id: (0, import_mysql_core41.varchar)("id", {
11206
+ id: (0, import_mysql_core43.varchar)("id", {
10983
11207
  length: 191
10984
11208
  }).notNull(),
10985
- transferState: (0, import_mysql_core41.mysqlEnum)("transferState", [
11209
+ transferState: (0, import_mysql_core43.mysqlEnum)("transferState", [
10986
11210
  "AVAILABLE",
10987
11211
  "INITIATED",
10988
11212
  "VERIFIED",
@@ -10991,47 +11215,47 @@ function getPurchaseUserTransferSchema(mysqlTable) {
10991
11215
  "CONFIRMED",
10992
11216
  "COMPLETED"
10993
11217
  ]).default("AVAILABLE").notNull(),
10994
- purchaseId: (0, import_mysql_core41.varchar)("purchaseId", {
11218
+ purchaseId: (0, import_mysql_core43.varchar)("purchaseId", {
10995
11219
  length: 191
10996
11220
  }).notNull(),
10997
- organizationId: (0, import_mysql_core41.varchar)("organizationId", {
11221
+ organizationId: (0, import_mysql_core43.varchar)("organizationId", {
10998
11222
  length: 191
10999
11223
  }),
11000
- sourceUserId: (0, import_mysql_core41.varchar)("sourceUserId", {
11224
+ sourceUserId: (0, import_mysql_core43.varchar)("sourceUserId", {
11001
11225
  length: 191
11002
11226
  }).notNull(),
11003
- targetUserId: (0, import_mysql_core41.varchar)("targetUserId", {
11227
+ targetUserId: (0, import_mysql_core43.varchar)("targetUserId", {
11004
11228
  length: 191
11005
11229
  }),
11006
- createdAt: (0, import_mysql_core41.timestamp)("createdAt", {
11230
+ createdAt: (0, import_mysql_core43.timestamp)("createdAt", {
11007
11231
  mode: "date",
11008
11232
  fsp: 3
11009
- }).default(import_drizzle_orm36.sql`CURRENT_TIMESTAMP(3)`).notNull(),
11010
- expiresAt: (0, import_mysql_core41.timestamp)("expiresAt", {
11233
+ }).default(import_drizzle_orm38.sql`CURRENT_TIMESTAMP(3)`).notNull(),
11234
+ expiresAt: (0, import_mysql_core43.timestamp)("expiresAt", {
11011
11235
  mode: "date",
11012
11236
  fsp: 3
11013
11237
  }),
11014
- canceledAt: (0, import_mysql_core41.timestamp)("canceledAt", {
11238
+ canceledAt: (0, import_mysql_core43.timestamp)("canceledAt", {
11015
11239
  mode: "date",
11016
11240
  fsp: 3
11017
11241
  }),
11018
- confirmedAt: (0, import_mysql_core41.timestamp)("confirmedAt", {
11242
+ confirmedAt: (0, import_mysql_core43.timestamp)("confirmedAt", {
11019
11243
  mode: "date",
11020
11244
  fsp: 3
11021
11245
  }),
11022
- completedAt: (0, import_mysql_core41.timestamp)("completedAt", {
11246
+ completedAt: (0, import_mysql_core43.timestamp)("completedAt", {
11023
11247
  mode: "date",
11024
11248
  fsp: 3
11025
11249
  })
11026
11250
  }, (table) => {
11027
11251
  return {
11028
- purchaseUserTransferId: (0, import_mysql_core41.primaryKey)({
11252
+ purchaseUserTransferId: (0, import_mysql_core43.primaryKey)({
11029
11253
  columns: [
11030
11254
  table.id
11031
11255
  ],
11032
11256
  name: "PurchaseUserTransfer_id"
11033
11257
  }),
11034
- organizationIdIdx: (0, import_mysql_core41.index)("organizationId_idx").on(table.organizationId)
11258
+ organizationIdIdx: (0, import_mysql_core43.index)("organizationId_idx").on(table.organizationId)
11035
11259
  };
11036
11260
  });
11037
11261
  }
@@ -11040,7 +11264,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
11040
11264
  const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
11041
11265
  const user = getUsersSchema(mysqlTable);
11042
11266
  const purchase = getPurchaseSchema(mysqlTable);
11043
- return (0, import_drizzle_orm36.relations)(purchaseUserTransfer, ({ one }) => ({
11267
+ return (0, import_drizzle_orm38.relations)(purchaseUserTransfer, ({ one }) => ({
11044
11268
  sourceUser: one(user, {
11045
11269
  fields: [
11046
11270
  purchaseUserTransfer.sourceUserId
@@ -11073,50 +11297,50 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
11073
11297
  __name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
11074
11298
 
11075
11299
  // src/lib/mysql/schemas/commerce/upgradable-products.ts
11076
- var import_drizzle_orm37 = require("drizzle-orm");
11077
- var import_mysql_core42 = require("drizzle-orm/mysql-core");
11300
+ var import_drizzle_orm39 = require("drizzle-orm");
11301
+ var import_mysql_core44 = require("drizzle-orm/mysql-core");
11078
11302
  function getUpgradableProductsSchema(mysqlTable) {
11079
11303
  return mysqlTable("UpgradableProducts", {
11080
- upgradableToId: (0, import_mysql_core42.varchar)("upgradableToId", {
11304
+ upgradableToId: (0, import_mysql_core44.varchar)("upgradableToId", {
11081
11305
  length: 255
11082
11306
  }).notNull(),
11083
- upgradableFromId: (0, import_mysql_core42.varchar)("upgradableFrom", {
11307
+ upgradableFromId: (0, import_mysql_core44.varchar)("upgradableFrom", {
11084
11308
  length: 255
11085
11309
  }).notNull(),
11086
- organizationId: (0, import_mysql_core42.varchar)("organizationId", {
11310
+ organizationId: (0, import_mysql_core44.varchar)("organizationId", {
11087
11311
  length: 191
11088
11312
  }),
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", {
11313
+ position: (0, import_mysql_core44.double)("position").notNull().default(0),
11314
+ metadata: (0, import_mysql_core44.json)("metadata").$type().default({}),
11315
+ createdAt: (0, import_mysql_core44.timestamp)("createdAt", {
11092
11316
  mode: "date",
11093
11317
  fsp: 3
11094
- }).default(import_drizzle_orm37.sql`CURRENT_TIMESTAMP(3)`),
11095
- updatedAt: (0, import_mysql_core42.timestamp)("updatedAt", {
11318
+ }).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`),
11319
+ updatedAt: (0, import_mysql_core44.timestamp)("updatedAt", {
11096
11320
  mode: "date",
11097
11321
  fsp: 3
11098
- }).default(import_drizzle_orm37.sql`CURRENT_TIMESTAMP(3)`),
11099
- deletedAt: (0, import_mysql_core42.timestamp)("deletedAt", {
11322
+ }).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`),
11323
+ deletedAt: (0, import_mysql_core44.timestamp)("deletedAt", {
11100
11324
  mode: "date",
11101
11325
  fsp: 3
11102
11326
  })
11103
11327
  }, (crr) => ({
11104
- pk: (0, import_mysql_core42.primaryKey)({
11328
+ pk: (0, import_mysql_core44.primaryKey)({
11105
11329
  columns: [
11106
11330
  crr.upgradableToId,
11107
11331
  crr.upgradableFromId
11108
11332
  ]
11109
11333
  }),
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)
11334
+ upgradableToIdIdx: (0, import_mysql_core44.index)("upgradableFromId_idx").on(crr.upgradableToId),
11335
+ upgradableFromIdIdx: (0, import_mysql_core44.index)("upgradableToId_idx").on(crr.upgradableFromId),
11336
+ organizationIdIdx: (0, import_mysql_core44.index)("organizationId_idx").on(crr.organizationId)
11113
11337
  }));
11114
11338
  }
11115
11339
  __name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
11116
11340
  function getUpgradableProductsRelationsSchema(mysqlTable) {
11117
11341
  const product = getProductSchema(mysqlTable);
11118
11342
  const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
11119
- return (0, import_drizzle_orm37.relations)(upgradableProduct, ({ one }) => ({
11343
+ return (0, import_drizzle_orm39.relations)(upgradableProduct, ({ one }) => ({
11120
11344
  upgradableTo: one(product, {
11121
11345
  fields: [
11122
11346
  upgradableProduct.upgradableToId
@@ -11140,174 +11364,208 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
11140
11364
  __name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
11141
11365
 
11142
11366
  // src/lib/mysql/schemas/content/lesson-progress.ts
11143
- var import_drizzle_orm38 = require("drizzle-orm");
11144
- var import_mysql_core43 = require("drizzle-orm/mysql-core");
11367
+ var import_drizzle_orm40 = require("drizzle-orm");
11368
+ var import_mysql_core45 = require("drizzle-orm/mysql-core");
11145
11369
  function getLessonProgressSchema(mysqlTable) {
11146
11370
  return mysqlTable("LessonProgress", {
11147
- id: (0, import_mysql_core43.varchar)("id", {
11371
+ id: (0, import_mysql_core45.varchar)("id", {
11148
11372
  length: 191
11149
11373
  }).notNull().primaryKey(),
11150
- userId: (0, import_mysql_core43.varchar)("userId", {
11374
+ userId: (0, import_mysql_core45.varchar)("userId", {
11151
11375
  length: 191
11152
11376
  }).notNull(),
11153
- organizationId: (0, import_mysql_core43.varchar)("organizationId", {
11377
+ organizationId: (0, import_mysql_core45.varchar)("organizationId", {
11154
11378
  length: 191
11155
11379
  }),
11156
- organizationMembershipId: (0, import_mysql_core43.varchar)("organizationMembershipId", {
11380
+ organizationMembershipId: (0, import_mysql_core45.varchar)("organizationMembershipId", {
11157
11381
  length: 191
11158
11382
  }),
11159
- lessonId: (0, import_mysql_core43.varchar)("lessonId", {
11383
+ lessonId: (0, import_mysql_core45.varchar)("lessonId", {
11160
11384
  length: 191
11161
11385
  }),
11162
- lessonSlug: (0, import_mysql_core43.varchar)("lessonSlug", {
11386
+ lessonSlug: (0, import_mysql_core45.varchar)("lessonSlug", {
11163
11387
  length: 191
11164
11388
  }),
11165
- lessonVersion: (0, import_mysql_core43.varchar)("lessonVersion", {
11389
+ lessonVersion: (0, import_mysql_core45.varchar)("lessonVersion", {
11166
11390
  length: 191
11167
11391
  }),
11168
- sectionId: (0, import_mysql_core43.varchar)("sectionId", {
11392
+ sectionId: (0, import_mysql_core45.varchar)("sectionId", {
11169
11393
  length: 191
11170
11394
  }),
11171
- moduleId: (0, import_mysql_core43.varchar)("moduleId", {
11395
+ moduleId: (0, import_mysql_core45.varchar)("moduleId", {
11172
11396
  length: 191
11173
11397
  }),
11174
- completedAt: (0, import_mysql_core43.datetime)("completedAt", {
11398
+ completedAt: (0, import_mysql_core45.datetime)("completedAt", {
11175
11399
  mode: "date",
11176
11400
  fsp: 3
11177
11401
  }),
11178
- updatedAt: (0, import_mysql_core43.datetime)("updatedAt", {
11402
+ updatedAt: (0, import_mysql_core45.datetime)("updatedAt", {
11179
11403
  mode: "date",
11180
11404
  fsp: 3
11181
11405
  }),
11182
- createdAt: (0, import_mysql_core43.datetime)("createdAt", {
11406
+ createdAt: (0, import_mysql_core45.datetime)("createdAt", {
11183
11407
  mode: "date",
11184
11408
  fsp: 3
11185
- }).default(import_drizzle_orm38.sql`CURRENT_TIMESTAMP(3)`).notNull()
11409
+ }).default(import_drizzle_orm40.sql`CURRENT_TIMESTAMP(3)`).notNull()
11186
11410
  }, (crp) => {
11187
11411
  return {
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)
11412
+ userIdLessonIdIdx: (0, import_mysql_core45.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
11413
+ userIdIdx: (0, import_mysql_core45.index)("userId_idx").on(crp.userId),
11414
+ lessonIdIdx: (0, import_mysql_core45.index)("lessonId_idx").on(crp.lessonId),
11415
+ organizationMembershipIdIdx: (0, import_mysql_core45.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
11192
11416
  };
11193
11417
  });
11194
11418
  }
11195
11419
  __name(getLessonProgressSchema, "getLessonProgressSchema");
11196
11420
 
11197
11421
  // src/lib/mysql/schemas/content/resource-progress.ts
11198
- var import_drizzle_orm39 = require("drizzle-orm");
11199
- var import_mysql_core44 = require("drizzle-orm/mysql-core");
11422
+ var import_drizzle_orm41 = require("drizzle-orm");
11423
+ var import_mysql_core46 = require("drizzle-orm/mysql-core");
11200
11424
  function getResourceProgressSchema(mysqlTable) {
11201
11425
  return mysqlTable("ResourceProgress", {
11202
- userId: (0, import_mysql_core44.varchar)("userId", {
11426
+ userId: (0, import_mysql_core46.varchar)("userId", {
11203
11427
  length: 255
11204
11428
  }).notNull(),
11205
- organizationId: (0, import_mysql_core44.varchar)("organizationId", {
11429
+ organizationId: (0, import_mysql_core46.varchar)("organizationId", {
11206
11430
  length: 191
11207
11431
  }),
11208
- organizationMembershipId: (0, import_mysql_core44.varchar)("organizationMembershipId", {
11432
+ organizationMembershipId: (0, import_mysql_core46.varchar)("organizationMembershipId", {
11209
11433
  length: 191
11210
11434
  }),
11211
- resourceId: (0, import_mysql_core44.varchar)("resourceId", {
11435
+ resourceId: (0, import_mysql_core46.varchar)("resourceId", {
11212
11436
  length: 255
11213
11437
  }),
11214
- fields: (0, import_mysql_core44.json)("fields").$type().default({}),
11215
- completedAt: (0, import_mysql_core44.datetime)("completedAt", {
11438
+ fields: (0, import_mysql_core46.json)("fields").$type().default({}),
11439
+ completedAt: (0, import_mysql_core46.datetime)("completedAt", {
11216
11440
  mode: "date",
11217
11441
  fsp: 3
11218
11442
  }),
11219
- updatedAt: (0, import_mysql_core44.datetime)("updatedAt", {
11443
+ updatedAt: (0, import_mysql_core46.datetime)("updatedAt", {
11220
11444
  mode: "date",
11221
11445
  fsp: 3
11222
11446
  }),
11223
- createdAt: (0, import_mysql_core44.datetime)("createdAt", {
11447
+ createdAt: (0, import_mysql_core46.datetime)("createdAt", {
11224
11448
  mode: "date",
11225
11449
  fsp: 3
11226
- }).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`).notNull()
11450
+ }).default(import_drizzle_orm41.sql`CURRENT_TIMESTAMP(3)`).notNull()
11227
11451
  }, (crp) => {
11228
11452
  return {
11229
- userIdLessonIdIdx: (0, import_mysql_core44.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
11230
- pk: (0, import_mysql_core44.primaryKey)({
11453
+ userIdLessonIdIdx: (0, import_mysql_core46.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
11454
+ pk: (0, import_mysql_core46.primaryKey)({
11231
11455
  columns: [
11232
11456
  crp.userId,
11233
11457
  crp.resourceId
11234
11458
  ]
11235
11459
  }),
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)
11460
+ contentResourceIdIdx: (0, import_mysql_core46.index)("contentResourceId_idx").on(crp.resourceId),
11461
+ userIdIdx: (0, import_mysql_core46.index)("resourceId_idx").on(crp.userId),
11462
+ organizationMembershipIdIdx: (0, import_mysql_core46.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
11239
11463
  };
11240
11464
  });
11241
11465
  }
11242
11466
  __name(getResourceProgressSchema, "getResourceProgressSchema");
11243
11467
 
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", {
11468
+ // src/lib/mysql/schemas/entitlements/entitlement-type.ts
11469
+ var import_mysql_core47 = require("drizzle-orm/mysql-core");
11470
+ function getEntitlementTypesSchema(mysqlTable) {
11471
+ return mysqlTable("EntitlementType", {
11472
+ id: (0, import_mysql_core47.varchar)("id", {
11473
+ length: 191
11474
+ }).notNull().primaryKey(),
11475
+ name: (0, import_mysql_core47.varchar)("name", {
11250
11476
  length: 255
11251
11477
  }).notNull(),
11252
- roleId: (0, import_mysql_core45.varchar)("roleId", {
11478
+ description: (0, import_mysql_core47.text)("description")
11479
+ }, (table) => ({
11480
+ uniqueName: (0, import_mysql_core47.uniqueIndex)("unique_name_idx").on(table.name)
11481
+ }));
11482
+ }
11483
+ __name(getEntitlementTypesSchema, "getEntitlementTypesSchema");
11484
+
11485
+ // src/lib/mysql/schemas/entitlements/entitlement.ts
11486
+ var import_drizzle_orm42 = require("drizzle-orm");
11487
+ var import_mysql_core48 = require("drizzle-orm/mysql-core");
11488
+ function getEntitlementsSchema(mysqlTable) {
11489
+ return mysqlTable("Entitlement", {
11490
+ id: (0, import_mysql_core48.varchar)("id", {
11491
+ length: 191
11492
+ }).notNull().primaryKey(),
11493
+ entitlementType: (0, import_mysql_core48.varchar)("entitlementType", {
11253
11494
  length: 255
11254
11495
  }).notNull(),
11255
- active: (0, import_mysql_core45.boolean)("active").notNull().default(true),
11256
- organizationId: (0, import_mysql_core45.varchar)("organizationId", {
11496
+ userId: (0, import_mysql_core48.varchar)("userId", {
11497
+ length: 191
11498
+ }),
11499
+ organizationId: (0, import_mysql_core48.varchar)("organizationId", {
11500
+ length: 191
11501
+ }),
11502
+ organizationMembershipId: (0, import_mysql_core48.varchar)("organizationMembershipId", {
11257
11503
  length: 191
11258
11504
  }),
11259
- createdAt: (0, import_mysql_core45.timestamp)("createdAt", {
11505
+ sourceType: (0, import_mysql_core48.varchar)("sourceType", {
11506
+ length: 255
11507
+ }).notNull(),
11508
+ sourceId: (0, import_mysql_core48.varchar)("sourceId", {
11509
+ length: 191
11510
+ }).notNull(),
11511
+ metadata: (0, import_mysql_core48.json)("metadata").$type().default({}),
11512
+ expiresAt: (0, import_mysql_core48.timestamp)("expiresAt", {
11260
11513
  mode: "date",
11261
11514
  fsp: 3
11262
- }).defaultNow(),
11263
- updatedAt: (0, import_mysql_core45.timestamp)("updatedAt", {
11515
+ }),
11516
+ createdAt: (0, import_mysql_core48.timestamp)("createdAt", {
11264
11517
  mode: "date",
11265
11518
  fsp: 3
11266
- }).defaultNow(),
11267
- deletedAt: (0, import_mysql_core45.timestamp)("deletedAt", {
11519
+ }).default(import_drizzle_orm42.sql`CURRENT_TIMESTAMP(3)`).notNull(),
11520
+ updatedAt: (0, import_mysql_core48.timestamp)("updatedAt", {
11521
+ mode: "date",
11522
+ fsp: 3
11523
+ }).default(import_drizzle_orm42.sql`CURRENT_TIMESTAMP(3)`).notNull(),
11524
+ deletedAt: (0, import_mysql_core48.timestamp)("deletedAt", {
11268
11525
  mode: "date",
11269
11526
  fsp: 3
11270
11527
  })
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)
11528
+ }, (table) => ({
11529
+ userIdIdx: (0, import_mysql_core48.index)("userId_idx").on(table.userId),
11530
+ orgIdIdx: (0, import_mysql_core48.index)("orgId_idx").on(table.organizationId),
11531
+ sourceIdx: (0, import_mysql_core48.index)("source_idx").on(table.sourceType, table.sourceId),
11532
+ typeIdx: (0, import_mysql_core48.index)("type_idx").on(table.entitlementType)
11282
11533
  }));
11283
11534
  }
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, {
11535
+ __name(getEntitlementsSchema, "getEntitlementsSchema");
11536
+ function getEntitlementRelationsSchema(mysqlTable) {
11537
+ const entitlements = getEntitlementsSchema(mysqlTable);
11538
+ const users = getUsersSchema(mysqlTable);
11539
+ const orgs = getOrganizationsSchema(mysqlTable);
11540
+ const memberships = getOrganizationMembershipsSchema(mysqlTable);
11541
+ return (0, import_drizzle_orm42.relations)(entitlements, ({ one }) => ({
11542
+ user: one(users, {
11291
11543
  fields: [
11292
- organizationMembershipRoles.organizationMembershipId
11544
+ entitlements.userId
11293
11545
  ],
11294
11546
  references: [
11295
- organizationMemberships.id
11296
- ],
11297
- relationName: "organizationMembership"
11547
+ users.id
11548
+ ]
11298
11549
  }),
11299
- role: one(roles, {
11550
+ organization: one(orgs, {
11300
11551
  fields: [
11301
- organizationMembershipRoles.roleId
11552
+ entitlements.organizationId
11302
11553
  ],
11303
11554
  references: [
11304
- roles.id
11555
+ orgs.id
11556
+ ]
11557
+ }),
11558
+ membership: one(memberships, {
11559
+ fields: [
11560
+ entitlements.organizationMembershipId
11305
11561
  ],
11306
- relationName: "role"
11562
+ references: [
11563
+ memberships.id
11564
+ ]
11307
11565
  })
11308
11566
  }));
11309
11567
  }
11310
- __name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
11568
+ __name(getEntitlementRelationsSchema, "getEntitlementRelationsSchema");
11311
11569
 
11312
11570
  // src/lib/mysql/index.ts
11313
11571
  var guid = (0, import_nanoid.customAlphabet)("1234567890abcdefghijklmnopqrstuvwxyz", 5);
@@ -11390,7 +11648,12 @@ function getCourseBuilderSchema(mysqlTable) {
11390
11648
  merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
11391
11649
  merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
11392
11650
  subscription: getSubscriptionSchema(mysqlTable),
11393
- subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable)
11651
+ subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
11652
+ profiles: getProfilesSchema(mysqlTable),
11653
+ profilesRelations: getProfilesRelationsSchema(mysqlTable),
11654
+ entitlementTypes: getEntitlementTypesSchema(mysqlTable),
11655
+ entitlements: getEntitlementsSchema(mysqlTable),
11656
+ entitlementsRelations: getEntitlementRelationsSchema(mysqlTable)
11394
11657
  };
11395
11658
  }
11396
11659
  __name(getCourseBuilderSchema, "getCourseBuilderSchema");
@@ -11398,8 +11661,8 @@ function createTables(mySqlTable) {
11398
11661
  return getCourseBuilderSchema(mySqlTable);
11399
11662
  }
11400
11663
  __name(createTables, "createTables");
11401
- function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, paymentProvider) {
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);
11664
+ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core49.mysqlTable, paymentProvider) {
11665
+ const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments, organization: organizationTable, organizationMemberships: organizationMembershipTable, organizationMembershipRoles: organizationMembershipRoleTable, roles: roleTable, merchantSubscription: merchantSubscriptionTable, subscription: subscriptionTable } = createTables(tableFn);
11403
11666
  const adapter = {
11404
11667
  client,
11405
11668
  async redeemFullPriceCoupon(options) {
@@ -11470,12 +11733,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11470
11733
  },
11471
11734
  incrementCouponUsedCount: async (couponId) => {
11472
11735
  await client.update(coupon).set({
11473
- usedCount: import_drizzle_orm41.sql`${coupon.usedCount} + 1`
11474
- }).where((0, import_drizzle_orm41.eq)(coupon.id, couponId));
11736
+ usedCount: import_drizzle_orm43.sql`${coupon.usedCount} + 1`
11737
+ }).where((0, import_drizzle_orm43.eq)(coupon.id, couponId));
11475
11738
  },
11476
11739
  getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
11477
11740
  const existingPurchases = await client.query.purchases.findMany({
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))
11741
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm43.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm43.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm43.isNull)(purchaseTable.bulkCouponId))
11479
11742
  });
11480
11743
  return z.array(purchaseSchema).parse(existingPurchases);
11481
11744
  },
@@ -11488,17 +11751,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11488
11751
  status: 1
11489
11752
  });
11490
11753
  return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
11491
- where: (0, import_drizzle_orm41.eq)(merchantCustomer.identifier, options.identifier)
11754
+ where: (0, import_drizzle_orm43.eq)(merchantCustomer.identifier, options.identifier)
11492
11755
  }));
11493
11756
  },
11494
11757
  getMerchantAccount: async (options) => {
11495
11758
  return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
11496
- where: (0, import_drizzle_orm41.eq)(merchantAccount.label, options.provider)
11759
+ where: (0, import_drizzle_orm43.eq)(merchantAccount.label, options.provider)
11497
11760
  }));
11498
11761
  },
11499
11762
  getMerchantPriceForProductId: async (productId) => {
11500
11763
  const merchantPriceData = await client.query.merchantPrice.findFirst({
11501
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm41.eq)(merchantPrice.status, 1))
11764
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm43.eq)(merchantPrice.status, 1))
11502
11765
  });
11503
11766
  const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
11504
11767
  if (!parsedMerchantPrice.success) {
@@ -11509,7 +11772,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11509
11772
  },
11510
11773
  getMerchantProductForProductId: async (productId) => {
11511
11774
  const merchantProductData = await client.query.merchantProduct.findFirst({
11512
- where: (0, import_drizzle_orm41.eq)(merchantProduct.productId, productId)
11775
+ where: (0, import_drizzle_orm43.eq)(merchantProduct.productId, productId)
11513
11776
  });
11514
11777
  if (!merchantProductData)
11515
11778
  return null;
@@ -11517,7 +11780,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11517
11780
  },
11518
11781
  getMerchantCustomerForUserId: async (userId) => {
11519
11782
  const merchantCustomerData = await client.query.merchantCustomer.findFirst({
11520
- where: (0, import_drizzle_orm41.eq)(merchantCustomer.userId, userId)
11783
+ where: (0, import_drizzle_orm43.eq)(merchantCustomer.userId, userId)
11521
11784
  });
11522
11785
  if (!merchantCustomerData)
11523
11786
  return null;
@@ -11526,14 +11789,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11526
11789
  getUpgradableProducts: async (options) => {
11527
11790
  const { upgradableFromId, upgradableToId } = options;
11528
11791
  return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
11529
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm41.eq)(upgradableProducts.upgradableToId, upgradableToId))
11792
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm43.eq)(upgradableProducts.upgradableToId, upgradableToId))
11530
11793
  }));
11531
11794
  },
11532
11795
  async availableUpgradesForProduct(purchases, productId) {
11533
11796
  const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
11534
11797
  if (previousPurchaseProductIds.length > 0) {
11535
11798
  return client.query.upgradableProducts.findMany({
11536
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm41.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
11799
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm43.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
11537
11800
  });
11538
11801
  }
11539
11802
  return [];
@@ -11546,7 +11809,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11546
11809
  throw new Error("No lessonId provided");
11547
11810
  }
11548
11811
  let lessonProgress = await client.query.resourceProgress.findFirst({
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))
11812
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm43.eq)(resourceProgress.resourceId, options.lessonId))
11550
11813
  });
11551
11814
  const now = /* @__PURE__ */ new Date();
11552
11815
  if (lessonProgress) {
@@ -11554,7 +11817,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11554
11817
  await client.update(resourceProgress).set({
11555
11818
  completedAt: now,
11556
11819
  updatedAt: now
11557
- }).where((0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId));
11820
+ }).where((0, import_drizzle_orm43.eq)(resourceProgress.resourceId, options.lessonId));
11558
11821
  }
11559
11822
  } else {
11560
11823
  await client.insert(resourceProgress).values({
@@ -11565,7 +11828,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11565
11828
  });
11566
11829
  }
11567
11830
  lessonProgress = await client.query.resourceProgress.findFirst({
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))
11831
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm43.eq)(resourceProgress.resourceId, options.lessonId))
11569
11832
  });
11570
11833
  const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
11571
11834
  if (!parsedLessonProgress.success) {
@@ -11578,7 +11841,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11578
11841
  if (!options.couponId && !options.code)
11579
11842
  return null;
11580
11843
  const couponForIdOrCode = await client.query.coupon.findFirst({
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))),
11844
+ where: (0, import_drizzle_orm43.or)((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.or)(options.code ? (0, import_drizzle_orm43.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm43.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm43.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.or)(options.code ? (0, import_drizzle_orm43.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm43.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm43.isNull)(coupon.expires))),
11582
11845
  with: {
11583
11846
  merchantCoupon: true
11584
11847
  }
@@ -11594,15 +11857,29 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11594
11857
  }
11595
11858
  return parsedCoupon.data;
11596
11859
  },
11860
+ async createMerchantSession(options) {
11861
+ const id = `ms_${(0, import_uuid.v4)()}`;
11862
+ await client.insert(merchantSession).values({
11863
+ id,
11864
+ identifier: options.identifier,
11865
+ merchantAccountId: options.merchantAccountId,
11866
+ ...options.organizationId ? {
11867
+ organizationId: options.organizationId
11868
+ } : {}
11869
+ });
11870
+ return MerchantSessionSchema.parse(await client.query.merchantSession.findFirst({
11871
+ where: (0, import_drizzle_orm43.eq)(merchantSession.id, id)
11872
+ }));
11873
+ },
11597
11874
  async createMerchantChargeAndPurchase(options) {
11598
11875
  const purchaseId = await client.transaction(async (trx) => {
11599
11876
  try {
11600
- const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
11877
+ const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId, organizationId } = options;
11601
11878
  const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
11602
- where: (0, import_drizzle_orm41.eq)(merchantCharge.identifier, stripeChargeId)
11879
+ where: (0, import_drizzle_orm43.eq)(merchantCharge.identifier, stripeChargeId)
11603
11880
  }) || null);
11604
11881
  const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
11605
- where: (0, import_drizzle_orm41.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
11882
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
11606
11883
  with: {
11607
11884
  user: true,
11608
11885
  product: true,
@@ -11623,12 +11900,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11623
11900
  merchantCustomerId
11624
11901
  });
11625
11902
  const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
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, [
11903
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm43.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm43.inArray)(purchaseTable.status, [
11627
11904
  "Valid",
11628
11905
  "Restricted"
11629
11906
  ]))
11630
11907
  }) || null);
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) => {
11908
+ const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm43.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm43.eq)(purchaseTable.userId, userId))).then((res) => {
11632
11909
  return res[0]?.Coupon ?? null;
11633
11910
  }));
11634
11911
  const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
@@ -11638,11 +11915,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11638
11915
  bulkCouponId = existingBulkCoupon !== null ? existingBulkCoupon.id : (0, import_uuid.v4)();
11639
11916
  if (existingBulkCoupon !== null) {
11640
11917
  couponToUpdate = await client.update(coupon).set({
11641
- maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
11642
- }).where((0, import_drizzle_orm41.eq)(coupon.id, bulkCouponId));
11918
+ maxUses: (existingBulkCoupon?.maxUses || 0) + quantity,
11919
+ ...organizationId ? {
11920
+ organizationId
11921
+ } : {}
11922
+ }).where((0, import_drizzle_orm43.eq)(coupon.id, bulkCouponId));
11643
11923
  } else {
11644
11924
  const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
11645
- where: (0, import_drizzle_orm41.eq)(merchantCoupon.identifier, stripeCouponId)
11925
+ where: (0, import_drizzle_orm43.eq)(merchantCoupon.identifier, stripeCouponId)
11646
11926
  })) : null;
11647
11927
  couponToUpdate = await client.insert(coupon).values({
11648
11928
  id: bulkCouponId,
@@ -11650,6 +11930,9 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11650
11930
  restrictedToProductId: productId,
11651
11931
  maxUses: quantity,
11652
11932
  status: 1,
11933
+ ...organizationId ? {
11934
+ organizationId
11935
+ } : {},
11653
11936
  ...merchantCouponToUse ? {
11654
11937
  merchantCouponId: merchantCouponToUse.id
11655
11938
  } : {}
@@ -11657,19 +11940,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11657
11940
  }
11658
11941
  }
11659
11942
  const merchantSessionId = `ms_${(0, import_uuid.v4)()}`;
11660
- const newMerchantSession = await client.insert(merchantSession).values({
11943
+ await client.insert(merchantSession).values({
11661
11944
  id: merchantSessionId,
11662
11945
  identifier: checkoutSessionId,
11663
11946
  merchantAccountId
11664
11947
  });
11665
11948
  const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
11666
- where: (0, import_drizzle_orm41.eq)(merchantCoupon.identifier, stripeCouponId)
11949
+ where: (0, import_drizzle_orm43.eq)(merchantCoupon.identifier, stripeCouponId)
11667
11950
  }) : null;
11668
11951
  const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
11669
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm41.eq)(merchantCoupon.type, "ppp"))
11952
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm43.eq)(merchantCoupon.type, "ppp"))
11670
11953
  }) : null;
11671
11954
  const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
11672
- const newPurchase = await client.insert(purchaseTable).values({
11955
+ await client.insert(purchaseTable).values({
11673
11956
  id: purchaseId2,
11674
11957
  status: newPurchaseStatus,
11675
11958
  userId,
@@ -11680,14 +11963,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11680
11963
  merchantSessionId,
11681
11964
  country,
11682
11965
  upgradedFromId: upgradedFromPurchaseId || null,
11683
- couponId: usedCouponId || null
11966
+ couponId: usedCouponId || null,
11967
+ ...organizationId ? {
11968
+ organizationId
11969
+ } : {}
11684
11970
  });
11685
11971
  const oneWeekInMilliseconds = 1e3 * 60 * 60 * 24 * 7;
11686
- const newPurchaseUserTransfer = await client.insert(purchaseUserTransfer).values({
11972
+ await client.insert(purchaseUserTransfer).values({
11687
11973
  id: `put_${(0, import_uuid.v4)()}`,
11688
11974
  purchaseId: purchaseId2,
11689
11975
  expiresAt: existingPurchase ? /* @__PURE__ */ new Date() : new Date(Date.now() + oneWeekInMilliseconds),
11690
- sourceUserId: userId
11976
+ sourceUserId: userId,
11977
+ ...organizationId ? {
11978
+ organizationId
11979
+ } : {}
11691
11980
  });
11692
11981
  return purchaseId2;
11693
11982
  } catch (error) {
@@ -11697,7 +11986,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11697
11986
  }
11698
11987
  });
11699
11988
  const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
11700
- where: (0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId)
11989
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.id, purchaseId)
11701
11990
  }));
11702
11991
  if (!parsedPurchase.success) {
11703
11992
  console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
@@ -11742,7 +12031,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11742
12031
  },
11743
12032
  async getCoupon(couponIdOrCode) {
11744
12033
  const loadedCoupon = await client.query.coupon.findFirst({
11745
- where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm41.eq)(coupon.code, couponIdOrCode))
12034
+ where: (0, import_drizzle_orm43.or)((0, import_drizzle_orm43.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm43.eq)(coupon.code, couponIdOrCode))
11746
12035
  }) || null;
11747
12036
  logger.debug("loadedCoupon", {
11748
12037
  loadedCoupon
@@ -11757,7 +12046,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11757
12046
  let bulkCouponPurchases;
11758
12047
  try {
11759
12048
  couponData = await client.query.coupon.findFirst({
11760
- where: (0, import_drizzle_orm41.eq)(coupon.id, couponId),
12049
+ where: (0, import_drizzle_orm43.eq)(coupon.id, couponId),
11761
12050
  with: {
11762
12051
  bulkPurchases: true,
11763
12052
  redeemedBulkCouponPurchases: true
@@ -11769,7 +12058,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11769
12058
  }
11770
12059
  try {
11771
12060
  bulkCouponPurchases = await client.query.purchases.findMany({
11772
- where: (0, import_drizzle_orm41.eq)(purchaseTable.redeemedBulkCouponId, couponId),
12061
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.redeemedBulkCouponId, couponId),
11773
12062
  with: {
11774
12063
  user: true
11775
12064
  }
@@ -11801,8 +12090,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11801
12090
  },
11802
12091
  async getDefaultCoupon(productIds) {
11803
12092
  const activeSaleCoupon = await client.query.coupon.findFirst({
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),
12093
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(coupon.status, 1), (0, import_drizzle_orm43.eq)(coupon.default, true), (0, import_drizzle_orm43.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm43.or)(productIds ? (0, import_drizzle_orm43.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm43.isNull)(coupon.restrictedToProductId))),
12094
+ orderBy: (0, import_drizzle_orm43.desc)(coupon.percentageDiscount),
11806
12095
  with: {
11807
12096
  merchantCoupon: true,
11808
12097
  product: true
@@ -11826,7 +12115,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11826
12115
  },
11827
12116
  async getLessonProgressForUser(userId) {
11828
12117
  const userProgress = await client.query.resourceProgress.findMany({
11829
- where: (0, import_drizzle_orm41.eq)(resourceProgress.userId, userId)
12118
+ where: (0, import_drizzle_orm43.eq)(resourceProgress.userId, userId)
11830
12119
  });
11831
12120
  const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
11832
12121
  if (!parsed.success) {
@@ -11837,7 +12126,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11837
12126
  },
11838
12127
  async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
11839
12128
  const user = await client.query.users.findFirst({
11840
- where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm41.eq)(users.email, userIdOrEmail)),
12129
+ where: (0, import_drizzle_orm43.or)((0, import_drizzle_orm43.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm43.eq)(users.email, userIdOrEmail)),
11841
12130
  columns: {
11842
12131
  id: true
11843
12132
  }
@@ -11849,12 +12138,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11849
12138
  resource_id: z.string(),
11850
12139
  resource_type: z.enum([
11851
12140
  "lesson",
11852
- "exercise"
12141
+ "exercise",
12142
+ "post"
11853
12143
  ]),
11854
12144
  resource_slug: z.string().nullable(),
11855
12145
  completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
11856
12146
  });
11857
- const results = await client.execute(import_drizzle_orm41.sql`
12147
+ const results = await client.execute(import_drizzle_orm43.sql`
11858
12148
  SELECT
11859
12149
  cr.id AS resource_id,
11860
12150
  cr.type AS resource_type,
@@ -11885,7 +12175,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11885
12175
  LEFT JOIN ${resourceProgress} rp ON rp.resourceId = cr.id
11886
12176
  AND rp.userId = ${user.id}
11887
12177
  WHERE
11888
- cr.type IN ('lesson', 'exercise')
12178
+ cr.type IN ('lesson', 'exercise', 'post')
11889
12179
 
11890
12180
  `);
11891
12181
  const completedLessons = [];
@@ -11935,7 +12225,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11935
12225
  },
11936
12226
  async getMerchantCharge(merchantChargeId) {
11937
12227
  const mCharge = await client.query.merchantCharge.findFirst({
11938
- where: (0, import_drizzle_orm41.eq)(merchantCharge.id, merchantChargeId)
12228
+ where: (0, import_drizzle_orm43.eq)(merchantCharge.id, merchantChargeId)
11939
12229
  });
11940
12230
  const parsed = merchantChargeSchema.safeParse(mCharge);
11941
12231
  if (!parsed.success) {
@@ -11946,12 +12236,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11946
12236
  },
11947
12237
  async getMerchantCouponsForTypeAndPercent(params) {
11948
12238
  return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
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()))
12239
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm43.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
11950
12240
  }));
11951
12241
  },
11952
12242
  async getMerchantCouponForTypeAndPercent(params) {
11953
12243
  const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
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()))
12244
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm43.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
11955
12245
  });
11956
12246
  const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
11957
12247
  if (parsed.success) {
@@ -11961,7 +12251,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11961
12251
  },
11962
12252
  async getMerchantCoupon(merchantCouponId) {
11963
12253
  const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
11964
- where: (0, import_drizzle_orm41.eq)(merchantCoupon.id, merchantCouponId)
12254
+ where: (0, import_drizzle_orm43.eq)(merchantCoupon.id, merchantCouponId)
11965
12255
  });
11966
12256
  const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
11967
12257
  if (parsed.success) {
@@ -11971,7 +12261,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11971
12261
  },
11972
12262
  async getMerchantProduct(stripeProductId) {
11973
12263
  return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
11974
- where: (0, import_drizzle_orm41.eq)(merchantProduct.identifier, stripeProductId)
12264
+ where: (0, import_drizzle_orm43.eq)(merchantProduct.identifier, stripeProductId)
11975
12265
  }));
11976
12266
  },
11977
12267
  getPrice(productId) {
@@ -11979,7 +12269,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11979
12269
  },
11980
12270
  async getPriceForProduct(productId) {
11981
12271
  return priceSchema.nullable().parse(await client.query.prices.findFirst({
11982
- where: (0, import_drizzle_orm41.eq)(prices.productId, productId)
12272
+ where: (0, import_drizzle_orm43.eq)(prices.productId, productId)
11983
12273
  }));
11984
12274
  },
11985
12275
  async archiveProduct(productId) {
@@ -11995,19 +12285,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
11995
12285
  await client.update(products).set({
11996
12286
  status: 0,
11997
12287
  name: `${product.name} (Archived)`
11998
- }).where((0, import_drizzle_orm41.eq)(products.id, productId));
12288
+ }).where((0, import_drizzle_orm43.eq)(products.id, productId));
11999
12289
  await client.update(prices).set({
12000
12290
  status: 0,
12001
12291
  nickname: `${product.name} (Archived)`
12002
- }).where((0, import_drizzle_orm41.eq)(prices.productId, productId));
12292
+ }).where((0, import_drizzle_orm43.eq)(prices.productId, productId));
12003
12293
  await client.update(merchantProduct).set({
12004
12294
  status: 0
12005
- }).where((0, import_drizzle_orm41.eq)(merchantProduct.productId, productId));
12295
+ }).where((0, import_drizzle_orm43.eq)(merchantProduct.productId, productId));
12006
12296
  await client.update(merchantPrice).set({
12007
12297
  status: 0
12008
- }).where((0, import_drizzle_orm41.eq)(merchantPrice.priceId, product.price.id));
12298
+ }).where((0, import_drizzle_orm43.eq)(merchantPrice.priceId, product.price.id));
12009
12299
  const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
12010
- where: (0, import_drizzle_orm41.eq)(merchantProduct.productId, productId)
12300
+ where: (0, import_drizzle_orm43.eq)(merchantProduct.productId, productId)
12011
12301
  }));
12012
12302
  if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
12013
12303
  throw new Error(`Merchant product not found for id (${productId})`);
@@ -12016,7 +12306,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12016
12306
  active: false
12017
12307
  });
12018
12308
  const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
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))
12309
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(merchantPrice.priceId, product.price.id), (0, import_drizzle_orm43.eq)(merchantPrice.status, 1))
12020
12310
  }));
12021
12311
  if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
12022
12312
  throw new Error(`Merchant price not found for id (${productId})`);
@@ -12076,12 +12366,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12076
12366
  if (currentMerchantPrice) {
12077
12367
  await client.update(merchantPrice).set({
12078
12368
  status: 0
12079
- }).where((0, import_drizzle_orm41.eq)(merchantPrice.id, currentMerchantPrice.id));
12369
+ }).where((0, import_drizzle_orm43.eq)(merchantPrice.id, currentMerchantPrice.id));
12080
12370
  }
12081
12371
  await client.update(prices).set({
12082
12372
  unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
12083
12373
  nickname: input.name
12084
- }).where((0, import_drizzle_orm41.eq)(prices.id, currentProduct.price.id));
12374
+ }).where((0, import_drizzle_orm43.eq)(prices.id, currentProduct.price.id));
12085
12375
  if (currentStripePrice) {
12086
12376
  await paymentProvider.updatePrice(currentStripePrice.id, {
12087
12377
  active: false
@@ -12109,8 +12399,9 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12109
12399
  ...image?.url && {
12110
12400
  image
12111
12401
  }
12112
- }
12113
- }).where((0, import_drizzle_orm41.eq)(products.id, currentProduct.id));
12402
+ },
12403
+ type: input.type
12404
+ }).where((0, import_drizzle_orm43.eq)(products.id, currentProduct.id));
12114
12405
  return adapter.getProduct(currentProduct.id);
12115
12406
  },
12116
12407
  async createProduct(input) {
@@ -12186,7 +12477,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12186
12477
  }
12187
12478
  try {
12188
12479
  const productData = await client.query.products.findFirst({
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))),
12480
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.or)((0, import_drizzle_orm43.eq)(import_drizzle_orm43.sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), (0, import_drizzle_orm43.eq)(products.id, productSlugOrId))),
12190
12481
  with: {
12191
12482
  price: true,
12192
12483
  ...withResources && {
@@ -12215,20 +12506,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12215
12506
  },
12216
12507
  async getProductResources(productId) {
12217
12508
  const contentResourceProductsForProduct = z.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
12218
- where: (0, import_drizzle_orm41.eq)(contentResourceProduct.productId, productId)
12509
+ where: (0, import_drizzle_orm43.eq)(contentResourceProduct.productId, productId)
12219
12510
  }));
12220
12511
  if (!contentResourceProductsForProduct) {
12221
12512
  return null;
12222
12513
  } else {
12223
12514
  const contentResources = z.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
12224
- where: (0, import_drizzle_orm41.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
12515
+ where: (0, import_drizzle_orm43.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
12225
12516
  }));
12226
12517
  return contentResources;
12227
12518
  }
12228
12519
  },
12229
12520
  async getPurchaseCountForProduct(productId) {
12230
12521
  return await client.query.purchases.findMany({
12231
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, [
12522
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm43.inArray)(purchaseTable.status, [
12232
12523
  "Valid",
12233
12524
  "Restricted"
12234
12525
  ]))
@@ -12236,7 +12527,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12236
12527
  },
12237
12528
  async getPurchase(purchaseId) {
12238
12529
  const purchase = await client.query.purchases.findFirst({
12239
- where: (0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId)
12530
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.id, purchaseId)
12240
12531
  });
12241
12532
  return purchase ? purchaseSchema.parse(purchase) : null;
12242
12533
  },
@@ -12254,14 +12545,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12254
12545
  stripeChargeId
12255
12546
  });
12256
12547
  const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
12257
- where: (0, import_drizzle_orm41.eq)(merchantCharge.identifier, stripeChargeId)
12548
+ where: (0, import_drizzle_orm43.eq)(merchantCharge.identifier, stripeChargeId)
12258
12549
  }) || null);
12259
12550
  if (!chargeForPurchase) {
12260
12551
  logger.error(new Error(`No charge found for purchase: Stripe Charge ID: ${stripeChargeId}`));
12261
12552
  return null;
12262
12553
  }
12263
12554
  const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
12264
- where: (0, import_drizzle_orm41.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
12555
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
12265
12556
  with: {
12266
12557
  user: true,
12267
12558
  product: true,
@@ -12275,7 +12566,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12275
12566
  },
12276
12567
  async getPurchaseUserTransferById(options) {
12277
12568
  const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
12278
- where: (0, import_drizzle_orm41.eq)(purchaseUserTransfer.id, options.id),
12569
+ where: (0, import_drizzle_orm43.eq)(purchaseUserTransfer.id, options.id),
12279
12570
  with: {
12280
12571
  sourceUser: true,
12281
12572
  targetUser: true,
@@ -12290,7 +12581,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12290
12581
  },
12291
12582
  async getPurchaseWithUser(purchaseId) {
12292
12583
  const purchaseData = await client.query.purchases.findFirst({
12293
- where: (0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId),
12584
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.id, purchaseId),
12294
12585
  with: {
12295
12586
  user: true
12296
12587
  }
@@ -12314,13 +12605,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12314
12605
  "Restricted"
12315
12606
  ];
12316
12607
  const userPurchases = await client.query.purchases.findMany({
12317
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, visiblePurchaseStates)),
12608
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm43.inArray)(purchaseTable.status, visiblePurchaseStates)),
12318
12609
  with: {
12319
12610
  user: true,
12320
12611
  product: true,
12321
12612
  bulkCoupon: true
12322
12613
  },
12323
- orderBy: (0, import_drizzle_orm41.asc)(purchaseTable.createdAt)
12614
+ orderBy: (0, import_drizzle_orm43.asc)(purchaseTable.createdAt)
12324
12615
  });
12325
12616
  const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
12326
12617
  if (!parsedPurchases.success) {
@@ -12336,18 +12627,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12336
12627
  "Restricted"
12337
12628
  ];
12338
12629
  const userPurchases = await client.query.purchases.findMany({
12339
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.status, visiblePurchaseStates)),
12630
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm43.inArray)(purchaseTable.status, visiblePurchaseStates)),
12340
12631
  with: {
12341
12632
  user: true,
12342
12633
  product: true,
12343
12634
  bulkCoupon: true
12344
12635
  },
12345
- orderBy: (0, import_drizzle_orm41.asc)(purchaseTable.createdAt)
12636
+ orderBy: (0, import_drizzle_orm43.asc)(purchaseTable.createdAt)
12346
12637
  });
12347
12638
  const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
12348
12639
  const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
12349
12640
  const thePurchase = await client.query.purchases.findFirst({
12350
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm41.eq)(purchaseTable.userId, userId)),
12641
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm43.eq)(purchaseTable.userId, userId)),
12351
12642
  with: {
12352
12643
  user: true,
12353
12644
  product: true,
@@ -12368,7 +12659,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12368
12659
  let availableUpgrades = [];
12369
12660
  if (purchaseCanUpgrade) {
12370
12661
  availableUpgrades = await client.query.upgradableProducts.findMany({
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)))),
12662
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm43.not)((0, import_drizzle_orm43.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
12372
12663
  with: {
12373
12664
  upgradableTo: true,
12374
12665
  upgradableFrom: true
@@ -12376,10 +12667,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12376
12667
  });
12377
12668
  }
12378
12669
  const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
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, [
12670
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm43.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm43.inArray)(purchaseTable.status, [
12380
12671
  "Valid",
12381
12672
  "Restricted"
12382
- ]), (0, import_drizzle_orm41.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm41.not)((0, import_drizzle_orm41.eq)(purchaseTable.id, parsedPurchase.data.id))),
12673
+ ]), (0, import_drizzle_orm43.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm43.not)((0, import_drizzle_orm43.eq)(purchaseTable.id, parsedPurchase.data.id))),
12383
12674
  with: {
12384
12675
  user: true,
12385
12676
  product: true,
@@ -12394,7 +12685,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12394
12685
  },
12395
12686
  async getUserWithPurchasersByEmail(email) {
12396
12687
  const user = await client.query.users.findFirst({
12397
- where: (0, import_drizzle_orm41.eq)(users.email, email.trim().toLowerCase()),
12688
+ where: (0, import_drizzle_orm43.eq)(users.email, email.trim().toLowerCase()),
12398
12689
  with: {
12399
12690
  // merchantCustomer: true,
12400
12691
  roles: {
@@ -12421,7 +12712,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12421
12712
  },
12422
12713
  async getUserById(userId) {
12423
12714
  const user = await client.query.users.findFirst({
12424
- where: (0, import_drizzle_orm41.eq)(users.id, userId),
12715
+ where: (0, import_drizzle_orm43.eq)(users.id, userId),
12425
12716
  with: {
12426
12717
  roles: {
12427
12718
  with: {
@@ -12443,13 +12734,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12443
12734
  if (userId === void 0)
12444
12735
  return [];
12445
12736
  const canUpgradeProducts = await client.query.upgradableProducts.findMany({
12446
- where: (0, import_drizzle_orm41.eq)(upgradableProducts.upgradableToId, bundleId)
12737
+ where: (0, import_drizzle_orm43.eq)(upgradableProducts.upgradableToId, bundleId)
12447
12738
  });
12448
12739
  const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
12449
12740
  return product.upgradableFromId;
12450
12741
  }));
12451
12742
  const purchases = await client.query.purchases.findMany({
12452
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm41.inArray)(purchaseTable.productId, upgradableFrom))
12743
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm43.inArray)(purchaseTable.productId, upgradableFrom))
12453
12744
  });
12454
12745
  const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
12455
12746
  return purchase.productId;
@@ -12457,7 +12748,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12457
12748
  if (productsPurchased.length === 0)
12458
12749
  return [];
12459
12750
  const foundPrices = await client.query.prices.findMany({
12460
- where: (0, import_drizzle_orm41.inArray)(prices.productId, productsPurchased)
12751
+ where: (0, import_drizzle_orm43.inArray)(prices.productId, productsPurchased)
12461
12752
  });
12462
12753
  return z.array(priceSchema).parse(foundPrices);
12463
12754
  },
@@ -12466,14 +12757,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12466
12757
  throw new Error("No lessonId provided");
12467
12758
  }
12468
12759
  let lessonProgress = await client.query.resourceProgress.findFirst({
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))
12760
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm43.eq)(resourceProgress.resourceId, options.lessonId))
12470
12761
  });
12471
12762
  const now = /* @__PURE__ */ new Date();
12472
12763
  if (lessonProgress) {
12473
12764
  await client.update(resourceProgress).set({
12474
12765
  completedAt: lessonProgress.completedAt ? null : now,
12475
12766
  updatedAt: now
12476
- }).where((0, import_drizzle_orm41.eq)(resourceProgress.resourceId, options.lessonId));
12767
+ }).where((0, import_drizzle_orm43.eq)(resourceProgress.resourceId, options.lessonId));
12477
12768
  } else {
12478
12769
  await client.insert(resourceProgress).values({
12479
12770
  userId: options.userId,
@@ -12483,7 +12774,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12483
12774
  });
12484
12775
  }
12485
12776
  lessonProgress = await client.query.resourceProgress.findFirst({
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))
12777
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm43.eq)(resourceProgress.resourceId, options.lessonId))
12487
12778
  });
12488
12779
  const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
12489
12780
  if (!parsedLessonProgress.success) {
@@ -12505,7 +12796,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12505
12796
  throw new Error("No purchase found");
12506
12797
  await trx.update(purchaseTable).set({
12507
12798
  userId: targetUserId
12508
- }).where((0, import_drizzle_orm41.eq)(purchaseTable.id, purchase.id));
12799
+ }).where((0, import_drizzle_orm43.eq)(purchaseTable.id, purchase.id));
12509
12800
  await trx.insert(purchaseUserTransfer).values({
12510
12801
  id: transferId,
12511
12802
  purchaseId: purchase.id,
@@ -12520,21 +12811,21 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12520
12811
  if (paymentProvider && purchase.merchantChargeId) {
12521
12812
  await trx.update(merchantCharge).set({
12522
12813
  userId: targetUserId
12523
- }).where((0, import_drizzle_orm41.eq)(merchantCharge.id, purchase.merchantChargeId));
12814
+ }).where((0, import_drizzle_orm43.eq)(merchantCharge.id, purchase.merchantChargeId));
12524
12815
  const updatedMerchantCharge = await adapter.getMerchantCharge(purchase.merchantChargeId);
12525
12816
  if (!updatedMerchantCharge)
12526
12817
  throw new Error("No merchant charge found");
12527
12818
  await trx.update(merchantCustomer).set({
12528
12819
  userId: targetUserId
12529
- }).where((0, import_drizzle_orm41.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId));
12820
+ }).where((0, import_drizzle_orm43.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId));
12530
12821
  const updatedMerchantCustomer = merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
12531
- where: (0, import_drizzle_orm41.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId)
12822
+ where: (0, import_drizzle_orm43.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId)
12532
12823
  }));
12533
12824
  const targetUser = userSchema.parse(await client.query.users.findFirst({
12534
- where: (0, import_drizzle_orm41.eq)(users.id, targetUserId)
12825
+ where: (0, import_drizzle_orm43.eq)(users.id, targetUserId)
12535
12826
  }));
12536
12827
  const sourceUser = userSchema.parse(await client.query.users.findFirst({
12537
- where: (0, import_drizzle_orm41.eq)(users.id, sourceUserId)
12828
+ where: (0, import_drizzle_orm43.eq)(users.id, sourceUserId)
12538
12829
  }));
12539
12830
  await paymentProvider.updateCustomer(updatedMerchantCustomer.identifier, {
12540
12831
  email: targetUser.email,
@@ -12561,7 +12852,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12561
12852
  status
12562
12853
  });
12563
12854
  const merchantChargeForPurchase = await client.query.merchantCharge.findFirst({
12564
- where: (0, import_drizzle_orm41.or)((0, import_drizzle_orm41.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm41.eq)(merchantCharge.id, chargeId))
12855
+ where: (0, import_drizzle_orm43.or)((0, import_drizzle_orm43.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm43.eq)(merchantCharge.id, chargeId))
12565
12856
  });
12566
12857
  console.log("merchantChargeForPurchase", {
12567
12858
  merchantChargeForPurchase
@@ -12570,15 +12861,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12570
12861
  if (!parsedMerchantChargeForPurchase)
12571
12862
  throw new Error(`no-charge-found-for-purchase ${chargeId}`);
12572
12863
  const purchase = await client.query.purchases.findFirst({
12573
- where: (0, import_drizzle_orm41.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
12864
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
12574
12865
  });
12575
12866
  const parsedPurchase = purchaseSchema.nullable().parse(purchase);
12576
12867
  if (parsedPurchase) {
12577
12868
  await client.update(purchaseTable).set({
12578
12869
  status
12579
- }).where((0, import_drizzle_orm41.eq)(purchaseTable.id, parsedPurchase.id));
12870
+ }).where((0, import_drizzle_orm43.eq)(purchaseTable.id, parsedPurchase.id));
12580
12871
  const newPurchase = await client.query.purchases.findFirst({
12581
- where: (0, import_drizzle_orm41.eq)(purchaseTable.id, parsedPurchase.id)
12872
+ where: (0, import_drizzle_orm43.eq)(purchaseTable.id, parsedPurchase.id)
12582
12873
  });
12583
12874
  return purchaseSchema.optional().parse(newPurchase);
12584
12875
  } else {
@@ -12592,16 +12883,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12592
12883
  async updatePurchaseUserTransferTransferState(options) {
12593
12884
  await client.update(purchaseUserTransfer).set({
12594
12885
  transferState: options.transferState
12595
- }).where((0, import_drizzle_orm41.eq)(purchaseUserTransfer.id, options.id));
12886
+ }).where((0, import_drizzle_orm43.eq)(purchaseUserTransfer.id, options.id));
12596
12887
  const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
12597
- where: (0, import_drizzle_orm41.eq)(purchaseUserTransfer.id, options.id)
12888
+ where: (0, import_drizzle_orm43.eq)(purchaseUserTransfer.id, options.id)
12598
12889
  }) || null;
12599
12890
  return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
12600
12891
  },
12601
12892
  addResourceToResource: async function(options) {
12602
12893
  const { parentResourceId, childResourceId } = options;
12603
12894
  const parentResourceData = await client.query.contentResource.findFirst({
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)),
12895
+ where: (0, import_drizzle_orm43.or)((0, import_drizzle_orm43.eq)(import_drizzle_orm43.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm43.eq)(contentResource.id, parentResourceId)),
12605
12896
  with: {
12606
12897
  resources: true
12607
12898
  }
@@ -12613,7 +12904,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12613
12904
  position: parentResource.resources?.length || 0
12614
12905
  });
12615
12906
  const resourceJoin = client.query.contentResourceResource.findFirst({
12616
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm41.eq)(contentResourceResource.resourceId, childResourceId)),
12907
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm43.eq)(contentResourceResource.resourceId, childResourceId)),
12617
12908
  with: {
12618
12909
  resource: true
12619
12910
  }
@@ -12627,28 +12918,28 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12627
12918
  async removeResourceFromResource(options) {
12628
12919
  const { childResourceId, parentResourceId } = options;
12629
12920
  const resourceJoin = await client.query.contentResourceResource.findFirst({
12630
- where: (0, import_drizzle_orm41.and)((0, import_drizzle_orm41.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm41.eq)(contentResourceResource.resourceId, childResourceId))
12921
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm43.eq)(contentResourceResource.resourceId, childResourceId))
12631
12922
  });
12632
12923
  const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
12633
12924
  if (!parsedResourceJoin.success) {
12634
12925
  return null;
12635
12926
  }
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)));
12927
+ await client.delete(contentResourceResource).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm43.eq)(contentResourceResource.resourceId, childResourceId)));
12637
12928
  return parsedResourceJoin.data.resource;
12638
12929
  },
12639
12930
  async updateContentResourceFields(options) {
12640
12931
  if (!options.id) {
12641
12932
  throw new Error("No content resource id.");
12642
12933
  }
12643
- const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm41.eq)(contentResource.id, options.id)).then((res) => res[0]);
12934
+ const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm43.eq)(contentResource.id, options.id)).then((res) => res[0]);
12644
12935
  await client.update(contentResource).set({
12645
12936
  fields: {
12646
12937
  ...currentResource.fields,
12647
12938
  ...options.fields
12648
12939
  }
12649
- }).where((0, import_drizzle_orm41.eq)(contentResource.id, options.id));
12940
+ }).where((0, import_drizzle_orm43.eq)(contentResource.id, options.id));
12650
12941
  const resource = await client.query.contentResource.findFirst({
12651
- where: (0, import_drizzle_orm41.eq)(contentResource.id, options.id),
12942
+ where: (0, import_drizzle_orm43.eq)(contentResource.id, options.id),
12652
12943
  with: {
12653
12944
  resources: {
12654
12945
  with: {
@@ -12658,12 +12949,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12658
12949
  with: {
12659
12950
  resource: true
12660
12951
  },
12661
- orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
12952
+ orderBy: (0, import_drizzle_orm43.asc)(contentResourceResource.position)
12662
12953
  }
12663
12954
  }
12664
12955
  }
12665
12956
  },
12666
- orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
12957
+ orderBy: (0, import_drizzle_orm43.asc)(contentResourceResource.position)
12667
12958
  }
12668
12959
  }
12669
12960
  });
@@ -12678,7 +12969,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12678
12969
  if (!id) {
12679
12970
  return null;
12680
12971
  }
12681
- const query = import_drizzle_orm41.sql`
12972
+ const query = import_drizzle_orm43.sql`
12682
12973
  SELECT
12683
12974
  id as id,
12684
12975
  CAST(updatedAt AS DATETIME) as updatedAt,
@@ -12710,7 +13001,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12710
13001
  id
12711
13002
  });
12712
13003
  const resource = await client.query.contentResource.findFirst({
12713
- where: (0, import_drizzle_orm41.eq)(contentResource.id, id),
13004
+ where: (0, import_drizzle_orm43.eq)(contentResource.id, id),
12714
13005
  with: {
12715
13006
  resources: {
12716
13007
  with: {
@@ -12720,12 +13011,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12720
13011
  with: {
12721
13012
  resource: true
12722
13013
  },
12723
- orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
13014
+ orderBy: (0, import_drizzle_orm43.asc)(contentResourceResource.position)
12724
13015
  }
12725
13016
  }
12726
13017
  }
12727
13018
  },
12728
- orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
13019
+ orderBy: (0, import_drizzle_orm43.asc)(contentResourceResource.position)
12729
13020
  }
12730
13021
  }
12731
13022
  });
@@ -12738,7 +13029,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12738
13029
  },
12739
13030
  async getContentResource(data) {
12740
13031
  const resource = await client.query.contentResource.findFirst({
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}`)),
13032
+ where: (0, import_drizzle_orm43.or)((0, import_drizzle_orm43.eq)(contentResource.id, data), (0, import_drizzle_orm43.eq)(import_drizzle_orm43.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
12742
13033
  with: {
12743
13034
  resources: {
12744
13035
  with: {
@@ -12756,12 +13047,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12756
13047
  }
12757
13048
  }
12758
13049
  },
12759
- orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
13050
+ orderBy: (0, import_drizzle_orm43.asc)(contentResourceResource.position)
12760
13051
  }
12761
13052
  }
12762
13053
  }
12763
13054
  },
12764
- orderBy: (0, import_drizzle_orm41.asc)(contentResourceResource.position)
13055
+ orderBy: (0, import_drizzle_orm43.asc)(contentResourceResource.position)
12765
13056
  }
12766
13057
  }
12767
13058
  });
@@ -12779,61 +13070,84 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12779
13070
  ...data,
12780
13071
  id
12781
13072
  });
12782
- return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.id, id)).then((res) => res[0]);
13073
+ const personalOrganization = await adapter.createOrganization({
13074
+ name: `Personal (${data.email})`
13075
+ });
13076
+ if (!personalOrganization) {
13077
+ throw new Error("Failed to create personal organization");
13078
+ }
13079
+ const membership = await adapter.addMemberToOrganization({
13080
+ organizationId: personalOrganization.id,
13081
+ userId: id,
13082
+ invitedById: id
13083
+ });
13084
+ if (!membership) {
13085
+ throw new Error("Failed to add user to personal organization");
13086
+ }
13087
+ await adapter.addRoleForMember({
13088
+ organizationId: personalOrganization.id,
13089
+ memberId: membership.id,
13090
+ role: "owner"
13091
+ });
13092
+ const user = await adapter.getUser?.(id);
13093
+ if (!user) {
13094
+ throw new Error("Failed to get user");
13095
+ }
13096
+ return user;
12783
13097
  } catch (error) {
12784
13098
  console.error(error);
12785
13099
  throw error;
12786
13100
  }
12787
13101
  },
12788
13102
  async getUser(data) {
12789
- return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.id, data)).then((res) => res[0]) ?? null;
13103
+ return await client.select().from(users).where((0, import_drizzle_orm43.eq)(users.id, data)).then((res) => res[0]) ?? null;
12790
13104
  },
12791
13105
  async getUserByEmail(data) {
12792
- return await client.select().from(users).where((0, import_drizzle_orm41.eq)(users.email, data)).then((res) => res[0]) ?? null;
13106
+ return await client.select().from(users).where((0, import_drizzle_orm43.eq)(users.email, data)).then((res) => res[0]) ?? null;
12793
13107
  },
12794
13108
  async createSession(data) {
12795
13109
  await client.insert(sessions).values(data);
12796
- return await client.select().from(sessions).where((0, import_drizzle_orm41.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
13110
+ return await client.select().from(sessions).where((0, import_drizzle_orm43.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
12797
13111
  },
12798
13112
  async getSessionAndUser(data) {
12799
13113
  return await client.select({
12800
13114
  session: sessions,
12801
13115
  user: users
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;
13116
+ }).from(sessions).where((0, import_drizzle_orm43.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm43.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
12803
13117
  },
12804
13118
  async updateUser(data) {
12805
13119
  if (!data.id) {
12806
13120
  throw new Error("No user id.");
12807
13121
  }
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]);
13122
+ await client.update(users).set(data).where((0, import_drizzle_orm43.eq)(users.id, data.id));
13123
+ return await client.select().from(users).where((0, import_drizzle_orm43.eq)(users.id, data.id)).then((res) => res[0]);
12810
13124
  },
12811
13125
  async updateSession(data) {
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]);
13126
+ await client.update(sessions).set(data).where((0, import_drizzle_orm43.eq)(sessions.sessionToken, data.sessionToken));
13127
+ return await client.select().from(sessions).where((0, import_drizzle_orm43.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
12814
13128
  },
12815
13129
  async linkAccount(rawAccount) {
12816
13130
  await client.insert(accounts).values(rawAccount);
12817
13131
  },
12818
13132
  async getUserByAccount(account) {
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;
13133
+ const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm43.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm43.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
12820
13134
  if (!dbAccount) {
12821
13135
  return null;
12822
13136
  }
12823
13137
  return dbAccount.User;
12824
13138
  },
12825
13139
  async deleteSession(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));
13140
+ const session = await client.select().from(sessions).where((0, import_drizzle_orm43.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
13141
+ await client.delete(sessions).where((0, import_drizzle_orm43.eq)(sessions.sessionToken, sessionToken));
12828
13142
  return session;
12829
13143
  },
12830
13144
  async createVerificationToken(token) {
12831
13145
  await client.insert(verificationTokens).values(token);
12832
- return await client.select().from(verificationTokens).where((0, import_drizzle_orm41.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
13146
+ return await client.select().from(verificationTokens).where((0, import_drizzle_orm43.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
12833
13147
  },
12834
13148
  async useVerificationToken(token) {
12835
13149
  try {
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;
13150
+ const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm43.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
12837
13151
  if (deletedToken?.createdAt) {
12838
13152
  const TIMEOUT_IN_SECONDS = 90;
12839
13153
  const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
@@ -12842,7 +13156,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12842
13156
  const { id: _, ...verificationToken } = token;
12843
13157
  return deletedToken;
12844
13158
  } else {
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)));
13159
+ await client.delete(verificationTokens).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm43.eq)(verificationTokens.token, token.token)));
12846
13160
  return deletedToken;
12847
13161
  }
12848
13162
  }
@@ -12852,15 +13166,154 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
12852
13166
  }
12853
13167
  },
12854
13168
  async deleteUser(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));
13169
+ const user = await client.select().from(users).where((0, import_drizzle_orm43.eq)(users.id, id)).then((res) => res[0] ?? null);
13170
+ await client.delete(users).where((0, import_drizzle_orm43.eq)(users.id, id));
13171
+ await client.delete(sessions).where((0, import_drizzle_orm43.eq)(sessions.userId, id));
13172
+ await client.delete(accounts).where((0, import_drizzle_orm43.eq)(accounts.userId, id));
12859
13173
  return user;
12860
13174
  },
12861
13175
  async unlinkAccount(account) {
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)));
13176
+ await client.delete(accounts).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm43.eq)(accounts.provider, account.provider)));
12863
13177
  return void 0;
13178
+ },
13179
+ createOrganization: async (options) => {
13180
+ const organizationId = crypto.randomUUID();
13181
+ await client.insert(organizationTable).values({
13182
+ ...options,
13183
+ id: organizationId
13184
+ });
13185
+ return adapter.getOrganization(organizationId);
13186
+ },
13187
+ getOrganization: async (organizationId) => {
13188
+ return OrganizationSchema.parse(await client.query.organization.findFirst({
13189
+ where: (0, import_drizzle_orm43.eq)(organizationTable.id, organizationId)
13190
+ }));
13191
+ },
13192
+ addMemberToOrganization: async (options) => {
13193
+ const currentMembership = await client.query.organizationMemberships.findFirst({
13194
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm43.eq)(organizationMembershipTable.userId, options.userId))
13195
+ });
13196
+ if (currentMembership) {
13197
+ return OrganizationMemberSchema.parse(currentMembership);
13198
+ } else {
13199
+ const id = crypto.randomUUID();
13200
+ await client.insert(organizationMembershipTable).values({
13201
+ ...options,
13202
+ id
13203
+ });
13204
+ return OrganizationMemberSchema.parse(await client.query.organizationMemberships.findFirst({
13205
+ where: (0, import_drizzle_orm43.eq)(organizationMembershipTable.id, id),
13206
+ with: {
13207
+ organization: true,
13208
+ user: true
13209
+ }
13210
+ }));
13211
+ }
13212
+ },
13213
+ removeMemberFromOrganization: async (options) => {
13214
+ await client.delete(organizationMembershipTable).where((0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm43.eq)(organizationMembershipTable.userId, options.userId)));
13215
+ },
13216
+ addRoleForMember: async (options) => {
13217
+ const existingRole = z.object({
13218
+ id: z.string()
13219
+ }).nullish().parse(await client.query.roles.findFirst({
13220
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(roleTable.organizationId, options.organizationId), (0, import_drizzle_orm43.eq)(roleTable.name, options.role))
13221
+ }));
13222
+ const roleId = existingRole?.id || crypto.randomUUID();
13223
+ if (!existingRole) {
13224
+ await client.insert(roleTable).values({
13225
+ name: options.role,
13226
+ organizationId: options.organizationId,
13227
+ id: roleId
13228
+ });
13229
+ }
13230
+ const currentOrgMembershipRole = await client.query.organizationMembershipRoles.findFirst({
13231
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(organizationMembershipRoleTable.organizationMembershipId, options.memberId), (0, import_drizzle_orm43.eq)(organizationMembershipRoleTable.roleId, roleId))
13232
+ });
13233
+ if (!currentOrgMembershipRole) {
13234
+ await client.insert(organizationMembershipRoleTable).values({
13235
+ organizationId: options.organizationId,
13236
+ organizationMembershipId: options.memberId,
13237
+ roleId
13238
+ });
13239
+ }
13240
+ },
13241
+ removeRoleForMember: async (options) => {
13242
+ const existingRole = z.object({
13243
+ id: z.string()
13244
+ }).nullable().parse(await client.query.roles.findFirst({
13245
+ where: (0, import_drizzle_orm43.and)((0, import_drizzle_orm43.eq)(roleTable.organizationId, options.organizationId), (0, import_drizzle_orm43.eq)(roleTable.name, options.role))
13246
+ }));
13247
+ const roleId = existingRole?.id;
13248
+ if (roleId) {
13249
+ await client.delete(organizationMembershipRoleTable).where((0, import_drizzle_orm43.eq)(organizationMembershipRoleTable.roleId, roleId));
13250
+ }
13251
+ },
13252
+ getMembershipsForUser: async (userId) => {
13253
+ return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
13254
+ where: (0, import_drizzle_orm43.eq)(organizationMembershipTable.userId, userId),
13255
+ with: {
13256
+ organization: true,
13257
+ user: true
13258
+ }
13259
+ }) || []);
13260
+ },
13261
+ getOrganizationMembers: async (organizationId) => {
13262
+ return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
13263
+ where: (0, import_drizzle_orm43.eq)(organizationMembershipTable.organizationId, organizationId)
13264
+ }) || []);
13265
+ },
13266
+ createSubscription: async (options) => {
13267
+ const id = `sub_${crypto.randomUUID()}`;
13268
+ await client.insert(subscriptionTable).values({
13269
+ ...options,
13270
+ id
13271
+ });
13272
+ return SubscriptionSchema.parse(await client.query.subscription.findFirst({
13273
+ where: (0, import_drizzle_orm43.eq)(subscriptionTable.id, id),
13274
+ with: {
13275
+ product: true
13276
+ }
13277
+ }));
13278
+ },
13279
+ getMerchantSubscription: async (merchantSubscriptionId) => {
13280
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
13281
+ where: (0, import_drizzle_orm43.eq)(merchantSubscriptionTable.id, merchantSubscriptionId)
13282
+ }));
13283
+ },
13284
+ createMerchantSubscription: async (options) => {
13285
+ const id = crypto.randomUUID();
13286
+ await client.insert(merchantSubscriptionTable).values({
13287
+ ...options,
13288
+ id
13289
+ });
13290
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
13291
+ where: (0, import_drizzle_orm43.eq)(merchantSubscriptionTable.id, id)
13292
+ }));
13293
+ },
13294
+ updateMerchantSubscription: async (options) => {
13295
+ throw new Error("Not implemented");
13296
+ },
13297
+ deleteMerchantSubscription: async (merchantSubscriptionId) => {
13298
+ throw new Error("Not implemented");
13299
+ },
13300
+ getSubscriptionForStripeId: async (stripeSubscriptionId) => {
13301
+ const merchantSubscriptionParsed = MerchantSubscriptionSchema.safeParse(await client.query.merchantSubscription.findFirst({
13302
+ where: (0, import_drizzle_orm43.eq)(merchantSubscriptionTable.identifier, stripeSubscriptionId)
13303
+ }));
13304
+ if (!merchantSubscriptionParsed.success) {
13305
+ throw new Error(`No merchant subscription found for stripe id ${stripeSubscriptionId} ${merchantSubscriptionParsed.error}`);
13306
+ }
13307
+ const subscriptionParsed = SubscriptionSchema.safeParse(await client.query.subscription.findFirst({
13308
+ where: (0, import_drizzle_orm43.eq)(subscriptionTable.merchantSubscriptionId, merchantSubscriptionParsed.data.id),
13309
+ with: {
13310
+ product: true
13311
+ }
13312
+ }));
13313
+ if (!subscriptionParsed.success) {
13314
+ throw new Error(`No subscription found for merchant subscription ${merchantSubscriptionParsed.data.id} ${subscriptionParsed.error}`);
13315
+ }
13316
+ return subscriptionParsed.data;
12864
13317
  }
12865
13318
  };
12866
13319
  return adapter;