@uipath/maestro-builder-sdk 6.124.9 → 6.124.10
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.js +2 -2
- package/dist/core/expr-check.d.ts +13 -0
- package/dist/core/expr-check.js +1 -1
- package/dist/core/expr-helper-names.d.ts +8 -0
- package/dist/core/expr-helper-names.js +8 -0
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +1 -0
- package/dist/flow-expr-check.d.ts +14 -0
- package/dist/flow-expr-check.js +32 -1
- package/package.json +2 -2
package/dist/check.js
CHANGED
|
@@ -8,7 +8,7 @@ import { FlowNode } from './core/node-classes.js';
|
|
|
8
8
|
import { definitionHasErrorPort } from './core/error-port.js';
|
|
9
9
|
import { bundledDefinition, resolveContributionDefinition, serializeForCheck } from './serialize.js';
|
|
10
10
|
import { checkEventResolution, checkEventSubscription, eventParamsFor, } from './core/event-checks.js';
|
|
11
|
-
import { checkCookedEscapes, checkFlowExpressions, checkVarsOnlyInQuotes, literalExprShape, literalLooksLikeExpr } from './flow-expr-check.js';
|
|
11
|
+
import { checkCookedEscapes, checkFlowExpressions, checkHelperCalls, 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';
|
|
13
13
|
import { editDistance, nearestName } from './core/edit-distance.js';
|
|
14
14
|
import { escapeRegExp } from './core/escape-regexp.js';
|
|
@@ -53,7 +53,7 @@ export function checkCompiled(built, opts = {}) {
|
|
|
53
53
|
const diags = checkFlow(built, [], opts);
|
|
54
54
|
// Once, from the top: the walk reaches child flows itself, so running it per
|
|
55
55
|
// `checkFlow` would report a child's escape twice.
|
|
56
|
-
for (const d of [...checkCookedEscapes(built), ...checkVarsOnlyInQuotes(built)]) {
|
|
56
|
+
for (const d of [...checkCookedEscapes(built), ...checkVarsOnlyInQuotes(built), ...checkHelperCalls(built)]) {
|
|
57
57
|
diags.push({
|
|
58
58
|
level: d.level, code: d.code, message: `In ${d.where}: ${d.message}`,
|
|
59
59
|
...(d.step !== undefined ? { step: d.step } : {}),
|
|
@@ -108,6 +108,19 @@ export interface ExprScope {
|
|
|
108
108
|
*/
|
|
109
109
|
syntax?: 'javascript';
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Blank out the CONTENTS of single- and double-quoted string literals, preserving
|
|
113
|
+
* length and the quotes, so a `$vars.`-looking substring INSIDE a literal is not
|
|
114
|
+
* mistaken for a reference.
|
|
115
|
+
*
|
|
116
|
+
* `js`${input('a')} === ${'$vars.notAName'}`` renders to
|
|
117
|
+
* `$vars.a === "$vars.notAName"`; only the first is a reference. Template literals
|
|
118
|
+
* (backticks) are LEFT INTACT on purpose — the SDK's `tmpl` emits real references
|
|
119
|
+
* inside their `${…}`, and a literal `$vars.` in the surrounding URL/message text
|
|
120
|
+
* is not a thing the serializer produces. Escapes are honored so a quote inside a
|
|
121
|
+
* literal does not end it early.
|
|
122
|
+
*/
|
|
123
|
+
export declare function maskStringLiterals(expr: string): string;
|
|
111
124
|
/**
|
|
112
125
|
* Every `<namespace>.*` reference in an expression, in source order, with literals
|
|
113
126
|
* masked so a reference-shaped substring inside a string is not counted.
|
package/dist/core/expr-check.js
CHANGED
|
@@ -193,7 +193,7 @@ const DEFAULT_NAMESPACE = '$vars';
|
|
|
193
193
|
* is not a thing the serializer produces. Escapes are honored so a quote inside a
|
|
194
194
|
* literal does not end it early.
|
|
195
195
|
*/
|
|
196
|
-
function maskStringLiterals(expr) {
|
|
196
|
+
export function maskStringLiterals(expr) {
|
|
197
197
|
return expr.replace(/'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"/g, (m) => m[0] + ' '.repeat(m.length - 2) + m[m.length - 1]);
|
|
198
198
|
}
|
|
199
199
|
const SEGMENT = /\??\.([A-Za-z_$][\w$]*)|\[(\d+)\]/g;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The builder helpers in `expr.ts` that return an `Expr`: each runs while
|
|
3
|
+
* the flow is built, so its name written as text inside a `js` template reaches
|
|
4
|
+
* the runtime, which has no such function (EXPR_HELPER_CALL). Kept out of
|
|
5
|
+
* `expr.ts`, which `flow-sdk.ts` re-exports whole, so it stays internal.
|
|
6
|
+
* `tests/expr-helper-call.test.ts` fails when a helper in `expr.ts` is missing here.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EXPR_HELPER_NAMES: readonly ["lit", "v", "input", "entryInput", "out", "ran", "err"];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The builder helpers in `expr.ts` that return an `Expr`: each runs while
|
|
3
|
+
* the flow is built, so its name written as text inside a `js` template reaches
|
|
4
|
+
* the runtime, which has no such function (EXPR_HELPER_CALL). Kept out of
|
|
5
|
+
* `expr.ts`, which `flow-sdk.ts` re-exports whole, so it stays internal.
|
|
6
|
+
* `tests/expr-helper-call.test.ts` fails when a helper in `expr.ts` is missing here.
|
|
7
|
+
*/
|
|
8
|
+
export const EXPR_HELPER_NAMES = ['lit', 'v', 'input', 'entryInput', 'out', 'ran', 'err'];
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -369,6 +369,7 @@ export declare const REFUSALS: {
|
|
|
369
369
|
readonly EXPR_BARE_PREFIX: "lint";
|
|
370
370
|
readonly EXPR_BARE_PREFIX_JS_SYNTAX: "lint";
|
|
371
371
|
readonly EXPR_BARE_VAR_REF: "lint";
|
|
372
|
+
readonly EXPR_HELPER_CALL: "lint";
|
|
372
373
|
readonly EXPR_SYNTAX: "lowering";
|
|
373
374
|
readonly EXPR_UNDECLARED_REF: "lint";
|
|
374
375
|
readonly EXPR_VARS_ONLY_IN_QUOTES: "lint";
|
package/dist/core/refusals.js
CHANGED
|
@@ -443,6 +443,7 @@ export const REFUSALS = {
|
|
|
443
443
|
EXPR_BARE_PREFIX: 'lint',
|
|
444
444
|
EXPR_BARE_PREFIX_JS_SYNTAX: 'lint',
|
|
445
445
|
EXPR_BARE_VAR_REF: 'lint',
|
|
446
|
+
EXPR_HELPER_CALL: 'lint',
|
|
446
447
|
EXPR_SYNTAX: 'lowering',
|
|
447
448
|
EXPR_UNDECLARED_REF: 'lint',
|
|
448
449
|
EXPR_VARS_ONLY_IN_QUOTES: 'lint',
|
|
@@ -50,6 +50,20 @@ export declare function checkCookedEscapes(built: BuiltFlow): (LocatedDiagnostic
|
|
|
50
50
|
export declare function checkVarsOnlyInQuotes(built: BuiltFlow): (LocatedDiagnostic & {
|
|
51
51
|
step?: string;
|
|
52
52
|
})[];
|
|
53
|
+
/**
|
|
54
|
+
* EXPR_HELPER_CALL (warning): an expression whose text calls a builder helper
|
|
55
|
+
* (`out(`, `ran(`, `lit(` … {@link EXPR_HELPER_NAMES}) outside `${}`, or its
|
|
56
|
+
* optional-call form `out?.(`. The helper runs only while the flow
|
|
57
|
+
* is built, so js`out('a', 'score') >= 0.8` writes the call as text, and the
|
|
58
|
+
* runtime has no `out` to call. js`${out('a', 'score')} >= 0.8` is the read.
|
|
59
|
+
*
|
|
60
|
+
* String literals are masked first, so a helper name inside a quoted string is
|
|
61
|
+
* not reported. A name after `.`, `$` or a word character (`x.out(`, `about(`)
|
|
62
|
+
* is not a bare call.
|
|
63
|
+
*/
|
|
64
|
+
export declare function checkHelperCalls(built: BuiltFlow): (LocatedDiagnostic & {
|
|
65
|
+
step?: string;
|
|
66
|
+
})[];
|
|
53
67
|
/**
|
|
54
68
|
* How a plain string looks like an expression: `text` = sent as written,
|
|
55
69
|
* `template` = interpolated through `{{ … }}`, `wire` = evaluated because it
|
package/dist/flow-expr-check.js
CHANGED
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
* script body's `$vars.*` reads are `check.ts`'s UNKNOWN_REF.
|
|
33
33
|
*/
|
|
34
34
|
import { Expr, cookedEscapesOf } from './core/expr.js';
|
|
35
|
-
import {
|
|
35
|
+
import { EXPR_HELPER_NAMES } from './core/expr-helper-names.js';
|
|
36
|
+
import { checkExpression, cookedEscapeDiagnostics, extractRefs, maskStringLiterals, quotedOnlyMentions } from './core/expr-check.js';
|
|
36
37
|
import { refusalClass } from './core/refusals.js';
|
|
37
38
|
import { stepDeclaredVariables } from './flow-step-variables.js';
|
|
38
39
|
import { CompileRefusal } from './core/compile-refusal.js';
|
|
@@ -348,6 +349,36 @@ export function checkVarsOnlyInQuotes(built) {
|
|
|
348
349
|
});
|
|
349
350
|
return out;
|
|
350
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* EXPR_HELPER_CALL (warning): an expression whose text calls a builder helper
|
|
354
|
+
* (`out(`, `ran(`, `lit(` … {@link EXPR_HELPER_NAMES}) outside `${}`, or its
|
|
355
|
+
* optional-call form `out?.(`. The helper runs only while the flow
|
|
356
|
+
* is built, so js`out('a', 'score') >= 0.8` writes the call as text, and the
|
|
357
|
+
* runtime has no `out` to call. js`${out('a', 'score')} >= 0.8` is the read.
|
|
358
|
+
*
|
|
359
|
+
* String literals are masked first, so a helper name inside a quoted string is
|
|
360
|
+
* not reported. A name after `.`, `$` or a word character (`x.out(`, `about(`)
|
|
361
|
+
* is not a bare call.
|
|
362
|
+
*/
|
|
363
|
+
export function checkHelperCalls(built) {
|
|
364
|
+
const out = [];
|
|
365
|
+
const bareCall = new RegExp(`(?<![\\w$.])(${EXPR_HELPER_NAMES.join('|')})\\s*(?:\\?\\.)?\\(`);
|
|
366
|
+
visitExprs(built, (val, at) => {
|
|
367
|
+
if (!(val instanceof Expr) || val.literal)
|
|
368
|
+
return;
|
|
369
|
+
const helper = bareCall.exec(maskStringLiterals(val.js))?.[1];
|
|
370
|
+
if (helper === undefined)
|
|
371
|
+
return;
|
|
372
|
+
out.push(located({
|
|
373
|
+
level: 'warning',
|
|
374
|
+
code: 'EXPR_HELPER_CALL',
|
|
375
|
+
message: `the expression \`${val.js.length > 120 ? `${val.js.slice(0, 117)}...` : val.js}\` calls \`${helper}(...)\` as text. `
|
|
376
|
+
+ `\`${helper}\` is a builder helper: it runs only while the flow is built, and the runtime cannot call it. `
|
|
377
|
+
+ `Put the call inside \`\${}\`: js\`\${${helper}(...)} >= 0.8\`.`,
|
|
378
|
+
}, at));
|
|
379
|
+
});
|
|
380
|
+
return out;
|
|
381
|
+
}
|
|
351
382
|
// ─── LITERAL_LOOKS_LIKE_EXPR (#1970) ────────────────────────────────────────
|
|
352
383
|
//
|
|
353
384
|
// A plain string in a node input is not an expression to the SDK: only
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.124.
|
|
3
|
+
"version": "6.124.10",
|
|
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",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"@types/node": "^22.7.0",
|
|
129
129
|
"esbuild": "^0.28.1"
|
|
130
130
|
},
|
|
131
|
-
"gitref": "
|
|
131
|
+
"gitref": "5ba9a721fe5e26bf932d29dabbf0f24862f6fd5a"
|
|
132
132
|
}
|