@flowrunner/cli 0.1.17 → 0.1.18

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 (25) hide show
  1. package/ai-docs/instructions/service-code-format/02-zod-types.md +57 -33
  2. package/ai-docs/instructions/service-code-format/03-parameters.md +3 -1
  3. package/ai-docs/instructions/service-code-format/05-dictionaries.md +8 -2
  4. package/ai-docs/instructions/service-code-format/07-actions.md +1 -1
  5. package/ai-docs/instructions/service-code-format/14-reference-service.md +1 -1
  6. package/ai-docs/instructions/service-code-format/16-gotchas.md +59 -0
  7. package/ai-docs/instructions/service-code-format/18-test-recipes.md +2 -1
  8. package/ai-docs/instructions/service-code-format/README.md +1 -1
  9. package/dist/cli.js +25 -41
  10. package/dist/cli.js.map +3 -3
  11. package/dist/index.js +24 -40
  12. package/dist/index.js.map +3 -3
  13. package/dist/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
  14. package/dist/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -11
  15. package/dist/types/flow-extension-runner/src/v2/params/widget-types.d.ts +1 -1
  16. package/dist/types/flow-extension-runner/src/v2/params/zod.d.ts +9 -19
  17. package/dist/types/flow-extension-runner/src/v2/types.d.ts +1 -1
  18. package/package.json +1 -1
  19. package/runtime/index.js +24 -40
  20. package/runtime/index.js.map +3 -3
  21. package/runtime/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
  22. package/runtime/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -11
  23. package/runtime/types/flow-extension-runner/src/v2/params/widget-types.d.ts +1 -1
  24. package/runtime/types/flow-extension-runner/src/v2/params/zod.d.ts +9 -19
  25. package/runtime/types/flow-extension-runner/src/v2/types.d.ts +1 -1
package/dist/index.js CHANGED
@@ -15385,9 +15385,6 @@ function literalType(core) {
15385
15385
  }
