@coursebuilder/adapter-drizzle 1.0.0 → 1.0.1
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-3WYG5OE7.js → chunk-3GONHHMY.js} +2 -2
- package/dist/{chunk-WFC55BSF.js → chunk-FPAQINSA.js} +2 -2
- package/dist/{chunk-RCL6HPBL.js → chunk-HWIQUI7O.js} +2 -2
- package/dist/{chunk-QGZ2F5SW.js → chunk-LPJ2P2KJ.js} +1162 -1027
- package/dist/{chunk-L5ZAWSTN.js → chunk-MOV5TUON.js} +376 -116
- package/dist/{chunk-GAKWXOAY.js → chunk-OBUGOZKM.js} +2 -2
- package/dist/{chunk-A6XPL665.js → chunk-PBTEHA7F.js} +2 -2
- package/dist/{chunk-5XTOCFDB.js → chunk-YQNIXCD3.js} +2 -2
- package/dist/index.js +9 -10
- package/dist/lib/mysql/index.cjs +1415 -1088
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +218 -0
- package/dist/lib/mysql/index.d.ts +218 -0
- package/dist/lib/mysql/index.js +9 -10
- package/dist/lib/mysql/schemas/auth/accounts.cjs +106 -98
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +2 -2
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +99 -91
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.js +3 -3
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +100 -92
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +3 -3
- package/dist/lib/mysql/schemas/auth/profiles.cjs +254 -0
- package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -0
- package/dist/lib/mysql/schemas/auth/profiles.d.cts +112 -0
- package/dist/lib/mysql/schemas/auth/profiles.d.ts +112 -0
- package/dist/lib/mysql/schemas/auth/profiles.js +20 -0
- package/dist/lib/mysql/schemas/auth/profiles.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs +55 -46
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +3 -3
- package/dist/lib/mysql/schemas/auth/roles.cjs +57 -48
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +2 -2
- package/dist/lib/mysql/schemas/auth/sessions.cjs +96 -88
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +3 -3
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +99 -91
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +104 -96
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +58 -49
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +2 -2
- package/dist/lib/mysql/schemas/auth/users.cjs +295 -259
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +1 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +1 -0
- package/dist/lib/mysql/schemas/auth/users.js +2 -2
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +131 -123
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +96 -88
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +90 -82
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +2 -2
- package/dist/lib/mysql/schemas/commerce/price.cjs +98 -90
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.js +2 -2
- package/dist/lib/mysql/schemas/commerce/product.cjs +125 -117
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.js +2 -2
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +131 -123
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +3 -3
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +184 -176
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.js +2 -2
- package/dist/lib/mysql/schemas/commerce/subscription.cjs +117 -109
- package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/subscription.js +2 -2
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +105 -97
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +3 -3
- package/dist/lib/mysql/schemas/communication/comment.cjs +114 -106
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.js +2 -2
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +136 -128
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +2 -2
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +144 -136
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +99 -91
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +108 -100
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +118 -110
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +121 -113
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource.cjs +198 -190
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +2 -2
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +103 -95
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.js +2 -2
- package/dist/lib/mysql/schemas/content/tag.cjs +116 -108
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.js +2 -2
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +73 -35
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +2 -3
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +88 -38
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.js +2 -2
- package/dist/lib/mysql/schemas/org/organizations.cjs +131 -121
- package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organizations.js +2 -2
- package/package.json +4 -3
- package/src/lib/mysql/index.ts +320 -26
- package/src/lib/mysql/schemas/auth/profiles.ts +50 -0
- package/src/lib/mysql/schemas/auth/roles.ts +6 -1
- package/src/lib/mysql/schemas/auth/users.ts +6 -1
- package/src/lib/mysql/schemas/commerce/subscription.ts +3 -5
- package/src/lib/mysql/schemas/org/organization-membership-roles.ts +7 -0
- package/src/lib/mysql/schemas/org/organization-memberships.ts +6 -0
- package/dist/chunk-RP66NZN3.js +0 -81
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_orm42 = require("drizzle-orm");
|
|
43
|
+
var import_mysql_core47 = 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 json20 = JSON.stringify(obj, null, 2);
|
|
202
|
+
return json20.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(index44) {
|
|
2322
2322
|
return new _ZodObject({
|
|
2323
2323
|
...this._def,
|
|
2324
|
-
catchall:
|
|
2324
|
+
catchall: index44
|
|
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 index44 = 0; index44 < a.length; index44++) {
|
|
2640
|
+
const itemA = a[index44];
|
|
2641
|
+
const itemB = b[index44];
|
|
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], index44) => {
|
|
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, [index44, "key"])),
|
|
2856
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index44, "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 json20 = JSON.stringify(obj, null, 2);
|
|
4050
|
+
return json20.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(index44) {
|
|
6355
6355
|
return new _a18({
|
|
6356
6356
|
...this._def,
|
|
6357
|
-
catchall:
|
|
6357
|
+
catchall: index44
|
|
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 index44 = 0; index44 < a.length; index44++) {
|
|
6700
|
+
const itemA = a[index44];
|
|
6701
|
+
const itemB = b[index44];
|
|
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], index44) => {
|
|
6936
6936
|
return {
|
|
6937
6937
|
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
|
|
6938
|
-
|
|
6938
|
+
index44,
|
|
6939
6939
|
"key"
|
|
6940
6940
|
])),
|
|
6941
6941
|
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
|
|
6942
|
-
|
|
6942
|
+
index44,
|
|
6943
6943
|
"value"
|
|
6944
6944
|
]))
|
|
6945
6945
|
};
|
|
@@ -8080,38 +8080,26 @@ var VideoResourceSchema = z2.object({
|
|
|
8080
8080
|
])
|
|
8081
8081
|
});
|
|
8082
8082
|
|
|
8083
|
-
// ../core/dist/chunk-
|
|
8084
|
-
var
|
|
8085
|
-
id: z2.string().max(255),
|
|
8086
|
-
name: z2.string().max(255).optional().nullable(),
|
|
8087
|
-
role: z2.enum([
|
|
8088
|
-
"user",
|
|
8089
|
-
"admin"
|
|
8090
|
-
]).default("user"),
|
|
8091
|
-
email: z2.string().max(255).email(),
|
|
8092
|
-
emailVerified: z2.coerce.date().nullable(),
|
|
8093
|
-
image: z2.string().max(255).optional().nullable(),
|
|
8094
|
-
createdAt: z2.coerce.date().nullable(),
|
|
8095
|
-
roles: z2.array(z2.object({
|
|
8096
|
-
id: z2.string(),
|
|
8097
|
-
name: z2.string(),
|
|
8098
|
-
description: z2.string().nullable(),
|
|
8099
|
-
active: z2.boolean()
|
|
8100
|
-
})).optional().default([])
|
|
8101
|
-
});
|
|
8102
|
-
|
|
8103
|
-
// ../core/dist/chunk-47RWEDJ6.js
|
|
8104
|
-
var priceSchema = z2.object({
|
|
8083
|
+
// ../core/dist/chunk-LMH5A7OR.js
|
|
8084
|
+
var purchaseUserTransferSchema = z2.object({
|
|
8105
8085
|
id: z2.string().max(191),
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8086
|
+
transferState: z2.enum([
|
|
8087
|
+
"AVAILABLE",
|
|
8088
|
+
"INITIATED",
|
|
8089
|
+
"VERIFIED",
|
|
8090
|
+
"CANCELED",
|
|
8091
|
+
"EXPIRED",
|
|
8092
|
+
"CONFIRMED",
|
|
8093
|
+
"COMPLETED"
|
|
8094
|
+
]).default("AVAILABLE"),
|
|
8095
|
+
purchaseId: z2.string().max(191),
|
|
8096
|
+
sourceUserId: z2.string().max(191),
|
|
8097
|
+
targetUserId: z2.string().max(191).optional().nullable(),
|
|
8113
8098
|
createdAt: z2.date().nullable(),
|
|
8114
|
-
|
|
8099
|
+
expiresAt: z2.date().nullable(),
|
|
8100
|
+
canceledAt: z2.date().nullable(),
|
|
8101
|
+
confirmedAt: z2.date().nullable(),
|
|
8102
|
+
completedAt: z2.date().nullable()
|
|
8115
8103
|
});
|
|
8116
8104
|
|
|
8117
8105
|
// ../core/dist/chunk-SCKAG5RT.js
|
|
@@ -8161,14 +8149,93 @@ var ResourceVisibilitySchema = z2.union([
|
|
|
8161
8149
|
z2.literal("unlisted")
|
|
8162
8150
|
]);
|
|
8163
8151
|
|
|
8164
|
-
// ../core/dist/chunk-
|
|
8152
|
+
// ../core/dist/chunk-PG6VF2O6.js
|
|
8153
|
+
var resourceProgressSchema = z2.object({
|
|
8154
|
+
userId: z2.string().max(191),
|
|
8155
|
+
resourceId: z2.string().max(191).optional().nullable(),
|
|
8156
|
+
completedAt: z2.date().nullable()
|
|
8157
|
+
});
|
|
8158
|
+
var moduleProgressSchema = z2.object({
|
|
8159
|
+
completedLessons: z2.array(resourceProgressSchema),
|
|
8160
|
+
nextResource: ContentResourceSchema.partial().nullable(),
|
|
8161
|
+
percentCompleted: z2.number().default(0),
|
|
8162
|
+
completedLessonsCount: z2.number().default(0),
|
|
8163
|
+
totalLessonsCount: z2.number().default(0)
|
|
8164
|
+
});
|
|
8165
|
+
|
|
8166
|
+
// ../core/dist/chunk-DLQA3JMA.js
|
|
8167
|
+
var upgradableProductSchema = z2.object({
|
|
8168
|
+
upgradableToId: z2.string().max(255),
|
|
8169
|
+
upgradableFromId: z2.string().max(255),
|
|
8170
|
+
position: z2.number().default(0),
|
|
8171
|
+
metadata: z2.record(z2.any()).default({}),
|
|
8172
|
+
createdAt: z2.date().nullable(),
|
|
8173
|
+
updatedAt: z2.date().nullable(),
|
|
8174
|
+
deletedAt: z2.date().nullable()
|
|
8175
|
+
});
|
|
8176
|
+
|
|
8177
|
+
// ../core/dist/chunk-JZBK2DS3.js
|
|
8178
|
+
var userSchema = z2.object({
|
|
8179
|
+
id: z2.string().max(255),
|
|
8180
|
+
name: z2.string().max(255).optional().nullable(),
|
|
8181
|
+
role: z2.enum([
|
|
8182
|
+
"user",
|
|
8183
|
+
"admin"
|
|
8184
|
+
]).default("user"),
|
|
8185
|
+
email: z2.string().max(255).email(),
|
|
8186
|
+
emailVerified: z2.coerce.date().nullish(),
|
|
8187
|
+
image: z2.string().max(255).optional().nullable(),
|
|
8188
|
+
createdAt: z2.coerce.date().nullish(),
|
|
8189
|
+
memberships: z2.array(z2.object({
|
|
8190
|
+
id: z2.string(),
|
|
8191
|
+
organizationId: z2.string()
|
|
8192
|
+
})).nullish().default([]),
|
|
8193
|
+
roles: z2.array(z2.object({
|
|
8194
|
+
id: z2.string(),
|
|
8195
|
+
name: z2.string(),
|
|
8196
|
+
description: z2.string().nullable(),
|
|
8197
|
+
active: z2.boolean(),
|
|
8198
|
+
createdAt: z2.coerce.date().nullish(),
|
|
8199
|
+
updatedAt: z2.coerce.date().nullish(),
|
|
8200
|
+
deletedAt: z2.coerce.date().nullish()
|
|
8201
|
+
})).optional().default([]),
|
|
8202
|
+
organizationRoles: z2.array(z2.object({
|
|
8203
|
+
id: z2.string(),
|
|
8204
|
+
organizationId: z2.string(),
|
|
8205
|
+
name: z2.string(),
|
|
8206
|
+
description: z2.string().nullable(),
|
|
8207
|
+
active: z2.boolean(),
|
|
8208
|
+
createdAt: z2.coerce.date().nullish(),
|
|
8209
|
+
updatedAt: z2.coerce.date().nullish(),
|
|
8210
|
+
deletedAt: z2.coerce.date().nullish()
|
|
8211
|
+
})).optional().default([])
|
|
8212
|
+
});
|
|
8213
|
+
|
|
8214
|
+
// ../core/dist/chunk-M7IDYIVK.js
|
|
8215
|
+
var priceSchema = z2.object({
|
|
8216
|
+
id: z2.string().max(191),
|
|
8217
|
+
productId: z2.string().max(191).optional().nullable(),
|
|
8218
|
+
organizationId: z2.string().max(191).optional().nullable(),
|
|
8219
|
+
nickname: z2.string().max(191).optional().nullable(),
|
|
8220
|
+
status: z2.number().int().default(0),
|
|
8221
|
+
unitAmount: z2.coerce.number().refine((value) => {
|
|
8222
|
+
const decimalPlaces = value.toString().split(".")[1]?.length || 0;
|
|
8223
|
+
return decimalPlaces <= 2;
|
|
8224
|
+
}),
|
|
8225
|
+
createdAt: z2.date().nullable(),
|
|
8226
|
+
fields: z2.record(z2.any()).default({})
|
|
8227
|
+
});
|
|
8228
|
+
|
|
8229
|
+
// ../core/dist/chunk-3PC5DXPZ.js
|
|
8165
8230
|
var productSchema = z2.object({
|
|
8166
8231
|
id: z2.string().max(191),
|
|
8232
|
+
organizationId: z2.string().max(191).optional().nullable(),
|
|
8167
8233
|
name: z2.string().max(191),
|
|
8168
8234
|
key: z2.string().max(191).optional().nullable(),
|
|
8169
8235
|
type: z2.enum([
|
|
8170
8236
|
"live",
|
|
8171
|
-
"self-paced"
|
|
8237
|
+
"self-paced",
|
|
8238
|
+
"membership"
|
|
8172
8239
|
]).default("self-paced"),
|
|
8173
8240
|
fields: z2.object({
|
|
8174
8241
|
body: z2.string().nullable().optional(),
|
|
@@ -8205,7 +8272,7 @@ var NewProductSchema = z2.object({
|
|
|
8205
8272
|
price: z2.coerce.number().gte(0).default(0)
|
|
8206
8273
|
});
|
|
8207
8274
|
|
|
8208
|
-
// ../core/dist/chunk-
|
|
8275
|
+
// ../core/dist/chunk-K4MXE7BY.js
|
|
8209
8276
|
var couponSchema = z2.object({
|
|
8210
8277
|
id: z2.string(),
|
|
8211
8278
|
code: z2.string().max(191).optional().nullable(),
|
|
@@ -8224,10 +8291,11 @@ var couponSchema = z2.object({
|
|
|
8224
8291
|
restrictedToProductId: z2.string().max(191).optional().nullable(),
|
|
8225
8292
|
bulkPurchases: z2.array(z2.any()).default([]),
|
|
8226
8293
|
redeemedBulkCouponPurchases: z2.array(z2.any()).default([]),
|
|
8227
|
-
bulkPurchaseId: z2.string().max(191).optional().nullable()
|
|
8294
|
+
bulkPurchaseId: z2.string().max(191).optional().nullable(),
|
|
8295
|
+
organizationId: z2.string().max(191).optional().nullable()
|
|
8228
8296
|
});
|
|
8229
8297
|
|
|
8230
|
-
// ../core/dist/chunk-
|
|
8298
|
+
// ../core/dist/chunk-FH7M67MM.js
|
|
8231
8299
|
var purchaseSchema = z2.object({
|
|
8232
8300
|
id: z2.string().max(191),
|
|
8233
8301
|
userId: z2.string().max(191).optional().nullable(),
|
|
@@ -8251,54 +8319,21 @@ var purchaseSchema = z2.object({
|
|
|
8251
8319
|
fields: z2.record(z2.any()).default({}),
|
|
8252
8320
|
user: userSchema.optional().nullable(),
|
|
8253
8321
|
bulkCoupon: couponSchema.optional().nullable(),
|
|
8254
|
-
product: productSchema.optional().nullable()
|
|
8322
|
+
product: productSchema.optional().nullable(),
|
|
8323
|
+
purchasedByorganizationMembershipId: z2.string().max(191).optional().nullable(),
|
|
8324
|
+
organizationId: z2.string().max(191).optional().nullable()
|
|
8255
8325
|
});
|
|
8256
8326
|
|
|
8257
|
-
// ../core/dist/chunk-
|
|
8258
|
-
var
|
|
8327
|
+
// ../core/dist/chunk-SGE7BCRS.js
|
|
8328
|
+
var merchantChargeSchema = z2.object({
|
|
8259
8329
|
id: z2.string().max(191),
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
"INITIATED",
|
|
8263
|
-
"VERIFIED",
|
|
8264
|
-
"CANCELED",
|
|
8265
|
-
"EXPIRED",
|
|
8266
|
-
"CONFIRMED",
|
|
8267
|
-
"COMPLETED"
|
|
8268
|
-
]).default("AVAILABLE"),
|
|
8269
|
-
purchaseId: z2.string().max(191),
|
|
8270
|
-
sourceUserId: z2.string().max(191),
|
|
8271
|
-
targetUserId: z2.string().max(191).optional().nullable(),
|
|
8272
|
-
createdAt: z2.date().nullable(),
|
|
8273
|
-
expiresAt: z2.date().nullable(),
|
|
8274
|
-
canceledAt: z2.date().nullable(),
|
|
8275
|
-
confirmedAt: z2.date().nullable(),
|
|
8276
|
-
completedAt: z2.date().nullable()
|
|
8277
|
-
});
|
|
8278
|
-
|
|
8279
|
-
// ../core/dist/chunk-PG6VF2O6.js
|
|
8280
|
-
var resourceProgressSchema = z2.object({
|
|
8330
|
+
status: z2.number().int().default(0),
|
|
8331
|
+
identifier: z2.string().max(191),
|
|
8281
8332
|
userId: z2.string().max(191),
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
});
|
|
8285
|
-
var moduleProgressSchema = z2.object({
|
|
8286
|
-
completedLessons: z2.array(resourceProgressSchema),
|
|
8287
|
-
nextResource: ContentResourceSchema.partial().nullable(),
|
|
8288
|
-
percentCompleted: z2.number().default(0),
|
|
8289
|
-
completedLessonsCount: z2.number().default(0),
|
|
8290
|
-
totalLessonsCount: z2.number().default(0)
|
|
8291
|
-
});
|
|
8292
|
-
|
|
8293
|
-
// ../core/dist/chunk-DLQA3JMA.js
|
|
8294
|
-
var upgradableProductSchema = z2.object({
|
|
8295
|
-
upgradableToId: z2.string().max(255),
|
|
8296
|
-
upgradableFromId: z2.string().max(255),
|
|
8297
|
-
position: z2.number().default(0),
|
|
8298
|
-
metadata: z2.record(z2.any()).default({}),
|
|
8333
|
+
merchantAccountId: z2.string().max(191),
|
|
8334
|
+
merchantProductId: z2.string().max(191),
|
|
8299
8335
|
createdAt: z2.date().nullable(),
|
|
8300
|
-
|
|
8301
|
-
deletedAt: z2.date().nullable()
|
|
8336
|
+
merchantCustomerId: z2.string().max(191)
|
|
8302
8337
|
});
|
|
8303
8338
|
|
|
8304
8339
|
// ../core/dist/chunk-EDDT2FFU.js
|
|
@@ -8332,18 +8367,6 @@ var merchantProductSchema = z2.object({
|
|
|
8332
8367
|
createdAt: z2.date().nullable()
|
|
8333
8368
|
});
|
|
8334
8369
|
|
|
8335
|
-
// ../core/dist/chunk-SGE7BCRS.js
|
|
8336
|
-
var merchantChargeSchema = z2.object({
|
|
8337
|
-
id: z2.string().max(191),
|
|
8338
|
-
status: z2.number().int().default(0),
|
|
8339
|
-
identifier: z2.string().max(191),
|
|
8340
|
-
userId: z2.string().max(191),
|
|
8341
|
-
merchantAccountId: z2.string().max(191),
|
|
8342
|
-
merchantProductId: z2.string().max(191),
|
|
8343
|
-
createdAt: z2.date().nullable(),
|
|
8344
|
-
merchantCustomerId: z2.string().max(191)
|
|
8345
|
-
});
|
|
8346
|
-
|
|
8347
8370
|
// ../core/dist/chunk-256SROW3.js
|
|
8348
8371
|
var merchantCouponSchema = z2.object({
|
|
8349
8372
|
id: z2.string().max(191),
|
|
@@ -8366,6 +8389,71 @@ var merchantAccountSchema = z2.object({
|
|
|
8366
8389
|
status: z2.number().int().default(0)
|
|
8367
8390
|
});
|
|
8368
8391
|
|
|
8392
|
+
// ../core/dist/schemas/merchant-session.js
|
|
8393
|
+
var MerchantSessionSchema = z2.object({
|
|
8394
|
+
id: z2.string(),
|
|
8395
|
+
organizationId: z2.string().nullable(),
|
|
8396
|
+
identifier: z2.string(),
|
|
8397
|
+
merchantAccountId: z2.string()
|
|
8398
|
+
});
|
|
8399
|
+
|
|
8400
|
+
// ../core/dist/chunk-NCUZHHRE.js
|
|
8401
|
+
var MerchantSubscriptionSchema = z2.object({
|
|
8402
|
+
id: z2.string(),
|
|
8403
|
+
organizationId: z2.string().nullable(),
|
|
8404
|
+
merchantAccountId: z2.string(),
|
|
8405
|
+
status: z2.number().default(0),
|
|
8406
|
+
createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
|
|
8407
|
+
label: z2.string().nullable(),
|
|
8408
|
+
identifier: z2.string().nullable(),
|
|
8409
|
+
merchantCustomerId: z2.string(),
|
|
8410
|
+
merchantProductId: z2.string()
|
|
8411
|
+
});
|
|
8412
|
+
|
|
8413
|
+
// ../core/dist/chunk-KQ3HQRWM.js
|
|
8414
|
+
var OrganizationSchema = z2.object({
|
|
8415
|
+
id: z2.string(),
|
|
8416
|
+
name: z2.string().nullable(),
|
|
8417
|
+
fields: z2.record(z2.any()).default({}),
|
|
8418
|
+
image: z2.string().nullable(),
|
|
8419
|
+
createdAt: z2.date()
|
|
8420
|
+
});
|
|
8421
|
+
|
|
8422
|
+
// ../core/dist/schemas/organization-member.js
|
|
8423
|
+
var OrganizationMemberSchema = z2.object({
|
|
8424
|
+
id: z2.string(),
|
|
8425
|
+
organizationId: z2.string().optional(),
|
|
8426
|
+
role: z2.string().default("user"),
|
|
8427
|
+
invitedById: z2.string(),
|
|
8428
|
+
userId: z2.string(),
|
|
8429
|
+
fields: z2.record(z2.any()).default({}),
|
|
8430
|
+
createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
|
|
8431
|
+
organization: OrganizationSchema,
|
|
8432
|
+
user: userSchema
|
|
8433
|
+
});
|
|
8434
|
+
|
|
8435
|
+
// ../core/dist/schemas/subscription.js
|
|
8436
|
+
var SubscriptionSchema = z2.object({
|
|
8437
|
+
id: z2.string(),
|
|
8438
|
+
organizationId: z2.string().optional(),
|
|
8439
|
+
productId: z2.string(),
|
|
8440
|
+
createdAt: z2.date(),
|
|
8441
|
+
merchantSubscriptionId: z2.string(),
|
|
8442
|
+
status: z2.enum([
|
|
8443
|
+
"incomplete",
|
|
8444
|
+
"incomplete_expired",
|
|
8445
|
+
"trialing",
|
|
8446
|
+
"active",
|
|
8447
|
+
"past_due",
|
|
8448
|
+
"canceled",
|
|
8449
|
+
"unpaid",
|
|
8450
|
+
"paused"
|
|
8451
|
+
]).default("active"),
|
|
8452
|
+
fields: z2.record(z2.any()).default({}),
|
|
8453
|
+
product: productSchema,
|
|
8454
|
+
merchantSubscription: MerchantSubscriptionSchema.optional()
|
|
8455
|
+
});
|
|
8456
|
+
|
|
8369
8457
|
// ../core/dist/chunk-F32UWPXN.js
|
|
8370
8458
|
var _a41;
|
|
8371
8459
|
var _CourseBuilderError = (_a41 = class extends Error {
|
|
@@ -8496,149 +8584,268 @@ var validateCoupon = /* @__PURE__ */ __name2((coupon, productIds = []) => {
|
|
|
8496
8584
|
}, "validateCoupon");
|
|
8497
8585
|
|
|
8498
8586
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
8499
|
-
var
|
|
8500
|
-
var
|
|
8587
|
+
var import_drizzle_orm33 = require("drizzle-orm");
|
|
8588
|
+
var import_mysql_core37 = require("drizzle-orm/mysql-core");
|
|
8501
8589
|
|
|
8502
8590
|
// src/lib/mysql/schemas/auth/users.ts
|
|
8503
|
-
var
|
|
8504
|
-
var
|
|
8591
|
+
var import_drizzle_orm32 = require("drizzle-orm");
|
|
8592
|
+
var import_mysql_core36 = require("drizzle-orm/mysql-core");
|
|
8505
8593
|
|
|
8506
8594
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
8507
|
-
var
|
|
8508
|
-
var
|
|
8595
|
+
var import_drizzle_orm25 = require("drizzle-orm");
|
|
8596
|
+
var import_mysql_core27 = require("drizzle-orm/mysql-core");
|
|
8509
8597
|
|
|
8510
8598
|
// src/lib/mysql/schemas/org/organization-memberships.ts
|
|
8511
|
-
var
|
|
8512
|
-
var
|
|
8513
|
-
|
|
8514
|
-
// src/lib/mysql/schemas/org/organizations.ts
|
|
8515
|
-
var import_drizzle_orm19 = require("drizzle-orm");
|
|
8516
|
-
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
8517
|
-
|
|
8518
|
-
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
8519
|
-
var import_drizzle_orm18 = require("drizzle-orm");
|
|
8520
|
-
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
8599
|
+
var import_drizzle_orm23 = require("drizzle-orm");
|
|
8600
|
+
var import_mysql_core23 = require("drizzle-orm/mysql-core");
|
|
8521
8601
|
|
|
8522
|
-
// src/lib/mysql/schemas/
|
|
8523
|
-
var
|
|
8524
|
-
var
|
|
8602
|
+
// src/lib/mysql/schemas/org/organization-membership-roles.ts
|
|
8603
|
+
var import_drizzle_orm22 = require("drizzle-orm");
|
|
8604
|
+
var import_mysql_core22 = require("drizzle-orm/mysql-core");
|
|
8525
8605
|
|
|
8526
|
-
// src/lib/mysql/schemas/
|
|
8527
|
-
var
|
|
8528
|
-
var
|
|
8606
|
+
// src/lib/mysql/schemas/auth/roles.ts
|
|
8607
|
+
var import_drizzle_orm2 = require("drizzle-orm");
|
|
8608
|
+
var import_mysql_core2 = require("drizzle-orm/mysql-core");
|
|
8529
8609
|
|
|
8530
|
-
// src/lib/mysql/schemas/
|
|
8610
|
+
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
8531
8611
|
var import_drizzle_orm = require("drizzle-orm");
|
|
8532
8612
|
var import_mysql_core = require("drizzle-orm/mysql-core");
|
|
8533
|
-
function
|
|
8534
|
-
return mysqlTable("
|
|
8535
|
-
|
|
8536
|
-
length:
|
|
8613
|
+
function getUserRolesSchema(mysqlTable) {
|
|
8614
|
+
return mysqlTable("UserRole", {
|
|
8615
|
+
userId: (0, import_mysql_core.varchar)("userId", {
|
|
8616
|
+
length: 255
|
|
8617
|
+
}).notNull(),
|
|
8618
|
+
roleId: (0, import_mysql_core.varchar)("roleId", {
|
|
8619
|
+
length: 255
|
|
8537
8620
|
}).notNull(),
|
|
8621
|
+
active: (0, import_mysql_core.boolean)("active").notNull().default(true),
|
|
8538
8622
|
organizationId: (0, import_mysql_core.varchar)("organizationId", {
|
|
8539
8623
|
length: 191
|
|
8540
8624
|
}),
|
|
8541
|
-
status: (0, import_mysql_core.int)("status").default(0).notNull(),
|
|
8542
8625
|
createdAt: (0, import_mysql_core.timestamp)("createdAt", {
|
|
8543
8626
|
mode: "date",
|
|
8544
8627
|
fsp: 3
|
|
8545
|
-
}).
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8628
|
+
}).defaultNow(),
|
|
8629
|
+
updatedAt: (0, import_mysql_core.timestamp)("updatedAt", {
|
|
8630
|
+
mode: "date",
|
|
8631
|
+
fsp: 3
|
|
8632
|
+
}).defaultNow(),
|
|
8633
|
+
deletedAt: (0, import_mysql_core.timestamp)("deletedAt", {
|
|
8634
|
+
mode: "date",
|
|
8635
|
+
fsp: 3
|
|
8551
8636
|
})
|
|
8552
|
-
}, (
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
});
|
|
8563
|
-
}
|
|
8564
|
-
__name(
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8637
|
+
}, (ur) => ({
|
|
8638
|
+
pk: (0, import_mysql_core.primaryKey)({
|
|
8639
|
+
columns: [
|
|
8640
|
+
ur.userId,
|
|
8641
|
+
ur.roleId
|
|
8642
|
+
]
|
|
8643
|
+
}),
|
|
8644
|
+
userIdIdx: (0, import_mysql_core.index)("userId_idx").on(ur.userId),
|
|
8645
|
+
roleIdIdx: (0, import_mysql_core.index)("roleId_idx").on(ur.roleId),
|
|
8646
|
+
organizationIdIdx: (0, import_mysql_core.index)("organizationId_idx").on(ur.organizationId)
|
|
8647
|
+
}));
|
|
8648
|
+
}
|
|
8649
|
+
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
8650
|
+
function getUserRolesRelationsSchema(mysqlTable) {
|
|
8651
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
8652
|
+
const users = getUsersSchema(mysqlTable);
|
|
8653
|
+
const roles = getRolesSchema(mysqlTable);
|
|
8654
|
+
return (0, import_drizzle_orm.relations)(userRoles, ({ one }) => ({
|
|
8655
|
+
user: one(users, {
|
|
8656
|
+
fields: [
|
|
8657
|
+
userRoles.userId
|
|
8658
|
+
],
|
|
8659
|
+
references: [
|
|
8660
|
+
users.id
|
|
8661
|
+
],
|
|
8662
|
+
relationName: "user"
|
|
8663
|
+
}),
|
|
8664
|
+
role: one(roles, {
|
|
8665
|
+
fields: [
|
|
8666
|
+
userRoles.roleId
|
|
8667
|
+
],
|
|
8668
|
+
references: [
|
|
8669
|
+
roles.id
|
|
8670
|
+
],
|
|
8671
|
+
relationName: "role"
|
|
8672
|
+
})
|
|
8673
|
+
}));
|
|
8674
|
+
}
|
|
8675
|
+
__name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
8676
|
+
|
|
8677
|
+
// src/lib/mysql/schemas/auth/roles.ts
|
|
8678
|
+
function getRolesSchema(mysqlTable) {
|
|
8679
|
+
return mysqlTable("Role", {
|
|
8680
|
+
id: (0, import_mysql_core2.varchar)("id", {
|
|
8681
|
+
length: 255
|
|
8682
|
+
}).notNull().primaryKey(),
|
|
8683
|
+
organizationId: (0, import_mysql_core2.varchar)("organizationId", {
|
|
8684
|
+
length: 191
|
|
8685
|
+
}),
|
|
8686
|
+
name: (0, import_mysql_core2.varchar)("name", {
|
|
8687
|
+
length: 255
|
|
8688
|
+
}).notNull(),
|
|
8689
|
+
description: (0, import_mysql_core2.text)("description"),
|
|
8690
|
+
active: (0, import_mysql_core2.boolean)("active").notNull().default(true),
|
|
8691
|
+
createdAt: (0, import_mysql_core2.timestamp)("createdAt", {
|
|
8692
|
+
mode: "date",
|
|
8693
|
+
fsp: 3
|
|
8694
|
+
}).defaultNow(),
|
|
8695
|
+
updatedAt: (0, import_mysql_core2.timestamp)("updatedAt", {
|
|
8696
|
+
mode: "date",
|
|
8697
|
+
fsp: 3
|
|
8698
|
+
}).defaultNow(),
|
|
8699
|
+
deletedAt: (0, import_mysql_core2.timestamp)("deletedAt", {
|
|
8700
|
+
mode: "date",
|
|
8701
|
+
fsp: 3
|
|
8702
|
+
})
|
|
8703
|
+
}, (role) => ({
|
|
8704
|
+
nameIdx: (0, import_mysql_core2.index)("name_idx").on(role.name),
|
|
8705
|
+
organizationIdIdx: (0, import_mysql_core2.index)("organizationId_idx").on(role.organizationId),
|
|
8706
|
+
uniqueNamePerOrg: (0, import_mysql_core2.uniqueIndex)("unique_name_per_org").on(role.organizationId, role.name)
|
|
8707
|
+
}));
|
|
8708
|
+
}
|
|
8709
|
+
__name(getRolesSchema, "getRolesSchema");
|
|
8710
|
+
function getRolesRelationsSchema(mysqlTable) {
|
|
8711
|
+
const roles = getRolesSchema(mysqlTable);
|
|
8712
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
8713
|
+
return (0, import_drizzle_orm2.relations)(roles, ({ many }) => ({
|
|
8714
|
+
userRoles: many(userRoles, {
|
|
8715
|
+
relationName: "role"
|
|
8716
|
+
})
|
|
8717
|
+
}));
|
|
8718
|
+
}
|
|
8719
|
+
__name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
8720
|
+
|
|
8721
|
+
// src/lib/mysql/schemas/org/organizations.ts
|
|
8722
|
+
var import_drizzle_orm21 = require("drizzle-orm");
|
|
8723
|
+
var import_mysql_core21 = require("drizzle-orm/mysql-core");
|
|
8724
|
+
|
|
8725
|
+
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
8726
|
+
var import_drizzle_orm20 = require("drizzle-orm");
|
|
8727
|
+
var import_mysql_core20 = require("drizzle-orm/mysql-core");
|
|
8728
|
+
|
|
8729
|
+
// src/lib/mysql/schemas/commerce/merchant-subscription.ts
|
|
8730
|
+
var import_drizzle_orm7 = require("drizzle-orm");
|
|
8731
|
+
var import_mysql_core7 = require("drizzle-orm/mysql-core");
|
|
8732
|
+
|
|
8733
|
+
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
8734
|
+
var import_drizzle_orm6 = require("drizzle-orm");
|
|
8735
|
+
var import_mysql_core6 = require("drizzle-orm/mysql-core");
|
|
8736
|
+
|
|
8737
|
+
// src/lib/mysql/schemas/commerce/merchant-account.ts
|
|
8738
|
+
var import_drizzle_orm3 = require("drizzle-orm");
|
|
8739
|
+
var import_mysql_core3 = require("drizzle-orm/mysql-core");
|
|
8740
|
+
function getMerchantAccountSchema(mysqlTable) {
|
|
8741
|
+
return mysqlTable("MerchantAccount", {
|
|
8742
|
+
id: (0, import_mysql_core3.varchar)("id", {
|
|
8743
|
+
length: 191
|
|
8744
|
+
}).notNull(),
|
|
8745
|
+
organizationId: (0, import_mysql_core3.varchar)("organizationId", {
|
|
8746
|
+
length: 191
|
|
8747
|
+
}),
|
|
8748
|
+
status: (0, import_mysql_core3.int)("status").default(0).notNull(),
|
|
8749
|
+
createdAt: (0, import_mysql_core3.timestamp)("createdAt", {
|
|
8750
|
+
mode: "date",
|
|
8751
|
+
fsp: 3
|
|
8752
|
+
}).default(import_drizzle_orm3.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8753
|
+
label: (0, import_mysql_core3.varchar)("label", {
|
|
8754
|
+
length: 191
|
|
8755
|
+
}),
|
|
8756
|
+
identifier: (0, import_mysql_core3.varchar)("identifier", {
|
|
8757
|
+
length: 191
|
|
8758
|
+
})
|
|
8759
|
+
}, (table) => {
|
|
8760
|
+
return {
|
|
8761
|
+
merchantAccountId: (0, import_mysql_core3.primaryKey)({
|
|
8762
|
+
columns: [
|
|
8763
|
+
table.id
|
|
8764
|
+
],
|
|
8765
|
+
name: "MerchantAccount_id"
|
|
8766
|
+
}),
|
|
8767
|
+
organizationIdIdx: (0, import_mysql_core3.index)("organizationId_idx").on(table.organizationId)
|
|
8768
|
+
};
|
|
8769
|
+
});
|
|
8770
|
+
}
|
|
8771
|
+
__name(getMerchantAccountSchema, "getMerchantAccountSchema");
|
|
8772
|
+
|
|
8773
|
+
// src/lib/mysql/schemas/commerce/merchant-customer.ts
|
|
8774
|
+
var import_drizzle_orm4 = require("drizzle-orm");
|
|
8775
|
+
var import_mysql_core4 = require("drizzle-orm/mysql-core");
|
|
8569
8776
|
function getMerchantCustomerSchema(mysqlTable) {
|
|
8570
8777
|
return mysqlTable("MerchantCustomer", {
|
|
8571
|
-
id: (0,
|
|
8778
|
+
id: (0, import_mysql_core4.varchar)("id", {
|
|
8572
8779
|
length: 191
|
|
8573
8780
|
}).notNull(),
|
|
8574
|
-
organizationId: (0,
|
|
8781
|
+
organizationId: (0, import_mysql_core4.varchar)("organizationId", {
|
|
8575
8782
|
length: 191
|
|
8576
8783
|
}),
|
|
8577
|
-
userId: (0,
|
|
8784
|
+
userId: (0, import_mysql_core4.varchar)("userId", {
|
|
8578
8785
|
length: 191
|
|
8579
8786
|
}).notNull(),
|
|
8580
|
-
merchantAccountId: (0,
|
|
8787
|
+
merchantAccountId: (0, import_mysql_core4.varchar)("merchantAccountId", {
|
|
8581
8788
|
length: 191
|
|
8582
8789
|
}).notNull(),
|
|
8583
|
-
identifier: (0,
|
|
8790
|
+
identifier: (0, import_mysql_core4.varchar)("identifier", {
|
|
8584
8791
|
length: 191
|
|
8585
8792
|
}).notNull(),
|
|
8586
|
-
createdAt: (0,
|
|
8793
|
+
createdAt: (0, import_mysql_core4.timestamp)("createdAt", {
|
|
8587
8794
|
mode: "date",
|
|
8588
8795
|
fsp: 3
|
|
8589
|
-
}).default(
|
|
8590
|
-
status: (0,
|
|
8796
|
+
}).default(import_drizzle_orm4.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8797
|
+
status: (0, import_mysql_core4.int)("status").default(0)
|
|
8591
8798
|
}, (table) => {
|
|
8592
8799
|
return {
|
|
8593
|
-
merchantCustomerId: (0,
|
|
8800
|
+
merchantCustomerId: (0, import_mysql_core4.primaryKey)({
|
|
8594
8801
|
columns: [
|
|
8595
8802
|
table.id
|
|
8596
8803
|
],
|
|
8597
8804
|
name: "MerchantCustomer_id"
|
|
8598
8805
|
}),
|
|
8599
|
-
merchantCustomerIdentifierKey: (0,
|
|
8600
|
-
userIdIdx: (0,
|
|
8601
|
-
organizationIdIdx: (0,
|
|
8806
|
+
merchantCustomerIdentifierKey: (0, import_mysql_core4.unique)("MerchantCustomer_identifier_key").on(table.identifier),
|
|
8807
|
+
userIdIdx: (0, import_mysql_core4.index)("idx_MerchantCustomer_on_userId").on(table.userId),
|
|
8808
|
+
organizationIdIdx: (0, import_mysql_core4.index)("organizationId_idx").on(table.organizationId)
|
|
8602
8809
|
};
|
|
8603
8810
|
});
|
|
8604
8811
|
}
|
|
8605
8812
|
__name(getMerchantCustomerSchema, "getMerchantCustomerSchema");
|
|
8606
8813
|
|
|
8607
8814
|
// src/lib/mysql/schemas/commerce/merchant-product.ts
|
|
8608
|
-
var
|
|
8609
|
-
var
|
|
8815
|
+
var import_drizzle_orm5 = require("drizzle-orm");
|
|
8816
|
+
var import_mysql_core5 = require("drizzle-orm/mysql-core");
|
|
8610
8817
|
function getMerchantProductSchema(mysqlTable) {
|
|
8611
8818
|
return mysqlTable("MerchantProduct", {
|
|
8612
|
-
id: (0,
|
|
8819
|
+
id: (0, import_mysql_core5.varchar)("id", {
|
|
8613
8820
|
length: 191
|
|
8614
8821
|
}).notNull(),
|
|
8615
|
-
organizationId: (0,
|
|
8822
|
+
organizationId: (0, import_mysql_core5.varchar)("organizationId", {
|
|
8616
8823
|
length: 191
|
|
8617
8824
|
}),
|
|
8618
|
-
merchantAccountId: (0,
|
|
8825
|
+
merchantAccountId: (0, import_mysql_core5.varchar)("merchantAccountId", {
|
|
8619
8826
|
length: 191
|
|
8620
8827
|
}).notNull(),
|
|
8621
|
-
productId: (0,
|
|
8828
|
+
productId: (0, import_mysql_core5.varchar)("productId", {
|
|
8622
8829
|
length: 191
|
|
8623
8830
|
}).notNull(),
|
|
8624
|
-
status: (0,
|
|
8625
|
-
identifier: (0,
|
|
8831
|
+
status: (0, import_mysql_core5.int)("status").default(0).notNull(),
|
|
8832
|
+
identifier: (0, import_mysql_core5.varchar)("identifier", {
|
|
8626
8833
|
length: 191
|
|
8627
8834
|
}),
|
|
8628
|
-
createdAt: (0,
|
|
8835
|
+
createdAt: (0, import_mysql_core5.timestamp)("createdAt", {
|
|
8629
8836
|
mode: "date",
|
|
8630
8837
|
fsp: 3
|
|
8631
|
-
}).default(
|
|
8838
|
+
}).default(import_drizzle_orm5.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
8632
8839
|
}, (table) => {
|
|
8633
8840
|
return {
|
|
8634
|
-
merchantProductId: (0,
|
|
8841
|
+
merchantProductId: (0, import_mysql_core5.primaryKey)({
|
|
8635
8842
|
columns: [
|
|
8636
8843
|
table.id
|
|
8637
8844
|
],
|
|
8638
8845
|
name: "MerchantProduct_id"
|
|
8639
8846
|
}),
|
|
8640
|
-
merchantProductIdentifierKey: (0,
|
|
8641
|
-
organizationIdIdx: (0,
|
|
8847
|
+
merchantProductIdentifierKey: (0, import_mysql_core5.unique)("MerchantProduct_identifier_key").on(table.identifier),
|
|
8848
|
+
organizationIdIdx: (0, import_mysql_core5.index)("organizationId_idx").on(table.organizationId)
|
|
8642
8849
|
};
|
|
8643
8850
|
});
|
|
8644
8851
|
}
|
|
@@ -8647,46 +8854,46 @@ __name(getMerchantProductSchema, "getMerchantProductSchema");
|
|
|
8647
8854
|
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
8648
8855
|
function getMerchantChargeSchema(mysqlTable) {
|
|
8649
8856
|
return mysqlTable("MerchantCharge", {
|
|
8650
|
-
id: (0,
|
|
8857
|
+
id: (0, import_mysql_core6.varchar)("id", {
|
|
8651
8858
|
length: 191
|
|
8652
8859
|
}).notNull(),
|
|
8653
|
-
organizationId: (0,
|
|
8860
|
+
organizationId: (0, import_mysql_core6.varchar)("organizationId", {
|
|
8654
8861
|
length: 191
|
|
8655
8862
|
}),
|
|
8656
|
-
status: (0,
|
|
8657
|
-
identifier: (0,
|
|
8863
|
+
status: (0, import_mysql_core6.int)("status").default(0).notNull(),
|
|
8864
|
+
identifier: (0, import_mysql_core6.varchar)("identifier", {
|
|
8658
8865
|
length: 191
|
|
8659
8866
|
}).notNull(),
|
|
8660
|
-
userId: (0,
|
|
8867
|
+
userId: (0, import_mysql_core6.varchar)("userId", {
|
|
8661
8868
|
length: 191
|
|
8662
8869
|
}).notNull(),
|
|
8663
|
-
merchantAccountId: (0,
|
|
8870
|
+
merchantAccountId: (0, import_mysql_core6.varchar)("merchantAccountId", {
|
|
8664
8871
|
length: 191
|
|
8665
8872
|
}).notNull(),
|
|
8666
|
-
merchantProductId: (0,
|
|
8873
|
+
merchantProductId: (0, import_mysql_core6.varchar)("merchantProductId", {
|
|
8667
8874
|
length: 191
|
|
8668
8875
|
}).notNull(),
|
|
8669
|
-
merchantSubscriptionId: (0,
|
|
8876
|
+
merchantSubscriptionId: (0, import_mysql_core6.varchar)("merchantSubscriptionId", {
|
|
8670
8877
|
length: 191
|
|
8671
8878
|
}),
|
|
8672
|
-
createdAt: (0,
|
|
8879
|
+
createdAt: (0, import_mysql_core6.timestamp)("createdAt", {
|
|
8673
8880
|
mode: "date",
|
|
8674
8881
|
fsp: 3
|
|
8675
|
-
}).default(
|
|
8676
|
-
merchantCustomerId: (0,
|
|
8882
|
+
}).default(import_drizzle_orm6.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8883
|
+
merchantCustomerId: (0, import_mysql_core6.varchar)("merchantCustomerId", {
|
|
8677
8884
|
length: 191
|
|
8678
8885
|
}).notNull()
|
|
8679
8886
|
}, (table) => {
|
|
8680
8887
|
return {
|
|
8681
|
-
merchantChargeId: (0,
|
|
8888
|
+
merchantChargeId: (0, import_mysql_core6.primaryKey)({
|
|
8682
8889
|
columns: [
|
|
8683
8890
|
table.id
|
|
8684
8891
|
],
|
|
8685
8892
|
name: "MerchantCharge_id"
|
|
8686
8893
|
}),
|
|
8687
|
-
merchantChargeIdentifierKey: (0,
|
|
8688
|
-
merchantSubscriptionIdIdx: (0,
|
|
8689
|
-
organizationIdIdx: (0,
|
|
8894
|
+
merchantChargeIdentifierKey: (0, import_mysql_core6.unique)("MerchantCharge_identifier_key").on(table.identifier),
|
|
8895
|
+
merchantSubscriptionIdIdx: (0, import_mysql_core6.index)("merchantSubscriptionId_idx").on(table.merchantSubscriptionId),
|
|
8896
|
+
organizationIdIdx: (0, import_mysql_core6.index)("organizationId_idx").on(table.organizationId)
|
|
8690
8897
|
};
|
|
8691
8898
|
});
|
|
8692
8899
|
}
|
|
@@ -8697,7 +8904,7 @@ function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
|
8697
8904
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
8698
8905
|
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
8699
8906
|
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
|
|
8700
|
-
return (0,
|
|
8907
|
+
return (0, import_drizzle_orm6.relations)(merchantCharge, ({ one }) => ({
|
|
8701
8908
|
merchantAccount: one(merchantAccount, {
|
|
8702
8909
|
fields: [
|
|
8703
8910
|
merchantCharge.merchantAccountId
|
|
@@ -8741,41 +8948,41 @@ __name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
|
8741
8948
|
// src/lib/mysql/schemas/commerce/merchant-subscription.ts
|
|
8742
8949
|
function getMerchantSubscriptionSchema(mysqlTable) {
|
|
8743
8950
|
return mysqlTable("MerchantSubscription", {
|
|
8744
|
-
id: (0,
|
|
8951
|
+
id: (0, import_mysql_core7.varchar)("id", {
|
|
8745
8952
|
length: 191
|
|
8746
8953
|
}).notNull(),
|
|
8747
|
-
organizationId: (0,
|
|
8954
|
+
organizationId: (0, import_mysql_core7.varchar)("organizationId", {
|
|
8748
8955
|
length: 191
|
|
8749
8956
|
}),
|
|
8750
|
-
merchantAccountId: (0,
|
|
8957
|
+
merchantAccountId: (0, import_mysql_core7.varchar)("merchantAccountId", {
|
|
8751
8958
|
length: 191
|
|
8752
8959
|
}).notNull(),
|
|
8753
|
-
status: (0,
|
|
8754
|
-
createdAt: (0,
|
|
8960
|
+
status: (0, import_mysql_core7.int)("status").default(0).notNull(),
|
|
8961
|
+
createdAt: (0, import_mysql_core7.timestamp)("createdAt", {
|
|
8755
8962
|
mode: "date",
|
|
8756
8963
|
fsp: 3
|
|
8757
|
-
}).default(
|
|
8758
|
-
label: (0,
|
|
8964
|
+
}).default(import_drizzle_orm7.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
8965
|
+
label: (0, import_mysql_core7.varchar)("label", {
|
|
8759
8966
|
length: 191
|
|
8760
8967
|
}),
|
|
8761
|
-
identifier: (0,
|
|
8968
|
+
identifier: (0, import_mysql_core7.varchar)("identifier", {
|
|
8762
8969
|
length: 191
|
|
8763
8970
|
}),
|
|
8764
|
-
merchantCustomerId: (0,
|
|
8971
|
+
merchantCustomerId: (0, import_mysql_core7.varchar)("merchantCustomerId", {
|
|
8765
8972
|
length: 191
|
|
8766
8973
|
}).notNull(),
|
|
8767
|
-
merchantProductId: (0,
|
|
8974
|
+
merchantProductId: (0, import_mysql_core7.varchar)("merchantProductId", {
|
|
8768
8975
|
length: 191
|
|
8769
8976
|
}).notNull()
|
|
8770
8977
|
}, (table) => {
|
|
8771
8978
|
return {
|
|
8772
|
-
merchantSubscriptionId: (0,
|
|
8979
|
+
merchantSubscriptionId: (0, import_mysql_core7.primaryKey)({
|
|
8773
8980
|
columns: [
|
|
8774
8981
|
table.id
|
|
8775
8982
|
],
|
|
8776
8983
|
name: "MerchantSubscription_id"
|
|
8777
8984
|
}),
|
|
8778
|
-
organizationIdIdx: (0,
|
|
8985
|
+
organizationIdIdx: (0, import_mysql_core7.index)("organizationId_idx").on(table.organizationId)
|
|
8779
8986
|
};
|
|
8780
8987
|
});
|
|
8781
8988
|
}
|
|
@@ -8784,7 +8991,7 @@ function getMerchantSubscriptionRelationsSchema(mysqlTable) {
|
|
|
8784
8991
|
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
|
|
8785
8992
|
const merchantCharge = getMerchantChargeSchema(mysqlTable);
|
|
8786
8993
|
const subscription = getSubscriptionSchema(mysqlTable);
|
|
8787
|
-
return (0,
|
|
8994
|
+
return (0, import_drizzle_orm7.relations)(merchantSubscription, ({ many, one }) => ({
|
|
8788
8995
|
merchantCharges: many(merchantCharge, {
|
|
8789
8996
|
relationName: "merchantSubscription"
|
|
8790
8997
|
}),
|
|
@@ -8802,104 +9009,104 @@ function getMerchantSubscriptionRelationsSchema(mysqlTable) {
|
|
|
8802
9009
|
__name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
|
|
8803
9010
|
|
|
8804
9011
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
8805
|
-
var
|
|
8806
|
-
var
|
|
9012
|
+
var import_drizzle_orm19 = require("drizzle-orm");
|
|
9013
|
+
var import_mysql_core19 = require("drizzle-orm/mysql-core");
|
|
8807
9014
|
|
|
8808
9015
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
8809
|
-
var
|
|
8810
|
-
var
|
|
9016
|
+
var import_drizzle_orm16 = require("drizzle-orm");
|
|
9017
|
+
var import_mysql_core16 = require("drizzle-orm/mysql-core");
|
|
8811
9018
|
|
|
8812
9019
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
8813
|
-
var
|
|
8814
|
-
var
|
|
9020
|
+
var import_drizzle_orm15 = require("drizzle-orm");
|
|
9021
|
+
var import_mysql_core15 = require("drizzle-orm/mysql-core");
|
|
8815
9022
|
|
|
8816
9023
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
8817
|
-
var
|
|
8818
|
-
var
|
|
9024
|
+
var import_drizzle_orm9 = require("drizzle-orm");
|
|
9025
|
+
var import_mysql_core9 = require("drizzle-orm/mysql-core");
|
|
8819
9026
|
|
|
8820
9027
|
// src/lib/mysql/schemas/content/contribution-types.ts
|
|
8821
|
-
var
|
|
8822
|
-
var
|
|
9028
|
+
var import_drizzle_orm8 = require("drizzle-orm");
|
|
9029
|
+
var import_mysql_core8 = require("drizzle-orm/mysql-core");
|
|
8823
9030
|
function getContributionTypesSchema(mysqlTable) {
|
|
8824
9031
|
return mysqlTable("ContributionType", {
|
|
8825
|
-
id: (0,
|
|
9032
|
+
id: (0, import_mysql_core8.varchar)("id", {
|
|
8826
9033
|
length: 255
|
|
8827
9034
|
}).notNull().primaryKey(),
|
|
8828
|
-
organizationId: (0,
|
|
9035
|
+
organizationId: (0, import_mysql_core8.varchar)("organizationId", {
|
|
8829
9036
|
length: 191
|
|
8830
9037
|
}),
|
|
8831
|
-
slug: (0,
|
|
9038
|
+
slug: (0, import_mysql_core8.varchar)("slug", {
|
|
8832
9039
|
length: 255
|
|
8833
9040
|
}).notNull().unique(),
|
|
8834
|
-
name: (0,
|
|
9041
|
+
name: (0, import_mysql_core8.varchar)("name", {
|
|
8835
9042
|
length: 255
|
|
8836
9043
|
}).notNull(),
|
|
8837
|
-
description: (0,
|
|
8838
|
-
active: (0,
|
|
8839
|
-
createdAt: (0,
|
|
9044
|
+
description: (0, import_mysql_core8.text)("description"),
|
|
9045
|
+
active: (0, import_mysql_core8.boolean)("active").notNull().default(true),
|
|
9046
|
+
createdAt: (0, import_mysql_core8.timestamp)("createdAt", {
|
|
8840
9047
|
mode: "date",
|
|
8841
9048
|
fsp: 3
|
|
8842
9049
|
}).defaultNow(),
|
|
8843
|
-
updatedAt: (0,
|
|
9050
|
+
updatedAt: (0, import_mysql_core8.timestamp)("updatedAt", {
|
|
8844
9051
|
mode: "date",
|
|
8845
9052
|
fsp: 3
|
|
8846
9053
|
}).defaultNow(),
|
|
8847
|
-
deletedAt: (0,
|
|
9054
|
+
deletedAt: (0, import_mysql_core8.timestamp)("deletedAt", {
|
|
8848
9055
|
mode: "date",
|
|
8849
9056
|
fsp: 3
|
|
8850
9057
|
})
|
|
8851
9058
|
}, (ct) => ({
|
|
8852
|
-
nameIdx: (0,
|
|
8853
|
-
slugIdx: (0,
|
|
8854
|
-
organizationIdIdx: (0,
|
|
9059
|
+
nameIdx: (0, import_mysql_core8.index)("name_idx").on(ct.name),
|
|
9060
|
+
slugIdx: (0, import_mysql_core8.index)("slug_idx").on(ct.slug),
|
|
9061
|
+
organizationIdIdx: (0, import_mysql_core8.index)("organizationId_idx").on(ct.organizationId)
|
|
8855
9062
|
}));
|
|
8856
9063
|
}
|
|
8857
9064
|
__name(getContributionTypesSchema, "getContributionTypesSchema");
|
|
8858
9065
|
function getContributionTypesRelationsSchema(mysqlTable) {
|
|
8859
9066
|
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
8860
|
-
return (0,
|
|
9067
|
+
return (0, import_drizzle_orm8.relations)(contributionTypes, ({ many }) => ({}));
|
|
8861
9068
|
}
|
|
8862
9069
|
__name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
|
|
8863
9070
|
|
|
8864
9071
|
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
8865
9072
|
function getContentContributionsSchema(mysqlTable) {
|
|
8866
9073
|
return mysqlTable("ContentContribution", {
|
|
8867
|
-
id: (0,
|
|
9074
|
+
id: (0, import_mysql_core9.varchar)("id", {
|
|
8868
9075
|
length: 255
|
|
8869
9076
|
}).notNull().primaryKey(),
|
|
8870
|
-
userId: (0,
|
|
9077
|
+
userId: (0, import_mysql_core9.varchar)("userId", {
|
|
8871
9078
|
length: 255
|
|
8872
9079
|
}).notNull(),
|
|
8873
|
-
organizationId: (0,
|
|
9080
|
+
organizationId: (0, import_mysql_core9.varchar)("organizationId", {
|
|
8874
9081
|
length: 191
|
|
8875
9082
|
}),
|
|
8876
|
-
organizationMembershipId: (0,
|
|
9083
|
+
organizationMembershipId: (0, import_mysql_core9.varchar)("organizationMembershipId", {
|
|
8877
9084
|
length: 255
|
|
8878
9085
|
}),
|
|
8879
|
-
contentId: (0,
|
|
9086
|
+
contentId: (0, import_mysql_core9.varchar)("contentId", {
|
|
8880
9087
|
length: 255
|
|
8881
9088
|
}).notNull(),
|
|
8882
|
-
contributionTypeId: (0,
|
|
9089
|
+
contributionTypeId: (0, import_mysql_core9.varchar)("contributionTypeId", {
|
|
8883
9090
|
length: 255
|
|
8884
9091
|
}).notNull(),
|
|
8885
|
-
active: (0,
|
|
8886
|
-
createdAt: (0,
|
|
9092
|
+
active: (0, import_mysql_core9.boolean)("active").notNull().default(true),
|
|
9093
|
+
createdAt: (0, import_mysql_core9.timestamp)("createdAt", {
|
|
8887
9094
|
mode: "date",
|
|
8888
9095
|
fsp: 3
|
|
8889
9096
|
}).defaultNow(),
|
|
8890
|
-
updatedAt: (0,
|
|
9097
|
+
updatedAt: (0, import_mysql_core9.timestamp)("updatedAt", {
|
|
8891
9098
|
mode: "date",
|
|
8892
9099
|
fsp: 3
|
|
8893
9100
|
}).defaultNow(),
|
|
8894
|
-
deletedAt: (0,
|
|
9101
|
+
deletedAt: (0, import_mysql_core9.timestamp)("deletedAt", {
|
|
8895
9102
|
mode: "date",
|
|
8896
9103
|
fsp: 3
|
|
8897
9104
|
})
|
|
8898
9105
|
}, (cc) => ({
|
|
8899
|
-
userIdIdx: (0,
|
|
8900
|
-
contentIdIdx: (0,
|
|
8901
|
-
contributionTypeIdIdx: (0,
|
|
8902
|
-
organizationMembershipIdIdx: (0,
|
|
9106
|
+
userIdIdx: (0, import_mysql_core9.index)("userId_idx").on(cc.userId),
|
|
9107
|
+
contentIdIdx: (0, import_mysql_core9.index)("contentId_idx").on(cc.contentId),
|
|
9108
|
+
contributionTypeIdIdx: (0, import_mysql_core9.index)("contributionTypeId_idx").on(cc.contributionTypeId),
|
|
9109
|
+
organizationMembershipIdIdx: (0, import_mysql_core9.index)("organizationMembershipId_idx").on(cc.organizationMembershipId)
|
|
8903
9110
|
}));
|
|
8904
9111
|
}
|
|
8905
9112
|
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
@@ -8909,7 +9116,7 @@ function getContentContributionRelationsSchema(mysqlTable) {
|
|
|
8909
9116
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8910
9117
|
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
8911
9118
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
8912
|
-
return (0,
|
|
9119
|
+
return (0, import_drizzle_orm9.relations)(contentContributions, ({ one }) => ({
|
|
8913
9120
|
user: one(users, {
|
|
8914
9121
|
fields: [
|
|
8915
9122
|
contentContributions.userId
|
|
@@ -8951,50 +9158,50 @@ function getContentContributionRelationsSchema(mysqlTable) {
|
|
|
8951
9158
|
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
8952
9159
|
|
|
8953
9160
|
// src/lib/mysql/schemas/content/content-resource-resource.ts
|
|
8954
|
-
var
|
|
8955
|
-
var
|
|
9161
|
+
var import_drizzle_orm10 = require("drizzle-orm");
|
|
9162
|
+
var import_mysql_core10 = require("drizzle-orm/mysql-core");
|
|
8956
9163
|
function getContentResourceResourceSchema(mysqlTable) {
|
|
8957
9164
|
return mysqlTable("ContentResourceResource", {
|
|
8958
|
-
resourceOfId: (0,
|
|
9165
|
+
resourceOfId: (0, import_mysql_core10.varchar)("resourceOfId", {
|
|
8959
9166
|
length: 255
|
|
8960
9167
|
}).notNull(),
|
|
8961
|
-
resourceId: (0,
|
|
9168
|
+
resourceId: (0, import_mysql_core10.varchar)("resourceId", {
|
|
8962
9169
|
length: 255
|
|
8963
9170
|
}).notNull(),
|
|
8964
|
-
position: (0,
|
|
8965
|
-
metadata: (0,
|
|
8966
|
-
organizationId: (0,
|
|
9171
|
+
position: (0, import_mysql_core10.double)("position").notNull().default(0),
|
|
9172
|
+
metadata: (0, import_mysql_core10.json)("metadata").$type().default({}),
|
|
9173
|
+
organizationId: (0, import_mysql_core10.varchar)("organizationId", {
|
|
8967
9174
|
length: 191
|
|
8968
9175
|
}),
|
|
8969
|
-
createdAt: (0,
|
|
9176
|
+
createdAt: (0, import_mysql_core10.timestamp)("createdAt", {
|
|
8970
9177
|
mode: "date",
|
|
8971
9178
|
fsp: 3
|
|
8972
|
-
}).default(
|
|
8973
|
-
updatedAt: (0,
|
|
9179
|
+
}).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
|
|
9180
|
+
updatedAt: (0, import_mysql_core10.timestamp)("updatedAt", {
|
|
8974
9181
|
mode: "date",
|
|
8975
9182
|
fsp: 3
|
|
8976
|
-
}).default(
|
|
8977
|
-
deletedAt: (0,
|
|
9183
|
+
}).default(import_drizzle_orm10.sql`CURRENT_TIMESTAMP(3)`),
|
|
9184
|
+
deletedAt: (0, import_mysql_core10.timestamp)("deletedAt", {
|
|
8978
9185
|
mode: "date",
|
|
8979
9186
|
fsp: 3
|
|
8980
9187
|
})
|
|
8981
9188
|
}, (crr) => ({
|
|
8982
|
-
pk: (0,
|
|
9189
|
+
pk: (0, import_mysql_core10.primaryKey)({
|
|
8983
9190
|
columns: [
|
|
8984
9191
|
crr.resourceOfId,
|
|
8985
9192
|
crr.resourceId
|
|
8986
9193
|
]
|
|
8987
9194
|
}),
|
|
8988
|
-
contentResourceIdIdx: (0,
|
|
8989
|
-
resourceIdIdx: (0,
|
|
8990
|
-
organizationIdIdx: (0,
|
|
9195
|
+
contentResourceIdIdx: (0, import_mysql_core10.index)("contentResourceId_idx").on(crr.resourceOfId),
|
|
9196
|
+
resourceIdIdx: (0, import_mysql_core10.index)("resourceId_idx").on(crr.resourceId),
|
|
9197
|
+
organizationIdIdx: (0, import_mysql_core10.index)("organizationId_idx").on(crr.organizationId)
|
|
8991
9198
|
}));
|
|
8992
9199
|
}
|
|
8993
9200
|
__name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
|
|
8994
9201
|
function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
8995
9202
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
8996
9203
|
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
8997
|
-
return (0,
|
|
9204
|
+
return (0, import_drizzle_orm10.relations)(contentResourceResource, ({ one }) => ({
|
|
8998
9205
|
resourceOf: one(contentResource, {
|
|
8999
9206
|
fields: [
|
|
9000
9207
|
contentResourceResource.resourceOfId
|
|
@@ -9018,59 +9225,59 @@ function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
|
9018
9225
|
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
9019
9226
|
|
|
9020
9227
|
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
9021
|
-
var
|
|
9022
|
-
var
|
|
9228
|
+
var import_drizzle_orm13 = require("drizzle-orm");
|
|
9229
|
+
var import_mysql_core13 = require("drizzle-orm/mysql-core");
|
|
9023
9230
|
|
|
9024
9231
|
// src/lib/mysql/schemas/content/tag.ts
|
|
9025
|
-
var
|
|
9026
|
-
var
|
|
9232
|
+
var import_drizzle_orm12 = require("drizzle-orm");
|
|
9233
|
+
var import_mysql_core12 = require("drizzle-orm/mysql-core");
|
|
9027
9234
|
|
|
9028
9235
|
// src/lib/mysql/schemas/content/tag-tag.ts
|
|
9029
|
-
var
|
|
9030
|
-
var
|
|
9236
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
9237
|
+
var import_mysql_core11 = require("drizzle-orm/mysql-core");
|
|
9031
9238
|
function getTagTagSchema(mysqlTable) {
|
|
9032
9239
|
return mysqlTable("TagTag", {
|
|
9033
|
-
parentTagId: (0,
|
|
9240
|
+
parentTagId: (0, import_mysql_core11.varchar)("parentTagId", {
|
|
9034
9241
|
length: 255
|
|
9035
9242
|
}).notNull(),
|
|
9036
|
-
childTagId: (0,
|
|
9243
|
+
childTagId: (0, import_mysql_core11.varchar)("childTagId", {
|
|
9037
9244
|
length: 255
|
|
9038
9245
|
}).notNull(),
|
|
9039
|
-
position: (0,
|
|
9040
|
-
metadata: (0,
|
|
9041
|
-
organizationId: (0,
|
|
9246
|
+
position: (0, import_mysql_core11.double)("position").notNull().default(0),
|
|
9247
|
+
metadata: (0, import_mysql_core11.json)("metadata").$type().default({}),
|
|
9248
|
+
organizationId: (0, import_mysql_core11.varchar)("organizationId", {
|
|
9042
9249
|
length: 191
|
|
9043
9250
|
}),
|
|
9044
|
-
createdAt: (0,
|
|
9251
|
+
createdAt: (0, import_mysql_core11.timestamp)("createdAt", {
|
|
9045
9252
|
mode: "date",
|
|
9046
9253
|
fsp: 3
|
|
9047
|
-
}).default(
|
|
9048
|
-
updatedAt: (0,
|
|
9254
|
+
}).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
|
|
9255
|
+
updatedAt: (0, import_mysql_core11.timestamp)("updatedAt", {
|
|
9049
9256
|
mode: "date",
|
|
9050
9257
|
fsp: 3
|
|
9051
|
-
}).default(
|
|
9052
|
-
deletedAt: (0,
|
|
9258
|
+
}).default(import_drizzle_orm11.sql`CURRENT_TIMESTAMP(3)`),
|
|
9259
|
+
deletedAt: (0, import_mysql_core11.timestamp)("deletedAt", {
|
|
9053
9260
|
mode: "date",
|
|
9054
9261
|
fsp: 3
|
|
9055
9262
|
})
|
|
9056
9263
|
}, (tt) => ({
|
|
9057
|
-
pk: (0,
|
|
9264
|
+
pk: (0, import_mysql_core11.primaryKey)({
|
|
9058
9265
|
columns: [
|
|
9059
9266
|
tt.parentTagId,
|
|
9060
9267
|
tt.childTagId
|
|
9061
9268
|
]
|
|
9062
9269
|
}),
|
|
9063
|
-
parentTagIdIdx: (0,
|
|
9064
|
-
childTagIdIdx: (0,
|
|
9065
|
-
positionIdx: (0,
|
|
9066
|
-
organizationIdIdx: (0,
|
|
9270
|
+
parentTagIdIdx: (0, import_mysql_core11.index)("parentTagId_idx").on(tt.parentTagId),
|
|
9271
|
+
childTagIdIdx: (0, import_mysql_core11.index)("childTagId_idx").on(tt.childTagId),
|
|
9272
|
+
positionIdx: (0, import_mysql_core11.index)("position_idx").on(tt.position),
|
|
9273
|
+
organizationIdIdx: (0, import_mysql_core11.index)("organizationId_idx").on(tt.organizationId)
|
|
9067
9274
|
}));
|
|
9068
9275
|
}
|
|
9069
9276
|
__name(getTagTagSchema, "getTagTagSchema");
|
|
9070
9277
|
function getTagTagRelationsSchema(mysqlTable) {
|
|
9071
9278
|
const tag = getTagSchema(mysqlTable);
|
|
9072
9279
|
const tagTag = getTagTagSchema(mysqlTable);
|
|
9073
|
-
return (0,
|
|
9280
|
+
return (0, import_drizzle_orm11.relations)(tagTag, ({ one }) => ({
|
|
9074
9281
|
parentTag: one(tag, {
|
|
9075
9282
|
fields: [
|
|
9076
9283
|
tagTag.parentTagId
|
|
@@ -9096,31 +9303,31 @@ __name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
|
|
|
9096
9303
|
// src/lib/mysql/schemas/content/tag.ts
|
|
9097
9304
|
function getTagSchema(mysqlTable) {
|
|
9098
9305
|
return mysqlTable("Tag", {
|
|
9099
|
-
id: (0,
|
|
9306
|
+
id: (0, import_mysql_core12.varchar)("id", {
|
|
9100
9307
|
length: 255
|
|
9101
9308
|
}).notNull().primaryKey(),
|
|
9102
|
-
organizationId: (0,
|
|
9309
|
+
organizationId: (0, import_mysql_core12.varchar)("organizationId", {
|
|
9103
9310
|
length: 191
|
|
9104
9311
|
}),
|
|
9105
|
-
type: (0,
|
|
9312
|
+
type: (0, import_mysql_core12.varchar)("type", {
|
|
9106
9313
|
length: 255
|
|
9107
9314
|
}).notNull(),
|
|
9108
|
-
fields: (0,
|
|
9109
|
-
createdAt: (0,
|
|
9315
|
+
fields: (0, import_mysql_core12.json)("fields").$type().default({}),
|
|
9316
|
+
createdAt: (0, import_mysql_core12.timestamp)("createdAt", {
|
|
9110
9317
|
mode: "date",
|
|
9111
9318
|
fsp: 3
|
|
9112
|
-
}).default(
|
|
9113
|
-
updatedAt: (0,
|
|
9319
|
+
}).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
|
|
9320
|
+
updatedAt: (0, import_mysql_core12.timestamp)("updatedAt", {
|
|
9114
9321
|
mode: "date",
|
|
9115
9322
|
fsp: 3
|
|
9116
|
-
}).default(
|
|
9117
|
-
deletedAt: (0,
|
|
9323
|
+
}).default(import_drizzle_orm12.sql`CURRENT_TIMESTAMP(3)`),
|
|
9324
|
+
deletedAt: (0, import_mysql_core12.timestamp)("deletedAt", {
|
|
9118
9325
|
mode: "date",
|
|
9119
9326
|
fsp: 3
|
|
9120
9327
|
})
|
|
9121
9328
|
}, (t) => ({
|
|
9122
|
-
typeIdx: (0,
|
|
9123
|
-
organizationIdIdx: (0,
|
|
9329
|
+
typeIdx: (0, import_mysql_core12.index)("type_idx").on(t.type),
|
|
9330
|
+
organizationIdIdx: (0, import_mysql_core12.index)("organizationId_idx").on(t.organizationId)
|
|
9124
9331
|
}));
|
|
9125
9332
|
}
|
|
9126
9333
|
__name(getTagSchema, "getTagSchema");
|
|
@@ -9128,7 +9335,7 @@ function getTagRelationsSchema(mysqlTable) {
|
|
|
9128
9335
|
const tag = getTagSchema(mysqlTable);
|
|
9129
9336
|
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
9130
9337
|
const tagTag = getTagTagSchema(mysqlTable);
|
|
9131
|
-
return (0,
|
|
9338
|
+
return (0, import_drizzle_orm12.relations)(tag, ({ many }) => ({
|
|
9132
9339
|
resources: many(contentResourceTag, {
|
|
9133
9340
|
relationName: "contentResource"
|
|
9134
9341
|
}),
|
|
@@ -9145,35 +9352,35 @@ __name(getTagRelationsSchema, "getTagRelationsSchema");
|
|
|
9145
9352
|
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
9146
9353
|
function getContentResourceTagSchema(mysqlTable) {
|
|
9147
9354
|
return mysqlTable("ContentResourceTag", {
|
|
9148
|
-
contentResourceId: (0,
|
|
9355
|
+
contentResourceId: (0, import_mysql_core13.varchar)("contentResourceId", {
|
|
9149
9356
|
length: 255
|
|
9150
9357
|
}).notNull(),
|
|
9151
|
-
organizationId: (0,
|
|
9358
|
+
organizationId: (0, import_mysql_core13.varchar)("organizationId", {
|
|
9152
9359
|
length: 191
|
|
9153
9360
|
}),
|
|
9154
|
-
tagId: (0,
|
|
9361
|
+
tagId: (0, import_mysql_core13.varchar)("tagId", {
|
|
9155
9362
|
length: 255
|
|
9156
9363
|
}).notNull(),
|
|
9157
|
-
position: (0,
|
|
9158
|
-
createdAt: (0,
|
|
9364
|
+
position: (0, import_mysql_core13.double)("position").notNull().default(0),
|
|
9365
|
+
createdAt: (0, import_mysql_core13.timestamp)("createdAt", {
|
|
9159
9366
|
mode: "date",
|
|
9160
9367
|
fsp: 3
|
|
9161
|
-
}).default(
|
|
9162
|
-
updatedAt: (0,
|
|
9368
|
+
}).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`),
|
|
9369
|
+
updatedAt: (0, import_mysql_core13.timestamp)("updatedAt", {
|
|
9163
9370
|
mode: "date",
|
|
9164
9371
|
fsp: 3
|
|
9165
|
-
}).default(
|
|
9372
|
+
}).default(import_drizzle_orm13.sql`CURRENT_TIMESTAMP(3)`)
|
|
9166
9373
|
}, (crt) => ({
|
|
9167
|
-
pk: (0,
|
|
9374
|
+
pk: (0, import_mysql_core13.primaryKey)({
|
|
9168
9375
|
columns: [
|
|
9169
9376
|
crt.contentResourceId,
|
|
9170
9377
|
crt.tagId
|
|
9171
9378
|
]
|
|
9172
9379
|
}),
|
|
9173
|
-
contentResourceIdIdx: (0,
|
|
9174
|
-
tagIdIdx: (0,
|
|
9175
|
-
positionIdx: (0,
|
|
9176
|
-
organizationIdIdx: (0,
|
|
9380
|
+
contentResourceIdIdx: (0, import_mysql_core13.index)("contentResourceId_idx").on(crt.contentResourceId),
|
|
9381
|
+
tagIdIdx: (0, import_mysql_core13.index)("tagId_idx").on(crt.tagId),
|
|
9382
|
+
positionIdx: (0, import_mysql_core13.index)("position_idx").on(crt.position),
|
|
9383
|
+
organizationIdIdx: (0, import_mysql_core13.index)("organizationId_idx").on(crt.organizationId)
|
|
9177
9384
|
}));
|
|
9178
9385
|
}
|
|
9179
9386
|
__name(getContentResourceTagSchema, "getContentResourceTagSchema");
|
|
@@ -9181,7 +9388,7 @@ function getContentResourceTagRelationsSchema(mysqlTable) {
|
|
|
9181
9388
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9182
9389
|
const tag = getTagSchema(mysqlTable);
|
|
9183
9390
|
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
9184
|
-
return (0,
|
|
9391
|
+
return (0, import_drizzle_orm13.relations)(contentResourceTag, ({ one }) => ({
|
|
9185
9392
|
contentResource: one(contentResource, {
|
|
9186
9393
|
fields: [
|
|
9187
9394
|
contentResourceTag.contentResourceId
|
|
@@ -9205,37 +9412,37 @@ function getContentResourceTagRelationsSchema(mysqlTable) {
|
|
|
9205
9412
|
__name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
|
|
9206
9413
|
|
|
9207
9414
|
// src/lib/mysql/schemas/content/content-resource-version.ts
|
|
9208
|
-
var
|
|
9209
|
-
var
|
|
9415
|
+
var import_drizzle_orm14 = require("drizzle-orm");
|
|
9416
|
+
var import_mysql_core14 = require("drizzle-orm/mysql-core");
|
|
9210
9417
|
function getContentResourceVersionSchema(mysqlTable) {
|
|
9211
9418
|
return mysqlTable("ContentResourceVersion", {
|
|
9212
|
-
id: (0,
|
|
9419
|
+
id: (0, import_mysql_core14.varchar)("id", {
|
|
9213
9420
|
length: 255
|
|
9214
9421
|
}).notNull().primaryKey(),
|
|
9215
|
-
organizationId: (0,
|
|
9422
|
+
organizationId: (0, import_mysql_core14.varchar)("organizationId", {
|
|
9216
9423
|
length: 191
|
|
9217
9424
|
}),
|
|
9218
|
-
resourceId: (0,
|
|
9425
|
+
resourceId: (0, import_mysql_core14.varchar)("resourceId", {
|
|
9219
9426
|
length: 255
|
|
9220
9427
|
}).notNull(),
|
|
9221
|
-
parentVersionId: (0,
|
|
9428
|
+
parentVersionId: (0, import_mysql_core14.varchar)("parentVersionId", {
|
|
9222
9429
|
length: 255
|
|
9223
9430
|
}),
|
|
9224
|
-
versionNumber: (0,
|
|
9225
|
-
fields: (0,
|
|
9226
|
-
createdAt: (0,
|
|
9431
|
+
versionNumber: (0, import_mysql_core14.int)("versionNumber").notNull(),
|
|
9432
|
+
fields: (0, import_mysql_core14.json)("fields").$type().default({}),
|
|
9433
|
+
createdAt: (0, import_mysql_core14.timestamp)("createdAt", {
|
|
9227
9434
|
mode: "date",
|
|
9228
9435
|
fsp: 3
|
|
9229
|
-
}).default(
|
|
9230
|
-
createdById: (0,
|
|
9436
|
+
}).default(import_drizzle_orm14.sql`CURRENT_TIMESTAMP(3)`),
|
|
9437
|
+
createdById: (0, import_mysql_core14.varchar)("createdById", {
|
|
9231
9438
|
length: 255
|
|
9232
9439
|
}).notNull()
|
|
9233
9440
|
}, (crv) => ({
|
|
9234
|
-
resourceIdIdx: (0,
|
|
9235
|
-
parentVersionIdIdx: (0,
|
|
9236
|
-
resourceIdVersionNumberIdx: (0,
|
|
9237
|
-
uniqueResourceVersion: (0,
|
|
9238
|
-
organizationIdIdx: (0,
|
|
9441
|
+
resourceIdIdx: (0, import_mysql_core14.index)("resourceId_idx").on(crv.resourceId),
|
|
9442
|
+
parentVersionIdIdx: (0, import_mysql_core14.index)("parentVersionId_idx").on(crv.parentVersionId),
|
|
9443
|
+
resourceIdVersionNumberIdx: (0, import_mysql_core14.index)("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
|
|
9444
|
+
uniqueResourceVersion: (0, import_mysql_core14.unique)("uq_resource_version_number").on(crv.resourceId, crv.versionNumber),
|
|
9445
|
+
organizationIdIdx: (0, import_mysql_core14.index)("organizationId_idx").on(crv.organizationId)
|
|
9239
9446
|
}));
|
|
9240
9447
|
}
|
|
9241
9448
|
__name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
|
|
@@ -9243,7 +9450,7 @@ function getContentResourceVersionRelationsSchema(mysqlTable) {
|
|
|
9243
9450
|
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
9244
9451
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9245
9452
|
const users = getUsersSchema(mysqlTable);
|
|
9246
|
-
return (0,
|
|
9453
|
+
return (0, import_drizzle_orm14.relations)(contentResourceVersion, ({ one }) => ({
|
|
9247
9454
|
resource: one(contentResource, {
|
|
9248
9455
|
fields: [
|
|
9249
9456
|
contentResourceVersion.resourceId
|
|
@@ -9278,43 +9485,43 @@ __name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelat
|
|
|
9278
9485
|
// src/lib/mysql/schemas/content/content-resource.ts
|
|
9279
9486
|
function getContentResourceSchema(mysqlTable) {
|
|
9280
9487
|
return mysqlTable("ContentResource", {
|
|
9281
|
-
id: (0,
|
|
9488
|
+
id: (0, import_mysql_core15.varchar)("id", {
|
|
9282
9489
|
length: 255
|
|
9283
9490
|
}).notNull().primaryKey(),
|
|
9284
|
-
organizationId: (0,
|
|
9491
|
+
organizationId: (0, import_mysql_core15.varchar)("organizationId", {
|
|
9285
9492
|
length: 191
|
|
9286
9493
|
}),
|
|
9287
|
-
createdByOrganizationMembershipId: (0,
|
|
9494
|
+
createdByOrganizationMembershipId: (0, import_mysql_core15.varchar)("createdByOrganizationMembershipId", {
|
|
9288
9495
|
length: 191
|
|
9289
9496
|
}),
|
|
9290
|
-
type: (0,
|
|
9497
|
+
type: (0, import_mysql_core15.varchar)("type", {
|
|
9291
9498
|
length: 255
|
|
9292
9499
|
}).notNull(),
|
|
9293
|
-
createdById: (0,
|
|
9500
|
+
createdById: (0, import_mysql_core15.varchar)("createdById", {
|
|
9294
9501
|
length: 255
|
|
9295
9502
|
}).notNull(),
|
|
9296
|
-
fields: (0,
|
|
9297
|
-
currentVersionId: (0,
|
|
9503
|
+
fields: (0, import_mysql_core15.json)("fields").$type().default({}),
|
|
9504
|
+
currentVersionId: (0, import_mysql_core15.varchar)("currentVersionId", {
|
|
9298
9505
|
length: 255
|
|
9299
9506
|
}),
|
|
9300
|
-
createdAt: (0,
|
|
9507
|
+
createdAt: (0, import_mysql_core15.timestamp)("createdAt", {
|
|
9301
9508
|
mode: "date",
|
|
9302
9509
|
fsp: 3
|
|
9303
|
-
}).default(
|
|
9304
|
-
updatedAt: (0,
|
|
9510
|
+
}).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
|
|
9511
|
+
updatedAt: (0, import_mysql_core15.timestamp)("updatedAt", {
|
|
9305
9512
|
mode: "date",
|
|
9306
9513
|
fsp: 3
|
|
9307
|
-
}).default(
|
|
9308
|
-
deletedAt: (0,
|
|
9514
|
+
}).default(import_drizzle_orm15.sql`CURRENT_TIMESTAMP(3)`),
|
|
9515
|
+
deletedAt: (0, import_mysql_core15.timestamp)("deletedAt", {
|
|
9309
9516
|
mode: "date",
|
|
9310
9517
|
fsp: 3
|
|
9311
9518
|
})
|
|
9312
9519
|
}, (cm) => ({
|
|
9313
|
-
typeIdx: (0,
|
|
9314
|
-
createdByIdx: (0,
|
|
9315
|
-
createdAtIdx: (0,
|
|
9316
|
-
currentVersionIdIdx: (0,
|
|
9317
|
-
createdByOrganizationMembershipIdIdx: (0,
|
|
9520
|
+
typeIdx: (0, import_mysql_core15.index)("type_idx").on(cm.type),
|
|
9521
|
+
createdByIdx: (0, import_mysql_core15.index)("createdById_idx").on(cm.createdById),
|
|
9522
|
+
createdAtIdx: (0, import_mysql_core15.index)("createdAt_idx").on(cm.createdAt),
|
|
9523
|
+
currentVersionIdIdx: (0, import_mysql_core15.index)("currentVersionId_idx").on(cm.currentVersionId),
|
|
9524
|
+
createdByOrganizationMembershipIdIdx: (0, import_mysql_core15.index)("createdByOrganizationMembershipId_idx").on(cm.createdByOrganizationMembershipId)
|
|
9318
9525
|
}));
|
|
9319
9526
|
}
|
|
9320
9527
|
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
@@ -9328,7 +9535,7 @@ function getContentResourceRelationsSchema(mysqlTable) {
|
|
|
9328
9535
|
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
9329
9536
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
9330
9537
|
const tag = getTagSchema(mysqlTable);
|
|
9331
|
-
return (0,
|
|
9538
|
+
return (0, import_drizzle_orm15.relations)(contentResource, ({ one, many }) => ({
|
|
9332
9539
|
createdBy: one(users, {
|
|
9333
9540
|
fields: [
|
|
9334
9541
|
contentResource.createdById
|
|
@@ -9381,39 +9588,39 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
|
9381
9588
|
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
9382
9589
|
function getContentResourceProductSchema(mysqlTable) {
|
|
9383
9590
|
return mysqlTable("ContentResourceProduct", {
|
|
9384
|
-
productId: (0,
|
|
9591
|
+
productId: (0, import_mysql_core16.varchar)("productId", {
|
|
9385
9592
|
length: 255
|
|
9386
9593
|
}).notNull(),
|
|
9387
|
-
resourceId: (0,
|
|
9594
|
+
resourceId: (0, import_mysql_core16.varchar)("resourceId", {
|
|
9388
9595
|
length: 255
|
|
9389
9596
|
}).notNull(),
|
|
9390
|
-
organizationId: (0,
|
|
9597
|
+
organizationId: (0, import_mysql_core16.varchar)("organizationId", {
|
|
9391
9598
|
length: 191
|
|
9392
9599
|
}),
|
|
9393
|
-
position: (0,
|
|
9394
|
-
metadata: (0,
|
|
9395
|
-
createdAt: (0,
|
|
9600
|
+
position: (0, import_mysql_core16.double)("position").notNull().default(0),
|
|
9601
|
+
metadata: (0, import_mysql_core16.json)("metadata").$type().default({}),
|
|
9602
|
+
createdAt: (0, import_mysql_core16.timestamp)("createdAt", {
|
|
9396
9603
|
mode: "date",
|
|
9397
9604
|
fsp: 3
|
|
9398
|
-
}).default(
|
|
9399
|
-
updatedAt: (0,
|
|
9605
|
+
}).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`),
|
|
9606
|
+
updatedAt: (0, import_mysql_core16.timestamp)("updatedAt", {
|
|
9400
9607
|
mode: "date",
|
|
9401
9608
|
fsp: 3
|
|
9402
|
-
}).default(
|
|
9403
|
-
deletedAt: (0,
|
|
9609
|
+
}).default(import_drizzle_orm16.sql`CURRENT_TIMESTAMP(3)`),
|
|
9610
|
+
deletedAt: (0, import_mysql_core16.timestamp)("deletedAt", {
|
|
9404
9611
|
mode: "date",
|
|
9405
9612
|
fsp: 3
|
|
9406
9613
|
})
|
|
9407
9614
|
}, (crr) => ({
|
|
9408
|
-
pk: (0,
|
|
9615
|
+
pk: (0, import_mysql_core16.primaryKey)({
|
|
9409
9616
|
columns: [
|
|
9410
9617
|
crr.productId,
|
|
9411
9618
|
crr.resourceId
|
|
9412
9619
|
]
|
|
9413
9620
|
}),
|
|
9414
|
-
contentResourceIdIdx: (0,
|
|
9415
|
-
resourceIdIdx: (0,
|
|
9416
|
-
organizationIdIdx: (0,
|
|
9621
|
+
contentResourceIdIdx: (0, import_mysql_core16.index)("contentResourceId_idx").on(crr.productId),
|
|
9622
|
+
resourceIdIdx: (0, import_mysql_core16.index)("resourceId_idx").on(crr.resourceId),
|
|
9623
|
+
organizationIdIdx: (0, import_mysql_core16.index)("organizationId_idx").on(crr.organizationId)
|
|
9417
9624
|
}));
|
|
9418
9625
|
}
|
|
9419
9626
|
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
@@ -9421,7 +9628,7 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
9421
9628
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
9422
9629
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
9423
9630
|
const product = getProductSchema(mysqlTable);
|
|
9424
|
-
return (0,
|
|
9631
|
+
return (0, import_drizzle_orm16.relations)(contentResourceProduct, ({ one }) => ({
|
|
9425
9632
|
product: one(product, {
|
|
9426
9633
|
fields: [
|
|
9427
9634
|
contentResourceProduct.productId
|
|
@@ -9445,47 +9652,47 @@ function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
|
9445
9652
|
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
9446
9653
|
|
|
9447
9654
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
9448
|
-
var
|
|
9449
|
-
var
|
|
9655
|
+
var import_drizzle_orm18 = require("drizzle-orm");
|
|
9656
|
+
var import_mysql_core18 = require("drizzle-orm/mysql-core");
|
|
9450
9657
|
|
|
9451
9658
|
// src/lib/mysql/schemas/commerce/merchant-price.ts
|
|
9452
|
-
var
|
|
9453
|
-
var
|
|
9659
|
+
var import_drizzle_orm17 = require("drizzle-orm");
|
|
9660
|
+
var import_mysql_core17 = require("drizzle-orm/mysql-core");
|
|
9454
9661
|
function getMerchantPriceSchema(mysqlTable) {
|
|
9455
9662
|
return mysqlTable("MerchantPrice", {
|
|
9456
|
-
id: (0,
|
|
9663
|
+
id: (0, import_mysql_core17.varchar)("id", {
|
|
9457
9664
|
length: 191
|
|
9458
9665
|
}).notNull(),
|
|
9459
|
-
organizationId: (0,
|
|
9666
|
+
organizationId: (0, import_mysql_core17.varchar)("organizationId", {
|
|
9460
9667
|
length: 191
|
|
9461
9668
|
}),
|
|
9462
|
-
merchantAccountId: (0,
|
|
9669
|
+
merchantAccountId: (0, import_mysql_core17.varchar)("merchantAccountId", {
|
|
9463
9670
|
length: 191
|
|
9464
9671
|
}).notNull(),
|
|
9465
|
-
merchantProductId: (0,
|
|
9672
|
+
merchantProductId: (0, import_mysql_core17.varchar)("merchantProductId", {
|
|
9466
9673
|
length: 191
|
|
9467
9674
|
}).notNull(),
|
|
9468
|
-
status: (0,
|
|
9469
|
-
identifier: (0,
|
|
9675
|
+
status: (0, import_mysql_core17.int)("status").default(0),
|
|
9676
|
+
identifier: (0, import_mysql_core17.varchar)("identifier", {
|
|
9470
9677
|
length: 191
|
|
9471
9678
|
}),
|
|
9472
|
-
createdAt: (0,
|
|
9679
|
+
createdAt: (0, import_mysql_core17.timestamp)("createdAt", {
|
|
9473
9680
|
mode: "date",
|
|
9474
9681
|
fsp: 3
|
|
9475
|
-
}).default(
|
|
9476
|
-
priceId: (0,
|
|
9682
|
+
}).default(import_drizzle_orm17.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9683
|
+
priceId: (0, import_mysql_core17.varchar)("priceId", {
|
|
9477
9684
|
length: 191
|
|
9478
9685
|
})
|
|
9479
9686
|
}, (table) => {
|
|
9480
9687
|
return {
|
|
9481
|
-
merchantPriceId: (0,
|
|
9688
|
+
merchantPriceId: (0, import_mysql_core17.primaryKey)({
|
|
9482
9689
|
columns: [
|
|
9483
9690
|
table.id
|
|
9484
9691
|
],
|
|
9485
9692
|
name: "MerchantPrice_id"
|
|
9486
9693
|
}),
|
|
9487
|
-
merchantPriceIdentifierKey: (0,
|
|
9488
|
-
organizationIdIdx: (0,
|
|
9694
|
+
merchantPriceIdentifierKey: (0, import_mysql_core17.unique)("MerchantPrice_identifier_key").on(table.identifier),
|
|
9695
|
+
organizationIdIdx: (0, import_mysql_core17.index)("organizationId_idx").on(table.organizationId)
|
|
9489
9696
|
};
|
|
9490
9697
|
});
|
|
9491
9698
|
}
|
|
@@ -9494,37 +9701,37 @@ __name(getMerchantPriceSchema, "getMerchantPriceSchema");
|
|
|
9494
9701
|
// src/lib/mysql/schemas/commerce/price.ts
|
|
9495
9702
|
function getPriceSchema(mysqlTable) {
|
|
9496
9703
|
return mysqlTable("Price", {
|
|
9497
|
-
id: (0,
|
|
9704
|
+
id: (0, import_mysql_core18.varchar)("id", {
|
|
9498
9705
|
length: 191
|
|
9499
9706
|
}).notNull(),
|
|
9500
|
-
productId: (0,
|
|
9707
|
+
productId: (0, import_mysql_core18.varchar)("productId", {
|
|
9501
9708
|
length: 191
|
|
9502
9709
|
}),
|
|
9503
|
-
organizationId: (0,
|
|
9710
|
+
organizationId: (0, import_mysql_core18.varchar)("organizationId", {
|
|
9504
9711
|
length: 191
|
|
9505
9712
|
}),
|
|
9506
|
-
nickname: (0,
|
|
9713
|
+
nickname: (0, import_mysql_core18.varchar)("nickname", {
|
|
9507
9714
|
length: 191
|
|
9508
9715
|
}),
|
|
9509
|
-
status: (0,
|
|
9510
|
-
unitAmount: (0,
|
|
9716
|
+
status: (0, import_mysql_core18.int)("status").default(0).notNull(),
|
|
9717
|
+
unitAmount: (0, import_mysql_core18.decimal)("unitAmount", {
|
|
9511
9718
|
precision: 10,
|
|
9512
9719
|
scale: 2
|
|
9513
9720
|
}).notNull(),
|
|
9514
|
-
createdAt: (0,
|
|
9721
|
+
createdAt: (0, import_mysql_core18.timestamp)("createdAt", {
|
|
9515
9722
|
mode: "date",
|
|
9516
9723
|
fsp: 3
|
|
9517
|
-
}).default(
|
|
9518
|
-
fields: (0,
|
|
9724
|
+
}).default(import_drizzle_orm18.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9725
|
+
fields: (0, import_mysql_core18.json)("fields").$type().default({})
|
|
9519
9726
|
}, (table) => {
|
|
9520
9727
|
return {
|
|
9521
|
-
priceId: (0,
|
|
9728
|
+
priceId: (0, import_mysql_core18.primaryKey)({
|
|
9522
9729
|
columns: [
|
|
9523
9730
|
table.id
|
|
9524
9731
|
],
|
|
9525
9732
|
name: "Price_id"
|
|
9526
9733
|
}),
|
|
9527
|
-
organizationIdIdx: (0,
|
|
9734
|
+
organizationIdIdx: (0, import_mysql_core18.index)("organizationId_idx").on(table.organizationId)
|
|
9528
9735
|
};
|
|
9529
9736
|
});
|
|
9530
9737
|
}
|
|
@@ -9533,37 +9740,37 @@ __name(getPriceSchema, "getPriceSchema");
|
|
|
9533
9740
|
// src/lib/mysql/schemas/commerce/product.ts
|
|
9534
9741
|
function getProductSchema(mysqlTable) {
|
|
9535
9742
|
return mysqlTable("Product", {
|
|
9536
|
-
id: (0,
|
|
9743
|
+
id: (0, import_mysql_core19.varchar)("id", {
|
|
9537
9744
|
length: 191
|
|
9538
9745
|
}).notNull(),
|
|
9539
|
-
organizationId: (0,
|
|
9746
|
+
organizationId: (0, import_mysql_core19.varchar)("organizationId", {
|
|
9540
9747
|
length: 191
|
|
9541
9748
|
}),
|
|
9542
|
-
name: (0,
|
|
9749
|
+
name: (0, import_mysql_core19.varchar)("name", {
|
|
9543
9750
|
length: 191
|
|
9544
9751
|
}).notNull(),
|
|
9545
|
-
key: (0,
|
|
9752
|
+
key: (0, import_mysql_core19.varchar)("key", {
|
|
9546
9753
|
length: 191
|
|
9547
9754
|
}),
|
|
9548
|
-
type: (0,
|
|
9755
|
+
type: (0, import_mysql_core19.varchar)("type", {
|
|
9549
9756
|
length: 191
|
|
9550
9757
|
}),
|
|
9551
|
-
fields: (0,
|
|
9552
|
-
createdAt: (0,
|
|
9758
|
+
fields: (0, import_mysql_core19.json)("fields").$type().default({}),
|
|
9759
|
+
createdAt: (0, import_mysql_core19.timestamp)("createdAt", {
|
|
9553
9760
|
mode: "date",
|
|
9554
9761
|
fsp: 3
|
|
9555
|
-
}).default(
|
|
9556
|
-
status: (0,
|
|
9557
|
-
quantityAvailable: (0,
|
|
9762
|
+
}).default(import_drizzle_orm19.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9763
|
+
status: (0, import_mysql_core19.int)("status").default(0).notNull(),
|
|
9764
|
+
quantityAvailable: (0, import_mysql_core19.int)("quantityAvailable").default(-1).notNull()
|
|
9558
9765
|
}, (table) => {
|
|
9559
9766
|
return {
|
|
9560
|
-
productId: (0,
|
|
9767
|
+
productId: (0, import_mysql_core19.primaryKey)({
|
|
9561
9768
|
columns: [
|
|
9562
9769
|
table.id
|
|
9563
9770
|
],
|
|
9564
9771
|
name: "Product_id"
|
|
9565
9772
|
}),
|
|
9566
|
-
organizationIdIdx: (0,
|
|
9773
|
+
organizationIdIdx: (0, import_mysql_core19.index)("organizationId_idx").on(table.organizationId)
|
|
9567
9774
|
};
|
|
9568
9775
|
});
|
|
9569
9776
|
}
|
|
@@ -9573,7 +9780,7 @@ function getProductRelationsSchema(mysqlTable) {
|
|
|
9573
9780
|
const price = getPriceSchema(mysqlTable);
|
|
9574
9781
|
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
9575
9782
|
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
9576
|
-
return (0,
|
|
9783
|
+
return (0, import_drizzle_orm19.relations)(product, ({ one, many }) => ({
|
|
9577
9784
|
price: one(price, {
|
|
9578
9785
|
fields: [
|
|
9579
9786
|
product.id
|
|
@@ -9602,35 +9809,35 @@ __name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
|
9602
9809
|
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
9603
9810
|
function getSubscriptionSchema(mysqlTable) {
|
|
9604
9811
|
return mysqlTable("Subscription", {
|
|
9605
|
-
id: (0,
|
|
9812
|
+
id: (0, import_mysql_core20.varchar)("id", {
|
|
9606
9813
|
length: 191
|
|
9607
9814
|
}).notNull(),
|
|
9608
|
-
organizationId: (0,
|
|
9815
|
+
organizationId: (0, import_mysql_core20.varchar)("organizationId", {
|
|
9609
9816
|
length: 191
|
|
9610
9817
|
}),
|
|
9611
|
-
productId: (0,
|
|
9818
|
+
productId: (0, import_mysql_core20.varchar)("productId", {
|
|
9612
9819
|
length: 191
|
|
9613
9820
|
}).notNull(),
|
|
9614
|
-
createdAt: (0,
|
|
9821
|
+
createdAt: (0, import_mysql_core20.timestamp)("createdAt", {
|
|
9615
9822
|
mode: "date",
|
|
9616
9823
|
fsp: 3
|
|
9617
|
-
}).default(
|
|
9618
|
-
merchantSubscriptionId: (0,
|
|
9824
|
+
}).default(import_drizzle_orm20.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
9825
|
+
merchantSubscriptionId: (0, import_mysql_core20.varchar)("merchantSubscriptionId", {
|
|
9619
9826
|
length: 191
|
|
9620
9827
|
}).notNull(),
|
|
9621
|
-
status: (0,
|
|
9828
|
+
status: (0, import_mysql_core20.varchar)("status", {
|
|
9622
9829
|
length: 191
|
|
9623
|
-
}).default("
|
|
9624
|
-
fields: (0,
|
|
9830
|
+
}).default("active").notNull(),
|
|
9831
|
+
fields: (0, import_mysql_core20.json)("fields").$type().default({})
|
|
9625
9832
|
}, (table) => {
|
|
9626
9833
|
return {
|
|
9627
|
-
subscriptionId: (0,
|
|
9834
|
+
subscriptionId: (0, import_mysql_core20.primaryKey)({
|
|
9628
9835
|
columns: [
|
|
9629
9836
|
table.id
|
|
9630
9837
|
],
|
|
9631
9838
|
name: "Subscription_id"
|
|
9632
9839
|
}),
|
|
9633
|
-
organizationIdIdx: (0,
|
|
9840
|
+
organizationIdIdx: (0, import_mysql_core20.index)("organizationId_idx").on(table.organizationId)
|
|
9634
9841
|
};
|
|
9635
9842
|
});
|
|
9636
9843
|
}
|
|
@@ -9640,7 +9847,7 @@ function getSubscriptionRelationsSchema(mysqlTable) {
|
|
|
9640
9847
|
const products = getProductSchema(mysqlTable);
|
|
9641
9848
|
const organizations = getOrganizationsSchema(mysqlTable);
|
|
9642
9849
|
const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable);
|
|
9643
|
-
return (0,
|
|
9850
|
+
return (0, import_drizzle_orm20.relations)(subscriptions, ({ many, one }) => ({
|
|
9644
9851
|
organization: one(organizations, {
|
|
9645
9852
|
fields: [
|
|
9646
9853
|
subscriptions.organizationId
|
|
@@ -9675,22 +9882,22 @@ __name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
|
|
|
9675
9882
|
// src/lib/mysql/schemas/org/organizations.ts
|
|
9676
9883
|
function getOrganizationsSchema(mysqlTable) {
|
|
9677
9884
|
return mysqlTable("Organization", {
|
|
9678
|
-
id: (0,
|
|
9885
|
+
id: (0, import_mysql_core21.varchar)("id", {
|
|
9679
9886
|
length: 255
|
|
9680
9887
|
}).notNull().primaryKey(),
|
|
9681
|
-
name: (0,
|
|
9888
|
+
name: (0, import_mysql_core21.varchar)("name", {
|
|
9682
9889
|
length: 255
|
|
9683
9890
|
}),
|
|
9684
|
-
fields: (0,
|
|
9685
|
-
image: (0,
|
|
9891
|
+
fields: (0, import_mysql_core21.json)("fields").$type().default({}),
|
|
9892
|
+
image: (0, import_mysql_core21.varchar)("image", {
|
|
9686
9893
|
length: 255
|
|
9687
9894
|
}),
|
|
9688
|
-
createdAt: (0,
|
|
9895
|
+
createdAt: (0, import_mysql_core21.timestamp)("createdAt", {
|
|
9689
9896
|
mode: "date",
|
|
9690
9897
|
fsp: 3
|
|
9691
|
-
}).default(
|
|
9898
|
+
}).default(import_drizzle_orm21.sql`CURRENT_TIMESTAMP(3)`)
|
|
9692
9899
|
}, (organization) => ({
|
|
9693
|
-
createdAtIdx: (0,
|
|
9900
|
+
createdAtIdx: (0, import_mysql_core21.index)("created_at_idx").on(organization.createdAt)
|
|
9694
9901
|
}));
|
|
9695
9902
|
}
|
|
9696
9903
|
__name(getOrganizationsSchema, "getOrganizationsSchema");
|
|
@@ -9699,47 +9906,123 @@ function getOrganizationsRelationsSchema(mysqlTable) {
|
|
|
9699
9906
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
9700
9907
|
const subscriptions = getSubscriptionSchema(mysqlTable);
|
|
9701
9908
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
9702
|
-
return (0,
|
|
9909
|
+
return (0, import_drizzle_orm21.relations)(organizations, ({ many }) => ({
|
|
9703
9910
|
purchases: many(purchases, {
|
|
9704
9911
|
relationName: "organization"
|
|
9705
9912
|
}),
|
|
9706
|
-
subscriptions: many(subscriptions, {
|
|
9707
|
-
relationName: "organization"
|
|
9913
|
+
subscriptions: many(subscriptions, {
|
|
9914
|
+
relationName: "organization"
|
|
9915
|
+
}),
|
|
9916
|
+
members: many(organizationMemberships, {
|
|
9917
|
+
relationName: "organization"
|
|
9918
|
+
})
|
|
9919
|
+
}));
|
|
9920
|
+
}
|
|
9921
|
+
__name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
|
|
9922
|
+
|
|
9923
|
+
// src/lib/mysql/schemas/org/organization-membership-roles.ts
|
|
9924
|
+
function getOrganizationMembershipRolesSchema(mysqlTable) {
|
|
9925
|
+
return mysqlTable("OrganizationMembershipRole", {
|
|
9926
|
+
organizationMembershipId: (0, import_mysql_core22.varchar)("organizationMembershipId", {
|
|
9927
|
+
length: 255
|
|
9928
|
+
}).notNull(),
|
|
9929
|
+
roleId: (0, import_mysql_core22.varchar)("roleId", {
|
|
9930
|
+
length: 255
|
|
9931
|
+
}).notNull(),
|
|
9932
|
+
active: (0, import_mysql_core22.boolean)("active").notNull().default(true),
|
|
9933
|
+
organizationId: (0, import_mysql_core22.varchar)("organizationId", {
|
|
9934
|
+
length: 191
|
|
9935
|
+
}),
|
|
9936
|
+
createdAt: (0, import_mysql_core22.timestamp)("createdAt", {
|
|
9937
|
+
mode: "date",
|
|
9938
|
+
fsp: 3
|
|
9939
|
+
}).defaultNow(),
|
|
9940
|
+
updatedAt: (0, import_mysql_core22.timestamp)("updatedAt", {
|
|
9941
|
+
mode: "date",
|
|
9942
|
+
fsp: 3
|
|
9943
|
+
}).defaultNow(),
|
|
9944
|
+
deletedAt: (0, import_mysql_core22.timestamp)("deletedAt", {
|
|
9945
|
+
mode: "date",
|
|
9946
|
+
fsp: 3
|
|
9947
|
+
})
|
|
9948
|
+
}, (ur) => ({
|
|
9949
|
+
pk: (0, import_mysql_core22.primaryKey)({
|
|
9950
|
+
columns: [
|
|
9951
|
+
ur.organizationMembershipId,
|
|
9952
|
+
ur.roleId
|
|
9953
|
+
],
|
|
9954
|
+
name: "pk"
|
|
9955
|
+
}),
|
|
9956
|
+
orgMemberIdIdx: (0, import_mysql_core22.index)("orgMemberId_idx").on(ur.organizationMembershipId),
|
|
9957
|
+
roleIdIdx: (0, import_mysql_core22.index)("roleId_idx").on(ur.roleId),
|
|
9958
|
+
organizationIdIdx: (0, import_mysql_core22.index)("organizationId_idx").on(ur.organizationId)
|
|
9959
|
+
}));
|
|
9960
|
+
}
|
|
9961
|
+
__name(getOrganizationMembershipRolesSchema, "getOrganizationMembershipRolesSchema");
|
|
9962
|
+
function getOrganizationMembershipRolesRelationsSchema(mysqlTable) {
|
|
9963
|
+
const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
|
|
9964
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
9965
|
+
const roles = getRolesSchema(mysqlTable);
|
|
9966
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
9967
|
+
return (0, import_drizzle_orm22.relations)(organizationMembershipRoles, ({ one }) => ({
|
|
9968
|
+
organizationMembership: one(organizationMemberships, {
|
|
9969
|
+
fields: [
|
|
9970
|
+
organizationMembershipRoles.organizationMembershipId
|
|
9971
|
+
],
|
|
9972
|
+
references: [
|
|
9973
|
+
organizationMemberships.id
|
|
9974
|
+
],
|
|
9975
|
+
relationName: "organizationMembership"
|
|
9976
|
+
}),
|
|
9977
|
+
role: one(roles, {
|
|
9978
|
+
fields: [
|
|
9979
|
+
organizationMembershipRoles.roleId
|
|
9980
|
+
],
|
|
9981
|
+
references: [
|
|
9982
|
+
roles.id
|
|
9983
|
+
],
|
|
9984
|
+
relationName: "role"
|
|
9708
9985
|
}),
|
|
9709
|
-
|
|
9986
|
+
organization: one(organizations, {
|
|
9987
|
+
fields: [
|
|
9988
|
+
organizationMembershipRoles.organizationId
|
|
9989
|
+
],
|
|
9990
|
+
references: [
|
|
9991
|
+
organizations.id
|
|
9992
|
+
],
|
|
9710
9993
|
relationName: "organization"
|
|
9711
9994
|
})
|
|
9712
9995
|
}));
|
|
9713
9996
|
}
|
|
9714
|
-
__name(
|
|
9997
|
+
__name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
|
|
9715
9998
|
|
|
9716
9999
|
// src/lib/mysql/schemas/org/organization-memberships.ts
|
|
9717
10000
|
function getOrganizationMembershipsSchema(mysqlTable) {
|
|
9718
10001
|
return mysqlTable("OrganizationMembership", {
|
|
9719
|
-
id: (0,
|
|
10002
|
+
id: (0, import_mysql_core23.varchar)("id", {
|
|
9720
10003
|
length: 255
|
|
9721
10004
|
}).notNull().primaryKey(),
|
|
9722
|
-
organizationId: (0,
|
|
10005
|
+
organizationId: (0, import_mysql_core23.varchar)("organizationId", {
|
|
9723
10006
|
length: 191
|
|
9724
10007
|
}),
|
|
9725
|
-
role: (0,
|
|
10008
|
+
role: (0, import_mysql_core23.varchar)("role", {
|
|
9726
10009
|
length: 191
|
|
9727
10010
|
}).notNull().default("user"),
|
|
9728
|
-
invitedById: (0,
|
|
10011
|
+
invitedById: (0, import_mysql_core23.varchar)("invitedById", {
|
|
9729
10012
|
length: 255
|
|
9730
10013
|
}).notNull(),
|
|
9731
|
-
userId: (0,
|
|
10014
|
+
userId: (0, import_mysql_core23.varchar)("userId", {
|
|
9732
10015
|
length: 255
|
|
9733
10016
|
}).notNull(),
|
|
9734
|
-
fields: (0,
|
|
9735
|
-
createdAt: (0,
|
|
10017
|
+
fields: (0, import_mysql_core23.json)("fields").$type().default({}),
|
|
10018
|
+
createdAt: (0, import_mysql_core23.timestamp)("createdAt", {
|
|
9736
10019
|
mode: "date",
|
|
9737
10020
|
fsp: 3
|
|
9738
|
-
}).default(
|
|
10021
|
+
}).default(import_drizzle_orm23.sql`CURRENT_TIMESTAMP(3)`)
|
|
9739
10022
|
}, (organizationMembership) => ({
|
|
9740
|
-
roleIdx: (0,
|
|
9741
|
-
createdAtIdx: (0,
|
|
9742
|
-
organizationIdIdx: (0,
|
|
10023
|
+
roleIdx: (0, import_mysql_core23.index)("role_idx").on(organizationMembership.role),
|
|
10024
|
+
createdAtIdx: (0, import_mysql_core23.index)("created_at_idx").on(organizationMembership.createdAt),
|
|
10025
|
+
organizationIdIdx: (0, import_mysql_core23.index)("organizationId_idx").on(organizationMembership.organizationId)
|
|
9743
10026
|
}));
|
|
9744
10027
|
}
|
|
9745
10028
|
__name(getOrganizationMembershipsSchema, "getOrganizationMembershipsSchema");
|
|
@@ -9748,7 +10031,8 @@ function getOrganizationMembershipsRelationsSchema(mysqlTable) {
|
|
|
9748
10031
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
9749
10032
|
const purchases = getPurchaseSchema(mysqlTable);
|
|
9750
10033
|
const organizations = getOrganizationsSchema(mysqlTable);
|
|
9751
|
-
|
|
10034
|
+
const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
|
|
10035
|
+
return (0, import_drizzle_orm23.relations)(organizationMemberships, ({ one, many }) => ({
|
|
9752
10036
|
user: one(users, {
|
|
9753
10037
|
fields: [
|
|
9754
10038
|
organizationMemberships.userId
|
|
@@ -9776,49 +10060,52 @@ function getOrganizationMembershipsRelationsSchema(mysqlTable) {
|
|
|
9776
10060
|
organizations.id
|
|
9777
10061
|
],
|
|
9778
10062
|
relationName: "organization"
|
|
10063
|
+
}),
|
|
10064
|
+
organizationMembershipRoles: many(organizationMembershipRoles, {
|
|
10065
|
+
relationName: "organizationMembership"
|
|
9779
10066
|
})
|
|
9780
10067
|
}));
|
|
9781
10068
|
}
|
|
9782
10069
|
__name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
|
|
9783
10070
|
|
|
9784
10071
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
9785
|
-
var
|
|
9786
|
-
var
|
|
10072
|
+
var import_drizzle_orm24 = require("drizzle-orm");
|
|
10073
|
+
var import_mysql_core25 = require("drizzle-orm/mysql-core");
|
|
9787
10074
|
|
|
9788
10075
|
// src/lib/mysql/schemas/commerce/merchant-coupon.ts
|
|
9789
|
-
var
|
|
10076
|
+
var import_mysql_core24 = require("drizzle-orm/mysql-core");
|
|
9790
10077
|
function getMerchantCouponSchema(mysqlTable) {
|
|
9791
10078
|
return mysqlTable("MerchantCoupon", {
|
|
9792
|
-
id: (0,
|
|
10079
|
+
id: (0, import_mysql_core24.varchar)("id", {
|
|
9793
10080
|
length: 191
|
|
9794
10081
|
}).notNull(),
|
|
9795
|
-
identifier: (0,
|
|
10082
|
+
identifier: (0, import_mysql_core24.varchar)("identifier", {
|
|
9796
10083
|
length: 191
|
|
9797
10084
|
}),
|
|
9798
|
-
organizationId: (0,
|
|
10085
|
+
organizationId: (0, import_mysql_core24.varchar)("organizationId", {
|
|
9799
10086
|
length: 191
|
|
9800
10087
|
}),
|
|
9801
|
-
status: (0,
|
|
9802
|
-
merchantAccountId: (0,
|
|
10088
|
+
status: (0, import_mysql_core24.int)("status").default(0).notNull(),
|
|
10089
|
+
merchantAccountId: (0, import_mysql_core24.varchar)("merchantAccountId", {
|
|
9803
10090
|
length: 191
|
|
9804
10091
|
}).notNull(),
|
|
9805
|
-
percentageDiscount: (0,
|
|
10092
|
+
percentageDiscount: (0, import_mysql_core24.decimal)("percentageDiscount", {
|
|
9806
10093
|
precision: 3,
|
|
9807
10094
|
scale: 2
|
|
9808
10095
|
}).notNull(),
|
|
9809
|
-
type: (0,
|
|
10096
|
+
type: (0, import_mysql_core24.varchar)("type", {
|
|
9810
10097
|
length: 191
|
|
9811
10098
|
})
|
|
9812
10099
|
}, (table) => {
|
|
9813
10100
|
return {
|
|
9814
|
-
merchantCouponId: (0,
|
|
10101
|
+
merchantCouponId: (0, import_mysql_core24.primaryKey)({
|
|
9815
10102
|
columns: [
|
|
9816
10103
|
table.id
|
|
9817
10104
|
],
|
|
9818
10105
|
name: "MerchantCoupon_id"
|
|
9819
10106
|
}),
|
|
9820
|
-
merchantCouponIdentifierKey: (0,
|
|
9821
|
-
organizationIdIdx: (0,
|
|
10107
|
+
merchantCouponIdentifierKey: (0, import_mysql_core24.unique)("MerchantCoupon_identifier_key").on(table.identifier),
|
|
10108
|
+
organizationIdIdx: (0, import_mysql_core24.index)("organizationId_idx").on(table.organizationId)
|
|
9822
10109
|
};
|
|
9823
10110
|
});
|
|
9824
10111
|
}
|
|
@@ -9827,49 +10114,49 @@ __name(getMerchantCouponSchema, "getMerchantCouponSchema");
|
|
|
9827
10114
|
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
9828
10115
|
function getCouponSchema(mysqlTable) {
|
|
9829
10116
|
return mysqlTable("Coupon", {
|
|
9830
|
-
id: (0,
|
|
10117
|
+
id: (0, import_mysql_core25.varchar)("id", {
|
|
9831
10118
|
length: 191
|
|
9832
10119
|
}).notNull(),
|
|
9833
|
-
organizationId: (0,
|
|
10120
|
+
organizationId: (0, import_mysql_core25.varchar)("organizationId", {
|
|
9834
10121
|
length: 191
|
|
9835
10122
|
}),
|
|
9836
|
-
code: (0,
|
|
10123
|
+
code: (0, import_mysql_core25.varchar)("code", {
|
|
9837
10124
|
length: 191
|
|
9838
10125
|
}),
|
|
9839
|
-
createdAt: (0,
|
|
10126
|
+
createdAt: (0, import_mysql_core25.timestamp)("createdAt", {
|
|
9840
10127
|
mode: "date",
|
|
9841
10128
|
fsp: 3
|
|
9842
|
-
}).default(
|
|
9843
|
-
expires: (0,
|
|
10129
|
+
}).default(import_drizzle_orm24.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
10130
|
+
expires: (0, import_mysql_core25.timestamp)("expires", {
|
|
9844
10131
|
mode: "date",
|
|
9845
10132
|
fsp: 3
|
|
9846
10133
|
}),
|
|
9847
|
-
fields: (0,
|
|
9848
|
-
maxUses: (0,
|
|
9849
|
-
default: (0,
|
|
9850
|
-
merchantCouponId: (0,
|
|
10134
|
+
fields: (0, import_mysql_core25.json)("fields").$type().default({}),
|
|
10135
|
+
maxUses: (0, import_mysql_core25.int)("maxUses").default(-1).notNull(),
|
|
10136
|
+
default: (0, import_mysql_core25.boolean)("default").default(false).notNull(),
|
|
10137
|
+
merchantCouponId: (0, import_mysql_core25.varchar)("merchantCouponId", {
|
|
9851
10138
|
length: 191
|
|
9852
10139
|
}),
|
|
9853
|
-
status: (0,
|
|
9854
|
-
usedCount: (0,
|
|
9855
|
-
percentageDiscount: (0,
|
|
10140
|
+
status: (0, import_mysql_core25.int)("status").default(0).notNull(),
|
|
10141
|
+
usedCount: (0, import_mysql_core25.int)("usedCount").default(0).notNull(),
|
|
10142
|
+
percentageDiscount: (0, import_mysql_core25.decimal)("percentageDiscount", {
|
|
9856
10143
|
precision: 3,
|
|
9857
10144
|
scale: 2
|
|
9858
10145
|
}).notNull(),
|
|
9859
|
-
restrictedToProductId: (0,
|
|
10146
|
+
restrictedToProductId: (0, import_mysql_core25.varchar)("restrictedToProductId", {
|
|
9860
10147
|
length: 191
|
|
9861
10148
|
})
|
|
9862
10149
|
}, (table) => {
|
|
9863
10150
|
return {
|
|
9864
|
-
couponIdCodeIndex: (0,
|
|
9865
|
-
couponId: (0,
|
|
10151
|
+
couponIdCodeIndex: (0, import_mysql_core25.index)("Coupon_id_code_index").on(table.id, table.code),
|
|
10152
|
+
couponId: (0, import_mysql_core25.primaryKey)({
|
|
9866
10153
|
columns: [
|
|
9867
10154
|
table.id
|
|
9868
10155
|
],
|
|
9869
10156
|
name: "Coupon_id"
|
|
9870
10157
|
}),
|
|
9871
|
-
couponCodeKey: (0,
|
|
9872
|
-
organizationIdIdx: (0,
|
|
10158
|
+
couponCodeKey: (0, import_mysql_core25.unique)("Coupon_code_key").on(table.code),
|
|
10159
|
+
organizationIdIdx: (0, import_mysql_core25.index)("organizationId_idx").on(table.organizationId)
|
|
9873
10160
|
};
|
|
9874
10161
|
});
|
|
9875
10162
|
}
|
|
@@ -9878,7 +10165,7 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
9878
10165
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
9879
10166
|
const coupon = getCouponSchema(mysqlTable);
|
|
9880
10167
|
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
9881
|
-
return (0,
|
|
10168
|
+
return (0, import_drizzle_orm24.relations)(coupon, ({ many, one }) => ({
|
|
9882
10169
|
redeemedBulkCouponPurchases: many(purchase, {
|
|
9883
10170
|
relationName: "redeemedBulkCoupon"
|
|
9884
10171
|
}),
|
|
@@ -9908,30 +10195,30 @@ function getCouponRelationsSchema(mysqlTable) {
|
|
|
9908
10195
|
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
9909
10196
|
|
|
9910
10197
|
// src/lib/mysql/schemas/commerce/merchant-session.ts
|
|
9911
|
-
var
|
|
10198
|
+
var import_mysql_core26 = require("drizzle-orm/mysql-core");
|
|
9912
10199
|
function getMerchantSessionSchema(mysqlTable) {
|
|
9913
10200
|
return mysqlTable("MerchantSession", {
|
|
9914
|
-
id: (0,
|
|
10201
|
+
id: (0, import_mysql_core26.varchar)("id", {
|
|
9915
10202
|
length: 191
|
|
9916
10203
|
}).notNull(),
|
|
9917
|
-
organizationId: (0,
|
|
10204
|
+
organizationId: (0, import_mysql_core26.varchar)("organizationId", {
|
|
9918
10205
|
length: 191
|
|
9919
10206
|
}),
|
|
9920
|
-
identifier: (0,
|
|
10207
|
+
identifier: (0, import_mysql_core26.varchar)("identifier", {
|
|
9921
10208
|
length: 191
|
|
9922
10209
|
}).notNull(),
|
|
9923
|
-
merchantAccountId: (0,
|
|
10210
|
+
merchantAccountId: (0, import_mysql_core26.varchar)("merchantAccountId", {
|
|
9924
10211
|
length: 191
|
|
9925
10212
|
}).notNull()
|
|
9926
10213
|
}, (table) => {
|
|
9927
10214
|
return {
|
|
9928
|
-
merchantSessionId: (0,
|
|
10215
|
+
merchantSessionId: (0, import_mysql_core26.primaryKey)({
|
|
9929
10216
|
columns: [
|
|
9930
10217
|
table.id
|
|
9931
10218
|
],
|
|
9932
10219
|
name: "MerchantSession_id"
|
|
9933
10220
|
}),
|
|
9934
|
-
organizationIdIdx: (0,
|
|
10221
|
+
organizationIdIdx: (0, import_mysql_core26.index)("organizationId_idx").on(table.organizationId)
|
|
9935
10222
|
};
|
|
9936
10223
|
});
|
|
9937
10224
|
}
|
|
@@ -9940,75 +10227,75 @@ __name(getMerchantSessionSchema, "getMerchantSessionSchema");
|
|
|
9940
10227
|
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
9941
10228
|
function getPurchaseSchema(mysqlTable) {
|
|
9942
10229
|
return mysqlTable("Purchase", {
|
|
9943
|
-
id: (0,
|
|
10230
|
+
id: (0, import_mysql_core27.varchar)("id", {
|
|
9944
10231
|
length: 191
|
|
9945
10232
|
}).notNull(),
|
|
9946
|
-
userId: (0,
|
|
10233
|
+
userId: (0, import_mysql_core27.varchar)("userId", {
|
|
9947
10234
|
length: 191
|
|
9948
10235
|
}),
|
|
9949
|
-
purchasedByorganizationMembershipId: (0,
|
|
10236
|
+
purchasedByorganizationMembershipId: (0, import_mysql_core27.varchar)("organizationMembershipId", {
|
|
9950
10237
|
length: 191
|
|
9951
10238
|
}),
|
|
9952
|
-
organizationId: (0,
|
|
10239
|
+
organizationId: (0, import_mysql_core27.varchar)("organizationId", {
|
|
9953
10240
|
length: 191
|
|
9954
10241
|
}),
|
|
9955
|
-
createdAt: (0,
|
|
10242
|
+
createdAt: (0, import_mysql_core27.timestamp)("createdAt", {
|
|
9956
10243
|
mode: "date",
|
|
9957
10244
|
fsp: 3
|
|
9958
|
-
}).default(
|
|
9959
|
-
totalAmount: (0,
|
|
10245
|
+
}).default(import_drizzle_orm25.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
10246
|
+
totalAmount: (0, import_mysql_core27.decimal)("totalAmount", {
|
|
9960
10247
|
precision: 65,
|
|
9961
10248
|
scale: 30
|
|
9962
10249
|
}).notNull(),
|
|
9963
|
-
ipAddress: (0,
|
|
10250
|
+
ipAddress: (0, import_mysql_core27.varchar)("ip_address", {
|
|
9964
10251
|
length: 191
|
|
9965
10252
|
}),
|
|
9966
|
-
city: (0,
|
|
10253
|
+
city: (0, import_mysql_core27.varchar)("city", {
|
|
9967
10254
|
length: 191
|
|
9968
10255
|
}),
|
|
9969
|
-
state: (0,
|
|
10256
|
+
state: (0, import_mysql_core27.varchar)("state", {
|
|
9970
10257
|
length: 191
|
|
9971
10258
|
}),
|
|
9972
|
-
country: (0,
|
|
10259
|
+
country: (0, import_mysql_core27.varchar)("country", {
|
|
9973
10260
|
length: 191
|
|
9974
10261
|
}),
|
|
9975
|
-
couponId: (0,
|
|
10262
|
+
couponId: (0, import_mysql_core27.varchar)("couponId", {
|
|
9976
10263
|
length: 191
|
|
9977
10264
|
}),
|
|
9978
|
-
productId: (0,
|
|
10265
|
+
productId: (0, import_mysql_core27.varchar)("productId", {
|
|
9979
10266
|
length: 191
|
|
9980
10267
|
}).notNull(),
|
|
9981
|
-
merchantChargeId: (0,
|
|
10268
|
+
merchantChargeId: (0, import_mysql_core27.varchar)("merchantChargeId", {
|
|
9982
10269
|
length: 191
|
|
9983
10270
|
}),
|
|
9984
|
-
upgradedFromId: (0,
|
|
10271
|
+
upgradedFromId: (0, import_mysql_core27.varchar)("upgradedFromId", {
|
|
9985
10272
|
length: 191
|
|
9986
10273
|
}),
|
|
9987
|
-
status: (0,
|
|
10274
|
+
status: (0, import_mysql_core27.varchar)("status", {
|
|
9988
10275
|
length: 191
|
|
9989
10276
|
}).default("Valid").notNull(),
|
|
9990
|
-
bulkCouponId: (0,
|
|
10277
|
+
bulkCouponId: (0, import_mysql_core27.varchar)("bulkCouponId", {
|
|
9991
10278
|
length: 191
|
|
9992
10279
|
}),
|
|
9993
|
-
merchantSessionId: (0,
|
|
10280
|
+
merchantSessionId: (0, import_mysql_core27.varchar)("merchantSessionId", {
|
|
9994
10281
|
length: 191
|
|
9995
10282
|
}),
|
|
9996
|
-
redeemedBulkCouponId: (0,
|
|
10283
|
+
redeemedBulkCouponId: (0, import_mysql_core27.varchar)("redeemedBulkCouponId", {
|
|
9997
10284
|
length: 191
|
|
9998
10285
|
}),
|
|
9999
|
-
fields: (0,
|
|
10286
|
+
fields: (0, import_mysql_core27.json)("fields").$type().default({})
|
|
10000
10287
|
}, (table) => {
|
|
10001
10288
|
return {
|
|
10002
|
-
purchaseId: (0,
|
|
10289
|
+
purchaseId: (0, import_mysql_core27.primaryKey)({
|
|
10003
10290
|
columns: [
|
|
10004
10291
|
table.id
|
|
10005
10292
|
],
|
|
10006
10293
|
name: "Purchase_id"
|
|
10007
10294
|
}),
|
|
10008
|
-
merchantChargeIdIdx: (0,
|
|
10009
|
-
purchaseUpgradedFromIdKey: (0,
|
|
10010
|
-
organizationIdIdx: (0,
|
|
10011
|
-
organizationMembershipIdIdx: (0,
|
|
10295
|
+
merchantChargeIdIdx: (0, import_mysql_core27.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
10296
|
+
purchaseUpgradedFromIdKey: (0, import_mysql_core27.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId),
|
|
10297
|
+
organizationIdIdx: (0, import_mysql_core27.index)("organizationId_idx").on(table.organizationId),
|
|
10298
|
+
organizationMembershipIdIdx: (0, import_mysql_core27.index)("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId)
|
|
10012
10299
|
};
|
|
10013
10300
|
});
|
|
10014
10301
|
}
|
|
@@ -10022,7 +10309,7 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
10022
10309
|
const coupons = getCouponSchema(mysqlTable);
|
|
10023
10310
|
const organizations = getOrganizationsSchema(mysqlTable);
|
|
10024
10311
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
10025
|
-
return (0,
|
|
10312
|
+
return (0, import_drizzle_orm25.relations)(purchases, ({ many, one }) => ({
|
|
10026
10313
|
redeemedBulkCoupon: one(coupons, {
|
|
10027
10314
|
fields: [
|
|
10028
10315
|
purchases.redeemedBulkCouponId
|
|
@@ -10100,41 +10387,41 @@ function getPurchaseRelationsSchema(mysqlTable) {
|
|
|
10100
10387
|
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
10101
10388
|
|
|
10102
10389
|
// src/lib/mysql/schemas/communication/comment.ts
|
|
10103
|
-
var
|
|
10104
|
-
var
|
|
10390
|
+
var import_drizzle_orm26 = require("drizzle-orm");
|
|
10391
|
+
var import_mysql_core28 = require("drizzle-orm/mysql-core");
|
|
10105
10392
|
function getCommentsSchema(mysqlTable) {
|
|
10106
10393
|
return mysqlTable("Comment", {
|
|
10107
|
-
id: (0,
|
|
10394
|
+
id: (0, import_mysql_core28.varchar)("id", {
|
|
10108
10395
|
length: 191
|
|
10109
10396
|
}).notNull(),
|
|
10110
|
-
userId: (0,
|
|
10397
|
+
userId: (0, import_mysql_core28.varchar)("userId", {
|
|
10111
10398
|
length: 255
|
|
10112
10399
|
}).notNull(),
|
|
10113
|
-
organizationMembershipId: (0,
|
|
10400
|
+
organizationMembershipId: (0, import_mysql_core28.varchar)("organizationMembershipId", {
|
|
10114
10401
|
length: 255
|
|
10115
10402
|
}),
|
|
10116
|
-
context: (0,
|
|
10117
|
-
text: (0,
|
|
10118
|
-
createdAt: (0,
|
|
10403
|
+
context: (0, import_mysql_core28.json)("context").$type().default({}),
|
|
10404
|
+
text: (0, import_mysql_core28.text)("text").notNull(),
|
|
10405
|
+
createdAt: (0, import_mysql_core28.timestamp)("createdAt", {
|
|
10119
10406
|
mode: "date",
|
|
10120
10407
|
fsp: 3
|
|
10121
|
-
}).default(
|
|
10122
|
-
updatedAt: (0,
|
|
10408
|
+
}).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`),
|
|
10409
|
+
updatedAt: (0, import_mysql_core28.timestamp)("updatedAt", {
|
|
10123
10410
|
mode: "date",
|
|
10124
10411
|
fsp: 3
|
|
10125
|
-
}).default(
|
|
10126
|
-
deletedAt: (0,
|
|
10412
|
+
}).default(import_drizzle_orm26.sql`CURRENT_TIMESTAMP(3)`),
|
|
10413
|
+
deletedAt: (0, import_mysql_core28.timestamp)("deletedAt", {
|
|
10127
10414
|
mode: "date",
|
|
10128
10415
|
fsp: 3
|
|
10129
10416
|
})
|
|
10130
10417
|
}, (crr) => ({
|
|
10131
|
-
pk: (0,
|
|
10418
|
+
pk: (0, import_mysql_core28.primaryKey)({
|
|
10132
10419
|
columns: [
|
|
10133
10420
|
crr.id
|
|
10134
10421
|
]
|
|
10135
10422
|
}),
|
|
10136
|
-
crrUserIdIdKey: (0,
|
|
10137
|
-
organizationMembershipIdIdx: (0,
|
|
10423
|
+
crrUserIdIdKey: (0, import_mysql_core28.index)("crr_userIdId_idx").on(crr.userId),
|
|
10424
|
+
organizationMembershipIdIdx: (0, import_mysql_core28.index)("organizationMembershipId_idx").on(crr.organizationMembershipId)
|
|
10138
10425
|
}));
|
|
10139
10426
|
}
|
|
10140
10427
|
__name(getCommentsSchema, "getCommentsSchema");
|
|
@@ -10142,7 +10429,7 @@ function getCommentRelationsSchema(mysqlTable) {
|
|
|
10142
10429
|
const comment = getCommentsSchema(mysqlTable);
|
|
10143
10430
|
const user = getUsersSchema(mysqlTable);
|
|
10144
10431
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
10145
|
-
return (0,
|
|
10432
|
+
return (0, import_drizzle_orm26.relations)(comment, ({ one }) => ({
|
|
10146
10433
|
user: one(user, {
|
|
10147
10434
|
fields: [
|
|
10148
10435
|
comment.userId
|
|
@@ -10166,67 +10453,67 @@ function getCommentRelationsSchema(mysqlTable) {
|
|
|
10166
10453
|
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
10167
10454
|
|
|
10168
10455
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
10169
|
-
var
|
|
10170
|
-
var
|
|
10456
|
+
var import_drizzle_orm27 = require("drizzle-orm");
|
|
10457
|
+
var import_mysql_core31 = require("drizzle-orm/mysql-core");
|
|
10171
10458
|
|
|
10172
10459
|
// src/lib/mysql/schemas/communication/communication-channel.ts
|
|
10173
|
-
var
|
|
10460
|
+
var import_mysql_core29 = require("drizzle-orm/mysql-core");
|
|
10174
10461
|
function getCommunicationChannelSchema(mysqlTable) {
|
|
10175
10462
|
return mysqlTable("CommunicationChannel", {
|
|
10176
|
-
id: (0,
|
|
10463
|
+
id: (0, import_mysql_core29.varchar)("id", {
|
|
10177
10464
|
length: 255
|
|
10178
10465
|
}).notNull().primaryKey(),
|
|
10179
|
-
organizationId: (0,
|
|
10466
|
+
organizationId: (0, import_mysql_core29.varchar)("organizationId", {
|
|
10180
10467
|
length: 191
|
|
10181
10468
|
}),
|
|
10182
|
-
name: (0,
|
|
10469
|
+
name: (0, import_mysql_core29.varchar)("name", {
|
|
10183
10470
|
length: 255
|
|
10184
10471
|
}).notNull(),
|
|
10185
|
-
description: (0,
|
|
10186
|
-
active: (0,
|
|
10187
|
-
createdAt: (0,
|
|
10472
|
+
description: (0, import_mysql_core29.text)("description"),
|
|
10473
|
+
active: (0, import_mysql_core29.boolean)("active").notNull().default(true),
|
|
10474
|
+
createdAt: (0, import_mysql_core29.timestamp)("createdAt", {
|
|
10188
10475
|
mode: "date",
|
|
10189
10476
|
fsp: 3
|
|
10190
10477
|
}).defaultNow(),
|
|
10191
|
-
updatedAt: (0,
|
|
10478
|
+
updatedAt: (0, import_mysql_core29.timestamp)("updatedAt", {
|
|
10192
10479
|
mode: "date",
|
|
10193
10480
|
fsp: 3
|
|
10194
10481
|
}).defaultNow(),
|
|
10195
|
-
deletedAt: (0,
|
|
10482
|
+
deletedAt: (0, import_mysql_core29.timestamp)("deletedAt", {
|
|
10196
10483
|
mode: "date",
|
|
10197
10484
|
fsp: 3
|
|
10198
10485
|
})
|
|
10199
10486
|
}, (cc) => ({
|
|
10200
|
-
nameIdx: (0,
|
|
10201
|
-
organizationIdIdx: (0,
|
|
10487
|
+
nameIdx: (0, import_mysql_core29.index)("name_idx").on(cc.name),
|
|
10488
|
+
organizationIdIdx: (0, import_mysql_core29.index)("organizationId_idx").on(cc.organizationId)
|
|
10202
10489
|
}));
|
|
10203
10490
|
}
|
|
10204
10491
|
__name(getCommunicationChannelSchema, "getCommunicationChannelSchema");
|
|
10205
10492
|
|
|
10206
10493
|
// src/lib/mysql/schemas/communication/communication-preference-types.ts
|
|
10207
|
-
var
|
|
10494
|
+
var import_mysql_core30 = require("drizzle-orm/mysql-core");
|
|
10208
10495
|
function getCommunicationPreferenceTypesSchema(mysqlTable) {
|
|
10209
10496
|
return mysqlTable("CommunicationPreferenceType", {
|
|
10210
|
-
id: (0,
|
|
10497
|
+
id: (0, import_mysql_core30.varchar)("id", {
|
|
10211
10498
|
length: 255
|
|
10212
10499
|
}).notNull().primaryKey(),
|
|
10213
|
-
organizationId: (0,
|
|
10500
|
+
organizationId: (0, import_mysql_core30.varchar)("organizationId", {
|
|
10214
10501
|
length: 191
|
|
10215
10502
|
}),
|
|
10216
|
-
name: (0,
|
|
10503
|
+
name: (0, import_mysql_core30.varchar)("name", {
|
|
10217
10504
|
length: 255
|
|
10218
10505
|
}).notNull(),
|
|
10219
|
-
description: (0,
|
|
10220
|
-
active: (0,
|
|
10221
|
-
createdAt: (0,
|
|
10506
|
+
description: (0, import_mysql_core30.text)("description"),
|
|
10507
|
+
active: (0, import_mysql_core30.boolean)("active").notNull().default(true),
|
|
10508
|
+
createdAt: (0, import_mysql_core30.timestamp)("createdAt", {
|
|
10222
10509
|
mode: "date",
|
|
10223
10510
|
fsp: 3
|
|
10224
10511
|
}).defaultNow(),
|
|
10225
|
-
updatedAt: (0,
|
|
10512
|
+
updatedAt: (0, import_mysql_core30.timestamp)("updatedAt", {
|
|
10226
10513
|
mode: "date",
|
|
10227
10514
|
fsp: 3
|
|
10228
10515
|
}),
|
|
10229
|
-
deletedAt: (0,
|
|
10516
|
+
deletedAt: (0, import_mysql_core30.timestamp)("deletedAt", {
|
|
10230
10517
|
mode: "date",
|
|
10231
10518
|
fsp: 3
|
|
10232
10519
|
})
|
|
@@ -10237,55 +10524,55 @@ __name(getCommunicationPreferenceTypesSchema, "getCommunicationPreferenceTypesSc
|
|
|
10237
10524
|
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
10238
10525
|
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
10239
10526
|
return mysqlTable("CommunicationPreference", {
|
|
10240
|
-
id: (0,
|
|
10527
|
+
id: (0, import_mysql_core31.varchar)("id", {
|
|
10241
10528
|
length: 255
|
|
10242
10529
|
}).notNull().primaryKey(),
|
|
10243
|
-
organizationId: (0,
|
|
10530
|
+
organizationId: (0, import_mysql_core31.varchar)("organizationId", {
|
|
10244
10531
|
length: 191
|
|
10245
10532
|
}),
|
|
10246
|
-
userId: (0,
|
|
10533
|
+
userId: (0, import_mysql_core31.varchar)("userId", {
|
|
10247
10534
|
length: 255
|
|
10248
10535
|
}).notNull(),
|
|
10249
|
-
organizationMembershipId: (0,
|
|
10536
|
+
organizationMembershipId: (0, import_mysql_core31.varchar)("organizationMembershipId", {
|
|
10250
10537
|
length: 255
|
|
10251
10538
|
}),
|
|
10252
|
-
channelId: (0,
|
|
10539
|
+
channelId: (0, import_mysql_core31.varchar)("channelId", {
|
|
10253
10540
|
length: 255
|
|
10254
10541
|
}).notNull(),
|
|
10255
|
-
preferenceLevel: (0,
|
|
10542
|
+
preferenceLevel: (0, import_mysql_core31.mysqlEnum)("preferenceLevel", [
|
|
10256
10543
|
"low",
|
|
10257
10544
|
"medium",
|
|
10258
10545
|
"high"
|
|
10259
10546
|
]).notNull().default("medium"),
|
|
10260
|
-
preferenceTypeId: (0,
|
|
10547
|
+
preferenceTypeId: (0, import_mysql_core31.varchar)("preferenceTypeId", {
|
|
10261
10548
|
length: 255
|
|
10262
10549
|
}).notNull(),
|
|
10263
|
-
active: (0,
|
|
10264
|
-
createdAt: (0,
|
|
10550
|
+
active: (0, import_mysql_core31.boolean)("active").notNull().default(true),
|
|
10551
|
+
createdAt: (0, import_mysql_core31.timestamp)("createdAt", {
|
|
10265
10552
|
mode: "date",
|
|
10266
10553
|
fsp: 3
|
|
10267
10554
|
}).defaultNow(),
|
|
10268
|
-
optInAt: (0,
|
|
10555
|
+
optInAt: (0, import_mysql_core31.timestamp)("optInAt", {
|
|
10269
10556
|
mode: "date",
|
|
10270
10557
|
fsp: 3
|
|
10271
10558
|
}),
|
|
10272
|
-
optOutAt: (0,
|
|
10559
|
+
optOutAt: (0, import_mysql_core31.timestamp)("optOutAt", {
|
|
10273
10560
|
mode: "date",
|
|
10274
10561
|
fsp: 3
|
|
10275
10562
|
}),
|
|
10276
|
-
updatedAt: (0,
|
|
10563
|
+
updatedAt: (0, import_mysql_core31.timestamp)("updatedAt", {
|
|
10277
10564
|
mode: "date",
|
|
10278
10565
|
fsp: 3
|
|
10279
10566
|
}).defaultNow(),
|
|
10280
|
-
deletedAt: (0,
|
|
10567
|
+
deletedAt: (0, import_mysql_core31.timestamp)("deletedAt", {
|
|
10281
10568
|
mode: "date",
|
|
10282
10569
|
fsp: 3
|
|
10283
10570
|
})
|
|
10284
10571
|
}, (cp) => ({
|
|
10285
|
-
userIdIdx: (0,
|
|
10286
|
-
preferenceTypeIdx: (0,
|
|
10287
|
-
channelIdIdx: (0,
|
|
10288
|
-
organizationMembershipIdIdx: (0,
|
|
10572
|
+
userIdIdx: (0, import_mysql_core31.index)("userId_idx").on(cp.userId),
|
|
10573
|
+
preferenceTypeIdx: (0, import_mysql_core31.index)("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
10574
|
+
channelIdIdx: (0, import_mysql_core31.index)("channelId_idx").on(cp.channelId),
|
|
10575
|
+
organizationMembershipIdIdx: (0, import_mysql_core31.index)("organizationMembershipId_idx").on(cp.organizationMembershipId)
|
|
10289
10576
|
}));
|
|
10290
10577
|
}
|
|
10291
10578
|
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
@@ -10295,7 +10582,7 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
10295
10582
|
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
10296
10583
|
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
10297
10584
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
10298
|
-
return (0,
|
|
10585
|
+
return (0, import_drizzle_orm27.relations)(communicationPreferences, ({ one }) => ({
|
|
10299
10586
|
user: one(users, {
|
|
10300
10587
|
fields: [
|
|
10301
10588
|
communicationPreferences.userId
|
|
@@ -10336,80 +10623,126 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
|
10336
10623
|
}
|
|
10337
10624
|
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
10338
10625
|
|
|
10626
|
+
// src/lib/mysql/schemas/auth/profiles.ts
|
|
10627
|
+
var import_drizzle_orm28 = require("drizzle-orm");
|
|
10628
|
+
var import_mysql_core32 = require("drizzle-orm/mysql-core");
|
|
10629
|
+
function getProfilesSchema(mysqlTable) {
|
|
10630
|
+
return mysqlTable("Profile", {
|
|
10631
|
+
id: (0, import_mysql_core32.varchar)("id", {
|
|
10632
|
+
length: 255
|
|
10633
|
+
}).notNull().primaryKey(),
|
|
10634
|
+
userId: (0, import_mysql_core32.varchar)("userId", {
|
|
10635
|
+
length: 255
|
|
10636
|
+
}).notNull(),
|
|
10637
|
+
type: (0, import_mysql_core32.varchar)("type", {
|
|
10638
|
+
length: 255
|
|
10639
|
+
}).notNull(),
|
|
10640
|
+
fields: (0, import_mysql_core32.json)("fields").$type().default({}),
|
|
10641
|
+
createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
|
|
10642
|
+
mode: "date",
|
|
10643
|
+
fsp: 3
|
|
10644
|
+
}).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`),
|
|
10645
|
+
updatedAt: (0, import_mysql_core32.timestamp)("updatedAt", {
|
|
10646
|
+
mode: "date",
|
|
10647
|
+
fsp: 3
|
|
10648
|
+
}).default(import_drizzle_orm28.sql`CURRENT_TIMESTAMP(3)`)
|
|
10649
|
+
}, (profile) => ({
|
|
10650
|
+
userIdIdx: (0, import_mysql_core32.index)("userId_idx").on(profile.userId),
|
|
10651
|
+
uniqueUserType: (0, import_mysql_core32.uniqueIndex)("unique_user_type_idx").on(profile.userId, profile.type)
|
|
10652
|
+
}));
|
|
10653
|
+
}
|
|
10654
|
+
__name(getProfilesSchema, "getProfilesSchema");
|
|
10655
|
+
function getProfilesRelationsSchema(mysqlTable) {
|
|
10656
|
+
const profiles = getProfilesSchema(mysqlTable);
|
|
10657
|
+
const users = getUsersSchema(mysqlTable);
|
|
10658
|
+
return (0, import_drizzle_orm28.relations)(profiles, ({ one }) => ({
|
|
10659
|
+
user: one(users, {
|
|
10660
|
+
fields: [
|
|
10661
|
+
profiles.userId
|
|
10662
|
+
],
|
|
10663
|
+
references: [
|
|
10664
|
+
users.id
|
|
10665
|
+
],
|
|
10666
|
+
relationName: "profiles"
|
|
10667
|
+
})
|
|
10668
|
+
}));
|
|
10669
|
+
}
|
|
10670
|
+
__name(getProfilesRelationsSchema, "getProfilesRelationsSchema");
|
|
10671
|
+
|
|
10339
10672
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
10340
|
-
var
|
|
10341
|
-
var
|
|
10673
|
+
var import_drizzle_orm30 = require("drizzle-orm");
|
|
10674
|
+
var import_mysql_core34 = require("drizzle-orm/mysql-core");
|
|
10342
10675
|
|
|
10343
10676
|
// src/lib/mysql/schemas/auth/permissions.ts
|
|
10344
|
-
var
|
|
10345
|
-
var
|
|
10677
|
+
var import_drizzle_orm29 = require("drizzle-orm");
|
|
10678
|
+
var import_mysql_core33 = require("drizzle-orm/mysql-core");
|
|
10346
10679
|
function getPermissionsSchema(mysqlTable) {
|
|
10347
10680
|
return mysqlTable("Permission", {
|
|
10348
|
-
id: (0,
|
|
10681
|
+
id: (0, import_mysql_core33.varchar)("id", {
|
|
10349
10682
|
length: 255
|
|
10350
10683
|
}).notNull().primaryKey(),
|
|
10351
|
-
name: (0,
|
|
10684
|
+
name: (0, import_mysql_core33.varchar)("name", {
|
|
10352
10685
|
length: 255
|
|
10353
10686
|
}).notNull().unique(),
|
|
10354
|
-
description: (0,
|
|
10355
|
-
active: (0,
|
|
10356
|
-
createdAt: (0,
|
|
10687
|
+
description: (0, import_mysql_core33.text)("description"),
|
|
10688
|
+
active: (0, import_mysql_core33.boolean)("active").notNull().default(true),
|
|
10689
|
+
createdAt: (0, import_mysql_core33.timestamp)("createdAt", {
|
|
10357
10690
|
mode: "date",
|
|
10358
10691
|
fsp: 3
|
|
10359
10692
|
}).defaultNow(),
|
|
10360
|
-
updatedAt: (0,
|
|
10693
|
+
updatedAt: (0, import_mysql_core33.timestamp)("updatedAt", {
|
|
10361
10694
|
mode: "date",
|
|
10362
10695
|
fsp: 3
|
|
10363
10696
|
}).defaultNow(),
|
|
10364
|
-
deletedAt: (0,
|
|
10697
|
+
deletedAt: (0, import_mysql_core33.timestamp)("deletedAt", {
|
|
10365
10698
|
mode: "date",
|
|
10366
10699
|
fsp: 3
|
|
10367
10700
|
})
|
|
10368
10701
|
}, (permission) => ({
|
|
10369
|
-
nameIdx: (0,
|
|
10702
|
+
nameIdx: (0, import_mysql_core33.index)("name_idx").on(permission.name)
|
|
10370
10703
|
}));
|
|
10371
10704
|
}
|
|
10372
10705
|
__name(getPermissionsSchema, "getPermissionsSchema");
|
|
10373
10706
|
function getPermissionsRelationsSchema(mysqlTable) {
|
|
10374
|
-
return (0,
|
|
10707
|
+
return (0, import_drizzle_orm29.relations)(getPermissionsSchema(mysqlTable), ({ many }) => ({}));
|
|
10375
10708
|
}
|
|
10376
10709
|
__name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
|
|
10377
10710
|
|
|
10378
10711
|
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
10379
10712
|
function getUserPermissionsSchema(mysqlTable) {
|
|
10380
10713
|
return mysqlTable("UserPermission", {
|
|
10381
|
-
userId: (0,
|
|
10714
|
+
userId: (0, import_mysql_core34.varchar)("userId", {
|
|
10382
10715
|
length: 255
|
|
10383
10716
|
}).notNull(),
|
|
10384
|
-
organizationId: (0,
|
|
10717
|
+
organizationId: (0, import_mysql_core34.varchar)("organizationId", {
|
|
10385
10718
|
length: 191
|
|
10386
10719
|
}),
|
|
10387
|
-
permissionId: (0,
|
|
10720
|
+
permissionId: (0, import_mysql_core34.varchar)("permissionId", {
|
|
10388
10721
|
length: 255
|
|
10389
10722
|
}).notNull(),
|
|
10390
|
-
active: (0,
|
|
10391
|
-
createdAt: (0,
|
|
10723
|
+
active: (0, import_mysql_core34.boolean)("active").notNull().default(true),
|
|
10724
|
+
createdAt: (0, import_mysql_core34.timestamp)("createdAt", {
|
|
10392
10725
|
mode: "date",
|
|
10393
10726
|
fsp: 3
|
|
10394
10727
|
}).defaultNow(),
|
|
10395
|
-
updatedAt: (0,
|
|
10728
|
+
updatedAt: (0, import_mysql_core34.timestamp)("updatedAt", {
|
|
10396
10729
|
mode: "date",
|
|
10397
10730
|
fsp: 3
|
|
10398
10731
|
}).defaultNow(),
|
|
10399
|
-
deletedAt: (0,
|
|
10732
|
+
deletedAt: (0, import_mysql_core34.timestamp)("deletedAt", {
|
|
10400
10733
|
mode: "date",
|
|
10401
10734
|
fsp: 3
|
|
10402
10735
|
})
|
|
10403
10736
|
}, (up) => ({
|
|
10404
|
-
pk: (0,
|
|
10737
|
+
pk: (0, import_mysql_core34.primaryKey)({
|
|
10405
10738
|
columns: [
|
|
10406
10739
|
up.userId,
|
|
10407
10740
|
up.permissionId
|
|
10408
10741
|
]
|
|
10409
10742
|
}),
|
|
10410
|
-
userIdIdx: (0,
|
|
10411
|
-
permissionIdIdx: (0,
|
|
10412
|
-
organizationIdIdx: (0,
|
|
10743
|
+
userIdIdx: (0, import_mysql_core34.index)("userId_idx").on(up.userId),
|
|
10744
|
+
permissionIdIdx: (0, import_mysql_core34.index)("permissionId_idx").on(up.permissionId),
|
|
10745
|
+
organizationIdIdx: (0, import_mysql_core34.index)("organizationId_idx").on(up.organizationId)
|
|
10413
10746
|
}));
|
|
10414
10747
|
}
|
|
10415
10748
|
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
@@ -10417,7 +10750,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
10417
10750
|
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
10418
10751
|
const users = getUsersSchema(mysqlTable);
|
|
10419
10752
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
10420
|
-
return (0,
|
|
10753
|
+
return (0, import_drizzle_orm30.relations)(userPermissions, ({ one }) => ({
|
|
10421
10754
|
user: one(users, {
|
|
10422
10755
|
fields: [
|
|
10423
10756
|
userPermissions.userId
|
|
@@ -10428,226 +10761,113 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
|
10428
10761
|
relationName: "user"
|
|
10429
10762
|
}),
|
|
10430
10763
|
permission: one(permissions, {
|
|
10431
|
-
fields: [
|
|
10432
|
-
userPermissions.permissionId
|
|
10433
|
-
],
|
|
10434
|
-
references: [
|
|
10435
|
-
permissions.id
|
|
10436
|
-
],
|
|
10437
|
-
relationName: "permission"
|
|
10438
|
-
})
|
|
10439
|
-
}));
|
|
10440
|
-
}
|
|
10441
|
-
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
10442
|
-
|
|
10443
|
-
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
10444
|
-
var import_drizzle_orm27 = require("drizzle-orm");
|
|
10445
|
-
var import_mysql_core31 = require("drizzle-orm/mysql-core");
|
|
10446
|
-
function getUserPrefsSchema(mysqlTable) {
|
|
10447
|
-
return mysqlTable("UserPrefs", {
|
|
10448
|
-
id: (0, import_mysql_core31.varchar)("id", {
|
|
10449
|
-
length: 191
|
|
10450
|
-
}).notNull(),
|
|
10451
|
-
organizationId: (0, import_mysql_core31.varchar)("organizationId", {
|
|
10452
|
-
length: 191
|
|
10453
|
-
}),
|
|
10454
|
-
type: (0, import_mysql_core31.varchar)("type", {
|
|
10455
|
-
length: 191
|
|
10456
|
-
}).default("Global").notNull(),
|
|
10457
|
-
userId: (0, import_mysql_core31.varchar)("userId", {
|
|
10458
|
-
length: 255
|
|
10459
|
-
}).notNull(),
|
|
10460
|
-
fields: (0, import_mysql_core31.json)("fields").$type().default({}),
|
|
10461
|
-
createdAt: (0, import_mysql_core31.timestamp)("createdAt", {
|
|
10462
|
-
mode: "date",
|
|
10463
|
-
fsp: 3
|
|
10464
|
-
}).default(import_drizzle_orm27.sql`CURRENT_TIMESTAMP(3)`),
|
|
10465
|
-
updatedAt: (0, import_mysql_core31.timestamp)("updatedAt", {
|
|
10466
|
-
mode: "date",
|
|
10467
|
-
fsp: 3
|
|
10468
|
-
}).default(import_drizzle_orm27.sql`CURRENT_TIMESTAMP(3)`),
|
|
10469
|
-
deletedAt: (0, import_mysql_core31.timestamp)("deletedAt", {
|
|
10470
|
-
mode: "date",
|
|
10471
|
-
fsp: 3
|
|
10472
|
-
})
|
|
10473
|
-
}, (crr) => ({
|
|
10474
|
-
pk: (0, import_mysql_core31.primaryKey)({
|
|
10475
|
-
columns: [
|
|
10476
|
-
crr.id
|
|
10477
|
-
]
|
|
10478
|
-
}),
|
|
10479
|
-
crrUserIdIdKey: (0, import_mysql_core31.index)("crr_userIdId_idx").on(crr.userId),
|
|
10480
|
-
organizationIdIdx: (0, import_mysql_core31.index)("organizationId_idx").on(crr.organizationId)
|
|
10481
|
-
}));
|
|
10482
|
-
}
|
|
10483
|
-
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
10484
|
-
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
10485
|
-
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
10486
|
-
const user = getUsersSchema(mysqlTable);
|
|
10487
|
-
return (0, import_drizzle_orm27.relations)(userPrefs, ({ one }) => ({
|
|
10488
|
-
user: one(user, {
|
|
10489
|
-
fields: [
|
|
10490
|
-
userPrefs.userId
|
|
10491
|
-
],
|
|
10492
|
-
references: [
|
|
10493
|
-
user.id
|
|
10494
|
-
],
|
|
10495
|
-
relationName: "user"
|
|
10496
|
-
})
|
|
10497
|
-
}));
|
|
10498
|
-
}
|
|
10499
|
-
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
10500
|
-
|
|
10501
|
-
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
10502
|
-
var import_drizzle_orm29 = require("drizzle-orm");
|
|
10503
|
-
var import_mysql_core33 = require("drizzle-orm/mysql-core");
|
|
10504
|
-
|
|
10505
|
-
// src/lib/mysql/schemas/auth/roles.ts
|
|
10506
|
-
var import_drizzle_orm28 = require("drizzle-orm");
|
|
10507
|
-
var import_mysql_core32 = require("drizzle-orm/mysql-core");
|
|
10508
|
-
function getRolesSchema(mysqlTable) {
|
|
10509
|
-
return mysqlTable("Role", {
|
|
10510
|
-
id: (0, import_mysql_core32.varchar)("id", {
|
|
10511
|
-
length: 255
|
|
10512
|
-
}).notNull().primaryKey(),
|
|
10513
|
-
organizationId: (0, import_mysql_core32.varchar)("organizationId", {
|
|
10514
|
-
length: 191
|
|
10515
|
-
}),
|
|
10516
|
-
name: (0, import_mysql_core32.varchar)("name", {
|
|
10517
|
-
length: 255
|
|
10518
|
-
}).notNull().unique(),
|
|
10519
|
-
description: (0, import_mysql_core32.text)("description"),
|
|
10520
|
-
active: (0, import_mysql_core32.boolean)("active").notNull().default(true),
|
|
10521
|
-
createdAt: (0, import_mysql_core32.timestamp)("createdAt", {
|
|
10522
|
-
mode: "date",
|
|
10523
|
-
fsp: 3
|
|
10524
|
-
}).defaultNow(),
|
|
10525
|
-
updatedAt: (0, import_mysql_core32.timestamp)("updatedAt", {
|
|
10526
|
-
mode: "date",
|
|
10527
|
-
fsp: 3
|
|
10528
|
-
}).defaultNow(),
|
|
10529
|
-
deletedAt: (0, import_mysql_core32.timestamp)("deletedAt", {
|
|
10530
|
-
mode: "date",
|
|
10531
|
-
fsp: 3
|
|
10532
|
-
})
|
|
10533
|
-
}, (role) => ({
|
|
10534
|
-
nameIdx: (0, import_mysql_core32.index)("name_idx").on(role.name),
|
|
10535
|
-
organizationIdIdx: (0, import_mysql_core32.index)("organizationId_idx").on(role.organizationId)
|
|
10536
|
-
}));
|
|
10537
|
-
}
|
|
10538
|
-
__name(getRolesSchema, "getRolesSchema");
|
|
10539
|
-
function getRolesRelationsSchema(mysqlTable) {
|
|
10540
|
-
const roles = getRolesSchema(mysqlTable);
|
|
10541
|
-
const userRoles = getUserRolesSchema(mysqlTable);
|
|
10542
|
-
return (0, import_drizzle_orm28.relations)(roles, ({ many }) => ({
|
|
10543
|
-
userRoles: many(userRoles, {
|
|
10544
|
-
relationName: "role"
|
|
10764
|
+
fields: [
|
|
10765
|
+
userPermissions.permissionId
|
|
10766
|
+
],
|
|
10767
|
+
references: [
|
|
10768
|
+
permissions.id
|
|
10769
|
+
],
|
|
10770
|
+
relationName: "permission"
|
|
10545
10771
|
})
|
|
10546
10772
|
}));
|
|
10547
10773
|
}
|
|
10548
|
-
__name(
|
|
10774
|
+
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
10549
10775
|
|
|
10550
|
-
// src/lib/mysql/schemas/auth/user-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
length: 255
|
|
10776
|
+
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
10777
|
+
var import_drizzle_orm31 = require("drizzle-orm");
|
|
10778
|
+
var import_mysql_core35 = require("drizzle-orm/mysql-core");
|
|
10779
|
+
function getUserPrefsSchema(mysqlTable) {
|
|
10780
|
+
return mysqlTable("UserPrefs", {
|
|
10781
|
+
id: (0, import_mysql_core35.varchar)("id", {
|
|
10782
|
+
length: 191
|
|
10558
10783
|
}).notNull(),
|
|
10559
|
-
|
|
10560
|
-
organizationId: (0, import_mysql_core33.varchar)("organizationId", {
|
|
10784
|
+
organizationId: (0, import_mysql_core35.varchar)("organizationId", {
|
|
10561
10785
|
length: 191
|
|
10562
10786
|
}),
|
|
10563
|
-
|
|
10787
|
+
type: (0, import_mysql_core35.varchar)("type", {
|
|
10788
|
+
length: 191
|
|
10789
|
+
}).default("Global").notNull(),
|
|
10790
|
+
userId: (0, import_mysql_core35.varchar)("userId", {
|
|
10791
|
+
length: 255
|
|
10792
|
+
}).notNull(),
|
|
10793
|
+
fields: (0, import_mysql_core35.json)("fields").$type().default({}),
|
|
10794
|
+
createdAt: (0, import_mysql_core35.timestamp)("createdAt", {
|
|
10564
10795
|
mode: "date",
|
|
10565
10796
|
fsp: 3
|
|
10566
|
-
}).
|
|
10567
|
-
updatedAt: (0,
|
|
10797
|
+
}).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`),
|
|
10798
|
+
updatedAt: (0, import_mysql_core35.timestamp)("updatedAt", {
|
|
10568
10799
|
mode: "date",
|
|
10569
10800
|
fsp: 3
|
|
10570
|
-
}).
|
|
10571
|
-
deletedAt: (0,
|
|
10801
|
+
}).default(import_drizzle_orm31.sql`CURRENT_TIMESTAMP(3)`),
|
|
10802
|
+
deletedAt: (0, import_mysql_core35.timestamp)("deletedAt", {
|
|
10572
10803
|
mode: "date",
|
|
10573
10804
|
fsp: 3
|
|
10574
10805
|
})
|
|
10575
|
-
}, (
|
|
10576
|
-
pk: (0,
|
|
10806
|
+
}, (crr) => ({
|
|
10807
|
+
pk: (0, import_mysql_core35.primaryKey)({
|
|
10577
10808
|
columns: [
|
|
10578
|
-
|
|
10579
|
-
ur.roleId
|
|
10809
|
+
crr.id
|
|
10580
10810
|
]
|
|
10581
10811
|
}),
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
organizationIdIdx: (0, import_mysql_core33.index)("organizationId_idx").on(ur.organizationId)
|
|
10812
|
+
crrUserIdIdKey: (0, import_mysql_core35.index)("crr_userIdId_idx").on(crr.userId),
|
|
10813
|
+
organizationIdIdx: (0, import_mysql_core35.index)("organizationId_idx").on(crr.organizationId)
|
|
10585
10814
|
}));
|
|
10586
10815
|
}
|
|
10587
|
-
__name(
|
|
10588
|
-
function
|
|
10589
|
-
const
|
|
10590
|
-
const
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
user: one(users, {
|
|
10816
|
+
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
10817
|
+
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
10818
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
10819
|
+
const user = getUsersSchema(mysqlTable);
|
|
10820
|
+
return (0, import_drizzle_orm31.relations)(userPrefs, ({ one }) => ({
|
|
10821
|
+
user: one(user, {
|
|
10594
10822
|
fields: [
|
|
10595
|
-
|
|
10823
|
+
userPrefs.userId
|
|
10596
10824
|
],
|
|
10597
10825
|
references: [
|
|
10598
|
-
|
|
10826
|
+
user.id
|
|
10599
10827
|
],
|
|
10600
10828
|
relationName: "user"
|
|
10601
|
-
}),
|
|
10602
|
-
role: one(roles, {
|
|
10603
|
-
fields: [
|
|
10604
|
-
userRoles.roleId
|
|
10605
|
-
],
|
|
10606
|
-
references: [
|
|
10607
|
-
roles.id
|
|
10608
|
-
],
|
|
10609
|
-
relationName: "role"
|
|
10610
10829
|
})
|
|
10611
10830
|
}));
|
|
10612
10831
|
}
|
|
10613
|
-
__name(
|
|
10832
|
+
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
10614
10833
|
|
|
10615
10834
|
// src/lib/mysql/schemas/auth/users.ts
|
|
10616
10835
|
function getUsersSchema(mysqlTable) {
|
|
10617
10836
|
return mysqlTable("User", {
|
|
10618
|
-
id: (0,
|
|
10837
|
+
id: (0, import_mysql_core36.varchar)("id", {
|
|
10619
10838
|
length: 255
|
|
10620
10839
|
}).notNull().primaryKey(),
|
|
10621
|
-
name: (0,
|
|
10840
|
+
name: (0, import_mysql_core36.varchar)("name", {
|
|
10622
10841
|
length: 255
|
|
10623
10842
|
}),
|
|
10624
|
-
role: (0,
|
|
10843
|
+
role: (0, import_mysql_core36.varchar)("role", {
|
|
10625
10844
|
length: 191
|
|
10626
10845
|
}).notNull().default("user"),
|
|
10627
|
-
email: (0,
|
|
10846
|
+
email: (0, import_mysql_core36.varchar)("email", {
|
|
10628
10847
|
length: 255
|
|
10629
10848
|
}).notNull().unique(),
|
|
10630
|
-
fields: (0,
|
|
10631
|
-
emailVerified: (0,
|
|
10849
|
+
fields: (0, import_mysql_core36.json)("fields").$type().default({}),
|
|
10850
|
+
emailVerified: (0, import_mysql_core36.timestamp)("emailVerified", {
|
|
10632
10851
|
mode: "date",
|
|
10633
10852
|
fsp: 3
|
|
10634
10853
|
}),
|
|
10635
|
-
image: (0,
|
|
10854
|
+
image: (0, import_mysql_core36.varchar)("image", {
|
|
10636
10855
|
length: 255
|
|
10637
10856
|
}),
|
|
10638
|
-
createdAt: (0,
|
|
10857
|
+
createdAt: (0, import_mysql_core36.timestamp)("createdAt", {
|
|
10639
10858
|
mode: "date",
|
|
10640
10859
|
fsp: 3
|
|
10641
|
-
}).default(
|
|
10860
|
+
}).default(import_drizzle_orm32.sql`CURRENT_TIMESTAMP(3)`)
|
|
10642
10861
|
}, (user) => ({
|
|
10643
|
-
emailIdx: (0,
|
|
10644
|
-
roleIdx: (0,
|
|
10645
|
-
createdAtIdx: (0,
|
|
10862
|
+
emailIdx: (0, import_mysql_core36.index)("email_idx").on(user.email),
|
|
10863
|
+
roleIdx: (0, import_mysql_core36.index)("role_idx").on(user.role),
|
|
10864
|
+
createdAtIdx: (0, import_mysql_core36.index)("created_at_idx").on(user.createdAt)
|
|
10646
10865
|
}));
|
|
10647
10866
|
}
|
|
10648
10867
|
__name(getUsersSchema, "getUsersSchema");
|
|
10649
10868
|
function getUsersRelationsSchema(mysqlTable) {
|
|
10650
10869
|
const users = getUsersSchema(mysqlTable);
|
|
10870
|
+
const profiles = getProfilesSchema(mysqlTable);
|
|
10651
10871
|
const accounts = getAccountsSchema(mysqlTable);
|
|
10652
10872
|
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
|
|
10653
10873
|
const userRoles = getUserRolesSchema(mysqlTable);
|
|
@@ -10658,7 +10878,10 @@ function getUsersRelationsSchema(mysqlTable) {
|
|
|
10658
10878
|
const comments = getCommentsSchema(mysqlTable);
|
|
10659
10879
|
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
10660
10880
|
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
10661
|
-
return (0,
|
|
10881
|
+
return (0, import_drizzle_orm32.relations)(users, ({ many, one }) => ({
|
|
10882
|
+
profiles: many(profiles, {
|
|
10883
|
+
relationName: "profiles"
|
|
10884
|
+
}),
|
|
10662
10885
|
accounts: many(accounts, {
|
|
10663
10886
|
relationName: "user"
|
|
10664
10887
|
}),
|
|
@@ -10696,49 +10919,49 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
|
10696
10919
|
// src/lib/mysql/schemas/auth/accounts.ts
|
|
10697
10920
|
function getAccountsSchema(mysqlTable) {
|
|
10698
10921
|
return mysqlTable("Account", {
|
|
10699
|
-
userId: (0,
|
|
10922
|
+
userId: (0, import_mysql_core37.varchar)("userId", {
|
|
10700
10923
|
length: 255
|
|
10701
10924
|
}).notNull(),
|
|
10702
|
-
type: (0,
|
|
10925
|
+
type: (0, import_mysql_core37.varchar)("type", {
|
|
10703
10926
|
length: 255
|
|
10704
10927
|
}).$type().notNull(),
|
|
10705
|
-
provider: (0,
|
|
10928
|
+
provider: (0, import_mysql_core37.varchar)("provider", {
|
|
10706
10929
|
length: 255
|
|
10707
10930
|
}).notNull(),
|
|
10708
|
-
providerAccountId: (0,
|
|
10931
|
+
providerAccountId: (0, import_mysql_core37.varchar)("providerAccountId", {
|
|
10709
10932
|
length: 255
|
|
10710
10933
|
}).notNull(),
|
|
10711
|
-
refresh_token: (0,
|
|
10712
|
-
access_token: (0,
|
|
10713
|
-
oauth_token: (0,
|
|
10714
|
-
oauth_token_secret: (0,
|
|
10715
|
-
expires_at: (0,
|
|
10716
|
-
token_type: (0,
|
|
10934
|
+
refresh_token: (0, import_mysql_core37.text)("refresh_token"),
|
|
10935
|
+
access_token: (0, import_mysql_core37.text)("access_token"),
|
|
10936
|
+
oauth_token: (0, import_mysql_core37.text)("oauth_token"),
|
|
10937
|
+
oauth_token_secret: (0, import_mysql_core37.text)("oauth_token_secret"),
|
|
10938
|
+
expires_at: (0, import_mysql_core37.int)("expires_at"),
|
|
10939
|
+
token_type: (0, import_mysql_core37.varchar)("token_type", {
|
|
10717
10940
|
length: 255
|
|
10718
10941
|
}),
|
|
10719
|
-
scope: (0,
|
|
10942
|
+
scope: (0, import_mysql_core37.varchar)("scope", {
|
|
10720
10943
|
length: 255
|
|
10721
10944
|
}),
|
|
10722
|
-
id_token: (0,
|
|
10723
|
-
session_state: (0,
|
|
10945
|
+
id_token: (0, import_mysql_core37.text)("id_token"),
|
|
10946
|
+
session_state: (0, import_mysql_core37.varchar)("session_state", {
|
|
10724
10947
|
length: 255
|
|
10725
10948
|
}),
|
|
10726
|
-
refresh_token_expires_in: (0,
|
|
10949
|
+
refresh_token_expires_in: (0, import_mysql_core37.int)("refresh_token_expires_in")
|
|
10727
10950
|
}, (account) => ({
|
|
10728
|
-
pk: (0,
|
|
10951
|
+
pk: (0, import_mysql_core37.primaryKey)({
|
|
10729
10952
|
columns: [
|
|
10730
10953
|
account.provider,
|
|
10731
10954
|
account.providerAccountId
|
|
10732
10955
|
]
|
|
10733
10956
|
}),
|
|
10734
|
-
userIdIdx: (0,
|
|
10957
|
+
userIdIdx: (0, import_mysql_core37.index)("userId_idx").on(account.userId)
|
|
10735
10958
|
}));
|
|
10736
10959
|
}
|
|
10737
10960
|
__name(getAccountsSchema, "getAccountsSchema");
|
|
10738
10961
|
function getAccountsRelationsSchema(mysqlTable) {
|
|
10739
10962
|
const accounts = getAccountsSchema(mysqlTable);
|
|
10740
10963
|
const users = getUsersSchema(mysqlTable);
|
|
10741
|
-
return (0,
|
|
10964
|
+
return (0, import_drizzle_orm33.relations)(accounts, ({ one }) => ({
|
|
10742
10965
|
user: one(users, {
|
|
10743
10966
|
fields: [
|
|
10744
10967
|
accounts.userId
|
|
@@ -10753,37 +10976,37 @@ function getAccountsRelationsSchema(mysqlTable) {
|
|
|
10753
10976
|
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
10754
10977
|
|
|
10755
10978
|
// src/lib/mysql/schemas/auth/device-access-token.ts
|
|
10756
|
-
var
|
|
10757
|
-
var
|
|
10979
|
+
var import_drizzle_orm34 = require("drizzle-orm");
|
|
10980
|
+
var import_mysql_core38 = require("drizzle-orm/mysql-core");
|
|
10758
10981
|
function getDeviceAccessTokenSchema(mysqlTable) {
|
|
10759
10982
|
return mysqlTable("DeviceAccessToken", {
|
|
10760
|
-
token: (0,
|
|
10983
|
+
token: (0, import_mysql_core38.varchar)("token", {
|
|
10761
10984
|
length: 191
|
|
10762
10985
|
}).notNull(),
|
|
10763
|
-
userId: (0,
|
|
10986
|
+
userId: (0, import_mysql_core38.varchar)("userId", {
|
|
10764
10987
|
length: 191
|
|
10765
10988
|
}).notNull(),
|
|
10766
|
-
organizationMembershipId: (0,
|
|
10989
|
+
organizationMembershipId: (0, import_mysql_core38.varchar)("organizationMembershipId", {
|
|
10767
10990
|
length: 191
|
|
10768
10991
|
}),
|
|
10769
|
-
createdAt: (0,
|
|
10992
|
+
createdAt: (0, import_mysql_core38.timestamp)("createdAt", {
|
|
10770
10993
|
mode: "date",
|
|
10771
10994
|
fsp: 3
|
|
10772
|
-
}).default(
|
|
10995
|
+
}).default(import_drizzle_orm34.sql`CURRENT_TIMESTAMP(3)`)
|
|
10773
10996
|
}, (crr) => ({
|
|
10774
|
-
pk: (0,
|
|
10997
|
+
pk: (0, import_mysql_core38.primaryKey)({
|
|
10775
10998
|
columns: [
|
|
10776
10999
|
crr.token
|
|
10777
11000
|
]
|
|
10778
11001
|
}),
|
|
10779
|
-
userIdIdx: (0,
|
|
11002
|
+
userIdIdx: (0, import_mysql_core38.index)("userId_idx").on(crr.userId)
|
|
10780
11003
|
}));
|
|
10781
11004
|
}
|
|
10782
11005
|
__name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
|
|
10783
11006
|
function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
10784
11007
|
const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
|
|
10785
11008
|
const user = getUsersSchema(mysqlTable);
|
|
10786
|
-
return (0,
|
|
11009
|
+
return (0, import_drizzle_orm34.relations)(deviceAccessToken, ({ one }) => ({
|
|
10787
11010
|
verifiedBy: one(user, {
|
|
10788
11011
|
fields: [
|
|
10789
11012
|
deviceAccessToken.userId
|
|
@@ -10798,31 +11021,31 @@ function getDeviceAccessTokenRelationsSchema(mysqlTable) {
|
|
|
10798
11021
|
__name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
|
|
10799
11022
|
|
|
10800
11023
|
// src/lib/mysql/schemas/auth/device-verification.ts
|
|
10801
|
-
var
|
|
10802
|
-
var
|
|
11024
|
+
var import_drizzle_orm35 = require("drizzle-orm");
|
|
11025
|
+
var import_mysql_core39 = require("drizzle-orm/mysql-core");
|
|
10803
11026
|
function getDeviceVerificationSchema(mysqlTable) {
|
|
10804
11027
|
return mysqlTable("DeviceVerification", {
|
|
10805
|
-
verifiedByUserId: (0,
|
|
11028
|
+
verifiedByUserId: (0, import_mysql_core39.varchar)("verifiedByUserId", {
|
|
10806
11029
|
length: 255
|
|
10807
11030
|
}),
|
|
10808
|
-
deviceCode: (0,
|
|
11031
|
+
deviceCode: (0, import_mysql_core39.varchar)("deviceCode", {
|
|
10809
11032
|
length: 191
|
|
10810
11033
|
}).notNull(),
|
|
10811
|
-
userCode: (0,
|
|
10812
|
-
expires: (0,
|
|
11034
|
+
userCode: (0, import_mysql_core39.text)("userCode").notNull(),
|
|
11035
|
+
expires: (0, import_mysql_core39.timestamp)("expires", {
|
|
10813
11036
|
mode: "date",
|
|
10814
11037
|
fsp: 3
|
|
10815
11038
|
}).notNull(),
|
|
10816
|
-
createdAt: (0,
|
|
11039
|
+
createdAt: (0, import_mysql_core39.timestamp)("createdAt", {
|
|
10817
11040
|
mode: "date",
|
|
10818
11041
|
fsp: 3
|
|
10819
|
-
}).default(
|
|
10820
|
-
verifiedAt: (0,
|
|
11042
|
+
}).default(import_drizzle_orm35.sql`CURRENT_TIMESTAMP(3)`),
|
|
11043
|
+
verifiedAt: (0, import_mysql_core39.timestamp)("verifiedAt", {
|
|
10821
11044
|
mode: "date",
|
|
10822
11045
|
fsp: 3
|
|
10823
11046
|
})
|
|
10824
11047
|
}, (crr) => ({
|
|
10825
|
-
pk: (0,
|
|
11048
|
+
pk: (0, import_mysql_core39.primaryKey)({
|
|
10826
11049
|
columns: [
|
|
10827
11050
|
crr.deviceCode
|
|
10828
11051
|
]
|
|
@@ -10833,7 +11056,7 @@ __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
|
|
|
10833
11056
|
function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
10834
11057
|
const deviceVerification = getDeviceVerificationSchema(mysqlTable);
|
|
10835
11058
|
const user = getUsersSchema(mysqlTable);
|
|
10836
|
-
return (0,
|
|
11059
|
+
return (0, import_drizzle_orm35.relations)(deviceVerification, ({ one }) => ({
|
|
10837
11060
|
verifiedBy: one(user, {
|
|
10838
11061
|
fields: [
|
|
10839
11062
|
deviceVerification.verifiedByUserId
|
|
@@ -10848,38 +11071,38 @@ function getDeviceVerificationRelationsSchema(mysqlTable) {
|
|
|
10848
11071
|
__name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
|
|
10849
11072
|
|
|
10850
11073
|
// src/lib/mysql/schemas/auth/role-permissions.ts
|
|
10851
|
-
var
|
|
10852
|
-
var
|
|
11074
|
+
var import_drizzle_orm36 = require("drizzle-orm");
|
|
11075
|
+
var import_mysql_core40 = require("drizzle-orm/mysql-core");
|
|
10853
11076
|
function getRolePermissionsSchema(mysqlTable) {
|
|
10854
11077
|
return mysqlTable("RolePermission", {
|
|
10855
|
-
roleId: (0,
|
|
11078
|
+
roleId: (0, import_mysql_core40.varchar)("roleId", {
|
|
10856
11079
|
length: 255
|
|
10857
11080
|
}).notNull(),
|
|
10858
|
-
permissionId: (0,
|
|
11081
|
+
permissionId: (0, import_mysql_core40.varchar)("permissionId", {
|
|
10859
11082
|
length: 255
|
|
10860
11083
|
}).notNull(),
|
|
10861
|
-
active: (0,
|
|
10862
|
-
createdAt: (0,
|
|
11084
|
+
active: (0, import_mysql_core40.boolean)("active").notNull().default(true),
|
|
11085
|
+
createdAt: (0, import_mysql_core40.timestamp)("createdAt", {
|
|
10863
11086
|
mode: "date",
|
|
10864
11087
|
fsp: 3
|
|
10865
11088
|
}).defaultNow(),
|
|
10866
|
-
updatedAt: (0,
|
|
11089
|
+
updatedAt: (0, import_mysql_core40.timestamp)("updatedAt", {
|
|
10867
11090
|
mode: "date",
|
|
10868
11091
|
fsp: 3
|
|
10869
11092
|
}).defaultNow(),
|
|
10870
|
-
deletedAt: (0,
|
|
11093
|
+
deletedAt: (0, import_mysql_core40.timestamp)("deletedAt", {
|
|
10871
11094
|
mode: "date",
|
|
10872
11095
|
fsp: 3
|
|
10873
11096
|
})
|
|
10874
11097
|
}, (rp) => ({
|
|
10875
|
-
pk: (0,
|
|
11098
|
+
pk: (0, import_mysql_core40.primaryKey)({
|
|
10876
11099
|
columns: [
|
|
10877
11100
|
rp.roleId,
|
|
10878
11101
|
rp.permissionId
|
|
10879
11102
|
]
|
|
10880
11103
|
}),
|
|
10881
|
-
roleIdIdx: (0,
|
|
10882
|
-
permissionIdIdx: (0,
|
|
11104
|
+
roleIdIdx: (0, import_mysql_core40.index)("roleId_idx").on(rp.roleId),
|
|
11105
|
+
permissionIdIdx: (0, import_mysql_core40.index)("permissionId_idx").on(rp.permissionId)
|
|
10883
11106
|
}));
|
|
10884
11107
|
}
|
|
10885
11108
|
__name(getRolePermissionsSchema, "getRolePermissionsSchema");
|
|
@@ -10887,7 +11110,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
10887
11110
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
10888
11111
|
const roles = getRolesSchema(mysqlTable);
|
|
10889
11112
|
const rolePermissions = getRolePermissionsSchema(mysqlTable);
|
|
10890
|
-
return (0,
|
|
11113
|
+
return (0, import_drizzle_orm36.relations)(rolePermissions, ({ one }) => ({
|
|
10891
11114
|
role: one(roles, {
|
|
10892
11115
|
fields: [
|
|
10893
11116
|
rolePermissions.roleId
|
|
@@ -10911,28 +11134,28 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
10911
11134
|
__name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
|
|
10912
11135
|
|
|
10913
11136
|
// src/lib/mysql/schemas/auth/sessions.ts
|
|
10914
|
-
var
|
|
10915
|
-
var
|
|
11137
|
+
var import_drizzle_orm37 = require("drizzle-orm");
|
|
11138
|
+
var import_mysql_core41 = require("drizzle-orm/mysql-core");
|
|
10916
11139
|
function getSessionsSchema(mysqlTable) {
|
|
10917
11140
|
return mysqlTable("Session", {
|
|
10918
|
-
sessionToken: (0,
|
|
11141
|
+
sessionToken: (0, import_mysql_core41.varchar)("sessionToken", {
|
|
10919
11142
|
length: 255
|
|
10920
11143
|
}).notNull().primaryKey(),
|
|
10921
|
-
userId: (0,
|
|
11144
|
+
userId: (0, import_mysql_core41.varchar)("userId", {
|
|
10922
11145
|
length: 255
|
|
10923
11146
|
}).notNull(),
|
|
10924
|
-
expires: (0,
|
|
11147
|
+
expires: (0, import_mysql_core41.timestamp)("expires", {
|
|
10925
11148
|
mode: "date"
|
|
10926
11149
|
}).notNull()
|
|
10927
11150
|
}, (session) => ({
|
|
10928
|
-
userIdIdx: (0,
|
|
11151
|
+
userIdIdx: (0, import_mysql_core41.index)("userId_idx").on(session.userId)
|
|
10929
11152
|
}));
|
|
10930
11153
|
}
|
|
10931
11154
|
__name(getSessionsSchema, "getSessionsSchema");
|
|
10932
11155
|
function getSessionRelationsSchema(mysqlTable) {
|
|
10933
11156
|
const sessions = getSessionsSchema(mysqlTable);
|
|
10934
11157
|
const users = getUsersSchema(mysqlTable);
|
|
10935
|
-
return (0,
|
|
11158
|
+
return (0, import_drizzle_orm37.relations)(sessions, ({ one }) => ({
|
|
10936
11159
|
user: one(users, {
|
|
10937
11160
|
fields: [
|
|
10938
11161
|
sessions.userId
|
|
@@ -10947,24 +11170,24 @@ function getSessionRelationsSchema(mysqlTable) {
|
|
|
10947
11170
|
__name(getSessionRelationsSchema, "getSessionRelationsSchema");
|
|
10948
11171
|
|
|
10949
11172
|
// src/lib/mysql/schemas/auth/verification-tokens.ts
|
|
10950
|
-
var
|
|
11173
|
+
var import_mysql_core42 = require("drizzle-orm/mysql-core");
|
|
10951
11174
|
function getVerificationTokensSchema(mysqlTable) {
|
|
10952
11175
|
return mysqlTable("VerificationToken", {
|
|
10953
|
-
identifier: (0,
|
|
11176
|
+
identifier: (0, import_mysql_core42.varchar)("identifier", {
|
|
10954
11177
|
length: 255
|
|
10955
11178
|
}).notNull(),
|
|
10956
|
-
token: (0,
|
|
11179
|
+
token: (0, import_mysql_core42.varchar)("token", {
|
|
10957
11180
|
length: 255
|
|
10958
11181
|
}).notNull(),
|
|
10959
|
-
expires: (0,
|
|
11182
|
+
expires: (0, import_mysql_core42.timestamp)("expires", {
|
|
10960
11183
|
mode: "date"
|
|
10961
11184
|
}).notNull(),
|
|
10962
|
-
createdAt: (0,
|
|
11185
|
+
createdAt: (0, import_mysql_core42.timestamp)("createdAt", {
|
|
10963
11186
|
mode: "date",
|
|
10964
11187
|
fsp: 3
|
|
10965
11188
|
}).defaultNow()
|
|
10966
11189
|
}, (vt) => ({
|
|
10967
|
-
pk: (0,
|
|
11190
|
+
pk: (0, import_mysql_core42.primaryKey)({
|
|
10968
11191
|
columns: [
|
|
10969
11192
|
vt.identifier,
|
|
10970
11193
|
vt.token
|
|
@@ -10975,14 +11198,14 @@ function getVerificationTokensSchema(mysqlTable) {
|
|
|
10975
11198
|
__name(getVerificationTokensSchema, "getVerificationTokensSchema");
|
|
10976
11199
|
|
|
10977
11200
|
// src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
|
|
10978
|
-
var
|
|
10979
|
-
var
|
|
11201
|
+
var import_drizzle_orm38 = require("drizzle-orm");
|
|
11202
|
+
var import_mysql_core43 = require("drizzle-orm/mysql-core");
|
|
10980
11203
|
function getPurchaseUserTransferSchema(mysqlTable) {
|
|
10981
11204
|
return mysqlTable("PurchaseUserTransfer", {
|
|
10982
|
-
id: (0,
|
|
11205
|
+
id: (0, import_mysql_core43.varchar)("id", {
|
|
10983
11206
|
length: 191
|
|
10984
11207
|
}).notNull(),
|
|
10985
|
-
transferState: (0,
|
|
11208
|
+
transferState: (0, import_mysql_core43.mysqlEnum)("transferState", [
|
|
10986
11209
|
"AVAILABLE",
|
|
10987
11210
|
"INITIATED",
|
|
10988
11211
|
"VERIFIED",
|
|
@@ -10991,47 +11214,47 @@ function getPurchaseUserTransferSchema(mysqlTable) {
|
|
|
10991
11214
|
"CONFIRMED",
|
|
10992
11215
|
"COMPLETED"
|
|
10993
11216
|
]).default("AVAILABLE").notNull(),
|
|
10994
|
-
purchaseId: (0,
|
|
11217
|
+
purchaseId: (0, import_mysql_core43.varchar)("purchaseId", {
|
|
10995
11218
|
length: 191
|
|
10996
11219
|
}).notNull(),
|
|
10997
|
-
organizationId: (0,
|
|
11220
|
+
organizationId: (0, import_mysql_core43.varchar)("organizationId", {
|
|
10998
11221
|
length: 191
|
|
10999
11222
|
}),
|
|
11000
|
-
sourceUserId: (0,
|
|
11223
|
+
sourceUserId: (0, import_mysql_core43.varchar)("sourceUserId", {
|
|
11001
11224
|
length: 191
|
|
11002
11225
|
}).notNull(),
|
|
11003
|
-
targetUserId: (0,
|
|
11226
|
+
targetUserId: (0, import_mysql_core43.varchar)("targetUserId", {
|
|
11004
11227
|
length: 191
|
|
11005
11228
|
}),
|
|
11006
|
-
createdAt: (0,
|
|
11229
|
+
createdAt: (0, import_mysql_core43.timestamp)("createdAt", {
|
|
11007
11230
|
mode: "date",
|
|
11008
11231
|
fsp: 3
|
|
11009
|
-
}).default(
|
|
11010
|
-
expiresAt: (0,
|
|
11232
|
+
}).default(import_drizzle_orm38.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
11233
|
+
expiresAt: (0, import_mysql_core43.timestamp)("expiresAt", {
|
|
11011
11234
|
mode: "date",
|
|
11012
11235
|
fsp: 3
|
|
11013
11236
|
}),
|
|
11014
|
-
canceledAt: (0,
|
|
11237
|
+
canceledAt: (0, import_mysql_core43.timestamp)("canceledAt", {
|
|
11015
11238
|
mode: "date",
|
|
11016
11239
|
fsp: 3
|
|
11017
11240
|
}),
|
|
11018
|
-
confirmedAt: (0,
|
|
11241
|
+
confirmedAt: (0, import_mysql_core43.timestamp)("confirmedAt", {
|
|
11019
11242
|
mode: "date",
|
|
11020
11243
|
fsp: 3
|
|
11021
11244
|
}),
|
|
11022
|
-
completedAt: (0,
|
|
11245
|
+
completedAt: (0, import_mysql_core43.timestamp)("completedAt", {
|
|
11023
11246
|
mode: "date",
|
|
11024
11247
|
fsp: 3
|
|
11025
11248
|
})
|
|
11026
11249
|
}, (table) => {
|
|
11027
11250
|
return {
|
|
11028
|
-
purchaseUserTransferId: (0,
|
|
11251
|
+
purchaseUserTransferId: (0, import_mysql_core43.primaryKey)({
|
|
11029
11252
|
columns: [
|
|
11030
11253
|
table.id
|
|
11031
11254
|
],
|
|
11032
11255
|
name: "PurchaseUserTransfer_id"
|
|
11033
11256
|
}),
|
|
11034
|
-
organizationIdIdx: (0,
|
|
11257
|
+
organizationIdIdx: (0, import_mysql_core43.index)("organizationId_idx").on(table.organizationId)
|
|
11035
11258
|
};
|
|
11036
11259
|
});
|
|
11037
11260
|
}
|
|
@@ -11040,7 +11263,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
11040
11263
|
const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
|
|
11041
11264
|
const user = getUsersSchema(mysqlTable);
|
|
11042
11265
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
11043
|
-
return (0,
|
|
11266
|
+
return (0, import_drizzle_orm38.relations)(purchaseUserTransfer, ({ one }) => ({
|
|
11044
11267
|
sourceUser: one(user, {
|
|
11045
11268
|
fields: [
|
|
11046
11269
|
purchaseUserTransfer.sourceUserId
|
|
@@ -11073,50 +11296,50 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable) {
|
|
|
11073
11296
|
__name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
|
|
11074
11297
|
|
|
11075
11298
|
// src/lib/mysql/schemas/commerce/upgradable-products.ts
|
|
11076
|
-
var
|
|
11077
|
-
var
|
|
11299
|
+
var import_drizzle_orm39 = require("drizzle-orm");
|
|
11300
|
+
var import_mysql_core44 = require("drizzle-orm/mysql-core");
|
|
11078
11301
|
function getUpgradableProductsSchema(mysqlTable) {
|
|
11079
11302
|
return mysqlTable("UpgradableProducts", {
|
|
11080
|
-
upgradableToId: (0,
|
|
11303
|
+
upgradableToId: (0, import_mysql_core44.varchar)("upgradableToId", {
|
|
11081
11304
|
length: 255
|
|
11082
11305
|
}).notNull(),
|
|
11083
|
-
upgradableFromId: (0,
|
|
11306
|
+
upgradableFromId: (0, import_mysql_core44.varchar)("upgradableFrom", {
|
|
11084
11307
|
length: 255
|
|
11085
11308
|
}).notNull(),
|
|
11086
|
-
organizationId: (0,
|
|
11309
|
+
organizationId: (0, import_mysql_core44.varchar)("organizationId", {
|
|
11087
11310
|
length: 191
|
|
11088
11311
|
}),
|
|
11089
|
-
position: (0,
|
|
11090
|
-
metadata: (0,
|
|
11091
|
-
createdAt: (0,
|
|
11312
|
+
position: (0, import_mysql_core44.double)("position").notNull().default(0),
|
|
11313
|
+
metadata: (0, import_mysql_core44.json)("metadata").$type().default({}),
|
|
11314
|
+
createdAt: (0, import_mysql_core44.timestamp)("createdAt", {
|
|
11092
11315
|
mode: "date",
|
|
11093
11316
|
fsp: 3
|
|
11094
|
-
}).default(
|
|
11095
|
-
updatedAt: (0,
|
|
11317
|
+
}).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`),
|
|
11318
|
+
updatedAt: (0, import_mysql_core44.timestamp)("updatedAt", {
|
|
11096
11319
|
mode: "date",
|
|
11097
11320
|
fsp: 3
|
|
11098
|
-
}).default(
|
|
11099
|
-
deletedAt: (0,
|
|
11321
|
+
}).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`),
|
|
11322
|
+
deletedAt: (0, import_mysql_core44.timestamp)("deletedAt", {
|
|
11100
11323
|
mode: "date",
|
|
11101
11324
|
fsp: 3
|
|
11102
11325
|
})
|
|
11103
11326
|
}, (crr) => ({
|
|
11104
|
-
pk: (0,
|
|
11327
|
+
pk: (0, import_mysql_core44.primaryKey)({
|
|
11105
11328
|
columns: [
|
|
11106
11329
|
crr.upgradableToId,
|
|
11107
11330
|
crr.upgradableFromId
|
|
11108
11331
|
]
|
|
11109
11332
|
}),
|
|
11110
|
-
upgradableToIdIdx: (0,
|
|
11111
|
-
upgradableFromIdIdx: (0,
|
|
11112
|
-
organizationIdIdx: (0,
|
|
11333
|
+
upgradableToIdIdx: (0, import_mysql_core44.index)("upgradableFromId_idx").on(crr.upgradableToId),
|
|
11334
|
+
upgradableFromIdIdx: (0, import_mysql_core44.index)("upgradableToId_idx").on(crr.upgradableFromId),
|
|
11335
|
+
organizationIdIdx: (0, import_mysql_core44.index)("organizationId_idx").on(crr.organizationId)
|
|
11113
11336
|
}));
|
|
11114
11337
|
}
|
|
11115
11338
|
__name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
|
|
11116
11339
|
function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
11117
11340
|
const product = getProductSchema(mysqlTable);
|
|
11118
11341
|
const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
|
|
11119
|
-
return (0,
|
|
11342
|
+
return (0, import_drizzle_orm39.relations)(upgradableProduct, ({ one }) => ({
|
|
11120
11343
|
upgradableTo: one(product, {
|
|
11121
11344
|
fields: [
|
|
11122
11345
|
upgradableProduct.upgradableToId
|
|
@@ -11140,175 +11363,107 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
|
11140
11363
|
__name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
|
|
11141
11364
|
|
|
11142
11365
|
// src/lib/mysql/schemas/content/lesson-progress.ts
|
|
11143
|
-
var
|
|
11144
|
-
var
|
|
11366
|
+
var import_drizzle_orm40 = require("drizzle-orm");
|
|
11367
|
+
var import_mysql_core45 = require("drizzle-orm/mysql-core");
|
|
11145
11368
|
function getLessonProgressSchema(mysqlTable) {
|
|
11146
11369
|
return mysqlTable("LessonProgress", {
|
|
11147
|
-
id: (0,
|
|
11370
|
+
id: (0, import_mysql_core45.varchar)("id", {
|
|
11148
11371
|
length: 191
|
|
11149
11372
|
}).notNull().primaryKey(),
|
|
11150
|
-
userId: (0,
|
|
11373
|
+
userId: (0, import_mysql_core45.varchar)("userId", {
|
|
11151
11374
|
length: 191
|
|
11152
11375
|
}).notNull(),
|
|
11153
|
-
organizationId: (0,
|
|
11376
|
+
organizationId: (0, import_mysql_core45.varchar)("organizationId", {
|
|
11154
11377
|
length: 191
|
|
11155
11378
|
}),
|
|
11156
|
-
organizationMembershipId: (0,
|
|
11379
|
+
organizationMembershipId: (0, import_mysql_core45.varchar)("organizationMembershipId", {
|
|
11157
11380
|
length: 191
|
|
11158
11381
|
}),
|
|
11159
|
-
lessonId: (0,
|
|
11382
|
+
lessonId: (0, import_mysql_core45.varchar)("lessonId", {
|
|
11160
11383
|
length: 191
|
|
11161
11384
|
}),
|
|
11162
|
-
lessonSlug: (0,
|
|
11385
|
+
lessonSlug: (0, import_mysql_core45.varchar)("lessonSlug", {
|
|
11163
11386
|
length: 191
|
|
11164
11387
|
}),
|
|
11165
|
-
lessonVersion: (0,
|
|
11388
|
+
lessonVersion: (0, import_mysql_core45.varchar)("lessonVersion", {
|
|
11166
11389
|
length: 191
|
|
11167
11390
|
}),
|
|
11168
|
-
sectionId: (0,
|
|
11391
|
+
sectionId: (0, import_mysql_core45.varchar)("sectionId", {
|
|
11169
11392
|
length: 191
|
|
11170
11393
|
}),
|
|
11171
|
-
moduleId: (0,
|
|
11394
|
+
moduleId: (0, import_mysql_core45.varchar)("moduleId", {
|
|
11172
11395
|
length: 191
|
|
11173
11396
|
}),
|
|
11174
|
-
completedAt: (0,
|
|
11397
|
+
completedAt: (0, import_mysql_core45.datetime)("completedAt", {
|
|
11175
11398
|
mode: "date",
|
|
11176
11399
|
fsp: 3
|
|
11177
11400
|
}),
|
|
11178
|
-
updatedAt: (0,
|
|
11401
|
+
updatedAt: (0, import_mysql_core45.datetime)("updatedAt", {
|
|
11179
11402
|
mode: "date",
|
|
11180
11403
|
fsp: 3
|
|
11181
11404
|
}),
|
|
11182
|
-
createdAt: (0,
|
|
11405
|
+
createdAt: (0, import_mysql_core45.datetime)("createdAt", {
|
|
11183
11406
|
mode: "date",
|
|
11184
11407
|
fsp: 3
|
|
11185
|
-
}).default(
|
|
11408
|
+
}).default(import_drizzle_orm40.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
11186
11409
|
}, (crp) => {
|
|
11187
11410
|
return {
|
|
11188
|
-
userIdLessonIdIdx: (0,
|
|
11189
|
-
userIdIdx: (0,
|
|
11190
|
-
lessonIdIdx: (0,
|
|
11191
|
-
organizationMembershipIdIdx: (0,
|
|
11411
|
+
userIdLessonIdIdx: (0, import_mysql_core45.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
|
|
11412
|
+
userIdIdx: (0, import_mysql_core45.index)("userId_idx").on(crp.userId),
|
|
11413
|
+
lessonIdIdx: (0, import_mysql_core45.index)("lessonId_idx").on(crp.lessonId),
|
|
11414
|
+
organizationMembershipIdIdx: (0, import_mysql_core45.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
|
|
11192
11415
|
};
|
|
11193
11416
|
});
|
|
11194
11417
|
}
|
|
11195
11418
|
__name(getLessonProgressSchema, "getLessonProgressSchema");
|
|
11196
11419
|
|
|
11197
11420
|
// src/lib/mysql/schemas/content/resource-progress.ts
|
|
11198
|
-
var
|
|
11199
|
-
var
|
|
11421
|
+
var import_drizzle_orm41 = require("drizzle-orm");
|
|
11422
|
+
var import_mysql_core46 = require("drizzle-orm/mysql-core");
|
|
11200
11423
|
function getResourceProgressSchema(mysqlTable) {
|
|
11201
11424
|
return mysqlTable("ResourceProgress", {
|
|
11202
|
-
userId: (0,
|
|
11425
|
+
userId: (0, import_mysql_core46.varchar)("userId", {
|
|
11203
11426
|
length: 255
|
|
11204
11427
|
}).notNull(),
|
|
11205
|
-
organizationId: (0,
|
|
11428
|
+
organizationId: (0, import_mysql_core46.varchar)("organizationId", {
|
|
11206
11429
|
length: 191
|
|
11207
11430
|
}),
|
|
11208
|
-
organizationMembershipId: (0,
|
|
11431
|
+
organizationMembershipId: (0, import_mysql_core46.varchar)("organizationMembershipId", {
|
|
11209
11432
|
length: 191
|
|
11210
11433
|
}),
|
|
11211
|
-
resourceId: (0,
|
|
11434
|
+
resourceId: (0, import_mysql_core46.varchar)("resourceId", {
|
|
11212
11435
|
length: 255
|
|
11213
11436
|
}),
|
|
11214
|
-
fields: (0,
|
|
11215
|
-
completedAt: (0,
|
|
11437
|
+
fields: (0, import_mysql_core46.json)("fields").$type().default({}),
|
|
11438
|
+
completedAt: (0, import_mysql_core46.datetime)("completedAt", {
|
|
11216
11439
|
mode: "date",
|
|
11217
11440
|
fsp: 3
|
|
11218
11441
|
}),
|
|
11219
|
-
updatedAt: (0,
|
|
11442
|
+
updatedAt: (0, import_mysql_core46.datetime)("updatedAt", {
|
|
11220
11443
|
mode: "date",
|
|
11221
11444
|
fsp: 3
|
|
11222
11445
|
}),
|
|
11223
|
-
createdAt: (0,
|
|
11446
|
+
createdAt: (0, import_mysql_core46.datetime)("createdAt", {
|
|
11224
11447
|
mode: "date",
|
|
11225
11448
|
fsp: 3
|
|
11226
|
-
}).default(
|
|
11449
|
+
}).default(import_drizzle_orm41.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
11227
11450
|
}, (crp) => {
|
|
11228
11451
|
return {
|
|
11229
|
-
userIdLessonIdIdx: (0,
|
|
11230
|
-
pk: (0,
|
|
11452
|
+
userIdLessonIdIdx: (0, import_mysql_core46.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
|
|
11453
|
+
pk: (0, import_mysql_core46.primaryKey)({
|
|
11231
11454
|
columns: [
|
|
11232
11455
|
crp.userId,
|
|
11233
11456
|
crp.resourceId
|
|
11234
11457
|
]
|
|
11235
11458
|
}),
|
|
11236
|
-
contentResourceIdIdx: (0,
|
|
11237
|
-
userIdIdx: (0,
|
|
11238
|
-
organizationMembershipIdIdx: (0,
|
|
11459
|
+
contentResourceIdIdx: (0, import_mysql_core46.index)("contentResourceId_idx").on(crp.resourceId),
|
|
11460
|
+
userIdIdx: (0, import_mysql_core46.index)("resourceId_idx").on(crp.userId),
|
|
11461
|
+
organizationMembershipIdIdx: (0, import_mysql_core46.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
|
|
11239
11462
|
};
|
|
11240
11463
|
});
|
|
11241
11464
|
}
|
|
11242
11465
|
__name(getResourceProgressSchema, "getResourceProgressSchema");
|
|
11243
11466
|
|
|
11244
|
-
// src/lib/mysql/schemas/org/organization-membership-roles.ts
|
|
11245
|
-
var import_drizzle_orm40 = require("drizzle-orm");
|
|
11246
|
-
var import_mysql_core45 = require("drizzle-orm/mysql-core");
|
|
11247
|
-
function getOrganizationMembershipRolesSchema(mysqlTable) {
|
|
11248
|
-
return mysqlTable("OrganizationMembershipRole", {
|
|
11249
|
-
organizationMembershipId: (0, import_mysql_core45.varchar)("organizationMembershipId", {
|
|
11250
|
-
length: 255
|
|
11251
|
-
}).notNull(),
|
|
11252
|
-
roleId: (0, import_mysql_core45.varchar)("roleId", {
|
|
11253
|
-
length: 255
|
|
11254
|
-
}).notNull(),
|
|
11255
|
-
active: (0, import_mysql_core45.boolean)("active").notNull().default(true),
|
|
11256
|
-
organizationId: (0, import_mysql_core45.varchar)("organizationId", {
|
|
11257
|
-
length: 191
|
|
11258
|
-
}),
|
|
11259
|
-
createdAt: (0, import_mysql_core45.timestamp)("createdAt", {
|
|
11260
|
-
mode: "date",
|
|
11261
|
-
fsp: 3
|
|
11262
|
-
}).defaultNow(),
|
|
11263
|
-
updatedAt: (0, import_mysql_core45.timestamp)("updatedAt", {
|
|
11264
|
-
mode: "date",
|
|
11265
|
-
fsp: 3
|
|
11266
|
-
}).defaultNow(),
|
|
11267
|
-
deletedAt: (0, import_mysql_core45.timestamp)("deletedAt", {
|
|
11268
|
-
mode: "date",
|
|
11269
|
-
fsp: 3
|
|
11270
|
-
})
|
|
11271
|
-
}, (ur) => ({
|
|
11272
|
-
pk: (0, import_mysql_core45.primaryKey)({
|
|
11273
|
-
columns: [
|
|
11274
|
-
ur.organizationMembershipId,
|
|
11275
|
-
ur.roleId
|
|
11276
|
-
],
|
|
11277
|
-
name: "pk"
|
|
11278
|
-
}),
|
|
11279
|
-
orgMemberIdIdx: (0, import_mysql_core45.index)("orgMemberId_idx").on(ur.organizationMembershipId),
|
|
11280
|
-
roleIdIdx: (0, import_mysql_core45.index)("roleId_idx").on(ur.roleId),
|
|
11281
|
-
organizationIdIdx: (0, import_mysql_core45.index)("organizationId_idx").on(ur.organizationId)
|
|
11282
|
-
}));
|
|
11283
|
-
}
|
|
11284
|
-
__name(getOrganizationMembershipRolesSchema, "getOrganizationMembershipRolesSchema");
|
|
11285
|
-
function getOrganizationMembershipRolesRelationsSchema(mysqlTable) {
|
|
11286
|
-
const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
|
|
11287
|
-
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
11288
|
-
const roles = getRolesSchema(mysqlTable);
|
|
11289
|
-
return (0, import_drizzle_orm40.relations)(organizationMembershipRoles, ({ one }) => ({
|
|
11290
|
-
organizationMembership: one(organizationMemberships, {
|
|
11291
|
-
fields: [
|
|
11292
|
-
organizationMembershipRoles.organizationMembershipId
|
|
11293
|
-
],
|
|
11294
|
-
references: [
|
|
11295
|
-
organizationMemberships.id
|
|
11296
|
-
],
|
|
11297
|
-
relationName: "organizationMembership"
|
|
11298
|
-
}),
|
|
11299
|
-
role: one(roles, {
|
|
11300
|
-
fields: [
|
|
11301
|
-
organizationMembershipRoles.roleId
|
|
11302
|
-
],
|
|
11303
|
-
references: [
|
|
11304
|
-
roles.id
|
|
11305
|
-
],
|
|
11306
|
-
relationName: "role"
|
|
11307
|
-
})
|
|
11308
|
-
}));
|
|
11309
|
-
}
|
|
11310
|
-
__name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
|
|
11311
|
-
|
|
11312
11467
|
// src/lib/mysql/index.ts
|
|
11313
11468
|
var guid = (0, import_nanoid.customAlphabet)("1234567890abcdefghijklmnopqrstuvwxyz", 5);
|
|
11314
11469
|
function getCourseBuilderSchema(mysqlTable) {
|
|
@@ -11390,7 +11545,9 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
11390
11545
|
merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
|
|
11391
11546
|
merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
|
|
11392
11547
|
subscription: getSubscriptionSchema(mysqlTable),
|
|
11393
|
-
subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable)
|
|
11548
|
+
subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
|
|
11549
|
+
profiles: getProfilesSchema(mysqlTable),
|
|
11550
|
+
profilesRelations: getProfilesRelationsSchema(mysqlTable)
|
|
11394
11551
|
};
|
|
11395
11552
|
}
|
|
11396
11553
|
__name(getCourseBuilderSchema, "getCourseBuilderSchema");
|
|
@@ -11398,8 +11555,8 @@ function createTables(mySqlTable) {
|
|
|
11398
11555
|
return getCourseBuilderSchema(mySqlTable);
|
|
11399
11556
|
}
|
|
11400
11557
|
__name(createTables, "createTables");
|
|
11401
|
-
function mySqlDrizzleAdapter(client, tableFn =
|
|
11402
|
-
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);
|
|
11558
|
+
function mySqlDrizzleAdapter(client, tableFn = import_mysql_core47.mysqlTable, paymentProvider) {
|
|
11559
|
+
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments, organization: organizationTable, organizationMemberships: organizationMembershipTable, organizationMembershipRoles: organizationMembershipRoleTable, roles: roleTable, merchantSubscription: merchantSubscriptionTable, subscription: subscriptionTable } = createTables(tableFn);
|
|
11403
11560
|
const adapter = {
|
|
11404
11561
|
client,
|
|
11405
11562
|
async redeemFullPriceCoupon(options) {
|
|
@@ -11470,12 +11627,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11470
11627
|
},
|
|
11471
11628
|
incrementCouponUsedCount: async (couponId) => {
|
|
11472
11629
|
await client.update(coupon).set({
|
|
11473
|
-
usedCount:
|
|
11474
|
-
}).where((0,
|
|
11630
|
+
usedCount: import_drizzle_orm42.sql`${coupon.usedCount} + 1`
|
|
11631
|
+
}).where((0, import_drizzle_orm42.eq)(coupon.id, couponId));
|
|
11475
11632
|
},
|
|
11476
11633
|
getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
|
|
11477
11634
|
const existingPurchases = await client.query.purchases.findMany({
|
|
11478
|
-
where: (0,
|
|
11635
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm42.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm42.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm42.isNull)(purchaseTable.bulkCouponId))
|
|
11479
11636
|
});
|
|
11480
11637
|
return z.array(purchaseSchema).parse(existingPurchases);
|
|
11481
11638
|
},
|
|
@@ -11488,17 +11645,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11488
11645
|
status: 1
|
|
11489
11646
|
});
|
|
11490
11647
|
return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
11491
|
-
where: (0,
|
|
11648
|
+
where: (0, import_drizzle_orm42.eq)(merchantCustomer.identifier, options.identifier)
|
|
11492
11649
|
}));
|
|
11493
11650
|
},
|
|
11494
11651
|
getMerchantAccount: async (options) => {
|
|
11495
11652
|
return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
|
|
11496
|
-
where: (0,
|
|
11653
|
+
where: (0, import_drizzle_orm42.eq)(merchantAccount.label, options.provider)
|
|
11497
11654
|
}));
|
|
11498
11655
|
},
|
|
11499
11656
|
getMerchantPriceForProductId: async (productId) => {
|
|
11500
11657
|
const merchantPriceData = await client.query.merchantPrice.findFirst({
|
|
11501
|
-
where: (0,
|
|
11658
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm42.eq)(merchantPrice.status, 1))
|
|
11502
11659
|
});
|
|
11503
11660
|
const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
|
|
11504
11661
|
if (!parsedMerchantPrice.success) {
|
|
@@ -11509,7 +11666,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11509
11666
|
},
|
|
11510
11667
|
getMerchantProductForProductId: async (productId) => {
|
|
11511
11668
|
const merchantProductData = await client.query.merchantProduct.findFirst({
|
|
11512
|
-
where: (0,
|
|
11669
|
+
where: (0, import_drizzle_orm42.eq)(merchantProduct.productId, productId)
|
|
11513
11670
|
});
|
|
11514
11671
|
if (!merchantProductData)
|
|
11515
11672
|
return null;
|
|
@@ -11517,7 +11674,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11517
11674
|
},
|
|
11518
11675
|
getMerchantCustomerForUserId: async (userId) => {
|
|
11519
11676
|
const merchantCustomerData = await client.query.merchantCustomer.findFirst({
|
|
11520
|
-
where: (0,
|
|
11677
|
+
where: (0, import_drizzle_orm42.eq)(merchantCustomer.userId, userId)
|
|
11521
11678
|
});
|
|
11522
11679
|
if (!merchantCustomerData)
|
|
11523
11680
|
return null;
|
|
@@ -11526,14 +11683,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11526
11683
|
getUpgradableProducts: async (options) => {
|
|
11527
11684
|
const { upgradableFromId, upgradableToId } = options;
|
|
11528
11685
|
return z.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
11529
|
-
where: (0,
|
|
11686
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm42.eq)(upgradableProducts.upgradableToId, upgradableToId))
|
|
11530
11687
|
}));
|
|
11531
11688
|
},
|
|
11532
11689
|
async availableUpgradesForProduct(purchases, productId) {
|
|
11533
11690
|
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
11534
11691
|
if (previousPurchaseProductIds.length > 0) {
|
|
11535
11692
|
return client.query.upgradableProducts.findMany({
|
|
11536
|
-
where: (0,
|
|
11693
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm42.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
|
|
11537
11694
|
});
|
|
11538
11695
|
}
|
|
11539
11696
|
return [];
|
|
@@ -11546,7 +11703,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11546
11703
|
throw new Error("No lessonId provided");
|
|
11547
11704
|
}
|
|
11548
11705
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11549
|
-
where: (0,
|
|
11706
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm42.eq)(resourceProgress.resourceId, options.lessonId))
|
|
11550
11707
|
});
|
|
11551
11708
|
const now = /* @__PURE__ */ new Date();
|
|
11552
11709
|
if (lessonProgress) {
|
|
@@ -11554,7 +11711,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11554
11711
|
await client.update(resourceProgress).set({
|
|
11555
11712
|
completedAt: now,
|
|
11556
11713
|
updatedAt: now
|
|
11557
|
-
}).where((0,
|
|
11714
|
+
}).where((0, import_drizzle_orm42.eq)(resourceProgress.resourceId, options.lessonId));
|
|
11558
11715
|
}
|
|
11559
11716
|
} else {
|
|
11560
11717
|
await client.insert(resourceProgress).values({
|
|
@@ -11565,7 +11722,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11565
11722
|
});
|
|
11566
11723
|
}
|
|
11567
11724
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
11568
|
-
where: (0,
|
|
11725
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm42.eq)(resourceProgress.resourceId, options.lessonId))
|
|
11569
11726
|
});
|
|
11570
11727
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
11571
11728
|
if (!parsedLessonProgress.success) {
|
|
@@ -11578,7 +11735,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11578
11735
|
if (!options.couponId && !options.code)
|
|
11579
11736
|
return null;
|
|
11580
11737
|
const couponForIdOrCode = await client.query.coupon.findFirst({
|
|
11581
|
-
where: (0,
|
|
11738
|
+
where: (0, import_drizzle_orm42.or)((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.or)(options.code ? (0, import_drizzle_orm42.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm42.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm42.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.or)(options.code ? (0, import_drizzle_orm42.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm42.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm42.isNull)(coupon.expires))),
|
|
11582
11739
|
with: {
|
|
11583
11740
|
merchantCoupon: true
|
|
11584
11741
|
}
|
|
@@ -11594,15 +11751,29 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11594
11751
|
}
|
|
11595
11752
|
return parsedCoupon.data;
|
|
11596
11753
|
},
|
|
11754
|
+
async createMerchantSession(options) {
|
|
11755
|
+
const id = `ms_${(0, import_uuid.v4)()}`;
|
|
11756
|
+
await client.insert(merchantSession).values({
|
|
11757
|
+
id,
|
|
11758
|
+
identifier: options.identifier,
|
|
11759
|
+
merchantAccountId: options.merchantAccountId,
|
|
11760
|
+
...options.organizationId ? {
|
|
11761
|
+
organizationId: options.organizationId
|
|
11762
|
+
} : {}
|
|
11763
|
+
});
|
|
11764
|
+
return MerchantSessionSchema.parse(await client.query.merchantSession.findFirst({
|
|
11765
|
+
where: (0, import_drizzle_orm42.eq)(merchantSession.id, id)
|
|
11766
|
+
}));
|
|
11767
|
+
},
|
|
11597
11768
|
async createMerchantChargeAndPurchase(options) {
|
|
11598
11769
|
const purchaseId = await client.transaction(async (trx) => {
|
|
11599
11770
|
try {
|
|
11600
11771
|
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
|
|
11601
11772
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
11602
|
-
where: (0,
|
|
11773
|
+
where: (0, import_drizzle_orm42.eq)(merchantCharge.identifier, stripeChargeId)
|
|
11603
11774
|
}) || null);
|
|
11604
11775
|
const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
|
|
11605
|
-
where: (0,
|
|
11776
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
|
|
11606
11777
|
with: {
|
|
11607
11778
|
user: true,
|
|
11608
11779
|
product: true,
|
|
@@ -11623,12 +11794,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11623
11794
|
merchantCustomerId
|
|
11624
11795
|
});
|
|
11625
11796
|
const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
|
|
11626
|
-
where: (0,
|
|
11797
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm42.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm42.inArray)(purchaseTable.status, [
|
|
11627
11798
|
"Valid",
|
|
11628
11799
|
"Restricted"
|
|
11629
11800
|
]))
|
|
11630
11801
|
}) || null);
|
|
11631
|
-
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0,
|
|
11802
|
+
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm42.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm42.eq)(purchaseTable.userId, userId))).then((res) => {
|
|
11632
11803
|
return res[0]?.Coupon ?? null;
|
|
11633
11804
|
}));
|
|
11634
11805
|
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk || Boolean(existingPurchase?.status === "Valid");
|
|
@@ -11639,10 +11810,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11639
11810
|
if (existingBulkCoupon !== null) {
|
|
11640
11811
|
couponToUpdate = await client.update(coupon).set({
|
|
11641
11812
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
|
|
11642
|
-
}).where((0,
|
|
11813
|
+
}).where((0, import_drizzle_orm42.eq)(coupon.id, bulkCouponId));
|
|
11643
11814
|
} else {
|
|
11644
11815
|
const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
11645
|
-
where: (0,
|
|
11816
|
+
where: (0, import_drizzle_orm42.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
11646
11817
|
})) : null;
|
|
11647
11818
|
couponToUpdate = await client.insert(coupon).values({
|
|
11648
11819
|
id: bulkCouponId,
|
|
@@ -11657,19 +11828,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11657
11828
|
}
|
|
11658
11829
|
}
|
|
11659
11830
|
const merchantSessionId = `ms_${(0, import_uuid.v4)()}`;
|
|
11660
|
-
|
|
11831
|
+
await client.insert(merchantSession).values({
|
|
11661
11832
|
id: merchantSessionId,
|
|
11662
11833
|
identifier: checkoutSessionId,
|
|
11663
11834
|
merchantAccountId
|
|
11664
11835
|
});
|
|
11665
11836
|
const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
11666
|
-
where: (0,
|
|
11837
|
+
where: (0, import_drizzle_orm42.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
11667
11838
|
}) : null;
|
|
11668
11839
|
const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
11669
|
-
where: (0,
|
|
11840
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm42.eq)(merchantCoupon.type, "ppp"))
|
|
11670
11841
|
}) : null;
|
|
11671
11842
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
11672
|
-
|
|
11843
|
+
await client.insert(purchaseTable).values({
|
|
11673
11844
|
id: purchaseId2,
|
|
11674
11845
|
status: newPurchaseStatus,
|
|
11675
11846
|
userId,
|
|
@@ -11683,7 +11854,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11683
11854
|
couponId: usedCouponId || null
|
|
11684
11855
|
});
|
|
11685
11856
|
const oneWeekInMilliseconds = 1e3 * 60 * 60 * 24 * 7;
|
|
11686
|
-
|
|
11857
|
+
await client.insert(purchaseUserTransfer).values({
|
|
11687
11858
|
id: `put_${(0, import_uuid.v4)()}`,
|
|
11688
11859
|
purchaseId: purchaseId2,
|
|
11689
11860
|
expiresAt: existingPurchase ? /* @__PURE__ */ new Date() : new Date(Date.now() + oneWeekInMilliseconds),
|
|
@@ -11697,7 +11868,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11697
11868
|
}
|
|
11698
11869
|
});
|
|
11699
11870
|
const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
11700
|
-
where: (0,
|
|
11871
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.id, purchaseId)
|
|
11701
11872
|
}));
|
|
11702
11873
|
if (!parsedPurchase.success) {
|
|
11703
11874
|
console.error("Error parsing purchase", parsedPurchase, JSON.stringify(parsedPurchase, null, 2));
|
|
@@ -11742,7 +11913,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11742
11913
|
},
|
|
11743
11914
|
async getCoupon(couponIdOrCode) {
|
|
11744
11915
|
const loadedCoupon = await client.query.coupon.findFirst({
|
|
11745
|
-
where: (0,
|
|
11916
|
+
where: (0, import_drizzle_orm42.or)((0, import_drizzle_orm42.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm42.eq)(coupon.code, couponIdOrCode))
|
|
11746
11917
|
}) || null;
|
|
11747
11918
|
logger.debug("loadedCoupon", {
|
|
11748
11919
|
loadedCoupon
|
|
@@ -11757,7 +11928,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11757
11928
|
let bulkCouponPurchases;
|
|
11758
11929
|
try {
|
|
11759
11930
|
couponData = await client.query.coupon.findFirst({
|
|
11760
|
-
where: (0,
|
|
11931
|
+
where: (0, import_drizzle_orm42.eq)(coupon.id, couponId),
|
|
11761
11932
|
with: {
|
|
11762
11933
|
bulkPurchases: true,
|
|
11763
11934
|
redeemedBulkCouponPurchases: true
|
|
@@ -11769,7 +11940,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11769
11940
|
}
|
|
11770
11941
|
try {
|
|
11771
11942
|
bulkCouponPurchases = await client.query.purchases.findMany({
|
|
11772
|
-
where: (0,
|
|
11943
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.redeemedBulkCouponId, couponId),
|
|
11773
11944
|
with: {
|
|
11774
11945
|
user: true
|
|
11775
11946
|
}
|
|
@@ -11801,8 +11972,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11801
11972
|
},
|
|
11802
11973
|
async getDefaultCoupon(productIds) {
|
|
11803
11974
|
const activeSaleCoupon = await client.query.coupon.findFirst({
|
|
11804
|
-
where: (0,
|
|
11805
|
-
orderBy: (0,
|
|
11975
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(coupon.status, 1), (0, import_drizzle_orm42.eq)(coupon.default, true), (0, import_drizzle_orm42.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm42.or)(productIds ? (0, import_drizzle_orm42.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm42.isNull)(coupon.restrictedToProductId))),
|
|
11976
|
+
orderBy: (0, import_drizzle_orm42.desc)(coupon.percentageDiscount),
|
|
11806
11977
|
with: {
|
|
11807
11978
|
merchantCoupon: true,
|
|
11808
11979
|
product: true
|
|
@@ -11826,7 +11997,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11826
11997
|
},
|
|
11827
11998
|
async getLessonProgressForUser(userId) {
|
|
11828
11999
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
11829
|
-
where: (0,
|
|
12000
|
+
where: (0, import_drizzle_orm42.eq)(resourceProgress.userId, userId)
|
|
11830
12001
|
});
|
|
11831
12002
|
const parsed = z.array(resourceProgressSchema).safeParse(userProgress);
|
|
11832
12003
|
if (!parsed.success) {
|
|
@@ -11837,7 +12008,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11837
12008
|
},
|
|
11838
12009
|
async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
|
|
11839
12010
|
const user = await client.query.users.findFirst({
|
|
11840
|
-
where: (0,
|
|
12011
|
+
where: (0, import_drizzle_orm42.or)((0, import_drizzle_orm42.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm42.eq)(users.email, userIdOrEmail)),
|
|
11841
12012
|
columns: {
|
|
11842
12013
|
id: true
|
|
11843
12014
|
}
|
|
@@ -11849,12 +12020,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11849
12020
|
resource_id: z.string(),
|
|
11850
12021
|
resource_type: z.enum([
|
|
11851
12022
|
"lesson",
|
|
11852
|
-
"exercise"
|
|
12023
|
+
"exercise",
|
|
12024
|
+
"post"
|
|
11853
12025
|
]),
|
|
11854
12026
|
resource_slug: z.string().nullable(),
|
|
11855
12027
|
completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
|
|
11856
12028
|
});
|
|
11857
|
-
const results = await client.execute(
|
|
12029
|
+
const results = await client.execute(import_drizzle_orm42.sql`
|
|
11858
12030
|
SELECT
|
|
11859
12031
|
cr.id AS resource_id,
|
|
11860
12032
|
cr.type AS resource_type,
|
|
@@ -11885,7 +12057,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11885
12057
|
LEFT JOIN ${resourceProgress} rp ON rp.resourceId = cr.id
|
|
11886
12058
|
AND rp.userId = ${user.id}
|
|
11887
12059
|
WHERE
|
|
11888
|
-
cr.type IN ('lesson', 'exercise')
|
|
12060
|
+
cr.type IN ('lesson', 'exercise', 'post')
|
|
11889
12061
|
|
|
11890
12062
|
`);
|
|
11891
12063
|
const completedLessons = [];
|
|
@@ -11935,7 +12107,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11935
12107
|
},
|
|
11936
12108
|
async getMerchantCharge(merchantChargeId) {
|
|
11937
12109
|
const mCharge = await client.query.merchantCharge.findFirst({
|
|
11938
|
-
where: (0,
|
|
12110
|
+
where: (0, import_drizzle_orm42.eq)(merchantCharge.id, merchantChargeId)
|
|
11939
12111
|
});
|
|
11940
12112
|
const parsed = merchantChargeSchema.safeParse(mCharge);
|
|
11941
12113
|
if (!parsed.success) {
|
|
@@ -11946,12 +12118,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11946
12118
|
},
|
|
11947
12119
|
async getMerchantCouponsForTypeAndPercent(params) {
|
|
11948
12120
|
return z.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
|
|
11949
|
-
where: (0,
|
|
12121
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm42.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
11950
12122
|
}));
|
|
11951
12123
|
},
|
|
11952
12124
|
async getMerchantCouponForTypeAndPercent(params) {
|
|
11953
12125
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
11954
|
-
where: (0,
|
|
12126
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm42.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
11955
12127
|
});
|
|
11956
12128
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
11957
12129
|
if (parsed.success) {
|
|
@@ -11961,7 +12133,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11961
12133
|
},
|
|
11962
12134
|
async getMerchantCoupon(merchantCouponId) {
|
|
11963
12135
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
11964
|
-
where: (0,
|
|
12136
|
+
where: (0, import_drizzle_orm42.eq)(merchantCoupon.id, merchantCouponId)
|
|
11965
12137
|
});
|
|
11966
12138
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
11967
12139
|
if (parsed.success) {
|
|
@@ -11971,7 +12143,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11971
12143
|
},
|
|
11972
12144
|
async getMerchantProduct(stripeProductId) {
|
|
11973
12145
|
return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
|
|
11974
|
-
where: (0,
|
|
12146
|
+
where: (0, import_drizzle_orm42.eq)(merchantProduct.identifier, stripeProductId)
|
|
11975
12147
|
}));
|
|
11976
12148
|
},
|
|
11977
12149
|
getPrice(productId) {
|
|
@@ -11979,7 +12151,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11979
12151
|
},
|
|
11980
12152
|
async getPriceForProduct(productId) {
|
|
11981
12153
|
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
11982
|
-
where: (0,
|
|
12154
|
+
where: (0, import_drizzle_orm42.eq)(prices.productId, productId)
|
|
11983
12155
|
}));
|
|
11984
12156
|
},
|
|
11985
12157
|
async archiveProduct(productId) {
|
|
@@ -11995,19 +12167,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
11995
12167
|
await client.update(products).set({
|
|
11996
12168
|
status: 0,
|
|
11997
12169
|
name: `${product.name} (Archived)`
|
|
11998
|
-
}).where((0,
|
|
12170
|
+
}).where((0, import_drizzle_orm42.eq)(products.id, productId));
|
|
11999
12171
|
await client.update(prices).set({
|
|
12000
12172
|
status: 0,
|
|
12001
12173
|
nickname: `${product.name} (Archived)`
|
|
12002
|
-
}).where((0,
|
|
12174
|
+
}).where((0, import_drizzle_orm42.eq)(prices.productId, productId));
|
|
12003
12175
|
await client.update(merchantProduct).set({
|
|
12004
12176
|
status: 0
|
|
12005
|
-
}).where((0,
|
|
12177
|
+
}).where((0, import_drizzle_orm42.eq)(merchantProduct.productId, productId));
|
|
12006
12178
|
await client.update(merchantPrice).set({
|
|
12007
12179
|
status: 0
|
|
12008
|
-
}).where((0,
|
|
12180
|
+
}).where((0, import_drizzle_orm42.eq)(merchantPrice.priceId, product.price.id));
|
|
12009
12181
|
const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
12010
|
-
where: (0,
|
|
12182
|
+
where: (0, import_drizzle_orm42.eq)(merchantProduct.productId, productId)
|
|
12011
12183
|
}));
|
|
12012
12184
|
if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
|
|
12013
12185
|
throw new Error(`Merchant product not found for id (${productId})`);
|
|
@@ -12016,7 +12188,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12016
12188
|
active: false
|
|
12017
12189
|
});
|
|
12018
12190
|
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
12019
|
-
where: (0,
|
|
12191
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(merchantPrice.priceId, product.price.id), (0, import_drizzle_orm42.eq)(merchantPrice.status, 1))
|
|
12020
12192
|
}));
|
|
12021
12193
|
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
12022
12194
|
throw new Error(`Merchant price not found for id (${productId})`);
|
|
@@ -12076,12 +12248,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12076
12248
|
if (currentMerchantPrice) {
|
|
12077
12249
|
await client.update(merchantPrice).set({
|
|
12078
12250
|
status: 0
|
|
12079
|
-
}).where((0,
|
|
12251
|
+
}).where((0, import_drizzle_orm42.eq)(merchantPrice.id, currentMerchantPrice.id));
|
|
12080
12252
|
}
|
|
12081
12253
|
await client.update(prices).set({
|
|
12082
12254
|
unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
|
|
12083
12255
|
nickname: input.name
|
|
12084
|
-
}).where((0,
|
|
12256
|
+
}).where((0, import_drizzle_orm42.eq)(prices.id, currentProduct.price.id));
|
|
12085
12257
|
if (currentStripePrice) {
|
|
12086
12258
|
await paymentProvider.updatePrice(currentStripePrice.id, {
|
|
12087
12259
|
active: false
|
|
@@ -12110,7 +12282,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12110
12282
|
image
|
|
12111
12283
|
}
|
|
12112
12284
|
}
|
|
12113
|
-
}).where((0,
|
|
12285
|
+
}).where((0, import_drizzle_orm42.eq)(products.id, currentProduct.id));
|
|
12114
12286
|
return adapter.getProduct(currentProduct.id);
|
|
12115
12287
|
},
|
|
12116
12288
|
async createProduct(input) {
|
|
@@ -12186,7 +12358,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12186
12358
|
}
|
|
12187
12359
|
try {
|
|
12188
12360
|
const productData = await client.query.products.findFirst({
|
|
12189
|
-
where: (0,
|
|
12361
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.or)((0, import_drizzle_orm42.eq)(import_drizzle_orm42.sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), (0, import_drizzle_orm42.eq)(products.id, productSlugOrId))),
|
|
12190
12362
|
with: {
|
|
12191
12363
|
price: true,
|
|
12192
12364
|
...withResources && {
|
|
@@ -12215,20 +12387,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12215
12387
|
},
|
|
12216
12388
|
async getProductResources(productId) {
|
|
12217
12389
|
const contentResourceProductsForProduct = z.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
|
|
12218
|
-
where: (0,
|
|
12390
|
+
where: (0, import_drizzle_orm42.eq)(contentResourceProduct.productId, productId)
|
|
12219
12391
|
}));
|
|
12220
12392
|
if (!contentResourceProductsForProduct) {
|
|
12221
12393
|
return null;
|
|
12222
12394
|
} else {
|
|
12223
12395
|
const contentResources = z.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
|
|
12224
|
-
where: (0,
|
|
12396
|
+
where: (0, import_drizzle_orm42.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
|
|
12225
12397
|
}));
|
|
12226
12398
|
return contentResources;
|
|
12227
12399
|
}
|
|
12228
12400
|
},
|
|
12229
12401
|
async getPurchaseCountForProduct(productId) {
|
|
12230
12402
|
return await client.query.purchases.findMany({
|
|
12231
|
-
where: (0,
|
|
12403
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm42.inArray)(purchaseTable.status, [
|
|
12232
12404
|
"Valid",
|
|
12233
12405
|
"Restricted"
|
|
12234
12406
|
]))
|
|
@@ -12236,7 +12408,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12236
12408
|
},
|
|
12237
12409
|
async getPurchase(purchaseId) {
|
|
12238
12410
|
const purchase = await client.query.purchases.findFirst({
|
|
12239
|
-
where: (0,
|
|
12411
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.id, purchaseId)
|
|
12240
12412
|
});
|
|
12241
12413
|
return purchase ? purchaseSchema.parse(purchase) : null;
|
|
12242
12414
|
},
|
|
@@ -12254,14 +12426,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12254
12426
|
stripeChargeId
|
|
12255
12427
|
});
|
|
12256
12428
|
const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
12257
|
-
where: (0,
|
|
12429
|
+
where: (0, import_drizzle_orm42.eq)(merchantCharge.identifier, stripeChargeId)
|
|
12258
12430
|
}) || null);
|
|
12259
12431
|
if (!chargeForPurchase) {
|
|
12260
12432
|
logger.error(new Error(`No charge found for purchase: Stripe Charge ID: ${stripeChargeId}`));
|
|
12261
12433
|
return null;
|
|
12262
12434
|
}
|
|
12263
12435
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
12264
|
-
where: (0,
|
|
12436
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
|
|
12265
12437
|
with: {
|
|
12266
12438
|
user: true,
|
|
12267
12439
|
product: true,
|
|
@@ -12275,7 +12447,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12275
12447
|
},
|
|
12276
12448
|
async getPurchaseUserTransferById(options) {
|
|
12277
12449
|
const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
12278
|
-
where: (0,
|
|
12450
|
+
where: (0, import_drizzle_orm42.eq)(purchaseUserTransfer.id, options.id),
|
|
12279
12451
|
with: {
|
|
12280
12452
|
sourceUser: true,
|
|
12281
12453
|
targetUser: true,
|
|
@@ -12290,7 +12462,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12290
12462
|
},
|
|
12291
12463
|
async getPurchaseWithUser(purchaseId) {
|
|
12292
12464
|
const purchaseData = await client.query.purchases.findFirst({
|
|
12293
|
-
where: (0,
|
|
12465
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.id, purchaseId),
|
|
12294
12466
|
with: {
|
|
12295
12467
|
user: true
|
|
12296
12468
|
}
|
|
@@ -12314,13 +12486,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12314
12486
|
"Restricted"
|
|
12315
12487
|
];
|
|
12316
12488
|
const userPurchases = await client.query.purchases.findMany({
|
|
12317
|
-
where: (0,
|
|
12489
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm42.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
12318
12490
|
with: {
|
|
12319
12491
|
user: true,
|
|
12320
12492
|
product: true,
|
|
12321
12493
|
bulkCoupon: true
|
|
12322
12494
|
},
|
|
12323
|
-
orderBy: (0,
|
|
12495
|
+
orderBy: (0, import_drizzle_orm42.asc)(purchaseTable.createdAt)
|
|
12324
12496
|
});
|
|
12325
12497
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
12326
12498
|
if (!parsedPurchases.success) {
|
|
@@ -12336,18 +12508,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12336
12508
|
"Restricted"
|
|
12337
12509
|
];
|
|
12338
12510
|
const userPurchases = await client.query.purchases.findMany({
|
|
12339
|
-
where: (0,
|
|
12511
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm42.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
12340
12512
|
with: {
|
|
12341
12513
|
user: true,
|
|
12342
12514
|
product: true,
|
|
12343
12515
|
bulkCoupon: true
|
|
12344
12516
|
},
|
|
12345
|
-
orderBy: (0,
|
|
12517
|
+
orderBy: (0, import_drizzle_orm42.asc)(purchaseTable.createdAt)
|
|
12346
12518
|
});
|
|
12347
12519
|
const parsedPurchases = z.array(purchaseSchema).safeParse(userPurchases);
|
|
12348
12520
|
const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
|
|
12349
12521
|
const thePurchase = await client.query.purchases.findFirst({
|
|
12350
|
-
where: (0,
|
|
12522
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm42.eq)(purchaseTable.userId, userId)),
|
|
12351
12523
|
with: {
|
|
12352
12524
|
user: true,
|
|
12353
12525
|
product: true,
|
|
@@ -12368,7 +12540,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12368
12540
|
let availableUpgrades = [];
|
|
12369
12541
|
if (purchaseCanUpgrade) {
|
|
12370
12542
|
availableUpgrades = await client.query.upgradableProducts.findMany({
|
|
12371
|
-
where: (0,
|
|
12543
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm42.not)((0, import_drizzle_orm42.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
|
|
12372
12544
|
with: {
|
|
12373
12545
|
upgradableTo: true,
|
|
12374
12546
|
upgradableFrom: true
|
|
@@ -12376,10 +12548,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12376
12548
|
});
|
|
12377
12549
|
}
|
|
12378
12550
|
const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
|
|
12379
|
-
where: (0,
|
|
12551
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm42.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm42.inArray)(purchaseTable.status, [
|
|
12380
12552
|
"Valid",
|
|
12381
12553
|
"Restricted"
|
|
12382
|
-
]), (0,
|
|
12554
|
+
]), (0, import_drizzle_orm42.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm42.not)((0, import_drizzle_orm42.eq)(purchaseTable.id, parsedPurchase.data.id))),
|
|
12383
12555
|
with: {
|
|
12384
12556
|
user: true,
|
|
12385
12557
|
product: true,
|
|
@@ -12394,7 +12566,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12394
12566
|
},
|
|
12395
12567
|
async getUserWithPurchasersByEmail(email) {
|
|
12396
12568
|
const user = await client.query.users.findFirst({
|
|
12397
|
-
where: (0,
|
|
12569
|
+
where: (0, import_drizzle_orm42.eq)(users.email, email.trim().toLowerCase()),
|
|
12398
12570
|
with: {
|
|
12399
12571
|
// merchantCustomer: true,
|
|
12400
12572
|
roles: {
|
|
@@ -12421,7 +12593,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12421
12593
|
},
|
|
12422
12594
|
async getUserById(userId) {
|
|
12423
12595
|
const user = await client.query.users.findFirst({
|
|
12424
|
-
where: (0,
|
|
12596
|
+
where: (0, import_drizzle_orm42.eq)(users.id, userId),
|
|
12425
12597
|
with: {
|
|
12426
12598
|
roles: {
|
|
12427
12599
|
with: {
|
|
@@ -12443,13 +12615,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12443
12615
|
if (userId === void 0)
|
|
12444
12616
|
return [];
|
|
12445
12617
|
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
12446
|
-
where: (0,
|
|
12618
|
+
where: (0, import_drizzle_orm42.eq)(upgradableProducts.upgradableToId, bundleId)
|
|
12447
12619
|
});
|
|
12448
12620
|
const upgradableFrom = z.array(z.string()).parse(canUpgradeProducts.map((product) => {
|
|
12449
12621
|
return product.upgradableFromId;
|
|
12450
12622
|
}));
|
|
12451
12623
|
const purchases = await client.query.purchases.findMany({
|
|
12452
|
-
where: (0,
|
|
12624
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm42.inArray)(purchaseTable.productId, upgradableFrom))
|
|
12453
12625
|
});
|
|
12454
12626
|
const productsPurchased = z.array(z.string()).parse(purchases.map((purchase) => {
|
|
12455
12627
|
return purchase.productId;
|
|
@@ -12457,7 +12629,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12457
12629
|
if (productsPurchased.length === 0)
|
|
12458
12630
|
return [];
|
|
12459
12631
|
const foundPrices = await client.query.prices.findMany({
|
|
12460
|
-
where: (0,
|
|
12632
|
+
where: (0, import_drizzle_orm42.inArray)(prices.productId, productsPurchased)
|
|
12461
12633
|
});
|
|
12462
12634
|
return z.array(priceSchema).parse(foundPrices);
|
|
12463
12635
|
},
|
|
@@ -12466,14 +12638,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12466
12638
|
throw new Error("No lessonId provided");
|
|
12467
12639
|
}
|
|
12468
12640
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
12469
|
-
where: (0,
|
|
12641
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm42.eq)(resourceProgress.resourceId, options.lessonId))
|
|
12470
12642
|
});
|
|
12471
12643
|
const now = /* @__PURE__ */ new Date();
|
|
12472
12644
|
if (lessonProgress) {
|
|
12473
12645
|
await client.update(resourceProgress).set({
|
|
12474
12646
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
12475
12647
|
updatedAt: now
|
|
12476
|
-
}).where((0,
|
|
12648
|
+
}).where((0, import_drizzle_orm42.eq)(resourceProgress.resourceId, options.lessonId));
|
|
12477
12649
|
} else {
|
|
12478
12650
|
await client.insert(resourceProgress).values({
|
|
12479
12651
|
userId: options.userId,
|
|
@@ -12483,7 +12655,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12483
12655
|
});
|
|
12484
12656
|
}
|
|
12485
12657
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
12486
|
-
where: (0,
|
|
12658
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm42.eq)(resourceProgress.resourceId, options.lessonId))
|
|
12487
12659
|
});
|
|
12488
12660
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
12489
12661
|
if (!parsedLessonProgress.success) {
|
|
@@ -12505,7 +12677,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12505
12677
|
throw new Error("No purchase found");
|
|
12506
12678
|
await trx.update(purchaseTable).set({
|
|
12507
12679
|
userId: targetUserId
|
|
12508
|
-
}).where((0,
|
|
12680
|
+
}).where((0, import_drizzle_orm42.eq)(purchaseTable.id, purchase.id));
|
|
12509
12681
|
await trx.insert(purchaseUserTransfer).values({
|
|
12510
12682
|
id: transferId,
|
|
12511
12683
|
purchaseId: purchase.id,
|
|
@@ -12520,21 +12692,21 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12520
12692
|
if (paymentProvider && purchase.merchantChargeId) {
|
|
12521
12693
|
await trx.update(merchantCharge).set({
|
|
12522
12694
|
userId: targetUserId
|
|
12523
|
-
}).where((0,
|
|
12695
|
+
}).where((0, import_drizzle_orm42.eq)(merchantCharge.id, purchase.merchantChargeId));
|
|
12524
12696
|
const updatedMerchantCharge = await adapter.getMerchantCharge(purchase.merchantChargeId);
|
|
12525
12697
|
if (!updatedMerchantCharge)
|
|
12526
12698
|
throw new Error("No merchant charge found");
|
|
12527
12699
|
await trx.update(merchantCustomer).set({
|
|
12528
12700
|
userId: targetUserId
|
|
12529
|
-
}).where((0,
|
|
12701
|
+
}).where((0, import_drizzle_orm42.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId));
|
|
12530
12702
|
const updatedMerchantCustomer = merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
12531
|
-
where: (0,
|
|
12703
|
+
where: (0, import_drizzle_orm42.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId)
|
|
12532
12704
|
}));
|
|
12533
12705
|
const targetUser = userSchema.parse(await client.query.users.findFirst({
|
|
12534
|
-
where: (0,
|
|
12706
|
+
where: (0, import_drizzle_orm42.eq)(users.id, targetUserId)
|
|
12535
12707
|
}));
|
|
12536
12708
|
const sourceUser = userSchema.parse(await client.query.users.findFirst({
|
|
12537
|
-
where: (0,
|
|
12709
|
+
where: (0, import_drizzle_orm42.eq)(users.id, sourceUserId)
|
|
12538
12710
|
}));
|
|
12539
12711
|
await paymentProvider.updateCustomer(updatedMerchantCustomer.identifier, {
|
|
12540
12712
|
email: targetUser.email,
|
|
@@ -12561,7 +12733,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12561
12733
|
status
|
|
12562
12734
|
});
|
|
12563
12735
|
const merchantChargeForPurchase = await client.query.merchantCharge.findFirst({
|
|
12564
|
-
where: (0,
|
|
12736
|
+
where: (0, import_drizzle_orm42.or)((0, import_drizzle_orm42.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm42.eq)(merchantCharge.id, chargeId))
|
|
12565
12737
|
});
|
|
12566
12738
|
console.log("merchantChargeForPurchase", {
|
|
12567
12739
|
merchantChargeForPurchase
|
|
@@ -12570,15 +12742,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12570
12742
|
if (!parsedMerchantChargeForPurchase)
|
|
12571
12743
|
throw new Error(`no-charge-found-for-purchase ${chargeId}`);
|
|
12572
12744
|
const purchase = await client.query.purchases.findFirst({
|
|
12573
|
-
where: (0,
|
|
12745
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
|
|
12574
12746
|
});
|
|
12575
12747
|
const parsedPurchase = purchaseSchema.nullable().parse(purchase);
|
|
12576
12748
|
if (parsedPurchase) {
|
|
12577
12749
|
await client.update(purchaseTable).set({
|
|
12578
12750
|
status
|
|
12579
|
-
}).where((0,
|
|
12751
|
+
}).where((0, import_drizzle_orm42.eq)(purchaseTable.id, parsedPurchase.id));
|
|
12580
12752
|
const newPurchase = await client.query.purchases.findFirst({
|
|
12581
|
-
where: (0,
|
|
12753
|
+
where: (0, import_drizzle_orm42.eq)(purchaseTable.id, parsedPurchase.id)
|
|
12582
12754
|
});
|
|
12583
12755
|
return purchaseSchema.optional().parse(newPurchase);
|
|
12584
12756
|
} else {
|
|
@@ -12592,16 +12764,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12592
12764
|
async updatePurchaseUserTransferTransferState(options) {
|
|
12593
12765
|
await client.update(purchaseUserTransfer).set({
|
|
12594
12766
|
transferState: options.transferState
|
|
12595
|
-
}).where((0,
|
|
12767
|
+
}).where((0, import_drizzle_orm42.eq)(purchaseUserTransfer.id, options.id));
|
|
12596
12768
|
const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
12597
|
-
where: (0,
|
|
12769
|
+
where: (0, import_drizzle_orm42.eq)(purchaseUserTransfer.id, options.id)
|
|
12598
12770
|
}) || null;
|
|
12599
12771
|
return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
|
|
12600
12772
|
},
|
|
12601
12773
|
addResourceToResource: async function(options) {
|
|
12602
12774
|
const { parentResourceId, childResourceId } = options;
|
|
12603
12775
|
const parentResourceData = await client.query.contentResource.findFirst({
|
|
12604
|
-
where: (0,
|
|
12776
|
+
where: (0, import_drizzle_orm42.or)((0, import_drizzle_orm42.eq)(import_drizzle_orm42.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm42.eq)(contentResource.id, parentResourceId)),
|
|
12605
12777
|
with: {
|
|
12606
12778
|
resources: true
|
|
12607
12779
|
}
|
|
@@ -12613,7 +12785,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12613
12785
|
position: parentResource.resources?.length || 0
|
|
12614
12786
|
});
|
|
12615
12787
|
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
12616
|
-
where: (0,
|
|
12788
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm42.eq)(contentResourceResource.resourceId, childResourceId)),
|
|
12617
12789
|
with: {
|
|
12618
12790
|
resource: true
|
|
12619
12791
|
}
|
|
@@ -12627,28 +12799,28 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12627
12799
|
async removeResourceFromResource(options) {
|
|
12628
12800
|
const { childResourceId, parentResourceId } = options;
|
|
12629
12801
|
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
12630
|
-
where: (0,
|
|
12802
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm42.eq)(contentResourceResource.resourceId, childResourceId))
|
|
12631
12803
|
});
|
|
12632
12804
|
const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
|
|
12633
12805
|
if (!parsedResourceJoin.success) {
|
|
12634
12806
|
return null;
|
|
12635
12807
|
}
|
|
12636
|
-
await client.delete(contentResourceResource).where((0,
|
|
12808
|
+
await client.delete(contentResourceResource).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(contentResourceResource.resourceOfId, parentResourceId), (0, import_drizzle_orm42.eq)(contentResourceResource.resourceId, childResourceId)));
|
|
12637
12809
|
return parsedResourceJoin.data.resource;
|
|
12638
12810
|
},
|
|
12639
12811
|
async updateContentResourceFields(options) {
|
|
12640
12812
|
if (!options.id) {
|
|
12641
12813
|
throw new Error("No content resource id.");
|
|
12642
12814
|
}
|
|
12643
|
-
const currentResource = await client.select().from(contentResource).where((0,
|
|
12815
|
+
const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm42.eq)(contentResource.id, options.id)).then((res) => res[0]);
|
|
12644
12816
|
await client.update(contentResource).set({
|
|
12645
12817
|
fields: {
|
|
12646
12818
|
...currentResource.fields,
|
|
12647
12819
|
...options.fields
|
|
12648
12820
|
}
|
|
12649
|
-
}).where((0,
|
|
12821
|
+
}).where((0, import_drizzle_orm42.eq)(contentResource.id, options.id));
|
|
12650
12822
|
const resource = await client.query.contentResource.findFirst({
|
|
12651
|
-
where: (0,
|
|
12823
|
+
where: (0, import_drizzle_orm42.eq)(contentResource.id, options.id),
|
|
12652
12824
|
with: {
|
|
12653
12825
|
resources: {
|
|
12654
12826
|
with: {
|
|
@@ -12658,12 +12830,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12658
12830
|
with: {
|
|
12659
12831
|
resource: true
|
|
12660
12832
|
},
|
|
12661
|
-
orderBy: (0,
|
|
12833
|
+
orderBy: (0, import_drizzle_orm42.asc)(contentResourceResource.position)
|
|
12662
12834
|
}
|
|
12663
12835
|
}
|
|
12664
12836
|
}
|
|
12665
12837
|
},
|
|
12666
|
-
orderBy: (0,
|
|
12838
|
+
orderBy: (0, import_drizzle_orm42.asc)(contentResourceResource.position)
|
|
12667
12839
|
}
|
|
12668
12840
|
}
|
|
12669
12841
|
});
|
|
@@ -12678,7 +12850,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12678
12850
|
if (!id) {
|
|
12679
12851
|
return null;
|
|
12680
12852
|
}
|
|
12681
|
-
const query =
|
|
12853
|
+
const query = import_drizzle_orm42.sql`
|
|
12682
12854
|
SELECT
|
|
12683
12855
|
id as id,
|
|
12684
12856
|
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
@@ -12710,7 +12882,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12710
12882
|
id
|
|
12711
12883
|
});
|
|
12712
12884
|
const resource = await client.query.contentResource.findFirst({
|
|
12713
|
-
where: (0,
|
|
12885
|
+
where: (0, import_drizzle_orm42.eq)(contentResource.id, id),
|
|
12714
12886
|
with: {
|
|
12715
12887
|
resources: {
|
|
12716
12888
|
with: {
|
|
@@ -12720,12 +12892,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12720
12892
|
with: {
|
|
12721
12893
|
resource: true
|
|
12722
12894
|
},
|
|
12723
|
-
orderBy: (0,
|
|
12895
|
+
orderBy: (0, import_drizzle_orm42.asc)(contentResourceResource.position)
|
|
12724
12896
|
}
|
|
12725
12897
|
}
|
|
12726
12898
|
}
|
|
12727
12899
|
},
|
|
12728
|
-
orderBy: (0,
|
|
12900
|
+
orderBy: (0, import_drizzle_orm42.asc)(contentResourceResource.position)
|
|
12729
12901
|
}
|
|
12730
12902
|
}
|
|
12731
12903
|
});
|
|
@@ -12738,7 +12910,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12738
12910
|
},
|
|
12739
12911
|
async getContentResource(data) {
|
|
12740
12912
|
const resource = await client.query.contentResource.findFirst({
|
|
12741
|
-
where: (0,
|
|
12913
|
+
where: (0, import_drizzle_orm42.or)((0, import_drizzle_orm42.eq)(contentResource.id, data), (0, import_drizzle_orm42.eq)(import_drizzle_orm42.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
|
|
12742
12914
|
with: {
|
|
12743
12915
|
resources: {
|
|
12744
12916
|
with: {
|
|
@@ -12756,12 +12928,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12756
12928
|
}
|
|
12757
12929
|
}
|
|
12758
12930
|
},
|
|
12759
|
-
orderBy: (0,
|
|
12931
|
+
orderBy: (0, import_drizzle_orm42.asc)(contentResourceResource.position)
|
|
12760
12932
|
}
|
|
12761
12933
|
}
|
|
12762
12934
|
}
|
|
12763
12935
|
},
|
|
12764
|
-
orderBy: (0,
|
|
12936
|
+
orderBy: (0, import_drizzle_orm42.asc)(contentResourceResource.position)
|
|
12765
12937
|
}
|
|
12766
12938
|
}
|
|
12767
12939
|
});
|
|
@@ -12779,61 +12951,84 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12779
12951
|
...data,
|
|
12780
12952
|
id
|
|
12781
12953
|
});
|
|
12782
|
-
|
|
12954
|
+
const personalOrganization = await adapter.createOrganization({
|
|
12955
|
+
name: `Personal (${data.email})`
|
|
12956
|
+
});
|
|
12957
|
+
if (!personalOrganization) {
|
|
12958
|
+
throw new Error("Failed to create personal organization");
|
|
12959
|
+
}
|
|
12960
|
+
const membership = await adapter.addMemberToOrganization({
|
|
12961
|
+
organizationId: personalOrganization.id,
|
|
12962
|
+
userId: id,
|
|
12963
|
+
invitedById: id
|
|
12964
|
+
});
|
|
12965
|
+
if (!membership) {
|
|
12966
|
+
throw new Error("Failed to add user to personal organization");
|
|
12967
|
+
}
|
|
12968
|
+
await adapter.addRoleForMember({
|
|
12969
|
+
organizationId: personalOrganization.id,
|
|
12970
|
+
memberId: membership.id,
|
|
12971
|
+
role: "owner"
|
|
12972
|
+
});
|
|
12973
|
+
const user = await adapter.getUser?.(id);
|
|
12974
|
+
if (!user) {
|
|
12975
|
+
throw new Error("Failed to get user");
|
|
12976
|
+
}
|
|
12977
|
+
return user;
|
|
12783
12978
|
} catch (error) {
|
|
12784
12979
|
console.error(error);
|
|
12785
12980
|
throw error;
|
|
12786
12981
|
}
|
|
12787
12982
|
},
|
|
12788
12983
|
async getUser(data) {
|
|
12789
|
-
return await client.select().from(users).where((0,
|
|
12984
|
+
return await client.select().from(users).where((0, import_drizzle_orm42.eq)(users.id, data)).then((res) => res[0]) ?? null;
|
|
12790
12985
|
},
|
|
12791
12986
|
async getUserByEmail(data) {
|
|
12792
|
-
return await client.select().from(users).where((0,
|
|
12987
|
+
return await client.select().from(users).where((0, import_drizzle_orm42.eq)(users.email, data)).then((res) => res[0]) ?? null;
|
|
12793
12988
|
},
|
|
12794
12989
|
async createSession(data) {
|
|
12795
12990
|
await client.insert(sessions).values(data);
|
|
12796
|
-
return await client.select().from(sessions).where((0,
|
|
12991
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm42.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
12797
12992
|
},
|
|
12798
12993
|
async getSessionAndUser(data) {
|
|
12799
12994
|
return await client.select({
|
|
12800
12995
|
session: sessions,
|
|
12801
12996
|
user: users
|
|
12802
|
-
}).from(sessions).where((0,
|
|
12997
|
+
}).from(sessions).where((0, import_drizzle_orm42.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm42.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
|
|
12803
12998
|
},
|
|
12804
12999
|
async updateUser(data) {
|
|
12805
13000
|
if (!data.id) {
|
|
12806
13001
|
throw new Error("No user id.");
|
|
12807
13002
|
}
|
|
12808
|
-
await client.update(users).set(data).where((0,
|
|
12809
|
-
return await client.select().from(users).where((0,
|
|
13003
|
+
await client.update(users).set(data).where((0, import_drizzle_orm42.eq)(users.id, data.id));
|
|
13004
|
+
return await client.select().from(users).where((0, import_drizzle_orm42.eq)(users.id, data.id)).then((res) => res[0]);
|
|
12810
13005
|
},
|
|
12811
13006
|
async updateSession(data) {
|
|
12812
|
-
await client.update(sessions).set(data).where((0,
|
|
12813
|
-
return await client.select().from(sessions).where((0,
|
|
13007
|
+
await client.update(sessions).set(data).where((0, import_drizzle_orm42.eq)(sessions.sessionToken, data.sessionToken));
|
|
13008
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm42.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
12814
13009
|
},
|
|
12815
13010
|
async linkAccount(rawAccount) {
|
|
12816
13011
|
await client.insert(accounts).values(rawAccount);
|
|
12817
13012
|
},
|
|
12818
13013
|
async getUserByAccount(account) {
|
|
12819
|
-
const dbAccount = await client.select().from(accounts).where((0,
|
|
13014
|
+
const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm42.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm42.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
|
|
12820
13015
|
if (!dbAccount) {
|
|
12821
13016
|
return null;
|
|
12822
13017
|
}
|
|
12823
13018
|
return dbAccount.User;
|
|
12824
13019
|
},
|
|
12825
13020
|
async deleteSession(sessionToken) {
|
|
12826
|
-
const session = await client.select().from(sessions).where((0,
|
|
12827
|
-
await client.delete(sessions).where((0,
|
|
13021
|
+
const session = await client.select().from(sessions).where((0, import_drizzle_orm42.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
|
|
13022
|
+
await client.delete(sessions).where((0, import_drizzle_orm42.eq)(sessions.sessionToken, sessionToken));
|
|
12828
13023
|
return session;
|
|
12829
13024
|
},
|
|
12830
13025
|
async createVerificationToken(token) {
|
|
12831
13026
|
await client.insert(verificationTokens).values(token);
|
|
12832
|
-
return await client.select().from(verificationTokens).where((0,
|
|
13027
|
+
return await client.select().from(verificationTokens).where((0, import_drizzle_orm42.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
|
|
12833
13028
|
},
|
|
12834
13029
|
async useVerificationToken(token) {
|
|
12835
13030
|
try {
|
|
12836
|
-
const deletedToken = await client.select().from(verificationTokens).where((0,
|
|
13031
|
+
const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm42.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
|
|
12837
13032
|
if (deletedToken?.createdAt) {
|
|
12838
13033
|
const TIMEOUT_IN_SECONDS = 90;
|
|
12839
13034
|
const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
@@ -12842,7 +13037,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12842
13037
|
const { id: _, ...verificationToken } = token;
|
|
12843
13038
|
return deletedToken;
|
|
12844
13039
|
} else {
|
|
12845
|
-
await client.delete(verificationTokens).where((0,
|
|
13040
|
+
await client.delete(verificationTokens).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm42.eq)(verificationTokens.token, token.token)));
|
|
12846
13041
|
return deletedToken;
|
|
12847
13042
|
}
|
|
12848
13043
|
}
|
|
@@ -12852,15 +13047,147 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core46.mysqlTable, p
|
|
|
12852
13047
|
}
|
|
12853
13048
|
},
|
|
12854
13049
|
async deleteUser(id) {
|
|
12855
|
-
const user = await client.select().from(users).where((0,
|
|
12856
|
-
await client.delete(users).where((0,
|
|
12857
|
-
await client.delete(sessions).where((0,
|
|
12858
|
-
await client.delete(accounts).where((0,
|
|
13050
|
+
const user = await client.select().from(users).where((0, import_drizzle_orm42.eq)(users.id, id)).then((res) => res[0] ?? null);
|
|
13051
|
+
await client.delete(users).where((0, import_drizzle_orm42.eq)(users.id, id));
|
|
13052
|
+
await client.delete(sessions).where((0, import_drizzle_orm42.eq)(sessions.userId, id));
|
|
13053
|
+
await client.delete(accounts).where((0, import_drizzle_orm42.eq)(accounts.userId, id));
|
|
12859
13054
|
return user;
|
|
12860
13055
|
},
|
|
12861
13056
|
async unlinkAccount(account) {
|
|
12862
|
-
await client.delete(accounts).where((0,
|
|
13057
|
+
await client.delete(accounts).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm42.eq)(accounts.provider, account.provider)));
|
|
12863
13058
|
return void 0;
|
|
13059
|
+
},
|
|
13060
|
+
createOrganization: async (options) => {
|
|
13061
|
+
const organizationId = crypto.randomUUID();
|
|
13062
|
+
await client.insert(organizationTable).values({
|
|
13063
|
+
...options,
|
|
13064
|
+
id: organizationId
|
|
13065
|
+
});
|
|
13066
|
+
return adapter.getOrganization(organizationId);
|
|
13067
|
+
},
|
|
13068
|
+
getOrganization: async (organizationId) => {
|
|
13069
|
+
return OrganizationSchema.parse(await client.query.organization.findFirst({
|
|
13070
|
+
where: (0, import_drizzle_orm42.eq)(organizationTable.id, organizationId)
|
|
13071
|
+
}));
|
|
13072
|
+
},
|
|
13073
|
+
addMemberToOrganization: async (options) => {
|
|
13074
|
+
const id = crypto.randomUUID();
|
|
13075
|
+
await client.insert(organizationMembershipTable).values({
|
|
13076
|
+
...options,
|
|
13077
|
+
id
|
|
13078
|
+
});
|
|
13079
|
+
return OrganizationMemberSchema.parse(await client.query.organizationMemberships.findFirst({
|
|
13080
|
+
where: (0, import_drizzle_orm42.eq)(organizationMembershipTable.id, id),
|
|
13081
|
+
with: {
|
|
13082
|
+
organization: true,
|
|
13083
|
+
user: true
|
|
13084
|
+
}
|
|
13085
|
+
}));
|
|
13086
|
+
},
|
|
13087
|
+
removeMemberFromOrganization: async (options) => {
|
|
13088
|
+
await client.delete(organizationMembershipTable).where((0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm42.eq)(organizationMembershipTable.userId, options.userId)));
|
|
13089
|
+
},
|
|
13090
|
+
addRoleForMember: async (options) => {
|
|
13091
|
+
const existingRole = z.object({
|
|
13092
|
+
id: z.string()
|
|
13093
|
+
}).nullish().parse(await client.query.roles.findFirst({
|
|
13094
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(roleTable.organizationId, options.organizationId), (0, import_drizzle_orm42.eq)(roleTable.name, options.role))
|
|
13095
|
+
}));
|
|
13096
|
+
const roleId = existingRole?.id || crypto.randomUUID();
|
|
13097
|
+
if (!existingRole) {
|
|
13098
|
+
await client.insert(roleTable).values({
|
|
13099
|
+
name: options.role,
|
|
13100
|
+
organizationId: options.organizationId,
|
|
13101
|
+
id: roleId
|
|
13102
|
+
});
|
|
13103
|
+
}
|
|
13104
|
+
const currentOrgMembershipRole = await client.query.organizationMembershipRoles.findFirst({
|
|
13105
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(organizationMembershipRoleTable.organizationMembershipId, options.memberId), (0, import_drizzle_orm42.eq)(organizationMembershipRoleTable.roleId, roleId))
|
|
13106
|
+
});
|
|
13107
|
+
if (!currentOrgMembershipRole) {
|
|
13108
|
+
await client.insert(organizationMembershipRoleTable).values({
|
|
13109
|
+
organizationId: options.organizationId,
|
|
13110
|
+
organizationMembershipId: options.memberId,
|
|
13111
|
+
roleId
|
|
13112
|
+
});
|
|
13113
|
+
}
|
|
13114
|
+
},
|
|
13115
|
+
removeRoleForMember: async (options) => {
|
|
13116
|
+
const existingRole = z.object({
|
|
13117
|
+
id: z.string()
|
|
13118
|
+
}).nullable().parse(await client.query.roles.findFirst({
|
|
13119
|
+
where: (0, import_drizzle_orm42.and)((0, import_drizzle_orm42.eq)(roleTable.organizationId, options.organizationId), (0, import_drizzle_orm42.eq)(roleTable.name, options.role))
|
|
13120
|
+
}));
|
|
13121
|
+
const roleId = existingRole?.id;
|
|
13122
|
+
if (roleId) {
|
|
13123
|
+
await client.delete(organizationMembershipRoleTable).where((0, import_drizzle_orm42.eq)(organizationMembershipRoleTable.roleId, roleId));
|
|
13124
|
+
}
|
|
13125
|
+
},
|
|
13126
|
+
getMembershipsForUser: async (userId) => {
|
|
13127
|
+
return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
|
|
13128
|
+
where: (0, import_drizzle_orm42.eq)(organizationMembershipTable.userId, userId),
|
|
13129
|
+
with: {
|
|
13130
|
+
organization: true,
|
|
13131
|
+
user: true
|
|
13132
|
+
}
|
|
13133
|
+
}) || []);
|
|
13134
|
+
},
|
|
13135
|
+
getOrganizationMembers: async (organizationId) => {
|
|
13136
|
+
return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
|
|
13137
|
+
where: (0, import_drizzle_orm42.eq)(organizationMembershipTable.organizationId, organizationId)
|
|
13138
|
+
}) || []);
|
|
13139
|
+
},
|
|
13140
|
+
createSubscription: async (options) => {
|
|
13141
|
+
const id = `sub_${crypto.randomUUID()}`;
|
|
13142
|
+
await client.insert(subscriptionTable).values({
|
|
13143
|
+
...options,
|
|
13144
|
+
id
|
|
13145
|
+
});
|
|
13146
|
+
return SubscriptionSchema.parse(await client.query.subscription.findFirst({
|
|
13147
|
+
where: (0, import_drizzle_orm42.eq)(subscriptionTable.id, id),
|
|
13148
|
+
with: {
|
|
13149
|
+
product: true
|
|
13150
|
+
}
|
|
13151
|
+
}));
|
|
13152
|
+
},
|
|
13153
|
+
getMerchantSubscription: async (merchantSubscriptionId) => {
|
|
13154
|
+
return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
|
|
13155
|
+
where: (0, import_drizzle_orm42.eq)(merchantSubscriptionTable.id, merchantSubscriptionId)
|
|
13156
|
+
}));
|
|
13157
|
+
},
|
|
13158
|
+
createMerchantSubscription: async (options) => {
|
|
13159
|
+
const id = crypto.randomUUID();
|
|
13160
|
+
await client.insert(merchantSubscriptionTable).values({
|
|
13161
|
+
...options,
|
|
13162
|
+
id
|
|
13163
|
+
});
|
|
13164
|
+
return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
|
|
13165
|
+
where: (0, import_drizzle_orm42.eq)(merchantSubscriptionTable.id, id)
|
|
13166
|
+
}));
|
|
13167
|
+
},
|
|
13168
|
+
updateMerchantSubscription: async (options) => {
|
|
13169
|
+
throw new Error("Not implemented");
|
|
13170
|
+
},
|
|
13171
|
+
deleteMerchantSubscription: async (merchantSubscriptionId) => {
|
|
13172
|
+
throw new Error("Not implemented");
|
|
13173
|
+
},
|
|
13174
|
+
getSubscriptionForStripeId: async (stripeSubscriptionId) => {
|
|
13175
|
+
const merchantSubscriptionParsed = MerchantSubscriptionSchema.safeParse(await client.query.merchantSubscription.findFirst({
|
|
13176
|
+
where: (0, import_drizzle_orm42.eq)(merchantSubscriptionTable.identifier, stripeSubscriptionId)
|
|
13177
|
+
}));
|
|
13178
|
+
if (!merchantSubscriptionParsed.success) {
|
|
13179
|
+
throw new Error(`No merchant subscription found for stripe id ${stripeSubscriptionId} ${merchantSubscriptionParsed.error}`);
|
|
13180
|
+
}
|
|
13181
|
+
const subscriptionParsed = SubscriptionSchema.safeParse(await client.query.subscription.findFirst({
|
|
13182
|
+
where: (0, import_drizzle_orm42.eq)(subscriptionTable.merchantSubscriptionId, merchantSubscriptionParsed.data.id),
|
|
13183
|
+
with: {
|
|
13184
|
+
product: true
|
|
13185
|
+
}
|
|
13186
|
+
}));
|
|
13187
|
+
if (!subscriptionParsed.success) {
|
|
13188
|
+
throw new Error(`No subscription found for merchant subscription ${merchantSubscriptionParsed.data.id} ${subscriptionParsed.error}`);
|
|
13189
|
+
}
|
|
13190
|
+
return subscriptionParsed.data;
|
|
12864
13191
|
}
|
|
12865
13192
|
};
|
|
12866
13193
|
return adapter;
|