@coursebuilder/adapter-drizzle 0.1.1 → 0.1.3

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