@uipath/maestro-builder-sdk 6.93.0 → 6.93.1

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.
@@ -905,6 +905,45 @@ export type TimerSpecData = {
905
905
  date?: never;
906
906
  cycle: string;
907
907
  };
908
+ /**
909
+ * A task's retry policy, saved as the task's `retry` (Case schema V29+). The
910
+ * platform lowers it onto the task's BPMN activity as `uipath:Retry` when the
911
+ * case turns on task error handling (`metadata.caseExecutionTaskErrorHandling`),
912
+ * and the runtime retries a faulted task by it. For example, retry once after a
913
+ * second on any error:
914
+ *
915
+ * .retry({ maxRetryCount: 1, retryBackoff: 'PT1S', retryAllErrors: true, retryBackoffType: 'Static' })
916
+ *
917
+ * The platform keeps but never runs a policy when:
918
+ * - the case does not turn on task error handling. The SDK cannot turn it on;
919
+ * only a plan saved with the Studio Web setting on carries it
920
+ * (`case check`: TASK_RETRY_OFF);
921
+ * - `retryAllErrors` is `false`: that retries only errors the task's error
922
+ * mapping marks retryable, and the SDK writes no error mapping
923
+ * (TASK_RETRY_INEFFECTIVE);
924
+ * - the task is a wait-for-timer or wait-for-connector task (TASK_RETRY_UNSUPPORTED).
925
+ *
926
+ * Decompile keeps such a policy when a saved plan holds one, so it survives the
927
+ * round trip, but do not author one.
928
+ */
929
+ export interface TaskRetryPolicy {
930
+ /** How many times to retry, after the first attempt. */
931
+ maxRetryCount?: number;
932
+ /** ISO 8601 duration between attempts (`PT1S`); the platform writes `PT1S` when absent. */
933
+ retryBackoff?: string;
934
+ /**
935
+ * Retry on every error. `false` retries only errors the task's error mapping
936
+ * marks retryable; the SDK writes no error mapping, so `false` never retries.
937
+ * Use `true`.
938
+ */
939
+ retryAllErrors: boolean;
940
+ /** How the backoff grows between attempts. */
941
+ retryBackoffType?: 'Static' | 'Linear' | 'Exponential';
942
+ /** ISO 8601 duration after which no more attempts start. */
943
+ maxDuration?: string;
944
+ /** The growth factor of an `Exponential` backoff. */
945
+ exponentialBase?: number;
946
+ }
908
947
  /** A task input binding: a resource input parameter set to a literal or a `=`-expression. */
