@uipath/maestro-builder-sdk 6.107.0 → 6.108.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/serialize.js CHANGED
@@ -2256,11 +2256,12 @@ function serializeFlow(built, opts) {
2256
2256
  */
2257
2257
  function emitRegistered(entry, step, tails, scope, parentId) {
2258
2258
  const where = `step "${step.name}"`;
2259
- const spec = step.spec;
2260
2259
  // A pin the registry has no implementation for, but the flow carries, is
2261
2260
  // emitted at that version with the carried definition (#1128).
2262
- const resolved = resolveVersionCarried(entry.type, spec, step.options?.version, where, carriedFor);
2261
+ const resolved = resolveVersionCarried(entry.type, step.spec, step.options?.version, where, carriedFor);
2263
2262
  const impl = resolved.impl;
2263
+ // What the solution says about a sibling the step names (#1978), as check reads it.
2264
+ const spec = impl.withSolution ? impl.withSolution(step.spec, opts.solution) : step.spec;
2264
2265
  const version = resolved.version;
2265
2266
  const id = stepUid(scope, step.name);
2266
2267
  if (impl.capsOpenTail)
@@ -2311,6 +2312,7 @@ function serializeFlow(built, opts) {
2311
2312
  // to the step's next resource (two tools on one process share it).
2312
2313
  bind: (b) => { bound.push(b); resourceBindings.set(b.id, b); },
2313
2314
  resources: opts.resources,
2315
+ ...(opts.solution !== undefined ? { solution: opts.solution } : {}),
2314
2316
  // At a carried version the node's own definition IS the carried one,
2315
2317
  // whatever version the implementation asks for (it was written for a
2316
2318
  // bundled one), so its defaults and outputs come from the file's entry.
@@ -0,0 +1,6 @@
1
+ import type { SolutionProjects } from './core/solution-projects.js';
2
+ /**
3
+ * The solution `fromDir` sits in, and its sibling projects; `undefined` when
4
+ * no folder at or above `fromDir` holds a `.uipx`.
5
+ */
6
+ export declare function readSolutionProjects(fromDir: string): SolutionProjects | undefined;
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Reading a solution's sibling projects from disk, for `compile-cli` and
3
+ * `check-cli` (#1978). Apart from `core/solution-projects.ts`, whose shape the
4
+ * serializer and `check` read, so the flow core loads no `node:fs` (FB015).
5
+ *
6
+ * What is read, and where it comes from:
7
+ *
8
+ * - the solution folder: the nearest folder at or above the flow that holds a
9
+ * `*.uipx` (`solutionRoot`, which `registry prepare` and Case's orphan
10
+ * report use too);
11
+ * - every `resources/solution_folder/process/<type>/<Project>.json`, the
12
+ * resource file `uip solution resources refresh` writes for each project:
13
+ * `resource.name`, `resource.type`, `resource.key`, `resource.projectKey`;
14
+ * - each project's `entry-points.json`, found through the `.uipx` project
15
+ * whose `Id` is the resource's `projectKey` (else the folder named after the
16
+ * project), in the three places uipath-cli's `registry get --local` reads
17
+ * (`./`, `content/`, then `.local/content/`, where `uip rpa build` writes it),
18
+ * else, for a Flow project, the outputs its `.flow` declares.
19
+ *
20
+ * A file that is missing or does not parse is skipped, as the CLI's own reader
21
+ * skips it: one broken resource file must not fail a compile that does not
22
+ * call that project.
23
+ */
24
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
25
+ import { dirname, join, relative, resolve } from 'node:path';
26
+ import { isRecord } from './core/node-envelope.js';
27
+ import { sameGuid } from './core/solution-projects.js';
28
+ import { solutionRoot } from './registry/prepare/resources.js';
29
+ /** Parse a JSON file, or `undefined` when it is absent or is not JSON. */
30
+ function readJson(path) {
31
+ try {
32
+ return JSON.parse(readFileSync(path, 'utf8'));
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ }
38
+ /** The `.uipx` projects: id → the project's folder. */
39
+ function uipxProjectDirs(solutionDir) {
40
+ let entries;
41
+ try {
42
+ entries = readdirSync(solutionDir);
43
+ }
44
+ catch {
45
+ return [];
46
+ }
47
+ const uipx = entries.find((e) => e.endsWith('.uipx'));
48
+ if (uipx === undefined)
49
+ return [];
50
+ const parsed = readJson(join(solutionDir, uipx));
51
+ const projects = isRecord(parsed) && Array.isArray(parsed.Projects) ? parsed.Projects : [];
52
+ return projects.flatMap((p) => (isRecord(p) && typeof p.Id === 'string' && typeof p.ProjectRelativePath === 'string'
53
+ ? [{ id: p.Id, dir: resolve(solutionDir, dirname(p.ProjectRelativePath)) }]
54
+ : []));
55
+ }
56
+ /** The first entry point of the first `entry-points.json` that has one. */
57
+ function firstEntryPoint(projectDir) {
58
+ for (const path of [
59
+ join(projectDir, 'entry-points.json'),
60
+ join(projectDir, 'content', 'entry-points.json'),
61
+ join(projectDir, '.local', 'content', 'entry-points.json'),
62
+ ]) {
63
+ const parsed = readJson(path);
64
+ const entry = isRecord(parsed) && Array.isArray(parsed.entryPoints) ? parsed.entryPoints[0] : undefined;
65
+ if (isRecord(entry))
66
+ return entry;
67
+ }
68
+ return undefined;
69
+ }
70
+ /** `{ <field>: <type> }` from a JSON schema's `properties`; undefined when it has none. */
71
+ function schemaFields(schema) {
72
+ if (!isRecord(schema) || !isRecord(schema.properties))
73
+ return undefined;
74
+ const fields = {};
75
+ for (const [name, field] of Object.entries(schema.properties)) {
76
+ fields[name] = isRecord(field) && typeof field.type === 'string' ? field.type : 'object';
77
+ }
78
+ return fields;
79
+ }
80
+ /**
81
+ * The outputs a Flow project declares in its `.flow` (`variables.globals` with
82
+ * direction `out` or `inout`), for a sibling Flow no pack has written
83
+ * `entry-points.json` for yet: the fallback `registry get --local` takes too.
84
+ */
85
+ function flowOutputs(projectDir) {
86
+ let flowFile;
87
+ try {
88
+ flowFile = readdirSync(projectDir).sort().find((e) => e.endsWith('.flow'));
89
+ }
90
+ catch {
91
+ return undefined;
92
+ }
93
+ if (flowFile === undefined)
94
+ return undefined;
95
+ const parsed = readJson(join(projectDir, flowFile));
96
+ const globals = isRecord(parsed) && isRecord(parsed.variables) ? parsed.variables.globals : undefined;
97
+ if (!Array.isArray(globals))
98
+ return undefined;
99
+ const fields = {};
100
+ for (const g of globals) {
101
+ if (!isRecord(g) || typeof g.id !== 'string' || (g.direction !== 'out' && g.direction !== 'inout'))
102
+ continue;
103
+ fields[g.id] = typeof g.type === 'string' ? g.type : 'string';
104
+ }
105
+ return fields;
106
+ }
107
+ /**
108
+ * The solution `fromDir` sits in, and its sibling projects; `undefined` when
109
+ * no folder at or above `fromDir` holds a `.uipx`.
110
+ */
111
+ export function readSolutionProjects(fromDir) {
112
+ const dir = solutionRoot(fromDir);
113
+ if (dir === undefined)
114
+ return undefined;
115
+ const processDir = join(dir, 'resources', 'solution_folder', 'process');
116
+ if (!existsSync(processDir))
117
+ return { dir, projects: [] };
118
+ const uipx = uipxProjectDirs(dir);
119
+ const projects = [];
120
+ let typeDirs;
121
+ try {
122
+ typeDirs = readdirSync(processDir).sort();
123
+ }
124
+ catch {
125
+ return { dir, projects: [] };
126
+ }
127
+ for (const typeDir of typeDirs) {
128
+ let files;
129
+ try {
130
+ files = readdirSync(join(processDir, typeDir)).sort();
131
+ }
132
+ catch {
133
+ continue;
134
+ }
135
+ for (const file of files) {
136
+ if (!file.endsWith('.json'))
137
+ continue;
138
+ const path = join(processDir, typeDir, file);
139
+ const parsed = readJson(path);
140
+ const resource = isRecord(parsed) ? parsed.resource : undefined;
141
+ if (!isRecord(resource))
142
+ continue;
143
+ const { name, key, projectKey } = resource;
144
+ if (typeof name !== 'string' || typeof key !== 'string' || typeof projectKey !== 'string')
145
+ continue;
146
+ if (name === '' || key === '' || projectKey === '')
147
+ continue;
148
+ const projectDir = uipx.find((p) => sameGuid(p.id, projectKey))?.dir ?? join(dir, name);
149
+ const entry = firstEntryPoint(projectDir);
150
+ const outputs = entry !== undefined ? schemaFields(entry.output) : flowOutputs(projectDir);
151
+ projects.push({
152
+ name,
153
+ resourceType: typeof resource.type === 'string' ? resource.type : typeDir,
154
+ key,
155
+ projectId: projectKey,
156
+ file: relative(dir, path).split('\\').join('/'),
157
+ ...(typeof entry?.type === 'string' ? { entryPointType: entry.type } : {}),
158
+ ...(outputs !== undefined ? { outputs } : {}),
159
+ });
160
+ }
161
+ }
162
+ return { dir, projects };
163
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.107.0",
3
+ "version": "6.108.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",
@@ -123,5 +123,5 @@
123
123
  "@types/node": "^22.7.0",
124
124
  "esbuild": "^0.28.1"
125
125
  },
126
- "gitref": "4295f20ce709d1016209913e4bfc43b93ee986ef"
126
+ "gitref": "1e8b322d60aba10f23ac264525a341eda6b10b88"
127
127
  }