@coursebuilder/adapter-drizzle 1.0.7 → 2.0.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 (126) hide show
  1. package/dist/authjs.d.ts +27 -0
  2. package/dist/authjs.js +1 -0
  3. package/dist/chunk-3XHKEHGF.js +88 -0
  4. package/dist/{chunk-ENIKVP6O.js → chunk-4SMVVOU5.js} +2 -2
  5. package/dist/{chunk-EJ7UDN4T.js → chunk-52A4W4YI.js} +2 -2
  6. package/dist/{chunk-3RQH7IPC.js → chunk-6VDGZ4KA.js} +2 -2
  7. package/dist/{chunk-JX53ECWI.js → chunk-DB473RZJ.js} +13 -12
  8. package/dist/{chunk-O4PMFTPJ.js → chunk-DHII2GRW.js} +2 -2
  9. package/dist/{chunk-P76GFFVH.js → chunk-Q5NZ5UFZ.js} +2 -2
  10. package/dist/{chunk-5WMUBNWJ.js → chunk-QDWLBCD3.js} +2 -2
  11. package/dist/{chunk-MQSLKVLJ.js → chunk-RDAVEULA.js} +2 -2
  12. package/dist/{chunk-DP6YPJZ4.js → chunk-ULJCXOOM.js} +634 -197
  13. package/dist/{chunk-U6XVAMCK.js → chunk-WPDVDHLH.js} +4 -3
  14. package/dist/index.d.ts +5 -3
  15. package/dist/index.js +15 -14
  16. package/dist/lib/mysql/index.cjs +1068 -557
  17. package/dist/lib/mysql/index.cjs.map +1 -1
  18. package/dist/lib/mysql/index.d.cts +412 -6
  19. package/dist/lib/mysql/index.d.ts +412 -6
  20. package/dist/lib/mysql/index.js +15 -14
  21. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  22. package/dist/lib/mysql/schemas/auth/accounts.d.cts +2 -2
  23. package/dist/lib/mysql/schemas/auth/accounts.d.ts +2 -2
  24. package/dist/lib/mysql/schemas/auth/accounts.js +3 -3
  25. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  26. package/dist/lib/mysql/schemas/auth/device-access-token.js +4 -4
  27. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  28. package/dist/lib/mysql/schemas/auth/device-verification.js +4 -4
  29. package/dist/lib/mysql/schemas/auth/personal-access-token.cjs +288 -0
  30. package/dist/lib/mysql/schemas/auth/personal-access-token.cjs.map +1 -0
  31. package/dist/lib/mysql/schemas/auth/personal-access-token.d.cts +243 -0
  32. package/dist/lib/mysql/schemas/auth/personal-access-token.d.ts +243 -0
  33. package/dist/lib/mysql/schemas/auth/personal-access-token.js +21 -0
  34. package/dist/lib/mysql/schemas/auth/personal-access-token.js.map +1 -0
  35. package/dist/lib/mysql/schemas/auth/profiles.cjs.map +1 -1
  36. package/dist/lib/mysql/schemas/auth/profiles.js +3 -3
  37. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  38. package/dist/lib/mysql/schemas/auth/role-permissions.js +4 -4
  39. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/auth/roles.js +3 -3
  41. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  42. package/dist/lib/mysql/schemas/auth/sessions.js +4 -4
  43. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/auth/user-permissions.js +3 -3
  45. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  46. package/dist/lib/mysql/schemas/auth/user-prefs.js +3 -3
  47. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/auth/user-roles.js +3 -3
  49. package/dist/lib/mysql/schemas/auth/users.cjs +2 -1
  50. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  51. package/dist/lib/mysql/schemas/auth/users.js +3 -3
  52. package/dist/lib/mysql/schemas/commerce/coupon.cjs +2 -1
  53. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  54. package/dist/lib/mysql/schemas/commerce/coupon.js +3 -3
  55. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  56. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +3 -3
  57. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +3 -3
  59. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  60. package/dist/lib/mysql/schemas/commerce/price.js +3 -3
  61. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  62. package/dist/lib/mysql/schemas/commerce/product.js +3 -3
  63. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +2 -1
  64. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  65. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +4 -4
  66. package/dist/lib/mysql/schemas/commerce/purchase.cjs +2 -1
  67. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  68. package/dist/lib/mysql/schemas/commerce/purchase.js +3 -3
  69. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -1
  70. package/dist/lib/mysql/schemas/commerce/subscription.js +3 -3
  71. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  72. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +4 -4
  73. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  74. package/dist/lib/mysql/schemas/communication/comment.js +3 -3
  75. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  76. package/dist/lib/mysql/schemas/communication/communication-preferences.js +3 -3
  77. package/dist/lib/mysql/schemas/communication/question-response.cjs.map +1 -1
  78. package/dist/lib/mysql/schemas/communication/question-response.js +4 -4
  79. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  80. package/dist/lib/mysql/schemas/content/content-contributions.js +3 -3
  81. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  82. package/dist/lib/mysql/schemas/content/content-resource-product.js +3 -3
  83. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  84. package/dist/lib/mysql/schemas/content/content-resource-resource.js +3 -3
  85. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  86. package/dist/lib/mysql/schemas/content/content-resource-tag.js +3 -3
  87. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  88. package/dist/lib/mysql/schemas/content/content-resource-version.js +3 -3
  89. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  90. package/dist/lib/mysql/schemas/content/content-resource.js +3 -3
  91. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  92. package/dist/lib/mysql/schemas/content/tag-tag.js +3 -3
  93. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  94. package/dist/lib/mysql/schemas/content/tag.js +3 -3
  95. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs +2 -1
  96. package/dist/lib/mysql/schemas/entitlements/entitlement.cjs.map +1 -1
  97. package/dist/lib/mysql/schemas/entitlements/entitlement.js +4 -4
  98. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -1
  99. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +3 -3
  100. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +2 -1
  101. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -1
  102. package/dist/lib/mysql/schemas/org/organization-memberships.js +3 -3
  103. package/dist/lib/mysql/schemas/org/organizations.cjs +2 -1
  104. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -1
  105. package/dist/lib/mysql/schemas/org/organizations.js +3 -3
  106. package/dist/lib/utils.d.cts +3 -1
  107. package/dist/lib/utils.d.ts +3 -1
  108. package/package.json +9 -8
  109. package/src/authjs.ts +34 -0
  110. package/src/index.ts +2 -2
  111. package/src/lib/mysql/index.ts +224 -50
  112. package/src/lib/mysql/schemas/auth/accounts.ts +3 -2
  113. package/src/lib/mysql/schemas/auth/personal-access-token.ts +107 -0
  114. package/src/lib/mysql/schemas/commerce/purchase.ts +3 -0
  115. package/src/lib/mysql/schemas/entitlements/entitlement.ts +3 -0
  116. package/dist/chunk-6XFVP2Q4.js +0 -101
  117. package/dist/chunk-7223HR2E.js +0 -112
  118. package/dist/chunk-HEQ5MII4.js +0 -12764
  119. package/dist/chunk-LV3LIBNU.js +0 -12764
  120. package/dist/chunk-MUFYDXA7.js +0 -2143
  121. package/dist/chunk-OK4NHV6Z.js +0 -58
  122. package/dist/chunk-SUOPB24V.js +0 -78
  123. package/dist/chunk-UIQCNODZ.js +0 -100
  124. package/dist/chunk-XKCPXM63.js +0 -79
  125. package/dist/chunk-XM5PWOCV.js +0 -63
  126. package/dist/chunk-YMVONZZW.js +0 -49