15386
15386
  function deriveWidget(ins) {
15387
15387
  const { coreType, core, meta } = ins;
15388
- if (meta.frJson) {
15389
- return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
15390
- }
15391
15388
  switch (coreType) {
15392
15389
  case "string":
15393
15390
  if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
@@ -15777,7 +15774,6 @@ function declaredAbsence(schema) {
15777
15774
  function coerces(schema) {
15778
15775
  return inspect(schema).core?._zod?.def?.coerce === true;
15779
15776
  }
15780
- var parsesJson = (schema) => !!inspect(schema).meta.frJson;
15781
15777
  var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
15782
15778
  var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
15783
15779
  function requiredOpenType(schema) {
@@ -15799,7 +15795,7 @@ function requiredOpenType(schema) {
15799
15795
  return false;
15800
15796
  }
15801
15797
  function probeAbsence(schema) {
15802
- if (coerces(schema) || parsesJson(schema)) {
15798
+ if (coerces(schema)) {
15803
15799
  return declaredAbsence(schema);
15804
15800
  }
15805
15801
  if (requiredOpenType(schema)) {
@@ -15826,7 +15822,7 @@ function absenceOf(schema) {
15826
15822
  if (cached2) {
15827
15823
  return cached2;
15828
15824
  }
15829
- const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) && !parsesJson(schema) };
15825
+ const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) };
15830
15826
  probeCache.set(schema, probed);
15831
15827
  return probed;
15832
15828
  }
@@ -15922,16 +15918,6 @@ function toBooleanValue(value) {
15922
15918
  const lowered = value.trim().toLowerCase();
15923
15919
  return TRUE.has(lowered) ? ok(true) : FALSE.has(lowered) ? ok(false) : fail("boolean");
15924
15920
  }
15925
- function toJsonValue(value) {
15926
- if (typeof value !== "string") {
15927
- return ok(value);
15928
- }
15929
- try {
15930
- return ok(JSON.parse(value));
15931
- } catch {
15932
- return fail("json");
15933
- }
15934
- }
15935
15921
  function coerceValue(value, coreType) {
15936
15922
  if (coreType === "string") {
15937
15923
  return toStringValue(value);
@@ -16029,9 +16015,6 @@ function coerceLeaf(value, ins) {
16029
16015
  if (ins.branches) {
16030
16016
  return ok(coerceUnion(value, ins.branches));
16031
16017
  }
16032
- if (ins.meta.frJson) {
16033
- return toJsonValue(value);
16034
- }
16035
16018
  const format = formatOf(ins);
16036
16019
  if (ins.coreType === "string" && isConvertibleIso(format)) {
16037
16020
  const iso = toIso(value, format);
@@ -16126,9 +16109,7 @@ var EXPECTED = {
16126
16109
  object: "an object",
16127
16110
  array: "an array",
16128
16111
  // 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",
16130
- // `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
16131
- json: "valid JSON"
16112
+ record: "an object"
16132
16113
  };
16133
16114
  var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
16134
16115
  var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
@@ -16546,10 +16527,9 @@ function text() {
16546
16527
  return import_zod2.z.string().meta({ frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT });
16547
16528
  }
16548
16529
  function json() {
16549
- return import_zod2.z.unknown().nonoptional().meta({
16550
- frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT,
16551
- frJson: true
16552
- });
16530
+ throw new Error(
16531
+ "`z.json()` is not supported \u2014 declare `z.unknown()` for any value passed as given (`.required()` to make it required), or declare the shape: `z.object({ \u2026 })` / `z.array(\u2026)` also accept JSON text and parse it."
16532
+ );
16553
16533
  }
16554
16534
  var namespace = Object.create(import_zod2.z);
16555
16535
  Object.defineProperties(namespace, {
@@ -16563,7 +16543,7 @@ Object.defineProperties(namespace, {
16563
16543
  var z = namespace;
16564
16544
 
16565
16545
  // ../../flow-extension-runner/src/v2/params/json/values.ts
16566
- function toJsonValue2(value) {
16546
+ function toJsonValue(value) {
16567
16547
  if (typeof value === "bigint") {
16568
16548
  return { $bigint: value.toString() };
16569
16549
  }
@@ -16571,10 +16551,10 @@ function toJsonValue2(value) {
16571
16551
  return { $date: value.toISOString() };
16572
16552
  }
16573
16553
  if (Array.isArray(value)) {
16574
- return value.map(toJsonValue2);
16554
+ return value.map(toJsonValue);
16575
16555
  }
16576
16556
  if (value && typeof value === "object") {
16577
- return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue2(inner)]));
16557
+ return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue(inner)]));
16578
16558
  }
16579
16559
  return value;
16580
16560
  }
@@ -16609,18 +16589,18 @@ function encodeCheck(check) {
16609
16589
  switch (def.check) {
16610
16590
  // strings and arrays
16611
16591
  case "min_length":
16612
- return at("min", toJsonValue2(def.minimum));
16592
+ return at("min", toJsonValue(def.minimum));
16613
16593
  case "max_length":
16614
- return at("max", toJsonValue2(def.maximum));
16594
+ return at("max", toJsonValue(def.maximum));
16615
16595
  case "length_equals":
16616
- return at("length", toJsonValue2(def.length));
16596
+ return at("length", toJsonValue(def.length));
16617
16597
  // numbers and bigints
16618
16598
  case "greater_than":
16619
- return at("min", toJsonValue2(def.value), def.inclusive ? void 0 : true);
16599
+ return at("min", toJsonValue(def.value), def.inclusive ? void 0 : true);
16620
16600
  case "less_than":
16621
- return at("max", toJsonValue2(def.value), def.inclusive ? void 0 : true);
16601
+ return at("max", toJsonValue(def.value), def.inclusive ? void 0 : true);
16622
16602
  case "multiple_of":
16623
- return at("multipleOf", toJsonValue2(def.value));
16603
+ return at("multipleOf", toJsonValue(def.value));
16624
16604
  case "number_format":
16625
16605
  return def.format === "safeint" || def.format === "int32" ? at("int") : void 0;
16626
16606
  // the string sub-formats that are checks rather than types
@@ -16781,7 +16761,7 @@ function encodeMeta(meta, field, scope2, loaderId) {
16781
16761
  if (hasFunction(source)) {
16782
16762
  throw new Error(`Cannot encode "${field}": its metadata holds a function, which has no wire form.`);
16783
16763
  }
16784
- const encoded = toJsonValue2(source);
16764
+ const encoded = toJsonValue(source);
16785
16765
  return Object.keys(encoded).length ? encoded : void 0;
16786
16766
  }
16787
16767
  function isLoose(core) {
@@ -16791,11 +16771,11 @@ function isLoose(core) {
16791
16771
  function encodeValues(core, type) {
16792
16772
  if (type === "enum") {
16793
16773
  const entries = core?._zod?.def?.entries ?? {};
16794
- return Object.values(entries).map(toJsonValue2);
16774
+ return Object.values(entries).map(toJsonValue);
16795
16775
  }
16796
16776
  if (type === "literal") {
16797
16777
  const values = core?._zod?.def?.values ?? [];
16798
- return values.map(toJsonValue2);
16778
+ return values.map(toJsonValue);
16799
16779
  }
16800
16780
  return void 0;
16801
16781
  }
@@ -16825,7 +16805,7 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
16825
16805
  ...format ? { format } : {},
16826
16806
  ...optional ? { optional: true } : {},
16827
16807
  ...nullable ? { nullable: true } : {},
16828
- ...hasDefault ? { default: toJsonValue2(defaultValue) } : {},
16808
+ ...hasDefault ? { default: toJsonValue(defaultValue) } : {},
16829
16809
  ...checks.length ? { checks } : {},
16830
16810
  ...values?.length ? { values } : {},
16831
16811
  ...meta ? { meta } : {},
@@ -17502,6 +17482,10 @@ var DictionaryMethod = class extends ExtensionMethod {
17502
17482
  return this.criteria.keys();
17503
17483
  }
17504
17484
  // ── runtime ────────────────────────────────────────────────────────────────
17485
+ // `search` is always text, trimmed (FR-3910): `''` when the author typed nothing — the console then sends no
17486
+ // `search` at all — or only spaces. So a handler never guards it: `search ? { q: search } : undefined`, and
17487
+ // `search.toLowerCase()` as is. Surrounding spaces never mean anything to a lookup.
17488
+ //
17505
17489
  // Two-stage: the `{ search, cursor, criteria }` envelope the runtime owns, then the author-declared
17506
17490
  // criteria through the shared pipeline — reported as a criteria failure so the console can point at the
17507
17491
  // dependent fields rather than the whole call.
@@ -17510,7 +17494,7 @@ var DictionaryMethod = class extends ExtensionMethod {
17510
17494
  const payload = input.parseField("payload", DictionaryPayloadSchema);
17511
17495
  const criteria = this.criteria.normalize(this.#resolveAliases(payload.criteria), input.invalidCriteria());
17512
17496
  return {
17513
- search: payload.search,
17497
+ search: payload.search?.trim() ?? "",
17514
17498
  cursor: payload.cursor,
17515
17499
  criteria
17516
17500
  };