@uipath/maestro-builder-sdk 6.88.3 → 6.89.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.
- package/dist/case/check-cli.js +114 -4
- package/dist/case/check.d.ts +7 -0
- package/dist/case/check.js +5 -0
- package/dist/case/registry-resolved.d.ts +121 -0
- package/dist/case/registry-resolved.js +155 -0
- package/dist/cli/commands/case.js +7 -0
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +3 -0
- package/dist/nodes/trigger/flow/node-type.js +8 -15
- package/package.json +2 -2
package/dist/case/check-cli.js
CHANGED
|
@@ -4,11 +4,21 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Usage: node --experimental-strip-types check-cli.js <case.ts | BaseName> \
|
|
6
6
|
* [--library <library-json dir>] [--connectors-local <overlay dir>] [--bindings <bindings.json>] \
|
|
7
|
-
* [-o <the plan compile writes>] [--resources <resources.json>]
|
|
7
|
+
* [-o <the plan compile writes>] [--resources <resources.json>] \
|
|
8
|
+
* [--registry-resolved <tasks/registry-resolved.json> | --no-registry-resolved]
|
|
8
9
|
* Exits 0 when clean (warnings allowed), 1 on any error.
|
|
9
10
|
*
|
|
10
11
|
* The library is opened exactly as `compile-cli` opens it (`openCliLibrary`), so
|
|
11
12
|
* a connector task `compile` cannot resolve fails here first (#1014).
|
|
13
|
+
*
|
|
14
|
+
* `--registry-resolved <file>` holds each resource task to the resource the
|
|
15
|
+
* SDD resolved it to (RESOURCE_NOT_AS_RESOLVED). With no file named, check
|
|
16
|
+
* looks where `uip maestro case sdd resolve` writes it (`registryCandidates`).
|
|
17
|
+
* A file found there that gives no entries is reported and passed over; a
|
|
18
|
+
* named one is an error. The file read, how many resource tasks it judged, the
|
|
19
|
+
* tasks it had no entry for, and the entries it could not use are printed, so
|
|
20
|
+
* the check is never silent. `--no-registry-resolved` turns it off for an
|
|
21
|
+
* author who chose another resource on purpose, and check says so.
|
|
12
22
|
*/
|
|
13
23
|
import { reportDiagnostics } from '../cli-result.js';
|
|
14
24
|
import { resolveCaseFile, loadBuiltCase } from './load.js';
|
|
@@ -20,9 +30,71 @@ import { runWhenInvokedDirectly } from '../cli-run.js';
|
|
|
20
30
|
import { ensureTypeScriptRuntime } from '../node-runtime.js';
|
|
21
31
|
import { defaultResourcesFile } from '../workdir.js';
|
|
22
32
|
import { readCliResources } from '../registry/prepare/resources.js';
|
|
33
|
+
import { DEFAULT_REGISTRY_RESOLVED, RESOLVE_COMMAND, readRegistryResolved, registryResolvedCoverage } from './registry-resolved.js';
|
|
34
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
35
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
23
36
|
/** Flags that take a value: their argument is never the source positional. */
|
|
24
|
-
const VALUE_FLAGS = new Set(['--library', '--connectors-local', '--bindings', '--resources', '-o']);
|
|
25
|
-
const USAGE = 'usage: check <case.ts | BaseName> [--library <dir>] [--connectors-local <dir>] [--bindings <file>] [--resources <file>] [-o <plan>]';
|
|
37
|
+
const VALUE_FLAGS = new Set(['--library', '--connectors-local', '--bindings', '--resources', '--registry-resolved', '-o']);
|
|
38
|
+
const USAGE = 'usage: check <case.ts | BaseName> [--library <dir>] [--connectors-local <dir>] [--bindings <file>] [--resources <file>] [--registry-resolved <file> | --no-registry-resolved] [-o <plan>]';
|
|
39
|
+
/**
|
|
40
|
+
* Where to look for the SDD's resolutions when no file is named: the working
|
|
41
|
+
* directory's `tasks/`, then beside the case file and up to two directories
|
|
42
|
+
* above it, under `tasks/` or at the root (cli `findRegistryLedger`). The
|
|
43
|
+
* authoring layout puts the case at `<workspace>/<solution>/<project>/` and the
|
|
44
|
+
* file at `<workspace>/tasks/`, so check run from either place finds it.
|
|
45
|
+
*/
|
|
46
|
+
function registryCandidates(caseFile) {
|
|
47
|
+
const dir = dirname(resolve(caseFile));
|
|
48
|
+
const all = [resolve(DEFAULT_REGISTRY_RESOLVED)];
|
|
49
|
+
for (const up of ['', '..', join('..', '..')])
|
|
50
|
+
for (const leaf of ['tasks', '.'])
|
|
51
|
+
all.push(resolve(dir, up, leaf, 'registry-resolved.json'));
|
|
52
|
+
return [...new Set(all)];
|
|
53
|
+
}
|
|
54
|
+
const shown = (file) => relative(process.cwd(), file) || file;
|
|
55
|
+
/** Read one registry-resolved file: its resolutions, or why it gives none. */
|
|
56
|
+
function readRegistryFile(file) {
|
|
57
|
+
let json;
|
|
58
|
+
try {
|
|
59
|
+
json = JSON.parse(readFileSync(file, 'utf8'));
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
return { why: `not JSON (${e.message})` };
|
|
63
|
+
}
|
|
64
|
+
const registry = readRegistryResolved(json);
|
|
65
|
+
return registry ? { registry: { ...registry, file: shown(file) } } : { why: 'no resolved entries (no object with a "task" and a "selected")' };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The SDD's resolutions. A file named with `--registry-resolved` must give
|
|
69
|
+
* some: if not, that is an error. Otherwise the first candidate that gives
|
|
70
|
+
* some is used, and each candidate passed over is reported in `notes`.
|
|
71
|
+
* `--no-registry-resolved` reads none, and says so when a candidate exists.
|
|
72
|
+
*/
|
|
73
|
+
function cliRegistryResolved(argv, caseFile) {
|
|
74
|
+
const i = argv.indexOf('--registry-resolved');
|
|
75
|
+
const named = i >= 0 ? argv[i + 1] : undefined;
|
|
76
|
+
const found = () => registryCandidates(caseFile).filter((f) => existsSync(f));
|
|
77
|
+
if (argv.includes('--no-registry-resolved')) {
|
|
78
|
+
if (i >= 0)
|
|
79
|
+
return { error: '--registry-resolved and --no-registry-resolved are both given. Remove one of them.', notes: [] };
|
|
80
|
+
const first = found()[0];
|
|
81
|
+
return { notes: first ? [`check: ${shown(first)} not read (--no-registry-resolved): resource tasks are not held to the SDD's resolutions.`] : [] };
|
|
82
|
+
}
|
|
83
|
+
if (named !== undefined) {
|
|
84
|
+
if (!existsSync(resolve(named)))
|
|
85
|
+
return { error: `cannot read ${named}: no such file. Name the file \`${RESOLVE_COMMAND}\` wrote, or drop --registry-resolved.`, notes: [] };
|
|
86
|
+
const { registry, why } = readRegistryFile(resolve(named));
|
|
87
|
+
return registry ? { registry, notes: [] } : { error: `cannot read ${named}: ${why}. Fix the file, or drop --registry-resolved.`, notes: [] };
|
|
88
|
+
}
|
|
89
|
+
const notes = [];
|
|
90
|
+
for (const file of found()) {
|
|
91
|
+
const { registry, why } = readRegistryFile(file);
|
|
92
|
+
if (registry)
|
|
93
|
+
return { registry, notes };
|
|
94
|
+
notes.push(`check: ${shown(file)} not read: ${why}. Resource tasks are not held to it.`);
|
|
95
|
+
}
|
|
96
|
+
return { notes };
|
|
97
|
+
}
|
|
26
98
|
export async function run(argv) {
|
|
27
99
|
if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
|
|
28
100
|
console.error(USAGE);
|
|
@@ -40,7 +112,45 @@ export async function run(argv) {
|
|
|
40
112
|
// binding-label rules (#1034): `-o` names the plan as it does for compile.
|
|
41
113
|
const { bindings } = caseCompileTarget(argv);
|
|
42
114
|
const resources = readCliResources(argv, defaultResourcesFile());
|
|
43
|
-
const
|
|
115
|
+
const resolved = cliRegistryResolved(argv, file);
|
|
116
|
+
if (resolved.error) {
|
|
117
|
+
console.error(`check: ${resolved.error}`);
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
for (const note of resolved.notes)
|
|
121
|
+
console.error(note);
|
|
122
|
+
if (resolved.registry) {
|
|
123
|
+
const cover = registryResolvedCoverage(built, resolved.registry);
|
|
124
|
+
const quoted = (names) => names.map((n) => JSON.stringify(n)).join(', ');
|
|
125
|
+
const { resolved: list, unusable } = resolved.registry;
|
|
126
|
+
const inSolution = list.filter((e) => e.selected.inSolution).length;
|
|
127
|
+
const open = unusable.filter((e) => e.why === 'unresolved').length;
|
|
128
|
+
const noName = unusable.length - open;
|
|
129
|
+
console.error(`check: resource tasks held to ${resolved.registry.file}: ${cover.held} of ${cover.held + cover.noEntry.length + cover.ambiguous.length + cover.unusable.length} judged`
|
|
130
|
+
+ ` (${list.length} resolution(s)${open ? `, ${open} unresolved` : ''}`
|
|
131
|
+
+ `${noName ? `, ${noName} with no selected name` : ''}`
|
|
132
|
+
+ `${inSolution ? `, ${inSolution} with no folder, read as solution_folder (a project in this solution)` : ''}).`);
|
|
133
|
+
if (cover.noEntry.length)
|
|
134
|
+
console.error(`check: not judged, no entry with this task name: ${quoted(cover.noEntry)}. `
|
|
135
|
+
+ 'Use the SDD\'s task name, or resolve the task again.');
|
|
136
|
+
if (cover.ambiguous.length)
|
|
137
|
+
console.error(`check: not judged, more than one entry has this task name and none is in the task's stage: ${quoted(cover.ambiguous)}. `
|
|
138
|
+
+ 'Use the SDD\'s stage name, or resolve the task again.');
|
|
139
|
+
const unjudged = (why) => cover.unusable.filter((u) => u.why === why).map((u) => u.task);
|
|
140
|
+
if (unjudged('unresolved').length)
|
|
141
|
+
console.error(`check: not judged, the SDD left the task unresolved (selected: null): ${quoted(unjudged('unresolved'))}. `
|
|
142
|
+
+ 'A resource created for it is not checked against the SDD.');
|
|
143
|
+
if (unjudged('no-name').length)
|
|
144
|
+
console.error(`check: not judged, the entry's selection has no string name: ${quoted(unjudged('no-name'))}. `
|
|
145
|
+
+ `Fix the entry, or resolve the task again (\`${RESOLVE_COMMAND}\`).`);
|
|
146
|
+
if (cover.unused.length)
|
|
147
|
+
console.error(`check: no resource task matched these resolutions: ${quoted(cover.unused)}.`);
|
|
148
|
+
}
|
|
149
|
+
const diags = check(built, {
|
|
150
|
+
...caseCheckOpts(openCliLibrary(argv), bindings),
|
|
151
|
+
...(resources ? { resources } : {}),
|
|
152
|
+
...(resolved.registry ? { registryResolved: resolved.registry } : {}),
|
|
153
|
+
});
|
|
44
154
|
reportDiagnostics(diags);
|
|
45
155
|
for (const d of diags)
|
|
46
156
|
console.error(` ${d.level === 'error' ? '✗' : '⚠'} [${d.code}] ${d.message}`);
|
package/dist/case/check.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { BuiltCase } from './case-sdk.js';
|
|
15
15
|
import { type ConnectorCheckOpts } from '../core/connector-checks.js';
|
|
16
|
+
import { type RegistryResolved } from './registry-resolved.js';
|
|
16
17
|
import type { Library } from '../core/library.js';
|
|
17
18
|
export interface Diagnostic {
|
|
18
19
|
level: 'error' | 'warning';
|
|
@@ -43,6 +44,12 @@ export interface Diagnostic {
|
|
|
43
44
|
export type CaseCheckOpts = Pick<ConnectorCheckOpts, 'lookups' | 'resolutions' | 'resources' | 'schemaReadiness' | 'bindings'> & {
|
|
44
45
|
/** The library `compile` serializes against, for the serializer `check` runs. */
|
|
45
46
|
library?: Library;
|
|
47
|
+
/**
|
|
48
|
+
* The resources the SDD resolved each task to (`tasks/registry-resolved.json`,
|
|
49
|
+
* read with `readRegistryResolved`). A resource task whose name or folder
|
|
50
|
+
* differs is RESOURCE_NOT_AS_RESOLVED. Omit it and no task is judged.
|
|
51
|
+
*/
|
|
52
|
+
registryResolved?: RegistryResolved;
|
|
46
53
|
};
|
|
47
54
|
/**
|
|
48
55
|
* Validate a built case.
|
package/dist/case/check.js
CHANGED
|
@@ -9,6 +9,7 @@ import { caseJsonPreservation } from './preserve.js';
|
|
|
9
9
|
import { scriptLint } from './script.js';
|
|
10
10
|
import { httpRequestLint } from './http-request.js';
|
|
11
11
|
import { checkRuleSemantics } from './check-rule-semantics.js';
|
|
12
|
+
import { registryResolvedLint } from './registry-resolved.js';
|
|
12
13
|
import { serialize } from './serialize.js';
|
|
13
14
|
import { lintPlanFindings, planReport } from './plan-check/index.js';
|
|
14
15
|
import { caseExprLints } from './case-expr-check.js';
|
|
@@ -246,6 +247,10 @@ export function check(built, opts = {}) {
|
|
|
246
247
|
for (const f of httpRequestLint(`HTTP request task "${t.name}"`, t.http))
|
|
247
248
|
diags.push({ level: 'error', code: f.code, message: f.message, ...(f.suggestion ? { suggestion: f.suggestion } : {}), where: t.name });
|
|
248
249
|
checkRuleSemantics(built, diags);
|
|
250
|
+
// A resource task bound to another resource than the SDD resolved (lint).
|
|
251
|
+
if (opts.registryResolved)
|
|
252
|
+
for (const f of registryResolvedLint(built, opts.registryResolved))
|
|
253
|
+
diags.push({ level: 'error', code: f.code, message: f.message, suggestion: f.suggestion, where: f.where });
|
|
249
254
|
checkLibraryConnectors(built, opts, diags);
|
|
250
255
|
diags.push(...serializerRefusals(built, opts, diags, reportedReads));
|
|
251
256
|
return diags;
|
|
@@ -0,0 +1,121 @@
|
|
|
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[];
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
}
|
|
@@ -30,6 +30,9 @@ export function registerCaseCommands(program) {
|
|
|
30
30
|
.option('--connectors-local <dir>', 'connection-resolved connector overlay')
|
|
31
31
|
.option('--bindings <file>', 'bindings.json, for the connection/folder label rules')
|
|
32
32
|
.option('--resources <file>', 'resource ledger that registry prepare writes (default .flow-sdk/resources.json)')
|
|
33
|
+
.option('--registry-resolved <file>', 'the resources `uip maestro case sdd resolve` resolved each task to (default tasks/registry-resolved.json)')
|
|
34
|
+
// Commander keeps the default undefined when --no-X follows --X: the value is a file, false, or unset.
|
|
35
|
+
.option('--no-registry-resolved', 'do not hold resource tasks to tasks/registry-resolved.json')
|
|
33
36
|
.addOption(retiredCompiledOption())
|
|
34
37
|
.action(async (input, options) => {
|
|
35
38
|
let mode;
|
|
@@ -49,6 +52,10 @@ export function registerCaseCommands(program) {
|
|
|
49
52
|
addValue(argv, '--connectors-local', options.connectorsLocal);
|
|
50
53
|
addValue(argv, '--bindings', options.bindings);
|
|
51
54
|
addValue(argv, '--resources', options.resources);
|
|
55
|
+
if (options.registryResolved === false)
|
|
56
|
+
argv.push('--no-registry-resolved');
|
|
57
|
+
else
|
|
58
|
+
addValue(argv, '--registry-resolved', options.registryResolved);
|
|
52
59
|
await invoke('case check', () => import('../../case/check-cli.js'), argv);
|
|
53
60
|
});
|
|
54
61
|
family.command('decompile')
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -624,6 +624,7 @@ export declare const REFUSALS: {
|
|
|
624
624
|
readonly RESOURCE_REF_IS_BINDING: "lowering";
|
|
625
625
|
readonly RESOURCE_ROW_INCOMPLETE: "lowering";
|
|
626
626
|
readonly RESOURCE_UNRESOLVED: "lowering";
|
|
627
|
+
readonly RESOURCE_NOT_AS_RESOLVED: "lint";
|
|
627
628
|
readonly RETRY_BASE_WITHOUT_EXPONENTIAL: "lint";
|
|
628
629
|
readonly RETRY_INVALID_COUNT: "lint";
|
|
629
630
|
readonly RETRY_INVALID_DURATION: "lint";
|
package/dist/core/refusals.js
CHANGED
|
@@ -698,6 +698,9 @@ export const REFUSALS = {
|
|
|
698
698
|
RESOURCE_REF_IS_BINDING: 'lowering',
|
|
699
699
|
RESOURCE_ROW_INCOMPLETE: 'lowering',
|
|
700
700
|
RESOURCE_UNRESOLVED: 'lowering',
|
|
701
|
+
// Case check (case/registry-resolved.ts): a resource task's name or folder is
|
|
702
|
+
// not the one tasks/registry-resolved.json resolved; compile writes it as authored.
|
|
703
|
+
RESOURCE_NOT_AS_RESOLVED: 'lint',
|
|
701
704
|
RETRY_BASE_WITHOUT_EXPONENTIAL: 'lint',
|
|
702
705
|
RETRY_INVALID_COUNT: 'lint',
|
|
703
706
|
RETRY_INVALID_DURATION: 'lint',
|
|
@@ -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.89.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": "
|
|
113
|
+
"gitref": "84d87f63b6f8b64c55eb483c87e818b2efa1b4da"
|
|
114
114
|
}
|