@coursebuilder/adapter-drizzle 0.0.7 → 0.1.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 (161) hide show
  1. package/dist/{chunk-ICL7XZ2Y.js → chunk-27KREOQW.js} +4 -4
  2. package/dist/{chunk-KVN3JV7C.js → chunk-44VDBYFU.js} +6 -6
  3. package/dist/{chunk-VEFCDI73.js → chunk-75V6F7LZ.js} +12 -12
  4. package/dist/{chunk-SQR6UWVO.js → chunk-7LAAAEVE.js} +165 -11
  5. package/dist/{chunk-TA6VLEV5.js → chunk-AFQGYW7Z.js} +4 -4
  6. package/dist/{chunk-US2EXVMI.js → chunk-CPE4P26C.js} +4 -4
  7. package/dist/{chunk-VZABQCFH.js → chunk-IN6G6MTW.js} +4 -4
  8. package/dist/{chunk-4HDU7QIB.js → chunk-ISURSRBK.js} +345 -324
  9. package/dist/{chunk-AIDEJDKJ.js → chunk-JKRFXYAR.js} +4 -4
  10. package/dist/{chunk-KI47TR7F.js → chunk-L2TQQYG4.js} +4 -4
  11. package/dist/{chunk-UY3DVPP3.js → chunk-LSOPFMDB.js} +4 -4
  12. package/dist/chunk-MCFL2YV4.js +4679 -0
  13. package/dist/{chunk-PFN4YUQZ.js → chunk-MYRB6GLJ.js} +4 -3
  14. package/dist/chunk-NZDLUQWP.js +44 -0
  15. package/dist/{chunk-22KIKVBY.js → chunk-O2KKII62.js} +163 -10
  16. package/dist/{chunk-MBQ3TMHH.js → chunk-OIUOQ3TT.js} +4 -4
  17. package/dist/chunk-QZOBGJSV.js +78 -0
  18. package/dist/chunk-RVYJDDZD.js +75 -0
  19. package/dist/chunk-V6QEDDFG.js +49 -0
  20. package/dist/{chunk-FRNVLW7N.js → chunk-Y34AIPU7.js} +34 -303
  21. package/dist/index.js +21 -17
  22. package/dist/lib/mysql/index.cjs +5896 -1367
  23. package/dist/lib/mysql/index.cjs.map +1 -1
  24. package/dist/lib/mysql/index.d.ts +325 -129
  25. package/dist/lib/mysql/index.js +19 -15
  26. package/dist/lib/mysql/schemas/auth/accounts.cjs +73 -57
  27. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  28. package/dist/lib/mysql/schemas/auth/accounts.js +7 -1
  29. package/dist/lib/mysql/schemas/auth/permissions.cjs +9 -98
  30. package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
  31. package/dist/lib/mysql/schemas/auth/permissions.d.ts +1 -3
  32. package/dist/lib/mysql/schemas/auth/permissions.js +1 -3
  33. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +64 -43
  34. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  35. package/dist/lib/mysql/schemas/auth/role-permissions.js +8 -1
  36. package/dist/lib/mysql/schemas/auth/roles.cjs +63 -46
  37. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  38. package/dist/lib/mysql/schemas/auth/roles.js +7 -1
  39. package/dist/lib/mysql/schemas/auth/sessions.cjs +63 -47
  40. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  41. package/dist/lib/mysql/schemas/auth/sessions.js +8 -2
  42. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +97 -82
  43. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/auth/user-permissions.js +7 -1
  45. package/dist/lib/mysql/schemas/auth/user-roles.cjs +65 -48
  46. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  47. package/dist/lib/mysql/schemas/auth/user-roles.js +7 -1
  48. package/dist/lib/mysql/schemas/auth/users.cjs +233 -132
  49. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  50. package/dist/lib/mysql/schemas/auth/users.d.ts +2 -1
  51. package/dist/lib/mysql/schemas/auth/users.js +7 -1
  52. package/dist/lib/mysql/schemas/commerce/coupon.cjs +4 -4
  53. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  54. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +6 -6
  55. package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
  56. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +2 -2
  57. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +3 -3
  59. package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
  60. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +2 -2
  61. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  62. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +3 -3
  63. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +1 -1
  64. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +2 -2
  65. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
  66. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +3 -3
  67. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
  68. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +2 -2
  69. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
  70. package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +3 -3
  71. package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
  72. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +2 -2
  73. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
  74. package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +3 -3
  75. package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
  76. package/dist/lib/mysql/schemas/commerce/price.cjs +2 -2
  77. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  78. package/dist/lib/mysql/schemas/commerce/price.d.ts +3 -3
  79. package/dist/lib/mysql/schemas/commerce/price.js +1 -1
  80. package/dist/lib/mysql/schemas/commerce/product.cjs +2 -2
  81. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  82. package/dist/lib/mysql/schemas/commerce/product.d.ts +3 -3
  83. package/dist/lib/mysql/schemas/commerce/product.js +1 -1
  84. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +10 -10
  85. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  86. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +15 -15
  87. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +1 -1
  88. package/dist/lib/mysql/schemas/commerce/purchase.cjs +320 -21
  89. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  90. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +12 -4
  91. package/dist/lib/mysql/schemas/commerce/purchase.js +11 -1
  92. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +130 -0
  93. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -0
  94. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +101 -0
  95. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -0
  96. package/dist/lib/mysql/schemas/commerce/upgradable-products.js.map +1 -0
  97. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +90 -72
  98. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  99. package/dist/lib/mysql/schemas/communication/communication-preferences.js +7 -1
  100. package/dist/lib/mysql/schemas/content/content-contributions.cjs +94 -76
  101. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  102. package/dist/lib/mysql/schemas/content/content-contributions.js +7 -1
  103. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +68 -53
  104. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  105. package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +1 -1
  106. package/dist/lib/mysql/schemas/content/content-resource-resource.js +7 -1
  107. package/dist/lib/mysql/schemas/content/content-resource.cjs +81 -103
  108. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  109. package/dist/lib/mysql/schemas/content/content-resource.d.ts +0 -1
  110. package/dist/lib/mysql/schemas/content/content-resource.js +7 -1
  111. package/dist/lib/mysql/schemas/content/contribution-types.cjs +11 -102
  112. package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
  113. package/dist/lib/mysql/schemas/content/contribution-types.d.ts +1 -3
  114. package/dist/lib/mysql/schemas/content/contribution-types.js +1 -3
  115. package/dist/lib/mysql/schemas/content/resource-progress.cjs +3 -3
  116. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  117. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +9 -9
  118. package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
  119. package/dist/lib/mysql/utils.cjs +51 -0
  120. package/dist/lib/mysql/utils.cjs.map +1 -0
  121. package/dist/lib/mysql/utils.d.ts +12 -0
  122. package/dist/lib/mysql/utils.js +29 -0
  123. package/dist/lib/mysql/utils.js.map +1 -0
  124. package/dist/lib/pg.cjs +4289 -9
  125. package/dist/lib/pg.cjs.map +1 -1
  126. package/dist/lib/pg.d.ts +91 -0
  127. package/dist/lib/pg.js +2 -1
  128. package/dist/lib/sqlite.cjs +4285 -8
  129. package/dist/lib/sqlite.cjs.map +1 -1
  130. package/dist/lib/sqlite.js +2 -1
  131. package/package.json +6 -4
  132. package/src/lib/mysql/index.ts +694 -34
  133. package/src/lib/mysql/schemas/auth/accounts.ts +5 -1
  134. package/src/lib/mysql/schemas/auth/permissions.ts +1 -3
  135. package/src/lib/mysql/schemas/auth/role-permissions.ts +2 -0
  136. package/src/lib/mysql/schemas/auth/roles.ts +1 -1
  137. package/src/lib/mysql/schemas/auth/sessions.ts +5 -1
  138. package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -0
  139. package/src/lib/mysql/schemas/auth/user-roles.ts +2 -0
  140. package/src/lib/mysql/schemas/auth/users.ts +23 -6
  141. package/src/lib/mysql/schemas/commerce/coupon.ts +3 -3
  142. package/src/lib/mysql/schemas/commerce/merchant-account.ts +2 -2
  143. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +2 -2
  144. package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -2
  145. package/src/lib/mysql/schemas/commerce/merchant-price.ts +2 -2
  146. package/src/lib/mysql/schemas/commerce/merchant-product.ts +2 -2
  147. package/src/lib/mysql/schemas/commerce/price.ts +2 -2
  148. package/src/lib/mysql/schemas/commerce/product.ts +2 -2
  149. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +6 -6
  150. package/src/lib/mysql/schemas/commerce/purchase.ts +49 -3
  151. package/src/lib/mysql/schemas/commerce/upgradable-products.ts +58 -0
  152. package/src/lib/mysql/schemas/communication/communication-preferences.ts +3 -0
  153. package/src/lib/mysql/schemas/content/content-contributions.ts +3 -0
  154. package/src/lib/mysql/schemas/content/content-resource-resource.ts +1 -1
  155. package/src/lib/mysql/schemas/content/content-resource.ts +1 -2
  156. package/src/lib/mysql/schemas/content/contribution-types.ts +1 -4
  157. package/src/lib/mysql/schemas/content/resource-progress.ts +3 -3
  158. package/src/lib/mysql/utils.ts +23 -0
  159. package/src/lib/pg.ts +298 -16
  160. package/src/lib/sqlite.ts +290 -15
  161. package/dist/chunk-BRGTUNY2.js +0 -78
