@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
|
@@ -0,0 +1,2122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getContributionTypesSchema
|
|
3
|
+
} from "./chunk-MP4CUWYC.js";
|
|
4
|
+
import {
|
|
5
|
+
getCommunicationChannelSchema
|
|
6
|
+
} from "./chunk-WJWJ6E5Y.js";
|
|
7
|
+
import {
|
|
8
|
+
getCommunicationPreferenceTypesSchema
|
|
9
|
+
} from "./chunk-EHRARBRS.js";
|
|
10
|
+
import {
|
|
11
|
+
getMerchantSessionSchema
|
|
12
|
+
} from "./chunk-BLDW3QUS.js";
|
|
13
|
+
import {
|
|
14
|
+
getMerchantAccountSchema
|
|
15
|
+
} from "./chunk-DKJO4Y3K.js";
|
|
16
|
+
import {
|
|
17
|
+
getMerchantCouponSchema
|
|
18
|
+
} from "./chunk-WPJZAYX7.js";
|
|
19
|
+
import {
|
|
20
|
+
getMerchantCustomerSchema
|
|
21
|
+
} from "./chunk-6MRFUIH5.js";
|
|
22
|
+
import {
|
|
23
|
+
getMerchantPriceSchema
|
|
24
|
+
} from "./chunk-MGZMGDQ5.js";
|
|
25
|
+
import {
|
|
26
|
+
getMerchantProductSchema
|
|
27
|
+
} from "./chunk-KPBVZ44W.js";
|
|
28
|
+
import {
|
|
29
|
+
getPermissionsSchema
|
|
30
|
+
} from "./chunk-LZHZDFNZ.js";
|
|
31
|
+
import {
|
|
32
|
+
__name
|
|
33
|
+
} from "./chunk-H736K5TN.js";
|
|
34
|
+
|
|
35
|
+
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
36
|
+
import { relations as relations27 } from "drizzle-orm";
|
|
37
|
+
import { boolean as boolean7, index as index27, primaryKey as primaryKey17, timestamp as timestamp26, varchar as varchar27 } from "drizzle-orm/mysql-core";
|
|
38
|
+
|
|
39
|
+
// src/lib/mysql/schemas/auth/roles.ts
|
|
40
|
+
import { relations } from "drizzle-orm";
|
|
41
|
+
import { boolean, index, text, timestamp, uniqueIndex, varchar } from "drizzle-orm/mysql-core";
|
|
42
|
+
function getRolesSchema(mysqlTable) {
|
|
43
|
+
return mysqlTable("Role", {
|
|
44
|
+
id: varchar("id", {
|
|
45
|
+
length: 255
|
|
46
|
+
}).notNull().primaryKey(),
|
|
47
|
+
organizationId: varchar("organizationId", {
|
|
48
|
+
length: 191
|
|
49
|
+
}),
|
|
50
|
+
name: varchar("name", {
|
|
51
|
+
length: 255
|
|
52
|
+
}).notNull(),
|
|
53
|
+
description: text("description"),
|
|
54
|
+
active: boolean("active").notNull().default(true),
|
|
55
|
+
createdAt: timestamp("createdAt", {
|
|
56
|
+
mode: "date",
|
|
57
|
+
fsp: 3
|
|
58
|
+
}).defaultNow(),
|
|
59
|
+
updatedAt: timestamp("updatedAt", {
|
|
60
|
+
mode: "date",
|
|
61
|
+
fsp: 3
|
|
62
|
+
}).defaultNow(),
|
|
63
|
+
deletedAt: timestamp("deletedAt", {
|
|
64
|
+
mode: "date",
|
|
65
|
+
fsp: 3
|
|
66
|
+
})
|
|
67
|
+
}, (role) => ({
|
|
68
|
+
nameIdx: index("name_idx").on(role.name),
|
|
69
|
+
organizationIdIdx: index("organizationId_idx").on(role.organizationId),
|
|
70
|
+
uniqueNamePerOrg: uniqueIndex("unique_name_per_org").on(role.organizationId, role.name)
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
__name(getRolesSchema, "getRolesSchema");
|
|
74
|
+
function getRolesRelationsSchema(mysqlTable) {
|
|
75
|
+
const roles = getRolesSchema(mysqlTable);
|
|
76
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
77
|
+
return relations(roles, ({ many }) => ({
|
|
78
|
+
userRoles: many(userRoles, {
|
|
79
|
+
relationName: "role"
|
|
80
|
+
})
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
__name(getRolesRelationsSchema, "getRolesRelationsSchema");
|
|
84
|
+
|
|
85
|
+
// src/lib/mysql/schemas/auth/users.ts
|
|
86
|
+
import { relations as relations26, sql as sql20 } from "drizzle-orm";
|
|
87
|
+
import { index as index26, json as json17, timestamp as timestamp25, varchar as varchar26 } from "drizzle-orm/mysql-core";
|
|
88
|
+
|
|
89
|
+
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
90
|
+
import { relations as relations19, sql as sql16 } from "drizzle-orm";
|
|
91
|
+
import { decimal as decimal3, index as index19, json as json13, primaryKey as primaryKey12, timestamp as timestamp19, unique as unique4, varchar as varchar19 } from "drizzle-orm/mysql-core";
|
|
92
|
+
|
|
93
|
+
// src/lib/mysql/schemas/org/organization-memberships.ts
|
|
94
|
+
import { relations as relations17, sql as sql14 } from "drizzle-orm";
|
|
95
|
+
import { index as index17, json as json11, timestamp as timestamp17, varchar as varchar17 } from "drizzle-orm/mysql-core";
|
|
96
|
+
|
|
97
|
+
// src/lib/mysql/schemas/org/organization-membership-roles.ts
|
|
98
|
+
import { relations as relations16 } from "drizzle-orm";
|
|
99
|
+
import { boolean as boolean3, index as index16, primaryKey as primaryKey10, timestamp as timestamp16, varchar as varchar16 } from "drizzle-orm/mysql-core";
|
|
100
|
+
|
|
101
|
+
// src/lib/mysql/schemas/org/organizations.ts
|
|
102
|
+
import { relations as relations15, sql as sql13 } from "drizzle-orm";
|
|
103
|
+
import { index as index15, json as json10, timestamp as timestamp15, varchar as varchar15 } from "drizzle-orm/mysql-core";
|
|
104
|
+
|
|
105
|
+
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
106
|
+
import { relations as relations14, sql as sql12 } from "drizzle-orm";
|
|
107
|
+
import { index as index14, json as json9, primaryKey as primaryKey9, timestamp as timestamp14, varchar as varchar14 } from "drizzle-orm/mysql-core";
|
|
108
|
+
|
|
109
|
+
// src/lib/mysql/schemas/commerce/merchant-subscription.ts
|
|
110
|
+
import { relations as relations3, sql as sql2 } from "drizzle-orm";
|
|
111
|
+
import { index as index3, int as int2, primaryKey as primaryKey2, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
|
|
112
|
+
|
|
113
|
+
// src/lib/mysql/schemas/commerce/merchant-charge.ts
|
|
114
|
+
import { relations as relations2, sql } from "drizzle-orm";
|
|
115
|
+
import { index as index2, int, primaryKey, timestamp as timestamp2, unique, varchar as varchar2 } from "drizzle-orm/mysql-core";
|
|
116
|
+
function getMerchantChargeSchema(mysqlTable) {
|
|
117
|
+
return mysqlTable("MerchantCharge", {
|
|
118
|
+
id: varchar2("id", {
|
|
119
|
+
length: 191
|
|
120
|
+
}).notNull(),
|
|
121
|
+
organizationId: varchar2("organizationId", {
|
|
122
|
+
length: 191
|
|
123
|
+
}),
|
|
124
|
+
status: int("status").default(0).notNull(),
|
|
125
|
+
identifier: varchar2("identifier", {
|
|
126
|
+
length: 191
|
|
127
|
+
}).notNull(),
|
|
128
|
+
userId: varchar2("userId", {
|
|
129
|
+
length: 191
|
|
130
|
+
}).notNull(),
|
|
131
|
+
merchantAccountId: varchar2("merchantAccountId", {
|
|
132
|
+
length: 191
|
|
133
|
+
}).notNull(),
|
|
134
|
+
merchantProductId: varchar2("merchantProductId", {
|
|
135
|
+
length: 191
|
|
136
|
+
}).notNull(),
|
|
137
|
+
merchantSubscriptionId: varchar2("merchantSubscriptionId", {
|
|
138
|
+
length: 191
|
|
139
|
+
}),
|
|
140
|
+
createdAt: timestamp2("createdAt", {
|
|
141
|
+
mode: "date",
|
|
142
|
+
fsp: 3
|
|
143
|
+
}).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
144
|
+
merchantCustomerId: varchar2("merchantCustomerId", {
|
|
145
|
+
length: 191
|
|
146
|
+
}).notNull()
|
|
147
|
+
}, (table) => {
|
|
148
|
+
return {
|
|
149
|
+
merchantChargeId: primaryKey({
|
|
150
|
+
columns: [
|
|
151
|
+
table.id
|
|
152
|
+
],
|
|
153
|
+
name: "MerchantCharge_id"
|
|
154
|
+
}),
|
|
155
|
+
merchantChargeIdentifierKey: unique("MerchantCharge_identifier_key").on(table.identifier),
|
|
156
|
+
merchantSubscriptionIdIdx: index2("merchantSubscriptionId_idx").on(table.merchantSubscriptionId),
|
|
157
|
+
organizationIdIdx: index2("organizationId_idx").on(table.organizationId)
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
__name(getMerchantChargeSchema, "getMerchantChargeSchema");
|
|
162
|
+
function getMerchantChargeRelationsSchema(mysqlTable) {
|
|
163
|
+
const merchantCharge = getMerchantChargeSchema(mysqlTable);
|
|
164
|
+
const merchantAccount = getMerchantAccountSchema(mysqlTable);
|
|
165
|
+
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
166
|
+
const merchantCustomer = getMerchantCustomerSchema(mysqlTable);
|
|
167
|
+
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
|
|
168
|
+
return relations2(merchantCharge, ({ one }) => ({
|
|
169
|
+
merchantAccount: one(merchantAccount, {
|
|
170
|
+
fields: [
|
|
171
|
+
merchantCharge.merchantAccountId
|
|
172
|
+
],
|
|
173
|
+
references: [
|
|
174
|
+
merchantAccount.id
|
|
175
|
+
],
|
|
176
|
+
relationName: "merchantAccount"
|
|
177
|
+
}),
|
|
178
|
+
merchantProduct: one(merchantProduct, {
|
|
179
|
+
fields: [
|
|
180
|
+
merchantCharge.merchantProductId
|
|
181
|
+
],
|
|
182
|
+
references: [
|
|
183
|
+
merchantProduct.id
|
|
184
|
+
],
|
|
185
|
+
relationName: "merchantProduct"
|
|
186
|
+
}),
|
|
187
|
+
merchantCustomer: one(merchantCustomer, {
|
|
188
|
+
fields: [
|
|
189
|
+
merchantCharge.merchantCustomerId
|
|
190
|
+
],
|
|
191
|
+
references: [
|
|
192
|
+
merchantCustomer.id
|
|
193
|
+
],
|
|
194
|
+
relationName: "merchantCustomer"
|
|
195
|
+
}),
|
|
196
|
+
merchantSubscription: one(merchantSubscription, {
|
|
197
|
+
fields: [
|
|
198
|
+
merchantCharge.merchantSubscriptionId
|
|
199
|
+
],
|
|
200
|
+
references: [
|
|
201
|
+
merchantSubscription.id
|
|
202
|
+
],
|
|
203
|
+
relationName: "merchantSubscription"
|
|
204
|
+
})
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
207
|
+
__name(getMerchantChargeRelationsSchema, "getMerchantChargeRelationsSchema");
|
|
208
|
+
|
|
209
|
+
// src/lib/mysql/schemas/commerce/merchant-subscription.ts
|
|
210
|
+
function getMerchantSubscriptionSchema(mysqlTable) {
|
|
211
|
+
return mysqlTable("MerchantSubscription", {
|
|
212
|
+
id: varchar3("id", {
|
|
213
|
+
length: 191
|
|
214
|
+
}).notNull(),
|
|
215
|
+
organizationId: varchar3("organizationId", {
|
|
216
|
+
length: 191
|
|
217
|
+
}),
|
|
218
|
+
merchantAccountId: varchar3("merchantAccountId", {
|
|
219
|
+
length: 191
|
|
220
|
+
}).notNull(),
|
|
221
|
+
status: int2("status").default(0).notNull(),
|
|
222
|
+
createdAt: timestamp3("createdAt", {
|
|
223
|
+
mode: "date",
|
|
224
|
+
fsp: 3
|
|
225
|
+
}).default(sql2`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
226
|
+
label: varchar3("label", {
|
|
227
|
+
length: 191
|
|
228
|
+
}),
|
|
229
|
+
identifier: varchar3("identifier", {
|
|
230
|
+
length: 191
|
|
231
|
+
}),
|
|
232
|
+
merchantCustomerId: varchar3("merchantCustomerId", {
|
|
233
|
+
length: 191
|
|
234
|
+
}).notNull(),
|
|
235
|
+
merchantProductId: varchar3("merchantProductId", {
|
|
236
|
+
length: 191
|
|
237
|
+
}).notNull()
|
|
238
|
+
}, (table) => {
|
|
239
|
+
return {
|
|
240
|
+
merchantSubscriptionId: primaryKey2({
|
|
241
|
+
columns: [
|
|
242
|
+
table.id
|
|
243
|
+
],
|
|
244
|
+
name: "MerchantSubscription_id"
|
|
245
|
+
}),
|
|
246
|
+
organizationIdIdx: index3("organizationId_idx").on(table.organizationId)
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
__name(getMerchantSubscriptionSchema, "getMerchantSubscriptionSchema");
|
|
251
|
+
function getMerchantSubscriptionRelationsSchema(mysqlTable) {
|
|
252
|
+
const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable);
|
|
253
|
+
const merchantCharge = getMerchantChargeSchema(mysqlTable);
|
|
254
|
+
const subscription = getSubscriptionSchema(mysqlTable);
|
|
255
|
+
return relations3(merchantSubscription, ({ many, one }) => ({
|
|
256
|
+
merchantCharges: many(merchantCharge, {
|
|
257
|
+
relationName: "merchantSubscription"
|
|
258
|
+
}),
|
|
259
|
+
subscription: one(subscription, {
|
|
260
|
+
fields: [
|
|
261
|
+
merchantSubscription.id
|
|
262
|
+
],
|
|
263
|
+
references: [
|
|
264
|
+
subscription.merchantSubscriptionId
|
|
265
|
+
],
|
|
266
|
+
relationName: "subscription"
|
|
267
|
+
})
|
|
268
|
+
}));
|
|
269
|
+
}
|
|
270
|
+
__name(getMerchantSubscriptionRelationsSchema, "getMerchantSubscriptionRelationsSchema");
|
|
271
|
+
|
|
272
|
+
// src/lib/mysql/schemas/commerce/product.ts
|
|
273
|
+
import { relations as relations13, sql as sql11 } from "drizzle-orm";
|
|
274
|
+
import { index as index13, int as int5, json as json8, primaryKey as primaryKey8, timestamp as timestamp13, varchar as varchar13 } from "drizzle-orm/mysql-core";
|
|
275
|
+
|
|
276
|
+
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
277
|
+
import { relations as relations11, sql as sql9 } from "drizzle-orm";
|
|
278
|
+
import { double as double4, index as index11, json as json6, primaryKey as primaryKey6, timestamp as timestamp11, varchar as varchar11 } from "drizzle-orm/mysql-core";
|
|
279
|
+
|
|
280
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
281
|
+
import { relations as relations10, sql as sql8 } from "drizzle-orm";
|
|
282
|
+
import { index as index10, json as json5, timestamp as timestamp10, varchar as varchar10 } from "drizzle-orm/mysql-core";
|
|
283
|
+
|
|
284
|
+
// src/lib/mysql/schemas/content/content-contributions.ts
|
|
285
|
+
import { relations as relations4 } from "drizzle-orm";
|
|
286
|
+
import { boolean as boolean2, index as index4, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
|
|
287
|
+
function getContentContributionsSchema(mysqlTable) {
|
|
288
|
+
return mysqlTable("ContentContribution", {
|
|
289
|
+
id: varchar4("id", {
|
|
290
|
+
length: 255
|
|
291
|
+
}).notNull().primaryKey(),
|
|
292
|
+
userId: varchar4("userId", {
|
|
293
|
+
length: 255
|
|
294
|
+
}).notNull(),
|
|
295
|
+
organizationId: varchar4("organizationId", {
|
|
296
|
+
length: 191
|
|
297
|
+
}),
|
|
298
|
+
organizationMembershipId: varchar4("organizationMembershipId", {
|
|
299
|
+
length: 255
|
|
300
|
+
}),
|
|
301
|
+
contentId: varchar4("contentId", {
|
|
302
|
+
length: 255
|
|
303
|
+
}).notNull(),
|
|
304
|
+
contributionTypeId: varchar4("contributionTypeId", {
|
|
305
|
+
length: 255
|
|
306
|
+
}).notNull(),
|
|
307
|
+
active: boolean2("active").notNull().default(true),
|
|
308
|
+
createdAt: timestamp4("createdAt", {
|
|
309
|
+
mode: "date",
|
|
310
|
+
fsp: 3
|
|
311
|
+
}).defaultNow(),
|
|
312
|
+
updatedAt: timestamp4("updatedAt", {
|
|
313
|
+
mode: "date",
|
|
314
|
+
fsp: 3
|
|
315
|
+
}).defaultNow(),
|
|
316
|
+
deletedAt: timestamp4("deletedAt", {
|
|
317
|
+
mode: "date",
|
|
318
|
+
fsp: 3
|
|
319
|
+
})
|
|
320
|
+
}, (cc) => ({
|
|
321
|
+
userIdIdx: index4("userId_idx").on(cc.userId),
|
|
322
|
+
contentIdIdx: index4("contentId_idx").on(cc.contentId),
|
|
323
|
+
contributionTypeIdIdx: index4("contributionTypeId_idx").on(cc.contributionTypeId),
|
|
324
|
+
organizationMembershipIdIdx: index4("organizationMembershipId_idx").on(cc.organizationMembershipId)
|
|
325
|
+
}));
|
|
326
|
+
}
|
|
327
|
+
__name(getContentContributionsSchema, "getContentContributionsSchema");
|
|
328
|
+
function getContentContributionRelationsSchema(mysqlTable) {
|
|
329
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
330
|
+
const users = getUsersSchema(mysqlTable);
|
|
331
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
332
|
+
const contributionTypes = getContributionTypesSchema(mysqlTable);
|
|
333
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
334
|
+
return relations4(contentContributions, ({ one }) => ({
|
|
335
|
+
user: one(users, {
|
|
336
|
+
fields: [
|
|
337
|
+
contentContributions.userId
|
|
338
|
+
],
|
|
339
|
+
references: [
|
|
340
|
+
users.id
|
|
341
|
+
],
|
|
342
|
+
relationName: "user"
|
|
343
|
+
}),
|
|
344
|
+
content: one(contentResource, {
|
|
345
|
+
fields: [
|
|
346
|
+
contentContributions.contentId
|
|
347
|
+
],
|
|
348
|
+
references: [
|
|
349
|
+
contentResource.id
|
|
350
|
+
],
|
|
351
|
+
relationName: "contributions"
|
|
352
|
+
}),
|
|
353
|
+
contributionType: one(contributionTypes, {
|
|
354
|
+
fields: [
|
|
355
|
+
contentContributions.contributionTypeId
|
|
356
|
+
],
|
|
357
|
+
references: [
|
|
358
|
+
contributionTypes.id
|
|
359
|
+
],
|
|
360
|
+
relationName: "contributionType"
|
|
361
|
+
}),
|
|
362
|
+
organizationMembership: one(organizationMemberships, {
|
|
363
|
+
fields: [
|
|
364
|
+
contentContributions.organizationMembershipId
|
|
365
|
+
],
|
|
366
|
+
references: [
|
|
367
|
+
organizationMemberships.id
|
|
368
|
+
],
|
|
369
|
+
relationName: "organizationMembership"
|
|
370
|
+
})
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
373
|
+
__name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
|
|
374
|
+
|
|
375
|
+
// src/lib/mysql/schemas/content/content-resource-resource.ts
|
|
376
|
+
import { relations as relations5, sql as sql3 } from "drizzle-orm";
|
|
377
|
+
import { double, index as index5, json, primaryKey as primaryKey3, timestamp as timestamp5, varchar as varchar5 } from "drizzle-orm/mysql-core";
|
|
378
|
+
function getContentResourceResourceSchema(mysqlTable) {
|
|
379
|
+
return mysqlTable("ContentResourceResource", {
|
|
380
|
+
resourceOfId: varchar5("resourceOfId", {
|
|
381
|
+
length: 255
|
|
382
|
+
}).notNull(),
|
|
383
|
+
resourceId: varchar5("resourceId", {
|
|
384
|
+
length: 255
|
|
385
|
+
}).notNull(),
|
|
386
|
+
position: double("position").notNull().default(0),
|
|
387
|
+
metadata: json("metadata").$type().default({}),
|
|
388
|
+
organizationId: varchar5("organizationId", {
|
|
389
|
+
length: 191
|
|
390
|
+
}),
|
|
391
|
+
createdAt: timestamp5("createdAt", {
|
|
392
|
+
mode: "date",
|
|
393
|
+
fsp: 3
|
|
394
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`),
|
|
395
|
+
updatedAt: timestamp5("updatedAt", {
|
|
396
|
+
mode: "date",
|
|
397
|
+
fsp: 3
|
|
398
|
+
}).default(sql3`CURRENT_TIMESTAMP(3)`),
|
|
399
|
+
deletedAt: timestamp5("deletedAt", {
|
|
400
|
+
mode: "date",
|
|
401
|
+
fsp: 3
|
|
402
|
+
})
|
|
403
|
+
}, (crr) => ({
|
|
404
|
+
pk: primaryKey3({
|
|
405
|
+
columns: [
|
|
406
|
+
crr.resourceOfId,
|
|
407
|
+
crr.resourceId
|
|
408
|
+
]
|
|
409
|
+
}),
|
|
410
|
+
contentResourceIdIdx: index5("contentResourceId_idx").on(crr.resourceOfId),
|
|
411
|
+
resourceIdIdx: index5("resourceId_idx").on(crr.resourceId),
|
|
412
|
+
organizationIdIdx: index5("organizationId_idx").on(crr.organizationId)
|
|
413
|
+
}));
|
|
414
|
+
}
|
|
415
|
+
__name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
|
|
416
|
+
function getContentResourceResourceRelationsSchema(mysqlTable) {
|
|
417
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
418
|
+
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
419
|
+
return relations5(contentResourceResource, ({ one }) => ({
|
|
420
|
+
resourceOf: one(contentResource, {
|
|
421
|
+
fields: [
|
|
422
|
+
contentResourceResource.resourceOfId
|
|
423
|
+
],
|
|
424
|
+
references: [
|
|
425
|
+
contentResource.id
|
|
426
|
+
],
|
|
427
|
+
relationName: "resourceOf"
|
|
428
|
+
}),
|
|
429
|
+
resource: one(contentResource, {
|
|
430
|
+
fields: [
|
|
431
|
+
contentResourceResource.resourceId
|
|
432
|
+
],
|
|
433
|
+
references: [
|
|
434
|
+
contentResource.id
|
|
435
|
+
],
|
|
436
|
+
relationName: "resource"
|
|
437
|
+
})
|
|
438
|
+
}));
|
|
439
|
+
}
|
|
440
|
+
__name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
|
|
441
|
+
|
|
442
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
443
|
+
import { relations as relations8, sql as sql6 } from "drizzle-orm";
|
|
444
|
+
import { double as double3, index as index8, primaryKey as primaryKey5, timestamp as timestamp8, varchar as varchar8 } from "drizzle-orm/mysql-core";
|
|
445
|
+
|
|
446
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
447
|
+
import { relations as relations7, sql as sql5 } from "drizzle-orm";
|
|
448
|
+
import { index as index7, json as json3, timestamp as timestamp7, varchar as varchar7 } from "drizzle-orm/mysql-core";
|
|
449
|
+
|
|
450
|
+
// src/lib/mysql/schemas/content/tag-tag.ts
|
|
451
|
+
import { relations as relations6, sql as sql4 } from "drizzle-orm";
|
|
452
|
+
import { double as double2, index as index6, json as json2, primaryKey as primaryKey4, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
|
|
453
|
+
function getTagTagSchema(mysqlTable) {
|
|
454
|
+
return mysqlTable("TagTag", {
|
|
455
|
+
parentTagId: varchar6("parentTagId", {
|
|
456
|
+
length: 255
|
|
457
|
+
}).notNull(),
|
|
458
|
+
childTagId: varchar6("childTagId", {
|
|
459
|
+
length: 255
|
|
460
|
+
}).notNull(),
|
|
461
|
+
position: double2("position").notNull().default(0),
|
|
462
|
+
metadata: json2("metadata").$type().default({}),
|
|
463
|
+
organizationId: varchar6("organizationId", {
|
|
464
|
+
length: 191
|
|
465
|
+
}),
|
|
466
|
+
createdAt: timestamp6("createdAt", {
|
|
467
|
+
mode: "date",
|
|
468
|
+
fsp: 3
|
|
469
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`),
|
|
470
|
+
updatedAt: timestamp6("updatedAt", {
|
|
471
|
+
mode: "date",
|
|
472
|
+
fsp: 3
|
|
473
|
+
}).default(sql4`CURRENT_TIMESTAMP(3)`),
|
|
474
|
+
deletedAt: timestamp6("deletedAt", {
|
|
475
|
+
mode: "date",
|
|
476
|
+
fsp: 3
|
|
477
|
+
})
|
|
478
|
+
}, (tt) => ({
|
|
479
|
+
pk: primaryKey4({
|
|
480
|
+
columns: [
|
|
481
|
+
tt.parentTagId,
|
|
482
|
+
tt.childTagId
|
|
483
|
+
]
|
|
484
|
+
}),
|
|
485
|
+
parentTagIdIdx: index6("parentTagId_idx").on(tt.parentTagId),
|
|
486
|
+
childTagIdIdx: index6("childTagId_idx").on(tt.childTagId),
|
|
487
|
+
positionIdx: index6("position_idx").on(tt.position),
|
|
488
|
+
organizationIdIdx: index6("organizationId_idx").on(tt.organizationId)
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
__name(getTagTagSchema, "getTagTagSchema");
|
|
492
|
+
function getTagTagRelationsSchema(mysqlTable) {
|
|
493
|
+
const tag = getTagSchema(mysqlTable);
|
|
494
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
495
|
+
return relations6(tagTag, ({ one }) => ({
|
|
496
|
+
parentTag: one(tag, {
|
|
497
|
+
fields: [
|
|
498
|
+
tagTag.parentTagId
|
|
499
|
+
],
|
|
500
|
+
references: [
|
|
501
|
+
tag.id
|
|
502
|
+
],
|
|
503
|
+
relationName: "parentTag"
|
|
504
|
+
}),
|
|
505
|
+
childTag: one(tag, {
|
|
506
|
+
fields: [
|
|
507
|
+
tagTag.childTagId
|
|
508
|
+
],
|
|
509
|
+
references: [
|
|
510
|
+
tag.id
|
|
511
|
+
],
|
|
512
|
+
relationName: "childTag"
|
|
513
|
+
})
|
|
514
|
+
}));
|
|
515
|
+
}
|
|
516
|
+
__name(getTagTagRelationsSchema, "getTagTagRelationsSchema");
|
|
517
|
+
|
|
518
|
+
// src/lib/mysql/schemas/content/tag.ts
|
|
519
|
+
function getTagSchema(mysqlTable) {
|
|
520
|
+
return mysqlTable("Tag", {
|
|
521
|
+
id: varchar7("id", {
|
|
522
|
+
length: 255
|
|
523
|
+
}).notNull().primaryKey(),
|
|
524
|
+
organizationId: varchar7("organizationId", {
|
|
525
|
+
length: 191
|
|
526
|
+
}),
|
|
527
|
+
type: varchar7("type", {
|
|
528
|
+
length: 255
|
|
529
|
+
}).notNull(),
|
|
530
|
+
fields: json3("fields").$type().default({}),
|
|
531
|
+
createdAt: timestamp7("createdAt", {
|
|
532
|
+
mode: "date",
|
|
533
|
+
fsp: 3
|
|
534
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
535
|
+
updatedAt: timestamp7("updatedAt", {
|
|
536
|
+
mode: "date",
|
|
537
|
+
fsp: 3
|
|
538
|
+
}).default(sql5`CURRENT_TIMESTAMP(3)`),
|
|
539
|
+
deletedAt: timestamp7("deletedAt", {
|
|
540
|
+
mode: "date",
|
|
541
|
+
fsp: 3
|
|
542
|
+
})
|
|
543
|
+
}, (t) => ({
|
|
544
|
+
typeIdx: index7("type_idx").on(t.type),
|
|
545
|
+
organizationIdIdx: index7("organizationId_idx").on(t.organizationId)
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
__name(getTagSchema, "getTagSchema");
|
|
549
|
+
function getTagRelationsSchema(mysqlTable) {
|
|
550
|
+
const tag = getTagSchema(mysqlTable);
|
|
551
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
552
|
+
const tagTag = getTagTagSchema(mysqlTable);
|
|
553
|
+
return relations7(tag, ({ many }) => ({
|
|
554
|
+
resources: many(contentResourceTag, {
|
|
555
|
+
relationName: "contentResource"
|
|
556
|
+
}),
|
|
557
|
+
parentTags: many(tagTag, {
|
|
558
|
+
relationName: "childTag"
|
|
559
|
+
}),
|
|
560
|
+
childTags: many(tagTag, {
|
|
561
|
+
relationName: "parentTag"
|
|
562
|
+
})
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
565
|
+
__name(getTagRelationsSchema, "getTagRelationsSchema");
|
|
566
|
+
|
|
567
|
+
// src/lib/mysql/schemas/content/content-resource-tag.ts
|
|
568
|
+
function getContentResourceTagSchema(mysqlTable) {
|
|
569
|
+
return mysqlTable("ContentResourceTag", {
|
|
570
|
+
contentResourceId: varchar8("contentResourceId", {
|
|
571
|
+
length: 255
|
|
572
|
+
}).notNull(),
|
|
573
|
+
organizationId: varchar8("organizationId", {
|
|
574
|
+
length: 191
|
|
575
|
+
}),
|
|
576
|
+
tagId: varchar8("tagId", {
|
|
577
|
+
length: 255
|
|
578
|
+
}).notNull(),
|
|
579
|
+
position: double3("position").notNull().default(0),
|
|
580
|
+
createdAt: timestamp8("createdAt", {
|
|
581
|
+
mode: "date",
|
|
582
|
+
fsp: 3
|
|
583
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`),
|
|
584
|
+
updatedAt: timestamp8("updatedAt", {
|
|
585
|
+
mode: "date",
|
|
586
|
+
fsp: 3
|
|
587
|
+
}).default(sql6`CURRENT_TIMESTAMP(3)`)
|
|
588
|
+
}, (crt) => ({
|
|
589
|
+
pk: primaryKey5({
|
|
590
|
+
columns: [
|
|
591
|
+
crt.contentResourceId,
|
|
592
|
+
crt.tagId
|
|
593
|
+
]
|
|
594
|
+
}),
|
|
595
|
+
contentResourceIdIdx: index8("contentResourceId_idx").on(crt.contentResourceId),
|
|
596
|
+
tagIdIdx: index8("tagId_idx").on(crt.tagId),
|
|
597
|
+
positionIdx: index8("position_idx").on(crt.position),
|
|
598
|
+
organizationIdIdx: index8("organizationId_idx").on(crt.organizationId)
|
|
599
|
+
}));
|
|
600
|
+
}
|
|
601
|
+
__name(getContentResourceTagSchema, "getContentResourceTagSchema");
|
|
602
|
+
function getContentResourceTagRelationsSchema(mysqlTable) {
|
|
603
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
604
|
+
const tag = getTagSchema(mysqlTable);
|
|
605
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
606
|
+
return relations8(contentResourceTag, ({ one }) => ({
|
|
607
|
+
contentResource: one(contentResource, {
|
|
608
|
+
fields: [
|
|
609
|
+
contentResourceTag.contentResourceId
|
|
610
|
+
],
|
|
611
|
+
references: [
|
|
612
|
+
contentResource.id
|
|
613
|
+
],
|
|
614
|
+
relationName: "contentResource"
|
|
615
|
+
}),
|
|
616
|
+
tag: one(tag, {
|
|
617
|
+
fields: [
|
|
618
|
+
contentResourceTag.tagId
|
|
619
|
+
],
|
|
620
|
+
references: [
|
|
621
|
+
tag.id
|
|
622
|
+
],
|
|
623
|
+
relationName: "tag"
|
|
624
|
+
})
|
|
625
|
+
}));
|
|
626
|
+
}
|
|
627
|
+
__name(getContentResourceTagRelationsSchema, "getContentResourceTagRelationsSchema");
|
|
628
|
+
|
|
629
|
+
// src/lib/mysql/schemas/content/content-resource-version.ts
|
|
630
|
+
import { relations as relations9, sql as sql7 } from "drizzle-orm";
|
|
631
|
+
import { index as index9, int as int3, json as json4, timestamp as timestamp9, unique as unique2, varchar as varchar9 } from "drizzle-orm/mysql-core";
|
|
632
|
+
function getContentResourceVersionSchema(mysqlTable) {
|
|
633
|
+
return mysqlTable("ContentResourceVersion", {
|
|
634
|
+
id: varchar9("id", {
|
|
635
|
+
length: 255
|
|
636
|
+
}).notNull().primaryKey(),
|
|
637
|
+
organizationId: varchar9("organizationId", {
|
|
638
|
+
length: 191
|
|
639
|
+
}),
|
|
640
|
+
resourceId: varchar9("resourceId", {
|
|
641
|
+
length: 255
|
|
642
|
+
}).notNull(),
|
|
643
|
+
parentVersionId: varchar9("parentVersionId", {
|
|
644
|
+
length: 255
|
|
645
|
+
}),
|
|
646
|
+
versionNumber: int3("versionNumber").notNull(),
|
|
647
|
+
fields: json4("fields").$type().default({}),
|
|
648
|
+
createdAt: timestamp9("createdAt", {
|
|
649
|
+
mode: "date",
|
|
650
|
+
fsp: 3
|
|
651
|
+
}).default(sql7`CURRENT_TIMESTAMP(3)`),
|
|
652
|
+
createdById: varchar9("createdById", {
|
|
653
|
+
length: 255
|
|
654
|
+
}).notNull()
|
|
655
|
+
}, (crv) => ({
|
|
656
|
+
resourceIdIdx: index9("resourceId_idx").on(crv.resourceId),
|
|
657
|
+
parentVersionIdIdx: index9("parentVersionId_idx").on(crv.parentVersionId),
|
|
658
|
+
resourceIdVersionNumberIdx: index9("resourceId_versionNumber_idx").on(crv.resourceId, crv.versionNumber),
|
|
659
|
+
uniqueResourceVersion: unique2("uq_resource_version_number").on(crv.resourceId, crv.versionNumber),
|
|
660
|
+
organizationIdIdx: index9("organizationId_idx").on(crv.organizationId)
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
__name(getContentResourceVersionSchema, "getContentResourceVersionSchema");
|
|
664
|
+
function getContentResourceVersionRelationsSchema(mysqlTable) {
|
|
665
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
666
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
667
|
+
const users = getUsersSchema(mysqlTable);
|
|
668
|
+
return relations9(contentResourceVersion, ({ one }) => ({
|
|
669
|
+
resource: one(contentResource, {
|
|
670
|
+
fields: [
|
|
671
|
+
contentResourceVersion.resourceId
|
|
672
|
+
],
|
|
673
|
+
references: [
|
|
674
|
+
contentResource.id
|
|
675
|
+
],
|
|
676
|
+
relationName: "versions"
|
|
677
|
+
}),
|
|
678
|
+
parentVersion: one(contentResourceVersion, {
|
|
679
|
+
fields: [
|
|
680
|
+
contentResourceVersion.parentVersionId
|
|
681
|
+
],
|
|
682
|
+
references: [
|
|
683
|
+
contentResourceVersion.id
|
|
684
|
+
],
|
|
685
|
+
relationName: "childVersions"
|
|
686
|
+
}),
|
|
687
|
+
createdBy: one(users, {
|
|
688
|
+
fields: [
|
|
689
|
+
contentResourceVersion.createdById
|
|
690
|
+
],
|
|
691
|
+
references: [
|
|
692
|
+
users.id
|
|
693
|
+
],
|
|
694
|
+
relationName: "createdVersions"
|
|
695
|
+
})
|
|
696
|
+
}));
|
|
697
|
+
}
|
|
698
|
+
__name(getContentResourceVersionRelationsSchema, "getContentResourceVersionRelationsSchema");
|
|
699
|
+
|
|
700
|
+
// src/lib/mysql/schemas/content/content-resource.ts
|
|
701
|
+
function getContentResourceSchema(mysqlTable) {
|
|
702
|
+
return mysqlTable("ContentResource", {
|
|
703
|
+
id: varchar10("id", {
|
|
704
|
+
length: 255
|
|
705
|
+
}).notNull().primaryKey(),
|
|
706
|
+
organizationId: varchar10("organizationId", {
|
|
707
|
+
length: 191
|
|
708
|
+
}),
|
|
709
|
+
createdByOrganizationMembershipId: varchar10("createdByOrganizationMembershipId", {
|
|
710
|
+
length: 191
|
|
711
|
+
}),
|
|
712
|
+
type: varchar10("type", {
|
|
713
|
+
length: 255
|
|
714
|
+
}).notNull(),
|
|
715
|
+
createdById: varchar10("createdById", {
|
|
716
|
+
length: 255
|
|
717
|
+
}).notNull(),
|
|
718
|
+
fields: json5("fields").$type().default({}),
|
|
719
|
+
currentVersionId: varchar10("currentVersionId", {
|
|
720
|
+
length: 255
|
|
721
|
+
}),
|
|
722
|
+
createdAt: timestamp10("createdAt", {
|
|
723
|
+
mode: "date",
|
|
724
|
+
fsp: 3
|
|
725
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`),
|
|
726
|
+
updatedAt: timestamp10("updatedAt", {
|
|
727
|
+
mode: "date",
|
|
728
|
+
fsp: 3
|
|
729
|
+
}).default(sql8`CURRENT_TIMESTAMP(3)`),
|
|
730
|
+
deletedAt: timestamp10("deletedAt", {
|
|
731
|
+
mode: "date",
|
|
732
|
+
fsp: 3
|
|
733
|
+
})
|
|
734
|
+
}, (cm) => ({
|
|
735
|
+
typeIdx: index10("type_idx").on(cm.type),
|
|
736
|
+
createdByIdx: index10("createdById_idx").on(cm.createdById),
|
|
737
|
+
createdAtIdx: index10("createdAt_idx").on(cm.createdAt),
|
|
738
|
+
currentVersionIdIdx: index10("currentVersionId_idx").on(cm.currentVersionId),
|
|
739
|
+
createdByOrganizationMembershipIdIdx: index10("createdByOrganizationMembershipId_idx").on(cm.createdByOrganizationMembershipId)
|
|
740
|
+
}));
|
|
741
|
+
}
|
|
742
|
+
__name(getContentResourceSchema, "getContentResourceSchema");
|
|
743
|
+
function getContentResourceRelationsSchema(mysqlTable) {
|
|
744
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
745
|
+
const users = getUsersSchema(mysqlTable);
|
|
746
|
+
const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
|
|
747
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
748
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
749
|
+
const contentResourceTag = getContentResourceTagSchema(mysqlTable);
|
|
750
|
+
const contentResourceVersion = getContentResourceVersionSchema(mysqlTable);
|
|
751
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
752
|
+
const tag = getTagSchema(mysqlTable);
|
|
753
|
+
return relations10(contentResource, ({ one, many }) => ({
|
|
754
|
+
createdBy: one(users, {
|
|
755
|
+
fields: [
|
|
756
|
+
contentResource.createdById
|
|
757
|
+
],
|
|
758
|
+
references: [
|
|
759
|
+
users.id
|
|
760
|
+
],
|
|
761
|
+
relationName: "creator"
|
|
762
|
+
}),
|
|
763
|
+
createdByOrganizationMembership: one(organizationMemberships, {
|
|
764
|
+
fields: [
|
|
765
|
+
contentResource.createdByOrganizationMembershipId
|
|
766
|
+
],
|
|
767
|
+
references: [
|
|
768
|
+
organizationMemberships.id
|
|
769
|
+
],
|
|
770
|
+
relationName: "createdByOrganizationMembership"
|
|
771
|
+
}),
|
|
772
|
+
tags: many(contentResourceTag, {
|
|
773
|
+
relationName: "contentResource"
|
|
774
|
+
}),
|
|
775
|
+
resources: many(contentResourceResource, {
|
|
776
|
+
relationName: "resourceOf"
|
|
777
|
+
}),
|
|
778
|
+
resourceOf: many(contentResourceResource, {
|
|
779
|
+
relationName: "resource"
|
|
780
|
+
}),
|
|
781
|
+
resourceProducts: many(contentResourceProduct, {
|
|
782
|
+
relationName: "resource"
|
|
783
|
+
}),
|
|
784
|
+
contributions: many(contentContributions, {
|
|
785
|
+
relationName: "contributions"
|
|
786
|
+
}),
|
|
787
|
+
currentVersion: one(contentResourceVersion, {
|
|
788
|
+
fields: [
|
|
789
|
+
contentResource.currentVersionId
|
|
790
|
+
],
|
|
791
|
+
references: [
|
|
792
|
+
contentResourceVersion.id
|
|
793
|
+
],
|
|
794
|
+
relationName: "currentVersionResource"
|
|
795
|
+
}),
|
|
796
|
+
versions: many(contentResourceVersion, {
|
|
797
|
+
relationName: "resource"
|
|
798
|
+
})
|
|
799
|
+
}));
|
|
800
|
+
}
|
|
801
|
+
__name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
|
|
802
|
+
|
|
803
|
+
// src/lib/mysql/schemas/content/content-resource-product.ts
|
|
804
|
+
function getContentResourceProductSchema(mysqlTable) {
|
|
805
|
+
return mysqlTable("ContentResourceProduct", {
|
|
806
|
+
productId: varchar11("productId", {
|
|
807
|
+
length: 255
|
|
808
|
+
}).notNull(),
|
|
809
|
+
resourceId: varchar11("resourceId", {
|
|
810
|
+
length: 255
|
|
811
|
+
}).notNull(),
|
|
812
|
+
organizationId: varchar11("organizationId", {
|
|
813
|
+
length: 191
|
|
814
|
+
}),
|
|
815
|
+
position: double4("position").notNull().default(0),
|
|
816
|
+
metadata: json6("metadata").$type().default({}),
|
|
817
|
+
createdAt: timestamp11("createdAt", {
|
|
818
|
+
mode: "date",
|
|
819
|
+
fsp: 3
|
|
820
|
+
}).default(sql9`CURRENT_TIMESTAMP(3)`),
|
|
821
|
+
updatedAt: timestamp11("updatedAt", {
|
|
822
|
+
mode: "date",
|
|
823
|
+
fsp: 3
|
|
824
|
+
}).default(sql9`CURRENT_TIMESTAMP(3)`),
|
|
825
|
+
deletedAt: timestamp11("deletedAt", {
|
|
826
|
+
mode: "date",
|
|
827
|
+
fsp: 3
|
|
828
|
+
})
|
|
829
|
+
}, (crr) => ({
|
|
830
|
+
pk: primaryKey6({
|
|
831
|
+
columns: [
|
|
832
|
+
crr.productId,
|
|
833
|
+
crr.resourceId
|
|
834
|
+
]
|
|
835
|
+
}),
|
|
836
|
+
contentResourceIdIdx: index11("contentResourceId_idx").on(crr.productId),
|
|
837
|
+
resourceIdIdx: index11("resourceId_idx").on(crr.resourceId),
|
|
838
|
+
organizationIdIdx: index11("organizationId_idx").on(crr.organizationId)
|
|
839
|
+
}));
|
|
840
|
+
}
|
|
841
|
+
__name(getContentResourceProductSchema, "getContentResourceProductSchema");
|
|
842
|
+
function getContentResourceProductRelationsSchema(mysqlTable) {
|
|
843
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
844
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
845
|
+
const product = getProductSchema(mysqlTable);
|
|
846
|
+
return relations11(contentResourceProduct, ({ one }) => ({
|
|
847
|
+
product: one(product, {
|
|
848
|
+
fields: [
|
|
849
|
+
contentResourceProduct.productId
|
|
850
|
+
],
|
|
851
|
+
references: [
|
|
852
|
+
product.id
|
|
853
|
+
],
|
|
854
|
+
relationName: "product"
|
|
855
|
+
}),
|
|
856
|
+
resource: one(contentResource, {
|
|
857
|
+
fields: [
|
|
858
|
+
contentResourceProduct.resourceId
|
|
859
|
+
],
|
|
860
|
+
references: [
|
|
861
|
+
contentResource.id
|
|
862
|
+
],
|
|
863
|
+
relationName: "resource"
|
|
864
|
+
})
|
|
865
|
+
}));
|
|
866
|
+
}
|
|
867
|
+
__name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
|
|
868
|
+
|
|
869
|
+
// src/lib/mysql/schemas/commerce/price.ts
|
|
870
|
+
import { relations as relations12, sql as sql10 } from "drizzle-orm";
|
|
871
|
+
import { decimal, index as index12, int as int4, json as json7, primaryKey as primaryKey7, timestamp as timestamp12, varchar as varchar12 } from "drizzle-orm/mysql-core";
|
|
872
|
+
function getPriceSchema(mysqlTable) {
|
|
873
|
+
return mysqlTable("Price", {
|
|
874
|
+
id: varchar12("id", {
|
|
875
|
+
length: 191
|
|
876
|
+
}).notNull(),
|
|
877
|
+
productId: varchar12("productId", {
|
|
878
|
+
length: 191
|
|
879
|
+
}),
|
|
880
|
+
organizationId: varchar12("organizationId", {
|
|
881
|
+
length: 191
|
|
882
|
+
}),
|
|
883
|
+
nickname: varchar12("nickname", {
|
|
884
|
+
length: 191
|
|
885
|
+
}),
|
|
886
|
+
status: int4("status").default(0).notNull(),
|
|
887
|
+
unitAmount: decimal("unitAmount", {
|
|
888
|
+
precision: 10,
|
|
889
|
+
scale: 2
|
|
890
|
+
}).notNull(),
|
|
891
|
+
createdAt: timestamp12("createdAt", {
|
|
892
|
+
mode: "date",
|
|
893
|
+
fsp: 3
|
|
894
|
+
}).default(sql10`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
895
|
+
fields: json7("fields").$type().default({})
|
|
896
|
+
}, (table) => {
|
|
897
|
+
return {
|
|
898
|
+
priceId: primaryKey7({
|
|
899
|
+
columns: [
|
|
900
|
+
table.id
|
|
901
|
+
],
|
|
902
|
+
name: "Price_id"
|
|
903
|
+
}),
|
|
904
|
+
organizationIdIdx: index12("organizationId_idx").on(table.organizationId)
|
|
905
|
+
};
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
__name(getPriceSchema, "getPriceSchema");
|
|
909
|
+
function getProductRelationsSchema(mysqlTable) {
|
|
910
|
+
const product = getProductSchema(mysqlTable);
|
|
911
|
+
const price = getPriceSchema(mysqlTable);
|
|
912
|
+
const merchantPrice = getMerchantPriceSchema(mysqlTable);
|
|
913
|
+
return relations12(price, ({ one, many }) => ({
|
|
914
|
+
product: one(product, {
|
|
915
|
+
fields: [
|
|
916
|
+
price.productId
|
|
917
|
+
],
|
|
918
|
+
references: [
|
|
919
|
+
product.id
|
|
920
|
+
],
|
|
921
|
+
relationName: "user"
|
|
922
|
+
}),
|
|
923
|
+
merchantPrice: one(merchantPrice, {
|
|
924
|
+
fields: [
|
|
925
|
+
price.id
|
|
926
|
+
],
|
|
927
|
+
references: [
|
|
928
|
+
merchantPrice.priceId
|
|
929
|
+
],
|
|
930
|
+
relationName: "merchantPrice"
|
|
931
|
+
})
|
|
932
|
+
}));
|
|
933
|
+
}
|
|
934
|
+
__name(getProductRelationsSchema, "getProductRelationsSchema");
|
|
935
|
+
|
|
936
|
+
// src/lib/mysql/schemas/commerce/product.ts
|
|
937
|
+
function getProductSchema(mysqlTable) {
|
|
938
|
+
return mysqlTable("Product", {
|
|
939
|
+
id: varchar13("id", {
|
|
940
|
+
length: 191
|
|
941
|
+
}).notNull(),
|
|
942
|
+
organizationId: varchar13("organizationId", {
|
|
943
|
+
length: 191
|
|
944
|
+
}),
|
|
945
|
+
name: varchar13("name", {
|
|
946
|
+
length: 191
|
|
947
|
+
}).notNull(),
|
|
948
|
+
key: varchar13("key", {
|
|
949
|
+
length: 191
|
|
950
|
+
}),
|
|
951
|
+
type: varchar13("type", {
|
|
952
|
+
length: 191
|
|
953
|
+
}),
|
|
954
|
+
fields: json8("fields").$type().default({}),
|
|
955
|
+
createdAt: timestamp13("createdAt", {
|
|
956
|
+
mode: "date",
|
|
957
|
+
fsp: 3
|
|
958
|
+
}).default(sql11`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
959
|
+
status: int5("status").default(0).notNull(),
|
|
960
|
+
quantityAvailable: int5("quantityAvailable").default(-1).notNull()
|
|
961
|
+
}, (table) => {
|
|
962
|
+
return {
|
|
963
|
+
productId: primaryKey8({
|
|
964
|
+
columns: [
|
|
965
|
+
table.id
|
|
966
|
+
],
|
|
967
|
+
name: "Product_id"
|
|
968
|
+
}),
|
|
969
|
+
organizationIdIdx: index13("organizationId_idx").on(table.organizationId)
|
|
970
|
+
};
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
__name(getProductSchema, "getProductSchema");
|
|
974
|
+
function getProductRelationsSchema2(mysqlTable) {
|
|
975
|
+
const product = getProductSchema(mysqlTable);
|
|
976
|
+
const price = getPriceSchema(mysqlTable);
|
|
977
|
+
const merchantProduct = getMerchantProductSchema(mysqlTable);
|
|
978
|
+
const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
|
|
979
|
+
return relations13(product, ({ one, many }) => ({
|
|
980
|
+
price: one(price, {
|
|
981
|
+
fields: [
|
|
982
|
+
product.id
|
|
983
|
+
],
|
|
984
|
+
references: [
|
|
985
|
+
price.productId
|
|
986
|
+
],
|
|
987
|
+
relationName: "price"
|
|
988
|
+
}),
|
|
989
|
+
resources: many(contentResourceProduct, {
|
|
990
|
+
relationName: "product"
|
|
991
|
+
}),
|
|
992
|
+
merchantProduct: one(merchantProduct, {
|
|
993
|
+
fields: [
|
|
994
|
+
product.id
|
|
995
|
+
],
|
|
996
|
+
references: [
|
|
997
|
+
merchantProduct.productId
|
|
998
|
+
],
|
|
999
|
+
relationName: "merchantProduct"
|
|
1000
|
+
})
|
|
1001
|
+
}));
|
|
1002
|
+
}
|
|
1003
|
+
__name(getProductRelationsSchema2, "getProductRelationsSchema");
|
|
1004
|
+
|
|
1005
|
+
// src/lib/mysql/schemas/commerce/subscription.ts
|
|
1006
|
+
function getSubscriptionSchema(mysqlTable) {
|
|
1007
|
+
return mysqlTable("Subscription", {
|
|
1008
|
+
id: varchar14("id", {
|
|
1009
|
+
length: 191
|
|
1010
|
+
}).notNull(),
|
|
1011
|
+
organizationId: varchar14("organizationId", {
|
|
1012
|
+
length: 191
|
|
1013
|
+
}),
|
|
1014
|
+
productId: varchar14("productId", {
|
|
1015
|
+
length: 191
|
|
1016
|
+
}).notNull(),
|
|
1017
|
+
createdAt: timestamp14("createdAt", {
|
|
1018
|
+
mode: "date",
|
|
1019
|
+
fsp: 3
|
|
1020
|
+
}).default(sql12`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1021
|
+
merchantSubscriptionId: varchar14("merchantSubscriptionId", {
|
|
1022
|
+
length: 191
|
|
1023
|
+
}).notNull(),
|
|
1024
|
+
status: varchar14("status", {
|
|
1025
|
+
length: 191
|
|
1026
|
+
}).default("active").notNull(),
|
|
1027
|
+
fields: json9("fields").$type().default({})
|
|
1028
|
+
}, (table) => {
|
|
1029
|
+
return {
|
|
1030
|
+
subscriptionId: primaryKey9({
|
|
1031
|
+
columns: [
|
|
1032
|
+
table.id
|
|
1033
|
+
],
|
|
1034
|
+
name: "Subscription_id"
|
|
1035
|
+
}),
|
|
1036
|
+
organizationIdIdx: index14("organizationId_idx").on(table.organizationId)
|
|
1037
|
+
};
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
__name(getSubscriptionSchema, "getSubscriptionSchema");
|
|
1041
|
+
function getSubscriptionRelationsSchema(mysqlTable) {
|
|
1042
|
+
const subscriptions = getSubscriptionSchema(mysqlTable);
|
|
1043
|
+
const products = getProductSchema(mysqlTable);
|
|
1044
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1045
|
+
const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable);
|
|
1046
|
+
return relations14(subscriptions, ({ many, one }) => ({
|
|
1047
|
+
organization: one(organizations, {
|
|
1048
|
+
fields: [
|
|
1049
|
+
subscriptions.organizationId
|
|
1050
|
+
],
|
|
1051
|
+
references: [
|
|
1052
|
+
organizations.id
|
|
1053
|
+
],
|
|
1054
|
+
relationName: "organization"
|
|
1055
|
+
}),
|
|
1056
|
+
product: one(products, {
|
|
1057
|
+
fields: [
|
|
1058
|
+
subscriptions.productId
|
|
1059
|
+
],
|
|
1060
|
+
references: [
|
|
1061
|
+
products.id
|
|
1062
|
+
],
|
|
1063
|
+
relationName: "product"
|
|
1064
|
+
}),
|
|
1065
|
+
merchantSubscription: one(merchantSubscriptions, {
|
|
1066
|
+
fields: [
|
|
1067
|
+
subscriptions.merchantSubscriptionId
|
|
1068
|
+
],
|
|
1069
|
+
references: [
|
|
1070
|
+
merchantSubscriptions.id
|
|
1071
|
+
],
|
|
1072
|
+
relationName: "merchantSubscription"
|
|
1073
|
+
})
|
|
1074
|
+
}));
|
|
1075
|
+
}
|
|
1076
|
+
__name(getSubscriptionRelationsSchema, "getSubscriptionRelationsSchema");
|
|
1077
|
+
|
|
1078
|
+
// src/lib/mysql/schemas/org/organizations.ts
|
|
1079
|
+
function getOrganizationsSchema(mysqlTable) {
|
|
1080
|
+
return mysqlTable("Organization", {
|
|
1081
|
+
id: varchar15("id", {
|
|
1082
|
+
length: 255
|
|
1083
|
+
}).notNull().primaryKey(),
|
|
1084
|
+
name: varchar15("name", {
|
|
1085
|
+
length: 255
|
|
1086
|
+
}),
|
|
1087
|
+
fields: json10("fields").$type().default({}),
|
|
1088
|
+
image: varchar15("image", {
|
|
1089
|
+
length: 255
|
|
1090
|
+
}),
|
|
1091
|
+
createdAt: timestamp15("createdAt", {
|
|
1092
|
+
mode: "date",
|
|
1093
|
+
fsp: 3
|
|
1094
|
+
}).default(sql13`CURRENT_TIMESTAMP(3)`)
|
|
1095
|
+
}, (organization) => ({
|
|
1096
|
+
createdAtIdx: index15("created_at_idx").on(organization.createdAt)
|
|
1097
|
+
}));
|
|
1098
|
+
}
|
|
1099
|
+
__name(getOrganizationsSchema, "getOrganizationsSchema");
|
|
1100
|
+
function getOrganizationsRelationsSchema(mysqlTable) {
|
|
1101
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1102
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1103
|
+
const subscriptions = getSubscriptionSchema(mysqlTable);
|
|
1104
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1105
|
+
return relations15(organizations, ({ many }) => ({
|
|
1106
|
+
purchases: many(purchases, {
|
|
1107
|
+
relationName: "organization"
|
|
1108
|
+
}),
|
|
1109
|
+
subscriptions: many(subscriptions, {
|
|
1110
|
+
relationName: "organization"
|
|
1111
|
+
}),
|
|
1112
|
+
members: many(organizationMemberships, {
|
|
1113
|
+
relationName: "organization"
|
|
1114
|
+
})
|
|
1115
|
+
}));
|
|
1116
|
+
}
|
|
1117
|
+
__name(getOrganizationsRelationsSchema, "getOrganizationsRelationsSchema");
|
|
1118
|
+
|
|
1119
|
+
// src/lib/mysql/schemas/org/organization-membership-roles.ts
|
|
1120
|
+
function getOrganizationMembershipRolesSchema(mysqlTable) {
|
|
1121
|
+
return mysqlTable("OrganizationMembershipRole", {
|
|
1122
|
+
organizationMembershipId: varchar16("organizationMembershipId", {
|
|
1123
|
+
length: 255
|
|
1124
|
+
}).notNull(),
|
|
1125
|
+
roleId: varchar16("roleId", {
|
|
1126
|
+
length: 255
|
|
1127
|
+
}).notNull(),
|
|
1128
|
+
active: boolean3("active").notNull().default(true),
|
|
1129
|
+
organizationId: varchar16("organizationId", {
|
|
1130
|
+
length: 191
|
|
1131
|
+
}),
|
|
1132
|
+
createdAt: timestamp16("createdAt", {
|
|
1133
|
+
mode: "date",
|
|
1134
|
+
fsp: 3
|
|
1135
|
+
}).defaultNow(),
|
|
1136
|
+
updatedAt: timestamp16("updatedAt", {
|
|
1137
|
+
mode: "date",
|
|
1138
|
+
fsp: 3
|
|
1139
|
+
}).defaultNow(),
|
|
1140
|
+
deletedAt: timestamp16("deletedAt", {
|
|
1141
|
+
mode: "date",
|
|
1142
|
+
fsp: 3
|
|
1143
|
+
})
|
|
1144
|
+
}, (ur) => ({
|
|
1145
|
+
pk: primaryKey10({
|
|
1146
|
+
columns: [
|
|
1147
|
+
ur.organizationMembershipId,
|
|
1148
|
+
ur.roleId
|
|
1149
|
+
],
|
|
1150
|
+
name: "pk"
|
|
1151
|
+
}),
|
|
1152
|
+
orgMemberIdIdx: index16("orgMemberId_idx").on(ur.organizationMembershipId),
|
|
1153
|
+
roleIdIdx: index16("roleId_idx").on(ur.roleId),
|
|
1154
|
+
organizationIdIdx: index16("organizationId_idx").on(ur.organizationId)
|
|
1155
|
+
}));
|
|
1156
|
+
}
|
|
1157
|
+
__name(getOrganizationMembershipRolesSchema, "getOrganizationMembershipRolesSchema");
|
|
1158
|
+
function getOrganizationMembershipRolesRelationsSchema(mysqlTable) {
|
|
1159
|
+
const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
|
|
1160
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1161
|
+
const roles = getRolesSchema(mysqlTable);
|
|
1162
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1163
|
+
return relations16(organizationMembershipRoles, ({ one }) => ({
|
|
1164
|
+
organizationMembership: one(organizationMemberships, {
|
|
1165
|
+
fields: [
|
|
1166
|
+
organizationMembershipRoles.organizationMembershipId
|
|
1167
|
+
],
|
|
1168
|
+
references: [
|
|
1169
|
+
organizationMemberships.id
|
|
1170
|
+
],
|
|
1171
|
+
relationName: "organizationMembership"
|
|
1172
|
+
}),
|
|
1173
|
+
role: one(roles, {
|
|
1174
|
+
fields: [
|
|
1175
|
+
organizationMembershipRoles.roleId
|
|
1176
|
+
],
|
|
1177
|
+
references: [
|
|
1178
|
+
roles.id
|
|
1179
|
+
],
|
|
1180
|
+
relationName: "role"
|
|
1181
|
+
}),
|
|
1182
|
+
organization: one(organizations, {
|
|
1183
|
+
fields: [
|
|
1184
|
+
organizationMembershipRoles.organizationId
|
|
1185
|
+
],
|
|
1186
|
+
references: [
|
|
1187
|
+
organizations.id
|
|
1188
|
+
],
|
|
1189
|
+
relationName: "organization"
|
|
1190
|
+
})
|
|
1191
|
+
}));
|
|
1192
|
+
}
|
|
1193
|
+
__name(getOrganizationMembershipRolesRelationsSchema, "getOrganizationMembershipRolesRelationsSchema");
|
|
1194
|
+
|
|
1195
|
+
// src/lib/mysql/schemas/org/organization-memberships.ts
|
|
1196
|
+
function getOrganizationMembershipsSchema(mysqlTable) {
|
|
1197
|
+
return mysqlTable("OrganizationMembership", {
|
|
1198
|
+
id: varchar17("id", {
|
|
1199
|
+
length: 255
|
|
1200
|
+
}).notNull().primaryKey(),
|
|
1201
|
+
organizationId: varchar17("organizationId", {
|
|
1202
|
+
length: 191
|
|
1203
|
+
}),
|
|
1204
|
+
role: varchar17("role", {
|
|
1205
|
+
length: 191
|
|
1206
|
+
}).notNull().default("user"),
|
|
1207
|
+
invitedById: varchar17("invitedById", {
|
|
1208
|
+
length: 255
|
|
1209
|
+
}).notNull(),
|
|
1210
|
+
userId: varchar17("userId", {
|
|
1211
|
+
length: 255
|
|
1212
|
+
}).notNull(),
|
|
1213
|
+
fields: json11("fields").$type().default({}),
|
|
1214
|
+
createdAt: timestamp17("createdAt", {
|
|
1215
|
+
mode: "date",
|
|
1216
|
+
fsp: 3
|
|
1217
|
+
}).default(sql14`CURRENT_TIMESTAMP(3)`)
|
|
1218
|
+
}, (organizationMembership) => ({
|
|
1219
|
+
roleIdx: index17("role_idx").on(organizationMembership.role),
|
|
1220
|
+
createdAtIdx: index17("created_at_idx").on(organizationMembership.createdAt),
|
|
1221
|
+
organizationIdIdx: index17("organizationId_idx").on(organizationMembership.organizationId)
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
__name(getOrganizationMembershipsSchema, "getOrganizationMembershipsSchema");
|
|
1225
|
+
function getOrganizationMembershipsRelationsSchema(mysqlTable) {
|
|
1226
|
+
const users = getUsersSchema(mysqlTable);
|
|
1227
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1228
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1229
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1230
|
+
const organizationMembershipRoles = getOrganizationMembershipRolesSchema(mysqlTable);
|
|
1231
|
+
return relations17(organizationMemberships, ({ one, many }) => ({
|
|
1232
|
+
user: one(users, {
|
|
1233
|
+
fields: [
|
|
1234
|
+
organizationMemberships.userId
|
|
1235
|
+
],
|
|
1236
|
+
references: [
|
|
1237
|
+
users.id
|
|
1238
|
+
],
|
|
1239
|
+
relationName: "user"
|
|
1240
|
+
}),
|
|
1241
|
+
invitedBy: one(users, {
|
|
1242
|
+
fields: [
|
|
1243
|
+
organizationMemberships.invitedById
|
|
1244
|
+
],
|
|
1245
|
+
references: [
|
|
1246
|
+
users.id
|
|
1247
|
+
],
|
|
1248
|
+
relationName: "invitedBy"
|
|
1249
|
+
}),
|
|
1250
|
+
purchases: many(purchases),
|
|
1251
|
+
organization: one(organizations, {
|
|
1252
|
+
fields: [
|
|
1253
|
+
organizationMemberships.organizationId
|
|
1254
|
+
],
|
|
1255
|
+
references: [
|
|
1256
|
+
organizations.id
|
|
1257
|
+
],
|
|
1258
|
+
relationName: "organization"
|
|
1259
|
+
}),
|
|
1260
|
+
organizationMembershipRoles: many(organizationMembershipRoles, {
|
|
1261
|
+
relationName: "organizationMembership"
|
|
1262
|
+
})
|
|
1263
|
+
}));
|
|
1264
|
+
}
|
|
1265
|
+
__name(getOrganizationMembershipsRelationsSchema, "getOrganizationMembershipsRelationsSchema");
|
|
1266
|
+
|
|
1267
|
+
// src/lib/mysql/schemas/commerce/coupon.ts
|
|
1268
|
+
import { relations as relations18, sql as sql15 } from "drizzle-orm";
|
|
1269
|
+
import { boolean as boolean4, decimal as decimal2, index as index18, int as int6, json as json12, primaryKey as primaryKey11, timestamp as timestamp18, unique as unique3, varchar as varchar18 } from "drizzle-orm/mysql-core";
|
|
1270
|
+
function getCouponSchema(mysqlTable) {
|
|
1271
|
+
return mysqlTable("Coupon", {
|
|
1272
|
+
id: varchar18("id", {
|
|
1273
|
+
length: 191
|
|
1274
|
+
}).notNull(),
|
|
1275
|
+
organizationId: varchar18("organizationId", {
|
|
1276
|
+
length: 191
|
|
1277
|
+
}),
|
|
1278
|
+
code: varchar18("code", {
|
|
1279
|
+
length: 191
|
|
1280
|
+
}),
|
|
1281
|
+
createdAt: timestamp18("createdAt", {
|
|
1282
|
+
mode: "date",
|
|
1283
|
+
fsp: 3
|
|
1284
|
+
}).default(sql15`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1285
|
+
expires: timestamp18("expires", {
|
|
1286
|
+
mode: "date",
|
|
1287
|
+
fsp: 3
|
|
1288
|
+
}),
|
|
1289
|
+
fields: json12("fields").$type().default({}),
|
|
1290
|
+
maxUses: int6("maxUses").default(-1).notNull(),
|
|
1291
|
+
default: boolean4("default").default(false).notNull(),
|
|
1292
|
+
merchantCouponId: varchar18("merchantCouponId", {
|
|
1293
|
+
length: 191
|
|
1294
|
+
}),
|
|
1295
|
+
status: int6("status").default(0).notNull(),
|
|
1296
|
+
usedCount: int6("usedCount").default(0).notNull(),
|
|
1297
|
+
percentageDiscount: decimal2("percentageDiscount", {
|
|
1298
|
+
precision: 3,
|
|
1299
|
+
scale: 2
|
|
1300
|
+
}).notNull(),
|
|
1301
|
+
restrictedToProductId: varchar18("restrictedToProductId", {
|
|
1302
|
+
length: 191
|
|
1303
|
+
})
|
|
1304
|
+
}, (table) => {
|
|
1305
|
+
return {
|
|
1306
|
+
couponIdCodeIndex: index18("Coupon_id_code_index").on(table.id, table.code),
|
|
1307
|
+
couponId: primaryKey11({
|
|
1308
|
+
columns: [
|
|
1309
|
+
table.id
|
|
1310
|
+
],
|
|
1311
|
+
name: "Coupon_id"
|
|
1312
|
+
}),
|
|
1313
|
+
couponCodeKey: unique3("Coupon_code_key").on(table.code),
|
|
1314
|
+
organizationIdIdx: index18("organizationId_idx").on(table.organizationId)
|
|
1315
|
+
};
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
__name(getCouponSchema, "getCouponSchema");
|
|
1319
|
+
function getCouponRelationsSchema(mysqlTable) {
|
|
1320
|
+
const purchase = getPurchaseSchema(mysqlTable);
|
|
1321
|
+
const coupon = getCouponSchema(mysqlTable);
|
|
1322
|
+
const merchantCoupon = getMerchantCouponSchema(mysqlTable);
|
|
1323
|
+
return relations18(coupon, ({ many, one }) => ({
|
|
1324
|
+
redeemedBulkCouponPurchases: many(purchase, {
|
|
1325
|
+
relationName: "redeemedBulkCoupon"
|
|
1326
|
+
}),
|
|
1327
|
+
merchantCoupon: one(merchantCoupon, {
|
|
1328
|
+
fields: [
|
|
1329
|
+
coupon.merchantCouponId
|
|
1330
|
+
],
|
|
1331
|
+
references: [
|
|
1332
|
+
merchantCoupon.id
|
|
1333
|
+
],
|
|
1334
|
+
relationName: "merchantCoupon"
|
|
1335
|
+
}),
|
|
1336
|
+
product: one(getProductSchema(mysqlTable), {
|
|
1337
|
+
fields: [
|
|
1338
|
+
coupon.restrictedToProductId
|
|
1339
|
+
],
|
|
1340
|
+
references: [
|
|
1341
|
+
getProductSchema(mysqlTable).id
|
|
1342
|
+
],
|
|
1343
|
+
relationName: "product"
|
|
1344
|
+
}),
|
|
1345
|
+
bulkPurchases: many(purchase, {
|
|
1346
|
+
relationName: "bulkCoupon"
|
|
1347
|
+
})
|
|
1348
|
+
}));
|
|
1349
|
+
}
|
|
1350
|
+
__name(getCouponRelationsSchema, "getCouponRelationsSchema");
|
|
1351
|
+
|
|
1352
|
+
// src/lib/mysql/schemas/commerce/purchase.ts
|
|
1353
|
+
function getPurchaseSchema(mysqlTable) {
|
|
1354
|
+
return mysqlTable("Purchase", {
|
|
1355
|
+
id: varchar19("id", {
|
|
1356
|
+
length: 191
|
|
1357
|
+
}).notNull(),
|
|
1358
|
+
userId: varchar19("userId", {
|
|
1359
|
+
length: 191
|
|
1360
|
+
}),
|
|
1361
|
+
purchasedByorganizationMembershipId: varchar19("organizationMembershipId", {
|
|
1362
|
+
length: 191
|
|
1363
|
+
}),
|
|
1364
|
+
organizationId: varchar19("organizationId", {
|
|
1365
|
+
length: 191
|
|
1366
|
+
}),
|
|
1367
|
+
createdAt: timestamp19("createdAt", {
|
|
1368
|
+
mode: "date",
|
|
1369
|
+
fsp: 3
|
|
1370
|
+
}).default(sql16`CURRENT_TIMESTAMP(3)`).notNull(),
|
|
1371
|
+
totalAmount: decimal3("totalAmount", {
|
|
1372
|
+
precision: 65,
|
|
1373
|
+
scale: 30
|
|
1374
|
+
}).notNull(),
|
|
1375
|
+
ipAddress: varchar19("ip_address", {
|
|
1376
|
+
length: 191
|
|
1377
|
+
}),
|
|
1378
|
+
city: varchar19("city", {
|
|
1379
|
+
length: 191
|
|
1380
|
+
}),
|
|
1381
|
+
state: varchar19("state", {
|
|
1382
|
+
length: 191
|
|
1383
|
+
}),
|
|
1384
|
+
country: varchar19("country", {
|
|
1385
|
+
length: 191
|
|
1386
|
+
}),
|
|
1387
|
+
couponId: varchar19("couponId", {
|
|
1388
|
+
length: 191
|
|
1389
|
+
}),
|
|
1390
|
+
productId: varchar19("productId", {
|
|
1391
|
+
length: 191
|
|
1392
|
+
}).notNull(),
|
|
1393
|
+
merchantChargeId: varchar19("merchantChargeId", {
|
|
1394
|
+
length: 191
|
|
1395
|
+
}),
|
|
1396
|
+
upgradedFromId: varchar19("upgradedFromId", {
|
|
1397
|
+
length: 191
|
|
1398
|
+
}),
|
|
1399
|
+
status: varchar19("status", {
|
|
1400
|
+
length: 191
|
|
1401
|
+
}).default("Valid").notNull(),
|
|
1402
|
+
bulkCouponId: varchar19("bulkCouponId", {
|
|
1403
|
+
length: 191
|
|
1404
|
+
}),
|
|
1405
|
+
merchantSessionId: varchar19("merchantSessionId", {
|
|
1406
|
+
length: 191
|
|
1407
|
+
}),
|
|
1408
|
+
redeemedBulkCouponId: varchar19("redeemedBulkCouponId", {
|
|
1409
|
+
length: 191
|
|
1410
|
+
}),
|
|
1411
|
+
fields: json13("fields").$type().default({})
|
|
1412
|
+
}, (table) => {
|
|
1413
|
+
return {
|
|
1414
|
+
purchaseId: primaryKey12({
|
|
1415
|
+
columns: [
|
|
1416
|
+
table.id
|
|
1417
|
+
],
|
|
1418
|
+
name: "Purchase_id"
|
|
1419
|
+
}),
|
|
1420
|
+
merchantChargeIdIdx: index19("idx_Purchase_on_merchantChargeId").on(table.merchantChargeId),
|
|
1421
|
+
purchaseUpgradedFromIdKey: unique4("Purchase_upgradedFromId_key").on(table.upgradedFromId),
|
|
1422
|
+
organizationIdIdx: index19("organizationId_idx").on(table.organizationId),
|
|
1423
|
+
organizationMembershipIdIdx: index19("organizationMembershipId_idx").on(table.purchasedByorganizationMembershipId)
|
|
1424
|
+
};
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
__name(getPurchaseSchema, "getPurchaseSchema");
|
|
1428
|
+
function getPurchaseRelationsSchema(mysqlTable) {
|
|
1429
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1430
|
+
const users = getUsersSchema(mysqlTable);
|
|
1431
|
+
const products = getProductSchema(mysqlTable);
|
|
1432
|
+
const merchantCharges = getMerchantChargeSchema(mysqlTable);
|
|
1433
|
+
const merchantSessions = getMerchantSessionSchema(mysqlTable);
|
|
1434
|
+
const coupons = getCouponSchema(mysqlTable);
|
|
1435
|
+
const organizations = getOrganizationsSchema(mysqlTable);
|
|
1436
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1437
|
+
return relations19(purchases, ({ many, one }) => ({
|
|
1438
|
+
redeemedBulkCoupon: one(coupons, {
|
|
1439
|
+
fields: [
|
|
1440
|
+
purchases.redeemedBulkCouponId
|
|
1441
|
+
],
|
|
1442
|
+
references: [
|
|
1443
|
+
coupons.id
|
|
1444
|
+
],
|
|
1445
|
+
relationName: "redeemedBulkCoupon"
|
|
1446
|
+
}),
|
|
1447
|
+
user: one(users, {
|
|
1448
|
+
fields: [
|
|
1449
|
+
purchases.userId
|
|
1450
|
+
],
|
|
1451
|
+
references: [
|
|
1452
|
+
users.id
|
|
1453
|
+
],
|
|
1454
|
+
relationName: "user"
|
|
1455
|
+
}),
|
|
1456
|
+
organization: one(organizations, {
|
|
1457
|
+
fields: [
|
|
1458
|
+
purchases.organizationId
|
|
1459
|
+
],
|
|
1460
|
+
references: [
|
|
1461
|
+
organizations.id
|
|
1462
|
+
],
|
|
1463
|
+
relationName: "organization"
|
|
1464
|
+
}),
|
|
1465
|
+
purchasedBy: one(organizationMemberships, {
|
|
1466
|
+
fields: [
|
|
1467
|
+
purchases.purchasedByorganizationMembershipId
|
|
1468
|
+
],
|
|
1469
|
+
references: [
|
|
1470
|
+
organizationMemberships.id
|
|
1471
|
+
],
|
|
1472
|
+
relationName: "organizationMembership"
|
|
1473
|
+
}),
|
|
1474
|
+
product: one(products, {
|
|
1475
|
+
fields: [
|
|
1476
|
+
purchases.productId
|
|
1477
|
+
],
|
|
1478
|
+
references: [
|
|
1479
|
+
products.id
|
|
1480
|
+
],
|
|
1481
|
+
relationName: "product"
|
|
1482
|
+
}),
|
|
1483
|
+
bulkCoupon: one(coupons, {
|
|
1484
|
+
fields: [
|
|
1485
|
+
purchases.bulkCouponId
|
|
1486
|
+
],
|
|
1487
|
+
references: [
|
|
1488
|
+
coupons.id
|
|
1489
|
+
],
|
|
1490
|
+
relationName: "bulkCoupon"
|
|
1491
|
+
}),
|
|
1492
|
+
merchantCharge: one(merchantCharges, {
|
|
1493
|
+
fields: [
|
|
1494
|
+
purchases.merchantChargeId
|
|
1495
|
+
],
|
|
1496
|
+
references: [
|
|
1497
|
+
merchantCharges.id
|
|
1498
|
+
],
|
|
1499
|
+
relationName: "merchantCharge"
|
|
1500
|
+
}),
|
|
1501
|
+
merchantSession: one(merchantSessions, {
|
|
1502
|
+
fields: [
|
|
1503
|
+
purchases.merchantSessionId
|
|
1504
|
+
],
|
|
1505
|
+
references: [
|
|
1506
|
+
merchantSessions.id
|
|
1507
|
+
],
|
|
1508
|
+
relationName: "merchantSession"
|
|
1509
|
+
})
|
|
1510
|
+
}));
|
|
1511
|
+
}
|
|
1512
|
+
__name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
|
|
1513
|
+
|
|
1514
|
+
// src/lib/mysql/schemas/communication/comment.ts
|
|
1515
|
+
import { relations as relations20, sql as sql17 } from "drizzle-orm";
|
|
1516
|
+
import { index as index20, json as json14, primaryKey as primaryKey13, text as text2, timestamp as timestamp20, varchar as varchar20 } from "drizzle-orm/mysql-core";
|
|
1517
|
+
function getCommentsSchema(mysqlTable) {
|
|
1518
|
+
return mysqlTable("Comment", {
|
|
1519
|
+
id: varchar20("id", {
|
|
1520
|
+
length: 191
|
|
1521
|
+
}).notNull(),
|
|
1522
|
+
userId: varchar20("userId", {
|
|
1523
|
+
length: 255
|
|
1524
|
+
}).notNull(),
|
|
1525
|
+
organizationMembershipId: varchar20("organizationMembershipId", {
|
|
1526
|
+
length: 255
|
|
1527
|
+
}),
|
|
1528
|
+
context: json14("context").$type().default({}),
|
|
1529
|
+
text: text2("text").notNull(),
|
|
1530
|
+
createdAt: timestamp20("createdAt", {
|
|
1531
|
+
mode: "date",
|
|
1532
|
+
fsp: 3
|
|
1533
|
+
}).default(sql17`CURRENT_TIMESTAMP(3)`),
|
|
1534
|
+
updatedAt: timestamp20("updatedAt", {
|
|
1535
|
+
mode: "date",
|
|
1536
|
+
fsp: 3
|
|
1537
|
+
}).default(sql17`CURRENT_TIMESTAMP(3)`),
|
|
1538
|
+
deletedAt: timestamp20("deletedAt", {
|
|
1539
|
+
mode: "date",
|
|
1540
|
+
fsp: 3
|
|
1541
|
+
})
|
|
1542
|
+
}, (crr) => ({
|
|
1543
|
+
pk: primaryKey13({
|
|
1544
|
+
columns: [
|
|
1545
|
+
crr.id
|
|
1546
|
+
]
|
|
1547
|
+
}),
|
|
1548
|
+
crrUserIdIdKey: index20("crr_userIdId_idx").on(crr.userId),
|
|
1549
|
+
organizationMembershipIdIdx: index20("organizationMembershipId_idx").on(crr.organizationMembershipId)
|
|
1550
|
+
}));
|
|
1551
|
+
}
|
|
1552
|
+
__name(getCommentsSchema, "getCommentsSchema");
|
|
1553
|
+
function getCommentRelationsSchema(mysqlTable) {
|
|
1554
|
+
const comment = getCommentsSchema(mysqlTable);
|
|
1555
|
+
const user = getUsersSchema(mysqlTable);
|
|
1556
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1557
|
+
return relations20(comment, ({ one }) => ({
|
|
1558
|
+
user: one(user, {
|
|
1559
|
+
fields: [
|
|
1560
|
+
comment.userId
|
|
1561
|
+
],
|
|
1562
|
+
references: [
|
|
1563
|
+
user.id
|
|
1564
|
+
],
|
|
1565
|
+
relationName: "user"
|
|
1566
|
+
}),
|
|
1567
|
+
organizationMembership: one(organizationMemberships, {
|
|
1568
|
+
fields: [
|
|
1569
|
+
comment.organizationMembershipId
|
|
1570
|
+
],
|
|
1571
|
+
references: [
|
|
1572
|
+
organizationMemberships.id
|
|
1573
|
+
],
|
|
1574
|
+
relationName: "organizationMembership"
|
|
1575
|
+
})
|
|
1576
|
+
}));
|
|
1577
|
+
}
|
|
1578
|
+
__name(getCommentRelationsSchema, "getCommentRelationsSchema");
|
|
1579
|
+
|
|
1580
|
+
// src/lib/mysql/schemas/communication/communication-preferences.ts
|
|
1581
|
+
import { relations as relations21 } from "drizzle-orm";
|
|
1582
|
+
import { boolean as boolean5, index as index21, mysqlEnum, timestamp as timestamp21, varchar as varchar21 } from "drizzle-orm/mysql-core";
|
|
1583
|
+
function getCommunicationPreferencesSchema(mysqlTable) {
|
|
1584
|
+
return mysqlTable("CommunicationPreference", {
|
|
1585
|
+
id: varchar21("id", {
|
|
1586
|
+
length: 255
|
|
1587
|
+
}).notNull().primaryKey(),
|
|
1588
|
+
organizationId: varchar21("organizationId", {
|
|
1589
|
+
length: 191
|
|
1590
|
+
}),
|
|
1591
|
+
userId: varchar21("userId", {
|
|
1592
|
+
length: 255
|
|
1593
|
+
}).notNull(),
|
|
1594
|
+
organizationMembershipId: varchar21("organizationMembershipId", {
|
|
1595
|
+
length: 255
|
|
1596
|
+
}),
|
|
1597
|
+
channelId: varchar21("channelId", {
|
|
1598
|
+
length: 255
|
|
1599
|
+
}).notNull(),
|
|
1600
|
+
preferenceLevel: mysqlEnum("preferenceLevel", [
|
|
1601
|
+
"low",
|
|
1602
|
+
"medium",
|
|
1603
|
+
"high"
|
|
1604
|
+
]).notNull().default("medium"),
|
|
1605
|
+
preferenceTypeId: varchar21("preferenceTypeId", {
|
|
1606
|
+
length: 255
|
|
1607
|
+
}).notNull(),
|
|
1608
|
+
active: boolean5("active").notNull().default(true),
|
|
1609
|
+
createdAt: timestamp21("createdAt", {
|
|
1610
|
+
mode: "date",
|
|
1611
|
+
fsp: 3
|
|
1612
|
+
}).defaultNow(),
|
|
1613
|
+
optInAt: timestamp21("optInAt", {
|
|
1614
|
+
mode: "date",
|
|
1615
|
+
fsp: 3
|
|
1616
|
+
}),
|
|
1617
|
+
optOutAt: timestamp21("optOutAt", {
|
|
1618
|
+
mode: "date",
|
|
1619
|
+
fsp: 3
|
|
1620
|
+
}),
|
|
1621
|
+
updatedAt: timestamp21("updatedAt", {
|
|
1622
|
+
mode: "date",
|
|
1623
|
+
fsp: 3
|
|
1624
|
+
}).defaultNow(),
|
|
1625
|
+
deletedAt: timestamp21("deletedAt", {
|
|
1626
|
+
mode: "date",
|
|
1627
|
+
fsp: 3
|
|
1628
|
+
})
|
|
1629
|
+
}, (cp) => ({
|
|
1630
|
+
userIdIdx: index21("userId_idx").on(cp.userId),
|
|
1631
|
+
preferenceTypeIdx: index21("preferenceTypeId_idx").on(cp.preferenceTypeId),
|
|
1632
|
+
channelIdIdx: index21("channelId_idx").on(cp.channelId),
|
|
1633
|
+
organizationMembershipIdIdx: index21("organizationMembershipId_idx").on(cp.organizationMembershipId)
|
|
1634
|
+
}));
|
|
1635
|
+
}
|
|
1636
|
+
__name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
|
|
1637
|
+
function getCommunicationPreferencesRelationsSchema(mysqlTable) {
|
|
1638
|
+
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
|
|
1639
|
+
const users = getUsersSchema(mysqlTable);
|
|
1640
|
+
const communicationChannel = getCommunicationChannelSchema(mysqlTable);
|
|
1641
|
+
const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
|
|
1642
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1643
|
+
return relations21(communicationPreferences, ({ one }) => ({
|
|
1644
|
+
user: one(users, {
|
|
1645
|
+
fields: [
|
|
1646
|
+
communicationPreferences.userId
|
|
1647
|
+
],
|
|
1648
|
+
references: [
|
|
1649
|
+
users.id
|
|
1650
|
+
],
|
|
1651
|
+
relationName: "user"
|
|
1652
|
+
}),
|
|
1653
|
+
organizationMembership: one(organizationMemberships, {
|
|
1654
|
+
fields: [
|
|
1655
|
+
communicationPreferences.organizationMembershipId
|
|
1656
|
+
],
|
|
1657
|
+
references: [
|
|
1658
|
+
organizationMemberships.id
|
|
1659
|
+
],
|
|
1660
|
+
relationName: "organizationMembership"
|
|
1661
|
+
}),
|
|
1662
|
+
channel: one(communicationChannel, {
|
|
1663
|
+
fields: [
|
|
1664
|
+
communicationPreferences.channelId
|
|
1665
|
+
],
|
|
1666
|
+
references: [
|
|
1667
|
+
communicationChannel.id
|
|
1668
|
+
],
|
|
1669
|
+
relationName: "channel"
|
|
1670
|
+
}),
|
|
1671
|
+
preferenceType: one(communicationPreferenceTypes, {
|
|
1672
|
+
fields: [
|
|
1673
|
+
communicationPreferences.preferenceTypeId
|
|
1674
|
+
],
|
|
1675
|
+
references: [
|
|
1676
|
+
communicationPreferenceTypes.id
|
|
1677
|
+
],
|
|
1678
|
+
relationName: "preferenceType"
|
|
1679
|
+
})
|
|
1680
|
+
}));
|
|
1681
|
+
}
|
|
1682
|
+
__name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
|
|
1683
|
+
|
|
1684
|
+
// src/lib/mysql/schemas/auth/accounts.ts
|
|
1685
|
+
import { relations as relations22 } from "drizzle-orm";
|
|
1686
|
+
import { index as index22, int as int7, primaryKey as primaryKey14, text as text3, varchar as varchar22 } from "drizzle-orm/mysql-core";
|
|
1687
|
+
function getAccountsSchema(mysqlTable) {
|
|
1688
|
+
return mysqlTable("Account", {
|
|
1689
|
+
userId: varchar22("userId", {
|
|
1690
|
+
length: 255
|
|
1691
|
+
}).notNull(),
|
|
1692
|
+
type: varchar22("type", {
|
|
1693
|
+
length: 255
|
|
1694
|
+
}).$type().notNull(),
|
|
1695
|
+
provider: varchar22("provider", {
|
|
1696
|
+
length: 255
|
|
1697
|
+
}).notNull(),
|
|
1698
|
+
providerAccountId: varchar22("providerAccountId", {
|
|
1699
|
+
length: 255
|
|
1700
|
+
}).notNull(),
|
|
1701
|
+
refresh_token: text3("refresh_token"),
|
|
1702
|
+
access_token: text3("access_token"),
|
|
1703
|
+
oauth_token: text3("oauth_token"),
|
|
1704
|
+
oauth_token_secret: text3("oauth_token_secret"),
|
|
1705
|
+
expires_at: int7("expires_at"),
|
|
1706
|
+
token_type: varchar22("token_type", {
|
|
1707
|
+
length: 255
|
|
1708
|
+
}),
|
|
1709
|
+
scope: varchar22("scope", {
|
|
1710
|
+
length: 255
|
|
1711
|
+
}),
|
|
1712
|
+
id_token: text3("id_token"),
|
|
1713
|
+
session_state: varchar22("session_state", {
|
|
1714
|
+
length: 255
|
|
1715
|
+
}),
|
|
1716
|
+
refresh_token_expires_in: int7("refresh_token_expires_in")
|
|
1717
|
+
}, (account) => ({
|
|
1718
|
+
pk: primaryKey14({
|
|
1719
|
+
columns: [
|
|
1720
|
+
account.provider,
|
|
1721
|
+
account.providerAccountId
|
|
1722
|
+
]
|
|
1723
|
+
}),
|
|
1724
|
+
userIdIdx: index22("userId_idx").on(account.userId)
|
|
1725
|
+
}));
|
|
1726
|
+
}
|
|
1727
|
+
__name(getAccountsSchema, "getAccountsSchema");
|
|
1728
|
+
function getAccountsRelationsSchema(mysqlTable) {
|
|
1729
|
+
const accounts = getAccountsSchema(mysqlTable);
|
|
1730
|
+
const users = getUsersSchema(mysqlTable);
|
|
1731
|
+
return relations22(accounts, ({ one }) => ({
|
|
1732
|
+
user: one(users, {
|
|
1733
|
+
fields: [
|
|
1734
|
+
accounts.userId
|
|
1735
|
+
],
|
|
1736
|
+
references: [
|
|
1737
|
+
users.id
|
|
1738
|
+
],
|
|
1739
|
+
relationName: "user"
|
|
1740
|
+
})
|
|
1741
|
+
}));
|
|
1742
|
+
}
|
|
1743
|
+
__name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
|
|
1744
|
+
|
|
1745
|
+
// src/lib/mysql/schemas/auth/profiles.ts
|
|
1746
|
+
import { relations as relations23, sql as sql18 } from "drizzle-orm";
|
|
1747
|
+
import { index as index23, json as json15, timestamp as timestamp22, uniqueIndex as uniqueIndex2, varchar as varchar23 } from "drizzle-orm/mysql-core";
|
|
1748
|
+
function getProfilesSchema(mysqlTable) {
|
|
1749
|
+
return mysqlTable("Profile", {
|
|
1750
|
+
id: varchar23("id", {
|
|
1751
|
+
length: 255
|
|
1752
|
+
}).notNull().primaryKey(),
|
|
1753
|
+
userId: varchar23("userId", {
|
|
1754
|
+
length: 255
|
|
1755
|
+
}).notNull(),
|
|
1756
|
+
type: varchar23("type", {
|
|
1757
|
+
length: 255
|
|
1758
|
+
}).notNull(),
|
|
1759
|
+
fields: json15("fields").$type().default({}),
|
|
1760
|
+
createdAt: timestamp22("createdAt", {
|
|
1761
|
+
mode: "date",
|
|
1762
|
+
fsp: 3
|
|
1763
|
+
}).default(sql18`CURRENT_TIMESTAMP(3)`),
|
|
1764
|
+
updatedAt: timestamp22("updatedAt", {
|
|
1765
|
+
mode: "date",
|
|
1766
|
+
fsp: 3
|
|
1767
|
+
}).default(sql18`CURRENT_TIMESTAMP(3)`)
|
|
1768
|
+
}, (profile) => ({
|
|
1769
|
+
userIdIdx: index23("userId_idx").on(profile.userId),
|
|
1770
|
+
uniqueUserType: uniqueIndex2("unique_user_type_idx").on(profile.userId, profile.type)
|
|
1771
|
+
}));
|
|
1772
|
+
}
|
|
1773
|
+
__name(getProfilesSchema, "getProfilesSchema");
|
|
1774
|
+
function getProfilesRelationsSchema(mysqlTable) {
|
|
1775
|
+
const profiles = getProfilesSchema(mysqlTable);
|
|
1776
|
+
const users = getUsersSchema(mysqlTable);
|
|
1777
|
+
return relations23(profiles, ({ one }) => ({
|
|
1778
|
+
user: one(users, {
|
|
1779
|
+
fields: [
|
|
1780
|
+
profiles.userId
|
|
1781
|
+
],
|
|
1782
|
+
references: [
|
|
1783
|
+
users.id
|
|
1784
|
+
],
|
|
1785
|
+
relationName: "profiles"
|
|
1786
|
+
})
|
|
1787
|
+
}));
|
|
1788
|
+
}
|
|
1789
|
+
__name(getProfilesRelationsSchema, "getProfilesRelationsSchema");
|
|
1790
|
+
|
|
1791
|
+
// src/lib/mysql/schemas/auth/user-permissions.ts
|
|
1792
|
+
import { relations as relations24 } from "drizzle-orm";
|
|
1793
|
+
import { boolean as boolean6, index as index24, primaryKey as primaryKey15, timestamp as timestamp23, varchar as varchar24 } from "drizzle-orm/mysql-core";
|
|
1794
|
+
function getUserPermissionsSchema(mysqlTable) {
|
|
1795
|
+
return mysqlTable("UserPermission", {
|
|
1796
|
+
userId: varchar24("userId", {
|
|
1797
|
+
length: 255
|
|
1798
|
+
}).notNull(),
|
|
1799
|
+
organizationId: varchar24("organizationId", {
|
|
1800
|
+
length: 191
|
|
1801
|
+
}),
|
|
1802
|
+
permissionId: varchar24("permissionId", {
|
|
1803
|
+
length: 255
|
|
1804
|
+
}).notNull(),
|
|
1805
|
+
active: boolean6("active").notNull().default(true),
|
|
1806
|
+
createdAt: timestamp23("createdAt", {
|
|
1807
|
+
mode: "date",
|
|
1808
|
+
fsp: 3
|
|
1809
|
+
}).defaultNow(),
|
|
1810
|
+
updatedAt: timestamp23("updatedAt", {
|
|
1811
|
+
mode: "date",
|
|
1812
|
+
fsp: 3
|
|
1813
|
+
}).defaultNow(),
|
|
1814
|
+
deletedAt: timestamp23("deletedAt", {
|
|
1815
|
+
mode: "date",
|
|
1816
|
+
fsp: 3
|
|
1817
|
+
})
|
|
1818
|
+
}, (up) => ({
|
|
1819
|
+
pk: primaryKey15({
|
|
1820
|
+
columns: [
|
|
1821
|
+
up.userId,
|
|
1822
|
+
up.permissionId
|
|
1823
|
+
]
|
|
1824
|
+
}),
|
|
1825
|
+
userIdIdx: index24("userId_idx").on(up.userId),
|
|
1826
|
+
permissionIdIdx: index24("permissionId_idx").on(up.permissionId),
|
|
1827
|
+
organizationIdIdx: index24("organizationId_idx").on(up.organizationId)
|
|
1828
|
+
}));
|
|
1829
|
+
}
|
|
1830
|
+
__name(getUserPermissionsSchema, "getUserPermissionsSchema");
|
|
1831
|
+
function getUserPermissionsRelationsSchema(mysqlTable) {
|
|
1832
|
+
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
1833
|
+
const users = getUsersSchema(mysqlTable);
|
|
1834
|
+
const permissions = getPermissionsSchema(mysqlTable);
|
|
1835
|
+
return relations24(userPermissions, ({ one }) => ({
|
|
1836
|
+
user: one(users, {
|
|
1837
|
+
fields: [
|
|
1838
|
+
userPermissions.userId
|
|
1839
|
+
],
|
|
1840
|
+
references: [
|
|
1841
|
+
users.id
|
|
1842
|
+
],
|
|
1843
|
+
relationName: "user"
|
|
1844
|
+
}),
|
|
1845
|
+
permission: one(permissions, {
|
|
1846
|
+
fields: [
|
|
1847
|
+
userPermissions.permissionId
|
|
1848
|
+
],
|
|
1849
|
+
references: [
|
|
1850
|
+
permissions.id
|
|
1851
|
+
],
|
|
1852
|
+
relationName: "permission"
|
|
1853
|
+
})
|
|
1854
|
+
}));
|
|
1855
|
+
}
|
|
1856
|
+
__name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
|
|
1857
|
+
|
|
1858
|
+
// src/lib/mysql/schemas/auth/user-prefs.ts
|
|
1859
|
+
import { relations as relations25, sql as sql19 } from "drizzle-orm";
|
|
1860
|
+
import { index as index25, json as json16, primaryKey as primaryKey16, timestamp as timestamp24, varchar as varchar25 } from "drizzle-orm/mysql-core";
|
|
1861
|
+
function getUserPrefsSchema(mysqlTable) {
|
|
1862
|
+
return mysqlTable("UserPrefs", {
|
|
1863
|
+
id: varchar25("id", {
|
|
1864
|
+
length: 191
|
|
1865
|
+
}).notNull(),
|
|
1866
|
+
organizationId: varchar25("organizationId", {
|
|
1867
|
+
length: 191
|
|
1868
|
+
}),
|
|
1869
|
+
type: varchar25("type", {
|
|
1870
|
+
length: 191
|
|
1871
|
+
}).default("Global").notNull(),
|
|
1872
|
+
userId: varchar25("userId", {
|
|
1873
|
+
length: 255
|
|
1874
|
+
}).notNull(),
|
|
1875
|
+
fields: json16("fields").$type().default({}),
|
|
1876
|
+
createdAt: timestamp24("createdAt", {
|
|
1877
|
+
mode: "date",
|
|
1878
|
+
fsp: 3
|
|
1879
|
+
}).default(sql19`CURRENT_TIMESTAMP(3)`),
|
|
1880
|
+
updatedAt: timestamp24("updatedAt", {
|
|
1881
|
+
mode: "date",
|
|
1882
|
+
fsp: 3
|
|
1883
|
+
}).default(sql19`CURRENT_TIMESTAMP(3)`),
|
|
1884
|
+
deletedAt: timestamp24("deletedAt", {
|
|
1885
|
+
mode: "date",
|
|
1886
|
+
fsp: 3
|
|
1887
|
+
})
|
|
1888
|
+
}, (crr) => ({
|
|
1889
|
+
pk: primaryKey16({
|
|
1890
|
+
columns: [
|
|
1891
|
+
crr.id
|
|
1892
|
+
]
|
|
1893
|
+
}),
|
|
1894
|
+
crrUserIdIdKey: index25("crr_userIdId_idx").on(crr.userId),
|
|
1895
|
+
organizationIdIdx: index25("organizationId_idx").on(crr.organizationId)
|
|
1896
|
+
}));
|
|
1897
|
+
}
|
|
1898
|
+
__name(getUserPrefsSchema, "getUserPrefsSchema");
|
|
1899
|
+
function getUserPrefsRelationsSchema(mysqlTable) {
|
|
1900
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
1901
|
+
const user = getUsersSchema(mysqlTable);
|
|
1902
|
+
return relations25(userPrefs, ({ one }) => ({
|
|
1903
|
+
user: one(user, {
|
|
1904
|
+
fields: [
|
|
1905
|
+
userPrefs.userId
|
|
1906
|
+
],
|
|
1907
|
+
references: [
|
|
1908
|
+
user.id
|
|
1909
|
+
],
|
|
1910
|
+
relationName: "user"
|
|
1911
|
+
})
|
|
1912
|
+
}));
|
|
1913
|
+
}
|
|
1914
|
+
__name(getUserPrefsRelationsSchema, "getUserPrefsRelationsSchema");
|
|
1915
|
+
|
|
1916
|
+
// src/lib/mysql/schemas/auth/users.ts
|
|
1917
|
+
function getUsersSchema(mysqlTable) {
|
|
1918
|
+
return mysqlTable("User", {
|
|
1919
|
+
id: varchar26("id", {
|
|
1920
|
+
length: 255
|
|
1921
|
+
}).notNull().primaryKey(),
|
|
1922
|
+
name: varchar26("name", {
|
|
1923
|
+
length: 255
|
|
1924
|
+
}),
|
|
1925
|
+
role: varchar26("role", {
|
|
1926
|
+
length: 191
|
|
1927
|
+
}).notNull().default("user"),
|
|
1928
|
+
email: varchar26("email", {
|
|
1929
|
+
length: 255
|
|
1930
|
+
}).notNull().unique(),
|
|
1931
|
+
fields: json17("fields").$type().default({}),
|
|
1932
|
+
emailVerified: timestamp25("emailVerified", {
|
|
1933
|
+
mode: "date",
|
|
1934
|
+
fsp: 3
|
|
1935
|
+
}),
|
|
1936
|
+
image: varchar26("image", {
|
|
1937
|
+
length: 255
|
|
1938
|
+
}),
|
|
1939
|
+
createdAt: timestamp25("createdAt", {
|
|
1940
|
+
mode: "date",
|
|
1941
|
+
fsp: 3
|
|
1942
|
+
}).default(sql20`CURRENT_TIMESTAMP(3)`)
|
|
1943
|
+
}, (user) => ({
|
|
1944
|
+
emailIdx: index26("email_idx").on(user.email),
|
|
1945
|
+
roleIdx: index26("role_idx").on(user.role),
|
|
1946
|
+
createdAtIdx: index26("created_at_idx").on(user.createdAt)
|
|
1947
|
+
}));
|
|
1948
|
+
}
|
|
1949
|
+
__name(getUsersSchema, "getUsersSchema");
|
|
1950
|
+
function getUsersRelationsSchema(mysqlTable) {
|
|
1951
|
+
const users = getUsersSchema(mysqlTable);
|
|
1952
|
+
const profiles = getProfilesSchema(mysqlTable);
|
|
1953
|
+
const accounts = getAccountsSchema(mysqlTable);
|
|
1954
|
+
const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
|
|
1955
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
1956
|
+
const userPermissions = getUserPermissionsSchema(mysqlTable);
|
|
1957
|
+
const contentContributions = getContentContributionsSchema(mysqlTable);
|
|
1958
|
+
const contentResource = getContentResourceSchema(mysqlTable);
|
|
1959
|
+
const purchases = getPurchaseSchema(mysqlTable);
|
|
1960
|
+
const comments = getCommentsSchema(mysqlTable);
|
|
1961
|
+
const userPrefs = getUserPrefsSchema(mysqlTable);
|
|
1962
|
+
const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable);
|
|
1963
|
+
return relations26(users, ({ many, one }) => ({
|
|
1964
|
+
profiles: many(profiles, {
|
|
1965
|
+
relationName: "profiles"
|
|
1966
|
+
}),
|
|
1967
|
+
accounts: many(accounts, {
|
|
1968
|
+
relationName: "user"
|
|
1969
|
+
}),
|
|
1970
|
+
purchases: many(purchases, {
|
|
1971
|
+
relationName: "user"
|
|
1972
|
+
}),
|
|
1973
|
+
communicationPreferences: many(communicationPreferences, {
|
|
1974
|
+
relationName: "user"
|
|
1975
|
+
}),
|
|
1976
|
+
roles: many(userRoles, {
|
|
1977
|
+
relationName: "user"
|
|
1978
|
+
}),
|
|
1979
|
+
userPermissions: many(userPermissions, {
|
|
1980
|
+
relationName: "user"
|
|
1981
|
+
}),
|
|
1982
|
+
contributions: many(contentContributions, {
|
|
1983
|
+
relationName: "user"
|
|
1984
|
+
}),
|
|
1985
|
+
createdContent: many(contentResource, {
|
|
1986
|
+
relationName: "user"
|
|
1987
|
+
}),
|
|
1988
|
+
comments: many(comments, {
|
|
1989
|
+
relationName: "user"
|
|
1990
|
+
}),
|
|
1991
|
+
prefs: many(userPrefs, {
|
|
1992
|
+
relationName: "user"
|
|
1993
|
+
}),
|
|
1994
|
+
organizationMemberships: many(organizationMemberships, {
|
|
1995
|
+
relationName: "user"
|
|
1996
|
+
})
|
|
1997
|
+
}));
|
|
1998
|
+
}
|
|
1999
|
+
__name(getUsersRelationsSchema, "getUsersRelationsSchema");
|
|
2000
|
+
|
|
2001
|
+
// src/lib/mysql/schemas/auth/user-roles.ts
|
|
2002
|
+
function getUserRolesSchema(mysqlTable) {
|
|
2003
|
+
return mysqlTable("UserRole", {
|
|
2004
|
+
userId: varchar27("userId", {
|
|
2005
|
+
length: 255
|
|
2006
|
+
}).notNull(),
|
|
2007
|
+
roleId: varchar27("roleId", {
|
|
2008
|
+
length: 255
|
|
2009
|
+
}).notNull(),
|
|
2010
|
+
active: boolean7("active").notNull().default(true),
|
|
2011
|
+
organizationId: varchar27("organizationId", {
|
|
2012
|
+
length: 191
|
|
2013
|
+
}),
|
|
2014
|
+
createdAt: timestamp26("createdAt", {
|
|
2015
|
+
mode: "date",
|
|
2016
|
+
fsp: 3
|
|
2017
|
+
}).defaultNow(),
|
|
2018
|
+
updatedAt: timestamp26("updatedAt", {
|
|
2019
|
+
mode: "date",
|
|
2020
|
+
fsp: 3
|
|
2021
|
+
}).defaultNow(),
|
|
2022
|
+
deletedAt: timestamp26("deletedAt", {
|
|
2023
|
+
mode: "date",
|
|
2024
|
+
fsp: 3
|
|
2025
|
+
})
|
|
2026
|
+
}, (ur) => ({
|
|
2027
|
+
pk: primaryKey17({
|
|
2028
|
+
columns: [
|
|
2029
|
+
ur.userId,
|
|
2030
|
+
ur.roleId
|
|
2031
|
+
]
|
|
2032
|
+
}),
|
|
2033
|
+
userIdIdx: index27("userId_idx").on(ur.userId),
|
|
2034
|
+
roleIdIdx: index27("roleId_idx").on(ur.roleId),
|
|
2035
|
+
organizationIdIdx: index27("organizationId_idx").on(ur.organizationId)
|
|
2036
|
+
}));
|
|
2037
|
+
}
|
|
2038
|
+
__name(getUserRolesSchema, "getUserRolesSchema");
|
|
2039
|
+
function getUserRolesRelationsSchema(mysqlTable) {
|
|
2040
|
+
const userRoles = getUserRolesSchema(mysqlTable);
|
|
2041
|
+
const users = getUsersSchema(mysqlTable);
|
|
2042
|
+
const roles = getRolesSchema(mysqlTable);
|
|
2043
|
+
return relations27(userRoles, ({ one }) => ({
|
|
2044
|
+
user: one(users, {
|
|
2045
|
+
fields: [
|
|
2046
|
+
userRoles.userId
|
|
2047
|
+
],
|
|
2048
|
+
references: [
|
|
2049
|
+
users.id
|
|
2050
|
+
],
|
|
2051
|
+
relationName: "user"
|
|
2052
|
+
}),
|
|
2053
|
+
role: one(roles, {
|
|
2054
|
+
fields: [
|
|
2055
|
+
userRoles.roleId
|
|
2056
|
+
],
|
|
2057
|
+
references: [
|
|
2058
|
+
roles.id
|
|
2059
|
+
],
|
|
2060
|
+
relationName: "role"
|
|
2061
|
+
})
|
|
2062
|
+
}));
|
|
2063
|
+
}
|
|
2064
|
+
__name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
|
|
2065
|
+
|
|
2066
|
+
export {
|
|
2067
|
+
getUserRolesSchema,
|
|
2068
|
+
getUserRolesRelationsSchema,
|
|
2069
|
+
getRolesSchema,
|
|
2070
|
+
getRolesRelationsSchema,
|
|
2071
|
+
getMerchantChargeSchema,
|
|
2072
|
+
getMerchantChargeRelationsSchema,
|
|
2073
|
+
getMerchantSubscriptionSchema,
|
|
2074
|
+
getMerchantSubscriptionRelationsSchema,
|
|
2075
|
+
getContentContributionsSchema,
|
|
2076
|
+
getContentContributionRelationsSchema,
|
|
2077
|
+
getContentResourceResourceSchema,
|
|
2078
|
+
getContentResourceResourceRelationsSchema,
|
|
2079
|
+
getTagTagSchema,
|
|
2080
|
+
getTagTagRelationsSchema,
|
|
2081
|
+
getTagSchema,
|
|
2082
|
+
getTagRelationsSchema,
|
|
2083
|
+
getContentResourceTagSchema,
|
|
2084
|
+
getContentResourceTagRelationsSchema,
|
|
2085
|
+
getContentResourceVersionSchema,
|
|
2086
|
+
getContentResourceVersionRelationsSchema,
|
|
2087
|
+
getContentResourceSchema,
|
|
2088
|
+
getContentResourceRelationsSchema,
|
|
2089
|
+
getContentResourceProductSchema,
|
|
2090
|
+
getContentResourceProductRelationsSchema,
|
|
2091
|
+
getPriceSchema,
|
|
2092
|
+
getProductRelationsSchema,
|
|
2093
|
+
getProductSchema,
|
|
2094
|
+
getProductRelationsSchema2,
|
|
2095
|
+
getSubscriptionSchema,
|
|
2096
|
+
getSubscriptionRelationsSchema,
|
|
2097
|
+
getOrganizationsSchema,
|
|
2098
|
+
getOrganizationsRelationsSchema,
|
|
2099
|
+
getOrganizationMembershipRolesSchema,
|
|
2100
|
+
getOrganizationMembershipRolesRelationsSchema,
|
|
2101
|
+
getOrganizationMembershipsSchema,
|
|
2102
|
+
getOrganizationMembershipsRelationsSchema,
|
|
2103
|
+
getCouponSchema,
|
|
2104
|
+
getCouponRelationsSchema,
|
|
2105
|
+
getPurchaseSchema,
|
|
2106
|
+
getPurchaseRelationsSchema,
|
|
2107
|
+
getCommentsSchema,
|
|
2108
|
+
getCommentRelationsSchema,
|
|
2109
|
+
getCommunicationPreferencesSchema,
|
|
2110
|
+
getCommunicationPreferencesRelationsSchema,
|
|
2111
|
+
getProfilesSchema,
|
|
2112
|
+
getProfilesRelationsSchema,
|
|
2113
|
+
getUserPermissionsSchema,
|
|
2114
|
+
getUserPermissionsRelationsSchema,
|
|
2115
|
+
getUserPrefsSchema,
|
|
2116
|
+
getUserPrefsRelationsSchema,
|
|
2117
|
+
getUsersSchema,
|
|
2118
|
+
getUsersRelationsSchema,
|
|
2119
|
+
getAccountsSchema,
|
|
2120
|
+
getAccountsRelationsSchema
|
|
2121
|
+
};
|
|
2122
|
+
//# sourceMappingURL=chunk-LPJ2P2KJ.js.map
|