@coursebuilder/adapter-drizzle 0.3.0 → 0.4.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 (51) hide show
  1. package/dist/{chunk-J63FMGT7.js → chunk-A26D3TCA.js} +167 -140
  2. package/dist/{chunk-PIQXK2CY.js → chunk-DL3UMWB4.js} +2 -2
  3. package/dist/{chunk-QMDE6HUA.js → chunk-IDINCRHK.js} +2 -2
  4. package/dist/{chunk-4PJWD6YK.js → chunk-N7UDJAI3.js} +32 -31
  5. package/dist/{chunk-QY4TPO7D.js → chunk-ULEUIL2Y.js} +2 -2
  6. package/dist/{chunk-MCARHGE5.js → chunk-XJHSXR42.js} +2 -2
  7. package/dist/index.js +6 -6
  8. package/dist/lib/mysql/index.cjs +178 -150
  9. package/dist/lib/mysql/index.cjs.map +1 -1
  10. package/dist/lib/mysql/index.js +6 -6
  11. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  12. package/dist/lib/mysql/schemas/auth/accounts.js +1 -1
  13. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  14. package/dist/lib/mysql/schemas/auth/role-permissions.js +2 -2
  15. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  16. package/dist/lib/mysql/schemas/auth/roles.js +1 -1
  17. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  18. package/dist/lib/mysql/schemas/auth/sessions.js +2 -2
  19. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  20. package/dist/lib/mysql/schemas/auth/user-permissions.js +1 -1
  21. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  22. package/dist/lib/mysql/schemas/auth/user-roles.js +1 -1
  23. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  24. package/dist/lib/mysql/schemas/auth/users.js +1 -1
  25. package/dist/lib/mysql/schemas/commerce/coupon.cjs +1 -0
  26. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  27. package/dist/lib/mysql/schemas/commerce/coupon.js +1 -1
  28. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  29. package/dist/lib/mysql/schemas/commerce/price.js +1 -1
  30. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  31. package/dist/lib/mysql/schemas/commerce/product.js +1 -1
  32. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  33. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +2 -2
  34. package/dist/lib/mysql/schemas/commerce/purchase.cjs +1 -0
  35. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  36. package/dist/lib/mysql/schemas/commerce/purchase.js +1 -1
  37. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  38. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +2 -2
  39. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/communication/communication-preferences.js +1 -1
  41. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  42. package/dist/lib/mysql/schemas/content/content-contributions.js +1 -1
  43. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  44. package/dist/lib/mysql/schemas/content/content-resource-product.js +1 -1
  45. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  46. package/dist/lib/mysql/schemas/content/content-resource-resource.js +1 -1
  47. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/content/content-resource.js +1 -1
  49. package/package.json +1 -1
  50. package/src/lib/mysql/index.ts +46 -17
  51. package/src/lib/mysql/schemas/commerce/coupon.ts +5 -0
@@ -2305,10 +2305,10 @@ var _ZodObject = class _ZodObject extends ZodType {
2305
2305
  // }) as any;
2306
2306
  // return merged;
2307
2307
  // }
2308
- catchall(index18) {
2308
+ catchall(index19) {
2309
2309
  return new _ZodObject({
2310
2310
  ...this._def,
2311
- catchall: index18
2311
+ catchall: index19
2312
2312
  });
2313
2313
  }
2314
2314
  pick(mask) {
@@ -2623,9 +2623,9 @@ function mergeValues(a, b) {
2623
2623
  return { valid: false };
2624
2624
  }
2625
2625
  const newArray = [];
2626
- for (let index18 = 0; index18 < a.length; index18++) {
2627
- const itemA = a[index18];
2628
- const itemB = b[index18];
2626
+ for (let index19 = 0; index19 < a.length; index19++) {
2627
+ const itemA = a[index19];
2628
+ const itemB = b[index19];
2629
2629
  const sharedValue = mergeValues(itemA, itemB);
2630
2630
  if (!sharedValue.valid) {
2631
2631
  return { valid: false };
@@ -2837,10 +2837,10 @@ var _ZodMap = class _ZodMap extends ZodType {
2837
2837
  }
2838
2838
  const keyType = this._def.keyType;
2839
2839
  const valueType = this._def.valueType;
2840
- const pairs = [...ctx.data.entries()].map(([key, value], index18) => {
2840
+ const pairs = [...ctx.data.entries()].map(([key, value], index19) => {
2841
2841
  return {
2842
- key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index18, "key"])),
2843
- value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index18, "value"]))
2842
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index19, "key"])),
2843
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index19, "value"]))
2844
2844
  };
