@uipath/maestro-builder-sdk 6.66.11 → 6.66.13

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.
@@ -48,3 +48,10 @@ export declare function applyPreservation(result: Record<string, unknown>, prese
48
48
  * the payload does not.
49
49
  */
50
50
  export declare function followRenames(result: Record<string, unknown>, preservation: CaseJsonPreservation): CaseJsonPreservation;
51
+ /**
52
+ * Rename ids in one string: the whole value, or a whole id inside it, bounded
53
+ * by characters that cannot be part of an id (`"Stage_A-tB"`, `"=vars.vSlot"`).
54
+ * `trigger_1` does not match inside `trigger_10` or `trigger_1_x`. One pass, so
55
+ * a replacement is never replaced again.
56
+ */
57
+ export declare function idRenamer(renames: ReadonlyMap<string, string>): (value: string) => string;
@@ -711,6 +711,15 @@ function applyPreservedIdentities(result, preservation) {
711
711
  const identities = preservation.identities;
712
712
  if (!identities)
713
713
  return;
714
+ // Two kinds of id are restored:
715
+ // - an ELEMENT id (case, trigger, stage, task, condition, rule, SLA,
716
+ // escalation, root variable) is unique in the plan and other elements point
717
+ // at it (`elementId: "<stageId>-<taskId>"`, `exitToStageId`). `take` records
718
+ // the rename and `rewrite` follows it through the plan.
719
+ // - an io ROW id (a task's or a rule's `inputs[]` / `outputs[]` row) is only
720
+ // spelled by its own row, and the generated value repeats across owners:
721
+ // every subscription body row is `vbody`. `takeRow` renames inside that one
722
+ // row and never adds to the plan-wide map.
714
723
  const replacements = new Map();
715
724
  const take = (current, wanted) => {
716
725
  if (!current || !wanted || typeof current.id !== 'string')
@@ -718,6 +727,25 @@ function applyPreservedIdentities(result, preservation) {
718
727
  replacements.set(current.id, wanted);
719
728
  current.id = wanted;
720
729
  };
730
+ // Applied after `rewrite`, so a preserved row id is never itself rewritten.
731
+ const rowRenames = [];
732
+ const takeRow = (row, wanted, output) => {
733
+ if (!row || !wanted || typeof row.id !== 'string' || row.id === wanted)
734
+ return;
735
+ const was = row.id;
736
+ row.id = wanted;
737
+ rowRenames.push(() => {
738
+ if (row.var === was)
739
+ row.var = wanted;
740
+ if (row.originalVar === was)
741
+ row.originalVar = wanted;
742
+ if (row.target === `=${was}`)
743
+ row.target = `=${wanted}`;
744
+ // An input row's `value` is the value passed in, never its own id.
745
+ if (output && row.value === was)
746
+ row.value = wanted;
747
+ });
748
+ };
721
749
  const nodes = result.nodes;
722
750
  const stages = nodes.filter((node) => String(node.type).endsWith('Stage'));
723
751
  const bagField = CASE_FORMAT_PROFILE.waitConnectorRuleBagField;
@@ -762,14 +790,11 @@ function applyPreservedIdentities(result, preservation) {
762
790
  return;
763
791
  if (target && typeof row.id === 'string' && row.id !== currentId && heldOutputIds.has(row.id))
764
792
  return;
765
- take(target, row.id);
793
+ takeRow(target, row.id, true);
766
794
  if (target && typeof row.id === 'string' && typeof currentId === 'string') {
767
795
  heldOutputIds.delete(currentId);
768
796
  heldOutputIds.add(row.id);
769
797
  }
770
- if (typeof currentId === 'string' && typeof row.id === 'string' && target?.value === currentId) {
771
- target.value = row.id;
772
- }
773
798
  });
774
799
  };
775
800
  const takeConditions = (current, wanted) => {
@@ -804,7 +829,7 @@ function applyPreservedIdentities(result, preservation) {
804
829
  const task = stageTask(stage, taskIdentity.name);
805
830
  take(task, taskIdentity.id);
806
831
  takeConditions(task?.entryConditions, taskIdentity.entryConditions);
807
- (taskIdentity.inputs ?? []).forEach((row, index) => take(task?.data?.inputs?.[index], row.id));
832
+ (taskIdentity.inputs ?? []).forEach((row, index) => takeRow(task?.data?.inputs?.[index], row.id, false));
808
833
  takeOutputRows(task?.data?.outputs ?? [], taskIdentity.outputs ?? []);
809
834
  }));
810
835
  }
@@ -818,15 +843,7 @@ function applyPreservedIdentities(result, preservation) {
818
843
  return;
819
844
  take(variables[lane]?.find((candidate) => candidate.name === row.name), row.id);
820
845
  });
821
- const longestFirst = [...replacements].sort((a, b) => b[0].length - a[0].length);
822
- const replace = (value) => {
823
- if (replacements.has(value))
824
- return replacements.get(value);
825
- let replaced = value;
826
- for (const [current, wanted] of longestFirst)
827
- replaced = replaced.replaceAll(current, wanted);
828
- return replaced;
829
- };
846
+ const replace = idRenamer(replacements);
830
847
  // Every field that carries an id GENERATED by this serialize pass has to be
