@uipath/maestro-builder-sdk 6.110.0 → 6.111.0

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 CHANGED
@@ -6,7 +6,7 @@ import { FlowNode } from './core/node-classes.js';
6
6
  import { definitionHasErrorPort } from './core/error-port.js';
7
7
  import { bundledDefinition, resolveContributionDefinition, serialize } from './serialize.js';
8
8
  import { checkEventResolution, checkEventSubscription, eventParamsFor, } from './core/event-checks.js';
9
- import { checkCookedEscapes, checkFlowExpressions } from './flow-expr-check.js';
9
+ import { checkCookedEscapes, checkFlowExpressions, literalExprShape, literalLooksLikeExpr } from './flow-expr-check.js';
10
10
  import { FLOW_EXPR_DIALECT, checkBindingLabels, checkConnectorLookups as coreCheckConnectorLookups, checkConnectorResources as coreCheckConnectorResources, checkConnectorSchema as coreCheckConnectorSchema, } from './core/connector-checks.js';
11
11
  import { nearestName } from './core/edit-distance.js';
12
12
  import { escapeRegExp } from './core/escape-regexp.js';
@@ -2498,6 +2498,7 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
2498
2498
  },
2499
2499
  };
2500
2500
  impl.check?.(spec, ctx);
2501
+ const lookalikes = new Set();
2501
2502
  for (const site of impl.expressions(spec)) {
2502
2503
  if ('code' in site) {
2503
2504
  // A script body: checked for its `$vars.` refs although it is a string. No
@@ -2506,6 +2507,7 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
2506
2507
  }
2507
2508
  else {
2508
2509
  pushDeepExprs(site.value, s.name, errorSource, exprs);
2510
+ pushLiteralLookalikes(site.value, s.name, diags, lookalikes);
2509
2511
  }
2510
2512
  }
2511
2513
  return ctx;
@@ -2562,6 +2564,34 @@ function pushDeepExprs(value, step, errorSource, out) {
2562
2564
  pushDeepExprs(v, step, errorSource, out);
2563
2565
  }
2564
2566
  }
2567
+ /**
2568
+ * LITERAL_LOOKS_LIKE_EXPR (warning): every plain string in an evaluated value
2569
+ * (`value`, walked as `pushDeepExprs` walks it) that reads like an expression
2570
+ * (`literalExprShape`, which documents what it does and does not flag). An
2571
+ * `Expr` is skipped whole, a `lit(...)` included: that is how an author says
2572
+ * the text is meant. One finding per distinct string per step: a URL repeated
2573
+ * in two headers is one mistake.
2574
+ */
2575
+ function pushLiteralLookalikes(value, step, diags, seen) {
2576
+ if (value instanceof Expr)
2577
+ return;
2578
+ if (typeof value === 'string') {
2579
+ const shape = literalExprShape(value);
2580
+ if (shape === undefined || seen.has(value))
2581
+ return;
2582
+ seen.add(value);
2583
+ const { message, suggestion } = literalLooksLikeExpr(value, shape, step);
2584
+ diags.push({ level: 'warning', code: 'LITERAL_LOOKS_LIKE_EXPR', step, message, ...(suggestion !== undefined ? { suggestion } : {}) });
2585
+ }
2586
+ else if (Array.isArray(value)) {
2587
+ for (const v of value)
2588
+ pushLiteralLookalikes(v, step, diags, seen);
2589
+ }
2590
+ else if (value && typeof value === 'object') {
2591
+ for (const v of Object.values(value))
2592
+ pushLiteralLookalikes(v, step, diags, seen);
2593
+ }
2594
+ }
2565
2595
  /** Whether `e` is one of the SDK's own `internal SDK error:` throws, which `check` never turns into a diagnostic. */
