@coursebuilder/adapter-drizzle 1.0.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authjs.d.ts +27 -0
- package/dist/authjs.js +1 -0
- package/dist/chunk-3XHKEHGF.js +88 -0
- package/dist/{chunk-ENIKVP6O.js → chunk-4SMVVOU5.js} +2 -2
- package/dist/{chunk-EJ7UDN4T.js → chunk-52A4W4YI.js} +2 -2
- package/dist/{chunk-SUOPB24V.js → chunk-6VDGZ4KA.js} +2 -2
- package/dist/{chunk-MUFYDXA7.js → chunk-DB473RZJ.js} +9 -8
- package/dist/{chunk-XKCPXM63.js → chunk-DHII2GRW.js} +2 -2
- package/dist/{chunk-YMVONZZW.js → chunk-Q5NZ5UFZ.js} +2 -2
- package/dist/{chunk-5WMUBNWJ.js → chunk-QDWLBCD3.js} +2 -2
- package/dist/{chunk-MQSLKVLJ.js → chunk-RDAVEULA.js} +2 -2
- package/dist/{chunk-HEQ5MII4.js → chunk-ULJCXOOM.js} +564 -127
- package/dist/{chunk-U6XVAMCK.js → chunk-WPDVDHLH.js} +4 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +15 -14
- package/dist/lib/mysql/index.cjs +967 -456
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +412 -6
- package/dist/lib/mysql/index.d.ts +412 -6
- package/dist/lib/mysql/index.js +15 -14
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.d.cts +2 -2
- package/dist/lib/mysql/schemas/auth/accounts.d.ts +2 -2
- package/dist/lib/mysql/schemas/auth/accounts.js +3 -3
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.js +4 -4
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +4 -4
- package/dist/lib/mysql/schemas/auth/personal-access-token.cjs +288 -0
- package/dist/lib/mysql/schemas/auth/personal-access-token.cjs.map +1 -0
- package/dist/lib/mysql/schemas/auth/personal-access-token.d.cts +243 -0
- package/dist/lib/mysql/schemas/auth/personal-access-token.d.ts +243 -0
- package/dist/lib/mysql/schemas/auth/personal-access-token.js +21 -0
- package/dist/lib/mysql/schemas/auth/personal-access-token.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/profiles.js +3 -3
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +4 -4
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +3 -3
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +4 -4
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +3 -3
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.js +3 -3
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +3 -3
- package/dist/lib/mysql/schemas/auth/users.cjs +2 -1
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.js +3 -3
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +2 -1
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.js +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +3 -3
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +3 -3
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.js +3 -3
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.js +3 -3
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +4 -4
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +2 -1
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.js +3 -3
- package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/subscription.js +3 -3
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +4 -4
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.js +3 -3
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +3 -3
- package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/question-response.js +4 -4
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +3 -3
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.js +3 -3
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +3 -3
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +3 -3
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.js +3 -3
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +3 -3
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.js +3 -3
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.js +3 -3
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +2 -1
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
- package/dist/lib/mysql/schemas/entitlements/entitlement.js +4 -4
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +3 -3
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +2 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.js +3 -3
- package/dist/lib/mysql/schemas/org/organizations.cjs +2 -1
- package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organizations.js +3 -3
- package/dist/lib/utils.d.cts +3 -1
- package/dist/lib/utils.d.ts +3 -1
- package/package.json +9 -8
- package/src/authjs.ts +34 -0
- package/src/index.ts +2 -2
- package/src/lib/mysql/index.ts +224 -50
- package/src/lib/mysql/schemas/auth/accounts.ts +3 -2
- package/src/lib/mysql/schemas/auth/personal-access-token.ts +107 -0
- package/src/lib/mysql/schemas/commerce/purchase.ts +3 -0
- package/src/lib/mysql/schemas/entitlements/entitlement.ts +3 -0
package/dist/lib/mysql/index.cjs
CHANGED
|
@@ -40,8 +40,8 @@ __export(mysql_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(mysql_exports);
|
|
41
41
|
var import_slugify = __toESM(require("@sindresorhus/slugify"), 1);
|
|
42
42
|
var import_date_fns2 = require("date-fns");
|
|
43
|
-
var
|
|
44
|
-
var
|
|
43
|
+
var import_drizzle_orm46 = require("drizzle-orm");
|
|
44
|
+
var import_mysql_core52 = require("drizzle-orm/mysql-core");
|
|
45
45
|
var import_nanoid = require("nanoid");
|
|
46
46
|
var import_uuid = require("uuid");
|
|
47
47
|
|
|
@@ -313,8 +313,8 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
313
313
|
"not_finite"
|
|
314
314
|
]);
|
|
315
315
|
var quotelessJson = /* @__PURE__ */ __name((obj) => {
|
|
316
|
-
const
|
|
317
|
-
return
|
|
316
|
+
const json24 = JSON.stringify(obj, null, 2);
|
|
317
|
+
return json24.replace(/"([^"]+)":/g, "$1:");
|
|
318
318
|
}, "quotelessJson");
|
|
319
319
|
var _ZodError = class _ZodError extends Error {
|
|
320
320
|
get errors() {
|
|
@@ -2889,10 +2889,10 @@ var _ZodObject = class _ZodObject extends ZodType {
|
|
|
2889
2889
|
// }) as any;
|
|
2890
2890
|
// return merged;
|
|
2891
2891
|
// }
|
|
2892
|
-
catchall(
|
|
2892
|
+
catchall(index48) {
|
|
2893
2893
|
return new _ZodObject({
|
|
2894
2894
|
...this._def,
|
|
2895
|
-
catchall:
|
|
2895
|
+
catchall: index48
|
|
2896
2896
|
});
|
|
2897
2897
|
}
|
|
2898
2898
|
pick(mask) {
|
|
@@ -3247,9 +3247,9 @@ function mergeValues(a, b) {
|
|
|
3247
3247
|
};
|
|
3248
3248
|
}
|
|
3249
3249
|
const newArray = [];
|
|
3250
|
-
for (let
|
|
3251
|
-
const itemA = a[
|
|
3252
|
-
const itemB = b[
|
|
3250
|
+
for (let index48 = 0; index48 < a.length; index48++) {
|
|
3251
|
+
const itemA = a[index48];
|
|
3252
|
+
const itemB = b[index48];
|
|
3253
3253
|
const sharedValue = mergeValues(itemA, itemB);
|
|
3254
3254
|
if (!sharedValue.valid) {
|
|
3255
3255
|
return {
|
|
@@ -3479,14 +3479,14 @@ var _ZodMap = class _ZodMap extends ZodType {
|
|
|
3479
3479
|
const valueType = this._def.valueType;
|
|
3480
3480
|
const pairs = [
|
|
3481
3481
|
...ctx.data.entries()
|
|
3482
|
-
].map(([key, value],
|
|
3482
|
+
].map(([key, value], index48) => {
|
|
3483
3483
|
return {
|
|
3484
3484
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
|
3485
|
-
|
|
3485
|
+
index48,
|
|
3486
3486
|
"key"
|
|
3487
3487
|
])),
|
|
3488
3488
|
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [
|
|
3489
|
-
|
|
3489
|
+
index48,
|
|
3490
3490
|
"value"
|
|
3491
3491
|
]))
|
|
3492
3492
|
};
|
|
@@ -4700,8 +4700,8 @@ var ZodIssueCode2 = util2.arrayToEnum([
|
|
|
4700
4700
|
"not_finite"
|
|
4701
4701
|
]);
|
|
4702
4702
|
var quotelessJson2 = /* @__PURE__ */ __name2((obj) => {
|
|
4703
|
-
const
|
|
4704
|
-
return
|
|
4703
|
+
const json24 = JSON.stringify(obj, null, 2);
|
|
4704
|
+
return json24.replace(/"([^"]+)":/g, "$1:");
|
|
4705
4705
|
}, "quotelessJson");
|
|
4706
4706
|
var _a2;
|
|
4707
4707
|
var _ZodError2 = (_a2 = class extends Error {
|
|
@@ -7293,10 +7293,10 @@ var _ZodObject2 = (_a20 = class extends ZodType2 {
|
|
|
7293
7293
|
// }) as any;
|
|
7294
7294
|
// return merged;
|
|
7295
7295
|
// }
|
|
7296
|
-
catchall(
|
|
7296
|
+
catchall(index48) {
|
|
7297
7297
|
return new _a20({
|
|
7298
7298
|
...this._def,
|
|
7299
|
-
catchall:
|
|
7299
|
+
catchall: index48
|
|
7300
7300
|
});
|
|
7301
7301
|
}
|
|
7302
7302
|
pick(mask) {
|
|
@@ -7654,9 +7654,9 @@ function mergeValues2(a, b) {
|
|
|
7654
7654
|
};
|
|
7655
7655
|
}
|
|
7656
7656
|
const newArray = [];
|
|
7657
|
-
for (let
|
|
7658
|
-
const itemA = a[
|
|
7659
|
-
const itemB = b[
|
|
7657
|
+
for (let index48 = 0; index48 < a.length; index48++) {
|
|
7658
|
+
const itemA = a[index48];
|
|
7659
|
+
const itemB = b[index48];
|
|
7660
7660
|
const sharedValue = mergeValues2(itemA, itemB);
|
|
7661
7661
|
if (!sharedValue.valid) {
|
|
7662
7662
|
return {
|
|
@@ -7891,14 +7891,14 @@ var _ZodMap2 = (_a26 = class extends ZodType2 {
|
|
|
7891
7891
|
const valueType = this._def.valueType;
|
|
7892
7892
|
const pairs = [
|
|
7893
7893
|
...ctx.data.entries()
|
|
7894
|
-
].map(([key, value],
|
|
7894
|
+
].map(([key, value], index48) => {
|
|
7895
7895
|
return {
|
|
7896
7896
|
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
|
|
7897
|
-
|
|
7897
|
+
index48,
|
|
7898
7898
|
"key"
|
|
7899
7899
|
])),
|
|
7900
7900
|
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
|
|
7901
|
-
|
|
7901
|
+
index48,
|
|
7902
7902
|
"value"
|
|
7903
7903
|
]))
|
|
7904
7904
|
};
|
|
@@ -9063,6 +9063,280 @@ __export2(external_exports2, {
|
|
|
9063
9063
|
void: () => voidType2
|
|
9064
9064
|
});
|
|
9065
9065
|
|
|
9066
|
+
// ../core/dist/chunk-H3WWX3FM.js
|
|
9067
|
+
var PURCHASE_BENEFIT_METADATA_KEY = "purchaseBenefits";
|
|
9068
|
+
var PURCHASE_BENEFIT_TRANSPORT_VERSION = 1;
|
|
9069
|
+
var purchaseBenefitTypeSchema = external_exports2.literal("access");
|
|
9070
|
+
var purchaseBenefitAppliesToSchema = external_exports2.enum([
|
|
9071
|
+
"buyer",
|
|
9072
|
+
"redeemed_team_seat"
|
|
9073
|
+
]);
|
|
9074
|
+
var purchaseBenefitIntentSchema = external_exports2.object({
|
|
9075
|
+
type: purchaseBenefitTypeSchema,
|
|
9076
|
+
resourceType: external_exports2.string().min(1),
|
|
9077
|
+
resourceId: external_exports2.string().min(1),
|
|
9078
|
+
welcomeEmailResourceId: external_exports2.string().min(1).optional()
|
|
9079
|
+
});
|
|
9080
|
+
var expandedPurchaseBenefitSourceSchema = external_exports2.object({
|
|
9081
|
+
transportVersion: external_exports2.literal(PURCHASE_BENEFIT_TRANSPORT_VERSION),
|
|
9082
|
+
metadataKey: external_exports2.literal(PURCHASE_BENEFIT_METADATA_KEY),
|
|
9083
|
+
transport: external_exports2.string(),
|
|
9084
|
+
index: external_exports2.number().int().nonnegative()
|
|
9085
|
+
});
|
|
9086
|
+
var expandedPurchaseBenefitSchema = purchaseBenefitIntentSchema.extend({
|
|
9087
|
+
id: external_exports2.string().min(1),
|
|
9088
|
+
appliesTo: purchaseBenefitAppliesToSchema,
|
|
9089
|
+
source: expandedPurchaseBenefitSourceSchema
|
|
9090
|
+
});
|
|
9091
|
+
var purchaseBenefitTransportReviewSchema = external_exports2.object({
|
|
9092
|
+
status: external_exports2.literal("needs_review"),
|
|
9093
|
+
metadataKey: external_exports2.literal(PURCHASE_BENEFIT_METADATA_KEY),
|
|
9094
|
+
transport: external_exports2.string().optional(),
|
|
9095
|
+
errors: external_exports2.array(external_exports2.object({
|
|
9096
|
+
code: external_exports2.string().min(1),
|
|
9097
|
+
message: external_exports2.string().min(1),
|
|
9098
|
+
path: external_exports2.array(external_exports2.union([
|
|
9099
|
+
external_exports2.string(),
|
|
9100
|
+
external_exports2.number()
|
|
9101
|
+
])).optional()
|
|
9102
|
+
}))
|
|
9103
|
+
});
|
|
9104
|
+
function parsePurchaseBenefitTransport(transport) {
|
|
9105
|
+
if (!transport || transport.trim().length === 0) {
|
|
9106
|
+
return {
|
|
9107
|
+
success: false,
|
|
9108
|
+
errors: [
|
|
9109
|
+
{
|
|
9110
|
+
code: "missing_transport",
|
|
9111
|
+
message: "Purchase Benefit Transport is required."
|
|
9112
|
+
}
|
|
9113
|
+
]
|
|
9114
|
+
};
|
|
9115
|
+
}
|
|
9116
|
+
let parsed;
|
|
9117
|
+
try {
|
|
9118
|
+
parsed = JSON.parse(transport);
|
|
9119
|
+
} catch {
|
|
9120
|
+
return {
|
|
9121
|
+
success: false,
|
|
9122
|
+
errors: [
|
|
9123
|
+
{
|
|
9124
|
+
code: "malformed_json",
|
|
9125
|
+
message: "Purchase Benefit Transport must be valid JSON."
|
|
9126
|
+
}
|
|
9127
|
+
]
|
|
9128
|
+
};
|
|
9129
|
+
}
|
|
9130
|
+
if (!isRecord(parsed)) {
|
|
9131
|
+
return invalidTransportShape();
|
|
9132
|
+
}
|
|
9133
|
+
if (parsed.v !== PURCHASE_BENEFIT_TRANSPORT_VERSION) {
|
|
9134
|
+
return {
|
|
9135
|
+
success: false,
|
|
9136
|
+
errors: [
|
|
9137
|
+
{
|
|
9138
|
+
code: "unsupported_version",
|
|
9139
|
+
message: `Unsupported Purchase Benefit Transport version: ${String(parsed.v)}.`,
|
|
9140
|
+
path: [
|
|
9141
|
+
"v"
|
|
9142
|
+
]
|
|
9143
|
+
}
|
|
9144
|
+
]
|
|
9145
|
+
};
|
|
9146
|
+
}
|
|
9147
|
+
if (!Array.isArray(parsed.b)) {
|
|
9148
|
+
return {
|
|
9149
|
+
success: false,
|
|
9150
|
+
errors: [
|
|
9151
|
+
{
|
|
9152
|
+
code: "invalid_benefits_shape",
|
|
9153
|
+
message: "Purchase Benefit Transport benefits must be an array.",
|
|
9154
|
+
path: [
|
|
9155
|
+
"b"
|
|
9156
|
+
]
|
|
9157
|
+
}
|
|
9158
|
+
]
|
|
9159
|
+
};
|
|
9160
|
+
}
|
|
9161
|
+
const errors = [];
|
|
9162
|
+
const benefits = [];
|
|
9163
|
+
parsed.b.forEach((tuple, index48) => {
|
|
9164
|
+
const tuplePath = [
|
|
9165
|
+
"b",
|
|
9166
|
+
index48
|
|
9167
|
+
];
|
|
9168
|
+
if (!Array.isArray(tuple) || tuple.length < 3 || tuple.length > 4) {
|
|
9169
|
+
errors.push({
|
|
9170
|
+
code: "invalid_tuple_shape",
|
|
9171
|
+
message: "Purchase Benefit tuple must be [type, resourceType, resourceId, optionalWelcomeEmailResourceId].",
|
|
9172
|
+
path: tuplePath
|
|
9173
|
+
});
|
|
9174
|
+
return;
|
|
9175
|
+
}
|
|
9176
|
+
const [type, rawResourceType, rawResourceId, rawWelcomeEmailResourceId] = tuple;
|
|
9177
|
+
const resourceType = typeof rawResourceType === "string" ? rawResourceType.trim() : rawResourceType;
|
|
9178
|
+
const resourceId = typeof rawResourceId === "string" ? rawResourceId.trim() : rawResourceId;
|
|
9179
|
+
const welcomeEmailResourceId = typeof rawWelcomeEmailResourceId === "string" ? rawWelcomeEmailResourceId.trim() : rawWelcomeEmailResourceId;
|
|
9180
|
+
if (type !== "access") {
|
|
9181
|
+
errors.push({
|
|
9182
|
+
code: "unsupported_benefit_type",
|
|
9183
|
+
message: `Unsupported Purchase Benefit type: ${String(type)}.`,
|
|
9184
|
+
path: [
|
|
9185
|
+
...tuplePath,
|
|
9186
|
+
0
|
|
9187
|
+
]
|
|
9188
|
+
});
|
|
9189
|
+
}
|
|
9190
|
+
if (!isNonEmptyString(resourceType)) {
|
|
9191
|
+
errors.push({
|
|
9192
|
+
code: "missing_resource_type",
|
|
9193
|
+
message: "Purchase Benefit resourceType is required.",
|
|
9194
|
+
path: [
|
|
9195
|
+
...tuplePath,
|
|
9196
|
+
1
|
|
9197
|
+
]
|
|
9198
|
+
});
|
|
9199
|
+
}
|
|
9200
|
+
if (!isNonEmptyString(resourceId)) {
|
|
9201
|
+
errors.push({
|
|
9202
|
+
code: "missing_resource_id",
|
|
9203
|
+
message: "Purchase Benefit resourceId is required.",
|
|
9204
|
+
path: [
|
|
9205
|
+
...tuplePath,
|
|
9206
|
+
2
|
|
9207
|
+
]
|
|
9208
|
+
});
|
|
9209
|
+
}
|
|
9210
|
+
if (welcomeEmailResourceId !== void 0 && !isNonEmptyString(welcomeEmailResourceId)) {
|
|
9211
|
+
errors.push({
|
|
9212
|
+
code: "invalid_welcome_email_resource_id",
|
|
9213
|
+
message: "Purchase Benefit welcomeEmailResourceId must be a non-empty string when provided.",
|
|
9214
|
+
path: [
|
|
9215
|
+
...tuplePath,
|
|
9216
|
+
3
|
|
9217
|
+
]
|
|
9218
|
+
});
|
|
9219
|
+
}
|
|
9220
|
+
if (type === "access" && isNonEmptyString(resourceType) && isNonEmptyString(resourceId) && (welcomeEmailResourceId === void 0 || isNonEmptyString(welcomeEmailResourceId))) {
|
|
9221
|
+
benefits.push({
|
|
9222
|
+
type,
|
|
9223
|
+
resourceType,
|
|
9224
|
+
resourceId,
|
|
9225
|
+
...welcomeEmailResourceId ? {
|
|
9226
|
+
welcomeEmailResourceId
|
|
9227
|
+
} : {}
|
|
9228
|
+
});
|
|
9229
|
+
}
|
|
9230
|
+
});
|
|
9231
|
+
if (errors.length > 0) {
|
|
9232
|
+
return {
|
|
9233
|
+
success: false,
|
|
9234
|
+
errors
|
|
9235
|
+
};
|
|
9236
|
+
}
|
|
9237
|
+
return {
|
|
9238
|
+
success: true,
|
|
9239
|
+
version: PURCHASE_BENEFIT_TRANSPORT_VERSION,
|
|
9240
|
+
benefits
|
|
9241
|
+
};
|
|
9242
|
+
}
|
|
9243
|
+
__name(parsePurchaseBenefitTransport, "parsePurchaseBenefitTransport");
|
|
9244
|
+
__name2(parsePurchaseBenefitTransport, "parsePurchaseBenefitTransport");
|
|
9245
|
+
function expandPurchaseBenefits(input) {
|
|
9246
|
+
return input.benefits.map((benefit, index48) => ({
|
|
9247
|
+
id: createPurchaseBenefitId(benefit, input.appliesTo, index48),
|
|
9248
|
+
...benefit,
|
|
9249
|
+
appliesTo: input.appliesTo,
|
|
9250
|
+
source: {
|
|
9251
|
+
transportVersion: PURCHASE_BENEFIT_TRANSPORT_VERSION,
|
|
9252
|
+
metadataKey: PURCHASE_BENEFIT_METADATA_KEY,
|
|
9253
|
+
transport: input.transport,
|
|
9254
|
+
index: index48
|
|
9255
|
+
}
|
|
9256
|
+
}));
|
|
9257
|
+
}
|
|
9258
|
+
__name(expandPurchaseBenefits, "expandPurchaseBenefits");
|
|
9259
|
+
__name2(expandPurchaseBenefits, "expandPurchaseBenefits");
|
|
9260
|
+
function parseAndExpandPurchaseBenefitTransport(input) {
|
|
9261
|
+
const parsed = parsePurchaseBenefitTransport(input.transport);
|
|
9262
|
+
if (!parsed.success) {
|
|
9263
|
+
return {
|
|
9264
|
+
success: false,
|
|
9265
|
+
review: purchaseBenefitTransportErrorsToReview({
|
|
9266
|
+
transport: input.transport ?? void 0,
|
|
9267
|
+
errors: parsed.errors
|
|
9268
|
+
})
|
|
9269
|
+
};
|
|
9270
|
+
}
|
|
9271
|
+
return {
|
|
9272
|
+
success: true,
|
|
9273
|
+
benefits: expandPurchaseBenefits({
|
|
9274
|
+
transport: input.transport ?? "",
|
|
9275
|
+
benefits: parsed.benefits,
|
|
9276
|
+
appliesTo: input.appliesTo
|
|
9277
|
+
})
|
|
9278
|
+
};
|
|
9279
|
+
}
|
|
9280
|
+
__name(parseAndExpandPurchaseBenefitTransport, "parseAndExpandPurchaseBenefitTransport");
|
|
9281
|
+
__name2(parseAndExpandPurchaseBenefitTransport, "parseAndExpandPurchaseBenefitTransport");
|
|
9282
|
+
function purchaseBenefitTransportErrorsToReview(input) {
|
|
9283
|
+
return purchaseBenefitTransportReviewSchema.parse({
|
|
9284
|
+
status: "needs_review",
|
|
9285
|
+
metadataKey: PURCHASE_BENEFIT_METADATA_KEY,
|
|
9286
|
+
transport: input.transport,
|
|
9287
|
+
errors: input.errors
|
|
9288
|
+
});
|
|
9289
|
+
}
|
|
9290
|
+
__name(purchaseBenefitTransportErrorsToReview, "purchaseBenefitTransportErrorsToReview");
|
|
9291
|
+
__name2(purchaseBenefitTransportErrorsToReview, "purchaseBenefitTransportErrorsToReview");
|
|
9292
|
+
function invalidTransportShape() {
|
|
9293
|
+
return {
|
|
9294
|
+
success: false,
|
|
9295
|
+
errors: [
|
|
9296
|
+
{
|
|
9297
|
+
code: "invalid_transport_shape",
|
|
9298
|
+
message: "Purchase Benefit Transport must be an object with version and benefits."
|
|
9299
|
+
}
|
|
9300
|
+
]
|
|
9301
|
+
};
|
|
9302
|
+
}
|
|
9303
|
+
__name(invalidTransportShape, "invalidTransportShape");
|
|
9304
|
+
__name2(invalidTransportShape, "invalidTransportShape");
|
|
9305
|
+
function createPurchaseBenefitId(benefit, appliesTo, index48) {
|
|
9306
|
+
const hash = hashString(JSON.stringify([
|
|
9307
|
+
PURCHASE_BENEFIT_TRANSPORT_VERSION,
|
|
9308
|
+
appliesTo,
|
|
9309
|
+
index48,
|
|
9310
|
+
benefit.type,
|
|
9311
|
+
benefit.resourceType,
|
|
9312
|
+
benefit.resourceId,
|
|
9313
|
+
benefit.welcomeEmailResourceId ?? null
|
|
9314
|
+
]));
|
|
9315
|
+
return `pb_${hash}`;
|
|
9316
|
+
}
|
|
9317
|
+
__name(createPurchaseBenefitId, "createPurchaseBenefitId");
|
|
9318
|
+
__name2(createPurchaseBenefitId, "createPurchaseBenefitId");
|
|
9319
|
+
function hashString(value) {
|
|
9320
|
+
let hash = 2166136261;
|
|
9321
|
+
for (let index48 = 0; index48 < value.length; index48++) {
|
|
9322
|
+
hash ^= value.charCodeAt(index48);
|
|
9323
|
+
hash = Math.imul(hash, 16777619);
|
|
9324
|
+
}
|
|
9325
|
+
return (hash >>> 0).toString(36);
|
|
9326
|
+
}
|
|
9327
|
+
__name(hashString, "hashString");
|
|
9328
|
+
__name2(hashString, "hashString");
|
|
9329
|
+
function isRecord(value) {
|
|
9330
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9331
|
+
}
|
|
9332
|
+
__name(isRecord, "isRecord");
|
|
9333
|
+
__name2(isRecord, "isRecord");
|
|
9334
|
+
function isNonEmptyString(value) {
|
|
9335
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
9336
|
+
}
|
|
9337
|
+
__name(isNonEmptyString, "isNonEmptyString");
|
|
9338
|
+
__name2(isNonEmptyString, "isNonEmptyString");
|
|
9339
|
+
|
|
9066
9340
|
// ../core/dist/chunk-KXTOX2R2.js
|
|
9067
9341
|
var upgradableProductSchema = external_exports2.object({
|
|
9068
9342
|
upgradableToId: external_exports2.string().max(255),
|
|
@@ -9074,7 +9348,11 @@ var upgradableProductSchema = external_exports2.object({
|
|
|
9074
9348
|
deletedAt: external_exports2.date().nullable()
|
|
9075
9349
|
});
|
|
9076
9350
|
|
|
9077
|
-
// ../core/dist/chunk-
|
|
9351
|
+
// ../core/dist/chunk-QHRMESWX.js
|
|
9352
|
+
var VideoChapterSchema = external_exports2.object({
|
|
9353
|
+
startTime: external_exports2.number().min(0),
|
|
9354
|
+
title: external_exports2.string().min(1).max(120)
|
|
9355
|
+
}).strict();
|
|
9078
9356
|
var VideoResourceSchema = external_exports2.object({
|
|
9079
9357
|
id: external_exports2.string(),
|
|
9080
9358
|
updatedAt: external_exports2.coerce.date().optional(),
|
|
@@ -9087,6 +9365,7 @@ var VideoResourceSchema = external_exports2.object({
|
|
|
9087
9365
|
transcriptWithScreenshots: external_exports2.string().optional().nullable(),
|
|
9088
9366
|
srt: external_exports2.string().optional().nullable(),
|
|
9089
9367
|
wordLevelSrt: external_exports2.string().optional().nullable(),
|
|
9368
|
+
chapters: external_exports2.array(VideoChapterSchema).optional().nullable(),
|
|
9090
9369
|
state: external_exports2.enum([
|
|
9091
9370
|
"new",
|
|
9092
9371
|
"processing",
|
|
@@ -9097,44 +9376,6 @@ var VideoResourceSchema = external_exports2.object({
|
|
|
9097
9376
|
])
|
|
9098
9377
|
});
|
|
9099
9378
|
|
|
9100
|
-
// ../core/dist/chunk-4EYC75KK.js
|
|
9101
|
-
var userSchema = external_exports2.object({
|
|
9102
|
-
id: external_exports2.string().max(255),
|
|
9103
|
-
name: external_exports2.string().max(255).optional().nullable(),
|
|
9104
|
-
role: external_exports2.enum([
|
|
9105
|
-
"user",
|
|
9106
|
-
"admin",
|
|
9107
|
-
"contributor"
|
|
9108
|
-
]).default("user"),
|
|
9109
|
-
email: external_exports2.string().max(255).email(),
|
|
9110
|
-
emailVerified: external_exports2.coerce.date().nullish(),
|
|
9111
|
-
image: external_exports2.string().max(255).optional().nullable(),
|
|
9112
|
-
createdAt: external_exports2.coerce.date().nullish(),
|
|
9113
|
-
memberships: external_exports2.array(external_exports2.object({
|
|
9114
|
-
id: external_exports2.string(),
|
|
9115
|
-
organizationId: external_exports2.string()
|
|
9116
|
-
})).nullish().default([]),
|
|
9117
|
-
roles: external_exports2.array(external_exports2.object({
|
|
9118
|
-
id: external_exports2.string(),
|
|
9119
|
-
name: external_exports2.string(),
|
|
9120
|
-
description: external_exports2.string().nullable(),
|
|
9121
|
-
active: external_exports2.boolean(),
|
|
9122
|
-
createdAt: external_exports2.coerce.date().nullish(),
|
|
9123
|
-
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9124
|
-
deletedAt: external_exports2.coerce.date().nullish()
|
|
9125
|
-
})).optional().default([]),
|
|
9126
|
-
organizationRoles: external_exports2.array(external_exports2.object({
|
|
9127
|
-
id: external_exports2.string(),
|
|
9128
|
-
organizationId: external_exports2.string(),
|
|
9129
|
-
name: external_exports2.string(),
|
|
9130
|
-
description: external_exports2.string().nullable(),
|
|
9131
|
-
active: external_exports2.boolean(),
|
|
9132
|
-
createdAt: external_exports2.coerce.date().nullish(),
|
|
9133
|
-
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9134
|
-
deletedAt: external_exports2.coerce.date().nullish()
|
|
9135
|
-
})).optional().default([])
|
|
9136
|
-
});
|
|
9137
|
-
|
|
9138
9379
|
// ../core/dist/chunk-ZSS5ABRS.js
|
|
9139
9380
|
var priceSchema = external_exports2.object({
|
|
9140
9381
|
id: external_exports2.string().max(191),
|
|
@@ -9287,6 +9528,44 @@ var NewProductSchema = external_exports2.object({
|
|
|
9287
9528
|
]).optional()
|
|
9288
9529
|
});
|
|
9289
9530
|
|
|
9531
|
+
// ../core/dist/chunk-4EYC75KK.js
|
|
9532
|
+
var userSchema = external_exports2.object({
|
|
9533
|
+
id: external_exports2.string().max(255),
|
|
9534
|
+
name: external_exports2.string().max(255).optional().nullable(),
|
|
9535
|
+
role: external_exports2.enum([
|
|
9536
|
+
"user",
|
|
9537
|
+
"admin",
|
|
9538
|
+
"contributor"
|
|
9539
|
+
]).default("user"),
|
|
9540
|
+
email: external_exports2.string().max(255).email(),
|
|
9541
|
+
emailVerified: external_exports2.coerce.date().nullish(),
|
|
9542
|
+
image: external_exports2.string().max(255).optional().nullable(),
|
|
9543
|
+
createdAt: external_exports2.coerce.date().nullish(),
|
|
9544
|
+
memberships: external_exports2.array(external_exports2.object({
|
|
9545
|
+
id: external_exports2.string(),
|
|
9546
|
+
organizationId: external_exports2.string()
|
|
9547
|
+
})).nullish().default([]),
|
|
9548
|
+
roles: external_exports2.array(external_exports2.object({
|
|
9549
|
+
id: external_exports2.string(),
|
|
9550
|
+
name: external_exports2.string(),
|
|
9551
|
+
description: external_exports2.string().nullable(),
|
|
9552
|
+
active: external_exports2.boolean(),
|
|
9553
|
+
createdAt: external_exports2.coerce.date().nullish(),
|
|
9554
|
+
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9555
|
+
deletedAt: external_exports2.coerce.date().nullish()
|
|
9556
|
+
})).optional().default([]),
|
|
9557
|
+
organizationRoles: external_exports2.array(external_exports2.object({
|
|
9558
|
+
id: external_exports2.string(),
|
|
9559
|
+
organizationId: external_exports2.string(),
|
|
9560
|
+
name: external_exports2.string(),
|
|
9561
|
+
description: external_exports2.string().nullable(),
|
|
9562
|
+
active: external_exports2.boolean(),
|
|
9563
|
+
createdAt: external_exports2.coerce.date().nullish(),
|
|
9564
|
+
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9565
|
+
deletedAt: external_exports2.coerce.date().nullish()
|
|
9566
|
+
})).optional().default([])
|
|
9567
|
+
});
|
|
9568
|
+
|
|
9290
9569
|
// ../core/dist/chunk-KBC2DYK6.js
|
|
9291
9570
|
var eligibilityConditionSchema = external_exports2.discriminatedUnion("type", [
|
|
9292
9571
|
external_exports2.object({
|
|
@@ -9331,7 +9610,7 @@ var couponSchema = external_exports2.object({
|
|
|
9331
9610
|
organizationId: external_exports2.string().max(191).optional().nullable()
|
|
9332
9611
|
});
|
|
9333
9612
|
|
|
9334
|
-
// ../core/dist/chunk-
|
|
9613
|
+
// ../core/dist/chunk-OAARZI4L.js
|
|
9335
9614
|
var purchaseSchema = external_exports2.object({
|
|
9336
9615
|
id: external_exports2.string().max(191),
|
|
9337
9616
|
userId: external_exports2.string().max(191).optional().nullable(),
|
|
@@ -9411,6 +9690,43 @@ var moduleProgressSchema = external_exports2.object({
|
|
|
9411
9690
|
totalLessonsCount: external_exports2.number().default(0)
|
|
9412
9691
|
});
|
|
9413
9692
|
|
|
9693
|
+
// ../core/dist/chunk-IDHV7EM4.js
|
|
9694
|
+
var merchantPriceSchema = external_exports2.object({
|
|
9695
|
+
id: external_exports2.string().max(191),
|
|
9696
|
+
merchantAccountId: external_exports2.string().max(191),
|
|
9697
|
+
merchantProductId: external_exports2.string().max(191),
|
|
9698
|
+
status: external_exports2.number().int().default(0),
|
|
9699
|
+
identifier: external_exports2.string().max(191).optional().nullable(),
|
|
9700
|
+
createdAt: external_exports2.date(),
|
|
9701
|
+
priceId: external_exports2.string().max(191).optional().nullable()
|
|
9702
|
+
});
|
|
9703
|
+
|
|
9704
|
+
// ../core/dist/chunk-ZHSWPV43.js
|
|
9705
|
+
var merchantProductSchema = external_exports2.object({
|
|
9706
|
+
id: external_exports2.string().max(191),
|
|
9707
|
+
merchantAccountId: external_exports2.string().max(191),
|
|
9708
|
+
productId: external_exports2.string().max(191),
|
|
9709
|
+
status: external_exports2.number().int().default(0),
|
|
9710
|
+
identifier: external_exports2.string().max(191).optional().nullable(),
|
|
9711
|
+
createdAt: external_exports2.date().nullable()
|
|
9712
|
+
});
|
|
9713
|
+
|
|
9714
|
+
// ../core/dist/chunk-FNESWG4F.js
|
|
9715
|
+
var entitlementSchema = external_exports2.object({
|
|
9716
|
+
id: external_exports2.string().max(191),
|
|
9717
|
+
entitlementType: external_exports2.string().max(255),
|
|
9718
|
+
userId: external_exports2.string().max(191).nullable().optional(),
|
|
9719
|
+
organizationId: external_exports2.string().max(191).nullable().optional(),
|
|
9720
|
+
organizationMembershipId: external_exports2.string().max(191).nullable().optional(),
|
|
9721
|
+
sourceType: external_exports2.string().max(255),
|
|
9722
|
+
sourceId: external_exports2.string().max(191),
|
|
9723
|
+
metadata: external_exports2.record(external_exports2.any()).default({}),
|
|
9724
|
+
expiresAt: external_exports2.date().nullable().optional(),
|
|
9725
|
+
createdAt: external_exports2.date().nullable().optional(),
|
|
9726
|
+
updatedAt: external_exports2.date().nullable().optional(),
|
|
9727
|
+
deletedAt: external_exports2.date().nullable().optional()
|
|
9728
|
+
});
|
|
9729
|
+
|
|
9414
9730
|
// ../core/dist/chunk-MVVSJ2XH.js
|
|
9415
9731
|
var merchantChargeSchema = external_exports2.object({
|
|
9416
9732
|
id: external_exports2.string().max(191),
|
|
@@ -9462,42 +9778,67 @@ var merchantEventsSchema = external_exports2.object({
|
|
|
9462
9778
|
createdAt: external_exports2.date().nullable()
|
|
9463
9779
|
});
|
|
9464
9780
|
|
|
9465
|
-
// ../core/dist/chunk-
|
|
9466
|
-
var
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
});
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9781
|
+
// ../core/dist/chunk-Y6GOOY2Z.js
|
|
9782
|
+
var PaidClickIdsSchema = external_exports2.object({
|
|
9783
|
+
gclid: external_exports2.string().optional(),
|
|
9784
|
+
gbraid: external_exports2.string().optional(),
|
|
9785
|
+
wbraid: external_exports2.string().optional(),
|
|
9786
|
+
fbclid: external_exports2.string().optional(),
|
|
9787
|
+
li_fat_id: external_exports2.string().optional(),
|
|
9788
|
+
ttclid: external_exports2.string().optional(),
|
|
9789
|
+
twclid: external_exports2.string().optional()
|
|
9790
|
+
}).partial();
|
|
9791
|
+
var AttributionSnapshotPayloadSchema = external_exports2.object({
|
|
9792
|
+
schemaVersion: external_exports2.literal(1),
|
|
9793
|
+
capturedAt: external_exports2.string(),
|
|
9794
|
+
source: external_exports2.string().optional(),
|
|
9795
|
+
medium: external_exports2.string().optional(),
|
|
9796
|
+
campaign: external_exports2.string().optional(),
|
|
9797
|
+
frontConversationId: external_exports2.string().optional(),
|
|
9798
|
+
operatorRunId: external_exports2.string().optional(),
|
|
9799
|
+
recoveredFrom: external_exports2.string().optional(),
|
|
9800
|
+
recoveredAt: external_exports2.string().optional(),
|
|
9801
|
+
landingPath: external_exports2.string().optional(),
|
|
9802
|
+
landingVariant: external_exports2.string().optional(),
|
|
9803
|
+
referrer: external_exports2.string().optional(),
|
|
9804
|
+
utm: external_exports2.object({
|
|
9805
|
+
source: external_exports2.string().optional(),
|
|
9806
|
+
medium: external_exports2.string().optional(),
|
|
9807
|
+
campaign: external_exports2.string().optional(),
|
|
9808
|
+
content: external_exports2.string().optional(),
|
|
9809
|
+
term: external_exports2.string().optional()
|
|
9810
|
+
}).optional(),
|
|
9811
|
+
clickIds: PaidClickIdsSchema.optional(),
|
|
9812
|
+
shortlink: external_exports2.object({
|
|
9813
|
+
id: external_exports2.string().nullable().optional(),
|
|
9814
|
+
slug: external_exports2.string().nullable().optional(),
|
|
9815
|
+
metadata: external_exports2.record(external_exports2.unknown()).nullable().optional()
|
|
9816
|
+
}).optional(),
|
|
9817
|
+
ga: external_exports2.object({
|
|
9818
|
+
clientId: external_exports2.string().optional()
|
|
9819
|
+
}).optional(),
|
|
9820
|
+
selfReportedSource: external_exports2.string().optional(),
|
|
9821
|
+
// Bounded original landing-page query params. This is intentionally not the
|
|
9822
|
+
// checkout callback query string because Stripe metadata values are small.
|
|
9823
|
+
params: external_exports2.record(external_exports2.string()).optional(),
|
|
9824
|
+
synthetic: external_exports2.boolean().optional(),
|
|
9825
|
+
syntheticReason: external_exports2.string().optional()
|
|
9500
9826
|
});
|
|
9827
|
+
function parseAttributionSnapshotPayload(value) {
|
|
9828
|
+
if (!value)
|
|
9829
|
+
return void 0;
|
|
9830
|
+
if (typeof value === "string") {
|
|
9831
|
+
try {
|
|
9832
|
+
return AttributionSnapshotPayloadSchema.parse(JSON.parse(value));
|
|
9833
|
+
} catch {
|
|
9834
|
+
return void 0;
|
|
9835
|
+
}
|
|
9836
|
+
}
|
|
9837
|
+
const parsed = AttributionSnapshotPayloadSchema.safeParse(value);
|
|
9838
|
+
return parsed.success ? parsed.data : void 0;
|
|
9839
|
+
}
|
|
9840
|
+
__name(parseAttributionSnapshotPayload, "parseAttributionSnapshotPayload");
|
|
9841
|
+
__name2(parseAttributionSnapshotPayload, "parseAttributionSnapshotPayload");
|
|
9501
9842
|
|
|
9502
9843
|
// ../core/dist/schemas/merchant-account-schema.js
|
|
9503
9844
|
var merchantAccountSchema = external_exports2.object({
|
|
@@ -11440,7 +11781,8 @@ function getPurchaseSchema(mysqlTable) {
|
|
|
11440
11781
|
merchantChargeIdIdx: (0, import_mysql_core27.index)("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
11441
11782
|
purchaseUpgradedFromIdKey: (0, import_mysql_core27.unique)("Purchase_upgradedFromId_key").on(table.upgradedFromId),
|
|
11442
11783
|
organizationIdIdx: (0, import_mysql_core27.index)("organizationId_idx").on(table.organizationId),
|
|
11443
|
-
organizationMembershipIdIdx: (0, import_mysql_core27.index)("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId)
|
|
11784
|
+
organizationMembershipIdIdx: (0, import_mysql_core27.index)("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId),
|
|
11785
|
+
userStatusProductIdx: (0, import_mysql_core27.index)("idx_Purchase_on_userId_status_productId").on(table.userId, table.status, table.productId)
|
|
11444
11786
|
};
|
|
11445
11787
|
});
|
|
11446
11788
|
}
|
|
@@ -12225,39 +12567,115 @@ function getDeviceVerificationRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12225
12567
|
}
|
|
12226
12568
|
__name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
|
|
12227
12569
|
|
|
12228
|
-
// src/lib/mysql/schemas/auth/
|
|
12570
|
+
// src/lib/mysql/schemas/auth/personal-access-token.ts
|
|
12229
12571
|
var import_drizzle_orm36 = require("drizzle-orm");
|
|
12230
12572
|
var import_mysql_core40 = require("drizzle-orm/mysql-core");
|
|
12573
|
+
function getPersonalAccessTokenSchema(mysqlTable) {
|
|
12574
|
+
return mysqlTable("PersonalAccessToken", {
|
|
12575
|
+
id: (0, import_mysql_core40.varchar)("id", {
|
|
12576
|
+
length: 191
|
|
12577
|
+
}).notNull(),
|
|
12578
|
+
userId: (0, import_mysql_core40.varchar)("userId", {
|
|
12579
|
+
length: 191
|
|
12580
|
+
}).notNull(),
|
|
12581
|
+
name: (0, import_mysql_core40.varchar)("name", {
|
|
12582
|
+
length: 255
|
|
12583
|
+
}).notNull(),
|
|
12584
|
+
publicId: (0, import_mysql_core40.varchar)("publicId", {
|
|
12585
|
+
length: 64
|
|
12586
|
+
}).notNull(),
|
|
12587
|
+
tokenPrefix: (0, import_mysql_core40.varchar)("tokenPrefix", {
|
|
12588
|
+
length: 128
|
|
12589
|
+
}).notNull(),
|
|
12590
|
+
tokenHash: (0, import_mysql_core40.varchar)("tokenHash", {
|
|
12591
|
+
length: 128
|
|
12592
|
+
}).notNull(),
|
|
12593
|
+
scopes: (0, import_mysql_core40.json)("scopes").$type().notNull(),
|
|
12594
|
+
expiresAt: (0, import_mysql_core40.timestamp)("expiresAt", {
|
|
12595
|
+
mode: "date",
|
|
12596
|
+
fsp: 3
|
|
12597
|
+
}),
|
|
12598
|
+
lastUsedAt: (0, import_mysql_core40.timestamp)("lastUsedAt", {
|
|
12599
|
+
mode: "date",
|
|
12600
|
+
fsp: 3
|
|
12601
|
+
}),
|
|
12602
|
+
revokedAt: (0, import_mysql_core40.timestamp)("revokedAt", {
|
|
12603
|
+
mode: "date",
|
|
12604
|
+
fsp: 3
|
|
12605
|
+
}),
|
|
12606
|
+
createdAt: (0, import_mysql_core40.timestamp)("createdAt", {
|
|
12607
|
+
mode: "date",
|
|
12608
|
+
fsp: 3
|
|
12609
|
+
}).default(import_drizzle_orm36.sql`CURRENT_TIMESTAMP(3)`),
|
|
12610
|
+
updatedAt: (0, import_mysql_core40.timestamp)("updatedAt", {
|
|
12611
|
+
mode: "date",
|
|
12612
|
+
fsp: 3
|
|
12613
|
+
}).default(import_drizzle_orm36.sql`CURRENT_TIMESTAMP(3)`).$onUpdate(() => /* @__PURE__ */ new Date())
|
|
12614
|
+
}, (pat) => ({
|
|
12615
|
+
pk: (0, import_mysql_core40.primaryKey)({
|
|
12616
|
+
columns: [
|
|
12617
|
+
pat.id
|
|
12618
|
+
]
|
|
12619
|
+
}),
|
|
12620
|
+
publicIdIdx: (0, import_mysql_core40.uniqueIndex)("publicId_idx").on(pat.publicId),
|
|
12621
|
+
tokenHashIdx: (0, import_mysql_core40.uniqueIndex)("tokenHash_idx").on(pat.tokenHash),
|
|
12622
|
+
userIdIdx: (0, import_mysql_core40.index)("userId_idx").on(pat.userId),
|
|
12623
|
+
expiresAtIdx: (0, import_mysql_core40.index)("expiresAt_idx").on(pat.expiresAt),
|
|
12624
|
+
revokedAtIdx: (0, import_mysql_core40.index)("revokedAt_idx").on(pat.revokedAt)
|
|
12625
|
+
}));
|
|
12626
|
+
}
|
|
12627
|
+
__name(getPersonalAccessTokenSchema, "getPersonalAccessTokenSchema");
|
|
12628
|
+
function getPersonalAccessTokenRelationsSchema(mysqlTable, overrides = {}) {
|
|
12629
|
+
const personalAccessToken = getPersonalAccessTokenSchema(mysqlTable);
|
|
12630
|
+
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
12631
|
+
const user = resolveUsersSchema(mysqlTable);
|
|
12632
|
+
return (0, import_drizzle_orm36.relations)(personalAccessToken, ({ one }) => ({
|
|
12633
|
+
user: one(user, {
|
|
12634
|
+
fields: [
|
|
12635
|
+
personalAccessToken.userId
|
|
12636
|
+
],
|
|
12637
|
+
references: [
|
|
12638
|
+
user.id
|
|
12639
|
+
],
|
|
12640
|
+
relationName: "user"
|
|
12641
|
+
})
|
|
12642
|
+
}));
|
|
12643
|
+
}
|
|
12644
|
+
__name(getPersonalAccessTokenRelationsSchema, "getPersonalAccessTokenRelationsSchema");
|
|
12645
|
+
|
|
12646
|
+
// src/lib/mysql/schemas/auth/role-permissions.ts
|
|
12647
|
+
var import_drizzle_orm37 = require("drizzle-orm");
|
|
12648
|
+
var import_mysql_core41 = require("drizzle-orm/mysql-core");
|
|
12231
12649
|
function getRolePermissionsSchema(mysqlTable) {
|
|
12232
12650
|
return mysqlTable("RolePermission", {
|
|
12233
|
-
roleId: (0,
|
|
12651
|
+
roleId: (0, import_mysql_core41.varchar)("roleId", {
|
|
12234
12652
|
length: 255
|
|
12235
12653
|
}).notNull(),
|
|
12236
|
-
permissionId: (0,
|
|
12654
|
+
permissionId: (0, import_mysql_core41.varchar)("permissionId", {
|
|
12237
12655
|
length: 255
|
|
12238
12656
|
}).notNull(),
|
|
12239
|
-
active: (0,
|
|
12240
|
-
createdAt: (0,
|
|
12657
|
+
active: (0, import_mysql_core41.boolean)("active").notNull().default(true),
|
|
12658
|
+
createdAt: (0, import_mysql_core41.timestamp)("createdAt", {
|
|
12241
12659
|
mode: "date",
|
|
12242
12660
|
fsp: 3
|
|
12243
12661
|
}).defaultNow(),
|
|
12244
|
-
updatedAt: (0,
|
|
12662
|
+
updatedAt: (0, import_mysql_core41.timestamp)("updatedAt", {
|
|
12245
12663
|
mode: "date",
|
|
12246
12664
|
fsp: 3
|
|
12247
12665
|
}).defaultNow(),
|
|
12248
|
-
deletedAt: (0,
|
|
12666
|
+
deletedAt: (0, import_mysql_core41.timestamp)("deletedAt", {
|
|
12249
12667
|
mode: "date",
|
|
12250
12668
|
fsp: 3
|
|
12251
12669
|
})
|
|
12252
12670
|
}, (rp) => ({
|
|
12253
|
-
pk: (0,
|
|
12671
|
+
pk: (0, import_mysql_core41.primaryKey)({
|
|
12254
12672
|
columns: [
|
|
12255
12673
|
rp.roleId,
|
|
12256
12674
|
rp.permissionId
|
|
12257
12675
|
]
|
|
12258
12676
|
}),
|
|
12259
|
-
roleIdIdx: (0,
|
|
12260
|
-
permissionIdIdx: (0,
|
|
12677
|
+
roleIdIdx: (0, import_mysql_core41.index)("roleId_idx").on(rp.roleId),
|
|
12678
|
+
permissionIdIdx: (0, import_mysql_core41.index)("permissionId_idx").on(rp.permissionId)
|
|
12261
12679
|
}));
|
|
12262
12680
|
}
|
|
12263
12681
|
__name(getRolePermissionsSchema, "getRolePermissionsSchema");
|
|
@@ -12265,7 +12683,7 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
12265
12683
|
const permissions = getPermissionsSchema(mysqlTable);
|
|
12266
12684
|
const roles = getRolesSchema(mysqlTable);
|
|
12267
12685
|
const rolePermissions = getRolePermissionsSchema(mysqlTable);
|
|
12268
|
-
return (0,
|
|
12686
|
+
return (0, import_drizzle_orm37.relations)(rolePermissions, ({ one }) => ({
|
|
12269
12687
|
role: one(roles, {
|
|
12270
12688
|
fields: [
|
|
12271
12689
|
rolePermissions.roleId
|
|
@@ -12289,21 +12707,21 @@ function getRolePermissionsRelationsSchema(mysqlTable) {
|
|
|
12289
12707
|
__name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
|
|
12290
12708
|
|
|
12291
12709
|
// src/lib/mysql/schemas/auth/sessions.ts
|
|
12292
|
-
var
|
|
12293
|
-
var
|
|
12710
|
+
var import_drizzle_orm38 = require("drizzle-orm");
|
|
12711
|
+
var import_mysql_core42 = require("drizzle-orm/mysql-core");
|
|
12294
12712
|
function getSessionsSchema(mysqlTable) {
|
|
12295
12713
|
return mysqlTable("Session", {
|
|
12296
|
-
sessionToken: (0,
|
|
12714
|
+
sessionToken: (0, import_mysql_core42.varchar)("sessionToken", {
|
|
12297
12715
|
length: 255
|
|
12298
12716
|
}).notNull().primaryKey(),
|
|
12299
|
-
userId: (0,
|
|
12717
|
+
userId: (0, import_mysql_core42.varchar)("userId", {
|
|
12300
12718
|
length: 255
|
|
12301
12719
|
}).notNull(),
|
|
12302
|
-
expires: (0,
|
|
12720
|
+
expires: (0, import_mysql_core42.timestamp)("expires", {
|
|
12303
12721
|
mode: "date"
|
|
12304
12722
|
}).notNull()
|
|
12305
12723
|
}, (session) => ({
|
|
12306
|
-
userIdIdx: (0,
|
|
12724
|
+
userIdIdx: (0, import_mysql_core42.index)("userId_idx").on(session.userId)
|
|
12307
12725
|
}));
|
|
12308
12726
|
}
|
|
12309
12727
|
__name(getSessionsSchema, "getSessionsSchema");
|
|
@@ -12311,7 +12729,7 @@ function getSessionRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12311
12729
|
const sessions = getSessionsSchema(mysqlTable);
|
|
12312
12730
|
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
12313
12731
|
const users = resolveUsersSchema(mysqlTable);
|
|
12314
|
-
return (0,
|
|
12732
|
+
return (0, import_drizzle_orm38.relations)(sessions, ({ one }) => ({
|
|
12315
12733
|
user: one(users, {
|
|
12316
12734
|
fields: [
|
|
12317
12735
|
sessions.userId
|
|
@@ -12326,24 +12744,24 @@ function getSessionRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12326
12744
|
__name(getSessionRelationsSchema, "getSessionRelationsSchema");
|
|
12327
12745
|
|
|
12328
12746
|
// src/lib/mysql/schemas/auth/verification-tokens.ts
|
|
12329
|
-
var
|
|
12747
|
+
var import_mysql_core43 = require("drizzle-orm/mysql-core");
|
|
12330
12748
|
function getVerificationTokensSchema(mysqlTable) {
|
|
12331
12749
|
return mysqlTable("VerificationToken", {
|
|
12332
|
-
identifier: (0,
|
|
12750
|
+
identifier: (0, import_mysql_core43.varchar)("identifier", {
|
|
12333
12751
|
length: 255
|
|
12334
12752
|
}).notNull(),
|
|
12335
|
-
token: (0,
|
|
12753
|
+
token: (0, import_mysql_core43.varchar)("token", {
|
|
12336
12754
|
length: 255
|
|
12337
12755
|
}).notNull(),
|
|
12338
|
-
expires: (0,
|
|
12756
|
+
expires: (0, import_mysql_core43.timestamp)("expires", {
|
|
12339
12757
|
mode: "date"
|
|
12340
12758
|
}).notNull(),
|
|
12341
|
-
createdAt: (0,
|
|
12759
|
+
createdAt: (0, import_mysql_core43.timestamp)("createdAt", {
|
|
12342
12760
|
mode: "date",
|
|
12343
12761
|
fsp: 3
|
|
12344
12762
|
}).defaultNow()
|
|
12345
12763
|
}, (vt) => ({
|
|
12346
|
-
pk: (0,
|
|
12764
|
+
pk: (0, import_mysql_core43.primaryKey)({
|
|
12347
12765
|
columns: [
|
|
12348
12766
|
vt.identifier,
|
|
12349
12767
|
vt.token
|
|
@@ -12354,35 +12772,35 @@ function getVerificationTokensSchema(mysqlTable) {
|
|
|
12354
12772
|
__name(getVerificationTokensSchema, "getVerificationTokensSchema");
|
|
12355
12773
|
|
|
12356
12774
|
// src/lib/mysql/schemas/commerce/merchant-events.ts
|
|
12357
|
-
var
|
|
12358
|
-
var
|
|
12775
|
+
var import_drizzle_orm39 = require("drizzle-orm");
|
|
12776
|
+
var import_mysql_core44 = require("drizzle-orm/mysql-core");
|
|
12359
12777
|
function getMerchantEventsSchema(mysqlTable) {
|
|
12360
12778
|
return mysqlTable("MerchantEvents", {
|
|
12361
|
-
id: (0,
|
|
12779
|
+
id: (0, import_mysql_core44.varchar)("id", {
|
|
12362
12780
|
length: 191
|
|
12363
12781
|
}).notNull(),
|
|
12364
|
-
merchantAccountId: (0,
|
|
12782
|
+
merchantAccountId: (0, import_mysql_core44.varchar)("merchantAccountId", {
|
|
12365
12783
|
length: 191
|
|
12366
12784
|
}).notNull(),
|
|
12367
|
-
identifier: (0,
|
|
12785
|
+
identifier: (0, import_mysql_core44.varchar)("identifier", {
|
|
12368
12786
|
length: 191
|
|
12369
12787
|
}).notNull(),
|
|
12370
|
-
payload: (0,
|
|
12371
|
-
createdAt: (0,
|
|
12788
|
+
payload: (0, import_mysql_core44.json)("payload").notNull(),
|
|
12789
|
+
createdAt: (0, import_mysql_core44.timestamp)("createdAt", {
|
|
12372
12790
|
mode: "date",
|
|
12373
12791
|
fsp: 3
|
|
12374
|
-
}).default(
|
|
12792
|
+
}).default(import_drizzle_orm39.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
12375
12793
|
}, (table) => {
|
|
12376
12794
|
return {
|
|
12377
|
-
merchantEventsId: (0,
|
|
12795
|
+
merchantEventsId: (0, import_mysql_core44.primaryKey)({
|
|
12378
12796
|
columns: [
|
|
12379
12797
|
table.id
|
|
12380
12798
|
],
|
|
12381
12799
|
name: "MerchantEvents_id"
|
|
12382
12800
|
}),
|
|
12383
|
-
merchantEventsIdentifierKey: (0,
|
|
12384
|
-
merchantAccountIdIdx: (0,
|
|
12385
|
-
createdAtIdx: (0,
|
|
12801
|
+
merchantEventsIdentifierKey: (0, import_mysql_core44.unique)("MerchantEvents_identifier_key").on(table.identifier),
|
|
12802
|
+
merchantAccountIdIdx: (0, import_mysql_core44.index)("merchantAccountId_idx").on(table.merchantAccountId),
|
|
12803
|
+
createdAtIdx: (0, import_mysql_core44.index)("createdAt_idx").on(table.createdAt)
|
|
12386
12804
|
};
|
|
12387
12805
|
});
|
|
12388
12806
|
}
|
|
@@ -12390,7 +12808,7 @@ __name(getMerchantEventsSchema, "getMerchantEventsSchema");
|
|
|
12390
12808
|
function getMerchantEventsRelationsSchema(mysqlTable) {
|
|
12391
12809
|
const merchantEvents = getMerchantEventsSchema(mysqlTable);
|
|
12392
12810
|
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
12393
|
-
return (0,
|
|
12811
|
+
return (0, import_drizzle_orm39.relations)(merchantEvents, ({ one }) => ({
|
|
12394
12812
|
merchantAccount: one(merchantAccount, {
|
|
12395
12813
|
fields: [
|
|
12396
12814
|
merchantEvents.merchantAccountId
|
|
@@ -12405,14 +12823,14 @@ function getMerchantEventsRelationsSchema(mysqlTable) {
|
|
|
12405
12823
|
__name(getMerchantEventsRelationsSchema, "getMerchantEventsRelationsSchema");
|
|
12406
12824
|
|
|
12407
12825
|
// src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
|
|
12408
|
-
var
|
|
12409
|
-
var
|
|
12826
|
+
var import_drizzle_orm40 = require("drizzle-orm");
|
|
12827
|
+
var import_mysql_core45 = require("drizzle-orm/mysql-core");
|
|
12410
12828
|
function getPurchaseUserTransferSchema(mysqlTable) {
|
|
12411
12829
|
return mysqlTable("PurchaseUserTransfer", {
|
|
12412
|
-
id: (0,
|
|
12830
|
+
id: (0, import_mysql_core45.varchar)("id", {
|
|
12413
12831
|
length: 191
|
|
12414
12832
|
}).notNull(),
|
|
12415
|
-
transferState: (0,
|
|
12833
|
+
transferState: (0, import_mysql_core45.mysqlEnum)("transferState", [
|
|
12416
12834
|
"AVAILABLE",
|
|
12417
12835
|
"INITIATED",
|
|
12418
12836
|
"VERIFIED",
|
|
@@ -12421,47 +12839,47 @@ function getPurchaseUserTransferSchema(mysqlTable) {
|
|
|
12421
12839
|
"CONFIRMED",
|
|
12422
12840
|
"COMPLETED"
|
|
12423
12841
|
]).default("AVAILABLE").notNull(),
|
|
12424
|
-
purchaseId: (0,
|
|
12842
|
+
purchaseId: (0, import_mysql_core45.varchar)("purchaseId", {
|
|
12425
12843
|
length: 191
|
|
12426
12844
|
}).notNull(),
|
|
12427
|
-
organizationId: (0,
|
|
12845
|
+
organizationId: (0, import_mysql_core45.varchar)("organizationId", {
|
|
12428
12846
|
length: 191
|
|
12429
12847
|
}),
|
|
12430
|
-
sourceUserId: (0,
|
|
12848
|
+
sourceUserId: (0, import_mysql_core45.varchar)("sourceUserId", {
|
|
12431
12849
|
length: 191
|
|
12432
12850
|
}).notNull(),
|
|
12433
|
-
targetUserId: (0,
|
|
12851
|
+
targetUserId: (0, import_mysql_core45.varchar)("targetUserId", {
|
|
12434
12852
|
length: 191
|
|
12435
12853
|
}),
|
|
12436
|
-
createdAt: (0,
|
|
12854
|
+
createdAt: (0, import_mysql_core45.timestamp)("createdAt", {
|
|
12437
12855
|
mode: "date",
|
|
12438
12856
|
fsp: 3
|
|
12439
|
-
}).default(
|
|
12440
|
-
expiresAt: (0,
|
|
12857
|
+
}).default(import_drizzle_orm40.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
12858
|
+
expiresAt: (0, import_mysql_core45.timestamp)("expiresAt", {
|
|
12441
12859
|
mode: "date",
|
|
12442
12860
|
fsp: 3
|
|
12443
12861
|
}),
|
|
12444
|
-
canceledAt: (0,
|
|
12862
|
+
canceledAt: (0, import_mysql_core45.timestamp)("canceledAt", {
|
|
12445
12863
|
mode: "date",
|
|
12446
12864
|
fsp: 3
|
|
12447
12865
|
}),
|
|
12448
|
-
confirmedAt: (0,
|
|
12866
|
+
confirmedAt: (0, import_mysql_core45.timestamp)("confirmedAt", {
|
|
12449
12867
|
mode: "date",
|
|
12450
12868
|
fsp: 3
|
|
12451
12869
|
}),
|
|
12452
|
-
completedAt: (0,
|
|
12870
|
+
completedAt: (0, import_mysql_core45.timestamp)("completedAt", {
|
|
12453
12871
|
mode: "date",
|
|
12454
12872
|
fsp: 3
|
|
12455
12873
|
})
|
|
12456
12874
|
}, (table) => {
|
|
12457
12875
|
return {
|
|
12458
|
-
purchaseUserTransferId: (0,
|
|
12876
|
+
purchaseUserTransferId: (0, import_mysql_core45.primaryKey)({
|
|
12459
12877
|
columns: [
|
|
12460
12878
|
table.id
|
|
12461
12879
|
],
|
|
12462
12880
|
name: "PurchaseUserTransfer_id"
|
|
12463
12881
|
}),
|
|
12464
|
-
organizationIdIdx: (0,
|
|
12882
|
+
organizationIdIdx: (0, import_mysql_core45.index)("organizationId_idx").on(table.organizationId)
|
|
12465
12883
|
};
|
|
12466
12884
|
});
|
|
12467
12885
|
}
|
|
@@ -12471,7 +12889,7 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12471
12889
|
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
12472
12890
|
const user = resolveUsersSchema(mysqlTable);
|
|
12473
12891
|
const purchase = getPurchaseSchema(mysqlTable);
|
|
12474
|
-
return (0,
|
|
12892
|
+
return (0, import_drizzle_orm40.relations)(purchaseUserTransfer, ({ one }) => ({
|
|
12475
12893
|
sourceUser: one(user, {
|
|
12476
12894
|
fields: [
|
|
12477
12895
|
purchaseUserTransfer.sourceUserId
|
|
@@ -12504,50 +12922,50 @@ function getPurchaseUserTransferRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12504
12922
|
__name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
|
|
12505
12923
|
|
|
12506
12924
|
// src/lib/mysql/schemas/commerce/upgradable-products.ts
|
|
12507
|
-
var
|
|
12508
|
-
var
|
|
12925
|
+
var import_drizzle_orm41 = require("drizzle-orm");
|
|
12926
|
+
var import_mysql_core46 = require("drizzle-orm/mysql-core");
|
|
12509
12927
|
function getUpgradableProductsSchema(mysqlTable) {
|
|
12510
12928
|
return mysqlTable("UpgradableProducts", {
|
|
12511
|
-
upgradableToId: (0,
|
|
12929
|
+
upgradableToId: (0, import_mysql_core46.varchar)("upgradableToId", {
|
|
12512
12930
|
length: 255
|
|
12513
12931
|
}).notNull(),
|
|
12514
|
-
upgradableFromId: (0,
|
|
12932
|
+
upgradableFromId: (0, import_mysql_core46.varchar)("upgradableFrom", {
|
|
12515
12933
|
length: 255
|
|
12516
12934
|
}).notNull(),
|
|
12517
|
-
organizationId: (0,
|
|
12935
|
+
organizationId: (0, import_mysql_core46.varchar)("organizationId", {
|
|
12518
12936
|
length: 191
|
|
12519
12937
|
}),
|
|
12520
|
-
position: (0,
|
|
12521
|
-
metadata: (0,
|
|
12522
|
-
createdAt: (0,
|
|
12938
|
+
position: (0, import_mysql_core46.double)("position").notNull().default(0),
|
|
12939
|
+
metadata: (0, import_mysql_core46.json)("metadata").$type().default({}),
|
|
12940
|
+
createdAt: (0, import_mysql_core46.timestamp)("createdAt", {
|
|
12523
12941
|
mode: "date",
|
|
12524
12942
|
fsp: 3
|
|
12525
|
-
}).default(
|
|
12526
|
-
updatedAt: (0,
|
|
12943
|
+
}).default(import_drizzle_orm41.sql`CURRENT_TIMESTAMP(3)`),
|
|
12944
|
+
updatedAt: (0, import_mysql_core46.timestamp)("updatedAt", {
|
|
12527
12945
|
mode: "date",
|
|
12528
12946
|
fsp: 3
|
|
12529
|
-
}).default(
|
|
12530
|
-
deletedAt: (0,
|
|
12947
|
+
}).default(import_drizzle_orm41.sql`CURRENT_TIMESTAMP(3)`),
|
|
12948
|
+
deletedAt: (0, import_mysql_core46.timestamp)("deletedAt", {
|
|
12531
12949
|
mode: "date",
|
|
12532
12950
|
fsp: 3
|
|
12533
12951
|
})
|
|
12534
12952
|
}, (crr) => ({
|
|
12535
|
-
pk: (0,
|
|
12953
|
+
pk: (0, import_mysql_core46.primaryKey)({
|
|
12536
12954
|
columns: [
|
|
12537
12955
|
crr.upgradableToId,
|
|
12538
12956
|
crr.upgradableFromId
|
|
12539
12957
|
]
|
|
12540
12958
|
}),
|
|
12541
|
-
upgradableToIdIdx: (0,
|
|
12542
|
-
upgradableFromIdIdx: (0,
|
|
12543
|
-
organizationIdIdx: (0,
|
|
12959
|
+
upgradableToIdIdx: (0, import_mysql_core46.index)("upgradableFromId_idx").on(crr.upgradableToId),
|
|
12960
|
+
upgradableFromIdIdx: (0, import_mysql_core46.index)("upgradableToId_idx").on(crr.upgradableFromId),
|
|
12961
|
+
organizationIdIdx: (0, import_mysql_core46.index)("organizationId_idx").on(crr.organizationId)
|
|
12544
12962
|
}));
|
|
12545
12963
|
}
|
|
12546
12964
|
__name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
|
|
12547
12965
|
function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
12548
12966
|
const product = getProductSchema(mysqlTable);
|
|
12549
12967
|
const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
|
|
12550
|
-
return (0,
|
|
12968
|
+
return (0, import_drizzle_orm41.relations)(upgradableProduct, ({ one }) => ({
|
|
12551
12969
|
upgradableTo: one(product, {
|
|
12552
12970
|
fields: [
|
|
12553
12971
|
upgradableProduct.upgradableToId
|
|
@@ -12571,53 +12989,53 @@ function getUpgradableProductsRelationsSchema(mysqlTable) {
|
|
|
12571
12989
|
__name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
|
|
12572
12990
|
|
|
12573
12991
|
// src/lib/mysql/schemas/communication/question-response.ts
|
|
12574
|
-
var
|
|
12575
|
-
var
|
|
12992
|
+
var import_drizzle_orm42 = require("drizzle-orm");
|
|
12993
|
+
var import_mysql_core47 = require("drizzle-orm/mysql-core");
|
|
12576
12994
|
function getQuestionResponseSchema(mysqlTable) {
|
|
12577
12995
|
return mysqlTable("QuestionResponse", {
|
|
12578
|
-
id: (0,
|
|
12996
|
+
id: (0, import_mysql_core47.varchar)("id", {
|
|
12579
12997
|
length: 255
|
|
12580
12998
|
}).notNull().primaryKey(),
|
|
12581
|
-
surveyId: (0,
|
|
12999
|
+
surveyId: (0, import_mysql_core47.varchar)("surveyId", {
|
|
12582
13000
|
length: 255
|
|
12583
13001
|
}).notNull(),
|
|
12584
|
-
questionId: (0,
|
|
13002
|
+
questionId: (0, import_mysql_core47.varchar)("questionId", {
|
|
12585
13003
|
length: 255
|
|
12586
13004
|
}).notNull(),
|
|
12587
|
-
respondentKey: (0,
|
|
13005
|
+
respondentKey: (0, import_mysql_core47.varchar)("respondentKey", {
|
|
12588
13006
|
length: 255
|
|
12589
13007
|
}),
|
|
12590
|
-
surveySessionId: (0,
|
|
13008
|
+
surveySessionId: (0, import_mysql_core47.varchar)("surveySessionId", {
|
|
12591
13009
|
length: 255
|
|
12592
13010
|
}),
|
|
12593
|
-
userId: (0,
|
|
13011
|
+
userId: (0, import_mysql_core47.varchar)("userId", {
|
|
12594
13012
|
length: 255
|
|
12595
13013
|
}),
|
|
12596
|
-
emailListSubscriberId: (0,
|
|
13014
|
+
emailListSubscriberId: (0, import_mysql_core47.varchar)("emailListSubscriberId", {
|
|
12597
13015
|
length: 255
|
|
12598
13016
|
}),
|
|
12599
|
-
fields: (0,
|
|
12600
|
-
createdAt: (0,
|
|
13017
|
+
fields: (0, import_mysql_core47.json)("fields").$type().default({}),
|
|
13018
|
+
createdAt: (0, import_mysql_core47.timestamp)("createdAt", {
|
|
12601
13019
|
mode: "date",
|
|
12602
13020
|
fsp: 3
|
|
12603
|
-
}).default(
|
|
12604
|
-
updatedAt: (0,
|
|
13021
|
+
}).default(import_drizzle_orm42.sql`CURRENT_TIMESTAMP(3)`),
|
|
13022
|
+
updatedAt: (0, import_mysql_core47.timestamp)("updatedAt", {
|
|
12605
13023
|
mode: "date",
|
|
12606
13024
|
fsp: 3
|
|
12607
|
-
}).default(
|
|
12608
|
-
deletedAt: (0,
|
|
13025
|
+
}).default(import_drizzle_orm42.sql`CURRENT_TIMESTAMP(3)`),
|
|
13026
|
+
deletedAt: (0, import_mysql_core47.timestamp)("deletedAt", {
|
|
12609
13027
|
mode: "date",
|
|
12610
13028
|
fsp: 3
|
|
12611
13029
|
})
|
|
12612
13030
|
}, (qr) => ({
|
|
12613
|
-
surveyIdIdx: (0,
|
|
12614
|
-
questionIdIdx: (0,
|
|
12615
|
-
respondentKeyIdx: (0,
|
|
12616
|
-
surveySessionIdIdx: (0,
|
|
12617
|
-
userIdIdx: (0,
|
|
12618
|
-
emailListSubscriberIdIdx: (0,
|
|
12619
|
-
surveySubscriberIdx: (0,
|
|
12620
|
-
surveyQuestionRespondentIdx: (0,
|
|
13031
|
+
surveyIdIdx: (0, import_mysql_core47.index)("surveyId_idx").on(qr.surveyId),
|
|
13032
|
+
questionIdIdx: (0, import_mysql_core47.index)("questionId_idx").on(qr.questionId),
|
|
13033
|
+
respondentKeyIdx: (0, import_mysql_core47.index)("respondent_key_idx").on(qr.respondentKey),
|
|
13034
|
+
surveySessionIdIdx: (0, import_mysql_core47.index)("survey_session_id_idx").on(qr.surveySessionId),
|
|
13035
|
+
userIdIdx: (0, import_mysql_core47.index)("userId_idx").on(qr.userId),
|
|
13036
|
+
emailListSubscriberIdIdx: (0, import_mysql_core47.index)("emailListSubscriberId_idx").on(qr.emailListSubscriberId),
|
|
13037
|
+
surveySubscriberIdx: (0, import_mysql_core47.index)("survey_subscriber_idx").on(qr.surveyId, qr.emailListSubscriberId),
|
|
13038
|
+
surveyQuestionRespondentIdx: (0, import_mysql_core47.uniqueIndex)("survey_question_respondent_unique").on(qr.surveyId, qr.questionId, qr.respondentKey)
|
|
12621
13039
|
}));
|
|
12622
13040
|
}
|
|
12623
13041
|
__name(getQuestionResponseSchema, "getQuestionResponseSchema");
|
|
@@ -12626,7 +13044,7 @@ function getQuestionResponseRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12626
13044
|
const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
12627
13045
|
const users = resolveUsersSchema(mysqlTable);
|
|
12628
13046
|
const contentResource = getContentResourceSchema(mysqlTable);
|
|
12629
|
-
return (0,
|
|
13047
|
+
return (0, import_drizzle_orm42.relations)(questionResponse, ({ one }) => ({
|
|
12630
13048
|
user: one(users, {
|
|
12631
13049
|
fields: [
|
|
12632
13050
|
questionResponse.userId
|
|
@@ -12659,172 +13077,173 @@ function getQuestionResponseRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12659
13077
|
__name(getQuestionResponseRelationsSchema, "getQuestionResponseRelationsSchema");
|
|
12660
13078
|
|
|
12661
13079
|
// src/lib/mysql/schemas/content/lesson-progress.ts
|
|
12662
|
-
var
|
|
12663
|
-
var
|
|
13080
|
+
var import_drizzle_orm43 = require("drizzle-orm");
|
|
13081
|
+
var import_mysql_core48 = require("drizzle-orm/mysql-core");
|
|
12664
13082
|
function getLessonProgressSchema(mysqlTable) {
|
|
12665
13083
|
return mysqlTable("LessonProgress", {
|
|
12666
|
-
id: (0,
|
|
13084
|
+
id: (0, import_mysql_core48.varchar)("id", {
|
|
12667
13085
|
length: 191
|
|
12668
13086
|
}).notNull().primaryKey(),
|
|
12669
|
-
userId: (0,
|
|
13087
|
+
userId: (0, import_mysql_core48.varchar)("userId", {
|
|
12670
13088
|
length: 191
|
|
12671
13089
|
}).notNull(),
|
|
12672
|
-
organizationId: (0,
|
|
13090
|
+
organizationId: (0, import_mysql_core48.varchar)("organizationId", {
|
|
12673
13091
|
length: 191
|
|
12674
13092
|
}),
|
|
12675
|
-
organizationMembershipId: (0,
|
|
13093
|
+
organizationMembershipId: (0, import_mysql_core48.varchar)("organizationMembershipId", {
|
|
12676
13094
|
length: 191
|
|
12677
13095
|
}),
|
|
12678
|
-
lessonId: (0,
|
|
13096
|
+
lessonId: (0, import_mysql_core48.varchar)("lessonId", {
|
|
12679
13097
|
length: 191
|
|
12680
13098
|
}),
|
|
12681
|
-
lessonSlug: (0,
|
|
13099
|
+
lessonSlug: (0, import_mysql_core48.varchar)("lessonSlug", {
|
|
12682
13100
|
length: 191
|
|
12683
13101
|
}),
|
|
12684
|
-
lessonVersion: (0,
|
|
13102
|
+
lessonVersion: (0, import_mysql_core48.varchar)("lessonVersion", {
|
|
12685
13103
|
length: 191
|
|
12686
13104
|
}),
|
|
12687
|
-
sectionId: (0,
|
|
13105
|
+
sectionId: (0, import_mysql_core48.varchar)("sectionId", {
|
|
12688
13106
|
length: 191
|
|
12689
13107
|
}),
|
|
12690
|
-
moduleId: (0,
|
|
13108
|
+
moduleId: (0, import_mysql_core48.varchar)("moduleId", {
|
|
12691
13109
|
length: 191
|
|
12692
13110
|
}),
|
|
12693
|
-
completedAt: (0,
|
|
13111
|
+
completedAt: (0, import_mysql_core48.datetime)("completedAt", {
|
|
12694
13112
|
mode: "date",
|
|
12695
13113
|
fsp: 3
|
|
12696
13114
|
}),
|
|
12697
|
-
updatedAt: (0,
|
|
13115
|
+
updatedAt: (0, import_mysql_core48.datetime)("updatedAt", {
|
|
12698
13116
|
mode: "date",
|
|
12699
13117
|
fsp: 3
|
|
12700
13118
|
}),
|
|
12701
|
-
createdAt: (0,
|
|
13119
|
+
createdAt: (0, import_mysql_core48.datetime)("createdAt", {
|
|
12702
13120
|
mode: "date",
|
|
12703
13121
|
fsp: 3
|
|
12704
|
-
}).default(
|
|
13122
|
+
}).default(import_drizzle_orm43.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
12705
13123
|
}, (crp) => {
|
|
12706
13124
|
return {
|
|
12707
|
-
userIdLessonIdIdx: (0,
|
|
12708
|
-
userIdIdx: (0,
|
|
12709
|
-
lessonIdIdx: (0,
|
|
12710
|
-
organizationMembershipIdIdx: (0,
|
|
13125
|
+
userIdLessonIdIdx: (0, import_mysql_core48.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.lessonId),
|
|
13126
|
+
userIdIdx: (0, import_mysql_core48.index)("userId_idx").on(crp.userId),
|
|
13127
|
+
lessonIdIdx: (0, import_mysql_core48.index)("lessonId_idx").on(crp.lessonId),
|
|
13128
|
+
organizationMembershipIdIdx: (0, import_mysql_core48.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
|
|
12711
13129
|
};
|
|
12712
13130
|
});
|
|
12713
13131
|
}
|
|
12714
13132
|
__name(getLessonProgressSchema, "getLessonProgressSchema");
|
|
12715
13133
|
|
|
12716
13134
|
// src/lib/mysql/schemas/content/resource-progress.ts
|
|
12717
|
-
var
|
|
12718
|
-
var
|
|
13135
|
+
var import_drizzle_orm44 = require("drizzle-orm");
|
|
13136
|
+
var import_mysql_core49 = require("drizzle-orm/mysql-core");
|
|
12719
13137
|
function getResourceProgressSchema(mysqlTable) {
|
|
12720
13138
|
return mysqlTable("ResourceProgress", {
|
|
12721
|
-
userId: (0,
|
|
13139
|
+
userId: (0, import_mysql_core49.varchar)("userId", {
|
|
12722
13140
|
length: 255
|
|
12723
13141
|
}).notNull(),
|
|
12724
|
-
organizationId: (0,
|
|
13142
|
+
organizationId: (0, import_mysql_core49.varchar)("organizationId", {
|
|
12725
13143
|
length: 191
|
|
12726
13144
|
}),
|
|
12727
|
-
organizationMembershipId: (0,
|
|
13145
|
+
organizationMembershipId: (0, import_mysql_core49.varchar)("organizationMembershipId", {
|
|
12728
13146
|
length: 191
|
|
12729
13147
|
}),
|
|
12730
|
-
resourceId: (0,
|
|
13148
|
+
resourceId: (0, import_mysql_core49.varchar)("resourceId", {
|
|
12731
13149
|
length: 255
|
|
12732
13150
|
}),
|
|
12733
|
-
fields: (0,
|
|
12734
|
-
completedAt: (0,
|
|
13151
|
+
fields: (0, import_mysql_core49.json)("fields").$type().default({}),
|
|
13152
|
+
completedAt: (0, import_mysql_core49.datetime)("completedAt", {
|
|
12735
13153
|
mode: "date",
|
|
12736
13154
|
fsp: 3
|
|
12737
13155
|
}),
|
|
12738
|
-
updatedAt: (0,
|
|
13156
|
+
updatedAt: (0, import_mysql_core49.datetime)("updatedAt", {
|
|
12739
13157
|
mode: "date",
|
|
12740
13158
|
fsp: 3
|
|
12741
13159
|
}),
|
|
12742
|
-
createdAt: (0,
|
|
13160
|
+
createdAt: (0, import_mysql_core49.datetime)("createdAt", {
|
|
12743
13161
|
mode: "date",
|
|
12744
13162
|
fsp: 3
|
|
12745
|
-
}).default(
|
|
13163
|
+
}).default(import_drizzle_orm44.sql`CURRENT_TIMESTAMP(3)`).notNull()
|
|
12746
13164
|
}, (crp) => {
|
|
12747
13165
|
return {
|
|
12748
|
-
userIdLessonIdIdx: (0,
|
|
12749
|
-
pk: (0,
|
|
13166
|
+
userIdLessonIdIdx: (0, import_mysql_core49.index)("crp_userId_contentResourceId_idx").on(crp.userId, crp.resourceId),
|
|
13167
|
+
pk: (0, import_mysql_core49.primaryKey)({
|
|
12750
13168
|
columns: [
|
|
12751
13169
|
crp.userId,
|
|
12752
13170
|
crp.resourceId
|
|
12753
13171
|
]
|
|
12754
13172
|
}),
|
|
12755
|
-
contentResourceIdIdx: (0,
|
|
12756
|
-
userIdIdx: (0,
|
|
12757
|
-
organizationMembershipIdIdx: (0,
|
|
13173
|
+
contentResourceIdIdx: (0, import_mysql_core49.index)("contentResourceId_idx").on(crp.resourceId),
|
|
13174
|
+
userIdIdx: (0, import_mysql_core49.index)("resourceId_idx").on(crp.userId),
|
|
13175
|
+
organizationMembershipIdIdx: (0, import_mysql_core49.index)("organizationMembershipId_idx").on(crp.organizationMembershipId)
|
|
12758
13176
|
};
|
|
12759
13177
|
});
|
|
12760
13178
|
}
|
|
12761
13179
|
__name(getResourceProgressSchema, "getResourceProgressSchema");
|
|
12762
13180
|
|
|
12763
13181
|
// src/lib/mysql/schemas/entitlements/entitlement-type.ts
|
|
12764
|
-
var
|
|
13182
|
+
var import_mysql_core50 = require("drizzle-orm/mysql-core");
|
|
12765
13183
|
function getEntitlementTypesSchema(mysqlTable) {
|
|
12766
13184
|
return mysqlTable("EntitlementType", {
|
|
12767
|
-
id: (0,
|
|
13185
|
+
id: (0, import_mysql_core50.varchar)("id", {
|
|
12768
13186
|
length: 191
|
|
12769
13187
|
}).notNull().primaryKey(),
|
|
12770
|
-
name: (0,
|
|
13188
|
+
name: (0, import_mysql_core50.varchar)("name", {
|
|
12771
13189
|
length: 255
|
|
12772
13190
|
}).notNull(),
|
|
12773
|
-
description: (0,
|
|
13191
|
+
description: (0, import_mysql_core50.text)("description")
|
|
12774
13192
|
}, (table) => ({
|
|
12775
|
-
uniqueName: (0,
|
|
13193
|
+
uniqueName: (0, import_mysql_core50.uniqueIndex)("unique_name_idx").on(table.name)
|
|
12776
13194
|
}));
|
|
12777
13195
|
}
|
|
12778
13196
|
__name(getEntitlementTypesSchema, "getEntitlementTypesSchema");
|
|
12779
13197
|
|
|
12780
13198
|
// src/lib/mysql/schemas/entitlements/entitlement.ts
|
|
12781
|
-
var
|
|
12782
|
-
var
|
|
13199
|
+
var import_drizzle_orm45 = require("drizzle-orm");
|
|
13200
|
+
var import_mysql_core51 = require("drizzle-orm/mysql-core");
|
|
12783
13201
|
function getEntitlementsSchema(mysqlTable) {
|
|
12784
13202
|
return mysqlTable("Entitlement", {
|
|
12785
|
-
id: (0,
|
|
13203
|
+
id: (0, import_mysql_core51.varchar)("id", {
|
|
12786
13204
|
length: 191
|
|
12787
13205
|
}).notNull().primaryKey(),
|
|
12788
|
-
entitlementType: (0,
|
|
13206
|
+
entitlementType: (0, import_mysql_core51.varchar)("entitlementType", {
|
|
12789
13207
|
length: 255
|
|
12790
13208
|
}).notNull(),
|
|
12791
|
-
userId: (0,
|
|
13209
|
+
userId: (0, import_mysql_core51.varchar)("userId", {
|
|
12792
13210
|
length: 191
|
|
12793
13211
|
}),
|
|
12794
|
-
organizationId: (0,
|
|
13212
|
+
organizationId: (0, import_mysql_core51.varchar)("organizationId", {
|
|
12795
13213
|
length: 191
|
|
12796
13214
|
}),
|
|
12797
|
-
organizationMembershipId: (0,
|
|
13215
|
+
organizationMembershipId: (0, import_mysql_core51.varchar)("organizationMembershipId", {
|
|
12798
13216
|
length: 191
|
|
12799
13217
|
}),
|
|
12800
|
-
sourceType: (0,
|
|
13218
|
+
sourceType: (0, import_mysql_core51.varchar)("sourceType", {
|
|
12801
13219
|
length: 255
|
|
12802
13220
|
}).notNull(),
|
|
12803
|
-
sourceId: (0,
|
|
13221
|
+
sourceId: (0, import_mysql_core51.varchar)("sourceId", {
|
|
12804
13222
|
length: 191
|
|
12805
13223
|
}).notNull(),
|
|
12806
|
-
metadata: (0,
|
|
12807
|
-
expiresAt: (0,
|
|
13224
|
+
metadata: (0, import_mysql_core51.json)("metadata").$type().default({}),
|
|
13225
|
+
expiresAt: (0, import_mysql_core51.timestamp)("expiresAt", {
|
|
12808
13226
|
mode: "date",
|
|
12809
13227
|
fsp: 3
|
|
12810
13228
|
}),
|
|
12811
|
-
createdAt: (0,
|
|
13229
|
+
createdAt: (0, import_mysql_core51.timestamp)("createdAt", {
|
|
12812
13230
|
mode: "date",
|
|
12813
13231
|
fsp: 3
|
|
12814
|
-
}).default(
|
|
12815
|
-
updatedAt: (0,
|
|
13232
|
+
}).default(import_drizzle_orm45.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
13233
|
+
updatedAt: (0, import_mysql_core51.timestamp)("updatedAt", {
|
|
12816
13234
|
mode: "date",
|
|
12817
13235
|
fsp: 3
|
|
12818
|
-
}).default(
|
|
12819
|
-
deletedAt: (0,
|
|
13236
|
+
}).default(import_drizzle_orm45.sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
13237
|
+
deletedAt: (0, import_mysql_core51.timestamp)("deletedAt", {
|
|
12820
13238
|
mode: "date",
|
|
12821
13239
|
fsp: 3
|
|
12822
13240
|
})
|
|
12823
13241
|
}, (table) => ({
|
|
12824
|
-
userIdIdx: (0,
|
|
12825
|
-
orgIdIdx: (0,
|
|
12826
|
-
sourceIdx: (0,
|
|
12827
|
-
typeIdx: (0,
|
|
13242
|
+
userIdIdx: (0, import_mysql_core51.index)("userId_idx").on(table.userId),
|
|
13243
|
+
orgIdIdx: (0, import_mysql_core51.index)("orgId_idx").on(table.organizationId),
|
|
13244
|
+
sourceIdx: (0, import_mysql_core51.index)("source_idx").on(table.sourceType, table.sourceId),
|
|
13245
|
+
typeIdx: (0, import_mysql_core51.index)("type_idx").on(table.entitlementType),
|
|
13246
|
+
userIdTypeDeletedAtIdx: (0, import_mysql_core51.index)("idx_Entitlement_on_userId_type_deletedAt").on(table.userId, table.entitlementType, table.deletedAt)
|
|
12828
13247
|
}));
|
|
12829
13248
|
}
|
|
12830
13249
|
__name(getEntitlementsSchema, "getEntitlementsSchema");
|
|
@@ -12834,7 +13253,7 @@ function getEntitlementRelationsSchema(mysqlTable, overrides = {}) {
|
|
|
12834
13253
|
const users = resolveUsersSchema(mysqlTable);
|
|
12835
13254
|
const orgs = getOrganizationsSchema(mysqlTable);
|
|
12836
13255
|
const memberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
12837
|
-
return (0,
|
|
13256
|
+
return (0, import_drizzle_orm45.relations)(entitlements, ({ one }) => ({
|
|
12838
13257
|
user: one(users, {
|
|
12839
13258
|
fields: [
|
|
12840
13259
|
entitlements.userId
|
|
@@ -12875,6 +13294,19 @@ function toError(error) {
|
|
|
12875
13294
|
}
|
|
12876
13295
|
__name(toError, "toError");
|
|
12877
13296
|
var logger2 = logger;
|
|
13297
|
+
function mergePurchaseBenefitFields(fields, expansion) {
|
|
13298
|
+
if (!expansion)
|
|
13299
|
+
return fields;
|
|
13300
|
+
return {
|
|
13301
|
+
...fields,
|
|
13302
|
+
...expansion.success ? {
|
|
13303
|
+
purchaseBenefits: expansion.benefits
|
|
13304
|
+
} : {
|
|
13305
|
+
purchaseBenefitsReview: expansion.review
|
|
13306
|
+
}
|
|
13307
|
+
};
|
|
13308
|
+
}
|
|
13309
|
+
__name(mergePurchaseBenefitFields, "mergePurchaseBenefitFields");
|
|
12878
13310
|
function getCourseBuilderSchema(mysqlTable, overrides = {}) {
|
|
12879
13311
|
const resolvedGetUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
12880
13312
|
const userRelationsOverrides = {
|
|
@@ -12947,6 +13379,8 @@ function getCourseBuilderSchema(mysqlTable, overrides = {}) {
|
|
|
12947
13379
|
deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
12948
13380
|
deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
|
|
12949
13381
|
deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
13382
|
+
personalAccessToken: getPersonalAccessTokenSchema(mysqlTable),
|
|
13383
|
+
personalAccessTokenRelations: getPersonalAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
12950
13384
|
tag: getTagSchema(mysqlTable),
|
|
12951
13385
|
tagRelations: getTagRelationsSchema(mysqlTable),
|
|
12952
13386
|
tagTag: getTagTagSchema(mysqlTable),
|
|
@@ -12975,13 +13409,40 @@ function createTables(mySqlTable) {
|
|
|
12975
13409
|
return getCourseBuilderSchema(mySqlTable);
|
|
12976
13410
|
}
|
|
12977
13411
|
__name(createTables, "createTables");
|
|
12978
|
-
function
|
|
13412
|
+
async function provisionPersonalOrganization(adapter, params) {
|
|
13413
|
+
const { userId, email } = params;
|
|
13414
|
+
const personalOrganization = await adapter.createOrganization({
|
|
13415
|
+
name: `Personal (${email})`
|
|
13416
|
+
});
|
|
13417
|
+
if (!personalOrganization) {
|
|
13418
|
+
throw new Error("Failed to create personal organization");
|
|
13419
|
+
}
|
|
13420
|
+
const membership = await adapter.addMemberToOrganization({
|
|
13421
|
+
organizationId: personalOrganization.id,
|
|
13422
|
+
userId,
|
|
13423
|
+
invitedById: userId
|
|
13424
|
+
});
|
|
13425
|
+
if (!membership) {
|
|
13426
|
+
throw new Error("Failed to add user to personal organization");
|
|
13427
|
+
}
|
|
13428
|
+
await adapter.addRoleForMember({
|
|
13429
|
+
organizationId: personalOrganization.id,
|
|
13430
|
+
memberId: membership.id,
|
|
13431
|
+
role: "owner"
|
|
13432
|
+
});
|
|
13433
|
+
}
|
|
13434
|
+
__name(provisionPersonalOrganization, "provisionPersonalOrganization");
|
|
13435
|
+
function mySqlDrizzleAdapter(client, tableFn = import_mysql_core52.mysqlTable, paymentProvider) {
|
|
12979
13436
|
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, contentResourceTag, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantEvents, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments, organization: organizationTable, organizationMemberships: organizationMembershipTable, organizationMembershipRoles: organizationMembershipRoleTable, roles: roleTable, merchantSubscription: merchantSubscriptionTable, subscription: subscriptionTable, entitlements: entitlementTable, entitlementTypes } = createTables(tableFn);
|
|
13437
|
+
const normalizeLearnerEmail = /* @__PURE__ */ __name((email) => email.trim().toLowerCase().replace(/\s+/g, "+"), "normalizeLearnerEmail");
|
|
12980
13438
|
const adapter = {
|
|
12981
13439
|
client,
|
|
13440
|
+
async provisionPersonalOrganization(params) {
|
|
13441
|
+
await provisionPersonalOrganization(adapter, params);
|
|
13442
|
+
},
|
|
12982
13443
|
async redeemFullPriceCoupon(options) {
|
|
12983
13444
|
const { email: baseEmail, couponId, productIds, currentUserId, redeemingProductId } = options;
|
|
12984
|
-
const email = String(baseEmail)
|
|
13445
|
+
const email = normalizeLearnerEmail(String(baseEmail));
|
|
12985
13446
|
const coupon2 = await adapter.getCouponWithBulkPurchases(couponId);
|
|
12986
13447
|
const productId = coupon2 && coupon2.restrictedToProductId || redeemingProductId;
|
|
12987
13448
|
if (!productId)
|
|
@@ -12994,6 +13455,28 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
12994
13455
|
throw new Error(`unable-to-create-user-${email}`);
|
|
12995
13456
|
const currentUser = currentUserId ? await adapter.getUserById(currentUserId) : null;
|
|
12996
13457
|
const redeemingForCurrentUser = currentUser?.id === user.id;
|
|
13458
|
+
if (bulkCouponRedemption) {
|
|
13459
|
+
const existingValidRedemption = await client.query.purchases.findFirst({
|
|
13460
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.redeemedBulkCouponId, coupon2.id), (0, import_drizzle_orm46.eq)(purchaseTable.userId, user.id), (0, import_drizzle_orm46.eq)(purchaseTable.status, "Valid"))
|
|
13461
|
+
});
|
|
13462
|
+
if (existingValidRedemption) {
|
|
13463
|
+
logger2.info("adapter.coupon.redeem.duplicate_team_seat", {
|
|
13464
|
+
couponId: coupon2.id,
|
|
13465
|
+
currentUserId,
|
|
13466
|
+
email,
|
|
13467
|
+
productId,
|
|
13468
|
+
purchaseId: existingValidRedemption.id,
|
|
13469
|
+
userId: user.id
|
|
13470
|
+
});
|
|
13471
|
+
return {
|
|
13472
|
+
error: {
|
|
13473
|
+
message: "team-seat-redemption-already-claimed"
|
|
13474
|
+
},
|
|
13475
|
+
redeemingForCurrentUser,
|
|
13476
|
+
purchase: null
|
|
13477
|
+
};
|
|
13478
|
+
}
|
|
13479
|
+
}
|
|
12997
13480
|
const existingPurchases = await adapter.getExistingNonBulkValidPurchasesOfProduct({
|
|
12998
13481
|
userId: user.id,
|
|
12999
13482
|
productId
|
|
@@ -13056,12 +13539,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13056
13539
|
},
|
|
13057
13540
|
incrementCouponUsedCount: async (couponId) => {
|
|
13058
13541
|
await client.update(coupon).set({
|
|
13059
|
-
usedCount:
|
|
13060
|
-
}).where((0,
|
|
13542
|
+
usedCount: import_drizzle_orm46.sql`${coupon.usedCount} + 1`
|
|
13543
|
+
}).where((0, import_drizzle_orm46.eq)(coupon.id, couponId));
|
|
13061
13544
|
},
|
|
13062
13545
|
getExistingNonBulkValidPurchasesOfProduct: async ({ userId, productId }) => {
|
|
13063
13546
|
const existingPurchases = await client.query.purchases.findMany({
|
|
13064
|
-
where: (0,
|
|
13547
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), productId ? (0, import_drizzle_orm46.eq)(purchaseTable.productId, productId) : void 0, (0, import_drizzle_orm46.eq)(purchaseTable.status, "Valid"), (0, import_drizzle_orm46.isNull)(purchaseTable.bulkCouponId))
|
|
13065
13548
|
});
|
|
13066
13549
|
return external_exports.array(purchaseSchema).parse(existingPurchases);
|
|
13067
13550
|
},
|
|
@@ -13074,7 +13557,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13074
13557
|
status: 1
|
|
13075
13558
|
});
|
|
13076
13559
|
return merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
13077
|
-
where: (0,
|
|
13560
|
+
where: (0, import_drizzle_orm46.eq)(merchantCustomer.identifier, options.identifier)
|
|
13078
13561
|
}));
|
|
13079
13562
|
},
|
|
13080
13563
|
createMerchantCoupon: async (options) => {
|
|
@@ -13087,17 +13570,17 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13087
13570
|
status: 1
|
|
13088
13571
|
});
|
|
13089
13572
|
return merchantCouponSchema.parse(await client.query.merchantCoupon.findFirst({
|
|
13090
|
-
where: (0,
|
|
13573
|
+
where: (0, import_drizzle_orm46.eq)(merchantCoupon.identifier, options.identifier)
|
|
13091
13574
|
}));
|
|
13092
13575
|
},
|
|
13093
13576
|
getMerchantAccount: async (options) => {
|
|
13094
13577
|
return merchantAccountSchema.parse(await client.query.merchantAccount.findFirst({
|
|
13095
|
-
where: (0,
|
|
13578
|
+
where: (0, import_drizzle_orm46.eq)(merchantAccount.label, options.provider)
|
|
13096
13579
|
}));
|
|
13097
13580
|
},
|
|
13098
13581
|
getMerchantPriceForProductId: async (productId) => {
|
|
13099
13582
|
const merchantPriceData = await client.query.merchantPrice.findFirst({
|
|
13100
|
-
where: (0,
|
|
13583
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantPrice.merchantProductId, productId), (0, import_drizzle_orm46.eq)(merchantPrice.status, 1))
|
|
13101
13584
|
});
|
|
13102
13585
|
const parsedMerchantPrice = merchantPriceSchema.safeParse(merchantPriceData);
|
|
13103
13586
|
if (!parsedMerchantPrice.success) {
|
|
@@ -13111,7 +13594,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13111
13594
|
},
|
|
13112
13595
|
getMerchantProductForProductId: async (productId) => {
|
|
13113
13596
|
const merchantProductData = await client.query.merchantProduct.findFirst({
|
|
13114
|
-
where: (0,
|
|
13597
|
+
where: (0, import_drizzle_orm46.eq)(merchantProduct.productId, productId)
|
|
13115
13598
|
});
|
|
13116
13599
|
if (!merchantProductData)
|
|
13117
13600
|
return null;
|
|
@@ -13119,7 +13602,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13119
13602
|
},
|
|
13120
13603
|
getMerchantCustomerForUserId: async (userId) => {
|
|
13121
13604
|
const merchantCustomerData = await client.query.merchantCustomer.findFirst({
|
|
13122
|
-
where: (0,
|
|
13605
|
+
where: (0, import_drizzle_orm46.eq)(merchantCustomer.userId, userId)
|
|
13123
13606
|
});
|
|
13124
13607
|
if (!merchantCustomerData)
|
|
13125
13608
|
return null;
|
|
@@ -13128,14 +13611,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13128
13611
|
getUpgradableProducts: async (options) => {
|
|
13129
13612
|
const { upgradableFromId, upgradableToId } = options;
|
|
13130
13613
|
return external_exports.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
13131
|
-
where: (0,
|
|
13614
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(upgradableProducts.upgradableFromId, upgradableFromId), (0, import_drizzle_orm46.eq)(upgradableProducts.upgradableToId, upgradableToId))
|
|
13132
13615
|
}));
|
|
13133
13616
|
},
|
|
13134
13617
|
async availableUpgradesForProduct(purchases, productId) {
|
|
13135
13618
|
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
13136
13619
|
if (previousPurchaseProductIds.length > 0) {
|
|
13137
13620
|
return client.query.upgradableProducts.findMany({
|
|
13138
|
-
where: (0,
|
|
13621
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(upgradableProducts.upgradableToId, productId), (0, import_drizzle_orm46.inArray)(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
|
|
13139
13622
|
});
|
|
13140
13623
|
}
|
|
13141
13624
|
return [];
|
|
@@ -13148,7 +13631,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13148
13631
|
throw new Error("No lessonId provided");
|
|
13149
13632
|
}
|
|
13150
13633
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
13151
|
-
where: (0,
|
|
13634
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm46.eq)(resourceProgress.resourceId, options.lessonId))
|
|
13152
13635
|
});
|
|
13153
13636
|
const now = /* @__PURE__ */ new Date();
|
|
13154
13637
|
if (lessonProgress) {
|
|
@@ -13156,7 +13639,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13156
13639
|
await client.update(resourceProgress).set({
|
|
13157
13640
|
completedAt: now,
|
|
13158
13641
|
updatedAt: now
|
|
13159
|
-
}).where((0,
|
|
13642
|
+
}).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm46.eq)(resourceProgress.resourceId, options.lessonId)));
|
|
13160
13643
|
}
|
|
13161
13644
|
} else {
|
|
13162
13645
|
await client.insert(resourceProgress).values({
|
|
@@ -13167,7 +13650,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13167
13650
|
});
|
|
13168
13651
|
}
|
|
13169
13652
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
13170
|
-
where: (0,
|
|
13653
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm46.eq)(resourceProgress.resourceId, options.lessonId))
|
|
13171
13654
|
});
|
|
13172
13655
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
13173
13656
|
if (!parsedLessonProgress.success) {
|
|
@@ -13184,7 +13667,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13184
13667
|
if (!options.couponId && !options.code)
|
|
13185
13668
|
return null;
|
|
13186
13669
|
const couponForIdOrCode = await client.query.coupon.findFirst({
|
|
13187
|
-
where: (0,
|
|
13670
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.or)(options.code ? (0, import_drizzle_orm46.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm46.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm46.gte)(coupon.expires, /* @__PURE__ */ new Date())), (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.or)(options.code ? (0, import_drizzle_orm46.eq)(coupon.code, options.code) : void 0, options.couponId ? (0, import_drizzle_orm46.eq)(coupon.id, options.couponId) : void 0), (0, import_drizzle_orm46.isNull)(coupon.expires))),
|
|
13188
13671
|
with: {
|
|
13189
13672
|
merchantCoupon: true
|
|
13190
13673
|
}
|
|
@@ -13215,18 +13698,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13215
13698
|
} : {}
|
|
13216
13699
|
});
|
|
13217
13700
|
return MerchantSessionSchema.parse(await client.query.merchantSession.findFirst({
|
|
13218
|
-
where: (0,
|
|
13701
|
+
where: (0, import_drizzle_orm46.eq)(merchantSession.id, id)
|
|
13219
13702
|
}));
|
|
13220
13703
|
},
|
|
13221
13704
|
async createMerchantChargeAndPurchase(options) {
|
|
13222
13705
|
const purchaseId = await client.transaction(async (trx) => {
|
|
13223
13706
|
try {
|
|
13224
|
-
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId, organizationId } = options;
|
|
13707
|
+
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId, organizationId, attributionSnapshot } = options;
|
|
13225
13708
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
13226
|
-
where: (0,
|
|
13709
|
+
where: (0, import_drizzle_orm46.eq)(merchantCharge.identifier, stripeChargeId)
|
|
13227
13710
|
}) || null);
|
|
13228
13711
|
const existingPurchaseForCharge = existingMerchantCharge ? await client.query.purchases.findFirst({
|
|
13229
|
-
where: (0,
|
|
13712
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.merchantChargeId, existingMerchantCharge.id),
|
|
13230
13713
|
with: {
|
|
13231
13714
|
user: true,
|
|
13232
13715
|
product: true,
|
|
@@ -13247,37 +13730,55 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13247
13730
|
merchantCustomerId
|
|
13248
13731
|
});
|
|
13249
13732
|
const existingPurchase = purchaseSchema.nullable().parse(await client.query.purchases.findFirst({
|
|
13250
|
-
where: (0,
|
|
13733
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm46.inArray)(purchaseTable.status, [
|
|
13251
13734
|
"Valid",
|
|
13252
13735
|
"Restricted"
|
|
13253
13736
|
]))
|
|
13254
13737
|
}) || null);
|
|
13255
|
-
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0,
|
|
13738
|
+
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(coupon.id, purchaseTable.bulkCouponId), (0, import_drizzle_orm46.eq)(purchaseTable.userId, userId))).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(coupon.restrictedToProductId, productId), (0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm46.eq)(purchaseTable.status, "Valid"))).then((res) => {
|
|
13256
13739
|
return res[0]?.Coupon ?? null;
|
|
13257
13740
|
}));
|
|
13258
|
-
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk
|
|
13741
|
+
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || Boolean(options.bulk);
|
|
13259
13742
|
let bulkCouponId = null;
|
|
13260
13743
|
let couponToUpdate = null;
|
|
13744
|
+
const purchaseBenefitsTransport = options.purchaseBenefitsTransport?.trim() || void 0;
|
|
13745
|
+
const purchaseBenefitExpansion = purchaseBenefitsTransport ? parseAndExpandPurchaseBenefitTransport({
|
|
13746
|
+
transport: purchaseBenefitsTransport,
|
|
13747
|
+
appliesTo: isBulkPurchase ? "redeemed_team_seat" : "buyer"
|
|
13748
|
+
}) : null;
|
|
13749
|
+
if (purchaseBenefitExpansion && !purchaseBenefitExpansion.success) {
|
|
13750
|
+
logger2.info("purchase_benefits.transport.needs_review", {
|
|
13751
|
+
checkoutSessionId,
|
|
13752
|
+
event: "purchase_benefits.transport.needs_review",
|
|
13753
|
+
metadataKey: PURCHASE_BENEFIT_METADATA_KEY,
|
|
13754
|
+
productId,
|
|
13755
|
+
stripeChargeId,
|
|
13756
|
+
userId,
|
|
13757
|
+
errors: purchaseBenefitExpansion.review.errors
|
|
13758
|
+
});
|
|
13759
|
+
}
|
|
13261
13760
|
if (isBulkPurchase) {
|
|
13262
13761
|
bulkCouponId = existingBulkCoupon !== null ? existingBulkCoupon.id : (0, import_uuid.v4)();
|
|
13263
13762
|
if (existingBulkCoupon !== null) {
|
|
13763
|
+
const existingCouponFields = existingBulkCoupon.fields ?? {};
|
|
13264
13764
|
couponToUpdate = await client.update(coupon).set({
|
|
13265
13765
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity,
|
|
13766
|
+
fields: mergePurchaseBenefitFields(existingCouponFields, purchaseBenefitExpansion),
|
|
13266
13767
|
...organizationId ? {
|
|
13267
13768
|
organizationId
|
|
13268
13769
|
} : {}
|
|
13269
|
-
}).where((0,
|
|
13770
|
+
}).where((0, import_drizzle_orm46.eq)(coupon.id, bulkCouponId));
|
|
13270
13771
|
} else {
|
|
13271
13772
|
let merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
13272
|
-
where: (0,
|
|
13773
|
+
where: (0, import_drizzle_orm46.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
13273
13774
|
}) || null) : null;
|
|
13274
13775
|
if (!merchantCouponToUse && usedCouponId) {
|
|
13275
13776
|
const usedCoupon = couponSchema.nullable().parse(await client.query.coupon.findFirst({
|
|
13276
|
-
where: (0,
|
|
13777
|
+
where: (0, import_drizzle_orm46.eq)(coupon.id, usedCouponId)
|
|
13277
13778
|
}) || null);
|
|
13278
13779
|
if (usedCoupon?.merchantCouponId) {
|
|
13279
13780
|
merchantCouponToUse = merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
13280
|
-
where: (0,
|
|
13781
|
+
where: (0, import_drizzle_orm46.eq)(merchantCoupon.id, usedCoupon.merchantCouponId)
|
|
13281
13782
|
}) || null);
|
|
13282
13783
|
}
|
|
13283
13784
|
}
|
|
@@ -13287,6 +13788,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13287
13788
|
restrictedToProductId: productId,
|
|
13288
13789
|
maxUses: quantity,
|
|
13289
13790
|
status: 1,
|
|
13791
|
+
fields: mergePurchaseBenefitFields({}, purchaseBenefitExpansion),
|
|
13290
13792
|
...organizationId ? {
|
|
13291
13793
|
organizationId
|
|
13292
13794
|
} : {},
|
|
@@ -13304,10 +13806,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13304
13806
|
merchantAccountId
|
|
13305
13807
|
});
|
|
13306
13808
|
const merchantCouponUsed = stripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
13307
|
-
where: (0,
|
|
13809
|
+
where: (0, import_drizzle_orm46.eq)(merchantCoupon.identifier, stripeCouponId)
|
|
13308
13810
|
}) : null;
|
|
13309
13811
|
const pppMerchantCoupon = appliedPPPStripeCouponId ? await client.query.merchantCoupon.findFirst({
|
|
13310
|
-
where: (0,
|
|
13812
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantCoupon.identifier, appliedPPPStripeCouponId), (0, import_drizzle_orm46.eq)(merchantCoupon.type, "ppp"))
|
|
13311
13813
|
}) : null;
|
|
13312
13814
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
13313
13815
|
await client.insert(purchaseTable).values({
|
|
@@ -13320,6 +13822,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13320
13822
|
bulkCouponId,
|
|
13321
13823
|
merchantSessionId,
|
|
13322
13824
|
country,
|
|
13825
|
+
fields: {
|
|
13826
|
+
...!isBulkPurchase ? mergePurchaseBenefitFields({}, purchaseBenefitExpansion) : {},
|
|
13827
|
+
...attributionSnapshot ? {
|
|
13828
|
+
attribution: attributionSnapshot
|
|
13829
|
+
} : {}
|
|
13830
|
+
},
|
|
13323
13831
|
upgradedFromId: upgradedFromPurchaseId || null,
|
|
13324
13832
|
couponId: usedCouponId || null,
|
|
13325
13833
|
...organizationId ? {
|
|
@@ -13351,7 +13859,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13351
13859
|
}
|
|
13352
13860
|
});
|
|
13353
13861
|
const parsedPurchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
13354
|
-
where: (0,
|
|
13862
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.id, purchaseId)
|
|
13355
13863
|
}));
|
|
13356
13864
|
if (!parsedPurchase.success) {
|
|
13357
13865
|
logger2.error(parsedPurchase.error, {
|
|
@@ -13386,21 +13894,21 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13386
13894
|
payload: options.payload
|
|
13387
13895
|
});
|
|
13388
13896
|
const createdEvent = await client.query.merchantEvents.findFirst({
|
|
13389
|
-
where: (0,
|
|
13897
|
+
where: (0, import_drizzle_orm46.eq)(merchantEvents.id, eventId)
|
|
13390
13898
|
});
|
|
13391
13899
|
return merchantEventsSchema.parse(createdEvent);
|
|
13392
13900
|
},
|
|
13393
13901
|
async getMerchantEventByIdentifier(identifier) {
|
|
13394
13902
|
const event = await client.query.merchantEvents.findFirst({
|
|
13395
|
-
where: (0,
|
|
13903
|
+
where: (0, import_drizzle_orm46.eq)(merchantEvents.identifier, identifier)
|
|
13396
13904
|
});
|
|
13397
13905
|
return event ? merchantEventsSchema.parse(event) : null;
|
|
13398
13906
|
},
|
|
13399
13907
|
async getMerchantEventsByAccount(merchantAccountId) {
|
|
13400
13908
|
const events = await client.query.merchantEvents.findMany({
|
|
13401
|
-
where: (0,
|
|
13909
|
+
where: (0, import_drizzle_orm46.eq)(merchantEvents.merchantAccountId, merchantAccountId),
|
|
13402
13910
|
orderBy: [
|
|
13403
|
-
(0,
|
|
13911
|
+
(0, import_drizzle_orm46.desc)(merchantEvents.createdAt)
|
|
13404
13912
|
]
|
|
13405
13913
|
});
|
|
13406
13914
|
return events.map((event) => merchantEventsSchema.parse(event));
|
|
@@ -13433,7 +13941,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13433
13941
|
},
|
|
13434
13942
|
async getCoupon(couponIdOrCode) {
|
|
13435
13943
|
const loadedCoupon = await client.query.coupon.findFirst({
|
|
13436
|
-
where: (0,
|
|
13944
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm46.eq)(coupon.code, couponIdOrCode))
|
|
13437
13945
|
}) || null;
|
|
13438
13946
|
logger2.debug("getCoupon", {
|
|
13439
13947
|
couponIdOrCode,
|
|
@@ -13445,7 +13953,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13445
13953
|
return external_exports.array(purchaseSchema.extend({
|
|
13446
13954
|
user: userSchema
|
|
13447
13955
|
})).parse(await client.query.purchases.findMany({
|
|
13448
|
-
where: (0,
|
|
13956
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.bulkCouponId, bulkCouponId),
|
|
13449
13957
|
with: {
|
|
13450
13958
|
user: true
|
|
13451
13959
|
}
|
|
@@ -13459,7 +13967,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13459
13967
|
let bulkCouponPurchases = [];
|
|
13460
13968
|
try {
|
|
13461
13969
|
couponData = await client.query.coupon.findFirst({
|
|
13462
|
-
where: (0,
|
|
13970
|
+
where: (0, import_drizzle_orm46.eq)(coupon.id, couponId),
|
|
13463
13971
|
with: {
|
|
13464
13972
|
bulkPurchases: true,
|
|
13465
13973
|
redeemedBulkCouponPurchases: true
|
|
@@ -13474,7 +13982,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13474
13982
|
}
|
|
13475
13983
|
try {
|
|
13476
13984
|
bulkCouponPurchases = await client.query.purchases.findMany({
|
|
13477
|
-
where: (0,
|
|
13985
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.redeemedBulkCouponId, couponId),
|
|
13478
13986
|
with: {
|
|
13479
13987
|
user: true
|
|
13480
13988
|
}
|
|
@@ -13516,8 +14024,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13516
14024
|
},
|
|
13517
14025
|
async getDefaultCoupon(productIds) {
|
|
13518
14026
|
const activeSaleCoupon = await client.query.coupon.findFirst({
|
|
13519
|
-
where: (0,
|
|
13520
|
-
orderBy: (0,
|
|
14027
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(coupon.status, 1), (0, import_drizzle_orm46.eq)(coupon.default, true), (0, import_drizzle_orm46.gte)(coupon.expires, /* @__PURE__ */ new Date()), (0, import_drizzle_orm46.or)(productIds ? (0, import_drizzle_orm46.inArray)(coupon.restrictedToProductId, productIds) : void 0, (0, import_drizzle_orm46.isNull)(coupon.restrictedToProductId))),
|
|
14028
|
+
orderBy: (0, import_drizzle_orm46.desc)(coupon.percentageDiscount),
|
|
13521
14029
|
with: {
|
|
13522
14030
|
merchantCoupon: true,
|
|
13523
14031
|
product: true
|
|
@@ -13541,7 +14049,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13541
14049
|
},
|
|
13542
14050
|
async getLessonProgressForUser(userId) {
|
|
13543
14051
|
const userProgress = await client.query.resourceProgress.findMany({
|
|
13544
|
-
where: (0,
|
|
14052
|
+
where: (0, import_drizzle_orm46.eq)(resourceProgress.userId, userId)
|
|
13545
14053
|
});
|
|
13546
14054
|
const parsed = external_exports.array(resourceProgressSchema).safeParse(userProgress);
|
|
13547
14055
|
if (!parsed.success) {
|
|
@@ -13555,7 +14063,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13555
14063
|
},
|
|
13556
14064
|
async getModuleProgressForUser(userIdOrEmail, moduleIdOrSlug) {
|
|
13557
14065
|
const user = await client.query.users.findFirst({
|
|
13558
|
-
where: (0,
|
|
14066
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm46.eq)(users.email, userIdOrEmail)),
|
|
13559
14067
|
columns: {
|
|
13560
14068
|
id: true
|
|
13561
14069
|
}
|
|
@@ -13573,7 +14081,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13573
14081
|
resource_slug: external_exports.string().nullable(),
|
|
13574
14082
|
completed_at: external_exports.string().nullable().transform((val) => val ? new Date(val) : null)
|
|
13575
14083
|
});
|
|
13576
|
-
const results = await client.execute(
|
|
14084
|
+
const results = await client.execute(import_drizzle_orm46.sql`
|
|
13577
14085
|
WITH RECURSIVE workshop AS (
|
|
13578
14086
|
SELECT id, fields->>'$.slug' AS slug
|
|
13579
14087
|
FROM ${contentResource}
|
|
@@ -13680,7 +14188,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13680
14188
|
},
|
|
13681
14189
|
async getMerchantCharge(merchantChargeId) {
|
|
13682
14190
|
const mCharge = await client.query.merchantCharge.findFirst({
|
|
13683
|
-
where: (0,
|
|
14191
|
+
where: (0, import_drizzle_orm46.eq)(merchantCharge.id, merchantChargeId)
|
|
13684
14192
|
});
|
|
13685
14193
|
const parsed = merchantChargeSchema.safeParse(mCharge);
|
|
13686
14194
|
if (!parsed.success) {
|
|
@@ -13694,12 +14202,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13694
14202
|
},
|
|
13695
14203
|
async getMerchantCouponsForTypeAndPercent(params) {
|
|
13696
14204
|
return external_exports.array(merchantCouponSchema).parse(await client.query.merchantCoupon.findMany({
|
|
13697
|
-
where: (0,
|
|
14205
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm46.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
13698
14206
|
}));
|
|
13699
14207
|
},
|
|
13700
14208
|
async getMerchantCouponForTypeAndPercent(params) {
|
|
13701
14209
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
13702
|
-
where: (0,
|
|
14210
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm46.eq)(merchantCoupon.percentageDiscount, params.percentageDiscount.toString()))
|
|
13703
14211
|
});
|
|
13704
14212
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
13705
14213
|
if (parsed.success) {
|
|
@@ -13709,7 +14217,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13709
14217
|
},
|
|
13710
14218
|
async getMerchantCouponForTypeAndAmount(params) {
|
|
13711
14219
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
13712
|
-
where: (0,
|
|
14220
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantCoupon.type, params.type), (0, import_drizzle_orm46.eq)(merchantCoupon.amountDiscount, params.amountDiscount))
|
|
13713
14221
|
});
|
|
13714
14222
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
13715
14223
|
if (parsed.success) {
|
|
@@ -13719,7 +14227,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13719
14227
|
},
|
|
13720
14228
|
async getMerchantCoupon(merchantCouponId) {
|
|
13721
14229
|
const foundMerchantCoupon = await client.query.merchantCoupon.findFirst({
|
|
13722
|
-
where: (0,
|
|
14230
|
+
where: (0, import_drizzle_orm46.eq)(merchantCoupon.id, merchantCouponId)
|
|
13723
14231
|
});
|
|
13724
14232
|
const parsed = merchantCouponSchema.nullable().safeParse(foundMerchantCoupon);
|
|
13725
14233
|
if (parsed.success) {
|
|
@@ -13729,7 +14237,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13729
14237
|
},
|
|
13730
14238
|
async getMerchantProduct(stripeProductId) {
|
|
13731
14239
|
return merchantProductSchema.nullable().parse(await client.query.merchantProduct.findFirst({
|
|
13732
|
-
where: (0,
|
|
14240
|
+
where: (0, import_drizzle_orm46.eq)(merchantProduct.identifier, stripeProductId)
|
|
13733
14241
|
}));
|
|
13734
14242
|
},
|
|
13735
14243
|
getPrice(productId) {
|
|
@@ -13737,7 +14245,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13737
14245
|
},
|
|
13738
14246
|
async getPriceForProduct(productId) {
|
|
13739
14247
|
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
13740
|
-
where: (0,
|
|
14248
|
+
where: (0, import_drizzle_orm46.eq)(prices.productId, productId)
|
|
13741
14249
|
}));
|
|
13742
14250
|
},
|
|
13743
14251
|
async archiveProduct(productId) {
|
|
@@ -13753,19 +14261,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13753
14261
|
await client.update(products).set({
|
|
13754
14262
|
status: 0,
|
|
13755
14263
|
name: `${product.name} (Archived)`
|
|
13756
|
-
}).where((0,
|
|
14264
|
+
}).where((0, import_drizzle_orm46.eq)(products.id, productId));
|
|
13757
14265
|
await client.update(prices).set({
|
|
13758
14266
|
status: 0,
|
|
13759
14267
|
nickname: `${product.name} (Archived)`
|
|
13760
|
-
}).where((0,
|
|
14268
|
+
}).where((0, import_drizzle_orm46.eq)(prices.productId, productId));
|
|
13761
14269
|
await client.update(merchantProduct).set({
|
|
13762
14270
|
status: 0
|
|
13763
|
-
}).where((0,
|
|
14271
|
+
}).where((0, import_drizzle_orm46.eq)(merchantProduct.productId, productId));
|
|
13764
14272
|
await client.update(merchantPrice).set({
|
|
13765
14273
|
status: 0
|
|
13766
|
-
}).where((0,
|
|
14274
|
+
}).where((0, import_drizzle_orm46.eq)(merchantPrice.priceId, product.price.id));
|
|
13767
14275
|
const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
13768
|
-
where: (0,
|
|
14276
|
+
where: (0, import_drizzle_orm46.eq)(merchantProduct.productId, productId)
|
|
13769
14277
|
}));
|
|
13770
14278
|
if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
|
|
13771
14279
|
throw new Error(`Merchant product not found for id (${productId})`);
|
|
@@ -13774,7 +14282,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13774
14282
|
active: false
|
|
13775
14283
|
});
|
|
13776
14284
|
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
13777
|
-
where: (0,
|
|
14285
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantPrice.priceId, product.price.id), (0, import_drizzle_orm46.eq)(merchantPrice.status, 1))
|
|
13778
14286
|
}));
|
|
13779
14287
|
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
13780
14288
|
throw new Error(`Merchant price not found for id (${productId})`);
|
|
@@ -13858,12 +14366,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13858
14366
|
if (currentMerchantPrice) {
|
|
13859
14367
|
await client.update(merchantPrice).set({
|
|
13860
14368
|
status: 0
|
|
13861
|
-
}).where((0,
|
|
14369
|
+
}).where((0, import_drizzle_orm46.eq)(merchantPrice.id, currentMerchantPrice.id));
|
|
13862
14370
|
}
|
|
13863
14371
|
await client.update(prices).set({
|
|
13864
14372
|
unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
|
|
13865
14373
|
nickname: input.name
|
|
13866
|
-
}).where((0,
|
|
14374
|
+
}).where((0, import_drizzle_orm46.eq)(prices.id, currentProduct.price.id));
|
|
13867
14375
|
if (currentStripePrice) {
|
|
13868
14376
|
await paymentProvider.updatePrice(currentStripePrice.id, {
|
|
13869
14377
|
active: false
|
|
@@ -13893,7 +14401,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13893
14401
|
}
|
|
13894
14402
|
},
|
|
13895
14403
|
type: input.type
|
|
13896
|
-
}).where((0,
|
|
14404
|
+
}).where((0, import_drizzle_orm46.eq)(products.id, currentProduct.id));
|
|
13897
14405
|
return adapter.getProduct(currentProduct.id);
|
|
13898
14406
|
},
|
|
13899
14407
|
async createProduct(input) {
|
|
@@ -13987,7 +14495,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
13987
14495
|
}
|
|
13988
14496
|
try {
|
|
13989
14497
|
const productData = await client.query.products.findFirst({
|
|
13990
|
-
where: (0,
|
|
14498
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(import_drizzle_orm46.sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), (0, import_drizzle_orm46.eq)(products.id, productSlugOrId))),
|
|
13991
14499
|
with: {
|
|
13992
14500
|
price: true,
|
|
13993
14501
|
...withResources && {
|
|
@@ -14024,20 +14532,20 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14024
14532
|
},
|
|
14025
14533
|
async getProductResources(productId) {
|
|
14026
14534
|
const contentResourceProductsForProduct = external_exports.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
|
|
14027
|
-
where: (0,
|
|
14535
|
+
where: (0, import_drizzle_orm46.eq)(contentResourceProduct.productId, productId)
|
|
14028
14536
|
}));
|
|
14029
14537
|
if (!contentResourceProductsForProduct) {
|
|
14030
14538
|
return null;
|
|
14031
14539
|
} else {
|
|
14032
14540
|
const contentResources = external_exports.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
|
|
14033
|
-
where: (0,
|
|
14541
|
+
where: (0, import_drizzle_orm46.inArray)(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
|
|
14034
14542
|
}));
|
|
14035
14543
|
return contentResources;
|
|
14036
14544
|
}
|
|
14037
14545
|
},
|
|
14038
14546
|
async getPurchaseCountForProduct(productId) {
|
|
14039
14547
|
return await client.query.purchases.findMany({
|
|
14040
|
-
where: (0,
|
|
14548
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.productId, productId), (0, import_drizzle_orm46.inArray)(purchaseTable.status, [
|
|
14041
14549
|
"Valid",
|
|
14042
14550
|
"Restricted"
|
|
14043
14551
|
]))
|
|
@@ -14045,7 +14553,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14045
14553
|
},
|
|
14046
14554
|
async getPurchase(purchaseId) {
|
|
14047
14555
|
const purchase = await client.query.purchases.findFirst({
|
|
14048
|
-
where: (0,
|
|
14556
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.id, purchaseId)
|
|
14049
14557
|
});
|
|
14050
14558
|
return purchase ? purchaseSchema.parse(purchase) : null;
|
|
14051
14559
|
},
|
|
@@ -14063,7 +14571,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14063
14571
|
stripeChargeId
|
|
14064
14572
|
});
|
|
14065
14573
|
const chargeForPurchase = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
14066
|
-
where: (0,
|
|
14574
|
+
where: (0, import_drizzle_orm46.eq)(merchantCharge.identifier, stripeChargeId)
|
|
14067
14575
|
}) || null);
|
|
14068
14576
|
if (!chargeForPurchase) {
|
|
14069
14577
|
logger2.debug("getPurchaseForStripeCharge: no matching charge", {
|
|
@@ -14073,7 +14581,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14073
14581
|
return null;
|
|
14074
14582
|
}
|
|
14075
14583
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
14076
|
-
where: (0,
|
|
14584
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.merchantChargeId, chargeForPurchase.id),
|
|
14077
14585
|
with: {
|
|
14078
14586
|
user: true,
|
|
14079
14587
|
product: true,
|
|
@@ -14090,7 +14598,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14090
14598
|
checkoutSessionId
|
|
14091
14599
|
});
|
|
14092
14600
|
const session = await client.query.merchantSession.findFirst({
|
|
14093
|
-
where: (0,
|
|
14601
|
+
where: (0, import_drizzle_orm46.eq)(merchantSession.identifier, checkoutSessionId)
|
|
14094
14602
|
});
|
|
14095
14603
|
if (!session) {
|
|
14096
14604
|
logger2.debug("getPurchaseByCheckoutSessionId: no matching session", {
|
|
@@ -14099,7 +14607,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14099
14607
|
return null;
|
|
14100
14608
|
}
|
|
14101
14609
|
const purchase = purchaseSchema.safeParse(await client.query.purchases.findFirst({
|
|
14102
|
-
where: (0,
|
|
14610
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.merchantSessionId, String(session.id)),
|
|
14103
14611
|
with: {
|
|
14104
14612
|
user: true,
|
|
14105
14613
|
product: true,
|
|
@@ -14113,7 +14621,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14113
14621
|
},
|
|
14114
14622
|
async getPurchaseUserTransferById(options) {
|
|
14115
14623
|
const purchaseTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
14116
|
-
where: (0,
|
|
14624
|
+
where: (0, import_drizzle_orm46.eq)(purchaseUserTransfer.id, options.id),
|
|
14117
14625
|
with: {
|
|
14118
14626
|
sourceUser: true,
|
|
14119
14627
|
targetUser: true,
|
|
@@ -14129,7 +14637,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14129
14637
|
},
|
|
14130
14638
|
async getPurchaseWithUser(purchaseId) {
|
|
14131
14639
|
const purchaseData = await client.query.purchases.findFirst({
|
|
14132
|
-
where: (0,
|
|
14640
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.id, purchaseId),
|
|
14133
14641
|
with: {
|
|
14134
14642
|
user: true
|
|
14135
14643
|
}
|
|
@@ -14156,13 +14664,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14156
14664
|
"Restricted"
|
|
14157
14665
|
];
|
|
14158
14666
|
const userPurchases = await client.query.purchases.findMany({
|
|
14159
|
-
where: (0,
|
|
14667
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm46.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
14160
14668
|
with: {
|
|
14161
14669
|
user: true,
|
|
14162
14670
|
product: true,
|
|
14163
14671
|
bulkCoupon: true
|
|
14164
14672
|
},
|
|
14165
|
-
orderBy: (0,
|
|
14673
|
+
orderBy: (0, import_drizzle_orm46.asc)(purchaseTable.createdAt)
|
|
14166
14674
|
});
|
|
14167
14675
|
const parsedPurchases = external_exports.array(purchaseSchema).safeParse(userPurchases);
|
|
14168
14676
|
if (!parsedPurchases.success) {
|
|
@@ -14181,22 +14689,22 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14181
14689
|
return [];
|
|
14182
14690
|
}
|
|
14183
14691
|
const conditions = [
|
|
14184
|
-
(0,
|
|
14692
|
+
(0, import_drizzle_orm46.eq)(entitlementTable.userId, userId)
|
|
14185
14693
|
];
|
|
14186
14694
|
if (sourceType) {
|
|
14187
|
-
conditions.push((0,
|
|
14695
|
+
conditions.push((0, import_drizzle_orm46.eq)(entitlementTable.sourceType, sourceType));
|
|
14188
14696
|
}
|
|
14189
14697
|
if (entitlementType) {
|
|
14190
|
-
conditions.push((0,
|
|
14698
|
+
conditions.push((0, import_drizzle_orm46.eq)(entitlementTable.entitlementType, entitlementType));
|
|
14191
14699
|
}
|
|
14192
|
-
conditions.push((0,
|
|
14193
|
-
const expiresCondition = (0,
|
|
14700
|
+
conditions.push((0, import_drizzle_orm46.isNull)(entitlementTable.deletedAt));
|
|
14701
|
+
const expiresCondition = (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.isNull)(entitlementTable.expiresAt), (0, import_drizzle_orm46.gte)(entitlementTable.expiresAt, import_drizzle_orm46.sql`CURRENT_TIMESTAMP`));
|
|
14194
14702
|
if (expiresCondition) {
|
|
14195
14703
|
conditions.push(expiresCondition);
|
|
14196
14704
|
}
|
|
14197
14705
|
const userEntitlements = await client.query.entitlements.findMany({
|
|
14198
|
-
where: conditions.length > 0 ? (0,
|
|
14199
|
-
orderBy: (0,
|
|
14706
|
+
where: conditions.length > 0 ? (0, import_drizzle_orm46.and)(...conditions) : void 0,
|
|
14707
|
+
orderBy: (0, import_drizzle_orm46.asc)(entitlementTable.createdAt)
|
|
14200
14708
|
});
|
|
14201
14709
|
const parsedEntitlements = external_exports.array(entitlementSchema).safeParse(userEntitlements);
|
|
14202
14710
|
if (!parsedEntitlements.success) {
|
|
@@ -14213,7 +14721,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14213
14721
|
},
|
|
14214
14722
|
async getEntitlementTypeByName(name) {
|
|
14215
14723
|
const entitlementType = await client.query.entitlementTypes.findFirst({
|
|
14216
|
-
where: (0,
|
|
14724
|
+
where: (0, import_drizzle_orm46.eq)(entitlementTypes.name, name)
|
|
14217
14725
|
});
|
|
14218
14726
|
if (!entitlementType) {
|
|
14219
14727
|
return null;
|
|
@@ -14230,18 +14738,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14230
14738
|
"Restricted"
|
|
14231
14739
|
];
|
|
14232
14740
|
const userPurchases = await client.query.purchases.findMany({
|
|
14233
|
-
where: (0,
|
|
14741
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm46.inArray)(purchaseTable.status, visiblePurchaseStates)),
|
|
14234
14742
|
with: {
|
|
14235
14743
|
user: true,
|
|
14236
14744
|
product: true,
|
|
14237
14745
|
bulkCoupon: true
|
|
14238
14746
|
},
|
|
14239
|
-
orderBy: (0,
|
|
14747
|
+
orderBy: (0, import_drizzle_orm46.asc)(purchaseTable.createdAt)
|
|
14240
14748
|
});
|
|
14241
14749
|
const parsedPurchases = external_exports.array(purchaseSchema).safeParse(userPurchases);
|
|
14242
14750
|
const allPurchases = parsedPurchases.success ? parsedPurchases.data : [];
|
|
14243
14751
|
const thePurchase = await client.query.purchases.findFirst({
|
|
14244
|
-
where: (0,
|
|
14752
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.id, purchaseId), (0, import_drizzle_orm46.eq)(purchaseTable.userId, userId)),
|
|
14245
14753
|
with: {
|
|
14246
14754
|
user: true,
|
|
14247
14755
|
product: true,
|
|
@@ -14266,7 +14774,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14266
14774
|
let availableUpgrades = [];
|
|
14267
14775
|
if (purchaseCanUpgrade) {
|
|
14268
14776
|
availableUpgrades = await client.query.upgradableProducts.findMany({
|
|
14269
|
-
where: (0,
|
|
14777
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(upgradableProducts.upgradableFromId, parsedPurchase.data.product?.id), (0, import_drizzle_orm46.not)((0, import_drizzle_orm46.inArray)(upgradableProducts.upgradableToId, allPurchases.map((p) => p.product?.id)))),
|
|
14270
14778
|
with: {
|
|
14271
14779
|
upgradableTo: true,
|
|
14272
14780
|
upgradableFrom: true
|
|
@@ -14274,10 +14782,10 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14274
14782
|
});
|
|
14275
14783
|
}
|
|
14276
14784
|
const existingPurchase = purchaseSchema.optional().nullable().parse(await client.query.purchases.findFirst({
|
|
14277
|
-
where: (0,
|
|
14785
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm46.eq)(purchaseTable.productId, parsedPurchase.data.productId), (0, import_drizzle_orm46.inArray)(purchaseTable.status, [
|
|
14278
14786
|
"Valid",
|
|
14279
14787
|
"Restricted"
|
|
14280
|
-
]), (0,
|
|
14788
|
+
]), (0, import_drizzle_orm46.isNull)(purchaseTable.bulkCouponId), (0, import_drizzle_orm46.not)((0, import_drizzle_orm46.eq)(purchaseTable.id, parsedPurchase.data.id))),
|
|
14281
14789
|
with: {
|
|
14282
14790
|
user: true,
|
|
14283
14791
|
product: true,
|
|
@@ -14292,7 +14800,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14292
14800
|
},
|
|
14293
14801
|
async getUserWithPurchasersByEmail(email) {
|
|
14294
14802
|
const user = await client.query.users.findFirst({
|
|
14295
|
-
where: (0,
|
|
14803
|
+
where: (0, import_drizzle_orm46.eq)(users.email, email.trim().toLowerCase()),
|
|
14296
14804
|
with: {
|
|
14297
14805
|
// merchantCustomer: true,
|
|
14298
14806
|
roles: {
|
|
@@ -14319,7 +14827,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14319
14827
|
},
|
|
14320
14828
|
async getUserById(userId) {
|
|
14321
14829
|
const user = await client.query.users.findFirst({
|
|
14322
|
-
where: (0,
|
|
14830
|
+
where: (0, import_drizzle_orm46.eq)(users.id, userId),
|
|
14323
14831
|
with: {
|
|
14324
14832
|
roles: {
|
|
14325
14833
|
with: {
|
|
@@ -14341,13 +14849,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14341
14849
|
if (userId === void 0)
|
|
14342
14850
|
return [];
|
|
14343
14851
|
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
14344
|
-
where: (0,
|
|
14852
|
+
where: (0, import_drizzle_orm46.eq)(upgradableProducts.upgradableToId, bundleId)
|
|
14345
14853
|
});
|
|
14346
14854
|
const upgradableFrom = external_exports.array(external_exports.string()).parse(canUpgradeProducts.map((product) => {
|
|
14347
14855
|
return product.upgradableFromId;
|
|
14348
14856
|
}));
|
|
14349
14857
|
const purchases = await client.query.purchases.findMany({
|
|
14350
|
-
where: (0,
|
|
14858
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(purchaseTable.userId, userId), (0, import_drizzle_orm46.inArray)(purchaseTable.productId, upgradableFrom))
|
|
14351
14859
|
});
|
|
14352
14860
|
const productsPurchased = external_exports.array(external_exports.string()).parse(purchases.map((purchase) => {
|
|
14353
14861
|
return purchase.productId;
|
|
@@ -14355,7 +14863,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14355
14863
|
if (productsPurchased.length === 0)
|
|
14356
14864
|
return [];
|
|
14357
14865
|
const foundPrices = await client.query.prices.findMany({
|
|
14358
|
-
where: (0,
|
|
14866
|
+
where: (0, import_drizzle_orm46.inArray)(prices.productId, productsPurchased)
|
|
14359
14867
|
});
|
|
14360
14868
|
return external_exports.array(priceSchema).parse(foundPrices);
|
|
14361
14869
|
},
|
|
@@ -14364,14 +14872,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14364
14872
|
throw new Error("No lessonId provided");
|
|
14365
14873
|
}
|
|
14366
14874
|
let lessonProgress = await client.query.resourceProgress.findFirst({
|
|
14367
|
-
where: (0,
|
|
14875
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm46.eq)(resourceProgress.resourceId, options.lessonId))
|
|
14368
14876
|
});
|
|
14369
14877
|
const now = /* @__PURE__ */ new Date();
|
|
14370
14878
|
if (lessonProgress) {
|
|
14371
14879
|
await client.update(resourceProgress).set({
|
|
14372
14880
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
14373
14881
|
updatedAt: now
|
|
14374
|
-
}).where((0,
|
|
14882
|
+
}).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm46.eq)(resourceProgress.resourceId, options.lessonId)));
|
|
14375
14883
|
} else {
|
|
14376
14884
|
await client.insert(resourceProgress).values({
|
|
14377
14885
|
userId: options.userId,
|
|
@@ -14381,7 +14889,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14381
14889
|
});
|
|
14382
14890
|
}
|
|
14383
14891
|
lessonProgress = await client.query.resourceProgress.findFirst({
|
|
14384
|
-
where: (0,
|
|
14892
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(resourceProgress.userId, options.userId), (0, import_drizzle_orm46.eq)(resourceProgress.resourceId, options.lessonId))
|
|
14385
14893
|
});
|
|
14386
14894
|
const parsedLessonProgress = resourceProgressSchema.safeParse(lessonProgress);
|
|
14387
14895
|
if (!parsedLessonProgress.success) {
|
|
@@ -14407,7 +14915,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14407
14915
|
throw new Error("No purchase found");
|
|
14408
14916
|
await trx.update(purchaseTable).set({
|
|
14409
14917
|
userId: targetUserId
|
|
14410
|
-
}).where((0,
|
|
14918
|
+
}).where((0, import_drizzle_orm46.eq)(purchaseTable.id, purchase.id));
|
|
14411
14919
|
await trx.insert(purchaseUserTransfer).values({
|
|
14412
14920
|
id: transferId,
|
|
14413
14921
|
purchaseId: purchase.id,
|
|
@@ -14422,21 +14930,21 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14422
14930
|
if (paymentProvider && purchase.merchantChargeId) {
|
|
14423
14931
|
await trx.update(merchantCharge).set({
|
|
14424
14932
|
userId: targetUserId
|
|
14425
|
-
}).where((0,
|
|
14933
|
+
}).where((0, import_drizzle_orm46.eq)(merchantCharge.id, purchase.merchantChargeId));
|
|
14426
14934
|
const updatedMerchantCharge = await adapter.getMerchantCharge(purchase.merchantChargeId);
|
|
14427
14935
|
if (!updatedMerchantCharge)
|
|
14428
14936
|
throw new Error("No merchant charge found");
|
|
14429
14937
|
await trx.update(merchantCustomer).set({
|
|
14430
14938
|
userId: targetUserId
|
|
14431
|
-
}).where((0,
|
|
14939
|
+
}).where((0, import_drizzle_orm46.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId));
|
|
14432
14940
|
const updatedMerchantCustomer = merchantCustomerSchema.parse(await client.query.merchantCustomer.findFirst({
|
|
14433
|
-
where: (0,
|
|
14941
|
+
where: (0, import_drizzle_orm46.eq)(merchantCustomer.id, updatedMerchantCharge.merchantCustomerId)
|
|
14434
14942
|
}));
|
|
14435
14943
|
const targetUser = userSchema.parse(await client.query.users.findFirst({
|
|
14436
|
-
where: (0,
|
|
14944
|
+
where: (0, import_drizzle_orm46.eq)(users.id, targetUserId)
|
|
14437
14945
|
}));
|
|
14438
14946
|
const sourceUser = userSchema.parse(await client.query.users.findFirst({
|
|
14439
|
-
where: (0,
|
|
14947
|
+
where: (0, import_drizzle_orm46.eq)(users.id, sourceUserId)
|
|
14440
14948
|
}));
|
|
14441
14949
|
await paymentProvider.updateCustomer(updatedMerchantCustomer.identifier, {
|
|
14442
14950
|
email: targetUser.email,
|
|
@@ -14463,7 +14971,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14463
14971
|
status
|
|
14464
14972
|
});
|
|
14465
14973
|
const merchantChargeForPurchase = await client.query.merchantCharge.findFirst({
|
|
14466
|
-
where: (0,
|
|
14974
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(merchantCharge.identifier, chargeId), (0, import_drizzle_orm46.eq)(merchantCharge.id, chargeId))
|
|
14467
14975
|
});
|
|
14468
14976
|
logger2.debug("adapter.purchase.status_update.charge_resolved", {
|
|
14469
14977
|
chargeId,
|
|
@@ -14474,15 +14982,15 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14474
14982
|
if (!parsedMerchantChargeForPurchase)
|
|
14475
14983
|
throw new Error(`no-charge-found-for-purchase ${chargeId}`);
|
|
14476
14984
|
const purchase = await client.query.purchases.findFirst({
|
|
14477
|
-
where: (0,
|
|
14985
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.merchantChargeId, parsedMerchantChargeForPurchase.id)
|
|
14478
14986
|
});
|
|
14479
14987
|
const parsedPurchase = purchaseSchema.nullable().parse(purchase);
|
|
14480
14988
|
if (parsedPurchase) {
|
|
14481
14989
|
await client.update(purchaseTable).set({
|
|
14482
14990
|
status
|
|
14483
|
-
}).where((0,
|
|
14991
|
+
}).where((0, import_drizzle_orm46.eq)(purchaseTable.id, parsedPurchase.id));
|
|
14484
14992
|
const newPurchase = await client.query.purchases.findFirst({
|
|
14485
|
-
where: (0,
|
|
14993
|
+
where: (0, import_drizzle_orm46.eq)(purchaseTable.id, parsedPurchase.id)
|
|
14486
14994
|
});
|
|
14487
14995
|
return purchaseSchema.optional().parse(newPurchase);
|
|
14488
14996
|
} else {
|
|
@@ -14500,28 +15008,32 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14500
15008
|
async updatePurchaseUserTransferTransferState(options) {
|
|
14501
15009
|
await client.update(purchaseUserTransfer).set({
|
|
14502
15010
|
transferState: options.transferState
|
|
14503
|
-
}).where((0,
|
|
15011
|
+
}).where((0, import_drizzle_orm46.eq)(purchaseUserTransfer.id, options.id));
|
|
14504
15012
|
const purchaseUserTransferData = await client.query.purchaseUserTransfer.findFirst({
|
|
14505
|
-
where: (0,
|
|
15013
|
+
where: (0, import_drizzle_orm46.eq)(purchaseUserTransfer.id, options.id)
|
|
14506
15014
|
}) || null;
|
|
14507
15015
|
return purchaseUserTransferSchema.nullable().parse(purchaseUserTransferData);
|
|
14508
15016
|
},
|
|
14509
15017
|
addResourceToResource: async function(options) {
|
|
14510
15018
|
const { parentResourceId, childResourceId } = options;
|
|
14511
15019
|
const parentResourceData = await client.query.contentResource.findFirst({
|
|
14512
|
-
where: (0,
|
|
15020
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(import_drizzle_orm46.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm46.eq)(contentResource.id, parentResourceId)),
|
|
14513
15021
|
with: {
|
|
14514
15022
|
resources: true
|
|
14515
15023
|
}
|
|
14516
15024
|
});
|
|
14517
|
-
const
|
|
15025
|
+
const parsedParentResource = ContentResourceSchema.safeParse(parentResourceData);
|
|
15026
|
+
if (!parsedParentResource.success) {
|
|
15027
|
+
return null;
|
|
15028
|
+
}
|
|
15029
|
+
const parentResource = parsedParentResource.data;
|
|
14518
15030
|
await client.insert(contentResourceResource).values({
|
|
14519
15031
|
resourceOfId: parentResource.id,
|
|
14520
15032
|
resourceId: childResourceId,
|
|
14521
15033
|
position: parentResource.resources?.length || 0
|
|
14522
15034
|
});
|
|
14523
|
-
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
14524
|
-
where: (0,
|
|
15035
|
+
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
15036
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(contentResourceResource.resourceOfId, parentResource.id), (0, import_drizzle_orm46.eq)(contentResourceResource.resourceId, childResourceId)),
|
|
14525
15037
|
with: {
|
|
14526
15038
|
resource: true
|
|
14527
15039
|
}
|
|
@@ -14534,29 +15046,40 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14534
15046
|
},
|
|
14535
15047
|
async removeResourceFromResource(options) {
|
|
14536
15048
|
const { childResourceId, parentResourceId } = options;
|
|
15049
|
+
const parentResourceData = await client.query.contentResource.findFirst({
|
|
15050
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(import_drizzle_orm46.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), (0, import_drizzle_orm46.eq)(contentResource.id, parentResourceId))
|
|
15051
|
+
});
|
|
15052
|
+
const parsedParentResource = ContentResourceSchema.safeParse(parentResourceData);
|
|
15053
|
+
if (!parsedParentResource.success) {
|
|
15054
|
+
return null;
|
|
15055
|
+
}
|
|
15056
|
+
const parentResource = parsedParentResource.data;
|
|
14537
15057
|
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
14538
|
-
where: (0,
|
|
15058
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(contentResourceResource.resourceOfId, parentResource.id), (0, import_drizzle_orm46.eq)(contentResourceResource.resourceId, childResourceId)),
|
|
15059
|
+
with: {
|
|
15060
|
+
resource: true
|
|
15061
|
+
}
|
|
14539
15062
|
});
|
|
14540
15063
|
const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
|
|
14541
15064
|
if (!parsedResourceJoin.success) {
|
|
14542
15065
|
return null;
|
|
14543
15066
|
}
|
|
14544
|
-
await client.delete(contentResourceResource).where((0,
|
|
15067
|
+
await client.delete(contentResourceResource).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(contentResourceResource.resourceOfId, parentResource.id), (0, import_drizzle_orm46.eq)(contentResourceResource.resourceId, childResourceId)));
|
|
14545
15068
|
return parsedResourceJoin.data.resource;
|
|
14546
15069
|
},
|
|
14547
15070
|
async updateContentResourceFields(options) {
|
|
14548
15071
|
if (!options.id) {
|
|
14549
15072
|
throw new Error("No content resource id.");
|
|
14550
15073
|
}
|
|
14551
|
-
const currentResource = await client.select().from(contentResource).where((0,
|
|
15074
|
+
const currentResource = await client.select().from(contentResource).where((0, import_drizzle_orm46.eq)(contentResource.id, options.id)).then((res) => res[0]);
|
|
14552
15075
|
await client.update(contentResource).set({
|
|
14553
15076
|
fields: {
|
|
14554
15077
|
...currentResource.fields,
|
|
14555
15078
|
...options.fields
|
|
14556
15079
|
}
|
|
14557
|
-
}).where((0,
|
|
15080
|
+
}).where((0, import_drizzle_orm46.eq)(contentResource.id, options.id));
|
|
14558
15081
|
const resource = await client.query.contentResource.findFirst({
|
|
14559
|
-
where: (0,
|
|
15082
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, options.id),
|
|
14560
15083
|
with: {
|
|
14561
15084
|
resources: {
|
|
14562
15085
|
with: {
|
|
@@ -14566,12 +15089,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14566
15089
|
with: {
|
|
14567
15090
|
resource: true
|
|
14568
15091
|
},
|
|
14569
|
-
orderBy: (0,
|
|
15092
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14570
15093
|
}
|
|
14571
15094
|
}
|
|
14572
15095
|
}
|
|
14573
15096
|
},
|
|
14574
|
-
orderBy: (0,
|
|
15097
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14575
15098
|
}
|
|
14576
15099
|
}
|
|
14577
15100
|
});
|
|
@@ -14589,7 +15112,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14589
15112
|
if (!id) {
|
|
14590
15113
|
return null;
|
|
14591
15114
|
}
|
|
14592
|
-
const query =
|
|
15115
|
+
const query = import_drizzle_orm46.sql`
|
|
14593
15116
|
SELECT
|
|
14594
15117
|
id as id,
|
|
14595
15118
|
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
@@ -14598,7 +15121,8 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14598
15121
|
JSON_EXTRACT (${contentResource.fields}, "$.duration") AS duration,
|
|
14599
15122
|
JSON_EXTRACT (${contentResource.fields}, "$.muxPlaybackId") AS muxPlaybackId,
|
|
14600
15123
|
JSON_EXTRACT (${contentResource.fields}, "$.muxAssetId") AS muxAssetId,
|
|
14601
|
-
JSON_EXTRACT (${contentResource.fields}, "$.transcript") AS transcript
|
|
15124
|
+
JSON_EXTRACT (${contentResource.fields}, "$.transcript") AS transcript,
|
|
15125
|
+
JSON_EXTRACT (${contentResource.fields}, "$.chapters") AS chapters
|
|
14602
15126
|
FROM
|
|
14603
15127
|
${contentResource}
|
|
14604
15128
|
WHERE
|
|
@@ -14621,7 +15145,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14621
15145
|
if (!videoResourceId) {
|
|
14622
15146
|
return null;
|
|
14623
15147
|
}
|
|
14624
|
-
const results = await client.select().from(contentResource).innerJoin(contentResourceResource, (0,
|
|
15148
|
+
const results = await client.select().from(contentResource).innerJoin(contentResourceResource, (0, import_drizzle_orm46.eq)(contentResourceResource.resourceOfId, contentResource.id)).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(contentResourceResource.resourceId, videoResourceId), (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(contentResource.type, "post"), (0, import_drizzle_orm46.eq)(contentResource.type, "lesson")))).limit(1);
|
|
14625
15149
|
if (!results || results.length === 0) {
|
|
14626
15150
|
return null;
|
|
14627
15151
|
}
|
|
@@ -14630,7 +15154,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14630
15154
|
return null;
|
|
14631
15155
|
}
|
|
14632
15156
|
const fullResource = await client.query.contentResource.findFirst({
|
|
14633
|
-
where: (0,
|
|
15157
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, resourceData.id),
|
|
14634
15158
|
with: {
|
|
14635
15159
|
resources: true
|
|
14636
15160
|
}
|
|
@@ -14647,7 +15171,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14647
15171
|
id
|
|
14648
15172
|
});
|
|
14649
15173
|
const resource = await client.query.contentResource.findFirst({
|
|
14650
|
-
where: (0,
|
|
15174
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, id),
|
|
14651
15175
|
with: {
|
|
14652
15176
|
resources: {
|
|
14653
15177
|
with: {
|
|
@@ -14657,12 +15181,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14657
15181
|
with: {
|
|
14658
15182
|
resource: true
|
|
14659
15183
|
},
|
|
14660
|
-
orderBy: (0,
|
|
15184
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14661
15185
|
}
|
|
14662
15186
|
}
|
|
14663
15187
|
}
|
|
14664
15188
|
},
|
|
14665
|
-
orderBy: (0,
|
|
15189
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14666
15190
|
}
|
|
14667
15191
|
}
|
|
14668
15192
|
});
|
|
@@ -14679,7 +15203,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14679
15203
|
},
|
|
14680
15204
|
async getContentResource(data) {
|
|
14681
15205
|
const resource = await client.query.contentResource.findFirst({
|
|
14682
|
-
where: (0,
|
|
15206
|
+
where: (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(contentResource.id, data), (0, import_drizzle_orm46.eq)(import_drizzle_orm46.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
|
|
14683
15207
|
with: {
|
|
14684
15208
|
resources: {
|
|
14685
15209
|
with: {
|
|
@@ -14697,12 +15221,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14697
15221
|
}
|
|
14698
15222
|
}
|
|
14699
15223
|
},
|
|
14700
|
-
orderBy: (0,
|
|
15224
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14701
15225
|
}
|
|
14702
15226
|
}
|
|
14703
15227
|
}
|
|
14704
15228
|
},
|
|
14705
|
-
orderBy: (0,
|
|
15229
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14706
15230
|
}
|
|
14707
15231
|
}
|
|
14708
15232
|
});
|
|
@@ -14720,14 +15244,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14720
15244
|
async getEvent(eventIdOrSlug, options) {
|
|
14721
15245
|
const { withResources = false, withTags = false, withProducts = false, withPricing = false } = options || {};
|
|
14722
15246
|
const eventQuery = await client.query.contentResource.findFirst({
|
|
14723
|
-
where: (0,
|
|
15247
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(contentResource.type, "event"), (0, import_drizzle_orm46.eq)(contentResource.type, "event-series")), (0, import_drizzle_orm46.or)((0, import_drizzle_orm46.eq)(contentResource.id, eventIdOrSlug), (0, import_drizzle_orm46.eq)(import_drizzle_orm46.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, eventIdOrSlug))),
|
|
14724
15248
|
with: {
|
|
14725
15249
|
...withResources && {
|
|
14726
15250
|
resources: {
|
|
14727
15251
|
with: {
|
|
14728
15252
|
resource: true
|
|
14729
15253
|
},
|
|
14730
|
-
orderBy: (0,
|
|
15254
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14731
15255
|
}
|
|
14732
15256
|
},
|
|
14733
15257
|
...withTags && {
|
|
@@ -14735,7 +15259,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14735
15259
|
with: {
|
|
14736
15260
|
tag: true
|
|
14737
15261
|
},
|
|
14738
|
-
orderBy: (0,
|
|
15262
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceTag.position)
|
|
14739
15263
|
}
|
|
14740
15264
|
},
|
|
14741
15265
|
...withProducts && {
|
|
@@ -14778,7 +15302,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14778
15302
|
}
|
|
14779
15303
|
});
|
|
14780
15304
|
const resourceProduct = await client.query.contentResourceProduct.findFirst({
|
|
14781
|
-
where: (0,
|
|
15305
|
+
where: (0, import_drizzle_orm46.eq)(contentResourceProduct.resourceId, resource.id),
|
|
14782
15306
|
with: {
|
|
14783
15307
|
resource: true,
|
|
14784
15308
|
product: true
|
|
@@ -14940,7 +15464,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14940
15464
|
};
|
|
14941
15465
|
await tx.insert(contentResource).values(newEventSeries);
|
|
14942
15466
|
const eventSeriesResource = await tx.query.contentResource.findFirst({
|
|
14943
|
-
where: (0,
|
|
15467
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, eventSeriesResourceId),
|
|
14944
15468
|
with: {
|
|
14945
15469
|
resources: {
|
|
14946
15470
|
with: {
|
|
@@ -14950,18 +15474,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
14950
15474
|
with: {
|
|
14951
15475
|
resource: true
|
|
14952
15476
|
},
|
|
14953
|
-
orderBy: (0,
|
|
15477
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14954
15478
|
}
|
|
14955
15479
|
}
|
|
14956
15480
|
}
|
|
14957
15481
|
},
|
|
14958
|
-
orderBy: (0,
|
|
15482
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
14959
15483
|
},
|
|
14960
15484
|
tags: {
|
|
14961
15485
|
with: {
|
|
14962
15486
|
tag: true
|
|
14963
15487
|
},
|
|
14964
|
-
orderBy: (0,
|
|
15488
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceTag.position)
|
|
14965
15489
|
},
|
|
14966
15490
|
resourceProducts: {
|
|
14967
15491
|
with: {
|
|
@@ -15014,7 +15538,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15014
15538
|
};
|
|
15015
15539
|
await tx.insert(contentResource).values(newChildEvent);
|
|
15016
15540
|
const childEventResource = await tx.query.contentResource.findFirst({
|
|
15017
|
-
where: (0,
|
|
15541
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, childEventResourceId),
|
|
15018
15542
|
with: {
|
|
15019
15543
|
resources: {
|
|
15020
15544
|
with: {
|
|
@@ -15024,18 +15548,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15024
15548
|
with: {
|
|
15025
15549
|
resource: true
|
|
15026
15550
|
},
|
|
15027
|
-
orderBy: (0,
|
|
15551
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
15028
15552
|
}
|
|
15029
15553
|
}
|
|
15030
15554
|
}
|
|
15031
15555
|
},
|
|
15032
|
-
orderBy: (0,
|
|
15556
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
15033
15557
|
},
|
|
15034
15558
|
tags: {
|
|
15035
15559
|
with: {
|
|
15036
15560
|
tag: true
|
|
15037
15561
|
},
|
|
15038
|
-
orderBy: (0,
|
|
15562
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceTag.position)
|
|
15039
15563
|
},
|
|
15040
15564
|
resourceProducts: {
|
|
15041
15565
|
with: {
|
|
@@ -15162,13 +15686,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15162
15686
|
}
|
|
15163
15687
|
});
|
|
15164
15688
|
const cohort2 = await tx.query.contentResource.findFirst({
|
|
15165
|
-
where: (0,
|
|
15689
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, cohortId),
|
|
15166
15690
|
with: {
|
|
15167
15691
|
resources: {
|
|
15168
15692
|
with: {
|
|
15169
15693
|
resource: true
|
|
15170
15694
|
},
|
|
15171
|
-
orderBy: (0,
|
|
15695
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
15172
15696
|
}
|
|
15173
15697
|
}
|
|
15174
15698
|
});
|
|
@@ -15281,7 +15805,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15281
15805
|
}
|
|
15282
15806
|
});
|
|
15283
15807
|
const workshop = await tx.query.contentResource.findFirst({
|
|
15284
|
-
where: (0,
|
|
15808
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, workshopId),
|
|
15285
15809
|
with: {
|
|
15286
15810
|
resources: {
|
|
15287
15811
|
with: {
|
|
@@ -15291,12 +15815,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15291
15815
|
with: {
|
|
15292
15816
|
resource: true
|
|
15293
15817
|
},
|
|
15294
|
-
orderBy: (0,
|
|
15818
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
15295
15819
|
}
|
|
15296
15820
|
}
|
|
15297
15821
|
}
|
|
15298
15822
|
},
|
|
15299
|
-
orderBy: (0,
|
|
15823
|
+
orderBy: (0, import_drizzle_orm46.asc)(contentResourceResource.position)
|
|
15300
15824
|
}
|
|
15301
15825
|
}
|
|
15302
15826
|
});
|
|
@@ -15340,7 +15864,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15340
15864
|
position
|
|
15341
15865
|
});
|
|
15342
15866
|
const section = await tx.query.contentResource.findFirst({
|
|
15343
|
-
where: (0,
|
|
15867
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, sectionId)
|
|
15344
15868
|
});
|
|
15345
15869
|
if (section) {
|
|
15346
15870
|
createdSections.push(section);
|
|
@@ -15374,7 +15898,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15374
15898
|
position: lessonPosition
|
|
15375
15899
|
});
|
|
15376
15900
|
const lesson = await tx.query.contentResource.findFirst({
|
|
15377
|
-
where: (0,
|
|
15901
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, lessonId)
|
|
15378
15902
|
});
|
|
15379
15903
|
if (lesson) {
|
|
15380
15904
|
createdLessons.push(lesson);
|
|
@@ -15410,7 +15934,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15410
15934
|
position
|
|
15411
15935
|
});
|
|
15412
15936
|
const lesson = await tx.query.contentResource.findFirst({
|
|
15413
|
-
where: (0,
|
|
15937
|
+
where: (0, import_drizzle_orm46.eq)(contentResource.id, lessonId)
|
|
15414
15938
|
});
|
|
15415
15939
|
if (lesson) {
|
|
15416
15940
|
createdLessons.push(lesson);
|
|
@@ -15513,14 +16037,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15513
16037
|
__name(findClosestDiscount, "findClosestDiscount");
|
|
15514
16038
|
const percentageDiscount = findClosestDiscount(Number(input.percentageDiscount) * 100);
|
|
15515
16039
|
const merchantCouponResult = percentageDiscount < 1 ? await client.query.merchantCoupon.findFirst({
|
|
15516
|
-
where: (0,
|
|
16040
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(merchantCoupon.percentageDiscount, percentageDiscount.toString()), (0, import_drizzle_orm46.eq)(merchantCoupon.type, "special"))
|
|
15517
16041
|
}) : null;
|
|
15518
16042
|
if (!merchantCouponResult) {
|
|
15519
16043
|
return [];
|
|
15520
16044
|
}
|
|
15521
16045
|
const codesArray = [];
|
|
16046
|
+
const requestedQuantity = Number(input.quantity);
|
|
16047
|
+
const couponQuantity = requestedQuantity < 0 ? 1 : requestedQuantity;
|
|
15522
16048
|
await client.transaction(async (trx) => {
|
|
15523
|
-
for (let i = 0; i <
|
|
16049
|
+
for (let i = 0; i < couponQuantity; i++) {
|
|
15524
16050
|
const id = `coupon_${guid()}`;
|
|
15525
16051
|
await trx.insert(coupon).values({
|
|
15526
16052
|
...input,
|
|
@@ -15539,24 +16065,9 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15539
16065
|
...data,
|
|
15540
16066
|
id
|
|
15541
16067
|
});
|
|
15542
|
-
|
|
15543
|
-
name: `Personal (${data.email})`
|
|
15544
|
-
});
|
|
15545
|
-
if (!personalOrganization) {
|
|
15546
|
-
throw new Error("Failed to create personal organization");
|
|
15547
|
-
}
|
|
15548
|
-
const membership = await adapter.addMemberToOrganization({
|
|
15549
|
-
organizationId: personalOrganization.id,
|
|
16068
|
+
await provisionPersonalOrganization(adapter, {
|
|
15550
16069
|
userId: id,
|
|
15551
|
-
|
|
15552
|
-
});
|
|
15553
|
-
if (!membership) {
|
|
15554
|
-
throw new Error("Failed to add user to personal organization");
|
|
15555
|
-
}
|
|
15556
|
-
await adapter.addRoleForMember({
|
|
15557
|
-
organizationId: personalOrganization.id,
|
|
15558
|
-
memberId: membership.id,
|
|
15559
|
-
role: "owner"
|
|
16070
|
+
email: data.email
|
|
15560
16071
|
});
|
|
15561
16072
|
const user = await adapter.getUser?.(id);
|
|
15562
16073
|
if (!user) {
|
|
@@ -15573,54 +16084,54 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15573
16084
|
}
|
|
15574
16085
|
},
|
|
15575
16086
|
async getUser(data) {
|
|
15576
|
-
return await client.select().from(users).where((0,
|
|
16087
|
+
return await client.select().from(users).where((0, import_drizzle_orm46.eq)(users.id, data)).then((res) => res[0]) ?? null;
|
|
15577
16088
|
},
|
|
15578
16089
|
async getUserByEmail(data) {
|
|
15579
|
-
return await client.select().from(users).where((0,
|
|
16090
|
+
return await client.select().from(users).where((0, import_drizzle_orm46.eq)(users.email, data)).then((res) => res[0]) ?? null;
|
|
15580
16091
|
},
|
|
15581
16092
|
async createSession(data) {
|
|
15582
16093
|
await client.insert(sessions).values(data);
|
|
15583
|
-
return await client.select().from(sessions).where((0,
|
|
16094
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm46.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
15584
16095
|
},
|
|
15585
16096
|
async getSessionAndUser(data) {
|
|
15586
16097
|
return await client.select({
|
|
15587
16098
|
session: sessions,
|
|
15588
16099
|
user: users
|
|
15589
|
-
}).from(sessions).where((0,
|
|
16100
|
+
}).from(sessions).where((0, import_drizzle_orm46.eq)(sessions.sessionToken, data)).innerJoin(users, (0, import_drizzle_orm46.eq)(users.id, sessions.userId)).then((res) => res[0]) ?? null;
|
|
15590
16101
|
},
|
|
15591
16102
|
async updateUser(data) {
|
|
15592
16103
|
if (!data.id) {
|
|
15593
16104
|
throw new Error("No user id.");
|
|
15594
16105
|
}
|
|
15595
|
-
await client.update(users).set(data).where((0,
|
|
15596
|
-
return await client.select().from(users).where((0,
|
|
16106
|
+
await client.update(users).set(data).where((0, import_drizzle_orm46.eq)(users.id, data.id));
|
|
16107
|
+
return await client.select().from(users).where((0, import_drizzle_orm46.eq)(users.id, data.id)).then((res) => res[0]);
|
|
15597
16108
|
},
|
|
15598
16109
|
async updateSession(data) {
|
|
15599
|
-
await client.update(sessions).set(data).where((0,
|
|
15600
|
-
return await client.select().from(sessions).where((0,
|
|
16110
|
+
await client.update(sessions).set(data).where((0, import_drizzle_orm46.eq)(sessions.sessionToken, data.sessionToken));
|
|
16111
|
+
return await client.select().from(sessions).where((0, import_drizzle_orm46.eq)(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
|
|
15601
16112
|
},
|
|
15602
16113
|
async linkAccount(rawAccount) {
|
|
15603
16114
|
await client.insert(accounts).values(rawAccount);
|
|
15604
16115
|
},
|
|
15605
16116
|
async getUserByAccount(account) {
|
|
15606
|
-
const dbAccount = await client.select().from(accounts).where((0,
|
|
16117
|
+
const dbAccount = await client.select().from(accounts).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm46.eq)(accounts.provider, account.provider))).leftJoin(users, (0, import_drizzle_orm46.eq)(accounts.userId, users.id)).then((res) => res[0]) ?? null;
|
|
15607
16118
|
if (!dbAccount) {
|
|
15608
16119
|
return null;
|
|
15609
16120
|
}
|
|
15610
16121
|
return dbAccount.User;
|
|
15611
16122
|
},
|
|
15612
16123
|
async deleteSession(sessionToken) {
|
|
15613
|
-
const session = await client.select().from(sessions).where((0,
|
|
15614
|
-
await client.delete(sessions).where((0,
|
|
16124
|
+
const session = await client.select().from(sessions).where((0, import_drizzle_orm46.eq)(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
|
|
16125
|
+
await client.delete(sessions).where((0, import_drizzle_orm46.eq)(sessions.sessionToken, sessionToken));
|
|
15615
16126
|
return session;
|
|
15616
16127
|
},
|
|
15617
16128
|
async createVerificationToken(token) {
|
|
15618
16129
|
await client.insert(verificationTokens).values(token);
|
|
15619
|
-
return await client.select().from(verificationTokens).where((0,
|
|
16130
|
+
return await client.select().from(verificationTokens).where((0, import_drizzle_orm46.eq)(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
|
|
15620
16131
|
},
|
|
15621
16132
|
async useVerificationToken(token) {
|
|
15622
16133
|
try {
|
|
15623
|
-
const deletedToken = await client.select().from(verificationTokens).where((0,
|
|
16134
|
+
const deletedToken = await client.select().from(verificationTokens).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm46.eq)(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
|
|
15624
16135
|
if (deletedToken?.createdAt) {
|
|
15625
16136
|
const TIMEOUT_IN_SECONDS = 90;
|
|
15626
16137
|
const expireMultipleClicks = (0, import_date_fns2.addSeconds)(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
|
|
@@ -15629,7 +16140,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15629
16140
|
const { id: _, ...verificationToken } = token;
|
|
15630
16141
|
return deletedToken;
|
|
15631
16142
|
} else {
|
|
15632
|
-
await client.delete(verificationTokens).where((0,
|
|
16143
|
+
await client.delete(verificationTokens).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(verificationTokens.identifier, token.identifier), (0, import_drizzle_orm46.eq)(verificationTokens.token, token.token)));
|
|
15633
16144
|
return deletedToken;
|
|
15634
16145
|
}
|
|
15635
16146
|
}
|
|
@@ -15639,14 +16150,14 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15639
16150
|
}
|
|
15640
16151
|
},
|
|
15641
16152
|
async deleteUser(id) {
|
|
15642
|
-
const user = await client.select().from(users).where((0,
|
|
15643
|
-
await client.delete(users).where((0,
|
|
15644
|
-
await client.delete(sessions).where((0,
|
|
15645
|
-
await client.delete(accounts).where((0,
|
|
16153
|
+
const user = await client.select().from(users).where((0, import_drizzle_orm46.eq)(users.id, id)).then((res) => res[0] ?? null);
|
|
16154
|
+
await client.delete(users).where((0, import_drizzle_orm46.eq)(users.id, id));
|
|
16155
|
+
await client.delete(sessions).where((0, import_drizzle_orm46.eq)(sessions.userId, id));
|
|
16156
|
+
await client.delete(accounts).where((0, import_drizzle_orm46.eq)(accounts.userId, id));
|
|
15646
16157
|
return user;
|
|
15647
16158
|
},
|
|
15648
16159
|
async unlinkAccount(account) {
|
|
15649
|
-
await client.delete(accounts).where((0,
|
|
16160
|
+
await client.delete(accounts).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(accounts.providerAccountId, account.providerAccountId), (0, import_drizzle_orm46.eq)(accounts.provider, account.provider)));
|
|
15650
16161
|
return void 0;
|
|
15651
16162
|
},
|
|
15652
16163
|
createOrganization: async (options) => {
|
|
@@ -15659,12 +16170,12 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15659
16170
|
},
|
|
15660
16171
|
getOrganization: async (organizationId) => {
|
|
15661
16172
|
return OrganizationSchema.parse(await client.query.organization.findFirst({
|
|
15662
|
-
where: (0,
|
|
16173
|
+
where: (0, import_drizzle_orm46.eq)(organizationTable.id, organizationId)
|
|
15663
16174
|
}));
|
|
15664
16175
|
},
|
|
15665
16176
|
addMemberToOrganization: async (options) => {
|
|
15666
16177
|
const currentMembership = await client.query.organizationMemberships.findFirst({
|
|
15667
|
-
where: (0,
|
|
16178
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm46.eq)(organizationMembershipTable.userId, options.userId)),
|
|
15668
16179
|
with: {
|
|
15669
16180
|
organization: true,
|
|
15670
16181
|
user: true
|
|
@@ -15679,7 +16190,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15679
16190
|
id
|
|
15680
16191
|
});
|
|
15681
16192
|
return OrganizationMemberSchema.parse(await client.query.organizationMemberships.findFirst({
|
|
15682
|
-
where: (0,
|
|
16193
|
+
where: (0, import_drizzle_orm46.eq)(organizationMembershipTable.id, id),
|
|
15683
16194
|
with: {
|
|
15684
16195
|
organization: true,
|
|
15685
16196
|
user: true
|
|
@@ -15688,13 +16199,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15688
16199
|
}
|
|
15689
16200
|
},
|
|
15690
16201
|
removeMemberFromOrganization: async (options) => {
|
|
15691
|
-
await client.delete(organizationMembershipTable).where((0,
|
|
16202
|
+
await client.delete(organizationMembershipTable).where((0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(organizationMembershipTable.organizationId, options.organizationId), (0, import_drizzle_orm46.eq)(organizationMembershipTable.userId, options.userId)));
|
|
15692
16203
|
},
|
|
15693
16204
|
addRoleForMember: async (options) => {
|
|
15694
16205
|
const existingRole = external_exports.object({
|
|
15695
16206
|
id: external_exports.string()
|
|
15696
16207
|
}).nullish().parse(await client.query.roles.findFirst({
|
|
15697
|
-
where: (0,
|
|
16208
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(roleTable.organizationId, options.organizationId), (0, import_drizzle_orm46.eq)(roleTable.name, options.role))
|
|
15698
16209
|
}));
|
|
15699
16210
|
const roleId = existingRole?.id || crypto.randomUUID();
|
|
15700
16211
|
if (!existingRole) {
|
|
@@ -15705,7 +16216,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15705
16216
|
});
|
|
15706
16217
|
}
|
|
15707
16218
|
const currentOrgMembershipRole = await client.query.organizationMembershipRoles.findFirst({
|
|
15708
|
-
where: (0,
|
|
16219
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(organizationMembershipRoleTable.organizationMembershipId, options.memberId), (0, import_drizzle_orm46.eq)(organizationMembershipRoleTable.roleId, roleId))
|
|
15709
16220
|
});
|
|
15710
16221
|
if (!currentOrgMembershipRole) {
|
|
15711
16222
|
await client.insert(organizationMembershipRoleTable).values({
|
|
@@ -15719,16 +16230,16 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15719
16230
|
const existingRole = external_exports.object({
|
|
15720
16231
|
id: external_exports.string()
|
|
15721
16232
|
}).nullable().parse(await client.query.roles.findFirst({
|
|
15722
|
-
where: (0,
|
|
16233
|
+
where: (0, import_drizzle_orm46.and)((0, import_drizzle_orm46.eq)(roleTable.organizationId, options.organizationId), (0, import_drizzle_orm46.eq)(roleTable.name, options.role))
|
|
15723
16234
|
}));
|
|
15724
16235
|
const roleId = existingRole?.id;
|
|
15725
16236
|
if (roleId) {
|
|
15726
|
-
await client.delete(organizationMembershipRoleTable).where((0,
|
|
16237
|
+
await client.delete(organizationMembershipRoleTable).where((0, import_drizzle_orm46.eq)(organizationMembershipRoleTable.roleId, roleId));
|
|
15727
16238
|
}
|
|
15728
16239
|
},
|
|
15729
16240
|
getMembershipsForUser: async (userId) => {
|
|
15730
16241
|
return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
|
|
15731
|
-
where: (0,
|
|
16242
|
+
where: (0, import_drizzle_orm46.eq)(organizationMembershipTable.userId, userId),
|
|
15732
16243
|
with: {
|
|
15733
16244
|
organization: true,
|
|
15734
16245
|
user: true
|
|
@@ -15737,7 +16248,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15737
16248
|
},
|
|
15738
16249
|
getOrganizationMembers: async (organizationId) => {
|
|
15739
16250
|
return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
|
|
15740
|
-
where: (0,
|
|
16251
|
+
where: (0, import_drizzle_orm46.eq)(organizationMembershipTable.organizationId, organizationId)
|
|
15741
16252
|
}) || []);
|
|
15742
16253
|
},
|
|
15743
16254
|
createSubscription: async (options) => {
|
|
@@ -15747,7 +16258,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15747
16258
|
id
|
|
15748
16259
|
});
|
|
15749
16260
|
return SubscriptionSchema.parse(await client.query.subscription.findFirst({
|
|
15750
|
-
where: (0,
|
|
16261
|
+
where: (0, import_drizzle_orm46.eq)(subscriptionTable.id, id),
|
|
15751
16262
|
with: {
|
|
15752
16263
|
product: true
|
|
15753
16264
|
}
|
|
@@ -15755,7 +16266,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15755
16266
|
},
|
|
15756
16267
|
getMerchantSubscription: async (merchantSubscriptionId) => {
|
|
15757
16268
|
return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
|
|
15758
|
-
where: (0,
|
|
16269
|
+
where: (0, import_drizzle_orm46.eq)(merchantSubscriptionTable.id, merchantSubscriptionId)
|
|
15759
16270
|
}));
|
|
15760
16271
|
},
|
|
15761
16272
|
createMerchantSubscription: async (options) => {
|
|
@@ -15765,7 +16276,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15765
16276
|
id
|
|
15766
16277
|
});
|
|
15767
16278
|
return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
|
|
15768
|
-
where: (0,
|
|
16279
|
+
where: (0, import_drizzle_orm46.eq)(merchantSubscriptionTable.id, id)
|
|
15769
16280
|
}));
|
|
15770
16281
|
},
|
|
15771
16282
|
updateMerchantSubscription: async (options) => {
|
|
@@ -15776,13 +16287,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15776
16287
|
},
|
|
15777
16288
|
getSubscriptionForStripeId: async (stripeSubscriptionId) => {
|
|
15778
16289
|
const merchantSubscriptionParsed = MerchantSubscriptionSchema.safeParse(await client.query.merchantSubscription.findFirst({
|
|
15779
|
-
where: (0,
|
|
16290
|
+
where: (0, import_drizzle_orm46.eq)(merchantSubscriptionTable.identifier, stripeSubscriptionId)
|
|
15780
16291
|
}));
|
|
15781
16292
|
if (!merchantSubscriptionParsed.success) {
|
|
15782
16293
|
throw new Error(`No merchant subscription found for stripe id ${stripeSubscriptionId} ${merchantSubscriptionParsed.error}`);
|
|
15783
16294
|
}
|
|
15784
16295
|
const subscriptionParsed = SubscriptionSchema.safeParse(await client.query.subscription.findFirst({
|
|
15785
|
-
where: (0,
|
|
16296
|
+
where: (0, import_drizzle_orm46.eq)(subscriptionTable.merchantSubscriptionId, merchantSubscriptionParsed.data.id),
|
|
15786
16297
|
with: {
|
|
15787
16298
|
product: true
|
|
15788
16299
|
}
|
|
@@ -15795,7 +16306,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core51.mysqlTable, p
|
|
|
15795
16306
|
updateSubscriptionStatus: async (subscriptionId, status) => {
|
|
15796
16307
|
await client.update(subscriptionTable).set({
|
|
15797
16308
|
status
|
|
15798
|
-
}).where((0,
|
|
16309
|
+
}).where((0, import_drizzle_orm46.eq)(subscriptionTable.id, subscriptionId));
|
|
15799
16310
|
}
|
|
15800
16311
|
};
|
|
15801
16312
|
return adapter;
|