@coursebuilder/adapter-drizzle 0.0.6 → 0.1.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 (161) hide show
  1. package/dist/{chunk-ICL7XZ2Y.js → chunk-27KREOQW.js} +4 -4
  2. package/dist/{chunk-KVN3JV7C.js → chunk-44VDBYFU.js} +6 -6
  3. package/dist/{chunk-VEFCDI73.js → chunk-75V6F7LZ.js} +12 -12
  4. package/dist/{chunk-SQR6UWVO.js → chunk-7LAAAEVE.js} +165 -11
  5. package/dist/{chunk-TA6VLEV5.js → chunk-AFQGYW7Z.js} +4 -4
  6. package/dist/{chunk-US2EXVMI.js → chunk-CPE4P26C.js} +4 -4
  7. package/dist/chunk-GVURJJRV.js +4679 -0
  8. package/dist/{chunk-VZABQCFH.js → chunk-IN6G6MTW.js} +4 -4
  9. package/dist/{chunk-4HDU7QIB.js → chunk-ISURSRBK.js} +345 -324
  10. package/dist/{chunk-AIDEJDKJ.js → chunk-JKRFXYAR.js} +4 -4
  11. package/dist/{chunk-KI47TR7F.js → chunk-L2TQQYG4.js} +4 -4
  12. package/dist/{chunk-UY3DVPP3.js → chunk-LSOPFMDB.js} +4 -4
  13. package/dist/{chunk-PFN4YUQZ.js → chunk-MYRB6GLJ.js} +4 -3
  14. package/dist/chunk-NZDLUQWP.js +44 -0
  15. package/dist/{chunk-22KIKVBY.js → chunk-O2KKII62.js} +163 -10
  16. package/dist/{chunk-MBQ3TMHH.js → chunk-OIUOQ3TT.js} +4 -4
  17. package/dist/chunk-QZOBGJSV.js +78 -0
  18. package/dist/chunk-RVYJDDZD.js +75 -0
  19. package/dist/chunk-V6QEDDFG.js +49 -0
  20. package/dist/{chunk-FRNVLW7N.js → chunk-Y34AIPU7.js} +34 -303
  21. package/dist/index.js +21 -17
  22. package/dist/lib/mysql/index.cjs +5896 -1367
  23. package/dist/lib/mysql/index.cjs.map +1 -1
  24. package/dist/lib/mysql/index.d.ts +325 -129
  25. package/dist/lib/mysql/index.js +19 -15
  26. package/dist/lib/mysql/schemas/auth/accounts.cjs +73 -57
  27. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  28. package/dist/lib/mysql/schemas/auth/accounts.js +7 -1
  29. package/dist/lib/mysql/schemas/auth/permissions.cjs +9 -98
  30. package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
  31. package/dist/lib/mysql/schemas/auth/permissions.d.ts +1 -3
  32. package/dist/lib/mysql/schemas/auth/permissions.js +1 -3
  33. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +64 -43
  34. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  35. package/dist/lib/mysql/schemas/auth/role-permissions.js +8 -1
  36. package/dist/lib/mysql/schemas/auth/roles.cjs +63 -46
  37. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  38. package/dist/lib/mysql/schemas/auth/roles.js +7 -1
  39. package/dist/lib/mysql/schemas/auth/sessions.cjs +63 -47
  40. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  41. package/dist/lib/mysql/schemas/auth/sessions.js +8 -2
  42. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +97 -82
  43. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/auth/user-permissions.js +7 -1
  45. package/dist/lib/mysql/schemas/auth/user-roles.cjs +65 -48
  46. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  47. package/dist/lib/mysql/schemas/auth/user-roles.js +7 -1
  48. package/dist/lib/mysql/schemas/auth/users.cjs +233 -132
  49. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  50. package/dist/lib/mysql/schemas/auth/users.d.ts +2 -1
  51. package/dist/lib/mysql/schemas/auth/users.js +7 -1
  52. package/dist/lib/mysql/schemas/commerce/coupon.cjs +4 -4
  53. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  54. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +6 -6
  55. package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
  56. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +2 -2
  57. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
  58. package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +3 -3
  59. package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
  60. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +2 -2
  61. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  62. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +3 -3
  63. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +1 -1
  64. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +2 -2
  65. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
  66. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +3 -3
  67. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
  68. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +2 -2
  69. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
  70. package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +3 -3
  71. package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
  72. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +2 -2
  73. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
  74. package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +3 -3
  75. package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
  76. package/dist/lib/mysql/schemas/commerce/price.cjs +2 -2
  77. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  78. package/dist/lib/mysql/schemas/commerce/price.d.ts +3 -3
  79. package/dist/lib/mysql/schemas/commerce/price.js +1 -1
  80. package/dist/lib/mysql/schemas/commerce/product.cjs +2 -2
  81. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  82. package/dist/lib/mysql/schemas/commerce/product.d.ts +3 -3
  83. package/dist/lib/mysql/schemas/commerce/product.js +1 -1
  84. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +10 -10
  85. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  86. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +15 -15
  87. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +1 -1
  88. package/dist/lib/mysql/schemas/commerce/purchase.cjs +320 -21
  89. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  90. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +12 -4
  91. package/dist/lib/mysql/schemas/commerce/purchase.js +11 -1
  92. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +130 -0
  93. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -0
  94. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +101 -0
  95. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -0
  96. package/dist/lib/mysql/schemas/commerce/upgradable-products.js.map +1 -0
  97. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +90 -72
  98. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  99. package/dist/lib/mysql/schemas/communication/communication-preferences.js +7 -1
  100. package/dist/lib/mysql/schemas/content/content-contributions.cjs +94 -76
  101. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  102. package/dist/lib/mysql/schemas/content/content-contributions.js +7 -1
  103. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +68 -53
  104. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  105. package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +1 -1
  106. package/dist/lib/mysql/schemas/content/content-resource-resource.js +7 -1
  107. package/dist/lib/mysql/schemas/content/content-resource.cjs +81 -103
  108. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  109. package/dist/lib/mysql/schemas/content/content-resource.d.ts +0 -1
  110. package/dist/lib/mysql/schemas/content/content-resource.js +7 -1
  111. package/dist/lib/mysql/schemas/content/contribution-types.cjs +11 -102
  112. package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
  113. package/dist/lib/mysql/schemas/content/contribution-types.d.ts +1 -3
  114. package/dist/lib/mysql/schemas/content/contribution-types.js +1 -3
  115. package/dist/lib/mysql/schemas/content/resource-progress.cjs +3 -3
  116. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  117. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +9 -9
  118. package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
  119. package/dist/lib/mysql/utils.cjs +51 -0
  120. package/dist/lib/mysql/utils.cjs.map +1 -0
  121. package/dist/lib/mysql/utils.d.ts +12 -0
  122. package/dist/lib/mysql/utils.js +29 -0
  123. package/dist/lib/mysql/utils.js.map +1 -0
  124. package/dist/lib/pg.cjs +4289 -9
  125. package/dist/lib/pg.cjs.map +1 -1
  126. package/dist/lib/pg.d.ts +91 -0
  127. package/dist/lib/pg.js +2 -1
  128. package/dist/lib/sqlite.cjs +4285 -8
  129. package/dist/lib/sqlite.cjs.map +1 -1
  130. package/dist/lib/sqlite.js +2 -1
  131. package/package.json +7 -5
  132. package/src/lib/mysql/index.ts +688 -34
  133. package/src/lib/mysql/schemas/auth/accounts.ts +5 -1
  134. package/src/lib/mysql/schemas/auth/permissions.ts +1 -3
  135. package/src/lib/mysql/schemas/auth/role-permissions.ts +2 -0
  136. package/src/lib/mysql/schemas/auth/roles.ts +1 -1
  137. package/src/lib/mysql/schemas/auth/sessions.ts +5 -1
  138. package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -0
  139. package/src/lib/mysql/schemas/auth/user-roles.ts +2 -0
  140. package/src/lib/mysql/schemas/auth/users.ts +23 -6
  141. package/src/lib/mysql/schemas/commerce/coupon.ts +3 -3
  142. package/src/lib/mysql/schemas/commerce/merchant-account.ts +2 -2
  143. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +2 -2
  144. package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -2
  145. package/src/lib/mysql/schemas/commerce/merchant-price.ts +2 -2
  146. package/src/lib/mysql/schemas/commerce/merchant-product.ts +2 -2
  147. package/src/lib/mysql/schemas/commerce/price.ts +2 -2
  148. package/src/lib/mysql/schemas/commerce/product.ts +2 -2
  149. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +6 -6
  150. package/src/lib/mysql/schemas/commerce/purchase.ts +49 -3
  151. package/src/lib/mysql/schemas/commerce/upgradable-products.ts +58 -0
  152. package/src/lib/mysql/schemas/communication/communication-preferences.ts +3 -0
  153. package/src/lib/mysql/schemas/content/content-contributions.ts +3 -0
  154. package/src/lib/mysql/schemas/content/content-resource-resource.ts +1 -1
  155. package/src/lib/mysql/schemas/content/content-resource.ts +1 -2
  156. package/src/lib/mysql/schemas/content/contribution-types.ts +1 -4
  157. package/src/lib/mysql/schemas/content/resource-progress.ts +3 -3
  158. package/src/lib/mysql/utils.ts +23 -0
  159. package/src/lib/pg.ts +298 -16
  160. package/src/lib/sqlite.ts +290 -15
  161. package/dist/chunk-BRGTUNY2.js +0 -78
