@uipath/maestro-builder-sdk 6.109.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.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * lives in the serializer alone.
10
10
  */
11
11
  import type { SolutionProjects } from './core/solution-projects.js';
12
- import type { ResourceResolutions } from './core/resource-resolution.js';
12
+ import { type ResourceResolutions } from './core/resource-resolution.js';
13
13
  import type { NodeCatalog } from './core/node-catalog.js';
14
14
  import type { Library } from './core/library.js';
15
15
  import type { BuiltFlow } from './flow-sdk.js';
package/dist/check.js CHANGED
@@ -1,9 +1,12 @@
1
+ import { isResourceToken } from './core/resource-resolution.js';
2
+ import { isLookupToken } from './core/lookups.js';
3
+ import { prepareCommand } from './core/cli-spelling.js';
1
4
  import { Expr, parallelFork } from './flow-sdk.js';
2
5
  import { FlowNode } from './core/node-classes.js';
3
6
  import { definitionHasErrorPort } from './core/error-port.js';
4
7
  import { bundledDefinition, resolveContributionDefinition, serialize } from './serialize.js';
5
8
  import { checkEventResolution, checkEventSubscription, eventParamsFor, } from './core/event-checks.js';
6
- import { checkCookedEscapes, checkFlowExpressions } from './flow-expr-check.js';
9
+ import { checkCookedEscapes, checkFlowExpressions, literalExprShape, literalLooksLikeExpr } from './flow-expr-check.js';
7
10
  import { FLOW_EXPR_DIALECT, checkBindingLabels, checkConnectorLookups as coreCheckConnectorLookups, checkConnectorResources as coreCheckConnectorResources, checkConnectorSchema as coreCheckConnectorSchema, } from './core/connector-checks.js';
8
11
  import { nearestName } from './core/edit-distance.js';
9
12
  import { escapeRegExp } from './core/escape-regexp.js';
