@uipath/maestro-builder-sdk 6.95.3 → 6.95.5

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.
@@ -69,7 +69,10 @@ export declare function mergeJson3(original: unknown, baseline: unknown, edited:
69
69
  /**
70
70
  * The sidecar files the merged flow needs written beside it, and what merge could
71
71
  * not carry. `merged` is `mergeFlow`'s result. An agent is new when the
72
- * original side has no `<source>/agent.json` for it.
72
+ * original flow has no node with its `source`. `missing` holds the agents the
73
+ * original flow has but whose `<source>/agent.json` is not beside it: writing the
74
+ * compiled file would replace the project's, so merge refuses them in every
75
+ * mode. An embedded original node never reads its `agent.json`, so it is exempt.
73
76
  */
74
77
  export declare function mergeAgentSidecars(merged: {
75
78
  nodes?: AnyNode[];
@@ -78,5 +81,6 @@ export declare function mergeAgentSidecars(merged: {
78
81
  writes: SidecarWrite[];
79
82
  removals: string[];
80
83
  findings: MergeFinding[];
84
+ missing: MergeFinding[];
81
85
  };
82
86
  export {};
@@ -279,21 +279,33 @@ const finding = (message) => ({ kind: 'agent-sidecar', message, refuses: true })
279
279
  /**
280
280
  * The sidecar files the merged flow needs written beside it, and what merge could
281
281
  * not carry. `merged` is `mergeFlow`'s result. An agent is new when the
282
- * original side has no `<source>/agent.json` for it.
282
+ * original flow has no node with its `source`. `missing` holds the agents the
283
+ * original flow has but whose `<source>/agent.json` is not beside it: writing the
284
+ * compiled file would replace the project's, so merge refuses them in every
285
+ * mode. An embedded original node never reads its `agent.json`, so it is exempt.
283
286
  */
284
287
  export function mergeAgentSidecars(merged, sources, flows) {
285
288
  const writes = [];
286
289
  const removals = [];
287
290
  const findings = [];
291
+ const missing = [];
292
+ const originalAgents = agentSources(flows?.original);
288
293
  for (const [source, node] of agentSources(merged)) {
289
294
  const edited = sources.edited(source);
290
295
  if (edited === undefined)
291
296
  continue; // the edited compile wrote no sidecar here: nothing to carry
292
297
  const orig = sources.original(source);
293
298
  const agentPath = `${source}/agent.json`;
299
+ const originalNode = originalAgents.get(source);
300
+ if (orig === undefined && originalNode !== undefined && !isEmbeddedAgent(originalNode)) {
301
+ missing.push(finding(`agent "${node.id}": the original flow has this agent, but ${agentPath} is not beside --original, or does not `
302
+ + `parse. Nothing is written. Pass the project's own <Name>.flow as --original, with ${agentPath} beside it `
303
+ + `(not a copy of the .flow alone), and run merge again. If the project itself has no valid ${agentPath}, `
304
+ + `first copy the edited compile's ${agentPath} into the project beside its .flow.`));
305
+ continue;
306
+ }
294
307
  if (orig === undefined) {
295
- // An agent the edit added (or one whose original sidecar is missing):
296
- // the edited compile's files are the only ones there are.
308
+ // An agent the edit added: the edited compile's files are the only ones there are.
297
309
  for (const [path, json] of Object.entries(edited))
298
310
  writes.push({ path, json: jsonClone(json), carried: ['new agent'] });
299
311
  continue;
@@ -360,5 +372,5 @@ export function mergeAgentSidecars(merged, sources, flows) {
360
372
  + 'stay as they are. Make that change on the canvas.'));
361
373
  }
362
374
  }
363
- return { writes, removals, findings };
375
+ return { writes, removals, findings, missing };
364
376
  }
package/dist/merge.d.ts CHANGED
@@ -126,6 +126,7 @@ export interface MergeOptions {
126
126
  * where the author made no edit, or (with sidecars, `mergeFlowWithSidecars`)
127
127
  * would leave out an agent sidecar edit, throw {@link MergeRefusedError}
128
128
  * listing every such finding, and return nothing. The other findings still go to `warn`.
129
+ * A merge that would replace the project's `agent.json` is refused without `strict` too.
129
130
  * Two findings never refuse, because the merged file does what the original
130
131
  * does: an End the compile appends to a tail the original leaves open, and a
131
132
  * binding row the round trip drops (merge keeps the original's). Meant to be
@@ -140,7 +141,8 @@ export declare function mergeFlow(original: AnyFlow, edited: AnyFlow, options?:
140
141
  * `<source>/agent.json`, so an edit to them changes no node; this carries the
141
142
  * author's change to that file onto the original's copy. What it cannot carry
142
143
  * becomes a finding: warned, and refused under `strict`, with the flow's own
143
- * findings. See merge-sidecars.ts.
144
+ * findings. One that would replace the project's `agent.json` is refused in
145
+ * every mode. See merge-sidecars.ts.
144
146
  */
145
147
  export declare function mergeFlowWithSidecars(original: AnyFlow, edited: AnyFlow, sidecars: MergeSidecarSources, options?: MergeOptions): {
146
148
  flow: AnyFlow;
package/dist/merge.js CHANGED
@@ -312,20 +312,33 @@ export function mergeFlow(original, edited, options = {}) {
312
312
  * `<source>/agent.json`, so an edit to them changes no node; this carries the
313
313
  * author's change to that file onto the original's copy. What it cannot carry
314
314
  * becomes a finding: warned, and refused under `strict`, with the flow's own
315
- * findings. See merge-sidecars.ts.
315
+ * findings. One that would replace the project's `agent.json` is refused in
316
+ * every mode. See merge-sidecars.ts.
316
317
  */
317
318
  export function mergeFlowWithSidecars(original, edited, sidecars, options = {}) {
318
319
  const { result, findings } = mergeFlowFindings(original, edited, options);
319
320
  const carried = mergeAgentSidecars(result, sidecars, { original, baseline: options.baseline, edited });
320
- reportOrRefuse([...findings, ...carried.findings], options);
321
+ reportOrRefuse([...findings, ...carried.findings], options, carried.missing);
321
322
  return { flow: result, sidecars: carried.writes, removals: carried.removals };
322
323
  }
323
- /** Warn every finding; under `strict`, throw over the refusing ones (and still warn the rest). */
324
- function reportOrRefuse(findings, options) {
324
+ /** Refused with or without `strict`: merging would replace the project's `agent.json`. */
325
+ class SidecarOverwriteError extends MergeRefusedError {
326
+ constructor(findings) {
327
+ super(findings);
328
+ this.message = `refused:\n${findings.map((f) => ` - ${f.message}`).join('\n')}`;
329
+ }
330
+ }
331
+ /**
332
+ * Warn every finding; under `strict`, throw over the refusing ones (and still
333
+ * warn the rest). `overwrites` refuse in every mode.
334
+ */
335
+ function reportOrRefuse(findings, options, overwrites = []) {
325
336
  const refusing = options.strict ? findings.filter((f) => f.refuses) : [];
326
337
  for (const f of findings)
327
338
  if (!refusing.includes(f))
328
339
  options.warn?.(f.message);
340
+ if (overwrites.length > 0)
341
+ throw new SidecarOverwriteError([...overwrites, ...refusing]);
329
342
  if (refusing.length > 0)
330
343
  throw new MergeRefusedError(refusing);
331
344
  }
@@ -1,4 +1,5 @@
1
1
  import { SCHEDULE_PRESETS } from './spec.js';
2
+ import { isJsExpressionValue } from '../../../core/wire-expr.js';
2
3
  export const TRIGGER_DIAGNOSTICS = {
3
4
  SCHEDULE_NO_INTERVAL: { severity: 'error', summary: 'a schedule with no `every`, so it never starts the flow' },
4
5
  SCHEDULE_NOT_ISO: { severity: 'error', summary: '`every` is not an ISO-8601 repeating interval or a Quartz cron expression' },
@@ -88,6 +89,21 @@ export function checkSchedule(spec, ctx) {
88
89
  + `Give it an ISO-8601 repeating interval — ${SCHEDULE_PRESETS.join(', ')} are the designer's presets.`, `every: 'R/PT1H'`);
89
90
  return;
90
91
  }
92
+ // An expression is refused, though `uip maestro flow validate` accepts it at
93
+ // 1.1 and 1.2 (#1687). Nothing evaluates a schedule at run time: `uip maestro
94
+ // flow pack` turns `timerValue` into an Orchestrator TimeTrigger with a fixed
95
+ // CronExpression, computed at pack time, before any `$vars` exist
96
+ // (flow-workbench packaging.ts). An envelope registers no trigger; a bare
97
+ // `=js:` string becomes the monthly-midnight fallback cron (#1904 review).
98
+ // "Expression" is migrate's own rule (`isJsExpressionValue`), so `' =js:…'`,
99
+ // which compile writes as text, is checked as the literal it is below.
100
+ if (isJsExpressionValue(raw)) {
101
+ at('SCHEDULE_NOT_ISO', `The scheduled trigger's interval is an expression (${JSON.stringify(raw)}). A schedule is registered as a `
102
+ + `fixed cron when the flow is published, before any variable has a value, so it cannot be computed from `
103
+ + `variables: an expression schedule never fires as written. Write a literal ISO-8601 repeating interval `
104
+ + `(R/PT1H, R/P1D) or a Quartz cron expression.`, `every: 'R/PT1H'`);
105
+ return;
106
+ }
91
107
  const every = String(raw).trim();
92
108
  if (SCHEDULE_CRON_RE.test(every.trim())) {
93
109
  // A Quartz cron expression — admitted by the scheduled trigger's 1.2
@@ -17,9 +17,13 @@
17
17
  */
18
18
  import { CompileRefusal } from '../../../core/compile-refusal.js';
19
19
  import { checkSchedule, checkStartingPrompts, fitsScheduleV12, isIsoInterval } from './check.js';
20
+ import { isJsExpressionValue } from '../../../core/wire-expr.js';
20
21
  import { SCHEDULE_PRESETS } from './spec.js';
21
22
  /** A Quartz cron expression: 6–7 whitespace-separated fields, none of them an ISO `R/` interval. */
22
23
  function isQuartz(every) {
24
+ // An `=js:` expression can have six tokens too; it is not cron.
25
+ if (isJsExpressionValue(every))
26
+ return false;
23
27
  const fields = every.trim().split(/\s+/);
24
28
  return fields.length >= 6 && fields.length <= 7 && !every.trim().startsWith('R');
25
29
  }
@@ -57,7 +61,8 @@ function scheduledVersion(inputs, explicit) {
57
61
  }
58
62
  return explicit;
59
63
  }
60
- if (cron || fitsScheduleV12(every))
64
+ // An expression has no interval to fit: it is written at the current version.
65
+ if (cron || isJsExpressionValue(every) || fitsScheduleV12(every))
61
66
  return SCHEDULED_DEFAULT_VERSION;
62
67
  return '1.1';
63
68
  }
@@ -136,13 +141,15 @@ function scheduleInputs(inputs, entryPointId, version) {
136
141
  * shapes: 1.1 splits preset/custom over `timerPreset`/`timerValue`; 1.2 (the
137
142
  * cron-capable contract) dropped `timerPreset` and rides `timerValue` alone.
138
143
  */
139
- function scheduleEvery(node) {
144
+ function scheduleEvery(node, ctx) {
140
145
  const i = (node.inputs ?? {});
141
- if (typeof i.timerPreset !== 'string')
142
- return typeof i.timerValue === 'string' ? i.timerValue : '';
143
- return i.timerPreset === 'custom'
144
- ? (typeof i.timerValue === 'string' ? i.timerValue : '')
145
- : i.timerPreset;
146
+ // Through `sourceText`, so an `=js:` schedule the file holds as a jsExpression
147
+ // envelope comes back as its `=js:` text instead of '' (#1687).
148
+ const text = (raw) => ctx.sourceText(raw);
149
+ const preset = text(i.timerPreset);
150
+ if (preset === undefined)
151
+ return text(i.timerValue) ?? '';
152
+ return preset === 'custom' ? (text(i.timerValue) ?? '') : preset;
146
153
  }
147
154
  /**
148
155
  * A conversation or a call starts with only what the platform supplies, so an
@@ -176,7 +183,7 @@ export const scheduledTriggerType = {
176
183
  const entryPointId = ctx.root.isDefault ? ctx.entryPointId('start') : ctx.entryPointId();
177
184
  return { version, inputs: scheduleInputs(spec.inputs, entryPointId, version) };
178
185
  },
179
- deserialize: (node) => ({ kind: 'scheduled', inputs: { every: scheduleEvery(node) } }),
186
+ deserialize: (node, ctx) => ({ kind: 'scheduled', inputs: { every: scheduleEvery(node, ctx) } }),
180
187
  print: (spec, ctx) => ({ factory: 'scheduled', options: [['every', ctx.string(spec.inputs.every)]] }),
181
188
  check: (spec, ctx) => checkSchedule(spec, ctx),
182
189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.95.3",
3
+ "version": "6.95.5",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -112,5 +112,5 @@
112
112
  "@types/node": "^22.7.0",
113
113
  "esbuild": "^0.28.1"
114
114
  },
115
- "gitref": "ca9243687f789cf274900bda7e6b7de6bc39ae79"
115
+ "gitref": "670117b96facaf1fcc6f9a03e3924a0e99e085e4"
116
116
  }