@uipath/maestro-builder-sdk 6.124.14 → 6.124.16

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.
package/dist/merge-cli.js CHANGED
@@ -89,6 +89,9 @@ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSy
89
89
  import { inlineAgentResources, mergeBindingsV2, projectBindingRows, refreshInlineAgentRows } from './bindings-v2.js';
90
90
  import { readBindingsV2, readInlineAgentFiles } from './bindings-v2-files.js';
91
91
  import { readSolutionProjects } from './solution-projects-files.js';
92
+ import { provisionIdpProcessors } from './idp-processor-files.js';
93
+ import { collectWorkflowNodes, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, withIdpProcessorRows } from './nodes/document/flow/family.js';
94
+ import { stableJson } from './merge-variables.js';
92
95
  import { basename, dirname, join, relative, resolve } from 'node:path';
93
96
  import { MergeRefusedError, mergeFlowWithSidecars } from './merge.js';
94
97
  import { sidecarSetFromList } from './merge-sidecars.js';
@@ -156,7 +159,7 @@ export function sidecarsBeside(flowPath) {
156
159
  * as it will stand once the candidate is installed: the original's files, with
157
160
  * merge's writes over them and its removals taken out.
158
161
  */
159
- function projectBindings(projectDir, originalPath, mergedFlow, writes, removals) {
162
+ function projectBindings(projectDir, originalPath, mergedFlow, writes, removals, processorNames) {
160
163
  if (!existsSync(join(projectDir, 'project.uiproj')))
161
164
  return undefined;
162
165
  const self = resolve(originalPath);
@@ -220,14 +223,20 @@ function projectBindings(projectDir, originalPath, mergedFlow, writes, removals)
220
223
  const existing = readBindingsV2(join(projectDir, 'bindings_v2.json'));
221
224
  const current = existing?.resources ?? [];
222
225
  const derived = mainElsewhere ? undefined : projectBindingRows(rowFlows);
226
+ // The `idpProcessor` row of each processor the flows' Extract document nodes
227
+ // name, as compile and pack derive them (#1984).
228
+ const processorRows = derived
229
+ ? rowFlows.flatMap((f) => idpProcessorBindingRows(f.flow && typeof f.flow === 'object' ? f.flow : {}, processorNames))
230
+ : [];
223
231
  const declares = (derived?.connections.length ?? 0) > 0 || (derived?.entities.length ?? 0) > 0
224
- || agents.some((a) => inlineAgentResources(a).length > 0);
232
+ || processorRows.length > 0 || agents.some((a) => inlineAgentResources(a).length > 0);
225
233
  if (existing === undefined && !declares)
226
234
  return undefined;
227
235
  const base = derived
228
236
  ? mergeBindingsV2(existing, derived.connections, derived.entities, { keepUnderived: derived.unreadable.length > 0 }).resources
229
237
  : current;
230
- const after = refreshInlineAgentRows(base, agents, removedBodies);
238
+ const refreshed = refreshInlineAgentRows(base, agents, removedBodies);
239
+ const after = derived ? withIdpProcessorRows(refreshed, processorRows, { keepUnderived: derived.unreadable.length > 0 }) : refreshed;
231
240
  const settled = (rows) => JSON.stringify(rows.map((r) => JSON.stringify(r)).sort());
232
241
  if (settled(after) === settled(current))
233
242
  return undefined;
@@ -629,6 +638,19 @@ export async function run(argv) {
629
638
  return 1;
630
639
  }
631
640
  const flow = merged.flow;
641
+ // Each Extract document node the merge took from the edit, or gave the key
642
+ // compile minted (merge.ts `provisionKeylessExtractNodes`): its IDP processor's
643
+ // resource file in the solution and its name on the node, as compile leaves
644
+ // them (#1984), so validate and pack pass with no CLI step after merge. Only
645
+ // for the flow the project packs, by compile's rule; a candidate written
646
+ // elsewhere must not rewrite the solution's processors. A node kept from the
647
+ // original whole is left as it is, name and resource file included.
648
+ const outProject = flowProjectOf(resolve(out));
649
+ const outMain = outProject !== undefined ? projectMainFlow(outProject).file : undefined;
650
+ const packsThisFlow = outProject !== undefined
651
+ && (outMain !== undefined ? resolve(outMain) === resolve(out) : outProject === resolve(outDir));
652
+ const touched = packsThisFlow ? touchedExtractNodes(original, flow) : [];
653
+ const processors = touched.length > 0 ? provisionIdpProcessors({ nodes: touched }, outProject) : undefined;
632
654
  mkdirSync(outDir, { recursive: true });
633
655
  writeJsonFile(out, flow);
634
656
  console.log(`flow-merge: wrote ${basename(out)} (${(flow.nodes ?? []).length} nodes, ${(flow.edges ?? []).length} edges)`);
@@ -645,6 +667,12 @@ export async function run(argv) {
645
667
  writeJsonFile(target, sidecar.json);
646
668
  console.log(`flow-merge: wrote ${sidecar.path} (carries ${sidecar.carried.join(', ')})`);
647
669
  }
670
+ for (const path of processors?.written ?? [])
671
+ console.log(`flow-merge: wrote ${path} (IDP processor)`);
672
+ for (const why of processors?.skipped ?? [])
673
+ console.error(`flow-merge: did not write the IDP processor ${why}`);
674
+ if (processors?.pending !== undefined)
675
+ console.log(`flow-merge: ${processors.pending}`);
648
676
  for (const { nodeId, inputs } of merged.onNodes) {
649
677
  console.log(`flow-merge: carried the agent.json edit onto embedded agent "${nodeId}" (${inputs.map((k) => `inputs.${k}`).join(', ')})`);
650
678
  }
@@ -661,7 +689,7 @@ export async function run(argv) {
661
689
  });
662
690
  // Derived before anything is deleted: a removed resource's row is matched by
663
691
  // the body read from its file.
664
- const bindingsV2 = projectBindings(originalDir, originalPath, flow, merged.sidecars, removals);
692
+ const bindingsV2 = projectBindings(originalDir, originalPath, flow, merged.sidecars, removals, processors?.namesByKey);
665
693
  // Written over the original, merge deletes what it has just made unreferenced
666
694
  // itself (#1995): each agent resource directory the edit removed, and, for a
667
695
  // split original now written as one file, its part files. Only paths it can
@@ -741,7 +769,7 @@ export async function run(argv) {
741
769
  }
742
770
  if (bindingsV2 !== undefined) {
743
771
  writeJsonFile(join(outDir, 'bindings_v2.json'), bindingsV2);
744
- console.log('flow-merge: wrote bindings_v2.json (connection and agent resource rows, re-derived as compile does)');
772
+ console.log('flow-merge: wrote bindings_v2.json (connection, IDP processor and agent resource rows, re-derived as compile does)');
745
773
  }
746
774
  // Written over the original: point the source's stamp at the merged file, so the
747
775
  // next edit-and-merge round on the same source passes the check. Its digest is
@@ -788,6 +816,21 @@ export async function run(argv) {
788
816
  });
789
817
  return 0;
790
818
  }