909
948
  export interface TaskInputBinding {
910
949
  /** The resource's input parameter name. */
@@ -962,6 +1001,8 @@ export interface BuiltTask {
962
1001
  runOnce?: boolean;
963
1002
  description?: string;
964
1003
  skip?: string;
1004
+ /** The task's retry policy (`retry`). */
1005
+ retry?: TaskRetryPolicy;
965
1006
  /** Reference-mode task input bindings (`data.inputs[]`). */
966
1007
  inputs?: TaskInputBinding[];
967
1008
  /** Reference-mode task output extractions (`data.outputs[]` + a readable case-variable companion). */
@@ -1222,6 +1263,7 @@ declare class TaskBuilder {
1222
1263
  private _runOnce?;
1223
1264
  private _description?;
1224
1265
  private _skip?;
1266
+ private _retry?;
1225
1267
  private _inputs?;
1226
1268
  private _outputs?;
1227
1269
  private readonly _entry;
@@ -1584,6 +1626,20 @@ declare class TaskBuilder {
1584
1626
  * @returns This builder, so calls chain.
1585
1627
  */
1586
1628
  skipWhen(expression: string): this;
1629
+ /**
1630
+ * Retry this task when it faults. The platform runs the policy only when the
1631
+ * case turns on task error handling, a Studio Web case setting
1632
+ * (`metadata.caseExecutionTaskErrorHandling`) the SDK cannot turn on: a case
1633
+ * built from scratch keeps the policy and never runs it. It never runs
1634
+ * `retryAllErrors: false` (no error mapping) or a retry on a wait-for-timer or
1635
+ * wait-for-connector task either. `case check` warns on each of these
1636
+ * (TASK_RETRY_OFF, TASK_RETRY_INEFFECTIVE, TASK_RETRY_UNSUPPORTED). Decompile
1637
+ * writes `.retry()` for a plan Studio Web saved with a policy.
1638
+ *
1639
+ * @param policy - The retry policy, saved as the task's `retry`. See {@link TaskRetryPolicy}.
1640
+ * @returns This builder, so calls chain.
1641
+ */
1642
+ retry(policy: TaskRetryPolicy): this;
1587
1643
  /**
1588
1644
  * Bind resource **input** parameters (reference-mode tasks). Each key is a
1589
1645
  * declared input parameter name; each value is a literal, a case-variable read
@@ -275,6 +275,7 @@ class TaskBuilder {
275
275
  _runOnce;
276
276
  _description;
277
277
  _skip;
278
+ _retry;
278
279
  _inputs;
279
280
  _outputs;
280
281
  _entry = [];
@@ -690,6 +691,23 @@ class TaskBuilder {
690
691
  this._skip = expression;
691
692
  return this;
692
693
  }
694
+ /**
695
+ * Retry this task when it faults. The platform runs the policy only when the
696
+ * case turns on task error handling, a Studio Web case setting
697
+ * (`metadata.caseExecutionTaskErrorHandling`) the SDK cannot turn on: a case
698
+ * built from scratch keeps the policy and never runs it. It never runs
699
+ * `retryAllErrors: false` (no error mapping) or a retry on a wait-for-timer or
700
+ * wait-for-connector task either. `case check` warns on each of these
701
+ * (TASK_RETRY_OFF, TASK_RETRY_INEFFECTIVE, TASK_RETRY_UNSUPPORTED). Decompile
702
+ * writes `.retry()` for a plan Studio Web saved with a policy.
703
+ *
704
+ * @param policy - The retry policy, saved as the task's `retry`. See {@link TaskRetryPolicy}.
705
+ * @returns This builder, so calls chain.
706
+ */
707
+ retry(policy) {
708
+ this._retry = { ...policy };
709
+ return this;
710
+ }
693
711
  /**
694
712
  * Bind resource **input** parameters (reference-mode tasks). Each key is a
695
713
  * declared input parameter name; each value is a literal, a case-variable read
@@ -918,6 +936,7 @@ class TaskBuilder {
918
936
  runOnce: this._runOnce,
919
937
  description: this._description,
920
938
  skip: this._skip,
939
+ ...(this._retry ? { retry: this._retry } : {}),
921
940
  inputs: this._inputs,
922
941
  outputs: this._outputs,
923
942
  entry: this._entry,
@@ -245,11 +245,69 @@ export function check(built, opts = {}) {
245
245
  if (t.kind === 'http-request' && t.http)
246
246
  for (const f of httpRequestLint(`HTTP request task "${t.name}"`, t.http))
247
247
  diags.push({ level: 'error', code: f.code, message: f.message, ...(f.suggestion ? { suggestion: f.suggestion } : {}), where: t.name });
248
+ // A retry policy compile writes as authored but the platform never runs (lint).
249
+ checkTaskRetry(built, diags);
248
250
  checkRuleSemantics(built, diags);
249
251
  checkLibraryConnectors(built, opts, diags);
250
252
  diags.push(...serializerRefusals(built, opts, diags, reportedReads));
251
253
  return diags;
252
254
  }
255
+ /**
256
+ * Task types whose retry policy the platform drops (`caseTaskTypeSupportsErrorHandling`
257
+ * in `@uipath/case-schema`): a wait has no activity to retry.
258
+ */
259
+ const RETRY_UNSUPPORTED_KINDS = new Set(['wait-for-timer', 'wait-for-connector']);
260
+ /**
261
+ * A `.retry()` the platform keeps but never runs. Compile writes the policy as
262
+ * authored (a saved plan can hold any of these, and decompile keeps them), so
263
+ * each is a warning:
264
+ *
265
+ * - TASK_RETRY_UNSUPPORTED: on a wait-for-timer or wait-for-connector task,
266
+ * which the platform's converter gives no retry.
267
+ * - TASK_RETRY_INEFFECTIVE: `retryAllErrors: false` retries only errors the
268
+ * task's error mapping marks retryable, and the SDK writes no error mapping,
269
+ * so nothing is retried (`validate`'s CASE_MGMT_TASK_RETRY_INEFFECTIVE).
270
+ * - TASK_RETRY_OFF: the plan does not turn on task error handling
271
+ * (`metadata.caseExecutionTaskErrorHandling`), and the converter reads `retry`
272
+ * only when it is on. The SDK cannot turn it on; only a plan Studio Web saved
273
+ * with it carries it (the brownfield metadata carry).
274
+ */
275
+ function checkTaskRetry(built, diags) {
276
+ const handlingOn = caseJsonPreservation(built)?.metadata?.caseExecutionTaskErrorHandling === true;
277
+ for (const stage of built.stages)
278
+ for (const lane of stage.lanes)
279
+ for (const t of lane) {
280
+ if (!t.retry)
281
+ continue;
282
+ const who = `Task "${t.name}"`;
283
+ if (RETRY_UNSUPPORTED_KINDS.has(t.kind)) {
284
+ diags.push({
285
+ level: 'warning',
286
+ code: 'TASK_RETRY_UNSUPPORTED',
287
+ message: `${who} is a ${t.kind} task, which the platform never retries, so its .retry() policy is kept but not run.`,
288
+ suggestion: 'Remove the .retry() call, or move the retry to the task that does the work.',
289
+ where: t.name,
290
+ });
291
+ continue;
292
+ }
293
+ if (t.retry.retryAllErrors === false)
294
+ diags.push({
295
+ level: 'warning',
296
+ code: 'TASK_RETRY_INEFFECTIVE',
297
+ message: `${who} retries only errors its error mapping marks retryable (retryAllErrors: false), and it has no error mapping, so it is never retried.`,
298
+ suggestion: 'Set retryAllErrors: true to retry on any error.',
299
+ where: t.name,
300
+ });
301
+ if (!handlingOn)
302
+ diags.push({
303
+ level: 'warning',
304
+ code: 'TASK_RETRY_OFF',
305
+ message: `${who} has a .retry() policy, but this case does not turn on task error handling, so the platform keeps the policy and never runs it. The SDK cannot turn task error handling on yet (builder-sdk#1914).`,
306
+ suggestion: 'Turn on task error handling in the case settings in Studio Web, or remove the .retry() call.',
307
+ where: t.name,
308
+ });
309
+ }
310
+ }
253
311
  /**
254
312
  * Every refusal `compile` would raise for `built`: the serializer, run in
255
313
  * collect mode (docs/CHECK_COMPILE_CONTRACT_DESIGN.md §3.5, phase 8), so each
@@ -98,6 +98,7 @@ interface TaskNode {
98
98
  entryConditions?: Condition[];
99
99
  conditions?: unknown;
100
100
  nonSequentialRunConditions?: unknown;
101
+ retry?: unknown;
101
102
  [key: string]: unknown;
102
103
  }
103
104
  interface StageNode {
@@ -1487,6 +1487,38 @@ function ioArg(rows, kind, task, varKeyById) {
1487
1487
  });
1488
1488
  return `{ ${entries.join(', ')} }`;
1489
1489
  }
1490
+ /**
1491
+ * The fields of `CaseManagementJsonTaskRetrySchema` (case-schema V29+) and the
1492
+ * type each holds. `retryAllErrors` is the one the schema requires.
1493
+ */
1494
+ const RETRY_FIELDS = {
1495
+ maxRetryCount: 'number', retryBackoff: 'string', retryAllErrors: 'boolean',
1496
+ retryBackoffType: 'string', maxDuration: 'string', exponentialBase: 'number',
1497
+ };
1498
+ const RETRY_BACKOFF_TYPES = new Set(['Static', 'Linear', 'Exponential']);
1499
+ /**
1500
+ * A task's saved `retry`, as `.retry()` takes it. One the schema would reject
1501
+ * (a field it does not name, a value of another type, no `retryAllErrors`) is
1502
+ * refused: `.retry()` could not write it back as saved.
1503
+ */
1504
+ function retryPolicy(task) {
1505
+ const retry = task.retry;
1506
+ const who = `task "${task.displayName ?? task.id ?? '?'}"`;
1507
+ if (!retry || typeof retry !== 'object' || Array.isArray(retry))
1508
+ throw new Error(`${who} has a retry policy that is not an object.`);
1509
+ for (const [field, value] of Object.entries(retry)) {
1510
+ const type = ownEntry(RETRY_FIELDS, field);
1511
+ if (!type)
1512
+ throw new Error(`${who} retry policy has unsupported field "${field}".`);
1513
+ if (typeof value !== type || (type === 'number' && !Number.isFinite(value)))
1514
+ throw new Error(`${who} retry policy field "${field}" is not a ${type}.`);
1515
+ if (field === 'retryBackoffType' && !RETRY_BACKOFF_TYPES.has(value))
1516
+ throw new Error(`${who} retry policy has unsupported retryBackoffType ${JSON.stringify(value)}.`);
1517
+ }
1518
+ if (typeof retry.retryAllErrors !== 'boolean')
1519
+ throw new Error(`${who} retry policy has no retryAllErrors.`);
1520
+ return retry;
1521
+ }
1490
1522
  function emitTask(out, depth, task, lane, refs, library) {
1491
1523
  out.line(depth, `.task(${tsLiteral(taskSourceName(task))}, t => t`);
1492
1524
  const inner = depth + 1;
@@ -1509,6 +1541,8 @@ function emitTask(out, depth, task, lane, refs, library) {
1509
1541
  out.line(inner, `.description(${tsLiteral(task.description)})`);
1510
1542
  if (task.skipCondition)
1511
1543
  out.line(inner, `.skipWhen(${tsLiteral(task.skipCondition)})`);
1544
+ if (task.retry !== undefined)
1545
+ out.line(inner, `.retry(${tsLiteral(retryPolicy(task))})`);
1512
1546
  for (const condition of task.entryConditions ?? [])
1513
1547
  emitEntryWhen(out, inner, condition, refs, false);
1514
1548
  out.line(depth, lane > 0 ? `, ${opts([['lane', String(lane)]])})` : ')');
@@ -2631,7 +2665,7 @@ export function collectPreservation(plan) {
2631
2665
  preservation.omitTriggerLabels = unlabeled;
2632
2666
  const taskKnown = new Set([
2633
2667
  'id', 'displayName', 'type', 'data', 'shouldRunOnlyOnce', 'isRequired', 'skipCondition', 'description',
2634
- 'entryConditions', 'conditions', 'nonSequentialRunConditions',
2668
+ 'entryConditions', 'conditions', 'nonSequentialRunConditions', 'retry',
2635
2669
  ]);
2636
2670
  const taskFields = [];
2637
2671
  const connectorConfigurations = [];
@@ -178,7 +178,7 @@ const VARIABLE_KEYS = new Set([
178
178
  ]);
179
179
  const TASK_KEYS = new Set([
180
180
  'id', 'displayName', 'type', 'data', 'shouldRunOnlyOnce', 'isRequired', 'skipCondition', 'description',
181
- 'entryConditions', 'conditions', 'nonSequentialRunConditions',
181
+ 'entryConditions', 'conditions', 'nonSequentialRunConditions', 'retry',
182
182
  ]);
183
183
  const TRIGGER_DATA_KEYS = new Set(['label', 'description', 'uipath', 'display', 'inputs', 'typeVersion']);
184
184
  const PRESERVED_TASK_KEYS = new Set(['elementId']);
@@ -2207,6 +2207,9 @@ function emitTaskNode(task, stageLabel, stageId, taskId, type, ids, resolver) {
2207
2207
  if (task.entry.length) {
2208
2208
  node.entryConditions = task.entry.map((c, i) => emitTaskEntry(c, `${stageLabel}/${task.name}:entry:${i}`, stageId, task.name, ids, resolver));
2209
2209
  }
2210
+ // Last, where Studio Web writes it.
2211
+ if (task.retry)
2212
+ node.retry = { ...task.retry };
2210
2213
  return node;
2211
2214
  }
2212
2215
  function taskData(task, resolver, taskId, stageId, ids) {
@@ -733,6 +733,9 @@ export declare const REFUSALS: {
733
733
  readonly TASK_OUTPUT_REF_UNRESOLVED: "lowering";
734
734
  readonly TASK_OUTPUT_SOURCE_AND_ASSIGN: "lowering";
735
735
  readonly TASK_REENTRY_IGNORED: "lint";
736
+ readonly TASK_RETRY_INEFFECTIVE: "lint";
737
+ readonly TASK_RETRY_OFF: "lint";
738
+ readonly TASK_RETRY_UNSUPPORTED: "lint";
736
739
  readonly TASK_TIMER_OUT_OF_RANGE: "lint";
737
740
  readonly TEMPLATED_EXITS_ONLY: "lowering";
738
741
  readonly TERMINATE_HAS_NO_OUTPUT: "lint";
@@ -807,6 +807,9 @@ export const REFUSALS = {
807
807
  TASK_OUTPUT_REF_UNRESOLVED: 'lowering',
808
808
  TASK_OUTPUT_SOURCE_AND_ASSIGN: 'lowering',
809
809
  TASK_REENTRY_IGNORED: 'lint',
810
+ TASK_RETRY_INEFFECTIVE: 'lint',
811
+ TASK_RETRY_OFF: 'lint',
812
+ TASK_RETRY_UNSUPPORTED: 'lint',
810
813
  TASK_TIMER_OUT_OF_RANGE: 'lint',
811
814
  TEMPLATED_EXITS_ONLY: 'lowering',
812
815
  TERMINATE_HAS_NO_OUTPUT: 'lint',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.93.0",
3
+ "version": "6.93.1",
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",
@@ -111,5 +111,5 @@
111
111
  "@types/node": "^22.7.0",
112
112
  "esbuild": "^0.28.1"
113
113
  },
114
- "gitref": "cffee7a830032c8012375a0275d77fa683350d38"
114
+ "gitref": "f4ab3ce258d87a754bc38d9f4e07af1498216211"
115
115
  }