@@ -1291,6 +1294,58 @@ function checkConnectorResourceScope(step, spec, opts, diags) {
1291
1294
  function checkConnectorSchema(step, spec, opts, diags) {
1292
1295
  const { where, report } = connectorSite(step, diags);
1293
1296
  coreCheckConnectorSchema(where, spec, opts, FLOW_EXPR_DIALECT, report);
1297
+ checkConnectorSchemaReplay(where, spec, opts, report);
1298
+ }
1299
+ /**
1300
+ * SCHEMA_REPLAY_PARENT_MISMATCH (#1972): a step on a prepared schema-dynamic
1301
+ * operation that sets a parent to another literal than the one prepared. A
1302
+ * warning: compile writes the step's own request, and the flow may be right;
1303
+ * what is unproven is that its inputs fit that parent's fields.
1304
+ *
1305
+ * SCHEMA_REPLAY_MISSING (#1972): a schema-dynamic operation whose fields depend
1306
+ * on the VALUES of parent inputs (Jira `create-issue` on project and issue
1307
+ * type), on a step that compile would write `customFieldsRequestDetails: null`
1308
+ * for — no `prepare -f` recorded a request, and a parent is unset or computed
1309
+ * at run time. `validate` accepts that, and the designer cannot replay the
1310
+ * schema, so it opens the node with only the parents. A warning: the run reads
1311
+ * the node's parameters, not the request. The fix is the prepare that records
1312
+ * the request for the values the step means.
1313
+ *
1314
+ * A `lookup()` or `resource()` token is a literal by compile time, so it counts
1315
+ * as set.
1316
+ */
1317
+ function checkConnectorSchemaReplay(where, spec, opts, report) {
1318
+ const authored = Object.entries(spec.inputs ?? {});
1319
+ // A token's value is not known here, so it is not compared with the prepared one.
1320
+ const mismatch = opts.schemaReplayMismatch?.(spec, Object.fromEntries(authored.filter(([, v]) => !isLookupToken(v) && !isResourceToken(v))));
1321
+ if (mismatch) {
1322
+ report({
1323
+ level: 'warning',
1324
+ code: 'SCHEMA_REPLAY_PARENT_MISMATCH',
1325
+ message: `${where}: this operation's fields were prepared for `
1326
+ + mismatch.mismatches.map((m) => `${m.name} = ${JSON.stringify(m.recorded)}`).join(', ')
1327
+ + `, but this step sets ${mismatch.mismatches.map((m) => `${m.name} = ${JSON.stringify(m.given)}`).join(', ')}. `
1328
+ + "Compile writes this step's own schema replay request, but its inputs were checked against the prepared values' "
1329
+ + 'fields, which can differ. To check them against this step\'s fields, prepare for its values and re-run check:\n'
1330
+ + ` ${prepareCommand(spec.key, spec.action, ...mismatch.flags)}\n`
1331
+ + 'One operation keeps one prepared field set, so with several steps on it, check each one this way in turn.',
1332
+ });
1333
+ }
1334
+ const inputs = Object.fromEntries(authored
1335
+ .map(([k, v]) => [k, isLookupToken(v) || isResourceToken(v) ? '<resolved at compile>' : v]));
1336
+ const gap = opts.schemaReplayGap?.(spec, inputs);
1337
+ if (!gap)
1338
+ return;
1339
+ const flags = gap.parents.flatMap((p) => ['-f', `${p}=<value>`]);
1340
+ report({
1341
+ level: 'warning',
1342
+ code: 'SCHEMA_REPLAY_MISSING',
1343
+ message: `${where}: this operation's fields depend on the values of ${gap.parents.map((p) => `\`${p}\``).join(', ')}, `
1344
+ + `and ${gap.unresolved.map((p) => `\`${p}\``).join(', ')} ${gap.unresolved.length === 1 ? 'has' : 'have'} no literal value here, `
1345
+ + 'so compile writes no schema replay request (customFieldsRequestDetails: null). validate accepts that, but the '
1346
+ + 'designer cannot load the fields for it. Record the request for the values the step is designed for:\n'
1347
+ + ` ${prepareCommand(spec.key, spec.action, ...flags)}`,
1348
+ });
1294
1349
  }
1295
1350
  /**
1296
1351
  * Reject a wrapper hop when the runtime shape of a list has been measured: the
@@ -2443,6 +2498,7 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
2443
2498
  },
2444
2499
  };
2445
2500
  impl.check?.(spec, ctx);
2501
+ const lookalikes = new Set();
2446
2502
  for (const site of impl.expressions(spec)) {
2447
2503
  if ('code' in site) {
2448
2504
  // A script body: checked for its `$vars.` refs although it is a string. No
@@ -2451,6 +2507,7 @@ function checkRegisteredStep(entry, s, exprs, errorSource, opts, diags, typeOf,
2451
2507
  }
2452
2508
  else {
2453
2509
  pushDeepExprs(site.value, s.name, errorSource, exprs);
2510
+ pushLiteralLookalikes(site.value, s.name, diags, lookalikes);
2454
2511
  }
2455
2512
  }
2456
2513
  return ctx;
@@ -2507,6 +2564,34 @@ function pushDeepExprs(value, step, errorSource, out) {
2507
2564
  pushDeepExprs(v, step, errorSource, out);
2508
2565
  }
2509
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
+ }
2510
2595
  /** Whether `e` is one of the SDK's own `internal SDK error:` throws, which `check` never turns into a diagnostic. */
2511
2596
  function isInternalSdkError(e) {
2512
2597
  return e instanceof Error && e.message.startsWith('internal SDK error:');
@@ -22,6 +22,7 @@ import { flagValue } from '../cli-run.js';
22
22
  import { defaultOverlayDir } from '../workdir.js';
23
23
  import { EQUALS_EXPR_DIALECT } from './connector-checks.js';
24
24
  import { connectorInputErrors, connectorResourceRefusals } from './connector-inputs.js';
25
+ import { schemaReplayGap, schemaReplayMismatch } from './connector-configuration.js';
25
26
  /**
26
27
  * The library for this invocation, or `undefined` when there is none.
27
28
  *
@@ -149,6 +150,16 @@ export function connectorCheckOpts(library, bindings, inputErrors = (rc, inputs,
149
150
  return undefined;
150
151
  return inputErrors(r.rc, inputs, library.lookupResolutions ?? {}, library.lookupSpecs(spec.key, spec.action, spec.version, spec.object) ?? {});
151
152
  },
153
+ // A schema-dynamic operation compile would write no replay request for (#1972).
154
+ schemaReplayGap: (spec, inputs) => {
155
+ const r = resolve(spec);
156
+ return 'rc' in r ? schemaReplayGap(r.rc.entry, inputs) : undefined;
157
+ },
158
+ // A prepared one whose parents the step sets to other values (#1972).
159
+ schemaReplayMismatch: (spec, inputs) => {
160
+ const r = resolve(spec);
161
+ return 'rc' in r ? schemaReplayMismatch(r.rc.entry, inputs) : undefined;
162
+ },
152
163
  // The unresolved `resource()` tokens, through the field paths compile projects.
153
164
  connectorResources: (spec, inputs, resources) => {
154
165
  const r = resolve(spec);
@@ -159,6 +159,38 @@ export interface ConnectorCheckOpts {
159
159
  * steps share across connections from one `prepare` can fix.
160
160
  */
161
161
  lookupConnections?: LookupConnectionIndex;
162
+ /**
163
+ * For a schema-dynamic operation compile would write no replay request for:
164
+ * its parents, and the ones these inputs leave without a literal value
165
+ * (`schemaReplayGap`, core/connector-configuration.ts). `undefined` otherwise.
166
+ */
167
+ schemaReplayGap?: (spec: {
168
+ key: string;
169
+ action: string;
170
+ version?: string;
171
+ object?: string;
172
+ }, inputs: Record<string, unknown>) => {
173
+ parents: string[];
174
+ unresolved: string[];
175
+ } | undefined;
176
+ /**
177
+ * For a prepared schema-dynamic operation: the parents these inputs set to
178
+ * other literals than `prepare -f` recorded, and the `-f` flags that would
179
+ * record the step's values (`schemaReplayMismatch`). `undefined` otherwise.
180
+ */
181
+ schemaReplayMismatch?: (spec: {
182
+ key: string;
183
+ action: string;
184
+ version?: string;
185
+ object?: string;
186
+ }, inputs: Record<string, unknown>) => {
187
+ mismatches: Array<{
188
+ name: string;
189
+ recorded: string;
190
+ given: string;
191
+ }>;
192
+ flags: string[];
193
+ } | undefined;
162
194
  }
163
195
  /**
164
196
  * The `resource()` / `entity()` inputs.
@@ -9,6 +9,58 @@
9
9
  * nodes already store. See {@link buildConfiguration} for why the split form
10
10
  * broke the designer (flow-builder-sdk#936).
11
11
  */
12
+ /**
13
+ * The parents a prepared replay request was recorded for that the step sets to
14
+ * a DIFFERENT literal, as `{ name, recorded, given }`.
15
+ *
16
+ * `registry prepare -f <parent>=<value>` records the request
17
+ * (`customFieldsRequestDetails`) and the field set those values select. A step
18
+ * that names another project or issue type had its inputs checked against the
19
+ * old fields (#1972). A parent the step leaves unset, or
20
+ * sets from a runtime expression, is not compared: the recorded values are the
21
+ * author's design-time choice for it.
22
+ */
23
+ export declare function schemaReplayParentMismatches(details: unknown, inputValues: Record<string, unknown> | undefined): Array<{
24
+ name: string;
25
+ recorded: string;
26
+ given: string;
27
+ }>;
28
+ /**
29
+ * The parents a schema-dynamic operation needs literal values for before
30
+ * compile can write a replay request, or `undefined` when it writes one (or
31
+ * needs none).
32
+ *
33
+ * An operation is schema-dynamic when the library records its design-time
34
+ * action (`operation.schemaAction` with `parents`). Compile writes the request
35
+ * `prepare -f` recorded, else one from the step's own literal parents; with a
36
+ * parent unset or computed at run time it writes `customFieldsRequestDetails:
37
+ * null`, which `validate` accepts and the designer cannot replay
38
+ * (`SCHEMA_REPLAY_MISSING`, #1972).
39
+ */
40
+ export declare function schemaReplayGap(entry: any, inputValues: Record<string, unknown>): {
41
+ parents: string[];
42
+ unresolved: string[];
43
+ } | undefined;
44
+ /**
45
+ * A prepared operation's mismatch for one step: the parents the step sets to
46
+ * another literal, and the `prepare` that would record the step's own values,
47
+ * or `undefined` when the step matches what was prepared (or nothing was).
48
+ *
49
+ * `prepare -f` records ONE request per operation, so two steps on the same
50
+ * operation with different parents (two entities, two Jira projects) cannot
51
+ * both match it. Compile therefore writes each step's own request (see
52
+ * {@link schemaReplayDetails}); what is left is that the step's inputs were
53
+ * validated against the prepared values' field set, which `check` reports as
54
+ * the warning `SCHEMA_REPLAY_PARENT_MISMATCH` (#1972).
55
+ */
56
+ export declare function schemaReplayMismatch(entry: any, inputValues: Record<string, unknown>): {
57
+ mismatches: Array<{
58
+ name: string;
59
+ recorded: string;
60
+ given: string;
61
+ }>;
62
+ flags: string[];
63
+ } | undefined;
12
64
  /**
13
65
  * Compose the `=jsonString:`-wrapped configuration for a connector library entry.
14
66
  *
@@ -89,9 +89,136 @@ const ESSENTIAL_KEYS = new Set([
89
89
  'path',
90
90
  'unifiedTypesCompatible',
91
91
  ]);
92
- function schemaReplayDetails(operation, inputValues) {
92
+ /**
93
+ * An input's value by the library's name for it: the flat key (`project`,
94
+ * `fields.project.key` as one key), else the nested path a body object holds
95
+ * (`{ fields: { project: { key } } }`).
96
+ */
97
+ function inputAt(inputValues, name) {
98
+ if (Object.hasOwn(inputValues, name))
99
+ return inputValues[name];
100
+ let at = inputValues;
101
+ for (const segment of name.split('.')) {
102
+ if (typeof at !== 'object' || at === null || Array.isArray(at) || !Object.hasOwn(at, segment))
103
+ return undefined;
104
+ at = at[segment];
105
+ }
106
+ return at;
107
+ }
108
+ /**
109
+ * A parent input's literal text, or `undefined` for one that is not a literal:
110
+ * absent, a container, or a runtime expression (Flow's `=js:…`, BPMN's
111
+ * `=vars.…`; a literal parent value never starts with `=`).
112
+ */
113
+ function literalParent(value) {
114
+ if (typeof value === 'number' || typeof value === 'boolean')
115
+ return String(value);
116
+ if (typeof value === 'string' && !value.startsWith('='))
117
+ return value;
118
+ return undefined;
119
+ }
120
+ /**
121
+ * The parents a prepared replay request was recorded for that the step sets to
122
+ * a DIFFERENT literal, as `{ name, recorded, given }`.
123
+ *
124
+ * `registry prepare -f <parent>=<value>` records the request
125
+ * (`customFieldsRequestDetails`) and the field set those values select. A step
126
+ * that names another project or issue type had its inputs checked against the
127
+ * old fields (#1972). A parent the step leaves unset, or
128
+ * sets from a runtime expression, is not compared: the recorded values are the
129
+ * author's design-time choice for it.
130
+ */
131
+ export function schemaReplayParentMismatches(details, inputValues) {
132
+ const rows = details?.parameterValues;
133
+ if (!inputValues || !Array.isArray(rows))
134
+ return [];
135
+ const mismatches = [];
136
+ for (const row of rows) {
137
+ if (!Array.isArray(row) || typeof row[0] !== 'string')
138
+ continue;
139
+ const name = row[0].replaceAll('_sub_', '.');
140
+ const recorded = String(row[1]);
141
+ const given = literalParent(inputAt(inputValues, name));
142
+ if (given !== undefined && given !== recorded)
143
+ mismatches.push({ name, recorded, given });
144
+ }
145
+ return mismatches;
146
+ }
147
+ /**
148
+ * The parents a schema-dynamic operation needs literal values for before
149
+ * compile can write a replay request, or `undefined` when it writes one (or
150
+ * needs none).
151
+ *
152
+ * An operation is schema-dynamic when the library records its design-time
153
+ * action (`operation.schemaAction` with `parents`). Compile writes the request
154
+ * `prepare -f` recorded, else one from the step's own literal parents; with a
155
+ * parent unset or computed at run time it writes `customFieldsRequestDetails:
156
+ * null`, which `validate` accepts and the designer cannot replay
157
+ * (`SCHEMA_REPLAY_MISSING`, #1972).
158
+ */
159
+ export function schemaReplayGap(entry, inputValues) {
160
+ const operation = entry?.operation ?? {};
93
161
  if (operation.customFieldsRequestDetails)
94
- return operation.customFieldsRequestDetails;
162
+ return undefined;
163
+ const action = operation.schemaAction;
164
+ const parents = Array.isArray(action?.parents) ? action.parents.filter((p) => typeof p === 'string') : [];
165
+ if (typeof action?.name !== 'string' || parents.length === 0)
166
+ return undefined;
167
+ const unresolved = parents.filter((p) => literalParent(inputAt(inputValues, p)) === undefined);
168
+ return unresolved.length > 0 ? { parents, unresolved } : undefined;
169
+ }
170
+ /**
171
+ * A prepared operation's mismatch for one step: the parents the step sets to
172
+ * another literal, and the `prepare` that would record the step's own values,
173
+ * or `undefined` when the step matches what was prepared (or nothing was).
174
+ *
175
+ * `prepare -f` records ONE request per operation, so two steps on the same
176
+ * operation with different parents (two entities, two Jira projects) cannot
177
+ * both match it. Compile therefore writes each step's own request (see
178
+ * {@link schemaReplayDetails}); what is left is that the step's inputs were
179
+ * validated against the prepared values' field set, which `check` reports as
180
+ * the warning `SCHEMA_REPLAY_PARENT_MISMATCH` (#1972).
181
+ */
182
+ export function schemaReplayMismatch(entry, inputValues) {
183
+ const details = entry?.operation?.customFieldsRequestDetails;
184
+ const mismatches = schemaReplayParentMismatches(details, inputValues);
185
+ if (mismatches.length === 0)
186
+ return undefined;
187
+ const flags = details.parameterValues
188
+ .filter((row) => Array.isArray(row) && typeof row[0] === 'string')
189
+ .flatMap((row) => {
190
+ const name = String(row[0]).replaceAll('_sub_', '.');
191
+ const changed = mismatches.find((m) => m.name === name);
192
+ return ['-f', `${name}=${changed ? changed.given : String(row[1])}`];
193
+ });
194
+ return { mismatches, flags };
195
+ }
196
+ /**
197
+ * The schema replay request compile writes for one step.
198
+ *
199
+ * A prepared request whose parents the step sets to other literals is rebuilt
200
+ * with the step's values: the request is per step, the recording per
201
+ * operation, so the recorded one would describe another parent's schema
202
+ * (#1972). A parent the step leaves unset or computes at run time keeps the
203
+ * prepared value, the author's design-time choice for it.
204
+ */
205
+ function schemaReplayDetails(entry, inputValues) {
206
+ const operation = entry?.operation ?? {};
207
+ if (operation.customFieldsRequestDetails) {
208
+ const details = operation.customFieldsRequestDetails;
209
+ const mismatches = schemaReplayParentMismatches(details, inputValues);
210
+ if (mismatches.length === 0)
211
+ return details;
212
+ return {
213
+ ...details,
214
+ parameterValues: details.parameterValues.map((row) => {
215
+ if (!Array.isArray(row) || typeof row[0] !== 'string')
216
+ return row;
217
+ const changed = mismatches.find((m) => m.name === String(row[0]).replaceAll('_sub_', '.'));
218
+ return changed ? [row[0], changed.given] : row;
219
+ }),
220
+ };
221
+ }
95
222
  const action = operation.schemaAction;
96
223
  const parents = Array.isArray(action?.parents) ? action.parents : [];
97
224
  if (!inputValues || typeof action?.name !== 'string' || parents.length === 0)
@@ -241,7 +368,7 @@ export function buildEssentialConfiguration(entry, version, inputValues, seed =
241
368
  // activity has none (`null`, the default).
242
369
  executionType,
243
370
  operation: verb,
244
- customFieldsRequestDetails: schemaReplayDetails(op, inputValues),
371
+ customFieldsRequestDetails: schemaReplayDetails(entry, inputValues),
245
372
  savedFilterTrees: savedFilterTrees(op, inputValues, seed),
246
373
  objectName: op.objectName,
247
374
  httpMethod: transportHttpMethod(op.httpMethod),
@@ -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";
@@ -703,6 +704,8 @@ export declare const REFUSALS: {
703
704
  readonly SCHEDULE_NEVER_FIRES: "lint";
704
705
  readonly SCHEDULE_NOT_ISO: "lint";
705
706
  readonly SCHEDULE_NO_INTERVAL: "lint";
707
+ readonly SCHEMA_REPLAY_MISSING: "lint";
708
+ readonly SCHEMA_REPLAY_PARENT_MISMATCH: "lint";
706
709
  readonly SCHEMA_VERSION_ABOVE_FLOOR: "lint";
707
710
  readonly SCHEMA_VERSION_BELOW_FLOOR: "lint";
708
711
  readonly SCHEMA_VERSION_ON_SUBFLOW: "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',
@@ -779,6 +780,8 @@ export const REFUSALS = {
779
780
  SCHEDULE_NEVER_FIRES: 'lint',
780
781
  SCHEDULE_NOT_ISO: 'lint',
781
782
  SCHEDULE_NO_INTERVAL: 'lint',
783
+ SCHEMA_REPLAY_MISSING: 'lint',
784
+ SCHEMA_REPLAY_PARENT_MISMATCH: 'lint',
782
785
  SCHEMA_VERSION_ABOVE_FLOOR: 'lint',
783
786
  SCHEMA_VERSION_BELOW_FLOOR: 'lint',
784
787
  SCHEMA_VERSION_ON_SUBFLOW: '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.109.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": "5b4742b27753c744b24c39aa70538961b642b18c"
126
+ "gitref": "b15c2763847c5eddc42573477d28692f00a28844"
127
127
  }