819
+ /**
820
+ * The merged flow's Extract document nodes that differ from the original's node
821
+ * of the same id, or that the original lacks: the ones merge took from the edit
822
+ * or gave a processor key. Root and subflows; the objects are `merged`'s own,
823
+ * so provisioning them writes into the merged flow.
824
+ */
825
+ function touchedExtractNodes(original, merged) {
826
+ const before = new Map(collectWorkflowNodes(original).map((n) => [n.id, n]));
827
+ return collectWorkflowNodes(merged).filter((n) => {
828
+ if (n.type !== DYNAMIC_EXTRACT_TYPE)
829
+ return false;
830
+ const was = before.get(n.id);
831
+ return was === undefined || stableJson(was) !== stableJson(n);
832
+ });
833
+ }
791
834
  /**
792
835
  * The error for a refusal on an untouched node that restoring it from the
793
836
  * original would not undo, with the step to take: a crash is an SDK defect;
@@ -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' | 'extract-draft';
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' | 'processor-provisioned' | 'taxonomy-ids-minted';
37
37
  /** The finding, phrased for the author, naming the node, edge or row. */
38
38
  message: string;
39
39
  /**
@@ -41,7 +41,8 @@ export interface MergeFinding {
41
41
  * `binding-removed`, which leave the merged file doing what the original does,
42
42
  * for `agent-embedded-edit`, which reports what merge did not carry, for
43
43
  * `outputs-superseded`, which reports a declaration merge corrected, and for
44
- * `entry-point-repaired`, which reports a fix merge made.
44
+ * `entry-point-repaired`, `processor-provisioned` and `taxonomy-ids-minted`,
45
+ * which report a fix merge made.
45
46
  */
