@uipath/maestro-builder-sdk 6.89.1 → 6.90.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.
@@ -14,7 +14,7 @@ import { agentInputPlan, agentSidecarInputs, conversationalAgentJson, voiceAgent
14
14
  import { Expr, toExpr } from '../../../core/expr.js';
15
15
  import { wireExprBody } from '../../../core/wire-expr.js';
16
16
  import { checkAgentResources, checkConversationalAgent, checkInlineAgent, checkInlineAgentRead, checkVoice } from './check.js';
17
- import { INLINE_AGENT_DEFAULT_VERSION, INLINE_AGENT_VERSIONS, attachAgentResources, serializeInlineAgent, } from './inline-agent.js';
17
+ import { INLINE_AGENT_DEFAULT_VERSION, INLINE_AGENT_VERSIONS, attachAgentResources, processToolArguments, serializeInlineAgent, } from './inline-agent.js';
18
18
  import { liftAgentResources, liftInlineAgent, printInlineAgent } from './inline-agent-lift.js';
19
19
  import { INLINE_AGENT } from './resources.js';
20
20
  const CREATE_OUTGOING_CALL = 'uipath.conversational.voice.create-outgoing-call';
@@ -126,7 +126,13 @@ function serializeVoiceAgent(s, ctx) {
126
126
  * resource nodes and `resource.json` files, under this agent's `source` (#1670).
127
127
  */
128
128
  function shellResources(s, ctx, source, who) {
129
+ // A process tool argument compile cannot write, a Variable included, is held
130
+ // until the resources are judged, and thrown before LIBRARY_REQUIRED, which
131
+ // `check` drops, as on the inline agent.
132
+ const { toolArgument } = processToolArguments(s, ctx.step, who, (v) => ctx.render(v), false);
129
133
  const { attach, libraryRequired } = attachAgentResources(s, ctx, source, who);
134
+ if (toolArgument)
135
+ throw toolArgument;
130
136
  if (libraryRequired)
131
137
  throw libraryRequired;
132
138
  return attach;
@@ -316,7 +322,7 @@ function printShellAgent(spec, ctx) {
316
322
  ['voice', voiceSrc],
317
323
  ['maxIterations', num(a.maxIterations)],
318
324
  ['context', a.resources.context],
319
- ['tools', a.resources.tools],
325
+ ['tools', typeof a.resources.tools === 'function' ? a.resources.tools(ctx) : a.resources.tools],
320
326
  ['escalation', a.resources.escalation],
321
327
  ['source', ctx.string(a.source ?? '')],
322
328
  ],
@@ -353,7 +359,7 @@ function printShellAgent(spec, ctx) {
353
359
  ['maxIterations', num(a.maxIterations)],
354
360
  ['guardrails', a.guardrails === undefined ? undefined : ctx.json(a.guardrails)],
355
361
  ['context', a.resources.context],
356
- ['tools', a.resources.tools],
362
+ ['tools', typeof a.resources.tools === 'function' ? a.resources.tools(ctx) : a.resources.tools],
357
363
  ['escalation', a.resources.escalation],
358
364
  ['source', ctx.string(a.source ?? '')],
359
365
  ],
@@ -1,4 +1,4 @@
1
- import type { ContextIndexRef, EscalationRef } from '../../../core/actions.js';
1
+ import type { ContextIndexRef, EscalationRef, ProcessToolKind, ToolArgument } from '../../../core/actions.js';
2
2
  import type { ResolvedConnector } from '../../../core/library.js';
3
3
  import type { ProcessResourceSubType } from '../../../core/process-resource.js';
4
4
  /** The inline (autonomous) agent's node type — fixed, not per-instance. */
@@ -111,9 +111,15 @@ export declare function requireAll(schema: {
111
111
  *
112
112
  * Which `type`/`toolType` values compile writes — and so owns and may prune —
113
113
  * is {@link compileOwnsResource}, read off the same tables these writers use.
114
+ *
115
+ * `spec.variables` names the agent input each Variable argument binds
116
+ * (`toolVariableRefs`), for its `argumentProperties` entry.
114
117
  */
115
118
  export declare function toolResourceJson(tr: any, spec: {
116
119
  id: string;
120
+ variables?: Record<string, {
121
+ flatName: string;
122
+ }>;
117
123
  }): Record<string, unknown> | undefined;
118
124
  /** `inline` → `Inline`: the node's enum spelling to the resource schema's. */
119
125
  export declare const enumValue: (v: unknown) => string;
@@ -362,6 +368,8 @@ export declare const PROCESS_TOOL_META: Record<string, {
362
368
  icon: string;
363
369
  sortOrder: number;
364
370
  }>;
371
+ /** Whether `kind` is a deployed-resource tool's: a key of {@link PROCESS_TOOL_META}. */
372
+ export declare function isProcessToolKind(kind: unknown): kind is ProcessToolKind;
365
373
  /**
366
374
  * The definition for one per-instance tool resource. Like `rpaWorkflowDef`
367
375
  * and its siblings — whose model half this shares verb for verb — the def
@@ -374,7 +382,7 @@ export declare function processToolDef(kind: string, spec: {
374
382
  key: string;
375
383
  name: string;
376
384
  folderPath: string;
377
- inputs?: Record<string, string>;
385
+ inputs?: Record<string, ToolArgument>;
378
386
  returns?: Record<string, string>;
379
387
  }): any;
380
388
  /**
@@ -16,6 +16,7 @@ import { CONTEXT_INDEX_DEFAULTS, CONTEXT_INDEX_DEFAULT_FILE_EXTENSION, contextIn
16
16
  import { formFieldJsonSchema } from '../../../core/form-field-type.js';
17
17
  import { jsonClone } from '../../../core/json-clone.js';
18
18
  import { ownEntry } from '../../../core/own-entry.js';
19
+ import { argumentTypes, jsonPathKey, promptOf, toolArgumentProperties } from '../../../core/tool-argument.js';
19
20
  /** The inline (autonomous) agent's node type — fixed, not per-instance. */
20
21
  export const INLINE_AGENT = 'uipath.agent.autonomous';
21
22
  const IXP_DEF = ixpDefinition;
@@ -196,6 +197,20 @@ export function requireAll(schema) {
196
197
  const names = Object.keys(schema.properties);
197
198
  return names.length === 0 ? schema : { ...schema, required: names };
198
199
  }
200
+ /**
201
+ * A process tool's `inputSchema` in its `resource.json`: every argument's type,
202
+ * required whatever its source, and an argument's Prompt as its `description`,
203
+ * which is where the canvas's `enrichProcessFamilyTool` writes it.
204
+ */
205
+ function toolInputSchema(inputs) {
206
+ const schema = fieldSchema(argumentTypes(inputs));
207
+ for (const [name, arg] of Object.entries(inputs ?? {})) {
208
+ const prompt = promptOf(arg);
209
+ if (prompt !== undefined)
210
+ schema.properties[name].description = prompt;
211
+ }
212
+ return requireAll(schema);
213
+ }
199
214
  /**
200
215
  * The `resources/<id>/resource.json` a DEPLOYED-RESOURCE tool needs — the tool
201
216
  * half of what `contextResourceJson` does for an index, and inert for the same
@@ -231,6 +246,9 @@ export function requireAll(schema) {
231
246
  *
232
247
  * Which `type`/`toolType` values compile writes — and so owns and may prune —
233
248
  * is {@link compileOwnsResource}, read off the same tables these writers use.
249
+ *
250
+ * `spec.variables` names the agent input each Variable argument binds
251
+ * (`toolVariableRefs`), for its `argumentProperties` entry.
234
252
  */
235
253
  export function toolResourceJson(tr, spec) {
236
254
  const common = {
@@ -245,13 +263,16 @@ export function toolResourceJson(tr, spec) {
245
263
  // model reads this schema to build the call, and an argument the process needs
246
264
  // but the schema calls optional fails at run time with nothing said at compile
247
265
  // time. The corpus fixture lists every declared argument.
248
- inputSchema: requireAll(fieldSchema(tr.inputs)),
266
+ inputSchema: toolInputSchema(tr.inputs),
249
267
  outputSchema: fieldSchema(tr.returns),
250
268
  // No policies: `inlineAgent`'s tool refs carry none, and the field is
251
269
  // required-but-emptyable.
252
270
  guardrail: { policies: [] },
253
271
  settings: {},
254
- argumentProperties: {},
272
+ // Each Fixed value's `static` entry and each Variable's `argument` entry.
273
+ // Written empty when there are none, which the canvas omits; the schema
274
+ // defaults it to `{}` either way.
275
+ argumentProperties: toolArgumentProperties(tr.inputs, spec.variables),
255
276
  };
256
277
  const resourceType = ownEntry(TOOL_RESOURCE_TYPE, tr.kind);
257
278
  if (resourceType !== undefined) {
@@ -428,7 +449,7 @@ export function httpRequestToolResourceJson(label, inputs, spec) {
428
449
  const row = (inputs[field] ?? {});
429
450
  properties[field] = { ...schema, description: String(row.promptValue ?? '') };
430
451
  if (row.mode !== undefined && row.mode !== 'prompt') {
431
- argumentProperties[`$['${field}']`] = { variant: 'static', value: row.textValue, isSensitive: false };
452
+ argumentProperties[jsonPathKey(field)] = { variant: 'static', value: row.textValue, isSensitive: false };
432
453
  }
433
454
  }
434
455
  return {
@@ -1017,6 +1038,10 @@ export const PROCESS_TOOL_META = {
1017
1038
  // (see `publishedFunctionDef`, transcribed from the platform's manifest).
1018
1039
  function: { ns: 'function', serviceType: 'Orchestrator.ExecuteFunctionAsync', subType: 'Function', orchestratorType: 'function', category: 'agent.tool.function', icon: 'function', sortOrder: 557 },
1019
1040
  };
1041
+ /** Whether `kind` is a deployed-resource tool's: a key of {@link PROCESS_TOOL_META}. */
1042
+ export function isProcessToolKind(kind) {
1043
+ return typeof kind === 'string' && ownEntry(PROCESS_TOOL_META, kind) !== undefined;
1044
+ }
1020
1045
  /**
1021
1046
  * The definition for one per-instance tool resource. Like `rpaWorkflowDef`
1022
1047
  * and its siblings — whose model half this shares verb for verb — the def
@@ -1027,7 +1052,8 @@ export const PROCESS_TOOL_META = {
1027
1052
  */
1028
1053
  export function processToolDef(kind, spec) {
1029
1054
  const meta = PROCESS_TOOL_META[kind];
1030
- const inputProps = Object.keys(spec.inputs ?? {});
1055
+ const inputs = argumentTypes(spec.inputs);
1056
+ const inputProps = Object.keys(inputs ?? {});
1031
1057
  return {
1032
1058
  nodeType: `uipath.agent.resource.tool.${meta.ns}.${spec.key}`,
1033
1059
  version: '1.0.0',
@@ -1061,10 +1087,10 @@ export function processToolDef(kind, spec) {
1061
1087
  // The registry's per-tenant copy declares the resource's arguments here
1062
1088
  // when it can read the deployed resource; offline the author's declaration
1063
1089
  // is the only source (`{}` when none — the registry's own empty shape).
1064
- inputDefinition: inputProps.length ? fieldSchema(spec.inputs) : {},
1090
+ inputDefinition: inputProps.length ? fieldSchema(inputs) : {},
1065
1091
  inputDefaults: {
1066
1092
  ...Object.fromEntries(inputProps.map((k) => [k, null])),
1067
- inputSchema: fieldSchema(spec.inputs),
1093
+ inputSchema: fieldSchema(inputs),
1068
1094
  outputSchema: fieldSchema(spec.returns),
1069
1095
  },
1070
1096
  };
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.89.1",
3
+ "version": "6.90.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",
@@ -110,5 +110,5 @@
110
110
  "@types/node": "^22.7.0",
111
111
  "esbuild": "^0.28.1"
112
112
  },
113
- "gitref": "84d87f63b6f8b64c55eb483c87e818b2efa1b4da"
113
+ "gitref": "e5c5dd2ef362641d4c6540e8d01ccf347e1aa3ef"
114
114
  }
@@ -1,121 +0,0 @@
1
- /**
2
- * case/registry-resolved — `check` holds each resource task to the resource
3
- * the SDD resolved it to.
4
- *
5
- * `uip maestro case sdd resolve sdd.md --out tasks/registry-resolved.json`
6
- * records, per SDD task, the tenant resource it was resolved to:
7
- *
8
- * { "resolved": [ { "stage": "Binding Matrix (`bindingMatrix`)", "task": "Echo literal",
9
- * "taskType": "api-workflow",
10
- * "selected": { "name": "API Workflow", "folder": "Shared/…/CM-Golden-Expense-Reporting-106", … } } ] }
11
- *
12
- * An author who then writes a different name or folder on the task (the
13
- * folder's last segment as the name, say) gets a plan that compiles and
14
- * validates, but binds a resource the tenant does not have under that key.
15
- * Compile and `validate` read the name and folder as free strings. So `check`
16
- * compares them (RESOURCE_NOT_AS_RESOLVED, `lint`: compile writes the task as
17
- * authored).
18
- *
19
- * Why the ledger may make `check` stricter. The CLI reads the same file only
20
- * to soften a finding, because the agent being audited can edit it. Here the
21
- * ledger is the record of the resources the user approved in the SDD review,
22
- * and `check` runs while the agent authors against it. A wrong binding is the
23
- * likely error, and an edit to the ledger to match it is not. The two cases
24
- * where the ledger is wrong have a way out: run `sdd resolve` again when the
25
- * SDD changed, or pass `--no-registry-resolved` for a resource chosen on purpose.
26
- *
27
- * Read as data, the way the CLI reads it (`registry-ledger.ts`): entries are
28
- * found wherever they sit, to a bounded depth, so a bare array or another
29
- * envelope reads too. An entry this module cannot use is kept and reported,
30
- * never guessed at. A selection with no folder is a project in this solution,
31
- * read as `solution_folder`, and the message says so. Comparison follows the
32
- * CLI's `comparableFolder`: folders ignore case, surrounding whitespace and
33
- * leading or trailing slashes. Names are exact, against `selected.name`, the
34
- * one name `sdd resolve` writes and `validate --strict --sdd` compares. An
35
- * action app also answers to its other spellings (`deploymentTitle`, `title`,
36
- * `displayName`), as `sdd resolve` matches it.
37
- */
38
- import type { BuiltCase } from './case-sdk.js';
39
- /** Where `uip maestro case sdd resolve` writes its resolutions, relative to the workspace. */
40
- export declare const DEFAULT_REGISTRY_RESOLVED = "tasks/registry-resolved.json";
41
- /** The command that writes the resolutions again. */
42
- export declare const RESOLVE_COMMAND = "uip maestro case sdd resolve sdd.md --out tasks/registry-resolved.json";
43
- /** One resolved SDD task. */
44
- export interface RegistryResolution {
45
- /** The SDD's stage heading, e.g. "Review (`review`)". Absent in some hand-written ledgers. */
46
- stage?: string;
47
- /** The SDD task's name. */
48
- task: string;
49
- /** The SDD task type, e.g. `api-workflow`, `process`, `agent`. */
50
- taskType?: string;
51
- /**
52
- * The resource the task resolved to. `name` is the one to write; `names`
53
- * holds every spelling the task may bind (more than one only for an action
54
- * app). `inSolution` marks a project in this solution, which the entry gives
55
- * with no folder: `folder` is then `solution_folder`.
56
- */
57
- selected: {
58
- name: string;
59
- names: readonly string[];
60
- folder: string;
61
- inSolution: boolean;
62
- };
63
- }
64
- /** An entry `check` cannot judge a task against, and why. */
65
- export interface UnusableEntry {
66
- stage?: string;
67
- task: string;
68
- /** `unresolved`: `selected` is null, the SDD left the task open. `no-name`: the selection has no string name. */
69
- why: 'unresolved' | 'no-name';
70
- }
71
- /** What `check` needs from a registry-resolved file, with the entries it cannot use. */
72
- export interface RegistryResolved {
73
- resolved: readonly RegistryResolution[];
74
- /** Entries found but not usable. They still count when tasks are matched by name. */
75
- unusable: readonly UnusableEntry[];
76
- /** The file read, for messages. Defaults to {@link DEFAULT_REGISTRY_RESOLVED}. */
77
- file?: string;
78
- }
79
- /** A finding from {@link registryResolvedLint}. */
80
- export interface RegistryResolvedFinding {
81
- code: 'RESOURCE_NOT_AS_RESOLVED';
82
- message: string;
83
- suggestion: string;
84
- where: string;
85
- }
86
- /** A folder in the form two spellings of it share (cli `comparableFolder`). */
87
- export declare function comparableFolder(folder: string): string;
88
- /**
89
- * Read a parsed registry-resolved file. Returns `undefined` when it holds no
90
- * entry. An entry with `selected: null` and one whose selection has no string
91
- * name are kept as {@link UnusableEntry}. A selection with `source: "local"`
92
- * or no folder is a project in this solution (`sdd resolve` writes a sibling
93
- * that way): its folder is read as `solution_folder` and marked `inSolution`.
94
- */
95
- export declare function readRegistryResolved(json: unknown): RegistryResolved | undefined;
96
- /** The stage label of an SDD stage heading: "Review (`review`)" → "Review". */
97
- export declare function sddStageLabel(heading: string): string;
98
- /** How the SDD's resolutions met the plan's resource tasks: what `check` judged and what it could not. */
99
- export interface RegistryResolvedCoverage {
100
- /** Resource tasks matched to a usable entry, so judged. */
101
- held: number;
102
- /** Resource tasks (by name) with no entry of that name: not judged. A renamed task lands here. */
103
- noEntry: string[];
104
- /** Resource tasks (by name) whose name more than one entry has, none of them in the task's stage: not judged. */
105
- ambiguous: string[];
106
- /** Resource tasks matched to an entry `check` cannot use: not judged. */
107
- unusable: {
108
- task: string;
109
- why: UnusableEntry['why'];
110
- }[];
111
- /** Usable entries (by task name) that no resource task matched. */
112
- unused: string[];
113
- }
114
- /** What {@link registryResolvedLint} judged, so the CLI can say what it did not. */
115
- export declare function registryResolvedCoverage(built: BuiltCase, registry: RegistryResolved): RegistryResolvedCoverage;
116
- /**
117
- * A resource task whose name or folder differs from the resource the SDD
118
- * resolved it to. Tasks are matched as {@link matchTasks} says; a task with no
119
- * usable entry is not judged ({@link registryResolvedCoverage} counts it).
120
- */
121
- export declare function registryResolvedLint(built: BuiltCase, registry: RegistryResolved): RegistryResolvedFinding[];
@@ -1,155 +0,0 @@
1
- /** Where `uip maestro case sdd resolve` writes its resolutions, relative to the workspace. */
2
- export const DEFAULT_REGISTRY_RESOLVED = 'tasks/registry-resolved.json';
3
- /** The command that writes the resolutions again. */
4
- export const RESOLVE_COMMAND = `uip maestro case sdd resolve sdd.md --out ${DEFAULT_REGISTRY_RESOLVED}`;
5
- const isText = (v) => typeof v === 'string';
6
- const asRecord = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) ? v : undefined;
7
- /** The spellings an index entry answers to, as `sdd resolve` reads them (`namesOf`). */
8
- const NAME_FIELDS = ['name', 'deploymentTitle', 'title', 'displayName'];
9
- /**
10
- * Entries wherever they sit: an object with a string `task` and a `selected`
11
- * or `matches` key, in an array at depth 4 or less (cli `collectEntries`).
12
- */
13
- function collectEntries(value, into, depth = 0) {
14
- if (depth > 4)
15
- return;
16
- if (Array.isArray(value)) {
17
- for (const item of value) {
18
- const record = asRecord(item);
19
- if (record && isText(record.task) && ('selected' in record || 'matches' in record))
20
- into.push(record);
21
- else
22
- collectEntries(item, into, depth + 1);
23
- }
24
- return;
25
- }
26
- for (const v of Object.values(asRecord(value) ?? {}))
27
- collectEntries(v, into, depth + 1);
28
- }
29
- /** A folder in the form two spellings of it share (cli `comparableFolder`). */
30
- export function comparableFolder(folder) {
31
- return folder.trim().replace(/^\/+|\/+$/g, '').toLowerCase();
32
- }
33
- /** The folder compile writes for a resource in this solution, and `sdd resolve` lists a sibling project under. */
34
- const SOLUTION_FOLDER = 'solution_folder';
35
- /**
36
- * Read a parsed registry-resolved file. Returns `undefined` when it holds no
37
- * entry. An entry with `selected: null` and one whose selection has no string
38
- * name are kept as {@link UnusableEntry}. A selection with `source: "local"`
39
- * or no folder is a project in this solution (`sdd resolve` writes a sibling
40
- * that way): its folder is read as `solution_folder` and marked `inSolution`.
41
- */
42
- export function readRegistryResolved(json) {
43
- const entries = [];
44
- collectEntries(json, entries);
45
- if (entries.length === 0)
46
- return undefined;
47
- const resolved = [];
48
- const unusable = [];
49
- for (const e of entries) {
50
- const head = { ...(isText(e.stage) ? { stage: e.stage } : {}), task: e.task };
51
- if (e.selected === null || e.selected === undefined) {
52
- unusable.push({ ...head, why: 'unresolved' });
53
- continue;
54
- }
55
- const sel = asRecord(e.selected);
56
- const spellings = sel ? NAME_FIELDS.map((f) => sel[f]).filter((v) => isText(v) && v !== '') : [];
57
- const inSolution = sel?.source === 'local' || sel?.folder === undefined || sel.folder === null || sel.folder === '';
58
- if (!sel || spellings.length === 0 || (!inSolution && !isText(sel.folder))) {
59
- unusable.push({ ...head, why: 'no-name' });
60
- continue;
61
- }
62
- // `sdd resolve` writes one name (`namesOf(entry)[0]`), and validate
63
- // --strict --sdd compares a binding to it exactly. Only an action app is
64
- // matched under its other spellings (title, deploymentTitle) as well.
65
- const names = e.taskType === 'action' ? spellings : spellings.slice(0, 1);
66
- resolved.push({
67
- ...head,
68
- ...(isText(e.taskType) ? { taskType: e.taskType } : {}),
69
- selected: { name: spellings[0], names, folder: inSolution ? SOLUTION_FOLDER : sel.folder, inSolution },
70
- });
71
- }
72
- return { resolved, unusable };
73
- }
74
- /** The stage label of an SDD stage heading: "Review (`review`)" → "Review". */
75
- export function sddStageLabel(heading) {
76
- return heading.replace(/\s*\(`[^`]*`\)\s*$/, '').trim();
77
- }
78
- /**
79
- * Pair each resource task with its entry: by stage label and task name; when
80
- * no entry of that name has the task's stage (the stage was relabelled, or the
81
- * entry has none), by task name alone if exactly one entry has it. Unusable
82
- * entries count as candidates, so a task whose own entry is unresolved is
83
- * never judged against another stage's entry of the same name.
84
- */
85
- function matchTasks(built, registry) {
86
- const all = [
87
- ...registry.resolved.map((e) => ({ stage: e.stage, task: e.task, candidate: { usable: e } })),
88
- ...registry.unusable.map((e) => ({ stage: e.stage, task: e.task, candidate: { unusable: e } })),
89
- ];
90
- const out = [];
91
- for (const stage of built.stages)
92
- for (const lane of stage.lanes)
93
- for (const task of lane) {
94
- if (!task.ref)
95
- continue;
96
- const byName = all.filter((e) => e.task === task.name);
97
- const hit = byName.find((e) => e.stage !== undefined && sddStageLabel(e.stage) === stage.label)
98
- ?? (byName.length === 1 ? byName[0] : undefined);
99
- const found = hit ? 'entry' : byName.length > 1 ? 'ambiguous' : 'none';
100
- out.push({ stage: stage.label, task: { name: task.name, ref: task.ref }, found, ...(hit ? { candidate: hit.candidate } : {}) });
101
- }
102
- return out;
103
- }
104
- const usableOf = (m) => m.candidate && 'usable' in m.candidate ? m.candidate.usable : undefined;
105
- /** What {@link registryResolvedLint} judged, so the CLI can say what it did not. */
106
- export function registryResolvedCoverage(built, registry) {
107
- const matches = matchTasks(built, registry);
108
- const used = new Set(matches.flatMap((m) => usableOf(m) ?? []));
109
- return {
110
- held: matches.filter((m) => usableOf(m)).length,
111
- noEntry: matches.filter((m) => m.found === 'none').map((m) => m.task.name),
112
- ambiguous: matches.filter((m) => m.found === 'ambiguous').map((m) => m.task.name),
113
- unusable: matches.flatMap((m) => (m.candidate && 'unusable' in m.candidate ? [{ task: m.task.name, why: m.candidate.unusable.why }] : [])),
114
- unused: registry.resolved.filter((e) => !used.has(e)).map((e) => e.task),
115
- };
116
- }
117
- /**
118
- * A resource task whose name or folder differs from the resource the SDD
119
- * resolved it to. Tasks are matched as {@link matchTasks} says; a task with no
120
- * usable entry is not judged ({@link registryResolvedCoverage} counts it).
121
- */
122
- export function registryResolvedLint(built, registry) {
123
- const file = registry.file ?? DEFAULT_REGISTRY_RESOLVED;
124
- const findings = [];
125
- for (const m of matchTasks(built, registry)) {
126
- const entry = usableOf(m);
127
- if (!entry)
128
- continue;
129
- const { stage, task } = m;
130
- const { name, names, folder, inSolution } = entry.selected;
131
- const authoredFolder = task.ref.folderPath === '' ? SOLUTION_FOLDER : task.ref.folderPath;
132
- const nameOk = names.includes(task.ref.name);
133
- const folderOk = comparableFolder(authoredFolder) === comparableFolder(folder);
134
- if (nameOk && folderOk)
135
- continue;
136
- const differs = [
137
- ...(nameOk ? [] : [`name "${task.ref.name}" (resolved: "${name}")`]),
138
- ...(folderOk ? [] : [`folder "${authoredFolder}" (resolved: "${folder}")`]),
139
- ].join(' and ');
140
- findings.push({
141
- code: 'RESOURCE_NOT_AS_RESOLVED',
142
- where: task.name,
143
- message: `Task "${task.name}" in stage "${stage}" binds ${differs}, `
144
- + `but ${file} resolved it to "${name}" in "${folder}"${inSolution ? ' (a project in this solution)' : ''}. `
145
- + `Compile would bind "${authoredFolder}.${task.ref.name}", which is not the resource the SDD names.`,
146
- suggestion: (inSolution
147
- ? `Use the resolved name with no folder: ("${name}"), so compile binds it in this solution. `
148
- : `Use the resolved name and folder: ("${name}", { folder: "${folder}" }). `)
149
- + 'The name is the resource\'s own name (selected.name), not its folder or package. '
150
- + `If the SDD changed, resolve the task again (\`${RESOLVE_COMMAND}\` writes the whole file again). `
151
- + 'If you chose another resource on purpose, run check with --no-registry-resolved.',
152
- });
153
- }
154
- return findings;
155
- }