@coursebuilder/adapter-drizzle 0.1.0 → 0.1.2

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.
@@ -3889,6 +3889,38 @@ var z2 = /* @__PURE__ */ Object.freeze({
3889
3889
  ZodError
3890
3890
  });
3891
3891
 
3892
+ // ../core/dist/chunk-625UEV4B.js
3893
+ var purchaseUserTransferSchema = z.object({
3894
+ id: z.string().max(191),
3895
+ transferState: z.enum([
3896
+ "AVAILABLE",
3897
+ "INITIATED",
3898
+ "VERIFIED",
3899
+ "CANCELED",
3900
+ "EXPIRED",
3901
+ "CONFIRMED",
3902
+ "COMPLETED"
3903
+ ]).default("AVAILABLE"),
3904
+ purchaseId: z.string().max(191),
3905
+ sourceUserId: z.string().max(191),
3906
+ targetUserId: z.string().max(191).optional(),
3907
+ createdAt: z.date().nullable(),
3908
+ expiresAt: z.date().nullable(),
3909
+ canceledAt: z.date().nullable(),
3910
+ confirmedAt: z.date().nullable(),
3911
+ completedAt: z.date().nullable()
3912
+ });
3913
+
3914
+ // ../core/dist/chunk-NH6Z6YIN.js
3915
+ var resourceProgressSchema = z.object({
3916
+ userId: z.string().max(191),
3917
+ contentResourceId: z.string().max(191).optional().nullable(),
3918
+ metadata: z.record(z.any()).default({}),
3919
+ completedAt: z.date().nullable(),
3920
+ updatedAt: z.date().nullable(),
3921
+ createdAt: z.date().nullable()
3922
+ });
3923
+
3892
3924
  // ../core/dist/chunk-N2FP5B4I.js
3893
3925
  var upgradableProductSchema = z.object({
3894
3926
  upgradableToId: z.string().length(255),
@@ -3922,6 +3954,31 @@ var VideoResourceSchema = z.object({
3922
3954
  ])
3923
3955
  });
3924
3956
 
3957
+ // ../core/dist/chunk-AYRXRIAF.js
3958
+ var merchantChargeSchema = z.object({
3959
+ id: z.string().length(191),
3960
+ status: z.number().int().default(0),
3961
+ identifier: z.string().length(191),
3962
+ userId: z.string().length(191),
3963
+ merchantAccountId: z.string().length(191),
3964
+ merchantProductId: z.string().length(191),
3965
+ createdAt: z.date().nullable(),
3966
+ merchantCustomerId: z.string().length(191)
3967
+ });
3968
+
3969
+ // ../core/dist/chunk-NTKCZFHE.js
3970
+ var merchantCouponSchema = z.object({
3971
+ id: z.string().max(191),
3972
+ identifier: z.string().max(191).optional().nullable(),
3973
+ status: z.number().int().default(0),
3974
+ merchantAccountId: z.string().max(191),
3975
+ percentageDiscount: z.coerce.number().refine((value) => {
3976
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
3977
+ return decimalPlaces <= 2;
3978
+ }),
3979
+ type: z.string().max(191).optional().nullable()
3980
+ });
3981
+
3925
3982
  // ../core/dist/chunk-BRSSFQ7G.js
