@flowrunner/cli 0.1.15 → 0.1.17
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 +96 -18
- package/ai-docs/instructions/service-code-format/07-actions.md +4 -0
- package/ai-docs/instructions/service-code-format/16-gotchas.md +35 -0
- package/dist/cli.js +94 -15
- package/dist/cli.js.map +3 -3
- package/dist/index.js +93 -14
- package/dist/index.js.map +3 -3
- package/dist/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +9 -4
- package/dist/types/flow-extension-runner/src/v2/params/zod.d.ts +12 -0
- package/package.json +1 -1
- package/runtime/index.js +93 -14
- package/runtime/index.js.map +3 -3
- package/runtime/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +9 -4
- package/runtime/types/flow-extension-runner/src/v2/params/zod.d.ts +12 -0
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 } =
|
|
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
|
};
|
|
@@ -15835,8 +15860,29 @@ function toStringValue(value) {
|
|
|
15835
15860
|
if (typeof value === "boolean") {
|
|
15836
15861
|
return ok(String(value));
|
|
15837
15862
|
}
|
|
15863
|
+
if (value !== null && typeof value === "object") {
|
|
15864
|
+
return ok(value instanceof Date ? value.toISOString() : JSON.stringify(value));
|
|
15865
|
+
}
|
|
15838
15866
|
return typeof value === "number" && Number.isFinite(value) ? ok(String(value)) : fail("string");
|
|
15839
15867
|
}
|
|
15868
|
+
var OPENS = { array: "[", object: "{" };
|
|
15869
|
+
function parseContainerText(value, kind) {
|
|
15870
|
+
if (typeof value !== "string") {
|
|
15871
|
+
return value;
|
|
15872
|
+
}
|
|
15873
|
+
const text2 = value.trim();
|
|
15874
|
+
if (!text2.startsWith(OPENS[kind])) {
|
|
15875
|
+
return value;
|
|
15876
|
+
}
|
|
15877
|
+
try {
|
|
15878
|
+
const parsed = JSON.parse(text2);
|
|
15879
|
+
const isList = Array.isArray(parsed);
|
|
15880
|
+
const fits = kind === "array" ? isList : parsed !== null && typeof parsed === "object" && !isList;
|
|
15881
|
+
return fits ? parsed : value;
|
|
15882
|
+
} catch {
|
|
15883
|
+
return value;
|
|
15884
|
+
}
|
|
15885
|
+
}
|
|
15840
15886
|
function toNumberValue(value) {
|
|
15841
15887
|
if (typeof value === "number") {
|
|
15842
15888
|
return Number.isFinite(value) ? ok(value) : fail("number");
|
|
@@ -15916,7 +15962,14 @@ function accepts(schema, value) {
|
|
|
15916
15962
|
}
|
|
15917
15963
|
}
|
|
15918
15964
|
function coerceUnion(value, branches) {
|
|
15965
|
+
if (branches.some((branch) => accepts(branch, value))) {
|
|
15966
|
+
return value;
|
|
15967
|
+
}
|
|
15968
|
+
const isStructure = value !== null && typeof value === "object";
|
|
15919
15969
|
for (const branch of branches) {
|
|
15970
|
+
if (isStructure && inspect(branch).coreType === "string") {
|
|
15971
|
+
continue;
|
|
15972
|
+
}
|
|
15920
15973
|
const coerced = coerceDeep(value, branch);
|
|
15921
15974
|
if (accepts(branch, coerced)) {
|
|
15922
15975
|
return coerced;
|
|
@@ -15941,22 +15994,25 @@ function coerceDeep(value, schema) {
|
|
|
15941
15994
|
}
|
|
15942
15995
|
if (ins.coreType === "array") {
|
|
15943
15996
|
const element = ins.core?._zod?.def?.element;
|
|
15944
|
-
|
|
15997
|
+
const list = parseContainerText(value, "array");
|
|
15998
|
+
return Array.isArray(list) ? list.map((item) => coerceDeep(item, element)) : list;
|
|
15945
15999
|
}
|
|
15946
16000
|
if (ins.coreType === "record") {
|
|
15947
|
-
|
|
15948
|
-
|
|
16001
|
+
const map = parseContainerText(value, "object");
|
|
16002
|
+
if (typeof map !== "object" || Array.isArray(map)) {
|
|
16003
|
+
return map;
|
|
15949
16004
|
}
|
|
15950
16005
|
const valueType = ins.core?._zod?.def?.valueType;
|
|
15951
16006
|
return Object.fromEntries(
|
|
15952
|
-
Object.entries(
|
|
16007
|
+
Object.entries(map).map(([key, item]) => [key, coerceDeep(item, valueType)])
|
|
15953
16008
|
);
|
|
15954
16009
|
}
|
|
15955
16010
|
if (ins.coreType === "object") {
|
|
15956
|
-
|
|
15957
|
-
|
|
16011
|
+
const parsed = parseContainerText(value, "object");
|
|
16012
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
16013
|
+
return parsed;
|
|
15958
16014
|
}
|
|
15959
|
-
const source =
|
|
16015
|
+
const source = parsed;
|
|
15960
16016
|
const coerced = { ...source };
|
|
15961
16017
|
for (const [name, property] of shapeEntries(ins.core)) {
|
|
15962
16018
|
if (name in source) {
|
|
@@ -15991,7 +16047,13 @@ function coerceLeaf(value, ins) {
|
|
|
15991
16047
|
return coerceValue(value, ins.coreType);
|
|
15992
16048
|
}
|
|
15993
16049
|
function isBlank(value, ins, schema) {
|
|
15994
|
-
if (value === void 0
|
|
16050
|
+
if (value === void 0) {
|
|
16051
|
+
return true;
|
|
16052
|
+
}
|
|
16053
|
+
if (absenceOf(schema).keepsEmpty) {
|
|
16054
|
+
return false;
|
|
16055
|
+
}
|
|
16056
|
+
if (value === null) {
|
|
15995
16057
|
return true;
|
|
15996
16058
|
}
|
|
15997
16059
|
if (value !== "") {
|
|
@@ -16000,6 +16062,9 @@ function isBlank(value, ins, schema) {
|
|
|
16000
16062
|
if (ins.branches) {
|
|
16001
16063
|
return true;
|
|
16002
16064
|
}
|
|
16065
|
+
if (absenceOf(schema).blankIsValue) {
|
|
16066
|
+
return absenceOf(schema).absorbsBlank;
|
|
16067
|
+
}
|
|
16003
16068
|
return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
|
|
16004
16069
|
}
|
|
16005
16070
|
function absentAs(schema, value) {
|
|
@@ -16060,6 +16125,8 @@ var EXPECTED = {
|
|
|
16060
16125
|
date: "a date",
|
|
16061
16126
|
object: "an object",
|
|
16062
16127
|
array: "an array",
|
|
16128
|
+
// 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",
|
|
16063
16130
|
// `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
|
|
16064
16131
|
json: "valid JSON"
|
|
16065
16132
|
};
|
|
@@ -16136,7 +16203,13 @@ function toFieldIssue(plan2, issue, fieldValue) {
|
|
|
16136
16203
|
var resolved = (value) => ({ value, present: true, issues: [] });
|
|
16137
16204
|
var rejected = (issues) => ({ present: false, issues });
|
|
16138
16205
|
function isAbsent(value, plan2) {
|
|
16139
|
-
if (value === void 0
|
|
16206
|
+
if (value === void 0) {
|
|
16207
|
+
return true;
|
|
16208
|
+
}
|
|
16209
|
+
if (plan2.keepsEmpty) {
|
|
16210
|
+
return false;
|
|
16211
|
+
}
|
|
16212
|
+
if (value === null) {
|
|
16140
16213
|
return true;
|
|
16141
16214
|
}
|
|
16142
16215
|
if (value !== "") {
|
|
@@ -16145,6 +16218,9 @@ function isAbsent(value, plan2) {
|
|
|
16145
16218
|
if (plan2.isUnion) {
|
|
16146
16219
|
return true;
|
|
16147
16220
|
}
|
|
16221
|
+
if (plan2.blankIsValue) {
|
|
16222
|
+
return plan2.absorbsBlank;
|
|
16223
|
+
}
|
|
16148
16224
|
return plan2.coreType !== "string" || plan2.absorbsBlank;
|
|
16149
16225
|
}
|
|
16150
16226
|
function normalizeAbsence(value, plan2) {
|
|
@@ -16432,6 +16508,9 @@ function extendPrototype() {
|
|
|
16432
16508
|
const existing = this.meta()?.examples ?? [];
|
|
16433
16509
|
return this.meta({ examples: [...existing, value] });
|
|
16434
16510
|
};
|
|
16511
|
+
proto.required = function required() {
|
|
16512
|
+
return this.nonoptional();
|
|
16513
|
+
};
|
|
16435
16514
|
proto.shared = function shared() {
|
|
16436
16515
|
return this.meta({ frShared: true });
|
|
16437
16516
|
};
|