@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/merge-cli.js CHANGED
@@ -81,6 +81,7 @@ import { writeJsonFile } from './core/json-file.js';
81
81
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
82
82
  import { inlineAgentResources, mergeBindingsV2, projectBindingRows, refreshInlineAgentRows } from './bindings-v2.js';
83
83
  import { readBindingsV2, readInlineAgentFiles } from './bindings-v2-files.js';
84
+ import { readSolutionProjects } from './solution-projects-files.js';
84
85
  import { basename, dirname, join, relative, resolve } from 'node:path';
85
86
  import { MergeRefusedError, mergeFlowWithSidecars } from './merge.js';
86
87
  import { sidecarSetFromList } from './merge-sidecars.js';
@@ -313,7 +314,11 @@ export async function run(argv) {
313
314
  const bindings = derivedFrom || editedIsSource ? new Bindings(flagValue(argv, '--bindings') ?? defaultBindingsFile()) : undefined;
314
315
  // The node registry cache a manifest-less `rawNode` resolves from (#1981), read on first use.
315
316
  const nodeCatalog = readNodeCatalog();
316
- const compileOpts = { library, bindings, nodeCatalog };
317
+ // The solution the edited source sits in, read as compile and check read it, so a
318
+ // step named by `project` merges as it compiles (#1978).
319
+ const solution = readSolutionProjects(dirname(resolve(editedPath)));
320
+ const compileOpts = { library, bindings, nodeCatalog, ...(solution !== undefined ? { solution } : {}) };
321
+ const checkOpts = { ...flowCheckOpts(library, bindings), nodeCatalog, ...(solution !== undefined ? { solution } : {}) };
317
322
  // Resolved as decompile resolves it, so a split `.flow` merges as the document the
318
323
  // source was decompiled from.
319
324
  const originalParts = [];
@@ -334,7 +339,7 @@ export async function run(argv) {
334
339
  editedSidecars = compiled.sidecars;
335
340
  drafts = compiled.drafts;
336
341
  lowering = compiled.lowering.map(onNode);
337
- diagnostics = checkEdited(compiled.built, edited, { ...flowCheckOpts(library, bindings), nodeCatalog });
342
+ diagnostics = checkEdited(compiled.built, edited, checkOpts);
338
343
  }
339
344
  else {
340
345
  edited = JSON.parse(readFileSync(editedPath, 'utf8'));
@@ -435,7 +440,7 @@ export async function run(argv) {
435
440
  const baselineFindings = baselineCompile === undefined ? undefined : findingCounts([
436
441
  ...baselineCompile.drafts,
437
442
  ...baselineCompile.lowering,
438
- ...checkEdited(baselineCompile.built, baselineCompile.flow, { ...flowCheckOpts(library, bindings), nodeCatalog }).filter((d) => d.level === 'error'),
443
+ ...checkEdited(baselineCompile.built, baselineCompile.flow, checkOpts).filter((d) => d.level === 'error'),
439
444
  ]);
440
445
  const unplacedDrafts = splitUnplaced(unplaced, baselineFindings);
441
446
  const unplacedChecks = splitUnplaced(checked.unplaced, baselineFindings);
@@ -55,6 +55,11 @@ export const PROCESS_DIAGNOSTICS = {
55
55
  FUNCTION_READ_NOT_OUTPUT: { severity: 'error', summary: 'a function step read outside output' },
56
56
  FUNCTION_READ_UNKNOWN_FIELD: { severity: 'error', summary: 'a function step read of a field returns does not declare' },
57
57
  FUNCTION_READ_WITHOUT_RETURNS: { severity: 'error', summary: 'a function step field read with no returns' },
58
+ IN_SOLUTION_KEY_MISMATCH: { severity: 'error', summary: 'an in-solution process step whose key or projectId is not its project\'s' },
59
+ IN_SOLUTION_NO_SOLUTION: { severity: 'error', summary: 'an in-solution process step named by project, compiled outside a solution' },
60
+ IN_SOLUTION_PROJECT_NOT_FOUND: { severity: 'error', summary: 'an in-solution process step naming no project of the solution' },
61
+ IN_SOLUTION_PROJECT_PUBLISHED: { severity: 'error', summary: 'a process step naming a project with location published' },
62
+ IN_SOLUTION_WRONG_BUILDER: { severity: 'error', summary: 'an in-solution process step whose builder does not call its project\'s type' },
58
63
  RPA_KEY_NOT_KEY: { severity: 'error', summary: 'an RPA step whose key is not a GUID' },
59
64
  RPA_LOCAL_HAS_FOLDER: { severity: 'error', summary: 'an RPA step in-solution, with a folderPath' },
60
65
  RPA_LOCAL_NO_PROJECT_ID: { severity: 'warning', summary: 'an RPA step in-solution, with no projectId' },
@@ -127,10 +132,12 @@ export function checkRpaWorkflow(inputs, ctx) {
127
132
  at('RPA_NO_FOLDER', `RPA step "${step}" has no \`folderPath\`. The runtime starts the job by name + folder, so the `
128
133
  + `Orchestrator folder holding the process is required.`, `folderPath: 'Shared/uipath-maestro-flow/ProjectEuler RPA'`);
129
134
  }
130
- if (inSolution && blank(inputs?.projectId)) {
135
+ // A step named by `project` has its projectId filled by `withSolution`, or the
136
+ // serializer's IN_SOLUTION_* refusal says why it could not be (in-solution.ts).
137
+ if (inSolution && blank(inputs?.projectId) && blank(inputs?.project)) {
131
138
  at('RPA_LOCAL_NO_PROJECT_ID', noProjectIdMessage('RPA', step, 'process'), `projectId: '<resource.projectKey>'`);
132
139
  }
133
- else if (inSolution && !GUID_RE.test(String(inputs.projectId).trim())) {
140
+ else if (inSolution && !blank(inputs?.projectId) && !GUID_RE.test(String(inputs.projectId).trim())) {
134
141
  at('RPA_LOCAL_PROJECT_ID_NOT_GUID', `In-solution RPA step "${step}" has projectId ${JSON.stringify(inputs.projectId)}, which is not `
135
142
  + `the sibling project's GUID. Read \`resource.projectKey\` from the generated resource file.`, `projectId: '<resource.projectKey>'`);
136
143
  }
@@ -184,10 +191,10 @@ export function checkApiWorkflow(inputs, ctx) {
184
191
  + `Orchestrator folder holding the workflow is required. For an API workflow in the SAME solution, set `
185
192
  + `\`location: 'in-solution'\` and its \`projectId\` instead.`, `folderPath: 'Shared'`);
186
193
  }
187
- if (inSolution && blank(inputs?.projectId)) {
194
+ if (inSolution && blank(inputs?.projectId) && blank(inputs?.project)) {
188
195
  at('APIWF_LOCAL_NO_PROJECT_ID', noProjectIdMessage('API workflow', step, 'api'), `projectId: '<resource.projectKey>'`);
189
196
  }
190
- else if (inSolution && !GUID_RE.test(String(inputs.projectId).trim())) {
197
+ else if (inSolution && !blank(inputs?.projectId) && !GUID_RE.test(String(inputs.projectId).trim())) {
191
198
  at('APIWF_LOCAL_PROJECT_ID_NOT_GUID', `In-solution API workflow step "${step}" has projectId ${JSON.stringify(inputs.projectId)}, which is not `
192
199
  + `the sibling project's GUID. Read \`resource.projectKey\` from the generated resource file.`, `projectId: '<resource.projectKey>'`);
193
200
  }
@@ -235,10 +242,10 @@ export function checkPublishedFunction(inputs, ctx) {
235
242
  + `than assuming 'Shared'. For a coded function in the SAME solution, set \`location: 'in-solution'\` `
236
243
  + `and its \`projectId\` instead.`, `folderPath: 'Shared/acme-echo'`);
237
244
  }
238
- if (inSolution && blank(inputs?.projectId)) {
245
+ if (inSolution && blank(inputs?.projectId) && blank(inputs?.project)) {
239
246
  at('FUNCTION_LOCAL_NO_PROJECT_ID', noProjectIdMessage('function', step, 'function'), `projectId: '<resource.projectKey>'`);
240
247
  }
241
- else if (inSolution && !GUID_RE.test(String(inputs.projectId).trim())) {
248
+ else if (inSolution && !blank(inputs?.projectId) && !GUID_RE.test(String(inputs.projectId).trim())) {
242
249
  at('FUNCTION_LOCAL_PROJECT_ID_NOT_GUID', `In-solution function step "${step}" has projectId ${JSON.stringify(inputs.projectId)}, which is not `
243
250
  + `the sibling project's GUID. Read \`resource.projectKey\` from the generated resource file.`, `projectId: '<resource.projectKey>'`);
244
251
  }
@@ -318,11 +325,11 @@ export function checkAgenticProcess(inputs, ctx) {
318
325
  + `published process instead (drop \`location\` and \`projectId\`, set \`folderPath\`), or use `
319
326
  + `\`form: 'flow'\` if the sibling is a Flow.`, `location: 'published', folderPath: 'Shared/<folder>'`);
320
327
  }
321
- if (inSolution && blank(inputs?.projectId)) {
328
+ if (inSolution && blank(inputs?.projectId) && blank(inputs?.project)) {
322
329
  const folder = (ownEntry(AGENTIC_PROCESS_FORMS, inputs?.form ?? 'bpmn') ?? AGENTIC_PROCESS_FORMS.bpmn).solutionFolder;
323
330
  at('AGENTIC_LOCAL_NO_PROJECT_ID', noProjectIdMessage('agentic process', step, folder), `projectId: '<resource.projectKey>'`);
324
331
  }
325
- else if (inSolution && !GUID_RE.test(String(inputs.projectId).trim())) {
332
+ else if (inSolution && !blank(inputs?.projectId) && !GUID_RE.test(String(inputs.projectId).trim())) {
326
333
  at('AGENTIC_LOCAL_PROJECT_ID_NOT_GUID', `In-solution agentic process step "${step}" has projectId ${JSON.stringify(inputs.projectId)}, which is not `
327
334
  + `the sibling project's GUID. Read \`resource.projectKey\` from the generated resource file.`, `projectId: '<resource.projectKey>'`);
328
335
  }
@@ -496,12 +503,12 @@ export function checkAgent(inputs, ctx) {
496
503
  + `two same-named agents: this tenant has \`CountLetters\` in both \`Shared\` and `
497
504
  + `\`Shared/uipath-maestro-flow/CountLetters CodedAgent\`.`, `folderPath: 'Shared/uipath-maestro-flow/CountLetters LowCode'`);
498
505
  }
499
- if (inSolution && blank(inputs?.projectId)) {
506
+ if (inSolution && blank(inputs?.projectId) && blank(inputs?.project)) {
500
507
  at('AGENT_LOCAL_NO_PROJECT_ID', `In-solution agent step "${step}" has no \`projectId\`. Read \`resource.projectKey\` from `
501
508
  + `\`resources/solution_folder/process/agent/<project>.json\` after registering the sibling `
502
509
  + `with \`uip solution projects add\`.`, `projectId: '<resource.projectKey>'`);
503
510
  }
504
- else if (inSolution && !GUID_RE.test(String(inputs.projectId).trim())) {
511
+ else if (inSolution && !blank(inputs?.projectId) && !GUID_RE.test(String(inputs.projectId).trim())) {
505
512
  at('AGENT_LOCAL_PROJECT_ID_NOT_GUID', `In-solution agent step "${step}" has projectId ${JSON.stringify(inputs.projectId)}, which is not `
506
513
  + `the registered sibling project's GUID. Read \`resource.projectKey\` from the generated resource file.`, `projectId: '<resource.projectKey>'`);
507
514
  }
@@ -0,0 +1,32 @@
1
+ import { type ProcessKind } from '../../../core/process-resource.js';
2
+ import { type SolutionProject, type SolutionProjects } from '../../../core/solution-projects.js';
3
+ /** The factory call a sibling takes: its kind, and for an agentic process its form. */
4
+ interface Builder {
5
+ kind: ProcessKind;
6
+ form?: 'bpmn' | 'flow' | 'case';
7
+ /** The builder, for messages: `rpaWorkflow`, `agenticProcess` with form 'flow'. */
8
+ label: string;
9
+ /** How the call opens, for a suggestion: `agenticProcess({ form: 'flow', `. */
10
+ open: string;
11
+ }
12
+ /**
13
+ * The factory that calls `project`. The entry point's own type wins over the
14
+ * folder: `uip solution projects add` files a coded agent with no `ProjectType`
15
+ * under `process/function/`, while its `entry-points.json` still says `agent`.
16
+ */
17
+ export declare function builderOf(project: SolutionProject): Builder | undefined;
18
+ /**
19
+ * `inputs` with what the solution says about the sibling it names filled in.
20
+ * Only an in-solution step named by `project`, whose sibling is found and is
21
+ * this factory's, is filled; a field the author wrote is kept (a wrong one is
22
+ * `refuseInSolution`'s). Anything else is returned unchanged.
23
+ */
24
+ export declare function resolveInSolution(kind: ProcessKind, inputs: unknown, solution: SolutionProjects | undefined): unknown;
25
+ /**
26
+ * Throw what the serializer cannot write correctly about an in-solution step,
27
+ * knowing the solution. For instance `publishedFunction({ location:
28
+ * 'in-solution', project: 'Summarizer' })` on a project whose entry point is an
29
+ * agent throws `IN_SOLUTION_WRONG_BUILDER`, naming `agent(`.
30
+ */
31
+ export declare function refuseInSolution(kind: ProcessKind, inputs: unknown, solution: SolutionProjects | undefined, step: string): void;
32
+ export {};
@@ -0,0 +1,169 @@
1
+ /**
2
+ * An in-solution process step resolved against the solution on disk (#1978).
3
+ *
4
+ * The author names the sibling by project:
5
+ *
6
+ * rpaWorkflow({ location: 'in-solution', project: 'CalculatePay', inputs: { hours: 40 } })
7
+ *
8
+ * and `resolveInSolution` fills what the sibling's resource file and entry points
9
+ * say: `key` (`resource.key`), `projectId` (`resource.projectKey`), `name` (the
10
+ * project's name) and, when the step declares none, `returns` (the entry point's
11
+ * output fields). The serializer and `check` both run it (`withSolution` on the
12
+ * node type), so the read rules see the filled `returns` and the two rungs agree.
13
+ *
14
+ * `refuseInSolution` is the serializer's half: what it cannot write correctly once
15
+ * it knows the solution. A `project` it cannot find, a sibling the factory cannot
16
+ * call (a coded agent under `process/function/` called with `publishedFunction()`
17
+ * "validates and dispatches nothing"), and a `key` or `projectId` that names no
18
+ * sibling of this solution. Without a solution (a library call, or a flow outside
19
+ * any `.uipx` folder) an explicit `key` is not judged, and a `project` is refused:
20
+ * nothing can say what it names.
21
+ */
22
+ import { CompileRefusal } from '../../../core/compile-refusal.js';
23
+ import { nearestName } from '../../../core/edit-distance.js';
24
+ import { blank } from '../../../core/process-resource.js';
25
+ import { sameGuid, solutionProjectByKey, solutionProjectByName, } from '../../../core/solution-projects.js';
26
+ /**
27
+ * The factory that calls `project`. The entry point's own type wins over the
28
+ * folder: `uip solution projects add` files a coded agent with no `ProjectType`
29
+ * under `process/function/`, while its `entry-points.json` still says `agent`.
30
+ */
31
+ export function builderOf(project) {
32
+ const entry = project.entryPointType?.toLowerCase();
33
+ if (entry === 'agent')
34
+ return { kind: 'agent', label: 'agent', open: 'agent({ ' };
35
+ if (entry === 'function')
36
+ return { kind: 'publishedFunction', label: 'publishedFunction', open: 'publishedFunction({ ' };
37
+ switch (project.resourceType.toLowerCase()) {
38
+ case 'process': return { kind: 'rpaWorkflow', label: 'rpaWorkflow', open: 'rpaWorkflow({ ' };
39
+ case 'api': return { kind: 'apiWorkflow', label: 'apiWorkflow', open: 'apiWorkflow({ ' };
40
+ case 'function': return { kind: 'publishedFunction', label: 'publishedFunction', open: 'publishedFunction({ ' };
41
+ case 'agent': return { kind: 'agent', label: 'agent', open: 'agent({ ' };
42
+ case 'flow': return { kind: 'agenticProcess', form: 'flow', label: "agenticProcess with form 'flow'", open: "agenticProcess({ form: 'flow', " };
43
+ case 'processorchestration': return { kind: 'agenticProcess', form: 'bpmn', label: "agenticProcess with form 'bpmn'", open: "agenticProcess({ form: 'bpmn', " };
44
+ case 'casemanagement': return { kind: 'agenticProcess', form: 'case', label: "agenticProcess with form 'case'", open: "agenticProcess({ form: 'case', " };
45
+ default: return undefined;
46
+ }
47
+ }
48
+ /** Whether a `kind` step (with `form`, for an agentic process) is the call `builder` names. */
49
+ function fits(builder, kind, form) {
50
+ if (builder === undefined || builder.kind !== kind)
51
+ return false;
52
+ return kind !== 'agenticProcess' || (form ?? 'bpmn') === builder.form;
53
+ }
54
+ /** A JSON schema type as a `returns` type; anything else (a union, `null`) reads as `object`. */
55
+ function returnType(type) {
56
+ return type === 'string' || type === 'number' || type === 'integer' || type === 'boolean' || type === 'array'
57
+ ? type
58
+ : 'object';
59
+ }
60
+ /** The project a step names: by `project`, else by its `key`. */
61
+ function namedProject(s, solution) {
62
+ if (!blank(s.project))
63
+ return solutionProjectByName(solution, String(s.project).trim());
64
+ return !blank(s.key) ? solutionProjectByKey(solution, String(s.key)) : undefined;
65
+ }
66
+ /**
67
+ * `inputs` with what the solution says about the sibling it names filled in.
68
+ * Only an in-solution step named by `project`, whose sibling is found and is
69
+ * this factory's, is filled; a field the author wrote is kept (a wrong one is
70
+ * `refuseInSolution`'s). Anything else is returned unchanged.
71
+ */
72
+ export function resolveInSolution(kind, inputs, solution) {
73
+ const authored = (inputs ?? {});
74
+ // `project` names a sibling, so it implies the location; beside 'published' it is refused.
75
+ if (blank(authored.project) || (authored.location !== undefined && authored.location !== 'in-solution'))
76
+ return inputs;
77
+ const s = { ...authored, location: 'in-solution' };
78
+ const project = String(s.project).trim();
79
+ // The name is the project's either way, so an unresolved one is not also "has no name".
80
+ const found = solution !== undefined ? solutionProjectByName(solution, project) : undefined;
81
+ if (found === undefined || !fits(builderOf(found), kind, s.form)) {
82
+ return blank(s.name) ? { ...s, name: project } : s;
83
+ }
84
+ const outputs = found.outputs !== undefined && Object.keys(found.outputs).length > 0 ? found.outputs : undefined;
85
+ const fillReturns = s.returns === undefined && s.completion !== 'fire-and-forget' && outputs !== undefined;
86
+ return {
87
+ ...s,
88
+ key: blank(s.key) ? found.key : s.key,
89
+ name: blank(s.name) ? found.name : s.name,
90
+ projectId: blank(s.projectId) ? found.projectId : s.projectId,
91
+ ...(fillReturns ? { returns: Object.fromEntries(Object.entries(outputs).map(([f, t]) => [f, returnType(t)])) } : {}),
92
+ };
93
+ }
94
+ /** ` The solution's projects: "CalculatePay" (rpaWorkflow, resources/…/CalculatePay.json); …` */
95
+ function siblingList(solution) {
96
+ if (solution.projects.length === 0)
97
+ return '';
98
+ return ` The solution's projects: ${solution.projects
99
+ .map((p) => `"${p.name}" (${builderOf(p)?.label ?? p.resourceType}, ${p.file})`)
100
+ .join('; ')}.`;
101
+ }
102
+ /**
103
+ * Throw what the serializer cannot write correctly about an in-solution step,
104
+ * knowing the solution. For instance `publishedFunction({ location:
105
+ * 'in-solution', project: 'Summarizer' })` on a project whose entry point is an
106
+ * agent throws `IN_SOLUTION_WRONG_BUILDER`, naming `agent(`.
107
+ */
108
+ export function refuseInSolution(kind, inputs, solution, step) {
109
+ const s = (inputs ?? {});
110
+ const byProject = !blank(s.project);
111
+ if (byProject && s.location !== undefined && s.location !== 'in-solution') {
112
+ throw new CompileRefusal('IN_SOLUTION_PROJECT_PUBLISHED', `Step "${step}" names project ${JSON.stringify(s.project)} with \`location: ${JSON.stringify(s.location)}\`. `
113
+ + `\`project\` names a sibling of this solution; a published process is named by \`key\`, \`name\` and `
114
+ + `\`folderPath\`. Drop \`location\` (or set 'in-solution') to call the sibling, or drop \`project\`.`, `location: 'in-solution'`);
115
+ }
116
+ if (s.location !== 'in-solution')
117
+ return;
118
+ if (solution === undefined) {
119
+ if (!byProject)
120
+ return;
121
+ throw new CompileRefusal('IN_SOLUTION_NO_SOLUTION', `Step "${step}" calls in-solution project ${JSON.stringify(s.project)}, but this compile was given no `
122
+ + `solution to look it up in. \`flow compile\`, \`flow check\` and \`flow merge\` read it from the nearest folder `
123
+ + `at or above the flow that holds a \`.uipx\`, and found none; a library call to \`serialize()\` or \`check()\` `
124
+ + `passes it as the \`solution\` option. Run the command from inside the solution (\`<Solution>/<FlowProject>/\`), `
125
+ + `or write the sibling's \`key\` and \`projectId\` instead of \`project\`.`, `key: '<resource.key>', projectId: '<resource.projectKey>'`);
126
+ }
127
+ // Nothing to check an explicit key against: the solution was never refreshed,
128
+ // so the step's key cannot be judged here (`flow validate` sees it).
129
+ if (!byProject && solution.projects.length === 0)
130
+ return;
131
+ const project = namedProject(s, solution);
132
+ if (project === undefined) {
133
+ const refresh = solution.projects.length === 0
134
+ ? ` The solution has no project resource files yet: run \`uip solution resources refresh\` in ${solution.dir} `
135
+ + `after \`uip solution projects add\`, then compile again.`
136
+ : '';
137
+ if (byProject) {
138
+ const near = nearestName(String(s.project), solution.projects.map((p) => p.name));
139
+ throw new CompileRefusal('IN_SOLUTION_PROJECT_NOT_FOUND', `Step "${step}" calls in-solution project ${JSON.stringify(s.project)}, but the solution has no project of that `
140
+ + `name under resources/solution_folder/process/.${siblingList(solution)}${refresh}`, near !== undefined ? `project: '${near}'` : undefined);
141
+ }
142
+ const byName = !blank(s.name) ? solutionProjectByName(solution, String(s.name).trim()) : undefined;
143
+ if (byName !== undefined) {
144
+ throw new CompileRefusal('IN_SOLUTION_KEY_MISMATCH', `In-solution step "${step}" has \`key\` ${JSON.stringify(s.key)}, but project "${byName.name}" has resource key `
145
+ + `"${byName.key}" (${byName.file}). A key that names no sibling is a node the platform cannot resolve. `
146
+ + `Write \`project: '${byName.name}'\` and drop \`key\` and \`projectId\`, so compile reads them.`, `project: '${byName.name}'`);
147
+ }
148
+ throw new CompileRefusal('IN_SOLUTION_PROJECT_NOT_FOUND', `In-solution step "${step}" has \`key\` ${JSON.stringify(s.key)}, which is no project's resource key in this `
149
+ + `solution.${siblingList(solution)} Name the sibling with \`project: '<name>'\` and drop \`key\` and \`projectId\`.`);
150
+ }
151
+ const builder = builderOf(project);
152
+ if (!fits(builder, kind, s.form)) {
153
+ const why = project.entryPointType !== undefined
154
+ ? `its entry point is of type "${project.entryPointType}" and its resource is in ${project.file}`
155
+ : `its resource is in ${project.file}`;
156
+ throw new CompileRefusal('IN_SOLUTION_WRONG_BUILDER', `Step "${step}" calls project "${project.name}" with the wrong builder: ${why}, so it is called with `
157
+ + `${builder !== undefined ? builder.label : 'no process builder'}. The wrong builder writes a node `
158
+ + `that validates and starts nothing.`, builder !== undefined ? `${builder.open}location: 'in-solution', project: '${project.name}', … })` : undefined);
159
+ }
160
+ if (!blank(s.key) && !sameGuid(String(s.key), project.key)) {
161
+ throw new CompileRefusal('IN_SOLUTION_KEY_MISMATCH', `In-solution step "${step}" has \`key\` ${JSON.stringify(s.key)}, but project "${project.name}" has resource key `
162
+ + `"${project.key}" (${project.file}). Drop \`key\` and let compile read it from \`project\`.`, `key: '${project.key}'`);
163
+ }
164
+ if (!blank(s.projectId) && !sameGuid(String(s.projectId), project.projectId)) {
165
+ throw new CompileRefusal('IN_SOLUTION_KEY_MISMATCH', `In-solution step "${step}" has \`projectId\` ${JSON.stringify(s.projectId)}, but project "${project.name}" has `
166
+ + `\`resource.projectKey\` "${project.projectId}" (${project.file}). Drop \`projectId\` and let compile read it `
167
+ + `from \`project\`.`, `projectId: '${project.projectId}'`);
168
+ }
169
+ }
@@ -19,6 +19,7 @@ import { resourceNodeSortOrder } from '../../../core/process-resource-sort-order
19
19
  import { processResourceBindings, processResourceLocation } from '../../../core/process-resource.js';
20
20
  import { checkAgent, checkAgentRead, checkAgenticProcess, checkAgenticProcessRead, checkApiWorkflow, checkApiWorkflowRead, checkPublishedFunction, checkPublishedFunctionRead, checkRpaWorkflow, rpaWorkflowRead, } from './check.js';
21
21
  import { refuseLossyProcess } from './refusals.js';
22
+ import { refuseInSolution, resolveInSolution } from './in-solution.js';
22
23
  import { declareKeys } from '../../../core/option-keys.js';
23
24
  /** The RPA-workflow node type family. The process's release key is the suffix. */
24
25
  const RPA_WORKFLOW_PREFIX = 'uipath.core.rpa-workflow.';
@@ -644,6 +645,9 @@ export function processDefinition(spec) {
644
645
  * are identical, and the DATA paths that differ are all downstream in the engine.
645
646
  */
646
647
  function serializeProcess(spec, ctx) {
648
+ // A sibling the solution does not have, or one this factory cannot call:
649
+ // refused before the generic rules, which would only say "no key" (#1978).
650
+ refuseInSolution(spec.kind, spec.inputs, ctx.solution, ctx.step);
647
651
  // A missing key, a folder beside in-solution, a reserved `fireAndForget`
648
652
  // argument: each would be written wrong, so it is refused here (#1518).
649
653
  refuseLossyProcess(spec.kind, spec.inputs, ctx.step);
@@ -834,11 +838,11 @@ function processCheck(spec, ctx) {
834
838
  }
835
839
  /** Every key of each factory's options (builder-sdk#1990), by kind; `tsc` holds each list to its type. */
836
840
  const PROCESS_OPTIONS = {
837
- rpaWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
838
- apiWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
839
- publishedFunction: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
840
- agenticProcess: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, form: true, completion: true, returns: true }) },
841
- agent: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true, flavour: true }) },
841
+ rpaWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
842
+ apiWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
843
+ publishedFunction: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
844
+ agenticProcess: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, form: true, completion: true, returns: true }) },
845
+ agent: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true, flavour: true }) },
842
846
  };
