@coursebuilder/adapter-drizzle 2.0.0 → 2.1.0

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 (77) hide show
  1. package/dist/{chunk-ULJCXOOM.js → chunk-25RKHMRM.js} +521 -4993
  2. package/dist/{chunk-WPDVDHLH.js → chunk-2AW5KYAK.js} +2 -2
  3. package/dist/{chunk-QDWLBCD3.js → chunk-3AF6MZQ7.js} +2 -2
  4. package/dist/{chunk-RDAVEULA.js → chunk-3EF5ZXLG.js} +2 -2
  5. package/dist/{chunk-4SMVVOU5.js → chunk-4SWTV7Z3.js} +2 -2
  6. package/dist/{chunk-6VDGZ4KA.js → chunk-7FBSP3VD.js} +2 -2
  7. package/dist/chunk-AP5HBIV4.js +112 -0
  8. package/dist/chunk-CFSRMUNC.js +78 -0
  9. package/dist/{chunk-Q5NZ5UFZ.js → chunk-DUFH5L2F.js} +2 -2
  10. package/dist/{chunk-DHII2GRW.js → chunk-EZEQQJNH.js} +2 -2
  11. package/dist/chunk-F56AI52P.js +49 -0
  12. package/dist/chunk-FJGNLVE4.js +101 -0
  13. package/dist/chunk-HAQZSRJL.js +4696 -0
  14. package/dist/chunk-I2U5PTWN.js +79 -0
  15. package/dist/chunk-IBQGXFEX.js +8729 -0
  16. package/dist/chunk-KIQLUFJX.js +101 -0
  17. package/dist/{chunk-3XHKEHGF.js → chunk-M3WM5Q7W.js} +2 -2
  18. package/dist/{chunk-52A4W4YI.js → chunk-MYG6PCE3.js} +2 -2
  19. package/dist/chunk-PJORQUQP.js +58 -0
  20. package/dist/{chunk-DB473RZJ.js → chunk-PNPTKVJ4.js} +4 -4
  21. package/dist/chunk-W6RPAAKG.js +2144 -0
  22. package/dist/chunk-WKJTU24D.js +88 -0
  23. package/dist/chunk-WWBSNLRC.js +63 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.js +18 -17
  26. package/dist/lib/mysql/cms-resource-actions.cjs +4715 -0
  27. package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -0
  28. package/dist/lib/mysql/cms-resource-actions.d.cts +140 -0
  29. package/dist/lib/mysql/cms-resource-actions.d.ts +140 -0
  30. package/dist/lib/mysql/cms-resource-actions.js +8 -0
  31. package/dist/lib/mysql/cms-resource-actions.js.map +1 -0
  32. package/dist/lib/mysql/index.cjs +398 -186
  33. package/dist/lib/mysql/index.cjs.map +1 -1
  34. package/dist/lib/mysql/index.d.cts +5 -0
  35. package/dist/lib/mysql/index.d.ts +5 -0
  36. package/dist/lib/mysql/index.js +21 -17
  37. package/dist/lib/mysql/schemas/auth/accounts.js +5 -5
  38. package/dist/lib/mysql/schemas/auth/device-access-token.js +6 -6
  39. package/dist/lib/mysql/schemas/auth/device-verification.js +6 -6
  40. package/dist/lib/mysql/schemas/auth/personal-access-token.js +6 -6
  41. package/dist/lib/mysql/schemas/auth/profiles.js +5 -5
  42. package/dist/lib/mysql/schemas/auth/role-permissions.js +6 -6
  43. package/dist/lib/mysql/schemas/auth/roles.js +5 -5
  44. package/dist/lib/mysql/schemas/auth/sessions.js +6 -6
  45. package/dist/lib/mysql/schemas/auth/user-permissions.js +5 -5
  46. package/dist/lib/mysql/schemas/auth/user-prefs.js +5 -5
  47. package/dist/lib/mysql/schemas/auth/user-roles.js +5 -5
  48. package/dist/lib/mysql/schemas/auth/users.js +5 -5
  49. package/dist/lib/mysql/schemas/commerce/coupon.js +5 -5
  50. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +5 -5
  51. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +5 -5
  52. package/dist/lib/mysql/schemas/commerce/price.js +5 -5
  53. package/dist/lib/mysql/schemas/commerce/product.js +5 -5
  54. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +6 -6
  55. package/dist/lib/mysql/schemas/commerce/purchase.js +5 -5
  56. package/dist/lib/mysql/schemas/commerce/subscription.js +5 -5
  57. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +6 -6
  58. package/dist/lib/mysql/schemas/communication/comment.js +5 -5
  59. package/dist/lib/mysql/schemas/communication/communication-preferences.js +5 -5
  60. package/dist/lib/mysql/schemas/communication/question-response.js +6 -6
  61. package/dist/lib/mysql/schemas/content/content-contributions.js +5 -5
  62. package/dist/lib/mysql/schemas/content/content-resource-product.js +5 -5
  63. package/dist/lib/mysql/schemas/content/content-resource-resource.js +5 -5
  64. package/dist/lib/mysql/schemas/content/content-resource-tag.js +5 -5
  65. package/dist/lib/mysql/schemas/content/content-resource-version.js +5 -5
  66. package/dist/lib/mysql/schemas/content/content-resource.js +5 -5
  67. package/dist/lib/mysql/schemas/content/tag-tag.js +5 -5
  68. package/dist/lib/mysql/schemas/content/tag.js +5 -5
  69. package/dist/lib/mysql/schemas/entitlements/entitlement.js +6 -6
  70. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +5 -5
  71. package/dist/lib/mysql/schemas/org/organization-memberships.js +5 -5
  72. package/dist/lib/mysql/schemas/org/organizations.js +5 -5
  73. package/dist/lib/utils.d.cts +5 -0
  74. package/dist/lib/utils.d.ts +5 -0
  75. package/package.json +2 -2
  76. package/src/lib/mysql/cms-resource-actions.ts +490 -0
  77. package/src/lib/mysql/index.ts +2 -0
