@coursebuilder/adapter-drizzle 0.4.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-ULEUIL2Y.js → chunk-BM5UKWXI.js} +3 -3
- package/dist/{chunk-IDINCRHK.js → chunk-CQNKTFXE.js} +3 -3
- package/dist/{chunk-N7UDJAI3.js → chunk-FRA4ZCRA.js} +462 -337
- 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-XJHSXR42.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-DL3UMWB4.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-A26D3TCA.js → chunk-Z245DYMP.js} +159 -62
- package/dist/index.js +22 -19
- package/dist/lib/mysql/index.cjs +992 -650
- 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 -66
- 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 -129
- 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 +142 -39
- 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 +1 -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
|
};
|
|
@@ -8231,10 +8231,10 @@ var purchaseUserTransferSchema = z2.object({
|
|
|
8231
8231
|
completedAt: z2.date().nullable()
|
|
8232
8232
|
});
|
|
8233
8233
|
|
|
8234
|
-
// ../core/dist/chunk-
|
|
8234
|
+
// ../core/dist/chunk-K6G2HAJT.js
|
|
8235
8235
|
var resourceProgressSchema = z2.object({
|
|
8236
8236
|
userId: z2.string().max(191),
|
|
8237
|
-
|
|
8237
|
+
resourceId: z2.string().max(191).optional().nullable(),
|
|
8238
8238
|
fields: z2.record(z2.any()).default({}),
|
|
8239
8239
|
completedAt: z2.date().nullable(),
|
|
8240
8240
|
updatedAt: z2.date().nullable(),
|
|
@@ -8259,7 +8259,7 @@ var upgradableProductSchema = z2.object({
|
|
|
8259
8259
|
deletedAt: z2.date().nullable()
|
|
8260
8260
|
});
|
|
8261
8261
|
|
|
8262
|
-
// ../core/dist/chunk-
|
|
8262
|
+
// ../core/dist/chunk-5QZXOTEH.js
|
|
8263
8263
|
var VideoResourceSchema = z2.object({
|
|
8264
8264
|
id: z2.string(),
|
|
8265
8265
|
updatedAt: z2.string().optional(),
|
|
@@ -8277,7 +8277,8 @@ var VideoResourceSchema = z2.object({
|
|
|
8277
8277
|
"processing",
|
|
8278
8278
|
"preparing",
|
|
8279
8279
|
"ready",
|
|
8280
|
-
"errored"
|
|
8280
|
+
"errored",
|
|
8281
|
+
"deleted"
|
|
8281
8282
|
])
|
|
8282
8283
|
});
|
|
8283
8284
|
|
|
@@ -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,50 +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
|
-
couponIdCodeIndex: (0,
|
|
8943
|
-
couponId: (0,
|
|
9063
|
+
couponIdCodeIndex: (0, import_mysql_core11.index)("Coupon_id_code_index").on(table.id, table.code),
|
|
9064
|
+
couponId: (0, import_mysql_core11.primaryKey)({
|
|
8944
9065
|
columns: [
|
|
8945
9066
|
table.id
|
|
8946
9067
|
],
|
|
8947
9068
|
name: "Coupon_id"
|
|
8948
9069
|
}),
|
|
8949
|
-
couponBulkPurchaseIdKey: (0,
|
|
8950
|
-
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)
|
|
8951
9072
|
};
|
|
8952
9073
|
});
|
|
8953
9074
|
}
|
|
@@ -8956,7 +9077,7 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
8956
9077
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
8957
9078
|
const coupon = getCouponSchema(mysqlTable);
|
|
8958
9079
|
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
8959
|
-
return (0,
|
|
9080
|
+
return (0, import_drizzle_orm10.relations)(coupon, ({ many, one }) => ({
|
|
8960
9081
|
bulkCouponPurchases: many(purchase, {
|
|
8961
9082
|
relationName: "redeemedBulkCoupon"
|
|
8962
9083
|
}),
|
|
@@ -8992,31 +9113,31 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
8992
9113
|
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
8993
9114
|
|
|
8994
9115
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
8995
|
-
var
|
|
8996
|
-
var
|
|
9116
|
+
var import_drizzle_orm13 = require("drizzle-orm");
|
|
9117
|
+
var import_mysql_core14 = require("drizzle-orm/mysql-core");
|
|
8997
9118
|
|
|
8998
9119
|
// src/lib/mysql/schemas/commerce/merchant-account.ts
|
|
8999
|
-
var
|
|
9000
|
-
var
|
|
9120
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
9121
|
+
var import_mysql_core12 = require("drizzle-orm/mysql-core");
|
|
9001
9122
|
function getMerchantAccountSchema(mysqlTable) {
|
|
9002
|
-
return mysqlTable("
|
|
9003
|
-
id: (0,
|
|
9123
|
+
return mysqlTable("MerchantAccount", {
|
|
9124
|
+
id: (0, import_mysql_core12.varchar)("id", {
|
|
9004
9125
|
length: 191
|
|
9005
9126
|
}).notNull(),
|
|
9006
|
-
status: (0,
|
|
9007
|
-
createdAt: (0,
|
|
9127
|
+
status: (0, import_mysql_core12.int)("status").default(0).notNull(),
|
|
9128
|
+
createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
|
|
9008
9129
|
mode: "date",
|
|
9009
9130
|
fsp: 3
|
|
9010
|
-
}).default(
|
|
9011
|
-
label: (0,
|
|
9131
|
+
}).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9132
|
+
label: (0, import_mysql_core12.varchar)("label", {
|
|
9012
9133
|
length: 191
|
|
9013
9134
|
}),
|
|
9014
|
-
identifier: (0,
|
|
9135
|
+
identifier: (0, import_mysql_core12.varchar)("identifier", {
|
|
9015
9136
|
length: 191
|
|
9016
9137
|
})
|
|
9017
9138
|
}, (table) => {
|
|
9018
9139
|
return {
|
|
9019
|
-
merchantAccountId: (0,
|
|
9140
|
+
merchantAccountId: (0, import_mysql_core12.primaryKey)({
|
|
9020
9141
|
columns: [
|
|
9021
9142
|
table.id
|
|
9022
9143
|
],
|
|
@@ -9028,36 +9149,37 @@ function getMerchantAccountSchema(mysqlTable) {
|
|
|
9028
9149
|
__name(getMerchantAccountSchema, "getMerchantAccountSchema");
|
|
9029
9150
|
|
|
9030
9151
|
// src/lib/mysql/schemas/commerce/merchant-customer.ts
|
|
9031
|
-
var
|
|
9032
|
-
var
|
|
9152
|
+
var import_drizzle_orm12 = require("drizzle-orm");
|
|
9153
|
+
var import_mysql_core13 = require("drizzle-orm/mysql-core");
|
|
9033
9154
|
function getMerchantCustomerSchema(mysqlTable) {
|
|
9034
|
-
return mysqlTable("
|
|
9035
|
-
id: (0,
|
|
9155
|
+
return mysqlTable("MerchantCustomer", {
|
|
9156
|
+
id: (0, import_mysql_core13.varchar)("id", {
|
|
9036
9157
|
length: 191
|
|
9037
9158
|
}).notNull(),
|
|
9038
|
-
userId: (0,
|
|
9159
|
+
userId: (0, import_mysql_core13.varchar)("userId", {
|
|
9039
9160
|
length: 191
|
|
9040
9161
|
}).notNull(),
|
|
9041
|
-
merchantAccountId: (0,
|
|
9162
|
+
merchantAccountId: (0, import_mysql_core13.varchar)("merchantAccountId", {
|
|
9042
9163
|
length: 191
|
|
9043
9164
|
}).notNull(),
|
|
9044
|
-
identifier: (0,
|
|
9165
|
+
identifier: (0, import_mysql_core13.varchar)("identifier", {
|
|
9045
9166
|
length: 191
|
|
9046
9167
|
}).notNull(),
|
|
9047
|
-
createdAt: (0,
|
|
9168
|
+
createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
|
|
9048
9169
|
mode: "date",
|
|
9049
9170
|
fsp: 3
|
|
9050
|
-
}).default(
|
|
9051
|
-
status: (0,
|
|
9171
|
+
}).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9172
|
+
status: (0, import_mysql_core13.int)("status").default(0)
|
|
9052
9173
|
}, (table) => {
|
|
9053
9174
|
return {
|
|
9054
|
-
merchantCustomerId: (0,
|
|
9175
|
+
merchantCustomerId: (0, import_mysql_core13.primaryKey)({
|
|
9055
9176
|
columns: [
|
|
9056
9177
|
table.id
|
|
9057
9178
|
],
|
|
9058
9179
|
name: "MerchantCustomer_id"
|
|
9059
9180
|
}),
|
|
9060
|
-
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)
|
|
9061
9183
|
};
|
|
9062
9184
|
});
|
|
9063
9185
|
}
|
|
@@ -9065,39 +9187,39 @@ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
|
|
|
9065
9187
|
|
|
9066
9188
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
9067
9189
|
function getMerchantChargeSchema(mysqlTable) {
|
|
9068
|
-
return mysqlTable("
|
|
9069
|
-
id: (0,
|
|
9190
|
+
return mysqlTable("MerchantCharge", {
|
|
9191
|
+
id: (0, import_mysql_core14.varchar)("id", {
|
|
9070
9192
|
length: 191
|
|
9071
9193
|
}).notNull(),
|
|
9072
|
-
status: (0,
|
|
9073
|
-
identifier: (0,
|
|
9194
|
+
status: (0, import_mysql_core14.int)("status").default(0).notNull(),
|
|
9195
|
+
identifier: (0, import_mysql_core14.varchar)("identifier", {
|
|
9074
9196
|
length: 191
|
|
9075
9197
|
}).notNull(),
|
|
9076
|
-
userId: (0,
|
|
9198
|
+
userId: (0, import_mysql_core14.varchar)("userId", {
|
|
9077
9199
|
length: 191
|
|
9078
9200
|
}).notNull(),
|
|
9079
|
-
merchantAccountId: (0,
|
|
9201
|
+
merchantAccountId: (0, import_mysql_core14.varchar)("merchantAccountId", {
|
|
9080
9202
|
length: 191
|
|
9081
9203
|
}).notNull(),
|
|
9082
|
-
merchantProductId: (0,
|
|
9204
|
+
merchantProductId: (0, import_mysql_core14.varchar)("merchantProductId", {
|
|
9083
9205
|
length: 191
|
|
9084
9206
|
}).notNull(),
|
|
9085
|
-
createdAt: (0,
|
|
9207
|
+
createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
|
|
9086
9208
|
mode: "date",
|
|
9087
9209
|
fsp: 3
|
|
9088
|
-
}).default(
|
|
9089
|
-
merchantCustomerId: (0,
|
|
9210
|
+
}).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9211
|
+
merchantCustomerId: (0, import_mysql_core14.varchar)("merchantCustomerId", {
|
|
9090
9212
|
length: 191
|
|
9091
9213
|
}).notNull()
|
|
9092
9214
|
}, (table) => {
|
|
9093
9215
|
return {
|
|
9094
|
-
merchantChargeId: (0,
|
|
9216
|
+
merchantChargeId: (0, import_mysql_core14.primaryKey)({
|
|
9095
9217
|
columns: [
|
|
9096
9218
|
table.id
|
|
9097
9219
|
],
|
|
9098
9220
|
name: "MerchantCharge_id"
|
|
9099
9221
|
}),
|
|
9100
|
-
merchantChargeIdentifierKey: (0,
|
|
9222
|
+
merchantChargeIdentifierKey: (0, import_mysql_core14.unique)("MerchantCharge_identifier_key").on(table.identifier)
|
|
9101
9223
|
};
|
|
9102
9224
|
});
|
|
9103
9225
|
}
|
|
@@ -9107,7 +9229,7 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9107
9229
|
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
9108
9230
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
9109
9231
|
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
9110
|
-
return (0,
|
|
9232
|
+
return (0, import_drizzle_orm13.relations)(merchantCharge, ({ one }) => ({
|
|
9111
9233
|
merchantAccount: one(merchantAccount, {
|
|
9112
9234
|
fields: [
|
|
9113
9235
|
merchantCharge.merchantAccountId
|
|
@@ -9140,21 +9262,21 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9140
9262
|
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
9141
9263
|
|
|
9142
9264
|
// src/lib/mysql/schemas/commerce/merchant-session.ts
|
|
9143
|
-
var
|
|
9265
|
+
var import_mysql_core15 = require("drizzle-orm/mysql-core");
|
|
9144
9266
|
function getMerchantSessionSchema(mysqlTable) {
|
|
9145
|
-
return mysqlTable("
|
|
9146
|
-
id: (0,
|
|
9267
|
+
return mysqlTable("MerchantSession", {
|
|
9268
|
+
id: (0, import_mysql_core15.varchar)("id", {
|
|
9147
9269
|
length: 191
|
|
9148
9270
|
}).notNull(),
|
|
9149
|
-
identifier: (0,
|
|
9271
|
+
identifier: (0, import_mysql_core15.varchar)("identifier", {
|
|
9150
9272
|
length: 191
|
|
9151
9273
|
}).notNull(),
|
|
9152
|
-
merchantAccountId: (0,
|
|
9274
|
+
merchantAccountId: (0, import_mysql_core15.varchar)("merchantAccountId", {
|
|
9153
9275
|
length: 191
|
|
9154
9276
|
}).notNull()
|
|
9155
9277
|
}, (table) => {
|
|
9156
9278
|
return {
|
|
9157
|
-
merchantSessionId: (0,
|
|
9279
|
+
merchantSessionId: (0, import_mysql_core15.primaryKey)({
|
|
9158
9280
|
columns: [
|
|
9159
9281
|
table.id
|
|
9160
9282
|
],
|
|
@@ -9167,67 +9289,68 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
|
|
|
9167
9289
|
|
|
9168
9290
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
9169
9291
|
function getPurchaseSchema(mysqlTable) {
|
|
9170
|
-
return mysqlTable("
|
|
9171
|
-
id: (0,
|
|
9292
|
+
return mysqlTable("Purchase", {
|
|
9293
|
+
id: (0, import_mysql_core16.varchar)("id", {
|
|
9172
9294
|
length: 191
|
|
9173
9295
|
}).notNull(),
|
|
9174
|
-
userId: (0,
|
|
9296
|
+
userId: (0, import_mysql_core16.varchar)("userId", {
|
|
9175
9297
|
length: 191
|
|
9176
9298
|
}),
|
|
9177
|
-
createdAt: (0,
|
|
9299
|
+
createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
|
|
9178
9300
|
mode: "date",
|
|
9179
9301
|
fsp: 3
|
|
9180
|
-
}).default(
|
|
9181
|
-
totalAmount: (0,
|
|
9302
|
+
}).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9303
|
+
totalAmount: (0, import_mysql_core16.decimal)("totalAmount", {
|
|
9182
9304
|
precision: 65,
|
|
9183
9305
|
scale: 30
|
|
9184
9306
|
}).notNull(),
|
|
9185
|
-
ipAddress: (0,
|
|
9307
|
+
ipAddress: (0, import_mysql_core16.varchar)("ip_address", {
|
|
9186
9308
|
length: 191
|
|
9187
9309
|
}),
|
|
9188
|
-
city: (0,
|
|
9310
|
+
city: (0, import_mysql_core16.varchar)("city", {
|
|
9189
9311
|
length: 191
|
|
9190
9312
|
}),
|
|
9191
|
-
state: (0,
|
|
9313
|
+
state: (0, import_mysql_core16.varchar)("state", {
|
|
9192
9314
|
length: 191
|
|
9193
9315
|
}),
|
|
9194
|
-
country: (0,
|
|
9316
|
+
country: (0, import_mysql_core16.varchar)("country", {
|
|
9195
9317
|
length: 191
|
|
9196
9318
|
}),
|
|
9197
|
-
couponId: (0,
|
|
9319
|
+
couponId: (0, import_mysql_core16.varchar)("couponId", {
|
|
9198
9320
|
length: 191
|
|
9199
9321
|
}),
|
|
9200
|
-
productId: (0,
|
|
9322
|
+
productId: (0, import_mysql_core16.varchar)("productId", {
|
|
9201
9323
|
length: 191
|
|
9202
9324
|
}).notNull(),
|
|
9203
|
-
merchantChargeId: (0,
|
|
9325
|
+
merchantChargeId: (0, import_mysql_core16.varchar)("merchantChargeId", {
|
|
9204
9326
|
length: 191
|
|
9205
9327
|
}),
|
|
9206
|
-
upgradedFromId: (0,
|
|
9328
|
+
upgradedFromId: (0, import_mysql_core16.varchar)("upgradedFromId", {
|
|
9207
9329
|
length: 191
|
|
9208
9330
|
}),
|
|
9209
|
-
status: (0,
|
|
9331
|
+
status: (0, import_mysql_core16.varchar)("status", {
|
|
9210
9332
|
length: 191
|
|
9211
9333
|
}).default("Valid").notNull(),
|
|
9212
|
-
bulkCouponId: (0,
|
|
9334
|
+
bulkCouponId: (0, import_mysql_core16.varchar)("bulkCouponId", {
|
|
9213
9335
|
length: 191
|
|
9214
9336
|
}),
|
|
9215
|
-
merchantSessionId: (0,
|
|
9337
|
+
merchantSessionId: (0, import_mysql_core16.varchar)("merchantSessionId", {
|
|
9216
9338
|
length: 191
|
|
9217
9339
|
}),
|
|
9218
|
-
redeemedBulkCouponId: (0,
|
|
9340
|
+
redeemedBulkCouponId: (0, import_mysql_core16.varchar)("redeemedBulkCouponId", {
|
|
9219
9341
|
length: 191
|
|
9220
9342
|
}),
|
|
9221
|
-
fields: (0,
|
|
9343
|
+
fields: (0, import_mysql_core16.json)("fields").$type().default({})
|
|
9222
9344
|
}, (table) => {
|
|
9223
9345
|
return {
|
|
9224
|
-
purchaseId: (0,
|
|
9346
|
+
purchaseId: (0, import_mysql_core16.primaryKey)({
|
|
9225
9347
|
columns: [
|
|
9226
9348
|
table.id
|
|
9227
9349
|
],
|
|
9228
9350
|
name: "Purchase_id"
|
|
9229
9351
|
}),
|
|
9230
|
-
|
|
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)
|
|
9231
9354
|
};
|
|
9232
9355
|
});
|
|
9233
9356
|
}
|
|
@@ -9239,7 +9362,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9239
9362
|
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
9240
9363
|
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
9241
9364
|
const coupons = getCouponSchema(mysqlTable);
|
|
9242
|
-
return (0,
|
|
9365
|
+
return (0, import_drizzle_orm14.relations)(purchases, ({ many, one }) => ({
|
|
9243
9366
|
redeemedBulkCoupon: one(coupons, {
|
|
9244
9367
|
fields: [
|
|
9245
9368
|
purchases.redeemedBulkCouponId
|
|
@@ -9298,61 +9421,113 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9298
9421
|
}
|
|
9299
9422
|
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
9300
9423
|
|
|
9301
|
-
// src/lib/mysql/schemas/communication/
|
|
9302
|
-
var
|
|
9424
|
+
// src/lib/mysql/schemas/communication/comment.ts
|
|
9425
|
+
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9303
9426
|
var import_mysql_core17 = require("drizzle-orm/mysql-core");
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
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");
|
|
9479
|
+
|
|
9480
|
+
// src/lib/mysql/schemas/communication/communication-channel.ts
|
|
9481
|
+
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9307
9482
|
function getCommunicationChannelSchema(mysqlTable) {
|
|
9308
|
-
return mysqlTable("
|
|
9309
|
-
id: (0,
|
|
9483
|
+
return mysqlTable("CommunicationChannel", {
|
|
9484
|
+
id: (0, import_mysql_core18.varchar)("id", {
|
|
9310
9485
|
length: 255
|
|
9311
9486
|
}).notNull().primaryKey(),
|
|
9312
|
-
name: (0,
|
|
9487
|
+
name: (0, import_mysql_core18.varchar)("name", {
|
|
9313
9488
|
length: 255
|
|
9314
9489
|
}).notNull(),
|
|
9315
|
-
description: (0,
|
|
9316
|
-
active: (0,
|
|
9317
|
-
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", {
|
|
9318
9493
|
mode: "date",
|
|
9319
9494
|
fsp: 3
|
|
9320
9495
|
}).defaultNow(),
|
|
9321
|
-
updatedAt: (0,
|
|
9496
|
+
updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
|
|
9322
9497
|
mode: "date",
|
|
9323
9498
|
fsp: 3
|
|
9324
9499
|
}).defaultNow(),
|
|
9325
|
-
deletedAt: (0,
|
|
9500
|
+
deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
|
|
9326
9501
|
mode: "date",
|
|
9327
9502
|
fsp: 3
|
|
9328
9503
|
})
|
|
9329
9504
|
}, (cc) => ({
|
|
9330
|
-
nameIdx: (0,
|
|
9505
|
+
nameIdx: (0, import_mysql_core18.index)("name_idx").on(cc.name)
|
|
9331
9506
|
}));
|
|
9332
9507
|
}
|
|
9333
9508
|
__name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
|
|
9334
9509
|
|
|
9335
9510
|
// src/lib/mysql/schemas/communication/communication-preference-types.ts
|
|
9336
|
-
var
|
|
9511
|
+
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
9337
9512
|
function getCommunicationPreferenceTypesSchema(mysqlTable) {
|
|
9338
|
-
return mysqlTable("
|
|
9339
|
-
id: (0,
|
|
9513
|
+
return mysqlTable("CommunicationPreferenceType", {
|
|
9514
|
+
id: (0, import_mysql_core19.varchar)("id", {
|
|
9340
9515
|
length: 255
|
|
9341
9516
|
}).notNull().primaryKey(),
|
|
9342
|
-
name: (0,
|
|
9517
|
+
name: (0, import_mysql_core19.varchar)("name", {
|
|
9343
9518
|
length: 255
|
|
9344
9519
|
}).notNull(),
|
|
9345
|
-
description: (0,
|
|
9346
|
-
active: (0,
|
|
9347
|
-
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", {
|
|
9348
9523
|
mode: "date",
|
|
9349
9524
|
fsp: 3
|
|
9350
9525
|
}).defaultNow(),
|
|
9351
|
-
updatedAt: (0,
|
|
9526
|
+
updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
|
|
9352
9527
|
mode: "date",
|
|
9353
9528
|
fsp: 3
|
|
9354
9529
|
}),
|
|
9355
|
-
deletedAt: (0,
|
|
9530
|
+
deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
|
|
9356
9531
|
mode: "date",
|
|
9357
9532
|
fsp: 3
|
|
9358
9533
|
})
|
|
@@ -9362,49 +9537,49 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
|
|
|
9362
9537
|
|
|
9363
9538
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9364
9539
|
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
9365
|
-
return mysqlTable("
|
|
9366
|
-
id: (0,
|
|
9540
|
+
return mysqlTable("CommunicationPreference", {
|
|
9541
|
+
id: (0, import_mysql_core20.varchar)("id", {
|
|
9367
9542
|
length: 255
|
|
9368
9543
|
}).notNull().primaryKey(),
|
|
9369
|
-
userId: (0,
|
|
9544
|
+
userId: (0, import_mysql_core20.varchar)("userId", {
|
|
9370
9545
|
length: 255
|
|
9371
9546
|
}).notNull(),
|
|
9372
|
-
channelId: (0,
|
|
9547
|
+
channelId: (0, import_mysql_core20.varchar)("channelId", {
|
|
9373
9548
|
length: 255
|
|
9374
9549
|
}).notNull(),
|
|
9375
|
-
preferenceLevel: (0,
|
|
9550
|
+
preferenceLevel: (0, import_mysql_core20.mysqlEnum)("preferenceLevel", [
|
|
9376
9551
|
"low",
|
|
9377
9552
|
"medium",
|
|
9378
9553
|
"high"
|
|
9379
9554
|
]).notNull().default("medium"),
|
|
9380
|
-
preferenceTypeId: (0,
|
|
9555
|
+
preferenceTypeId: (0, import_mysql_core20.varchar)("preferenceTypeId", {
|
|
9381
9556
|
length: 255
|
|
9382
9557
|
}).notNull(),
|
|
9383
|
-
active: (0,
|
|
9384
|
-
createdAt: (0,
|
|
9558
|
+
active: (0, import_mysql_core20.boolean)("active").notNull().default(true),
|
|
9559
|
+
createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
|
|
9385
9560
|
mode: "date",
|
|
9386
9561
|
fsp: 3
|
|
9387
9562
|
}).defaultNow(),
|
|
9388
|
-
optInAt: (0,
|
|
9563
|
+
optInAt: (0, import_mysql_core20.timestamp)("optInAt", {
|
|
9389
9564
|
mode: "date",
|
|
9390
9565
|
fsp: 3
|
|
9391
9566
|
}),
|
|
9392
|
-
optOutAt: (0,
|
|
9567
|
+
optOutAt: (0, import_mysql_core20.timestamp)("optOutAt", {
|
|
9393
9568
|
mode: "date",
|
|
9394
9569
|
fsp: 3
|
|
9395
9570
|
}),
|
|
9396
|
-
updatedAt: (0,
|
|
9571
|
+
updatedAt: (0, import_mysql_core20.timestamp)("updatedAt", {
|
|
9397
9572
|
mode: "date",
|
|
9398
9573
|
fsp: 3
|
|
9399
9574
|
}).defaultNow(),
|
|
9400
|
-
deletedAt: (0,
|
|
9575
|
+
deletedAt: (0, import_mysql_core20.timestamp)("deletedAt", {
|
|
9401
9576
|
mode: "date",
|
|
9402
9577
|
fsp: 3
|
|
9403
9578
|
})
|
|
9404
9579
|
}, (cp) => ({
|
|
9405
|
-
userIdIdx: (0,
|
|
9406
|
-
preferenceTypeIdx: (0,
|
|
9407
|
-
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)
|
|
9408
9583
|
}));
|
|
9409
9584
|
}
|
|
9410
9585
|
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
@@ -9413,7 +9588,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9413
9588
|
const users = getUsersSchema(mysqlTable);
|
|
9414
9589
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
9415
9590
|
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
9416
|
-
return (0,
|
|
9591
|
+
return (0, import_drizzle_orm16.relations)(communicationPreferences, ({ one }) => ({
|
|
9417
9592
|
user: one(users, {
|
|
9418
9593
|
fields: [
|
|
9419
9594
|
communicationPreferences.userId
|
|
@@ -9445,192 +9620,76 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9445
9620
|
}
|
|
9446
9621
|
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
9447
9622
|
|
|
9448
|
-
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
9449
|
-
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9450
|
-
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
9451
|
-
|
|
9452
|
-
// src/lib/mysql/schemas/content/contribution-types.ts
|
|
9453
|
-
var import_drizzle_orm14 = require("drizzle-orm");
|
|
9454
|
-
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9455
|
-
function getContributionTypesSchema(mysqlTable) {
|
|
9456
|
-
return mysqlTable("contributionType", {
|
|
9457
|
-
id: (0, import_mysql_core18.varchar)("id", {
|
|
9458
|
-
length: 255
|
|
9459
|
-
}).notNull().primaryKey(),
|
|
9460
|
-
slug: (0, import_mysql_core18.varchar)("slug", {
|
|
9461
|
-
length: 255
|
|
9462
|
-
}).notNull().unique(),
|
|
9463
|
-
name: (0, import_mysql_core18.varchar)("name", {
|
|
9464
|
-
length: 255
|
|
9465
|
-
}).notNull(),
|
|
9466
|
-
description: (0, import_mysql_core18.text)("description"),
|
|
9467
|
-
active: (0, import_mysql_core18.boolean)("active").notNull().default(true),
|
|
9468
|
-
createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
|
|
9469
|
-
mode: "date",
|
|
9470
|
-
fsp: 3
|
|
9471
|
-
}).defaultNow(),
|
|
9472
|
-
updatedAt: (0, import_mysql_core18.timestamp)("updatedAt", {
|
|
9473
|
-
mode: "date",
|
|
9474
|
-
fsp: 3
|
|
9475
|
-
}).defaultNow(),
|
|
9476
|
-
deletedAt: (0, import_mysql_core18.timestamp)("deletedAt", {
|
|
9477
|
-
mode: "date",
|
|
9478
|
-
fsp: 3
|
|
9479
|
-
})
|
|
9480
|
-
}, (ct) => ({
|
|
9481
|
-
nameIdx: (0, import_mysql_core18.index)("name_idx").on(ct.name),
|
|
9482
|
-
slugIdx: (0, import_mysql_core18.index)("slug_idx").on(ct.slug)
|
|
9483
|
-
}));
|
|
9484
|
-
}
|
|
9485
|
-
__name(getContributionTypesSchema, "getContributionTypesSchema");
|
|
9486
|
-
function getContributionTypesRelationsSchema(mysqlTable) {
|
|
9487
|
-
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
9488
|
-
return (0, import_drizzle_orm14.relations)(contributionTypes, ({ many }) => ({}));
|
|
9489
|
-
}
|
|
9490
|
-
__name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
|
|
9491
|
-
|
|
9492
|
-
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
9493
|
-
function getContentContributionsSchema(mysqlTable) {
|
|
9494
|
-
return mysqlTable("contentContribution", {
|
|
9495
|
-
id: (0, import_mysql_core19.varchar)("id", {
|
|
9496
|
-
length: 255
|
|
9497
|
-
}).notNull().primaryKey(),
|
|
9498
|
-
userId: (0, import_mysql_core19.varchar)("userId", {
|
|
9499
|
-
length: 255
|
|
9500
|
-
}).notNull(),
|
|
9501
|
-
contentId: (0, import_mysql_core19.varchar)("contentId", {
|
|
9502
|
-
length: 255
|
|
9503
|
-
}).notNull(),
|
|
9504
|
-
contributionTypeId: (0, import_mysql_core19.varchar)("contributionTypeId", {
|
|
9505
|
-
length: 255
|
|
9506
|
-
}).notNull(),
|
|
9507
|
-
active: (0, import_mysql_core19.boolean)("active").notNull().default(true),
|
|
9508
|
-
createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
|
|
9509
|
-
mode: "date",
|
|
9510
|
-
fsp: 3
|
|
9511
|
-
}).defaultNow(),
|
|
9512
|
-
updatedAt: (0, import_mysql_core19.timestamp)("updatedAt", {
|
|
9513
|
-
mode: "date",
|
|
9514
|
-
fsp: 3
|
|
9515
|
-
}).defaultNow(),
|
|
9516
|
-
deletedAt: (0, import_mysql_core19.timestamp)("deletedAt", {
|
|
9517
|
-
mode: "date",
|
|
9518
|
-
fsp: 3
|
|
9519
|
-
})
|
|
9520
|
-
}, (cc) => ({
|
|
9521
|
-
userIdIdx: (0, import_mysql_core19.index)("userId_idx").on(cc.userId),
|
|
9522
|
-
contentIdIdx: (0, import_mysql_core19.index)("contentId_idx").on(cc.contentId),
|
|
9523
|
-
contributionTypeIdIdx: (0, import_mysql_core19.index)("contributionTypeId_idx").on(cc.contributionTypeId)
|
|
9524
|
-
}));
|
|
9525
|
-
}
|
|
9526
|
-
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
9527
|
-
function getContentContributionRelationsSchema(mysqlTable) {
|
|
9528
|
-
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
9529
|
-
const users = getUsersSchema(mysqlTable);
|
|
9530
|
-
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9531
|
-
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
9532
|
-
return (0, import_drizzle_orm15.relations)(contentContributions, ({ one }) => ({
|
|
9533
|
-
user: one(users, {
|
|
9534
|
-
fields: [
|
|
9535
|
-
contentContributions.userId
|
|
9536
|
-
],
|
|
9537
|
-
references: [
|
|
9538
|
-
users.id
|
|
9539
|
-
],
|
|
9540
|
-
relationName: "user"
|
|
9541
|
-
}),
|
|
9542
|
-
content: one(contentResource, {
|
|
9543
|
-
fields: [
|
|
9544
|
-
contentContributions.contentId
|
|
9545
|
-
],
|
|
9546
|
-
references: [
|
|
9547
|
-
contentResource.id
|
|
9548
|
-
],
|
|
9549
|
-
relationName: "contributions"
|
|
9550
|
-
}),
|
|
9551
|
-
contributionType: one(contributionTypes, {
|
|
9552
|
-
fields: [
|
|
9553
|
-
contentContributions.contributionTypeId
|
|
9554
|
-
],
|
|
9555
|
-
references: [
|
|
9556
|
-
contributionTypes.id
|
|
9557
|
-
],
|
|
9558
|
-
relationName: "contributionType"
|
|
9559
|
-
})
|
|
9560
|
-
}));
|
|
9561
|
-
}
|
|
9562
|
-
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
9563
|
-
|
|
9564
9623
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9565
|
-
var
|
|
9566
|
-
var
|
|
9624
|
+
var import_drizzle_orm18 = require("drizzle-orm");
|
|
9625
|
+
var import_mysql_core22 = require("drizzle-orm/mysql-core");
|
|
9567
9626
|
|
|
9568
9627
|
// src/lib/mysql/schemas/auth/permissions.ts
|
|
9569
|
-
var
|
|
9570
|
-
var
|
|
9628
|
+
var import_drizzle_orm17 = require("drizzle-orm");
|
|
9629
|
+
var import_mysql_core21 = require("drizzle-orm/mysql-core");
|
|
9571
9630
|
function getPermissionsSchema(mysqlTable) {
|
|
9572
|
-
return mysqlTable("
|
|
9573
|
-
id: (0,
|
|
9631
|
+
return mysqlTable("Permission", {
|
|
9632
|
+
id: (0, import_mysql_core21.varchar)("id", {
|
|
9574
9633
|
length: 255
|
|
9575
9634
|
}).notNull().primaryKey(),
|
|
9576
|
-
name: (0,
|
|
9635
|
+
name: (0, import_mysql_core21.varchar)("name", {
|
|
9577
9636
|
length: 255
|
|
9578
9637
|
}).notNull().unique(),
|
|
9579
|
-
description: (0,
|
|
9580
|
-
active: (0,
|
|
9581
|
-
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", {
|
|
9582
9641
|
mode: "date",
|
|
9583
9642
|
fsp: 3
|
|
9584
9643
|
}).defaultNow(),
|
|
9585
|
-
updatedAt: (0,
|
|
9644
|
+
updatedAt: (0, import_mysql_core21.timestamp)("updatedAt", {
|
|
9586
9645
|
mode: "date",
|
|
9587
9646
|
fsp: 3
|
|
9588
9647
|
}).defaultNow(),
|
|
9589
|
-
deletedAt: (0,
|
|
9648
|
+
deletedAt: (0, import_mysql_core21.timestamp)("deletedAt", {
|
|
9590
9649
|
mode: "date",
|
|
9591
9650
|
fsp: 3
|
|
9592
9651
|
})
|
|
9593
9652
|
}, (permission) => ({
|
|
9594
|
-
nameIdx: (0,
|
|
9653
|
+
nameIdx: (0, import_mysql_core21.index)("name_idx").on(permission.name)
|
|
9595
9654
|
}));
|
|
9596
9655
|
}
|
|
9597
9656
|
__name(getPermissionsSchema, "getPermissionsSchema");
|
|
9598
9657
|
function getPermissionsRelationsSchema(mysqlTable) {
|
|
9599
|
-
return (0,
|
|
9658
|
+
return (0, import_drizzle_orm17.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
|
|
9600
9659
|
}
|
|
9601
9660
|
__name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
|
|
9602
9661
|
|
|
9603
9662
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9604
9663
|
function getUserPermissionsSchema(mysqlTable) {
|
|
9605
|
-
return mysqlTable("
|
|
9606
|
-
userId: (0,
|
|
9664
|
+
return mysqlTable("UserPermission", {
|
|
9665
|
+
userId: (0, import_mysql_core22.varchar)("userId", {
|
|
9607
9666
|
length: 255
|
|
9608
9667
|
}).notNull(),
|
|
9609
|
-
permissionId: (0,
|
|
9668
|
+
permissionId: (0, import_mysql_core22.varchar)("permissionId", {
|
|
9610
9669
|
length: 255
|
|
9611
9670
|
}).notNull(),
|
|
9612
|
-
active: (0,
|
|
9613
|
-
createdAt: (0,
|
|
9671
|
+
active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
|
|
9672
|
+
createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
|
|
9614
9673
|
mode: "date",
|
|
9615
9674
|
fsp: 3
|
|
9616
9675
|
}).defaultNow(),
|
|
9617
|
-
updatedAt: (0,
|
|
9676
|
+
updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
|
|
9618
9677
|
mode: "date",
|
|
9619
9678
|
fsp: 3
|
|
9620
9679
|
}).defaultNow(),
|
|
9621
|
-
deletedAt: (0,
|
|
9680
|
+
deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
|
|
9622
9681
|
mode: "date",
|
|
9623
9682
|
fsp: 3
|
|
9624
9683
|
})
|
|
9625
9684
|
}, (up) => ({
|
|
9626
|
-
pk: (0,
|
|
9685
|
+
pk: (0, import_mysql_core22.primaryKey)({
|
|
9627
9686
|
columns: [
|
|
9628
9687
|
up.userId,
|
|
9629
9688
|
up.permissionId
|
|
9630
9689
|
]
|
|
9631
9690
|
}),
|
|
9632
|
-
userIdIdx: (0,
|
|
9633
|
-
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)
|
|
9634
9693
|
}));
|
|
9635
9694
|
}
|
|
9636
9695
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -9638,7 +9697,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9638
9697
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
9639
9698
|
const users = getUsersSchema(mysqlTable);
|
|
9640
9699
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
9641
|
-
return (0,
|
|
9700
|
+
return (0, import_drizzle_orm18.relations)(userPermissions, ({ one }) => ({
|
|
9642
9701
|
user: one(users, {
|
|
9643
9702
|
fields: [
|
|
9644
9703
|
userPermissions.userId
|
|
@@ -9661,44 +9720,98 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9661
9720
|
}
|
|
9662
9721
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
9663
9722
|
|
|
9664
|
-
// src/lib/mysql/schemas/auth/user-
|
|
9723
|
+
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
9665
9724
|
var import_drizzle_orm19 = require("drizzle-orm");
|
|
9666
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");
|
|
9667
9780
|
|
|
9668
9781
|
// src/lib/mysql/schemas/auth/roles.ts
|
|
9669
|
-
var
|
|
9670
|
-
var
|
|
9782
|
+
var import_drizzle_orm20 = require("drizzle-orm");
|
|
9783
|
+
var import_mysql_core24 = require("drizzle-orm/mysql-core");
|
|
9671
9784
|
function getRolesSchema(mysqlTable) {
|
|
9672
|
-
return mysqlTable("
|
|
9673
|
-
id: (0,
|
|
9785
|
+
return mysqlTable("Role", {
|
|
9786
|
+
id: (0, import_mysql_core24.varchar)("id", {
|
|
9674
9787
|
length: 255
|
|
9675
9788
|
}).notNull().primaryKey(),
|
|
9676
|
-
name: (0,
|
|
9789
|
+
name: (0, import_mysql_core24.varchar)("name", {
|
|
9677
9790
|
length: 255
|
|
9678
9791
|
}).notNull().unique(),
|
|
9679
|
-
description: (0,
|
|
9680
|
-
active: (0,
|
|
9681
|
-
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", {
|
|
9682
9795
|
mode: "date",
|
|
9683
9796
|
fsp: 3
|
|
9684
9797
|
}).defaultNow(),
|
|
9685
|
-
updatedAt: (0,
|
|
9798
|
+
updatedAt: (0, import_mysql_core24.timestamp)("updatedAt", {
|
|
9686
9799
|
mode: "date",
|
|
9687
9800
|
fsp: 3
|
|
9688
9801
|
}).defaultNow(),
|
|
9689
|
-
deletedAt: (0,
|
|
9802
|
+
deletedAt: (0, import_mysql_core24.timestamp)("deletedAt", {
|
|
9690
9803
|
mode: "date",
|
|
9691
9804
|
fsp: 3
|
|
9692
9805
|
})
|
|
9693
9806
|
}, (role) => ({
|
|
9694
|
-
nameIdx: (0,
|
|
9807
|
+
nameIdx: (0, import_mysql_core24.index)("name_idx").on(role.name)
|
|
9695
9808
|
}));
|
|
9696
9809
|
}
|
|
9697
9810
|
__name(getRolesSchema, "getRolesSchema");
|
|
9698
9811
|
function getRolesRelationsSchema(mysqlTable) {
|
|
9699
9812
|
const roles = getRolesSchema(mysqlTable);
|
|
9700
9813
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9701
|
-
return (0,
|
|
9814
|
+
return (0, import_drizzle_orm20.relations)(roles, ({ many }) => ({
|
|
9702
9815
|
userRoles: many(userRoles, {
|
|
9703
9816
|
relationName: "role"
|
|
9704
9817
|
})
|
|
@@ -9708,35 +9821,35 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
|
9708
9821
|
|
|
9709
9822
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9710
9823
|
function getUserRolesSchema(mysqlTable) {
|
|
9711
|
-
return mysqlTable("
|
|
9712
|
-
userId: (0,
|
|
9824
|
+
return mysqlTable("UserRole", {
|
|
9825
|
+
userId: (0, import_mysql_core25.varchar)("userId", {
|
|
9713
9826
|
length: 255
|
|
9714
9827
|
}).notNull(),
|
|
9715
|
-
roleId: (0,
|
|
9828
|
+
roleId: (0, import_mysql_core25.varchar)("roleId", {
|
|
9716
9829
|
length: 255
|
|
9717
9830
|
}).notNull(),
|
|
9718
|
-
active: (0,
|
|
9719
|
-
createdAt: (0,
|
|
9831
|
+
active: (0, import_mysql_core25.boolean)("active").notNull().default(true),
|
|
9832
|
+
createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
|
|
9720
9833
|
mode: "date",
|
|
9721
9834
|
fsp: 3
|
|
9722
9835
|
}).defaultNow(),
|
|
9723
|
-
updatedAt: (0,
|
|
9836
|
+
updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
|
|
9724
9837
|
mode: "date",
|
|
9725
9838
|
fsp: 3
|
|
9726
9839
|
}).defaultNow(),
|
|
9727
|
-
deletedAt: (0,
|
|
9840
|
+
deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
|
|
9728
9841
|
mode: "date",
|
|
9729
9842
|
fsp: 3
|
|
9730
9843
|
})
|
|
9731
9844
|
}, (ur) => ({
|
|
9732
|
-
pk: (0,
|
|
9845
|
+
pk: (0, import_mysql_core25.primaryKey)({
|
|
9733
9846
|
columns: [
|
|
9734
9847
|
ur.userId,
|
|
9735
9848
|
ur.roleId
|
|
9736
9849
|
]
|
|
9737
9850
|
}),
|
|
9738
|
-
userIdIdx: (0,
|
|
9739
|
-
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)
|
|
9740
9853
|
}));
|
|
9741
9854
|
}
|
|
9742
9855
|
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
@@ -9744,7 +9857,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
|
|
|
9744
9857
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9745
9858
|
const users = getUsersSchema(mysqlTable);
|
|
9746
9859
|
const roles = getRolesSchema(mysqlTable);
|
|
9747
|
-
return (0,
|
|
9860
|
+
return (0, import_drizzle_orm21.relations)(userRoles, ({ one }) => ({
|
|
9748
9861
|
user: one(users, {
|
|
9749
9862
|
fields: [
|
|
9750
9863
|
userRoles.userId
|
|
@@ -9769,35 +9882,35 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
|
9769
9882
|
|
|
9770
9883
|
// src/lib/mysql/schemas/auth/users.ts
|
|
9771
9884
|
function getUsersSchema(mysqlTable) {
|
|
9772
|
-
return mysqlTable("
|
|
9773
|
-
id: (0,
|
|
9885
|
+
return mysqlTable("User", {
|
|
9886
|
+
id: (0, import_mysql_core26.varchar)("id", {
|
|
9774
9887
|
length: 255
|
|
9775
9888
|
}).notNull().primaryKey(),
|
|
9776
|
-
name: (0,
|
|
9889
|
+
name: (0, import_mysql_core26.varchar)("name", {
|
|
9777
9890
|
length: 255
|
|
9778
9891
|
}),
|
|
9779
|
-
role: (0,
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
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", {
|
|
9784
9896
|
length: 255
|
|
9785
9897
|
}).notNull().unique(),
|
|
9786
|
-
|
|
9898
|
+
fields: (0, import_mysql_core26.json)("fields").$type().default({}),
|
|
9899
|
+
emailVerified: (0, import_mysql_core26.timestamp)("emailVerified", {
|
|
9787
9900
|
mode: "date",
|
|
9788
9901
|
fsp: 3
|
|
9789
9902
|
}),
|
|
9790
|
-
image: (0,
|
|
9903
|
+
image: (0, import_mysql_core26.varchar)("image", {
|
|
9791
9904
|
length: 255
|
|
9792
9905
|
}),
|
|
9793
|
-
createdAt: (0,
|
|
9906
|
+
createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
|
|
9794
9907
|
mode: "date",
|
|
9795
9908
|
fsp: 3
|
|
9796
|
-
}).default(
|
|
9909
|
+
}).default(import_drizzle_orm22.sql`CURRENT_TIMESTAMP(3)`)
|
|
9797
9910
|
}, (user) => ({
|
|
9798
|
-
emailIdx: (0,
|
|
9799
|
-
roleIdx: (0,
|
|
9800
|
-
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)
|
|
9801
9914
|
}));
|
|
9802
9915
|
}
|
|
9803
9916
|
__name(getUsersSchema, "getUsersSchema");
|
|
@@ -9810,7 +9923,9 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
9810
9923
|
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
9811
9924
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9812
9925
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
9813
|
-
|
|
9926
|
+
const comments = getCommentsSchema(mysqlTable);
|
|
9927
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9928
|
+
return (0, import_drizzle_orm22.relations)(users, ({ many }) => ({
|
|
9814
9929
|
accounts: many(accounts, {
|
|
9815
9930
|
relationName: "user"
|
|
9816
9931
|
}),
|
|
@@ -9831,6 +9946,12 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
9831
9946
|
}),
|
|
9832
9947
|
createdContent: many(contentResource, {
|
|
9833
9948
|
relationName: "user"
|
|
9949
|
+
}),
|
|
9950
|
+
comments: many(comments, {
|
|
9951
|
+
relationName: "user"
|
|
9952
|
+
}),
|
|
9953
|
+
prefs: many(userPrefs, {
|
|
9954
|
+
relationName: "user"
|
|
9834
9955
|
})
|
|
9835
9956
|
}));
|
|
9836
9957
|
}
|
|
@@ -9838,50 +9959,50 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
|
9838
9959
|
|
|
9839
9960
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
9840
9961
|
function getAccountsSchema(mysqlTable) {
|
|
9841
|
-
return mysqlTable("
|
|
9842
|
-
userId: (0,
|
|
9962
|
+
return mysqlTable("Account", {
|
|
9963
|
+
userId: (0, import_mysql_core27.varchar)("userId", {
|
|
9843
9964
|
length: 255
|
|
9844
9965
|
}).notNull(),
|
|
9845
|
-
type: (0,
|
|
9966
|
+
type: (0, import_mysql_core27.varchar)("type", {
|
|
9846
9967
|
length: 255
|
|
9847
9968
|
}).$type().notNull(),
|
|
9848
|
-
provider: (0,
|
|
9969
|
+
provider: (0, import_mysql_core27.varchar)("provider", {
|
|
9849
9970
|
length: 255
|
|
9850
9971
|
}).notNull(),
|
|
9851
|
-
providerAccountId: (0,
|
|
9972
|
+
providerAccountId: (0, import_mysql_core27.varchar)("providerAccountId", {
|
|
9852
9973
|
length: 255
|
|
9853
9974
|
}).notNull(),
|
|
9854
|
-
refresh_token: (0,
|
|
9855
|
-
access_token: (0,
|
|
9856
|
-
oauth_token: (0,
|
|
9857
|
-
oauth_token_secret: (0,
|
|
9858
|
-
expires_at: (0,
|
|
9859
|
-
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", {
|
|
9860
9981
|
length: 255
|
|
9861
9982
|
}),
|
|
9862
|
-
scope: (0,
|
|
9983
|
+
scope: (0, import_mysql_core27.varchar)("scope", {
|
|
9863
9984
|
length: 255
|
|
9864
9985
|
}),
|
|
9865
|
-
id_token: (0,
|
|
9866
|
-
session_state: (0,
|
|
9986
|
+
id_token: (0, import_mysql_core27.text)("id_token"),
|
|
9987
|
+
session_state: (0, import_mysql_core27.varchar)("session_state", {
|
|
9867
9988
|
length: 255
|
|
9868
9989
|
}),
|
|
9869
|
-
refresh_token_expires_in: (0,
|
|
9990
|
+
refresh_token_expires_in: (0, import_mysql_core27.int)("refresh_token_expires_in")
|
|
9870
9991
|
}, (account) => ({
|
|
9871
|
-
pk: (0,
|
|
9992
|
+
pk: (0, import_mysql_core27.primaryKey)({
|
|
9872
9993
|
columns: [
|
|
9873
9994
|
account.provider,
|
|
9874
9995
|
account.providerAccountId
|
|
9875
9996
|
]
|
|
9876
9997
|
}),
|
|
9877
|
-
userIdIdx: (0,
|
|
9998
|
+
userIdIdx: (0, import_mysql_core27.index)("userId_idx").on(account.userId)
|
|
9878
9999
|
}));
|
|
9879
10000
|
}
|
|
9880
10001
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
9881
10002
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
9882
10003
|
const accounts = getAccountsSchema(mysqlTable);
|
|
9883
10004
|
const users = getUsersSchema(mysqlTable);
|
|
9884
|
-
return (0,
|
|
10005
|
+
return (0, import_drizzle_orm23.relations)(accounts, ({ one }) => ({
|
|
9885
10006
|
user: one(users, {
|
|
9886
10007
|
fields: [
|
|
9887
10008
|
accounts.userId
|
|
@@ -9895,39 +10016,131 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
9895
10016
|
}
|
|
9896
10017
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
9897
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
|
+
|
|
9898
10111
|
// src/lib/mysql/schemas/auth/role-permissions.ts
|
|
9899
|
-
var
|
|
9900
|
-
var
|
|
10112
|
+
var import_drizzle_orm26 = require("drizzle-orm");
|
|
10113
|
+
var import_mysql_core30 = require("drizzle-orm/mysql-core");
|
|
9901
10114
|
function getRolePermissionsSchema(mysqlTable) {
|
|
9902
|
-
return mysqlTable("
|
|
9903
|
-
roleId: (0,
|
|
10115
|
+
return mysqlTable("RolePermission", {
|
|
10116
|
+
roleId: (0, import_mysql_core30.varchar)("roleId", {
|
|
9904
10117
|
length: 255
|
|
9905
10118
|
}).notNull(),
|
|
9906
|
-
permissionId: (0,
|
|
10119
|
+
permissionId: (0, import_mysql_core30.varchar)("permissionId", {
|
|
9907
10120
|
length: 255
|
|
9908
10121
|
}).notNull(),
|
|
9909
|
-
active: (0,
|
|
9910
|
-
createdAt: (0,
|
|
10122
|
+
active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
|
|
10123
|
+
createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
|
|
9911
10124
|
mode: "date",
|
|
9912
10125
|
fsp: 3
|
|
9913
10126
|
}).defaultNow(),
|
|
9914
|
-
updatedAt: (0,
|
|
10127
|
+
updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
|
|
9915
10128
|
mode: "date",
|
|
9916
10129
|
fsp: 3
|
|
9917
10130
|
}).defaultNow(),
|
|
9918
|
-
deletedAt: (0,
|
|
10131
|
+
deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
|
|
9919
10132
|
mode: "date",
|
|
9920
10133
|
fsp: 3
|
|
9921
10134
|
})
|
|
9922
10135
|
}, (rp) => ({
|
|
9923
|
-
pk: (0,
|
|
10136
|
+
pk: (0, import_mysql_core30.primaryKey)({
|
|
9924
10137
|
columns: [
|
|
9925
10138
|
rp.roleId,
|
|
9926
10139
|
rp.permissionId
|
|
9927
10140
|
]
|
|
9928
10141
|
}),
|
|
9929
|
-
roleIdIdx: (0,
|
|
9930
|
-
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)
|
|
9931
10144
|
}));
|
|
9932
10145
|
}
|
|
9933
10146
|
__name(getRolePermissionsSchema, "getRolePermissionsSchema");
|
|
@@ -9935,7 +10148,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
9935
10148
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
9936
10149
|
const roles = getRolesSchema(mysqlTable);
|
|
9937
10150
|
const rolePermissions = getRolePermissionsSchema(mysqlTable);
|
|
9938
|
-
return (0,
|
|
10151
|
+
return (0, import_drizzle_orm26.relations)(rolePermissions, ({ one }) => ({
|
|
9939
10152
|
role: one(roles, {
|
|
9940
10153
|
fields: [
|
|
9941
10154
|
rolePermissions.roleId
|
|
@@ -9959,28 +10172,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
9959
10172
|
__name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
|
|
9960
10173
|
|
|
9961
10174
|
// src/lib/mysql/schemas/auth/sessions.ts
|
|
9962
|
-
var
|
|
9963
|
-
var
|
|
10175
|
+
var import_drizzle_orm27 = require("drizzle-orm");
|
|
10176
|
+
var import_mysql_core31 = require("drizzle-orm/mysql-core");
|
|
9964
10177
|
function getSessionsSchema(mysqlTable) {
|
|
9965
|
-
return mysqlTable("
|
|
9966
|
-
sessionToken: (0,
|
|
10178
|
+
return mysqlTable("Session", {
|
|
10179
|
+
sessionToken: (0, import_mysql_core31.varchar)("sessionToken", {
|
|
9967
10180
|
length: 255
|
|
9968
10181
|
}).notNull().primaryKey(),
|
|
9969
|
-
userId: (0,
|
|
10182
|
+
userId: (0, import_mysql_core31.varchar)("userId", {
|
|
9970
10183
|
length: 255
|
|
9971
10184
|
}).notNull(),
|
|
9972
|
-
expires: (0,
|
|
10185
|
+
expires: (0, import_mysql_core31.timestamp)("expires", {
|
|
9973
10186
|
mode: "date"
|
|
9974
10187
|
}).notNull()
|
|
9975
10188
|
}, (session) => ({
|
|
9976
|
-
userIdIdx: (0,
|
|
10189
|
+
userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(session.userId)
|
|
9977
10190
|
}));
|
|
9978
10191
|
}
|
|
9979
10192
|
__name(getSessionsSchema, "getSessionsSchema");
|
|
9980
10193
|
function getSessionRelationsSchema(mysqlTable) {
|
|
9981
10194
|
const sessions = getSessionsSchema(mysqlTable);
|
|
9982
10195
|
const users = getUsersSchema(mysqlTable);
|
|
9983
|
-
return (0,
|
|
10196
|
+
return (0, import_drizzle_orm27.relations)(sessions, ({ one }) => ({
|
|
9984
10197
|
user: one(users, {
|
|
9985
10198
|
fields: [
|
|
9986
10199
|
sessions.userId
|
|
@@ -9995,24 +10208,24 @@ function getSessionRelationsSchema(mysqlTable) {
|
|
|
9995
10208
|
__name(getSessionRelationsSchema, "getSessionRelationsSchema");
|
|
9996
10209
|
|
|
9997
10210
|
// src/lib/mysql/schemas/auth/verification-tokens.ts
|
|
9998
|
-
var
|
|
10211
|
+
var import_mysql_core32 = require("drizzle-orm/mysql-core");
|
|
9999
10212
|
function getVerificationTokensSchema(mysqlTable) {
|
|
10000
|
-
return mysqlTable("
|
|
10001
|
-
identifier: (0,
|
|
10213
|
+
return mysqlTable("VerificationToken", {
|
|
10214
|
+
identifier: (0, import_mysql_core32.varchar)("identifier", {
|
|
10002
10215
|
length: 255
|
|
10003
10216
|
}).notNull(),
|
|
10004
|
-
token: (0,
|
|
10217
|
+
token: (0, import_mysql_core32.varchar)("token", {
|
|
10005
10218
|
length: 255
|
|
10006
10219
|
}).notNull(),
|
|
10007
|
-
expires: (0,
|
|
10220
|
+
expires: (0, import_mysql_core32.timestamp)("expires", {
|
|
10008
10221
|
mode: "date"
|
|
10009
10222
|
}).notNull(),
|
|
10010
|
-
createdAt: (0,
|
|
10223
|
+
createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
|
|
10011
10224
|
mode: "date",
|
|
10012
10225
|
fsp: 3
|
|
10013
10226
|
}).defaultNow()
|
|
10014
10227
|
}, (vt) => ({
|
|
10015
|
-
pk: (0,
|
|
10228
|
+
pk: (0, import_mysql_core32.primaryKey)({
|
|
10016
10229
|
columns: [
|
|
10017
10230
|
vt.identifier,
|
|
10018
10231
|
vt.token
|
|
@@ -10023,14 +10236,14 @@ function getVerificationTokensSchema(mysqlTable) {
|
|
|
10023
10236
|
__name(getVerificationTokensSchema, "getVerificationTokensSchema");
|
|
10024
10237
|
|
|
10025
10238
|
// src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
|
|
10026
|
-
var
|
|
10027
|
-
var
|
|
10239
|
+
var import_drizzle_orm28 = require("drizzle-orm");
|
|
10240
|
+
var import_mysql_core33 = require("drizzle-orm/mysql-core");
|
|
10028
10241
|
function getPurchaseUserTransferSchema(mysqlTable) {
|
|
10029
|
-
return mysqlTable("
|
|
10030
|
-
id: (0,
|
|
10242
|
+
return mysqlTable("PurchaseUserTransfer", {
|
|
10243
|
+
id: (0, import_mysql_core33.varchar)("id", {
|
|
10031
10244
|
length: 191
|
|
10032
10245
|
}).notNull(),
|
|
10033
|
-
transferState: (0,
|
|
10246
|
+
transferState: (0, import_mysql_core33.mysqlEnum)("transferState", [
|
|
10034
10247
|
"AVAILABLE",
|
|
10035
10248
|
"INITIATED",
|
|
10036
10249
|
"VERIFIED",
|
|
@@ -10039,38 +10252,38 @@ function getPurchaseUserTransferSchema(mysqlTable) {
|
|
|
10039
10252
|
"CONFIRMED",
|
|
10040
10253
|
"COMPLETED"
|
|
10041
10254
|
]).default("AVAILABLE").notNull(),
|
|
10042
|
-
purchaseId: (0,
|
|
10255
|
+
purchaseId: (0, import_mysql_core33.varchar)("purchaseId", {
|
|
10043
10256
|
length: 191
|
|
10044
10257
|
}).notNull(),
|
|
10045
|
-
sourceUserId: (0,
|
|
10258
|
+
sourceUserId: (0, import_mysql_core33.varchar)("sourceUserId", {
|
|
10046
10259
|
length: 191
|
|
10047
10260
|
}).notNull(),
|
|
10048
|
-
targetUserId: (0,
|
|
10261
|
+
targetUserId: (0, import_mysql_core33.varchar)("targetUserId", {
|
|
10049
10262
|
length: 191
|
|
10050
10263
|
}),
|
|
10051
|
-
createdAt: (0,
|
|
10264
|
+
createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
|
|
10052
10265
|
mode: "date",
|
|
10053
10266
|
fsp: 3
|
|
10054
|
-
}).default(
|
|
10055
|
-
expiresAt: (0,
|
|
10267
|
+
}).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
10268
|
+
expiresAt: (0, import_mysql_core33.timestamp)("expiresAt", {
|
|
10056
10269
|
mode: "date",
|
|
10057
10270
|
fsp: 3
|
|
10058
10271
|
}),
|
|
10059
|
-
canceledAt: (0,
|
|
10272
|
+
canceledAt: (0, import_mysql_core33.timestamp)("canceledAt", {
|
|
10060
10273
|
mode: "date",
|
|
10061
10274
|
fsp: 3
|
|
10062
10275
|
}),
|
|
10063
|
-
confirmedAt: (0,
|
|
10276
|
+
confirmedAt: (0, import_mysql_core33.timestamp)("confirmedAt", {
|
|
10064
10277
|
mode: "date",
|
|
10065
10278
|
fsp: 3
|
|
10066
10279
|
}),
|
|
10067
|
-
completedAt: (0,
|
|
10280
|
+
completedAt: (0, import_mysql_core33.timestamp)("completedAt", {
|
|
10068
10281
|
mode: "date",
|
|
10069
10282
|
fsp: 3
|
|
10070
10283
|
})
|
|
10071
10284
|
}, (table) => {
|
|
10072
10285
|
return {
|
|
10073
|
-
purchaseUserTransferId: (0,
|
|
10286
|
+
purchaseUserTransferId: (0, import_mysql_core33.primaryKey)({
|
|
10074
10287
|
columns: [
|
|
10075
10288
|
table.id
|
|
10076
10289
|
],
|
|
@@ -10084,7 +10297,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10084
10297
|
const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
|
|
10085
10298
|
const user = getUsersSchema(mysqlTable);
|
|
10086
10299
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
10087
|
-
return (0,
|
|
10300
|
+
return (0, import_drizzle_orm28.relations)(purchaseUserTransfer, ({ one }) => ({
|
|
10088
10301
|
sourceUser: one(user, {
|
|
10089
10302
|
fields: [
|
|
10090
10303
|
purchaseUserTransfer.sourceUserId
|
|
@@ -10117,46 +10330,46 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10117
10330
|
__name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
|
|
10118
10331
|
|
|
10119
10332
|
// src/lib/mysql/schemas/commerce/upgradable-products.ts
|
|
10120
|
-
var
|
|
10121
|
-
var
|
|
10333
|
+
var import_drizzle_orm29 = require("drizzle-orm");
|
|
10334
|
+
var import_mysql_core34 = require("drizzle-orm/mysql-core");
|
|
10122
10335
|
function getUpgradableProductsSchema(mysqlTable) {
|
|
10123
|
-
return mysqlTable("
|
|
10124
|
-
upgradableToId: (0,
|
|
10336
|
+
return mysqlTable("UpgradableProducts", {
|
|
10337
|
+
upgradableToId: (0, import_mysql_core34.varchar)("upgradableToId", {
|
|
10125
10338
|
length: 255
|
|
10126
10339
|
}).notNull(),
|
|
10127
|
-
upgradableFromId: (0,
|
|
10340
|
+
upgradableFromId: (0, import_mysql_core34.varchar)("upgradableFrom", {
|
|
10128
10341
|
length: 255
|
|
10129
10342
|
}).notNull(),
|
|
10130
|
-
position: (0,
|
|
10131
|
-
metadata: (0,
|
|
10132
|
-
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", {
|
|
10133
10346
|
mode: "date",
|
|
10134
10347
|
fsp: 3
|
|
10135
|
-
}).default(
|
|
10136
|
-
updatedAt: (0,
|
|
10348
|
+
}).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
|
|
10349
|
+
updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
|
|
10137
10350
|
mode: "date",
|
|
10138
10351
|
fsp: 3
|
|
10139
|
-
}).default(
|
|
10140
|
-
deletedAt: (0,
|
|
10352
|
+
}).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
|
|
10353
|
+
deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
|
|
10141
10354
|
mode: "date",
|
|
10142
10355
|
fsp: 3
|
|
10143
10356
|
})
|
|
10144
10357
|
}, (crr) => ({
|
|
10145
|
-
pk: (0,
|
|
10358
|
+
pk: (0, import_mysql_core34.primaryKey)({
|
|
10146
10359
|
columns: [
|
|
10147
10360
|
crr.upgradableToId,
|
|
10148
10361
|
crr.upgradableFromId
|
|
10149
10362
|
]
|
|
10150
10363
|
}),
|
|
10151
|
-
upgradableToIdIdx: (0,
|
|
10152
|
-
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)
|
|
10153
10366
|
}));
|
|
10154
10367
|
}
|
|
10155
10368
|
__name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
|
|
10156
10369
|
function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
10157
10370
|
const product = getProductSchema(mysqlTable);
|
|
10158
10371
|
const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
|
|
10159
|
-
return (0,
|
|
10372
|
+
return (0, import_drizzle_orm29.relations)(upgradableProduct, ({ one }) => ({
|
|
10160
10373
|
upgradableTo: one(product, {
|
|
10161
10374
|
fields: [
|
|
10162
10375
|
upgradableProduct.upgradableToId
|
|
@@ -10179,41 +10392,89 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
|
10179
10392
|
}
|
|
10180
10393
|
__name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
|
|
10181
10394
|
|
|
10182
|
-
// src/lib/mysql/schemas/content/
|
|
10183
|
-
var
|
|
10184
|
-
var
|
|
10185
|
-
function
|
|
10186
|
-
return mysqlTable("
|
|
10187
|
-
|
|
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", {
|
|
10188
10404
|
length: 191
|
|
10189
10405
|
}).notNull(),
|
|
10190
|
-
|
|
10406
|
+
lessonId: (0, import_mysql_core35.varchar)("lessonId", {
|
|
10407
|
+
length: 191
|
|
10408
|
+
}),
|
|
10409
|
+
lessonSlug: (0, import_mysql_core35.varchar)("lessonSlug", {
|
|
10191
10410
|
length: 191
|
|
10192
10411
|
}),
|
|
10193
|
-
|
|
10194
|
-
|
|
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", {
|
|
10419
|
+
length: 191
|
|
10420
|
+
}),
|
|
10421
|
+
completedAt: (0, import_mysql_core35.datetime)("completedAt", {
|
|
10422
|
+
mode: "date",
|
|
10423
|
+
fsp: 3
|
|
10424
|
+
}),
|
|
10425
|
+
updatedAt: (0, import_mysql_core35.datetime)("updatedAt", {
|
|
10426
|
+
mode: "date",
|
|
10427
|
+
fsp: 3
|
|
10428
|
+
}),
|
|
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", {
|
|
10195
10456
|
mode: "date",
|
|
10196
10457
|
fsp: 3
|
|
10197
10458
|
}),
|
|
10198
|
-
updatedAt: (0,
|
|
10459
|
+
updatedAt: (0, import_mysql_core36.datetime)("updatedAt", {
|
|
10199
10460
|
mode: "date",
|
|
10200
10461
|
fsp: 3
|
|
10201
10462
|
}),
|
|
10202
|
-
createdAt: (0,
|
|
10463
|
+
createdAt: (0, import_mysql_core36.datetime)("createdAt", {
|
|
10203
10464
|
mode: "date",
|
|
10204
10465
|
fsp: 3
|
|
10205
|
-
}).default(
|
|
10466
|
+
}).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10206
10467
|
}, (crp) => {
|
|
10207
10468
|
return {
|
|
10208
|
-
userIdLessonIdIdx: (0,
|
|
10209
|
-
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)({
|
|
10210
10471
|
columns: [
|
|
10211
10472
|
crp.userId,
|
|
10212
|
-
crp.
|
|
10473
|
+
crp.resourceId
|
|
10213
10474
|
]
|
|
10214
10475
|
}),
|
|
10215
|
-
contentResourceIdIdx: (0,
|
|
10216
|
-
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)
|
|
10217
10478
|
};
|
|
10218
10479
|
});
|
|
10219
10480
|
}
|
|
@@ -10241,6 +10502,7 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10241
10502
|
verificationTokens: getVerificationTokensSchema(mysqlTable),
|
|
10242
10503
|
coupon: getCouponSchema(mysqlTable),
|
|
10243
10504
|
couponRelations: getCouponRelationsSchema(mysqlTable),
|
|
10505
|
+
lessonProgress: getLessonProgressSchema(mysqlTable),
|
|
10244
10506
|
merchantAccount: getMerchantAccountSchema(mysqlTable),
|
|
10245
10507
|
merchantCharge: getMerchantChargeSchema(mysqlTable),
|
|
10246
10508
|
merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
|
|
@@ -10272,7 +10534,15 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10272
10534
|
upgradableProductsRelations: getUpgradableProductsRelationsSchema(mysqlTable),
|
|
10273
10535
|
contentResourceProduct: getContentResourceProductSchema(mysqlTable),
|
|
10274
10536
|
contentResourceProductRelations: getContentResourceProductRelationsSchema(mysqlTable),
|
|
10275
|
-
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)
|
|
10276
10546
|
};
|
|
10277
10547
|
}
|
|
10278
10548
|
__name(getCourseBuilderSchema, "getCourseBuilderSchema");
|
|
@@ -10280,8 +10550,8 @@ function createTables(mySqlTable) {
|
|
|
10280
10550
|
return getCourseBuilderSchema(mySqlTable);
|
|
10281
10551
|
}
|
|
10282
10552
|
__name(createTables, "createTables");
|
|
10283
|
-
function mySqlDrizzleAdapter(client, tableFn =
|
|
10284
|
-
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);
|
|
10285
10555
|
const adapter = {
|
|
10286
10556
|
client,
|
|
10287
10557
|
async redeemFullPriceCoupon(options) {
|
|
@@ -10342,12 +10612,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10342
10612
|
},
|
|
10343
10613
|
incrementCouponUsedCount: async (couponId) => {
|
|
10344
10614
|
await client.update(coupon).set({
|
|
10345
|
-
usedCount:
|
|
10346
|
-
}).where((0,
|
|
10615
|
+
usedCount: import_drizzle_orm32.sql`${coupon.usedCount} + 1`
|
|
10616
|
+
}).where((0, import_drizzle_orm32.eq)(coupon.id, couponId));
|
|
10347
10617
|
},
|
|
10348
10618
|
getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
|
|
10349
10619
|
const existingPurchases = await client.query.purchases.findMany({
|
|
10350
|
-
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))
|
|
10351
10621
|
});
|
|
10352
10622
|
return z.array(purchaseSchema).parse(existingPurchases);
|
|
10353
10623
|
},
|
|
@@ -10360,17 +10630,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10360
10630
|
status: 1
|
|
10361
10631
|
});
|
|
10362
10632
|
return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
10363
|
-
where: (0,
|
|
10633
|
+
where: (0, import_drizzle_orm32.eq)(merchantCustomer.identifier, options.identifier)
|
|
10364
10634
|
}));
|
|
10365
10635
|
},
|
|
10366
10636
|
getMerchantAccount: async (options) => {
|
|
10367
10637
|
return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
|
|
10368
|
-
where: (0,
|
|
10638
|
+
where: (0, import_drizzle_orm32.eq)(merchantAccount.label, options.provider)
|
|
10369
10639
|
}));
|
|
10370
10640
|
},
|
|
10371
10641
|
getMerchantPriceForProductId: async (productId) => {
|
|
10372
10642
|
const merchantPriceData = await client.query.merchantPrice.findFirst({
|
|
10373
|
-
where: (0,
|
|
10643
|
+
where: (0, import_drizzle_orm32.eq)(merchantPrice.merchantProductId, productId)
|
|
10374
10644
|
});
|
|
10375
10645
|
const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
|
|
10376
10646
|
if (!parsedMerchantPrice.success) {
|
|
@@ -10381,7 +10651,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10381
10651
|
},
|
|
10382
10652
|
getMerchantProductForProductId: async (productId) => {
|
|
10383
10653
|
const merchantProductData = await client.query.merchantProduct.findFirst({
|
|
10384
|
-
where: (0,
|
|
10654
|
+
where: (0, import_drizzle_orm32.eq)(merchantProduct.productId, productId)
|
|
10385
10655
|
});
|
|
10386
10656
|
if (!merchantProductData)
|
|
10387
10657
|
return null;
|
|
@@ -10389,7 +10659,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10389
10659
|
},
|
|
10390
10660
|
getMerchantCustomerForUserId: async (userId) => {
|
|
10391
10661
|
const merchantCustomerData = await client.query.merchantCustomer.findFirst({
|
|
10392
|
-
where: (0,
|
|
10662
|
+
where: (0, import_drizzle_orm32.eq)(merchantCustomer.userId, userId)
|
|
10393
10663
|
});
|
|
10394
10664
|
if (!merchantCustomerData)
|
|
10395
10665
|
return null;
|
|
@@ -10398,14 +10668,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10398
10668
|
getUpgradableProducts: async (options) => {
|
|
10399
10669
|
const { upgradableFromId, upgradableToId } = options;
|
|
10400
10670
|
return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
10401
|
-
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))
|
|
10402
10672
|
}));
|
|
10403
10673
|
},
|
|
10404
10674
|
async availableUpgradesForProduct(purchases, productId) {
|
|
10405
10675
|
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
10406
10676
|
if (previousPurchaseProductIds.length > 0) {
|
|
10407
10677
|
return await client.query.upgradableProducts.findMany({
|
|
10408
|
-
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))
|
|
10409
10679
|
});
|
|
10410
10680
|
}
|
|
10411
10681
|
return [];
|
|
@@ -10418,7 +10688,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10418
10688
|
throw new Error("No lessonId provided");
|
|
10419
10689
|
}
|
|
10420
10690
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10421
|
-
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))
|
|
10422
10692
|
});
|
|
10423
10693
|
const now = /* @__PURE__ */ new Date();
|
|
10424
10694
|
if (lessonProgress) {
|
|
@@ -10426,18 +10696,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10426
10696
|
await client.update(resourceProgress).set({
|
|
10427
10697
|
completedAt: now,
|
|
10428
10698
|
updatedAt: now
|
|
10429
|
-
}).where((0,
|
|
10699
|
+
}).where((0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId));
|
|
10430
10700
|
}
|
|
10431
10701
|
} else {
|
|
10432
10702
|
await client.insert(resourceProgress).values({
|
|
10433
10703
|
userId: options.userId,
|
|
10434
|
-
|
|
10704
|
+
resourceId: options.lessonId,
|
|
10435
10705
|
completedAt: now,
|
|
10436
10706
|
updatedAt: now
|
|
10437
10707
|
});
|
|
10438
10708
|
}
|
|
10439
10709
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10440
|
-
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))
|
|
10441
10711
|
});
|
|
10442
10712
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
10443
10713
|
if (!parsedLessonProgress.success) {
|
|
@@ -10450,26 +10720,31 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10450
10720
|
if (!options.couponId && !options.code)
|
|
10451
10721
|
return null;
|
|
10452
10722
|
const couponForIdOrCode = await client.query.coupon.findFirst({
|
|
10453
|
-
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))),
|
|
10454
10724
|
with: {
|
|
10455
10725
|
merchantCoupon: true
|
|
10456
10726
|
}
|
|
10457
10727
|
});
|
|
10458
10728
|
if (!couponForIdOrCode)
|
|
10459
10729
|
return null;
|
|
10460
|
-
|
|
10730
|
+
const parsedCoupon = couponSchema.extend({
|
|
10461
10731
|
merchantCoupon: merchantCouponSchema
|
|
10462
|
-
}).
|
|
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;
|
|
10463
10738
|
},
|
|
10464
10739
|
async createMerchantChargeAndPurchase(options) {
|
|
10465
10740
|
const purchaseId = await client.transaction(async (trx) => {
|
|
10466
10741
|
try {
|
|
10467
10742
|
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
|
|
10468
10743
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10469
|
-
where: (0,
|
|
10744
|
+
where: (0, import_drizzle_orm32.eq)(merchantCharge.identifier, stripeChargeId)
|
|
10470
10745
|
}) || null);
|
|
10471
10746
|
const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
|
|
10472
|
-
where: (0,
|
|
10747
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
|
|
10473
10748
|
with: {
|
|
10474
10749
|
user: true,
|
|
10475
10750
|
product: true,
|
|
@@ -10490,13 +10765,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10490
10765
|
merchantCustomerId
|
|
10491
10766
|
});
|
|
10492
10767
|
const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
|
|
10493
|
-
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, [
|
|
10494
10769
|
"Valid",
|
|
10495
10770
|
"Restricted"
|
|
10496
10771
|
]))
|
|
10497
10772
|
}) || null);
|
|
10498
|
-
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0,
|
|
10499
|
-
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;
|
|
10500
10775
|
}));
|
|
10501
10776
|
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
|
|
10502
10777
|
let bulkCouponId = null;
|
|
@@ -10506,10 +10781,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10506
10781
|
if (existingBulkCoupon !== null) {
|
|
10507
10782
|
couponToUpdate = await client.update(coupon).set({
|
|
10508
10783
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
|
|
10509
|
-
}).where((0,
|
|
10784
|
+
}).where((0, import_drizzle_orm32.eq)(coupon.id, bulkCouponId));
|
|
10510
10785
|
} else {
|
|
10511
10786
|
const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
10512
|
-
where: (0,
|
|
10787
|
+
where: (0, import_drizzle_orm32.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10513
10788
|
})) : null;
|
|
10514
10789
|
couponToUpdate = await client.insert(coupon).values({
|
|
10515
10790
|
id: bulkCouponId,
|
|
@@ -10530,10 +10805,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10530
10805
|
merchantAccountId
|
|
10531
10806
|
});
|
|
10532
10807
|
const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10533
|
-
where: (0,
|
|
10808
|
+
where: (0, import_drizzle_orm32.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10534
10809
|
}) : null;
|
|
10535
10810
|
const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10536
|
-
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"))
|
|
10537
10812
|
}) : null;
|
|
10538
10813
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
10539
10814
|
const newPurchase = await client.insert(purchaseTable).values({
|
|
@@ -10564,7 +10839,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10564
10839
|
}
|
|
10565
10840
|
});
|
|
10566
10841
|
const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
10567
|
-
where: (0,
|
|
10842
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId)
|
|
10568
10843
|
}));
|
|
10569
10844
|
if (!parsedPurchase.success) {
|
|
10570
10845
|
console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
|
|
@@ -10609,7 +10884,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10609
10884
|
},
|
|
10610
10885
|
async getCoupon(couponIdOrCode) {
|
|
10611
10886
|
const loadedCoupon = await client.query.coupon.findFirst({
|
|
10612
|
-
where: (0,
|
|
10887
|
+
where: (0, import_drizzle_orm32.or)((0, import_drizzle_orm32.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm32.eq)(coupon.code, couponIdOrCode))
|
|
10613
10888
|
}) || null;
|
|
10614
10889
|
logger.debug("loadedCoupon", {
|
|
10615
10890
|
loadedCoupon
|
|
@@ -10623,7 +10898,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10623
10898
|
let couponData;
|
|
10624
10899
|
try {
|
|
10625
10900
|
couponData = await client.query.coupon.findFirst({
|
|
10626
|
-
where: (0,
|
|
10901
|
+
where: (0, import_drizzle_orm32.eq)(coupon.id, couponId),
|
|
10627
10902
|
with: {
|
|
10628
10903
|
bulkPurchase: true,
|
|
10629
10904
|
bulkCouponPurchases: true
|
|
@@ -10652,8 +10927,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10652
10927
|
},
|
|
10653
10928
|
async getDefaultCoupon(productIds) {
|
|
10654
10929
|
const activeSaleCoupon = await client.query.coupon.findFirst({
|
|
10655
|
-
where: (0,
|
|
10656
|
-
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),
|
|
10657
10932
|
with: {
|
|
10658
10933
|
merchantCoupon: true,
|
|
10659
10934
|
product: true
|
|
@@ -10677,7 +10952,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10677
10952
|
},
|
|
10678
10953
|
async getLessonProgressForUser(userId) {
|
|
10679
10954
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
10680
|
-
where: (0,
|
|
10955
|
+
where: (0, import_drizzle_orm32.eq)(resourceProgress.userId, userId)
|
|
10681
10956
|
});
|
|
10682
10957
|
const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
10683
10958
|
if (!parsed.success) {
|
|
@@ -10687,22 +10962,67 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10687
10962
|
return parsed.data;
|
|
10688
10963
|
},
|
|
10689
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
|
+
];
|
|
10690
10974
|
const module2 = await client.query.contentResource.findFirst({
|
|
10691
|
-
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)),
|
|
10692
10976
|
with: {
|
|
10693
10977
|
resources: {
|
|
10694
|
-
|
|
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)
|
|
10695
10999
|
}
|
|
10696
11000
|
}
|
|
10697
11001
|
});
|
|
10698
11002
|
const parsedModule = ContentResourceSchema.parse(module2);
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
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);
|
|
10702
11022
|
});
|
|
10703
|
-
const
|
|
10704
|
-
if (!
|
|
10705
|
-
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);
|
|
10706
11026
|
return {
|
|
10707
11027
|
completedLessons: [],
|
|
10708
11028
|
nextResource: null,
|
|
@@ -10711,8 +11031,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10711
11031
|
totalLessonsCount: 0
|
|
10712
11032
|
};
|
|
10713
11033
|
}
|
|
11034
|
+
const progressResources = parsedResources.data.filter((r) => {
|
|
11035
|
+
return COUNTABLE_MODULE_RESOURCE_TYPES.includes(r.type);
|
|
11036
|
+
});
|
|
11037
|
+
const totalLessonsCount = progressResources.length;
|
|
10714
11038
|
const user = await client.query.users.findFirst({
|
|
10715
|
-
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)),
|
|
10716
11040
|
with: {
|
|
10717
11041
|
roles: {
|
|
10718
11042
|
with: {
|
|
@@ -10735,7 +11059,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10735
11059
|
nextResource: null,
|
|
10736
11060
|
percentCompleted: 0,
|
|
10737
11061
|
completedLessonsCount: 0,
|
|
10738
|
-
totalLessonsCount
|
|
11062
|
+
totalLessonsCount
|
|
10739
11063
|
};
|
|
10740
11064
|
}
|
|
10741
11065
|
const parsedUser = userSchema.safeParse(user);
|
|
@@ -10746,16 +11070,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10746
11070
|
nextResource: null,
|
|
10747
11071
|
percentCompleted: 0,
|
|
10748
11072
|
completedLessonsCount: 0,
|
|
10749
|
-
totalLessonsCount
|
|
11073
|
+
totalLessonsCount
|
|
10750
11074
|
};
|
|
10751
11075
|
}
|
|
10752
11076
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
10753
|
-
where: (0,
|
|
10754
|
-
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)
|
|
10755
11079
|
});
|
|
10756
|
-
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;
|
|
10757
11083
|
const nextResource = await client.query.contentResource.findFirst({
|
|
10758
|
-
where: (0,
|
|
11084
|
+
where: (0, import_drizzle_orm32.eq)(contentResource.id, nextResourceId)
|
|
10759
11085
|
});
|
|
10760
11086
|
const parsedNextResource = ContentResourceSchema.nullable().optional().default(null).parse(nextResource);
|
|
10761
11087
|
const parsedProgress = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
@@ -10766,16 +11092,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10766
11092
|
nextResource: null,
|
|
10767
11093
|
percentCompleted: 0,
|
|
10768
11094
|
completedLessonsCount: 0,
|
|
10769
|
-
totalLessonsCount
|
|
11095
|
+
totalLessonsCount
|
|
10770
11096
|
};
|
|
10771
11097
|
}
|
|
10772
|
-
const percentCompleted = Math.round(parsedProgress.data.length /
|
|
11098
|
+
const percentCompleted = Math.round(parsedProgress.data.length / parsedResources.data.length * 100);
|
|
10773
11099
|
return {
|
|
10774
11100
|
completedLessons: parsedProgress.data,
|
|
10775
11101
|
nextResource: parsedNextResource,
|
|
10776
11102
|
percentCompleted,
|
|
10777
11103
|
completedLessonsCount: parsedProgress.data.length,
|
|
10778
|
-
totalLessonsCount
|
|
11104
|
+
totalLessonsCount
|
|
10779
11105
|
};
|
|
10780
11106
|
},
|
|
10781
11107
|
getLessonProgresses() {
|
|
@@ -10783,7 +11109,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10783
11109
|
},
|
|
10784
11110
|
async getMerchantCharge(merchantChargeId) {
|
|
10785
11111
|
const mCharge = await client.query.merchantCharge.findFirst({
|
|
10786
|
-
where: (0,
|
|
11112
|
+
where: (0, import_drizzle_orm32.eq)(merchantCharge.id, merchantChargeId)
|
|
10787
11113
|
});
|
|
10788
11114
|
const parsed = merchantChargeSchema.safeParse(mCharge);
|
|
10789
11115
|
if (!parsed.success) {
|
|
@@ -10794,12 +11120,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10794
11120
|
},
|
|
10795
11121
|
async getMerchantCouponsForTypeAndPercent(params) {
|
|
10796
11122
|
return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
|
|
10797
|
-
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()))
|
|
10798
11124
|
}));
|
|
10799
11125
|
},
|
|
10800
11126
|
async getMerchantCouponForTypeAndPercent(params) {
|
|
10801
11127
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
10802
|
-
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()))
|
|
10803
11129
|
});
|
|
10804
11130
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
10805
11131
|
if (parsed.success) {
|
|
@@ -10809,7 +11135,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10809
11135
|
},
|
|
10810
11136
|
async getMerchantCoupon(merchantCouponId) {
|
|
10811
11137
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
10812
|
-
where: (0,
|
|
11138
|
+
where: (0, import_drizzle_orm32.eq)(merchantCoupon.id, merchantCouponId)
|
|
10813
11139
|
});
|
|
10814
11140
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
10815
11141
|
if (parsed.success) {
|
|
@@ -10819,7 +11145,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10819
11145
|
},
|
|
10820
11146
|
async getMerchantProduct(stripeProductId) {
|
|
10821
11147
|
return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
|
|
10822
|
-
where: (0,
|
|
11148
|
+
where: (0, import_drizzle_orm32.eq)(merchantProduct.identifier, stripeProductId)
|
|
10823
11149
|
}));
|
|
10824
11150
|
},
|
|
10825
11151
|
getPrice(productId) {
|
|
@@ -10827,17 +11153,25 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10827
11153
|
},
|
|
10828
11154
|
async getPriceForProduct(productId) {
|
|
10829
11155
|
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
10830
|
-
where: (0,
|
|
11156
|
+
where: (0, import_drizzle_orm32.eq)(prices.productId, productId)
|
|
10831
11157
|
}));
|
|
10832
11158
|
},
|
|
10833
11159
|
async getProduct(productId) {
|
|
10834
11160
|
return productSchema.nullable().parse(await client.query.products.findFirst({
|
|
10835
|
-
where: (0,
|
|
11161
|
+
where: (0, import_drizzle_orm32.eq)(products.id, productId)
|
|
10836
11162
|
}));
|
|
10837
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
|
+
},
|
|
10838
11172
|
async getPurchase(purchaseId) {
|
|
10839
11173
|
const purchase = await client.query.purchases.findFirst({
|
|
10840
|
-
where: (0,
|
|
11174
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId)
|
|
10841
11175
|
});
|
|
10842
11176
|
return purchase ? purchaseSchema.parse(purchase) : null;
|
|
10843
11177
|
},
|
|
@@ -10855,14 +11189,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10855
11189
|
stripeChargeId
|
|
10856
11190
|
});
|
|
10857
11191
|
const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10858
|
-
where: (0,
|
|
11192
|
+
where: (0, import_drizzle_orm32.eq)(merchantCharge.identifier, stripeChargeId)
|
|
10859
11193
|
}) || null);
|
|
10860
11194
|
if (!chargeForPurchase) {
|
|
10861
11195
|
logger.error(new Error("No charge found for purchase"));
|
|
10862
11196
|
return null;
|
|
10863
11197
|
}
|
|
10864
11198
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
10865
|
-
where: (0,
|
|
11199
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
|
|
10866
11200
|
with: {
|
|
10867
11201
|
user: true,
|
|
10868
11202
|
product: true,
|
|
@@ -10876,7 +11210,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10876
11210
|
},
|
|
10877
11211
|
async getPurchaseUserTransferById(options) {
|
|
10878
11212
|
const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
10879
|
-
where: (0,
|
|
11213
|
+
where: (0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id),
|
|
10880
11214
|
with: {
|
|
10881
11215
|
sourceUser: true,
|
|
10882
11216
|
targetUser: true,
|
|
@@ -10891,7 +11225,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10891
11225
|
},
|
|
10892
11226
|
async getPurchaseWithUser(purchaseId) {
|
|
10893
11227
|
const purchaseData = await client.query.purchases.findFirst({
|
|
10894
|
-
where: (0,
|
|
11228
|
+
where: (0, import_drizzle_orm32.eq)(purchaseTable.id, purchaseId),
|
|
10895
11229
|
with: {
|
|
10896
11230
|
user: true
|
|
10897
11231
|
}
|
|
@@ -10915,13 +11249,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10915
11249
|
"Restricted"
|
|
10916
11250
|
];
|
|
10917
11251
|
const userPurchases = await client.query.purchases.findMany({
|
|
10918
|
-
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)),
|
|
10919
11253
|
with: {
|
|
10920
11254
|
user: true,
|
|
10921
11255
|
product: true,
|
|
10922
11256
|
bulkCoupon: true
|
|
10923
11257
|
},
|
|
10924
|
-
orderBy: (0,
|
|
11258
|
+
orderBy: (0, import_drizzle_orm32.asc)(purchaseTable.createdAt)
|
|
10925
11259
|
});
|
|
10926
11260
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
10927
11261
|
if (!parsedPurchases.success) {
|
|
@@ -10937,18 +11271,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10937
11271
|
"Restricted"
|
|
10938
11272
|
];
|
|
10939
11273
|
const userPurchases = await client.query.purchases.findMany({
|
|
10940
|
-
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)),
|
|
10941
11275
|
with: {
|
|
10942
11276
|
user: true,
|
|
10943
11277
|
product: true,
|
|
10944
11278
|
bulkCoupon: true
|
|
10945
11279
|
},
|
|
10946
|
-
orderBy: (0,
|
|
11280
|
+
orderBy: (0, import_drizzle_orm32.asc)(purchaseTable.createdAt)
|
|
10947
11281
|
});
|
|
10948
11282
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
10949
11283
|
const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
|
|
10950
11284
|
const thePurchase = await client.query.purchases.findFirst({
|
|
10951
|
-
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)),
|
|
10952
11286
|
with: {
|
|
10953
11287
|
user: true,
|
|
10954
11288
|
product: true,
|
|
@@ -10969,7 +11303,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10969
11303
|
let availableUpgrades = [];
|
|
10970
11304
|
if (purchaseCanUpgrade) {
|
|
10971
11305
|
availableUpgrades = await client.query.upgradableProducts.findMany({
|
|
10972
|
-
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)))),
|
|
10973
11307
|
with: {
|
|
10974
11308
|
upgradableTo: true,
|
|
10975
11309
|
upgradableFrom: true
|
|
@@ -10977,10 +11311,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10977
11311
|
});
|
|
10978
11312
|
}
|
|
10979
11313
|
const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
|
|
10980
|
-
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, [
|
|
10981
11315
|
"Valid",
|
|
10982
11316
|
"Restricted"
|
|
10983
|
-
]), (0,
|
|
11317
|
+
]), (0, import_drizzle_orm32.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm32.not)((0, import_drizzle_orm32.eq)(purchaseTable.id, parsedPurchase.data.id))),
|
|
10984
11318
|
with: {
|
|
10985
11319
|
user: true,
|
|
10986
11320
|
product: true,
|
|
@@ -10995,7 +11329,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
10995
11329
|
},
|
|
10996
11330
|
async getUserById(userId) {
|
|
10997
11331
|
const user = await client.query.users.findFirst({
|
|
10998
|
-
where: (0,
|
|
11332
|
+
where: (0, import_drizzle_orm32.eq)(users.id, userId),
|
|
10999
11333
|
with: {
|
|
11000
11334
|
roles: {
|
|
11001
11335
|
with: {
|
|
@@ -11017,13 +11351,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11017
11351
|
if (userId === void 0)
|
|
11018
11352
|
return [];
|
|
11019
11353
|
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
11020
|
-
where: (0,
|
|
11354
|
+
where: (0, import_drizzle_orm32.eq)(upgradableProducts.upgradableToId, bundleId)
|
|
11021
11355
|
});
|
|
11022
11356
|
const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
|
|
11023
11357
|
return product.upgradableFromId;
|
|
11024
11358
|
}));
|
|
11025
11359
|
const purchases = await client.query.purchases.findMany({
|
|
11026
|
-
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))
|
|
11027
11361
|
});
|
|
11028
11362
|
const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
|
|
11029
11363
|
return purchase.productId;
|
|
@@ -11031,7 +11365,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11031
11365
|
if (productsPurchased.length === 0)
|
|
11032
11366
|
return [];
|
|
11033
11367
|
const foundPrices = await client.query.prices.findMany({
|
|
11034
|
-
where: (0,
|
|
11368
|
+
where: (0, import_drizzle_orm32.inArray)(prices.productId, productsPurchased)
|
|
11035
11369
|
});
|
|
11036
11370
|
return z.array(priceSchema).parse(foundPrices);
|
|
11037
11371
|
},
|
|
@@ -11040,24 +11374,24 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11040
11374
|
throw new Error("No lessonId provided");
|
|
11041
11375
|
}
|
|
11042
11376
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11043
|
-
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))
|
|
11044
11378
|
});
|
|
11045
11379
|
const now = /* @__PURE__ */ new Date();
|
|
11046
11380
|
if (lessonProgress) {
|
|
11047
11381
|
await client.update(resourceProgress).set({
|
|
11048
11382
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
11049
11383
|
updatedAt: now
|
|
11050
|
-
}).where((0,
|
|
11384
|
+
}).where((0, import_drizzle_orm32.eq)(resourceProgress.resourceId, options.lessonId));
|
|
11051
11385
|
} else {
|
|
11052
11386
|
await client.insert(resourceProgress).values({
|
|
11053
11387
|
userId: options.userId,
|
|
11054
|
-
|
|
11388
|
+
resourceId: options.lessonId,
|
|
11055
11389
|
completedAt: now,
|
|
11056
11390
|
updatedAt: now
|
|
11057
11391
|
});
|
|
11058
11392
|
}
|
|
11059
11393
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11060
|
-
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))
|
|
11061
11395
|
});
|
|
11062
11396
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
11063
11397
|
if (!parsedLessonProgress.success) {
|
|
@@ -11075,16 +11409,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11075
11409
|
async updatePurchaseUserTransferTransferState(options) {
|
|
11076
11410
|
await client.update(purchaseUserTransfer).set({
|
|
11077
11411
|
transferState: options.transferState
|
|
11078
|
-
}).where((0,
|
|
11412
|
+
}).where((0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id));
|
|
11079
11413
|
const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
11080
|
-
where: (0,
|
|
11414
|
+
where: (0, import_drizzle_orm32.eq)(purchaseUserTransfer.id, options.id)
|
|
11081
11415
|
}) || null;
|
|
11082
11416
|
return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
|
|
11083
11417
|
},
|
|
11084
11418
|
addResourceToResource: async function(options) {
|
|
11085
11419
|
const { parentResourceId, childResourceId } = options;
|
|
11086
11420
|
const parentResourceData = await client.query.contentResource.findFirst({
|
|
11087
|
-
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)),
|
|
11088
11422
|
with: {
|
|
11089
11423
|
resources: true
|
|
11090
11424
|
}
|
|
@@ -11096,7 +11430,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11096
11430
|
position: parentResource.resources?.length || 0
|
|
11097
11431
|
});
|
|
11098
11432
|
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
11099
|
-
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)),
|
|
11100
11434
|
with: {
|
|
11101
11435
|
resource: true
|
|
11102
11436
|
}
|
|
@@ -11111,15 +11445,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11111
11445
|
if (!options.id) {
|
|
11112
11446
|
throw new Error("No content resource id.");
|
|
11113
11447
|
}
|
|
11114
|
-
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]);
|
|
11115
11449
|
await client.update(contentResource).set({
|
|
11116
11450
|
fields: {
|
|
11117
11451
|
...currentResource.fields,
|
|
11118
11452
|
...options.fields
|
|
11119
11453
|
}
|
|
11120
|
-
}).where((0,
|
|
11454
|
+
}).where((0, import_drizzle_orm32.eq)(contentResource.id, options.id));
|
|
11121
11455
|
const resource = await client.query.contentResource.findFirst({
|
|
11122
|
-
where: (0,
|
|
11456
|
+
where: (0, import_drizzle_orm32.eq)(contentResource.id, options.id),
|
|
11123
11457
|
with: {
|
|
11124
11458
|
resources: {
|
|
11125
11459
|
with: {
|
|
@@ -11129,12 +11463,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11129
11463
|
with: {
|
|
11130
11464
|
resource: true
|
|
11131
11465
|
},
|
|
11132
|
-
orderBy: (0,
|
|
11466
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11133
11467
|
}
|
|
11134
11468
|
}
|
|
11135
11469
|
}
|
|
11136
11470
|
},
|
|
11137
|
-
orderBy: (0,
|
|
11471
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11138
11472
|
}
|
|
11139
11473
|
}
|
|
11140
11474
|
});
|
|
@@ -11149,7 +11483,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11149
11483
|
if (!id) {
|
|
11150
11484
|
return null;
|
|
11151
11485
|
}
|
|
11152
|
-
const query =
|
|
11486
|
+
const query = import_drizzle_orm32.sql`
|
|
11153
11487
|
SELECT
|
|
11154
11488
|
id as id,
|
|
11155
11489
|
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
@@ -11181,7 +11515,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11181
11515
|
id
|
|
11182
11516
|
});
|
|
11183
11517
|
const resource = await client.query.contentResource.findFirst({
|
|
11184
|
-
where: (0,
|
|
11518
|
+
where: (0, import_drizzle_orm32.eq)(contentResource.id, id),
|
|
11185
11519
|
with: {
|
|
11186
11520
|
resources: {
|
|
11187
11521
|
with: {
|
|
@@ -11191,12 +11525,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11191
11525
|
with: {
|
|
11192
11526
|
resource: true
|
|
11193
11527
|
},
|
|
11194
|
-
orderBy: (0,
|
|
11528
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11195
11529
|
}
|
|
11196
11530
|
}
|
|
11197
11531
|
}
|
|
11198
11532
|
},
|
|
11199
|
-
orderBy: (0,
|
|
11533
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11200
11534
|
}
|
|
11201
11535
|
}
|
|
11202
11536
|
});
|
|
@@ -11209,7 +11543,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11209
11543
|
},
|
|
11210
11544
|
async getContentResource(data) {
|
|
11211
11545
|
const resource = await client.query.contentResource.findFirst({
|
|
11212
|
-
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}`)),
|
|
11213
11547
|
with: {
|
|
11214
11548
|
resources: {
|
|
11215
11549
|
with: {
|
|
@@ -11217,14 +11551,22 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11217
11551
|
with: {
|
|
11218
11552
|
resources: {
|
|
11219
11553
|
with: {
|
|
11220
|
-
resource:
|
|
11554
|
+
resource: {
|
|
11555
|
+
with: {
|
|
11556
|
+
resources: {
|
|
11557
|
+
with: {
|
|
11558
|
+
resource: true
|
|
11559
|
+
}
|
|
11560
|
+
}
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11221
11563
|
},
|
|
11222
|
-
orderBy: (0,
|
|
11564
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11223
11565
|
}
|
|
11224
11566
|
}
|
|
11225
11567
|
}
|
|
11226
11568
|
},
|
|
11227
|
-
orderBy: (0,
|
|
11569
|
+
orderBy: (0, import_drizzle_orm32.asc)(contentResourceResource.position)
|
|
11228
11570
|
}
|
|
11229
11571
|
}
|
|
11230
11572
|
});
|
|
@@ -11242,61 +11584,61 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11242
11584
|
...data,
|
|
11243
11585
|
id
|
|
11244
11586
|
});
|
|
11245
|
-
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]);
|
|
11246
11588
|
} catch (error) {
|
|
11247
11589
|
console.error(error);
|
|
11248
11590
|
throw error;
|
|
11249
11591
|
}
|
|
11250
11592
|
},
|
|
11251
11593
|
async getUser(data) {
|
|
11252
|
-
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;
|
|
11253
11595
|
},
|
|
11254
11596
|
async getUserByEmail(data) {
|
|
11255
|
-
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;
|
|
11256
11598
|
},
|
|
11257
11599
|
async createSession(data) {
|
|
11258
11600
|
await client.insert(sessions).values(data);
|
|
11259
|
-
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]);
|
|
11260
11602
|
},
|
|
11261
11603
|
async getSessionAndUser(data) {
|
|
11262
11604
|
return await client.select({
|
|
11263
11605
|
session: sessions,
|
|
11264
11606
|
user: users
|
|
11265
|
-
}).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;
|
|
11266
11608
|
},
|
|
11267
11609
|
async updateUser(data) {
|
|
11268
11610
|
if (!data.id) {
|
|
11269
11611
|
throw new Error("No user id.");
|
|
11270
11612
|
}
|
|
11271
|
-
await client.update(users).set(data).where((0,
|
|
11272
|
-
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]);
|
|
11273
11615
|
},
|
|
11274
11616
|
async updateSession(data) {
|
|
11275
|
-
await client.update(sessions).set(data).where((0,
|
|
11276
|
-
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]);
|
|
11277
11619
|
},
|
|
11278
11620
|
async linkAccount(rawAccount) {
|
|
11279
11621
|
await client.insert(accounts).values(rawAccount);
|
|
11280
11622
|
},
|
|
11281
11623
|
async getUserByAccount(account) {
|
|
11282
|
-
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;
|
|
11283
11625
|
if (!dbAccount) {
|
|
11284
11626
|
return null;
|
|
11285
11627
|
}
|
|
11286
|
-
return dbAccount.
|
|
11628
|
+
return dbAccount.User;
|
|
11287
11629
|
},
|
|
11288
11630
|
async deleteSession(sessionToken) {
|
|
11289
|
-
const session = await client.select().from(sessions).where((0,
|
|
11290
|
-
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));
|
|
11291
11633
|
return session;
|
|
11292
11634
|
},
|
|
11293
11635
|
async createVerificationToken(token) {
|
|
11294
11636
|
await client.insert(verificationTokens).values(token);
|
|
11295
|
-
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]);
|
|
11296
11638
|
},
|
|
11297
11639
|
async useVerificationToken(token) {
|
|
11298
11640
|
try {
|
|
11299
|
-
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;
|
|
11300
11642
|
if (deletedToken?.createdAt) {
|
|
11301
11643
|
const TIMEOUT_IN_SECONDS = 90;
|
|
11302
11644
|
const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
@@ -11305,7 +11647,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11305
11647
|
const { id: _, ...verificationToken } = token;
|
|
11306
11648
|
return deletedToken;
|
|
11307
11649
|
} else {
|
|
11308
|
-
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)));
|
|
11309
11651
|
return deletedToken;
|
|
11310
11652
|
}
|
|
11311
11653
|
}
|
|
@@ -11315,14 +11657,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
|
|
|
11315
11657
|
}
|
|
11316
11658
|
},
|
|
11317
11659
|
async deleteUser(id) {
|
|
11318
|
-
const user = await client.select().from(users).where((0,
|
|
11319
|
-
await client.delete(users).where((0,
|
|
11320
|
-
await client.delete(sessions).where((0,
|
|
11321
|
-
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));
|
|
11322
11664
|
return user;
|
|
11323
11665
|
},
|
|
11324
11666
|
async unlinkAccount(account) {
|
|
11325
|
-
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)));
|
|
11326
11668
|
return void 0;
|
|
11327
11669
|
}
|
|
11328
11670
|
};
|