@coursebuilder/adapter-drizzle 0.1.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/{chunk-3RJVKNXB.js → chunk-4PJWD6YK.js} +421 -392
  2. package/dist/{chunk-WQ7UXKZC.js → chunk-J63FMGT7.js} +538 -200
  3. package/dist/{chunk-2CI3IGR2.js → chunk-MCARHGE5.js} +2 -2
  4. package/dist/{chunk-Q5WENQT6.js → chunk-PIQXK2CY.js} +2 -2
  5. package/dist/{chunk-5HT43CVZ.js → chunk-QMDE6HUA.js} +43 -3
  6. package/dist/{chunk-53266VWH.js → chunk-QY4TPO7D.js} +2 -2
  7. package/dist/chunk-ZD3R6UPJ.js +96 -0
  8. package/dist/index.js +11 -11
  9. package/dist/lib/mysql/index.cjs +1110 -671
  10. package/dist/lib/mysql/index.cjs.map +1 -1
  11. package/dist/lib/mysql/index.d.cts +26 -0
  12. package/dist/lib/mysql/index.d.ts +26 -0
  13. package/dist/lib/mysql/index.js +11 -11
  14. package/dist/lib/mysql/schemas/auth/accounts.cjs +83 -72
  15. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  16. package/dist/lib/mysql/schemas/auth/accounts.js +6 -3
  17. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +73 -62
  18. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  19. package/dist/lib/mysql/schemas/auth/role-permissions.js +7 -4
  20. package/dist/lib/mysql/schemas/auth/roles.cjs +73 -62
  21. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  22. package/dist/lib/mysql/schemas/auth/roles.js +6 -3
  23. package/dist/lib/mysql/schemas/auth/sessions.cjs +73 -62
  24. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  25. package/dist/lib/mysql/schemas/auth/sessions.js +7 -4
  26. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +74 -63
  27. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  28. package/dist/lib/mysql/schemas/auth/user-permissions.js +6 -3
  29. package/dist/lib/mysql/schemas/auth/user-roles.cjs +74 -63
  30. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  31. package/dist/lib/mysql/schemas/auth/user-roles.js +6 -3
  32. package/dist/lib/mysql/schemas/auth/users.cjs +158 -147
  33. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  34. package/dist/lib/mysql/schemas/auth/users.js +6 -3
  35. package/dist/lib/mysql/schemas/commerce/coupon.cjs +209 -103
  36. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  37. package/dist/lib/mysql/schemas/commerce/coupon.d.cts +3 -0
  38. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +3 -0
  39. package/dist/lib/mysql/schemas/commerce/coupon.js +6 -3
  40. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +154 -10
  41. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  42. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +7 -1
  43. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +7 -1
  44. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +6 -1
  45. package/dist/lib/mysql/schemas/commerce/price.cjs +68 -57
  46. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  47. package/dist/lib/mysql/schemas/commerce/price.js +6 -3
  48. package/dist/lib/mysql/schemas/commerce/product.cjs +115 -104
  49. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  50. package/dist/lib/mysql/schemas/commerce/product.js +6 -3
  51. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +251 -13
  52. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  53. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +7 -1
  54. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +7 -1
  55. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +15 -1
  56. package/dist/lib/mysql/schemas/commerce/purchase.cjs +71 -56
  57. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/commerce/purchase.js +6 -3
  59. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +75 -64
  60. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  61. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +7 -4
  62. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +96 -85
  63. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  64. package/dist/lib/mysql/schemas/communication/communication-preferences.js +6 -3
  65. package/dist/lib/mysql/schemas/content/content-contributions.cjs +100 -89
  66. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  67. package/dist/lib/mysql/schemas/content/content-contributions.js +6 -3
  68. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +66 -55
  69. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  70. package/dist/lib/mysql/schemas/content/content-resource-product.js +6 -3
  71. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +79 -68
  72. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  73. package/dist/lib/mysql/schemas/content/content-resource-resource.js +6 -3
  74. package/dist/lib/mysql/schemas/content/content-resource.cjs +103 -92
  75. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  76. package/dist/lib/mysql/schemas/content/content-resource.js +6 -3
  77. package/package.json +2 -2
  78. package/src/lib/mysql/index.ts +456 -95
  79. package/src/lib/mysql/schemas/commerce/coupon.ts +18 -1
  80. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +29 -1
  81. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +29 -1
  82. package/dist/chunk-PJHGIRZM.js +0 -50
