@coursebuilder/adapter-drizzle 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BM5UKWXI.js → chunk-27UC2HEP.js} +2 -2
- package/dist/{chunk-QTGVGIRO.js → chunk-6SLQW6OM.js} +2 -2
- package/dist/{chunk-TBM3AK3P.js → chunk-EFVZ7IN4.js} +2 -2
- package/dist/{chunk-FRA4ZCRA.js → chunk-JW2PFVLO.js} +485 -223
- package/dist/{chunk-O6JECJRY.js → chunk-QQA7STVO.js} +2 -2
- package/dist/{chunk-CQNKTFXE.js → chunk-XJXCDN7B.js} +2 -2
- package/dist/{chunk-JZQ666KH.js → chunk-YMFPIZMO.js} +2 -2
- package/dist/{chunk-Z245DYMP.js → chunk-ZYQYJNLK.js} +569 -198
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -12
- package/dist/lib/mysql/index.cjs +1349 -721
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +3147 -126
- package/dist/lib/mysql/index.d.ts +3147 -126
- package/dist/lib/mysql/index.js +10 -8
- package/dist/lib/mysql/schemas/auth/accounts.cjs +87 -71
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +58 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +58 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +79 -63
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +12 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +12 -0
- package/dist/lib/mysql/schemas/auth/device-access-token.js +2 -2
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +81 -65
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/device-verification.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/device-verification.js +2 -2
- package/dist/lib/mysql/schemas/auth/permissions.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/permissions.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +76 -60
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.js +2 -2
- package/dist/lib/mysql/schemas/auth/roles.cjs +76 -60
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/roles.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/roles.js +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.cjs +77 -61
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.d.cts +12 -0
- package/dist/lib/mysql/schemas/auth/sessions.d.ts +12 -0
- package/dist/lib/mysql/schemas/auth/sessions.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +78 -62
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/user-permissions.js +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +82 -66
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +28 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +28 -0
- package/dist/lib/mysql/schemas/auth/user-prefs.js +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +78 -62
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.d.cts +24 -0
- package/dist/lib/mysql/schemas/auth/user-roles.d.ts +24 -0
- package/dist/lib/mysql/schemas/auth/user-roles.js +1 -1
- package/dist/lib/mysql/schemas/auth/users.cjs +179 -159
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +32 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +32 -0
- package/dist/lib/mysql/schemas/auth/users.js +1 -1
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +16 -0
- package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +16 -0
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +57 -51
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +50 -14
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +50 -14
- package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +20 -0
- package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +20 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +32 -0
- package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +32 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +28 -0
- package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +24 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +12 -0
- package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +12 -0
- package/dist/lib/mysql/schemas/commerce/price.cjs +44 -28
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.d.cts +28 -0
- package/dist/lib/mysql/schemas/commerce/price.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/price.js +1 -1
- package/dist/lib/mysql/schemas/commerce/product.cjs +58 -42
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.d.cts +32 -0
- package/dist/lib/mysql/schemas/commerce/product.d.ts +32 -0
- package/dist/lib/mysql/schemas/commerce/product.js +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +106 -90
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +40 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +40 -0
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +2 -2
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +110 -98
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.d.cts +68 -0
- package/dist/lib/mysql/schemas/commerce/purchase.d.ts +68 -0
- package/dist/lib/mysql/schemas/commerce/purchase.js +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +50 -34
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +28 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +28 -0
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +2 -2
- package/dist/lib/mysql/schemas/communication/comment.cjs +82 -66
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.d.cts +28 -0
- package/dist/lib/mysql/schemas/communication/comment.d.ts +28 -0
- package/dist/lib/mysql/schemas/communication/comment.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +28 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +100 -84
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +44 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +44 -0
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +112 -92
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/content-contributions.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/content-contributions.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +49 -29
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-product.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +49 -29
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +28 -0
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +274 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +97 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +97 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +21 -0
- package/dist/lib/mysql/schemas/content/content-resource-tag.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +288 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +130 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +130 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js +21 -0
- package/dist/lib/mysql/schemas/content/content-resource-version.js.map +1 -0
- package/dist/lib/mysql/schemas/content/content-resource.cjs +141 -15
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.d.cts +47 -0
- package/dist/lib/mysql/schemas/content/content-resource.d.ts +47 -0
- package/dist/lib/mysql/schemas/content/content-resource.js +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.d.cts +32 -0
- package/dist/lib/mysql/schemas/content/contribution-types.d.ts +32 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +40 -0
- package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +40 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.cts +24 -0
- package/dist/lib/mysql/schemas/content/resource-progress.d.ts +24 -0
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +241 -0
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.cts +129 -0
- package/dist/lib/mysql/schemas/content/tag-tag.d.ts +129 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js +21 -0
- package/dist/lib/mysql/schemas/content/tag-tag.js.map +1 -0
- package/dist/lib/mysql/schemas/content/tag.cjs +263 -0
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -0
- package/dist/lib/mysql/schemas/content/tag.d.cts +114 -0
- package/dist/lib/mysql/schemas/content/tag.d.ts +114 -0
- package/dist/lib/mysql/schemas/content/tag.js +21 -0
- package/dist/lib/mysql/schemas/content/tag.js.map +1 -0
- package/dist/lib/mysql/utils.d.cts +1 -0
- package/dist/lib/mysql/utils.d.ts +1 -0
- package/dist/lib/utils.d.cts +2 -0
- package/dist/lib/utils.d.ts +2 -0
- package/package.json +8 -6
- package/src/index.ts +14 -4
- package/src/lib/mysql/index.ts +718 -182
- package/src/lib/mysql/schemas/commerce/coupon.ts +3 -9
- package/src/lib/mysql/schemas/content/content-resource-tag.ts +59 -0
- package/src/lib/mysql/schemas/content/content-resource-version.ts +69 -0
- package/src/lib/mysql/schemas/content/content-resource.ts +17 -0
- package/src/lib/mysql/schemas/content/tag-tag.ts +59 -0
- package/src/lib/mysql/schemas/content/tag.ts +48 -0
package/dist/lib/mysql/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
9
|
var __export = (target, all) => {
|
|
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc2) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
|
|
21
31
|
// src/lib/mysql/index.ts
|
|
@@ -23,12 +33,15 @@ var mysql_exports = {};
|
|
|
23
33
|
__export(mysql_exports, {
|
|
24
34
|
createTables: () => createTables,
|
|
25
35
|
getCourseBuilderSchema: () => getCourseBuilderSchema,
|
|
36
|
+
guid: () => guid,
|
|
26
37
|
mySqlDrizzleAdapter: () => mySqlDrizzleAdapter
|
|
27
38
|
});
|
|
28
39
|
module.exports = __toCommonJS(mysql_exports);
|
|
40
|
+
var import_slugify = __toESM(require("@sindresorhus/slugify"), 1);
|
|
29
41
|
var import_date_fns2 = require("date-fns");
|
|
30
|
-
var
|
|
31
|
-
var
|
|
42
|
+
var import_drizzle_orm36 = require("drizzle-orm");
|
|
43
|
+
var import_mysql_core41 = require("drizzle-orm/mysql-core");
|
|
44
|
+
var import_nanoid = require("nanoid");
|
|
32
45
|
var import_uuid = require("uuid");
|
|
33
46
|
|
|
34
47
|
// ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
@@ -185,8 +198,8 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
185
198
|
"not_finite"
|
|
186
199
|
]);
|
|
187
200
|
var quotelessJson = /* @__PURE__ */ __name((obj) => {
|
|
188
|
-
const
|
|
189
|
-
return
|
|
201
|
+
const json16 = JSON.stringify(obj, null, 2);
|
|
202
|
+
return json16.replace(/"([^"]+)":/g, "$1:");
|
|
190
203
|
}, "quotelessJson");
|
|
191
204
|
var _ZodError = class _ZodError extends Error {
|
|
192
205
|
constructor(issues) {
|
|
@@ -2305,10 +2318,10 @@ var _ZodObject = class _ZodObject extends ZodType {
|
|
|
2305
2318
|
// }) as any;
|
|
2306
2319
|
// return merged;
|
|
2307
2320
|
// }
|
|
2308
|
-
catchall(
|
|
2321
|
+
catchall(index29) {
|
|
2309
2322
|
return new _ZodObject({
|
|
2310
2323
|
...this._def,
|
|
2311
|
-
catchall:
|
|
2324
|
+
catchall: index29
|
|
2312
2325
|
});
|
|
2313
2326
|
}
|
|
2314
2327
|
pick(mask) {
|
|
@@ -2623,9 +2636,9 @@ function mergeValues(a, b) {
|
|
|
2623
2636
|
return { valid: false };
|
|
2624
2637
|
}
|
|
2625
2638
|
const newArray = [];
|
|
2626
|
-
for (let
|
|
2627
|
-
const itemA = a[
|
|
2628
|
-
const itemB = b[
|
|
2639
|
+
for (let index29 = 0; index29 < a.length; index29++) {
|
|
2640
|
+
const itemA = a[index29];
|
|
2641
|
+
const itemB = b[index29];
|
|
2629
2642
|
const sharedValue = mergeValues(itemA, itemB);
|
|
2630
2643
|
if (!sharedValue.valid) {
|
|
2631
2644
|
return { valid: false };
|
|
@@ -2837,10 +2850,10 @@ var _ZodMap = class _ZodMap extends ZodType {
|
|
|
2837
2850
|
}
|
|
2838
2851
|
const keyType = this._def.keyType;
|
|
2839
2852
|
const valueType = this._def.valueType;
|
|
2840
|
-
const pairs = [...ctx.data.entries()].map(([key, value],
|
|
2853
|
+
const pairs = [...ctx.data.entries()].map(([key, value], index29) => {
|
|
2841
2854
|
return {
|
|
2842
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
|
2843
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [
|
|
2855
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index29, "key"])),
|
|
2856
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index29, "value"]))
|
|
2844
2857
|
};
|
|
2845
2858
|
});
|
|
2846
2859
|
if (ctx.common.async) {
|
|
@@ -4033,8 +4046,8 @@ var ZodIssueCode2 = util2.arrayToEnum([
|
|
|
4033
4046
|
"not_finite"
|
|
4034
4047
|
]);
|
|
4035
4048
|
var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
|
|
4036
|
-
const
|
|
4037
|
-
return
|
|
4049
|
+
const json16 = JSON.stringify(obj, null, 2);
|
|
4050
|
+
return json16.replace(/"([^"]+)":/g, "$1:");
|
|
4038
4051
|
}, "quotelessJson");
|
|
4039
4052
|
var _a;
|
|
4040
4053
|
var _ZodError2 = (_a = class extends Error {
|
|
@@ -6338,10 +6351,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
|
|
|
6338
6351
|
// }) as any;
|
|
6339
6352
|
// return merged;
|
|
6340
6353
|
// }
|
|
6341
|
-
catchall(
|
|
6354
|
+
catchall(index29) {
|
|
6342
6355
|
return new _a18({
|
|
6343
6356
|
...this._def,
|
|
6344
|
-
catchall:
|
|
6357
|
+
catchall: index29
|
|
6345
6358
|
});
|
|
6346
6359
|
}
|
|
6347
6360
|
pick(mask) {
|
|
@@ -6683,9 +6696,9 @@ function mergeValues2(a, b) {
|
|
|
6683
6696
|
};
|
|
6684
6697
|
}
|
|
6685
6698
|
const newArray = [];
|
|
6686
|
-
for (let
|
|
6687
|
-
const itemA = a[
|
|
6688
|
-
const itemB = b[
|
|
6699
|
+
for (let index29 = 0; index29 < a.length; index29++) {
|
|
6700
|
+
const itemA = a[index29];
|
|
6701
|
+
const itemB = b[index29];
|
|
6689
6702
|
const sharedValue = mergeValues2(itemA, itemB);
|
|
6690
6703
|
if (!sharedValue.valid) {
|
|
6691
6704
|
return {
|
|
@@ -6919,14 +6932,14 @@ var _ZodMap2 = (_a24 = class extends ZodType2 {
|
|
|
6919
6932
|
const valueType = this._def.valueType;
|
|
6920
6933
|
const pairs = [
|
|
6921
6934
|
...ctx.data.entries()
|
|
6922
|
-
].map(([key, value],
|
|
6935
|
+
].map(([key, value], index29) => {
|
|
6923
6936
|
return {
|
|
6924
6937
|
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
|
|
6925
|
-
|
|
6938
|
+
index29,
|
|
6926
6939
|
"key"
|
|
6927
6940
|
])),
|
|
6928
6941
|
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
|
|
6929
|
-
|
|
6942
|
+
index29,
|
|
6930
6943
|
"value"
|
|
6931
6944
|
]))
|
|
6932
6945
|
};
|
|
@@ -8044,6 +8057,29 @@ var z2 = /* @__PURE__ */ Object.freeze({
|
|
|
8044
8057
|
ZodError: ZodError2
|
|
8045
8058
|
});
|
|
8046
8059
|
|
|
8060
|
+
// ../core/dist/chunk-CMH4QQ3R.js
|
|
8061
|
+
var VideoResourceSchema = z2.object({
|
|
8062
|
+
id: z2.string(),
|
|
8063
|
+
updatedAt: z2.coerce.date().optional(),
|
|
8064
|
+
createdAt: z2.coerce.date().optional(),
|
|
8065
|
+
title: z2.string().optional().nullable(),
|
|
8066
|
+
duration: z2.number().optional().nullable(),
|
|
8067
|
+
muxPlaybackId: z2.string().optional().nullable(),
|
|
8068
|
+
muxAssetId: z2.string().optional().nullable(),
|
|
8069
|
+
transcript: z2.string().optional().nullable(),
|
|
8070
|
+
transcriptWithScreenshots: z2.string().optional().nullable(),
|
|
8071
|
+
srt: z2.string().optional().nullable(),
|
|
8072
|
+
wordLevelSrt: z2.string().optional().nullable(),
|
|
8073
|
+
state: z2.enum([
|
|
8074
|
+
"new",
|
|
8075
|
+
"processing",
|
|
8076
|
+
"preparing",
|
|
8077
|
+
"ready",
|
|
8078
|
+
"errored",
|
|
8079
|
+
"deleted"
|
|
8080
|
+
])
|
|
8081
|
+
});
|
|
8082
|
+
|
|
8047
8083
|
// ../core/dist/chunk-CHYUPSYW.js
|
|
8048
8084
|
var userSchema = z2.object({
|
|
8049
8085
|
id: z2.string().max(255),
|
|
@@ -8078,25 +8114,26 @@ var priceSchema = z2.object({
|
|
|
8078
8114
|
fields: z2.record(z2.any()).default({})
|
|
8079
8115
|
});
|
|
8080
8116
|
|
|
8081
|
-
// ../core/dist/chunk-
|
|
8117
|
+
// ../core/dist/chunk-6BXXN6IV.js
|
|
8082
8118
|
var ContentResourceResourceSchema = z2.object({
|
|
8083
8119
|
resourceId: z2.string(),
|
|
8084
8120
|
resourceOfId: z2.string(),
|
|
8085
8121
|
position: z2.number().default(0),
|
|
8086
8122
|
metadata: z2.record(z2.string(), z2.any()).default({}).nullable(),
|
|
8087
|
-
createdAt: z2.date().nullable(),
|
|
8088
|
-
updatedAt: z2.date().nullable(),
|
|
8089
|
-
deletedAt: z2.date().nullable(),
|
|
8123
|
+
createdAt: z2.coerce.date().nullable(),
|
|
8124
|
+
updatedAt: z2.coerce.date().nullable(),
|
|
8125
|
+
deletedAt: z2.coerce.date().nullable(),
|
|
8090
8126
|
resource: z2.any()
|
|
8091
8127
|
});
|
|
8092
8128
|
var ContentResourceSchema = z2.object({
|
|
8093
8129
|
id: z2.string(),
|
|
8094
8130
|
type: z2.string(),
|
|
8095
8131
|
createdById: z2.string(),
|
|
8132
|
+
currentVersionId: z2.string().nullish(),
|
|
8096
8133
|
fields: z2.record(z2.string(), z2.any()).default({}).nullable().optional(),
|
|
8097
|
-
createdAt: z2.date().nullable(),
|
|
8098
|
-
updatedAt: z2.date().nullable(),
|
|
8099
|
-
deletedAt: z2.date().nullable(),
|
|
8134
|
+
createdAt: z2.coerce.date().nullable(),
|
|
8135
|
+
updatedAt: z2.coerce.date().nullable(),
|
|
8136
|
+
deletedAt: z2.coerce.date().nullable(),
|
|
8100
8137
|
resources: z2.array(ContentResourceResourceSchema).default([]).nullable()
|
|
8101
8138
|
});
|
|
8102
8139
|
var ContentResourceProductSchema = z2.object({
|
|
@@ -8104,9 +8141,9 @@ var ContentResourceProductSchema = z2.object({
|
|
|
8104
8141
|
productId: z2.string(),
|
|
8105
8142
|
position: z2.number().default(0),
|
|
8106
8143
|
metadata: z2.record(z2.string(), z2.any()).default({}).nullable(),
|
|
8107
|
-
createdAt: z2.date().nullable(),
|
|
8108
|
-
updatedAt: z2.date().nullable(),
|
|
8109
|
-
deletedAt: z2.date().nullable(),
|
|
8144
|
+
createdAt: z2.coerce.date().nullable(),
|
|
8145
|
+
updatedAt: z2.coerce.date().nullable(),
|
|
8146
|
+
deletedAt: z2.coerce.date().nullable(),
|
|
8110
8147
|
resource: z2.any(),
|
|
8111
8148
|
product: z2.any()
|
|
8112
8149
|
});
|
|
@@ -8122,7 +8159,7 @@ var ResourceVisibilitySchema = z2.union([
|
|
|
8122
8159
|
z2.literal("unlisted")
|
|
8123
8160
|
]);
|
|
8124
8161
|
|
|
8125
|
-
// ../core/dist/chunk-
|
|
8162
|
+
// ../core/dist/chunk-LVVTCZ7P.js
|
|
8126
8163
|
var productSchema = z2.object({
|
|
8127
8164
|
id: z2.string().max(191),
|
|
8128
8165
|
name: z2.string().max(191),
|
|
@@ -8133,10 +8170,10 @@ var productSchema = z2.object({
|
|
|
8133
8170
|
]).default("self-paced"),
|
|
8134
8171
|
fields: z2.object({
|
|
8135
8172
|
body: z2.string().nullable().optional(),
|
|
8136
|
-
description: z2.string().
|
|
8173
|
+
description: z2.string().nullish(),
|
|
8137
8174
|
slug: z2.string(),
|
|
8138
8175
|
image: z2.object({
|
|
8139
|
-
url: z2.string()
|
|
8176
|
+
url: z2.string(),
|
|
8140
8177
|
alt: z2.string().optional().nullable(),
|
|
8141
8178
|
width: z2.number().optional().nullable(),
|
|
8142
8179
|
height: z2.number().optional().nullable()
|
|
@@ -8154,14 +8191,19 @@ var productSchema = z2.object({
|
|
|
8154
8191
|
"unlisted"
|
|
8155
8192
|
]).default("unlisted")
|
|
8156
8193
|
}),
|
|
8157
|
-
createdAt: z2.date().nullable(),
|
|
8194
|
+
createdAt: z2.coerce.date().nullable(),
|
|
8158
8195
|
status: z2.number().int().default(0),
|
|
8159
8196
|
quantityAvailable: z2.number().int().default(-1),
|
|
8160
8197
|
price: priceSchema.nullable().optional(),
|
|
8161
8198
|
resources: z2.array(ContentResourceProductSchema).default([]).nullable()
|
|
8162
8199
|
});
|
|
8200
|
+
var NewProductSchema = z2.object({
|
|
8201
|
+
name: z2.string().min(2).max(90),
|
|
8202
|
+
quantityAvailable: z2.coerce.number().default(-1),
|
|
8203
|
+
price: z2.coerce.number().gte(0).default(0)
|
|
8204
|
+
});
|
|
8163
8205
|
|
|
8164
|
-
// ../core/dist/chunk-
|
|
8206
|
+
// ../core/dist/chunk-RCFZC3SN.js
|
|
8165
8207
|
var couponSchema = z2.object({
|
|
8166
8208
|
id: z2.string(),
|
|
8167
8209
|
code: z2.string().max(191).optional().nullable(),
|
|
@@ -8178,11 +8220,12 @@ var couponSchema = z2.object({
|
|
|
8178
8220
|
return decimalPlaces <= 2;
|
|
8179
8221
|
}),
|
|
8180
8222
|
restrictedToProductId: z2.string().max(191).optional().nullable(),
|
|
8181
|
-
|
|
8182
|
-
|
|
8223
|
+
bulkPurchases: z2.array(z2.any()).default([]),
|
|
8224
|
+
redeemedBulkCouponPurchases: z2.array(z2.any()).default([]),
|
|
8225
|
+
bulkPurchaseId: z2.string().max(191).optional().nullable()
|
|
8183
8226
|
});
|
|
8184
8227
|
|
|
8185
|
-
// ../core/dist/chunk-
|
|
8228
|
+
// ../core/dist/chunk-ACXDXYNY.js
|
|
8186
8229
|
var purchaseSchema = z2.object({
|
|
8187
8230
|
id: z2.string().max(191),
|
|
8188
8231
|
userId: z2.string().max(191).optional().nullable(),
|
|
@@ -8231,18 +8274,15 @@ var purchaseUserTransferSchema = z2.object({
|
|
|
8231
8274
|
completedAt: z2.date().nullable()
|
|
8232
8275
|
});
|
|
8233
8276
|
|
|
8234
|
-
// ../core/dist/chunk-
|
|
8277
|
+
// ../core/dist/chunk-6BTTEQD2.js
|
|
8235
8278
|
var resourceProgressSchema = z2.object({
|
|
8236
8279
|
userId: z2.string().max(191),
|
|
8237
8280
|
resourceId: z2.string().max(191).optional().nullable(),
|
|
8238
|
-
|
|
8239
|
-
completedAt: z2.date().nullable(),
|
|
8240
|
-
updatedAt: z2.date().nullable(),
|
|
8241
|
-
createdAt: z2.date().nullable()
|
|
8281
|
+
completedAt: z2.date().nullable()
|
|
8242
8282
|
});
|
|
8243
8283
|
var moduleProgressSchema = z2.object({
|
|
8244
8284
|
completedLessons: z2.array(resourceProgressSchema),
|
|
8245
|
-
nextResource: ContentResourceSchema.nullable(),
|
|
8285
|
+
nextResource: ContentResourceSchema.partial().nullable(),
|
|
8246
8286
|
percentCompleted: z2.number().default(0),
|
|
8247
8287
|
completedLessonsCount: z2.number().default(0),
|
|
8248
8288
|
totalLessonsCount: z2.number().default(0)
|
|
@@ -8259,29 +8299,6 @@ var upgradableProductSchema = z2.object({
|
|
|
8259
8299
|
deletedAt: z2.date().nullable()
|
|
8260
8300
|
});
|
|
8261
8301
|
|
|
8262
|
-
// ../core/dist/chunk-5QZXOTEH.js
|
|
8263
|
-
var VideoResourceSchema = z2.object({
|
|
8264
|
-
id: z2.string(),
|
|
8265
|
-
updatedAt: z2.string().optional(),
|
|
8266
|
-
createdAt: z2.string().optional(),
|
|
8267
|
-
title: z2.string().optional().nullable(),
|
|
8268
|
-
duration: z2.number().optional().nullable(),
|
|
8269
|
-
muxPlaybackId: z2.string().optional().nullable(),
|
|
8270
|
-
muxAssetId: z2.string().optional().nullable(),
|
|
8271
|
-
transcript: z2.string().optional().nullable(),
|
|
8272
|
-
transcriptWithScreenshots: z2.string().optional().nullable(),
|
|
8273
|
-
srt: z2.string().optional().nullable(),
|
|
8274
|
-
wordLevelSrt: z2.string().optional().nullable(),
|
|
8275
|
-
state: z2.enum([
|
|
8276
|
-
"new",
|
|
8277
|
-
"processing",
|
|
8278
|
-
"preparing",
|
|
8279
|
-
"ready",
|
|
8280
|
-
"errored",
|
|
8281
|
-
"deleted"
|
|
8282
|
-
])
|
|
8283
|
-
});
|
|
8284
|
-
|
|
8285
8302
|
// ../core/dist/chunk-EDDT2FFU.js
|
|
8286
8303
|
var merchantCustomerSchema = z2.object({
|
|
8287
8304
|
id: z2.string().max(191),
|
|
@@ -8477,20 +8494,20 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
|
|
|
8477
8494
|
}, "validateCoupon");
|
|
8478
8495
|
|
|
8479
8496
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
8480
|
-
var
|
|
8481
|
-
var
|
|
8497
|
+
var import_drizzle_orm27 = require("drizzle-orm");
|
|
8498
|
+
var import_mysql_core31 = require("drizzle-orm/mysql-core");
|
|
8482
8499
|
|
|
8483
8500
|
// src/lib/mysql/schemas/auth/users.ts
|
|
8484
|
-
var
|
|
8485
|
-
var
|
|
8501
|
+
var import_drizzle_orm26 = require("drizzle-orm");
|
|
8502
|
+
var import_mysql_core30 = require("drizzle-orm/mysql-core");
|
|
8486
8503
|
|
|
8487
8504
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
8488
|
-
var
|
|
8489
|
-
var
|
|
8505
|
+
var import_drizzle_orm18 = require("drizzle-orm");
|
|
8506
|
+
var import_mysql_core20 = require("drizzle-orm/mysql-core");
|
|
8490
8507
|
|
|
8491
8508
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
8492
|
-
var
|
|
8493
|
-
var
|
|
8509
|
+
var import_drizzle_orm14 = require("drizzle-orm");
|
|
8510
|
+
var import_mysql_core15 = require("drizzle-orm/mysql-core");
|
|
8494
8511
|
|
|
8495
8512
|
// src/lib/mysql/schemas/commerce/merchant-coupon.ts
|
|
8496
8513
|
var import_mysql_core = require("drizzle-orm/mysql-core");
|
|
@@ -8528,16 +8545,16 @@ function getMerchantCouponSchema(mysqlTable) {
|
|
|
8528
8545
|
__name(getMerchantCouponSchema, "getMerchantCouponSchema");
|
|
8529
8546
|
|
|
8530
8547
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8531
|
-
var
|
|
8532
|
-
var
|
|
8548
|
+
var import_drizzle_orm13 = require("drizzle-orm");
|
|
8549
|
+
var import_mysql_core14 = require("drizzle-orm/mysql-core");
|
|
8533
8550
|
|
|
8534
8551
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8535
|
-
var
|
|
8536
|
-
var
|
|
8552
|
+
var import_drizzle_orm9 = require("drizzle-orm");
|
|
8553
|
+
var import_mysql_core10 = require("drizzle-orm/mysql-core");
|
|
8537
8554
|
|
|
8538
8555
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8539
|
-
var
|
|
8540
|
-
var
|
|
8556
|
+
var import_drizzle_orm8 = require("drizzle-orm");
|
|
8557
|
+
var import_mysql_core9 = require("drizzle-orm/mysql-core");
|
|
8541
8558
|
|
|
8542
8559
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
8543
8560
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
@@ -8718,19 +8735,27 @@ function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
|
8718
8735
|
}
|
|
8719
8736
|
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
8720
8737
|
|
|
8721
|
-
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8738
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
8739
|
+
var import_drizzle_orm6 = require("drizzle-orm");
|
|
8740
|
+
var import_mysql_core7 = require("drizzle-orm/mysql-core");
|
|
8741
|
+
|
|
8742
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
8743
|
+
var import_drizzle_orm5 = require("drizzle-orm");
|
|
8744
|
+
var import_mysql_core6 = require("drizzle-orm/mysql-core");
|
|
8745
|
+
|
|
8746
|
+
// src/lib/mysql/schemas/content/tag-tag.ts
|
|
8747
|
+
var import_drizzle_orm4 = require("drizzle-orm");
|
|
8748
|
+
var import_mysql_core5 = require("drizzle-orm/mysql-core");
|
|
8749
|
+
function getTagTagSchema(mysqlTable) {
|
|
8750
|
+
return mysqlTable("TagTag", {
|
|
8751
|
+
parentTagId: (0, import_mysql_core5.varchar)("parentTagId", {
|
|
8728
8752
|
length: 255
|
|
8729
8753
|
}).notNull(),
|
|
8730
|
-
|
|
8754
|
+
childTagId: (0, import_mysql_core5.varchar)("childTagId", {
|
|
8731
8755
|
length: 255
|
|
8732
8756
|
}).notNull(),
|
|
8733
|
-
|
|
8757
|
+
position: (0, import_mysql_core5.double)("position").notNull().default(0),
|
|
8758
|
+
metadata: (0, import_mysql_core5.json)("metadata").$type().default({}),
|
|
8734
8759
|
createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
|
|
8735
8760
|
mode: "date",
|
|
8736
8761
|
fsp: 3
|
|
@@ -8743,10 +8768,248 @@ function getContentResourceSchema(mysqlTable) {
|
|
|
8743
8768
|
mode: "date",
|
|
8744
8769
|
fsp: 3
|
|
8745
8770
|
})
|
|
8771
|
+
}, (tt) => ({
|
|
8772
|
+
pk: (0, import_mysql_core5.primaryKey)({
|
|
8773
|
+
columns: [
|
|
8774
|
+
tt.parentTagId,
|
|
8775
|
+
tt.childTagId
|
|
8776
|
+
]
|
|
8777
|
+
}),
|
|
8778
|
+
parentTagIdIdx: (0, import_mysql_core5.index)("parentTagId_idx").on(tt.parentTagId),
|
|
8779
|
+
childTagIdIdx: (0, import_mysql_core5.index)("childTagId_idx").on(tt.childTagId),
|
|
8780
|
+
positionIdx: (0, import_mysql_core5.index)("position_idx").on(tt.position)
|
|
8781
|
+
}));
|
|
8782
|
+
}
|
|
8783
|
+
__name(getTagTagSchema, "getTagTagSchema");
|
|
8784
|
+
function getTagTagRelationsSchema(mysqlTable) {
|
|
8785
|
+
const tag = getTagSchema(mysqlTable);
|
|
8786
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
8787
|
+
return (0, import_drizzle_orm4.relations)(tagTag, ({ one }) => ({
|
|
8788
|
+
parentTag: one(tag, {
|
|
8789
|
+
fields: [
|
|
8790
|
+
tagTag.parentTagId
|
|
8791
|
+
],
|
|
8792
|
+
references: [
|
|
8793
|
+
tag.id
|
|
8794
|
+
],
|
|
8795
|
+
relationName: "parentTag"
|
|
8796
|
+
}),
|
|
8797
|
+
childTag: one(tag, {
|
|
8798
|
+
fields: [
|
|
8799
|
+
tagTag.childTagId
|
|
8800
|
+
],
|
|
8801
|
+
references: [
|
|
8802
|
+
tag.id
|
|
8803
|
+
],
|
|
8804
|
+
relationName: "childTag"
|
|
8805
|
+
})
|
|
8806
|
+
}));
|
|
8807
|
+
}
|
|
8808
|
+
__name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
|
|
8809
|
+
|
|
8810
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
8811
|
+
function getTagSchema(mysqlTable) {
|
|
8812
|
+
return mysqlTable("Tag", {
|
|
8813
|
+
id: (0, import_mysql_core6.varchar)("id", {
|
|
8814
|
+
length: 255
|
|
8815
|
+
}).notNull().primaryKey(),
|
|
8816
|
+
type: (0, import_mysql_core6.varchar)("type", {
|
|
8817
|
+
length: 255
|
|
8818
|
+
}).notNull(),
|
|
8819
|
+
fields: (0, import_mysql_core6.json)("fields").$type().default({}),
|
|
8820
|
+
createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
|
|
8821
|
+
mode: "date",
|
|
8822
|
+
fsp: 3
|
|
8823
|
+
}).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
|
|
8824
|
+
updatedAt: (0, import_mysql_core6.timestamp)("updatedAt", {
|
|
8825
|
+
mode: "date",
|
|
8826
|
+
fsp: 3
|
|
8827
|
+
}).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`),
|
|
8828
|
+
deletedAt: (0, import_mysql_core6.timestamp)("deletedAt", {
|
|
8829
|
+
mode: "date",
|
|
8830
|
+
fsp: 3
|
|
8831
|
+
})
|
|
8832
|
+
}, (t) => ({
|
|
8833
|
+
typeIdx: (0, import_mysql_core6.index)("type_idx").on(t.type)
|
|
8834
|
+
}));
|
|
8835
|
+
}
|
|
8836
|
+
__name(getTagSchema, "getTagSchema");
|
|
8837
|
+
function getTagRelationsSchema(mysqlTable) {
|
|
8838
|
+
const tag = getTagSchema(mysqlTable);
|
|
8839
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
8840
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
8841
|
+
return (0, import_drizzle_orm5.relations)(tag, ({ many }) => ({
|
|
8842
|
+
resources: many(contentResourceTag, {
|
|
8843
|
+
relationName: "contentResource"
|
|
8844
|
+
}),
|
|
8845
|
+
parentTags: many(tagTag, {
|
|
8846
|
+
relationName: "childTag"
|
|
8847
|
+
}),
|
|
8848
|
+
childTags: many(tagTag, {
|
|
8849
|
+
relationName: "parentTag"
|
|
8850
|
+
})
|
|
8851
|
+
}));
|
|
8852
|
+
}
|
|
8853
|
+
__name(getTagRelationsSchema, "getTagRelationsSchema");
|
|
8854
|
+
|
|
8855
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
8856
|
+
function getContentResourceTagSchema(mysqlTable) {
|
|
8857
|
+
return mysqlTable("ContentResourceTag", {
|
|
8858
|
+
contentResourceId: (0, import_mysql_core7.varchar)("contentResourceId", {
|
|
8859
|
+
length: 255
|
|
8860
|
+
}).notNull(),
|
|
8861
|
+
tagId: (0, import_mysql_core7.varchar)("tagId", {
|
|
8862
|
+
length: 255
|
|
8863
|
+
}).notNull(),
|
|
8864
|
+
position: (0, import_mysql_core7.double)("position").notNull().default(0),
|
|
8865
|
+
createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
|
|
8866
|
+
mode: "date",
|
|
8867
|
+
fsp: 3
|
|
8868
|
+
}).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`),
|
|
8869
|
+
updatedAt: (0, import_mysql_core7.timestamp)("updatedAt", {
|
|
8870
|
+
mode: "date",
|
|
8871
|
+
fsp: 3
|
|
8872
|
+
}).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`)
|
|
8873
|
+
}, (crt) => ({
|
|
8874
|
+
pk: (0, import_mysql_core7.primaryKey)({
|
|
8875
|
+
columns: [
|
|
8876
|
+
crt.contentResourceId,
|
|
8877
|
+
crt.tagId
|
|
8878
|
+
]
|
|
8879
|
+
}),
|
|
8880
|
+
contentResourceIdIdx: (0, import_mysql_core7.index)("contentResourceId_idx").on(crt.contentResourceId),
|
|
8881
|
+
tagIdIdx: (0, import_mysql_core7.index)("tagId_idx").on(crt.tagId),
|
|
8882
|
+
positionIdx: (0, import_mysql_core7.index)("position_idx").on(crt.position)
|
|
8883
|
+
}));
|
|
8884
|
+
}
|
|
8885
|
+
__name(getContentResourceTagSchema, "getContentResourceTagSchema");
|
|
8886
|
+
function getContentResourceTagRelationsSchema(mysqlTable) {
|
|
8887
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8888
|
+
const tag = getTagSchema(mysqlTable);
|
|
8889
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
8890
|
+
return (0, import_drizzle_orm6.relations)(contentResourceTag, ({ one }) => ({
|
|
8891
|
+
contentResource: one(contentResource, {
|
|
8892
|
+
fields: [
|
|
8893
|
+
contentResourceTag.contentResourceId
|
|
8894
|
+
],
|
|
8895
|
+
references: [
|
|
8896
|
+
contentResource.id
|
|
8897
|
+
],
|
|
8898
|
+
relationName: "contentResource"
|
|
8899
|
+
}),
|
|
8900
|
+
tag: one(tag, {
|
|
8901
|
+
fields: [
|
|
8902
|
+
contentResourceTag.tagId
|
|
8903
|
+
],
|
|
8904
|
+
references: [
|
|
8905
|
+
tag.id
|
|
8906
|
+
],
|
|
8907
|
+
relationName: "tag"
|
|
8908
|
+
})
|
|
8909
|
+
}));
|
|
8910
|
+
}
|
|
8911
|
+
__name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
|
|
8912
|
+
|
|
8913
|
+
// src/lib/mysql/schemas/content/content-resource-version.ts
|
|
8914
|
+
var import_drizzle_orm7 = require("drizzle-orm");
|
|
8915
|
+
var import_mysql_core8 = require("drizzle-orm/mysql-core");
|
|
8916
|
+
function getContentResourceVersionSchema(mysqlTable) {
|
|
8917
|
+
return mysqlTable("ContentResourceVersion", {
|
|
8918
|
+
id: (0, import_mysql_core8.varchar)("id", {
|
|
8919
|
+
length: 255
|
|
8920
|
+
}).notNull().primaryKey(),
|
|
8921
|
+
resourceId: (0, import_mysql_core8.varchar)("resourceId", {
|
|
8922
|
+
length: 255
|
|
8923
|
+
}).notNull(),
|
|
8924
|
+
parentVersionId: (0, import_mysql_core8.varchar)("parentVersionId", {
|
|
8925
|
+
length: 255
|
|
8926
|
+
}),
|
|
8927
|
+
versionNumber: (0, import_mysql_core8.int)("versionNumber").notNull(),
|
|
8928
|
+
fields: (0, import_mysql_core8.json)("fields").$type().default({}),
|
|
8929
|
+
createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
|
|
8930
|
+
mode: "date",
|
|
8931
|
+
fsp: 3
|
|
8932
|
+
}).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`),
|
|
8933
|
+
createdById: (0, import_mysql_core8.varchar)("createdById", {
|
|
8934
|
+
length: 255
|
|
8935
|
+
}).notNull()
|
|
8936
|
+
}, (crv) => ({
|
|
8937
|
+
resourceIdIdx: (0, import_mysql_core8.index)("resourceId_idx").on(crv.resourceId),
|
|
8938
|
+
parentVersionIdIdx: (0, import_mysql_core8.index)("parentVersionId_idx").on(crv.parentVersionId),
|
|
8939
|
+
resourceIdVersionNumberIdx: (0, import_mysql_core8.index)("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
|
|
8940
|
+
uniqueResourceVersion: (0, import_mysql_core8.unique)("uq_resource_version_number").on(crv.resourceId, crv.versionNumber)
|
|
8941
|
+
}));
|
|
8942
|
+
}
|
|
8943
|
+
__name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
|
|
8944
|
+
function getContentResourceVersionRelationsSchema(mysqlTable) {
|
|
8945
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
8946
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8947
|
+
const users = getUsersSchema(mysqlTable);
|
|
8948
|
+
return (0, import_drizzle_orm7.relations)(contentResourceVersion, ({ one }) => ({
|
|
8949
|
+
resource: one(contentResource, {
|
|
8950
|
+
fields: [
|
|
8951
|
+
contentResourceVersion.resourceId
|
|
8952
|
+
],
|
|
8953
|
+
references: [
|
|
8954
|
+
contentResource.id
|
|
8955
|
+
],
|
|
8956
|
+
relationName: "versions"
|
|
8957
|
+
}),
|
|
8958
|
+
parentVersion: one(contentResourceVersion, {
|
|
8959
|
+
fields: [
|
|
8960
|
+
contentResourceVersion.parentVersionId
|
|
8961
|
+
],
|
|
8962
|
+
references: [
|
|
8963
|
+
contentResourceVersion.id
|
|
8964
|
+
],
|
|
8965
|
+
relationName: "childVersions"
|
|
8966
|
+
}),
|
|
8967
|
+
createdBy: one(users, {
|
|
8968
|
+
fields: [
|
|
8969
|
+
contentResourceVersion.createdById
|
|
8970
|
+
],
|
|
8971
|
+
references: [
|
|
8972
|
+
users.id
|
|
8973
|
+
],
|
|
8974
|
+
relationName: "createdVersions"
|
|
8975
|
+
})
|
|
8976
|
+
}));
|
|
8977
|
+
}
|
|
8978
|
+
__name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelationsSchema");
|
|
8979
|
+
|
|
8980
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8981
|
+
function getContentResourceSchema(mysqlTable) {
|
|
8982
|
+
return mysqlTable("ContentResource", {
|
|
8983
|
+
id: (0, import_mysql_core9.varchar)("id", {
|
|
8984
|
+
length: 255
|
|
8985
|
+
}).notNull().primaryKey(),
|
|
8986
|
+
type: (0, import_mysql_core9.varchar)("type", {
|
|
8987
|
+
length: 255
|
|
8988
|
+
}).notNull(),
|
|
8989
|
+
createdById: (0, import_mysql_core9.varchar)("createdById", {
|
|
8990
|
+
length: 255
|
|
8991
|
+
}).notNull(),
|
|
8992
|
+
fields: (0, import_mysql_core9.json)("fields").$type().default({}),
|
|
8993
|
+
currentVersionId: (0, import_mysql_core9.varchar)("currentVersionId", {
|
|
8994
|
+
length: 255
|
|
8995
|
+
}),
|
|
8996
|
+
createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
|
|
8997
|
+
mode: "date",
|
|
8998
|
+
fsp: 3
|
|
8999
|
+
}).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`),
|
|
9000
|
+
updatedAt: (0, import_mysql_core9.timestamp)("updatedAt", {
|
|
9001
|
+
mode: "date",
|
|
9002
|
+
fsp: 3
|
|
9003
|
+
}).default(import_drizzle_orm8.sql`CURRENT_TIMESTAMP(3)`),
|
|
9004
|
+
deletedAt: (0, import_mysql_core9.timestamp)("deletedAt", {
|
|
9005
|
+
mode: "date",
|
|
9006
|
+
fsp: 3
|
|
9007
|
+
})
|
|
8746
9008
|
}, (cm) => ({
|
|
8747
|
-
typeIdx: (0,
|
|
8748
|
-
createdByIdx: (0,
|
|
8749
|
-
createdAtIdx: (0,
|
|
9009
|
+
typeIdx: (0, import_mysql_core9.index)("type_idx").on(cm.type),
|
|
9010
|
+
createdByIdx: (0, import_mysql_core9.index)("createdById_idx").on(cm.createdById),
|
|
9011
|
+
createdAtIdx: (0, import_mysql_core9.index)("createdAt_idx").on(cm.createdAt),
|
|
9012
|
+
currentVersionIdIdx: (0, import_mysql_core9.index)("currentVersionId_idx").on(cm.currentVersionId)
|
|
8750
9013
|
}));
|
|
8751
9014
|
}
|
|
8752
9015
|
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
@@ -8756,7 +9019,10 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8756
9019
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
8757
9020
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8758
9021
|
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
8759
|
-
|
|
9022
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
9023
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
9024
|
+
const tag = getTagSchema(mysqlTable);
|
|
9025
|
+
return (0, import_drizzle_orm8.relations)(contentResource, ({ one, many }) => ({
|
|
8760
9026
|
createdBy: one(users, {
|
|
8761
9027
|
fields: [
|
|
8762
9028
|
contentResource.createdById
|
|
@@ -8766,6 +9032,9 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8766
9032
|
],
|
|
8767
9033
|
relationName: "creator"
|
|
8768
9034
|
}),
|
|
9035
|
+
tags: many(contentResourceTag, {
|
|
9036
|
+
relationName: "contentResource"
|
|
9037
|
+
}),
|
|
8769
9038
|
resources: many(contentResourceResource, {
|
|
8770
9039
|
relationName: "resourceOf"
|
|
8771
9040
|
}),
|
|
@@ -8777,6 +9046,18 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8777
9046
|
}),
|
|
8778
9047
|
contributions: many(contentContributions, {
|
|
8779
9048
|
relationName: "contributions"
|
|
9049
|
+
}),
|
|
9050
|
+
currentVersion: one(contentResourceVersion, {
|
|
9051
|
+
fields: [
|
|
9052
|
+
contentResource.currentVersionId
|
|
9053
|
+
],
|
|
9054
|
+
references: [
|
|
9055
|
+
contentResourceVersion.id
|
|
9056
|
+
],
|
|
9057
|
+
relationName: "currentVersionResource"
|
|
9058
|
+
}),
|
|
9059
|
+
versions: many(contentResourceVersion, {
|
|
9060
|
+
relationName: "resource"
|
|
8780
9061
|
})
|
|
8781
9062
|
}));
|
|
8782
9063
|
}
|
|
@@ -8785,35 +9066,35 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
|
8785
9066
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8786
9067
|
function getContentResourceProductSchema(mysqlTable) {
|
|
8787
9068
|
return mysqlTable("ContentResourceProduct", {
|
|
8788
|
-
productId: (0,
|
|
9069
|
+
productId: (0, import_mysql_core10.varchar)("productId", {
|
|
8789
9070
|
length: 255
|
|
8790
9071
|
}).notNull(),
|
|
8791
|
-
resourceId: (0,
|
|
9072
|
+
resourceId: (0, import_mysql_core10.varchar)("resourceId", {
|
|
8792
9073
|
length: 255
|
|
8793
9074
|
}).notNull(),
|
|
8794
|
-
position: (0,
|
|
8795
|
-
metadata: (0,
|
|
8796
|
-
createdAt: (0,
|
|
9075
|
+
position: (0, import_mysql_core10.double)("position").notNull().default(0),
|
|
9076
|
+
metadata: (0, import_mysql_core10.json)("metadata").$type().default({}),
|
|
9077
|
+
createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
|
|
8797
9078
|
mode: "date",
|
|
8798
9079
|
fsp: 3
|
|
8799
|
-
}).default(
|
|
8800
|
-
updatedAt: (0,
|
|
9080
|
+
}).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
|
|
9081
|
+
updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
|
|
8801
9082
|
mode: "date",
|
|
8802
9083
|
fsp: 3
|
|
8803
|
-
}).default(
|
|
8804
|
-
deletedAt: (0,
|
|
9084
|
+
}).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
|
|
9085
|
+
deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
|
|
8805
9086
|
mode: "date",
|
|
8806
9087
|
fsp: 3
|
|
8807
9088
|
})
|
|
8808
9089
|
}, (crr) => ({
|
|
8809
|
-
pk: (0,
|
|
9090
|
+
pk: (0, import_mysql_core10.primaryKey)({
|
|
8810
9091
|
columns: [
|
|
8811
9092
|
crr.productId,
|
|
8812
9093
|
crr.resourceId
|
|
8813
9094
|
]
|
|
8814
9095
|
}),
|
|
8815
|
-
contentResourceIdIdx: (0,
|
|
8816
|
-
resourceIdIdx: (0,
|
|
9096
|
+
contentResourceIdIdx: (0, import_mysql_core10.index)("contentResourceId_idx").on(crr.productId),
|
|
9097
|
+
resourceIdIdx: (0, import_mysql_core10.index)("resourceId_idx").on(crr.resourceId)
|
|
8817
9098
|
}));
|
|
8818
9099
|
}
|
|
8819
9100
|
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
@@ -8821,7 +9102,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
8821
9102
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8822
9103
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8823
9104
|
const product = getProductSchema(mysqlTable);
|
|
8824
|
-
return (0,
|
|
9105
|
+
return (0, import_drizzle_orm9.relations)(contentResourceProduct, ({ one }) => ({
|
|
8825
9106
|
product: one(product, {
|
|
8826
9107
|
fields: [
|
|
8827
9108
|
contentResourceProduct.productId
|
|
@@ -8845,79 +9126,79 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
8845
9126
|
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
8846
9127
|
|
|
8847
9128
|
// src/lib/mysql/schemas/commerce/merchant-product.ts
|
|
8848
|
-
var
|
|
8849
|
-
var
|
|
9129
|
+
var import_drizzle_orm10 = require("drizzle-orm");
|
|
9130
|
+
var import_mysql_core11 = require("drizzle-orm/mysql-core");
|
|
8850
9131
|
function getMerchantProductSchema(mysqlTable) {
|
|
8851
9132
|
return mysqlTable("MerchantProduct", {
|
|
8852
|
-
id: (0,
|
|
9133
|
+
id: (0, import_mysql_core11.varchar)("id", {
|
|
8853
9134
|
length: 191
|
|
8854
9135
|
}).notNull(),
|
|
8855
|
-
merchantAccountId: (0,
|
|
9136
|
+
merchantAccountId: (0, import_mysql_core11.varchar)("merchantAccountId", {
|
|
8856
9137
|
length: 191
|
|
8857
9138
|
}).notNull(),
|
|
8858
|
-
productId: (0,
|
|
9139
|
+
productId: (0, import_mysql_core11.varchar)("productId", {
|
|
8859
9140
|
length: 191
|
|
8860
9141
|
}).notNull(),
|
|
8861
|
-
status: (0,
|
|
8862
|
-
identifier: (0,
|
|
9142
|
+
status: (0, import_mysql_core11.int)("status").default(0).notNull(),
|
|
9143
|
+
identifier: (0, import_mysql_core11.varchar)("identifier", {
|
|
8863
9144
|
length: 191
|
|
8864
9145
|
}),
|
|
8865
|
-
createdAt: (0,
|
|
9146
|
+
createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
|
|
8866
9147
|
mode: "date",
|
|
8867
9148
|
fsp: 3
|
|
8868
|
-
}).default(
|
|
9149
|
+
}).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
8869
9150
|
}, (table) => {
|
|
8870
9151
|
return {
|
|
8871
|
-
merchantProductId: (0,
|
|
9152
|
+
merchantProductId: (0, import_mysql_core11.primaryKey)({
|
|
8872
9153
|
columns: [
|
|
8873
9154
|
table.id
|
|
8874
9155
|
],
|
|
8875
9156
|
name: "MerchantProduct_id"
|
|
8876
9157
|
}),
|
|
8877
|
-
merchantProductIdentifierKey: (0,
|
|
9158
|
+
merchantProductIdentifierKey: (0, import_mysql_core11.unique)("MerchantProduct_identifier_key").on(table.identifier)
|
|
8878
9159
|
};
|
|
8879
9160
|
});
|
|
8880
9161
|
}
|
|
8881
9162
|
__name(getMerchantProductSchema, "getMerchantProductSchema");
|
|
8882
9163
|
|
|
8883
9164
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
8884
|
-
var
|
|
8885
|
-
var
|
|
9165
|
+
var import_drizzle_orm12 = require("drizzle-orm");
|
|
9166
|
+
var import_mysql_core13 = require("drizzle-orm/mysql-core");
|
|
8886
9167
|
|
|
8887
9168
|
// src/lib/mysql/schemas/commerce/merchant-price.ts
|
|
8888
|
-
var
|
|
8889
|
-
var
|
|
9169
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
9170
|
+
var import_mysql_core12 = require("drizzle-orm/mysql-core");
|
|
8890
9171
|
function getMerchantPriceSchema(mysqlTable) {
|
|
8891
9172
|
return mysqlTable("MerchantPrice", {
|
|
8892
|
-
id: (0,
|
|
9173
|
+
id: (0, import_mysql_core12.varchar)("id", {
|
|
8893
9174
|
length: 191
|
|
8894
9175
|
}).notNull(),
|
|
8895
|
-
merchantAccountId: (0,
|
|
9176
|
+
merchantAccountId: (0, import_mysql_core12.varchar)("merchantAccountId", {
|
|
8896
9177
|
length: 191
|
|
8897
9178
|
}).notNull(),
|
|
8898
|
-
merchantProductId: (0,
|
|
9179
|
+
merchantProductId: (0, import_mysql_core12.varchar)("merchantProductId", {
|
|
8899
9180
|
length: 191
|
|
8900
9181
|
}).notNull(),
|
|
8901
|
-
status: (0,
|
|
8902
|
-
identifier: (0,
|
|
9182
|
+
status: (0, import_mysql_core12.int)("status").default(0),
|
|
9183
|
+
identifier: (0, import_mysql_core12.varchar)("identifier", {
|
|
8903
9184
|
length: 191
|
|
8904
9185
|
}),
|
|
8905
|
-
createdAt: (0,
|
|
9186
|
+
createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
|
|
8906
9187
|
mode: "date",
|
|
8907
9188
|
fsp: 3
|
|
8908
|
-
}).default(
|
|
8909
|
-
priceId: (0,
|
|
9189
|
+
}).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9190
|
+
priceId: (0, import_mysql_core12.varchar)("priceId", {
|
|
8910
9191
|
length: 191
|
|
8911
9192
|
})
|
|
8912
9193
|
}, (table) => {
|
|
8913
9194
|
return {
|
|
8914
|
-
merchantPriceId: (0,
|
|
9195
|
+
merchantPriceId: (0, import_mysql_core12.primaryKey)({
|
|
8915
9196
|
columns: [
|
|
8916
9197
|
table.id
|
|
8917
9198
|
],
|
|
8918
9199
|
name: "MerchantPrice_id"
|
|
8919
9200
|
}),
|
|
8920
|
-
merchantPriceIdentifierKey: (0,
|
|
9201
|
+
merchantPriceIdentifierKey: (0, import_mysql_core12.unique)("MerchantPrice_identifier_key").on(table.identifier)
|
|
8921
9202
|
};
|
|
8922
9203
|
});
|
|
8923
9204
|
}
|
|
@@ -8926,28 +9207,28 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
|
|
|
8926
9207
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
8927
9208
|
function getPriceSchema(mysqlTable) {
|
|
8928
9209
|
return mysqlTable("Price", {
|
|
8929
|
-
id: (0,
|
|
9210
|
+
id: (0, import_mysql_core13.varchar)("id", {
|
|
8930
9211
|
length: 191
|
|
8931
9212
|
}).notNull(),
|
|
8932
|
-
productId: (0,
|
|
9213
|
+
productId: (0, import_mysql_core13.varchar)("productId", {
|
|
8933
9214
|
length: 191
|
|
8934
9215
|
}),
|
|
8935
|
-
nickname: (0,
|
|
9216
|
+
nickname: (0, import_mysql_core13.varchar)("nickname", {
|
|
8936
9217
|
length: 191
|
|
8937
9218
|
}),
|
|
8938
|
-
status: (0,
|
|
8939
|
-
unitAmount: (0,
|
|
9219
|
+
status: (0, import_mysql_core13.int)("status").default(0).notNull(),
|
|
9220
|
+
unitAmount: (0, import_mysql_core13.decimal)("unitAmount", {
|
|
8940
9221
|
precision: 10,
|
|
8941
9222
|
scale: 2
|
|
8942
9223
|
}).notNull(),
|
|
8943
|
-
createdAt: (0,
|
|
9224
|
+
createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
|
|
8944
9225
|
mode: "date",
|
|
8945
9226
|
fsp: 3
|
|
8946
|
-
}).default(
|
|
8947
|
-
fields: (0,
|
|
9227
|
+
}).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9228
|
+
fields: (0, import_mysql_core13.json)("fields").$type().default({})
|
|
8948
9229
|
}, (table) => {
|
|
8949
9230
|
return {
|
|
8950
|
-
priceId: (0,
|
|
9231
|
+
priceId: (0, import_mysql_core13.primaryKey)({
|
|
8951
9232
|
columns: [
|
|
8952
9233
|
table.id
|
|
8953
9234
|
],
|
|
@@ -8961,28 +9242,28 @@ __name(getPriceSchema, "getPriceSchema");
|
|
|
8961
9242
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8962
9243
|
function getProductSchema(mysqlTable) {
|
|
8963
9244
|
return mysqlTable("Product", {
|
|
8964
|
-
id: (0,
|
|
9245
|
+
id: (0, import_mysql_core14.varchar)("id", {
|
|
8965
9246
|
length: 191
|
|
8966
9247
|
}).notNull(),
|
|
8967
|
-
name: (0,
|
|
9248
|
+
name: (0, import_mysql_core14.varchar)("name", {
|
|
8968
9249
|
length: 191
|
|
8969
9250
|
}).notNull(),
|
|
8970
|
-
key: (0,
|
|
9251
|
+
key: (0, import_mysql_core14.varchar)("key", {
|
|
8971
9252
|
length: 191
|
|
8972
9253
|
}),
|
|
8973
|
-
type: (0,
|
|
9254
|
+
type: (0, import_mysql_core14.varchar)("type", {
|
|
8974
9255
|
length: 191
|
|
8975
9256
|
}),
|
|
8976
|
-
fields: (0,
|
|
8977
|
-
createdAt: (0,
|
|
9257
|
+
fields: (0, import_mysql_core14.json)("fields").$type().default({}),
|
|
9258
|
+
createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
|
|
8978
9259
|
mode: "date",
|
|
8979
9260
|
fsp: 3
|
|
8980
|
-
}).default(
|
|
8981
|
-
status: (0,
|
|
8982
|
-
quantityAvailable: (0,
|
|
9261
|
+
}).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9262
|
+
status: (0, import_mysql_core14.int)("status").default(0).notNull(),
|
|
9263
|
+
quantityAvailable: (0, import_mysql_core14.int)("quantityAvailable").default(-1).notNull()
|
|
8983
9264
|
}, (table) => {
|
|
8984
9265
|
return {
|
|
8985
|
-
productId: (0,
|
|
9266
|
+
productId: (0, import_mysql_core14.primaryKey)({
|
|
8986
9267
|
columns: [
|
|
8987
9268
|
table.id
|
|
8988
9269
|
],
|
|
@@ -8997,7 +9278,7 @@ function getProductRelationsSchema(mysqlTable) {
|
|
|
8997
9278
|
const price = getPriceSchema(mysqlTable);
|
|
8998
9279
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
8999
9280
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
9000
|
-
return (0,
|
|
9281
|
+
return (0, import_drizzle_orm13.relations)(product, ({ one, many }) => ({
|
|
9001
9282
|
price: one(price, {
|
|
9002
9283
|
fields: [
|
|
9003
9284
|
product.id
|
|
@@ -9026,49 +9307,45 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
|
9026
9307
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
9027
9308
|
function getCouponSchema(mysqlTable) {
|
|
9028
9309
|
return mysqlTable("Coupon", {
|
|
9029
|
-
id: (0,
|
|
9310
|
+
id: (0, import_mysql_core15.varchar)("id", {
|
|
9030
9311
|
length: 191
|
|
9031
9312
|
}).notNull(),
|
|
9032
|
-
code: (0,
|
|
9313
|
+
code: (0, import_mysql_core15.varchar)("code", {
|
|
9033
9314
|
length: 191
|
|
9034
9315
|
}),
|
|
9035
|
-
createdAt: (0,
|
|
9316
|
+
createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
|
|
9036
9317
|
mode: "date",
|
|
9037
9318
|
fsp: 3
|
|
9038
|
-
}).default(
|
|
9039
|
-
expires: (0,
|
|
9319
|
+
}).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9320
|
+
expires: (0, import_mysql_core15.timestamp)("expires", {
|
|
9040
9321
|
mode: "date",
|
|
9041
9322
|
fsp: 3
|
|
9042
9323
|
}),
|
|
9043
|
-
fields: (0,
|
|
9044
|
-
maxUses: (0,
|
|
9045
|
-
default: (0,
|
|
9046
|
-
merchantCouponId: (0,
|
|
9324
|
+
fields: (0, import_mysql_core15.json)("fields").$type().default({}),
|
|
9325
|
+
maxUses: (0, import_mysql_core15.int)("maxUses").default(-1).notNull(),
|
|
9326
|
+
default: (0, import_mysql_core15.boolean)("default").default(false).notNull(),
|
|
9327
|
+
merchantCouponId: (0, import_mysql_core15.varchar)("merchantCouponId", {
|
|
9047
9328
|
length: 191
|
|
9048
9329
|
}),
|
|
9049
|
-
status: (0,
|
|
9050
|
-
usedCount: (0,
|
|
9051
|
-
percentageDiscount: (0,
|
|
9330
|
+
status: (0, import_mysql_core15.int)("status").default(0).notNull(),
|
|
9331
|
+
usedCount: (0, import_mysql_core15.int)("usedCount").default(0).notNull(),
|
|
9332
|
+
percentageDiscount: (0, import_mysql_core15.decimal)("percentageDiscount", {
|
|
9052
9333
|
precision: 3,
|
|
9053
9334
|
scale: 2
|
|
9054
9335
|
}).notNull(),
|
|
9055
|
-
restrictedToProductId: (0,
|
|
9056
|
-
length: 191
|
|
9057
|
-
}),
|
|
9058
|
-
bulkPurchaseId: (0, import_mysql_core11.varchar)("bulkPurchaseId", {
|
|
9336
|
+
restrictedToProductId: (0, import_mysql_core15.varchar)("restrictedToProductId", {
|
|
9059
9337
|
length: 191
|
|
9060
9338
|
})
|
|
9061
9339
|
}, (table) => {
|
|
9062
9340
|
return {
|
|
9063
|
-
couponIdCodeIndex: (0,
|
|
9064
|
-
couponId: (0,
|
|
9341
|
+
couponIdCodeIndex: (0, import_mysql_core15.index)("Coupon_id_code_index").on(table.id, table.code),
|
|
9342
|
+
couponId: (0, import_mysql_core15.primaryKey)({
|
|
9065
9343
|
columns: [
|
|
9066
9344
|
table.id
|
|
9067
9345
|
],
|
|
9068
9346
|
name: "Coupon_id"
|
|
9069
9347
|
}),
|
|
9070
|
-
|
|
9071
|
-
couponCodeKey: (0, import_mysql_core11.unique)("Coupon_code_key").on(table.code)
|
|
9348
|
+
couponCodeKey: (0, import_mysql_core15.unique)("Coupon_code_key").on(table.code)
|
|
9072
9349
|
};
|
|
9073
9350
|
});
|
|
9074
9351
|
}
|
|
@@ -9077,8 +9354,8 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
9077
9354
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
9078
9355
|
const coupon = getCouponSchema(mysqlTable);
|
|
9079
9356
|
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
9080
|
-
return (0,
|
|
9081
|
-
|
|
9357
|
+
return (0, import_drizzle_orm14.relations)(coupon, ({ many, one }) => ({
|
|
9358
|
+
redeemedBulkCouponPurchases: many(purchase, {
|
|
9082
9359
|
relationName: "redeemedBulkCoupon"
|
|
9083
9360
|
}),
|
|
9084
9361
|
merchantCoupon: one(merchantCoupon, {
|
|
@@ -9099,45 +9376,39 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
9099
9376
|
],
|
|
9100
9377
|
relationName: "product"
|
|
9101
9378
|
}),
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
coupon.bulkPurchaseId
|
|
9105
|
-
],
|
|
9106
|
-
references: [
|
|
9107
|
-
purchase.id
|
|
9108
|
-
],
|
|
9109
|
-
relationName: "bulkPurchase"
|
|
9379
|
+
bulkPurchases: many(purchase, {
|
|
9380
|
+
relationName: "bulkCoupon"
|
|
9110
9381
|
})
|
|
9111
9382
|
}));
|
|
9112
9383
|
}
|
|
9113
9384
|
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
9114
9385
|
|
|
9115
9386
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
9116
|
-
var
|
|
9117
|
-
var
|
|
9387
|
+
var import_drizzle_orm17 = require("drizzle-orm");
|
|
9388
|
+
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9118
9389
|
|
|
9119
9390
|
// src/lib/mysql/schemas/commerce/merchant-account.ts
|
|
9120
|
-
var
|
|
9121
|
-
var
|
|
9391
|
+
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9392
|
+
var import_mysql_core16 = require("drizzle-orm/mysql-core");
|
|
9122
9393
|
function getMerchantAccountSchema(mysqlTable) {
|
|
9123
9394
|
return mysqlTable("MerchantAccount", {
|
|
9124
|
-
id: (0,
|
|
9395
|
+
id: (0, import_mysql_core16.varchar)("id", {
|
|
9125
9396
|
length: 191
|
|
9126
9397
|
}).notNull(),
|
|
9127
|
-
status: (0,
|
|
9128
|
-
createdAt: (0,
|
|
9398
|
+
status: (0, import_mysql_core16.int)("status").default(0).notNull(),
|
|
9399
|
+
createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
|
|
9129
9400
|
mode: "date",
|
|
9130
9401
|
fsp: 3
|
|
9131
|
-
}).default(
|
|
9132
|
-
label: (0,
|
|
9402
|
+
}).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9403
|
+
label: (0, import_mysql_core16.varchar)("label", {
|
|
9133
9404
|
length: 191
|
|
9134
9405
|
}),
|
|
9135
|
-
identifier: (0,
|
|
9406
|
+
identifier: (0, import_mysql_core16.varchar)("identifier", {
|
|
9136
9407
|
length: 191
|
|
9137
9408
|
})
|
|
9138
9409
|
}, (table) => {
|
|
9139
9410
|
return {
|
|
9140
|
-
merchantAccountId: (0,
|
|
9411
|
+
merchantAccountId: (0, import_mysql_core16.primaryKey)({
|
|
9141
9412
|
columns: [
|
|
9142
9413
|
table.id
|
|
9143
9414
|
],
|
|
@@ -9149,37 +9420,37 @@ function getMerchantAccountSchema(mysqlTable) {
|
|
|
9149
9420
|
__name(getMerchantAccountSchema, "getMerchantAccountSchema");
|
|
9150
9421
|
|
|
9151
9422
|
// src/lib/mysql/schemas/commerce/merchant-customer.ts
|
|
9152
|
-
var
|
|
9153
|
-
var
|
|
9423
|
+
var import_drizzle_orm16 = require("drizzle-orm");
|
|
9424
|
+
var import_mysql_core17 = require("drizzle-orm/mysql-core");
|
|
9154
9425
|
function getMerchantCustomerSchema(mysqlTable) {
|
|
9155
9426
|
return mysqlTable("MerchantCustomer", {
|
|
9156
|
-
id: (0,
|
|
9427
|
+
id: (0, import_mysql_core17.varchar)("id", {
|
|
9157
9428
|
length: 191
|
|
9158
9429
|
}).notNull(),
|
|
9159
|
-
userId: (0,
|
|
9430
|
+
userId: (0, import_mysql_core17.varchar)("userId", {
|
|
9160
9431
|
length: 191
|
|
9161
9432
|
}).notNull(),
|
|
9162
|
-
merchantAccountId: (0,
|
|
9433
|
+
merchantAccountId: (0, import_mysql_core17.varchar)("merchantAccountId", {
|
|
9163
9434
|
length: 191
|
|
9164
9435
|
}).notNull(),
|
|
9165
|
-
identifier: (0,
|
|
9436
|
+
identifier: (0, import_mysql_core17.varchar)("identifier", {
|
|
9166
9437
|
length: 191
|
|
9167
9438
|
}).notNull(),
|
|
9168
|
-
createdAt: (0,
|
|
9439
|
+
createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
|
|
9169
9440
|
mode: "date",
|
|
9170
9441
|
fsp: 3
|
|
9171
|
-
}).default(
|
|
9172
|
-
status: (0,
|
|
9442
|
+
}).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9443
|
+
status: (0, import_mysql_core17.int)("status").default(0)
|
|
9173
9444
|
}, (table) => {
|
|
9174
9445
|
return {
|
|
9175
|
-
merchantCustomerId: (0,
|
|
9446
|
+
merchantCustomerId: (0, import_mysql_core17.primaryKey)({
|
|
9176
9447
|
columns: [
|
|
9177
9448
|
table.id
|
|
9178
9449
|
],
|
|
9179
9450
|
name: "MerchantCustomer_id"
|
|
9180
9451
|
}),
|
|
9181
|
-
merchantCustomerIdentifierKey: (0,
|
|
9182
|
-
userIdIdx: (0,
|
|
9452
|
+
merchantCustomerIdentifierKey: (0, import_mysql_core17.unique)("MerchantCustomer_identifier_key").on(table.identifier),
|
|
9453
|
+
userIdIdx: (0, import_mysql_core17.index)("idx_MerchantCustomer_on_userId").on(table.userId)
|
|
9183
9454
|
};
|
|
9184
9455
|
});
|
|
9185
9456
|
}
|
|
@@ -9188,38 +9459,38 @@ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
|
|
|
9188
9459
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
9189
9460
|
function getMerchantChargeSchema(mysqlTable) {
|
|
9190
9461
|
return mysqlTable("MerchantCharge", {
|
|
9191
|
-
id: (0,
|
|
9462
|
+
id: (0, import_mysql_core18.varchar)("id", {
|
|
9192
9463
|
length: 191
|
|
9193
9464
|
}).notNull(),
|
|
9194
|
-
status: (0,
|
|
9195
|
-
identifier: (0,
|
|
9465
|
+
status: (0, import_mysql_core18.int)("status").default(0).notNull(),
|
|
9466
|
+
identifier: (0, import_mysql_core18.varchar)("identifier", {
|
|
9196
9467
|
length: 191
|
|
9197
9468
|
}).notNull(),
|
|
9198
|
-
userId: (0,
|
|
9469
|
+
userId: (0, import_mysql_core18.varchar)("userId", {
|
|
9199
9470
|
length: 191
|
|
9200
9471
|
}).notNull(),
|
|
9201
|
-
merchantAccountId: (0,
|
|
9472
|
+
merchantAccountId: (0, import_mysql_core18.varchar)("merchantAccountId", {
|
|
9202
9473
|
length: 191
|
|
9203
9474
|
}).notNull(),
|
|
9204
|
-
merchantProductId: (0,
|
|
9475
|
+
merchantProductId: (0, import_mysql_core18.varchar)("merchantProductId", {
|
|
9205
9476
|
length: 191
|
|
9206
9477
|
}).notNull(),
|
|
9207
|
-
createdAt: (0,
|
|
9478
|
+
createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
|
|
9208
9479
|
mode: "date",
|
|
9209
9480
|
fsp: 3
|
|
9210
|
-
}).default(
|
|
9211
|
-
merchantCustomerId: (0,
|
|
9481
|
+
}).default(import_drizzle_orm17.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9482
|
+
merchantCustomerId: (0, import_mysql_core18.varchar)("merchantCustomerId", {
|
|
9212
9483
|
length: 191
|
|
9213
9484
|
}).notNull()
|
|
9214
9485
|
}, (table) => {
|
|
9215
9486
|
return {
|
|
9216
|
-
merchantChargeId: (0,
|
|
9487
|
+
merchantChargeId: (0, import_mysql_core18.primaryKey)({
|
|
9217
9488
|
columns: [
|
|
9218
9489
|
table.id
|
|
9219
9490
|
],
|
|
9220
9491
|
name: "MerchantCharge_id"
|
|
9221
9492
|
}),
|
|
9222
|
-
merchantChargeIdentifierKey: (0,
|
|
9493
|
+
merchantChargeIdentifierKey: (0, import_mysql_core18.unique)("MerchantCharge_identifier_key").on(table.identifier)
|
|
9223
9494
|
};
|
|
9224
9495
|
});
|
|
9225
9496
|
}
|
|
@@ -9229,7 +9500,7 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9229
9500
|
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
9230
9501
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
9231
9502
|
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
9232
|
-
return (0,
|
|
9503
|
+
return (0, import_drizzle_orm17.relations)(merchantCharge, ({ one }) => ({
|
|
9233
9504
|
merchantAccount: one(merchantAccount, {
|
|
9234
9505
|
fields: [
|
|
9235
9506
|
merchantCharge.merchantAccountId
|
|
@@ -9262,21 +9533,21 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9262
9533
|
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
9263
9534
|
|
|
9264
9535
|
// src/lib/mysql/schemas/commerce/merchant-session.ts
|
|
9265
|
-
var
|
|
9536
|
+
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
9266
9537
|
function getMerchantSessionSchema(mysqlTable) {
|
|
9267
9538
|
return mysqlTable("MerchantSession", {
|
|
9268
|
-
id: (0,
|
|
9539
|
+
id: (0, import_mysql_core19.varchar)("id", {
|
|
9269
9540
|
length: 191
|
|
9270
9541
|
}).notNull(),
|
|
9271
|
-
identifier: (0,
|
|
9542
|
+
identifier: (0, import_mysql_core19.varchar)("identifier", {
|
|
9272
9543
|
length: 191
|
|
9273
9544
|
}).notNull(),
|
|
9274
|
-
merchantAccountId: (0,
|
|
9545
|
+
merchantAccountId: (0, import_mysql_core19.varchar)("merchantAccountId", {
|
|
9275
9546
|
length: 191
|
|
9276
9547
|
}).notNull()
|
|
9277
9548
|
}, (table) => {
|
|
9278
9549
|
return {
|
|
9279
|
-
merchantSessionId: (0,
|
|
9550
|
+
merchantSessionId: (0, import_mysql_core19.primaryKey)({
|
|
9280
9551
|
columns: [
|
|
9281
9552
|
table.id
|
|
9282
9553
|
],
|
|
@@ -9290,67 +9561,67 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
|
|
|
9290
9561
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
9291
9562
|
function getPurchaseSchema(mysqlTable) {
|
|
9292
9563
|
return mysqlTable("Purchase", {
|
|
9293
|
-
id: (0,
|
|
9564
|
+
id: (0, import_mysql_core20.varchar)("id", {
|
|
9294
9565
|
length: 191
|
|
9295
9566
|
}).notNull(),
|
|
9296
|
-
userId: (0,
|
|
9567
|
+
userId: (0, import_mysql_core20.varchar)("userId", {
|
|
9297
9568
|
length: 191
|
|
9298
9569
|
}),
|
|
9299
|
-
createdAt: (0,
|
|
9570
|
+
createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
|
|
9300
9571
|
mode: "date",
|
|
9301
9572
|
fsp: 3
|
|
9302
|
-
}).default(
|
|
9303
|
-
totalAmount: (0,
|
|
9573
|
+
}).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9574
|
+
totalAmount: (0, import_mysql_core20.decimal)("totalAmount", {
|
|
9304
9575
|
precision: 65,
|
|
9305
9576
|
scale: 30
|
|
9306
9577
|
}).notNull(),
|
|
9307
|
-
ipAddress: (0,
|
|
9578
|
+
ipAddress: (0, import_mysql_core20.varchar)("ip_address", {
|
|
9308
9579
|
length: 191
|
|
9309
9580
|
}),
|
|
9310
|
-
city: (0,
|
|
9581
|
+
city: (0, import_mysql_core20.varchar)("city", {
|
|
9311
9582
|
length: 191
|
|
9312
9583
|
}),
|
|
9313
|
-
state: (0,
|
|
9584
|
+
state: (0, import_mysql_core20.varchar)("state", {
|
|
9314
9585
|
length: 191
|
|
9315
9586
|
}),
|
|
9316
|
-
country: (0,
|
|
9587
|
+
country: (0, import_mysql_core20.varchar)("country", {
|
|
9317
9588
|
length: 191
|
|
9318
9589
|
}),
|
|
9319
|
-
couponId: (0,
|
|
9590
|
+
couponId: (0, import_mysql_core20.varchar)("couponId", {
|
|
9320
9591
|
length: 191
|
|
9321
9592
|
}),
|
|
9322
|
-
productId: (0,
|
|
9593
|
+
productId: (0, import_mysql_core20.varchar)("productId", {
|
|
9323
9594
|
length: 191
|
|
9324
9595
|
}).notNull(),
|
|
9325
|
-
merchantChargeId: (0,
|
|
9596
|
+
merchantChargeId: (0, import_mysql_core20.varchar)("merchantChargeId", {
|
|
9326
9597
|
length: 191
|
|
9327
9598
|
}),
|
|
9328
|
-
upgradedFromId: (0,
|
|
9599
|
+
upgradedFromId: (0, import_mysql_core20.varchar)("upgradedFromId", {
|
|
9329
9600
|
length: 191
|
|
9330
9601
|
}),
|
|
9331
|
-
status: (0,
|
|
9602
|
+
status: (0, import_mysql_core20.varchar)("status", {
|
|
9332
9603
|
length: 191
|
|
9333
9604
|
}).default("Valid").notNull(),
|
|
9334
|
-
bulkCouponId: (0,
|
|
9605
|
+
bulkCouponId: (0, import_mysql_core20.varchar)("bulkCouponId", {
|
|
9335
9606
|
length: 191
|
|
9336
9607
|
}),
|
|
9337
|
-
merchantSessionId: (0,
|
|
9608
|
+
merchantSessionId: (0, import_mysql_core20.varchar)("merchantSessionId", {
|
|
9338
9609
|
length: 191
|
|
9339
9610
|
}),
|
|
9340
|
-
redeemedBulkCouponId: (0,
|
|
9611
|
+
redeemedBulkCouponId: (0, import_mysql_core20.varchar)("redeemedBulkCouponId", {
|
|
9341
9612
|
length: 191
|
|
9342
9613
|
}),
|
|
9343
|
-
fields: (0,
|
|
9614
|
+
fields: (0, import_mysql_core20.json)("fields").$type().default({})
|
|
9344
9615
|
}, (table) => {
|
|
9345
9616
|
return {
|
|
9346
|
-
purchaseId: (0,
|
|
9617
|
+
purchaseId: (0, import_mysql_core20.primaryKey)({
|
|
9347
9618
|
columns: [
|
|
9348
9619
|
table.id
|
|
9349
9620
|
],
|
|
9350
9621
|
name: "Purchase_id"
|
|
9351
9622
|
}),
|
|
9352
|
-
merchantChargeIdIdx: (0,
|
|
9353
|
-
purchaseUpgradedFromIdKey: (0,
|
|
9623
|
+
merchantChargeIdIdx: (0, import_mysql_core20.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
9624
|
+
purchaseUpgradedFromIdKey: (0, import_mysql_core20.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId)
|
|
9354
9625
|
};
|
|
9355
9626
|
});
|
|
9356
9627
|
}
|
|
@@ -9362,7 +9633,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9362
9633
|
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
9363
9634
|
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
9364
9635
|
const coupons = getCouponSchema(mysqlTable);
|
|
9365
|
-
return (0,
|
|
9636
|
+
return (0, import_drizzle_orm18.relations)(purchases, ({ many, one }) => ({
|
|
9366
9637
|
redeemedBulkCoupon: one(coupons, {
|
|
9367
9638
|
fields: [
|
|
9368
9639
|
purchases.redeemedBulkCouponId
|
|
@@ -9422,44 +9693,44 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9422
9693
|
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
9423
9694
|
|
|
9424
9695
|
// src/lib/mysql/schemas/communication/comment.ts
|
|
9425
|
-
var
|
|
9426
|
-
var
|
|
9696
|
+
var import_drizzle_orm19 = require("drizzle-orm");
|
|
9697
|
+
var import_mysql_core21 = require("drizzle-orm/mysql-core");
|
|
9427
9698
|
function getCommentsSchema(mysqlTable) {
|
|
9428
9699
|
return mysqlTable("Comment", {
|
|
9429
|
-
id: (0,
|
|
9700
|
+
id: (0, import_mysql_core21.varchar)("id", {
|
|
9430
9701
|
length: 191
|
|
9431
9702
|
}).notNull(),
|
|
9432
|
-
userId: (0,
|
|
9703
|
+
userId: (0, import_mysql_core21.varchar)("userId", {
|
|
9433
9704
|
length: 255
|
|
9434
9705
|
}).notNull(),
|
|
9435
|
-
context: (0,
|
|
9436
|
-
text: (0,
|
|
9437
|
-
createdAt: (0,
|
|
9706
|
+
context: (0, import_mysql_core21.json)("context").$type().default({}),
|
|
9707
|
+
text: (0, import_mysql_core21.text)("text").notNull(),
|
|
9708
|
+
createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
|
|
9438
9709
|
mode: "date",
|
|
9439
9710
|
fsp: 3
|
|
9440
|
-
}).default(
|
|
9441
|
-
updatedAt: (0,
|
|
9711
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
|
|
9712
|
+
updatedAt: (0, import_mysql_core21.timestamp)("updatedAt", {
|
|
9442
9713
|
mode: "date",
|
|
9443
9714
|
fsp: 3
|
|
9444
|
-
}).default(
|
|
9445
|
-
deletedAt: (0,
|
|
9715
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
|
|
9716
|
+
deletedAt: (0, import_mysql_core21.timestamp)("deletedAt", {
|
|
9446
9717
|
mode: "date",
|
|
9447
9718
|
fsp: 3
|
|
9448
9719
|
})
|
|
9449
9720
|
}, (crr) => ({
|
|
9450
|
-
pk: (0,
|
|
9721
|
+
pk: (0, import_mysql_core21.primaryKey)({
|
|
9451
9722
|
columns: [
|
|
9452
9723
|
crr.id
|
|
9453
9724
|
]
|
|
9454
9725
|
}),
|
|
9455
|
-
crrUserIdIdKey: (0,
|
|
9726
|
+
crrUserIdIdKey: (0, import_mysql_core21.index)("crr_userIdId_idx").on(crr.userId)
|
|
9456
9727
|
}));
|
|
9457
9728
|
}
|
|
9458
9729
|
__name(getCommentsSchema, "getCommentsSchema");
|
|
9459
9730
|
function getCommentRelationsSchema(mysqlTable) {
|
|
9460
9731
|
const comment = getCommentsSchema(mysqlTable);
|
|
9461
9732
|
const user = getUsersSchema(mysqlTable);
|
|
9462
|
-
return (0,
|
|
9733
|
+
return (0, import_drizzle_orm19.relations)(comment, ({ one }) => ({
|
|
9463
9734
|
user: one(user, {
|
|
9464
9735
|
fields: [
|
|
9465
9736
|
comment.userId
|
|
@@ -9474,60 +9745,60 @@ function getCommentRelationsSchema(mysqlTable) {
|
|
|
9474
9745
|
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
9475
9746
|
|
|
9476
9747
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9477
|
-
var
|
|
9478
|
-
var
|
|
9748
|
+
var import_drizzle_orm20 = require("drizzle-orm");
|
|
9749
|
+
var import_mysql_core24 = require("drizzle-orm/mysql-core");
|
|
9479
9750
|
|
|
9480
9751
|
// src/lib/mysql/schemas/communication/communication-channel.ts
|
|
9481
|
-
var
|
|
9752
|
+
var import_mysql_core22 = require("drizzle-orm/mysql-core");
|
|
9482
9753
|
function getCommunicationChannelSchema(mysqlTable) {
|
|
9483
9754
|
return mysqlTable("CommunicationChannel", {
|
|
9484
|
-
id: (0,
|
|
9755
|
+
id: (0, import_mysql_core22.varchar)("id", {
|
|
9485
9756
|
length: 255
|
|
9486
9757
|
}).notNull().primaryKey(),
|
|
9487
|
-
name: (0,
|
|
9758
|
+
name: (0, import_mysql_core22.varchar)("name", {
|
|
9488
9759
|
length: 255
|
|
9489
9760
|
}).notNull(),
|
|
9490
|
-
description: (0,
|
|
9491
|
-
active: (0,
|
|
9492
|
-
createdAt: (0,
|
|
9761
|
+
description: (0, import_mysql_core22.text)("description"),
|
|
9762
|
+
active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
|
|
9763
|
+
createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
|
|
9493
9764
|
mode: "date",
|
|
9494
9765
|
fsp: 3
|
|
9495
9766
|
}).defaultNow(),
|
|
9496
|
-
updatedAt: (0,
|
|
9767
|
+
updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
|
|
9497
9768
|
mode: "date",
|
|
9498
9769
|
fsp: 3
|
|
9499
9770
|
}).defaultNow(),
|
|
9500
|
-
deletedAt: (0,
|
|
9771
|
+
deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
|
|
9501
9772
|
mode: "date",
|
|
9502
9773
|
fsp: 3
|
|
9503
9774
|
})
|
|
9504
9775
|
}, (cc) => ({
|
|
9505
|
-
nameIdx: (0,
|
|
9776
|
+
nameIdx: (0, import_mysql_core22.index)("name_idx").on(cc.name)
|
|
9506
9777
|
}));
|
|
9507
9778
|
}
|
|
9508
9779
|
__name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
|
|
9509
9780
|
|
|
9510
9781
|
// src/lib/mysql/schemas/communication/communication-preference-types.ts
|
|
9511
|
-
var
|
|
9782
|
+
var import_mysql_core23 = require("drizzle-orm/mysql-core");
|
|
9512
9783
|
function getCommunicationPreferenceTypesSchema(mysqlTable) {
|
|
9513
9784
|
return mysqlTable("CommunicationPreferenceType", {
|
|
9514
|
-
id: (0,
|
|
9785
|
+
id: (0, import_mysql_core23.varchar)("id", {
|
|
9515
9786
|
length: 255
|
|
9516
9787
|
}).notNull().primaryKey(),
|
|
9517
|
-
name: (0,
|
|
9788
|
+
name: (0, import_mysql_core23.varchar)("name", {
|
|
9518
9789
|
length: 255
|
|
9519
9790
|
}).notNull(),
|
|
9520
|
-
description: (0,
|
|
9521
|
-
active: (0,
|
|
9522
|
-
createdAt: (0,
|
|
9791
|
+
description: (0, import_mysql_core23.text)("description"),
|
|
9792
|
+
active: (0, import_mysql_core23.boolean)("active").notNull().default(true),
|
|
9793
|
+
createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
|
|
9523
9794
|
mode: "date",
|
|
9524
9795
|
fsp: 3
|
|
9525
9796
|
}).defaultNow(),
|
|
9526
|
-
updatedAt: (0,
|
|
9797
|
+
updatedAt: (0, import_mysql_core23.timestamp)("updatedAt", {
|
|
9527
9798
|
mode: "date",
|
|
9528
9799
|
fsp: 3
|
|
9529
9800
|
}),
|
|
9530
|
-
deletedAt: (0,
|
|
9801
|
+
deletedAt: (0, import_mysql_core23.timestamp)("deletedAt", {
|
|
9531
9802
|
mode: "date",
|
|
9532
9803
|
fsp: 3
|
|
9533
9804
|
})
|
|
@@ -9538,48 +9809,48 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
|
|
|
9538
9809
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9539
9810
|
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
9540
9811
|
return mysqlTable("CommunicationPreference", {
|
|
9541
|
-
id: (0,
|
|
9812
|
+
id: (0, import_mysql_core24.varchar)("id", {
|
|
9542
9813
|
length: 255
|
|
9543
9814
|
}).notNull().primaryKey(),
|
|
9544
|
-
userId: (0,
|
|
9815
|
+
userId: (0, import_mysql_core24.varchar)("userId", {
|
|
9545
9816
|
length: 255
|
|
9546
9817
|
}).notNull(),
|
|
9547
|
-
channelId: (0,
|
|
9818
|
+
channelId: (0, import_mysql_core24.varchar)("channelId", {
|
|
9548
9819
|
length: 255
|
|
9549
9820
|
}).notNull(),
|
|
9550
|
-
preferenceLevel: (0,
|
|
9821
|
+
preferenceLevel: (0, import_mysql_core24.mysqlEnum)("preferenceLevel", [
|
|
9551
9822
|
"low",
|
|
9552
9823
|
"medium",
|
|
9553
9824
|
"high"
|
|
9554
9825
|
]).notNull().default("medium"),
|
|
9555
|
-
preferenceTypeId: (0,
|
|
9826
|
+
preferenceTypeId: (0, import_mysql_core24.varchar)("preferenceTypeId", {
|
|
9556
9827
|
length: 255
|
|
9557
9828
|
}).notNull(),
|
|
9558
|
-
active: (0,
|
|
9559
|
-
createdAt: (0,
|
|
9829
|
+
active: (0, import_mysql_core24.boolean)("active").notNull().default(true),
|
|
9830
|
+
createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
|
|
9560
9831
|
mode: "date",
|
|
9561
9832
|
fsp: 3
|
|
9562
9833
|
}).defaultNow(),
|
|
9563
|
-
optInAt: (0,
|
|
9834
|
+
optInAt: (0, import_mysql_core24.timestamp)("optInAt", {
|
|
9564
9835
|
mode: "date",
|
|
9565
9836
|
fsp: 3
|
|
9566
9837
|
}),
|
|
9567
|
-
optOutAt: (0,
|
|
9838
|
+
optOutAt: (0, import_mysql_core24.timestamp)("optOutAt", {
|
|
9568
9839
|
mode: "date",
|
|
9569
9840
|
fsp: 3
|
|
9570
9841
|
}),
|
|
9571
|
-
updatedAt: (0,
|
|
9842
|
+
updatedAt: (0, import_mysql_core24.timestamp)("updatedAt", {
|
|
9572
9843
|
mode: "date",
|
|
9573
9844
|
fsp: 3
|
|
9574
9845
|
}).defaultNow(),
|
|
9575
|
-
deletedAt: (0,
|
|
9846
|
+
deletedAt: (0, import_mysql_core24.timestamp)("deletedAt", {
|
|
9576
9847
|
mode: "date",
|
|
9577
9848
|
fsp: 3
|
|
9578
9849
|
})
|
|
9579
9850
|
}, (cp) => ({
|
|
9580
|
-
userIdIdx: (0,
|
|
9581
|
-
preferenceTypeIdx: (0,
|
|
9582
|
-
channelIdIdx: (0,
|
|
9851
|
+
userIdIdx: (0, import_mysql_core24.index)("userId_idx").on(cp.userId),
|
|
9852
|
+
preferenceTypeIdx: (0, import_mysql_core24.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
9853
|
+
channelIdIdx: (0, import_mysql_core24.index)("channelId_idx").on(cp.channelId)
|
|
9583
9854
|
}));
|
|
9584
9855
|
}
|
|
9585
9856
|
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
@@ -9588,7 +9859,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9588
9859
|
const users = getUsersSchema(mysqlTable);
|
|
9589
9860
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
9590
9861
|
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
9591
|
-
return (0,
|
|
9862
|
+
return (0, import_drizzle_orm20.relations)(communicationPreferences, ({ one }) => ({
|
|
9592
9863
|
user: one(users, {
|
|
9593
9864
|
fields: [
|
|
9594
9865
|
communicationPreferences.userId
|
|
@@ -9621,75 +9892,75 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9621
9892
|
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
9622
9893
|
|
|
9623
9894
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9624
|
-
var
|
|
9625
|
-
var
|
|
9895
|
+
var import_drizzle_orm22 = require("drizzle-orm");
|
|
9896
|
+
var import_mysql_core26 = require("drizzle-orm/mysql-core");
|
|
9626
9897
|
|
|
9627
9898
|
// src/lib/mysql/schemas/auth/permissions.ts
|
|
9628
|
-
var
|
|
9629
|
-
var
|
|
9899
|
+
var import_drizzle_orm21 = require("drizzle-orm");
|
|
9900
|
+
var import_mysql_core25 = require("drizzle-orm/mysql-core");
|
|
9630
9901
|
function getPermissionsSchema(mysqlTable) {
|
|
9631
9902
|
return mysqlTable("Permission", {
|
|
9632
|
-
id: (0,
|
|
9903
|
+
id: (0, import_mysql_core25.varchar)("id", {
|
|
9633
9904
|
length: 255
|
|
9634
9905
|
}).notNull().primaryKey(),
|
|
9635
|
-
name: (0,
|
|
9906
|
+
name: (0, import_mysql_core25.varchar)("name", {
|
|
9636
9907
|
length: 255
|
|
9637
9908
|
}).notNull().unique(),
|
|
9638
|
-
description: (0,
|
|
9639
|
-
active: (0,
|
|
9640
|
-
createdAt: (0,
|
|
9909
|
+
description: (0, import_mysql_core25.text)("description"),
|
|
9910
|
+
active: (0, import_mysql_core25.boolean)("active").notNull().default(true),
|
|
9911
|
+
createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
|
|
9641
9912
|
mode: "date",
|
|
9642
9913
|
fsp: 3
|
|
9643
9914
|
}).defaultNow(),
|
|
9644
|
-
updatedAt: (0,
|
|
9915
|
+
updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
|
|
9645
9916
|
mode: "date",
|
|
9646
9917
|
fsp: 3
|
|
9647
9918
|
}).defaultNow(),
|
|
9648
|
-
deletedAt: (0,
|
|
9919
|
+
deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
|
|
9649
9920
|
mode: "date",
|
|
9650
9921
|
fsp: 3
|
|
9651
9922
|
})
|
|
9652
9923
|
}, (permission) => ({
|
|
9653
|
-
nameIdx: (0,
|
|
9924
|
+
nameIdx: (0, import_mysql_core25.index)("name_idx").on(permission.name)
|
|
9654
9925
|
}));
|
|
9655
9926
|
}
|
|
9656
9927
|
__name(getPermissionsSchema, "getPermissionsSchema");
|
|
9657
9928
|
function getPermissionsRelationsSchema(mysqlTable) {
|
|
9658
|
-
return (0,
|
|
9929
|
+
return (0, import_drizzle_orm21.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
|
|
9659
9930
|
}
|
|
9660
9931
|
__name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
|
|
9661
9932
|
|
|
9662
9933
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9663
9934
|
function getUserPermissionsSchema(mysqlTable) {
|
|
9664
9935
|
return mysqlTable("UserPermission", {
|
|
9665
|
-
userId: (0,
|
|
9936
|
+
userId: (0, import_mysql_core26.varchar)("userId", {
|
|
9666
9937
|
length: 255
|
|
9667
9938
|
}).notNull(),
|
|
9668
|
-
permissionId: (0,
|
|
9939
|
+
permissionId: (0, import_mysql_core26.varchar)("permissionId", {
|
|
9669
9940
|
length: 255
|
|
9670
9941
|
}).notNull(),
|
|
9671
|
-
active: (0,
|
|
9672
|
-
createdAt: (0,
|
|
9942
|
+
active: (0, import_mysql_core26.boolean)("active").notNull().default(true),
|
|
9943
|
+
createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
|
|
9673
9944
|
mode: "date",
|
|
9674
9945
|
fsp: 3
|
|
9675
9946
|
}).defaultNow(),
|
|
9676
|
-
updatedAt: (0,
|
|
9947
|
+
updatedAt: (0, import_mysql_core26.timestamp)("updatedAt", {
|
|
9677
9948
|
mode: "date",
|
|
9678
9949
|
fsp: 3
|
|
9679
9950
|
}).defaultNow(),
|
|
9680
|
-
deletedAt: (0,
|
|
9951
|
+
deletedAt: (0, import_mysql_core26.timestamp)("deletedAt", {
|
|
9681
9952
|
mode: "date",
|
|
9682
9953
|
fsp: 3
|
|
9683
9954
|
})
|
|
9684
9955
|
}, (up) => ({
|
|
9685
|
-
pk: (0,
|
|
9956
|
+
pk: (0, import_mysql_core26.primaryKey)({
|
|
9686
9957
|
columns: [
|
|
9687
9958
|
up.userId,
|
|
9688
9959
|
up.permissionId
|
|
9689
9960
|
]
|
|
9690
9961
|
}),
|
|
9691
|
-
userIdIdx: (0,
|
|
9692
|
-
permissionIdIdx: (0,
|
|
9962
|
+
userIdIdx: (0, import_mysql_core26.index)("userId_idx").on(up.userId),
|
|
9963
|
+
permissionIdIdx: (0, import_mysql_core26.index)("permissionId_idx").on(up.permissionId)
|
|
9693
9964
|
}));
|
|
9694
9965
|
}
|
|
9695
9966
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -9697,7 +9968,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9697
9968
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
9698
9969
|
const users = getUsersSchema(mysqlTable);
|
|
9699
9970
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
9700
|
-
return (0,
|
|
9971
|
+
return (0, import_drizzle_orm22.relations)(userPermissions, ({ one }) => ({
|
|
9701
9972
|
user: one(users, {
|
|
9702
9973
|
fields: [
|
|
9703
9974
|
userPermissions.userId
|
|
@@ -9721,46 +9992,46 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9721
9992
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
9722
9993
|
|
|
9723
9994
|
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
9724
|
-
var
|
|
9725
|
-
var
|
|
9995
|
+
var import_drizzle_orm23 = require("drizzle-orm");
|
|
9996
|
+
var import_mysql_core27 = require("drizzle-orm/mysql-core");
|
|
9726
9997
|
function getUserPrefsSchema(mysqlTable) {
|
|
9727
9998
|
return mysqlTable("UserPrefs", {
|
|
9728
|
-
id: (0,
|
|
9999
|
+
id: (0, import_mysql_core27.varchar)("id", {
|
|
9729
10000
|
length: 191
|
|
9730
10001
|
}).notNull(),
|
|
9731
|
-
type: (0,
|
|
10002
|
+
type: (0, import_mysql_core27.varchar)("type", {
|
|
9732
10003
|
length: 191
|
|
9733
10004
|
}).default("Global").notNull(),
|
|
9734
|
-
userId: (0,
|
|
10005
|
+
userId: (0, import_mysql_core27.varchar)("userId", {
|
|
9735
10006
|
length: 255
|
|
9736
10007
|
}).notNull(),
|
|
9737
|
-
fields: (0,
|
|
9738
|
-
createdAt: (0,
|
|
10008
|
+
fields: (0, import_mysql_core27.json)("fields").$type().default({}),
|
|
10009
|
+
createdAt: (0, import_mysql_core27.timestamp)("createdAt", {
|
|
9739
10010
|
mode: "date",
|
|
9740
10011
|
fsp: 3
|
|
9741
|
-
}).default(
|
|
9742
|
-
updatedAt: (0,
|
|
10012
|
+
}).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
|
|
10013
|
+
updatedAt: (0, import_mysql_core27.timestamp)("updatedAt", {
|
|
9743
10014
|
mode: "date",
|
|
9744
10015
|
fsp: 3
|
|
9745
|
-
}).default(
|
|
9746
|
-
deletedAt: (0,
|
|
10016
|
+
}).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
|
|
10017
|
+
deletedAt: (0, import_mysql_core27.timestamp)("deletedAt", {
|
|
9747
10018
|
mode: "date",
|
|
9748
10019
|
fsp: 3
|
|
9749
10020
|
})
|
|
9750
10021
|
}, (crr) => ({
|
|
9751
|
-
pk: (0,
|
|
10022
|
+
pk: (0, import_mysql_core27.primaryKey)({
|
|
9752
10023
|
columns: [
|
|
9753
10024
|
crr.id
|
|
9754
10025
|
]
|
|
9755
10026
|
}),
|
|
9756
|
-
crrUserIdIdKey: (0,
|
|
10027
|
+
crrUserIdIdKey: (0, import_mysql_core27.index)("crr_userIdId_idx").on(crr.userId)
|
|
9757
10028
|
}));
|
|
9758
10029
|
}
|
|
9759
10030
|
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
9760
10031
|
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
9761
10032
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9762
10033
|
const user = getUsersSchema(mysqlTable);
|
|
9763
|
-
return (0,
|
|
10034
|
+
return (0, import_drizzle_orm23.relations)(userPrefs, ({ one }) => ({
|
|
9764
10035
|
user: one(user, {
|
|
9765
10036
|
fields: [
|
|
9766
10037
|
userPrefs.userId
|
|
@@ -9775,43 +10046,43 @@ function getUserPrefsRelationsSchema(mysqlTable) {
|
|
|
9775
10046
|
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
9776
10047
|
|
|
9777
10048
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9778
|
-
var
|
|
9779
|
-
var
|
|
10049
|
+
var import_drizzle_orm25 = require("drizzle-orm");
|
|
10050
|
+
var import_mysql_core29 = require("drizzle-orm/mysql-core");
|
|
9780
10051
|
|
|
9781
10052
|
// src/lib/mysql/schemas/auth/roles.ts
|
|
9782
|
-
var
|
|
9783
|
-
var
|
|
10053
|
+
var import_drizzle_orm24 = require("drizzle-orm");
|
|
10054
|
+
var import_mysql_core28 = require("drizzle-orm/mysql-core");
|
|
9784
10055
|
function getRolesSchema(mysqlTable) {
|
|
9785
10056
|
return mysqlTable("Role", {
|
|
9786
|
-
id: (0,
|
|
10057
|
+
id: (0, import_mysql_core28.varchar)("id", {
|
|
9787
10058
|
length: 255
|
|
9788
10059
|
}).notNull().primaryKey(),
|
|
9789
|
-
name: (0,
|
|
10060
|
+
name: (0, import_mysql_core28.varchar)("name", {
|
|
9790
10061
|
length: 255
|
|
9791
10062
|
}).notNull().unique(),
|
|
9792
|
-
description: (0,
|
|
9793
|
-
active: (0,
|
|
9794
|
-
createdAt: (0,
|
|
10063
|
+
description: (0, import_mysql_core28.text)("description"),
|
|
10064
|
+
active: (0, import_mysql_core28.boolean)("active").notNull().default(true),
|
|
10065
|
+
createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
|
|
9795
10066
|
mode: "date",
|
|
9796
10067
|
fsp: 3
|
|
9797
10068
|
}).defaultNow(),
|
|
9798
|
-
updatedAt: (0,
|
|
10069
|
+
updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
|
|
9799
10070
|
mode: "date",
|
|
9800
10071
|
fsp: 3
|
|
9801
10072
|
}).defaultNow(),
|
|
9802
|
-
deletedAt: (0,
|
|
10073
|
+
deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
|
|
9803
10074
|
mode: "date",
|
|
9804
10075
|
fsp: 3
|
|
9805
10076
|
})
|
|
9806
10077
|
}, (role) => ({
|
|
9807
|
-
nameIdx: (0,
|
|
10078
|
+
nameIdx: (0, import_mysql_core28.index)("name_idx").on(role.name)
|
|
9808
10079
|
}));
|
|
9809
10080
|
}
|
|
9810
10081
|
__name(getRolesSchema, "getRolesSchema");
|
|
9811
10082
|
function getRolesRelationsSchema(mysqlTable) {
|
|
9812
10083
|
const roles = getRolesSchema(mysqlTable);
|
|
9813
10084
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9814
|
-
return (0,
|
|
10085
|
+
return (0, import_drizzle_orm24.relations)(roles, ({ many }) => ({
|
|
9815
10086
|
userRoles: many(userRoles, {
|
|
9816
10087
|
relationName: "role"
|
|
9817
10088
|
})
|
|
@@ -9822,34 +10093,34 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
|
9822
10093
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9823
10094
|
function getUserRolesSchema(mysqlTable) {
|
|
9824
10095
|
return mysqlTable("UserRole", {
|
|
9825
|
-
userId: (0,
|
|
10096
|
+
userId: (0, import_mysql_core29.varchar)("userId", {
|
|
9826
10097
|
length: 255
|
|
9827
10098
|
}).notNull(),
|
|
9828
|
-
roleId: (0,
|
|
10099
|
+
roleId: (0, import_mysql_core29.varchar)("roleId", {
|
|
9829
10100
|
length: 255
|
|
9830
10101
|
}).notNull(),
|
|
9831
|
-
active: (0,
|
|
9832
|
-
createdAt: (0,
|
|
10102
|
+
active: (0, import_mysql_core29.boolean)("active").notNull().default(true),
|
|
10103
|
+
createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
|
|
9833
10104
|
mode: "date",
|
|
9834
10105
|
fsp: 3
|
|
9835
10106
|
}).defaultNow(),
|
|
9836
|
-
updatedAt: (0,
|
|
10107
|
+
updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
|
|
9837
10108
|
mode: "date",
|
|
9838
10109
|
fsp: 3
|
|
9839
10110
|
}).defaultNow(),
|
|
9840
|
-
deletedAt: (0,
|
|
10111
|
+
deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
|
|
9841
10112
|
mode: "date",
|
|
9842
10113
|
fsp: 3
|
|
9843
10114
|
})
|
|
9844
10115
|
}, (ur) => ({
|
|
9845
|
-
pk: (0,
|
|
10116
|
+
pk: (0, import_mysql_core29.primaryKey)({
|
|
9846
10117
|
columns: [
|
|
9847
10118
|
ur.userId,
|
|
9848
10119
|
ur.roleId
|
|
9849
10120
|
]
|
|
9850
10121
|
}),
|
|
9851
|
-
userIdIdx: (0,
|
|
9852
|
-
roleIdIdx: (0,
|
|
10122
|
+
userIdIdx: (0, import_mysql_core29.index)("userId_idx").on(ur.userId),
|
|
10123
|
+
roleIdIdx: (0, import_mysql_core29.index)("roleId_idx").on(ur.roleId)
|
|
9853
10124
|
}));
|
|
9854
10125
|
}
|
|
9855
10126
|
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
@@ -9857,7 +10128,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
|
|
|
9857
10128
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9858
10129
|
const users = getUsersSchema(mysqlTable);
|
|
9859
10130
|
const roles = getRolesSchema(mysqlTable);
|
|
9860
|
-
return (0,
|
|
10131
|
+
return (0, import_drizzle_orm25.relations)(userRoles, ({ one }) => ({
|
|
9861
10132
|
user: one(users, {
|
|
9862
10133
|
fields: [
|
|
9863
10134
|
userRoles.userId
|
|
@@ -9883,34 +10154,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
|
9883
10154
|
// src/lib/mysql/schemas/auth/users.ts
|
|
9884
10155
|
function getUsersSchema(mysqlTable) {
|
|
9885
10156
|
return mysqlTable("User", {
|
|
9886
|
-
id: (0,
|
|
10157
|
+
id: (0, import_mysql_core30.varchar)("id", {
|
|
9887
10158
|
length: 255
|
|
9888
10159
|
}).notNull().primaryKey(),
|
|
9889
|
-
name: (0,
|
|
10160
|
+
name: (0, import_mysql_core30.varchar)("name", {
|
|
9890
10161
|
length: 255
|
|
9891
10162
|
}),
|
|
9892
|
-
role: (0,
|
|
10163
|
+
role: (0, import_mysql_core30.varchar)("role", {
|
|
9893
10164
|
length: 191
|
|
9894
10165
|
}).notNull().default("user"),
|
|
9895
|
-
email: (0,
|
|
10166
|
+
email: (0, import_mysql_core30.varchar)("email", {
|
|
9896
10167
|
length: 255
|
|
9897
10168
|
}).notNull().unique(),
|
|
9898
|
-
fields: (0,
|
|
9899
|
-
emailVerified: (0,
|
|
10169
|
+
fields: (0, import_mysql_core30.json)("fields").$type().default({}),
|
|
10170
|
+
emailVerified: (0, import_mysql_core30.timestamp)("emailVerified", {
|
|
9900
10171
|
mode: "date",
|
|
9901
10172
|
fsp: 3
|
|
9902
10173
|
}),
|
|
9903
|
-
image: (0,
|
|
10174
|
+
image: (0, import_mysql_core30.varchar)("image", {
|
|
9904
10175
|
length: 255
|
|
9905
10176
|
}),
|
|
9906
|
-
createdAt: (0,
|
|
10177
|
+
createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
|
|
9907
10178
|
mode: "date",
|
|
9908
10179
|
fsp: 3
|
|
9909
|
-
}).default(
|
|
10180
|
+
}).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`)
|
|
9910
10181
|
}, (user) => ({
|
|
9911
|
-
emailIdx: (0,
|
|
9912
|
-
roleIdx: (0,
|
|
9913
|
-
createdAtIdx: (0,
|
|
10182
|
+
emailIdx: (0, import_mysql_core30.index)("email_idx").on(user.email),
|
|
10183
|
+
roleIdx: (0, import_mysql_core30.index)("role_idx").on(user.role),
|
|
10184
|
+
createdAtIdx: (0, import_mysql_core30.index)("created_at_idx").on(user.createdAt)
|
|
9914
10185
|
}));
|
|
9915
10186
|
}
|
|
9916
10187
|
__name(getUsersSchema, "getUsersSchema");
|
|
@@ -9925,7 +10196,7 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
9925
10196
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
9926
10197
|
const comments = getCommentsSchema(mysqlTable);
|
|
9927
10198
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9928
|
-
return (0,
|
|
10199
|
+
return (0, import_drizzle_orm26.relations)(users, ({ many }) => ({
|
|
9929
10200
|
accounts: many(accounts, {
|
|
9930
10201
|
relationName: "user"
|
|
9931
10202
|
}),
|
|
@@ -9960,49 +10231,49 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
|
9960
10231
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
9961
10232
|
function getAccountsSchema(mysqlTable) {
|
|
9962
10233
|
return mysqlTable("Account", {
|
|
9963
|
-
userId: (0,
|
|
10234
|
+
userId: (0, import_mysql_core31.varchar)("userId", {
|
|
9964
10235
|
length: 255
|
|
9965
10236
|
}).notNull(),
|
|
9966
|
-
type: (0,
|
|
10237
|
+
type: (0, import_mysql_core31.varchar)("type", {
|
|
9967
10238
|
length: 255
|
|
9968
10239
|
}).$type().notNull(),
|
|
9969
|
-
provider: (0,
|
|
10240
|
+
provider: (0, import_mysql_core31.varchar)("provider", {
|
|
9970
10241
|
length: 255
|
|
9971
10242
|
}).notNull(),
|
|
9972
|
-
providerAccountId: (0,
|
|
10243
|
+
providerAccountId: (0, import_mysql_core31.varchar)("providerAccountId", {
|
|
9973
10244
|
length: 255
|
|
9974
10245
|
}).notNull(),
|
|
9975
|
-
refresh_token: (0,
|
|
9976
|
-
access_token: (0,
|
|
9977
|
-
oauth_token: (0,
|
|
9978
|
-
oauth_token_secret: (0,
|
|
9979
|
-
expires_at: (0,
|
|
9980
|
-
token_type: (0,
|
|
10246
|
+
refresh_token: (0, import_mysql_core31.text)("refresh_token"),
|
|
10247
|
+
access_token: (0, import_mysql_core31.text)("access_token"),
|
|
10248
|
+
oauth_token: (0, import_mysql_core31.text)("oauth_token"),
|
|
10249
|
+
oauth_token_secret: (0, import_mysql_core31.text)("oauth_token_secret"),
|
|
10250
|
+
expires_at: (0, import_mysql_core31.int)("expires_at"),
|
|
10251
|
+
token_type: (0, import_mysql_core31.varchar)("token_type", {
|
|
9981
10252
|
length: 255
|
|
9982
10253
|
}),
|
|
9983
|
-
scope: (0,
|
|
10254
|
+
scope: (0, import_mysql_core31.varchar)("scope", {
|
|
9984
10255
|
length: 255
|
|
9985
10256
|
}),
|
|
9986
|
-
id_token: (0,
|
|
9987
|
-
session_state: (0,
|
|
10257
|
+
id_token: (0, import_mysql_core31.text)("id_token"),
|
|
10258
|
+
session_state: (0, import_mysql_core31.varchar)("session_state", {
|
|
9988
10259
|
length: 255
|
|
9989
10260
|
}),
|
|
9990
|
-
refresh_token_expires_in: (0,
|
|
10261
|
+
refresh_token_expires_in: (0, import_mysql_core31.int)("refresh_token_expires_in")
|
|
9991
10262
|
}, (account) => ({
|
|
9992
|
-
pk: (0,
|
|
10263
|
+
pk: (0, import_mysql_core31.primaryKey)({
|
|
9993
10264
|
columns: [
|
|
9994
10265
|
account.provider,
|
|
9995
10266
|
account.providerAccountId
|
|
9996
10267
|
]
|
|
9997
10268
|
}),
|
|
9998
|
-
userIdIdx: (0,
|
|
10269
|
+
userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(account.userId)
|
|
9999
10270
|
}));
|
|
10000
10271
|
}
|
|
10001
10272
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
10002
10273
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
10003
10274
|
const accounts = getAccountsSchema(mysqlTable);
|
|
10004
10275
|
const users = getUsersSchema(mysqlTable);
|
|
10005
|
-
return (0,
|
|
10276
|
+
return (0, import_drizzle_orm27.relations)(accounts, ({ one }) => ({
|
|
10006
10277
|
user: one(users, {
|
|
10007
10278
|
fields: [
|
|
10008
10279
|
accounts.userId
|
|
@@ -10017,34 +10288,34 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
10017
10288
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
10018
10289
|
|
|
10019
10290
|
// src/lib/mysql/schemas/auth/device-access-token.ts
|
|
10020
|
-
var
|
|
10021
|
-
var
|
|
10291
|
+
var import_drizzle_orm28 = require("drizzle-orm");
|
|
10292
|
+
var import_mysql_core32 = require("drizzle-orm/mysql-core");
|
|
10022
10293
|
function getDeviceAccessTokenSchema(mysqlTable) {
|
|
10023
10294
|
return mysqlTable("DeviceAccessToken", {
|
|
10024
|
-
token: (0,
|
|
10295
|
+
token: (0, import_mysql_core32.varchar)("token", {
|
|
10025
10296
|
length: 191
|
|
10026
10297
|
}).notNull(),
|
|
10027
|
-
userId: (0,
|
|
10298
|
+
userId: (0, import_mysql_core32.varchar)("userId", {
|
|
10028
10299
|
length: 191
|
|
10029
10300
|
}).notNull(),
|
|
10030
|
-
createdAt: (0,
|
|
10301
|
+
createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
|
|
10031
10302
|
mode: "date",
|
|
10032
10303
|
fsp: 3
|
|
10033
|
-
}).default(
|
|
10304
|
+
}).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`)
|
|
10034
10305
|
}, (crr) => ({
|
|
10035
|
-
pk: (0,
|
|
10306
|
+
pk: (0, import_mysql_core32.primaryKey)({
|
|
10036
10307
|
columns: [
|
|
10037
10308
|
crr.token
|
|
10038
10309
|
]
|
|
10039
10310
|
}),
|
|
10040
|
-
userIdIdx: (0,
|
|
10311
|
+
userIdIdx: (0, import_mysql_core32.index)("userId_idx").on(crr.userId)
|
|
10041
10312
|
}));
|
|
10042
10313
|
}
|
|
10043
10314
|
__name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
|
|
10044
10315
|
function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
10045
10316
|
const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
|
|
10046
10317
|
const user = getUsersSchema(mysqlTable);
|
|
10047
|
-
return (0,
|
|
10318
|
+
return (0, import_drizzle_orm28.relations)(deviceAccessToken, ({ one }) => ({
|
|
10048
10319
|
verifiedBy: one(user, {
|
|
10049
10320
|
fields: [
|
|
10050
10321
|
deviceAccessToken.userId
|
|
@@ -10059,31 +10330,31 @@ function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
|
10059
10330
|
__name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
|
|
10060
10331
|
|
|
10061
10332
|
// src/lib/mysql/schemas/auth/device-verification.ts
|
|
10062
|
-
var
|
|
10063
|
-
var
|
|
10333
|
+
var import_drizzle_orm29 = require("drizzle-orm");
|
|
10334
|
+
var import_mysql_core33 = require("drizzle-orm/mysql-core");
|
|
10064
10335
|
function getDeviceVerificationSchema(mysqlTable) {
|
|
10065
10336
|
return mysqlTable("DeviceVerification", {
|
|
10066
|
-
verifiedByUserId: (0,
|
|
10337
|
+
verifiedByUserId: (0, import_mysql_core33.varchar)("verifiedByUserId", {
|
|
10067
10338
|
length: 255
|
|
10068
10339
|
}),
|
|
10069
|
-
deviceCode: (0,
|
|
10340
|
+
deviceCode: (0, import_mysql_core33.varchar)("deviceCode", {
|
|
10070
10341
|
length: 191
|
|
10071
10342
|
}).notNull(),
|
|
10072
|
-
userCode: (0,
|
|
10073
|
-
expires: (0,
|
|
10343
|
+
userCode: (0, import_mysql_core33.text)("userCode").notNull(),
|
|
10344
|
+
expires: (0, import_mysql_core33.timestamp)("expires", {
|
|
10074
10345
|
mode: "date",
|
|
10075
10346
|
fsp: 3
|
|
10076
10347
|
}).notNull(),
|
|
10077
|
-
createdAt: (0,
|
|
10348
|
+
createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
|
|
10078
10349
|
mode: "date",
|
|
10079
10350
|
fsp: 3
|
|
10080
|
-
}).default(
|
|
10081
|
-
verifiedAt: (0,
|
|
10351
|
+
}).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
|
|
10352
|
+
verifiedAt: (0, import_mysql_core33.timestamp)("verifiedAt", {
|
|
10082
10353
|
mode: "date",
|
|
10083
10354
|
fsp: 3
|
|
10084
10355
|
})
|
|
10085
10356
|
}, (crr) => ({
|
|
10086
|
-
pk: (0,
|
|
10357
|
+
pk: (0, import_mysql_core33.primaryKey)({
|
|
10087
10358
|
columns: [
|
|
10088
10359
|
crr.deviceCode
|
|
10089
10360
|
]
|
|
@@ -10094,7 +10365,7 @@ __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
|
|
|
10094
10365
|
function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
10095
10366
|
const deviceVerification = getDeviceVerificationSchema(mysqlTable);
|
|
10096
10367
|
const user = getUsersSchema(mysqlTable);
|
|
10097
|
-
return (0,
|
|
10368
|
+
return (0, import_drizzle_orm29.relations)(deviceVerification, ({ one }) => ({
|
|
10098
10369
|
verifiedBy: one(user, {
|
|
10099
10370
|
fields: [
|
|
10100
10371
|
deviceVerification.verifiedByUserId
|
|
@@ -10109,38 +10380,38 @@ function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
|
10109
10380
|
__name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
|
|
10110
10381
|
|
|
10111
10382
|
// src/lib/mysql/schemas/auth/role-permissions.ts
|
|
10112
|
-
var
|
|
10113
|
-
var
|
|
10383
|
+
var import_drizzle_orm30 = require("drizzle-orm");
|
|
10384
|
+
var import_mysql_core34 = require("drizzle-orm/mysql-core");
|
|
10114
10385
|
function getRolePermissionsSchema(mysqlTable) {
|
|
10115
10386
|
return mysqlTable("RolePermission", {
|
|
10116
|
-
roleId: (0,
|
|
10387
|
+
roleId: (0, import_mysql_core34.varchar)("roleId", {
|
|
10117
10388
|
length: 255
|
|
10118
10389
|
}).notNull(),
|
|
10119
|
-
permissionId: (0,
|
|
10390
|
+
permissionId: (0, import_mysql_core34.varchar)("permissionId", {
|
|
10120
10391
|
length: 255
|
|
10121
10392
|
}).notNull(),
|
|
10122
|
-
active: (0,
|
|
10123
|
-
createdAt: (0,
|
|
10393
|
+
active: (0, import_mysql_core34.boolean)("active").notNull().default(true),
|
|
10394
|
+
createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
|
|
10124
10395
|
mode: "date",
|
|
10125
10396
|
fsp: 3
|
|
10126
10397
|
}).defaultNow(),
|
|
10127
|
-
updatedAt: (0,
|
|
10398
|
+
updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
|
|
10128
10399
|
mode: "date",
|
|
10129
10400
|
fsp: 3
|
|
10130
10401
|
}).defaultNow(),
|
|
10131
|
-
deletedAt: (0,
|
|
10402
|
+
deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
|
|
10132
10403
|
mode: "date",
|
|
10133
10404
|
fsp: 3
|
|
10134
10405
|
})
|
|
10135
10406
|
}, (rp) => ({
|
|
10136
|
-
pk: (0,
|
|
10407
|
+
pk: (0, import_mysql_core34.primaryKey)({
|
|
10137
10408
|
columns: [
|
|
10138
10409
|
rp.roleId,
|
|
10139
10410
|
rp.permissionId
|
|
10140
10411
|
]
|
|
10141
10412
|
}),
|
|
10142
|
-
roleIdIdx: (0,
|
|
10143
|
-
permissionIdIdx: (0,
|
|
10413
|
+
roleIdIdx: (0, import_mysql_core34.index)("roleId_idx").on(rp.roleId),
|
|
10414
|
+
permissionIdIdx: (0, import_mysql_core34.index)("permissionId_idx").on(rp.permissionId)
|
|
10144
10415
|
}));
|
|
10145
10416
|
}
|
|
10146
10417
|
__name(getRolePermissionsSchema, "getRolePermissionsSchema");
|
|
@@ -10148,7 +10419,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
10148
10419
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
10149
10420
|
const roles = getRolesSchema(mysqlTable);
|
|
10150
10421
|
const rolePermissions = getRolePermissionsSchema(mysqlTable);
|
|
10151
|
-
return (0,
|
|
10422
|
+
return (0, import_drizzle_orm30.relations)(rolePermissions, ({ one }) => ({
|
|
10152
10423
|
role: one(roles, {
|
|
10153
10424
|
fields: [
|
|
10154
10425
|
rolePermissions.roleId
|
|
@@ -10172,28 +10443,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
10172
10443
|
__name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
|
|
10173
10444
|
|
|
10174
10445
|
// src/lib/mysql/schemas/auth/sessions.ts
|
|
10175
|
-
var
|
|
10176
|
-
var
|
|
10446
|
+
var import_drizzle_orm31 = require("drizzle-orm");
|
|
10447
|
+
var import_mysql_core35 = require("drizzle-orm/mysql-core");
|
|
10177
10448
|
function getSessionsSchema(mysqlTable) {
|
|
10178
10449
|
return mysqlTable("Session", {
|
|
10179
|
-
sessionToken: (0,
|
|
10450
|
+
sessionToken: (0, import_mysql_core35.varchar)("sessionToken", {
|
|
10180
10451
|
length: 255
|
|
10181
10452
|
}).notNull().primaryKey(),
|
|
10182
|
-
userId: (0,
|
|
10453
|
+
userId: (0, import_mysql_core35.varchar)("userId", {
|
|
10183
10454
|
length: 255
|
|
10184
10455
|
}).notNull(),
|
|
10185
|
-
expires: (0,
|
|
10456
|
+
expires: (0, import_mysql_core35.timestamp)("expires", {
|
|
10186
10457
|
mode: "date"
|
|
10187
10458
|
}).notNull()
|
|
10188
10459
|
}, (session) => ({
|
|
10189
|
-
userIdIdx: (0,
|
|
10460
|
+
userIdIdx: (0, import_mysql_core35.index)("userId_idx").on(session.userId)
|
|
10190
10461
|
}));
|
|
10191
10462
|
}
|
|
10192
10463
|
__name(getSessionsSchema, "getSessionsSchema");
|
|
10193
10464
|
function getSessionRelationsSchema(mysqlTable) {
|
|
10194
10465
|
const sessions = getSessionsSchema(mysqlTable);
|
|
10195
10466
|
const users = getUsersSchema(mysqlTable);
|
|
10196
|
-
return (0,
|
|
10467
|
+
return (0, import_drizzle_orm31.relations)(sessions, ({ one }) => ({
|
|
10197
10468
|
user: one(users, {
|
|
10198
10469
|
fields: [
|
|
10199
10470
|
sessions.userId
|
|
@@ -10208,24 +10479,24 @@ function getSessionRelationsSchema(mysqlTable) {
|
|
|
10208
10479
|
__name(getSessionRelationsSchema, "getSessionRelationsSchema");
|
|
10209
10480
|
|
|
10210
10481
|
// src/lib/mysql/schemas/auth/verification-tokens.ts
|
|
10211
|
-
var
|
|
10482
|
+
var import_mysql_core36 = require("drizzle-orm/mysql-core");
|
|
10212
10483
|
function getVerificationTokensSchema(mysqlTable) {
|
|
10213
10484
|
return mysqlTable("VerificationToken", {
|
|
10214
|
-
identifier: (0,
|
|
10485
|
+
identifier: (0, import_mysql_core36.varchar)("identifier", {
|
|
10215
10486
|
length: 255
|
|
10216
10487
|
}).notNull(),
|
|
10217
|
-
token: (0,
|
|
10488
|
+
token: (0, import_mysql_core36.varchar)("token", {
|
|
10218
10489
|
length: 255
|
|
10219
10490
|
}).notNull(),
|
|
10220
|
-
expires: (0,
|
|
10491
|
+
expires: (0, import_mysql_core36.timestamp)("expires", {
|
|
10221
10492
|
mode: "date"
|
|
10222
10493
|
}).notNull(),
|
|
10223
|
-
createdAt: (0,
|
|
10494
|
+
createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
|
|
10224
10495
|
mode: "date",
|
|
10225
10496
|
fsp: 3
|
|
10226
10497
|
}).defaultNow()
|
|
10227
10498
|
}, (vt) => ({
|
|
10228
|
-
pk: (0,
|
|
10499
|
+
pk: (0, import_mysql_core36.primaryKey)({
|
|
10229
10500
|
columns: [
|
|
10230
10501
|
vt.identifier,
|
|
10231
10502
|
vt.token
|
|
@@ -10236,14 +10507,14 @@ function getVerificationTokensSchema(mysqlTable) {
|
|
|
10236
10507
|
__name(getVerificationTokensSchema, "getVerificationTokensSchema");
|
|
10237
10508
|
|
|
10238
10509
|
// src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
|
|
10239
|
-
var
|
|
10240
|
-
var
|
|
10510
|
+
var import_drizzle_orm32 = require("drizzle-orm");
|
|
10511
|
+
var import_mysql_core37 = require("drizzle-orm/mysql-core");
|
|
10241
10512
|
function getPurchaseUserTransferSchema(mysqlTable) {
|
|
10242
10513
|
return mysqlTable("PurchaseUserTransfer", {
|
|
10243
|
-
id: (0,
|
|
10514
|
+
id: (0, import_mysql_core37.varchar)("id", {
|
|
10244
10515
|
length: 191
|
|
10245
10516
|
}).notNull(),
|
|
10246
|
-
transferState: (0,
|
|
10517
|
+
transferState: (0, import_mysql_core37.mysqlEnum)("transferState", [
|
|
10247
10518
|
"AVAILABLE",
|
|
10248
10519
|
"INITIATED",
|
|
10249
10520
|
"VERIFIED",
|
|
@@ -10252,38 +10523,38 @@ function getPurchaseUserTransferSchema(mysqlTable) {
|
|
|
10252
10523
|
"CONFIRMED",
|
|
10253
10524
|
"COMPLETED"
|
|
10254
10525
|
]).default("AVAILABLE").notNull(),
|
|
10255
|
-
purchaseId: (0,
|
|
10526
|
+
purchaseId: (0, import_mysql_core37.varchar)("purchaseId", {
|
|
10256
10527
|
length: 191
|
|
10257
10528
|
}).notNull(),
|
|
10258
|
-
sourceUserId: (0,
|
|
10529
|
+
sourceUserId: (0, import_mysql_core37.varchar)("sourceUserId", {
|
|
10259
10530
|
length: 191
|
|
10260
10531
|
}).notNull(),
|
|
10261
|
-
targetUserId: (0,
|
|
10532
|
+
targetUserId: (0, import_mysql_core37.varchar)("targetUserId", {
|
|
10262
10533
|
length: 191
|
|
10263
10534
|
}),
|
|
10264
|
-
createdAt: (0,
|
|
10535
|
+
createdAt: (0, import_mysql_core37.timestamp)("createdAt", {
|
|
10265
10536
|
mode: "date",
|
|
10266
10537
|
fsp: 3
|
|
10267
|
-
}).default(
|
|
10268
|
-
expiresAt: (0,
|
|
10538
|
+
}).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
10539
|
+
expiresAt: (0, import_mysql_core37.timestamp)("expiresAt", {
|
|
10269
10540
|
mode: "date",
|
|
10270
10541
|
fsp: 3
|
|
10271
10542
|
}),
|
|
10272
|
-
canceledAt: (0,
|
|
10543
|
+
canceledAt: (0, import_mysql_core37.timestamp)("canceledAt", {
|
|
10273
10544
|
mode: "date",
|
|
10274
10545
|
fsp: 3
|
|
10275
10546
|
}),
|
|
10276
|
-
confirmedAt: (0,
|
|
10547
|
+
confirmedAt: (0, import_mysql_core37.timestamp)("confirmedAt", {
|
|
10277
10548
|
mode: "date",
|
|
10278
10549
|
fsp: 3
|
|
10279
10550
|
}),
|
|
10280
|
-
completedAt: (0,
|
|
10551
|
+
completedAt: (0, import_mysql_core37.timestamp)("completedAt", {
|
|
10281
10552
|
mode: "date",
|
|
10282
10553
|
fsp: 3
|
|
10283
10554
|
})
|
|
10284
10555
|
}, (table) => {
|
|
10285
10556
|
return {
|
|
10286
|
-
purchaseUserTransferId: (0,
|
|
10557
|
+
purchaseUserTransferId: (0, import_mysql_core37.primaryKey)({
|
|
10287
10558
|
columns: [
|
|
10288
10559
|
table.id
|
|
10289
10560
|
],
|
|
@@ -10297,7 +10568,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10297
10568
|
const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
|
|
10298
10569
|
const user = getUsersSchema(mysqlTable);
|
|
10299
10570
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
10300
|
-
return (0,
|
|
10571
|
+
return (0, import_drizzle_orm32.relations)(purchaseUserTransfer, ({ one }) => ({
|
|
10301
10572
|
sourceUser: one(user, {
|
|
10302
10573
|
fields: [
|
|
10303
10574
|
purchaseUserTransfer.sourceUserId
|
|
@@ -10330,46 +10601,46 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10330
10601
|
__name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
|
|
10331
10602
|
|
|
10332
10603
|
// src/lib/mysql/schemas/commerce/upgradable-products.ts
|
|
10333
|
-
var
|
|
10334
|
-
var
|
|
10604
|
+
var import_drizzle_orm33 = require("drizzle-orm");
|
|
10605
|
+
var import_mysql_core38 = require("drizzle-orm/mysql-core");
|
|
10335
10606
|
function getUpgradableProductsSchema(mysqlTable) {
|
|
10336
10607
|
return mysqlTable("UpgradableProducts", {
|
|
10337
|
-
upgradableToId: (0,
|
|
10608
|
+
upgradableToId: (0, import_mysql_core38.varchar)("upgradableToId", {
|
|
10338
10609
|
length: 255
|
|
10339
10610
|
}).notNull(),
|
|
10340
|
-
upgradableFromId: (0,
|
|
10611
|
+
upgradableFromId: (0, import_mysql_core38.varchar)("upgradableFrom", {
|
|
10341
10612
|
length: 255
|
|
10342
10613
|
}).notNull(),
|
|
10343
|
-
position: (0,
|
|
10344
|
-
metadata: (0,
|
|
10345
|
-
createdAt: (0,
|
|
10614
|
+
position: (0, import_mysql_core38.double)("position").notNull().default(0),
|
|
10615
|
+
metadata: (0, import_mysql_core38.json)("metadata").$type().default({}),
|
|
10616
|
+
createdAt: (0, import_mysql_core38.timestamp)("createdAt", {
|
|
10346
10617
|
mode: "date",
|
|
10347
10618
|
fsp: 3
|
|
10348
|
-
}).default(
|
|
10349
|
-
updatedAt: (0,
|
|
10619
|
+
}).default(import_drizzle_orm33.sql`CURRENT_TIMESTAMP(3)`),
|
|
10620
|
+
updatedAt: (0, import_mysql_core38.timestamp)("updatedAt", {
|
|
10350
10621
|
mode: "date",
|
|
10351
10622
|
fsp: 3
|
|
10352
|
-
}).default(
|
|
10353
|
-
deletedAt: (0,
|
|
10623
|
+
}).default(import_drizzle_orm33.sql`CURRENT_TIMESTAMP(3)`),
|
|
10624
|
+
deletedAt: (0, import_mysql_core38.timestamp)("deletedAt", {
|
|
10354
10625
|
mode: "date",
|
|
10355
10626
|
fsp: 3
|
|
10356
10627
|
})
|
|
10357
10628
|
}, (crr) => ({
|
|
10358
|
-
pk: (0,
|
|
10629
|
+
pk: (0, import_mysql_core38.primaryKey)({
|
|
10359
10630
|
columns: [
|
|
10360
10631
|
crr.upgradableToId,
|
|
10361
10632
|
crr.upgradableFromId
|
|
10362
10633
|
]
|
|
10363
10634
|
}),
|
|
10364
|
-
upgradableToIdIdx: (0,
|
|
10365
|
-
upgradableFromIdIdx: (0,
|
|
10635
|
+
upgradableToIdIdx: (0, import_mysql_core38.index)("upgradableFromId_idx").on(crr.upgradableToId),
|
|
10636
|
+
upgradableFromIdIdx: (0, import_mysql_core38.index)("upgradableToId_idx").on(crr.upgradableFromId)
|
|
10366
10637
|
}));
|
|
10367
10638
|
}
|
|
10368
10639
|
__name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
|
|
10369
10640
|
function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
10370
10641
|
const product = getProductSchema(mysqlTable);
|
|
10371
10642
|
const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
|
|
10372
|
-
return (0,
|
|
10643
|
+
return (0, import_drizzle_orm33.relations)(upgradableProduct, ({ one }) => ({
|
|
10373
10644
|
upgradableTo: one(product, {
|
|
10374
10645
|
fields: [
|
|
10375
10646
|
upgradableProduct.upgradableToId
|
|
@@ -10393,94 +10664,95 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
|
10393
10664
|
__name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
|
|
10394
10665
|
|
|
10395
10666
|
// src/lib/mysql/schemas/content/lesson-progress.ts
|
|
10396
|
-
var
|
|
10397
|
-
var
|
|
10667
|
+
var import_drizzle_orm34 = require("drizzle-orm");
|
|
10668
|
+
var import_mysql_core39 = require("drizzle-orm/mysql-core");
|
|
10398
10669
|
function getLessonProgressSchema(mysqlTable) {
|
|
10399
10670
|
return mysqlTable("LessonProgress", {
|
|
10400
|
-
id: (0,
|
|
10671
|
+
id: (0, import_mysql_core39.varchar)("id", {
|
|
10401
10672
|
length: 191
|
|
10402
10673
|
}).notNull().primaryKey(),
|
|
10403
|
-
userId: (0,
|
|
10674
|
+
userId: (0, import_mysql_core39.varchar)("userId", {
|
|
10404
10675
|
length: 191
|
|
10405
10676
|
}).notNull(),
|
|
10406
|
-
lessonId: (0,
|
|
10677
|
+
lessonId: (0, import_mysql_core39.varchar)("lessonId", {
|
|
10407
10678
|
length: 191
|
|
10408
10679
|
}),
|
|
10409
|
-
lessonSlug: (0,
|
|
10680
|
+
lessonSlug: (0, import_mysql_core39.varchar)("lessonSlug", {
|
|
10410
10681
|
length: 191
|
|
10411
10682
|
}),
|
|
10412
|
-
lessonVersion: (0,
|
|
10683
|
+
lessonVersion: (0, import_mysql_core39.varchar)("lessonVersion", {
|
|
10413
10684
|
length: 191
|
|
10414
10685
|
}),
|
|
10415
|
-
sectionId: (0,
|
|
10686
|
+
sectionId: (0, import_mysql_core39.varchar)("sectionId", {
|
|
10416
10687
|
length: 191
|
|
10417
10688
|
}),
|
|
10418
|
-
moduleId: (0,
|
|
10689
|
+
moduleId: (0, import_mysql_core39.varchar)("moduleId", {
|
|
10419
10690
|
length: 191
|
|
10420
10691
|
}),
|
|
10421
|
-
completedAt: (0,
|
|
10692
|
+
completedAt: (0, import_mysql_core39.datetime)("completedAt", {
|
|
10422
10693
|
mode: "date",
|
|
10423
10694
|
fsp: 3
|
|
10424
10695
|
}),
|
|
10425
|
-
updatedAt: (0,
|
|
10696
|
+
updatedAt: (0, import_mysql_core39.datetime)("updatedAt", {
|
|
10426
10697
|
mode: "date",
|
|
10427
10698
|
fsp: 3
|
|
10428
10699
|
}),
|
|
10429
|
-
createdAt: (0,
|
|
10700
|
+
createdAt: (0, import_mysql_core39.datetime)("createdAt", {
|
|
10430
10701
|
mode: "date",
|
|
10431
10702
|
fsp: 3
|
|
10432
|
-
}).default(
|
|
10703
|
+
}).default(import_drizzle_orm34.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10433
10704
|
}, (crp) => {
|
|
10434
10705
|
return {
|
|
10435
|
-
userIdLessonIdIdx: (0,
|
|
10436
|
-
userIdIdx: (0,
|
|
10437
|
-
lessonIdIdx: (0,
|
|
10706
|
+
userIdLessonIdIdx: (0, import_mysql_core39.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
|
|
10707
|
+
userIdIdx: (0, import_mysql_core39.index)("userId_idx").on(crp.userId),
|
|
10708
|
+
lessonIdIdx: (0, import_mysql_core39.index)("lessonId_idx").on(crp.lessonId)
|
|
10438
10709
|
};
|
|
10439
10710
|
});
|
|
10440
10711
|
}
|
|
10441
10712
|
__name(getLessonProgressSchema, "getLessonProgressSchema");
|
|
10442
10713
|
|
|
10443
10714
|
// src/lib/mysql/schemas/content/resource-progress.ts
|
|
10444
|
-
var
|
|
10445
|
-
var
|
|
10715
|
+
var import_drizzle_orm35 = require("drizzle-orm");
|
|
10716
|
+
var import_mysql_core40 = require("drizzle-orm/mysql-core");
|
|
10446
10717
|
function getResourceProgressSchema(mysqlTable) {
|
|
10447
10718
|
return mysqlTable("ResourceProgress", {
|
|
10448
|
-
userId: (0,
|
|
10719
|
+
userId: (0, import_mysql_core40.varchar)("userId", {
|
|
10449
10720
|
length: 255
|
|
10450
10721
|
}).notNull(),
|
|
10451
|
-
resourceId: (0,
|
|
10722
|
+
resourceId: (0, import_mysql_core40.varchar)("resourceId", {
|
|
10452
10723
|
length: 255
|
|
10453
10724
|
}),
|
|
10454
|
-
fields: (0,
|
|
10455
|
-
completedAt: (0,
|
|
10725
|
+
fields: (0, import_mysql_core40.json)("fields").$type().default({}),
|
|
10726
|
+
completedAt: (0, import_mysql_core40.datetime)("completedAt", {
|
|
10456
10727
|
mode: "date",
|
|
10457
10728
|
fsp: 3
|
|
10458
10729
|
}),
|
|
10459
|
-
updatedAt: (0,
|
|
10730
|
+
updatedAt: (0, import_mysql_core40.datetime)("updatedAt", {
|
|
10460
10731
|
mode: "date",
|
|
10461
10732
|
fsp: 3
|
|
10462
10733
|
}),
|
|
10463
|
-
createdAt: (0,
|
|
10734
|
+
createdAt: (0, import_mysql_core40.datetime)("createdAt", {
|
|
10464
10735
|
mode: "date",
|
|
10465
10736
|
fsp: 3
|
|
10466
|
-
}).default(
|
|
10737
|
+
}).default(import_drizzle_orm35.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10467
10738
|
}, (crp) => {
|
|
10468
10739
|
return {
|
|
10469
|
-
userIdLessonIdIdx: (0,
|
|
10470
|
-
pk: (0,
|
|
10740
|
+
userIdLessonIdIdx: (0, import_mysql_core40.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
|
|
10741
|
+
pk: (0, import_mysql_core40.primaryKey)({
|
|
10471
10742
|
columns: [
|
|
10472
10743
|
crp.userId,
|
|
10473
10744
|
crp.resourceId
|
|
10474
10745
|
]
|
|
10475
10746
|
}),
|
|
10476
|
-
contentResourceIdIdx: (0,
|
|
10477
|
-
userIdIdx: (0,
|
|
10747
|
+
contentResourceIdIdx: (0, import_mysql_core40.index)("contentResourceId_idx").on(crp.resourceId),
|
|
10748
|
+
userIdIdx: (0, import_mysql_core40.index)("resourceId_idx").on(crp.userId)
|
|
10478
10749
|
};
|
|
10479
10750
|
});
|
|
10480
10751
|
}
|
|
10481
10752
|
__name(getResourceProgressSchema, "getResourceProgressSchema");
|
|
10482
10753
|
|
|
10483
10754
|
// src/lib/mysql/index.ts
|
|
10755
|
+
var guid = (0, import_nanoid.customAlphabet)("1234567890abcdefghijklmnopqrstuvwxyz", 5);
|
|
10484
10756
|
function getCourseBuilderSchema(mysqlTable) {
|
|
10485
10757
|
return {
|
|
10486
10758
|
accounts: getAccountsSchema(mysqlTable),
|
|
@@ -10524,9 +10796,13 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10524
10796
|
contentContributions: getContentContributionsSchema(mysqlTable),
|
|
10525
10797
|
contentContributionRelations: getContentContributionRelationsSchema(mysqlTable),
|
|
10526
10798
|
contentResource: getContentResourceSchema(mysqlTable),
|
|
10799
|
+
contentResourceVersion: getContentResourceVersionSchema(mysqlTable),
|
|
10800
|
+
contentResourceVersionRelations: getContentResourceVersionRelationsSchema(mysqlTable),
|
|
10527
10801
|
contentResourceRelations: getContentResourceRelationsSchema(mysqlTable),
|
|
10528
10802
|
contentResourceResource: getContentResourceResourceSchema(mysqlTable),
|
|
10529
10803
|
contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
|
|
10804
|
+
contentResourceTag: getContentResourceTagSchema(mysqlTable),
|
|
10805
|
+
contentResourceTagRelations: getContentResourceTagRelationsSchema(mysqlTable),
|
|
10530
10806
|
contributionTypes: getContributionTypesSchema(mysqlTable),
|
|
10531
10807
|
contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
|
|
10532
10808
|
resourceProgress: getResourceProgressSchema(mysqlTable),
|
|
@@ -10541,6 +10817,10 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10541
10817
|
deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable),
|
|
10542
10818
|
deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
|
|
10543
10819
|
deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable),
|
|
10820
|
+
tag: getTagSchema(mysqlTable),
|
|
10821
|
+
tagRelations: getTagRelationsSchema(mysqlTable),
|
|
10822
|
+
tagTag: getTagTagSchema(mysqlTable),
|
|
10823
|
+
tagTagRelations: getTagTagRelationsSchema(mysqlTable),
|
|
10544
10824
|
userPrefs: getUserPrefsSchema(mysqlTable),
|
|
10545
10825
|
userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable)
|
|
10546
10826
|
};
|
|
@@ -10550,8 +10830,8 @@ function createTables(mySqlTable) {
|
|
|
10550
10830
|
return getCourseBuilderSchema(mySqlTable);
|
|
10551
10831
|
}
|
|
10552
10832
|
__name(createTables, "createTables");
|
|
10553
|
-
function mySqlDrizzleAdapter(client, tableFn =
|
|
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);
|
|
10833
|
+
function mySqlDrizzleAdapter(client, tableFn = import_mysql_core41.mysqlTable, paymentProvider) {
|
|
10834
|
+
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments } = createTables(tableFn);
|
|
10555
10835
|
const adapter = {
|
|
10556
10836
|
client,
|
|
10557
10837
|
async redeemFullPriceCoupon(options) {
|
|
@@ -10563,7 +10843,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10563
10843
|
throw new Error(`unable-to-find-any-product-id`);
|
|
10564
10844
|
const couponValidation = validateCoupon(coupon2, productIds);
|
|
10565
10845
|
if (coupon2 && couponValidation.isRedeemable) {
|
|
10566
|
-
const bulkCouponRedemption = Boolean(coupon2.
|
|
10846
|
+
const bulkCouponRedemption = Boolean(coupon2.maxUses > 1);
|
|
10567
10847
|
const { user } = await adapter.findOrCreateUser(email);
|
|
10568
10848
|
if (!user)
|
|
10569
10849
|
throw new Error(`unable-to-create-user-${email}`);
|
|
@@ -10573,8 +10853,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10573
10853
|
userId: user.id,
|
|
10574
10854
|
productId
|
|
10575
10855
|
});
|
|
10576
|
-
if (existingPurchases.length > 0)
|
|
10577
|
-
|
|
10856
|
+
if (existingPurchases.length > 0) {
|
|
10857
|
+
const errorMessage = `already-purchased-${email}`;
|
|
10858
|
+
console.error(errorMessage);
|
|
10859
|
+
return {
|
|
10860
|
+
error: {
|
|
10861
|
+
message: errorMessage
|
|
10862
|
+
},
|
|
10863
|
+
redeemingForCurrentUser,
|
|
10864
|
+
purchase: null
|
|
10865
|
+
};
|
|
10866
|
+
throw new Error(errorMessage);
|
|
10867
|
+
}
|
|
10578
10868
|
const purchaseId = `purchase-${(0, import_uuid.v4)()}`;
|
|
10579
10869
|
await adapter.createPurchase({
|
|
10580
10870
|
id: purchaseId,
|
|
@@ -10612,12 +10902,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10612
10902
|
},
|
|
10613
10903
|
incrementCouponUsedCount: async (couponId) => {
|
|
10614
10904
|
await client.update(coupon).set({
|
|
10615
|
-
usedCount:
|
|
10616
|
-
}).where((0,
|
|
10905
|
+
usedCount: import_drizzle_orm36.sql`${coupon.usedCount} + 1`
|
|
10906
|
+
}).where((0, import_drizzle_orm36.eq)(coupon.id, couponId));
|
|
10617
10907
|
},
|
|
10618
10908
|
getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
|
|
10619
10909
|
const existingPurchases = await client.query.purchases.findMany({
|
|
10620
|
-
where: (0,
|
|
10910
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm36.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm36.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm36.isNull)(purchaseTable.bulkCouponId))
|
|
10621
10911
|
});
|
|
10622
10912
|
return z.array(purchaseSchema).parse(existingPurchases);
|
|
10623
10913
|
},
|
|
@@ -10630,17 +10920,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10630
10920
|
status: 1
|
|
10631
10921
|
});
|
|
10632
10922
|
return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
10633
|
-
where: (0,
|
|
10923
|
+
where: (0, import_drizzle_orm36.eq)(merchantCustomer.identifier, options.identifier)
|
|
10634
10924
|
}));
|
|
10635
10925
|
},
|
|
10636
10926
|
getMerchantAccount: async (options) => {
|
|
10637
10927
|
return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
|
|
10638
|
-
where: (0,
|
|
10928
|
+
where: (0, import_drizzle_orm36.eq)(merchantAccount.label, options.provider)
|
|
10639
10929
|
}));
|
|
10640
10930
|
},
|
|
10641
10931
|
getMerchantPriceForProductId: async (productId) => {
|
|
10642
10932
|
const merchantPriceData = await client.query.merchantPrice.findFirst({
|
|
10643
|
-
where: (0,
|
|
10933
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm36.eq)(merchantPrice.status, 1))
|
|
10644
10934
|
});
|
|
10645
10935
|
const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
|
|
10646
10936
|
if (!parsedMerchantPrice.success) {
|
|
@@ -10651,7 +10941,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10651
10941
|
},
|
|
10652
10942
|
getMerchantProductForProductId: async (productId) => {
|
|
10653
10943
|
const merchantProductData = await client.query.merchantProduct.findFirst({
|
|
10654
|
-
where: (0,
|
|
10944
|
+
where: (0, import_drizzle_orm36.eq)(merchantProduct.productId, productId)
|
|
10655
10945
|
});
|
|
10656
10946
|
if (!merchantProductData)
|
|
10657
10947
|
return null;
|
|
@@ -10659,7 +10949,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10659
10949
|
},
|
|
10660
10950
|
getMerchantCustomerForUserId: async (userId) => {
|
|
10661
10951
|
const merchantCustomerData = await client.query.merchantCustomer.findFirst({
|
|
10662
|
-
where: (0,
|
|
10952
|
+
where: (0, import_drizzle_orm36.eq)(merchantCustomer.userId, userId)
|
|
10663
10953
|
});
|
|
10664
10954
|
if (!merchantCustomerData)
|
|
10665
10955
|
return null;
|
|
@@ -10668,14 +10958,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10668
10958
|
getUpgradableProducts: async (options) => {
|
|
10669
10959
|
const { upgradableFromId, upgradableToId } = options;
|
|
10670
10960
|
return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
10671
|
-
where: (0,
|
|
10961
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm36.eq)(upgradableProducts.upgradableToId, upgradableToId))
|
|
10672
10962
|
}));
|
|
10673
10963
|
},
|
|
10674
10964
|
async availableUpgradesForProduct(purchases, productId) {
|
|
10675
10965
|
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
10676
10966
|
if (previousPurchaseProductIds.length > 0) {
|
|
10677
|
-
return
|
|
10678
|
-
where: (0,
|
|
10967
|
+
return client.query.upgradableProducts.findMany({
|
|
10968
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm36.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
|
|
10679
10969
|
});
|
|
10680
10970
|
}
|
|
10681
10971
|
return [];
|
|
@@ -10688,7 +10978,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10688
10978
|
throw new Error("No lessonId provided");
|
|
10689
10979
|
}
|
|
10690
10980
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10691
|
-
where: (0,
|
|
10981
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId))
|
|
10692
10982
|
});
|
|
10693
10983
|
const now = /* @__PURE__ */ new Date();
|
|
10694
10984
|
if (lessonProgress) {
|
|
@@ -10696,7 +10986,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10696
10986
|
await client.update(resourceProgress).set({
|
|
10697
10987
|
completedAt: now,
|
|
10698
10988
|
updatedAt: now
|
|
10699
|
-
}).where((0,
|
|
10989
|
+
}).where((0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId));
|
|
10700
10990
|
}
|
|
10701
10991
|
} else {
|
|
10702
10992
|
await client.insert(resourceProgress).values({
|
|
@@ -10707,7 +10997,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10707
10997
|
});
|
|
10708
10998
|
}
|
|
10709
10999
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10710
|
-
where: (0,
|
|
11000
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId))
|
|
10711
11001
|
});
|
|
10712
11002
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
10713
11003
|
if (!parsedLessonProgress.success) {
|
|
@@ -10720,7 +11010,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10720
11010
|
if (!options.couponId && !options.code)
|
|
10721
11011
|
return null;
|
|
10722
11012
|
const couponForIdOrCode = await client.query.coupon.findFirst({
|
|
10723
|
-
where: (0,
|
|
11013
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.or)(options.code ? (0, import_drizzle_orm36.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm36.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm36.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.or)(options.code ? (0, import_drizzle_orm36.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm36.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm36.isNull)(coupon.expires))),
|
|
10724
11014
|
with: {
|
|
10725
11015
|
merchantCoupon: true
|
|
10726
11016
|
}
|
|
@@ -10741,10 +11031,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10741
11031
|
try {
|
|
10742
11032
|
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
|
|
10743
11033
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10744
|
-
where: (0,
|
|
11034
|
+
where: (0, import_drizzle_orm36.eq)(merchantCharge.identifier, stripeChargeId)
|
|
10745
11035
|
}) || null);
|
|
10746
11036
|
const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
|
|
10747
|
-
where: (0,
|
|
11037
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
|
|
10748
11038
|
with: {
|
|
10749
11039
|
user: true,
|
|
10750
11040
|
product: true,
|
|
@@ -10765,12 +11055,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10765
11055
|
merchantCustomerId
|
|
10766
11056
|
});
|
|
10767
11057
|
const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
|
|
10768
|
-
where: (0,
|
|
11058
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm36.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm36.inArray)(purchaseTable.status, [
|
|
10769
11059
|
"Valid",
|
|
10770
11060
|
"Restricted"
|
|
10771
11061
|
]))
|
|
10772
11062
|
}) || null);
|
|
10773
|
-
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0,
|
|
11063
|
+
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm36.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm36.eq)(purchaseTable.userId, userId))).then((res) => {
|
|
10774
11064
|
return res[0]?.Coupon ?? null;
|
|
10775
11065
|
}));
|
|
10776
11066
|
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
|
|
@@ -10781,10 +11071,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10781
11071
|
if (existingBulkCoupon !== null) {
|
|
10782
11072
|
couponToUpdate = await client.update(coupon).set({
|
|
10783
11073
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
|
|
10784
|
-
}).where((0,
|
|
11074
|
+
}).where((0, import_drizzle_orm36.eq)(coupon.id, bulkCouponId));
|
|
10785
11075
|
} else {
|
|
10786
11076
|
const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
10787
|
-
where: (0,
|
|
11077
|
+
where: (0, import_drizzle_orm36.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10788
11078
|
})) : null;
|
|
10789
11079
|
couponToUpdate = await client.insert(coupon).values({
|
|
10790
11080
|
id: bulkCouponId,
|
|
@@ -10805,10 +11095,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10805
11095
|
merchantAccountId
|
|
10806
11096
|
});
|
|
10807
11097
|
const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10808
|
-
where: (0,
|
|
11098
|
+
where: (0, import_drizzle_orm36.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10809
11099
|
}) : null;
|
|
10810
11100
|
const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10811
|
-
where: (0,
|
|
11101
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm36.eq)(merchantCoupon.type, "ppp"))
|
|
10812
11102
|
}) : null;
|
|
10813
11103
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
10814
11104
|
const newPurchase = await client.insert(purchaseTable).values({
|
|
@@ -10839,7 +11129,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10839
11129
|
}
|
|
10840
11130
|
});
|
|
10841
11131
|
const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
10842
|
-
where: (0,
|
|
11132
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId)
|
|
10843
11133
|
}));
|
|
10844
11134
|
if (!parsedPurchase.success) {
|
|
10845
11135
|
console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
|
|
@@ -10884,7 +11174,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10884
11174
|
},
|
|
10885
11175
|
async getCoupon(couponIdOrCode) {
|
|
10886
11176
|
const loadedCoupon = await client.query.coupon.findFirst({
|
|
10887
|
-
where: (0,
|
|
11177
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm36.eq)(coupon.code, couponIdOrCode))
|
|
10888
11178
|
}) || null;
|
|
10889
11179
|
logger.debug("loadedCoupon", {
|
|
10890
11180
|
loadedCoupon
|
|
@@ -10896,18 +11186,31 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10896
11186
|
couponId
|
|
10897
11187
|
});
|
|
10898
11188
|
let couponData;
|
|
11189
|
+
let bulkCouponPurchases;
|
|
10899
11190
|
try {
|
|
10900
11191
|
couponData = await client.query.coupon.findFirst({
|
|
10901
|
-
where: (0,
|
|
11192
|
+
where: (0, import_drizzle_orm36.eq)(coupon.id, couponId),
|
|
10902
11193
|
with: {
|
|
10903
|
-
|
|
10904
|
-
|
|
11194
|
+
bulkPurchases: true,
|
|
11195
|
+
redeemedBulkCouponPurchases: true
|
|
10905
11196
|
}
|
|
10906
11197
|
}) || null;
|
|
10907
11198
|
} catch (e) {
|
|
10908
11199
|
console.log("getCouponWithBulkPurchases");
|
|
10909
11200
|
logger.error(e);
|
|
10910
11201
|
}
|
|
11202
|
+
try {
|
|
11203
|
+
bulkCouponPurchases = await client.query.purchases.findMany({
|
|
11204
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.redeemedBulkCouponId, couponId),
|
|
11205
|
+
with: {
|
|
11206
|
+
user: true
|
|
11207
|
+
}
|
|
11208
|
+
});
|
|
11209
|
+
console.log("purchases with redeemedBulkCouponId", bulkCouponPurchases);
|
|
11210
|
+
} catch (e) {
|
|
11211
|
+
console.log("getCouponWithBulkPurchases");
|
|
11212
|
+
logger.error(e);
|
|
11213
|
+
}
|
|
10911
11214
|
if (!couponData) {
|
|
10912
11215
|
logger.debug("getCouponWithBulkPurchases", {
|
|
10913
11216
|
couponId,
|
|
@@ -10915,20 +11218,23 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10915
11218
|
});
|
|
10916
11219
|
return null;
|
|
10917
11220
|
}
|
|
11221
|
+
const couponWithBulkPurchases = {
|
|
11222
|
+
...couponData,
|
|
11223
|
+
redeemedBulkCouponPurchases: bulkCouponPurchases || []
|
|
11224
|
+
};
|
|
10918
11225
|
const parsedCoupon = couponSchema.merge(z.object({
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
})).nullable().safeParse(couponData);
|
|
11226
|
+
redeemedBulkCouponPurchases: z.array(purchaseSchema)
|
|
11227
|
+
})).nullable().safeParse(couponWithBulkPurchases);
|
|
10922
11228
|
if (!parsedCoupon.success) {
|
|
10923
|
-
console.error("Error parsing coupon", couponData);
|
|
11229
|
+
console.error("Error parsing coupon", JSON.stringify(parsedCoupon.error), couponData);
|
|
10924
11230
|
return null;
|
|
10925
11231
|
}
|
|
10926
11232
|
return parsedCoupon.data;
|
|
10927
11233
|
},
|
|
10928
11234
|
async getDefaultCoupon(productIds) {
|
|
10929
11235
|
const activeSaleCoupon = await client.query.coupon.findFirst({
|
|
10930
|
-
where: (0,
|
|
10931
|
-
orderBy: (0,
|
|
11236
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(coupon.status, 1), (0, import_drizzle_orm36.eq)(coupon.default, true), (0, import_drizzle_orm36.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm36.or)(productIds ? (0, import_drizzle_orm36.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm36.isNull)(coupon.restrictedToProductId))),
|
|
11237
|
+
orderBy: (0, import_drizzle_orm36.desc)(coupon.percentageDiscount),
|
|
10932
11238
|
with: {
|
|
10933
11239
|
merchantCoupon: true,
|
|
10934
11240
|
product: true
|
|
@@ -10952,7 +11258,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10952
11258
|
},
|
|
10953
11259
|
async getLessonProgressForUser(userId) {
|
|
10954
11260
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
10955
|
-
where: (0,
|
|
11261
|
+
where: (0, import_drizzle_orm36.eq)(resourceProgress.userId, userId)
|
|
10956
11262
|
});
|
|
10957
11263
|
const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
10958
11264
|
if (!parsed.success) {
|
|
@@ -10962,109 +11268,65 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
10962
11268
|
return parsed.data;
|
|
10963
11269
|
},
|
|
10964
11270
|
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
|
-
];
|
|
10974
|
-
const module2 = await client.query.contentResource.findFirst({
|
|
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)),
|
|
10976
|
-
with: {
|
|
10977
|
-
resources: {
|
|
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)
|
|
10999
|
-
}
|
|
11000
|
-
}
|
|
11001
|
-
});
|
|
11002
|
-
const parsedModule = ContentResourceSchema.parse(module2);
|
|
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);
|
|
11022
|
-
});
|
|
11023
|
-
const parsedResources = z.array(ContentResourceSchema).safeParse(filteredResources);
|
|
11024
|
-
if (!parsedResources.success) {
|
|
11025
|
-
console.error("Error parsing module resources", parsedResources.error);
|
|
11026
|
-
return {
|
|
11027
|
-
completedLessons: [],
|
|
11028
|
-
nextResource: null,
|
|
11029
|
-
percentCompleted: 0,
|
|
11030
|
-
completedLessonsCount: 0,
|
|
11031
|
-
totalLessonsCount: 0
|
|
11032
|
-
};
|
|
11033
|
-
}
|
|
11034
|
-
const progressResources = parsedResources.data.filter((r) => {
|
|
11035
|
-
return COUNTABLE_MODULE_RESOURCE_TYPES.includes(r.type);
|
|
11036
|
-
});
|
|
11037
|
-
const totalLessonsCount = progressResources.length;
|
|
11038
11271
|
const user = await client.query.users.findFirst({
|
|
11039
|
-
where: (0,
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
with: {
|
|
11043
|
-
role: true
|
|
11044
|
-
}
|
|
11045
|
-
}
|
|
11046
|
-
}
|
|
11047
|
-
}).then(async (res) => {
|
|
11048
|
-
if (res) {
|
|
11049
|
-
return {
|
|
11050
|
-
...res,
|
|
11051
|
-
roles: res.roles.map((r) => r.role)
|
|
11052
|
-
};
|
|
11272
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm36.eq)(users.email, userIdOrEmail)),
|
|
11273
|
+
columns: {
|
|
11274
|
+
id: true
|
|
11053
11275
|
}
|
|
11054
11276
|
});
|
|
11055
11277
|
if (!user) {
|
|
11056
|
-
|
|
11057
|
-
return {
|
|
11058
|
-
completedLessons: [],
|
|
11059
|
-
nextResource: null,
|
|
11060
|
-
percentCompleted: 0,
|
|
11061
|
-
completedLessonsCount: 0,
|
|
11062
|
-
totalLessonsCount
|
|
11063
|
-
};
|
|
11278
|
+
return null;
|
|
11064
11279
|
}
|
|
11065
|
-
const
|
|
11066
|
-
|
|
11067
|
-
|
|
11280
|
+
const ResultRowSchema = z.object({
|
|
11281
|
+
resource_id: z.string(),
|
|
11282
|
+
resource_type: z.enum([
|
|
11283
|
+
"lesson",
|
|
11284
|
+
"exercise"
|
|
11285
|
+
]),
|
|
11286
|
+
resource_slug: z.string().nullable(),
|
|
11287
|
+
completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
|
|
11288
|
+
});
|
|
11289
|
+
const results = await client.execute(import_drizzle_orm36.sql`
|
|
11290
|
+
SELECT
|
|
11291
|
+
cr.id AS resource_id,
|
|
11292
|
+
cr.type AS resource_type,
|
|
11293
|
+
cr.fields->>'$.slug' AS resource_slug,
|
|
11294
|
+
rp.completedAt AS completed_at
|
|
11295
|
+
FROM
|
|
11296
|
+
(SELECT id, fields->>'$.slug' AS slug
|
|
11297
|
+
FROM ${contentResource}
|
|
11298
|
+
WHERE id = ${moduleIdOrSlug}
|
|
11299
|
+
OR fields->>'$.slug' = ${moduleIdOrSlug}) AS w
|
|
11300
|
+
LEFT JOIN
|
|
11301
|
+
(SELECT
|
|
11302
|
+
crr.resourceOfId AS workshop_id,
|
|
11303
|
+
crr.resourceId,
|
|
11304
|
+
crr.position
|
|
11305
|
+
FROM ${contentResourceResource} crr) AS tlr ON w.id = tlr.workshop_id
|
|
11306
|
+
LEFT JOIN ${contentResource} sections ON sections.id = tlr.resourceId AND sections.type = 'section'
|
|
11307
|
+
LEFT JOIN
|
|
11308
|
+
(SELECT
|
|
11309
|
+
crr.resourceOfId AS section_id,
|
|
11310
|
+
crr.resourceId AS resource_id,
|
|
11311
|
+
crr.position AS position_in_section,
|
|
11312
|
+
section_crr.position AS section_position
|
|
11313
|
+
FROM ${contentResourceResource} crr
|
|
11314
|
+
JOIN ${contentResourceResource} section_crr ON crr.resourceOfId = section_crr.resourceId) AS sr
|
|
11315
|
+
ON sr.section_id = sections.id
|
|
11316
|
+
JOIN ${contentResource} cr ON cr.id = COALESCE(sr.resource_id, tlr.resourceId)
|
|
11317
|
+
LEFT JOIN ${resourceProgress} rp ON rp.resourceId = cr.id
|
|
11318
|
+
AND rp.userId = ${user.id}
|
|
11319
|
+
WHERE
|
|
11320
|
+
cr.type IN ('lesson', 'exercise')
|
|
11321
|
+
|
|
11322
|
+
`);
|
|
11323
|
+
const completedLessons = [];
|
|
11324
|
+
let nextResource = null;
|
|
11325
|
+
let completedLessonsCount = 0;
|
|
11326
|
+
let totalLessonsCount = results.rows.length;
|
|
11327
|
+
const parsedRows = z.array(ResultRowSchema).safeParse(results.rows);
|
|
11328
|
+
if (!parsedRows.success) {
|
|
11329
|
+
console.error("Error parsing rows", parsedRows.error);
|
|
11068
11330
|
return {
|
|
11069
11331
|
completedLessons: [],
|
|
11070
11332
|
nextResource: null,
|
|
@@ -11073,34 +11335,30 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11073
11335
|
totalLessonsCount
|
|
11074
11336
|
};
|
|
11075
11337
|
}
|
|
11076
|
-
const
|
|
11077
|
-
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
percentCompleted: 0,
|
|
11094
|
-
completedLessonsCount: 0,
|
|
11095
|
-
totalLessonsCount
|
|
11096
|
-
};
|
|
11338
|
+
for (const row of parsedRows.data) {
|
|
11339
|
+
if (row.completed_at) {
|
|
11340
|
+
completedLessonsCount++;
|
|
11341
|
+
completedLessons.push({
|
|
11342
|
+
userId: user.id,
|
|
11343
|
+
resourceId: row.resource_id,
|
|
11344
|
+
completedAt: new Date(row.completed_at)
|
|
11345
|
+
});
|
|
11346
|
+
} else if (!nextResource) {
|
|
11347
|
+
nextResource = {
|
|
11348
|
+
id: row.resource_id,
|
|
11349
|
+
type: row.resource_type,
|
|
11350
|
+
fields: {
|
|
11351
|
+
slug: row.resource_slug
|
|
11352
|
+
}
|
|
11353
|
+
};
|
|
11354
|
+
}
|
|
11097
11355
|
}
|
|
11098
|
-
const percentCompleted = Math.
|
|
11356
|
+
const percentCompleted = totalLessonsCount > 0 ? Math.ceil(completedLessonsCount / totalLessonsCount * 100) : 0;
|
|
11099
11357
|
return {
|
|
11100
|
-
completedLessons
|
|
11101
|
-
nextResource
|
|
11358
|
+
completedLessons,
|
|
11359
|
+
nextResource,
|
|
11102
11360
|
percentCompleted,
|
|
11103
|
-
completedLessonsCount
|
|
11361
|
+
completedLessonsCount,
|
|
11104
11362
|
totalLessonsCount
|
|
11105
11363
|
};
|
|
11106
11364
|
},
|
|
@@ -11109,23 +11367,23 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11109
11367
|
},
|
|
11110
11368
|
async getMerchantCharge(merchantChargeId) {
|
|
11111
11369
|
const mCharge = await client.query.merchantCharge.findFirst({
|
|
11112
|
-
where: (0,
|
|
11370
|
+
where: (0, import_drizzle_orm36.eq)(merchantCharge.id, merchantChargeId)
|
|
11113
11371
|
});
|
|
11114
11372
|
const parsed = merchantChargeSchema.safeParse(mCharge);
|
|
11115
11373
|
if (!parsed.success) {
|
|
11116
|
-
console.
|
|
11374
|
+
console.info("Error parsing merchantCharge", mCharge);
|
|
11117
11375
|
return null;
|
|
11118
11376
|
}
|
|
11119
11377
|
return parsed.data;
|
|
11120
11378
|
},
|
|
11121
11379
|
async getMerchantCouponsForTypeAndPercent(params) {
|
|
11122
11380
|
return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
|
|
11123
|
-
where: (0,
|
|
11381
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm36.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
11124
11382
|
}));
|
|
11125
11383
|
},
|
|
11126
11384
|
async getMerchantCouponForTypeAndPercent(params) {
|
|
11127
11385
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
11128
|
-
where: (0,
|
|
11386
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm36.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
11129
11387
|
});
|
|
11130
11388
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
11131
11389
|
if (parsed.success) {
|
|
@@ -11135,7 +11393,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11135
11393
|
},
|
|
11136
11394
|
async getMerchantCoupon(merchantCouponId) {
|
|
11137
11395
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
11138
|
-
where: (0,
|
|
11396
|
+
where: (0, import_drizzle_orm36.eq)(merchantCoupon.id, merchantCouponId)
|
|
11139
11397
|
});
|
|
11140
11398
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
11141
11399
|
if (parsed.success) {
|
|
@@ -11145,7 +11403,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11145
11403
|
},
|
|
11146
11404
|
async getMerchantProduct(stripeProductId) {
|
|
11147
11405
|
return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
|
|
11148
|
-
where: (0,
|
|
11406
|
+
where: (0, import_drizzle_orm36.eq)(merchantProduct.identifier, stripeProductId)
|
|
11149
11407
|
}));
|
|
11150
11408
|
},
|
|
11151
11409
|
getPrice(productId) {
|
|
@@ -11153,17 +11411,256 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11153
11411
|
},
|
|
11154
11412
|
async getPriceForProduct(productId) {
|
|
11155
11413
|
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
11156
|
-
where: (0,
|
|
11414
|
+
where: (0, import_drizzle_orm36.eq)(prices.productId, productId)
|
|
11415
|
+
}));
|
|
11416
|
+
},
|
|
11417
|
+
async archiveProduct(productId) {
|
|
11418
|
+
if (!paymentProvider)
|
|
11419
|
+
throw new Error("Payment provider not found");
|
|
11420
|
+
const product = await adapter.getProduct(productId);
|
|
11421
|
+
if (!product) {
|
|
11422
|
+
throw new Error(`Product not found for id (${productId})`);
|
|
11423
|
+
}
|
|
11424
|
+
if (!product.price) {
|
|
11425
|
+
throw new Error(`Product has no price`);
|
|
11426
|
+
}
|
|
11427
|
+
await client.update(products).set({
|
|
11428
|
+
status: 0,
|
|
11429
|
+
name: `${product.name} (Archived)`
|
|
11430
|
+
}).where((0, import_drizzle_orm36.eq)(products.id, productId));
|
|
11431
|
+
await client.update(prices).set({
|
|
11432
|
+
status: 0,
|
|
11433
|
+
nickname: `${product.name} (Archived)`
|
|
11434
|
+
}).where((0, import_drizzle_orm36.eq)(prices.productId, productId));
|
|
11435
|
+
await client.update(merchantProduct).set({
|
|
11436
|
+
status: 0
|
|
11437
|
+
}).where((0, import_drizzle_orm36.eq)(merchantProduct.productId, productId));
|
|
11438
|
+
await client.update(merchantPrice).set({
|
|
11439
|
+
status: 0
|
|
11440
|
+
}).where((0, import_drizzle_orm36.eq)(merchantPrice.priceId, product.price.id));
|
|
11441
|
+
const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
11442
|
+
where: (0, import_drizzle_orm36.eq)(merchantProduct.productId, productId)
|
|
11443
|
+
}));
|
|
11444
|
+
if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
|
|
11445
|
+
throw new Error(`Merchant product not found for id (${productId})`);
|
|
11446
|
+
}
|
|
11447
|
+
await paymentProvider.updateProduct(currentMerchantProduct.identifier, {
|
|
11448
|
+
active: false
|
|
11449
|
+
});
|
|
11450
|
+
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
11451
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(merchantPrice.priceId, product.price.id), (0, import_drizzle_orm36.eq)(merchantPrice.status, 1))
|
|
11452
|
+
}));
|
|
11453
|
+
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
11454
|
+
throw new Error(`Merchant price not found for id (${productId})`);
|
|
11455
|
+
}
|
|
11456
|
+
await paymentProvider.updatePrice(currentMerchantPrice.identifier, {
|
|
11457
|
+
active: false
|
|
11458
|
+
});
|
|
11459
|
+
return adapter.getProduct(productId);
|
|
11460
|
+
},
|
|
11461
|
+
async updateProduct(input) {
|
|
11462
|
+
if (!paymentProvider)
|
|
11463
|
+
throw new Error("Payment provider not found");
|
|
11464
|
+
const currentProduct = await adapter.getProduct(input.id);
|
|
11465
|
+
if (!currentProduct) {
|
|
11466
|
+
throw new Error(`Product not found`);
|
|
11467
|
+
}
|
|
11468
|
+
if (!currentProduct.price) {
|
|
11469
|
+
throw new Error(`Product has no price`);
|
|
11470
|
+
}
|
|
11471
|
+
const merchantProduct2 = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
11472
|
+
where: (merchantProduct3, { eq: eq2 }) => eq2(merchantProduct3.productId, input.id)
|
|
11157
11473
|
}));
|
|
11474
|
+
if (!merchantProduct2 || !merchantProduct2.identifier) {
|
|
11475
|
+
throw new Error(`Merchant product not found`);
|
|
11476
|
+
}
|
|
11477
|
+
const stripeProduct = await paymentProvider.getProduct(merchantProduct2.identifier);
|
|
11478
|
+
const priceChanged = currentProduct.price.unitAmount.toString() !== input.price?.unitAmount.toString();
|
|
11479
|
+
if (priceChanged) {
|
|
11480
|
+
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
11481
|
+
where: (merchantPrice2, { eq: eq2, and: and2 }) => and2(eq2(merchantPrice2.merchantProductId, merchantProduct2.id), eq2(merchantPrice2.status, 1))
|
|
11482
|
+
}));
|
|
11483
|
+
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
11484
|
+
throw new Error(`Merchant price not found`);
|
|
11485
|
+
}
|
|
11486
|
+
const currentStripePrice = await paymentProvider.getPrice(currentMerchantPrice.identifier);
|
|
11487
|
+
const newStripePrice = await paymentProvider.createPrice({
|
|
11488
|
+
product: stripeProduct.id,
|
|
11489
|
+
unit_amount: Math.floor(Number(input.price?.unitAmount || 0) * 100),
|
|
11490
|
+
currency: "usd",
|
|
11491
|
+
metadata: {
|
|
11492
|
+
slug: input.fields.slug
|
|
11493
|
+
},
|
|
11494
|
+
active: true
|
|
11495
|
+
});
|
|
11496
|
+
await paymentProvider.updateProduct(stripeProduct.id, {
|
|
11497
|
+
default_price: newStripePrice.id
|
|
11498
|
+
});
|
|
11499
|
+
const newMerchantPriceId = `mprice_${(0, import_uuid.v4)()}`;
|
|
11500
|
+
await client.insert(merchantPrice).values({
|
|
11501
|
+
id: newMerchantPriceId,
|
|
11502
|
+
merchantProductId: merchantProduct2.id,
|
|
11503
|
+
merchantAccountId: merchantProduct2.merchantAccountId,
|
|
11504
|
+
priceId: currentProduct.price.id,
|
|
11505
|
+
status: 1,
|
|
11506
|
+
identifier: newStripePrice.id
|
|
11507
|
+
});
|
|
11508
|
+
if (currentMerchantPrice) {
|
|
11509
|
+
await client.update(merchantPrice).set({
|
|
11510
|
+
status: 0
|
|
11511
|
+
}).where((0, import_drizzle_orm36.eq)(merchantPrice.id, currentMerchantPrice.id));
|
|
11512
|
+
}
|
|
11513
|
+
await client.update(prices).set({
|
|
11514
|
+
unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
|
|
11515
|
+
nickname: input.name
|
|
11516
|
+
}).where((0, import_drizzle_orm36.eq)(prices.id, currentProduct.price.id));
|
|
11517
|
+
if (currentStripePrice) {
|
|
11518
|
+
await paymentProvider.updatePrice(currentStripePrice.id, {
|
|
11519
|
+
active: false
|
|
11520
|
+
});
|
|
11521
|
+
}
|
|
11522
|
+
}
|
|
11523
|
+
await paymentProvider.updateProduct(stripeProduct.id, {
|
|
11524
|
+
name: input.name,
|
|
11525
|
+
active: true,
|
|
11526
|
+
images: input.fields.image?.url ? [
|
|
11527
|
+
input.fields.image.url
|
|
11528
|
+
] : void 0,
|
|
11529
|
+
description: input.fields.description || "",
|
|
11530
|
+
metadata: {
|
|
11531
|
+
slug: input.fields.slug
|
|
11532
|
+
}
|
|
11533
|
+
});
|
|
11534
|
+
const { image, ...fieldsNoImage } = input.fields;
|
|
11535
|
+
await client.update(products).set({
|
|
11536
|
+
name: input.name,
|
|
11537
|
+
quantityAvailable: input.quantityAvailable,
|
|
11538
|
+
status: 1,
|
|
11539
|
+
fields: {
|
|
11540
|
+
...fieldsNoImage,
|
|
11541
|
+
...image?.url && {
|
|
11542
|
+
image
|
|
11543
|
+
}
|
|
11544
|
+
}
|
|
11545
|
+
}).where((0, import_drizzle_orm36.eq)(products.id, currentProduct.id));
|
|
11546
|
+
return adapter.getProduct(currentProduct.id);
|
|
11158
11547
|
},
|
|
11159
|
-
async
|
|
11160
|
-
|
|
11161
|
-
|
|
11548
|
+
async createProduct(input) {
|
|
11549
|
+
if (!paymentProvider)
|
|
11550
|
+
throw new Error("Payment provider not found");
|
|
11551
|
+
const merchantAccount2 = merchantAccountSchema.nullish().parse(await client.query.merchantAccount.findFirst({
|
|
11552
|
+
where: (merchantAccount3, { eq: eq2 }) => eq2(merchantAccount3.label, "stripe")
|
|
11162
11553
|
}));
|
|
11554
|
+
if (!merchantAccount2) {
|
|
11555
|
+
throw new Error("Merchant account not found");
|
|
11556
|
+
}
|
|
11557
|
+
const hash = guid();
|
|
11558
|
+
const newProductId = (0, import_slugify.default)(`product-${hash}`);
|
|
11559
|
+
const newProduct = {
|
|
11560
|
+
id: newProductId,
|
|
11561
|
+
name: input.name,
|
|
11562
|
+
status: 1,
|
|
11563
|
+
type: "self-paced",
|
|
11564
|
+
quantityAvailable: input.quantityAvailable,
|
|
11565
|
+
fields: {
|
|
11566
|
+
state: "draft",
|
|
11567
|
+
visibility: "unlisted",
|
|
11568
|
+
slug: (0, import_slugify.default)(`${input.name}-${hash}`)
|
|
11569
|
+
}
|
|
11570
|
+
};
|
|
11571
|
+
await client.insert(products).values(newProduct);
|
|
11572
|
+
const priceHash = guid();
|
|
11573
|
+
const newPriceId = `price-${priceHash}`;
|
|
11574
|
+
await client.insert(prices).values({
|
|
11575
|
+
id: newPriceId,
|
|
11576
|
+
productId: newProductId,
|
|
11577
|
+
unitAmount: input.price.toString(),
|
|
11578
|
+
status: 1
|
|
11579
|
+
});
|
|
11580
|
+
const product = await adapter.getProduct(newProductId);
|
|
11581
|
+
const stripeProduct = await paymentProvider.createProduct({
|
|
11582
|
+
name: input.name,
|
|
11583
|
+
metadata: {
|
|
11584
|
+
slug: product?.fields?.slug || null
|
|
11585
|
+
}
|
|
11586
|
+
});
|
|
11587
|
+
const stripePrice = await paymentProvider.createPrice({
|
|
11588
|
+
product: stripeProduct.id,
|
|
11589
|
+
unit_amount: Math.floor(Number(input.price) * 100),
|
|
11590
|
+
currency: "usd",
|
|
11591
|
+
nickname: input.name,
|
|
11592
|
+
metadata: {
|
|
11593
|
+
slug: product?.fields?.slug || null
|
|
11594
|
+
}
|
|
11595
|
+
});
|
|
11596
|
+
const newMerchantProductId = `mproduct_${(0, import_uuid.v4)()}`;
|
|
11597
|
+
await client.insert(merchantProduct).values({
|
|
11598
|
+
id: newMerchantProductId,
|
|
11599
|
+
merchantAccountId: merchantAccount2.id,
|
|
11600
|
+
productId: newProductId,
|
|
11601
|
+
identifier: stripeProduct.id,
|
|
11602
|
+
status: 1
|
|
11603
|
+
});
|
|
11604
|
+
const newMerchantPriceId = `mprice_${(0, import_uuid.v4)()}`;
|
|
11605
|
+
await client.insert(merchantPrice).values({
|
|
11606
|
+
id: newMerchantPriceId,
|
|
11607
|
+
merchantAccountId: merchantAccount2.id,
|
|
11608
|
+
merchantProductId: newMerchantProductId,
|
|
11609
|
+
priceId: newPriceId,
|
|
11610
|
+
identifier: stripePrice.id,
|
|
11611
|
+
status: 1
|
|
11612
|
+
});
|
|
11613
|
+
return product;
|
|
11614
|
+
},
|
|
11615
|
+
async getProduct(productSlugOrId, withResources = true) {
|
|
11616
|
+
if (!productSlugOrId) {
|
|
11617
|
+
return null;
|
|
11618
|
+
}
|
|
11619
|
+
try {
|
|
11620
|
+
const productData = await client.query.products.findFirst({
|
|
11621
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(import_drizzle_orm36.sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), (0, import_drizzle_orm36.eq)(products.id, productSlugOrId))),
|
|
11622
|
+
with: {
|
|
11623
|
+
price: true,
|
|
11624
|
+
...withResources && {
|
|
11625
|
+
resources: {
|
|
11626
|
+
with: {
|
|
11627
|
+
resource: {
|
|
11628
|
+
with: {
|
|
11629
|
+
resources: true
|
|
11630
|
+
}
|
|
11631
|
+
}
|
|
11632
|
+
}
|
|
11633
|
+
}
|
|
11634
|
+
}
|
|
11635
|
+
}
|
|
11636
|
+
});
|
|
11637
|
+
const parsedProduct = productSchema.safeParse(productData);
|
|
11638
|
+
if (!parsedProduct.success) {
|
|
11639
|
+
console.error("Error parsing product", JSON.stringify(parsedProduct.error), JSON.stringify(productData));
|
|
11640
|
+
return null;
|
|
11641
|
+
}
|
|
11642
|
+
return parsedProduct.data;
|
|
11643
|
+
} catch (e) {
|
|
11644
|
+
console.log("getProduct error", e);
|
|
11645
|
+
return null;
|
|
11646
|
+
}
|
|
11647
|
+
},
|
|
11648
|
+
async getProductResources(productId) {
|
|
11649
|
+
const contentResourceProductsForProduct = z.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
|
|
11650
|
+
where: (0, import_drizzle_orm36.eq)(contentResourceProduct.productId, productId)
|
|
11651
|
+
}));
|
|
11652
|
+
if (!contentResourceProductsForProduct) {
|
|
11653
|
+
return null;
|
|
11654
|
+
} else {
|
|
11655
|
+
const contentResources = z.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
|
|
11656
|
+
where: (0, import_drizzle_orm36.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
|
|
11657
|
+
}));
|
|
11658
|
+
return contentResources;
|
|
11659
|
+
}
|
|
11163
11660
|
},
|
|
11164
11661
|
async getPurchaseCountForProduct(productId) {
|
|
11165
11662
|
return await client.query.purchases.findMany({
|
|
11166
|
-
where: (0,
|
|
11663
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm36.inArray)(purchaseTable.status, [
|
|
11167
11664
|
"Valid",
|
|
11168
11665
|
"Restricted"
|
|
11169
11666
|
]))
|
|
@@ -11171,7 +11668,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11171
11668
|
},
|
|
11172
11669
|
async getPurchase(purchaseId) {
|
|
11173
11670
|
const purchase = await client.query.purchases.findFirst({
|
|
11174
|
-
where: (0,
|
|
11671
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId)
|
|
11175
11672
|
});
|
|
11176
11673
|
return purchase ? purchaseSchema.parse(purchase) : null;
|
|
11177
11674
|
},
|
|
@@ -11189,14 +11686,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11189
11686
|
stripeChargeId
|
|
11190
11687
|
});
|
|
11191
11688
|
const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
11192
|
-
where: (0,
|
|
11689
|
+
where: (0, import_drizzle_orm36.eq)(merchantCharge.identifier, stripeChargeId)
|
|
11193
11690
|
}) || null);
|
|
11194
11691
|
if (!chargeForPurchase) {
|
|
11195
|
-
logger.error(new Error(
|
|
11692
|
+
logger.error(new Error(`No charge found for purchase: Stripe Charge ID: ${stripeChargeId}`));
|
|
11196
11693
|
return null;
|
|
11197
11694
|
}
|
|
11198
11695
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
11199
|
-
where: (0,
|
|
11696
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
|
|
11200
11697
|
with: {
|
|
11201
11698
|
user: true,
|
|
11202
11699
|
product: true,
|
|
@@ -11210,7 +11707,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11210
11707
|
},
|
|
11211
11708
|
async getPurchaseUserTransferById(options) {
|
|
11212
11709
|
const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
11213
|
-
where: (0,
|
|
11710
|
+
where: (0, import_drizzle_orm36.eq)(purchaseUserTransfer.id, options.id),
|
|
11214
11711
|
with: {
|
|
11215
11712
|
sourceUser: true,
|
|
11216
11713
|
targetUser: true,
|
|
@@ -11225,7 +11722,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11225
11722
|
},
|
|
11226
11723
|
async getPurchaseWithUser(purchaseId) {
|
|
11227
11724
|
const purchaseData = await client.query.purchases.findFirst({
|
|
11228
|
-
where: (0,
|
|
11725
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId),
|
|
11229
11726
|
with: {
|
|
11230
11727
|
user: true
|
|
11231
11728
|
}
|
|
@@ -11249,13 +11746,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11249
11746
|
"Restricted"
|
|
11250
11747
|
];
|
|
11251
11748
|
const userPurchases = await client.query.purchases.findMany({
|
|
11252
|
-
where: (0,
|
|
11749
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm36.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
11253
11750
|
with: {
|
|
11254
11751
|
user: true,
|
|
11255
11752
|
product: true,
|
|
11256
11753
|
bulkCoupon: true
|
|
11257
11754
|
},
|
|
11258
|
-
orderBy: (0,
|
|
11755
|
+
orderBy: (0, import_drizzle_orm36.asc)(purchaseTable.createdAt)
|
|
11259
11756
|
});
|
|
11260
11757
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
11261
11758
|
if (!parsedPurchases.success) {
|
|
@@ -11271,18 +11768,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11271
11768
|
"Restricted"
|
|
11272
11769
|
];
|
|
11273
11770
|
const userPurchases = await client.query.purchases.findMany({
|
|
11274
|
-
where: (0,
|
|
11771
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm36.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
11275
11772
|
with: {
|
|
11276
11773
|
user: true,
|
|
11277
11774
|
product: true,
|
|
11278
11775
|
bulkCoupon: true
|
|
11279
11776
|
},
|
|
11280
|
-
orderBy: (0,
|
|
11777
|
+
orderBy: (0, import_drizzle_orm36.asc)(purchaseTable.createdAt)
|
|
11281
11778
|
});
|
|
11282
11779
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
11283
11780
|
const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
|
|
11284
11781
|
const thePurchase = await client.query.purchases.findFirst({
|
|
11285
|
-
where: (0,
|
|
11782
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm36.eq)(purchaseTable.userId, userId)),
|
|
11286
11783
|
with: {
|
|
11287
11784
|
user: true,
|
|
11288
11785
|
product: true,
|
|
@@ -11303,7 +11800,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11303
11800
|
let availableUpgrades = [];
|
|
11304
11801
|
if (purchaseCanUpgrade) {
|
|
11305
11802
|
availableUpgrades = await client.query.upgradableProducts.findMany({
|
|
11306
|
-
where: (0,
|
|
11803
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm36.not)((0, import_drizzle_orm36.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
|
|
11307
11804
|
with: {
|
|
11308
11805
|
upgradableTo: true,
|
|
11309
11806
|
upgradableFrom: true
|
|
@@ -11311,10 +11808,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11311
11808
|
});
|
|
11312
11809
|
}
|
|
11313
11810
|
const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
|
|
11314
|
-
where: (0,
|
|
11811
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm36.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm36.inArray)(purchaseTable.status, [
|
|
11315
11812
|
"Valid",
|
|
11316
11813
|
"Restricted"
|
|
11317
|
-
]), (0,
|
|
11814
|
+
]), (0, import_drizzle_orm36.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm36.not)((0, import_drizzle_orm36.eq)(purchaseTable.id, parsedPurchase.data.id))),
|
|
11318
11815
|
with: {
|
|
11319
11816
|
user: true,
|
|
11320
11817
|
product: true,
|
|
@@ -11327,9 +11824,36 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11327
11824
|
purchase: parsedPurchase.data
|
|
11328
11825
|
};
|
|
11329
11826
|
},
|
|
11827
|
+
async getUserWithPurchasersByEmail(email) {
|
|
11828
|
+
const user = await client.query.users.findFirst({
|
|
11829
|
+
where: (0, import_drizzle_orm36.eq)(users.email, email.trim().toLowerCase()),
|
|
11830
|
+
with: {
|
|
11831
|
+
// merchantCustomer: true,
|
|
11832
|
+
roles: {
|
|
11833
|
+
with: {
|
|
11834
|
+
role: true
|
|
11835
|
+
}
|
|
11836
|
+
},
|
|
11837
|
+
purchases: {
|
|
11838
|
+
with: {
|
|
11839
|
+
bulkCoupon: true,
|
|
11840
|
+
merchantCharge: true,
|
|
11841
|
+
product: {
|
|
11842
|
+
columns: {
|
|
11843
|
+
id: true,
|
|
11844
|
+
name: true,
|
|
11845
|
+
key: true
|
|
11846
|
+
}
|
|
11847
|
+
}
|
|
11848
|
+
}
|
|
11849
|
+
}
|
|
11850
|
+
}
|
|
11851
|
+
});
|
|
11852
|
+
return user;
|
|
11853
|
+
},
|
|
11330
11854
|
async getUserById(userId) {
|
|
11331
11855
|
const user = await client.query.users.findFirst({
|
|
11332
|
-
where: (0,
|
|
11856
|
+
where: (0, import_drizzle_orm36.eq)(users.id, userId),
|
|
11333
11857
|
with: {
|
|
11334
11858
|
roles: {
|
|
11335
11859
|
with: {
|
|
@@ -11351,13 +11875,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11351
11875
|
if (userId === void 0)
|
|
11352
11876
|
return [];
|
|
11353
11877
|
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
11354
|
-
where: (0,
|
|
11878
|
+
where: (0, import_drizzle_orm36.eq)(upgradableProducts.upgradableToId, bundleId)
|
|
11355
11879
|
});
|
|
11356
11880
|
const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
|
|
11357
11881
|
return product.upgradableFromId;
|
|
11358
11882
|
}));
|
|
11359
11883
|
const purchases = await client.query.purchases.findMany({
|
|
11360
|
-
where: (0,
|
|
11884
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm36.inArray)(purchaseTable.productId, upgradableFrom))
|
|
11361
11885
|
});
|
|
11362
11886
|
const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
|
|
11363
11887
|
return purchase.productId;
|
|
@@ -11365,7 +11889,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11365
11889
|
if (productsPurchased.length === 0)
|
|
11366
11890
|
return [];
|
|
11367
11891
|
const foundPrices = await client.query.prices.findMany({
|
|
11368
|
-
where: (0,
|
|
11892
|
+
where: (0, import_drizzle_orm36.inArray)(prices.productId, productsPurchased)
|
|
11369
11893
|
});
|
|
11370
11894
|
return z.array(priceSchema).parse(foundPrices);
|
|
11371
11895
|
},
|
|
@@ -11374,14 +11898,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11374
11898
|
throw new Error("No lessonId provided");
|
|
11375
11899
|
}
|
|
11376
11900
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11377
|
-
where: (0,
|
|
11901
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId))
|
|
11378
11902
|
});
|
|
11379
11903
|
const now = /* @__PURE__ */ new Date();
|
|
11380
11904
|
if (lessonProgress) {
|
|
11381
11905
|
await client.update(resourceProgress).set({
|
|
11382
11906
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
11383
11907
|
updatedAt: now
|
|
11384
|
-
}).where((0,
|
|
11908
|
+
}).where((0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId));
|
|
11385
11909
|
} else {
|
|
11386
11910
|
await client.insert(resourceProgress).values({
|
|
11387
11911
|
userId: options.userId,
|
|
@@ -11391,7 +11915,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11391
11915
|
});
|
|
11392
11916
|
}
|
|
11393
11917
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11394
|
-
where: (0,
|
|
11918
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId))
|
|
11395
11919
|
});
|
|
11396
11920
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
11397
11921
|
if (!parsedLessonProgress.success) {
|
|
@@ -11400,25 +11924,116 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11400
11924
|
}
|
|
11401
11925
|
return parsedLessonProgress.data;
|
|
11402
11926
|
},
|
|
11927
|
+
transferPurchaseToUser: async (options) => {
|
|
11928
|
+
const { purchaseId, targetUserId, sourceUserId } = options;
|
|
11929
|
+
const transferId = `put_${(0, import_uuid.v4)()}`;
|
|
11930
|
+
let purchase = await adapter.getPurchase(purchaseId);
|
|
11931
|
+
if (!purchase)
|
|
11932
|
+
throw new Error("No purchase found");
|
|
11933
|
+
if (purchase.userId !== sourceUserId)
|
|
11934
|
+
throw new Error("Invalid source user");
|
|
11935
|
+
await client.transaction(async (trx) => {
|
|
11936
|
+
if (!purchase)
|
|
11937
|
+
throw new Error("No purchase found");
|
|
11938
|
+
await trx.update(purchaseTable).set({
|
|
11939
|
+
userId: targetUserId
|
|
11940
|
+
}).where((0, import_drizzle_orm36.eq)(purchaseTable.id, purchase.id));
|
|
11941
|
+
await trx.insert(purchaseUserTransfer).values({
|
|
11942
|
+
id: transferId,
|
|
11943
|
+
purchaseId: purchase.id,
|
|
11944
|
+
sourceUserId,
|
|
11945
|
+
targetUserId,
|
|
11946
|
+
transferState: "COMPLETED",
|
|
11947
|
+
completedAt: /* @__PURE__ */ new Date()
|
|
11948
|
+
});
|
|
11949
|
+
purchase = await adapter.getPurchase(purchaseId);
|
|
11950
|
+
if (!purchase)
|
|
11951
|
+
throw new Error("No purchase found");
|
|
11952
|
+
if (paymentProvider && purchase.merchantChargeId) {
|
|
11953
|
+
await trx.update(merchantCharge).set({
|
|
11954
|
+
userId: targetUserId
|
|
11955
|
+
}).where((0, import_drizzle_orm36.eq)(merchantCharge.id, purchase.merchantChargeId));
|
|
11956
|
+
const updatedMerchantCharge = await adapter.getMerchantCharge(purchase.merchantChargeId);
|
|
11957
|
+
if (!updatedMerchantCharge)
|
|
11958
|
+
throw new Error("No merchant charge found");
|
|
11959
|
+
await trx.update(merchantCustomer).set({
|
|
11960
|
+
userId: targetUserId
|
|
11961
|
+
}).where((0, import_drizzle_orm36.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId));
|
|
11962
|
+
const updatedMerchantCustomer = merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
11963
|
+
where: (0, import_drizzle_orm36.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId)
|
|
11964
|
+
}));
|
|
11965
|
+
const targetUser = userSchema.parse(await client.query.users.findFirst({
|
|
11966
|
+
where: (0, import_drizzle_orm36.eq)(users.id, targetUserId)
|
|
11967
|
+
}));
|
|
11968
|
+
const sourceUser = userSchema.parse(await client.query.users.findFirst({
|
|
11969
|
+
where: (0, import_drizzle_orm36.eq)(users.id, sourceUserId)
|
|
11970
|
+
}));
|
|
11971
|
+
await paymentProvider.updateCustomer(updatedMerchantCustomer.identifier, {
|
|
11972
|
+
email: targetUser.email,
|
|
11973
|
+
name: targetUser.name || sourceUser.name || "",
|
|
11974
|
+
metadata: {
|
|
11975
|
+
transferId,
|
|
11976
|
+
transferredFrom: sourceUser.email,
|
|
11977
|
+
transferredOn: (/* @__PURE__ */ new Date()).toISOString()
|
|
11978
|
+
}
|
|
11979
|
+
});
|
|
11980
|
+
}
|
|
11981
|
+
});
|
|
11982
|
+
return await adapter.getPurchaseUserTransferById({
|
|
11983
|
+
id: transferId
|
|
11984
|
+
});
|
|
11985
|
+
},
|
|
11403
11986
|
transferPurchasesToNewUser(options) {
|
|
11404
11987
|
throw new Error("Method not implemented.");
|
|
11405
11988
|
},
|
|
11406
|
-
updatePurchaseStatusForCharge(chargeId, status) {
|
|
11407
|
-
|
|
11989
|
+
async updatePurchaseStatusForCharge(chargeId, status) {
|
|
11990
|
+
try {
|
|
11991
|
+
console.log("updatePurchaseStatusForCharge", {
|
|
11992
|
+
chargeId,
|
|
11993
|
+
status
|
|
11994
|
+
});
|
|
11995
|
+
const merchantChargeForPurchase = await client.query.merchantCharge.findFirst({
|
|
11996
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm36.eq)(merchantCharge.id, chargeId))
|
|
11997
|
+
});
|
|
11998
|
+
console.log("merchantChargeForPurchase", {
|
|
11999
|
+
merchantChargeForPurchase
|
|
12000
|
+
});
|
|
12001
|
+
const parsedMerchantChargeForPurchase = merchantChargeSchema.parse(merchantChargeForPurchase);
|
|
12002
|
+
if (!parsedMerchantChargeForPurchase)
|
|
12003
|
+
throw new Error(`no-charge-found-for-purchase ${chargeId}`);
|
|
12004
|
+
const purchase = await client.query.purchases.findFirst({
|
|
12005
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
|
|
12006
|
+
});
|
|
12007
|
+
const parsedPurchase = purchaseSchema.nullable().parse(purchase);
|
|
12008
|
+
if (parsedPurchase) {
|
|
12009
|
+
await client.update(purchaseTable).set({
|
|
12010
|
+
status
|
|
12011
|
+
}).where((0, import_drizzle_orm36.eq)(purchaseTable.id, parsedPurchase.id));
|
|
12012
|
+
const newPurchase = await client.query.purchases.findFirst({
|
|
12013
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, parsedPurchase.id)
|
|
12014
|
+
});
|
|
12015
|
+
return purchaseSchema.optional().parse(newPurchase);
|
|
12016
|
+
} else {
|
|
12017
|
+
throw new Error(`no-purchase-found-for-charge ${chargeId}`);
|
|
12018
|
+
}
|
|
12019
|
+
} catch (e) {
|
|
12020
|
+
console.log("error updating purchase status", e);
|
|
12021
|
+
throw e;
|
|
12022
|
+
}
|
|
11408
12023
|
},
|
|
11409
12024
|
async updatePurchaseUserTransferTransferState(options) {
|
|
11410
12025
|
await client.update(purchaseUserTransfer).set({
|
|
11411
12026
|
transferState: options.transferState
|
|
11412
|
-
}).where((0,
|
|
12027
|
+
}).where((0, import_drizzle_orm36.eq)(purchaseUserTransfer.id, options.id));
|
|
11413
12028
|
const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
11414
|
-
where: (0,
|
|
12029
|
+
where: (0, import_drizzle_orm36.eq)(purchaseUserTransfer.id, options.id)
|
|
11415
12030
|
}) || null;
|
|
11416
12031
|
return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
|
|
11417
12032
|
},
|
|
11418
12033
|
addResourceToResource: async function(options) {
|
|
11419
12034
|
const { parentResourceId, childResourceId } = options;
|
|
11420
12035
|
const parentResourceData = await client.query.contentResource.findFirst({
|
|
11421
|
-
where: (0,
|
|
12036
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(import_drizzle_orm36.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm36.eq)(contentResource.id, parentResourceId)),
|
|
11422
12037
|
with: {
|
|
11423
12038
|
resources: true
|
|
11424
12039
|
}
|
|
@@ -11430,7 +12045,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11430
12045
|
position: parentResource.resources?.length || 0
|
|
11431
12046
|
});
|
|
11432
12047
|
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
11433
|
-
where: (0,
|
|
12048
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm36.eq)(contentResourceResource.resourceId, childResourceId)),
|
|
11434
12049
|
with: {
|
|
11435
12050
|
resource: true
|
|
11436
12051
|
}
|
|
@@ -11441,19 +12056,31 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11441
12056
|
}
|
|
11442
12057
|
return parsedResourceJoin.data;
|
|
11443
12058
|
},
|
|
12059
|
+
async removeResourceFromResource(options) {
|
|
12060
|
+
const { childResourceId, parentResourceId } = options;
|
|
12061
|
+
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
12062
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm36.eq)(contentResourceResource.resourceId, childResourceId))
|
|
12063
|
+
});
|
|
12064
|
+
const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
|
|
12065
|
+
if (!parsedResourceJoin.success) {
|
|
12066
|
+
return null;
|
|
12067
|
+
}
|
|
12068
|
+
await client.delete(contentResourceResource).where((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm36.eq)(contentResourceResource.resourceId, childResourceId)));
|
|
12069
|
+
return parsedResourceJoin.data.resource;
|
|
12070
|
+
},
|
|
11444
12071
|
async updateContentResourceFields(options) {
|
|
11445
12072
|
if (!options.id) {
|
|
11446
12073
|
throw new Error("No content resource id.");
|
|
11447
12074
|
}
|
|
11448
|
-
const currentResource = await client.select().from(contentResource).where((0,
|
|
12075
|
+
const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm36.eq)(contentResource.id, options.id)).then((res) => res[0]);
|
|
11449
12076
|
await client.update(contentResource).set({
|
|
11450
12077
|
fields: {
|
|
11451
12078
|
...currentResource.fields,
|
|
11452
12079
|
...options.fields
|
|
11453
12080
|
}
|
|
11454
|
-
}).where((0,
|
|
12081
|
+
}).where((0, import_drizzle_orm36.eq)(contentResource.id, options.id));
|
|
11455
12082
|
const resource = await client.query.contentResource.findFirst({
|
|
11456
|
-
where: (0,
|
|
12083
|
+
where: (0, import_drizzle_orm36.eq)(contentResource.id, options.id),
|
|
11457
12084
|
with: {
|
|
11458
12085
|
resources: {
|
|
11459
12086
|
with: {
|
|
@@ -11463,12 +12090,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11463
12090
|
with: {
|
|
11464
12091
|
resource: true
|
|
11465
12092
|
},
|
|
11466
|
-
orderBy: (0,
|
|
12093
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11467
12094
|
}
|
|
11468
12095
|
}
|
|
11469
12096
|
}
|
|
11470
12097
|
},
|
|
11471
|
-
orderBy: (0,
|
|
12098
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11472
12099
|
}
|
|
11473
12100
|
}
|
|
11474
12101
|
});
|
|
@@ -11483,7 +12110,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11483
12110
|
if (!id) {
|
|
11484
12111
|
return null;
|
|
11485
12112
|
}
|
|
11486
|
-
const query =
|
|
12113
|
+
const query = import_drizzle_orm36.sql`
|
|
11487
12114
|
SELECT
|
|
11488
12115
|
id as id,
|
|
11489
12116
|
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
@@ -11515,7 +12142,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11515
12142
|
id
|
|
11516
12143
|
});
|
|
11517
12144
|
const resource = await client.query.contentResource.findFirst({
|
|
11518
|
-
where: (0,
|
|
12145
|
+
where: (0, import_drizzle_orm36.eq)(contentResource.id, id),
|
|
11519
12146
|
with: {
|
|
11520
12147
|
resources: {
|
|
11521
12148
|
with: {
|
|
@@ -11525,12 +12152,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11525
12152
|
with: {
|
|
11526
12153
|
resource: true
|
|
11527
12154
|
},
|
|
11528
|
-
orderBy: (0,
|
|
12155
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11529
12156
|
}
|
|
11530
12157
|
}
|
|
11531
12158
|
}
|
|
11532
12159
|
},
|
|
11533
|
-
orderBy: (0,
|
|
12160
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11534
12161
|
}
|
|
11535
12162
|
}
|
|
11536
12163
|
});
|
|
@@ -11543,7 +12170,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11543
12170
|
},
|
|
11544
12171
|
async getContentResource(data) {
|
|
11545
12172
|
const resource = await client.query.contentResource.findFirst({
|
|
11546
|
-
where: (0,
|
|
12173
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(contentResource.id, data), (0, import_drizzle_orm36.eq)(import_drizzle_orm36.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
|
|
11547
12174
|
with: {
|
|
11548
12175
|
resources: {
|
|
11549
12176
|
with: {
|
|
@@ -11561,12 +12188,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11561
12188
|
}
|
|
11562
12189
|
}
|
|
11563
12190
|
},
|
|
11564
|
-
orderBy: (0,
|
|
12191
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11565
12192
|
}
|
|
11566
12193
|
}
|
|
11567
12194
|
}
|
|
11568
12195
|
},
|
|
11569
|
-
orderBy: (0,
|
|
12196
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11570
12197
|
}
|
|
11571
12198
|
}
|
|
11572
12199
|
});
|
|
@@ -11584,61 +12211,61 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11584
12211
|
...data,
|
|
11585
12212
|
id
|
|
11586
12213
|
});
|
|
11587
|
-
return await client.select().from(users).where((0,
|
|
12214
|
+
return await client.select().from(users).where((0, import_drizzle_orm36.eq)(users.id, id)).then((res) => res[0]);
|
|
11588
12215
|
} catch (error) {
|
|
11589
12216
|
console.error(error);
|
|
11590
12217
|
throw error;
|
|
11591
12218
|
}
|
|
11592
12219
|
},
|
|
11593
12220
|
async getUser(data) {
|
|
11594
|
-
return await client.select().from(users).where((0,
|
|
12221
|
+
return await client.select().from(users).where((0, import_drizzle_orm36.eq)(users.id, data)).then((res) => res[0]) ?? null;
|
|
11595
12222
|
},
|
|
11596
12223
|
async getUserByEmail(data) {
|
|
11597
|
-
return await client.select().from(users).where((0,
|
|
12224
|
+
return await client.select().from(users).where((0, import_drizzle_orm36.eq)(users.email, data)).then((res) => res[0]) ?? null;
|
|
11598
12225
|
},
|
|
11599
12226
|
async createSession(data) {
|
|
11600
12227
|
await client.insert(sessions).values(data);
|
|
11601
|
-
return await client.select().from(sessions).where((0,
|
|
12228
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm36.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
11602
12229
|
},
|
|
11603
12230
|
async getSessionAndUser(data) {
|
|
11604
12231
|
return await client.select({
|
|
11605
12232
|
session: sessions,
|
|
11606
12233
|
user: users
|
|
11607
|
-
}).from(sessions).where((0,
|
|
12234
|
+
}).from(sessions).where((0, import_drizzle_orm36.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm36.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
|
|
11608
12235
|
},
|
|
11609
12236
|
async updateUser(data) {
|
|
11610
12237
|
if (!data.id) {
|
|
11611
12238
|
throw new Error("No user id.");
|
|
11612
12239
|
}
|
|
11613
|
-
await client.update(users).set(data).where((0,
|
|
11614
|
-
return await client.select().from(users).where((0,
|
|
12240
|
+
await client.update(users).set(data).where((0, import_drizzle_orm36.eq)(users.id, data.id));
|
|
12241
|
+
return await client.select().from(users).where((0, import_drizzle_orm36.eq)(users.id, data.id)).then((res) => res[0]);
|
|
11615
12242
|
},
|
|
11616
12243
|
async updateSession(data) {
|
|
11617
|
-
await client.update(sessions).set(data).where((0,
|
|
11618
|
-
return await client.select().from(sessions).where((0,
|
|
12244
|
+
await client.update(sessions).set(data).where((0, import_drizzle_orm36.eq)(sessions.sessionToken, data.sessionToken));
|
|
12245
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm36.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
11619
12246
|
},
|
|
11620
12247
|
async linkAccount(rawAccount) {
|
|
11621
12248
|
await client.insert(accounts).values(rawAccount);
|
|
11622
12249
|
},
|
|
11623
12250
|
async getUserByAccount(account) {
|
|
11624
|
-
const dbAccount = await client.select().from(accounts).where((0,
|
|
12251
|
+
const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm36.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm36.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
|
|
11625
12252
|
if (!dbAccount) {
|
|
11626
12253
|
return null;
|
|
11627
12254
|
}
|
|
11628
12255
|
return dbAccount.User;
|
|
11629
12256
|
},
|
|
11630
12257
|
async deleteSession(sessionToken) {
|
|
11631
|
-
const session = await client.select().from(sessions).where((0,
|
|
11632
|
-
await client.delete(sessions).where((0,
|
|
12258
|
+
const session = await client.select().from(sessions).where((0, import_drizzle_orm36.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
|
|
12259
|
+
await client.delete(sessions).where((0, import_drizzle_orm36.eq)(sessions.sessionToken, sessionToken));
|
|
11633
12260
|
return session;
|
|
11634
12261
|
},
|
|
11635
12262
|
async createVerificationToken(token) {
|
|
11636
12263
|
await client.insert(verificationTokens).values(token);
|
|
11637
|
-
return await client.select().from(verificationTokens).where((0,
|
|
12264
|
+
return await client.select().from(verificationTokens).where((0, import_drizzle_orm36.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
|
|
11638
12265
|
},
|
|
11639
12266
|
async useVerificationToken(token) {
|
|
11640
12267
|
try {
|
|
11641
|
-
const deletedToken = await client.select().from(verificationTokens).where((0,
|
|
12268
|
+
const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm36.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
|
|
11642
12269
|
if (deletedToken?.createdAt) {
|
|
11643
12270
|
const TIMEOUT_IN_SECONDS = 90;
|
|
11644
12271
|
const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
@@ -11647,7 +12274,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11647
12274
|
const { id: _, ...verificationToken } = token;
|
|
11648
12275
|
return deletedToken;
|
|
11649
12276
|
} else {
|
|
11650
|
-
await client.delete(verificationTokens).where((0,
|
|
12277
|
+
await client.delete(verificationTokens).where((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm36.eq)(verificationTokens.token, token.token)));
|
|
11651
12278
|
return deletedToken;
|
|
11652
12279
|
}
|
|
11653
12280
|
}
|
|
@@ -11657,14 +12284,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable) {
|
|
|
11657
12284
|
}
|
|
11658
12285
|
},
|
|
11659
12286
|
async deleteUser(id) {
|
|
11660
|
-
const user = await client.select().from(users).where((0,
|
|
11661
|
-
await client.delete(users).where((0,
|
|
11662
|
-
await client.delete(sessions).where((0,
|
|
11663
|
-
await client.delete(accounts).where((0,
|
|
12287
|
+
const user = await client.select().from(users).where((0, import_drizzle_orm36.eq)(users.id, id)).then((res) => res[0] ?? null);
|
|
12288
|
+
await client.delete(users).where((0, import_drizzle_orm36.eq)(users.id, id));
|
|
12289
|
+
await client.delete(sessions).where((0, import_drizzle_orm36.eq)(sessions.userId, id));
|
|
12290
|
+
await client.delete(accounts).where((0, import_drizzle_orm36.eq)(accounts.userId, id));
|
|
11664
12291
|
return user;
|
|
11665
12292
|
},
|
|
11666
12293
|
async unlinkAccount(account) {
|
|
11667
|
-
await client.delete(accounts).where((0,
|
|
12294
|
+
await client.delete(accounts).where((0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm36.eq)(accounts.provider, account.provider)));
|
|
11668
12295
|
return void 0;
|
|
11669
12296
|
}
|
|
11670
12297
|
};
|
|
@@ -11675,6 +12302,7 @@ __name(mySqlDrizzleAdapter, "mySqlDrizzleAdapter");
|
|
|
11675
12302
|
0 && (module.exports = {
|
|
11676
12303
|
createTables,
|
|
11677
12304
|
getCourseBuilderSchema,
|
|
12305
|
+
guid,
|
|
11678
12306
|
mySqlDrizzleAdapter
|
|
11679
12307
|
});
|
|
11680
12308
|
//# sourceMappingURL=index.cjs.map
|