3926
3983
  var merchantCustomerSchema = z.object({
3927
3984
  id: z.string().max(191),
@@ -4028,63 +4085,6 @@ var purchaseSchema = z.object({
4028
4085
  product: productSchema.optional().nullable()
4029
4086
  });
4030
4087
 
4031
- // ../core/dist/chunk-625UEV4B.js
4032
- var purchaseUserTransferSchema = z.object({
4033
- id: z.string().max(191),
4034
- transferState: z.enum([
4035
- "AVAILABLE",
4036
- "INITIATED",
4037
- "VERIFIED",
4038
- "CANCELED",
4039
- "EXPIRED",
4040
- "CONFIRMED",
4041
- "COMPLETED"
4042
- ]).default("AVAILABLE"),
4043
- purchaseId: z.string().max(191),
4044
- sourceUserId: z.string().max(191),
4045
- targetUserId: z.string().max(191).optional(),
4046
- createdAt: z.date().nullable(),
4047
- expiresAt: z.date().nullable(),
4048
- canceledAt: z.date().nullable(),
4049
- confirmedAt: z.date().nullable(),
4050
- completedAt: z.date().nullable()
4051
- });
4052
-
4053
- // ../core/dist/chunk-NH6Z6YIN.js
4054
- var resourceProgressSchema = z.object({
4055
- userId: z.string().max(191),
4056
- contentResourceId: z.string().max(191).optional().nullable(),
4057
- metadata: z.record(z.any()).default({}),
4058
- completedAt: z.date().nullable(),
4059
- updatedAt: z.date().nullable(),
4060
- createdAt: z.date().nullable()
4061
- });
4062
-
4063
- // ../core/dist/chunk-AYRXRIAF.js
4064
- var merchantChargeSchema = z.object({
4065
- id: z.string().length(191),
4066
- status: z.number().int().default(0),
4067
- identifier: z.string().length(191),
4068
- userId: z.string().length(191),
4069
- merchantAccountId: z.string().length(191),
4070
- merchantProductId: z.string().length(191),
4071
- createdAt: z.date().nullable(),
4072
- merchantCustomerId: z.string().length(191)
4073
- });
4074
-
4075
- // ../core/dist/chunk-NTKCZFHE.js
4076
- var merchantCouponSchema = z.object({
4077
- id: z.string().max(191),
4078
- identifier: z.string().max(191).optional().nullable(),
4079
- status: z.number().int().default(0),
4080
- merchantAccountId: z.string().max(191),
4081
- percentageDiscount: z.coerce.number().refine((value) => {
4082
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
4083
- return decimalPlaces <= 2;
4084
- }),
4085
- type: z.string().max(191).optional().nullable()
4086
- });
4087
-
4088
4088
  // src/lib/mysql/index.ts
4089
4089
  function getCourseBuilderSchema(mysqlTable) {
4090
4090
  return {
@@ -4488,7 +4488,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
4488
4488
  },
4489
4489
  async getVideoResource(id) {
4490
4490
  if (!id) {
4491
- throw new Error("videoResourceId is required");
4491
+ return null;
4492
4492
  }
4493
4493
  const query = sql`
4494
4494
  SELECT
@@ -4550,7 +4550,7 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
4550
4550
  },
4551
4551
  async getContentResource(data) {
4552
4552
  const resource = await client.query.contentResource.findFirst({
4553
- where: eq(contentResource.id, data),
4553
+ where: or(eq(contentResource.id, data), eq(sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
4554
4554
  with: {
4555
4555
  resources: {
4556
4556
  with: {
@@ -4676,4 +4676,4 @@ export {
4676
4676
  createTables,
4677
4677
  mySqlDrizzleAdapter
4678
4678
  };
4679
- //# sourceMappingURL=chunk-GVURJJRV.js.map
4679
+ //# sourceMappingURL=chunk-DHYYRN35.js.map
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import "./chunk-GFUUJRX7.js";
8
8
  import {
9
9
  createTables,
10
10
  mySqlDrizzleAdapter
11
- } from "./chunk-GVURJJRV.js";
11
+ } from "./chunk-DHYYRN35.js";
12
12
  import "./chunk-LSOPFMDB.js";
13
13
  import "./chunk-75V6F7LZ.js";
14
14
  import "./chunk-RVYJDDZD.js";
@@ -7914,6 +7914,38 @@ var z2 = /* @__PURE__ */ Object.freeze({
7914
7914
  ZodError: ZodError2
7915
7915
  });
7916
7916
 
7917
+ // ../core/dist/chunk-625UEV4B.js
7918
+ var purchaseUserTransferSchema = z2.object({
7919
+ id: z2.string().max(191),
7920
+ transferState: z2.enum([
7921
+ "AVAILABLE",
7922
+ "INITIATED",
7923
+ "VERIFIED",
7924
+ "CANCELED",
7925
+ "EXPIRED",
7926
+ "CONFIRMED",
7927
+ "COMPLETED"
7928
+ ]).default("AVAILABLE"),
7929
+ purchaseId: z2.string().max(191),
7930
+ sourceUserId: z2.string().max(191),
7931
+ targetUserId: z2.string().max(191).optional(),
7932
+ createdAt: z2.date().nullable(),
7933
+ expiresAt: z2.date().nullable(),
7934
+ canceledAt: z2.date().nullable(),
7935
+ confirmedAt: z2.date().nullable(),
7936
+ completedAt: z2.date().nullable()
7937
+ });
7938
+
7939
+ // ../core/dist/chunk-NH6Z6YIN.js
7940
+ var resourceProgressSchema = z2.object({
7941
+ userId: z2.string().max(191),
7942
+ contentResourceId: z2.string().max(191).optional().nullable(),
7943
+ metadata: z2.record(z2.any()).default({}),
7944
+ completedAt: z2.date().nullable(),
7945
+ updatedAt: z2.date().nullable(),
7946
+ createdAt: z2.date().nullable()
7947
+ });
7948
+
7917
7949
  // ../core/dist/chunk-N2FP5B4I.js
7918
7950
  var upgradableProductSchema = z2.object({
7919
7951
  upgradableToId: z2.string().length(255),
@@ -7947,6 +7979,31 @@ var VideoResourceSchema = z2.object({
7947
7979
  ])
7948
7980
  });
7949
7981
 
7982
+ // ../core/dist/chunk-AYRXRIAF.js
7983
+ var merchantChargeSchema = z2.object({
7984
+ id: z2.string().length(191),
7985
+ status: z2.number().int().default(0),
7986
+ identifier: z2.string().length(191),
7987
+ userId: z2.string().length(191),
7988
+ merchantAccountId: z2.string().length(191),
7989
+ merchantProductId: z2.string().length(191),
7990
+ createdAt: z2.date().nullable(),
7991
+ merchantCustomerId: z2.string().length(191)
7992
+ });
7993
+
7994
+ // ../core/dist/chunk-NTKCZFHE.js
7995
+ var merchantCouponSchema = z2.object({
7996
+ id: z2.string().max(191),
7997
+ identifier: z2.string().max(191).optional().nullable(),
7998
+ status: z2.number().int().default(0),
7999
+ merchantAccountId: z2.string().max(191),
8000
+ percentageDiscount: z2.coerce.number().refine((value) => {
8001
+ const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8002
+ return decimalPlaces <= 2;
8003
+ }),
8004
+ type: z2.string().max(191).optional().nullable()
8005
+ });
8006
+
7950
8007
  // ../core/dist/chunk-BRSSFQ7G.js
7951
8008
  var merchantCustomerSchema = z2.object({
7952
8009
  id: z2.string().max(191),
@@ -8053,63 +8110,6 @@ var purchaseSchema = z2.object({
8053
8110
  product: productSchema.optional().nullable()
8054
8111
  });
8055
8112
 
8056
- // ../core/dist/chunk-625UEV4B.js
8057
- var purchaseUserTransferSchema = z2.object({
8058
- id: z2.string().max(191),
8059
- transferState: z2.enum([
8060
- "AVAILABLE",
8061
- "INITIATED",
8062
- "VERIFIED",
8063
- "CANCELED",
8064
- "EXPIRED",
8065
- "CONFIRMED",
8066
- "COMPLETED"
8067
- ]).default("AVAILABLE"),
8068
- purchaseId: z2.string().max(191),
8069
- sourceUserId: z2.string().max(191),
8070
- targetUserId: z2.string().max(191).optional(),
8071
- createdAt: z2.date().nullable(),
8072
- expiresAt: z2.date().nullable(),
8073
- canceledAt: z2.date().nullable(),
8074
- confirmedAt: z2.date().nullable(),
8075
- completedAt: z2.date().nullable()
8076
- });
8077
-
8078
- // ../core/dist/chunk-NH6Z6YIN.js
8079
- var resourceProgressSchema = z2.object({
8080
- userId: z2.string().max(191),
8081
- contentResourceId: z2.string().max(191).optional().nullable(),
8082
- metadata: z2.record(z2.any()).default({}),
8083
- completedAt: z2.date().nullable(),
8084
- updatedAt: z2.date().nullable(),
8085
- createdAt: z2.date().nullable()
8086
- });
8087
-
8088
- // ../core/dist/chunk-AYRXRIAF.js
8089
- var merchantChargeSchema = z2.object({
8090
- id: z2.string().length(191),
8091
- status: z2.number().int().default(0),
8092
- identifier: z2.string().length(191),
8093
- userId: z2.string().length(191),
8094
- merchantAccountId: z2.string().length(191),
8095
- merchantProductId: z2.string().length(191),
8096
- createdAt: z2.date().nullable(),
8097
- merchantCustomerId: z2.string().length(191)
8098
- });
8099
-
8100
- // ../core/dist/chunk-NTKCZFHE.js
8101
- var merchantCouponSchema = z2.object({
8102
- id: z2.string().max(191),
8103
- identifier: z2.string().max(191).optional().nullable(),
8104
- status: z2.number().int().default(0),
8105
- merchantAccountId: z2.string().max(191),
8106
- percentageDiscount: z2.coerce.number().refine((value) => {
8107
- const decimalPlaces = value.toString().split(".")[1]?.length || 0;
8108
- return decimalPlaces <= 2;
8109
- }),
8110
- type: z2.string().max(191).optional().nullable()
8111
- });
8112
-
8113
8113
  // ../core/dist/schemas/content-resource-schema.js
8114
8114
  var ContentResourceResourceSchema = z2.object({
8115
8115
  resourceId: z2.string(),
@@ -10060,7 +10060,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core31.mysqlTable) {
10060
10060
  },
10061
10061
  async getVideoResource(id) {
10062
10062
  if (!id) {
10063
- throw new Error("videoResourceId is required");
10063
+ return null;
10064
10064
  }
10065
10065
  const query = import_drizzle_orm26.sql`
10066
10066
  SELECT
@@ -10122,7 +10122,7 @@ function mySqlDrizzleAdapter(client, tableFn = import_mysql_core31.mysqlTable) {
10122
10122
  },
10123
10123
  async getContentResource(data) {
10124
10124
  const resource = await client.query.contentResource.findFirst({
10125
- where: (0, import_drizzle_orm26.eq)(contentResource.id, data),
10125
+ where: (0, import_drizzle_orm26.or)((0, import_drizzle_orm26.eq)(contentResource.id, data), (0, import_drizzle_orm26.eq)(import_drizzle_orm26.sql`JSON_EXTRACT (${contentResource.fields}, "$.slug")`, `${data}`)),
10126
10126
  with: {
10127
10127
  resources: {
10128
10128
  with: {