@@ -1,90 +1,7 @@
1
- import {
2
- getResourceProgressSchema
3
- } from "./chunk-UY3DVPP3.js";
4
- import {
5
- getPurchaseUserTransferSchema
6
- } from "./chunk-VEFCDI73.js";
7
- import {
8
- getPurchaseSchema
9
- } from "./chunk-BRGTUNY2.js";
10
- import {
11
- getMerchantChargeSchema
12
- } from "./chunk-ICL7XZ2Y.js";
13
- import {
14
- getMerchantCouponSchema
15
- } from "./chunk-JD4KFACE.js";
16
- import {
17
- getMerchantCustomerSchema
18
- } from "./chunk-MBQ3TMHH.js";
19
- import {
20
- getMerchantPriceSchema
21
- } from "./chunk-KI47TR7F.js";
22
- import {
23
- getMerchantProductSchema
24
- } from "./chunk-AIDEJDKJ.js";
25
- import {
26
- getMerchantSessionSchema
27
- } from "./chunk-H4MXNDWO.js";
28
- import {
29
- getPriceSchema
30
- } from "./chunk-TA6VLEV5.js";
31
- import {
32
- getProductSchema
33
- } from "./chunk-US2EXVMI.js";
34
- import {
35
- getSessionRelationsSchema,
36
- getSessionsSchema
37
- } from "./chunk-PFN4YUQZ.js";
38
- import {
39
- getVerificationTokensSchema
40
- } from "./chunk-TMQIGK3N.js";
41
- import {
42
- getCouponSchema
43
- } from "./chunk-KVN3JV7C.js";
44
- import {
45
- getMerchantAccountSchema
46
- } from "./chunk-VZABQCFH.js";
47
- import {
48
- getAccountsRelationsSchema,
49
- getAccountsSchema,
50
- getCommunicationPreferencesRelationsSchema,
51
- getCommunicationPreferencesSchema,
52
- getContentContributionRelationsSchema,
53
- getContentContributionsSchema,
54
- getContentResourceRelationsSchema,
55
- getContentResourceResourceRelationsSchema,
56
- getContentResourceResourceSchema,
57
- getContentResourceSchema,
58
- getContributionTypesRelationsSchema,
59
- getContributionTypesSchema,
60
- getPermissionsRelationsSchema,
61
- getPermissionsSchema,
62
- getRolePermissionsRelationsSchema,
63
- getRolePermissionsSchema,
64
- getRolesRelationsSchema,
65
- getRolesSchema,
66
- getUserPermissionsRelationsSchema,
67
- getUserPermissionsSchema,
68
- getUserRolesRelationsSchema,
69
- getUserRolesSchema,
70
- getUsersRelationsSchema,
71
- getUsersSchema
72
- } from "./chunk-4HDU7QIB.js";
73
- import {
74
- getCommunicationChannelSchema
75
- } from "./chunk-6CBAFOL3.js";
76
- import {
77
- getCommunicationPreferenceTypesSchema
78
- } from "./chunk-SFJM6FKE.js";
79
1
  import {
80
2
  __name
81
3
  } from "./chunk-VNI36MMC.js";
