@coursebuilder/adapter-drizzle 0.0.4 → 0.0.5

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 (188) hide show
  1. package/dist/{chunk-QM6AYTGN.js → chunk-6CBAFOL3.js} +5 -7
  2. package/dist/{chunk-NCDVIRG4.js → chunk-AIDEJDKJ.js} +5 -7
  3. package/dist/{chunk-34QNODEZ.js → chunk-BRGTUNY2.js} +5 -7
  4. package/dist/{chunk-WULUGMHP.js → chunk-H4MXNDWO.js} +5 -7
  5. package/dist/{chunk-JWWIIUV3.js → chunk-ICL7XZ2Y.js} +5 -7
  6. package/dist/{chunk-SBGLYMAH.js → chunk-JD4KFACE.js} +5 -7
  7. package/dist/{chunk-VID6JINS.js → chunk-JQFZOCAU.js} +98 -45
  8. package/dist/{chunk-ZUKX3WXB.js → chunk-KI47TR7F.js} +5 -7
  9. package/dist/{chunk-FZHAOQVB.js → chunk-KVN3JV7C.js} +5 -7
  10. package/dist/{chunk-H7XEMCP4.js → chunk-MBQ3TMHH.js} +5 -7
  11. package/dist/chunk-NISOQSUL.js +47 -0
  12. package/dist/chunk-PUGK2AEH.js +746 -0
  13. package/dist/{chunk-ABVLEWR5.js → chunk-SFJM6FKE.js} +5 -7
  14. package/dist/{chunk-QRRP7Y2V.js → chunk-TA6VLEV5.js} +5 -7
  15. package/dist/{chunk-BZPXYS6A.js → chunk-TMQIGK3N.js} +5 -7
  16. package/dist/{chunk-VWMY6XV7.js → chunk-US2EXVMI.js} +5 -7
  17. package/dist/{chunk-KFQAWBFP.js → chunk-UY3DVPP3.js} +5 -7
  18. package/dist/{chunk-M5NL4CY4.js → chunk-VEFCDI73.js} +5 -7
  19. package/dist/{chunk-EFO2N6T7.js → chunk-VZABQCFH.js} +5 -7
  20. package/dist/index.d.ts +1 -29
  21. package/dist/index.js +19 -30
  22. package/dist/lib/mysql/index.cjs +967 -769
  23. package/dist/lib/mysql/index.cjs.map +1 -1
  24. package/dist/lib/mysql/index.d.ts +4649 -745
  25. package/dist/lib/mysql/index.js +21 -117
  26. package/dist/lib/mysql/schemas/auth/accounts.cjs +124 -22
  27. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  28. package/dist/lib/mysql/schemas/auth/accounts.d.ts +180 -178
  29. package/dist/lib/mysql/schemas/auth/accounts.js +5 -1
  30. package/dist/lib/mysql/schemas/auth/permissions.cjs +108 -14
  31. package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
  32. package/dist/lib/mysql/schemas/auth/permissions.d.ts +96 -94
  33. package/dist/lib/mysql/schemas/auth/permissions.js +5 -1
  34. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +146 -13
  35. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  36. package/dist/lib/mysql/schemas/auth/role-permissions.d.ts +85 -82
  37. package/dist/lib/mysql/schemas/auth/role-permissions.js +5 -1
  38. package/dist/lib/mysql/schemas/auth/roles.cjs +110 -14
  39. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/auth/roles.d.ts +96 -94
  41. package/dist/lib/mysql/schemas/auth/roles.js +5 -1
  42. package/dist/lib/mysql/schemas/auth/sessions.cjs +116 -10
  43. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/auth/sessions.d.ts +48 -46
  45. package/dist/lib/mysql/schemas/auth/sessions.js +6 -1
  46. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +155 -15
  47. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +85 -82
  49. package/dist/lib/mysql/schemas/auth/user-permissions.js +5 -1
  50. package/dist/lib/mysql/schemas/auth/user-roles.cjs +151 -13
  51. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  52. package/dist/lib/mysql/schemas/auth/user-roles.d.ts +85 -82
  53. package/dist/lib/mysql/schemas/auth/user-roles.js +5 -1
  54. package/dist/lib/mysql/schemas/auth/users.cjs +310 -14
  55. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  56. package/dist/lib/mysql/schemas/auth/users.d.ts +101 -94
  57. package/dist/lib/mysql/schemas/auth/users.js +5 -1
  58. package/dist/lib/mysql/schemas/auth/verification-tokens.cjs +4 -6
  59. package/dist/lib/mysql/schemas/auth/verification-tokens.cjs.map +1 -1
  60. package/dist/lib/mysql/schemas/auth/verification-tokens.d.ts +55 -57
  61. package/dist/lib/mysql/schemas/auth/verification-tokens.js +1 -1
  62. package/dist/lib/mysql/schemas/commerce/coupon.cjs +4 -6
  63. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  64. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +163 -165
  65. package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
  66. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +4 -6
  67. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
  68. package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +67 -69
  69. package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
  70. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +4 -6
  71. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  72. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +103 -105
  73. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +1 -1
  74. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +4 -6
  75. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
  76. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +79 -81
  77. package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
  78. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +4 -6
  79. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
  80. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +79 -81
  81. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
  82. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +4 -6
  83. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
  84. package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +91 -93
  85. package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
  86. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +4 -6
  87. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
  88. package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +79 -81
  89. package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
  90. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +4 -6
  91. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
  92. package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +43 -45
  93. package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
  94. package/dist/lib/mysql/schemas/commerce/price.cjs +4 -6
  95. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  96. package/dist/lib/mysql/schemas/commerce/price.d.ts +91 -93
  97. package/dist/lib/mysql/schemas/commerce/price.js +1 -1
  98. package/dist/lib/mysql/schemas/commerce/product.cjs +4 -6
  99. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  100. package/dist/lib/mysql/schemas/commerce/product.d.ts +91 -93
  101. package/dist/lib/mysql/schemas/commerce/product.js +1 -1
  102. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +4 -6
  103. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  104. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +127 -129
  105. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +1 -1
  106. package/dist/lib/mysql/schemas/commerce/purchase.cjs +4 -6
  107. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  108. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +211 -213
  109. package/dist/lib/mysql/schemas/commerce/purchase.js +1 -1
  110. package/dist/lib/mysql/schemas/communication/communication-channel.cjs +4 -6
  111. package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
  112. package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +91 -93
  113. package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
  114. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +4 -6
  115. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
  116. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +91 -93
  117. package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
  118. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +192 -20
  119. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  120. package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +146 -142
  121. package/dist/lib/mysql/schemas/communication/communication-preferences.js +5 -1
  122. package/dist/lib/mysql/schemas/content/content-contributions.cjs +201 -17
  123. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  124. package/dist/lib/mysql/schemas/content/content-contributions.d.ts +110 -106
  125. package/dist/lib/mysql/schemas/content/content-contributions.js +5 -1
  126. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +128 -18
  127. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  128. package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +97 -94
  129. package/dist/lib/mysql/schemas/content/content-resource-resource.js +5 -1
  130. package/dist/lib/mysql/schemas/content/content-resource.cjs +198 -18
  131. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  132. package/dist/lib/mysql/schemas/content/content-resource.d.ts +99 -94
  133. package/dist/lib/mysql/schemas/content/content-resource.js +5 -1
  134. package/dist/lib/mysql/schemas/content/contribution-types.cjs +113 -16
  135. package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
  136. package/dist/lib/mysql/schemas/content/contribution-types.d.ts +108 -106
  137. package/dist/lib/mysql/schemas/content/contribution-types.js +5 -1
  138. package/dist/lib/mysql/schemas/content/resource-progress.cjs +4 -6
  139. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  140. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +79 -81
  141. package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
  142. package/dist/lib/pg.d.ts +1 -1
  143. package/dist/lib/sqlite.d.ts +1 -1
  144. package/dist/lib/utils.d.ts +1 -29
  145. package/package.json +1 -1
  146. package/src/lib/mysql/index.ts +95 -65
  147. package/src/lib/mysql/schemas/auth/accounts.ts +12 -3
  148. package/src/lib/mysql/schemas/auth/permissions.ts +10 -3
  149. package/src/lib/mysql/schemas/auth/role-permissions.ts +21 -3
  150. package/src/lib/mysql/schemas/auth/roles.ts +12 -3
  151. package/src/lib/mysql/schemas/auth/sessions.ts +12 -3
  152. package/src/lib/mysql/schemas/auth/user-permissions.ts +21 -3
  153. package/src/lib/mysql/schemas/auth/user-roles.ts +21 -3
  154. package/src/lib/mysql/schemas/auth/users.ts +26 -3
  155. package/src/lib/mysql/schemas/auth/verification-tokens.ts +2 -4
  156. package/src/lib/mysql/schemas/commerce/coupon.ts +2 -4
  157. package/src/lib/mysql/schemas/commerce/merchant-account.ts +2 -4
  158. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +2 -4
  159. package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +2 -4
  160. package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -4
  161. package/src/lib/mysql/schemas/commerce/merchant-price.ts +2 -4
  162. package/src/lib/mysql/schemas/commerce/merchant-product.ts +2 -4
  163. package/src/lib/mysql/schemas/commerce/merchant-session.ts +2 -4
  164. package/src/lib/mysql/schemas/commerce/price.ts +2 -4
  165. package/src/lib/mysql/schemas/commerce/product.ts +2 -4
  166. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +2 -4
  167. package/src/lib/mysql/schemas/commerce/purchase.ts +2 -4
  168. package/src/lib/mysql/schemas/communication/communication-channel.ts +2 -4
  169. package/src/lib/mysql/schemas/communication/communication-preference-types.ts +20 -25
  170. package/src/lib/mysql/schemas/communication/communication-preferences.ts +30 -3
  171. package/src/lib/mysql/schemas/content/content-contributions.ts +31 -3
  172. package/src/lib/mysql/schemas/content/content-resource-resource.ts +23 -4
  173. package/src/lib/mysql/schemas/content/content-resource.ts +22 -4
  174. package/src/lib/mysql/schemas/content/contribution-types.ts +13 -3
  175. package/src/lib/mysql/schemas/content/resource-progress.ts +2 -4
  176. package/dist/chunk-7Z72PW3G.js +0 -60
  177. package/dist/chunk-C2G2KMWQ.js +0 -48
  178. package/dist/chunk-GJZCLS2Y.js +0 -29
  179. package/dist/chunk-HHQK736S.js +0 -40
  180. package/dist/chunk-I4NIW2NF.js +0 -46
  181. package/dist/chunk-IHQ3ARH4.js +0 -44
  182. package/dist/chunk-KEJBPPZC.js +0 -45
  183. package/dist/chunk-L3XBKPYA.js +0 -47
  184. package/dist/chunk-MHZHMZ5C.js +0 -47
  185. package/dist/chunk-MOO56C62.js +0 -46
  186. package/dist/chunk-RLTOQRJB.js +0 -40
  187. package/dist/chunk-SWOTLIQI.js +0 -46
  188. package/dist/chunk-XM4CEU6B.js +0 -54
