@uipath/maestro-builder-sdk 6.95.4 → 6.95.6

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.
@@ -36,8 +36,8 @@
36
36
  *
37
37
  * Nothing here prints; the CLIs do.
38
38
  */
39
- import { createHash } from 'node:crypto';
40
39
  import { commentText } from '../core/comment-text.js';
40
+ import { bytesToHex, sha256 } from '../core/sha.js';
41
41
  /** The marker that starts the stamp line. */
42
42
  export const STAMP_MARKER = '// @decompiled-from ';
43
43
  /** The SDK import line of a decompiled source; `buildSource` (lift-verify.ts) rewrites the same line. */
@@ -50,7 +50,7 @@ const IMPORT_RE = /^(import\s*\{[^}]*\}\s*from\s*)["'][^"']+["'];/m;
50
50
  * @param source - The decompiled source, before {@link stampSource}.
51
51
  */
52
52
  export function sourceDigest(source) {
53
- return createHash('sha256').update(source.replace(IMPORT_RE, '$1"@";')).digest('hex');
53
+ return bytesToHex(sha256(source.replace(IMPORT_RE, '$1"@";')));
54
54
  }
55
55
  /** The stamp line, without a line terminator. */
56
56
  export function formatStamp(stamp) {
@@ -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,8 +1,8 @@
1
- import { createHash } from "node:crypto";
2
1
  import { mkdirSync, readFileSync, existsSync } from "node:fs";
3
2
  import { createRequire } from "node:module";
4
3
  import { join } from "node:path";
5
4
  import { writeJsonFile } from "../../core/json-file.js";
5
+ import { bytesToHex, sha256 } from "../../core/sha.js";
6
6
  import { HostUipClient } from "./host.js";
7
7
  import { launchFor } from "./launch.js";
8
8
  /**
@@ -115,7 +115,7 @@ export function recordingName(argv) {
115
115
  // `["uip", "is", "a b"]` and `["uip", "is", "a", "b"]` the same recording,
116
116
  // and `--connectors "a,b"` versus two flags is exactly the kind of pair the
117
117
  // registry issues.
118
- const digest = createHash("sha256").update(argv.join("\u0000")).digest("hex").slice(0, 16);
118
+ const digest = bytesToHex(sha256(argv.join("\u0000"))).slice(0, 16);
119
119
  const slug = argv
120
120
  .slice(1, 5)
121
121
  .join("-")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.95.4",
3
+ "version": "6.95.6",
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": "4c58402d9acb62bdecb393a60d959c89f5594df2"
115
+ "gitref": "a338c75fc5efff55716b4e8aaac369d24a770950"
116
116
  }