@flowrunner/cli 0.1.17 → 0.1.18-dev.2
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 +173 -41
- 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 +1 -1
- package/ai-docs/instructions/service-code-format/11-output-model.md +3 -0
- package/ai-docs/instructions/service-code-format/14-reference-service.md +1 -1
- package/ai-docs/instructions/service-code-format/16-gotchas.md +89 -6
- 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 +646 -89
- package/dist/cli.js.map +4 -4
- package/dist/index.js +645 -88
- package/dist/index.js.map +4 -4
- package/dist/types/flow-extension-runner/src/v2/context/execution-context.d.ts +8 -0
- package/dist/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
- package/dist/types/flow-extension-runner/src/v2/params/index.d.ts +2 -0
- package/dist/types/flow-extension-runner/src/v2/params/json/types.d.ts +2 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/date-format.d.ts +80 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -10
- package/dist/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +9 -2
- package/dist/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +8 -0
- package/dist/types/flow-extension-runner/src/v2/params/schema/notices.d.ts +15 -0
- 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 +30 -19
- package/dist/types/flow-extension-runner/src/v2/types.d.ts +1 -1
- package/package.json +1 -1
- package/runtime/index.js +652 -89
- package/runtime/index.js.map +4 -4
- package/runtime/types/flow-extension-runner/src/v2/context/execution-context.d.ts +8 -0
- package/runtime/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
- package/runtime/types/flow-extension-runner/src/v2/params/index.d.ts +2 -0
- package/runtime/types/flow-extension-runner/src/v2/params/json/types.d.ts +2 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/date-format.d.ts +80 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -10
- package/runtime/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +9 -2
- package/runtime/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +8 -0
- package/runtime/types/flow-extension-runner/src/v2/params/schema/notices.d.ts +15 -0
- 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 +30 -19
- package/runtime/types/flow-extension-runner/src/v2/types.d.ts +1 -1
package/runtime/index.js
CHANGED
|
@@ -9836,8 +9836,8 @@ var require_get_intrinsic = __commonJS({
|
|
|
9836
9836
|
throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
|
|
9837
9837
|
}
|
|
9838
9838
|
var result = [];
|
|
9839
|
-
$replace(string, rePropName, function(match, number,
|
|
9840
|
-
result[result.length] =
|
|
9839
|
+
$replace(string, rePropName, function(match, number, quote2, subString) {
|
|
9840
|
+
result[result.length] = quote2 ? $replace(subString, reEscapeChar, "$1") : number || match;
|
|
9841
9841
|
});
|
|
9842
9842
|
return result;
|
|
9843
9843
|
};
|
|
@@ -11936,39 +11936,6 @@ function assertObjectSchema(scheme, source) {
|
|
|
11936
11936
|
);
|
|
11937
11937
|
}
|
|
11938
11938
|
|
|
11939
|
-
// ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
|
|
11940
|
-
var DictionaryScope = class _DictionaryScope {
|
|
11941
|
-
constructor(top, visible) {
|
|
11942
|
-
this.top = top;
|
|
11943
|
-
this.visible = visible;
|
|
11944
|
-
}
|
|
11945
|
-
static {
|
|
11946
|
-
this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
|
|
11947
|
-
}
|
|
11948
|
-
enter(names) {
|
|
11949
|
-
if (!this.top) {
|
|
11950
|
-
const top = new Set(names);
|
|
11951
|
-
return new _DictionaryScope(top, top);
|
|
11952
|
-
}
|
|
11953
|
-
return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
|
|
11954
|
-
}
|
|
11955
|
-
};
|
|
11956
|
-
function resolveDependsOn(binding, scope2) {
|
|
11957
|
-
const aliases = binding.criteriaAliases ?? {};
|
|
11958
|
-
let clash;
|
|
11959
|
-
const dependsOn = binding.dependsOn.map((key) => {
|
|
11960
|
-
const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
|
|
11961
|
-
if (visible.length > 1 && !clash) {
|
|
11962
|
-
clash = { key, names: visible };
|
|
11963
|
-
}
|
|
11964
|
-
return visible[0] ?? key;
|
|
11965
|
-
});
|
|
11966
|
-
return clash ? { dependsOn, clash } : { dependsOn };
|
|
11967
|
-
}
|
|
11968
|
-
function publishedBinding(binding, scope2) {
|
|
11969
|
-
return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
|
|
11970
|
-
}
|
|
11971
|
-
|
|
11972
11939
|
// ../../flow-extension-runner/src/v2/params/widget-types.ts
|
|
11973
11940
|
var FlowExtensionParamGroupTypes = {
|
|
11974
11941
|
FILE_UPLOAD_OPTIONS: "FILE_UPLOAD_OPTIONS",
|
|
@@ -11987,7 +11954,9 @@ var FlowExtensionParamWidgetTypes = {
|
|
|
11987
11954
|
...FlowExtensionParamGroupTypes,
|
|
11988
11955
|
// legacy — no zod declaration produces these. They reach the console only from a legacy JSDoc-format
|
|
11989
11956
|
// service, which writes `uiComponent` by hand. Kept because the console still renders them for an
|
|
11990
|
-
// already-installed extension.
|
|
11957
|
+
// already-installed extension. `DATE_TIME_PICKER` / `TIME_PICKER` are also published, with
|
|
11958
|
+
// `valueKind: 'string'` and `format`, by `z.iso.datetime({ local: true })` / `z.iso.time()` (FR-3920) —
|
|
11959
|
+
// without `valueKind` they are the legacy tokens, storing epoch millis.
|
|
11991
11960
|
NUMERIC: "NUMERIC",
|
|
11992
11961
|
CHECKBOX: "CHECKBOX",
|
|
11993
11962
|
DATE_TIME_PICKER: "DATE_TIME_PICKER",
|
|
@@ -12080,17 +12049,20 @@ function literalType(core) {
|
|
|
12080
12049
|
const [kind] = [...kinds];
|
|
12081
12050
|
return kinds.size === 1 && LITERAL_KINDS.has(kind) ? kind : void 0;
|
|
12082
12051
|
}
|
|
12052
|
+
function hasBlankBranch(ins) {
|
|
12053
|
+
return !!ins.branches?.some((branch) => {
|
|
12054
|
+
const { core, coreType } = inspect(branch);
|
|
12055
|
+
return coreType === "literal" && (core._zod?.def?.values ?? []).includes("");
|
|
12056
|
+
});
|
|
12057
|
+
}
|
|
12083
12058
|
function deriveWidget(ins) {
|
|
12084
12059
|
const { coreType, core, meta } = ins;
|
|
12085
|
-
if (meta.frJson) {
|
|
12086
|
-
return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
|
|
12087
|
-
}
|
|
12088
12060
|
switch (coreType) {
|
|
12089
12061
|
case "string":
|
|
12090
12062
|
if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
|
|
12091
12063
|
return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
|
|
12092
12064
|
}
|
|
12093
|
-
return { paramType: "STRING" };
|
|
12065
|
+
return dateStringWidget(ins) ?? { paramType: "STRING" };
|
|
12094
12066
|
case "number":
|
|
12095
12067
|
case "bigint":
|
|
12096
12068
|
return { paramType: "NUMBER", uiComponent: { type: FlowExtensionParamWidgetTypes.NUMERIC_STEPPER } };
|
|
@@ -12133,11 +12105,399 @@ function deriveWidget(ins) {
|
|
|
12133
12105
|
return { paramType: "STRING" };
|
|
12134
12106
|
}
|
|
12135
12107
|
}
|
|
12108
|
+
var DATE_STRING_WIDGETS = {
|
|
12109
|
+
date: FlowExtensionParamWidgetTypes.DATE_PICKER,
|
|
12110
|
+
datetime: FlowExtensionParamWidgetTypes.DATE_TIME_PICKER,
|
|
12111
|
+
time: FlowExtensionParamWidgetTypes.TIME_PICKER
|
|
12112
|
+
};
|
|
12113
|
+
function dateStringWidget(ins) {
|
|
12114
|
+
const kind = dateStringKind(ins);
|
|
12115
|
+
return kind ? { paramType: "STRING", uiComponent: { type: DATE_STRING_WIDGETS[kind], valueKind: "string", format: patternOf(ins, kind) } } : void 0;
|
|
12116
|
+
}
|
|
12136
12117
|
function shapeEntries(schema) {
|
|
12137
12118
|
const shape = schema?.shape;
|
|
12138
12119
|
return shape && typeof shape === "object" ? Object.entries(shape) : [];
|
|
12139
12120
|
}
|
|
12140
12121
|
|
|
12122
|
+
// ../../flow-extension-runner/src/v2/params/schema/date-format.ts
|
|
12123
|
+
var ISO_PATTERNS = {
|
|
12124
|
+
date: "yyyy-MM-dd",
|
|
12125
|
+
datetime: "yyyy-MM-dd'T'HH:mm",
|
|
12126
|
+
time: "HH:mm"
|
|
12127
|
+
};
|
|
12128
|
+
var DATE_STRINGS_ACCEPT_TIMESTAMPS = true;
|
|
12129
|
+
function dateStringKind(ins) {
|
|
12130
|
+
if (ins.coreType !== "string") {
|
|
12131
|
+
return void 0;
|
|
12132
|
+
}
|
|
12133
|
+
const def = ins.core?._zod?.def;
|
|
12134
|
+
if (def?.format === "date" || def?.format === "time") {
|
|
12135
|
+
return def.format;
|
|
12136
|
+
}
|
|
12137
|
+
return def?.format === "datetime" && def.local ? "datetime" : void 0;
|
|
12138
|
+
}
|
|
12139
|
+
var patternOf = (ins, kind) => ins.meta.frDateFormat ?? ISO_PATTERNS[kind];
|
|
12140
|
+
var TOKENS = ["yyyy", "yy", "MM", "M", "dd", "d", "HH", "H", "hh", "h", "mm", "ss", "a"];
|
|
12141
|
+
var SPEC = {
|
|
12142
|
+
yyyy: { part: "year", width: 4 },
|
|
12143
|
+
yy: { part: "year", width: 2 },
|
|
12144
|
+
MM: { part: "month", width: 2 },
|
|
12145
|
+
M: { part: "month" },
|
|
12146
|
+
dd: { part: "day", width: 2 },
|
|
12147
|
+
d: { part: "day" },
|
|
12148
|
+
HH: { part: "hour", width: 2 },
|
|
12149
|
+
H: { part: "hour" },
|
|
12150
|
+
hh: { part: "hour", width: 2 },
|
|
12151
|
+
h: { part: "hour" },
|
|
12152
|
+
mm: { part: "minute", width: 2 },
|
|
12153
|
+
ss: { part: "second", width: 2 },
|
|
12154
|
+
a: { part: "meridiem" }
|
|
12155
|
+
};
|
|
12156
|
+
var DATE_PARTS = /* @__PURE__ */ new Set(["year", "month", "day"]);
|
|
12157
|
+
var TIME_PARTS = /* @__PURE__ */ new Set(["hour", "minute", "second", "meridiem"]);
|
|
12158
|
+
var DateFormatError = class extends Error {
|
|
12159
|
+
};
|
|
12160
|
+
var LOOK_ALIKES = {
|
|
12161
|
+
YYYY: "yyyy",
|
|
12162
|
+
YY: "yy",
|
|
12163
|
+
DD: "dd",
|
|
12164
|
+
D: "d",
|
|
12165
|
+
S: "ss",
|
|
12166
|
+
A: "a"
|
|
12167
|
+
};
|
|
12168
|
+
function tokenize(pattern, kind) {
|
|
12169
|
+
const tokens = [];
|
|
12170
|
+
let index = 0;
|
|
12171
|
+
while (index < pattern.length) {
|
|
12172
|
+
const char = pattern[index];
|
|
12173
|
+
if (char === "'") {
|
|
12174
|
+
const end = pattern.indexOf("'", index + 1);
|
|
12175
|
+
if (end < 0) {
|
|
12176
|
+
throw new DateFormatError("has an unclosed quote \u2014 literal text is written between two single quotes");
|
|
12177
|
+
}
|
|
12178
|
+
tokens.push({ literal: end === index + 1 ? "'" : pattern.slice(index + 1, end) });
|
|
12179
|
+
index = end + 1;
|
|
12180
|
+
continue;
|
|
12181
|
+
}
|
|
12182
|
+
if (!/[A-Za-z]/.test(char)) {
|
|
12183
|
+
tokens.push({ literal: char });
|
|
12184
|
+
index++;
|
|
12185
|
+
continue;
|
|
12186
|
+
}
|
|
12187
|
+
const run = /^([A-Za-z])\1*/.exec(pattern.slice(index))?.[0];
|
|
12188
|
+
const known = TOKENS.find((token) => run.startsWith(token) && token.length === run.length);
|
|
12189
|
+
if (!known) {
|
|
12190
|
+
const hint2 = LOOK_ALIKES[run] ? ` (did you mean \`${suggest(pattern, kind)}\`?)` : "";
|
|
12191
|
+
throw new DateFormatError(
|
|
12192
|
+
`uses \`${run}\`, which is not a supported token${hint2}. Supported: yyyy yy MM M dd d HH H hh h mm ss a, and literal text in single quotes`
|
|
12193
|
+
);
|
|
12194
|
+
}
|
|
12195
|
+
tokens.push({ token: known });
|
|
12196
|
+
index += run.length;
|
|
12197
|
+
}
|
|
12198
|
+
return tokens;
|
|
12199
|
+
}
|
|
12200
|
+
function suggest(pattern, kind) {
|
|
12201
|
+
let fixed = pattern;
|
|
12202
|
+
for (const [wrong, right] of Object.entries(LOOK_ALIKES)) {
|
|
12203
|
+
fixed = fixed.replace(new RegExp(`(?<![A-Za-z])${wrong}(?![A-Za-z])`, "g"), right);
|
|
12204
|
+
}
|
|
12205
|
+
if (kind === "date") {
|
|
12206
|
+
fixed = fixed.replace(/mm/g, "MM");
|
|
12207
|
+
}
|
|
12208
|
+
return fixed;
|
|
12209
|
+
}
|
|
12210
|
+
var parsedPatterns = /* @__PURE__ */ new Map();
|
|
12211
|
+
function compilePattern(pattern, kind) {
|
|
12212
|
+
const key = `${kind}|${pattern}`;
|
|
12213
|
+
const cached = parsedPatterns.get(key);
|
|
12214
|
+
if (cached) {
|
|
12215
|
+
return cached;
|
|
12216
|
+
}
|
|
12217
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
12218
|
+
throw new DateFormatError("needs a pattern, e.g. `dd/MM/yyyy`");
|
|
12219
|
+
}
|
|
12220
|
+
const tokens = tokenize(pattern, kind);
|
|
12221
|
+
const names = tokens.flatMap((token) => "token" in token ? [token.token] : []);
|
|
12222
|
+
const parts = names.map((name) => SPEC[name].part);
|
|
12223
|
+
const has = (part) => parts.includes(part);
|
|
12224
|
+
const repeated = parts.find((part, index) => parts.indexOf(part) !== index);
|
|
12225
|
+
if (repeated) {
|
|
12226
|
+
throw new DateFormatError(`names the ${repeated === "meridiem" ? "AM/PM" : repeated} twice`);
|
|
12227
|
+
}
|
|
12228
|
+
if (kind === "date" && names.includes("mm") && !has("hour")) {
|
|
12229
|
+
throw new DateFormatError(`uses \`mm\`, which is minutes \u2014 did you mean \`${suggest(pattern, kind)}\`?`);
|
|
12230
|
+
}
|
|
12231
|
+
if (kind === "date" && parts.some((part) => TIME_PARTS.has(part))) {
|
|
12232
|
+
throw new DateFormatError("has a time of day, which a date has not \u2014 declare `z.iso.datetime({ local: true })`");
|
|
12233
|
+
}
|
|
12234
|
+
if (kind === "time" && parts.some((part) => DATE_PARTS.has(part))) {
|
|
12235
|
+
throw new DateFormatError("has a date, which a time has not \u2014 declare `z.iso.datetime({ local: true })`");
|
|
12236
|
+
}
|
|
12237
|
+
const missing = [
|
|
12238
|
+
...kind !== "time" ? [["year", "yyyy"], ["month", "MM"], ["day", "dd"]] : [],
|
|
12239
|
+
...kind !== "date" ? [["hour", "HH"], ["minute", "mm"]] : []
|
|
12240
|
+
].filter(([part]) => !has(part)).map(([, token]) => `\`${token}\``);
|
|
12241
|
+
if (missing.length) {
|
|
12242
|
+
throw new DateFormatError(`is missing ${missing.join(", ")} \u2014 every part of a ${describeKind(kind)} must be in it`);
|
|
12243
|
+
}
|
|
12244
|
+
if ((names.includes("HH") || names.includes("H")) && names.includes("a")) {
|
|
12245
|
+
throw new DateFormatError(
|
|
12246
|
+
"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"
|
|
12247
|
+
);
|
|
12248
|
+
}
|
|
12249
|
+
if ((names.includes("hh") || names.includes("h")) && !names.includes("a")) {
|
|
12250
|
+
throw new DateFormatError(
|
|
12251
|
+
"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"
|
|
12252
|
+
);
|
|
12253
|
+
}
|
|
12254
|
+
parsedPatterns.set(key, tokens);
|
|
12255
|
+
return tokens;
|
|
12256
|
+
}
|
|
12257
|
+
var describeKind = (kind) => kind === "date" ? "date" : kind === "time" ? "time" : "date and time";
|
|
12258
|
+
var pad = (value, width) => String(value).padStart(width, "0");
|
|
12259
|
+
function formatParts(parts, pattern, kind) {
|
|
12260
|
+
return compilePattern(pattern, kind).map((token) => {
|
|
12261
|
+
if ("literal" in token) {
|
|
12262
|
+
return token.literal;
|
|
12263
|
+
}
|
|
12264
|
+
const hour = parts.hour ?? 0;
|
|
12265
|
+
switch (token.token) {
|
|
12266
|
+
case "yyyy":
|
|
12267
|
+
return pad(parts.year ?? 0, 4);
|
|
12268
|
+
case "yy":
|
|
12269
|
+
return pad((parts.year ?? 0) % 100, 2);
|
|
12270
|
+
case "MM":
|
|
12271
|
+
return pad(parts.month ?? 0, 2);
|
|
12272
|
+
case "M":
|
|
12273
|
+
return String(parts.month ?? 0);
|
|
12274
|
+
case "dd":
|
|
12275
|
+
return pad(parts.day ?? 0, 2);
|
|
12276
|
+
case "d":
|
|
12277
|
+
return String(parts.day ?? 0);
|
|
12278
|
+
case "HH":
|
|
12279
|
+
return pad(hour, 2);
|
|
12280
|
+
case "H":
|
|
12281
|
+
return String(hour);
|
|
12282
|
+
case "hh":
|
|
12283
|
+
return pad(hour % 12 || 12, 2);
|
|
12284
|
+
case "h":
|
|
12285
|
+
return String(hour % 12 || 12);
|
|
12286
|
+
case "mm":
|
|
12287
|
+
return pad(parts.minute ?? 0, 2);
|
|
12288
|
+
case "ss":
|
|
12289
|
+
return pad(parts.second ?? 0, 2);
|
|
12290
|
+
case "a":
|
|
12291
|
+
return hour < 12 ? "AM" : "PM";
|
|
12292
|
+
}
|
|
12293
|
+
}).join("");
|
|
12294
|
+
}
|
|
12295
|
+
var escapeRegex = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12296
|
+
function parseInPattern(text2, pattern, kind) {
|
|
12297
|
+
const tokens = compilePattern(pattern, kind);
|
|
12298
|
+
const order = [];
|
|
12299
|
+
const source = tokens.map((token) => {
|
|
12300
|
+
if ("literal" in token) {
|
|
12301
|
+
return escapeRegex(token.literal);
|
|
12302
|
+
}
|
|
12303
|
+
order.push(token.token);
|
|
12304
|
+
if (token.token === "a") {
|
|
12305
|
+
return "(AM|PM)";
|
|
12306
|
+
}
|
|
12307
|
+
const { width } = SPEC[token.token];
|
|
12308
|
+
return width ? `(\\d{${width}})` : "(\\d{1,2})";
|
|
12309
|
+
}).join("");
|
|
12310
|
+
const match = new RegExp(`^${source}$`).exec(text2);
|
|
12311
|
+
if (!match) {
|
|
12312
|
+
return void 0;
|
|
12313
|
+
}
|
|
12314
|
+
const parts = {};
|
|
12315
|
+
let meridiem;
|
|
12316
|
+
order.forEach((name, index) => {
|
|
12317
|
+
const raw = match[index + 1];
|
|
12318
|
+
if (name === "a") {
|
|
12319
|
+
meridiem = raw;
|
|
12320
|
+
return;
|
|
12321
|
+
}
|
|
12322
|
+
const value = Number(raw);
|
|
12323
|
+
switch (name) {
|
|
12324
|
+
// date-fns' two-digit year rule against its reference year 2000: 00–49 → 20xx, 50–99 → 19xx.
|
|
12325
|
+
case "yy":
|
|
12326
|
+
parts.year = value < 50 ? 2e3 + value : 1900 + value;
|
|
12327
|
+
break;
|
|
12328
|
+
case "hh":
|
|
12329
|
+
case "h":
|
|
12330
|
+
parts.hour = value;
|
|
12331
|
+
break;
|
|
12332
|
+
default:
|
|
12333
|
+
parts[SPEC[name].part] = value;
|
|
12334
|
+
}
|
|
12335
|
+
});
|
|
12336
|
+
if (meridiem) {
|
|
12337
|
+
if (parts.hour === void 0 || parts.hour < 1 || parts.hour > 12) {
|
|
12338
|
+
return void 0;
|
|
12339
|
+
}
|
|
12340
|
+
parts.hour = parts.hour % 12 + (meridiem === "PM" ? 12 : 0);
|
|
12341
|
+
}
|
|
12342
|
+
const complete = completeParts(parts, kind);
|
|
12343
|
+
return complete && formatParts(complete, pattern, kind) === text2 ? complete : void 0;
|
|
12344
|
+
}
|
|
12345
|
+
function completeParts(parts, kind) {
|
|
12346
|
+
const { year, month, day, hour, minute, second } = parts;
|
|
12347
|
+
if (kind !== "time" && !isRealDate(year, month, day)) {
|
|
12348
|
+
return void 0;
|
|
12349
|
+
}
|
|
12350
|
+
if (kind !== "date" && !isRealTime(hour, minute, second)) {
|
|
12351
|
+
return void 0;
|
|
12352
|
+
}
|
|
12353
|
+
return kind === "date" ? { year, month, day } : kind === "time" ? { hour, minute, ...second !== void 0 ? { second } : {} } : { year, month, day, hour, minute, ...second !== void 0 ? { second } : {} };
|
|
12354
|
+
}
|
|
12355
|
+
function isRealDate(year, month, day) {
|
|
12356
|
+
if (year === void 0 || month === void 0 || day === void 0 || month < 1 || month > 12 || day < 1) {
|
|
12357
|
+
return false;
|
|
12358
|
+
}
|
|
12359
|
+
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
12360
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
|
|
12361
|
+
return day <= days;
|
|
12362
|
+
}
|
|
12363
|
+
var isRealTime = (hour, minute, second) => hour !== void 0 && minute !== void 0 && hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59 && (second === void 0 || second >= 0 && second <= 59);
|
|
12364
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
12365
|
+
var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
|
|
12366
|
+
var ISO_TIME = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
|
|
12367
|
+
function parseIso(text2, kind) {
|
|
12368
|
+
const dateTime = ISO_DATE_TIME.exec(text2);
|
|
12369
|
+
if (dateTime) {
|
|
12370
|
+
const [, year, month, day, hour, minute, second] = dateTime.map(Number);
|
|
12371
|
+
return completeParts({ year, month, day, hour, minute, ...dateTime[6] ? { second } : {} }, kind);
|
|
12372
|
+
}
|
|
12373
|
+
const date = ISO_DATE.exec(text2);
|
|
12374
|
+
if (date) {
|
|
12375
|
+
return kind === "date" ? completeParts({ year: +date[1], month: +date[2], day: +date[3] }, kind) : void 0;
|
|
12376
|
+
}
|
|
12377
|
+
const time = ISO_TIME.exec(text2);
|
|
12378
|
+
if (time && kind === "time") {
|
|
12379
|
+
return completeParts({ hour: +time[1], minute: +time[2], ...time[3] ? { second: +time[3] } : {} }, kind);
|
|
12380
|
+
}
|
|
12381
|
+
return void 0;
|
|
12382
|
+
}
|
|
12383
|
+
function toCanonical(parts, kind) {
|
|
12384
|
+
const seconds = parts.second !== void 0 ? `:${pad(parts.second, 2)}` : "";
|
|
12385
|
+
const date = `${pad(parts.year ?? 0, 4)}-${pad(parts.month ?? 0, 2)}-${pad(parts.day ?? 0, 2)}`;
|
|
12386
|
+
const time = `${pad(parts.hour ?? 0, 2)}:${pad(parts.minute ?? 0, 2)}${seconds}`;
|
|
12387
|
+
return kind === "date" ? date : kind === "time" ? time : `${date}T${time}`;
|
|
12388
|
+
}
|
|
12389
|
+
function canonicalToPattern(canonical, ins, kind) {
|
|
12390
|
+
const pattern = ins.meta.frDateFormat;
|
|
12391
|
+
if (!pattern) {
|
|
12392
|
+
return canonical;
|
|
12393
|
+
}
|
|
12394
|
+
const parts = parseIso(canonical, kind);
|
|
12395
|
+
return parts ? formatParts(parts, pattern, kind) : canonical;
|
|
12396
|
+
}
|
|
12397
|
+
var MIN_TIMESTAMP_DIGITS = 13;
|
|
12398
|
+
function digitOnlyLength(pattern, kind) {
|
|
12399
|
+
const example = formatParts(EXAMPLE, pattern, kind);
|
|
12400
|
+
return /^\d+$/.test(example) ? example.length : void 0;
|
|
12401
|
+
}
|
|
12402
|
+
function isTimestamp(value, pattern, kind) {
|
|
12403
|
+
if (typeof value === "number") {
|
|
12404
|
+
return Number.isFinite(value);
|
|
12405
|
+
}
|
|
12406
|
+
if (typeof value !== "string") {
|
|
12407
|
+
return false;
|
|
12408
|
+
}
|
|
12409
|
+
const text2 = value.trim();
|
|
12410
|
+
return new RegExp(`^\\d{${MIN_TIMESTAMP_DIGITS},}$`).test(text2) && digitOnlyLength(pattern, kind) !== text2.length;
|
|
12411
|
+
}
|
|
12412
|
+
function timestampParts(value, kind) {
|
|
12413
|
+
const date = new Date(Number(value));
|
|
12414
|
+
if (Number.isNaN(date.getTime())) {
|
|
12415
|
+
return void 0;
|
|
12416
|
+
}
|
|
12417
|
+
const second = date.getSeconds();
|
|
12418
|
+
return completeParts({
|
|
12419
|
+
year: date.getFullYear(),
|
|
12420
|
+
month: date.getMonth() + 1,
|
|
12421
|
+
day: date.getDate(),
|
|
12422
|
+
hour: date.getHours(),
|
|
12423
|
+
minute: date.getMinutes(),
|
|
12424
|
+
...second ? { second } : {}
|
|
12425
|
+
}, kind);
|
|
12426
|
+
}
|
|
12427
|
+
function toDateString(value, ins, kind) {
|
|
12428
|
+
const pattern = ins.meta.frDateFormat;
|
|
12429
|
+
const text2 = typeof value === "string" ? value.trim() : typeof value === "number" && Number.isInteger(value) && value >= 0 ? String(value) : void 0;
|
|
12430
|
+
if (text2 !== void 0) {
|
|
12431
|
+
const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? (typeof value === "string" ? parseIso(text2, kind) : void 0);
|
|
12432
|
+
if (parts) {
|
|
12433
|
+
return { canonical: toCanonical(parts, kind) };
|
|
12434
|
+
}
|
|
12435
|
+
}
|
|
12436
|
+
if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value, patternOf(ins, kind), kind)) {
|
|
12437
|
+
const parts = timestampParts(value, kind);
|
|
12438
|
+
return parts ? { canonical: toCanonical(parts, kind), fromTimestamp: true } : {};
|
|
12439
|
+
}
|
|
12440
|
+
return {};
|
|
12441
|
+
}
|
|
12442
|
+
var EXAMPLE = { year: 2024, month: 1, day: 31, hour: 13, minute: 45, second: 30 };
|
|
12443
|
+
function expectedDateString(ins, kind) {
|
|
12444
|
+
const pattern = patternOf(ins, kind);
|
|
12445
|
+
const shown = ins.meta.frDateFormat ? pattern : pattern.replace(/'T'/, "T");
|
|
12446
|
+
const example = formatParts(EXAMPLE, pattern, kind);
|
|
12447
|
+
return `${kind === "date" ? "a date" : kind === "time" ? "a time" : "a date and time"} in ${shown}, e.g. ${example}`;
|
|
12448
|
+
}
|
|
12449
|
+
function hasDateFormat(schema, seen = /* @__PURE__ */ new Set()) {
|
|
12450
|
+
if (!schema || seen.has(schema)) {
|
|
12451
|
+
return false;
|
|
12452
|
+
}
|
|
12453
|
+
seen.add(schema);
|
|
12454
|
+
const ins = inspect(schema);
|
|
12455
|
+
if (ins.meta.frDateFormat && dateStringKind(ins)) {
|
|
12456
|
+
return true;
|
|
12457
|
+
}
|
|
12458
|
+
const def = ins.core?._zod?.def ?? {};
|
|
12459
|
+
const children = [
|
|
12460
|
+
...shapeEntries(ins.core).map(([, child]) => child),
|
|
12461
|
+
...def.element ? [def.element] : [],
|
|
12462
|
+
...def.valueType ? [def.valueType] : [],
|
|
12463
|
+
...ins.branches ?? []
|
|
12464
|
+
];
|
|
12465
|
+
return children.some((child) => hasDateFormat(child, seen));
|
|
12466
|
+
}
|
|
12467
|
+
|
|
12468
|
+
// ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
|
|
12469
|
+
var DictionaryScope = class _DictionaryScope {
|
|
12470
|
+
constructor(top, visible) {
|
|
12471
|
+
this.top = top;
|
|
12472
|
+
this.visible = visible;
|
|
12473
|
+
}
|
|
12474
|
+
static {
|
|
12475
|
+
this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
|
|
12476
|
+
}
|
|
12477
|
+
enter(names) {
|
|
12478
|
+
if (!this.top) {
|
|
12479
|
+
const top = new Set(names);
|
|
12480
|
+
return new _DictionaryScope(top, top);
|
|
12481
|
+
}
|
|
12482
|
+
return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
|
|
12483
|
+
}
|
|
12484
|
+
};
|
|
12485
|
+
function resolveDependsOn(binding, scope2) {
|
|
12486
|
+
const aliases = binding.criteriaAliases ?? {};
|
|
12487
|
+
let clash;
|
|
12488
|
+
const dependsOn = binding.dependsOn.map((key) => {
|
|
12489
|
+
const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
|
|
12490
|
+
if (visible.length > 1 && !clash) {
|
|
12491
|
+
clash = { key, names: visible };
|
|
12492
|
+
}
|
|
12493
|
+
return visible[0] ?? key;
|
|
12494
|
+
});
|
|
12495
|
+
return clash ? { dependsOn, clash } : { dependsOn };
|
|
12496
|
+
}
|
|
12497
|
+
function publishedBinding(binding, scope2) {
|
|
12498
|
+
return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
|
|
12499
|
+
}
|
|
12500
|
+
|
|
12141
12501
|
// ../../flow-extension-runner/src/v2/params/schema/assert-supported-schema.ts
|
|
12142
12502
|
var GUARDED_KINDS = /* @__PURE__ */ new Set(["action", "dictionary", "polling trigger", "realtime trigger", "extension"]);
|
|
12143
12503
|
var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -12267,6 +12627,48 @@ function assertDictionaryBinding(schema, source, path2, scope2) {
|
|
|
12267
12627
|
);
|
|
12268
12628
|
}
|
|
12269
12629
|
}
|
|
12630
|
+
function assertDateString(schema, source, path2) {
|
|
12631
|
+
const ins = inspect(schema);
|
|
12632
|
+
const pattern = ins.meta.frDateFormat;
|
|
12633
|
+
const kind = dateStringKind(ins);
|
|
12634
|
+
if (pattern !== void 0 && !kind) {
|
|
12635
|
+
const format = ins.core?._zod?.def?.format;
|
|
12636
|
+
const zoned = ins.coreType === "string" && format === "datetime";
|
|
12637
|
+
refuse(
|
|
12638
|
+
`${subjectOf(source, path2)} uses \`.dateFormat()\` on ${zoned ? "z.iso.datetime() with a zone \u2014 an instant, not a wall clock" : "a type that is not a date string"}. Only z.iso.date(), z.iso.datetime({ local: true }) and z.iso.time() take a format.`,
|
|
12639
|
+
source,
|
|
12640
|
+
path2,
|
|
12641
|
+
zoned ? "datetime" : ins.resolvedType ?? "unknown"
|
|
12642
|
+
);
|
|
12643
|
+
}
|
|
12644
|
+
if (!kind) {
|
|
12645
|
+
return;
|
|
12646
|
+
}
|
|
12647
|
+
if (pattern !== void 0) {
|
|
12648
|
+
try {
|
|
12649
|
+
compilePattern(pattern, kind);
|
|
12650
|
+
} catch (error) {
|
|
12651
|
+
if (error instanceof DateFormatError) {
|
|
12652
|
+
refuse(`${subjectOf(source, path2)}: \`.dateFormat('${pattern}')\` ${error.message}.`, source, path2, pattern);
|
|
12653
|
+
}
|
|
12654
|
+
throw error;
|
|
12655
|
+
}
|
|
12656
|
+
}
|
|
12657
|
+
const fallback = ins.defaultValue;
|
|
12658
|
+
if (fallback === void 0 || fallback === null) {
|
|
12659
|
+
return;
|
|
12660
|
+
}
|
|
12661
|
+
const written = patternOf(ins, kind);
|
|
12662
|
+
const fits = typeof fallback === "string" && (pattern !== void 0 ? !!parseInPattern(fallback, pattern, kind) : ((parts) => !!parts && toCanonical(parts, kind) === fallback)(parseIso(fallback, kind)));
|
|
12663
|
+
if (!fits) {
|
|
12664
|
+
refuse(
|
|
12665
|
+
`${subjectOf(source, path2)} has the default ${JSON.stringify(fallback)}, which is not written in ${written.replace(/'T'/, "T")} \u2014 a default is handed to \`execute\` as written, so write it in the field's own format.`,
|
|
12666
|
+
source,
|
|
12667
|
+
path2,
|
|
12668
|
+
String(fallback)
|
|
12669
|
+
);
|
|
12670
|
+
}
|
|
12671
|
+
}
|
|
12270
12672
|
function assertField(schema, source, path2, seen, scope2, topLevel = false) {
|
|
12271
12673
|
if (!schema || seen.has(schema)) {
|
|
12272
12674
|
return;
|
|
@@ -12285,6 +12687,7 @@ function assertField(schema, source, path2, seen, scope2, topLevel = false) {
|
|
|
12285
12687
|
refuseCatch(source, path2);
|
|
12286
12688
|
}
|
|
12287
12689
|
assertDictionaryBinding(schema, source, path2, scope2);
|
|
12690
|
+
assertDateString(schema, source, path2);
|
|
12288
12691
|
if (!ins.resolvedType || !SUPPORTED_TYPES.has(ins.resolvedType)) {
|
|
12289
12692
|
refuseType(source, path2, ins.resolvedType);
|
|
12290
12693
|
}
|
|
@@ -12474,7 +12877,6 @@ function declaredAbsence(schema) {
|
|
|
12474
12877
|
function coerces(schema) {
|
|
12475
12878
|
return inspect(schema).core?._zod?.def?.coerce === true;
|
|
12476
12879
|
}
|
|
12477
|
-
var parsesJson = (schema) => !!inspect(schema).meta.frJson;
|
|
12478
12880
|
var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
|
|
12479
12881
|
var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
|
|
12480
12882
|
function requiredOpenType(schema) {
|
|
@@ -12496,7 +12898,7 @@ function requiredOpenType(schema) {
|
|
|
12496
12898
|
return false;
|
|
12497
12899
|
}
|
|
12498
12900
|
function probeAbsence(schema) {
|
|
12499
|
-
if (coerces(schema)
|
|
12901
|
+
if (coerces(schema)) {
|
|
12500
12902
|
return declaredAbsence(schema);
|
|
12501
12903
|
}
|
|
12502
12904
|
if (requiredOpenType(schema)) {
|
|
@@ -12523,7 +12925,7 @@ function absenceOf(schema) {
|
|
|
12523
12925
|
if (cached) {
|
|
12524
12926
|
return cached;
|
|
12525
12927
|
}
|
|
12526
|
-
const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema)
|
|
12928
|
+
const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) };
|
|
12527
12929
|
probeCache.set(schema, probed);
|
|
12528
12930
|
return probed;
|
|
12529
12931
|
}
|
|
@@ -12536,15 +12938,45 @@ function planField(name, schema) {
|
|
|
12536
12938
|
label: labelOf(name, schema),
|
|
12537
12939
|
coreType: ins.coreType,
|
|
12538
12940
|
isUnion: !!ins.branches,
|
|
12941
|
+
blankBranch: hasBlankBranch(ins),
|
|
12539
12942
|
absence,
|
|
12540
12943
|
absorbsBlank,
|
|
12541
12944
|
keepsEmpty,
|
|
12542
12945
|
blankIsValue,
|
|
12543
12946
|
passThroughDate: passesDateThrough(ins),
|
|
12544
|
-
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
|
|
12947
|
+
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries),
|
|
12948
|
+
dateString: dateStringKind(ins),
|
|
12949
|
+
formatsDates: hasDateFormat(schema)
|
|
12545
12950
|
};
|
|
12546
12951
|
}
|
|
12547
12952
|
|
|
12953
|
+
// ../../flow-extension-runner/src/v2/params/schema/notices.ts
|
|
12954
|
+
var sink;
|
|
12955
|
+
var currentField;
|
|
12956
|
+
function collectNotices(fn) {
|
|
12957
|
+
const outer = sink;
|
|
12958
|
+
const notices = [];
|
|
12959
|
+
sink = notices;
|
|
12960
|
+
try {
|
|
12961
|
+
return { result: fn(), notices };
|
|
12962
|
+
} finally {
|
|
12963
|
+
sink = outer;
|
|
12964
|
+
outer?.push(...notices);
|
|
12965
|
+
}
|
|
12966
|
+
}
|
|
12967
|
+
function withinField(field, fn) {
|
|
12968
|
+
const outer = currentField;
|
|
12969
|
+
currentField = field;
|
|
12970
|
+
try {
|
|
12971
|
+
return fn();
|
|
12972
|
+
} finally {
|
|
12973
|
+
currentField = outer;
|
|
12974
|
+
}
|
|
12975
|
+
}
|
|
12976
|
+
function notice(entry) {
|
|
12977
|
+
sink?.push({ field: currentField, ...entry });
|
|
12978
|
+
}
|
|
12979
|
+
|
|
12548
12980
|
// ../../flow-extension-runner/src/v2/params/schema/coerce.ts
|
|
12549
12981
|
var ok = (value) => ({ ok: true, value });
|
|
12550
12982
|
var fail = (expected) => ({ ok: false, expected });
|
|
@@ -12619,16 +13051,6 @@ function toBooleanValue(value) {
|
|
|
12619
13051
|
const lowered = value.trim().toLowerCase();
|
|
12620
13052
|
return TRUE.has(lowered) ? ok(true) : FALSE.has(lowered) ? ok(false) : fail("boolean");
|
|
12621
13053
|
}
|
|
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
13054
|
function coerceValue(value, coreType) {
|
|
12633
13055
|
if (coreType === "string") {
|
|
12634
13056
|
return toStringValue(value);
|
|
@@ -12726,8 +13148,20 @@ function coerceLeaf(value, ins) {
|
|
|
12726
13148
|
if (ins.branches) {
|
|
12727
13149
|
return ok(coerceUnion(value, ins.branches));
|
|
12728
13150
|
}
|
|
12729
|
-
|
|
12730
|
-
|
|
13151
|
+
const kind = dateStringKind(ins);
|
|
13152
|
+
if (kind) {
|
|
13153
|
+
const { canonical, fromTimestamp } = toDateString(value, ins, kind);
|
|
13154
|
+
if (canonical === void 0) {
|
|
13155
|
+
return fail(expectedDateString(ins, kind));
|
|
13156
|
+
}
|
|
13157
|
+
if (fromTimestamp) {
|
|
13158
|
+
notice({
|
|
13159
|
+
message: "a timestamp was converted to a date string in the server time zone (FR-3920 lenient period)",
|
|
13160
|
+
value,
|
|
13161
|
+
converted: canonical
|
|
13162
|
+
});
|
|
13163
|
+
}
|
|
13164
|
+
return ok(canonical);
|
|
12731
13165
|
}
|
|
12732
13166
|
const format = formatOf(ins);
|
|
12733
13167
|
if (ins.coreType === "string" && isConvertibleIso(format)) {
|
|
@@ -12757,12 +13191,12 @@ function isBlank(value, ins, schema) {
|
|
|
12757
13191
|
return false;
|
|
12758
13192
|
}
|
|
12759
13193
|
if (ins.branches) {
|
|
12760
|
-
return
|
|
13194
|
+
return !hasBlankBranch(ins) || absenceOf(schema).absorbsBlank;
|
|
12761
13195
|
}
|
|
12762
13196
|
if (absenceOf(schema).blankIsValue) {
|
|
12763
13197
|
return absenceOf(schema).absorbsBlank;
|
|
12764
13198
|
}
|
|
12765
|
-
return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
|
|
13199
|
+
return ins.coreType !== "string" || !!dateStringKind(ins) || absenceOf(schema).absorbsBlank;
|
|
12766
13200
|
}
|
|
12767
13201
|
function absentAs(schema, value) {
|
|
12768
13202
|
const { absence } = absenceOf(schema);
|
|
@@ -12823,11 +13257,76 @@ var EXPECTED = {
|
|
|
12823
13257
|
object: "an object",
|
|
12824
13258
|
array: "an array",
|
|
12825
13259
|
// 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"
|
|
13260
|
+
record: "an object"
|
|
12829
13261
|
};
|
|
12830
13262
|
var requiredMessage = (plan) => `\xAB${plan.label}\xBB is required`;
|
|
13263
|
+
var quote = (value) => typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
13264
|
+
var oneOf = (values) => values.length === 1 ? quote(values[0]) : `one of: ${values.map(quote).join(", ")}`;
|
|
13265
|
+
var formatPhrase = (format) => {
|
|
13266
|
+
const described = FORMAT_DESCRIPTIONS[format ?? ""];
|
|
13267
|
+
return described?.replace(/^Expects (.*?), e\.g\. (.*)$/, "$1 (e.g. $2)").replace(/^Expects /, "");
|
|
13268
|
+
};
|
|
13269
|
+
var distinct = (phrases) => [...new Set(phrases.filter((phrase) => !!phrase))];
|
|
13270
|
+
function unionPhrases(union, value) {
|
|
13271
|
+
return distinct((inspect(union).branches ?? []).map((branch) => {
|
|
13272
|
+
try {
|
|
13273
|
+
const result = branch.safeParse(value);
|
|
13274
|
+
return branchPhrase(branch, result.error?.issues[0]);
|
|
13275
|
+
} catch {
|
|
13276
|
+
return void 0;
|
|
13277
|
+
}
|
|
13278
|
+
}));
|
|
13279
|
+
}
|
|
13280
|
+
function remainingIssue(branch, value) {
|
|
13281
|
+
if (!branch) {
|
|
13282
|
+
return void 0;
|
|
13283
|
+
}
|
|
13284
|
+
try {
|
|
13285
|
+
const result = branch.safeParse(coerceDeep(value, branch));
|
|
13286
|
+
return result.success ? void 0 : result.error?.issues[0];
|
|
13287
|
+
} catch {
|
|
13288
|
+
return void 0;
|
|
13289
|
+
}
|
|
13290
|
+
}
|
|
13291
|
+
function branchPhrase(branch, issue) {
|
|
13292
|
+
if (!branch || !issue) {
|
|
13293
|
+
return void 0;
|
|
13294
|
+
}
|
|
13295
|
+
const ins = inspect(branch);
|
|
13296
|
+
const values = ins.core._zod?.def?.values ?? [];
|
|
13297
|
+
if (ins.coreType === "literal" && values.length === 1 && values[0] === "") {
|
|
13298
|
+
return void 0;
|
|
13299
|
+
}
|
|
13300
|
+
const dateKind = dateStringKind(ins);
|
|
13301
|
+
if (dateKind) {
|
|
13302
|
+
return expectedDateString(ins, dateKind);
|
|
13303
|
+
}
|
|
13304
|
+
switch (issue.code) {
|
|
13305
|
+
case "invalid_type":
|
|
13306
|
+
return EXPECTED[issue.expected ?? ""] ?? issue.expected;
|
|
13307
|
+
case "invalid_value":
|
|
13308
|
+
return oneOf(issue.values ?? values);
|
|
13309
|
+
case "invalid_format":
|
|
13310
|
+
return formatPhrase(issue.format);
|
|
13311
|
+
// A bound has no short phrase ("a number of at least 10"); the branch still names its type.
|
|
13312
|
+
case "too_small":
|
|
13313
|
+
case "too_big":
|
|
13314
|
+
return EXPECTED[ins.coreType === "literal" ? literalType(ins.core) ?? "" : ins.coreType];
|
|
13315
|
+
default:
|
|
13316
|
+
return void 0;
|
|
13317
|
+
}
|
|
13318
|
+
}
|
|
13319
|
+
function unionIssue(plan, issue, union, unionValue, fieldValue) {
|
|
13320
|
+
const branches = union ? inspect(union).branches : void 0;
|
|
13321
|
+
const errors = issue.errors ?? [];
|
|
13322
|
+
const deepIndex = errors.findIndex((branchIssues) => branchIssues.some((branchIssue) => (branchIssue.path ?? []).length));
|
|
13323
|
+
if (deepIndex >= 0) {
|
|
13324
|
+
const deep = remainingIssue(branches?.[deepIndex], unionValue) ?? errors[deepIndex].find((branchIssue) => (branchIssue.path ?? []).length);
|
|
13325
|
+
return toFieldIssue(plan, { ...deep, path: [...issue.path ?? [], ...deep.path ?? []] }, fieldValue);
|
|
13326
|
+
}
|
|
13327
|
+
const phrases = distinct(errors.map((branchIssues, index) => branchPhrase(branches?.[index], branchIssues[0])));
|
|
13328
|
+
return phrases.length ? { path: "", code: "invalid_union", message: `must be ${phrases.join(", or ")}` } : void 0;
|
|
13329
|
+
}
|
|
12831
13330
|
var invalidTypeMessage = (plan, expected) => `\xAB${plan.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
|
|
12832
13331
|
var isIndex = (segment) => /^\d+$/.test(segment);
|
|
12833
13332
|
function resolveTarget(plan, segments, fieldValue) {
|
|
@@ -12852,7 +13351,7 @@ function resolveTarget(plan, segments, fieldValue) {
|
|
|
12852
13351
|
schema = nested[1];
|
|
12853
13352
|
label = labelOf(segment, schema);
|
|
12854
13353
|
}
|
|
12855
|
-
return { label, value, found };
|
|
13354
|
+
return { label, value, found, schema: found ? schema : void 0 };
|
|
12856
13355
|
}
|
|
12857
13356
|
function bound(value, plan) {
|
|
12858
13357
|
if (plan.coreType !== "date" || typeof value !== "number") {
|
|
@@ -12874,6 +13373,17 @@ function toFieldIssue(plan, issue, fieldValue) {
|
|
|
12874
13373
|
if (isAuthored(issue)) {
|
|
12875
13374
|
return { path: path2, code, message: issue.message };
|
|
12876
13375
|
}
|
|
13376
|
+
if (code !== "invalid_union" && target.schema && inspect(target.schema).branches) {
|
|
13377
|
+
const combined = unionPhrases(target.schema, target.value);
|
|
13378
|
+
if (combined.length > 1) {
|
|
13379
|
+
return { path: path2, code: "invalid_union", message: `\xAB${target.label}\xBB must be ${combined.join(", or ")}` };
|
|
13380
|
+
}
|
|
13381
|
+
}
|
|
13382
|
+
const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
|
|
13383
|
+
const dateMissing = target.value == null || target.value === "";
|
|
13384
|
+
if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
|
|
13385
|
+
return dateMissing ? { path: path2, code, message: requiredMessage(named) } : { path: path2, code, message: invalidTypeMessage(named, expectedDateString(inspect(target.schema), dateKind)) };
|
|
13386
|
+
}
|
|
12877
13387
|
if (code === "invalid_type") {
|
|
12878
13388
|
const received = issue.received;
|
|
12879
13389
|
const absent = segments.length ? target.found && target.value == null : received === "undefined" || received === "null" || issue.expected === void 0;
|
|
@@ -12886,13 +13396,18 @@ function toFieldIssue(plan, issue, fieldValue) {
|
|
|
12886
13396
|
return { path: path2, code, message: `\xAB${target.label}\xBB must be at most ${bound(issue.maximum, plan)}` };
|
|
12887
13397
|
}
|
|
12888
13398
|
if (code === "invalid_value") {
|
|
12889
|
-
|
|
12890
|
-
return { path: path2, code, message: `\xAB${target.label}\xBB must be one of: ${values.join(", ")}` };
|
|
13399
|
+
return { path: path2, code, message: `\xAB${target.label}\xBB must be ${oneOf(issue.values ?? [])}` };
|
|
12891
13400
|
}
|
|
12892
13401
|
if (code === "invalid_format") {
|
|
12893
13402
|
const described = FORMAT_DESCRIPTIONS[issue.format ?? ""];
|
|
12894
13403
|
return described ? { path: path2, code, message: `\xAB${target.label}\xBB is invalid \u2014 ${described.replace(/^Expects /, "expects ")}` } : { path: path2, code, message: `\xAB${target.label}\xBB has an invalid format` };
|
|
12895
13404
|
}
|
|
13405
|
+
if (code === "invalid_union") {
|
|
13406
|
+
const combined = unionIssue(plan, issue, target.schema, target.value, fieldValue);
|
|
13407
|
+
if (combined) {
|
|
13408
|
+
return combined.path ? combined : { path: path2, code, message: `\xAB${target.label}\xBB ${combined.message}` };
|
|
13409
|
+
}
|
|
13410
|
+
}
|
|
12896
13411
|
return { path: path2, code, message: `\xAB${target.label}\xBB is invalid` };
|
|
12897
13412
|
}
|
|
12898
13413
|
|
|
@@ -12913,12 +13428,12 @@ function isAbsent(value, plan) {
|
|
|
12913
13428
|
return false;
|
|
12914
13429
|
}
|
|
12915
13430
|
if (plan.isUnion) {
|
|
12916
|
-
return
|
|
13431
|
+
return !plan.blankBranch || plan.absorbsBlank;
|
|
12917
13432
|
}
|
|
12918
13433
|
if (plan.blankIsValue) {
|
|
12919
13434
|
return plan.absorbsBlank;
|
|
12920
13435
|
}
|
|
12921
|
-
return plan.coreType !== "string" || plan.absorbsBlank;
|
|
13436
|
+
return plan.coreType !== "string" || !!plan.dateString || plan.absorbsBlank;
|
|
12922
13437
|
}
|
|
12923
13438
|
function normalizeAbsence(value, plan) {
|
|
12924
13439
|
if (plan.absence === "required") {
|
|
@@ -12957,7 +13472,7 @@ function normalizeField(value, plan) {
|
|
|
12957
13472
|
return restore(validate(coerced.value, plan), value, plan);
|
|
12958
13473
|
}
|
|
12959
13474
|
function restore(result, original, plan) {
|
|
12960
|
-
if (!plan.restoresDates || !result.present || result.issues.length) {
|
|
13475
|
+
if (!(plan.restoresDates || plan.formatsDates) || !result.present || result.issues.length) {
|
|
12961
13476
|
return result;
|
|
12962
13477
|
}
|
|
12963
13478
|
if (plan.passThroughDate) {
|
|
@@ -12977,6 +13492,10 @@ function restoreDeep(output, original, schema) {
|
|
|
12977
13492
|
const branch = ins.branches.find((option) => accepts(option, output));
|
|
12978
13493
|
return branch ? restoreDeep(output, original, branch) : output;
|
|
12979
13494
|
}
|
|
13495
|
+
const kind = dateStringKind(ins);
|
|
13496
|
+
if (kind) {
|
|
13497
|
+
return typeof output === "string" && original !== "" ? canonicalToPattern(output, ins, kind) : output;
|
|
13498
|
+
}
|
|
12980
13499
|
const element = ins.core?._zod?.def?.element;
|
|
12981
13500
|
if (ins.coreType === "array" && element && Array.isArray(output) && Array.isArray(original)) {
|
|
12982
13501
|
return output.map((item, index) => restoreDeep(item, original[index], element));
|
|
@@ -13066,7 +13585,7 @@ var Params = class {
|
|
|
13066
13585
|
const values = {};
|
|
13067
13586
|
const issues = [];
|
|
13068
13587
|
for (const plan of this.plans()) {
|
|
13069
|
-
const result = normalizeField(source[plan.name], plan);
|
|
13588
|
+
const result = withinField(plan.name, () => normalizeField(source[plan.name], plan));
|
|
13070
13589
|
if (result.issues.length) {
|
|
13071
13590
|
issues.push(...result.issues);
|
|
13072
13591
|
} else if (result.present) {
|
|
@@ -13221,6 +13740,9 @@ function extendPrototype() {
|
|
|
13221
13740
|
}
|
|
13222
13741
|
return this.meta({ frDictionary: binding });
|
|
13223
13742
|
};
|
|
13743
|
+
proto.dateFormat = function dateFormat(pattern) {
|
|
13744
|
+
return this.meta({ frDateFormat: pattern });
|
|
13745
|
+
};
|
|
13224
13746
|
proto.labels = function labels(byValue) {
|
|
13225
13747
|
return this.meta({ frLabels: byValue });
|
|
13226
13748
|
};
|
|
@@ -13243,10 +13765,9 @@ function text() {
|
|
|
13243
13765
|
return import_zod2.z.string().meta({ frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT });
|
|
13244
13766
|
}
|
|
13245
13767
|
function json() {
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
});
|
|
13768
|
+
throw new Error(
|
|
13769
|
+
"`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."
|
|
13770
|
+
);
|
|
13250
13771
|
}
|
|
13251
13772
|
var namespace = Object.create(import_zod2.z);
|
|
13252
13773
|
Object.defineProperties(namespace, {
|
|
@@ -13260,7 +13781,7 @@ Object.defineProperties(namespace, {
|
|
|
13260
13781
|
var z = namespace;
|
|
13261
13782
|
|
|
13262
13783
|
// ../../flow-extension-runner/src/v2/params/json/values.ts
|
|
13263
|
-
function
|
|
13784
|
+
function toJsonValue(value) {
|
|
13264
13785
|
if (typeof value === "bigint") {
|
|
13265
13786
|
return { $bigint: value.toString() };
|
|
13266
13787
|
}
|
|
@@ -13268,10 +13789,10 @@ function toJsonValue2(value) {
|
|
|
13268
13789
|
return { $date: value.toISOString() };
|
|
13269
13790
|
}
|
|
13270
13791
|
if (Array.isArray(value)) {
|
|
13271
|
-
return value.map(
|
|
13792
|
+
return value.map(toJsonValue);
|
|
13272
13793
|
}
|
|
13273
13794
|
if (value && typeof value === "object") {
|
|
13274
|
-
return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key,
|
|
13795
|
+
return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue(inner)]));
|
|
13275
13796
|
}
|
|
13276
13797
|
return value;
|
|
13277
13798
|
}
|
|
@@ -13306,18 +13827,18 @@ function encodeCheck(check) {
|
|
|
13306
13827
|
switch (def.check) {
|
|
13307
13828
|
// strings and arrays
|
|
13308
13829
|
case "min_length":
|
|
13309
|
-
return at("min",
|
|
13830
|
+
return at("min", toJsonValue(def.minimum));
|
|
13310
13831
|
case "max_length":
|
|
13311
|
-
return at("max",
|
|
13832
|
+
return at("max", toJsonValue(def.maximum));
|
|
13312
13833
|
case "length_equals":
|
|
13313
|
-
return at("length",
|
|
13834
|
+
return at("length", toJsonValue(def.length));
|
|
13314
13835
|
// numbers and bigints
|
|
13315
13836
|
case "greater_than":
|
|
13316
|
-
return at("min",
|
|
13837
|
+
return at("min", toJsonValue(def.value), def.inclusive ? void 0 : true);
|
|
13317
13838
|
case "less_than":
|
|
13318
|
-
return at("max",
|
|
13839
|
+
return at("max", toJsonValue(def.value), def.inclusive ? void 0 : true);
|
|
13319
13840
|
case "multiple_of":
|
|
13320
|
-
return at("multipleOf",
|
|
13841
|
+
return at("multipleOf", toJsonValue(def.value));
|
|
13321
13842
|
case "number_format":
|
|
13322
13843
|
return def.format === "safeint" || def.format === "int32" ? at("int") : void 0;
|
|
13323
13844
|
// the string sub-formats that are checks rather than types
|
|
@@ -13478,7 +13999,7 @@ function encodeMeta(meta, field, scope2, loaderId) {
|
|
|
13478
13999
|
if (hasFunction(source)) {
|
|
13479
14000
|
throw new Error(`Cannot encode "${field}": its metadata holds a function, which has no wire form.`);
|
|
13480
14001
|
}
|
|
13481
|
-
const encoded =
|
|
14002
|
+
const encoded = toJsonValue(source);
|
|
13482
14003
|
return Object.keys(encoded).length ? encoded : void 0;
|
|
13483
14004
|
}
|
|
13484
14005
|
function isLoose(core) {
|
|
@@ -13488,11 +14009,11 @@ function isLoose(core) {
|
|
|
13488
14009
|
function encodeValues(core, type) {
|
|
13489
14010
|
if (type === "enum") {
|
|
13490
14011
|
const entries = core?._zod?.def?.entries ?? {};
|
|
13491
|
-
return Object.values(entries).map(
|
|
14012
|
+
return Object.values(entries).map(toJsonValue);
|
|
13492
14013
|
}
|
|
13493
14014
|
if (type === "literal") {
|
|
13494
14015
|
const values = core?._zod?.def?.values ?? [];
|
|
13495
|
-
return values.map(
|
|
14016
|
+
return values.map(toJsonValue);
|
|
13496
14017
|
}
|
|
13497
14018
|
return void 0;
|
|
13498
14019
|
}
|
|
@@ -13520,9 +14041,10 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
|
|
|
13520
14041
|
name,
|
|
13521
14042
|
type,
|
|
13522
14043
|
...format ? { format } : {},
|
|
14044
|
+
...format === "datetime" && core?._zod?.def?.local ? { local: true } : {},
|
|
13523
14045
|
...optional ? { optional: true } : {},
|
|
13524
14046
|
...nullable ? { nullable: true } : {},
|
|
13525
|
-
...hasDefault ? { default:
|
|
14047
|
+
...hasDefault ? { default: toJsonValue(defaultValue) } : {},
|
|
13526
14048
|
...checks.length ? { checks } : {},
|
|
13527
14049
|
...values?.length ? { values } : {},
|
|
13528
14050
|
...meta ? { meta } : {},
|
|
@@ -14172,8 +14694,23 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
14172
14694
|
get logger() {
|
|
14173
14695
|
return this.#options.logger ?? defaultLogger;
|
|
14174
14696
|
}
|
|
14697
|
+
get invocation() {
|
|
14698
|
+
return this.#options.invocation ?? {};
|
|
14699
|
+
}
|
|
14175
14700
|
get config() {
|
|
14176
|
-
|
|
14701
|
+
if (!this.#config) {
|
|
14702
|
+
const { result, notices } = collectNotices(() => this.#extension.config.resolve(this.#options.configs));
|
|
14703
|
+
for (const { message, field, value, converted } of notices) {
|
|
14704
|
+
this.logger.warn(`[flow-extension:${this.#extension.id}] config item "${field ?? "?"}": ${message}`, {
|
|
14705
|
+
serviceId: this.#extension.id,
|
|
14706
|
+
configItem: field,
|
|
14707
|
+
value,
|
|
14708
|
+
converted,
|
|
14709
|
+
...this.invocation
|
|
14710
|
+
});
|
|
14711
|
+
}
|
|
14712
|
+
this.#config = result;
|
|
14713
|
+
}
|
|
14177
14714
|
return this.#config;
|
|
14178
14715
|
}
|
|
14179
14716
|
// The header access token plus its deserialized composite payload — or a throwing proxy when the
|
|
@@ -14324,6 +14861,10 @@ var DictionaryMethod = class extends ExtensionMethod {
|
|
|
14324
14861
|
return this.criteria.keys();
|
|
14325
14862
|
}
|
|
14326
14863
|
// ── runtime ────────────────────────────────────────────────────────────────
|
|
14864
|
+
// `search` is always text, trimmed (FR-3910): `''` when the author typed nothing — the console then sends no
|
|
14865
|
+
// `search` at all — or only spaces. So a handler never guards it: `search ? { q: search } : undefined`, and
|
|
14866
|
+
// `search.toLowerCase()` as is. Surrounding spaces never mean anything to a lookup.
|
|
14867
|
+
//
|
|
14327
14868
|
// Two-stage: the `{ search, cursor, criteria }` envelope the runtime owns, then the author-declared
|
|
14328
14869
|
// criteria through the shared pipeline — reported as a criteria failure so the console can point at the
|
|
14329
14870
|
// dependent fields rather than the whole call.
|
|
@@ -14332,7 +14873,7 @@ var DictionaryMethod = class extends ExtensionMethod {
|
|
|
14332
14873
|
const payload = input.parseField("payload", DictionaryPayloadSchema);
|
|
14333
14874
|
const criteria = this.criteria.normalize(this.#resolveAliases(payload.criteria), input.invalidCriteria());
|
|
14334
14875
|
return {
|
|
14335
|
-
search: payload.search,
|
|
14876
|
+
search: payload.search?.trim() ?? "",
|
|
14336
14877
|
cursor: payload.cursor,
|
|
14337
14878
|
criteria
|
|
14338
14879
|
};
|
|
@@ -15683,7 +16224,23 @@ var Extension = class {
|
|
|
15683
16224
|
// generated loader, SYSTEM seam — arrives here through the same three steps.
|
|
15684
16225
|
async run(methodName, methodData, ctx) {
|
|
15685
16226
|
const method = this.getMethod(methodName);
|
|
15686
|
-
|
|
16227
|
+
const { result: input, notices } = collectNotices(() => method.validate(methodData ?? {}));
|
|
16228
|
+
this.#reportNotices(notices, methodName, ctx);
|
|
16229
|
+
return method.execute(input, ctx);
|
|
16230
|
+
}
|
|
16231
|
+
// One warning per value the pipeline accepted only under a temporary rule — today a timestamp converted for
|
|
16232
|
+
// a date-string field (FR-3920 lenient period). Named well enough to find the flow still holding one.
|
|
16233
|
+
#reportNotices(notices, methodName, ctx) {
|
|
16234
|
+
for (const { message, field, value, converted } of notices) {
|
|
16235
|
+
ctx.logger.warn(`[flow-extension:${this.id}] ${methodName}: param "${field ?? "?"}": ${message}`, {
|
|
16236
|
+
serviceId: this.id,
|
|
16237
|
+
method: methodName,
|
|
16238
|
+
param: field,
|
|
16239
|
+
value,
|
|
16240
|
+
converted,
|
|
16241
|
+
...ctx.invocation
|
|
16242
|
+
});
|
|
16243
|
+
}
|
|
15687
16244
|
}
|
|
15688
16245
|
// ── output model ────────────────────────────────────────────────────────────
|
|
15689
16246
|
toConfigItems() {
|
|
@@ -16050,7 +16607,13 @@ async function runServiceMethod2(data) {
|
|
|
16050
16607
|
retrieveNewS3Token
|
|
16051
16608
|
};
|
|
16052
16609
|
const files = extension.props.usesFileStorage ? (data.createFiles ?? defaultCreateFiles)(filesOptions) : void 0;
|
|
16053
|
-
const ctx = extension.createContext({
|
|
16610
|
+
const ctx = extension.createContext({
|
|
16611
|
+
configs: data.configs,
|
|
16612
|
+
accessToken,
|
|
16613
|
+
logger: data.logger,
|
|
16614
|
+
files,
|
|
16615
|
+
invocation: { flowId, executionId }
|
|
16616
|
+
});
|
|
16054
16617
|
return extension.run(methodName, methodData, ctx);
|
|
16055
16618
|
}
|
|
16056
16619
|
|