@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
@@ -4,7 +4,7 @@ export declare const DictionaryPayloadSchema: import("zod").ZodObject<{
4
4
  criteria: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
5
5
  }, import("zod/v4/core").$loose>;
6
6
  export interface DictionaryPayload {
7
- search?: string;
7
+ search: string;
8
8
  cursor?: unknown;
9
9
  criteria: Record<string, unknown>;
10
10
  }
@@ -1,12 +1,6 @@
1
1
  import { type AnyZod } from './introspect';
2
2
  /** `z.text()` — FlowRunner's own marker, the most specific thing a field can declare. */
3
3
  export declare const WIDGET_DESCRIPTIONS: Record<string, string>;
4
- /**
5
- * `z.json()`. More specific than the widget it carries: it renders as the same textarea `z.text()` does, so
6
- * the widget wording would say "line breaks are allowed" and leave out the only rule that actually rejects
7
- * anything — that what is typed has to parse.
8
- */
9
- export declare const JSON_DESCRIPTION = "Expects JSON, e.g. {\"key\": \"value\"}";
10
4
  /**
11
5
  * The plain core type, when nothing more specific is declared.
12
6
  *
@@ -26,11 +20,10 @@ export declare const FORMAT_DESCRIPTIONS: Record<string, string>;
26
20
  /**
27
21
  * What a field's declaration explains about itself, most specific wins:
28
22
  *
29
- * 1. `z.json()` — the content rule, which outranks the widget it shares with `z.text()`
30
- * 2. a FlowRunner widget marker — `z.text()`, a string the console renders specially
31
- * 3. a zod `format` token — `z.email()`, `z.ipv4()`, `z.iso.date()`, …
32
- * 4. the plain core type — `number`, `bigint`, `literal`, `enum`, `date`
23
+ * 1. a FlowRunner widget marker — `z.text()`, a string the console renders specially
24
+ * 2. a zod `format` token — `z.email()`, `z.ipv4()`, `z.iso.date()`, …
25
+ * 3. the plain core type — `number`, `bigint`, `literal`, `enum`, `date`
33
26
  *
34
- * All three are read past the optional/nullable/default wrappers, so a modifier never changes the answer.
27
+ * Each is read past the optional/nullable/default wrappers, so a modifier never changes the answer.
35
28
  */
36
29
  export declare function describeField(schema: AnyZod): string | undefined;