2566
2596
  function isInternalSdkError(e) {
2567
2597
  return e instanceof Error && e.message.startsWith('internal SDK error:');
@@ -572,6 +572,7 @@ export declare const REFUSALS: {
572
572
  readonly LIBRARY_NOT_FOUND: "lowering";
573
573
  readonly LIBRARY_REQUIRED: "lowering";
574
574
  readonly LIST_OUTPUT_WRAPPER: "lint";
575
+ readonly LITERAL_LOOKS_LIKE_EXPR: "lint";
575
576
  readonly LOOKUP_ARGS: "lowering";
576
577
  readonly LOOKUP_CONNECTION_MISMATCH: "lint";
577
578
  readonly LOOKUP_LITERAL_ID: "lint";
@@ -648,6 +648,7 @@ export const REFUSALS = {
648
648
  LIBRARY_NOT_FOUND: 'lowering',
649
649
  LIBRARY_REQUIRED: 'lowering',
650
650
  LIST_OUTPUT_WRAPPER: 'lint',
651
+ LITERAL_LOOKS_LIKE_EXPR: 'lint',
651
652
  LOOKUP_ARGS: 'lowering',
652
653
  LOOKUP_CONNECTION_MISMATCH: 'lint',
653
654
  LOOKUP_LITERAL_ID: 'lint',
@@ -36,6 +36,24 @@ export declare function checkFlowExpressions(built: BuiltFlow): LocatedDiagnosti
36
36
  export declare function checkCookedEscapes(built: BuiltFlow): (LocatedDiagnostic & {
37
37
  step?: string;
38
38
  })[];
39
+ /**
40
+ * How a plain string looks like an expression: `text` = sent as written,
41
+ * `template` = interpolated through `{{ … }}`, `wire` = evaluated because it
42
+ * starts with `=`.
43
+ */
44
+ export type LiteralExprShape = 'wire' | 'template' | 'text';
45
+ /** Whether a plain input string looks like an expression the author meant to write as one. */
46
+ export declare function literalExprShape(text: string): LiteralExprShape | undefined;
47
+ /**
48
+ * The finding for one plain string `literalExprShape` matched, worded for `step`.
49
+ * The suggestion is the SDK spelling when the string is exactly one reference
50
+ * (`$vars.s.output.x` or `=vars.s.output.x` → `out('s', 'x')`), or `js` around
51
+ * an `=js:` body.
52
+ */
53
+ export declare function literalLooksLikeExpr(text: string, shape: LiteralExprShape, step: string): {
54
+ message: string;
55
+ suggestion?: string;
56
+ };
39
57
  /**
40
58
  * The expression problems `compile` refuses: every error whose code is
41
59
  * `lowering` (`EXPR_SYNTAX`). The serializer throws a {@link FlowBuildError} on
@@ -280,6 +280,81 @@ export function checkCookedEscapes(built) {
280
280
  visit(built, { where: 'flow', prefix: '' });
281
281
  return out;
282
282
  }
283
+ // ─── LITERAL_LOOKS_LIKE_EXPR (#1970) ────────────────────────────────────────
284
+ //
285
+ // A plain string in a node input is not an expression to the SDK: only
286
+ // `js`/`tmpl`/`out()` build one. TypeScript accepts it (the field is
287
+ // `string | Expr`), the serializer writes it as authored, and no reference,
288
+ // syntax or rename check reaches it. What happens to it at run time depends on
289
+ // its shape, and the rule below names the three shapes that look like an
290
+ // expression the author meant:
291
+ //
292
+ // - `text`: a `$vars.` / `$vars[` / `$metadata.` / `$metadata[` mention outside
293
+ // `{{ … }}`. That part is sent as written: `http({ url: '$vars.s.output.x' })`
294
+ // sends the characters `$vars.s.output.x`.
295
+ // - `template`: every mention sits inside `{{ … }}`. The product's converter
296
+ // compiles such a literal to a template (`{{ $vars.x }}` → `${vars.x}`), so
297
+ // it runs, but unchecked.
298
+ // - `wire`: the string starts with `=`. The engine evaluates every `=` string
299
+ // as an expression (`=js:…`, and the binding spellings `=vars.x`, `=$vars.x`
300
+ // as well; the C# engine's `ParseEval`, the local engine's
301
+ // `evaluateObjectExpressions`), and one that does not evaluate is null. So it
302
+ // runs, but unchecked, and `=SUM(A1:A3)` or `==== Report ====` reaches the
303
+ // next step as null, not as the text.
304
+ //
305
+ // It looks only where a node evaluates a value (a node type's `expressions()`
306
+ // value sites, `check.ts` `pushLiteralLookalikes`). Deliberately NOT flagged:
307
+ // an `=` inside the text (a URL query string `?a=b`), `{{ name }}` with no
308
+ // `$vars`/`$metadata` in it, `lit(...)` (the explicit literal), and anything
309
+ // that is not a value site — a script body (`code`), an agent prompt,
310
+ // human-task titles and descriptions, a raw node's wire inputs. A subflow
311
+ // input and a `.return()` value are not read either: the builder turns a plain
312
+ // string there into `lit(...)` (`toExpr`), so it cannot be told from one the
313
+ // author wrote on purpose.
314
+ /** A `$vars` / `$metadata` read, as JavaScript spells one. */
315
+ const VARS_MENTION = /\$(?:vars|metadata)\s*[.[]/;
316
+ /** A `{{ … }}` interpolation, as the product's converter finds one (`hasMustacheInterpolation`). */
317
+ const MUSTACHE = /\{\{[^{}]+\}\}/g;
318
+ /** Whether a plain input string looks like an expression the author meant to write as one. */
319
+ export function literalExprShape(text) {
320
+ if (text.startsWith('='))
321
+ return 'wire';
322
+ if (!VARS_MENTION.test(text))
323
+ return undefined;
324
+ return VARS_MENTION.test(text.replace(/\\\{/g, '').replace(MUSTACHE, '')) ? 'text' : 'template';
325
+ }
326
+ /**
327
+ * The finding for one plain string `literalExprShape` matched, worded for `step`.
328
+ * The suggestion is the SDK spelling when the string is exactly one reference
329
+ * (`$vars.s.output.x` or `=vars.s.output.x` → `out('s', 'x')`), or `js` around
330
+ * an `=js:` body.
331
+ */
332
+ export function literalLooksLikeExpr(text, shape, step) {
333
+ const shown = JSON.stringify(text.length > 80 ? `${text.slice(0, 77)}...` : text);
334
+ const unchecked = 'but the SDK never checks it: no reference, syntax or rename check reaches a plain string.';
335
+ const message = shape === 'wire'
336
+ ? `In step "${step}": the plain string ${shown} starts with "=", so the engine evaluates it as an expression `
337
+ + `(null when it does not evaluate), ${unchecked} `
338
+ + 'Write the expression with js`...` (or out(...), input(...), tmpl`...`) so it is checked, '
339
+ + 'or drop the leading "=" if the text is meant.'
340
+ : shape === 'template'
341
+ ? `In step "${step}": the plain string ${shown} reads $vars inside {{ ... }}, which the converter interpolates, ${unchecked} `
342
+ + 'Write it with tmpl`...${out(...)}...` so each reference is checked.'
343
+ : `In step "${step}": the plain string ${shown} looks like an expression, but a plain string is literal text: `
344
+ + 'the flow sends it exactly as written. Write it as an expression (out(...), input(...), js`...` or tmpl`...`), '
345
+ + 'or wrap it in lit(...) if the text really is meant.';
346
+ const body = (text.startsWith('=js:') ? text.slice(4) : text.replace(/^=/, '')).trim()
347
+ .replace(/^(?=(?:vars|metadata)\.)/, () => '$');
348
+ const ref = /^\$vars\.([A-Za-z_$][\w$]*)\.output(?:\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*))?$/.exec(body);
349
+ let suggestion;
350
+ if (ref && ref[1] === 'start' && ref[2] && !ref[2].includes('.'))
351
+ suggestion = `input('${ref[2]}')`;
352
+ else if (ref)
353
+ suggestion = ref[2] ? `out('${ref[1]}', '${ref[2]}')` : `out('${ref[1]}')`;
354
+ else if (text.startsWith('=js:') && body && !/[`\\]|\$\{/.test(body))
355
+ suggestion = `js\`${body}\``;
356
+ return { message, ...(suggestion !== undefined ? { suggestion } : {}) };
357
+ }
283
358
  /**
284
359
  * The expression problems `compile` refuses: every error whose code is
285
360
  * `lowering` (`EXPR_SYNTAX`). The serializer throws a {@link FlowBuildError} on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.110.0",
3
+ "version": "6.111.0",
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",
@@ -123,5 +123,5 @@
123
123
  "@types/node": "^22.7.0",
124
124
  "esbuild": "^0.28.1"
125
125
  },
126
- "gitref": "0a9aff796fc17366d91e10f723108adb494d09b4"
126
+ "gitref": "b15c2763847c5eddc42573477d28692f00a28844"
127
127
  }