@@ -8,11 +8,11 @@ var __export = (target, all) => {
8
8
  for (var name in all)
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
- var __copyProps = (to, from, except, desc) => {
11
+ var __copyProps = (to, from, except, desc2) => {
12
12
  if (from && typeof from === "object" || typeof from === "function") {
13
13
  for (let key of __getOwnPropNames(from))
14
14
  if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
16
16
  }
17
17
  return to;
18
18
  };
@@ -624,11 +624,11 @@ var _ZodType = class _ZodType {
624
624
  throw result.error;
625
625
  }
626
626
  safeParse(data, params) {
627
- var _a41;
627
+ var _a46;
628
628
  const ctx = {
629
629
  common: {
630
630
  issues: [],
631
- async: (_a41 = params === null || params === void 0 ? void 0 : params.async) !== null && _a41 !== void 0 ? _a41 : false,
631
+ async: (_a46 = params === null || params === void 0 ? void 0 : params.async) !== null && _a46 !== void 0 ? _a46 : false,
632
632
  contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
633
633
  },
634
634
  path: (params === null || params === void 0 ? void 0 : params.path) || [],
@@ -973,7 +973,7 @@ var _ZodString = class _ZodString extends ZodType {
973
973
  } else if (check.kind === "url") {
974
974
  try {
975
975
  new URL(input.data);
976
- } catch (_a41) {
976
+ } catch (_a46) {
977
977
  ctx = this._getOrReturnCtx(input, ctx);
978
978
  addIssueToContext(ctx, {
979
979
  validation: "url",
@@ -1095,7 +1095,7 @@ var _ZodString = class _ZodString extends ZodType {
1095
1095
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1096
1096
  }
1097
1097
  datetime(options) {
1098
- var _a41;
1098
+ var _a46;
1099
1099
  if (typeof options === "string") {
1100
1100
  return this._addCheck({
1101
1101
  kind: "datetime",
@@ -1107,7 +1107,7 @@ var _ZodString = class _ZodString extends ZodType {
1107
1107
  return this._addCheck({
1108
1108
  kind: "datetime",
1109
1109
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1110
- offset: (_a41 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a41 !== void 0 ? _a41 : false,
1110
+ offset: (_a46 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a46 !== void 0 ? _a46 : false,
1111
1111
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1112
1112
  });
1113
1113
  }
@@ -1237,11 +1237,11 @@ var _ZodString = class _ZodString extends ZodType {
1237
1237
  __name(_ZodString, "ZodString");
1238
1238
  var ZodString = _ZodString;
1239
1239
  ZodString.create = (params) => {
1240
- var _a41;
1240
+ var _a46;
1241
1241
  return new ZodString({
1242
1242
  checks: [],
1243
1243
  typeName: ZodFirstPartyTypeKind.ZodString,
1244
- coerce: (_a41 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a41 !== void 0 ? _a41 : false,
1244
+ coerce: (_a46 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a46 !== void 0 ? _a46 : false,
1245
1245
  ...processCreateParams(params)
1246
1246
  });
1247
1247
  };
@@ -1647,11 +1647,11 @@ var _ZodBigInt = class _ZodBigInt extends ZodType {
1647
1647
  __name(_ZodBigInt, "ZodBigInt");
1648
1648
  var ZodBigInt = _ZodBigInt;
1649
1649
  ZodBigInt.create = (params) => {
1650
- var _a41;
1650
+ var _a46;
1651
1651
  return new ZodBigInt({
1652
1652
  checks: [],
1653
1653
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
1654
- coerce: (_a41 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a41 !== void 0 ? _a41 : false,
1654
+ coerce: (_a46 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a46 !== void 0 ? _a46 : false,
1655
1655
  ...processCreateParams(params)
1656
1656
  });
1657
1657
  };
@@ -2178,8 +2178,8 @@ var _ZodObject = class _ZodObject extends ZodType {
2178
2178
  unknownKeys: "strict",
2179
2179
  ...message !== void 0 ? {
2180
2180
  errorMap: (issue, ctx) => {
2181
- var _a41, _b, _c, _d;
2182
- const defaultError = (_c = (_b = (_a41 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a41, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2181
+ var _a46, _b, _c, _d;
2182
+ const defaultError = (_c = (_b = (_a46 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a46, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2183
2183
  if (issue.code === "unrecognized_keys")
2184
2184
  return {
2185
2185
  message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
@@ -3641,10 +3641,10 @@ ZodReadonly.create = (type, params) => {
3641
3641
  var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
3642
3642
  if (check)
3643
3643
  return ZodAny.create().superRefine((data, ctx) => {
3644
- var _a41, _b;
3644
+ var _a46, _b;
3645
3645
  if (!check(data)) {
3646
3646
  const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3647
- const _fatal = (_b = (_a41 = p.fatal) !== null && _a41 !== void 0 ? _a41 : fatal) !== null && _b !== void 0 ? _b : true;
3647
+ const _fatal = (_b = (_a46 = p.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
3648
3648
  const p2 = typeof p === "string" ? { message: p } : p;
3649
3649
  ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
3650
3650
  }
@@ -3862,12 +3862,22 @@ var z = /* @__PURE__ */ Object.freeze({
3862
3862
 
3863
3863
  // ../core/dist/chunk-VLQXSCFN.js
3864
3864
  var __defProp2 = Object.defineProperty;
3865
+ var __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, {
3866
+ enumerable: true,
3867
+ configurable: true,
3868
+ writable: true,
3869
+ value
3870
+ }) : obj[key] = value, "__defNormalProp");
3865
3871
  var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", {
3866
3872
  value,
3867
3873
  configurable: true
3868
3874
  }), "__name");
3875
+ var __publicField = /* @__PURE__ */ __name((obj, key, value) => {
3876
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
3877
+ return value;
3878
+ }, "__publicField");
3869
3879
 
3870
- // ../core/dist/chunk-KQBRKKMR.js
3880
+ // ../core/dist/chunk-GH4VK5VM.js
3871
3881
  var util2;
3872
3882
  (function(util22) {
3873
3883
  util22.assertEqual = (val) => val;
@@ -4521,11 +4531,11 @@ var _ZodType2 = (_a4 = class {
4521
4531
  throw result.error;
4522
4532
  }
4523
4533
  safeParse(data, params) {
4524
- var _a41;
4534
+ var _a46;
4525
4535
  const ctx = {
4526
4536
  common: {
4527
4537
  issues: [],
4528
- async: (_a41 = params === null || params === void 0 ? void 0 : params.async) !== null && _a41 !== void 0 ? _a41 : false,
4538
+ async: (_a46 = params === null || params === void 0 ? void 0 : params.async) !== null && _a46 !== void 0 ? _a46 : false,
4529
4539
  contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
4530
4540
  },
4531
4541
  path: (params === null || params === void 0 ? void 0 : params.path) || [],
@@ -4887,7 +4897,7 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
4887
4897
  } else if (check.kind === "url") {
4888
4898
  try {
4889
4899
  new URL(input.data);
4890
- } catch (_a41) {
4900
+ } catch (_a46) {
4891
4901
  ctx = this._getOrReturnCtx(input, ctx);
4892
4902
  addIssueToContext2(ctx, {
4893
4903
  validation: "url",
@@ -5046,7 +5056,7 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5046
5056
  });
5047
5057
  }
5048
5058
  datetime(options) {
5049
- var _a41;
5059
+ var _a46;
5050
5060
  if (typeof options === "string") {
5051
5061
  return this._addCheck({
5052
5062
  kind: "datetime",
@@ -5058,7 +5068,7 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5058
5068
  return this._addCheck({
5059
5069
  kind: "datetime",
5060
5070
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
5061
- offset: (_a41 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a41 !== void 0 ? _a41 : false,
5071
+ offset: (_a46 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a46 !== void 0 ? _a46 : false,
5062
5072
  ...errorUtil2.errToObj(options === null || options === void 0 ? void 0 : options.message)
5063
5073
  });
5064
5074
  }
@@ -5203,11 +5213,11 @@ var _ZodString2 = (_a5 = class extends ZodType2 {
5203
5213
  __name2(_ZodString2, "ZodString");
5204
5214
  var ZodString2 = _ZodString2;
5205
5215
  ZodString2.create = (params) => {
5206
- var _a41;
5216
+ var _a46;
5207
5217
  return new ZodString2({
5208
5218
  checks: [],
5209
5219
  typeName: ZodFirstPartyTypeKind2.ZodString,
5210
- coerce: (_a41 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a41 !== void 0 ? _a41 : false,
5220
+ coerce: (_a46 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a46 !== void 0 ? _a46 : false,
5211
5221
  ...processCreateParams2(params)
5212
5222
  });
5213
5223
  };
@@ -5628,11 +5638,11 @@ var _ZodBigInt2 = (_a7 = class extends ZodType2 {
5628
5638
  __name2(_ZodBigInt2, "ZodBigInt");
5629
5639
  var ZodBigInt2 = _ZodBigInt2;
5630
5640
  ZodBigInt2.create = (params) => {
5631
- var _a41;
5641
+ var _a46;
5632
5642
  return new ZodBigInt2({
5633
5643
  checks: [],
5634
5644
  typeName: ZodFirstPartyTypeKind2.ZodBigInt,
5635
- coerce: (_a41 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a41 !== void 0 ? _a41 : false,
5645
+ coerce: (_a46 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a46 !== void 0 ? _a46 : false,
5636
5646
  ...processCreateParams2(params)
5637
5647
  });
5638
5648
  };
@@ -6199,8 +6209,8 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
6199
6209
  unknownKeys: "strict",
6200
6210
  ...message !== void 0 ? {
6201
6211
  errorMap: (issue, ctx) => {
6202
- var _a41, _b, _c, _d;
6203
- const defaultError = (_c = (_b = (_a41 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a41, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
6212
+ var _a46, _b, _c, _d;
6213
+ const defaultError = (_c = (_b = (_a46 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a46, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
6204
6214
  if (issue.code === "unrecognized_keys")
6205
6215
  return {
6206
6216
  message: (_d = errorUtil2.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
@@ -7795,12 +7805,12 @@ ZodReadonly2.create = (type, params) => {
7795
7805
  var custom2 = /* @__PURE__ */ __name2((check, params = {}, fatal) => {
7796
7806
  if (check)
7797
7807
  return ZodAny2.create().superRefine((data, ctx) => {
7798
- var _a41, _b;
7808
+ var _a46, _b;
7799
7809
  if (!check(data)) {
7800
7810
  const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
7801
7811
  message: params
7802
7812
  } : params;
7803
- const _fatal = (_b = (_a41 = p.fatal) !== null && _a41 !== void 0 ? _a41 : fatal) !== null && _b !== void 0 ? _b : true;
7813
+ const _fatal = (_b = (_a46 = p.fatal) !== null && _a46 !== void 0 ? _a46 : fatal) !== null && _b !== void 0 ? _b : true;
7804
7814
  const p2 = typeof p === "string" ? {
7805
7815
  message: p
7806
7816
  } : p;
@@ -8034,7 +8044,7 @@ var z2 = /* @__PURE__ */ Object.freeze({
8034
8044
  ZodError: ZodError2
8035
8045
  });
8036
8046
 
8037
- // ../core/dist/chunk-OMI2MGEL.js
8047
+ // ../core/dist/chunk-LMH5A7OR.js
8038
8048
  var purchaseUserTransferSchema = z2.object({
8039
8049
  id: z2.string().max(191),
8040
8050
  transferState: z2.enum([
@@ -8056,7 +8066,51 @@ var purchaseUserTransferSchema = z2.object({
8056
8066
  completedAt: z2.date().nullable()
8057
8067
  });
8058
8068
 
8059
- // ../core/dist/chunk-UKYAUN7W.js
8069
+ // ../core/dist/chunk-YYIPQN6H.js
8070
+ var ContentResourceResourceSchema = z2.object({
8071
+ resourceId: z2.string(),
8072
+ resourceOfId: z2.string(),
8073
+ position: z2.number().default(0),
8074
+ metadata: z2.record(z2.string(), z2.any()).default({}).nullable(),
8075
+ createdAt: z2.date().nullable(),
8076
+ updatedAt: z2.date().nullable(),
8077
+ deletedAt: z2.date().nullable(),
8078
+ resource: z2.any()
8079
+ });
8080
+ var ContentResourceSchema = z2.object({
8081
+ id: z2.string(),
8082
+ type: z2.string(),
8083
+ createdById: z2.string(),
8084
+ fields: z2.record(z2.string(), z2.any()).default({}).nullable().optional(),
8085
+ createdAt: z2.date().nullable(),
8086
+ updatedAt: z2.date().nullable(),
8087
+ deletedAt: z2.date().nullable(),
8088
+ resources: z2.array(ContentResourceResourceSchema).default([]).nullable()
8089
+ });
8090
+ var ContentResourceProductSchema = z2.object({
8091
+ resourceId: z2.string(),
8092
+ productId: z2.string(),
8093
+ position: z2.number().default(0),
8094
+ metadata: z2.record(z2.string(), z2.any()).default({}).nullable(),
8095
+ createdAt: z2.date().nullable(),
8096
+ updatedAt: z2.date().nullable(),
8097
+ deletedAt: z2.date().nullable(),
8098
+ resource: z2.any(),
8099
+ product: z2.any()
8100
+ });
8101
+ var ResourceStateSchema = z2.union([
8102
+ z2.literal("draft"),
8103
+ z2.literal("published"),
8104
+ z2.literal("archived"),
8105
+ z2.literal("deleted")
8106
+ ]);
8107
+ var ResourceVisibilitySchema = z2.union([
8108
+ z2.literal("public"),
8109
+ z2.literal("private"),
8110
+ z2.literal("unlisted")
8111
+ ]);
8112
+
8113
+ // ../core/dist/chunk-GCYJ74DO.js
8060
8114
  var resourceProgressSchema = z2.object({
8061
8115
  userId: z2.string().max(191),
8062
8116
  contentResourceId: z2.string().max(191).optional().nullable(),
@@ -8065,8 +8119,15 @@ var resourceProgressSchema = z2.object({
8065
8119
  updatedAt: z2.date().nullable(),
8066
8120
  createdAt: z2.date().nullable()
8067
8121
  });
8122
+ var moduleProgressSchema = z2.object({
8123
+ completedLessons: z2.array(resourceProgressSchema),
8124
+ nextResource: ContentResourceSchema.nullable(),
8125
+ percentCompleted: z2.number().default(0),
8126
+ completedLessonsCount: z2.number().default(0),
8127
+ totalLessonsCount: z2.number().default(0)
8128
+ });
8068
8129
 
8069
- // ../core/dist/chunk-3K3P6UHD.js
8130
+ // ../core/dist/chunk-DLQA3JMA.js
8070
8131
  var upgradableProductSchema = z2.object({
8071
8132
  upgradableToId: z2.string().max(255),
8072
8133
  upgradableFromId: z2.string().max(255),
@@ -8077,7 +8138,7 @@ var upgradableProductSchema = z2.object({
8077
8138
  deletedAt: z2.date().nullable()
8078
8139
  });
8079
8140
 
8080
- // ../core/dist/chunk-QWXG37EL.js
8141
+ // ../core/dist/chunk-G22WGQ3G.js
8081
8142
  var VideoResourceSchema = z2.object({
8082
8143
  id: z2.string(),
8083
8144
  updatedAt: z2.string().optional(),
@@ -8099,7 +8160,7 @@ var VideoResourceSchema = z2.object({
8099
8160
  ])
8100
8161
  });
8101
8162
 
8102
- // ../core/dist/chunk-QWVS7RLZ.js
8163
+ // ../core/dist/chunk-PS6USEN7.js
8103
8164
  var merchantPriceSchema = z2.object({
8104
8165
  id: z2.string().max(191),
8105
8166
  merchantAccountId: z2.string().max(191),
@@ -8110,7 +8171,7 @@ var merchantPriceSchema = z2.object({
8110
8171
  priceId: z2.string().max(191).optional().nullable()
8111
8172
  });
8112
8173
 
8113
- // ../core/dist/chunk-5FAFQVN5.js
8174
+ // ../core/dist/chunk-DAG4HKGL.js
8114
8175
  var merchantProductSchema = z2.object({
8115
8176
  id: z2.string().max(191),
8116
8177
  merchantAccountId: z2.string().max(191),
@@ -8120,7 +8181,7 @@ var merchantProductSchema = z2.object({
8120
8181
  createdAt: z2.date().nullable()
8121
8182
  });
8122
8183
 
8123
- // ../core/dist/chunk-E2O65L6F.js
8184
+ // ../core/dist/chunk-CHYUPSYW.js
8124
8185
  var userSchema = z2.object({
8125
8186
  id: z2.string().max(255),
8126
8187
  name: z2.string().max(255).optional().nullable(),
@@ -8129,12 +8190,18 @@ var userSchema = z2.object({
8129
8190
  "admin"
8130
8191
  ]).default("user"),
8131
8192
  email: z2.string().max(255).email(),
8132
- emailVerified: z2.date().nullable(),
8193
+ emailVerified: z2.coerce.date().nullable(),
8133
8194
  image: z2.string().max(255).optional().nullable(),
8134
- createdAt: z2.date().nullable()
8195
+ createdAt: z2.coerce.date().nullable(),
8196
+ roles: z2.array(z2.object({
8197
+ id: z2.string(),
8198
+ name: z2.string(),
8199
+ description: z2.string().nullable(),
8200
+ active: z2.boolean()
8201
+ })).optional().default([])
8135
8202
  });
8136
8203
 
8137
- // ../core/dist/chunk-BEN776QX.js
8204
+ // ../core/dist/chunk-47RWEDJ6.js
8138
8205
  var priceSchema = z2.object({
8139
8206
  id: z2.string().max(191),
8140
8207
  productId: z2.string().max(191).optional().nullable(),
@@ -8148,51 +8215,7 @@ var priceSchema = z2.object({
8148
8215
  fields: z2.record(z2.any()).default({})
8149
8216
  });
8150
8217
 
8151
- // ../core/dist/chunk-DBONTSXM.js
8152
- var ContentResourceResourceSchema = z2.object({
8153
- resourceId: z2.string(),
8154
- resourceOfId: z2.string(),
8155
- position: z2.number().default(0),
8156
- metadata: z2.record(z2.string(), z2.any()).default({}).nullable(),
8157
- createdAt: z2.date().nullable(),
8158
- updatedAt: z2.date().nullable(),
8159
- deletedAt: z2.date().nullable(),
8160
- resource: z2.any()
8161
- });
8162
- var ContentResourceSchema = z2.object({
8163
- id: z2.string(),
8164
- type: z2.string(),
8165
- createdById: z2.string(),
8166
- fields: z2.record(z2.string(), z2.any()).default({}).nullable().optional(),
8167
- createdAt: z2.date().nullable(),
8168
- updatedAt: z2.date().nullable(),
8169
- deletedAt: z2.date().nullable(),
8170
- resources: z2.array(ContentResourceResourceSchema).default([]).nullable()
8171
- });
8172
- var ContentResourceProductSchema = z2.object({
8173
- resourceId: z2.string(),
8174
- productId: z2.string(),
8175
- position: z2.number().default(0),
8176
- metadata: z2.record(z2.string(), z2.any()).default({}).nullable(),
8177
- createdAt: z2.date().nullable(),
8178
- updatedAt: z2.date().nullable(),
8179
- deletedAt: z2.date().nullable(),
8180
- resource: z2.any(),
8181
- product: z2.any()
8182
- });
8183
- var ResourceStateSchema = z2.union([
8184
- z2.literal("draft"),
8185
- z2.literal("published"),
8186
- z2.literal("archived"),
8187
- z2.literal("deleted")
8188
- ]);
8189
- var ResourceVisibilitySchema = z2.union([
8190
- z2.literal("public"),
8191
- z2.literal("private"),
8192
- z2.literal("unlisted")
8193
- ]);
8194
-
8195
- // ../core/dist/chunk-EHEPZVSG.js
8218
+ // ../core/dist/chunk-DGMGNBW7.js
8196
8219
  var productSchema = z2.object({
8197
8220
  id: z2.string().max(191),
8198
8221
  name: z2.string().max(191),
@@ -8208,8 +8231,8 @@ var productSchema = z2.object({
8208
8231
  image: z2.object({
8209
8232
  url: z2.string().url(),
8210
8233
  alt: z2.string().optional().nullable(),
8211
- width: z2.number(),
8212
- height: z2.number()
8234
+ width: z2.number().optional().nullable(),
8235
+ height: z2.number().optional().nullable()
8213
8236
  }).optional().nullable(),
8214
8237
  action: z2.string().optional().nullable().default("Buy Now"),
8215
8238
  state: z2.enum([
@@ -8231,7 +8254,7 @@ var productSchema = z2.object({
8231
8254
  resources: z2.array(ContentResourceProductSchema).default([]).nullable()
8232
8255
  });
8233
8256
 
8234
- // ../core/dist/chunk-VQL6W6PO.js
8257
+ // ../core/dist/chunk-VDB4YSMY.js
8235
8258
  var couponSchema = z2.object({
8236
8259
  id: z2.string(),
8237
8260
  code: z2.string().max(191).optional().nullable(),
@@ -8252,7 +8275,7 @@ var couponSchema = z2.object({
8252
8275
  bulkCouponPurchases: z2.any().optional().nullable()
8253
8276
  });
8254
8277
 
8255
- // ../core/dist/chunk-L7DZR25Q.js
8278
+ // ../core/dist/chunk-OUYYSWMK.js
8256
8279
  var purchaseSchema = z2.object({
8257
8280
  id: z2.string().max(191),
8258
8281
  userId: z2.string().max(191).optional().nullable(),
@@ -8279,7 +8302,7 @@ var purchaseSchema = z2.object({
8279
8302
  product: productSchema.optional().nullable()
8280
8303
  });
8281
8304
 
8282
- // ../core/dist/chunk-5RZIDLCA.js
8305
+ // ../core/dist/chunk-SGE7BCRS.js
8283
8306
  var merchantChargeSchema = z2.object({
8284
8307
  id: z2.string().max(191),
8285
8308
  status: z2.number().int().default(0),
@@ -8291,7 +8314,17 @@ var merchantChargeSchema = z2.object({
8291
8314
  merchantCustomerId: z2.string().max(191)
8292
8315
  });
8293
8316
 
8294
- // ../core/dist/chunk-GSATJJT4.js
8317
+ // ../core/dist/chunk-EDDT2FFU.js
8318
+ var merchantCustomerSchema = z2.object({
8319
+ id: z2.string().max(191),
8320
+ userId: z2.string().max(191),
8321
+ merchantAccountId: z2.string().max(191),
8322
+ identifier: z2.string().max(191),
8323
+ createdAt: z2.date().nullable(),
8324
+ status: z2.number().int().default(0)
8325
+ });
8326
+
8327
+ // ../core/dist/chunk-256SROW3.js
8295
8328
  var merchantCouponSchema = z2.object({
8296
8329
  id: z2.string().max(191),
8297
8330
  identifier: z2.string().max(191).optional().nullable(),
@@ -8301,17 +8334,7 @@ var merchantCouponSchema = z2.object({
8301
8334
  const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8302
8335
  return decimalPlaces <= 2;
8303
8336
  }),
8304
- type: z2.string().max(191).optional().nullable()
8305
- });
8306
-
8307
- // ../core/dist/chunk-LQYMTPOB.js
8308
- var merchantCustomerSchema = z2.object({
8309
- id: z2.string().max(191),
8310
- userId: z2.string().max(191),
8311
- merchantAccountId: z2.string().max(191),
8312
- identifier: z2.string().max(191),
8313
- createdAt: z2.date().nullable(),
8314
- status: z2.number().int().default(0)
8337
+ type: z2.string().max(191)
8315
8338
  });
8316
8339
 
8317
8340
  // ../core/dist/schemas/merchant-account-schema.js
@@ -8323,6 +8346,107 @@ var merchantAccountSchema = z2.object({
8323
8346
  status: z2.number().int().default(0)
8324
8347
  });
8325
8348
 
8349
+ // ../core/dist/chunk-F32UWPXN.js
8350
+ var _a41;
8351
+ var _CourseBuilderError = (_a41 = class extends Error {
8352
+ constructor(message, errorOptions) {
8353
+ var __super = /* @__PURE__ */ __name((...args) => {
8354
+ super(...args);
8355
+ __publicField(this, "type");
8356
+ __publicField(this, "kind");
8357
+ __publicField(this, "cause");
8358
+ return this;
8359
+ }, "__super");
8360
+ if (message instanceof Error) {
8361
+ __super(void 0, {
8362
+ cause: {
8363
+ err: message,
8364
+ ...message.cause,
8365
+ ...errorOptions
8366
+ }
8367
+ });
8368
+ } else if (typeof message === "string") {
8369
+ if (errorOptions instanceof Error) {
8370
+ errorOptions = {
8371
+ err: errorOptions,
8372
+ ...errorOptions.cause
8373
+ };
8374
+ }
8375
+ __super(message, errorOptions);
8376
+ } else {
8377
+ __super(void 0, message);
8378
+ }
8379
+ this.name = this.constructor.name;
8380
+ this.type = this.constructor.type ?? "CourseBuilderError";
8381
+ this.kind = this.constructor.kind ?? "error";
8382
+ Error.captureStackTrace?.(this, this.constructor);
8383
+ const url = `https://errors.authjs.dev#${this.type.toLowerCase()}`;
8384
+ this.message += `${this.message ? ". " : ""}Read more at ${url}`;
8385
+ }
8386
+ }, __name(_a41, "_CourseBuilderError"), _a41);
8387
+ __name2(_CourseBuilderError, "CourseBuilderError");
8388
+ var CourseBuilderError = _CourseBuilderError;
8389
+ var _a42;
8390
+ var _AdapterError = (_a42 = class extends CourseBuilderError {
8391
+ }, __name(_a42, "_AdapterError"), _a42);
8392
+ __name2(_AdapterError, "AdapterError");
8393
+ __publicField(_AdapterError, "type", "AdapterError");
8394
+ var _a43;
8395
+ var _UnsupportedStrategy = (_a43 = class extends CourseBuilderError {
8396
+ }, __name(_a43, "_UnsupportedStrategy"), _a43);
8397
+ __name2(_UnsupportedStrategy, "UnsupportedStrategy");
8398
+ __publicField(_UnsupportedStrategy, "type", "UnsupportedStrategy");
8399
+ var _a44;
8400
+ var _MissingAdapter = (_a44 = class extends CourseBuilderError {
8401
+ }, __name(_a44, "_MissingAdapter"), _a44);
8402
+ __name2(_MissingAdapter, "MissingAdapter");
8403
+ __publicField(_MissingAdapter, "type", "MissingAdapter");
8404
+ var _a45;
8405
+ var _MissingAdapterMethods = (_a45 = class extends CourseBuilderError {
8406
+ }, __name(_a45, "_MissingAdapterMethods"), _a45);
8407
+ __name2(_MissingAdapterMethods, "MissingAdapterMethods");
8408
+ __publicField(_MissingAdapterMethods, "type", "MissingAdapterMethods");
8409
+
8410
+ // ../core/dist/chunk-B73XG2UO.js
8411
+ var red = "\x1B[31m";
8412
+ var yellow = "\x1B[33m";
8413
+ var grey = "\x1B[38;5;246m";
8414
+ var reset = "\x1B[0m";
8415
+ var logger = {
8416
+ error(error) {
8417
+ const name = error instanceof CourseBuilderError ? error.type : error.name;
8418
+ console.error(`${red}[coursebuilder][error]${reset} ${name}: ${error.message}`);
8419
+ if (error.cause && typeof error.cause === "object" && "err" in error.cause && error.cause.err instanceof Error) {
8420
+ const { err, ...data } = error.cause;
8421
+ console.error(`${red}[coursebuilder][cause]${reset}:`, err.stack);
8422
+ if (data)
8423
+ console.error(`${red}[coursebuilder][details]${reset}:`, JSON.stringify(data, null, 2));
8424
+ } else if (error.stack) {
8425
+ console.error(error.stack.replace(/.*/, "").substring(1));
8426
+ }
8427
+ },
8428
+ warn(code) {
8429
+ const url = `https://warnings.coursebuilder.dev#${code}`;
8430
+ console.warn(`${yellow}[coursebuilder][warn][${code}]${reset}`, `Read more: ${url}`);
8431
+ },
8432
+ debug(message, metadata) {
8433
+ console.log(`${grey}[coursebuilder][debug]:${reset} ${message}`, JSON.stringify(metadata, null, 2));
8434
+ }
8435
+ };
8436
+ function setLogger(newLogger = {}, debug) {
8437
+ if (!debug)
8438
+ logger.debug = () => {
8439
+ };
8440
+ if (newLogger.error)
8441
+ logger.error = newLogger.error;
8442
+ if (newLogger.warn)
8443
+ logger.warn = newLogger.warn;
8444
+ if (newLogger.debug)
8445
+ logger.debug = newLogger.debug;
8446
+ }
8447
+ __name(setLogger, "setLogger");
8448
+ __name2(setLogger, "setLogger");
8449
+
8326
8450
  // ../core/dist/lib/utils/validate-coupon.js
8327
8451
  var import_date_fns = require("date-fns");
8328
8452
  var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
@@ -8352,200 +8476,109 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
8352
8476
  }, "validateCoupon");
8353
8477
 
8354
8478
  // src/lib/mysql/schemas/auth/accounts.ts
8355
- var import_drizzle_orm19 = require("drizzle-orm");
8356
- var import_mysql_core22 = require("drizzle-orm/mysql-core");
8479
+ var import_drizzle_orm21 = require("drizzle-orm");
8480
+ var import_mysql_core25 = require("drizzle-orm/mysql-core");
8357
8481
 
8358
8482
  // src/lib/mysql/schemas/auth/users.ts
8359
- var import_drizzle_orm18 = require("drizzle-orm");
8360
- var import_mysql_core21 = require("drizzle-orm/mysql-core");
8483
+ var import_drizzle_orm20 = require("drizzle-orm");
8484
+ var import_mysql_core24 = require("drizzle-orm/mysql-core");
8361
8485
 
8362
8486
  // src/lib/mysql/schemas/commerce/purchase.ts
8363
- var import_drizzle_orm10 = require("drizzle-orm");
8364
- var import_mysql_core11 = require("drizzle-orm/mysql-core");
8487
+ var import_drizzle_orm12 = require("drizzle-orm");
8488
+ var import_mysql_core14 = require("drizzle-orm/mysql-core");
8365
8489
 
8366
8490
  // src/lib/mysql/schemas/commerce/coupon.ts
8367
- var import_drizzle_orm = require("drizzle-orm");
8491
+ var import_drizzle_orm8 = require("drizzle-orm");
8492
+ var import_mysql_core9 = require("drizzle-orm/mysql-core");
8493
+
8494
+ // src/lib/mysql/schemas/commerce/merchant-coupon.ts
8368
8495
  var import_mysql_core = require("drizzle-orm/mysql-core");
8369
- function getCouponSchema(mysqlTable) {
8370
- return mysqlTable("coupons", {
8496
+ function getMerchantCouponSchema(mysqlTable) {
8497
+ return mysqlTable("merchantCoupons", {
8371
8498
  id: (0, import_mysql_core.varchar)("id", {
8372
8499
  length: 191
8373
8500
  }).notNull(),
8374
- code: (0, import_mysql_core.varchar)("code", {
8375
- length: 191
8376
- }),
8377
- createdAt: (0, import_mysql_core.timestamp)("createdAt", {
8378
- mode: "date",
8379
- fsp: 3
8380
- }).default(import_drizzle_orm.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8381
- expires: (0, import_mysql_core.timestamp)("expires", {
8382
- mode: "date",
8383
- fsp: 3
8384
- }),
8385
- fields: (0, import_mysql_core.json)("fields").$type().default({}),
8386
- maxUses: (0, import_mysql_core.int)("maxUses").default(-1).notNull(),
8387
- default: (0, import_mysql_core.boolean)("default").default(false).notNull(),
8388
- merchantCouponId: (0, import_mysql_core.varchar)("merchantCouponId", {
8501
+ identifier: (0, import_mysql_core.varchar)("identifier", {
8389
8502
  length: 191
8390
8503
  }),
8391
8504
  status: (0, import_mysql_core.int)("status").default(0).notNull(),
8392
- usedCount: (0, import_mysql_core.int)("usedCount").default(0).notNull(),
8505
+ merchantAccountId: (0, import_mysql_core.varchar)("merchantAccountId", {
8506
+ length: 191
8507
+ }).notNull(),
8393
8508
  percentageDiscount: (0, import_mysql_core.decimal)("percentageDiscount", {
8394
8509
  precision: 3,
8395
8510
  scale: 2
8396
8511
  }).notNull(),
8397
- restrictedToProductId: (0, import_mysql_core.varchar)("restrictedToProductId", {
8398
- length: 191
8399
- }),
8400
- bulkPurchaseId: (0, import_mysql_core.varchar)("bulkPurchaseId", {
8512
+ type: (0, import_mysql_core.varchar)("type", {
8401
8513
  length: 191
8402
8514
  })
8403
8515
  }, (table) => {
8404
8516
  return {
8405
- couponId: (0, import_mysql_core.primaryKey)({
8406
- columns: [
8407
- table.id
8408
- ],
8409
- name: "Coupon_id"
8410
- }),
8411
- couponBulkPurchaseIdKey: (0, import_mysql_core.unique)("Coupon_bulkPurchaseId_key").on(table.bulkPurchaseId),
8412
- couponCodeKey: (0, import_mysql_core.unique)("Coupon_code_key").on(table.code)
8413
- };
8414
- });
8415
- }
8416
- __name(getCouponSchema, "getCouponSchema");
8417
- function getCouponRelationsSchema(mysqlTable) {
8418
- const purchase = getPurchaseSchema(mysqlTable);
8419
- const coupon = getCouponSchema(mysqlTable);
8420
- return (0, import_drizzle_orm.relations)(coupon, ({ many }) => ({
8421
- bulkCouponPurchases: many(purchase, {
8422
- relationName: "redeemedBulkCoupon"
8423
- })
8424
- }));
8425
- }
8426
- __name(getCouponRelationsSchema, "getCouponRelationsSchema");
8427
-
8428
- // src/lib/mysql/schemas/commerce/merchant-charge.ts
8429
- var import_drizzle_orm2 = require("drizzle-orm");
8430
- var import_mysql_core2 = require("drizzle-orm/mysql-core");
8431
- function getMerchantChargeSchema(mysqlTable) {
8432
- return mysqlTable("merchantCharges", {
8433
- id: (0, import_mysql_core2.varchar)("id", {
8434
- length: 191
8435
- }).notNull(),
8436
- status: (0, import_mysql_core2.int)("status").default(0).notNull(),
8437
- identifier: (0, import_mysql_core2.varchar)("identifier", {
8438
- length: 191
8439
- }).notNull(),
8440
- userId: (0, import_mysql_core2.varchar)("userId", {
8441
- length: 191
8442
- }).notNull(),
8443
- merchantAccountId: (0, import_mysql_core2.varchar)("merchantAccountId", {
8444
- length: 191
8445
- }).notNull(),
8446
- merchantProductId: (0, import_mysql_core2.varchar)("merchantProductId", {
8447
- length: 191
8448
- }).notNull(),
8449
- createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
8450
- mode: "date",
8451
- fsp: 3
8452
- }).default(import_drizzle_orm2.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8453
- merchantCustomerId: (0, import_mysql_core2.varchar)("merchantCustomerId", {
8454
- length: 191
8455
- }).notNull()
8456
- }, (table) => {
8457
- return {
8458
- merchantChargeId: (0, import_mysql_core2.primaryKey)({
8517
+ merchantCouponId: (0, import_mysql_core.primaryKey)({
8459
8518
  columns: [
8460
8519
  table.id
8461
8520
  ],
8462
- name: "MerchantCharge_id"
8521
+ name: "MerchantCoupon_id"
8463
8522
  }),
8464
- merchantChargeIdentifierKey: (0, import_mysql_core2.unique)("MerchantCharge_identifier_key").on(table.identifier)
8465
- };
8466
- });
8467
- }
8468
- __name(getMerchantChargeSchema, "getMerchantChargeSchema");
8469
-
8470
- // src/lib/mysql/schemas/commerce/merchant-session.ts
8471
- var import_mysql_core3 = require("drizzle-orm/mysql-core");
8472
- function getMerchantSessionSchema(mysqlTable) {
8473
- return mysqlTable("merchantSessions", {
8474
- id: (0, import_mysql_core3.varchar)("id", {
8475
- length: 191
8476
- }).notNull(),
8477
- identifier: (0, import_mysql_core3.varchar)("identifier", {
8478
- length: 191
8479
- }).notNull(),
8480
- merchantAccountId: (0, import_mysql_core3.varchar)("merchantAccountId", {
8481
- length: 191
8482
- }).notNull()
8483
- }, (table) => {
8484
- return {
8485
- merchantSessionId: (0, import_mysql_core3.primaryKey)({
8486
- columns: [
8487
- table.id
8488
- ],
8489
- name: "MerchantSession_id"
8490
- })
8523
+ merchantCouponIdentifierKey: (0, import_mysql_core.unique)("MerchantCoupon_identifier_key").on(table.identifier)
8491
8524
  };
8492
8525
  });
8493
8526
  }
8494
- __name(getMerchantSessionSchema, "getMerchantSessionSchema");
8527
+ __name(getMerchantCouponSchema, "getMerchantCouponSchema");
8495
8528
 
8496
8529
  // src/lib/mysql/schemas/commerce/product.ts
8497
- var import_drizzle_orm9 = require("drizzle-orm");
8498
- var import_mysql_core10 = require("drizzle-orm/mysql-core");
8530
+ var import_drizzle_orm7 = require("drizzle-orm");
8531
+ var import_mysql_core8 = require("drizzle-orm/mysql-core");
8499
8532
 
8500
8533
  // src/lib/mysql/schemas/content/content-resource-product.ts
8501
- var import_drizzle_orm5 = require("drizzle-orm");
8502
- var import_mysql_core6 = require("drizzle-orm/mysql-core");
8534
+ var import_drizzle_orm3 = require("drizzle-orm");
8535
+ var import_mysql_core4 = require("drizzle-orm/mysql-core");
8503
8536
 
8504
8537
  // src/lib/mysql/schemas/content/content-resource.ts
8505
- var import_drizzle_orm4 = require("drizzle-orm");
8506
- var import_mysql_core5 = require("drizzle-orm/mysql-core");
8538
+ var import_drizzle_orm2 = require("drizzle-orm");
8539
+ var import_mysql_core3 = require("drizzle-orm/mysql-core");
8507
8540
 
8508
8541
  // src/lib/mysql/schemas/content/content-resource-resource.ts
8509
- var import_drizzle_orm3 = require("drizzle-orm");
8510
- var import_mysql_core4 = require("drizzle-orm/mysql-core");
8542
+ var import_drizzle_orm = require("drizzle-orm");
8543
+ var import_mysql_core2 = require("drizzle-orm/mysql-core");
8511
8544
  function getContentResourceResourceSchema(mysqlTable) {
8512
8545
  return mysqlTable("contentResourceResource", {
8513
- resourceOfId: (0, import_mysql_core4.varchar)("resourceOfId", {
8546
+ resourceOfId: (0, import_mysql_core2.varchar)("resourceOfId", {
8514
8547
  length: 255
8515
8548
  }).notNull(),
8516
- resourceId: (0, import_mysql_core4.varchar)("resourceId", {
8549
+ resourceId: (0, import_mysql_core2.varchar)("resourceId", {
8517
8550
  length: 255
8518
8551
  }).notNull(),
8519
- position: (0, import_mysql_core4.double)("position").notNull().default(0),
8520
- metadata: (0, import_mysql_core4.json)("metadata").$type().default({}),
8521
- createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
8552
+ position: (0, import_mysql_core2.double)("position").notNull().default(0),
8553
+ metadata: (0, import_mysql_core2.json)("metadata").$type().default({}),
8554
+ createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
8522
8555
  mode: "date",
8523
8556
  fsp: 3
8524
- }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
8525
- updatedAt: (0, import_mysql_core4.timestamp)("updatedAt", {
8557
+ }).default(import_drizzle_orm.sql`CURRENT_TIMESTAMP(3)`),
8558
+ updatedAt: (0, import_mysql_core2.timestamp)("updatedAt", {
8526
8559
  mode: "date",
8527
8560
  fsp: 3
8528
- }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
8529
- deletedAt: (0, import_mysql_core4.timestamp)("deletedAt", {
8561
+ }).default(import_drizzle_orm.sql`CURRENT_TIMESTAMP(3)`),
8562
+ deletedAt: (0, import_mysql_core2.timestamp)("deletedAt", {
8530
8563
  mode: "date",
8531
8564
  fsp: 3
8532
8565
  })
8533
8566
  }, (crr) => ({
8534
- pk: (0, import_mysql_core4.primaryKey)({
8567
+ pk: (0, import_mysql_core2.primaryKey)({
8535
8568
  columns: [
8536
8569
  crr.resourceOfId,
8537
8570
  crr.resourceId
8538
8571
  ]
8539
8572
  }),
8540
- contentResourceIdIdx: (0, import_mysql_core4.index)("contentResourceId_idx").on(crr.resourceOfId),
8541
- resourceIdIdx: (0, import_mysql_core4.index)("resourceId_idx").on(crr.resourceId)
8573
+ contentResourceIdIdx: (0, import_mysql_core2.index)("contentResourceId_idx").on(crr.resourceOfId),
8574
+ resourceIdIdx: (0, import_mysql_core2.index)("resourceId_idx").on(crr.resourceId)
8542
8575
  }));
8543
8576
  }
8544
8577
  __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
8545
8578
  function getContentResourceResourceRelationsSchema(mysqlTable) {
8546
8579
  const contentResource = getContentResourceSchema(mysqlTable);
8547
8580
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
8548
- return (0, import_drizzle_orm3.relations)(contentResourceResource, ({ one }) => ({
8581
+ return (0, import_drizzle_orm.relations)(contentResourceResource, ({ one }) => ({
8549
8582
  resourceOf: one(contentResource, {
8550
8583
  fields: [
8551
8584
  contentResourceResource.resourceOfId
@@ -8571,32 +8604,32 @@ __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRel
8571
8604
  // src/lib/mysql/schemas/content/content-resource.ts
8572
8605
  function getContentResourceSchema(mysqlTable) {
8573
8606
  return mysqlTable("contentResource", {
8574
- id: (0, import_mysql_core5.varchar)("id", {
8607
+ id: (0, import_mysql_core3.varchar)("id", {
8575
8608
  length: 255
8576
8609
  }).notNull().primaryKey(),
8577
- type: (0, import_mysql_core5.varchar)("type", {
8610
+ type: (0, import_mysql_core3.varchar)("type", {
8578
8611
  length: 255
8579
8612
  }).notNull(),
8580
- createdById: (0, import_mysql_core5.varchar)("createdById", {
8613
+ createdById: (0, import_mysql_core3.varchar)("createdById", {
8581
8614
  length: 255
8582
8615
  }).notNull(),
8583
- fields: (0, import_mysql_core5.json)("fields").$type().default({}),
8584
- createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
8616
+ fields: (0, import_mysql_core3.json)("fields").$type().default({}),
8617
+ createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
8585
8618
  mode: "date",
8586
8619
  fsp: 3
8587
- }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`),
8588
- updatedAt: (0, import_mysql_core5.timestamp)("updatedAt", {
8620
+ }).default(import_drizzle_orm2.sql`CURRENT_TIMESTAMP(3)`),
8621
+ updatedAt: (0, import_mysql_core3.timestamp)("updatedAt", {
8589
8622
  mode: "date",
8590
8623
  fsp: 3
8591
- }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`),
8592
- deletedAt: (0, import_mysql_core5.timestamp)("deletedAt", {
8624
+ }).default(import_drizzle_orm2.sql`CURRENT_TIMESTAMP(3)`),
8625
+ deletedAt: (0, import_mysql_core3.timestamp)("deletedAt", {
8593
8626
  mode: "date",
8594
8627
  fsp: 3
8595
8628
  })
8596
8629
  }, (cm) => ({
8597
- typeIdx: (0, import_mysql_core5.index)("type_idx").on(cm.type),
8598
- createdByIdx: (0, import_mysql_core5.index)("createdById_idx").on(cm.createdById),
8599
- createdAtIdx: (0, import_mysql_core5.index)("createdAt_idx").on(cm.createdAt)
8630
+ typeIdx: (0, import_mysql_core3.index)("type_idx").on(cm.type),
8631
+ createdByIdx: (0, import_mysql_core3.index)("createdById_idx").on(cm.createdById),
8632
+ createdAtIdx: (0, import_mysql_core3.index)("createdAt_idx").on(cm.createdAt)
8600
8633
  }));
8601
8634
  }
8602
8635
  __name(getContentResourceSchema, "getContentResourceSchema");
@@ -8605,7 +8638,7 @@ function getContentResourceRelationsSchema(mysqlTable) {
8605
8638
  const users = getUsersSchema(mysqlTable);
8606
8639
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
8607
8640
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
8608
- return (0, import_drizzle_orm4.relations)(contentResource, ({ one, many }) => ({
8641
+ return (0, import_drizzle_orm2.relations)(contentResource, ({ one, many }) => ({
8609
8642
  createdBy: one(users, {
8610
8643
  fields: [
8611
8644
  contentResource.createdById
@@ -8631,35 +8664,35 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
8631
8664
  // src/lib/mysql/schemas/content/content-resource-product.ts
8632
8665
  function getContentResourceProductSchema(mysqlTable) {
8633
8666
  return mysqlTable("contentResourceProduct", {
8634
- productId: (0, import_mysql_core6.varchar)("productId", {
8667
+ productId: (0, import_mysql_core4.varchar)("productId", {
8635
8668
  length: 255
8636
8669
  }).notNull(),
8637
- resourceId: (0, import_mysql_core6.varchar)("resourceId", {
8670
+ resourceId: (0, import_mysql_core4.varchar)("resourceId", {
8638
8671
  length: 255
8639
8672
  }).notNull(),
8640
- position: (0, import_mysql_core6.double)("position").notNull().default(0),
8641
- metadata: (0, import_mysql_core6.json)("metadata").$type().default({}),
8642
- createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
8673
+ position: (0, import_mysql_core4.double)("position").notNull().default(0),
8674
+ metadata: (0, import_mysql_core4.json)("metadata").$type().default({}),
8675
+ createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
8643
8676
  mode: "date",
8644
8677
  fsp: 3
8645
- }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
8646
- updatedAt: (0, import_mysql_core6.timestamp)("updatedAt", {
8678
+ }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
8679
+ updatedAt: (0, import_mysql_core4.timestamp)("updatedAt", {
8647
8680
  mode: "date",
8648
8681
  fsp: 3
8649
- }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
8650
- deletedAt: (0, import_mysql_core6.timestamp)("deletedAt", {
8682
+ }).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
8683
+ deletedAt: (0, import_mysql_core4.timestamp)("deletedAt", {
8651
8684
  mode: "date",
8652
8685
  fsp: 3
8653
8686
  })
8654
8687
  }, (crr) => ({
8655
- pk: (0, import_mysql_core6.primaryKey)({
8688
+ pk: (0, import_mysql_core4.primaryKey)({
8656
8689
  columns: [
8657
8690
  crr.productId,
8658
8691
  crr.resourceId
8659
8692
  ]
8660
8693
  }),
8661
- contentResourceIdIdx: (0, import_mysql_core6.index)("contentResourceId_idx").on(crr.productId),
8662
- resourceIdIdx: (0, import_mysql_core6.index)("resourceId_idx").on(crr.resourceId)
8694
+ contentResourceIdIdx: (0, import_mysql_core4.index)("contentResourceId_idx").on(crr.productId),
8695
+ resourceIdIdx: (0, import_mysql_core4.index)("resourceId_idx").on(crr.resourceId)
8663
8696
  }));
8664
8697
  }
8665
8698
  __name(getContentResourceProductSchema, "getContentResourceProductSchema");
@@ -8667,7 +8700,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
8667
8700
  const contentResource = getContentResourceSchema(mysqlTable);
8668
8701
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
8669
8702
  const product = getProductSchema(mysqlTable);
8670
- return (0, import_drizzle_orm5.relations)(contentResourceProduct, ({ one }) => ({
8703
+ return (0, import_drizzle_orm3.relations)(contentResourceProduct, ({ one }) => ({
8671
8704
  product: one(product, {
8672
8705
  fields: [
8673
8706
  contentResourceProduct.productId
@@ -8691,79 +8724,79 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
8691
8724
  __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
8692
8725
 
8693
8726
  // src/lib/mysql/schemas/commerce/merchant-product.ts
8694
- var import_drizzle_orm6 = require("drizzle-orm");
8695
- var import_mysql_core7 = require("drizzle-orm/mysql-core");
8727
+ var import_drizzle_orm4 = require("drizzle-orm");
8728
+ var import_mysql_core5 = require("drizzle-orm/mysql-core");
8696
8729
  function getMerchantProductSchema(mysqlTable) {
8697
8730
  return mysqlTable("merchantProducts", {
8698
- id: (0, import_mysql_core7.varchar)("id", {
8731
+ id: (0, import_mysql_core5.varchar)("id", {
8699
8732
  length: 191
8700
8733
  }).notNull(),
8701
- merchantAccountId: (0, import_mysql_core7.varchar)("merchantAccountId", {
8734
+ merchantAccountId: (0, import_mysql_core5.varchar)("merchantAccountId", {
8702
8735
  length: 191
8703
8736
  }).notNull(),
8704
- productId: (0, import_mysql_core7.varchar)("productId", {
8737
+ productId: (0, import_mysql_core5.varchar)("productId", {
8705
8738
  length: 191
8706
8739
  }).notNull(),
8707
- status: (0, import_mysql_core7.int)("status").default(0).notNull(),
8708
- identifier: (0, import_mysql_core7.varchar)("identifier", {
8740
+ status: (0, import_mysql_core5.int)("status").default(0).notNull(),
8741
+ identifier: (0, import_mysql_core5.varchar)("identifier", {
8709
8742
  length: 191
8710
8743
  }),
8711
- createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
8744
+ createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
8712
8745
  mode: "date",
8713
8746
  fsp: 3
8714
- }).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull()
8747
+ }).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`).notNull()
8715
8748
  }, (table) => {
8716
8749
  return {
8717
- merchantProductId: (0, import_mysql_core7.primaryKey)({
8750
+ merchantProductId: (0, import_mysql_core5.primaryKey)({
8718
8751
  columns: [
8719
8752
  table.id
8720
8753
  ],
8721
8754
  name: "MerchantProduct_id"
8722
8755
  }),
8723
- merchantProductIdentifierKey: (0, import_mysql_core7.unique)("MerchantProduct_identifier_key").on(table.identifier)
8756
+ merchantProductIdentifierKey: (0, import_mysql_core5.unique)("MerchantProduct_identifier_key").on(table.identifier)
8724
8757
  };
8725
8758
  });
8726
8759
  }
8727
8760
  __name(getMerchantProductSchema, "getMerchantProductSchema");
8728
8761
 
8729
8762
  // src/lib/mysql/schemas/commerce/price.ts
8730
- var import_drizzle_orm8 = require("drizzle-orm");
8731
- var import_mysql_core9 = require("drizzle-orm/mysql-core");
8763
+ var import_drizzle_orm6 = require("drizzle-orm");
8764
+ var import_mysql_core7 = require("drizzle-orm/mysql-core");
8732
8765
 
8733
8766
  // src/lib/mysql/schemas/commerce/merchant-price.ts
8734
- var import_drizzle_orm7 = require("drizzle-orm");
8735
- var import_mysql_core8 = require("drizzle-orm/mysql-core");
8767
+ var import_drizzle_orm5 = require("drizzle-orm");
8768
+ var import_mysql_core6 = require("drizzle-orm/mysql-core");
8736
8769
  function getMerchantPriceSchema(mysqlTable) {
8737
8770
  return mysqlTable("merchantPrices", {
8738
- id: (0, import_mysql_core8.varchar)("id", {
8771
+ id: (0, import_mysql_core6.varchar)("id", {
8739
8772
  length: 191
8740
8773
  }).notNull(),
8741
- merchantAccountId: (0, import_mysql_core8.varchar)("merchantAccountId", {
8774
+ merchantAccountId: (0, import_mysql_core6.varchar)("merchantAccountId", {
8742
8775
  length: 191
8743
8776
  }).notNull(),
8744
- merchantProductId: (0, import_mysql_core8.varchar)("merchantProductId", {
8777
+ merchantProductId: (0, import_mysql_core6.varchar)("merchantProductId", {
8745
8778
  length: 191
8746
8779
  }).notNull(),
8747
- status: (0, import_mysql_core8.int)("status").default(0),
8748
- identifier: (0, import_mysql_core8.varchar)("identifier", {
8780
+ status: (0, import_mysql_core6.int)("status").default(0),
8781
+ identifier: (0, import_mysql_core6.varchar)("identifier", {
8749
8782
  length: 191
8750
8783
  }),
8751
- createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
8784
+ createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
8752
8785
  mode: "date",
8753
8786
  fsp: 3
8754
- }).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8755
- priceId: (0, import_mysql_core8.varchar)("priceId", {
8787
+ }).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8788
+ priceId: (0, import_mysql_core6.varchar)("priceId", {
8756
8789
  length: 191
8757
8790
  })
8758
8791
  }, (table) => {
8759
8792
  return {
8760
- merchantPriceId: (0, import_mysql_core8.primaryKey)({
8793
+ merchantPriceId: (0, import_mysql_core6.primaryKey)({
8761
8794
  columns: [
8762
8795
  table.id
8763
8796
  ],
8764
8797
  name: "MerchantPrice_id"
8765
8798
  }),
8766
- merchantPriceIdentifierKey: (0, import_mysql_core8.unique)("MerchantPrice_identifier_key").on(table.identifier)
8799
+ merchantPriceIdentifierKey: (0, import_mysql_core6.unique)("MerchantPrice_identifier_key").on(table.identifier)
8767
8800
  };
8768
8801
  });
8769
8802
  }
@@ -8772,28 +8805,28 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
8772
8805
  // src/lib/mysql/schemas/commerce/price.ts
8773
8806
  function getPriceSchema(mysqlTable) {
8774
8807
  return mysqlTable("prices", {
8775
- id: (0, import_mysql_core9.varchar)("id", {
8808
+ id: (0, import_mysql_core7.varchar)("id", {
8776
8809
  length: 191
8777
8810
  }).notNull(),
8778
- productId: (0, import_mysql_core9.varchar)("productId", {
8811
+ productId: (0, import_mysql_core7.varchar)("productId", {
8779
8812
  length: 191
8780
8813
  }),
8781
- nickname: (0, import_mysql_core9.varchar)("nickname", {
8814
+ nickname: (0, import_mysql_core7.varchar)("nickname", {
8782
8815
  length: 191
8783
8816
  }),
8784
- status: (0, import_mysql_core9.int)("status").default(0).notNull(),
8785
- unitAmount: (0, import_mysql_core9.decimal)("unitAmount", {
8817
+ status: (0, import_mysql_core7.int)("status").default(0).notNull(),
8818
+ unitAmount: (0, import_mysql_core7.decimal)("unitAmount", {
8786
8819
  precision: 10,
8787
8820
  scale: 2
8788
8821
  }).notNull(),
8789
- createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
8822
+ createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
8790
8823
  mode: "date",
8791
8824
  fsp: 3
8792
- }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8793
- fields: (0, import_mysql_core9.json)("fields").$type().default({})
8825
+ }).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8826
+ fields: (0, import_mysql_core7.json)("fields").$type().default({})
8794
8827
  }, (table) => {
8795
8828
  return {
8796
- priceId: (0, import_mysql_core9.primaryKey)({
8829
+ priceId: (0, import_mysql_core7.primaryKey)({
8797
8830
  columns: [
8798
8831
  table.id
8799
8832
  ],
@@ -8807,28 +8840,28 @@ __name(getPriceSchema, "getPriceSchema");
8807
8840
  // src/lib/mysql/schemas/commerce/product.ts
8808
8841
  function getProductSchema(mysqlTable) {
8809
8842
  return mysqlTable("products", {
8810
- id: (0, import_mysql_core10.varchar)("id", {
8843
+ id: (0, import_mysql_core8.varchar)("id", {
8811
8844
  length: 191
8812
8845
  }).notNull(),
8813
- name: (0, import_mysql_core10.varchar)("name", {
8846
+ name: (0, import_mysql_core8.varchar)("name", {
8814
8847
  length: 191
8815
8848
  }).notNull(),
8816
- key: (0, import_mysql_core10.varchar)("key", {
8849
+ key: (0, import_mysql_core8.varchar)("key", {
8817
8850
  length: 191
8818
8851
  }),
8819
- type: (0, import_mysql_core10.varchar)("type", {
8852
+ type: (0, import_mysql_core8.varchar)("type", {
8820
8853
  length: 191
8821
8854
  }),
8822
- fields: (0, import_mysql_core10.json)("fields").$type().default({}),
8823
- createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
8855
+ fields: (0, import_mysql_core8.json)("fields").$type().default({}),
8856
+ createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
8824
8857
  mode: "date",
8825
8858
  fsp: 3
8826
- }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8827
- status: (0, import_mysql_core10.int)("status").default(0).notNull(),
8828
- quantityAvailable: (0, import_mysql_core10.int)("quantityAvailable").default(-1).notNull()
8859
+ }).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8860
+ status: (0, import_mysql_core8.int)("status").default(0).notNull(),
8861
+ quantityAvailable: (0, import_mysql_core8.int)("quantityAvailable").default(-1).notNull()
8829
8862
  }, (table) => {
8830
8863
  return {
8831
- productId: (0, import_mysql_core10.primaryKey)({
8864
+ productId: (0, import_mysql_core8.primaryKey)({
8832
8865
  columns: [
8833
8866
  table.id
8834
8867
  ],
@@ -8843,7 +8876,7 @@ function getProductRelationsSchema(mysqlTable) {
8843
8876
  const price = getPriceSchema(mysqlTable);
8844
8877
  const merchantProduct = getMerchantProductSchema(mysqlTable);
8845
8878
  const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
8846
- return (0, import_drizzle_orm9.relations)(product, ({ one, many }) => ({
8879
+ return (0, import_drizzle_orm7.relations)(product, ({ one, many }) => ({
8847
8880
  price: one(price, {
8848
8881
  fields: [
8849
8882
  product.id
@@ -8869,69 +8902,331 @@ function getProductRelationsSchema(mysqlTable) {
8869
8902
  }
8870
8903
  __name(getProductRelationsSchema, "getProductRelationsSchema");
8871
8904
 
8872
- // src/lib/mysql/schemas/commerce/purchase.ts
8873
- function getPurchaseSchema(mysqlTable) {
8874
- return mysqlTable("purchases", {
8905
+ // src/lib/mysql/schemas/commerce/coupon.ts
8906
+ function getCouponSchema(mysqlTable) {
8907
+ return mysqlTable("coupons", {
8908
+ id: (0, import_mysql_core9.varchar)("id", {
8909
+ length: 191
8910
+ }).notNull(),
8911
+ code: (0, import_mysql_core9.varchar)("code", {
8912
+ length: 191
8913
+ }),
8914
+ createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
8915
+ mode: "date",
8916
+ fsp: 3
8917
+ }).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8918
+ expires: (0, import_mysql_core9.timestamp)("expires", {
8919
+ mode: "date",
8920
+ fsp: 3
8921
+ }),
8922
+ fields: (0, import_mysql_core9.json)("fields").$type().default({}),
8923
+ maxUses: (0, import_mysql_core9.int)("maxUses").default(-1).notNull(),
8924
+ default: (0, import_mysql_core9.boolean)("default").default(false).notNull(),
8925
+ merchantCouponId: (0, import_mysql_core9.varchar)("merchantCouponId", {
8926
+ length: 191
8927
+ }),
8928
+ status: (0, import_mysql_core9.int)("status").default(0).notNull(),
8929
+ usedCount: (0, import_mysql_core9.int)("usedCount").default(0).notNull(),
8930
+ percentageDiscount: (0, import_mysql_core9.decimal)("percentageDiscount", {
8931
+ precision: 3,
8932
+ scale: 2
8933
+ }).notNull(),
8934
+ restrictedToProductId: (0, import_mysql_core9.varchar)("restrictedToProductId", {
8935
+ length: 191
8936
+ }),
8937
+ bulkPurchaseId: (0, import_mysql_core9.varchar)("bulkPurchaseId", {
8938
+ length: 191
8939
+ })
8940
+ }, (table) => {
8941
+ return {
8942
+ couponId: (0, import_mysql_core9.primaryKey)({
8943
+ columns: [
8944
+ table.id
8945
+ ],
8946
+ name: "Coupon_id"
8947
+ }),
8948
+ couponBulkPurchaseIdKey: (0, import_mysql_core9.unique)("Coupon_bulkPurchaseId_key").on(table.bulkPurchaseId),
8949
+ couponCodeKey: (0, import_mysql_core9.unique)("Coupon_code_key").on(table.code)
8950
+ };
8951
+ });
8952
+ }
8953
+ __name(getCouponSchema, "getCouponSchema");
8954
+ function getCouponRelationsSchema(mysqlTable) {
8955
+ const purchase = getPurchaseSchema(mysqlTable);
8956
+ const coupon = getCouponSchema(mysqlTable);
8957
+ const merchantCoupon = getMerchantCouponSchema(mysqlTable);
8958
+ return (0, import_drizzle_orm8.relations)(coupon, ({ many, one }) => ({
8959
+ bulkCouponPurchases: many(purchase, {
8960
+ relationName: "redeemedBulkCoupon"
8961
+ }),
8962
+ merchantCoupon: one(merchantCoupon, {
8963
+ fields: [
8964
+ coupon.merchantCouponId
8965
+ ],
8966
+ references: [
8967
+ merchantCoupon.id
8968
+ ],
8969
+ relationName: "merchantCoupon"
8970
+ }),
8971
+ product: one(getProductSchema(mysqlTable), {
8972
+ fields: [
8973
+ coupon.restrictedToProductId
8974
+ ],
8975
+ references: [
8976
+ getProductSchema(mysqlTable).id
8977
+ ],
8978
+ relationName: "product"
8979
+ }),
8980
+ bulkPurchase: one(purchase, {
8981
+ fields: [
8982
+ coupon.bulkPurchaseId
8983
+ ],
8984
+ references: [
8985
+ purchase.id
8986
+ ],
8987
+ relationName: "bulkPurchase"
8988
+ })
8989
+ }));
8990
+ }
8991
+ __name(getCouponRelationsSchema, "getCouponRelationsSchema");
8992
+
8993
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
8994
+ var import_drizzle_orm11 = require("drizzle-orm");
8995
+ var import_mysql_core12 = require("drizzle-orm/mysql-core");
8996
+
8997
+ // src/lib/mysql/schemas/commerce/merchant-account.ts
8998
+ var import_drizzle_orm9 = require("drizzle-orm");
8999
+ var import_mysql_core10 = require("drizzle-orm/mysql-core");
9000
+ function getMerchantAccountSchema(mysqlTable) {
9001
+ return mysqlTable("merchantAccounts", {
9002
+ id: (0, import_mysql_core10.varchar)("id", {
9003
+ length: 191
9004
+ }).notNull(),
9005
+ status: (0, import_mysql_core10.int)("status").default(0).notNull(),
9006
+ createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
9007
+ mode: "date",
9008
+ fsp: 3
9009
+ }).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9010
+ label: (0, import_mysql_core10.varchar)("label", {
9011
+ length: 191
9012
+ }),
9013
+ identifier: (0, import_mysql_core10.varchar)("identifier", {
9014
+ length: 191
9015
+ })
9016
+ }, (table) => {
9017
+ return {
9018
+ merchantAccountId: (0, import_mysql_core10.primaryKey)({
9019
+ columns: [
9020
+ table.id
9021
+ ],
9022
+ name: "MerchantAccount_id"
9023
+ })
9024
+ };
9025
+ });
9026
+ }
9027
+ __name(getMerchantAccountSchema, "getMerchantAccountSchema");
9028
+
9029
+ // src/lib/mysql/schemas/commerce/merchant-customer.ts
9030
+ var import_drizzle_orm10 = require("drizzle-orm");
9031
+ var import_mysql_core11 = require("drizzle-orm/mysql-core");
9032
+ function getMerchantCustomerSchema(mysqlTable) {
9033
+ return mysqlTable("merchantCustomers", {
8875
9034
  id: (0, import_mysql_core11.varchar)("id", {
8876
9035
  length: 191
8877
9036
  }).notNull(),
8878
9037
  userId: (0, import_mysql_core11.varchar)("userId", {
8879
9038
  length: 191
8880
- }),
9039
+ }).notNull(),
9040
+ merchantAccountId: (0, import_mysql_core11.varchar)("merchantAccountId", {
9041
+ length: 191
9042
+ }).notNull(),
9043
+ identifier: (0, import_mysql_core11.varchar)("identifier", {
9044
+ length: 191
9045
+ }).notNull(),
8881
9046
  createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
8882
9047
  mode: "date",
8883
9048
  fsp: 3
8884
9049
  }).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`).notNull(),
8885
- totalAmount: (0, import_mysql_core11.decimal)("totalAmount", {
9050
+ status: (0, import_mysql_core11.int)("status").default(0)
9051
+ }, (table) => {
9052
+ return {
9053
+ merchantCustomerId: (0, import_mysql_core11.primaryKey)({
9054
+ columns: [
9055
+ table.id
9056
+ ],
9057
+ name: "MerchantCustomer_id"
9058
+ }),
9059
+ merchantCustomerIdentifierKey: (0, import_mysql_core11.unique)("MerchantCustomer_identifier_key").on(table.identifier)
9060
+ };
9061
+ });
9062
+ }
9063
+ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
9064
+
9065
+ // src/lib/mysql/schemas/commerce/merchant-charge.ts
9066
+ function getMerchantChargeSchema(mysqlTable) {
9067
+ return mysqlTable("merchantCharges", {
9068
+ id: (0, import_mysql_core12.varchar)("id", {
9069
+ length: 191
9070
+ }).notNull(),
9071
+ status: (0, import_mysql_core12.int)("status").default(0).notNull(),
9072
+ identifier: (0, import_mysql_core12.varchar)("identifier", {
9073
+ length: 191
9074
+ }).notNull(),
9075
+ userId: (0, import_mysql_core12.varchar)("userId", {
9076
+ length: 191
9077
+ }).notNull(),
9078
+ merchantAccountId: (0, import_mysql_core12.varchar)("merchantAccountId", {
9079
+ length: 191
9080
+ }).notNull(),
9081
+ merchantProductId: (0, import_mysql_core12.varchar)("merchantProductId", {
9082
+ length: 191
9083
+ }).notNull(),
9084
+ createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
9085
+ mode: "date",
9086
+ fsp: 3
9087
+ }).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9088
+ merchantCustomerId: (0, import_mysql_core12.varchar)("merchantCustomerId", {
9089
+ length: 191
9090
+ }).notNull()
9091
+ }, (table) => {
9092
+ return {
9093
+ merchantChargeId: (0, import_mysql_core12.primaryKey)({
9094
+ columns: [
9095
+ table.id
9096
+ ],
9097
+ name: "MerchantCharge_id"
9098
+ }),
9099
+ merchantChargeIdentifierKey: (0, import_mysql_core12.unique)("MerchantCharge_identifier_key").on(table.identifier)
9100
+ };
9101
+ });
9102
+ }
9103
+ __name(getMerchantChargeSchema, "getMerchantChargeSchema");
9104
+ function getMerchantChargeRelationsSchema(mysqlTable) {
9105
+ const merchantCharge = getMerchantChargeSchema(mysqlTable);
9106
+ const merchantAccount = getMerchantAccountSchema(mysqlTable);
9107
+ const merchantProduct = getMerchantProductSchema(mysqlTable);
9108
+ const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
9109
+ return (0, import_drizzle_orm11.relations)(merchantCharge, ({ one }) => ({
9110
+ merchantAccount: one(merchantAccount, {
9111
+ fields: [
9112
+ merchantCharge.merchantAccountId
9113
+ ],
9114
+ references: [
9115
+ merchantAccount.id
9116
+ ],
9117
+ relationName: "merchantAccount"
9118
+ }),
9119
+ merchantProduct: one(merchantProduct, {
9120
+ fields: [
9121
+ merchantCharge.merchantProductId
9122
+ ],
9123
+ references: [
9124
+ merchantProduct.id
9125
+ ],
9126
+ relationName: "merchantProduct"
9127
+ }),
9128
+ merchantCustomer: one(merchantCustomer, {
9129
+ fields: [
9130
+ merchantCharge.merchantCustomerId
9131
+ ],
9132
+ references: [
9133
+ merchantCustomer.id
9134
+ ],
9135
+ relationName: "merchantCustomer"
9136
+ })
9137
+ }));
9138
+ }
9139
+ __name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
9140
+
9141
+ // src/lib/mysql/schemas/commerce/merchant-session.ts
9142
+ var import_mysql_core13 = require("drizzle-orm/mysql-core");
9143
+ function getMerchantSessionSchema(mysqlTable) {
9144
+ return mysqlTable("merchantSessions", {
9145
+ id: (0, import_mysql_core13.varchar)("id", {
9146
+ length: 191
9147
+ }).notNull(),
9148
+ identifier: (0, import_mysql_core13.varchar)("identifier", {
9149
+ length: 191
9150
+ }).notNull(),
9151
+ merchantAccountId: (0, import_mysql_core13.varchar)("merchantAccountId", {
9152
+ length: 191
9153
+ }).notNull()
9154
+ }, (table) => {
9155
+ return {
9156
+ merchantSessionId: (0, import_mysql_core13.primaryKey)({
9157
+ columns: [
9158
+ table.id
9159
+ ],
9160
+ name: "MerchantSession_id"
9161
+ })
9162
+ };
9163
+ });
9164
+ }
9165
+ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
9166
+
9167
+ // src/lib/mysql/schemas/commerce/purchase.ts
9168
+ function getPurchaseSchema(mysqlTable) {
9169
+ return mysqlTable("purchases", {
9170
+ id: (0, import_mysql_core14.varchar)("id", {
9171
+ length: 191
9172
+ }).notNull(),
9173
+ userId: (0, import_mysql_core14.varchar)("userId", {
9174
+ length: 191
9175
+ }),
9176
+ createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
9177
+ mode: "date",
9178
+ fsp: 3
9179
+ }).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9180
+ totalAmount: (0, import_mysql_core14.decimal)("totalAmount", {
8886
9181
  precision: 65,
8887
9182
  scale: 30
8888
9183
  }).notNull(),
8889
- ipAddress: (0, import_mysql_core11.varchar)("ip_address", {
9184
+ ipAddress: (0, import_mysql_core14.varchar)("ip_address", {
8890
9185
  length: 191
8891
9186
  }),
8892
- city: (0, import_mysql_core11.varchar)("city", {
9187
+ city: (0, import_mysql_core14.varchar)("city", {
8893
9188
  length: 191
8894
9189
  }),
8895
- state: (0, import_mysql_core11.varchar)("state", {
9190
+ state: (0, import_mysql_core14.varchar)("state", {
8896
9191
  length: 191
8897
9192
  }),
8898
- country: (0, import_mysql_core11.varchar)("country", {
9193
+ country: (0, import_mysql_core14.varchar)("country", {
8899
9194
  length: 191
8900
9195
  }),
8901
- couponId: (0, import_mysql_core11.varchar)("couponId", {
9196
+ couponId: (0, import_mysql_core14.varchar)("couponId", {
8902
9197
  length: 191
8903
9198
  }),
8904
- productId: (0, import_mysql_core11.varchar)("productId", {
9199
+ productId: (0, import_mysql_core14.varchar)("productId", {
8905
9200
  length: 191
8906
9201
  }).notNull(),
8907
- merchantChargeId: (0, import_mysql_core11.varchar)("merchantChargeId", {
9202
+ merchantChargeId: (0, import_mysql_core14.varchar)("merchantChargeId", {
8908
9203
  length: 191
8909
9204
  }),
8910
- upgradedFromId: (0, import_mysql_core11.varchar)("upgradedFromId", {
9205
+ upgradedFromId: (0, import_mysql_core14.varchar)("upgradedFromId", {
8911
9206
  length: 191
8912
9207
  }),
8913
- status: (0, import_mysql_core11.varchar)("status", {
9208
+ status: (0, import_mysql_core14.varchar)("status", {
8914
9209
  length: 191
8915
9210
  }).default("Valid").notNull(),
8916
- bulkCouponId: (0, import_mysql_core11.varchar)("bulkCouponId", {
9211
+ bulkCouponId: (0, import_mysql_core14.varchar)("bulkCouponId", {
8917
9212
  length: 191
8918
9213
  }),
8919
- merchantSessionId: (0, import_mysql_core11.varchar)("merchantSessionId", {
9214
+ merchantSessionId: (0, import_mysql_core14.varchar)("merchantSessionId", {
8920
9215
  length: 191
8921
9216
  }),
8922
- redeemedBulkCouponId: (0, import_mysql_core11.varchar)("redeemedBulkCouponId", {
9217
+ redeemedBulkCouponId: (0, import_mysql_core14.varchar)("redeemedBulkCouponId", {
8923
9218
  length: 191
8924
9219
  }),
8925
- fields: (0, import_mysql_core11.json)("fields").$type().default({})
9220
+ fields: (0, import_mysql_core14.json)("fields").$type().default({})
8926
9221
  }, (table) => {
8927
9222
  return {
8928
- purchaseId: (0, import_mysql_core11.primaryKey)({
9223
+ purchaseId: (0, import_mysql_core14.primaryKey)({
8929
9224
  columns: [
8930
9225
  table.id
8931
9226
  ],
8932
9227
  name: "Purchase_id"
8933
9228
  }),
8934
- purchaseUpgradedFromIdKey: (0, import_mysql_core11.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId)
9229
+ purchaseUpgradedFromIdKey: (0, import_mysql_core14.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId)
8935
9230
  };
8936
9231
  });
8937
9232
  }
@@ -8943,7 +9238,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
8943
9238
  const merchantCharges = getMerchantChargeSchema(mysqlTable);
8944
9239
  const merchantSessions = getMerchantSessionSchema(mysqlTable);
8945
9240
  const coupons = getCouponSchema(mysqlTable);
8946
- return (0, import_drizzle_orm10.relations)(purchases, ({ many, one }) => ({
9241
+ return (0, import_drizzle_orm12.relations)(purchases, ({ many, one }) => ({
8947
9242
  redeemedBulkCoupon: one(coupons, {
8948
9243
  fields: [
8949
9244
  purchases.redeemedBulkCouponId
@@ -9003,60 +9298,60 @@ function getPurchaseRelationsSchema(mysqlTable) {
9003
9298
  __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
9004
9299
 
9005
9300
  // src/lib/mysql/schemas/communication/communication-preferences.ts
9006
- var import_drizzle_orm11 = require("drizzle-orm");
9007
- var import_mysql_core14 = require("drizzle-orm/mysql-core");
9301
+ var import_drizzle_orm13 = require("drizzle-orm");
9302
+ var import_mysql_core17 = require("drizzle-orm/mysql-core");
9008
9303
 
9009
9304
  // src/lib/mysql/schemas/communication/communication-channel.ts
9010
- var import_mysql_core12 = require("drizzle-orm/mysql-core");
9305
+ var import_mysql_core15 = require("drizzle-orm/mysql-core");
9011
9306
  function getCommunicationChannelSchema(mysqlTable) {
9012
9307
  return mysqlTable("communicationChannel", {
9013
- id: (0, import_mysql_core12.varchar)("id", {
9308
+ id: (0, import_mysql_core15.varchar)("id", {
9014
9309
  length: 255
9015
9310
  }).notNull().primaryKey(),
9016
- name: (0, import_mysql_core12.varchar)("name", {
9311
+ name: (0, import_mysql_core15.varchar)("name", {
9017
9312
  length: 255
9018
9313
  }).notNull(),
9019
- description: (0, import_mysql_core12.text)("description"),
9020
- active: (0, import_mysql_core12.boolean)("active").notNull().default(true),
9021
- createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
9314
+ description: (0, import_mysql_core15.text)("description"),
9315
+ active: (0, import_mysql_core15.boolean)("active").notNull().default(true),
9316
+ createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
9022
9317
  mode: "date",
9023
9318
  fsp: 3
9024
9319
  }).defaultNow(),
9025
- updatedAt: (0, import_mysql_core12.timestamp)("updatedAt", {
9320
+ updatedAt: (0, import_mysql_core15.timestamp)("updatedAt", {
9026
9321
  mode: "date",
9027
9322
  fsp: 3
9028
9323
  }).defaultNow(),
9029
- deletedAt: (0, import_mysql_core12.timestamp)("deletedAt", {
9324
+ deletedAt: (0, import_mysql_core15.timestamp)("deletedAt", {
9030
9325
  mode: "date",
9031
9326
  fsp: 3
9032
9327
  })
9033
9328
  }, (cc) => ({
9034
- nameIdx: (0, import_mysql_core12.index)("name_idx").on(cc.name)
9329
+ nameIdx: (0, import_mysql_core15.index)("name_idx").on(cc.name)
9035
9330
  }));
9036
9331
  }
9037
9332
  __name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
9038
9333
 
9039
9334
  // src/lib/mysql/schemas/communication/communication-preference-types.ts
9040
- var import_mysql_core13 = require("drizzle-orm/mysql-core");
9335
+ var import_mysql_core16 = require("drizzle-orm/mysql-core");
9041
9336
  function getCommunicationPreferenceTypesSchema(mysqlTable) {
9042
9337
  return mysqlTable("communicationPreferenceType", {
9043
- id: (0, import_mysql_core13.varchar)("id", {
9338
+ id: (0, import_mysql_core16.varchar)("id", {
9044
9339
  length: 255
9045
9340
  }).notNull().primaryKey(),
9046
- name: (0, import_mysql_core13.varchar)("name", {
9341
+ name: (0, import_mysql_core16.varchar)("name", {
9047
9342
  length: 255
9048
9343
  }).notNull(),
9049
- description: (0, import_mysql_core13.text)("description"),
9050
- active: (0, import_mysql_core13.boolean)("active").notNull().default(true),
9051
- createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
9344
+ description: (0, import_mysql_core16.text)("description"),
9345
+ active: (0, import_mysql_core16.boolean)("active").notNull().default(true),
9346
+ createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
9052
9347
  mode: "date",
9053
9348
  fsp: 3
9054
9349
  }).defaultNow(),
9055
- updatedAt: (0, import_mysql_core13.timestamp)("updatedAt", {
9350
+ updatedAt: (0, import_mysql_core16.timestamp)("updatedAt", {
9056
9351
  mode: "date",
9057
9352
  fsp: 3
9058
9353
  }),
9059
- deletedAt: (0, import_mysql_core13.timestamp)("deletedAt", {
9354
+ deletedAt: (0, import_mysql_core16.timestamp)("deletedAt", {
9060
9355
  mode: "date",
9061
9356
  fsp: 3
9062
9357
  })
@@ -9067,48 +9362,48 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
9067
9362
  // src/lib/mysql/schemas/communication/communication-preferences.ts
9068
9363
  function getCommunicationPreferencesSchema(mysqlTable) {
9069
9364
  return mysqlTable("communicationPreference", {
9070
- id: (0, import_mysql_core14.varchar)("id", {
9365
+ id: (0, import_mysql_core17.varchar)("id", {
9071
9366
  length: 255
9072
9367
  }).notNull().primaryKey(),
9073
- userId: (0, import_mysql_core14.varchar)("userId", {
9368
+ userId: (0, import_mysql_core17.varchar)("userId", {
9074
9369
  length: 255
9075
9370
  }).notNull(),
9076
- channelId: (0, import_mysql_core14.varchar)("channelId", {
9371
+ channelId: (0, import_mysql_core17.varchar)("channelId", {
9077
9372
  length: 255
9078
9373
  }).notNull(),
9079
- preferenceLevel: (0, import_mysql_core14.mysqlEnum)("preferenceLevel", [
9374
+ preferenceLevel: (0, import_mysql_core17.mysqlEnum)("preferenceLevel", [
9080
9375
  "low",
9081
9376
  "medium",
9082
9377
  "high"
9083
9378
  ]).notNull().default("medium"),
9084
- preferenceTypeId: (0, import_mysql_core14.varchar)("preferenceTypeId", {
9379
+ preferenceTypeId: (0, import_mysql_core17.varchar)("preferenceTypeId", {
9085
9380
  length: 255
9086
9381
  }).notNull(),
9087
- active: (0, import_mysql_core14.boolean)("active").notNull().default(true),
9088
- createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
9382
+ active: (0, import_mysql_core17.boolean)("active").notNull().default(true),
9383
+ createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
9089
9384
  mode: "date",
9090
9385
  fsp: 3
9091
9386
  }).defaultNow(),
9092
- optInAt: (0, import_mysql_core14.timestamp)("optInAt", {
9387
+ optInAt: (0, import_mysql_core17.timestamp)("optInAt", {
9093
9388
  mode: "date",
9094
9389
  fsp: 3
9095
9390
  }),
9096
- optOutAt: (0, import_mysql_core14.timestamp)("optOutAt", {
9391
+ optOutAt: (0, import_mysql_core17.timestamp)("optOutAt", {
9097
9392
  mode: "date",
9098
9393
  fsp: 3
9099
9394
  }),
9100
- updatedAt: (0, import_mysql_core14.timestamp)("updatedAt", {
9395
+ updatedAt: (0, import_mysql_core17.timestamp)("updatedAt", {
9101
9396
  mode: "date",
9102
9397
  fsp: 3
9103
9398
  }).defaultNow(),
9104
- deletedAt: (0, import_mysql_core14.timestamp)("deletedAt", {
9399
+ deletedAt: (0, import_mysql_core17.timestamp)("deletedAt", {
9105
9400
  mode: "date",
9106
9401
  fsp: 3
9107
9402
  })
9108
9403
  }, (cp) => ({
9109
- userIdIdx: (0, import_mysql_core14.index)("userId_idx").on(cp.userId),
9110
- preferenceTypeIdx: (0, import_mysql_core14.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
9111
- channelIdIdx: (0, import_mysql_core14.index)("channelId_idx").on(cp.channelId)
9404
+ userIdIdx: (0, import_mysql_core17.index)("userId_idx").on(cp.userId),
9405
+ preferenceTypeIdx: (0, import_mysql_core17.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
9406
+ channelIdIdx: (0, import_mysql_core17.index)("channelId_idx").on(cp.channelId)
9112
9407
  }));
9113
9408
  }
9114
9409
  __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
@@ -9117,7 +9412,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
9117
9412
  const users = getUsersSchema(mysqlTable);
9118
9413
  const communicationChannel = getCommunicationChannelSchema(mysqlTable);
9119
9414
  const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
9120
- return (0, import_drizzle_orm11.relations)(communicationPreferences, ({ one }) => ({
9415
+ return (0, import_drizzle_orm13.relations)(communicationPreferences, ({ one }) => ({
9121
9416
  user: one(users, {
9122
9417
  fields: [
9123
9418
  communicationPreferences.userId
@@ -9150,81 +9445,81 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
9150
9445
  __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
9151
9446
 
9152
9447
  // src/lib/mysql/schemas/content/content-contributions.ts
9153
- var import_drizzle_orm13 = require("drizzle-orm");
9154
- var import_mysql_core16 = require("drizzle-orm/mysql-core");
9448
+ var import_drizzle_orm15 = require("drizzle-orm");
9449
+ var import_mysql_core19 = require("drizzle-orm/mysql-core");
9155
9450
 
9156
9451
  // src/lib/mysql/schemas/content/contribution-types.ts
9157
- var import_drizzle_orm12 = require("drizzle-orm");
9158
- var import_mysql_core15 = require("drizzle-orm/mysql-core");
9452
+ var import_drizzle_orm14 = require("drizzle-orm");
9453
+ var import_mysql_core18 = require("drizzle-orm/mysql-core");
9159
9454
  function getContributionTypesSchema(mysqlTable) {
9160
9455
  return mysqlTable("contributionType", {
9161
- id: (0, import_mysql_core15.varchar)("id", {
9456
+ id: (0, import_mysql_core18.varchar)("id", {
9162
9457
  length: 255
9163
9458
  }).notNull().primaryKey(),
9164
- slug: (0, import_mysql_core15.varchar)("slug", {
9459
+ slug: (0, import_mysql_core18.varchar)("slug", {
9165
9460
  length: 255
9166
9461
  }).notNull().unique(),
9167
- name: (0, import_mysql_core15.varchar)("name", {
9462
+ name: (0, import_mysql_core18.varchar)("name", {
9168
9463
  length: 255
9169
9464
  }).notNull(),
9170
- description: (0, import_mysql_core15.text)("description"),
9171
- active: (0, import_mysql_core15.boolean)("active").notNull().default(true),
9172
- createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
9465
+ description: (0, import_mysql_core18.text)("description"),
9466
+ active: (0, import_mysql_core18.boolean)("active").notNull().default(true),
9467
+ createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
9173
9468
  mode: "date",
9174
9469
  fsp: 3
9175
9470
  }).defaultNow(),
9176
- updatedAt: (0, import_mysql_core15.timestamp)("updatedAt", {
9471
+ updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
9177
9472
  mode: "date",
9178
9473
  fsp: 3
9179
9474
  }).defaultNow(),
9180
- deletedAt: (0, import_mysql_core15.timestamp)("deletedAt", {
9475
+ deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
9181
9476
  mode: "date",
9182
9477
  fsp: 3
9183
9478
  })
9184
9479
  }, (ct) => ({
9185
- nameIdx: (0, import_mysql_core15.index)("name_idx").on(ct.name),
9186
- slugIdx: (0, import_mysql_core15.index)("slug_idx").on(ct.slug)
9480
+ nameIdx: (0, import_mysql_core18.index)("name_idx").on(ct.name),
9481
+ slugIdx: (0, import_mysql_core18.index)("slug_idx").on(ct.slug)
9187
9482
  }));
9188
9483
  }
9189
9484
  __name(getContributionTypesSchema, "getContributionTypesSchema");
9190
9485
  function getContributionTypesRelationsSchema(mysqlTable) {
9191
9486
  const contributionTypes = getContributionTypesSchema(mysqlTable);
9192
- return (0, import_drizzle_orm12.relations)(contributionTypes, ({ many }) => ({}));
9487
+ return (0, import_drizzle_orm14.relations)(contributionTypes, ({ many }) => ({}));
9193
9488
  }
9194
9489
  __name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
9195
9490
 
9196
9491
  // src/lib/mysql/schemas/content/content-contributions.ts
9197
9492
  function getContentContributionsSchema(mysqlTable) {
9198
9493
  return mysqlTable("contentContribution", {
9199
- id: (0, import_mysql_core16.varchar)("id", {
9494
+ id: (0, import_mysql_core19.varchar)("id", {
9200
9495
  length: 255
9201
9496
  }).notNull().primaryKey(),
9202
- userId: (0, import_mysql_core16.varchar)("userId", {
9497
+ userId: (0, import_mysql_core19.varchar)("userId", {
9203
9498
  length: 255
9204
9499
  }).notNull(),
9205
- contentId: (0, import_mysql_core16.varchar)("contentId", {
9500
+ contentId: (0, import_mysql_core19.varchar)("contentId", {
9206
9501
  length: 255
9207
9502
  }).notNull(),
9208
- contributionTypeId: (0, import_mysql_core16.varchar)("contributionTypeId", {
9503
+ contributionTypeId: (0, import_mysql_core19.varchar)("contributionTypeId", {
9209
9504
  length: 255
9210
9505
  }).notNull(),
9211
- active: (0, import_mysql_core16.boolean)("active").notNull().default(true),
9212
- createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
9506
+ active: (0, import_mysql_core19.boolean)("active").notNull().default(true),
9507
+ createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
9213
9508
  mode: "date",
9214
9509
  fsp: 3
9215
9510
  }).defaultNow(),
9216
- updatedAt: (0, import_mysql_core16.timestamp)("updatedAt", {
9511
+ updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
9217
9512
  mode: "date",
9218
9513
  fsp: 3
9219
9514
  }).defaultNow(),
9220
- deletedAt: (0, import_mysql_core16.timestamp)("deletedAt", {
9515
+ deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
9221
9516
  mode: "date",
9222
9517
  fsp: 3
9223
9518
  })
9224
9519
  }, (cc) => ({
9225
- userIdIdx: (0, import_mysql_core16.index)("userId_idx").on(cc.userId),
9226
- contentIdIdx: (0, import_mysql_core16.index)("contentId_idx").on(cc.contentId),
9227
- contributionTypeIdIdx: (0, import_mysql_core16.index)("contributionTypeId_idx").on(cc.contributionTypeId)
9520
+ userIdIdx: (0, import_mysql_core19.index)("userId_idx").on(cc.userId),
9521
+ contentIdIdx: (0, import_mysql_core19.index)("contentId_idx").on(cc.contentId),
9522
+ contributionTypeIdIdx: (0, import_mysql_core19.index)("contributionTypeId_idx").on(cc.contributionTypeId)
9228
9523
  }));
9229
9524
  }
9230
9525
  __name(getContentContributionsSchema, "getContentContributionsSchema");
@@ -9233,7 +9528,7 @@ function getContentContributionRelationsSchema(mysqlTable) {
9233
9528
  const users = getUsersSchema(mysqlTable);
9234
9529
  const contentResource = getContentResourceSchema(mysqlTable);
9235
9530
  const contributionTypes = getContributionTypesSchema(mysqlTable);
9236
- return (0, import_drizzle_orm13.relations)(contentContributions, ({ one }) => ({
9531
+ return (0, import_drizzle_orm15.relations)(contentContributions, ({ one }) => ({
9237
9532
  user: one(users, {
9238
9533
  fields: [
9239
9534
  contentContributions.userId
@@ -9266,75 +9561,75 @@ function getContentContributionRelationsSchema(mysqlTable) {
9266
9561
  __name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
9267
9562
 
9268
9563
  // src/lib/mysql/schemas/auth/user-permissions.ts
9269
- var import_drizzle_orm15 = require("drizzle-orm");
9270
- var import_mysql_core18 = require("drizzle-orm/mysql-core");
9564
+ var import_drizzle_orm17 = require("drizzle-orm");
9565
+ var import_mysql_core21 = require("drizzle-orm/mysql-core");
9271
9566
 
9272
9567
  // src/lib/mysql/schemas/auth/permissions.ts
9273
- var import_drizzle_orm14 = require("drizzle-orm");
9274
- var import_mysql_core17 = require("drizzle-orm/mysql-core");
9568
+ var import_drizzle_orm16 = require("drizzle-orm");
9569
+ var import_mysql_core20 = require("drizzle-orm/mysql-core");
9275
9570
  function getPermissionsSchema(mysqlTable) {
9276
9571
  return mysqlTable("permission", {
9277
- id: (0, import_mysql_core17.varchar)("id", {
9572
+ id: (0, import_mysql_core20.varchar)("id", {
9278
9573
  length: 255
9279
9574
  }).notNull().primaryKey(),
9280
- name: (0, import_mysql_core17.varchar)("name", {
9575
+ name: (0, import_mysql_core20.varchar)("name", {
9281
9576
  length: 255
9282
9577
  }).notNull().unique(),
9283
- description: (0, import_mysql_core17.text)("description"),
9284
- active: (0, import_mysql_core17.boolean)("active").notNull().default(true),
9285
- createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
9578
+ description: (0, import_mysql_core20.text)("description"),
9579
+ active: (0, import_mysql_core20.boolean)("active").notNull().default(true),
9580
+ createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
9286
9581
  mode: "date",
9287
9582
  fsp: 3
9288
9583
  }).defaultNow(),
9289
- updatedAt: (0, import_mysql_core17.timestamp)("updatedAt", {
9584
+ updatedAt: (0, import_mysql_core20.timestamp)("updatedAt", {
9290
9585
  mode: "date",
9291
9586
  fsp: 3
9292
9587
  }).defaultNow(),
9293
- deletedAt: (0, import_mysql_core17.timestamp)("deletedAt", {
9588
+ deletedAt: (0, import_mysql_core20.timestamp)("deletedAt", {
9294
9589
  mode: "date",
9295
9590
  fsp: 3
9296
9591
  })
9297
9592
  }, (permission) => ({
9298
- nameIdx: (0, import_mysql_core17.index)("name_idx").on(permission.name)
9593
+ nameIdx: (0, import_mysql_core20.index)("name_idx").on(permission.name)
9299
9594
  }));
9300
9595
  }
9301
9596
  __name(getPermissionsSchema, "getPermissionsSchema");
9302
9597
  function getPermissionsRelationsSchema(mysqlTable) {
9303
- return (0, import_drizzle_orm14.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
9598
+ return (0, import_drizzle_orm16.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
9304
9599
  }
9305
9600
  __name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
9306
9601
 
9307
9602
  // src/lib/mysql/schemas/auth/user-permissions.ts
9308
9603
  function getUserPermissionsSchema(mysqlTable) {
9309
9604
  return mysqlTable("userPermission", {
9310
- userId: (0, import_mysql_core18.varchar)("userId", {
9605
+ userId: (0, import_mysql_core21.varchar)("userId", {
9311
9606
  length: 255
9312
9607
  }).notNull(),
9313
- permissionId: (0, import_mysql_core18.varchar)("permissionId", {
9608
+ permissionId: (0, import_mysql_core21.varchar)("permissionId", {
9314
9609
  length: 255
9315
9610
  }).notNull(),
9316
- active: (0, import_mysql_core18.boolean)("active").notNull().default(true),
9317
- createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
9611
+ active: (0, import_mysql_core21.boolean)("active").notNull().default(true),
9612
+ createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
9318
9613
  mode: "date",
9319
9614
  fsp: 3
9320
9615
  }).defaultNow(),
9321
- updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
9616
+ updatedAt: (0, import_mysql_core21.timestamp)("updatedAt", {
9322
9617
  mode: "date",
9323
9618
  fsp: 3
9324
9619
  }).defaultNow(),
9325
- deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
9620
+ deletedAt: (0, import_mysql_core21.timestamp)("deletedAt", {
9326
9621
  mode: "date",
9327
9622
  fsp: 3
9328
9623
  })
9329
9624
  }, (up) => ({
9330
- pk: (0, import_mysql_core18.primaryKey)({
9625
+ pk: (0, import_mysql_core21.primaryKey)({
9331
9626
  columns: [
9332
9627
  up.userId,
9333
9628
  up.permissionId
9334
9629
  ]
9335
9630
  }),
9336
- userIdIdx: (0, import_mysql_core18.index)("userId_idx").on(up.userId),
9337
- permissionIdIdx: (0, import_mysql_core18.index)("permissionId_idx").on(up.permissionId)
9631
+ userIdIdx: (0, import_mysql_core21.index)("userId_idx").on(up.userId),
9632
+ permissionIdIdx: (0, import_mysql_core21.index)("permissionId_idx").on(up.permissionId)
9338
9633
  }));
9339
9634
  }
9340
9635
  __name(getUserPermissionsSchema, "getUserPermissionsSchema");
@@ -9342,7 +9637,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
9342
9637
  const userPermissions = getUserPermissionsSchema(mysqlTable);
9343
9638
  const users = getUsersSchema(mysqlTable);
9344
9639
  const permissions = getPermissionsSchema(mysqlTable);
9345
- return (0, import_drizzle_orm15.relations)(userPermissions, ({ one }) => ({
9640
+ return (0, import_drizzle_orm17.relations)(userPermissions, ({ one }) => ({
9346
9641
  user: one(users, {
9347
9642
  fields: [
9348
9643
  userPermissions.userId
@@ -9366,43 +9661,43 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
9366
9661
  __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
9367
9662
 
9368
9663
  // src/lib/mysql/schemas/auth/user-roles.ts
9369
- var import_drizzle_orm17 = require("drizzle-orm");
9370
- var import_mysql_core20 = require("drizzle-orm/mysql-core");
9664
+ var import_drizzle_orm19 = require("drizzle-orm");
9665
+ var import_mysql_core23 = require("drizzle-orm/mysql-core");
9371
9666
 
9372
9667
  // src/lib/mysql/schemas/auth/roles.ts
9373
- var import_drizzle_orm16 = require("drizzle-orm");
9374
- var import_mysql_core19 = require("drizzle-orm/mysql-core");
9668
+ var import_drizzle_orm18 = require("drizzle-orm");
9669
+ var import_mysql_core22 = require("drizzle-orm/mysql-core");
9375
9670
  function getRolesSchema(mysqlTable) {
9376
9671
  return mysqlTable("role", {
9377
- id: (0, import_mysql_core19.varchar)("id", {
9672
+ id: (0, import_mysql_core22.varchar)("id", {
9378
9673
  length: 255
9379
9674
  }).notNull().primaryKey(),
9380
- name: (0, import_mysql_core19.varchar)("name", {
9675
+ name: (0, import_mysql_core22.varchar)("name", {
9381
9676
  length: 255
9382
9677
  }).notNull().unique(),
9383
- description: (0, import_mysql_core19.text)("description"),
9384
- active: (0, import_mysql_core19.boolean)("active").notNull().default(true),
9385
- createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
9678
+ description: (0, import_mysql_core22.text)("description"),
9679
+ active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
9680
+ createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
9386
9681
  mode: "date",
9387
9682
  fsp: 3
9388
9683
  }).defaultNow(),
9389
- updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
9684
+ updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
9390
9685
  mode: "date",
9391
9686
  fsp: 3
9392
9687
  }).defaultNow(),
9393
- deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
9688
+ deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
9394
9689
  mode: "date",
9395
9690
  fsp: 3
9396
9691
  })
9397
9692
  }, (role) => ({
9398
- nameIdx: (0, import_mysql_core19.index)("name_idx").on(role.name)
9693
+ nameIdx: (0, import_mysql_core22.index)("name_idx").on(role.name)
9399
9694
  }));
9400
9695
  }
9401
9696
  __name(getRolesSchema, "getRolesSchema");
9402
9697
  function getRolesRelationsSchema(mysqlTable) {
9403
9698
  const roles = getRolesSchema(mysqlTable);
9404
9699
  const userRoles = getUserRolesSchema(mysqlTable);
9405
- return (0, import_drizzle_orm16.relations)(roles, ({ many }) => ({
9700
+ return (0, import_drizzle_orm18.relations)(roles, ({ many }) => ({
9406
9701
  userRoles: many(userRoles, {
9407
9702
  relationName: "role"
9408
9703
  })
@@ -9413,34 +9708,34 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
9413
9708
  // src/lib/mysql/schemas/auth/user-roles.ts
9414
9709
  function getUserRolesSchema(mysqlTable) {
9415
9710
  return mysqlTable("userRole", {
9416
- userId: (0, import_mysql_core20.varchar)("userId", {
9711
+ userId: (0, import_mysql_core23.varchar)("userId", {
9417
9712
  length: 255
9418
9713
  }).notNull(),
9419
- roleId: (0, import_mysql_core20.varchar)("roleId", {
9714
+ roleId: (0, import_mysql_core23.varchar)("roleId", {
9420
9715
  length: 255
9421
9716
  }).notNull(),
9422
- active: (0, import_mysql_core20.boolean)("active").notNull().default(true),
9423
- createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
9717
+ active: (0, import_mysql_core23.boolean)("active").notNull().default(true),
9718
+ createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
9424
9719
  mode: "date",
9425
9720
  fsp: 3
9426
9721
  }).defaultNow(),
9427
- updatedAt: (0, import_mysql_core20.timestamp)("updatedAt", {
9722
+ updatedAt: (0, import_mysql_core23.timestamp)("updatedAt", {
9428
9723
  mode: "date",
9429
9724
  fsp: 3
9430
9725
  }).defaultNow(),
9431
- deletedAt: (0, import_mysql_core20.timestamp)("deletedAt", {
9726
+ deletedAt: (0, import_mysql_core23.timestamp)("deletedAt", {
9432
9727
  mode: "date",
9433
9728
  fsp: 3
9434
9729
  })
9435
9730
  }, (ur) => ({
9436
- pk: (0, import_mysql_core20.primaryKey)({
9731
+ pk: (0, import_mysql_core23.primaryKey)({
9437
9732
  columns: [
9438
9733
  ur.userId,
9439
9734
  ur.roleId
9440
9735
  ]
9441
9736
  }),
9442
- userIdIdx: (0, import_mysql_core20.index)("userId_idx").on(ur.userId),
9443
- roleIdIdx: (0, import_mysql_core20.index)("roleId_idx").on(ur.roleId)
9737
+ userIdIdx: (0, import_mysql_core23.index)("userId_idx").on(ur.userId),
9738
+ roleIdIdx: (0, import_mysql_core23.index)("roleId_idx").on(ur.roleId)
9444
9739
  }));
9445
9740
  }
9446
9741
  __name(getUserRolesSchema, "getUserRolesSchema");
@@ -9448,7 +9743,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
9448
9743
  const userRoles = getUserRolesSchema(mysqlTable);
9449
9744
  const users = getUsersSchema(mysqlTable);
9450
9745
  const roles = getRolesSchema(mysqlTable);
9451
- return (0, import_drizzle_orm17.relations)(userRoles, ({ one }) => ({
9746
+ return (0, import_drizzle_orm19.relations)(userRoles, ({ one }) => ({
9452
9747
  user: one(users, {
9453
9748
  fields: [
9454
9749
  userRoles.userId
@@ -9474,34 +9769,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
9474
9769
  // src/lib/mysql/schemas/auth/users.ts
9475
9770
  function getUsersSchema(mysqlTable) {
9476
9771
  return mysqlTable("user", {
9477
- id: (0, import_mysql_core21.varchar)("id", {
9772
+ id: (0, import_mysql_core24.varchar)("id", {
9478
9773
  length: 255
9479
9774
  }).notNull().primaryKey(),
9480
- name: (0, import_mysql_core21.varchar)("name", {
9775
+ name: (0, import_mysql_core24.varchar)("name", {
9481
9776
  length: 255
9482
9777
  }),
9483
- role: (0, import_mysql_core21.mysqlEnum)("role", [
9778
+ role: (0, import_mysql_core24.mysqlEnum)("role", [
9484
9779
  "user",
9485
9780
  "admin"
9486
9781
  ]).default("user"),
9487
- email: (0, import_mysql_core21.varchar)("email", {
9782
+ email: (0, import_mysql_core24.varchar)("email", {
9488
9783
  length: 255
9489
9784
  }).notNull().unique(),
9490
- emailVerified: (0, import_mysql_core21.timestamp)("emailVerified", {
9785
+ emailVerified: (0, import_mysql_core24.timestamp)("emailVerified", {
9491
9786
  mode: "date",
9492
9787
  fsp: 3
9493
9788
  }),
9494
- image: (0, import_mysql_core21.varchar)("image", {
9789
+ image: (0, import_mysql_core24.varchar)("image", {
9495
9790
  length: 255
9496
9791
  }),
9497
- createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
9792
+ createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
9498
9793
  mode: "date",
9499
9794
  fsp: 3
9500
- }).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`)
9795
+ }).default(import_drizzle_orm20.sql`CURRENT_TIMESTAMP(3)`)
9501
9796
  }, (user) => ({
9502
- emailIdx: (0, import_mysql_core21.index)("email_idx").on(user.email),
9503
- roleIdx: (0, import_mysql_core21.index)("role_idx").on(user.role),
9504
- createdAtIdx: (0, import_mysql_core21.index)("created_at_idx").on(user.createdAt)
9797
+ emailIdx: (0, import_mysql_core24.index)("email_idx").on(user.email),
9798
+ roleIdx: (0, import_mysql_core24.index)("role_idx").on(user.role),
9799
+ createdAtIdx: (0, import_mysql_core24.index)("created_at_idx").on(user.createdAt)
9505
9800
  }));
9506
9801
  }
9507
9802
  __name(getUsersSchema, "getUsersSchema");
@@ -9514,7 +9809,7 @@ function getUsersRelationsSchema(mysqlTable) {
9514
9809
  const contentContributions = getContentContributionsSchema(mysqlTable);
9515
9810
  const contentResource = getContentResourceSchema(mysqlTable);
9516
9811
  const purchases = getPurchaseSchema(mysqlTable);
9517
- return (0, import_drizzle_orm18.relations)(users, ({ many }) => ({
9812
+ return (0, import_drizzle_orm20.relations)(users, ({ many }) => ({
9518
9813
  accounts: many(accounts, {
9519
9814
  relationName: "user"
9520
9815
  }),
@@ -9543,49 +9838,49 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
9543
9838
  // src/lib/mysql/schemas/auth/accounts.ts
9544
9839
  function getAccountsSchema(mysqlTable) {
9545
9840
  return mysqlTable("account", {
9546
- userId: (0, import_mysql_core22.varchar)("userId", {
9841
+ userId: (0, import_mysql_core25.varchar)("userId", {
9547
9842
  length: 255
9548
9843
  }).notNull(),
9549
- type: (0, import_mysql_core22.varchar)("type", {
9844
+ type: (0, import_mysql_core25.varchar)("type", {
9550
9845
  length: 255
9551
9846
  }).$type().notNull(),
9552
- provider: (0, import_mysql_core22.varchar)("provider", {
9847
+ provider: (0, import_mysql_core25.varchar)("provider", {
9553
9848
  length: 255
9554
9849
  }).notNull(),
9555
- providerAccountId: (0, import_mysql_core22.varchar)("providerAccountId", {
9850
+ providerAccountId: (0, import_mysql_core25.varchar)("providerAccountId", {
9556
9851
  length: 255
9557
9852
  }).notNull(),
9558
- refresh_token: (0, import_mysql_core22.text)("refresh_token"),
9559
- access_token: (0, import_mysql_core22.text)("access_token"),
9560
- oauth_token: (0, import_mysql_core22.text)("oauth_token"),
9561
- oauth_token_secret: (0, import_mysql_core22.text)("oauth_token_secret"),
9562
- expires_at: (0, import_mysql_core22.int)("expires_at"),
9563
- token_type: (0, import_mysql_core22.varchar)("token_type", {
9853
+ refresh_token: (0, import_mysql_core25.text)("refresh_token"),
9854
+ access_token: (0, import_mysql_core25.text)("access_token"),
9855
+ oauth_token: (0, import_mysql_core25.text)("oauth_token"),
9856
+ oauth_token_secret: (0, import_mysql_core25.text)("oauth_token_secret"),
9857
+ expires_at: (0, import_mysql_core25.int)("expires_at"),
9858
+ token_type: (0, import_mysql_core25.varchar)("token_type", {
9564
9859
  length: 255
9565
9860
  }),
9566
- scope: (0, import_mysql_core22.varchar)("scope", {
9861
+ scope: (0, import_mysql_core25.varchar)("scope", {
9567
9862
  length: 255
9568
9863
  }),
9569
- id_token: (0, import_mysql_core22.text)("id_token"),
9570
- session_state: (0, import_mysql_core22.varchar)("session_state", {
9864
+ id_token: (0, import_mysql_core25.text)("id_token"),
9865
+ session_state: (0, import_mysql_core25.varchar)("session_state", {
9571
9866
  length: 255
9572
9867
  }),
9573
- refresh_token_expires_in: (0, import_mysql_core22.int)("refresh_token_expires_in")
9868
+ refresh_token_expires_in: (0, import_mysql_core25.int)("refresh_token_expires_in")
9574
9869
  }, (account) => ({
9575
- pk: (0, import_mysql_core22.primaryKey)({
9870
+ pk: (0, import_mysql_core25.primaryKey)({
9576
9871
  columns: [
9577
9872
  account.provider,
9578
9873
  account.providerAccountId
9579
9874
  ]
9580
9875
  }),
9581
- userIdIdx: (0, import_mysql_core22.index)("userId_idx").on(account.userId)
9876
+ userIdIdx: (0, import_mysql_core25.index)("userId_idx").on(account.userId)
9582
9877
  }));
9583
9878
  }
9584
9879
  __name(getAccountsSchema, "getAccountsSchema");
9585
9880
  function getAccountsRelationsSchema(mysqlTable) {
9586
9881
  const accounts = getAccountsSchema(mysqlTable);
9587
9882
  const users = getUsersSchema(mysqlTable);
9588
- return (0, import_drizzle_orm19.relations)(accounts, ({ one }) => ({
9883
+ return (0, import_drizzle_orm21.relations)(accounts, ({ one }) => ({
9589
9884
  user: one(users, {
9590
9885
  fields: [
9591
9886
  accounts.userId
@@ -9600,38 +9895,38 @@ function getAccountsRelationsSchema(mysqlTable) {
9600
9895
  __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
9601
9896
 
9602
9897
  // src/lib/mysql/schemas/auth/role-permissions.ts
9603
- var import_drizzle_orm20 = require("drizzle-orm");
9604
- var import_mysql_core23 = require("drizzle-orm/mysql-core");
9898
+ var import_drizzle_orm22 = require("drizzle-orm");
9899
+ var import_mysql_core26 = require("drizzle-orm/mysql-core");
9605
9900
  function getRolePermissionsSchema(mysqlTable) {
9606
9901
  return mysqlTable("rolePermission", {
9607
- roleId: (0, import_mysql_core23.varchar)("roleId", {
9902
+ roleId: (0, import_mysql_core26.varchar)("roleId", {
9608
9903
  length: 255
9609
9904
  }).notNull(),
9610
- permissionId: (0, import_mysql_core23.varchar)("permissionId", {
9905
+ permissionId: (0, import_mysql_core26.varchar)("permissionId", {
9611
9906
  length: 255
9612
9907
  }).notNull(),
9613
- active: (0, import_mysql_core23.boolean)("active").notNull().default(true),
9614
- createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
9908
+ active: (0, import_mysql_core26.boolean)("active").notNull().default(true),
9909
+ createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
9615
9910
  mode: "date",
9616
9911
  fsp: 3
9617
9912
  }).defaultNow(),
9618
- updatedAt: (0, import_mysql_core23.timestamp)("updatedAt", {
9913
+ updatedAt: (0, import_mysql_core26.timestamp)("updatedAt", {
9619
9914
  mode: "date",
9620
9915
  fsp: 3
9621
9916
  }).defaultNow(),
9622
- deletedAt: (0, import_mysql_core23.timestamp)("deletedAt", {
9917
+ deletedAt: (0, import_mysql_core26.timestamp)("deletedAt", {
9623
9918
  mode: "date",
9624
9919
  fsp: 3
9625
9920
  })
9626
9921
  }, (rp) => ({
9627
- pk: (0, import_mysql_core23.primaryKey)({
9922
+ pk: (0, import_mysql_core26.primaryKey)({
9628
9923
  columns: [
9629
9924
  rp.roleId,
9630
9925
  rp.permissionId
9631
9926
  ]
9632
9927
  }),
9633
- roleIdIdx: (0, import_mysql_core23.index)("roleId_idx").on(rp.roleId),
9634
- permissionIdIdx: (0, import_mysql_core23.index)("permissionId_idx").on(rp.permissionId)
9928
+ roleIdIdx: (0, import_mysql_core26.index)("roleId_idx").on(rp.roleId),
9929
+ permissionIdIdx: (0, import_mysql_core26.index)("permissionId_idx").on(rp.permissionId)
9635
9930
  }));
9636
9931
  }
9637
9932
  __name(getRolePermissionsSchema, "getRolePermissionsSchema");
@@ -9639,7 +9934,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
9639
9934
  const permissions = getPermissionsSchema(mysqlTable);
9640
9935
  const roles = getRolesSchema(mysqlTable);
9641
9936
  const rolePermissions = getRolePermissionsSchema(mysqlTable);
9642
- return (0, import_drizzle_orm20.relations)(rolePermissions, ({ one }) => ({
9937
+ return (0, import_drizzle_orm22.relations)(rolePermissions, ({ one }) => ({
9643
9938
  role: one(roles, {
9644
9939
  fields: [
9645
9940
  rolePermissions.roleId
@@ -9663,28 +9958,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
9663
9958
  __name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
9664
9959
 
9665
9960
  // src/lib/mysql/schemas/auth/sessions.ts
9666
- var import_drizzle_orm21 = require("drizzle-orm");
9667
- var import_mysql_core24 = require("drizzle-orm/mysql-core");
9961
+ var import_drizzle_orm23 = require("drizzle-orm");
9962
+ var import_mysql_core27 = require("drizzle-orm/mysql-core");
9668
9963
  function getSessionsSchema(mysqlTable) {
9669
9964
  return mysqlTable("session", {
9670
- sessionToken: (0, import_mysql_core24.varchar)("sessionToken", {
9965
+ sessionToken: (0, import_mysql_core27.varchar)("sessionToken", {
9671
9966
  length: 255
9672
9967
  }).notNull().primaryKey(),
9673
- userId: (0, import_mysql_core24.varchar)("userId", {
9968
+ userId: (0, import_mysql_core27.varchar)("userId", {
9674
9969
  length: 255
9675
9970
  }).notNull(),
9676
- expires: (0, import_mysql_core24.timestamp)("expires", {
9971
+ expires: (0, import_mysql_core27.timestamp)("expires", {
9677
9972
  mode: "date"
9678
9973
  }).notNull()
9679
9974
  }, (session) => ({
9680
- userIdIdx: (0, import_mysql_core24.index)("userId_idx").on(session.userId)
9975
+ userIdIdx: (0, import_mysql_core27.index)("userId_idx").on(session.userId)
9681
9976
  }));
9682
9977
  }
9683
9978
  __name(getSessionsSchema, "getSessionsSchema");
9684
9979
  function getSessionRelationsSchema(mysqlTable) {
9685
9980
  const sessions = getSessionsSchema(mysqlTable);
9686
9981
  const users = getUsersSchema(mysqlTable);
9687
- return (0, import_drizzle_orm21.relations)(sessions, ({ one }) => ({
9982
+ return (0, import_drizzle_orm23.relations)(sessions, ({ one }) => ({
9688
9983
  user: one(users, {
9689
9984
  fields: [
9690
9985
  sessions.userId
@@ -9699,24 +9994,24 @@ function getSessionRelationsSchema(mysqlTable) {
9699
9994
  __name(getSessionRelationsSchema, "getSessionRelationsSchema");
9700
9995
 
9701
9996
  // src/lib/mysql/schemas/auth/verification-tokens.ts
9702
- var import_mysql_core25 = require("drizzle-orm/mysql-core");
9997
+ var import_mysql_core28 = require("drizzle-orm/mysql-core");
9703
9998
  function getVerificationTokensSchema(mysqlTable) {
9704
9999
  return mysqlTable("verificationToken", {
9705
- identifier: (0, import_mysql_core25.varchar)("identifier", {
10000
+ identifier: (0, import_mysql_core28.varchar)("identifier", {
9706
10001
  length: 255
9707
10002
  }).notNull(),
9708
- token: (0, import_mysql_core25.varchar)("token", {
10003
+ token: (0, import_mysql_core28.varchar)("token", {
9709
10004
  length: 255
9710
10005
  }).notNull(),
9711
- expires: (0, import_mysql_core25.timestamp)("expires", {
10006
+ expires: (0, import_mysql_core28.timestamp)("expires", {
9712
10007
  mode: "date"
9713
10008
  }).notNull(),
9714
- createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
10009
+ createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
9715
10010
  mode: "date",
9716
10011
  fsp: 3
9717
10012
  }).defaultNow()
9718
10013
  }, (vt) => ({
9719
- pk: (0, import_mysql_core25.primaryKey)({
10014
+ pk: (0, import_mysql_core28.primaryKey)({
9720
10015
  columns: [
9721
10016
  vt.identifier,
9722
10017
  vt.token
@@ -9726,109 +10021,6 @@ function getVerificationTokensSchema(mysqlTable) {
9726
10021
  }
9727
10022
  __name(getVerificationTokensSchema, "getVerificationTokensSchema");
9728
10023
 
9729
- // src/lib/mysql/schemas/commerce/merchant-account.ts
9730
- var import_drizzle_orm22 = require("drizzle-orm");
9731
- var import_mysql_core26 = require("drizzle-orm/mysql-core");
9732
- function getMerchantAccountSchema(mysqlTable) {
9733
- return mysqlTable("merchantAccounts", {
9734
- id: (0, import_mysql_core26.varchar)("id", {
9735
- length: 191
9736
- }).notNull(),
9737
- status: (0, import_mysql_core26.int)("status").default(0).notNull(),
9738
- createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
9739
- mode: "date",
9740
- fsp: 3
9741
- }).default(import_drizzle_orm22.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9742
- label: (0, import_mysql_core26.varchar)("label", {
9743
- length: 191
9744
- }),
9745
- identifier: (0, import_mysql_core26.varchar)("identifier", {
9746
- length: 191
9747
- })
9748
- }, (table) => {
9749
- return {
9750
- merchantAccountId: (0, import_mysql_core26.primaryKey)({
9751
- columns: [
9752
- table.id
9753
- ],
9754
- name: "MerchantAccount_id"
9755
- })
9756
- };
9757
- });
9758
- }
9759
- __name(getMerchantAccountSchema, "getMerchantAccountSchema");
9760
-
9761
- // src/lib/mysql/schemas/commerce/merchant-coupon.ts
9762
- var import_mysql_core27 = require("drizzle-orm/mysql-core");
9763
- function getMerchantCouponSchema(mysqlTable) {
9764
- return mysqlTable("merchantCoupons", {
9765
- id: (0, import_mysql_core27.varchar)("id", {
9766
- length: 191
9767
- }).notNull(),
9768
- identifier: (0, import_mysql_core27.varchar)("identifier", {
9769
- length: 191
9770
- }),
9771
- status: (0, import_mysql_core27.int)("status").default(0).notNull(),
9772
- merchantAccountId: (0, import_mysql_core27.varchar)("merchantAccountId", {
9773
- length: 191
9774
- }).notNull(),
9775
- percentageDiscount: (0, import_mysql_core27.decimal)("percentageDiscount", {
9776
- precision: 3,
9777
- scale: 2
9778
- }).notNull(),
9779
- type: (0, import_mysql_core27.varchar)("type", {
9780
- length: 191
9781
- })
9782
- }, (table) => {
9783
- return {
9784
- merchantCouponId: (0, import_mysql_core27.primaryKey)({
9785
- columns: [
9786
- table.id
9787
- ],
9788
- name: "MerchantCoupon_id"
9789
- }),
9790
- merchantCouponIdentifierKey: (0, import_mysql_core27.unique)("MerchantCoupon_identifier_key").on(table.identifier)
9791
- };
9792
- });
9793
- }
9794
- __name(getMerchantCouponSchema, "getMerchantCouponSchema");
9795
-
9796
- // src/lib/mysql/schemas/commerce/merchant-customer.ts
9797
- var import_drizzle_orm23 = require("drizzle-orm");
9798
- var import_mysql_core28 = require("drizzle-orm/mysql-core");
9799
- function getMerchantCustomerSchema(mysqlTable) {
9800
- return mysqlTable("merchantCustomers", {
9801
- id: (0, import_mysql_core28.varchar)("id", {
9802
- length: 191
9803
- }).notNull(),
9804
- userId: (0, import_mysql_core28.varchar)("userId", {
9805
- length: 191
9806
- }).notNull(),
9807
- merchantAccountId: (0, import_mysql_core28.varchar)("merchantAccountId", {
9808
- length: 191
9809
- }).notNull(),
9810
- identifier: (0, import_mysql_core28.varchar)("identifier", {
9811
- length: 191
9812
- }).notNull(),
9813
- createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
9814
- mode: "date",
9815
- fsp: 3
9816
- }).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`).notNull(),
9817
- status: (0, import_mysql_core28.int)("status").default(0)
9818
- }, (table) => {
9819
- return {
9820
- merchantCustomerId: (0, import_mysql_core28.primaryKey)({
9821
- columns: [
9822
- table.id
9823
- ],
9824
- name: "MerchantCustomer_id"
9825
- }),
9826
- merchantCustomerIdentifierKey: (0, import_mysql_core28.unique)("MerchantCustomer_identifier_key").on(table.identifier)
9827
- };
9828
- });
9829
- }
9830
- __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
9831
-
9832
10024
  // src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
9833
10025
  var import_drizzle_orm24 = require("drizzle-orm");
9834
10026
  var import_mysql_core29 = require("drizzle-orm/mysql-core");
@@ -9887,6 +10079,41 @@ function getPurchaseUserTransferSchema(mysqlTable) {
9887
10079
  });
9888
10080
  }
9889
10081
  __name(getPurchaseUserTransferSchema, "getPurchaseUserTransferSchema");
10082
+ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
10083
+ const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
10084
+ const user = getUsersSchema(mysqlTable);
10085
+ const purchase = getPurchaseSchema(mysqlTable);
10086
+ return (0, import_drizzle_orm24.relations)(purchaseUserTransfer, ({ one }) => ({
10087
+ sourceUser: one(user, {
10088
+ fields: [
10089
+ purchaseUserTransfer.sourceUserId
10090
+ ],
10091
+ references: [
10092
+ user.id
10093
+ ],
10094
+ relationName: "sourceUser"
10095
+ }),
10096
+ targetUser: one(user, {
10097
+ fields: [
10098
+ purchaseUserTransfer.targetUserId
10099
+ ],
10100
+ references: [
10101
+ user.id
10102
+ ],
10103
+ relationName: "targetUser"
10104
+ }),
10105
+ purchase: one(purchase, {
10106
+ fields: [
10107
+ purchaseUserTransfer.purchaseId
10108
+ ],
10109
+ references: [
10110
+ purchase.id
10111
+ ],
10112
+ relationName: "purchase"
10113
+ })
10114
+ }));
10115
+ }
10116
+ __name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
9890
10117
 
9891
10118
  // src/lib/mysql/schemas/commerce/upgradable-products.ts
9892
10119
  var import_drizzle_orm25 = require("drizzle-orm");
@@ -10015,6 +10242,7 @@ function getCourseBuilderSchema(mysqlTable) {
10015
10242
  couponRelations: getCouponRelationsSchema(mysqlTable),
10016
10243
  merchantAccount: getMerchantAccountSchema(mysqlTable),
10017
10244
  merchantCharge: getMerchantChargeSchema(mysqlTable),
10245
+ merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
10018
10246
  merchantCoupon: getMerchantCouponSchema(mysqlTable),
10019
10247
  merchantCustomer: getMerchantCustomerSchema(mysqlTable),
10020
10248
  merchantPrice: getMerchantPriceSchema(mysqlTable),
@@ -10025,6 +10253,7 @@ function getCourseBuilderSchema(mysqlTable) {
10025
10253
  purchases: getPurchaseSchema(mysqlTable),
10026
10254
  purchaseRelations: getPurchaseRelationsSchema(mysqlTable),
10027
10255
  purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
10256
+ purchaseUserTransferRelations: getPurchaseUserTransferRelationsSchema(mysqlTable),
10028
10257
  communicationChannel: getCommunicationChannelSchema(mysqlTable),
10029
10258
  communicationPreferenceTypes: getCommunicationPreferenceTypesSchema(mysqlTable),
10030
10259
  communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
@@ -10052,31 +10281,31 @@ function createTables(mySqlTable) {
10052
10281
  __name(createTables, "createTables");
10053
10282
  function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10054
10283
  const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress } = createTables(tableFn);
10055
- return {
10284
+ const adapter = {
10056
10285
  client,
10057
10286
  async redeemFullPriceCoupon(options) {
10058
10287
  const { email: baseEmail, couponId, productIds, currentUserId, redeemingProductId } = options;
10059
10288
  const email = String(baseEmail).replace(" ", "+");
10060
- const coupon2 = await this.getCouponWithBulkPurchases(couponId);
10289
+ const coupon2 = await adapter.getCouponWithBulkPurchases(couponId);
10061
10290
  const productId = coupon2 && coupon2.restrictedToProductId || redeemingProductId;
10062
10291
  if (!productId)
10063
10292
  throw new Error(`unable-to-find-any-product-id`);
10064
10293
  const couponValidation = validateCoupon(coupon2, productIds);
10065
10294
  if (coupon2 && couponValidation.isRedeemable) {
10066
- const bulkCouponRedemption = Boolean(coupon2.bulkCouponPurchases[0]?.bulkCouponId);
10067
- const { user } = await this.findOrCreateUser(email);
10295
+ const bulkCouponRedemption = Boolean(coupon2.bulkPurchase?.bulkCouponId);
10296
+ const { user } = await adapter.findOrCreateUser(email);
10068
10297
  if (!user)
10069
10298
  throw new Error(`unable-to-create-user-${email}`);
10070
- const currentUser = currentUserId ? await this.getUserById(currentUserId) : null;
10299
+ const currentUser = currentUserId ? await adapter.getUserById(currentUserId) : null;
10071
10300
  const redeemingForCurrentUser = currentUser?.id === user.id;
10072
- const existingPurchases = await this.getExistingNonBulkValidPurchasesOfProduct({
10301
+ const existingPurchases = await adapter.getExistingNonBulkValidPurchasesOfProduct({
10073
10302
  userId: user.id,
10074
10303
  productId
10075
10304
  });
10076
10305
  if (existingPurchases.length > 0)
10077
10306
  throw new Error(`already-purchased-${email}`);
10078
10307
  const purchaseId = `purchase-${(0, import_uuid.v4)()}`;
10079
- await this.createPurchase({
10308
+ await adapter.createPurchase({
10080
10309
  id: purchaseId,
10081
10310
  userId: user.id,
10082
10311
  couponId: bulkCouponRedemption ? null : coupon2.id,
@@ -10087,9 +10316,9 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10087
10316
  couponUsedId: bulkCouponRedemption ? null : coupon2.id
10088
10317
  }
10089
10318
  });
10090
- const newPurchase = await this.getPurchase(purchaseId);
10091
- await this.incrementCouponUsedCount(coupon2.id);
10092
- await this.createPurchaseTransfer({
10319
+ const newPurchase = await adapter.getPurchase(purchaseId);
10320
+ await adapter.incrementCouponUsedCount(coupon2.id);
10321
+ await adapter.createPurchaseTransfer({
10093
10322
  sourceUserId: user.id,
10094
10323
  purchaseId,
10095
10324
  expiresAt: new Date(Date.now() + 1e3 * 60 * 60 * 24 * 7)
@@ -10171,14 +10400,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10171
10400
  where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm27.eq)(upgradableProducts.upgradableToId, upgradableToId))
10172
10401
  }));
10173
10402
  },
10174
- availableUpgradesForProduct(purchases, productId) {
10403
+ async availableUpgradesForProduct(purchases, productId) {
10175
10404
  const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
10176
- return client.query.upgradableProducts.findMany({
10177
- where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm27.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
10178
- });
10405
+ if (previousPurchaseProductIds.length > 0) {
10406
+ return await client.query.upgradableProducts.findMany({
10407
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm27.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
10408
+ });
10409
+ }
10410
+ return [];
10179
10411
  },
10180
10412
  clearLessonProgressForUser(options) {
10181
- throw new Error("Method not implemented.");
10413
+ throw new Error("clearLessonProgressForUser Method not implemented.");
10182
10414
  },
10183
10415
  async completeLessonProgressForUser(options) {
10184
10416
  if (!options.lessonId) {
@@ -10213,8 +10445,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10213
10445
  }
10214
10446
  return parsedLessonProgress.data;
10215
10447
  },
10216
- couponForIdOrCode(options) {
10217
- throw new Error("Method not implemented.");
10448
+ async couponForIdOrCode(options) {
10449
+ if (!options.couponId && !options.code)
10450
+ return null;
10451
+ const couponForIdOrCode = await client.query.coupon.findFirst({
10452
+ where: (0, import_drizzle_orm27.or)((0, import_drizzle_orm27.and)((0, import_drizzle_orm27.or)(options.code ? (0, import_drizzle_orm27.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm27.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm27.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.or)(options.code ? (0, import_drizzle_orm27.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm27.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm27.isNull)(coupon.expires))),
10453
+ with: {
10454
+ merchantCoupon: true
10455
+ }
10456
+ });
10457
+ if (!couponForIdOrCode)
10458
+ return null;
10459
+ return couponSchema.extend({
10460
+ merchantCoupon: merchantCouponSchema
10461
+ }).parse(couponForIdOrCode);
10218
10462
  },
10219
10463
  async createMerchantChargeAndPurchase(options) {
10220
10464
  const purchaseId = await client.transaction(async (trx) => {
@@ -10251,14 +10495,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10251
10495
  ]))
10252
10496
  }) || null);
10253
10497
  const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm27.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm27.eq)(purchaseTable.userId, userId))).then((res) => {
10254
- console.log({
10255
- res
10256
- });
10257
10498
  return res[0]?.coupons ?? null;
10258
10499
  }));
10259
- console.log({
10260
- existingBulkCoupon
10261
- });
10262
10500
  const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
10263
10501
  let bulkCouponId = null;
10264
10502
  let couponToUpdate = null;
@@ -10290,21 +10528,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10290
10528
  identifier: checkoutSessionId,
10291
10529
  merchantAccountId
10292
10530
  });
10293
- console.log({
10294
- newMerchantSession
10295
- });
10296
10531
  const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
10297
10532
  where: (0, import_drizzle_orm27.eq)(merchantCoupon.identifier, stripeCouponId)
10298
10533
  }) : null;
10299
- console.log({
10300
- merchantCouponUsed
10301
- });
10302
10534
  const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
10303
10535
  where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm27.eq)(merchantCoupon.type, "ppp"))
10304
10536
  }) : null;
10305
- console.log({
10306
- pppMerchantCoupon
10307
- });
10308
10537
  const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
10309
10538
  const newPurchase = await client.insert(purchaseTable).values({
10310
10539
  id: purchaseId2,
@@ -10319,9 +10548,6 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10319
10548
  upgradedFromId: upgradedFromPurchaseId || null,
10320
10549
  couponId: usedCouponId || null
10321
10550
  });
10322
- console.log({
10323
- newPurchase
10324
- });
10325
10551
  const oneWeekInMilliseconds = 1e3 * 60 * 60 * 24 * 7;
10326
10552
  const newPurchaseUserTransfer = await client.insert(purchaseUserTransfer).values({
10327
10553
  id: `put_${(0, import_uuid.v4)()}`,
@@ -10329,12 +10555,6 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10329
10555
  expiresAt: existingPurchase ? /* @__PURE__ */ new Date() : new Date(Date.now() + oneWeekInMilliseconds),
10330
10556
  sourceUserId: userId
10331
10557
  });
10332
- console.log({
10333
- newPurchaseUserTransfer
10334
- });
10335
- console.log("inside", {
10336
- purchaseId: purchaseId2
10337
- });
10338
10558
  return purchaseId2;
10339
10559
  } catch (error) {
10340
10560
  console.error(error);
@@ -10342,9 +10562,6 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10342
10562
  throw error;
10343
10563
  }
10344
10564
  });
10345
- console.log("putside", {
10346
- purchaseId
10347
- });
10348
10565
  const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
10349
10566
  where: (0, import_drizzle_orm27.eq)(purchaseTable.id, purchaseId)
10350
10567
  }));
@@ -10361,16 +10578,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10361
10578
  if (merchantCustomer2) {
10362
10579
  return merchantCustomer2;
10363
10580
  }
10364
- return await this.createMerchantCustomer({
10581
+ return await adapter.createMerchantCustomer({
10365
10582
  identifier: options.identifier,
10366
10583
  merchantAccountId: options.merchantAccountId,
10367
10584
  userId: options.user.id
10368
10585
  });
10369
10586
  },
10370
10587
  async findOrCreateUser(email, name) {
10371
- const user = await this.getUserByEmail?.(email);
10588
+ const user = await adapter.getUserByEmail?.(email);
10372
10589
  if (!user) {
10373
- const newUser = await this.createUser?.({
10590
+ const newUser = await adapter.createUser?.({
10374
10591
  id: `u_${(0, import_uuid.v4)()}`,
10375
10592
  email,
10376
10593
  name,
@@ -10392,26 +10609,154 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10392
10609
  async getCoupon(couponIdOrCode) {
10393
10610
  return couponSchema.nullable().parse(await client.select().from(coupon).where((0, import_drizzle_orm27.or)((0, import_drizzle_orm27.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm27.eq)(coupon.code, couponIdOrCode))).then((res) => res[0] ?? null));
10394
10611
  },
10395
- getCouponWithBulkPurchases(couponId) {
10396
- throw new Error("Method not implemented.");
10612
+ async getCouponWithBulkPurchases(couponId) {
10613
+ logger.debug("getCouponWithBulkPurchases", {
10614
+ couponId
10615
+ });
10616
+ let couponData;
10617
+ try {
10618
+ couponData = await client.query.coupon.findFirst({
10619
+ where: (0, import_drizzle_orm27.eq)(coupon.id, couponId),
10620
+ with: {
10621
+ bulkPurchase: true,
10622
+ bulkCouponPurchases: true
10623
+ }
10624
+ }) || null;
10625
+ } catch (e) {
10626
+ console.log("getCouponWithBulkPurchases");
10627
+ logger.error(e);
10628
+ }
10629
+ if (!couponData) {
10630
+ logger.debug("getCouponWithBulkPurchases", {
10631
+ couponId,
10632
+ error: "no coupon found"
10633
+ });
10634
+ return null;
10635
+ }
10636
+ const parsedCoupon = couponSchema.merge(z.object({
10637
+ bulkCouponPurchases: z.array(purchaseSchema),
10638
+ bulkPurchase: purchaseSchema.nullable().optional()
10639
+ })).nullable().safeParse(couponData);
10640
+ if (!parsedCoupon.success) {
10641
+ console.error("Error parsing coupon", couponData);
10642
+ return null;
10643
+ }
10644
+ return parsedCoupon.data;
10397
10645
  },
10398
- getDefaultCoupon(productIds) {
10399
- throw new Error("Method not implemented.");
10646
+ async getDefaultCoupon(productIds) {
10647
+ const activeSaleCoupon = await client.query.coupon.findFirst({
10648
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(coupon.status, 1), (0, import_drizzle_orm27.eq)(coupon.default, true), (0, import_drizzle_orm27.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm27.or)(productIds ? (0, import_drizzle_orm27.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm27.isNull)(coupon.restrictedToProductId))),
10649
+ orderBy: (0, import_drizzle_orm27.desc)(coupon.percentageDiscount),
10650
+ with: {
10651
+ merchantCoupon: true,
10652
+ product: true
10653
+ }
10654
+ });
10655
+ if (activeSaleCoupon) {
10656
+ const { restrictedToProductId } = activeSaleCoupon;
10657
+ const validForProdcutId = restrictedToProductId ? productIds?.includes(restrictedToProductId) : true;
10658
+ const { merchantCoupon: defaultMerchantCoupon, ...defaultCoupon } = activeSaleCoupon;
10659
+ if (validForProdcutId) {
10660
+ return {
10661
+ defaultMerchantCoupon: merchantCouponSchema.parse(defaultMerchantCoupon),
10662
+ defaultCoupon: couponSchema.parse(defaultCoupon)
10663
+ };
10664
+ }
10665
+ }
10666
+ return null;
10400
10667
  },
10401
10668
  getLessonProgressCountsByDate() {
10402
- throw new Error("Method not implemented.");
10669
+ throw new Error("getLessonProgressCountsByDate Method not implemented.");
10403
10670
  },
10404
- getLessonProgressForUser(userId) {
10405
- throw new Error("Method not implemented.");
10671
+ async getLessonProgressForUser(userId) {
10672
+ const userProgress = await client.query.resourceProgress.findMany({
10673
+ where: (0, import_drizzle_orm27.eq)(resourceProgress.userId, userId)
10674
+ });
10675
+ const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
10676
+ if (!parsed.success) {
10677
+ console.error("Error parsing user progress", userProgress);
10678
+ return [];
10679
+ }
10680
+ return parsed.data;
10681
+ },
10682
+ async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
10683
+ const module2 = await client.query.contentResource.findFirst({
10684
+ where: (0, import_drizzle_orm27.or)((0, import_drizzle_orm27.eq)(contentResource.id, moduleIdOrSlug), (0, import_drizzle_orm27.eq)(import_drizzle_orm27.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, moduleIdOrSlug)),
10685
+ with: {
10686
+ resources: {
10687
+ orderBy: (0, import_drizzle_orm27.asc)(contentResourceResource.position)
10688
+ }
10689
+ }
10690
+ });
10691
+ const parsedModule = ContentResourceSchema.parse(module2);
10692
+ const moduleResources = await client.query.contentResourceResource.findMany({
10693
+ where: (0, import_drizzle_orm27.inArray)(contentResourceResource.resourceOfId, parsedModule.resources?.map((r) => r.resourceId) ?? []),
10694
+ orderBy: (0, import_drizzle_orm27.asc)(contentResourceResource.position)
10695
+ });
10696
+ const parsedModuleResources = z.array(ContentResourceResourceSchema).safeParse(moduleResources);
10697
+ if (!parsedModuleResources.success) {
10698
+ console.error("Error parsing module resources", parsedModuleResources.error);
10699
+ return {
10700
+ completedLessons: [],
10701
+ nextResource: null,
10702
+ percentCompleted: 0,
10703
+ completedLessonsCount: 0,
10704
+ totalLessonsCount: 0
10705
+ };
10706
+ }
10707
+ const user = await client.query.users.findFirst({
10708
+ where: (0, import_drizzle_orm27.or)((0, import_drizzle_orm27.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm27.eq)(users.email, userIdOrEmail)),
10709
+ with: {
10710
+ roles: true
10711
+ }
10712
+ });
10713
+ if (!user) {
10714
+ console.error("User not found", userIdOrEmail);
10715
+ return {
10716
+ completedLessons: [],
10717
+ nextResource: null,
10718
+ percentCompleted: 0,
10719
+ completedLessonsCount: 0,
10720
+ totalLessonsCount: parsedModuleResources.data.length
10721
+ };
10722
+ }
10723
+ const parsedUser = userSchema.parse(user);
10724
+ const userProgress = await client.query.resourceProgress.findMany({
10725
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(resourceProgress.userId, parsedUser.id), (0, import_drizzle_orm27.isNotNull)(resourceProgress.completedAt), (0, import_drizzle_orm27.inArray)(resourceProgress.contentResourceId, parsedModuleResources.data.map((r) => r.resourceId))),
10726
+ orderBy: (0, import_drizzle_orm27.asc)(resourceProgress.completedAt)
10727
+ });
10728
+ const nextResourceId = moduleResources.find((r) => !userProgress.find((p) => p.contentResourceId === r.resourceId))?.resourceId;
10729
+ const nextResource = await client.query.contentResource.findFirst({
10730
+ where: (0, import_drizzle_orm27.eq)(contentResource.id, nextResourceId)
10731
+ });
10732
+ const parsedNextResource = ContentResourceSchema.nullable().optional().default(null).parse(nextResource);
10733
+ const parsedProgress = z.array(resourceProgressSchema).safeParse(userProgress);
10734
+ if (!parsedProgress.success) {
10735
+ console.error("Error parsing user progress", parsedProgress.error);
10736
+ return {
10737
+ completedLessons: [],
10738
+ nextResource: null,
10739
+ percentCompleted: 0,
10740
+ completedLessonsCount: 0,
10741
+ totalLessonsCount: parsedModuleResources.data.length
10742
+ };
10743
+ }
10744
+ const percentCompleted = Math.round(parsedProgress.data.length / parsedModuleResources.data.length * 100);
10745
+ return {
10746
+ completedLessons: parsedProgress.data,
10747
+ nextResource: parsedNextResource,
10748
+ percentCompleted,
10749
+ completedLessonsCount: parsedProgress.data.length,
10750
+ totalLessonsCount: parsedModuleResources.data.length
10751
+ };
10406
10752
  },
10407
10753
  getLessonProgresses() {
10408
- throw new Error("Method not implemented.");
10754
+ throw new Error("getLessonProgresses Method not implemented.");
10409
10755
  },
10410
10756
  async getMerchantCharge(merchantChargeId) {
10411
10757
  const mCharge = await client.query.merchantCharge.findFirst({
10412
10758
  where: (0, import_drizzle_orm27.eq)(merchantCharge.id, merchantChargeId)
10413
10759
  });
10414
- console.log("mCharge", mCharge);
10415
10760
  const parsed = merchantChargeSchema.safeParse(mCharge);
10416
10761
  if (!parsed.success) {
10417
10762
  console.error("Error parsing merchantCharge", mCharge);
@@ -10450,7 +10795,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10450
10795
  }));
10451
10796
  },
10452
10797
  getPrice(productId) {
10453
- throw new Error("Method not implemented.");
10798
+ throw new Error("getPrice not implemented.");
10454
10799
  },
10455
10800
  async getPriceForProduct(productId) {
10456
10801
  return priceSchema.nullable().parse(await client.query.prices.findFirst({
@@ -10474,23 +10819,63 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10474
10819
  ...options,
10475
10820
  id: newPurchaseId
10476
10821
  });
10477
- const newPurchase = await this.getPurchase(newPurchaseId);
10822
+ const newPurchase = await adapter.getPurchase(newPurchaseId);
10478
10823
  return purchaseSchema.parse(newPurchase);
10479
10824
  },
10480
10825
  async getPurchaseForStripeCharge(stripeChargeId) {
10481
- const purchase = purchaseSchema.safeParse(await client.select().from(purchaseTable).leftJoin(merchantCharge, (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(merchantCharge.identifier, stripeChargeId), (0, import_drizzle_orm27.eq)(merchantCharge.id, purchaseTable.merchantChargeId))).then((res) => {
10482
- return res[0]?.purchases ?? null;
10826
+ logger.debug("getPurchaseForStripeCharge", {
10827
+ stripeChargeId
10828
+ });
10829
+ const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
10830
+ where: (0, import_drizzle_orm27.eq)(merchantCharge.identifier, stripeChargeId)
10831
+ }) || null);
10832
+ if (!chargeForPurchase) {
10833
+ logger.error(new Error("No charge found for purchase"));
10834
+ return null;
10835
+ }
10836
+ const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
10837
+ where: (0, import_drizzle_orm27.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
10838
+ with: {
10839
+ user: true,
10840
+ product: true,
10841
+ bulkCoupon: true
10842
+ }
10483
10843
  }));
10484
10844
  if (!purchase.success) {
10485
10845
  return null;
10486
10846
  }
10487
10847
  return purchase.data;
10488
10848
  },
10489
- getPurchaseUserTransferById(options) {
10490
- throw new Error("Method not implemented.");
10849
+ async getPurchaseUserTransferById(options) {
10850
+ const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
10851
+ where: (0, import_drizzle_orm27.eq)(purchaseUserTransfer.id, options.id),
10852
+ with: {
10853
+ sourceUser: true,
10854
+ targetUser: true,
10855
+ purchase: true
10856
+ }
10857
+ });
10858
+ return purchaseUserTransferSchema.merge(z.object({
10859
+ sourceUser: userSchema,
10860
+ targetUser: userSchema.nullable(),
10861
+ purchase: purchaseSchema
10862
+ })).nullable().parse(purchaseTransferData);
10491
10863
  },
10492
- getPurchaseWithUser(purchaseId) {
10493
- throw new Error("Method not implemented.");
10864
+ async getPurchaseWithUser(purchaseId) {
10865
+ const purchaseData = await client.query.purchases.findFirst({
10866
+ where: (0, import_drizzle_orm27.eq)(purchaseTable.id, purchaseId),
10867
+ with: {
10868
+ user: true
10869
+ }
10870
+ }) || null;
10871
+ const parsedPurchase = purchaseSchema.merge(z.object({
10872
+ user: userSchema
10873
+ })).nullable().safeParse(purchaseData);
10874
+ if (!parsedPurchase.success) {
10875
+ console.error("Error parsing purchase", parsedPurchase.error);
10876
+ return null;
10877
+ }
10878
+ return parsedPurchase.data;
10494
10879
  },
10495
10880
  async getPurchasesForUser(userId) {
10496
10881
  if (!userId) {
@@ -10534,9 +10919,6 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10534
10919
  });
10535
10920
  const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
10536
10921
  const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
10537
- console.log("\u{1F9A6}", {
10538
- allPurchases
10539
- });
10540
10922
  const thePurchase = await client.query.purchases.findFirst({
10541
10923
  where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm27.eq)(purchaseTable.userId, userId)),
10542
10924
  with: {
@@ -10552,9 +10934,6 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10552
10934
  availableUpgrades: []
10553
10935
  };
10554
10936
  }
10555
- console.log("\u{1F9A6}", {
10556
- parsedPurchase: parsedPurchase.data
10557
- });
10558
10937
  const purchaseCanUpgrade = [
10559
10938
  "Valid",
10560
10939
  "Restricted"
@@ -10569,17 +10948,42 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10569
10948
  }
10570
10949
  });
10571
10950
  }
10572
- const existingPurchase = allPurchases.find((p) => p.product?.id === parsedPurchase.data.product?.id);
10573
- return Promise.resolve({
10951
+ const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
10952
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm27.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm27.inArray)(purchaseTable.status, [
10953
+ "Valid",
10954
+ "Restricted"
10955
+ ]), (0, import_drizzle_orm27.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm27.not)((0, import_drizzle_orm27.eq)(purchaseTable.id, parsedPurchase.data.id))),
10956
+ with: {
10957
+ user: true,
10958
+ product: true,
10959
+ bulkCoupon: true
10960
+ }
10961
+ }) || null);
10962
+ return {
10574
10963
  availableUpgrades: z.array(upgradableProductSchema).parse(availableUpgrades),
10575
10964
  existingPurchase,
10576
10965
  purchase: parsedPurchase.data
10577
- });
10966
+ };
10578
10967
  },
10579
10968
  async getUserById(userId) {
10580
- return userSchema.nullable().parse(await client.query.users.findFirst({
10581
- where: (0, import_drizzle_orm27.eq)(users.id, userId)
10582
- }));
10969
+ const user = await client.query.users.findFirst({
10970
+ where: (0, import_drizzle_orm27.eq)(users.id, userId),
10971
+ with: {
10972
+ roles: {
10973
+ with: {
10974
+ role: true
10975
+ }
10976
+ }
10977
+ }
10978
+ }).then(async (res) => {
10979
+ if (res) {
10980
+ return {
10981
+ ...res,
10982
+ roles: res.roles.map((r) => r.role)
10983
+ };
10984
+ }
10985
+ });
10986
+ return userSchema.nullable().parse(user ?? null);
10583
10987
  },
10584
10988
  async pricesOfPurchasesTowardOneBundle({ userId, bundleId }) {
10585
10989
  if (userId === void 0)
@@ -10603,17 +11007,51 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10603
11007
  });
10604
11008
  return z.array(priceSchema).parse(foundPrices);
10605
11009
  },
10606
- toggleLessonProgressForUser(options) {
10607
- throw new Error("Method not implemented.");
11010
+ async toggleLessonProgressForUser(options) {
11011
+ if (!options.lessonId) {
11012
+ throw new Error("No lessonId provided");
11013
+ }
11014
+ let lessonProgress = await client.query.resourceProgress.findFirst({
11015
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm27.eq)(resourceProgress.contentResourceId, options.lessonId))
11016
+ });
11017
+ const now = /* @__PURE__ */ new Date();
11018
+ if (lessonProgress) {
11019
+ await client.update(resourceProgress).set({
11020
+ completedAt: lessonProgress.completedAt ? null : now,
11021
+ updatedAt: now
11022
+ }).where((0, import_drizzle_orm27.eq)(resourceProgress.contentResourceId, options.lessonId));
11023
+ } else {
11024
+ await client.insert(resourceProgress).values({
11025
+ userId: options.userId,
11026
+ contentResourceId: options.lessonId,
11027
+ completedAt: now,
11028
+ updatedAt: now
11029
+ });
11030
+ }
11031
+ lessonProgress = await client.query.resourceProgress.findFirst({
11032
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm27.eq)(resourceProgress.contentResourceId, options.lessonId))
11033
+ });
11034
+ const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
11035
+ if (!parsedLessonProgress.success) {
11036
+ console.error("Error parsing lesson progress", lessonProgress);
11037
+ return null;
11038
+ }
11039
+ return parsedLessonProgress.data;
10608
11040
  },
10609
11041
  transferPurchasesToNewUser(options) {
10610
11042
  throw new Error("Method not implemented.");
10611
11043
  },
10612
11044
  updatePurchaseStatusForCharge(chargeId, status) {
10613
- throw new Error("Method not implemented.");
11045
+ throw new Error("updatePurchaseStatusForCharge Method not implemented.");
10614
11046
  },
10615
- updatePurchaseUserTransferTransferState(options) {
10616
- throw new Error("Method not implemented.");
11047
+ async updatePurchaseUserTransferTransferState(options) {
11048
+ await client.update(purchaseUserTransfer).set({
11049
+ transferState: options.transferState
11050
+ }).where((0, import_drizzle_orm27.eq)(purchaseUserTransfer.id, options.id));
11051
+ const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
11052
+ where: (0, import_drizzle_orm27.eq)(purchaseUserTransfer.id, options.id)
11053
+ }) || null;
11054
+ return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
10617
11055
  },
10618
11056
  addResourceToResource: async function(options) {
10619
11057
  const { parentResourceId, childResourceId } = options;
@@ -10860,6 +11298,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10860
11298
  return void 0;
10861
11299
  }
10862
11300
  };
11301
+ return adapter;
10863
11302
  }
10864
11303
  __name(mySqlDrizzleAdapter, "mySqlDrizzleAdapter");
10865
11304
  // Annotate the CommonJS export names for ESM import in node: