@uipath/maestro-builder-sdk 6.122.4 → 6.122.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-index.md +92 -90
- package/dist/api-members.md +401 -396
- package/dist/bpmn/bpmn-sdk.d.ts +54 -19
- package/dist/bpmn/bpmn-sdk.js +42 -9
- package/dist/bpmn/decompile.js +46 -5
- package/dist/bpmn/merge.js +7 -3
- package/dist/bpmn/serialize.js +5 -1
- package/dist/bpmn-api.md +38 -9
- package/dist/core/refusals.d.ts +3 -0
- package/dist/core/refusals.js +3 -0
- package/dist/nodes/process/flow/check.js +42 -1
- package/dist/nodes/process/flow/contract.d.ts +8 -0
- package/dist/nodes/process/flow/contract.js +4 -4
- package/dist/nodes/process/flow/input-schema.d.ts +50 -0
- package/dist/nodes/process/flow/input-schema.js +113 -0
- package/dist/nodes/process/flow/node-type.js +31 -38
- package/dist/nodes/process/flow/refusals.js +12 -0
- package/dist/nodes/process/flow/spec.d.ts +105 -0
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ import { GUID_RE } from '../../../core/binding-messages.js';
|
|
|
3
3
|
import { nearestName } from '../../../core/edit-distance.js';
|
|
4
4
|
import { ownEntry } from '../../../core/own-entry.js';
|
|
5
5
|
import { blank } from '../../../core/process-resource.js';
|
|
6
|
-
import { returnsFromTenantHint } from './contract.js';
|
|
6
|
+
import { isLiteral, literalFits, literalType, returnsFromTenantHint, typesOf } from './contract.js';
|
|
7
7
|
export const PROCESS_DIAGNOSTICS = {
|
|
8
8
|
AGENT_EMPTY_INPUT_FLOOR: { severity: 'warning', summary: 'an agent step that binds no inputs' },
|
|
9
9
|
AGENT_EMPTY_RETURNS: { severity: 'warning', summary: 'an agent step with returns: {}' },
|
|
@@ -61,6 +61,8 @@ export const PROCESS_DIAGNOSTICS = {
|
|
|
61
61
|
IN_SOLUTION_PROJECT_NOT_FOUND: { severity: 'error', summary: 'an in-solution process step naming no project of the solution' },
|
|
62
62
|
IN_SOLUTION_PROJECT_PUBLISHED: { severity: 'error', summary: 'a process step naming a project with location published' },
|
|
63
63
|
IN_SOLUTION_WRONG_BUILDER: { severity: 'error', summary: 'an in-solution process step whose builder does not call its project\'s type' },
|
|
64
|
+
PROCESS_INPUT_SCHEMA_INVALID: { severity: 'error', summary: 'a process step whose inputSchema is not a JSON object' },
|
|
65
|
+
PROCESS_INPUT_SCHEMA_TYPE: { severity: 'error', summary: 'a process step input whose literal is not the type its inputSchema declares' },
|
|
64
66
|
PROCESS_INPUT_MISSING: { severity: 'error', summary: 'a published process step that leaves out an input the recorded process requires' },
|
|
65
67
|
PROCESS_INPUT_TYPE: { severity: 'error', summary: 'a published process step input whose literal is not the recorded argument type' },
|
|
66
68
|
PROCESS_INPUT_UNKNOWN: { severity: 'error', summary: 'a published process step input the recorded process does not declare' },
|
|
@@ -100,6 +102,40 @@ function noProjectIdMessage(kind, step, solutionFolder) {
|
|
|
100
102
|
+ `add it: Studio Web's Run node reads \`model.projectId\` to deploy the sibling before it runs the step. `
|
|
101
103
|
+ `Read \`resource.projectKey\` from \`resources/solution_folder/process/${solutionFolder}/<project>.json\`.`;
|
|
102
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* `PROCESS_INPUT_SCHEMA_TYPE`: a literal input that does not fit the type its
|
|
107
|
+
* `inputSchema` property declares. `uip maestro flow validate` reports the same
|
|
108
|
+
* value as `[TYPE_MISMATCH] "<input>" on "<node>" expects <type>`; this says it
|
|
109
|
+
* before compile. Only a JSON Schema object (`properties`) is read, and only
|
|
110
|
+
* object and array literals: an expression's value is not known until run
|
|
111
|
+
* time, and validate coerces a string or number literal rather than rejecting
|
|
112
|
+
* it (`TimeoutMinutes: "5"` against `number` validates).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // inputs: { owsResult: {} }, inputSchema: { type: 'object', properties: { owsResult: { type: 'string' } } }
|
|
116
|
+
* // → PROCESS_INPUT_SCHEMA_TYPE: passes {} (object) for "owsResult", which inputSchema declares as string
|
|
117
|
+
*/
|
|
118
|
+
function checkInputSchema(inputs, label, ctx) {
|
|
119
|
+
const schema = inputs?.inputSchema;
|
|
120
|
+
const properties = schema !== null && typeof schema === 'object' ? schema.properties : undefined;
|
|
121
|
+
if (properties === null || typeof properties !== 'object' || Array.isArray(properties))
|
|
122
|
+
return;
|
|
123
|
+
const declared = properties;
|
|
124
|
+
for (const [name, value] of Object.entries(inputs?.inputs ?? {})) {
|
|
125
|
+
// Only an object or array literal: validate coerces a string (`"5"` for a
|
|
126
|
+
// number, `"=$vars.x"` for an object) and accepts it, so a scalar is not
|
|
127
|
+
// reported here.
|
|
128
|
+
if (!Object.hasOwn(declared, name) || value === null || typeof value !== 'object' || !isLiteral(value))
|
|
129
|
+
continue;
|
|
130
|
+
const property = declared[name];
|
|
131
|
+
const types = typesOf(property !== null && typeof property === 'object' ? property : undefined);
|
|
132
|
+
if (literalFits(value, types))
|
|
133
|
+
continue;
|
|
134
|
+
ctx.report('PROCESS_INPUT_SCHEMA_TYPE', `${label} step "${ctx.step}" passes ${JSON.stringify(value)} (${literalType(value)}) for input ${JSON.stringify(name)}, `
|
|
135
|
+
+ `which its \`inputSchema\` declares as ${types.join(' | ')}. \`uip maestro flow validate\` rejects the file `
|
|
136
|
+
+ '(TYPE_MISMATCH). Pass a value of that type, or fix the type in `inputSchema`.');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
103
139
|
/**
|
|
104
140
|
* Check an `rpaWorkflow(...)` call.
|
|
105
141
|
*
|
|
@@ -126,6 +162,7 @@ function noProjectIdMessage(kind, step, solutionFolder) {
|
|
|
126
162
|
export function checkRpaWorkflow(inputs, ctx) {
|
|
127
163
|
const step = ctx.step;
|
|
128
164
|
const at = (code, message, suggestion) => ctx.report(code, message, suggestion);
|
|
165
|
+
checkInputSchema(inputs, 'RPA', ctx);
|
|
129
166
|
// A blank key is the serializer's RPA_NO_KEY (refusals.ts).
|
|
130
167
|
if (!blank(inputs?.key) && !GUID_RE.test(String(inputs.key).trim())) {
|
|
131
168
|
at('RPA_KEY_NOT_KEY', `RPA step "${step}"'s \`key\` is ${JSON.stringify(inputs.key)}, which is not a release key. `
|
|
@@ -184,6 +221,7 @@ export function checkRpaWorkflow(inputs, ctx) {
|
|
|
184
221
|
export function checkApiWorkflow(inputs, ctx) {
|
|
185
222
|
const step = ctx.step;
|
|
186
223
|
const at = (code, message, suggestion) => ctx.report(code, message, suggestion);
|
|
224
|
+
checkInputSchema(inputs, 'API workflow', ctx);
|
|
187
225
|
// A blank key is the serializer's APIWF_NO_KEY (refusals.ts).
|
|
188
226
|
if (!blank(inputs?.key) && !GUID_RE.test(String(inputs.key).trim())) {
|
|
189
227
|
at('APIWF_KEY_NOT_KEY', `API workflow step "${step}"'s \`key\` is ${JSON.stringify(inputs.key)}, which is not a key. `
|
|
@@ -234,6 +272,7 @@ export function checkApiWorkflow(inputs, ctx) {
|
|
|
234
272
|
export function checkPublishedFunction(inputs, ctx) {
|
|
235
273
|
const step = ctx.step;
|
|
236
274
|
const at = (code, message, suggestion) => ctx.report(code, message, suggestion);
|
|
275
|
+
checkInputSchema(inputs, 'Function', ctx);
|
|
237
276
|
// A blank key is the serializer's FUNCTION_NO_KEY (refusals.ts).
|
|
238
277
|
if (!blank(inputs?.key) && !GUID_RE.test(String(inputs.key).trim())) {
|
|
239
278
|
at('FUNCTION_KEY_NOT_KEY', `Function step "${step}"'s \`key\` is ${JSON.stringify(inputs.key)}, which is not a key. \`key\` is the `
|
|
@@ -297,6 +336,7 @@ export function checkPublishedFunction(inputs, ctx) {
|
|
|
297
336
|
export function checkAgenticProcess(inputs, ctx) {
|
|
298
337
|
const step = ctx.step;
|
|
299
338
|
const at = (code, message, suggestion) => ctx.report(code, message, suggestion);
|
|
339
|
+
checkInputSchema(inputs, 'Agentic process', ctx);
|
|
300
340
|
// A blank key is the serializer's AGENTIC_NO_KEY (refusals.ts).
|
|
301
341
|
if (!blank(inputs?.key) && !GUID_RE.test(String(inputs.key).trim())) {
|
|
302
342
|
at('AGENTIC_KEY_NOT_KEY', `Agentic process step "${step}"'s \`key\` is ${JSON.stringify(inputs.key)}, which is not a key. `
|
|
@@ -490,6 +530,7 @@ export function checkAgenticProcessRead({ node: name, field, rest, reader: step
|
|
|
490
530
|
export function checkAgent(inputs, ctx) {
|
|
491
531
|
const step = ctx.step;
|
|
492
532
|
const at = (code, message, suggestion) => ctx.report(code, message, suggestion);
|
|
533
|
+
checkInputSchema(inputs, 'Agent', ctx);
|
|
493
534
|
const inSolution = inputs?.location === 'in-solution';
|
|
494
535
|
// A blank key is the serializer's AGENT_NO_KEY (refusals.ts).
|
|
495
536
|
if (!blank(inputs?.key) && !GUID_RE.test(String(inputs.key).trim())) {
|
|
@@ -34,6 +34,8 @@ import type { FlowCheckContext } from '../../../flow-node-type.js';
|
|
|
34
34
|
* or one missing either, which has nothing to look up.
|
|
35
35
|
*/
|
|
36
36
|
export declare function processRef(inputs: unknown): ResourceRef | undefined;
|
|
37
|
+
/** A property's JSON Schema types: `['integer']`, `['string', 'null']`; `[]` for an untyped one. */
|
|
38
|
+
export declare function typesOf(property: Record<string, unknown> | undefined): string[];
|
|
37
39
|
/**
|
|
38
40
|
* The `returns` a recorded output schema declares, or undefined when it
|
|
39
41
|
* declares no field.
|
|
@@ -68,6 +70,12 @@ export declare function unrecordedKeyReason(inputs: unknown, resources: Resource
|
|
|
68
70
|
* writes. `''` when the step names no process to record.
|
|
69
71
|
*/
|
|
70
72
|
export declare function returnsFromTenantHint(inputs: unknown): string;
|
|
73
|
+
/** True for a value written as a plain JSON literal (not an expression or other object). */
|
|
74
|
+
export declare function isLiteral(v: unknown): boolean;
|
|
75
|
+
/** Whether a literal fits a JSON Schema type list; an untyped property takes anything. */
|
|
76
|
+
export declare function literalFits(v: unknown, types: readonly string[]): boolean;
|
|
77
|
+
/** A literal's JSON type, for a message. */
|
|
78
|
+
export declare function literalType(v: unknown): string;
|
|
71
79
|
/**
|
|
72
80
|
* Check a published process step against its recorded row: the key, the
|
|
73
81
|
* factory (`subType`, the binding subtype the step would be written with, is
|
|
@@ -38,7 +38,7 @@ function propertiesOf(schema) {
|
|
|
38
38
|
return typeof p === 'object' && p !== null && !Array.isArray(p) ? p : {};
|
|
39
39
|
}
|
|
40
40
|
/** A property's JSON Schema types: `['integer']`, `['string', 'null']`; `[]` for an untyped one. */
|
|
41
|
-
function typesOf(property) {
|
|
41
|
+
export function typesOf(property) {
|
|
42
42
|
const t = property?.type;
|
|
43
43
|
if (typeof t === 'string')
|
|
44
44
|
return [t];
|
|
@@ -122,7 +122,7 @@ export function returnsFromTenantHint(inputs) {
|
|
|
122
122
|
return ref === undefined ? '' : ` Or record the process (\`${resourcePrepareCommand(ref)}\`) and leave \`returns\` out: compile writes the output schema when Orchestrator has one (it prints \`Outputs\`).`;
|
|
123
123
|
}
|
|
124
124
|
/** True for a value written as a plain JSON literal (not an expression or other object). */
|
|
125
|
-
function isLiteral(v) {
|
|
125
|
+
export function isLiteral(v) {
|
|
126
126
|
if (v === null || typeof v !== 'object')
|
|
127
127
|
return true;
|
|
128
128
|
if (Array.isArray(v))
|
|
@@ -130,7 +130,7 @@ function isLiteral(v) {
|
|
|
130
130
|
return Object.getPrototypeOf(v) === Object.prototype;
|
|
131
131
|
}
|
|
132
132
|
/** Whether a literal fits a JSON Schema type list; an untyped property takes anything. */
|
|
133
|
-
function literalFits(v, types) {
|
|
133
|
+
export function literalFits(v, types) {
|
|
134
134
|
if (types.length === 0 || v === null || v === undefined)
|
|
135
135
|
return true;
|
|
136
136
|
return types.some((t) => {
|
|
@@ -147,7 +147,7 @@ function literalFits(v, types) {
|
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
/** A literal's JSON type, for a message. */
|
|
150
|
-
function literalType(v) {
|
|
150
|
+
export function literalType(v) {
|
|
151
151
|
if (Array.isArray(v))
|
|
152
152
|
return 'array';
|
|
153
153
|
if (typeof v === 'number')
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** A process's input arguments as a JSON Schema: the definition's `inputDefinition`, verbatim. */
|
|
2
|
+
export type ProcessInputSchema = Readonly<Record<string, unknown>>;
|
|
3
|
+
/**
|
|
4
|
+
* Which input definition a process kind writes: `'plain'` declares only the
|
|
5
|
+
* process's own arguments; `'with-fire-and-forget'` (agentic process) also
|
|
6
|
+
* declares the boolean `fireAndForget` switch.
|
|
7
|
+
*/
|
|
8
|
+
export type InputSchemaPolicy = 'plain' | 'with-fire-and-forget';
|
|
9
|
+
/**
|
|
10
|
+
* Whether an `inputSchema` is one compile can write: a plain JSON object.
|
|
11
|
+
* Anything else is `PROCESS_INPUT_SCHEMA_INVALID` (refusals.ts); until that
|
|
12
|
+
* refusal is reported, the definition is derived as if no schema were written,
|
|
13
|
+
* so check and the error-port lookup never trip over it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isWritableInputSchema(v: unknown): v is ProcessInputSchema;
|
|
16
|
+
/**
|
|
17
|
+
* A passed value's JSON Schema type, as compile infers it with no `inputSchema`:
|
|
18
|
+
* a literal by its JSON shape, anything else (an expression, `input()`, `out()`)
|
|
19
|
+
* a string, since its value is not known until run time.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* inferredInputType(3) // 'number'
|
|
23
|
+
* inferredInputType({}) // 'object'
|
|
24
|
+
* inferredInputType([1]) // 'array'
|
|
25
|
+
* inferredInputType(js`$x`) // 'string'
|
|
26
|
+
*/
|
|
27
|
+
export declare function inferredInputType(v: unknown): string;
|
|
28
|
+
/**
|
|
29
|
+
* The `inputDefinition` compile writes for a process step.
|
|
30
|
+
*
|
|
31
|
+
* @param inputs - The step's inputs as passed (authored or lifted).
|
|
32
|
+
* @param inputSchema - The author's `inputSchema`, or undefined to infer one
|
|
33
|
+
* from `inputs`. A value that is not a plain object is ignored here (and
|
|
34
|
+
* refused by the serializer as `PROCESS_INPUT_SCHEMA_INVALID`).
|
|
35
|
+
* @param policy - `'with-fire-and-forget'` adds the agentic-process switch to
|
|
36
|
+
* an object schema that does not declare it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function processInputDefinition(inputs: Readonly<Record<string, unknown>>, inputSchema: unknown, policy: InputSchemaPolicy): Record<string, unknown>;
|
|
39
|
+
/** The argument names an input definition declares under `properties` (none for any other shape). */
|
|
40
|
+
export declare function inputSchemaPropertyNames(definition: Readonly<Record<string, unknown>>): string[];
|
|
41
|
+
/**
|
|
42
|
+
* The `inputSchema` decompile writes for a step: the saved `inputDefinition`
|
|
43
|
+
* verbatim when compile would not reproduce it from the lifted inputs, else
|
|
44
|
+
* undefined (so a step compile wrote decompiles without one).
|
|
45
|
+
*
|
|
46
|
+
* @param saved - The definition's `inputDefinition` as the file has it.
|
|
47
|
+
* @param inputs - The step's inputs as lifted (expressions as `Expr`).
|
|
48
|
+
* @param policy - As for {@link processInputDefinition}.
|
|
49
|
+
*/
|
|
50
|
+
export declare function liftedInputSchema(saved: unknown, inputs: Readonly<Record<string, unknown>>, policy: InputSchemaPolicy): ProcessInputSchema | undefined;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The process family's input schema: what a process step's definition says
|
|
3
|
+
* about the arguments the process takes (`inputDefinition`), and how that
|
|
4
|
+
* survives a decompile → compile round trip.
|
|
5
|
+
*
|
|
6
|
+
* Compile has two sources for it:
|
|
7
|
+
*
|
|
8
|
+
* - the author's `inputSchema` option, written verbatim (the platform's own
|
|
9
|
+
* definition carries the deployed process's argument schema, with titles,
|
|
10
|
+
* descriptions, enums and `additionalProperties`, and a decompiled step
|
|
11
|
+
* carries that schema back here);
|
|
12
|
+
* - otherwise, one property per passed input, typed from the value passed.
|
|
13
|
+
*
|
|
14
|
+
* Decompile writes `inputSchema` only when the saved definition says something
|
|
15
|
+
* the second rule would not reproduce, so an SDK-authored step decompiles to
|
|
16
|
+
* the source it came from.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // A saved definition types `owsResult` as an object; the step passes `{}`.
|
|
20
|
+
* // Inferred, compile would write `{ owsResult: { type: 'object' } }` without the
|
|
21
|
+
* // title, so decompile carries the saved schema:
|
|
22
|
+
* publishedFunction({ key, name, folderPath, inputs: { owsResult: {} },
|
|
23
|
+
* inputSchema: { type: 'object', properties: { owsResult: { type: 'object', title: 'Owsresult' } } } })
|
|
24
|
+
*/
|
|
25
|
+
import { Expr } from '../../../core/expr.js';
|
|
26
|
+
import { isLiteral } from './contract.js';
|
|
27
|
+
/** The input the agentic-process definition always declares: the design-time fire-and-forget switch. */
|
|
28
|
+
const FIRE_AND_FORGET = 'fireAndForget';
|
|
29
|
+
/**
|
|
30
|
+
* Whether an `inputSchema` is one compile can write: a plain JSON object.
|
|
31
|
+
* Anything else is `PROCESS_INPUT_SCHEMA_INVALID` (refusals.ts); until that
|
|
32
|
+
* refusal is reported, the definition is derived as if no schema were written,
|
|
33
|
+
* so check and the error-port lookup never trip over it.
|
|
34
|
+
*/
|
|
35
|
+
export function isWritableInputSchema(v) {
|
|
36
|
+
return isPlainObject(v);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A passed value's JSON Schema type, as compile infers it with no `inputSchema`:
|
|
40
|
+
* a literal by its JSON shape, anything else (an expression, `input()`, `out()`)
|
|
41
|
+
* a string, since its value is not known until run time.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* inferredInputType(3) // 'number'
|
|
45
|
+
* inferredInputType({}) // 'object'
|
|
46
|
+
* inferredInputType([1]) // 'array'
|
|
47
|
+
* inferredInputType(js`$x`) // 'string'
|
|
48
|
+
*/
|
|
49
|
+
export function inferredInputType(v) {
|
|
50
|
+
const value = v instanceof Expr && v.literal ? v.value : v;
|
|
51
|
+
if (typeof value === 'number')
|
|
52
|
+
return 'number';
|
|
53
|
+
if (typeof value === 'boolean')
|
|
54
|
+
return 'boolean';
|
|
55
|
+
if (Array.isArray(value))
|
|
56
|
+
return 'array';
|
|
57
|
+
if (value !== null && typeof value === 'object' && isLiteral(value))
|
|
58
|
+
return 'object';
|
|
59
|
+
return 'string';
|
|
60
|
+
}
|
|
61
|
+
function isPlainObject(v) {
|
|
62
|
+
return typeof v === 'object' && v !== null && !Array.isArray(v) && isLiteral(v);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The `inputDefinition` compile writes for a process step.
|
|
66
|
+
*
|
|
67
|
+
* @param inputs - The step's inputs as passed (authored or lifted).
|
|
68
|
+
* @param inputSchema - The author's `inputSchema`, or undefined to infer one
|
|
69
|
+
* from `inputs`. A value that is not a plain object is ignored here (and
|
|
70
|
+
* refused by the serializer as `PROCESS_INPUT_SCHEMA_INVALID`).
|
|
71
|
+
* @param policy - `'with-fire-and-forget'` adds the agentic-process switch to
|
|
72
|
+
* an object schema that does not declare it.
|
|
73
|
+
*/
|
|
74
|
+
export function processInputDefinition(inputs, inputSchema, policy) {
|
|
75
|
+
const fireAndForget = policy === 'with-fire-and-forget';
|
|
76
|
+
if (isWritableInputSchema(inputSchema)) {
|
|
77
|
+
const schema = JSON.parse(JSON.stringify(inputSchema));
|
|
78
|
+
if (fireAndForget && isPlainObject(schema.properties) && !Object.hasOwn(schema.properties, FIRE_AND_FORGET)) {
|
|
79
|
+
schema.properties = { ...schema.properties, [FIRE_AND_FORGET]: { type: 'boolean' } };
|
|
80
|
+
}
|
|
81
|
+
return schema;
|
|
82
|
+
}
|
|
83
|
+
const properties = {};
|
|
84
|
+
for (const [k, v] of Object.entries(inputs))
|
|
85
|
+
properties[k] = { type: inferredInputType(v) };
|
|
86
|
+
if (fireAndForget)
|
|
87
|
+
return { type: 'object', properties: { ...properties, [FIRE_AND_FORGET]: { type: 'boolean' } } };
|
|
88
|
+
return Object.keys(properties).length ? { type: 'object', properties } : {};
|
|
89
|
+
}
|
|
90
|
+
/** The argument names an input definition declares under `properties` (none for any other shape). */
|
|
91
|
+
export function inputSchemaPropertyNames(definition) {
|
|
92
|
+
return isPlainObject(definition.properties) ? Object.keys(definition.properties) : [];
|
|
93
|
+
}
|
|
94
|
+
/** JSON with object keys sorted, so two schemas compare equal whatever order their keys were written in. */
|
|
95
|
+
function canonical(v) {
|
|
96
|
+
return JSON.stringify(v, (_k, x) => (isPlainObject(x)
|
|
97
|
+
? Object.fromEntries(Object.keys(x).sort().map((k) => [k, x[k]]))
|
|
98
|
+
: x));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The `inputSchema` decompile writes for a step: the saved `inputDefinition`
|
|
102
|
+
* verbatim when compile would not reproduce it from the lifted inputs, else
|
|
103
|
+
* undefined (so a step compile wrote decompiles without one).
|
|
104
|
+
*
|
|
105
|
+
* @param saved - The definition's `inputDefinition` as the file has it.
|
|
106
|
+
* @param inputs - The step's inputs as lifted (expressions as `Expr`).
|
|
107
|
+
* @param policy - As for {@link processInputDefinition}.
|
|
108
|
+
*/
|
|
109
|
+
export function liftedInputSchema(saved, inputs, policy) {
|
|
110
|
+
const schema = isPlainObject(saved) ? saved : {};
|
|
111
|
+
const inferred = processInputDefinition(inputs, undefined, policy);
|
|
112
|
+
return canonical(processInputDefinition(inputs, schema, policy)) === canonical(inferred) ? undefined : schema;
|
|
113
|
+
}
|
|
@@ -22,6 +22,7 @@ import { checkRecordedProcess, withRecordedProcess } from './contract.js';
|
|
|
22
22
|
import { processLabel, refuseLossyProcess } from './refusals.js';
|
|
23
23
|
import { refuseInSolution, resolveInSolution } from './in-solution.js';
|
|
24
24
|
import { declareKeys } from '../../../core/option-keys.js';
|
|
25
|
+
import { inputSchemaPropertyNames, liftedInputSchema, processInputDefinition } from './input-schema.js';
|
|
25
26
|
/** The RPA-workflow node type family. The process's release key is the suffix. */
|
|
26
27
|
const RPA_WORKFLOW_PREFIX = 'uipath.core.rpa-workflow.';
|
|
27
28
|
/**
|
|
@@ -53,7 +54,9 @@ const RPA_WORKFLOW_PREFIX = 'uipath.core.rpa-workflow.';
|
|
|
53
54
|
* what is evidenced — but here the evidence is the authored call, not the
|
|
54
55
|
* deployed process, so it cannot catch an argument the process does not have.
|
|
55
56
|
* Nothing local can: only the robot knows. A wrong argument name faults the
|
|
56
|
-
* job on a live run, which is what the `robot` rung is for.
|
|
57
|
+
* job on a live run, which is what the `robot` rung is for. An `inputSchema`
|
|
58
|
+
* the author (or decompile, from a saved definition) writes replaces the
|
|
59
|
+
* inferred one verbatim (`input-schema.ts`).
|
|
57
60
|
* - `outputDefinition.output` carries no schema for the same reason. Its source
|
|
58
61
|
* expressions follow the tenant-current registry (`=this` / `=Error`). Older
|
|
59
62
|
* corpus artifacts mostly used `=result.response` / `=result.Error`, but a
|
|
@@ -63,10 +66,6 @@ const RPA_WORKFLOW_PREFIX = 'uipath.core.rpa-workflow.';
|
|
|
63
66
|
function rpaWorkflowDef(spec) {
|
|
64
67
|
const loc = processResourceLocation(spec);
|
|
65
68
|
const { resourceKey } = loc;
|
|
66
|
-
const properties = {};
|
|
67
|
-
for (const [k, v] of Object.entries(spec.inputs)) {
|
|
68
|
-
properties[k] = { type: typeof v === 'number' ? 'number' : typeof v === 'boolean' ? 'boolean' : 'string' };
|
|
69
|
-
}
|
|
70
69
|
return {
|
|
71
70
|
nodeType: `${RPA_WORKFLOW_PREFIX}${spec.key}`,
|
|
72
71
|
version: '1.0.0',
|
|
@@ -104,7 +103,7 @@ function rpaWorkflowDef(spec) {
|
|
|
104
103
|
{ name: '_label', type: 'string', value: spec.name },
|
|
105
104
|
],
|
|
106
105
|
},
|
|
107
|
-
inputDefinition:
|
|
106
|
+
inputDefinition: processInputDefinition(spec.inputs, spec.inputSchema, 'plain'),
|
|
108
107
|
inputDefaults: {},
|
|
109
108
|
outputDefinition: {
|
|
110
109
|
output: {
|
|
@@ -182,10 +181,6 @@ const API_WORKFLOW_PREFIX = 'uipath.core.api-workflow.';
|
|
|
182
181
|
function apiWorkflowDef(spec) {
|
|
183
182
|
const loc = processResourceLocation(spec);
|
|
184
183
|
const { resourceKey } = loc;
|
|
185
|
-
const properties = {};
|
|
186
|
-
for (const [k, v] of Object.entries(spec.inputs)) {
|
|
187
|
-
properties[k] = { type: typeof v === 'number' ? 'number' : typeof v === 'boolean' ? 'boolean' : 'string' };
|
|
188
|
-
}
|
|
189
184
|
return {
|
|
190
185
|
nodeType: `${API_WORKFLOW_PREFIX}${spec.key}`,
|
|
191
186
|
version: '1.0.0',
|
|
@@ -223,7 +218,7 @@ function apiWorkflowDef(spec) {
|
|
|
223
218
|
{ name: '_label', type: 'string', value: spec.name },
|
|
224
219
|
],
|
|
225
220
|
},
|
|
226
|
-
inputDefinition:
|
|
221
|
+
inputDefinition: processInputDefinition(spec.inputs, spec.inputSchema, 'plain'),
|
|
227
222
|
inputDefaults: {},
|
|
228
223
|
outputDefinition: {
|
|
229
224
|
output: {
|
|
@@ -271,10 +266,6 @@ function publishedFunctionDef(spec) {
|
|
|
271
266
|
// `section`, and `projectId`/`projectName`/`isInSolution` on the model.
|
|
272
267
|
const loc = processResourceLocation(spec);
|
|
273
268
|
const { resourceKey } = loc;
|
|
274
|
-
const properties = {};
|
|
275
|
-
for (const [k, v] of Object.entries(spec.inputs)) {
|
|
276
|
-
properties[k] = { type: typeof v === 'number' ? 'number' : typeof v === 'boolean' ? 'boolean' : 'string' };
|
|
277
|
-
}
|
|
278
269
|
return {
|
|
279
270
|
nodeType: `${FUNCTION_PREFIX}${spec.key}`,
|
|
280
271
|
version: '1.0.0',
|
|
@@ -322,7 +313,7 @@ function publishedFunctionDef(spec) {
|
|
|
322
313
|
{ name: '_label', type: 'string', value: spec.name },
|
|
323
314
|
],
|
|
324
315
|
},
|
|
325
|
-
inputDefinition:
|
|
316
|
+
inputDefinition: processInputDefinition(spec.inputs, spec.inputSchema, 'plain'),
|
|
326
317
|
inputDefaults: {},
|
|
327
318
|
outputDefinition: {
|
|
328
319
|
output: {
|
|
@@ -394,10 +385,6 @@ function agenticProcessDef(spec) {
|
|
|
394
385
|
const form = ownEntry(AGENTIC_PROCESS_FORMS, spec.form ?? 'bpmn') ?? AGENTIC_PROCESS_FORMS.bpmn;
|
|
395
386
|
const loc = processResourceLocation(spec);
|
|
396
387
|
const { resourceKey } = loc;
|
|
397
|
-
const properties = {};
|
|
398
|
-
for (const [k, v] of Object.entries(spec.inputs)) {
|
|
399
|
-
properties[k] = { type: typeof v === 'number' ? 'number' : typeof v === 'boolean' ? 'boolean' : 'string' };
|
|
400
|
-
}
|
|
401
388
|
return {
|
|
402
389
|
nodeType: `${form.prefix}${spec.key}`,
|
|
403
390
|
version: '1.0.0',
|
|
@@ -439,7 +426,7 @@ function agenticProcessDef(spec) {
|
|
|
439
426
|
// declares it: a boolean INPUT on the definition (default false). The sync
|
|
440
427
|
// serviceType stays on the model — the platform's BPMN serializer swaps in
|
|
441
428
|
// the async sibling when the instance opts in.
|
|
442
|
-
inputDefinition:
|
|
429
|
+
inputDefinition: processInputDefinition(spec.inputs, spec.inputSchema, 'with-fire-and-forget'),
|
|
443
430
|
inputDefaults: { fireAndForget: false },
|
|
444
431
|
outputDefinition: {
|
|
445
432
|
output: {
|
|
@@ -528,10 +515,7 @@ function agentDef(spec) {
|
|
|
528
515
|
// flow-core's `createModel` writes for every sibling-project resource.
|
|
529
516
|
const loc = processResourceLocation(spec);
|
|
530
517
|
const { inSolution, resourceKey } = loc;
|
|
531
|
-
const
|
|
532
|
-
for (const [k, v] of Object.entries(spec.inputs)) {
|
|
533
|
-
properties[k] = { type: typeof v === 'number' ? 'number' : typeof v === 'boolean' ? 'boolean' : 'string' };
|
|
534
|
-
}
|
|
518
|
+
const inputDefinition = processInputDefinition(spec.inputs, spec.inputSchema, 'plain');
|
|
535
519
|
return {
|
|
536
520
|
nodeType: `${AGENT_PREFIX}${spec.key}`,
|
|
537
521
|
version: '1.0.0',
|
|
@@ -572,9 +556,9 @@ function agentDef(spec) {
|
|
|
572
556
|
{ name: '_label', type: 'string', value: spec.name },
|
|
573
557
|
],
|
|
574
558
|
},
|
|
575
|
-
inputDefinition
|
|
559
|
+
inputDefinition,
|
|
576
560
|
inputDefaults: inSolution
|
|
577
|
-
? Object.fromEntries(
|
|
561
|
+
? Object.fromEntries(inputSchemaPropertyNames(inputDefinition).map((name) => [name, '']))
|
|
578
562
|
: {},
|
|
579
563
|
outputDefinition: {
|
|
580
564
|
output: {
|
|
@@ -615,27 +599,27 @@ export function processDefinition(spec) {
|
|
|
615
599
|
case 'publishedFunction':
|
|
616
600
|
return publishedFunctionDef({
|
|
617
601
|
key: s.key, name: s.name, folderPath: s.folderPath, location: s.location, projectId: s.projectId,
|
|
618
|
-
inputs: s.inputs ?? {}, returns: s.returns,
|
|
602
|
+
inputs: s.inputs ?? {}, inputSchema: s.inputSchema, returns: s.returns,
|
|
619
603
|
});
|
|
620
604
|
case 'apiWorkflow':
|
|
621
605
|
return apiWorkflowDef({
|
|
622
606
|
key: s.key, name: s.name, folderPath: s.folderPath, location: s.location, projectId: s.projectId,
|
|
623
|
-
inputs: s.inputs ?? {}, returns: s.returns,
|
|
607
|
+
inputs: s.inputs ?? {}, inputSchema: s.inputSchema, returns: s.returns,
|
|
624
608
|
});
|
|
625
609
|
case 'agenticProcess':
|
|
626
610
|
return agenticProcessDef({
|
|
627
611
|
key: s.key, name: s.name, folderPath: s.folderPath, location: s.location, projectId: s.projectId,
|
|
628
|
-
inputs: s.inputs ?? {}, returns: s.returns, form: s.form,
|
|
612
|
+
inputs: s.inputs ?? {}, inputSchema: s.inputSchema, returns: s.returns, form: s.form,
|
|
629
613
|
});
|
|
630
614
|
case 'rpaWorkflow':
|
|
631
615
|
return rpaWorkflowDef({
|
|
632
616
|
key: s.key, name: s.name, folderPath: s.folderPath, location: s.location, projectId: s.projectId,
|
|
633
|
-
inputs: s.inputs ?? {}, returns: s.returns,
|
|
617
|
+
inputs: s.inputs ?? {}, inputSchema: s.inputSchema, returns: s.returns,
|
|
634
618
|
});
|
|
635
619
|
case 'agent':
|
|
636
620
|
return agentDef({
|
|
637
621
|
key: s.key, name: s.name, folderPath: s.folderPath, location: s.location, projectId: s.projectId,
|
|
638
|
-
inputs: s.inputs ?? {}, returns: s.returns, flavour: s.flavour,
|
|
622
|
+
inputs: s.inputs ?? {}, inputSchema: s.inputSchema, returns: s.returns, flavour: s.flavour,
|
|
639
623
|
});
|
|
640
624
|
}
|
|
641
625
|
}
|
|
@@ -774,13 +758,21 @@ function liftProcess(node, ctx, prefix, kind, form) {
|
|
|
774
758
|
+ `a fire-and-forget dispatch publishes no output, and agenticProcess() refuses the pair. Compile writes the `
|
|
775
759
|
+ `definition without that schema. To read the process result, set completion: 'wait' and declare \`returns\`.`);
|
|
776
760
|
}
|
|
761
|
+
const liftedInputs = Object.fromEntries(Object.entries(inputs).map(([k, v]) => [k, lifted(v, ctx)]));
|
|
762
|
+
// The saved argument schema, when compile would not write it back from the
|
|
763
|
+
// inputs alone: a definition that types `owsResult` as an object, or that
|
|
764
|
+
// declares an argument the step does not pass, or one it passes as
|
|
765
|
+
// undeclared. Inferred, every non-literal input became `{ type: 'string' }`
|
|
766
|
+
// and a passed `{}` then failed validate's type check.
|
|
767
|
+
const inputSchema = liftedInputSchema(def?.inputDefinition, liftedInputs, kind === 'agenticProcess' ? 'with-fire-and-forget' : 'plain');
|
|
777
768
|
const spec = {
|
|
778
769
|
key,
|
|
779
770
|
...(name !== undefined ? { name } : {}),
|
|
780
771
|
...(inSolution ? { location: 'in-solution' } : {}),
|
|
781
772
|
...(!inSolution && folderPath !== undefined ? { folderPath } : {}),
|
|
782
773
|
...(inSolution && projectId !== undefined ? { projectId } : {}),
|
|
783
|
-
...(Object.keys(inputs).length ? { inputs:
|
|
774
|
+
...(Object.keys(inputs).length ? { inputs: liftedInputs } : {}),
|
|
775
|
+
...(inputSchema !== undefined ? { inputSchema } : {}),
|
|
784
776
|
...(returns !== undefined && !fireAndForget ? { returns } : {}),
|
|
785
777
|
...(form !== undefined ? { form } : {}),
|
|
786
778
|
...(fireAndForget ? { completion: 'fire-and-forget' } : {}),
|
|
@@ -803,6 +795,7 @@ function printProcess(spec, ctx, factory) {
|
|
|
803
795
|
['folderPath', p.folderPath !== undefined ? ctx.string(p.folderPath) : undefined],
|
|
804
796
|
['projectId', p.projectId !== undefined ? ctx.string(p.projectId) : undefined],
|
|
805
797
|
['inputs', p.inputs !== undefined ? obj(Object.entries(p.inputs).map(([k, v]) => [k, val(v)])) : undefined],
|
|
798
|
+
['inputSchema', p.inputSchema !== undefined ? ctx.json(p.inputSchema) : undefined],
|
|
806
799
|
['returns', p.returns !== undefined ? obj(Object.entries(p.returns).map(([k, t]) => [k, ctx.string(t)])) : undefined],
|
|
807
800
|
['form', p.form !== undefined ? ctx.string(p.form) : undefined],
|
|
808
801
|
['completion', p.completion !== undefined ? ctx.string(p.completion) : undefined],
|
|
@@ -856,11 +849,11 @@ function processCheck(authored, ctx) {
|
|
|
856
849
|
}
|
|
857
850
|
/** Every key of each factory's options (builder-sdk#1990), by kind; `tsc` holds each list to its type. */
|
|
858
851
|
const PROCESS_OPTIONS = {
|
|
859
|
-
rpaWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
|
|
860
|
-
apiWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
|
|
861
|
-
publishedFunction: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
|
|
862
|
-
agenticProcess: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, form: true, completion: true, returns: true }) },
|
|
863
|
-
agent: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, returns: true, flavour: true }) },
|
|
852
|
+
rpaWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, inputSchema: true, returns: true }) },
|
|
853
|
+
apiWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, inputSchema: true, returns: true }) },
|
|
854
|
+
publishedFunction: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, inputSchema: true, returns: true }) },
|
|
855
|
+
agenticProcess: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, inputSchema: true, form: true, completion: true, returns: true }) },
|
|
856
|
+
agent: { inputs: declareKeys({ key: true, name: true, location: true, project: true, folderPath: true, projectId: true, inputs: true, inputSchema: true, returns: true, flavour: true }) },
|
|
864
857
|
};
|
|
865
858
|
function processType(kind, prefix, factory, form) {
|
|
866
859
|
const impl = {
|
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
* folder `""` (`processResourceLocation`), so the author's folderPath is dropped.
|
|
12
12
|
* - `AGENTIC_RESERVED_INPUT`: `fireAndForget` is the design-time switch; the
|
|
13
13
|
* definition retypes it boolean and decompile deletes it as an argument.
|
|
14
|
+
* - `PROCESS_INPUT_SCHEMA_INVALID`: `inputSchema` is written verbatim as the
|
|
15
|
+
* definition's `inputDefinition`, so it must be a plain JSON object.
|
|
14
16
|
*/
|
|
15
17
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
16
18
|
import { ownEntry } from '../../../core/own-entry.js';
|
|
17
19
|
import { blank, renamedFieldMessage } from '../../../core/process-resource.js';
|
|
18
20
|
import { unrecordedKeyReason } from './contract.js';
|
|
21
|
+
import { isWritableInputSchema } from './input-schema.js';
|
|
19
22
|
/** Per kind: the codes, the label messages use, and the retired name of `key` (if any). */
|
|
20
23
|
const KINDS = {
|
|
21
24
|
rpaWorkflow: {
|
|
@@ -97,6 +100,15 @@ export function refuseLossyProcess(kind, inputs, step, resources) {
|
|
|
97
100
|
+ `arrives. Locally it would appear to work, because this engine passes the whole envelope through. `
|
|
98
101
|
+ `Rename the argument, or set \`completion: 'fire-and-forget'\` to start the process without waiting.`);
|
|
99
102
|
}
|
|
103
|
+
// `inputSchema` is written verbatim as the definition's `inputDefinition`, so it
|
|
104
|
+
// has to be the JSON object a definition holds: an expression or an array would
|
|
105
|
+
// be serialized as whatever its fields happen to be.
|
|
106
|
+
const schema = s.inputSchema;
|
|
107
|
+
if (schema !== undefined && !isWritableInputSchema(schema)) {
|
|
108
|
+
throw new CompileRefusal('PROCESS_INPUT_SCHEMA_INVALID', `${k.label} step "${step}"'s \`inputSchema\` is not a JSON object. It is written as is as the definition's `
|
|
109
|
+
+ `\`inputDefinition\` (the process's argument schema), so it has to be a plain object literal, e.g. `
|
|
110
|
+
+ `\`{ type: 'object', properties: { payload: { type: 'object' } } }\`. Leave it out to declare each input typed from its value.`, `inputSchema: { type: 'object', properties: { … } }`);
|
|
111
|
+
}
|
|
100
112
|
}
|
|
101
113
|
/** How a message names a process kind's step: `RPA`, `API workflow`, `Agent`, … */
|
|
102
114
|
export function processLabel(kind) {
|