@flowrunner/cli 0.1.16 → 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.
- package/ai-docs/instructions/service-code-format/02-zod-types.md +87 -29
- package/ai-docs/instructions/service-code-format/03-parameters.md +3 -1
- package/ai-docs/instructions/service-code-format/05-dictionaries.md +8 -2
- package/ai-docs/instructions/service-code-format/07-actions.md +5 -1
- package/ai-docs/instructions/service-code-format/14-reference-service.md +1 -1
- package/ai-docs/instructions/service-code-format/16-gotchas.md +90 -0
- package/ai-docs/instructions/service-code-format/18-test-recipes.md +2 -1
- package/ai-docs/instructions/service-code-format/README.md +1 -1
- package/dist/cli.js +61 -47
- package/dist/cli.js.map +3 -3
- package/dist/index.js +60 -46
- package/dist/index.js.map +3 -3
- package/dist/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
- package/dist/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -11
- package/dist/types/flow-extension-runner/src/v2/params/widget-types.d.ts +1 -1
- package/dist/types/flow-extension-runner/src/v2/params/zod.d.ts +9 -19
- package/dist/types/flow-extension-runner/src/v2/types.d.ts +1 -1
- package/package.json +1 -1
- package/runtime/index.js +60 -46
- package/runtime/index.js.map +3 -3
- package/runtime/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
- package/runtime/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -11
- package/runtime/types/flow-extension-runner/src/v2/params/widget-types.d.ts +1 -1
- package/runtime/types/flow-extension-runner/src/v2/params/zod.d.ts +9 -19
- 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)
|
|
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)
|
|
15825
|
+
const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) };
|
|
15830
15826
|
probeCache.set(schema, probed);
|
|
15831
15827
|
return probed;
|
|
15832
15828
|
}
|
|
@@ -15860,8 +15856,29 @@ function toStringValue(value) {
|
|
|
15860
15856
|
if (typeof value === "boolean") {
|
|
15861
15857
|
return ok(String(value));
|
|
15862
15858
|
}
|
|
15859
|
+
if (value !== null && typeof value === "object") {
|
|
15860
|
+
return ok(value instanceof Date ? value.toISOString() : JSON.stringify(value));
|
|
15861
|
+
}
|
|
15863
15862
|
return typeof value === "number" && Number.isFinite(value) ? ok(String(value)) : fail("string");
|
|
15864
15863
|
}
|
|
15864
|
+
var OPENS = { array: "[", object: "{" };
|
|
15865
|
+
function parseContainerText(value, kind) {
|
|
15866
|
+
if (typeof value !== "string") {
|
|
15867
|
+
return value;
|
|
15868
|
+
}
|
|
15869
|
+
const text2 = value.trim();
|
|
15870
|
+
if (!text2.startsWith(OPENS[kind])) {
|
|
15871
|
+
return value;
|
|
15872
|
+
}
|
|
15873
|
+
try {
|
|
15874
|
+
const parsed = JSON.parse(text2);
|
|
15875
|
+
const isList = Array.isArray(parsed);
|
|
15876
|
+
const fits = kind === "array" ? isList : parsed !== null && typeof parsed === "object" && !isList;
|
|
15877
|
+
return fits ? parsed : value;
|
|
15878
|
+
} catch {
|
|
15879
|
+
return value;
|
|
15880
|
+
}
|
|
15881
|
+
}
|
|
15865
15882
|
function toNumberValue(value) {
|
|
15866
15883
|
if (typeof value === "number") {
|
|
15867
15884
|
return Number.isFinite(value) ? ok(value) : fail("number");
|
|
@@ -15901,16 +15918,6 @@ function toBooleanValue(value) {
|
|
|
15901
15918
|
const lowered = value.trim().toLowerCase();
|
|
15902
15919
|
return TRUE.has(lowered) ? ok(true) : FALSE.has(lowered) ? ok(false) : fail("boolean");
|
|
15903
15920
|
}
|
|
15904
|
-
function toJsonValue(value) {
|
|
15905
|
-
if (typeof value !== "string") {
|
|
15906
|
-
return ok(value);
|
|
15907
|
-
}
|
|
15908
|
-
try {
|
|
15909
|
-
return ok(JSON.parse(value));
|
|
15910
|
-
} catch {
|
|
15911
|
-
return fail("json");
|
|
15912
|
-
}
|
|
15913
|
-
}
|
|
15914
15921
|
function coerceValue(value, coreType) {
|
|
15915
15922
|
if (coreType === "string") {
|
|
15916
15923
|
return toStringValue(value);
|
|
@@ -15944,7 +15951,11 @@ function coerceUnion(value, branches) {
|
|
|
15944
15951
|
if (branches.some((branch) => accepts(branch, value))) {
|
|
15945
15952
|
return value;
|
|
15946
15953
|
}
|
|
15954
|
+
const isStructure = value !== null && typeof value === "object";
|
|
15947
15955
|
for (const branch of branches) {
|
|
15956
|
+
if (isStructure && inspect(branch).coreType === "string") {
|
|
15957
|
+
continue;
|
|
15958
|
+
}
|
|
15948
15959
|
const coerced = coerceDeep(value, branch);
|
|
15949
15960
|
if (accepts(branch, coerced)) {
|
|
15950
15961
|
return coerced;
|
|
@@ -15969,22 +15980,25 @@ function coerceDeep(value, schema) {
|
|
|
15969
15980
|
}
|
|
15970
15981
|
if (ins.coreType === "array") {
|
|
15971
15982
|
const element = ins.core?._zod?.def?.element;
|
|
15972
|
-
|
|
15983
|
+
const list = parseContainerText(value, "array");
|
|
15984
|
+
return Array.isArray(list) ? list.map((item) => coerceDeep(item, element)) : list;
|
|
15973
15985
|
}
|
|
15974
15986
|
if (ins.coreType === "record") {
|
|
15975
|
-
|
|
15976
|
-
|
|
15987
|
+
const map = parseContainerText(value, "object");
|
|
15988
|
+
if (typeof map !== "object" || Array.isArray(map)) {
|
|
15989
|
+
return map;
|
|
15977
15990
|
}
|
|
15978
15991
|
const valueType = ins.core?._zod?.def?.valueType;
|
|
15979
15992
|
return Object.fromEntries(
|
|
15980
|
-
Object.entries(
|
|
15993
|
+
Object.entries(map).map(([key, item]) => [key, coerceDeep(item, valueType)])
|
|
15981
15994
|
);
|
|
15982
15995
|
}
|
|
15983
15996
|
if (ins.coreType === "object") {
|
|
15984
|
-
|
|
15985
|
-
|
|
15997
|
+
const parsed = parseContainerText(value, "object");
|
|
15998
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
15999
|
+
return parsed;
|
|
15986
16000
|
}
|
|
15987
|
-
const source =
|
|
16001
|
+
const source = parsed;
|
|
15988
16002
|
const coerced = { ...source };
|
|
15989
16003
|
for (const [name, property] of shapeEntries(ins.core)) {
|
|
15990
16004
|
if (name in source) {
|
|
@@ -16001,9 +16015,6 @@ function coerceLeaf(value, ins) {
|
|
|
16001
16015
|
if (ins.branches) {
|
|
16002
16016
|
return ok(coerceUnion(value, ins.branches));
|
|
16003
16017
|
}
|
|
16004
|
-
if (ins.meta.frJson) {
|
|
16005
|
-
return toJsonValue(value);
|
|
16006
|
-
}
|
|
16007
16018
|
const format = formatOf(ins);
|
|
16008
16019
|
if (ins.coreType === "string" && isConvertibleIso(format)) {
|
|
16009
16020
|
const iso = toIso(value, format);
|
|
@@ -16097,8 +16108,8 @@ var EXPECTED = {
|
|
|
16097
16108
|
date: "a date",
|
|
16098
16109
|
object: "an object",
|
|
16099
16110
|
array: "an array",
|
|
16100
|
-
// `z.
|
|
16101
|
-
|
|
16111
|
+
// zod's own token for `z.record()`, which the author declared as a map — to a person it is an object.
|
|
16112
|
+
record: "an object"
|
|
16102
16113
|
};
|
|
16103
16114
|
var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
|
|
16104
16115
|
var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
|
|
@@ -16516,10 +16527,9 @@ function text() {
|
|
|
16516
16527
|
return import_zod2.z.string().meta({ frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT });
|
|
16517
16528
|
}
|
|
16518
16529
|
function json() {
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
|
|
16522
|
-
});
|
|
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
|
+
);
|
|
16523
16533
|
}
|
|
16524
16534
|
var namespace = Object.create(import_zod2.z);
|
|
16525
16535
|
Object.defineProperties(namespace, {
|
|
@@ -16533,7 +16543,7 @@ Object.defineProperties(namespace, {
|
|
|
16533
16543
|
var z = namespace;
|
|
16534
16544
|
|
|
16535
16545
|
// ../../flow-extension-runner/src/v2/params/json/values.ts
|
|
16536
|
-
function
|
|
16546
|
+
function toJsonValue(value) {
|
|
16537
16547
|
if (typeof value === "bigint") {
|
|
16538
16548
|
return { $bigint: value.toString() };
|
|
16539
16549
|
}
|
|
@@ -16541,10 +16551,10 @@ function toJsonValue2(value) {
|
|
|
16541
16551
|
return { $date: value.toISOString() };
|
|
16542
16552
|
}
|
|
16543
16553
|
if (Array.isArray(value)) {
|
|
16544
|
-
return value.map(
|
|
16554
|
+
return value.map(toJsonValue);
|
|
16545
16555
|
}
|
|
16546
16556
|
if (value && typeof value === "object") {
|
|
16547
|
-
return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key,
|
|
16557
|
+
return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue(inner)]));
|
|
16548
16558
|
}
|
|
16549
16559
|
return value;
|
|
16550
16560
|
}
|
|
@@ -16579,18 +16589,18 @@ function encodeCheck(check) {
|
|
|
16579
16589
|
switch (def.check) {
|
|
16580
16590
|
// strings and arrays
|
|
16581
16591
|
case "min_length":
|
|
16582
|
-
return at("min",
|
|
16592
|
+
return at("min", toJsonValue(def.minimum));
|
|
16583
16593
|
case "max_length":
|
|
16584
|
-
return at("max",
|
|
16594
|
+
return at("max", toJsonValue(def.maximum));
|
|
16585
16595
|
case "length_equals":
|
|
16586
|
-
return at("length",
|
|
16596
|
+
return at("length", toJsonValue(def.length));
|
|
16587
16597
|
// numbers and bigints
|
|
16588
16598
|
case "greater_than":
|
|
16589
|
-
return at("min",
|
|
16599
|
+
return at("min", toJsonValue(def.value), def.inclusive ? void 0 : true);
|
|
16590
16600
|
case "less_than":
|
|
16591
|
-
return at("max",
|
|
16601
|
+
return at("max", toJsonValue(def.value), def.inclusive ? void 0 : true);
|
|
16592
16602
|
case "multiple_of":
|
|
16593
|
-
return at("multipleOf",
|
|
16603
|
+
return at("multipleOf", toJsonValue(def.value));
|
|
16594
16604
|
case "number_format":
|
|
16595
16605
|
return def.format === "safeint" || def.format === "int32" ? at("int") : void 0;
|
|
16596
16606
|
// the string sub-formats that are checks rather than types
|
|
@@ -16751,7 +16761,7 @@ function encodeMeta(meta, field, scope2, loaderId) {
|
|
|
16751
16761
|
if (hasFunction(source)) {
|
|
16752
16762
|
throw new Error(`Cannot encode "${field}": its metadata holds a function, which has no wire form.`);
|
|
16753
16763
|
}
|
|
16754
|
-
const encoded =
|
|
16764
|
+
const encoded = toJsonValue(source);
|
|
16755
16765
|
return Object.keys(encoded).length ? encoded : void 0;
|
|
16756
16766
|
}
|
|
16757
16767
|
function isLoose(core) {
|
|
@@ -16761,11 +16771,11 @@ function isLoose(core) {
|
|
|
16761
16771
|
function encodeValues(core, type) {
|
|
16762
16772
|
if (type === "enum") {
|
|
16763
16773
|
const entries = core?._zod?.def?.entries ?? {};
|
|
16764
|
-
return Object.values(entries).map(
|
|
16774
|
+
return Object.values(entries).map(toJsonValue);
|
|
16765
16775
|
}
|
|
16766
16776
|
if (type === "literal") {
|
|
16767
16777
|
const values = core?._zod?.def?.values ?? [];
|
|
16768
|
-
return values.map(
|
|
16778
|
+
return values.map(toJsonValue);
|
|
16769
16779
|
}
|
|
16770
16780
|
return void 0;
|
|
16771
16781
|
}
|
|
@@ -16795,7 +16805,7 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
|
|
|
16795
16805
|
...format ? { format } : {},
|
|
16796
16806
|
...optional ? { optional: true } : {},
|
|
16797
16807
|
...nullable ? { nullable: true } : {},
|
|
16798
|
-
...hasDefault ? { default:
|
|
16808
|
+
...hasDefault ? { default: toJsonValue(defaultValue) } : {},
|
|
16799
16809
|
...checks.length ? { checks } : {},
|
|
16800
16810
|
...values?.length ? { values } : {},
|
|
16801
16811
|
...meta ? { meta } : {},
|
|
@@ -17472,6 +17482,10 @@ var DictionaryMethod = class extends ExtensionMethod {
|
|
|
17472
17482
|
return this.criteria.keys();
|
|
17473
17483
|
}
|
|
17474
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
|
+
//
|
|
17475
17489
|
// Two-stage: the `{ search, cursor, criteria }` envelope the runtime owns, then the author-declared
|
|
17476
17490
|
// criteria through the shared pipeline — reported as a criteria failure so the console can point at the
|
|
17477
17491
|
// dependent fields rather than the whole call.
|
|
@@ -17480,7 +17494,7 @@ var DictionaryMethod = class extends ExtensionMethod {
|
|
|
17480
17494
|
const payload = input.parseField("payload", DictionaryPayloadSchema);
|
|
17481
17495
|
const criteria = this.criteria.normalize(this.#resolveAliases(payload.criteria), input.invalidCriteria());
|
|
17482
17496
|
return {
|
|
17483
|
-
search: payload.search,
|
|
17497
|
+
search: payload.search?.trim() ?? "",
|
|
17484
17498
|
cursor: payload.cursor,
|
|
17485
17499
|
criteria
|
|
17486
17500
|
};
|