@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.
Files changed (28) hide show
  1. package/ai-docs/instructions/service-code-format/02-zod-types.md +115 -7
  2. package/ai-docs/instructions/service-code-format/11-output-model.md +3 -0
  3. package/ai-docs/instructions/service-code-format/16-gotchas.md +30 -6
  4. package/dist/cli.js +625 -48
  5. package/dist/cli.js.map +4 -4
  6. package/dist/index.js +624 -47
  7. package/dist/index.js.map +4 -4
  8. package/dist/types/flow-extension-runner/src/v2/context/execution-context.d.ts +8 -0
  9. package/dist/types/flow-extension-runner/src/v2/params/index.d.ts +2 -0
  10. package/dist/types/flow-extension-runner/src/v2/params/json/types.d.ts +2 -0
  11. package/dist/types/flow-extension-runner/src/v2/params/schema/date-format.d.ts +80 -0
  12. package/dist/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +3 -2
  13. package/dist/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +9 -2
  14. package/dist/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +8 -0
  15. package/dist/types/flow-extension-runner/src/v2/params/schema/notices.d.ts +15 -0
  16. package/dist/types/flow-extension-runner/src/v2/params/zod.d.ts +21 -0
  17. package/package.json +1 -1
  18. package/runtime/index.js +631 -48
  19. package/runtime/index.js.map +4 -4
  20. package/runtime/types/flow-extension-runner/src/v2/context/execution-context.d.ts +8 -0
  21. package/runtime/types/flow-extension-runner/src/v2/params/index.d.ts +2 -0
  22. package/runtime/types/flow-extension-runner/src/v2/params/json/types.d.ts +2 -0
  23. package/runtime/types/flow-extension-runner/src/v2/params/schema/date-format.d.ts +80 -0
  24. package/runtime/types/flow-extension-runner/src/v2/params/schema/defaults.d.ts +3 -2
  25. package/runtime/types/flow-extension-runner/src/v2/params/schema/field-plan.d.ts +9 -2
  26. package/runtime/types/flow-extension-runner/src/v2/params/schema/introspect.d.ts +8 -0
  27. package/runtime/types/flow-extension-runner/src/v2/params/schema/notices.d.ts +15 -0
  28. package/runtime/types/flow-extension-runner/src/v2/params/zod.d.ts +21 -0
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.18",
14511
+ version: "0.1.19",
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",
@@ -15902,6 +15871,12 @@ function literalType(core) {
15902
15871
  const [kind] = [...kinds];
15903
15872
  return kinds.size === 1 && LITERAL_KINDS.has(kind) ? kind : void 0;
15904
15873
  }
