@uipath/maestro-builder-sdk 6.105.0 → 6.106.0
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/README.md +13 -2
- 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/build-cli.d.ts +3 -0
- package/dist/build-cli.js +192 -0
- package/dist/case/decompile-cli.js +2 -3
- package/dist/cli/commands/flow.js +29 -0
- package/dist/cli-result.d.ts +5 -0
- package/dist/cli-result.js +7 -0
- 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/decompile-cli.js +6 -3
- package/dist/decompile-stamp.d.ts +7 -0
- package/dist/decompile-stamp.js +4 -1
- package/dist/merge-cli.js +23 -8
- package/dist/nodes/connector/flow/node-type.js +9 -3
- 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 +5 -3
package/dist/merge-cli.js
CHANGED
|
@@ -87,11 +87,12 @@ import { readFlowFile } from './decompile-file.js';
|
|
|
87
87
|
import { readFlowStamp, restampFlowSource, sourceDigest, STAMP_MARKER } from './decompile-stamp.js';
|
|
88
88
|
import { ensureTypeScriptRuntime } from './node-runtime.js';
|
|
89
89
|
import { flowCheckOpts, openCliLibrary } from './cli-library.js';
|
|
90
|
+
import { hasPulledLibrary } from './core/cli-library.js';
|
|
90
91
|
import { FETCHED_PROVENANCE } from './core/library.js';
|
|
91
92
|
import { readNodeCatalog } from './node-catalog-files.js';
|
|
92
|
-
import { flowConnectorRequests, hidesLacked } from './registry/fetch/flow-requests.js';
|
|
93
|
-
import {
|
|
94
|
-
import { openWithFetchedDefinitions, withFetchedDefinitions } from './registry/fetch/with-fetched-definitions.js';
|
|
93
|
+
import { flowConnectorRequests, hidesLacked, lacksNodeType } from './registry/fetch/flow-requests.js';
|
|
94
|
+
import { fetchableNodeType } from './registry/fetch/fetch-definitions.js';
|
|
95
|
+
import { fetchesDefinitions, openWithFetchedDefinitions, withFetchedDefinitions } from './registry/fetch/with-fetched-definitions.js';
|
|
95
96
|
import { Bindings } from './bindings.js';
|
|
96
97
|
import { defaultBindingsFile } from './workdir.js';
|
|
97
98
|
import { loadNodePackages } from './node-packages.js';
|
|
@@ -298,7 +299,7 @@ export async function run(argv) {
|
|
|
298
299
|
? openCliLibrary(argv, {
|
|
299
300
|
always: true,
|
|
300
301
|
hide,
|
|
301
|
-
missNote: (nodeType) => (
|
|
302
|
+
missNote: (nodeType) => (lacksNodeType(lacked, nodeType)
|
|
302
303
|
? 'This source carries it from the file it was decompiled from; '
|
|
303
304
|
+ 'to compile a step against the tenant’s definition, decompile the original again.'
|
|
304
305
|
: undefined),
|
|
@@ -347,7 +348,12 @@ export async function run(argv) {
|
|
|
347
348
|
// Decompiled as the stamp records, so the baseline is built from the source the
|
|
348
349
|
// author started from; without a stamp, with decompile's defaults.
|
|
349
350
|
// The library decompile carried connector operations against: the one compile opens.
|
|
350
|
-
|
|
351
|
+
// A decompile that had no library at all is reproduced with none; both sides
|
|
352
|
+
// still compile against `library`.
|
|
353
|
+
const decompileLibrary = stamp?.noLibrary ? undefined : library;
|
|
354
|
+
// `library` is always named, `undefined` included: `baselineFromOriginal` sets the
|
|
355
|
+
// compile library first, and only an explicit key overrides it.
|
|
356
|
+
const decompileOpts = { ...(stamp ? { scripts: stamp.scripts, strict: stamp.strict } : {}), library: decompileLibrary };
|
|
351
357
|
let baselineCompile;
|
|
352
358
|
if (derivedFrom) {
|
|
353
359
|
try {
|
|
@@ -372,7 +378,14 @@ export async function run(argv) {
|
|
|
372
378
|
const packages = stamp.packages.length > 0 ? ', or a node-type package it loads,' : '';
|
|
373
379
|
return refuseMerge('MERGE_ORIGINAL_CHANGED', `${name}${packages} changed since ${basename(editedPath)} was decompiled from ${stamp.file === name ? 'it' : stamp.file}: `
|
|
374
380
|
+ `decompiling it now gives a different source (sha256 ${stamp.sha256} recorded, ${actual} now). `
|
|
375
|
-
+ `Merging would read those changes as the edit's deletions and revert them, so nothing was written.
|
|
381
|
+
+ `Merging would read those changes as the edit's deletions and revert them, so nothing was written. `
|
|
382
|
+
// A stamp from before fetching existed, with no pulled library now: the
|
|
383
|
+
// library that decompile read may be what is gone, not the original.
|
|
384
|
+
+ (preFetch && !hasPulledLibrary(argv)
|
|
385
|
+
? 'This source was decompiled by an SDK that did not fetch through uip, likely against a pulled library that is no longer here: '
|
|
386
|
+
+ 'pass it with --library (or run `uip maestro registry pull`), or decompile the original again. '
|
|
387
|
+
: '')
|
|
388
|
+
+ redoAdvice(derivedFrom));
|
|
376
389
|
}
|
|
377
390
|
}
|
|
378
391
|
const baselineSidecars = baselineCompile?.sidecars;
|
|
@@ -609,10 +622,12 @@ async function mergeLibrary(argv, originalPath, editedSource) {
|
|
|
609
622
|
// edit added still says why it could not be fetched.
|
|
610
623
|
const notes = new Map();
|
|
611
624
|
const library = await openWithFetchedDefinitions(argv, flowConnectorRequests(original), { who: 'flow-merge', notes });
|
|
612
|
-
if (editedSource === undefined || !
|
|
625
|
+
if (editedSource === undefined || !fetchesDefinitions(argv))
|
|
613
626
|
return library;
|
|
614
627
|
// A recording pass only, its result discarded: the merge compiles with the
|
|
615
628
|
// library opened after it, which reads whatever it fetched.
|
|
616
629
|
await withFetchedDefinitions(argv, (pass) => compileSourceDraftTolerant(editedSource, { library: pass, nodeCatalog: readNodeCatalog() }), { who: 'flow-merge', notes });
|
|
617
|
-
|
|
630
|
+
// Opened only: both steps above asked for everything, and asking again for
|
|
631
|
+
// what the tenant does not serve would repeat the uip calls and the notes.
|
|
632
|
+
return openCliLibrary(argv, { always: true, missNote: (nodeType) => notes.get(fetchableNodeType(nodeType)) });
|
|
618
633
|
}
|
|
@@ -425,13 +425,19 @@ const connector10 = {
|
|
|
425
425
|
deserialize: (node, ctx) => liftConnector(node, ctx),
|
|
426
426
|
isDraft: (node, definition) => isConnectorDraft(node, definition),
|
|
427
427
|
// An operation the decompile's library has no entry for is carried from the
|
|
428
|
-
// file, when its saved detail describes one compile can rebuild.
|
|
428
|
+
// file, when its saved detail describes one compile can rebuild. Per object: a
|
|
429
|
+
// generic operation held for another object still lacks this one, as the
|
|
430
|
+
// stamp's `lacked=` records it.
|
|
429
431
|
carriesFromFile: (node, library) => {
|
|
430
432
|
const n = node;
|
|
431
|
-
if (typeof n.type !== 'string' || splitOperation(n.type) === undefined
|
|
433
|
+
if (typeof n.type !== 'string' || splitOperation(n.type) === undefined)
|
|
432
434
|
return false;
|
|
433
435
|
const detail = n.inputs?.detail;
|
|
434
|
-
|
|
436
|
+
if (!detail || typeof detail !== 'object')
|
|
437
|
+
return false;
|
|
438
|
+
if (library.indexes(n.type, liftedObject(detail)))
|
|
439
|
+
return false;
|
|
440
|
+
return carriedOperationOf(detail) !== undefined;
|
|
435
441
|
},
|
|
436
442
|
print: (spec, ctx) => printConnector(spec, ctx),
|
|
437
443
|
check: (spec, ctx) => ctx.connector(spec),
|
|
@@ -8,8 +8,16 @@ export interface FetchConnectorsOptions {
|
|
|
8
8
|
client?: UipClient;
|
|
9
9
|
reporter?: Reporter;
|
|
10
10
|
timeoutMs?: number;
|
|
11
|
+
/** Parallel catalog lookups. */
|
|
12
|
+
concurrency?: number;
|
|
11
13
|
/** Node types not to fetch: the ones a library layer already holds. */
|
|
12
14
|
skip?: (nodeType: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Regenerate the typed `<key>.ts` modules (the default, for `pull`). A
|
|
17
|
+
* decompile or merge passes `false`: it names an operation by strings, and must
|
|
18
|
+
* not rewrite a module the author edited or `prepare --import` wrote.
|
|
19
|
+
*/
|
|
20
|
+
modules?: boolean;
|
|
13
21
|
}
|
|
14
22
|
export interface FetchConnectorsResult extends FetchDefinitionsResult {
|
|
15
23
|
/** Connector keys the tenant's catalog lists nothing for, sorted. */
|
|
@@ -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.
|