@coursebuilder/adapter-drizzle 0.3.0 → 0.5.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.
- package/dist/{chunk-57CX5SOI.js → chunk-2UU2F4DM.js} +5 -4
- package/dist/{chunk-V23SCQL7.js → chunk-3NUCFLQJ.js} +2 -2
- package/dist/{chunk-Y7QZGEPT.js → chunk-4ZWS76VQ.js} +2 -2
- package/dist/{chunk-PPBEA4EM.js → chunk-6ON2O6UD.js} +2 -2
- package/dist/{chunk-QY4TPO7D.js → chunk-BM5UKWXI.js} +3 -3
- package/dist/{chunk-QMDE6HUA.js → chunk-CQNKTFXE.js} +3 -3
- package/dist/{chunk-4PJWD6YK.js → chunk-FRA4ZCRA.js} +462 -336
- package/dist/{chunk-J4LBG2TH.js → chunk-GINRTL6J.js} +2 -2
- package/dist/chunk-JZQ666KH.js +62 -0
- package/dist/{chunk-GLPDG7UE.js → chunk-KDEWFXEP.js} +2 -2
- package/dist/{chunk-MBB4GIJI.js → chunk-LERR6HQ3.js} +2 -2
- package/dist/{chunk-VDVCCU7D.js → chunk-LZHZDFNZ.js} +2 -2
- package/dist/{chunk-MCARHGE5.js → chunk-O6JECJRY.js} +4 -4
- package/dist/{chunk-BX5SO2JG.js → chunk-P4VXXTVA.js} +2 -2
- package/dist/{chunk-VXZRMVNY.js → chunk-QP6YMUQX.js} +2 -2
- package/dist/chunk-QTGVGIRO.js +54 -0
- package/dist/{chunk-ZD3R6UPJ.js → chunk-SRTIWWLG.js} +7 -7
- package/dist/{chunk-PIQXK2CY.js → chunk-TBM3AK3P.js} +3 -3
- package/dist/{chunk-FNYW3XKR.js → chunk-XIGJFVUM.js} +8 -8
- package/dist/{chunk-JKOYOL7A.js → chunk-YGRYHMCG.js} +2 -2
- package/dist/chunk-YVVXDJHI.js +56 -0
- package/dist/{chunk-J63FMGT7.js → chunk-Z245DYMP.js} +314 -190
- package/dist/index.js +22 -19
- package/dist/lib/mysql/index.cjs +1144 -774
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +2064 -1148
- package/dist/lib/mysql/index.d.ts +2064 -1148
- package/dist/lib/mysql/index.js +22 -19
- package/dist/lib/mysql/schemas/auth/accounts.cjs +85 -77
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +17 -17
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +17 -17
- package/dist/lib/mysql/schemas/auth/accounts.js +12 -12
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +214 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +52 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +52 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js +22 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +222 -0
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -0
- package/dist/lib/mysql/schemas/auth/device-verification.d.cts +88 -0
- package/dist/lib/mysql/schemas/auth/device-verification.d.ts +88 -0
- package/dist/lib/mysql/schemas/auth/device-verification.js +22 -0
- package/dist/lib/mysql/schemas/auth/device-verification.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/permissions.cjs +1 -1
- package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/permissions.d.cts +9 -9
- package/dist/lib/mysql/schemas/auth/permissions.d.ts +9 -9
- package/dist/lib/mysql/schemas/auth/permissions.js +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +74 -66
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +10 -10
- package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +10 -10
- package/dist/lib/mysql/schemas/auth/role-permissions.js +13 -13
- package/dist/lib/mysql/schemas/auth/roles.cjs +72 -64
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +10 -10
- package/dist/lib/mysql/schemas/auth/roles.d.ts +10 -10
- package/dist/lib/mysql/schemas/auth/roles.js +12 -12
- package/dist/lib/mysql/schemas/auth/sessions.cjs +75 -67
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.cts +6 -6
- package/dist/lib/mysql/schemas/auth/sessions.d.ts +6 -6
- package/dist/lib/mysql/schemas/auth/sessions.js +13 -13
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +77 -69
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +10 -10
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +10 -10
- package/dist/lib/mysql/schemas/auth/user-permissions.js +12 -12
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +222 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +100 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +100 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js +21 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +77 -69
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +10 -10
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +10 -10
- package/dist/lib/mysql/schemas/auth/user-roles.js +12 -12
- package/dist/lib/mysql/schemas/auth/users.cjs +263 -180
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +35 -21
- package/dist/lib/mysql/schemas/auth/users.d.ts +35 -21
- package/dist/lib/mysql/schemas/auth/users.js +12 -12
- package/dist/lib/mysql/schemas/auth/verification-tokens.cjs +1 -1
- package/dist/lib/mysql/schemas/auth/verification-tokens.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +5 -5
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +5 -5
- package/dist/lib/mysql/schemas/auth/verification-tokens.js +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +75 -65
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +19 -19
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +19 -19
- package/dist/lib/mysql/schemas/commerce/coupon.js +12 -12
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +6 -6
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +6 -6
- package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +6 -5
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +13 -13
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +13 -13
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +4 -4
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +7 -7
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +7 -7
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +3 -2
- package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +7 -7
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +7 -7
- package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +8 -8
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +8 -8
- package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +7 -7
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +7 -7
- package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +4 -4
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +4 -4
- package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
- package/dist/lib/mysql/schemas/commerce/price.cjs +60 -52
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +11 -11
- package/dist/lib/mysql/schemas/commerce/price.d.ts +11 -11
- package/dist/lib/mysql/schemas/commerce/price.js +12 -12
- package/dist/lib/mysql/schemas/commerce/product.cjs +75 -67
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +13 -13
- package/dist/lib/mysql/schemas/commerce/product.d.ts +13 -13
- package/dist/lib/mysql/schemas/commerce/product.js +12 -12
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +105 -96
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +15 -15
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +15 -15
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +13 -13
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +138 -128
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +25 -25
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +25 -25
- package/dist/lib/mysql/schemas/commerce/purchase.js +12 -12
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +66 -58
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +11 -11
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +11 -11
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +13 -13
- package/dist/lib/mysql/schemas/communication/comment.cjs +220 -0
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -0
- package/dist/lib/mysql/schemas/communication/comment.d.cts +100 -0
- package/dist/lib/mysql/schemas/communication/comment.d.ts +100 -0
- package/dist/lib/mysql/schemas/communication/comment.js +21 -0
- package/dist/lib/mysql/schemas/communication/comment.js.map +1 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +8 -8
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +8 -8
- package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +8 -8
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +8 -8
- package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +99 -91
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +16 -16
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +16 -16
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +12 -12
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +67 -59
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +13 -13
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +13 -13
- package/dist/lib/mysql/schemas/content/content-contributions.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +61 -53
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +11 -11
- package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +11 -11
- package/dist/lib/mysql/schemas/content/content-resource-product.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +58 -50
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +11 -11
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +11 -11
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +12 -12
- package/dist/lib/mysql/schemas/content/content-resource.cjs +114 -66
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +14 -13
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +14 -13
- package/dist/lib/mysql/schemas/content/content-resource.js +12 -12
- package/dist/lib/mysql/schemas/content/contribution-types.cjs +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.cts +10 -10
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +10 -10
- package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
- package/dist/lib/mysql/schemas/content/lesson-progress.cjs +77 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +132 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +132 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.js +8 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.js.map +1 -0
- package/dist/lib/mysql/schemas/content/resource-progress.cjs +7 -7
- package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/resource-progress.d.cts +9 -9
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +9 -9
- package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
- package/package.json +5 -5
- package/src/lib/mysql/index.ts +186 -54
- package/src/lib/mysql/schemas/auth/accounts.ts +1 -1
- package/src/lib/mysql/schemas/auth/device-access-token.ts +40 -0
- package/src/lib/mysql/schemas/auth/device-verification.ts +48 -0
- package/src/lib/mysql/schemas/auth/permissions.ts +1 -1
- package/src/lib/mysql/schemas/auth/role-permissions.ts +1 -1
- package/src/lib/mysql/schemas/auth/roles.ts +1 -1
- package/src/lib/mysql/schemas/auth/sessions.ts +1 -1
- package/src/lib/mysql/schemas/auth/user-permissions.ts +1 -1
- package/src/lib/mysql/schemas/auth/user-prefs.ts +52 -0
- package/src/lib/mysql/schemas/auth/user-roles.ts +1 -1
- package/src/lib/mysql/schemas/auth/users.ts +14 -2
- package/src/lib/mysql/schemas/auth/verification-tokens.ts +1 -1
- package/src/lib/mysql/schemas/commerce/coupon.ts +6 -4
- package/src/lib/mysql/schemas/commerce/merchant-account.ts +1 -1
- package/src/lib/mysql/schemas/commerce/merchant-charge.ts +1 -1
- package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +1 -1
- package/src/lib/mysql/schemas/commerce/merchant-customer.ts +3 -1
- package/src/lib/mysql/schemas/commerce/merchant-price.ts +1 -1
- package/src/lib/mysql/schemas/commerce/merchant-product.ts +1 -1
- package/src/lib/mysql/schemas/commerce/merchant-session.ts +1 -1
- package/src/lib/mysql/schemas/commerce/price.ts +1 -1
- package/src/lib/mysql/schemas/commerce/product.ts +1 -1
- package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +1 -1
- package/src/lib/mysql/schemas/commerce/purchase.ts +5 -4
- package/src/lib/mysql/schemas/commerce/upgradable-products.ts +1 -1
- package/src/lib/mysql/schemas/communication/comment.ts +52 -0
- package/src/lib/mysql/schemas/communication/communication-channel.ts +1 -1
- package/src/lib/mysql/schemas/communication/communication-preference-types.ts +1 -1
- package/src/lib/mysql/schemas/communication/communication-preferences.ts +1 -1
- package/src/lib/mysql/schemas/content/content-contributions.ts +1 -1
- package/src/lib/mysql/schemas/content/content-resource-product.ts +1 -1
- package/src/lib/mysql/schemas/content/content-resource-resource.ts +1 -1
- package/src/lib/mysql/schemas/content/content-resource.ts +6 -2
- package/src/lib/mysql/schemas/content/contribution-types.ts +1 -1
- package/src/lib/mysql/schemas/content/lesson-progress.ts +39 -0
- package/src/lib/mysql/schemas/content/resource-progress.ts +6 -8
package/dist/lib/mysql/index.cjs
CHANGED
|
@@ -27,8 +27,8 @@ __export(mysql_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(mysql_exports);
|
|
29
29
|
var import_date_fns2 = require("date-fns");
|
|
30
|
-
var
|
|
31
|
-
var
|
|
30
|
+
var import_drizzle_orm32 = require("drizzle-orm");
|
|
31
|
+
var import_mysql_core37 = require("drizzle-orm/mysql-core");
|
|
32
32
|
var import_uuid = require("uuid");
|
|
33
33
|
|
|
34
34
|
// ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
@@ -185,8 +185,8 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
185
185
|
"not_finite"
|
|
186
186
|
]);
|
|
187
187
|
var quotelessJson = /* @__PURE__ */ __name((obj) => {
|
|
188
|
-
const
|
|
189
|
-
return
|
|
188
|
+
const json13 = JSON.stringify(obj, null, 2);
|
|
189
|
+
return json13.replace(/"([^"]+)":/g, "$1:");
|
|
190
190
|
}, "quotelessJson");
|
|
191
191
|
var _ZodError = class _ZodError extends Error {
|
|
192
192
|
constructor(issues) {
|
|
@@ -2305,10 +2305,10 @@ var _ZodObject = class _ZodObject extends ZodType {
|
|
|
2305
2305
|
// }) as any;
|
|
2306
2306
|
// return merged;
|
|
2307
2307
|
// }
|
|
2308
|
-
catchall(
|
|
2308
|
+
catchall(index25) {
|
|
2309
2309
|
return new _ZodObject({
|
|
2310
2310
|
...this._def,
|
|
2311
|
-
catchall:
|
|
2311
|
+
catchall: index25
|
|
2312
2312
|
});
|
|
2313
2313
|
}
|
|
2314
2314
|
pick(mask) {
|
|
@@ -2623,9 +2623,9 @@ function mergeValues(a, b) {
|
|
|
2623
2623
|
return { valid: false };
|
|
2624
2624
|
}
|
|
2625
2625
|
const newArray = [];
|
|
2626
|
-
for (let
|
|
2627
|
-
const itemA = a[
|
|
2628
|
-
const itemB = b[
|
|
2626
|
+
for (let index25 = 0; index25 < a.length; index25++) {
|
|
2627
|
+
const itemA = a[index25];
|
|
2628
|
+
const itemB = b[index25];
|
|
2629
2629
|
const sharedValue = mergeValues(itemA, itemB);
|
|
2630
2630
|
if (!sharedValue.valid) {
|
|
2631
2631
|
return { valid: false };
|
|
@@ -2837,10 +2837,10 @@ var _ZodMap = class _ZodMap extends ZodType {
|
|
|
2837
2837
|
}
|
|
2838
2838
|
const keyType = this._def.keyType;
|
|
2839
2839
|
const valueType = this._def.valueType;
|
|
2840
|
-
const pairs = [...ctx.data.entries()].map(([key, value],
|
|
2840
|
+
const pairs = [...ctx.data.entries()].map(([key, value], index25) => {
|
|
2841
2841
|
return {
|
|
2842
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
|
2843
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [
|
|
2842
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index25, "key"])),
|
|
2843
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index25, "value"]))
|
|
2844
2844
|
};
|
|
2845
2845
|
});
|
|
2846
2846
|
if (ctx.common.async) {
|
|
@@ -4033,8 +4033,8 @@ var ZodIssueCode2 = util2.arrayToEnum([
|
|
|
4033
4033
|
"not_finite"
|
|
4034
4034
|
]);
|
|
4035
4035
|
var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
|
|
4036
|
-
const
|
|
4037
|
-
return
|
|
4036
|
+
const json13 = JSON.stringify(obj, null, 2);
|
|
4037
|
+
return json13.replace(/"([^"]+)":/g, "$1:");
|
|
4038
4038
|
}, "quotelessJson");
|
|
4039
4039
|
var _a;
|
|
4040
4040
|
var _ZodError2 = (_a = class extends Error {
|
|
@@ -6338,10 +6338,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
|
|
|
6338
6338
|
// }) as any;
|
|
6339
6339
|
// return merged;
|
|
6340
6340
|
// }
|
|
6341
|
-
catchall(
|
|
6341
|
+
catchall(index25) {
|
|
6342
6342
|
return new _a18({
|
|
6343
6343
|
...this._def,
|
|
6344
|
-
catchall:
|
|
6344
|
+
catchall: index25
|
|
6345
6345
|
});
|
|
6346
6346
|
}
|
|
6347
6347
|
pick(mask) {
|
|
@@ -6683,9 +6683,9 @@ function mergeValues2(a, b) {
|
|
|
6683
6683
|
};
|
|
6684
6684
|
}
|
|
6685
6685
|
const newArray = [];
|
|
6686
|
-
for (let
|
|
6687
|
-
const itemA = a[
|
|
6688
|
-
const itemB = b[
|
|
6686
|
+
for (let index25 = 0; index25 < a.length; index25++) {
|
|
6687
|
+
const itemA = a[index25];
|
|
6688
|
+
const itemB = b[index25];
|
|
6689
6689
|
const sharedValue = mergeValues2(itemA, itemB);
|
|
6690
6690
|
if (!sharedValue.valid) {
|
|
6691
6691
|
return {
|
|
@@ -6919,14 +6919,14 @@ var _ZodMap2 = (_a24 = class extends ZodType2 {
|
|
|
6919
6919
|
const valueType = this._def.valueType;
|
|
6920
6920
|
const pairs = [
|
|
6921
6921
|
...ctx.data.entries()
|
|
6922
|
-
].map(([key, value],
|
|
6922
|
+
].map(([key, value], index25) => {
|
|
6923
6923
|
return {
|
|
6924
6924
|
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
|
|
6925
|
-
|
|
6925
|
+
index25,
|
|
6926
6926
|
"key"
|
|
6927
6927
|
])),
|
|
6928
6928
|
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
|
|
6929
|
-
|
|
6929
|
+
index25,
|
|
6930
6930
|
"value"
|
|
6931
6931
|
]))
|
|
6932
6932
|
};
|
|
@@ -8044,26 +8044,38 @@ var z2 = /* @__PURE__ */ Object.freeze({
|
|
|
8044
8044
|
ZodError: ZodError2
|
|
8045
8045
|
});
|
|
8046
8046
|
|
|
8047
|
-
// ../core/dist/chunk-
|
|
8048
|
-
var
|
|
8047
|
+
// ../core/dist/chunk-CHYUPSYW.js
|
|
8048
|
+
var userSchema = z2.object({
|
|
8049
|
+
id: z2.string().max(255),
|
|
8050
|
+
name: z2.string().max(255).optional().nullable(),
|
|
8051
|
+
role: z2.enum([
|
|
8052
|
+
"user",
|
|
8053
|
+
"admin"
|
|
8054
|
+
]).default("user"),
|
|
8055
|
+
email: z2.string().max(255).email(),
|
|
8056
|
+
emailVerified: z2.coerce.date().nullable(),
|
|
8057
|
+
image: z2.string().max(255).optional().nullable(),
|
|
8058
|
+
createdAt: z2.coerce.date().nullable(),
|
|
8059
|
+
roles: z2.array(z2.object({
|
|
8060
|
+
id: z2.string(),
|
|
8061
|
+
name: z2.string(),
|
|
8062
|
+
description: z2.string().nullable(),
|
|
8063
|
+
active: z2.boolean()
|
|
8064
|
+
})).optional().default([])
|
|
8065
|
+
});
|
|
8066
|
+
|
|
8067
|
+
// ../core/dist/chunk-47RWEDJ6.js
|
|
8068
|
+
var priceSchema = z2.object({
|
|
8049
8069
|
id: z2.string().max(191),
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
"
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
"COMPLETED"
|
|
8058
|
-
]).default("AVAILABLE"),
|
|
8059
|
-
purchaseId: z2.string().max(191),
|
|
8060
|
-
sourceUserId: z2.string().max(191),
|
|
8061
|
-
targetUserId: z2.string().max(191).optional().nullable(),
|
|
8070
|
+
productId: z2.string().max(191).optional().nullable(),
|
|
8071
|
+
nickname: z2.string().max(191).optional().nullable(),
|
|
8072
|
+
status: z2.number().int().default(0),
|
|
8073
|
+
unitAmount: z2.coerce.number().refine((value) => {
|
|
8074
|
+
const decimalPlaces = value.toString().split(".")[1]?.length || 0;
|
|
8075
|
+
return decimalPlaces <= 2;
|
|
8076
|
+
}),
|
|
8062
8077
|
createdAt: z2.date().nullable(),
|
|
8063
|
-
|
|
8064
|
-
canceledAt: z2.date().nullable(),
|
|
8065
|
-
confirmedAt: z2.date().nullable(),
|
|
8066
|
-
completedAt: z2.date().nullable()
|
|
8078
|
+
fields: z2.record(z2.any()).default({})
|
|
8067
8079
|
});
|
|
8068
8080
|
|
|
8069
8081
|
// ../core/dist/chunk-YYIPQN6H.js
|
|
@@ -8110,111 +8122,6 @@ var ResourceVisibilitySchema = z2.union([
|
|
|
8110
8122
|
z2.literal("unlisted")
|
|
8111
8123
|
]);
|
|
8112
8124
|
|
|
8113
|
-
// ../core/dist/chunk-GCYJ74DO.js
|
|
8114
|
-
var resourceProgressSchema = z2.object({
|
|
8115
|
-
userId: z2.string().max(191),
|
|
8116
|
-
contentResourceId: z2.string().max(191).optional().nullable(),
|
|
8117
|
-
fields: z2.record(z2.any()).default({}),
|
|
8118
|
-
completedAt: z2.date().nullable(),
|
|
8119
|
-
updatedAt: z2.date().nullable(),
|
|
8120
|
-
createdAt: z2.date().nullable()
|
|
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
|
-
});
|
|
8129
|
-
|
|
8130
|
-
// ../core/dist/chunk-DLQA3JMA.js
|
|
8131
|
-
var upgradableProductSchema = z2.object({
|
|
8132
|
-
upgradableToId: z2.string().max(255),
|
|
8133
|
-
upgradableFromId: z2.string().max(255),
|
|
8134
|
-
position: z2.number().default(0),
|
|
8135
|
-
metadata: z2.record(z2.any()).default({}),
|
|
8136
|
-
createdAt: z2.date().nullable(),
|
|
8137
|
-
updatedAt: z2.date().nullable(),
|
|
8138
|
-
deletedAt: z2.date().nullable()
|
|
8139
|
-
});
|
|
8140
|
-
|
|
8141
|
-
// ../core/dist/chunk-G22WGQ3G.js
|
|
8142
|
-
var VideoResourceSchema = z2.object({
|
|
8143
|
-
id: z2.string(),
|
|
8144
|
-
updatedAt: z2.string().optional(),
|
|
8145
|
-
createdAt: z2.string().optional(),
|
|
8146
|
-
title: z2.string().optional().nullable(),
|
|
8147
|
-
duration: z2.number().optional().nullable(),
|
|
8148
|
-
muxPlaybackId: z2.string().optional().nullable(),
|
|
8149
|
-
muxAssetId: z2.string().optional().nullable(),
|
|
8150
|
-
transcript: z2.string().optional().nullable(),
|
|
8151
|
-
transcriptWithScreenshots: z2.string().optional().nullable(),
|
|
8152
|
-
srt: z2.string().optional().nullable(),
|
|
8153
|
-
wordLevelSrt: z2.string().optional().nullable(),
|
|
8154
|
-
state: z2.enum([
|
|
8155
|
-
"new",
|
|
8156
|
-
"processing",
|
|
8157
|
-
"preparing",
|
|
8158
|
-
"ready",
|
|
8159
|
-
"errored"
|
|
8160
|
-
])
|
|
8161
|
-
});
|
|
8162
|
-
|
|
8163
|
-
// ../core/dist/chunk-PS6USEN7.js
|
|
8164
|
-
var merchantPriceSchema = z2.object({
|
|
8165
|
-
id: z2.string().max(191),
|
|
8166
|
-
merchantAccountId: z2.string().max(191),
|
|
8167
|
-
merchantProductId: z2.string().max(191),
|
|
8168
|
-
status: z2.number().int().default(0),
|
|
8169
|
-
identifier: z2.string().max(191).optional().nullable(),
|
|
8170
|
-
createdAt: z2.date(),
|
|
8171
|
-
priceId: z2.string().max(191).optional().nullable()
|
|
8172
|
-
});
|
|
8173
|
-
|
|
8174
|
-
// ../core/dist/chunk-DAG4HKGL.js
|
|
8175
|
-
var merchantProductSchema = z2.object({
|
|
8176
|
-
id: z2.string().max(191),
|
|
8177
|
-
merchantAccountId: z2.string().max(191),
|
|
8178
|
-
productId: z2.string().max(191),
|
|
8179
|
-
status: z2.number().int().default(0),
|
|
8180
|
-
identifier: z2.string().max(191).optional().nullable(),
|
|
8181
|
-
createdAt: z2.date().nullable()
|
|
8182
|
-
});
|
|
8183
|
-
|
|
8184
|
-
// ../core/dist/chunk-CHYUPSYW.js
|
|
8185
|
-
var userSchema = z2.object({
|
|
8186
|
-
id: z2.string().max(255),
|
|
8187
|
-
name: z2.string().max(255).optional().nullable(),
|
|
8188
|
-
role: z2.enum([
|
|
8189
|
-
"user",
|
|
8190
|
-
"admin"
|
|
8191
|
-
]).default("user"),
|
|
8192
|
-
email: z2.string().max(255).email(),
|
|
8193
|
-
emailVerified: z2.coerce.date().nullable(),
|
|
8194
|
-
image: z2.string().max(255).optional().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([])
|
|
8202
|
-
});
|
|
8203
|
-
|
|
8204
|
-
// ../core/dist/chunk-47RWEDJ6.js
|
|
8205
|
-
var priceSchema = z2.object({
|
|
8206
|
-
id: z2.string().max(191),
|
|
8207
|
-
productId: z2.string().max(191).optional().nullable(),
|
|
8208
|
-
nickname: z2.string().max(191).optional().nullable(),
|
|
8209
|
-
status: z2.number().int().default(0),
|
|
8210
|
-
unitAmount: z2.coerce.number().refine((value) => {
|
|
8211
|
-
const decimalPlaces = value.toString().split(".")[1]?.length || 0;
|
|
8212
|
-
return decimalPlaces <= 2;
|
|
8213
|
-
}),
|
|
8214
|
-
createdAt: z2.date().nullable(),
|
|
8215
|
-
fields: z2.record(z2.any()).default({})
|
|
8216
|
-
});
|
|
8217
|
-
|
|
8218
8125
|
// ../core/dist/chunk-DGMGNBW7.js
|
|
8219
8126
|
var productSchema = z2.object({
|
|
8220
8127
|
id: z2.string().max(191),
|
|
@@ -8302,16 +8209,77 @@ var purchaseSchema = z2.object({
|
|
|
8302
8209
|
product: productSchema.optional().nullable()
|
|
8303
8210
|
});
|
|
8304
8211
|
|
|
8305
|
-
// ../core/dist/chunk-
|
|
8306
|
-
var
|
|
8212
|
+
// ../core/dist/chunk-LMH5A7OR.js
|
|
8213
|
+
var purchaseUserTransferSchema = z2.object({
|
|
8307
8214
|
id: z2.string().max(191),
|
|
8308
|
-
|
|
8309
|
-
|
|
8215
|
+
transferState: z2.enum([
|
|
8216
|
+
"AVAILABLE",
|
|
8217
|
+
"INITIATED",
|
|
8218
|
+
"VERIFIED",
|
|
8219
|
+
"CANCELED",
|
|
8220
|
+
"EXPIRED",
|
|
8221
|
+
"CONFIRMED",
|
|
8222
|
+
"COMPLETED"
|
|
8223
|
+
]).default("AVAILABLE"),
|
|
8224
|
+
purchaseId: z2.string().max(191),
|
|
8225
|
+
sourceUserId: z2.string().max(191),
|
|
8226
|
+
targetUserId: z2.string().max(191).optional().nullable(),
|
|
8227
|
+
createdAt: z2.date().nullable(),
|
|
8228
|
+
expiresAt: z2.date().nullable(),
|
|
8229
|
+
canceledAt: z2.date().nullable(),
|
|
8230
|
+
confirmedAt: z2.date().nullable(),
|
|
8231
|
+
completedAt: z2.date().nullable()
|
|
8232
|
+
});
|
|
8233
|
+
|
|
8234
|
+
// ../core/dist/chunk-K6G2HAJT.js
|
|
8235
|
+
var resourceProgressSchema = z2.object({
|
|
8310
8236
|
userId: z2.string().max(191),
|
|
8311
|
-
|
|
8312
|
-
|
|
8237
|
+
resourceId: z2.string().max(191).optional().nullable(),
|
|
8238
|
+
fields: z2.record(z2.any()).default({}),
|
|
8239
|
+
completedAt: z2.date().nullable(),
|
|
8240
|
+
updatedAt: z2.date().nullable(),
|
|
8241
|
+
createdAt: z2.date().nullable()
|
|
8242
|
+
});
|
|
8243
|
+
var moduleProgressSchema = z2.object({
|
|
8244
|
+
completedLessons: z2.array(resourceProgressSchema),
|
|
8245
|
+
nextResource: ContentResourceSchema.nullable(),
|
|
8246
|
+
percentCompleted: z2.number().default(0),
|
|
8247
|
+
completedLessonsCount: z2.number().default(0),
|
|
8248
|
+
totalLessonsCount: z2.number().default(0)
|
|
8249
|
+
});
|
|
8250
|
+
|
|
8251
|
+
// ../core/dist/chunk-DLQA3JMA.js
|
|
8252
|
+
var upgradableProductSchema = z2.object({
|
|
8253
|
+
upgradableToId: z2.string().max(255),
|
|
8254
|
+
upgradableFromId: z2.string().max(255),
|
|
8255
|
+
position: z2.number().default(0),
|
|
8256
|
+
metadata: z2.record(z2.any()).default({}),
|
|
8313
8257
|
createdAt: z2.date().nullable(),
|
|
8314
|
-
|
|
8258
|
+
updatedAt: z2.date().nullable(),
|
|
8259
|
+
deletedAt: z2.date().nullable()
|
|
8260
|
+
});
|
|
8261
|
+
|
|
8262
|
+
// ../core/dist/chunk-5QZXOTEH.js
|
|
8263
|
+
var VideoResourceSchema = z2.object({
|
|
8264
|
+
id: z2.string(),
|
|
8265
|
+
updatedAt: z2.string().optional(),
|
|
8266
|
+
createdAt: z2.string().optional(),
|
|
8267
|
+
title: z2.string().optional().nullable(),
|
|
8268
|
+
duration: z2.number().optional().nullable(),
|
|
8269
|
+
muxPlaybackId: z2.string().optional().nullable(),
|
|
8270
|
+
muxAssetId: z2.string().optional().nullable(),
|
|
8271
|
+
transcript: z2.string().optional().nullable(),
|
|
8272
|
+
transcriptWithScreenshots: z2.string().optional().nullable(),
|
|
8273
|
+
srt: z2.string().optional().nullable(),
|
|
8274
|
+
wordLevelSrt: z2.string().optional().nullable(),
|
|
8275
|
+
state: z2.enum([
|
|
8276
|
+
"new",
|
|
8277
|
+
"processing",
|
|
8278
|
+
"preparing",
|
|
8279
|
+
"ready",
|
|
8280
|
+
"errored",
|
|
8281
|
+
"deleted"
|
|
8282
|
+
])
|
|
8315
8283
|
});
|
|
8316
8284
|
|
|
8317
8285
|
// ../core/dist/chunk-EDDT2FFU.js
|
|
@@ -8324,6 +8292,39 @@ var merchantCustomerSchema = z2.object({
|
|
|
8324
8292
|
status: z2.number().int().default(0)
|
|
8325
8293
|
});
|
|
8326
8294
|
|
|
8295
|
+
// ../core/dist/chunk-PS6USEN7.js
|
|
8296
|
+
var merchantPriceSchema = z2.object({
|
|
8297
|
+
id: z2.string().max(191),
|
|
8298
|
+
merchantAccountId: z2.string().max(191),
|
|
8299
|
+
merchantProductId: z2.string().max(191),
|
|
8300
|
+
status: z2.number().int().default(0),
|
|
8301
|
+
identifier: z2.string().max(191).optional().nullable(),
|
|
8302
|
+
createdAt: z2.date(),
|
|
8303
|
+
priceId: z2.string().max(191).optional().nullable()
|
|
8304
|
+
});
|
|
8305
|
+
|
|
8306
|
+
// ../core/dist/chunk-DAG4HKGL.js
|
|
8307
|
+
var merchantProductSchema = z2.object({
|
|
8308
|
+
id: z2.string().max(191),
|
|
8309
|
+
merchantAccountId: z2.string().max(191),
|
|
8310
|
+
productId: z2.string().max(191),
|
|
8311
|
+
status: z2.number().int().default(0),
|
|
8312
|
+
identifier: z2.string().max(191).optional().nullable(),
|
|
8313
|
+
createdAt: z2.date().nullable()
|
|
8314
|
+
});
|
|
8315
|
+
|
|
8316
|
+
// ../core/dist/chunk-SGE7BCRS.js
|
|
8317
|
+
var merchantChargeSchema = z2.object({
|
|
8318
|
+
id: z2.string().max(191),
|
|
8319
|
+
status: z2.number().int().default(0),
|
|
8320
|
+
identifier: z2.string().max(191),
|
|
8321
|
+
userId: z2.string().max(191),
|
|
8322
|
+
merchantAccountId: z2.string().max(191),
|
|
8323
|
+
merchantProductId: z2.string().max(191),
|
|
8324
|
+
createdAt: z2.date().nullable(),
|
|
8325
|
+
merchantCustomerId: z2.string().max(191)
|
|
8326
|
+
});
|
|
8327
|
+
|
|
8327
8328
|
// ../core/dist/chunk-256SROW3.js
|
|
8328
8329
|
var merchantCouponSchema = z2.object({
|
|
8329
8330
|
id: z2.string().max(191),
|
|
@@ -8476,25 +8477,25 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
|
|
|
8476
8477
|
}, "validateCoupon");
|
|
8477
8478
|
|
|
8478
8479
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
8479
|
-
var
|
|
8480
|
-
var
|
|
8480
|
+
var import_drizzle_orm23 = require("drizzle-orm");
|
|
8481
|
+
var import_mysql_core27 = require("drizzle-orm/mysql-core");
|
|
8481
8482
|
|
|
8482
8483
|
// src/lib/mysql/schemas/auth/users.ts
|
|
8483
|
-
var
|
|
8484
|
-
var
|
|
8484
|
+
var import_drizzle_orm22 = require("drizzle-orm");
|
|
8485
|
+
var import_mysql_core26 = require("drizzle-orm/mysql-core");
|
|
8485
8486
|
|
|
8486
8487
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
8487
|
-
var
|
|
8488
|
-
var
|
|
8488
|
+
var import_drizzle_orm14 = require("drizzle-orm");
|
|
8489
|
+
var import_mysql_core16 = require("drizzle-orm/mysql-core");
|
|
8489
8490
|
|
|
8490
8491
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
8491
|
-
var
|
|
8492
|
-
var
|
|
8492
|
+
var import_drizzle_orm10 = require("drizzle-orm");
|
|
8493
|
+
var import_mysql_core11 = require("drizzle-orm/mysql-core");
|
|
8493
8494
|
|
|
8494
8495
|
// src/lib/mysql/schemas/commerce/merchant-coupon.ts
|
|
8495
8496
|
var import_mysql_core = require("drizzle-orm/mysql-core");
|
|
8496
8497
|
function getMerchantCouponSchema(mysqlTable) {
|
|
8497
|
-
return mysqlTable("
|
|
8498
|
+
return mysqlTable("MerchantCoupon", {
|
|
8498
8499
|
id: (0, import_mysql_core.varchar)("id", {
|
|
8499
8500
|
length: 191
|
|
8500
8501
|
}).notNull(),
|
|
@@ -8527,58 +8528,174 @@ function getMerchantCouponSchema(mysqlTable) {
|
|
|
8527
8528
|
__name(getMerchantCouponSchema, "getMerchantCouponSchema");
|
|
8528
8529
|
|
|
8529
8530
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8530
|
-
var
|
|
8531
|
-
var
|
|
8531
|
+
var import_drizzle_orm9 = require("drizzle-orm");
|
|
8532
|
+
var import_mysql_core10 = require("drizzle-orm/mysql-core");
|
|
8532
8533
|
|
|
8533
8534
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8534
|
-
var
|
|
8535
|
-
var
|
|
8535
|
+
var import_drizzle_orm5 = require("drizzle-orm");
|
|
8536
|
+
var import_mysql_core6 = require("drizzle-orm/mysql-core");
|
|
8536
8537
|
|
|
8537
8538
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8539
|
+
var import_drizzle_orm4 = require("drizzle-orm");
|
|
8540
|
+
var import_mysql_core5 = require("drizzle-orm/mysql-core");
|
|
8541
|
+
|
|
8542
|
+
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
8538
8543
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
8539
8544
|
var import_mysql_core3 = require("drizzle-orm/mysql-core");
|
|
8540
8545
|
|
|
8541
|
-
// src/lib/mysql/schemas/content/
|
|
8546
|
+
// src/lib/mysql/schemas/content/contribution-types.ts
|
|
8542
8547
|
var import_drizzle_orm = require("drizzle-orm");
|
|
8543
8548
|
var import_mysql_core2 = require("drizzle-orm/mysql-core");
|
|
8544
|
-
function
|
|
8545
|
-
return mysqlTable("
|
|
8546
|
-
|
|
8549
|
+
function getContributionTypesSchema(mysqlTable) {
|
|
8550
|
+
return mysqlTable("ContributionType", {
|
|
8551
|
+
id: (0, import_mysql_core2.varchar)("id", {
|
|
8547
8552
|
length: 255
|
|
8548
|
-
}).notNull(),
|
|
8549
|
-
|
|
8553
|
+
}).notNull().primaryKey(),
|
|
8554
|
+
slug: (0, import_mysql_core2.varchar)("slug", {
|
|
8555
|
+
length: 255
|
|
8556
|
+
}).notNull().unique(),
|
|
8557
|
+
name: (0, import_mysql_core2.varchar)("name", {
|
|
8550
8558
|
length: 255
|
|
8551
8559
|
}).notNull(),
|
|
8552
|
-
|
|
8553
|
-
|
|
8560
|
+
description: (0, import_mysql_core2.text)("description"),
|
|
8561
|
+
active: (0, import_mysql_core2.boolean)("active").notNull().default(true),
|
|
8554
8562
|
createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
|
|
8555
8563
|
mode: "date",
|
|
8556
8564
|
fsp: 3
|
|
8557
|
-
}).
|
|
8565
|
+
}).defaultNow(),
|
|
8558
8566
|
updatedAt: (0, import_mysql_core2.timestamp)("updatedAt", {
|
|
8559
8567
|
mode: "date",
|
|
8560
8568
|
fsp: 3
|
|
8561
|
-
}).
|
|
8569
|
+
}).defaultNow(),
|
|
8562
8570
|
deletedAt: (0, import_mysql_core2.timestamp)("deletedAt", {
|
|
8563
8571
|
mode: "date",
|
|
8564
8572
|
fsp: 3
|
|
8565
8573
|
})
|
|
8574
|
+
}, (ct) => ({
|
|
8575
|
+
nameIdx: (0, import_mysql_core2.index)("name_idx").on(ct.name),
|
|
8576
|
+
slugIdx: (0, import_mysql_core2.index)("slug_idx").on(ct.slug)
|
|
8577
|
+
}));
|
|
8578
|
+
}
|
|
8579
|
+
__name(getContributionTypesSchema, "getContributionTypesSchema");
|
|
8580
|
+
function getContributionTypesRelationsSchema(mysqlTable) {
|
|
8581
|
+
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
8582
|
+
return (0, import_drizzle_orm.relations)(contributionTypes, ({ many }) => ({}));
|
|
8583
|
+
}
|
|
8584
|
+
__name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
|
|
8585
|
+
|
|
8586
|
+
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
8587
|
+
function getContentContributionsSchema(mysqlTable) {
|
|
8588
|
+
return mysqlTable("ContentContribution", {
|
|
8589
|
+
id: (0, import_mysql_core3.varchar)("id", {
|
|
8590
|
+
length: 255
|
|
8591
|
+
}).notNull().primaryKey(),
|
|
8592
|
+
userId: (0, import_mysql_core3.varchar)("userId", {
|
|
8593
|
+
length: 255
|
|
8594
|
+
}).notNull(),
|
|
8595
|
+
contentId: (0, import_mysql_core3.varchar)("contentId", {
|
|
8596
|
+
length: 255
|
|
8597
|
+
}).notNull(),
|
|
8598
|
+
contributionTypeId: (0, import_mysql_core3.varchar)("contributionTypeId", {
|
|
8599
|
+
length: 255
|
|
8600
|
+
}).notNull(),
|
|
8601
|
+
active: (0, import_mysql_core3.boolean)("active").notNull().default(true),
|
|
8602
|
+
createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
|
|
8603
|
+
mode: "date",
|
|
8604
|
+
fsp: 3
|
|
8605
|
+
}).defaultNow(),
|
|
8606
|
+
updatedAt: (0, import_mysql_core3.timestamp)("updatedAt", {
|
|
8607
|
+
mode: "date",
|
|
8608
|
+
fsp: 3
|
|
8609
|
+
}).defaultNow(),
|
|
8610
|
+
deletedAt: (0, import_mysql_core3.timestamp)("deletedAt", {
|
|
8611
|
+
mode: "date",
|
|
8612
|
+
fsp: 3
|
|
8613
|
+
})
|
|
8614
|
+
}, (cc) => ({
|
|
8615
|
+
userIdIdx: (0, import_mysql_core3.index)("userId_idx").on(cc.userId),
|
|
8616
|
+
contentIdIdx: (0, import_mysql_core3.index)("contentId_idx").on(cc.contentId),
|
|
8617
|
+
contributionTypeIdIdx: (0, import_mysql_core3.index)("contributionTypeId_idx").on(cc.contributionTypeId)
|
|
8618
|
+
}));
|
|
8619
|
+
}
|
|
8620
|
+
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
8621
|
+
function getContentContributionRelationsSchema(mysqlTable) {
|
|
8622
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
8623
|
+
const users = getUsersSchema(mysqlTable);
|
|
8624
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8625
|
+
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
8626
|
+
return (0, import_drizzle_orm2.relations)(contentContributions, ({ one }) => ({
|
|
8627
|
+
user: one(users, {
|
|
8628
|
+
fields: [
|
|
8629
|
+
contentContributions.userId
|
|
8630
|
+
],
|
|
8631
|
+
references: [
|
|
8632
|
+
users.id
|
|
8633
|
+
],
|
|
8634
|
+
relationName: "user"
|
|
8635
|
+
}),
|
|
8636
|
+
content: one(contentResource, {
|
|
8637
|
+
fields: [
|
|
8638
|
+
contentContributions.contentId
|
|
8639
|
+
],
|
|
8640
|
+
references: [
|
|
8641
|
+
contentResource.id
|
|
8642
|
+
],
|
|
8643
|
+
relationName: "contributions"
|
|
8644
|
+
}),
|
|
8645
|
+
contributionType: one(contributionTypes, {
|
|
8646
|
+
fields: [
|
|
8647
|
+
contentContributions.contributionTypeId
|
|
8648
|
+
],
|
|
8649
|
+
references: [
|
|
8650
|
+
contributionTypes.id
|
|
8651
|
+
],
|
|
8652
|
+
relationName: "contributionType"
|
|
8653
|
+
})
|
|
8654
|
+
}));
|
|
8655
|
+
}
|
|
8656
|
+
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
8657
|
+
|
|
8658
|
+
// src/lib/mysql/schemas/content/content-resource-resource.ts
|
|
8659
|
+
var import_drizzle_orm3 = require("drizzle-orm");
|
|
8660
|
+
var import_mysql_core4 = require("drizzle-orm/mysql-core");
|
|
8661
|
+
function getContentResourceResourceSchema(mysqlTable) {
|
|
8662
|
+
return mysqlTable("ContentResourceResource", {
|
|
8663
|
+
resourceOfId: (0, import_mysql_core4.varchar)("resourceOfId", {
|
|
8664
|
+
length: 255
|
|
8665
|
+
}).notNull(),
|
|
8666
|
+
resourceId: (0, import_mysql_core4.varchar)("resourceId", {
|
|
8667
|
+
length: 255
|
|
8668
|
+
}).notNull(),
|
|
8669
|
+
position: (0, import_mysql_core4.double)("position").notNull().default(0),
|
|
8670
|
+
metadata: (0, import_mysql_core4.json)("metadata").$type().default({}),
|
|
8671
|
+
createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
|
|
8672
|
+
mode: "date",
|
|
8673
|
+
fsp: 3
|
|
8674
|
+
}).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
|
|
8675
|
+
updatedAt: (0, import_mysql_core4.timestamp)("updatedAt", {
|
|
8676
|
+
mode: "date",
|
|
8677
|
+
fsp: 3
|
|
8678
|
+
}).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`),
|
|
8679
|
+
deletedAt: (0, import_mysql_core4.timestamp)("deletedAt", {
|
|
8680
|
+
mode: "date",
|
|
8681
|
+
fsp: 3
|
|
8682
|
+
})
|
|
8566
8683
|
}, (crr) => ({
|
|
8567
|
-
pk: (0,
|
|
8684
|
+
pk: (0, import_mysql_core4.primaryKey)({
|
|
8568
8685
|
columns: [
|
|
8569
8686
|
crr.resourceOfId,
|
|
8570
8687
|
crr.resourceId
|
|
8571
8688
|
]
|
|
8572
8689
|
}),
|
|
8573
|
-
contentResourceIdIdx: (0,
|
|
8574
|
-
resourceIdIdx: (0,
|
|
8690
|
+
contentResourceIdIdx: (0, import_mysql_core4.index)("contentResourceId_idx").on(crr.resourceOfId),
|
|
8691
|
+
resourceIdIdx: (0, import_mysql_core4.index)("resourceId_idx").on(crr.resourceId)
|
|
8575
8692
|
}));
|
|
8576
8693
|
}
|
|
8577
8694
|
__name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
|
|
8578
8695
|
function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
8579
8696
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8580
8697
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
8581
|
-
return (0,
|
|
8698
|
+
return (0, import_drizzle_orm3.relations)(contentResourceResource, ({ one }) => ({
|
|
8582
8699
|
resourceOf: one(contentResource, {
|
|
8583
8700
|
fields: [
|
|
8584
8701
|
contentResourceResource.resourceOfId
|
|
@@ -8603,33 +8720,33 @@ __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRel
|
|
|
8603
8720
|
|
|
8604
8721
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8605
8722
|
function getContentResourceSchema(mysqlTable) {
|
|
8606
|
-
return mysqlTable("
|
|
8607
|
-
id: (0,
|
|
8723
|
+
return mysqlTable("ContentResource", {
|
|
8724
|
+
id: (0, import_mysql_core5.varchar)("id", {
|
|
8608
8725
|
length: 255
|
|
8609
8726
|
}).notNull().primaryKey(),
|
|
8610
|
-
type: (0,
|
|
8727
|
+
type: (0, import_mysql_core5.varchar)("type", {
|
|
8611
8728
|
length: 255
|
|
8612
8729
|
}).notNull(),
|
|
8613
|
-
createdById: (0,
|
|
8730
|
+
createdById: (0, import_mysql_core5.varchar)("createdById", {
|
|
8614
8731
|
length: 255
|
|
8615
8732
|
}).notNull(),
|
|
8616
|
-
fields: (0,
|
|
8617
|
-
createdAt: (0,
|
|
8733
|
+
fields: (0, import_mysql_core5.json)("fields").$type().default({}),
|
|
8734
|
+
createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
|
|
8618
8735
|
mode: "date",
|
|
8619
8736
|
fsp: 3
|
|
8620
|
-
}).default(
|
|
8621
|
-
updatedAt: (0,
|
|
8737
|
+
}).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`),
|
|
8738
|
+
updatedAt: (0, import_mysql_core5.timestamp)("updatedAt", {
|
|
8622
8739
|
mode: "date",
|
|
8623
8740
|
fsp: 3
|
|
8624
|
-
}).default(
|
|
8625
|
-
deletedAt: (0,
|
|
8741
|
+
}).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`),
|
|
8742
|
+
deletedAt: (0, import_mysql_core5.timestamp)("deletedAt", {
|
|
8626
8743
|
mode: "date",
|
|
8627
8744
|
fsp: 3
|
|
8628
8745
|
})
|
|
8629
8746
|
}, (cm) => ({
|
|
8630
|
-
typeIdx: (0,
|
|
8631
|
-
createdByIdx: (0,
|
|
8632
|
-
createdAtIdx: (0,
|
|
8747
|
+
typeIdx: (0, import_mysql_core5.index)("type_idx").on(cm.type),
|
|
8748
|
+
createdByIdx: (0, import_mysql_core5.index)("createdById_idx").on(cm.createdById),
|
|
8749
|
+
createdAtIdx: (0, import_mysql_core5.index)("createdAt_idx").on(cm.createdAt)
|
|
8633
8750
|
}));
|
|
8634
8751
|
}
|
|
8635
8752
|
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
@@ -8638,7 +8755,8 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8638
8755
|
const users = getUsersSchema(mysqlTable);
|
|
8639
8756
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
8640
8757
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8641
|
-
|
|
8758
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
8759
|
+
return (0, import_drizzle_orm4.relations)(contentResource, ({ one, many }) => ({
|
|
8642
8760
|
createdBy: one(users, {
|
|
8643
8761
|
fields: [
|
|
8644
8762
|
contentResource.createdById
|
|
@@ -8646,7 +8764,7 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8646
8764
|
references: [
|
|
8647
8765
|
users.id
|
|
8648
8766
|
],
|
|
8649
|
-
relationName: "
|
|
8767
|
+
relationName: "creator"
|
|
8650
8768
|
}),
|
|
8651
8769
|
resources: many(contentResourceResource, {
|
|
8652
8770
|
relationName: "resourceOf"
|
|
@@ -8656,6 +8774,9 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8656
8774
|
}),
|
|
8657
8775
|
resourceProducts: many(contentResourceProduct, {
|
|
8658
8776
|
relationName: "resource"
|
|
8777
|
+
}),
|
|
8778
|
+
contributions: many(contentContributions, {
|
|
8779
|
+
relationName: "contributions"
|
|
8659
8780
|
})
|
|
8660
8781
|
}));
|
|
8661
8782
|
}
|
|
@@ -8663,36 +8784,36 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
|
8663
8784
|
|
|
8664
8785
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8665
8786
|
function getContentResourceProductSchema(mysqlTable) {
|
|
8666
|
-
return mysqlTable("
|
|
8667
|
-
productId: (0,
|
|
8787
|
+
return mysqlTable("ContentResourceProduct", {
|
|
8788
|
+
productId: (0, import_mysql_core6.varchar)("productId", {
|
|
8668
8789
|
length: 255
|
|
8669
8790
|
}).notNull(),
|
|
8670
|
-
resourceId: (0,
|
|
8791
|
+
resourceId: (0, import_mysql_core6.varchar)("resourceId", {
|
|
8671
8792
|
length: 255
|
|
8672
8793
|
}).notNull(),
|
|
8673
|
-
position: (0,
|
|
8674
|
-
metadata: (0,
|
|
8675
|
-
createdAt: (0,
|
|
8794
|
+
position: (0, import_mysql_core6.double)("position").notNull().default(0),
|
|
8795
|
+
metadata: (0, import_mysql_core6.json)("metadata").$type().default({}),
|
|
8796
|
+
createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
|
|
8676
8797
|
mode: "date",
|
|
8677
8798
|
fsp: 3
|
|
8678
|
-
}).default(
|
|
8679
|
-
updatedAt: (0,
|
|
8799
|
+
}).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
|
|
8800
|
+
updatedAt: (0, import_mysql_core6.timestamp)("updatedAt", {
|
|
8680
8801
|
mode: "date",
|
|
8681
8802
|
fsp: 3
|
|
8682
|
-
}).default(
|
|
8683
|
-
deletedAt: (0,
|
|
8803
|
+
}).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
|
|
8804
|
+
deletedAt: (0, import_mysql_core6.timestamp)("deletedAt", {
|
|
8684
8805
|
mode: "date",
|
|
8685
8806
|
fsp: 3
|
|
8686
8807
|
})
|
|
8687
8808
|
}, (crr) => ({
|
|
8688
|
-
pk: (0,
|
|
8809
|
+
pk: (0, import_mysql_core6.primaryKey)({
|
|
8689
8810
|
columns: [
|
|
8690
8811
|
crr.productId,
|
|
8691
8812
|
crr.resourceId
|
|
8692
8813
|
]
|
|
8693
8814
|
}),
|
|
8694
|
-
contentResourceIdIdx: (0,
|
|
8695
|
-
resourceIdIdx: (0,
|
|
8815
|
+
contentResourceIdIdx: (0, import_mysql_core6.index)("contentResourceId_idx").on(crr.productId),
|
|
8816
|
+
resourceIdIdx: (0, import_mysql_core6.index)("resourceId_idx").on(crr.resourceId)
|
|
8696
8817
|
}));
|
|
8697
8818
|
}
|
|
8698
8819
|
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
@@ -8700,7 +8821,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
8700
8821
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8701
8822
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8702
8823
|
const product = getProductSchema(mysqlTable);
|
|
8703
|
-
return (0,
|
|
8824
|
+
return (0, import_drizzle_orm5.relations)(contentResourceProduct, ({ one }) => ({
|
|
8704
8825
|
product: one(product, {
|
|
8705
8826
|
fields: [
|
|
8706
8827
|
contentResourceProduct.productId
|
|
@@ -8724,79 +8845,79 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
8724
8845
|
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
8725
8846
|
|
|
8726
8847
|
// src/lib/mysql/schemas/commerce/merchant-product.ts
|
|
8727
|
-
var
|
|
8728
|
-
var
|
|
8848
|
+
var import_drizzle_orm6 = require("drizzle-orm");
|
|
8849
|
+
var import_mysql_core7 = require("drizzle-orm/mysql-core");
|
|
8729
8850
|
function getMerchantProductSchema(mysqlTable) {
|
|
8730
|
-
return mysqlTable("
|
|
8731
|
-
id: (0,
|
|
8851
|
+
return mysqlTable("MerchantProduct", {
|
|
8852
|
+
id: (0, import_mysql_core7.varchar)("id", {
|
|
8732
8853
|
length: 191
|
|
8733
8854
|
}).notNull(),
|
|
8734
|
-
merchantAccountId: (0,
|
|
8855
|
+
merchantAccountId: (0, import_mysql_core7.varchar)("merchantAccountId", {
|
|
8735
8856
|
length: 191
|
|
8736
8857
|
}).notNull(),
|
|
8737
|
-
productId: (0,
|
|
8858
|
+
productId: (0, import_mysql_core7.varchar)("productId", {
|
|
8738
8859
|
length: 191
|
|
8739
8860
|
}).notNull(),
|
|
8740
|
-
status: (0,
|
|
8741
|
-
identifier: (0,
|
|
8861
|
+
status: (0, import_mysql_core7.int)("status").default(0).notNull(),
|
|
8862
|
+
identifier: (0, import_mysql_core7.varchar)("identifier", {
|
|
8742
8863
|
length: 191
|
|
8743
8864
|
}),
|
|
8744
|
-
createdAt: (0,
|
|
8865
|
+
createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
|
|
8745
8866
|
mode: "date",
|
|
8746
8867
|
fsp: 3
|
|
8747
|
-
}).default(
|
|
8868
|
+
}).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
8748
8869
|
}, (table) => {
|
|
8749
8870
|
return {
|
|
8750
|
-
merchantProductId: (0,
|
|
8871
|
+
merchantProductId: (0, import_mysql_core7.primaryKey)({
|
|
8751
8872
|
columns: [
|
|
8752
8873
|
table.id
|
|
8753
8874
|
],
|
|
8754
8875
|
name: "MerchantProduct_id"
|
|
8755
8876
|
}),
|
|
8756
|
-
merchantProductIdentifierKey: (0,
|
|
8877
|
+
merchantProductIdentifierKey: (0, import_mysql_core7.unique)("MerchantProduct_identifier_key").on(table.identifier)
|
|
8757
8878
|
};
|
|
8758
8879
|
});
|
|
8759
8880
|
}
|
|
8760
8881
|
__name(getMerchantProductSchema, "getMerchantProductSchema");
|
|
8761
8882
|
|
|
8762
8883
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
8763
|
-
var
|
|
8764
|
-
var
|
|
8884
|
+
var import_drizzle_orm8 = require("drizzle-orm");
|
|
8885
|
+
var import_mysql_core9 = require("drizzle-orm/mysql-core");
|
|
8765
8886
|
|
|
8766
8887
|
// src/lib/mysql/schemas/commerce/merchant-price.ts
|
|
8767
|
-
var
|
|
8768
|
-
var
|
|
8888
|
+
var import_drizzle_orm7 = require("drizzle-orm");
|
|
8889
|
+
var import_mysql_core8 = require("drizzle-orm/mysql-core");
|
|
8769
8890
|
function getMerchantPriceSchema(mysqlTable) {
|
|
8770
|
-
return mysqlTable("
|
|
8771
|
-
id: (0,
|
|
8891
|
+
return mysqlTable("MerchantPrice", {
|
|
8892
|
+
id: (0, import_mysql_core8.varchar)("id", {
|
|
8772
8893
|
length: 191
|
|
8773
8894
|
}).notNull(),
|
|
8774
|
-
merchantAccountId: (0,
|
|
8895
|
+
merchantAccountId: (0, import_mysql_core8.varchar)("merchantAccountId", {
|
|
8775
8896
|
length: 191
|
|
8776
8897
|
}).notNull(),
|
|
8777
|
-
merchantProductId: (0,
|
|
8898
|
+
merchantProductId: (0, import_mysql_core8.varchar)("merchantProductId", {
|
|
8778
8899
|
length: 191
|
|
8779
8900
|
}).notNull(),
|
|
8780
|
-
status: (0,
|
|
8781
|
-
identifier: (0,
|
|
8901
|
+
status: (0, import_mysql_core8.int)("status").default(0),
|
|
8902
|
+
identifier: (0, import_mysql_core8.varchar)("identifier", {
|
|
8782
8903
|
length: 191
|
|
8783
8904
|
}),
|
|
8784
|
-
createdAt: (0,
|
|
8905
|
+
createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
|
|
8785
8906
|
mode: "date",
|
|
8786
8907
|
fsp: 3
|
|
8787
|
-
}).default(
|
|
8788
|
-
priceId: (0,
|
|
8908
|
+
}).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8909
|
+
priceId: (0, import_mysql_core8.varchar)("priceId", {
|
|
8789
8910
|
length: 191
|
|
8790
8911
|
})
|
|
8791
8912
|
}, (table) => {
|
|
8792
8913
|
return {
|
|
8793
|
-
merchantPriceId: (0,
|
|
8914
|
+
merchantPriceId: (0, import_mysql_core8.primaryKey)({
|
|
8794
8915
|
columns: [
|
|
8795
8916
|
table.id
|
|
8796
8917
|
],
|
|
8797
8918
|
name: "MerchantPrice_id"
|
|
8798
8919
|
}),
|
|
8799
|
-
merchantPriceIdentifierKey: (0,
|
|
8920
|
+
merchantPriceIdentifierKey: (0, import_mysql_core8.unique)("MerchantPrice_identifier_key").on(table.identifier)
|
|
8800
8921
|
};
|
|
8801
8922
|
});
|
|
8802
8923
|
}
|
|
@@ -8804,29 +8925,29 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
|
|
|
8804
8925
|
|
|
8805
8926
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
8806
8927
|
function getPriceSchema(mysqlTable) {
|
|
8807
|
-
return mysqlTable("
|
|
8808
|
-
id: (0,
|
|
8928
|
+
return mysqlTable("Price", {
|
|
8929
|
+
id: (0, import_mysql_core9.varchar)("id", {
|
|
8809
8930
|
length: 191
|
|
8810
8931
|
}).notNull(),
|
|
8811
|
-
productId: (0,
|
|
8932
|
+
productId: (0, import_mysql_core9.varchar)("productId", {
|
|
8812
8933
|
length: 191
|
|
8813
8934
|
}),
|
|
8814
|
-
nickname: (0,
|
|
8935
|
+
nickname: (0, import_mysql_core9.varchar)("nickname", {
|
|
8815
8936
|
length: 191
|
|
8816
8937
|
}),
|
|
8817
|
-
status: (0,
|
|
8818
|
-
unitAmount: (0,
|
|
8938
|
+
status: (0, import_mysql_core9.int)("status").default(0).notNull(),
|
|
8939
|
+
unitAmount: (0, import_mysql_core9.decimal)("unitAmount", {
|
|
8819
8940
|
precision: 10,
|
|
8820
8941
|
scale: 2
|
|
8821
8942
|
}).notNull(),
|
|
8822
|
-
createdAt: (0,
|
|
8943
|
+
createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
|
|
8823
8944
|
mode: "date",
|
|
8824
8945
|
fsp: 3
|
|
8825
|
-
}).default(
|
|
8826
|
-
fields: (0,
|
|
8946
|
+
}).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8947
|
+
fields: (0, import_mysql_core9.json)("fields").$type().default({})
|
|
8827
8948
|
}, (table) => {
|
|
8828
8949
|
return {
|
|
8829
|
-
priceId: (0,
|
|
8950
|
+
priceId: (0, import_mysql_core9.primaryKey)({
|
|
8830
8951
|
columns: [
|
|
8831
8952
|
table.id
|
|
8832
8953
|
],
|
|
@@ -8839,29 +8960,29 @@ __name(getPriceSchema, "getPriceSchema");
|
|
|
8839
8960
|
|
|
8840
8961
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8841
8962
|
function getProductSchema(mysqlTable) {
|
|
8842
|
-
return mysqlTable("
|
|
8843
|
-
id: (0,
|
|
8963
|
+
return mysqlTable("Product", {
|
|
8964
|
+
id: (0, import_mysql_core10.varchar)("id", {
|
|
8844
8965
|
length: 191
|
|
8845
8966
|
}).notNull(),
|
|
8846
|
-
name: (0,
|
|
8967
|
+
name: (0, import_mysql_core10.varchar)("name", {
|
|
8847
8968
|
length: 191
|
|
8848
8969
|
}).notNull(),
|
|
8849
|
-
key: (0,
|
|
8970
|
+
key: (0, import_mysql_core10.varchar)("key", {
|
|
8850
8971
|
length: 191
|
|
8851
8972
|
}),
|
|
8852
|
-
type: (0,
|
|
8973
|
+
type: (0, import_mysql_core10.varchar)("type", {
|
|
8853
8974
|
length: 191
|
|
8854
8975
|
}),
|
|
8855
|
-
fields: (0,
|
|
8856
|
-
createdAt: (0,
|
|
8976
|
+
fields: (0, import_mysql_core10.json)("fields").$type().default({}),
|
|
8977
|
+
createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
|
|
8857
8978
|
mode: "date",
|
|
8858
8979
|
fsp: 3
|
|
8859
|
-
}).default(
|
|
8860
|
-
status: (0,
|
|
8861
|
-
quantityAvailable: (0,
|
|
8980
|
+
}).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8981
|
+
status: (0, import_mysql_core10.int)("status").default(0).notNull(),
|
|
8982
|
+
quantityAvailable: (0, import_mysql_core10.int)("quantityAvailable").default(-1).notNull()
|
|
8862
8983
|
}, (table) => {
|
|
8863
8984
|
return {
|
|
8864
|
-
productId: (0,
|
|
8985
|
+
productId: (0, import_mysql_core10.primaryKey)({
|
|
8865
8986
|
columns: [
|
|
8866
8987
|
table.id
|
|
8867
8988
|
],
|
|
@@ -8876,7 +8997,7 @@ function getProductRelationsSchema(mysqlTable) {
|
|
|
8876
8997
|
const price = getPriceSchema(mysqlTable);
|
|
8877
8998
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
8878
8999
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8879
|
-
return (0,
|
|
9000
|
+
return (0, import_drizzle_orm9.relations)(product, ({ one, many }) => ({
|
|
8880
9001
|
price: one(price, {
|
|
8881
9002
|
fields: [
|
|
8882
9003
|
product.id
|
|
@@ -8904,49 +9025,50 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
|
8904
9025
|
|
|
8905
9026
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
8906
9027
|
function getCouponSchema(mysqlTable) {
|
|
8907
|
-
return mysqlTable("
|
|
8908
|
-
id: (0,
|
|
9028
|
+
return mysqlTable("Coupon", {
|
|
9029
|
+
id: (0, import_mysql_core11.varchar)("id", {
|
|
8909
9030
|
length: 191
|
|
8910
9031
|
}).notNull(),
|
|
8911
|
-
code: (0,
|
|
9032
|
+
code: (0, import_mysql_core11.varchar)("code", {
|
|
8912
9033
|
length: 191
|
|
8913
9034
|
}),
|
|
8914
|
-
createdAt: (0,
|
|
9035
|
+
createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
|
|
8915
9036
|
mode: "date",
|
|
8916
9037
|
fsp: 3
|
|
8917
|
-
}).default(
|
|
8918
|
-
expires: (0,
|
|
9038
|
+
}).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9039
|
+
expires: (0, import_mysql_core11.timestamp)("expires", {
|
|
8919
9040
|
mode: "date",
|
|
8920
9041
|
fsp: 3
|
|
8921
9042
|
}),
|
|
8922
|
-
fields: (0,
|
|
8923
|
-
maxUses: (0,
|
|
8924
|
-
default: (0,
|
|
8925
|
-
merchantCouponId: (0,
|
|
9043
|
+
fields: (0, import_mysql_core11.json)("fields").$type().default({}),
|
|
9044
|
+
maxUses: (0, import_mysql_core11.int)("maxUses").default(-1).notNull(),
|
|
9045
|
+
default: (0, import_mysql_core11.boolean)("default").default(false).notNull(),
|
|
9046
|
+
merchantCouponId: (0, import_mysql_core11.varchar)("merchantCouponId", {
|
|
8926
9047
|
length: 191
|
|
8927
9048
|
}),
|
|
8928
|
-
status: (0,
|
|
8929
|
-
usedCount: (0,
|
|
8930
|
-
percentageDiscount: (0,
|
|
9049
|
+
status: (0, import_mysql_core11.int)("status").default(0).notNull(),
|
|
9050
|
+
usedCount: (0, import_mysql_core11.int)("usedCount").default(0).notNull(),
|
|
9051
|
+
percentageDiscount: (0, import_mysql_core11.decimal)("percentageDiscount", {
|
|
8931
9052
|
precision: 3,
|
|
8932
9053
|
scale: 2
|
|
8933
9054
|
}).notNull(),
|
|
8934
|
-
restrictedToProductId: (0,
|
|
9055
|
+
restrictedToProductId: (0, import_mysql_core11.varchar)("restrictedToProductId", {
|
|
8935
9056
|
length: 191
|
|
8936
9057
|
}),
|
|
8937
|
-
bulkPurchaseId: (0,
|
|
9058
|
+
bulkPurchaseId: (0, import_mysql_core11.varchar)("bulkPurchaseId", {
|
|
8938
9059
|
length: 191
|
|
8939
9060
|
})
|
|
8940
9061
|
}, (table) => {
|
|
8941
9062
|
return {
|
|
8942
|
-
|
|
9063
|
+
couponIdCodeIndex: (0, import_mysql_core11.index)("Coupon_id_code_index").on(table.id, table.code),
|
|
9064
|
+
couponId: (0, import_mysql_core11.primaryKey)({
|
|
8943
9065
|
columns: [
|
|
8944
9066
|
table.id
|
|
8945
9067
|
],
|
|
8946
9068
|
name: "Coupon_id"
|
|
8947
9069
|
}),
|
|
8948
|
-
couponBulkPurchaseIdKey: (0,
|
|
8949
|
-
couponCodeKey: (0,
|
|
9070
|
+
couponBulkPurchaseIdKey: (0, import_mysql_core11.unique)("Coupon_bulkPurchaseId_key").on(table.bulkPurchaseId),
|
|
9071
|
+
couponCodeKey: (0, import_mysql_core11.unique)("Coupon_code_key").on(table.code)
|
|
8950
9072
|
};
|
|
8951
9073
|
});
|
|
8952
9074
|
}
|
|
@@ -8955,7 +9077,7 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
8955
9077
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
8956
9078
|
const coupon = getCouponSchema(mysqlTable);
|
|
8957
9079
|
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
8958
|
-
return (0,
|
|
9080
|
+
return (0, import_drizzle_orm10.relations)(coupon, ({ many, one }) => ({
|
|
8959
9081
|
bulkCouponPurchases: many(purchase, {
|
|
8960
9082
|
relationName: "redeemedBulkCoupon"
|
|
8961
9083
|
}),
|
|
@@ -8991,31 +9113,31 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
8991
9113
|
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
8992
9114
|
|
|
8993
9115
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
8994
|
-
var
|
|
8995
|
-
var
|
|
9116
|
+
var import_drizzle_orm13 = require("drizzle-orm");
|
|
9117
|
+
var import_mysql_core14 = require("drizzle-orm/mysql-core");
|
|
8996
9118
|
|
|
8997
9119
|
// src/lib/mysql/schemas/commerce/merchant-account.ts
|
|
8998
|
-
var
|
|
8999
|
-
var
|
|
9120
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
9121
|
+
var import_mysql_core12 = require("drizzle-orm/mysql-core");
|
|
9000
9122
|
function getMerchantAccountSchema(mysqlTable) {
|
|
9001
|
-
return mysqlTable("
|
|
9002
|
-
id: (0,
|
|
9123
|
+
return mysqlTable("MerchantAccount", {
|
|
9124
|
+
id: (0, import_mysql_core12.varchar)("id", {
|
|
9003
9125
|
length: 191
|
|
9004
9126
|
}).notNull(),
|
|
9005
|
-
status: (0,
|
|
9006
|
-
createdAt: (0,
|
|
9127
|
+
status: (0, import_mysql_core12.int)("status").default(0).notNull(),
|
|
9128
|
+
createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
|
|
9007
9129
|
mode: "date",
|
|
9008
9130
|
fsp: 3
|
|
9009
|
-
}).default(
|
|
9010
|
-
label: (0,
|
|
9131
|
+
}).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9132
|
+
label: (0, import_mysql_core12.varchar)("label", {
|
|
9011
9133
|
length: 191
|
|
9012
9134
|
}),
|
|
9013
|
-
identifier: (0,
|
|
9135
|
+
identifier: (0, import_mysql_core12.varchar)("identifier", {
|
|
9014
9136
|
length: 191
|
|
9015
9137
|
})
|
|
9016
9138
|
}, (table) => {
|
|
9017
9139
|
return {
|
|
9018
|
-
merchantAccountId: (0,
|
|
9140
|
+
merchantAccountId: (0, import_mysql_core12.primaryKey)({
|
|
9019
9141
|
columns: [
|
|
9020
9142
|
table.id
|
|
9021
9143
|
],
|
|
@@ -9027,36 +9149,37 @@ function getMerchantAccountSchema(mysqlTable) {
|
|
|
9027
9149
|
__name(getMerchantAccountSchema, "getMerchantAccountSchema");
|
|
9028
9150
|
|
|
9029
9151
|
// src/lib/mysql/schemas/commerce/merchant-customer.ts
|
|
9030
|
-
var
|
|
9031
|
-
var
|
|
9152
|
+
var import_drizzle_orm12 = require("drizzle-orm");
|
|
9153
|
+
var import_mysql_core13 = require("drizzle-orm/mysql-core");
|
|
9032
9154
|
function getMerchantCustomerSchema(mysqlTable) {
|
|
9033
|
-
return mysqlTable("
|
|
9034
|
-
id: (0,
|
|
9155
|
+
return mysqlTable("MerchantCustomer", {
|
|
9156
|
+
id: (0, import_mysql_core13.varchar)("id", {
|
|
9035
9157
|
length: 191
|
|
9036
9158
|
}).notNull(),
|
|
9037
|
-
userId: (0,
|
|
9159
|
+
userId: (0, import_mysql_core13.varchar)("userId", {
|
|
9038
9160
|
length: 191
|
|
9039
9161
|
}).notNull(),
|
|
9040
|
-
merchantAccountId: (0,
|
|
9162
|
+
merchantAccountId: (0, import_mysql_core13.varchar)("merchantAccountId", {
|
|
9041
9163
|
length: 191
|
|
9042
9164
|
}).notNull(),
|
|
9043
|
-
identifier: (0,
|
|
9165
|
+
identifier: (0, import_mysql_core13.varchar)("identifier", {
|
|
9044
9166
|
length: 191
|
|
9045
9167
|
}).notNull(),
|
|
9046
|
-
createdAt: (0,
|
|
9168
|
+
createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
|
|
9047
9169
|
mode: "date",
|
|
9048
9170
|
fsp: 3
|
|
9049
|
-
}).default(
|
|
9050
|
-
status: (0,
|
|
9171
|
+
}).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9172
|
+
status: (0, import_mysql_core13.int)("status").default(0)
|
|
9051
9173
|
}, (table) => {
|
|
9052
9174
|
return {
|
|
9053
|
-
merchantCustomerId: (0,
|
|
9175
|
+
merchantCustomerId: (0, import_mysql_core13.primaryKey)({
|
|
9054
9176
|
columns: [
|
|
9055
9177
|
table.id
|
|
9056
9178
|
],
|
|
9057
9179
|
name: "MerchantCustomer_id"
|
|
9058
9180
|
}),
|
|
9059
|
-
merchantCustomerIdentifierKey: (0,
|
|
9181
|
+
merchantCustomerIdentifierKey: (0, import_mysql_core13.unique)("MerchantCustomer_identifier_key").on(table.identifier),
|
|
9182
|
+
userIdIdx: (0, import_mysql_core13.index)("idx_MerchantCustomer_on_userId").on(table.userId)
|
|
9060
9183
|
};
|
|
9061
9184
|
});
|
|
9062
9185
|
}
|
|
@@ -9064,39 +9187,39 @@ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
|
|
|
9064
9187
|
|
|
9065
9188
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
9066
9189
|
function getMerchantChargeSchema(mysqlTable) {
|
|
9067
|
-
return mysqlTable("
|
|
9068
|
-
id: (0,
|
|
9190
|
+
return mysqlTable("MerchantCharge", {
|
|
9191
|
+
id: (0, import_mysql_core14.varchar)("id", {
|
|
9069
9192
|
length: 191
|
|
9070
9193
|
}).notNull(),
|
|
9071
|
-
status: (0,
|
|
9072
|
-
identifier: (0,
|
|
9194
|
+
status: (0, import_mysql_core14.int)("status").default(0).notNull(),
|
|
9195
|
+
identifier: (0, import_mysql_core14.varchar)("identifier", {
|
|
9073
9196
|
length: 191
|
|
9074
9197
|
}).notNull(),
|
|
9075
|
-
userId: (0,
|
|
9198
|
+
userId: (0, import_mysql_core14.varchar)("userId", {
|
|
9076
9199
|
length: 191
|
|
9077
9200
|
}).notNull(),
|
|
9078
|
-
merchantAccountId: (0,
|
|
9201
|
+
merchantAccountId: (0, import_mysql_core14.varchar)("merchantAccountId", {
|
|
9079
9202
|
length: 191
|
|
9080
9203
|
}).notNull(),
|
|
9081
|
-
merchantProductId: (0,
|
|
9204
|
+
merchantProductId: (0, import_mysql_core14.varchar)("merchantProductId", {
|
|
9082
9205
|
length: 191
|
|
9083
9206
|
}).notNull(),
|
|
9084
|
-
createdAt: (0,
|
|
9207
|
+
createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
|
|
9085
9208
|
mode: "date",
|
|
9086
9209
|
fsp: 3
|
|
9087
|
-
}).default(
|
|
9088
|
-
merchantCustomerId: (0,
|
|
9210
|
+
}).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9211
|
+
merchantCustomerId: (0, import_mysql_core14.varchar)("merchantCustomerId", {
|
|
9089
9212
|
length: 191
|
|
9090
9213
|
}).notNull()
|
|
9091
9214
|
}, (table) => {
|
|
9092
9215
|
return {
|
|
9093
|
-
merchantChargeId: (0,
|
|
9216
|
+
merchantChargeId: (0, import_mysql_core14.primaryKey)({
|
|
9094
9217
|
columns: [
|
|
9095
9218
|
table.id
|
|
9096
9219
|
],
|
|
9097
9220
|
name: "MerchantCharge_id"
|
|
9098
9221
|
}),
|
|
9099
|
-
merchantChargeIdentifierKey: (0,
|
|
9222
|
+
merchantChargeIdentifierKey: (0, import_mysql_core14.unique)("MerchantCharge_identifier_key").on(table.identifier)
|
|
9100
9223
|
};
|
|
9101
9224
|
});
|
|
9102
9225
|
}
|
|
@@ -9106,7 +9229,7 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9106
9229
|
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
9107
9230
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
9108
9231
|
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
9109
|
-
return (0,
|
|
9232
|
+
return (0, import_drizzle_orm13.relations)(merchantCharge, ({ one }) => ({
|
|
9110
9233
|
merchantAccount: one(merchantAccount, {
|
|
9111
9234
|
fields: [
|
|
9112
9235
|
merchantCharge.merchantAccountId
|
|
@@ -9139,21 +9262,21 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9139
9262
|
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
9140
9263
|
|
|
9141
9264
|
// src/lib/mysql/schemas/commerce/merchant-session.ts
|
|
9142
|
-
var
|
|
9265
|
+
var import_mysql_core15 = require("drizzle-orm/mysql-core");
|
|
9143
9266
|
function getMerchantSessionSchema(mysqlTable) {
|
|
9144
|
-
return mysqlTable("
|
|
9145
|
-
id: (0,
|
|
9267
|
+
return mysqlTable("MerchantSession", {
|
|
9268
|
+
id: (0, import_mysql_core15.varchar)("id", {
|
|
9146
9269
|
length: 191
|
|
9147
9270
|
}).notNull(),
|
|
9148
|
-
identifier: (0,
|
|
9271
|
+
identifier: (0, import_mysql_core15.varchar)("identifier", {
|
|
9149
9272
|
length: 191
|
|
9150
9273
|
}).notNull(),
|
|
9151
|
-
merchantAccountId: (0,
|
|
9274
|
+
merchantAccountId: (0, import_mysql_core15.varchar)("merchantAccountId", {
|
|
9152
9275
|
length: 191
|
|
9153
9276
|
}).notNull()
|
|
9154
9277
|
}, (table) => {
|
|
9155
9278
|
return {
|
|
9156
|
-
merchantSessionId: (0,
|
|
9279
|
+
merchantSessionId: (0, import_mysql_core15.primaryKey)({
|
|
9157
9280
|
columns: [
|
|
9158
9281
|
table.id
|
|
9159
9282
|
],
|
|
@@ -9166,67 +9289,68 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
|
|
|
9166
9289
|
|
|
9167
9290
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
9168
9291
|
function getPurchaseSchema(mysqlTable) {
|
|
9169
|
-
return mysqlTable("
|
|
9170
|
-
id: (0,
|
|
9292
|
+
return mysqlTable("Purchase", {
|
|
9293
|
+
id: (0, import_mysql_core16.varchar)("id", {
|
|
9171
9294
|
length: 191
|
|
9172
9295
|
}).notNull(),
|
|
9173
|
-
userId: (0,
|
|
9296
|
+
userId: (0, import_mysql_core16.varchar)("userId", {
|
|
9174
9297
|
length: 191
|
|
9175
9298
|
}),
|
|
9176
|
-
createdAt: (0,
|
|
9299
|
+
createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
|
|
9177
9300
|
mode: "date",
|
|
9178
9301
|
fsp: 3
|
|
9179
|
-
}).default(
|
|
9180
|
-
totalAmount: (0,
|
|
9302
|
+
}).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9303
|
+
totalAmount: (0, import_mysql_core16.decimal)("totalAmount", {
|
|
9181
9304
|
precision: 65,
|
|
9182
9305
|
scale: 30
|
|
9183
9306
|
}).notNull(),
|
|
9184
|
-
ipAddress: (0,
|
|
9307
|
+
ipAddress: (0, import_mysql_core16.varchar)("ip_address", {
|
|
9185
9308
|
length: 191
|
|
9186
9309
|
}),
|
|
9187
|
-
city: (0,
|
|
9310
|
+
city: (0, import_mysql_core16.varchar)("city", {
|
|
9188
9311
|
length: 191
|
|
9189
9312
|
}),
|
|
9190
|
-
state: (0,
|
|
9313
|
+
state: (0, import_mysql_core16.varchar)("state", {
|
|
9191
9314
|
length: 191
|
|
9192
9315
|
}),
|
|
9193
|
-
country: (0,
|
|
9316
|
+
country: (0, import_mysql_core16.varchar)("country", {
|
|
9194
9317
|
length: 191
|
|
9195
9318
|
}),
|
|
9196
|
-
couponId: (0,
|
|
9319
|
+
couponId: (0, import_mysql_core16.varchar)("couponId", {
|
|
9197
9320
|
length: 191
|
|
9198
9321
|
}),
|
|
9199
|
-
productId: (0,
|
|
9322
|
+
productId: (0, import_mysql_core16.varchar)("productId", {
|
|
9200
9323
|
length: 191
|
|
9201
9324
|
}).notNull(),
|
|
9202
|
-
merchantChargeId: (0,
|
|
9325
|
+
merchantChargeId: (0, import_mysql_core16.varchar)("merchantChargeId", {
|
|
9203
9326
|
length: 191
|
|
9204
9327
|
}),
|
|
9205
|
-
upgradedFromId: (0,
|
|
9328
|
+
upgradedFromId: (0, import_mysql_core16.varchar)("upgradedFromId", {
|
|
9206
9329
|
length: 191
|
|
9207
9330
|
}),
|
|
9208
|
-
status: (0,
|
|
9331
|
+
status: (0, import_mysql_core16.varchar)("status", {
|
|
9209
9332
|
length: 191
|
|
9210
9333
|
}).default("Valid").notNull(),
|
|
9211
|
-
bulkCouponId: (0,
|
|
9334
|
+
bulkCouponId: (0, import_mysql_core16.varchar)("bulkCouponId", {
|
|
9212
9335
|
length: 191
|
|
9213
9336
|
}),
|
|
9214
|
-
merchantSessionId: (0,
|
|
9337
|
+
merchantSessionId: (0, import_mysql_core16.varchar)("merchantSessionId", {
|
|
9215
9338
|
length: 191
|
|
9216
9339
|
}),
|
|
9217
|
-
redeemedBulkCouponId: (0,
|
|
9340
|
+
redeemedBulkCouponId: (0, import_mysql_core16.varchar)("redeemedBulkCouponId", {
|
|
9218
9341
|
length: 191
|
|
9219
9342
|
}),
|
|
9220
|
-
fields: (0,
|
|
9343
|
+
fields: (0, import_mysql_core16.json)("fields").$type().default({})
|
|
9221
9344
|
}, (table) => {
|
|
9222
9345
|
return {
|
|
9223
|
-
purchaseId: (0,
|
|
9346
|
+
purchaseId: (0, import_mysql_core16.primaryKey)({
|
|
9224
9347
|
columns: [
|
|
9225
9348
|
table.id
|
|
9226
9349
|
],
|
|
9227
9350
|
name: "Purchase_id"
|
|
9228
9351
|
}),
|
|
9229
|
-
|
|
9352
|
+
merchantChargeIdIdx: (0, import_mysql_core16.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
9353
|
+
purchaseUpgradedFromIdKey: (0, import_mysql_core16.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId)
|
|
9230
9354
|
};
|
|
9231
9355
|
});
|
|
9232
9356
|
}
|
|
@@ -9238,7 +9362,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9238
9362
|
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
9239
9363
|
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
9240
9364
|
const coupons = getCouponSchema(mysqlTable);
|
|
9241
|
-
return (0,
|
|
9365
|
+
return (0, import_drizzle_orm14.relations)(purchases, ({ many, one }) => ({
|
|
9242
9366
|
redeemedBulkCoupon: one(coupons, {
|
|
9243
9367
|
fields: [
|
|
9244
9368
|
purchases.redeemedBulkCouponId
|
|
@@ -9297,61 +9421,113 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9297
9421
|
}
|
|
9298
9422
|
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
9299
9423
|
|
|
9300
|
-
// src/lib/mysql/schemas/communication/
|
|
9301
|
-
var
|
|
9424
|
+
// src/lib/mysql/schemas/communication/comment.ts
|
|
9425
|
+
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9302
9426
|
var import_mysql_core17 = require("drizzle-orm/mysql-core");
|
|
9427
|
+
function getCommentsSchema(mysqlTable) {
|
|
9428
|
+
return mysqlTable("Comment", {
|
|
9429
|
+
id: (0, import_mysql_core17.varchar)("id", {
|
|
9430
|
+
length: 191
|
|
9431
|
+
}).notNull(),
|
|
9432
|
+
userId: (0, import_mysql_core17.varchar)("userId", {
|
|
9433
|
+
length: 255
|
|
9434
|
+
}).notNull(),
|
|
9435
|
+
context: (0, import_mysql_core17.json)("context").$type().default({}),
|
|
9436
|
+
text: (0, import_mysql_core17.text)("text").notNull(),
|
|
9437
|
+
createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
|
|
9438
|
+
mode: "date",
|
|
9439
|
+
fsp: 3
|
|
9440
|
+
}).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
|
|
9441
|
+
updatedAt: (0, import_mysql_core17.timestamp)("updatedAt", {
|
|
9442
|
+
mode: "date",
|
|
9443
|
+
fsp: 3
|
|
9444
|
+
}).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
|
|
9445
|
+
deletedAt: (0, import_mysql_core17.timestamp)("deletedAt", {
|
|
9446
|
+
mode: "date",
|
|
9447
|
+
fsp: 3
|
|
9448
|
+
})
|
|
9449
|
+
}, (crr) => ({
|
|
9450
|
+
pk: (0, import_mysql_core17.primaryKey)({
|
|
9451
|
+
columns: [
|
|
9452
|
+
crr.id
|
|
9453
|
+
]
|
|
9454
|
+
}),
|
|
9455
|
+
crrUserIdIdKey: (0, import_mysql_core17.index)("crr_userIdId_idx").on(crr.userId)
|
|
9456
|
+
}));
|
|
9457
|
+
}
|
|
9458
|
+
__name(getCommentsSchema, "getCommentsSchema");
|
|
9459
|
+
function getCommentRelationsSchema(mysqlTable) {
|
|
9460
|
+
const comment = getCommentsSchema(mysqlTable);
|
|
9461
|
+
const user = getUsersSchema(mysqlTable);
|
|
9462
|
+
return (0, import_drizzle_orm15.relations)(comment, ({ one }) => ({
|
|
9463
|
+
user: one(user, {
|
|
9464
|
+
fields: [
|
|
9465
|
+
comment.userId
|
|
9466
|
+
],
|
|
9467
|
+
references: [
|
|
9468
|
+
user.id
|
|
9469
|
+
],
|
|
9470
|
+
relationName: "user"
|
|
9471
|
+
})
|
|
9472
|
+
}));
|
|
9473
|
+
}
|
|
9474
|
+
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
9475
|
+
|
|
9476
|
+
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9477
|
+
var import_drizzle_orm16 = require("drizzle-orm");
|
|
9478
|
+
var import_mysql_core20 = require("drizzle-orm/mysql-core");
|
|
9303
9479
|
|
|
9304
9480
|
// src/lib/mysql/schemas/communication/communication-channel.ts
|
|
9305
|
-
var
|
|
9481
|
+
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9306
9482
|
function getCommunicationChannelSchema(mysqlTable) {
|
|
9307
|
-
return mysqlTable("
|
|
9308
|
-
id: (0,
|
|
9483
|
+
return mysqlTable("CommunicationChannel", {
|
|
9484
|
+
id: (0, import_mysql_core18.varchar)("id", {
|
|
9309
9485
|
length: 255
|
|
9310
9486
|
}).notNull().primaryKey(),
|
|
9311
|
-
name: (0,
|
|
9487
|
+
name: (0, import_mysql_core18.varchar)("name", {
|
|
9312
9488
|
length: 255
|
|
9313
9489
|
}).notNull(),
|
|
9314
|
-
description: (0,
|
|
9315
|
-
active: (0,
|
|
9316
|
-
createdAt: (0,
|
|
9490
|
+
description: (0, import_mysql_core18.text)("description"),
|
|
9491
|
+
active: (0, import_mysql_core18.boolean)("active").notNull().default(true),
|
|
9492
|
+
createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
|
|
9317
9493
|
mode: "date",
|
|
9318
9494
|
fsp: 3
|
|
9319
9495
|
}).defaultNow(),
|
|
9320
|
-
updatedAt: (0,
|
|
9496
|
+
updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
|
|
9321
9497
|
mode: "date",
|
|
9322
9498
|
fsp: 3
|
|
9323
9499
|
}).defaultNow(),
|
|
9324
|
-
deletedAt: (0,
|
|
9500
|
+
deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
|
|
9325
9501
|
mode: "date",
|
|
9326
9502
|
fsp: 3
|
|
9327
9503
|
})
|
|
9328
9504
|
}, (cc) => ({
|
|
9329
|
-
nameIdx: (0,
|
|
9505
|
+
nameIdx: (0, import_mysql_core18.index)("name_idx").on(cc.name)
|
|
9330
9506
|
}));
|
|
9331
9507
|
}
|
|
9332
9508
|
__name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
|
|
9333
9509
|
|
|
9334
9510
|
// src/lib/mysql/schemas/communication/communication-preference-types.ts
|
|
9335
|
-
var
|
|
9511
|
+
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
9336
9512
|
function getCommunicationPreferenceTypesSchema(mysqlTable) {
|
|
9337
|
-
return mysqlTable("
|
|
9338
|
-
id: (0,
|
|
9513
|
+
return mysqlTable("CommunicationPreferenceType", {
|
|
9514
|
+
id: (0, import_mysql_core19.varchar)("id", {
|
|
9339
9515
|
length: 255
|
|
9340
9516
|
}).notNull().primaryKey(),
|
|
9341
|
-
name: (0,
|
|
9517
|
+
name: (0, import_mysql_core19.varchar)("name", {
|
|
9342
9518
|
length: 255
|
|
9343
9519
|
}).notNull(),
|
|
9344
|
-
description: (0,
|
|
9345
|
-
active: (0,
|
|
9346
|
-
createdAt: (0,
|
|
9520
|
+
description: (0, import_mysql_core19.text)("description"),
|
|
9521
|
+
active: (0, import_mysql_core19.boolean)("active").notNull().default(true),
|
|
9522
|
+
createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
|
|
9347
9523
|
mode: "date",
|
|
9348
9524
|
fsp: 3
|
|
9349
9525
|
}).defaultNow(),
|
|
9350
|
-
updatedAt: (0,
|
|
9526
|
+
updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
|
|
9351
9527
|
mode: "date",
|
|
9352
9528
|
fsp: 3
|
|
9353
9529
|
}),
|
|
9354
|
-
deletedAt: (0,
|
|
9530
|
+
deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
|
|
9355
9531
|
mode: "date",
|
|
9356
9532
|
fsp: 3
|
|
9357
9533
|
})
|
|
@@ -9361,49 +9537,49 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
|
|
|
9361
9537
|
|
|
9362
9538
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9363
9539
|
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
9364
|
-
return mysqlTable("
|
|
9365
|
-
id: (0,
|
|
9540
|
+
return mysqlTable("CommunicationPreference", {
|
|
9541
|
+
id: (0, import_mysql_core20.varchar)("id", {
|
|
9366
9542
|
length: 255
|
|
9367
9543
|
}).notNull().primaryKey(),
|
|
9368
|
-
userId: (0,
|
|
9544
|
+
userId: (0, import_mysql_core20.varchar)("userId", {
|
|
9369
9545
|
length: 255
|
|
9370
9546
|
}).notNull(),
|
|
9371
|
-
channelId: (0,
|
|
9547
|
+
channelId: (0, import_mysql_core20.varchar)("channelId", {
|
|
9372
9548
|
length: 255
|
|
9373
9549
|
}).notNull(),
|
|
9374
|
-
preferenceLevel: (0,
|
|
9550
|
+
preferenceLevel: (0, import_mysql_core20.mysqlEnum)("preferenceLevel", [
|
|
9375
9551
|
"low",
|
|
9376
9552
|
"medium",
|
|
9377
9553
|
"high"
|
|
9378
9554
|
]).notNull().default("medium"),
|
|
9379
|
-
preferenceTypeId: (0,
|
|
9555
|
+
preferenceTypeId: (0, import_mysql_core20.varchar)("preferenceTypeId", {
|
|
9380
9556
|
length: 255
|
|
9381
9557
|
}).notNull(),
|
|
9382
|
-
active: (0,
|
|
9383
|
-
createdAt: (0,
|
|
9558
|
+
active: (0, import_mysql_core20.boolean)("active").notNull().default(true),
|
|
9559
|
+
createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
|
|
9384
9560
|
mode: "date",
|
|
9385
9561
|
fsp: 3
|
|
9386
9562
|
}).defaultNow(),
|
|
9387
|
-
optInAt: (0,
|
|
9563
|
+
optInAt: (0, import_mysql_core20.timestamp)("optInAt", {
|
|
9388
9564
|
mode: "date",
|
|
9389
9565
|
fsp: 3
|
|
9390
9566
|
}),
|
|
9391
|
-
optOutAt: (0,
|
|
9567
|
+
optOutAt: (0, import_mysql_core20.timestamp)("optOutAt", {
|
|
9392
9568
|
mode: "date",
|
|
9393
9569
|
fsp: 3
|
|
9394
9570
|
}),
|
|
9395
|
-
updatedAt: (0,
|
|
9571
|
+
updatedAt: (0, import_mysql_core20.timestamp)("updatedAt", {
|
|
9396
9572
|
mode: "date",
|
|
9397
9573
|
fsp: 3
|
|
9398
9574
|
}).defaultNow(),
|
|
9399
|
-
deletedAt: (0,
|
|
9575
|
+
deletedAt: (0, import_mysql_core20.timestamp)("deletedAt", {
|
|
9400
9576
|
mode: "date",
|
|
9401
9577
|
fsp: 3
|
|
9402
9578
|
})
|
|
9403
9579
|
}, (cp) => ({
|
|
9404
|
-
userIdIdx: (0,
|
|
9405
|
-
preferenceTypeIdx: (0,
|
|
9406
|
-
channelIdIdx: (0,
|
|
9580
|
+
userIdIdx: (0, import_mysql_core20.index)("userId_idx").on(cp.userId),
|
|
9581
|
+
preferenceTypeIdx: (0, import_mysql_core20.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
9582
|
+
channelIdIdx: (0, import_mysql_core20.index)("channelId_idx").on(cp.channelId)
|
|
9407
9583
|
}));
|
|
9408
9584
|
}
|
|
9409
9585
|
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
@@ -9412,7 +9588,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9412
9588
|
const users = getUsersSchema(mysqlTable);
|
|
9413
9589
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
9414
9590
|
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
9415
|
-
return (0,
|
|
9591
|
+
return (0, import_drizzle_orm16.relations)(communicationPreferences, ({ one }) => ({
|
|
9416
9592
|
user: one(users, {
|
|
9417
9593
|
fields: [
|
|
9418
9594
|
communicationPreferences.userId
|
|
@@ -9444,192 +9620,76 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9444
9620
|
}
|
|
9445
9621
|
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
9446
9622
|
|
|
9447
|
-
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
9448
|
-
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9449
|
-
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
9450
|
-
|
|
9451
|
-
// src/lib/mysql/schemas/content/contribution-types.ts
|
|
9452
|
-
var import_drizzle_orm14 = require("drizzle-orm");
|
|
9453
|
-
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9454
|
-
function getContributionTypesSchema(mysqlTable) {
|
|
9455
|
-
return mysqlTable("contributionType", {
|
|
9456
|
-
id: (0, import_mysql_core18.varchar)("id", {
|
|
9457
|
-
length: 255
|
|
9458
|
-
}).notNull().primaryKey(),
|
|
9459
|
-
slug: (0, import_mysql_core18.varchar)("slug", {
|
|
9460
|
-
length: 255
|
|
9461
|
-
}).notNull().unique(),
|
|
9462
|
-
name: (0, import_mysql_core18.varchar)("name", {
|
|
9463
|
-
length: 255
|
|
9464
|
-
}).notNull(),
|
|
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", {
|
|
9468
|
-
mode: "date",
|
|
9469
|
-
fsp: 3
|
|
9470
|
-
}).defaultNow(),
|
|
9471
|
-
updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
|
|
9472
|
-
mode: "date",
|
|
9473
|
-
fsp: 3
|
|
9474
|
-
}).defaultNow(),
|
|
9475
|
-
deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
|
|
9476
|
-
mode: "date",
|
|
9477
|
-
fsp: 3
|
|
9478
|
-
})
|
|
9479
|
-
}, (ct) => ({
|
|
9480
|
-
nameIdx: (0, import_mysql_core18.index)("name_idx").on(ct.name),
|
|
9481
|
-
slugIdx: (0, import_mysql_core18.index)("slug_idx").on(ct.slug)
|
|
9482
|
-
}));
|
|
9483
|
-
}
|
|
9484
|
-
__name(getContributionTypesSchema, "getContributionTypesSchema");
|
|
9485
|
-
function getContributionTypesRelationsSchema(mysqlTable) {
|
|
9486
|
-
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
9487
|
-
return (0, import_drizzle_orm14.relations)(contributionTypes, ({ many }) => ({}));
|
|
9488
|
-
}
|
|
9489
|
-
__name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
|
|
9490
|
-
|
|
9491
|
-
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
9492
|
-
function getContentContributionsSchema(mysqlTable) {
|
|
9493
|
-
return mysqlTable("contentContribution", {
|
|
9494
|
-
id: (0, import_mysql_core19.varchar)("id", {
|
|
9495
|
-
length: 255
|
|
9496
|
-
}).notNull().primaryKey(),
|
|
9497
|
-
userId: (0, import_mysql_core19.varchar)("userId", {
|
|
9498
|
-
length: 255
|
|
9499
|
-
}).notNull(),
|
|
9500
|
-
contentId: (0, import_mysql_core19.varchar)("contentId", {
|
|
9501
|
-
length: 255
|
|
9502
|
-
}).notNull(),
|
|
9503
|
-
contributionTypeId: (0, import_mysql_core19.varchar)("contributionTypeId", {
|
|
9504
|
-
length: 255
|
|
9505
|
-
}).notNull(),
|
|
9506
|
-
active: (0, import_mysql_core19.boolean)("active").notNull().default(true),
|
|
9507
|
-
createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
|
|
9508
|
-
mode: "date",
|
|
9509
|
-
fsp: 3
|
|
9510
|
-
}).defaultNow(),
|
|
9511
|
-
updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
|
|
9512
|
-
mode: "date",
|
|
9513
|
-
fsp: 3
|
|
9514
|
-
}).defaultNow(),
|
|
9515
|
-
deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
|
|
9516
|
-
mode: "date",
|
|
9517
|
-
fsp: 3
|
|
9518
|
-
})
|
|
9519
|
-
}, (cc) => ({
|
|
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)
|
|
9523
|
-
}));
|
|
9524
|
-
}
|
|
9525
|
-
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
9526
|
-
function getContentContributionRelationsSchema(mysqlTable) {
|
|
9527
|
-
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
9528
|
-
const users = getUsersSchema(mysqlTable);
|
|
9529
|
-
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9530
|
-
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
9531
|
-
return (0, import_drizzle_orm15.relations)(contentContributions, ({ one }) => ({
|
|
9532
|
-
user: one(users, {
|
|
9533
|
-
fields: [
|
|
9534
|
-
contentContributions.userId
|
|
9535
|
-
],
|
|
9536
|
-
references: [
|
|
9537
|
-
users.id
|
|
9538
|
-
],
|
|
9539
|
-
relationName: "user"
|
|
9540
|
-
}),
|
|
9541
|
-
content: one(contentResource, {
|
|
9542
|
-
fields: [
|
|
9543
|
-
contentContributions.contentId
|
|
9544
|
-
],
|
|
9545
|
-
references: [
|
|
9546
|
-
contentResource.id
|
|
9547
|
-
],
|
|
9548
|
-
relationName: "contributions"
|
|
9549
|
-
}),
|
|
9550
|
-
contributionType: one(contributionTypes, {
|
|
9551
|
-
fields: [
|
|
9552
|
-
contentContributions.contributionTypeId
|
|
9553
|
-
],
|
|
9554
|
-
references: [
|
|
9555
|
-
contributionTypes.id
|
|
9556
|
-
],
|
|
9557
|
-
relationName: "contributionType"
|
|
9558
|
-
})
|
|
9559
|
-
}));
|
|
9560
|
-
}
|
|
9561
|
-
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
9562
|
-
|
|
9563
9623
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9564
|
-
var
|
|
9565
|
-
var
|
|
9624
|
+
var import_drizzle_orm18 = require("drizzle-orm");
|
|
9625
|
+
var import_mysql_core22 = require("drizzle-orm/mysql-core");
|
|
9566
9626
|
|
|
9567
9627
|
// src/lib/mysql/schemas/auth/permissions.ts
|
|
9568
|
-
var
|
|
9569
|
-
var
|
|
9628
|
+
var import_drizzle_orm17 = require("drizzle-orm");
|
|
9629
|
+
var import_mysql_core21 = require("drizzle-orm/mysql-core");
|
|
9570
9630
|
function getPermissionsSchema(mysqlTable) {
|
|
9571
|
-
return mysqlTable("
|
|
9572
|
-
id: (0,
|
|
9631
|
+
return mysqlTable("Permission", {
|
|
9632
|
+
id: (0, import_mysql_core21.varchar)("id", {
|
|
9573
9633
|
length: 255
|
|
9574
9634
|
}).notNull().primaryKey(),
|
|
9575
|
-
name: (0,
|
|
9635
|
+
name: (0, import_mysql_core21.varchar)("name", {
|
|
9576
9636
|
length: 255
|
|
9577
9637
|
}).notNull().unique(),
|
|
9578
|
-
description: (0,
|
|
9579
|
-
active: (0,
|
|
9580
|
-
createdAt: (0,
|
|
9638
|
+
description: (0, import_mysql_core21.text)("description"),
|
|
9639
|
+
active: (0, import_mysql_core21.boolean)("active").notNull().default(true),
|
|
9640
|
+
createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
|
|
9581
9641
|
mode: "date",
|
|
9582
9642
|
fsp: 3
|
|
9583
9643
|
}).defaultNow(),
|
|
9584
|
-
updatedAt: (0,
|
|
9644
|
+
updatedAt: (0, import_mysql_core21.timestamp)("updatedAt", {
|
|
9585
9645
|
mode: "date",
|
|
9586
9646
|
fsp: 3
|
|
9587
9647
|
}).defaultNow(),
|
|
9588
|
-
deletedAt: (0,
|
|
9648
|
+
deletedAt: (0, import_mysql_core21.timestamp)("deletedAt", {
|
|
9589
9649
|
mode: "date",
|
|
9590
9650
|
fsp: 3
|
|
9591
9651
|
})
|
|
9592
9652
|
}, (permission) => ({
|
|
9593
|
-
nameIdx: (0,
|
|
9653
|
+
nameIdx: (0, import_mysql_core21.index)("name_idx").on(permission.name)
|
|
9594
9654
|
}));
|
|
9595
9655
|
}
|
|
9596
9656
|
__name(getPermissionsSchema, "getPermissionsSchema");
|
|
9597
9657
|
function getPermissionsRelationsSchema(mysqlTable) {
|
|
9598
|
-
return (0,
|
|
9658
|
+
return (0, import_drizzle_orm17.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
|
|
9599
9659
|
}
|
|
9600
9660
|
__name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
|
|
9601
9661
|
|
|
9602
9662
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9603
9663
|
function getUserPermissionsSchema(mysqlTable) {
|
|
9604
|
-
return mysqlTable("
|
|
9605
|
-
userId: (0,
|
|
9664
|
+
return mysqlTable("UserPermission", {
|
|
9665
|
+
userId: (0, import_mysql_core22.varchar)("userId", {
|
|
9606
9666
|
length: 255
|
|
9607
9667
|
}).notNull(),
|
|
9608
|
-
permissionId: (0,
|
|
9668
|
+
permissionId: (0, import_mysql_core22.varchar)("permissionId", {
|
|
9609
9669
|
length: 255
|
|
9610
9670
|
}).notNull(),
|
|
9611
|
-
active: (0,
|
|
9612
|
-
createdAt: (0,
|
|
9671
|
+
active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
|
|
9672
|
+
createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
|
|
9613
9673
|
mode: "date",
|
|
9614
9674
|
fsp: 3
|
|
9615
9675
|
}).defaultNow(),
|
|
9616
|
-
updatedAt: (0,
|
|
9676
|
+
updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
|
|
9617
9677
|
mode: "date",
|
|
9618
9678
|
fsp: 3
|
|
9619
9679
|
}).defaultNow(),
|
|
9620
|
-
deletedAt: (0,
|
|
9680
|
+
deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
|
|
9621
9681
|
mode: "date",
|
|
9622
9682
|
fsp: 3
|
|
9623
9683
|
})
|
|
9624
9684
|
}, (up) => ({
|
|
9625
|
-
pk: (0,
|
|
9685
|
+
pk: (0, import_mysql_core22.primaryKey)({
|
|
9626
9686
|
columns: [
|
|
9627
9687
|
up.userId,
|
|
9628
9688
|
up.permissionId
|
|
9629
9689
|
]
|
|
9630
9690
|
}),
|
|
9631
|
-
userIdIdx: (0,
|
|
9632
|
-
permissionIdIdx: (0,
|
|
9691
|
+
userIdIdx: (0, import_mysql_core22.index)("userId_idx").on(up.userId),
|
|
9692
|
+
permissionIdIdx: (0, import_mysql_core22.index)("permissionId_idx").on(up.permissionId)
|
|
9633
9693
|
}));
|
|
9634
9694
|
}
|
|
9635
9695
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -9637,7 +9697,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9637
9697
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
9638
9698
|
const users = getUsersSchema(mysqlTable);
|
|
9639
9699
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
9640
|
-
return (0,
|
|
9700
|
+
return (0, import_drizzle_orm18.relations)(userPermissions, ({ one }) => ({
|
|
9641
9701
|
user: one(users, {
|
|
9642
9702
|
fields: [
|
|
9643
9703
|
userPermissions.userId
|
|
@@ -9660,44 +9720,98 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9660
9720
|
}
|
|
9661
9721
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
9662
9722
|
|
|
9663
|
-
// src/lib/mysql/schemas/auth/user-
|
|
9723
|
+
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
9664
9724
|
var import_drizzle_orm19 = require("drizzle-orm");
|
|
9665
9725
|
var import_mysql_core23 = require("drizzle-orm/mysql-core");
|
|
9726
|
+
function getUserPrefsSchema(mysqlTable) {
|
|
9727
|
+
return mysqlTable("UserPrefs", {
|
|
9728
|
+
id: (0, import_mysql_core23.varchar)("id", {
|
|
9729
|
+
length: 191
|
|
9730
|
+
}).notNull(),
|
|
9731
|
+
type: (0, import_mysql_core23.varchar)("type", {
|
|
9732
|
+
length: 191
|
|
9733
|
+
}).default("Global").notNull(),
|
|
9734
|
+
userId: (0, import_mysql_core23.varchar)("userId", {
|
|
9735
|
+
length: 255
|
|
9736
|
+
}).notNull(),
|
|
9737
|
+
fields: (0, import_mysql_core23.json)("fields").$type().default({}),
|
|
9738
|
+
createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
|
|
9739
|
+
mode: "date",
|
|
9740
|
+
fsp: 3
|
|
9741
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
|
|
9742
|
+
updatedAt: (0, import_mysql_core23.timestamp)("updatedAt", {
|
|
9743
|
+
mode: "date",
|
|
9744
|
+
fsp: 3
|
|
9745
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
|
|
9746
|
+
deletedAt: (0, import_mysql_core23.timestamp)("deletedAt", {
|
|
9747
|
+
mode: "date",
|
|
9748
|
+
fsp: 3
|
|
9749
|
+
})
|
|
9750
|
+
}, (crr) => ({
|
|
9751
|
+
pk: (0, import_mysql_core23.primaryKey)({
|
|
9752
|
+
columns: [
|
|
9753
|
+
crr.id
|
|
9754
|
+
]
|
|
9755
|
+
}),
|
|
9756
|
+
crrUserIdIdKey: (0, import_mysql_core23.index)("crr_userIdId_idx").on(crr.userId)
|
|
9757
|
+
}));
|
|
9758
|
+
}
|
|
9759
|
+
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
9760
|
+
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
9761
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9762
|
+
const user = getUsersSchema(mysqlTable);
|
|
9763
|
+
return (0, import_drizzle_orm19.relations)(userPrefs, ({ one }) => ({
|
|
9764
|
+
user: one(user, {
|
|
9765
|
+
fields: [
|
|
9766
|
+
userPrefs.userId
|
|
9767
|
+
],
|
|
9768
|
+
references: [
|
|
9769
|
+
user.id
|
|
9770
|
+
],
|
|
9771
|
+
relationName: "user"
|
|
9772
|
+
})
|
|
9773
|
+
}));
|
|
9774
|
+
}
|
|
9775
|
+
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
9776
|
+
|
|
9777
|
+
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9778
|
+
var import_drizzle_orm21 = require("drizzle-orm");
|
|
9779
|
+
var import_mysql_core25 = require("drizzle-orm/mysql-core");
|
|
9666
9780
|
|
|
9667
9781
|
// src/lib/mysql/schemas/auth/roles.ts
|
|
9668
|
-
var
|
|
9669
|
-
var
|
|
9782
|
+
var import_drizzle_orm20 = require("drizzle-orm");
|
|
9783
|
+
var import_mysql_core24 = require("drizzle-orm/mysql-core");
|
|
9670
9784
|
function getRolesSchema(mysqlTable) {
|
|
9671
|
-
return mysqlTable("
|
|
9672
|
-
id: (0,
|
|
9785
|
+
return mysqlTable("Role", {
|
|
9786
|
+
id: (0, import_mysql_core24.varchar)("id", {
|
|
9673
9787
|
length: 255
|
|
9674
9788
|
}).notNull().primaryKey(),
|
|
9675
|
-
name: (0,
|
|
9789
|
+
name: (0, import_mysql_core24.varchar)("name", {
|
|
9676
9790
|
length: 255
|
|
9677
9791
|
}).notNull().unique(),
|
|
9678
|
-
description: (0,
|
|
9679
|
-
active: (0,
|
|
9680
|
-
createdAt: (0,
|
|
9792
|
+
description: (0, import_mysql_core24.text)("description"),
|
|
9793
|
+
active: (0, import_mysql_core24.boolean)("active").notNull().default(true),
|
|
9794
|
+
createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
|
|
9681
9795
|
mode: "date",
|
|
9682
9796
|
fsp: 3
|
|
9683
9797
|
}).defaultNow(),
|
|
9684
|
-
updatedAt: (0,
|
|
9798
|
+
updatedAt: (0, import_mysql_core24.timestamp)("updatedAt", {
|
|
9685
9799
|
mode: "date",
|
|
9686
9800
|
fsp: 3
|
|
9687
9801
|
}).defaultNow(),
|
|
9688
|
-
deletedAt: (0,
|
|
9802
|
+
deletedAt: (0, import_mysql_core24.timestamp)("deletedAt", {
|
|
9689
9803
|
mode: "date",
|
|
9690
9804
|
fsp: 3
|
|
9691
9805
|
})
|
|
9692
9806
|
}, (role) => ({
|
|
9693
|
-
nameIdx: (0,
|
|
9807
|
+
nameIdx: (0, import_mysql_core24.index)("name_idx").on(role.name)
|
|
9694
9808
|
}));
|
|
9695
9809
|
}
|
|
9696
9810
|
__name(getRolesSchema, "getRolesSchema");
|
|
9697
9811
|
function getRolesRelationsSchema(mysqlTable) {
|
|
9698
9812
|
const roles = getRolesSchema(mysqlTable);
|
|
9699
9813
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9700
|
-
return (0,
|
|
9814
|
+
return (0, import_drizzle_orm20.relations)(roles, ({ many }) => ({
|
|
9701
9815
|
userRoles: many(userRoles, {
|
|
9702
9816
|
relationName: "role"
|
|
9703
9817
|
})
|
|
@@ -9707,35 +9821,35 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
|
9707
9821
|
|
|
9708
9822
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9709
9823
|
function getUserRolesSchema(mysqlTable) {
|
|
9710
|
-
return mysqlTable("
|
|
9711
|
-
userId: (0,
|
|
9824
|
+
return mysqlTable("UserRole", {
|
|
9825
|
+
userId: (0, import_mysql_core25.varchar)("userId", {
|
|
9712
9826
|
length: 255
|
|
9713
9827
|
}).notNull(),
|
|
9714
|
-
roleId: (0,
|
|
9828
|
+
roleId: (0, import_mysql_core25.varchar)("roleId", {
|
|
9715
9829
|
length: 255
|
|
9716
9830
|
}).notNull(),
|
|
9717
|
-
active: (0,
|
|
9718
|
-
createdAt: (0,
|
|
9831
|
+
active: (0, import_mysql_core25.boolean)("active").notNull().default(true),
|
|
9832
|
+
createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
|
|
9719
9833
|
mode: "date",
|
|
9720
9834
|
fsp: 3
|
|
9721
9835
|
}).defaultNow(),
|
|
9722
|
-
updatedAt: (0,
|
|
9836
|
+
updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
|
|
9723
9837
|
mode: "date",
|
|
9724
9838
|
fsp: 3
|
|
9725
9839
|
}).defaultNow(),
|
|
9726
|
-
deletedAt: (0,
|
|
9840
|
+
deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
|
|
9727
9841
|
mode: "date",
|
|
9728
9842
|
fsp: 3
|
|
9729
9843
|
})
|
|
9730
9844
|
}, (ur) => ({
|
|
9731
|
-
pk: (0,
|
|
9845
|
+
pk: (0, import_mysql_core25.primaryKey)({
|
|
9732
9846
|
columns: [
|
|
9733
9847
|
ur.userId,
|
|
9734
9848
|
ur.roleId
|
|
9735
9849
|
]
|
|
9736
9850
|
}),
|
|
9737
|
-
userIdIdx: (0,
|
|
9738
|
-
roleIdIdx: (0,
|
|
9851
|
+
userIdIdx: (0, import_mysql_core25.index)("userId_idx").on(ur.userId),
|
|
9852
|
+
roleIdIdx: (0, import_mysql_core25.index)("roleId_idx").on(ur.roleId)
|
|
9739
9853
|
}));
|
|
9740
9854
|
}
|
|
9741
9855
|
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
@@ -9743,7 +9857,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
|
|
|
9743
9857
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9744
9858
|
const users = getUsersSchema(mysqlTable);
|
|
9745
9859
|
const roles = getRolesSchema(mysqlTable);
|
|
9746
|
-
return (0,
|
|
9860
|
+
return (0, import_drizzle_orm21.relations)(userRoles, ({ one }) => ({
|
|
9747
9861
|
user: one(users, {
|
|
9748
9862
|
fields: [
|
|
9749
9863
|
userRoles.userId
|
|
@@ -9768,35 +9882,35 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
|
9768
9882
|
|
|
9769
9883
|
// src/lib/mysql/schemas/auth/users.ts
|
|
9770
9884
|
function getUsersSchema(mysqlTable) {
|
|
9771
|
-
return mysqlTable("
|
|
9772
|
-
id: (0,
|
|
9885
|
+
return mysqlTable("User", {
|
|
9886
|
+
id: (0, import_mysql_core26.varchar)("id", {
|
|
9773
9887
|
length: 255
|
|
9774
9888
|
}).notNull().primaryKey(),
|
|
9775
|
-
name: (0,
|
|
9889
|
+
name: (0, import_mysql_core26.varchar)("name", {
|
|
9776
9890
|
length: 255
|
|
9777
9891
|
}),
|
|
9778
|
-
role: (0,
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
email: (0, import_mysql_core24.varchar)("email", {
|
|
9892
|
+
role: (0, import_mysql_core26.varchar)("role", {
|
|
9893
|
+
length: 191
|
|
9894
|
+
}).notNull().default("user"),
|
|
9895
|
+
email: (0, import_mysql_core26.varchar)("email", {
|
|
9783
9896
|
length: 255
|
|
9784
9897
|
}).notNull().unique(),
|
|
9785
|
-
|
|
9898
|
+
fields: (0, import_mysql_core26.json)("fields").$type().default({}),
|
|
9899
|
+
emailVerified: (0, import_mysql_core26.timestamp)("emailVerified", {
|
|
9786
9900
|
mode: "date",
|
|
9787
9901
|
fsp: 3
|
|
9788
9902
|
}),
|
|
9789
|
-
image: (0,
|
|
9903
|
+
image: (0, import_mysql_core26.varchar)("image", {
|
|
9790
9904
|
length: 255
|
|
9791
9905
|
}),
|
|
9792
|
-
createdAt: (0,
|
|
9906
|
+
createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
|
|
9793
9907
|
mode: "date",
|
|
9794
9908
|
fsp: 3
|
|
9795
|
-
}).default(
|
|
9909
|
+
}).default(import_drizzle_orm22.sql`CURRENT_TIMESTAMP(3)`)
|
|
9796
9910
|
}, (user) => ({
|
|
9797
|
-
emailIdx: (0,
|
|
9798
|
-
roleIdx: (0,
|
|
9799
|
-
createdAtIdx: (0,
|
|
9911
|
+
emailIdx: (0, import_mysql_core26.index)("email_idx").on(user.email),
|
|
9912
|
+
roleIdx: (0, import_mysql_core26.index)("role_idx").on(user.role),
|
|
9913
|
+
createdAtIdx: (0, import_mysql_core26.index)("created_at_idx").on(user.createdAt)
|
|
9800
9914
|
}));
|
|
9801
9915
|
}
|
|
9802
9916
|
__name(getUsersSchema, "getUsersSchema");
|
|
@@ -9809,7 +9923,9 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
9809
9923
|
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
9810
9924
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9811
9925
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
9812
|
-
|
|
9926
|
+
const comments = getCommentsSchema(mysqlTable);
|
|
9927
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9928
|
+
return (0, import_drizzle_orm22.relations)(users, ({ many }) => ({
|
|
9813
9929
|
accounts: many(accounts, {
|
|
9814
9930
|
relationName: "user"
|
|
9815
9931
|
}),
|
|
@@ -9830,6 +9946,12 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
9830
9946
|
}),
|
|
9831
9947
|
createdContent: many(contentResource, {
|
|
9832
9948
|
relationName: "user"
|
|
9949
|
+
}),
|
|
9950
|
+
comments: many(comments, {
|
|
9951
|
+
relationName: "user"
|
|
9952
|
+
}),
|
|
9953
|
+
prefs: many(userPrefs, {
|
|
9954
|
+
relationName: "user"
|
|
9833
9955
|
})
|
|
9834
9956
|
}));
|
|
9835
9957
|
}
|
|
@@ -9837,50 +9959,50 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
|
9837
9959
|
|
|
9838
9960
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
9839
9961
|
function getAccountsSchema(mysqlTable) {
|
|
9840
|
-
return mysqlTable("
|
|
9841
|
-
userId: (0,
|
|
9962
|
+
return mysqlTable("Account", {
|
|
9963
|
+
userId: (0, import_mysql_core27.varchar)("userId", {
|
|
9842
9964
|
length: 255
|
|
9843
9965
|
}).notNull(),
|
|
9844
|
-
type: (0,
|
|
9966
|
+
type: (0, import_mysql_core27.varchar)("type", {
|
|
9845
9967
|
length: 255
|
|
9846
9968
|
}).$type().notNull(),
|
|
9847
|
-
provider: (0,
|
|
9969
|
+
provider: (0, import_mysql_core27.varchar)("provider", {
|
|
9848
9970
|
length: 255
|
|
9849
9971
|
}).notNull(),
|
|
9850
|
-
providerAccountId: (0,
|
|
9972
|
+
providerAccountId: (0, import_mysql_core27.varchar)("providerAccountId", {
|
|
9851
9973
|
length: 255
|
|
9852
9974
|
}).notNull(),
|
|
9853
|
-
refresh_token: (0,
|
|
9854
|
-
access_token: (0,
|
|
9855
|
-
oauth_token: (0,
|
|
9856
|
-
oauth_token_secret: (0,
|
|
9857
|
-
expires_at: (0,
|
|
9858
|
-
token_type: (0,
|
|
9975
|
+
refresh_token: (0, import_mysql_core27.text)("refresh_token"),
|
|
9976
|
+
access_token: (0, import_mysql_core27.text)("access_token"),
|
|
9977
|
+
oauth_token: (0, import_mysql_core27.text)("oauth_token"),
|
|
9978
|
+
oauth_token_secret: (0, import_mysql_core27.text)("oauth_token_secret"),
|
|
9979
|
+
expires_at: (0, import_mysql_core27.int)("expires_at"),
|
|
9980
|
+
token_type: (0, import_mysql_core27.varchar)("token_type", {
|
|
9859
9981
|
length: 255
|
|
9860
9982
|
}),
|
|
9861
|
-
scope: (0,
|
|
9983
|
+
scope: (0, import_mysql_core27.varchar)("scope", {
|
|
9862
9984
|
length: 255
|
|
9863
9985
|
}),
|
|
9864
|
-
id_token: (0,
|
|
9865
|
-
session_state: (0,
|
|
9986
|
+
id_token: (0, import_mysql_core27.text)("id_token"),
|
|
9987
|
+
session_state: (0, import_mysql_core27.varchar)("session_state", {
|
|
9866
9988
|
length: 255
|
|
9867
9989
|
}),
|
|
9868
|
-
refresh_token_expires_in: (0,
|
|
9990
|
+
refresh_token_expires_in: (0, import_mysql_core27.int)("refresh_token_expires_in")
|
|
9869
9991
|
}, (account) => ({
|
|
9870
|
-
pk: (0,
|
|
9992
|
+
pk: (0, import_mysql_core27.primaryKey)({
|
|
9871
9993
|
columns: [
|
|
9872
9994
|
account.provider,
|
|
9873
9995
|
account.providerAccountId
|
|
9874
9996
|
]
|
|
9875
9997
|
}),
|
|
9876
|
-
userIdIdx: (0,
|
|
9998
|
+
userIdIdx: (0, import_mysql_core27.index)("userId_idx").on(account.userId)
|
|
9877
9999
|
}));
|
|
9878
10000
|
}
|
|
9879
10001
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
9880
10002
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
9881
10003
|
const accounts = getAccountsSchema(mysqlTable);
|
|
9882
10004
|
const users = getUsersSchema(mysqlTable);
|
|
9883
|
-
return (0,
|
|
10005
|
+
return (0, import_drizzle_orm23.relations)(accounts, ({ one }) => ({
|
|
9884
10006
|
user: one(users, {
|
|
9885
10007
|
fields: [
|
|
9886
10008
|
accounts.userId
|
|
@@ -9894,39 +10016,131 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
9894
10016
|
}
|
|
9895
10017
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
9896
10018
|
|
|
10019
|
+
// src/lib/mysql/schemas/auth/device-access-token.ts
|
|
10020
|
+
var import_drizzle_orm24 = require("drizzle-orm");
|
|
10021
|
+
var import_mysql_core28 = require("drizzle-orm/mysql-core");
|
|
10022
|
+
function getDeviceAccessTokenSchema(mysqlTable) {
|
|
10023
|
+
return mysqlTable("DeviceAccessToken", {
|
|
10024
|
+
token: (0, import_mysql_core28.varchar)("token", {
|
|
10025
|
+
length: 191
|
|
10026
|
+
}).notNull(),
|
|
10027
|
+
userId: (0, import_mysql_core28.varchar)("userId", {
|
|
10028
|
+
length: 191
|
|
10029
|
+
}).notNull(),
|
|
10030
|
+
createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
|
|
10031
|
+
mode: "date",
|
|
10032
|
+
fsp: 3
|
|
10033
|
+
}).default(import_drizzle_orm24.sql`CURRENT_TIMESTAMP(3)`)
|
|
10034
|
+
}, (crr) => ({
|
|
10035
|
+
pk: (0, import_mysql_core28.primaryKey)({
|
|
10036
|
+
columns: [
|
|
10037
|
+
crr.token
|
|
10038
|
+
]
|
|
10039
|
+
}),
|
|
10040
|
+
userIdIdx: (0, import_mysql_core28.index)("userId_idx").on(crr.userId)
|
|
10041
|
+
}));
|
|
10042
|
+
}
|
|
10043
|
+
__name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
|
|
10044
|
+
function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
10045
|
+
const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
|
|
10046
|
+
const user = getUsersSchema(mysqlTable);
|
|
10047
|
+
return (0, import_drizzle_orm24.relations)(deviceAccessToken, ({ one }) => ({
|
|
10048
|
+
verifiedBy: one(user, {
|
|
10049
|
+
fields: [
|
|
10050
|
+
deviceAccessToken.userId
|
|
10051
|
+
],
|
|
10052
|
+
references: [
|
|
10053
|
+
user.id
|
|
10054
|
+
],
|
|
10055
|
+
relationName: "user"
|
|
10056
|
+
})
|
|
10057
|
+
}));
|
|
10058
|
+
}
|
|
10059
|
+
__name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
|
|
10060
|
+
|
|
10061
|
+
// src/lib/mysql/schemas/auth/device-verification.ts
|
|
10062
|
+
var import_drizzle_orm25 = require("drizzle-orm");
|
|
10063
|
+
var import_mysql_core29 = require("drizzle-orm/mysql-core");
|
|
10064
|
+
function getDeviceVerificationSchema(mysqlTable) {
|
|
10065
|
+
return mysqlTable("DeviceVerification", {
|
|
10066
|
+
verifiedByUserId: (0, import_mysql_core29.varchar)("verifiedByUserId", {
|
|
10067
|
+
length: 255
|
|
10068
|
+
}),
|
|
10069
|
+
deviceCode: (0, import_mysql_core29.varchar)("deviceCode", {
|
|
10070
|
+
length: 191
|
|
10071
|
+
}).notNull(),
|
|
10072
|
+
userCode: (0, import_mysql_core29.text)("userCode").notNull(),
|
|
10073
|
+
expires: (0, import_mysql_core29.timestamp)("expires", {
|
|
10074
|
+
mode: "date",
|
|
10075
|
+
fsp: 3
|
|
10076
|
+
}).notNull(),
|
|
10077
|
+
createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
|
|
10078
|
+
mode: "date",
|
|
10079
|
+
fsp: 3
|
|
10080
|
+
}).default(import_drizzle_orm25.sql`CURRENT_TIMESTAMP(3)`),
|
|
10081
|
+
verifiedAt: (0, import_mysql_core29.timestamp)("verifiedAt", {
|
|
10082
|
+
mode: "date",
|
|
10083
|
+
fsp: 3
|
|
10084
|
+
})
|
|
10085
|
+
}, (crr) => ({
|
|
10086
|
+
pk: (0, import_mysql_core29.primaryKey)({
|
|
10087
|
+
columns: [
|
|
10088
|
+
crr.deviceCode
|
|
10089
|
+
]
|
|
10090
|
+
})
|
|
10091
|
+
}));
|
|
10092
|
+
}
|
|
10093
|
+
__name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
|
|
10094
|
+
function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
10095
|
+
const deviceVerification = getDeviceVerificationSchema(mysqlTable);
|
|
10096
|
+
const user = getUsersSchema(mysqlTable);
|
|
10097
|
+
return (0, import_drizzle_orm25.relations)(deviceVerification, ({ one }) => ({
|
|
10098
|
+
verifiedBy: one(user, {
|
|
10099
|
+
fields: [
|
|
10100
|
+
deviceVerification.verifiedByUserId
|
|
10101
|
+
],
|
|
10102
|
+
references: [
|
|
10103
|
+
user.id
|
|
10104
|
+
],
|
|
10105
|
+
relationName: "user"
|
|
10106
|
+
})
|
|
10107
|
+
}));
|
|
10108
|
+
}
|
|
10109
|
+
__name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
|
|
10110
|
+
|
|
9897
10111
|
// src/lib/mysql/schemas/auth/role-permissions.ts
|
|
9898
|
-
var
|
|
9899
|
-
var
|
|
10112
|
+
var import_drizzle_orm26 = require("drizzle-orm");
|
|
10113
|
+
var import_mysql_core30 = require("drizzle-orm/mysql-core");
|
|
9900
10114
|
function getRolePermissionsSchema(mysqlTable) {
|
|
9901
|
-
return mysqlTable("
|
|
9902
|
-
roleId: (0,
|
|
10115
|
+
return mysqlTable("RolePermission", {
|
|
10116
|
+
roleId: (0, import_mysql_core30.varchar)("roleId", {
|
|
9903
10117
|
length: 255
|
|
9904
10118
|
}).notNull(),
|
|
9905
|
-
permissionId: (0,
|
|
10119
|
+
permissionId: (0, import_mysql_core30.varchar)("permissionId", {
|
|
9906
10120
|
length: 255
|
|
9907
10121
|
}).notNull(),
|
|
9908
|
-
active: (0,
|
|
9909
|
-
createdAt: (0,
|
|
10122
|
+
active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
|
|
10123
|
+
createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
|
|
9910
10124
|
mode: "date",
|
|
9911
10125
|
fsp: 3
|
|
9912
10126
|
}).defaultNow(),
|
|
9913
|
-
updatedAt: (0,
|
|
10127
|
+
updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
|
|
9914
10128
|
mode: "date",
|
|
9915
10129
|
fsp: 3
|
|
9916
10130
|
}).defaultNow(),
|
|
9917
|
-
deletedAt: (0,
|
|
10131
|
+
deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
|
|
9918
10132
|
mode: "date",
|
|
9919
10133
|
fsp: 3
|
|
9920
10134
|
})
|
|
9921
10135
|
}, (rp) => ({
|
|
9922
|
-
pk: (0,
|
|
10136
|
+
pk: (0, import_mysql_core30.primaryKey)({
|
|
9923
10137
|
columns: [
|
|
9924
10138
|
rp.roleId,
|
|
9925
10139
|
rp.permissionId
|
|
9926
10140
|
]
|
|
9927
10141
|
}),
|
|
9928
|
-
roleIdIdx: (0,
|
|
9929
|
-
permissionIdIdx: (0,
|
|
10142
|
+
roleIdIdx: (0, import_mysql_core30.index)("roleId_idx").on(rp.roleId),
|
|
10143
|
+
permissionIdIdx: (0, import_mysql_core30.index)("permissionId_idx").on(rp.permissionId)
|
|
9930
10144
|
}));
|
|
9931
10145
|
}
|
|
9932
10146
|
__name(getRolePermissionsSchema, "getRolePermissionsSchema");
|
|
@@ -9934,7 +10148,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
9934
10148
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
9935
10149
|
const roles = getRolesSchema(mysqlTable);
|
|
9936
10150
|
const rolePermissions = getRolePermissionsSchema(mysqlTable);
|
|
9937
|
-
return (0,
|
|
10151
|
+
return (0, import_drizzle_orm26.relations)(rolePermissions, ({ one }) => ({
|
|
9938
10152
|
role: one(roles, {
|
|
9939
10153
|
fields: [
|
|
9940
10154
|
rolePermissions.roleId
|
|
@@ -9958,28 +10172,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
9958
10172
|
__name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
|
|
9959
10173
|
|
|
9960
10174
|
// src/lib/mysql/schemas/auth/sessions.ts
|
|
9961
|
-
var
|
|
9962
|
-
var
|
|
10175
|
+
var import_drizzle_orm27 = require("drizzle-orm");
|
|
10176
|
+
var import_mysql_core31 = require("drizzle-orm/mysql-core");
|
|
9963
10177
|
function getSessionsSchema(mysqlTable) {
|
|
9964
|
-
return mysqlTable("
|
|
9965
|
-
sessionToken: (0,
|
|
10178
|
+
return mysqlTable("Session", {
|
|
10179
|
+
sessionToken: (0, import_mysql_core31.varchar)("sessionToken", {
|
|
9966
10180
|
length: 255
|
|
9967
10181
|
}).notNull().primaryKey(),
|
|
9968
|
-
userId: (0,
|
|
10182
|
+
userId: (0, import_mysql_core31.varchar)("userId", {
|
|
9969
10183
|
length: 255
|
|
9970
10184
|
}).notNull(),
|
|
9971
|
-
expires: (0,
|
|
10185
|
+
expires: (0, import_mysql_core31.timestamp)("expires", {
|
|
9972
10186
|
mode: "date"
|
|
9973
10187
|
}).notNull()
|
|
9974
10188
|
}, (session) => ({
|
|
9975
|
-
userIdIdx: (0,
|
|
10189
|
+
userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(session.userId)
|
|
9976
10190
|
}));
|
|
9977
10191
|
}
|
|
9978
10192
|
__name(getSessionsSchema, "getSessionsSchema");
|
|
9979
10193
|
function getSessionRelationsSchema(mysqlTable) {
|
|
9980
10194
|
const sessions = getSessionsSchema(mysqlTable);
|
|
9981
10195
|
const users = getUsersSchema(mysqlTable);
|
|
9982
|
-
return (0,
|
|
10196
|
+
return (0, import_drizzle_orm27.relations)(sessions, ({ one }) => ({
|
|
9983
10197
|
user: one(users, {
|
|
9984
10198
|
fields: [
|
|
9985
10199
|
sessions.userId
|
|
@@ -9994,24 +10208,24 @@ function getSessionRelationsSchema(mysqlTable) {
|
|
|
9994
10208
|
__name(getSessionRelationsSchema, "getSessionRelationsSchema");
|
|
9995
10209
|
|
|
9996
10210
|
// src/lib/mysql/schemas/auth/verification-tokens.ts
|
|
9997
|
-
var
|
|
10211
|
+
var import_mysql_core32 = require("drizzle-orm/mysql-core");
|
|
9998
10212
|
function getVerificationTokensSchema(mysqlTable) {
|
|
9999
|
-
return mysqlTable("
|
|
10000
|
-
identifier: (0,
|
|
10213
|
+
return mysqlTable("VerificationToken", {
|
|
10214
|
+
identifier: (0, import_mysql_core32.varchar)("identifier", {
|
|
10001
10215
|
length: 255
|
|
10002
10216
|
}).notNull(),
|
|
10003
|
-
token: (0,
|
|
10217
|
+
token: (0, import_mysql_core32.varchar)("token", {
|
|
10004
10218
|
length: 255
|
|
10005
10219
|
}).notNull(),
|
|
10006
|
-
expires: (0,
|
|
10220
|
+
expires: (0, import_mysql_core32.timestamp)("expires", {
|
|
10007
10221
|
mode: "date"
|
|
10008
10222
|
}).notNull(),
|
|
10009
|
-
createdAt: (0,
|
|
10223
|
+
createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
|
|
10010
10224
|
mode: "date",
|
|
10011
10225
|
fsp: 3
|
|
10012
10226
|
}).defaultNow()
|
|
10013
10227
|
}, (vt) => ({
|
|
10014
|
-
pk: (0,
|
|
10228
|
+
pk: (0, import_mysql_core32.primaryKey)({
|
|
10015
10229
|
columns: [
|
|
10016
10230
|
vt.identifier,
|
|
10017
10231
|
vt.token
|
|
@@ -10022,14 +10236,14 @@ function getVerificationTokensSchema(mysqlTable) {
|
|
|
10022
10236
|
__name(getVerificationTokensSchema, "getVerificationTokensSchema");
|
|
10023
10237
|
|
|
10024
10238
|
// src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
|
|
10025
|
-
var
|
|
10026
|
-
var
|
|
10239
|
+
var import_drizzle_orm28 = require("drizzle-orm");
|
|
10240
|
+
var import_mysql_core33 = require("drizzle-orm/mysql-core");
|
|
10027
10241
|
function getPurchaseUserTransferSchema(mysqlTable) {
|
|
10028
|
-
return mysqlTable("
|
|
10029
|
-
id: (0,
|
|
10242
|
+
return mysqlTable("PurchaseUserTransfer", {
|
|
10243
|
+
id: (0, import_mysql_core33.varchar)("id", {
|
|
10030
10244
|
length: 191
|
|
10031
10245
|
}).notNull(),
|
|
10032
|
-
transferState: (0,
|
|
10246
|
+
transferState: (0, import_mysql_core33.mysqlEnum)("transferState", [
|
|
10033
10247
|
"AVAILABLE",
|
|
10034
10248
|
"INITIATED",
|
|
10035
10249
|
"VERIFIED",
|
|
@@ -10038,38 +10252,38 @@ function getPurchaseUserTransferSchema(mysqlTable) {
|
|
|
10038
10252
|
"CONFIRMED",
|
|
10039
10253
|
"COMPLETED"
|
|
10040
10254
|
]).default("AVAILABLE").notNull(),
|
|
10041
|
-
purchaseId: (0,
|
|
10255
|
+
purchaseId: (0, import_mysql_core33.varchar)("purchaseId", {
|
|
10042
10256
|
length: 191
|
|
10043
10257
|
}).notNull(),
|
|
10044
|
-
sourceUserId: (0,
|
|
10258
|
+
sourceUserId: (0, import_mysql_core33.varchar)("sourceUserId", {
|
|
10045
10259
|
length: 191
|
|
10046
10260
|
}).notNull(),
|
|
10047
|
-
targetUserId: (0,
|
|
10261
|
+
targetUserId: (0, import_mysql_core33.varchar)("targetUserId", {
|
|
10048
10262
|
length: 191
|
|
10049
10263
|
}),
|
|
10050
|
-
createdAt: (0,
|
|
10264
|
+
createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
|
|
10051
10265
|
mode: "date",
|
|
10052
10266
|
fsp: 3
|
|
10053
|
-
}).default(
|
|
10054
|
-
expiresAt: (0,
|
|
10267
|
+
}).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
10268
|
+
expiresAt: (0, import_mysql_core33.timestamp)("expiresAt", {
|
|
10055
10269
|
mode: "date",
|
|
10056
10270
|
fsp: 3
|
|
10057
10271
|
}),
|
|
10058
|
-
canceledAt: (0,
|
|
10272
|
+
canceledAt: (0, import_mysql_core33.timestamp)("canceledAt", {
|
|
10059
10273
|
mode: "date",
|
|
10060
10274
|
fsp: 3
|
|
10061
10275
|
}),
|
|
10062
|
-
confirmedAt: (0,
|
|
10276
|
+
confirmedAt: (0, import_mysql_core33.timestamp)("confirmedAt", {
|
|
10063
10277
|
mode: "date",
|
|
10064
10278
|
fsp: 3
|
|
10065
10279
|
}),
|
|
10066
|
-
completedAt: (0,
|
|
10280
|
+
completedAt: (0, import_mysql_core33.timestamp)("completedAt", {
|
|
10067
10281
|
mode: "date",
|
|
10068
10282
|
fsp: 3
|
|
10069
10283
|
})
|
|
10070
10284
|
}, (table) => {
|
|
10071
10285
|
return {
|
|
10072
|
-
purchaseUserTransferId: (0,
|
|
10286
|
+
purchaseUserTransferId: (0, import_mysql_core33.primaryKey)({
|
|
10073
10287
|
columns: [
|
|
10074
10288
|
table.id
|
|
10075
10289
|
],
|
|
@@ -10083,7 +10297,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10083
10297
|
const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
|
|
10084
10298
|
const user = getUsersSchema(mysqlTable);
|
|
10085
10299
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
10086
|
-
return (0,
|
|
10300
|
+
return (0, import_drizzle_orm28.relations)(purchaseUserTransfer, ({ one }) => ({
|
|
10087
10301
|
sourceUser: one(user, {
|
|
10088
10302
|
fields: [
|
|
10089
10303
|
purchaseUserTransfer.sourceUserId
|
|
@@ -10116,46 +10330,46 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10116
10330
|
__name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
|
|
10117
10331
|
|
|
10118
10332
|
// src/lib/mysql/schemas/commerce/upgradable-products.ts
|
|
10119
|
-
var
|
|
10120
|
-
var
|
|
10333
|
+
var import_drizzle_orm29 = require("drizzle-orm");
|
|
10334
|
+
var import_mysql_core34 = require("drizzle-orm/mysql-core");
|
|
10121
10335
|
function getUpgradableProductsSchema(mysqlTable) {
|
|
10122
|
-
return mysqlTable("
|
|
10123
|
-
upgradableToId: (0,
|
|
10336
|
+
return mysqlTable("UpgradableProducts", {
|
|
10337
|
+
upgradableToId: (0, import_mysql_core34.varchar)("upgradableToId", {
|
|
10124
10338
|
length: 255
|
|
10125
10339
|
}).notNull(),
|
|
10126
|
-
upgradableFromId: (0,
|
|
10340
|
+
upgradableFromId: (0, import_mysql_core34.varchar)("upgradableFrom", {
|
|
10127
10341
|
length: 255
|
|
10128
10342
|
}).notNull(),
|
|
10129
|
-
position: (0,
|
|
10130
|
-
metadata: (0,
|
|
10131
|
-
createdAt: (0,
|
|
10343
|
+
position: (0, import_mysql_core34.double)("position").notNull().default(0),
|
|
10344
|
+
metadata: (0, import_mysql_core34.json)("metadata").$type().default({}),
|
|
10345
|
+
createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
|
|
10132
10346
|
mode: "date",
|
|
10133
10347
|
fsp: 3
|
|
10134
|
-
}).default(
|
|
10135
|
-
updatedAt: (0,
|
|
10348
|
+
}).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
|
|
10349
|
+
updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
|
|
10136
10350
|
mode: "date",
|
|
10137
10351
|
fsp: 3
|
|
10138
|
-
}).default(
|
|
10139
|
-
deletedAt: (0,
|
|
10352
|
+
}).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
|
|
10353
|
+
deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
|
|
10140
10354
|
mode: "date",
|
|
10141
10355
|
fsp: 3
|
|
10142
10356
|
})
|
|
10143
10357
|
}, (crr) => ({
|
|
10144
|
-
pk: (0,
|
|
10358
|
+
pk: (0, import_mysql_core34.primaryKey)({
|
|
10145
10359
|
columns: [
|
|
10146
10360
|
crr.upgradableToId,
|
|
10147
10361
|
crr.upgradableFromId
|
|
10148
10362
|
]
|
|
10149
10363
|
}),
|
|
10150
|
-
upgradableToIdIdx: (0,
|
|
10151
|
-
upgradableFromIdIdx: (0,
|
|
10364
|
+
upgradableToIdIdx: (0, import_mysql_core34.index)("upgradableFromId_idx").on(crr.upgradableToId),
|
|
10365
|
+
upgradableFromIdIdx: (0, import_mysql_core34.index)("upgradableToId_idx").on(crr.upgradableFromId)
|
|
10152
10366
|
}));
|
|
10153
10367
|
}
|
|
10154
10368
|
__name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
|
|
10155
10369
|
function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
10156
10370
|
const product = getProductSchema(mysqlTable);
|
|
10157
10371
|
const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
|
|
10158
|
-
return (0,
|
|
10372
|
+
return (0, import_drizzle_orm29.relations)(upgradableProduct, ({ one }) => ({
|
|
10159
10373
|
upgradableTo: one(product, {
|
|
10160
10374
|
fields: [
|
|
10161
10375
|
upgradableProduct.upgradableToId
|
|
@@ -10178,41 +10392,89 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
|
10178
10392
|
}
|
|
10179
10393
|
__name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
|
|
10180
10394
|
|
|
10181
|
-
// src/lib/mysql/schemas/content/
|
|
10182
|
-
var
|
|
10183
|
-
var
|
|
10184
|
-
function
|
|
10185
|
-
return mysqlTable("
|
|
10186
|
-
|
|
10395
|
+
// src/lib/mysql/schemas/content/lesson-progress.ts
|
|
10396
|
+
var import_drizzle_orm30 = require("drizzle-orm");
|
|
10397
|
+
var import_mysql_core35 = require("drizzle-orm/mysql-core");
|
|
10398
|
+
function getLessonProgressSchema(mysqlTable) {
|
|
10399
|
+
return mysqlTable("LessonProgress", {
|
|
10400
|
+
id: (0, import_mysql_core35.varchar)("id", {
|
|
10401
|
+
length: 191
|
|
10402
|
+
}).notNull().primaryKey(),
|
|
10403
|
+
userId: (0, import_mysql_core35.varchar)("userId", {
|
|
10187
10404
|
length: 191
|
|
10188
10405
|
}).notNull(),
|
|
10189
|
-
|
|
10406
|
+
lessonId: (0, import_mysql_core35.varchar)("lessonId", {
|
|
10407
|
+
length: 191
|
|
10408
|
+
}),
|
|
10409
|
+
lessonSlug: (0, import_mysql_core35.varchar)("lessonSlug", {
|
|
10410
|
+
length: 191
|
|
10411
|
+
}),
|
|
10412
|
+
lessonVersion: (0, import_mysql_core35.varchar)("lessonVersion", {
|
|
10413
|
+
length: 191
|
|
10414
|
+
}),
|
|
10415
|
+
sectionId: (0, import_mysql_core35.varchar)("sectionId", {
|
|
10416
|
+
length: 191
|
|
10417
|
+
}),
|
|
10418
|
+
moduleId: (0, import_mysql_core35.varchar)("moduleId", {
|
|
10190
10419
|
length: 191
|
|
10191
10420
|
}),
|
|
10192
|
-
|
|
10193
|
-
|
|
10421
|
+
completedAt: (0, import_mysql_core35.datetime)("completedAt", {
|
|
10422
|
+
mode: "date",
|
|
10423
|
+
fsp: 3
|
|
10424
|
+
}),
|
|
10425
|
+
updatedAt: (0, import_mysql_core35.datetime)("updatedAt", {
|
|
10194
10426
|
mode: "date",
|
|
10195
10427
|
fsp: 3
|
|
10196
10428
|
}),
|
|
10197
|
-
|
|
10429
|
+
createdAt: (0, import_mysql_core35.datetime)("createdAt", {
|
|
10430
|
+
mode: "date",
|
|
10431
|
+
fsp: 3
|
|
10432
|
+
}).default(import_drizzle_orm30.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10433
|
+
}, (crp) => {
|
|
10434
|
+
return {
|
|
10435
|
+
userIdLessonIdIdx: (0, import_mysql_core35.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
|
|
10436
|
+
userIdIdx: (0, import_mysql_core35.index)("userId_idx").on(crp.userId),
|
|
10437
|
+
lessonIdIdx: (0, import_mysql_core35.index)("lessonId_idx").on(crp.lessonId)
|
|
10438
|
+
};
|
|
10439
|
+
});
|
|
10440
|
+
}
|
|
10441
|
+
__name(getLessonProgressSchema, "getLessonProgressSchema");
|
|
10442
|
+
|
|
10443
|
+
// src/lib/mysql/schemas/content/resource-progress.ts
|
|
10444
|
+
var import_drizzle_orm31 = require("drizzle-orm");
|
|
10445
|
+
var import_mysql_core36 = require("drizzle-orm/mysql-core");
|
|
10446
|
+
function getResourceProgressSchema(mysqlTable) {
|
|
10447
|
+
return mysqlTable("ResourceProgress", {
|
|
10448
|
+
userId: (0, import_mysql_core36.varchar)("userId", {
|
|
10449
|
+
length: 255
|
|
10450
|
+
}).notNull(),
|
|
10451
|
+
resourceId: (0, import_mysql_core36.varchar)("resourceId", {
|
|
10452
|
+
length: 255
|
|
10453
|
+
}),
|
|
10454
|
+
fields: (0, import_mysql_core36.json)("fields").$type().default({}),
|
|
10455
|
+
completedAt: (0, import_mysql_core36.datetime)("completedAt", {
|
|
10456
|
+
mode: "date",
|
|
10457
|
+
fsp: 3
|
|
10458
|
+
}),
|
|
10459
|
+
updatedAt: (0, import_mysql_core36.datetime)("updatedAt", {
|
|
10198
10460
|
mode: "date",
|
|
10199
10461
|
fsp: 3
|
|
10200
10462
|
}),
|
|
10201
|
-
createdAt: (0,
|
|
10463
|
+
createdAt: (0, import_mysql_core36.datetime)("createdAt", {
|
|
10202
10464
|
mode: "date",
|
|
10203
10465
|
fsp: 3
|
|
10204
|
-
}).default(
|
|
10466
|
+
}).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10205
10467
|
}, (crp) => {
|
|
10206
10468
|
return {
|
|
10207
|
-
userIdLessonIdIdx: (0,
|
|
10208
|
-
pk: (0,
|
|
10469
|
+
userIdLessonIdIdx: (0, import_mysql_core36.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
|
|
10470
|
+
pk: (0, import_mysql_core36.primaryKey)({
|
|
10209
10471
|
columns: [
|
|
10210
10472
|
crp.userId,
|
|
10211
|
-
crp.
|
|
10473
|
+
crp.resourceId
|
|
10212
10474
|
]
|
|
10213
10475
|
}),
|
|
10214
|
-
contentResourceIdIdx: (0,
|
|
10215
|
-
userIdIdx: (0,
|
|
10476
|
+
contentResourceIdIdx: (0, import_mysql_core36.index)("contentResourceId_idx").on(crp.resourceId),
|
|
10477
|
+
userIdIdx: (0, import_mysql_core36.index)("resourceId_idx").on(crp.userId)
|
|
10216
10478
|
};
|
|
10217
10479
|
});
|
|
10218
10480
|
}
|
|
@@ -10240,6 +10502,7 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10240
10502
|
verificationTokens: getVerificationTokensSchema(mysqlTable),
|
|
10241
10503
|
coupon: getCouponSchema(mysqlTable),
|
|
10242
10504
|
couponRelations: getCouponRelationsSchema(mysqlTable),
|
|
10505
|
+
lessonProgress: getLessonProgressSchema(mysqlTable),
|
|
10243
10506
|
merchantAccount: getMerchantAccountSchema(mysqlTable),
|
|
10244
10507
|
merchantCharge: getMerchantChargeSchema(mysqlTable),
|
|
10245
10508
|
merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
|
|
@@ -10271,7 +10534,15 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10271
10534
|
upgradableProductsRelations: getUpgradableProductsRelationsSchema(mysqlTable),
|
|
10272
10535
|
contentResourceProduct: getContentResourceProductSchema(mysqlTable),
|
|
10273
10536
|
contentResourceProductRelations: getContentResourceProductRelationsSchema(mysqlTable),
|
|
10274
|
-
productRelations: getProductRelationsSchema(mysqlTable)
|
|
10537
|
+
productRelations: getProductRelationsSchema(mysqlTable),
|
|
10538
|
+
comments: getCommentsSchema(mysqlTable),
|
|
10539
|
+
commentsRelations: getCommentRelationsSchema(mysqlTable),
|
|
10540
|
+
deviceVerifications: getDeviceVerificationSchema(mysqlTable),
|
|
10541
|
+
deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable),
|
|
10542
|
+
deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
|
|
10543
|
+
deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable),
|
|
10544
|
+
userPrefs: getUserPrefsSchema(mysqlTable),
|
|
10545
|
+
userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable)
|
|
10275
10546
|
};
|
|
10276
10547
|
}
|
|
10277
10548
|
__name(getCourseBuilderSchema, "getCourseBuilderSchema");
|
|
@@ -10279,8 +10550,8 @@ function createTables(mySqlTable) {
|
|
|
10279
10550
|
return getCourseBuilderSchema(mySqlTable);
|
|
10280
10551
|
}
|
|
10281
10552
|
__name(createTables, "createTables");
|
|
10282
|
-
function mySqlDrizzleAdapter(client, tableFn =
|
|
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);
|
|
10553
|
+
function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
10554
|
+
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments } = createTables(tableFn);
|
|
10284
10555
|
const adapter = {
|
|
10285
10556
|
client,
|
|
10286
10557
|
async redeemFullPriceCoupon(options) {
|
|
@@ -10341,12 +10612,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10341
10612
|
},
|
|
10342
10613
|
incrementCouponUsedCount: async (couponId) => {
|
|
10343
10614
|
await client.update(coupon).set({
|
|
10344
|
-
usedCount:
|
|
10345
|
-
}).where((0,
|
|
10615
|
+
usedCount: import_drizzle_orm32.sql`${coupon.usedCount} + 1`
|
|
10616
|
+
}).where((0, import_drizzle_orm32.eq)(coupon.id, couponId));
|
|
10346
10617
|
},
|
|
10347
10618
|
getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
|
|
10348
10619
|
const existingPurchases = await client.query.purchases.findMany({
|
|
10349
|
-
where: (0,
|
|
10620
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm32.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm32.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm32.isNull)(purchaseTable.bulkCouponId))
|
|
10350
10621
|
});
|
|
10351
10622
|
return z.array(purchaseSchema).parse(existingPurchases);
|
|
10352
10623
|
},
|
|
@@ -10359,17 +10630,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10359
10630
|
status: 1
|
|
10360
10631
|
});
|
|
10361
10632
|
return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
10362
|
-
where: (0,
|
|
10633
|
+
where: (0, import_drizzle_orm32.eq)(merchantCustomer.identifier, options.identifier)
|
|
10363
10634
|
}));
|
|
10364
10635
|
},
|
|
10365
10636
|
getMerchantAccount: async (options) => {
|
|
10366
10637
|
return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
|
|
10367
|
-
where: (0,
|
|
10638
|
+
where: (0, import_drizzle_orm32.eq)(merchantAccount.label, options.provider)
|
|
10368
10639
|
}));
|
|
10369
10640
|
},
|
|
10370
10641
|
getMerchantPriceForProductId: async (productId) => {
|
|
10371
10642
|
const merchantPriceData = await client.query.merchantPrice.findFirst({
|
|
10372
|
-
where: (0,
|
|
10643
|
+
where: (0, import_drizzle_orm32.eq)(merchantPrice.merchantProductId, productId)
|
|
10373
10644
|
});
|
|
10374
10645
|
const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
|
|
10375
10646
|
if (!parsedMerchantPrice.success) {
|
|
@@ -10380,7 +10651,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10380
10651
|
},
|
|
10381
10652
|
getMerchantProductForProductId: async (productId) => {
|
|
10382
10653
|
const merchantProductData = await client.query.merchantProduct.findFirst({
|
|
10383
|
-
where: (0,
|
|
10654
|
+
where: (0, import_drizzle_orm32.eq)(merchantProduct.productId, productId)
|
|
10384
10655
|
});
|
|
10385
10656
|
if (!merchantProductData)
|
|
10386
10657
|
return null;
|
|
@@ -10388,7 +10659,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10388
10659
|
},
|
|
10389
10660
|
getMerchantCustomerForUserId: async (userId) => {
|
|
10390
10661
|
const merchantCustomerData = await client.query.merchantCustomer.findFirst({
|
|
10391
|
-
where: (0,
|
|
10662
|
+
where: (0, import_drizzle_orm32.eq)(merchantCustomer.userId, userId)
|
|
10392
10663
|
});
|
|
10393
10664
|
if (!merchantCustomerData)
|
|
10394
10665
|
return null;
|
|
@@ -10397,14 +10668,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10397
10668
|
getUpgradableProducts: async (options) => {
|
|
10398
10669
|
const { upgradableFromId, upgradableToId } = options;
|
|
10399
10670
|
return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
10400
|
-
where: (0,
|
|
10671
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, upgradableToId))
|
|
10401
10672
|
}));
|
|
10402
10673
|
},
|
|
10403
10674
|
async availableUpgradesForProduct(purchases, productId) {
|
|
10404
10675
|
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
10405
10676
|
if (previousPurchaseProductIds.length > 0) {
|
|
10406
10677
|
return await client.query.upgradableProducts.findMany({
|
|
10407
|
-
where: (0,
|
|
10678
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm32.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
|
|
10408
10679
|
});
|
|
10409
10680
|
}
|
|
10410
10681
|
return [];
|
|
@@ -10417,7 +10688,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10417
10688
|
throw new Error("No lessonId provided");
|
|
10418
10689
|
}
|
|
10419
10690
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10420
|
-
where: (0,
|
|
10691
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
|
|
10421
10692
|
});
|
|
10422
10693
|
const now = /* @__PURE__ */ new Date();
|
|
10423
10694
|
if (lessonProgress) {
|
|
@@ -10425,18 +10696,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10425
10696
|
await client.update(resourceProgress).set({
|
|
10426
10697
|
completedAt: now,
|
|
10427
10698
|
updatedAt: now
|
|
10428
|
-
}).where((0,
|
|
10699
|
+
}).where((0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId));
|
|
10429
10700
|
}
|
|
10430
10701
|
} else {
|
|
10431
10702
|
await client.insert(resourceProgress).values({
|
|
10432
10703
|
userId: options.userId,
|
|
10433
|
-
|
|
10704
|
+
resourceId: options.lessonId,
|
|
10434
10705
|
completedAt: now,
|
|
10435
10706
|
updatedAt: now
|
|
10436
10707
|
});
|
|
10437
10708
|
}
|
|
10438
10709
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10439
|
-
where: (0,
|
|
10710
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
|
|
10440
10711
|
});
|
|
10441
10712
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
10442
10713
|
if (!parsedLessonProgress.success) {
|
|
@@ -10449,26 +10720,31 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10449
10720
|
if (!options.couponId && !options.code)
|
|
10450
10721
|
return null;
|
|
10451
10722
|
const couponForIdOrCode = await client.query.coupon.findFirst({
|
|
10452
|
-
where: (0,
|
|
10723
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.or)(options.code ? (0, import_drizzle_orm32.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm32.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm32.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.or)(options.code ? (0, import_drizzle_orm32.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm32.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm32.isNull)(coupon.expires))),
|
|
10453
10724
|
with: {
|
|
10454
10725
|
merchantCoupon: true
|
|
10455
10726
|
}
|
|
10456
10727
|
});
|
|
10457
10728
|
if (!couponForIdOrCode)
|
|
10458
10729
|
return null;
|
|
10459
|
-
|
|
10730
|
+
const parsedCoupon = couponSchema.extend({
|
|
10460
10731
|
merchantCoupon: merchantCouponSchema
|
|
10461
|
-
}).
|
|
10732
|
+
}).safeParse(couponForIdOrCode);
|
|
10733
|
+
if (!parsedCoupon.success) {
|
|
10734
|
+
console.error("Error parsing coupon", JSON.stringify(parsedCoupon.error));
|
|
10735
|
+
return null;
|
|
10736
|
+
}
|
|
10737
|
+
return parsedCoupon.data;
|
|
10462
10738
|
},
|
|
10463
10739
|
async createMerchantChargeAndPurchase(options) {
|
|
10464
10740
|
const purchaseId = await client.transaction(async (trx) => {
|
|
10465
10741
|
try {
|
|
10466
10742
|
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
|
|
10467
10743
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10468
|
-
where: (0,
|
|
10744
|
+
where: (0, import_drizzle_orm32.eq)(merchantCharge.identifier, stripeChargeId)
|
|
10469
10745
|
}) || null);
|
|
10470
10746
|
const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
|
|
10471
|
-
where: (0,
|
|
10747
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
|
|
10472
10748
|
with: {
|
|
10473
10749
|
user: true,
|
|
10474
10750
|
product: true,
|
|
@@ -10489,13 +10765,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10489
10765
|
merchantCustomerId
|
|
10490
10766
|
});
|
|
10491
10767
|
const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
|
|
10492
|
-
where: (0,
|
|
10768
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, [
|
|
10493
10769
|
"Valid",
|
|
10494
10770
|
"Restricted"
|
|
10495
10771
|
]))
|
|
10496
10772
|
}) || null);
|
|
10497
|
-
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0,
|
|
10498
|
-
return res[0]?.
|
|
10773
|
+
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId))).then((res) => {
|
|
10774
|
+
return res[0]?.Coupon ?? null;
|
|
10499
10775
|
}));
|
|
10500
10776
|
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
|
|
10501
10777
|
let bulkCouponId = null;
|
|
@@ -10505,10 +10781,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10505
10781
|
if (existingBulkCoupon !== null) {
|
|
10506
10782
|
couponToUpdate = await client.update(coupon).set({
|
|
10507
10783
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
|
|
10508
|
-
}).where((0,
|
|
10784
|
+
}).where((0, import_drizzle_orm32.eq)(coupon.id, bulkCouponId));
|
|
10509
10785
|
} else {
|
|
10510
10786
|
const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
10511
|
-
where: (0,
|
|
10787
|
+
where: (0, import_drizzle_orm32.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10512
10788
|
})) : null;
|
|
10513
10789
|
couponToUpdate = await client.insert(coupon).values({
|
|
10514
10790
|
id: bulkCouponId,
|
|
@@ -10529,10 +10805,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10529
10805
|
merchantAccountId
|
|
10530
10806
|
});
|
|
10531
10807
|
const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10532
|
-
where: (0,
|
|
10808
|
+
where: (0, import_drizzle_orm32.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10533
10809
|
}) : null;
|
|
10534
10810
|
const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10535
|
-
where: (0,
|
|
10811
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm32.eq)(merchantCoupon.type, "ppp"))
|
|
10536
10812
|
}) : null;
|
|
10537
10813
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
10538
10814
|
const newPurchase = await client.insert(purchaseTable).values({
|
|
@@ -10563,7 +10839,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10563
10839
|
}
|
|
10564
10840
|
});
|
|
10565
10841
|
const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
10566
|
-
where: (0,
|
|
10842
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId)
|
|
10567
10843
|
}));
|
|
10568
10844
|
if (!parsedPurchase.success) {
|
|
10569
10845
|
console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
|
|
@@ -10607,7 +10883,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10607
10883
|
};
|
|
10608
10884
|
},
|
|
10609
10885
|
async getCoupon(couponIdOrCode) {
|
|
10610
|
-
|
|
10886
|
+
const loadedCoupon = await client.query.coupon.findFirst({
|
|
10887
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm32.eq)(coupon.code, couponIdOrCode))
|
|
10888
|
+
}) || null;
|
|
10889
|
+
logger.debug("loadedCoupon", {
|
|
10890
|
+
loadedCoupon
|
|
10891
|
+
});
|
|
10892
|
+
return couponSchema.nullable().parse(loadedCoupon);
|
|
10611
10893
|
},
|
|
10612
10894
|
async getCouponWithBulkPurchases(couponId) {
|
|
10613
10895
|
logger.debug("getCouponWithBulkPurchases", {
|
|
@@ -10616,7 +10898,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10616
10898
|
let couponData;
|
|
10617
10899
|
try {
|
|
10618
10900
|
couponData = await client.query.coupon.findFirst({
|
|
10619
|
-
where: (0,
|
|
10901
|
+
where: (0, import_drizzle_orm32.eq)(coupon.id, couponId),
|
|
10620
10902
|
with: {
|
|
10621
10903
|
bulkPurchase: true,
|
|
10622
10904
|
bulkCouponPurchases: true
|
|
@@ -10645,8 +10927,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10645
10927
|
},
|
|
10646
10928
|
async getDefaultCoupon(productIds) {
|
|
10647
10929
|
const activeSaleCoupon = await client.query.coupon.findFirst({
|
|
10648
|
-
where: (0,
|
|
10649
|
-
orderBy: (0,
|
|
10930
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(coupon.status, 1), (0, import_drizzle_orm32.eq)(coupon.default, true), (0, import_drizzle_orm32.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm32.or)(productIds ? (0, import_drizzle_orm32.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm32.isNull)(coupon.restrictedToProductId))),
|
|
10931
|
+
orderBy: (0, import_drizzle_orm32.desc)(coupon.percentageDiscount),
|
|
10650
10932
|
with: {
|
|
10651
10933
|
merchantCoupon: true,
|
|
10652
10934
|
product: true
|
|
@@ -10670,7 +10952,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10670
10952
|
},
|
|
10671
10953
|
async getLessonProgressForUser(userId) {
|
|
10672
10954
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
10673
|
-
where: (0,
|
|
10955
|
+
where: (0, import_drizzle_orm32.eq)(resourceProgress.userId, userId)
|
|
10674
10956
|
});
|
|
10675
10957
|
const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
10676
10958
|
if (!parsed.success) {
|
|
@@ -10680,22 +10962,67 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10680
10962
|
return parsed.data;
|
|
10681
10963
|
},
|
|
10682
10964
|
async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
|
|
10965
|
+
const ALLOWED_MODULE_RESOURCE_TYPES = [
|
|
10966
|
+
"lesson",
|
|
10967
|
+
"exercise",
|
|
10968
|
+
"solution"
|
|
10969
|
+
];
|
|
10970
|
+
const COUNTABLE_MODULE_RESOURCE_TYPES = [
|
|
10971
|
+
"lesson",
|
|
10972
|
+
"exercise"
|
|
10973
|
+
];
|
|
10683
10974
|
const module2 = await client.query.contentResource.findFirst({
|
|
10684
|
-
where: (0,
|
|
10975
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(contentResource.id, moduleIdOrSlug), (0, import_drizzle_orm32.eq)(import_drizzle_orm32.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, moduleIdOrSlug)),
|
|
10685
10976
|
with: {
|
|
10686
10977
|
resources: {
|
|
10687
|
-
|
|
10978
|
+
with: {
|
|
10979
|
+
resource: {
|
|
10980
|
+
with: {
|
|
10981
|
+
resources: {
|
|
10982
|
+
with: {
|
|
10983
|
+
resource: {
|
|
10984
|
+
with: {
|
|
10985
|
+
resources: {
|
|
10986
|
+
with: {
|
|
10987
|
+
resource: true
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
}
|
|
10991
|
+
}
|
|
10992
|
+
},
|
|
10993
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
10994
|
+
}
|
|
10995
|
+
}
|
|
10996
|
+
}
|
|
10997
|
+
},
|
|
10998
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
10688
10999
|
}
|
|
10689
11000
|
}
|
|
10690
11001
|
});
|
|
10691
11002
|
const parsedModule = ContentResourceSchema.parse(module2);
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
11003
|
+
function flattenResources(resources) {
|
|
11004
|
+
const result = [];
|
|
11005
|
+
function recurse(resources2) {
|
|
11006
|
+
for (const nestedResource of resources2) {
|
|
11007
|
+
const resource = nestedResource.resource;
|
|
11008
|
+
result.push(resource);
|
|
11009
|
+
if (resource.resources) {
|
|
11010
|
+
recurse(resource.resources);
|
|
11011
|
+
}
|
|
11012
|
+
}
|
|
11013
|
+
}
|
|
11014
|
+
__name(recurse, "recurse");
|
|
11015
|
+
recurse(resources);
|
|
11016
|
+
return result;
|
|
11017
|
+
}
|
|
11018
|
+
__name(flattenResources, "flattenResources");
|
|
11019
|
+
const allResources = parsedModule?.resources && flattenResources(parsedModule.resources);
|
|
11020
|
+
const filteredResources = allResources?.filter((resource) => {
|
|
11021
|
+
return ALLOWED_MODULE_RESOURCE_TYPES.includes(resource.type);
|
|
10695
11022
|
});
|
|
10696
|
-
const
|
|
10697
|
-
if (!
|
|
10698
|
-
console.error("Error parsing module resources",
|
|
11023
|
+
const parsedResources = z.array(ContentResourceSchema).safeParse(filteredResources);
|
|
11024
|
+
if (!parsedResources.success) {
|
|
11025
|
+
console.error("Error parsing module resources", parsedResources.error);
|
|
10699
11026
|
return {
|
|
10700
11027
|
completedLessons: [],
|
|
10701
11028
|
nextResource: null,
|
|
@@ -10704,10 +11031,25 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10704
11031
|
totalLessonsCount: 0
|
|
10705
11032
|
};
|
|
10706
11033
|
}
|
|
11034
|
+
const progressResources = parsedResources.data.filter((r) => {
|
|
11035
|
+
return COUNTABLE_MODULE_RESOURCE_TYPES.includes(r.type);
|
|
11036
|
+
});
|
|
11037
|
+
const totalLessonsCount = progressResources.length;
|
|
10707
11038
|
const user = await client.query.users.findFirst({
|
|
10708
|
-
where: (0,
|
|
11039
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm32.eq)(users.email, userIdOrEmail)),
|
|
10709
11040
|
with: {
|
|
10710
|
-
roles:
|
|
11041
|
+
roles: {
|
|
11042
|
+
with: {
|
|
11043
|
+
role: true
|
|
11044
|
+
}
|
|
11045
|
+
}
|
|
11046
|
+
}
|
|
11047
|
+
}).then(async (res) => {
|
|
11048
|
+
if (res) {
|
|
11049
|
+
return {
|
|
11050
|
+
...res,
|
|
11051
|
+
roles: res.roles.map((r) => r.role)
|
|
11052
|
+
};
|
|
10711
11053
|
}
|
|
10712
11054
|
});
|
|
10713
11055
|
if (!user) {
|
|
@@ -10717,17 +11059,29 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10717
11059
|
nextResource: null,
|
|
10718
11060
|
percentCompleted: 0,
|
|
10719
11061
|
completedLessonsCount: 0,
|
|
10720
|
-
totalLessonsCount
|
|
11062
|
+
totalLessonsCount
|
|
11063
|
+
};
|
|
11064
|
+
}
|
|
11065
|
+
const parsedUser = userSchema.safeParse(user);
|
|
11066
|
+
if (!parsedUser.success) {
|
|
11067
|
+
console.error("Error parsing user", parsedUser.error);
|
|
11068
|
+
return {
|
|
11069
|
+
completedLessons: [],
|
|
11070
|
+
nextResource: null,
|
|
11071
|
+
percentCompleted: 0,
|
|
11072
|
+
completedLessonsCount: 0,
|
|
11073
|
+
totalLessonsCount
|
|
10721
11074
|
};
|
|
10722
11075
|
}
|
|
10723
|
-
const parsedUser = userSchema.parse(user);
|
|
10724
11076
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
10725
|
-
where: (0,
|
|
10726
|
-
orderBy: (0,
|
|
11077
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, parsedUser.data.id), (0, import_drizzle_orm32.isNotNull)(resourceProgress.completedAt), (0, import_drizzle_orm32.inArray)(resourceProgress.resourceId, progressResources.map((r) => r.id))),
|
|
11078
|
+
orderBy: (0, import_drizzle_orm32.asc)(resourceProgress.completedAt)
|
|
10727
11079
|
});
|
|
10728
|
-
const nextResourceId =
|
|
11080
|
+
const nextResourceId = parsedResources.data.filter((r) => {
|
|
11081
|
+
return COUNTABLE_MODULE_RESOURCE_TYPES.includes(r.type);
|
|
11082
|
+
}).find((r) => !userProgress.find((p) => p.resourceId === r.id))?.id;
|
|
10729
11083
|
const nextResource = await client.query.contentResource.findFirst({
|
|
10730
|
-
where: (0,
|
|
11084
|
+
where: (0, import_drizzle_orm32.eq)(contentResource.id, nextResourceId)
|
|
10731
11085
|
});
|
|
10732
11086
|
const parsedNextResource = ContentResourceSchema.nullable().optional().default(null).parse(nextResource);
|
|
10733
11087
|
const parsedProgress = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
@@ -10738,16 +11092,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10738
11092
|
nextResource: null,
|
|
10739
11093
|
percentCompleted: 0,
|
|
10740
11094
|
completedLessonsCount: 0,
|
|
10741
|
-
totalLessonsCount
|
|
11095
|
+
totalLessonsCount
|
|
10742
11096
|
};
|
|
10743
11097
|
}
|
|
10744
|
-
const percentCompleted = Math.round(parsedProgress.data.length /
|
|
11098
|
+
const percentCompleted = Math.round(parsedProgress.data.length / parsedResources.data.length * 100);
|
|
10745
11099
|
return {
|
|
10746
11100
|
completedLessons: parsedProgress.data,
|
|
10747
11101
|
nextResource: parsedNextResource,
|
|
10748
11102
|
percentCompleted,
|
|
10749
11103
|
completedLessonsCount: parsedProgress.data.length,
|
|
10750
|
-
totalLessonsCount
|
|
11104
|
+
totalLessonsCount
|
|
10751
11105
|
};
|
|
10752
11106
|
},
|
|
10753
11107
|
getLessonProgresses() {
|
|
@@ -10755,7 +11109,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10755
11109
|
},
|
|
10756
11110
|
async getMerchantCharge(merchantChargeId) {
|
|
10757
11111
|
const mCharge = await client.query.merchantCharge.findFirst({
|
|
10758
|
-
where: (0,
|
|
11112
|
+
where: (0, import_drizzle_orm32.eq)(merchantCharge.id, merchantChargeId)
|
|
10759
11113
|
});
|
|
10760
11114
|
const parsed = merchantChargeSchema.safeParse(mCharge);
|
|
10761
11115
|
if (!parsed.success) {
|
|
@@ -10766,12 +11120,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10766
11120
|
},
|
|
10767
11121
|
async getMerchantCouponsForTypeAndPercent(params) {
|
|
10768
11122
|
return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
|
|
10769
|
-
where: (0,
|
|
11123
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm32.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
10770
11124
|
}));
|
|
10771
11125
|
},
|
|
10772
11126
|
async getMerchantCouponForTypeAndPercent(params) {
|
|
10773
11127
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
10774
|
-
where: (0,
|
|
11128
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm32.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
10775
11129
|
});
|
|
10776
11130
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
10777
11131
|
if (parsed.success) {
|
|
@@ -10781,7 +11135,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10781
11135
|
},
|
|
10782
11136
|
async getMerchantCoupon(merchantCouponId) {
|
|
10783
11137
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
10784
|
-
where: (0,
|
|
11138
|
+
where: (0, import_drizzle_orm32.eq)(merchantCoupon.id, merchantCouponId)
|
|
10785
11139
|
});
|
|
10786
11140
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
10787
11141
|
if (parsed.success) {
|
|
@@ -10791,7 +11145,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10791
11145
|
},
|
|
10792
11146
|
async getMerchantProduct(stripeProductId) {
|
|
10793
11147
|
return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
|
|
10794
|
-
where: (0,
|
|
11148
|
+
where: (0, import_drizzle_orm32.eq)(merchantProduct.identifier, stripeProductId)
|
|
10795
11149
|
}));
|
|
10796
11150
|
},
|
|
10797
11151
|
getPrice(productId) {
|
|
@@ -10799,17 +11153,25 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10799
11153
|
},
|
|
10800
11154
|
async getPriceForProduct(productId) {
|
|
10801
11155
|
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
10802
|
-
where: (0,
|
|
11156
|
+
where: (0, import_drizzle_orm32.eq)(prices.productId, productId)
|
|
10803
11157
|
}));
|
|
10804
11158
|
},
|
|
10805
11159
|
async getProduct(productId) {
|
|
10806
11160
|
return productSchema.nullable().parse(await client.query.products.findFirst({
|
|
10807
|
-
where: (0,
|
|
11161
|
+
where: (0, import_drizzle_orm32.eq)(products.id, productId)
|
|
10808
11162
|
}));
|
|
10809
11163
|
},
|
|
11164
|
+
async getPurchaseCountForProduct(productId) {
|
|
11165
|
+
return await client.query.purchases.findMany({
|
|
11166
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, [
|
|
11167
|
+
"Valid",
|
|
11168
|
+
"Restricted"
|
|
11169
|
+
]))
|
|
11170
|
+
}).then((res) => res.length);
|
|
11171
|
+
},
|
|
10810
11172
|
async getPurchase(purchaseId) {
|
|
10811
11173
|
const purchase = await client.query.purchases.findFirst({
|
|
10812
|
-
where: (0,
|
|
11174
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId)
|
|
10813
11175
|
});
|
|
10814
11176
|
return purchase ? purchaseSchema.parse(purchase) : null;
|
|
10815
11177
|
},
|
|
@@ -10827,14 +11189,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10827
11189
|
stripeChargeId
|
|
10828
11190
|
});
|
|
10829
11191
|
const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10830
|
-
where: (0,
|
|
11192
|
+
where: (0, import_drizzle_orm32.eq)(merchantCharge.identifier, stripeChargeId)
|
|
10831
11193
|
}) || null);
|
|
10832
11194
|
if (!chargeForPurchase) {
|
|
10833
11195
|
logger.error(new Error("No charge found for purchase"));
|
|
10834
11196
|
return null;
|
|
10835
11197
|
}
|
|
10836
11198
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
10837
|
-
where: (0,
|
|
11199
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
|
|
10838
11200
|
with: {
|
|
10839
11201
|
user: true,
|
|
10840
11202
|
product: true,
|
|
@@ -10848,7 +11210,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10848
11210
|
},
|
|
10849
11211
|
async getPurchaseUserTransferById(options) {
|
|
10850
11212
|
const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
10851
|
-
where: (0,
|
|
11213
|
+
where: (0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id),
|
|
10852
11214
|
with: {
|
|
10853
11215
|
sourceUser: true,
|
|
10854
11216
|
targetUser: true,
|
|
@@ -10863,7 +11225,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10863
11225
|
},
|
|
10864
11226
|
async getPurchaseWithUser(purchaseId) {
|
|
10865
11227
|
const purchaseData = await client.query.purchases.findFirst({
|
|
10866
|
-
where: (0,
|
|
11228
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId),
|
|
10867
11229
|
with: {
|
|
10868
11230
|
user: true
|
|
10869
11231
|
}
|
|
@@ -10887,13 +11249,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10887
11249
|
"Restricted"
|
|
10888
11250
|
];
|
|
10889
11251
|
const userPurchases = await client.query.purchases.findMany({
|
|
10890
|
-
where: (0,
|
|
11252
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
10891
11253
|
with: {
|
|
10892
11254
|
user: true,
|
|
10893
11255
|
product: true,
|
|
10894
11256
|
bulkCoupon: true
|
|
10895
11257
|
},
|
|
10896
|
-
orderBy: (0,
|
|
11258
|
+
orderBy: (0, import_drizzle_orm32.asc)(purchaseTable.createdAt)
|
|
10897
11259
|
});
|
|
10898
11260
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
10899
11261
|
if (!parsedPurchases.success) {
|
|
@@ -10909,18 +11271,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10909
11271
|
"Restricted"
|
|
10910
11272
|
];
|
|
10911
11273
|
const userPurchases = await client.query.purchases.findMany({
|
|
10912
|
-
where: (0,
|
|
11274
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
10913
11275
|
with: {
|
|
10914
11276
|
user: true,
|
|
10915
11277
|
product: true,
|
|
10916
11278
|
bulkCoupon: true
|
|
10917
11279
|
},
|
|
10918
|
-
orderBy: (0,
|
|
11280
|
+
orderBy: (0, import_drizzle_orm32.asc)(purchaseTable.createdAt)
|
|
10919
11281
|
});
|
|
10920
11282
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
10921
11283
|
const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
|
|
10922
11284
|
const thePurchase = await client.query.purchases.findFirst({
|
|
10923
|
-
where: (0,
|
|
11285
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm32.eq)(purchaseTable.userId, userId)),
|
|
10924
11286
|
with: {
|
|
10925
11287
|
user: true,
|
|
10926
11288
|
product: true,
|
|
@@ -10941,7 +11303,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10941
11303
|
let availableUpgrades = [];
|
|
10942
11304
|
if (purchaseCanUpgrade) {
|
|
10943
11305
|
availableUpgrades = await client.query.upgradableProducts.findMany({
|
|
10944
|
-
where: (0,
|
|
11306
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm32.not)((0, import_drizzle_orm32.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
|
|
10945
11307
|
with: {
|
|
10946
11308
|
upgradableTo: true,
|
|
10947
11309
|
upgradableFrom: true
|
|
@@ -10949,10 +11311,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10949
11311
|
});
|
|
10950
11312
|
}
|
|
10951
11313
|
const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
|
|
10952
|
-
where: (0,
|
|
11314
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm32.inArray)(purchaseTable.status, [
|
|
10953
11315
|
"Valid",
|
|
10954
11316
|
"Restricted"
|
|
10955
|
-
]), (0,
|
|
11317
|
+
]), (0, import_drizzle_orm32.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm32.not)((0, import_drizzle_orm32.eq)(purchaseTable.id, parsedPurchase.data.id))),
|
|
10956
11318
|
with: {
|
|
10957
11319
|
user: true,
|
|
10958
11320
|
product: true,
|
|
@@ -10967,7 +11329,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10967
11329
|
},
|
|
10968
11330
|
async getUserById(userId) {
|
|
10969
11331
|
const user = await client.query.users.findFirst({
|
|
10970
|
-
where: (0,
|
|
11332
|
+
where: (0, import_drizzle_orm32.eq)(users.id, userId),
|
|
10971
11333
|
with: {
|
|
10972
11334
|
roles: {
|
|
10973
11335
|
with: {
|
|
@@ -10989,13 +11351,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10989
11351
|
if (userId === void 0)
|
|
10990
11352
|
return [];
|
|
10991
11353
|
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
10992
|
-
where: (0,
|
|
11354
|
+
where: (0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, bundleId)
|
|
10993
11355
|
});
|
|
10994
11356
|
const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
|
|
10995
11357
|
return product.upgradableFromId;
|
|
10996
11358
|
}));
|
|
10997
11359
|
const purchases = await client.query.purchases.findMany({
|
|
10998
|
-
where: (0,
|
|
11360
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm32.inArray)(purchaseTable.productId, upgradableFrom))
|
|
10999
11361
|
});
|
|
11000
11362
|
const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
|
|
11001
11363
|
return purchase.productId;
|
|
@@ -11003,7 +11365,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11003
11365
|
if (productsPurchased.length === 0)
|
|
11004
11366
|
return [];
|
|
11005
11367
|
const foundPrices = await client.query.prices.findMany({
|
|
11006
|
-
where: (0,
|
|
11368
|
+
where: (0, import_drizzle_orm32.inArray)(prices.productId, productsPurchased)
|
|
11007
11369
|
});
|
|
11008
11370
|
return z.array(priceSchema).parse(foundPrices);
|
|
11009
11371
|
},
|
|
@@ -11012,24 +11374,24 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11012
11374
|
throw new Error("No lessonId provided");
|
|
11013
11375
|
}
|
|
11014
11376
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11015
|
-
where: (0,
|
|
11377
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
|
|
11016
11378
|
});
|
|
11017
11379
|
const now = /* @__PURE__ */ new Date();
|
|
11018
11380
|
if (lessonProgress) {
|
|
11019
11381
|
await client.update(resourceProgress).set({
|
|
11020
11382
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
11021
11383
|
updatedAt: now
|
|
11022
|
-
}).where((0,
|
|
11384
|
+
}).where((0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId));
|
|
11023
11385
|
} else {
|
|
11024
11386
|
await client.insert(resourceProgress).values({
|
|
11025
11387
|
userId: options.userId,
|
|
11026
|
-
|
|
11388
|
+
resourceId: options.lessonId,
|
|
11027
11389
|
completedAt: now,
|
|
11028
11390
|
updatedAt: now
|
|
11029
11391
|
});
|
|
11030
11392
|
}
|
|
11031
11393
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11032
|
-
where: (0,
|
|
11394
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId))
|
|
11033
11395
|
});
|
|
11034
11396
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
11035
11397
|
if (!parsedLessonProgress.success) {
|
|
@@ -11047,16 +11409,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11047
11409
|
async updatePurchaseUserTransferTransferState(options) {
|
|
11048
11410
|
await client.update(purchaseUserTransfer).set({
|
|
11049
11411
|
transferState: options.transferState
|
|
11050
|
-
}).where((0,
|
|
11412
|
+
}).where((0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id));
|
|
11051
11413
|
const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
11052
|
-
where: (0,
|
|
11414
|
+
where: (0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id)
|
|
11053
11415
|
}) || null;
|
|
11054
11416
|
return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
|
|
11055
11417
|
},
|
|
11056
11418
|
addResourceToResource: async function(options) {
|
|
11057
11419
|
const { parentResourceId, childResourceId } = options;
|
|
11058
11420
|
const parentResourceData = await client.query.contentResource.findFirst({
|
|
11059
|
-
where: (0,
|
|
11421
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(import_drizzle_orm32.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm32.eq)(contentResource.id, parentResourceId)),
|
|
11060
11422
|
with: {
|
|
11061
11423
|
resources: true
|
|
11062
11424
|
}
|
|
@@ -11068,7 +11430,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11068
11430
|
position: parentResource.resources?.length || 0
|
|
11069
11431
|
});
|
|
11070
11432
|
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
11071
|
-
where: (0,
|
|
11433
|
+
where: (0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm32.eq)(contentResourceResource.resourceId, childResourceId)),
|
|
11072
11434
|
with: {
|
|
11073
11435
|
resource: true
|
|
11074
11436
|
}
|
|
@@ -11083,15 +11445,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11083
11445
|
if (!options.id) {
|
|
11084
11446
|
throw new Error("No content resource id.");
|
|
11085
11447
|
}
|
|
11086
|
-
const currentResource = await client.select().from(contentResource).where((0,
|
|
11448
|
+
const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm32.eq)(contentResource.id, options.id)).then((res) => res[0]);
|
|
11087
11449
|
await client.update(contentResource).set({
|
|
11088
11450
|
fields: {
|
|
11089
11451
|
...currentResource.fields,
|
|
11090
11452
|
...options.fields
|
|
11091
11453
|
}
|
|
11092
|
-
}).where((0,
|
|
11454
|
+
}).where((0, import_drizzle_orm32.eq)(contentResource.id, options.id));
|
|
11093
11455
|
const resource = await client.query.contentResource.findFirst({
|
|
11094
|
-
where: (0,
|
|
11456
|
+
where: (0, import_drizzle_orm32.eq)(contentResource.id, options.id),
|
|
11095
11457
|
with: {
|
|
11096
11458
|
resources: {
|
|
11097
11459
|
with: {
|
|
@@ -11101,12 +11463,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11101
11463
|
with: {
|
|
11102
11464
|
resource: true
|
|
11103
11465
|
},
|
|
11104
|
-
orderBy: (0,
|
|
11466
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11105
11467
|
}
|
|
11106
11468
|
}
|
|
11107
11469
|
}
|
|
11108
11470
|
},
|
|
11109
|
-
orderBy: (0,
|
|
11471
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11110
11472
|
}
|
|
11111
11473
|
}
|
|
11112
11474
|
});
|
|
@@ -11121,7 +11483,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11121
11483
|
if (!id) {
|
|
11122
11484
|
return null;
|
|
11123
11485
|
}
|
|
11124
|
-
const query =
|
|
11486
|
+
const query = import_drizzle_orm32.sql`
|
|
11125
11487
|
SELECT
|
|
11126
11488
|
id as id,
|
|
11127
11489
|
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
@@ -11153,7 +11515,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11153
11515
|
id
|
|
11154
11516
|
});
|
|
11155
11517
|
const resource = await client.query.contentResource.findFirst({
|
|
11156
|
-
where: (0,
|
|
11518
|
+
where: (0, import_drizzle_orm32.eq)(contentResource.id, id),
|
|
11157
11519
|
with: {
|
|
11158
11520
|
resources: {
|
|
11159
11521
|
with: {
|
|
@@ -11163,12 +11525,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11163
11525
|
with: {
|
|
11164
11526
|
resource: true
|
|
11165
11527
|
},
|
|
11166
|
-
orderBy: (0,
|
|
11528
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11167
11529
|
}
|
|
11168
11530
|
}
|
|
11169
11531
|
}
|
|
11170
11532
|
},
|
|
11171
|
-
orderBy: (0,
|
|
11533
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11172
11534
|
}
|
|
11173
11535
|
}
|
|
11174
11536
|
});
|
|
@@ -11181,7 +11543,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11181
11543
|
},
|
|
11182
11544
|
async getContentResource(data) {
|
|
11183
11545
|
const resource = await client.query.contentResource.findFirst({
|
|
11184
|
-
where: (0,
|
|
11546
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(contentResource.id, data), (0, import_drizzle_orm32.eq)(import_drizzle_orm32.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
|
|
11185
11547
|
with: {
|
|
11186
11548
|
resources: {
|
|
11187
11549
|
with: {
|
|
@@ -11189,14 +11551,22 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11189
11551
|
with: {
|
|
11190
11552
|
resources: {
|
|
11191
11553
|
with: {
|
|
11192
|
-
resource:
|
|
11554
|
+
resource: {
|
|
11555
|
+
with: {
|
|
11556
|
+
resources: {
|
|
11557
|
+
with: {
|
|
11558
|
+
resource: true
|
|
11559
|
+
}
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11193
11563
|
},
|
|
11194
|
-
orderBy: (0,
|
|
11564
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11195
11565
|
}
|
|
11196
11566
|
}
|
|
11197
11567
|
}
|
|
11198
11568
|
},
|
|
11199
|
-
orderBy: (0,
|
|
11569
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11200
11570
|
}
|
|
11201
11571
|
}
|
|
11202
11572
|
});
|
|
@@ -11214,61 +11584,61 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11214
11584
|
...data,
|
|
11215
11585
|
id
|
|
11216
11586
|
});
|
|
11217
|
-
return await client.select().from(users).where((0,
|
|
11587
|
+
return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, id)).then((res) => res[0]);
|
|
11218
11588
|
} catch (error) {
|
|
11219
11589
|
console.error(error);
|
|
11220
11590
|
throw error;
|
|
11221
11591
|
}
|
|
11222
11592
|
},
|
|
11223
11593
|
async getUser(data) {
|
|
11224
|
-
return await client.select().from(users).where((0,
|
|
11594
|
+
return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, data)).then((res) => res[0]) ?? null;
|
|
11225
11595
|
},
|
|
11226
11596
|
async getUserByEmail(data) {
|
|
11227
|
-
return await client.select().from(users).where((0,
|
|
11597
|
+
return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.email, data)).then((res) => res[0]) ?? null;
|
|
11228
11598
|
},
|
|
11229
11599
|
async createSession(data) {
|
|
11230
11600
|
await client.insert(sessions).values(data);
|
|
11231
|
-
return await client.select().from(sessions).where((0,
|
|
11601
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
11232
11602
|
},
|
|
11233
11603
|
async getSessionAndUser(data) {
|
|
11234
11604
|
return await client.select({
|
|
11235
11605
|
session: sessions,
|
|
11236
11606
|
user: users
|
|
11237
|
-
}).from(sessions).where((0,
|
|
11607
|
+
}).from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm32.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
|
|
11238
11608
|
},
|
|
11239
11609
|
async updateUser(data) {
|
|
11240
11610
|
if (!data.id) {
|
|
11241
11611
|
throw new Error("No user id.");
|
|
11242
11612
|
}
|
|
11243
|
-
await client.update(users).set(data).where((0,
|
|
11244
|
-
return await client.select().from(users).where((0,
|
|
11613
|
+
await client.update(users).set(data).where((0, import_drizzle_orm32.eq)(users.id, data.id));
|
|
11614
|
+
return await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, data.id)).then((res) => res[0]);
|
|
11245
11615
|
},
|
|
11246
11616
|
async updateSession(data) {
|
|
11247
|
-
await client.update(sessions).set(data).where((0,
|
|
11248
|
-
return await client.select().from(sessions).where((0,
|
|
11617
|
+
await client.update(sessions).set(data).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data.sessionToken));
|
|
11618
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
11249
11619
|
},
|
|
11250
11620
|
async linkAccount(rawAccount) {
|
|
11251
11621
|
await client.insert(accounts).values(rawAccount);
|
|
11252
11622
|
},
|
|
11253
11623
|
async getUserByAccount(account) {
|
|
11254
|
-
const dbAccount = await client.select().from(accounts).where((0,
|
|
11624
|
+
const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm32.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm32.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
|
|
11255
11625
|
if (!dbAccount) {
|
|
11256
11626
|
return null;
|
|
11257
11627
|
}
|
|
11258
|
-
return dbAccount.
|
|
11628
|
+
return dbAccount.User;
|
|
11259
11629
|
},
|
|
11260
11630
|
async deleteSession(sessionToken) {
|
|
11261
|
-
const session = await client.select().from(sessions).where((0,
|
|
11262
|
-
await client.delete(sessions).where((0,
|
|
11631
|
+
const session = await client.select().from(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
|
|
11632
|
+
await client.delete(sessions).where((0, import_drizzle_orm32.eq)(sessions.sessionToken, sessionToken));
|
|
11263
11633
|
return session;
|
|
11264
11634
|
},
|
|
11265
11635
|
async createVerificationToken(token) {
|
|
11266
11636
|
await client.insert(verificationTokens).values(token);
|
|
11267
|
-
return await client.select().from(verificationTokens).where((0,
|
|
11637
|
+
return await client.select().from(verificationTokens).where((0, import_drizzle_orm32.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
|
|
11268
11638
|
},
|
|
11269
11639
|
async useVerificationToken(token) {
|
|
11270
11640
|
try {
|
|
11271
|
-
const deletedToken = await client.select().from(verificationTokens).where((0,
|
|
11641
|
+
const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm32.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
|
|
11272
11642
|
if (deletedToken?.createdAt) {
|
|
11273
11643
|
const TIMEOUT_IN_SECONDS = 90;
|
|
11274
11644
|
const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
@@ -11277,7 +11647,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11277
11647
|
const { id: _, ...verificationToken } = token;
|
|
11278
11648
|
return deletedToken;
|
|
11279
11649
|
} else {
|
|
11280
|
-
await client.delete(verificationTokens).where((0,
|
|
11650
|
+
await client.delete(verificationTokens).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm32.eq)(verificationTokens.token, token.token)));
|
|
11281
11651
|
return deletedToken;
|
|
11282
11652
|
}
|
|
11283
11653
|
}
|
|
@@ -11287,14 +11657,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11287
11657
|
}
|
|
11288
11658
|
},
|
|
11289
11659
|
async deleteUser(id) {
|
|
11290
|
-
const user = await client.select().from(users).where((0,
|
|
11291
|
-
await client.delete(users).where((0,
|
|
11292
|
-
await client.delete(sessions).where((0,
|
|
11293
|
-
await client.delete(accounts).where((0,
|
|
11660
|
+
const user = await client.select().from(users).where((0, import_drizzle_orm32.eq)(users.id, id)).then((res) => res[0] ?? null);
|
|
11661
|
+
await client.delete(users).where((0, import_drizzle_orm32.eq)(users.id, id));
|
|
11662
|
+
await client.delete(sessions).where((0, import_drizzle_orm32.eq)(sessions.userId, id));
|
|
11663
|
+
await client.delete(accounts).where((0, import_drizzle_orm32.eq)(accounts.userId, id));
|
|
11294
11664
|
return user;
|
|
11295
11665
|
},
|
|
11296
11666
|
async unlinkAccount(account) {
|
|
11297
|
-
await client.delete(accounts).where((0,
|
|
11667
|
+
await client.delete(accounts).where((0, import_drizzle_orm32.and)((0, import_drizzle_orm32.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm32.eq)(accounts.provider, account.provider)));
|
|
11298
11668
|
return void 0;
|
|
11299
11669
|
}
|
|
11300
11670
|
};
|