@@ -1,51 +1,156 @@
1
+ import {
2
+ getContributionTypesSchema
3
+ } from "./chunk-V6QEDDFG.js";
4
+ import {
5
+ getProductSchema
6
+ } from "./chunk-CPE4P26C.js";
1
7
  import {
2
8
  getCommunicationChannelSchema
3
9
  } from "./chunk-6CBAFOL3.js";
4
10
  import {
5
11
  getCommunicationPreferenceTypesSchema
6
12
  } from "./chunk-SFJM6FKE.js";
13
+ import {
14
+ getMerchantChargeSchema
15
+ } from "./chunk-27KREOQW.js";
16
+ import {
17
+ getMerchantSessionSchema
18
+ } from "./chunk-H4MXNDWO.js";
19
+ import {
20
+ getCouponSchema
21
+ } from "./chunk-44VDBYFU.js";
22
+ import {
23
+ getPermissionsSchema
24
+ } from "./chunk-NZDLUQWP.js";
7
25
  import {
8
26
  __name
9
27
  } from "./chunk-VNI36MMC.js";
10
28
 
11
- // src/lib/mysql/schemas/communication/communication-preferences.ts
12
- import { relations as relations12 } from "drizzle-orm";
13
- import { boolean as boolean8, index as index12, mysqlEnum as mysqlEnum2, timestamp as timestamp11, varchar as varchar12 } from "drizzle-orm/mysql-core";
29
+ // src/lib/mysql/schemas/commerce/purchase.ts
30
+ import { relations as relations10, sql as sql4 } from "drizzle-orm";
31
+ import { decimal, json as json3, primaryKey as primaryKey5, timestamp as timestamp9, unique, varchar as varchar10 } from "drizzle-orm/mysql-core";
14
32
 
15
33
  // src/lib/mysql/schemas/auth/users.ts