@@ -2,7 +2,7 @@ import {
2
2
  getOrganizationMembershipsSchema,
3
3
  getOrganizationsSchema,
4
4
  getUsersSchema
5
- } from "./chunk-DB473RZJ.js";
5
+ } from "./chunk-PNPTKVJ4.js";
6
6
  import {
7
7
  __name
8
8
  } from "./chunk-2X5XVNDN.js";
@@ -98,4 +98,4 @@ export {
98
98
  getEntitlementsSchema,
99
99
  getEntitlementRelationsSchema
100
100
  };
101
- //# sourceMappingURL=chunk-WPDVDHLH.js.map
101
+ //# sourceMappingURL=chunk-2AW5KYAK.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getPurchaseSchema,
3
3
  getUsersSchema
4
- } from "./chunk-DB473RZJ.js";
4
+ } from "./chunk-W6RPAAKG.js";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-2X5XVNDN.js";
@@ -109,4 +109,4 @@ export {
109
109
  getPurchaseUserTransferSchema,
110
110
  getPurchaseUserTransferRelationsSchema
111
111
  };
112
- //# sourceMappingURL=chunk-QDWLBCD3.js.map
112
+ //# sourceMappingURL=chunk-3AF6MZQ7.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getContentResourceSchema,
3
3
  getUsersSchema
4
- } from "./chunk-DB473RZJ.js";
4
+ } from "./chunk-W6RPAAKG.js";
5
5
  import {
6
6
  __name
7
7
  } from "./chunk-2X5XVNDN.js";
@@ -98,4 +98,4 @@ export {
98
98
  getQuestionResponseSchema,
99
99
  getQuestionResponseRelationsSchema
100
100
  };
101
- //# sourceMappingURL=chunk-RDAVEULA.js.map
101
+ //# sourceMappingURL=chunk-3EF5ZXLG.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getUsersSchema
3
- } from "./chunk-DB473RZJ.js";
3
+ } from "./chunk-W6RPAAKG.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-2X5XVNDN.js";
@@ -55,4 +55,4 @@ export {
55
55
  getDeviceAccessTokenSchema,
56
56
  getDeviceAccessTokenRelationsSchema
57
57
  };
58
- //# sourceMappingURL=chunk-4SMVVOU5.js.map
58
+ //# sourceMappingURL=chunk-4SWTV7Z3.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getRolesSchema
3
- } from "./chunk-DB473RZJ.js";
3
+ } from "./chunk-PNPTKVJ4.js";
4
4
  import {
5
5
  getPermissionsSchema
6
6
  } from "./chunk-UWUDJCJM.js";
@@ -75,4 +75,4 @@ export {
75
75
  getRolePermissionsSchema,
76
76
  getRolePermissionsRelationsSchema
77
77
  };
