@flowrunner/cli 0.1.18-dev.1 → 0.1.18-dev.3
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 +33 -7
- package/ai-docs/instructions/service-code-format/16-gotchas.md +9 -6
- package/dist/cli.js +127 -12
- package/dist/cli.js.map +2 -2
- package/dist/index.js +126 -11
- package/dist/index.js.map +2 -2
- package/dist/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +2 -2
- package/dist/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +8 -0
- package/package.json +1 -1
- package/runtime/index.js +126 -11
- package/runtime/index.js.map +2 -2
- package/runtime/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +2 -2
- package/runtime/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +8 -0
package/dist/index.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
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
|
|
16497
|
+
return !hasBlankBranch(ins) || absenceOf(schema).absorbsBlank;
|
|
16472
16498
|
}
|
|
16473
16499
|
if (absenceOf(schema).blankIsValue) {
|
|
16474
16500
|
return absenceOf(schema).absorbsBlank;
|
|
@@ -16537,6 +16563,72 @@ var EXPECTED = {
|
|
|
16537
16563
|
record: "an object"
|
|
16538
16564
|
};
|
|
16539
16565
|
var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
|
|
16566
|
+
var oneOf = (values) => `one of: ${values.map(String).join(", ")}`;
|
|
16567
|
+
var formatPhrase = (format) => {
|
|
16568
|
+
const described = FORMAT_DESCRIPTIONS[format ?? ""];
|
|
16569
|
+
return described?.replace(/^Expects (.*?), e\.g\. (.*)$/, "$1 (e.g. $2)").replace(/^Expects /, "");
|
|
16570
|
+
};
|
|
16571
|
+
var distinct = (phrases) => [...new Set(phrases.filter((phrase) => !!phrase))];
|
|
16572
|
+
function unionPhrases(union, value) {
|
|
16573
|
+
return distinct((inspect(union).branches ?? []).map((branch) => {
|
|
16574
|
+
try {
|
|
16575
|
+
const result = branch.safeParse(value);
|
|
16576
|
+
return branchPhrase(branch, result.error?.issues[0]);
|
|
16577
|
+
} catch {
|
|
16578
|
+
return void 0;
|
|
16579
|
+
}
|
|
16580
|
+
}));
|
|
16581
|
+
}
|
|
16582
|
+
function remainingIssue(branch, value) {
|
|
16583
|
+
if (!branch) {
|
|
16584
|
+
return void 0;
|
|
16585
|
+
}
|
|
16586
|
+
try {
|
|
16587
|
+
const result = branch.safeParse(coerceDeep(value, branch));
|
|
16588
|
+
return result.success ? void 0 : result.error?.issues[0];
|
|
16589
|
+
} catch {
|
|
16590
|
+
return void 0;
|
|
16591
|
+
}
|
|
16592
|
+
}
|
|
16593
|
+
function branchPhrase(branch, issue) {
|
|
16594
|
+
if (!branch || !issue) {
|
|
16595
|
+
return void 0;
|
|
16596
|
+
}
|
|
16597
|
+
const ins = inspect(branch);
|
|
16598
|
+
const values = ins.core._zod?.def?.values ?? [];
|
|
16599
|
+
if (ins.coreType === "literal" && values.length === 1 && values[0] === "") {
|
|
16600
|
+
return void 0;
|
|
16601
|
+
}
|
|
16602
|
+
const dateKind = dateStringKind(ins);
|
|
16603
|
+
if (dateKind) {
|
|
16604
|
+
return expectedDateString(ins, dateKind);
|
|
16605
|
+
}
|
|
16606
|
+
switch (issue.code) {
|
|
16607
|
+
case "invalid_type":
|
|
16608
|
+
return EXPECTED[issue.expected ?? ""] ?? issue.expected;
|
|
16609
|
+
case "invalid_value":
|
|
16610
|
+
return oneOf(issue.values ?? values);
|
|
16611
|
+
case "invalid_format":
|
|
16612
|
+
return formatPhrase(issue.format);
|
|
16613
|
+
// A bound has no short phrase ("a number of at least 10"); the branch still names its type.
|
|
16614
|
+
case "too_small":
|
|
16615
|
+
case "too_big":
|
|
16616
|
+
return EXPECTED[ins.coreType === "literal" ? literalType(ins.core) ?? "" : ins.coreType];
|
|
16617
|
+
default:
|
|
16618
|
+
return void 0;
|
|
16619
|
+
}
|
|
16620
|
+
}
|
|
16621
|
+
function unionIssue(plan2, issue, union, unionValue, fieldValue) {
|
|
16622
|
+
const branches = union ? inspect(union).branches : void 0;
|
|
16623
|
+
const errors = issue.errors ?? [];
|
|
16624
|
+
const deepIndex = errors.findIndex((branchIssues) => branchIssues.some((branchIssue) => (branchIssue.path ?? []).length));
|
|
16625
|
+
if (deepIndex >= 0) {
|
|
16626
|
+
const deep = remainingIssue(branches?.[deepIndex], unionValue) ?? errors[deepIndex].find((branchIssue) => (branchIssue.path ?? []).length);
|
|
16627
|
+
return toFieldIssue(plan2, { ...deep, path: [...issue.path ?? [], ...deep.path ?? []] }, fieldValue);
|
|
16628
|
+
}
|
|
16629
|
+
const phrases = distinct(errors.map((branchIssues, index) => branchPhrase(branches?.[index], branchIssues[0])));
|
|
16630
|
+
return phrases.length ? { path: "", code: "invalid_union", message: `must be ${phrases.join(", or ")}` } : void 0;
|
|
16631
|
+
}
|
|
16540
16632
|
var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
|
|
16541
16633
|
var isIndex = (segment) => /^\d+$/.test(segment);
|
|
16542
16634
|
function resolveTarget(plan2, segments, fieldValue) {
|
|
@@ -16583,6 +16675,12 @@ function toFieldIssue(plan2, issue, fieldValue) {
|
|
|
16583
16675
|
if (isAuthored(issue)) {
|
|
16584
16676
|
return { path: path19, code, message: issue.message };
|
|
16585
16677
|
}
|
|
16678
|
+
if (code !== "invalid_union" && target.schema && inspect(target.schema).branches) {
|
|
16679
|
+
const combined = unionPhrases(target.schema, target.value);
|
|
16680
|
+
if (combined.length > 1) {
|
|
16681
|
+
return { path: path19, code: "invalid_union", message: `\xAB${target.label}\xBB must be ${combined.join(", or ")}` };
|
|
16682
|
+
}
|
|
16683
|
+
}
|
|
16586
16684
|
const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
|
|
16587
16685
|
const dateMissing = target.value == null || target.value === "";
|
|
16588
16686
|
if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
|
|
@@ -16600,13 +16698,18 @@ function toFieldIssue(plan2, issue, fieldValue) {
|
|
|
16600
16698
|
return { path: path19, code, message: `\xAB${target.label}\xBB must be at most ${bound(issue.maximum, plan2)}` };
|
|
16601
16699
|
}
|
|
16602
16700
|
if (code === "invalid_value") {
|
|
16603
|
-
|
|
16604
|
-
return { path: path19, code, message: `\xAB${target.label}\xBB must be one of: ${values.join(", ")}` };
|
|
16701
|
+
return { path: path19, code, message: `\xAB${target.label}\xBB must be ${oneOf(issue.values ?? [])}` };
|
|
16605
16702
|
}
|
|
16606
16703
|
if (code === "invalid_format") {
|
|
16607
16704
|
const described = FORMAT_DESCRIPTIONS[issue.format ?? ""];
|
|
16608
16705
|
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
16706
|
}
|
|
16707
|
+
if (code === "invalid_union") {
|
|
16708
|
+
const combined = unionIssue(plan2, issue, target.schema, target.value, fieldValue);
|
|
16709
|
+
if (combined) {
|
|
16710
|
+
return combined.path ? combined : { path: path19, code, message: `\xAB${target.label}\xBB ${combined.message}` };
|
|
16711
|
+
}
|
|
16712
|
+
}
|
|
16610
16713
|
return { path: path19, code, message: `\xAB${target.label}\xBB is invalid` };
|
|
16611
16714
|
}
|
|
16612
16715
|
|
|
@@ -16627,7 +16730,7 @@ function isAbsent(value, plan2) {
|
|
|
16627
16730
|
return false;
|
|
16628
16731
|
}
|
|
16629
16732
|
if (plan2.isUnion) {
|
|
16630
|
-
return
|
|
16733
|
+
return !plan2.blankBranch || plan2.absorbsBlank;
|
|
16631
16734
|
}
|
|
16632
16735
|
if (plan2.blankIsValue) {
|
|
16633
16736
|
return plan2.absorbsBlank;
|
|
@@ -17772,7 +17875,19 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
17772
17875
|
return this.#options.invocation ?? {};
|
|
17773
17876
|
}
|
|
17774
17877
|
get config() {
|
|
17775
|
-
|
|
17878
|
+
if (!this.#config) {
|
|
17879
|
+
const { result, notices } = collectNotices(() => this.#extension.config.resolve(this.#options.configs));
|
|
17880
|
+
for (const { message, field, value, converted } of notices) {
|
|
17881
|
+
this.logger.warn(`[flow-extension:${this.#extension.id}] config item "${field ?? "?"}": ${message}`, {
|
|
17882
|
+
serviceId: this.#extension.id,
|
|
17883
|
+
configItem: field,
|
|
17884
|
+
value,
|
|
17885
|
+
converted,
|
|
17886
|
+
...this.invocation
|
|
17887
|
+
});
|
|
17888
|
+
}
|
|
17889
|
+
this.#config = result;
|
|
17890
|
+
}
|
|
17776
17891
|
return this.#config;
|
|
17777
17892
|
}
|
|
17778
17893
|
// The header access token plus its deserialized composite payload — or a throwing proxy when the
|