@uipath/maestro-builder-sdk 6.17.3 → 6.17.4

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.
@@ -96,7 +96,8 @@ export function connectorCheckOpts(library, bindings, inputErrors = (rc, inputs,
96
96
  },
97
97
  // The refusal compile throws for an operation it cannot resolve, with its
98
98
  // code and text: CONNECTOR_NOT_IN_LIBRARY, CONNECTOR_OBJECT_REQUIRED,
99
- // CONNECTOR_OBJECT_NOT_GENERIC.
99
+ // CONNECTOR_OBJECT_NOT_GENERIC, CONNECTOR_LIBRARY_ENTRY_UNREADABLE, or
100
+ // CONNECTOR_RESOLVE_FAILED for any other throw.
100
101
  connectorResolveError: (spec) => {
101
102
  const r = resolve(spec);
102
103
  return 'error' in r ? r.error : undefined;
@@ -114,11 +115,19 @@ export function connectorCheckOpts(library, bindings, inputErrors = (rc, inputs,
114
115
  ...(bindings ? { bindings } : {}),
115
116
  };
116
117
  }
118
+ /** `check`'s code for an untyped throw from `library.resolve`; see {@link connectorResolver}. */
119
+ const CONNECTOR_RESOLVE_FAILED = 'CONNECTOR_RESOLVE_FAILED';
117
120
  /**
118
121
  * `library.resolve` for one connector step, memoized per step for the life of
119
- * one check's options. A {@link ConnectorResolveError} is the refusal compile
120
- * throws and becomes `error`; anything else thrown is not a verdict about the
121
- * author's source and stays "unknown", as before.
122
+ * one check's options.
123
+ *
124
+ * This is the exact call `serialize` makes, so ANY throw here is a throw compile
125
+ * makes too, and becomes `error`. A {@link ConnectorResolveError} keeps its own
126
+ * code (CONNECTOR_NOT_IN_LIBRARY, CONNECTOR_LIBRARY_ENTRY_UNREADABLE, …).
127
+ * Anything else, which `library.resolve` does not throw on purpose, is reported
128
+ * as CONNECTOR_RESOLVE_FAILED with its message. Treating an untyped throw as
129
+ * "unknown" used to let `check` pass a step `compile` then died on (#1015); the
130
+ * event twin, `eventResolveErrorFor`, already reported every throw.
122
131
  */
123
132
  function connectorResolver(library) {
124
133
  const memo = new Map();
@@ -132,7 +141,7 @@ function connectorResolver(library) {
132
141
  catch (error) {
133
142
  r = error instanceof ConnectorResolveError
134
143
  ? { error: { code: error.code, message: error.message } }
135
- : { unknown: true };
144
+ : { error: { code: CONNECTOR_RESOLVE_FAILED, message: error instanceof Error ? error.message : String(error) } };
136
145
  }
137
146
  memo.set(id, r);
138
147
  }
@@ -225,7 +225,12 @@ export type ConnectorResolveCode =
225
225
  /** A GENERIC operation (one entry per object) named without an `object`. */
226
226
  | 'CONNECTOR_OBJECT_REQUIRED'
227
227
  /** An `object` on a single, non-generic operation. */
228
- | 'CONNECTOR_OBJECT_NOT_GENERIC';
228
+ | 'CONNECTOR_OBJECT_NOT_GENERIC'
229
+ /**
230
+ * The index lists the operation, but its entry file or `.v1def.json` sidecar is
231
+ * missing or not valid JSON: the library on disk is incomplete (#1015).
232
+ */
233
+ | 'CONNECTOR_LIBRARY_ENTRY_UNREADABLE';
229
234
  /**
230
235
  * The refusal {@link Library.resolve} throws, with a `code` for each reason.
231
236
  *
@@ -827,8 +827,13 @@ export class Library {
827
827
  }
828
828
  build(dir, e, nodeType, opts = {}) {
829
829
  const entryPath = join(dir, e.path);
830
- const entry = JSON.parse(readFileSync(entryPath, 'utf8'));
831
- const v1def = readV1def(entryPath);
830
+ // The two files the index row promises. A missing or corrupt one is a fault in
831
+ // the library on disk, not in the author's source, but compile cannot go on
832
+ // without it, so it is a typed refusal like the others: `check` reports it with
833
+ // the same code and text instead of passing a step compile then dies on with a
834
+ // bare ENOENT (#1015).
835
+ const entry = readLibraryFile(nodeType, entryPath, () => JSON.parse(readFileSync(entryPath, 'utf8')));
836
+ const v1def = readLibraryFile(nodeType, v1defPathOf(entryPath), () => readV1def(entryPath));
832
837
  // A stamped object (case 4) reaches here with the index entry's `objectName`
833
838
  // replaced but the sibling's FILE on disk — so restate the object and derive
834
839
  // the endpoint from the sibling's own template, rather than shipping a node
@@ -944,6 +949,33 @@ function deriveObjectPath(operation, objectName) {
944
949
  }
945
950
  return out;
946
951
  }
952
+ /** The `.v1def.json` sidecar path beside a library entry file. */
953
+ function v1defPathOf(entryPath) {
954
+ return entryPath.replace(/\.json$/, '.v1def.json');
955
+ }
956
+ /**
957
+ * Read one file an index row points at, turning a missing or unparsable file
958
+ * into {@link ConnectorResolveError} `CONNECTOR_LIBRARY_ENTRY_UNREADABLE`.
959
+ *
960
+ * The library build refuses to write an entry without its sidecar
961
+ * (`registry/library-build/plan.ts`), so this only fires for a library that was
962
+ * damaged after it was built: an interrupted pull, a hand-edited overlay. The
963
+ * remedy is the same either way: rebuild the layer the file belongs to.
964
+ */
965
+ function readLibraryFile(nodeType, path, read) {
966
+ try {
967
+ return read();
968
+ }
969
+ catch (error) {
970
+ const message = error instanceof Error ? error.message : String(error);
971
+ // ENOENT already names the path; a JSON SyntaxError does not.
972
+ const reason = message.includes(path) ? message : `${path}: ${message}`;
973
+ throw new ConnectorResolveError('CONNECTOR_LIBRARY_ENTRY_UNREADABLE', `connector library entry for ${nodeType} is unreadable: ${reason}. The library index lists `
974
+ + `this operation, but the file is missing or not valid JSON, so the library on disk is incomplete. `
975
+ + `Refresh it with \`${PULL_COMMAND}\`; if the file is in the \`connectors-local\` overlay, `
976
+ + `re-run the \`${prepareCommand()}\` that wrote it.`);
977
+ }
978
+ }
947
979
  /**
948
980
  * Read the `.v1def.json` sidecar beside a library entry file, with a connection
949
981
  * definition's `model.bindings.resource` in the designer's canonical casing.
@@ -961,7 +993,7 @@ function deriveObjectPath(operation, objectName) {
961
993
  * validate and debug — which fold the case — passed.
962
994
  */
963
995
  function readV1def(entryPath) {
964
- const raw = JSON.parse(readFileSync(entryPath.replace(/\.json$/, '.v1def.json'), 'utf8'));
996
+ const raw = JSON.parse(readFileSync(v1defPathOf(entryPath), 'utf8'));
965
997
  const v1def = Array.isArray(raw) ? raw[0] : raw;
966
998
  const bindings = v1def?.model?.bindings;
967
999
  if (typeof bindings?.resource === 'string' && bindings.resource.toLowerCase() === 'connection') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.17.3",
3
+ "version": "6.17.4",
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",
@@ -92,5 +92,5 @@
92
92
  "@types/node": "^22.7.0",
93
93
  "esbuild": "^0.28.1"
94
94
  },
95
- "gitref": "8da4aeeb1592a342b2ac705939e646cd77baa891"
95
+ "gitref": "6a0dfa03e18d92bd2452c96704c1c80fa122fc11"
96
96
  }