@uipath/maestro-builder-sdk 6.96.1 → 6.96.2
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 +77 -70
- package/dist/api-members.md +187 -182
- package/dist/bpmn-api.md +24 -0
- package/dist/check-cli.js +1 -1
- package/dist/cli/commands/flow.js +2 -0
- package/dist/core/actions.d.ts +17 -0
- package/dist/core/actions.js +2 -0
- package/dist/core/carried-connector-operation.d.ts +120 -0
- package/dist/core/carried-connector-operation.js +297 -0
- package/dist/core/library.d.ts +12 -0
- package/dist/core/library.js +14 -0
- package/dist/decompile-cli.js +21 -2
- package/dist/decompile.d.ts +13 -0
- package/dist/decompile.js +23 -1
- package/dist/flow-node-type.d.ts +19 -0
- package/dist/merge-cli.js +2 -1
- package/dist/merge-compile.d.ts +9 -0
- package/dist/merge-compile.js +5 -1
- package/dist/nodes/connector/flow/node-type.js +86 -5
- package/package.json +2 -2
package/dist/bpmn-api.md
CHANGED
|
@@ -480,6 +480,7 @@ What every ACTIVITY accepts, on top of its own options — a script task, a vari
|
|
|
480
480
|
- `ConnectorOpts.connection?: string` — Symbolic connection name declared in bindings.json (→ ConnectionId).
|
|
481
481
|
- `ConnectorOpts.folder?: string` — Symbolic folder name declared in bindings.json (→ connectionFolderKey).
|
|
482
482
|
- `ConnectorOpts.object?: string` — Which OBJECT a **generic** operation addresses — e.g. ServiceNow's "List All Records" on `'acr_user'`, NetSuite's "Get…
|
|
483
|
+
- `ConnectorOpts.carried?: CarriedConnectorOperation` — Flow only, and written by decompile, not by an author: the `.flow` file's own description of an operation the connector…
|
|
483
484
|
|
|
484
485
|
### `HumanTaskAppOpts`
|
|
485
486
|
|
|
@@ -1066,6 +1067,15 @@ One lookup field's retrieval contract, generated from `reference`.
|
|
|
1066
1067
|
- `LookupSpec.strategy: LookupStrategy`
|
|
1067
1068
|
- `LookupSpec.dependsOn?: readonly string[]` — For `strategy: 'dependent'`, the fields that must resolve first.
|
|
1068
1069
|
|
|
1070
|
+
### `CarriedConnectorOperation`
|
|
1071
|
+
|
|
1072
|
+
The file's description of a connector operation the library lacks; see the module comment.
|
|
1073
|
+
|
|
1074
|
+
- `CarriedConnectorOperation.method: string` — The HTTP method the node calls, as the file saved it (`detail.method`), e.g. `POST`.
|
|
1075
|
+
- `CarriedConnectorOperation.endpoint: string` — The endpoint the node calls (`detail.endpoint`), e.g. `/v2/{entityName}/CreateEntityRecord`.
|
|
1076
|
+
- `CarriedConnectorOperation.operation?: string` — The operation verb the node's configuration records (`essentialConfiguration.operation`), e.g. `create` or `list`.
|
|
1077
|
+
- `CarriedConnectorOperation.fields?: readonly CarriedConnectorField[]` — Every input the node sets, with the slot it rides in.
|
|
1078
|
+
|
|
1069
1079
|
### `DataServiceFolderEntity`
|
|
1070
1080
|
|
|
1071
1081
|
A Data Fabric entity in an Orchestrator folder — what Studio Web's folder-scoped entity picker selects, as opposed to a…
|
|
@@ -1087,6 +1097,14 @@ How `prepare` should retrieve the collection, chosen from the metadata.
|
|
|
1087
1097
|
|
|
1088
1098
|
- `type LookupStrategy = 'filter' | 'scan' | 'tree' | 'dependent'`
|
|
1089
1099
|
|
|
1100
|
+
### `CarriedConnectorField`
|
|
1101
|
+
|
|
1102
|
+
One input field a connector task carries from the plan it was decompiled from.
|
|
1103
|
+
|
|
1104
|
+
- `CarriedConnectorField.name: string` — The field's name, as the saved field list names it, e.g. `bodyFormat`.
|
|
1105
|
+
- `CarriedConnectorField.location: CarriedFieldLocation` — The wire slot the saved field list names (`fieldLocation`).
|
|
1106
|
+
- `CarriedConnectorField.type?: string` — `string`, `number`, `boolean`, `array` or `object`, when the saved field declares one.
|
|
1107
|
+
|
|
1090
1108
|
### `HumanTaskFormField`
|
|
1091
1109
|
|
|
1092
1110
|
One field of an inline human-task form.
|
|
@@ -1099,6 +1117,12 @@ One button the reviewer can finish the task with.
|
|
|
1099
1117
|
|
|
1100
1118
|
- `type HumanTaskOutcome = string | { name: string; id?: string; }`
|
|
1101
1119
|
|
|
1120
|
+
### `CarriedFieldLocation`
|
|
1121
|
+
|
|
1122
|
+
Where a carried field rides on the wire: the request body, the query string or the path.
|
|
1123
|
+
|
|
1124
|
+
- `type CarriedFieldLocation = Extract<FieldLocation, 'body' | 'query' | 'path'>`
|
|
1125
|
+
|
|
1102
1126
|
### `HumanTaskShownField`
|
|
1103
1127
|
|
|
1104
1128
|
A value the reviewer READS: shown on the form, filled in from the process.
|
package/dist/check-cli.js
CHANGED
|
@@ -93,7 +93,7 @@ async function checkAgainstBaseline(built, originalPath, original, opts, package
|
|
|
93
93
|
const loaded = await loadNodePackages(originalPath, original, packages);
|
|
94
94
|
for (const message of loaded.warnings)
|
|
95
95
|
console.error(`check: warning: ${message}`);
|
|
96
|
-
const baseline = await withDecompiledOriginal(originalPath, (b) => checkCompiled(b, opts), (m) => console.error(`check: decompile warning: ${m}`));
|
|
96
|
+
const baseline = await withDecompiledOriginal(originalPath, (b) => checkCompiled(b, opts), (m) => console.error(`check: decompile warning: ${m}`), opts.library ? { library: opts.library } : {});
|
|
97
97
|
return scopeToEdit(checkCompiled(built, opts), baseline);
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
@@ -107,11 +107,13 @@ export function registerFlowCommands(program) {
|
|
|
107
107
|
.option('--no-pipeline', 'do not emit a brownfield pipeline helper')
|
|
108
108
|
.option('--package <name...>', 'trust and load this node-type package (repeatable); otherwise package.json "maestroBuilderSdk".nodePackages decides')
|
|
109
109
|
.option('--scripts <form>', 'print script steps as "function" (the default) or "string"')
|
|
110
|
+
.option('--library <dir>', 'connector library compile will use (default $FLOW_SDK_LIBRARY_JSON, else the pulled cache); an operation it lacks is carried from the file')
|
|
110
111
|
.action(async (input, options) => {
|
|
111
112
|
const argv = [input];
|
|
112
113
|
addValue(argv, '-o', options.output);
|
|
113
114
|
addValue(argv, '--import', options.import);
|
|
114
115
|
addValue(argv, '--scripts', options.scripts);
|
|
116
|
+
addValue(argv, '--library', options.library);
|
|
115
117
|
if (options.strict)
|
|
116
118
|
argv.push('--strict');
|
|
117
119
|
if (options.pipeline === false)
|
package/dist/core/actions.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { LookupToken } from './lookups.js';
|
|
|
12
12
|
import type { EventFilterExpression } from './event-filters.js';
|
|
13
13
|
export type { EventFilterExpression } from './event-filters.js';
|
|
14
14
|
import { type ConnectorDescriptor, type TriggerDescriptor } from './connectors.js';
|
|
15
|
+
import type { CarriedConnectorOperation } from './carried-connector-operation.js';
|
|
15
16
|
export interface ConnectorOpts {
|
|
16
17
|
/** Connector action version (defaults to the library's newest match). */
|
|
17
18
|
version?: string;
|
|
@@ -55,6 +56,20 @@ export interface ConnectorOpts {
|
|
|
55
56
|
* different object is an error: nothing could make that right.
|
|
56
57
|
*/
|
|
57
58
|
object?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Flow only, and written by decompile, not by an author: the `.flow` file's own
|
|
61
|
+
* description of an operation the connector library does not have — the
|
|
62
|
+
* method and endpoint its node calls, the verb its configuration records, and
|
|
63
|
+
* the slot of each input it sets. Compile reads it only when the library has
|
|
64
|
+
* no entry for the node type, together with the definition the source carries
|
|
65
|
+
* in `.definitions([...])`; see `core/carried-connector-operation.ts`.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* { method: 'POST', endpoint: '/v2/{entityName}/CreateEntityRecord', operation: 'create',
|
|
69
|
+
* fields: [{ name: 'Name', location: 'body' }, { name: 'entityName', location: 'path' }] }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
carried?: CarriedConnectorOperation;
|
|
58
73
|
}
|
|
59
74
|
/**
|
|
60
75
|
* The platform's 11 canonical quick-form field types (`@uipath/hitl-schema-types`
|
|
@@ -924,6 +939,8 @@ export interface FlowActionSpecs {
|
|
|
924
939
|
folder?: string;
|
|
925
940
|
/** Which OBJECT a generic operation addresses — see {@link ConnectorOpts.object}. */
|
|
926
941
|
object?: string;
|
|
942
|
+
/** The file's description of an operation the library lacks — see {@link ConnectorOpts.carried}. */
|
|
943
|
+
carried?: CarriedConnectorOperation;
|
|
927
944
|
/** The operation's inputs, by field. */
|
|
928
945
|
inputs: Record<string, unknown>;
|
|
929
946
|
};
|
package/dist/core/actions.js
CHANGED
|
@@ -60,6 +60,7 @@ export function connector(a, b, c, d) {
|
|
|
60
60
|
connection: opts.connection,
|
|
61
61
|
folder: opts.folder,
|
|
62
62
|
object: opts.object,
|
|
63
|
+
...(opts.carried !== undefined ? { carried: opts.carried } : {}),
|
|
63
64
|
inputs: c ?? {},
|
|
64
65
|
});
|
|
65
66
|
}
|
|
@@ -74,6 +75,7 @@ export function connector(a, b, c, d) {
|
|
|
74
75
|
connection: opts.connection,
|
|
75
76
|
folder: opts.folder,
|
|
76
77
|
object: opts.object ?? a.objectName,
|
|
78
|
+
...(opts.carried !== undefined ? { carried: opts.carried } : {}),
|
|
77
79
|
inputs: b ?? {},
|
|
78
80
|
});
|
|
79
81
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connector operation a decompiled Flow step CARRIES: the file's own
|
|
3
|
+
* description of an operation the connector library does not have at all.
|
|
4
|
+
*
|
|
5
|
+
* The published library is a snapshot. A tenant keeps adding connectors and
|
|
6
|
+
* operations after it is taken (Data Fabric `create-entity-record`, Test
|
|
7
|
+
* Manager, a tenant's custom connector), and Studio Web saves a step against the
|
|
8
|
+
* LIVE connector. With the library as the only authority, compile refused such a
|
|
9
|
+
* step as CONNECTOR_NOT_IN_LIBRARY, so the source decompile wrote for an
|
|
10
|
+
* untouched product flow did not compile.
|
|
11
|
+
*
|
|
12
|
+
* The `.flow` file describes the operation in two places, and between them they
|
|
13
|
+
* hold everything compile reads from a library entry:
|
|
14
|
+
*
|
|
15
|
+
* - its `definitions[]` entry for the node type: the form, handles, model,
|
|
16
|
+
* bindings and activity type id. Decompile carries it in `.definitions([...])`,
|
|
17
|
+
* exactly as it carries a pinned core node's definition (#1128).
|
|
18
|
+
* - the node's own `inputs.detail`: the HTTP method and endpoint it calls, the
|
|
19
|
+
* operation verb its configuration records, and the slot (body, query, path)
|
|
20
|
+
* of every input it sets. Decompile carries these as the step's `carried`
|
|
21
|
+
* option: `{ method, endpoint, operation, fields }`.
|
|
22
|
+
*
|
|
23
|
+
* This is the same idea as Case's carried connector fields
|
|
24
|
+
* (`core/carried-connector-fields.ts`, #1362): the file's own definition is the
|
|
25
|
+
* third source, after the SDK and the library. It is a FALLBACK only:
|
|
26
|
+
*
|
|
27
|
+
* - compile reads it only when the library has no entry for the node type. An
|
|
28
|
+
* operation the library knows is compiled from the library, whatever is
|
|
29
|
+
* carried, so a carried copy can never relax what the library declares.
|
|
30
|
+
* - it names only the inputs the file sets. An input it does not name is still
|
|
31
|
+
* `unknown input` (CONNECTOR_INPUT). A carried field is optional, except a
|
|
32
|
+
* path field the endpoint template names (`{entityName}`): the file shows
|
|
33
|
+
* that a field exists, not that it is required, but an unfilled placeholder
|
|
34
|
+
* is a node `flow validate` refuses.
|
|
35
|
+
* - the method must be one `flow validate` accepts, every `{name}` in the
|
|
36
|
+
* endpoint needs a carried path field, and the carried definition must record
|
|
37
|
+
* the step's connector key and method (`carriedDefinitionMismatch`).
|
|
38
|
+
* - without the carried definition in `.definitions([...])`, the step is still
|
|
39
|
+
* CONNECTOR_NOT_IN_LIBRARY.
|
|
40
|
+
*
|
|
41
|
+
* For instance a Data Fabric "Create Entity Record" step, saved against a
|
|
42
|
+
* connector newer than the library, decompiles to
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* connector("uipath-uipath-dataservice", "create-entity-record", { Name: "Ada", entityName: "Contact" }, {
|
|
46
|
+
* connection: "…", folder: "…",
|
|
47
|
+
* carried: { method: "POST", endpoint: "/v2/{entityName}/CreateEntityRecord", operation: "create",
|
|
48
|
+
* fields: [{ name: "Name", location: "body" }, { name: "entityName", location: "path" }] },
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* plus `.definitions([createEntityRecordV1_0_0Definition])`, and compiles back.
|
|
53
|
+
*/
|
|
54
|
+
import { type CarriedConnectorField } from './carried-connector-fields.js';
|
|
55
|
+
import type { ResolvedConnector } from './library.js';
|
|
56
|
+
/** The file's description of a connector operation the library lacks; see the module comment. */
|
|
57
|
+
export interface CarriedConnectorOperation {
|
|
58
|
+
/** The HTTP method the node calls, as the file saved it (`detail.method`), e.g. `POST`. */
|
|
59
|
+
method: string;
|
|
60
|
+
/** The endpoint the node calls (`detail.endpoint`), e.g. `/v2/{entityName}/CreateEntityRecord`. */
|
|
61
|
+
endpoint: string;
|
|
62
|
+
/** The operation verb the node's configuration records (`essentialConfiguration.operation`), e.g. `create` or `list`. */
|
|
63
|
+
operation?: string;
|
|
64
|
+
/** Every input the node sets, with the slot it rides in. Each is optional to compile; any other input is refused. */
|
|
65
|
+
fields?: readonly CarriedConnectorField[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The `{name}` placeholders in an endpoint template, in order. For instance
|
|
69
|
+
* `/v2/{ProjectId}/testsets/{id}` gives `['ProjectId', 'id']`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function endpointPlaceholders(endpoint: string): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Why `carried` cannot be a step's carried operation, or `undefined` when it can.
|
|
74
|
+
*
|
|
75
|
+
* For instance `{ endpoint: '/send' }` is refused for naming no `method`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function carriedOperationRefusal(carried: unknown, where: string): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Why `definition` cannot be the definition of carried operation `carried` on
|
|
80
|
+
* connector `key`, or `undefined` when it can: the connector key and HTTP
|
|
81
|
+
* method the definition itself records must agree with the step's. A
|
|
82
|
+
* definition borrowed from another connector, or from an operation with
|
|
83
|
+
* another verb, is refused. A definition that records neither is not checked
|
|
84
|
+
* on that point.
|
|
85
|
+
*
|
|
86
|
+
* For instance a Slack POST operation's definition under
|
|
87
|
+
* `carried: { method: 'DELETE', … }` is refused.
|
|
88
|
+
*/
|
|
89
|
+
export declare function carriedDefinitionMismatch(definition: Record<string, unknown>, key: string, carried: CarriedConnectorOperation, where: string): string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* The operation `carried` and the carried `definition` describe, resolved as
|
|
92
|
+
* `Library.resolve` resolves a library entry. `carried` must have passed
|
|
93
|
+
* {@link carriedOperationRefusal}.
|
|
94
|
+
*
|
|
95
|
+
* The entry is built from the two halves: the transport (method, endpoint, verb)
|
|
96
|
+
* from `carried`, the object, activity kind and connector name from the
|
|
97
|
+
* definition. The fields are the carried ones, optional except a path field
|
|
98
|
+
* the endpoint template names.
|
|
99
|
+
*
|
|
100
|
+
* @param nodeType - The step's node type, `uipath.connector.<key>.<action>`.
|
|
101
|
+
* @param key - The connector key.
|
|
102
|
+
* @param version - The step's pinned version, which the definition carries.
|
|
103
|
+
* @param definition - The carried `definitions[]` entry for `nodeType@version`.
|
|
104
|
+
* @param carried - The step's carried operation.
|
|
105
|
+
*/
|
|
106
|
+
export declare function carriedConnector(nodeType: string, key: string, version: string, definition: Record<string, unknown>, carried: CarriedConnectorOperation): ResolvedConnector;
|
|
107
|
+
/**
|
|
108
|
+
* The operation a saved connector node describes, for decompile to carry: its
|
|
109
|
+
* method, endpoint, the verb its configuration records, and each input it sets
|
|
110
|
+
* with its slot. `undefined` when the node does not describe one compile could
|
|
111
|
+
* rebuild: no method `flow validate` accepts or no endpoint, a multipart part
|
|
112
|
+
* (its part list is the library's to declare), one name in two slots, or an
|
|
113
|
+
* endpoint placeholder no path parameter fills.
|
|
114
|
+
*
|
|
115
|
+
* For instance a node with `detail: { method: 'POST', endpoint: '/send', bodyParameters: { text: 'hi' } }`
|
|
116
|
+
* gives `{ method: 'POST', endpoint: '/send', fields: [{ name: 'text', location: 'body' }] }`.
|
|
117
|
+
*
|
|
118
|
+
* @param detail - The node's `inputs.detail`.
|
|
119
|
+
*/
|
|
120
|
+
export declare function carriedOperationOf(detail: Record<string, unknown>): CarriedConnectorOperation | undefined;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connector operation a decompiled Flow step CARRIES: the file's own
|
|
3
|
+
* description of an operation the connector library does not have at all.
|
|
4
|
+
*
|
|
5
|
+
* The published library is a snapshot. A tenant keeps adding connectors and
|
|
6
|
+
* operations after it is taken (Data Fabric `create-entity-record`, Test
|
|
7
|
+
* Manager, a tenant's custom connector), and Studio Web saves a step against the
|
|
8
|
+
* LIVE connector. With the library as the only authority, compile refused such a
|
|
9
|
+
* step as CONNECTOR_NOT_IN_LIBRARY, so the source decompile wrote for an
|
|
10
|
+
* untouched product flow did not compile.
|
|
11
|
+
*
|
|
12
|
+
* The `.flow` file describes the operation in two places, and between them they
|
|
13
|
+
* hold everything compile reads from a library entry:
|
|
14
|
+
*
|
|
15
|
+
* - its `definitions[]` entry for the node type: the form, handles, model,
|
|
16
|
+
* bindings and activity type id. Decompile carries it in `.definitions([...])`,
|
|
17
|
+
* exactly as it carries a pinned core node's definition (#1128).
|
|
18
|
+
* - the node's own `inputs.detail`: the HTTP method and endpoint it calls, the
|
|
19
|
+
* operation verb its configuration records, and the slot (body, query, path)
|
|
20
|
+
* of every input it sets. Decompile carries these as the step's `carried`
|
|
21
|
+
* option: `{ method, endpoint, operation, fields }`.
|
|
22
|
+
*
|
|
23
|
+
* This is the same idea as Case's carried connector fields
|
|
24
|
+
* (`core/carried-connector-fields.ts`, #1362): the file's own definition is the
|
|
25
|
+
* third source, after the SDK and the library. It is a FALLBACK only:
|
|
26
|
+
*
|
|
27
|
+
* - compile reads it only when the library has no entry for the node type. An
|
|
28
|
+
* operation the library knows is compiled from the library, whatever is
|
|
29
|
+
* carried, so a carried copy can never relax what the library declares.
|
|
30
|
+
* - it names only the inputs the file sets. An input it does not name is still
|
|
31
|
+
* `unknown input` (CONNECTOR_INPUT). A carried field is optional, except a
|
|
32
|
+
* path field the endpoint template names (`{entityName}`): the file shows
|
|
33
|
+
* that a field exists, not that it is required, but an unfilled placeholder
|
|
34
|
+
* is a node `flow validate` refuses.
|
|
35
|
+
* - the method must be one `flow validate` accepts, every `{name}` in the
|
|
36
|
+
* endpoint needs a carried path field, and the carried definition must record
|
|
37
|
+
* the step's connector key and method (`carriedDefinitionMismatch`).
|
|
38
|
+
* - without the carried definition in `.definitions([...])`, the step is still
|
|
39
|
+
* CONNECTOR_NOT_IN_LIBRARY.
|
|
40
|
+
*
|
|
41
|
+
* For instance a Data Fabric "Create Entity Record" step, saved against a
|
|
42
|
+
* connector newer than the library, decompiles to
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* connector("uipath-uipath-dataservice", "create-entity-record", { Name: "Ada", entityName: "Contact" }, {
|
|
46
|
+
* connection: "…", folder: "…",
|
|
47
|
+
* carried: { method: "POST", endpoint: "/v2/{entityName}/CreateEntityRecord", operation: "create",
|
|
48
|
+
* fields: [{ name: "Name", location: "body" }, { name: "entityName", location: "path" }] },
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* plus `.definitions([createEntityRecordV1_0_0Definition])`, and compiles back.
|
|
53
|
+
*/
|
|
54
|
+
import { carriedConnectorFieldsRefusal } from './carried-connector-fields.js';
|
|
55
|
+
import { ownEntry } from './own-entry.js';
|
|
56
|
+
import { transportHttpMethod } from './connector-inputs.js';
|
|
57
|
+
const KEYS = new Set(['method', 'endpoint', 'operation', 'fields']);
|
|
58
|
+
/** The HTTP methods `flow validate` accepts on a connector node, upper-cased. */
|
|
59
|
+
const METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
60
|
+
/** Whether `method` is one of {@link METHODS}, in any case. */
|
|
61
|
+
function isHttpMethod(method) {
|
|
62
|
+
return typeof method === 'string' && METHODS.has(method.toUpperCase());
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The `{name}` placeholders in an endpoint template, in order. For instance
|
|
66
|
+
* `/v2/{ProjectId}/testsets/{id}` gives `['ProjectId', 'id']`.
|
|
67
|
+
*/
|
|
68
|
+
export function endpointPlaceholders(endpoint) {
|
|
69
|
+
return [...endpoint.matchAll(/\{([^{}]+)\}/g)].map((m) => m[1]);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Why `carried` cannot be a step's carried operation, or `undefined` when it can.
|
|
73
|
+
*
|
|
74
|
+
* For instance `{ endpoint: '/send' }` is refused for naming no `method`.
|
|
75
|
+
*/
|
|
76
|
+
export function carriedOperationRefusal(carried, where) {
|
|
77
|
+
if (carried === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
if (!carried || typeof carried !== 'object' || Array.isArray(carried))
|
|
80
|
+
return `${where}: carried must be an object { method, endpoint, operation?, fields? }.`;
|
|
81
|
+
const c = carried;
|
|
82
|
+
const extra = Object.keys(c).find((key) => !KEYS.has(key));
|
|
83
|
+
if (extra !== undefined)
|
|
84
|
+
return `${where}: carried has unsupported key "${extra}".`;
|
|
85
|
+
if (!isHttpMethod(c.method))
|
|
86
|
+
return `${where}: carried.method must be the HTTP method the file's node calls: GET, POST, PUT, PATCH or DELETE.`;
|
|
87
|
+
if (typeof c.endpoint !== 'string' || !c.endpoint.startsWith('/'))
|
|
88
|
+
return `${where}: carried.endpoint must be the endpoint the file's node calls, starting with "/".`;
|
|
89
|
+
if (c.operation !== undefined && (typeof c.operation !== 'string' || !c.operation))
|
|
90
|
+
return `${where}: carried.operation must be a non-empty string when given.`;
|
|
91
|
+
const fieldsRefusal = carriedConnectorFieldsRefusal(c.fields, `${where}: carried`);
|
|
92
|
+
if (fieldsRefusal)
|
|
93
|
+
return fieldsRefusal;
|
|
94
|
+
// Every `{name}` the endpoint template has needs a carried PATH field: the
|
|
95
|
+
// platform fills the template from `pathParameters`, and `flow validate`
|
|
96
|
+
// refuses a node with a placeholder no path parameter fills.
|
|
97
|
+
const paths = new Set((c.fields ?? [])
|
|
98
|
+
.filter((f) => f.location === 'path').map((f) => f.name));
|
|
99
|
+
const unfilled = endpointPlaceholders(c.endpoint).filter((name) => !paths.has(name));
|
|
100
|
+
if (unfilled.length > 0)
|
|
101
|
+
return `${where}: carried.endpoint ${JSON.stringify(c.endpoint)} has ${unfilled.map((n) => `{${n}}`).join(', ')} `
|
|
102
|
+
+ `with no carried field of location "path" to fill ${unfilled.length > 1 ? 'them' : 'it'}.`;
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Why `definition` cannot be the definition of carried operation `carried` on
|
|
107
|
+
* connector `key`, or `undefined` when it can: the connector key and HTTP
|
|
108
|
+
* method the definition itself records must agree with the step's. A
|
|
109
|
+
* definition borrowed from another connector, or from an operation with
|
|
110
|
+
* another verb, is refused. A definition that records neither is not checked
|
|
111
|
+
* on that point.
|
|
112
|
+
*
|
|
113
|
+
* For instance a Slack POST operation's definition under
|
|
114
|
+
* `carried: { method: 'DELETE', … }` is refused.
|
|
115
|
+
*/
|
|
116
|
+
export function carriedDefinitionMismatch(definition, key, carried, where) {
|
|
117
|
+
const identity = definitionIdentity(definition);
|
|
118
|
+
const context = definition.model?.context;
|
|
119
|
+
const contextValue = (name) => (Array.isArray(context)
|
|
120
|
+
? context.find((c) => c?.name === name)?.value
|
|
121
|
+
: undefined);
|
|
122
|
+
const text = (v) => (typeof v === 'string' && v ? v : undefined);
|
|
123
|
+
const definedKey = text(identity.connectorKey) ?? text(contextValue('connectorKey'));
|
|
124
|
+
if (definedKey !== undefined && definedKey !== key)
|
|
125
|
+
return `${where}: the carried definition is connector "${definedKey}"'s, not "${key}"'s. `
|
|
126
|
+
+ 'Keep the definition the .flow file holds for this node.';
|
|
127
|
+
const definedMethod = text(identity.httpMethod) ?? text(contextValue('method'));
|
|
128
|
+
if (definedMethod !== undefined && transportHttpMethod(definedMethod.toUpperCase()) !== transportHttpMethod(carried.method.toUpperCase()))
|
|
129
|
+
return `${where}: carried.method is ${carried.method.toUpperCase()}, but the carried definition's operation is ${definedMethod.toUpperCase()}. `
|
|
130
|
+
+ 'Keep the method and definition the .flow file holds for this node.';
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
/** The definition's own copy of the activity's identity: `connectorDetail.configuration`, parsed. */
|
|
134
|
+
function definitionIdentity(definition) {
|
|
135
|
+
let found = {};
|
|
136
|
+
const visit = (v) => {
|
|
137
|
+
if (Array.isArray(v)) {
|
|
138
|
+
v.forEach(visit);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!v || typeof v !== 'object')
|
|
142
|
+
return;
|
|
143
|
+
const detail = v.connectorDetail;
|
|
144
|
+
if (typeof detail?.configuration === 'string') {
|
|
145
|
+
try {
|
|
146
|
+
const parsed = JSON.parse(detail.configuration);
|
|
147
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
|
|
148
|
+
found = parsed;
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Not JSON: the definition names no identity here.
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
for (const child of Object.values(v))
|
|
156
|
+
visit(child);
|
|
157
|
+
};
|
|
158
|
+
visit(definition.form);
|
|
159
|
+
return found;
|
|
160
|
+
}
|
|
161
|
+
/** The first `uiPathActivityTypeId` string anywhere in the definition, as the library reads it. */
|
|
162
|
+
function activityTypeIdOf(definition) {
|
|
163
|
+
if (!definition || typeof definition !== 'object')
|
|
164
|
+
return undefined;
|
|
165
|
+
if (Array.isArray(definition)) {
|
|
166
|
+
for (const item of definition) {
|
|
167
|
+
const id = activityTypeIdOf(item);
|
|
168
|
+
if (id !== undefined)
|
|
169
|
+
return id;
|
|
170
|
+
}
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
const own = ownEntry(definition, 'uiPathActivityTypeId');
|
|
174
|
+
if (typeof own === 'string' && own)
|
|
175
|
+
return own;
|
|
176
|
+
for (const child of Object.values(definition)) {
|
|
177
|
+
const id = activityTypeIdOf(child);
|
|
178
|
+
if (id !== undefined)
|
|
179
|
+
return id;
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The operation `carried` and the carried `definition` describe, resolved as
|
|
185
|
+
* `Library.resolve` resolves a library entry. `carried` must have passed
|
|
186
|
+
* {@link carriedOperationRefusal}.
|
|
187
|
+
*
|
|
188
|
+
* The entry is built from the two halves: the transport (method, endpoint, verb)
|
|
189
|
+
* from `carried`, the object, activity kind and connector name from the
|
|
190
|
+
* definition. The fields are the carried ones, optional except a path field
|
|
191
|
+
* the endpoint template names.
|
|
192
|
+
*
|
|
193
|
+
* @param nodeType - The step's node type, `uipath.connector.<key>.<action>`.
|
|
194
|
+
* @param key - The connector key.
|
|
195
|
+
* @param version - The step's pinned version, which the definition carries.
|
|
196
|
+
* @param definition - The carried `definitions[]` entry for `nodeType@version`.
|
|
197
|
+
* @param carried - The step's carried operation.
|
|
198
|
+
*/
|
|
199
|
+
export function carriedConnector(nodeType, key, version, definition, carried) {
|
|
200
|
+
const identity = definitionIdentity(definition);
|
|
201
|
+
const text = (v) => (typeof v === 'string' && v ? v : undefined);
|
|
202
|
+
const objectName = text(identity.objectName) ?? '';
|
|
203
|
+
const connectorName = text(definition.display?.sourceDisplayName) ?? '';
|
|
204
|
+
const operation = {
|
|
205
|
+
// `buildConfiguration` lower-cases the verb; the file's is already lower-case.
|
|
206
|
+
...(carried.operation !== undefined ? { name: carried.operation } : {}),
|
|
207
|
+
objectName,
|
|
208
|
+
httpMethod: carried.method.toUpperCase(),
|
|
209
|
+
path: carried.endpoint,
|
|
210
|
+
activityType: text(identity.activityType) ?? 'Curated',
|
|
211
|
+
...(identity.subType !== undefined ? { subType: identity.subType } : {}),
|
|
212
|
+
...(identity.supportsStreaming !== undefined ? { supportsStreaming: identity.supportsStreaming } : {}),
|
|
213
|
+
};
|
|
214
|
+
// A path field the endpoint template names is required: without it the node
|
|
215
|
+
// calls an unfilled `{name}`, which `flow validate` refuses. Every other
|
|
216
|
+
// carried field is optional: the file shows that it exists, not that it is required.
|
|
217
|
+
const templated = new Set(endpointPlaceholders(carried.endpoint));
|
|
218
|
+
const fields = (carried.fields ?? []).map((f) => ({
|
|
219
|
+
name: f.name, location: f.location, required: f.location === 'path' && templated.has(f.name),
|
|
220
|
+
...(f.type !== undefined ? { type: f.type } : {}),
|
|
221
|
+
}));
|
|
222
|
+
const activityTypeId = activityTypeIdOf(definition);
|
|
223
|
+
return {
|
|
224
|
+
nodeType,
|
|
225
|
+
version,
|
|
226
|
+
connectorKey: key,
|
|
227
|
+
connectorName,
|
|
228
|
+
httpMethod: carried.method.toUpperCase(),
|
|
229
|
+
endpoint: carried.endpoint,
|
|
230
|
+
...(activityTypeId !== undefined ? { activityTypeId } : {}),
|
|
231
|
+
v1def: definition,
|
|
232
|
+
entry: { connector: { key, name: connectorName }, operation },
|
|
233
|
+
fields,
|
|
234
|
+
multipartParts: [],
|
|
235
|
+
objectName,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/** The slot each `inputs.detail` parameter map rides in, as a carried field's location. */
|
|
239
|
+
const SLOTS = [['bodyParameters', 'body'], ['queryParameters', 'query'], ['pathParameters', 'path']];
|
|
240
|
+
/**
|
|
241
|
+
* The operation a saved connector node describes, for decompile to carry: its
|
|
242
|
+
* method, endpoint, the verb its configuration records, and each input it sets
|
|
243
|
+
* with its slot. `undefined` when the node does not describe one compile could
|
|
244
|
+
* rebuild: no method `flow validate` accepts or no endpoint, a multipart part
|
|
245
|
+
* (its part list is the library's to declare), one name in two slots, or an
|
|
246
|
+
* endpoint placeholder no path parameter fills.
|
|
247
|
+
*
|
|
248
|
+
* For instance a node with `detail: { method: 'POST', endpoint: '/send', bodyParameters: { text: 'hi' } }`
|
|
249
|
+
* gives `{ method: 'POST', endpoint: '/send', fields: [{ name: 'text', location: 'body' }] }`.
|
|
250
|
+
*
|
|
251
|
+
* @param detail - The node's `inputs.detail`.
|
|
252
|
+
*/
|
|
253
|
+
export function carriedOperationOf(detail) {
|
|
254
|
+
const { method, endpoint } = detail;
|
|
255
|
+
if (!isHttpMethod(method) || typeof endpoint !== 'string' || !endpoint.startsWith('/'))
|
|
256
|
+
return undefined;
|
|
257
|
+
if (Array.isArray(detail.multipartParameters) && detail.multipartParameters.length > 0)
|
|
258
|
+
return undefined;
|
|
259
|
+
const fields = [];
|
|
260
|
+
const seen = new Set();
|
|
261
|
+
for (const [slot, location] of SLOTS) {
|
|
262
|
+
const m = detail[slot];
|
|
263
|
+
if (!m || typeof m !== 'object' || Array.isArray(m))
|
|
264
|
+
continue;
|
|
265
|
+
for (const name of Object.keys(m)) {
|
|
266
|
+
if (!name || seen.has(name))
|
|
267
|
+
return undefined;
|
|
268
|
+
seen.add(name);
|
|
269
|
+
fields.push({ name, location });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// A template placeholder the node fills from no path parameter: compile would
|
|
273
|
+
// refuse the description, so it is not carried.
|
|
274
|
+
const paths = new Set(fields.filter((f) => f.location === 'path').map((f) => f.name));
|
|
275
|
+
if (endpointPlaceholders(endpoint).some((name) => !paths.has(name)))
|
|
276
|
+
return undefined;
|
|
277
|
+
const operation = savedOperationVerb(detail.configuration);
|
|
278
|
+
return {
|
|
279
|
+
method,
|
|
280
|
+
endpoint,
|
|
281
|
+
...(operation !== undefined ? { operation } : {}),
|
|
282
|
+
...(fields.length > 0 ? { fields } : {}),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/** `essentialConfiguration.operation` of a node's `=jsonString:` configuration, when it records one. */
|
|
286
|
+
function savedOperationVerb(configuration) {
|
|
287
|
+
if (typeof configuration !== 'string' || !configuration.startsWith('=jsonString:'))
|
|
288
|
+
return undefined;
|
|
289
|
+
try {
|
|
290
|
+
const parsed = JSON.parse(configuration.slice('=jsonString:'.length));
|
|
291
|
+
const verb = parsed?.essentialConfiguration?.operation;
|
|
292
|
+
return typeof verb === 'string' && verb ? verb : undefined;
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
}
|
package/dist/core/library.d.ts
CHANGED
|
@@ -297,6 +297,18 @@ export declare class Library {
|
|
|
297
297
|
*/
|
|
298
298
|
lookupSpecs(key: string, action: string, version?: string, objectName?: string): Record<string, LookupSpec>;
|
|
299
299
|
resolve(key: string, action: string, version?: string, objectName?: string): ResolvedConnector;
|
|
300
|
+
/**
|
|
301
|
+
* Whether any layer (the prepared overlay or the library) has an entry for
|
|
302
|
+
* `nodeType`, at any version. `false` is exactly when `resolve` refuses the
|
|
303
|
+
* operation as CONNECTOR_NOT_IN_LIBRARY whatever object is asked for: Flow
|
|
304
|
+
* decompile carries such an operation from the file
|
|
305
|
+
* (`core/carried-connector-operation.ts`). Reads the index only, so it warns
|
|
306
|
+
* about nothing.
|
|
307
|
+
*
|
|
308
|
+
* For instance `indexes('uipath.connector.uipath-salesforce-slack.send-message-to-channel')`
|
|
309
|
+
* is `true` on the shipped library.
|
|
310
|
+
*/
|
|
311
|
+
indexes(nodeType: string): boolean;
|
|
300
312
|
/**
|
|
301
313
|
* One operation's page source, for `registry describe`: the entry and definition
|
|
302
314
|
* of one index row, from the first layer that carries it. That is the prepared
|
package/dist/core/library.js
CHANGED
|
@@ -112,6 +112,20 @@ export class Library {
|
|
|
112
112
|
resolve(key, action, version, objectName) {
|
|
113
113
|
return this.resolveType(`uipath.connector.${key}.${action}`, version, objectName);
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Whether any layer (the prepared overlay or the library) has an entry for
|
|
117
|
+
* `nodeType`, at any version. `false` is exactly when `resolve` refuses the
|
|
118
|
+
* operation as CONNECTOR_NOT_IN_LIBRARY whatever object is asked for: Flow
|
|
119
|
+
* decompile carries such an operation from the file
|
|
120
|
+
* (`core/carried-connector-operation.ts`). Reads the index only, so it warns
|
|
121
|
+
* about nothing.
|
|
122
|
+
*
|
|
123
|
+
* For instance `indexes('uipath.connector.uipath-salesforce-slack.send-message-to-channel')`
|
|
124
|
+
* is `true` on the shipped library.
|
|
125
|
+
*/
|
|
126
|
+
indexes(nodeType) {
|
|
127
|
+
return this.carries(nodeType);
|
|
128
|
+
}
|
|
115
129
|
/**
|
|
116
130
|
* One operation's page source, for `registry describe`: the entry and definition
|
|
117
131
|
* of one index row, from the first layer that carries it. That is the prepared
|
package/dist/decompile-cli.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
6
|
* flow-decompile <original.flow> [-o Name.flow.ts] [--import <specifier>] [--strict] [--scripts function|string]
|
|
7
|
+
* [--library <library-json dir>] [--connectors-local <dir>]
|
|
7
8
|
*
|
|
8
9
|
* The reverse of compile-cli: reads a `.flow` JSON and emits Flow SDK builder
|
|
9
10
|
* source whose default export re-serializes to the same graph (same node ids,
|
|
@@ -13,6 +14,10 @@
|
|
|
13
14
|
* unsupported construct is a hard error instead of a `// TODO` marker.
|
|
14
15
|
* `--scripts string` prints every script step as `script({ code })` instead of
|
|
15
16
|
* as a TypeScript function (the default, where the body allows it).
|
|
17
|
+
* `--library` and `--connectors-local` pick the connector library as `compile`
|
|
18
|
+
* does (default `$FLOW_SDK_LIBRARY_JSON`, else the pulled cache): a connector
|
|
19
|
+
* operation it has no entry for is carried from the file, so the untouched step
|
|
20
|
+
* compiles back (`core/carried-connector-operation.ts`).
|
|
16
21
|
*
|
|
17
22
|
* The source's first line is a stamp (decompile-stamp.ts): the original's name, the
|
|
18
23
|
* digest of the source written, and the options that shaped it. `flow merge
|
|
@@ -34,6 +39,7 @@ import { PACKAGE_NAME } from './package-name.js';
|
|
|
34
39
|
import { commentText } from './core/comment-text.js';
|
|
35
40
|
import { loadNodePackages } from './node-packages.js';
|
|
36
41
|
import { pipelineFrontDoor } from './registry/uip/pipeline-front-door.js';
|
|
42
|
+
import { openCliLibrary } from './core/cli-library.js';
|
|
37
43
|
/** Derive a PascalCase base name from the flow name/id for the default output file. */
|
|
38
44
|
function baseName(flow) {
|
|
39
45
|
const src = flow.name ?? flow.id ?? 'Flow';
|
|
@@ -46,10 +52,10 @@ function baseName(flow) {
|
|
|
46
52
|
}
|
|
47
53
|
export async function run(argv) {
|
|
48
54
|
if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
|
|
49
|
-
console.error('usage: flow-decompile <original.flow> [-o Name.flow.ts] [--import <specifier>] [--package <name>]... [--strict] [--scripts function|string]');
|
|
55
|
+
console.error('usage: flow-decompile <original.flow> [-o Name.flow.ts] [--import <specifier>] [--package <name>]... [--strict] [--scripts function|string] [--library <dir>] [--connectors-local <dir>]');
|
|
50
56
|
return 2;
|
|
51
57
|
}
|
|
52
|
-
const flags = new Set(['-o', '--import', '--package', '--scripts']);
|
|
58
|
+
const flags = new Set(['-o', '--import', '--package', '--scripts', '--library', '--connectors-local']);
|
|
53
59
|
const pos = argv.find((a, i) => !flags.has(a) && !flags.has(argv[i - 1]) && !a.startsWith('--'));
|
|
54
60
|
if (!pos) {
|
|
55
61
|
console.error('flow-decompile: missing <original.flow>');
|
|
@@ -73,9 +79,22 @@ export async function run(argv) {
|
|
|
73
79
|
console.error(`flow-decompile: warning: ${message}`);
|
|
74
80
|
if (packages.loaded.length > 0)
|
|
75
81
|
reportResult({ packages: packages.loaded.map((p) => p.package) });
|
|
82
|
+
// The library `compile` will open, so a connector operation it has no entry
|
|
83
|
+
// for is carried from the file instead of being refused on recompile. Decompile
|
|
84
|
+
// needs no library otherwise: one it cannot read (a corrupt or half-written
|
|
85
|
+
// cache) is a warning, and the source is written with nothing carried.
|
|
86
|
+
let library;
|
|
87
|
+
try {
|
|
88
|
+
library = openCliLibrary(argv);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error(`flow-decompile: warning: connector library unreadable (${error instanceof Error ? error.message : String(error)}); nothing is carried`);
|
|
92
|
+
library = undefined;
|
|
93
|
+
}
|
|
76
94
|
const strict = argv.includes('--strict');
|
|
77
95
|
const ts = decompileFlowFile(pos, flow, {
|
|
78
96
|
importSpecifier: flagValue(argv, '--import') ?? PACKAGE_NAME,
|
|
97
|
+
...(library ? { library } : {}),
|
|
79
98
|
bestEffort: !strict,
|
|
80
99
|
scripts,
|
|
81
100
|
// Findings the source cannot carry on its own (a node no trigger reaches, a
|