@flowrunner/cli 0.1.15 → 0.1.16

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
@@ -15772,16 +15772,39 @@ function declaredAbsence(schema) {
15772
15772
  current = def.innerType;
15773
15773
  }
15774
15774
  const absence = acceptsUndefined && acceptsNull ? "as-received" : acceptsUndefined ? "undefined" : acceptsNull ? "null" : "required";
15775
- return { absence, absorbsBlank };
15775
+ return { absence, absorbsBlank, keepsEmpty: false, blankIsValue: false };
15776
15776
  }
15777
15777
  function coerces(schema) {
15778
15778
  return inspect(schema).core?._zod?.def?.coerce === true;
15779
15779
  }
15780
15780
  var parsesJson = (schema) => !!inspect(schema).meta.frJson;
15781
+ var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
15782
+ var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
15783
+ function requiredOpenType(schema) {
15784
+ if (!isOpenType(schema)) {
15785
+ return false;
15786
+ }
15787
+ let current = schema;
15788
+ while (current?._zod) {
15789
+ const def = current._zod.def ?? {};
15790
+ const type = def.type;
15791
+ if (type === "nonoptional") {
15792
+ return true;
15793
+ }
15794
+ if (!TRANSPARENT_WRAPPERS.has(type)) {
15795
+ return false;
15796
+ }
15797
+ current = innerOf(def, type);
15798
+ }
15799
+ return false;
15800
+ }
15781
15801
  function probeAbsence(schema) {
15782
15802
  if (coerces(schema) || parsesJson(schema)) {
15783
15803
  return declaredAbsence(schema);
15784
15804
  }
15805
+ if (requiredOpenType(schema)) {
15806
+ return { absence: "required", absorbsBlank: false, keepsEmpty: true, blankIsValue: true };
15807
+ }
15785
15808
  const parse = (value) => {
15786
15809
  try {
15787
15810
  return schema.safeParse(value);
@@ -15792,24 +15815,24 @@ function probeAbsence(schema) {
15792
15815
  const asUndefined = parse(void 0);
15793
15816
  const asNull = parse(null);
15794
15817
  const absence = asUndefined.success && asNull.success ? "as-received" : asUndefined.success ? "undefined" : asNull.success ? "null" : "required";
15795
- return { absence, absorbsBlank: asUndefined.success && asUndefined.data !== void 0 };
15818
+ return { absence, absorbsBlank: asUndefined.success && asUndefined.data !== void 0, keepsEmpty: false, blankIsValue: false };
15796
15819
  }
15797
15820
  var probeCache = /* @__PURE__ */ new WeakMap();
15798
15821
  function absenceOf(schema) {
15799
15822
  if (!schema || typeof schema !== "object") {
15800
- return { absence: "as-received", absorbsBlank: false };
15823
+ return { absence: "as-received", absorbsBlank: false, keepsEmpty: false, blankIsValue: false };
15801
15824
  }
15802
15825
  const cached2 = probeCache.get(schema);
15803
15826
  if (cached2) {
15804
15827
  return cached2;
15805
15828
  }
15806
- const probed = probeAbsence(schema);
15829
+ const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) && !parsesJson(schema) };
15807
15830
  probeCache.set(schema, probed);
15808
15831
  return probed;
15809
15832
  }
15810
15833
  function planField(name, schema) {
15811
15834
  const ins = inspect(schema);
15812
- const { absence, absorbsBlank } = probeAbsence(schema);
15835
+ const { absence, absorbsBlank, keepsEmpty, blankIsValue } = absenceOf(schema);
15813
15836
  return {
15814
15837
  name,
15815
15838
  schema,
@@ -15818,6 +15841,8 @@ function planField(name, schema) {
15818
15841
  isUnion: !!ins.branches,
15819
15842
  absence,
15820
15843
  absorbsBlank,
15844
+ keepsEmpty,
15845
+ blankIsValue,
15821
15846
  passThroughDate: passesDateThrough(ins),
15822
15847
  restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
15823
15848
  };
@@ -15916,6 +15941,9 @@ function accepts(schema, value) {
15916
15941
  }
15917
15942
  }
15918
15943
  function coerceUnion(value, branches) {
15944
+ if (branches.some((branch) => accepts(branch, value))) {
15945
+ return value;
15946
+ }
15919
15947
  for (const branch of branches) {
15920
15948
  const coerced = coerceDeep(value, branch);
15921
15949
  if (accepts(branch, coerced)) {
@@ -15991,7 +16019,13 @@ function coerceLeaf(value, ins) {
15991
16019
  return coerceValue(value, ins.coreType);
15992
16020
  }
15993
16021
  function isBlank(value, ins, schema) {
15994
- if (value === void 0 || value === null) {
16022
+ if (value === void 0) {
16023
+ return true;
16024
+ }
16025
+ if (absenceOf(schema).keepsEmpty) {
16026
+ return false;
16027
+ }
16028
+ if (value === null) {
15995
16029
  return true;
15996
16030
  }
15997
16031
  if (value !== "") {
@@ -16000,6 +16034,9 @@ function isBlank(value, ins, schema) {
16000
16034
  if (ins.branches) {
16001
16035
  return true;
16002
16036
  }
16037
+ if (absenceOf(schema).blankIsValue) {
16038
+ return absenceOf(schema).absorbsBlank;
16039
+ }
16003
16040
  return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
16004
16041
  }
16005
16042
  function absentAs(schema, value) {
@@ -16136,7 +16173,13 @@ function toFieldIssue(plan2, issue, fieldValue) {
16136
16173
  var resolved = (value) => ({ value, present: true, issues: [] });
16137
16174
  var rejected = (issues) => ({ present: false, issues });
16138
16175
  function isAbsent(value, plan2) {
16139
- if (value === void 0 || value === null) {
16176
+ if (value === void 0) {
16177
+ return true;
16178
+ }
16179
+ if (plan2.keepsEmpty) {
16180
+ return false;
16181
+ }
16182
+ if (value === null) {
16140
16183
  return true;
16141
16184
  }
16142
16185
  if (value !== "") {
@@ -16145,6 +16188,9 @@ function isAbsent(value, plan2) {
16145
16188
  if (plan2.isUnion) {
16146
16189
  return true;
16147
16190
  }
16191
+ if (plan2.blankIsValue) {
16192
+ return plan2.absorbsBlank;
16193
+ }
16148
16194
  return plan2.coreType !== "string" || plan2.absorbsBlank;
16149
16195
  }
16150
16196
  function normalizeAbsence(value, plan2) {
@@ -16432,6 +16478,9 @@ function extendPrototype() {
16432
16478
  const existing = this.meta()?.examples ?? [];
16433
16479
  return this.meta({ examples: [...existing, value] });
16434
16480
  };
16481
+ proto.required = function required() {
16482
+ return this.nonoptional();
16483
+ };
16435
16484
  proto.shared = function shared() {
16436
16485
  return this.meta({ frShared: true });
16437
16486
  };