16
- import { relations as relations11, sql as sql3 } from "drizzle-orm";
17
- import { index as index11, mysqlEnum, timestamp as timestamp10, varchar as varchar11 } from "drizzle-orm/mysql-core";
34
+ import { relations as relations9, sql as sql3 } from "drizzle-orm";
35
+ import { index as index9, mysqlEnum as mysqlEnum2, timestamp as timestamp8, varchar as varchar9 } from "drizzle-orm/mysql-core";
36
+
37
+ // src/lib/mysql/schemas/communication/communication-preferences.ts
38
+ import { relations } from "drizzle-orm";
39
+ import { boolean, index, mysqlEnum, timestamp, varchar } from "drizzle-orm/mysql-core";
40
+ function getCommunicationPreferencesSchema(mysqlTable) {
41
+ return mysqlTable("communicationPreference", {
42
+ id: varchar("id", {
43
+ length: 255
44
+ }).notNull().primaryKey(),
45
+ userId: varchar("userId", {
46
+ length: 255
47
+ }).notNull(),
48
+ channelId: varchar("channelId", {
49
+ length: 255
50
+ }).notNull(),
51
+ preferenceLevel: mysqlEnum("preferenceLevel", [
52
+ "low",
53
+ "medium",
54
+ "high"
55
+ ]).notNull().default("medium"),
56
+ preferenceTypeId: varchar("preferenceTypeId", {
57
+ length: 255
58
+ }).notNull(),
59
+ active: boolean("active").notNull().default(true),
60
+ createdAt: timestamp("createdAt", {
61
+ mode: "date",
62
+ fsp: 3
63
+ }).defaultNow(),
64
+ optInAt: timestamp("optInAt", {
65
+ mode: "date",
66
+ fsp: 3
67
+ }),
68
+ optOutAt: timestamp("optOutAt", {
69
+ mode: "date",
70
+ fsp: 3
71
+ }),
72
+ updatedAt: timestamp("updatedAt", {
73
+ mode: "date",
74
+ fsp: 3
75
+ }).defaultNow(),
76
+ deletedAt: timestamp("deletedAt", {
77
+ mode: "date",
78
+ fsp: 3
79
+ })
80
+ }, (cp) => ({
81
+ userIdIdx: index("userId_idx").on(cp.userId),
82
+ preferenceTypeIdx: index("preferenceTypeId_idx").on(cp.preferenceTypeId),
83
+ channelIdIdx: index("channelId_idx").on(cp.channelId)
84
+ }));
85
+ }
86
+ __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
87
+ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
88
+ const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
89
+ const users = getUsersSchema(mysqlTable);
90
+ const communicationChannel = getCommunicationChannelSchema(mysqlTable);
91
+ const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
92
+ return relations(communicationPreferences, ({ one }) => ({
93
+ user: one(users, {
94
+ fields: [
95
+ communicationPreferences.userId
96
+ ],
97
+ references: [
98
+ users.id
99
+ ],
100
+ relationName: "user"
101
+ }),
102
+ channel: one(communicationChannel, {
103
+ fields: [
104
+ communicationPreferences.channelId
105
+ ],
106
+ references: [
107
+ communicationChannel.id
108
+ ],
109
+ relationName: "channel"
110
+ }),
111
+ preferenceType: one(communicationPreferenceTypes, {
112
+ fields: [
113
+ communicationPreferences.preferenceTypeId
114
+ ],
115
+ references: [
116
+ communicationPreferenceTypes.id
117
+ ],
118
+ relationName: "preferenceType"
119
+ })
120
+ }));
121
+ }
122
+ __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
18
123
 
19
124
  // src/lib/mysql/schemas/content/content-contributions.ts
20
125
  import { relations as relations4 } from "drizzle-orm";
