@coursebuilder/adapter-drizzle 0.1.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/{chunk-3RJVKNXB.js → chunk-4PJWD6YK.js} +421 -392
  2. package/dist/{chunk-WQ7UXKZC.js → chunk-J63FMGT7.js} +538 -200
  3. package/dist/{chunk-2CI3IGR2.js → chunk-MCARHGE5.js} +2 -2
  4. package/dist/{chunk-Q5WENQT6.js → chunk-PIQXK2CY.js} +2 -2
  5. package/dist/{chunk-5HT43CVZ.js → chunk-QMDE6HUA.js} +43 -3
  6. package/dist/{chunk-53266VWH.js → chunk-QY4TPO7D.js} +2 -2
  7. package/dist/chunk-ZD3R6UPJ.js +96 -0
  8. package/dist/index.js +11 -11
  9. package/dist/lib/mysql/index.cjs +1110 -671
  10. package/dist/lib/mysql/index.cjs.map +1 -1
  11. package/dist/lib/mysql/index.d.cts +26 -0
  12. package/dist/lib/mysql/index.d.ts +26 -0
  13. package/dist/lib/mysql/index.js +11 -11
  14. package/dist/lib/mysql/schemas/auth/accounts.cjs +83 -72
  15. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  16. package/dist/lib/mysql/schemas/auth/accounts.js +6 -3
  17. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +73 -62
  18. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  19. package/dist/lib/mysql/schemas/auth/role-permissions.js +7 -4
  20. package/dist/lib/mysql/schemas/auth/roles.cjs +73 -62
  21. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  22. package/dist/lib/mysql/schemas/auth/roles.js +6 -3
  23. package/dist/lib/mysql/schemas/auth/sessions.cjs +73 -62
  24. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  25. package/dist/lib/mysql/schemas/auth/sessions.js +7 -4
  26. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +74 -63
  27. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  28. package/dist/lib/mysql/schemas/auth/user-permissions.js +6 -3
  29. package/dist/lib/mysql/schemas/auth/user-roles.cjs +74 -63
  30. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  31. package/dist/lib/mysql/schemas/auth/user-roles.js +6 -3
  32. package/dist/lib/mysql/schemas/auth/users.cjs +158 -147
  33. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  34. package/dist/lib/mysql/schemas/auth/users.js +6 -3
  35. package/dist/lib/mysql/schemas/commerce/coupon.cjs +209 -103
  36. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  37. package/dist/lib/mysql/schemas/commerce/coupon.d.cts +3 -0
  38. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +3 -0
  39. package/dist/lib/mysql/schemas/commerce/coupon.js +6 -3
  40. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +154 -10
  41. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  42. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +7 -1
  43. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +7 -1
  44. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +6 -1
  45. package/dist/lib/mysql/schemas/commerce/price.cjs +68 -57
  46. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  47. package/dist/lib/mysql/schemas/commerce/price.js +6 -3
  48. package/dist/lib/mysql/schemas/commerce/product.cjs +115 -104
  49. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  50. package/dist/lib/mysql/schemas/commerce/product.js +6 -3
  51. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +251 -13
  52. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  53. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +7 -1
  54. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +7 -1
  55. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +15 -1
  56. package/dist/lib/mysql/schemas/commerce/purchase.cjs +71 -56
  57. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/commerce/purchase.js +6 -3
  59. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +75 -64
  60. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  61. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +7 -4
  62. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +96 -85
  63. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  64. package/dist/lib/mysql/schemas/communication/communication-preferences.js +6 -3
  65. package/dist/lib/mysql/schemas/content/content-contributions.cjs +100 -89
  66. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  67. package/dist/lib/mysql/schemas/content/content-contributions.js +6 -3
  68. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +66 -55
  69. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  70. package/dist/lib/mysql/schemas/content/content-resource-product.js +6 -3
  71. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +79 -68
  72. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  73. package/dist/lib/mysql/schemas/content/content-resource-resource.js +6 -3
  74. package/dist/lib/mysql/schemas/content/content-resource.cjs +103 -92
  75. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  76. package/dist/lib/mysql/schemas/content/content-resource.js +6 -3
  77. package/package.json +2 -2
  78. package/src/lib/mysql/index.ts +456 -95
  79. package/src/lib/mysql/schemas/commerce/coupon.ts +18 -1
  80. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +29 -1
  81. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +29 -1
  82. package/dist/chunk-PJHGIRZM.js +0 -50
@@ -7,18 +7,21 @@ import {
7
7
  import {
8
8
  getCommunicationPreferenceTypesSchema
9
9
  } from "./chunk-BX5SO2JG.js";
10
+ import {
11
+ getMerchantCouponSchema
12
+ } from "./chunk-JKOYOL7A.js";
10
13
  import {
11
14
  getMerchantPriceSchema
12
15
  } from "./chunk-PPBEA4EM.js";
13
- import {
14
- getMerchantProductSchema
15
- } from "./chunk-Y7QZGEPT.js";
16
16
  import {
17
17
  getMerchantSessionSchema
18
18
  } from "./chunk-V23SCQL7.js";
19
19
  import {
20
20
  getMerchantChargeSchema
21
- } from "./chunk-PJHGIRZM.js";
21
+ } from "./chunk-ZD3R6UPJ.js";
22
+ import {
23
+ getMerchantProductSchema
24
+ } from "./chunk-Y7QZGEPT.js";
22
25
  import {
23
26
  getPermissionsSchema
24
27
  } from "./chunk-VDVCCU7D.js";
@@ -26,124 +29,97 @@ import {
26
29
  __name
27
30
  } from "./chunk-H736K5TN.js";
28
31
 
29
- // src/lib/mysql/schemas/commerce/coupon.ts
32
+ // src/lib/mysql/schemas/content/content-resource-resource.ts
30
33
  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";
34
+ import { double as double2, index as index10, json as json7, primaryKey as primaryKey9, timestamp as timestamp13, varchar as varchar14 } from "drizzle-orm/mysql-core";
32
35
 
33
- // src/lib/mysql/schemas/commerce/purchase.ts
36
+ // src/lib/mysql/schemas/content/content-resource.ts
34
37
  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";
