@uipath/maestro-builder-sdk 6.89.0 → 6.90.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.
- package/dist/api-index.md +24 -23
- package/dist/api-members.md +49 -49
- package/dist/case/check-cli.js +4 -114
- package/dist/case/check.d.ts +0 -7
- package/dist/case/check.js +0 -5
- package/dist/cli/commands/case.js +0 -7
- package/dist/core/actions.d.ts +35 -2
- package/dist/core/agent-sidecar.d.ts +28 -2
- package/dist/core/agent-sidecar.js +29 -8
- package/dist/core/expr.d.ts +19 -0
- package/dist/core/expr.js +25 -0
- package/dist/core/refusals.d.ts +6 -1
- package/dist/core/refusals.js +6 -3
- package/dist/core/tool-argument.d.ts +105 -0
- package/dist/core/tool-argument.js +207 -0
- package/dist/decompile.js +6 -0
- package/dist/flow-node-type.d.ts +7 -0
- package/dist/nodes/agent/flow/check.d.ts +2 -9
- package/dist/nodes/agent/flow/check.js +104 -8
- package/dist/nodes/agent/flow/inline-agent-lift.d.ts +22 -3
- package/dist/nodes/agent/flow/inline-agent-lift.js +333 -56
- package/dist/nodes/agent/flow/inline-agent.d.ts +22 -1
- package/dist/nodes/agent/flow/inline-agent.js +60 -4
- package/dist/nodes/agent/flow/node-type.js +9 -3
- package/dist/nodes/agent/flow/resources.d.ts +10 -2
- package/dist/nodes/agent/flow/resources.js +32 -6
- package/dist/nodes/trigger/flow/node-type.js +8 -15
- package/package.json +2 -2
- package/dist/case/registry-resolved.d.ts +0 -121
- package/dist/case/registry-resolved.js +0 -155
|
@@ -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,
|
|
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:
|
|
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
|
-
|
|
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[
|
|
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
|
|
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(
|
|
1090
|
+
inputDefinition: inputProps.length ? fieldSchema(inputs) : {},
|
|
1065
1091
|
inputDefaults: {
|
|
1066
1092
|
...Object.fromEntries(inputProps.map((k) => [k, null])),
|
|
1067
|
-
inputSchema: fieldSchema(
|
|
1093
|
+
inputSchema: fieldSchema(inputs),
|
|
1068
1094
|
outputSchema: fieldSchema(spec.returns),
|
|
1069
1095
|
},
|
|
1070
1096
|
};
|
|
@@ -115,20 +115,17 @@ function sentenceCase(id) {
|
|
|
115
115
|
* interval is a preset. Doing it here means the author states the interval once.
|
|
116
116
|
*
|
|
117
117
|
* `entryPointId` names the flow's entry point (the def's `model.entryPointId`).
|
|
118
|
-
*
|
|
119
|
-
* — deterministic, and it satisfies the platform's scheduled-trigger validator,
|
|
120
|
-
* which requires the field. The manual trigger keeps emitting no inputs at all,
|
|
121
|
-
* so every existing flow serializes byte-identically.
|
|
118
|
+
* It is a minted GUID: publish rejects any other value (errorCode 1205).
|
|
122
119
|
*/
|
|
123
|
-
function scheduleInputs(inputs,
|
|
120
|
+
function scheduleInputs(inputs, entryPointId, version) {
|
|
124
121
|
const every = String(inputs?.every ?? '');
|
|
125
122
|
if (!hasTimerPreset(version)) {
|
|
126
123
|
// 1.2 dropped timerPreset: every value, preset or not, rides timerValue alone.
|
|
127
|
-
return { entryPointId
|
|
124
|
+
return { entryPointId, timerType: 'timeCycle', timerValue: every };
|
|
128
125
|
}
|
|
129
126
|
const isPreset = SCHEDULE_PRESETS.includes(every);
|
|
130
127
|
return {
|
|
131
|
-
entryPointId
|
|
128
|
+
entryPointId,
|
|
132
129
|
timerType: 'timeCycle',
|
|
133
130
|
timerPreset: isPreset ? every : 'custom',
|
|
134
131
|
...(isPreset ? {} : { timerValue: every }),
|
|
@@ -176,12 +173,8 @@ export const scheduledTriggerType = {
|
|
|
176
173
|
noun: 'schedule',
|
|
177
174
|
serialize: (spec, ctx) => {
|
|
178
175
|
const version = scheduledVersion(spec.inputs, ctx.version);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const inputs = ctx.root.isDefault
|
|
182
|
-
? scheduleInputs(spec.inputs, ctx.root.id, version)
|
|
183
|
-
: { entryPointId: ctx.entryPointId(), ...scheduleInputs(spec.inputs, ctx.root.id, version) };
|
|
184
|
-
return { version, inputs };
|
|
176
|
+
const entryPointId = ctx.root.isDefault ? ctx.entryPointId('start') : ctx.entryPointId();
|
|
177
|
+
return { version, inputs: scheduleInputs(spec.inputs, entryPointId, version) };
|
|
185
178
|
},
|
|
186
179
|
deserialize: (node) => ({ kind: 'scheduled', inputs: { every: scheduleEvery(node) } }),
|
|
187
180
|
print: (spec, ctx) => ({ factory: 'scheduled', options: [['every', ctx.string(spec.inputs.every)]] }),
|
|
@@ -219,10 +212,10 @@ export const formTriggerType = {
|
|
|
219
212
|
* Both are entry points (`model.entryPointId: true`) with nothing else
|
|
220
213
|
* authored: what the platform started — the conversation, or the live call's
|
|
221
214
|
* `callContext` — is the trigger's own declared output. The default root's
|
|
222
|
-
* identity is
|
|
215
|
+
* identity is minted too: pack copies it into entry-points.json `uniqueId`, which is a GUID.
|
|
223
216
|
*/
|
|
224
217
|
function platformStartedInputs(ctx) {
|
|
225
|
-
return { inputs: { entryPointId: ctx.root.isDefault ? ctx.
|
|
218
|
+
return { inputs: { entryPointId: ctx.root.isDefault ? ctx.entryPointId('start') : ctx.entryPointId() } };
|
|
226
219
|
}
|
|
227
220
|
/** The conversation-trigger version an unpinned `conversationTrigger()` writes: the platform's current one, which has an appearance. */
|
|
228
221
|
const CONVERSATION_DEFAULT_VERSION = '1.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.90.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",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"@types/node": "^22.7.0",
|
|
111
111
|
"esbuild": "^0.28.1"
|
|
112
112
|
},
|
|
113
|
-
"gitref": "
|
|
113
|
+
"gitref": "2d54d6aa56285f53167cff2277bcf3e4bd73751b"
|
|
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
|
-
}
|