@@ -33,7 +33,7 @@ export declare const FlowExtensionParamWidgetTypes: {
33
33
  * The widget tokens a declaration carries EXPLICITLY, as author metadata (`meta.frWidget`) — everything else
34
34
  * in the map above is DERIVED from the zod type by `deriveWidget`.
35
35
  *
36
- * `MULTI_LINE_TEXT` is `z.text()` / `z.json()`; the `FILE_*_OPTIONS` tokens name a platform param group.
36
+ * `MULTI_LINE_TEXT` is `z.text()`; the `FILE_*_OPTIONS` tokens name a platform param group.
37
37
  */
38
38
  export type FrWidgetToken = 'MULTI_LINE_TEXT' | 'FILE_UPLOAD_OPTIONS' | 'FILE_LIST_OPTIONS' | 'FILE_GET_OPTIONS' | 'FILE_DELETE_OPTIONS';
39
39
  /** The subset that names a platform param GROUP rather than a single control. */
@@ -33,8 +33,6 @@ export interface FrMeta {
33
33
  /** A widget token the declaration carries explicitly — see `FrWidgetToken` in ./widget-types.ts. */
34
34
  frWidget?: FrWidgetToken;
35
35
  frSecret?: boolean;
36
- /** `z.json()` — the value arrives as TEXT and is parsed before the handler sees it. See `json()` below. */
37
- frJson?: boolean;
38
36
  /**
39
37
  * `.dynamicProps()` — the spec (holding the author's function) on a declared schema, the plain ref of the
40
38
  * method that runs it on a decoded one. Never encoded as the spec: see ./json/encode.ts.
@@ -98,25 +96,17 @@ declare module 'zod' {
98
96
  }
99
97
  declare function text(): baseZod.ZodString;
100
98
  /**
101
- * Custom type: a parameter that takes arbitrary JSON.
99
+ * `z.json()` is not a param type. It was one — JSON typed into a textarea, parsed before the handler ran — and
100
+ * was removed (FR-3910): `z.unknown()` takes any value as given, and a declared `z.object()` / `z.array()` takes
101
+ * JSON text of its kind (see ./schema/coerce.ts), so the only thing it still offered was a parse of free text
102
+ * into a value nobody had described.
102
103
  *
103
- * Three facts have to hold at once, and each picks one piece of this declaration:
104
- *
105
- * - **The console renders a textarea.** `frWidget` says so, and ../schema/introspect.ts publishes the
106
- * parameter as `STRING` — the model describes what a caller SUPPLIES, and what a caller supplies is text.
107
- * - **`execute` receives the parsed structure.** `frJson` tells ../schema/coerce.ts to `JSON.parse` the text
108
- * on the way in, so no service writes its own parse and none has to invent wording for text that is not
109
- * JSON. Coercion already sits between the transport and zod for exactly this kind of conversion — this is
110
- * the same arrangement as `z.string().pipe(z.coerce.number())`, with a fixed conversion.
111
- * - **The author's TYPE is the parsed value, not the text.** Hence `unknown` underneath: `z.infer` gives the
112
- * handler `unknown`, which is what it actually receives. Declaring `z.string()` here would publish and
113
- * coerce correctly and then lie to every author about what lands in `params`.
114
- *
115
- * ⚠️ This SHADOWS zod's own `z.json()` (the namespace is `Object.create(baseZod)`). Deliberate, and safe
116
- * only because zod's version cannot currently be declared at all — it recurses until the stack is gone, and
117
- * the extension never registers (FR-3600). An author reaching for `z.json()` gets this one.
104
+ * It throws rather than disappearing, because the name would otherwise fall through to zod's own `z.json()`
105
+ * (the namespace is `Object.create(baseZod)`), which cannot be declared at all: it recurses until the stack is
106
+ * gone and the extension never registers (FR-3600). An author following an old example gets a message naming
107
+ * what to write instead, at registration, instead of a stack overflow.
118
108
  */
119
- declare function json(): baseZod.ZodNonOptional<baseZod.ZodUnknown>;
109
+ declare function json(): never;
120
110
  export declare const z: Omit<typeof baseZod, "json"> & {
121
111
  text: typeof text;
122
112
  json: typeof json;
@@ -90,7 +90,7 @@ export interface DictionaryProps<TShape extends ExtensionShape = AnyShape, TCrit
90
90
  result?: unknown;
91
91
  oauth2Scopes?: string[];
92
92
  execute: (bag: HandlerBag<TShape> & {
93
- search?: string;
93
+ search: string;
94
94
  cursor?: unknown;
95
95
  criteria: Infer<TCriteria>;
96
96
  }) => DictionaryResult | DictionaryResultItems | Promise<DictionaryResult | DictionaryResultItems>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowrunner/cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/runtime/index.js CHANGED
@@ -12082,9 +12082,6 @@ function literalType(core) {
12082
12082
  }
12083
12083
  function deriveWidget(ins) {
12084
12084
  const { coreType, core, meta } = ins;
12085
- if (meta.frJson) {
12086
- return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
12087
- }
12088
12085
  switch (coreType) {
12089
12086
  case "string":
12090
12087
  if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
@@ -12474,7 +12471,6 @@ function declaredAbsence(schema) {
12474
12471
  function coerces(schema) {
12475
12472
  return inspect(schema).core?._zod?.def?.coerce === true;
12476
12473
  }
12477
- var parsesJson = (schema) => !!inspect(schema).meta.frJson;
12478
12474
  var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
12479
12475
  var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
12480
12476
  function requiredOpenType(schema) {
@@ -12496,7 +12492,7 @@ function requiredOpenType(schema) {
12496
12492
  return false;
12497
12493
  }
12498
12494
  function probeAbsence(schema) {
12499
- if (coerces(schema) || parsesJson(schema)) {
12495
+ if (coerces(schema)) {
12500
12496
  return declaredAbsence(schema);
12501
12497
  }
12502
12498
  if (requiredOpenType(schema)) {
@@ -12523,7 +12519,7 @@ function absenceOf(schema) {
12523
12519
  if (cached) {
12524
12520
  return cached;
12525
12521
  }
12526
- const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) && !parsesJson(schema) };
12522
+ const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) };
12527
12523
  probeCache.set(schema, probed);
12528
12524
  return probed;
12529
12525
  }
@@ -12619,16 +12615,6 @@ function toBooleanValue(value) {
12619
12615
  const lowered = value.trim().toLowerCase();
12620
12616
  return TRUE.has(lowered) ? ok(true) : FALSE.has(lowered) ? ok(false) : fail("boolean");
12621
12617
  }
12622
- function toJsonValue(value) {
12623
- if (typeof value !== "string") {
12624
- return ok(value);
12625
- }
12626
- try {
12627
- return ok(JSON.parse(value));
12628
- } catch {
12629
- return fail("json");
12630
- }
12631
- }
12632
12618
  function coerceValue(value, coreType) {
12633
12619
  if (coreType === "string") {
12634
12620
  return toStringValue(value);
@@ -12726,9 +12712,6 @@ function coerceLeaf(value, ins) {
12726
12712
  if (ins.branches) {
12727
12713
  return ok(coerceUnion(value, ins.branches));
12728
12714
  }
12729
- if (ins.meta.frJson) {
12730
- return toJsonValue(value);
12731
- }
12732
12715
  const format = formatOf(ins);
12733
12716
  if (ins.coreType === "string" && isConvertibleIso(format)) {
12734
12717
  const iso = toIso(value, format);
@@ -12823,9 +12806,7 @@ var EXPECTED = {
12823
12806
  object: "an object",
12824
12807
  array: "an array",
12825
12808
  // 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",
12827
- // `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
12828
- json: "valid JSON"
12809
+ record: "an object"
12829
12810
  };
12830
12811
  var requiredMessage = (plan) => `\xAB${plan.label}\xBB is required`;
12831
12812
  var invalidTypeMessage = (plan, expected) => `\xAB${plan.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
@@ -13243,10 +13224,9 @@ function text() {
13243
13224
  return import_zod2.z.string().meta({ frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT });
13244
13225
  }
13245
13226
  function json() {
13246
- return import_zod2.z.unknown().nonoptional().meta({
13247
- frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT,
13248
- frJson: true
13249
- });
13227
+ throw new Error(
13228
+ "`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."
13229
+ );
13250
13230
  }
13251
13231
  var namespace = Object.create(import_zod2.z);
13252
13232
  Object.defineProperties(namespace, {
@@ -13260,7 +13240,7 @@ Object.defineProperties(namespace, {
13260
13240
  var z = namespace;
13261
13241
 
13262
13242
  // ../../flow-extension-runner/src/v2/params/json/values.ts
13263
- function toJsonValue2(value) {
13243
+ function toJsonValue(value) {
13264
13244
  if (typeof value === "bigint") {
13265
13245
  return { $bigint: value.toString() };
13266
13246
  }
@@ -13268,10 +13248,10 @@ function toJsonValue2(value) {
13268
13248
  return { $date: value.toISOString() };
13269
13249
  }
13270
13250
  if (Array.isArray(value)) {
13271
- return value.map(toJsonValue2);
13251
+ return value.map(toJsonValue);
13272
13252
  }
13273
13253
  if (value && typeof value === "object") {
13274
- return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue2(inner)]));
13254
+ return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue(inner)]));
13275
13255
  }
13276
13256
  return value;
13277
13257
  }
@@ -13306,18 +13286,18 @@ function encodeCheck(check) {
13306
13286
  switch (def.check) {
13307
13287
  // strings and arrays
13308
13288
  case "min_length":
13309
- return at("min", toJsonValue2(def.minimum));
13289
+ return at("min", toJsonValue(def.minimum));
13310
13290
  case "max_length":
13311
- return at("max", toJsonValue2(def.maximum));
13291
+ return at("max", toJsonValue(def.maximum));
13312
13292
  case "length_equals":
13313
- return at("length", toJsonValue2(def.length));
13293
+ return at("length", toJsonValue(def.length));
13314
13294
  // numbers and bigints
13315
13295
  case "greater_than":
13316
- return at("min", toJsonValue2(def.value), def.inclusive ? void 0 : true);
13296
+ return at("min", toJsonValue(def.value), def.inclusive ? void 0 : true);
13317
13297
  case "less_than":
13318
- return at("max", toJsonValue2(def.value), def.inclusive ? void 0 : true);
13298
+ return at("max", toJsonValue(def.value), def.inclusive ? void 0 : true);
13319
13299
  case "multiple_of":
13320
- return at("multipleOf", toJsonValue2(def.value));
13300
+ return at("multipleOf", toJsonValue(def.value));
13321
13301
  case "number_format":
13322
13302
  return def.format === "safeint" || def.format === "int32" ? at("int") : void 0;
13323
13303
  // the string sub-formats that are checks rather than types
@@ -13478,7 +13458,7 @@ function encodeMeta(meta, field, scope2, loaderId) {
13478
13458
  if (hasFunction(source)) {
13479
13459
  throw new Error(`Cannot encode "${field}": its metadata holds a function, which has no wire form.`);
13480
13460
  }
13481
- const encoded = toJsonValue2(source);
13461
+ const encoded = toJsonValue(source);
13482
13462
  return Object.keys(encoded).length ? encoded : void 0;
13483
13463
  }
13484
13464
  function isLoose(core) {
@@ -13488,11 +13468,11 @@ function isLoose(core) {
13488
13468
  function encodeValues(core, type) {
13489
13469
  if (type === "enum") {
13490
13470
  const entries = core?._zod?.def?.entries ?? {};
13491
- return Object.values(entries).map(toJsonValue2);
13471
+ return Object.values(entries).map(toJsonValue);
13492
13472
  }
13493
13473
  if (type === "literal") {
13494
13474
  const values = core?._zod?.def?.values ?? [];
13495
- return values.map(toJsonValue2);
13475
+ return values.map(toJsonValue);
13496
13476
  }
13497
13477
  return void 0;
13498
13478
  }
@@ -13522,7 +13502,7 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
13522
13502
  ...format ? { format } : {},
13523
13503
  ...optional ? { optional: true } : {},
13524
13504
  ...nullable ? { nullable: true } : {},
13525
- ...hasDefault ? { default: toJsonValue2(defaultValue) } : {},
13505
+ ...hasDefault ? { default: toJsonValue(defaultValue) } : {},
13526
13506
  ...checks.length ? { checks } : {},
13527
13507
  ...values?.length ? { values } : {},
13528
13508
  ...meta ? { meta } : {},
@@ -14324,6 +14304,10 @@ var DictionaryMethod = class extends ExtensionMethod {
14324
14304
  return this.criteria.keys();
14325
14305
  }
14326
14306
  // ── runtime ────────────────────────────────────────────────────────────────
14307
+ // `search` is always text, trimmed (FR-3910): `''` when the author typed nothing — the console then sends no
14308
+ // `search` at all — or only spaces. So a handler never guards it: `search ? { q: search } : undefined`, and
14309
+ // `search.toLowerCase()` as is. Surrounding spaces never mean anything to a lookup.
14310
+ //
14327
14311
  // Two-stage: the `{ search, cursor, criteria }` envelope the runtime owns, then the author-declared
14328
14312
  // criteria through the shared pipeline — reported as a criteria failure so the console can point at the
14329
14313
  // dependent fields rather than the whole call.
@@ -14332,7 +14316,7 @@ var DictionaryMethod = class extends ExtensionMethod {
14332
14316
  const payload = input.parseField("payload", DictionaryPayloadSchema);
14333
14317
  const criteria = this.criteria.normalize(this.#resolveAliases(payload.criteria), input.invalidCriteria());
14334
14318
  return {
14335
- search: payload.search,
14319
+ search: payload.search?.trim() ?? "",
14336
14320
  cursor: payload.cursor,
14337
14321
  criteria
14338
14322
  };