@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/dist/index.js
CHANGED
|
@@ -15239,39 +15239,6 @@ function assertObjectSchema(scheme, source) {
|
|
|
15239
15239
|
);
|
|
15240
15240
|
}
|
|
15241
15241
|
|
|
15242
|
-
// ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
|
|
15243
|
-
var DictionaryScope = class _DictionaryScope {
|
|
15244
|
-
constructor(top, visible) {
|
|
15245
|
-
this.top = top;
|
|
15246
|
-
this.visible = visible;
|
|
15247
|
-
}
|
|
15248
|
-
static {
|
|
15249
|
-
this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
|
|
15250
|
-
}
|
|
15251
|
-
enter(names) {
|
|
15252
|
-
if (!this.top) {
|
|
15253
|
-
const top = new Set(names);
|
|
15254
|
-
return new _DictionaryScope(top, top);
|
|
15255
|
-
}
|
|
15256
|
-
return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
|
|
15257
|
-
}
|
|
15258
|
-
};
|
|
15259
|
-
function resolveDependsOn(binding, scope2) {
|
|
15260
|
-
const aliases = binding.criteriaAliases ?? {};
|
|
15261
|
-
let clash;
|
|
15262
|
-
const dependsOn = binding.dependsOn.map((key) => {
|
|
15263
|
-
const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
|
|
15264
|
-
if (visible.length > 1 && !clash) {
|
|
15265
|
-
clash = { key, names: visible };
|
|
15266
|
-
}
|
|
15267
|
-
return visible[0] ?? key;
|
|
15268
|
-
});
|
|
15269
|
-
return clash ? { dependsOn, clash } : { dependsOn };
|
|
15270
|
-
}
|
|
15271
|
-
function publishedBinding(binding, scope2) {
|
|
15272
|
-
return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
|
|
15273
|
-
}
|
|
15274
|
-
|
|
15275
15242
|
// ../../flow-extension-runner/src/v2/params/widget-types.ts
|
|
15276
15243
|
var FlowExtensionParamGroupTypes = {
|
|
15277
15244
|
FILE_UPLOAD_OPTIONS: "FILE_UPLOAD_OPTIONS",
|
|
@@ -15290,7 +15257,9 @@ var FlowExtensionParamWidgetTypes = {
|
|
|
15290
15257
|
...FlowExtensionParamGroupTypes,
|
|
15291
15258
|
// legacy — no zod declaration produces these. They reach the console only from a legacy JSDoc-format
|
|
15292
15259
|
// service, which writes `uiComponent` by hand. Kept because the console still renders them for an
|
|
15293
|
-
// already-installed extension.
|
|
15260
|
+
// already-installed extension. `DATE_TIME_PICKER` / `TIME_PICKER` are also published, with
|
|
15261
|
+
// `valueKind: 'string'` and `format`, by `z.iso.datetime({ local: true })` / `z.iso.time()` (FR-3920) —
|
|
15262
|
+
// without `valueKind` they are the legacy tokens, storing epoch millis.
|
|
15294
15263
|
NUMERIC: "NUMERIC",
|
|
15295
15264
|
CHECKBOX: "CHECKBOX",
|
|
15296
15265
|
DATE_TIME_PICKER: "DATE_TIME_PICKER",
|
|
@@ -15383,6 +15352,12 @@ function literalType(core) {
|
|
|
15383
15352
|
const [kind] = [...kinds];
|
|
15384
15353
|
return kinds.size === 1 && LITERAL_KINDS.has(kind) ? kind : void 0;
|
|
15385
15354
|
}
|
|
15355
|
+
function hasBlankBranch(ins) {
|
|
15356
|
+
return !!ins.branches?.some((branch) => {
|
|
15357
|
+
const { core, coreType } = inspect(branch);
|
|
15358
|
+
return coreType === "literal" && (core._zod?.def?.values ?? []).includes("");
|
|
15359
|
+
});
|
|
15360
|
+
}
|
|
15386
15361
|
function deriveWidget(ins) {
|
|
15387
15362
|
const { coreType, core, meta } = ins;
|
|
15388
15363
|
switch (coreType) {
|
|
@@ -15390,7 +15365,7 @@ function deriveWidget(ins) {
|
|
|
15390
15365
|
if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
|
|
15391
15366
|
return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
|
|
15392
15367
|
}
|
|
15393
|
-
return { paramType: "STRING" };
|
|
15368
|
+
return dateStringWidget(ins) ?? { paramType: "STRING" };
|
|
15394
15369
|
case "number":
|
|
15395
15370
|
case "bigint":
|
|
15396
15371
|
return { paramType: "NUMBER", uiComponent: { type: FlowExtensionParamWidgetTypes.NUMERIC_STEPPER } };
|
|
@@ -15433,11 +15408,399 @@ function deriveWidget(ins) {
|
|
|
15433
15408
|
return { paramType: "STRING" };
|
|
15434
15409
|
}
|
|
15435
15410
|
}
|
|
15411
|
+
var DATE_STRING_WIDGETS = {
|
|
15412
|
+
date: FlowExtensionParamWidgetTypes.DATE_PICKER,
|
|
15413
|
+
datetime: FlowExtensionParamWidgetTypes.DATE_TIME_PICKER,
|
|
15414
|
+
time: FlowExtensionParamWidgetTypes.TIME_PICKER
|
|
15415
|
+
};
|
|
15416
|
+
function dateStringWidget(ins) {
|
|
15417
|
+
const kind = dateStringKind(ins);
|
|
15418
|
+
return kind ? { paramType: "STRING", uiComponent: { type: DATE_STRING_WIDGETS[kind], valueKind: "string", format: patternOf(ins, kind) } } : void 0;
|
|
15419
|
+
}
|
|
15436
15420
|
function shapeEntries(schema) {
|
|
15437
15421
|
const shape = schema?.shape;
|
|
15438
15422
|
return shape && typeof shape === "object" ? Object.entries(shape) : [];
|
|
15439
15423
|
}
|
|
15440
15424
|
|
|
15425
|
+
// ../../flow-extension-runner/src/v2/params/schema/date-format.ts
|
|
15426
|
+
var ISO_PATTERNS = {
|
|
15427
|
+
date: "yyyy-MM-dd",
|
|
15428
|
+
datetime: "yyyy-MM-dd'T'HH:mm",
|
|
15429
|
+
time: "HH:mm"
|
|
15430
|
+
};
|
|
15431
|
+
var DATE_STRINGS_ACCEPT_TIMESTAMPS = true;
|
|
15432
|
+
function dateStringKind(ins) {
|
|
15433
|
+
if (ins.coreType !== "string") {
|
|
15434
|
+
return void 0;
|
|
15435
|
+
}
|
|
15436
|
+
const def = ins.core?._zod?.def;
|
|
15437
|
+
if (def?.format === "date" || def?.format === "time") {
|
|
15438
|
+
return def.format;
|
|
15439
|
+
}
|
|
15440
|
+
return def?.format === "datetime" && def.local ? "datetime" : void 0;
|
|
15441
|
+
}
|
|
15442
|
+
var patternOf = (ins, kind) => ins.meta.frDateFormat ?? ISO_PATTERNS[kind];
|
|
15443
|
+
var TOKENS = ["yyyy", "yy", "MM", "M", "dd", "d", "HH", "H", "hh", "h", "mm", "ss", "a"];
|
|
15444
|
+
var SPEC = {
|
|
15445
|
+
yyyy: { part: "year", width: 4 },
|
|
15446
|
+
yy: { part: "year", width: 2 },
|
|
15447
|
+
MM: { part: "month", width: 2 },
|
|
15448
|
+
M: { part: "month" },
|
|
15449
|
+
dd: { part: "day", width: 2 },
|
|
15450
|
+
d: { part: "day" },
|
|
15451
|
+
HH: { part: "hour", width: 2 },
|
|
15452
|
+
H: { part: "hour" },
|
|
15453
|
+
hh: { part: "hour", width: 2 },
|
|
15454
|
+
h: { part: "hour" },
|
|
15455
|
+
mm: { part: "minute", width: 2 },
|
|
15456
|
+
ss: { part: "second", width: 2 },
|
|
15457
|
+
a: { part: "meridiem" }
|
|
15458
|
+
};
|
|
15459
|
+
var DATE_PARTS = /* @__PURE__ */ new Set(["year", "month", "day"]);
|
|
15460
|
+
var TIME_PARTS = /* @__PURE__ */ new Set(["hour", "minute", "second", "meridiem"]);
|
|
15461
|
+
var DateFormatError = class extends Error {
|
|
15462
|
+
};
|
|
15463
|
+
var LOOK_ALIKES = {
|
|
15464
|
+
YYYY: "yyyy",
|
|
15465
|
+
YY: "yy",
|
|
15466
|
+
DD: "dd",
|
|
15467
|
+
D: "d",
|
|
15468
|
+
S: "ss",
|
|
15469
|
+
A: "a"
|
|
15470
|
+
};
|
|
15471
|
+
function tokenize(pattern, kind) {
|
|
15472
|
+
const tokens = [];
|
|
15473
|
+
let index = 0;
|
|
15474
|
+
while (index < pattern.length) {
|
|
15475
|
+
const char = pattern[index];
|
|
15476
|
+
if (char === "'") {
|
|
15477
|
+
const end = pattern.indexOf("'", index + 1);
|
|
15478
|
+
if (end < 0) {
|
|
15479
|
+
throw new DateFormatError("has an unclosed quote \u2014 literal text is written between two single quotes");
|
|
15480
|
+
}
|
|
15481
|
+
tokens.push({ literal: end === index + 1 ? "'" : pattern.slice(index + 1, end) });
|
|
15482
|
+
index = end + 1;
|
|
15483
|
+
continue;
|
|
15484
|
+
}
|
|
15485
|
+
if (!/[A-Za-z]/.test(char)) {
|
|
15486
|
+
tokens.push({ literal: char });
|
|
15487
|
+
index++;
|
|
15488
|
+
continue;
|
|
15489
|
+
}
|
|
15490
|
+
const run = /^([A-Za-z])\1*/.exec(pattern.slice(index))?.[0];
|
|
15491
|
+
const known = TOKENS.find((token) => run.startsWith(token) && token.length === run.length);
|
|
15492
|
+
if (!known) {
|
|
15493
|
+
const hint2 = LOOK_ALIKES[run] ? ` (did you mean \`${suggest(pattern, kind)}\`?)` : "";
|
|
15494
|
+
throw new DateFormatError(
|
|
15495
|
+
`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`
|
|
15496
|
+
);
|
|
15497
|
+
}
|
|
15498
|
+
tokens.push({ token: known });
|
|
15499
|
+
index += run.length;
|
|
15500
|
+
}
|
|
15501
|
+
return tokens;
|
|
15502
|
+
}
|
|
15503
|
+
function suggest(pattern, kind) {
|
|
15504
|
+
let fixed = pattern;
|
|
15505
|
+
for (const [wrong, right] of Object.entries(LOOK_ALIKES)) {
|
|
15506
|
+
fixed = fixed.replace(new RegExp(`(?<![A-Za-z])${wrong}(?![A-Za-z])`, "g"), right);
|
|
15507
|
+
}
|
|
15508
|
+
if (kind === "date") {
|
|
15509
|
+
fixed = fixed.replace(/mm/g, "MM");
|
|
15510
|
+
}
|
|
15511
|
+
return fixed;
|
|
15512
|
+
}
|
|
15513
|
+
var parsedPatterns = /* @__PURE__ */ new Map();
|
|
15514
|
+
function compilePattern(pattern, kind) {
|
|
15515
|
+
const key = `${kind}|${pattern}`;
|
|
15516
|
+
const cached2 = parsedPatterns.get(key);
|
|
15517
|
+
if (cached2) {
|
|
15518
|
+
return cached2;
|
|
15519
|
+
}
|
|
15520
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
15521
|
+
throw new DateFormatError("needs a pattern, e.g. `dd/MM/yyyy`");
|
|
15522
|
+
}
|
|
15523
|
+
const tokens = tokenize(pattern, kind);
|
|
15524
|
+
const names = tokens.flatMap((token) => "token" in token ? [token.token] : []);
|
|
15525
|
+
const parts = names.map((name) => SPEC[name].part);
|
|
15526
|
+
const has = (part) => parts.includes(part);
|
|
15527
|
+
const repeated = parts.find((part, index) => parts.indexOf(part) !== index);
|
|
15528
|
+
if (repeated) {
|
|
15529
|
+
throw new DateFormatError(`names the ${repeated === "meridiem" ? "AM/PM" : repeated} twice`);
|
|
15530
|
+
}
|
|
15531
|
+
if (kind === "date" && names.includes("mm") && !has("hour")) {
|
|
15532
|
+
throw new DateFormatError(`uses \`mm\`, which is minutes \u2014 did you mean \`${suggest(pattern, kind)}\`?`);
|
|
15533
|
+
}
|
|
15534
|
+
if (kind === "date" && parts.some((part) => TIME_PARTS.has(part))) {
|
|
15535
|
+
throw new DateFormatError("has a time of day, which a date has not \u2014 declare `z.iso.datetime({ local: true })`");
|
|
15536
|
+
}
|
|
15537
|
+
if (kind === "time" && parts.some((part) => DATE_PARTS.has(part))) {
|
|
15538
|
+
throw new DateFormatError("has a date, which a time has not \u2014 declare `z.iso.datetime({ local: true })`");
|
|
15539
|
+
}
|
|
15540
|
+
const missing = [
|
|
15541
|
+
...kind !== "time" ? [["year", "yyyy"], ["month", "MM"], ["day", "dd"]] : [],
|
|
15542
|
+
...kind !== "date" ? [["hour", "HH"], ["minute", "mm"]] : []
|
|
15543
|
+
].filter(([part]) => !has(part)).map(([, token]) => `\`${token}\``);
|
|
15544
|
+
if (missing.length) {
|
|
15545
|
+
throw new DateFormatError(`is missing ${missing.join(", ")} \u2014 every part of a ${describeKind(kind)} must be in it`);
|
|
15546
|
+
}
|
|
15547
|
+
if ((names.includes("HH") || names.includes("H")) && names.includes("a")) {
|
|
15548
|
+
throw new DateFormatError(
|
|
15549
|
+
"uses a 24-hour clock (`HH` / `H`) with `a` \u2014 13:45 would be written `13:45 PM`, which cannot be read back. Use `hh` / `h` with `a`, or `HH` without it"
|
|
15550
|
+
);
|
|
15551
|
+
}
|
|
15552
|
+
if ((names.includes("hh") || names.includes("h")) && !names.includes("a")) {
|
|
15553
|
+
throw new DateFormatError(
|
|
15554
|
+
"uses a 12-hour clock (`hh` / `h`) without `a` \u2014 without AM/PM the value cannot be read back. Add `a`, or use `HH` for a 24-hour clock"
|
|
15555
|
+
);
|
|
15556
|
+
}
|
|
15557
|
+
parsedPatterns.set(key, tokens);
|
|
15558
|
+
return tokens;
|
|
15559
|
+
}
|
|
15560
|
+
var describeKind = (kind) => kind === "date" ? "date" : kind === "time" ? "time" : "date and time";
|
|
15561
|
+
var pad = (value, width) => String(value).padStart(width, "0");
|
|
15562
|
+
function formatParts(parts, pattern, kind) {
|
|
15563
|
+
return compilePattern(pattern, kind).map((token) => {
|
|
15564
|
+
if ("literal" in token) {
|
|
15565
|
+
return token.literal;
|
|
15566
|
+
}
|
|
15567
|
+
const hour = parts.hour ?? 0;
|
|
15568
|
+
switch (token.token) {
|
|
15569
|
+
case "yyyy":
|
|
15570
|
+
return pad(parts.year ?? 0, 4);
|
|
15571
|
+
case "yy":
|
|
15572
|
+
return pad((parts.year ?? 0) % 100, 2);
|
|
15573
|
+
case "MM":
|
|
15574
|
+
return pad(parts.month ?? 0, 2);
|
|
15575
|
+
case "M":
|
|
15576
|
+
return String(parts.month ?? 0);
|
|
15577
|
+
case "dd":
|
|
15578
|
+
return pad(parts.day ?? 0, 2);
|
|
15579
|
+
case "d":
|
|
15580
|
+
return String(parts.day ?? 0);
|
|
15581
|
+
case "HH":
|
|
15582
|
+
return pad(hour, 2);
|
|
15583
|
+
case "H":
|
|
15584
|
+
return String(hour);
|
|
15585
|
+
case "hh":
|
|
15586
|
+
return pad(hour % 12 || 12, 2);
|
|
15587
|
+
case "h":
|
|
15588
|
+
return String(hour % 12 || 12);
|
|
15589
|
+
case "mm":
|
|
15590
|
+
return pad(parts.minute ?? 0, 2);
|
|
15591
|
+
case "ss":
|
|
15592
|
+
return pad(parts.second ?? 0, 2);
|
|
15593
|
+
case "a":
|
|
15594
|
+
return hour < 12 ? "AM" : "PM";
|
|
15595
|
+
}
|
|
15596
|
+
}).join("");
|
|
15597
|
+
}
|
|
15598
|
+
var escapeRegex = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15599
|
+
function parseInPattern(text2, pattern, kind) {
|
|
15600
|
+
const tokens = compilePattern(pattern, kind);
|
|
15601
|
+
const order = [];
|
|
15602
|
+
const source = tokens.map((token) => {
|
|
15603
|
+
if ("literal" in token) {
|
|
15604
|
+
return escapeRegex(token.literal);
|
|
15605
|
+
}
|
|
15606
|
+
order.push(token.token);
|
|
15607
|
+
if (token.token === "a") {
|
|
15608
|
+
return "(AM|PM)";
|
|
15609
|
+
}
|
|
15610
|
+
const { width } = SPEC[token.token];
|
|
15611
|
+
return width ? `(\\d{${width}})` : "(\\d{1,2})";
|
|
15612
|
+
}).join("");
|
|
15613
|
+
const match = new RegExp(`^${source}$`).exec(text2);
|
|
15614
|
+
if (!match) {
|
|
15615
|
+
return void 0;
|
|
15616
|
+
}
|
|
15617
|
+
const parts = {};
|
|
15618
|
+
let meridiem;
|
|
15619
|
+
order.forEach((name, index) => {
|
|
15620
|
+
const raw = match[index + 1];
|
|
15621
|
+
if (name === "a") {
|
|
15622
|
+
meridiem = raw;
|
|
15623
|
+
return;
|
|
15624
|
+
}
|
|
15625
|
+
const value = Number(raw);
|
|
15626
|
+
switch (name) {
|
|
15627
|
+
// date-fns' two-digit year rule against its reference year 2000: 00–49 → 20xx, 50–99 → 19xx.
|
|
15628
|
+
case "yy":
|
|
15629
|
+
parts.year = value < 50 ? 2e3 + value : 1900 + value;
|
|
15630
|
+
break;
|
|
15631
|
+
case "hh":
|
|
15632
|
+
case "h":
|
|
15633
|
+
parts.hour = value;
|
|
15634
|
+
break;
|
|
15635
|
+
default:
|
|
15636
|
+
parts[SPEC[name].part] = value;
|
|
15637
|
+
}
|
|
15638
|
+
});
|
|
15639
|
+
if (meridiem) {
|
|
15640
|
+
if (parts.hour === void 0 || parts.hour < 1 || parts.hour > 12) {
|
|
15641
|
+
return void 0;
|
|
15642
|
+
}
|
|
15643
|
+
parts.hour = parts.hour % 12 + (meridiem === "PM" ? 12 : 0);
|
|
15644
|
+
}
|
|
15645
|
+
const complete = completeParts(parts, kind);
|
|
15646
|
+
return complete && formatParts(complete, pattern, kind) === text2 ? complete : void 0;
|
|
15647
|
+
}
|
|
15648
|
+
function completeParts(parts, kind) {
|
|
15649
|
+
const { year, month, day, hour, minute, second } = parts;
|
|
15650
|
+
if (kind !== "time" && !isRealDate(year, month, day)) {
|
|
15651
|
+
return void 0;
|
|
15652
|
+
}
|
|
15653
|
+
if (kind !== "date" && !isRealTime(hour, minute, second)) {
|
|
15654
|
+
return void 0;
|
|
15655
|
+
}
|
|
15656
|
+
return kind === "date" ? { year, month, day } : kind === "time" ? { hour, minute, ...second !== void 0 ? { second } : {} } : { year, month, day, hour, minute, ...second !== void 0 ? { second } : {} };
|
|
15657
|
+
}
|
|
15658
|
+
function isRealDate(year, month, day) {
|
|
15659
|
+
if (year === void 0 || month === void 0 || day === void 0 || month < 1 || month > 12 || day < 1) {
|
|
15660
|
+
return false;
|
|
15661
|
+
}
|
|
15662
|
+
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
15663
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
|
|
15664
|
+
return day <= days;
|
|
15665
|
+
}
|
|
15666
|
+
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);
|
|
15667
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
15668
|
+
var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
|
|
15669
|
+
var ISO_TIME = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
|
|
15670
|
+
function parseIso(text2, kind) {
|
|
15671
|
+
const dateTime = ISO_DATE_TIME.exec(text2);
|
|
15672
|
+
if (dateTime) {
|
|
15673
|
+
const [, year, month, day, hour, minute, second] = dateTime.map(Number);
|
|
15674
|
+
return completeParts({ year, month, day, hour, minute, ...dateTime[6] ? { second } : {} }, kind);
|
|
15675
|
+
}
|
|
15676
|
+
const date = ISO_DATE.exec(text2);
|
|
15677
|
+
if (date) {
|
|
15678
|
+
return kind === "date" ? completeParts({ year: +date[1], month: +date[2], day: +date[3] }, kind) : void 0;
|
|
15679
|
+
}
|
|
15680
|
+
const time = ISO_TIME.exec(text2);
|
|
15681
|
+
if (time && kind === "time") {
|
|
15682
|
+
return completeParts({ hour: +time[1], minute: +time[2], ...time[3] ? { second: +time[3] } : {} }, kind);
|
|
15683
|
+
}
|
|
15684
|
+
return void 0;
|
|
15685
|
+
}
|
|
15686
|
+
function toCanonical(parts, kind) {
|
|
15687
|
+
const seconds = parts.second !== void 0 ? `:${pad(parts.second, 2)}` : "";
|
|
15688
|
+
const date = `${pad(parts.year ?? 0, 4)}-${pad(parts.month ?? 0, 2)}-${pad(parts.day ?? 0, 2)}`;
|
|
15689
|
+
const time = `${pad(parts.hour ?? 0, 2)}:${pad(parts.minute ?? 0, 2)}${seconds}`;
|
|
15690
|
+
return kind === "date" ? date : kind === "time" ? time : `${date}T${time}`;
|
|
15691
|
+
}
|
|
15692
|
+
function canonicalToPattern(canonical, ins, kind) {
|
|
15693
|
+
const pattern = ins.meta.frDateFormat;
|
|
15694
|
+
if (!pattern) {
|
|
15695
|
+
return canonical;
|
|
15696
|
+
}
|
|
15697
|
+
const parts = parseIso(canonical, kind);
|
|
15698
|
+
return parts ? formatParts(parts, pattern, kind) : canonical;
|
|
15699
|
+
}
|
|
15700
|
+
var MIN_TIMESTAMP_DIGITS = 13;
|
|
15701
|
+
function digitOnlyLength(pattern, kind) {
|
|
15702
|
+
const example = formatParts(EXAMPLE, pattern, kind);
|
|
15703
|
+
return /^\d+$/.test(example) ? example.length : void 0;
|
|
15704
|
+
}
|
|
15705
|
+
function isTimestamp(value, pattern, kind) {
|
|
15706
|
+
if (typeof value === "number") {
|
|
15707
|
+
return Number.isFinite(value);
|
|
15708
|
+
}
|
|
15709
|
+
if (typeof value !== "string") {
|
|
15710
|
+
return false;
|
|
15711
|
+
}
|
|
15712
|
+
const text2 = value.trim();
|
|
15713
|
+
return new RegExp(`^\\d{${MIN_TIMESTAMP_DIGITS},}$`).test(text2) && digitOnlyLength(pattern, kind) !== text2.length;
|
|
15714
|
+
}
|
|
15715
|
+
function timestampParts(value, kind) {
|
|
15716
|
+
const date = new Date(Number(value));
|
|
15717
|
+
if (Number.isNaN(date.getTime())) {
|
|
15718
|
+
return void 0;
|
|
15719
|
+
}
|
|
15720
|
+
const second = date.getSeconds();
|
|
15721
|
+
return completeParts({
|
|
15722
|
+
year: date.getFullYear(),
|
|
15723
|
+
month: date.getMonth() + 1,
|
|
15724
|
+
day: date.getDate(),
|
|
15725
|
+
hour: date.getHours(),
|
|
15726
|
+
minute: date.getMinutes(),
|
|
15727
|
+
...second ? { second } : {}
|
|
15728
|
+
}, kind);
|
|
15729
|
+
}
|
|
15730
|
+
function toDateString(value, ins, kind) {
|
|
15731
|
+
const pattern = ins.meta.frDateFormat;
|
|
15732
|
+
const text2 = typeof value === "string" ? value.trim() : typeof value === "number" && Number.isInteger(value) && value >= 0 ? String(value) : void 0;
|
|
15733
|
+
if (text2 !== void 0) {
|
|
15734
|
+
const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? (typeof value === "string" ? parseIso(text2, kind) : void 0);
|
|
15735
|
+
if (parts) {
|
|
15736
|
+
return { canonical: toCanonical(parts, kind) };
|
|
15737
|
+
}
|
|
15738
|
+
}
|
|
15739
|
+
if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value, patternOf(ins, kind), kind)) {
|
|
15740
|
+
const parts = timestampParts(value, kind);
|
|
15741
|
+
return parts ? { canonical: toCanonical(parts, kind), fromTimestamp: true } : {};
|
|
15742
|
+
}
|
|
15743
|
+
return {};
|
|
15744
|
+
}
|
|
15745
|
+
var EXAMPLE = { year: 2024, month: 1, day: 31, hour: 13, minute: 45, second: 30 };
|
|
15746
|
+
function expectedDateString(ins, kind) {
|
|
15747
|
+
const pattern = patternOf(ins, kind);
|
|
15748
|
+
const shown = ins.meta.frDateFormat ? pattern : pattern.replace(/'T'/, "T");
|
|
15749
|
+
const example = formatParts(EXAMPLE, pattern, kind);
|
|
15750
|
+
return `${kind === "date" ? "a date" : kind === "time" ? "a time" : "a date and time"} in ${shown}, e.g. ${example}`;
|
|
15751
|
+
}
|
|
15752
|
+
function hasDateFormat(schema, seen = /* @__PURE__ */ new Set()) {
|
|
15753
|
+
if (!schema || seen.has(schema)) {
|
|
15754
|
+
return false;
|
|
15755
|
+
}
|
|
15756
|
+
seen.add(schema);
|
|
15757
|
+
const ins = inspect(schema);
|
|
15758
|
+
if (ins.meta.frDateFormat && dateStringKind(ins)) {
|
|
15759
|
+
return true;
|
|
15760
|
+
}
|
|
15761
|
+
const def = ins.core?._zod?.def ?? {};
|
|
15762
|
+
const children = [
|
|
15763
|
+
...shapeEntries(ins.core).map(([, child]) => child),
|
|
15764
|
+
...def.element ? [def.element] : [],
|
|
15765
|
+
...def.valueType ? [def.valueType] : [],
|
|
15766
|
+
...ins.branches ?? []
|
|
15767
|
+
];
|
|
15768
|
+
return children.some((child) => hasDateFormat(child, seen));
|
|
15769
|
+
}
|
|
15770
|
+
|
|
15771
|
+
// ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
|
|
15772
|
+
var DictionaryScope = class _DictionaryScope {
|
|
15773
|
+
constructor(top, visible) {
|
|
15774
|
+
this.top = top;
|
|
15775
|
+
this.visible = visible;
|
|
15776
|
+
}
|
|
15777
|
+
static {
|
|
15778
|
+
this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
|
|
15779
|
+
}
|
|
15780
|
+
enter(names) {
|
|
15781
|
+
if (!this.top) {
|
|
15782
|
+
const top = new Set(names);
|
|
15783
|
+
return new _DictionaryScope(top, top);
|
|
15784
|
+
}
|
|
15785
|
+
return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
|
|
15786
|
+
}
|
|
15787
|
+
};
|
|
15788
|
+
function resolveDependsOn(binding, scope2) {
|
|
15789
|
+
const aliases = binding.criteriaAliases ?? {};
|
|
15790
|
+
let clash;
|
|
15791
|
+
const dependsOn = binding.dependsOn.map((key) => {
|
|
15792
|
+
const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
|
|
15793
|
+
if (visible.length > 1 && !clash) {
|
|
15794
|
+
clash = { key, names: visible };
|
|
15795
|
+
}
|
|
15796
|
+
return visible[0] ?? key;
|
|
15797
|
+
});
|
|
15798
|
+
return clash ? { dependsOn, clash } : { dependsOn };
|
|
15799
|
+
}
|
|
15800
|
+
function publishedBinding(binding, scope2) {
|
|
15801
|
+
return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
|
|
15802
|
+
}
|
|
15803
|
+
|
|
15441
15804
|
// ../../flow-extension-runner/src/v2/params/schema/assert-supported-schema.ts
|
|
15442
15805
|
var GUARDED_KINDS = /* @__PURE__ */ new Set(["action", "dictionary", "polling trigger", "realtime trigger", "extension"]);
|
|
15443
15806
|
var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -15567,6 +15930,48 @@ function assertDictionaryBinding(schema, source, path19, scope2) {
|
|
|
15567
15930
|
);
|
|
15568
15931
|
}
|
|
15569
15932
|
}
|
|
15933
|
+
function assertDateString(schema, source, path19) {
|
|
15934
|
+
const ins = inspect(schema);
|
|
15935
|
+
const pattern = ins.meta.frDateFormat;
|
|
15936
|
+
const kind = dateStringKind(ins);
|
|
15937
|
+
if (pattern !== void 0 && !kind) {
|
|
15938
|
+
const format = ins.core?._zod?.def?.format;
|
|
15939
|
+
const zoned = ins.coreType === "string" && format === "datetime";
|
|
15940
|
+
refuse(
|
|
15941
|
+
`${subjectOf(source, path19)} 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.`,
|
|
15942
|
+
source,
|
|
15943
|
+
path19,
|
|
15944
|
+
zoned ? "datetime" : ins.resolvedType ?? "unknown"
|
|
15945
|
+
);
|
|
15946
|
+
}
|
|
15947
|
+
if (!kind) {
|
|
15948
|
+
return;
|
|
15949
|
+
}
|
|
15950
|
+
if (pattern !== void 0) {
|
|
15951
|
+
try {
|
|
15952
|
+
compilePattern(pattern, kind);
|
|
15953
|
+
} catch (error) {
|
|
15954
|
+
if (error instanceof DateFormatError) {
|
|
15955
|
+
refuse(`${subjectOf(source, path19)}: \`.dateFormat('${pattern}')\` ${error.message}.`, source, path19, pattern);
|
|
15956
|
+
}
|
|
15957
|
+
throw error;
|
|
15958
|
+
}
|
|
15959
|
+
}
|
|
15960
|
+
const fallback = ins.defaultValue;
|
|
15961
|
+
if (fallback === void 0 || fallback === null) {
|
|
15962
|
+
return;
|
|
15963
|
+
}
|
|
15964
|
+
const written = patternOf(ins, kind);
|
|
15965
|
+
const fits = typeof fallback === "string" && (pattern !== void 0 ? !!parseInPattern(fallback, pattern, kind) : ((parts) => !!parts && toCanonical(parts, kind) === fallback)(parseIso(fallback, kind)));
|
|
15966
|
+
if (!fits) {
|
|
15967
|
+
refuse(
|
|
15968
|
+
`${subjectOf(source, path19)} 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.`,
|
|
15969
|
+
source,
|
|
15970
|
+
path19,
|
|
15971
|
+
String(fallback)
|
|
15972
|
+
);
|
|
15973
|
+
}
|
|
15974
|
+
}
|
|
15570
15975
|
function assertField(schema, source, path19, seen, scope2, topLevel = false) {
|
|
15571
15976
|
if (!schema || seen.has(schema)) {
|
|
15572
15977
|
return;
|
|
@@ -15585,6 +15990,7 @@ function assertField(schema, source, path19, seen, scope2, topLevel = false) {
|
|
|
15585
15990
|
refuseCatch(source, path19);
|
|
15586
15991
|
}
|
|
15587
15992
|
assertDictionaryBinding(schema, source, path19, scope2);
|
|
15993
|
+
assertDateString(schema, source, path19);
|
|
15588
15994
|
if (!ins.resolvedType || !SUPPORTED_TYPES.has(ins.resolvedType)) {
|
|
15589
15995
|
refuseType(source, path19, ins.resolvedType);
|
|
15590
15996
|
}
|
|
@@ -15835,15 +16241,45 @@ function planField(name, schema) {
|
|
|
15835
16241
|
label: labelOf(name, schema),
|
|
15836
16242
|
coreType: ins.coreType,
|
|
15837
16243
|
isUnion: !!ins.branches,
|
|
16244
|
+
blankBranch: hasBlankBranch(ins),
|
|
15838
16245
|
absence,
|
|
15839
16246
|
absorbsBlank,
|
|
15840
16247
|
keepsEmpty,
|
|
15841
16248
|
blankIsValue,
|
|
15842
16249
|
passThroughDate: passesDateThrough(ins),
|
|
15843
|
-
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
|
|
16250
|
+
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries),
|
|
16251
|
+
dateString: dateStringKind(ins),
|
|
16252
|
+
formatsDates: hasDateFormat(schema)
|
|
15844
16253
|
};
|
|
15845
16254
|
}
|
|
15846
16255
|
|
|
16256
|
+
// ../../flow-extension-runner/src/v2/params/schema/notices.ts
|
|
16257
|
+
var sink;
|
|
16258
|
+
var currentField;
|
|
16259
|
+
function collectNotices(fn) {
|
|
16260
|
+
const outer = sink;
|
|
16261
|
+
const notices = [];
|
|
16262
|
+
sink = notices;
|
|
16263
|
+
try {
|
|
16264
|
+
return { result: fn(), notices };
|
|
16265
|
+
} finally {
|
|
16266
|
+
sink = outer;
|
|
16267
|
+
outer?.push(...notices);
|
|
16268
|
+
}
|
|
16269
|
+
}
|
|
16270
|
+
function withinField(field, fn) {
|
|
16271
|
+
const outer = currentField;
|
|
16272
|
+
currentField = field;
|
|
16273
|
+
try {
|
|
16274
|
+
return fn();
|
|
16275
|
+
} finally {
|
|
16276
|
+
currentField = outer;
|
|
16277
|
+
}
|
|
16278
|
+
}
|
|
16279
|
+
function notice(entry) {
|
|
16280
|
+
sink?.push({ field: currentField, ...entry });
|
|
16281
|
+
}
|
|
16282
|
+
|
|
15847
16283
|
// ../../flow-extension-runner/src/v2/params/schema/coerce.ts
|
|
15848
16284
|
var ok = (value) => ({ ok: true, value });
|
|
15849
16285
|
var fail = (expected) => ({ ok: false, expected });
|
|
@@ -16015,6 +16451,21 @@ function coerceLeaf(value, ins) {
|
|
|
16015
16451
|
if (ins.branches) {
|
|
16016
16452
|
return ok(coerceUnion(value, ins.branches));
|
|
16017
16453
|
}
|
|
16454
|
+
const kind = dateStringKind(ins);
|
|
16455
|
+
if (kind) {
|
|
16456
|
+
const { canonical, fromTimestamp } = toDateString(value, ins, kind);
|
|
16457
|
+
if (canonical === void 0) {
|
|
16458
|
+
return fail(expectedDateString(ins, kind));
|
|
16459
|
+
}
|
|
16460
|
+
if (fromTimestamp) {
|
|
16461
|
+
notice({
|
|
16462
|
+
message: "a timestamp was converted to a date string in the server time zone (FR-3920 lenient period)",
|
|
16463
|
+
value,
|
|
16464
|
+
converted: canonical
|
|
16465
|
+
});
|
|
16466
|
+
}
|
|
16467
|
+
return ok(canonical);
|
|
16468
|
+
}
|
|
16018
16469
|
const format = formatOf(ins);
|
|
16019
16470
|
if (ins.coreType === "string" && isConvertibleIso(format)) {
|
|
16020
16471
|
const iso = toIso(value, format);
|
|
@@ -16043,12 +16494,12 @@ function isBlank(value, ins, schema) {
|
|
|
16043
16494
|
return false;
|
|
16044
16495
|
}
|
|
16045
16496
|
if (ins.branches) {
|
|
16046
|
-
return
|
|
16497
|
+
return !hasBlankBranch(ins) || absenceOf(schema).absorbsBlank;
|
|
16047
16498
|
}
|
|
16048
16499
|
if (absenceOf(schema).blankIsValue) {
|
|
16049
16500
|
return absenceOf(schema).absorbsBlank;
|
|
16050
16501
|
}
|
|
16051
|
-
return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
|
|
16502
|
+
return ins.coreType !== "string" || !!dateStringKind(ins) || absenceOf(schema).absorbsBlank;
|
|
16052
16503
|
}
|
|
16053
16504
|
function absentAs(schema, value) {
|
|
16054
16505
|
const { absence } = absenceOf(schema);
|
|
@@ -16112,6 +16563,72 @@ var EXPECTED = {
|
|
|
16112
16563
|
record: "an object"
|
|
16113
16564
|
};
|
|
16114
16565
|
var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
|
|
16566
|
+
var oneOf = (values) => `one of: ${values.map(String).join(", ")}`;
|
|
16567
|
+
var formatPhrase = (format) => {
|
|
16568
|
+
const described = FORMAT_DESCRIPTIONS[format ?? ""];
|
|
16569
|
+
return described?.replace(/^Expects (.*?), e\.g\. (.*)$/, "$1 (e.g. $2)").replace(/^Expects /, "");
|
|
16570
|
+
};
|
|
16571
|
+
var distinct = (phrases) => [...new Set(phrases.filter((phrase) => !!phrase))];
|
|
16572
|
+
function unionPhrases(union, value) {
|
|
16573
|
+
return distinct((inspect(union).branches ?? []).map((branch) => {
|
|
16574
|
+
try {
|
|
16575
|
+
const result = branch.safeParse(value);
|
|
16576
|
+
return branchPhrase(branch, result.error?.issues[0]);
|
|
16577
|
+
} catch {
|
|
16578
|
+
return void 0;
|
|
16579
|
+
}
|
|
16580
|
+
}));
|
|
16581
|
+
}
|
|
16582
|
+
function remainingIssue(branch, value) {
|
|
16583
|
+
if (!branch) {
|
|
16584
|
+
return void 0;
|
|
16585
|
+
}
|
|
16586
|
+
try {
|
|
16587
|
+
const result = branch.safeParse(coerceDeep(value, branch));
|
|
16588
|
+
return result.success ? void 0 : result.error?.issues[0];
|
|
16589
|
+
} catch {
|
|
16590
|
+
return void 0;
|
|
16591
|
+
}
|
|
16592
|
+
}
|
|
16593
|
+
function branchPhrase(branch, issue) {
|
|
16594
|
+
if (!branch || !issue) {
|
|
16595
|
+
return void 0;
|
|
16596
|
+
}
|
|
16597
|
+
const ins = inspect(branch);
|
|
16598
|
+
const values = ins.core._zod?.def?.values ?? [];
|
|
16599
|
+
if (ins.coreType === "literal" && values.length === 1 && values[0] === "") {
|
|
16600
|
+
return void 0;
|
|
16601
|
+
}
|
|
16602
|
+
const dateKind = dateStringKind(ins);
|
|
16603
|
+
if (dateKind) {
|
|
16604
|
+
return expectedDateString(ins, dateKind);
|
|
16605
|
+
}
|
|
16606
|
+
switch (issue.code) {
|
|
16607
|
+
case "invalid_type":
|
|
16608
|
+
return EXPECTED[issue.expected ?? ""] ?? issue.expected;
|
|
16609
|
+
case "invalid_value":
|
|
16610
|
+
return oneOf(issue.values ?? values);
|
|
16611
|
+
case "invalid_format":
|
|
16612
|
+
return formatPhrase(issue.format);
|
|
16613
|
+
// A bound has no short phrase ("a number of at least 10"); the branch still names its type.
|
|
16614
|
+
case "too_small":
|
|
16615
|
+
case "too_big":
|
|
16616
|
+
return EXPECTED[ins.coreType === "literal" ? literalType(ins.core) ?? "" : ins.coreType];
|
|
16617
|
+
default:
|
|
16618
|
+
return void 0;
|
|
16619
|
+
}
|
|
16620
|
+
}
|
|
16621
|
+
function unionIssue(plan2, issue, union, unionValue, fieldValue) {
|
|
16622
|
+
const branches = union ? inspect(union).branches : void 0;
|
|
16623
|
+
const errors = issue.errors ?? [];
|
|
16624
|
+
const deepIndex = errors.findIndex((branchIssues) => branchIssues.some((branchIssue) => (branchIssue.path ?? []).length));
|
|
16625
|
+
if (deepIndex >= 0) {
|
|
16626
|
+
const deep = remainingIssue(branches?.[deepIndex], unionValue) ?? errors[deepIndex].find((branchIssue) => (branchIssue.path ?? []).length);
|
|
16627
|
+
return toFieldIssue(plan2, { ...deep, path: [...issue.path ?? [], ...deep.path ?? []] }, fieldValue);
|
|
16628
|
+
}
|
|
16629
|
+
const phrases = distinct(errors.map((branchIssues, index) => branchPhrase(branches?.[index], branchIssues[0])));
|
|
16630
|
+
return phrases.length ? { path: "", code: "invalid_union", message: `must be ${phrases.join(", or ")}` } : void 0;
|
|
16631
|
+
}
|
|
16115
16632
|
var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
|
|
16116
16633
|
var isIndex = (segment) => /^\d+$/.test(segment);
|
|
16117
16634
|
function resolveTarget(plan2, segments, fieldValue) {
|
|
@@ -16120,6 +16637,8 @@ function resolveTarget(plan2, segments, fieldValue) {
|
|
|
16120
16637
|
let label = plan2.label;
|
|
16121
16638
|
let found = true;
|
|
16122
16639
|
for (const segment of segments) {
|
|
16640
|
+
const branch = schema && inspect(schema).branches?.find((candidate) => isIndex(segment) ? inspect(candidate).coreType === "array" : shapeEntries(inspect(candidate).core).some(([name]) => name === segment));
|
|
16641
|
+
schema = branch ?? schema;
|
|
16123
16642
|
const core = schema ? inspect(schema).core : void 0;
|
|
16124
16643
|
const coreType = core ? inspect(schema).coreType : void 0;
|
|
16125
16644
|
value = value == null ? void 0 : value[segment];
|
|
@@ -16136,7 +16655,7 @@ function resolveTarget(plan2, segments, fieldValue) {
|
|
|
16136
16655
|
schema = nested[1];
|
|
16137
16656
|
label = labelOf(segment, schema);
|
|
16138
16657
|
}
|
|
16139
|
-
return { label, value, found };
|
|
16658
|
+
return { label, value, found, schema: found ? schema : void 0 };
|
|
16140
16659
|
}
|
|
16141
16660
|
function bound(value, plan2) {
|
|
16142
16661
|
if (plan2.coreType !== "date" || typeof value !== "number") {
|
|
@@ -16158,6 +16677,17 @@ function toFieldIssue(plan2, issue, fieldValue) {
|
|
|
16158
16677
|
if (isAuthored(issue)) {
|
|
16159
16678
|
return { path: path19, code, message: issue.message };
|
|
16160
16679
|
}
|
|
16680
|
+
if (code === "invalid_format" && target.schema && inspect(target.schema).branches) {
|
|
16681
|
+
const combined = unionPhrases(target.schema, target.value);
|
|
16682
|
+
if (combined.length > 1) {
|
|
16683
|
+
return { path: path19, code: "invalid_union", message: `\xAB${target.label}\xBB must be ${combined.join(", or ")}` };
|
|
16684
|
+
}
|
|
16685
|
+
}
|
|
16686
|
+
const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
|
|
16687
|
+
const dateMissing = target.value == null || target.value === "";
|
|
16688
|
+
if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
|
|
16689
|
+
return dateMissing ? { path: path19, code, message: requiredMessage(named) } : { path: path19, code, message: invalidTypeMessage(named, expectedDateString(inspect(target.schema), dateKind)) };
|
|
16690
|
+
}
|
|
16161
16691
|
if (code === "invalid_type") {
|
|
16162
16692
|
const received = issue.received;
|
|
16163
16693
|
const absent = segments.length ? target.found && target.value == null : received === "undefined" || received === "null" || issue.expected === void 0;
|
|
@@ -16170,13 +16700,21 @@ function toFieldIssue(plan2, issue, fieldValue) {
|
|
|
16170
16700
|
return { path: path19, code, message: `\xAB${target.label}\xBB must be at most ${bound(issue.maximum, plan2)}` };
|
|
16171
16701
|
}
|
|
16172
16702
|
if (code === "invalid_value") {
|
|
16173
|
-
|
|
16174
|
-
return { path: path19, code, message: `\xAB${target.label}\xBB must be one of: ${values.join(", ")}` };
|
|
16703
|
+
return { path: path19, code, message: `\xAB${target.label}\xBB must be ${oneOf(issue.values ?? [])}` };
|
|
16175
16704
|
}
|
|
16176
16705
|
if (code === "invalid_format") {
|
|
16177
16706
|
const described = FORMAT_DESCRIPTIONS[issue.format ?? ""];
|
|
16178
16707
|
return described ? { path: path19, code, message: `\xAB${target.label}\xBB is invalid \u2014 ${described.replace(/^Expects /, "expects ")}` } : { path: path19, code, message: `\xAB${target.label}\xBB has an invalid format` };
|
|
16179
16708
|
}
|
|
16709
|
+
if (code === "invalid_union") {
|
|
16710
|
+
if (segments.length && target.found && target.value == null) {
|
|
16711
|
+
return { path: path19, code, message: requiredMessage(named) };
|
|
16712
|
+
}
|
|
16713
|
+
const combined = unionIssue(plan2, issue, target.schema, target.value, fieldValue);
|
|
16714
|
+
if (combined) {
|
|
16715
|
+
return combined.path ? combined : { path: path19, code, message: `\xAB${target.label}\xBB ${combined.message}` };
|
|
16716
|
+
}
|
|
16717
|
+
}
|
|
16180
16718
|
return { path: path19, code, message: `\xAB${target.label}\xBB is invalid` };
|
|
16181
16719
|
}
|
|
16182
16720
|
|
|
@@ -16197,12 +16735,12 @@ function isAbsent(value, plan2) {
|
|
|
16197
16735
|
return false;
|
|
16198
16736
|
}
|
|
16199
16737
|
if (plan2.isUnion) {
|
|
16200
|
-
return
|
|
16738
|
+
return !plan2.blankBranch || plan2.absorbsBlank;
|
|
16201
16739
|
}
|
|
16202
16740
|
if (plan2.blankIsValue) {
|
|
16203
16741
|
return plan2.absorbsBlank;
|
|
16204
16742
|
}
|
|
16205
|
-
return plan2.coreType !== "string" || plan2.absorbsBlank;
|
|
16743
|
+
return plan2.coreType !== "string" || !!plan2.dateString || plan2.absorbsBlank;
|
|
16206
16744
|
}
|
|
16207
16745
|
function normalizeAbsence(value, plan2) {
|
|
16208
16746
|
if (plan2.absence === "required") {
|
|
@@ -16241,7 +16779,7 @@ function normalizeField(value, plan2) {
|
|
|
16241
16779
|
return restore(validate(coerced.value, plan2), value, plan2);
|
|
16242
16780
|
}
|
|
16243
16781
|
function restore(result, original, plan2) {
|
|
16244
|
-
if (!plan2.restoresDates || !result.present || result.issues.length) {
|
|
16782
|
+
if (!(plan2.restoresDates || plan2.formatsDates) || !result.present || result.issues.length) {
|
|
16245
16783
|
return result;
|
|
16246
16784
|
}
|
|
16247
16785
|
if (plan2.passThroughDate) {
|
|
@@ -16261,6 +16799,10 @@ function restoreDeep(output, original, schema) {
|
|
|
16261
16799
|
const branch = ins.branches.find((option) => accepts(option, output));
|
|
16262
16800
|
return branch ? restoreDeep(output, original, branch) : output;
|
|
16263
16801
|
}
|
|
16802
|
+
const kind = dateStringKind(ins);
|
|
16803
|
+
if (kind) {
|
|
16804
|
+
return typeof output === "string" && original !== "" ? canonicalToPattern(output, ins, kind) : output;
|
|
16805
|
+
}
|
|
16264
16806
|
const element = ins.core?._zod?.def?.element;
|
|
16265
16807
|
if (ins.coreType === "array" && element && Array.isArray(output) && Array.isArray(original)) {
|
|
16266
16808
|
return output.map((item, index) => restoreDeep(item, original[index], element));
|
|
@@ -16350,7 +16892,7 @@ var Params = class {
|
|
|
16350
16892
|
const values = {};
|
|
16351
16893
|
const issues = [];
|
|
16352
16894
|
for (const plan2 of this.plans()) {
|
|
16353
|
-
const result = normalizeField(source[plan2.name], plan2);
|
|
16895
|
+
const result = withinField(plan2.name, () => normalizeField(source[plan2.name], plan2));
|
|
16354
16896
|
if (result.issues.length) {
|
|
16355
16897
|
issues.push(...result.issues);
|
|
16356
16898
|
} else if (result.present) {
|
|
@@ -16505,6 +17047,9 @@ function extendPrototype() {
|
|
|
16505
17047
|
}
|
|
16506
17048
|
return this.meta({ frDictionary: binding });
|
|
16507
17049
|
};
|
|
17050
|
+
proto.dateFormat = function dateFormat(pattern) {
|
|
17051
|
+
return this.meta({ frDateFormat: pattern });
|
|
17052
|
+
};
|
|
16508
17053
|
proto.labels = function labels(byValue) {
|
|
16509
17054
|
return this.meta({ frLabels: byValue });
|
|
16510
17055
|
};
|
|
@@ -16803,6 +17348,7 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
|
|
|
16803
17348
|
name,
|
|
16804
17349
|
type,
|
|
16805
17350
|
...format ? { format } : {},
|
|
17351
|
+
...format === "datetime" && core?._zod?.def?.local ? { local: true } : {},
|
|
16806
17352
|
...optional ? { optional: true } : {},
|
|
16807
17353
|
...nullable ? { nullable: true } : {},
|
|
16808
17354
|
...hasDefault ? { default: toJsonValue(defaultValue) } : {},
|
|
@@ -17330,8 +17876,23 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
17330
17876
|
get logger() {
|
|
17331
17877
|
return this.#options.logger ?? defaultLogger;
|
|
17332
17878
|
}
|
|
17879
|
+
get invocation() {
|
|
17880
|
+
return this.#options.invocation ?? {};
|
|
17881
|
+
}
|
|
17333
17882
|
get config() {
|
|
17334
|
-
|
|
17883
|
+
if (!this.#config) {
|
|
17884
|
+
const { result, notices } = collectNotices(() => this.#extension.config.resolve(this.#options.configs));
|
|
17885
|
+
for (const { message, field, value, converted } of notices) {
|
|
17886
|
+
this.logger.warn(`[flow-extension:${this.#extension.id}] config item "${field ?? "?"}": ${message}`, {
|
|
17887
|
+
serviceId: this.#extension.id,
|
|
17888
|
+
configItem: field,
|
|
17889
|
+
value,
|
|
17890
|
+
converted,
|
|
17891
|
+
...this.invocation
|
|
17892
|
+
});
|
|
17893
|
+
}
|
|
17894
|
+
this.#config = result;
|
|
17895
|
+
}
|
|
17335
17896
|
return this.#config;
|
|
17336
17897
|
}
|
|
17337
17898
|
// The header access token plus its deserialized composite payload — or a throwing proxy when the
|
|
@@ -18845,7 +19406,23 @@ var Extension = class {
|
|
|
18845
19406
|
// generated loader, SYSTEM seam — arrives here through the same three steps.
|
|
18846
19407
|
async run(methodName, methodData, ctx) {
|
|
18847
19408
|
const method = this.getMethod(methodName);
|
|
18848
|
-
|
|
19409
|
+
const { result: input, notices } = collectNotices(() => method.validate(methodData ?? {}));
|
|
19410
|
+
this.#reportNotices(notices, methodName, ctx);
|
|
19411
|
+
return method.execute(input, ctx);
|
|
19412
|
+
}
|
|
19413
|
+
// One warning per value the pipeline accepted only under a temporary rule — today a timestamp converted for
|
|
19414
|
+
// a date-string field (FR-3920 lenient period). Named well enough to find the flow still holding one.
|
|
19415
|
+
#reportNotices(notices, methodName, ctx) {
|
|
19416
|
+
for (const { message, field, value, converted } of notices) {
|
|
19417
|
+
ctx.logger.warn(`[flow-extension:${this.id}] ${methodName}: param "${field ?? "?"}": ${message}`, {
|
|
19418
|
+
serviceId: this.id,
|
|
19419
|
+
method: methodName,
|
|
19420
|
+
param: field,
|
|
19421
|
+
value,
|
|
19422
|
+
converted,
|
|
19423
|
+
...ctx.invocation
|
|
19424
|
+
});
|
|
19425
|
+
}
|
|
18849
19426
|
}
|
|
18850
19427
|
// ── output model ────────────────────────────────────────────────────────────
|
|
18851
19428
|
toConfigItems() {
|