@@ -1,3 +1,4 @@
1
+ import { relations } from 'drizzle-orm'
1
2
  import {
2
3
  boolean,
3
4
  index,
@@ -7,8 +8,11 @@ import {
7
8
  varchar,
8
9
  } from 'drizzle-orm/mysql-core'
9
10
 
10
- export const getUserRolesSchema = (mysqlTable: MySqlTableFn) => {
11
- const userRoles = mysqlTable(
11
+ import { getRolesSchema } from './roles'
12
+ import { getUsersSchema } from './users'
13
+
14
+ export function getUserRolesSchema(mysqlTable: MySqlTableFn) {
15
+ return mysqlTable(
12
16
  'userRole',
13
17
  {
14
18
  userId: varchar('userId', { length: 255 }).notNull(),
@@ -33,6 +37,20 @@ export const getUserRolesSchema = (mysqlTable: MySqlTableFn) => {
33
37
  roleIdIdx: index('roleId_idx').on(ur.roleId),
34
38
  }),
35
39
  )
40
+ }
36
41
 
37
- return { userRoles }
42
+ export function getUserRolesRelationsSchema(mysqlTable: MySqlTableFn) {
43
+ const userRoles = getUserRolesSchema(mysqlTable)
44
+ const users = getUsersSchema(mysqlTable)
45
+ const roles = getRolesSchema(mysqlTable)
46
+ return relations(userRoles, ({ one }) => ({
47
+ user: one(users, {
48
+ fields: [userRoles.userId],
49
+ references: [users.id],
50
+ }),
51
+ role: one(roles, {
52
+ fields: [userRoles.roleId],
53
+ references: [roles.id],
54
+ }),
55
+ }))
38
56
  }
@@ -1,4 +1,4 @@
1
- import { sql } from 'drizzle-orm'
1
+ import { relations, sql } from 'drizzle-orm'
2
2
  import {
3
3
  index,
4
4
  mysqlEnum,
@@ -7,8 +7,15 @@ import {
7
7
  varchar,
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
+ import { getCommunicationPreferencesSchema } from '../communication/communication-preferences'
11
+ import { getContentContributionsSchema } from '../content/content-contributions'
12
+ import { getContentResourceSchema } from '../content/content-resource'
13
+ import { getAccountsSchema } from './accounts'
14
+ import { getUserPermissionsSchema } from './user-permissions'
15
+ import { getUserRolesSchema } from './user-roles'
16
+
10
17
  export function getUsersSchema(mysqlTable: MySqlTableFn) {
11
- const users = mysqlTable(
18
+ return mysqlTable(
12
19
  'user',
13
20
  {
14
21
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
@@ -30,6 +37,22 @@ export function getUsersSchema(mysqlTable: MySqlTableFn) {
30
37
  roleIdx: index('role_idx').on(user.role),
31
38
  }),
32
39
  )
40
+ }
33
41
 
34
- return { users }
42
+ export function getUsersRelationsSchema(mysqlTable: MySqlTableFn) {
43
+ const users = getUsersSchema(mysqlTable)
44
+ const accounts = getAccountsSchema(mysqlTable)
45
+ const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable)
46
+ const userRoles = getUserRolesSchema(mysqlTable)
47
+ const userPermissions = getUserPermissionsSchema(mysqlTable)
48
+ const contentContributions = getContentContributionsSchema(mysqlTable)
49
+ const contentResource = getContentResourceSchema(mysqlTable)
50
+ return relations(users, ({ many }) => ({
51
+ accounts: many(accounts),
52
+ communicationPreferences: many(communicationPreferences),
53
+ userRoles: many(userRoles),
54
+ userPermissions: many(userPermissions),
55
+ contributions: many(contentContributions),
56
+ createdContent: many(contentResource),
57
+ }))
35
58
  }
@@ -5,8 +5,8 @@ import {
5
5
  varchar,
6
6
  } from 'drizzle-orm/mysql-core'
7
7
 
8
- export const getVerificationTokensSchema = (mysqlTable: MySqlTableFn) => {
9
- const verificationTokens = mysqlTable(
8
+ export function getVerificationTokensSchema(mysqlTable: MySqlTableFn) {
9
+ return mysqlTable(
10
10
  'verificationToken',
11
11
  {
12
12
  identifier: varchar('identifier', { length: 255 }).notNull(),
@@ -21,6 +21,4 @@ export const getVerificationTokensSchema = (mysqlTable: MySqlTableFn) => {
21
21
  pk: primaryKey({ columns: [vt.identifier, vt.token] }),
22
22
  }),
23
23
  )
24
-
25
- return { verificationTokens }
26
24
  }
@@ -11,8 +11,8 @@ import {
11
11
  varchar,
12
12
  } from 'drizzle-orm/mysql-core'
13
13
 
14
- export const getCouponSchema = (mysqlTable: MySqlTableFn) => {
15
- const coupon = mysqlTable(
14
+ export function getCouponSchema(mysqlTable: MySqlTableFn) {
15
+ return mysqlTable(
16
16
  'coupons',
17
17
  {
18
18
  id: varchar('id', { length: 191 }).notNull(),
@@ -44,6 +44,4 @@ export const getCouponSchema = (mysqlTable: MySqlTableFn) => {
44
44
  }
45
45
  },
46
46
  )
47
-
48
- return { coupon }
49
47
  }
@@ -7,8 +7,8 @@ import {
7
7
  varchar,
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
- export const getMerchantAccountSchema = (mysqlTable: MySqlTableFn) => {
11
- const merchantAccount = mysqlTable(
10
+ export function getMerchantAccountSchema(mysqlTable: MySqlTableFn) {
11
+ return mysqlTable(
12
12
  'merchantAccounts',
13
13
  {
14
14
  id: varchar('id', { length: 191 }).notNull(),
@@ -28,6 +28,4 @@ export const getMerchantAccountSchema = (mysqlTable: MySqlTableFn) => {
28
28
  }
29
29
  },
30
30
  )
31
-
32
- return { merchantAccount }
33
31
  }
@@ -8,8 +8,8 @@ import {
8
8
  varchar,
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
- export const getMerchantChargeSchema = (mysqlTable: MySqlTableFn) => {
12
- const merchantCharge = mysqlTable(
11
+ export function getMerchantChargeSchema(mysqlTable: MySqlTableFn) {
12
+ return mysqlTable(
13
13
  'merchantCharges',
14
14
  {
15
15
  id: varchar('id', { length: 191 }).notNull(),
@@ -41,6 +41,4 @@ export const getMerchantChargeSchema = (mysqlTable: MySqlTableFn) => {
41
41
  }
42
42
  },
43
43
  )
44
-
45
- return { merchantCharge }
46
44
  }
@@ -7,8 +7,8 @@ import {
7
7
  varchar,
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
- export const getMerchantCouponSchema = (mysqlTable: MySqlTableFn) => {
11
- const merchantCoupon = mysqlTable(
10
+ export function getMerchantCouponSchema(mysqlTable: MySqlTableFn) {
11
+ return mysqlTable(
12
12
  'merchantCoupons',
13
13
  {
14
14
  id: varchar('id', { length: 191 }).notNull(),
@@ -35,6 +35,4 @@ export const getMerchantCouponSchema = (mysqlTable: MySqlTableFn) => {
35
35
  }
36
36
  },
37
37
  )
38
-
39
- return { merchantCoupon }
40
38
  }
@@ -8,8 +8,8 @@ import {
8
8
  varchar,
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
- export const getMerchantCustomerSchema = (mysqlTable: MySqlTableFn) => {
12
- const merchantCustomer = mysqlTable(
11
+ export function getMerchantCustomerSchema(mysqlTable: MySqlTableFn) {
12
+ return mysqlTable(
13
13
  'merchantCustomers',
14
14
  {
15
15
  id: varchar('id', { length: 191 }).notNull(),
@@ -35,6 +35,4 @@ export const getMerchantCustomerSchema = (mysqlTable: MySqlTableFn) => {
35
35
  }
36
36
  },
37
37
  )
38
-
39
- return { merchantCustomer }
40
38
  }
@@ -8,8 +8,8 @@ import {
8
8
  varchar,
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
- export const getMerchantPriceSchema = (mysqlTable: MySqlTableFn) => {
12
- const merchantPrice = mysqlTable(
11
+ export function getMerchantPriceSchema(mysqlTable: MySqlTableFn) {
12
+ return mysqlTable(
13
13
  'merchantPrices',
14
14
  {
15
15
  id: varchar('id', { length: 191 }).notNull(),
@@ -38,6 +38,4 @@ export const getMerchantPriceSchema = (mysqlTable: MySqlTableFn) => {
38
38
  }
39
39
  },
40
40
  )
41
-
42
- return { merchantPrice }
43
41
  }
@@ -8,8 +8,8 @@ import {
8
8
  varchar,
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
- export const getMerchantProductSchema = (mysqlTable: MySqlTableFn) => {
12
- const merchantProduct = mysqlTable(
11
+ export function getMerchantProductSchema(mysqlTable: MySqlTableFn) {
12
+ return mysqlTable(
13
13
  'merchantProducts',
14
14
  {
15
15
  id: varchar('id', { length: 191 }).notNull(),
@@ -35,6 +35,4 @@ export const getMerchantProductSchema = (mysqlTable: MySqlTableFn) => {
35
35
  }
36
36
  },
37
37
  )
38
-
39
- return { merchantProduct }
40
38
  }
@@ -1,7 +1,7 @@
1
1
  import { MySqlTableFn, primaryKey, varchar } from 'drizzle-orm/mysql-core'
2
2
 
3
- export const getMerchantSessionSchema = (mysqlTable: MySqlTableFn) => {
4
- const merchantSession = mysqlTable(
3
+ export function getMerchantSessionSchema(mysqlTable: MySqlTableFn) {
4
+ return mysqlTable(
5
5
  'merchantSessions',
6
6
  {
7
7
  id: varchar('id', { length: 191 }).notNull(),
@@ -19,6 +19,4 @@ export const getMerchantSessionSchema = (mysqlTable: MySqlTableFn) => {
19
19
  }
20
20
  },
21
21
  )
22
-
23
- return { merchantSession }
24
22
  }
@@ -9,8 +9,8 @@ import {
9
9
  varchar,
10
10
  } from 'drizzle-orm/mysql-core'
11
11
 
12
- export const getPriceSchema = (mysqlTable: MySqlTableFn) => {
13
- const price = mysqlTable(
12
+ export function getPriceSchema(mysqlTable: MySqlTableFn) {
13
+ return mysqlTable(
14
14
  'prices',
15
15
  {
16
16
  id: varchar('id', { length: 191 }).notNull(),
@@ -29,6 +29,4 @@ export const getPriceSchema = (mysqlTable: MySqlTableFn) => {
29
29
  }
30
30
  },
31
31
  )
32
-
33
- return { price }
34
32
  }
@@ -8,8 +8,8 @@ import {
8
8
  varchar,
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
- export const getProductSchema = (mysqlTable: MySqlTableFn) => {
12
- const product = mysqlTable(
11
+ export function getProductSchema(mysqlTable: MySqlTableFn) {
12
+ return mysqlTable(
13
13
  'products',
14
14
  {
15
15
  id: varchar('id', { length: 191 }).notNull(),
@@ -28,6 +28,4 @@ export const getProductSchema = (mysqlTable: MySqlTableFn) => {
28
28
  }
29
29
  },
30
30
  )
31
-
32
- return { product }
33
31
  }
@@ -7,8 +7,8 @@ import {
7
7
  varchar,
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
- export const getPurchaseUserTransferSchema = (mysqlTable: MySqlTableFn) => {
11
- const purchaseUserTransfer = mysqlTable(
10
+ export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
11
+ return mysqlTable(
12
12
  'purchaseUserTransfers',
13
13
  {
14
14
  id: varchar('id', { length: 191 }).notNull(),
@@ -43,6 +43,4 @@ export const getPurchaseUserTransferSchema = (mysqlTable: MySqlTableFn) => {
43
43
  }
44
44
  },
45
45
  )
46
-
47
- return { purchaseUserTransfer }
48
46
  }
@@ -9,8 +9,8 @@ import {
9
9
  varchar,
10
10
  } from 'drizzle-orm/mysql-core'
11
11
 
12
- export const getPurchaseSchema = (mysqlTable: MySqlTableFn) => {
13
- const purchase = mysqlTable(
12
+ export function getPurchaseSchema(mysqlTable: MySqlTableFn) {
13
+ return mysqlTable(
14
14
  'purchases',
15
15
  {
16
16
  id: varchar('id', { length: 191 }).notNull(),
@@ -45,6 +45,4 @@ export const getPurchaseSchema = (mysqlTable: MySqlTableFn) => {
45
45
  }
46
46
  },
47
47
  )
48
-
49
- return { purchase }
50
48
  }
@@ -7,8 +7,8 @@ import {
7
7
  varchar,
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
- export const getCommunicationChannelSchema = (mysqlTable: MySqlTableFn) => {
11
- const communicationChannel = mysqlTable(
10
+ export function getCommunicationChannelSchema(mysqlTable: MySqlTableFn) {
11
+ return mysqlTable(
12
12
  'communicationChannel',
13
13
  {
14
14
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
@@ -32,6 +32,4 @@ export const getCommunicationChannelSchema = (mysqlTable: MySqlTableFn) => {
32
32
  nameIdx: index('name_idx').on(cc.name),
33
33
  }),
34
34
  )
35
-
36
- return { communicationChannel }
37
35
  }
@@ -6,30 +6,25 @@ import {
6
6
  varchar,
7
7
  } from 'drizzle-orm/mysql-core'
8
8
 
9
- export const getCommunicationPreferenceTypesSchema = (
9
+ export function getCommunicationPreferenceTypesSchema(
10
10
  mysqlTable: MySqlTableFn,
11
- ) => {
12
- const communicationPreferenceTypes = mysqlTable(
13
- 'communicationPreferenceType',
14
- {
15
- id: varchar('id', { length: 255 }).notNull().primaryKey(),
16
- name: varchar('name', { length: 255 }).notNull(),
17
- description: text('description'),
18
- active: boolean('active').notNull().default(true),
19
- createdAt: timestamp('createdAt', {
20
- mode: 'date',
21
- fsp: 3,
22
- }).defaultNow(),
23
- updatedAt: timestamp('updatedAt', {
24
- mode: 'date',
25
- fsp: 3,
26
- }),
27
- deletedAt: timestamp('deletedAt', {
28
- mode: 'date',
29
- fsp: 3,
30
- }),
31
- },
32
- )
33
-
34
- return { communicationPreferenceTypes }
11
+ ) {
12
+ return mysqlTable('communicationPreferenceType', {
13
+ id: varchar('id', { length: 255 }).notNull().primaryKey(),
14
+ name: varchar('name', { length: 255 }).notNull(),
15
+ description: text('description'),
16
+ active: boolean('active').notNull().default(true),
17
+ createdAt: timestamp('createdAt', {
18
+ mode: 'date',
19
+ fsp: 3,
20
+ }).defaultNow(),
21
+ updatedAt: timestamp('updatedAt', {
22
+ mode: 'date',
23
+ fsp: 3,
24
+ }),
25
+ deletedAt: timestamp('deletedAt', {
26
+ mode: 'date',
27
+ fsp: 3,
28
+ }),
29
+ })
35
30
  }
@@ -1,3 +1,4 @@
1
+ import { relations } from 'drizzle-orm'
1
2
  import {
2
3
  boolean,
3
4
  index,
@@ -7,8 +8,12 @@ import {
7
8
  varchar,
8
9
  } from 'drizzle-orm/mysql-core'
9
10
 
10
- export const getCommunicationPreferencesSchema = (mysqlTable: MySqlTableFn) => {
11
- const communicationPreferences = mysqlTable(
11
+ import { getUsersSchema } from '../auth/users'
12
+ import { getCommunicationChannelSchema } from './communication-channel'
13
+ import { getCommunicationPreferenceTypesSchema } from './communication-preference-types'
14
+
15
+ export function getCommunicationPreferencesSchema(mysqlTable: MySqlTableFn) {
16
+ return mysqlTable(
12
17
  'communicationPreference',
13
18
  {
14
19
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
@@ -46,6 +51,28 @@ export const getCommunicationPreferencesSchema = (mysqlTable: MySqlTableFn) => {
46
51
  channelIdIdx: index('channelId_idx').on(cp.channelId),
47
52
  }),
48
53
  )
54
+ }
49
55
 
50
- return { communicationPreferences }
56
+ export function getCommunicationPreferencesRelationsSchema(
57
+ mysqlTable: MySqlTableFn,
58
+ ) {
59
+ const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable)
60
+ const users = getUsersSchema(mysqlTable)
61
+ const communicationChannel = getCommunicationChannelSchema(mysqlTable)
62
+ const communicationPreferenceTypes =
63
+ getCommunicationPreferenceTypesSchema(mysqlTable)
64
+ return relations(communicationPreferences, ({ one }) => ({
65
+ user: one(users, {
66
+ fields: [communicationPreferences.userId],
67
+ references: [users.id],
68
+ }),
69
+ channel: one(communicationChannel, {
70
+ fields: [communicationPreferences.channelId],
71
+ references: [communicationChannel.id],
72
+ }),
73
+ preferenceType: one(communicationPreferenceTypes, {
74
+ fields: [communicationPreferences.preferenceTypeId],
75
+ references: [communicationPreferenceTypes.id],
76
+ }),
77
+ }))
51
78
  }
@@ -1,3 +1,4 @@
1
+ import { relations } from 'drizzle-orm'
1
2
  import {
2
3
  boolean,
3
4
  index,
@@ -6,8 +7,12 @@ import {
6
7
  varchar,
7
8
  } from 'drizzle-orm/mysql-core'
8
9
 
9
- export const getContentContributionsSchema = (mysqlTable: MySqlTableFn) => {
10
- const contentContributions = mysqlTable(
10
+ import { getUsersSchema } from '../auth/users'
11
+ import { getContentResourceSchema } from './content-resource'
12
+ import { getContributionTypesSchema } from './contribution-types'
13
+
14
+ export function getContentContributionsSchema(mysqlTable: MySqlTableFn) {
15
+ return mysqlTable(
11
16
  'contentContribution',
12
17
  {
13
18
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
@@ -38,5 +43,28 @@ export const getContentContributionsSchema = (mysqlTable: MySqlTableFn) => {
38
43
  ),
39
44
  }),
40
45
  )
41
- return { contentContributions }
46
+ }
47
+
48
+ export function getContentContributionRelationsSchema(
49
+ mysqlTable: MySqlTableFn,
50
+ ) {
51
+ const contentContributions = getContentContributionsSchema(mysqlTable)
52
+ const users = getUsersSchema(mysqlTable)
53
+ const contentResource = getContentResourceSchema(mysqlTable)
54
+ const contributionTypes = getContributionTypesSchema(mysqlTable)
55
+
56
+ return relations(contentContributions, ({ one }) => ({
57
+ user: one(users, {
58
+ fields: [contentContributions.userId],
59
+ references: [users.id],
60
+ }),
61
+ content: one(contentResource, {
62
+ fields: [contentContributions.contentId],
63
+ references: [contentResource.id],
64
+ }),
65
+ contributionType: one(contributionTypes, {
66
+ fields: [contentContributions.contributionTypeId],
67
+ references: [contributionTypes.id],
68
+ }),
69
+ }))
42
70
  }
@@ -1,4 +1,4 @@
1
- import { sql } from 'drizzle-orm'
1
+ import { relations, sql } from 'drizzle-orm'
2
2
  import {
3
3
  double,
4
4
  index,
@@ -9,8 +9,10 @@ import {
9
9
  varchar,
10
10
  } from 'drizzle-orm/mysql-core'
11
11
 
12
- export const getContentResourceResourceSchema = (mysqlTable: MySqlTableFn) => {
13
- const contentResourceResource = mysqlTable(
12
+ import { getContentResourceSchema } from './content-resource'
13
+
14
+ export function getContentResourceResourceSchema(mysqlTable: MySqlTableFn) {
15
+ return mysqlTable(
14
16
  'contentResourceResource',
15
17
  {
16
18
  resourceOfId: varchar('resourceOfId', { length: 255 }).notNull(),
@@ -36,6 +38,23 @@ export const getContentResourceResourceSchema = (mysqlTable: MySqlTableFn) => {
36
38
  resourceIdIdx: index('resourceId_idx').on(crr.resourceId),
37
39
  }),
38
40
  )
41
+ }
39
42
 
40
- return { contentResourceResource }
43
+ export function getContentResourceResourceRelationsSchema(
44
+ mysqlTable: MySqlTableFn,
45
+ ) {
46
+ const contentResource = getContentResourceSchema(mysqlTable)
47
+ const contentResourceResource = getContentResourceResourceSchema(mysqlTable)
48
+ return relations(contentResourceResource, ({ one }) => ({
49
+ resourceOf: one(contentResource, {
50
+ fields: [contentResourceResource.resourceOfId],
51
+ references: [contentResource.id],
52
+ relationName: 'resourceOf',
53
+ }),
54
+ resource: one(contentResource, {
55
+ fields: [contentResourceResource.resourceId],
56
+ references: [contentResource.id],
57
+ relationName: 'resource',
58
+ }),
59
+ }))
41
60
  }
@@ -1,4 +1,4 @@
1
- import { sql } from 'drizzle-orm'
1
+ import { relations, sql } from 'drizzle-orm'
2
2
  import {
3
3
  index,
4
4
  json,
@@ -7,8 +7,12 @@ import {
7
7
  varchar,
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
- export const getContentResourceSchema = (mysqlTable: MySqlTableFn) => {
11
- const contentResource = mysqlTable(
10
+ import { getUsersSchema } from '../auth/users'
11
+ import { getContentContributionsSchema } from './content-contributions'
12
+ import { getContentResourceResourceSchema } from './content-resource-resource'
13
+
14
+ export function getContentResourceSchema(mysqlTable: MySqlTableFn) {
15
+ return mysqlTable(
12
16
  'contentResource',
13
17
  {
14
18
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
@@ -34,6 +38,20 @@ export const getContentResourceSchema = (mysqlTable: MySqlTableFn) => {
34
38
  createdAtIdx: index('createdAt_idx').on(cm.createdAt),
35
39
  }),
36
40
  )
41
+ }
37
42
 
38
- return { contentResource }
43
+ export function getContentResourceRelationsSchema(mysqlTable: MySqlTableFn) {
44
+ const contentResource = getContentResourceSchema(mysqlTable)
45
+ const users = getUsersSchema(mysqlTable)
46
+ const contentContributions = getContentContributionsSchema(mysqlTable)
47
+ const contentResourceResource = getContentResourceResourceSchema(mysqlTable)
48
+ return relations(contentResource, ({ one, many }) => ({
49
+ createdBy: one(users, {
50
+ fields: [contentResource.createdById],
51
+ references: [users.id],
52
+ }),
53
+ contributions: many(contentContributions),
54
+ resources: many(contentResourceResource, { relationName: 'resourceOf' }),
55
+ resourceOf: many(contentResourceResource, { relationName: 'resource' }),
56
+ }))
39
57
  }
@@ -1,3 +1,4 @@
1
+ import { relations } from 'drizzle-orm'
1
2
  import {
2
3
  boolean,
3
4
  index,
@@ -7,8 +8,10 @@ import {
7
8
  varchar,
8
9
  } from 'drizzle-orm/mysql-core'
9
10
 
10
- export const getContributionTypesSchema = (mysqlTable: MySqlTableFn) => {
11
- const contributionTypes = mysqlTable(
11
+ import { getContentContributionsSchema } from './content-contributions'
12
+
13
+ export function getContributionTypesSchema(mysqlTable: MySqlTableFn) {
14
+ return mysqlTable(
12
15
  'contributionType',
13
16
  {
14
17
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
@@ -34,6 +37,13 @@ export const getContributionTypesSchema = (mysqlTable: MySqlTableFn) => {
34
37
  slugIdx: index('slug_idx').on(ct.slug),
35
38
  }),
36
39
  )
40
+ }
41
+
42
+ export function getContributionTypesRelationsSchema(mysqlTable: MySqlTableFn) {
43
+ const contributionTypes = getContributionTypesSchema(mysqlTable)
44
+ const contentContributions = getContentContributionsSchema(mysqlTable)
37
45
 
38
- return { contributionTypes }
46
+ return relations(contributionTypes, ({ many }) => ({
47
+ contributions: many(contentContributions),
48
+ }))
39
49
  }
@@ -8,8 +8,8 @@ import {
8
8
  varchar,
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
- export const getResourceProgressSchema = (mysqlTable: MySqlTableFn) => {
12
- const resourceProgress = mysqlTable(
11
+ export function getResourceProgressSchema(mysqlTable: MySqlTableFn) {
12
+ return mysqlTable(
13
13
  'resourceProgresses',
14
14
  {
15
15
  userId: varchar('userId', { length: 191 }).notNull(),
@@ -35,6 +35,4 @@ export const getResourceProgressSchema = (mysqlTable: MySqlTableFn) => {
35
35
  }
36
36
  },
37
37
  )
38
-
39
- return { resourceProgress }
40
38
  }