@uipath/maestro-builder-sdk 6.90.0 → 6.90.2

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/decompile.js CHANGED
@@ -2942,7 +2942,7 @@ function canonicalJson(v) {
2942
2942
  /**
2943
2943
  * The wire fields whose plain-string value is JavaScript (no `=js:` prefix):
2944
2944
  * a script body, a decision or switch `expression`, a loop's `condition` and
2945
- * `completionCondition`, an HTTP branch's `conditionExpression`, a transform's
2945
+ * `completionCondition`, a `conditionExpression` an older compile wrote bare, a transform's
2946
2946
  * `collection`. `serialize` renames `$vars` reads in exactly these and in
2947
2947
  * `=js:` values. A loop's `completionCondition` is listed for files written
2948
2948
  * before #1763: the SDK now writes it as a jsExpression envelope, because the
package/dist/merge.js CHANGED
@@ -193,6 +193,26 @@ function inOriginalSpelling(o, b, e) {
193
193
  }
194
194
  return isRecord(o) && o.type === 'jsExpression' && o.expression === b ? { ...jsonClone(o), expression: e } : undefined;
195
195
  }
196
+ const JS_WIRE_PREFIX = '=js:';
197
+ /**
198
+ * An HTTP branch row an older SDK wrote without `=js:` never fires. The baseline is the
199
+ * current compile of the same source, so where it spells the row `=js:<bare>` the merged
200
+ * row takes the baseline's spelling.
201
+ */
202
+ function repairBareBranches(node, base) {
203
+ const rows = node.inputs?.branches;
204
+ const baseRows = base?.inputs?.branches;
205
+ if (!Array.isArray(rows) || !Array.isArray(baseRows))
206
+ return;
207
+ for (const row of rows) {
208
+ if (!isRecord(row) || typeof row.conditionExpression !== 'string')
209
+ continue;
210
+ const same = baseRows.find((b) => isRecord(b) && b.id === row.id);
211
+ if (!isRecord(same) || same.conditionExpression !== JS_WIRE_PREFIX + row.conditionExpression)
212
+ continue;
213
+ row.conditionExpression = same.conditionExpression;
214
+ }
215
+ }
196
216
  /** What `after` changed from `before`, key by key; `undefined` when nothing. */
197
217
  function changedFrom(before, after) {
198
218
  if (stableJson(after) === stableJson(before))
@@ -362,6 +382,8 @@ function mergeFlowFindings(original, edited, options) {
362
382
  }
363
383
  }
364
384
  result.nodes = finalNodes;
385
+ for (const node of finalNodes)
386
+ repairBareBranches(node, baseNodes.get(node.id));
365
387
  // Nodes present in the original but absent from `edited` were deleted by the
366
388
  // user; they are simply not carried over.
367
389
  // ── Subflows: the edited flow is authoritative (the user's graph) — except a
@@ -372,8 +394,12 @@ function mergeFlowFindings(original, edited, options) {
372
394
  result.subflows = jsonClone(edited.subflows ?? {});
373
395
  const takenSubflows = new Set(subflowsTakenFromEdited(original, edited, options.baseline));
374
396
  for (const key of Object.keys(result.subflows)) {
375
- if (!takenSubflows.has(key))
376
- result.subflows[key] = jsonClone(original.subflows[key]);
397
+ if (takenSubflows.has(key))
398
+ continue;
399
+ result.subflows[key] = jsonClone(original.subflows[key]);
400
+ const baseNodes = byId(options.baseline?.subflows?.[key]?.nodes);
401
+ for (const node of result.subflows[key].nodes ?? [])
402
+ repairBareBranches(node, baseNodes.get(node.id));
377
403
  }
378
404
  // A kept subflow carries the original's edge ids and a taken one the
379
405
  // recompile's, from two different counters, so a taken subflow's edges are
@@ -25,7 +25,8 @@ export declare function checkHttpStep(inputs: HttpInputs, ctx: FlowCheckContext)
25
25
  /**
26
26
  * A read of an `http()` step's result.
27
27
  *
28
- * The response is an envelope — `{ body, statusCode, headers }` — and `returns`
28
+ * The response is an envelope — `{ body, statusCode, headers }`, or `{ body, code, headers }`
29
+ * on the managed node — and `returns`
29
30
  * declares the parsed JSON body's top-level fields, so a declared field is read
30
31
  * at `output.body.<field>` (`out('<step>', 'body.<field>')`). That nesting is the
31
32
  * one thing this family does not share with the process families, and it is
@@ -132,7 +132,7 @@ export function checkHttpStep(inputs, ctx) {
132
132
  }
133
133
  seen.add(b.name);
134
134
  if (b.condition.literal) {
135
- ctx.report('HTTP_BRANCH_CONST', `HTTP branch ${JSON.stringify(b.name)} on "${step}" tests a constant — it would fire always or never. Reference the response, e.g. $vars.${step}.output.statusCode.`);
135
+ ctx.report('HTTP_BRANCH_CONST', `HTTP branch ${JSON.stringify(b.name)} on "${step}" tests a constant — it would fire always or never. Reference the response, e.g. $vars.${step}.output.${inputs?.managed ? 'code' : 'statusCode'}.`);
136
136
  }
137
137
  }
138
138
  }
@@ -142,10 +142,13 @@ export function checkHttpStep(inputs, ctx) {
142
142
  * `returns` describes what is INSIDE `body`, never beside it.
143
143
  */
144
144
  const HTTP_ENVELOPE_FIELDS = ['body', 'statusCode', 'headers'];
145
+ /** The managed node's response is Integration Service's `{ code, headers, body }`. */
146
+ const MANAGED_HTTP_ENVELOPE_FIELDS = ['body', 'code', 'headers'];
145
147
  /**
146
148
  * A read of an `http()` step's result.
147
149
  *
148
- * The response is an envelope — `{ body, statusCode, headers }` — and `returns`
150
+ * The response is an envelope — `{ body, statusCode, headers }`, or `{ body, code, headers }`
151
+ * on the managed node — and `returns`
149
152
  * declares the parsed JSON body's top-level fields, so a declared field is read
150
153
  * at `output.body.<field>` (`out('<step>', 'body.<field>')`). That nesting is the
151
154
  * one thing this family does not share with the process families, and it is
@@ -168,19 +171,25 @@ export function checkHttpRead({ node: name, field, rest, reader: step }, spec, r
168
171
  if (!top)
169
172
  return; // `$vars.<name>.output` — the whole envelope.
170
173
  const declared = Object.keys(spec?.returns ?? {});
171
- if (!HTTP_ENVELOPE_FIELDS.includes(top)) {
174
+ const envelope = spec?.managed ? MANAGED_HTTP_ENVELOPE_FIELDS : HTTP_ENVELOPE_FIELDS;
175
+ if (!envelope.includes(top)) {
172
176
  // The commonest form: a declared body field read one level too high.
173
177
  const hoisted = declared.includes(top) ? top : undefined;
178
+ if (spec?.managed && top === 'statusCode') {
179
+ report('HTTP_READ_UNKNOWN_FIELD', `"$vars.${name}.output.statusCode" (read in "${step}") is not a field of managed HTTP step "${name}"'s `
180
+ + `response, which publishes "code", "headers", "body". It resolves to undefined at run time, so a branch on it never fires.`, `$vars.${name}.output.code`);
181
+ return;
182
+ }
174
183
  const nearest = hoisted ?? nearestName(top, declared);
175
184
  report('HTTP_READ_UNKNOWN_FIELD', `"$vars.${name}.output.${top}" (read in "${step}") is not a field of HTTP step "${name}"'s `
176
- + `response. An HTTP response publishes ${HTTP_ENVELOPE_FIELDS.map((f) => `"${f}"`).join(', ')}; `
185
+ + `response. An HTTP response publishes ${envelope.map((f) => `"${f}"`).join(', ')}; `
177
186
  + `the fields \`returns\` declares live under "body"`
178
187
  + (hoisted ? `, so "${top}" is read as "$vars.${name}.output.body.${top}".` : '.')
179
188
  + ` A read outside that shape resolves to undefined and faults a gateway at run time.`, nearest !== undefined ? `out('${name}', 'body.${nearest}')` : undefined);
180
189
  return;
181
190
  }
182
191
  if (top !== 'body' || !inner)
183
- return; // `statusCode`, `headers`, or the whole body.
192
+ return; // the status, `headers`, or the whole body.
184
193
  if (declared.length === 0) {
185
194
  report('HTTP_READ_WITHOUT_RETURNS', `"$vars.${name}.output.body.${inner}" (read in "${step}") reads a field of HTTP step "${name}"'s `
186
195
  + `response body, but the step declares no \`returns\` — so the node carries no body schema and nothing `
@@ -51,7 +51,7 @@ function httpRequestSettings(i) {
51
51
  ...(i.retryCount !== undefined ? { retryCount: i.retryCount } : {}),
52
52
  };
53
53
  }
54
- /** The `branches` rows both HTTP definitions declare: id/name from the author's name, conditions rendered like a decision's. */
54
+ /** The `branches` rows both HTTP definitions declare: id/name from the author's name, conditions written as `=js:` values: the gateway's flow reads no other spelling. */
55
55
  function httpBranchRows(i, ctx) {
56
56
  if (!i.branches?.length)
57
57
  return {};
@@ -59,7 +59,7 @@ function httpBranchRows(i, ctx) {
59
59
  branches: i.branches.map((b) => ({
60
60
  id: b.name,
61
61
  name: b.name,
62
- conditionExpression: ctx.renameRefs(b.condition.js),
62
+ conditionExpression: `=js:${ctx.renameRefs(b.condition.js)}`,
63
63
  })),
64
64
  };
65
65
  }
@@ -189,7 +189,7 @@ function httpOutputs(base, returns, managed) {
189
189
  // The whole `output` shape lives on the INSTANCE, not in the bundled
190
190
  // definition — deliberately. An instance schema may refine a GENERIC definition
191
191
  // object but never override one that already declares a
192
- // shape, so declaring `body`/`statusCode` in the def would lock the author's
192
+ // shape, so declaring `body` and the status in the def would lock the author's
193
193
  // `returns` out of the very read it exists to license. The definition stays
194
194
  // byte-faithful to the platform's (a bare object, because only the API being
195
195
  // called knows its body) and the author's declaration is the only source of
@@ -202,7 +202,9 @@ function httpOutputs(base, returns, managed) {
202
202
  : 'JSON response body, deserialized by the standalone HTTP runtime',
203
203
  properties: Object.fromEntries(Object.entries(returns).map(([name, type]) => [name, { type }])),
204
204
  },
205
- statusCode: { type: 'number', description: 'HTTP status code of the response' },
205
+ ...(managed
206
+ ? { code: { type: 'integer', description: 'HTTP status code' } }
207
+ : { statusCode: { type: 'number', description: 'HTTP status code of the response' } }),
206
208
  };
207
209
  return out;
208
210
  }
@@ -16,7 +16,7 @@ export interface HttpBranch {
16
16
  name: string;
17
17
  /**
18
18
  * When to take this exit, evaluated against the response — e.g.
19
- * js-tagged: `$vars.fetch.output.statusCode === 429`. Branches are checked in
19
+ * js-tagged: `$vars.fetch.output.statusCode === 429` (`output.code` on the managed node). Branches are checked in
20
20
  * order; the first truthy one wins, else the default port fires.
21
21
  */
22
22
  condition: Expr;
@@ -84,7 +84,7 @@ interface HttpInputsBase {
84
84
  * `$vars.fetch.output.items` is undefined at run time.
85
85
  *
86
86
  * @enforcedBy HTTP_READ_UNKNOWN_FIELD A read must be `output.body.<declared field>`,
87
- * `output.statusCode` or `output.headers`.
87
+ * `output.statusCode` (`output.code` on the managed node) or `output.headers`.
88
88
  * @enforcedBy HTTP_READ_WITHOUT_RETURNS Reading a body field requires declaring it here.
89
89
  */
90
90
  returns?: Record<string, ReturnFieldType>;
@@ -36,6 +36,8 @@ export interface LookupExhaustedFacts {
36
36
  pages: number;
37
37
  /** True when a cap, not the collection's end, stopped the scan. */
38
38
  capped: boolean;
39
+ /** True when the service reported more records (`HasMore`) but returned no `NextPageToken`. */
40
+ truncated?: boolean;
39
41
  /**
40
42
  * Every distinct value the scan saw at `by`, when the whole collection was
41
43
  * read and holds at most {@link CANDIDATE_LIMIT} records — what to pick from.
@@ -77,6 +79,7 @@ export declare class LookupExhausted extends ResolutionRefusal {
77
79
  readonly scanned: number;
78
80
  readonly pages: number;
79
81
  readonly capped: boolean;
82
+ readonly truncated: boolean;
80
83
  readonly candidates?: readonly string[];
81
84
  readonly near?: string;
82
85
  constructor(message: string, facts: LookupExhaustedFacts);
@@ -207,6 +210,8 @@ export interface ScanOutcome {
207
210
  pages: number;
208
211
  /** True when a cap, not the collection's end, stopped the scan. */
209
212
  capped: boolean;
213
+ /** True when `HasMore` was true but no `NextPageToken` came back, so the scan could not continue. */
214
+ truncated: boolean;
210
215
  }
211
216
  /**
212
217
  * Page through a collection, yielding each page's records and returning where
@@ -216,6 +221,8 @@ export interface ScanOutcome {
216
221
  * / `pageToken` / `nextPageToken` is a documented way to loop forever on page
217
222
  * one. Stops when the reply says there is no more, when it carries no token,
218
223
  * at {@link MAX_SCANNED} records, or after {@link PAGE_GUARD} transitions.
224
+ * A reply with `HasMore` true and no token is a truncated scan, not the end:
225
+ * it stops without looping and says so in {@link ScanOutcome.truncated}.
219
226
  */
220
227
  export declare function scanCollection(client: UipClient, connectorKey: string, collection: string, connectionId: string, query: string | undefined): AsyncGenerator<unknown[], ScanOutcome, void>;
221
228
  /**
@@ -84,6 +84,7 @@ export class LookupExhausted extends ResolutionRefusal {
84
84
  scanned;
85
85
  pages;
86
86
  capped;
87
+ truncated;
87
88
  candidates;
88
89
  near;
89
90
  constructor(message, facts) {
@@ -96,6 +97,7 @@ export class LookupExhausted extends ResolutionRefusal {
96
97
  this.scanned = facts.scanned;
97
98
  this.pages = facts.pages;
98
99
  this.capped = facts.capped;
100
+ this.truncated = facts.truncated === true;
99
101
  if (facts.candidates !== undefined)
100
102
  this.candidates = facts.candidates;
101
103
  if (facts.near !== undefined)
@@ -408,6 +410,10 @@ export function substitute(template, resolved) {
408
410
  export function matchRecord(record, by, value) {
409
411
  return pyStrAny(readPath(record, by)) === value;
410
412
  }
413
+ /** What a scan stopped by {@link ScanOutcome.truncated} says in place of "collection exhausted". */
414
+ function truncatedNote(collection, scanned) {
415
+ return `; TRUNCATED: the service reported more records in ${pyRepr(collection)} but returned no NextPageToken after ${scanned} record(s), so the value may be further in`;
416
+ }
411
417
  /**
412
418
  * Page through a collection, yielding each page's records and returning where
413
419
  * the scan stopped.
@@ -416,10 +422,13 @@ export function matchRecord(record, by, value) {
416
422
  * / `pageToken` / `nextPageToken` is a documented way to loop forever on page
417
423
  * one. Stops when the reply says there is no more, when it carries no token,
418
424
  * at {@link MAX_SCANNED} records, or after {@link PAGE_GUARD} transitions.
425
+ * A reply with `HasMore` true and no token is a truncated scan, not the end:
426
+ * it stops without looping and says so in {@link ScanOutcome.truncated}.
419
427
  */
420
428
  export async function* scanCollection(client, connectorKey, collection, connectionId, query) {
421
429
  let scanned = 0;
422
430
  let pages = 0;
431
+ let truncated = false;
423
432
  for (;;) {
424
433
  const payload = await listPage(client, connectorKey, collection, connectionId, query);
425
434
  const items = envelopeItems(payload);
@@ -427,7 +436,13 @@ export async function* scanCollection(client, connectorKey, collection, connecti
427
436
  yield items;
428
437
  const pagination = envelopePagination(payload);
429
438
  const token = pagination.NextPageToken;
430
- if (!truthy(pagination.HasMore) || !pyTruthy(token) || scanned >= MAX_SCANNED)
439
+ if (!truthy(pagination.HasMore))
440
+ break;
441
+ if (!pyTruthy(token)) {
442
+ truncated = scanned < MAX_SCANNED;
443
+ break;
444
+ }
445
+ if (scanned >= MAX_SCANNED)
431
446
  break;
432
447
  pages += 1;
433
448
  if (pages > PAGE_GUARD)
@@ -436,7 +451,7 @@ export async function* scanCollection(client, connectorKey, collection, connecti
436
451
  // is a documented way to loop forever on page one.
437
452
  query = query ? `${query}&nextPage=${pyStrAny(token)}` : `nextPage=${pyStrAny(token)}`;
438
453
  }
439
- return { scanned, pages, capped: scanned >= MAX_SCANNED || pages > PAGE_GUARD };
454
+ return { scanned, pages, capped: truncated || scanned >= MAX_SCANNED || pages > PAGE_GUARD, truncated };
440
455
  }
441
456
  /**
442
457
  * The connector-facing id for one lookup, or throw {@link ResolutionRefusal}.
@@ -513,7 +528,7 @@ export async function resolveOne(client, connectorKey, spec, field, by, value, c
513
528
  }
514
529
  step = await scan.next();
515
530
  }
516
- const { scanned, pages, capped } = step.value;
531
+ const { scanned, pages, capped, truncated } = step.value;
517
532
  // No exact match anywhere in the collection: try the case-only ones. Exact
518
533
  // first, because an id picked by a looser rule while the exact record sat
519
534
  // on a later page would be the wrong id. Only once the scan has read to the
@@ -562,13 +577,17 @@ export async function resolveOne(client, connectorKey, spec, field, by, value, c
562
577
  const candidates = !capped && !pyTruthy(filterPattern) && scanned <= CANDIDATE_LIMIT && held.length > 0 ? held : undefined;
563
578
  throw new LookupExhausted(`${field}: no record in ${pyRepr(collection)} has ${by}=${pyRepr(value)} ` +
564
579
  `(scanned ${scanned} record(s) across ${pages + 1} page(s)` +
565
- (capped ? `; STOPPED AT THE ${MAX_SCANNED}-record cap, so the value may be further in` : "; collection exhausted") +
580
+ (truncated
581
+ ? truncatedNote(collection, scanned)
582
+ : capped
583
+ ? `; STOPPED AT THE ${MAX_SCANNED}-record cap, so the value may be further in`
584
+ : "; collection exhausted") +
566
585
  `) on connection ${connectionId}.` +
567
586
  (near !== undefined
568
587
  ? ` Did you mean ${pyRepr(near)}? It differs only in case and was not taken: the scan stopped before the end, where an exact match may still be.`
569
588
  : "") +
570
589
  (candidates !== undefined ? ` It holds: ${candidates.map(pyRepr).join(", ")}.` : ""), {
571
- field, collection, by, value, scanned, pages: pages + 1, capped,
590
+ field, collection, by, value, scanned, pages: pages + 1, capped, truncated,
572
591
  ...(candidates !== undefined ? { candidates } : {}),
573
592
  ...(near !== undefined ? { near } : {}),
574
593
  });
@@ -689,10 +708,14 @@ async function resolveInTree(client, connectorKey, spec, field, by, value, conne
689
708
  if (hit === undefined) {
690
709
  const held = level.records.map((record) => pyStrAny(readPath(record, by))).filter((text) => text !== "None");
691
710
  const shown = !level.outcome.capped && held.length > 0 && held.length <= CANDIDATE_LIMIT ? ` It holds: ${held.map(pyRepr).join(", ")}.` : "";
692
- const facts = { field, collection: where, by, value, scanned, pages, capped: level.outcome.capped };
711
+ const facts = { field, collection: where, by, value, scanned, pages, capped: level.outcome.capped, truncated: level.outcome.truncated };
693
712
  throw new LookupExhausted(`${field}: path ${pyRepr(value)} stops at segment ${i + 1}, ${pyRepr(segment)}: no record in ${pyRepr(where)} ` +
694
713
  `has ${by}=${pyRepr(segment)} (walked ${listings} listing(s), ${scanned} record(s)` +
695
- (level.outcome.capped ? `; STOPPED AT THE ${MAX_SCANNED}-record cap` : "; that listing exhausted") +
714
+ (level.outcome.truncated
715
+ ? truncatedNote(where, level.outcome.scanned)
716
+ : level.outcome.capped
717
+ ? `; STOPPED AT THE ${MAX_SCANNED}-record cap`
718
+ : "; that listing exhausted") +
696
719
  `) on connection ${connectionId}.${shown}`, facts);
697
720
  }
698
721
  if (i === segments.length - 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.90.0",
3
+ "version": "6.90.2",
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",
@@ -110,5 +110,5 @@
110
110
  "@types/node": "^22.7.0",
111
111
  "esbuild": "^0.28.1"
112
112
  },
113
- "gitref": "2d54d6aa56285f53167cff2277bcf3e4bd73751b"
113
+ "gitref": "fa145822a2c32fdc05f6c41bddf9d9dc4c0163db"
114
114
  }