46
47
  refuses: boolean;
47
48
  }
package/dist/merge.js CHANGED
@@ -109,6 +109,7 @@ 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
111
  import { extractDraftFindings } from './merge-extract-draft.js';
112
+ import { DYNAMIC_EXTRACT_TYPE, fillMissingTaxonomyIds, isIdpProcessorReadOnly, readIdpProcessorFolderPath, readIdpProcessorKey } from './nodes/document/flow/family.js';
112
113
  import { byId, isKept, nodeUnchanged, subflowsTakenFromEdited } from './edit-scope.js';
113
114
  export { MergeRefusedError } from './merge-roundtrip.js';
114
115
  /**
@@ -578,6 +579,14 @@ function mergeFlowFindings(original, edited, options) {
578
579
  if (options.baseline)
579
580
  keepOriginalSourcesInSubflows(original, takenEntries, options.baseline);
580
581
  const subflowScopes = Object.values(result.subflows);
582
+ // ── Processors: an Extract document node that authors a processor but names
583
+ // none gets the key the edited compile minted for it, kept or edited
584
+ // (provisionKeylessExtractNodes). ──
585
+ const processorRepairs = provisionKeylessExtractNodes([...finalNodes, ...subflowScopes.flatMap((sf) => sf?.nodes ?? [])], byId([...(edited.nodes ?? []), ...Object.values(edited.subflows ?? {}).flatMap((sf) => sf?.nodes ?? [])]));
586
+ // ── Taxonomy ids: an Extract document group or field the merged node leaves
587
+ // without an id gets the one the edited compile minted for it, kept or
588
+ // edited (mintMissingTaxonomyIds). ──
589
+ const taxonomyRepairs = mintMissingTaxonomyIds([...finalNodes, ...subflowScopes.flatMap((sf) => sf?.nodes ?? [])], byId([...(edited.nodes ?? []), ...Object.values(edited.subflows ?? {}).flatMap((sf) => sf?.nodes ?? [])]), edited.id ?? original.id ?? '');
581
590
  // ── Variables: the same delta as nodes, per entry — what the author did not
582
591
  // change stays the original's, so compile's own spellings (an added
583
592
  // `name`, a re-derived End output type) do not reach the file (#1261).
@@ -687,6 +696,8 @@ function mergeFlowFindings(original, edited, options) {
687
696
  ...superseded.findings,
688
697
  ...(options.baseline ? roundTripFindings(original, options.baseline, result, superseded.rootVariables) : []),
689
698
  ...entryPointRepairs,
699
+ ...processorRepairs,
700
+ ...taxonomyRepairs,
690
701
  ...mergedFileFindings(result, original),
691
702
  ];
692
703
  const agentFindings = (authored) => embeddedAgentFindings(!!options.baseline, [
@@ -722,6 +733,80 @@ function repairEntryPointIds(nodes, editedNodes) {
722
733
  }
723
734
  return out;
724
735
  }
736
+ /**
737
+ * Give each Extract document node that authors a processor but names none the
738
+ * `inputs.processorKey` the edited compile minted for it, the repair an older
739
+ * `uip`'s `nodes provision` made.
740
+ *
741
+ * Compile mints a key for every such step (one per node, the same on every
742
+ * recompile), so the no-edit baseline carries the same key as the edit, and
743
+ * the delta merge read the key as unchanged and kept the original's keyless
744
+ * node: `flow validate` then refused the merged file and a deployed run
745
+ * extracted nothing. A node kept from the original gets the key too, since
746
+ * that is the repair a decompile -> merge round trip exists to make. A
747
+ * read-only mirror (`processorReadOnly`) and a link to a tenant processor
748
+ * (`processorFolderPath`) author nothing, so they get no key, as compile mints
749
+ * them none. A key the node already names is never replaced.
750
+ *
751
+ * For instance, an original `extractInvoice1` with no key merges to
752
+ * `"processorKey": "<the key compile minted for extractInvoice1>"`; `merge-cli`
753
+ * then writes its resource file when the flow is the solution's.
754
+ */
755
+ function provisionKeylessExtractNodes(nodes, editedNodes) {
756
+ const out = [];
757
+ for (const node of nodes) {
758
+ if (node.type !== DYNAMIC_EXTRACT_TYPE || !isRecord(node.inputs))
759
+ continue;
760
+ const inputs = node.inputs;
761
+ if (readIdpProcessorKey(inputs) !== undefined)
762
+ continue;
763
+ if (isIdpProcessorReadOnly(inputs) || readIdpProcessorFolderPath(inputs) !== undefined)
764
+ continue;
765
+ const e = editedNodes.get(node.id);
766
+ if (e?.type !== DYNAMIC_EXTRACT_TYPE)
767
+ continue;
768
+ const minted = readIdpProcessorKey(e.inputs);
769
+ if (minted === undefined)
770
+ continue;
771
+ inputs.processorKey = minted;
772
+ out.push({
773
+ kind: 'processor-provisioned', refuses: false,
774
+ message: `Extract document node "${node.id}" named no IDP processor (inputs.processorKey); gave it ${minted}, the key compile minted for it.`,
775
+ });
776
+ }
777
+ return out;
778
+ }
779
+ /**
780
+ * Give each Extract document group and field that has no taxonomy id the one
781
+ * the edited compile minted for it (`x-uipath-field-group-id`,
782
+ * `x-uipath-field-id`), the way `uip maestro flow nodes schema set` filled them.
783
+ *
784
+ * Compile mints an id for every entry that has none, the same one on every
785
+ * recompile, so the no-edit baseline carries the same id as the edit, and the
786
+ * delta merge read it as unchanged and kept the original's id-less entry:
787
+ * `flow validate` kept warning, with no CLI-free way to repair it (#2259). A
788
+ * node kept from the original gets the ids too, since that is the repair a
789
+ * decompile -> merge round trip exists to make. An id the node names is never
790
+ * replaced, and a node with every id is left as it is.
791
+ */
792
+ function mintMissingTaxonomyIds(nodes, editedNodes, flowId) {
793
+ const out = [];
794
+ for (const node of nodes) {
795
+ const filled = fillMissingTaxonomyIds(node, editedNodes.get(node.id), flowId);
796
+ if (filled === undefined)
797
+ continue;
798
+ const parts = [
799
+ filled.groupIds > 0 ? `${filled.groupIds} field group id(s) (x-uipath-field-group-id)` : '',
800
+ filled.fieldIds > 0 ? `${filled.fieldIds} field id(s) (x-uipath-field-id)` : '',
801
+ filled.parentGroupIds > 0 ? `${filled.parentGroupIds} parent group reference(s)` : '',
802
+ ].filter((p) => p.length > 0);
803
+ out.push({
804
+ kind: 'taxonomy-ids-minted', refuses: false,
805
+ message: `Extract document node "${node.id}" had taxonomy entries with no id; gave them ${parts.join(', ')}, the ones compile minted.`,
806
+ });
807
+ }
808
+ return out;
809
+ }
725
810
  /**
726
811
  * Whether the merged node for `orig` must be built from the original rather than
727
812
  * taken from `edited`: the original is an embedded agent and the edited node is
@@ -3,7 +3,9 @@ import type { FlowNodeFamily } from '../../../flow-node-type.js';
3
3
  export { isIxpNodeType } from './ixp.js';
4
4
  export declare const documentFlowFamily: FlowNodeFamily;
5
5
  /**
6
- * The IDP processor rules, for `compile` (`idp-processor-files.ts`) and
7
- * `bindings_v2.json`: pure, and not part of the public surface.
6
+ * The IDP processor rules, for `compile` and `merge` (`idp-processor-files.ts`,
7
+ * `merge.ts`) and `bindings_v2.json`: pure, and not part of the public surface.
8
8
  */
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';
9
+ export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorReadOnly, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorFolderPath, readIdpProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, type IdpProcessorBindingRow, type WorkflowNodeLike, } from './idp-processor.js';
10
+ /** The taxonomy ids `merge` gives an Extract document node (#2259): pure, and not part of the public surface. */
11
+ export { fillMissingTaxonomyIds, type FilledTaxonomyIds } from './merge-taxonomy.js';
@@ -8,7 +8,9 @@ export const documentFlowFamily = {
8
8
  diagnostics: { ...DOCUMENT_DIAGNOSTICS, ...IXP_DIAGNOSTICS },
9
9
  };