82
4
 
83
- // src/lib/mysql/index.ts
84
- import { addSeconds, isAfter } from "date-fns";
85
- import { and, eq, sql } from "drizzle-orm";
86
- import { mysqlTable as defaultMySqlTableFn } from "drizzle-orm/mysql-core";
87
-
88
5
  // ../core/dist/chunk-DFHEFTJZ.js
89
6
  var __defProp = Object.defineProperty;
90
7
  var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", {
@@ -4179,228 +4096,42 @@ var z = /* @__PURE__ */ Object.freeze({
4179
4096
  ZodError
4180
4097
  });
4181
4098
 
4182
- // ../core/dist/schemas/video-resource.js
4183
- var VideoResourceSchema = z.object({
4099
+ // ../core/dist/schemas/content-resource-schema.js
4100
+ var ContentResourceResourceSchema = z.object({
4101
+ resourceId: z.string(),
4102
+ resourceOfId: z.string(),
4103
+ position: z.number().default(0),
4104
+ metadata: z.record(z.string(), z.any()).default({}).nullable(),
4105
+ createdAt: z.date().nullable(),
4106
+ updatedAt: z.date().nullable(),
4107
+ deletedAt: z.date().nullable(),
4108
+ resource: z.any()
4109
+ });
4110
+ var ContentResourceSchema = z.object({
4184
4111
  id: z.string(),
4185
- updatedAt: z.string().optional(),
4186
- createdAt: z.string().optional(),
4187
- title: z.string().optional().nullable(),
4188
- duration: z.number().optional().nullable(),
4189
- muxPlaybackId: z.string().optional().nullable(),
4190
- muxAssetId: z.string().optional().nullable(),
4191
- transcript: z.string().optional().nullable(),
4192
- transcriptWithScreenshots: z.string().optional().nullable(),
4193
- srt: z.string().optional().nullable(),
4194
- wordLevelSrt: z.string().optional().nullable(),
4195
- state: z.enum([
4196
- "new",
4197
- "processing",
4198
- "preparing",
4199
- "ready",
4200
- "errored"
4201
- ])
4112
+ type: z.string(),
4113
+ createdById: z.string(),
4114
+ fields: z.record(z.string(), z.any()).default({}).nullable().optional(),
4115
+ createdAt: z.date().nullable(),
4116
+ updatedAt: z.date().nullable(),
4117
+ deletedAt: z.date().nullable(),
4118
+ resources: z.array(ContentResourceResourceSchema).default([]).nullable()
4202
4119
  });
4203
-
4204
- // src/lib/mysql/index.ts
4205
- function getCourseBuilderSchema(mysqlTable) {
4206
- return {
4207
- accounts: getAccountsSchema(mysqlTable),
4208
- accountsRelations: getAccountsRelationsSchema(mysqlTable),
4209
- permissions: getPermissionsSchema(mysqlTable),
4210
- permissionsRelations: getPermissionsRelationsSchema(mysqlTable),
4211
- rolePermissions: getRolePermissionsSchema(mysqlTable),
4212
- rolePermissionsRelations: getRolePermissionsRelationsSchema(mysqlTable),
4213
- roles: getRolesSchema(mysqlTable),
4214
- rolesRelations: getRolesRelationsSchema(mysqlTable),
4215
- sessions: getSessionsSchema(mysqlTable),
4216
- sessionsRelations: getSessionRelationsSchema(mysqlTable),
4217
- userPermissions: getUserPermissionsSchema(mysqlTable),
4218
- userPermissionsRelations: getUserPermissionsRelationsSchema(mysqlTable),
4219
- userRoles: getUserRolesSchema(mysqlTable),
4220
- userRolesRelations: getUserRolesRelationsSchema(mysqlTable),
4221
- users: getUsersSchema(mysqlTable),
4222
- usersRelations: getUsersRelationsSchema(mysqlTable),
4223
- verificationTokens: getVerificationTokensSchema(mysqlTable),
4224
- coupon: getCouponSchema(mysqlTable),
4225
- merchantAccount: getMerchantAccountSchema(mysqlTable),
4226
- merchantCharge: getMerchantChargeSchema(mysqlTable),
4227
- merchantCoupon: getMerchantCouponSchema(mysqlTable),
4228
- merchantCustomer: getMerchantCustomerSchema(mysqlTable),
4229
- merchantPrice: getMerchantPriceSchema(mysqlTable),
4230
- merchantProduct: getMerchantProductSchema(mysqlTable),
4231
- merchantSession: getMerchantSessionSchema(mysqlTable),
4232
- price: getPriceSchema(mysqlTable),
4233
- product: getProductSchema(mysqlTable),
4234
- purchase: getPurchaseSchema(mysqlTable),
4235
- purchaseUserTransfer: getPurchaseUserTransferSchema(mysqlTable),
4236
- communicationChannel: getCommunicationChannelSchema(mysqlTable),
4237
- communicationPreferenceTypes: getCommunicationPreferenceTypesSchema(mysqlTable),
4238
- communicationPreferences: getCommunicationPreferencesSchema(mysqlTable),
4239
- communicationPreferencesRelations: getCommunicationPreferencesRelationsSchema(mysqlTable),
4240
- contentContributions: getContentContributionsSchema(mysqlTable),
4241
- contentContributionRelations: getContentContributionRelationsSchema(mysqlTable),
4242
- contentResource: getContentResourceSchema(mysqlTable),
4243
- contentResourceRelations: getContentResourceRelationsSchema(mysqlTable),
4244
- contentResourceResource: getContentResourceResourceSchema(mysqlTable),
4245
- contentResourceResourceRelations: getContentResourceResourceRelationsSchema(mysqlTable),
4246
- contributionTypes: getContributionTypesSchema(mysqlTable),
4247
- contributionTypesRelations: getContributionTypesRelationsSchema(mysqlTable),
4248
- resourceProgress: getResourceProgressSchema(mysqlTable)
4249
- };
4250
- }
4251
- __name(getCourseBuilderSchema, "getCourseBuilderSchema");
4252
- function createTables(mySqlTable) {
4253
- return getCourseBuilderSchema(mySqlTable);
4254
- }
4255
- __name(createTables, "createTables");
4256
- function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
4257
- const { users, accounts, sessions, verificationTokens, contentResource, contentResourceResource, purchase, purchaseUserTransfer, coupon, merchantCoupon, merchantCharge, merchantAccount, merchantPrice, merchantCustomer, merchantSession, merchantProduct, price, product } = createTables(tableFn);
4258
- return {
4259
- async updateContentResourceFields(options) {
4260
- if (!options.id) {
4261
- throw new Error("No content resource id.");
4262
- }
4263
- const currentResource = await client.select().from(contentResource).where(eq(contentResource.id, options.id)).then((res) => res[0]);
4264
- await client.update(contentResource).set({
4265
- fields: {
4266
- ...currentResource.fields,
4267
- ...options.fields
4268
- }
4269
- }).where(eq(contentResource.id, options.id));
4270
- return await client.select().from(contentResource).where(eq(contentResource.id, options.id)).then((res) => res[0]);
4271
- },
4272
- async getVideoResource(id) {
4273
- if (!id) {
4274
- throw new Error("videoResourceId is required");
4275
- }
4276
- const query = sql`
4277
- SELECT
4278
- id as id,
4279
- CAST(updatedAt AS DATETIME) as updatedAt,
4280
- CAST(createdAt AS DATETIME) as createdAt,
4281
- JSON_EXTRACT (${contentResource.fields}, "$.state") AS state,
4282
- JSON_EXTRACT (${contentResource.fields}, "$.duration") AS duration,
4283
- JSON_EXTRACT (${contentResource.fields}, "$.muxPlaybackId") AS muxPlaybackId,
4284
- JSON_EXTRACT (${contentResource.fields}, "$.muxAssetId") AS muxAssetId,
4285
- JSON_EXTRACT (${contentResource.fields}, "$.transcript") AS transcript
4286
- FROM
4287
- ${contentResource}
4288
- WHERE
4289
- type = 'videoResource'
4290
- AND (id = ${id});
4291
-
4292
- `;
4293
- return client.execute(query).then((result) => {
4294
- const parsedResource = VideoResourceSchema.safeParse(result.rows[0]);
4295
- return parsedResource.success ? parsedResource.data : null;
4296
- }).catch((error) => {
4297
- console.error(error);
4298
- return error;
4299
- });
4300
- },
4301
- async createContentResource(data) {
4302
- const id = data.id || crypto.randomUUID();
4303
- await client.insert(contentResource).values({
4304
- ...data,
4305
- id
4306
- });
4307
- return await client.select().from(contentResource).where(eq(contentResource.id, id)).then((res) => res[0]);
4308
- },
4309
- async getContentResource(data) {
4310
- return await client.select().from(contentResource).where(eq(contentResource.id, data)).then((res) => res[0]) ?? null;
4311
- },
4312
- async createUser(data) {
4313
- const id = crypto.randomUUID();
4314
- await client.insert(users).values({
4315
- ...data,
4316
- id
4317
- });
4318
- return await client.select().from(users).where(eq(users.id, id)).then((res) => res[0]);
4319
- },
4320
- async getUser(data) {
4321
- return await client.select().from(users).where(eq(users.id, data)).then((res) => res[0]) ?? null;
4322
- },
4323
- async getUserByEmail(data) {
4324
- return await client.select().from(users).where(eq(users.email, data)).then((res) => res[0]) ?? null;
4325
- },
4326
- async createSession(data) {
4327
- await client.insert(sessions).values(data);
4328
- return await client.select().from(sessions).where(eq(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
4329
- },
4330
- async getSessionAndUser(data) {
4331
- return await client.select({
4332
- session: sessions,
4333
- user: users
4334
- }).from(sessions).where(eq(sessions.sessionToken, data)).innerJoin(users, eq(users.id, sessions.userId)).then((res) => res[0]) ?? null;
4335
- },
4336
- async updateUser(data) {
4337
- if (!data.id) {
4338
- throw new Error("No user id.");
4339
- }
4340
- await client.update(users).set(data).where(eq(users.id, data.id));
4341
- return await client.select().from(users).where(eq(users.id, data.id)).then((res) => res[0]);
4342
- },
4343
- async updateSession(data) {
4344
- await client.update(sessions).set(data).where(eq(sessions.sessionToken, data.sessionToken));
4345
- return await client.select().from(sessions).where(eq(sessions.sessionToken, data.sessionToken)).then((res) => res[0]);
4346
- },
4347
- async linkAccount(rawAccount) {
4348
- await client.insert(accounts).values(rawAccount);
4349
- },
4350
- async getUserByAccount(account) {
4351
- const dbAccount = await client.select().from(accounts).where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider))).leftJoin(users, eq(accounts.userId, users.id)).then((res) => res[0]) ?? null;
4352
- if (!dbAccount) {
4353
- return null;
4354
- }
4355
- return dbAccount.user;
4356
- },
4357
- async deleteSession(sessionToken) {
4358
- const session = await client.select().from(sessions).where(eq(sessions.sessionToken, sessionToken)).then((res) => res[0]) ?? null;
4359
- await client.delete(sessions).where(eq(sessions.sessionToken, sessionToken));
4360
- return session;
4361
- },
4362
- async createVerificationToken(token) {
4363
- await client.insert(verificationTokens).values(token);
4364
- return await client.select().from(verificationTokens).where(eq(verificationTokens.identifier, token.identifier)).then((res) => res[0]);
4365
- },
4366
- async useVerificationToken(token) {
4367
- try {
4368
- const deletedToken = await client.select().from(verificationTokens).where(and(eq(verificationTokens.identifier, token.identifier), eq(verificationTokens.token, token.token))).then((res) => res[0]) ?? null;
4369
- if (deletedToken?.createdAt) {
4370
- const TIMEOUT_IN_SECONDS = 90;
4371
- const expireMultipleClicks = addSeconds(deletedToken.createdAt, TIMEOUT_IN_SECONDS);
4372
- const now = /* @__PURE__ */ new Date();
4373
- if (isAfter(expireMultipleClicks, now)) {
4374
- const { id: _, ...verificationToken } = token;
4375
- return deletedToken;
4376
- } else {
4377
- await client.delete(verificationTokens).where(and(eq(verificationTokens.identifier, token.identifier), eq(verificationTokens.token, token.token)));
4378
- return deletedToken;
4379
- }
4380
- }
4381
- return deletedToken;
4382
- } catch (err) {
4383
- throw new Error("No verification token found.");
4384
- }
4385
- },
4386
- async deleteUser(id) {
4387
- const user = await client.select().from(users).where(eq(users.id, id)).then((res) => res[0] ?? null);
4388
- await client.delete(users).where(eq(users.id, id));
4389
- await client.delete(sessions).where(eq(sessions.userId, id));
4390
- await client.delete(accounts).where(eq(accounts.userId, id));
4391
- return user;
4392
- },
4393
- async unlinkAccount(account) {
4394
- await client.delete(accounts).where(and(eq(accounts.providerAccountId, account.providerAccountId), eq(accounts.provider, account.provider)));
4395
- return void 0;
4396
- }
4397
- };
4398
- }
4399
- __name(mySqlDrizzleAdapter, "mySqlDrizzleAdapter");
4120
+ var ResourceStateSchema = z.union([
4121
+ z.literal("draft"),
4122
+ z.literal("published"),
4123
+ z.literal("archived"),
4124
+ z.literal("deleted")
4125
+ ]);
4126
+ var ResourceVisibilitySchema = z.union([
4127
+ z.literal("public"),
4128
+ z.literal("private"),
4129
+ z.literal("unlisted")
4130
+ ]);
4400
4131
 
