@coursebuilder/adapter-drizzle 1.0.0 → 1.0.2
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-253RMSB3.js +99 -0
- package/dist/{chunk-3WYG5OE7.js → chunk-3GONHHMY.js} +2 -2
- package/dist/{chunk-L5ZAWSTN.js → chunk-5QEGBX2O.js} +411 -120
- package/dist/{chunk-WFC55BSF.js → chunk-FPAQINSA.js} +2 -2
- package/dist/{chunk-RCL6HPBL.js → chunk-HWIQUI7O.js} +2 -2
- package/dist/{chunk-QGZ2F5SW.js → chunk-LPJ2P2KJ.js} +1162 -1027
- package/dist/{chunk-GAKWXOAY.js → chunk-OBUGOZKM.js} +2 -2
- package/dist/chunk-ORRM7KVW.js +25 -0
- package/dist/{chunk-A6XPL665.js → chunk-PBTEHA7F.js} +2 -2
- package/dist/{chunk-5XTOCFDB.js → chunk-YQNIXCD3.js} +2 -2
- package/dist/index.js +11 -10
- package/dist/lib/mysql/index.cjs +1513 -1060
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +2994 -2258
- package/dist/lib/mysql/index.d.ts +2994 -2258
- package/dist/lib/mysql/index.js +11 -10
- package/dist/lib/mysql/schemas/auth/accounts.cjs +106 -98
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +2 -2
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs +99 -91
- package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-access-token.js +3 -3
- package/dist/lib/mysql/schemas/auth/device-verification.cjs +100 -92
- package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/device-verification.js +3 -3
- 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 +55 -46
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +3 -3
- package/dist/lib/mysql/schemas/auth/roles.cjs +57 -48
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +2 -2
- package/dist/lib/mysql/schemas/auth/sessions.cjs +96 -88
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +3 -3
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +99 -91
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs +104 -96
- package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-prefs.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +58 -49
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +2 -2
- package/dist/lib/mysql/schemas/auth/users.cjs +295 -259
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.d.cts +1 -0
- package/dist/lib/mysql/schemas/auth/users.d.ts +1 -0
- package/dist/lib/mysql/schemas/auth/users.js +2 -2
- package/dist/lib/mysql/schemas/commerce/coupon.cjs +131 -123
- package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/coupon.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +96 -88
- package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +2 -2
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +90 -82
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +2 -2
- package/dist/lib/mysql/schemas/commerce/price.cjs +98 -90
- package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/price.js +2 -2
- package/dist/lib/mysql/schemas/commerce/product.cjs +125 -117
- package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/product.js +2 -2
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +131 -123
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +3 -3
- package/dist/lib/mysql/schemas/commerce/purchase.cjs +184 -176
- package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/purchase.js +2 -2
- package/dist/lib/mysql/schemas/commerce/subscription.cjs +117 -109
- package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/subscription.js +2 -2
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +105 -97
- package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +3 -3
- package/dist/lib/mysql/schemas/communication/comment.cjs +114 -106
- package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/comment.js +2 -2
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +136 -128
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +2 -2
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +144 -136
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs +99 -91
- package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-product.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +108 -100
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +118 -110
- package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs +121 -113
- package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-version.js +2 -2
- package/dist/lib/mysql/schemas/content/content-resource.cjs +198 -190
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +2 -2
- package/dist/lib/mysql/schemas/content/tag-tag.cjs +103 -95
- package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag-tag.js +2 -2
- package/dist/lib/mysql/schemas/content/tag.cjs +116 -108
- package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/tag.js +2 -2
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.cjs +46 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.cjs.map +1 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.d.cts +60 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.d.ts +60 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.js +8 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement-type.js.map +1 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +351 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement.d.cts +210 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement.d.ts +210 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement.js +21 -0
- package/dist/lib/mysql/schemas/entitlements/entitlement.js.map +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +73 -35
- package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +1 -0
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +2 -3
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs +88 -38
- package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +1 -0
- package/dist/lib/mysql/schemas/org/organization-memberships.js +2 -2
- package/dist/lib/mysql/schemas/org/organizations.cjs +131 -121
- package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
- package/dist/lib/mysql/schemas/org/organizations.js +2 -2
- package/package.json +4 -3
- package/src/lib/mysql/index.ts +349 -26
- package/src/lib/mysql/schemas/auth/profiles.ts +50 -0
- package/src/lib/mysql/schemas/auth/roles.ts +6 -1
- package/src/lib/mysql/schemas/auth/users.ts +6 -1
- package/src/lib/mysql/schemas/commerce/subscription.ts +3 -5
- package/src/lib/mysql/schemas/entitlements/entitlement-type.ts +21 -0
- package/src/lib/mysql/schemas/entitlements/entitlement.ts +66 -0
- package/src/lib/mysql/schemas/org/organization-membership-roles.ts +7 -0
- package/src/lib/mysql/schemas/org/organization-memberships.ts +6 -0
- package/dist/chunk-RP66NZN3.js +0 -81
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEntitlementRelationsSchema,
|
|
3
|
+
getEntitlementsSchema
|
|
4
|
+
} from "./chunk-253RMSB3.js";
|
|
1
5
|
import {
|
|
2
6
|
getLessonProgressSchema
|
|
3
7
|
} from "./chunk-ET3QAIY7.js";
|
|
@@ -5,36 +9,35 @@ import {
|
|
|
5
9
|
getResourceProgressSchema
|
|
6
10
|
} from "./chunk-6YPHJWS2.js";
|
|
7
11
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "./chunk-RP66NZN3.js";
|
|
12
|
+
getEntitlementTypesSchema
|
|
13
|
+
} from "./chunk-ORRM7KVW.js";
|
|
11
14
|
import {
|
|
12
15
|
getPurchaseUserTransferRelationsSchema,
|
|
13
16
|
getPurchaseUserTransferSchema
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-HWIQUI7O.js";
|
|
15
18
|
import {
|
|
16
19
|
getUpgradableProductsRelationsSchema,
|
|
17
20
|
getUpgradableProductsSchema
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-FPAQINSA.js";
|
|
22
|
+
import {
|
|
23
|
+
getVerificationTokensSchema
|
|
24
|
+
} from "./chunk-LERR6HQ3.js";
|
|
19
25
|
import {
|
|
20
26
|
getRolePermissionsRelationsSchema,
|
|
21
27
|
getRolePermissionsSchema
|
|
22
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-3GONHHMY.js";
|
|
23
29
|
import {
|
|
24
30
|
getSessionRelationsSchema,
|
|
25
31
|
getSessionsSchema
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import {
|
|
28
|
-
getVerificationTokensSchema
|
|
29
|
-
} from "./chunk-LERR6HQ3.js";
|
|
32
|
+
} from "./chunk-PBTEHA7F.js";
|
|
30
33
|
import {
|
|
31
34
|
getDeviceAccessTokenRelationsSchema,
|
|
32
35
|
getDeviceAccessTokenSchema
|
|
33
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-YQNIXCD3.js";
|
|
34
37
|
import {
|
|
35
38
|
getDeviceVerificationRelationsSchema,
|
|
36
39
|
getDeviceVerificationSchema
|
|
37
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-OBUGOZKM.js";
|
|
38
41
|
import {
|
|
39
42
|
getAccountsRelationsSchema,
|
|
40
43
|
getAccountsSchema,
|
|
@@ -60,6 +63,8 @@ import {
|
|
|
60
63
|
getMerchantChargeSchema,
|
|
61
64
|
getMerchantSubscriptionRelationsSchema,
|
|
62
65
|
getMerchantSubscriptionSchema,
|
|
66
|
+
getOrganizationMembershipRolesRelationsSchema,
|
|
67
|
+
getOrganizationMembershipRolesSchema,
|
|
63
68
|
getOrganizationMembershipsRelationsSchema,
|
|
64
69
|
getOrganizationMembershipsSchema,
|
|
65
70
|
getOrganizationsRelationsSchema,
|
|
@@ -67,6 +72,8 @@ import {
|
|
|
67
72
|
getPriceSchema,
|
|
68
73
|
getProductRelationsSchema2 as getProductRelationsSchema,
|
|
69
74
|
getProductSchema,
|
|
75
|
+
getProfilesRelationsSchema,
|
|
76
|
+
getProfilesSchema,
|
|
70
77
|
getPurchaseRelationsSchema,
|
|
71
78
|
getPurchaseSchema,
|
|
72
79
|
getRolesRelationsSchema,
|
|
@@ -85,7 +92,7 @@ import {
|
|
|
85
92
|
getUserRolesSchema,
|
|
86
93
|
getUsersRelationsSchema,
|
|
87
94
|
getUsersSchema
|
|
88
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-LPJ2P2KJ.js";
|
|
89
96
|
import {
|
|
90
97
|
getContributionTypesRelationsSchema,
|
|
91
98
|
getContributionTypesSchema
|
|
@@ -96,6 +103,9 @@ import {
|
|
|
96
103
|
import {
|
|
97
104
|
getCommunicationPreferenceTypesSchema
|
|
98
105
|
} from "./chunk-EHRARBRS.js";
|
|
106
|
+
import {
|
|
107
|
+
getMerchantSessionSchema
|
|
108
|
+
} from "./chunk-BLDW3QUS.js";
|
|
99
109
|
import {
|
|
100
110
|
getMerchantAccountSchema
|
|
101
111
|
} from "./chunk-DKJO4Y3K.js";
|
|
@@ -111,9 +121,6 @@ import {
|
|
|
111
121
|
import {
|
|
112
122
|
getMerchantProductSchema
|
|
113
123
|
} from "./chunk-KPBVZ44W.js";
|
|
114
|
-
import {
|
|
115
|
-
getMerchantSessionSchema
|
|
116
|
-
} from "./chunk-BLDW3QUS.js";
|
|
117
124
|
import {
|
|
118
125
|
getPermissionsRelationsSchema,
|
|
119
126
|
getPermissionsSchema
|
|
@@ -8166,38 +8173,26 @@ var VideoResourceSchema = z2.object({
|
|
|
8166
8173
|
])
|
|
8167
8174
|
});
|
|
8168
8175
|
|
|
8169
|
-
// ../core/dist/chunk-
|
|
8170
|
-
var
|
|
8171
|
-
id: z2.string().max(255),
|
|
8172
|
-
name: z2.string().max(255).optional().nullable(),
|
|
8173
|
-
role: z2.enum([
|
|
8174
|
-
"user",
|
|
8175
|
-
"admin"
|
|
8176
|
-
]).default("user"),
|
|
8177
|
-
email: z2.string().max(255).email(),
|
|
8178
|
-
emailVerified: z2.coerce.date().nullable(),
|
|
8179
|
-
image: z2.string().max(255).optional().nullable(),
|
|
8180
|
-
createdAt: z2.coerce.date().nullable(),
|
|
8181
|
-
roles: z2.array(z2.object({
|
|
8182
|
-
id: z2.string(),
|
|
8183
|
-
name: z2.string(),
|
|
8184
|
-
description: z2.string().nullable(),
|
|
8185
|
-
active: z2.boolean()
|
|
8186
|
-
})).optional().default([])
|
|
8187
|
-
});
|
|
8188
|
-
|
|
8189
|
-
// ../core/dist/chunk-47RWEDJ6.js
|
|
8190
|
-
var priceSchema = z2.object({
|
|
8176
|
+
// ../core/dist/chunk-LMH5A7OR.js
|
|
8177
|
+
var purchaseUserTransferSchema = z2.object({
|
|
8191
8178
|
id: z2.string().max(191),
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8179
|
+
transferState: z2.enum([
|
|
8180
|
+
"AVAILABLE",
|
|
8181
|
+
"INITIATED",
|
|
8182
|
+
"VERIFIED",
|
|
8183
|
+
"CANCELED",
|
|
8184
|
+
"EXPIRED",
|
|
8185
|
+
"CONFIRMED",
|
|
8186
|
+
"COMPLETED"
|
|
8187
|
+
]).default("AVAILABLE"),
|
|
8188
|
+
purchaseId: z2.string().max(191),
|
|
8189
|
+
sourceUserId: z2.string().max(191),
|
|
8190
|
+
targetUserId: z2.string().max(191).optional().nullable(),
|
|
8199
8191
|
createdAt: z2.date().nullable(),
|
|
8200
|
-
|
|
8192
|
+
expiresAt: z2.date().nullable(),
|
|
8193
|
+
canceledAt: z2.date().nullable(),
|
|
8194
|
+
confirmedAt: z2.date().nullable(),
|
|
8195
|
+
completedAt: z2.date().nullable()
|
|
8201
8196
|
});
|
|
8202
8197
|
|
|
8203
8198
|
// ../core/dist/chunk-SCKAG5RT.js
|
|
@@ -8247,14 +8242,94 @@ var ResourceVisibilitySchema = z2.union([
|
|
|
8247
8242
|
z2.literal("unlisted")
|
|
8248
8243
|
]);
|
|
8249
8244
|
|
|
8250
|
-
// ../core/dist/chunk-
|
|
8245
|
+
// ../core/dist/chunk-PG6VF2O6.js
|
|
8246
|
+
var resourceProgressSchema = z2.object({
|
|
8247
|
+
userId: z2.string().max(191),
|
|
8248
|
+
resourceId: z2.string().max(191).optional().nullable(),
|
|
8249
|
+
completedAt: z2.date().nullable()
|
|
8250
|
+
});
|
|
8251
|
+
var moduleProgressSchema = z2.object({
|
|
8252
|
+
completedLessons: z2.array(resourceProgressSchema),
|
|
8253
|
+
nextResource: ContentResourceSchema.partial().nullable(),
|
|
8254
|
+
percentCompleted: z2.number().default(0),
|
|
8255
|
+
completedLessonsCount: z2.number().default(0),
|
|
8256
|
+
totalLessonsCount: z2.number().default(0)
|
|
8257
|
+
});
|
|
8258
|
+
|
|
8259
|
+
// ../core/dist/chunk-DLQA3JMA.js
|
|
8260
|
+
var upgradableProductSchema = z2.object({
|
|
8261
|
+
upgradableToId: z2.string().max(255),
|
|
8262
|
+
upgradableFromId: z2.string().max(255),
|
|
8263
|
+
position: z2.number().default(0),
|
|
8264
|
+
metadata: z2.record(z2.any()).default({}),
|
|
8265
|
+
createdAt: z2.date().nullable(),
|
|
8266
|
+
updatedAt: z2.date().nullable(),
|
|
8267
|
+
deletedAt: z2.date().nullable()
|
|
8268
|
+
});
|
|
8269
|
+
|
|
8270
|
+
// ../core/dist/chunk-JZBK2DS3.js
|
|
8271
|
+
var userSchema = z2.object({
|
|
8272
|
+
id: z2.string().max(255),
|
|
8273
|
+
name: z2.string().max(255).optional().nullable(),
|
|
8274
|
+
role: z2.enum([
|
|
8275
|
+
"user",
|
|
8276
|
+
"admin"
|
|
8277
|
+
]).default("user"),
|
|
8278
|
+
email: z2.string().max(255).email(),
|
|
8279
|
+
emailVerified: z2.coerce.date().nullish(),
|
|
8280
|
+
image: z2.string().max(255).optional().nullable(),
|
|
8281
|
+
createdAt: z2.coerce.date().nullish(),
|
|
8282
|
+
memberships: z2.array(z2.object({
|
|
8283
|
+
id: z2.string(),
|
|
8284
|
+
organizationId: z2.string()
|
|
8285
|
+
})).nullish().default([]),
|
|
8286
|
+
roles: z2.array(z2.object({
|
|
8287
|
+
id: z2.string(),
|
|
8288
|
+
name: z2.string(),
|
|
8289
|
+
description: z2.string().nullable(),
|
|
8290
|
+
active: z2.boolean(),
|
|
8291
|
+
createdAt: z2.coerce.date().nullish(),
|
|
8292
|
+
updatedAt: z2.coerce.date().nullish(),
|
|
8293
|
+
deletedAt: z2.coerce.date().nullish()
|
|
8294
|
+
})).optional().default([]),
|
|
8295
|
+
organizationRoles: z2.array(z2.object({
|
|
8296
|
+
id: z2.string(),
|
|
8297
|
+
organizationId: z2.string(),
|
|
8298
|
+
name: z2.string(),
|
|
8299
|
+
description: z2.string().nullable(),
|
|
8300
|
+
active: z2.boolean(),
|
|
8301
|
+
createdAt: z2.coerce.date().nullish(),
|
|
8302
|
+
updatedAt: z2.coerce.date().nullish(),
|
|
8303
|
+
deletedAt: z2.coerce.date().nullish()
|
|
8304
|
+
})).optional().default([])
|
|
8305
|
+
});
|
|
8306
|
+
|
|
8307
|
+
// ../core/dist/chunk-M7IDYIVK.js
|
|
8308
|
+
var priceSchema = z2.object({
|
|
8309
|
+
id: z2.string().max(191),
|
|
8310
|
+
productId: z2.string().max(191).optional().nullable(),
|
|
8311
|
+
organizationId: z2.string().max(191).optional().nullable(),
|
|
8312
|
+
nickname: z2.string().max(191).optional().nullable(),
|
|
8313
|
+
status: z2.number().int().default(0),
|
|
8314
|
+
unitAmount: z2.coerce.number().refine((value) => {
|
|
8315
|
+
const decimalPlaces = value.toString().split(".")[1]?.length || 0;
|
|
8316
|
+
return decimalPlaces <= 2;
|
|
8317
|
+
}),
|
|
8318
|
+
createdAt: z2.date().nullable(),
|
|
8319
|
+
fields: z2.record(z2.any()).default({})
|
|
8320
|
+
});
|
|
8321
|
+
|
|
8322
|
+
// ../core/dist/chunk-FMAXYBP4.js
|
|
8251
8323
|
var productSchema = z2.object({
|
|
8252
8324
|
id: z2.string().max(191),
|
|
8325
|
+
organizationId: z2.string().max(191).optional().nullable(),
|
|
8253
8326
|
name: z2.string().max(191),
|
|
8254
8327
|
key: z2.string().max(191).optional().nullable(),
|
|
8255
8328
|
type: z2.enum([
|
|
8256
8329
|
"live",
|
|
8257
|
-
"self-paced"
|
|
8330
|
+
"self-paced",
|
|
8331
|
+
"membership",
|
|
8332
|
+
"cohort"
|
|
8258
8333
|
]).default("self-paced"),
|
|
8259
8334
|
fields: z2.object({
|
|
8260
8335
|
body: z2.string().nullable().optional(),
|
|
@@ -8291,7 +8366,7 @@ var NewProductSchema = z2.object({
|
|
|
8291
8366
|
price: z2.coerce.number().gte(0).default(0)
|
|
8292
8367
|
});
|
|
8293
8368
|
|
|
8294
|
-
// ../core/dist/chunk-
|
|
8369
|
+
// ../core/dist/chunk-K4MXE7BY.js
|
|
8295
8370
|
var couponSchema = z2.object({
|
|
8296
8371
|
id: z2.string(),
|
|
8297
8372
|
code: z2.string().max(191).optional().nullable(),
|
|
@@ -8310,10 +8385,11 @@ var couponSchema = z2.object({
|
|
|
8310
8385
|
restrictedToProductId: z2.string().max(191).optional().nullable(),
|
|
8311
8386
|
bulkPurchases: z2.array(z2.any()).default([]),
|
|
8312
8387
|
redeemedBulkCouponPurchases: z2.array(z2.any()).default([]),
|
|
8313
|
-
bulkPurchaseId: z2.string().max(191).optional().nullable()
|
|
8388
|
+
bulkPurchaseId: z2.string().max(191).optional().nullable(),
|
|
8389
|
+
organizationId: z2.string().max(191).optional().nullable()
|
|
8314
8390
|
});
|
|
8315
8391
|
|
|
8316
|
-
// ../core/dist/chunk-
|
|
8392
|
+
// ../core/dist/chunk-MDUGHSSW.js
|
|
8317
8393
|
var purchaseSchema = z2.object({
|
|
8318
8394
|
id: z2.string().max(191),
|
|
8319
8395
|
userId: z2.string().max(191).optional().nullable(),
|
|
@@ -8337,54 +8413,21 @@ var purchaseSchema = z2.object({
|
|
|
8337
8413
|
fields: z2.record(z2.any()).default({}),
|
|
8338
8414
|
user: userSchema.optional().nullable(),
|
|
8339
8415
|
bulkCoupon: couponSchema.optional().nullable(),
|
|
8340
|
-
product: productSchema.optional().nullable()
|
|
8416
|
+
product: productSchema.optional().nullable(),
|
|
8417
|
+
purchasedByorganizationMembershipId: z2.string().max(191).optional().nullable(),
|
|
8418
|
+
organizationId: z2.string().max(191).optional().nullable()
|
|
8341
8419
|
});
|
|
8342
8420
|
|
|
8343
|
-
// ../core/dist/chunk-
|
|
8344
|
-
var
|
|
8421
|
+
// ../core/dist/chunk-SGE7BCRS.js
|
|
8422
|
+
var merchantChargeSchema = z2.object({
|
|
8345
8423
|
id: z2.string().max(191),
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
"INITIATED",
|
|
8349
|
-
"VERIFIED",
|
|
8350
|
-
"CANCELED",
|
|
8351
|
-
"EXPIRED",
|
|
8352
|
-
"CONFIRMED",
|
|
8353
|
-
"COMPLETED"
|
|
8354
|
-
]).default("AVAILABLE"),
|
|
8355
|
-
purchaseId: z2.string().max(191),
|
|
8356
|
-
sourceUserId: z2.string().max(191),
|
|
8357
|
-
targetUserId: z2.string().max(191).optional().nullable(),
|
|
8358
|
-
createdAt: z2.date().nullable(),
|
|
8359
|
-
expiresAt: z2.date().nullable(),
|
|
8360
|
-
canceledAt: z2.date().nullable(),
|
|
8361
|
-
confirmedAt: z2.date().nullable(),
|
|
8362
|
-
completedAt: z2.date().nullable()
|
|
8363
|
-
});
|
|
8364
|
-
|
|
8365
|
-
// ../core/dist/chunk-PG6VF2O6.js
|
|
8366
|
-
var resourceProgressSchema = z2.object({
|
|
8424
|
+
status: z2.number().int().default(0),
|
|
8425
|
+
identifier: z2.string().max(191),
|
|
8367
8426
|
userId: z2.string().max(191),
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
});
|
|
8371
|
-
var moduleProgressSchema = z2.object({
|
|
8372
|
-
completedLessons: z2.array(resourceProgressSchema),
|
|
8373
|
-
nextResource: ContentResourceSchema.partial().nullable(),
|
|
8374
|
-
percentCompleted: z2.number().default(0),
|
|
8375
|
-
completedLessonsCount: z2.number().default(0),
|
|
8376
|
-
totalLessonsCount: z2.number().default(0)
|
|
8377
|
-
});
|
|
8378
|
-
|
|
8379
|
-
// ../core/dist/chunk-DLQA3JMA.js
|
|
8380
|
-
var upgradableProductSchema = z2.object({
|
|
8381
|
-
upgradableToId: z2.string().max(255),
|
|
8382
|
-
upgradableFromId: z2.string().max(255),
|
|
8383
|
-
position: z2.number().default(0),
|
|
8384
|
-
metadata: z2.record(z2.any()).default({}),
|
|
8427
|
+
merchantAccountId: z2.string().max(191),
|
|
8428
|
+
merchantProductId: z2.string().max(191),
|
|
8385
8429
|
createdAt: z2.date().nullable(),
|
|
8386
|
-
|
|
8387
|
-
deletedAt: z2.date().nullable()
|
|
8430
|
+
merchantCustomerId: z2.string().max(191)
|
|
8388
8431
|
});
|
|
8389
8432
|
|
|
8390
8433
|
// ../core/dist/chunk-EDDT2FFU.js
|
|
@@ -8418,18 +8461,6 @@ var merchantProductSchema = z2.object({
|
|
|
8418
8461
|
createdAt: z2.date().nullable()
|
|
8419
8462
|
});
|
|
8420
8463
|
|
|
8421
|
-
// ../core/dist/chunk-SGE7BCRS.js
|
|
8422
|
-
var merchantChargeSchema = z2.object({
|
|
8423
|
-
id: z2.string().max(191),
|
|
8424
|
-
status: z2.number().int().default(0),
|
|
8425
|
-
identifier: z2.string().max(191),
|
|
8426
|
-
userId: z2.string().max(191),
|
|
8427
|
-
merchantAccountId: z2.string().max(191),
|
|
8428
|
-
merchantProductId: z2.string().max(191),
|
|
8429
|
-
createdAt: z2.date().nullable(),
|
|
8430
|
-
merchantCustomerId: z2.string().max(191)
|
|
8431
|
-
});
|
|
8432
|
-
|
|
8433
8464
|
// ../core/dist/chunk-256SROW3.js
|
|
8434
8465
|
var merchantCouponSchema = z2.object({
|
|
8435
8466
|
id: z2.string().max(191),
|
|
@@ -8452,6 +8483,71 @@ var merchantAccountSchema = z2.object({
|
|
|
8452
8483
|
status: z2.number().int().default(0)
|
|
8453
8484
|
});
|
|
8454
8485
|
|
|
8486
|
+
// ../core/dist/schemas/merchant-session.js
|
|
8487
|
+
var MerchantSessionSchema = z2.object({
|
|
8488
|
+
id: z2.string(),
|
|
8489
|
+
organizationId: z2.string().nullable(),
|
|
8490
|
+
identifier: z2.string(),
|
|
8491
|
+
merchantAccountId: z2.string()
|
|
8492
|
+
});
|
|
8493
|
+
|
|
8494
|
+
// ../core/dist/chunk-NCUZHHRE.js
|
|
8495
|
+
var MerchantSubscriptionSchema = z2.object({
|
|
8496
|
+
id: z2.string(),
|
|
8497
|
+
organizationId: z2.string().nullable(),
|
|
8498
|
+
merchantAccountId: z2.string(),
|
|
8499
|
+
status: z2.number().default(0),
|
|
8500
|
+
createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
|
|
8501
|
+
label: z2.string().nullable(),
|
|
8502
|
+
identifier: z2.string().nullable(),
|
|
8503
|
+
merchantCustomerId: z2.string(),
|
|
8504
|
+
merchantProductId: z2.string()
|
|
8505
|
+
});
|
|
8506
|
+
|
|
8507
|
+
// ../core/dist/chunk-KQ3HQRWM.js
|
|
8508
|
+
var OrganizationSchema = z2.object({
|
|
8509
|
+
id: z2.string(),
|
|
8510
|
+
name: z2.string().nullable(),
|
|
8511
|
+
fields: z2.record(z2.any()).default({}),
|
|
8512
|
+
image: z2.string().nullable(),
|
|
8513
|
+
createdAt: z2.date()
|
|
8514
|
+
});
|
|
8515
|
+
|
|
8516
|
+
// ../core/dist/schemas/organization-member.js
|
|
8517
|
+
var OrganizationMemberSchema = z2.object({
|
|
8518
|
+
id: z2.string(),
|
|
8519
|
+
organizationId: z2.string().optional(),
|
|
8520
|
+
role: z2.string().default("user"),
|
|
8521
|
+
invitedById: z2.string(),
|
|
8522
|
+
userId: z2.string(),
|
|
8523
|
+
fields: z2.record(z2.any()).default({}),
|
|
8524
|
+
createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
|
|
8525
|
+
organization: OrganizationSchema,
|
|
8526
|
+
user: userSchema
|
|
8527
|
+
});
|
|
8528
|
+
|
|
8529
|
+
// ../core/dist/schemas/subscription.js
|
|
8530
|
+
var SubscriptionSchema = z2.object({
|
|
8531
|
+
id: z2.string(),
|
|
8532
|
+
organizationId: z2.string().optional(),
|
|
8533
|
+
productId: z2.string(),
|
|
8534
|
+
createdAt: z2.date(),
|
|
8535
|
+
merchantSubscriptionId: z2.string(),
|
|
8536
|
+
status: z2.enum([
|
|
8537
|
+
"incomplete",
|
|
8538
|
+
"incomplete_expired",
|
|
8539
|
+
"trialing",
|
|
8540
|
+
"active",
|
|
8541
|
+
"past_due",
|
|
8542
|
+
"canceled",
|
|
8543
|
+
"unpaid",
|
|
8544
|
+
"paused"
|
|
8545
|
+
]).default("active"),
|
|
8546
|
+
fields: z2.record(z2.any()).default({}),
|
|
8547
|
+
product: productSchema,
|
|
8548
|
+
merchantSubscription: MerchantSubscriptionSchema.optional()
|
|
8549
|
+
});
|
|
8550
|
+
|
|
8455
8551
|
// ../core/dist/chunk-F32UWPXN.js
|
|
8456
8552
|
var _a41;
|
|
8457
8553
|
var _CourseBuilderError = (_a41 = class extends Error {
|
|
@@ -8662,7 +8758,12 @@ function getCourseBuilderSchema(mysqlTable) {
|
|
|
8662
8758
|
merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
|
|
8663
8759
|
merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
|
|
8664
8760
|
subscription: getSubscriptionSchema(mysqlTable),
|
|
8665
|
-
subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable)
|
|
8761
|
+
subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
|
|
8762
|
+
profiles: getProfilesSchema(mysqlTable),
|
|
8763
|
+
profilesRelations: getProfilesRelationsSchema(mysqlTable),
|
|
8764
|
+
entitlementTypes: getEntitlementTypesSchema(mysqlTable),
|
|
8765
|
+
entitlements: getEntitlementsSchema(mysqlTable),
|
|
8766
|
+
entitlementsRelations: getEntitlementRelationsSchema(mysqlTable)
|
|
8666
8767
|
};
|
|
8667
8768
|
}
|
|
8668
8769
|
__name(getCourseBuilderSchema, "getCourseBuilderSchema");
|
|
@@ -8671,7 +8772,7 @@ function createTables(mySqlTable) {
|
|
|
8671
8772
|
}
|
|
8672
8773
|
__name(createTables, "createTables");
|
|
8673
8774
|
function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvider) {
|
|
8674
|
-
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments } = createTables(tableFn);
|
|
8775
|
+
const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, contentResourceProduct, purchases: purchaseTable, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, prices, products, upgradableProducts, resourceProgress, comments, organization: organizationTable, organizationMemberships: organizationMembershipTable, organizationMembershipRoles: organizationMembershipRoleTable, roles: roleTable, merchantSubscription: merchantSubscriptionTable, subscription: subscriptionTable } = createTables(tableFn);
|
|
8675
8776
|
const adapter = {
|
|
8676
8777
|
client,
|
|
8677
8778
|
async redeemFullPriceCoupon(options) {
|
|
@@ -8866,10 +8967,24 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
8866
8967
|
}
|
|
8867
8968
|
return parsedCoupon.data;
|
|
8868
8969
|
},
|
|
8970
|
+
async createMerchantSession(options) {
|
|
8971
|
+
const id = `ms_${v4()}`;
|
|
8972
|
+
await client.insert(merchantSession).values({
|
|
8973
|
+
id,
|
|
8974
|
+
identifier: options.identifier,
|
|
8975
|
+
merchantAccountId: options.merchantAccountId,
|
|
8976
|
+
...options.organizationId ? {
|
|
8977
|
+
organizationId: options.organizationId
|
|
8978
|
+
} : {}
|
|
8979
|
+
});
|
|
8980
|
+
return MerchantSessionSchema.parse(await client.query.merchantSession.findFirst({
|
|
8981
|
+
where: eq(merchantSession.id, id)
|
|
8982
|
+
}));
|
|
8983
|
+
},
|
|
8869
8984
|
async createMerchantChargeAndPurchase(options) {
|
|
8870
8985
|
const purchaseId = await client.transaction(async (trx) => {
|
|
8871
8986
|
try {
|
|
8872
|
-
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId } = options;
|
|
8987
|
+
const { userId, stripeChargeId, stripeCouponId, merchantAccountId, merchantProductId, merchantCustomerId, productId, stripeChargeAmount, quantity = 1, checkoutSessionId, appliedPPPStripeCouponId, upgradedFromPurchaseId, country, usedCouponId, organizationId } = options;
|
|
8873
8988
|
const existingMerchantCharge = merchantChargeSchema.nullable().parse(await client.query.merchantCharge.findFirst({
|
|
8874
8989
|
where: eq(merchantCharge.identifier, stripeChargeId)
|
|
8875
8990
|
}) || null);
|
|
@@ -8910,7 +9025,10 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
8910
9025
|
bulkCouponId = existingBulkCoupon !== null ? existingBulkCoupon.id : v4();
|
|
8911
9026
|
if (existingBulkCoupon !== null) {
|
|
8912
9027
|
couponToUpdate = await client.update(coupon).set({
|
|
8913
|
-
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity
|
|
9028
|
+
maxUses: (existingBulkCoupon?.maxUses || 0) + quantity,
|
|
9029
|
+
...organizationId ? {
|
|
9030
|
+
organizationId
|
|
9031
|
+
} : {}
|
|
8914
9032
|
}).where(eq(coupon.id, bulkCouponId));
|
|
8915
9033
|
} else {
|
|
8916
9034
|
const merchantCouponToUse = stripeCouponId ? merchantCouponSchema.nullable().parse(await client.query.merchantCoupon.findFirst({
|
|
@@ -8922,6 +9040,9 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
8922
9040
|
restrictedToProductId: productId,
|
|
8923
9041
|
maxUses: quantity,
|
|
8924
9042
|
status: 1,
|
|
9043
|
+
...organizationId ? {
|
|
9044
|
+
organizationId
|
|
9045
|
+
} : {},
|
|
8925
9046
|
...merchantCouponToUse ? {
|
|
8926
9047
|
merchantCouponId: merchantCouponToUse.id
|
|
8927
9048
|
} : {}
|
|
@@ -8929,7 +9050,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
8929
9050
|
}
|
|
8930
9051
|
}
|
|
8931
9052
|
const merchantSessionId = `ms_${v4()}`;
|
|
8932
|
-
|
|
9053
|
+
await client.insert(merchantSession).values({
|
|
8933
9054
|
id: merchantSessionId,
|
|
8934
9055
|
identifier: checkoutSessionId,
|
|
8935
9056
|
merchantAccountId
|
|
@@ -8941,7 +9062,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
8941
9062
|
where: and(eq(merchantCoupon.identifier, appliedPPPStripeCouponId), eq(merchantCoupon.type, "ppp"))
|
|
8942
9063
|
}) : null;
|
|
8943
9064
|
const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
|
|
8944
|
-
|
|
9065
|
+
await client.insert(purchaseTable).values({
|
|
8945
9066
|
id: purchaseId2,
|
|
8946
9067
|
status: newPurchaseStatus,
|
|
8947
9068
|
userId,
|
|
@@ -8952,14 +9073,20 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
8952
9073
|
merchantSessionId,
|
|
8953
9074
|
country,
|
|
8954
9075
|
upgradedFromId: upgradedFromPurchaseId || null,
|
|
8955
|
-
couponId: usedCouponId || null
|
|
9076
|
+
couponId: usedCouponId || null,
|
|
9077
|
+
...organizationId ? {
|
|
9078
|
+
organizationId
|
|
9079
|
+
} : {}
|
|
8956
9080
|
});
|
|
8957
9081
|
const oneWeekInMilliseconds = 1e3 * 60 * 60 * 24 * 7;
|
|
8958
|
-
|
|
9082
|
+
await client.insert(purchaseUserTransfer).values({
|
|
8959
9083
|
id: `put_${v4()}`,
|
|
8960
9084
|
purchaseId: purchaseId2,
|
|
8961
9085
|
expiresAt: existingPurchase ? /* @__PURE__ */ new Date() : new Date(Date.now() + oneWeekInMilliseconds),
|
|
8962
|
-
sourceUserId: userId
|
|
9086
|
+
sourceUserId: userId,
|
|
9087
|
+
...organizationId ? {
|
|
9088
|
+
organizationId
|
|
9089
|
+
} : {}
|
|
8963
9090
|
});
|
|
8964
9091
|
return purchaseId2;
|
|
8965
9092
|
} catch (error) {
|
|
@@ -9121,7 +9248,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
9121
9248
|
resource_id: z.string(),
|
|
9122
9249
|
resource_type: z.enum([
|
|
9123
9250
|
"lesson",
|
|
9124
|
-
"exercise"
|
|
9251
|
+
"exercise",
|
|
9252
|
+
"post"
|
|
9125
9253
|
]),
|
|
9126
9254
|
resource_slug: z.string().nullable(),
|
|
9127
9255
|
completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
|
|
@@ -9157,7 +9285,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
9157
9285
|
LEFT JOIN ${resourceProgress} rp ON rp.resourceId = cr.id
|
|
9158
9286
|
AND rp.userId = ${user.id}
|
|
9159
9287
|
WHERE
|
|
9160
|
-
cr.type IN ('lesson', 'exercise')
|
|
9288
|
+
cr.type IN ('lesson', 'exercise', 'post')
|
|
9161
9289
|
|
|
9162
9290
|
`);
|
|
9163
9291
|
const completedLessons = [];
|
|
@@ -9381,7 +9509,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
9381
9509
|
...image?.url && {
|
|
9382
9510
|
image
|
|
9383
9511
|
}
|
|
9384
|
-
}
|
|
9512
|
+
},
|
|
9513
|
+
type: input.type
|
|
9385
9514
|
}).where(eq(products.id, currentProduct.id));
|
|
9386
9515
|
return adapter.getProduct(currentProduct.id);
|
|
9387
9516
|
},
|
|
@@ -10051,7 +10180,30 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10051
10180
|
...data,
|
|
10052
10181
|
id
|
|
10053
10182
|
});
|
|
10054
|
-
|
|
10183
|
+
const personalOrganization = await adapter.createOrganization({
|
|
10184
|
+
name: `Personal (${data.email})`
|
|
10185
|
+
});
|
|
10186
|
+
if (!personalOrganization) {
|
|
10187
|
+
throw new Error("Failed to create personal organization");
|
|
10188
|
+
}
|
|
10189
|
+
const membership = await adapter.addMemberToOrganization({
|
|
10190
|
+
organizationId: personalOrganization.id,
|
|
10191
|
+
userId: id,
|
|
10192
|
+
invitedById: id
|
|
10193
|
+
});
|
|
10194
|
+
if (!membership) {
|
|
10195
|
+
throw new Error("Failed to add user to personal organization");
|
|
10196
|
+
}
|
|
10197
|
+
await adapter.addRoleForMember({
|
|
10198
|
+
organizationId: personalOrganization.id,
|
|
10199
|
+
memberId: membership.id,
|
|
10200
|
+
role: "owner"
|
|
10201
|
+
});
|
|
10202
|
+
const user = await adapter.getUser?.(id);
|
|
10203
|
+
if (!user) {
|
|
10204
|
+
throw new Error("Failed to get user");
|
|
10205
|
+
}
|
|
10206
|
+
return user;
|
|
10055
10207
|
} catch (error) {
|
|
10056
10208
|
console.error(error);
|
|
10057
10209
|
throw error;
|
|
@@ -10133,6 +10285,145 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
|
|
|
10133
10285
|
async unlinkAccount(account) {
|
|
10134
10286
|
await client.delete(accounts).where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)));
|
|
10135
10287
|
return void 0;
|
|
10288
|
+
},
|
|
10289
|
+
createOrganization: async (options) => {
|
|
10290
|
+
const organizationId = crypto.randomUUID();
|
|
10291
|
+
await client.insert(organizationTable).values({
|
|
10292
|
+
...options,
|
|
10293
|
+
id: organizationId
|
|
10294
|
+
});
|
|
10295
|
+
return adapter.getOrganization(organizationId);
|
|
10296
|
+
},
|
|
10297
|
+
getOrganization: async (organizationId) => {
|
|
10298
|
+
return OrganizationSchema.parse(await client.query.organization.findFirst({
|
|
10299
|
+
where: eq(organizationTable.id, organizationId)
|
|
10300
|
+
}));
|
|
10301
|
+
},
|
|
10302
|
+
addMemberToOrganization: async (options) => {
|
|
10303
|
+
const currentMembership = await client.query.organizationMemberships.findFirst({
|
|
10304
|
+
where: and(eq(organizationMembershipTable.organizationId, options.organizationId), eq(organizationMembershipTable.userId, options.userId))
|
|
10305
|
+
});
|
|
10306
|
+
if (currentMembership) {
|
|
10307
|
+
return OrganizationMemberSchema.parse(currentMembership);
|
|
10308
|
+
} else {
|
|
10309
|
+
const id = crypto.randomUUID();
|
|
10310
|
+
await client.insert(organizationMembershipTable).values({
|
|
10311
|
+
...options,
|
|
10312
|
+
id
|
|
10313
|
+
});
|
|
10314
|
+
return OrganizationMemberSchema.parse(await client.query.organizationMemberships.findFirst({
|
|
10315
|
+
where: eq(organizationMembershipTable.id, id),
|
|
10316
|
+
with: {
|
|
10317
|
+
organization: true,
|
|
10318
|
+
user: true
|
|
10319
|
+
}
|
|
10320
|
+
}));
|
|
10321
|
+
}
|
|
10322
|
+
},
|
|
10323
|
+
removeMemberFromOrganization: async (options) => {
|
|
10324
|
+
await client.delete(organizationMembershipTable).where(and(eq(organizationMembershipTable.organizationId, options.organizationId), eq(organizationMembershipTable.userId, options.userId)));
|
|
10325
|
+
},
|
|
10326
|
+
addRoleForMember: async (options) => {
|
|
10327
|
+
const existingRole = z.object({
|
|
10328
|
+
id: z.string()
|
|
10329
|
+
}).nullish().parse(await client.query.roles.findFirst({
|
|
10330
|
+
where: and(eq(roleTable.organizationId, options.organizationId), eq(roleTable.name, options.role))
|
|
10331
|
+
}));
|
|
10332
|
+
const roleId = existingRole?.id || crypto.randomUUID();
|
|
10333
|
+
if (!existingRole) {
|
|
10334
|
+
await client.insert(roleTable).values({
|
|
10335
|
+
name: options.role,
|
|
10336
|
+
organizationId: options.organizationId,
|
|
10337
|
+
id: roleId
|
|
10338
|
+
});
|
|
10339
|
+
}
|
|
10340
|
+
const currentOrgMembershipRole = await client.query.organizationMembershipRoles.findFirst({
|
|
10341
|
+
where: and(eq(organizationMembershipRoleTable.organizationMembershipId, options.memberId), eq(organizationMembershipRoleTable.roleId, roleId))
|
|
10342
|
+
});
|
|
10343
|
+
if (!currentOrgMembershipRole) {
|
|
10344
|
+
await client.insert(organizationMembershipRoleTable).values({
|
|
10345
|
+
organizationId: options.organizationId,
|
|
10346
|
+
organizationMembershipId: options.memberId,
|
|
10347
|
+
roleId
|
|
10348
|
+
});
|
|
10349
|
+
}
|
|
10350
|
+
},
|
|
10351
|
+
removeRoleForMember: async (options) => {
|
|
10352
|
+
const existingRole = z.object({
|
|
10353
|
+
id: z.string()
|
|
10354
|
+
}).nullable().parse(await client.query.roles.findFirst({
|
|
10355
|
+
where: and(eq(roleTable.organizationId, options.organizationId), eq(roleTable.name, options.role))
|
|
10356
|
+
}));
|
|
10357
|
+
const roleId = existingRole?.id;
|
|
10358
|
+
if (roleId) {
|
|
10359
|
+
await client.delete(organizationMembershipRoleTable).where(eq(organizationMembershipRoleTable.roleId, roleId));
|
|
10360
|
+
}
|
|
10361
|
+
},
|
|
10362
|
+
getMembershipsForUser: async (userId) => {
|
|
10363
|
+
return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
|
|
10364
|
+
where: eq(organizationMembershipTable.userId, userId),
|
|
10365
|
+
with: {
|
|
10366
|
+
organization: true,
|
|
10367
|
+
user: true
|
|
10368
|
+
}
|
|
10369
|
+
}) || []);
|
|
10370
|
+
},
|
|
10371
|
+
getOrganizationMembers: async (organizationId) => {
|
|
10372
|
+
return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
|
|
10373
|
+
where: eq(organizationMembershipTable.organizationId, organizationId)
|
|
10374
|
+
}) || []);
|
|
10375
|
+
},
|
|
10376
|
+
createSubscription: async (options) => {
|
|
10377
|
+
const id = `sub_${crypto.randomUUID()}`;
|
|
10378
|
+
await client.insert(subscriptionTable).values({
|
|
10379
|
+
...options,
|
|
10380
|
+
id
|
|
10381
|
+
});
|
|
10382
|
+
return SubscriptionSchema.parse(await client.query.subscription.findFirst({
|
|
10383
|
+
where: eq(subscriptionTable.id, id),
|
|
10384
|
+
with: {
|
|
10385
|
+
product: true
|
|
10386
|
+
}
|
|
10387
|
+
}));
|
|
10388
|
+
},
|
|
10389
|
+
getMerchantSubscription: async (merchantSubscriptionId) => {
|
|
10390
|
+
return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
|
|
10391
|
+
where: eq(merchantSubscriptionTable.id, merchantSubscriptionId)
|
|
10392
|
+
}));
|
|
10393
|
+
},
|
|
10394
|
+
createMerchantSubscription: async (options) => {
|
|
10395
|
+
const id = crypto.randomUUID();
|
|
10396
|
+
await client.insert(merchantSubscriptionTable).values({
|
|
10397
|
+
...options,
|
|
10398
|
+
id
|
|
10399
|
+
});
|
|
10400
|
+
return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
|
|
10401
|
+
where: eq(merchantSubscriptionTable.id, id)
|
|
10402
|
+
}));
|
|
10403
|
+
},
|
|
10404
|
+
updateMerchantSubscription: async (options) => {
|
|
10405
|
+
throw new Error("Not implemented");
|
|
10406
|
+
},
|
|
10407
|
+
deleteMerchantSubscription: async (merchantSubscriptionId) => {
|
|
10408
|
+
throw new Error("Not implemented");
|
|
10409
|
+
},
|
|
10410
|
+
getSubscriptionForStripeId: async (stripeSubscriptionId) => {
|
|
10411
|
+
const merchantSubscriptionParsed = MerchantSubscriptionSchema.safeParse(await client.query.merchantSubscription.findFirst({
|
|
10412
|
+
where: eq(merchantSubscriptionTable.identifier, stripeSubscriptionId)
|
|
10413
|
+
}));
|
|
10414
|
+
if (!merchantSubscriptionParsed.success) {
|
|
10415
|
+
throw new Error(`No merchant subscription found for stripe id ${stripeSubscriptionId} ${merchantSubscriptionParsed.error}`);
|
|
10416
|
+
}
|
|
10417
|
+
const subscriptionParsed = SubscriptionSchema.safeParse(await client.query.subscription.findFirst({
|
|
10418
|
+
where: eq(subscriptionTable.merchantSubscriptionId, merchantSubscriptionParsed.data.id),
|
|
10419
|
+
with: {
|
|
10420
|
+
product: true
|
|
10421
|
+
}
|
|
10422
|
+
}));
|
|
10423
|
+
if (!subscriptionParsed.success) {
|
|
10424
|
+
throw new Error(`No subscription found for merchant subscription ${merchantSubscriptionParsed.data.id} ${subscriptionParsed.error}`);
|
|
10425
|
+
}
|
|
10426
|
+
return subscriptionParsed.data;
|
|
10136
10427
|
}
|
|
10137
10428
|
};
|
|
10138
10429
|
return adapter;
|
|
@@ -10145,4 +10436,4 @@ export {
|
|
|
10145
10436
|
createTables,
|
|
10146
10437
|
mySqlDrizzleAdapter
|
|
10147
10438
|
};
|
|
10148
|
-
//# sourceMappingURL=chunk-
|
|
10439
|
+
//# sourceMappingURL=chunk-5QEGBX2O.js.map
|