@uipath/maestro-builder-sdk 6.119.0 → 6.119.2
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/check-cli.js +1 -1
- package/dist/check.d.ts +7 -0
- package/dist/check.js +22 -1
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +1 -0
- package/dist/merge-baseline-connections.d.ts +25 -0
- package/dist/merge-baseline-connections.js +113 -0
- package/dist/merge.js +19 -0
- package/dist/registry/prepare/messages.d.ts +5 -3
- package/dist/registry/prepare/messages.js +20 -6
- package/dist/registry/prepare/pipeline.d.ts +2 -0
- package/dist/registry/prepare/pipeline.js +19 -4
- package/dist/registry/prepare/resolve.d.ts +11 -0
- package/dist/registry/prepare/resolve.js +25 -1
- package/dist/registry/prepare/retry.js +14 -4
- package/dist/registry/prepare/solution-connection.d.ts +37 -0
- package/dist/registry/prepare/solution-connection.js +60 -0
- package/dist/registry/uip/commands.d.ts +9 -0
- package/dist/registry/uip/commands.js +14 -0
- package/dist/script-type-check.d.ts +22 -0
- package/dist/script-type-check.js +89 -0
- package/package.json +2 -2
package/dist/check-cli.js
CHANGED
|
@@ -58,7 +58,7 @@ function checkOpts(argv, library, solution) {
|
|
|
58
58
|
// The resource ledger `prepare` writes, the default found as bindings.json is.
|
|
59
59
|
const resources = readCliResources(argv, defaultResourcesFile());
|
|
60
60
|
// The node registry cache a manifest-less `rawNode` resolves from (#1981), read on first use.
|
|
61
|
-
return { ...flowCheckOpts(library, bindings), ...(resources ? { resources } : {}), nodeCatalog: readNodeCatalog(), ...(solution ? { solution } : {}) };
|
|
61
|
+
return { ...flowCheckOpts(library, bindings), ...(resources ? { resources } : {}), nodeCatalog: readNodeCatalog(), ...(solution ? { solution } : {}), scriptTypes: true };
|
|
62
62
|
}
|
|
63
63
|
export async function run(argv) {
|
|
64
64
|
const arg = argv.find((a, i) => !a.startsWith('--') && !VALUE_FLAGS.has(argv[i - 1])) ?? argv[0];
|
package/dist/check.d.ts
CHANGED
|
@@ -96,6 +96,13 @@ export interface CheckOpts extends ConnectorCheckOpts, EventCheckOpts {
|
|
|
96
96
|
nodeCatalog?: NodeCatalog;
|
|
97
97
|
/** `false` skips the serializer pass, for a caller that compiles the flow itself (`merge`). */
|
|
98
98
|
serializer?: false;
|
|
99
|
+
/**
|
|
100
|
+
* Type-check each script body of the compiled flow as Studio Web's script editor does
|
|
101
|
+
* (`script-type-check.ts`) and report its complaints as `SCRIPT_TYPE_DIAGNOSTIC`
|
|
102
|
+
* warnings. Off unless set: it parses the ES2020 library, which `flow check` pays and
|
|
103
|
+
* `compile` and `merge` need not.
|
|
104
|
+
*/
|
|
105
|
+
scriptTypes?: boolean;
|
|
99
106
|
}
|
|
100
107
|
export declare function check(built: BuiltFlow, opts?: CheckOpts): Diagnostic[];
|
|
101
108
|
/**
|
package/dist/check.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { typescript } from './core/typescript-module.js';
|
|
2
|
+
import { scriptTypeFindings, scriptTypeHint } from './script-type-check.js';
|
|
2
3
|
import { isResourceToken } from './core/resource-resolution.js';
|
|
3
4
|
import { isLookupToken } from './core/lookups.js';
|
|
4
5
|
import { prepareCommand } from './core/cli-spelling.js';
|
|
@@ -69,6 +70,24 @@ export function checkCompiled(built, opts = {}) {
|
|
|
69
70
|
});
|
|
70
71
|
return { diagnostics, flow: serialized.flow, ...(serialized.stoppedAt ? { stoppedAt: serialized.stoppedAt } : {}) };
|
|
71
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The canvas's script type complaints on the script bodies of one flow level (the code
|
|
75
|
+
* sites its node types declare), one warning each (`script-type-check.ts`).
|
|
76
|
+
* For example `const t = {}; t.summary = 1;` in step `formatComment` gives
|
|
77
|
+
* `[SCRIPT_TYPE_DIAGNOSTIC] Script step "formatComment", line 2: Studio Web type-checks …
|
|
78
|
+
* and reports this as a validation warning: Property 'summary' does not exist on type '{}'. (TS2339) …`.
|
|
79
|
+
*/
|
|
80
|
+
function scriptTypeDiagnostics(bodies) {
|
|
81
|
+
return scriptTypeFindings(bodies.map((b) => ({ step: b.step, body: b.js }))).map((f) => {
|
|
82
|
+
const hint = scriptTypeHint(f);
|
|
83
|
+
return {
|
|
84
|
+
level: 'warning', code: 'SCRIPT_TYPE_DIAGNOSTIC', step: f.step,
|
|
85
|
+
message: `Script step "${f.step}", line ${f.line}: Studio Web type-checks script bodies as TypeScript and reports this as a validation warning: `
|
|
86
|
+
+ `${f.message} (TS${f.tsCode}). The engine runs the body as JavaScript, so the run is not affected.`
|
|
87
|
+
+ (hint ? ` ${hint}` : ''),
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
72
91
|
/**
|
|
73
92
|
* Scope `edited`'s findings to the edit, against `baseline`: the original
|
|
74
93
|
* `.flow` decompiled and checked the same way (`flow check --baseline`,
|
|
@@ -868,6 +887,8 @@ function checkFlow(built, ancestors, opts = {}) {
|
|
|
868
887
|
}
|
|
869
888
|
checkStepRefs(built, diags);
|
|
870
889
|
checkArmScopedReads(built, diags);
|
|
890
|
+
if (opts.scriptTypes)
|
|
891
|
+
diags.push(...scriptTypeDiagnostics(exprs.filter((e) => e.code)));
|
|
871
892
|
// A fire-and-forget dispatch publishes no output: any read of it would wait
|
|
872
893
|
// on a value the run will never produce. Error reads stay legal — dispatch
|
|
873
894
|
// failures still route (design §2.2).
|
|
@@ -2624,7 +2645,7 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
|
|
|
2624
2645
|
if ('code' in site) {
|
|
2625
2646
|
// A script body: checked for its `$vars.` refs although it is a string. No
|
|
2626
2647
|
// errorSource, as for `script()` (collectActionExprs).
|
|
2627
|
-
exprs.push({ js: site.code, step: s.name });
|
|
2648
|
+
exprs.push({ js: site.code, step: s.name, code: true });
|
|
2628
2649
|
}
|
|
2629
2650
|
else {
|
|
2630
2651
|
pushDeepExprs(site.value, s.name, errorSource, exprs);
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -736,6 +736,7 @@ export declare const REFUSALS: {
|
|
|
736
736
|
readonly SCRIPT_RESULT_NOT_RESPONSE: "lint";
|
|
737
737
|
readonly SCRIPT_RETURNS_UNKNOWN_TYPE: "lint";
|
|
738
738
|
readonly SCRIPT_TASK_NO_BODY: "lint";
|
|
739
|
+
readonly SCRIPT_TYPE_DIAGNOSTIC: "lint";
|
|
739
740
|
readonly SDK_RESOLVE_HOOK_MISSING: "lowering";
|
|
740
741
|
readonly SELECT_NEXT_STAGE_EXIT_TYPE: "lowering";
|
|
741
742
|
readonly SELECT_NEXT_STAGE_MULTIPLE: "lowering";
|
package/dist/core/refusals.js
CHANGED
|
@@ -812,6 +812,7 @@ export const REFUSALS = {
|
|
|
812
812
|
SCRIPT_RESULT_NOT_RESPONSE: 'lint',
|
|
813
813
|
SCRIPT_RETURNS_UNKNOWN_TYPE: 'lint',
|
|
814
814
|
SCRIPT_TASK_NO_BODY: 'lint',
|
|
815
|
+
SCRIPT_TYPE_DIAGNOSTIC: 'lint',
|
|
815
816
|
SDK_RESOLVE_HOOK_MISSING: 'lowering',
|
|
816
817
|
SELECT_NEXT_STAGE_EXIT_TYPE: 'lowering',
|
|
817
818
|
SELECT_NEXT_STAGE_MULTIPLE: 'lowering',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AnyFlow } from './edit-scope.js';
|
|
2
|
+
/** The `inputs.detail` fields a bindings.json entry resolves a label into. */
|
|
3
|
+
declare const CONNECTION_FIELDS: readonly ["connectionId", "connectionResourceId", "connectionFolderKey"];
|
|
4
|
+
/** One field the baseline resolved that the original carries as written. */
|
|
5
|
+
export interface ResolvedConnectionField {
|
|
6
|
+
/** The subflow key, or `undefined` at the root. */
|
|
7
|
+
subflow?: string;
|
|
8
|
+
nodeId: string;
|
|
9
|
+
field: (typeof CONNECTION_FIELDS)[number];
|
|
10
|
+
/** The original's value: the label. */
|
|
11
|
+
original: string;
|
|
12
|
+
/** The baseline's value: what the label resolved to. */
|
|
13
|
+
baseline: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The baseline with the original's connection labels restored, and each field
|
|
17
|
+
* restored. Returns the baseline itself (not a copy) when nothing differs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withOriginalConnectionLabels(original: AnyFlow, baseline: AnyFlow): {
|
|
20
|
+
baseline: AnyFlow;
|
|
21
|
+
restored: ResolvedConnectionField[];
|
|
22
|
+
};
|
|
23
|
+
/** The warning merge prints for each node whose baseline it restored. */
|
|
24
|
+
export declare function restoredConnectionMessage(fields: readonly ResolvedConnectionField[]): string[];
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* merge-baseline-connections — give a precompiled baseline the original's
|
|
3
|
+
* connection labels back (UV-17831 item 4).
|
|
4
|
+
*
|
|
5
|
+
* The baseline is compile(decompile(original)) before the edit, so merge reads
|
|
6
|
+
* "edited equals baseline" as "untouched". That holds only while the baseline
|
|
7
|
+
* reproduces the original. A connection the original carries as a label
|
|
8
|
+
* (`"slack"`, compiled before bindings.json named it) does not survive a compile
|
|
9
|
+
* that resolves labels through bindings.json: the baseline gets the real id. A
|
|
10
|
+
* later edit that swaps the label for that id then equals the baseline, merge
|
|
11
|
+
* keeps the original node, and the edit is dropped without an error.
|
|
12
|
+
*
|
|
13
|
+
* `flow merge --baseline-from` and the stamped source form compile the baseline
|
|
14
|
+
* themselves with no bindings, so their baseline keeps the label (#1929). A
|
|
15
|
+
* baseline file compiled elsewhere (the decompile pipeline's
|
|
16
|
+
* `<Name>.baseline/<Name>.flow`, a supplied source's baseline, any
|
|
17
|
+
* `flow compile` run with `.flow-sdk/bindings.json` present) is fixed up here,
|
|
18
|
+
* so every merge with a baseline compares the edit against the same thing.
|
|
19
|
+
*
|
|
20
|
+
* Example. Original node `notify`: `connectionId: "slack"`; baseline file:
|
|
21
|
+
* `connectionId: "0f0e…"` (resolved). After this, the baseline says `"slack"`,
|
|
22
|
+
* the edit's `"0f0e…"` differs from it, and merge writes the id.
|
|
23
|
+
*
|
|
24
|
+
* Only a label (not a GUID) the baseline resolved to a GUID is restored, and only
|
|
25
|
+
* in the fields a connection binding resolves
|
|
26
|
+
* (`inputs.detail.connectionId`, `connectionResourceId`, `connectionFolderKey`),
|
|
27
|
+
* plus the binding rows that carry the resolved values under the original row's
|
|
28
|
+
* id. Every other round-trip difference is left for merge-roundtrip.ts to report.
|
|
29
|
+
*/
|
|
30
|
+
import { GUID_RE } from './core/binding-messages.js';
|
|
31
|
+
import { jsonClone } from './core/json-clone.js';
|
|
32
|
+
import { isRecord } from './core/node-envelope.js';
|
|
33
|
+
/** The `inputs.detail` fields a bindings.json entry resolves a label into. */
|
|
34
|
+
const CONNECTION_FIELDS = ['connectionId', 'connectionResourceId', 'connectionFolderKey'];
|
|
35
|
+
function detailOf(node) {
|
|
36
|
+
const detail = node?.inputs?.detail;
|
|
37
|
+
return isRecord(detail) ? detail : undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The baseline with the original's connection labels restored, and each field
|
|
41
|
+
* restored. Returns the baseline itself (not a copy) when nothing differs.
|
|
42
|
+
*/
|
|
43
|
+
export function withOriginalConnectionLabels(original, baseline) {
|
|
44
|
+
const restored = [];
|
|
45
|
+
const scopes = [
|
|
46
|
+
[undefined, original, baseline],
|
|
47
|
+
...Object.keys(baseline.subflows ?? {}).map((key) => [
|
|
48
|
+
key,
|
|
49
|
+
original.subflows?.[key],
|
|
50
|
+
baseline.subflows?.[key],
|
|
51
|
+
]),
|
|
52
|
+
];
|
|
53
|
+
for (const [subflow, o, b] of scopes) {
|
|
54
|
+
const origById = new Map((o?.nodes ?? []).map((n) => [n.id, n]));
|
|
55
|
+
for (const node of b?.nodes ?? []) {
|
|
56
|
+
const od = detailOf(origById.get(node.id));
|
|
57
|
+
const bd = detailOf(node);
|
|
58
|
+
if (!od || !bd)
|
|
59
|
+
continue;
|
|
60
|
+
for (const field of CONNECTION_FIELDS) {
|
|
61
|
+
const ov = od[field];
|
|
62
|
+
const bv = bd[field];
|
|
63
|
+
// Only a label the baseline resolved to an id: never a differing id or
|
|
64
|
+
// a differing label, which are real round-trip changes merge reports.
|
|
65
|
+
if (typeof ov === 'string' && ov !== '' && !GUID_RE.test(ov) && typeof bv === 'string' && GUID_RE.test(bv)) {
|
|
66
|
+
restored.push({ ...(subflow !== undefined ? { subflow } : {}), nodeId: node.id, field, original: ov, baseline: bv });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (restored.length === 0)
|
|
72
|
+
return { baseline, restored };
|
|
73
|
+
const fixed = jsonClone(baseline);
|
|
74
|
+
const fixedScope = (subflow) => subflow === undefined ? fixed : fixed.subflows?.[subflow];
|
|
75
|
+
for (const r of restored) {
|
|
76
|
+
const detail = detailOf(fixedScope(r.subflow)?.nodes?.find((n) => n.id === r.nodeId));
|
|
77
|
+
if (detail)
|
|
78
|
+
detail[r.field] = r.original;
|
|
79
|
+
}
|
|
80
|
+
// A row is the original's row with the resolved values in it: same id, and
|
|
81
|
+
// equal to the original's once each resolved value is mapped back to its label.
|
|
82
|
+
const labelOf = new Map(restored.map((r) => [r.baseline, r.original]));
|
|
83
|
+
const origRows = new Map((original.bindings ?? []).filter((r) => typeof r.id === 'string').map((r) => [r.id, r]));
|
|
84
|
+
if (fixed.bindings) {
|
|
85
|
+
fixed.bindings = fixed.bindings.map((row) => {
|
|
86
|
+
const orig = typeof row.id === 'string' ? origRows.get(row.id) : undefined;
|
|
87
|
+
if (!orig || row.resource !== 'connection')
|
|
88
|
+
return row;
|
|
89
|
+
const unresolved = Object.fromEntries(Object.entries(row).map(([k, v]) => [k, typeof v === 'string' ? labelOf.get(v) ?? v : v]));
|
|
90
|
+
return JSON.stringify(sorted(unresolved)) === JSON.stringify(sorted(orig)) ? jsonClone(orig) : row;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return { baseline: fixed, restored };
|
|
94
|
+
}
|
|
95
|
+
function sorted(o) {
|
|
96
|
+
return Object.fromEntries(Object.entries(o).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
97
|
+
}
|
|
98
|
+
/** The warning merge prints for each node whose baseline it restored. */
|
|
99
|
+
export function restoredConnectionMessage(fields) {
|
|
100
|
+
const byNode = new Map();
|
|
101
|
+
for (const f of fields) {
|
|
102
|
+
const key = `${f.subflow ?? ''}\n${f.nodeId}`;
|
|
103
|
+
byNode.set(key, [...(byNode.get(key) ?? []), f]);
|
|
104
|
+
}
|
|
105
|
+
return [...byNode.values()].map((fs) => {
|
|
106
|
+
const where = fs[0].subflow !== undefined ? ` in subflow "${fs[0].subflow}"` : '';
|
|
107
|
+
const pairs = [...new Map(fs.map((f) => [`${f.original}\n${f.baseline}`, f])).values()]
|
|
108
|
+
.map((f) => `"${f.original}" -> "${f.baseline}"`).join(', ');
|
|
109
|
+
return `the baseline resolves the connection of node "${fs[0].nodeId}"${where} (${pairs}), which the original carries as a label: `
|
|
110
|
+
+ 'the baseline was compiled with a bindings.json and the original was not. Merge compares the edit against the original\'s label, '
|
|
111
|
+
+ 'so the connection the edited flow names is written.';
|
|
112
|
+
});
|
|
113
|
+
}
|
package/dist/merge.js
CHANGED
|
@@ -105,6 +105,7 @@ import { mergeAgentSidecars } from './merge-sidecars.js';
|
|
|
105
105
|
import { embeddedAgentFindings, isEmbeddedAgent, mergeEmbeddedAgentNode } from './merge-embedded-agent.js';
|
|
106
106
|
import { mergeObject, mergeVariables, stableJson } from './merge-variables.js';
|
|
107
107
|
import { replaceSupersededOutputs } from './merge-superseded-outputs.js';
|
|
108
|
+
import { restoredConnectionMessage, withOriginalConnectionLabels } from './merge-baseline-connections.js';
|
|
108
109
|
import { byId, isKept, nodeUnchanged, subflowsTakenFromEdited } from './edit-scope.js';
|
|
109
110
|
export { MergeRefusedError } from './merge-roundtrip.js';
|
|
110
111
|
/**
|
|
@@ -392,6 +393,7 @@ function positionStoreOf(f) {
|
|
|
392
393
|
return nodes && Object.keys(nodes).length > 0 ? nodes : undefined;
|
|
393
394
|
}
|
|
394
395
|
export function mergeFlow(original, edited, options = {}) {
|
|
396
|
+
options = withFaithfulBaseline(original, options);
|
|
395
397
|
const { result, findings, agentFindings } = mergeFlowFindings(original, edited, options);
|
|
396
398
|
reportOrRefuse([...findings, ...agentFindings()], options);
|
|
397
399
|
return result;
|
|
@@ -407,6 +409,7 @@ export function mergeFlow(original, edited, options = {}) {
|
|
|
407
409
|
* project's `agent.json` is refused in every mode. See merge-sidecars.ts.
|
|
408
410
|
*/
|
|
409
411
|
export function mergeFlowWithSidecars(original, edited, sidecars, options = {}) {
|
|
412
|
+
options = withFaithfulBaseline(original, options);
|
|
410
413
|
const { result, findings, agentFindings } = mergeFlowFindings(original, edited, options);
|
|
411
414
|
const carried = mergeAgentSidecars(result, sidecars, { original, baseline: options.baseline, edited });
|
|
412
415
|
// After the carry: what it wrote onto an embedded node is the author's.
|
|
@@ -419,6 +422,22 @@ export function mergeFlowWithSidecars(original, edited, sidecars, options = {})
|
|
|
419
422
|
onNodes: carried.onNodes.map((c) => ({ nodeId: c.node.id, inputs: c.inputs })),
|
|
420
423
|
};
|
|
421
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* `options` with a baseline that reproduces the original's connection labels
|
|
427
|
+
* (merge-baseline-connections.ts, UV-17831): a baseline compiled with a
|
|
428
|
+
* bindings.json the original was not would make a label-to-id edit equal the
|
|
429
|
+
* baseline, and merge would drop it. Each node it restores is warned.
|
|
430
|
+
*/
|
|
431
|
+
function withFaithfulBaseline(original, options) {
|
|
432
|
+
if (!options.baseline)
|
|
433
|
+
return options;
|
|
434
|
+
const { baseline, restored } = withOriginalConnectionLabels(original, options.baseline);
|
|
435
|
+
if (restored.length === 0)
|
|
436
|
+
return options;
|
|
437
|
+
for (const message of restoredConnectionMessage(restored))
|
|
438
|
+
options.warn?.(message);
|
|
439
|
+
return { ...options, baseline };
|
|
440
|
+
}
|
|
422
441
|
/** Refused with or without `strict`: merging would replace the project's `agent.json`. */
|
|
423
442
|
class SidecarOverwriteError extends MergeRefusedError {
|
|
424
443
|
constructor(findings) {
|
|
@@ -262,7 +262,7 @@ export declare function rerunAgainstLine(label: string, field: string, connectio
|
|
|
262
262
|
/** The terminal report's line for a candidate that resolved every requested lookup. */
|
|
263
263
|
export declare function candidateResolvesAllLine(label: string, lookups: number): string;
|
|
264
264
|
/** The terminal report's line for a candidate whose collection was read to the end. */
|
|
265
|
-
export declare function candidateExhaustedLine(label: string, field: string, scanned: number): string;
|
|
265
|
+
export declare function candidateExhaustedLine(label: string, field: string, scanned: number, absentBy?: string): string;
|
|
266
266
|
/** The terminal report's line for a candidate whose lookup failed for another reason: the error, verbatim. */
|
|
267
267
|
export declare function candidateErrorLine(label: string, error: unknown): string;
|
|
268
268
|
/**
|
|
@@ -285,7 +285,7 @@ export declare function collectionListingHint(connectorKey: string, collection:
|
|
|
285
285
|
export declare function pinnedConnectionExhaustedMessage(first: string, connectorKey: string, othersCount: number, othersListing: string, hint: string): string;
|
|
286
286
|
/** The listing of other connections itself failed; the original lookup failure is what the author asked about. */
|
|
287
287
|
export declare function candidateListingFailedMessage(first: string, error: unknown): string;
|
|
288
|
-
export declare function onlyConnectionMessage(first: string, connectorKey: string, hint: string): string;
|
|
288
|
+
export declare function onlyConnectionMessage(first: string, connectorKey: string, hint: string, byAbsent?: boolean): string;
|
|
289
289
|
/** Two or more candidates resolve everything: reported, never chosen between. */
|
|
290
290
|
export declare function severalConnectionsResolveMessage(count: number, connectorKey: string, listing: string): string;
|
|
291
291
|
/**
|
|
@@ -299,7 +299,9 @@ export declare function noConnectionResolvesMessage(connectorKey: string, first:
|
|
|
299
299
|
by: string;
|
|
300
300
|
value: string;
|
|
301
301
|
collection: string;
|
|
302
|
-
}, lines: readonly string[], connectionId: string
|
|
302
|
+
}, lines: readonly string[], connectionId: string, absent?: {
|
|
303
|
+
otherBys?: readonly string[];
|
|
304
|
+
}): string;
|
|
303
305
|
export declare function eventParentFieldsMessage(): string;
|
|
304
306
|
export declare function eventAllObjectsMessage(): string;
|
|
305
307
|
/** A Generic event fires for ONE object; name it. `rows` is the `triggers objects` catalog. */
|
|
@@ -597,8 +597,17 @@ export function candidateResolvesAllLine(label, lookups) {
|
|
|
597
597
|
return ` ${label} resolves all ${lookups} lookup(s)`;
|
|
598
598
|
}
|
|
599
599
|
/** The terminal report's line for a candidate whose collection was read to the end. */
|
|
600
|
-
export function candidateExhaustedLine(label, field, scanned) {
|
|
601
|
-
return
|
|
600
|
+
export function candidateExhaustedLine(label, field, scanned, absentBy) {
|
|
601
|
+
return absentBy !== undefined
|
|
602
|
+
? ` ${label} ${field}: ${scanned} record(s) scanned, none carries ${pyRepr(absentBy)}`
|
|
603
|
+
: ` ${label} ${field}: ${scanned} record(s) scanned, no match`;
|
|
604
|
+
}
|
|
605
|
+
/** What to do when no record on any candidate carried the field searched by. */
|
|
606
|
+
function byAbsentRemedy(by, otherBys) {
|
|
607
|
+
return (`No record carries ${pyRepr(by)} on any connection tried, so the value is not what to check: ` +
|
|
608
|
+
(otherBys !== undefined && otherBys.length > 0
|
|
609
|
+
? `search by ${otherBys.map(pyRepr).join(" or ")} instead. `
|
|
610
|
+
: "no other field of this lookup is searchable, so list what the collection holds to choose a record. "));
|
|
602
611
|
}
|
|
603
612
|
/** The terminal report's line for a candidate whose lookup failed for another reason: the error, verbatim. */
|
|
604
613
|
export function candidateErrorLine(label, error) {
|
|
@@ -638,9 +647,12 @@ export function pinnedConnectionExhaustedMessage(first, connectorKey, othersCoun
|
|
|
638
647
|
export function candidateListingFailedMessage(first, error) {
|
|
639
648
|
return `${PREFIX}${first}\n(could not list other connections: ${messageOf(error)})`;
|
|
640
649
|
}
|
|
641
|
-
export function onlyConnectionMessage(first, connectorKey, hint) {
|
|
650
|
+
export function onlyConnectionMessage(first, connectorKey, hint, byAbsent = false) {
|
|
642
651
|
return (`${PREFIX}${first}\n` +
|
|
643
|
-
|
|
652
|
+
// A `byAbsent` miss already says what to search by instead (`byAbsentNote`).
|
|
653
|
+
(byAbsent
|
|
654
|
+
? `This is the only enabled ${connectorKey} connection on the tenant.\n`
|
|
655
|
+
: `This is the only enabled ${connectorKey} connection on the tenant, so the value is what to check.\n`) +
|
|
644
656
|
hint);
|
|
645
657
|
}
|
|
646
658
|
/** Two or more candidates resolve everything: reported, never chosen between. */
|
|
@@ -656,11 +668,13 @@ export function severalConnectionsResolveMessage(count, connectorKey, listing) {
|
|
|
656
668
|
* been tried, so seeing what the collection actually holds is the next step
|
|
657
669
|
* rather than the detour it is while a retry is still available.
|
|
658
670
|
*/
|
|
659
|
-
export function noConnectionResolvesMessage(connectorKey, first, lines, connectionId) {
|
|
671
|
+
export function noConnectionResolvesMessage(connectorKey, first, lines, connectionId, absent) {
|
|
660
672
|
return (`${PREFIX}no ${connectorKey} connection could resolve ` +
|
|
661
673
|
`${first.field}: ${first.by}=${pyRepr(first.value)}\n` +
|
|
662
674
|
`${lines.join("\n")}\n` +
|
|
663
|
-
|
|
675
|
+
(absent !== undefined
|
|
676
|
+
? `Every candidate was read to the end. ${byAbsentRemedy(first.by, absent.otherBys)}`
|
|
677
|
+
: "Every candidate was read to the end, so the value is what to check now. ") +
|
|
664
678
|
collectionListingHint(connectorKey, first.collection, connectionId));
|
|
665
679
|
}
|
|
666
680
|
// ---------------------------------------------------------------------------
|
|
@@ -79,6 +79,8 @@ export interface PrepareReport {
|
|
|
79
79
|
/** The node type the overlay entry is stored under (the WAIT form for an event). */
|
|
80
80
|
nodeType: string;
|
|
81
81
|
connectionId: string;
|
|
82
|
+
/** The connection's `Name` in the tenant's listing. */
|
|
83
|
+
connectionName?: string;
|
|
82
84
|
/** The symbolic names written to `bindings.json`, when bindings were touched. */
|
|
83
85
|
bound?: {
|
|
84
86
|
connection: string;
|
|
@@ -43,6 +43,7 @@ import { chooseConnection, listConnections, lookupConnection, mergeBindings, res
|
|
|
43
43
|
import { prepareEvent } from "./event.js";
|
|
44
44
|
import { integrationServiceEntry } from "./integration-service.js";
|
|
45
45
|
import { descriptorUsage } from "./handoff.js";
|
|
46
|
+
import { declareConnectionInSolution } from "./solution-connection.js";
|
|
46
47
|
import { ResolutionsExhausted, allParentsResolved, resolvedParentValues, writeResolutions } from "./ledger.js";
|
|
47
48
|
import { PrepareRefusal, ambiguousLabelsMessage, connectionChoiceLine, bindingsLine, bpmnConnectorUsageLines, candidateLabel, connectionLine, describeNextLine, generatedModulesLine, genericActionNeedsObjectMessage, inputFieldNote, flagDiffersFromSourceLine, keptSchemaMessage, labelTakenMessage, lookupVocabularyLines, missingGenericSchemaMessage, missingParentsNote, nextLine, noCanonicalEntryMessage, objectFlagsOnlyForGenericMessage, objectNoteLine, objectRecordedLine, parentFieldNamesMismatchMessage, parentOnlyMessage, prefixed, preparedFromIntegrationServiceLine, actionCanonicalizedLine, catalogRefreshFailedLine, catalogRefreshPartialLine, probeSkippedReason, refreshingCatalogLine, rememberedAbsenceLine, preparedSummaryLine, rejectedParentFieldsMessage, rerunAgainstLine, resolvedParentsNote, registryGetFailedMessage, sharedLabelMessage, sourceLabelSuffix, tsNote, partlyUnreadableLabelLine, unreadableLabelLine, missingExecutionEventLine, unrecordedExecutionLine, unresolvedOperationMessage, planRowReplacedLine, } from "./messages.js";
|
|
48
49
|
import { ObjectMatchRefusal, RESOLUTIONS_FILENAME, matchObject, recordObjectResolution } from "./objects.js";
|
|
@@ -276,8 +277,21 @@ async function connect(options, ports) {
|
|
|
276
277
|
* Nothing reaches the disk until the whole command, re-run included, has
|
|
277
278
|
* succeeded; a refusal writes nothing (`staged-files.ts`).
|
|
278
279
|
*/
|
|
279
|
-
export function prepareConnector(options, ports) {
|
|
280
|
-
|
|
280
|
+
export async function prepareConnector(options, ports) {
|
|
281
|
+
const report = await stagedWrites(() => prepareOrRetry(options, ports));
|
|
282
|
+
// After the writes landed: a refused prepare must not leave a resource
|
|
283
|
+
// behind for a binding it did not write.
|
|
284
|
+
if (report.bound) {
|
|
285
|
+
await declareConnectionInSolution({
|
|
286
|
+
client: ports.client,
|
|
287
|
+
reporter: ports.reporter,
|
|
288
|
+
cwd: ports.cwd ?? process.cwd(),
|
|
289
|
+
connectorKey: options.connectorKey,
|
|
290
|
+
connectionId: report.connectionId,
|
|
291
|
+
...(report.connectionName !== undefined ? { connectionName: report.connectionName } : {}),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return report;
|
|
281
295
|
}
|
|
282
296
|
async function prepareOrRetry(options, ports) {
|
|
283
297
|
const info = (line) => ports.reporter.info(line);
|
|
@@ -360,6 +374,7 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
|
|
|
360
374
|
const importSpecifier = options.importSpecifier ?? PACKAGE_NAME;
|
|
361
375
|
const jsonOnly = options.jsonOnly ?? false;
|
|
362
376
|
const { connectionId, bound, rollback } = connected;
|
|
377
|
+
const connectionName = pyStrAny(pyGet(connected.row, "Name", "")) || undefined;
|
|
363
378
|
const describeOverlay = out === resolve(cwd, defaultOverlayOut(cwd)) ? undefined : outShown;
|
|
364
379
|
const ctx = createBuildContext({ client: ports.client, caches: ports.caches ?? memoryCaches(), reporter: ports.reporter, concurrency: 1, timeoutMs: ports.timeoutMs }, { connectionId, parentFields });
|
|
365
380
|
let nodeType = `uipath.connector.${connectorKey}.${action}`;
|
|
@@ -435,7 +450,7 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
|
|
|
435
450
|
});
|
|
436
451
|
if (!("missed" in event)) {
|
|
437
452
|
info(describeNextLine(cli, event.eventNodeType, event.objectName, describeOverlay));
|
|
438
|
-
return { kind: "event", nodeType: event.eventNodeType, connectionId, bound, objectName: event.objectName };
|
|
453
|
+
return { kind: "event", nodeType: event.eventNodeType, connectionId, connectionName, bound, objectName: event.objectName };
|
|
439
454
|
}
|
|
440
455
|
const probes = [actionProbe.miss, event.missed];
|
|
441
456
|
// Only the CLI's "Node not found" says a node is absent. Any other failure
|
|
@@ -639,5 +654,5 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
|
|
|
639
654
|
info(nextLine(line));
|
|
640
655
|
}
|
|
641
656
|
info(describeNextLine(cli, nodeType, options.allObjects ? "<object>" : objectName, describeOverlay));
|
|
642
|
-
return { kind: "action", nodeType, connectionId, bound, variants, inputFields, kept, objectName };
|
|
657
|
+
return { kind: "action", nodeType, connectionId, connectionName, bound, variants, inputFields, kept, objectName };
|
|
643
658
|
}
|
|
@@ -45,6 +45,13 @@ export interface LookupExhaustedFacts {
|
|
|
45
45
|
candidates?: readonly string[];
|
|
46
46
|
/** A value the scan saw that equals the wanted one ignoring case; the match itself is exact. */
|
|
47
47
|
near?: string;
|
|
48
|
+
/**
|
|
49
|
+
* True when a scan read to the end but NONE of the records carried a value
|
|
50
|
+
* at `by`: no value can match on that field on this connection.
|
|
51
|
+
*/
|
|
52
|
+
byAbsent?: boolean;
|
|
53
|
+
/** The other fields this lookup is searchable by, for a `byAbsent` miss. */
|
|
54
|
+
otherBys?: readonly string[];
|
|
48
55
|
}
|
|
49
56
|
/**
|
|
50
57
|
* A collection this small is listed in full when a value is not in it. The
|
|
@@ -82,8 +89,12 @@ export declare class LookupExhausted extends ResolutionRefusal {
|
|
|
82
89
|
readonly truncated: boolean;
|
|
83
90
|
readonly candidates?: readonly string[];
|
|
84
91
|
readonly near?: string;
|
|
92
|
+
readonly byAbsent: boolean;
|
|
93
|
+
readonly otherBys?: readonly string[];
|
|
85
94
|
constructor(message: string, facts: LookupExhaustedFacts);
|
|
86
95
|
}
|
|
96
|
+
/** The sentence a `byAbsent` miss adds, with what to search by instead. */
|
|
97
|
+
export declare function byAbsentNote(scanned: number, by: string, otherBys: readonly string[] | undefined): string;
|
|
87
98
|
/** One `--resolve <field>:<by>=<value>`, parsed. */
|
|
88
99
|
export type ResolveRequest = readonly [field: string, by: string, value: string];
|
|
89
100
|
/**
|
|
@@ -87,6 +87,8 @@ export class LookupExhausted extends ResolutionRefusal {
|
|
|
87
87
|
truncated;
|
|
88
88
|
candidates;
|
|
89
89
|
near;
|
|
90
|
+
byAbsent;
|
|
91
|
+
otherBys;
|
|
90
92
|
constructor(message, facts) {
|
|
91
93
|
super(message, "RESOLVE_NO_MATCH");
|
|
92
94
|
this.name = "LookupExhausted";
|
|
@@ -102,8 +104,19 @@ export class LookupExhausted extends ResolutionRefusal {
|
|
|
102
104
|
this.candidates = facts.candidates;
|
|
103
105
|
if (facts.near !== undefined)
|
|
104
106
|
this.near = facts.near;
|
|
107
|
+
this.byAbsent = facts.byAbsent === true;
|
|
108
|
+
if (facts.otherBys !== undefined)
|
|
109
|
+
this.otherBys = facts.otherBys;
|
|
105
110
|
}
|
|
106
111
|
}
|
|
112
|
+
/** The sentence a `byAbsent` miss adds, with what to search by instead. */
|
|
113
|
+
export function byAbsentNote(scanned, by, otherBys) {
|
|
114
|
+
return (` None of the ${scanned} record(s) carries a ${pyRepr(by)} value on this connection, so no ${pyRepr(by)} can match here: ` +
|
|
115
|
+
"the connection hides or does not expose that field." +
|
|
116
|
+
(otherBys !== undefined && otherBys.length > 0
|
|
117
|
+
? ` Search by ${otherBys.map(pyRepr).join(" or ")} instead.`
|
|
118
|
+
: " No other field of this lookup is searchable; list what the collection holds to choose a record."));
|
|
119
|
+
}
|
|
107
120
|
/**
|
|
108
121
|
* A tree walk lists one child collection per parent it opens. Google Drive's
|
|
109
122
|
* picker root holds three records (`My Drive`, `Shared with me`, `Shared
|
|
@@ -506,10 +519,15 @@ export async function resolveOne(client, connectorKey, spec, field, by, value, c
|
|
|
506
519
|
// Records whose `by` equals the value ignoring case only, first per distinct
|
|
507
520
|
// spelling: the fallback when no record matches exactly.
|
|
508
521
|
const caseOnly = new Map();
|
|
522
|
+
// Records with any value at `by`: zero across a non-empty scan means the
|
|
523
|
+
// connection hides the field, not that the value is wrong.
|
|
524
|
+
let carrying = 0;
|
|
509
525
|
let step = await scan.next();
|
|
510
526
|
while (!step.done) {
|
|
511
527
|
for (const record of step.value) {
|
|
512
528
|
const at = readPath(record, by);
|
|
529
|
+
if (at !== null && at !== undefined && at !== "")
|
|
530
|
+
carrying += 1;
|
|
513
531
|
if (at !== null && at !== undefined) {
|
|
514
532
|
const text = pyStrAny(at);
|
|
515
533
|
if (held.length <= CANDIDATE_LIMIT && !held.includes(text))
|
|
@@ -575,6 +593,10 @@ export async function resolveOne(client, connectorKey, spec, field, by, value, c
|
|
|
575
593
|
// Eval Test'), and listing that subset as what the collection "holds" would
|
|
576
594
|
// be false. 693 library operations declare a `filterPattern`.
|
|
577
595
|
const candidates = !capped && !pyTruthy(filterPattern) && scanned <= CANDIDATE_LIMIT && held.length > 0 ? held : undefined;
|
|
596
|
+
// A filtered or capped scan did not read every record, so an empty `by`
|
|
597
|
+
// among the records it read says nothing about the field.
|
|
598
|
+
const byAbsent = scanned > 0 && carrying === 0 && !capped && !truncated && !pyTruthy(filterPattern);
|
|
599
|
+
const otherBys = byAbsent ? searchableBy.filter((other) => other !== by) : undefined;
|
|
578
600
|
throw new LookupExhausted(`${field}: no record in ${pyRepr(collection)} has ${by}=${pyRepr(value)} ` +
|
|
579
601
|
`(scanned ${scanned} record(s) across ${pages + 1} page(s)` +
|
|
580
602
|
(truncated
|
|
@@ -586,10 +608,12 @@ export async function resolveOne(client, connectorKey, spec, field, by, value, c
|
|
|
586
608
|
(near !== undefined
|
|
587
609
|
? ` Did you mean ${pyRepr(near)}? It differs only in case and was not taken: the scan stopped before the end, where an exact match may still be.`
|
|
588
610
|
: "") +
|
|
589
|
-
(candidates !== undefined ? ` It holds: ${candidates.map(pyRepr).join(", ")}.` : "")
|
|
611
|
+
(candidates !== undefined ? ` It holds: ${candidates.map(pyRepr).join(", ")}.` : "") +
|
|
612
|
+
(byAbsent ? byAbsentNote(scanned, by, otherBys) : ""), {
|
|
590
613
|
field, collection, by, value, scanned, pages: pages + 1, capped, truncated,
|
|
591
614
|
...(candidates !== undefined ? { candidates } : {}),
|
|
592
615
|
...(near !== undefined ? { near } : {}),
|
|
616
|
+
...(byAbsent ? { byAbsent, otherBys } : {}),
|
|
593
617
|
});
|
|
594
618
|
}
|
|
595
619
|
/**
|
|
@@ -76,11 +76,14 @@ export async function retryOtherConnections(ctx, plan, first) {
|
|
|
76
76
|
}
|
|
77
77
|
const others = candidates.filter((row) => !sameId(row));
|
|
78
78
|
if (others.length === 0) {
|
|
79
|
-
throw new PrepareRefusal(onlyConnectionMessage(first.message, ctx.connectorKey, collectionListingHint(ctx.connectorKey, first.collection, ctx.connectionId)), "LOOKUP_EXHAUSTED_ONLY_CONNECTION");
|
|
79
|
+
throw new PrepareRefusal(onlyConnectionMessage(first.message, ctx.connectorKey, collectionListingHint(ctx.connectorKey, first.collection, ctx.connectionId), first.byAbsent), "LOOKUP_EXHAUSTED_ONLY_CONNECTION");
|
|
80
80
|
}
|
|
81
81
|
ctx.reporter.info(tryingOtherConnectionsLine(first.field, others.length, ctx.connectorKey));
|
|
82
82
|
const winners = [];
|
|
83
83
|
const report = [];
|
|
84
|
+
// Whether every candidate hid the field `first` searched by: then the value
|
|
85
|
+
// is not what to check, the `by` is.
|
|
86
|
+
let everyAbsent = first.byAbsent;
|
|
84
87
|
for (const row of others) {
|
|
85
88
|
const outcome = await probeCandidate(ctx.client, ctx.connectorKey, plan, pyStrAny(pyGet(row, "Id", null)));
|
|
86
89
|
const label = candidateLabel(row);
|
|
@@ -89,9 +92,13 @@ export async function retryOtherConnections(ctx, plan, first) {
|
|
|
89
92
|
report.push(candidateResolvesAllLine(label, plan.ordered.length));
|
|
90
93
|
}
|
|
91
94
|
else if (outcome.kind === "exhausted") {
|
|
92
|
-
|
|
95
|
+
const miss = outcome.error;
|
|
96
|
+
if (!(miss.byAbsent && miss.field === first.field))
|
|
97
|
+
everyAbsent = false;
|
|
98
|
+
report.push(candidateExhaustedLine(label, miss.field, miss.scanned, miss.byAbsent ? miss.by : undefined));
|
|
93
99
|
}
|
|
94
100
|
else {
|
|
101
|
+
everyAbsent = false;
|
|
95
102
|
report.push(candidateErrorLine(label, outcome.error));
|
|
96
103
|
}
|
|
97
104
|
}
|
|
@@ -104,6 +111,9 @@ export async function retryOtherConnections(ctx, plan, first) {
|
|
|
104
111
|
// one connection first, so the reader can see the value really is absent
|
|
105
112
|
// rather than guess which connection was asked.
|
|
106
113
|
const original = candidates.find(sameId) ?? { Name: ctx.connectionId, Folder: "?" };
|
|
107
|
-
const lines = [
|
|
108
|
-
|
|
114
|
+
const lines = [
|
|
115
|
+
candidateExhaustedLine(candidateLabel(original), first.field, first.scanned, first.byAbsent ? first.by : undefined),
|
|
116
|
+
...report,
|
|
117
|
+
];
|
|
118
|
+
throw new PrepareRefusal(noConnectionResolvesMessage(ctx.connectorKey, first, lines, ctx.connectionId, everyAbsent ? (first.otherBys !== undefined ? { otherBys: first.otherBys } : {}) : undefined), "LOOKUP_EXHAUSTED_EVERYWHERE");
|
|
109
119
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declare a bound connection in the project's solution, so the designer accepts the node.
|
|
3
|
+
* `uip solution resources add` is idempotent; a failure only warns with the command to run.
|
|
4
|
+
*/
|
|
5
|
+
import type { Reporter } from "../reporter.js";
|
|
6
|
+
import type { UipClient } from "../uip/client.js";
|
|
7
|
+
export interface DeclareConnectionInput {
|
|
8
|
+
client: UipClient;
|
|
9
|
+
reporter: Reporter;
|
|
10
|
+
/** The project directory prepare ran in. */
|
|
11
|
+
cwd: string;
|
|
12
|
+
connectorKey: string;
|
|
13
|
+
connectionId: string;
|
|
14
|
+
/** The connection's `Name` in the tenant's listing; `add` needs it. */
|
|
15
|
+
connectionName?: string;
|
|
16
|
+
}
|
|
17
|
+
/** What {@link declareConnectionInSolution} did, for tests and callers that report it. */
|
|
18
|
+
export type DeclareConnectionOutcome = {
|
|
19
|
+
status: "no-solution";
|
|
20
|
+
} | {
|
|
21
|
+
status: "already-declared";
|
|
22
|
+
solution: string;
|
|
23
|
+
} | {
|
|
24
|
+
status: "declared";
|
|
25
|
+
solution: string;
|
|
26
|
+
} | {
|
|
27
|
+
status: "failed";
|
|
28
|
+
solution: string;
|
|
29
|
+
command: string;
|
|
30
|
+
};
|
|
31
|
+
/** The pasteable form of the add, as the warning prints it. */
|
|
32
|
+
export declare function declareConnectionCommand(connectionId: string, connectionName: string, solution: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Declare `connectionId` in the solution that contains `cwd`, unless it is not
|
|
35
|
+
* inside one or the solution already declares that connection.
|
|
36
|
+
*/
|
|
37
|
+
export declare function declareConnectionInSolution(input: DeclareConnectionInput): Promise<DeclareConnectionOutcome>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { solutionResourcesAddConnection } from "../uip/commands.js";
|
|
2
|
+
import { failureReason, isSuccess, parseEnvelope } from "../uip/envelope.js";
|
|
3
|
+
import { solutionConnectionIds } from "./connections.js";
|
|
4
|
+
import { solutionRoot } from "./resources.js";
|
|
5
|
+
/** The pasteable form of the add, as the warning prints it. */
|
|
6
|
+
export function declareConnectionCommand(connectionId, connectionName, solution) {
|
|
7
|
+
return solutionResourcesAddConnection(connectionId, connectionName, solution)
|
|
8
|
+
.filter((arg, i, argv) => !(arg === "--output" || argv[i - 1] === "--output"))
|
|
9
|
+
.map((arg) => (/[\s'"]/.test(arg) ? `'${arg.replace(/'/g, `'\\''`)}'` : arg))
|
|
10
|
+
.join(" ");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Declare `connectionId` in the solution that contains `cwd`, unless it is not
|
|
14
|
+
* inside one or the solution already declares that connection.
|
|
15
|
+
*/
|
|
16
|
+
export async function declareConnectionInSolution(input) {
|
|
17
|
+
const solution = solutionRoot(input.cwd);
|
|
18
|
+
if (solution === undefined)
|
|
19
|
+
return { status: "no-solution" };
|
|
20
|
+
if (solutionConnectionIds(solution, input.connectorKey).has(input.connectionId)) {
|
|
21
|
+
return { status: "already-declared", solution };
|
|
22
|
+
}
|
|
23
|
+
if (input.connectionName === undefined || input.connectionName === "") {
|
|
24
|
+
const command = refreshCommand(solution);
|
|
25
|
+
input.reporter.warn(declareFailedLine(input.connectionId, "the connection listing gave it no name, which `resources add` needs", command, true));
|
|
26
|
+
return { status: "failed", solution, command };
|
|
27
|
+
}
|
|
28
|
+
const argv = solutionResourcesAddConnection(input.connectionId, input.connectionName, solution);
|
|
29
|
+
const result = await input.client.run(argv);
|
|
30
|
+
// A zero exit with a Failure envelope is a failure too: the envelope is the answer.
|
|
31
|
+
const envelope = parseEnvelope(result.stdout);
|
|
32
|
+
const declared = result.code === 0 &&
|
|
33
|
+
(envelope === undefined
|
|
34
|
+
? solutionConnectionIds(solution, input.connectorKey).has(input.connectionId)
|
|
35
|
+
: isSuccess(envelope));
|
|
36
|
+
if (declared) {
|
|
37
|
+
input.reporter.info(declaredLine(input.connectionId, solution));
|
|
38
|
+
return { status: "declared", solution };
|
|
39
|
+
}
|
|
40
|
+
const reason = result.code === 0 && envelope === undefined
|
|
41
|
+
? "uip exited 0 but printed no JSON answer, and no resource file for the connection appeared"
|
|
42
|
+
: failureReason(result);
|
|
43
|
+
const command = declareConnectionCommand(input.connectionId, input.connectionName, solution);
|
|
44
|
+
input.reporter.warn(declareFailedLine(input.connectionId, reason, command));
|
|
45
|
+
return { status: "failed", solution, command };
|
|
46
|
+
}
|
|
47
|
+
function declaredLine(connectionId, solution) {
|
|
48
|
+
return ` solution: declared connection ${connectionId} as a resource of ${solution}, so the designer accepts the node that uses it`;
|
|
49
|
+
}
|
|
50
|
+
/** The fallback that needs no name: refresh declares every `bindings_v2.json` connection. */
|
|
51
|
+
function refreshCommand(solution) {
|
|
52
|
+
return `uip solution resources refresh --solution-folder ${/[\s'"]/.test(solution) ? `'${solution.replace(/'/g, `'\\''`)}'` : solution}`;
|
|
53
|
+
}
|
|
54
|
+
function declareFailedLine(connectionId, reason, command, afterMerge = false) {
|
|
55
|
+
return (` WARN: could not declare connection ${connectionId} in the solution (${reason}). `
|
|
56
|
+
+ "Until it is declared, the designer shows \"The selected resource is not part of the solution\" on the node, "
|
|
57
|
+
+ "and saving the flow there clears its connection. Run, "
|
|
58
|
+
+ (afterMerge ? "after merge writes the connection into the flow and " : "")
|
|
59
|
+
+ `before the designer opens the flow:\n ${command}`);
|
|
60
|
+
}
|
|
@@ -47,6 +47,15 @@ export declare function isConnectionsList(options?: {
|
|
|
47
47
|
allFolders?: boolean;
|
|
48
48
|
byoa?: boolean;
|
|
49
49
|
}): string[];
|
|
50
|
+
/**
|
|
51
|
+
* `uip solution resources add --source remote --kind connection --name <name>
|
|
52
|
+
* --cloud-key <id>`: declare a tenant connection as a resource of the solution
|
|
53
|
+
* at `solutionFolder`. Idempotent: an id the solution already declares is
|
|
54
|
+
* returned unchanged (`Status: "Unchanged"`). `--name` is the connection's own
|
|
55
|
+
* `Name`: `uip` 1.205 requires it beside `--cloud-key`, and later releases
|
|
56
|
+
* check it against the connection.
|
|
57
|
+
*/
|
|
58
|
+
export declare function solutionResourcesAddConnection(connectionId: string, connectionName: string, solutionFolder: string): string[];
|
|
50
59
|
/**
|
|
51
60
|
* `uip solution resources list --kind <kind>`: the solution resource catalogue's
|
|
52
61
|
* resources of one kind, each with its `Key` and `Folder` (path), and — on the
|
|
@@ -93,6 +93,20 @@ export function isConnectionsList(options = {}) {
|
|
|
93
93
|
argv.splice(4, 0, "--byoa");
|
|
94
94
|
return argv;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* `uip solution resources add --source remote --kind connection --name <name>
|
|
98
|
+
* --cloud-key <id>`: declare a tenant connection as a resource of the solution
|
|
99
|
+
* at `solutionFolder`. Idempotent: an id the solution already declares is
|
|
100
|
+
* returned unchanged (`Status: "Unchanged"`). `--name` is the connection's own
|
|
101
|
+
* `Name`: `uip` 1.205 requires it beside `--cloud-key`, and later releases
|
|
102
|
+
* check it against the connection.
|
|
103
|
+
*/
|
|
104
|
+
export function solutionResourcesAddConnection(connectionId, connectionName, solutionFolder) {
|
|
105
|
+
return [
|
|
106
|
+
UIP, "solution", "resources", "add", "--source", "remote", "--kind", "connection",
|
|
107
|
+
"--name", connectionName, "--cloud-key", connectionId, "--solution-folder", solutionFolder, "--output", "json",
|
|
108
|
+
];
|
|
109
|
+
}
|
|
96
110
|
/**
|
|
97
111
|
* `uip solution resources list --kind <kind>`: the solution resource catalogue's
|
|
98
112
|
* resources of one kind, each with its `Key` and `Folder` (path), and — on the
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** One script body to check (a node type's `{ code }` site), and the step `check` names it by. */
|
|
2
|
+
export interface ScriptBody {
|
|
3
|
+
step: string;
|
|
4
|
+
body: string;
|
|
5
|
+
}
|
|
6
|
+
/** One TypeScript complaint on a script body. */
|
|
7
|
+
export interface ScriptTypeFinding {
|
|
8
|
+
step: string;
|
|
9
|
+
/** TypeScript's code: 2339 for "Property … does not exist on type …". */
|
|
10
|
+
tsCode: number;
|
|
11
|
+
message: string;
|
|
12
|
+
/** 1-based line within the body. */
|
|
13
|
+
line: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The TypeScript errors the canvas would show on each body, in one program (the ES2020
|
|
17
|
+
* library is parsed once). Empty in a host with no `ts.sys` (a browser): it cannot read
|
|
18
|
+
* the library files.
|
|
19
|
+
*/
|
|
20
|
+
export declare function scriptTypeFindings(bodies: readonly ScriptBody[]): ScriptTypeFinding[];
|
|
21
|
+
/** What to do about a finding, for the class UV-17831 hit first; undefined for any other. */
|
|
22
|
+
export declare function scriptTypeHint(f: ScriptTypeFinding): string | undefined;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { typescript } from './core/typescript-module.js';
|
|
2
|
+
/** The runtime's host globals, as `@uipath/flow-expression-model` declares them (runtime-globals.ts). */
|
|
3
|
+
const RUNTIME_GLOBALS = `declare function atob(data: string): string;
|
|
4
|
+
declare function btoa(data: string): string;
|
|
5
|
+
declare const console: {
|
|
6
|
+
log(...args: unknown[]): void;
|
|
7
|
+
info(...args: unknown[]): void;
|
|
8
|
+
warn(...args: unknown[]): void;
|
|
9
|
+
error(...args: unknown[]): void;
|
|
10
|
+
debug(...args: unknown[]): void;
|
|
11
|
+
};
|
|
12
|
+
declare const $vars: any;
|
|
13
|
+
declare const $metadata: any;
|
|
14
|
+
`;
|
|
15
|
+
const PREAMBLE = '/// <reference no-default-lib="true"/>\n/// <reference lib="es2020"/>\nexport {};\n' + RUNTIME_GLOBALS + '(function() {\n';
|
|
16
|
+
const SUFFIX = '\n})();\n';
|
|
17
|
+
/** The parsed ES2020 library files, shared by every check in this process. */
|
|
18
|
+
const LIB_CACHE = new Map();
|
|
19
|
+
/**
|
|
20
|
+
* Codes dropped: 6133 ("declared but never used"), which the canvas suppresses too; and
|
|
21
|
+
* the unresolved-name family, which belongs to the lowering's runtime-name rule.
|
|
22
|
+
*/
|
|
23
|
+
const DROPPED = new Set([6133, 2304, 2552, 2580, 2581, 2582, 2583, 2591, 2592, 2593]);
|
|
24
|
+
/**
|
|
25
|
+
* The TypeScript errors the canvas would show on each body, in one program (the ES2020
|
|
26
|
+
* library is parsed once). Empty in a host with no `ts.sys` (a browser): it cannot read
|
|
27
|
+
* the library files.
|
|
28
|
+
*/
|
|
29
|
+
export function scriptTypeFindings(bodies) {
|
|
30
|
+
if (bodies.length === 0)
|
|
31
|
+
return [];
|
|
32
|
+
const ts = typescript();
|
|
33
|
+
if (!ts.sys)
|
|
34
|
+
return [];
|
|
35
|
+
const options = { target: ts.ScriptTarget.Latest, noEmit: true, types: [], skipLibCheck: true };
|
|
36
|
+
const files = new Map(bodies.map((b, i) => [`/__flow_scripts__/script${i}.ts`, PREAMBLE + b.body + SUFFIX]));
|
|
37
|
+
const host = ts.createCompilerHost(options);
|
|
38
|
+
const getSourceFile = host.getSourceFile.bind(host);
|
|
39
|
+
host.getSourceFile = (name, lang, onError, create) => {
|
|
40
|
+
const text = files.get(name);
|
|
41
|
+
if (text !== undefined)
|
|
42
|
+
return ts.createSourceFile(name, text, lang);
|
|
43
|
+
// The library files never change in a process: parse each once, not once per check.
|
|
44
|
+
let lib = LIB_CACHE.get(name);
|
|
45
|
+
if (lib === undefined) {
|
|
46
|
+
lib = getSourceFile(name, lang, onError, create);
|
|
47
|
+
if (lib)
|
|
48
|
+
LIB_CACHE.set(name, lib);
|
|
49
|
+
}
|
|
50
|
+
return lib;
|
|
51
|
+
};
|
|
52
|
+
const fileExists = host.fileExists.bind(host);
|
|
53
|
+
host.fileExists = (name) => files.has(name) || fileExists(name);
|
|
54
|
+
const readFile = host.readFile.bind(host);
|
|
55
|
+
host.readFile = (name) => files.get(name) ?? readFile(name);
|
|
56
|
+
const program = ts.createProgram([...files.keys()], options, host);
|
|
57
|
+
const out = [];
|
|
58
|
+
[...files.keys()].forEach((name, i) => {
|
|
59
|
+
const sf = program.getSourceFile(name);
|
|
60
|
+
if (!sf)
|
|
61
|
+
return;
|
|
62
|
+
const b = bodies[i];
|
|
63
|
+
const start = PREAMBLE.length;
|
|
64
|
+
const end = start + b.body.length;
|
|
65
|
+
const startLine = sf.getLineAndCharacterOfPosition(start).line;
|
|
66
|
+
for (const d of [...program.getSyntacticDiagnostics(sf), ...program.getSemanticDiagnostics(sf)]) {
|
|
67
|
+
if (d.category !== ts.DiagnosticCategory.Error || DROPPED.has(d.code))
|
|
68
|
+
continue;
|
|
69
|
+
const at = d.start ?? -1;
|
|
70
|
+
if (at < start || at > end)
|
|
71
|
+
continue;
|
|
72
|
+
out.push({
|
|
73
|
+
step: b.step, tsCode: d.code,
|
|
74
|
+
message: ts.flattenDiagnosticMessageText(d.messageText, ' '),
|
|
75
|
+
line: sf.getLineAndCharacterOfPosition(at).line - startLine + 1,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/** What to do about a finding, for the class UV-17831 hit first; undefined for any other. */
|
|
82
|
+
export function scriptTypeHint(f) {
|
|
83
|
+
return /on type '\{\}'/.test(f.message)
|
|
84
|
+
? 'An empty object literal has type {}, so the canvas refuses every property added to it later. '
|
|
85
|
+
+ 'Build the object in one literal (`const t = { field: value }`), or start from a value TypeScript '
|
|
86
|
+
+ 'types as any (`const t = Object.create(null)`). A type annotation does not help: the engine runs '
|
|
87
|
+
+ 'the body as JavaScript, so a script cannot carry one.'
|
|
88
|
+
: undefined;
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.119.
|
|
3
|
+
"version": "6.119.2",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"@types/node": "^22.7.0",
|
|
125
125
|
"esbuild": "^0.28.1"
|
|
126
126
|
},
|
|
127
|
-
"gitref": "
|
|
127
|
+
"gitref": "2caacf86f4a3083208a58ffcd799a4b098acaf8d"
|
|
128
128
|
}
|