4401
4132
  export {
4402
- getCourseBuilderSchema,
4403
- createTables,
4404
- mySqlDrizzleAdapter
4133
+ z,
4134
+ ContentResourceResourceSchema,
4135
+ ContentResourceSchema
4405
4136
  };
4406
- //# sourceMappingURL=chunk-FRNVLW7N.js.map
4137
+ //# sourceMappingURL=chunk-Y34AIPU7.js.map
package/dist/index.js CHANGED
@@ -1,32 +1,36 @@
1
1
  import {
2
2
  pgDrizzleAdapter
3
- } from "./chunk-SQR6UWVO.js";
3
+ } from "./chunk-7LAAAEVE.js";
4
4
  import {
5
5
  SQLiteDrizzleAdapter
6
- } from "./chunk-22KIKVBY.js";
6
+ } from "./chunk-O2KKII62.js";
7
7
  import "./chunk-GFUUJRX7.js";
8
8
  import {
9
9
  createTables,
10
10
  mySqlDrizzleAdapter
11
- } from "./chunk-FRNVLW7N.js";
12
- import "./chunk-UY3DVPP3.js";
13
- import "./chunk-VEFCDI73.js";
14
- import "./chunk-BRGTUNY2.js";
15
- import "./chunk-ICL7XZ2Y.js";
11
+ } from "./chunk-GVURJJRV.js";
12
+ import "./chunk-LSOPFMDB.js";
13
+ import "./chunk-75V6F7LZ.js";
14
+ import "./chunk-RVYJDDZD.js";
15
+ import "./chunk-IN6G6MTW.js";
16
16
  import "./chunk-JD4KFACE.js";