@@ -1,58 +0,0 @@
1
- import {
2
- getUsersSchema
3
- } from "./chunk-JX53ECWI.js";
4
- import {
5
- __name
6
- } from "./chunk-2X5XVNDN.js";
7
-
8
- // src/lib/mysql/schemas/auth/device-access-token.ts
9
- import { relations, sql } from "drizzle-orm";
10
- import { index, primaryKey, timestamp, varchar } from "drizzle-orm/mysql-core";
11
- function getDeviceAccessTokenSchema(mysqlTable) {
12
- return mysqlTable("DeviceAccessToken", {
13
- token: varchar("token", {
14
- length: 191
15
- }).notNull(),
16
- userId: varchar("userId", {
17
- length: 191
18
- }).notNull(),
19
- organizationMembershipId: varchar("organizationMembershipId", {
20
- length: 191
21
- }),
22
- createdAt: timestamp("createdAt", {
23
- mode: "date",
24
- fsp: 3
25
- }).default(sql`CURRENT_TIMESTAMP(3)`)
26
- }, (crr) => ({
27
- pk: primaryKey({
28
- columns: [
29
- crr.token
30
- ]
31
- }),
32
- userIdIdx: index("userId_idx").on(crr.userId)
33
- }));
34
- }
35
- __name(getDeviceAccessTokenSchema, "getDeviceAccessTokenSchema");
36
- function getDeviceAccessTokenRelationsSchema(mysqlTable, overrides = {}) {
37
- const deviceAccessToken = getDeviceAccessTokenSchema(mysqlTable);
38
- const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
39
- const user = resolveUsersSchema(mysqlTable);
40
- return relations(deviceAccessToken, ({ one }) => ({
41
- verifiedBy: one(user, {
42
- fields: [
43
- deviceAccessToken.userId
44
- ],
45
- references: [
46
- user.id
47
- ],
48
- relationName: "user"
49
- })
50
- }));
51
- }
52
- __name(getDeviceAccessTokenRelationsSchema, "getDeviceAccessTokenRelationsSchema");
53
-
54
- export {
55
- getDeviceAccessTokenSchema,
56
- getDeviceAccessTokenRelationsSchema
57
- };
58
- //# sourceMappingURL=chunk-OK4NHV6Z.js.map
@@ -1,78 +0,0 @@
1
- import {
2
- getRolesSchema
3
- } from "./chunk-MUFYDXA7.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-SUOPB24V.js.map
@@ -1,100 +0,0 @@
1
- import {
2
- getOrganizationMembershipsSchema,
3
- getOrganizationsSchema,
4
- getUsersSchema
5
- } from "./chunk-JX53ECWI.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
- }));
59
- }
60
- __name(getEntitlementsSchema, "getEntitlementsSchema");
61
- function getEntitlementRelationsSchema(mysqlTable, overrides = {}) {
62
- const entitlements = getEntitlementsSchema(mysqlTable);
63
- const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
64
- const users = resolveUsersSchema(mysqlTable);
65
- const orgs = getOrganizationsSchema(mysqlTable);
66
- const memberships = getOrganizationMembershipsSchema(mysqlTable);
67
- return relations(entitlements, ({ one }) => ({
68
- user: one(users, {
69
- fields: [
70
- entitlements.userId
71
- ],
72
- references: [
73
- users.id
74
- ]
75
- }),
76
- organization: one(orgs, {
77
- fields: [
78
- entitlements.organizationId
79
- ],
80
- references: [
81
- orgs.id
82
- ]
83
- }),
84
- membership: one(memberships, {
85
- fields: [
86
- entitlements.organizationMembershipId
87
- ],
88
- references: [
89
- memberships.id
90
- ]
91
- })
92
- }));
93
- }
94
- __name(getEntitlementRelationsSchema, "getEntitlementRelationsSchema");
95
-
96
- export {
97
- getEntitlementsSchema,
98
- getEntitlementRelationsSchema
99
- };
100
- //# sourceMappingURL=chunk-UIQCNODZ.js.map
@@ -1,79 +0,0 @@
1
- import {
2
- getProductSchema
3
- } from "./chunk-MUFYDXA7.js";
4
- import {
5
- __name
6
- } from "./chunk-2X5XVNDN.js";
7
-
8
- // src/lib/mysql/schemas/commerce/upgradable-products.ts
9
- import { relations, sql } from "drizzle-orm";
10
- import { double, index, json, primaryKey, timestamp, varchar } from "drizzle-orm/mysql-core";
11
- function getUpgradableProductsSchema(mysqlTable) {
12
- return mysqlTable("UpgradableProducts", {
13
- upgradableToId: varchar("upgradableToId", {
14
- length: 255
15
- }).notNull(),
16
- upgradableFromId: varchar("upgradableFrom", {
17
- length: 255
18
- }).notNull(),
19
- organizationId: varchar("organizationId", {
20
- length: 191
21
- }),
22
- position: double("position").notNull().default(0),
23
- metadata: json("metadata").$type().default({}),
24
- createdAt: timestamp("createdAt", {
25
- mode: "date",
26
- fsp: 3
27
- }).default(sql`CURRENT_TIMESTAMP(3)`),
28
- updatedAt: timestamp("updatedAt", {
29
- mode: "date",
30
- fsp: 3
31
- }).default(sql`CURRENT_TIMESTAMP(3)`),
32
- deletedAt: timestamp("deletedAt", {
33
- mode: "date",
34
- fsp: 3
35
- })
36
- }, (crr) => ({
37
- pk: primaryKey({
38
- columns: [
39
- crr.upgradableToId,
40
- crr.upgradableFromId
41
- ]
42
- }),
43
- upgradableToIdIdx: index("upgradableFromId_idx").on(crr.upgradableToId),
44
- upgradableFromIdIdx: index("upgradableToId_idx").on(crr.upgradableFromId),
45
- organizationIdIdx: index("organizationId_idx").on(crr.organizationId)
46
- }));
47
- }
48
- __name(getUpgradableProductsSchema, "getUpgradableProductsSchema");
49
- function getUpgradableProductsRelationsSchema(mysqlTable) {
50
- const product = getProductSchema(mysqlTable);
51
- const upgradableProduct = getUpgradableProductsSchema(mysqlTable);
52
- return relations(upgradableProduct, ({ one }) => ({
53
- upgradableTo: one(product, {
54
- fields: [
55
- upgradableProduct.upgradableToId
56
- ],
57
- references: [
58
- product.id
59
- ],
60
- relationName: "upgradableTo"
61
- }),
62
- upgradableFrom: one(product, {
63
- fields: [
64
- upgradableProduct.upgradableFromId
65
- ],
66
- references: [
67
- product.id
68
- ],
69
- relationName: "upgradableFrom"
70
- })
71
- }));
72
- }
73
- __name(getUpgradableProductsRelationsSchema, "getUpgradableProductsRelationsSchema");
74
-
75
- export {
76
- getUpgradableProductsSchema,
77
- getUpgradableProductsRelationsSchema
78
- };
79
- //# sourceMappingURL=chunk-XKCPXM63.js.map
@@ -1,63 +0,0 @@
1
- import {
2
- getUsersSchema
3
- } from "./chunk-JX53ECWI.js";
4
- import {
5
- __name
6
- } from "./chunk-2X5XVNDN.js";
7
-
8
- // src/lib/mysql/schemas/auth/device-verification.ts
9
- import { relations, sql } from "drizzle-orm";
10
- import { primaryKey, text, timestamp, varchar } from "drizzle-orm/mysql-core";
11
- function getDeviceVerificationSchema(mysqlTable) {
12
- return mysqlTable("DeviceVerification", {
13
- verifiedByUserId: varchar("verifiedByUserId", {
14
- length: 255
15
- }),
16
- deviceCode: varchar("deviceCode", {
17
- length: 191
18
- }).notNull(),
19
- userCode: text("userCode").notNull(),
20
- expires: timestamp("expires", {
21
- mode: "date",
22
- fsp: 3
23
- }).notNull(),
24
- createdAt: timestamp("createdAt", {
25
- mode: "date",
26
- fsp: 3
27
- }).default(sql`CURRENT_TIMESTAMP(3)`),
28
- verifiedAt: timestamp("verifiedAt", {
29
- mode: "date",
30
- fsp: 3
31
- })
32
- }, (crr) => ({
33
- pk: primaryKey({
34
- columns: [
35
- crr.deviceCode
36
- ]
37
- })
38
- }));
39
- }
40
- __name(getDeviceVerificationSchema, "getDeviceVerificationSchema");
41
- function getDeviceVerificationRelationsSchema(mysqlTable, overrides = {}) {
42
- const deviceVerification = getDeviceVerificationSchema(mysqlTable);
43
- const resolveUsersSchema = overrides.getUsersSchema ?? getUsersSchema;
44
- const user = resolveUsersSchema(mysqlTable);
45
- return relations(deviceVerification, ({ one }) => ({
46
- verifiedBy: one(user, {
47
- fields: [
48
- deviceVerification.verifiedByUserId
49
- ],
50
- references: [
51
- user.id
52
- ],
53
- relationName: "user"
54
- })
55
- }));
56
- }
57
- __name(getDeviceVerificationRelationsSchema, "getDeviceVerificationRelationsSchema");
58
-
59
- export {
60
- getDeviceVerificationSchema,
61
- getDeviceVerificationRelationsSchema
62
- };
63
- //# sourceMappingURL=chunk-XM5PWOCV.js.map
@@ -1,49 +0,0 @@
1
- import {
2
- getUsersSchema
3
- } from "./chunk-MUFYDXA7.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-YMVONZZW.js.map