@flowrunner/cli 0.1.17 → 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.
Files changed (38) hide show
  1. package/ai-docs/instructions/service-code-format/02-zod-types.md +139 -33
  2. package/ai-docs/instructions/service-code-format/03-parameters.md +3 -1
  3. package/ai-docs/instructions/service-code-format/05-dictionaries.md +8 -2
  4. package/ai-docs/instructions/service-code-format/07-actions.md +1 -1
  5. package/ai-docs/instructions/service-code-format/11-output-model.md +3 -0
  6. package/ai-docs/instructions/service-code-format/14-reference-service.md +1 -1
  7. package/ai-docs/instructions/service-code-format/16-gotchas.md +80 -0
  8. package/ai-docs/instructions/service-code-format/18-test-recipes.md +2 -1
  9. package/ai-docs/instructions/service-code-format/README.md +1 -1
  10. package/dist/cli.js +523 -82
  11. package/dist/cli.js.map +4 -4
  12. package/dist/index.js +522 -81
  13. package/dist/index.js.map +4 -4
  14. package/dist/types/flow-extension-runner/src/v2/context/execution-context.d.ts +8 -0
  15. package/dist/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
  16. package/dist/types/flow-extension-runner/src/v2/params/index.d.ts +2 -0
  17. package/dist/types/flow-extension-runner/src/v2/params/json/types.d.ts +2 -0
  18. package/dist/types/flow-extension-runner/src/v2/params/schema/date-format.d.ts +80 -0
  19. package/dist/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -10
  20. package/dist/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +7 -0
  21. package/dist/types/flow-extension-runner/src/v2/params/schema/notices.d.ts +15 -0
  22. package/dist/types/flow-extension-runner/src/v2/params/widget-types.d.ts +1 -1
  23. package/dist/types/flow-extension-runner/src/v2/params/zod.d.ts +30 -19
  24. package/dist/types/flow-extension-runner/src/v2/types.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/runtime/index.js +529 -82
  27. package/runtime/index.js.map +4 -4
  28. package/runtime/types/flow-extension-runner/src/v2/context/execution-context.d.ts +8 -0
  29. package/runtime/types/flow-extension-runner/src/v2/dictionaries/payload-schema.d.ts +1 -1
  30. package/runtime/types/flow-extension-runner/src/v2/params/index.d.ts +2 -0
  31. package/runtime/types/flow-extension-runner/src/v2/params/json/types.d.ts +2 -0
  32. package/runtime/types/flow-extension-runner/src/v2/params/schema/date-format.d.ts +80 -0
  33. package/runtime/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +4 -10
  34. package/runtime/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +7 -0
  35. package/runtime/types/flow-extension-runner/src/v2/params/schema/notices.d.ts +15 -0
  36. package/runtime/types/flow-extension-runner/src/v2/params/widget-types.d.ts +1 -1
  37. package/runtime/types/flow-extension-runner/src/v2/params/zod.d.ts +30 -19
  38. package/runtime/types/flow-extension-runner/src/v2/types.d.ts +1 -1
