@inflector/optima 1.1.4 → 1.1.6

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.
@@ -95,6 +95,7 @@ var zodToDuckDBType = (zodType) => {
95
95
  if (zodType instanceof z.ZodBoolean) return "BOOLEAN";
96
96
  if (zodType instanceof z.ZodDate) return "TIMESTAMP";
97
97
  if (zodType instanceof z.ZodBigInt) return "BIGINT";
98
+ if (zodType instanceof z.ZodAny) return "VARCHAR";
98
99
  if ("element" in (def ?? {})) {
99
100
  const innerType = zodToDuckDBType(def.element);
100
101
  return `${innerType}[]`;
@@ -116,9 +117,8 @@ var Json = (obj) => {
116
117
  return col.STRUCTType(duckDBStructString);
117
118
  };
118
119
  var Array = (schema) => {
119
- const innerType = zodToDuckDBType(schema);
120
120
  const col = Column().SQlType("LIST");
121
- return col.STRUCTType(`${innerType}[]`);
121
+ return col.STRUCTType(`VARCHAR`);
122
122
  };
123
123
  var Email = () => Column().SQlType("VARCHAR").validate((v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v));
124
124
  var Slug = () => Column().SQlType("VARCHAR").validate((v) => /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(v));
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  Timestamp,
20
20
  Uuid,
21
21
  refHelpers
22
- } from "./chunk-JTCM2KCM.js";
22
+ } from "./chunk-FJ2AFIGL.js";
23
23
 
24
24
  // src/database.ts
25
25
  import { DuckDBInstance } from "@duckdb/node-api";
@@ -295,7 +295,9 @@ var notRegexp = (value) => cond().notRegexp(value);
295
295
  var escape = (val) => {
296
296
  if (val === null || val === void 0) return "NULL";
297
297
  if (typeof val === "bigint") return val.toString();
298
- if (typeof val === "string") return `'${val.replace(/'/g, "''")}'`;
298
+ if (typeof val === "string") {
299
+ return `'${val.replace(/\\/g, "\\\\").replace(/'/g, "''")}'`;
300
+ }
299
301
  if (val instanceof Date) return `'${val.toISOString()}'`;
300
302
  if (typeof val === "boolean") return val ? "TRUE" : "FALSE";
301
303
  if (typeof val === "object") {
@@ -303,7 +305,7 @@ var escape = (val) => {
303
305
  val,
304
306
  (_, v) => typeof v === "bigint" ? v.toString() : v
305
307
  );
306
- return `'${safe.replace(/'/g, "''")}'`;
308
+ return `'${safe.replace(/\\/g, "\\\\").replace(/'/g, "''")}'`;
307
309
  }
308
310
  return String(val);
309
311
  };
@@ -464,7 +466,7 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
464
466
  return Number(value);
465
467
  }
466
468
  if (Array.isArray(value)) {
467
- return value.map((item) => this.parseRecursive(item));
469
+ return value.map((item) => this.parseRecursive(item, type));
468
470
  }
469
471
  if (typeof value === "object") {
470
472
  if ("micros" in value && typeof value.micros === "bigint") {
@@ -472,20 +474,23 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
472
474
  return new Date(millis);
473
475
  }
474
476
  if (value.entries !== void 0) {
475
- return this.parseRecursive(value.entries);
477
+ return this.parseRecursive(value.entries, type);
476
478
  }
477
479
  if (value.items !== void 0) {
478
- return this.parseRecursive(value.items);
480
+ return this.parseRecursive(value.items, type);
479
481
  }
480
482
  const parsedObj = {};
481
483
  for (const [k, v] of Object.entries(value)) {
482
- parsedObj[k] = this.parseRecursive(v);
484
+ parsedObj[k] = this.parseRecursive(v, type);
483
485
  }
484
486
  return parsedObj;
485
487
  }
486
488
  if (type?.SQlType === "STRUCT" && type?.STRUCTType === "STRUCT()") {
487
489
  return JSON.parse(value);
488
490
  }
491
+ if (type?.SQlType === "LIST" && type?.STRUCTType === "VARCHAR") {
492
+ return JSON.parse(value);
493
+ }
489
494
  return value;
490
495
  };
491
496
  this.FormatOut = (data) => {
package/dist/types.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  Timestamp,
20
20
  Uuid,
21
21
  refHelpers
22
- } from "./chunk-JTCM2KCM.js";
22
+ } from "./chunk-FJ2AFIGL.js";
23
23
  export {
24
24
  Array,
25
25
  BigInt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflector/optima",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "type": "module",
5
5
  "author": "Inflector",
6
6
  "main": "./dist/index.js",