@flowrunner/cli 0.1.16 → 0.1.18-dev.1
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 +169 -29
- 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 +5 -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 +111 -0
- 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 +559 -88
- package/dist/cli.js.map +4 -4
- package/dist/index.js +558 -87
- 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 +7 -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 +565 -88
- 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 +7 -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
|
@@ -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",
|
|
@@ -12082,15 +12051,12 @@ function literalType(core) {
|
|
|
12082
12051
|
}
|
|
12083
12052
|
function deriveWidget(ins) {
|
|
12084
12053
|
const { coreType, core, meta } = ins;
|
|
12085
|
-
if (meta.frJson) {
|
|
12086
|
-
return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
|
|
12087
|
-
}
|
|
12088
12054
|
switch (coreType) {
|
|
12089
12055
|
case "string":
|
|
12090
12056
|
if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
|
|
12091
12057
|
return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
|
|
12092
12058
|
}
|
|
12093
|
-
return { paramType: "STRING" };
|
|
12059
|
+
return dateStringWidget(ins) ?? { paramType: "STRING" };
|
|
12094
12060
|
case "number":
|
|
12095
12061
|
case "bigint":
|
|
12096
12062
|
return { paramType: "NUMBER", uiComponent: { type: FlowExtensionParamWidgetTypes.NUMERIC_STEPPER } };
|
|
@@ -12133,11 +12099,380 @@ function deriveWidget(ins) {
|
|
|
12133
12099
|
return { paramType: "STRING" };
|
|
12134
12100
|
}
|
|
12135
12101
|
}
|
|
12102
|
+
var DATE_STRING_WIDGETS = {
|
|
12103
|
+
date: FlowExtensionParamWidgetTypes.DATE_PICKER,
|
|
12104
|
+
datetime: FlowExtensionParamWidgetTypes.DATE_TIME_PICKER,
|
|
12105
|
+
time: FlowExtensionParamWidgetTypes.TIME_PICKER
|
|
12106
|
+
};
|
|
12107
|
+
function dateStringWidget(ins) {
|
|
12108
|
+
const kind = dateStringKind(ins);
|
|
12109
|
+
return kind ? { paramType: "STRING", uiComponent: { type: DATE_STRING_WIDGETS[kind], valueKind: "string", format: patternOf(ins, kind) } } : void 0;
|
|
12110
|
+
}
|
|
12136
12111
|
function shapeEntries(schema) {
|
|
12137
12112
|
const shape = schema?.shape;
|
|
12138
12113
|
return shape && typeof shape === "object" ? Object.entries(shape) : [];
|
|
12139
12114
|
}
|
|
12140
12115
|
|
|
12116
|
+
// ../../flow-extension-runner/src/v2/params/schema/date-format.ts
|
|
12117
|
+
var ISO_PATTERNS = {
|
|
12118
|
+
date: "yyyy-MM-dd",
|
|
12119
|
+
datetime: "yyyy-MM-dd'T'HH:mm",
|
|
12120
|
+
time: "HH:mm"
|
|
12121
|
+
};
|
|
12122
|
+
var DATE_STRINGS_ACCEPT_TIMESTAMPS = true;
|
|
12123
|
+
function dateStringKind(ins) {
|
|
12124
|
+
if (ins.coreType !== "string") {
|
|
12125
|
+
return void 0;
|
|
12126
|
+
}
|
|
12127
|
+
const def = ins.core?._zod?.def;
|
|
12128
|
+
if (def?.format === "date" || def?.format === "time") {
|
|
12129
|
+
return def.format;
|
|
12130
|
+
}
|
|
12131
|
+
return def?.format === "datetime" && def.local ? "datetime" : void 0;
|
|
12132
|
+
}
|
|
12133
|
+
var patternOf = (ins, kind) => ins.meta.frDateFormat ?? ISO_PATTERNS[kind];
|
|
12134
|
+
var TOKENS = ["yyyy", "yy", "MM", "M", "dd", "d", "HH", "H", "hh", "h", "mm", "ss", "a"];
|
|
12135
|
+
var SPEC = {
|
|
12136
|
+
yyyy: { part: "year", width: 4 },
|
|
12137
|
+
yy: { part: "year", width: 2 },
|
|
12138
|
+
MM: { part: "month", width: 2 },
|
|
12139
|
+
M: { part: "month" },
|
|
12140
|
+
dd: { part: "day", width: 2 },
|
|
12141
|
+
d: { part: "day" },
|
|
12142
|
+
HH: { part: "hour", width: 2 },
|
|
12143
|
+
H: { part: "hour" },
|
|
12144
|
+
hh: { part: "hour", width: 2 },
|
|
12145
|
+
h: { part: "hour" },
|
|
12146
|
+
mm: { part: "minute", width: 2 },
|
|
12147
|
+
ss: { part: "second", width: 2 },
|
|
12148
|
+
a: { part: "meridiem" }
|
|
12149
|
+
};
|
|
12150
|
+
var DATE_PARTS = /* @__PURE__ */ new Set(["year", "month", "day"]);
|
|
12151
|
+
var TIME_PARTS = /* @__PURE__ */ new Set(["hour", "minute", "second", "meridiem"]);
|
|
12152
|
+
var DateFormatError = class extends Error {
|
|
12153
|
+
};
|
|
12154
|
+
var LOOK_ALIKES = {
|
|
12155
|
+
YYYY: "yyyy",
|
|
12156
|
+
YY: "yy",
|
|
12157
|
+
DD: "dd",
|
|
12158
|
+
D: "d",
|
|
12159
|
+
S: "ss",
|
|
12160
|
+
A: "a"
|
|
12161
|
+
};
|
|
12162
|
+
function tokenize(pattern, kind) {
|
|
12163
|
+
const tokens = [];
|
|
12164
|
+
let index = 0;
|
|
12165
|
+
while (index < pattern.length) {
|
|
12166
|
+
const char = pattern[index];
|
|
12167
|
+
if (char === "'") {
|
|
12168
|
+
const end = pattern.indexOf("'", index + 1);
|
|
12169
|
+
if (end < 0) {
|
|
12170
|
+
throw new DateFormatError("has an unclosed quote \u2014 literal text is written between two single quotes");
|
|
12171
|
+
}
|
|
12172
|
+
tokens.push({ literal: end === index + 1 ? "'" : pattern.slice(index + 1, end) });
|
|
12173
|
+
index = end + 1;
|
|
12174
|
+
continue;
|
|
12175
|
+
}
|
|
12176
|
+
if (!/[A-Za-z]/.test(char)) {
|
|
12177
|
+
tokens.push({ literal: char });
|
|
12178
|
+
index++;
|
|
12179
|
+
continue;
|
|
12180
|
+
}
|
|
12181
|
+
const run = /^([A-Za-z])\1*/.exec(pattern.slice(index))?.[0];
|
|
12182
|
+
const known = TOKENS.find((token) => run.startsWith(token) && token.length === run.length);
|
|
12183
|
+
if (!known) {
|
|
12184
|
+
const hint2 = LOOK_ALIKES[run] ? ` (did you mean \`${suggest(pattern, kind)}\`?)` : "";
|
|
12185
|
+
throw new DateFormatError(
|
|
12186
|
+
`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`
|
|
12187
|
+
);
|
|
12188
|
+
}
|
|
12189
|
+
tokens.push({ token: known });
|
|
12190
|
+
index += run.length;
|
|
12191
|
+
}
|
|
12192
|
+
return tokens;
|
|
12193
|
+
}
|
|
12194
|
+
function suggest(pattern, kind) {
|
|
12195
|
+
let fixed = pattern;
|
|
12196
|
+
for (const [wrong, right] of Object.entries(LOOK_ALIKES)) {
|
|
12197
|
+
fixed = fixed.replace(new RegExp(`(?<![A-Za-z])${wrong}(?![A-Za-z])`, "g"), right);
|
|
12198
|
+
}
|
|
12199
|
+
if (kind === "date") {
|
|
12200
|
+
fixed = fixed.replace(/mm/g, "MM");
|
|
12201
|
+
}
|
|
12202
|
+
return fixed;
|
|
12203
|
+
}
|
|
12204
|
+
var parsedPatterns = /* @__PURE__ */ new Map();
|
|
12205
|
+
function compilePattern(pattern, kind) {
|
|
12206
|
+
const key = `${kind}|${pattern}`;
|
|
12207
|
+
const cached = parsedPatterns.get(key);
|
|
12208
|
+
if (cached) {
|
|
12209
|
+
return cached;
|
|
12210
|
+
}
|
|
12211
|
+
if (typeof pattern !== "string" || !pattern.trim()) {
|
|
12212
|
+
throw new DateFormatError("needs a pattern, e.g. `dd/MM/yyyy`");
|
|
12213
|
+
}
|
|
12214
|
+
const tokens = tokenize(pattern, kind);
|
|
12215
|
+
const names = tokens.flatMap((token) => "token" in token ? [token.token] : []);
|
|
12216
|
+
const parts = names.map((name) => SPEC[name].part);
|
|
12217
|
+
const has = (part) => parts.includes(part);
|
|
12218
|
+
const repeated = parts.find((part, index) => parts.indexOf(part) !== index);
|
|
12219
|
+
if (repeated) {
|
|
12220
|
+
throw new DateFormatError(`names the ${repeated === "meridiem" ? "AM/PM" : repeated} twice`);
|
|
12221
|
+
}
|
|
12222
|
+
if (kind === "date" && names.includes("mm") && !has("hour")) {
|
|
12223
|
+
throw new DateFormatError(`uses \`mm\`, which is minutes \u2014 did you mean \`${suggest(pattern, kind)}\`?`);
|
|
12224
|
+
}
|
|
12225
|
+
if (kind === "date" && parts.some((part) => TIME_PARTS.has(part))) {
|
|
12226
|
+
throw new DateFormatError("has a time of day, which a date has not \u2014 declare `z.iso.datetime({ local: true })`");
|
|
12227
|
+
}
|
|
12228
|
+
if (kind === "time" && parts.some((part) => DATE_PARTS.has(part))) {
|
|
12229
|
+
throw new DateFormatError("has a date, which a time has not \u2014 declare `z.iso.datetime({ local: true })`");
|
|
12230
|
+
}
|
|
12231
|
+
const missing = [
|
|
12232
|
+
...kind !== "time" ? [["year", "yyyy"], ["month", "MM"], ["day", "dd"]] : [],
|
|
12233
|
+
...kind !== "date" ? [["hour", "HH"], ["minute", "mm"]] : []
|
|
12234
|
+
].filter(([part]) => !has(part)).map(([, token]) => `\`${token}\``);
|
|
12235
|
+
if (missing.length) {
|
|
12236
|
+
throw new DateFormatError(`is missing ${missing.join(", ")} \u2014 every part of a ${describeKind(kind)} must be in it`);
|
|
12237
|
+
}
|
|
12238
|
+
if ((names.includes("hh") || names.includes("h")) && !names.includes("a")) {
|
|
12239
|
+
throw new DateFormatError(
|
|
12240
|
+
"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"
|
|
12241
|
+
);
|
|
12242
|
+
}
|
|
12243
|
+
parsedPatterns.set(key, tokens);
|
|
12244
|
+
return tokens;
|
|
12245
|
+
}
|
|
12246
|
+
var describeKind = (kind) => kind === "date" ? "date" : kind === "time" ? "time" : "date and time";
|
|
12247
|
+
var pad = (value, width) => String(value).padStart(width, "0");
|
|
12248
|
+
function formatParts(parts, pattern, kind) {
|
|
12249
|
+
return compilePattern(pattern, kind).map((token) => {
|
|
12250
|
+
if ("literal" in token) {
|
|
12251
|
+
return token.literal;
|
|
12252
|
+
}
|
|
12253
|
+
const hour = parts.hour ?? 0;
|
|
12254
|
+
switch (token.token) {
|
|
12255
|
+
case "yyyy":
|
|
12256
|
+
return pad(parts.year ?? 0, 4);
|
|
12257
|
+
case "yy":
|
|
12258
|
+
return pad((parts.year ?? 0) % 100, 2);
|
|
12259
|
+
case "MM":
|
|
12260
|
+
return pad(parts.month ?? 0, 2);
|
|
12261
|
+
case "M":
|
|
12262
|
+
return String(parts.month ?? 0);
|
|
12263
|
+
case "dd":
|
|
12264
|
+
return pad(parts.day ?? 0, 2);
|
|
12265
|
+
case "d":
|
|
12266
|
+
return String(parts.day ?? 0);
|
|
12267
|
+
case "HH":
|
|
12268
|
+
return pad(hour, 2);
|
|
12269
|
+
case "H":
|
|
12270
|
+
return String(hour);
|
|
12271
|
+
case "hh":
|
|
12272
|
+
return pad(hour % 12 || 12, 2);
|
|
12273
|
+
case "h":
|
|
12274
|
+
return String(hour % 12 || 12);
|
|
12275
|
+
case "mm":
|
|
12276
|
+
return pad(parts.minute ?? 0, 2);
|
|
12277
|
+
case "ss":
|
|
12278
|
+
return pad(parts.second ?? 0, 2);
|
|
12279
|
+
case "a":
|
|
12280
|
+
return hour < 12 ? "AM" : "PM";
|
|
12281
|
+
}
|
|
12282
|
+
}).join("");
|
|
12283
|
+
}
|
|
12284
|
+
var escapeRegex = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12285
|
+
function parseInPattern(text2, pattern, kind) {
|
|
12286
|
+
const tokens = compilePattern(pattern, kind);
|
|
12287
|
+
const order = [];
|
|
12288
|
+
const source = tokens.map((token) => {
|
|
12289
|
+
if ("literal" in token) {
|
|
12290
|
+
return escapeRegex(token.literal);
|
|
12291
|
+
}
|
|
12292
|
+
order.push(token.token);
|
|
12293
|
+
if (token.token === "a") {
|
|
12294
|
+
return "(AM|PM)";
|
|
12295
|
+
}
|
|
12296
|
+
const { width } = SPEC[token.token];
|
|
12297
|
+
return width ? `(\\d{${width}})` : "(\\d{1,2})";
|
|
12298
|
+
}).join("");
|
|
12299
|
+
const match = new RegExp(`^${source}$`).exec(text2);
|
|
12300
|
+
if (!match) {
|
|
12301
|
+
return void 0;
|
|
12302
|
+
}
|
|
12303
|
+
const parts = {};
|
|
12304
|
+
let meridiem;
|
|
12305
|
+
order.forEach((name, index) => {
|
|
12306
|
+
const raw = match[index + 1];
|
|
12307
|
+
if (name === "a") {
|
|
12308
|
+
meridiem = raw;
|
|
12309
|
+
return;
|
|
12310
|
+
}
|
|
12311
|
+
const value = Number(raw);
|
|
12312
|
+
switch (name) {
|
|
12313
|
+
// date-fns' two-digit year rule against its reference year 2000: 00–49 → 20xx, 50–99 → 19xx.
|
|
12314
|
+
case "yy":
|
|
12315
|
+
parts.year = value < 50 ? 2e3 + value : 1900 + value;
|
|
12316
|
+
break;
|
|
12317
|
+
case "hh":
|
|
12318
|
+
case "h":
|
|
12319
|
+
parts.hour = value;
|
|
12320
|
+
break;
|
|
12321
|
+
default:
|
|
12322
|
+
parts[SPEC[name].part] = value;
|
|
12323
|
+
}
|
|
12324
|
+
});
|
|
12325
|
+
if (meridiem) {
|
|
12326
|
+
if (parts.hour === void 0 || parts.hour < 1 || parts.hour > 12) {
|
|
12327
|
+
return void 0;
|
|
12328
|
+
}
|
|
12329
|
+
parts.hour = parts.hour % 12 + (meridiem === "PM" ? 12 : 0);
|
|
12330
|
+
}
|
|
12331
|
+
const complete = completeParts(parts, kind);
|
|
12332
|
+
return complete && formatParts(complete, pattern, kind) === text2 ? complete : void 0;
|
|
12333
|
+
}
|
|
12334
|
+
function completeParts(parts, kind) {
|
|
12335
|
+
const { year, month, day, hour, minute, second } = parts;
|
|
12336
|
+
if (kind !== "time" && !isRealDate(year, month, day)) {
|
|
12337
|
+
return void 0;
|
|
12338
|
+
}
|
|
12339
|
+
if (kind !== "date" && !isRealTime(hour, minute, second)) {
|
|
12340
|
+
return void 0;
|
|
12341
|
+
}
|
|
12342
|
+
return kind === "date" ? { year, month, day } : kind === "time" ? { hour, minute, ...second !== void 0 ? { second } : {} } : { year, month, day, hour, minute, ...second !== void 0 ? { second } : {} };
|
|
12343
|
+
}
|
|
12344
|
+
function isRealDate(year, month, day) {
|
|
12345
|
+
if (year === void 0 || month === void 0 || day === void 0 || month < 1 || month > 12 || day < 1) {
|
|
12346
|
+
return false;
|
|
12347
|
+
}
|
|
12348
|
+
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
12349
|
+
const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
|
|
12350
|
+
return day <= days;
|
|
12351
|
+
}
|
|
12352
|
+
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);
|
|
12353
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
12354
|
+
var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
|
|
12355
|
+
var ISO_TIME = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
|
|
12356
|
+
function parseIso(text2, kind) {
|
|
12357
|
+
const dateTime = ISO_DATE_TIME.exec(text2);
|
|
12358
|
+
if (dateTime) {
|
|
12359
|
+
const [, year, month, day, hour, minute, second] = dateTime.map(Number);
|
|
12360
|
+
return completeParts({ year, month, day, hour, minute, ...dateTime[6] ? { second } : {} }, kind);
|
|
12361
|
+
}
|
|
12362
|
+
const date = ISO_DATE.exec(text2);
|
|
12363
|
+
if (date) {
|
|
12364
|
+
return kind === "date" ? completeParts({ year: +date[1], month: +date[2], day: +date[3] }, kind) : void 0;
|
|
12365
|
+
}
|
|
12366
|
+
const time = ISO_TIME.exec(text2);
|
|
12367
|
+
if (time && kind === "time") {
|
|
12368
|
+
return completeParts({ hour: +time[1], minute: +time[2], ...time[3] ? { second: +time[3] } : {} }, kind);
|
|
12369
|
+
}
|
|
12370
|
+
return void 0;
|
|
12371
|
+
}
|
|
12372
|
+
function toCanonical(parts, kind) {
|
|
12373
|
+
const seconds = parts.second !== void 0 ? `:${pad(parts.second, 2)}` : "";
|
|
12374
|
+
const date = `${pad(parts.year ?? 0, 4)}-${pad(parts.month ?? 0, 2)}-${pad(parts.day ?? 0, 2)}`;
|
|
12375
|
+
const time = `${pad(parts.hour ?? 0, 2)}:${pad(parts.minute ?? 0, 2)}${seconds}`;
|
|
12376
|
+
return kind === "date" ? date : kind === "time" ? time : `${date}T${time}`;
|
|
12377
|
+
}
|
|
12378
|
+
function canonicalToPattern(canonical, ins, kind) {
|
|
12379
|
+
const pattern = ins.meta.frDateFormat;
|
|
12380
|
+
if (!pattern) {
|
|
12381
|
+
return canonical;
|
|
12382
|
+
}
|
|
12383
|
+
const parts = parseIso(canonical, kind);
|
|
12384
|
+
return parts ? formatParts(parts, pattern, kind) : canonical;
|
|
12385
|
+
}
|
|
12386
|
+
var isTimestamp = (value) => typeof value === "number" && Number.isFinite(value) || typeof value === "string" && /^-?\d+(\.\d+)?$/.test(value.trim());
|
|
12387
|
+
function timestampParts(value, kind) {
|
|
12388
|
+
const date = new Date(Number(value));
|
|
12389
|
+
if (Number.isNaN(date.getTime())) {
|
|
12390
|
+
return void 0;
|
|
12391
|
+
}
|
|
12392
|
+
const second = date.getSeconds();
|
|
12393
|
+
return completeParts({
|
|
12394
|
+
year: date.getFullYear(),
|
|
12395
|
+
month: date.getMonth() + 1,
|
|
12396
|
+
day: date.getDate(),
|
|
12397
|
+
hour: date.getHours(),
|
|
12398
|
+
minute: date.getMinutes(),
|
|
12399
|
+
...second ? { second } : {}
|
|
12400
|
+
}, kind);
|
|
12401
|
+
}
|
|
12402
|
+
function toDateString(value, ins, kind) {
|
|
12403
|
+
if (typeof value === "string") {
|
|
12404
|
+
const text2 = value.trim();
|
|
12405
|
+
const pattern = ins.meta.frDateFormat;
|
|
12406
|
+
const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? parseIso(text2, kind);
|
|
12407
|
+
if (parts) {
|
|
12408
|
+
return { canonical: toCanonical(parts, kind) };
|
|
12409
|
+
}
|
|
12410
|
+
}
|
|
12411
|
+
if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value)) {
|
|
12412
|
+
const parts = timestampParts(value, kind);
|
|
12413
|
+
return parts ? { canonical: toCanonical(parts, kind), fromTimestamp: true } : {};
|
|
12414
|
+
}
|
|
12415
|
+
return {};
|
|
12416
|
+
}
|
|
12417
|
+
var EXAMPLE = { year: 2024, month: 1, day: 31, hour: 13, minute: 45, second: 30 };
|
|
12418
|
+
function expectedDateString(ins, kind) {
|
|
12419
|
+
const pattern = patternOf(ins, kind);
|
|
12420
|
+
const shown = ins.meta.frDateFormat ? pattern : pattern.replace(/'T'/, "T");
|
|
12421
|
+
const example = formatParts(EXAMPLE, pattern, kind);
|
|
12422
|
+
return `${kind === "date" ? "a date" : kind === "time" ? "a time" : "a date and time"} in ${shown}, e.g. ${example}`;
|
|
12423
|
+
}
|
|
12424
|
+
function hasDateFormat(schema, seen = /* @__PURE__ */ new Set()) {
|
|
12425
|
+
if (!schema || seen.has(schema)) {
|
|
12426
|
+
return false;
|
|
12427
|
+
}
|
|
12428
|
+
seen.add(schema);
|
|
12429
|
+
const ins = inspect(schema);
|
|
12430
|
+
if (ins.meta.frDateFormat && dateStringKind(ins)) {
|
|
12431
|
+
return true;
|
|
12432
|
+
}
|
|
12433
|
+
const def = ins.core?._zod?.def ?? {};
|
|
12434
|
+
const children = [
|
|
12435
|
+
...shapeEntries(ins.core).map(([, child]) => child),
|
|
12436
|
+
...def.element ? [def.element] : [],
|
|
12437
|
+
...def.valueType ? [def.valueType] : [],
|
|
12438
|
+
...ins.branches ?? []
|
|
12439
|
+
];
|
|
12440
|
+
return children.some((child) => hasDateFormat(child, seen));
|
|
12441
|
+
}
|
|
12442
|
+
|
|
12443
|
+
// ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
|
|
12444
|
+
var DictionaryScope = class _DictionaryScope {
|
|
12445
|
+
constructor(top, visible) {
|
|
12446
|
+
this.top = top;
|
|
12447
|
+
this.visible = visible;
|
|
12448
|
+
}
|
|
12449
|
+
static {
|
|
12450
|
+
this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
|
|
12451
|
+
}
|
|
12452
|
+
enter(names) {
|
|
12453
|
+
if (!this.top) {
|
|
12454
|
+
const top = new Set(names);
|
|
12455
|
+
return new _DictionaryScope(top, top);
|
|
12456
|
+
}
|
|
12457
|
+
return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
|
|
12458
|
+
}
|
|
12459
|
+
};
|
|
12460
|
+
function resolveDependsOn(binding, scope2) {
|
|
12461
|
+
const aliases = binding.criteriaAliases ?? {};
|
|
12462
|
+
let clash;
|
|
12463
|
+
const dependsOn = binding.dependsOn.map((key) => {
|
|
12464
|
+
const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
|
|
12465
|
+
if (visible.length > 1 && !clash) {
|
|
12466
|
+
clash = { key, names: visible };
|
|
12467
|
+
}
|
|
12468
|
+
return visible[0] ?? key;
|
|
12469
|
+
});
|
|
12470
|
+
return clash ? { dependsOn, clash } : { dependsOn };
|
|
12471
|
+
}
|
|
12472
|
+
function publishedBinding(binding, scope2) {
|
|
12473
|
+
return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
|
|
12474
|
+
}
|
|
12475
|
+
|
|
12141
12476
|
// ../../flow-extension-runner/src/v2/params/schema/assert-supported-schema.ts
|
|
12142
12477
|
var GUARDED_KINDS = /* @__PURE__ */ new Set(["action", "dictionary", "polling trigger", "realtime trigger", "extension"]);
|
|
12143
12478
|
var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -12267,6 +12602,48 @@ function assertDictionaryBinding(schema, source, path2, scope2) {
|
|
|
12267
12602
|
);
|
|
12268
12603
|
}
|
|
12269
12604
|
}
|
|
12605
|
+
function assertDateString(schema, source, path2) {
|
|
12606
|
+
const ins = inspect(schema);
|
|
12607
|
+
const pattern = ins.meta.frDateFormat;
|
|
12608
|
+
const kind = dateStringKind(ins);
|
|
12609
|
+
if (pattern !== void 0 && !kind) {
|
|
12610
|
+
const format = ins.core?._zod?.def?.format;
|
|
12611
|
+
const zoned = ins.coreType === "string" && format === "datetime";
|
|
12612
|
+
refuse(
|
|
12613
|
+
`${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.`,
|
|
12614
|
+
source,
|
|
12615
|
+
path2,
|
|
12616
|
+
zoned ? "datetime" : ins.resolvedType ?? "unknown"
|
|
12617
|
+
);
|
|
12618
|
+
}
|
|
12619
|
+
if (!kind) {
|
|
12620
|
+
return;
|
|
12621
|
+
}
|
|
12622
|
+
if (pattern !== void 0) {
|
|
12623
|
+
try {
|
|
12624
|
+
compilePattern(pattern, kind);
|
|
12625
|
+
} catch (error) {
|
|
12626
|
+
if (error instanceof DateFormatError) {
|
|
12627
|
+
refuse(`${subjectOf(source, path2)}: \`.dateFormat('${pattern}')\` ${error.message}.`, source, path2, pattern);
|
|
12628
|
+
}
|
|
12629
|
+
throw error;
|
|
12630
|
+
}
|
|
12631
|
+
}
|
|
12632
|
+
const fallback = ins.defaultValue;
|
|
12633
|
+
if (fallback === void 0 || fallback === null) {
|
|
12634
|
+
return;
|
|
12635
|
+
}
|
|
12636
|
+
const written = patternOf(ins, kind);
|
|
12637
|
+
const fits = typeof fallback === "string" && (pattern !== void 0 ? !!parseInPattern(fallback, pattern, kind) : ((parts) => !!parts && toCanonical(parts, kind) === fallback)(parseIso(fallback, kind)));
|
|
12638
|
+
if (!fits) {
|
|
12639
|
+
refuse(
|
|
12640
|
+
`${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.`,
|
|
12641
|
+
source,
|
|
12642
|
+
path2,
|
|
12643
|
+
String(fallback)
|
|
12644
|
+
);
|
|
12645
|
+
}
|
|
12646
|
+
}
|
|
12270
12647
|
function assertField(schema, source, path2, seen, scope2, topLevel = false) {
|
|
12271
12648
|
if (!schema || seen.has(schema)) {
|
|
12272
12649
|
return;
|
|
@@ -12285,6 +12662,7 @@ function assertField(schema, source, path2, seen, scope2, topLevel = false) {
|
|
|
12285
12662
|
refuseCatch(source, path2);
|
|
12286
12663
|
}
|
|
12287
12664
|
assertDictionaryBinding(schema, source, path2, scope2);
|
|
12665
|
+
assertDateString(schema, source, path2);
|
|
12288
12666
|
if (!ins.resolvedType || !SUPPORTED_TYPES.has(ins.resolvedType)) {
|
|
12289
12667
|
refuseType(source, path2, ins.resolvedType);
|
|
12290
12668
|
}
|
|
@@ -12474,7 +12852,6 @@ function declaredAbsence(schema) {
|
|
|
12474
12852
|
function coerces(schema) {
|
|
12475
12853
|
return inspect(schema).core?._zod?.def?.coerce === true;
|
|
12476
12854
|
}
|
|
12477
|
-
var parsesJson = (schema) => !!inspect(schema).meta.frJson;
|
|
12478
12855
|
var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
|
|
12479
12856
|
var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
|
|
12480
12857
|
function requiredOpenType(schema) {
|
|
@@ -12496,7 +12873,7 @@ function requiredOpenType(schema) {
|
|
|
12496
12873
|
return false;
|
|
12497
12874
|
}
|
|
12498
12875
|
function probeAbsence(schema) {
|
|
12499
|
-
if (coerces(schema)
|
|
12876
|
+
if (coerces(schema)) {
|
|
12500
12877
|
return declaredAbsence(schema);
|
|
12501
12878
|
}
|
|
12502
12879
|
if (requiredOpenType(schema)) {
|
|
@@ -12523,7 +12900,7 @@ function absenceOf(schema) {
|
|
|
12523
12900
|
if (cached) {
|
|
12524
12901
|
return cached;
|
|
12525
12902
|
}
|
|
12526
|
-
const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema)
|
|
12903
|
+
const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) };
|
|
12527
12904
|
probeCache.set(schema, probed);
|
|
12528
12905
|
return probed;
|
|
12529
12906
|
}
|
|
@@ -12541,10 +12918,39 @@ function planField(name, schema) {
|
|
|
12541
12918
|
keepsEmpty,
|
|
12542
12919
|
blankIsValue,
|
|
12543
12920
|
passThroughDate: passesDateThrough(ins),
|
|
12544
|
-
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
|
|
12921
|
+
restoresDates: hasPassThroughDate(schema, inspect, shapeEntries),
|
|
12922
|
+
dateString: dateStringKind(ins),
|
|
12923
|
+
formatsDates: hasDateFormat(schema)
|
|
12545
12924
|
};
|
|
12546
12925
|
}
|
|
12547
12926
|
|
|
12927
|
+
// ../../flow-extension-runner/src/v2/params/schema/notices.ts
|
|
12928
|
+
var sink;
|
|
12929
|
+
var currentField;
|
|
12930
|
+
function collectNotices(fn) {
|
|
12931
|
+
const outer = sink;
|
|
12932
|
+
const notices = [];
|
|
12933
|
+
sink = notices;
|
|
12934
|
+
try {
|
|
12935
|
+
return { result: fn(), notices };
|
|
12936
|
+
} finally {
|
|
12937
|
+
sink = outer;
|
|
12938
|
+
outer?.push(...notices);
|
|
12939
|
+
}
|
|
12940
|
+
}
|
|
12941
|
+
function withinField(field, fn) {
|
|
12942
|
+
const outer = currentField;
|
|
12943
|
+
currentField = field;
|
|
12944
|
+
try {
|
|
12945
|
+
return fn();
|
|
12946
|
+
} finally {
|
|
12947
|
+
currentField = outer;
|
|
12948
|
+
}
|
|
12949
|
+
}
|
|
12950
|
+
function notice(entry) {
|
|
12951
|
+
sink?.push({ field: currentField, ...entry });
|
|
12952
|
+
}
|
|
12953
|
+
|
|
12548
12954
|
// ../../flow-extension-runner/src/v2/params/schema/coerce.ts
|
|
12549
12955
|
var ok = (value) => ({ ok: true, value });
|
|
12550
12956
|
var fail = (expected) => ({ ok: false, expected });
|
|
@@ -12557,8 +12963,29 @@ function toStringValue(value) {
|
|
|
12557
12963
|
if (typeof value === "boolean") {
|
|
12558
12964
|
return ok(String(value));
|
|
12559
12965
|
}
|
|
12966
|
+
if (value !== null && typeof value === "object") {
|
|
12967
|
+
return ok(value instanceof Date ? value.toISOString() : JSON.stringify(value));
|
|
12968
|
+
}
|
|
12560
12969
|
return typeof value === "number" && Number.isFinite(value) ? ok(String(value)) : fail("string");
|
|
12561
12970
|
}
|
|
12971
|
+
var OPENS = { array: "[", object: "{" };
|
|
12972
|
+
function parseContainerText(value, kind) {
|
|
12973
|
+
if (typeof value !== "string") {
|
|
12974
|
+
return value;
|
|
12975
|
+
}
|
|
12976
|
+
const text2 = value.trim();
|
|
12977
|
+
if (!text2.startsWith(OPENS[kind])) {
|
|
12978
|
+
return value;
|
|
12979
|
+
}
|
|
12980
|
+
try {
|
|
12981
|
+
const parsed = JSON.parse(text2);
|
|
12982
|
+
const isList = Array.isArray(parsed);
|
|
12983
|
+
const fits = kind === "array" ? isList : parsed !== null && typeof parsed === "object" && !isList;
|
|
12984
|
+
return fits ? parsed : value;
|
|
12985
|
+
} catch {
|
|
12986
|
+
return value;
|
|
12987
|
+
}
|
|
12988
|
+
}
|
|
12562
12989
|
function toNumberValue(value) {
|
|
12563
12990
|
if (typeof value === "number") {
|
|
12564
12991
|
return Number.isFinite(value) ? ok(value) : fail("number");
|
|
@@ -12598,16 +13025,6 @@ function toBooleanValue(value) {
|
|
|
12598
13025
|
const lowered = value.trim().toLowerCase();
|
|
12599
13026
|
return TRUE.has(lowered) ? ok(true) : FALSE.has(lowered) ? ok(false) : fail("boolean");
|
|
12600
13027
|
}
|
|
12601
|
-
function toJsonValue(value) {
|
|
12602
|
-
if (typeof value !== "string") {
|
|
12603
|
-
return ok(value);
|
|
12604
|
-
}
|
|
12605
|
-
try {
|
|
12606
|
-
return ok(JSON.parse(value));
|
|
12607
|
-
} catch {
|
|
12608
|
-
return fail("json");
|
|
12609
|
-
}
|
|
12610
|
-
}
|
|
12611
13028
|
function coerceValue(value, coreType) {
|
|
12612
13029
|
if (coreType === "string") {
|
|
12613
13030
|
return toStringValue(value);
|
|
@@ -12641,7 +13058,11 @@ function coerceUnion(value, branches) {
|
|
|
12641
13058
|
if (branches.some((branch) => accepts(branch, value))) {
|
|
12642
13059
|
return value;
|
|
12643
13060
|
}
|
|
13061
|
+
const isStructure = value !== null && typeof value === "object";
|
|
12644
13062
|
for (const branch of branches) {
|
|
13063
|
+
if (isStructure && inspect(branch).coreType === "string") {
|
|
13064
|
+
continue;
|
|
13065
|
+
}
|
|
12645
13066
|
const coerced = coerceDeep(value, branch);
|
|
12646
13067
|
if (accepts(branch, coerced)) {
|
|
12647
13068
|
return coerced;
|
|
@@ -12666,22 +13087,25 @@ function coerceDeep(value, schema) {
|
|
|
12666
13087
|
}
|
|
12667
13088
|
if (ins.coreType === "array") {
|
|
12668
13089
|
const element = ins.core?._zod?.def?.element;
|
|
12669
|
-
|
|
13090
|
+
const list = parseContainerText(value, "array");
|
|
13091
|
+
return Array.isArray(list) ? list.map((item) => coerceDeep(item, element)) : list;
|
|
12670
13092
|
}
|
|
12671
13093
|
if (ins.coreType === "record") {
|
|
12672
|
-
|
|
12673
|
-
|
|
13094
|
+
const map = parseContainerText(value, "object");
|
|
13095
|
+
if (typeof map !== "object" || Array.isArray(map)) {
|
|
13096
|
+
return map;
|
|
12674
13097
|
}
|
|
12675
13098
|
const valueType = ins.core?._zod?.def?.valueType;
|
|
12676
13099
|
return Object.fromEntries(
|
|
12677
|
-
Object.entries(
|
|
13100
|
+
Object.entries(map).map(([key, item]) => [key, coerceDeep(item, valueType)])
|
|
12678
13101
|
);
|
|
12679
13102
|
}
|
|
12680
13103
|
if (ins.coreType === "object") {
|
|
12681
|
-
|
|
12682
|
-
|
|
13104
|
+
const parsed = parseContainerText(value, "object");
|
|
13105
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
13106
|
+
return parsed;
|
|
12683
13107
|
}
|
|
12684
|
-
const source =
|
|
13108
|
+
const source = parsed;
|
|
12685
13109
|
const coerced = { ...source };
|
|
12686
13110
|
for (const [name, property] of shapeEntries(ins.core)) {
|
|
12687
13111
|
if (name in source) {
|
|
@@ -12698,8 +13122,20 @@ function coerceLeaf(value, ins) {
|
|
|
12698
13122
|
if (ins.branches) {
|
|
12699
13123
|
return ok(coerceUnion(value, ins.branches));
|
|
12700
13124
|
}
|
|
12701
|
-
|
|
12702
|
-
|
|
13125
|
+
const kind = dateStringKind(ins);
|
|
13126
|
+
if (kind) {
|
|
13127
|
+
const { canonical, fromTimestamp } = toDateString(value, ins, kind);
|
|
13128
|
+
if (canonical === void 0) {
|
|
13129
|
+
return fail(expectedDateString(ins, kind));
|
|
13130
|
+
}
|
|
13131
|
+
if (fromTimestamp) {
|
|
13132
|
+
notice({
|
|
13133
|
+
message: "a timestamp was converted to a date string in the server time zone (FR-3920 lenient period)",
|
|
13134
|
+
value,
|
|
13135
|
+
converted: canonical
|
|
13136
|
+
});
|
|
13137
|
+
}
|
|
13138
|
+
return ok(canonical);
|
|
12703
13139
|
}
|
|
12704
13140
|
const format = formatOf(ins);
|
|
12705
13141
|
if (ins.coreType === "string" && isConvertibleIso(format)) {
|
|
@@ -12734,7 +13170,7 @@ function isBlank(value, ins, schema) {
|
|
|
12734
13170
|
if (absenceOf(schema).blankIsValue) {
|
|
12735
13171
|
return absenceOf(schema).absorbsBlank;
|
|
12736
13172
|
}
|
|
12737
|
-
return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
|
|
13173
|
+
return ins.coreType !== "string" || !!dateStringKind(ins) || absenceOf(schema).absorbsBlank;
|
|
12738
13174
|
}
|
|
12739
13175
|
function absentAs(schema, value) {
|
|
12740
13176
|
const { absence } = absenceOf(schema);
|
|
@@ -12794,8 +13230,8 @@ var EXPECTED = {
|
|
|
12794
13230
|
date: "a date",
|
|
12795
13231
|
object: "an object",
|
|
12796
13232
|
array: "an array",
|
|
12797
|
-
// `z.
|
|
12798
|
-
|
|
13233
|
+
// zod's own token for `z.record()`, which the author declared as a map — to a person it is an object.
|
|
13234
|
+
record: "an object"
|
|
12799
13235
|
};
|
|
12800
13236
|
var requiredMessage = (plan) => `\xAB${plan.label}\xBB is required`;
|
|
12801
13237
|
var invalidTypeMessage = (plan, expected) => `\xAB${plan.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
|
|
@@ -12822,7 +13258,7 @@ function resolveTarget(plan, segments, fieldValue) {
|
|
|
12822
13258
|
schema = nested[1];
|
|
12823
13259
|
label = labelOf(segment, schema);
|
|
12824
13260
|
}
|
|
12825
|
-
return { label, value, found };
|
|
13261
|
+
return { label, value, found, schema: found ? schema : void 0 };
|
|
12826
13262
|
}
|
|
12827
13263
|
function bound(value, plan) {
|
|
12828
13264
|
if (plan.coreType !== "date" || typeof value !== "number") {
|
|
@@ -12844,6 +13280,11 @@ function toFieldIssue(plan, issue, fieldValue) {
|
|
|
12844
13280
|
if (isAuthored(issue)) {
|
|
12845
13281
|
return { path: path2, code, message: issue.message };
|
|
12846
13282
|
}
|
|
13283
|
+
const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
|
|
13284
|
+
const dateMissing = target.value == null || target.value === "";
|
|
13285
|
+
if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
|
|
13286
|
+
return dateMissing ? { path: path2, code, message: requiredMessage(named) } : { path: path2, code, message: invalidTypeMessage(named, expectedDateString(inspect(target.schema), dateKind)) };
|
|
13287
|
+
}
|
|
12847
13288
|
if (code === "invalid_type") {
|
|
12848
13289
|
const received = issue.received;
|
|
12849
13290
|
const absent = segments.length ? target.found && target.value == null : received === "undefined" || received === "null" || issue.expected === void 0;
|
|
@@ -12888,7 +13329,7 @@ function isAbsent(value, plan) {
|
|
|
12888
13329
|
if (plan.blankIsValue) {
|
|
12889
13330
|
return plan.absorbsBlank;
|
|
12890
13331
|
}
|
|
12891
|
-
return plan.coreType !== "string" || plan.absorbsBlank;
|
|
13332
|
+
return plan.coreType !== "string" || !!plan.dateString || plan.absorbsBlank;
|
|
12892
13333
|
}
|
|
12893
13334
|
function normalizeAbsence(value, plan) {
|
|
12894
13335
|
if (plan.absence === "required") {
|
|
@@ -12927,7 +13368,7 @@ function normalizeField(value, plan) {
|
|
|
12927
13368
|
return restore(validate(coerced.value, plan), value, plan);
|
|
12928
13369
|
}
|
|
12929
13370
|
function restore(result, original, plan) {
|
|
12930
|
-
if (!plan.restoresDates || !result.present || result.issues.length) {
|
|
13371
|
+
if (!(plan.restoresDates || plan.formatsDates) || !result.present || result.issues.length) {
|
|
12931
13372
|
return result;
|
|
12932
13373
|
}
|
|
12933
13374
|
if (plan.passThroughDate) {
|
|
@@ -12947,6 +13388,10 @@ function restoreDeep(output, original, schema) {
|
|
|
12947
13388
|
const branch = ins.branches.find((option) => accepts(option, output));
|
|
12948
13389
|
return branch ? restoreDeep(output, original, branch) : output;
|
|
12949
13390
|
}
|
|
13391
|
+
const kind = dateStringKind(ins);
|
|
13392
|
+
if (kind) {
|
|
13393
|
+
return typeof output === "string" && original !== "" ? canonicalToPattern(output, ins, kind) : output;
|
|
13394
|
+
}
|
|
12950
13395
|
const element = ins.core?._zod?.def?.element;
|
|
12951
13396
|
if (ins.coreType === "array" && element && Array.isArray(output) && Array.isArray(original)) {
|
|
12952
13397
|
return output.map((item, index) => restoreDeep(item, original[index], element));
|
|
@@ -13036,7 +13481,7 @@ var Params = class {
|
|
|
13036
13481
|
const values = {};
|
|
13037
13482
|
const issues = [];
|
|
13038
13483
|
for (const plan of this.plans()) {
|
|
13039
|
-
const result = normalizeField(source[plan.name], plan);
|
|
13484
|
+
const result = withinField(plan.name, () => normalizeField(source[plan.name], plan));
|
|
13040
13485
|
if (result.issues.length) {
|
|
13041
13486
|
issues.push(...result.issues);
|
|
13042
13487
|
} else if (result.present) {
|
|
@@ -13191,6 +13636,9 @@ function extendPrototype() {
|
|
|
13191
13636
|
}
|
|
13192
13637
|
return this.meta({ frDictionary: binding });
|
|
13193
13638
|
};
|
|
13639
|
+
proto.dateFormat = function dateFormat(pattern) {
|
|
13640
|
+
return this.meta({ frDateFormat: pattern });
|
|
13641
|
+
};
|
|
13194
13642
|
proto.labels = function labels(byValue) {
|
|
13195
13643
|
return this.meta({ frLabels: byValue });
|
|
13196
13644
|
};
|
|
@@ -13213,10 +13661,9 @@ function text() {
|
|
|
13213
13661
|
return import_zod2.z.string().meta({ frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT });
|
|
13214
13662
|
}
|
|
13215
13663
|
function json() {
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
});
|
|
13664
|
+
throw new Error(
|
|
13665
|
+
"`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."
|
|
13666
|
+
);
|
|
13220
13667
|
}
|
|
13221
13668
|
var namespace = Object.create(import_zod2.z);
|
|
13222
13669
|
Object.defineProperties(namespace, {
|
|
@@ -13230,7 +13677,7 @@ Object.defineProperties(namespace, {
|
|
|
13230
13677
|
var z = namespace;
|
|
13231
13678
|
|
|
13232
13679
|
// ../../flow-extension-runner/src/v2/params/json/values.ts
|
|
13233
|
-
function
|
|
13680
|
+
function toJsonValue(value) {
|
|
13234
13681
|
if (typeof value === "bigint") {
|
|
13235
13682
|
return { $bigint: value.toString() };
|
|
13236
13683
|
}
|
|
@@ -13238,10 +13685,10 @@ function toJsonValue2(value) {
|
|
|
13238
13685
|
return { $date: value.toISOString() };
|
|
13239
13686
|
}
|
|
13240
13687
|
if (Array.isArray(value)) {
|
|
13241
|
-
return value.map(
|
|
13688
|
+
return value.map(toJsonValue);
|
|
13242
13689
|
}
|
|
13243
13690
|
if (value && typeof value === "object") {
|
|
13244
|
-
return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key,
|
|
13691
|
+
return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue(inner)]));
|
|
13245
13692
|
}
|
|
13246
13693
|
return value;
|
|
13247
13694
|
}
|
|
@@ -13276,18 +13723,18 @@ function encodeCheck(check) {
|
|
|
13276
13723
|
switch (def.check) {
|
|
13277
13724
|
// strings and arrays
|
|
13278
13725
|
case "min_length":
|
|
13279
|
-
return at("min",
|
|
13726
|
+
return at("min", toJsonValue(def.minimum));
|
|
13280
13727
|
case "max_length":
|
|
13281
|
-
return at("max",
|
|
13728
|
+
return at("max", toJsonValue(def.maximum));
|
|
13282
13729
|
case "length_equals":
|
|
13283
|
-
return at("length",
|
|
13730
|
+
return at("length", toJsonValue(def.length));
|
|
13284
13731
|
// numbers and bigints
|
|
13285
13732
|
case "greater_than":
|
|
13286
|
-
return at("min",
|
|
13733
|
+
return at("min", toJsonValue(def.value), def.inclusive ? void 0 : true);
|
|
13287
13734
|
case "less_than":
|
|
13288
|
-
return at("max",
|
|
13735
|
+
return at("max", toJsonValue(def.value), def.inclusive ? void 0 : true);
|
|
13289
13736
|
case "multiple_of":
|
|
13290
|
-
return at("multipleOf",
|
|
13737
|
+
return at("multipleOf", toJsonValue(def.value));
|
|
13291
13738
|
case "number_format":
|
|
13292
13739
|
return def.format === "safeint" || def.format === "int32" ? at("int") : void 0;
|
|
13293
13740
|
// the string sub-formats that are checks rather than types
|
|
@@ -13448,7 +13895,7 @@ function encodeMeta(meta, field, scope2, loaderId) {
|
|
|
13448
13895
|
if (hasFunction(source)) {
|
|
13449
13896
|
throw new Error(`Cannot encode "${field}": its metadata holds a function, which has no wire form.`);
|
|
13450
13897
|
}
|
|
13451
|
-
const encoded =
|
|
13898
|
+
const encoded = toJsonValue(source);
|
|
13452
13899
|
return Object.keys(encoded).length ? encoded : void 0;
|
|
13453
13900
|
}
|
|
13454
13901
|
function isLoose(core) {
|
|
@@ -13458,11 +13905,11 @@ function isLoose(core) {
|
|
|
13458
13905
|
function encodeValues(core, type) {
|
|
13459
13906
|
if (type === "enum") {
|
|
13460
13907
|
const entries = core?._zod?.def?.entries ?? {};
|
|
13461
|
-
return Object.values(entries).map(
|
|
13908
|
+
return Object.values(entries).map(toJsonValue);
|
|
13462
13909
|
}
|
|
13463
13910
|
if (type === "literal") {
|
|
13464
13911
|
const values = core?._zod?.def?.values ?? [];
|
|
13465
|
-
return values.map(
|
|
13912
|
+
return values.map(toJsonValue);
|
|
13466
13913
|
}
|
|
13467
13914
|
return void 0;
|
|
13468
13915
|
}
|
|
@@ -13490,9 +13937,10 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
|
|
|
13490
13937
|
name,
|
|
13491
13938
|
type,
|
|
13492
13939
|
...format ? { format } : {},
|
|
13940
|
+
...format === "datetime" && core?._zod?.def?.local ? { local: true } : {},
|
|
13493
13941
|
...optional ? { optional: true } : {},
|
|
13494
13942
|
...nullable ? { nullable: true } : {},
|
|
13495
|
-
...hasDefault ? { default:
|
|
13943
|
+
...hasDefault ? { default: toJsonValue(defaultValue) } : {},
|
|
13496
13944
|
...checks.length ? { checks } : {},
|
|
13497
13945
|
...values?.length ? { values } : {},
|
|
13498
13946
|
...meta ? { meta } : {},
|
|
@@ -14142,6 +14590,9 @@ var ExecutionContext = class _ExecutionContext {
|
|
|
14142
14590
|
get logger() {
|
|
14143
14591
|
return this.#options.logger ?? defaultLogger;
|
|
14144
14592
|
}
|
|
14593
|
+
get invocation() {
|
|
14594
|
+
return this.#options.invocation ?? {};
|
|
14595
|
+
}
|
|
14145
14596
|
get config() {
|
|
14146
14597
|
this.#config ??= this.#extension.config.resolve(this.#options.configs);
|
|
14147
14598
|
return this.#config;
|
|
@@ -14294,6 +14745,10 @@ var DictionaryMethod = class extends ExtensionMethod {
|
|
|
14294
14745
|
return this.criteria.keys();
|
|
14295
14746
|
}
|
|
14296
14747
|
// ── runtime ────────────────────────────────────────────────────────────────
|
|
14748
|
+
// `search` is always text, trimmed (FR-3910): `''` when the author typed nothing — the console then sends no
|
|
14749
|
+
// `search` at all — or only spaces. So a handler never guards it: `search ? { q: search } : undefined`, and
|
|
14750
|
+
// `search.toLowerCase()` as is. Surrounding spaces never mean anything to a lookup.
|
|
14751
|
+
//
|
|
14297
14752
|
// Two-stage: the `{ search, cursor, criteria }` envelope the runtime owns, then the author-declared
|
|
14298
14753
|
// criteria through the shared pipeline — reported as a criteria failure so the console can point at the
|
|
14299
14754
|
// dependent fields rather than the whole call.
|
|
@@ -14302,7 +14757,7 @@ var DictionaryMethod = class extends ExtensionMethod {
|
|
|
14302
14757
|
const payload = input.parseField("payload", DictionaryPayloadSchema);
|
|
14303
14758
|
const criteria = this.criteria.normalize(this.#resolveAliases(payload.criteria), input.invalidCriteria());
|
|
14304
14759
|
return {
|
|
14305
|
-
search: payload.search,
|
|
14760
|
+
search: payload.search?.trim() ?? "",
|
|
14306
14761
|
cursor: payload.cursor,
|
|
14307
14762
|
criteria
|
|
14308
14763
|
};
|
|
@@ -15653,7 +16108,23 @@ var Extension = class {
|
|
|
15653
16108
|
// generated loader, SYSTEM seam — arrives here through the same three steps.
|
|
15654
16109
|
async run(methodName, methodData, ctx) {
|
|
15655
16110
|
const method = this.getMethod(methodName);
|
|
15656
|
-
|
|
16111
|
+
const { result: input, notices } = collectNotices(() => method.validate(methodData ?? {}));
|
|
16112
|
+
this.#reportNotices(notices, methodName, ctx);
|
|
16113
|
+
return method.execute(input, ctx);
|
|
16114
|
+
}
|
|
16115
|
+
// One warning per value the pipeline accepted only under a temporary rule — today a timestamp converted for
|
|
16116
|
+
// a date-string field (FR-3920 lenient period). Named well enough to find the flow still holding one.
|
|
16117
|
+
#reportNotices(notices, methodName, ctx) {
|
|
16118
|
+
for (const { message, field, value, converted } of notices) {
|
|
16119
|
+
ctx.logger.warn(`[flow-extension:${this.id}] ${methodName}: param "${field ?? "?"}": ${message}`, {
|
|
16120
|
+
serviceId: this.id,
|
|
16121
|
+
method: methodName,
|
|
16122
|
+
param: field,
|
|
16123
|
+
value,
|
|
16124
|
+
converted,
|
|
16125
|
+
...ctx.invocation
|
|
16126
|
+
});
|
|
16127
|
+
}
|
|
15657
16128
|
}
|
|
15658
16129
|
// ── output model ────────────────────────────────────────────────────────────
|
|
15659
16130
|
toConfigItems() {
|
|
@@ -16020,7 +16491,13 @@ async function runServiceMethod2(data) {
|
|
|
16020
16491
|
retrieveNewS3Token
|
|
16021
16492
|
};
|
|
16022
16493
|
const files = extension.props.usesFileStorage ? (data.createFiles ?? defaultCreateFiles)(filesOptions) : void 0;
|
|
16023
|
-
const ctx = extension.createContext({
|
|
16494
|
+
const ctx = extension.createContext({
|
|
16495
|
+
configs: data.configs,
|
|
16496
|
+
accessToken,
|
|
16497
|
+
logger: data.logger,
|
|
16498
|
+
files,
|
|
16499
|
+
invocation: { flowId, executionId }
|
|
16500
|
+
});
|
|
16024
16501
|
return extension.run(methodName, methodData, ctx);
|
|
16025
16502
|
}
|
|
16026
16503
|
|