@uipath/maestro-builder-sdk 6.86.22 → 6.86.23

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.
@@ -33,6 +33,7 @@ import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
33
33
  import { ensureTypeScriptRuntime } from '../node-runtime.js';
34
34
  import { CASE_FORMAT_PROFILE } from './format-profile.js';
35
35
  import { deriveCaseBindingsV2 } from './bindings-v2.js';
36
+ import { orphanWarnings } from './orphaned-resources.js';
36
37
  import { BINDINGS_V2_DOCUMENT_VERSION } from '../core/bindings-v2-resource.js';
37
38
  import { sha256Uuid } from '../core/stable-id.js';
38
39
  export async function run(argv) {
@@ -88,6 +89,8 @@ export async function run(argv) {
88
89
  // (`reportCompileRefusal`, shared with Flow and BPMN).
89
90
  return reportCompileRefusal(error, { before: warnings });
90
91
  }
92
+ // Solution declarations no project binds once this derivation lands.
93
+ warnings.push(...orphanWarnings(caseplan, out));
91
94
  for (const w of warnings)
92
95
  console.error(` ${diagnosticLine(w)}`);
93
96
  // Reported before the first write, so a write that throws still carries it.
@@ -0,0 +1,3 @@
1
+ import type { Diagnostic } from './check.js';
2
+ /** Warnings for the solution declarations of `outPath`'s solution that no project binds. */
3
+ export declare function orphanWarnings(caseplan: Record<string, unknown>, outPath: string): Diagnostic[];
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Solution declarations no project binds any more (ORPHANED_SOLUTION_RESOURCE).
3
+ *
4
+ * `case compile` rewrites the project's `bindings_v2.json` from the source, so
5
+ * a resource-bound task removed from the source drops its row. Its declaration
6
+ * under `<solution>/resources/solution_folder/` stays: `uip solution resources
7
+ * refresh` only adds, `uip maestro case validate` reads neither file, and
8
+ * Studio Web provisioning fails on the unreferenced resource. Compile is the
9
+ * authoring step that runs after every edit, so it reports what is left.
10
+ *
11
+ * The orphans are derived from the solution as it is, not from the rows this
12
+ * compile dropped, so a recompile keeps reporting a declaration until it is
13
+ * removed. A declaration is reported when all of these hold:
14
+ * - its kind is one a sidecar binds (`process`, `app`); queues, assets and the
15
+ * rest never appear in `bindings_v2.json`, so their absence there means nothing;
16
+ * - it is not a project's own declaration (it carries no `projectKey`);
17
+ * - it is not a package (removing the process or app removes its package);
18
+ * - no project of the solution binds its kind and name (this Case's new
19
+ * derivation, or another project's `bindings_v2.json`), and no bound
20
+ * declaration depends on it: refresh imports an Action App's `webApp`
21
+ * process as a dependency of the app, and the sidecar names only the app.
22
+ *
23
+ * Identity is kind + name. A declaration's `folders` is the solution folder,
24
+ * not the tenant folder the binding names, so the tenant folder cannot be
25
+ * compared; the solution itself keys declarations by kind and name.
26
+ */
27
+ import { readFileSync, readdirSync, existsSync } from 'node:fs';
28
+ import { join, dirname, resolve } from 'node:path';
29
+ import { deriveCaseBindingsV2 } from './bindings-v2.js';
30
+ import { solutionRoot } from '../registry/prepare/resources.js';
31
+ const BOUND_KINDS = new Set(['process', 'app']);
32
+ const identity = (kind, name) => typeof kind === 'string' && typeof name === 'string' ? `${kind.toLowerCase()}\u0000${name}` : undefined;
33
+ /** Warnings for the solution declarations of `outPath`'s solution that no project binds. */
34
+ export function orphanWarnings(caseplan, outPath) {
35
+ const projectDir = dirname(resolve(outPath));
36
+ const solutionDir = solutionRoot(projectDir);
37
+ if (!solutionDir)
38
+ return [];
39
+ const declarations = solutionDeclarations(join(solutionDir, 'resources', 'solution_folder'));
40
+ if (declarations.length === 0)
41
+ return [];
42
+ const bound = new Set();
43
+ for (const r of deriveCaseBindingsV2(caseplan)) {
44
+ const id = identity(r?.resource, r?.value?.name?.defaultValue);
45
+ if (id)
46
+ bound.add(id);
47
+ }
48
+ for (const other of otherProjectDirs(solutionDir, projectDir)) {
49
+ const path = join(other, 'bindings_v2.json');
50
+ if (!existsSync(path))
51
+ continue;
52
+ const rows = readSidecar(path);
53
+ if (typeof rows === 'string') {
54
+ return [{
55
+ level: 'warning',
56
+ code: 'ORPHANED_SOLUTION_RESOURCE',
57
+ message: `cannot read ${path} (${rows}); orphaned solution declarations were not checked.`,
58
+ }];
59
+ }
60
+ for (const r of rows) {
61
+ const id = identity(r?.resource, r?.value?.name?.defaultValue);
62
+ if (id)
63
+ bound.add(id);
64
+ }
65
+ }
66
+ // Whatever a bound declaration depends on, transitively, is bound too.
67
+ const byId = new Map(declarations.map((d) => [identity(d.kind, d.name), d]));
68
+ const queue = [...bound];
69
+ while (queue.length > 0) {
70
+ for (const dep of byId.get(queue.pop())?.dependsOn ?? []) {
71
+ if (!bound.has(dep)) {
72
+ bound.add(dep);
73
+ queue.push(dep);
74
+ }
75
+ }
76
+ }
77
+ const quoted = JSON.stringify(solutionDir);
78
+ return declarations
79
+ .filter((d) => BOUND_KINDS.has(d.kind.toLowerCase()) && !d.own && !bound.has(identity(d.kind, d.name)))
80
+ .map((d) => ({
81
+ level: 'warning',
82
+ code: 'ORPHANED_SOLUTION_RESOURCE',
83
+ message: `${d.kind.toLowerCase()} "${d.name}" is declared in ${d.path}, but no project of the solution binds it. ` +
84
+ `resources refresh only adds and validate does not read it, so it would ship and fail Studio Web provisioning.`,
85
+ suggestion: `uip solution resources remove ${d.key} --solution-folder ${quoted} --output json ` +
86
+ `(removes its package declaration too), then uip solution resources refresh --solution-folder ${quoted} --output json`,
87
+ }));
88
+ }
89
+ /** The sidecar's rows, or the reason it cannot be read. */
90
+ function readSidecar(path) {
91
+ try {
92
+ const doc = JSON.parse(readFileSync(path, 'utf8'));
93
+ return Array.isArray(doc?.resources) ? doc.resources : [];
94
+ }
95
+ catch (error) {
96
+ return error instanceof Error ? error.message : String(error);
97
+ }
98
+ }
99
+ /** The other projects the solution manifest registers. */
100
+ function otherProjectDirs(solutionDir, projectDir) {
101
+ const dirs = [];
102
+ for (const name of readdirSync(solutionDir).filter((n) => n.endsWith('.uipx'))) {
103
+ try {
104
+ const manifest = JSON.parse(readFileSync(join(solutionDir, name), 'utf8'));
105
+ for (const p of Array.isArray(manifest?.Projects) ? manifest.Projects : []) {
106
+ if (typeof p?.ProjectRelativePath !== 'string')
107
+ continue;
108
+ const dir = resolve(solutionDir, dirname(p.ProjectRelativePath));
109
+ if (dir !== projectDir)
110
+ dirs.push(dir);
111
+ }
112
+ }
113
+ catch {
114
+ // An unreadable manifest names no other project.
115
+ }
116
+ }
117
+ return dirs;
118
+ }
119
+ /** Every non-package declaration under `resources/solution_folder/`, with its dependency edges. */
120
+ function solutionDeclarations(root) {
121
+ const found = [];
122
+ const walk = (dir) => {
123
+ let entries;
124
+ try {
125
+ entries = readdirSync(dir, { withFileTypes: true });
126
+ }
127
+ catch {
128
+ return;
129
+ }
130
+ for (const e of entries) {
131
+ const path = join(dir, e.name);
132
+ if (e.isDirectory()) {
133
+ if (dir === root && e.name.toLowerCase() === 'package')
134
+ continue;
135
+ walk(path);
136
+ }
137
+ else if (e.name.endsWith('.json')) {
138
+ try {
139
+ const r = JSON.parse(readFileSync(path, 'utf8'))?.resource ?? {};
140
+ // `resources remove` takes the solution key, `resource.key` (a GUID), not the sidecar key.
141
+ if (typeof r.kind !== 'string' || typeof r.name !== 'string' || typeof r.key !== 'string')
142
+ continue;
143
+ const dependsOn = (Array.isArray(r.dependencies) ? r.dependencies : [])
144
+ .map((d) => identity(d?.kind, d?.name))
145
+ .filter((id) => id !== undefined);
146
+ found.push({ kind: r.kind, name: r.name, key: r.key, path, own: r.projectKey !== undefined, dependsOn });
147
+ }
148
+ catch {
149
+ // Not a declaration.
150
+ }
151
+ }
152
+ }
153
+ };
154
+ walk(root);
155
+ return found.sort((a, b) => a.path.localeCompare(b.path));
156
+ }
@@ -555,6 +555,7 @@ export declare const REFUSALS: {
555
555
  readonly NO_START: "lint";
556
556
  readonly OBJECT_UNPREPARED: "lint";
557
557
  readonly ONERROR_NO_ERROR_PORT: "lowering";
558
+ readonly ORPHANED_SOLUTION_RESOURCE: "lint";
558
559
  readonly OUTPUT_BACKING_COLLISION: "lowering";
559
560
  readonly OUTPUT_FORWARD_READ: "lint";
560
561
  readonly OUTPUT_ROWS_FIXED: "lint";
@@ -628,6 +628,7 @@ export const REFUSALS = {
628
628
  NO_START: 'lint',
629
629
  OBJECT_UNPREPARED: 'lint',
630
630
  ONERROR_NO_ERROR_PORT: 'lowering',
631
+ ORPHANED_SOLUTION_RESOURCE: 'lint',
631
632
  OUTPUT_BACKING_COLLISION: 'lowering',
632
633
  OUTPUT_FORWARD_READ: 'lint',
633
634
  OUTPUT_ROWS_FIXED: 'lint',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.86.22",
3
+ "version": "6.86.23",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -103,5 +103,5 @@
103
103
  "@types/node": "^22.7.0",
104
104
  "esbuild": "^0.28.1"
105
105
  },
106
- "gitref": "5f41a8dcaad179d995dfe163d6b72120b35a2690"
106
+ "gitref": "01b10b60d64048ea4ec6bcb904919687d906fae4"
107
107
  }