package/dist/cli.js CHANGED
@@ -14508,7 +14508,7 @@ var require_package = __commonJS({
14508
14508
  "package.json"(exports2, module2) {
14509
14509
  module2.exports = {
14510
14510
  name: "@flowrunner/cli",
14511
- version: "0.1.17",
14511
+ version: "0.1.18-dev.1",
14512
14512
  publishConfig: {
14513
14513
  access: "public"
14514
14514
  },
@@ -15758,39 +15758,6 @@ function assertObjectSchema(scheme, source) {
15758
15758
  );
15759
15759
  }
15760
15760
 
15761
- // ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
15762
- var DictionaryScope = class _DictionaryScope {
15763
- constructor(top, visible) {
15764
- this.top = top;
15765
- this.visible = visible;
15766
- }
15767
- static {
15768
- this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
15769
- }
15770
- enter(names) {
15771
- if (!this.top) {
15772
- const top = new Set(names);
15773
- return new _DictionaryScope(top, top);
15774
- }
15775
- return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
15776
- }
15777
- };
15778
- function resolveDependsOn(binding, scope2) {
15779
- const aliases = binding.criteriaAliases ?? {};
15780
- let clash;
15781
- const dependsOn = binding.dependsOn.map((key) => {
15782
- const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
15783
- if (visible.length > 1 && !clash) {
15784
- clash = { key, names: visible };
15785
- }
15786
- return visible[0] ?? key;
15787
- });
15788
- return clash ? { dependsOn, clash } : { dependsOn };
15789
- }
15790
- function publishedBinding(binding, scope2) {
15791
- return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
15792
- }
15793
-
15794
15761
  // ../../flow-extension-runner/src/v2/params/widget-types.ts
15795
15762
  var FlowExtensionParamGroupTypes = {
15796
15763
  FILE_UPLOAD_OPTIONS: "FILE_UPLOAD_OPTIONS",
@@ -15809,7 +15776,9 @@ var FlowExtensionParamWidgetTypes = {
15809
15776
  ...FlowExtensionParamGroupTypes,
15810
15777
  // legacy — no zod declaration produces these. They reach the console only from a legacy JSDoc-format
15811
15778
  // service, which writes `uiComponent` by hand. Kept because the console still renders them for an
15812
- // already-installed extension.
15779
+ // already-installed extension. `DATE_TIME_PICKER` / `TIME_PICKER` are also published, with
15780
+ // `valueKind: 'string'` and `format`, by `z.iso.datetime({ local: true })` / `z.iso.time()` (FR-3920) —
15781
+ // without `valueKind` they are the legacy tokens, storing epoch millis.
15813
15782
  NUMERIC: "NUMERIC",
15814
15783
  CHECKBOX: "CHECKBOX",
15815
15784
  DATE_TIME_PICKER: "DATE_TIME_PICKER",
@@ -15904,15 +15873,12 @@ function literalType(core) {
15904
15873
  }
15905
15874
  function deriveWidget(ins) {
15906
15875
  const { coreType, core, meta } = ins;
15907
- if (meta.frJson) {
15908
- return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
15909
- }
15910
15876
  switch (coreType) {
15911
15877
  case "string":
15912
15878
  if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
15913
15879
  return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
15914
15880
  }
15915
- return { paramType: "STRING" };
15881
+ return dateStringWidget(ins) ?? { paramType: "STRING" };
15916
15882
  case "number":
15917
15883
  case "bigint":
15918
15884
  return { paramType: "NUMBER", uiComponent: { type: FlowExtensionParamWidgetTypes.NUMERIC_STEPPER } };
@@ -15955,11 +15921,380 @@ function deriveWidget(ins) {
15955
15921
  return { paramType: "STRING" };
15956
15922
  }
15957
15923
  }
15924
+ var DATE_STRING_WIDGETS = {
15925
+ date: FlowExtensionParamWidgetTypes.DATE_PICKER,
15926
+ datetime: FlowExtensionParamWidgetTypes.DATE_TIME_PICKER,
15927
+ time: FlowExtensionParamWidgetTypes.TIME_PICKER
15928
+ };
15929
+ function dateStringWidget(ins) {
15930
+ const kind = dateStringKind(ins);
15931
+ return kind ? { paramType: "STRING", uiComponent: { type: DATE_STRING_WIDGETS[kind], valueKind: "string", format: patternOf(ins, kind) } } : void 0;
15932
+ }
15958
15933
  function shapeEntries(schema) {
15959
15934
  const shape = schema?.shape;
15960
15935
  return shape && typeof shape === "object" ? Object.entries(shape) : [];
15961
15936
  }
15962
15937
 
15938
+ // ../../flow-extension-runner/src/v2/params/schema/date-format.ts
15939
+ var ISO_PATTERNS = {
15940
+ date: "yyyy-MM-dd",
15941
+ datetime: "yyyy-MM-dd'T'HH:mm",
15942
+ time: "HH:mm"
15943
+ };
15944
+ var DATE_STRINGS_ACCEPT_TIMESTAMPS = true;
15945
+ function dateStringKind(ins) {
15946
+ if (ins.coreType !== "string") {
15947
+ return void 0;
15948
+ }
15949
+ const def = ins.core?._zod?.def;
15950
+ if (def?.format === "date" || def?.format === "time") {
15951
+ return def.format;
15952
+ }
15953
+ return def?.format === "datetime" && def.local ? "datetime" : void 0;
15954
+ }
15955
+ var patternOf = (ins, kind) => ins.meta.frDateFormat ?? ISO_PATTERNS[kind];
15956
+ var TOKENS = ["yyyy", "yy", "MM", "M", "dd", "d", "HH", "H", "hh", "h", "mm", "ss", "a"];
15957
+ var SPEC = {
15958
+ yyyy: { part: "year", width: 4 },
15959
+ yy: { part: "year", width: 2 },
15960
+ MM: { part: "month", width: 2 },
15961
+ M: { part: "month" },
15962
+ dd: { part: "day", width: 2 },
15963
+ d: { part: "day" },
15964
+ HH: { part: "hour", width: 2 },
15965
+ H: { part: "hour" },
15966
+ hh: { part: "hour", width: 2 },
15967
+ h: { part: "hour" },
15968
+ mm: { part: "minute", width: 2 },
15969
+ ss: { part: "second", width: 2 },
15970
+ a: { part: "meridiem" }
15971
+ };
15972
+ var DATE_PARTS = /* @__PURE__ */ new Set(["year", "month", "day"]);
15973
+ var TIME_PARTS = /* @__PURE__ */ new Set(["hour", "minute", "second", "meridiem"]);
15974
+ var DateFormatError = class extends Error {
15975
+ };
15976
+ var LOOK_ALIKES = {
15977
+ YYYY: "yyyy",
15978
+ YY: "yy",
15979
+ DD: "dd",
15980
+ D: "d",
15981
+ S: "ss",
15982
+ A: "a"
15983
+ };
15984
+ function tokenize(pattern, kind) {
15985
+ const tokens = [];
15986
+ let index = 0;
15987
+ while (index < pattern.length) {
15988
+ const char = pattern[index];
15989
+ if (char === "'") {
15990
+ const end = pattern.indexOf("'", index + 1);
15991
+ if (end < 0) {
15992
+ throw new DateFormatError("has an unclosed quote \u2014 literal text is written between two single quotes");
15993
+ }
15994
+ tokens.push({ literal: end === index + 1 ? "'" : pattern.slice(index + 1, end) });
15995
+ index = end + 1;
15996
+ continue;
15997
+ }
15998
+ if (!/[A-Za-z]/.test(char)) {
15999
+ tokens.push({ literal: char });
16000
+ index++;
16001
+ continue;
16002
+ }
16003
+ const run = /^([A-Za-z])\1*/.exec(pattern.slice(index))?.[0];
16004
+ const known = TOKENS.find((token) => run.startsWith(token) && token.length === run.length);
16005
+ if (!known) {
16006
+ const hint3 = LOOK_ALIKES[run] ? ` (did you mean \`${suggest(pattern, kind)}\`?)` : "";
16007
+ throw new DateFormatError(
16008
+ `uses \`${run}\`, which is not a supported token${hint3}. Supported: yyyy yy MM M dd d HH H hh h mm ss a, and literal text in single quotes`
16009
+ );
16010
+ }
16011
+ tokens.push({ token: known });
16012
+ index += run.length;
16013
+ }
16014
+ return tokens;
16015
+ }
16016
+ function suggest(pattern, kind) {
16017
+ let fixed = pattern;
16018
+ for (const [wrong, right] of Object.entries(LOOK_ALIKES)) {
16019
+ fixed = fixed.replace(new RegExp(`(?<![A-Za-z])${wrong}(?![A-Za-z])`, "g"), right);
16020
+ }
16021
+ if (kind === "date") {
16022
+ fixed = fixed.replace(/mm/g, "MM");
16023
+ }
16024
+ return fixed;
16025
+ }
16026
+ var parsedPatterns = /* @__PURE__ */ new Map();
16027
+ function compilePattern(pattern, kind) {
16028
+ const key = `${kind}|${pattern}`;
16029
+ const cached2 = parsedPatterns.get(key);
16030
+ if (cached2) {
16031
+ return cached2;
16032
+ }
16033
+ if (typeof pattern !== "string" || !pattern.trim()) {
16034
+ throw new DateFormatError("needs a pattern, e.g. `dd/MM/yyyy`");
16035
+ }
16036
+ const tokens = tokenize(pattern, kind);
16037
+ const names = tokens.flatMap((token) => "token" in token ? [token.token] : []);
16038
+ const parts = names.map((name) => SPEC[name].part);
16039
+ const has = (part) => parts.includes(part);
16040
+ const repeated = parts.find((part, index) => parts.indexOf(part) !== index);
16041
+ if (repeated) {
16042
+ throw new DateFormatError(`names the ${repeated === "meridiem" ? "AM/PM" : repeated} twice`);
16043
+ }
16044
+ if (kind === "date" && names.includes("mm") && !has("hour")) {
16045
+ throw new DateFormatError(`uses \`mm\`, which is minutes \u2014 did you mean \`${suggest(pattern, kind)}\`?`);
16046
+ }
16047
+ if (kind === "date" && parts.some((part) => TIME_PARTS.has(part))) {
16048
+ throw new DateFormatError("has a time of day, which a date has not \u2014 declare `z.iso.datetime({ local: true })`");
16049
+ }
16050
+ if (kind === "time" && parts.some((part) => DATE_PARTS.has(part))) {
16051
+ throw new DateFormatError("has a date, which a time has not \u2014 declare `z.iso.datetime({ local: true })`");
16052
+ }
16053
+ const missing = [
16054
+ ...kind !== "time" ? [["year", "yyyy"], ["month", "MM"], ["day", "dd"]] : [],
16055
+ ...kind !== "date" ? [["hour", "HH"], ["minute", "mm"]] : []
16056
+ ].filter(([part]) => !has(part)).map(([, token]) => `\`${token}\``);
16057
+ if (missing.length) {
16058
+ throw new DateFormatError(`is missing ${missing.join(", ")} \u2014 every part of a ${describeKind(kind)} must be in it`);
16059
+ }
16060
+ if ((names.includes("hh") || names.includes("h")) && !names.includes("a")) {
16061
+ throw new DateFormatError(
16062
+ "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"
16063
+ );
16064
+ }
16065
+ parsedPatterns.set(key, tokens);
16066
+ return tokens;
16067
+ }
16068
+ var describeKind = (kind) => kind === "date" ? "date" : kind === "time" ? "time" : "date and time";
16069
+ var pad = (value, width) => String(value).padStart(width, "0");
16070
+ function formatParts(parts, pattern, kind) {
16071
+ return compilePattern(pattern, kind).map((token) => {
16072
+ if ("literal" in token) {
16073
+ return token.literal;
16074
+ }
16075
+ const hour = parts.hour ?? 0;
16076
+ switch (token.token) {
16077
+ case "yyyy":
16078
+ return pad(parts.year ?? 0, 4);
16079
+ case "yy":
16080
+ return pad((parts.year ?? 0) % 100, 2);
16081
+ case "MM":
16082
+ return pad(parts.month ?? 0, 2);
16083
+ case "M":
16084
+ return String(parts.month ?? 0);
16085
+ case "dd":
16086
+ return pad(parts.day ?? 0, 2);
16087
+ case "d":
16088
+ return String(parts.day ?? 0);
16089
+ case "HH":
16090
+ return pad(hour, 2);
16091
+ case "H":
16092
+ return String(hour);
16093
+ case "hh":
16094
+ return pad(hour % 12 || 12, 2);
16095
+ case "h":
16096
+ return String(hour % 12 || 12);
16097
+ case "mm":
16098
+ return pad(parts.minute ?? 0, 2);
16099
+ case "ss":
16100
+ return pad(parts.second ?? 0, 2);
16101
+ case "a":
16102
+ return hour < 12 ? "AM" : "PM";
16103
+ }
16104
+ }).join("");
16105
+ }
16106
+ var escapeRegex = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16107
+ function parseInPattern(text2, pattern, kind) {
16108
+ const tokens = compilePattern(pattern, kind);
16109
+ const order = [];
16110
+ const source = tokens.map((token) => {
16111
+ if ("literal" in token) {
16112
+ return escapeRegex(token.literal);
16113
+ }
16114
+ order.push(token.token);
16115
+ if (token.token === "a") {
16116
+ return "(AM|PM)";
16117
+ }
16118
+ const { width } = SPEC[token.token];
16119
+ return width ? `(\\d{${width}})` : "(\\d{1,2})";
16120
+ }).join("");
16121
+ const match = new RegExp(`^${source}$`).exec(text2);
16122
+ if (!match) {
16123
+ return void 0;
16124
+ }
16125
+ const parts = {};
16126
+ let meridiem;
16127
+ order.forEach((name, index) => {
16128
+ const raw = match[index + 1];
16129
+ if (name === "a") {
16130
+ meridiem = raw;
16131
+ return;
16132
+ }
16133
+ const value = Number(raw);
16134
+ switch (name) {
16135
+ // date-fns' two-digit year rule against its reference year 2000: 00–49 → 20xx, 50–99 → 19xx.
16136
+ case "yy":
16137
+ parts.year = value < 50 ? 2e3 + value : 1900 + value;
16138
+ break;
16139
+ case "hh":
16140
+ case "h":
16141
+ parts.hour = value;
16142
+ break;
16143
+ default:
16144
+ parts[SPEC[name].part] = value;
16145
+ }
16146
+ });
16147
+ if (meridiem) {
16148
+ if (parts.hour === void 0 || parts.hour < 1 || parts.hour > 12) {
16149
+ return void 0;
16150
+ }
16151
+ parts.hour = parts.hour % 12 + (meridiem === "PM" ? 12 : 0);
16152
+ }
16153
+ const complete = completeParts(parts, kind);
16154
+ return complete && formatParts(complete, pattern, kind) === text2 ? complete : void 0;
16155
+ }
16156
+ function completeParts(parts, kind) {
16157
+ const { year, month, day, hour, minute, second } = parts;
16158
+ if (kind !== "time" && !isRealDate(year, month, day)) {
16159
+ return void 0;
16160
+ }
16161
+ if (kind !== "date" && !isRealTime(hour, minute, second)) {
16162
+ return void 0;
16163
+ }
16164
+ return kind === "date" ? { year, month, day } : kind === "time" ? { hour, minute, ...second !== void 0 ? { second } : {} } : { year, month, day, hour, minute, ...second !== void 0 ? { second } : {} };
16165
+ }
16166
+ function isRealDate(year, month, day) {
16167
+ if (year === void 0 || month === void 0 || day === void 0 || month < 1 || month > 12 || day < 1) {
16168
+ return false;
16169
+ }
16170
+ const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
16171
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
16172
+ return day <= days;
16173
+ }
16174
+ 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);
16175
+ var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
16176
+ var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
16177
+ var ISO_TIME = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
16178
+ function parseIso(text2, kind) {
16179
+ const dateTime = ISO_DATE_TIME.exec(text2);
16180
+ if (dateTime) {
16181
+ const [, year, month, day, hour, minute, second] = dateTime.map(Number);
16182
+ return completeParts({ year, month, day, hour, minute, ...dateTime[6] ? { second } : {} }, kind);
16183
+ }
16184
+ const date = ISO_DATE.exec(text2);
16185
+ if (date) {
16186
+ return kind === "date" ? completeParts({ year: +date[1], month: +date[2], day: +date[3] }, kind) : void 0;
16187
+ }
16188
+ const time = ISO_TIME.exec(text2);
16189
+ if (time && kind === "time") {
16190
+ return completeParts({ hour: +time[1], minute: +time[2], ...time[3] ? { second: +time[3] } : {} }, kind);
16191
+ }
16192
+ return void 0;
16193
+ }
16194
+ function toCanonical(parts, kind) {
16195
+ const seconds = parts.second !== void 0 ? `:${pad(parts.second, 2)}` : "";
16196
+ const date = `${pad(parts.year ?? 0, 4)}-${pad(parts.month ?? 0, 2)}-${pad(parts.day ?? 0, 2)}`;
16197
+ const time = `${pad(parts.hour ?? 0, 2)}:${pad(parts.minute ?? 0, 2)}${seconds}`;
16198
+ return kind === "date" ? date : kind === "time" ? time : `${date}T${time}`;
16199
+ }
16200
+ function canonicalToPattern(canonical, ins, kind) {
16201
+ const pattern = ins.meta.frDateFormat;
16202
+ if (!pattern) {
16203
+ return canonical;
16204
+ }
16205
+ const parts = parseIso(canonical, kind);
16206
+ return parts ? formatParts(parts, pattern, kind) : canonical;
16207
+ }
16208
+ var isTimestamp = (value) => typeof value === "number" && Number.isFinite(value) || typeof value === "string" && /^-?\d+(\.\d+)?$/.test(value.trim());
16209
+ function timestampParts(value, kind) {
16210
+ const date = new Date(Number(value));
16211
+ if (Number.isNaN(date.getTime())) {
16212
+ return void 0;
16213
+ }
16214
+ const second = date.getSeconds();
16215
+ return completeParts({
16216
+ year: date.getFullYear(),
16217
+ month: date.getMonth() + 1,
16218
+ day: date.getDate(),
16219
+ hour: date.getHours(),
16220
+ minute: date.getMinutes(),
16221
+ ...second ? { second } : {}
16222
+ }, kind);
16223
+ }
16224
+ function toDateString(value, ins, kind) {
16225
+ if (typeof value === "string") {
16226
+ const text2 = value.trim();
16227
+ const pattern = ins.meta.frDateFormat;
16228
+ const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? parseIso(text2, kind);
16229
+ if (parts) {
16230
+ return { canonical: toCanonical(parts, kind) };
16231
+ }
16232
+ }
16233
+ if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value)) {
16234
+ const parts = timestampParts(value, kind);
16235
+ return parts ? { canonical: toCanonical(parts, kind), fromTimestamp: true } : {};
16236
+ }
16237
+ return {};
16238
+ }
16239
+ var EXAMPLE = { year: 2024, month: 1, day: 31, hour: 13, minute: 45, second: 30 };
16240
+ function expectedDateString(ins, kind) {
16241
+ const pattern = patternOf(ins, kind);
16242
+ const shown = ins.meta.frDateFormat ? pattern : pattern.replace(/'T'/, "T");
16243
+ const example = formatParts(EXAMPLE, pattern, kind);
16244
+ return `${kind === "date" ? "a date" : kind === "time" ? "a time" : "a date and time"} in ${shown}, e.g. ${example}`;
16245
+ }
16246
+ function hasDateFormat(schema, seen = /* @__PURE__ */ new Set()) {
16247
+ if (!schema || seen.has(schema)) {
16248
+ return false;
16249
+ }
16250
+ seen.add(schema);
16251
+ const ins = inspect(schema);
16252
+ if (ins.meta.frDateFormat && dateStringKind(ins)) {
16253
+ return true;
16254
+ }
16255
+ const def = ins.core?._zod?.def ?? {};
16256
+ const children = [
16257
+ ...shapeEntries(ins.core).map(([, child]) => child),
16258
+ ...def.element ? [def.element] : [],
16259
+ ...def.valueType ? [def.valueType] : [],
16260
+ ...ins.branches ?? []
16261
+ ];
16262
+ return children.some((child) => hasDateFormat(child, seen));
16263
+ }
16264
+
16265
+ // ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
16266
+ var DictionaryScope = class _DictionaryScope {
16267
+ constructor(top, visible) {
16268
+ this.top = top;
16269
+ this.visible = visible;
16270
+ }
16271
+ static {
16272
+ this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
16273
+ }
16274
+ enter(names) {
16275
+ if (!this.top) {
16276
+ const top = new Set(names);
16277
+ return new _DictionaryScope(top, top);
16278
+ }
16279
+ return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
16280
+ }
16281
+ };
16282
+ function resolveDependsOn(binding, scope2) {
16283
+ const aliases = binding.criteriaAliases ?? {};
16284
+ let clash;
16285
+ const dependsOn = binding.dependsOn.map((key) => {
16286
+ const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
16287
+ if (visible.length > 1 && !clash) {
16288
+ clash = { key, names: visible };
16289
+ }
16290
+ return visible[0] ?? key;
16291
+ });
16292
+ return clash ? { dependsOn, clash } : { dependsOn };
16293
+ }
16294
+ function publishedBinding(binding, scope2) {
16295
+ return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
16296
+ }
16297
+
15963
16298
  // ../../flow-extension-runner/src/v2/params/schema/assert-supported-schema.ts
15964
16299
  var GUARDED_KINDS = /* @__PURE__ */ new Set(["action", "dictionary", "polling trigger", "realtime trigger", "extension"]);
15965
16300
  var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
@@ -16089,6 +16424,48 @@ function assertDictionaryBinding(schema, source, path23, scope2) {
16089
16424
  );
16090
16425
  }
16091
16426
  }
