@coursebuilder/adapter-drizzle 0.1.2 → 0.1.4

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 (173) hide show
  1. package/dist/{chunk-QZOBGJSV.js → chunk-2CI3IGR2.js} +4 -4
  2. package/dist/{chunk-ISURSRBK.js → chunk-3RJVKNXB.js} +425 -142
  3. package/dist/{chunk-RVYJDDZD.js → chunk-53266VWH.js} +3 -3
  4. package/dist/{chunk-OIUOQ3TT.js → chunk-57CX5SOI.js} +2 -2
  5. package/dist/{chunk-75V6F7LZ.js → chunk-5HT43CVZ.js} +2 -2
  6. package/dist/{chunk-SFJM6FKE.js → chunk-BX5SO2JG.js} +2 -2
  7. package/dist/{chunk-LSOPFMDB.js → chunk-FNYW3XKR.js} +3 -3
  8. package/dist/{chunk-V6QEDDFG.js → chunk-GLPDG7UE.js} +2 -2
  9. package/dist/{chunk-VNI36MMC.js → chunk-H736K5TN.js} +1 -1
  10. package/dist/{chunk-6CBAFOL3.js → chunk-J4LBG2TH.js} +2 -2
  11. package/dist/{chunk-JD4KFACE.js → chunk-JKOYOL7A.js} +2 -2
  12. package/dist/{chunk-TMQIGK3N.js → chunk-MBB4GIJI.js} +2 -2
  13. package/dist/{chunk-27KREOQW.js → chunk-PJHGIRZM.js} +2 -2
  14. package/dist/{chunk-L2TQQYG4.js → chunk-PPBEA4EM.js} +2 -2
  15. package/dist/{chunk-MYRB6GLJ.js → chunk-Q5WENQT6.js} +3 -3
  16. package/dist/{chunk-H4MXNDWO.js → chunk-V23SCQL7.js} +2 -2
  17. package/dist/{chunk-NZDLUQWP.js → chunk-VDVCCU7D.js} +2 -2
  18. package/dist/{chunk-IN6G6MTW.js → chunk-VXZRMVNY.js} +2 -2
  19. package/dist/chunk-WQ7UXKZC.js +9293 -0
  20. package/dist/{chunk-JKRFXYAR.js → chunk-Y7QZGEPT.js} +2 -2
  21. package/dist/index.d.ts +0 -2
  22. package/dist/index.js +20 -37
  23. package/dist/lib/mysql/index.cjs +1775 -1155
  24. package/dist/lib/mysql/index.cjs.map +1 -1
  25. package/dist/lib/mysql/index.d.cts +6143 -0
  26. package/dist/lib/mysql/index.d.ts +253 -19
  27. package/dist/lib/mysql/index.js +20 -24
  28. package/dist/lib/mysql/schemas/auth/accounts.cjs +73 -57
  29. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  30. package/dist/lib/mysql/schemas/auth/accounts.d.cts +184 -0
  31. package/dist/lib/mysql/schemas/auth/accounts.js +10 -10
  32. package/dist/lib/mysql/schemas/auth/permissions.d.cts +98 -0
  33. package/dist/lib/mysql/schemas/auth/permissions.js +2 -2
  34. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +64 -48
  35. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  36. package/dist/lib/mysql/schemas/auth/role-permissions.d.cts +89 -0
  37. package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -11
  38. package/dist/lib/mysql/schemas/auth/roles.cjs +64 -48
  39. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/auth/roles.d.cts +100 -0
  41. package/dist/lib/mysql/schemas/auth/roles.js +10 -10
  42. package/dist/lib/mysql/schemas/auth/sessions.cjs +64 -48
  43. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/auth/sessions.d.cts +52 -0
  45. package/dist/lib/mysql/schemas/auth/sessions.js +11 -11
  46. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +65 -49
  47. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +89 -0
  49. package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -10
  50. package/dist/lib/mysql/schemas/auth/user-roles.cjs +67 -51
  51. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  52. package/dist/lib/mysql/schemas/auth/user-roles.d.cts +89 -0
  53. package/dist/lib/mysql/schemas/auth/user-roles.js +10 -10
  54. package/dist/lib/mysql/schemas/auth/users.cjs +170 -154
  55. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  56. package/dist/lib/mysql/schemas/auth/users.d.cts +106 -0
  57. package/dist/lib/mysql/schemas/auth/users.js +10 -10
  58. package/dist/lib/mysql/schemas/auth/verification-tokens.d.cts +60 -0
  59. package/dist/lib/mysql/schemas/auth/verification-tokens.js +2 -2
  60. package/dist/lib/mysql/schemas/commerce/coupon.cjs +180 -17
  61. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  62. package/dist/lib/mysql/schemas/commerce/coupon.d.cts +172 -0
  63. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +10 -6
  64. package/dist/lib/mysql/schemas/commerce/coupon.js +12 -2
  65. package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +72 -0
  66. package/dist/lib/mysql/schemas/commerce/merchant-account.js +2 -2
  67. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +108 -0
  68. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +2 -2
  69. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +84 -0
  70. package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +2 -2
  71. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +84 -0
  72. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +2 -2
  73. package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +96 -0
  74. package/dist/lib/mysql/schemas/commerce/merchant-price.js +2 -2
  75. package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +84 -0
  76. package/dist/lib/mysql/schemas/commerce/merchant-product.js +2 -2
  77. package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +48 -0
  78. package/dist/lib/mysql/schemas/commerce/merchant-session.js +2 -2
  79. package/dist/lib/mysql/schemas/commerce/price.cjs +192 -11
  80. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  81. package/dist/lib/mysql/schemas/commerce/price.d.cts +101 -0
  82. package/dist/lib/mysql/schemas/commerce/price.d.ts +7 -2
  83. package/dist/lib/mysql/schemas/commerce/price.js +14 -4
  84. package/dist/lib/mysql/schemas/commerce/product.cjs +230 -9
  85. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  86. package/dist/lib/mysql/schemas/commerce/product.d.cts +114 -0
  87. package/dist/lib/mysql/schemas/commerce/product.d.ts +20 -2
  88. package/dist/lib/mysql/schemas/commerce/product.js +12 -2
  89. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +132 -0
  90. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +2 -2
  91. package/dist/lib/mysql/schemas/commerce/purchase.cjs +152 -122
  92. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  93. package/dist/lib/mysql/schemas/commerce/purchase.d.cts +225 -0
  94. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +2 -1
  95. package/dist/lib/mysql/schemas/commerce/purchase.js +10 -10
  96. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +110 -24
  97. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  98. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +101 -0
  99. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -3
  100. package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +96 -0
  101. package/dist/lib/mysql/schemas/communication/communication-channel.js +2 -2
  102. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +96 -0
  103. package/dist/lib/mysql/schemas/communication/communication-preference-types.js +2 -2
  104. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +84 -68
  105. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  106. package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +150 -0
  107. package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -10
  108. package/dist/lib/mysql/schemas/content/content-contributions.cjs +92 -76
  109. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  110. package/dist/lib/mysql/schemas/content/content-contributions.d.cts +114 -0
  111. package/dist/lib/mysql/schemas/content/content-contributions.js +10 -10
  112. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +246 -0
  113. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -0
  114. package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +101 -0
  115. package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +101 -0
  116. package/dist/lib/mysql/schemas/content/content-resource-product.js +18 -0
  117. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +67 -51
  118. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  119. package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +101 -0
  120. package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -10
  121. package/dist/lib/mysql/schemas/content/content-resource.cjs +116 -62
  122. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  123. package/dist/lib/mysql/schemas/content/content-resource.d.cts +103 -0
  124. package/dist/lib/mysql/schemas/content/content-resource.d.ts +1 -0
  125. package/dist/lib/mysql/schemas/content/content-resource.js +10 -10
  126. package/dist/lib/mysql/schemas/content/contribution-types.d.cts +110 -0
  127. package/dist/lib/mysql/schemas/content/contribution-types.js +2 -2
  128. package/dist/lib/mysql/schemas/content/resource-progress.cjs +1 -1
  129. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  130. package/dist/lib/mysql/schemas/content/resource-progress.d.cts +84 -0
  131. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +1 -1
  132. package/dist/lib/mysql/schemas/content/resource-progress.js +2 -2
  133. package/dist/lib/mysql/utils.cjs.map +1 -1
  134. package/dist/lib/mysql/utils.d.cts +12 -0
  135. package/dist/lib/mysql/utils.js +1 -1
  136. package/dist/lib/mysql/utils.js.map +1 -1
  137. package/dist/lib/utils.cjs.map +1 -1
  138. package/dist/lib/utils.d.cts +22 -0
  139. package/dist/lib/utils.d.ts +4 -8
  140. package/dist/lib/utils.js +12 -3
  141. package/dist/lib/utils.js.map +1 -1
  142. package/package.json +5 -5
  143. package/src/index.ts +0 -8
  144. package/src/lib/mysql/index.ts +611 -129
  145. package/src/lib/mysql/schemas/auth/user-roles.ts +2 -2
  146. package/src/lib/mysql/schemas/commerce/coupon.ts +20 -4
  147. package/src/lib/mysql/schemas/commerce/price.ts +23 -2
  148. package/src/lib/mysql/schemas/commerce/product.ts +27 -2
  149. package/src/lib/mysql/schemas/commerce/purchase.ts +6 -1
  150. package/src/lib/mysql/schemas/content/content-resource-product.ts +62 -0
  151. package/src/lib/mysql/schemas/content/content-resource.ts +5 -0
  152. package/src/lib/mysql/schemas/content/resource-progress.ts +1 -1
  153. package/src/lib/utils.ts +1 -9
  154. package/dist/chunk-44VDBYFU.js +0 -60
  155. package/dist/chunk-7LAAAEVE.js +0 -379
  156. package/dist/chunk-AFQGYW7Z.js +0 -45
  157. package/dist/chunk-CPE4P26C.js +0 -42
  158. package/dist/chunk-DHYYRN35.js +0 -4679
  159. package/dist/chunk-GFUUJRX7.js +0 -18
  160. package/dist/chunk-O2KKII62.js +0 -381
  161. package/dist/chunk-Y34AIPU7.js +0 -4137
  162. package/dist/lib/pg.cjs +0 -4527
  163. package/dist/lib/pg.cjs.map +0 -1
  164. package/dist/lib/pg.d.ts +0 -496
  165. package/dist/lib/pg.js +0 -11
  166. package/dist/lib/sqlite.cjs +0 -4536
  167. package/dist/lib/sqlite.cjs.map +0 -1
  168. package/dist/lib/sqlite.d.ts +0 -496
  169. package/dist/lib/sqlite.js +0 -12
  170. package/dist/lib/sqlite.js.map +0 -1
  171. package/src/lib/pg.ts +0 -579
  172. package/src/lib/sqlite.ts +0 -562
  173. /package/dist/lib/{pg.js.map → mysql/schemas/content/content-resource-product.js.map} +0 -0