15874
+ function hasBlankBranch(ins) {
15875
+ return !!ins.branches?.some((branch) => {
15876
+ const { core, coreType } = inspect(branch);
15877
+ return coreType === "literal" && (core._zod?.def?.values ?? []).includes("");
15878
+ });
15879
+ }
15905
15880
  function deriveWidget(ins) {
15906
15881
  const { coreType, core, meta } = ins;
15907
15882
  switch (coreType) {
@@ -15909,7 +15884,7 @@ function deriveWidget(ins) {
15909
15884
  if (meta.frWidget === FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT) {
15910
15885
  return { paramType: "STRING", uiComponent: { type: FlowExtensionParamWidgetTypes.MULTI_LINE_TEXT } };
15911
15886
  }
15912
- return { paramType: "STRING" };
15887
+ return dateStringWidget(ins) ?? { paramType: "STRING" };
15913
15888
  case "number":
15914
15889
  case "bigint":
15915
15890
  return { paramType: "NUMBER", uiComponent: { type: FlowExtensionParamWidgetTypes.NUMERIC_STEPPER } };
@@ -15952,11 +15927,399 @@ function deriveWidget(ins) {
15952
15927
  return { paramType: "STRING" };
15953
15928
  }
15954
15929
  }
15930
+ var DATE_STRING_WIDGETS = {
15931
+ date: FlowExtensionParamWidgetTypes.DATE_PICKER,
15932
+ datetime: FlowExtensionParamWidgetTypes.DATE_TIME_PICKER,
15933
+ time: FlowExtensionParamWidgetTypes.TIME_PICKER
15934
+ };
15935
+ function dateStringWidget(ins) {
15936
+ const kind = dateStringKind(ins);
15937
+ return kind ? { paramType: "STRING", uiComponent: { type: DATE_STRING_WIDGETS[kind], valueKind: "string", format: patternOf(ins, kind) } } : void 0;
15938
+ }
15955
15939
  function shapeEntries(schema) {
15956
15940
  const shape = schema?.shape;
15957
15941
  return shape && typeof shape === "object" ? Object.entries(shape) : [];
15958
15942
  }
15959
15943
 
15944
+ // ../../flow-extension-runner/src/v2/params/schema/date-format.ts
15945
+ var ISO_PATTERNS = {
15946
+ date: "yyyy-MM-dd",
15947
+ datetime: "yyyy-MM-dd'T'HH:mm",
15948
+ time: "HH:mm"
15949
+ };
15950
+ var DATE_STRINGS_ACCEPT_TIMESTAMPS = true;
15951
+ function dateStringKind(ins) {
15952
+ if (ins.coreType !== "string") {
15953
+ return void 0;
15954
+ }
15955
+ const def = ins.core?._zod?.def;
15956
+ if (def?.format === "date" || def?.format === "time") {
15957
+ return def.format;
15958
+ }
15959
+ return def?.format === "datetime" && def.local ? "datetime" : void 0;
15960
+ }
15961
+ var patternOf = (ins, kind) => ins.meta.frDateFormat ?? ISO_PATTERNS[kind];
15962
+ var TOKENS = ["yyyy", "yy", "MM", "M", "dd", "d", "HH", "H", "hh", "h", "mm", "ss", "a"];
15963
+ var SPEC = {
15964
+ yyyy: { part: "year", width: 4 },
15965
+ yy: { part: "year", width: 2 },
15966
+ MM: { part: "month", width: 2 },
15967
+ M: { part: "month" },
15968
+ dd: { part: "day", width: 2 },
15969
+ d: { part: "day" },
15970
+ HH: { part: "hour", width: 2 },
15971
+ H: { part: "hour" },
15972
+ hh: { part: "hour", width: 2 },
15973
+ h: { part: "hour" },
15974
+ mm: { part: "minute", width: 2 },
15975
+ ss: { part: "second", width: 2 },
15976
+ a: { part: "meridiem" }
15977
+ };
15978
+ var DATE_PARTS = /* @__PURE__ */ new Set(["year", "month", "day"]);
15979
+ var TIME_PARTS = /* @__PURE__ */ new Set(["hour", "minute", "second", "meridiem"]);
15980
+ var DateFormatError = class extends Error {
15981
+ };
15982
+ var LOOK_ALIKES = {
15983
+ YYYY: "yyyy",
15984
+ YY: "yy",
15985
+ DD: "dd",
15986
+ D: "d",
15987
+ S: "ss",
15988
+ A: "a"
15989
+ };
15990
+ function tokenize(pattern, kind) {
15991
+ const tokens = [];
15992
+ let index = 0;
15993
+ while (index < pattern.length) {
15994
+ const char = pattern[index];
15995
+ if (char === "'") {
15996
+ const end = pattern.indexOf("'", index + 1);
15997
+ if (end < 0) {
15998
+ throw new DateFormatError("has an unclosed quote \u2014 literal text is written between two single quotes");
15999
+ }
16000
+ tokens.push({ literal: end === index + 1 ? "'" : pattern.slice(index + 1, end) });
16001
+ index = end + 1;
16002
+ continue;
16003
+ }
16004
+ if (!/[A-Za-z]/.test(char)) {
16005
+ tokens.push({ literal: char });
16006
+ index++;
16007
+ continue;
16008
+ }
16009
+ const run = /^([A-Za-z])\1*/.exec(pattern.slice(index))?.[0];
16010
+ const known = TOKENS.find((token) => run.startsWith(token) && token.length === run.length);
16011
+ if (!known) {
16012
+ const hint3 = LOOK_ALIKES[run] ? ` (did you mean \`${suggest(pattern, kind)}\`?)` : "";
16013
+ throw new DateFormatError(
16014
+ `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`
16015
+ );
16016
+ }
16017
+ tokens.push({ token: known });
16018
+ index += run.length;
16019
+ }
16020
+ return tokens;
16021
+ }
16022
+ function suggest(pattern, kind) {
16023
+ let fixed = pattern;
16024
+ for (const [wrong, right] of Object.entries(LOOK_ALIKES)) {
16025
+ fixed = fixed.replace(new RegExp(`(?<![A-Za-z])${wrong}(?![A-Za-z])`, "g"), right);
16026
+ }
16027
+ if (kind === "date") {
16028
+ fixed = fixed.replace(/mm/g, "MM");
16029
+ }
16030
+ return fixed;
16031
+ }
16032
+ var parsedPatterns = /* @__PURE__ */ new Map();
16033
+ function compilePattern(pattern, kind) {
16034
+ const key = `${kind}|${pattern}`;
16035
+ const cached2 = parsedPatterns.get(key);
16036
+ if (cached2) {
16037
+ return cached2;
16038
+ }
16039
+ if (typeof pattern !== "string" || !pattern.trim()) {
16040
+ throw new DateFormatError("needs a pattern, e.g. `dd/MM/yyyy`");
16041
+ }
16042
+ const tokens = tokenize(pattern, kind);
16043
+ const names = tokens.flatMap((token) => "token" in token ? [token.token] : []);
16044
+ const parts = names.map((name) => SPEC[name].part);
16045
+ const has = (part) => parts.includes(part);
16046
+ const repeated = parts.find((part, index) => parts.indexOf(part) !== index);
16047
+ if (repeated) {
16048
+ throw new DateFormatError(`names the ${repeated === "meridiem" ? "AM/PM" : repeated} twice`);
16049
+ }
16050
+ if (kind === "date" && names.includes("mm") && !has("hour")) {
16051
+ throw new DateFormatError(`uses \`mm\`, which is minutes \u2014 did you mean \`${suggest(pattern, kind)}\`?`);
16052
+ }
16053
+ if (kind === "date" && parts.some((part) => TIME_PARTS.has(part))) {
16054
+ throw new DateFormatError("has a time of day, which a date has not \u2014 declare `z.iso.datetime({ local: true })`");
16055
+ }
16056
+ if (kind === "time" && parts.some((part) => DATE_PARTS.has(part))) {
16057
+ throw new DateFormatError("has a date, which a time has not \u2014 declare `z.iso.datetime({ local: true })`");
16058
+ }
16059
+ const missing = [
16060
+ ...kind !== "time" ? [["year", "yyyy"], ["month", "MM"], ["day", "dd"]] : [],
16061
+ ...kind !== "date" ? [["hour", "HH"], ["minute", "mm"]] : []
16062
+ ].filter(([part]) => !has(part)).map(([, token]) => `\`${token}\``);
16063
+ if (missing.length) {
16064
+ throw new DateFormatError(`is missing ${missing.join(", ")} \u2014 every part of a ${describeKind(kind)} must be in it`);
16065
+ }
16066
+ if ((names.includes("HH") || names.includes("H")) && names.includes("a")) {
16067
+ throw new DateFormatError(
16068
+ "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"
16069
+ );
16070
+ }
16071
+ if ((names.includes("hh") || names.includes("h")) && !names.includes("a")) {
16072
+ throw new DateFormatError(
16073
+ "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"
16074
+ );
16075
+ }
16076
+ parsedPatterns.set(key, tokens);
16077
+ return tokens;
16078
+ }
16079
+ var describeKind = (kind) => kind === "date" ? "date" : kind === "time" ? "time" : "date and time";
16080
+ var pad = (value, width) => String(value).padStart(width, "0");
16081
+ function formatParts(parts, pattern, kind) {
16082
+ return compilePattern(pattern, kind).map((token) => {
16083
+ if ("literal" in token) {
16084
+ return token.literal;
16085
+ }
16086
+ const hour = parts.hour ?? 0;
16087
+ switch (token.token) {
16088
+ case "yyyy":
16089
+ return pad(parts.year ?? 0, 4);
16090
+ case "yy":
16091
+ return pad((parts.year ?? 0) % 100, 2);
16092
+ case "MM":
16093
+ return pad(parts.month ?? 0, 2);
16094
+ case "M":
16095
+ return String(parts.month ?? 0);
16096
+ case "dd":
16097
+ return pad(parts.day ?? 0, 2);
16098
+ case "d":
16099
+ return String(parts.day ?? 0);
16100
+ case "HH":
16101
+ return pad(hour, 2);
16102
+ case "H":
16103
+ return String(hour);
16104
+ case "hh":
16105
+ return pad(hour % 12 || 12, 2);
16106
+ case "h":
16107
+ return String(hour % 12 || 12);
16108
+ case "mm":
16109
+ return pad(parts.minute ?? 0, 2);
16110
+ case "ss":
16111
+ return pad(parts.second ?? 0, 2);
16112
+ case "a":
16113
+ return hour < 12 ? "AM" : "PM";
16114
+ }
16115
+ }).join("");
16116
+ }
16117
+ var escapeRegex = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16118
+ function parseInPattern(text2, pattern, kind) {
16119
+ const tokens = compilePattern(pattern, kind);
16120
+ const order = [];
16121
+ const source = tokens.map((token) => {
16122
+ if ("literal" in token) {
16123
+ return escapeRegex(token.literal);
16124
+ }
16125
+ order.push(token.token);
16126
+ if (token.token === "a") {
16127
+ return "(AM|PM)";
16128
+ }
16129
+ const { width } = SPEC[token.token];
16130
+ return width ? `(\\d{${width}})` : "(\\d{1,2})";
16131
+ }).join("");
16132
+ const match = new RegExp(`^${source}$`).exec(text2);
16133
+ if (!match) {
16134
+ return void 0;
16135
+ }
16136
+ const parts = {};
16137
+ let meridiem;
16138
+ order.forEach((name, index) => {
16139
+ const raw = match[index + 1];
16140
+ if (name === "a") {
16141
+ meridiem = raw;
16142
+ return;
16143
+ }
16144
+ const value = Number(raw);
16145
+ switch (name) {
16146
+ // date-fns' two-digit year rule against its reference year 2000: 00–49 → 20xx, 50–99 → 19xx.
16147
+ case "yy":
16148
+ parts.year = value < 50 ? 2e3 + value : 1900 + value;
16149
+ break;
16150
+ case "hh":
16151
+ case "h":
16152
+ parts.hour = value;
16153
+ break;
16154
+ default:
16155
+ parts[SPEC[name].part] = value;
16156
+ }
16157
+ });
16158
+ if (meridiem) {
16159
+ if (parts.hour === void 0 || parts.hour < 1 || parts.hour > 12) {
16160
+ return void 0;
16161
+ }
16162
+ parts.hour = parts.hour % 12 + (meridiem === "PM" ? 12 : 0);
16163
+ }
16164
+ const complete = completeParts(parts, kind);
16165
+ return complete && formatParts(complete, pattern, kind) === text2 ? complete : void 0;
16166
+ }
16167
+ function completeParts(parts, kind) {
16168
+ const { year, month, day, hour, minute, second } = parts;
16169
+ if (kind !== "time" && !isRealDate(year, month, day)) {
16170
+ return void 0;
16171
+ }
16172
+ if (kind !== "date" && !isRealTime(hour, minute, second)) {
16173
+ return void 0;
16174
+ }
16175
+ return kind === "date" ? { year, month, day } : kind === "time" ? { hour, minute, ...second !== void 0 ? { second } : {} } : { year, month, day, hour, minute, ...second !== void 0 ? { second } : {} };
16176
+ }
16177
+ function isRealDate(year, month, day) {
16178
+ if (year === void 0 || month === void 0 || day === void 0 || month < 1 || month > 12 || day < 1) {
16179
+ return false;
16180
+ }
16181
+ const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
16182
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
16183
+ return day <= days;
16184
+ }
16185
+ 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);
16186
+ var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
16187
+ var ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
16188
+ var ISO_TIME = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(?:Z|[+-]\d{2}(?::?\d{2})?)?$/i;
16189
+ function parseIso(text2, kind) {
16190
+ const dateTime = ISO_DATE_TIME.exec(text2);
16191
+ if (dateTime) {
16192
+ const [, year, month, day, hour, minute, second] = dateTime.map(Number);
16193
+ return completeParts({ year, month, day, hour, minute, ...dateTime[6] ? { second } : {} }, kind);
16194
+ }
16195
+ const date = ISO_DATE.exec(text2);
16196
+ if (date) {
16197
+ return kind === "date" ? completeParts({ year: +date[1], month: +date[2], day: +date[3] }, kind) : void 0;
16198
+ }
16199
+ const time = ISO_TIME.exec(text2);
16200
+ if (time && kind === "time") {
16201
+ return completeParts({ hour: +time[1], minute: +time[2], ...time[3] ? { second: +time[3] } : {} }, kind);
16202
+ }
16203
+ return void 0;
16204
+ }
16205
+ function toCanonical(parts, kind) {
16206
+ const seconds = parts.second !== void 0 ? `:${pad(parts.second, 2)}` : "";
16207
+ const date = `${pad(parts.year ?? 0, 4)}-${pad(parts.month ?? 0, 2)}-${pad(parts.day ?? 0, 2)}`;
16208
+ const time = `${pad(parts.hour ?? 0, 2)}:${pad(parts.minute ?? 0, 2)}${seconds}`;
16209
+ return kind === "date" ? date : kind === "time" ? time : `${date}T${time}`;
16210
+ }
16211
+ function canonicalToPattern(canonical, ins, kind) {
16212
+ const pattern = ins.meta.frDateFormat;
16213
+ if (!pattern) {
16214
+ return canonical;
16215
+ }
16216
+ const parts = parseIso(canonical, kind);
16217
+ return parts ? formatParts(parts, pattern, kind) : canonical;
16218
+ }
16219
+ var MIN_TIMESTAMP_DIGITS = 13;
16220
+ function digitOnlyLength(pattern, kind) {
16221
+ const example = formatParts(EXAMPLE, pattern, kind);
16222
+ return /^\d+$/.test(example) ? example.length : void 0;
16223
+ }
16224
+ function isTimestamp(value, pattern, kind) {
16225
+ if (typeof value === "number") {
16226
+ return Number.isFinite(value);
16227
+ }
16228
+ if (typeof value !== "string") {
16229
+ return false;
16230
+ }
16231
+ const text2 = value.trim();
16232
+ return new RegExp(`^\\d{${MIN_TIMESTAMP_DIGITS},}$`).test(text2) && digitOnlyLength(pattern, kind) !== text2.length;
16233
+ }
16234
+ function timestampParts(value, kind) {
16235
+ const date = new Date(Number(value));
16236
+ if (Number.isNaN(date.getTime())) {
16237
+ return void 0;
16238
+ }
16239
+ const second = date.getSeconds();
16240
+ return completeParts({
16241
+ year: date.getFullYear(),
16242
+ month: date.getMonth() + 1,
16243
+ day: date.getDate(),
16244
+ hour: date.getHours(),
16245
+ minute: date.getMinutes(),
16246
+ ...second ? { second } : {}
16247
+ }, kind);
16248
+ }
16249
+ function toDateString(value, ins, kind) {
16250
+ const pattern = ins.meta.frDateFormat;
16251
+ const text2 = typeof value === "string" ? value.trim() : typeof value === "number" && Number.isInteger(value) && value >= 0 ? String(value) : void 0;
16252
+ if (text2 !== void 0) {
16253
+ const parts = (pattern ? parseInPattern(text2, pattern, kind) : void 0) ?? (typeof value === "string" ? parseIso(text2, kind) : void 0);
16254
+ if (parts) {
16255
+ return { canonical: toCanonical(parts, kind) };
16256
+ }
16257
+ }
16258
+ if (DATE_STRINGS_ACCEPT_TIMESTAMPS && isTimestamp(value, patternOf(ins, kind), kind)) {
16259
+ const parts = timestampParts(value, kind);
16260
+ return parts ? { canonical: toCanonical(parts, kind), fromTimestamp: true } : {};
16261
+ }
16262
+ return {};
16263
+ }
16264
+ var EXAMPLE = { year: 2024, month: 1, day: 31, hour: 13, minute: 45, second: 30 };
16265
+ function expectedDateString(ins, kind) {
16266
+ const pattern = patternOf(ins, kind);
16267
+ const shown = ins.meta.frDateFormat ? pattern : pattern.replace(/'T'/, "T");
16268
+ const example = formatParts(EXAMPLE, pattern, kind);
16269
+ return `${kind === "date" ? "a date" : kind === "time" ? "a time" : "a date and time"} in ${shown}, e.g. ${example}`;
16270
+ }
16271
+ function hasDateFormat(schema, seen = /* @__PURE__ */ new Set()) {
16272
+ if (!schema || seen.has(schema)) {
16273
+ return false;
16274
+ }
16275
+ seen.add(schema);
16276
+ const ins = inspect(schema);
16277
+ if (ins.meta.frDateFormat && dateStringKind(ins)) {
16278
+ return true;
16279
+ }
16280
+ const def = ins.core?._zod?.def ?? {};
16281
+ const children = [
16282
+ ...shapeEntries(ins.core).map(([, child]) => child),
16283
+ ...def.element ? [def.element] : [],
16284
+ ...def.valueType ? [def.valueType] : [],
16285
+ ...ins.branches ?? []
16286
+ ];
16287
+ return children.some((child) => hasDateFormat(child, seen));
16288
+ }
16289
+
16290
+ // ../../flow-extension-runner/src/v2/params/schema/dictionary-binding.ts
16291
+ var DictionaryScope = class _DictionaryScope {
16292
+ constructor(top, visible) {
16293
+ this.top = top;
16294
+ this.visible = visible;
16295
+ }
16296
+ static {
16297
+ this.ROOT = new _DictionaryScope(null, /* @__PURE__ */ new Set());
16298
+ }
16299
+ enter(names) {
16300
+ if (!this.top) {
16301
+ const top = new Set(names);
16302
+ return new _DictionaryScope(top, top);
16303
+ }
16304
+ return new _DictionaryScope(this.top, /* @__PURE__ */ new Set([...this.top, ...names]));
16305
+ }
16306
+ };
16307
+ function resolveDependsOn(binding, scope2) {
16308
+ const aliases = binding.criteriaAliases ?? {};
16309
+ let clash;
16310
+ const dependsOn = binding.dependsOn.map((key) => {
16311
+ const visible = [key, ...aliases[key] ?? []].filter((name) => scope2.visible.has(name));
16312
+ if (visible.length > 1 && !clash) {
16313
+ clash = { key, names: visible };
16314
+ }
16315
+ return visible[0] ?? key;
16316
+ });
16317
+ return clash ? { dependsOn, clash } : { dependsOn };
16318
+ }
16319
+ function publishedBinding(binding, scope2) {
16320
+ return { id: binding.id, dependsOn: resolveDependsOn(binding, scope2).dependsOn };
16321
+ }
16322
+
15960
16323
  // ../../flow-extension-runner/src/v2/params/schema/assert-supported-schema.ts
15961
16324
  var GUARDED_KINDS = /* @__PURE__ */ new Set(["action", "dictionary", "polling trigger", "realtime trigger", "extension"]);
15962
16325
  var SUPPORTED_TYPES = /* @__PURE__ */ new Set([
@@ -16086,6 +16449,48 @@ function assertDictionaryBinding(schema, source, path23, scope2) {
16086
16449
  );
16087
16450
  }
16088
16451
  }
16452
+ function assertDateString(schema, source, path23) {
16453
+ const ins = inspect(schema);
16454
+ const pattern = ins.meta.frDateFormat;
16455
+ const kind = dateStringKind(ins);
16456
+ if (pattern !== void 0 && !kind) {
16457
+ const format = ins.core?._zod?.def?.format;
16458
+ const zoned = ins.coreType === "string" && format === "datetime";
16459
+ refuse(
16460
+ `${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.`,
16461
+ source,
16462
+ path23,
16463
+ zoned ? "datetime" : ins.resolvedType ?? "unknown"
16464
+ );
16465
+ }
16466
+ if (!kind) {
16467
+ return;
16468
+ }
16469
+ if (pattern !== void 0) {
16470
+ try {
16471
+ compilePattern(pattern, kind);
16472
+ } catch (error) {
16473
+ if (error instanceof DateFormatError) {
16474
+ refuse(`${subjectOf(source, path23)}: \`.dateFormat('${pattern}')\` ${error.message}.`, source, path23, pattern);
16475
+ }
16476
+ throw error;
16477
+ }
16478
+ }
16479
+ const fallback = ins.defaultValue;
16480
+ if (fallback === void 0 || fallback === null) {
16481
+ return;
16482
+ }
16483
+ const written = patternOf(ins, kind);
16484
+ const fits = typeof fallback === "string" && (pattern !== void 0 ? !!parseInPattern(fallback, pattern, kind) : ((parts) => !!parts && toCanonical(parts, kind) === fallback)(parseIso(fallback, kind)));
16485
+ if (!fits) {
16486
+ refuse(
16487
+ `${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.`,
16488
+ source,
16489
+ path23,
16490
+ String(fallback)
16491
+ );
16492
+ }
16493
+ }
16089
16494
  function assertField(schema, source, path23, seen, scope2, topLevel = false) {
16090
16495
  if (!schema || seen.has(schema)) {
16091
16496
  return;
@@ -16104,6 +16509,7 @@ function assertField(schema, source, path23, seen, scope2, topLevel = false) {
16104
16509
  refuseCatch(source, path23);
16105
16510
  }
16106
16511
  assertDictionaryBinding(schema, source, path23, scope2);
16512
+ assertDateString(schema, source, path23);
16107
16513
  if (!ins.resolvedType || !SUPPORTED_TYPES.has(ins.resolvedType)) {
16108
16514
  refuseType(source, path23, ins.resolvedType);
16109
16515
  }
@@ -16354,15 +16760,45 @@ function planField(name, schema) {
16354
16760
  label: labelOf(name, schema),
16355
16761
  coreType: ins.coreType,
16356
16762
  isUnion: !!ins.branches,
16763
+ blankBranch: hasBlankBranch(ins),
16357
16764
  absence,
16358
16765
  absorbsBlank,
16359
16766
  keepsEmpty,
16360
16767
  blankIsValue,
16361
16768
  passThroughDate: passesDateThrough(ins),
16362
- restoresDates: hasPassThroughDate(schema, inspect, shapeEntries)
16769
+ restoresDates: hasPassThroughDate(schema, inspect, shapeEntries),
16770
+ dateString: dateStringKind(ins),
16771
+ formatsDates: hasDateFormat(schema)
16363
16772
  };
16364
16773
  }
16365
16774
 
16775
+ // ../../flow-extension-runner/src/v2/params/schema/notices.ts
16776
+ var sink;
16777
+ var currentField;
16778
+ function collectNotices(fn) {
16779
+ const outer = sink;
16780
+ const notices = [];
16781
+ sink = notices;
16782
+ try {
16783
+ return { result: fn(), notices };
16784
+ } finally {
16785
+ sink = outer;
16786
+ outer?.push(...notices);
16787
+ }
16788
+ }
16789
+ function withinField(field, fn) {
16790
+ const outer = currentField;
16791
+ currentField = field;
16792
+ try {
16793
+ return fn();
16794
+ } finally {
16795
+ currentField = outer;
16796
+ }
16797
+ }
16798
+ function notice(entry) {
16799
+ sink?.push({ field: currentField, ...entry });
16800
+ }
16801
+
16366
16802
  // ../../flow-extension-runner/src/v2/params/schema/coerce.ts
16367
16803
  var ok = (value) => ({ ok: true, value });
16368
16804
  var fail2 = (expected) => ({ ok: false, expected });
@@ -16534,6 +16970,21 @@ function coerceLeaf(value, ins) {
16534
16970
  if (ins.branches) {
16535
16971
  return ok(coerceUnion(value, ins.branches));
16536
16972
  }
16973
+ const kind = dateStringKind(ins);
16974
+ if (kind) {
16975
+ const { canonical, fromTimestamp } = toDateString(value, ins, kind);
16976
+ if (canonical === void 0) {
16977
+ return fail2(expectedDateString(ins, kind));
16978
+ }
16979
+ if (fromTimestamp) {
16980
+ notice({
16981
+ message: "a timestamp was converted to a date string in the server time zone (FR-3920 lenient period)",
16982
+ value,
16983
+ converted: canonical
16984
+ });
16985
+ }
16986
+ return ok(canonical);
16987
+ }
16537
16988
  const format = formatOf(ins);
16538
16989
  if (ins.coreType === "string" && isConvertibleIso(format)) {
16539
16990
  const iso = toIso(value, format);
@@ -16562,12 +17013,12 @@ function isBlank(value, ins, schema) {
16562
17013
  return false;
16563
17014
  }
16564
17015
  if (ins.branches) {
16565
- return true;
17016
+ return !hasBlankBranch(ins) || absenceOf(schema).absorbsBlank;
16566
17017
  }
16567
17018
  if (absenceOf(schema).blankIsValue) {
16568
17019
  return absenceOf(schema).absorbsBlank;
16569
17020
  }
16570
- return ins.coreType !== "string" || absenceOf(schema).absorbsBlank;
17021
+ return ins.coreType !== "string" || !!dateStringKind(ins) || absenceOf(schema).absorbsBlank;
16571
17022
  }
16572
17023
  function absentAs(schema, value) {
16573
17024
  const { absence } = absenceOf(schema);
@@ -16631,6 +17082,72 @@ var EXPECTED = {
16631
17082
  record: "an object"
16632
17083
  };
16633
17084
  var requiredMessage = (plan2) => `\xAB${plan2.label}\xBB is required`;
17085
+ var oneOf = (values) => `one of: ${values.map(String).join(", ")}`;
17086
+ var formatPhrase = (format) => {
17087
+ const described = FORMAT_DESCRIPTIONS[format ?? ""];
17088
+ return described?.replace(/^Expects (.*?), e\.g\. (.*)$/, "$1 (e.g. $2)").replace(/^Expects /, "");
17089
+ };
17090
+ var distinct = (phrases) => [...new Set(phrases.filter((phrase) => !!phrase))];
17091
+ function unionPhrases(union, value) {
17092
+ return distinct((inspect(union).branches ?? []).map((branch) => {
17093
+ try {
17094
+ const result = branch.safeParse(value);
17095
+ return branchPhrase(branch, result.error?.issues[0]);
17096
+ } catch {
17097
+ return void 0;
17098
+ }
17099
+ }));
17100
+ }
17101
+ function remainingIssue(branch, value) {
17102
+ if (!branch) {
17103
+ return void 0;
17104
+ }
17105
+ try {
17106
+ const result = branch.safeParse(coerceDeep(value, branch));
17107
+ return result.success ? void 0 : result.error?.issues[0];
17108
+ } catch {
17109
+ return void 0;
17110
+ }
17111
+ }
17112
+ function branchPhrase(branch, issue) {
17113
+ if (!branch || !issue) {
17114
+ return void 0;
17115
+ }
17116
+ const ins = inspect(branch);
17117
+ const values = ins.core._zod?.def?.values ?? [];
17118
+ if (ins.coreType === "literal" && values.length === 1 && values[0] === "") {
17119
+ return void 0;
17120
+ }
17121
+ const dateKind = dateStringKind(ins);
17122
+ if (dateKind) {
17123
+ return expectedDateString(ins, dateKind);
17124
+ }
17125
+ switch (issue.code) {
17126
+ case "invalid_type":
17127
+ return EXPECTED[issue.expected ?? ""] ?? issue.expected;
17128
+ case "invalid_value":
17129
+ return oneOf(issue.values ?? values);
17130
+ case "invalid_format":
17131
+ return formatPhrase(issue.format);
17132
+ // A bound has no short phrase ("a number of at least 10"); the branch still names its type.
17133
+ case "too_small":
17134
+ case "too_big":
17135
+ return EXPECTED[ins.coreType === "literal" ? literalType(ins.core) ?? "" : ins.coreType];
17136
+ default:
17137
+ return void 0;
17138
+ }
17139
+ }
17140
+ function unionIssue(plan2, issue, union, unionValue, fieldValue) {
17141
+ const branches = union ? inspect(union).branches : void 0;
17142
+ const errors = issue.errors ?? [];
17143
+ const deepIndex = errors.findIndex((branchIssues) => branchIssues.some((branchIssue) => (branchIssue.path ?? []).length));
17144
+ if (deepIndex >= 0) {
17145
+ const deep = remainingIssue(branches?.[deepIndex], unionValue) ?? errors[deepIndex].find((branchIssue) => (branchIssue.path ?? []).length);
17146
+ return toFieldIssue(plan2, { ...deep, path: [...issue.path ?? [], ...deep.path ?? []] }, fieldValue);
17147
+ }
17148
+ const phrases = distinct(errors.map((branchIssues, index) => branchPhrase(branches?.[index], branchIssues[0])));
17149
+ return phrases.length ? { path: "", code: "invalid_union", message: `must be ${phrases.join(", or ")}` } : void 0;
17150
+ }
16634
17151
  var invalidTypeMessage = (plan2, expected) => `\xAB${plan2.label}\xBB must be ${EXPECTED[expected] ?? expected}`;
16635
17152
  var isIndex = (segment) => /^\d+$/.test(segment);
16636
17153
  function resolveTarget(plan2, segments, fieldValue) {
@@ -16639,6 +17156,8 @@ function resolveTarget(plan2, segments, fieldValue) {
16639
17156
  let label = plan2.label;
16640
17157
  let found = true;
16641
17158
  for (const segment of segments) {
17159
+ const branch = schema && inspect(schema).branches?.find((candidate) => isIndex(segment) ? inspect(candidate).coreType === "array" : shapeEntries(inspect(candidate).core).some(([name]) => name === segment));
17160
+ schema = branch ?? schema;
16642
17161
  const core = schema ? inspect(schema).core : void 0;
16643
17162
  const coreType = core ? inspect(schema).coreType : void 0;
16644
17163
  value = value == null ? void 0 : value[segment];
@@ -16655,7 +17174,7 @@ function resolveTarget(plan2, segments, fieldValue) {
16655
17174
  schema = nested[1];
16656
17175
  label = labelOf(segment, schema);
16657
17176
  }
16658
- return { label, value, found };
17177
+ return { label, value, found, schema: found ? schema : void 0 };
16659
17178
  }
16660
17179
  function bound(value, plan2) {
16661
17180
  if (plan2.coreType !== "date" || typeof value !== "number") {
@@ -16677,6 +17196,17 @@ function toFieldIssue(plan2, issue, fieldValue) {
16677
17196
  if (isAuthored(issue)) {
16678
17197
  return { path: path23, code, message: issue.message };
16679
17198
  }
17199
+ if (code === "invalid_format" && target.schema && inspect(target.schema).branches) {
17200
+ const combined = unionPhrases(target.schema, target.value);
17201
+ if (combined.length > 1) {
17202
+ return { path: path23, code: "invalid_union", message: `\xAB${target.label}\xBB must be ${combined.join(", or ")}` };
17203
+ }
17204
+ }
17205
+ const dateKind = target.schema ? dateStringKind(inspect(target.schema)) : void 0;
17206
+ const dateMissing = target.value == null || target.value === "";
17207
+ if (dateKind && (code === "invalid_type" || code === "invalid_format")) {
17208
+ return dateMissing ? { path: path23, code, message: requiredMessage(named) } : { path: path23, code, message: invalidTypeMessage(named, expectedDateString(inspect(target.schema), dateKind)) };
17209
+ }
16680
17210
  if (code === "invalid_type") {
16681
17211
  const received = issue.received;
16682
17212
  const absent = segments.length ? target.found && target.value == null : received === "undefined" || received === "null" || issue.expected === void 0;
@@ -16689,13 +17219,21 @@ function toFieldIssue(plan2, issue, fieldValue) {
16689
17219
  return { path: path23, code, message: `\xAB${target.label}\xBB must be at most ${bound(issue.maximum, plan2)}` };
16690
17220
  }
16691
17221
  if (code === "invalid_value") {
16692
- const values = (issue.values ?? []).map(String);
16693
- return { path: path23, code, message: `\xAB${target.label}\xBB must be one of: ${values.join(", ")}` };
17222
+ return { path: path23, code, message: `\xAB${target.label}\xBB must be ${oneOf(issue.values ?? [])}` };
16694
17223
  }
16695
17224
  if (code === "invalid_format") {
16696
17225
  const described = FORMAT_DESCRIPTIONS[issue.format ?? ""];
16697
17226
  return described ? { path: path23, code, message: `\xAB${target.label}\xBB is invalid \u2014 ${described.replace(/^Expects /, "expects ")}` } : { path: path23, code, message: `\xAB${target.label}\xBB has an invalid format` };
16698
17227
  }
17228
+ if (code === "invalid_union") {
17229
+ if (segments.length && target.found && target.value == null) {
17230
+ return { path: path23, code, message: requiredMessage(named) };
17231
+ }
17232
+ const combined = unionIssue(plan2, issue, target.schema, target.value, fieldValue);
17233
+ if (combined) {
17234
+ return combined.path ? combined : { path: path23, code, message: `\xAB${target.label}\xBB ${combined.message}` };
17235
+ }
17236
+ }
16699
17237
  return { path: path23, code, message: `\xAB${target.label}\xBB is invalid` };
16700
17238
  }
16701
17239
 
@@ -16716,12 +17254,12 @@ function isAbsent(value, plan2) {
16716
17254
  return false;
16717
17255
  }
16718
17256
  if (plan2.isUnion) {
16719
- return true;
17257
+ return !plan2.blankBranch || plan2.absorbsBlank;
16720
17258
  }
16721
17259
  if (plan2.blankIsValue) {
16722
17260
  return plan2.absorbsBlank;
16723
17261
  }
16724
- return plan2.coreType !== "string" || plan2.absorbsBlank;
17262
+ return plan2.coreType !== "string" || !!plan2.dateString || plan2.absorbsBlank;
16725
17263
  }
16726
17264
  function normalizeAbsence(value, plan2) {
16727
17265
  if (plan2.absence === "required") {
@@ -16760,7 +17298,7 @@ function normalizeField(value, plan2) {
16760
17298
  return restore(validate(coerced.value, plan2), value, plan2);
16761
17299
  }
16762
17300
  function restore(result, original, plan2) {
16763
- if (!plan2.restoresDates || !result.present || result.issues.length) {
17301
+ if (!(plan2.restoresDates || plan2.formatsDates) || !result.present || result.issues.length) {
16764
17302
  return result;
16765
17303
  }
16766
17304
  if (plan2.passThroughDate) {
@@ -16780,6 +17318,10 @@ function restoreDeep(output, original, schema) {
16780
17318
  const branch = ins.branches.find((option) => accepts(option, output));
16781
17319
  return branch ? restoreDeep(output, original, branch) : output;
16782
17320
  }
17321
+ const kind = dateStringKind(ins);
17322
+ if (kind) {
17323
+ return typeof output === "string" && original !== "" ? canonicalToPattern(output, ins, kind) : output;
17324
+ }
16783
17325
  const element = ins.core?._zod?.def?.element;
16784
17326
  if (ins.coreType === "array" && element && Array.isArray(output) && Array.isArray(original)) {
16785
17327
  return output.map((item, index) => restoreDeep(item, original[index], element));
@@ -16869,7 +17411,7 @@ var Params = class {
16869
17411
  const values = {};
16870
17412
  const issues = [];
16871
17413
  for (const plan2 of this.plans()) {
16872
- const result = normalizeField(source[plan2.name], plan2);
17414
+ const result = withinField(plan2.name, () => normalizeField(source[plan2.name], plan2));
16873
17415
  if (result.issues.length) {
16874
17416
  issues.push(...result.issues);
16875
17417
  } else if (result.present) {
@@ -17024,6 +17566,9 @@ function extendPrototype() {
17024
17566
  }
17025
17567
  return this.meta({ frDictionary: binding });
17026
17568
  };
17569
+ proto.dateFormat = function dateFormat(pattern) {
17570
+ return this.meta({ frDateFormat: pattern });
17571
+ };
17027
17572
  proto.labels = function labels(byValue) {
17028
17573
  return this.meta({ frLabels: byValue });
17029
17574
  };
@@ -17322,6 +17867,7 @@ function encodeField(name, schema, seen = /* @__PURE__ */ new Set(), loaderId, s
17322
17867
  name,
17323
17868
  type,
17324
17869
  ...format ? { format } : {},
17870
+ ...format === "datetime" && core?._zod?.def?.local ? { local: true } : {},
17325
17871
  ...optional ? { optional: true } : {},
17326
17872
  ...nullable ? { nullable: true } : {},
17327
17873
  ...hasDefault ? { default: toJsonValue(defaultValue) } : {},
@@ -17849,8 +18395,23 @@ var ExecutionContext = class _ExecutionContext {
17849
18395
  get logger() {
17850
18396
  return this.#options.logger ?? defaultLogger;
17851
18397
  }
18398
+ get invocation() {
18399
+ return this.#options.invocation ?? {};
18400
+ }
17852
18401
  get config() {
17853
- this.#config ??= this.#extension.config.resolve(this.#options.configs);
18402
+ if (!this.#config) {
18403
+ const { result, notices } = collectNotices(() => this.#extension.config.resolve(this.#options.configs));
18404
+ for (const { message, field, value, converted } of notices) {
18405
+ this.logger.warn(`[flow-extension:${this.#extension.id}] config item "${field ?? "?"}": ${message}`, {
18406
+ serviceId: this.#extension.id,
18407
+ configItem: field,
18408
+ value,
18409
+ converted,
18410
+ ...this.invocation
18411
+ });
18412
+ }
18413
+ this.#config = result;
18414
+ }
17854
18415
  return this.#config;
17855
18416
  }
17856
18417
  // The header access token plus its deserialized composite payload — or a throwing proxy when the
@@ -19364,7 +19925,23 @@ var Extension = class {
19364
19925
  // generated loader, SYSTEM seam — arrives here through the same three steps.
19365
19926
  async run(methodName, methodData, ctx) {
19366
19927
  const method = this.getMethod(methodName);
19367
- return method.execute(method.validate(methodData ?? {}), ctx);
19928
+ const { result: input, notices } = collectNotices(() => method.validate(methodData ?? {}));
19929
+ this.#reportNotices(notices, methodName, ctx);
19930
+ return method.execute(input, ctx);
19931
+ }
19932
+ // One warning per value the pipeline accepted only under a temporary rule — today a timestamp converted for
19933
+ // a date-string field (FR-3920 lenient period). Named well enough to find the flow still holding one.
19934
+ #reportNotices(notices, methodName, ctx) {
19935
+ for (const { message, field, value, converted } of notices) {
19936
+ ctx.logger.warn(`[flow-extension:${this.id}] ${methodName}: param "${field ?? "?"}": ${message}`, {
19937
+ serviceId: this.id,
19938
+ method: methodName,
19939
+ param: field,
19940
+ value,
19941
+ converted,
19942
+ ...ctx.invocation
19943
+ });
19944
+ }
19368
19945
  }
19369
19946
  // ── output model ────────────────────────────────────────────────────────────
19370
19947
  toConfigItems() {