@uipath/maestro-builder-sdk 6.86.15 → 6.86.17
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.
|
@@ -22,12 +22,36 @@ import type { BuiltCase } from './case-sdk.js';
|
|
|
22
22
|
export interface CaseLocatedDiagnostic extends ExprDiagnostic {
|
|
23
23
|
where: string;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The undeclared `vars.<root>` names `expr` reads, as `build()` reports them
|
|
27
|
+
* (`EXPR_UNDECLARED_REF`). A task-output reference stands in as a declared root.
|
|
28
|
+
* For decompile, which refuses such a gate by name rather than writing source
|
|
29
|
+
* compile refuses.
|
|
30
|
+
*/
|
|
31
|
+
export declare function undeclaredVarReads(expr: string, roots: ReadonlySet<string>): string[];
|
|
25
32
|
/**
|
|
26
33
|
* The platform variable that says whether the stage labelled `label` has run
|
|
27
34
|
* (case-schema `baseLocalStageHasRunVariableInfoForStage`): `Stage 1` ->
|
|
28
35
|
* `stageHasRun_Stage_1`. Exported for the Case fuzzer's stage renames.
|
|
29
36
|
*/
|
|
30
37
|
export declare function stageHasRunVariable(label: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Variables the platform declares for every case, which a plan's gates may read
|
|
40
|
+
* though no row of the plan declares them. `uip maestro case validate` adds the
|
|
41
|
+
* same set to the variables it checks against (case-schema
|
|
42
|
+
* `validateCaseManagementVariables`), and the BPMN converter writes each one:
|
|
43
|
+
*
|
|
44
|
+
* - `stageHasRun_<stage label>` per stage (`getCaseStateVariables`), set in the
|
|
45
|
+
* initial variables setup and updated when the stage exits or completes. The
|
|
46
|
+
* platform's own V11->V12 migration writes gates on it:
|
|
47
|
+
* `=js:(vars.stageHasRun_Review != true)` for "first time this stage runs";
|
|
48
|
+
* - the hidden event-subprocess rows `tasksEventSubprocessResponse`,
|
|
49
|
+
* `mainEventSubprocessResponse`, `connectorResponse` and `eventMetadata`.
|
|
50
|
+
*
|
|
51
|
+
* Not here: the per-SLA `stageSla_<stage>_<sla id>` rows, whose ids compile
|
|
52
|
+
* mints after this check runs.
|
|
53
|
+
*/
|
|
54
|
+
export declare function platformVariables(stageLabels: readonly string[]): string[];
|
|
31
55
|
/** Every first-level expression problem in a built case, each stamped with its location. */
|
|
32
56
|
export declare function checkCaseExpressions(built: BuiltCase): CaseLocatedDiagnostic[];
|
|
33
57
|
/**
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* (`rule.stage` / `rule.tasks`) are a different thing and are checked by
|
|
16
16
|
* `case/check.ts`, not here.
|
|
17
17
|
*/
|
|
18
|
-
import { checkExpression } from '../core/expr-check.js';
|
|
18
|
+
import { checkExpression, extractRefs } from '../core/expr-check.js';
|
|
19
19
|
import { CompileRefusal } from '../core/compile-refusal.js';
|
|
20
20
|
import { readEventFilter } from '../core/event-filters.js';
|
|
21
21
|
import { defaultActionOutputVar } from './action-output-var.js';
|
|
@@ -77,6 +77,17 @@ function checkTaskOutputRefs(built, value, where, out) {
|
|
|
77
77
|
out.push({ level: 'error', code: 'TASK_OUTPUT_REF_UNRESOLVED', message: unresolvedTaskOutputRef(ref, why), where });
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* The undeclared `vars.<root>` names `expr` reads, as `build()` reports them
|
|
82
|
+
* (`EXPR_UNDECLARED_REF`). A task-output reference stands in as a declared root.
|
|
83
|
+
* For decompile, which refuses such a gate by name rather than writing source
|
|
84
|
+
* compile refuses.
|
|
85
|
+
*/
|
|
86
|
+
export function undeclaredVarReads(expr, roots) {
|
|
87
|
+
const lowered = lowerTaskOutputRefs(expr, () => TASK_OUTPUT_ROOT);
|
|
88
|
+
const scope = new Set([...roots, TASK_OUTPUT_ROOT]);
|
|
89
|
+
return [...new Set(extractRefs(lowered, NAMESPACE).map((ref) => ref.root).filter((root) => !scope.has(root)))];
|
|
90
|
+
}
|
|
80
91
|
function checkExpr(built, expr, where, roots, out) {
|
|
81
92
|
if (!expr)
|
|
82
93
|
return;
|
|
@@ -147,9 +158,9 @@ export function stageHasRunVariable(label) {
|
|
|
147
158
|
* Not here: the per-SLA `stageSla_<stage>_<sla id>` rows, whose ids compile
|
|
148
159
|
* mints after this check runs.
|
|
149
160
|
*/
|
|
150
|
-
function platformVariables(
|
|
161
|
+
export function platformVariables(stageLabels) {
|
|
151
162
|
return [
|
|
152
|
-
...
|
|
163
|
+
...stageLabels.map((label) => stageHasRunVariable(label)),
|
|
153
164
|
'tasksEventSubprocessResponse',
|
|
154
165
|
'mainEventSubprocessResponse',
|
|
155
166
|
'connectorResponse',
|
|
@@ -159,7 +170,7 @@ function platformVariables(built) {
|
|
|
159
170
|
/** Every first-level expression problem in a built case, each stamped with its location. */
|
|
160
171
|
export function checkCaseExpressions(built) {
|
|
161
172
|
const roots = new Set(built.vars.map((v) => v.name));
|
|
162
|
-
for (const name of platformVariables(built))
|
|
173
|
+
for (const name of platformVariables(built.stages.map((s) => s.label)))
|
|
163
174
|
roots.add(name);
|
|
164
175
|
// Task output bindings declare readable case variables too (`=vars.<var>`),
|
|
165
176
|
// via a root `inputOutputs` companion — include them so a gate that reads a
|
package/dist/case/decompile.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ interface IoRow {
|
|
|
14
14
|
default?: unknown;
|
|
15
15
|
body?: unknown;
|
|
16
16
|
_jsonSchema?: unknown;
|
|
17
|
+
/** A third copy of an action form output's `body` the Designer can save. */
|
|
18
|
+
jsonSchema?: unknown;
|
|
17
19
|
custom?: boolean;
|
|
18
20
|
elementId?: string;
|
|
19
21
|
var?: string;
|
|
@@ -186,7 +188,7 @@ export interface DecompileOptions {
|
|
|
186
188
|
bestEffort?: boolean;
|
|
187
189
|
}
|
|
188
190
|
export interface CaseDecompileDiagnostic {
|
|
189
|
-
code: 'UNSUPPORTED_TASK_KIND' | 'UNKNOWN_STAGE_REFERENCE' | 'UNKNOWN_TASK_REFERENCE' | 'UNKNOWN_EXIT_TARGET';
|
|
191
|
+
code: 'UNSUPPORTED_TASK_KIND' | 'UNKNOWN_STAGE_REFERENCE' | 'UNKNOWN_TASK_REFERENCE' | 'UNKNOWN_EXIT_TARGET' | 'UNDECLARED_VARIABLE_REFERENCE';
|
|
190
192
|
message: string;
|
|
191
193
|
location: string;
|
|
192
194
|
}
|
package/dist/case/decompile.js
CHANGED
|
@@ -25,6 +25,8 @@ import { bindingIdCandidates, offlineBindingLabel } from './ids.js';
|
|
|
25
25
|
import { bindingRefId, isLiftFailure, isMintedWire, liftResourceFolder, liftResourceName, readBindingIds, resourceBindingOf, typedFolder, wireRows, } from './resource-wire.js';
|
|
26
26
|
import { connectorPlaceholderKindOf } from './connector-placeholder.js';
|
|
27
27
|
import { raiseTaskOutputReads, referableOutputIds } from './task-output-ref.js';
|
|
28
|
+
import { defaultActionOutputVar } from './action-output-var.js';
|
|
29
|
+
import { platformVariables, undeclaredVarReads } from './case-expr-check.js';
|
|
28
30
|
const TASK_KIND_METHOD = {
|
|
29
31
|
process: 'process',
|
|
30
32
|
agent: 'agent',
|
|
@@ -703,7 +705,7 @@ const ACTION_DATA_KEYS = new Set([
|
|
|
703
705
|
const ACTION_INPUT_ROW_KEYS = new Set([
|
|
704
706
|
'name', 'type', 'subType', 'displayName', 'value', 'required', 'options', 'body', 'source', 'id', 'var', 'elementId',
|
|
705
707
|
]);
|
|
706
|
-
const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema']);
|
|
708
|
+
const ACTION_OUTPUT_ROW_KEYS = new Set([...ACTION_INPUT_ROW_KEYS, 'target', 'originalVar', '_jsonSchema', 'jsonSchema']);
|
|
707
709
|
function actionFields(rows, side, owner) {
|
|
708
710
|
if (!rows?.length)
|
|
709
711
|
return undefined;
|
|
@@ -723,6 +725,11 @@ function actionFields(rows, side, owner) {
|
|
|
723
725
|
// Compile writes an output's `_jsonSchema` as a copy of its `body`.
|
|
724
726
|
if (row._jsonSchema !== undefined && JSON.stringify(row._jsonSchema) !== JSON.stringify(row.body))
|
|
725
727
|
throw new Error(`${owner} form output "${row.name ?? '?'}" has a _jsonSchema that is not a copy of its body.`);
|
|
728
|
+
// The Designer can also save a structured output's schema as `jsonSchema`,
|
|
729
|
+
// a third copy of its `body` that nothing reads to run the case; it is
|
|
730
|
+
// carried (`actionOutputShape`) only as that copy.
|
|
731
|
+
if (row.jsonSchema !== undefined && (row.body === undefined || JSON.stringify(row.jsonSchema) !== JSON.stringify(row.body)))
|
|
732
|
+
throw new Error(`${owner} form output "${row.name ?? '?'}" has a jsonSchema that is not a copy of its body.`);
|
|
726
733
|
}
|
|
727
734
|
const defaultSource = (row) => (side === 'output' ? `=${row.name ?? ''}` : undefined);
|
|
728
735
|
return `[${rows.map((row) => opts([
|
|
@@ -2181,7 +2188,8 @@ function actionInputShape(task, row) {
|
|
|
2181
2188
|
* way: `omit` lists the fields the Designer row lacks (`target`, which compile
|
|
2182
2189
|
* always writes; `_jsonSchema` beside a `body`; `elementId`), `target` names
|
|
2183
2190
|
* the variable a target spelled as `=<var>` or `=<originalVar>` names
|
|
2184
|
-
* (`outputTargetOf`),
|
|
2191
|
+
* (`outputTargetOf`), `bodyCopies` lists the extra copies of its `body` it was
|
|
2192
|
+
* saved with (`jsonSchema`), and `elementId`
|
|
2185
2193
|
* is carried when it names another element than the task (the converter wires
|
|
2186
2194
|
* an output to its task only on a matching `elementId`).
|
|
2187
2195
|
*/
|
|
@@ -2200,6 +2208,8 @@ function actionOutputShape(task, row) {
|
|
|
2200
2208
|
...(row.elementId !== undefined && row.elementId !== task.elementId ? { elementId: row.elementId } : {}),
|
|
2201
2209
|
...(omit.length ? { omit } : {}),
|
|
2202
2210
|
...(targetOf ? { target: targetOf } : {}),
|
|
2211
|
+
// `actionFields` has checked it is a copy of `body`.
|
|
2212
|
+
...(row.jsonSchema !== undefined ? { bodyCopies: ['jsonSchema'] } : {}),
|
|
2203
2213
|
};
|
|
2204
2214
|
}
|
|
2205
2215
|
/**
|
|
@@ -2771,6 +2781,7 @@ export function decompileWithDiagnostics(plan, options = {}) {
|
|
|
2771
2781
|
const diagnostics = [];
|
|
2772
2782
|
refuseUnsupportedAuthoring(plan);
|
|
2773
2783
|
plan = raiseTaskOutputRefs(plan);
|
|
2784
|
+
refuseUndeclaredGateReads(plan, options.bestEffort ? diagnostics : undefined);
|
|
2774
2785
|
const preservation = collectPreservation(plan);
|
|
2775
2786
|
const refs = buildRefs(plan, options.library, options.bestEffort ? diagnostics : undefined);
|
|
2776
2787
|
const selectNextStage = selectNextStageByExit(plan, refs);
|
|
@@ -2861,6 +2872,90 @@ export function decompileWithDiagnostics(plan, options = {}) {
|
|
|
2861
2872
|
const source = `import { ${imports.join(', ')} } from ${tsLiteral(options.importSpecifier ?? './case-sdk.js')};\n\n${diagnosticHeader}${out.toString()}\n`;
|
|
2862
2873
|
return { source, diagnostics };
|
|
2863
2874
|
}
|
|
2875
|
+
/**
|
|
2876
|
+
* Every name a `vars.<name>` gate of `plan` may read without `build()` calling
|
|
2877
|
+
* it undeclared: what the plan's rows declare (each `id` / `var` / `name`, a
|
|
2878
|
+
* literal `value` / `target`), an action form field's default variable, and the
|
|
2879
|
+
* variables the platform declares for every case. It is a superset of the roots
|
|
2880
|
+
* `build()` checks the decompiled source against, so decompile never refuses a
|
|
2881
|
+
* gate compile accepts.
|
|
2882
|
+
*/
|
|
2883
|
+
function gateRoots(plan) {
|
|
2884
|
+
const roots = new Set(platformVariables((plan.nodes ?? []).filter(isStage).map((s) => String(s.data?.label ?? ''))));
|
|
2885
|
+
const walk = (value, inAction) => {
|
|
2886
|
+
if (Array.isArray(value)) {
|
|
2887
|
+
for (const item of value)
|
|
2888
|
+
walk(item, inAction);
|
|
2889
|
+
return;
|
|
2890
|
+
}
|
|
2891
|
+
if (!value || typeof value !== 'object')
|
|
2892
|
+
return;
|
|
2893
|
+
const row = value;
|
|
2894
|
+
const action = inAction || row.type === 'action';
|
|
2895
|
+
for (const [key, field] of Object.entries(row)) {
|
|
2896
|
+
if (typeof field === 'string') {
|
|
2897
|
+
if (key === 'id' || key === 'var' || key === 'name')
|
|
2898
|
+
roots.add(field);
|
|
2899
|
+
if ((key === 'value' || key === 'target') && !field.startsWith('='))
|
|
2900
|
+
roots.add(field);
|
|
2901
|
+
if ((key === 'value' || key === 'target') && /^=[\w$]+$/.test(field))
|
|
2902
|
+
roots.add(field.slice(1));
|
|
2903
|
+
if (key === 'name' && action)
|
|
2904
|
+
roots.add(defaultActionOutputVar(field));
|
|
2905
|
+
}
|
|
2906
|
+
else
|
|
2907
|
+
walk(field, action);
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
walk({ ...plan, metadata: undefined }, false);
|
|
2911
|
+
walk(plan.metadata, false);
|
|
2912
|
+
return roots;
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Refuse a gate that reads a variable the plan does not declare. `build()`
|
|
2916
|
+
* rejects such a reference (`EXPR_UNDECLARED_REF`: `vars.` is a closed
|
|
2917
|
+
* namespace, and the runtime reads the name as `undefined`), so writing the
|
|
2918
|
+
* gate into the source would only hand the author source compile refuses.
|
|
2919
|
+
* Names the platform declares for every case (`stageHasRun_<stage>`, ...) are
|
|
2920
|
+
* not refused; see `platformVariables`.
|
|
2921
|
+
*/
|
|
2922
|
+
function refuseUndeclaredGateReads(plan, diagnostics) {
|
|
2923
|
+
const roots = gateRoots(plan);
|
|
2924
|
+
const check = (expr, where) => {
|
|
2925
|
+
if (typeof expr !== 'string' || !expr)
|
|
2926
|
+
return;
|
|
2927
|
+
const missing = undeclaredVarReads(expr, roots);
|
|
2928
|
+
if (!missing.length)
|
|
2929
|
+
return;
|
|
2930
|
+
const reads = `reads ${missing.map((name) => `\`vars.${name}\``).join(', ')}, which no variable of the plan declares `
|
|
2931
|
+
+ '(compile refuses it: EXPR_UNDECLARED_REF; at runtime it reads as undefined)';
|
|
2932
|
+
// Best effort keeps the gate and marks the source as needing this repair.
|
|
2933
|
+
if (diagnostics) {
|
|
2934
|
+
diagnostics.push({ code: 'UNDECLARED_VARIABLE_REFERENCE', location: where, message: `${reads}. Declare the variable, or fix the expression.` });
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
throw new Error(`${where} ${reads}. Declare the variable, or fix the expression to read one the case declares, then decompile again.`);
|
|
2938
|
+
};
|
|
2939
|
+
const rules = (conditions, where) => {
|
|
2940
|
+
for (const condition of conditions ?? [])
|
|
2941
|
+
for (const group of condition.rules ?? [])
|
|
2942
|
+
for (const r of group ?? [])
|
|
2943
|
+
check(r?.conditionExpression, where);
|
|
2944
|
+
};
|
|
2945
|
+
(plan.metadata?.slaRules ?? []).forEach((sla, i) => check(sla?.expression, `case SLA #${i + 1}`));
|
|
2946
|
+
rules(plan.metadata?.caseExitRules, 'case completion rule');
|
|
2947
|
+
for (const stage of (plan.nodes ?? []).filter(isStage)) {
|
|
2948
|
+
const at = `stage "${stage.data?.label ?? stage.id ?? '?'}"`;
|
|
2949
|
+
rules(stage.data?.entryConditions, `${at} entry rule`);
|
|
2950
|
+
rules(stage.data?.exitConditions, `${at} exit rule`);
|
|
2951
|
+
(stage.data?.slaRules ?? []).forEach((sla, i) => check(sla?.expression, `${at} SLA #${i + 1}`));
|
|
2952
|
+
for (const task of (stage.data?.tasks ?? []).flat()) {
|
|
2953
|
+
const tat = `task "${task?.displayName ?? task?.id ?? '?'}" in ${at}`;
|
|
2954
|
+
check(task?.skipCondition, `${tat} skip condition`);
|
|
2955
|
+
rules(task?.entryConditions, `${tat} entry rule`);
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2864
2959
|
/**
|
|
2865
2960
|
* The plan with each read of a task output that recompiling could not keep,
|
|
2866
2961
|
* `vars.<output id>`, written as the task-output reference that names the same
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -188,7 +188,7 @@ interface StageIdentity {
|
|
|
188
188
|
elementId?: string;
|
|
189
189
|
fields?: Record<string, unknown>;
|
|
190
190
|
}>;
|
|
191
|
-
/** `originalVar` only when it is not the row's `id` (the serializer's own spelling). `elementId` when an action form output names another element than its task. `fields` as on an input. `omit`: the fields an action form output (`target`, `_jsonSchema`, `elementId`) or a resource extract (`target`) was saved without that compile writes. `target`: which of the row's variables its saved `target` names when that is not its id (`=<var>` or `=<originalVar>`; compile writes `=<id>`). */
|
|
191
|
+
/** `originalVar` only when it is not the row's `id` (the serializer's own spelling). `elementId` when an action form output names another element than its task. `fields` as on an input. `omit`: the fields an action form output (`target`, `_jsonSchema`, `elementId`) or a resource extract (`target`) was saved without that compile writes. `target`: which of the row's variables its saved `target` names when that is not its id (`=<var>` or `=<originalVar>`; compile writes `=<id>`). `bodyCopies`: the extra copies of its `body` an action form output was saved with (`jsonSchema`), which compile writes back from the body. */
|
|
192
192
|
/** `var` and `custom: true`: a custom row whose label (`name`) is not the name of the variable it assigns. */
|
|
193
193
|
outputs?: Array<{
|
|
194
194
|
name: string;
|
|
@@ -198,6 +198,7 @@ interface StageIdentity {
|
|
|
198
198
|
fields?: Record<string, unknown>;
|
|
199
199
|
omit?: string[];
|
|
200
200
|
target?: 'var' | 'originalVar';
|
|
201
|
+
bodyCopies?: string[];
|
|
201
202
|
var?: string;
|
|
202
203
|
custom?: true;
|
|
203
204
|
}>;
|
package/dist/case/serialize.js
CHANGED
|
@@ -1383,6 +1383,10 @@ function applyPreservedIdentities(result, preservation) {
|
|
|
1383
1383
|
rowRenames.push(() => { delete target[field]; });
|
|
1384
1384
|
if (target && actionRows && typeof row.elementId === 'string')
|
|
1385
1385
|
rowRenames.push(() => { target.elementId = row.elementId; });
|
|
1386
|
+
// An action form output saved with a `jsonSchema` copy of its body gets the copy back, from the body it compiles with.
|
|
1387
|
+
if (target && actionRows && row.bodyCopies?.includes('jsonSchema'))
|
|
1388
|
+
rowRenames.push(() => { if (target.body !== undefined)
|
|
1389
|
+
target.jsonSchema = structuredClone(target.body); });
|
|
1386
1390
|
carryRowShape(target, row);
|
|
1387
1391
|
// A nested own-name row (`app_id: '=response.app_id'`, written bare since
|
|
1388
1392
|
// builder-sdk#1241) whose carried id is not its variable is a row an
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.86.
|
|
3
|
+
"version": "6.86.17",
|
|
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",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"@types/node": "^22.7.0",
|
|
104
104
|
"esbuild": "^0.28.1"
|
|
105
105
|
},
|
|
106
|
-
"gitref": "
|
|
106
|
+
"gitref": "21bd42bbb7051e1a78361d7669405d25d2294dbe"
|
|
107
107
|
}
|