@uipath/maestro-builder-sdk 6.124.19 → 6.125.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.
@@ -518,12 +518,16 @@ export interface CaseJsonPreservation {
518
518
  omitInputDefaults?: string[];
519
519
  /**
520
520
  * Metadata keys the serializer always writes that the source document did not
521
- * carry (only `caseAppEnabled`, `caseIdentifierType`, `publishVersion`,
522
- * `intsvcActivityConfig`).
523
- * Compile drops such a key while it still holds what the platform reads for
524
- * an absent one: the Case Designer's in-memory to canvas converter fills
521
+ * carry (`caseAppEnabled`, `caseIdentifierType`, `publishVersion`,
522
+ * `intsvcActivityConfig`), and the two task-exit flags of a document that has
523
+ * a `task-exited` rule without them. Compile drops such a key while it still
524
+ * holds what the platform reads for an absent one: the Case Designer's
525
+ * in-memory to canvas converter fills
525
526
  * `caseAppEnabled ?? true` and `caseIdentifierType ?? "constant"`, and
526
527
  * `publishVersion` is not authorable. A value the author changed is kept.
528
+ * The platform reads an absent task-exit flag as off, so the serializer does
529
+ * not imply a flag recorded here (`taskExitFlags`): the rule stays ignored
530
+ * until the source calls `.exitOnTaskFailure()` / `.taskExitRules()`.
527
531
  */
528
532
  omitMetadata?: PreservedMetadataKey[];
529
533
  /**
@@ -807,7 +811,7 @@ export declare function caseJsonPreservation(built: BuiltCase): CaseJsonPreserva
807
811
  export declare function preservedBindings(bindings: Bindings | undefined, payload: CaseJsonPreservation | undefined): Bindings | undefined;
808
812
  export declare function preservedBindings(bindings: BindingsView | undefined, payload: CaseJsonPreservation | undefined): BindingsView | undefined;
809
813
  /** A metadata key whose absence {@link CaseJsonPreservation.omitMetadata} records. */
810
- export type PreservedMetadataKey = 'caseAppEnabled' | 'caseIdentifierType' | 'publishVersion' | 'intsvcActivityConfig';
814
+ export type PreservedMetadataKey = 'caseAppEnabled' | 'caseIdentifierType' | 'publishVersion' | 'intsvcActivityConfig' | 'caseExecutionExitsOnTaskFailure' | 'caseExecutionUsesTaskExitRules';
811
815
  /**
812
816
  * @internal
813
817
  * What the platform reads for each {@link PreservedMetadataKey} the document
@@ -213,6 +213,8 @@ export const METADATA_ABSENT_READING = {
213
213
  // writes "v2" on a new case (intsvc-activity-config.ts): a plan saved with
214
214
  // none keeps none.
215
215
  intsvcActivityConfig: undefined,
216
+ caseExecutionExitsOnTaskFailure: false,
217
+ caseExecutionUsesTaskExitRules: false,
216
218
  };
217
219
  const TOP_LEVEL_KEYS = new Set([
218
220
  'id', 'name', 'description', 'version', 'bindings', 'variables', 'metadata', 'nodes', 'edges', 'layout',
@@ -221,6 +223,7 @@ const METADATA_KEYS = new Set([
221
223
  'caseIdentifier', 'caseIdentifierType', 'caseAppEnabled', 'publishVersion', 'caseExitRules', 'slaRules',
222
224
  'caseAppConfig', 'adhocCaseEndData',
223
225
  'allowAdhocOptionalStageTasks', 'waitForHumanSelectNextStageDFConnector', 'businessEvents',
226
+ 'caseExecutionExitsOnTaskFailure', 'caseExecutionUsesTaskExitRules',
224
227
  ]);
225
228
  const VARIABLE_KEYS = new Set([
226
229
  'id', 'name', 'type', 'default', 'body', '_jsonSchema', 'elementId', 'var',
@@ -22,6 +22,7 @@ const RULE_OPTIONS = {
22
22
  'wait-for-connector': ['connector'],
23
23
  'sla-status-change': ['sla', 'escalation'],
24
24
  'api-event': ['businessEvent'],
25
+ 'task-exited': ['tasks', 'exitReasons', 'errorCategories'],
25
26
  };
26
27
  /**
27
28
  * Report an unknown rule kind, or each option the rule's kind does not read.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Every rule of a built case with the condition slot it sits in, in document
3
+ * order: each stage's entry conditions, exit conditions and its tasks' entry
4
+ * conditions, then the case exits. One traversal for the rules that need the
5
+ * slot (`check-task-exit.ts`) and for the serializer's flag resolution
6
+ * (`task-exit.ts`), so the two cannot disagree on what a case contains.
7
+ */
8
+ import type { BuiltCase, BuiltExitCondition, BuiltStage, BuiltTask, CaseRule } from './case-sdk.js';
9
+ export type RuleSlot = 'stage-entry' | 'stage-exit' | 'task-entry' | 'case-exit';
10
+ export interface RuleSite {
11
+ rule: CaseRule;
12
+ slot: RuleSlot;
13
+ /** Where `check` says it is: `stage "S" entry`, `stage "S" exit`, `task "T" entry` or `case-exit`. */
14
+ where: string;
15
+ stage?: BuiltStage;
16
+ /** The task whose entry holds the rule. */
17
+ task?: BuiltTask;
18
+ /** For a stage exit, the condition, whose `marksStageComplete` and `type` decide what the platform compiles there. */
19
+ exit?: BuiltExitCondition;
20
+ }
21
+ /** Every rule of `built`, with its slot. */
22
+ export declare function ruleSites(built: BuiltCase): Generator<RuleSite>;
@@ -0,0 +1,19 @@
1
+ /** Every rule of `built`, with its slot. */
2
+ export function* ruleSites(built) {
3
+ for (const stage of built.stages) {
4
+ const at = `stage "${stage.label}"`;
5
+ for (const c of stage.entry)
6
+ for (const rule of c.rules.flat())
7
+ yield { rule, slot: 'stage-entry', where: `${at} entry`, stage };
8
+ for (const c of stage.exit)
9
+ for (const rule of c.rules.flat())
10
+ yield { rule, slot: 'stage-exit', where: `${at} exit`, stage, exit: c };
11
+ for (const task of stage.lanes.flat())
12
+ for (const c of task.entry)
13
+ for (const rule of c.rules.flat())
14
+ yield { rule, slot: 'task-entry', where: `task "${task.name}" entry`, stage, task };
15
+ }
16
+ for (const c of built.caseExit)
17
+ for (const rule of c.rules.flat())
18
+ yield { rule, slot: 'case-exit', where: 'case-exit' };
19
+ }
@@ -33,6 +33,8 @@ import { ownEntry } from '../core/own-entry.js';
33
33
  import { stableId } from '../core/stable-id.js';
34
34
  import { resolveSchemaVersion } from '../schema-version.js';
35
35
  import { CASE_NODE_LAYOUT_FIELDS, caseJsonPreservation, caseJsonPreservationErrors, filterLeafKey, preservedBindings, preservedLeafKey, } from './preserve.js';
36
+ import { TASK_ERROR_CATEGORIES, TASK_EXIT_REASONS } from './case-sdk.js';
37
+ import { taskExitFlags } from './task-exit.js';
36
38
  import { businessEventProblems } from './business-event-shape.js';
37
39
  import { eventFiltersNotArray, readEventFilter, readEventFilterLeaf, eventFilterTreeLeaf } from '../core/event-filters.js';
38
40
  import { responseJsonSchema } from '../core/connector-response-schema.js';
@@ -332,6 +334,12 @@ function serializeCase(built, opts) {
332
334
  if (built.allowAdhocOptionalStageTasks !== undefined) {
333
335
  metadata.allowAdhocOptionalStageTasks = built.allowAdhocOptionalStageTasks;
334
336
  }
337
+ // A `task-exited` rule turns both flags on unless the author set one (task-exit.ts).
338
+ const taskExit = taskExitFlags(built);
339
+ if (taskExit.exitOnTaskFailure !== undefined)
340
+ metadata.caseExecutionExitsOnTaskFailure = taskExit.exitOnTaskFailure;
341
+ if (taskExit.taskExitRules !== undefined)
342
+ metadata.caseExecutionUsesTaskExitRules = taskExit.taskExitRules;
335
343
  const selectNextStage = built.stages.flatMap((stage) => stage.exit)
336
344
  .filter((exit) => exit.selectNextStage !== undefined);
337
345
  if (selectNextStage.length > 1)
@@ -4400,14 +4408,30 @@ function emitRule(r, seed, ownerId, ids, resolver, site) {
4400
4408
  // No `tasks` writes no `selectedTasksIds`, as Studio Web saves a rule gated
4401
4409
  // by its expression alone; the platform reads an absent list as an empty one
4402
4410
  // (its converter takes `selectedTasksIds ?? []`). `tasks: []` writes `[]`.
4403
- if (r.rule === 'selected-tasks-completed' && r.tasks !== undefined) {
4411
+ if ((r.rule === 'selected-tasks-completed' || r.rule === 'task-exited') && r.tasks !== undefined) {
4404
4412
  out.selectedTasksIds = r.tasks.map((n) => {
4405
4413
  const tid = resolver.taskIdByKey.get(n);
4406
4414
  if (!tid)
4407
- throw new CompileRefusal('UNKNOWN_TASK_REF', `rule "selected-tasks-completed" references unknown task "${n}".`);
4415
+ throw new CompileRefusal('UNKNOWN_TASK_REF', `rule "${r.rule}" references unknown task "${n}".`);
4408
4416
  return tid;
4409
4417
  });
4410
4418
  }
4419
+ if (r.rule === 'task-exited') {
4420
+ // Both filters are closed enums in the schema; a value outside them fails
4421
+ // `validate` as an invalid enum value, so refuse it with the vocabulary.
4422
+ const closed = (values, allowed, field, code) => {
4423
+ const unknown = (values ?? []).find((value) => !allowed.includes(value));
4424
+ if (unknown !== undefined)
4425
+ throw new CompileRefusal(code, `rule "task-exited" in ${site} has ${field} ${JSON.stringify(unknown)}; the ${field} are ${allowed.map((v) => `'${v}'`).join(', ')}.`);
4426
+ };
4427
+ closed(r.exitReasons, TASK_EXIT_REASONS, 'exitReasons', 'TASK_EXITED_REASON_UNKNOWN');
4428
+ closed(r.errorCategories, TASK_ERROR_CATEGORIES, 'errorCategories', 'TASK_EXITED_CATEGORY_UNKNOWN');
4429
+ // Written as authored, an empty list included, so a decompiled rule compiles back to the same bytes.
4430
+ if (r.exitReasons !== undefined)
4431
+ out.exitReasons = [...r.exitReasons];
4432
+ if (r.errorCategories !== undefined)
4433
+ out.errorCategories = [...r.errorCategories];
4434
+ }
4411
4435
  if (r.rule === 'case-entered' && r.triggers !== undefined) {
4412
4436
  // Absent means any trigger; a list narrows the rule to those triggers.
4413
4437
  out.selectedTriggerIds = r.triggers.map((t, i) => {
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The task-exit feature's case flags, resolved in one place for `serialize`
3
+ * (which writes them) and `check` (which reads them).
4
+ *
5
+ * A `task-exited` rule reacts to a task ending without completing. The
6
+ * platform's converter lowers it only when the case root carries BOTH
7
+ * `caseExecutionExitsOnTaskFailure: true` (a failing task exits instead of
8
+ * faulting the case) and `caseExecutionUsesTaskExitRules: true` (the rules
9
+ * react to exits); with either off the rule is written and silently ignored
10
+ * (`uip maestro case validate` warns CASE_MGMT_CASE_CONDITION_RULE_TASK_EXITED_IGNORED).
11
+ * So a case that has such a rule gets both flags unless the author set one
12
+ * explicitly ({@link CaseBuilder.exitOnTaskFailure}, {@link CaseBuilder.taskExitRules}).
13
+ */
14
+ import type { BuiltCase } from './case-sdk.js';
15
+ /** True when any condition of the case holds a `task-exited` rule. */
16
+ export declare function usesTaskExitRules(built: BuiltCase): boolean;
17
+ /** The two flags as the caseplan carries them; an absent key is not written. */
18
+ export interface TaskExitFlags {
19
+ exitOnTaskFailure?: boolean;
20
+ taskExitRules?: boolean;
21
+ }
22
+ /**
23
+ * The flags the caseplan gets: what the author declared, else `true` for both
24
+ * when the case has a `task-exited` rule, else nothing. A decompiled source
25
+ * whose document had the rule without a flag records that
26
+ * (`CaseJsonPreservation.omitMetadata`), and the flag is then not implied: the
27
+ * platform read it as off, so compile does not turn the rule on.
28
+ *
29
+ * @param built - The case as built.
30
+ * @returns The flags to write, each present only when it has a value.
31
+ */
32
+ export declare function taskExitFlags(built: BuiltCase): TaskExitFlags;
@@ -0,0 +1,29 @@
1
+ import { caseJsonPreservation } from './preserve.js';
2
+ import { ruleSites } from './rule-sites.js';
3
+ /** True when any condition of the case holds a `task-exited` rule. */
4
+ export function usesTaskExitRules(built) {
5
+ for (const { rule } of ruleSites(built))
6
+ if (rule.rule === 'task-exited')
7
+ return true;
8
+ return false;
9
+ }
10
+ /**
11
+ * The flags the caseplan gets: what the author declared, else `true` for both
12
+ * when the case has a `task-exited` rule, else nothing. A decompiled source
13
+ * whose document had the rule without a flag records that
14
+ * (`CaseJsonPreservation.omitMetadata`), and the flag is then not implied: the
15
+ * platform read it as off, so compile does not turn the rule on.
16
+ *
17
+ * @param built - The case as built.
18
+ * @returns The flags to write, each present only when it has a value.
19
+ */
20
+ export function taskExitFlags(built) {
21
+ const absent = caseJsonPreservation(built)?.omitMetadata ?? [];
22
+ const implied = (key) => usesTaskExitRules(built) && !absent.includes(key) ? true : undefined;
23
+ const exitOnTaskFailure = built.exitOnTaskFailure ?? implied('caseExecutionExitsOnTaskFailure');
24
+ const taskExitRules = built.taskExitRules ?? implied('caseExecutionUsesTaskExitRules');
25
+ return {
26
+ ...(exitOnTaskFailure !== undefined ? { exitOnTaskFailure } : {}),
27
+ ...(taskExitRules !== undefined ? { taskExitRules } : {}),
28
+ };
29
+ }
@@ -817,6 +817,13 @@ export declare const REFUSALS: {
817
817
  readonly SWITCH_NO_CASES: "lint";
818
818
  readonly SWITCH_ON_UNUSED: "lint";
819
819
  readonly TASK_ENTRY_POINT_INCOMPLETE: "lowering";
820
+ readonly TASK_EXITED_CATEGORY_UNKNOWN: "lowering";
821
+ readonly TASK_EXITED_FILTER_IGNORED: "lint";
822
+ readonly TASK_EXITED_IGNORED: "lint";
823
+ readonly TASK_EXITED_PLACEMENT: "lint";
824
+ readonly TASK_EXITED_REASON_UNKNOWN: "lowering";
825
+ readonly TASK_EXITED_SELF_RERUN: "lint";
826
+ readonly TASK_EXITED_TASK_OUTSIDE_STAGE: "lint";
820
827
  readonly TASK_INPUTS_UNSUPPORTED: "lowering";
821
828
  readonly TASK_IO_TYPE: "lint";
822
829
  readonly TASK_IO_UNRESOLVED_REFERENCE: "lowering";
@@ -895,6 +895,13 @@ export const REFUSALS = {
895
895
  SWITCH_NO_CASES: 'lint',
896
896
  SWITCH_ON_UNUSED: 'lint',
897
897
  TASK_ENTRY_POINT_INCOMPLETE: 'lowering',
898
+ TASK_EXITED_CATEGORY_UNKNOWN: 'lowering',
899
+ TASK_EXITED_FILTER_IGNORED: 'lint',
900
+ TASK_EXITED_IGNORED: 'lint',
901
+ TASK_EXITED_PLACEMENT: 'lint',
902
+ TASK_EXITED_REASON_UNKNOWN: 'lowering',
903
+ TASK_EXITED_SELF_RERUN: 'lint',
904
+ TASK_EXITED_TASK_OUTSIDE_STAGE: 'lint',
898
905
  TASK_INPUTS_UNSUPPORTED: 'lowering',
899
906
  TASK_IO_TYPE: 'lint',
900
907
  TASK_IO_UNRESOLVED_REFERENCE: 'lowering',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.124.19",
3
+ "version": "6.125.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",
@@ -128,5 +128,5 @@
128
128
  "@types/node": "^22.7.0",
129
129
  "esbuild": "^0.28.1"
130
130
  },
131
- "gitref": "47a39806b6ecdeabac27e5f64636bc9dfbe0f7dd"
131
+ "gitref": "a7c0d60ab1441707d26a15b4c491b12fac27467a"
132
132
  }