@uipath/maestro-builder-sdk 6.96.7 → 6.97.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 +2 -1
- package/dist/bpmn/check-cli.js +8 -4
- package/dist/bpmn/compile-cli.js +4 -3
- package/dist/bpmn/decompile-cli.js +15 -1
- package/dist/bpmn/decompile-pipeline.d.ts +5 -0
- package/dist/bpmn/decompile-pipeline.js +3 -3
- package/dist/bpmn/decompile-stamp.d.ts +13 -0
- package/dist/bpmn/decompile-stamp.js +8 -0
- package/dist/bpmn/decompile.d.ts +17 -4
- package/dist/bpmn/decompile.js +9 -4
- package/dist/bpmn/merge-cli.js +32 -4
- package/dist/bpmn/merge-source.d.ts +2 -0
- package/dist/bpmn/merge-source.js +1 -0
- package/dist/case/check-cli.js +4 -2
- package/dist/case/compile-cli.js +14 -9
- package/dist/case/decompile-cli.d.ts +1 -1
- package/dist/case/decompile-cli.js +12 -2
- package/dist/check-cli.js +12 -6
- package/dist/cli/commands/registry.js +2 -0
- package/dist/compile-cli.js +16 -10
- package/dist/core/cli-library.d.ts +18 -2
- package/dist/core/cli-library.js +25 -5
- package/dist/core/library.d.ts +74 -2
- package/dist/core/library.js +88 -11
- package/dist/decompile-cli.js +17 -2
- package/dist/decompile-stamp.d.ts +13 -0
- package/dist/decompile-stamp.js +7 -1
- package/dist/emit.js +5 -8
- package/dist/merge-cli.js +51 -1
- package/dist/registry/curated-overlay.d.ts +11 -0
- package/dist/registry/curated-overlay.js +27 -0
- package/dist/registry/describe-cli.d.ts +3 -0
- package/dist/registry/describe-cli.js +38 -6
- package/dist/registry/fetch/fetch-connectors.d.ts +21 -0
- package/dist/registry/fetch/fetch-connectors.js +84 -0
- package/dist/registry/fetch/fetch-definitions.d.ts +61 -0
- package/dist/registry/fetch/fetch-definitions.js +447 -0
- package/dist/registry/fetch/flow-requests.d.ts +14 -0
- package/dist/registry/fetch/flow-requests.js +81 -0
- package/dist/registry/fetch/with-fetched-definitions.d.ts +46 -0
- package/dist/registry/fetch/with-fetched-definitions.js +211 -0
- package/dist/registry/library-build/events.d.ts +9 -2
- package/dist/registry/library-build/events.js +4 -10
- package/dist/registry/pull-cli.d.ts +9 -0
- package/dist/registry/pull-cli.js +150 -10
- package/dist/registry/search-cli.d.ts +25 -0
- package/dist/registry/search-cli.js +94 -10
- package/package.json +4 -3
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a CLI's work against the connector library, fetching through `uip` every
|
|
3
|
+
* node type it found in no layer, and run it again
|
|
4
|
+
* (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md §3.2).
|
|
5
|
+
*
|
|
6
|
+
* The work runs with a library that records its misses (`onMiss`). When it
|
|
7
|
+
* missed anything, those node types are fetched into `connectors-local` and the
|
|
8
|
+
* work runs again with a fresh library, which now reads them. `check` reports
|
|
9
|
+
* every refusal in one pass, so one fetch covers a whole file; `compile` stops
|
|
10
|
+
* at its first refusal, so the loop runs until a pass misses nothing it has not
|
|
11
|
+
* already asked for. Each pass asks for at least one new (node type, object), and
|
|
12
|
+
* a file names finitely many, so it ends.
|
|
13
|
+
*
|
|
14
|
+
* The last pass's library carries a `missNote` for what is still missing, so
|
|
15
|
+
* the refusal says why: the tenant does not serve it, or `uip` cannot be asked.
|
|
16
|
+
*
|
|
17
|
+
* With `FLOW_SDK_FETCH_DEFINITIONS=0` nothing is fetched and the library is
|
|
18
|
+
* opened exactly as `openCliLibrary(argv)` opens it.
|
|
19
|
+
*/
|
|
20
|
+
import { openCliLibrary } from "../../core/cli-library.js";
|
|
21
|
+
import { flagValue } from "../../cli-run.js";
|
|
22
|
+
import { defaultOverlayDir, workPath } from "../../workdir.js";
|
|
23
|
+
import { PACKAGE_NAME } from "../../package-name.js";
|
|
24
|
+
import { stderrReporter } from "../reporter.js";
|
|
25
|
+
import { fetchConnectors } from "./fetch-connectors.js";
|
|
26
|
+
import { fetchDefinitions, fetchDefinitionsEnabled, fetchableNodeType } from "./fetch-definitions.js";
|
|
27
|
+
/** The identity of a miss, as fetched: a start trigger as its wait form, and the object asked for. */
|
|
28
|
+
function missKey(miss) {
|
|
29
|
+
return JSON.stringify([fetchableNodeType(miss.nodeType), miss.objectName?.toLowerCase() ?? null]);
|
|
30
|
+
}
|
|
31
|
+
async function settle(work) {
|
|
32
|
+
try {
|
|
33
|
+
return { value: await work() };
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return { error };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const settled = (pass) => {
|
|
40
|
+
if ("error" in pass)
|
|
41
|
+
throw pass.error;
|
|
42
|
+
return pass.value;
|
|
43
|
+
};
|
|
44
|
+
/** The overlay a fetch writes into: the one the library opens, else `.flow-sdk/connectors-local`. */
|
|
45
|
+
export function fetchOverlayDir(argv) {
|
|
46
|
+
return flagValue(argv, "--connectors-local") ?? defaultOverlayDir() ?? workPath("connectors-local");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `work(library)`, after fetching what it missed. Returns its value or throws
|
|
50
|
+
* what its last pass threw.
|
|
51
|
+
*/
|
|
52
|
+
export async function withFetchedDefinitions(argv, work, options = {}) {
|
|
53
|
+
if (!fetchDefinitionsEnabled())
|
|
54
|
+
return work(openCliLibrary(argv));
|
|
55
|
+
const reporter = options.reporter ?? stderrReporter;
|
|
56
|
+
const who = options.who ?? "compile";
|
|
57
|
+
const overlayDir = fetchOverlayDir(argv);
|
|
58
|
+
const asked = new Set();
|
|
59
|
+
const notes = options.notes ?? new Map();
|
|
60
|
+
// Keyed by the node type fetched: a start trigger is fetched, and noted, as its wait form.
|
|
61
|
+
const missNote = (nodeType) => notes.get(fetchableNodeType(nodeType));
|
|
62
|
+
for (;;) {
|
|
63
|
+
const misses = [];
|
|
64
|
+
const library = openCliLibrary(argv, { always: true, missNote, onMiss: (miss) => misses.push(miss) });
|
|
65
|
+
const pass = await settle(() => work(library));
|
|
66
|
+
// Asked already (a second object of a generic operation is a new ask), or
|
|
67
|
+
// held after all: a start trigger whose wait form the library carries.
|
|
68
|
+
const fresh = misses.filter((miss) => !asked.has(missKey(miss))
|
|
69
|
+
&& !library.indexes(fetchableNodeType(miss.nodeType), miss.objectName));
|
|
70
|
+
if (fresh.length === 0)
|
|
71
|
+
return settled(pass);
|
|
72
|
+
for (const miss of fresh)
|
|
73
|
+
asked.add(missKey(miss));
|
|
74
|
+
reporter.info(`${who}: ${[...new Set(fresh.map((m) => m.nodeType))].join(", ")} not in the connector library; fetching through uip.`);
|
|
75
|
+
const result = await fetchDefinitions(fresh, {
|
|
76
|
+
overlayDir,
|
|
77
|
+
reporter,
|
|
78
|
+
...(options.client ? { client: options.client } : {}),
|
|
79
|
+
});
|
|
80
|
+
noteResult(notes, fresh, result);
|
|
81
|
+
// Nothing new to read: one more pass, so the refusal carries its note.
|
|
82
|
+
if (result.fetched.length === 0) {
|
|
83
|
+
const last = await settle(() => work(openCliLibrary(argv, { always: true, missNote })));
|
|
84
|
+
return settled(last);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Record, per node type fetched, why fetching it did not help. */
|
|
89
|
+
function noteResult(notes, asked, result) {
|
|
90
|
+
if (result.unavailable !== undefined) {
|
|
91
|
+
const note = `The connector library was not pulled, and the definition could not be fetched through uip: ${sentence(result.unavailable)}`;
|
|
92
|
+
for (const request of asked)
|
|
93
|
+
notes.set(fetchableNodeType(request.nodeType), note);
|
|
94
|
+
}
|
|
95
|
+
for (const nodeType of result.notServed) {
|
|
96
|
+
notes.set(nodeType, "The tenant was asked through uip (`uip maestro flow registry get`) and does not serve it.");
|
|
97
|
+
}
|
|
98
|
+
for (const failure of result.failed) {
|
|
99
|
+
notes.set(failure.nodeType, `Fetching it through uip failed: ${sentence(failure.reason)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The library for a command that knows up front which node types it needs —
|
|
104
|
+
* `decompile` and `merge`, from the saved file — with every one of them no
|
|
105
|
+
* layer carries fetched first. The library opened after the fetch carries the
|
|
106
|
+
* notes for what is still missing, as {@link withFetchedDefinitions}'s last pass does.
|
|
107
|
+
*
|
|
108
|
+
* With the fetch off it is `openCliLibrary(argv)`, as before.
|
|
109
|
+
*/
|
|
110
|
+
export async function openWithFetchedDefinitions(argv, requests, options = {}) {
|
|
111
|
+
if (!fetchDefinitionsEnabled())
|
|
112
|
+
return openCliLibrary(argv);
|
|
113
|
+
const library = openCliLibrary(argv, { always: true });
|
|
114
|
+
// A start trigger is carried as its wait form: either one in a layer is enough.
|
|
115
|
+
// Object by object: a generic operation held for another object still misses this one.
|
|
116
|
+
const missing = requests.filter((r) => !library.indexes(r.nodeType, r.objectName)
|
|
117
|
+
&& !library.indexes(fetchableNodeType(r.nodeType), r.objectName));
|
|
118
|
+
if (missing.length === 0) {
|
|
119
|
+
const notes = options.notes;
|
|
120
|
+
return notes === undefined || notes.size === 0 ? library : openCliLibrary(argv, { always: true, missNote: (nodeType) => notes.get(fetchableNodeType(nodeType)) });
|
|
121
|
+
}
|
|
122
|
+
const reporter = options.reporter ?? stderrReporter;
|
|
123
|
+
reporter.info(`${options.who ?? "decompile"}: ${[...new Set(missing.map((m) => m.nodeType))].join(", ")} not in the connector library; fetching through uip.`);
|
|
124
|
+
const result = await fetchDefinitions(missing, {
|
|
125
|
+
overlayDir: fetchOverlayDir(argv),
|
|
126
|
+
reporter,
|
|
127
|
+
...(options.client ? { client: options.client } : {}),
|
|
128
|
+
});
|
|
129
|
+
const notes = options.notes ?? new Map();
|
|
130
|
+
noteResult(notes, missing, result);
|
|
131
|
+
// Decompile goes on either way (what the tenant does not serve is carried
|
|
132
|
+
// from the file), so say what was not fetched and why.
|
|
133
|
+
for (const [nodeType, note] of [...notes].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
134
|
+
reporter.warn(`${options.who ?? "decompile"}: warning: ${nodeType}: ${note}`);
|
|
135
|
+
}
|
|
136
|
+
return openCliLibrary(argv, { always: true, missNote: (nodeType) => notes.get(fetchableNodeType(nodeType)) });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Fetch, through `uip`, what one probing run of `probe` found missing: the node
|
|
140
|
+
* types it resolved (`onMiss`) and the connectors it reversed a saved wire
|
|
141
|
+
* against (`onConnectorMiss`). A connector is fetched whole, with its typed
|
|
142
|
+
* module, because a decompiler identifies an operation from its saved method
|
|
143
|
+
* and path and so cannot name the node type it is missing.
|
|
144
|
+
*
|
|
145
|
+
* For the decompilers and BPMN `merge`, whose work has side effects or whose
|
|
146
|
+
* baseline must decompile the same way twice: the probe's result is discarded
|
|
147
|
+
* (and what it throws is swallowed), and the caller then opens the library
|
|
148
|
+
* once, with {@link openCliLibrary} and `always`, and runs for real. What could
|
|
149
|
+
* not be fetched is a warning; the caller's own refusal says the rest.
|
|
150
|
+
*/
|
|
151
|
+
export async function fetchMissedBy(argv, probe, options = {}) {
|
|
152
|
+
if (!fetchDefinitionsEnabled())
|
|
153
|
+
return;
|
|
154
|
+
const reporter = options.reporter ?? stderrReporter;
|
|
155
|
+
const who = options.who ?? "decompile";
|
|
156
|
+
const overlayDir = fetchOverlayDir(argv);
|
|
157
|
+
const client = options.client ? { client: options.client } : {};
|
|
158
|
+
const askedKeys = new Set();
|
|
159
|
+
const askedMisses = new Set();
|
|
160
|
+
// A fail-fast probe (Case decompile without --best-effort, a BPMN compile)
|
|
161
|
+
// stops at its first unknown connector, so it probes again after each fetch
|
|
162
|
+
// until it misses nothing it has not asked for.
|
|
163
|
+
for (;;) {
|
|
164
|
+
const keys = new Set();
|
|
165
|
+
const misses = [];
|
|
166
|
+
const library = openCliLibrary(argv, { always: true, onMiss: (miss) => misses.push(miss), onConnectorMiss: (key) => keys.add(key) });
|
|
167
|
+
try {
|
|
168
|
+
await probe(library);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// The real run reports it.
|
|
172
|
+
}
|
|
173
|
+
const freshKeys = [...keys].filter((key) => !askedKeys.has(key));
|
|
174
|
+
const freshMisses = misses.filter((miss) => !askedMisses.has(missKey(miss))
|
|
175
|
+
&& !library.indexes(fetchableNodeType(miss.nodeType), miss.objectName));
|
|
176
|
+
if (freshKeys.length === 0 && freshMisses.length === 0)
|
|
177
|
+
return;
|
|
178
|
+
for (const key of freshKeys)
|
|
179
|
+
askedKeys.add(key);
|
|
180
|
+
for (const miss of freshMisses)
|
|
181
|
+
askedMisses.add(missKey(miss));
|
|
182
|
+
const names = [...freshKeys, ...new Set(freshMisses.map((m) => m.nodeType))];
|
|
183
|
+
reporter.info(`${who}: ${names.join(", ")} not in the connector library; fetching through uip.`);
|
|
184
|
+
// The typed modules import the SDK's root, which exports the descriptor
|
|
185
|
+
// helpers, whatever specifier the decompiled source imports its family by.
|
|
186
|
+
const connectors = freshKeys.length > 0
|
|
187
|
+
// Only the operations no layer holds: a partially cached connector keeps its rows.
|
|
188
|
+
? await fetchConnectors(freshKeys, { overlayDir, importSpecifier: PACKAGE_NAME, reporter, skip: (nodeType) => library.indexes(nodeType), ...client })
|
|
189
|
+
: undefined;
|
|
190
|
+
const definitions = freshMisses.length > 0 ? await fetchDefinitions(freshMisses, { overlayDir, reporter, ...client }) : undefined;
|
|
191
|
+
const unavailable = connectors?.unavailable ?? definitions?.unavailable;
|
|
192
|
+
if (unavailable !== undefined) {
|
|
193
|
+
reporter.warn(`${who}: warning: nothing was fetched through uip: ${unavailable}.`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
for (const key of connectors?.unlisted ?? [])
|
|
197
|
+
reporter.warn(`${who}: warning: the tenant's catalog lists no action or event for ${key}.`);
|
|
198
|
+
for (const nodeType of [...(connectors?.notServed ?? []), ...(definitions?.notServed ?? [])]) {
|
|
199
|
+
reporter.warn(`${who}: warning: the tenant does not serve ${nodeType}.`);
|
|
200
|
+
}
|
|
201
|
+
for (const failure of [...(connectors?.failed ?? []), ...(definitions?.failed ?? [])]) {
|
|
202
|
+
reporter.warn(`${who}: warning: could not fetch ${failure.nodeType}: ${failure.reason}`);
|
|
203
|
+
}
|
|
204
|
+
if ((connectors?.fetched.length ?? 0) === 0 && (definitions?.fetched.length ?? 0) === 0)
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/** `text` as the end of a sentence: one closing period, whatever `uip`'s reason ended with. */
|
|
209
|
+
function sentence(text) {
|
|
210
|
+
return `${text.replace(/[\s.]+$/, "")}.`;
|
|
211
|
+
}
|
|
@@ -127,11 +127,18 @@ export declare function makeExpandedEventEntry(template: LibraryEntry, obj: unkn
|
|
|
127
127
|
* appended them as the describes completed); `build` sorts them before
|
|
128
128
|
* planning.
|
|
129
129
|
*/
|
|
130
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Which objects of a generic event to describe, by template and object name:
|
|
132
|
+
* every object when absent, as the library build wants. A fetch of one
|
|
133
|
+
* definition (`registry/fetch/`) passes the objects it was asked for, so it
|
|
134
|
+
* describes those and nothing else.
|
|
135
|
+
*/
|
|
136
|
+
export type EventObjectFilter = (template: LibraryEntry, objectName: string) => boolean;
|
|
137
|
+
export declare function expandGenericEvents(ctx: BuildContext, templates: LibraryEntry[], keep?: EventObjectFilter): Promise<LibraryEntry[]>;
|
|
131
138
|
/**
|
|
132
139
|
* `resolve_connector_events`: give every connector EVENT its real schema;
|
|
133
140
|
* expand the expandable ones. Returns `[entries, expanded]` — `entries` is the
|
|
134
141
|
* input with curated events described in place.
|
|
135
142
|
*/
|
|
136
|
-
export declare function resolveConnectorEvents(ctx: BuildContext, entries: LibraryEntry[]): Promise<[LibraryEntry[], LibraryEntry[]]>;
|
|
143
|
+
export declare function resolveConnectorEvents(ctx: BuildContext, entries: LibraryEntry[], keep?: EventObjectFilter): Promise<[LibraryEntry[], LibraryEntry[]]>;
|
|
137
144
|
export {};
|
|
@@ -465,13 +465,7 @@ export function makeExpandedEventEntry(template, obj, describe) {
|
|
|
465
465
|
item(entry, "display").label = pyStrip(`${pyStr(label)} (${pyStr(objectDisplay)})`);
|
|
466
466
|
return applyEventSchema(entry, describe, obj);
|
|
467
467
|
}
|
|
468
|
-
|
|
469
|
-
* `_expand_generic_events`: expand each generic EVENT template into one entry
|
|
470
|
-
* per event object. Variants come back in template × object order (the Python
|
|
471
|
-
* appended them as the describes completed); `build` sorts them before
|
|
472
|
-
* planning.
|
|
473
|
-
*/
|
|
474
|
-
export async function expandGenericEvents(ctx, templates) {
|
|
468
|
+
export async function expandGenericEvents(ctx, templates, keep) {
|
|
475
469
|
if (templates.length === 0)
|
|
476
470
|
return [];
|
|
477
471
|
const work = [];
|
|
@@ -481,7 +475,7 @@ export async function expandGenericEvents(ctx, templates) {
|
|
|
481
475
|
if (!pyTruthy(operation))
|
|
482
476
|
continue;
|
|
483
477
|
for (const obj of await triggersObjectsCached(ctx, key, operation)) {
|
|
484
|
-
if (pyTruthy(get(obj, "Name")))
|
|
478
|
+
if (pyTruthy(get(obj, "Name")) && (!keep || keep(template, item(obj, "Name"))))
|
|
485
479
|
work.push([template, key, operation, obj]);
|
|
486
480
|
}
|
|
487
481
|
}
|
|
@@ -497,7 +491,7 @@ export async function expandGenericEvents(ctx, templates) {
|
|
|
497
491
|
* expand the expandable ones. Returns `[entries, expanded]` — `entries` is the
|
|
498
492
|
* input with curated events described in place.
|
|
499
493
|
*/
|
|
500
|
-
export async function resolveConnectorEvents(ctx, entries) {
|
|
494
|
+
export async function resolveConnectorEvents(ctx, entries, keep) {
|
|
501
495
|
const curated = [];
|
|
502
496
|
const generic = [];
|
|
503
497
|
for (const e of entries) {
|
|
@@ -521,5 +515,5 @@ export async function resolveConnectorEvents(ctx, entries) {
|
|
|
521
515
|
if (curated.length === 0 && generic.length === 0)
|
|
522
516
|
return [entries, []];
|
|
523
517
|
await describeCuratedEvents(ctx, curated);
|
|
524
|
-
return [entries, await expandGenericEvents(ctx, generic)];
|
|
518
|
+
return [entries, await expandGenericEvents(ctx, generic, keep)];
|
|
525
519
|
}
|
|
@@ -20,6 +20,15 @@ export declare const CONNECTORS_LIBRARY_VERSION_ENV = "CONNECTORS_LIBRARY_VERSIO
|
|
|
20
20
|
* rather than guessed at, so a typo cannot fall back to "latest" silently.
|
|
21
21
|
*/
|
|
22
22
|
export declare function connectorsLibraryUrl(argv: string[], env?: Record<string, string | undefined>): string;
|
|
23
|
+
/**
|
|
24
|
+
* The published archive could not be reached: an HTTP error or a network
|
|
25
|
+
* failure, for the checksum or the archive itself. The one failure a pull
|
|
26
|
+
* survives, by fetching through `uip` instead. A checksum MISMATCH is not one
|
|
27
|
+
* of these: bytes that do not match their sidecar are refused, not routed around.
|
|
28
|
+
*/
|
|
29
|
+
export declare class ArchiveUnavailableError extends Error {
|
|
30
|
+
constructor(message: string);
|
|
31
|
+
}
|
|
23
32
|
/**
|
|
24
33
|
* Point `current` at an entry, replacing whatever it named.
|
|
25
34
|
*
|
|
@@ -9,6 +9,9 @@ import { materializeRegistry } from "./materializer.js";
|
|
|
9
9
|
import { curatedOverlayIdentity } from "./curated-overlay.js";
|
|
10
10
|
import { generatorIdentity } from "./generator-identity.js";
|
|
11
11
|
import { WORK_DIR, workPath } from "../workdir.js";
|
|
12
|
+
import { PACKAGE_NAME } from "../package-name.js";
|
|
13
|
+
import { fetchConnectors } from "./fetch/fetch-connectors.js";
|
|
14
|
+
import { stderrReporter } from "./reporter.js";
|
|
12
15
|
/**
|
|
13
16
|
* Fetch the published connector library into the shared cache, and generate the
|
|
14
17
|
* typed descriptors a project imports.
|
|
@@ -25,6 +28,13 @@ import { WORK_DIR, workPath } from "../workdir.js";
|
|
|
25
28
|
*
|
|
26
29
|
* `--library` and `--library-md` still name destinations, for a caller that wants
|
|
27
30
|
* the trees somewhere specific instead of in the cache.
|
|
31
|
+
*
|
|
32
|
+
* The archive is an optimization, not a requirement
|
|
33
|
+
* (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md). When it cannot be downloaded,
|
|
34
|
+
* the connectors the project references are fetched from the tenant through
|
|
35
|
+
* `uip` into `connectors-local` instead, with the typed modules beside them,
|
|
36
|
+
* and the pull succeeds. Only a `uip` that cannot be asked (not installed, not
|
|
37
|
+
* logged in) makes that fail.
|
|
28
38
|
*/
|
|
29
39
|
const DEFAULT_URL = "https://download.uipath.com/maestro/registry/library-json.zip";
|
|
30
40
|
/** Where each published build is kept, immutably, beside the stable alias. */
|
|
@@ -73,9 +83,13 @@ const USAGE = [
|
|
|
73
83
|
" [--library <dir>] [--library-md <dir>]",
|
|
74
84
|
" [--url <url>] [--archive <zip>] [--force]",
|
|
75
85
|
" [--import <specifier>] [--triggers <path>] [--root <prefix>]",
|
|
86
|
+
" [--connectors-local <dir>]",
|
|
76
87
|
"",
|
|
77
88
|
'Without --url, CONNECTORS_LIBRARY_VERSION selects the library: unset or "latest" for',
|
|
78
89
|
"the current published build, or a build number such as connectors-library-2026.09.9.",
|
|
90
|
+
"",
|
|
91
|
+
"When the library cannot be downloaded, the referenced connectors are fetched through",
|
|
92
|
+
"uip into --connectors-local (default .flow-sdk/connectors-local) instead.",
|
|
79
93
|
].join("\n");
|
|
80
94
|
/** Flags from the Python era, accepted for one release and ignored. */
|
|
81
95
|
const IGNORED = ["--python", "--extractor", "--generator"];
|
|
@@ -115,12 +129,49 @@ async function isFileAsync(path) {
|
|
|
115
129
|
return false;
|
|
116
130
|
}
|
|
117
131
|
}
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
/**
|
|
133
|
+
* The published archive could not be reached: an HTTP error or a network
|
|
134
|
+
* failure, for the checksum or the archive itself. The one failure a pull
|
|
135
|
+
* survives, by fetching through `uip` instead. A checksum MISMATCH is not one
|
|
136
|
+
* of these: bytes that do not match their sidecar are refused, not routed around.
|
|
137
|
+
*/
|
|
138
|
+
export class ArchiveUnavailableError extends Error {
|
|
139
|
+
constructor(message) {
|
|
140
|
+
super(message);
|
|
141
|
+
this.name = "ArchiveUnavailableError";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** `fetch(url)`, with a network failure as {@link ArchiveUnavailableError}. */
|
|
145
|
+
async function reach(url) {
|
|
146
|
+
let response;
|
|
147
|
+
try {
|
|
148
|
+
response = await fetch(url);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
const cause = error.cause;
|
|
152
|
+
const detail = cause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error);
|
|
153
|
+
throw new ArchiveUnavailableError(`Could not download ${url}: ${detail}`);
|
|
154
|
+
}
|
|
120
155
|
if (!response.ok) {
|
|
121
|
-
throw new
|
|
156
|
+
throw new ArchiveUnavailableError(`Could not download ${url}: HTTP ${response.status} ${response.statusText}`);
|
|
122
157
|
}
|
|
123
|
-
return
|
|
158
|
+
return response;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* `fetch` resolves on the headers; the body can still fail mid-read. That is
|
|
162
|
+
* the archive being unreachable too, not a bad archive.
|
|
163
|
+
*/
|
|
164
|
+
async function readBody(url, read) {
|
|
165
|
+
try {
|
|
166
|
+
return await read();
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
throw new ArchiveUnavailableError(`Could not download ${url}: ${error instanceof Error ? error.message : String(error)}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function download(url) {
|
|
173
|
+
const response = await reach(url);
|
|
174
|
+
return new Uint8Array(await readBody(url, () => response.arrayBuffer()));
|
|
124
175
|
}
|
|
125
176
|
/** `http://u:p@h` -> `http://***@h` */
|
|
126
177
|
function redactProxyCredentials(proxy) {
|
|
@@ -163,11 +214,8 @@ async function resolveArchive(argv, cacheDir, force) {
|
|
|
163
214
|
console.error(`registry pull: library from ${url}`);
|
|
164
215
|
}
|
|
165
216
|
warnAboutProxy();
|
|
166
|
-
const checksumResponse = await
|
|
167
|
-
|
|
168
|
-
throw new Error(`Could not download ${url}.sha256: HTTP ${checksumResponse.status} ${checksumResponse.statusText}`);
|
|
169
|
-
}
|
|
170
|
-
const expected = expectedChecksum(await checksumResponse.text());
|
|
217
|
+
const checksumResponse = await reach(`${url}.sha256`);
|
|
218
|
+
const expected = expectedChecksum(await readBody(`${url}.sha256`, () => checksumResponse.text()));
|
|
171
219
|
await mkdir(cacheDir, { recursive: true });
|
|
172
220
|
const cached = join(cacheDir, `${expected}.zip`);
|
|
173
221
|
if (!force && (await isFileAsync(cached))) {
|
|
@@ -321,7 +369,15 @@ export async function run(argv) {
|
|
|
321
369
|
// `.flow-sdk/connectors`, or a legacy `connectors/` the workspace already has.
|
|
322
370
|
const connectorsPath = value(argv, "--connectors") ?? workPath("connectors");
|
|
323
371
|
try {
|
|
324
|
-
|
|
372
|
+
let archive;
|
|
373
|
+
try {
|
|
374
|
+
archive = await resolveArchive(argv, cacheDir, force);
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
if (!(error instanceof ArchiveUnavailableError))
|
|
378
|
+
throw error;
|
|
379
|
+
return await pullWithoutArchive(argv, error.message);
|
|
380
|
+
}
|
|
325
381
|
const archiveSha256 = await archiveIdentity(archive);
|
|
326
382
|
const overlaySha256 = await curatedOverlayIdentity();
|
|
327
383
|
const generatorSha256 = await generatorIdentity();
|
|
@@ -407,3 +463,87 @@ export async function run(argv) {
|
|
|
407
463
|
return 1;
|
|
408
464
|
}
|
|
409
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* The pull when the archive is unreachable: the referenced connectors (or each
|
|
468
|
+
* `--connector`) fetched through `uip` into `--connectors-local`, else
|
|
469
|
+
* `.flow-sdk/connectors-local`, with their typed modules.
|
|
470
|
+
*
|
|
471
|
+
* Exits 1 only when nothing could be asked (no `uip`, no login) or a fetch
|
|
472
|
+
* failed outright. A connector the tenant does not list is a warning: the
|
|
473
|
+
* author's next `check` names it, and on Automation Suite it may simply not be
|
|
474
|
+
* approved.
|
|
475
|
+
*/
|
|
476
|
+
async function pullWithoutArchive(argv, why) {
|
|
477
|
+
const overlayDir = value(argv, "--connectors-local") ?? workPath("connectors-local");
|
|
478
|
+
const named = repeated(argv, "--connector");
|
|
479
|
+
const keys = named.length > 0
|
|
480
|
+
? named
|
|
481
|
+
: [...new Set([...referencedConnectorKeys("."), ...referencedConnectorKeys(WORK_DIR)])].sort();
|
|
482
|
+
console.error(`registry pull: ${why}`);
|
|
483
|
+
// The fallback answers only the default request: the published library,
|
|
484
|
+
// wherever the cache keeps it. A request that named a build, a source or a
|
|
485
|
+
// destination asked for THAT library, so it is refused, naming the flag,
|
|
486
|
+
// rather than answered from the tenant with nothing where it asked
|
|
487
|
+
// (`--connectors` would also need modules away from the definitions they
|
|
488
|
+
// import by relative path).
|
|
489
|
+
const refusedBy = explicitLibraryRequest(argv);
|
|
490
|
+
if (refusedBy !== undefined) {
|
|
491
|
+
console.error(`registry pull: ${refusedBy} asks for that library, and it is unavailable, so nothing was fetched through uip instead. ` +
|
|
492
|
+
`Fix the request, or drop ${refusedBy.split(" ")[0]} to fetch the referenced connectors through uip into ${overlayDir} (\`--connectors-local\`).`);
|
|
493
|
+
return 2;
|
|
494
|
+
}
|
|
495
|
+
if (keys.length === 0) {
|
|
496
|
+
console.error("registry pull: the connector library is unavailable and no connector is referenced by this project yet. " +
|
|
497
|
+
"Name one with `--connector <key>` to fetch it through uip.");
|
|
498
|
+
reportResult({ library: null, overlay: resolve(overlayDir), fetched: [] });
|
|
499
|
+
return 0;
|
|
500
|
+
}
|
|
501
|
+
console.error(`registry pull: fetching ${keys.join(", ")} through uip into ${overlayDir} instead.`);
|
|
502
|
+
const result = await fetchConnectors(keys, {
|
|
503
|
+
overlayDir,
|
|
504
|
+
importSpecifier: value(argv, "--import") ?? PACKAGE_NAME,
|
|
505
|
+
reporter: stderrReporter,
|
|
506
|
+
});
|
|
507
|
+
if (result.unavailable !== undefined) {
|
|
508
|
+
console.error(`registry pull: the connector library is unavailable, and uip cannot fetch definitions instead: ${result.unavailable}.`);
|
|
509
|
+
return 1;
|
|
510
|
+
}
|
|
511
|
+
for (const key of result.unlisted) {
|
|
512
|
+
console.error(`registry pull: the tenant's catalog lists no action or event for ${key}.`);
|
|
513
|
+
}
|
|
514
|
+
// A key named with --connector that the tenant does not list is a mistake
|
|
515
|
+
// (often a typo); one found by scanning the project is only reported.
|
|
516
|
+
const namedUnlisted = result.unlisted.filter((key) => named.includes(key));
|
|
517
|
+
for (const nodeType of result.notServed) {
|
|
518
|
+
console.error(`registry pull: the tenant does not serve ${nodeType}.`);
|
|
519
|
+
}
|
|
520
|
+
for (const failure of result.failed) {
|
|
521
|
+
console.error(`registry pull: could not fetch ${failure.nodeType}: ${failure.reason}`);
|
|
522
|
+
}
|
|
523
|
+
reportResult({
|
|
524
|
+
library: null,
|
|
525
|
+
overlay: resolve(overlayDir),
|
|
526
|
+
fetched: result.fetched,
|
|
527
|
+
modules: result.modules,
|
|
528
|
+
notServed: result.notServed,
|
|
529
|
+
unlisted: result.unlisted,
|
|
530
|
+
});
|
|
531
|
+
console.error(`registry pull: fetched ${result.fetched.length} definition(s) for ${keys.join(", ")} into ${overlayDir}` +
|
|
532
|
+
(result.modules.length > 0 ? `, with ${result.modules.join(", ")}` : "") + ".");
|
|
533
|
+
return result.failed.length > 0 || namedUnlisted.length > 0 ? 1 : 0;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* The flag (with its value) that asked for a specific library, or `undefined`
|
|
537
|
+
* for the default request the uip fallback may answer.
|
|
538
|
+
*/
|
|
539
|
+
function explicitLibraryRequest(argv) {
|
|
540
|
+
for (const flag of ["--url", "--library", "--library-md", "--connectors", "--root", "--triggers"]) {
|
|
541
|
+
const given = value(argv, flag);
|
|
542
|
+
if (given !== undefined)
|
|
543
|
+
return `${flag} ${given}`;
|
|
544
|
+
}
|
|
545
|
+
const version = process.env[CONNECTORS_LIBRARY_VERSION_ENV]?.trim();
|
|
546
|
+
if (version && version.toLowerCase() !== "latest")
|
|
547
|
+
return `${CONNECTORS_LIBRARY_VERSION_ENV}=${version}`;
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type UipClient } from "./uip/client.js";
|
|
1
2
|
/**
|
|
2
3
|
* Search an extracted connector library for operations.
|
|
3
4
|
*
|
|
@@ -36,6 +37,18 @@ export interface RegistrySearchOptions {
|
|
|
36
37
|
export interface RegistrySearchResult {
|
|
37
38
|
total: number;
|
|
38
39
|
operations: RegistryOperation[];
|
|
40
|
+
/**
|
|
41
|
+
* `tenant` when the answer is the tenant's live catalog through `uip`, because
|
|
42
|
+
* no library was pulled. Its operations carry no `definitionPath`: the
|
|
43
|
+
* definition is fetched when `check`, `compile` or `registry describe` needs it.
|
|
44
|
+
*/
|
|
45
|
+
source?: "tenant";
|
|
46
|
+
/**
|
|
47
|
+
* What `uip` said the answer may lack, verbatim: node sources its catalog copy
|
|
48
|
+
* is missing, so more matches may exist. A result carrying one is not the
|
|
49
|
+
* tenant's whole catalog, however few rows it has.
|
|
50
|
+
*/
|
|
51
|
+
warning?: string;
|
|
39
52
|
}
|
|
40
53
|
export declare const DEFAULT_SEARCH_LIMIT = 20;
|
|
41
54
|
/**
|
|
@@ -49,4 +62,16 @@ export declare const DEFAULT_SEARCH_LIMIT = 20;
|
|
|
49
62
|
*/
|
|
50
63
|
export declare function queryTokens(query?: string): string[];
|
|
51
64
|
export declare function searchRegistryOperations(options: RegistrySearchOptions): Promise<RegistrySearchResult>;
|
|
65
|
+
/**
|
|
66
|
+
* The search over the tenant's live catalog, for when no library was pulled
|
|
67
|
+
* (docs/CONNECTOR_LIBRARY_OPTIONAL_DESIGN.md §3.5): every connector node type
|
|
68
|
+
* `uip maestro flow registry search` lists, matched with the same tokens and
|
|
69
|
+
* `--connector` rule as the library search. On Automation Suite this is the
|
|
70
|
+
* curated catalog, which no published library describes.
|
|
71
|
+
*/
|
|
72
|
+
/** No library, and uip cannot be asked: a blocked mode (exit 2), as "no library cached" is with fetching off. */
|
|
73
|
+
export declare class TenantSearchBlocked extends Error {
|
|
74
|
+
name: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function searchTenantOperations(options: Omit<RegistrySearchOptions, "libraryPath" | "markdownPath">, client?: UipClient): Promise<RegistrySearchResult>;
|
|
52
77
|
export declare function run(argv: string[]): Promise<number>;
|