@coursebuilder/adapter-drizzle 2.1.0 → 3.0.0-canary.0.0c9beb2ae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-KIQLUFJX.js → chunk-2GW3BJE2.js} +2 -2
- package/dist/{chunk-M3WM5Q7W.js → chunk-33ZN7FN7.js} +2 -2
- package/dist/chunk-4VZJQAPV.js +74 -0
- package/dist/chunk-5FLS4ZBX.js +109 -0
- package/dist/chunk-5YR5M22S.js +147 -0
- package/dist/chunk-6XQ6C3IX.js +18 -0
- package/dist/chunk-AIDM2CH6.js +146 -0
- package/dist/chunk-ALTODDUX.js +173 -0
- package/dist/chunk-AZY2VRAE.js +63 -0
- package/dist/chunk-BS7T27VL.js +239 -0
- package/dist/chunk-CN3FCRLR.js +55 -0
- package/dist/chunk-EAXC4CQD.js +245 -0
- package/dist/chunk-EDDG2YFS.js +249 -0
- package/dist/chunk-EDKWCMA7.js +210 -0
- package/dist/{chunk-CFSRMUNC.js → chunk-EDM6DKA5.js} +2 -2
- package/dist/{chunk-EZEQQJNH.js → chunk-EIQBTF5J.js} +2 -2
- package/dist/chunk-FYT7RTVW.js +248 -0
- package/dist/{chunk-DUFH5L2F.js → chunk-INZTF6QV.js} +2 -2
- package/dist/{chunk-3AF6MZQ7.js → chunk-JVHX4JHA.js} +2 -2
- package/dist/chunk-LWEKWDLC.js +300 -0
- package/dist/chunk-OJPEBGGE.js +139 -0
- package/dist/chunk-QKOSV34V.js +16268 -0
- package/dist/chunk-QO3QE3LE.js +330 -0
- package/dist/chunk-QQKNNFFB.js +399 -0
- package/dist/chunk-RBHCV3UW.js +20 -0
- package/dist/chunk-TNH2C27F.js +252 -0
- package/dist/chunk-TNWNW666.js +133 -0
- package/dist/chunk-VBEXYQ6L.js +156 -0
- package/dist/chunk-W3ILNMLD.js +265 -0
- package/dist/chunk-WJ2ZUXL3.js +71 -0
- package/dist/{chunk-4SWTV7Z3.js → chunk-WUMDFFN3.js} +2 -2
- package/dist/{chunk-FJGNLVE4.js → chunk-X7DRYXB7.js} +2 -2
- package/dist/{chunk-PNPTKVJ4.js → chunk-XUBZKYH6.js} +24 -15
- package/dist/{chunk-MYG6PCE3.js → chunk-ZY4AFKUQ.js} +2 -2
- package/dist/index.d.ts +5 -11
- package/dist/index.js +42 -19
- package/dist/lib/mysql/cms-resource-actions.cjs +15932 -4129
- package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -1
- package/dist/lib/mysql/cms-resource-actions.d.cts +10 -25
- package/dist/lib/mysql/cms-resource-actions.d.ts +10 -25
- package/dist/lib/mysql/cms-resource-actions.js +2 -1
- package/dist/lib/mysql/context.cjs +3380 -0
- package/dist/lib/mysql/context.cjs.map +1 -0
- package/dist/lib/mysql/context.d.cts +15 -0
- package/dist/lib/mysql/context.d.ts +15 -0
- package/dist/lib/mysql/context.js +34 -0
- package/dist/lib/mysql/context.js.map +1 -0
- package/dist/lib/mysql/index.cjs +21648 -15013
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +24 -14300
- package/dist/lib/mysql/index.d.ts +24 -14300
- package/dist/lib/mysql/index.js +47 -23
- package/dist/lib/mysql/ports/auth-storage.cjs +84 -0
- package/dist/lib/mysql/ports/auth-storage.cjs.map +1 -0
- package/dist/lib/mysql/ports/auth-storage.d.cts +22 -0
- package/dist/lib/mysql/ports/auth-storage.d.ts +22 -0
- package/dist/lib/mysql/ports/auth-storage.js +8 -0
- package/dist/lib/mysql/ports/auth-storage.js.map +1 -0
- package/dist/lib/mysql/ports/catalog.cjs +16688 -0
- package/dist/lib/mysql/ports/catalog.cjs.map +1 -0
- package/dist/lib/mysql/ports/catalog.d.cts +24 -0
- package/dist/lib/mysql/ports/catalog.d.ts +24 -0
- package/dist/lib/mysql/ports/catalog.js +9 -0
- package/dist/lib/mysql/ports/catalog.js.map +1 -0
- package/dist/lib/mysql/ports/content-resource.cjs +321 -0
- package/dist/lib/mysql/ports/content-resource.cjs.map +1 -0
- package/dist/lib/mysql/ports/content-resource.d.cts +23 -0
- package/dist/lib/mysql/ports/content-resource.d.ts +23 -0
- package/dist/lib/mysql/ports/content-resource.js +8 -0
- package/dist/lib/mysql/ports/content-resource.js.map +1 -0
- package/dist/lib/mysql/ports/coupon.cjs +16524 -0
- package/dist/lib/mysql/ports/coupon.cjs.map +1 -0
- package/dist/lib/mysql/ports/coupon.d.cts +22 -0
- package/dist/lib/mysql/ports/coupon.d.ts +22 -0
- package/dist/lib/mysql/ports/coupon.js +9 -0
- package/dist/lib/mysql/ports/coupon.js.map +1 -0
- package/dist/lib/mysql/ports/entitlement.cjs +16350 -0
- package/dist/lib/mysql/ports/entitlement.cjs.map +1 -0
- package/dist/lib/mysql/ports/entitlement.d.cts +22 -0
- package/dist/lib/mysql/ports/entitlement.d.ts +22 -0
- package/dist/lib/mysql/ports/entitlement.js +9 -0
- package/dist/lib/mysql/ports/entitlement.js.map +1 -0
- package/dist/lib/mysql/ports/identity.cjs +154 -0
- package/dist/lib/mysql/ports/identity.cjs.map +1 -0
- package/dist/lib/mysql/ports/identity.d.cts +22 -0
- package/dist/lib/mysql/ports/identity.d.ts +22 -0
- package/dist/lib/mysql/ports/identity.js +8 -0
- package/dist/lib/mysql/ports/identity.js.map +1 -0
- package/dist/lib/mysql/ports/merchant.cjs +194 -0
- package/dist/lib/mysql/ports/merchant.cjs.map +1 -0
- package/dist/lib/mysql/ports/merchant.d.cts +22 -0
- package/dist/lib/mysql/ports/merchant.d.ts +22 -0
- package/dist/lib/mysql/ports/merchant.js +8 -0
- package/dist/lib/mysql/ports/merchant.js.map +1 -0
- package/dist/lib/mysql/ports/organization.cjs +16426 -0
- package/dist/lib/mysql/ports/organization.cjs.map +1 -0
- package/dist/lib/mysql/ports/organization.d.cts +22 -0
- package/dist/lib/mysql/ports/organization.d.ts +22 -0
- package/dist/lib/mysql/ports/organization.js +9 -0
- package/dist/lib/mysql/ports/organization.js.map +1 -0
- package/dist/lib/mysql/ports/progress.cjs +16544 -0
- package/dist/lib/mysql/ports/progress.cjs.map +1 -0
- package/dist/lib/mysql/ports/progress.d.cts +22 -0
- package/dist/lib/mysql/ports/progress.d.ts +22 -0
- package/dist/lib/mysql/ports/progress.js +9 -0
- package/dist/lib/mysql/ports/progress.js.map +1 -0
- package/dist/lib/mysql/ports/purchase.cjs +16609 -0
- package/dist/lib/mysql/ports/purchase.cjs.map +1 -0
- package/dist/lib/mysql/ports/purchase.d.cts +23 -0
- package/dist/lib/mysql/ports/purchase.d.ts +23 -0
- package/dist/lib/mysql/ports/purchase.js +9 -0
- package/dist/lib/mysql/ports/purchase.js.map +1 -0
- package/dist/lib/mysql/ports/subscription.cjs +76 -0
- package/dist/lib/mysql/ports/subscription.cjs.map +1 -0
- package/dist/lib/mysql/ports/subscription.d.cts +22 -0
- package/dist/lib/mysql/ports/subscription.d.ts +22 -0
- package/dist/lib/mysql/ports/subscription.js +8 -0
- package/dist/lib/mysql/ports/subscription.js.map +1 -0
- package/dist/lib/mysql/schema.cjs +3373 -0
- package/dist/lib/mysql/schema.cjs.map +1 -0
- package/dist/lib/mysql/schema.d.cts +14385 -0
- package/dist/lib/mysql/schema.d.ts +14385 -0
- package/dist/lib/mysql/schema.js +35 -0
- package/dist/lib/mysql/schema.js.map +1 -0
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +6 -6
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.js +7 -7
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +7 -7
- package/dist/lib/mysql/schemas/auth/personal-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/personal-access-token.js +7 -7
- package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/profiles.js +6 -6
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +7 -7
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +6 -6
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +7 -7
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +6 -6
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.js +6 -6
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +6 -6
- package/dist/lib/mysql/schemas/auth/users.cjs +5 -1
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.js +6 -6
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.js +6 -6
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +6 -6
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +6 -6
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.js +6 -6
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.js +6 -6
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +7 -7
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +11 -2
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.js +6 -6
- package/dist/lib/mysql/schemas/commerce/subscription.cjs +6 -1
- package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/subscription.js +6 -6
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +7 -7
- package/dist/lib/mysql/schemas/communication/comment.cjs +5 -1
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.js +6 -6
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +5 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +6 -6
- package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/question-response.js +7 -7
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +5 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +6 -6
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.js +6 -6
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +6 -6
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +6 -6
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.js +6 -6
- package/dist/lib/mysql/schemas/content/content-resource.cjs +5 -1
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +6 -6
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.js +6 -6
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.js +6 -6
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +11 -2
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
- package/dist/lib/mysql/schemas/entitlements/entitlement.js +7 -7
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +11 -2
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +6 -6
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +11 -2
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +16 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +16 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.js +6 -6
- package/dist/lib/mysql/schemas/org/organizations.cjs +11 -2
- package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organizations.d.cts +16 -0
- package/dist/lib/mysql/schemas/org/organizations.d.ts +16 -0
- package/dist/lib/mysql/schemas/org/organizations.js +6 -6
- package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs +40 -0
- package/dist/lib/mysql/workflows/content-resource-workflow-utils.cjs.map +1 -0
- package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.cts +4 -0
- package/dist/lib/mysql/workflows/content-resource-workflow-utils.d.ts +4 -0
- package/dist/lib/mysql/workflows/content-resource-workflow-utils.js +10 -0
- package/dist/lib/mysql/workflows/content-resource-workflow-utils.js.map +1 -0
- package/dist/lib/mysql/workflows/create-cohort.cjs +184 -0
- package/dist/lib/mysql/workflows/create-cohort.cjs.map +1 -0
- package/dist/lib/mysql/workflows/create-cohort.d.cts +24 -0
- package/dist/lib/mysql/workflows/create-cohort.d.ts +24 -0
- package/dist/lib/mysql/workflows/create-cohort.js +9 -0
- package/dist/lib/mysql/workflows/create-cohort.js.map +1 -0
- package/dist/lib/mysql/workflows/create-event-series.cjs +283 -0
- package/dist/lib/mysql/workflows/create-event-series.cjs.map +1 -0
- package/dist/lib/mysql/workflows/create-event-series.d.cts +24 -0
- package/dist/lib/mysql/workflows/create-event-series.d.ts +24 -0
- package/dist/lib/mysql/workflows/create-event-series.js +9 -0
- package/dist/lib/mysql/workflows/create-event-series.js.map +1 -0
- package/dist/lib/mysql/workflows/create-event.cjs +194 -0
- package/dist/lib/mysql/workflows/create-event.cjs.map +1 -0
- package/dist/lib/mysql/workflows/create-event.d.cts +24 -0
- package/dist/lib/mysql/workflows/create-event.d.ts +24 -0
- package/dist/lib/mysql/workflows/create-event.js +9 -0
- package/dist/lib/mysql/workflows/create-event.js.map +1 -0
- package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs +231 -0
- package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.cjs.map +1 -0
- package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.cts +22 -0
- package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.d.ts +22 -0
- package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js +8 -0
- package/dist/lib/mysql/workflows/create-merchant-charge-and-purchase.js.map +1 -0
- package/dist/lib/mysql/workflows/create-workshop.cjs +286 -0
- package/dist/lib/mysql/workflows/create-workshop.cjs.map +1 -0
- package/dist/lib/mysql/workflows/create-workshop.d.cts +24 -0
- package/dist/lib/mysql/workflows/create-workshop.d.ts +24 -0
- package/dist/lib/mysql/workflows/create-workshop.js +9 -0
- package/dist/lib/mysql/workflows/create-workshop.js.map +1 -0
- package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs +130 -0
- package/dist/lib/mysql/workflows/redeem-full-price-coupon.cjs.map +1 -0
- package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.cts +24 -0
- package/dist/lib/mysql/workflows/redeem-full-price-coupon.d.ts +24 -0
- package/dist/lib/mysql/workflows/redeem-full-price-coupon.js +8 -0
- package/dist/lib/mysql/workflows/redeem-full-price-coupon.js.map +1 -0
- package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs +95 -0
- package/dist/lib/mysql/workflows/transfer-purchase-to-user.cjs.map +1 -0
- package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.cts +30 -0
- package/dist/lib/mysql/workflows/transfer-purchase-to-user.d.ts +30 -0
- package/dist/lib/mysql/workflows/transfer-purchase-to-user.js +8 -0
- package/dist/lib/mysql/workflows/transfer-purchase-to-user.js.map +1 -0
- package/dist/lib/utils.d.cts +1 -10
- package/dist/lib/utils.d.ts +1 -10
- package/dist/types.d.ts +14 -0
- package/dist/types.js +1 -0
- package/package.json +9 -5
- package/src/index.ts +3 -2
- package/src/lib/mysql/cms-resource-actions.ts +37 -0
- package/src/lib/mysql/context.ts +20 -0
- package/src/lib/mysql/index.ts +118 -4872
- package/src/lib/mysql/ports/auth-storage.ts +139 -0
- package/src/lib/mysql/ports/catalog.ts +610 -0
- package/src/lib/mysql/ports/content-resource.ts +442 -0
- package/src/lib/mysql/ports/coupon.ts +387 -0
- package/src/lib/mysql/ports/entitlement.ts +96 -0
- package/src/lib/mysql/ports/identity.ts +160 -0
- package/src/lib/mysql/ports/merchant.ts +274 -0
- package/src/lib/mysql/ports/organization.ts +216 -0
- package/src/lib/mysql/ports/progress.ts +366 -0
- package/src/lib/mysql/ports/purchase.ts +517 -0
- package/src/lib/mysql/ports/subscription.ts +93 -0
- package/src/lib/mysql/schema.ts +374 -0
- package/src/lib/mysql/schemas/org/organization-memberships.ts +7 -0
- package/src/lib/mysql/schemas/org/organizations.ts +8 -0
- package/src/lib/mysql/workflows/content-resource-workflow-utils.ts +22 -0
- package/src/lib/mysql/workflows/create-cohort.ts +239 -0
- package/src/lib/mysql/workflows/create-event-series.ts +384 -0
- package/src/lib/mysql/workflows/create-event.ts +232 -0
- package/src/lib/mysql/workflows/create-merchant-charge-and-purchase.ts +365 -0
- package/src/lib/mysql/workflows/create-workshop.ts +372 -0
- package/src/lib/mysql/workflows/redeem-full-price-coupon.ts +179 -0
- package/src/lib/mysql/workflows/transfer-purchase-to-user.ts +142 -0
- package/src/types.ts +33 -0
- package/dist/authjs.d.ts +0 -27
- package/dist/authjs.js +0 -1
- package/dist/chunk-25RKHMRM.js +0 -8729
- package/dist/chunk-2AW5KYAK.js +0 -101
- package/dist/chunk-3EF5ZXLG.js +0 -101
- package/dist/chunk-7FBSP3VD.js +0 -78
- package/dist/chunk-AP5HBIV4.js +0 -112
- package/dist/chunk-F56AI52P.js +0 -49
- package/dist/chunk-HAQZSRJL.js +0 -4696
- package/dist/chunk-I2U5PTWN.js +0 -79
- package/dist/chunk-IBQGXFEX.js +0 -8729
- package/dist/chunk-PJORQUQP.js +0 -58
- package/dist/chunk-W6RPAAKG.js +0 -2144
- package/dist/chunk-WKJTU24D.js +0 -88
- package/dist/chunk-WWBSNLRC.js +0 -63
- package/src/authjs.ts +0 -34
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import {
|
|
2
|
+
external_exports
|
|
3
|
+
} from "./chunk-QKOSV34V.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-2X5XVNDN.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/mysql/ports/catalog.ts
|
|
9
|
+
import slugify from "@sindresorhus/slugify";
|
|
10
|
+
import { and, eq, inArray, or, sql } from "drizzle-orm";
|
|
11
|
+
import { customAlphabet } from "nanoid";
|
|
12
|
+
import { v4 } from "uuid";
|
|
13
|
+
import { merchantPriceSchema, merchantProductSchema, priceSchema, productSchema, upgradableProductSchema } from "@coursebuilder/core/schemas";
|
|
14
|
+
import { ContentResourceProductSchema, ContentResourceSchema } from "@coursebuilder/core/schemas/content-resource-schema";
|
|
15
|
+
import { merchantAccountSchema } from "@coursebuilder/core/schemas/merchant-account-schema";
|
|
16
|
+
import { logger as baseLogger } from "@coursebuilder/utils/logger";
|
|
17
|
+
var guid = customAlphabet("1234567890abcdefghijklmnopqrstuvwxyz", 5);
|
|
18
|
+
function toError(error) {
|
|
19
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
20
|
+
}
|
|
21
|
+
__name(toError, "toError");
|
|
22
|
+
var logger = baseLogger;
|
|
23
|
+
function createCatalogPort({ client, tables }, paymentProvider) {
|
|
24
|
+
const { contentResource, contentResourceProduct, merchantAccount, merchantPrice, merchantProduct, prices, products, purchases: purchaseTable, upgradableProducts } = tables;
|
|
25
|
+
const getProduct = /* @__PURE__ */ __name(async (productSlugOrId, withResources = true) => {
|
|
26
|
+
if (!productSlugOrId) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const productData = await client.query.products.findFirst({
|
|
31
|
+
where: and(or(eq(sql`JSON_EXTRACT (${products.fields}, "$.slug")`, `${productSlugOrId}`), eq(products.id, productSlugOrId))),
|
|
32
|
+
with: {
|
|
33
|
+
price: true,
|
|
34
|
+
...withResources && {
|
|
35
|
+
resources: {
|
|
36
|
+
with: {
|
|
37
|
+
resource: {
|
|
38
|
+
with: {
|
|
39
|
+
resources: true
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const parsedProduct = productSchema.safeParse(productData);
|
|
48
|
+
if (!parsedProduct.success) {
|
|
49
|
+
logger.error(parsedProduct.error, {
|
|
50
|
+
event: "adapter.product.parse_failed",
|
|
51
|
+
productId: productData?.id,
|
|
52
|
+
productSlugOrId
|
|
53
|
+
});
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return parsedProduct.data;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
logger.error(toError(e), {
|
|
59
|
+
event: "adapter.product.lookup.failed",
|
|
60
|
+
productSlugOrId,
|
|
61
|
+
withResources
|
|
62
|
+
});
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}, "getProduct");
|
|
66
|
+
return {
|
|
67
|
+
getProduct,
|
|
68
|
+
getUpgradableProducts: async (options) => {
|
|
69
|
+
const { upgradableFromId, upgradableToId } = options;
|
|
70
|
+
return external_exports.array(upgradableProductSchema).parse(await client.query.upgradableProducts.findMany({
|
|
71
|
+
where: and(eq(upgradableProducts.upgradableFromId, upgradableFromId), eq(upgradableProducts.upgradableToId, upgradableToId))
|
|
72
|
+
}));
|
|
73
|
+
},
|
|
74
|
+
async availableUpgradesForProduct(purchases, productId) {
|
|
75
|
+
const previousPurchaseProductIds = purchases.map(({ productId: productId2 }) => productId2);
|
|
76
|
+
if (previousPurchaseProductIds.length > 0) {
|
|
77
|
+
return client.query.upgradableProducts.findMany({
|
|
78
|
+
where: and(eq(upgradableProducts.upgradableToId, productId), inArray(upgradableProducts.upgradableFromId, previousPurchaseProductIds))
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return [];
|
|
82
|
+
},
|
|
83
|
+
async getPrice(productId) {
|
|
84
|
+
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
85
|
+
where: eq(prices.productId, productId)
|
|
86
|
+
}));
|
|
87
|
+
},
|
|
88
|
+
async getPriceForProduct(productId) {
|
|
89
|
+
return priceSchema.nullable().parse(await client.query.prices.findFirst({
|
|
90
|
+
where: eq(prices.productId, productId)
|
|
91
|
+
}));
|
|
92
|
+
},
|
|
93
|
+
async archiveProduct(productId) {
|
|
94
|
+
if (!paymentProvider)
|
|
95
|
+
throw new Error("Payment provider not found");
|
|
96
|
+
const product = await getProduct(productId);
|
|
97
|
+
if (!product) {
|
|
98
|
+
throw new Error(`Product not found for id (${productId})`);
|
|
99
|
+
}
|
|
100
|
+
if (!product.price) {
|
|
101
|
+
throw new Error(`Product has no price`);
|
|
102
|
+
}
|
|
103
|
+
await client.update(products).set({
|
|
104
|
+
status: 0,
|
|
105
|
+
name: `${product.name} (Archived)`
|
|
106
|
+
}).where(eq(products.id, productId));
|
|
107
|
+
await client.update(prices).set({
|
|
108
|
+
status: 0,
|
|
109
|
+
nickname: `${product.name} (Archived)`
|
|
110
|
+
}).where(eq(prices.productId, productId));
|
|
111
|
+
await client.update(merchantProduct).set({
|
|
112
|
+
status: 0
|
|
113
|
+
}).where(eq(merchantProduct.productId, productId));
|
|
114
|
+
await client.update(merchantPrice).set({
|
|
115
|
+
status: 0
|
|
116
|
+
}).where(eq(merchantPrice.priceId, product.price.id));
|
|
117
|
+
const currentMerchantProduct = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
118
|
+
where: eq(merchantProduct.productId, productId)
|
|
119
|
+
}));
|
|
120
|
+
if (!currentMerchantProduct || !currentMerchantProduct.identifier) {
|
|
121
|
+
throw new Error(`Merchant product not found for id (${productId})`);
|
|
122
|
+
}
|
|
123
|
+
await paymentProvider.updateProduct(currentMerchantProduct.identifier, {
|
|
124
|
+
active: false
|
|
125
|
+
});
|
|
126
|
+
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
127
|
+
where: eq(merchantPrice.priceId, product.price.id)
|
|
128
|
+
}));
|
|
129
|
+
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
130
|
+
throw new Error(`Merchant price not found for id (${productId})`);
|
|
131
|
+
}
|
|
132
|
+
await paymentProvider.updatePrice(currentMerchantPrice.identifier, {
|
|
133
|
+
active: false
|
|
134
|
+
});
|
|
135
|
+
return getProduct(productId);
|
|
136
|
+
},
|
|
137
|
+
async updateProduct(input) {
|
|
138
|
+
if (!paymentProvider)
|
|
139
|
+
throw new Error("Payment provider not found");
|
|
140
|
+
const currentProduct = await getProduct(input.id);
|
|
141
|
+
if (!currentProduct) {
|
|
142
|
+
throw new Error(`Product not found`);
|
|
143
|
+
}
|
|
144
|
+
if (!currentProduct.price) {
|
|
145
|
+
throw new Error(`Product has no price`);
|
|
146
|
+
}
|
|
147
|
+
const merchantProduct2 = merchantProductSchema.nullish().parse(await client.query.merchantProduct.findFirst({
|
|
148
|
+
where: (merchantProduct3, { eq: eq2 }) => eq2(merchantProduct3.productId, input.id)
|
|
149
|
+
}));
|
|
150
|
+
if (!merchantProduct2 || !merchantProduct2.identifier) {
|
|
151
|
+
throw new Error(`Merchant product not found`);
|
|
152
|
+
}
|
|
153
|
+
const stripeProduct = await paymentProvider.getProduct(merchantProduct2.identifier);
|
|
154
|
+
const priceChanged = currentProduct.price.unitAmount.toString() !== input.price?.unitAmount.toString();
|
|
155
|
+
const currentMerchantPrice = merchantPriceSchema.nullish().parse(await client.query.merchantPrice.findFirst({
|
|
156
|
+
where: (merchantPrice2, { eq: eq2, and: and2 }) => and2(eq2(merchantPrice2.merchantProductId, merchantProduct2.id), eq2(merchantPrice2.status, 1))
|
|
157
|
+
}));
|
|
158
|
+
if (!currentMerchantPrice || !currentMerchantPrice.identifier) {
|
|
159
|
+
throw new Error(`Merchant price not found`);
|
|
160
|
+
}
|
|
161
|
+
const currentStripePrice = await paymentProvider.getPrice(currentMerchantPrice.identifier);
|
|
162
|
+
const membershipTypeChanged = currentProduct.type !== input.type && (input.type === "membership" || currentProduct.type === "membership");
|
|
163
|
+
const billingIntervalChanged = input.type === "membership" && currentProduct.type === "membership" && currentProduct.fields?.billingInterval !== input.fields?.billingInterval;
|
|
164
|
+
const isMembership = input.type === "membership";
|
|
165
|
+
const stripePriceMismatch = isMembership !== !!currentStripePrice.recurring;
|
|
166
|
+
const needsPriceRecreation = priceChanged || membershipTypeChanged || billingIntervalChanged || stripePriceMismatch;
|
|
167
|
+
if (needsPriceRecreation) {
|
|
168
|
+
const billingInterval = input.fields?.billingInterval || "year";
|
|
169
|
+
const priceParams = {
|
|
170
|
+
product: stripeProduct.id,
|
|
171
|
+
unit_amount: Math.floor(Number(input.price?.unitAmount || 0) * 100),
|
|
172
|
+
currency: "usd",
|
|
173
|
+
metadata: {
|
|
174
|
+
slug: input.fields.slug
|
|
175
|
+
},
|
|
176
|
+
active: true,
|
|
177
|
+
// Membership products get recurring billing
|
|
178
|
+
...input.type === "membership" && {
|
|
179
|
+
recurring: {
|
|
180
|
+
interval: billingInterval
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
logger.debug("adapter.product.price_recreation.started", {
|
|
185
|
+
billingInterval,
|
|
186
|
+
currency: priceParams.currency,
|
|
187
|
+
currentMerchantPriceId: currentMerchantPrice.id,
|
|
188
|
+
isMembership: input.type === "membership",
|
|
189
|
+
merchantProductId: merchantProduct2.id,
|
|
190
|
+
productId: input.id,
|
|
191
|
+
productSlug: input.fields.slug,
|
|
192
|
+
stripeProductId: stripeProduct.id,
|
|
193
|
+
unitAmount: priceParams.unit_amount
|
|
194
|
+
});
|
|
195
|
+
const newStripePrice = await paymentProvider.createPrice(priceParams);
|
|
196
|
+
await paymentProvider.updateProduct(stripeProduct.id, {
|
|
197
|
+
default_price: newStripePrice.id
|
|
198
|
+
});
|
|
199
|
+
const newMerchantPriceId = `mprice_${v4()}`;
|
|
200
|
+
await client.insert(merchantPrice).values({
|
|
201
|
+
id: newMerchantPriceId,
|
|
202
|
+
merchantProductId: merchantProduct2.id,
|
|
203
|
+
merchantAccountId: merchantProduct2.merchantAccountId,
|
|
204
|
+
priceId: currentProduct.price.id,
|
|
205
|
+
status: 1,
|
|
206
|
+
identifier: newStripePrice.id
|
|
207
|
+
});
|
|
208
|
+
if (currentMerchantPrice) {
|
|
209
|
+
await client.update(merchantPrice).set({
|
|
210
|
+
status: 0
|
|
211
|
+
}).where(eq(merchantPrice.id, currentMerchantPrice.id));
|
|
212
|
+
}
|
|
213
|
+
await client.update(prices).set({
|
|
214
|
+
unitAmount: Math.floor(Number(input.price?.unitAmount || 0)).toString(),
|
|
215
|
+
nickname: input.name
|
|
216
|
+
}).where(eq(prices.id, currentProduct.price.id));
|
|
217
|
+
if (currentStripePrice) {
|
|
218
|
+
await paymentProvider.updatePrice(currentStripePrice.id, {
|
|
219
|
+
active: false
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
await paymentProvider.updateProduct(stripeProduct.id, {
|
|
224
|
+
name: input.name,
|
|
225
|
+
active: true,
|
|
226
|
+
images: input.fields.image?.url ? [
|
|
227
|
+
input.fields.image.url
|
|
228
|
+
] : void 0,
|
|
229
|
+
description: input.fields.description || "",
|
|
230
|
+
metadata: {
|
|
231
|
+
slug: input.fields.slug
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
const { image, ...fieldsNoImage } = input.fields;
|
|
235
|
+
await client.update(products).set({
|
|
236
|
+
name: input.name,
|
|
237
|
+
quantityAvailable: input.quantityAvailable,
|
|
238
|
+
status: 1,
|
|
239
|
+
fields: {
|
|
240
|
+
...fieldsNoImage,
|
|
241
|
+
...image?.url && {
|
|
242
|
+
image
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
type: input.type
|
|
246
|
+
}).where(eq(products.id, currentProduct.id));
|
|
247
|
+
return getProduct(currentProduct.id);
|
|
248
|
+
},
|
|
249
|
+
async createProduct(input) {
|
|
250
|
+
if (!paymentProvider)
|
|
251
|
+
throw new Error("Payment provider not found");
|
|
252
|
+
const merchantAccount2 = merchantAccountSchema.nullish().parse(await client.query.merchantAccount.findFirst({
|
|
253
|
+
where: (merchantAccount3, { eq: eq2 }) => eq2(merchantAccount3.label, "stripe")
|
|
254
|
+
}));
|
|
255
|
+
if (!merchantAccount2) {
|
|
256
|
+
throw new Error("Merchant account not found");
|
|
257
|
+
}
|
|
258
|
+
const hash = guid();
|
|
259
|
+
const newProductId = slugify(`product-${hash}`);
|
|
260
|
+
const newProduct = {
|
|
261
|
+
id: newProductId,
|
|
262
|
+
name: input.name,
|
|
263
|
+
status: 1,
|
|
264
|
+
type: input.type || "self-paced",
|
|
265
|
+
quantityAvailable: input.quantityAvailable,
|
|
266
|
+
fields: {
|
|
267
|
+
state: input.state || "draft",
|
|
268
|
+
visibility: input.visibility || "unlisted",
|
|
269
|
+
slug: slugify(`${input.name}-${hash}`),
|
|
270
|
+
...input.openEnrollment && {
|
|
271
|
+
openEnrollment: input.openEnrollment
|
|
272
|
+
},
|
|
273
|
+
...input.closeEnrollment && {
|
|
274
|
+
closeEnrollment: input.closeEnrollment
|
|
275
|
+
},
|
|
276
|
+
...typeof input.availableAfterDays === "number" && {
|
|
277
|
+
availableAfterDays: input.availableAfterDays
|
|
278
|
+
},
|
|
279
|
+
...typeof input.accessDurationDays === "number" && {
|
|
280
|
+
accessDurationDays: input.accessDurationDays
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
await client.insert(products).values(newProduct);
|
|
285
|
+
const priceHash = guid();
|
|
286
|
+
const newPriceId = `price-${priceHash}`;
|
|
287
|
+
await client.insert(prices).values({
|
|
288
|
+
id: newPriceId,
|
|
289
|
+
productId: newProductId,
|
|
290
|
+
unitAmount: input.price.toString(),
|
|
291
|
+
status: 1
|
|
292
|
+
});
|
|
293
|
+
const product = await getProduct(newProductId);
|
|
294
|
+
const stripeProduct = await paymentProvider.createProduct({
|
|
295
|
+
name: input.name,
|
|
296
|
+
metadata: {
|
|
297
|
+
slug: product?.fields?.slug || null
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
const stripePrice = await paymentProvider.createPrice({
|
|
301
|
+
product: stripeProduct.id,
|
|
302
|
+
unit_amount: Math.floor(Number(input.price) * 100),
|
|
303
|
+
currency: "usd",
|
|
304
|
+
nickname: input.name,
|
|
305
|
+
metadata: {
|
|
306
|
+
slug: product?.fields?.slug || null
|
|
307
|
+
},
|
|
308
|
+
// Membership products get recurring billing
|
|
309
|
+
...input.type === "membership" && {
|
|
310
|
+
recurring: {
|
|
311
|
+
interval: input.billingInterval || "year"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
const newMerchantProductId = `mproduct_${v4()}`;
|
|
316
|
+
await client.insert(merchantProduct).values({
|
|
317
|
+
id: newMerchantProductId,
|
|
318
|
+
merchantAccountId: merchantAccount2.id,
|
|
319
|
+
productId: newProductId,
|
|
320
|
+
identifier: stripeProduct.id,
|
|
321
|
+
status: 1
|
|
322
|
+
});
|
|
323
|
+
const newMerchantPriceId = `mprice_${v4()}`;
|
|
324
|
+
await client.insert(merchantPrice).values({
|
|
325
|
+
id: newMerchantPriceId,
|
|
326
|
+
merchantAccountId: merchantAccount2.id,
|
|
327
|
+
merchantProductId: newMerchantProductId,
|
|
328
|
+
priceId: newPriceId,
|
|
329
|
+
identifier: stripePrice.id,
|
|
330
|
+
status: 1
|
|
331
|
+
});
|
|
332
|
+
return product;
|
|
333
|
+
},
|
|
334
|
+
async getProductResources(productId) {
|
|
335
|
+
const contentResourceProductsForProduct = external_exports.array(ContentResourceProductSchema).nullable().parse(await client.query.contentResourceProduct.findMany({
|
|
336
|
+
where: eq(contentResourceProduct.productId, productId)
|
|
337
|
+
}));
|
|
338
|
+
if (!contentResourceProductsForProduct) {
|
|
339
|
+
return null;
|
|
340
|
+
} else {
|
|
341
|
+
const contentResources = external_exports.array(ContentResourceSchema).parse(await client.query.contentResource.findMany({
|
|
342
|
+
where: inArray(contentResource.id, contentResourceProductsForProduct.map((crp) => crp.resourceId))
|
|
343
|
+
}));
|
|
344
|
+
return contentResources;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
async pricesOfPurchasesTowardOneBundle({ userId, bundleId }) {
|
|
348
|
+
if (userId === void 0)
|
|
349
|
+
return [];
|
|
350
|
+
const canUpgradeProducts = await client.query.upgradableProducts.findMany({
|
|
351
|
+
where: eq(upgradableProducts.upgradableToId, bundleId)
|
|
352
|
+
});
|
|
353
|
+
const upgradableFrom = external_exports.array(external_exports.string()).parse(canUpgradeProducts.map((product) => {
|
|
354
|
+
return product.upgradableFromId;
|
|
355
|
+
}));
|
|
356
|
+
const purchases = await client.query.purchases.findMany({
|
|
357
|
+
where: and(eq(purchaseTable.userId, userId), inArray(purchaseTable.productId, upgradableFrom))
|
|
358
|
+
});
|
|
359
|
+
const productsPurchased = external_exports.array(external_exports.string()).parse(purchases.map((purchase) => {
|
|
360
|
+
return purchase.productId;
|
|
361
|
+
}));
|
|
362
|
+
if (productsPurchased.length === 0)
|
|
363
|
+
return [];
|
|
364
|
+
const foundPrices = await client.query.prices.findMany({
|
|
365
|
+
where: inArray(prices.productId, productsPurchased)
|
|
366
|
+
});
|
|
367
|
+
return external_exports.array(priceSchema).parse(foundPrices);
|
|
368
|
+
},
|
|
369
|
+
async addResourceToProduct(options) {
|
|
370
|
+
const { resource, productId, userId } = options;
|
|
371
|
+
const product = await getProduct(productId);
|
|
372
|
+
if (!product) {
|
|
373
|
+
throw new Error(`Product not found for id (${productId})`);
|
|
374
|
+
}
|
|
375
|
+
await client.insert(contentResourceProduct).values({
|
|
376
|
+
resourceId: resource.id,
|
|
377
|
+
productId,
|
|
378
|
+
position: product.resources?.length || 0,
|
|
379
|
+
metadata: {
|
|
380
|
+
addedBy: userId
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
const resourceProduct = await client.query.contentResourceProduct.findFirst({
|
|
384
|
+
where: eq(contentResourceProduct.resourceId, resource.id),
|
|
385
|
+
with: {
|
|
386
|
+
resource: true,
|
|
387
|
+
product: true
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
return ContentResourceProductSchema.safeParse(resourceProduct).data || null;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
__name(createCatalogPort, "createCatalogPort");
|
|
395
|
+
|
|
396
|
+
export {
|
|
397
|
+
createCatalogPort
|
|
398
|
+
};
|
|
399
|
+
//# sourceMappingURL=chunk-QQKNNFFB.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTables
|
|
3
|
+
} from "./chunk-TNH2C27F.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-2X5XVNDN.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/mysql/context.ts
|
|
9
|
+
function createMySqlContext(client, tableFn) {
|
|
10
|
+
return {
|
|
11
|
+
client,
|
|
12
|
+
tables: createTables(tableFn)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
__name(createMySqlContext, "createMySqlContext");
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
createMySqlContext
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-RBHCV3UW.js.map
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEntitlementTypesSchema
|
|
3
|
+
} from "./chunk-OFZECDCQ.js";
|
|
4
|
+
import {
|
|
5
|
+
getEntitlementRelationsSchema,
|
|
6
|
+
getEntitlementsSchema
|
|
7
|
+
} from "./chunk-X7DRYXB7.js";
|
|
8
|
+
import {
|
|
9
|
+
getLessonProgressSchema
|
|
10
|
+
} from "./chunk-CCXVDMTA.js";
|
|
11
|
+
import {
|
|
12
|
+
getResourceProgressSchema
|
|
13
|
+
} from "./chunk-WMCZWSAG.js";
|
|
14
|
+
import {
|
|
15
|
+
getUpgradableProductsRelationsSchema,
|
|
16
|
+
getUpgradableProductsSchema
|
|
17
|
+
} from "./chunk-EIQBTF5J.js";
|
|
18
|
+
import {
|
|
19
|
+
getQuestionResponseRelationsSchema,
|
|
20
|
+
getQuestionResponseSchema
|
|
21
|
+
} from "./chunk-2GW3BJE2.js";
|
|
22
|
+
import {
|
|
23
|
+
getPurchaseUserTransferRelationsSchema,
|
|
24
|
+
getPurchaseUserTransferSchema
|
|
25
|
+
} from "./chunk-JVHX4JHA.js";
|
|
26
|
+
import {
|
|
27
|
+
getVerificationTokensSchema
|
|
28
|
+
} from "./chunk-OUJPUONP.js";
|
|
29
|
+
import {
|
|
30
|
+
getMerchantEventsRelationsSchema,
|
|
31
|
+
getMerchantEventsSchema
|
|
32
|
+
} from "./chunk-SOOAUY4E.js";
|
|
33
|
+
import {
|
|
34
|
+
getRolePermissionsRelationsSchema,
|
|
35
|
+
getRolePermissionsSchema
|
|
36
|
+
} from "./chunk-EDM6DKA5.js";
|
|
37
|
+
import {
|
|
38
|
+
getSessionRelationsSchema,
|
|
39
|
+
getSessionsSchema
|
|
40
|
+
} from "./chunk-INZTF6QV.js";
|
|
41
|
+
import {
|
|
42
|
+
getDeviceAccessTokenRelationsSchema,
|
|
43
|
+
getDeviceAccessTokenSchema
|
|
44
|
+
} from "./chunk-WUMDFFN3.js";
|
|
45
|
+
import {
|
|
46
|
+
getDeviceVerificationRelationsSchema,
|
|
47
|
+
getDeviceVerificationSchema
|
|
48
|
+
} from "./chunk-ZY4AFKUQ.js";
|
|
49
|
+
import {
|
|
50
|
+
getPersonalAccessTokenRelationsSchema,
|
|
51
|
+
getPersonalAccessTokenSchema
|
|
52
|
+
} from "./chunk-33ZN7FN7.js";
|
|
53
|
+
import {
|
|
54
|
+
getAccountsRelationsSchema,
|
|
55
|
+
getAccountsSchema,
|
|
56
|
+
getCommentRelationsSchema,
|
|
57
|
+
getCommentsSchema,
|
|
58
|
+
getCommunicationPreferencesRelationsSchema,
|
|
59
|
+
getCommunicationPreferencesSchema,
|
|
60
|
+
getContentContributionRelationsSchema,
|
|
61
|
+
getContentContributionsSchema,
|
|
62
|
+
getContentResourceProductRelationsSchema,
|
|
63
|
+
getContentResourceProductSchema,
|
|
64
|
+
getContentResourceRelationsSchema,
|
|
65
|
+
getContentResourceResourceRelationsSchema,
|
|
66
|
+
getContentResourceResourceSchema,
|
|
67
|
+
getContentResourceSchema,
|
|
68
|
+
getContentResourceTagRelationsSchema,
|
|
69
|
+
getContentResourceTagSchema,
|
|
70
|
+
getContentResourceVersionRelationsSchema,
|
|
71
|
+
getContentResourceVersionSchema,
|
|
72
|
+
getCouponRelationsSchema,
|
|
73
|
+
getCouponSchema,
|
|
74
|
+
getMerchantChargeRelationsSchema,
|
|
75
|
+
getMerchantChargeSchema,
|
|
76
|
+
getMerchantSubscriptionRelationsSchema,
|
|
77
|
+
getMerchantSubscriptionSchema,
|
|
78
|
+
getOrganizationMembershipRolesRelationsSchema,
|
|
79
|
+
getOrganizationMembershipRolesSchema,
|
|
80
|
+
getOrganizationMembershipsRelationsSchema,
|
|
81
|
+
getOrganizationMembershipsSchema,
|
|
82
|
+
getOrganizationsRelationsSchema,
|
|
83
|
+
getOrganizationsSchema,
|
|
84
|
+
getPriceSchema,
|
|
85
|
+
getProductRelationsSchema2 as getProductRelationsSchema,
|
|
86
|
+
getProductSchema,
|
|
87
|
+
getProfilesRelationsSchema,
|
|
88
|
+
getProfilesSchema,
|
|
89
|
+
getPurchaseRelationsSchema,
|
|
90
|
+
getPurchaseSchema,
|
|
91
|
+
getRolesRelationsSchema,
|
|
92
|
+
getRolesSchema,
|
|
93
|
+
getSubscriptionRelationsSchema,
|
|
94
|
+
getSubscriptionSchema,
|
|
95
|
+
getTagRelationsSchema,
|
|
96
|
+
getTagSchema,
|
|
97
|
+
getTagTagRelationsSchema,
|
|
98
|
+
getTagTagSchema,
|
|
99
|
+
getUserPermissionsRelationsSchema,
|
|
100
|
+
getUserPermissionsSchema,
|
|
101
|
+
getUserPrefsRelationsSchema,
|
|
102
|
+
getUserPrefsSchema,
|
|
103
|
+
getUserRolesRelationsSchema,
|
|
104
|
+
getUserRolesSchema,
|
|
105
|
+
getUsersRelationsSchema,
|
|
106
|
+
getUsersSchema
|
|
107
|
+
} from "./chunk-XUBZKYH6.js";
|
|
108
|
+
import {
|
|
109
|
+
getContributionTypesRelationsSchema,
|
|
110
|
+
getContributionTypesSchema
|
|
111
|
+
} from "./chunk-6SJORFGN.js";
|
|
112
|
+
import {
|
|
113
|
+
getCommunicationChannelSchema
|
|
114
|
+
} from "./chunk-65H5Y4PD.js";
|
|
115
|
+
import {
|
|
116
|
+
getCommunicationPreferenceTypesSchema
|
|
117
|
+
} from "./chunk-QKFITIXC.js";
|
|
118
|
+
import {
|
|
119
|
+
getMerchantProductSchema
|
|
120
|
+
} from "./chunk-2I7NIOKI.js";
|
|
121
|
+
import {
|
|
122
|
+
getMerchantSessionSchema
|
|
123
|
+
} from "./chunk-5NNBQJUP.js";
|
|
124
|
+
import {
|
|
125
|
+
getMerchantCouponSchema
|
|
126
|
+
} from "./chunk-NON5CXDH.js";
|
|
127
|
+
import {
|
|
128
|
+
getMerchantCustomerSchema
|
|
129
|
+
} from "./chunk-SIZFEXIS.js";
|
|
130
|
+
import {
|
|
131
|
+
getMerchantAccountSchema
|
|
132
|
+
} from "./chunk-DNBW5D64.js";
|
|
133
|
+
import {
|
|
134
|
+
getMerchantPriceSchema
|
|
135
|
+
} from "./chunk-PMCOC5PM.js";
|
|
136
|
+
import {
|
|
137
|
+
getPermissionsRelationsSchema,
|
|
138
|
+
getPermissionsSchema
|
|
139
|
+
} from "./chunk-UWUDJCJM.js";
|
|
140
|
+
import {
|
|
141
|
+
__name
|
|
142
|
+
} from "./chunk-2X5XVNDN.js";
|
|
143
|
+
|
|
144
|
+
// src/lib/mysql/schema.ts
|
|
145
|
+
function getCourseBuilderSchema(mysqlTable, overrides = {}) {
|
|
146
|
+
const resolvedGetUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
|
|
147
|
+
const userRelationsOverrides = {
|
|
148
|
+
getUsersSchema: resolvedGetUsersSchema
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
accounts: getAccountsSchema(mysqlTable),
|
|
152
|
+
accountsRelations: getAccountsRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
153
|
+
permissions: getPermissionsSchema(mysqlTable),
|
|
154
|
+
permissionsRelations: getPermissionsRelationsSchema(mysqlTable),
|
|
155
|
+
rolePermissions: getRolePermissionsSchema(mysqlTable),
|
|
156
|
+
rolePermissionsRelations: getRolePermissionsRelationsSchema(mysqlTable),
|
|
157
|
+
roles: getRolesSchema(mysqlTable),
|
|
158
|
+
rolesRelations: getRolesRelationsSchema(mysqlTable),
|
|
159
|
+
sessions: getSessionsSchema(mysqlTable),
|
|
160
|
+
sessionsRelations: getSessionRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
161
|
+
userPermissions: getUserPermissionsSchema(mysqlTable),
|
|
162
|
+
userPermissionsRelations: getUserPermissionsRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
163
|
+
userRoles: getUserRolesSchema(mysqlTable),
|
|
164
|
+
userRolesRelations: getUserRolesRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
165
|
+
users: resolvedGetUsersSchema(mysqlTable),
|
|
166
|
+
usersRelations: getUsersRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
167
|
+
verificationTokens: getVerificationTokensSchema(mysqlTable),
|
|
168
|
+
coupon: getCouponSchema(mysqlTable),
|
|
169
|
+
couponRelations: getCouponRelationsSchema(mysqlTable),
|
|
170
|
+
lessonProgress: getLessonProgressSchema(mysqlTable),
|
|
171
|
+
merchantAccount: getMerchantAccountSchema(mysqlTable),
|
|
172
|
+
merchantCharge: getMerchantChargeSchema(mysqlTable),
|
|
173
|
+
merchantChargeRelations: getMerchantChargeRelationsSchema(mysqlTable),
|
|
174
|
+
merchantEvents: getMerchantEventsSchema(mysqlTable),
|
|
175
|
+
merchantEventsRelations: getMerchantEventsRelationsSchema(mysqlTable),
|
|
176
|
+
merchantCoupon: getMerchantCouponSchema(mysqlTable),
|
|
177
|
+
merchantCustomer: getMerchantCustomerSchema(mysqlTable),
|
|
178
|
+
merchantPrice: getMerchantPriceSchema(mysqlTable),
|
|
179
|
+
merchantProduct: getMerchantProductSchema(mysqlTable),
|
|
180
|
+
merchantSession: getMerchantSessionSchema(mysqlTable),
|
|
181
|
+
prices: getPriceSchema(mysqlTable),
|
|
182
|
+
products: getProductSchema(mysqlTable),
|
|
183
|
+
purchases: getPurchaseSchema(mysqlTable),
|
|
184
|
+
purchaseRelations: getPurchaseRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
185
|
+
purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
|
|
186
|
+
purchaseUserTransferRelations: getPurchaseUserTransferRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
187
|
+
communicationChannel: getCommunicationChannelSchema(mysqlTable),
|
|
188
|
+
communicationPreferenceTypes: getCommunicationPreferenceTypesSchema(mysqlTable),
|
|
189
|
+
communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
|
|
190
|
+
communicationPreferencesRelations: getCommunicationPreferencesRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
191
|
+
contentContributions: getContentContributionsSchema(mysqlTable),
|
|
192
|
+
contentContributionRelations: getContentContributionRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
193
|
+
contentResource: getContentResourceSchema(mysqlTable),
|
|
194
|
+
contentResourceVersion: getContentResourceVersionSchema(mysqlTable),
|
|
195
|
+
contentResourceVersionRelations: getContentResourceVersionRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
196
|
+
contentResourceRelations: getContentResourceRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
197
|
+
contentResourceResource: getContentResourceResourceSchema(mysqlTable),
|
|
198
|
+
contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
|
|
199
|
+
contentResourceTag: getContentResourceTagSchema(mysqlTable),
|
|
200
|
+
contentResourceTagRelations: getContentResourceTagRelationsSchema(mysqlTable),
|
|
201
|
+
contributionTypes: getContributionTypesSchema(mysqlTable),
|
|
202
|
+
contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
|
|
203
|
+
resourceProgress: getResourceProgressSchema(mysqlTable),
|
|
204
|
+
questionResponse: getQuestionResponseSchema(mysqlTable),
|
|
205
|
+
questionResponseRelations: getQuestionResponseRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
206
|
+
upgradableProducts: getUpgradableProductsSchema(mysqlTable),
|
|
207
|
+
upgradableProductsRelations: getUpgradableProductsRelationsSchema(mysqlTable),
|
|
208
|
+
contentResourceProduct: getContentResourceProductSchema(mysqlTable),
|
|
209
|
+
contentResourceProductRelations: getContentResourceProductRelationsSchema(mysqlTable),
|
|
210
|
+
productRelations: getProductRelationsSchema(mysqlTable),
|
|
211
|
+
comments: getCommentsSchema(mysqlTable),
|
|
212
|
+
commentsRelations: getCommentRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
213
|
+
deviceVerifications: getDeviceVerificationSchema(mysqlTable),
|
|
214
|
+
deviceVerificationRelations: getDeviceVerificationRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
215
|
+
deviceAccessToken: getDeviceAccessTokenSchema(mysqlTable),
|
|
216
|
+
deviceAccessTokenRelations: getDeviceAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
217
|
+
personalAccessToken: getPersonalAccessTokenSchema(mysqlTable),
|
|
218
|
+
personalAccessTokenRelations: getPersonalAccessTokenRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
219
|
+
tag: getTagSchema(mysqlTable),
|
|
220
|
+
tagRelations: getTagRelationsSchema(mysqlTable),
|
|
221
|
+
tagTag: getTagTagSchema(mysqlTable),
|
|
222
|
+
tagTagRelations: getTagTagRelationsSchema(mysqlTable),
|
|
223
|
+
userPrefs: getUserPrefsSchema(mysqlTable),
|
|
224
|
+
userPrefsRelations: getUserPrefsRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
225
|
+
organization: getOrganizationsSchema(mysqlTable),
|
|
226
|
+
organizationRelations: getOrganizationsRelationsSchema(mysqlTable),
|
|
227
|
+
organizationMemberships: getOrganizationMembershipsSchema(mysqlTable),
|
|
228
|
+
organizationMembershipRelations: getOrganizationMembershipsRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
229
|
+
organizationMembershipRoles: getOrganizationMembershipRolesSchema(mysqlTable),
|
|
230
|
+
organizationMembershipRolesRelations: getOrganizationMembershipRolesRelationsSchema(mysqlTable),
|
|
231
|
+
merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
|
|
232
|
+
merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
|
|
233
|
+
subscription: getSubscriptionSchema(mysqlTable),
|
|
234
|
+
subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
|
|
235
|
+
profiles: getProfilesSchema(mysqlTable),
|
|
236
|
+
profilesRelations: getProfilesRelationsSchema(mysqlTable, userRelationsOverrides),
|
|
237
|
+
entitlementTypes: getEntitlementTypesSchema(mysqlTable),
|
|
238
|
+
entitlements: getEntitlementsSchema(mysqlTable),
|
|
239
|
+
entitlementsRelations: getEntitlementRelationsSchema(mysqlTable, userRelationsOverrides)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
__name(getCourseBuilderSchema, "getCourseBuilderSchema");
|
|
243
|
+
function createTables(mySqlTable) {
|
|
244
|
+
return getCourseBuilderSchema(mySqlTable);
|
|
245
|
+
}
|
|
246
|
+
__name(createTables, "createTables");
|
|
247
|
+
|
|
248
|
+
export {
|
|
249
|
+
getCourseBuilderSchema,
|
|
250
|
+
createTables
|
|
251
|
+
};
|
|
252
|
+
//# sourceMappingURL=chunk-TNH2C27F.js.map
|