@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
|
@@ -1,51 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getResourceProgressSchema
|
|
3
|
+
} from "./chunk-WMCZWSAG.js";
|
|
1
4
|
import {
|
|
2
5
|
getEntitlementTypesSchema
|
|
3
6
|
} from "./chunk-OFZECDCQ.js";
|
|
4
7
|
import {
|
|
5
8
|
getEntitlementRelationsSchema,
|
|
6
9
|
getEntitlementsSchema
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-WPDVDHLH.js";
|
|
8
11
|
import {
|
|
9
12
|
getLessonProgressSchema
|
|
10
13
|
} from "./chunk-CCXVDMTA.js";
|
|
11
|
-
import {
|
|
12
|
-
getResourceProgressSchema
|
|
13
|
-
} from "./chunk-WMCZWSAG.js";
|
|
14
14
|
import {
|
|
15
15
|
getUpgradableProductsRelationsSchema,
|
|
16
16
|
getUpgradableProductsSchema
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-DHII2GRW.js";
|
|
18
18
|
import {
|
|
19
19
|
getQuestionResponseRelationsSchema,
|
|
20
20
|
getQuestionResponseSchema
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-RDAVEULA.js";
|
|
22
|
+
import {
|
|
23
|
+
getMerchantEventsRelationsSchema,
|
|
24
|
+
getMerchantEventsSchema
|
|
25
|
+
} from "./chunk-SOOAUY4E.js";
|
|
22
26
|
import {
|
|
23
27
|
getPurchaseUserTransferRelationsSchema,
|
|
24
28
|
getPurchaseUserTransferSchema
|
|
25
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-QDWLBCD3.js";
|
|
26
30
|
import {
|
|
27
31
|
getVerificationTokensSchema
|
|
28
32
|
} from "./chunk-OUJPUONP.js";
|
|
29
33
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from "./chunk-
|
|
34
|
+
getPersonalAccessTokenRelationsSchema,
|
|
35
|
+
getPersonalAccessTokenSchema
|
|
36
|
+
} from "./chunk-3XHKEHGF.js";
|
|
33
37
|
import {
|
|
34
38
|
getRolePermissionsRelationsSchema,
|
|
35
39
|
getRolePermissionsSchema
|
|
36
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-6VDGZ4KA.js";
|
|
37
41
|
import {
|
|
38
42
|
getSessionRelationsSchema,
|
|
39
43
|
getSessionsSchema
|
|
40
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-Q5NZ5UFZ.js";
|
|
41
45
|
import {
|
|
42
46
|
getDeviceAccessTokenRelationsSchema,
|
|
43
47
|
getDeviceAccessTokenSchema
|
|
44
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-4SMVVOU5.js";
|
|
45
49
|
import {
|
|
46
50
|
getDeviceVerificationRelationsSchema,
|
|
47
51
|
getDeviceVerificationSchema
|
|
48
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-52A4W4YI.js";
|
|
49
53
|
import {
|
|
50
54
|
getAccountsRelationsSchema,
|
|
51
55
|
getAccountsSchema,
|
|
@@ -100,7 +104,7 @@ import {
|
|
|
100
104
|
getUserRolesSchema,
|
|
101
105
|
getUsersRelationsSchema,
|
|
102
106
|
getUsersSchema
|
|
103
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-DB473RZJ.js";
|
|
104
108
|
import {
|
|
105
109
|
getContributionTypesRelationsSchema,
|
|
106
110
|
getContributionTypesSchema
|
|
@@ -111,24 +115,24 @@ import {
|
|
|
111
115
|
import {
|
|
112
116
|
getCommunicationPreferenceTypesSchema
|
|
113
117
|
} from "./chunk-QKFITIXC.js";
|
|
118
|
+
import {
|
|
119
|
+
getMerchantPriceSchema
|
|
120
|
+
} from "./chunk-PMCOC5PM.js";
|
|
114
121
|
import {
|
|
115
122
|
getMerchantProductSchema
|
|
116
123
|
} from "./chunk-2I7NIOKI.js";
|
|
117
124
|
import {
|
|
118
125
|
getMerchantSessionSchema
|
|
119
126
|
} from "./chunk-5NNBQJUP.js";
|
|
127
|
+
import {
|
|
128
|
+
getMerchantAccountSchema
|
|
129
|
+
} from "./chunk-DNBW5D64.js";
|
|
120
130
|
import {
|
|
121
131
|
getMerchantCouponSchema
|
|
122
132
|
} from "./chunk-NON5CXDH.js";
|
|
123
133
|
import {
|
|
124
134
|
getMerchantCustomerSchema
|
|
125
135
|
} from "./chunk-SIZFEXIS.js";
|
|
126
|
-
import {
|
|
127
|
-
getMerchantAccountSchema
|
|
128
|
-
} from "./chunk-DNBW5D64.js";
|
|
129
|
-
import {
|
|
130
|
-
getMerchantPriceSchema
|
|
131
|
-
} from "./chunk-PMCOC5PM.js";
|
|
132
136
|
import {
|
|
133
137
|
getPermissionsRelationsSchema,
|
|
134
138
|
getPermissionsSchema
|
|
@@ -9164,6 +9168,280 @@ __export2(external_exports2, {
|
|
|
9164
9168
|
void: () => voidType2
|
|
9165
9169
|
});
|
|
9166
9170
|
|
|
9171
|
+
// ../core/dist/chunk-H3WWX3FM.js
|
|
9172
|
+
var PURCHASE_BENEFIT_METADATA_KEY = "purchaseBenefits";
|
|
9173
|
+
var PURCHASE_BENEFIT_TRANSPORT_VERSION = 1;
|
|
9174
|
+
var purchaseBenefitTypeSchema = external_exports2.literal("access");
|
|
9175
|
+
var purchaseBenefitAppliesToSchema = external_exports2.enum([
|
|
9176
|
+
"buyer",
|
|
9177
|
+
"redeemed_team_seat"
|
|
9178
|
+
]);
|
|
9179
|
+
var purchaseBenefitIntentSchema = external_exports2.object({
|
|
9180
|
+
type: purchaseBenefitTypeSchema,
|
|
9181
|
+
resourceType: external_exports2.string().min(1),
|
|
9182
|
+
resourceId: external_exports2.string().min(1),
|
|
9183
|
+
welcomeEmailResourceId: external_exports2.string().min(1).optional()
|
|
9184
|
+
});
|
|
9185
|
+
var expandedPurchaseBenefitSourceSchema = external_exports2.object({
|
|
9186
|
+
transportVersion: external_exports2.literal(PURCHASE_BENEFIT_TRANSPORT_VERSION),
|
|
9187
|
+
metadataKey: external_exports2.literal(PURCHASE_BENEFIT_METADATA_KEY),
|
|
9188
|
+
transport: external_exports2.string(),
|
|
9189
|
+
index: external_exports2.number().int().nonnegative()
|
|
9190
|
+
});
|
|
9191
|
+
var expandedPurchaseBenefitSchema = purchaseBenefitIntentSchema.extend({
|
|
9192
|
+
id: external_exports2.string().min(1),
|
|
9193
|
+
appliesTo: purchaseBenefitAppliesToSchema,
|
|
9194
|
+
source: expandedPurchaseBenefitSourceSchema
|
|
9195
|
+
});
|
|
9196
|
+
var purchaseBenefitTransportReviewSchema = external_exports2.object({
|
|
9197
|
+
status: external_exports2.literal("needs_review"),
|
|
9198
|
+
metadataKey: external_exports2.literal(PURCHASE_BENEFIT_METADATA_KEY),
|
|
9199
|
+
transport: external_exports2.string().optional(),
|
|
9200
|
+
errors: external_exports2.array(external_exports2.object({
|
|
9201
|
+
code: external_exports2.string().min(1),
|
|
9202
|
+
message: external_exports2.string().min(1),
|
|
9203
|
+
path: external_exports2.array(external_exports2.union([
|
|
9204
|
+
external_exports2.string(),
|
|
9205
|
+
external_exports2.number()
|
|
9206
|
+
])).optional()
|
|
9207
|
+
}))
|
|
9208
|
+
});
|
|
9209
|
+
function parsePurchaseBenefitTransport(transport) {
|
|
9210
|
+
if (!transport || transport.trim().length === 0) {
|
|
9211
|
+
return {
|
|
9212
|
+
success: false,
|
|
9213
|
+
errors: [
|
|
9214
|
+
{
|
|
9215
|
+
code: "missing_transport",
|
|
9216
|
+
message: "Purchase Benefit Transport is required."
|
|
9217
|
+
}
|
|
9218
|
+
]
|
|
9219
|
+
};
|
|
9220
|
+
}
|
|
9221
|
+
let parsed;
|
|
9222
|
+
try {
|
|
9223
|
+
parsed = JSON.parse(transport);
|
|
9224
|
+
} catch {
|
|
9225
|
+
return {
|
|
9226
|
+
success: false,
|
|
9227
|
+
errors: [
|
|
9228
|
+
{
|
|
9229
|
+
code: "malformed_json",
|
|
9230
|
+
message: "Purchase Benefit Transport must be valid JSON."
|
|
9231
|
+
}
|
|
9232
|
+
]
|
|
9233
|
+
};
|
|
9234
|
+
}
|
|
9235
|
+
if (!isRecord(parsed)) {
|
|
9236
|
+
return invalidTransportShape();
|
|
9237
|
+
}
|
|
9238
|
+
if (parsed.v !== PURCHASE_BENEFIT_TRANSPORT_VERSION) {
|
|
9239
|
+
return {
|
|
9240
|
+
success: false,
|
|
9241
|
+
errors: [
|
|
9242
|
+
{
|
|
9243
|
+
code: "unsupported_version",
|
|
9244
|
+
message: `Unsupported Purchase Benefit Transport version: ${String(parsed.v)}.`,
|
|
9245
|
+
path: [
|
|
9246
|
+
"v"
|
|
9247
|
+
]
|
|
9248
|
+
}
|
|
9249
|
+
]
|
|
9250
|
+
};
|
|
9251
|
+
}
|
|
9252
|
+
if (!Array.isArray(parsed.b)) {
|
|
9253
|
+
return {
|
|
9254
|
+
success: false,
|
|
9255
|
+
errors: [
|
|
9256
|
+
{
|
|
9257
|
+
code: "invalid_benefits_shape",
|
|
9258
|
+
message: "Purchase Benefit Transport benefits must be an array.",
|
|
9259
|
+
path: [
|
|
9260
|
+
"b"
|
|
9261
|
+
]
|
|
9262
|
+
}
|
|
9263
|
+
]
|
|
9264
|
+
};
|
|
9265
|
+
}
|
|
9266
|
+
const errors = [];
|
|
9267
|
+
const benefits = [];
|
|
9268
|
+
parsed.b.forEach((tuple, index) => {
|
|
9269
|
+
const tuplePath = [
|
|
9270
|
+
"b",
|
|
9271
|
+
index
|
|
9272
|
+
];
|
|
9273
|
+
if (!Array.isArray(tuple) || tuple.length < 3 || tuple.length > 4) {
|
|
9274
|
+
errors.push({
|
|
9275
|
+
code: "invalid_tuple_shape",
|
|
9276
|
+
message: "Purchase Benefit tuple must be [type, resourceType, resourceId, optionalWelcomeEmailResourceId].",
|
|
9277
|
+
path: tuplePath
|
|
9278
|
+
});
|
|
9279
|
+
return;
|
|
9280
|
+
}
|
|
9281
|
+
const [type, rawResourceType, rawResourceId, rawWelcomeEmailResourceId] = tuple;
|
|
9282
|
+
const resourceType = typeof rawResourceType === "string" ? rawResourceType.trim() : rawResourceType;
|
|
9283
|
+
const resourceId = typeof rawResourceId === "string" ? rawResourceId.trim() : rawResourceId;
|
|
9284
|
+
const welcomeEmailResourceId = typeof rawWelcomeEmailResourceId === "string" ? rawWelcomeEmailResourceId.trim() : rawWelcomeEmailResourceId;
|
|
9285
|
+
if (type !== "access") {
|
|
9286
|
+
errors.push({
|
|
9287
|
+
code: "unsupported_benefit_type",
|
|
9288
|
+
message: `Unsupported Purchase Benefit type: ${String(type)}.`,
|
|
9289
|
+
path: [
|
|
9290
|
+
...tuplePath,
|
|
9291
|
+
0
|
|
9292
|
+
]
|
|
9293
|
+
});
|
|
9294
|
+
}
|
|
9295
|
+
if (!isNonEmptyString(resourceType)) {
|
|
9296
|
+
errors.push({
|
|
9297
|
+
code: "missing_resource_type",
|
|
9298
|
+
message: "Purchase Benefit resourceType is required.",
|
|
9299
|
+
path: [
|
|
9300
|
+
...tuplePath,
|
|
9301
|
+
1
|
|
9302
|
+
]
|
|
9303
|
+
});
|
|
9304
|
+
}
|
|
9305
|
+
if (!isNonEmptyString(resourceId)) {
|
|
9306
|
+
errors.push({
|
|
9307
|
+
code: "missing_resource_id",
|
|
9308
|
+
message: "Purchase Benefit resourceId is required.",
|
|
9309
|
+
path: [
|
|
9310
|
+
...tuplePath,
|
|
9311
|
+
2
|
|
9312
|
+
]
|
|
9313
|
+
});
|
|
9314
|
+
}
|
|
9315
|
+
if (welcomeEmailResourceId !== void 0 && !isNonEmptyString(welcomeEmailResourceId)) {
|
|
9316
|
+
errors.push({
|
|
9317
|
+
code: "invalid_welcome_email_resource_id",
|
|
9318
|
+
message: "Purchase Benefit welcomeEmailResourceId must be a non-empty string when provided.",
|
|
9319
|
+
path: [
|
|
9320
|
+
...tuplePath,
|
|
9321
|
+
3
|
|
9322
|
+
]
|
|
9323
|
+
});
|
|
9324
|
+
}
|
|
9325
|
+
if (type === "access" && isNonEmptyString(resourceType) && isNonEmptyString(resourceId) && (welcomeEmailResourceId === void 0 || isNonEmptyString(welcomeEmailResourceId))) {
|
|
9326
|
+
benefits.push({
|
|
9327
|
+
type,
|
|
9328
|
+
resourceType,
|
|
9329
|
+
resourceId,
|
|
9330
|
+
...welcomeEmailResourceId ? {
|
|
9331
|
+
welcomeEmailResourceId
|
|
9332
|
+
} : {}
|
|
9333
|
+
});
|
|
9334
|
+
}
|
|
9335
|
+
});
|
|
9336
|
+
if (errors.length > 0) {
|
|
9337
|
+
return {
|
|
9338
|
+
success: false,
|
|
9339
|
+
errors
|
|
9340
|
+
};
|
|
9341
|
+
}
|
|
9342
|
+
return {
|
|
9343
|
+
success: true,
|
|
9344
|
+
version: PURCHASE_BENEFIT_TRANSPORT_VERSION,
|
|
9345
|
+
benefits
|
|
9346
|
+
};
|
|
9347
|
+
}
|
|
9348
|
+
__name(parsePurchaseBenefitTransport, "parsePurchaseBenefitTransport");
|
|
9349
|
+
__name2(parsePurchaseBenefitTransport, "parsePurchaseBenefitTransport");
|
|
9350
|
+
function expandPurchaseBenefits(input) {
|
|
9351
|
+
return input.benefits.map((benefit, index) => ({
|
|
9352
|
+
id: createPurchaseBenefitId(benefit, input.appliesTo, index),
|
|
9353
|
+
...benefit,
|
|
9354
|
+
appliesTo: input.appliesTo,
|
|
9355
|
+
source: {
|
|
9356
|
+
transportVersion: PURCHASE_BENEFIT_TRANSPORT_VERSION,
|
|
9357
|
+
metadataKey: PURCHASE_BENEFIT_METADATA_KEY,
|
|
9358
|
+
transport: input.transport,
|
|
9359
|
+
index
|
|
9360
|
+
}
|
|
9361
|
+
}));
|
|
9362
|
+
}
|
|
9363
|
+
__name(expandPurchaseBenefits, "expandPurchaseBenefits");
|
|
9364
|
+
__name2(expandPurchaseBenefits, "expandPurchaseBenefits");
|
|
9365
|
+
function parseAndExpandPurchaseBenefitTransport(input) {
|
|
9366
|
+
const parsed = parsePurchaseBenefitTransport(input.transport);
|
|
9367
|
+
if (!parsed.success) {
|
|
9368
|
+
return {
|
|
9369
|
+
success: false,
|
|
9370
|
+
review: purchaseBenefitTransportErrorsToReview({
|
|
9371
|
+
transport: input.transport ?? void 0,
|
|
9372
|
+
errors: parsed.errors
|
|
9373
|
+
})
|
|
9374
|
+
};
|
|
9375
|
+
}
|
|
9376
|
+
return {
|
|
9377
|
+
success: true,
|
|
9378
|
+
benefits: expandPurchaseBenefits({
|
|
9379
|
+
transport: input.transport ?? "",
|
|
9380
|
+
benefits: parsed.benefits,
|
|
9381
|
+
appliesTo: input.appliesTo
|
|
9382
|
+
})
|
|
9383
|
+
};
|
|
9384
|
+
}
|
|
9385
|
+
__name(parseAndExpandPurchaseBenefitTransport, "parseAndExpandPurchaseBenefitTransport");
|
|
9386
|
+
__name2(parseAndExpandPurchaseBenefitTransport, "parseAndExpandPurchaseBenefitTransport");
|
|
9387
|
+
function purchaseBenefitTransportErrorsToReview(input) {
|
|
9388
|
+
return purchaseBenefitTransportReviewSchema.parse({
|
|
9389
|
+
status: "needs_review",
|
|
9390
|
+
metadataKey: PURCHASE_BENEFIT_METADATA_KEY,
|
|
9391
|
+
transport: input.transport,
|
|
9392
|
+
errors: input.errors
|
|
9393
|
+
});
|
|
9394
|
+
}
|
|
9395
|
+
__name(purchaseBenefitTransportErrorsToReview, "purchaseBenefitTransportErrorsToReview");
|
|
9396
|
+
__name2(purchaseBenefitTransportErrorsToReview, "purchaseBenefitTransportErrorsToReview");
|
|
9397
|
+
function invalidTransportShape() {
|
|
9398
|
+
return {
|
|
9399
|
+
success: false,
|
|
9400
|
+
errors: [
|
|
9401
|
+
{
|
|
9402
|
+
code: "invalid_transport_shape",
|
|
9403
|
+
message: "Purchase Benefit Transport must be an object with version and benefits."
|
|
9404
|
+
}
|
|
9405
|
+
]
|
|
9406
|
+
};
|
|
9407
|
+
}
|
|
9408
|
+
__name(invalidTransportShape, "invalidTransportShape");
|
|
9409
|
+
__name2(invalidTransportShape, "invalidTransportShape");
|
|
9410
|
+
function createPurchaseBenefitId(benefit, appliesTo, index) {
|
|
9411
|
+
const hash = hashString(JSON.stringify([
|
|
9412
|
+
PURCHASE_BENEFIT_TRANSPORT_VERSION,
|
|
9413
|
+
appliesTo,
|
|
9414
|
+
index,
|
|
9415
|
+
benefit.type,
|
|
9416
|
+
benefit.resourceType,
|
|
9417
|
+
benefit.resourceId,
|
|
9418
|
+
benefit.welcomeEmailResourceId ?? null
|
|
9419
|
+
]));
|
|
9420
|
+
return `pb_${hash}`;
|
|
9421
|
+
}
|
|
9422
|
+
__name(createPurchaseBenefitId, "createPurchaseBenefitId");
|
|
9423
|
+
__name2(createPurchaseBenefitId, "createPurchaseBenefitId");
|
|
9424
|
+
function hashString(value) {
|
|
9425
|
+
let hash = 2166136261;
|
|
9426
|
+
for (let index = 0; index < value.length; index++) {
|
|
9427
|
+
hash ^= value.charCodeAt(index);
|
|
9428
|
+
hash = Math.imul(hash, 16777619);
|
|
9429
|
+
}
|
|
9430
|
+
return (hash >>> 0).toString(36);
|
|
9431
|
+
}
|
|
9432
|
+
__name(hashString, "hashString");
|
|
9433
|
+
__name2(hashString, "hashString");
|
|
9434
|
+
function isRecord(value) {
|
|
9435
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9436
|
+
}
|
|
9437
|
+
__name(isRecord, "isRecord");
|
|
9438
|
+
__name2(isRecord, "isRecord");
|
|
9439
|
+
function isNonEmptyString(value) {
|
|
9440
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
9441
|
+
}
|
|
9442
|
+
__name(isNonEmptyString, "isNonEmptyString");
|
|
9443
|
+
__name2(isNonEmptyString, "isNonEmptyString");
|
|
9444
|
+
|
|
9167
9445
|
// ../core/dist/chunk-KXTOX2R2.js
|
|
9168
9446
|
var upgradableProductSchema = external_exports2.object({
|
|
9169
9447
|
upgradableToId: external_exports2.string().max(255),
|
|
@@ -9175,7 +9453,11 @@ var upgradableProductSchema = external_exports2.object({
|
|
|
9175
9453
|
deletedAt: external_exports2.date().nullable()
|
|
9176
9454
|
});
|
|
9177
9455
|
|
|
9178
|
-
// ../core/dist/chunk-
|
|
9456
|
+
// ../core/dist/chunk-QHRMESWX.js
|
|
9457
|
+
var VideoChapterSchema = external_exports2.object({
|
|
9458
|
+
startTime: external_exports2.number().min(0),
|
|
9459
|
+
title: external_exports2.string().min(1).max(120)
|
|
9460
|
+
}).strict();
|
|
9179
9461
|
var VideoResourceSchema = external_exports2.object({
|
|
9180
9462
|
id: external_exports2.string(),
|
|
9181
9463
|
updatedAt: external_exports2.coerce.date().optional(),
|
|
@@ -9188,6 +9470,7 @@ var VideoResourceSchema = external_exports2.object({
|
|
|
9188
9470
|
transcriptWithScreenshots: external_exports2.string().optional().nullable(),
|
|
9189
9471
|
srt: external_exports2.string().optional().nullable(),
|
|
9190
9472
|
wordLevelSrt: external_exports2.string().optional().nullable(),
|
|
9473
|
+
chapters: external_exports2.array(VideoChapterSchema).optional().nullable(),
|
|
9191
9474
|
state: external_exports2.enum([
|
|
9192
9475
|
"new",
|
|
9193
9476
|
"processing",
|
|
@@ -9198,44 +9481,6 @@ var VideoResourceSchema = external_exports2.object({
|
|
|
9198
9481
|
])
|
|
9199
9482
|
});
|
|
9200
9483
|
|
|
9201
|
-
// ../core/dist/chunk-4EYC75KK.js
|
|
9202
|
-
var userSchema = external_exports2.object({
|
|
9203
|
-
id: external_exports2.string().max(255),
|
|
9204
|
-
name: external_exports2.string().max(255).optional().nullable(),
|
|
9205
|
-
role: external_exports2.enum([
|
|
9206
|
-
"user",
|
|
9207
|
-
"admin",
|
|
9208
|
-
"contributor"
|
|
9209
|
-
]).default("user"),
|
|
9210
|
-
email: external_exports2.string().max(255).email(),
|
|
9211
|
-
emailVerified: external_exports2.coerce.date().nullish(),
|
|
9212
|
-
image: external_exports2.string().max(255).optional().nullable(),
|
|
9213
|
-
createdAt: external_exports2.coerce.date().nullish(),
|
|
9214
|
-
memberships: external_exports2.array(external_exports2.object({
|
|
9215
|
-
id: external_exports2.string(),
|
|
9216
|
-
organizationId: external_exports2.string()
|
|
9217
|
-
})).nullish().default([]),
|
|
9218
|
-
roles: external_exports2.array(external_exports2.object({
|
|
9219
|
-
id: external_exports2.string(),
|
|
9220
|
-
name: external_exports2.string(),
|
|
9221
|
-
description: external_exports2.string().nullable(),
|
|
9222
|
-
active: external_exports2.boolean(),
|
|
9223
|
-
createdAt: external_exports2.coerce.date().nullish(),
|
|
9224
|
-
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9225
|
-
deletedAt: external_exports2.coerce.date().nullish()
|
|
9226
|
-
})).optional().default([]),
|
|
9227
|
-
organizationRoles: external_exports2.array(external_exports2.object({
|
|
9228
|
-
id: external_exports2.string(),
|
|
9229
|
-
organizationId: external_exports2.string(),
|
|
9230
|
-
name: external_exports2.string(),
|
|
9231
|
-
description: external_exports2.string().nullable(),
|
|
9232
|
-
active: external_exports2.boolean(),
|
|
9233
|
-
createdAt: external_exports2.coerce.date().nullish(),
|
|
9234
|
-
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9235
|
-
deletedAt: external_exports2.coerce.date().nullish()
|
|
9236
|
-
})).optional().default([])
|
|
9237
|
-
});
|
|
9238
|
-
|
|
9239
9484
|
// ../core/dist/chunk-ZSS5ABRS.js
|
|
9240
9485
|
var priceSchema = external_exports2.object({
|
|
9241
9486
|
id: external_exports2.string().max(191),
|
|
@@ -9388,6 +9633,44 @@ var NewProductSchema = external_exports2.object({
|
|
|
9388
9633
|
]).optional()
|
|
9389
9634
|
});
|
|
9390
9635
|
|
|
9636
|
+
// ../core/dist/chunk-4EYC75KK.js
|
|
9637
|
+
var userSchema = external_exports2.object({
|
|
9638
|
+
id: external_exports2.string().max(255),
|
|
9639
|
+
name: external_exports2.string().max(255).optional().nullable(),
|
|
9640
|
+
role: external_exports2.enum([
|
|
9641
|
+
"user",
|
|
9642
|
+
"admin",
|
|
9643
|
+
"contributor"
|
|
9644
|
+
]).default("user"),
|
|
9645
|
+
email: external_exports2.string().max(255).email(),
|
|
9646
|
+
emailVerified: external_exports2.coerce.date().nullish(),
|
|
9647
|
+
image: external_exports2.string().max(255).optional().nullable(),
|
|
9648
|
+
createdAt: external_exports2.coerce.date().nullish(),
|
|
9649
|
+
memberships: external_exports2.array(external_exports2.object({
|
|
9650
|
+
id: external_exports2.string(),
|
|
9651
|
+
organizationId: external_exports2.string()
|
|
9652
|
+
})).nullish().default([]),
|
|
9653
|
+
roles: external_exports2.array(external_exports2.object({
|
|
9654
|
+
id: external_exports2.string(),
|
|
9655
|
+
name: external_exports2.string(),
|
|
9656
|
+
description: external_exports2.string().nullable(),
|
|
9657
|
+
active: external_exports2.boolean(),
|
|
9658
|
+
createdAt: external_exports2.coerce.date().nullish(),
|
|
9659
|
+
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9660
|
+
deletedAt: external_exports2.coerce.date().nullish()
|
|
9661
|
+
})).optional().default([]),
|
|
9662
|
+
organizationRoles: external_exports2.array(external_exports2.object({
|
|
9663
|
+
id: external_exports2.string(),
|
|
9664
|
+
organizationId: external_exports2.string(),
|
|
9665
|
+
name: external_exports2.string(),
|
|
9666
|
+
description: external_exports2.string().nullable(),
|
|
9667
|
+
active: external_exports2.boolean(),
|
|
9668
|
+
createdAt: external_exports2.coerce.date().nullish(),
|
|
9669
|
+
updatedAt: external_exports2.coerce.date().nullish(),
|
|
9670
|
+
deletedAt: external_exports2.coerce.date().nullish()
|
|
9671
|
+
})).optional().default([])
|
|
9672
|
+
});
|
|
9673
|
+
|
|
9391
9674
|
// ../core/dist/chunk-KBC2DYK6.js
|
|
9392
9675
|
var eligibilityConditionSchema = external_exports2.discriminatedUnion("type", [
|
|
9393
9676
|
external_exports2.object({
|
|
@@ -9432,7 +9715,7 @@ var couponSchema = external_exports2.object({
|
|
|
9432
9715
|
organizationId: external_exports2.string().max(191).optional().nullable()
|
|
9433
9716
|
});
|
|
9434
9717
|
|
|
9435
|
-
// ../core/dist/chunk-
|
|
9718
|
+
// ../core/dist/chunk-OAARZI4L.js
|
|
9436
9719
|
var purchaseSchema = external_exports2.object({
|
|
9437
9720
|
id: external_exports2.string().max(191),
|
|
9438
9721
|
userId: external_exports2.string().max(191).optional().nullable(),
|
|
@@ -9512,6 +9795,43 @@ var moduleProgressSchema = external_exports2.object({
|
|
|
9512
9795
|
totalLessonsCount: external_exports2.number().default(0)
|
|
9513
9796
|
});
|
|
9514
9797
|
|
|
9798
|
+
// ../core/dist/chunk-IDHV7EM4.js
|
|
9799
|
+
var merchantPriceSchema = external_exports2.object({
|
|
9800
|
+
id: external_exports2.string().max(191),
|
|
9801
|
+
merchantAccountId: external_exports2.string().max(191),
|
|
9802
|
+
merchantProductId: external_exports2.string().max(191),
|
|
9803
|
+
status: external_exports2.number().int().default(0),
|
|
9804
|
+
identifier: external_exports2.string().max(191).optional().nullable(),
|
|
9805
|
+
createdAt: external_exports2.date(),
|
|
9806
|
+
priceId: external_exports2.string().max(191).optional().nullable()
|
|
9807
|
+
});
|
|
9808
|
+
|
|
9809
|
+
// ../core/dist/chunk-ZHSWPV43.js
|
|
9810
|
+
var merchantProductSchema = external_exports2.object({
|
|
9811
|
+
id: external_exports2.string().max(191),
|
|
9812
|
+
merchantAccountId: external_exports2.string().max(191),
|
|
9813
|
+
productId: external_exports2.string().max(191),
|
|
9814
|
+
status: external_exports2.number().int().default(0),
|
|
9815
|
+
identifier: external_exports2.string().max(191).optional().nullable(),
|
|
9816
|
+
createdAt: external_exports2.date().nullable()
|
|
9817
|
+
});
|
|
9818
|
+
|
|
9819
|
+
// ../core/dist/chunk-FNESWG4F.js
|
|
9820
|
+
var entitlementSchema = external_exports2.object({
|
|
9821
|
+
id: external_exports2.string().max(191),
|
|
9822
|
+
entitlementType: external_exports2.string().max(255),
|
|
9823
|
+
userId: external_exports2.string().max(191).nullable().optional(),
|
|
9824
|
+
organizationId: external_exports2.string().max(191).nullable().optional(),
|
|
9825
|
+
organizationMembershipId: external_exports2.string().max(191).nullable().optional(),
|
|
9826
|
+
sourceType: external_exports2.string().max(255),
|
|
9827
|
+
sourceId: external_exports2.string().max(191),
|
|
9828
|
+
metadata: external_exports2.record(external_exports2.any()).default({}),
|
|
9829
|
+
expiresAt: external_exports2.date().nullable().optional(),
|
|
9830
|
+
createdAt: external_exports2.date().nullable().optional(),
|
|
9831
|
+
updatedAt: external_exports2.date().nullable().optional(),
|
|
9832
|
+
deletedAt: external_exports2.date().nullable().optional()
|
|
9833
|
+
});
|
|
9834
|
+
|
|
9515
9835
|
// ../core/dist/chunk-MVVSJ2XH.js
|
|
9516
9836
|
var merchantChargeSchema = external_exports2.object({
|
|
9517
9837
|
id: external_exports2.string().max(191),
|
|
@@ -9563,42 +9883,67 @@ var merchantEventsSchema = external_exports2.object({
|
|
|
9563
9883
|
createdAt: external_exports2.date().nullable()
|
|
9564
9884
|
});
|
|
9565
9885
|
|
|
9566
|
-
// ../core/dist/chunk-
|
|
9567
|
-
var
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
});
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9886
|
+
// ../core/dist/chunk-Y6GOOY2Z.js
|
|
9887
|
+
var PaidClickIdsSchema = external_exports2.object({
|
|
9888
|
+
gclid: external_exports2.string().optional(),
|
|
9889
|
+
gbraid: external_exports2.string().optional(),
|
|
9890
|
+
wbraid: external_exports2.string().optional(),
|
|
9891
|
+
fbclid: external_exports2.string().optional(),
|
|
9892
|
+
li_fat_id: external_exports2.string().optional(),
|
|
9893
|
+
ttclid: external_exports2.string().optional(),
|
|
9894
|
+
twclid: external_exports2.string().optional()
|
|
9895
|
+
}).partial();
|
|
9896
|
+
var AttributionSnapshotPayloadSchema = external_exports2.object({
|
|
9897
|
+
schemaVersion: external_exports2.literal(1),
|
|
9898
|
+
capturedAt: external_exports2.string(),
|
|
9899
|
+
source: external_exports2.string().optional(),
|
|
9900
|
+
medium: external_exports2.string().optional(),
|
|
9901
|
+
campaign: external_exports2.string().optional(),
|
|
9902
|
+
frontConversationId: external_exports2.string().optional(),
|
|
9903
|
+
operatorRunId: external_exports2.string().optional(),
|
|
9904
|
+
recoveredFrom: external_exports2.string().optional(),
|
|
9905
|
+
recoveredAt: external_exports2.string().optional(),
|
|
9906
|
+
landingPath: external_exports2.string().optional(),
|
|
9907
|
+
landingVariant: external_exports2.string().optional(),
|
|
9908
|
+
referrer: external_exports2.string().optional(),
|
|
9909
|
+
utm: external_exports2.object({
|
|
9910
|
+
source: external_exports2.string().optional(),
|
|
9911
|
+
medium: external_exports2.string().optional(),
|
|
9912
|
+
campaign: external_exports2.string().optional(),
|
|
9913
|
+
content: external_exports2.string().optional(),
|
|
9914
|
+
term: external_exports2.string().optional()
|
|
9915
|
+
}).optional(),
|
|
9916
|
+
clickIds: PaidClickIdsSchema.optional(),
|
|
9917
|
+
shortlink: external_exports2.object({
|
|
9918
|
+
id: external_exports2.string().nullable().optional(),
|
|
9919
|
+
slug: external_exports2.string().nullable().optional(),
|
|
9920
|
+
metadata: external_exports2.record(external_exports2.unknown()).nullable().optional()
|
|
9921
|
+
}).optional(),
|
|
9922
|
+
ga: external_exports2.object({
|
|
9923
|
+
clientId: external_exports2.string().optional()
|
|
9924
|
+
}).optional(),
|
|
9925
|
+
selfReportedSource: external_exports2.string().optional(),
|
|
9926
|
+
// Bounded original landing-page query params. This is intentionally not the
|
|
9927
|
+
// checkout callback query string because Stripe metadata values are small.
|
|
9928
|
+
params: external_exports2.record(external_exports2.string()).optional(),
|
|
9929
|
+
synthetic: external_exports2.boolean().optional(),
|
|
9930
|
+
syntheticReason: external_exports2.string().optional()
|
|
9601
9931
|
});
|
|
9932
|
+
function parseAttributionSnapshotPayload(value) {
|
|
9933
|
+
if (!value)
|
|
9934
|
+
return void 0;
|
|
9935
|
+
if (typeof value === "string") {
|
|
9936
|
+
try {
|
|
9937
|
+
return AttributionSnapshotPayloadSchema.parse(JSON.parse(value));
|
|
9938
|
+
} catch {
|
|
9939
|
+
return void 0;
|
|
9940
|
+
}
|
|
9941
|
+
}
|
|
9942
|
+
const parsed = AttributionSnapshotPayloadSchema.safeParse(value);
|
|
9943
|
+
return parsed.success ? parsed.data : void 0;
|
|
9944
|
+
}
|
|
9945
|
+
__name(parseAttributionSnapshotPayload, "parseAttributionSnapshotPayload");
|
|
9946
|
+
__name2(parseAttributionSnapshotPayload, "parseAttributionSnapshotPayload");
|
|
9602
9947
|
|
|
9603
9948
|
// ../core/dist/schemas/merchant-account-schema.js
|
|
9604
9949
|
var merchantAccountSchema = external_exports2.object({
|
|
@@ -9827,6 +10172,19 @@ function toError(error) {
|
|
|
9827
10172
|
}
|
|
9828
10173
|
__name(toError, "toError");
|
|
9829
10174
|
var logger2 = logger;
|
|
10175
|
+
function mergePurchaseBenefitFields(fields, expansion) {
|
|
10176
|
+
if (!expansion)
|
|
10177
|
+
return fields;
|
|
10178
|
+
return {
|
|
10179
|
+
...fields,
|
|
10180
|
+
...expansion.success ? {
|
|
10181
|
+
purchaseBenefits: expansion.benefits
|
|
10182
|
+
} : {
|
|
10183
|
+
purchaseBenefitsReview: expansion.review
|
|
10184
|
+
}
|
|
10185
|
+
};
|
|
10186
|
+
}
|
|
10187
|
+
__name(mergePurchaseBenefitFields, "mergePurchaseBenefitFields");
|
|
9830
10188
|
function getCourseBuilderSchema(mysqlTable, overrides = {}) {
|
|
9831
10189
|
const resolvedGetUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
9832
10190
|
const userRelationsOverrides = {
|
|
@@ -9899,6 +10257,8 @@ function getCourseBuilderSchema(mysqlTable, overrides = {}) {
|
|
|
9899
10257
|
deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
9900
10258
|
deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
|
|
9901
10259
|
deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
10260
|
+
personalAccessToken: getPersonalAccessTokenSchema(mysqlTable),
|
|
10261
|
+
personalAccessTokenRelations: getPersonalAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
9902
10262
|
tag: getTagSchema(mysqlTable),
|
|
9903
10263
|
tagRelations: getTagRelationsSchema(mysqlTable),
|
|
9904
10264
|
tagTag: getTagTagSchema(mysqlTable),
|
|
@@ -9927,13 +10287,40 @@ function createTables(mySqlTable) {
|
|
|
9927
10287
|
return getCourseBuilderSchema(mySqlTable);
|
|
9928
10288
|
}
|
|
9929
10289
|
__name(createTables, "createTables");
|
|
10290
|
+
async function provisionPersonalOrganization(adapter, params) {
|
|
10291
|
+
const { userId, email } = params;
|
|
10292
|
+
const personalOrganization = await adapter.createOrganization({
|
|
10293
|
+
name: `Personal (${email})`
|
|
10294
|
+
});
|
|
10295
|
+
if (!personalOrganization) {
|
|
10296
|
+
throw new Error("Failed to create personal organization");
|
|
10297
|
+
}
|
|
10298
|
+
const membership = await adapter.addMemberToOrganization({
|
|
10299
|
+
organizationId: personalOrganization.id,
|
|
10300
|
+
userId,
|
|
10301
|
+
invitedById: userId
|
|
10302
|
+
});
|
|
10303
|
+
if (!membership) {
|
|
10304
|
+
throw new Error("Failed to add user to personal organization");
|
|
10305
|
+
}
|
|
10306
|
+
await adapter.addRoleForMember({
|
|
10307
|
+
organizationId: personalOrganization.id,
|
|
10308
|
+
memberId: membership.id,
|
|
10309
|
+
role: "owner"
|
|
10310
|
+
});
|
|
10311
|
+
}
|
|
10312
|
+
__name(provisionPersonalOrganization, "provisionPersonalOrganization");
|
|
9930
10313
|
function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvider) {
|
|
9931
10314
|
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);
|
|
10315
|
+
const normalizeLearnerEmail = /* @__PURE__ */ __name((email) => email.trim().toLowerCase().replace(/\s+/g, "+"), "normalizeLearnerEmail");
|
|
9932
10316
|
const adapter = {
|
|
9933
10317
|
client,
|
|
10318
|
+
async provisionPersonalOrganization(params) {
|
|
10319
|
+
await provisionPersonalOrganization(adapter, params);
|
|
10320
|
+
},
|
|
9934
10321
|
async redeemFullPriceCoupon(options) {
|
|
9935
10322
|
const { email: baseEmail, couponId, productIds, currentUserId, redeemingProductId } = options;
|
|
9936
|
-
const email = String(baseEmail)
|
|
10323
|
+
const email = normalizeLearnerEmail(String(baseEmail));
|
|
9937
10324
|
const coupon2 = await adapter.getCouponWithBulkPurchases(couponId);
|
|
9938
10325
|
const productId = coupon2 && coupon2.restrictedToProductId || redeemingProductId;
|
|
9939
10326
|
if (!productId)
|
|
@@ -9946,6 +10333,28 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
9946
10333
|
throw new Error(`unable-to-create-user-${email}`);
|
|
9947
10334
|
const currentUser = currentUserId ? await adapter.getUserById(currentUserId) : null;
|
|
9948
10335
|
const redeemingForCurrentUser = currentUser?.id === user.id;
|
|
10336
|
+
if (bulkCouponRedemption) {
|
|
10337
|
+
const existingValidRedemption = await client.query.purchases.findFirst({
|
|
10338
|
+
where: and(eq(purchaseTable.redeemedBulkCouponId, coupon2.id), eq(purchaseTable.userId, user.id), eq(purchaseTable.status, "Valid"))
|
|
10339
|
+
});
|
|
10340
|
+
if (existingValidRedemption) {
|
|
10341
|
+
logger2.info("adapter.coupon.redeem.duplicate_team_seat", {
|
|
10342
|
+
couponId: coupon2.id,
|
|
10343
|
+
currentUserId,
|
|
10344
|
+
email,
|
|
10345
|
+
productId,
|
|
10346
|
+
purchaseId: existingValidRedemption.id,
|
|
10347
|
+
userId: user.id
|
|
10348
|
+
});
|
|
10349
|
+
return {
|
|
10350
|
+
error: {
|
|
10351
|
+
message: "team-seat-redemption-already-claimed"
|
|
10352
|
+
},
|
|
10353
|
+
redeemingForCurrentUser,
|
|
10354
|
+
purchase: null
|
|
10355
|
+
};
|
|
10356
|
+
}
|
|
10357
|
+
}
|
|
9949
10358
|
const existingPurchases = await adapter.getExistingNonBulkValidPurchasesOfProduct({
|
|
9950
10359
|
userId: user.id,
|
|
9951
10360
|
productId
|
|
@@ -10108,7 +10517,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10108
10517
|
await client.update(resourceProgress).set({
|
|
10109
10518
|
completedAt: now,
|
|
10110
10519
|
updatedAt: now
|
|
10111
|
-
}).where(eq(resourceProgress.resourceId, options.lessonId));
|
|
10520
|
+
}).where(and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId)));
|
|
10112
10521
|
}
|
|
10113
10522
|
} else {
|
|
10114
10523
|
await client.insert(resourceProgress).values({
|
|
@@ -10173,7 +10582,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10173
10582
|
async createMerchantChargeAndPurchase(options) {
|
|
10174
10583
|
const purchaseId = await client.transaction(async (trx) => {
|
|
10175
10584
|
try {
|
|
10176
|
-
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId, organizationId } = options;
|
|
10585
|
+
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId, organizationId, attributionSnapshot } = options;
|
|
10177
10586
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
10178
10587
|
where: eq(merchantCharge.identifier, stripeChargeId)
|
|
10179
10588
|
}) || null);
|
|
@@ -10204,17 +10613,35 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10204
10613
|
"Restricted"
|
|
10205
10614
|
]))
|
|
10206
10615
|
}) || null);
|
|
10207
|
-
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, and(eq(coupon.id, purchaseTable.bulkCouponId), eq(purchaseTable.userId, userId))).where(and(eq(coupon.restrictedToProductId, productId), eq(purchaseTable.userId, userId))).then((res) => {
|
|
10616
|
+
const existingBulkCoupon = couponSchema.nullable().parse(await client.select().from(coupon).leftJoin(purchaseTable, and(eq(coupon.id, purchaseTable.bulkCouponId), eq(purchaseTable.userId, userId))).where(and(eq(coupon.restrictedToProductId, productId), eq(purchaseTable.userId, userId), eq(purchaseTable.status, "Valid"))).then((res) => {
|
|
10208
10617
|
return res[0]?.Coupon ?? null;
|
|
10209
10618
|
}));
|
|
10210
|
-
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || options.bulk
|
|
10619
|
+
const isBulkPurchase = quantity > 1 || Boolean(existingBulkCoupon) || Boolean(options.bulk);
|
|
10211
10620
|
let bulkCouponId = null;
|
|
10212
10621
|
let couponToUpdate = null;
|
|
10622
|
+
const purchaseBenefitsTransport = options.purchaseBenefitsTransport?.trim() || void 0;
|
|
10623
|
+
const purchaseBenefitExpansion = purchaseBenefitsTransport ? parseAndExpandPurchaseBenefitTransport({
|
|
10624
|
+
transport: purchaseBenefitsTransport,
|
|
10625
|
+
appliesTo: isBulkPurchase ? "redeemed_team_seat" : "buyer"
|
|
10626
|
+
}) : null;
|
|
10627
|
+
if (purchaseBenefitExpansion && !purchaseBenefitExpansion.success) {
|
|
10628
|
+
logger2.info("purchase_benefits.transport.needs_review", {
|
|
10629
|
+
checkoutSessionId,
|
|
10630
|
+
event: "purchase_benefits.transport.needs_review",
|
|
10631
|
+
metadataKey: PURCHASE_BENEFIT_METADATA_KEY,
|
|
10632
|
+
productId,
|
|
10633
|
+
stripeChargeId,
|
|
10634
|
+
userId,
|
|
10635
|
+
errors: purchaseBenefitExpansion.review.errors
|
|
10636
|
+
});
|
|
10637
|
+
}
|
|
10213
10638
|
if (isBulkPurchase) {
|
|
10214
10639
|
bulkCouponId = existingBulkCoupon !== null ? existingBulkCoupon.id : v4();
|
|
10215
10640
|
if (existingBulkCoupon !== null) {
|
|
10641
|
+
const existingCouponFields = existingBulkCoupon.fields ?? {};
|
|
10216
10642
|
couponToUpdate = await client.update(coupon).set({
|
|
10217
10643
|
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity,
|
|
10644
|
+
fields: mergePurchaseBenefitFields(existingCouponFields, purchaseBenefitExpansion),
|
|
10218
10645
|
...organizationId ? {
|
|
10219
10646
|
organizationId
|
|
10220
10647
|
} : {}
|
|
@@ -10239,6 +10666,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10239
10666
|
restrictedToProductId: productId,
|
|
10240
10667
|
maxUses: quantity,
|
|
10241
10668
|
status: 1,
|
|
10669
|
+
fields: mergePurchaseBenefitFields({}, purchaseBenefitExpansion),
|
|
10242
10670
|
...organizationId ? {
|
|
10243
10671
|
organizationId
|
|
10244
10672
|
} : {},
|
|
@@ -10272,6 +10700,12 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10272
10700
|
bulkCouponId,
|
|
10273
10701
|
merchantSessionId,
|
|
10274
10702
|
country,
|
|
10703
|
+
fields: {
|
|
10704
|
+
...!isBulkPurchase ? mergePurchaseBenefitFields({}, purchaseBenefitExpansion) : {},
|
|
10705
|
+
...attributionSnapshot ? {
|
|
10706
|
+
attribution: attributionSnapshot
|
|
10707
|
+
} : {}
|
|
10708
|
+
},
|
|
10275
10709
|
upgradedFromId: upgradedFromPurchaseId || null,
|
|
10276
10710
|
couponId: usedCouponId || null,
|
|
10277
10711
|
...organizationId ? {
|
|
@@ -11323,7 +11757,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
11323
11757
|
await client.update(resourceProgress).set({
|
|
11324
11758
|
completedAt: lessonProgress.completedAt ? null : now,
|
|
11325
11759
|
updatedAt: now
|
|
11326
|
-
}).where(eq(resourceProgress.resourceId, options.lessonId));
|
|
11760
|
+
}).where(and(eq(resourceProgress.userId, options.userId), eq(resourceProgress.resourceId, options.lessonId)));
|
|
11327
11761
|
} else {
|
|
11328
11762
|
await client.insert(resourceProgress).values({
|
|
11329
11763
|
userId: options.userId,
|
|
@@ -11466,14 +11900,18 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
11466
11900
|
resources: true
|
|
11467
11901
|
}
|
|
11468
11902
|
});
|
|
11469
|
-
const
|
|
11903
|
+
const parsedParentResource = ContentResourceSchema.safeParse(parentResourceData);
|
|
11904
|
+
if (!parsedParentResource.success) {
|
|
11905
|
+
return null;
|
|
11906
|
+
}
|
|
11907
|
+
const parentResource = parsedParentResource.data;
|
|
11470
11908
|
await client.insert(contentResourceResource).values({
|
|
11471
11909
|
resourceOfId: parentResource.id,
|
|
11472
11910
|
resourceId: childResourceId,
|
|
11473
11911
|
position: parentResource.resources?.length || 0
|
|
11474
11912
|
});
|
|
11475
|
-
const resourceJoin = client.query.contentResourceResource.findFirst({
|
|
11476
|
-
where: and(eq(contentResourceResource.resourceOfId,
|
|
11913
|
+
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
11914
|
+
where: and(eq(contentResourceResource.resourceOfId, parentResource.id), eq(contentResourceResource.resourceId, childResourceId)),
|
|
11477
11915
|
with: {
|
|
11478
11916
|
resource: true
|
|
11479
11917
|
}
|
|
@@ -11486,14 +11924,25 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
11486
11924
|
},
|
|
11487
11925
|
async removeResourceFromResource(options) {
|
|
11488
11926
|
const { childResourceId, parentResourceId } = options;
|
|
11927
|
+
const parentResourceData = await client.query.contentResource.findFirst({
|
|
11928
|
+
where: or(eq(sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, parentResourceId), eq(contentResource.id, parentResourceId))
|
|
11929
|
+
});
|
|
11930
|
+
const parsedParentResource = ContentResourceSchema.safeParse(parentResourceData);
|
|
11931
|
+
if (!parsedParentResource.success) {
|
|
11932
|
+
return null;
|
|
11933
|
+
}
|
|
11934
|
+
const parentResource = parsedParentResource.data;
|
|
11489
11935
|
const resourceJoin = await client.query.contentResourceResource.findFirst({
|
|
11490
|
-
where: and(eq(contentResourceResource.resourceOfId,
|
|
11936
|
+
where: and(eq(contentResourceResource.resourceOfId, parentResource.id), eq(contentResourceResource.resourceId, childResourceId)),
|
|
11937
|
+
with: {
|
|
11938
|
+
resource: true
|
|
11939
|
+
}
|
|
11491
11940
|
});
|
|
11492
11941
|
const parsedResourceJoin = ContentResourceResourceSchema.safeParse(resourceJoin);
|
|
11493
11942
|
if (!parsedResourceJoin.success) {
|
|
11494
11943
|
return null;
|
|
11495
11944
|
}
|
|
11496
|
-
await client.delete(contentResourceResource).where(and(eq(contentResourceResource.resourceOfId,
|
|
11945
|
+
await client.delete(contentResourceResource).where(and(eq(contentResourceResource.resourceOfId, parentResource.id), eq(contentResourceResource.resourceId, childResourceId)));
|
|
11497
11946
|
return parsedResourceJoin.data.resource;
|
|
11498
11947
|
},
|
|
11499
11948
|
async updateContentResourceFields(options) {
|
|
@@ -11550,7 +11999,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
11550
11999
|
JSON_EXTRACT (${contentResource.fields}, "$.duration") AS duration,
|
|
11551
12000
|
JSON_EXTRACT (${contentResource.fields}, "$.muxPlaybackId") AS muxPlaybackId,
|
|
11552
12001
|
JSON_EXTRACT (${contentResource.fields}, "$.muxAssetId") AS muxAssetId,
|
|
11553
|
-
JSON_EXTRACT (${contentResource.fields}, "$.transcript") AS transcript
|
|
12002
|
+
JSON_EXTRACT (${contentResource.fields}, "$.transcript") AS transcript,
|
|
12003
|
+
JSON_EXTRACT (${contentResource.fields}, "$.chapters") AS chapters
|
|
11554
12004
|
FROM
|
|
11555
12005
|
${contentResource}
|
|
11556
12006
|
WHERE
|
|
@@ -12471,8 +12921,10 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
12471
12921
|
return [];
|
|
12472
12922
|
}
|
|
12473
12923
|
const codesArray = [];
|
|
12924
|
+
const requestedQuantity = Number(input.quantity);
|
|
12925
|
+
const couponQuantity = requestedQuantity < 0 ? 1 : requestedQuantity;
|
|
12474
12926
|
await client.transaction(async (trx) => {
|
|
12475
|
-
for (let i = 0; i <
|
|
12927
|
+
for (let i = 0; i < couponQuantity; i++) {
|
|
12476
12928
|
const id = `coupon_${guid()}`;
|
|
12477
12929
|
await trx.insert(coupon).values({
|
|
12478
12930
|
...input,
|
|
@@ -12491,24 +12943,9 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
12491
12943
|
...data,
|
|
12492
12944
|
id
|
|
12493
12945
|
});
|
|
12494
|
-
|
|
12495
|
-
name: `Personal (${data.email})`
|
|
12496
|
-
});
|
|
12497
|
-
if (!personalOrganization) {
|
|
12498
|
-
throw new Error("Failed to create personal organization");
|
|
12499
|
-
}
|
|
12500
|
-
const membership = await adapter.addMemberToOrganization({
|
|
12501
|
-
organizationId: personalOrganization.id,
|
|
12946
|
+
await provisionPersonalOrganization(adapter, {
|
|
12502
12947
|
userId: id,
|
|
12503
|
-
|
|
12504
|
-
});
|
|
12505
|
-
if (!membership) {
|
|
12506
|
-
throw new Error("Failed to add user to personal organization");
|
|
12507
|
-
}
|
|
12508
|
-
await adapter.addRoleForMember({
|
|
12509
|
-
organizationId: personalOrganization.id,
|
|
12510
|
-
memberId: membership.id,
|
|
12511
|
-
role: "owner"
|
|
12948
|
+
email: data.email
|
|
12512
12949
|
});
|
|
12513
12950
|
const user = await adapter.getUser?.(id);
|
|
12514
12951
|
if (!user) {
|
|
@@ -12761,4 +13198,4 @@ export {
|
|
|
12761
13198
|
createTables,
|
|
12762
13199
|
mySqlDrizzleAdapter
|
|
12763
13200
|
};
|
|
12764
|
-
//# sourceMappingURL=chunk-
|
|
13201
|
+
//# sourceMappingURL=chunk-ULJCXOOM.js.map
|