@uipath/maestro-builder-sdk 6.104.1 → 6.105.1
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/bpmn/check-cli.js +2 -2
- package/dist/bpmn/decompile-cli.js +2 -3
- package/dist/bpmn/merge-cli.js +2 -3
- package/dist/case/decompile-cli.js +2 -3
- package/dist/check.js +3 -2
- package/dist/core/cli-library.d.ts +8 -0
- package/dist/core/cli-library.js +17 -3
- package/dist/core/library-cache.d.ts +7 -1
- package/dist/core/library-cache.js +23 -2
- package/dist/core/library.d.ts +1 -1
- package/dist/core/library.js +8 -3
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +1 -0
- package/dist/decompile-cli.js +6 -3
- package/dist/decompile-stamp.d.ts +7 -0
- package/dist/decompile-stamp.js +4 -1
- package/dist/flow-node-type.d.ts +2 -0
- package/dist/merge-cli.js +23 -8
- package/dist/nodes/connector/flow/node-type.js +9 -3
- package/dist/nodes/data-fabric/flow/check.d.ts +14 -0
- package/dist/nodes/data-fabric/flow/check.js +65 -0
- package/dist/nodes/data-fabric/flow/family.js +5 -2
- package/dist/registry/fetch/fetch-connectors.d.ts +8 -0
- package/dist/registry/fetch/fetch-connectors.js +32 -9
- package/dist/registry/fetch/fetch-definitions.d.ts +17 -0
- package/dist/registry/fetch/fetch-definitions.js +54 -9
- package/dist/registry/fetch/flow-requests.d.ts +16 -5
- package/dist/registry/fetch/flow-requests.js +28 -7
- package/dist/registry/fetch/with-fetched-definitions.d.ts +8 -0
- package/dist/registry/fetch/with-fetched-definitions.js +45 -18
- package/dist/registry/prepare/overlay.js +4 -1
- package/dist/registry/pull-cli.d.ts +6 -1
- package/dist/registry/pull-cli.js +33 -6
- package/dist/registry/search-cli.js +29 -4
- package/package.json +2 -2
|
@@ -16,17 +16,26 @@ import { catalogServesNothing, refreshRegistryCatalog, registryCatalog } from ".
|
|
|
16
16
|
import { INDEX_FILENAME } from "../prepare/overlay.js";
|
|
17
17
|
import { silentReporter } from "../reporter.js";
|
|
18
18
|
import { defaultUipClient } from "../uip/client.js";
|
|
19
|
-
import {
|
|
19
|
+
import { mapConcurrent } from "../concurrency.js";
|
|
20
|
+
import { loginScope } from "../prepare/catalog-absence.js";
|
|
21
|
+
import { loginStatusData } from "../uip/login-status.js";
|
|
22
|
+
import { FETCH_REFRESH_TIMEOUT_MS, FETCH_TIMEOUT_MS, boundedUipClient, fetchDefinitions, readNotServed, rememberNotServedQuietly, uipUnavailableReason, } from "./fetch-definitions.js";
|
|
20
23
|
/** Fetch every operation the tenant serves for `keys` into `overlayDir`. */
|
|
21
24
|
export async function fetchConnectors(keys, options) {
|
|
22
25
|
const empty = { fetched: [], notServed: [], failed: [], unlisted: [], modules: [] };
|
|
23
26
|
if (keys.length === 0)
|
|
24
27
|
return empty;
|
|
25
|
-
const client = options.client ?? defaultUipClient();
|
|
28
|
+
const client = boundedUipClient(options.client ?? defaultUipClient(), options.timeoutMs ?? FETCH_TIMEOUT_MS);
|
|
26
29
|
const reporter = options.reporter ?? silentReporter;
|
|
27
30
|
const unavailable = await uipUnavailableReason(client);
|
|
28
31
|
if (unavailable !== undefined)
|
|
29
32
|
return { ...empty, unavailable };
|
|
33
|
+
// A connector the catalog listed nothing for is remembered as a node type the
|
|
34
|
+
// tenant does not serve is (`.not-served.json`), so a decompile or merge
|
|
35
|
+
// re-run does not search and refresh the catalog for it again.
|
|
36
|
+
const scope = loginScope((await loginStatusData(client)).data);
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
const remembered = readNotServed(options.overlayDir, scope, now);
|
|
30
39
|
const requests = [];
|
|
31
40
|
const unlisted = [];
|
|
32
41
|
const failed = [];
|
|
@@ -34,12 +43,20 @@ export async function fetchConnectors(keys, options) {
|
|
|
34
43
|
// when it is older than 30 minutes or another tenant's. A connector it lists
|
|
35
44
|
// nothing for is believed only after one `registry pull --force`, as
|
|
36
45
|
// `prepare` does; a refresh that fails or is partial makes it a failure.
|
|
46
|
+
// Every key is looked up at once, and the ones listing nothing again after
|
|
47
|
+
// one shared refresh.
|
|
48
|
+
const sorted = [...new Set(keys)].filter((key) => !remembered.has(key)).sort();
|
|
49
|
+
const catalogs = await mapConcurrent(sorted, options.concurrency ?? 4, (key) => registryCatalog(client, key, options.timeoutMs));
|
|
50
|
+
const listsNothing = sorted.filter((_, i) => catalogs[i].failure === undefined && catalogServesNothing(catalogs[i]));
|
|
37
51
|
let refresh;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
if (listsNothing.length > 0) {
|
|
53
|
+
refresh = await refreshRegistryCatalog(client, options.timeoutMs ?? FETCH_REFRESH_TIMEOUT_MS);
|
|
54
|
+
const again = await mapConcurrent(listsNothing, options.concurrency ?? 4, (key) => registryCatalog(client, key, options.timeoutMs));
|
|
55
|
+
listsNothing.forEach((key, i) => { catalogs[sorted.indexOf(key)] = again[i]; });
|
|
56
|
+
}
|
|
57
|
+
for (const [i, key] of sorted.entries()) {
|
|
58
|
+
const catalog = catalogs[i];
|
|
59
|
+
if (refresh !== undefined && listsNothing.includes(key)) {
|
|
43
60
|
const doubt = !refresh.ok ? `the catalog refresh failed: ${refresh.reason}` : refresh.partial;
|
|
44
61
|
if (catalogServesNothing(catalog) && doubt !== undefined) {
|
|
45
62
|
failed.push({ nodeType: key, reason: `uip's catalog lists nothing for it, and ${doubt}` });
|
|
@@ -77,8 +94,14 @@ export async function fetchConnectors(keys, options) {
|
|
|
77
94
|
// Whenever the overlay holds anything, not only when this call added to it:
|
|
78
95
|
// a module deleted, or an overlay `prepare --json-only` wrote, still gets one,
|
|
79
96
|
// and a changed import specifier applies.
|
|
80
|
-
const modules = existsSync(join(options.overlayDir, INDEX_FILENAME))
|
|
97
|
+
const modules = options.modules !== false && existsSync(join(options.overlayDir, INDEX_FILENAME))
|
|
81
98
|
? regenerateDescriptors(options.overlayDir, options.importSpecifier)
|
|
82
99
|
: [];
|
|
83
|
-
|
|
100
|
+
rememberNotServedQuietly(options.overlayDir, scope, unlisted, now);
|
|
101
|
+
return {
|
|
102
|
+
...fetched,
|
|
103
|
+
failed: [...failed, ...fetched.failed],
|
|
104
|
+
unlisted: [...unlisted, ...[...new Set(keys)].filter((key) => remembered.has(key))].sort(),
|
|
105
|
+
modules,
|
|
106
|
+
};
|
|
84
107
|
}
|
|
@@ -19,8 +19,19 @@ export interface FetchDefinitionsOptions {
|
|
|
19
19
|
reporter?: Reporter;
|
|
20
20
|
/** Parallel `uip` calls. */
|
|
21
21
|
concurrency?: number;
|
|
22
|
+
/** Kill each `uip` call after this long; {@link FETCH_TIMEOUT_MS} when unset. */
|
|
22
23
|
timeoutMs?: number;
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* How long one `uip` call may take before the fetch gives up on it. A `uip`
|
|
27
|
+
* waiting on an auth prompt or a dead tenant would otherwise hang the compile
|
|
28
|
+
* that asked, with nothing said. The catalog refresh downloads the whole
|
|
29
|
+
* catalog, so it gets {@link FETCH_REFRESH_TIMEOUT_MS}.
|
|
30
|
+
*/
|
|
31
|
+
export declare const FETCH_TIMEOUT_MS = 60000;
|
|
32
|
+
export declare const FETCH_REFRESH_TIMEOUT_MS = 300000;
|
|
33
|
+
/** `client` with `timeoutMs` for every call that names none. */
|
|
34
|
+
export declare function boundedUipClient(client: UipClient, timeoutMs: number): UipClient;
|
|
24
35
|
export interface FetchDefinitionsResult {
|
|
25
36
|
/** Node types written into the overlay, sorted. */
|
|
26
37
|
fetched: string[];
|
|
@@ -45,6 +56,12 @@ export interface FetchDefinitionsResult {
|
|
|
45
56
|
export declare function fetchableNodeType(nodeType: string): string;
|
|
46
57
|
/** Why `uip` cannot be asked anything, or `undefined` when it is logged in. */
|
|
47
58
|
export declare function uipUnavailableReason(client: UipClient): Promise<string | undefined>;
|
|
59
|
+
/** How long a "the tenant does not serve it" answer is believed without asking again: `uip`'s own catalog lifetime. */
|
|
60
|
+
export declare const NOT_SERVED_TTL_MS: number;
|
|
61
|
+
export declare const NOT_SERVED_FILE = ".not-served.json";
|
|
62
|
+
export declare function readNotServed(overlayDir: string, scope: string | undefined, now: number): Set<string>;
|
|
63
|
+
/** {@link rememberNotServed}, which is only a cache: a write that fails costs a repeated lookup, nothing more. */
|
|
64
|
+
export declare function rememberNotServedQuietly(overlayDir: string, scope: string | undefined, nodeTypes: readonly string[], now: number): void;
|
|
48
65
|
/**
|
|
49
66
|
* Fetch every requested node type the tenant serves into `overlayDir`.
|
|
50
67
|
*
|
|
@@ -62,6 +62,32 @@ export function fetchDefinitionsEnabled(env = process.env) {
|
|
|
62
62
|
const value = env[FETCH_DEFINITIONS_ENV]?.trim().toLowerCase();
|
|
63
63
|
return value !== "0" && value !== "false";
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* How long one `uip` call may take before the fetch gives up on it. A `uip`
|
|
67
|
+
* waiting on an auth prompt or a dead tenant would otherwise hang the compile
|
|
68
|
+
* that asked, with nothing said. The catalog refresh downloads the whole
|
|
69
|
+
* catalog, so it gets {@link FETCH_REFRESH_TIMEOUT_MS}.
|
|
70
|
+
*/
|
|
71
|
+
export const FETCH_TIMEOUT_MS = 60_000;
|
|
72
|
+
export const FETCH_REFRESH_TIMEOUT_MS = 300_000;
|
|
73
|
+
/** `client` with `timeoutMs` for every call that names none. */
|
|
74
|
+
export function boundedUipClient(client, timeoutMs) {
|
|
75
|
+
return new BoundedUipClient(client, timeoutMs);
|
|
76
|
+
}
|
|
77
|
+
class BoundedUipClient {
|
|
78
|
+
inner;
|
|
79
|
+
timeoutMs;
|
|
80
|
+
constructor(inner, timeoutMs) {
|
|
81
|
+
this.inner = inner;
|
|
82
|
+
this.timeoutMs = timeoutMs;
|
|
83
|
+
}
|
|
84
|
+
run(argv, options = {}) {
|
|
85
|
+
return this.inner.run(argv, { ...options, timeoutMs: options.timeoutMs ?? this.timeoutMs });
|
|
86
|
+
}
|
|
87
|
+
close() {
|
|
88
|
+
this.inner.close?.();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
65
91
|
const EVENT_NS = "uipath.connector.event.";
|
|
66
92
|
const TRIGGER_NS = "uipath.connector.trigger.";
|
|
67
93
|
/**
|
|
@@ -72,7 +98,6 @@ const TRIGGER_NS = "uipath.connector.trigger.";
|
|
|
72
98
|
export function fetchableNodeType(nodeType) {
|
|
73
99
|
return nodeType.startsWith(TRIGGER_NS) ? EVENT_NS + nodeType.slice(TRIGGER_NS.length) : nodeType;
|
|
74
100
|
}
|
|
75
|
-
/** The requests grouped by the node type fetched, with the objects asked for (none means every object). */
|
|
76
101
|
/** The versions asked for, by the node type fetched; a request with none asks for whichever the tenant serves. */
|
|
77
102
|
function requestedVersions(requests) {
|
|
78
103
|
const versions = new Map();
|
|
@@ -84,6 +109,7 @@ function requestedVersions(requests) {
|
|
|
84
109
|
}
|
|
85
110
|
return versions;
|
|
86
111
|
}
|
|
112
|
+
/** The requests grouped by the node type fetched, with the objects asked for (none means every object). */
|
|
87
113
|
function groupRequests(requests) {
|
|
88
114
|
const grouped = new Map();
|
|
89
115
|
for (const request of requests) {
|
|
@@ -112,6 +138,8 @@ export async function uipUnavailableReason(client) {
|
|
|
112
138
|
catch (error) {
|
|
113
139
|
return messageOf(error);
|
|
114
140
|
}
|
|
141
|
+
if (status.result.timedOut === true)
|
|
142
|
+
return "`uip login status` did not answer in time (is it waiting on a prompt?)";
|
|
115
143
|
const state = getCI(status.data, "Status");
|
|
116
144
|
if (status.result.code === 0 && typeof state === "string" && /^logged in$/i.test(state.trim()))
|
|
117
145
|
return undefined;
|
|
@@ -227,9 +255,9 @@ function planEach(entries, loadNode, failed) {
|
|
|
227
255
|
}
|
|
228
256
|
}
|
|
229
257
|
/** How long a "the tenant does not serve it" answer is believed without asking again: `uip`'s own catalog lifetime. */
|
|
230
|
-
const NOT_SERVED_TTL_MS = 30 * 60 * 1000;
|
|
231
|
-
const NOT_SERVED_FILE = ".not-served.json";
|
|
232
|
-
function readNotServed(overlayDir, scope, now) {
|
|
258
|
+
export const NOT_SERVED_TTL_MS = 30 * 60 * 1000;
|
|
259
|
+
export const NOT_SERVED_FILE = ".not-served.json";
|
|
260
|
+
export function readNotServed(overlayDir, scope, now) {
|
|
233
261
|
try {
|
|
234
262
|
const memory = JSON.parse(readFileSync(join(overlayDir, NOT_SERVED_FILE), "utf8"));
|
|
235
263
|
if (memory.scope !== scope)
|
|
@@ -257,6 +285,15 @@ function rememberNotServed(overlayDir, scope, nodeTypes, now) {
|
|
|
257
285
|
mkdirSync(overlayDir, { recursive: true });
|
|
258
286
|
writeInsideSync(overlayDir, join(overlayDir, NOT_SERVED_FILE), `${JSON.stringify({ scope, until }, null, 2)}\n`);
|
|
259
287
|
}
|
|
288
|
+
/** {@link rememberNotServed}, which is only a cache: a write that fails costs a repeated lookup, nothing more. */
|
|
289
|
+
export function rememberNotServedQuietly(overlayDir, scope, nodeTypes, now) {
|
|
290
|
+
try {
|
|
291
|
+
rememberNotServed(overlayDir, scope, nodeTypes, now);
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
// Asked again next time.
|
|
295
|
+
}
|
|
296
|
+
}
|
|
260
297
|
/**
|
|
261
298
|
* Fetch every requested node type the tenant serves into `overlayDir`.
|
|
262
299
|
*
|
|
@@ -275,7 +312,7 @@ export async function fetchDefinitions(requests, options) {
|
|
|
275
312
|
const grouped = groupRequests(requests);
|
|
276
313
|
if (grouped.size === 0)
|
|
277
314
|
return result;
|
|
278
|
-
const client = options.client ?? defaultUipClient();
|
|
315
|
+
const client = new BoundedUipClient(options.client ?? defaultUipClient(), options.timeoutMs ?? FETCH_TIMEOUT_MS);
|
|
279
316
|
const reporter = options.reporter ?? silentReporter;
|
|
280
317
|
const unavailable = await uipUnavailableReason(client);
|
|
281
318
|
if (unavailable !== undefined)
|
|
@@ -297,14 +334,13 @@ export async function fetchDefinitions(requests, options) {
|
|
|
297
334
|
caches: { registry: new MemoryResponseCache(), is: new MemoryResponseCache(), connectors: new MemoryResponseCache() },
|
|
298
335
|
reporter: silentReporter,
|
|
299
336
|
concurrency: options.concurrency ?? 4,
|
|
300
|
-
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
|
|
301
337
|
});
|
|
302
338
|
// 1. The node of every requested node type, with a "not found" checked
|
|
303
339
|
// against a refreshed catalog before it is believed.
|
|
304
340
|
const nodeTypes = [...grouped.keys()].sort();
|
|
305
341
|
const probes = await mapConcurrent(nodeTypes, ctx.concurrency, (nodeType) => probe(ctx, nodeType));
|
|
306
342
|
if (probes.some((p) => "miss" in p && p.miss.notFound)) {
|
|
307
|
-
const refresh = await refreshRegistryCatalog(client, options.timeoutMs);
|
|
343
|
+
const refresh = await refreshRegistryCatalog(client, options.timeoutMs ?? FETCH_REFRESH_TIMEOUT_MS);
|
|
308
344
|
const doubt = !refresh.ok ? `the catalog refresh failed: ${refresh.reason}` : refresh.partial;
|
|
309
345
|
await Promise.all(nodeTypes.map(async (nodeType, i) => {
|
|
310
346
|
const first = probes[i];
|
|
@@ -349,7 +385,7 @@ export async function fetchDefinitions(requests, options) {
|
|
|
349
385
|
entries.push(entry);
|
|
350
386
|
});
|
|
351
387
|
if (entries.length === 0) {
|
|
352
|
-
|
|
388
|
+
rememberNotServedQuietly(options.overlayDir, scope, result.notServed.filter((n) => !remembered.has(n)), now);
|
|
353
389
|
return finish(result);
|
|
354
390
|
}
|
|
355
391
|
// 2–3. Fields, then the connector records the object decisions read.
|
|
@@ -408,6 +444,15 @@ export async function fetchDefinitions(requests, options) {
|
|
|
408
444
|
await applyCorrectionsAndSideTables(staging, options.overlayDir);
|
|
409
445
|
mergeInto(staging, options.overlayDir);
|
|
410
446
|
}
|
|
447
|
+
catch (error) {
|
|
448
|
+
// A full disk or a read-only project: each node type it was writing
|
|
449
|
+
// fails with the reason, rather than the whole fetch throwing.
|
|
450
|
+
for (const nodeType of new Set(rows.map((row) => row.nodeType))) {
|
|
451
|
+
result.failed.push({ nodeType, reason: `could not write to ${options.overlayDir}: ${messageOf(error)}` });
|
|
452
|
+
}
|
|
453
|
+
rememberNotServedQuietly(options.overlayDir, scope, result.notServed.filter((n) => !remembered.has(n)), now);
|
|
454
|
+
return finish(result);
|
|
455
|
+
}
|
|
411
456
|
finally {
|
|
412
457
|
rmSync(staging, { recursive: true, force: true });
|
|
413
458
|
}
|
|
@@ -433,7 +478,7 @@ export async function fetchDefinitions(requests, options) {
|
|
|
433
478
|
}
|
|
434
479
|
}
|
|
435
480
|
}
|
|
436
|
-
|
|
481
|
+
rememberNotServedQuietly(options.overlayDir, scope, result.notServed.filter((n) => !remembered.has(n)), now);
|
|
437
482
|
result.fetched = [...new Set(rows.map((row) => row.nodeType))].sort();
|
|
438
483
|
for (const nodeType of result.fetched)
|
|
439
484
|
reporter.info(`fetched ${nodeType} from the tenant into ${options.overlayDir}`);
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { type DefinitionRequest } from "./fetch-definitions.js";
|
|
2
2
|
/** The connector node types `flow` uses, root and subflows, deduplicated, each with its saved object when it has one. */
|
|
3
3
|
export declare function flowConnectorRequests(flow: unknown): DefinitionRequest[];
|
|
4
|
+
/**
|
|
5
|
+
* A request as its stamp's `lacked=` token: the node type, and `#<object>`
|
|
6
|
+
* (URI-encoded, so `,` and spaces stay inside the token) when it names one. A
|
|
7
|
+
* generic operation decompile held for one object and lacked for another is
|
|
8
|
+
* lacked for that object alone.
|
|
9
|
+
*/
|
|
10
|
+
export declare function lackedToken(request: DefinitionRequest): string;
|
|
4
11
|
/**
|
|
5
12
|
* The `LibraryOpts.hide` predicate that reproduces a decompile's library from
|
|
6
|
-
* its stamp's `lacked=`: every row of
|
|
7
|
-
* the name the fetch writes it as too. A start
|
|
8
|
-
* `uipath.connector.trigger.K.E` is fetched (and
|
|
9
|
-
* `uipath.connector.event.K.E`, from which the
|
|
10
|
-
* so hiding only the trigger name would leave
|
|
13
|
+
* its stamp's `lacked=`: every row of what that decompile lacked (a node type,
|
|
14
|
+
* or one object of it), under the name the fetch writes it as too. A start
|
|
15
|
+
* trigger the `.flow` names as `uipath.connector.trigger.K.E` is fetched (and
|
|
16
|
+
* indexed) as its wait form `uipath.connector.event.K.E`, from which the
|
|
17
|
+
* library derives the start form, so hiding only the trigger name would leave
|
|
18
|
+
* the trigger resolvable.
|
|
11
19
|
*/
|
|
12
20
|
export declare function hidesLacked(lacked: readonly string[]): (row: {
|
|
13
21
|
nodeType?: unknown;
|
|
22
|
+
objectName?: unknown;
|
|
14
23
|
}) => boolean;
|
|
24
|
+
/** Whether `lacked` names `nodeType`, for any object or none. */
|
|
25
|
+
export declare function lacksNodeType(lacked: readonly string[], nodeType: string): boolean;
|
|
@@ -67,15 +67,36 @@ export function flowConnectorRequests(flow) {
|
|
|
67
67
|
}
|
|
68
68
|
return [...requests.values()];
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* A request as its stamp's `lacked=` token: the node type, and `#<object>`
|
|
72
|
+
* (URI-encoded, so `,` and spaces stay inside the token) when it names one. A
|
|
73
|
+
* generic operation decompile held for one object and lacked for another is
|
|
74
|
+
* lacked for that object alone.
|
|
75
|
+
*/
|
|
76
|
+
export function lackedToken(request) {
|
|
77
|
+
return request.objectName ? `${request.nodeType}#${encodeURIComponent(request.objectName)}` : request.nodeType;
|
|
78
|
+
}
|
|
79
|
+
function parseLacked(token) {
|
|
80
|
+
const hash = token.indexOf("#");
|
|
81
|
+
const nodeType = hash < 0 ? token : token.slice(0, hash);
|
|
82
|
+
const nodeTypes = [nodeType, fetchableNodeType(nodeType)];
|
|
83
|
+
return hash < 0 ? { nodeTypes } : { nodeTypes, objectName: decodeURIComponent(token.slice(hash + 1)).toLowerCase() };
|
|
84
|
+
}
|
|
70
85
|
/**
|
|
71
86
|
* The `LibraryOpts.hide` predicate that reproduces a decompile's library from
|
|
72
|
-
* its stamp's `lacked=`: every row of
|
|
73
|
-
* the name the fetch writes it as too. A start
|
|
74
|
-
* `uipath.connector.trigger.K.E` is fetched (and
|
|
75
|
-
* `uipath.connector.event.K.E`, from which the
|
|
76
|
-
* so hiding only the trigger name would leave
|
|
87
|
+
* its stamp's `lacked=`: every row of what that decompile lacked (a node type,
|
|
88
|
+
* or one object of it), under the name the fetch writes it as too. A start
|
|
89
|
+
* trigger the `.flow` names as `uipath.connector.trigger.K.E` is fetched (and
|
|
90
|
+
* indexed) as its wait form `uipath.connector.event.K.E`, from which the
|
|
91
|
+
* library derives the start form, so hiding only the trigger name would leave
|
|
92
|
+
* the trigger resolvable.
|
|
77
93
|
*/
|
|
78
94
|
export function hidesLacked(lacked) {
|
|
79
|
-
const
|
|
80
|
-
return (row) => typeof row.nodeType === "string" &&
|
|
95
|
+
const parsed = lacked.map(parseLacked);
|
|
96
|
+
return (row) => typeof row.nodeType === "string" && parsed.some(({ nodeTypes, objectName }) => nodeTypes.includes(row.nodeType)
|
|
97
|
+
&& (objectName === undefined || (typeof row.objectName === "string" && row.objectName.toLowerCase() === objectName)));
|
|
98
|
+
}
|
|
99
|
+
/** Whether `lacked` names `nodeType`, for any object or none. */
|
|
100
|
+
export function lacksNodeType(lacked, nodeType) {
|
|
101
|
+
return lacked.some((token) => parseLacked(token).nodeTypes.includes(nodeType));
|
|
81
102
|
}
|
|
@@ -14,6 +14,12 @@ export interface WithFetchedDefinitionsOptions {
|
|
|
14
14
|
*/
|
|
15
15
|
notes?: Map<string, string>;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Whether this invocation fetches a missing definition through `uip`: fetching
|
|
19
|
+
* is on, and no pre-cache library was pulled or named. The published library is
|
|
20
|
+
* the catalog when there is one; a typo against it is refused, not looked up.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fetchesDefinitions(argv: readonly string[]): boolean;
|
|
17
23
|
/** The overlay a fetch writes into: the one the library opens, else `.flow-sdk/connectors-local`. */
|
|
18
24
|
export declare function fetchOverlayDir(argv: readonly string[]): string;
|
|
19
25
|
/**
|
|
@@ -44,3 +50,5 @@ export declare function openWithFetchedDefinitions(argv: readonly string[], requ
|
|
|
44
50
|
* not be fetched is a warning; the caller's own refusal says the rest.
|
|
45
51
|
*/
|
|
46
52
|
export declare function fetchMissedBy(argv: readonly string[], probe: (library: Library) => unknown, options?: WithFetchedDefinitionsOptions): Promise<void>;
|
|
53
|
+
/** Why a node type is missing when the tenant does not serve it, and how to ask again before the answer expires. */
|
|
54
|
+
export declare function notServedNote(overlayDir: string): string;
|
|
@@ -14,16 +14,19 @@
|
|
|
14
14
|
* The last pass's library carries a `missNote` for what is still missing, so
|
|
15
15
|
* the refusal says why: the tenant does not serve it, or `uip` cannot be asked.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Only with no pulled library (`fetchesDefinitions`): an operation a pulled
|
|
18
|
+
* library lacks is refused, not fetched. With one, or with
|
|
19
|
+
* `FLOW_SDK_FETCH_DEFINITIONS=0`, nothing is fetched and the library is opened
|
|
20
|
+
* exactly as `openCliLibrary(argv)` opens it.
|
|
19
21
|
*/
|
|
20
|
-
import { openCliLibrary } from "../../core/cli-library.js";
|
|
22
|
+
import { hasPulledLibrary, openCliLibrary } from "../../core/cli-library.js";
|
|
21
23
|
import { flagValue } from "../../cli-run.js";
|
|
22
24
|
import { defaultOverlayDir, workPath } from "../../workdir.js";
|
|
23
25
|
import { PACKAGE_NAME } from "../../package-name.js";
|
|
24
26
|
import { stderrReporter } from "../reporter.js";
|
|
25
27
|
import { fetchConnectors } from "./fetch-connectors.js";
|
|
26
|
-
import {
|
|
28
|
+
import { join } from "node:path";
|
|
29
|
+
import { NOT_SERVED_FILE, NOT_SERVED_TTL_MS, fetchDefinitions, fetchDefinitionsEnabled, fetchableNodeType, } from "./fetch-definitions.js";
|
|
27
30
|
/** The identity of a miss, as fetched: a start trigger as its wait form, and the object asked for. */
|
|
28
31
|
function missKey(miss) {
|
|
29
32
|
return JSON.stringify([fetchableNodeType(miss.nodeType), miss.objectName?.toLowerCase() ?? null]);
|
|
@@ -41,6 +44,14 @@ const settled = (pass) => {
|
|
|
41
44
|
throw pass.error;
|
|
42
45
|
return pass.value;
|
|
43
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Whether this invocation fetches a missing definition through `uip`: fetching
|
|
49
|
+
* is on, and no pre-cache library was pulled or named. The published library is
|
|
50
|
+
* the catalog when there is one; a typo against it is refused, not looked up.
|
|
51
|
+
*/
|
|
52
|
+
export function fetchesDefinitions(argv) {
|
|
53
|
+
return fetchDefinitionsEnabled() && !hasPulledLibrary(argv);
|
|
54
|
+
}
|
|
44
55
|
/** The overlay a fetch writes into: the one the library opens, else `.flow-sdk/connectors-local`. */
|
|
45
56
|
export function fetchOverlayDir(argv) {
|
|
46
57
|
return flagValue(argv, "--connectors-local") ?? defaultOverlayDir() ?? workPath("connectors-local");
|
|
@@ -50,7 +61,7 @@ export function fetchOverlayDir(argv) {
|
|
|
50
61
|
* what its last pass threw.
|
|
51
62
|
*/
|
|
52
63
|
export async function withFetchedDefinitions(argv, work, options = {}) {
|
|
53
|
-
if (!
|
|
64
|
+
if (!fetchesDefinitions(argv))
|
|
54
65
|
return work(openCliLibrary(argv));
|
|
55
66
|
const reporter = options.reporter ?? stderrReporter;
|
|
56
67
|
const who = options.who ?? "compile";
|
|
@@ -77,7 +88,7 @@ export async function withFetchedDefinitions(argv, work, options = {}) {
|
|
|
77
88
|
reporter,
|
|
78
89
|
...(options.client ? { client: options.client } : {}),
|
|
79
90
|
});
|
|
80
|
-
noteResult(notes, fresh, result);
|
|
91
|
+
noteResult(notes, fresh, result, overlayDir);
|
|
81
92
|
// Nothing new to read: one more pass, so the refusal carries its note.
|
|
82
93
|
if (result.fetched.length === 0) {
|
|
83
94
|
const last = await settle(() => work(openCliLibrary(argv, { always: true, missNote })));
|
|
@@ -86,14 +97,14 @@ export async function withFetchedDefinitions(argv, work, options = {}) {
|
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
/** Record, per node type fetched, why fetching it did not help. */
|
|
89
|
-
function noteResult(notes, asked, result) {
|
|
100
|
+
function noteResult(notes, asked, result, overlayDir) {
|
|
90
101
|
if (result.unavailable !== undefined) {
|
|
91
102
|
const note = `The connector library was not pulled, and the definition could not be fetched through uip: ${sentence(result.unavailable)}`;
|
|
92
103
|
for (const request of asked)
|
|
93
104
|
notes.set(fetchableNodeType(request.nodeType), note);
|
|
94
105
|
}
|
|
95
106
|
for (const nodeType of result.notServed) {
|
|
96
|
-
notes.set(nodeType,
|
|
107
|
+
notes.set(nodeType, notServedNote(overlayDir));
|
|
97
108
|
}
|
|
98
109
|
for (const failure of result.failed) {
|
|
99
110
|
notes.set(failure.nodeType, `Fetching it through uip failed: ${sentence(failure.reason)}`);
|
|
@@ -108,7 +119,7 @@ function noteResult(notes, asked, result) {
|
|
|
108
119
|
* With the fetch off it is `openCliLibrary(argv)`, as before.
|
|
109
120
|
*/
|
|
110
121
|
export async function openWithFetchedDefinitions(argv, requests, options = {}) {
|
|
111
|
-
if (!
|
|
122
|
+
if (!fetchesDefinitions(argv))
|
|
112
123
|
return openCliLibrary(argv);
|
|
113
124
|
const library = openCliLibrary(argv, { always: true });
|
|
114
125
|
// A start trigger is carried as its wait form: either one in a layer is enough.
|
|
@@ -127,7 +138,7 @@ export async function openWithFetchedDefinitions(argv, requests, options = {}) {
|
|
|
127
138
|
...(options.client ? { client: options.client } : {}),
|
|
128
139
|
});
|
|
129
140
|
const notes = options.notes ?? new Map();
|
|
130
|
-
noteResult(notes, missing, result);
|
|
141
|
+
noteResult(notes, missing, result, fetchOverlayDir(argv));
|
|
131
142
|
// Decompile goes on either way (what the tenant does not serve is carried
|
|
132
143
|
// from the file), so say what was not fetched and why.
|
|
133
144
|
for (const [nodeType, note] of [...notes].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
@@ -149,7 +160,7 @@ export async function openWithFetchedDefinitions(argv, requests, options = {}) {
|
|
|
149
160
|
* not be fetched is a warning; the caller's own refusal says the rest.
|
|
150
161
|
*/
|
|
151
162
|
export async function fetchMissedBy(argv, probe, options = {}) {
|
|
152
|
-
if (!
|
|
163
|
+
if (!fetchesDefinitions(argv))
|
|
153
164
|
return;
|
|
154
165
|
const reporter = options.reporter ?? stderrReporter;
|
|
155
166
|
const who = options.who ?? "decompile";
|
|
@@ -181,13 +192,24 @@ export async function fetchMissedBy(argv, probe, options = {}) {
|
|
|
181
192
|
askedMisses.add(missKey(miss));
|
|
182
193
|
const names = [...freshKeys, ...new Set(freshMisses.map((m) => m.nodeType))];
|
|
183
194
|
reporter.info(`${who}: ${names.join(", ")} not in the connector library; fetching through uip.`);
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
195
|
+
// Definitions only, no typed modules: the source names an operation by
|
|
196
|
+
// strings, and a module the author edited (or `prepare --import` wrote) must
|
|
197
|
+
// not be rewritten. Only the operations no layer holds: a partially cached
|
|
198
|
+
// connector keeps its rows.
|
|
199
|
+
let connectors;
|
|
200
|
+
let definitions;
|
|
201
|
+
try {
|
|
202
|
+
connectors = freshKeys.length > 0
|
|
203
|
+
? await fetchConnectors(freshKeys, { overlayDir, importSpecifier: PACKAGE_NAME, reporter, skip: (nodeType) => library.indexes(nodeType), modules: false, ...client })
|
|
204
|
+
: undefined;
|
|
205
|
+
definitions = freshMisses.length > 0 ? await fetchDefinitions(freshMisses, { overlayDir, reporter, ...client }) : undefined;
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
// As Flow decompile treats an unreadable library: a warning, and the run
|
|
209
|
+
// goes on with the library as it is.
|
|
210
|
+
reporter.warn(`${who}: warning: fetching through uip failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
191
213
|
const unavailable = connectors?.unavailable ?? definitions?.unavailable;
|
|
192
214
|
if (unavailable !== undefined) {
|
|
193
215
|
reporter.warn(`${who}: warning: nothing was fetched through uip: ${unavailable}.`);
|
|
@@ -205,6 +227,11 @@ export async function fetchMissedBy(argv, probe, options = {}) {
|
|
|
205
227
|
return;
|
|
206
228
|
}
|
|
207
229
|
}
|
|
230
|
+
/** Why a node type is missing when the tenant does not serve it, and how to ask again before the answer expires. */
|
|
231
|
+
export function notServedNote(overlayDir) {
|
|
232
|
+
return "The tenant was asked through uip (`uip maestro flow registry get`) and does not serve it. " +
|
|
233
|
+
`That answer is kept for ${NOT_SERVED_TTL_MS / 60_000} minutes in ${join(overlayDir, NOT_SERVED_FILE)}; delete that file to ask again sooner.`;
|
|
234
|
+
}
|
|
208
235
|
/** `text` as the end of a sentence: one closing period, whatever `uip`'s reason ended with. */
|
|
209
236
|
function sentence(text) {
|
|
210
237
|
return `${text.replace(/[\s.]+$/, "")}.`;
|
|
@@ -299,7 +299,9 @@ export function mergeFilesInto(files, dst) {
|
|
|
299
299
|
return false;
|
|
300
300
|
});
|
|
301
301
|
dstIdx.entries = mergeIndexEntries(kept, srcRows);
|
|
302
|
-
|
|
302
|
+
// The descriptors first, then the index: a write that stops part way leaves
|
|
303
|
+
// files no row names, never a row with no file. No rename: Studio Web's file
|
|
304
|
+
// system refuses one (see staged-files.ts).
|
|
303
305
|
for (const [rel, content] of files) {
|
|
304
306
|
if (basename(rel) === INDEX_FILENAME)
|
|
305
307
|
continue;
|
|
@@ -307,6 +309,7 @@ export function mergeFilesInto(files, dst) {
|
|
|
307
309
|
mkdirSync(dirname(out), { recursive: true });
|
|
308
310
|
writeInsideSync(dst, out, content);
|
|
309
311
|
}
|
|
312
|
+
writeInsideSync(dst, join(dst, INDEX_FILENAME), formatOverlayIndex(dstIdx));
|
|
310
313
|
return { replacedPlanRows: replaced };
|
|
311
314
|
}
|
|
312
315
|
/** Every file under `root`, as `POSIX-relative path → bytes`. */
|
|
@@ -27,7 +27,12 @@ export declare function connectorsLibraryUrl(argv: string[], env?: Record<string
|
|
|
27
27
|
* of these: bytes that do not match their sidecar are refused, not routed around.
|
|
28
28
|
*/
|
|
29
29
|
export declare class ArchiveUnavailableError extends Error {
|
|
30
|
-
|
|
30
|
+
readonly status?: number | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* @param status The HTTP status when the server answered one: a 404 says no
|
|
33
|
+
* library is published there, anything else may pass.
|
|
34
|
+
*/
|
|
35
|
+
constructor(message: string, status?: number | undefined);
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* Point `current` at an entry, replacing whatever it named.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { reportResult } from '../cli-result.js';
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { mkdir, readFile, realpath, rename, rm, stat, symlink, unlink, writeFile, } from "node:fs/promises";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
4
5
|
import { join, resolve } from "node:path";
|
|
5
6
|
import { writeJsonFile } from "../core/json-file.js";
|
|
6
|
-
import { CURRENT_LINK, LIBRARY_JSON_DIR, LIBRARY_MARKDOWN_DIR, cacheEntry, libraryCacheRoot, referencedConnectorKeys, } from "../core/library-cache.js";
|
|
7
|
+
import { CURRENT_LINK, LIBRARY_JSON_DIR, LIBRARY_MARKDOWN_DIR, cacheEntry, libraryCacheRoot, referencedConnectorKeys, resolveCachedLibrary, } from "../core/library-cache.js";
|
|
7
8
|
import { extractLibrary } from "./extractor.js";
|
|
8
9
|
import { materializeRegistry } from "./materializer.js";
|
|
9
10
|
import { curatedOverlayIdentity } from "./curated-overlay.js";
|
|
@@ -136,8 +137,14 @@ async function isFileAsync(path) {
|
|
|
136
137
|
* of these: bytes that do not match their sidecar are refused, not routed around.
|
|
137
138
|
*/
|
|
138
139
|
export class ArchiveUnavailableError extends Error {
|
|
139
|
-
|
|
140
|
+
status;
|
|
141
|
+
/**
|
|
142
|
+
* @param status The HTTP status when the server answered one: a 404 says no
|
|
143
|
+
* library is published there, anything else may pass.
|
|
144
|
+
*/
|
|
145
|
+
constructor(message, status) {
|
|
140
146
|
super(message);
|
|
147
|
+
this.status = status;
|
|
141
148
|
this.name = "ArchiveUnavailableError";
|
|
142
149
|
}
|
|
143
150
|
}
|
|
@@ -153,7 +160,7 @@ async function reach(url) {
|
|
|
153
160
|
throw new ArchiveUnavailableError(`Could not download ${url}: ${detail}`);
|
|
154
161
|
}
|
|
155
162
|
if (!response.ok) {
|
|
156
|
-
throw new ArchiveUnavailableError(`Could not download ${url}: HTTP ${response.status} ${response.statusText}
|
|
163
|
+
throw new ArchiveUnavailableError(`Could not download ${url}: HTTP ${response.status} ${response.statusText}`, response.status);
|
|
157
164
|
}
|
|
158
165
|
return response;
|
|
159
166
|
}
|
|
@@ -376,7 +383,17 @@ export async function run(argv) {
|
|
|
376
383
|
catch (error) {
|
|
377
384
|
if (!(error instanceof ArchiveUnavailableError))
|
|
378
385
|
throw error;
|
|
379
|
-
|
|
386
|
+
// A library pulled earlier is still the library: compile keeps using
|
|
387
|
+
// it, so fetching beside it would mix the two. Say the download failed.
|
|
388
|
+
// The pulled cache, or a library FLOW_SDK_LIBRARY_JSON names: either is
|
|
389
|
+
// what compile reads, and a fetch beside it would bypass it.
|
|
390
|
+
const cached = resolveCachedLibrary(cacheDir) ?? configuredLibrary();
|
|
391
|
+
if (cached !== undefined && explicitLibraryRequest(argv) === undefined) {
|
|
392
|
+
console.error(`registry pull: ${error.message}. The library pulled earlier is kept (${cached}); ` +
|
|
393
|
+
"run the pull again once the download can be reached.");
|
|
394
|
+
return 1;
|
|
395
|
+
}
|
|
396
|
+
return await pullWithoutArchive(argv, error);
|
|
380
397
|
}
|
|
381
398
|
const archiveSha256 = await archiveIdentity(archive);
|
|
382
399
|
const overlaySha256 = await curatedOverlayIdentity();
|
|
@@ -473,7 +490,8 @@ export async function run(argv) {
|
|
|
473
490
|
* author's next `check` names it, and on Automation Suite it may simply not be
|
|
474
491
|
* approved.
|
|
475
492
|
*/
|
|
476
|
-
async function pullWithoutArchive(argv,
|
|
493
|
+
async function pullWithoutArchive(argv, unavailable) {
|
|
494
|
+
const why = unavailable.message;
|
|
477
495
|
const overlayDir = value(argv, "--connectors-local") ?? workPath("connectors-local");
|
|
478
496
|
const named = repeated(argv, "--connector");
|
|
479
497
|
const keys = named.length > 0
|
|
@@ -496,7 +514,11 @@ async function pullWithoutArchive(argv, why) {
|
|
|
496
514
|
console.error("registry pull: the connector library is unavailable and no connector is referenced by this project yet. " +
|
|
497
515
|
"Name one with `--connector <key>` to fetch it through uip.");
|
|
498
516
|
reportResult({ library: null, overlay: resolve(overlayDir), fetched: [] });
|
|
499
|
-
|
|
517
|
+
// Nothing published there (a 404), or no route to it at all, as on an
|
|
518
|
+
// air-gapped Automation Suite: no library is to be had, and nothing is
|
|
519
|
+
// referenced yet, so there is nothing to fail. A server error may pass,
|
|
520
|
+
// and a CI step must not read it as success.
|
|
521
|
+
return unavailable.status === undefined || unavailable.status === 404 ? 0 : 1;
|
|
500
522
|
}
|
|
501
523
|
console.error(`registry pull: fetching ${keys.join(", ")} through uip into ${overlayDir} instead.`);
|
|
502
524
|
const result = await fetchConnectors(keys, {
|
|
@@ -532,6 +554,11 @@ async function pullWithoutArchive(argv, why) {
|
|
|
532
554
|
(result.modules.length > 0 ? `, with ${result.modules.join(", ")}` : "") + ".");
|
|
533
555
|
return result.failed.length > 0 || namedUnlisted.length > 0 ? 1 : 0;
|
|
534
556
|
}
|
|
557
|
+
/** The library FLOW_SDK_LIBRARY_JSON names, when it holds an index. */
|
|
558
|
+
function configuredLibrary() {
|
|
559
|
+
const dir = process.env.FLOW_SDK_LIBRARY_JSON || undefined;
|
|
560
|
+
return dir !== undefined && existsSync(join(dir, "index.json")) ? dir : undefined;
|
|
561
|
+
}
|
|
535
562
|
/**
|
|
536
563
|
* The flag (with its value) that asked for a specific library, or `undefined`
|
|
537
564
|
* for the default request the uip fallback may answer.
|