@@ -1,38 +1,42 @@
1
1
  import {
2
2
  getContributionTypesSchema
3
- } from "./chunk-V6QEDDFG.js";
4
- import {
5
- getProductSchema
6
- } from "./chunk-CPE4P26C.js";
3
+ } from "./chunk-GLPDG7UE.js";
7
4
  import {
8
5
  getCommunicationChannelSchema
9
- } from "./chunk-6CBAFOL3.js";
6
+ } from "./chunk-J4LBG2TH.js";
10
7
  import {
11
8
  getCommunicationPreferenceTypesSchema
12
- } from "./chunk-SFJM6FKE.js";
9
+ } from "./chunk-BX5SO2JG.js";
13
10
  import {
14
- getMerchantChargeSchema
15
- } from "./chunk-27KREOQW.js";
11
+ getMerchantPriceSchema
12
+ } from "./chunk-PPBEA4EM.js";
13
+ import {
14
+ getMerchantProductSchema
15
+ } from "./chunk-Y7QZGEPT.js";
16
16
  import {
17
17
  getMerchantSessionSchema
18
- } from "./chunk-H4MXNDWO.js";
18
+ } from "./chunk-V23SCQL7.js";
19
19
  import {
20
- getCouponSchema
21
- } from "./chunk-44VDBYFU.js";
20
+ getMerchantChargeSchema
21
+ } from "./chunk-PJHGIRZM.js";
22
22
  import {
23
23
  getPermissionsSchema
24
- } from "./chunk-NZDLUQWP.js";
24
+ } from "./chunk-VDVCCU7D.js";
25
25
  import {
26
26
  __name
27
- } from "./chunk-VNI36MMC.js";
27
+ } from "./chunk-H736K5TN.js";
28
+
29
+ // src/lib/mysql/schemas/commerce/coupon.ts
30
+ import { relations as relations14, sql as sql8 } from "drizzle-orm";
31
+ import { boolean as boolean6, decimal as decimal3, int as int4, json as json7, primaryKey as primaryKey9, timestamp as timestamp13, unique as unique2, varchar as varchar14 } from "drizzle-orm/mysql-core";
28
32
 
