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