21
126
  import { boolean as boolean2, index as index4, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
22
127
 
23
128
  // src/lib/mysql/schemas/content/content-resource.ts
24
- import { relations as relations2, sql as sql2 } from "drizzle-orm";
25
- import { index as index2, json as json2, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
129
+ import { relations as relations3, sql as sql2 } from "drizzle-orm";
130
+ import { index as index3, json as json2, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
26
131
 
27
132
  // src/lib/mysql/schemas/content/content-resource-resource.ts
28
- import { relations, sql } from "drizzle-orm";
29
- import { double, index, json, primaryKey, timestamp, varchar } from "drizzle-orm/mysql-core";
133
+ import { relations as relations2, sql } from "drizzle-orm";
134
+ import { double, index as index2, json, primaryKey, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
30
135
  function getContentResourceResourceSchema(mysqlTable) {
31
136
  return mysqlTable("contentResourceResource", {
32
- resourceOfId: varchar("resourceOfId", {
137
+ resourceOfId: varchar2("resourceOfId", {
33
138
  length: 255
34
139
  }).notNull(),
35
- resourceId: varchar("resourceId", {
140
+ resourceId: varchar2("resourceId", {
36
141
  length: 255
37
142
  }).notNull(),
38
143
  position: double("position").notNull().default(0),
39
- metadata: json("fields").$type().default({}),
40
- createdAt: timestamp("createdAt", {
144
+ metadata: json("metadata").$type().default({}),
145
+ createdAt: timestamp2("createdAt", {
41
146
  mode: "date",
42
147
  fsp: 3
43
148
  }).default(sql`CURRENT_TIMESTAMP(3)`),
44
- updatedAt: timestamp("updatedAt", {
149
+ updatedAt: timestamp2("updatedAt", {
45
150
  mode: "date",
46
151
  fsp: 3
47
152
  }).default(sql`CURRENT_TIMESTAMP(3)`),
48
- deletedAt: timestamp("deletedAt", {
153
+ deletedAt: timestamp2("deletedAt", {
49
154
  mode: "date",
50
155
  fsp: 3
51
156
  })
@@ -56,15 +161,15 @@ function getContentResourceResourceSchema(mysqlTable) {
56
161
  crr.resourceId
57
162
  ]
58
163
  }),
59
- contentResourceIdIdx: index("contentResourceId_idx").on(crr.resourceOfId),
60
- resourceIdIdx: index("resourceId_idx").on(crr.resourceId)
164
+ contentResourceIdIdx: index2("contentResourceId_idx").on(crr.resourceOfId),
165
+ resourceIdIdx: index2("resourceId_idx").on(crr.resourceId)
61
166
  }));
62
167
  }
63
168
  __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
64
169
  function getContentResourceResourceRelationsSchema(mysqlTable) {
65
170
  const contentResource = getContentResourceSchema(mysqlTable);
66
171
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
67
- return relations(contentResourceResource, ({ one }) => ({
172
+ return relations2(contentResourceResource, ({ one }) => ({
68
173
  resourceOf: one(contentResource, {
69
174
  fields: [
70
175
  contentResourceResource.resourceOfId
@@ -90,50 +195,49 @@ __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRel
90
195
  // src/lib/mysql/schemas/content/content-resource.ts
91
196
  function getContentResourceSchema(mysqlTable) {
92
197
  return mysqlTable("contentResource", {
93
- id: varchar2("id", {
198
+ id: varchar3("id", {
94
199
  length: 255
95
200
  }).notNull().primaryKey(),
96
- type: varchar2("type", {
201
+ type: varchar3("type", {
97
202
  length: 255
98
203
  }).notNull(),
99
- createdById: varchar2("createdById", {
204
+ createdById: varchar3("createdById", {
100
205
  length: 255
101
206
  }).notNull(),
102
207
  fields: json2("fields").$type().default({}),
103
- createdAt: timestamp2("createdAt", {
208
+ createdAt: timestamp3("createdAt", {
104
209
  mode: "date",
105
210
  fsp: 3
106
211
  }).default(sql2`CURRENT_TIMESTAMP(3)`),
107
- updatedAt: timestamp2("updatedAt", {
212
+ updatedAt: timestamp3("updatedAt", {
108
213
  mode: "date",
109
214
  fsp: 3
110
215
  }).default(sql2`CURRENT_TIMESTAMP(3)`),
111
- deletedAt: timestamp2("deletedAt", {
216
+ deletedAt: timestamp3("deletedAt", {
112
217
  mode: "date",
113
218
  fsp: 3
114
219
  })
115
220
  }, (cm) => ({
116
- typeIdx: index2("type_idx").on(cm.type),
117
- createdByIdx: index2("createdById_idx").on(cm.createdById),
118
- createdAtIdx: index2("createdAt_idx").on(cm.createdAt)
221
+ typeIdx: index3("type_idx").on(cm.type),
222
+ createdByIdx: index3("createdById_idx").on(cm.createdById),
223
+ createdAtIdx: index3("createdAt_idx").on(cm.createdAt)
119
224
  }));
120
225
  }
121
226
  __name(getContentResourceSchema, "getContentResourceSchema");
122
227
  function getContentResourceRelationsSchema(mysqlTable) {
123
228
  const contentResource = getContentResourceSchema(mysqlTable);
124
229
  const users = getUsersSchema(mysqlTable);
125
- const contentContributions = getContentContributionsSchema(mysqlTable);
126
230
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
127
- return relations2(contentResource, ({ one, many }) => ({
231
+ return relations3(contentResource, ({ one, many }) => ({
128
232
  createdBy: one(users, {
129
233
  fields: [
130
234
  contentResource.createdById
131
235
  ],
132
236
  references: [
133
237
  users.id
134
- ]
238
+ ],
239
+ relationName: "user"
135
240
  }),
136
- contributions: many(contentContributions),
137
241
  resources: many(contentResourceResource, {
138
242
  relationName: "resourceOf"
139
243
  }),
@@ -144,49 +248,6 @@ function getContentResourceRelationsSchema(mysqlTable) {
144
248
  }
145
249
  __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
146
250
 
147
- // src/lib/mysql/schemas/content/contribution-types.ts
148
- import { relations as relations3 } from "drizzle-orm";
149
- import { boolean, index as index3, text, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
150
- function getContributionTypesSchema(mysqlTable) {
151
- return mysqlTable("contributionType", {
152
- id: varchar3("id", {
153
- length: 255
154
- }).notNull().primaryKey(),
155
- slug: varchar3("slug", {
156
- length: 255
157
- }).notNull().unique(),
158
- name: varchar3("name", {
159
- length: 255
160
- }).notNull(),
161
- description: text("description"),
162
- active: boolean("active").notNull().default(true),
163
- createdAt: timestamp3("createdAt", {
164
- mode: "date",
165
- fsp: 3
166
- }).defaultNow(),
167
- updatedAt: timestamp3("updatedAt", {
168
- mode: "date",
169
- fsp: 3
170
- }).defaultNow(),
171
- deletedAt: timestamp3("deletedAt", {
172
- mode: "date",
173
- fsp: 3
174
- })
175
- }, (ct) => ({
176
- nameIdx: index3("name_idx").on(ct.name),
177
- slugIdx: index3("slug_idx").on(ct.slug)
178
- }));
179
- }
180
- __name(getContributionTypesSchema, "getContributionTypesSchema");
181
- function getContributionTypesRelationsSchema(mysqlTable) {
182
- const contributionTypes = getContributionTypesSchema(mysqlTable);
183
- const contentContributions = getContentContributionsSchema(mysqlTable);
184
- return relations3(contributionTypes, ({ many }) => ({
185
- contributions: many(contentContributions)
186
- }));
187
- }
188
- __name(getContributionTypesRelationsSchema, "getContributionTypesRelationsSchema");
189
-
190
251
  // src/lib/mysql/schemas/content/content-contributions.ts
191
252
  function getContentContributionsSchema(mysqlTable) {
192
253
  return mysqlTable("contentContribution", {
@@ -234,7 +295,8 @@ function getContentContributionRelationsSchema(mysqlTable) {
234
295
  ],
235
296
  references: [
236
297
  users.id
237
- ]
298
+ ],
299
+ relationName: "user"
238
300
  }),
239
301
  content: one(contentResource, {
240
302
  fields: [
@@ -242,7 +304,8 @@ function getContentContributionRelationsSchema(mysqlTable) {
242
304
  ],
243
305
  references: [
244
306
  contentResource.id
245
- ]
307
+ ],
308
+ relationName: "contributions"
246
309
  }),
247
310
  contributionType: one(contributionTypes, {
248
311
  fields: [
@@ -250,7 +313,8 @@ function getContentContributionRelationsSchema(mysqlTable) {
250
313
  ],
251
314
  references: [
252
315
  contributionTypes.id
253
- ]
316
+ ],
317
+ relationName: "contributionType"
254
318
  })
255
319
  }));
256
320
  }
@@ -258,7 +322,7 @@ __name(getContentContributionRelationsSchema, "getContentContributionRelationsSc
258
322
 
259
323
  // src/lib/mysql/schemas/auth/accounts.ts
260
324
  import { relations as relations5 } from "drizzle-orm";
261
- import { index as index5, int, primaryKey as primaryKey2, text as text2, varchar as varchar5 } from "drizzle-orm/mysql-core";
325
+ import { index as index5, int, primaryKey as primaryKey2, text, varchar as varchar5 } from "drizzle-orm/mysql-core";
262
326
  function getAccountsSchema(mysqlTable) {
263
327
  return mysqlTable("account", {
264
328
  userId: varchar5("userId", {
@@ -273,10 +337,10 @@ function getAccountsSchema(mysqlTable) {
273
337
  providerAccountId: varchar5("providerAccountId", {
274
338
  length: 255
275
339
  }).notNull(),
276
- refresh_token: text2("refresh_token"),
277
- access_token: text2("access_token"),
278
- oauth_token: text2("oauth_token"),
279
- oauth_token_secret: text2("oauth_token_secret"),
340
+ refresh_token: text("refresh_token"),
341
+ access_token: text("access_token"),
342
+ oauth_token: text("oauth_token"),
343
+ oauth_token_secret: text("oauth_token_secret"),
280
344
  expires_at: int("expires_at"),
281
345
  token_type: varchar5("token_type", {
282
346
  length: 255
@@ -284,7 +348,7 @@ function getAccountsSchema(mysqlTable) {
284
348
  scope: varchar5("scope", {
285
349
  length: 255
286
350
  }),
287
- id_token: text2("id_token"),
351
+ id_token: text("id_token"),
288
352
  session_state: varchar5("session_state", {
289
353
  length: 255
290
354
  }),
@@ -310,37 +374,22 @@ function getAccountsRelationsSchema(mysqlTable) {
310
374
  ],
311
375
  references: [
312
376
  users.id
313
- ]
377
+ ],
378
+ relationName: "user"
314
379
  })
315
380
  }));
316
381
  }
317
382
  __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
318
383
 
319
384
  // src/lib/mysql/schemas/auth/user-permissions.ts
320
- import { relations as relations10 } from "drizzle-orm";
321
- import { boolean as boolean7, index as index10, primaryKey as primaryKey5, timestamp as timestamp9, varchar as varchar10 } from "drizzle-orm/mysql-core";
322
-
323
- // src/lib/mysql/schemas/auth/permissions.ts
324
- import { relations as relations9 } from "drizzle-orm";
325
- import { boolean as boolean6, index as index9, text as text4, timestamp as timestamp8, varchar as varchar9 } from "drizzle-orm/mysql-core";
326
-
327
- // src/lib/mysql/schemas/auth/role-permissions.ts
328
- import { relations as relations8 } from "drizzle-orm";
329
- import { boolean as boolean5, index as index8, primaryKey as primaryKey4, timestamp as timestamp7, varchar as varchar8 } from "drizzle-orm/mysql-core";
330
-
331
- // src/lib/mysql/schemas/auth/roles.ts
332
- import { relations as relations7 } from "drizzle-orm";
333
- import { boolean as boolean4, index as index7, text as text3, timestamp as timestamp6, varchar as varchar7 } from "drizzle-orm/mysql-core";
334
-
335
- // src/lib/mysql/schemas/auth/user-roles.ts
336
385
  import { relations as relations6 } from "drizzle-orm";
337
386
  import { boolean as boolean3, index as index6, primaryKey as primaryKey3, timestamp as timestamp5, varchar as varchar6 } from "drizzle-orm/mysql-core";
338
- function getUserRolesSchema(mysqlTable) {
339
- return mysqlTable("userRole", {
387
+ function getUserPermissionsSchema(mysqlTable) {
388
+ return mysqlTable("userPermission", {
340
389
  userId: varchar6("userId", {
341
390
  length: 255
342
391
  }).notNull(),
343
- roleId: varchar6("roleId", {
392
+ permissionId: varchar6("permissionId", {
344
393
  length: 255
345
394
  }).notNull(),
346
395
  active: boolean3("active").notNull().default(true),
@@ -356,44 +405,52 @@ function getUserRolesSchema(mysqlTable) {
356
405
  mode: "date",
357
406
  fsp: 3
358
407
  })
359
- }, (ur) => ({
408
+ }, (up) => ({
360
409
  pk: primaryKey3({
361
410
  columns: [
362
- ur.userId,
363
- ur.roleId
411
+ up.userId,
412
+ up.permissionId
364
413
  ]
365
414
  }),
366
- userIdIdx: index6("userId_idx").on(ur.userId),
367
- roleIdIdx: index6("roleId_idx").on(ur.roleId)
415
+ userIdIdx: index6("userId_idx").on(up.userId),
416
+ permissionIdIdx: index6("permissionId_idx").on(up.permissionId)
368
417
  }));
369
418
  }
370
- __name(getUserRolesSchema, "getUserRolesSchema");
371
- function getUserRolesRelationsSchema(mysqlTable) {
372
- const userRoles = getUserRolesSchema(mysqlTable);
419
+ __name(getUserPermissionsSchema, "getUserPermissionsSchema");
420
+ function getUserPermissionsRelationsSchema(mysqlTable) {
421
+ const userPermissions = getUserPermissionsSchema(mysqlTable);
373
422
  const users = getUsersSchema(mysqlTable);
374
- const roles = getRolesSchema(mysqlTable);
375
- return relations6(userRoles, ({ one }) => ({
423
+ const permissions = getPermissionsSchema(mysqlTable);
424
+ return relations6(userPermissions, ({ one }) => ({
376
425
  user: one(users, {
377
426
  fields: [
378
- userRoles.userId
427
+ userPermissions.userId
379
428
  ],
380
429
  references: [
381
430
  users.id
382
- ]
431
+ ],
432
+ relationName: "user"
383
433
  }),
384
- role: one(roles, {
434
+ permission: one(permissions, {
385
435
  fields: [
386
- userRoles.roleId
436
+ userPermissions.permissionId
387
437
  ],
388
438
  references: [
389
- roles.id
390
- ]
439
+ permissions.id
440
+ ],
441
+ relationName: "permission"
391
442
  })
392
443
  }));
393
444
  }
394
- __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
445
+ __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
446
+
447
+ // src/lib/mysql/schemas/auth/user-roles.ts
448
+ import { relations as relations8 } from "drizzle-orm";
449
+ import { boolean as boolean5, index as index8, primaryKey as primaryKey4, timestamp as timestamp7, varchar as varchar8 } from "drizzle-orm/mysql-core";
395
450
 
396
451
  // src/lib/mysql/schemas/auth/roles.ts
452
+ import { relations as relations7 } from "drizzle-orm";
453
+ import { boolean as boolean4, index as index7, text as text2, timestamp as timestamp6, varchar as varchar7 } from "drizzle-orm/mysql-core";
397
454
  function getRolesSchema(mysqlTable) {
398
455
  return mysqlTable("role", {
399
456
  id: varchar7("id", {
@@ -402,7 +459,7 @@ function getRolesSchema(mysqlTable) {
402
459
  name: varchar7("name", {
403
460
  length: 255
404
461
  }).notNull().unique(),
405
- description: text3("description"),
462
+ description: text2("description"),
406
463
  active: boolean4("active").notNull().default(true),
407
464
  createdAt: timestamp6("createdAt", {
408
465
  mode: "date",
@@ -425,18 +482,20 @@ function getRolesRelationsSchema(mysqlTable) {
425
482
  const roles = getRolesSchema(mysqlTable);
426
483
  const userRoles = getUserRolesSchema(mysqlTable);
427
484
  return relations7(roles, ({ many }) => ({
428
- userRoles: many(userRoles)
485
+ userRoles: many(userRoles, {
486
+ relationName: "role"
487
+ })
429
488
  }));
430
489
  }
431
490
  __name(getRolesRelationsSchema, "getRolesRelationsSchema");
432
491
 
433
- // src/lib/mysql/schemas/auth/role-permissions.ts
434
- function getRolePermissionsSchema(mysqlTable) {
435
- return mysqlTable("rolePermission", {
436
- roleId: varchar8("roleId", {
492
+ // src/lib/mysql/schemas/auth/user-roles.ts
493
+ function getUserRolesSchema(mysqlTable) {
494
+ return mysqlTable("userRole", {
495
+ userId: varchar8("userId", {
437
496
  length: 255
438
497
  }).notNull(),
439
- permissionId: varchar8("permissionId", {
498
+ roleId: varchar8("roleId", {
440
499
  length: 255
441
500
  }).notNull(),
442
501
  active: boolean5("active").notNull().default(true),
@@ -452,168 +511,76 @@ function getRolePermissionsSchema(mysqlTable) {
452
511
  mode: "date",
453
512
  fsp: 3
454
513
  })
455
- }, (rp) => ({
514
+ }, (ur) => ({
456
515
  pk: primaryKey4({
457
516
  columns: [
458
- rp.roleId,
459
- rp.permissionId
460
- ]
461
- }),
462
- roleIdIdx: index8("roleId_idx").on(rp.roleId),
463
- permissionIdIdx: index8("permissionId_idx").on(rp.permissionId)
464
- }));
465
- }
466
- __name(getRolePermissionsSchema, "getRolePermissionsSchema");
467
- function getRolePermissionsRelationsSchema(mysqlTable) {
468
- const permissions = getPermissionsSchema(mysqlTable);
469
- const roles = getRolesSchema(mysqlTable);
470
- const rolePermissions = getRolePermissionsSchema(mysqlTable);
471
- return relations8(rolePermissions, ({ one }) => ({
472
- role: one(roles, {
473
- fields: [
474
- rolePermissions.roleId
475
- ],
476
- references: [
477
- roles.id
478
- ]
479
- }),
480
- permission: one(permissions, {
481
- fields: [
482
- rolePermissions.permissionId
483
- ],
484
- references: [
485
- permissions.id
486
- ]
487
- })
488
- }));
489
- }
490
- __name(getRolePermissionsRelationsSchema, "getRolePermissionsRelationsSchema");
491
-
492
- // src/lib/mysql/schemas/auth/permissions.ts
493
- function getPermissionsSchema(mysqlTable) {
494
- return mysqlTable("permission", {
495
- id: varchar9("id", {
496
- length: 255
497
- }).notNull().primaryKey(),
498
- name: varchar9("name", {
499
- length: 255
500
- }).notNull().unique(),
501
- description: text4("description"),
502
- active: boolean6("active").notNull().default(true),
503
- createdAt: timestamp8("createdAt", {
504
- mode: "date",
505
- fsp: 3
506
- }).defaultNow(),
507
- updatedAt: timestamp8("updatedAt", {
508
- mode: "date",
509
- fsp: 3
510
- }).defaultNow(),
511
- deletedAt: timestamp8("deletedAt", {
512
- mode: "date",
513
- fsp: 3
514
- })
515
- }, (permission) => ({
516
- nameIdx: index9("name_idx").on(permission.name)
517
- }));
518
- }
519
- __name(getPermissionsSchema, "getPermissionsSchema");
520
- function getPermissionsRelationsSchema(mysqlTable) {
521
- return relations9(getPermissionsSchema(mysqlTable), ({ many }) => ({
522
- rolePermissions: many(getRolePermissionsSchema(mysqlTable))
523
- }));
524
- }
525
- __name(getPermissionsRelationsSchema, "getPermissionsRelationsSchema");
526
-
527
- // src/lib/mysql/schemas/auth/user-permissions.ts
528
- function getUserPermissionsSchema(mysqlTable) {
529
- return mysqlTable("userPermission", {
530
- userId: varchar10("userId", {
531
- length: 255
532
- }).notNull(),
533
- permissionId: varchar10("permissionId", {
534
- length: 255
535
- }).notNull(),
536
- active: boolean7("active").notNull().default(true),
537
- createdAt: timestamp9("createdAt", {
538
- mode: "date",
539
- fsp: 3
540
- }).defaultNow(),
541
- updatedAt: timestamp9("updatedAt", {
542
- mode: "date",
543
- fsp: 3
544
- }).defaultNow(),
545
- deletedAt: timestamp9("deletedAt", {
546
- mode: "date",
547
- fsp: 3
548
- })
549
- }, (up) => ({
550
- pk: primaryKey5({
551
- columns: [
552
- up.userId,
553
- up.permissionId
517
+ ur.userId,
518
+ ur.roleId
554
519
  ]
555
520
  }),
556
- userIdIdx: index10("userId_idx").on(up.userId),
557
- permissionIdIdx: index10("permissionId_idx").on(up.permissionId)
521
+ userIdIdx: index8("userId_idx").on(ur.userId),
522
+ roleIdIdx: index8("roleId_idx").on(ur.roleId)
558
523
  }));
559
524
  }
560
- __name(getUserPermissionsSchema, "getUserPermissionsSchema");
561
- function getUserPermissionsRelationsSchema(mysqlTable) {
562
- const userPermissions = getUserPermissionsSchema(mysqlTable);
525
+ __name(getUserRolesSchema, "getUserRolesSchema");
526
+ function getUserRolesRelationsSchema(mysqlTable) {
527
+ const userRoles = getUserRolesSchema(mysqlTable);
563
528
  const users = getUsersSchema(mysqlTable);
564
- const permissions = getPermissionsSchema(mysqlTable);
565
- return relations10(userPermissions, ({ one }) => ({
529
+ const roles = getRolesSchema(mysqlTable);
530
+ return relations8(userRoles, ({ one }) => ({
566
531
  user: one(users, {
567
532
  fields: [
568
- userPermissions.userId
533
+ userRoles.userId
569
534
  ],
570
535
  references: [
571
536
  users.id
572
- ]
537
+ ],
538
+ relationName: "role"
573
539
  }),
574
- permission: one(permissions, {
540
+ role: one(roles, {
575
541
  fields: [
576
- userPermissions.permissionId
542
+ userRoles.roleId
577
543
  ],
578
544
  references: [
579
- permissions.id
580
- ]
545
+ roles.id
546
+ ],
547
+ relationName: "user"
581
548
  })
582
549
  }));
583
550
  }
584
- __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
551
+ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
585
552
 
586
553
  // src/lib/mysql/schemas/auth/users.ts
587
554
  function getUsersSchema(mysqlTable) {
588
555
  return mysqlTable("user", {
589
- id: varchar11("id", {
556
+ id: varchar9("id", {
590
557
  length: 255
591
558
  }).notNull().primaryKey(),
592
- name: varchar11("name", {
559
+ name: varchar9("name", {
593
560
  length: 255
594
561
  }),
595
- role: mysqlEnum("role", [
562
+ role: mysqlEnum2("role", [
596
563
  "user",
597
564
  "admin"
598
565
  ]).default("user"),
599
- email: varchar11("email", {
566
+ email: varchar9("email", {
600
567
  length: 255
601
568
  }).notNull().unique(),
602
- emailVerified: timestamp10("emailVerified", {
569
+ emailVerified: timestamp8("emailVerified", {
603
570
  mode: "date",
604
571
  fsp: 3
605
572
  }),
606
- image: varchar11("image", {
573
+ image: varchar9("image", {
607
574
  length: 255
608
575
  }),
609
- createdAt: timestamp10("createdAt", {
576
+ createdAt: timestamp8("createdAt", {
610
577
  mode: "date",
611
578
  fsp: 3
612
579
  }).default(sql3`CURRENT_TIMESTAMP(3)`)
613
580
  }, (user) => ({
614
- emailIdx: index11("email_idx").on(user.email),
615
- roleIdx: index11("role_idx").on(user.role),
616
- createdAtIdx: index11("created_at_idx").on(user.createdAt)
581
+ emailIdx: index9("email_idx").on(user.email),
582
+ roleIdx: index9("role_idx").on(user.role),
583
+ createdAtIdx: index9("created_at_idx").on(user.createdAt)
617
584
  }));
618
585
  }
619
586
  __name(getUsersSchema, "getUsersSchema");
@@ -625,123 +592,177 @@ function getUsersRelationsSchema(mysqlTable) {
625
592
  const userPermissions = getUserPermissionsSchema(mysqlTable);
626
593
  const contentContributions = getContentContributionsSchema(mysqlTable);
627
594
  const contentResource = getContentResourceSchema(mysqlTable);
628
- return relations11(users, ({ many }) => ({
629
- accounts: many(accounts),
630
- communicationPreferences: many(communicationPreferences),
631
- userRoles: many(userRoles),
632
- userPermissions: many(userPermissions),
633
- contributions: many(contentContributions),
634
- createdContent: many(contentResource)
595
+ const purchases = getPurchaseSchema(mysqlTable);
596
+ return relations9(users, ({ many }) => ({
597
+ accounts: many(accounts, {
598
+ relationName: "user"
599
+ }),
600
+ purchases: many(purchases, {
601
+ relationName: "user"
602
+ }),
603
+ communicationPreferences: many(communicationPreferences, {
604
+ relationName: "user"
605
+ }),
606
+ roles: many(userRoles, {
607
+ relationName: "user"
608
+ }),
609
+ userPermissions: many(userPermissions, {
610
+ relationName: "user"
611
+ }),
612
+ contributions: many(contentContributions, {
613
+ relationName: "user"
614
+ }),
615
+ createdContent: many(contentResource, {
616
+ relationName: "user"
617
+ })
635
618
  }));
636
619
  }
637
620
  __name(getUsersRelationsSchema, "getUsersRelationsSchema");
638
621
 
639
- // src/lib/mysql/schemas/communication/communication-preferences.ts
640
- function getCommunicationPreferencesSchema(mysqlTable) {
641
- return mysqlTable("communicationPreference", {
642
- id: varchar12("id", {
643
- length: 255
644
- }).notNull().primaryKey(),
645
- userId: varchar12("userId", {
646
- length: 255
622
+ // src/lib/mysql/schemas/commerce/purchase.ts
623
+ function getPurchaseSchema(mysqlTable) {
624
+ return mysqlTable("purchases", {
625
+ id: varchar10("id", {
626
+ length: 191
647
627
  }).notNull(),
648
- channelId: varchar12("channelId", {
649
- length: 255
650
- }).notNull(),
651
- preferenceLevel: mysqlEnum2("preferenceLevel", [
652
- "low",
653
- "medium",
654
- "high"
655
- ]).notNull().default("medium"),
656
- preferenceTypeId: varchar12("preferenceTypeId", {
657
- length: 255
658
- }).notNull(),
659
- active: boolean8("active").notNull().default(true),
660
- createdAt: timestamp11("createdAt", {
661
- mode: "date",
662
- fsp: 3
663
- }).defaultNow(),
664
- optInAt: timestamp11("optInAt", {
665
- mode: "date",
666
- fsp: 3
628
+ userId: varchar10("userId", {
629
+ length: 191
667
630
  }),
668
- optOutAt: timestamp11("optOutAt", {
631
+ createdAt: timestamp9("createdAt", {
669
632
  mode: "date",
670
633
  fsp: 3
634
+ }).default(sql4`CURRENT_TIMESTAMP(3)`).notNull(),
635
+ totalAmount: decimal("totalAmount", {
636
+ precision: 65,
637
+ scale: 30
638
+ }).notNull(),
639
+ ipAddress: varchar10("ip_address", {
640
+ length: 191
671
641
  }),
672
- updatedAt: timestamp11("updatedAt", {
673
- mode: "date",
674
- fsp: 3
675
- }).defaultNow(),
676
- deletedAt: timestamp11("deletedAt", {
677
- mode: "date",
678
- fsp: 3
679
- })
680
- }, (cp) => ({
681
- userIdIdx: index12("userId_idx").on(cp.userId),
682
- preferenceTypeIdx: index12("preferenceTypeId_idx").on(cp.preferenceTypeId),
683
- channelIdIdx: index12("channelId_idx").on(cp.channelId)
684
- }));
642
+ city: varchar10("city", {
643
+ length: 191
644
+ }),
645
+ state: varchar10("state", {
646
+ length: 191
647
+ }),
648
+ country: varchar10("country", {
649
+ length: 191
650
+ }),
651
+ couponId: varchar10("couponId", {
652
+ length: 191
653
+ }),
654
+ productId: varchar10("productId", {
655
+ length: 191
656
+ }).notNull(),
657
+ merchantChargeId: varchar10("merchantChargeId", {
658
+ length: 191
659
+ }),
660
+ upgradedFromId: varchar10("upgradedFromId", {
661
+ length: 191
662
+ }),
663
+ status: varchar10("status", {
664
+ length: 191
665
+ }).default("Valid").notNull(),
666
+ bulkCouponId: varchar10("bulkCouponId", {
667
+ length: 191
668
+ }),
669
+ merchantSessionId: varchar10("merchantSessionId", {
670
+ length: 191
671
+ }),
672
+ redeemedBulkCouponId: varchar10("redeemedBulkCouponId", {
673
+ length: 191
674
+ }),
675
+ metadata: json3("fields").$type().default({})
676
+ }, (table) => {
677
+ return {
678
+ purchaseId: primaryKey5({
679
+ columns: [
680
+ table.id
681
+ ],
682
+ name: "Purchase_id"
683
+ }),
684
+ purchaseUpgradedFromIdKey: unique("Purchase_upgradedFromId_key").on(table.upgradedFromId)
685
+ };
686
+ });
685
687
  }
686
- __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
687
- function getCommunicationPreferencesRelationsSchema(mysqlTable) {
688
- const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
688
+ __name(getPurchaseSchema, "getPurchaseSchema");
689
+ function getPurchaseRelationsSchema(mysqlTable) {
690
+ const purchases = getPurchaseSchema(mysqlTable);
689
691
  const users = getUsersSchema(mysqlTable);
690
- const communicationChannel = getCommunicationChannelSchema(mysqlTable);
691
- const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
692
- return relations12(communicationPreferences, ({ one }) => ({
692
+ const products = getProductSchema(mysqlTable);
693
+ const merchantCharges = getMerchantChargeSchema(mysqlTable);
694
+ const merchantSessions = getMerchantSessionSchema(mysqlTable);
695
+ const coupons = getCouponSchema(mysqlTable);
696
+ return relations10(purchases, ({ many, one }) => ({
693
697
  user: one(users, {
694
698
  fields: [
695
- communicationPreferences.userId
699
+ purchases.userId
696
700
  ],
697
701
  references: [
698
702
  users.id
699
- ]
703
+ ],
704
+ relationName: "user"
700
705
  }),
701
- channel: one(communicationChannel, {
706
+ product: one(products, {
702
707
  fields: [
703
- communicationPreferences.channelId
708
+ purchases.productId
704
709
  ],
705
710
  references: [
706
- communicationChannel.id
707
- ]
711
+ products.id
712
+ ],
713
+ relationName: "product"
708
714
  }),
709
- preferenceType: one(communicationPreferenceTypes, {
715
+ bulkCoupon: one(coupons, {
710
716
  fields: [
711
- communicationPreferences.preferenceTypeId
717
+ purchases.bulkCouponId
712
718
  ],
713
719
  references: [
714
- communicationPreferenceTypes.id
715
- ]
720
+ coupons.id
721
+ ],
722
+ relationName: "bulkCoupon"
723
+ }),
724
+ merchantCharge: one(merchantCharges, {
725
+ fields: [
726
+ purchases.merchantChargeId
727
+ ],
728
+ references: [
729
+ merchantCharges.id
730
+ ],
731
+ relationName: "merchantCharge"
732
+ }),
733
+ merchantSession: one(merchantSessions, {
734
+ fields: [
735
+ purchases.merchantSessionId
736
+ ],
737
+ references: [
738
+ merchantSessions.id
739
+ ],
740
+ relationName: "merchantSession"
716
741
  })
717
742
  }));
718
743
  }
719
- __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
744
+ __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
720
745
 
721
746
  export {
747
+ getPurchaseSchema,
748
+ getPurchaseRelationsSchema,
722
749
  getCommunicationPreferencesSchema,
723
750
  getCommunicationPreferencesRelationsSchema,
724
751
  getContentResourceResourceSchema,
725
752
  getContentResourceResourceRelationsSchema,
726
753
  getContentResourceSchema,
727
754
  getContentResourceRelationsSchema,
728
- getContributionTypesSchema,
729
- getContributionTypesRelationsSchema,
730
755
  getContentContributionsSchema,
731
756
  getContentContributionRelationsSchema,
732
- getUserRolesSchema,
733
- getUserRolesRelationsSchema,
734
- getRolesSchema,
735
- getRolesRelationsSchema,
736
- getRolePermissionsSchema,
737
- getRolePermissionsRelationsSchema,
738
- getPermissionsSchema,
739
- getPermissionsRelationsSchema,
740
757
  getUserPermissionsSchema,
741
758
  getUserPermissionsRelationsSchema,
759
+ getRolesSchema,
760
+ getRolesRelationsSchema,
761
+ getUserRolesSchema,
762
+ getUserRolesRelationsSchema,
742
763
  getUsersSchema,
743
764
  getUsersRelationsSchema,
744
765
  getAccountsSchema,
745
766
  getAccountsRelationsSchema
746
767
  };
747
- //# sourceMappingURL=chunk-4HDU7QIB.js.map
768
+ //# sourceMappingURL=chunk-ISURSRBK.js.map