10
10
  /**
11
- * The IDP processor rules, for `compile` (`idp-processor-files.ts`) and
12
- * `bindings_v2.json`: pure, and not part of the public surface.
11
+ * The IDP processor rules, for `compile` and `merge` (`idp-processor-files.ts`,
12
+ * `merge.ts`) and `bindings_v2.json`: pure, and not part of the public surface.
13
13
  */
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';
14
+ export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, DYNAMIC_EXTRACT_TYPE, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorReadOnly, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorFolderPath, readIdpProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, } from './idp-processor.js';
15
+ /** The taxonomy ids `merge` gives an Extract document node (#2259): pure, and not part of the public surface. */
16
+ export { fillMissingTaxonomyIds } from './merge-taxonomy.js';
@@ -0,0 +1,25 @@
1
+ /** A flow node as merge holds it: only what this module reads. */
2
+ export interface TaxonomyNodeLike {
3
+ id: string;
4
+ type?: string;
5
+ inputs?: unknown;
6
+ }
7
+ /** How many ids {@link fillMissingTaxonomyIds} wrote onto one node. */
8
+ export interface FilledTaxonomyIds {
9
+ groupIds: number;
10
+ fieldIds: number;
11
+ parentGroupIds: number;
12
+ }
13
+ /**
14
+ * Write onto `node` (MUTATED) each taxonomy id its schema document lacks: the
15
+ * id `edited` (the edited compile's node of the same id) has for the same
16
+ * entry, else the one compile mints for it from `flowId` and the node id.
17
+ * A nested group with no parent reference gets its parent's id. `undefined`
18
+ * when the node is not an Extract document node, carries an unsaved Schema
19
+ * Editor draft, or lacks no id.
20
+ *
21
+ * For instance, an original group `Invoice` with no `x-uipath-field-group-id`
22
+ * merges to `"x-uipath-field-group-id": "<the id compile minted for Invoice>"`,
23
+ * and its field `Total` gets the field id compile minted under that group.
24
+ */
25
+ export declare function fillMissingTaxonomyIds(node: TaxonomyNodeLike, edited: TaxonomyNodeLike | undefined, flowId: string): FilledTaxonomyIds | undefined;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The taxonomy ids `merge` gives an Extract document node (builder-sdk#2259):
3
+ * every field group and field the merged node leaves without an id gets the
4
+ * one the edited compile minted for the same entry.
5
+ *
6
+ * Compile mints an id for each group and field that has none
7
+ * ({@link settleTaxonomyIds}, the same id on every recompile). So the no-edit
8
+ * baseline and the edit carry the same minted id, the delta merge reads it as
9
+ * unchanged, and the merged node keeps the original's entry, which has none.
10
+ * Merge is the only SDK-route writer of an existing flow, so without this an
11
+ * id-less taxonomy kept failing `flow validate`'s taxonomy-id warnings.
12
+ *
13
+ * Only missing ids are written, in place: an id the merged node names is never
14
+ * replaced, nothing else in the document moves (no business check is dropped,
15
+ * no object is closed), and a node with every id is not touched. A node that
16
+ * carries an unsaved Schema Editor draft (`x-uipath-schema-editor-draft`) is not
17
+ * touched either: `uip maestro flow nodes schema set` refused to write one, and
18
+ * minting ids there would turn a no-edit merge into a change of a document
19
+ * someone is still editing. Pure: the flow core is portable (FB015).
20
+ */
21
+ import { DYNAMIC_EXTRACT_TYPE } from './idp-processor.js';
22
+ import { derivedTaxonomyMint, FIELD_GROUP_ID_EXTENSION, FIELD_ID_EXTENSION, isRecord, PARENT_FIELD_GROUP_ID_EXTENSION, readOutputSchema, SCHEMA_EDITOR_DRAFT_EXTENSION, settleTaxonomyIds, } from './taxonomy.js';
23
+ const present = (id) => id !== undefined && id.length > 0;
24
+ const isNested = (group) => group.segments.length > 1;
25
+ /** The node's `inputs.schemaDocument` when it is an Extract document node with an `outputSchema` object. */
26
+ function schemaDocumentOf(node) {
27
+ if (node?.type !== DYNAMIC_EXTRACT_TYPE || !isRecord(node.inputs))
28
+ return undefined;
29
+ const document = node.inputs.schemaDocument;
30
+ return isRecord(document) && isRecord(document.outputSchema) ? document : undefined;
31
+ }
32
+ /**
33
+ * Write onto `node` (MUTATED) each taxonomy id its schema document lacks: the
34
+ * id `edited` (the edited compile's node of the same id) has for the same
35
+ * entry, else the one compile mints for it from `flowId` and the node id.
36
+ * A nested group with no parent reference gets its parent's id. `undefined`
37
+ * when the node is not an Extract document node, carries an unsaved Schema
38
+ * Editor draft, or lacks no id.
39
+ *
40
+ * For instance, an original group `Invoice` with no `x-uipath-field-group-id`
41
+ * merges to `"x-uipath-field-group-id": "<the id compile minted for Invoice>"`,
42
+ * and its field `Total` gets the field id compile minted under that group.
43
+ */
44
+ export function fillMissingTaxonomyIds(node, edited, flowId) {
45
+ const document = schemaDocumentOf(node);
46
+ if (document === undefined || Object.hasOwn(document, SCHEMA_EDITOR_DRAFT_EXTENSION))
47
+ return undefined;
48
+ const groups = readOutputSchema(document.outputSchema).groups;
49
+ const lacks = groups.some((g) => !present(g.groupId) || (isNested(g) && !present(g.parentGroupId))
50
+ || g.fields.some((f) => !present(f.fieldId)));
51
+ if (!lacks)
52
+ return undefined;
53
+ // The ids compile would settle on for this document: its own, else the edited
54
+ // compile's for the same entry, else a fresh mint. Read, never written back
55
+ // whole: only the missing ones are copied onto the node.
56
+ const settled = settleTaxonomyIds(document, schemaDocumentOf(edited), derivedTaxonomyMint(flowId, node.id)).document;
57
+ const settledGroups = new Map(readOutputSchema(settled.outputSchema).groups.map((g) => [g.pathKey, g]));
58
+ const filled = { groupIds: 0, fieldIds: 0, parentGroupIds: 0 };
59
+ for (const group of groups) {
60
+ const s = settledGroups.get(group.pathKey);
61
+ if (s === undefined)
62
+ continue;
63
+ if (!present(group.groupId) && present(s.groupId)) {
64
+ group.node[FIELD_GROUP_ID_EXTENSION] = s.groupId;
65
+ filled.groupIds++;
66
+ }
67
+ if (isNested(group) && !present(group.parentGroupId) && present(s.parentGroupId)) {
68
+ group.node[PARENT_FIELD_GROUP_ID_EXTENSION] = s.parentGroupId;
69
+ filled.parentGroupIds++;
70
+ }
71
+ const settledFields = new Map(s.fields.map((f) => [f.name, f]));
72
+ for (const field of group.fields) {
73
+ const sf = settledFields.get(field.name);
74
+ if (present(field.fieldId) || sf === undefined || !present(sf.fieldId))
75
+ continue;
76
+ field.node[FIELD_ID_EXTENSION] = sf.fieldId;
77
+ filled.fieldIds++;
78
+ }
79
+ }
80
+ return filled.groupIds + filled.fieldIds + filled.parentGroupIds > 0 ? filled : undefined;
81
+ }
@@ -5,6 +5,11 @@ export declare const FIELD_GROUP_ID_EXTENSION = "x-uipath-field-group-id";
5
5
  export declare const FIELD_ID_EXTENSION = "x-uipath-field-id";
6
6
  /** Vendor extension naming the group a nested group hangs under. */
7
7
  export declare const PARENT_FIELD_GROUP_ID_EXTENSION = "x-uipath-parent-field-group-id";
8
+ /**
9
+ * Where the Studio Web Schema Editor parks an unsaved draft of the taxonomy,
10
+ * beside the saved one (flow-schema `IXP_SCHEMA_EDITOR_DRAFT_EXTENSION`).
11
+ */
12
+ export declare const SCHEMA_EDITOR_DRAFT_EXTENSION = "x-uipath-schema-editor-draft";
8
13
  /** Vendor extension holding business checks, which reference fields by id. */
9
14
  export declare const BUSINESS_CHECKS_EXTENSION = "x-uipath-business-checks";
10
15
  /** Joins the segments of a nested field group's flattened property key: `Invoice > Line items`. */
@@ -22,6 +22,11 @@ export const FIELD_GROUP_ID_EXTENSION = 'x-uipath-field-group-id';
22
22
  export const FIELD_ID_EXTENSION = 'x-uipath-field-id';
23
23
  /** Vendor extension naming the group a nested group hangs under. */
24
24
  export const PARENT_FIELD_GROUP_ID_EXTENSION = 'x-uipath-parent-field-group-id';
25
+ /**
26
+ * Where the Studio Web Schema Editor parks an unsaved draft of the taxonomy,
27
+ * beside the saved one (flow-schema `IXP_SCHEMA_EDITOR_DRAFT_EXTENSION`).
28
+ */
29
+ export const SCHEMA_EDITOR_DRAFT_EXTENSION = 'x-uipath-schema-editor-draft';
25
30
  /** Vendor extension holding business checks, which reference fields by id. */
26
31
  export const BUSINESS_CHECKS_EXTENSION = 'x-uipath-business-checks';
27
32
  /** Joins the segments of a nested field group's flattened property key: `Invoice > Line items`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.124.14",
3
+ "version": "6.124.16",
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": "441c80145b3339941207ba6ad30b81ae6af00a75"
131
+ "gitref": "69972fc73389bf91d26f06a02279ad810879b6bc"
132
132
  }