843
847
  function processType(kind, prefix, factory, form) {
844
848
  const impl = {
@@ -853,6 +857,9 @@ function processType(kind, prefix, factory, form) {
853
857
  // check collected no expressions for a process step before the port; unchanged by it.
854
858
  expressions: () => [],
855
859
  output: processOutput,
860
+ // An in-solution step named by `project` takes its key, project id, name and
861
+ // returns from the sibling's files (#1978).
862
+ withSolution: (spec, solution) => ({ ...spec, inputs: resolveInSolution(spec.kind, spec.inputs, solution) }),
856
863
  ...(kind === 'agenticProcess' ? {
857
864
  fireAndForget: ({ inputs }) => inputs?.completion === 'fire-and-forget'
858
865
  ? { fix: "completion: 'wait'" }
@@ -15,19 +15,39 @@ export interface RpaWorkflowInputs {
15
15
  * `uip or processes list --all-folders --process-type Process` (the row's `Key`)
16
16
  * or `uip maestro flow registry search "uipath.core.rpa-workflow"`.
17
17
  *
18
- * For an in-solution sibling it is `resource.key` from
18
+ * For an in-solution sibling, leave it out and set `project`: compile fills
19
+ * it with `resource.key` from
19
20
  * `resources/solution_folder/process/process/<project>.json` — the suffix of the
20
21
  * node type `uip maestro flow registry list --local` shows.
21
22
  */
22
- key: string;
23
- /** The process's name in Orchestrator — e.g. `'RPA Workflow'`. */
24
- name: string;
23
+ key?: string;
24
+ /** The process's name in Orchestrator — e.g. `'RPA Workflow'`. Filled from `project` for an in-solution sibling. */
25
+ name?: string;
25
26
  /**
26
27
  * Where the process lives. `'published'` (the default) is a process deployed
27
28
  * to `folderPath`. `'in-solution'` is a sibling RPA project of the same
28
29
  * solution: it needs `projectId` and no `folderPath`.
29
30
  */
30
31
  location?: ProcessLocation;
32
+ /**
33
+ * The sibling project of this solution to call, by name — e.g.
34
+ * `'CalculatePay'`. It implies `location: 'in-solution'`. `compile` and `check`
35
+ * then read the project's `resources/solution_folder/process/<type>/<project>.json`
36
+ * and `entry-points.json`, and fill `key`, `projectId`, `name` and (when you
37
+ * declare none) `returns`, so none of them is copied by hand:
38
+ *
39
+ * ```ts
40
+ * rpaWorkflow({ location: 'in-solution', project: 'CalculatePay', inputs: { hours: 40 } })
41
+ * ```
42
+ *
43
+ * The flow must be compiled from inside its solution (a folder at or above it
44
+ * holds the `.uipx`), after `uip solution resources refresh`.
45
+ *
46
+ * @enforcedBy IN_SOLUTION_PROJECT_NOT_FOUND The solution has a project of this name.
47
+ * @enforcedBy IN_SOLUTION_WRONG_BUILDER The project is one this builder calls.
48
+ * @enforcedBy IN_SOLUTION_NO_SOLUTION The flow is compiled inside a solution.
49
+ */
50
+ project?: string;
31
51
  /**
32
52
  * The Orchestrator folder holding the process — e.g.
33
53
  * `'Shared/uipath-maestro-flow/ProjectEuler RPA'`. Required for a published
@@ -41,7 +61,8 @@ export interface RpaWorkflowInputs {
41
61
  * `resources/solution_folder/process/process/<project>.json`. Used only when
42
62
  * `location` is `'in-solution'`. The step resolves by `key`, so omitting it is a
43
63
  * warning, not an error; but Studio Web's Run node reads it to deploy the
44
- * sibling first, so set it on a step you author.
64
+ * sibling first, so set it on a step you author,
65
+ * or set `project` and compile fills it.
45
66
  *
46
67
  * @enforcedBy RPA_LOCAL_NO_PROJECT_ID An in-solution process should name its project (warning).
47
68
  */
@@ -77,13 +98,14 @@ export interface ApiWorkflowInputs {
77
98
  * `ProcessKey` reads `<name>.api.<name>`; the GUID you want is the row's `Key`)
78
99
  * or `uip maestro flow registry search`.
79
100
  *
80
- * For an in-solution sibling it is `resource.key` from
101
+ * For an in-solution sibling, leave it out and set `project`: compile fills
102
+ * it with `resource.key` from
81
103
  * `resources/solution_folder/process/api/<project>.json`, the suffix of the
82
104
  * node type `uip maestro flow registry list --local` shows.
83
105
  */
84
- key: string;
85
- /** The workflow's name in Orchestrator — e.g. `'NameToAgeFixed'`. */
86
- name: string;
106
+ key?: string;
107
+ /** The workflow's name in Orchestrator — e.g. `'NameToAgeFixed'`. Filled from `project` for an in-solution sibling. */
108
+ name?: string;
87
109
  /**
88
110
  * Where the workflow lives. `'published'` (the default) is a workflow
89
111
  * deployed to `folderPath`. `'in-solution'` is a sibling API workflow project
@@ -91,6 +113,25 @@ export interface ApiWorkflowInputs {
91
113
  * that sibling's `resource.key`.
92
114
  */
93
115
  location?: ProcessLocation;
116
+ /**
117
+ * The sibling project of this solution to call, by name — e.g.
118
+ * `'CalculatePay'`. It implies `location: 'in-solution'`. `compile` and `check`
119
+ * then read the project's `resources/solution_folder/process/<type>/<project>.json`
120
+ * and `entry-points.json`, and fill `key`, `projectId`, `name` and (when you
121
+ * declare none) `returns`, so none of them is copied by hand:
122
+ *
123
+ * ```ts
124
+ * rpaWorkflow({ location: 'in-solution', project: 'CalculatePay', inputs: { hours: 40 } })
125
+ * ```
126
+ *
127
+ * The flow must be compiled from inside its solution (a folder at or above it
128
+ * holds the `.uipx`), after `uip solution resources refresh`.
129
+ *
130
+ * @enforcedBy IN_SOLUTION_PROJECT_NOT_FOUND The solution has a project of this name.
131
+ * @enforcedBy IN_SOLUTION_WRONG_BUILDER The project is one this builder calls.
132
+ * @enforcedBy IN_SOLUTION_NO_SOLUTION The flow is compiled inside a solution.
133
+ */
134
+ project?: string;
94
135
  /**
95
136
  * The Orchestrator folder holding it — e.g. `'Shared'`. Required for a
96
137
  * published workflow; omit it for an in-solution sibling.
@@ -142,13 +183,14 @@ export interface PublishedFunctionInputs {
142
183
  * `uip maestro flow registry search "uipath.core.function"` (after
143
184
  * `registry pull --force`) or the Orchestrator process listing.
144
185
  *
145
- * For an in-solution sibling it is `resource.key` from
186
+ * For an in-solution sibling, leave it out and set `project`: compile fills
187
+ * it with `resource.key` from
146
188
  * `resources/solution_folder/process/function/<project>.json` — the suffix of
147
189
  * the node type `uip maestro flow registry list --local` shows.
148
190
  */
149
- key: string;
150
- /** The function's name in Orchestrator, e.g. `'acme-echo'`. */
151
- name: string;
191
+ key?: string;
192
+ /** The function's name in Orchestrator, e.g. `'acme-echo'`. Filled from `project` for an in-solution sibling. */
193
+ name?: string;
152
194
  /**
153
195
  * Where the function lives. `'published'` (the default) is a function
154
196
  * deployed to `folderPath`. `'in-solution'` is a sibling coded-function
@@ -157,6 +199,25 @@ export interface PublishedFunctionInputs {
157
199
  * `resources/solution_folder/process/function/<project>.json`.
158
200
  */
159
201
  location?: ProcessLocation;
202
+ /**
203
+ * The sibling project of this solution to call, by name — e.g.
204
+ * `'CalculatePay'`. It implies `location: 'in-solution'`. `compile` and `check`
205
+ * then read the project's `resources/solution_folder/process/<type>/<project>.json`
206
+ * and `entry-points.json`, and fill `key`, `projectId`, `name` and (when you
207
+ * declare none) `returns`, so none of them is copied by hand:
208
+ *
209
+ * ```ts
210
+ * rpaWorkflow({ location: 'in-solution', project: 'CalculatePay', inputs: { hours: 40 } })
211
+ * ```
212
+ *
213
+ * The flow must be compiled from inside its solution (a folder at or above it
214
+ * holds the `.uipx`), after `uip solution resources refresh`.
215
+ *
216
+ * @enforcedBy IN_SOLUTION_PROJECT_NOT_FOUND The solution has a project of this name.
217
+ * @enforcedBy IN_SOLUTION_WRONG_BUILDER The project is one this builder calls.
218
+ * @enforcedBy IN_SOLUTION_NO_SOLUTION The flow is compiled inside a solution.
219
+ */
220
+ project?: string;
160
221
  /**
161
222
  * The Orchestrator folder holding it. A function is usually deployed into a
162
223
  * folder of its OWN name (e.g. `'Shared/acme-echo'`), and the binding's
@@ -203,9 +264,9 @@ interface AgenticProcessInputsBase {
203
264
  * `--limit`/`--offset`, or scope the call with `--folder-path`, or a process that
204
265
  * exists will look as though it does not.
205
266
  */
206
- key: string;
207
- /** The process's name in Orchestrator — e.g. `'ProcurementProcess'`. */
208
- name: string;
267
+ key?: string;
268
+ /** The process's name in Orchestrator — e.g. `'ProcurementProcess'`. Filled from `project` for an in-solution sibling. */
269
+ name?: string;
209
270
  /**
210
271
  * Where the process lives. `'published'` (the default) is a process deployed
211
272
  * to `folderPath`. `'in-solution'` is a sibling Flow of the same solution, so
@@ -217,6 +278,25 @@ interface AgenticProcessInputsBase {
217
278
  * @enforcedBy AGENTIC_LOCAL_FORM_UNVERIFIED In-solution is supported for `form: 'flow'` only.
218
279
  */
219
280
  location?: ProcessLocation;
281
+ /**
282
+ * The sibling project of this solution to call, by name — e.g.
283
+ * `'CalculatePay'`. It implies `location: 'in-solution'`. `compile` and `check`
284
+ * then read the project's `resources/solution_folder/process/<type>/<project>.json`
285
+ * and `entry-points.json`, and fill `key`, `projectId`, `name` and (when you
286
+ * declare none) `returns`, so none of them is copied by hand:
287
+ *
288
+ * ```ts
289
+ * rpaWorkflow({ location: 'in-solution', project: 'CalculatePay', inputs: { hours: 40 } })
290
+ * ```
291
+ *
292
+ * The flow must be compiled from inside its solution (a folder at or above it
293
+ * holds the `.uipx`), after `uip solution resources refresh`.
294
+ *
295
+ * @enforcedBy IN_SOLUTION_PROJECT_NOT_FOUND The solution has a project of this name.
296
+ * @enforcedBy IN_SOLUTION_WRONG_BUILDER The project is one this builder calls.
297
+ * @enforcedBy IN_SOLUTION_NO_SOLUTION The flow is compiled inside a solution.
298
+ */
299
+ project?: string;
220
300
  /**
221
301
  * The Orchestrator folder holding it — e.g.
222
302
  * `'Shared/uipath-agents/ProcurementProcess'`. Required for a published
@@ -303,7 +383,8 @@ export interface AgentInputs {
303
383
  /**
304
384
  * The agent resource key (a GUID). It becomes the node's TYPE,
305
385
  * `uipath.core.agent.<key>`. For a published agent this is the Orchestrator
306
- * release key; for an in-solution sibling it is `resource.key` from
386
+ * release key; for an in-solution sibling, leave it out and set `project`: compile fills it
387
+ * with `resource.key` from
307
388
  * `resources/solution_folder/process/agent/<project>.json`.
308
389
  *
309
390
  * Find it with `uip or processes list --all-folders --process-type Agent` (an agent's
@@ -313,15 +394,34 @@ export interface AgentInputs {
313
394
  * Pass `--limit`: `--all-folders` returns 50 rows and reports the truncation
314
395
  * only in `Pagination.HasMore`, so an agent that exists can look absent.
315
396
  */
316
- key: string;
317
- /** The agent project name. */
318
- name: string;
397
+ key?: string;
398
+ /** The agent project name. Filled from `project` for an in-solution sibling. */
399
+ name?: string;
319
400
  /**
320
401
  * Where the referenced agent lives. Published is the backward-compatible
321
402
  * default. Use `in-solution` only after registering a sibling agent project
322
403
  * with `uip solution projects add`.
323
404
  */
324
405
  location?: AgentLocation;
406
+ /**
407
+ * The sibling project of this solution to call, by name — e.g.
408
+ * `'CalculatePay'`. It implies `location: 'in-solution'`. `compile` and `check`
409
+ * then read the project's `resources/solution_folder/process/<type>/<project>.json`
410
+ * and `entry-points.json`, and fill `key`, `projectId`, `name` and (when you
411
+ * declare none) `returns`, so none of them is copied by hand:
412
+ *
413
+ * ```ts
414
+ * rpaWorkflow({ location: 'in-solution', project: 'CalculatePay', inputs: { hours: 40 } })
415
+ * ```
416
+ *
417
+ * The flow must be compiled from inside its solution (a folder at or above it
418
+ * holds the `.uipx`), after `uip solution resources refresh`.
419
+ *
420
+ * @enforcedBy IN_SOLUTION_PROJECT_NOT_FOUND The solution has a project of this name.
421
+ * @enforcedBy IN_SOLUTION_WRONG_BUILDER The project is one this builder calls.
422
+ * @enforcedBy IN_SOLUTION_NO_SOLUTION The flow is compiled inside a solution.
423
+ */
424
+ project?: string;
325
425
  /**
326
426
  * The Orchestrator folder holding it — e.g.
327
427
  * `'Shared/uipath-maestro-flow/CountLetters LowCode'`.
@@ -7,6 +7,7 @@
7
7
  * the platform emits, so the result passes `uip maestro flow validate`.
8
8
  */
9
9
  import { type ResourceResolutions } from './core/resource-resolution.js';
10
+ import type { SolutionProjects } from './core/solution-projects.js';
10
11
  import type { NodeCatalog } from './core/node-catalog.js';
11
12
  import type { DefinitionReference } from './core/node-classes.js';
12
13
  import type { BuiltFlow } from './flow-sdk.js';
@@ -79,6 +80,14 @@ export interface SerializeOpts {
79
80
  * cache at `~/.uipath/nodes/index.json`; a programmatic caller passes its own.
80
81
  */
81
82
  nodeCatalog?: NodeCatalog;
83
+ /**
84
+ * The solution the flow is authored in and its sibling projects, read by the
85
+ * CLI (`readSolutionProjects`, #1978). An in-solution process step named by
86
+ * `project` compiles from its sibling's resource file, and an explicit `key`
87
+ * or `projectId` is checked against it. Absent: a step named by `project` is
88
+ * refused (`IN_SOLUTION_NO_SOLUTION`) and an explicit key is not judged.
89
+ */
90
+ solution?: SolutionProjects;
82
91
  /**
83
92
  * Receives each {@link SerializeWarning}. `compile-cli` prints them as
84
93
  * `⚠ [CODE] …` after `check()`'s diagnostics; a caller that passes nothing