78
- //# sourceMappingURL=chunk-6VDGZ4KA.js.map
78
+ //# sourceMappingURL=chunk-7FBSP3VD.js.map
@@ -0,0 +1,112 @@
1
+ import {
2
+ getPurchaseSchema,
3
+ getUsersSchema
4
+ } from "./chunk-PNPTKVJ4.js";
5
+ import {
6
+ __name
7
+ } from "./chunk-2X5XVNDN.js";
8
+
9
+ // src/lib/mysql/schemas/commerce/purchase-user-transfer.ts
10
+ import { relations, sql } from "drizzle-orm";
11
+ import { index, mysqlEnum, primaryKey, timestamp, varchar } from "drizzle-orm/mysql-core";
12
+ function getPurchaseUserTransferSchema(mysqlTable) {
13
+ return mysqlTable("PurchaseUserTransfer", {
14
+ id: varchar("id", {
15
+ length: 191
16
+ }).notNull(),
17
+ transferState: mysqlEnum("transferState", [
18
+ "AVAILABLE",
19
+ "INITIATED",
20
+ "VERIFIED",
21
+ "CANCELED",
22
+ "EXPIRED",
23
+ "CONFIRMED",
24
+ "COMPLETED"
25
+ ]).default("AVAILABLE").notNull(),
26
+ purchaseId: varchar("purchaseId", {
27
+ length: 191
28
+ }).notNull(),
29
+ organizationId: varchar("organizationId", {
30
+ length: 191
31
+ }),
32
+ sourceUserId: varchar("sourceUserId", {
33
+ length: 191
34
+ }).notNull(),
35
+ targetUserId: varchar("targetUserId", {
36
+ length: 191
37
+ }),
38
+ createdAt: timestamp("createdAt", {
39
+ mode: "date",
40
+ fsp: 3
41
+ }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
42
+ expiresAt: timestamp("expiresAt", {
43
+ mode: "date",
44
+ fsp: 3
45
+ }),
46
+ canceledAt: timestamp("canceledAt", {
47
+ mode: "date",
48
+ fsp: 3
49
+ }),
50
+ confirmedAt: timestamp("confirmedAt", {
51
+ mode: "date",
52
+ fsp: 3
53
+ }),
54
+ completedAt: timestamp("completedAt", {
55
+ mode: "date",
56
+ fsp: 3
57
+ })
58
+ }, (table) => {
59
+ return {
60
+ purchaseUserTransferId: primaryKey({
61
+ columns: [
62
+ table.id
63
+ ],
64
+ name: "PurchaseUserTransfer_id"
65
+ }),
66
+ organizationIdIdx: index("organizationId_idx").on(table.organizationId)
67
+ };
68
+ });
69
+ }
70
+ __name(getPurchaseUserTransferSchema, "getPurchaseUserTransferSchema");
71
+ function getPurchaseUserTransferRelationsSchema(mysqlTable, overrides = {}) {
72
+ const purchaseUserTransfer = getPurchaseUserTransferSchema(mysqlTable);
73
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
74
+ const user = resolveUsersSchema(mysqlTable);
75
+ const purchase = getPurchaseSchema(mysqlTable);
76
+ return relations(purchaseUserTransfer, ({ one }) => ({
77
+ sourceUser: one(user, {
78
+ fields: [
79
+ purchaseUserTransfer.sourceUserId
80
+ ],
81
+ references: [
82
+ user.id
83
+ ],
84
+ relationName: "sourceUser"
85
+ }),
86
+ targetUser: one(user, {
87
+ fields: [
88
+ purchaseUserTransfer.targetUserId
89
+ ],
90
+ references: [
91
+ user.id
92
+ ],
93
+ relationName: "targetUser"
94
+ }),
95
+ purchase: one(purchase, {
96
+ fields: [
97
+ purchaseUserTransfer.purchaseId
98
+ ],
99
+ references: [
100
+ purchase.id
101
+ ],
102
+ relationName: "purchase"
103
+ })
104
+ }));
105
+ }
106
+ __name(getPurchaseUserTransferRelationsSchema, "getPurchaseUserTransferRelationsSchema");
107
+
108
+ export {
109
+ getPurchaseUserTransferSchema,
110
+ getPurchaseUserTransferRelationsSchema
111
+ };
112
+ //# sourceMappingURL=chunk-AP5HBIV4.js.map
@@ -0,0 +1,78 @@
1
+ import {
2
+ getRolesSchema
3
+ } from "./chunk-W6RPAAKG.js";
4
+ import {
5
+ getPermissionsSchema
6
+ } from "./chunk-UWUDJCJM.js";
7
+ import {
8
+ __name
9
+ } from "./chunk-2X5XVNDN.js";
10
+
11
+ // src/lib/mysql/schemas/auth/role-permissions.ts
12
+ import { relations } from "drizzle-orm";
13
+ import { boolean, index, primaryKey, timestamp, varchar } from "drizzle-orm/mysql-core";
14
+ function getRolePermissionsSchema(mysqlTable) {
15
+ return mysqlTable("RolePermission", {
16
+ roleId: varchar("roleId", {
17
+ length: 255
18
+ }).notNull(),
19
+ permissionId: varchar("permissionId", {
20
+ length: 255
21
+ }).notNull(),
22
+ active: boolean("active").notNull().default(true),
23
+ createdAt: timestamp("createdAt", {
24
+ mode: "date",
25
+ fsp: 3
26
+ }).defaultNow(),
27
+ updatedAt: timestamp("updatedAt", {
28
+ mode: "date",
29
+ fsp: 3
30
+ }).defaultNow(),
31
+ deletedAt: timestamp("deletedAt", {
32
+ mode: "date",
33
+ fsp: 3
34
+ })
35
+ }, (rp) => ({
36
+ pk: primaryKey({
37
+ columns: [
38
+ rp.roleId,
39
+ rp.permissionId
40
+ ]
41
+ }),
42
+ roleIdIdx: index("roleId_idx").on(rp.roleId),
43
+ permissionIdIdx: index("permissionId_idx").on(rp.permissionId)
44
+ }));
45
+ }
46
+ __name(getRolePermissionsSchema, "getRolePermissionsSchema");
47
+ function getRolePermissionsRelationsSchema(mysqlTable) {
48
+ const permissions = getPermissionsSchema(mysqlTable);
49
+ const roles = getRolesSchema(mysqlTable);
50
+ const rolePermissions = getRolePermissionsSchema(mysqlTable);
51
+ return relations(rolePermissions, ({ one }) => ({
52
+ role: one(roles, {
53
+ fields: [
54
+ rolePermissions.roleId
55
+ ],
56
+ references: [
57
+ roles.id
58
+ ],
59
+ relationName: "role"
60
+ }),
61
+ permission: one(permissions, {
62
+ fields: [
63
+ rolePermissions.permissionId
64
+ ],
65
+ references: [
66
+ permissions.id
67
+ ],
68
+ relationName: "permission"
69
+ })
70
+ }));
71
+ }
72
+ __name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
73
+
74
+ export {
75
+ getRolePermissionsSchema,
76
+ getRolePermissionsRelationsSchema
77
+ };
78
+ //# sourceMappingURL=chunk-CFSRMUNC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getUsersSchema
3
- } from "./chunk-DB473RZJ.js";
3
+ } from "./chunk-W6RPAAKG.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-2X5XVNDN.js";
@@ -46,4 +46,4 @@ export {
46
46
  getSessionsSchema,
47
47
  getSessionRelationsSchema
48
48
  };
