@coursebuilder/adapter-drizzle 1.0.0 → 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.
Files changed (131) hide show
  1. package/dist/{chunk-3WYG5OE7.js → chunk-3GONHHMY.js} +2 -2
  2. package/dist/{chunk-WFC55BSF.js → chunk-FPAQINSA.js} +2 -2
  3. package/dist/{chunk-RCL6HPBL.js → chunk-HWIQUI7O.js} +2 -2
  4. package/dist/{chunk-QGZ2F5SW.js → chunk-LPJ2P2KJ.js} +1162 -1027
  5. package/dist/{chunk-L5ZAWSTN.js → chunk-MOV5TUON.js} +376 -116
  6. package/dist/{chunk-GAKWXOAY.js → chunk-OBUGOZKM.js} +2 -2
  7. package/dist/{chunk-A6XPL665.js → chunk-PBTEHA7F.js} +2 -2
  8. package/dist/{chunk-5XTOCFDB.js → chunk-YQNIXCD3.js} +2 -2
  9. package/dist/index.js +9 -10
  10. package/dist/lib/mysql/index.cjs +1415 -1088
  11. package/dist/lib/mysql/index.cjs.map +1 -1
  12. package/dist/lib/mysql/index.d.cts +218 -0
  13. package/dist/lib/mysql/index.d.ts +218 -0
  14. package/dist/lib/mysql/index.js +9 -10
  15. package/dist/lib/mysql/schemas/auth/accounts.cjs +106 -98
  16. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  17. package/dist/lib/mysql/schemas/auth/accounts.js +2 -2
  18. package/dist/lib/mysql/schemas/auth/device-access-token.cjs +99 -91
  19. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  20. package/dist/lib/mysql/schemas/auth/device-access-token.js +3 -3
  21. package/dist/lib/mysql/schemas/auth/device-verification.cjs +100 -92
  22. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  23. package/dist/lib/mysql/schemas/auth/device-verification.js +3 -3
  24. package/dist/lib/mysql/schemas/auth/profiles.cjs +254 -0
  25. package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -0
  26. package/dist/lib/mysql/schemas/auth/profiles.d.cts +112 -0
  27. package/dist/lib/mysql/schemas/auth/profiles.d.ts +112 -0
  28. package/dist/lib/mysql/schemas/auth/profiles.js +20 -0
  29. package/dist/lib/mysql/schemas/auth/profiles.js.map +1 -0
  30. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +55 -46
  31. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  32. package/dist/lib/mysql/schemas/auth/role-permissions.js +3 -3
  33. package/dist/lib/mysql/schemas/auth/roles.cjs +57 -48
  34. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  35. package/dist/lib/mysql/schemas/auth/roles.js +2 -2
  36. package/dist/lib/mysql/schemas/auth/sessions.cjs +96 -88
  37. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  38. package/dist/lib/mysql/schemas/auth/sessions.js +3 -3
  39. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +99 -91
  40. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  41. package/dist/lib/mysql/schemas/auth/user-permissions.js +2 -2
  42. package/dist/lib/mysql/schemas/auth/user-prefs.cjs +104 -96
  43. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/auth/user-prefs.js +2 -2
  45. package/dist/lib/mysql/schemas/auth/user-roles.cjs +58 -49
  46. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  47. package/dist/lib/mysql/schemas/auth/user-roles.js +2 -2
  48. package/dist/lib/mysql/schemas/auth/users.cjs +295 -259
  49. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  50. package/dist/lib/mysql/schemas/auth/users.d.cts +1 -0
  51. package/dist/lib/mysql/schemas/auth/users.d.ts +1 -0
  52. package/dist/lib/mysql/schemas/auth/users.js +2 -2
  53. package/dist/lib/mysql/schemas/commerce/coupon.cjs +131 -123
  54. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  55. package/dist/lib/mysql/schemas/commerce/coupon.js +2 -2
  56. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +96 -88
  57. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +2 -2
  59. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +90 -82
  60. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
  61. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +2 -2
  62. package/dist/lib/mysql/schemas/commerce/price.cjs +98 -90
  63. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  64. package/dist/lib/mysql/schemas/commerce/price.js +2 -2
  65. package/dist/lib/mysql/schemas/commerce/product.cjs +125 -117
  66. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  67. package/dist/lib/mysql/schemas/commerce/product.js +2 -2
  68. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +131 -123
  69. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  70. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +3 -3
  71. package/dist/lib/mysql/schemas/commerce/purchase.cjs +184 -176
  72. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  73. package/dist/lib/mysql/schemas/commerce/purchase.js +2 -2
  74. package/dist/lib/mysql/schemas/commerce/subscription.cjs +117 -109
  75. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
  76. package/dist/lib/mysql/schemas/commerce/subscription.js +2 -2
  77. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +105 -97
  78. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  79. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +3 -3
  80. package/dist/lib/mysql/schemas/communication/comment.cjs +114 -106
  81. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  82. package/dist/lib/mysql/schemas/communication/comment.js +2 -2
  83. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +136 -128
  84. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  85. package/dist/lib/mysql/schemas/communication/communication-preferences.js +2 -2
  86. package/dist/lib/mysql/schemas/content/content-contributions.cjs +144 -136
  87. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  88. package/dist/lib/mysql/schemas/content/content-contributions.js +2 -2
  89. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +99 -91
  90. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  91. package/dist/lib/mysql/schemas/content/content-resource-product.js +2 -2
  92. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +108 -100
  93. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  94. package/dist/lib/mysql/schemas/content/content-resource-resource.js +2 -2
  95. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +118 -110
  96. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  97. package/dist/lib/mysql/schemas/content/content-resource-tag.js +2 -2
  98. package/dist/lib/mysql/schemas/content/content-resource-version.cjs +121 -113
  99. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  100. package/dist/lib/mysql/schemas/content/content-resource-version.js +2 -2
  101. package/dist/lib/mysql/schemas/content/content-resource.cjs +198 -190
  102. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  103. package/dist/lib/mysql/schemas/content/content-resource.js +2 -2
  104. package/dist/lib/mysql/schemas/content/tag-tag.cjs +103 -95
  105. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  106. package/dist/lib/mysql/schemas/content/tag-tag.js +2 -2
  107. package/dist/lib/mysql/schemas/content/tag.cjs +116 -108
  108. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  109. package/dist/lib/mysql/schemas/content/tag.js +2 -2
  110. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +73 -35
  111. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
  112. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +1 -0
  113. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +1 -0
  114. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +2 -3
  115. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +88 -38
  116. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
  117. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +1 -0
  118. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +1 -0
  119. package/dist/lib/mysql/schemas/org/organization-memberships.js +2 -2
  120. package/dist/lib/mysql/schemas/org/organizations.cjs +131 -121
  121. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
  122. package/dist/lib/mysql/schemas/org/organizations.js +2 -2
  123. package/package.json +4 -3
  124. package/src/lib/mysql/index.ts +320 -26
  125. package/src/lib/mysql/schemas/auth/profiles.ts +50 -0
  126. package/src/lib/mysql/schemas/auth/roles.ts +6 -1
  127. package/src/lib/mysql/schemas/auth/users.ts +6 -1
  128. package/src/lib/mysql/schemas/commerce/subscription.ts +3 -5
  129. package/src/lib/mysql/schemas/org/organization-membership-roles.ts +7 -0
  130. package/src/lib/mysql/schemas/org/organization-memberships.ts +6 -0
  131. package/dist/chunk-RP66NZN3.js +0 -81