2845
2845
  });
2846
2846
  if (ctx.common.async) {
@@ -6338,10 +6338,10 @@ var _ZodObject2 = (_a18 = class extends ZodType2 {
6338
6338
  // }) as any;
6339
6339
  // return merged;
6340
6340
  // }
6341
- catchall(index18) {
6341
+ catchall(index19) {
6342
6342
  return new _a18({
6343
6343
  ...this._def,
6344
- catchall: index18
6344
+ catchall: index19
6345
6345
  });
6346
6346
  }
6347
6347
  pick(mask) {
@@ -6683,9 +6683,9 @@ function mergeValues2(a, b) {
6683
6683
  };
6684
6684
  }
6685
6685
  const newArray = [];
6686
- for (let index18 = 0; index18 < a.length; index18++) {
6687
- const itemA = a[index18];
6688
- const itemB = b[index18];
6686
+ for (let index19 = 0; index19 < a.length; index19++) {
6687
+ const itemA = a[index19];
6688
+ const itemB = b[index19];
6689
6689
  const sharedValue = mergeValues2(itemA, itemB);
6690
6690
  if (!sharedValue.valid) {
6691
6691
  return {
@@ -6919,14 +6919,14 @@ var _ZodMap2 = (_a24 = class extends ZodType2 {
6919
6919
  const valueType = this._def.valueType;
6920
6920
  const pairs = [
6921
6921
  ...ctx.data.entries()
6922
- ].map(([key, value], index18) => {
6922
+ ].map(([key, value], index19) => {
6923
6923
  return {
6924
6924
  key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [
6925
- index18,
6925
+ index19,
6926
6926
  "key"
6927
6927
  ])),
6928
6928
  value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [
6929
- index18,
6929
+ index19,
6930
6930
  "value"
6931
6931
  ]))
6932
6932
  };
@@ -8044,26 +8044,38 @@ var z2 = /* @__PURE__ */ Object.freeze({
8044
8044
  ZodError: ZodError2
8045
8045
  });
8046
8046
 
8047
- // ../core/dist/chunk-LMH5A7OR.js
8048
- var purchaseUserTransferSchema = z2.object({
8047
+ // ../core/dist/chunk-CHYUPSYW.js
8048
+ var userSchema = z2.object({
8049
+ id: z2.string().max(255),
8050
+ name: z2.string().max(255).optional().nullable(),
8051
+ role: z2.enum([
8052
+ "user",
8053
+ "admin"
8054
+ ]).default("user"),
8055
+ email: z2.string().max(255).email(),
8056
+ emailVerified: z2.coerce.date().nullable(),
8057
+ image: z2.string().max(255).optional().nullable(),
8058
+ createdAt: z2.coerce.date().nullable(),
8059
+ roles: z2.array(z2.object({
8060
+ id: z2.string(),
8061
+ name: z2.string(),
8062
+ description: z2.string().nullable(),
8063
+ active: z2.boolean()
8064
+ })).optional().default([])
8065
+ });
8066
+
8067
+ // ../core/dist/chunk-47RWEDJ6.js
8068
+ var priceSchema = z2.object({
8049
8069
  id: z2.string().max(191),
8050
- transferState: z2.enum([
8051
- "AVAILABLE",
8052
- "INITIATED",
8053
- "VERIFIED",
8054
- "CANCELED",
8055
- "EXPIRED",
8056
- "CONFIRMED",
8057
- "COMPLETED"
8058
- ]).default("AVAILABLE"),
8059
- purchaseId: z2.string().max(191),
8060
- sourceUserId: z2.string().max(191),
8061
- targetUserId: z2.string().max(191).optional().nullable(),
8070
+ productId: z2.string().max(191).optional().nullable(),
8071
+ nickname: z2.string().max(191).optional().nullable(),
8072
+ status: z2.number().int().default(0),
8073
+ unitAmount: z2.coerce.number().refine((value) => {
8074
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8075
+ return decimalPlaces <= 2;
8076
+ }),
8062
8077
  createdAt: z2.date().nullable(),
8063
- expiresAt: z2.date().nullable(),
8064
- canceledAt: z2.date().nullable(),
8065
- confirmedAt: z2.date().nullable(),
8066
- completedAt: z2.date().nullable()
8078
+ fields: z2.record(z2.any()).default({})
8067
8079
  });
8068
8080
 
8069
8081
  // ../core/dist/chunk-YYIPQN6H.js
@@ -8110,111 +8122,6 @@ var ResourceVisibilitySchema = z2.union([
8110
8122
  z2.literal("unlisted")
8111
8123
  ]);
8112
8124
 
8113
- // ../core/dist/chunk-GCYJ74DO.js
8114
- var resourceProgressSchema = z2.object({
8115
- userId: z2.string().max(191),
8116
- contentResourceId: z2.string().max(191).optional().nullable(),
8117
- fields: z2.record(z2.any()).default({}),
8118
- completedAt: z2.date().nullable(),
8119
- updatedAt: z2.date().nullable(),
8120
- createdAt: z2.date().nullable()
8121
- });
8122
- var moduleProgressSchema = z2.object({
8123
- completedLessons: z2.array(resourceProgressSchema),
8124
- nextResource: ContentResourceSchema.nullable(),
8125
- percentCompleted: z2.number().default(0),
8126
- completedLessonsCount: z2.number().default(0),
8127
- totalLessonsCount: z2.number().default(0)
8128
- });
8129
-
8130
- // ../core/dist/chunk-DLQA3JMA.js
8131
- var upgradableProductSchema = z2.object({
8132
- upgradableToId: z2.string().max(255),
8133
- upgradableFromId: z2.string().max(255),
8134
- position: z2.number().default(0),
8135
- metadata: z2.record(z2.any()).default({}),
8136
- createdAt: z2.date().nullable(),
8137
- updatedAt: z2.date().nullable(),
8138
- deletedAt: z2.date().nullable()
8139
- });
8140
-
8141
- // ../core/dist/chunk-G22WGQ3G.js
8142
- var VideoResourceSchema = z2.object({
8143
- id: z2.string(),
8144
- updatedAt: z2.string().optional(),
8145
- createdAt: z2.string().optional(),
8146
- title: z2.string().optional().nullable(),
8147
- duration: z2.number().optional().nullable(),
8148
- muxPlaybackId: z2.string().optional().nullable(),
8149
- muxAssetId: z2.string().optional().nullable(),
8150
- transcript: z2.string().optional().nullable(),
8151
- transcriptWithScreenshots: z2.string().optional().nullable(),
8152
- srt: z2.string().optional().nullable(),
8153
- wordLevelSrt: z2.string().optional().nullable(),
8154
- state: z2.enum([
8155
- "new",
8156
- "processing",
8157
- "preparing",
8158
- "ready",
8159
- "errored"
8160
- ])
8161
- });
8162
-
8163
- // ../core/dist/chunk-PS6USEN7.js
8164
- var merchantPriceSchema = z2.object({
8165
- id: z2.string().max(191),
8166
- merchantAccountId: z2.string().max(191),
8167
- merchantProductId: z2.string().max(191),
8168
- status: z2.number().int().default(0),
8169
- identifier: z2.string().max(191).optional().nullable(),
8170
- createdAt: z2.date(),
8171
- priceId: z2.string().max(191).optional().nullable()
8172
- });
8173
-
8174
- // ../core/dist/chunk-DAG4HKGL.js
8175
- var merchantProductSchema = z2.object({
8176
- id: z2.string().max(191),
8177
- merchantAccountId: z2.string().max(191),
8178
- productId: z2.string().max(191),
8179
- status: z2.number().int().default(0),
8180
- identifier: z2.string().max(191).optional().nullable(),
8181
- createdAt: z2.date().nullable()
8182
- });
8183
-
8184
- // ../core/dist/chunk-CHYUPSYW.js
8185
- var userSchema = z2.object({
8186
- id: z2.string().max(255),
8187
- name: z2.string().max(255).optional().nullable(),
8188
- role: z2.enum([
8189
- "user",
8190
- "admin"
8191
- ]).default("user"),
8192
- email: z2.string().max(255).email(),
8193
- emailVerified: z2.coerce.date().nullable(),
8194
- image: z2.string().max(255).optional().nullable(),
8195
- createdAt: z2.coerce.date().nullable(),
8196
- roles: z2.array(z2.object({
8197
- id: z2.string(),
8198
- name: z2.string(),
8199
- description: z2.string().nullable(),
8200
- active: z2.boolean()
8201
- })).optional().default([])
8202
- });
8203
-
8204
- // ../core/dist/chunk-47RWEDJ6.js
8205
- var priceSchema = z2.object({
8206
- id: z2.string().max(191),
8207
- productId: z2.string().max(191).optional().nullable(),
8208
- nickname: z2.string().max(191).optional().nullable(),
8209
- status: z2.number().int().default(0),
8210
- unitAmount: z2.coerce.number().refine((value) => {
8211
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8212
- return decimalPlaces <= 2;
8213
- }),
8214
- createdAt: z2.date().nullable(),
8215
- fields: z2.record(z2.any()).default({})
8216
- });
8217
-
8218
8125
  // ../core/dist/chunk-DGMGNBW7.js
8219
8126
  var productSchema = z2.object({
8220
8127
  id: z2.string().max(191),
@@ -8302,16 +8209,76 @@ var purchaseSchema = z2.object({
8302
8209
  product: productSchema.optional().nullable()
8303
8210
  });
8304
8211
 
8305
- // ../core/dist/chunk-SGE7BCRS.js
8306
- var merchantChargeSchema = z2.object({
8212
+ // ../core/dist/chunk-LMH5A7OR.js
8213
+ var purchaseUserTransferSchema = z2.object({
8307
8214
  id: z2.string().max(191),
8308
- status: z2.number().int().default(0),
8309
- identifier: z2.string().max(191),
8215
+ transferState: z2.enum([
8216
+ "AVAILABLE",
8217
+ "INITIATED",
8218
+ "VERIFIED",
8219
+ "CANCELED",
8220
+ "EXPIRED",
8221
+ "CONFIRMED",
8222
+ "COMPLETED"
8223
+ ]).default("AVAILABLE"),
8224
+ purchaseId: z2.string().max(191),
8225
+ sourceUserId: z2.string().max(191),
8226
+ targetUserId: z2.string().max(191).optional().nullable(),
8227
+ createdAt: z2.date().nullable(),
8228
+ expiresAt: z2.date().nullable(),
8229
+ canceledAt: z2.date().nullable(),
8230
+ confirmedAt: z2.date().nullable(),
8231
+ completedAt: z2.date().nullable()
8232
+ });
8233
+
8234
+ // ../core/dist/chunk-GCYJ74DO.js
8235
+ var resourceProgressSchema = z2.object({
8310
8236
  userId: z2.string().max(191),
8311
- merchantAccountId: z2.string().max(191),
8312
- merchantProductId: z2.string().max(191),
8237
+ contentResourceId: z2.string().max(191).optional().nullable(),
8238
+ fields: z2.record(z2.any()).default({}),
8239
+ completedAt: z2.date().nullable(),
8240
+ updatedAt: z2.date().nullable(),
8241
+ createdAt: z2.date().nullable()
8242
+ });
8243
+ var moduleProgressSchema = z2.object({
8244
+ completedLessons: z2.array(resourceProgressSchema),
8245
+ nextResource: ContentResourceSchema.nullable(),
8246
+ percentCompleted: z2.number().default(0),
8247
+ completedLessonsCount: z2.number().default(0),
8248
+ totalLessonsCount: z2.number().default(0)
8249
+ });
8250
+
8251
+ // ../core/dist/chunk-DLQA3JMA.js
8252
+ var upgradableProductSchema = z2.object({
8253
+ upgradableToId: z2.string().max(255),
8254
+ upgradableFromId: z2.string().max(255),
8255
+ position: z2.number().default(0),
8256
+ metadata: z2.record(z2.any()).default({}),
8313
8257
  createdAt: z2.date().nullable(),
8314
- merchantCustomerId: z2.string().max(191)
8258
+ updatedAt: z2.date().nullable(),
8259
+ deletedAt: z2.date().nullable()
8260
+ });
8261
+
8262
+ // ../core/dist/chunk-G22WGQ3G.js
8263
+ var VideoResourceSchema = z2.object({
8264
+ id: z2.string(),
8265
+ updatedAt: z2.string().optional(),
8266
+ createdAt: z2.string().optional(),
8267
+ title: z2.string().optional().nullable(),
8268
+ duration: z2.number().optional().nullable(),
8269
+ muxPlaybackId: z2.string().optional().nullable(),
8270
+ muxAssetId: z2.string().optional().nullable(),
8271
+ transcript: z2.string().optional().nullable(),
8272
+ transcriptWithScreenshots: z2.string().optional().nullable(),
8273
+ srt: z2.string().optional().nullable(),
8274
+ wordLevelSrt: z2.string().optional().nullable(),
8275
+ state: z2.enum([
8276
+ "new",
8277
+ "processing",
8278
+ "preparing",
8279
+ "ready",
8280
+ "errored"
8281
+ ])
8315
8282
  });
8316
8283
 
8317
8284
  // ../core/dist/chunk-EDDT2FFU.js
@@ -8324,6 +8291,39 @@ var merchantCustomerSchema = z2.object({
8324
8291
  status: z2.number().int().default(0)
8325
8292
  });
8326
8293
 
8294
+ // ../core/dist/chunk-PS6USEN7.js
8295
+ var merchantPriceSchema = z2.object({
8296
+ id: z2.string().max(191),
8297
+ merchantAccountId: z2.string().max(191),
8298
+ merchantProductId: z2.string().max(191),
8299
+ status: z2.number().int().default(0),
8300
+ identifier: z2.string().max(191).optional().nullable(),
8301
+ createdAt: z2.date(),
8302
+ priceId: z2.string().max(191).optional().nullable()
8303
+ });
8304
+
8305
+ // ../core/dist/chunk-DAG4HKGL.js
8306
+ var merchantProductSchema = z2.object({
8307
+ id: z2.string().max(191),
8308
+ merchantAccountId: z2.string().max(191),
8309
+ productId: z2.string().max(191),
8310
+ status: z2.number().int().default(0),
8311
+ identifier: z2.string().max(191).optional().nullable(),
8312
+ createdAt: z2.date().nullable()
8313
+ });
8314
+
8315
+ // ../core/dist/chunk-SGE7BCRS.js
8316
+ var merchantChargeSchema = z2.object({
8317
+ id: z2.string().max(191),
8318
+ status: z2.number().int().default(0),
8319
+ identifier: z2.string().max(191),
8320
+ userId: z2.string().max(191),
8321
+ merchantAccountId: z2.string().max(191),
8322
+ merchantProductId: z2.string().max(191),
8323
+ createdAt: z2.date().nullable(),
8324
+ merchantCustomerId: z2.string().max(191)
8325
+ });
8326
+
8327
8327
  // ../core/dist/chunk-256SROW3.js
8328
8328
  var merchantCouponSchema = z2.object({
8329
8329
  id: z2.string().max(191),
@@ -8939,6 +8939,7 @@ function getCouponSchema(mysqlTable) {
8939
8939
  })
8940
8940
  }, (table) => {
8941
8941
  return {
8942
+ couponIdCodeIndex: (0, import_mysql_core9.index)("Coupon_id_code_index").on(table.id, table.code),
8942
8943
  couponId: (0, import_mysql_core9.primaryKey)({
8943
8944
  columns: [
8944
8945
  table.id
@@ -10607,7 +10608,13 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10607
10608
  };
10608
10609
  },
10609
10610
  async getCoupon(couponIdOrCode) {
10610
- return couponSchema.nullable().parse(await client.select().from(coupon).where((0, import_drizzle_orm27.or)((0, import_drizzle_orm27.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm27.eq)(coupon.code, couponIdOrCode))).then((res) => res[0] ?? null));
10611
+ const loadedCoupon = await client.query.coupon.findFirst({
10612
+ where: (0, import_drizzle_orm27.or)((0, import_drizzle_orm27.eq)(coupon.id, couponIdOrCode), (0, import_drizzle_orm27.eq)(coupon.code, couponIdOrCode))
10613
+ }) || null;
10614
+ logger.debug("loadedCoupon", {
10615
+ loadedCoupon
10616
+ });
10617
+ return couponSchema.nullable().parse(loadedCoupon);
10611
10618
  },
10612
10619
  async getCouponWithBulkPurchases(couponId) {
10613
10620
  logger.debug("getCouponWithBulkPurchases", {
@@ -10707,7 +10714,18 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10707
10714
  const user = await client.query.users.findFirst({
10708
10715
  where: (0, import_drizzle_orm27.or)((0, import_drizzle_orm27.eq)(users.id, userIdOrEmail), (0, import_drizzle_orm27.eq)(users.email, userIdOrEmail)),
10709
10716
  with: {
10710
- roles: true
10717
+ roles: {
10718
+ with: {
10719
+ role: true
10720
+ }
10721
+ }
10722
+ }
10723
+ }).then(async (res) => {
10724
+ if (res) {
10725
+ return {
10726
+ ...res,
10727
+ roles: res.roles.map((r) => r.role)
10728
+ };
10711
10729
  }
10712
10730
  });
10713
10731
  if (!user) {
@@ -10720,9 +10738,19 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core32.mysqlTable) {
10720
10738
  totalLessonsCount: parsedModuleResources.data.length
10721
10739
  };
10722
10740
  }
10723
- const parsedUser = userSchema.parse(user);
10741
+ const parsedUser = userSchema.safeParse(user);
10742
+ if (!parsedUser.success) {
10743
+ console.error("Error parsing user", parsedUser.error);
10744
+ return {
10745
+ completedLessons: [],
10746
+ nextResource: null,
10747
+ percentCompleted: 0,
10748
+ completedLessonsCount: 0,
10749
+ totalLessonsCount: parsedModuleResources.data.length
10750
+ };
10751
+ }
10724
10752
  const userProgress = await client.query.resourceProgress.findMany({
10725
- where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(resourceProgress.userId, parsedUser.id), (0, import_drizzle_orm27.isNotNull)(resourceProgress.completedAt), (0, import_drizzle_orm27.inArray)(resourceProgress.contentResourceId, parsedModuleResources.data.map((r) => r.resourceId))),
10753
+ where: (0, import_drizzle_orm27.and)((0, import_drizzle_orm27.eq)(resourceProgress.userId, parsedUser.data.id), (0, import_drizzle_orm27.isNotNull)(resourceProgress.completedAt), (0, import_drizzle_orm27.inArray)(resourceProgress.contentResourceId, parsedModuleResources.data.map((r) => r.resourceId))),
10726
10754
  orderBy: (0, import_drizzle_orm27.asc)(resourceProgress.completedAt)
10727
10755
  });
10728
10756
  const nextResourceId = moduleResources.find((r) => !userProgress.find((p) => p.contentResourceId === r.resourceId))?.resourceId;