@coursebuilder/adapter-drizzle 0.5.1 → 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-7ISZNMPU.js → chunk-27UC2HEP.js} +2 -2
- package/dist/{chunk-UK6EHYS5.js → chunk-6SLQW6OM.js} +2 -2
- package/dist/{chunk-7X7TMG4A.js → chunk-EFVZ7IN4.js} +2 -2
- package/dist/{chunk-UHH4OVKA.js → chunk-JW2PFVLO.js} +482 -210
- package/dist/{chunk-QPXUGIXO.js → chunk-QQA7STVO.js} +2 -2
- package/dist/{chunk-DAP5KOAO.js → chunk-XJXCDN7B.js} +2 -2
- package/dist/{chunk-KDOSK7KN.js → chunk-YMFPIZMO.js} +2 -2
- package/dist/{chunk-VUS77FG3.js → chunk-ZYQYJNLK.js} +88 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -8
- package/dist/lib/mysql/index.cjs +878 -546
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +3123 -80
- package/dist/lib/mysql/index.d.ts +3123 -80
- package/dist/lib/mysql/index.js +8 -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 +54 -38
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.d.cts +48 -0
- package/dist/lib/mysql/schemas/commerce/coupon.d.ts +48 -0
- 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 -94
- 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 +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/package.json +6 -6
- package/src/lib/mysql/index.ts +117 -0
- 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
|
@@ -39,8 +39,8 @@ __export(mysql_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(mysql_exports);
|
|
40
40
|
var import_slugify = __toESM(require("@sindresorhus/slugify"), 1);
|
|
41
41
|
var import_date_fns2 = require("date-fns");
|
|
42
|
-
var
|
|
43
|
-
var
|
|
42
|
+
var import_drizzle_orm36 = require("drizzle-orm");
|
|
43
|
+
var import_mysql_core41 = require("drizzle-orm/mysql-core");
|
|
44
44
|
var import_nanoid = require("nanoid");
|
|
45
45
|
var import_uuid = require("uuid");
|
|
46
46
|
|
|
@@ -198,8 +198,8 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
198
198
|
"not_finite"
|
|
199
199
|
]);
|
|
200
200
|
var quotelessJson = /* @__PURE__ */ __name((obj) => {
|
|
201
|
-
const
|
|
202
|
-
return
|
|
201
|
+
const json16 = JSON.stringify(obj, null, 2);
|
|
202
|
+
return json16.replace(/"([^"]+)":/g, "$1:");
|
|
203
203
|
}, "quotelessJson");
|
|
204
204
|
var _ZodError = class _ZodError extends Error {
|
|
205
205
|
constructor(issues) {
|
|
@@ -2318,10 +2318,10 @@ var _ZodObject = class _ZodObject extends ZodType {
|
|
|
2318
2318
|
// }) as any;
|
|
2319
2319
|
// return merged;
|
|
2320
2320
|
// }
|
|
2321
|
-
catchall(
|
|
2321
|
+
catchall(index29) {
|
|
2322
2322
|
return new _ZodObject({
|
|
2323
2323
|
...this._def,
|
|
2324
|
-
catchall:
|
|
2324
|
+
catchall: index29
|
|
2325
2325
|
});
|
|
2326
2326
|
}
|
|
2327
2327
|
pick(mask) {
|
|
@@ -2636,9 +2636,9 @@ function mergeValues(a, b) {
|
|
|
2636
2636
|
return { valid: false };
|
|
2637
2637
|
}
|
|
2638
2638
|
const newArray = [];
|
|
2639
|
-
for (let
|
|
2640
|
-
const itemA = a[
|
|
2641
|
-
const itemB = b[
|
|
2639
|
+
for (let index29 = 0; index29 < a.length; index29++) {
|
|
2640
|
+
const itemA = a[index29];
|
|
2641
|
+
const itemB = b[index29];
|
|
2642
2642
|
const sharedValue = mergeValues(itemA, itemB);
|
|
2643
2643
|
if (!sharedValue.valid) {
|
|
2644
2644
|
return { valid: false };
|
|
@@ -2850,10 +2850,10 @@ var _ZodMap = class _ZodMap extends ZodType {
|
|
|
2850
2850
|
}
|
|
2851
2851
|
const keyType = this._def.keyType;
|
|
2852
2852
|
const valueType = this._def.valueType;
|
|
2853
|
-
const pairs = [...ctx.data.entries()].map(([key, value],
|
|
2853
|
+
const pairs = [...ctx.data.entries()].map(([key, value], index29) => {
|
|
2854
2854
|
return {
|
|
2855
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
|
2856
|
-
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"]))
|
|
2857
2857
|
};
|
|
2858
2858
|
});
|
|
2859
2859
|
if (ctx.common.async) {
|
|
@@ -4046,8 +4046,8 @@ var ZodIssueCode2 = util2.arrayToEnum([
|
|
|
4046
4046
|
"not_finite"
|
|
4047
4047
|
]);
|
|
4048
4048
|
var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
|
|
4049
|
-
const
|
|
4050
|
-
return
|
|
4049
|
+
const json16 = JSON.stringify(obj, null, 2);
|
|
4050
|
+
return json16.replace(/"([^"]+)":/g, "$1:");
|
|
4051
4051
|
}, "quotelessJson");
|
|
4052
4052
|
var _a;
|
|
4053
4053
|
var _ZodError2 = (_a = class extends Error {
|
|
@@ -6351,10 +6351,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
|
|
|
6351
6351
|
// }) as any;
|
|
6352
6352
|
// return merged;
|
|
6353
6353
|
// }
|
|
6354
|
-
catchall(
|
|
6354
|
+
catchall(index29) {
|
|
6355
6355
|
return new _a18({
|
|
6356
6356
|
...this._def,
|
|
6357
|
-
catchall:
|
|
6357
|
+
catchall: index29
|
|
6358
6358
|
});
|
|
6359
6359
|
}
|
|
6360
6360
|
pick(mask) {
|
|
@@ -6696,9 +6696,9 @@ function mergeValues2(a, b) {
|
|
|
6696
6696
|
};
|
|
6697
6697
|
}
|
|
6698
6698
|
const newArray = [];
|
|
6699
|
-
for (let
|
|
6700
|
-
const itemA = a[
|
|
6701
|
-
const itemB = b[
|
|
6699
|
+
for (let index29 = 0; index29 < a.length; index29++) {
|
|
6700
|
+
const itemA = a[index29];
|
|
6701
|
+
const itemB = b[index29];
|
|
6702
6702
|
const sharedValue = mergeValues2(itemA, itemB);
|
|
6703
6703
|
if (!sharedValue.valid) {
|
|
6704
6704
|
return {
|
|
@@ -6932,14 +6932,14 @@ var _ZodMap2 = (_a24 = class extends ZodType2 {
|
|
|
6932
6932
|
const valueType = this._def.valueType;
|
|
6933
6933
|
const pairs = [
|
|
6934
6934
|
...ctx.data.entries()
|
|
6935
|
-
].map(([key, value],
|
|
6935
|
+
].map(([key, value], index29) => {
|
|
6936
6936
|
return {
|
|
6937
6937
|
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
|
|
6938
|
-
|
|
6938
|
+
index29,
|
|
6939
6939
|
"key"
|
|
6940
6940
|
])),
|
|
6941
6941
|
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
|
|
6942
|
-
|
|
6942
|
+
index29,
|
|
6943
6943
|
"value"
|
|
6944
6944
|
]))
|
|
6945
6945
|
};
|
|
@@ -8114,7 +8114,7 @@ var priceSchema = z2.object({
|
|
|
8114
8114
|
fields: z2.record(z2.any()).default({})
|
|
8115
8115
|
});
|
|
8116
8116
|
|
|
8117
|
-
// ../core/dist/chunk-
|
|
8117
|
+
// ../core/dist/chunk-6BXXN6IV.js
|
|
8118
8118
|
var ContentResourceResourceSchema = z2.object({
|
|
8119
8119
|
resourceId: z2.string(),
|
|
8120
8120
|
resourceOfId: z2.string(),
|
|
@@ -8129,6 +8129,7 @@ var ContentResourceSchema = z2.object({
|
|
|
8129
8129
|
id: z2.string(),
|
|
8130
8130
|
type: z2.string(),
|
|
8131
8131
|
createdById: z2.string(),
|
|
8132
|
+
currentVersionId: z2.string().nullish(),
|
|
8132
8133
|
fields: z2.record(z2.string(), z2.any()).default({}).nullable().optional(),
|
|
8133
8134
|
createdAt: z2.coerce.date().nullable(),
|
|
8134
8135
|
updatedAt: z2.coerce.date().nullable(),
|
|
@@ -8158,7 +8159,7 @@ var ResourceVisibilitySchema = z2.union([
|
|
|
8158
8159
|
z2.literal("unlisted")
|
|
8159
8160
|
]);
|
|
8160
8161
|
|
|
8161
|
-
// ../core/dist/chunk-
|
|
8162
|
+
// ../core/dist/chunk-LVVTCZ7P.js
|
|
8162
8163
|
var productSchema = z2.object({
|
|
8163
8164
|
id: z2.string().max(191),
|
|
8164
8165
|
name: z2.string().max(191),
|
|
@@ -8224,7 +8225,7 @@ var couponSchema = z2.object({
|
|
|
8224
8225
|
bulkPurchaseId: z2.string().max(191).optional().nullable()
|
|
8225
8226
|
});
|
|
8226
8227
|
|
|
8227
|
-
// ../core/dist/chunk-
|
|
8228
|
+
// ../core/dist/chunk-ACXDXYNY.js
|
|
8228
8229
|
var purchaseSchema = z2.object({
|
|
8229
8230
|
id: z2.string().max(191),
|
|
8230
8231
|
userId: z2.string().max(191).optional().nullable(),
|
|
@@ -8273,7 +8274,7 @@ var purchaseUserTransferSchema = z2.object({
|
|
|
8273
8274
|
completedAt: z2.date().nullable()
|
|
8274
8275
|
});
|
|
8275
8276
|
|
|
8276
|
-
// ../core/dist/chunk-
|
|
8277
|
+
// ../core/dist/chunk-6BTTEQD2.js
|
|
8277
8278
|
var resourceProgressSchema = z2.object({
|
|
8278
8279
|
userId: z2.string().max(191),
|
|
8279
8280
|
resourceId: z2.string().max(191).optional().nullable(),
|
|
@@ -8493,20 +8494,20 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
|
|
|
8493
8494
|
}, "validateCoupon");
|
|
8494
8495
|
|
|
8495
8496
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
8496
|
-
var
|
|
8497
|
-
var
|
|
8497
|
+
var import_drizzle_orm27 = require("drizzle-orm");
|
|
8498
|
+
var import_mysql_core31 = require("drizzle-orm/mysql-core");
|
|
8498
8499
|
|
|
8499
8500
|
// src/lib/mysql/schemas/auth/users.ts
|
|
8500
|
-
var
|
|
8501
|
-
var
|
|
8501
|
+
var import_drizzle_orm26 = require("drizzle-orm");
|
|
8502
|
+
var import_mysql_core30 = require("drizzle-orm/mysql-core");
|
|
8502
8503
|
|
|
8503
8504
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
8504
|
-
var
|
|
8505
|
-
var
|
|
8505
|
+
var import_drizzle_orm18 = require("drizzle-orm");
|
|
8506
|
+
var import_mysql_core20 = require("drizzle-orm/mysql-core");
|
|
8506
8507
|
|
|
8507
8508
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
8508
|
-
var
|
|
8509
|
-
var
|
|
8509
|
+
var import_drizzle_orm14 = require("drizzle-orm");
|
|
8510
|
+
var import_mysql_core15 = require("drizzle-orm/mysql-core");
|
|
8510
8511
|
|
|
8511
8512
|
// src/lib/mysql/schemas/commerce/merchant-coupon.ts
|
|
8512
8513
|
var import_mysql_core = require("drizzle-orm/mysql-core");
|
|
@@ -8544,16 +8545,16 @@ function getMerchantCouponSchema(mysqlTable) {
|
|
|
8544
8545
|
__name(getMerchantCouponSchema, "getMerchantCouponSchema");
|
|
8545
8546
|
|
|
8546
8547
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8547
|
-
var
|
|
8548
|
-
var
|
|
8548
|
+
var import_drizzle_orm13 = require("drizzle-orm");
|
|
8549
|
+
var import_mysql_core14 = require("drizzle-orm/mysql-core");
|
|
8549
8550
|
|
|
8550
8551
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8551
|
-
var
|
|
8552
|
-
var
|
|
8552
|
+
var import_drizzle_orm9 = require("drizzle-orm");
|
|
8553
|
+
var import_mysql_core10 = require("drizzle-orm/mysql-core");
|
|
8553
8554
|
|
|
8554
8555
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8555
|
-
var
|
|
8556
|
-
var
|
|
8556
|
+
var import_drizzle_orm8 = require("drizzle-orm");
|
|
8557
|
+
var import_mysql_core9 = require("drizzle-orm/mysql-core");
|
|
8557
8558
|
|
|
8558
8559
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
8559
8560
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
@@ -8734,19 +8735,27 @@ function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
|
8734
8735
|
}
|
|
8735
8736
|
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
8736
8737
|
|
|
8737
|
-
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
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", {
|
|
8744
8752
|
length: 255
|
|
8745
8753
|
}).notNull(),
|
|
8746
|
-
|
|
8754
|
+
childTagId: (0, import_mysql_core5.varchar)("childTagId", {
|
|
8747
8755
|
length: 255
|
|
8748
8756
|
}).notNull(),
|
|
8749
|
-
|
|
8757
|
+
position: (0, import_mysql_core5.double)("position").notNull().default(0),
|
|
8758
|
+
metadata: (0, import_mysql_core5.json)("metadata").$type().default({}),
|
|
8750
8759
|
createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
|
|
8751
8760
|
mode: "date",
|
|
8752
8761
|
fsp: 3
|
|
@@ -8759,10 +8768,248 @@ function getContentResourceSchema(mysqlTable) {
|
|
|
8759
8768
|
mode: "date",
|
|
8760
8769
|
fsp: 3
|
|
8761
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
|
+
})
|
|
8762
9008
|
}, (cm) => ({
|
|
8763
|
-
typeIdx: (0,
|
|
8764
|
-
createdByIdx: (0,
|
|
8765
|
-
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)
|
|
8766
9013
|
}));
|
|
8767
9014
|
}
|
|
8768
9015
|
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
@@ -8772,7 +9019,10 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8772
9019
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
8773
9020
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8774
9021
|
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
8775
|
-
|
|
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 }) => ({
|
|
8776
9026
|
createdBy: one(users, {
|
|
8777
9027
|
fields: [
|
|
8778
9028
|
contentResource.createdById
|
|
@@ -8782,6 +9032,9 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8782
9032
|
],
|
|
8783
9033
|
relationName: "creator"
|
|
8784
9034
|
}),
|
|
9035
|
+
tags: many(contentResourceTag, {
|
|
9036
|
+
relationName: "contentResource"
|
|
9037
|
+
}),
|
|
8785
9038
|
resources: many(contentResourceResource, {
|
|
8786
9039
|
relationName: "resourceOf"
|
|
8787
9040
|
}),
|
|
@@ -8793,6 +9046,18 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
8793
9046
|
}),
|
|
8794
9047
|
contributions: many(contentContributions, {
|
|
8795
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"
|
|
8796
9061
|
})
|
|
8797
9062
|
}));
|
|
8798
9063
|
}
|
|
@@ -8801,35 +9066,35 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
|
8801
9066
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8802
9067
|
function getContentResourceProductSchema(mysqlTable) {
|
|
8803
9068
|
return mysqlTable("ContentResourceProduct", {
|
|
8804
|
-
productId: (0,
|
|
9069
|
+
productId: (0, import_mysql_core10.varchar)("productId", {
|
|
8805
9070
|
length: 255
|
|
8806
9071
|
}).notNull(),
|
|
8807
|
-
resourceId: (0,
|
|
9072
|
+
resourceId: (0, import_mysql_core10.varchar)("resourceId", {
|
|
8808
9073
|
length: 255
|
|
8809
9074
|
}).notNull(),
|
|
8810
|
-
position: (0,
|
|
8811
|
-
metadata: (0,
|
|
8812
|
-
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", {
|
|
8813
9078
|
mode: "date",
|
|
8814
9079
|
fsp: 3
|
|
8815
|
-
}).default(
|
|
8816
|
-
updatedAt: (0,
|
|
9080
|
+
}).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
|
|
9081
|
+
updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
|
|
8817
9082
|
mode: "date",
|
|
8818
9083
|
fsp: 3
|
|
8819
|
-
}).default(
|
|
8820
|
-
deletedAt: (0,
|
|
9084
|
+
}).default(import_drizzle_orm9.sql`CURRENT_TIMESTAMP(3)`),
|
|
9085
|
+
deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
|
|
8821
9086
|
mode: "date",
|
|
8822
9087
|
fsp: 3
|
|
8823
9088
|
})
|
|
8824
9089
|
}, (crr) => ({
|
|
8825
|
-
pk: (0,
|
|
9090
|
+
pk: (0, import_mysql_core10.primaryKey)({
|
|
8826
9091
|
columns: [
|
|
8827
9092
|
crr.productId,
|
|
8828
9093
|
crr.resourceId
|
|
8829
9094
|
]
|
|
8830
9095
|
}),
|
|
8831
|
-
contentResourceIdIdx: (0,
|
|
8832
|
-
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)
|
|
8833
9098
|
}));
|
|
8834
9099
|
}
|
|
8835
9100
|
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
@@ -8837,7 +9102,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
8837
9102
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8838
9103
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
8839
9104
|
const product = getProductSchema(mysqlTable);
|
|
8840
|
-
return (0,
|
|
9105
|
+
return (0, import_drizzle_orm9.relations)(contentResourceProduct, ({ one }) => ({
|
|
8841
9106
|
product: one(product, {
|
|
8842
9107
|
fields: [
|
|
8843
9108
|
contentResourceProduct.productId
|
|
@@ -8861,79 +9126,79 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
8861
9126
|
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
8862
9127
|
|
|
8863
9128
|
// src/lib/mysql/schemas/commerce/merchant-product.ts
|
|
8864
|
-
var
|
|
8865
|
-
var
|
|
9129
|
+
var import_drizzle_orm10 = require("drizzle-orm");
|
|
9130
|
+
var import_mysql_core11 = require("drizzle-orm/mysql-core");
|
|
8866
9131
|
function getMerchantProductSchema(mysqlTable) {
|
|
8867
9132
|
return mysqlTable("MerchantProduct", {
|
|
8868
|
-
id: (0,
|
|
9133
|
+
id: (0, import_mysql_core11.varchar)("id", {
|
|
8869
9134
|
length: 191
|
|
8870
9135
|
}).notNull(),
|
|
8871
|
-
merchantAccountId: (0,
|
|
9136
|
+
merchantAccountId: (0, import_mysql_core11.varchar)("merchantAccountId", {
|
|
8872
9137
|
length: 191
|
|
8873
9138
|
}).notNull(),
|
|
8874
|
-
productId: (0,
|
|
9139
|
+
productId: (0, import_mysql_core11.varchar)("productId", {
|
|
8875
9140
|
length: 191
|
|
8876
9141
|
}).notNull(),
|
|
8877
|
-
status: (0,
|
|
8878
|
-
identifier: (0,
|
|
9142
|
+
status: (0, import_mysql_core11.int)("status").default(0).notNull(),
|
|
9143
|
+
identifier: (0, import_mysql_core11.varchar)("identifier", {
|
|
8879
9144
|
length: 191
|
|
8880
9145
|
}),
|
|
8881
|
-
createdAt: (0,
|
|
9146
|
+
createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
|
|
8882
9147
|
mode: "date",
|
|
8883
9148
|
fsp: 3
|
|
8884
|
-
}).default(
|
|
9149
|
+
}).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
8885
9150
|
}, (table) => {
|
|
8886
9151
|
return {
|
|
8887
|
-
merchantProductId: (0,
|
|
9152
|
+
merchantProductId: (0, import_mysql_core11.primaryKey)({
|
|
8888
9153
|
columns: [
|
|
8889
9154
|
table.id
|
|
8890
9155
|
],
|
|
8891
9156
|
name: "MerchantProduct_id"
|
|
8892
9157
|
}),
|
|
8893
|
-
merchantProductIdentifierKey: (0,
|
|
9158
|
+
merchantProductIdentifierKey: (0, import_mysql_core11.unique)("MerchantProduct_identifier_key").on(table.identifier)
|
|
8894
9159
|
};
|
|
8895
9160
|
});
|
|
8896
9161
|
}
|
|
8897
9162
|
__name(getMerchantProductSchema, "getMerchantProductSchema");
|
|
8898
9163
|
|
|
8899
9164
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
8900
|
-
var
|
|
8901
|
-
var
|
|
9165
|
+
var import_drizzle_orm12 = require("drizzle-orm");
|
|
9166
|
+
var import_mysql_core13 = require("drizzle-orm/mysql-core");
|
|
8902
9167
|
|
|
8903
9168
|
// src/lib/mysql/schemas/commerce/merchant-price.ts
|
|
8904
|
-
var
|
|
8905
|
-
var
|
|
9169
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
9170
|
+
var import_mysql_core12 = require("drizzle-orm/mysql-core");
|
|
8906
9171
|
function getMerchantPriceSchema(mysqlTable) {
|
|
8907
9172
|
return mysqlTable("MerchantPrice", {
|
|
8908
|
-
id: (0,
|
|
9173
|
+
id: (0, import_mysql_core12.varchar)("id", {
|
|
8909
9174
|
length: 191
|
|
8910
9175
|
}).notNull(),
|
|
8911
|
-
merchantAccountId: (0,
|
|
9176
|
+
merchantAccountId: (0, import_mysql_core12.varchar)("merchantAccountId", {
|
|
8912
9177
|
length: 191
|
|
8913
9178
|
}).notNull(),
|
|
8914
|
-
merchantProductId: (0,
|
|
9179
|
+
merchantProductId: (0, import_mysql_core12.varchar)("merchantProductId", {
|
|
8915
9180
|
length: 191
|
|
8916
9181
|
}).notNull(),
|
|
8917
|
-
status: (0,
|
|
8918
|
-
identifier: (0,
|
|
9182
|
+
status: (0, import_mysql_core12.int)("status").default(0),
|
|
9183
|
+
identifier: (0, import_mysql_core12.varchar)("identifier", {
|
|
8919
9184
|
length: 191
|
|
8920
9185
|
}),
|
|
8921
|
-
createdAt: (0,
|
|
9186
|
+
createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
|
|
8922
9187
|
mode: "date",
|
|
8923
9188
|
fsp: 3
|
|
8924
|
-
}).default(
|
|
8925
|
-
priceId: (0,
|
|
9189
|
+
}).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9190
|
+
priceId: (0, import_mysql_core12.varchar)("priceId", {
|
|
8926
9191
|
length: 191
|
|
8927
9192
|
})
|
|
8928
9193
|
}, (table) => {
|
|
8929
9194
|
return {
|
|
8930
|
-
merchantPriceId: (0,
|
|
9195
|
+
merchantPriceId: (0, import_mysql_core12.primaryKey)({
|
|
8931
9196
|
columns: [
|
|
8932
9197
|
table.id
|
|
8933
9198
|
],
|
|
8934
9199
|
name: "MerchantPrice_id"
|
|
8935
9200
|
}),
|
|
8936
|
-
merchantPriceIdentifierKey: (0,
|
|
9201
|
+
merchantPriceIdentifierKey: (0, import_mysql_core12.unique)("MerchantPrice_identifier_key").on(table.identifier)
|
|
8937
9202
|
};
|
|
8938
9203
|
});
|
|
8939
9204
|
}
|
|
@@ -8942,28 +9207,28 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
|
|
|
8942
9207
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
8943
9208
|
function getPriceSchema(mysqlTable) {
|
|
8944
9209
|
return mysqlTable("Price", {
|
|
8945
|
-
id: (0,
|
|
9210
|
+
id: (0, import_mysql_core13.varchar)("id", {
|
|
8946
9211
|
length: 191
|
|
8947
9212
|
}).notNull(),
|
|
8948
|
-
productId: (0,
|
|
9213
|
+
productId: (0, import_mysql_core13.varchar)("productId", {
|
|
8949
9214
|
length: 191
|
|
8950
9215
|
}),
|
|
8951
|
-
nickname: (0,
|
|
9216
|
+
nickname: (0, import_mysql_core13.varchar)("nickname", {
|
|
8952
9217
|
length: 191
|
|
8953
9218
|
}),
|
|
8954
|
-
status: (0,
|
|
8955
|
-
unitAmount: (0,
|
|
9219
|
+
status: (0, import_mysql_core13.int)("status").default(0).notNull(),
|
|
9220
|
+
unitAmount: (0, import_mysql_core13.decimal)("unitAmount", {
|
|
8956
9221
|
precision: 10,
|
|
8957
9222
|
scale: 2
|
|
8958
9223
|
}).notNull(),
|
|
8959
|
-
createdAt: (0,
|
|
9224
|
+
createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
|
|
8960
9225
|
mode: "date",
|
|
8961
9226
|
fsp: 3
|
|
8962
|
-
}).default(
|
|
8963
|
-
fields: (0,
|
|
9227
|
+
}).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9228
|
+
fields: (0, import_mysql_core13.json)("fields").$type().default({})
|
|
8964
9229
|
}, (table) => {
|
|
8965
9230
|
return {
|
|
8966
|
-
priceId: (0,
|
|
9231
|
+
priceId: (0, import_mysql_core13.primaryKey)({
|
|
8967
9232
|
columns: [
|
|
8968
9233
|
table.id
|
|
8969
9234
|
],
|
|
@@ -8977,28 +9242,28 @@ __name(getPriceSchema, "getPriceSchema");
|
|
|
8977
9242
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8978
9243
|
function getProductSchema(mysqlTable) {
|
|
8979
9244
|
return mysqlTable("Product", {
|
|
8980
|
-
id: (0,
|
|
9245
|
+
id: (0, import_mysql_core14.varchar)("id", {
|
|
8981
9246
|
length: 191
|
|
8982
9247
|
}).notNull(),
|
|
8983
|
-
name: (0,
|
|
9248
|
+
name: (0, import_mysql_core14.varchar)("name", {
|
|
8984
9249
|
length: 191
|
|
8985
9250
|
}).notNull(),
|
|
8986
|
-
key: (0,
|
|
9251
|
+
key: (0, import_mysql_core14.varchar)("key", {
|
|
8987
9252
|
length: 191
|
|
8988
9253
|
}),
|
|
8989
|
-
type: (0,
|
|
9254
|
+
type: (0, import_mysql_core14.varchar)("type", {
|
|
8990
9255
|
length: 191
|
|
8991
9256
|
}),
|
|
8992
|
-
fields: (0,
|
|
8993
|
-
createdAt: (0,
|
|
9257
|
+
fields: (0, import_mysql_core14.json)("fields").$type().default({}),
|
|
9258
|
+
createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
|
|
8994
9259
|
mode: "date",
|
|
8995
9260
|
fsp: 3
|
|
8996
|
-
}).default(
|
|
8997
|
-
status: (0,
|
|
8998
|
-
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()
|
|
8999
9264
|
}, (table) => {
|
|
9000
9265
|
return {
|
|
9001
|
-
productId: (0,
|
|
9266
|
+
productId: (0, import_mysql_core14.primaryKey)({
|
|
9002
9267
|
columns: [
|
|
9003
9268
|
table.id
|
|
9004
9269
|
],
|
|
@@ -9013,7 +9278,7 @@ function getProductRelationsSchema(mysqlTable) {
|
|
|
9013
9278
|
const price = getPriceSchema(mysqlTable);
|
|
9014
9279
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
9015
9280
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
9016
|
-
return (0,
|
|
9281
|
+
return (0, import_drizzle_orm13.relations)(product, ({ one, many }) => ({
|
|
9017
9282
|
price: one(price, {
|
|
9018
9283
|
fields: [
|
|
9019
9284
|
product.id
|
|
@@ -9042,45 +9307,45 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
|
9042
9307
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
9043
9308
|
function getCouponSchema(mysqlTable) {
|
|
9044
9309
|
return mysqlTable("Coupon", {
|
|
9045
|
-
id: (0,
|
|
9310
|
+
id: (0, import_mysql_core15.varchar)("id", {
|
|
9046
9311
|
length: 191
|
|
9047
9312
|
}).notNull(),
|
|
9048
|
-
code: (0,
|
|
9313
|
+
code: (0, import_mysql_core15.varchar)("code", {
|
|
9049
9314
|
length: 191
|
|
9050
9315
|
}),
|
|
9051
|
-
createdAt: (0,
|
|
9316
|
+
createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
|
|
9052
9317
|
mode: "date",
|
|
9053
9318
|
fsp: 3
|
|
9054
|
-
}).default(
|
|
9055
|
-
expires: (0,
|
|
9319
|
+
}).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9320
|
+
expires: (0, import_mysql_core15.timestamp)("expires", {
|
|
9056
9321
|
mode: "date",
|
|
9057
9322
|
fsp: 3
|
|
9058
9323
|
}),
|
|
9059
|
-
fields: (0,
|
|
9060
|
-
maxUses: (0,
|
|
9061
|
-
default: (0,
|
|
9062
|
-
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", {
|
|
9063
9328
|
length: 191
|
|
9064
9329
|
}),
|
|
9065
|
-
status: (0,
|
|
9066
|
-
usedCount: (0,
|
|
9067
|
-
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", {
|
|
9068
9333
|
precision: 3,
|
|
9069
9334
|
scale: 2
|
|
9070
9335
|
}).notNull(),
|
|
9071
|
-
restrictedToProductId: (0,
|
|
9336
|
+
restrictedToProductId: (0, import_mysql_core15.varchar)("restrictedToProductId", {
|
|
9072
9337
|
length: 191
|
|
9073
9338
|
})
|
|
9074
9339
|
}, (table) => {
|
|
9075
9340
|
return {
|
|
9076
|
-
couponIdCodeIndex: (0,
|
|
9077
|
-
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)({
|
|
9078
9343
|
columns: [
|
|
9079
9344
|
table.id
|
|
9080
9345
|
],
|
|
9081
9346
|
name: "Coupon_id"
|
|
9082
9347
|
}),
|
|
9083
|
-
couponCodeKey: (0,
|
|
9348
|
+
couponCodeKey: (0, import_mysql_core15.unique)("Coupon_code_key").on(table.code)
|
|
9084
9349
|
};
|
|
9085
9350
|
});
|
|
9086
9351
|
}
|
|
@@ -9089,7 +9354,7 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
9089
9354
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
9090
9355
|
const coupon = getCouponSchema(mysqlTable);
|
|
9091
9356
|
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
9092
|
-
return (0,
|
|
9357
|
+
return (0, import_drizzle_orm14.relations)(coupon, ({ many, one }) => ({
|
|
9093
9358
|
redeemedBulkCouponPurchases: many(purchase, {
|
|
9094
9359
|
relationName: "redeemedBulkCoupon"
|
|
9095
9360
|
}),
|
|
@@ -9119,31 +9384,31 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
9119
9384
|
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
9120
9385
|
|
|
9121
9386
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
9122
|
-
var
|
|
9123
|
-
var
|
|
9387
|
+
var import_drizzle_orm17 = require("drizzle-orm");
|
|
9388
|
+
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9124
9389
|
|
|
9125
9390
|
// src/lib/mysql/schemas/commerce/merchant-account.ts
|
|
9126
|
-
var
|
|
9127
|
-
var
|
|
9391
|
+
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9392
|
+
var import_mysql_core16 = require("drizzle-orm/mysql-core");
|
|
9128
9393
|
function getMerchantAccountSchema(mysqlTable) {
|
|
9129
9394
|
return mysqlTable("MerchantAccount", {
|
|
9130
|
-
id: (0,
|
|
9395
|
+
id: (0, import_mysql_core16.varchar)("id", {
|
|
9131
9396
|
length: 191
|
|
9132
9397
|
}).notNull(),
|
|
9133
|
-
status: (0,
|
|
9134
|
-
createdAt: (0,
|
|
9398
|
+
status: (0, import_mysql_core16.int)("status").default(0).notNull(),
|
|
9399
|
+
createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
|
|
9135
9400
|
mode: "date",
|
|
9136
9401
|
fsp: 3
|
|
9137
|
-
}).default(
|
|
9138
|
-
label: (0,
|
|
9402
|
+
}).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9403
|
+
label: (0, import_mysql_core16.varchar)("label", {
|
|
9139
9404
|
length: 191
|
|
9140
9405
|
}),
|
|
9141
|
-
identifier: (0,
|
|
9406
|
+
identifier: (0, import_mysql_core16.varchar)("identifier", {
|
|
9142
9407
|
length: 191
|
|
9143
9408
|
})
|
|
9144
9409
|
}, (table) => {
|
|
9145
9410
|
return {
|
|
9146
|
-
merchantAccountId: (0,
|
|
9411
|
+
merchantAccountId: (0, import_mysql_core16.primaryKey)({
|
|
9147
9412
|
columns: [
|
|
9148
9413
|
table.id
|
|
9149
9414
|
],
|
|
@@ -9155,37 +9420,37 @@ function getMerchantAccountSchema(mysqlTable) {
|
|
|
9155
9420
|
__name(getMerchantAccountSchema, "getMerchantAccountSchema");
|
|
9156
9421
|
|
|
9157
9422
|
// src/lib/mysql/schemas/commerce/merchant-customer.ts
|
|
9158
|
-
var
|
|
9159
|
-
var
|
|
9423
|
+
var import_drizzle_orm16 = require("drizzle-orm");
|
|
9424
|
+
var import_mysql_core17 = require("drizzle-orm/mysql-core");
|
|
9160
9425
|
function getMerchantCustomerSchema(mysqlTable) {
|
|
9161
9426
|
return mysqlTable("MerchantCustomer", {
|
|
9162
|
-
id: (0,
|
|
9427
|
+
id: (0, import_mysql_core17.varchar)("id", {
|
|
9163
9428
|
length: 191
|
|
9164
9429
|
}).notNull(),
|
|
9165
|
-
userId: (0,
|
|
9430
|
+
userId: (0, import_mysql_core17.varchar)("userId", {
|
|
9166
9431
|
length: 191
|
|
9167
9432
|
}).notNull(),
|
|
9168
|
-
merchantAccountId: (0,
|
|
9433
|
+
merchantAccountId: (0, import_mysql_core17.varchar)("merchantAccountId", {
|
|
9169
9434
|
length: 191
|
|
9170
9435
|
}).notNull(),
|
|
9171
|
-
identifier: (0,
|
|
9436
|
+
identifier: (0, import_mysql_core17.varchar)("identifier", {
|
|
9172
9437
|
length: 191
|
|
9173
9438
|
}).notNull(),
|
|
9174
|
-
createdAt: (0,
|
|
9439
|
+
createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
|
|
9175
9440
|
mode: "date",
|
|
9176
9441
|
fsp: 3
|
|
9177
|
-
}).default(
|
|
9178
|
-
status: (0,
|
|
9442
|
+
}).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9443
|
+
status: (0, import_mysql_core17.int)("status").default(0)
|
|
9179
9444
|
}, (table) => {
|
|
9180
9445
|
return {
|
|
9181
|
-
merchantCustomerId: (0,
|
|
9446
|
+
merchantCustomerId: (0, import_mysql_core17.primaryKey)({
|
|
9182
9447
|
columns: [
|
|
9183
9448
|
table.id
|
|
9184
9449
|
],
|
|
9185
9450
|
name: "MerchantCustomer_id"
|
|
9186
9451
|
}),
|
|
9187
|
-
merchantCustomerIdentifierKey: (0,
|
|
9188
|
-
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)
|
|
9189
9454
|
};
|
|
9190
9455
|
});
|
|
9191
9456
|
}
|
|
@@ -9194,38 +9459,38 @@ __name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
|
|
|
9194
9459
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
9195
9460
|
function getMerchantChargeSchema(mysqlTable) {
|
|
9196
9461
|
return mysqlTable("MerchantCharge", {
|
|
9197
|
-
id: (0,
|
|
9462
|
+
id: (0, import_mysql_core18.varchar)("id", {
|
|
9198
9463
|
length: 191
|
|
9199
9464
|
}).notNull(),
|
|
9200
|
-
status: (0,
|
|
9201
|
-
identifier: (0,
|
|
9465
|
+
status: (0, import_mysql_core18.int)("status").default(0).notNull(),
|
|
9466
|
+
identifier: (0, import_mysql_core18.varchar)("identifier", {
|
|
9202
9467
|
length: 191
|
|
9203
9468
|
}).notNull(),
|
|
9204
|
-
userId: (0,
|
|
9469
|
+
userId: (0, import_mysql_core18.varchar)("userId", {
|
|
9205
9470
|
length: 191
|
|
9206
9471
|
}).notNull(),
|
|
9207
|
-
merchantAccountId: (0,
|
|
9472
|
+
merchantAccountId: (0, import_mysql_core18.varchar)("merchantAccountId", {
|
|
9208
9473
|
length: 191
|
|
9209
9474
|
}).notNull(),
|
|
9210
|
-
merchantProductId: (0,
|
|
9475
|
+
merchantProductId: (0, import_mysql_core18.varchar)("merchantProductId", {
|
|
9211
9476
|
length: 191
|
|
9212
9477
|
}).notNull(),
|
|
9213
|
-
createdAt: (0,
|
|
9478
|
+
createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
|
|
9214
9479
|
mode: "date",
|
|
9215
9480
|
fsp: 3
|
|
9216
|
-
}).default(
|
|
9217
|
-
merchantCustomerId: (0,
|
|
9481
|
+
}).default(import_drizzle_orm17.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9482
|
+
merchantCustomerId: (0, import_mysql_core18.varchar)("merchantCustomerId", {
|
|
9218
9483
|
length: 191
|
|
9219
9484
|
}).notNull()
|
|
9220
9485
|
}, (table) => {
|
|
9221
9486
|
return {
|
|
9222
|
-
merchantChargeId: (0,
|
|
9487
|
+
merchantChargeId: (0, import_mysql_core18.primaryKey)({
|
|
9223
9488
|
columns: [
|
|
9224
9489
|
table.id
|
|
9225
9490
|
],
|
|
9226
9491
|
name: "MerchantCharge_id"
|
|
9227
9492
|
}),
|
|
9228
|
-
merchantChargeIdentifierKey: (0,
|
|
9493
|
+
merchantChargeIdentifierKey: (0, import_mysql_core18.unique)("MerchantCharge_identifier_key").on(table.identifier)
|
|
9229
9494
|
};
|
|
9230
9495
|
});
|
|
9231
9496
|
}
|
|
@@ -9235,7 +9500,7 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9235
9500
|
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
9236
9501
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
9237
9502
|
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
9238
|
-
return (0,
|
|
9503
|
+
return (0, import_drizzle_orm17.relations)(merchantCharge, ({ one }) => ({
|
|
9239
9504
|
merchantAccount: one(merchantAccount, {
|
|
9240
9505
|
fields: [
|
|
9241
9506
|
merchantCharge.merchantAccountId
|
|
@@ -9268,21 +9533,21 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
9268
9533
|
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
9269
9534
|
|
|
9270
9535
|
// src/lib/mysql/schemas/commerce/merchant-session.ts
|
|
9271
|
-
var
|
|
9536
|
+
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
9272
9537
|
function getMerchantSessionSchema(mysqlTable) {
|
|
9273
9538
|
return mysqlTable("MerchantSession", {
|
|
9274
|
-
id: (0,
|
|
9539
|
+
id: (0, import_mysql_core19.varchar)("id", {
|
|
9275
9540
|
length: 191
|
|
9276
9541
|
}).notNull(),
|
|
9277
|
-
identifier: (0,
|
|
9542
|
+
identifier: (0, import_mysql_core19.varchar)("identifier", {
|
|
9278
9543
|
length: 191
|
|
9279
9544
|
}).notNull(),
|
|
9280
|
-
merchantAccountId: (0,
|
|
9545
|
+
merchantAccountId: (0, import_mysql_core19.varchar)("merchantAccountId", {
|
|
9281
9546
|
length: 191
|
|
9282
9547
|
}).notNull()
|
|
9283
9548
|
}, (table) => {
|
|
9284
9549
|
return {
|
|
9285
|
-
merchantSessionId: (0,
|
|
9550
|
+
merchantSessionId: (0, import_mysql_core19.primaryKey)({
|
|
9286
9551
|
columns: [
|
|
9287
9552
|
table.id
|
|
9288
9553
|
],
|
|
@@ -9296,67 +9561,67 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
|
|
|
9296
9561
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
9297
9562
|
function getPurchaseSchema(mysqlTable) {
|
|
9298
9563
|
return mysqlTable("Purchase", {
|
|
9299
|
-
id: (0,
|
|
9564
|
+
id: (0, import_mysql_core20.varchar)("id", {
|
|
9300
9565
|
length: 191
|
|
9301
9566
|
}).notNull(),
|
|
9302
|
-
userId: (0,
|
|
9567
|
+
userId: (0, import_mysql_core20.varchar)("userId", {
|
|
9303
9568
|
length: 191
|
|
9304
9569
|
}),
|
|
9305
|
-
createdAt: (0,
|
|
9570
|
+
createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
|
|
9306
9571
|
mode: "date",
|
|
9307
9572
|
fsp: 3
|
|
9308
|
-
}).default(
|
|
9309
|
-
totalAmount: (0,
|
|
9573
|
+
}).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9574
|
+
totalAmount: (0, import_mysql_core20.decimal)("totalAmount", {
|
|
9310
9575
|
precision: 65,
|
|
9311
9576
|
scale: 30
|
|
9312
9577
|
}).notNull(),
|
|
9313
|
-
ipAddress: (0,
|
|
9578
|
+
ipAddress: (0, import_mysql_core20.varchar)("ip_address", {
|
|
9314
9579
|
length: 191
|
|
9315
9580
|
}),
|
|
9316
|
-
city: (0,
|
|
9581
|
+
city: (0, import_mysql_core20.varchar)("city", {
|
|
9317
9582
|
length: 191
|
|
9318
9583
|
}),
|
|
9319
|
-
state: (0,
|
|
9584
|
+
state: (0, import_mysql_core20.varchar)("state", {
|
|
9320
9585
|
length: 191
|
|
9321
9586
|
}),
|
|
9322
|
-
country: (0,
|
|
9587
|
+
country: (0, import_mysql_core20.varchar)("country", {
|
|
9323
9588
|
length: 191
|
|
9324
9589
|
}),
|
|
9325
|
-
couponId: (0,
|
|
9590
|
+
couponId: (0, import_mysql_core20.varchar)("couponId", {
|
|
9326
9591
|
length: 191
|
|
9327
9592
|
}),
|
|
9328
|
-
productId: (0,
|
|
9593
|
+
productId: (0, import_mysql_core20.varchar)("productId", {
|
|
9329
9594
|
length: 191
|
|
9330
9595
|
}).notNull(),
|
|
9331
|
-
merchantChargeId: (0,
|
|
9596
|
+
merchantChargeId: (0, import_mysql_core20.varchar)("merchantChargeId", {
|
|
9332
9597
|
length: 191
|
|
9333
9598
|
}),
|
|
9334
|
-
upgradedFromId: (0,
|
|
9599
|
+
upgradedFromId: (0, import_mysql_core20.varchar)("upgradedFromId", {
|
|
9335
9600
|
length: 191
|
|
9336
9601
|
}),
|
|
9337
|
-
status: (0,
|
|
9602
|
+
status: (0, import_mysql_core20.varchar)("status", {
|
|
9338
9603
|
length: 191
|
|
9339
9604
|
}).default("Valid").notNull(),
|
|
9340
|
-
bulkCouponId: (0,
|
|
9605
|
+
bulkCouponId: (0, import_mysql_core20.varchar)("bulkCouponId", {
|
|
9341
9606
|
length: 191
|
|
9342
9607
|
}),
|
|
9343
|
-
merchantSessionId: (0,
|
|
9608
|
+
merchantSessionId: (0, import_mysql_core20.varchar)("merchantSessionId", {
|
|
9344
9609
|
length: 191
|
|
9345
9610
|
}),
|
|
9346
|
-
redeemedBulkCouponId: (0,
|
|
9611
|
+
redeemedBulkCouponId: (0, import_mysql_core20.varchar)("redeemedBulkCouponId", {
|
|
9347
9612
|
length: 191
|
|
9348
9613
|
}),
|
|
9349
|
-
fields: (0,
|
|
9614
|
+
fields: (0, import_mysql_core20.json)("fields").$type().default({})
|
|
9350
9615
|
}, (table) => {
|
|
9351
9616
|
return {
|
|
9352
|
-
purchaseId: (0,
|
|
9617
|
+
purchaseId: (0, import_mysql_core20.primaryKey)({
|
|
9353
9618
|
columns: [
|
|
9354
9619
|
table.id
|
|
9355
9620
|
],
|
|
9356
9621
|
name: "Purchase_id"
|
|
9357
9622
|
}),
|
|
9358
|
-
merchantChargeIdIdx: (0,
|
|
9359
|
-
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)
|
|
9360
9625
|
};
|
|
9361
9626
|
});
|
|
9362
9627
|
}
|
|
@@ -9368,7 +9633,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9368
9633
|
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
9369
9634
|
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
9370
9635
|
const coupons = getCouponSchema(mysqlTable);
|
|
9371
|
-
return (0,
|
|
9636
|
+
return (0, import_drizzle_orm18.relations)(purchases, ({ many, one }) => ({
|
|
9372
9637
|
redeemedBulkCoupon: one(coupons, {
|
|
9373
9638
|
fields: [
|
|
9374
9639
|
purchases.redeemedBulkCouponId
|
|
@@ -9428,44 +9693,44 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
9428
9693
|
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
9429
9694
|
|
|
9430
9695
|
// src/lib/mysql/schemas/communication/comment.ts
|
|
9431
|
-
var
|
|
9432
|
-
var
|
|
9696
|
+
var import_drizzle_orm19 = require("drizzle-orm");
|
|
9697
|
+
var import_mysql_core21 = require("drizzle-orm/mysql-core");
|
|
9433
9698
|
function getCommentsSchema(mysqlTable) {
|
|
9434
9699
|
return mysqlTable("Comment", {
|
|
9435
|
-
id: (0,
|
|
9700
|
+
id: (0, import_mysql_core21.varchar)("id", {
|
|
9436
9701
|
length: 191
|
|
9437
9702
|
}).notNull(),
|
|
9438
|
-
userId: (0,
|
|
9703
|
+
userId: (0, import_mysql_core21.varchar)("userId", {
|
|
9439
9704
|
length: 255
|
|
9440
9705
|
}).notNull(),
|
|
9441
|
-
context: (0,
|
|
9442
|
-
text: (0,
|
|
9443
|
-
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", {
|
|
9444
9709
|
mode: "date",
|
|
9445
9710
|
fsp: 3
|
|
9446
|
-
}).default(
|
|
9447
|
-
updatedAt: (0,
|
|
9711
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
|
|
9712
|
+
updatedAt: (0, import_mysql_core21.timestamp)("updatedAt", {
|
|
9448
9713
|
mode: "date",
|
|
9449
9714
|
fsp: 3
|
|
9450
|
-
}).default(
|
|
9451
|
-
deletedAt: (0,
|
|
9715
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`),
|
|
9716
|
+
deletedAt: (0, import_mysql_core21.timestamp)("deletedAt", {
|
|
9452
9717
|
mode: "date",
|
|
9453
9718
|
fsp: 3
|
|
9454
9719
|
})
|
|
9455
9720
|
}, (crr) => ({
|
|
9456
|
-
pk: (0,
|
|
9721
|
+
pk: (0, import_mysql_core21.primaryKey)({
|
|
9457
9722
|
columns: [
|
|
9458
9723
|
crr.id
|
|
9459
9724
|
]
|
|
9460
9725
|
}),
|
|
9461
|
-
crrUserIdIdKey: (0,
|
|
9726
|
+
crrUserIdIdKey: (0, import_mysql_core21.index)("crr_userIdId_idx").on(crr.userId)
|
|
9462
9727
|
}));
|
|
9463
9728
|
}
|
|
9464
9729
|
__name(getCommentsSchema, "getCommentsSchema");
|
|
9465
9730
|
function getCommentRelationsSchema(mysqlTable) {
|
|
9466
9731
|
const comment = getCommentsSchema(mysqlTable);
|
|
9467
9732
|
const user = getUsersSchema(mysqlTable);
|
|
9468
|
-
return (0,
|
|
9733
|
+
return (0, import_drizzle_orm19.relations)(comment, ({ one }) => ({
|
|
9469
9734
|
user: one(user, {
|
|
9470
9735
|
fields: [
|
|
9471
9736
|
comment.userId
|
|
@@ -9480,60 +9745,60 @@ function getCommentRelationsSchema(mysqlTable) {
|
|
|
9480
9745
|
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
9481
9746
|
|
|
9482
9747
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9483
|
-
var
|
|
9484
|
-
var
|
|
9748
|
+
var import_drizzle_orm20 = require("drizzle-orm");
|
|
9749
|
+
var import_mysql_core24 = require("drizzle-orm/mysql-core");
|
|
9485
9750
|
|
|
9486
9751
|
// src/lib/mysql/schemas/communication/communication-channel.ts
|
|
9487
|
-
var
|
|
9752
|
+
var import_mysql_core22 = require("drizzle-orm/mysql-core");
|
|
9488
9753
|
function getCommunicationChannelSchema(mysqlTable) {
|
|
9489
9754
|
return mysqlTable("CommunicationChannel", {
|
|
9490
|
-
id: (0,
|
|
9755
|
+
id: (0, import_mysql_core22.varchar)("id", {
|
|
9491
9756
|
length: 255
|
|
9492
9757
|
}).notNull().primaryKey(),
|
|
9493
|
-
name: (0,
|
|
9758
|
+
name: (0, import_mysql_core22.varchar)("name", {
|
|
9494
9759
|
length: 255
|
|
9495
9760
|
}).notNull(),
|
|
9496
|
-
description: (0,
|
|
9497
|
-
active: (0,
|
|
9498
|
-
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", {
|
|
9499
9764
|
mode: "date",
|
|
9500
9765
|
fsp: 3
|
|
9501
9766
|
}).defaultNow(),
|
|
9502
|
-
updatedAt: (0,
|
|
9767
|
+
updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
|
|
9503
9768
|
mode: "date",
|
|
9504
9769
|
fsp: 3
|
|
9505
9770
|
}).defaultNow(),
|
|
9506
|
-
deletedAt: (0,
|
|
9771
|
+
deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
|
|
9507
9772
|
mode: "date",
|
|
9508
9773
|
fsp: 3
|
|
9509
9774
|
})
|
|
9510
9775
|
}, (cc) => ({
|
|
9511
|
-
nameIdx: (0,
|
|
9776
|
+
nameIdx: (0, import_mysql_core22.index)("name_idx").on(cc.name)
|
|
9512
9777
|
}));
|
|
9513
9778
|
}
|
|
9514
9779
|
__name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
|
|
9515
9780
|
|
|
9516
9781
|
// src/lib/mysql/schemas/communication/communication-preference-types.ts
|
|
9517
|
-
var
|
|
9782
|
+
var import_mysql_core23 = require("drizzle-orm/mysql-core");
|
|
9518
9783
|
function getCommunicationPreferenceTypesSchema(mysqlTable) {
|
|
9519
9784
|
return mysqlTable("CommunicationPreferenceType", {
|
|
9520
|
-
id: (0,
|
|
9785
|
+
id: (0, import_mysql_core23.varchar)("id", {
|
|
9521
9786
|
length: 255
|
|
9522
9787
|
}).notNull().primaryKey(),
|
|
9523
|
-
name: (0,
|
|
9788
|
+
name: (0, import_mysql_core23.varchar)("name", {
|
|
9524
9789
|
length: 255
|
|
9525
9790
|
}).notNull(),
|
|
9526
|
-
description: (0,
|
|
9527
|
-
active: (0,
|
|
9528
|
-
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", {
|
|
9529
9794
|
mode: "date",
|
|
9530
9795
|
fsp: 3
|
|
9531
9796
|
}).defaultNow(),
|
|
9532
|
-
updatedAt: (0,
|
|
9797
|
+
updatedAt: (0, import_mysql_core23.timestamp)("updatedAt", {
|
|
9533
9798
|
mode: "date",
|
|
9534
9799
|
fsp: 3
|
|
9535
9800
|
}),
|
|
9536
|
-
deletedAt: (0,
|
|
9801
|
+
deletedAt: (0, import_mysql_core23.timestamp)("deletedAt", {
|
|
9537
9802
|
mode: "date",
|
|
9538
9803
|
fsp: 3
|
|
9539
9804
|
})
|
|
@@ -9544,48 +9809,48 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
|
|
|
9544
9809
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
9545
9810
|
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
9546
9811
|
return mysqlTable("CommunicationPreference", {
|
|
9547
|
-
id: (0,
|
|
9812
|
+
id: (0, import_mysql_core24.varchar)("id", {
|
|
9548
9813
|
length: 255
|
|
9549
9814
|
}).notNull().primaryKey(),
|
|
9550
|
-
userId: (0,
|
|
9815
|
+
userId: (0, import_mysql_core24.varchar)("userId", {
|
|
9551
9816
|
length: 255
|
|
9552
9817
|
}).notNull(),
|
|
9553
|
-
channelId: (0,
|
|
9818
|
+
channelId: (0, import_mysql_core24.varchar)("channelId", {
|
|
9554
9819
|
length: 255
|
|
9555
9820
|
}).notNull(),
|
|
9556
|
-
preferenceLevel: (0,
|
|
9821
|
+
preferenceLevel: (0, import_mysql_core24.mysqlEnum)("preferenceLevel", [
|
|
9557
9822
|
"low",
|
|
9558
9823
|
"medium",
|
|
9559
9824
|
"high"
|
|
9560
9825
|
]).notNull().default("medium"),
|
|
9561
|
-
preferenceTypeId: (0,
|
|
9826
|
+
preferenceTypeId: (0, import_mysql_core24.varchar)("preferenceTypeId", {
|
|
9562
9827
|
length: 255
|
|
9563
9828
|
}).notNull(),
|
|
9564
|
-
active: (0,
|
|
9565
|
-
createdAt: (0,
|
|
9829
|
+
active: (0, import_mysql_core24.boolean)("active").notNull().default(true),
|
|
9830
|
+
createdAt: (0, import_mysql_core24.timestamp)("createdAt", {
|
|
9566
9831
|
mode: "date",
|
|
9567
9832
|
fsp: 3
|
|
9568
9833
|
}).defaultNow(),
|
|
9569
|
-
optInAt: (0,
|
|
9834
|
+
optInAt: (0, import_mysql_core24.timestamp)("optInAt", {
|
|
9570
9835
|
mode: "date",
|
|
9571
9836
|
fsp: 3
|
|
9572
9837
|
}),
|
|
9573
|
-
optOutAt: (0,
|
|
9838
|
+
optOutAt: (0, import_mysql_core24.timestamp)("optOutAt", {
|
|
9574
9839
|
mode: "date",
|
|
9575
9840
|
fsp: 3
|
|
9576
9841
|
}),
|
|
9577
|
-
updatedAt: (0,
|
|
9842
|
+
updatedAt: (0, import_mysql_core24.timestamp)("updatedAt", {
|
|
9578
9843
|
mode: "date",
|
|
9579
9844
|
fsp: 3
|
|
9580
9845
|
}).defaultNow(),
|
|
9581
|
-
deletedAt: (0,
|
|
9846
|
+
deletedAt: (0, import_mysql_core24.timestamp)("deletedAt", {
|
|
9582
9847
|
mode: "date",
|
|
9583
9848
|
fsp: 3
|
|
9584
9849
|
})
|
|
9585
9850
|
}, (cp) => ({
|
|
9586
|
-
userIdIdx: (0,
|
|
9587
|
-
preferenceTypeIdx: (0,
|
|
9588
|
-
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)
|
|
9589
9854
|
}));
|
|
9590
9855
|
}
|
|
9591
9856
|
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
@@ -9594,7 +9859,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9594
9859
|
const users = getUsersSchema(mysqlTable);
|
|
9595
9860
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
9596
9861
|
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
9597
|
-
return (0,
|
|
9862
|
+
return (0, import_drizzle_orm20.relations)(communicationPreferences, ({ one }) => ({
|
|
9598
9863
|
user: one(users, {
|
|
9599
9864
|
fields: [
|
|
9600
9865
|
communicationPreferences.userId
|
|
@@ -9627,75 +9892,75 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
9627
9892
|
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
9628
9893
|
|
|
9629
9894
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9630
|
-
var
|
|
9631
|
-
var
|
|
9895
|
+
var import_drizzle_orm22 = require("drizzle-orm");
|
|
9896
|
+
var import_mysql_core26 = require("drizzle-orm/mysql-core");
|
|
9632
9897
|
|
|
9633
9898
|
// src/lib/mysql/schemas/auth/permissions.ts
|
|
9634
|
-
var
|
|
9635
|
-
var
|
|
9899
|
+
var import_drizzle_orm21 = require("drizzle-orm");
|
|
9900
|
+
var import_mysql_core25 = require("drizzle-orm/mysql-core");
|
|
9636
9901
|
function getPermissionsSchema(mysqlTable) {
|
|
9637
9902
|
return mysqlTable("Permission", {
|
|
9638
|
-
id: (0,
|
|
9903
|
+
id: (0, import_mysql_core25.varchar)("id", {
|
|
9639
9904
|
length: 255
|
|
9640
9905
|
}).notNull().primaryKey(),
|
|
9641
|
-
name: (0,
|
|
9906
|
+
name: (0, import_mysql_core25.varchar)("name", {
|
|
9642
9907
|
length: 255
|
|
9643
9908
|
}).notNull().unique(),
|
|
9644
|
-
description: (0,
|
|
9645
|
-
active: (0,
|
|
9646
|
-
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", {
|
|
9647
9912
|
mode: "date",
|
|
9648
9913
|
fsp: 3
|
|
9649
9914
|
}).defaultNow(),
|
|
9650
|
-
updatedAt: (0,
|
|
9915
|
+
updatedAt: (0, import_mysql_core25.timestamp)("updatedAt", {
|
|
9651
9916
|
mode: "date",
|
|
9652
9917
|
fsp: 3
|
|
9653
9918
|
}).defaultNow(),
|
|
9654
|
-
deletedAt: (0,
|
|
9919
|
+
deletedAt: (0, import_mysql_core25.timestamp)("deletedAt", {
|
|
9655
9920
|
mode: "date",
|
|
9656
9921
|
fsp: 3
|
|
9657
9922
|
})
|
|
9658
9923
|
}, (permission) => ({
|
|
9659
|
-
nameIdx: (0,
|
|
9924
|
+
nameIdx: (0, import_mysql_core25.index)("name_idx").on(permission.name)
|
|
9660
9925
|
}));
|
|
9661
9926
|
}
|
|
9662
9927
|
__name(getPermissionsSchema, "getPermissionsSchema");
|
|
9663
9928
|
function getPermissionsRelationsSchema(mysqlTable) {
|
|
9664
|
-
return (0,
|
|
9929
|
+
return (0, import_drizzle_orm21.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
|
|
9665
9930
|
}
|
|
9666
9931
|
__name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
|
|
9667
9932
|
|
|
9668
9933
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
9669
9934
|
function getUserPermissionsSchema(mysqlTable) {
|
|
9670
9935
|
return mysqlTable("UserPermission", {
|
|
9671
|
-
userId: (0,
|
|
9936
|
+
userId: (0, import_mysql_core26.varchar)("userId", {
|
|
9672
9937
|
length: 255
|
|
9673
9938
|
}).notNull(),
|
|
9674
|
-
permissionId: (0,
|
|
9939
|
+
permissionId: (0, import_mysql_core26.varchar)("permissionId", {
|
|
9675
9940
|
length: 255
|
|
9676
9941
|
}).notNull(),
|
|
9677
|
-
active: (0,
|
|
9678
|
-
createdAt: (0,
|
|
9942
|
+
active: (0, import_mysql_core26.boolean)("active").notNull().default(true),
|
|
9943
|
+
createdAt: (0, import_mysql_core26.timestamp)("createdAt", {
|
|
9679
9944
|
mode: "date",
|
|
9680
9945
|
fsp: 3
|
|
9681
9946
|
}).defaultNow(),
|
|
9682
|
-
updatedAt: (0,
|
|
9947
|
+
updatedAt: (0, import_mysql_core26.timestamp)("updatedAt", {
|
|
9683
9948
|
mode: "date",
|
|
9684
9949
|
fsp: 3
|
|
9685
9950
|
}).defaultNow(),
|
|
9686
|
-
deletedAt: (0,
|
|
9951
|
+
deletedAt: (0, import_mysql_core26.timestamp)("deletedAt", {
|
|
9687
9952
|
mode: "date",
|
|
9688
9953
|
fsp: 3
|
|
9689
9954
|
})
|
|
9690
9955
|
}, (up) => ({
|
|
9691
|
-
pk: (0,
|
|
9956
|
+
pk: (0, import_mysql_core26.primaryKey)({
|
|
9692
9957
|
columns: [
|
|
9693
9958
|
up.userId,
|
|
9694
9959
|
up.permissionId
|
|
9695
9960
|
]
|
|
9696
9961
|
}),
|
|
9697
|
-
userIdIdx: (0,
|
|
9698
|
-
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)
|
|
9699
9964
|
}));
|
|
9700
9965
|
}
|
|
9701
9966
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -9703,7 +9968,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9703
9968
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
9704
9969
|
const users = getUsersSchema(mysqlTable);
|
|
9705
9970
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
9706
|
-
return (0,
|
|
9971
|
+
return (0, import_drizzle_orm22.relations)(userPermissions, ({ one }) => ({
|
|
9707
9972
|
user: one(users, {
|
|
9708
9973
|
fields: [
|
|
9709
9974
|
userPermissions.userId
|
|
@@ -9727,46 +9992,46 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
9727
9992
|
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
9728
9993
|
|
|
9729
9994
|
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
9730
|
-
var
|
|
9731
|
-
var
|
|
9995
|
+
var import_drizzle_orm23 = require("drizzle-orm");
|
|
9996
|
+
var import_mysql_core27 = require("drizzle-orm/mysql-core");
|
|
9732
9997
|
function getUserPrefsSchema(mysqlTable) {
|
|
9733
9998
|
return mysqlTable("UserPrefs", {
|
|
9734
|
-
id: (0,
|
|
9999
|
+
id: (0, import_mysql_core27.varchar)("id", {
|
|
9735
10000
|
length: 191
|
|
9736
10001
|
}).notNull(),
|
|
9737
|
-
type: (0,
|
|
10002
|
+
type: (0, import_mysql_core27.varchar)("type", {
|
|
9738
10003
|
length: 191
|
|
9739
10004
|
}).default("Global").notNull(),
|
|
9740
|
-
userId: (0,
|
|
10005
|
+
userId: (0, import_mysql_core27.varchar)("userId", {
|
|
9741
10006
|
length: 255
|
|
9742
10007
|
}).notNull(),
|
|
9743
|
-
fields: (0,
|
|
9744
|
-
createdAt: (0,
|
|
10008
|
+
fields: (0, import_mysql_core27.json)("fields").$type().default({}),
|
|
10009
|
+
createdAt: (0, import_mysql_core27.timestamp)("createdAt", {
|
|
9745
10010
|
mode: "date",
|
|
9746
10011
|
fsp: 3
|
|
9747
|
-
}).default(
|
|
9748
|
-
updatedAt: (0,
|
|
10012
|
+
}).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
|
|
10013
|
+
updatedAt: (0, import_mysql_core27.timestamp)("updatedAt", {
|
|
9749
10014
|
mode: "date",
|
|
9750
10015
|
fsp: 3
|
|
9751
|
-
}).default(
|
|
9752
|
-
deletedAt: (0,
|
|
10016
|
+
}).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`),
|
|
10017
|
+
deletedAt: (0, import_mysql_core27.timestamp)("deletedAt", {
|
|
9753
10018
|
mode: "date",
|
|
9754
10019
|
fsp: 3
|
|
9755
10020
|
})
|
|
9756
10021
|
}, (crr) => ({
|
|
9757
|
-
pk: (0,
|
|
10022
|
+
pk: (0, import_mysql_core27.primaryKey)({
|
|
9758
10023
|
columns: [
|
|
9759
10024
|
crr.id
|
|
9760
10025
|
]
|
|
9761
10026
|
}),
|
|
9762
|
-
crrUserIdIdKey: (0,
|
|
10027
|
+
crrUserIdIdKey: (0, import_mysql_core27.index)("crr_userIdId_idx").on(crr.userId)
|
|
9763
10028
|
}));
|
|
9764
10029
|
}
|
|
9765
10030
|
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
9766
10031
|
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
9767
10032
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9768
10033
|
const user = getUsersSchema(mysqlTable);
|
|
9769
|
-
return (0,
|
|
10034
|
+
return (0, import_drizzle_orm23.relations)(userPrefs, ({ one }) => ({
|
|
9770
10035
|
user: one(user, {
|
|
9771
10036
|
fields: [
|
|
9772
10037
|
userPrefs.userId
|
|
@@ -9781,43 +10046,43 @@ function getUserPrefsRelationsSchema(mysqlTable) {
|
|
|
9781
10046
|
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
9782
10047
|
|
|
9783
10048
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9784
|
-
var
|
|
9785
|
-
var
|
|
10049
|
+
var import_drizzle_orm25 = require("drizzle-orm");
|
|
10050
|
+
var import_mysql_core29 = require("drizzle-orm/mysql-core");
|
|
9786
10051
|
|
|
9787
10052
|
// src/lib/mysql/schemas/auth/roles.ts
|
|
9788
|
-
var
|
|
9789
|
-
var
|
|
10053
|
+
var import_drizzle_orm24 = require("drizzle-orm");
|
|
10054
|
+
var import_mysql_core28 = require("drizzle-orm/mysql-core");
|
|
9790
10055
|
function getRolesSchema(mysqlTable) {
|
|
9791
10056
|
return mysqlTable("Role", {
|
|
9792
|
-
id: (0,
|
|
10057
|
+
id: (0, import_mysql_core28.varchar)("id", {
|
|
9793
10058
|
length: 255
|
|
9794
10059
|
}).notNull().primaryKey(),
|
|
9795
|
-
name: (0,
|
|
10060
|
+
name: (0, import_mysql_core28.varchar)("name", {
|
|
9796
10061
|
length: 255
|
|
9797
10062
|
}).notNull().unique(),
|
|
9798
|
-
description: (0,
|
|
9799
|
-
active: (0,
|
|
9800
|
-
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", {
|
|
9801
10066
|
mode: "date",
|
|
9802
10067
|
fsp: 3
|
|
9803
10068
|
}).defaultNow(),
|
|
9804
|
-
updatedAt: (0,
|
|
10069
|
+
updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
|
|
9805
10070
|
mode: "date",
|
|
9806
10071
|
fsp: 3
|
|
9807
10072
|
}).defaultNow(),
|
|
9808
|
-
deletedAt: (0,
|
|
10073
|
+
deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
|
|
9809
10074
|
mode: "date",
|
|
9810
10075
|
fsp: 3
|
|
9811
10076
|
})
|
|
9812
10077
|
}, (role) => ({
|
|
9813
|
-
nameIdx: (0,
|
|
10078
|
+
nameIdx: (0, import_mysql_core28.index)("name_idx").on(role.name)
|
|
9814
10079
|
}));
|
|
9815
10080
|
}
|
|
9816
10081
|
__name(getRolesSchema, "getRolesSchema");
|
|
9817
10082
|
function getRolesRelationsSchema(mysqlTable) {
|
|
9818
10083
|
const roles = getRolesSchema(mysqlTable);
|
|
9819
10084
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9820
|
-
return (0,
|
|
10085
|
+
return (0, import_drizzle_orm24.relations)(roles, ({ many }) => ({
|
|
9821
10086
|
userRoles: many(userRoles, {
|
|
9822
10087
|
relationName: "role"
|
|
9823
10088
|
})
|
|
@@ -9828,34 +10093,34 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
|
9828
10093
|
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
9829
10094
|
function getUserRolesSchema(mysqlTable) {
|
|
9830
10095
|
return mysqlTable("UserRole", {
|
|
9831
|
-
userId: (0,
|
|
10096
|
+
userId: (0, import_mysql_core29.varchar)("userId", {
|
|
9832
10097
|
length: 255
|
|
9833
10098
|
}).notNull(),
|
|
9834
|
-
roleId: (0,
|
|
10099
|
+
roleId: (0, import_mysql_core29.varchar)("roleId", {
|
|
9835
10100
|
length: 255
|
|
9836
10101
|
}).notNull(),
|
|
9837
|
-
active: (0,
|
|
9838
|
-
createdAt: (0,
|
|
10102
|
+
active: (0, import_mysql_core29.boolean)("active").notNull().default(true),
|
|
10103
|
+
createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
|
|
9839
10104
|
mode: "date",
|
|
9840
10105
|
fsp: 3
|
|
9841
10106
|
}).defaultNow(),
|
|
9842
|
-
updatedAt: (0,
|
|
10107
|
+
updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
|
|
9843
10108
|
mode: "date",
|
|
9844
10109
|
fsp: 3
|
|
9845
10110
|
}).defaultNow(),
|
|
9846
|
-
deletedAt: (0,
|
|
10111
|
+
deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
|
|
9847
10112
|
mode: "date",
|
|
9848
10113
|
fsp: 3
|
|
9849
10114
|
})
|
|
9850
10115
|
}, (ur) => ({
|
|
9851
|
-
pk: (0,
|
|
10116
|
+
pk: (0, import_mysql_core29.primaryKey)({
|
|
9852
10117
|
columns: [
|
|
9853
10118
|
ur.userId,
|
|
9854
10119
|
ur.roleId
|
|
9855
10120
|
]
|
|
9856
10121
|
}),
|
|
9857
|
-
userIdIdx: (0,
|
|
9858
|
-
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)
|
|
9859
10124
|
}));
|
|
9860
10125
|
}
|
|
9861
10126
|
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
@@ -9863,7 +10128,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
|
|
|
9863
10128
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
9864
10129
|
const users = getUsersSchema(mysqlTable);
|
|
9865
10130
|
const roles = getRolesSchema(mysqlTable);
|
|
9866
|
-
return (0,
|
|
10131
|
+
return (0, import_drizzle_orm25.relations)(userRoles, ({ one }) => ({
|
|
9867
10132
|
user: one(users, {
|
|
9868
10133
|
fields: [
|
|
9869
10134
|
userRoles.userId
|
|
@@ -9889,34 +10154,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
|
9889
10154
|
// src/lib/mysql/schemas/auth/users.ts
|
|
9890
10155
|
function getUsersSchema(mysqlTable) {
|
|
9891
10156
|
return mysqlTable("User", {
|
|
9892
|
-
id: (0,
|
|
10157
|
+
id: (0, import_mysql_core30.varchar)("id", {
|
|
9893
10158
|
length: 255
|
|
9894
10159
|
}).notNull().primaryKey(),
|
|
9895
|
-
name: (0,
|
|
10160
|
+
name: (0, import_mysql_core30.varchar)("name", {
|
|
9896
10161
|
length: 255
|
|
9897
10162
|
}),
|
|
9898
|
-
role: (0,
|
|
10163
|
+
role: (0, import_mysql_core30.varchar)("role", {
|
|
9899
10164
|
length: 191
|
|
9900
10165
|
}).notNull().default("user"),
|
|
9901
|
-
email: (0,
|
|
10166
|
+
email: (0, import_mysql_core30.varchar)("email", {
|
|
9902
10167
|
length: 255
|
|
9903
10168
|
}).notNull().unique(),
|
|
9904
|
-
fields: (0,
|
|
9905
|
-
emailVerified: (0,
|
|
10169
|
+
fields: (0, import_mysql_core30.json)("fields").$type().default({}),
|
|
10170
|
+
emailVerified: (0, import_mysql_core30.timestamp)("emailVerified", {
|
|
9906
10171
|
mode: "date",
|
|
9907
10172
|
fsp: 3
|
|
9908
10173
|
}),
|
|
9909
|
-
image: (0,
|
|
10174
|
+
image: (0, import_mysql_core30.varchar)("image", {
|
|
9910
10175
|
length: 255
|
|
9911
10176
|
}),
|
|
9912
|
-
createdAt: (0,
|
|
10177
|
+
createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
|
|
9913
10178
|
mode: "date",
|
|
9914
10179
|
fsp: 3
|
|
9915
|
-
}).default(
|
|
10180
|
+
}).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`)
|
|
9916
10181
|
}, (user) => ({
|
|
9917
|
-
emailIdx: (0,
|
|
9918
|
-
roleIdx: (0,
|
|
9919
|
-
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)
|
|
9920
10185
|
}));
|
|
9921
10186
|
}
|
|
9922
10187
|
__name(getUsersSchema, "getUsersSchema");
|
|
@@ -9931,7 +10196,7 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
9931
10196
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
9932
10197
|
const comments = getCommentsSchema(mysqlTable);
|
|
9933
10198
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
9934
|
-
return (0,
|
|
10199
|
+
return (0, import_drizzle_orm26.relations)(users, ({ many }) => ({
|
|
9935
10200
|
accounts: many(accounts, {
|
|
9936
10201
|
relationName: "user"
|
|
9937
10202
|
}),
|
|
@@ -9966,49 +10231,49 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
|
9966
10231
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
9967
10232
|
function getAccountsSchema(mysqlTable) {
|
|
9968
10233
|
return mysqlTable("Account", {
|
|
9969
|
-
userId: (0,
|
|
10234
|
+
userId: (0, import_mysql_core31.varchar)("userId", {
|
|
9970
10235
|
length: 255
|
|
9971
10236
|
}).notNull(),
|
|
9972
|
-
type: (0,
|
|
10237
|
+
type: (0, import_mysql_core31.varchar)("type", {
|
|
9973
10238
|
length: 255
|
|
9974
10239
|
}).$type().notNull(),
|
|
9975
|
-
provider: (0,
|
|
10240
|
+
provider: (0, import_mysql_core31.varchar)("provider", {
|
|
9976
10241
|
length: 255
|
|
9977
10242
|
}).notNull(),
|
|
9978
|
-
providerAccountId: (0,
|
|
10243
|
+
providerAccountId: (0, import_mysql_core31.varchar)("providerAccountId", {
|
|
9979
10244
|
length: 255
|
|
9980
10245
|
}).notNull(),
|
|
9981
|
-
refresh_token: (0,
|
|
9982
|
-
access_token: (0,
|
|
9983
|
-
oauth_token: (0,
|
|
9984
|
-
oauth_token_secret: (0,
|
|
9985
|
-
expires_at: (0,
|
|
9986
|
-
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", {
|
|
9987
10252
|
length: 255
|
|
9988
10253
|
}),
|
|
9989
|
-
scope: (0,
|
|
10254
|
+
scope: (0, import_mysql_core31.varchar)("scope", {
|
|
9990
10255
|
length: 255
|
|
9991
10256
|
}),
|
|
9992
|
-
id_token: (0,
|
|
9993
|
-
session_state: (0,
|
|
10257
|
+
id_token: (0, import_mysql_core31.text)("id_token"),
|
|
10258
|
+
session_state: (0, import_mysql_core31.varchar)("session_state", {
|
|
9994
10259
|
length: 255
|
|
9995
10260
|
}),
|
|
9996
|
-
refresh_token_expires_in: (0,
|
|
10261
|
+
refresh_token_expires_in: (0, import_mysql_core31.int)("refresh_token_expires_in")
|
|
9997
10262
|
}, (account) => ({
|
|
9998
|
-
pk: (0,
|
|
10263
|
+
pk: (0, import_mysql_core31.primaryKey)({
|
|
9999
10264
|
columns: [
|
|
10000
10265
|
account.provider,
|
|
10001
10266
|
account.providerAccountId
|
|
10002
10267
|
]
|
|
10003
10268
|
}),
|
|
10004
|
-
userIdIdx: (0,
|
|
10269
|
+
userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(account.userId)
|
|
10005
10270
|
}));
|
|
10006
10271
|
}
|
|
10007
10272
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
10008
10273
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
10009
10274
|
const accounts = getAccountsSchema(mysqlTable);
|
|
10010
10275
|
const users = getUsersSchema(mysqlTable);
|
|
10011
|
-
return (0,
|
|
10276
|
+
return (0, import_drizzle_orm27.relations)(accounts, ({ one }) => ({
|
|
10012
10277
|
user: one(users, {
|
|
10013
10278
|
fields: [
|
|
10014
10279
|
accounts.userId
|
|
@@ -10023,34 +10288,34 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
10023
10288
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
10024
10289
|
|
|
10025
10290
|
// src/lib/mysql/schemas/auth/device-access-token.ts
|
|
10026
|
-
var
|
|
10027
|
-
var
|
|
10291
|
+
var import_drizzle_orm28 = require("drizzle-orm");
|
|
10292
|
+
var import_mysql_core32 = require("drizzle-orm/mysql-core");
|
|
10028
10293
|
function getDeviceAccessTokenSchema(mysqlTable) {
|
|
10029
10294
|
return mysqlTable("DeviceAccessToken", {
|
|
10030
|
-
token: (0,
|
|
10295
|
+
token: (0, import_mysql_core32.varchar)("token", {
|
|
10031
10296
|
length: 191
|
|
10032
10297
|
}).notNull(),
|
|
10033
|
-
userId: (0,
|
|
10298
|
+
userId: (0, import_mysql_core32.varchar)("userId", {
|
|
10034
10299
|
length: 191
|
|
10035
10300
|
}).notNull(),
|
|
10036
|
-
createdAt: (0,
|
|
10301
|
+
createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
|
|
10037
10302
|
mode: "date",
|
|
10038
10303
|
fsp: 3
|
|
10039
|
-
}).default(
|
|
10304
|
+
}).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`)
|
|
10040
10305
|
}, (crr) => ({
|
|
10041
|
-
pk: (0,
|
|
10306
|
+
pk: (0, import_mysql_core32.primaryKey)({
|
|
10042
10307
|
columns: [
|
|
10043
10308
|
crr.token
|
|
10044
10309
|
]
|
|
10045
10310
|
}),
|
|
10046
|
-
userIdIdx: (0,
|
|
10311
|
+
userIdIdx: (0, import_mysql_core32.index)("userId_idx").on(crr.userId)
|
|
10047
10312
|
}));
|
|
10048
10313
|
}
|
|
10049
10314
|
__name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
|
|
10050
10315
|
function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
10051
10316
|
const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
|
|
10052
10317
|
const user = getUsersSchema(mysqlTable);
|
|
10053
|
-
return (0,
|
|
10318
|
+
return (0, import_drizzle_orm28.relations)(deviceAccessToken, ({ one }) => ({
|
|
10054
10319
|
verifiedBy: one(user, {
|
|
10055
10320
|
fields: [
|
|
10056
10321
|
deviceAccessToken.userId
|
|
@@ -10065,31 +10330,31 @@ function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
|
10065
10330
|
__name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
|
|
10066
10331
|
|
|
10067
10332
|
// src/lib/mysql/schemas/auth/device-verification.ts
|
|
10068
|
-
var
|
|
10069
|
-
var
|
|
10333
|
+
var import_drizzle_orm29 = require("drizzle-orm");
|
|
10334
|
+
var import_mysql_core33 = require("drizzle-orm/mysql-core");
|
|
10070
10335
|
function getDeviceVerificationSchema(mysqlTable) {
|
|
10071
10336
|
return mysqlTable("DeviceVerification", {
|
|
10072
|
-
verifiedByUserId: (0,
|
|
10337
|
+
verifiedByUserId: (0, import_mysql_core33.varchar)("verifiedByUserId", {
|
|
10073
10338
|
length: 255
|
|
10074
10339
|
}),
|
|
10075
|
-
deviceCode: (0,
|
|
10340
|
+
deviceCode: (0, import_mysql_core33.varchar)("deviceCode", {
|
|
10076
10341
|
length: 191
|
|
10077
10342
|
}).notNull(),
|
|
10078
|
-
userCode: (0,
|
|
10079
|
-
expires: (0,
|
|
10343
|
+
userCode: (0, import_mysql_core33.text)("userCode").notNull(),
|
|
10344
|
+
expires: (0, import_mysql_core33.timestamp)("expires", {
|
|
10080
10345
|
mode: "date",
|
|
10081
10346
|
fsp: 3
|
|
10082
10347
|
}).notNull(),
|
|
10083
|
-
createdAt: (0,
|
|
10348
|
+
createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
|
|
10084
10349
|
mode: "date",
|
|
10085
10350
|
fsp: 3
|
|
10086
|
-
}).default(
|
|
10087
|
-
verifiedAt: (0,
|
|
10351
|
+
}).default(import_drizzle_orm29.sql`CURRENT_TIMESTAMP(3)`),
|
|
10352
|
+
verifiedAt: (0, import_mysql_core33.timestamp)("verifiedAt", {
|
|
10088
10353
|
mode: "date",
|
|
10089
10354
|
fsp: 3
|
|
10090
10355
|
})
|
|
10091
10356
|
}, (crr) => ({
|
|
10092
|
-
pk: (0,
|
|
10357
|
+
pk: (0, import_mysql_core33.primaryKey)({
|
|
10093
10358
|
columns: [
|
|
10094
10359
|
crr.deviceCode
|
|
10095
10360
|
]
|
|
@@ -10100,7 +10365,7 @@ __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
|
|
|
10100
10365
|
function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
10101
10366
|
const deviceVerification = getDeviceVerificationSchema(mysqlTable);
|
|
10102
10367
|
const user = getUsersSchema(mysqlTable);
|
|
10103
|
-
return (0,
|
|
10368
|
+
return (0, import_drizzle_orm29.relations)(deviceVerification, ({ one }) => ({
|
|
10104
10369
|
verifiedBy: one(user, {
|
|
10105
10370
|
fields: [
|
|
10106
10371
|
deviceVerification.verifiedByUserId
|
|
@@ -10115,38 +10380,38 @@ function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
|
10115
10380
|
__name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
|
|
10116
10381
|
|
|
10117
10382
|
// src/lib/mysql/schemas/auth/role-permissions.ts
|
|
10118
|
-
var
|
|
10119
|
-
var
|
|
10383
|
+
var import_drizzle_orm30 = require("drizzle-orm");
|
|
10384
|
+
var import_mysql_core34 = require("drizzle-orm/mysql-core");
|
|
10120
10385
|
function getRolePermissionsSchema(mysqlTable) {
|
|
10121
10386
|
return mysqlTable("RolePermission", {
|
|
10122
|
-
roleId: (0,
|
|
10387
|
+
roleId: (0, import_mysql_core34.varchar)("roleId", {
|
|
10123
10388
|
length: 255
|
|
10124
10389
|
}).notNull(),
|
|
10125
|
-
permissionId: (0,
|
|
10390
|
+
permissionId: (0, import_mysql_core34.varchar)("permissionId", {
|
|
10126
10391
|
length: 255
|
|
10127
10392
|
}).notNull(),
|
|
10128
|
-
active: (0,
|
|
10129
|
-
createdAt: (0,
|
|
10393
|
+
active: (0, import_mysql_core34.boolean)("active").notNull().default(true),
|
|
10394
|
+
createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
|
|
10130
10395
|
mode: "date",
|
|
10131
10396
|
fsp: 3
|
|
10132
10397
|
}).defaultNow(),
|
|
10133
|
-
updatedAt: (0,
|
|
10398
|
+
updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
|
|
10134
10399
|
mode: "date",
|
|
10135
10400
|
fsp: 3
|
|
10136
10401
|
}).defaultNow(),
|
|
10137
|
-
deletedAt: (0,
|
|
10402
|
+
deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
|
|
10138
10403
|
mode: "date",
|
|
10139
10404
|
fsp: 3
|
|
10140
10405
|
})
|
|
10141
10406
|
}, (rp) => ({
|
|
10142
|
-
pk: (0,
|
|
10407
|
+
pk: (0, import_mysql_core34.primaryKey)({
|
|
10143
10408
|
columns: [
|
|
10144
10409
|
rp.roleId,
|
|
10145
10410
|
rp.permissionId
|
|
10146
10411
|
]
|
|
10147
10412
|
}),
|
|
10148
|
-
roleIdIdx: (0,
|
|
10149
|
-
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)
|
|
10150
10415
|
}));
|
|
10151
10416
|
}
|
|
10152
10417
|
__name(getRolePermissionsSchema, "getRolePermissionsSchema");
|
|
@@ -10154,7 +10419,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
10154
10419
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
10155
10420
|
const roles = getRolesSchema(mysqlTable);
|
|
10156
10421
|
const rolePermissions = getRolePermissionsSchema(mysqlTable);
|
|
10157
|
-
return (0,
|
|
10422
|
+
return (0, import_drizzle_orm30.relations)(rolePermissions, ({ one }) => ({
|
|
10158
10423
|
role: one(roles, {
|
|
10159
10424
|
fields: [
|
|
10160
10425
|
rolePermissions.roleId
|
|
@@ -10178,28 +10443,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
10178
10443
|
__name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
|
|
10179
10444
|
|
|
10180
10445
|
// src/lib/mysql/schemas/auth/sessions.ts
|
|
10181
|
-
var
|
|
10182
|
-
var
|
|
10446
|
+
var import_drizzle_orm31 = require("drizzle-orm");
|
|
10447
|
+
var import_mysql_core35 = require("drizzle-orm/mysql-core");
|
|
10183
10448
|
function getSessionsSchema(mysqlTable) {
|
|
10184
10449
|
return mysqlTable("Session", {
|
|
10185
|
-
sessionToken: (0,
|
|
10450
|
+
sessionToken: (0, import_mysql_core35.varchar)("sessionToken", {
|
|
10186
10451
|
length: 255
|
|
10187
10452
|
}).notNull().primaryKey(),
|
|
10188
|
-
userId: (0,
|
|
10453
|
+
userId: (0, import_mysql_core35.varchar)("userId", {
|
|
10189
10454
|
length: 255
|
|
10190
10455
|
}).notNull(),
|
|
10191
|
-
expires: (0,
|
|
10456
|
+
expires: (0, import_mysql_core35.timestamp)("expires", {
|
|
10192
10457
|
mode: "date"
|
|
10193
10458
|
}).notNull()
|
|
10194
10459
|
}, (session) => ({
|
|
10195
|
-
userIdIdx: (0,
|
|
10460
|
+
userIdIdx: (0, import_mysql_core35.index)("userId_idx").on(session.userId)
|
|
10196
10461
|
}));
|
|
10197
10462
|
}
|
|
10198
10463
|
__name(getSessionsSchema, "getSessionsSchema");
|
|
10199
10464
|
function getSessionRelationsSchema(mysqlTable) {
|
|
10200
10465
|
const sessions = getSessionsSchema(mysqlTable);
|
|
10201
10466
|
const users = getUsersSchema(mysqlTable);
|
|
10202
|
-
return (0,
|
|
10467
|
+
return (0, import_drizzle_orm31.relations)(sessions, ({ one }) => ({
|
|
10203
10468
|
user: one(users, {
|
|
10204
10469
|
fields: [
|
|
10205
10470
|
sessions.userId
|
|
@@ -10214,24 +10479,24 @@ function getSessionRelationsSchema(mysqlTable) {
|
|
|
10214
10479
|
__name(getSessionRelationsSchema, "getSessionRelationsSchema");
|
|
10215
10480
|
|
|
10216
10481
|
// src/lib/mysql/schemas/auth/verification-tokens.ts
|
|
10217
|
-
var
|
|
10482
|
+
var import_mysql_core36 = require("drizzle-orm/mysql-core");
|
|
10218
10483
|
function getVerificationTokensSchema(mysqlTable) {
|
|
10219
10484
|
return mysqlTable("VerificationToken", {
|
|
10220
|
-
identifier: (0,
|
|
10485
|
+
identifier: (0, import_mysql_core36.varchar)("identifier", {
|
|
10221
10486
|
length: 255
|
|
10222
10487
|
}).notNull(),
|
|
10223
|
-
token: (0,
|
|
10488
|
+
token: (0, import_mysql_core36.varchar)("token", {
|
|
10224
10489
|
length: 255
|
|
10225
10490
|
}).notNull(),
|
|
10226
|
-
expires: (0,
|
|
10491
|
+
expires: (0, import_mysql_core36.timestamp)("expires", {
|
|
10227
10492
|
mode: "date"
|
|
10228
10493
|
}).notNull(),
|
|
10229
|
-
createdAt: (0,
|
|
10494
|
+
createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
|
|
10230
10495
|
mode: "date",
|
|
10231
10496
|
fsp: 3
|
|
10232
10497
|
}).defaultNow()
|
|
10233
10498
|
}, (vt) => ({
|
|
10234
|
-
pk: (0,
|
|
10499
|
+
pk: (0, import_mysql_core36.primaryKey)({
|
|
10235
10500
|
columns: [
|
|
10236
10501
|
vt.identifier,
|
|
10237
10502
|
vt.token
|
|
@@ -10242,14 +10507,14 @@ function getVerificationTokensSchema(mysqlTable) {
|
|
|
10242
10507
|
__name(getVerificationTokensSchema, "getVerificationTokensSchema");
|
|
10243
10508
|
|
|
10244
10509
|
// src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
|
|
10245
|
-
var
|
|
10246
|
-
var
|
|
10510
|
+
var import_drizzle_orm32 = require("drizzle-orm");
|
|
10511
|
+
var import_mysql_core37 = require("drizzle-orm/mysql-core");
|
|
10247
10512
|
function getPurchaseUserTransferSchema(mysqlTable) {
|
|
10248
10513
|
return mysqlTable("PurchaseUserTransfer", {
|
|
10249
|
-
id: (0,
|
|
10514
|
+
id: (0, import_mysql_core37.varchar)("id", {
|
|
10250
10515
|
length: 191
|
|
10251
10516
|
}).notNull(),
|
|
10252
|
-
transferState: (0,
|
|
10517
|
+
transferState: (0, import_mysql_core37.mysqlEnum)("transferState", [
|
|
10253
10518
|
"AVAILABLE",
|
|
10254
10519
|
"INITIATED",
|
|
10255
10520
|
"VERIFIED",
|
|
@@ -10258,38 +10523,38 @@ function getPurchaseUserTransferSchema(mysqlTable) {
|
|
|
10258
10523
|
"CONFIRMED",
|
|
10259
10524
|
"COMPLETED"
|
|
10260
10525
|
]).default("AVAILABLE").notNull(),
|
|
10261
|
-
purchaseId: (0,
|
|
10526
|
+
purchaseId: (0, import_mysql_core37.varchar)("purchaseId", {
|
|
10262
10527
|
length: 191
|
|
10263
10528
|
}).notNull(),
|
|
10264
|
-
sourceUserId: (0,
|
|
10529
|
+
sourceUserId: (0, import_mysql_core37.varchar)("sourceUserId", {
|
|
10265
10530
|
length: 191
|
|
10266
10531
|
}).notNull(),
|
|
10267
|
-
targetUserId: (0,
|
|
10532
|
+
targetUserId: (0, import_mysql_core37.varchar)("targetUserId", {
|
|
10268
10533
|
length: 191
|
|
10269
10534
|
}),
|
|
10270
|
-
createdAt: (0,
|
|
10535
|
+
createdAt: (0, import_mysql_core37.timestamp)("createdAt", {
|
|
10271
10536
|
mode: "date",
|
|
10272
10537
|
fsp: 3
|
|
10273
|
-
}).default(
|
|
10274
|
-
expiresAt: (0,
|
|
10538
|
+
}).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
10539
|
+
expiresAt: (0, import_mysql_core37.timestamp)("expiresAt", {
|
|
10275
10540
|
mode: "date",
|
|
10276
10541
|
fsp: 3
|
|
10277
10542
|
}),
|
|
10278
|
-
canceledAt: (0,
|
|
10543
|
+
canceledAt: (0, import_mysql_core37.timestamp)("canceledAt", {
|
|
10279
10544
|
mode: "date",
|
|
10280
10545
|
fsp: 3
|
|
10281
10546
|
}),
|
|
10282
|
-
confirmedAt: (0,
|
|
10547
|
+
confirmedAt: (0, import_mysql_core37.timestamp)("confirmedAt", {
|
|
10283
10548
|
mode: "date",
|
|
10284
10549
|
fsp: 3
|
|
10285
10550
|
}),
|
|
10286
|
-
completedAt: (0,
|
|
10551
|
+
completedAt: (0, import_mysql_core37.timestamp)("completedAt", {
|
|
10287
10552
|
mode: "date",
|
|
10288
10553
|
fsp: 3
|
|
10289
10554
|
})
|
|
10290
10555
|
}, (table) => {
|
|
10291
10556
|
return {
|
|
10292
|
-
purchaseUserTransferId: (0,
|
|
10557
|
+
purchaseUserTransferId: (0, import_mysql_core37.primaryKey)({
|
|
10293
10558
|
columns: [
|
|
10294
10559
|
table.id
|
|
10295
10560
|
],
|
|
@@ -10303,7 +10568,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10303
10568
|
const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
|
|
10304
10569
|
const user = getUsersSchema(mysqlTable);
|
|
10305
10570
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
10306
|
-
return (0,
|
|
10571
|
+
return (0, import_drizzle_orm32.relations)(purchaseUserTransfer, ({ one }) => ({
|
|
10307
10572
|
sourceUser: one(user, {
|
|
10308
10573
|
fields: [
|
|
10309
10574
|
purchaseUserTransfer.sourceUserId
|
|
@@ -10336,46 +10601,46 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
10336
10601
|
__name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
|
|
10337
10602
|
|
|
10338
10603
|
// src/lib/mysql/schemas/commerce/upgradable-products.ts
|
|
10339
|
-
var
|
|
10340
|
-
var
|
|
10604
|
+
var import_drizzle_orm33 = require("drizzle-orm");
|
|
10605
|
+
var import_mysql_core38 = require("drizzle-orm/mysql-core");
|
|
10341
10606
|
function getUpgradableProductsSchema(mysqlTable) {
|
|
10342
10607
|
return mysqlTable("UpgradableProducts", {
|
|
10343
|
-
upgradableToId: (0,
|
|
10608
|
+
upgradableToId: (0, import_mysql_core38.varchar)("upgradableToId", {
|
|
10344
10609
|
length: 255
|
|
10345
10610
|
}).notNull(),
|
|
10346
|
-
upgradableFromId: (0,
|
|
10611
|
+
upgradableFromId: (0, import_mysql_core38.varchar)("upgradableFrom", {
|
|
10347
10612
|
length: 255
|
|
10348
10613
|
}).notNull(),
|
|
10349
|
-
position: (0,
|
|
10350
|
-
metadata: (0,
|
|
10351
|
-
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", {
|
|
10352
10617
|
mode: "date",
|
|
10353
10618
|
fsp: 3
|
|
10354
|
-
}).default(
|
|
10355
|
-
updatedAt: (0,
|
|
10619
|
+
}).default(import_drizzle_orm33.sql`CURRENT_TIMESTAMP(3)`),
|
|
10620
|
+
updatedAt: (0, import_mysql_core38.timestamp)("updatedAt", {
|
|
10356
10621
|
mode: "date",
|
|
10357
10622
|
fsp: 3
|
|
10358
|
-
}).default(
|
|
10359
|
-
deletedAt: (0,
|
|
10623
|
+
}).default(import_drizzle_orm33.sql`CURRENT_TIMESTAMP(3)`),
|
|
10624
|
+
deletedAt: (0, import_mysql_core38.timestamp)("deletedAt", {
|
|
10360
10625
|
mode: "date",
|
|
10361
10626
|
fsp: 3
|
|
10362
10627
|
})
|
|
10363
10628
|
}, (crr) => ({
|
|
10364
|
-
pk: (0,
|
|
10629
|
+
pk: (0, import_mysql_core38.primaryKey)({
|
|
10365
10630
|
columns: [
|
|
10366
10631
|
crr.upgradableToId,
|
|
10367
10632
|
crr.upgradableFromId
|
|
10368
10633
|
]
|
|
10369
10634
|
}),
|
|
10370
|
-
upgradableToIdIdx: (0,
|
|
10371
|
-
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)
|
|
10372
10637
|
}));
|
|
10373
10638
|
}
|
|
10374
10639
|
__name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
|
|
10375
10640
|
function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
10376
10641
|
const product = getProductSchema(mysqlTable);
|
|
10377
10642
|
const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
|
|
10378
|
-
return (0,
|
|
10643
|
+
return (0, import_drizzle_orm33.relations)(upgradableProduct, ({ one }) => ({
|
|
10379
10644
|
upgradableTo: one(product, {
|
|
10380
10645
|
fields: [
|
|
10381
10646
|
upgradableProduct.upgradableToId
|
|
@@ -10399,88 +10664,88 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
|
10399
10664
|
__name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
|
|
10400
10665
|
|
|
10401
10666
|
// src/lib/mysql/schemas/content/lesson-progress.ts
|
|
10402
|
-
var
|
|
10403
|
-
var
|
|
10667
|
+
var import_drizzle_orm34 = require("drizzle-orm");
|
|
10668
|
+
var import_mysql_core39 = require("drizzle-orm/mysql-core");
|
|
10404
10669
|
function getLessonProgressSchema(mysqlTable) {
|
|
10405
10670
|
return mysqlTable("LessonProgress", {
|
|
10406
|
-
id: (0,
|
|
10671
|
+
id: (0, import_mysql_core39.varchar)("id", {
|
|
10407
10672
|
length: 191
|
|
10408
10673
|
}).notNull().primaryKey(),
|
|
10409
|
-
userId: (0,
|
|
10674
|
+
userId: (0, import_mysql_core39.varchar)("userId", {
|
|
10410
10675
|
length: 191
|
|
10411
10676
|
}).notNull(),
|
|
10412
|
-
lessonId: (0,
|
|
10677
|
+
lessonId: (0, import_mysql_core39.varchar)("lessonId", {
|
|
10413
10678
|
length: 191
|
|
10414
10679
|
}),
|
|
10415
|
-
lessonSlug: (0,
|
|
10680
|
+
lessonSlug: (0, import_mysql_core39.varchar)("lessonSlug", {
|
|
10416
10681
|
length: 191
|
|
10417
10682
|
}),
|
|
10418
|
-
lessonVersion: (0,
|
|
10683
|
+
lessonVersion: (0, import_mysql_core39.varchar)("lessonVersion", {
|
|
10419
10684
|
length: 191
|
|
10420
10685
|
}),
|
|
10421
|
-
sectionId: (0,
|
|
10686
|
+
sectionId: (0, import_mysql_core39.varchar)("sectionId", {
|
|
10422
10687
|
length: 191
|
|
10423
10688
|
}),
|
|
10424
|
-
moduleId: (0,
|
|
10689
|
+
moduleId: (0, import_mysql_core39.varchar)("moduleId", {
|
|
10425
10690
|
length: 191
|
|
10426
10691
|
}),
|
|
10427
|
-
completedAt: (0,
|
|
10692
|
+
completedAt: (0, import_mysql_core39.datetime)("completedAt", {
|
|
10428
10693
|
mode: "date",
|
|
10429
10694
|
fsp: 3
|
|
10430
10695
|
}),
|
|
10431
|
-
updatedAt: (0,
|
|
10696
|
+
updatedAt: (0, import_mysql_core39.datetime)("updatedAt", {
|
|
10432
10697
|
mode: "date",
|
|
10433
10698
|
fsp: 3
|
|
10434
10699
|
}),
|
|
10435
|
-
createdAt: (0,
|
|
10700
|
+
createdAt: (0, import_mysql_core39.datetime)("createdAt", {
|
|
10436
10701
|
mode: "date",
|
|
10437
10702
|
fsp: 3
|
|
10438
|
-
}).default(
|
|
10703
|
+
}).default(import_drizzle_orm34.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10439
10704
|
}, (crp) => {
|
|
10440
10705
|
return {
|
|
10441
|
-
userIdLessonIdIdx: (0,
|
|
10442
|
-
userIdIdx: (0,
|
|
10443
|
-
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)
|
|
10444
10709
|
};
|
|
10445
10710
|
});
|
|
10446
10711
|
}
|
|
10447
10712
|
__name(getLessonProgressSchema, "getLessonProgressSchema");
|
|
10448
10713
|
|
|
10449
10714
|
// src/lib/mysql/schemas/content/resource-progress.ts
|
|
10450
|
-
var
|
|
10451
|
-
var
|
|
10715
|
+
var import_drizzle_orm35 = require("drizzle-orm");
|
|
10716
|
+
var import_mysql_core40 = require("drizzle-orm/mysql-core");
|
|
10452
10717
|
function getResourceProgressSchema(mysqlTable) {
|
|
10453
10718
|
return mysqlTable("ResourceProgress", {
|
|
10454
|
-
userId: (0,
|
|
10719
|
+
userId: (0, import_mysql_core40.varchar)("userId", {
|
|
10455
10720
|
length: 255
|
|
10456
10721
|
}).notNull(),
|
|
10457
|
-
resourceId: (0,
|
|
10722
|
+
resourceId: (0, import_mysql_core40.varchar)("resourceId", {
|
|
10458
10723
|
length: 255
|
|
10459
10724
|
}),
|
|
10460
|
-
fields: (0,
|
|
10461
|
-
completedAt: (0,
|
|
10725
|
+
fields: (0, import_mysql_core40.json)("fields").$type().default({}),
|
|
10726
|
+
completedAt: (0, import_mysql_core40.datetime)("completedAt", {
|
|
10462
10727
|
mode: "date",
|
|
10463
10728
|
fsp: 3
|
|
10464
10729
|
}),
|
|
10465
|
-
updatedAt: (0,
|
|
10730
|
+
updatedAt: (0, import_mysql_core40.datetime)("updatedAt", {
|
|
10466
10731
|
mode: "date",
|
|
10467
10732
|
fsp: 3
|
|
10468
10733
|
}),
|
|
10469
|
-
createdAt: (0,
|
|
10734
|
+
createdAt: (0, import_mysql_core40.datetime)("createdAt", {
|
|
10470
10735
|
mode: "date",
|
|
10471
10736
|
fsp: 3
|
|
10472
|
-
}).default(
|
|
10737
|
+
}).default(import_drizzle_orm35.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
10473
10738
|
}, (crp) => {
|
|
10474
10739
|
return {
|
|
10475
|
-
userIdLessonIdIdx: (0,
|
|
10476
|
-
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)({
|
|
10477
10742
|
columns: [
|
|
10478
10743
|
crp.userId,
|
|
10479
10744
|
crp.resourceId
|
|
10480
10745
|
]
|
|
10481
10746
|
}),
|
|
10482
|
-
contentResourceIdIdx: (0,
|
|
10483
|
-
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)
|
|
10484
10749
|
};
|
|
10485
10750
|
});
|
|
10486
10751
|
}
|
|
@@ -10531,9 +10796,13 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10531
10796
|
contentContributions: getContentContributionsSchema(mysqlTable),
|
|
10532
10797
|
contentContributionRelations: getContentContributionRelationsSchema(mysqlTable),
|
|
10533
10798
|
contentResource: getContentResourceSchema(mysqlTable),
|
|
10799
|
+
contentResourceVersion: getContentResourceVersionSchema(mysqlTable),
|
|
10800
|
+
contentResourceVersionRelations: getContentResourceVersionRelationsSchema(mysqlTable),
|
|
10534
10801
|
contentResourceRelations: getContentResourceRelationsSchema(mysqlTable),
|
|
10535
10802
|
contentResourceResource: getContentResourceResourceSchema(mysqlTable),
|
|
10536
10803
|
contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
|
|
10804
|
+
contentResourceTag: getContentResourceTagSchema(mysqlTable),
|
|
10805
|
+
contentResourceTagRelations: getContentResourceTagRelationsSchema(mysqlTable),
|
|
10537
10806
|
contributionTypes: getContributionTypesSchema(mysqlTable),
|
|
10538
10807
|
contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
|
|
10539
10808
|
resourceProgress: getResourceProgressSchema(mysqlTable),
|
|
@@ -10548,6 +10817,10 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
10548
10817
|
deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable),
|
|
10549
10818
|
deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
|
|
10550
10819
|
deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable),
|
|
10820
|
+
tag: getTagSchema(mysqlTable),
|
|
10821
|
+
tagRelations: getTagRelationsSchema(mysqlTable),
|
|
10822
|
+
tagTag: getTagTagSchema(mysqlTable),
|
|
10823
|
+
tagTagRelations: getTagTagRelationsSchema(mysqlTable),
|
|
10551
10824
|
userPrefs: getUserPrefsSchema(mysqlTable),
|
|
10552
10825
|
userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable)
|
|
10553
10826
|
};
|
|
@@ -10557,7 +10830,7 @@ function createTables(mySqlTable) {
|
|
|
10557
10830
|
return getCourseBuilderSchema(mySqlTable);
|
|
10558
10831
|
}
|
|
10559
10832
|
__name(createTables, "createTables");
|
|
10560
|
-
function mySqlDrizzleAdapter(client, tableFn =
|
|
10833
|
+
function mySqlDrizzleAdapter(client, tableFn = import_mysql_core41.mysqlTable, paymentProvider) {
|
|
10561
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);
|
|
10562
10835
|
const adapter = {
|
|
10563
10836
|
client,
|
|
@@ -10629,12 +10902,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10629
10902
|
},
|
|
10630
10903
|
incrementCouponUsedCount: async (couponId) => {
|
|
10631
10904
|
await client.update(coupon).set({
|
|
10632
|
-
usedCount:
|
|
10633
|
-
}).where((0,
|
|
10905
|
+
usedCount: import_drizzle_orm36.sql`${coupon.usedCount} + 1`
|
|
10906
|
+
}).where((0, import_drizzle_orm36.eq)(coupon.id, couponId));
|
|
10634
10907
|
},
|
|
10635
10908
|
getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
|
|
10636
10909
|
const existingPurchases = await client.query.purchases.findMany({
|
|
10637
|
-
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))
|
|
10638
10911
|
});
|
|
10639
10912
|
return z.array(purchaseSchema).parse(existingPurchases);
|
|
10640
10913
|
},
|
|
@@ -10647,17 +10920,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10647
10920
|
status: 1
|
|
10648
10921
|
});
|
|
10649
10922
|
return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
10650
|
-
where: (0,
|
|
10923
|
+
where: (0, import_drizzle_orm36.eq)(merchantCustomer.identifier, options.identifier)
|
|
10651
10924
|
}));
|
|
10652
10925
|
},
|
|
10653
10926
|
getMerchantAccount: async (options) => {
|
|
10654
10927
|
return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
|
|
10655
|
-
where: (0,
|
|
10928
|
+
where: (0, import_drizzle_orm36.eq)(merchantAccount.label, options.provider)
|
|
10656
10929
|
}));
|
|
10657
10930
|
},
|
|
10658
10931
|
getMerchantPriceForProductId: async (productId) => {
|
|
10659
10932
|
const merchantPriceData = await client.query.merchantPrice.findFirst({
|
|
10660
|
-
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))
|
|
10661
10934
|
});
|
|
10662
10935
|
const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
|
|
10663
10936
|
if (!parsedMerchantPrice.success) {
|
|
@@ -10668,7 +10941,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10668
10941
|
},
|
|
10669
10942
|
getMerchantProductForProductId: async (productId) => {
|
|
10670
10943
|
const merchantProductData = await client.query.merchantProduct.findFirst({
|
|
10671
|
-
where: (0,
|
|
10944
|
+
where: (0, import_drizzle_orm36.eq)(merchantProduct.productId, productId)
|
|
10672
10945
|
});
|
|
10673
10946
|
if (!merchantProductData)
|
|
10674
10947
|
return null;
|
|
@@ -10676,7 +10949,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10676
10949
|
},
|
|
10677
10950
|
getMerchantCustomerForUserId: async (userId) => {
|
|
10678
10951
|
const merchantCustomerData = await client.query.merchantCustomer.findFirst({
|
|
10679
|
-
where: (0,
|
|
10952
|
+
where: (0, import_drizzle_orm36.eq)(merchantCustomer.userId, userId)
|
|
10680
10953
|
});
|
|
10681
10954
|
if (!merchantCustomerData)
|
|
10682
10955
|
return null;
|
|
@@ -10685,14 +10958,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10685
10958
|
getUpgradableProducts: async (options) => {
|
|
10686
10959
|
const { upgradableFromId, upgradableToId } = options;
|
|
10687
10960
|
return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
10688
|
-
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))
|
|
10689
10962
|
}));
|
|
10690
10963
|
},
|
|
10691
10964
|
async availableUpgradesForProduct(purchases, productId) {
|
|
10692
10965
|
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
10693
10966
|
if (previousPurchaseProductIds.length > 0) {
|
|
10694
10967
|
return client.query.upgradableProducts.findMany({
|
|
10695
|
-
where: (0,
|
|
10968
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm36.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
|
|
10696
10969
|
});
|
|
10697
10970
|
}
|
|
10698
10971
|
return [];
|
|
@@ -10705,7 +10978,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10705
10978
|
throw new Error("No lessonId provided");
|
|
10706
10979
|
}
|
|
10707
10980
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10708
|
-
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))
|
|
10709
10982
|
});
|
|
10710
10983
|
const now = /* @__PURE__ */ new Date();
|
|
10711
10984
|
if (lessonProgress) {
|
|
@@ -10713,7 +10986,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10713
10986
|
await client.update(resourceProgress).set({
|
|
10714
10987
|
completedAt: now,
|
|
10715
10988
|
updatedAt: now
|
|
10716
|
-
}).where((0,
|
|
10989
|
+
}).where((0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId));
|
|
10717
10990
|
}
|
|
10718
10991
|
} else {
|
|
10719
10992
|
await client.insert(resourceProgress).values({
|
|
@@ -10724,7 +10997,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10724
10997
|
});
|
|
10725
10998
|
}
|
|
10726
10999
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
10727
|
-
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))
|
|
10728
11001
|
});
|
|
10729
11002
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
10730
11003
|
if (!parsedLessonProgress.success) {
|
|
@@ -10737,7 +11010,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10737
11010
|
if (!options.couponId && !options.code)
|
|
10738
11011
|
return null;
|
|
10739
11012
|
const couponForIdOrCode = await client.query.coupon.findFirst({
|
|
10740
|
-
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))),
|
|
10741
11014
|
with: {
|
|
10742
11015
|
merchantCoupon: true
|
|
10743
11016
|
}
|
|
@@ -10758,10 +11031,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10758
11031
|
try {
|
|
10759
11032
|
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
|
|
10760
11033
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10761
|
-
where: (0,
|
|
11034
|
+
where: (0, import_drizzle_orm36.eq)(merchantCharge.identifier, stripeChargeId)
|
|
10762
11035
|
}) || null);
|
|
10763
11036
|
const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
|
|
10764
|
-
where: (0,
|
|
11037
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
|
|
10765
11038
|
with: {
|
|
10766
11039
|
user: true,
|
|
10767
11040
|
product: true,
|
|
@@ -10782,12 +11055,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10782
11055
|
merchantCustomerId
|
|
10783
11056
|
});
|
|
10784
11057
|
const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
|
|
10785
|
-
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, [
|
|
10786
11059
|
"Valid",
|
|
10787
11060
|
"Restricted"
|
|
10788
11061
|
]))
|
|
10789
11062
|
}) || null);
|
|
10790
|
-
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) => {
|
|
10791
11064
|
return res[0]?.Coupon ?? null;
|
|
10792
11065
|
}));
|
|
10793
11066
|
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
|
|
@@ -10798,10 +11071,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10798
11071
|
if (existingBulkCoupon !== null) {
|
|
10799
11072
|
couponToUpdate = await client.update(coupon).set({
|
|
10800
11073
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
|
|
10801
|
-
}).where((0,
|
|
11074
|
+
}).where((0, import_drizzle_orm36.eq)(coupon.id, bulkCouponId));
|
|
10802
11075
|
} else {
|
|
10803
11076
|
const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
10804
|
-
where: (0,
|
|
11077
|
+
where: (0, import_drizzle_orm36.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10805
11078
|
})) : null;
|
|
10806
11079
|
couponToUpdate = await client.insert(coupon).values({
|
|
10807
11080
|
id: bulkCouponId,
|
|
@@ -10822,10 +11095,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10822
11095
|
merchantAccountId
|
|
10823
11096
|
});
|
|
10824
11097
|
const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10825
|
-
where: (0,
|
|
11098
|
+
where: (0, import_drizzle_orm36.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
10826
11099
|
}) : null;
|
|
10827
11100
|
const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
10828
|
-
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"))
|
|
10829
11102
|
}) : null;
|
|
10830
11103
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
10831
11104
|
const newPurchase = await client.insert(purchaseTable).values({
|
|
@@ -10856,7 +11129,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10856
11129
|
}
|
|
10857
11130
|
});
|
|
10858
11131
|
const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
10859
|
-
where: (0,
|
|
11132
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId)
|
|
10860
11133
|
}));
|
|
10861
11134
|
if (!parsedPurchase.success) {
|
|
10862
11135
|
console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
|
|
@@ -10901,7 +11174,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10901
11174
|
},
|
|
10902
11175
|
async getCoupon(couponIdOrCode) {
|
|
10903
11176
|
const loadedCoupon = await client.query.coupon.findFirst({
|
|
10904
|
-
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))
|
|
10905
11178
|
}) || null;
|
|
10906
11179
|
logger.debug("loadedCoupon", {
|
|
10907
11180
|
loadedCoupon
|
|
@@ -10916,7 +11189,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10916
11189
|
let bulkCouponPurchases;
|
|
10917
11190
|
try {
|
|
10918
11191
|
couponData = await client.query.coupon.findFirst({
|
|
10919
|
-
where: (0,
|
|
11192
|
+
where: (0, import_drizzle_orm36.eq)(coupon.id, couponId),
|
|
10920
11193
|
with: {
|
|
10921
11194
|
bulkPurchases: true,
|
|
10922
11195
|
redeemedBulkCouponPurchases: true
|
|
@@ -10928,7 +11201,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10928
11201
|
}
|
|
10929
11202
|
try {
|
|
10930
11203
|
bulkCouponPurchases = await client.query.purchases.findMany({
|
|
10931
|
-
where: (0,
|
|
11204
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.redeemedBulkCouponId, couponId),
|
|
10932
11205
|
with: {
|
|
10933
11206
|
user: true
|
|
10934
11207
|
}
|
|
@@ -10960,8 +11233,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10960
11233
|
},
|
|
10961
11234
|
async getDefaultCoupon(productIds) {
|
|
10962
11235
|
const activeSaleCoupon = await client.query.coupon.findFirst({
|
|
10963
|
-
where: (0,
|
|
10964
|
-
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),
|
|
10965
11238
|
with: {
|
|
10966
11239
|
merchantCoupon: true,
|
|
10967
11240
|
product: true
|
|
@@ -10985,7 +11258,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10985
11258
|
},
|
|
10986
11259
|
async getLessonProgressForUser(userId) {
|
|
10987
11260
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
10988
|
-
where: (0,
|
|
11261
|
+
where: (0, import_drizzle_orm36.eq)(resourceProgress.userId, userId)
|
|
10989
11262
|
});
|
|
10990
11263
|
const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
10991
11264
|
if (!parsed.success) {
|
|
@@ -10996,7 +11269,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
10996
11269
|
},
|
|
10997
11270
|
async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
|
|
10998
11271
|
const user = await client.query.users.findFirst({
|
|
10999
|
-
where: (0,
|
|
11272
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm36.eq)(users.email, userIdOrEmail)),
|
|
11000
11273
|
columns: {
|
|
11001
11274
|
id: true
|
|
11002
11275
|
}
|
|
@@ -11013,7 +11286,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11013
11286
|
resource_slug: z.string().nullable(),
|
|
11014
11287
|
completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
|
|
11015
11288
|
});
|
|
11016
|
-
const results = await client.execute(
|
|
11289
|
+
const results = await client.execute(import_drizzle_orm36.sql`
|
|
11017
11290
|
SELECT
|
|
11018
11291
|
cr.id AS resource_id,
|
|
11019
11292
|
cr.type AS resource_type,
|
|
@@ -11094,7 +11367,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11094
11367
|
},
|
|
11095
11368
|
async getMerchantCharge(merchantChargeId) {
|
|
11096
11369
|
const mCharge = await client.query.merchantCharge.findFirst({
|
|
11097
|
-
where: (0,
|
|
11370
|
+
where: (0, import_drizzle_orm36.eq)(merchantCharge.id, merchantChargeId)
|
|
11098
11371
|
});
|
|
11099
11372
|
const parsed = merchantChargeSchema.safeParse(mCharge);
|
|
11100
11373
|
if (!parsed.success) {
|
|
@@ -11105,12 +11378,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11105
11378
|
},
|
|
11106
11379
|
async getMerchantCouponsForTypeAndPercent(params) {
|
|
11107
11380
|
return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
|
|
11108
|
-
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()))
|
|
11109
11382
|
}));
|
|
11110
11383
|
},
|
|
11111
11384
|
async getMerchantCouponForTypeAndPercent(params) {
|
|
11112
11385
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
11113
|
-
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()))
|
|
11114
11387
|
});
|
|
11115
11388
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
11116
11389
|
if (parsed.success) {
|
|
@@ -11120,7 +11393,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11120
11393
|
},
|
|
11121
11394
|
async getMerchantCoupon(merchantCouponId) {
|
|
11122
11395
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
11123
|
-
where: (0,
|
|
11396
|
+
where: (0, import_drizzle_orm36.eq)(merchantCoupon.id, merchantCouponId)
|
|
11124
11397
|
});
|
|
11125
11398
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
11126
11399
|
if (parsed.success) {
|
|
@@ -11130,7 +11403,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11130
11403
|
},
|
|
11131
11404
|
async getMerchantProduct(stripeProductId) {
|
|
11132
11405
|
return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
|
|
11133
|
-
where: (0,
|
|
11406
|
+
where: (0, import_drizzle_orm36.eq)(merchantProduct.identifier, stripeProductId)
|
|
11134
11407
|
}));
|
|
11135
11408
|
},
|
|
11136
11409
|
getPrice(productId) {
|
|
@@ -11138,7 +11411,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11138
11411
|
},
|
|
11139
11412
|
async getPriceForProduct(productId) {
|
|
11140
11413
|
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
11141
|
-
where: (0,
|
|
11414
|
+
where: (0, import_drizzle_orm36.eq)(prices.productId, productId)
|
|
11142
11415
|
}));
|
|
11143
11416
|
},
|
|
11144
11417
|
async archiveProduct(productId) {
|
|
@@ -11154,19 +11427,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11154
11427
|
await client.update(products).set({
|
|
11155
11428
|
status: 0,
|
|
11156
11429
|
name: `${product.name} (Archived)`
|
|
11157
|
-
}).where((0,
|
|
11430
|
+
}).where((0, import_drizzle_orm36.eq)(products.id, productId));
|
|
11158
11431
|
await client.update(prices).set({
|
|
11159
11432
|
status: 0,
|
|
11160
11433
|
nickname: `${product.name} (Archived)`
|
|
11161
|
-
}).where((0,
|
|
11434
|
+
}).where((0, import_drizzle_orm36.eq)(prices.productId, productId));
|
|
11162
11435
|
await client.update(merchantProduct).set({
|
|
11163
11436
|
status: 0
|
|
11164
|
-
}).where((0,
|
|
11437
|
+
}).where((0, import_drizzle_orm36.eq)(merchantProduct.productId, productId));
|
|
11165
11438
|
await client.update(merchantPrice).set({
|
|
11166
11439
|
status: 0
|
|
11167
|
-
}).where((0,
|
|
11440
|
+
}).where((0, import_drizzle_orm36.eq)(merchantPrice.priceId, product.price.id));
|
|
11168
11441
|
const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
11169
|
-
where: (0,
|
|
11442
|
+
where: (0, import_drizzle_orm36.eq)(merchantProduct.productId, productId)
|
|
11170
11443
|
}));
|
|
11171
11444
|
if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
|
|
11172
11445
|
throw new Error(`Merchant product not found for id (${productId})`);
|
|
@@ -11175,7 +11448,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11175
11448
|
active: false
|
|
11176
11449
|
});
|
|
11177
11450
|
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
11178
|
-
where: (0,
|
|
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))
|
|
11179
11452
|
}));
|
|
11180
11453
|
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
11181
11454
|
throw new Error(`Merchant price not found for id (${productId})`);
|
|
@@ -11235,12 +11508,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11235
11508
|
if (currentMerchantPrice) {
|
|
11236
11509
|
await client.update(merchantPrice).set({
|
|
11237
11510
|
status: 0
|
|
11238
|
-
}).where((0,
|
|
11511
|
+
}).where((0, import_drizzle_orm36.eq)(merchantPrice.id, currentMerchantPrice.id));
|
|
11239
11512
|
}
|
|
11240
11513
|
await client.update(prices).set({
|
|
11241
11514
|
unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
|
|
11242
11515
|
nickname: input.name
|
|
11243
|
-
}).where((0,
|
|
11516
|
+
}).where((0, import_drizzle_orm36.eq)(prices.id, currentProduct.price.id));
|
|
11244
11517
|
if (currentStripePrice) {
|
|
11245
11518
|
await paymentProvider.updatePrice(currentStripePrice.id, {
|
|
11246
11519
|
active: false
|
|
@@ -11269,7 +11542,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11269
11542
|
image
|
|
11270
11543
|
}
|
|
11271
11544
|
}
|
|
11272
|
-
}).where((0,
|
|
11545
|
+
}).where((0, import_drizzle_orm36.eq)(products.id, currentProduct.id));
|
|
11273
11546
|
return adapter.getProduct(currentProduct.id);
|
|
11274
11547
|
},
|
|
11275
11548
|
async createProduct(input) {
|
|
@@ -11345,7 +11618,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11345
11618
|
}
|
|
11346
11619
|
try {
|
|
11347
11620
|
const productData = await client.query.products.findFirst({
|
|
11348
|
-
where: (0,
|
|
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))),
|
|
11349
11622
|
with: {
|
|
11350
11623
|
price: true,
|
|
11351
11624
|
...withResources && {
|
|
@@ -11374,20 +11647,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11374
11647
|
},
|
|
11375
11648
|
async getProductResources(productId) {
|
|
11376
11649
|
const contentResourceProductsForProduct = z.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
|
|
11377
|
-
where: (0,
|
|
11650
|
+
where: (0, import_drizzle_orm36.eq)(contentResourceProduct.productId, productId)
|
|
11378
11651
|
}));
|
|
11379
11652
|
if (!contentResourceProductsForProduct) {
|
|
11380
11653
|
return null;
|
|
11381
11654
|
} else {
|
|
11382
11655
|
const contentResources = z.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
|
|
11383
|
-
where: (0,
|
|
11656
|
+
where: (0, import_drizzle_orm36.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
|
|
11384
11657
|
}));
|
|
11385
11658
|
return contentResources;
|
|
11386
11659
|
}
|
|
11387
11660
|
},
|
|
11388
11661
|
async getPurchaseCountForProduct(productId) {
|
|
11389
11662
|
return await client.query.purchases.findMany({
|
|
11390
|
-
where: (0,
|
|
11663
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm36.inArray)(purchaseTable.status, [
|
|
11391
11664
|
"Valid",
|
|
11392
11665
|
"Restricted"
|
|
11393
11666
|
]))
|
|
@@ -11395,7 +11668,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11395
11668
|
},
|
|
11396
11669
|
async getPurchase(purchaseId) {
|
|
11397
11670
|
const purchase = await client.query.purchases.findFirst({
|
|
11398
|
-
where: (0,
|
|
11671
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId)
|
|
11399
11672
|
});
|
|
11400
11673
|
return purchase ? purchaseSchema.parse(purchase) : null;
|
|
11401
11674
|
},
|
|
@@ -11413,14 +11686,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11413
11686
|
stripeChargeId
|
|
11414
11687
|
});
|
|
11415
11688
|
const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
11416
|
-
where: (0,
|
|
11689
|
+
where: (0, import_drizzle_orm36.eq)(merchantCharge.identifier, stripeChargeId)
|
|
11417
11690
|
}) || null);
|
|
11418
11691
|
if (!chargeForPurchase) {
|
|
11419
11692
|
logger.error(new Error(`No charge found for purchase: Stripe Charge ID: ${stripeChargeId}`));
|
|
11420
11693
|
return null;
|
|
11421
11694
|
}
|
|
11422
11695
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
11423
|
-
where: (0,
|
|
11696
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
|
|
11424
11697
|
with: {
|
|
11425
11698
|
user: true,
|
|
11426
11699
|
product: true,
|
|
@@ -11434,7 +11707,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11434
11707
|
},
|
|
11435
11708
|
async getPurchaseUserTransferById(options) {
|
|
11436
11709
|
const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
11437
|
-
where: (0,
|
|
11710
|
+
where: (0, import_drizzle_orm36.eq)(purchaseUserTransfer.id, options.id),
|
|
11438
11711
|
with: {
|
|
11439
11712
|
sourceUser: true,
|
|
11440
11713
|
targetUser: true,
|
|
@@ -11449,7 +11722,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11449
11722
|
},
|
|
11450
11723
|
async getPurchaseWithUser(purchaseId) {
|
|
11451
11724
|
const purchaseData = await client.query.purchases.findFirst({
|
|
11452
|
-
where: (0,
|
|
11725
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, purchaseId),
|
|
11453
11726
|
with: {
|
|
11454
11727
|
user: true
|
|
11455
11728
|
}
|
|
@@ -11473,13 +11746,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11473
11746
|
"Restricted"
|
|
11474
11747
|
];
|
|
11475
11748
|
const userPurchases = await client.query.purchases.findMany({
|
|
11476
|
-
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)),
|
|
11477
11750
|
with: {
|
|
11478
11751
|
user: true,
|
|
11479
11752
|
product: true,
|
|
11480
11753
|
bulkCoupon: true
|
|
11481
11754
|
},
|
|
11482
|
-
orderBy: (0,
|
|
11755
|
+
orderBy: (0, import_drizzle_orm36.asc)(purchaseTable.createdAt)
|
|
11483
11756
|
});
|
|
11484
11757
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
11485
11758
|
if (!parsedPurchases.success) {
|
|
@@ -11495,18 +11768,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11495
11768
|
"Restricted"
|
|
11496
11769
|
];
|
|
11497
11770
|
const userPurchases = await client.query.purchases.findMany({
|
|
11498
|
-
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)),
|
|
11499
11772
|
with: {
|
|
11500
11773
|
user: true,
|
|
11501
11774
|
product: true,
|
|
11502
11775
|
bulkCoupon: true
|
|
11503
11776
|
},
|
|
11504
|
-
orderBy: (0,
|
|
11777
|
+
orderBy: (0, import_drizzle_orm36.asc)(purchaseTable.createdAt)
|
|
11505
11778
|
});
|
|
11506
11779
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
11507
11780
|
const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
|
|
11508
11781
|
const thePurchase = await client.query.purchases.findFirst({
|
|
11509
|
-
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)),
|
|
11510
11783
|
with: {
|
|
11511
11784
|
user: true,
|
|
11512
11785
|
product: true,
|
|
@@ -11527,7 +11800,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11527
11800
|
let availableUpgrades = [];
|
|
11528
11801
|
if (purchaseCanUpgrade) {
|
|
11529
11802
|
availableUpgrades = await client.query.upgradableProducts.findMany({
|
|
11530
|
-
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)))),
|
|
11531
11804
|
with: {
|
|
11532
11805
|
upgradableTo: true,
|
|
11533
11806
|
upgradableFrom: true
|
|
@@ -11535,10 +11808,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11535
11808
|
});
|
|
11536
11809
|
}
|
|
11537
11810
|
const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
|
|
11538
|
-
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, [
|
|
11539
11812
|
"Valid",
|
|
11540
11813
|
"Restricted"
|
|
11541
|
-
]), (0,
|
|
11814
|
+
]), (0, import_drizzle_orm36.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm36.not)((0, import_drizzle_orm36.eq)(purchaseTable.id, parsedPurchase.data.id))),
|
|
11542
11815
|
with: {
|
|
11543
11816
|
user: true,
|
|
11544
11817
|
product: true,
|
|
@@ -11553,7 +11826,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11553
11826
|
},
|
|
11554
11827
|
async getUserWithPurchasersByEmail(email) {
|
|
11555
11828
|
const user = await client.query.users.findFirst({
|
|
11556
|
-
where: (0,
|
|
11829
|
+
where: (0, import_drizzle_orm36.eq)(users.email, email.trim().toLowerCase()),
|
|
11557
11830
|
with: {
|
|
11558
11831
|
// merchantCustomer: true,
|
|
11559
11832
|
roles: {
|
|
@@ -11580,7 +11853,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11580
11853
|
},
|
|
11581
11854
|
async getUserById(userId) {
|
|
11582
11855
|
const user = await client.query.users.findFirst({
|
|
11583
|
-
where: (0,
|
|
11856
|
+
where: (0, import_drizzle_orm36.eq)(users.id, userId),
|
|
11584
11857
|
with: {
|
|
11585
11858
|
roles: {
|
|
11586
11859
|
with: {
|
|
@@ -11602,13 +11875,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11602
11875
|
if (userId === void 0)
|
|
11603
11876
|
return [];
|
|
11604
11877
|
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
11605
|
-
where: (0,
|
|
11878
|
+
where: (0, import_drizzle_orm36.eq)(upgradableProducts.upgradableToId, bundleId)
|
|
11606
11879
|
});
|
|
11607
11880
|
const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
|
|
11608
11881
|
return product.upgradableFromId;
|
|
11609
11882
|
}));
|
|
11610
11883
|
const purchases = await client.query.purchases.findMany({
|
|
11611
|
-
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))
|
|
11612
11885
|
});
|
|
11613
11886
|
const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
|
|
11614
11887
|
return purchase.productId;
|
|
@@ -11616,7 +11889,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11616
11889
|
if (productsPurchased.length === 0)
|
|
11617
11890
|
return [];
|
|
11618
11891
|
const foundPrices = await client.query.prices.findMany({
|
|
11619
|
-
where: (0,
|
|
11892
|
+
where: (0, import_drizzle_orm36.inArray)(prices.productId, productsPurchased)
|
|
11620
11893
|
});
|
|
11621
11894
|
return z.array(priceSchema).parse(foundPrices);
|
|
11622
11895
|
},
|
|
@@ -11625,14 +11898,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11625
11898
|
throw new Error("No lessonId provided");
|
|
11626
11899
|
}
|
|
11627
11900
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11628
|
-
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))
|
|
11629
11902
|
});
|
|
11630
11903
|
const now = /* @__PURE__ */ new Date();
|
|
11631
11904
|
if (lessonProgress) {
|
|
11632
11905
|
await client.update(resourceProgress).set({
|
|
11633
11906
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
11634
11907
|
updatedAt: now
|
|
11635
|
-
}).where((0,
|
|
11908
|
+
}).where((0, import_drizzle_orm36.eq)(resourceProgress.resourceId, options.lessonId));
|
|
11636
11909
|
} else {
|
|
11637
11910
|
await client.insert(resourceProgress).values({
|
|
11638
11911
|
userId: options.userId,
|
|
@@ -11642,7 +11915,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11642
11915
|
});
|
|
11643
11916
|
}
|
|
11644
11917
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11645
|
-
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))
|
|
11646
11919
|
});
|
|
11647
11920
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
11648
11921
|
if (!parsedLessonProgress.success) {
|
|
@@ -11651,6 +11924,65 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11651
11924
|
}
|
|
11652
11925
|
return parsedLessonProgress.data;
|
|
11653
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
|
+
},
|
|
11654
11986
|
transferPurchasesToNewUser(options) {
|
|
11655
11987
|
throw new Error("Method not implemented.");
|
|
11656
11988
|
},
|
|
@@ -11661,7 +11993,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11661
11993
|
status
|
|
11662
11994
|
});
|
|
11663
11995
|
const merchantChargeForPurchase = await client.query.merchantCharge.findFirst({
|
|
11664
|
-
where: (0,
|
|
11996
|
+
where: (0, import_drizzle_orm36.or)((0, import_drizzle_orm36.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm36.eq)(merchantCharge.id, chargeId))
|
|
11665
11997
|
});
|
|
11666
11998
|
console.log("merchantChargeForPurchase", {
|
|
11667
11999
|
merchantChargeForPurchase
|
|
@@ -11670,15 +12002,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11670
12002
|
if (!parsedMerchantChargeForPurchase)
|
|
11671
12003
|
throw new Error(`no-charge-found-for-purchase ${chargeId}`);
|
|
11672
12004
|
const purchase = await client.query.purchases.findFirst({
|
|
11673
|
-
where: (0,
|
|
12005
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
|
|
11674
12006
|
});
|
|
11675
12007
|
const parsedPurchase = purchaseSchema.nullable().parse(purchase);
|
|
11676
12008
|
if (parsedPurchase) {
|
|
11677
12009
|
await client.update(purchaseTable).set({
|
|
11678
12010
|
status
|
|
11679
|
-
}).where((0,
|
|
12011
|
+
}).where((0, import_drizzle_orm36.eq)(purchaseTable.id, parsedPurchase.id));
|
|
11680
12012
|
const newPurchase = await client.query.purchases.findFirst({
|
|
11681
|
-
where: (0,
|
|
12013
|
+
where: (0, import_drizzle_orm36.eq)(purchaseTable.id, parsedPurchase.id)
|
|
11682
12014
|
});
|
|
11683
12015
|
return purchaseSchema.optional().parse(newPurchase);
|
|
11684
12016
|
} else {
|
|
@@ -11692,16 +12024,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11692
12024
|
async updatePurchaseUserTransferTransferState(options) {
|
|
11693
12025
|
await client.update(purchaseUserTransfer).set({
|
|
11694
12026
|
transferState: options.transferState
|
|
11695
|
-
}).where((0,
|
|
12027
|
+
}).where((0, import_drizzle_orm36.eq)(purchaseUserTransfer.id, options.id));
|
|
11696
12028
|
const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
11697
|
-
where: (0,
|
|
12029
|
+
where: (0, import_drizzle_orm36.eq)(purchaseUserTransfer.id, options.id)
|
|
11698
12030
|
}) || null;
|
|
11699
12031
|
return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
|
|
11700
12032
|
},
|
|
11701
12033
|
addResourceToResource: async function(options) {
|
|
11702
12034
|
const { parentResourceId, childResourceId } = options;
|
|
11703
12035
|
const parentResourceData = await client.query.contentResource.findFirst({
|
|
11704
|
-
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)),
|
|
11705
12037
|
with: {
|
|
11706
12038
|
resources: true
|
|
11707
12039
|
}
|
|
@@ -11713,7 +12045,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11713
12045
|
position: parentResource.resources?.length || 0
|
|
11714
12046
|
});
|
|
11715
12047
|
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
11716
|
-
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)),
|
|
11717
12049
|
with: {
|
|
11718
12050
|
resource: true
|
|
11719
12051
|
}
|
|
@@ -11727,28 +12059,28 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11727
12059
|
async removeResourceFromResource(options) {
|
|
11728
12060
|
const { childResourceId, parentResourceId } = options;
|
|
11729
12061
|
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
11730
|
-
where: (0,
|
|
12062
|
+
where: (0, import_drizzle_orm36.and)((0, import_drizzle_orm36.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm36.eq)(contentResourceResource.resourceId, childResourceId))
|
|
11731
12063
|
});
|
|
11732
12064
|
const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
|
|
11733
12065
|
if (!parsedResourceJoin.success) {
|
|
11734
12066
|
return null;
|
|
11735
12067
|
}
|
|
11736
|
-
await client.delete(contentResourceResource).where((0,
|
|
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)));
|
|
11737
12069
|
return parsedResourceJoin.data.resource;
|
|
11738
12070
|
},
|
|
11739
12071
|
async updateContentResourceFields(options) {
|
|
11740
12072
|
if (!options.id) {
|
|
11741
12073
|
throw new Error("No content resource id.");
|
|
11742
12074
|
}
|
|
11743
|
-
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]);
|
|
11744
12076
|
await client.update(contentResource).set({
|
|
11745
12077
|
fields: {
|
|
11746
12078
|
...currentResource.fields,
|
|
11747
12079
|
...options.fields
|
|
11748
12080
|
}
|
|
11749
|
-
}).where((0,
|
|
12081
|
+
}).where((0, import_drizzle_orm36.eq)(contentResource.id, options.id));
|
|
11750
12082
|
const resource = await client.query.contentResource.findFirst({
|
|
11751
|
-
where: (0,
|
|
12083
|
+
where: (0, import_drizzle_orm36.eq)(contentResource.id, options.id),
|
|
11752
12084
|
with: {
|
|
11753
12085
|
resources: {
|
|
11754
12086
|
with: {
|
|
@@ -11758,12 +12090,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11758
12090
|
with: {
|
|
11759
12091
|
resource: true
|
|
11760
12092
|
},
|
|
11761
|
-
orderBy: (0,
|
|
12093
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11762
12094
|
}
|
|
11763
12095
|
}
|
|
11764
12096
|
}
|
|
11765
12097
|
},
|
|
11766
|
-
orderBy: (0,
|
|
12098
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11767
12099
|
}
|
|
11768
12100
|
}
|
|
11769
12101
|
});
|
|
@@ -11778,7 +12110,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11778
12110
|
if (!id) {
|
|
11779
12111
|
return null;
|
|
11780
12112
|
}
|
|
11781
|
-
const query =
|
|
12113
|
+
const query = import_drizzle_orm36.sql`
|
|
11782
12114
|
SELECT
|
|
11783
12115
|
id as id,
|
|
11784
12116
|
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
@@ -11810,7 +12142,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11810
12142
|
id
|
|
11811
12143
|
});
|
|
11812
12144
|
const resource = await client.query.contentResource.findFirst({
|
|
11813
|
-
where: (0,
|
|
12145
|
+
where: (0, import_drizzle_orm36.eq)(contentResource.id, id),
|
|
11814
12146
|
with: {
|
|
11815
12147
|
resources: {
|
|
11816
12148
|
with: {
|
|
@@ -11820,12 +12152,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11820
12152
|
with: {
|
|
11821
12153
|
resource: true
|
|
11822
12154
|
},
|
|
11823
|
-
orderBy: (0,
|
|
12155
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11824
12156
|
}
|
|
11825
12157
|
}
|
|
11826
12158
|
}
|
|
11827
12159
|
},
|
|
11828
|
-
orderBy: (0,
|
|
12160
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11829
12161
|
}
|
|
11830
12162
|
}
|
|
11831
12163
|
});
|
|
@@ -11838,7 +12170,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11838
12170
|
},
|
|
11839
12171
|
async getContentResource(data) {
|
|
11840
12172
|
const resource = await client.query.contentResource.findFirst({
|
|
11841
|
-
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}`)),
|
|
11842
12174
|
with: {
|
|
11843
12175
|
resources: {
|
|
11844
12176
|
with: {
|
|
@@ -11856,12 +12188,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11856
12188
|
}
|
|
11857
12189
|
}
|
|
11858
12190
|
},
|
|
11859
|
-
orderBy: (0,
|
|
12191
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11860
12192
|
}
|
|
11861
12193
|
}
|
|
11862
12194
|
}
|
|
11863
12195
|
},
|
|
11864
|
-
orderBy: (0,
|
|
12196
|
+
orderBy: (0, import_drizzle_orm36.asc)(contentResourceResource.position)
|
|
11865
12197
|
}
|
|
11866
12198
|
}
|
|
11867
12199
|
});
|
|
@@ -11879,61 +12211,61 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11879
12211
|
...data,
|
|
11880
12212
|
id
|
|
11881
12213
|
});
|
|
11882
|
-
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]);
|
|
11883
12215
|
} catch (error) {
|
|
11884
12216
|
console.error(error);
|
|
11885
12217
|
throw error;
|
|
11886
12218
|
}
|
|
11887
12219
|
},
|
|
11888
12220
|
async getUser(data) {
|
|
11889
|
-
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;
|
|
11890
12222
|
},
|
|
11891
12223
|
async getUserByEmail(data) {
|
|
11892
|
-
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;
|
|
11893
12225
|
},
|
|
11894
12226
|
async createSession(data) {
|
|
11895
12227
|
await client.insert(sessions).values(data);
|
|
11896
|
-
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]);
|
|
11897
12229
|
},
|
|
11898
12230
|
async getSessionAndUser(data) {
|
|
11899
12231
|
return await client.select({
|
|
11900
12232
|
session: sessions,
|
|
11901
12233
|
user: users
|
|
11902
|
-
}).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;
|
|
11903
12235
|
},
|
|
11904
12236
|
async updateUser(data) {
|
|
11905
12237
|
if (!data.id) {
|
|
11906
12238
|
throw new Error("No user id.");
|
|
11907
12239
|
}
|
|
11908
|
-
await client.update(users).set(data).where((0,
|
|
11909
|
-
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]);
|
|
11910
12242
|
},
|
|
11911
12243
|
async updateSession(data) {
|
|
11912
|
-
await client.update(sessions).set(data).where((0,
|
|
11913
|
-
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]);
|
|
11914
12246
|
},
|
|
11915
12247
|
async linkAccount(rawAccount) {
|
|
11916
12248
|
await client.insert(accounts).values(rawAccount);
|
|
11917
12249
|
},
|
|
11918
12250
|
async getUserByAccount(account) {
|
|
11919
|
-
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;
|
|
11920
12252
|
if (!dbAccount) {
|
|
11921
12253
|
return null;
|
|
11922
12254
|
}
|
|
11923
12255
|
return dbAccount.User;
|
|
11924
12256
|
},
|
|
11925
12257
|
async deleteSession(sessionToken) {
|
|
11926
|
-
const session = await client.select().from(sessions).where((0,
|
|
11927
|
-
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));
|
|
11928
12260
|
return session;
|
|
11929
12261
|
},
|
|
11930
12262
|
async createVerificationToken(token) {
|
|
11931
12263
|
await client.insert(verificationTokens).values(token);
|
|
11932
|
-
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]);
|
|
11933
12265
|
},
|
|
11934
12266
|
async useVerificationToken(token) {
|
|
11935
12267
|
try {
|
|
11936
|
-
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;
|
|
11937
12269
|
if (deletedToken?.createdAt) {
|
|
11938
12270
|
const TIMEOUT_IN_SECONDS = 90;
|
|
11939
12271
|
const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
@@ -11942,7 +12274,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11942
12274
|
const { id: _, ...verificationToken } = token;
|
|
11943
12275
|
return deletedToken;
|
|
11944
12276
|
} else {
|
|
11945
|
-
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)));
|
|
11946
12278
|
return deletedToken;
|
|
11947
12279
|
}
|
|
11948
12280
|
}
|
|
@@ -11952,14 +12284,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core37.mysqlTable, p
|
|
|
11952
12284
|
}
|
|
11953
12285
|
},
|
|
11954
12286
|
async deleteUser(id) {
|
|
11955
|
-
const user = await client.select().from(users).where((0,
|
|
11956
|
-
await client.delete(users).where((0,
|
|
11957
|
-
await client.delete(sessions).where((0,
|
|
11958
|
-
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));
|
|
11959
12291
|
return user;
|
|
11960
12292
|
},
|
|
11961
12293
|
async unlinkAccount(account) {
|
|
11962
|
-
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)));
|
|
11963
12295
|
return void 0;
|
|
11964
12296
|
}
|
|
11965
12297
|
};
|