@flowrunner/cli 0.1.18-dev.1 → 0.1.18-dev.2

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
@@ -9836,8 +9836,8 @@ var require_get_intrinsic = __commonJS({
9836
9836
  throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
9837
9837
  }
9838
9838
  var result = [];
9839
- $replace(string, rePropName, function(match, number, quote, subString) {
9840
- result[result.length] = quote ? $replace(subString, reEscapeChar, "$1") : number || match;
9839
+ $replace(string, rePropName, function(match, number, quote2, subString) {
9840
+ result[result.length] = quote2 ? $replace(subString, reEscapeChar, "$1") : number || match;
9841
9841
  });
9842
9842
  return result;
9843
9843
  };
@@ -15352,6 +15352,12 @@ function literalType(core) {
15352
15352
  const [kind] = [...kinds];
15353
15353
  return kinds.size === 1 && LITERAL_KINDS.has(kind) ? kind : void 0;
15354
15354
  }
15355
+ function hasBlankBranch(ins) {
15356
+ return !!ins.branches?.some((branch) => {
15357
+ const { core, coreType } = inspect(branch);
15358
+ return coreType === "literal" && (core._zod?.def?.values ?? []).includes("");
15359
+ });
15360
+ }
15355
15361
  function deriveWidget(ins) {
15356
15362
  const { coreType, core, meta } = ins;
15357
15363
  switch (coreType) {
@@ -15538,6 +15544,11 @@ function compilePattern(pattern, kind) {
15538
15544
  if (missing.length) {
15539
15545
  throw new DateFormatError(`is missing ${missing.join(", ")} \u2014 every part of a ${describeKind(kind)} must be in it`);
15540
15546
  }
15547
+ if ((names.includes("HH") || names.includes("H")) && names.includes("a")) {
15548
+ throw new DateFormatError(
15549
+ "uses a 24-hour clock (`HH` / `H`) with `a` \u2014 13:45 would be written `13:45 PM`, which cannot be read back. Use `hh` / `h` with `a`, or `HH` without it"
15550
+ );
15551
+ }
15541
15552
  if ((names.includes("hh") || names.includes("h")) && !names.includes("a")) {
15542
15553
  throw new DateFormatError(
15543
15554
  "uses a 12-hour clock (`hh` / `h`) without `a` \u2014 without AM/PM the value cannot be read back. Add `a`, or use `HH` for a 24-hour clock"
@@ -15686,7 +15697,21 @@ function canonicalToPattern(canonical, ins, kind) {
15686
15697
  const parts = parseIso(canonical, kind);
15687
15698
  return parts ? formatParts(parts, pattern, kind) : canonical;
15688
15699
  }
15689
- var isTimestamp = (value) => typeof value === "number" && Number.isFinite(value) || typeof value === "string" && /^-?\d+(\.\d+)?$/.test(value.trim());
15700
+ var MIN_TIMESTAMP_DIGITS = 13;
15701
+ function digitOnlyLength(pattern, kind) {
15702
+ const example = formatParts(EXAMPLE, pattern, kind);
15703
+ return /^\d+$/.test(example) ? example.length : void 0;
15704
+ }
15705
+ function isTimestamp(value, pattern, kind) {
15706
+ if (typeof value === "number") {
15707
+ return Number.isFinite(value);
15708
+ }
15709
+ if (typeof value !== "string") {
15710
+ return false;
15711
+ }
15712
+ const text2 = value.trim();
15713
+ return new RegExp(`^\\d{${MIN_TIMESTAMP_DIGITS},}$`).test(text2) && digitOnlyLength(pattern, kind) !== text2.length;
15714
+ }
15690
15715
  function timestampParts(value, kind) {
15691
15716
  const date = new Date(Number(value));
15692
15717
  if (Number.isNaN(date.getTime())) {
@@ -15703,15 +15728,15 @@ function timestampParts(value, kind) {
15703
15728
  }, kind);
15704
15729
  }
15705
15730
  function toDateString(value, ins, kind) {
15706
- if (typeof value === "string") {
15707
- const text2 = value.trim();
15708
- const pattern = ins.meta.frDateFormat;
15709
- const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? parseIso(text2, kind);
15731
+ const pattern = ins.meta.frDateFormat;
15732
+ const text2 = typeof value === "string" ? value.trim() : typeof value === "number" && Number.isInteger(value) && value >= 0 ? String(value) : void 0;
15733
+ if (text2 !== void 0) {
15734
+ const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? (typeof value === "string" ? parseIso(text2, kind) : void 0);
15710
15735
  if (parts) {
15711
15736
  return { canonical: toCanonical(parts, kind) };
15712
15737
  }
15713
15738
  }
15714
- if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value)) {
15739
+ if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value, patternOf(ins, kind), kind)) {
15715
15740
  const parts = timestampParts(value, kind);
15716
15741
  return parts ? { canonical: toCanonical(parts, kind), fromTimestamp: true } : {};
15717
15742
  }
@@ -16216,6 +16241,7 @@ function planField(name, schema) {
16216
16241
  label: labelOf(name, schema),
16217
16242
  coreType: ins.coreType,
16218
16243
  isUnion: !!ins.branches,
16244
+ blankBranch: hasBlankBranch(ins),
16219
16245
  absence,
16220
16246
  absorbsBlank,
16221
16247
  keepsEmpty,
@@ -16468,7 +16494,7 @@ function isBlank(value, ins, schema) {
16468
16494
  return false;
16469
16495
  }
16470
16496
  if (ins.branches) {
16471
- return true;
16497
+ return !hasBlankBranch(ins) || absenceOf(schema).absorbsBlank;
16472
16498
  }
16473
16499
  if (absenceOf(schema).blankIsValue) {
16474
16500
  return absenceOf(schema).absorbsBlank;
@@ -16537,6 +16563,73 @@ var EXPECTED = {
16537
16563
  record: "an object"
16538
16564
  };
16539
16565
  var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
16566
+ var quote = (value) => typeof value === "string" ? JSON.stringify(value) : String(value);
16567
+ var oneOf = (values) => values.length === 1 ? quote(values[0]) : `one of: ${values.map(quote).join(", ")}`;
16568
+ var formatPhrase = (format) => {
16569
+ const described = FORMAT_DESCRIPTIONS[format ?? ""];
16570
+ return described?.replace(/^Expects (.*?), e\.g\. (.*)$/, "$1 (e.g. $2)").replace(/^Expects /, "");
16571
+ };
16572
+ var distinct = (phrases) => [...new Set(phrases.filter((phrase) => !!phrase))];
16573
+ function unionPhrases(union, value) {
16574
+ return distinct((inspect(union).branches ?? []).map((branch) => {
16575
+ try {
16576
+ const result = branch.safeParse(value);
16577
+ return branchPhrase(branch, result.error?.issues[0]);
16578
+ } catch {
16579
+ return void 0;
16580
+ }
16581
+ }));
16582
+ }
16583
+ function remainingIssue(branch, value) {
16584
+ if (!branch) {
16585
+ return void 0;
16586
+ }
16587
+ try {
16588
+ const result = branch.safeParse(coerceDeep(value, branch));
16589
+ return result.success ? void 0 : result.error?.issues[0];
16590
+ } catch {
16591
+ return void 0;
16592
+ }
16593
+ }
16594
+ function branchPhrase(branch, issue) {
16595
+ if (!branch || !issue) {
16596
+ return void 0;
16597
+ }
16598
+ const ins = inspect(branch);
16599
+ const values = ins.core._zod?.def?.values ?? [];
16600
+ if (ins.coreType === "literal" && values.length === 1 && values[0] === "") {
16601
+ return void 0;
16602
+ }
16603
+ const dateKind = dateStringKind(ins);
16604
+ if (dateKind) {
16605
+ return expectedDateString(ins, dateKind);
16606
+ }
16607
+ switch (issue.code) {
16608
+ case "invalid_type":
16609
+ return EXPECTED[issue.expected ?? ""] ?? issue.expected;
16610
+ case "invalid_value":
16611
+ return oneOf(issue.values ?? values);
16612
+ case "invalid_format":
16613
+ return formatPhrase(issue.format);
16614
+ // A bound has no short phrase ("a number of at least 10"); the branch still names its type.
16615
+ case "too_small":
16616
+ case "too_big":
16617
+ return EXPECTED[ins.coreType === "literal" ? literalType(ins.core) ?? "" : ins.coreType];
16618
+ default:
16619
+ return void 0;
16620
+ }
16621
+ }
16622
+ function unionIssue(plan2, issue, union, unionValue, fieldValue) {
16623
+ const branches = union ? inspect(union).branches : void 0;
16624
+ const errors = issue.errors ?? [];
16625
+ const deepIndex = errors.findIndex((branchIssues) => branchIssues.some((branchIssue) => (branchIssue.path ?? []).length));
16626
+ if (deepIndex >= 0) {
16627
+ const deep = remainingIssue(branches?.[deepIndex], unionValue) ?? errors[deepIndex].find((branchIssue) => (branchIssue.path ?? []).length);
16628
+ return toFieldIssue(plan2, { ...deep, path: [...issue.path ?? [], ...deep.path ?? []] }, fieldValue);
16629
+ }
16630
+ const phrases = distinct(errors.map((branchIssues, index) => branchPhrase(branches?.[index], branchIssues[0])));
16631
+ return phrases.length ? { path: "", code: "invalid_union", message: `must be ${phrases.join(", or ")}` } : void 0;
16632
+ }
16540
16633
  var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
16541
16634
  var isIndex = (segment) => /^\d+$/.test(segment);
16542
16635
  function resolveTarget(plan2, segments, fieldValue) {
@@ -16583,6 +16676,12 @@ function toFieldIssue(plan2, issue, fieldValue) {
16583
16676
  if (isAuthored(issue)) {
16584
16677
  return { path: path19, code, message: issue.message };
16585
16678
  }
16679
+ if (code !== "invalid_union" && target.schema && inspect(target.schema).branches) {
16680
+ const combined = unionPhrases(target.schema, target.value);
16681
+ if (combined.length > 1) {
16682
+ return { path: path19, code: "invalid_union", message: `\xAB${target.label}\xBB must be ${combined.join(", or ")}` };
16683
+ }
16684
+ }
16586
16685
  const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
16587
16686
  const dateMissing = target.value == null || target.value === "";
16588
16687
  if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
@@ -16600,13 +16699,18 @@ function toFieldIssue(plan2, issue, fieldValue) {
16600
16699
  return { path: path19, code, message: `\xAB${target.label}\xBB must be at most ${bound(issue.maximum, plan2)}` };
16601
16700
  }
16602
16701
  if (code === "invalid_value") {
16603
- const values = (issue.values ?? []).map(String);
16604
- return { path: path19, code, message: `\xAB${target.label}\xBB must be one of: ${values.join(", ")}` };
16702
+ return { path: path19, code, message: `\xAB${target.label}\xBB must be ${oneOf(issue.values ?? [])}` };
16605
16703
  }
16606
16704
  if (code === "invalid_format") {
16607
16705
  const described = FORMAT_DESCRIPTIONS[issue.format ?? ""];
16608
16706
  return described ? { path: path19, code, message: `\xAB${target.label}\xBB is invalid \u2014 ${described.replace(/^Expects /, "expects ")}` } : { path: path19, code, message: `\xAB${target.label}\xBB has an invalid format` };
16609
16707
  }
16708
+ if (code === "invalid_union") {
16709
+ const combined = unionIssue(plan2, issue, target.schema, target.value, fieldValue);
16710
+ if (combined) {
16711
+ return combined.path ? combined : { path: path19, code, message: `\xAB${target.label}\xBB ${combined.message}` };
16712
+ }
16713
+ }
16610
16714
  return { path: path19, code, message: `\xAB${target.label}\xBB is invalid` };
16611
16715
  }
16612
16716
 
@@ -16627,7 +16731,7 @@ function isAbsent(value, plan2) {
16627
16731
  return false;
16628
16732
  }
16629
16733
  if (plan2.isUnion) {
16630
- return true;
16734
+ return !plan2.blankBranch || plan2.absorbsBlank;
16631
16735
  }
16632
16736
  if (plan2.blankIsValue) {
16633
16737
  return plan2.absorbsBlank;
@@ -17772,7 +17876,19 @@ var ExecutionContext = class _ExecutionContext {
17772
17876
  return this.#options.invocation ?? {};
17773
17877
  }
17774
17878
  get config() {
17775
- this.#config ??= this.#extension.config.resolve(this.#options.configs);
17879
+ if (!this.#config) {
17880
+ const { result, notices } = collectNotices(() => this.#extension.config.resolve(this.#options.configs));
17881
+ for (const { message, field, value, converted } of notices) {
17882
+ this.logger.warn(`[flow-extension:${this.#extension.id}] config item "${field ?? "?"}": ${message}`, {
17883
+ serviceId: this.#extension.id,
17884
+ configItem: field,
17885
+ value,
17886
+ converted,
17887
+ ...this.invocation
17888
+ });
17889
+ }
17890
+ this.#config = result;
17891
+ }
17776
17892
  return this.#config;
17777
17893
  }
17778
17894
  // The header access token plus its deserialized composite payload — or a throwing proxy when the