831
848
  // rewritten when preservation renames the node that id belongs to. Missing one
832
849
  // leaves a reference pointing at an id nothing has any more.
@@ -888,6 +905,8 @@ function applyPreservedIdentities(result, preservation) {
888
905
  rewrite(result);
889
906
  for (const { row, source } of preservedOutputSources)
890
907
  row.source = source;
908
+ for (const rename of rowRenames)
909
+ rename();
891
910
  // An id hashed from a generated element id is re-minted from the preserved one,
892
911
  // wherever it is spelled, including inside a `=jsonString:` configuration.
893
912
  const reseeded = new Map();
@@ -899,6 +918,25 @@ function applyPreservedIdentities(result, preservation) {
899
918
  if (reseeded.size)
900
919
  reseed(result, reseeded);
901
920
  }
921
+ /**
922
+ * Rename ids in one string: the whole value, or a whole id inside it, bounded
923
+ * by characters that cannot be part of an id (`"Stage_A-tB"`, `"=vars.vSlot"`).
924
+ * `trigger_1` does not match inside `trigger_10` or `trigger_1_x`. One pass, so
925
+ * a replacement is never replaced again.
926
+ */
927
+ export function idRenamer(renames) {
928
+ const longestFirst = [...renames.keys()].sort((a, b) => b.length - a.length);
929
+ const asPattern = (id) => id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
930
+ const token = longestFirst.length
931
+ ? new RegExp(`(?<![\\w$])(?:${longestFirst.map(asPattern).join('|')})(?![\\w$])`, 'g')
932
+ : undefined;
933
+ return (value) => {
934
+ const whole = renames.get(value);
935
+ if (whole !== undefined)
936
+ return whole;
937
+ return token ? value.replace(token, (id) => renames.get(id)) : value;
938
+ };
939
+ }
902
940
  function reseed(value, ids) {
903
941
  if (!value || typeof value !== 'object')
904
942
  return;
@@ -17,6 +17,8 @@ export type ConnectorResolveCode =
17
17
  * missing or not valid JSON: the library on disk is incomplete (#1015).
18
18
  */
19
19
  | 'CONNECTOR_LIBRARY_ENTRY_UNREADABLE'
20
+ /** The index row and its entry file name different objects for the operation. */
21
+ | 'CONNECTOR_LIBRARY_ENTRY_INCONSISTENT'
20
22
  /**
21
23
  * Flow only: the sidecar was synthesized from Integration Service by `registry
22
24
  * prepare` (no registry node exists), and a Flow node needs the registry's
@@ -147,12 +147,10 @@ export class Library {
147
147
  if (row)
148
148
  return this.pageOf(nodeType, layer, row);
149
149
  }
150
- const parts = nodeType.split('.');
151
- const eventNs = parts[2] === 'trigger' || parts[2] === 'event';
152
150
  const near = nearest(objectName ?? '', objects);
153
151
  throw new ConnectorResolveError('CONNECTOR_NOT_IN_LIBRARY', `connector ${nodeType} has no page for object "${objectName}"`
154
152
  + `${near ? ` (nearest: "${near}")` : ''}. ${describeObjects(objects)} If it is a connection-scoped object, run `
155
- + `\`${prepareCommand(eventNs ? parts[3] : parts[2], (eventNs ? parts.slice(4) : parts.slice(3)).join('.'), '--object', String(objectName))}\` `
153
+ + `\`${prepareFor(nodeType, '--object', String(objectName))}\` `
156
154
  + 'to prepare it, then describe again.');
157
155
  }
158
156
  /**
@@ -909,36 +907,24 @@ export class Library {
909
907
  // bare ENOENT (#1015).
910
908
  const entry = readLibraryFile(nodeType, entryPath, () => readJson(this.read, entryPath));
911
909
  const v1def = readLibraryFile(nodeType, v1defPathOf(entryPath), () => readV1def(this.read, entryPath));
912
- // A stamped object (case 4) reaches here with the index entry's `objectName`
913
- // replaced but the sibling's FILE on disk — so restate the object and derive
914
- // the endpoint from the sibling's own template, rather than shipping a node
915
- // whose `objectName` and `path` name two different objects.
916
- // The index and the definition file can disagree about which object the
917
- // operation addresses, and the definition is the stale side: for
918
- // `uipath-microsoft-outlook365.send-email` the index says `send-mail-v2`
919
- // (what the tenant's typecache reports, connector 1.39.0) while the
920
- // definition still says `send-mail` with `/hubs/productivity/send-mail`.
921
- // `build` reads the definition, so the compiled node dispatched the retired
922
- // path and the runtime SendTask failed — the whole external-outcome half of
923
- // one eval task, from a one-token disagreement.
924
- //
925
- // The index is the fresher side and the one resolution keys on, so restate
926
- // the object from it and re-derive the endpoint, exactly as the stamped
927
- // branch below does. Warned, not silent: it is upstream archive data, so the
928
- // author should see that the two sources disagreed. Unique in the current
929
- // archive (1 of 8035 entries).
910
+ // An index row and its definition that name different objects cannot be
911
+ // reconciled here: the object, path and parameters must come from one
912
+ // operation. Taking the index's path with the definition's parameters sent
913
+ // JSON to Outlook's multipart `send-mail-v2` (MST-17534).
930
914
  if (!opts.objectNameUnverified && entry.operation
931
915
  && typeof e.objectName === 'string' && e.objectName !== ''
932
916
  && typeof entry.operation.objectName === 'string'
933
917
  && entry.operation.objectName !== e.objectName) {
934
- const stale = entry.operation.objectName;
935
- const derived = deriveObjectPath(entry.operation, e.objectName);
936
- this.warn(` warn: connector ${nodeType}: the library index says objectName "${e.objectName}" but its `
937
- + `definition file says "${stale}". Using the index and deriving the endpoint`
938
- + (derived.path ? ` (${entry.operation.path} -> ${derived.path})` : '')
939
- + `; the definition is the stale side when these disagree.\n`);
940
- entry.operation = { ...entry.operation, objectName: e.objectName, ...derived };
918
+ throw new ConnectorResolveError('CONNECTOR_LIBRARY_ENTRY_INCONSISTENT', `connector library entry for ${nodeType} is inconsistent: index.json says objectName `
919
+ + `"${e.objectName}" but ${e.path} says "${entry.operation.objectName}" `
920
+ + `(${entry.operation.path ?? 'no path'}). The compiled node would call one operation with `
921
+ + `another's inputs. Refresh the library with \`${PULL_COMMAND} --force\`, or describe the `
922
+ + `operation from the live connection with \`${prepareFor(nodeType, ...(e.activityType === 'Generic' ? ['--object', e.objectName] : []))}\`.`);
941
923
  }
924
+ // A stamped object (case 4) reaches here with the index entry's `objectName`
925
+ // replaced but the sibling's FILE on disk — so restate the object and derive
926
+ // the endpoint from the sibling's own template, rather than shipping a node
927
+ // whose `objectName` and `path` name two different objects.
942
928
  if (opts.objectNameUnverified && entry.operation) {
943
929
  entry.operation = {
944
930
  ...entry.operation,
@@ -1052,6 +1038,12 @@ function libraryEntries(read, path) {
1052
1038
  cache?.set(path, entries);
1053
1039
  return entries;
1054
1040
  }
1041
+ /** The `registry prepare` command for a connector action or event `nodeType`. */
1042
+ function prepareFor(nodeType, ...rest) {
1043
+ const parts = nodeType.split('.');
1044
+ const eventNs = parts[2] === 'trigger' || parts[2] === 'event';
1045
+ return prepareCommand(eventNs ? parts[3] : parts[2], (eventNs ? parts.slice(4) : parts.slice(3)).join('.'), ...rest);
1046
+ }
1055
1047
  function readLibraryFile(nodeType, path, read) {
1056
1048
  try {
1057
1049
  return read();
@@ -165,6 +165,7 @@ export declare const REFUSALS: {
165
165
  readonly CONNECTOR_INPUT_MISSING: "draft";
166
166
  readonly CONNECTOR_INPUT_ROW_NO_TARGET: "lint";
167
167
  readonly CONNECTOR_INPUT_ROW_TARGET_UNKNOWN: "lint";
168
+ readonly CONNECTOR_LIBRARY_ENTRY_INCONSISTENT: "lowering";
168
169
  readonly CONNECTOR_LIBRARY_ENTRY_UNREADABLE: "lowering";
169
170
  readonly CONNECTOR_NODE_TYPE_INVALID: "lowering";
170
171
  readonly CONNECTOR_NOT_IN_LIBRARY: "lowering";
@@ -216,6 +216,7 @@ export const REFUSALS = {
216
216
  CONNECTOR_INPUT_MISSING: 'draft',
217
217
  CONNECTOR_INPUT_ROW_NO_TARGET: 'lint',
218
218
  CONNECTOR_INPUT_ROW_TARGET_UNKNOWN: 'lint',
219
+ CONNECTOR_LIBRARY_ENTRY_INCONSISTENT: 'lowering',
219
220
  CONNECTOR_LIBRARY_ENTRY_UNREADABLE: 'lowering',
220
221
  CONNECTOR_NODE_TYPE_INVALID: 'lowering',
221
222
  CONNECTOR_NOT_IN_LIBRARY: 'lowering',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.66.11",
3
+ "version": "6.66.13",
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",
@@ -100,5 +100,5 @@
100
100
  "@types/node": "^22.7.0",
101
101
  "esbuild": "^0.28.1"
102
102
  },
103
- "gitref": "308e41ca7b62e6bb7dda3a974c00fbee9141b757"
103
+ "gitref": "5d85b66f664b911c9c92a92e66a50abcc022da3b"
104
104
  }