@uipath/maestro-builder-sdk 6.83.0 → 6.84.1

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.
@@ -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
@@ -0,0 +1,67 @@
1
+ /**
2
+ * core/connector-v2-metadata — the `metadata` json a V2 (`activityConfigurationVersion:
3
+ * v2`) Integration Service node carries in its context: the design-time configuration
4
+ * and the activity's catalog entry, as Studio Web's V2 connector panel saves them.
5
+ *
6
+ * Case and BPMN write the same blob. Their envelopes differ (caseplan JSON rows,
7
+ * `uipath:input` rows), but the CLI renders one connector spec into both
8
+ * (UiPath/cli `buildActivityContext` / `buildTriggerContext`, rendered for BPMN by
9
+ * `renderBpmnV2Element`), so the two families share one builder here. It used to
10
+ * live in `case/serialize.ts`, where BPMN could not reach it.
11
+ *
12
+ * The configuration is functional only: designer cosmetics (packageId,
13
+ * activityColor, svgIconUrl, …) are omitted. Studio Web fills them from its type
14
+ * cache on open.
15
+ */
16
+ import type { Library, ResolvedConnector } from './library.js';
17
+ import type { buildConnectorInputs } from './connector-inputs.js';
18
+ import { type ReadEventFilter } from './event-filters.js';
19
+ /**
20
+ * What the activity metadata reads of a resolved operation. A library entry
21
+ * (`Library.resolve`) is one; an operation the SDK describes itself, such as a
22
+ * Data Service curated record operation (`bpmn/data-service.ts`), is another.
23
+ */
24
+ export type ConnectorMetadataSource = Pick<ResolvedConnector, 'entry' | 'version' | 'activityTypeId' | 'nodeType' | 'connectorKey' | 'connectorName'>;
25
+ /** The routed inputs the activity metadata replays (`buildConnectorInputs`'s slots). */
26
+ export type ConnectorMetadataSlots = Pick<ReturnType<typeof buildConnectorInputs>, 'pathParameters' | 'queryParameters' | 'bodyParameters' | 'multipartParameters' | 'inputMetadata'>;
27
+ /** How an External Agent / Workflow object runs; a connector activity has none. */
28
+ export type ConnectorExecutionType = 'sync' | 'async' | 'hybrid';
29
+ /** The event an async or hybrid external object answers with. */
30
+ export interface ConnectorEventPair {
31
+ operation: string;
32
+ mode: string;
33
+ }
34
+ /**
35
+ * The `metadata` of a connector activity: the FUNCTIONAL essentialConfiguration +
36
+ * activityTypeId, and the multipart wire of a multipart operation.
37
+ *
38
+ * The configuration is the one Flow writes, from the shared
39
+ * {@link buildEssentialConfiguration}. Case used to build its own, thinner copy:
40
+ * no `operation` verb, `customFieldsRequestDetails`, `connectorVersion` or
41
+ * `unifiedTypesCompatible`, a curated-only `instanceParameters` even for a
42
+ * Generic activity, and the library version where the platform writes
43
+ * `packageVersion: "1.0.0"` (#1420).
44
+ *
45
+ * @param seed - The element id, which seeds the ids inside the configuration.
46
+ */
47
+ export declare function connectorActivityMetadata(rc: ConnectorMetadataSource, op: any, slots: ConnectorMetadataSlots, seed: string, executionType?: ConnectorExecutionType, event?: ConnectorEventPair): Record<string, unknown>;
48
+ /**
49
+ * The designer's filter tree for a connector event's filter conditions, or `null`
50
+ * for none: the `essentialConfiguration.filter` the event metadata carries.
51
+ *
52
+ * @param conditions - The authored leaves, already read and judged (each caller
53
+ * refuses a malformed leaf with its own message, under the code `check` gives).
54
+ * @param seededId - Mints a stable id from a suffix of the element's id; Case
55
+ * records each one so preservation can re-mint it.
56
+ */
57
+ export declare function connectorEventFilterTree(conditions: readonly ReadEventFilter[], seededId: (suffix: string) => string): Record<string, unknown> | null;
58
+ /**
59
+ * The `metadata` of a connector event (a trigger or a wait): the subscription's
60
+ * essentialConfiguration, its event type and mode, and the catalog entry.
61
+ *
62
+ * @param filter - The designer's filter tree ({@link connectorEventFilterTree}).
63
+ * @param filterExpression - The compiled JMESPath of the same filter, which Studio
64
+ * Web also records here (`activityPropertyConfiguration.filterExpression`); omitted
65
+ * when there is none.
66
+ */
67
+ export declare function connectorEventMetadata(rc: ReturnType<Library['resolveEvent']>, op: any, filter: Record<string, unknown> | null, filterExpression?: string): Record<string, unknown>;
@@ -0,0 +1,145 @@
1
+ import { replayInputsOf } from './connector-inputs.js';
2
+ import { buildEssentialConfiguration } from './connector-configuration.js';
3
+ import { eventFilterTreeLeaf } from './event-filters.js';
4
+ /**
5
+ * The `metadata` of a connector activity: the FUNCTIONAL essentialConfiguration +
6
+ * activityTypeId, and the multipart wire of a multipart operation.
7
+ *
8
+ * The configuration is the one Flow writes, from the shared
9
+ * {@link buildEssentialConfiguration}. Case used to build its own, thinner copy:
10
+ * no `operation` verb, `customFieldsRequestDetails`, `connectorVersion` or
11
+ * `unifiedTypesCompatible`, a curated-only `instanceParameters` even for a
12
+ * Generic activity, and the library version where the platform writes
13
+ * `packageVersion: "1.0.0"` (#1420).
14
+ *
15
+ * @param seed - The element id, which seeds the ids inside the configuration.
16
+ */
17
+ export function connectorActivityMetadata(rc, op, slots, seed, executionType, event) {
18
+ // The part DECLARATIONS only: a file part's value rides on its `file` input.
19
+ const multipartParameters = (slots.multipartParameters ?? []).map(({ name, dataType }) => ({ name, dataType }));
20
+ // The configuration replays the authored values (a schema action's parent
21
+ // fields, a CEQL filter's tree), keyed by the library's own names, as Flow's.
22
+ const essential = buildEssentialConfiguration(rc.entry, rc.version, replayInputsOf(slots), seed, executionType ?? null);
23
+ const configuration = `=jsonString:${JSON.stringify({ essentialConfiguration: essential })}`;
24
+ const instanceParameters = essential.instanceParameters;
25
+ const objectName = String(op.objectName ?? rc.nodeType.split('.').pop());
26
+ return {
27
+ activityPropertyConfiguration: {
28
+ ...(multipartParameters.length ? { multipartParameters } : {}),
29
+ configuration,
30
+ uiPathActivityTypeId: rc.activityTypeId ?? '',
31
+ errorState: { issues: [] },
32
+ ...(executionType ? { executionType } : {}),
33
+ // The event an async / hybrid object answers with, named as the Designer
34
+ // names it here (`eventType`, where the context row is `operation`).
35
+ ...(event ? { eventType: event.operation, eventMode: event.mode } : {}),
36
+ },
37
+ activityMetadata: {
38
+ activity: {
39
+ displayName: rc.entry.display?.label ?? objectName,
40
+ description: rc.entry.display?.description ?? '',
41
+ category: rc.connectorName,
42
+ configuration: JSON.stringify(instanceParameters),
43
+ uiPathActivityTypeId: rc.activityTypeId ?? '',
44
+ isEnabled: true,
45
+ },
46
+ },
47
+ // `{}` unless the operation is multipart, as the Designer saves every
48
+ // connector activity, external tasks included.
49
+ inputMetadata: slots.inputMetadata ?? {},
50
+ telemetryData: {
51
+ connectorKey: rc.connectorKey,
52
+ connectorName: rc.connectorName,
53
+ objectName,
54
+ objectDisplayName: op.objectDisplayName ?? rc.entry.display?.operationLabel ?? '',
55
+ },
56
+ };
57
+ }
58
+ /**
59
+ * The designer's filter tree for a connector event's filter conditions, or `null`
60
+ * for none: the `essentialConfiguration.filter` the event metadata carries.
61
+ *
62
+ * @param conditions - The authored leaves, already read and judged (each caller
63
+ * refuses a malformed leaf with its own message, under the code `check` gives).
64
+ * @param seededId - Mints a stable id from a suffix of the element's id; Case
65
+ * records each one so preservation can re-mint it.
66
+ */
67
+ export function connectorEventFilterTree(conditions, seededId) {
68
+ if (!conditions.length)
69
+ return null;
70
+ return {
71
+ groupOperator: 0,
72
+ index: 0,
73
+ filters: conditions.map((read, index) => ({
74
+ ...eventFilterTreeLeaf(read),
75
+ uiId: seededId(`:${read.field}:${read.expression ?? String(read.value)}:${index}`),
76
+ })).map((leaf) => ({
77
+ id: leaf.id,
78
+ operator: leaf.operator,
79
+ value: leaf.value,
80
+ uiId: leaf.uiId,
81
+ })),
82
+ groups: [],
83
+ uuId: seededId(':filters'),
84
+ };
85
+ }
86
+ /**
87
+ * The `metadata` of a connector event (a trigger or a wait): the subscription's
88
+ * essentialConfiguration, its event type and mode, and the catalog entry.
89
+ *
90
+ * @param filter - The designer's filter tree ({@link connectorEventFilterTree}).
91
+ * @param filterExpression - The compiled JMESPath of the same filter, which Studio
92
+ * Web also records here (`activityPropertyConfiguration.filterExpression`); omitted
93
+ * when there is none.
94
+ */
95
+ export function connectorEventMetadata(rc, op, filter, filterExpression) {
96
+ const instanceParameters = {
97
+ connectorKey: rc.connectorKey,
98
+ objectName: op.objectName ?? rc.nodeType.split('.').pop(),
99
+ activityType: op.activityType,
100
+ version: rc.version,
101
+ eventOperation: op.eventOperation,
102
+ eventMode: op.eventMode,
103
+ supportsStreaming: op.supportsStreaming ?? false,
104
+ };
105
+ const configuration = {
106
+ essentialConfiguration: {
107
+ connectorVersion: null,
108
+ executionType: null,
109
+ customFieldsRequestDetails: null,
110
+ instanceParameters,
111
+ objectName: instanceParameters.objectName,
112
+ packageVersion: rc.version,
113
+ httpMethod: null,
114
+ path: null,
115
+ filter,
116
+ },
117
+ };
118
+ return {
119
+ activityPropertyConfiguration: {
120
+ objectName: instanceParameters.objectName,
121
+ eventType: op.eventOperation,
122
+ eventMode: op.eventMode,
123
+ configuration: `=jsonString:${JSON.stringify(configuration)}`,
124
+ uiPathActivityTypeId: rc.activityTypeId ?? '',
125
+ errorState: { issues: [] },
126
+ ...(filterExpression ? { filterExpression } : {}),
127
+ },
128
+ activityMetadata: {
129
+ activity: {
130
+ displayName: rc.entry.display?.label ?? instanceParameters.objectName,
131
+ description: rc.entry.display?.description ?? '',
132
+ category: rc.connectorName,
133
+ configuration: JSON.stringify(instanceParameters),
134
+ uiPathActivityTypeId: rc.activityTypeId ?? '',
135
+ isEnabled: true,
136
+ },
137
+ },
138
+ telemetryData: {
139
+ connectorKey: rc.connectorKey,
140
+ connectorName: rc.connectorName,
141
+ objectName: instanceParameters.objectName,
142
+ objectDisplayName: op.objectDisplayName ?? rc.entry.display?.operationLabel ?? '',
143
+ },
144
+ };
145
+ }
@@ -322,6 +322,7 @@ export declare const REFUSALS: {
322
322
  readonly EVENT_NO_SCOPE: "lint";
323
323
  readonly EVENT_NO_SUBSCRIPTION: "lint";
324
324
  readonly EVENT_OBJECT_NOT_GENERIC: "lint";
325
+ readonly EVENT_OUTPUT_NOT_RESPONSE: "lint";
325
326
  readonly EVENT_SCOPE_NOT_TAKEN: "lint";
326
327
  readonly EVENT_UNKNOWN: "lowering";
327
328
  readonly EVENT_UNPREPARED: "lint";
@@ -395,6 +395,7 @@ export const REFUSALS = {
395
395
  EVENT_NO_SCOPE: 'lint',
396
396
  EVENT_NO_SUBSCRIPTION: 'lint',
397
397
  EVENT_OBJECT_NOT_GENERIC: 'lint',
398
+ EVENT_OUTPUT_NOT_RESPONSE: 'lint',
398
399
  EVENT_SCOPE_NOT_TAKEN: 'lint',
399
400
  EVENT_UNKNOWN: 'lowering',
400
401
  EVENT_UNPREPARED: 'lint',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.83.0",
3
+ "version": "6.84.1",
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": "8083a43e2cb53d4c0eb99e508b06d3d4a35f4386"
106
+ "gitref": "14e818c75fa7dc26d0dbab599bd2b718891d6136"
107
107
  }