@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/dist/index.js CHANGED
@@ -15860,8 +15860,29 @@ function toStringValue(value) {
15860
15860
  if (typeof value === "boolean") {
15861
15861
  return ok(String(value));
15862
15862
  }
15863
+ if (value !== null && typeof value === "object") {
15864
+ return ok(value instanceof Date ? value.toISOString() : JSON.stringify(value));
15865
+ }
15863
15866
  return typeof value === "number" && Number.isFinite(value) ? ok(String(value)) : fail("string");
15864
15867
  }
15868
+ var OPENS = { array: "[", object: "{" };
15869
+ function parseContainerText(value, kind) {
15870
+ if (typeof value !== "string") {
15871
+ return value;
15872
+ }
15873
+ const text2 = value.trim();
15874
+ if (!text2.startsWith(OPENS[kind])) {
15875
+ return value;
15876
+ }
15877
+ try {
15878
+ const parsed = JSON.parse(text2);
15879
+ const isList = Array.isArray(parsed);
15880
+ const fits = kind === "array" ? isList : parsed !== null && typeof parsed === "object" && !isList;
15881
+ return fits ? parsed : value;
15882
+ } catch {
15883
+ return value;
15884
+ }
15885
+ }
15865
15886
  function toNumberValue(value) {
15866
15887
  if (typeof value === "number") {
15867
15888
  return Number.isFinite(value) ? ok(value) : fail("number");
@@ -15944,7 +15965,11 @@ function coerceUnion(value, branches) {
15944
15965
  if (branches.some((branch) => accepts(branch, value))) {
15945
15966
  return value;
15946
15967
  }
15968
+ const isStructure = value !== null && typeof value === "object";
15947
15969
  for (const branch of branches) {
15970
+ if (isStructure && inspect(branch).coreType === "string") {
15971
+ continue;
15972
+ }
15948
15973
  const coerced = coerceDeep(value, branch);
15949
15974
  if (accepts(branch, coerced)) {
15950
15975
  return coerced;
@@ -15969,22 +15994,25 @@ function coerceDeep(value, schema) {
15969
15994
  }
15970
15995
  if (ins.coreType === "array") {
15971
15996
  const element = ins.core?._zod?.def?.element;
15972
- return Array.isArray(value) ? value.map((item) => coerceDeep(item, element)) : value;
15997
+ const list = parseContainerText(value, "array");
15998
+ return Array.isArray(list) ? list.map((item) => coerceDeep(item, element)) : list;
15973
15999
  }
15974
16000
  if (ins.coreType === "record") {
15975
- if (typeof value !== "object" || Array.isArray(value)) {
15976
- return value;
16001
+ const map = parseContainerText(value, "object");
16002
+ if (typeof map !== "object" || Array.isArray(map)) {
16003
+ return map;
15977
16004
  }
15978
16005
  const valueType = ins.core?._zod?.def?.valueType;
15979
16006
  return Object.fromEntries(
15980
- Object.entries(value).map(([key, item]) => [key, coerceDeep(item, valueType)])
16007
+ Object.entries(map).map(([key, item]) => [key, coerceDeep(item, valueType)])
15981
16008
  );
15982
16009
  }
15983
16010
  if (ins.coreType === "object") {
15984
- if (typeof value !== "object" || Array.isArray(value)) {
15985
- return value;
16011
+ const parsed = parseContainerText(value, "object");
16012
+ if (typeof parsed !== "object" || Array.isArray(parsed)) {
16013
+ return parsed;
15986
16014
  }
15987
- const source = value;
16015
+ const source = parsed;
15988
16016
  const coerced = { ...source };
15989
16017
  for (const [name, property] of shapeEntries(ins.core)) {
15990
16018
  if (name in source) {
@@ -16097,6 +16125,8 @@ var EXPECTED = {
16097
16125
  date: "a date",
16098
16126
  object: "an object",
16099
16127
  array: "an array",
16128
+ // zod's own token for `z.record()`, which the author declared as a map — to a person it is an object.
16129
+ record: "an object",
16100
16130
  // `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
16101
16131
  json: "valid JSON"
16102
16132
  };