@uipath/maestro-builder-sdk 6.124.11 → 6.124.12

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.
@@ -0,0 +1,18 @@
1
+ import type { MergeFinding } from './merge-roundtrip.js';
2
+ import type { AnyNode } from './edit-scope.js';
3
+ /** The key the Schema Editor parks an unsaved draft under (flow-schema `IXP_SCHEMA_EDITOR_DRAFT_EXTENSION`). */
4
+ export declare const SCHEMA_EDITOR_DRAFT_KEY = "x-uipath-schema-editor-draft";
5
+ /** The problems the editor found in that draft (flow-schema `IXP_SCHEMA_EDITOR_ISSUES_EXTENSION`). */
6
+ export declare const SCHEMA_EDITOR_ISSUES_KEY = "x-uipath-schema-editor-issues";
7
+ /**
8
+ * Check every merged Extract document node against the original node of the
9
+ * same id: `refused` for one whose draft the merge would overwrite, `discarded`
10
+ * (a report, never refusing) for one whose draft the source dropped. MUTATES a
11
+ * discarded node: its leftover issues key goes with the draft.
12
+ */
13
+ export declare function extractDraftFindings(originalNodes: readonly AnyNode[], mergedNodes: readonly AnyNode[],
14
+ /** The baseline's nodes, root and subflows; `undefined` for a two-way merge. */
15
+ baselineNodes?: readonly AnyNode[]): {
16
+ refused: MergeFinding[];
17
+ discarded: MergeFinding[];
18
+ };
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Merge and an Extract document node's unsaved Schema Editor draft.
3
+ *
4
+ * Short version: when someone leaves an editing session in the Studio Web Schema
5
+ * Editor that is not valid yet, the designer parks their unfinished taxonomy on
6
+ * the node, beside the saved one:
7
+ *
8
+ * ```json
9
+ * "schemaDocument": {
10
+ * "prompt": "...", "outputSchema": { ... },
11
+ * "x-uipath-schema-editor-draft": { "prompt": "...", "outputSchema": { ... } },
12
+ * "x-uipath-schema-editor-issues": [{ "message": "Field \"PO Number\" ... has no instructions." }]
13
+ * }
14
+ * ```
15
+ *
16
+ * That draft is a person's work. An older `uip`'s `nodes schema set` refused to
17
+ * write such a node unless told `--discard-draft`. Decompile carries the whole
18
+ * document into `dynamicExtract({ schema })`, so before this the SDK route let an
19
+ * edit to the saved taxonomy land beside a draft that no longer matched it, with
20
+ * nothing refusing. The same rule, at merge:
21
+ *
22
+ * - The merged node still carries the draft, and its schema document differs
23
+ * from the original's in any way (the saved taxonomy or the draft itself):
24
+ * refused in every mode, nothing written.
25
+ * - The source dropped the draft key, and the baseline (the decompile the author
26
+ * started from) carries it: the author saw the draft and discarded it, the
27
+ * SDK route's discard. Merge writes the edit, removes the leftover issues
28
+ * key with the draft, and reports the discard. With no baseline, or one
29
+ * without the draft, the source may never have held it (one compiled from a
30
+ * hand-written file), so a missing key is no discard: the edit is refused as
31
+ * above. (The object merge already keeps the original's key there, since
32
+ * no baseline says it was removed; this check does not lean on that.)
33
+ * - The edit removed the node's inline schema document (a published model in
34
+ * its place): refused, with its own message, since the draft lives in it.
35
+ *
36
+ * A node the edit did not touch keeps its draft as the original has it.
37
+ */
38
+ import { isRecord } from './core/node-envelope.js';
39
+ import { DYNAMIC_EXTRACT_TYPE } from './nodes/document/flow/family.js';
40
+ /** The key the Schema Editor parks an unsaved draft under (flow-schema `IXP_SCHEMA_EDITOR_DRAFT_EXTENSION`). */
41
+ export const SCHEMA_EDITOR_DRAFT_KEY = 'x-uipath-schema-editor-draft';
42
+ /** The problems the editor found in that draft (flow-schema `IXP_SCHEMA_EDITOR_ISSUES_EXTENSION`). */
43
+ export const SCHEMA_EDITOR_ISSUES_KEY = 'x-uipath-schema-editor-issues';
44
+ function schemaDocumentOf(node) {
45
+ const doc = isRecord(node?.inputs) ? node.inputs.schemaDocument : undefined;
46
+ return isRecord(doc) ? doc : undefined;
47
+ }
48
+ /** JSON text with object keys sorted, so key order alone is no change. */
49
+ function sortedJson(v) {
50
+ return JSON.stringify(v, (_k, value) => (isRecord(value) && !Array.isArray(value)
51
+ ? Object.fromEntries(Object.keys(value).sort().map((k) => [k, value[k]]))
52
+ : value));
53
+ }
54
+ /** The issue messages the editor left with the draft, for the refusal. */
55
+ function issueMessages(doc) {
56
+ const issues = doc[SCHEMA_EDITOR_ISSUES_KEY];
57
+ return Array.isArray(issues)
58
+ ? issues.flatMap((i) => (isRecord(i) && typeof i.message === 'string' && i.message.trim() !== '' ? [i.message.trim()] : []))
59
+ : [];
60
+ }
61
+ function issuesSuffix(doc) {
62
+ const issues = issueMessages(doc);
63
+ return issues.length > 0 ? ` The editor reported: ${issues.join(' ')}` : '';
64
+ }
65
+ /**
66
+ * Check every merged Extract document node against the original node of the
67
+ * same id: `refused` for one whose draft the merge would overwrite, `discarded`
68
+ * (a report, never refusing) for one whose draft the source dropped. MUTATES a
69
+ * discarded node: its leftover issues key goes with the draft.
70
+ */
71
+ export function extractDraftFindings(originalNodes, mergedNodes,
72
+ /** The baseline's nodes, root and subflows; `undefined` for a two-way merge. */
73
+ baselineNodes) {
74
+ const before = new Map(originalNodes.map((n) => [n.id, n]));
75
+ const base = new Map((baselineNodes ?? []).map((n) => [n.id, n]));
76
+ const refused = [];
77
+ const discarded = [];
78
+ for (const node of mergedNodes) {
79
+ if (node.type !== DYNAMIC_EXTRACT_TYPE)
80
+ continue;
81
+ const was = schemaDocumentOf(before.get(node.id));
82
+ if (was === undefined || !Object.hasOwn(was, SCHEMA_EDITOR_DRAFT_KEY))
83
+ continue;
84
+ const now = schemaDocumentOf(node);
85
+ if (now === undefined) {
86
+ refused.push({
87
+ kind: 'extract-draft', refuses: true,
88
+ message: `Extract document node "${node.id}" carries an unsaved Schema Editor draft (${SCHEMA_EDITOR_DRAFT_KEY}), `
89
+ + 'someone\'s unfinished work in Studio Web, and the edit removes the inline taxonomy (its schema document) '
90
+ + 'that holds the draft. Have the author finish or discard the draft in Studio Web first, then merge again.'
91
+ + issuesSuffix(was),
92
+ });
93
+ continue;
94
+ }
95
+ const sawDraft = Object.hasOwn(schemaDocumentOf(base.get(node.id)) ?? {}, SCHEMA_EDITOR_DRAFT_KEY);
96
+ if (sawDraft && !Object.hasOwn(now, SCHEMA_EDITOR_DRAFT_KEY)) {
97
+ delete now[SCHEMA_EDITOR_ISSUES_KEY];
98
+ discarded.push({
99
+ kind: 'extract-draft', refuses: false,
100
+ message: `Extract document node "${node.id}": the source dropped its unsaved Schema Editor draft `
101
+ + `(${SCHEMA_EDITOR_DRAFT_KEY}), so merge discarded it: deleting the draft key is the discard.`,
102
+ });
103
+ continue;
104
+ }
105
+ if (sortedJson(now) === sortedJson(was))
106
+ continue;
107
+ refused.push({
108
+ kind: 'extract-draft', refuses: true,
109
+ message: `Extract document node "${node.id}" carries an unsaved Schema Editor draft (${SCHEMA_EDITOR_DRAFT_KEY}), `
110
+ + 'someone\'s unfinished work in Studio Web, and the edit changes its schema document. Have the author finish '
111
+ + 'or discard the draft in Studio Web first. To throw the draft away, only when the user says so, delete the '
112
+ + `"${SCHEMA_EDITOR_DRAFT_KEY}" key from the step's schema in the source and merge again. `
113
+ + 'If no one can be asked, leave the node unchanged and report the draft.'
114
+ + issuesSuffix(was),
115
+ });
116
+ }
117
+ return { refused, discarded };
118
+ }
@@ -33,7 +33,7 @@ interface RtFlow {
33
33
  /** One difference, or one inconsistency in the merged file. */
34
34
  export interface MergeFinding {
35
35
  /** Which comparison found it. */
36
- kind: 'node-removed' | 'node-added' | 'node-type' | 'implicit-end' | 'edge-handle-renamed' | 'edge-rewired' | 'edge-removed' | 'edge-added' | 'handle-ids' | 'binding-removed' | 'binding-added' | 'variable-added' | 'variable-changed' | 'undeclared-handle' | 'duplicate-binding' | 'agent-sidecar' | 'agent-storage' | 'agent-prompt-input' | 'agent-embedded-edit' | 'outputs-superseded' | 'entry-point-repaired';
36
+ kind: 'node-removed' | 'node-added' | 'node-type' | 'implicit-end' | 'edge-handle-renamed' | 'edge-rewired' | 'edge-removed' | 'edge-added' | 'handle-ids' | 'binding-removed' | 'binding-added' | 'variable-added' | 'variable-changed' | 'undeclared-handle' | 'duplicate-binding' | 'agent-sidecar' | 'agent-storage' | 'agent-prompt-input' | 'agent-embedded-edit' | 'outputs-superseded' | 'entry-point-repaired' | 'extract-draft';
37
37
  /** The finding, phrased for the author, naming the node, edge or row. */
38
38
  message: string;
39
39
  /**
package/dist/merge.js CHANGED
@@ -108,6 +108,7 @@ import { mergeObject, mergeVariables, stableJson, withoutReturnRespellings } fro
108
108
  import { keepProcessInputReads } from './merge-process-inputs.js';
109
109
  import { replaceSupersededOutputs } from './merge-superseded-outputs.js';
110
110
  import { restoredConnectionMessage, withOriginalConnectionLabels } from './merge-baseline-connections.js';
111
+ import { extractDraftFindings } from './merge-extract-draft.js';
111
112
  import { byId, isKept, nodeUnchanged, subflowsTakenFromEdited } from './edit-scope.js';
112
113
  export { MergeRefusedError } from './merge-roundtrip.js';
113
114
  /**
@@ -403,8 +404,8 @@ function positionStoreOf(f) {
403
404
  }
404
405
  export function mergeFlow(original, edited, options = {}) {
405
406
  options = withFaithfulBaseline(original, options);
406
- const { result, findings, agentFindings } = mergeFlowFindings(original, edited, options);
407
- reportOrRefuse([...findings, ...agentFindings()], options);
407
+ const { result, findings, agentFindings, draftRefusals } = mergeFlowFindings(original, edited, options);
408
+ reportOrRefuse([...findings, ...agentFindings()], options, draftRefusals);
408
409
  return result;
409
410
  }
410
411
  /**
@@ -419,11 +420,11 @@ export function mergeFlow(original, edited, options = {}) {
419
420
  */
420
421
  export function mergeFlowWithSidecars(original, edited, sidecars, options = {}) {
421
422
  options = withFaithfulBaseline(original, options);
422
- const { result, findings, agentFindings } = mergeFlowFindings(original, edited, options);
423
+ const { result, findings, agentFindings, draftRefusals } = mergeFlowFindings(original, edited, options);
423
424
  const carried = mergeAgentSidecars(result, sidecars, { original, baseline: options.baseline, edited });
424
425
  // After the carry: what it wrote onto an embedded node is the author's.
425
426
  const authored = new Map(carried.onNodes.map((c) => [c.node, c.inputs]));
426
- reportOrRefuse([...findings, ...agentFindings(authored), ...carried.findings], options, carried.missing);
427
+ reportOrRefuse([...findings, ...agentFindings(authored), ...carried.findings], options, [...carried.missing, ...draftRefusals]);
427
428
  return {
428
429
  flow: result,
429
430
  sidecars: carried.writes,
@@ -447,7 +448,11 @@ function withFaithfulBaseline(original, options) {
447
448
  options.warn?.(message);
448
449
  return { ...options, baseline };
449
450
  }
450
- /** Refused with or without `strict`: merging would replace the project's `agent.json`. */
451
+ /**
452
+ * Refused with or without `strict`: merging would replace the project's
453
+ * `agent.json`, or change the taxonomy of an Extract document node that holds
454
+ * someone's unsaved Schema Editor draft (merge-extract-draft.ts).
455
+ */
451
456
  class SidecarOverwriteError extends MergeRefusedError {
452
457
  constructor(findings) {
453
458
  super(findings);
@@ -456,7 +461,8 @@ class SidecarOverwriteError extends MergeRefusedError {
456
461
  }
457
462
  /**
458
463
  * Warn every finding; under `strict`, throw over the refusing ones (and still
459
- * warn the rest). `overwrites` refuse in every mode.
464
+ * warn the rest). `overwrites` refuse in every mode: an `agent.json` replaced,
465
+ * an Extract document draft overwritten.
460
466
  */
461
467
  function reportOrRefuse(findings, options, overwrites = []) {
462
468
  const refusing = options.strict ? findings.filter((f) => f.refuses) : [];
@@ -670,7 +676,14 @@ function mergeFlowFindings(original, edited, options) {
670
676
  const superseded = replaceSupersededOutputs(result, edited);
671
677
  // ── What the no-edit round trip changed, and what mixing sources broke. ──
672
678
  // The caller warns them, or refuses under strict (`reportOrRefuse`).
679
+ // ── Extract document drafts: an edit to a taxonomy someone left an unsaved
680
+ // Schema Editor draft on is refused; dropping the draft discards it. ──
681
+ const drafts = extractDraftFindings(originalNodes, allNodes, options.baseline && [
682
+ ...(options.baseline.nodes ?? []),
683
+ ...Object.values(options.baseline.subflows ?? {}).flatMap((sf) => sf?.nodes ?? []),
684
+ ]);
673
685
  const findings = [
686
+ ...drafts.discarded,
674
687
  ...superseded.findings,
675
688
  ...(options.baseline ? roundTripFindings(original, options.baseline, result, superseded.rootVariables) : []),
676
689
  ...entryPointRepairs,
@@ -685,7 +698,7 @@ function mergeFlowFindings(original, edited, options) {
685
698
  edited: subflowEdited.get(key) ?? new Set(),
686
699
  })),
687
700
  ], authored);
688
- return { result, findings, agentFindings };
701
+ return { result, findings, agentFindings, draftRefusals: drafts.refused };
689
702
  }
690
703
  /**
691
704
  * Replace a non-GUID root `entryPointId` with the edited compile's GUID: publish
@@ -6,4 +6,4 @@ export declare const documentFlowFamily: FlowNodeFamily;
6
6
  * The IDP processor rules, for `compile` (`idp-processor-files.ts`) and
7
7
  * `bindings_v2.json`: pure, and not part of the public surface.
8
8
  */
9
- export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, type IdpProcessorBindingRow, type WorkflowNodeLike, } from './idp-processor.js';
9
+ export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, type IdpProcessorBindingRow, type WorkflowNodeLike, } from './idp-processor.js';
@@ -11,4 +11,4 @@ export const documentFlowFamily = {
11
11
  * The IDP processor rules, for `compile` (`idp-processor-files.ts`) and
12
12
  * `bindings_v2.json`: pure, and not part of the public surface.
13
13
  */
14
- export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, } from './idp-processor.js';
14
+ export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, } from './idp-processor.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.124.11",
3
+ "version": "6.124.12",
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",
@@ -128,5 +128,5 @@
128
128
  "@types/node": "^22.7.0",
129
129
  "esbuild": "^0.28.1"
130
130
  },
131
- "gitref": "0b448e1f428f388337994691c97be736a75984df"
131
+ "gitref": "a60735460ba3ff5356cc66cdfa31151cdd83713f"
132
132
  }