49
- //# sourceMappingURL=chunk-Q5NZ5UFZ.js.map
49
+ //# sourceMappingURL=chunk-DUFH5L2F.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getProductSchema
3
- } from "./chunk-DB473RZJ.js";
3
+ } from "./chunk-PNPTKVJ4.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-2X5XVNDN.js";
@@ -76,4 +76,4 @@ export {
76
76
  getUpgradableProductsSchema,
77
77
  getUpgradableProductsRelationsSchema
78
78
  };
79
- //# sourceMappingURL=chunk-DHII2GRW.js.map
79
+ //# sourceMappingURL=chunk-EZEQQJNH.js.map
@@ -0,0 +1,49 @@
1
+ import {
2
+ getUsersSchema
3
+ } from "./chunk-PNPTKVJ4.js";
4
+ import {
5
+ __name
6
+ } from "./chunk-2X5XVNDN.js";
7
+
8
+ // src/lib/mysql/schemas/auth/sessions.ts
9
+ import { relations } from "drizzle-orm";
10
+ import { index, timestamp, varchar } from "drizzle-orm/mysql-core";
11
+ function getSessionsSchema(mysqlTable) {
12
+ return mysqlTable("Session", {
13
+ sessionToken: varchar("sessionToken", {
14
+ length: 255
15
+ }).notNull().primaryKey(),
16
+ userId: varchar("userId", {
17
+ length: 255
18
+ }).notNull(),
19
+ expires: timestamp("expires", {
20
+ mode: "date"
21
+ }).notNull()
22
+ }, (session) => ({
23
+ userIdIdx: index("userId_idx").on(session.userId)
24
+ }));
25
+ }
26
+ __name(getSessionsSchema, "getSessionsSchema");
27
+ function getSessionRelationsSchema(mysqlTable, overrides = {}) {
28
+ const sessions = getSessionsSchema(mysqlTable);
29
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
30
+ const users = resolveUsersSchema(mysqlTable);
31
+ return relations(sessions, ({ one }) => ({
32
+ user: one(users, {
33
+ fields: [
34
+ sessions.userId
35
+ ],
36
+ references: [
37
+ users.id
38
+ ],
39
+ relationName: "user"
40
+ })
41
+ }));
42
+ }
43
+ __name(getSessionRelationsSchema, "getSessionRelationsSchema");
44
+
45
+ export {
46
+ getSessionsSchema,
47
+ getSessionRelationsSchema
48
+ };
49
+ //# sourceMappingURL=chunk-F56AI52P.js.map
@@ -0,0 +1,101 @@
1
+ import {
2
+ getOrganizationMembershipsSchema,
3
+ getOrganizationsSchema,
4
+ getUsersSchema
5
+ } from "./chunk-W6RPAAKG.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-2X5XVNDN.js";
9
+
10
+ // src/lib/mysql/schemas/entitlements/entitlement.ts
11
+ import { relations, sql } from "drizzle-orm";
12
+ import { index, json, timestamp, varchar } from "drizzle-orm/mysql-core";
13
+ function getEntitlementsSchema(mysqlTable) {
14
+ return mysqlTable("Entitlement", {
15
+ id: varchar("id", {
16
+ length: 191
17
+ }).notNull().primaryKey(),
18
+ entitlementType: varchar("entitlementType", {
19
+ length: 255
20
+ }).notNull(),
21
+ userId: varchar("userId", {
22
+ length: 191
23
+ }),
24
+ organizationId: varchar("organizationId", {
25
+ length: 191
26
+ }),
27
+ organizationMembershipId: varchar("organizationMembershipId", {
28
+ length: 191
29
+ }),
30
+ sourceType: varchar("sourceType", {
31
+ length: 255
32
+ }).notNull(),
33
+ sourceId: varchar("sourceId", {
34
+ length: 191
35
+ }).notNull(),
36
+ metadata: json("metadata").$type().default({}),
37
+ expiresAt: timestamp("expiresAt", {
38
+ mode: "date",
39
+ fsp: 3
40
+ }),
41
+ createdAt: timestamp("createdAt", {
42
+ mode: "date",
43
+ fsp: 3
44
+ }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
45
+ updatedAt: timestamp("updatedAt", {
46
+ mode: "date",
47
+ fsp: 3
48
+ }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
49
+ deletedAt: timestamp("deletedAt", {
50
+ mode: "date",
51
+ fsp: 3
52
+ })
53
+ }, (table) => ({
54
+ userIdIdx: index("userId_idx").on(table.userId),
55
+ orgIdIdx: index("orgId_idx").on(table.organizationId),
56
+ sourceIdx: index("source_idx").on(table.sourceType, table.sourceId),
57
+ typeIdx: index("type_idx").on(table.entitlementType),
58
+ userIdTypeDeletedAtIdx: index("idx_Entitlement_on_userId_type_deletedAt").on(table.userId, table.entitlementType, table.deletedAt)
59
+ }));
60
+ }
61
+ __name(getEntitlementsSchema, "getEntitlementsSchema");
62
+ function getEntitlementRelationsSchema(mysqlTable, overrides = {}) {
63
+ const entitlements = getEntitlementsSchema(mysqlTable);
64
+ const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
65
+ const users = resolveUsersSchema(mysqlTable);
66
+ const orgs = getOrganizationsSchema(mysqlTable);
67
+ const memberships = getOrganizationMembershipsSchema(mysqlTable);
68
+ return relations(entitlements, ({ one }) => ({
69
+ user: one(users, {
70
+ fields: [
71
+ entitlements.userId
72
+ ],
73
+ references: [
74
+ users.id
75
+ ]
76
+ }),
77
+ organization: one(orgs, {
78
+ fields: [
79
+ entitlements.organizationId
80
+ ],
81
+ references: [
82
+ orgs.id
83
+ ]
84
+ }),
85
+ membership: one(memberships, {
86
+ fields: [
87
+ entitlements.organizationMembershipId
88
+ ],
89
+ references: [
90
+ memberships.id
91
+ ]
92
+ })
93
+ }));
94
+ }
95
+ __name(getEntitlementRelationsSchema, "getEntitlementRelationsSchema");
96
+
97
+ export {
98
+ getEntitlementsSchema,
99
+ getEntitlementRelationsSchema
100
+ };
101
+ //# sourceMappingURL=chunk-FJGNLVE4.js.map