@uipath/maestro-builder-sdk 6.82.7 → 6.83.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.
@@ -64,10 +64,11 @@ export interface RuleOpts {
64
64
  sla?: string;
65
65
  /**
66
66
  * For an **at-risk** `sla-status-change` rule — the displayName of the escalation
67
- * (declared on the referenced SLA, `trigger: 'at-risk'`) that fires it. Omit for
68
- * a **breach** rule (`slaId` alone). Resolved to `escalationId`.
67
+ * (declared on the referenced SLA, `trigger: 'at-risk'`) that fires it, or
68
+ * {@link ANY_ESCALATION} to fire on every at-risk escalation of that SLA. Omit
69
+ * for a **breach** rule (`slaId` alone). Resolved to `escalationId`.
69
70
  */
70
- escalation?: string;
71
+ escalation?: string | typeof ANY_ESCALATION;
71
72
  /**
72
73
  * For an `api-event` rule — the **name of the business event** it listens for,
73
74
  * e.g. `rule('api-event', { businessEvent: 'Invoice Approved' })`. Declare the
@@ -83,6 +84,26 @@ export interface RuleOpts {
83
84
  export interface CaseRule extends RuleOpts {
84
85
  rule: CaseRuleType;
85
86
  }
87
+ /**
88
+ * The escalation of an at-risk `sla-status-change` rule that fires on **any**
89
+ * at-risk escalation of the referenced SLA: the Case Designer's "Any" choice,
90
+ * which it writes by default when a rule's status is At risk. Written as
91
+ * `escalationId: "any"`; the platform runs it as one at-risk condition per
92
+ * at-risk escalation of that SLA. A symbol, not the string `'any'`, so it
93
+ * never names a real escalation whose displayName is "any".
94
+ *
95
+ * @example
96
+ * **Enter a lane as soon as the case SLA is at risk, whichever escalation fires**
97
+ * ```ts
98
+ * casePlan('claims')
99
+ * .sla({ displayName: 'Resolution SLA', count: 10, unit: 'd', escalations: [
100
+ * escalation({ displayName: 'Warn owner', trigger: 'at-risk', atRiskPercentage: 80, notify: [toUser('owner@example.com')] }),
101
+ * ] })
102
+ * .exceptionStage('Escalation Review', (s) => s
103
+ * .entryWhen(rule('sla-status-change', { sla: 'Resolution SLA', escalation: ANY_ESCALATION })))
104
+ * ```
105
+ */
106
+ export declare const ANY_ESCALATION: unique symbol;
86
107
  /**
87
108
  * Declare a condition rule. Pass one rule, an array for an AND-group, or an
88
109
  * array of arrays for the complete OR-of-AND grid to
@@ -1557,6 +1578,25 @@ declare class TaskBuilder {
1557
1578
  * the parameter's flag and default value on the row, as the Case Designer
1558
1579
  * does: `{ value: 'hi', required: false, default: 'Empty' }`.
1559
1580
  *
1581
+ * A literal wholly wrapped in one pair of quotes loses them, the way `uip
1582
+ * maestro case sdd convert` reads an SDD cell and `{ assign }` reads its
1583
+ * value, so an SDD cell can be copied as written:
1584
+ *
1585
+ * `'"literal-seed"'` and `'literal-seed'` both store `literal-seed`. To send
1586
+ * the quotes themselves, wrap the value in one more pair of the other quote;
1587
+ * decompile writes that spelling for a stored value that looks quoted. A `=`
1588
+ * expression is never changed.
1589
+ *
1590
+ * @example
1591
+ * **Copy an SDD literal cell, and keep a literal's quotes**
1592
+ * ```ts
1593
+ * casePlan('echo').stage('Echo', (s) => s.task('Echo', (t) =>
1594
+ * t.apiWorkflow('Echo', { folder: 'Shared' }).inputs({
1595
+ * APIInput1: '"literal-seed"', // stores literal-seed
1596
+ * APIInput2: `'"literal-seed"'`, // stores "literal-seed", quotes kept
1597
+ * })))
1598
+ * ```
1599
+ *
1560
1600
  * @param shape - Input parameter names to literals, case-variable references, or `{ value, type, required, default }`.
1561
1601
  * @returns This builder, so calls chain.
1562
1602
  */
@@ -1600,7 +1640,8 @@ declare class TaskBuilder {
1600
1640
  * written as Studio Web saves one: `custom: true`, `elementId: 'root'`, no
1601
1641
  * `id`. The SDD notation `=metadata.<field>` reads nothing outside `=js:`, so it
1602
1642
  * is written as `=js:metadata.<field>`. An SDD literal copied with its quotes
1603
- * (`{ assign: '"literal-assigned"' }`) loses them, as `sdd convert` reads it.
1643
+ * (`{ assign: '"literal-assigned"' }`) loses them, as `sdd convert` reads it;
1644
+ * wrap it in one more pair of the other quote to keep them (see `.inputs()`).
1604
1645
  * A custom output sees only the outputs listed before it on the same task:
1605
1646
  * outputs are evaluated in order, so it cannot read its own variable or a
1606
1647
  * later output's (`check` reports `OUTPUT_SELF_REFERENCE` /
@@ -28,8 +28,30 @@ import { CASE_FORMAT_PROFILE, CASE_SCHEMA_VERSIONS, recordAuthoredCaseVersion }
28
28
  import { schemaVersionRefusal } from '../schema-version.js';
29
29
  import { CompileRefusal } from '../core/compile-refusal.js';
30
30
  import { isConnectorPlaceholder } from './connector-placeholder.js';
31
+ import { unquoteLiteral } from './literal.js';
32
+ import { ANY_ESCALATION_KEY } from './rule-options.js';
31
33
  export { preserveCaseJson } from './preserve.js';
32
34
  export { CaseBuildError } from './case-expr-check.js';
35
+ /**
36
+ * The escalation of an at-risk `sla-status-change` rule that fires on **any**
37
+ * at-risk escalation of the referenced SLA: the Case Designer's "Any" choice,
38
+ * which it writes by default when a rule's status is At risk. Written as
39
+ * `escalationId: "any"`; the platform runs it as one at-risk condition per
40
+ * at-risk escalation of that SLA. A symbol, not the string `'any'`, so it
41
+ * never names a real escalation whose displayName is "any".
42
+ *
43
+ * @example
44
+ * **Enter a lane as soon as the case SLA is at risk, whichever escalation fires**
45
+ * ```ts
46
+ * casePlan('claims')
47
+ * .sla({ displayName: 'Resolution SLA', count: 10, unit: 'd', escalations: [
48
+ * escalation({ displayName: 'Warn owner', trigger: 'at-risk', atRiskPercentage: 80, notify: [toUser('owner@example.com')] }),
49
+ * ] })
50
+ * .exceptionStage('Escalation Review', (s) => s
51
+ * .entryWhen(rule('sla-status-change', { sla: 'Resolution SLA', escalation: ANY_ESCALATION })))
52
+ * ```
53
+ */
54
+ export const ANY_ESCALATION = Symbol.for(ANY_ESCALATION_KEY);
33
55
  /**
34
56
  * Declare a condition rule. Pass one rule, an array for an AND-group, or an
35
57
  * array of arrays for the complete OR-of-AND grid to
@@ -675,6 +697,25 @@ class TaskBuilder {
675
697
  * the parameter's flag and default value on the row, as the Case Designer
676
698
  * does: `{ value: 'hi', required: false, default: 'Empty' }`.
677
699
  *
700
+ * A literal wholly wrapped in one pair of quotes loses them, the way `uip
701
+ * maestro case sdd convert` reads an SDD cell and `{ assign }` reads its
702
+ * value, so an SDD cell can be copied as written:
703
+ *
704
+ * `'"literal-seed"'` and `'literal-seed'` both store `literal-seed`. To send
705
+ * the quotes themselves, wrap the value in one more pair of the other quote;
706
+ * decompile writes that spelling for a stored value that looks quoted. A `=`
707
+ * expression is never changed.
708
+ *
709
+ * @example
710
+ * **Copy an SDD literal cell, and keep a literal's quotes**
711
+ * ```ts
712
+ * casePlan('echo').stage('Echo', (s) => s.task('Echo', (t) =>
713
+ * t.apiWorkflow('Echo', { folder: 'Shared' }).inputs({
714
+ * APIInput1: '"literal-seed"', // stores literal-seed
715
+ * APIInput2: `'"literal-seed"'`, // stores "literal-seed", quotes kept
716
+ * })))
717
+ * ```
718
+ *
678
719
  * @param shape - Input parameter names to literals, case-variable references, or `{ value, type, required, default }`.
679
720
  * @returns This builder, so calls chain.
680
721
  */
@@ -682,10 +723,10 @@ class TaskBuilder {
682
723
  this._inputs ??= [];
683
724
  for (const [name, v] of Object.entries(shape)) {
684
725
  if (typeof v === 'string') {
685
- this._inputs.push({ name, value: v, type: 'string' });
726
+ this._inputs.push({ name, value: unquoteLiteral(v), type: 'string' });
686
727
  continue;
687
728
  }
688
- const binding = { name, value: v.value, type: (v.type ?? 'string') };
729
+ const binding = { name, value: typeof v.value === 'string' ? unquoteLiteral(v.value) : v.value, type: (v.type ?? 'string') };
689
730
  if (v.required !== undefined)
690
731
  binding.required = v.required;
691
732
  if (v.default !== undefined)
@@ -728,7 +769,8 @@ class TaskBuilder {
728
769
  * written as Studio Web saves one: `custom: true`, `elementId: 'root'`, no
729
770
  * `id`. The SDD notation `=metadata.<field>` reads nothing outside `=js:`, so it
730
771
  * is written as `=js:metadata.<field>`. An SDD literal copied with its quotes
731
- * (`{ assign: '"literal-assigned"' }`) loses them, as `sdd convert` reads it.
772
+ * (`{ assign: '"literal-assigned"' }`) loses them, as `sdd convert` reads it;
773
+ * wrap it in one more pair of the other quote to keep them (see `.inputs()`).
732
774
  * A custom output sees only the outputs listed before it on the same task:
733
775
  * outputs are evaluated in order, so it cannot read its own variable or a
734
776
  * later output's (`check` reports `OUTPUT_SELF_REFERENCE` /
@@ -891,31 +933,6 @@ function customOutputValue(value) {
891
933
  const unquoted = unquoteLiteral(value);
892
934
  return unquoted.startsWith('=metadata.') ? `=js:${unquoted.slice(1)}` : unquoted;
893
935
  }
894
- /**
895
- * An SDD cell's quoted literal without its quotes, as the CLI's `sdd convert`
896
- * reads it (`unquoteLiteral` in `packages/case-tool/src/services/sdd-convert/io.ts`):
897
- * `"literal-assigned"` → `literal-assigned`, with escaped quotes unescaped.
898
- * A value not wholly wrapped in one pair of `"…"` or `'…'` (an unescaped quote
899
- * inside, or an expression like `'a' + 'b'`) is returned unchanged.
900
- */
901
- function unquoteLiteral(cell) {
902
- const text = cell.trim();
903
- const quote = text[0];
904
- if (quote !== '"' && quote !== "'")
905
- return cell;
906
- if (text.length < 2 || text[text.length - 1] !== quote)
907
- return cell;
908
- const inner = text.slice(1, -1);
909
- for (let at = 0; at < inner.length; at += 1) {
910
- if (inner[at] === '\\') {
911
- at += 1;
912
- continue;
913
- }
914
- if (inner[at] === quote)
915
- return cell;
916
- }
917
- return inner.replaceAll(`\\${quote}`, quote);
918
- }
919
936
  class StageBuilder {
920
937
  _label;
921
938
  _exception;
@@ -7,7 +7,7 @@
7
7
  * `references/implementation.md` Check 13, `references/case-schema.md`,
8
8
  * `references/sla-response-shapes.md` §5).
9
9
  *
10
- * All four are `lint`: compile still writes the plan as authored, so a
10
+ * All five are `lint`: compile still writes the plan as authored, so a
11
11
  * decompiled source keeps the condition and `check` reports it again. Each is a
12
12
  * warning wherever `validate --strict` accepts the plan as a working design.
13
13
  *
@@ -17,7 +17,9 @@
17
17
  * "AtRisk" : "Breached"`, PO.Frontend `GenerateCasePlanJsonConditionSlaStatusChangeRuleUtils.ts`),
18
18
  * and `rule('sla-status-change', { sla, escalation })` names one escalation by
19
19
  * its displayName, whose own `trigger` decides. The defect the skill describes
20
- * comes from repairing `escalationId: "any"` by hand, which the DSL cannot write.
20
+ * comes from repairing `escalationId: "any"` by hand; `ANY_ESCALATION` writes
21
+ * that value, and {@link anyEscalationWithoutAtRisk} covers the one way it
22
+ * goes wrong.
21
23
  */
22
24
  import type { Diagnostic } from './check.js';
23
25
  import type { BuiltCase } from './case-sdk.js';
@@ -1,3 +1,4 @@
1
+ import { ANY_ESCALATION_KEY } from './rule-options.js';
1
2
  /** Every rule of a condition list, flattened. */
2
3
  const rulesOf = (conditions) => conditions.flatMap((c) => c.rules.flat());
3
4
  /** Every rule in the case, with the place `check` names for it. */
@@ -204,6 +205,38 @@ function slaReentry(built, decls, diags) {
204
205
  }
205
206
  }
206
207
  }
208
+ /**
209
+ * A `sla-status-change` rule with `escalation: ANY_ESCALATION` on an SLA that
210
+ * declares no `at-risk` escalation. The converter expands `"any"` to one
211
+ * AtRisk condition per at-risk escalation of the SLA
212
+ * (PO.Frontend `GenerateCasePlanJsonConditionSlaStatusChangeRuleUtils.ts`), so
213
+ * with none it writes no condition at all and the rule never fires. The
214
+ * Designer validator skips `"any"`, so `validate` accepts the plan; a warning,
215
+ * like {@link exitedWithoutExit}. The SLA is the one the rule binds to (see
216
+ * {@link slaDecls}); an unknown name is UNKNOWN_SLA_REF.
217
+ */
218
+ function anyEscalationWithoutAtRisk(built, decls, diags) {
219
+ // `ANY_ESCALATION` (case-sdk), matched by its registered key the way serialize does.
220
+ const any = Symbol.for(ANY_ESCALATION_KEY);
221
+ for (const { rule, where } of everyRule(built)) {
222
+ const named = rule.escalation;
223
+ if (rule.rule !== 'sla-status-change' || named !== any || rule.sla === undefined)
224
+ continue;
225
+ const bound = decls.get(rule.sla)?.at(-1)?.sla;
226
+ if (bound === undefined || bound.escalations.some((e) => e.trigger === 'at-risk'))
227
+ continue;
228
+ diags.push({
229
+ level: 'warning',
230
+ code: 'ANY_ESCALATION_NO_AT_RISK',
231
+ message: `Rule "sla-status-change" fires on ANY_ESCALATION of SLA "${rule.sla}", which declares no 'at-risk' escalation. `
232
+ + 'The platform turns the wildcard into one at-risk condition per at-risk escalation of the SLA, so this rule '
233
+ + 'gets none and never fires.',
234
+ suggestion: `For a breach response, drop the escalation: rule('sla-status-change', { sla: '${rule.sla}' }). For an `
235
+ + `at-risk response, declare an escalation with trigger: 'at-risk' on "${rule.sla}".`,
236
+ where,
237
+ });
238
+ }
239
+ }
207
240
  /** The rules above, in the order `check` reports them. */
208
241
  export function checkRuleSemantics(built, diags) {
209
242
  adhocSelections(built, diags);
@@ -211,4 +244,5 @@ export function checkRuleSemantics(built, diags) {
211
244
  const decls = slaDecls(built);
212
245
  slaReentry(built, decls, diags);
213
246
  slaNameDuplicates(built, decls, diags);
247
+ anyEscalationWithoutAtRisk(built, decls, diags);
214
248
  }
@@ -9,6 +9,8 @@ import { isScriptOwnOutput, liftScript } from './decompile-script.js';
9
9
  import { isHttpRequestOwnOutput, liftHttpRequest } from './decompile-http-request.js';
10
10
  import { savedHttpRequestMetadata } from './http-request.js';
11
11
  import { builtChainSource, chainStatements } from '../core/builder-chain.js';
12
+ import { literalSource } from './literal.js';
13
+ import { ANY_ESCALATION_ID } from './rule-options.js';
12
14
  import { CASE_FORMAT_PROFILE, CASE_SCHEMA_VERSIONS } from './format-profile.js';
13
15
  import { EXTERNAL_TASK_CONTEXT, EXTERNAL_TASK_EVENT_CONTEXT, externalDescriptorRefusal, externalEventRefusal, externalServiceType, isExternalExecutionMode, libraryExecution } from './external.js';
14
16
  import { preserveSchemaVersion } from '../schema-version.js';
@@ -519,7 +521,12 @@ function emitRule(rule, refs) {
519
521
  if (!sla)
520
522
  throw new Error(`sla-status-change rule references unnamed or unknown SLA id "${rule.slaId ?? ''}".`);
521
523
  entries.push(['sla', tsLiteral(sla)]);
522
- if (rule.escalationId !== undefined) {
524
+ if (rule.escalationId === ANY_ESCALATION_ID) {
525
+ // The Designer's "any at-risk escalation" choice, not a dangling id.
526
+ refs.usesAnyEscalation = true;
527
+ entries.push(['escalation', 'ANY_ESCALATION']);
528
+ }
529
+ else if (rule.escalationId !== undefined) {
523
530
  const escalation = refs.escalationNameById.get(rule.escalationId);
524
531
  if (!escalation)
525
532
  throw new Error(`sla-status-change rule references unnamed or unknown escalation id "${rule.escalationId}".`);
@@ -1294,11 +1301,21 @@ function emptyIoLists(task) {
1294
1301
  const empty = ['inputs', 'outputs'].filter((side) => Array.isArray(task.data?.[side]) && task.data[side].length === 0);
1295
1302
  return empty.length ? { emptyIo: [...empty] } : {};
1296
1303
  }
1297
- function ioArg(rows, kind) {
1304
+ function ioArg(rows, kind, task) {
1298
1305
  const valueField = kind === 'inputs' ? 'value' : 'source';
1299
1306
  const entries = rows.map((row) => {
1300
1307
  const name = kind === 'inputs' ? row.name : row.var;
1301
- const value = tsLiteral(row[valueField] ?? '');
1308
+ // A stored literal that itself looks quoted is written in one more pair, so
1309
+ // `.inputs()` / `{ assign }` (which strip one pair, as `sdd convert` does)
1310
+ // compile it back to the same text.
1311
+ const stored = row[valueField] ?? '';
1312
+ const unquotes = kind === 'inputs' || row.custom === true;
1313
+ const spelled = unquotes ? literalSource(String(stored)) : stored;
1314
+ if (spelled === undefined) {
1315
+ const what = kind === 'inputs' ? `input "${row.name ?? '?'}"` : `custom output "${row.var ?? row.name ?? '?'}"`;
1316
+ throw new Error(`${String(task.type)} task "${task.displayName ?? task.id ?? '?'}" ${what} stores the literal ${JSON.stringify(stored)}, which cannot be written as ${kind === 'inputs' ? '.inputs()' : '{ assign }'} source without losing its quotes: it is wrapped in one quote and contains both \\' and \\", and the SDK reads one wrapping pair of quotes off a literal the way \`uip maestro case sdd convert\` does. Decompile refuses it rather than change the value on recompile. Edit the value in the Case Designer (drop the wrapping quotes, or one of the escaped quotes) and decompile again.`);
1317
+ }
1318
+ const value = tsLiteral(spelled);
1302
1319
  // A custom output (`custom: true`) assigns its value; it reads no result field.
1303
1320
  const custom = kind === 'outputs' && row.custom === true;
1304
1321
  // An input's `required` / `default` are the resource parameter's flag and
@@ -1322,13 +1339,13 @@ function emitTask(out, depth, task, lane, refs, library) {
1322
1339
  if (ownEntry(TASK_KIND_METHOD, task.type) || isAuthorableBusinessRule(task)) {
1323
1340
  const data = task.data ?? {};
1324
1341
  if (Array.isArray(data.inputs) && data.inputs.length)
1325
- out.line(inner, `.inputs(${ioArg(data.inputs, 'inputs')})`);
1342
+ out.line(inner, `.inputs(${ioArg(data.inputs, 'inputs', task)})`);
1326
1343
  }
1327
1344
  const outputs = taskOutputRows(task);
1328
1345
  if (outputs)
1329
1346
  refuseUnwrittenOutputs(task, outputs);
1330
1347
  if (outputs?.lifted.length)
1331
- out.line(inner, `.outputs(${ioArg(outputs.lifted, 'outputs')})`);
1348
+ out.line(inner, `.outputs(${ioArg(outputs.lifted, 'outputs', task)})`);
1332
1349
  if (task.isRequired !== undefined)
1333
1350
  out.line(inner, task.isRequired ? '.required()' : '.required(false)');
1334
1351
  if (task.shouldRunOnlyOnce !== undefined)
@@ -2635,6 +2652,8 @@ export function decompileWithDiagnostics(plan, options = {}) {
2635
2652
  const imports = ['casePlan', 'rule', 'manualTrigger', 'timerTrigger', 'eventTrigger', 'jsonSchema', 'escalation', 'toUser', 'toGroup'];
2636
2653
  if (preservation)
2637
2654
  imports.push('preserveCaseJson');
2655
+ if (refs.usesAnyEscalation)
2656
+ imports.push('ANY_ESCALATION');
2638
2657
  const diagnosticHeader = diagnostics.length
2639
2658
  ? `${[
2640
2659
  '// BEST-EFFORT DECOMPILE: this source is intentionally not buildable until every marker below is repaired.',
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The quoted-literal rule a task io value follows, shared by `.inputs()`, the
3
+ * custom `{ assign }` output, and decompile.
4
+ *
5
+ * An SDD (software design document) cell writes a string literal in quotes:
6
+ * `| APIInput1 | string | "literal-seed" |`. The CLI's `uip maestro case sdd
7
+ * convert` stores the text inside the quotes (`unquoteLiteral` in
8
+ * `packages/case-tool/src/services/sdd-convert/io.ts`), and so does the Case
9
+ * Designer, which has no quoting at all: a literal is its bare text. The SDK
10
+ * reads a value the same way, so the same cell gives the same runtime value
11
+ * whichever toolchain wrote the plan.
12
+ */
13
+ /**
14
+ * An SDD cell's quoted literal without its quotes: `"literal-assigned"` →
15
+ * `literal-assigned`, with escaped quotes unescaped. A value not wholly wrapped
16
+ * in one pair of `"…"` or `'…'` (an unescaped quote inside, or an expression
17
+ * like `'a' + 'b'`) is returned unchanged, and so is any `=` expression.
18
+ */
19
+ export declare function unquoteLiteral(cell: string): string;
20
+ /**
21
+ * The authored spelling of a stored value: one that {@link unquoteLiteral}
22
+ * reads back to exactly `stored`. A value it would leave alone is written as
23
+ * is; a value that itself looks quoted (a Designer literal whose text is
24
+ * `"x"`) is wrapped in one more pair, `'"x"'`, so decompile → compile keeps
25
+ * the quotes instead of stripping them.
26
+ *
27
+ * `undefined` when no spelling exists. `unquoteLiteral` matches the CLI's, so
28
+ * it unescapes only the wrapping quote and treats a backslash before either
29
+ * quote as an escape: a value wrapped in one quote that contains both `\'`
30
+ * and `\"` (Designer literal `"a\"b\'c"`) cannot be wrapped in either
31
+ * quote and read back unchanged. The caller refuses it, naming the row.
32
+ */
33
+ export declare function literalSource(stored: string): string | undefined;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The quoted-literal rule a task io value follows, shared by `.inputs()`, the
3
+ * custom `{ assign }` output, and decompile.
4
+ *
5
+ * An SDD (software design document) cell writes a string literal in quotes:
6
+ * `| APIInput1 | string | "literal-seed" |`. The CLI's `uip maestro case sdd
7
+ * convert` stores the text inside the quotes (`unquoteLiteral` in
8
+ * `packages/case-tool/src/services/sdd-convert/io.ts`), and so does the Case
9
+ * Designer, which has no quoting at all: a literal is its bare text. The SDK
10
+ * reads a value the same way, so the same cell gives the same runtime value
11
+ * whichever toolchain wrote the plan.
12
+ */
13
+ /**
14
+ * An SDD cell's quoted literal without its quotes: `"literal-assigned"` →
15
+ * `literal-assigned`, with escaped quotes unescaped. A value not wholly wrapped
16
+ * in one pair of `"…"` or `'…'` (an unescaped quote inside, or an expression
17
+ * like `'a' + 'b'`) is returned unchanged, and so is any `=` expression.
18
+ */
19
+ export function unquoteLiteral(cell) {
20
+ const text = cell.trim();
21
+ const quote = text[0];
22
+ if (quote !== '"' && quote !== "'")
23
+ return cell;
24
+ if (text.length < 2 || text[text.length - 1] !== quote)
25
+ return cell;
26
+ const inner = text.slice(1, -1);
27
+ for (let at = 0; at < inner.length; at += 1) {
28
+ if (inner[at] === '\\') {
29
+ at += 1;
30
+ continue;
31
+ }
32
+ if (inner[at] === quote)
33
+ return cell;
34
+ }
35
+ return inner.replaceAll(`\\${quote}`, quote);
36
+ }
37
+ /**
38
+ * The authored spelling of a stored value: one that {@link unquoteLiteral}
39
+ * reads back to exactly `stored`. A value it would leave alone is written as
40
+ * is; a value that itself looks quoted (a Designer literal whose text is
41
+ * `"x"`) is wrapped in one more pair, `'"x"'`, so decompile → compile keeps
42
+ * the quotes instead of stripping them.
43
+ *
44
+ * `undefined` when no spelling exists. `unquoteLiteral` matches the CLI's, so
45
+ * it unescapes only the wrapping quote and treats a backslash before either
46
+ * quote as an escape: a value wrapped in one quote that contains both `\'`
47
+ * and `\"` (Designer literal `"a\"b\'c"`) cannot be wrapped in either
48
+ * quote and read back unchanged. The caller refuses it, naming the row.
49
+ */
50
+ export function literalSource(stored) {
51
+ if (unquoteLiteral(stored) === stored)
52
+ return stored;
53
+ for (const quote of ["'", '"']) {
54
+ const candidate = `${quote}${stored.replaceAll(quote, `\\${quote}`)}${quote}`;
55
+ if (unquoteLiteral(candidate) === stored)
56
+ return candidate;
57
+ }
58
+ return undefined;
59
+ }
@@ -1,5 +1,12 @@
1
1
  /** Options each rule kind reads; check and serialize refuse any other key. */
2
2
  import type { CaseRule } from './case-sdk.js';
3
+ /** The `Symbol.for` key of `ANY_ESCALATION`, so serialize and every SDK copy match it. */
4
+ export declare const ANY_ESCALATION_KEY = "@uipath/maestro-builder-sdk/case/anyEscalation";
5
+ /**
6
+ * The `escalationId` the Case Designer persists for its "any at-risk escalation"
7
+ * choice (`SLA_ANY_ESCALATION_VALUE` in Studio Web), authored as `ANY_ESCALATION`.
8
+ */
9
+ export declare const ANY_ESCALATION_ID = "any";
3
10
  /** One problem with a rule's shape: an unknown kind, or an option its kind does not read. */
4
11
  export interface RuleShapeProblem {
5
12
  code: 'UNKNOWN_RULE' | 'RULE_UNKNOWN_OPTION';
@@ -1,4 +1,11 @@
1
1
  import { ownEntry } from '../core/own-entry.js';
2
+ /** The `Symbol.for` key of `ANY_ESCALATION`, so serialize and every SDK copy match it. */
3
+ export const ANY_ESCALATION_KEY = '@uipath/maestro-builder-sdk/case/anyEscalation';
4
+ /**
5
+ * The `escalationId` the Case Designer persists for its "any at-risk escalation"
6
+ * choice (`SLA_ANY_ESCALATION_VALUE` in Studio Web), authored as `ANY_ESCALATION`.
7
+ */
8
+ export const ANY_ESCALATION_ID = 'any';
2
9
  /** `expression` is a gate any rule can carry. */
3
10
  const COMMON = ['expression'];
4
11
  const RULE_OPTIONS = {
@@ -33,7 +33,7 @@ import { CASE_NODE_LAYOUT_FIELDS, caseJsonPreservation, caseJsonPreservationErro
33
33
  import { businessEventProblems } from './business-event-shape.js';
34
34
  import { eventFiltersNotArray, readEventFilter, readEventFilterLeaf, eventFilterTreeLeaf } from '../core/event-filters.js';
35
35
  import { responseJsonSchema } from '../core/connector-response-schema.js';
36
- import { ruleShapeProblems } from './rule-options.js';
36
+ import { ANY_ESCALATION_ID, ANY_ESCALATION_KEY, ruleShapeProblems } from './rule-options.js';
37
37
  import { CompileRefusal } from '../core/compile-refusal.js';
38
38
  import { expressionBindingId } from '../core/expression-binding-id.js';
39
39
  import { implicitInArgBuiltTrigger, unboundInArgMessage } from './in-arg-binding.js';
@@ -3438,7 +3438,12 @@ function emitRule(r, seed, ownerId, ids, resolver, site) {
3438
3438
  if (!slaId)
3439
3439
  throw new CompileRefusal('UNKNOWN_SLA_REF', `rule "sla-status-change" references unknown SLA "${r.sla}" — declare it with .sla({ displayName: "${r.sla}", … }).`);
3440
3440
  out.slaId = slaId;
3441
- if (r.escalation) {
3441
+ // `ANY_ESCALATION` (case-sdk), matched by its registered key, so a second copy of the SDK matches too.
3442
+ if (r.escalation === Symbol.for(ANY_ESCALATION_KEY))
3443
+ out.escalationId = ANY_ESCALATION_ID;
3444
+ else if (r.escalation) {
3445
+ if (typeof r.escalation !== 'string')
3446
+ throw new CompileRefusal('UNKNOWN_ESCALATION_REF', `rule "sla-status-change" escalation must be an escalation displayName or ANY_ESCALATION.`);
3442
3447
  const escId = resolver.escalationIdByName.get(r.escalation);
3443
3448
  if (!escId)
3444
3449
  throw new CompileRefusal('UNKNOWN_ESCALATION_REF', `rule "sla-status-change" references unknown escalation "${r.escalation}".`);
@@ -185,6 +185,7 @@ export declare const REFUSALS: {
185
185
  readonly SELECTED_STAGE_EXITED_NO_EXIT: "lint";
186
186
  readonly SLA_RESPONSE_REENTERS_STAGE: "lint";
187
187
  readonly SLA_NAME_DUPLICATE: "lint";
188
+ readonly ANY_ESCALATION_NO_AT_RISK: "lint";
188
189
  readonly CASE_MGMT_BINDING_KEY_MISMATCH: "lint";
189
190
  readonly CASE_MGMT_NODE_ID_DUPLICATE: "lint";
190
191
  readonly CASE_MGMT_OUTPUT_ID_DUPLICATE: "lint";
@@ -249,6 +249,7 @@ export const REFUSALS = {
249
249
  SELECTED_STAGE_EXITED_NO_EXIT: 'lint',
250
250
  SLA_RESPONSE_REENTERS_STAGE: 'lint',
251
251
  SLA_NAME_DUPLICATE: 'lint',
252
+ ANY_ESCALATION_NO_AT_RISK: 'lint',
252
253
  // `uip maestro case validate`'s own codes, ported to case/plan-check/. All
253
254
  // `lint` for now: only `check` reports them. The four on fields compile writes
254
255
  // (ids, binding keys) are also carried from a decompiled plan's preserved
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.82.7",
3
+ "version": "6.83.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",
@@ -103,5 +103,5 @@
103
103
  "@types/node": "^22.7.0",
104
104
  "esbuild": "^0.28.1"
105
105
  },
106
- "gitref": "d5a34f7e92e62b7ef79bb43f22e0dba65ce3c48c"
106
+ "gitref": "8083a43e2cb53d4c0eb99e508b06d3d4a35f4386"
107
107
  }