imean-cassandra-orm 2.7.2 → 2.7.4

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.
package/dist/mod.cjs CHANGED
@@ -1013,7 +1013,7 @@ function convertValueToCassandra(value, config) {
1013
1013
  }
1014
1014
  }
1015
1015
  function convertValueFromCassandra(value, config, zodSchema, filedName) {
1016
- if (value === null) {
1016
+ if (value === null && !config.type.startsWith("list<") && !config.type.startsWith("set<")) {
1017
1017
  return config.flags.optional ? null : void 0;
1018
1018
  }
1019
1019
  switch (config.type) {
@@ -1046,9 +1046,12 @@ function convertValueFromCassandra(value, config, zodSchema, filedName) {
1046
1046
  switch (type) {
1047
1047
  case "list<text>":
1048
1048
  case "set<text>":
1049
+ if (!value || value === "null") {
1050
+ return [];
1051
+ }
1049
1052
  return value.map((item) => {
1050
1053
  try {
1051
- return JSON.parse(item);
1054
+ return JSON.parse(item) || [];
1052
1055
  } catch {
1053
1056
  return item;
1054
1057
  }
@@ -1602,6 +1605,7 @@ var Types = {
1602
1605
  enum: zod.z.enum,
1603
1606
  object: zod.z.object,
1604
1607
  json: () => createCassandraType(zod.z.any(), "text"),
1608
+ record: (keyType, valueType) => createCassandraType(zod.z.record(keyType, valueType), `text`),
1605
1609
  float: () => createCassandraType(
1606
1610
  zod.z.number().transform((val) => parseFloat(val.toString())),
1607
1611
  "float"
package/dist/mod.d.cts CHANGED
@@ -133,6 +133,7 @@ declare const Types: {
133
133
  };
134
134
  object: <T extends z.ZodRawShape>(shape: T, params?: z.RawCreateParams) => z.ZodObject<T, "strip", z.ZodTypeAny, z.objectOutputType<T, z.ZodTypeAny, "strip">, z.objectInputType<T, z.ZodTypeAny, "strip">>;
135
135
  json: () => z.ZodAny & CassandraTypeMarker;
136
+ record: <Keys extends z.ZodTypeAny, Value extends z.ZodTypeAny>(keyType: Keys, valueType: Value) => z.ZodRecord<Keys, Value> & CassandraTypeMarker;
136
137
  float: () => z.ZodEffects<z.ZodNumber, number, number> & CassandraTypeMarker;
137
138
  int: () => z.ZodNumber & CassandraTypeMarker;
138
139
  bigint: () => z.ZodBigInt & CassandraTypeMarker;
package/dist/mod.d.ts CHANGED
@@ -133,6 +133,7 @@ declare const Types: {
133
133
  };
134
134
  object: <T extends z.ZodRawShape>(shape: T, params?: z.RawCreateParams) => z.ZodObject<T, "strip", z.ZodTypeAny, z.objectOutputType<T, z.ZodTypeAny, "strip">, z.objectInputType<T, z.ZodTypeAny, "strip">>;
135
135
  json: () => z.ZodAny & CassandraTypeMarker;
136
+ record: <Keys extends z.ZodTypeAny, Value extends z.ZodTypeAny>(keyType: Keys, valueType: Value) => z.ZodRecord<Keys, Value> & CassandraTypeMarker;
136
137
  float: () => z.ZodEffects<z.ZodNumber, number, number> & CassandraTypeMarker;
137
138
  int: () => z.ZodNumber & CassandraTypeMarker;
138
139
  bigint: () => z.ZodBigInt & CassandraTypeMarker;
package/dist/mod.js CHANGED
@@ -1011,7 +1011,7 @@ function convertValueToCassandra(value, config) {
1011
1011
  }
1012
1012
  }
1013
1013
  function convertValueFromCassandra(value, config, zodSchema, filedName) {
1014
- if (value === null) {
1014
+ if (value === null && !config.type.startsWith("list<") && !config.type.startsWith("set<")) {
1015
1015
  return config.flags.optional ? null : void 0;
1016
1016
  }
1017
1017
  switch (config.type) {
@@ -1044,9 +1044,12 @@ function convertValueFromCassandra(value, config, zodSchema, filedName) {
1044
1044
  switch (type) {
1045
1045
  case "list<text>":
1046
1046
  case "set<text>":
1047
+ if (!value || value === "null") {
1048
+ return [];
1049
+ }
1047
1050
  return value.map((item) => {
1048
1051
  try {
1049
- return JSON.parse(item);
1052
+ return JSON.parse(item) || [];
1050
1053
  } catch {
1051
1054
  return item;
1052
1055
  }
@@ -1600,6 +1603,7 @@ var Types = {
1600
1603
  enum: z.enum,
1601
1604
  object: z.object,
1602
1605
  json: () => createCassandraType(z.any(), "text"),
1606
+ record: (keyType, valueType) => createCassandraType(z.record(keyType, valueType), `text`),
1603
1607
  float: () => createCassandraType(
1604
1608
  z.number().transform((val) => parseFloat(val.toString())),
1605
1609
  "float"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imean-cassandra-orm",
3
- "version": "2.7.2",
3
+ "version": "2.7.4",
4
4
  "description": "cassandra orm",
5
5
  "keywords": [
6
6
  "cassandra",