@flowrunner/cli 0.1.16 → 0.1.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowrunner/cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/runtime/index.js CHANGED
@@ -12557,8 +12557,29 @@ function toStringValue(value) {
12557
12557
  if (typeof value === "boolean") {
12558
12558
  return ok(String(value));
12559
12559
  }
12560
+ if (value !== null && typeof value === "object") {
12561
+ return ok(value instanceof Date ? value.toISOString() : JSON.stringify(value));
12562
+ }
12560
12563
  return typeof value === "number" && Number.isFinite(value) ? ok(String(value)) : fail("string");
12561
12564
  }
12565
+ var OPENS = { array: "[", object: "{" };
12566
+ function parseContainerText(value, kind) {
12567
+ if (typeof value !== "string") {
12568
+ return value;
12569
+ }
12570
+ const text2 = value.trim();
12571
+ if (!text2.startsWith(OPENS[kind])) {
12572
+ return value;
12573
+ }
12574
+ try {
12575
+ const parsed = JSON.parse(text2);
12576
+ const isList = Array.isArray(parsed);
12577
+ const fits = kind === "array" ? isList : parsed !== null && typeof parsed === "object" && !isList;
12578
+ return fits ? parsed : value;
12579
+ } catch {
12580
+ return value;
12581
+ }
12582
+ }
12562
12583
  function toNumberValue(value) {
12563
12584
  if (typeof value === "number") {
12564
12585
  return Number.isFinite(value) ? ok(value) : fail("number");
@@ -12641,7 +12662,11 @@ function coerceUnion(value, branches) {
12641
12662
  if (branches.some((branch) => accepts(branch, value))) {
12642
12663
  return value;
12643
12664
  }
12665
+ const isStructure = value !== null && typeof value === "object";
12644
12666
  for (const branch of branches) {
12667
+ if (isStructure && inspect(branch).coreType === "string") {
12668
+ continue;
12669
+ }
12645
12670
  const coerced = coerceDeep(value, branch);
12646
12671
  if (accepts(branch, coerced)) {
12647
12672
  return coerced;
@@ -12666,22 +12691,25 @@ function coerceDeep(value, schema) {
12666
12691
  }
12667
12692
  if (ins.coreType === "array") {
12668
12693
  const element = ins.core?._zod?.def?.element;
12669
- return Array.isArray(value) ? value.map((item) => coerceDeep(item, element)) : value;
12694
+ const list = parseContainerText(value, "array");
12695
+ return Array.isArray(list) ? list.map((item) => coerceDeep(item, element)) : list;
12670
12696
  }
12671
12697
  if (ins.coreType === "record") {
12672
- if (typeof value !== "object" || Array.isArray(value)) {
12673
- return value;
12698
+ const map = parseContainerText(value, "object");
12699
+ if (typeof map !== "object" || Array.isArray(map)) {
12700
+ return map;
12674
12701
  }
12675
12702
  const valueType = ins.core?._zod?.def?.valueType;
12676
12703
  return Object.fromEntries(
12677
- Object.entries(value).map(([key, item]) => [key, coerceDeep(item, valueType)])
12704
+ Object.entries(map).map(([key, item]) => [key, coerceDeep(item, valueType)])
12678
12705
  );
12679
12706
  }
12680
12707
  if (ins.coreType === "object") {
12681
- if (typeof value !== "object" || Array.isArray(value)) {
12682
- return value;
12708
+ const parsed = parseContainerText(value, "object");
12709
+ if (typeof parsed !== "object" || Array.isArray(parsed)) {
12710
+ return parsed;
12683
12711
  }
12684
- const source = value;
12712
+ const source = parsed;
12685
12713
  const coerced = { ...source };
12686
12714
  for (const [name, property] of shapeEntries(ins.core)) {
12687
12715
  if (name in source) {
@@ -12794,6 +12822,8 @@ var EXPECTED = {
12794
12822
  date: "a date",
12795
12823
  object: "an object",
12796
12824
  array: "an array",
12825
+ // zod's own token for `z.record()`, which the author declared as a map — to a person it is an object.
12826
+ record: "an object",
12797
12827
  // `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
12798
12828
  json: "valid JSON"
12799
12829
  };