38
+ import { index as index9, json as json6, timestamp as timestamp12, varchar as varchar13 } from "drizzle-orm/mysql-core";
36
39
 
37
40
  // src/lib/mysql/schemas/auth/users.ts
38
41
  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";
42
+ import { index as index8, mysqlEnum as mysqlEnum2, timestamp as timestamp11, varchar as varchar12 } from "drizzle-orm/mysql-core";
40
43
 
41
- // src/lib/mysql/schemas/communication/communication-preferences.ts
42
- import { relations } from "drizzle-orm";
43
- import { boolean, index, mysqlEnum, timestamp, varchar } from "drizzle-orm/mysql-core";
44
- function getCommunicationPreferencesSchema(mysqlTable) {
45
- return mysqlTable("communicationPreference", {
46
- id: varchar("id", {
47
- length: 255
48
- }).notNull().primaryKey(),
49
- userId: varchar("userId", {
50
- length: 255
51
- }).notNull(),
52
- channelId: varchar("channelId", {
44
+ // src/lib/mysql/schemas/commerce/purchase.ts
45
+ import { relations as relations5, sql as sql5 } from "drizzle-orm";
46
+ import { decimal as decimal3, json as json5, primaryKey as primaryKey5, timestamp as timestamp5, unique as unique2, varchar as varchar5 } from "drizzle-orm/mysql-core";
47
+
48
+ // src/lib/mysql/schemas/commerce/coupon.ts
49
+ import { relations as relations4, sql as sql4 } from "drizzle-orm";
50
+ import { boolean, decimal as decimal2, int as int3, json as json4, primaryKey as primaryKey4, timestamp as timestamp4, unique, varchar as varchar4 } from "drizzle-orm/mysql-core";
51
+
52
+ // src/lib/mysql/schemas/commerce/product.ts
53
+ import { relations as relations3, sql as sql3 } from "drizzle-orm";
54
+ import { int as int2, json as json3, primaryKey as primaryKey3, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
55
+
56
+ // src/lib/mysql/schemas/content/content-resource-product.ts
57
+ import { relations, sql } from "drizzle-orm";
58
+ import { double, index, json, primaryKey, timestamp, varchar } from "drizzle-orm/mysql-core";
59
+ function getContentResourceProductSchema(mysqlTable) {
60
+ return mysqlTable("contentResourceProduct", {
61
+ productId: varchar("productId", {
53
62
  length: 255
54
63
  }).notNull(),
55
- preferenceLevel: mysqlEnum("preferenceLevel", [
56
- "low",
57
- "medium",
58
- "high"
59
- ]).notNull().default("medium"),
60
- preferenceTypeId: varchar("preferenceTypeId", {
64
+ resourceId: varchar("resourceId", {
61
65
  length: 255
62
66
  }).notNull(),
63
- active: boolean("active").notNull().default(true),
67
+ position: double("position").notNull().default(0),
68
+ metadata: json("metadata").$type().default({}),
64
69
  createdAt: timestamp("createdAt", {
65
70
  mode: "date",
66
71
  fsp: 3
67
- }).defaultNow(),
68
- optInAt: timestamp("optInAt", {
69
- mode: "date",
70
- fsp: 3
71
- }),
72
- optOutAt: timestamp("optOutAt", {
73
- mode: "date",
74
- fsp: 3
75
- }),
72
+ }).default(sql`CURRENT_TIMESTAMP(3)`),
76
73
  updatedAt: timestamp("updatedAt", {
77
74
  mode: "date",
78
75
  fsp: 3
79
- }).defaultNow(),
76
+ }).default(sql`CURRENT_TIMESTAMP(3)`),
80
77
  deletedAt: timestamp("deletedAt", {
81
78
  mode: "date",
82
79
  fsp: 3
83
80
  })
84
- }, (cp) => ({
85
- userIdIdx: index("userId_idx").on(cp.userId),
86
- preferenceTypeIdx: index("preferenceTypeId_idx").on(cp.preferenceTypeId),
87
- channelIdIdx: index("channelId_idx").on(cp.channelId)
81
+ }, (crr) => ({
82
+ pk: primaryKey({
83
+ columns: [
84
+ crr.productId,
85
+ crr.resourceId
86
+ ]
87
+ }),
88
+ contentResourceIdIdx: index("contentResourceId_idx").on(crr.productId),
89
+ resourceIdIdx: index("resourceId_idx").on(crr.resourceId)
88
90
  }));
89
91
  }
90
- __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
91
- function getCommunicationPreferencesRelationsSchema(mysqlTable) {
92
- const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
93
- const users = getUsersSchema(mysqlTable);
94
- const communicationChannel = getCommunicationChannelSchema(mysqlTable);
95
- const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
96
- return relations(communicationPreferences, ({ one }) => ({
97
- user: one(users, {
98
- fields: [
99
- communicationPreferences.userId
100
- ],
101
- references: [
102
- users.id
103
- ],
104
- relationName: "user"
105
- }),
106
- channel: one(communicationChannel, {
92
+ __name(getContentResourceProductSchema, "getContentResourceProductSchema");
93
+ function getContentResourceProductRelationsSchema(mysqlTable) {
94
+ const contentResource = getContentResourceSchema(mysqlTable);
95
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
96
+ const product = getProductSchema(mysqlTable);
97
+ return relations(contentResourceProduct, ({ one }) => ({
98
+ product: one(product, {
107
99
  fields: [
108
- communicationPreferences.channelId
100
+ contentResourceProduct.productId
109
101
  ],
110
102
  references: [
111
- communicationChannel.id
103
+ product.id
112
104
  ],
113
- relationName: "channel"
105
+ relationName: "product"
114
106
  }),
115
- preferenceType: one(communicationPreferenceTypes, {
107
+ resource: one(contentResource, {
116
108
  fields: [
117
- communicationPreferences.preferenceTypeId
109
+ contentResourceProduct.resourceId
118
110
  ],
119
111
  references: [
120
- communicationPreferenceTypes.id
112
+ contentResource.id
121
113
  ],
122
- relationName: "preferenceType"
114
+ relationName: "resource"
123
115
  })
124
116
  }));
125
117
  }
126
- __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
127
-
128
- // src/lib/mysql/schemas/content/content-contributions.ts
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";
131
-
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
141
- import { relations as relations3, sql as sql2 } from "drizzle-orm";
142
- import { int as int2, json as json2, primaryKey as primaryKey2, timestamp as timestamp3, varchar as varchar3 } from "drizzle-orm/mysql-core";
118
+ __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
143
119
 
144
120
  // src/lib/mysql/schemas/commerce/price.ts
145
- import { relations as relations2, sql } from "drizzle-orm";
146
- import { decimal, int, json, primaryKey, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
121
+ import { relations as relations2, sql as sql2 } from "drizzle-orm";
122
+ import { decimal, int, json as json2, primaryKey as primaryKey2, timestamp as timestamp2, varchar as varchar2 } from "drizzle-orm/mysql-core";
147
123
  function getPriceSchema(mysqlTable) {
148
124
  return mysqlTable("prices", {
149
125
  id: varchar2("id", {
@@ -163,11 +139,11 @@ function getPriceSchema(mysqlTable) {
163
139
  createdAt: timestamp2("createdAt", {
164
140
  mode: "date",
165
141
  fsp: 3
166
- }).default(sql`CURRENT_TIMESTAMP(3)`).notNull(),
167
- fields: json("fields").$type().default({})
142
+ }).default(sql2`CURRENT_TIMESTAMP(3)`).notNull(),
143
+ fields: json2("fields").$type().default({})
168
144
  }, (table) => {
169
145
  return {
170
- priceId: primaryKey({
146
+ priceId: primaryKey2({
171
147
  columns: [
172
148
  table.id
173
149
  ],
@@ -219,16 +195,16 @@ function getProductSchema(mysqlTable) {
219
195
  type: varchar3("type", {
220
196
  length: 191
221
197
  }),
222
- fields: json2("fields").$type().default({}),
198
+ fields: json3("fields").$type().default({}),
223
199
  createdAt: timestamp3("createdAt", {
224
200
  mode: "date",
225
201
  fsp: 3
226
- }).default(sql2`CURRENT_TIMESTAMP(3)`).notNull(),
202
+ }).default(sql3`CURRENT_TIMESTAMP(3)`).notNull(),
227
203
  status: int2("status").default(0).notNull(),
228
204
  quantityAvailable: int2("quantityAvailable").default(-1).notNull()
229
205
  }, (table) => {
230
206
  return {
231
- productId: primaryKey2({
207
+ productId: primaryKey3({
232
208
  columns: [
233
209
  table.id
234
210
  ],
@@ -269,192 +245,317 @@ function getProductRelationsSchema2(mysqlTable) {
269
245
  }
270
246
  __name(getProductRelationsSchema2, "getProductRelationsSchema");
271
247
 
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
248
+ // src/lib/mysql/schemas/commerce/coupon.ts
249
+ function getCouponSchema(mysqlTable) {
250
+ return mysqlTable("coupons", {
251
+ id: varchar4("id", {
252
+ length: 191
280
253
  }).notNull(),
281
- position: double("position").notNull().default(0),
282
- metadata: json3("metadata").$type().default({}),
254
+ code: varchar4("code", {
255
+ length: 191
256
+ }),
283
257
  createdAt: timestamp4("createdAt", {
284
258
  mode: "date",
285
259
  fsp: 3
286
- }).default(sql3`CURRENT_TIMESTAMP(3)`),
287
- updatedAt: timestamp4("updatedAt", {
260
+ }).default(sql4`CURRENT_TIMESTAMP(3)`).notNull(),
261
+ expires: timestamp4("expires", {
288
262
  mode: "date",
289
263
  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
264
  }),
302
- contentResourceIdIdx: index2("contentResourceId_idx").on(crr.productId),
303
- resourceIdIdx: index2("resourceId_idx").on(crr.resourceId)
304
- }));
265
+ fields: json4("fields").$type().default({}),
266
+ maxUses: int3("maxUses").default(-1).notNull(),
267
+ default: boolean("default").default(false).notNull(),
268
+ merchantCouponId: varchar4("merchantCouponId", {
269
+ length: 191
270
+ }),
271
+ status: int3("status").default(0).notNull(),
272
+ usedCount: int3("usedCount").default(0).notNull(),
273
+ percentageDiscount: decimal2("percentageDiscount", {
274
+ precision: 3,
275
+ scale: 2
276
+ }).notNull(),
277
+ restrictedToProductId: varchar4("restrictedToProductId", {
278
+ length: 191
279
+ }),
280
+ bulkPurchaseId: varchar4("bulkPurchaseId", {
281
+ length: 191
282
+ })
283
+ }, (table) => {
284
+ return {
285
+ couponId: primaryKey4({
286
+ columns: [
287
+ table.id
288
+ ],
289
+ name: "Coupon_id"
290
+ }),
291
+ couponBulkPurchaseIdKey: unique("Coupon_bulkPurchaseId_key").on(table.bulkPurchaseId),
292
+ couponCodeKey: unique("Coupon_code_key").on(table.code)
293
+ };
294
+ });
305
295
  }
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, {
296
+ __name(getCouponSchema, "getCouponSchema");
297
+ function getCouponRelationsSchema(mysqlTable) {
298
+ const purchase = getPurchaseSchema(mysqlTable);
299
+ const coupon = getCouponSchema(mysqlTable);
300
+ const merchantCoupon = getMerchantCouponSchema(mysqlTable);
301
+ return relations4(coupon, ({ many, one }) => ({
302
+ bulkCouponPurchases: many(purchase, {
303
+ relationName: "redeemedBulkCoupon"
304
+ }),
305
+ merchantCoupon: one(merchantCoupon, {
313
306
  fields: [
314
- contentResourceProduct.productId
307
+ coupon.merchantCouponId
315
308
  ],
316
309
  references: [
317
- product.id
310
+ merchantCoupon.id
311
+ ],
312
+ relationName: "merchantCoupon"
313
+ }),
314
+ product: one(getProductSchema(mysqlTable), {
315
+ fields: [
316
+ coupon.restrictedToProductId
317
+ ],
318
+ references: [
319
+ getProductSchema(mysqlTable).id
318
320
  ],
319
321
  relationName: "product"
320
322
  }),
321
- resource: one(contentResource, {
323
+ bulkPurchase: one(purchase, {
322
324
  fields: [
323
- contentResourceProduct.resourceId
325
+ coupon.bulkPurchaseId
324
326
  ],
325
327
  references: [
326
- contentResource.id
328
+ purchase.id
327
329
  ],
328
- relationName: "resource"
330
+ relationName: "bulkPurchase"
329
331
  })
330
332
  }));
331
333
  }
332
- __name(getContentResourceProductRelationsSchema, "getContentResourceProductRelationsSchema");
334
+ __name(getCouponRelationsSchema, "getCouponRelationsSchema");
333
335
 
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";
337
- function getContentResourceResourceSchema(mysqlTable) {
338
- return mysqlTable("contentResourceResource", {
339
- resourceOfId: varchar5("resourceOfId", {
340
- length: 255
341
- }).notNull(),
342
- resourceId: varchar5("resourceId", {
343
- length: 255
336
+ // src/lib/mysql/schemas/commerce/purchase.ts
337
+ function getPurchaseSchema(mysqlTable) {
338
+ return mysqlTable("purchases", {
339
+ id: varchar5("id", {
340
+ length: 191
344
341
  }).notNull(),
345
- position: double2("position").notNull().default(0),
346
- metadata: json4("metadata").$type().default({}),
342
+ userId: varchar5("userId", {
343
+ length: 191
344
+ }),
347
345
  createdAt: timestamp5("createdAt", {
348
346
  mode: "date",
349
347
  fsp: 3
350
- }).default(sql4`CURRENT_TIMESTAMP(3)`),
351
- updatedAt: timestamp5("updatedAt", {
352
- mode: "date",
353
- fsp: 3
354
- }).default(sql4`CURRENT_TIMESTAMP(3)`),
355
- deletedAt: timestamp5("deletedAt", {
356
- mode: "date",
357
- fsp: 3
358
- })
359
- }, (crr) => ({
360
- pk: primaryKey4({
361
- columns: [
362
- crr.resourceOfId,
363
- crr.resourceId
364
- ]
348
+ }).default(sql5`CURRENT_TIMESTAMP(3)`).notNull(),
349
+ totalAmount: decimal3("totalAmount", {
350
+ precision: 65,
351
+ scale: 30
352
+ }).notNull(),
353
+ ipAddress: varchar5("ip_address", {
354
+ length: 191
365
355
  }),
366
- contentResourceIdIdx: index3("contentResourceId_idx").on(crr.resourceOfId),
367
- resourceIdIdx: index3("resourceId_idx").on(crr.resourceId)
368
- }));
356
+ city: varchar5("city", {
357
+ length: 191
358
+ }),
359
+ state: varchar5("state", {
360
+ length: 191
361
+ }),
362
+ country: varchar5("country", {
363
+ length: 191
364
+ }),
365
+ couponId: varchar5("couponId", {
366
+ length: 191
367
+ }),
368
+ productId: varchar5("productId", {
369
+ length: 191
370
+ }).notNull(),
371
+ merchantChargeId: varchar5("merchantChargeId", {
372
+ length: 191
373
+ }),
374
+ upgradedFromId: varchar5("upgradedFromId", {
375
+ length: 191
376
+ }),
377
+ status: varchar5("status", {
378
+ length: 191
379
+ }).default("Valid").notNull(),
380
+ bulkCouponId: varchar5("bulkCouponId", {
381
+ length: 191
382
+ }),
383
+ merchantSessionId: varchar5("merchantSessionId", {
384
+ length: 191
385
+ }),
386
+ redeemedBulkCouponId: varchar5("redeemedBulkCouponId", {
387
+ length: 191
388
+ }),
389
+ fields: json5("fields").$type().default({})
390
+ }, (table) => {
391
+ return {
392
+ purchaseId: primaryKey5({
393
+ columns: [
394
+ table.id
395
+ ],
396
+ name: "Purchase_id"
397
+ }),
398
+ purchaseUpgradedFromIdKey: unique2("Purchase_upgradedFromId_key").on(table.upgradedFromId)
399
+ };
400
+ });
369
401
  }
370
- __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
371
- function getContentResourceResourceRelationsSchema(mysqlTable) {
372
- const contentResource = getContentResourceSchema(mysqlTable);
373
- const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
374
- return relations5(contentResourceResource, ({ one }) => ({
375
- resourceOf: one(contentResource, {
402
+ __name(getPurchaseSchema, "getPurchaseSchema");
403
+ function getPurchaseRelationsSchema(mysqlTable) {
404
+ const purchases = getPurchaseSchema(mysqlTable);
405
+ const users = getUsersSchema(mysqlTable);
406
+ const products = getProductSchema(mysqlTable);
407
+ const merchantCharges = getMerchantChargeSchema(mysqlTable);
408
+ const merchantSessions = getMerchantSessionSchema(mysqlTable);
409
+ const coupons = getCouponSchema(mysqlTable);
410
+ return relations5(purchases, ({ many, one }) => ({
411
+ redeemedBulkCoupon: one(coupons, {
376
412
  fields: [
377
- contentResourceResource.resourceOfId
413
+ purchases.redeemedBulkCouponId
378
414
  ],
379
415
  references: [
380
- contentResource.id
416
+ coupons.id
381
417
  ],
382
- relationName: "resourceOf"
418
+ relationName: "redeemedBulkCoupon"
383
419
  }),
384
- resource: one(contentResource, {
420
+ user: one(users, {
385
421
  fields: [
386
- contentResourceResource.resourceId
422
+ purchases.userId
387
423
  ],
388
424
  references: [
389
- contentResource.id
425
+ users.id
390
426
  ],
391
- relationName: "resource"
427
+ relationName: "user"
428
+ }),
429
+ product: one(products, {
430
+ fields: [
431
+ purchases.productId
432
+ ],
433
+ references: [
434
+ products.id
435
+ ],
436
+ relationName: "product"
437
+ }),
438
+ bulkCoupon: one(coupons, {
439
+ fields: [
440
+ purchases.bulkCouponId
441
+ ],
442
+ references: [
443
+ coupons.id
444
+ ],
445
+ relationName: "bulkCoupon"
446
+ }),
447
+ merchantCharge: one(merchantCharges, {
448
+ fields: [
449
+ purchases.merchantChargeId
450
+ ],
451
+ references: [
452
+ merchantCharges.id
453
+ ],
454
+ relationName: "merchantCharge"
455
+ }),
456
+ merchantSession: one(merchantSessions, {
457
+ fields: [
458
+ purchases.merchantSessionId
459
+ ],
460
+ references: [
461
+ merchantSessions.id
462
+ ],
463
+ relationName: "merchantSession"
392
464
  })
393
465
  }));
394
466
  }
395
- __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
467
+ __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
396
468
 
397
- // src/lib/mysql/schemas/content/content-resource.ts
398
- function getContentResourceSchema(mysqlTable) {
399
- return mysqlTable("contentResource", {
469
+ // src/lib/mysql/schemas/communication/communication-preferences.ts
470
+ import { relations as relations6 } from "drizzle-orm";
471
+ import { boolean as boolean2, index as index2, mysqlEnum, timestamp as timestamp6, varchar as varchar6 } from "drizzle-orm/mysql-core";
472
+ function getCommunicationPreferencesSchema(mysqlTable) {
473
+ return mysqlTable("communicationPreference", {
400
474
  id: varchar6("id", {
401
475
  length: 255
402
476
  }).notNull().primaryKey(),
403
- type: varchar6("type", {
477
+ userId: varchar6("userId", {
404
478
  length: 255
405
479
  }).notNull(),
406
- createdById: varchar6("createdById", {
480
+ channelId: varchar6("channelId", {
407
481
  length: 255
408
482
  }).notNull(),
409
- fields: json5("fields").$type().default({}),
483
+ preferenceLevel: mysqlEnum("preferenceLevel", [
484
+ "low",
485
+ "medium",
486
+ "high"
487
+ ]).notNull().default("medium"),
488
+ preferenceTypeId: varchar6("preferenceTypeId", {
489
+ length: 255
490
+ }).notNull(),
491
+ active: boolean2("active").notNull().default(true),
410
492
  createdAt: timestamp6("createdAt", {
411
493
  mode: "date",
412
494
  fsp: 3
413
- }).default(sql5`CURRENT_TIMESTAMP(3)`),
495
+ }).defaultNow(),
496
+ optInAt: timestamp6("optInAt", {
497
+ mode: "date",
498
+ fsp: 3
499
+ }),
500
+ optOutAt: timestamp6("optOutAt", {
501
+ mode: "date",
502
+ fsp: 3
503
+ }),
414
504
  updatedAt: timestamp6("updatedAt", {
415
505
  mode: "date",
416
506
  fsp: 3
417
- }).default(sql5`CURRENT_TIMESTAMP(3)`),
507
+ }).defaultNow(),
418
508
  deletedAt: timestamp6("deletedAt", {
419
509
  mode: "date",
420
510
  fsp: 3
421
511
  })
422
- }, (cm) => ({
423
- typeIdx: index4("type_idx").on(cm.type),
424
- createdByIdx: index4("createdById_idx").on(cm.createdById),
425
- createdAtIdx: index4("createdAt_idx").on(cm.createdAt)
512
+ }, (cp) => ({
513
+ userIdIdx: index2("userId_idx").on(cp.userId),
514
+ preferenceTypeIdx: index2("preferenceTypeId_idx").on(cp.preferenceTypeId),
515
+ channelIdIdx: index2("channelId_idx").on(cp.channelId)
426
516
  }));
427
517
  }
428
- __name(getContentResourceSchema, "getContentResourceSchema");
429
- function getContentResourceRelationsSchema(mysqlTable) {
430
- const contentResource = getContentResourceSchema(mysqlTable);
518
+ __name(getCommunicationPreferencesSchema, "getCommunicationPreferencesSchema");
519
+ function getCommunicationPreferencesRelationsSchema(mysqlTable) {
520
+ const communicationPreferences = getCommunicationPreferencesSchema(mysqlTable);
431
521
  const users = getUsersSchema(mysqlTable);
432
- const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
433
- const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
434
- return relations6(contentResource, ({ one, many }) => ({
435
- createdBy: one(users, {
522
+ const communicationChannel = getCommunicationChannelSchema(mysqlTable);
523
+ const communicationPreferenceTypes = getCommunicationPreferenceTypesSchema(mysqlTable);
524
+ return relations6(communicationPreferences, ({ one }) => ({
525
+ user: one(users, {
436
526
  fields: [
437
- contentResource.createdById
527
+ communicationPreferences.userId
438
528
  ],
439
529
  references: [
440
530
  users.id
441
531
  ],
442
532
  relationName: "user"
443
533
  }),
444
- resources: many(contentResourceResource, {
445
- relationName: "resourceOf"
446
- }),
447
- resourceOf: many(contentResourceResource, {
448
- relationName: "resource"
534
+ channel: one(communicationChannel, {
535
+ fields: [
536
+ communicationPreferences.channelId
537
+ ],
538
+ references: [
539
+ communicationChannel.id
540
+ ],
541
+ relationName: "channel"
449
542
  }),
450
- resourceProducts: many(contentResourceProduct, {
451
- relationName: "resource"
543
+ preferenceType: one(communicationPreferenceTypes, {
544
+ fields: [
545
+ communicationPreferences.preferenceTypeId
546
+ ],
547
+ references: [
548
+ communicationPreferenceTypes.id
549
+ ],
550
+ relationName: "preferenceType"
452
551
  })
453
552
  }));
454
553
  }
455
- __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
554
+ __name(getCommunicationPreferencesRelationsSchema, "getCommunicationPreferencesRelationsSchema");
456
555
 
457
556
  // src/lib/mysql/schemas/content/content-contributions.ts
557
+ import { relations as relations7 } from "drizzle-orm";
558
+ import { boolean as boolean3, index as index3, timestamp as timestamp7, varchar as varchar7 } from "drizzle-orm/mysql-core";
458
559
  function getContentContributionsSchema(mysqlTable) {
459
560
  return mysqlTable("contentContribution", {
460
561
  id: varchar7("id", {
@@ -469,7 +570,7 @@ function getContentContributionsSchema(mysqlTable) {
469
570
  contributionTypeId: varchar7("contributionTypeId", {
470
571
  length: 255
471
572
  }).notNull(),
472
- active: boolean2("active").notNull().default(true),
573
+ active: boolean3("active").notNull().default(true),
473
574
  createdAt: timestamp7("createdAt", {
474
575
  mode: "date",
475
576
  fsp: 3
@@ -483,9 +584,9 @@ function getContentContributionsSchema(mysqlTable) {
483
584
  fsp: 3
484
585
  })
485
586
  }, (cc) => ({
486
- userIdIdx: index5("userId_idx").on(cc.userId),
487
- contentIdIdx: index5("contentId_idx").on(cc.contentId),
488
- contributionTypeIdIdx: index5("contributionTypeId_idx").on(cc.contributionTypeId)
587
+ userIdIdx: index3("userId_idx").on(cc.userId),
588
+ contentIdIdx: index3("contentId_idx").on(cc.contentId),
589
+ contributionTypeIdIdx: index3("contributionTypeId_idx").on(cc.contributionTypeId)
489
590
  }));
490
591
  }
491
592
  __name(getContentContributionsSchema, "getContentContributionsSchema");
@@ -528,7 +629,7 @@ __name(getContentContributionRelationsSchema, "getContentContributionRelationsSc
528
629
 
529
630
  // src/lib/mysql/schemas/auth/accounts.ts
530
631
  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";
632
+ import { index as index4, int as int4, primaryKey as primaryKey6, text, varchar as varchar8 } from "drizzle-orm/mysql-core";
532
633
  function getAccountsSchema(mysqlTable) {
533
634
  return mysqlTable("account", {
534
635
  userId: varchar8("userId", {
@@ -547,7 +648,7 @@ function getAccountsSchema(mysqlTable) {
547
648
  access_token: text("access_token"),
548
649
  oauth_token: text("oauth_token"),
549
650
  oauth_token_secret: text("oauth_token_secret"),
550
- expires_at: int3("expires_at"),
651
+ expires_at: int4("expires_at"),
551
652
  token_type: varchar8("token_type", {
552
653
  length: 255
553
654
  }),
@@ -558,15 +659,15 @@ function getAccountsSchema(mysqlTable) {
558
659
  session_state: varchar8("session_state", {
559
660
  length: 255
560
661
  }),
561
- refresh_token_expires_in: int3("refresh_token_expires_in")
662
+ refresh_token_expires_in: int4("refresh_token_expires_in")
562
663
  }, (account) => ({
563
- pk: primaryKey5({
664
+ pk: primaryKey6({
564
665
  columns: [
565
666
  account.provider,
566
667
  account.providerAccountId
567
668
  ]
568
669
  }),
569
- userIdIdx: index6("userId_idx").on(account.userId)
670
+ userIdIdx: index4("userId_idx").on(account.userId)
570
671
  }));
571
672
  }
572
673
  __name(getAccountsSchema, "getAccountsSchema");
@@ -589,7 +690,7 @@ __name(getAccountsRelationsSchema, "getAccountsRelationsSchema");
589
690
 
590
691
  // src/lib/mysql/schemas/auth/user-permissions.ts
591
692
  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";
693
+ import { boolean as boolean4, index as index5, primaryKey as primaryKey7, timestamp as timestamp8, varchar as varchar9 } from "drizzle-orm/mysql-core";
593
694
  function getUserPermissionsSchema(mysqlTable) {
594
695
  return mysqlTable("userPermission", {
595
696
  userId: varchar9("userId", {
@@ -598,7 +699,7 @@ function getUserPermissionsSchema(mysqlTable) {
598
699
  permissionId: varchar9("permissionId", {
599
700
  length: 255
600
701
  }).notNull(),
601
- active: boolean3("active").notNull().default(true),
702
+ active: boolean4("active").notNull().default(true),
602
703
  createdAt: timestamp8("createdAt", {
603
704
  mode: "date",
604
705
  fsp: 3
@@ -612,14 +713,14 @@ function getUserPermissionsSchema(mysqlTable) {
612
713
  fsp: 3
613
714
  })
614
715
  }, (up) => ({
615
- pk: primaryKey6({
716
+ pk: primaryKey7({
616
717
  columns: [
617
718
  up.userId,
618
719
  up.permissionId
619
720
  ]
620
721
  }),
621
- userIdIdx: index7("userId_idx").on(up.userId),
622
- permissionIdIdx: index7("permissionId_idx").on(up.permissionId)
722
+ userIdIdx: index5("userId_idx").on(up.userId),
723
+ permissionIdIdx: index5("permissionId_idx").on(up.permissionId)
623
724
  }));
624
725
  }
625
726
  __name(getUserPermissionsSchema, "getUserPermissionsSchema");
@@ -652,11 +753,11 @@ __name(getUserPermissionsRelationsSchema, "getUserPermissionsRelationsSchema");
652
753
 
653
754
  // src/lib/mysql/schemas/auth/user-roles.ts
654
755
  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";
756
+ import { boolean as boolean6, index as index7, primaryKey as primaryKey8, timestamp as timestamp10, varchar as varchar11 } from "drizzle-orm/mysql-core";
656
757
 
657
758
  // src/lib/mysql/schemas/auth/roles.ts
658
759
  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";
760
+ import { boolean as boolean5, index as index6, text as text2, timestamp as timestamp9, varchar as varchar10 } from "drizzle-orm/mysql-core";
660
761
  function getRolesSchema(mysqlTable) {
661
762
  return mysqlTable("role", {
662
763
  id: varchar10("id", {
@@ -666,7 +767,7 @@ function getRolesSchema(mysqlTable) {
666
767
  length: 255
667
768
  }).notNull().unique(),
668
769
  description: text2("description"),
669
- active: boolean4("active").notNull().default(true),
770
+ active: boolean5("active").notNull().default(true),
670
771
  createdAt: timestamp9("createdAt", {
671
772
  mode: "date",
672
773
  fsp: 3
@@ -680,7 +781,7 @@ function getRolesSchema(mysqlTable) {
680
781
  fsp: 3
681
782
  })
682
783
  }, (role) => ({
683
- nameIdx: index8("name_idx").on(role.name)
784
+ nameIdx: index6("name_idx").on(role.name)
684
785
  }));
685
786
  }
686
787
  __name(getRolesSchema, "getRolesSchema");
@@ -704,7 +805,7 @@ function getUserRolesSchema(mysqlTable) {
704
805
  roleId: varchar11("roleId", {
705
806
  length: 255
706
807
  }).notNull(),
707
- active: boolean5("active").notNull().default(true),
808
+ active: boolean6("active").notNull().default(true),
708
809
  createdAt: timestamp10("createdAt", {
709
810
  mode: "date",
710
811
  fsp: 3
@@ -718,14 +819,14 @@ function getUserRolesSchema(mysqlTable) {
718
819
  fsp: 3
719
820
  })
720
821
  }, (ur) => ({
721
- pk: primaryKey7({
822
+ pk: primaryKey8({
722
823
  columns: [
723
824
  ur.userId,
724
825
  ur.roleId
725
826
  ]
726
827
  }),
727
- userIdIdx: index9("userId_idx").on(ur.userId),
728
- roleIdIdx: index9("roleId_idx").on(ur.roleId)
828
+ userIdIdx: index7("userId_idx").on(ur.userId),
829
+ roleIdIdx: index7("roleId_idx").on(ur.roleId)
729
830
  }));
730
831
  }
731
832
  __name(getUserRolesSchema, "getUserRolesSchema");
@@ -784,9 +885,9 @@ function getUsersSchema(mysqlTable) {
784
885
  fsp: 3
785
886
  }).default(sql6`CURRENT_TIMESTAMP(3)`)
786
887
  }, (user) => ({
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)
888
+ emailIdx: index8("email_idx").on(user.email),
889
+ roleIdx: index8("role_idx").on(user.role),
890
+ createdAtIdx: index8("created_at_idx").on(user.createdAt)
790
891
  }));
791
892
  }
792
893
  __name(getUsersSchema, "getUsersSchema");
@@ -825,202 +926,128 @@ function getUsersRelationsSchema(mysqlTable) {
825
926
  }
826
927
  __name(getUsersRelationsSchema, "getUsersRelationsSchema");
827
928
 
828
- // src/lib/mysql/schemas/commerce/purchase.ts
829
- function getPurchaseSchema(mysqlTable) {
830
- return mysqlTable("purchases", {
929
+ // src/lib/mysql/schemas/content/content-resource.ts
930
+ function getContentResourceSchema(mysqlTable) {
931
+ return mysqlTable("contentResource", {
831
932
  id: varchar13("id", {
832
- length: 191
933
+ length: 255
934
+ }).notNull().primaryKey(),
935
+ type: varchar13("type", {
936
+ length: 255
833
937
  }).notNull(),
834
- userId: varchar13("userId", {
835
- length: 191
836
- }),
938
+ createdById: varchar13("createdById", {
939
+ length: 255
940
+ }).notNull(),
941
+ fields: json6("fields").$type().default({}),
837
942
  createdAt: timestamp12("createdAt", {
838
943
  mode: "date",
839
944
  fsp: 3
840
- }).default(sql7`CURRENT_TIMESTAMP(3)`).notNull(),
841
- totalAmount: decimal2("totalAmount", {
842
- precision: 65,
843
- scale: 30
844
- }).notNull(),
845
- ipAddress: varchar13("ip_address", {
846
- length: 191
847
- }),
848
- city: varchar13("city", {
849
- length: 191
850
- }),
851
- state: varchar13("state", {
852
- length: 191
853
- }),
854
- country: varchar13("country", {
855
- length: 191
856
- }),
857
- couponId: varchar13("couponId", {
858
- length: 191
859
- }),
860
- productId: varchar13("productId", {
861
- length: 191
862
- }).notNull(),
863
- merchantChargeId: varchar13("merchantChargeId", {
864
- length: 191
865
- }),
866
- upgradedFromId: varchar13("upgradedFromId", {
867
- length: 191
868
- }),
869
- status: varchar13("status", {
870
- length: 191
871
- }).default("Valid").notNull(),
872
- bulkCouponId: varchar13("bulkCouponId", {
873
- length: 191
874
- }),
875
- merchantSessionId: varchar13("merchantSessionId", {
876
- length: 191
877
- }),
878
- redeemedBulkCouponId: varchar13("redeemedBulkCouponId", {
879
- length: 191
880
- }),
881
- fields: json6("fields").$type().default({})
882
- }, (table) => {
883
- return {
884
- purchaseId: primaryKey8({
885
- columns: [
886
- table.id
887
- ],
888
- name: "Purchase_id"
889
- }),
890
- purchaseUpgradedFromIdKey: unique("Purchase_upgradedFromId_key").on(table.upgradedFromId)
891
- };
892
- });
945
+ }).default(sql7`CURRENT_TIMESTAMP(3)`),
946
+ updatedAt: timestamp12("updatedAt", {
947
+ mode: "date",
948
+ fsp: 3
949
+ }).default(sql7`CURRENT_TIMESTAMP(3)`),
950
+ deletedAt: timestamp12("deletedAt", {
951
+ mode: "date",
952
+ fsp: 3
953
+ })
954
+ }, (cm) => ({
955
+ typeIdx: index9("type_idx").on(cm.type),
956
+ createdByIdx: index9("createdById_idx").on(cm.createdById),
957
+ createdAtIdx: index9("createdAt_idx").on(cm.createdAt)
958
+ }));
893
959
  }
894
- __name(getPurchaseSchema, "getPurchaseSchema");
895
- function getPurchaseRelationsSchema(mysqlTable) {
896
- const purchases = getPurchaseSchema(mysqlTable);
960
+ __name(getContentResourceSchema, "getContentResourceSchema");
961
+ function getContentResourceRelationsSchema(mysqlTable) {
962
+ const contentResource = getContentResourceSchema(mysqlTable);
897
963
  const users = getUsersSchema(mysqlTable);
898
- const products = getProductSchema(mysqlTable);
899
- const merchantCharges = getMerchantChargeSchema(mysqlTable);
900
- const merchantSessions = getMerchantSessionSchema(mysqlTable);
901
- const coupons = getCouponSchema(mysqlTable);
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
- }),
912
- user: one(users, {
964
+ const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
965
+ const contentResourceProduct = getContentResourceProductSchema(mysqlTable);
966
+ return relations13(contentResource, ({ one, many }) => ({
967
+ createdBy: one(users, {
913
968
  fields: [
914
- purchases.userId
969
+ contentResource.createdById
915
970
  ],
916
971
  references: [
917
972
  users.id
918
973
  ],
919
974
  relationName: "user"
920
975
  }),
921
- product: one(products, {
922
- fields: [
923
- purchases.productId
924
- ],
925
- references: [
926
- products.id
927
- ],
928
- relationName: "product"
929
- }),
930
- bulkCoupon: one(coupons, {
931
- fields: [
932
- purchases.bulkCouponId
933
- ],
934
- references: [
935
- coupons.id
936
- ],
937
- relationName: "bulkCoupon"
976
+ resources: many(contentResourceResource, {
977
+ relationName: "resourceOf"
938
978
  }),
939
- merchantCharge: one(merchantCharges, {
940
- fields: [
941
- purchases.merchantChargeId
942
- ],
943
- references: [
944
- merchantCharges.id
945
- ],
946
- relationName: "merchantCharge"
979
+ resourceOf: many(contentResourceResource, {
980
+ relationName: "resource"
947
981
  }),
948
- merchantSession: one(merchantSessions, {
949
- fields: [
950
- purchases.merchantSessionId
951
- ],
952
- references: [
953
- merchantSessions.id
954
- ],
955
- relationName: "merchantSession"
982
+ resourceProducts: many(contentResourceProduct, {
983
+ relationName: "resource"
956
984
  })
957
985
  }));
958
986
  }
959
- __name(getPurchaseRelationsSchema, "getPurchaseRelationsSchema");
987
+ __name(getContentResourceRelationsSchema, "getContentResourceRelationsSchema");
960
988
 
961
- // src/lib/mysql/schemas/commerce/coupon.ts
962
- function getCouponSchema(mysqlTable) {
963
- return mysqlTable("coupons", {
964
- id: varchar14("id", {
965
- length: 191
989
+ // src/lib/mysql/schemas/content/content-resource-resource.ts
990
+ function getContentResourceResourceSchema(mysqlTable) {
991
+ return mysqlTable("contentResourceResource", {
992
+ resourceOfId: varchar14("resourceOfId", {
993
+ length: 255
966
994
  }).notNull(),
967
- code: varchar14("code", {
968
- length: 191
969
- }),
995
+ resourceId: varchar14("resourceId", {
996
+ length: 255
997
+ }).notNull(),
998
+ position: double2("position").notNull().default(0),
999
+ metadata: json7("metadata").$type().default({}),
970
1000
  createdAt: timestamp13("createdAt", {
971
1001
  mode: "date",
972
1002
  fsp: 3
973
- }).default(sql8`CURRENT_TIMESTAMP(3)`).notNull(),
974
- expires: timestamp13("expires", {
1003
+ }).default(sql8`CURRENT_TIMESTAMP(3)`),
1004
+ updatedAt: timestamp13("updatedAt", {
1005
+ mode: "date",
1006
+ fsp: 3
1007
+ }).default(sql8`CURRENT_TIMESTAMP(3)`),
1008
+ deletedAt: timestamp13("deletedAt", {
975
1009
  mode: "date",
976
1010
  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
1011
  })
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
- });
1012
+ }, (crr) => ({
1013
+ pk: primaryKey9({
1014
+ columns: [
1015
+ crr.resourceOfId,
1016
+ crr.resourceId
1017
+ ]
1018
+ }),
1019
+ contentResourceIdIdx: index10("contentResourceId_idx").on(crr.resourceOfId),
1020
+ resourceIdIdx: index10("resourceId_idx").on(crr.resourceId)
1021
+ }));
1008
1022
  }
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"
1023
+ __name(getContentResourceResourceSchema, "getContentResourceResourceSchema");
1024
+ function getContentResourceResourceRelationsSchema(mysqlTable) {
1025
+ const contentResource = getContentResourceSchema(mysqlTable);
1026
+ const contentResourceResource = getContentResourceResourceSchema(mysqlTable);
1027
+ return relations14(contentResourceResource, ({ one }) => ({
1028
+ resourceOf: one(contentResource, {
1029
+ fields: [
1030
+ contentResourceResource.resourceOfId
1031
+ ],
1032
+ references: [
1033
+ contentResource.id
1034
+ ],
1035
+ relationName: "resourceOf"
1036
+ }),
1037
+ resource: one(contentResource, {
1038
+ fields: [
1039
+ contentResourceResource.resourceId
1040
+ ],
1041
+ references: [
1042
+ contentResource.id
1043
+ ],
1044
+ relationName: "resource"
1016
1045
  })
1017
1046
  }));
1018
1047
  }
1019
- __name(getCouponRelationsSchema, "getCouponRelationsSchema");
1048
+ __name(getContentResourceResourceRelationsSchema, "getContentResourceResourceRelationsSchema");
1020
1049
 
1021
1050
  export {
1022
- getCouponSchema,
1023
- getCouponRelationsSchema,
1024
1051
  getContentResourceResourceSchema,
1025
1052
  getContentResourceResourceRelationsSchema,
1026
1053
  getContentResourceSchema,
@@ -1031,6 +1058,8 @@ export {
1031
1058
  getProductRelationsSchema,
1032
1059
  getProductSchema,
1033
1060
  getProductRelationsSchema2,
1061
+ getCouponSchema,
1062
+ getCouponRelationsSchema,
1034
1063
  getPurchaseSchema,
1035
1064
  getPurchaseRelationsSchema,
1036
1065
  getCommunicationPreferencesSchema,
@@ -1048,4 +1077,4 @@ export {
1048
1077
  getAccountsSchema,
1049
1078
  getAccountsRelationsSchema
1050
1079
  };
1051
- //# sourceMappingURL=chunk-3RJVKNXB.js.map
1080
+ //# sourceMappingURL=chunk-4PJWD6YK.js.map