@inflector/optima 1.0.3 → 1.0.5

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 (2) hide show
  1. package/dist/index.js +17 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -577,8 +577,13 @@ var OptimaTable = class _OptimaTable {
577
577
  const valuesBlock = Records.map((r) => {
578
578
  const orderedValues = columnKeys.map((key) => {
579
579
  let v = r[key];
580
- if (v == null && this.Columns[key].config.default) {
581
- v = this.Columns[key].config.default();
580
+ if (v == null) {
581
+ console.log(this.Columns[key].config);
582
+ if (typeof this.Columns[key].config.default === "function") {
583
+ v = this.Columns[key].config.default();
584
+ } else if (this.Columns[key].config.defaultNow) {
585
+ v = /* @__PURE__ */ new Date();
586
+ }
582
587
  }
583
588
  return escape(v);
584
589
  });
@@ -616,17 +621,22 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
616
621
  return { sql: query, args: [] };
617
622
  };
618
623
  // Helper to handle the deep recursion
619
- this.parseRecursive = (value) => {
624
+ // Helper to handle the deep recursion
625
+ this.parseRecursive = (value, type) => {
620
626
  if (value === null || value === void 0) {
621
627
  return value;
622
628
  }
623
- if (value instanceof Date) {
624
- return value;
629
+ if (typeof value === "bigint") {
630
+ return Number(value);
625
631
  }
626
632
  if (Array.isArray(value)) {
627
633
  return value.map((item) => this.parseRecursive(item));
628
634
  }
629
635
  if (typeof value === "object") {
636
+ if ("micros" in value && typeof value.micros === "bigint") {
637
+ const millis = Number(value.micros / 1000n);
638
+ return new Date(millis);
639
+ }
630
640
  if (value.entries !== void 0) {
631
641
  return this.parseRecursive(value.entries);
632
642
  }
@@ -649,7 +659,8 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
649
659
  formatted[key] = [];
650
660
  continue;
651
661
  }
652
- formatted[key] = this.parseRecursive(value);
662
+ const config = this.Columns && this.Columns[key] ? this.Columns[key].config : void 0;
663
+ formatted[key] = this.parseRecursive(value, config);
653
664
  }
654
665
  return formatted;
655
666
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflector/optima",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "author": "Inflector",
6
6
  "main": "./dist/index.js",