16427
+ function assertDateString(schema, source, path23) {
16428
+ const ins = inspect(schema);
16429
+ const pattern = ins.meta.frDateFormat;
16430
+ const kind = dateStringKind(ins);
16431
+ if (pattern !== void 0 && !kind) {
16432
+ const format = ins.core?._zod?.def?.format;
16433
+ const zoned = ins.coreType === "string" && format === "datetime";
16434
+ refuse(
16435
+ `${subjectOf(source, path23)} 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.`,
16436
+ source,
16437
+ path23,
16438
+ zoned ? "datetime" : ins.resolvedType ?? "unknown"
16439
+ );
16440
+ }
16441
+ if (!kind) {
16442
+ return;
16443
+ }
16444
+ if (pattern !== void 0) {
16445
+ try {
16446
+ compilePattern(pattern, kind);
16447
+ } catch (error) {
16448
+ if (error instanceof DateFormatError) {
16449
+ refuse(`${subjectOf(source, path23)}: \`.dateFormat('${pattern}')\` ${error.message}.`, source, path23, pattern);
16450
+ }
16451
+ throw error;
16452
+ }
16453
+ }
16454
+ const fallback = ins.defaultValue;
16455
+ if (fallback === void 0 || fallback === null) {
16456
+ return;
16457
+ }
16458
+ const written = patternOf(ins, kind);
16459
+ const fits = typeof fallback === "string" && (pattern !== void 0 ? !!parseInPattern(fallback, pattern, kind) : ((parts) => !!parts && toCanonical(parts, kind) === fallback)(parseIso(fallback, kind)));
16460
+ if (!fits) {
16461
+ refuse(
16462
+ `${subjectOf(source, path23)} 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.`,
16463
+ source,
16464
+ path23,
16465
+ String(fallback)
16466
+ );
16467
+ }
16468
+ }
16092
16469
  function assertField(schema, source, path23, seen, scope2, topLevel = false) {
16093
16470
  if (!schema || seen.has(schema)) {
16094
16471
  return;
@@ -16107,6 +16484,7 @@ function assertField(schema, source, path23, seen, scope2, topLevel = false) {
16107
16484
  refuseCatch(source, path23);
16108
16485
  }
16109
16486
  assertDictionaryBinding(schema, source, path23, scope2);
16487
+ assertDateString(schema, source, path23);
16110
16488
  if (!ins.resolvedType || !SUPPORTED_TYPES.has(ins.resolvedType)) {
16111
16489
  refuseType(source, path23, ins.resolvedType);
16112
16490
  }
@@ -16296,7 +16674,6 @@ function declaredAbsence(schema) {
16296
16674
  function coerces(schema) {
16297
16675
  return inspect(schema).core?._zod?.def?.coerce === true;
16298
16676
  }
16299
- var parsesJson = (schema) => !!inspect(schema).meta.frJson;
16300
16677
  var OPEN_TYPES = /* @__PURE__ */ new Set(["unknown", "any"]);
16301
16678
  var isOpenType = (schema) => OPEN_TYPES.has(inspect(schema).coreType);
16302
16679
  function requiredOpenType(schema) {
@@ -16318,7 +16695,7 @@ function requiredOpenType(schema) {
16318
16695
  return false;
16319
16696
  }
16320
16697
  function probeAbsence(schema) {
16321
- if (coerces(schema) || parsesJson(schema)) {
16698
+ if (coerces(schema)) {
16322
16699
  return declaredAbsence(schema);
16323
16700
  }
16324
16701
  if (requiredOpenType(schema)) {
@@ -16345,7 +16722,7 @@ function absenceOf(schema) {
16345
16722
  if (cached2) {
16346
16723
  return cached2;
16347
16724
  }
16348
- const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) && !parsesJson(schema) };
16725
+ const probed = { ...probeAbsence(schema), blankIsValue: isOpenType(schema) };
16349
16726
  probeCache.set(schema, probed);
16350
16727
  return probed;
16351
16728
  }
@@ -16363,10 +16740,39 @@ function planField(name, schema) {
16363
16740
  keepsEmpty,
16364
16741
  blankIsValue,
16365
16742
  passThroughDate: passesDateThrough(ins),
16366
- restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
16743
+ restoresDates: hasPassThroughDate(schema, inspect, shapeEntries),
16744
+ dateString: dateStringKind(ins),
16745
+ formatsDates: hasDateFormat(schema)
16367
16746
  };
16368
16747
  }
16369
16748
 
16749
+ // ../../flow-extension-runner/src/v2/params/schema/notices.ts
16750
+ var sink;
16751
+ var currentField;
16752
+ function collectNotices(fn) {
16753
+ const outer = sink;
16754
+ const notices = [];
16755
+ sink = notices;
16756
+ try {
16757
+ return { result: fn(), notices };
16758
+ } finally {
16759
+ sink = outer;
16760
+ outer?.push(...notices);
16761
+ }
16762
+ }
16763
+ function withinField(field, fn) {
16764
+ const outer = currentField;
16765
+ currentField = field;
16766
+ try {
16767
+ return fn();
16768
+ } finally {
16769
+ currentField = outer;
16770
+ }
16771
+ }
16772
+ function notice(entry) {
16773
+ sink?.push({ field: currentField, ...entry });
16774
+ }
16775
+
16370
16776
  // ../../flow-extension-runner/src/v2/params/schema/coerce.ts
16371
16777
  var ok = (value) => ({ ok: true, value });
16372
16778
  var fail2 = (expected) => ({ ok: false, expected });
@@ -16441,16 +16847,6 @@ function toBooleanValue(value) {
16441
16847
  const lowered = value.trim().toLowerCase();
16442
16848
  return TRUE.has(lowered) ? ok(true) : FALSE.has(lowered) ? ok(false) : fail2("boolean");
16443
16849
  }
16444
- function toJsonValue(value) {
16445
- if (typeof value !== "string") {
16446
- return ok(value);
16447
- }
16448
- try {
16449
- return ok(JSON.parse(value));
16450
- } catch {
16451
- return fail2("json");
16452
- }
16453
- }
16454
16850
  function coerceValue(value, coreType) {
16455
16851
  if (coreType === "string") {
16456
16852
  return toStringValue(value);
@@ -16548,8 +16944,20 @@ function coerceLeaf(value, ins) {
16548
16944
  if (ins.branches) {
16549
16945
  return ok(coerceUnion(value, ins.branches));
16550
16946
  }
16551
- if (ins.meta.frJson) {
16552
- return toJsonValue(value);
16947
+ const kind = dateStringKind(ins);
16948
+ if (kind) {
16949
+ const { canonical, fromTimestamp } = toDateString(value, ins, kind);
16950
+ if (canonical === void 0) {
16951
+ return fail2(expectedDateString(ins, kind));
16952
+ }
16953
+ if (fromTimestamp) {
16954
+ notice({
16955
+ message: "a timestamp was converted to a date string in the server time zone (FR-3920 lenient period)",
16956
+ value,
16957
+ converted: canonical
16958
+ });
16959
+ }
16960
+ return ok(canonical);
16553
16961
  }
16554
16962
  const format = formatOf(ins);
16555
16963
  if (ins.coreType === "string" && isConvertibleIso(format)) {
@@ -16584,7 +16992,7 @@ function isBlank(value, ins, schema) {
16584
16992
  if (absenceOf(schema).blankIsValue) {
16585
16993
  return absenceOf(schema).absorbsBlank;
16586
16994
  }
16587
- return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
16995
+ return ins.coreType !== "string" || !!dateStringKind(ins) || absenceOf(schema).absorbsBlank;
16588
16996
  }
16589
16997
  function absentAs(schema, value) {
16590
16998
  const { absence } = absenceOf(schema);
@@ -16645,9 +17053,7 @@ var EXPECTED = {
16645
17053
  object: "an object",
16646
17054
  array: "an array",
16647
17055
  // zod's own token for `z.record()`, which the author declared as a map — to a person it is an object.
16648
- record: "an object",
16649
- // `z.json()`. Not a zod token — ./coerce.ts raises it when the submitted text will not parse.
16650
- json: "valid JSON"
17056
+ record: "an object"
16651
17057
  };
16652
17058
  var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
16653
17059
  var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
@@ -16674,7 +17080,7 @@ function resolveTarget(plan2, segments, fieldValue) {
16674
17080
  schema = nested[1];
16675
17081
  label = labelOf(segment, schema);
16676
17082
  }
16677
- return { label, value, found };
17083
+ return { label, value, found, schema: found ? schema : void 0 };
16678
17084
  }
16679
17085
  function bound(value, plan2) {
16680
17086
  if (plan2.coreType !== "date" || typeof value !== "number") {
@@ -16696,6 +17102,11 @@ function toFieldIssue(plan2, issue, fieldValue) {
16696
17102
  if (isAuthored(issue)) {
16697
17103
  return { path: path23, code, message: issue.message };
16698
17104
  }
17105
+ const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
17106
+ const dateMissing = target.value == null || target.value === "";
17107
+ if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
17108
+ return dateMissing ? { path: path23, code, message: requiredMessage(named) } : { path: path23, code, message: invalidTypeMessage(named, expectedDateString(inspect(target.schema), dateKind)) };
17109
+ }
16699
17110
  if (code === "invalid_type") {
16700
17111
  const received = issue.received;
16701
17112
  const absent = segments.length ? target.found && target.value == null : received === "undefined" || received === "null" || issue.expected === void 0;
@@ -16740,7 +17151,7 @@ function isAbsent(value, plan2) {
16740
17151
  if (plan2.blankIsValue) {
16741
17152
  return plan2.absorbsBlank;
16742
17153
  }
16743
- return plan2.coreType !== "string" || plan2.absorbsBlank;
17154
+ return plan2.coreType !== "string" || !!plan2.dateString || plan2.absorbsBlank;
16744
17155
  }
16745
17156
  function normalizeAbsence(value, plan2) {
16746
17157
  if (plan2.absence === "required") {
@@ -16779,7 +17190,7 @@ function normalizeField(value, plan2) {
16779
17190
  return restore(validate(coerced.value, plan2), value, plan2);
16780
17191
  }
16781
17192
  function restore(result, original, plan2) {
16782
- if (!plan2.restoresDates || !result.present || result.issues.length) {
17193
+ if (!(plan2.restoresDates || plan2.formatsDates) || !result.present || result.issues.length) {
16783
17194
  return result;
16784
17195
  }
16785
17196
  if (plan2.passThroughDate) {
@@ -16799,6 +17210,10 @@ function restoreDeep(output, original, schema) {
16799
17210
  const branch = ins.branches.find((option) => accepts(option, output));
16800
17211
  return branch ? restoreDeep(output, original, branch) : output;
16801
17212
  }
17213
+ const kind = dateStringKind(ins);
17214
+ if (kind) {
17215
+ return typeof output === "string" && original !== "" ? canonicalToPattern(output, ins, kind) : output;
17216
+ }
16802
17217
  const element = ins.core?._zod?.def?.element;
16803
17218
  if (ins.coreType === "array" && element && Array.isArray(output) && Array.isArray(original)) {
16804
17219
  return output.map((item, index) => restoreDeep(item, original[index], element));
@@ -16888,7 +17303,7 @@ var Params = class {
16888
17303
  const values = {};
16889
17304
  const issues = [];
16890
17305
  for (const plan2 of this.plans()) {
16891
- const result = normalizeField(source[plan2.name], plan2);
17306
+ const result = withinField(plan2.name, () => normalizeField(source[plan2.name], plan2));
16892
17307
  if (result.issues.length) {
16893
17308
  issues.push(...result.issues);
16894
17309
  } else if (result.present) {
@@ -17043,6 +17458,9 @@ function extendPrototype() {
17043
17458
  }
17044
17459
  return this.meta({ frDictionary: binding });
17045
17460
  };
17461
+ proto.dateFormat = function dateFormat(pattern) {
17462
+ return this.meta({ frDateFormat: pattern });
17463
+ };
17046
17464
  proto.labels = function labels(byValue) {
17047
17465
  return this.meta({ frLabels: byValue });
17048
17466
  };
@@ -17065,10 +17483,9 @@ function text() {
17065
17483
  return import_zod3.z.string().meta({ frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT });
17066
17484
  }
17067
17485
  function json() {
17068
- return import_zod3.z.unknown().nonoptional().meta({
17069
- frWidget: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT,
17070
- frJson: true
17071
- });
17486
+ throw new Error(
17487
+ "`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."
17488
+ );
17072
17489
  }
17073
17490
  var namespace = Object.create(import_zod3.z);
17074
17491
  Object.defineProperties(namespace, {
@@ -17082,7 +17499,7 @@ Object.defineProperties(namespace, {
17082
17499
  var z2 = namespace;
17083
17500
 
17084
17501
  // ../../flow-extension-runner/src/v2/params/json/values.ts
17085
- function toJsonValue2(value) {
17502
+ function toJsonValue(value) {
17086
17503
  if (typeof value === "bigint") {
17087
17504
  return { $bigint: value.toString() };
17088
17505
  }
@@ -17090,10 +17507,10 @@ function toJsonValue2(value) {
17090
17507
  return { $date: value.toISOString() };
17091
17508
  }
17092
17509
  if (Array.isArray(value)) {
17093
- return value.map(toJsonValue2);
17510
+ return value.map(toJsonValue);
17094
17511
  }
17095
17512
  if (value && typeof value === "object") {
17096
- return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue2(inner)]));
17513
+ return Object.fromEntries(Object.entries(value).map(([key, inner]) => [key, toJsonValue(inner)]));
17097
17514
  }
17098
17515
  return value;
17099
17516
  }
@@ -17128,18 +17545,18 @@ function encodeCheck(check) {
17128
17545
  switch (def.check) {
17129
17546
  // strings and arrays
17130
17547
  case "min_length":
17131
- return at("min", toJsonValue2(def.minimum));
17548
+ return at("min", toJsonValue(def.minimum));
17132
17549
  case "max_length":
17133
- return at("max", toJsonValue2(def.maximum));
17550
+ return at("max", toJsonValue(def.maximum));
17134
17551
  case "length_equals":
17135
- return at("length", toJsonValue2(def.length));
17552
+ return at("length", toJsonValue(def.length));
17136
17553
  // numbers and bigints
17137
17554
  case "greater_than":
17138
- return at("min", toJsonValue2(def.value), def.inclusive ? void 0 : true);
17555
+ return at("min", toJsonValue(def.value), def.inclusive ? void 0 : true);
17139
17556
  case "less_than":
17140
- return at("max", toJsonValue2(def.value), def.inclusive ? void 0 : true);
17557
+ return at("max", toJsonValue(def.value), def.inclusive ? void 0 : true);
17141
17558
  case "multiple_of":
17142
- return at("multipleOf", toJsonValue2(def.value));
17559
+ return at("multipleOf", toJsonValue(def.value));
17143
17560
  case "number_format":
17144
17561
  return def.format === "safeint" || def.format === "int32" ? at("int") : void 0;
17145
17562
  // the string sub-formats that are checks rather than types
@@ -17300,7 +17717,7 @@ function encodeMeta(meta, field, scope2, loaderId) {
17300
17717
  if (hasFunction(source)) {
17301
17718
  throw new Error(`Cannot encode "${field}": its metadata holds a function, which has no wire form.`);
17302
17719
  }
17303
- const encoded = toJsonValue2(source);
17720
+ const encoded = toJsonValue(source);
17304
17721
  return Object.keys(encoded).length ? encoded : void 0;
17305
17722
  }
17306
17723
  function isLoose(core) {
@@ -17310,11 +17727,11 @@ function isLoose(core) {
17310
17727
  function encodeValues(core, type) {
17311
17728
  if (type === "enum") {
17312
17729
  const entries = core?._zod?.def?.entries ?? {};
17313
- return Object.values(entries).map(toJsonValue2);
17730
+ return Object.values(entries).map(toJsonValue);
17314
17731
  }
17315
17732
  if (type === "literal") {
17316
17733
  const values = core?._zod?.def?.values ?? [];
17317
- return values.map(toJsonValue2);
17734
+ return values.map(toJsonValue);
17318
17735
  }
17319
17736
  return void 0;
17320
17737
  }
@@ -17342,9 +17759,10 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
17342
17759
  name,
17343
17760
  type,
17344
17761
  ...format ? { format } : {},
17762
+ ...format === "datetime" && core?._zod?.def?.local ? { local: true } : {},
17345
17763
  ...optional ? { optional: true } : {},
17346
17764
  ...nullable ? { nullable: true } : {},
17347
- ...hasDefault ? { default: toJsonValue2(defaultValue) } : {},
17765
+ ...hasDefault ? { default: toJsonValue(defaultValue) } : {},
17348
17766
  ...checks.length ? { checks } : {},
17349
17767
  ...values?.length ? { values } : {},
17350
17768
  ...meta ? { meta } : {},
@@ -17869,6 +18287,9 @@ var ExecutionContext = class _ExecutionContext {
17869
18287
  get logger() {
17870
18288
  return this.#options.logger ?? defaultLogger;
17871
18289
  }
18290
+ get invocation() {
18291
+ return this.#options.invocation ?? {};
18292
+ }
17872
18293
  get config() {
17873
18294
  this.#config ??= this.#extension.config.resolve(this.#options.configs);
17874
18295
  return this.#config;
@@ -18021,6 +18442,10 @@ var DictionaryMethod = class extends ExtensionMethod {
18021
18442
  return this.criteria.keys();
18022
18443
  }
18023
18444
  // ── runtime ────────────────────────────────────────────────────────────────
18445
+ // `search` is always text, trimmed (FR-3910): `''` when the author typed nothing — the console then sends no
18446
+ // `search` at all — or only spaces. So a handler never guards it: `search ? { q: search } : undefined`, and
18447
+ // `search.toLowerCase()` as is. Surrounding spaces never mean anything to a lookup.
18448
+ //
18024
18449
  // Two-stage: the `{ search, cursor, criteria }` envelope the runtime owns, then the author-declared
18025
18450
  // criteria through the shared pipeline — reported as a criteria failure so the console can point at the
18026
18451
  // dependent fields rather than the whole call.
@@ -18029,7 +18454,7 @@ var DictionaryMethod = class extends ExtensionMethod {
18029
18454
  const payload = input.parseField("payload", DictionaryPayloadSchema);
18030
18455
  const criteria = this.criteria.normalize(this.#resolveAliases(payload.criteria), input.invalidCriteria());
18031
18456
  return {
18032
- search: payload.search,
18457
+ search: payload.search?.trim() ?? "",
18033
18458
  cursor: payload.cursor,
18034
18459
  criteria
18035
18460
  };
@@ -19380,7 +19805,23 @@ var Extension = class {
19380
19805
  // generated loader, SYSTEM seam — arrives here through the same three steps.
19381
19806
  async run(methodName, methodData, ctx) {
19382
19807
  const method = this.getMethod(methodName);
19383
- return method.execute(method.validate(methodData ?? {}), ctx);
19808
+ const { result: input, notices } = collectNotices(() => method.validate(methodData ?? {}));
19809
+ this.#reportNotices(notices, methodName, ctx);
19810
+ return method.execute(input, ctx);
19811
+ }
19812
+ // One warning per value the pipeline accepted only under a temporary rule — today a timestamp converted for
19813
+ // a date-string field (FR-3920 lenient period). Named well enough to find the flow still holding one.
19814
+ #reportNotices(notices, methodName, ctx) {
19815
+ for (const { message, field, value, converted } of notices) {
19816
+ ctx.logger.warn(`[flow-extension:${this.id}] ${methodName}: param "${field ?? "?"}": ${message}`, {
19817
+ serviceId: this.id,
19818
+ method: methodName,
19819
+ param: field,
19820
+ value,
19821
+ converted,
19822
+ ...ctx.invocation
19823
+ });
19824
+ }
19384
19825
  }
19385
19826
  // ── output model ────────────────────────────────────────────────────────────
19386
19827
  toConfigItems() {