@uipath/maestro-builder-sdk 6.122.10 → 6.122.11
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/auto-layout.d.ts +10 -1
- package/dist/auto-layout.js +5 -1
- package/dist/bpmn/bpmn-sdk.js +49 -2
- package/dist/check.js +2 -2
- package/dist/core/elk-module.d.ts +7 -0
- package/dist/core/elk-module.js +17 -3
- package/dist/core/option-keys.d.ts +7 -2
- package/dist/core/option-keys.js +5 -4
- package/dist/core/refusals.d.ts +2 -0
- package/dist/core/refusals.js +2 -0
- package/dist/script-function-scope.d.ts +14 -0
- package/dist/script-function-scope.js +63 -2
- package/dist/serialize.d.ts +19 -2
- package/dist/serialize.js +26 -4
- package/package.json +2 -2
package/dist/auto-layout.d.ts
CHANGED
|
@@ -43,6 +43,15 @@ export interface AuthorGeometry {
|
|
|
43
43
|
/** Nodes with an author size. */
|
|
44
44
|
sized: ReadonlySet<string>;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* How {@link applyCompiledGeometry} treats a scope with no `.layout()` entry:
|
|
48
|
+
* `'elk'` lays it out; `'probe'` (for `check`) leaves it unplaced and only
|
|
49
|
+
* refuses `ELK_UNAVAILABLE` where `'elk'` would, so `check` skips the layout,
|
|
50
|
+
* which changes no finding, and still reports a host with no layout engine.
|
|
51
|
+
* An ELK failure (`LAYOUT_AUTO_FAILED`) needs the layout, so only `'elk'` can
|
|
52
|
+
* raise it.
|
|
53
|
+
*/
|
|
54
|
+
export type ScopeLayout = 'elk' | 'probe';
|
|
46
55
|
/**
|
|
47
56
|
* Write compile's geometry onto every scope of `flow`: canonical sizes everywhere, and
|
|
48
57
|
* the `format` layout in each scope where the author placed no node.
|
|
@@ -55,5 +64,5 @@ export declare function applyCompiledGeometry(flow: {
|
|
|
55
64
|
edges: GeoEdge[];
|
|
56
65
|
definitions?: unknown[];
|
|
57
66
|
subflows?: Record<string, GeoScope>;
|
|
58
|
-
}, author: AuthorGeometry): void;
|
|
67
|
+
}, author: AuthorGeometry, scopeLayout?: ScopeLayout): void;
|
|
59
68
|
export {};
|
package/dist/auto-layout.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
*/
|
|
39
39
|
import { STICKY_NOTE_TYPE } from './core/definitionless-node-types.js';
|
|
40
40
|
import { PLACEHOLDER_FLAG, markCompilePlaced } from './node-placement.js';
|
|
41
|
+
import { assertElkAvailable } from './core/elk-module.js';
|
|
41
42
|
import { CompileRefusal } from './core/compile-refusal.js';
|
|
42
43
|
import { DEFAULT_NODE_SIZE, defaultContainerFit, layoutRoot, snapToGrid, tidyContainer, } from './core/elk-layout.js';
|
|
43
44
|
/** Where the canvas puts a new flow's trigger (flow-core `DEFAULT_TRIGGER_POSITION`). */
|
|
@@ -133,7 +134,7 @@ function portResolver(definitions, nodeOf) {
|
|
|
133
134
|
* @param flow - The compiled flow (root `nodes`/`edges`, `subflows`, `definitions`); changed in place.
|
|
134
135
|
* @param author - What `.layout()` set.
|
|
135
136
|
*/
|
|
136
|
-
export function applyCompiledGeometry(flow, author) {
|
|
137
|
+
export function applyCompiledGeometry(flow, author, scopeLayout = 'elk') {
|
|
137
138
|
const definitions = flow.definitions ?? [];
|
|
138
139
|
const shapeOf = shapeResolver(definitions);
|
|
139
140
|
for (const [where, scope] of [['the flow', flow], ...Object.entries(flow.subflows ?? {}).map(([k, sf]) => [`subflow "${k}"`, sf])]) {
|
|
@@ -149,6 +150,9 @@ export function applyCompiledGeometry(flow, author) {
|
|
|
149
150
|
n.ui = author.placed.has(n.id) ? { ...n.ui, [PLACEHOLDER_FLAG]: false } : markCompilePlaced(n.ui ?? {}, true);
|
|
150
151
|
}
|
|
151
152
|
}
|
|
153
|
+
else if (scopeLayout === 'probe') {
|
|
154
|
+
assertElkAvailable();
|
|
155
|
+
}
|
|
152
156
|
else {
|
|
153
157
|
try {
|
|
154
158
|
layOutScope(scope, definitions, shapeOf);
|
package/dist/bpmn/bpmn-sdk.js
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveResourceKeyPattern } from './resource-key-pattern.js';
|
|
|
6
6
|
import { PLAIN_TASK_ELEMENTS } from './task-elements.js';
|
|
7
7
|
import { quickHumanTaskRows } from './human-task-form.js';
|
|
8
8
|
import { CompileRefusal } from '../core/compile-refusal.js';
|
|
9
|
+
import { declareKeys, unknownOptionRefusal } from '../core/option-keys.js';
|
|
9
10
|
import { DATA_SERVICE_ACTIVITY_TYPE, dataServiceContext, dataServiceWire, isPendingEntity, pendsOnFolderKeyRow, refuseEntityShape, } from './data-service.js';
|
|
10
11
|
import { IMPLICIT_CONNECTION, IMPLICIT_CONNECTION_BINDING_ID, MANAGED_HTTP_CONNECTION_NAME, MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_FOLDER_NAME, MANAGED_HTTP_TYPE, managedHttpContext, managedHttpInputs, managedHttpOutputs, } from './managed-http.js';
|
|
11
12
|
import { ownEntry } from '../core/own-entry.js';
|
|
@@ -38,6 +39,43 @@ export const NO_MESSAGE = Symbol.for('@uipath/maestro-builder-sdk/bpmn/noMessage
|
|
|
38
39
|
function variableUpdatesOf(opts) {
|
|
39
40
|
return opts.updates === undefined && opts.updateRows === undefined ? undefined : { updates: opts.updates, updateRows: opts.updateRows };
|
|
40
41
|
}
|
|
42
|
+
const BPMN_UNKNOWN_OPTION = { code: 'BPMN_UNKNOWN_OPTION', noun: 'process' };
|
|
43
|
+
/** Every option key the Orchestrator job-start family reads. */
|
|
44
|
+
const ORCHESTRATOR_KEY_SET = {
|
|
45
|
+
tags: true,
|
|
46
|
+
retry: true,
|
|
47
|
+
loop: true,
|
|
48
|
+
errorMapping: true,
|
|
49
|
+
updates: true,
|
|
50
|
+
updateRows: true,
|
|
51
|
+
name: true,
|
|
52
|
+
process: true,
|
|
53
|
+
folder: true,
|
|
54
|
+
input: true,
|
|
55
|
+
releaseKey: true,
|
|
56
|
+
folderKey: true,
|
|
57
|
+
outputs: true,
|
|
58
|
+
outputVar: true,
|
|
59
|
+
skipCondition: true,
|
|
60
|
+
};
|
|
61
|
+
const ORCHESTRATOR_OPTION_KEYS = declareKeys(ORCHESTRATOR_KEY_SET);
|
|
62
|
+
/** The keys of the two builders that take `async`: it is unknown, so refused, on the others. */
|
|
63
|
+
const ORCHESTRATOR_ASYNC_OPTION_KEYS = declareKeys({ ...ORCHESTRATOR_KEY_SET, async: true });
|
|
64
|
+
/** The engine's expression namespaces, lowercased: no variable may take one of these names. */
|
|
65
|
+
const EXPRESSION_NAMESPACES = new Set([
|
|
66
|
+
'bindings',
|
|
67
|
+
'datafabric',
|
|
68
|
+
'outputs',
|
|
69
|
+
'result',
|
|
70
|
+
'this',
|
|
71
|
+
'vars',
|
|
72
|
+
'iterator',
|
|
73
|
+
'metadata',
|
|
74
|
+
'orchestrator',
|
|
75
|
+
'instanceglobals',
|
|
76
|
+
'runtime',
|
|
77
|
+
'senderinfo',
|
|
78
|
+
]);
|
|
41
79
|
/**
|
|
42
80
|
* The `uipath:type` version of an app-backed `.humanTask()`. PO.BpmnEngine
|
|
43
81
|
* (`AppTasksCreateArgs`) reads the app from `name`/`folderPath` only on `v2`; on `v1` it
|
|
@@ -1426,6 +1464,15 @@ class ScopeBuilder {
|
|
|
1426
1464
|
orchestratorNode(id, type, opts, body,
|
|
1427
1465
|
/** A member's own departures from the family: the business rule's v3 stamp and `_label`. */
|
|
1428
1466
|
own = {}) {
|
|
1467
|
+
const unknown = unknownOptionRefusal(opts, own.takesAsync ? ORCHESTRATOR_ASYNC_OPTION_KEYS : ORCHESTRATOR_OPTION_KEYS, `${type} options`, `node "${id}"`, BPMN_UNKNOWN_OPTION);
|
|
1468
|
+
if (unknown !== undefined)
|
|
1469
|
+
throw unknown;
|
|
1470
|
+
const reserved = [...Object.keys(opts.outputs ?? {}), ...(opts.outputVar !== undefined ? [opts.outputVar] : [])].find((name) => EXPRESSION_NAMESPACES.has(name.trim().toLowerCase()));
|
|
1471
|
+
if (reserved !== undefined) {
|
|
1472
|
+
throw new CompileRefusal('BPMN_JOB_OUTPUT_VAR_RESERVED', `node "${id}" (${type}): "${reserved}" is an expression namespace, so a variable cannot take that name ` +
|
|
1473
|
+
`(\`validate\` rejects it as RESERVED_VARIABLE_NAME). Name the outputs key or outputVar something else, ` +
|
|
1474
|
+
`e.g. "${id}_${reserved.trim()}", and read the job's value from it.`);
|
|
1475
|
+
}
|
|
1429
1476
|
// The `uipath:type` version selects the engine's addressing branch — see
|
|
1430
1477
|
// OrchestratorOpts.process. By name → v2 (`name` + `folderPath`); by key → v1
|
|
1431
1478
|
// (`releaseKey` + `folderKey`). A literal release key becomes a `process`/`Key`
|
|
@@ -1514,7 +1561,7 @@ class ScopeBuilder {
|
|
|
1514
1561
|
* @returns This builder, so calls chain.
|
|
1515
1562
|
*/
|
|
1516
1563
|
startAgenticProcess(id, opts, body) {
|
|
1517
|
-
return this.orchestratorNode(id, opts.async ? 'Orchestrator.StartAgenticProcessAsync' : 'Orchestrator.StartAgenticProcess', opts, body);
|
|
1564
|
+
return this.orchestratorNode(id, opts.async ? 'Orchestrator.StartAgenticProcessAsync' : 'Orchestrator.StartAgenticProcess', opts, body, { takesAsync: true });
|
|
1518
1565
|
}
|
|
1519
1566
|
/**
|
|
1520
1567
|
* Invoke a **case-management process** as a call activity
|
|
@@ -1526,7 +1573,7 @@ class ScopeBuilder {
|
|
|
1526
1573
|
* @returns This builder, so calls chain.
|
|
1527
1574
|
*/
|
|
1528
1575
|
startCaseProcess(id, opts, body) {
|
|
1529
|
-
return this.orchestratorNode(id, opts.async ? 'Orchestrator.StartCaseMgmtProcessAsync' : 'Orchestrator.StartCaseMgmtProcess', opts, body);
|
|
1576
|
+
return this.orchestratorNode(id, opts.async ? 'Orchestrator.StartCaseMgmtProcessAsync' : 'Orchestrator.StartCaseMgmtProcess', opts, body, { takesAsync: true });
|
|
1530
1577
|
}
|
|
1531
1578
|
/**
|
|
1532
1579
|
* Execute an **API workflow** and wait for it (`Orchestrator.ExecuteApiWorkflowAsync`).
|
package/dist/check.js
CHANGED
|
@@ -6,7 +6,7 @@ import { prepareCommand } from './core/cli-spelling.js';
|
|
|
6
6
|
import { Expr, parallelFork } from './flow-sdk.js';
|
|
7
7
|
import { FlowNode } from './core/node-classes.js';
|
|
8
8
|
import { definitionHasErrorPort } from './core/error-port.js';
|
|
9
|
-
import { bundledDefinition, resolveContributionDefinition,
|
|
9
|
+
import { bundledDefinition, resolveContributionDefinition, serializeForCheck } from './serialize.js';
|
|
10
10
|
import { checkEventResolution, checkEventSubscription, eventParamsFor, } from './core/event-checks.js';
|
|
11
11
|
import { checkCookedEscapes, checkFlowExpressions, checkVarsOnlyInQuotes, literalExprShape, literalLooksLikeExpr } from './flow-expr-check.js';
|
|
12
12
|
import { FLOW_EXPR_DIALECT, checkBindingLabels, checkConnectorLookups as coreCheckConnectorLookups, checkConnectorResources as coreCheckConnectorResources, checkConnectorSchema as coreCheckConnectorSchema, } from './core/connector-checks.js';
|
|
@@ -260,7 +260,7 @@ function serializerRefusals(built, compile, found) {
|
|
|
260
260
|
try {
|
|
261
261
|
// A stale `.layout()` key is the one serializer warning `check` repeats: compile
|
|
262
262
|
// drops the entry, and the author can only see that here (#1994).
|
|
263
|
-
flow =
|
|
263
|
+
flow = serializeForCheck(built, { ...compile, collect: (r) => collected.push(r), scopes: (sc) => scopes.push(sc), warn: (w) => { if (w.code === 'LAYOUT_UNKNOWN_KEY')
|
|
264
264
|
warned.push(w); } });
|
|
265
265
|
// Collection stopped: the refusal that stopped it is the last one reported.
|
|
266
266
|
const stop = collected[collected.length - 1];
|
|
@@ -38,3 +38,10 @@ export interface ElkEdge {
|
|
|
38
38
|
* @throws CompileRefusal `ELK_UNAVAILABLE` outside Node when no host handed elkjs over.
|
|
39
39
|
*/
|
|
40
40
|
export declare function elkLayout(graph: ElkNode): ElkNode;
|
|
41
|
+
/**
|
|
42
|
+
* Refuse as {@link elkLayout} would when this host has no layout engine, without
|
|
43
|
+
* loading one: `check` calls it where `compile` would lay a scope out.
|
|
44
|
+
*
|
|
45
|
+
* @throws CompileRefusal `ELK_UNAVAILABLE` outside Node when no host handed elkjs over.
|
|
46
|
+
*/
|
|
47
|
+
export declare function assertElkAvailable(): void;
|
package/dist/core/elk-module.js
CHANGED
|
@@ -62,11 +62,25 @@ function startWorker() {
|
|
|
62
62
|
post(w, { cmd: 'register', algorithms: DEFAULT_ALGORITHMS });
|
|
63
63
|
return w;
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Refuse as {@link elkLayout} would when this host has no layout engine, without
|
|
67
|
+
* loading one: `check` calls it where `compile` would lay a scope out.
|
|
68
|
+
*
|
|
69
|
+
* @throws CompileRefusal `ELK_UNAVAILABLE` outside Node when no host handed elkjs over.
|
|
70
|
+
*/
|
|
71
|
+
export function assertElkAvailable() {
|
|
72
|
+
if (worker !== undefined || globalThis[HOST_ELK] !== undefined)
|
|
73
|
+
return;
|
|
74
|
+
if (globalThis.process?.getBuiltinModule === undefined)
|
|
75
|
+
throw elkUnavailable();
|
|
76
|
+
}
|
|
77
|
+
function elkUnavailable() {
|
|
78
|
+
return new CompileRefusal('ELK_UNAVAILABLE', "no layout engine: outside Node, set globalThis[Symbol.for('uipath.maestro-builder-sdk.elkjs')] to the 'elkjs/lib/elk-worker.min.js' module before compiling a flow with no .layout()");
|
|
79
|
+
}
|
|
65
80
|
function fromNode() {
|
|
66
81
|
const getBuiltinModule = globalThis.process?.getBuiltinModule;
|
|
67
|
-
if (getBuiltinModule === undefined)
|
|
68
|
-
throw
|
|
69
|
-
}
|
|
82
|
+
if (getBuiltinModule === undefined)
|
|
83
|
+
throw elkUnavailable();
|
|
70
84
|
const { createRequire } = getBuiltinModule('node:module');
|
|
71
85
|
return createRequire(import.meta.url)('elkjs/lib/elk-worker.min.js');
|
|
72
86
|
}
|
|
@@ -46,8 +46,13 @@ export type OptionKeySet<T> = {
|
|
|
46
46
|
* {@link OptionKeySet}). Declare a family's list with it, never by hand.
|
|
47
47
|
*/
|
|
48
48
|
export declare function declareKeys<T>(keys: OptionKeySet<T>): readonly string[];
|
|
49
|
+
/** The refusal code and the noun its message uses for what would lose the key. */
|
|
50
|
+
export interface UnknownOptionOrigin {
|
|
51
|
+
readonly code: string;
|
|
52
|
+
readonly noun: string;
|
|
53
|
+
}
|
|
49
54
|
/**
|
|
50
|
-
* The
|
|
55
|
+
* The unknown-option refusal (FLOW_UNKNOWN_OPTION unless `origin` says otherwise) for the first key of `bag` that is not in
|
|
51
56
|
* `known`, or `undefined` when every key is known. A key whose value is
|
|
52
57
|
* `undefined` is skipped: it sets nothing, so nothing is dropped. Anything that
|
|
53
58
|
* is not a plain object (an array, an `Expr`, a missing bag) is not judged here.
|
|
@@ -59,4 +64,4 @@ export declare function declareKeys<T>(keys: OptionKeySet<T>): readonly string[]
|
|
|
59
64
|
* reads `step "fetch": http() has no option "retryCont". This SDK knows: …`, with the
|
|
60
65
|
* suggestion `retryCount` (the CLI prints it as `(did you mean "retryCount"?)`).
|
|
61
66
|
*/
|
|
62
|
-
export declare function unknownOptionRefusal(bag: unknown, known: readonly string[], call: string, where: string): CompileRefusal | undefined;
|
|
67
|
+
export declare function unknownOptionRefusal(bag: unknown, known: readonly string[], call: string, where: string, origin?: UnknownOptionOrigin): CompileRefusal | undefined;
|
package/dist/core/option-keys.js
CHANGED
|
@@ -34,8 +34,9 @@ import { PACKAGE_NAME } from '../package-name.js';
|
|
|
34
34
|
export function declareKeys(keys) {
|
|
35
35
|
return Object.freeze(Object.keys(keys));
|
|
36
36
|
}
|
|
37
|
+
const FLOW_ORIGIN = { code: 'FLOW_UNKNOWN_OPTION', noun: 'flow' };
|
|
37
38
|
/**
|
|
38
|
-
* The
|
|
39
|
+
* The unknown-option refusal (FLOW_UNKNOWN_OPTION unless `origin` says otherwise) for the first key of `bag` that is not in
|
|
39
40
|
* `known`, or `undefined` when every key is known. A key whose value is
|
|
40
41
|
* `undefined` is skipped: it sets nothing, so nothing is dropped. Anything that
|
|
41
42
|
* is not a plain object (an array, an `Expr`, a missing bag) is not judged here.
|
|
@@ -47,7 +48,7 @@ export function declareKeys(keys) {
|
|
|
47
48
|
* reads `step "fetch": http() has no option "retryCont". This SDK knows: …`, with the
|
|
48
49
|
* suggestion `retryCount` (the CLI prints it as `(did you mean "retryCount"?)`).
|
|
49
50
|
*/
|
|
50
|
-
export function unknownOptionRefusal(bag, known, call, where) {
|
|
51
|
+
export function unknownOptionRefusal(bag, known, call, where, origin = FLOW_ORIGIN) {
|
|
51
52
|
if (bag === null || typeof bag !== 'object' || Array.isArray(bag))
|
|
52
53
|
return undefined;
|
|
53
54
|
const proto = Object.getPrototypeOf(bag);
|
|
@@ -59,8 +60,8 @@ export function unknownOptionRefusal(bag, known, call, where) {
|
|
|
59
60
|
const key = unknown[0];
|
|
60
61
|
const nearest = nearestName(key, [...known]);
|
|
61
62
|
const others = unknown.length > 1 ? ` (and ${unknown.slice(1).map((k) => `"${k}"`).join(', ')})` : '';
|
|
62
|
-
return new CompileRefusal(
|
|
63
|
+
return new CompileRefusal(origin.code, `${where}: ${call} has no option "${key}"${others}.`
|
|
63
64
|
+ ` This SDK knows: ${known.length > 0 ? known.join(', ') : '(none)'}. An unknown option would be dropped `
|
|
64
|
-
+
|
|
65
|
+
+ `from the compiled ${origin.noun}, so it is refused: fix the spelling, remove it, or, if a newer SDK added it, `
|
|
65
66
|
+ `upgrade ${PACKAGE_NAME}.`, nearest);
|
|
66
67
|
}
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -122,6 +122,7 @@ export declare const REFUSALS: {
|
|
|
122
122
|
readonly BPMN_HUMAN_TASK_APP_NO_FOLDER: "lowering";
|
|
123
123
|
readonly BPMN_HUMAN_TASK_APP_V1_FIELDS: "lowering";
|
|
124
124
|
readonly BPMN_HUMAN_TASK_APP_XOR_FORM: "lowering";
|
|
125
|
+
readonly BPMN_JOB_OUTPUT_VAR_RESERVED: "lowering";
|
|
125
126
|
readonly BPMN_JSON_INPUT_CDATA_END: "lowering";
|
|
126
127
|
readonly BPMN_MESSAGE_NAME_EMPTY: "lowering";
|
|
127
128
|
readonly BPMN_NO_DEFAULT_EXPORT: "lowering";
|
|
@@ -147,6 +148,7 @@ export declare const REFUSALS: {
|
|
|
147
148
|
readonly BPMN_TYPE_NO_INPUTS: "lowering";
|
|
148
149
|
readonly BPMN_TYPE_SKIP_UNSUPPORTED: "lowering";
|
|
149
150
|
readonly BPMN_TYPE_UNKNOWN: "lowering";
|
|
151
|
+
readonly BPMN_UNKNOWN_OPTION: "lowering";
|
|
150
152
|
readonly BPMN_UNREACHABLE_IN_BODY: "lowering";
|
|
151
153
|
readonly BPMN_XML_MALFORMED: "lowering";
|
|
152
154
|
readonly BRANCH_CONST_COND: "lint";
|
package/dist/core/refusals.js
CHANGED
|
@@ -171,6 +171,7 @@ export const REFUSALS = {
|
|
|
171
171
|
BPMN_HUMAN_TASK_APP_NO_FOLDER: 'lowering',
|
|
172
172
|
BPMN_HUMAN_TASK_APP_V1_FIELDS: 'lowering',
|
|
173
173
|
BPMN_HUMAN_TASK_APP_XOR_FORM: 'lowering',
|
|
174
|
+
BPMN_JOB_OUTPUT_VAR_RESERVED: 'lowering',
|
|
174
175
|
BPMN_JSON_INPUT_CDATA_END: 'lowering',
|
|
175
176
|
BPMN_MESSAGE_NAME_EMPTY: 'lowering',
|
|
176
177
|
BPMN_NO_DEFAULT_EXPORT: 'lowering',
|
|
@@ -196,6 +197,7 @@ export const REFUSALS = {
|
|
|
196
197
|
BPMN_TYPE_NO_INPUTS: 'lowering',
|
|
197
198
|
BPMN_TYPE_SKIP_UNSUPPORTED: 'lowering',
|
|
198
199
|
BPMN_TYPE_UNKNOWN: 'lowering',
|
|
200
|
+
BPMN_UNKNOWN_OPTION: 'lowering',
|
|
199
201
|
BPMN_UNREACHABLE_IN_BODY: 'lowering',
|
|
200
202
|
BPMN_XML_MALFORMED: 'lowering',
|
|
201
203
|
BRANCH_CONST_COND: 'lint',
|
|
@@ -70,6 +70,13 @@ export interface ScriptFunctionScope {
|
|
|
70
70
|
* options passed by name) is the string form and is not a script function.
|
|
71
71
|
*/
|
|
72
72
|
export declare function scriptFunctionScope(file: string): ScriptFunctionScope;
|
|
73
|
+
/**
|
|
74
|
+
* {@link scriptFunctionScope} always over the full program, the SDK's
|
|
75
|
+
* declarations included: the reference the fast path is tested against.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export declare function scriptFunctionScopeWithSdkTypes(file: string): ScriptFunctionScope;
|
|
73
80
|
/**
|
|
74
81
|
* A compiler host that resolves the SDK's own specifiers (the package name and
|
|
75
82
|
* its subpaths) from inside this package, as `sdk-resolve-hook.ts` does at run
|
|
@@ -80,6 +87,13 @@ export declare function scriptFunctionScope(file: string): ScriptFunctionScope;
|
|
|
80
87
|
* specifier resolves as before.
|
|
81
88
|
*/
|
|
82
89
|
export declare function sdkResolvingHost(ts: typeof TS, options: TS.CompilerOptions): TS.CompilerHost;
|
|
90
|
+
/**
|
|
91
|
+
* Whether {@link scriptFunctionScope} needs the full program for `file`, that
|
|
92
|
+
* is, whether its fast path does not stand. For tests.
|
|
93
|
+
*
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
export declare function scriptFunctionScopeNeedsSdkTypes(file: string): boolean;
|
|
83
97
|
/** A whitespace-free key for comparing function texts. */
|
|
84
98
|
export declare function functionTextKey(text: string): string;
|
|
85
99
|
/**
|
|
@@ -15,13 +15,32 @@ import { isReference } from './core/script-function.js';
|
|
|
15
15
|
* options passed by name) is the string form and is not a script function.
|
|
16
16
|
*/
|
|
17
17
|
export function scriptFunctionScope(file) {
|
|
18
|
+
// The SDK's declarations matter only for a Case task's `.script(fn)` and an argument the pass did not follow.
|
|
19
|
+
const cheap = scopeOfProgram(file, false);
|
|
20
|
+
if (!cheap.needsSdkTypes)
|
|
21
|
+
return cheap.scope;
|
|
22
|
+
return scopeOfProgram(file, true).scope;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* {@link scriptFunctionScope} always over the full program, the SDK's
|
|
26
|
+
* declarations included: the reference the fast path is tested against.
|
|
27
|
+
*
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export function scriptFunctionScopeWithSdkTypes(file) {
|
|
31
|
+
return scopeOfProgram(file, true).scope;
|
|
32
|
+
}
|
|
33
|
+
/** {@link scriptFunctionScope} over one program, with or without the SDK's own declarations. */
|
|
34
|
+
function scopeOfProgram(file, withSdk) {
|
|
18
35
|
const ts = typescript();
|
|
19
36
|
const options = {
|
|
20
37
|
noLib: true, types: [], noEmit: true, skipLibCheck: true, allowImportingTsExtensions: true,
|
|
21
38
|
target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.NodeNext, moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
22
39
|
};
|
|
23
|
-
const program = ts.createProgram([file], options, sdkResolvingHost(ts, options));
|
|
40
|
+
const program = ts.createProgram([file], options, withSdk ? sdkResolvingHost(ts, options) : sdkUnresolvedHost(ts, options));
|
|
24
41
|
const checker = program.getTypeChecker();
|
|
42
|
+
// Set when the SDK's types could change the answer (see scriptFunctionScope).
|
|
43
|
+
let needsSdkTypes = false;
|
|
25
44
|
const cwd = process.cwd();
|
|
26
45
|
const where = (n) => {
|
|
27
46
|
const sf = n.getSourceFile();
|
|
@@ -37,9 +56,18 @@ export function scriptFunctionScope(file) {
|
|
|
37
56
|
if (sf.isDeclarationFile || sf.fileName.includes('/node_modules/'))
|
|
38
57
|
continue;
|
|
39
58
|
const visit = (n) => {
|
|
59
|
+
// A `.script(…)` method call on no namespace import may be a Case task's.
|
|
60
|
+
if (!withSdk && ts.isCallExpression(n) && ts.isPropertyAccessExpression(n.expression) && n.expression.name.text === 'script'
|
|
61
|
+
&& !isNamespaceScriptCall(ts, checker, n.expression))
|
|
62
|
+
needsSdkTypes = true;
|
|
40
63
|
if (ts.isCallExpression(n) && isScriptCall(ts, checker, n) && n.arguments.length > 0) {
|
|
41
64
|
const arg = n.arguments[0];
|
|
42
65
|
const fn = functionOf(ts, checker, arg);
|
|
66
|
+
// Decided by syntax, not by the argument's type: without the SDK an SDK
|
|
67
|
+
// type is `any`, which an overload or a conditional type can turn into
|
|
68
|
+
// anything. Only an object literal (the string form) is sure either way.
|
|
69
|
+
if (!withSdk && !fn && !ts.isObjectLiteralExpression(skipParens(ts, arg)))
|
|
70
|
+
needsSdkTypes = true;
|
|
43
71
|
if (!fn) {
|
|
44
72
|
const type = checker.getTypeAtLocation(arg);
|
|
45
73
|
if (type.getCallSignatures().length > 0)
|
|
@@ -61,7 +89,10 @@ export function scriptFunctionScope(file) {
|
|
|
61
89
|
};
|
|
62
90
|
visit(sf);
|
|
63
91
|
}
|
|
64
|
-
return {
|
|
92
|
+
return {
|
|
93
|
+
scope: { captures: out, unfollowed, untyped, followed: seen.size, followedTexts },
|
|
94
|
+
needsSdkTypes,
|
|
95
|
+
};
|
|
65
96
|
}
|
|
66
97
|
/**
|
|
67
98
|
* A compiler host that resolves the SDK's own specifiers (the package name and
|
|
@@ -82,6 +113,36 @@ export function sdkResolvingHost(ts, options) {
|
|
|
82
113
|
});
|
|
83
114
|
return host;
|
|
84
115
|
}
|
|
116
|
+
/** `node` without the parentheses around it. */
|
|
117
|
+
function skipParens(ts, node) {
|
|
118
|
+
while (ts.isParenthesizedExpression(node))
|
|
119
|
+
node = node.expression;
|
|
120
|
+
return node;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether {@link scriptFunctionScope} needs the full program for `file`, that
|
|
124
|
+
* is, whether its fast path does not stand. For tests.
|
|
125
|
+
*
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
export function scriptFunctionScopeNeedsSdkTypes(file) {
|
|
129
|
+
return scopeOfProgram(file, false).needsSdkTypes;
|
|
130
|
+
}
|
|
131
|
+
/** A compiler host that leaves the SDK's own specifiers unresolved, and resolves every other one as usual. */
|
|
132
|
+
function sdkUnresolvedHost(ts, options) {
|
|
133
|
+
const host = ts.createCompilerHost(options);
|
|
134
|
+
host.resolveModuleNameLiterals = (literals, containingFile, redirected, opts, containing) => literals.map((literal) => isSdkSpecifier(literal.text)
|
|
135
|
+
? { resolvedModule: undefined }
|
|
136
|
+
: ts.resolveModuleName(literal.text, containingFile, opts, host, undefined, redirected, ts.getModeForUsageLocation(containing, literal, opts)));
|
|
137
|
+
return host;
|
|
138
|
+
}
|
|
139
|
+
/** Whether `callee` is `<namespace import>.script`, Flow's `script` through `import * as sdk`. */
|
|
140
|
+
function isNamespaceScriptCall(ts, checker, callee) {
|
|
141
|
+
if (!ts.isIdentifier(callee.expression))
|
|
142
|
+
return false;
|
|
143
|
+
const decl = checker.getSymbolAtLocation(callee.expression)?.declarations?.[0];
|
|
144
|
+
return decl !== undefined && ts.isNamespaceImport(decl);
|
|
145
|
+
}
|
|
85
146
|
/** A whitespace-free key for comparing function texts. */
|
|
86
147
|
export function functionTextKey(text) {
|
|
87
148
|
return text.replace(/\s+/g, '');
|
package/dist/serialize.d.ts
CHANGED
|
@@ -169,8 +169,9 @@ export interface SerializeOpts {
|
|
|
169
169
|
* A refusal that names no one step (two steps with one name, a variable plan,
|
|
170
170
|
* a layout key) is scope-level: it is reported with no step, and collection
|
|
171
171
|
* stops there, so `serialize` returns `undefined`. An `internal SDK error:`
|
|
172
|
-
* throw is never caught.
|
|
173
|
-
* read
|
|
172
|
+
* throw is never caught. For `check` the output, stand-ins and all, is for
|
|
173
|
+
* nothing to read (it goes through `serializeForCheck`, with no layout);
|
|
174
|
+
* `merge`'s draft-tolerant compile also collects, and writes its output.
|
|
174
175
|
*
|
|
175
176
|
* For instance, a flow whose `notify` step names an input its connector does
|
|
176
177
|
* not declare, and whose `ticket` step pins an unregistered version, reports
|
|
@@ -267,6 +268,22 @@ export declare function bundledContainerDefinition(kind: 'loop' | 'doWhile', req
|
|
|
267
268
|
*/
|
|
268
269
|
export declare function resolveContributionDefinition(ref: DefinitionReference, requestedVersion: string | undefined, where: string): any;
|
|
269
270
|
export declare function serialize(built: BuiltFlow, opts?: SerializeOpts): any;
|
|
271
|
+
/**
|
|
272
|
+
* {@link serialize} for `check`: the same emission, refusals and canonical
|
|
273
|
+
* sizes, without the ELK auto-layout itself.
|
|
274
|
+
*
|
|
275
|
+
* `check` reads the result for its findings and node ids only, and positions
|
|
276
|
+
* change no finding (tests/check-layout-parity.test.ts), while the layout was
|
|
277
|
+
* most of `check`'s time. Where `compile` would lay a scope out, this only checks
|
|
278
|
+
* that the host has a layout engine, so `ELK_UNAVAILABLE` still reaches `check`.
|
|
279
|
+
* The one refusal left to `compile` is `LAYOUT_AUTO_FAILED`, an ELK failure on a
|
|
280
|
+
* scope with no `.layout()`, which asks the author to report the flow. Not for
|
|
281
|
+
* anything that writes the result: `merge`'s collect-mode compile is written, so
|
|
282
|
+
* it goes through {@link serialize}.
|
|
283
|
+
*
|
|
284
|
+
* @internal
|
|
285
|
+
*/
|
|
286
|
+
export declare function serializeForCheck(built: BuiltFlow, opts?: SerializeOpts): any;
|
|
270
287
|
/**
|
|
271
288
|
* Every node `configuration` that carries Studio Web's split envelope must be
|
|
272
289
|
* one Studio Web can restore: either essential-only (no, or an empty,
|
package/dist/serialize.js
CHANGED
|
@@ -1275,11 +1275,32 @@ function safeNodeId(name) {
|
|
|
1275
1275
|
return name.replace(/[^A-Za-z0-9_]/g, '_') || 'node';
|
|
1276
1276
|
}
|
|
1277
1277
|
export function serialize(built, opts = {}) {
|
|
1278
|
+
return serializeWith(built, opts, 'elk');
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* {@link serialize} for `check`: the same emission, refusals and canonical
|
|
1282
|
+
* sizes, without the ELK auto-layout itself.
|
|
1283
|
+
*
|
|
1284
|
+
* `check` reads the result for its findings and node ids only, and positions
|
|
1285
|
+
* change no finding (tests/check-layout-parity.test.ts), while the layout was
|
|
1286
|
+
* most of `check`'s time. Where `compile` would lay a scope out, this only checks
|
|
1287
|
+
* that the host has a layout engine, so `ELK_UNAVAILABLE` still reaches `check`.
|
|
1288
|
+
* The one refusal left to `compile` is `LAYOUT_AUTO_FAILED`, an ELK failure on a
|
|
1289
|
+
* scope with no `.layout()`, which asks the author to report the flow. Not for
|
|
1290
|
+
* anything that writes the result: `merge`'s collect-mode compile is written, so
|
|
1291
|
+
* it goes through {@link serialize}.
|
|
1292
|
+
*
|
|
1293
|
+
* @internal
|
|
1294
|
+
*/
|
|
1295
|
+
export function serializeForCheck(built, opts = {}) {
|
|
1296
|
+
return serializeWith(built, opts, 'probe');
|
|
1297
|
+
}
|
|
1298
|
+
function serializeWith(built, opts, scopeLayout) {
|
|
1278
1299
|
const collect = opts.collect;
|
|
1279
1300
|
if (!collect)
|
|
1280
|
-
return serializeFlow(built, opts);
|
|
1301
|
+
return serializeFlow(built, opts, scopeLayout);
|
|
1281
1302
|
try {
|
|
1282
|
-
return serializeFlow(built, opts);
|
|
1303
|
+
return serializeFlow(built, opts, scopeLayout);
|
|
1283
1304
|
}
|
|
1284
1305
|
catch (error) {
|
|
1285
1306
|
// A step's own refusal was taken by its catch (`emitStep`), so one that gets
|
|
@@ -1341,7 +1362,7 @@ function standInNode(name, authored, version, id, parentId) {
|
|
|
1341
1362
|
inputs: { standIn: true, spec: authoredValue(spec) },
|
|
1342
1363
|
};
|
|
1343
1364
|
}
|
|
1344
|
-
function serializeFlow(built, opts) {
|
|
1365
|
+
function serializeFlow(built, opts, scopeLayout) {
|
|
1345
1366
|
/**
|
|
1346
1367
|
* Definitions the flow carries (`.definitions()`, #1128), by `type@version` —
|
|
1347
1368
|
* the third source a pinned `{ version }` resolves from, after the bundle and
|
|
@@ -3747,7 +3768,8 @@ function serializeFlow(built, opts) {
|
|
|
3747
3768
|
// Sizes from each node's canvas shape, and `uip maestro flow format`'s layout for a
|
|
3748
3769
|
// flow or subflow with no `.layout()` node entries (#1992). After migration, so the
|
|
3749
3770
|
// layout reads the file `format` would read.
|
|
3750
|
-
|
|
3771
|
+
// `check` skips the ELK layout itself (see serializeForCheck).
|
|
3772
|
+
applyCompiledGeometry(flow, authorGeometry, scopeLayout);
|
|
3751
3773
|
// Emitted-document invariants over connections, checked on the FINISHED file
|
|
3752
3774
|
// so every family and every emission order is covered by one rule, not by
|
|
3753
3775
|
// each call site remembering it (flow-builder-sdk#865/#866).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.122.
|
|
3
|
+
"version": "6.122.11",
|
|
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",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"@types/node": "^22.7.0",
|
|
127
127
|
"esbuild": "^0.28.1"
|
|
128
128
|
},
|
|
129
|
-
"gitref": "
|
|
129
|
+
"gitref": "3187f53215450e0ef8d2e8d45caf86d1aa285338"
|
|
130
130
|
}
|