@@ -4,37 +4,33 @@ import {
4
4
  import {
5
5
  getResourceProgressSchema
6
6
  } from "./chunk-6YPHJWS2.js";
7
- import {
8
- getOrganizationMembershipRolesRelationsSchema,
9
- getOrganizationMembershipRolesSchema
10
- } from "./chunk-RP66NZN3.js";
11
7
  import {
12
8
  getPurchaseUserTransferRelationsSchema,
13
9
  getPurchaseUserTransferSchema
14
- } from "./chunk-RCL6HPBL.js";
10
+ } from "./chunk-HWIQUI7O.js";
15
11
  import {
16
12
  getUpgradableProductsRelationsSchema,
17
13
  getUpgradableProductsSchema
18
- } from "./chunk-WFC55BSF.js";
14
+ } from "./chunk-FPAQINSA.js";
15
+ import {
16
+ getVerificationTokensSchema
17
+ } from "./chunk-LERR6HQ3.js";
19
18
  import {
20
19
  getRolePermissionsRelationsSchema,
21
20
  getRolePermissionsSchema
22
- } from "./chunk-3WYG5OE7.js";
21
+ } from "./chunk-3GONHHMY.js";
23
22
  import {
24
23
  getSessionRelationsSchema,
25
24
  getSessionsSchema
26
- } from "./chunk-A6XPL665.js";
27
- import {
28
- getVerificationTokensSchema
29
- } from "./chunk-LERR6HQ3.js";
25
+ } from "./chunk-PBTEHA7F.js";
30
26
  import {
31
27
  getDeviceAccessTokenRelationsSchema,
32
28
  getDeviceAccessTokenSchema
33
- } from "./chunk-5XTOCFDB.js";
29
+ } from "./chunk-YQNIXCD3.js";
34
30
  import {
35
31
  getDeviceVerificationRelationsSchema,
36
32
  getDeviceVerificationSchema
37
- } from "./chunk-GAKWXOAY.js";
33
+ } from "./chunk-OBUGOZKM.js";
38
34
  import {
39
35
  getAccountsRelationsSchema,
40
36
  getAccountsSchema,
@@ -60,6 +56,8 @@ import {
60
56
  getMerchantChargeSchema,
61
57
  getMerchantSubscriptionRelationsSchema,
62
58
  getMerchantSubscriptionSchema,
59
+ getOrganizationMembershipRolesRelationsSchema,
60
+ getOrganizationMembershipRolesSchema,
63
61
  getOrganizationMembershipsRelationsSchema,
64
62
  getOrganizationMembershipsSchema,
65
63
  getOrganizationsRelationsSchema,
@@ -67,6 +65,8 @@ import {
67
65
  getPriceSchema,
68
66
  getProductRelationsSchema2 as getProductRelationsSchema,
69
67
  getProductSchema,
68
+ getProfilesRelationsSchema,
69
+ getProfilesSchema,
70
70
  getPurchaseRelationsSchema,
71
71
  getPurchaseSchema,
72
72
  getRolesRelationsSchema,
@@ -85,7 +85,7 @@ import {
85
85
  getUserRolesSchema,
86
86
  getUsersRelationsSchema,
87
87
  getUsersSchema
88
- } from "./chunk-QGZ2F5SW.js";
88
+ } from "./chunk-LPJ2P2KJ.js";
89
89
  import {
90
90
  getContributionTypesRelationsSchema,
91
91
  getContributionTypesSchema
@@ -96,6 +96,9 @@ import {
96
96
  import {
97
97
  getCommunicationPreferenceTypesSchema
98
98
  } from "./chunk-EHRARBRS.js";
99
+ import {
100
+ getMerchantSessionSchema
101
+ } from "./chunk-BLDW3QUS.js";
99
102
  import {
100
103
  getMerchantAccountSchema
101
104
  } from "./chunk-DKJO4Y3K.js";
@@ -111,9 +114,6 @@ import {
111
114
  import {
112
115
  getMerchantProductSchema
113
116
  } from "./chunk-KPBVZ44W.js";
114
- import {
115
- getMerchantSessionSchema
116
- } from "./chunk-BLDW3QUS.js";
117
117
  import {
118
118
  getPermissionsRelationsSchema,
119
119
  getPermissionsSchema
@@ -8166,38 +8166,26 @@ var VideoResourceSchema = z2.object({
8166
8166
  ])
8167
8167
  });
8168
8168
 
8169
- // ../core/dist/chunk-CHYUPSYW.js
8170
- var userSchema = z2.object({
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({
8169
+ // ../core/dist/chunk-LMH5A7OR.js
8170
+ var purchaseUserTransferSchema = z2.object({
8191
8171
  id: z2.string().max(191),
8192
- productId: z2.string().max(191).optional().nullable(),
8193
- nickname: z2.string().max(191).optional().nullable(),
8194
- status: z2.number().int().default(0),
8195
- unitAmount: z2.coerce.number().refine((value) => {
8196
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8197
- return decimalPlaces <= 2;
8198
- }),
8172
+ transferState: z2.enum([
8173
+ "AVAILABLE",
8174
+ "INITIATED",
8175
+ "VERIFIED",
8176
+ "CANCELED",
8177
+ "EXPIRED",
8178
+ "CONFIRMED",
8179
+ "COMPLETED"
8180
+ ]).default("AVAILABLE"),
8181
+ purchaseId: z2.string().max(191),
8182
+ sourceUserId: z2.string().max(191),
8183
+ targetUserId: z2.string().max(191).optional().nullable(),
8199
8184
  createdAt: z2.date().nullable(),
8200
- fields: z2.record(z2.any()).default({})
8185
+ expiresAt: z2.date().nullable(),
8186
+ canceledAt: z2.date().nullable(),
8187
+ confirmedAt: z2.date().nullable(),
8188
+ completedAt: z2.date().nullable()
8201
8189
  });
8202
8190
 
8203
8191
  // ../core/dist/chunk-SCKAG5RT.js
@@ -8247,14 +8235,93 @@ var ResourceVisibilitySchema = z2.union([
8247
8235
  z2.literal("unlisted")
8248
8236
  ]);
8249
8237
 
8250
- // ../core/dist/chunk-E56UB2X2.js
8238
+ // ../core/dist/chunk-PG6VF2O6.js
8239
+ var resourceProgressSchema = z2.object({
8240
+ userId: z2.string().max(191),
8241
+ resourceId: z2.string().max(191).optional().nullable(),
8242
+ completedAt: z2.date().nullable()
8243
+ });
8244
+ var moduleProgressSchema = z2.object({
8245
+ completedLessons: z2.array(resourceProgressSchema),
8246
+ nextResource: ContentResourceSchema.partial().nullable(),
8247
+ percentCompleted: z2.number().default(0),
8248
+ completedLessonsCount: z2.number().default(0),
8249
+ totalLessonsCount: z2.number().default(0)
8250
+ });
8251
+
8252
+ // ../core/dist/chunk-DLQA3JMA.js
8253
+ var upgradableProductSchema = z2.object({
8254
+ upgradableToId: z2.string().max(255),
8255
+ upgradableFromId: z2.string().max(255),
8256
+ position: z2.number().default(0),
8257
+ metadata: z2.record(z2.any()).default({}),
8258
+ createdAt: z2.date().nullable(),
8259
+ updatedAt: z2.date().nullable(),
8260
+ deletedAt: z2.date().nullable()
8261
+ });
8262
+
8263
+ // ../core/dist/chunk-JZBK2DS3.js
8264
+ var userSchema = z2.object({
8265
+ id: z2.string().max(255),
8266
+ name: z2.string().max(255).optional().nullable(),
8267
+ role: z2.enum([
8268
+ "user",
8269
+ "admin"
8270
+ ]).default("user"),
8271
+ email: z2.string().max(255).email(),
8272
+ emailVerified: z2.coerce.date().nullish(),
8273
+ image: z2.string().max(255).optional().nullable(),
8274
+ createdAt: z2.coerce.date().nullish(),
8275
+ memberships: z2.array(z2.object({
8276
+ id: z2.string(),
8277
+ organizationId: z2.string()
8278
+ })).nullish().default([]),
8279
+ roles: z2.array(z2.object({
8280
+ id: z2.string(),
8281
+ name: z2.string(),
8282
+ description: z2.string().nullable(),
8283
+ active: z2.boolean(),
8284
+ createdAt: z2.coerce.date().nullish(),
8285
+ updatedAt: z2.coerce.date().nullish(),
8286
+ deletedAt: z2.coerce.date().nullish()
8287
+ })).optional().default([]),
8288
+ organizationRoles: z2.array(z2.object({
8289
+ id: z2.string(),
8290
+ organizationId: z2.string(),
8291
+ name: z2.string(),
8292
+ description: z2.string().nullable(),
8293
+ active: z2.boolean(),
8294
+ createdAt: z2.coerce.date().nullish(),
8295
+ updatedAt: z2.coerce.date().nullish(),
8296
+ deletedAt: z2.coerce.date().nullish()
8297
+ })).optional().default([])
8298
+ });
8299
+
8300
+ // ../core/dist/chunk-M7IDYIVK.js
8301
+ var priceSchema = z2.object({
8302
+ id: z2.string().max(191),
8303
+ productId: z2.string().max(191).optional().nullable(),
8304
+ organizationId: z2.string().max(191).optional().nullable(),
8305
+ nickname: z2.string().max(191).optional().nullable(),
8306
+ status: z2.number().int().default(0),
8307
+ unitAmount: z2.coerce.number().refine((value) => {
8308
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8309
+ return decimalPlaces <= 2;
8310
+ }),
8311
+ createdAt: z2.date().nullable(),
8312
+ fields: z2.record(z2.any()).default({})
8313
+ });
8314
+
8315
+ // ../core/dist/chunk-3PC5DXPZ.js
8251
8316
  var productSchema = z2.object({
8252
8317
  id: z2.string().max(191),
8318
+ organizationId: z2.string().max(191).optional().nullable(),
8253
8319
  name: z2.string().max(191),
8254
8320
  key: z2.string().max(191).optional().nullable(),
8255
8321
  type: z2.enum([
8256
8322
  "live",
8257
- "self-paced"
8323
+ "self-paced",
8324
+ "membership"
8258
8325
  ]).default("self-paced"),
8259
8326
  fields: z2.object({
8260
8327
  body: z2.string().nullable().optional(),
@@ -8291,7 +8358,7 @@ var NewProductSchema = z2.object({
8291
8358
  price: z2.coerce.number().gte(0).default(0)
8292
8359
  });
8293
8360
 
8294
- // ../core/dist/chunk-RCFZC3SN.js
8361
+ // ../core/dist/chunk-K4MXE7BY.js
8295
8362
  var couponSchema = z2.object({
8296
8363
  id: z2.string(),
8297
8364
  code: z2.string().max(191).optional().nullable(),
@@ -8310,10 +8377,11 @@ var couponSchema = z2.object({
8310
8377
  restrictedToProductId: z2.string().max(191).optional().nullable(),
8311
8378
  bulkPurchases: z2.array(z2.any()).default([]),
8312
8379
  redeemedBulkCouponPurchases: z2.array(z2.any()).default([]),
8313
- bulkPurchaseId: z2.string().max(191).optional().nullable()
8380
+ bulkPurchaseId: z2.string().max(191).optional().nullable(),
8381
+ organizationId: z2.string().max(191).optional().nullable()
8314
8382
  });
8315
8383
 
8316
- // ../core/dist/chunk-GZ7YLWVN.js
8384
+ // ../core/dist/chunk-FH7M67MM.js
8317
8385
  var purchaseSchema = z2.object({
8318
8386
  id: z2.string().max(191),
8319
8387
  userId: z2.string().max(191).optional().nullable(),
@@ -8337,54 +8405,21 @@ var purchaseSchema = z2.object({
8337
8405
  fields: z2.record(z2.any()).default({}),
8338
8406
  user: userSchema.optional().nullable(),
8339
8407
  bulkCoupon: couponSchema.optional().nullable(),
8340
- product: productSchema.optional().nullable()
8408
+ product: productSchema.optional().nullable(),
8409
+ purchasedByorganizationMembershipId: z2.string().max(191).optional().nullable(),
8410
+ organizationId: z2.string().max(191).optional().nullable()
8341
8411
  });
8342
8412
 
8343
- // ../core/dist/chunk-LMH5A7OR.js
8344
- var purchaseUserTransferSchema = z2.object({
8413
+ // ../core/dist/chunk-SGE7BCRS.js
8414
+ var merchantChargeSchema = z2.object({
8345
8415
  id: z2.string().max(191),
8346
- transferState: z2.enum([
8347
- "AVAILABLE",
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({
8416
+ status: z2.number().int().default(0),
8417
+ identifier: z2.string().max(191),
8367
8418
  userId: z2.string().max(191),
8368
- resourceId: z2.string().max(191).optional().nullable(),
8369
- completedAt: z2.date().nullable()
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({}),
8419
+ merchantAccountId: z2.string().max(191),
8420
+ merchantProductId: z2.string().max(191),
8385
8421
  createdAt: z2.date().nullable(),
8386
- updatedAt: z2.date().nullable(),
8387
- deletedAt: z2.date().nullable()
8422
+ merchantCustomerId: z2.string().max(191)
8388
8423
  });
8389
8424
 
8390
8425
  // ../core/dist/chunk-EDDT2FFU.js
@@ -8418,18 +8453,6 @@ var merchantProductSchema = z2.object({
8418
8453
  createdAt: z2.date().nullable()
8419
8454
  });
8420
8455
 
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
8456
  // ../core/dist/chunk-256SROW3.js
8434
8457
  var merchantCouponSchema = z2.object({
8435
8458
  id: z2.string().max(191),
@@ -8452,6 +8475,71 @@ var merchantAccountSchema = z2.object({
8452
8475
  status: z2.number().int().default(0)
8453
8476
  });
8454
8477
 
8478
+ // ../core/dist/schemas/merchant-session.js
8479
+ var MerchantSessionSchema = z2.object({
8480
+ id: z2.string(),
8481
+ organizationId: z2.string().nullable(),
8482
+ identifier: z2.string(),
8483
+ merchantAccountId: z2.string()
8484
+ });
8485
+
8486
+ // ../core/dist/chunk-NCUZHHRE.js
8487
+ var MerchantSubscriptionSchema = z2.object({
8488
+ id: z2.string(),
8489
+ organizationId: z2.string().nullable(),
8490
+ merchantAccountId: z2.string(),
8491
+ status: z2.number().default(0),
8492
+ createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
8493
+ label: z2.string().nullable(),
8494
+ identifier: z2.string().nullable(),
8495
+ merchantCustomerId: z2.string(),
8496
+ merchantProductId: z2.string()
8497
+ });
8498
+
8499
+ // ../core/dist/chunk-KQ3HQRWM.js
8500
+ var OrganizationSchema = z2.object({
8501
+ id: z2.string(),
8502
+ name: z2.string().nullable(),
8503
+ fields: z2.record(z2.any()).default({}),
8504
+ image: z2.string().nullable(),
8505
+ createdAt: z2.date()
8506
+ });
8507
+
8508
+ // ../core/dist/schemas/organization-member.js
8509
+ var OrganizationMemberSchema = z2.object({
8510
+ id: z2.string(),
8511
+ organizationId: z2.string().optional(),
8512
+ role: z2.string().default("user"),
8513
+ invitedById: z2.string(),
8514
+ userId: z2.string(),
8515
+ fields: z2.record(z2.any()).default({}),
8516
+ createdAt: z2.date().default(() => /* @__PURE__ */ new Date()),
8517
+ organization: OrganizationSchema,
8518
+ user: userSchema
8519
+ });
8520
+
8521
+ // ../core/dist/schemas/subscription.js
8522
+ var SubscriptionSchema = z2.object({
8523
+ id: z2.string(),
8524
+ organizationId: z2.string().optional(),
8525
+ productId: z2.string(),
8526
+ createdAt: z2.date(),
8527
+ merchantSubscriptionId: z2.string(),
8528
+ status: z2.enum([
8529
+ "incomplete",
8530
+ "incomplete_expired",
8531
+ "trialing",
8532
+ "active",
8533
+ "past_due",
8534
+ "canceled",
8535
+ "unpaid",
8536
+ "paused"
8537
+ ]).default("active"),
8538
+ fields: z2.record(z2.any()).default({}),
8539
+ product: productSchema,
8540
+ merchantSubscription: MerchantSubscriptionSchema.optional()
8541
+ });
8542
+
8455
8543
  // ../core/dist/chunk-F32UWPXN.js
8456
8544
  var _a41;
8457
8545
  var _CourseBuilderError = (_a41 = class extends Error {
@@ -8662,7 +8750,9 @@ function getCourseBuilderSchema(mysqlTable) {
8662
8750
  merchantSubscription: getMerchantSubscriptionSchema(mysqlTable),
8663
8751
  merchantSubscriptionRelations: getMerchantSubscriptionRelationsSchema(mysqlTable),
8664
8752
  subscription: getSubscriptionSchema(mysqlTable),
8665
- subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable)
8753
+ subscriptionRelations: getSubscriptionRelationsSchema(mysqlTable),
8754
+ profiles: getProfilesSchema(mysqlTable),
8755
+ profilesRelations: getProfilesRelationsSchema(mysqlTable)
8666
8756
  };
8667
8757
  }
8668
8758
  __name(getCourseBuilderSchema, "getCourseBuilderSchema");
@@ -8671,7 +8761,7 @@ function createTables(mySqlTable) {
8671
8761
  }
8672
8762
  __name(createTables, "createTables");
8673
8763
  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);
8764
+ 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
8765
  const adapter = {
8676
8766
  client,
8677
8767
  async redeemFullPriceCoupon(options) {
@@ -8866,6 +8956,20 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
8866
8956
  }
8867
8957
  return parsedCoupon.data;
8868
8958
  },
8959
+ async createMerchantSession(options) {
8960
+ const id = `ms_${v4()}`;
8961
+ await client.insert(merchantSession).values({
8962
+ id,
8963
+ identifier: options.identifier,
8964
+ merchantAccountId: options.merchantAccountId,
8965
+ ...options.organizationId ? {
8966
+ organizationId: options.organizationId
8967
+ } : {}
8968
+ });
8969
+ return MerchantSessionSchema.parse(await client.query.merchantSession.findFirst({
8970
+ where: eq(merchantSession.id, id)
8971
+ }));
8972
+ },
8869
8973
  async createMerchantChargeAndPurchase(options) {
8870
8974
  const purchaseId = await client.transaction(async (trx) => {
8871
8975
  try {
@@ -8929,7 +9033,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
8929
9033
  }
8930
9034
  }
8931
9035
  const merchantSessionId = `ms_${v4()}`;
8932
- const newMerchantSession = await client.insert(merchantSession).values({
9036
+ await client.insert(merchantSession).values({
8933
9037
  id: merchantSessionId,
8934
9038
  identifier: checkoutSessionId,
8935
9039
  merchantAccountId
@@ -8941,7 +9045,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
8941
9045
  where: and(eq(merchantCoupon.identifier, appliedPPPStripeCouponId), eq(merchantCoupon.type, "ppp"))
8942
9046
  }) : null;
8943
9047
  const newPurchaseStatus = merchantCouponUsed?.type === "ppp" || pppMerchantCoupon ? "Restricted" : "Valid";
8944
- const newPurchase = await client.insert(purchaseTable).values({
9048
+ await client.insert(purchaseTable).values({
8945
9049
  id: purchaseId2,
8946
9050
  status: newPurchaseStatus,
8947
9051
  userId,
@@ -8955,7 +9059,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
8955
9059
  couponId: usedCouponId || null
8956
9060
  });
8957
9061
  const oneWeekInMilliseconds = 1e3 * 60 * 60 * 24 * 7;
8958
- const newPurchaseUserTransfer = await client.insert(purchaseUserTransfer).values({
9062
+ await client.insert(purchaseUserTransfer).values({
8959
9063
  id: `put_${v4()}`,
8960
9064
  purchaseId: purchaseId2,
8961
9065
  expiresAt: existingPurchase ? /* @__PURE__ */ new Date() : new Date(Date.now() + oneWeekInMilliseconds),
@@ -9121,7 +9225,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
9121
9225
  resource_id: z.string(),
9122
9226
  resource_type: z.enum([
9123
9227
  "lesson",
9124
- "exercise"
9228
+ "exercise",
9229
+ "post"
9125
9230
  ]),
9126
9231
  resource_slug: z.string().nullable(),
9127
9232
  completed_at: z.string().nullable().transform((val) => val ? new Date(val) : null)
@@ -9157,7 +9262,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
9157
9262
  LEFT JOIN ${resourceProgress} rp ON rp.resourceId = cr.id
9158
9263
  AND rp.userId = ${user.id}
9159
9264
  WHERE
9160
- cr.type IN ('lesson', 'exercise')
9265
+ cr.type IN ('lesson', 'exercise', 'post')
9161
9266
 
9162
9267
  `);
9163
9268
  const completedLessons = [];
@@ -10051,7 +10156,30 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
10051
10156
  ...data,
10052
10157
  id
10053
10158
  });
10054
- return await client.select().from(users).where(eq(users.id, id)).then((res) => res[0]);
10159
+ const personalOrganization = await adapter.createOrganization({
10160
+ name: `Personal (${data.email})`
10161
+ });
10162
+ if (!personalOrganization) {
10163
+ throw new Error("Failed to create personal organization");
10164
+ }
10165
+ const membership = await adapter.addMemberToOrganization({
10166
+ organizationId: personalOrganization.id,
10167
+ userId: id,
10168
+ invitedById: id
10169
+ });
10170
+ if (!membership) {
10171
+ throw new Error("Failed to add user to personal organization");
10172
+ }
10173
+ await adapter.addRoleForMember({
10174
+ organizationId: personalOrganization.id,
10175
+ memberId: membership.id,
10176
+ role: "owner"
10177
+ });
10178
+ const user = await adapter.getUser?.(id);
10179
+ if (!user) {
10180
+ throw new Error("Failed to get user");
10181
+ }
10182
+ return user;
10055
10183
  } catch (error) {
10056
10184
  console.error(error);
10057
10185
  throw error;
@@ -10133,6 +10261,138 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn, paymentProvi
10133
10261
  async unlinkAccount(account) {
10134
10262
  await client.delete(accounts).where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)));
10135
10263
  return void 0;
10264
+ },
10265
+ createOrganization: async (options) => {
10266
+ const organizationId = crypto.randomUUID();
10267
+ await client.insert(organizationTable).values({
10268
+ ...options,
10269
+ id: organizationId
10270
+ });
10271
+ return adapter.getOrganization(organizationId);
10272
+ },
10273
+ getOrganization: async (organizationId) => {
10274
+ return OrganizationSchema.parse(await client.query.organization.findFirst({
10275
+ where: eq(organizationTable.id, organizationId)
10276
+ }));
10277
+ },
10278
+ addMemberToOrganization: async (options) => {
10279
+ const id = crypto.randomUUID();
10280
+ await client.insert(organizationMembershipTable).values({
10281
+ ...options,
10282
+ id
10283
+ });
10284
+ return OrganizationMemberSchema.parse(await client.query.organizationMemberships.findFirst({
10285
+ where: eq(organizationMembershipTable.id, id),
10286
+ with: {
10287
+ organization: true,
10288
+ user: true
10289
+ }
10290
+ }));
10291
+ },
10292
+ removeMemberFromOrganization: async (options) => {
10293
+ await client.delete(organizationMembershipTable).where(and(eq(organizationMembershipTable.organizationId, options.organizationId), eq(organizationMembershipTable.userId, options.userId)));
10294
+ },
10295
+ addRoleForMember: async (options) => {
10296
+ const existingRole = z.object({
10297
+ id: z.string()
10298
+ }).nullish().parse(await client.query.roles.findFirst({
10299
+ where: and(eq(roleTable.organizationId, options.organizationId), eq(roleTable.name, options.role))
10300
+ }));
10301
+ const roleId = existingRole?.id || crypto.randomUUID();
10302
+ if (!existingRole) {
10303
+ await client.insert(roleTable).values({
10304
+ name: options.role,
10305
+ organizationId: options.organizationId,
10306
+ id: roleId
10307
+ });
10308
+ }
10309
+ const currentOrgMembershipRole = await client.query.organizationMembershipRoles.findFirst({
10310
+ where: and(eq(organizationMembershipRoleTable.organizationMembershipId, options.memberId), eq(organizationMembershipRoleTable.roleId, roleId))
10311
+ });
10312
+ if (!currentOrgMembershipRole) {
10313
+ await client.insert(organizationMembershipRoleTable).values({
10314
+ organizationId: options.organizationId,
10315
+ organizationMembershipId: options.memberId,
10316
+ roleId
10317
+ });
10318
+ }
10319
+ },
10320
+ removeRoleForMember: async (options) => {
10321
+ const existingRole = z.object({
10322
+ id: z.string()
10323
+ }).nullable().parse(await client.query.roles.findFirst({
10324
+ where: and(eq(roleTable.organizationId, options.organizationId), eq(roleTable.name, options.role))
10325
+ }));
10326
+ const roleId = existingRole?.id;
10327
+ if (roleId) {
10328
+ await client.delete(organizationMembershipRoleTable).where(eq(organizationMembershipRoleTable.roleId, roleId));
10329
+ }
10330
+ },
10331
+ getMembershipsForUser: async (userId) => {
10332
+ return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
10333
+ where: eq(organizationMembershipTable.userId, userId),
10334
+ with: {
10335
+ organization: true,
10336
+ user: true
10337
+ }
10338
+ }) || []);
10339
+ },
10340
+ getOrganizationMembers: async (organizationId) => {
10341
+ return OrganizationMemberSchema.array().parse(await client.query.organizationMemberships.findMany({
10342
+ where: eq(organizationMembershipTable.organizationId, organizationId)
10343
+ }) || []);
10344
+ },
10345
+ createSubscription: async (options) => {
10346
+ const id = `sub_${crypto.randomUUID()}`;
10347
+ await client.insert(subscriptionTable).values({
10348
+ ...options,
10349
+ id
10350
+ });
10351
+ return SubscriptionSchema.parse(await client.query.subscription.findFirst({
10352
+ where: eq(subscriptionTable.id, id),
10353
+ with: {
10354
+ product: true
10355
+ }
10356
+ }));
10357
+ },
10358
+ getMerchantSubscription: async (merchantSubscriptionId) => {
10359
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
10360
+ where: eq(merchantSubscriptionTable.id, merchantSubscriptionId)
10361
+ }));
10362
+ },
10363
+ createMerchantSubscription: async (options) => {
10364
+ const id = crypto.randomUUID();
10365
+ await client.insert(merchantSubscriptionTable).values({
10366
+ ...options,
10367
+ id
10368
+ });
10369
+ return MerchantSubscriptionSchema.parse(await client.query.merchantSubscription.findFirst({
10370
+ where: eq(merchantSubscriptionTable.id, id)
10371
+ }));
10372
+ },
10373
+ updateMerchantSubscription: async (options) => {
10374
+ throw new Error("Not implemented");
10375
+ },
10376
+ deleteMerchantSubscription: async (merchantSubscriptionId) => {
10377
+ throw new Error("Not implemented");
10378
+ },
10379
+ getSubscriptionForStripeId: async (stripeSubscriptionId) => {
10380
+ const merchantSubscriptionParsed = MerchantSubscriptionSchema.safeParse(await client.query.merchantSubscription.findFirst({
10381
+ where: eq(merchantSubscriptionTable.identifier, stripeSubscriptionId)
10382
+ }));
10383
+ if (!merchantSubscriptionParsed.success) {
10384
+ throw new Error(`No merchant subscription found for stripe id ${stripeSubscriptionId} ${merchantSubscriptionParsed.error}`);
10385
+ }
10386
+ const subscriptionParsed = SubscriptionSchema.safeParse(await client.query.subscription.findFirst({
10387
+ where: eq(subscriptionTable.merchantSubscriptionId, merchantSubscriptionParsed.data.id),
10388
+ with: {
10389
+ product: true
10390
+ }
10391
+ }));
10392
+ if (!subscriptionParsed.success) {
10393
+ throw new Error(`No subscription found for merchant subscription ${merchantSubscriptionParsed.data.id} ${subscriptionParsed.error}`);
10394
+ }
10395
+ return subscriptionParsed.data;
10136
10396
  }
10137
10397
  };
10138
10398
  return adapter;
@@ -10145,4 +10405,4 @@ export {
10145
10405
  createTables,
10146
10406
  mySqlDrizzleAdapter
10147
10407
  };
10148
- //# sourceMappingURL=chunk-L5ZAWSTN.js.map
10408
+ //# sourceMappingURL=chunk-MOV5TUON.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getUsersSchema
3
- } from "./chunk-QGZ2F5SW.js";
3
+ } from "./chunk-LPJ2P2KJ.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-H736K5TN.js";
@@ -59,4 +59,4 @@ export {
59
59
  getDeviceVerificationSchema,
60
60
  getDeviceVerificationRelationsSchema
61
61
  };
62
- //# sourceMappingURL=chunk-GAKWXOAY.js.map
62
+ //# sourceMappingURL=chunk-OBUGOZKM.js.map