17
- import "./chunk-MBQ3TMHH.js";
18
- import "./chunk-KI47TR7F.js";
19
- import "./chunk-AIDEJDKJ.js";
20
- import "./chunk-H4MXNDWO.js";
21
- import "./chunk-TA6VLEV5.js";
22
- import "./chunk-US2EXVMI.js";
23
- import "./chunk-PFN4YUQZ.js";
17
+ import "./chunk-OIUOQ3TT.js";
18
+ import "./chunk-L2TQQYG4.js";
19
+ import "./chunk-JKRFXYAR.js";
20
+ import "./chunk-AFQGYW7Z.js";
21
+ import "./chunk-QZOBGJSV.js";
22
+ import "./chunk-MYRB6GLJ.js";
24
23
  import "./chunk-TMQIGK3N.js";
25
- import "./chunk-KVN3JV7C.js";
26
- import "./chunk-VZABQCFH.js";
27
- import "./chunk-4HDU7QIB.js";
24
+ import "./chunk-Y34AIPU7.js";
25
+ import "./chunk-ISURSRBK.js";
26
+ import "./chunk-V6QEDDFG.js";
27
+ import "./chunk-CPE4P26C.js";
28
28
  import "./chunk-6CBAFOL3.js";
29
29
  import "./chunk-SFJM6FKE.js";
30
+ import "./chunk-27KREOQW.js";
31
+ import "./chunk-H4MXNDWO.js";
32
+ import "./chunk-44VDBYFU.js";
33
+ import "./chunk-NZDLUQWP.js";
30
34
  import {
31
35
  __name
32
36
  } from "./chunk-VNI36MMC.js";