@uipath/maestro-builder-sdk 6.119.1 → 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/registry/prepare/pipeline.d.ts +2 -0
- package/dist/registry/prepare/pipeline.js +19 -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',
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|