@flowrunner/cli 0.1.18 → 0.1.19
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 +115 -7
- package/ai-docs/instructions/service-code-format/11-output-model.md +3 -0
- package/ai-docs/instructions/service-code-format/16-gotchas.md +30 -6
- package/dist/cli.js +625 -48
- package/dist/cli.js.map +4 -4
- package/dist/index.js +624 -47
- 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/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 +3 -2
- 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/zod.d.ts +21 -0
- package/package.json +1 -1
- package/runtime/index.js +631 -48
- 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/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 +3 -2
- 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/zod.d.ts +21 -0
package/runtime/index.js
CHANGED
|
@@ -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,6 +12049,12 @@ 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
12060
|
switch (coreType) {
|
|
@@ -12087,7 +12062,7 @@ function deriveWidget(ins) {
|
|
|
12087
12062
|
if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
|
|
12088
12063
|
return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
|
|
12089
12064
|
}
|
|
12090
|
-
return { paramType: "STRING" };
|
|
12065
|
+
return dateStringWidget(ins) ?? { paramType: "STRING" };
|
|
12091
12066
|
case "number":
|
|
12092
12067
|
case "bigint":
|
|
12093
12068
|
return { paramType: "NUMBER", uiComponent: { type: FlowExtensionParamWidgetTypes.NUMERIC_STEPPER } };
|
|
@@ -12130,11 +12105,399 @@ function deriveWidget(ins) {
|
|
|
12130
12105
|
return { paramType: "STRING" };
|
|
12131
12106
|
}
|
|
12132
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
|
+
}
|
|
12133
12117
|
function shapeEntries(schema) {
|
|
12134
12118
|
const shape = schema?.shape;
|
|
12135
12119
|
return shape && typeof shape === "object" ? Object.entries(shape) : [];
|
|
12136
12120
|
}
|
|
12137
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
|
+
|
|
12138
12501
|
// ../../flow-extension-runner/src/v2/params/schema/assert-supported-schema.ts
|
|
12139
12502
|
var GUARDED_KINDS = /* @__PURE__ */ new Set(["action", "dictionary", "polling trigger", "realtime trigger", "extension"]);
|
|
12140
12503
|
var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -12264,6 +12627,48 @@ function assertDictionaryBinding(schema, source, path2, scope2) {
|
|
|
12264
12627
|
);
|
|
12265
12628
|
}
|
|
12266
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
|
+
}
|
|
12267
12672
|
function assertField(schema, source, path2, seen, scope2, topLevel = false) {
|
|
12268
12673
|
if (!schema || seen.has(schema)) {
|
|
12269
12674
|
return;
|
|
@@ -12282,6 +12687,7 @@ function assertField(schema, source, path2, seen, scope2, topLevel = false) {
|
|
|
12282
12687
|
refuseCatch(source, path2);
|
|
12283
12688
|
}
|
|
12284
12689
|
assertDictionaryBinding(schema, source, path2, scope2);
|
|
12690
|
+
assertDateString(schema, source, path2);
|
|
12285
12691
|
if (!ins.resolvedType || !SUPPORTED_TYPES.has(ins.resolvedType)) {
|
|
12286
12692
|
refuseType(source, path2, ins.resolvedType);
|
|
12287
12693
|
}
|
|
@@ -12532,15 +12938,45 @@ function planField(name, schema) {
|
|
|
12532
12938
|
label: labelOf(name, schema),
|
|
12533
12939
|
coreType: ins.coreType,
|
|
12534
12940
|
isUnion: !!ins.branches,
|
|
12941
|
+
blankBranch: hasBlankBranch(ins),
|
|
12535
12942
|
absence,
|
|
12536
12943
|
absorbsBlank,
|
|
12537
12944
|
keepsEmpty,
|
|
12538
12945
|
blankIsValue,
|
|
12539
12946
|
passThroughDate: passesDateThrough(ins),
|
|
12540
|
-
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
|
|
12947
|
+
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries),
|
|
12948
|
+
dateString: dateStringKind(ins),
|
|
12949
|
+
formatsDates: hasDateFormat(schema)
|
|
12541
12950
|
};
|
|
12542
12951
|
}
|
|
12543
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
|
+
|
|
12544
12980
|
// ../../flow-extension-runner/src/v2/params/schema/coerce.ts
|
|
12545
12981
|
var ok = (value) => ({ ok: true, value });
|
|
12546
12982
|
var fail = (expected) => ({ ok: false, expected });
|
|
@@ -12712,6 +13148,21 @@ function coerceLeaf(value, ins) {
|
|
|
12712
13148
|
if (ins.branches) {
|
|
12713
13149
|
return ok(coerceUnion(value, ins.branches));
|
|
12714
13150
|
}
|
|
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);
|
|
13165
|
+
}
|
|
12715
13166
|
const format = formatOf(ins);
|
|
12716
13167
|
if (ins.coreType === "string" && isConvertibleIso(format)) {
|
|
12717
13168
|
const iso = toIso(value, format);
|
|
@@ -12740,12 +13191,12 @@ function isBlank(value, ins, schema) {
|
|
|
12740
13191
|
return false;
|
|
12741
13192
|
}
|
|
12742
13193
|
if (ins.branches) {
|
|
12743
|
-
return
|
|
13194
|
+
return !hasBlankBranch(ins) || absenceOf(schema).absorbsBlank;
|
|
12744
13195
|
}
|
|
12745
13196
|
if (absenceOf(schema).blankIsValue) {
|
|
12746
13197
|
return absenceOf(schema).absorbsBlank;
|
|
12747
13198
|
}
|
|
12748
|
-
return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
|
|
13199
|
+
return ins.coreType !== "string" || !!dateStringKind(ins) || absenceOf(schema).absorbsBlank;
|
|
12749
13200
|
}
|
|
12750
13201
|
function absentAs(schema, value) {
|
|
12751
13202
|
const { absence } = absenceOf(schema);
|
|
@@ -12809,6 +13260,72 @@ var EXPECTED = {
|
|
|
12809
13260
|
record: "an object"
|
|
12810
13261
|
};
|
|
12811
13262
|
var requiredMessage = (plan) => `\xAB${plan.label}\xBB is required`;
|
|
13263
|
+
var oneOf = (values) => `one of: ${values.map(String).join(", ")}`;
|
|
13264
|
+
var formatPhrase = (format) => {
|
|
13265
|
+
const described = FORMAT_DESCRIPTIONS[format ?? ""];
|
|
13266
|
+
return described?.replace(/^Expects (.*?), e\.g\. (.*)$/, "$1 (e.g. $2)").replace(/^Expects /, "");
|
|
13267
|
+
};
|
|
13268
|
+
var distinct = (phrases) => [...new Set(phrases.filter((phrase) => !!phrase))];
|
|
13269
|
+
function unionPhrases(union, value) {
|
|
13270
|
+
return distinct((inspect(union).branches ?? []).map((branch) => {
|
|
13271
|
+
try {
|
|
13272
|
+
const result = branch.safeParse(value);
|
|
13273
|
+
return branchPhrase(branch, result.error?.issues[0]);
|
|
13274
|
+
} catch {
|
|
13275
|
+
return void 0;
|
|
13276
|
+
}
|
|
13277
|
+
}));
|
|
13278
|
+
}
|
|
13279
|
+
function remainingIssue(branch, value) {
|
|
13280
|
+
if (!branch) {
|
|
13281
|
+
return void 0;
|
|
13282
|
+
}
|
|
13283
|
+
try {
|
|
13284
|
+
const result = branch.safeParse(coerceDeep(value, branch));
|
|
13285
|
+
return result.success ? void 0 : result.error?.issues[0];
|
|
13286
|
+
} catch {
|
|
13287
|
+
return void 0;
|
|
13288
|
+
}
|
|
13289
|
+
}
|
|
13290
|
+
function branchPhrase(branch, issue) {
|
|
13291
|
+
if (!branch || !issue) {
|
|
13292
|
+
return void 0;
|
|
13293
|
+
}
|
|
13294
|
+
const ins = inspect(branch);
|
|
13295
|
+
const values = ins.core._zod?.def?.values ?? [];
|
|
13296
|
+
if (ins.coreType === "literal" && values.length === 1 && values[0] === "") {
|
|
13297
|
+
return void 0;
|
|
13298
|
+
}
|
|
13299
|
+
const dateKind = dateStringKind(ins);
|
|
13300
|
+
if (dateKind) {
|
|
13301
|
+
return expectedDateString(ins, dateKind);
|
|
13302
|
+
}
|
|
13303
|
+
switch (issue.code) {
|
|
13304
|
+
case "invalid_type":
|
|
13305
|
+
return EXPECTED[issue.expected ?? ""] ?? issue.expected;
|
|
13306
|
+
case "invalid_value":
|
|
13307
|
+
return oneOf(issue.values ?? values);
|
|
13308
|
+
case "invalid_format":
|
|
13309
|
+
return formatPhrase(issue.format);
|
|
13310
|
+
// A bound has no short phrase ("a number of at least 10"); the branch still names its type.
|
|
13311
|
+
case "too_small":
|
|
13312
|
+
case "too_big":
|
|
13313
|
+
return EXPECTED[ins.coreType === "literal" ? literalType(ins.core) ?? "" : ins.coreType];
|
|
13314
|
+
default:
|
|
13315
|
+
return void 0;
|
|
13316
|
+
}
|
|
13317
|
+
}
|
|
13318
|
+
function unionIssue(plan, issue, union, unionValue, fieldValue) {
|
|
13319
|
+
const branches = union ? inspect(union).branches : void 0;
|
|
13320
|
+
const errors = issue.errors ?? [];
|
|
13321
|
+
const deepIndex = errors.findIndex((branchIssues) => branchIssues.some((branchIssue) => (branchIssue.path ?? []).length));
|
|
13322
|
+
if (deepIndex >= 0) {
|
|
13323
|
+
const deep = remainingIssue(branches?.[deepIndex], unionValue) ?? errors[deepIndex].find((branchIssue) => (branchIssue.path ?? []).length);
|
|
13324
|
+
return toFieldIssue(plan, { ...deep, path: [...issue.path ?? [], ...deep.path ?? []] }, fieldValue);
|
|
13325
|
+
}
|
|
13326
|
+
const phrases = distinct(errors.map((branchIssues, index) => branchPhrase(branches?.[index], branchIssues[0])));
|
|
13327
|
+
return phrases.length ? { path: "", code: "invalid_union", message: `must be ${phrases.join(", or ")}` } : void 0;
|
|
13328
|
+
}
|
|
12812
13329
|
var invalidTypeMessage = (plan, expected) => `\xAB${plan.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
|
|
12813
13330
|
var isIndex = (segment) => /^\d+$/.test(segment);
|
|
12814
13331
|
function resolveTarget(plan, segments, fieldValue) {
|
|
@@ -12817,6 +13334,8 @@ function resolveTarget(plan, segments, fieldValue) {
|
|
|
12817
13334
|
let label = plan.label;
|
|
12818
13335
|
let found = true;
|
|
12819
13336
|
for (const segment of segments) {
|
|
13337
|
+
const branch = schema && inspect(schema).branches?.find((candidate) => isIndex(segment) ? inspect(candidate).coreType === "array" : shapeEntries(inspect(candidate).core).some(([name]) => name === segment));
|
|
13338
|
+
schema = branch ?? schema;
|
|
12820
13339
|
const core = schema ? inspect(schema).core : void 0;
|
|
12821
13340
|
const coreType = core ? inspect(schema).coreType : void 0;
|
|
12822
13341
|
value = value == null ? void 0 : value[segment];
|
|
@@ -12833,7 +13352,7 @@ function resolveTarget(plan, segments, fieldValue) {
|
|
|
12833
13352
|
schema = nested[1];
|
|
12834
13353
|
label = labelOf(segment, schema);
|
|
12835
13354
|
}
|
|
12836
|
-
return { label, value, found };
|
|
13355
|
+
return { label, value, found, schema: found ? schema : void 0 };
|
|
12837
13356
|
}
|
|
12838
13357
|
function bound(value, plan) {
|
|
12839
13358
|
if (plan.coreType !== "date" || typeof value !== "number") {
|
|
@@ -12855,6 +13374,17 @@ function toFieldIssue(plan, issue, fieldValue) {
|
|
|
12855
13374
|
if (isAuthored(issue)) {
|
|
12856
13375
|
return { path: path2, code, message: issue.message };
|
|
12857
13376
|
}
|
|
13377
|
+
if (code === "invalid_format" && target.schema && inspect(target.schema).branches) {
|
|
13378
|
+
const combined = unionPhrases(target.schema, target.value);
|
|
13379
|
+
if (combined.length > 1) {
|
|
13380
|
+
return { path: path2, code: "invalid_union", message: `\xAB${target.label}\xBB must be ${combined.join(", or ")}` };
|
|
13381
|
+
}
|
|
13382
|
+
}
|
|
13383
|
+
const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
|
|
13384
|
+
const dateMissing = target.value == null || target.value === "";
|
|
13385
|
+
if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
|
|
13386
|
+
return dateMissing ? { path: path2, code, message: requiredMessage(named) } : { path: path2, code, message: invalidTypeMessage(named, expectedDateString(inspect(target.schema), dateKind)) };
|
|
13387
|
+
}
|
|
12858
13388
|
if (code === "invalid_type") {
|
|
12859
13389
|
const received = issue.received;
|
|
12860
13390
|
const absent = segments.length ? target.found && target.value == null : received === "undefined" || received === "null" || issue.expected === void 0;
|
|
@@ -12867,13 +13397,21 @@ function toFieldIssue(plan, issue, fieldValue) {
|
|
|
12867
13397
|
return { path: path2, code, message: `\xAB${target.label}\xBB must be at most ${bound(issue.maximum, plan)}` };
|
|
12868
13398
|
}
|
|
12869
13399
|
if (code === "invalid_value") {
|
|
12870
|
-
|
|
12871
|
-
return { path: path2, code, message: `\xAB${target.label}\xBB must be one of: ${values.join(", ")}` };
|
|
13400
|
+
return { path: path2, code, message: `\xAB${target.label}\xBB must be ${oneOf(issue.values ?? [])}` };
|
|
12872
13401
|
}
|
|
12873
13402
|
if (code === "invalid_format") {
|
|
12874
13403
|
const described = FORMAT_DESCRIPTIONS[issue.format ?? ""];
|
|
12875
13404
|
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` };
|
|
12876
13405
|
}
|
|
13406
|
+
if (code === "invalid_union") {
|
|
13407
|
+
if (segments.length && target.found && target.value == null) {
|
|
13408
|
+
return { path: path2, code, message: requiredMessage(named) };
|
|
13409
|
+
}
|
|
13410
|
+
const combined = unionIssue(plan, issue, target.schema, target.value, fieldValue);
|
|
13411
|
+
if (combined) {
|
|
13412
|
+
return combined.path ? combined : { path: path2, code, message: `\xAB${target.label}\xBB ${combined.message}` };
|
|
13413
|
+
}
|
|
13414
|
+
}
|
|
12877
13415
|
return { path: path2, code, message: `\xAB${target.label}\xBB is invalid` };
|
|
12878
13416
|
}
|
|
12879
13417
|
|
|
@@ -12894,12 +13432,12 @@ function isAbsent(value, plan) {
|
|
|
12894
13432
|
return false;
|
|
12895
13433
|
}
|
|
12896
13434
|
if (plan.isUnion) {
|
|
12897
|
-
return
|
|
13435
|
+
return !plan.blankBranch || plan.absorbsBlank;
|
|
12898
13436
|
}
|
|
12899
13437
|
if (plan.blankIsValue) {
|
|
12900
13438
|
return plan.absorbsBlank;
|
|
12901
13439
|
}
|
|
12902
|
-
return plan.coreType !== "string" || plan.absorbsBlank;
|
|
13440
|
+
return plan.coreType !== "string" || !!plan.dateString || plan.absorbsBlank;
|
|
12903
13441
|
}
|
|
12904
13442
|
function normalizeAbsence(value, plan) {
|
|
12905
13443
|
if (plan.absence === "required") {
|
|
@@ -12938,7 +13476,7 @@ function normalizeField(value, plan) {
|
|
|
12938
13476
|
return restore(validate(coerced.value, plan), value, plan);
|
|
12939
13477
|
}
|
|
12940
13478
|
function restore(result, original, plan) {
|
|
12941
|
-
if (!plan.restoresDates || !result.present || result.issues.length) {
|
|
13479
|
+
if (!(plan.restoresDates || plan.formatsDates) || !result.present || result.issues.length) {
|
|
12942
13480
|
return result;
|
|
12943
13481
|
}
|
|
12944
13482
|
if (plan.passThroughDate) {
|
|
@@ -12958,6 +13496,10 @@ function restoreDeep(output, original, schema) {
|
|
|
12958
13496
|
const branch = ins.branches.find((option) => accepts(option, output));
|
|
12959
13497
|
return branch ? restoreDeep(output, original, branch) : output;
|
|
12960
13498
|
}
|
|
13499
|
+
const kind = dateStringKind(ins);
|
|
13500
|
+
if (kind) {
|
|
13501
|
+
return typeof output === "string" && original !== "" ? canonicalToPattern(output, ins, kind) : output;
|
|
13502
|
+
}
|
|
12961
13503
|
const element = ins.core?._zod?.def?.element;
|
|
12962
13504
|
if (ins.coreType === "array" && element && Array.isArray(output) && Array.isArray(original)) {
|
|
12963
13505
|
return output.map((item, index) => restoreDeep(item, original[index], element));
|
|
@@ -13047,7 +13589,7 @@ var Params = class {
|
|
|
13047
13589
|
const values = {};
|
|
13048
13590
|
const issues = [];
|
|
13049
13591
|
for (const plan of this.plans()) {
|
|
13050
|
-
const result = normalizeField(source[plan.name], plan);
|
|
13592
|
+
const result = withinField(plan.name, () => normalizeField(source[plan.name], plan));
|
|
13051
13593
|
if (result.issues.length) {
|
|
13052
13594
|
issues.push(...result.issues);
|
|
13053
13595
|
} else if (result.present) {
|
|
@@ -13202,6 +13744,9 @@ function extendPrototype() {
|
|
|
13202
13744
|
}
|
|
13203
13745
|
return this.meta({ frDictionary: binding });
|
|
13204
13746
|
};
|
|
13747
|
+
proto.dateFormat = function dateFormat(pattern) {
|
|
13748
|
+
return this.meta({ frDateFormat: pattern });
|
|
13749
|
+
};
|
|
13205
13750
|
proto.labels = function labels(byValue) {
|
|
13206
13751
|
return this.meta({ frLabels: byValue });
|
|
13207
13752
|
};
|
|
@@ -13500,6 +14045,7 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
|
|
|
13500
14045
|
name,
|
|
13501
14046
|
type,
|
|
13502
14047
|
...format ? { format } : {},
|
|
14048
|
+
...format === "datetime" && core?._zod?.def?.local ? { local: true } : {},
|
|
13503
14049
|
...optional ? { optional: true } : {},
|
|
13504
14050
|
...nullable ? { nullable: true } : {},
|
|
13505
14051
|
...hasDefault ? { default: toJsonValue(defaultValue) } : {},
|
|
@@ -14152,8 +14698,23 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
14152
14698
|
get logger() {
|
|
14153
14699
|
return this.#options.logger ?? defaultLogger;
|
|
14154
14700
|
}
|
|
14701
|
+
get invocation() {
|
|
14702
|
+
return this.#options.invocation ?? {};
|
|
14703
|
+
}
|
|
14155
14704
|
get config() {
|
|
14156
|
-
|
|
14705
|
+
if (!this.#config) {
|
|
14706
|
+
const { result, notices } = collectNotices(() => this.#extension.config.resolve(this.#options.configs));
|
|
14707
|
+
for (const { message, field, value, converted } of notices) {
|
|
14708
|
+
this.logger.warn(`[flow-extension:${this.#extension.id}] config item "${field ?? "?"}": ${message}`, {
|
|
14709
|
+
serviceId: this.#extension.id,
|
|
14710
|
+
configItem: field,
|
|
14711
|
+
value,
|
|
14712
|
+
converted,
|
|
14713
|
+
...this.invocation
|
|
14714
|
+
});
|
|
14715
|
+
}
|
|
14716
|
+
this.#config = result;
|
|
14717
|
+
}
|
|
14157
14718
|
return this.#config;
|
|
14158
14719
|
}
|
|
14159
14720
|
// The header access token plus its deserialized composite payload — or a throwing proxy when the
|
|
@@ -15667,7 +16228,23 @@ var Extension = class {
|
|
|
15667
16228
|
// generated loader, SYSTEM seam — arrives here through the same three steps.
|
|
15668
16229
|
async run(methodName, methodData, ctx) {
|
|
15669
16230
|
const method = this.getMethod(methodName);
|
|
15670
|
-
|
|
16231
|
+
const { result: input, notices } = collectNotices(() => method.validate(methodData ?? {}));
|
|
16232
|
+
this.#reportNotices(notices, methodName, ctx);
|
|
16233
|
+
return method.execute(input, ctx);
|
|
16234
|
+
}
|
|
16235
|
+
// One warning per value the pipeline accepted only under a temporary rule — today a timestamp converted for
|
|
16236
|
+
// a date-string field (FR-3920 lenient period). Named well enough to find the flow still holding one.
|
|
16237
|
+
#reportNotices(notices, methodName, ctx) {
|
|
16238
|
+
for (const { message, field, value, converted } of notices) {
|
|
16239
|
+
ctx.logger.warn(`[flow-extension:${this.id}] ${methodName}: param "${field ?? "?"}": ${message}`, {
|
|
16240
|
+
serviceId: this.id,
|
|
16241
|
+
method: methodName,
|
|
16242
|
+
param: field,
|
|
16243
|
+
value,
|
|
16244
|
+
converted,
|
|
16245
|
+
...ctx.invocation
|
|
16246
|
+
});
|
|
16247
|
+
}
|
|
15671
16248
|
}
|
|
15672
16249
|
// ── output model ────────────────────────────────────────────────────────────
|
|
15673
16250
|
toConfigItems() {
|
|
@@ -16034,7 +16611,13 @@ async function runServiceMethod2(data) {
|
|
|
16034
16611
|
retrieveNewS3Token
|
|
16035
16612
|
};
|
|
16036
16613
|
const files = extension.props.usesFileStorage ? (data.createFiles ?? defaultCreateFiles)(filesOptions) : void 0;
|
|
16037
|
-
const ctx = extension.createContext({
|
|
16614
|
+
const ctx = extension.createContext({
|
|
16615
|
+
configs: data.configs,
|
|
16616
|
+
accessToken,
|
|
16617
|
+
logger: data.logger,
|
|
16618
|
+
files,
|
|
16619
|
+
invocation: { flowId, executionId }
|
|
16620
|
+
});
|
|
16038
16621
|
return extension.run(methodName, methodData, ctx);
|
|
16039
16622
|
}
|
|
16040
16623
|
|