29
33
  // 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";
34
+ import { relations as relations13, sql as sql7 } from "drizzle-orm";
35
+ import { decimal as decimal2, json as json6, primaryKey as primaryKey8, timestamp as timestamp12, unique, varchar as varchar13 } from "drizzle-orm/mysql-core";
32
36
 
33
37
  // src/lib/mysql/schemas/auth/users.ts
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";
38
+ import { relations as relations12, sql as sql6 } from "drizzle-orm";
39
+ import { index as index10, mysqlEnum as mysqlEnum2, timestamp as timestamp11, varchar as varchar12 } from "drizzle-orm/mysql-core";
36
40
 
37
41
  // src/lib/mysql/schemas/communication/communication-preferences.ts
38
42
  import { relations } from "drizzle-orm";
@@ -122,54 +126,252 @@ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
122
126
  __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
123
127
 
124
128
  // src/lib/mysql/schemas/content/content-contributions.ts
125
- import { relations as relations4 } from "drizzle-orm";
126
- import { boolean as boolean2, index as index4, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
129
+ import { relations as relations7 } from "drizzle-orm";
130
+ import { boolean as boolean2, index as index5, timestamp as timestamp7, varchar as varchar7 } from "drizzle-orm/mysql-core";
127
131
 
128
132
  // src/lib/mysql/schemas/content/content-resource.ts
133
+ import { relations as relations6, sql as sql5 } from "drizzle-orm";
134
+ import { index as index4, json as json5, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
135
+
136
+ // src/lib/mysql/schemas/content/content-resource-product.ts
137
+ import { relations as relations4, sql as sql3 } from "drizzle-orm";
138
+ import { double, index as index2, json as json3, primaryKey as primaryKey3, timestamp as timestamp4, varchar as varchar4 } from "drizzle-orm/mysql-core";
139
+
140
+ // src/lib/mysql/schemas/commerce/product.ts
129
141
  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";
142
+ import { int as int2, json as json2, primaryKey as primaryKey2, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
131
143
 
132
- // src/lib/mysql/schemas/content/content-resource-resource.ts
144
+ // src/lib/mysql/schemas/commerce/price.ts
133
145
  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";
146
+ import { decimal, int, json, primaryKey, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
147
+ function getPriceSchema(mysqlTable) {
148
+ return mysqlTable("prices", {
149
+ id: varchar2("id", {
150
+ length: 191
151
+ }).notNull(),
152
+ productId: varchar2("productId", {
153
+ length: 191
154
+ }),
155
+ nickname: varchar2("nickname", {
156
+ length: 191
157
+ }),
158
+ status: int("status").default(0).notNull(),
159
+ unitAmount: decimal("unitAmount", {
160
+ precision: 10,
161
+ scale: 2
162
+ }).notNull(),
163
+ createdAt: timestamp2("createdAt", {
164
+ mode: "date",
165
+ fsp: 3
166
+ }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
167
+ fields: json("fields").$type().default({})
168
+ }, (table) => {
169
+ return {
170
+ priceId: primaryKey({
171
+ columns: [
172
+ table.id
173
+ ],
174
+ name: "Price_id"
175
+ })
176
+ };
177
+ });
178
+ }
179
+ __name(getPriceSchema, "getPriceSchema");
180
+ function getProductRelationsSchema(mysqlTable) {
181
+ const product = getProductSchema(mysqlTable);
182
+ const price = getPriceSchema(mysqlTable);
183
+ const merchantPrice = getMerchantPriceSchema(mysqlTable);
184
+ return relations2(price, ({ one, many }) => ({
185
+ product: one(product, {
186
+ fields: [
187
+ price.productId
188
+ ],
189
+ references: [
190
+ product.id
191
+ ],
192
+ relationName: "user"
193
+ }),
194
+ merchantPrice: one(merchantPrice, {
195
+ fields: [
196
+ price.id
197
+ ],
198
+ references: [
199
+ merchantPrice.priceId
200
+ ],
201
+ relationName: "merchantPrice"
202
+ })
203
+ }));
204
+ }
205
+ __name(getProductRelationsSchema, "getProductRelationsSchema");
206
+
207
+ // src/lib/mysql/schemas/commerce/product.ts
208
+ function getProductSchema(mysqlTable) {
209
+ return mysqlTable("products", {
210
+ id: varchar3("id", {
211
+ length: 191
212
+ }).notNull(),
213
+ name: varchar3("name", {
214
+ length: 191
215
+ }).notNull(),
216
+ key: varchar3("key", {
217
+ length: 191
218
+ }),
219
+ type: varchar3("type", {
220
+ length: 191
221
+ }),
222
+ fields: json2("fields").$type().default({}),
223
+ createdAt: timestamp3("createdAt", {
224
+ mode: "date",
225
+ fsp: 3
226
+ }).default(sql2`CURRENT_TIMESTAMP(3)`).notNull(),
227
+ status: int2("status").default(0).notNull(),
228
+ quantityAvailable: int2("quantityAvailable").default(-1).notNull()
229
+ }, (table) => {
230
+ return {
231
+ productId: primaryKey2({
232
+ columns: [
233
+ table.id
234
+ ],
235
+ name: "Product_id"
236
+ })
237
+ };
238
+ });
239
+ }
240
+ __name(getProductSchema, "getProductSchema");
241
+ function getProductRelationsSchema2(mysqlTable) {
242
+ const product = getProductSchema(mysqlTable);
243
+ const price = getPriceSchema(mysqlTable);
244
+ const merchantProduct = getMerchantProductSchema(mysqlTable);
245
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
246
+ return relations3(product, ({ one, many }) => ({
247
+ price: one(price, {
248
+ fields: [
249
+ product.id
250
+ ],
251
+ references: [
252
+ price.productId
253
+ ],
254
+ relationName: "price"
255
+ }),
256
+ resources: many(contentResourceProduct, {
257
+ relationName: "product"
258
+ }),
259
+ merchantProduct: one(merchantProduct, {
260
+ fields: [
261
+ product.id
262
+ ],
263
+ references: [
264
+ merchantProduct.productId
265
+ ],
266
+ relationName: "merchantProduct"
267
+ })
268
+ }));
269
+ }
270
+ __name(getProductRelationsSchema2, "getProductRelationsSchema");
271
+
272
+ // src/lib/mysql/schemas/content/content-resource-product.ts
273
+ function getContentResourceProductSchema(mysqlTable) {
274
+ return mysqlTable("contentResourceProduct", {
275
+ productId: varchar4("productId", {
276
+ length: 255
277
+ }).notNull(),
278
+ resourceId: varchar4("resourceId", {
279
+ length: 255
280
+ }).notNull(),
281
+ position: double("position").notNull().default(0),
282
+ metadata: json3("metadata").$type().default({}),
283
+ createdAt: timestamp4("createdAt", {
284
+ mode: "date",
285
+ fsp: 3
286
+ }).default(sql3`CURRENT_TIMESTAMP(3)`),
287
+ updatedAt: timestamp4("updatedAt", {
288
+ mode: "date",
289
+ fsp: 3
290
+ }).default(sql3`CURRENT_TIMESTAMP(3)`),
291
+ deletedAt: timestamp4("deletedAt", {
292
+ mode: "date",
293
+ fsp: 3
294
+ })
295
+ }, (crr) => ({
296
+ pk: primaryKey3({
297
+ columns: [
298
+ crr.productId,
299
+ crr.resourceId
300
+ ]
301
+ }),
302
+ contentResourceIdIdx: index2("contentResourceId_idx").on(crr.productId),
303
+ resourceIdIdx: index2("resourceId_idx").on(crr.resourceId)
304
+ }));
305
+ }
306
+ __name(getContentResourceProductSchema, "getContentResourceProductSchema");
307
+ function getContentResourceProductRelationsSchema(mysqlTable) {
308
+ const contentResource = getContentResourceSchema(mysqlTable);
309
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
310
+ const product = getProductSchema(mysqlTable);
311
+ return relations4(contentResourceProduct, ({ one }) => ({
312
+ product: one(product, {
313
+ fields: [
314
+ contentResourceProduct.productId
315
+ ],
316
+ references: [
317
+ product.id
318
+ ],
319
+ relationName: "product"
320
+ }),
321
+ resource: one(contentResource, {
322
+ fields: [
323
+ contentResourceProduct.resourceId
324
+ ],
325
+ references: [
326
+ contentResource.id
327
+ ],
328
+ relationName: "resource"
329
+ })
330
+ }));
331
+ }
332
+ __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
333
+
334
+ // src/lib/mysql/schemas/content/content-resource-resource.ts
335
+ import { relations as relations5, sql as sql4 } from "drizzle-orm";
336
+ import { double as double2, index as index3, json as json4, primaryKey as primaryKey4, timestamp as timestamp5, varchar as varchar5 } from "drizzle-orm/mysql-core";
135
337
  function getContentResourceResourceSchema(mysqlTable) {
136
338
  return mysqlTable("contentResourceResource", {
137
- resourceOfId: varchar2("resourceOfId", {
339
+ resourceOfId: varchar5("resourceOfId", {
138
340
  length: 255
139
341
  }).notNull(),
140
- resourceId: varchar2("resourceId", {
342
+ resourceId: varchar5("resourceId", {
141
343
  length: 255
142
344
  }).notNull(),
143
- position: double("position").notNull().default(0),
144
- metadata: json("metadata").$type().default({}),
145
- createdAt: timestamp2("createdAt", {
345
+ position: double2("position").notNull().default(0),
346
+ metadata: json4("metadata").$type().default({}),
347
+ createdAt: timestamp5("createdAt", {
146
348
  mode: "date",
147
349
  fsp: 3
148
- }).default(sql`CURRENT_TIMESTAMP(3)`),
149
- updatedAt: timestamp2("updatedAt", {
350
+ }).default(sql4`CURRENT_TIMESTAMP(3)`),
351
+ updatedAt: timestamp5("updatedAt", {
150
352
  mode: "date",
151
353
  fsp: 3
152
- }).default(sql`CURRENT_TIMESTAMP(3)`),
153
- deletedAt: timestamp2("deletedAt", {
354
+ }).default(sql4`CURRENT_TIMESTAMP(3)`),
355
+ deletedAt: timestamp5("deletedAt", {
154
356
  mode: "date",
155
357
  fsp: 3
156
358
  })
157
359
  }, (crr) => ({
158
- pk: primaryKey({
360
+ pk: primaryKey4({
159
361
  columns: [
160
362
  crr.resourceOfId,
161
363
  crr.resourceId
162
364
  ]
163
365
  }),
164
- contentResourceIdIdx: index2("contentResourceId_idx").on(crr.resourceOfId),
165
- resourceIdIdx: index2("resourceId_idx").on(crr.resourceId)
366
+ contentResourceIdIdx: index3("contentResourceId_idx").on(crr.resourceOfId),
367
+ resourceIdIdx: index3("resourceId_idx").on(crr.resourceId)
166
368
  }));
167
369
  }
168
370
  __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
169
371
  function getContentResourceResourceRelationsSchema(mysqlTable) {
170
372
  const contentResource = getContentResourceSchema(mysqlTable);
171
373
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
172
- return relations2(contentResourceResource, ({ one }) => ({
374
+ return relations5(contentResourceResource, ({ one }) => ({
173
375
  resourceOf: one(contentResource, {
174
376
  fields: [
175
377
  contentResourceResource.resourceOfId
@@ -195,32 +397,32 @@ __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRel
195
397
  // src/lib/mysql/schemas/content/content-resource.ts
196
398
  function getContentResourceSchema(mysqlTable) {
197
399
  return mysqlTable("contentResource", {
198
- id: varchar3("id", {
400
+ id: varchar6("id", {
199
401
  length: 255
200
402
  }).notNull().primaryKey(),
201
- type: varchar3("type", {
403
+ type: varchar6("type", {
202
404
  length: 255
203
405
  }).notNull(),
204
- createdById: varchar3("createdById", {
406
+ createdById: varchar6("createdById", {
205
407
  length: 255
206
408
  }).notNull(),
207
- fields: json2("fields").$type().default({}),
208
- createdAt: timestamp3("createdAt", {
409
+ fields: json5("fields").$type().default({}),
410
+ createdAt: timestamp6("createdAt", {
209
411
  mode: "date",
210
412
  fsp: 3
211
- }).default(sql2`CURRENT_TIMESTAMP(3)`),
212
- updatedAt: timestamp3("updatedAt", {
413
+ }).default(sql5`CURRENT_TIMESTAMP(3)`),
414
+ updatedAt: timestamp6("updatedAt", {
213
415
  mode: "date",
214
416
  fsp: 3
215
- }).default(sql2`CURRENT_TIMESTAMP(3)`),
216
- deletedAt: timestamp3("deletedAt", {
417
+ }).default(sql5`CURRENT_TIMESTAMP(3)`),
418
+ deletedAt: timestamp6("deletedAt", {
217
419
  mode: "date",
218
420
  fsp: 3
219
421
  })
220
422
  }, (cm) => ({
221
- typeIdx: index3("type_idx").on(cm.type),
222
- createdByIdx: index3("createdById_idx").on(cm.createdById),
223
- createdAtIdx: index3("createdAt_idx").on(cm.createdAt)
423
+ typeIdx: index4("type_idx").on(cm.type),
424
+ createdByIdx: index4("createdById_idx").on(cm.createdById),
425
+ createdAtIdx: index4("createdAt_idx").on(cm.createdAt)
224
426
  }));
225
427
  }
226
428
  __name(getContentResourceSchema, "getContentResourceSchema");
@@ -228,7 +430,8 @@ function getContentResourceRelationsSchema(mysqlTable) {
228
430
  const contentResource = getContentResourceSchema(mysqlTable);
229
431
  const users = getUsersSchema(mysqlTable);
230
432
  const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
231
- return relations3(contentResource, ({ one, many }) => ({
433
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
434
+ return relations6(contentResource, ({ one, many }) => ({
232
435
  createdBy: one(users, {
233
436
  fields: [
234
437
  contentResource.createdById
@@ -243,6 +446,9 @@ function getContentResourceRelationsSchema(mysqlTable) {
243
446
  }),
244
447
  resourceOf: many(contentResourceResource, {
245
448
  relationName: "resource"
449
+ }),
450
+ resourceProducts: many(contentResourceProduct, {
451
+ relationName: "resource"
246
452
  })
247
453
  }));
248
454
  }
@@ -251,35 +457,35 @@ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
251
457
  // src/lib/mysql/schemas/content/content-contributions.ts
252
458
  function getContentContributionsSchema(mysqlTable) {
253
459
  return mysqlTable("contentContribution", {
254
- id: varchar4("id", {
460
+ id: varchar7("id", {
255
461
  length: 255
256
462
  }).notNull().primaryKey(),
257
- userId: varchar4("userId", {
463
+ userId: varchar7("userId", {
258
464
  length: 255
259
465
  }).notNull(),
260
- contentId: varchar4("contentId", {
466
+ contentId: varchar7("contentId", {
261
467
  length: 255
262
468
  }).notNull(),
263
- contributionTypeId: varchar4("contributionTypeId", {
469
+ contributionTypeId: varchar7("contributionTypeId", {
264
470
  length: 255
265
471
  }).notNull(),
266
472
  active: boolean2("active").notNull().default(true),
267
- createdAt: timestamp4("createdAt", {
473
+ createdAt: timestamp7("createdAt", {
268
474
  mode: "date",
269
475
  fsp: 3
270
476
  }).defaultNow(),
271
- updatedAt: timestamp4("updatedAt", {
477
+ updatedAt: timestamp7("updatedAt", {
272
478
  mode: "date",
273
479
  fsp: 3
274
480
  }).defaultNow(),
275
- deletedAt: timestamp4("deletedAt", {
481
+ deletedAt: timestamp7("deletedAt", {
276
482
  mode: "date",
277
483
  fsp: 3
278
484
  })
279
485
  }, (cc) => ({
280
- userIdIdx: index4("userId_idx").on(cc.userId),
281
- contentIdIdx: index4("contentId_idx").on(cc.contentId),
282
- contributionTypeIdIdx: index4("contributionTypeId_idx").on(cc.contributionTypeId)
486
+ userIdIdx: index5("userId_idx").on(cc.userId),
487
+ contentIdIdx: index5("contentId_idx").on(cc.contentId),
488
+ contributionTypeIdIdx: index5("contributionTypeId_idx").on(cc.contributionTypeId)
283
489
  }));
284
490
  }
285
491
  __name(getContentContributionsSchema, "getContentContributionsSchema");
@@ -288,7 +494,7 @@ function getContentContributionRelationsSchema(mysqlTable) {
288
494
  const users = getUsersSchema(mysqlTable);
289
495
  const contentResource = getContentResourceSchema(mysqlTable);
290
496
  const contributionTypes = getContributionTypesSchema(mysqlTable);
291
- return relations4(contentContributions, ({ one }) => ({
497
+ return relations7(contentContributions, ({ one }) => ({
292
498
  user: one(users, {
293
499
  fields: [
294
500
  contentContributions.userId
@@ -321,53 +527,53 @@ function getContentContributionRelationsSchema(mysqlTable) {
321
527
  __name(getContentContributionRelationsSchema, "getContentContributionRelationsSchema");
322
528
 
323
529
  // src/lib/mysql/schemas/auth/accounts.ts
324
- import { relations as relations5 } from "drizzle-orm";
325
- import { index as index5, int, primaryKey as primaryKey2, text, varchar as varchar5 } from "drizzle-orm/mysql-core";
530
+ import { relations as relations8 } from "drizzle-orm";
531
+ import { index as index6, int as int3, primaryKey as primaryKey5, text, varchar as varchar8 } from "drizzle-orm/mysql-core";
326
532
  function getAccountsSchema(mysqlTable) {
327
533
  return mysqlTable("account", {
328
- userId: varchar5("userId", {
534
+ userId: varchar8("userId", {
329
535
  length: 255
330
536
  }).notNull(),
331
- type: varchar5("type", {
537
+ type: varchar8("type", {
332
538
  length: 255
333
539
  }).$type().notNull(),
334
- provider: varchar5("provider", {
540
+ provider: varchar8("provider", {
335
541
  length: 255
336
542
  }).notNull(),
337
- providerAccountId: varchar5("providerAccountId", {
543
+ providerAccountId: varchar8("providerAccountId", {
338
544
  length: 255
339
545
  }).notNull(),
340
546
  refresh_token: text("refresh_token"),
341
547
  access_token: text("access_token"),
342
548
  oauth_token: text("oauth_token"),
343
549
  oauth_token_secret: text("oauth_token_secret"),
344
- expires_at: int("expires_at"),
345
- token_type: varchar5("token_type", {
550
+ expires_at: int3("expires_at"),
551
+ token_type: varchar8("token_type", {
346
552
  length: 255
347
553
  }),
348
- scope: varchar5("scope", {
554
+ scope: varchar8("scope", {
349
555
  length: 255
350
556
  }),
351
557
  id_token: text("id_token"),
352
- session_state: varchar5("session_state", {
558
+ session_state: varchar8("session_state", {
353
559
  length: 255
354
560
  }),
355
- refresh_token_expires_in: int("refresh_token_expires_in")
561
+ refresh_token_expires_in: int3("refresh_token_expires_in")
356
562
  }, (account) => ({
357
- pk: primaryKey2({
563
+ pk: primaryKey5({
358
564
  columns: [
359
565
  account.provider,
360
566
  account.providerAccountId
361
567
  ]
362
568
  }),
363
- userIdIdx: index5("userId_idx").on(account.userId)
569
+ userIdIdx: index6("userId_idx").on(account.userId)
364
570
  }));
365
571
  }
366
572
  __name(getAccountsSchema, "getAccountsSchema");
367
573
  function getAccountsRelationsSchema(mysqlTable) {
368
574
  const accounts = getAccountsSchema(mysqlTable);
369
575
  const users = getUsersSchema(mysqlTable);
370
- return relations5(accounts, ({ one }) => ({
576
+ return relations8(accounts, ({ one }) => ({
371
577
  user: one(users, {
372
578
  fields: [
373
579
  accounts.userId
@@ -382,38 +588,38 @@ function getAccountsRelationsSchema(mysqlTable) {
382
588
  __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
383
589
 
384
590
  // src/lib/mysql/schemas/auth/user-permissions.ts
385
- import { relations as relations6 } from "drizzle-orm";
386
- import { boolean as boolean3, index as index6, primaryKey as primaryKey3, timestamp as timestamp5, varchar as varchar6 } from "drizzle-orm/mysql-core";
591
+ import { relations as relations9 } from "drizzle-orm";
592
+ import { boolean as boolean3, index as index7, primaryKey as primaryKey6, timestamp as timestamp8, varchar as varchar9 } from "drizzle-orm/mysql-core";
387
593
  function getUserPermissionsSchema(mysqlTable) {
388
594
  return mysqlTable("userPermission", {
389
- userId: varchar6("userId", {
595
+ userId: varchar9("userId", {
390
596
  length: 255
391
597
  }).notNull(),
392
- permissionId: varchar6("permissionId", {
598
+ permissionId: varchar9("permissionId", {
393
599
  length: 255
394
600
  }).notNull(),
395
601
  active: boolean3("active").notNull().default(true),
396
- createdAt: timestamp5("createdAt", {
602
+ createdAt: timestamp8("createdAt", {
397
603
  mode: "date",
398
604
  fsp: 3
399
605
  }).defaultNow(),
400
- updatedAt: timestamp5("updatedAt", {
606
+ updatedAt: timestamp8("updatedAt", {
401
607
  mode: "date",
402
608
  fsp: 3
403
609
  }).defaultNow(),
404
- deletedAt: timestamp5("deletedAt", {
610
+ deletedAt: timestamp8("deletedAt", {
405
611
  mode: "date",
406
612
  fsp: 3
407
613
  })
408
614
  }, (up) => ({
409
- pk: primaryKey3({
615
+ pk: primaryKey6({
410
616
  columns: [
411
617
  up.userId,
412
618
  up.permissionId
413
619
  ]
414
620
  }),
415
- userIdIdx: index6("userId_idx").on(up.userId),
416
- permissionIdIdx: index6("permissionId_idx").on(up.permissionId)
621
+ userIdIdx: index7("userId_idx").on(up.userId),
622
+ permissionIdIdx: index7("permissionId_idx").on(up.permissionId)
417
623
  }));
418
624
  }
419
625
  __name(getUserPermissionsSchema, "getUserPermissionsSchema");
@@ -421,7 +627,7 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
421
627
  const userPermissions = getUserPermissionsSchema(mysqlTable);
422
628
  const users = getUsersSchema(mysqlTable);
423
629
  const permissions = getPermissionsSchema(mysqlTable);
424
- return relations6(userPermissions, ({ one }) => ({
630
+ return relations9(userPermissions, ({ one }) => ({
425
631
  user: one(users, {
426
632
  fields: [
427
633
  userPermissions.userId
@@ -445,43 +651,43 @@ function getUserPermissionsRelationsSchema(mysqlTable) {
445
651
  __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
446
652
 
447
653
  // 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";
654
+ import { relations as relations11 } from "drizzle-orm";
655
+ import { boolean as boolean5, index as index9, primaryKey as primaryKey7, timestamp as timestamp10, varchar as varchar11 } from "drizzle-orm/mysql-core";
450
656
 
451
657
  // 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";
658
+ import { relations as relations10 } from "drizzle-orm";
659
+ import { boolean as boolean4, index as index8, text as text2, timestamp as timestamp9, varchar as varchar10 } from "drizzle-orm/mysql-core";
454
660
  function getRolesSchema(mysqlTable) {
455
661
  return mysqlTable("role", {
456
- id: varchar7("id", {
662
+ id: varchar10("id", {
457
663
  length: 255
458
664
  }).notNull().primaryKey(),
459
- name: varchar7("name", {
665
+ name: varchar10("name", {
460
666
  length: 255
461
667
  }).notNull().unique(),
462
668
  description: text2("description"),
463
669
  active: boolean4("active").notNull().default(true),
464
- createdAt: timestamp6("createdAt", {
670
+ createdAt: timestamp9("createdAt", {
465
671
  mode: "date",
466
672
  fsp: 3
467
673
  }).defaultNow(),
468
- updatedAt: timestamp6("updatedAt", {
674
+ updatedAt: timestamp9("updatedAt", {
469
675
  mode: "date",
470
676
  fsp: 3
471
677
  }).defaultNow(),
472
- deletedAt: timestamp6("deletedAt", {
678
+ deletedAt: timestamp9("deletedAt", {
473
679
  mode: "date",
474
680
  fsp: 3
475
681
  })
476
682
  }, (role) => ({
477
- nameIdx: index7("name_idx").on(role.name)
683
+ nameIdx: index8("name_idx").on(role.name)
478
684
  }));
479
685
  }
480
686
  __name(getRolesSchema, "getRolesSchema");
481
687
  function getRolesRelationsSchema(mysqlTable) {
482
688
  const roles = getRolesSchema(mysqlTable);
483
689
  const userRoles = getUserRolesSchema(mysqlTable);
484
- return relations7(roles, ({ many }) => ({
690
+ return relations10(roles, ({ many }) => ({
485
691
  userRoles: many(userRoles, {
486
692
  relationName: "role"
487
693
  })
@@ -492,34 +698,34 @@ __name(getRolesRelationsSchema, "getRolesRelationsSchema");
492
698
  // src/lib/mysql/schemas/auth/user-roles.ts
493
699
  function getUserRolesSchema(mysqlTable) {
494
700
  return mysqlTable("userRole", {
495
- userId: varchar8("userId", {
701
+ userId: varchar11("userId", {
496
702
  length: 255
497
703
  }).notNull(),
498
- roleId: varchar8("roleId", {
704
+ roleId: varchar11("roleId", {
499
705
  length: 255
500
706
  }).notNull(),
501
707
  active: boolean5("active").notNull().default(true),
502
- createdAt: timestamp7("createdAt", {
708
+ createdAt: timestamp10("createdAt", {
503
709
  mode: "date",
504
710
  fsp: 3
505
711
  }).defaultNow(),
506
- updatedAt: timestamp7("updatedAt", {
712
+ updatedAt: timestamp10("updatedAt", {
507
713
  mode: "date",
508
714
  fsp: 3
509
715
  }).defaultNow(),
510
- deletedAt: timestamp7("deletedAt", {
716
+ deletedAt: timestamp10("deletedAt", {
511
717
  mode: "date",
512
718
  fsp: 3
513
719
  })
514
720
  }, (ur) => ({
515
- pk: primaryKey4({
721
+ pk: primaryKey7({
516
722
  columns: [
517
723
  ur.userId,
518
724
  ur.roleId
519
725
  ]
520
726
  }),
521
- userIdIdx: index8("userId_idx").on(ur.userId),
522
- roleIdIdx: index8("roleId_idx").on(ur.roleId)
727
+ userIdIdx: index9("userId_idx").on(ur.userId),
728
+ roleIdIdx: index9("roleId_idx").on(ur.roleId)
523
729
  }));
524
730
  }
525
731
  __name(getUserRolesSchema, "getUserRolesSchema");
@@ -527,7 +733,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
527
733
  const userRoles = getUserRolesSchema(mysqlTable);
528
734
  const users = getUsersSchema(mysqlTable);
529
735
  const roles = getRolesSchema(mysqlTable);
530
- return relations8(userRoles, ({ one }) => ({
736
+ return relations11(userRoles, ({ one }) => ({
531
737
  user: one(users, {
532
738
  fields: [
533
739
  userRoles.userId
@@ -535,7 +741,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
535
741
  references: [
536
742
  users.id
537
743
  ],
538
- relationName: "role"
744
+ relationName: "user"
539
745
  }),
540
746
  role: one(roles, {
541
747
  fields: [
@@ -544,7 +750,7 @@ function getUserRolesRelationsSchema(mysqlTable) {
544
750
  references: [
545
751
  roles.id
546
752
  ],
547
- relationName: "user"
753
+ relationName: "role"
548
754
  })
549
755
  }));
550
756
  }
@@ -553,34 +759,34 @@ __name(getUserRolesRelationsSchema, "getUserRolesRelationsSchema");
553
759
  // src/lib/mysql/schemas/auth/users.ts
554
760
  function getUsersSchema(mysqlTable) {
555
761
  return mysqlTable("user", {
556
- id: varchar9("id", {
762
+ id: varchar12("id", {
557
763
  length: 255
558
764
  }).notNull().primaryKey(),
559
- name: varchar9("name", {
765
+ name: varchar12("name", {
560
766
  length: 255
561
767
  }),
562
768
  role: mysqlEnum2("role", [
563
769
  "user",
564
770
  "admin"
565
771
  ]).default("user"),
566
- email: varchar9("email", {
772
+ email: varchar12("email", {
567
773
  length: 255
568
774
  }).notNull().unique(),
569
- emailVerified: timestamp8("emailVerified", {
775
+ emailVerified: timestamp11("emailVerified", {
570
776
  mode: "date",
571
777
  fsp: 3
572
778
  }),
573
- image: varchar9("image", {
779
+ image: varchar12("image", {
574
780
  length: 255
575
781
  }),
576
- createdAt: timestamp8("createdAt", {
782
+ createdAt: timestamp11("createdAt", {
577
783
  mode: "date",
578
784
  fsp: 3
579
- }).default(sql3`CURRENT_TIMESTAMP(3)`)
785
+ }).default(sql6`CURRENT_TIMESTAMP(3)`)
580
786
  }, (user) => ({
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)
787
+ emailIdx: index10("email_idx").on(user.email),
788
+ roleIdx: index10("role_idx").on(user.role),
789
+ createdAtIdx: index10("created_at_idx").on(user.createdAt)
584
790
  }));
585
791
  }
586
792
  __name(getUsersSchema, "getUsersSchema");
@@ -593,7 +799,7 @@ function getUsersRelationsSchema(mysqlTable) {
593
799
  const contentContributions = getContentContributionsSchema(mysqlTable);
594
800
  const contentResource = getContentResourceSchema(mysqlTable);
595
801
  const purchases = getPurchaseSchema(mysqlTable);
596
- return relations9(users, ({ many }) => ({
802
+ return relations12(users, ({ many }) => ({
597
803
  accounts: many(accounts, {
598
804
  relationName: "user"
599
805
  }),
@@ -622,60 +828,60 @@ __name(getUsersRelationsSchema, "getUsersRelationsSchema");
622
828
  // src/lib/mysql/schemas/commerce/purchase.ts
623
829
  function getPurchaseSchema(mysqlTable) {
624
830
  return mysqlTable("purchases", {
625
- id: varchar10("id", {
831
+ id: varchar13("id", {
626
832
  length: 191
627
833
  }).notNull(),
628
- userId: varchar10("userId", {
834
+ userId: varchar13("userId", {
629
835
  length: 191
630
836
  }),
631
- createdAt: timestamp9("createdAt", {
837
+ createdAt: timestamp12("createdAt", {
632
838
  mode: "date",
633
839
  fsp: 3
634
- }).default(sql4`CURRENT_TIMESTAMP(3)`).notNull(),
635
- totalAmount: decimal("totalAmount", {
840
+ }).default(sql7`CURRENT_TIMESTAMP(3)`).notNull(),
841
+ totalAmount: decimal2("totalAmount", {
636
842
  precision: 65,
637
843
  scale: 30
638
844
  }).notNull(),
639
- ipAddress: varchar10("ip_address", {
845
+ ipAddress: varchar13("ip_address", {
640
846
  length: 191
641
847
  }),
642
- city: varchar10("city", {
848
+ city: varchar13("city", {
643
849
  length: 191
644
850
  }),
645
- state: varchar10("state", {
851
+ state: varchar13("state", {
646
852
  length: 191
647
853
  }),
648
- country: varchar10("country", {
854
+ country: varchar13("country", {
649
855
  length: 191
650
856
  }),
651
- couponId: varchar10("couponId", {
857
+ couponId: varchar13("couponId", {
652
858
  length: 191
653
859
  }),
654
- productId: varchar10("productId", {
860
+ productId: varchar13("productId", {
655
861
  length: 191
656
862
  }).notNull(),
657
- merchantChargeId: varchar10("merchantChargeId", {
863
+ merchantChargeId: varchar13("merchantChargeId", {
658
864
  length: 191
659
865
  }),
660
- upgradedFromId: varchar10("upgradedFromId", {
866
+ upgradedFromId: varchar13("upgradedFromId", {
661
867
  length: 191
662
868
  }),
663
- status: varchar10("status", {
869
+ status: varchar13("status", {
664
870
  length: 191
665
871
  }).default("Valid").notNull(),
666
- bulkCouponId: varchar10("bulkCouponId", {
872
+ bulkCouponId: varchar13("bulkCouponId", {
667
873
  length: 191
668
874
  }),
669
- merchantSessionId: varchar10("merchantSessionId", {
875
+ merchantSessionId: varchar13("merchantSessionId", {
670
876
  length: 191
671
877
  }),
672
- redeemedBulkCouponId: varchar10("redeemedBulkCouponId", {
878
+ redeemedBulkCouponId: varchar13("redeemedBulkCouponId", {
673
879
  length: 191
674
880
  }),
675
- metadata: json3("fields").$type().default({})
881
+ fields: json6("fields").$type().default({})
676
882
  }, (table) => {
677
883
  return {
678
- purchaseId: primaryKey5({
884
+ purchaseId: primaryKey8({
679
885
  columns: [
680
886
  table.id
681
887
  ],
@@ -693,7 +899,16 @@ function getPurchaseRelationsSchema(mysqlTable) {
693
899
  const merchantCharges = getMerchantChargeSchema(mysqlTable);
694
900
  const merchantSessions = getMerchantSessionSchema(mysqlTable);
695
901
  const coupons = getCouponSchema(mysqlTable);
696
- return relations10(purchases, ({ many, one }) => ({
902
+ return relations13(purchases, ({ many, one }) => ({
903
+ redeemedBulkCoupon: one(coupons, {
904
+ fields: [
905
+ purchases.redeemedBulkCouponId
906
+ ],
907
+ references: [
908
+ coupons.id
909
+ ],
910
+ relationName: "redeemedBulkCoupon"
911
+ }),
697
912
  user: one(users, {
698
913
  fields: [
699
914
  purchases.userId
@@ -743,15 +958,83 @@ function getPurchaseRelationsSchema(mysqlTable) {
743
958
  }
744
959
  __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
745
960
 
961
+ // src/lib/mysql/schemas/commerce/coupon.ts
962
+ function getCouponSchema(mysqlTable) {
963
+ return mysqlTable("coupons", {
964
+ id: varchar14("id", {
965
+ length: 191
966
+ }).notNull(),
967
+ code: varchar14("code", {
968
+ length: 191
969
+ }),
970
+ createdAt: timestamp13("createdAt", {
971
+ mode: "date",
972
+ fsp: 3
973
+ }).default(sql8`CURRENT_TIMESTAMP(3)`).notNull(),
974
+ expires: timestamp13("expires", {
975
+ mode: "date",
976
+ fsp: 3
977
+ }),
978
+ fields: json7("fields").$type().default({}),
979
+ maxUses: int4("maxUses").default(-1).notNull(),
980
+ default: boolean6("default").default(false).notNull(),
981
+ merchantCouponId: varchar14("merchantCouponId", {
982
+ length: 191
983
+ }),
984
+ status: int4("status").default(0).notNull(),
985
+ usedCount: int4("usedCount").default(0).notNull(),
986
+ percentageDiscount: decimal3("percentageDiscount", {
987
+ precision: 3,
988
+ scale: 2
989
+ }).notNull(),
990
+ restrictedToProductId: varchar14("restrictedToProductId", {
991
+ length: 191
992
+ }),
993
+ bulkPurchaseId: varchar14("bulkPurchaseId", {
994
+ length: 191
995
+ })
996
+ }, (table) => {
997
+ return {
998
+ couponId: primaryKey9({
999
+ columns: [
1000
+ table.id
1001
+ ],
1002
+ name: "Coupon_id"
1003
+ }),
1004
+ couponBulkPurchaseIdKey: unique2("Coupon_bulkPurchaseId_key").on(table.bulkPurchaseId),
1005
+ couponCodeKey: unique2("Coupon_code_key").on(table.code)
1006
+ };
1007
+ });
1008
+ }
1009
+ __name(getCouponSchema, "getCouponSchema");
1010
+ function getCouponRelationsSchema(mysqlTable) {
1011
+ const purchase = getPurchaseSchema(mysqlTable);
1012
+ const coupon = getCouponSchema(mysqlTable);
1013
+ return relations14(coupon, ({ many }) => ({
1014
+ bulkCouponPurchases: many(purchase, {
1015
+ relationName: "redeemedBulkCoupon"
1016
+ })
1017
+ }));
1018
+ }
1019
+ __name(getCouponRelationsSchema, "getCouponRelationsSchema");
1020
+
746
1021
  export {
747
- getPurchaseSchema,
748
- getPurchaseRelationsSchema,
749
- getCommunicationPreferencesSchema,
750
- getCommunicationPreferencesRelationsSchema,
1022
+ getCouponSchema,
1023
+ getCouponRelationsSchema,
751
1024
  getContentResourceResourceSchema,
752
1025
  getContentResourceResourceRelationsSchema,
753
1026
  getContentResourceSchema,
754
1027
  getContentResourceRelationsSchema,
1028
+ getContentResourceProductSchema,
1029
+ getContentResourceProductRelationsSchema,
1030
+ getPriceSchema,
1031
+ getProductRelationsSchema,
1032
+ getProductSchema,
1033
+ getProductRelationsSchema2,
1034
+ getPurchaseSchema,
1035
+ getPurchaseRelationsSchema,
1036
+ getCommunicationPreferencesSchema,
1037
+ getCommunicationPreferencesRelationsSchema,
755
1038
  getContentContributionsSchema,
756
1039
  getContentContributionRelationsSchema,
757
1040
  getUserPermissionsSchema,
@@ -765,4 +1048,4 @@ export {
765
1048
  getAccountsSchema,
766
1049
  getAccountsRelationsSchema
767
1050
  };
768
- //# sourceMappingURL=chunk-ISURSRBK.js.map
1051
+ //# sourceMappingURL=chunk-3RJVKNXB.js.map