@uipath/maestro-builder-sdk 6.84.0 → 6.85.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/bpmn/decompile.js
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
* path/query split.
|
|
54
54
|
*/
|
|
55
55
|
import BpmnModdle from 'bpmn-moddle';
|
|
56
|
+
import { flattenConnectorBody } from '../core/connector-inputs.js';
|
|
56
57
|
import { createRequire } from 'node:module';
|
|
57
58
|
import { registryType, rowDeclaration } from './typed-node.js';
|
|
58
59
|
import { errorSchema, errorSchemaWithResponse } from './bpmn-sdk.js';
|
|
@@ -372,18 +373,26 @@ function planConnectorLift(el, payload) {
|
|
|
372
373
|
return `the library cannot resolve ${identity.key}/${identity.action}: ${e.message}`;
|
|
373
374
|
}
|
|
374
375
|
const inputs = {};
|
|
375
|
-
|
|
376
|
+
// `.connector()` validates every input against the library, and a field the static
|
|
377
|
+
// library does not declare — an entity's own columns on a Data Fabric update, a Jira
|
|
378
|
+
// project's custom fields — is refused until `registry prepare` loads it. The hint is
|
|
379
|
+
// given for every operation: the registry's own schema flags are not evidence that
|
|
380
|
+
// prepare cannot help (it marks Jira `create-issue` `requiresConnectionForSchema:
|
|
381
|
+
// false`, and `prepare -f` takes that operation from 5 fields to about 20).
|
|
382
|
+
const notInLibrary = (where, k) => `${where} field "${k}" is not in the library for ${identity.key}/${identity.action} ` +
|
|
383
|
+
'(if it is connection-specific, `registry prepare` loads it; `prepare -f <parent>=<value>` adds the fields a parent value unlocks)';
|
|
384
|
+
const put = (k, v, where) => {
|
|
376
385
|
if (k in inputs)
|
|
377
386
|
return `"${k}" appears both in ${where} and in another row`;
|
|
378
|
-
// `.connector()` validates every input against the library, and a field the
|
|
379
|
-
// static library does not declare — an entity's own columns on a Data Fabric
|
|
380
|
-
// update, a form's fields — is refused until `registry prepare` loads it.
|
|
381
|
-
if (!declared.has(k) && !declared.has(k.split('.')[0])) {
|
|
382
|
-
return `${where} field "${k}" is not in the library for ${identity.key}/${identity.action} (connection-specific; \`registry prepare\` loads it)`;
|
|
383
|
-
}
|
|
384
387
|
inputs[k] = v;
|
|
385
388
|
return undefined;
|
|
386
389
|
};
|
|
390
|
+
/** A parameter or file row's input: its name is flat, so it is checked as it is. */
|
|
391
|
+
const take = (k, v, where) => {
|
|
392
|
+
if (!declared.has(k) && !declared.has(k.split('.')[0]))
|
|
393
|
+
return notInLibrary(where, k);
|
|
394
|
+
return put(k, v, where);
|
|
395
|
+
};
|
|
387
396
|
for (const row of payload.input ?? []) {
|
|
388
397
|
const target = row.target;
|
|
389
398
|
if (target === 'file') {
|
|
@@ -404,10 +413,28 @@ function planConnectorLift(el, payload) {
|
|
|
404
413
|
const value = safeJson(row.body ?? '{}');
|
|
405
414
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
406
415
|
return `the ${row.name} row is not a JSON object`;
|
|
416
|
+
if (row.name === 'body') {
|
|
417
|
+
// The file writes the body nested and the library declares its fields dotted
|
|
418
|
+
// (`fields.project.key`), so the body is read back into the dotted inputs it
|
|
419
|
+
// compiles from.
|
|
420
|
+
const flat = flattenConnectorBody(value, declared);
|
|
421
|
+
if ('refusal' in flat) {
|
|
422
|
+
const { refusal } = flat;
|
|
423
|
+
return refusal.kind === 'undeclared'
|
|
424
|
+
? notInLibrary('the body row', refusal.field)
|
|
425
|
+
: `${refusal.message} (${identity.key}/${identity.action})`;
|
|
426
|
+
}
|
|
427
|
+
for (const [k, v] of Object.entries(flat.inputs)) {
|
|
428
|
+
const refused = put(k, v, 'the body row');
|
|
429
|
+
if (refused)
|
|
430
|
+
return refused;
|
|
431
|
+
}
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
407
434
|
for (const [k, v] of Object.entries(value)) {
|
|
408
435
|
// A parameter Studio Web saved as text (`"start": "0"`) is coerced to the type
|
|
409
436
|
// the library declares, which the shared validator checks.
|
|
410
|
-
const lifted =
|
|
437
|
+
const lifted = typeof v === 'string' ? liftedInputValue(v, params.get(k)) : v;
|
|
411
438
|
const refused = take(k, lifted, `the ${row.name} row`);
|
|
412
439
|
if (refused)
|
|
413
440
|
return refused;
|
|
@@ -136,6 +136,50 @@ interface ConnectorSlots {
|
|
|
136
136
|
* author already wrote under a plain key is merged into, not replaced.
|
|
137
137
|
*/
|
|
138
138
|
export declare function nestConnectorBody(flat: Record<string, unknown>): Record<string, unknown>;
|
|
139
|
+
/** Why a written request body has no `.connector()` inputs: the body field, and what is wrong with it. */
|
|
140
|
+
export interface ConnectorBodyRefusal {
|
|
141
|
+
/** The body field, as a dotted path into the written body (`fields.project`). */
|
|
142
|
+
field: string;
|
|
143
|
+
/**
|
|
144
|
+
* `undeclared` — the operation declares no field at that path; `literal-dotted` — a
|
|
145
|
+
* property NAME holds a dot, which `nestConnectorBody` would split into objects;
|
|
146
|
+
* `shape` — the library declares the path, but the value is not one compile could
|
|
147
|
+
* have written there (a non-array at a `[*]` field, a scalar or an empty object
|
|
148
|
+
* where the library has only sub-fields).
|
|
149
|
+
*/
|
|
150
|
+
kind: 'undeclared' | 'literal-dotted' | 'shape';
|
|
151
|
+
message: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The inverse of {@link nestConnectorBody}: a request body as the BPMN file writes it
|
|
155
|
+
* (nested), read back into the `.connector()` inputs it compiles from, keyed by the
|
|
156
|
+
* registry's dotted field ids — `{"fields":{"project":{"key":"CE"}}}` →
|
|
157
|
+
* `{"fields.project.key":"CE"}`. `fieldNames` are the operation's declared field ids
|
|
158
|
+
* (`fields.project.key`, `sendSettings.selectedCampaigns[*]`); a top-level parameter
|
|
159
|
+
* name is a field id too.
|
|
160
|
+
*
|
|
161
|
+
* A key is emitted under the field id exactly as the library spells it, `[*]` marker
|
|
162
|
+
* included, so the inputs say what `prepare -f` and `lookup()` say. A path the library
|
|
163
|
+
* declares as a field in its own right keeps its whole value there, even when the
|
|
164
|
+
* library declares sub-fields under it too (`meta` and `meta.id`): compile reads the
|
|
165
|
+
* whole value for the parent, so a required parent stays filled.
|
|
166
|
+
*
|
|
167
|
+
* One shape has no dotted spelling: an array of OBJECTS (`attachments[*].url` — a flat
|
|
168
|
+
* key cannot carry one value per element). The whole top-level key that holds one is
|
|
169
|
+
* kept in the natural nested form, which `buildConnectorInputs` reads too
|
|
170
|
+
* (`readConnectorPath`). Its subtree is still walked to the end, so the refusals below
|
|
171
|
+
* apply to it whatever order its keys come in.
|
|
172
|
+
*
|
|
173
|
+
* Returns the refusal instead when a key is not declared, when a property NAME holds a
|
|
174
|
+
* dot (a literal `"fields.summary"` property — nesting would split it, so it is not the
|
|
175
|
+
* request the file sends), or when a value is not one compile could have written at its
|
|
176
|
+
* path.
|
|
177
|
+
*/
|
|
178
|
+
export declare function flattenConnectorBody(body: Record<string, unknown>, fieldNames: Iterable<string>): {
|
|
179
|
+
inputs: Record<string, unknown>;
|
|
180
|
+
} | {
|
|
181
|
+
refusal: ConnectorBodyRefusal;
|
|
182
|
+
};
|
|
139
183
|
/**
|
|
140
184
|
* Convert an Integration Service operation discriminator into an HTTP transport
|
|
141
185
|
* verb. `GETBYID` identifies a curated Retrieve operation in the connector
|
|
@@ -380,6 +380,112 @@ export function nestConnectorBody(flat) {
|
|
|
380
380
|
}
|
|
381
381
|
return out;
|
|
382
382
|
}
|
|
383
|
+
/** A value's kind, as a refusal names it. */
|
|
384
|
+
function valueKind(value) {
|
|
385
|
+
if (isRecord(value))
|
|
386
|
+
return Object.keys(value).length ? 'an object' : 'an empty object';
|
|
387
|
+
if (Array.isArray(value))
|
|
388
|
+
return 'an array';
|
|
389
|
+
return value === null ? 'null' : `a ${typeof value}`;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The inverse of {@link nestConnectorBody}: a request body as the BPMN file writes it
|
|
393
|
+
* (nested), read back into the `.connector()` inputs it compiles from, keyed by the
|
|
394
|
+
* registry's dotted field ids — `{"fields":{"project":{"key":"CE"}}}` →
|
|
395
|
+
* `{"fields.project.key":"CE"}`. `fieldNames` are the operation's declared field ids
|
|
396
|
+
* (`fields.project.key`, `sendSettings.selectedCampaigns[*]`); a top-level parameter
|
|
397
|
+
* name is a field id too.
|
|
398
|
+
*
|
|
399
|
+
* A key is emitted under the field id exactly as the library spells it, `[*]` marker
|
|
400
|
+
* included, so the inputs say what `prepare -f` and `lookup()` say. A path the library
|
|
401
|
+
* declares as a field in its own right keeps its whole value there, even when the
|
|
402
|
+
* library declares sub-fields under it too (`meta` and `meta.id`): compile reads the
|
|
403
|
+
* whole value for the parent, so a required parent stays filled.
|
|
404
|
+
*
|
|
405
|
+
* One shape has no dotted spelling: an array of OBJECTS (`attachments[*].url` — a flat
|
|
406
|
+
* key cannot carry one value per element). The whole top-level key that holds one is
|
|
407
|
+
* kept in the natural nested form, which `buildConnectorInputs` reads too
|
|
408
|
+
* (`readConnectorPath`). Its subtree is still walked to the end, so the refusals below
|
|
409
|
+
* apply to it whatever order its keys come in.
|
|
410
|
+
*
|
|
411
|
+
* Returns the refusal instead when a key is not declared, when a property NAME holds a
|
|
412
|
+
* dot (a literal `"fields.summary"` property — nesting would split it, so it is not the
|
|
413
|
+
* request the file sends), or when a value is not one compile could have written at its
|
|
414
|
+
* path.
|
|
415
|
+
*/
|
|
416
|
+
export function flattenConnectorBody(body, fieldNames) {
|
|
417
|
+
const root = buildConnectorInputTrie([...fieldNames].map((name) => ({ name })));
|
|
418
|
+
const shape = (field, value, declared) => ({
|
|
419
|
+
refusal: { field, kind: 'shape', message: `body field "${field}" is ${valueKind(value)} where the library declares ${declared}` },
|
|
420
|
+
});
|
|
421
|
+
const subFieldsOf = (node, at) => {
|
|
422
|
+
const names = [...node.children.keys()];
|
|
423
|
+
return `${names.slice(0, 3).map((k) => `${at}.${k}`).join(', ')}${names.length > 3 ? ', …' : ''}`;
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Flatten the object `value` (at `node`) into `out`. Returns a refusal, or `nested`
|
|
427
|
+
* when the subtree holds an array of objects; the walk goes on to the end either way.
|
|
428
|
+
*/
|
|
429
|
+
const walk = (value, node, wire, path, out) => {
|
|
430
|
+
let nested = false;
|
|
431
|
+
for (const [key, child] of Object.entries(value)) {
|
|
432
|
+
const at = path ? `${path}.${key}` : key;
|
|
433
|
+
if (key.includes('.')) {
|
|
434
|
+
return {
|
|
435
|
+
refusal: {
|
|
436
|
+
field: at,
|
|
437
|
+
kind: 'literal-dotted',
|
|
438
|
+
message: `body field "${at}" is one property whose name holds a dot; .connector() nests a dotted field into objects, which is a different request`,
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const next = node.children.get(key);
|
|
443
|
+
if (!next)
|
|
444
|
+
return { refusal: { field: at, kind: 'undeclared', message: `body field "${at}" is not in the library` } };
|
|
445
|
+
const id = `${wire ? `${wire}.` : ''}${key}${next.array ? '[*]' : ''}`;
|
|
446
|
+
// Compile writes an array at every `[*]` segment (`nestConnectorBody` wraps a
|
|
447
|
+
// scalar), so anything else there is a request no input reproduces.
|
|
448
|
+
if (next.array && !Array.isArray(child))
|
|
449
|
+
return shape(at, child, `an array (${id})`);
|
|
450
|
+
if (next.children.size === 0 || next.terminal) {
|
|
451
|
+
out[id] = child;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (next.array) {
|
|
455
|
+
// An array of objects: check each element against the element's fields.
|
|
456
|
+
for (const [i, element] of child.entries()) {
|
|
457
|
+
if (!isRecord(element))
|
|
458
|
+
return shape(`${at}[${i}]`, element, `an object with fields (${subFieldsOf(next, at)})`);
|
|
459
|
+
const inner = walk(element, { ...next, array: false }, `${id}`, at, {});
|
|
460
|
+
if ('refusal' in inner)
|
|
461
|
+
return inner;
|
|
462
|
+
}
|
|
463
|
+
nested = true;
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
if (!isRecord(child) || Object.keys(child).length === 0) {
|
|
467
|
+
return shape(at, child, `an object with fields (${subFieldsOf(next, at)})`);
|
|
468
|
+
}
|
|
469
|
+
const inner = walk(child, next, id, at, out);
|
|
470
|
+
if ('refusal' in inner)
|
|
471
|
+
return inner;
|
|
472
|
+
nested ||= inner.nested;
|
|
473
|
+
}
|
|
474
|
+
return { nested };
|
|
475
|
+
};
|
|
476
|
+
const inputs = {};
|
|
477
|
+
for (const [key, value] of Object.entries(body)) {
|
|
478
|
+
const flat = {};
|
|
479
|
+
const outcome = walk({ [key]: value }, root, '', '', flat);
|
|
480
|
+
if ('refusal' in outcome)
|
|
481
|
+
return outcome;
|
|
482
|
+
if (outcome.nested)
|
|
483
|
+
inputs[key] = value;
|
|
484
|
+
else
|
|
485
|
+
Object.assign(inputs, flat);
|
|
486
|
+
}
|
|
487
|
+
return { inputs };
|
|
488
|
+
}
|
|
383
489
|
/**
|
|
384
490
|
* Convert an Integration Service operation discriminator into an HTTP transport
|
|
385
491
|
* verb. `GETBYID` identifies a curated Retrieve operation in the connector
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.85.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",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"@types/node": "^22.7.0",
|
|
104
104
|
"esbuild": "^0.28.1"
|
|
105
105
|
},
|
|
106
|
-
"gitref": "
|
|
106
|
+
"gitref": "191f26dc5581e91ec8e491ef8fa059d72941cace"
|
|
107
107
|
}
|