@uipath/maestro-builder-sdk 6.100.0 → 6.102.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/README.md +3 -0
- package/dist/api-index.md +14 -14
- package/dist/api-members.md +16 -16
- package/dist/cli/commands/capabilities.d.ts +10 -0
- package/dist/cli/commands/capabilities.js +24 -0
- package/dist/cli/common.d.ts +17 -17
- package/dist/cli/common.js +114 -20
- package/dist/cli/index.js +2 -0
- package/dist/core/actions.d.ts +6 -0
- package/dist/core/actions.js +7 -0
- package/dist/core/binding-messages.d.ts +33 -1
- package/dist/core/binding-messages.js +51 -0
- package/dist/core/connector-option-keys.d.ts +4 -0
- package/dist/core/connector-option-keys.js +9 -0
- package/dist/core/event-subscription.d.ts +8 -0
- package/dist/core/event-subscription.js +2 -4
- package/dist/core/nodes/node-type.d.ts +25 -0
- package/dist/core/nodes/versioned.d.ts +3 -1
- package/dist/core/nodes/versioned.js +1 -0
- package/dist/core/option-keys.d.ts +62 -0
- package/dist/core/option-keys.js +66 -0
- package/dist/core/refusals.d.ts +3 -0
- package/dist/core/refusals.js +5 -0
- package/dist/flow-node-type.d.ts +31 -1
- package/dist/flow-option-keys.d.ts +22 -0
- package/dist/flow-option-keys.js +33 -0
- package/dist/flow-sdk.js +5 -9
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/nodes/agent/flow/inline-agent.js +2 -4
- package/dist/nodes/agent/flow/node-type.js +12 -0
- package/dist/nodes/ai-patterns/flow/node-type.js +6 -0
- package/dist/nodes/connector/flow/event-trigger.js +4 -2
- package/dist/nodes/connector/flow/event-wait.js +4 -2
- package/dist/nodes/connector/flow/node-type.js +5 -4
- package/dist/nodes/connector/flow/raw-node.js +1 -1
- package/dist/nodes/conversation/flow/node-type.js +9 -0
- package/dist/nodes/data-fabric/flow/verbs.js +10 -0
- package/dist/nodes/delay/flow/node-type.js +4 -0
- package/dist/nodes/document/flow/ixp.js +4 -0
- package/dist/nodes/document/flow/node-type.js +6 -0
- package/dist/nodes/hitl/flow/node-type.js +4 -0
- package/dist/nodes/http/flow/check.js +55 -0
- package/dist/nodes/http/flow/node-type.js +7 -4
- package/dist/nodes/process/flow/node-type.js +10 -0
- package/dist/nodes/queue/flow/node-type.js +4 -0
- package/dist/nodes/script/flow/node-type.js +4 -0
- package/dist/nodes/transform/flow/node-type.js +4 -0
- package/dist/nodes/trigger/flow/node-type.js +6 -0
- package/dist/sdk-capabilities.d.ts +57 -0
- package/dist/sdk-capabilities.js +76 -0
- package/dist/serialize.js +73 -1
- package/package.json +9 -3
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* docs/NODE_TYPE_ARCHITECTURE_DESIGN.md.
|
|
17
17
|
*/
|
|
18
18
|
import { eventDetail, eventTarget, libraryRequiredForEvent, refuseUnverifiedByoa, resolveEvent } from '../../../core/event-subscription.js';
|
|
19
|
+
import { EVENT_SUBSCRIPTION_KEYS } from '../../../core/connector-option-keys.js';
|
|
19
20
|
import { liftSubscription, printSubscription, splitEvent } from './event-wait.js';
|
|
20
21
|
const CONNECTOR_PREFIX = 'uipath.connector.';
|
|
21
22
|
const PREFIXES = [`${CONNECTOR_PREFIX}trigger.`, `${CONNECTOR_PREFIX}event.`];
|
|
@@ -32,8 +33,7 @@ function serializeEventTrigger(spec, ctx) {
|
|
|
32
33
|
// mid-flow connector's does, so the pair goes into the flow's `bindings[]` (G-19).
|
|
33
34
|
const target = eventTarget(sub);
|
|
34
35
|
const bindingSite = root.isDefault ? 'event trigger' : 'onEvent() entry point';
|
|
35
|
-
const connectionId = ctx.
|
|
36
|
-
const folderKey = ctx.resolveBinding(sub.folder, 'folder', bindingSite, target);
|
|
36
|
+
const { connectionId, folderKey } = ctx.resolveBindingPair(sub, bindingSite, target);
|
|
37
37
|
ctx.bindConnection({
|
|
38
38
|
model: rc.v1def?.model,
|
|
39
39
|
connectorKey: rc.connectorKey, connectionId,
|
|
@@ -53,6 +53,8 @@ function serializeEventTrigger(spec, ctx) {
|
|
|
53
53
|
}
|
|
54
54
|
export const eventTriggerType = {
|
|
55
55
|
kind: 'event',
|
|
56
|
+
// The stringly form's subscription is the author's own object; the descriptor form's is built by the factory.
|
|
57
|
+
optionKeys: { subscription: EVENT_SUBSCRIPTION_KEYS },
|
|
56
58
|
typeName: `${CONNECTOR_PREFIX}*`,
|
|
57
59
|
typeNamePrefix: CONNECTOR_PREFIX,
|
|
58
60
|
// Any name under the two prefixes, an eventless one included: a root of that
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EVENT_SUBSCRIPTION_KEYS } from '../../../core/connector-option-keys.js';
|
|
1
2
|
import { bindingMissingMessage, missingBindingLabels } from '../../../core/binding-messages.js';
|
|
2
3
|
import { prepareCommand } from '../../../core/cli-spelling.js';
|
|
3
4
|
import { commentText } from '../../../core/comment-text.js';
|
|
@@ -62,8 +63,7 @@ function serializeEventWait(spec, ctx) {
|
|
|
62
63
|
// The platform reaches the connection through the flow's `bindings[]`, as for
|
|
63
64
|
// a connector operation (board G-19). `eventDetail` refused a node without
|
|
64
65
|
// both labels, so both resolve here.
|
|
65
|
-
const connectionId = ctx.
|
|
66
|
-
const folderKey = ctx.resolveBinding(sub.folder, 'folder', site, target);
|
|
66
|
+
const { connectionId, folderKey } = ctx.resolveBindingPair(sub, site, target);
|
|
67
67
|
ctx.bindConnection({
|
|
68
68
|
model: rc.v1def?.model,
|
|
69
69
|
connectorKey: rc.connectorKey, connectionId: connectionId,
|
|
@@ -191,6 +191,8 @@ const eventWait10 = {
|
|
|
191
191
|
};
|
|
192
192
|
export const eventWaitNodeType = {
|
|
193
193
|
kind: 'waitEvent', typeName: `${EVENT_PREFIX}*`, typeNamePrefix: EVENT_PREFIX, factory: 'waitForEvent',
|
|
194
|
+
// The stringly form's subscription is the author's own object; the descriptor form's is built by the factory.
|
|
195
|
+
optionKeys: { subscription: EVENT_SUBSCRIPTION_KEYS },
|
|
194
196
|
typeNameMatches: (typeName) => splitEvent(typeName) !== undefined,
|
|
195
197
|
versionedByDefinition: true,
|
|
196
198
|
defaultVersion: eventWait10.version,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CONNECTOR_OPTION_KEYS } from '../../../core/connector-option-keys.js';
|
|
1
2
|
import { BindingRefusal, bindingMissingMessage, missingBindingLabels } from '../../../core/binding-messages.js';
|
|
2
3
|
import { PULL_COMMAND, prepareCommand } from '../../../core/cli-spelling.js';
|
|
3
4
|
import { carriedConnector, carriedDefinitionMismatch, carriedOperationOf, carriedOperationRefusal, } from '../../../core/carried-connector-operation.js';
|
|
@@ -119,8 +120,7 @@ function serializeConnector(spec, ctx) {
|
|
|
119
120
|
const missing = missingBindingLabels(spec);
|
|
120
121
|
if (missing.length > 0 && !ctx.drafting)
|
|
121
122
|
throw new BindingRefusal('BINDING_MISSING', bindingMissingMessage(where, missing, target));
|
|
122
|
-
const connection = ctx.
|
|
123
|
-
ctx.resolveBinding(spec.folder, 'folder', where, target);
|
|
123
|
+
const { connectionId: connection } = ctx.resolveBindingPair(spec, where, target);
|
|
124
124
|
// The connection rides on the refusal, so check's stand-in for this step
|
|
125
125
|
// still takes part in the file-wide CONNECTION_CONNECTOR_CONFLICT rule.
|
|
126
126
|
throw new LibraryRequiredRefusal(`connector "${step}" needs a library (pass --library / set $FLOW_SDK_LIBRARY_JSON).`, connection !== undefined && typeof spec.key === 'string' && spec.key !== '' ? { connector: spec.key, connection } : undefined);
|
|
@@ -201,8 +201,7 @@ function serializeConnector(spec, ctx) {
|
|
|
201
201
|
ctx.draft(refusal.code, refusal.message);
|
|
202
202
|
unbound = true;
|
|
203
203
|
}
|
|
204
|
-
const conn = ctx.
|
|
205
|
-
const folder = ctx.resolveBinding(spec.folder, 'folder', where, target);
|
|
204
|
+
const { connectionId: conn, folderKey: folder } = ctx.resolveBindingPair(spec, where, target);
|
|
206
205
|
// The platform reaches the connection through the flow's `bindings[]`, never
|
|
207
206
|
// through `inputs.detail` — without this pair the run faults with `[102010]`
|
|
208
207
|
// (board G-19).
|
|
@@ -443,6 +442,8 @@ const connector10 = {
|
|
|
443
442
|
};
|
|
444
443
|
export const connectorNodeType = {
|
|
445
444
|
kind: 'connector', typeName: `${CONNECTOR_PREFIX}*`, typeNamePrefix: CONNECTOR_PREFIX, factory: 'connector',
|
|
445
|
+
// `inputs` are the connector's own fields, which the library checks (CONNECTOR_INPUT); only the options object is closed here.
|
|
446
|
+
optionKeys: { options: CONNECTOR_OPTION_KEYS },
|
|
446
447
|
typeNameMatches: (typeName) => splitOperation(typeName) !== undefined,
|
|
447
448
|
versionedByDefinition: true,
|
|
448
449
|
defaultVersion: connector10.version,
|
|
@@ -41,7 +41,7 @@ export function connectorRawNodeRefusal(nodeType) {
|
|
|
41
41
|
return (`rawNode("${nodeType}") names a connector operation. A raw node keeps its inputs verbatim, so the `
|
|
42
42
|
+ `emitted node would have no inputs.detail and no connection binding: \`validate\` only warns `
|
|
43
43
|
+ `("Connector is not configured") and the run can never reach Integration Service. `
|
|
44
|
-
+ `Author it as connector('${key}', '${action}', { ...inputs }, { connection: '<
|
|
44
|
+
+ `Author it as connector('${key}', '${action}', { ...inputs }, { connection: '<connection-label>', folder: '<folder-label>' }). `
|
|
45
45
|
+ `If compile then refuses an input the static library does not carry, run `
|
|
46
46
|
+ `\`${prepareCommand(key, action)}\` — it discovers the connection, writes bindings.json `
|
|
47
47
|
+ `and loads the connection-resolved fields into ./.flow-sdk/connectors-local/ (add \`-f <parent>=<value>\`, e.g. `
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
import { Expr, toExpr } from '../../../core/expr.js';
|
|
9
9
|
import { jsonClone } from '../../../core/json-clone.js';
|
|
10
10
|
import { checkConversational } from './check.js';
|
|
11
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
12
|
+
import { ownEntry } from '../../../core/own-entry.js';
|
|
11
13
|
/**
|
|
12
14
|
* The definition's `inputDefaults`, which supply the fixed fields the platform's
|
|
13
15
|
* schema requires (`role: 'assistant'` and `mimeType: 'text/markdown'` on send,
|
|
@@ -104,9 +106,16 @@ function conversationAt(kind, typeName, version) {
|
|
|
104
106
|
output: () => ({ kind: 'opaque' }),
|
|
105
107
|
};
|
|
106
108
|
}
|
|
109
|
+
/** Every key of each factory's options (builder-sdk#1990), by kind; `tsc` holds each list to its type. */
|
|
110
|
+
const CONVERSATION_OPTIONS = {
|
|
111
|
+
sendMessage: { inputs: declareKeys({ conversationId: true, exchangeId: true, content: true, endExchange: true }) },
|
|
112
|
+
waitForMessage: { inputs: declareKeys({ conversationId: true, numExchanges: true }) },
|
|
113
|
+
conversationContext: { inputs: declareKeys({ conversationId: true, exchangeLimit: true }) },
|
|
114
|
+
};
|
|
107
115
|
function conversationType(kind, typeName, versions) {
|
|
108
116
|
return {
|
|
109
117
|
kind, typeName, factory: kind, defaultVersion: '1.0',
|
|
118
|
+
optionKeys: ownEntry(CONVERSATION_OPTIONS, kind),
|
|
110
119
|
versions: Object.fromEntries(versions.map((v) => [v, conversationAt(kind, typeName, v)])),
|
|
111
120
|
};
|
|
112
121
|
}
|
|
@@ -2,6 +2,7 @@ import { applyScope, baseConfig, entityConfigOf, fieldRows, filterRows, liftFiel
|
|
|
2
2
|
import { checkCreate, checkRead, checkUpdate, checkWrite } from './check.js';
|
|
3
3
|
import { rawNodeAdvice } from './raw.js';
|
|
4
4
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
5
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
5
6
|
/**
|
|
6
7
|
* Every Data Fabric node carries no node-level `model`, whichever path emits it
|
|
7
8
|
* (a verb, or a rawNode of its definition). Studio Web never writes one
|
|
@@ -143,14 +144,21 @@ function liftFilters(q) {
|
|
|
143
144
|
}
|
|
144
145
|
return [];
|
|
145
146
|
}
|
|
147
|
+
/** Every key of each verb's options (builder-sdk#1990); `tsc` holds each list to its type. */
|
|
148
|
+
const READ_OPTIONS = { inputs: declareKeys({ entity: true, filters: true, resultMode: true, limit: true, skip: true, sort: true, fields: true, folderKey: true, resourceKey: true }) };
|
|
149
|
+
const CREATE_OPTIONS = { inputs: declareKeys({ entity: true, values: true, folderKey: true, resourceKey: true }) };
|
|
150
|
+
const UPDATE_OPTIONS = { inputs: declareKeys({ entity: true, record: true, set: true, folderKey: true, resourceKey: true }) };
|
|
151
|
+
const DELETE_OPTIONS = { inputs: declareKeys({ entity: true, record: true, folderKey: true, resourceKey: true }) };
|
|
146
152
|
export const dataFabricRead = {
|
|
147
153
|
kind: 'dataFabricRead', typeName: 'core.datafabric.read', factory: 'dataFabricRead', defaultVersion: '1.0',
|
|
154
|
+
optionKeys: READ_OPTIONS,
|
|
148
155
|
versions: { '1.0': readAt('1.0'), '1.4': readAt('1.4') },
|
|
149
156
|
select: ({ inputs }) => (inputs?.resultMode !== undefined ? '1.4' : '1.0'),
|
|
150
157
|
};
|
|
151
158
|
// ─── create ────────────────────────────────────────────────────────────────────
|
|
152
159
|
export const dataFabricCreate = {
|
|
153
160
|
kind: 'dataFabricCreate', typeName: 'core.datafabric.create', version: '1.3', factory: 'dataFabricCreate',
|
|
161
|
+
optionKeys: CREATE_OPTIONS,
|
|
154
162
|
definition: 'bundled', nodeModel: NODE_MODEL, rawNode: CREATE_ADVICE,
|
|
155
163
|
serialize: ({ inputs }, ctx) => {
|
|
156
164
|
const scope = resolvedScope(inputs, ctx);
|
|
@@ -207,11 +215,13 @@ function updateAt(version) {
|
|
|
207
215
|
}
|
|
208
216
|
export const dataFabricUpdate = {
|
|
209
217
|
kind: 'dataFabricUpdate', typeName: 'core.datafabric.update', factory: 'dataFabricUpdate', defaultVersion: '1.0',
|
|
218
|
+
optionKeys: UPDATE_OPTIONS,
|
|
210
219
|
versions: { '1.0': updateAt('1.0'), '1.3': updateAt('1.3') },
|
|
211
220
|
};
|
|
212
221
|
// ─── delete ────────────────────────────────────────────────────────────────────
|
|
213
222
|
export const dataFabricDelete = {
|
|
214
223
|
kind: 'dataFabricDelete', typeName: 'core.datafabric.delete', version: '1.3', factory: 'dataFabricDelete',
|
|
224
|
+
optionKeys: DELETE_OPTIONS,
|
|
215
225
|
definition: 'bundled', nodeModel: NODE_MODEL, rawNode: DELETE_ADVICE,
|
|
216
226
|
serialize: ({ inputs }, ctx) => {
|
|
217
227
|
const scope = resolvedScope(inputs, ctx);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DELAY_PRESETS } from './spec.js';
|
|
2
2
|
import { checkDelay } from './check.js';
|
|
3
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
3
4
|
/**
|
|
4
5
|
* Encode a delay's single `duration` into the two inputs the platform's node
|
|
5
6
|
* carries — the SAME split as the scheduled trigger above, on the same field
|
|
@@ -69,7 +70,10 @@ function delayAt(version) {
|
|
|
69
70
|
}),
|
|
70
71
|
};
|
|
71
72
|
}
|
|
73
|
+
/** Every key of `delay()`'s options (builder-sdk#1990); `tsc` holds the list to `DelayInputs`. */
|
|
74
|
+
const DELAY_OPTIONS = { inputs: declareKeys({ duration: true, until: true }) };
|
|
72
75
|
export const delayNodeType = {
|
|
73
76
|
kind: 'delay', typeName: 'core.logic.delay', factory: 'delay', defaultVersion: '1.0.0',
|
|
77
|
+
optionKeys: DELAY_OPTIONS,
|
|
74
78
|
versions: { '1.0.0': delayAt('1.0.0'), '1.0': delayAt('1.0') },
|
|
75
79
|
};
|
|
@@ -15,6 +15,7 @@ import { Expr } from '../../../core/expr.js';
|
|
|
15
15
|
import { jsonClone } from '../../../core/json-clone.js';
|
|
16
16
|
import { parseIxpProjectType } from './spec.js';
|
|
17
17
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
18
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
18
19
|
const IXP_PREFIX = 'uipath.ixp.';
|
|
19
20
|
export const IXP_DIAGNOSTICS = {
|
|
20
21
|
IXP_FORBIDDEN_INPUT: { severity: 'error', summary: 'an IxP step setting an input the current node does not declare' },
|
|
@@ -390,8 +391,11 @@ const ixpExtract10 = {
|
|
|
390
391
|
expressions: () => [],
|
|
391
392
|
output: () => ({ kind: 'opaque' }),
|
|
392
393
|
};
|
|
394
|
+
/** Every key of `ixpExtract()`'s options (builder-sdk#1990); `tsc` holds the list to `IxpExtractInputs`. */
|
|
395
|
+
const IXP_EXTRACT_OPTIONS = { inputs: declareKeys({ project: true, modelName: true, name: true, folderName: true, fileRef: true, pageRange: true, versionTag: true, folderPath: true, description: true }) };
|
|
393
396
|
export const ixpExtractNodeType = {
|
|
394
397
|
kind: 'ixpExtract', typeName: `${IXP_PREFIX}*`, typeNamePrefix: IXP_PREFIX, factory: 'ixpExtract',
|
|
398
|
+
optionKeys: IXP_EXTRACT_OPTIONS,
|
|
395
399
|
// An extractor is a tail of two uuids; Dynamic Extract's
|
|
396
400
|
// `uipath.ixp.extract-document-builder` and the older tails are not.
|
|
397
401
|
typeNameMatches: (typeName) => parseIxpProjectType(typeName) !== undefined,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { toExpr } from '../../../core/expr.js';
|
|
11
11
|
import { jsonClone } from '../../../core/json-clone.js';
|
|
12
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
12
13
|
export const DOCUMENT_DIAGNOSTICS = {
|
|
13
14
|
DOC_NO_FILEREF: { severity: 'error', summary: 'no fileRef, so nothing to classify or extract from' },
|
|
14
15
|
EXTRACT_SCHEMA_SHAPE: { severity: 'error', summary: 'a Dynamic Extract schema that is not an object' },
|
|
@@ -96,8 +97,12 @@ function liftClassificationSchema(node, ctx) {
|
|
|
96
97
|
}
|
|
97
98
|
return raw;
|
|
98
99
|
}
|
|
100
|
+
/** Every key of each factory's options (builder-sdk#1990); `tsc` holds each list to its type. */
|
|
101
|
+
const CLASSIFY_OPTIONS = { inputs: declareKeys({ fileRef: true, pageRange: true, splitPages: true, modelConfig: true, classificationSchema: true }) };
|
|
102
|
+
const DYNAMIC_EXTRACT_OPTIONS = { inputs: declareKeys({ fileRef: true, model: true, schema: true, pageRange: true, modelConfig: true }) };
|
|
99
103
|
export const documentClassifyNodeType = {
|
|
100
104
|
kind: 'documentClassify', typeName: 'uipath.document.classify', version: '1.0', factory: 'documentClassify',
|
|
105
|
+
optionKeys: CLASSIFY_OPTIONS,
|
|
101
106
|
definition: 'bundled', rawNode: { factory: 'documentClassify()' },
|
|
102
107
|
serialize: ({ inputs }, ctx) => {
|
|
103
108
|
const d = defaults('uipath.document.classify', '1.0', ctx);
|
|
@@ -149,6 +154,7 @@ export const documentClassifyNodeType = {
|
|
|
149
154
|
};
|
|
150
155
|
export const dynamicExtractNodeType = {
|
|
151
156
|
kind: 'dynamicExtract', typeName: 'uipath.ixp.extract-document-builder', version: '1.0.0', factory: 'dynamicExtract',
|
|
157
|
+
optionKeys: DYNAMIC_EXTRACT_OPTIONS,
|
|
152
158
|
definition: 'bundled', rawNode: { factory: 'dynamicExtract()' },
|
|
153
159
|
serialize: ({ inputs }, ctx) => {
|
|
154
160
|
const d = defaults('uipath.ixp.extract-document-builder', '1.0.0', ctx);
|
|
@@ -24,6 +24,7 @@ import { appAnswerSchemas, appContract, appInputSchema, liftActionSchema, normal
|
|
|
24
24
|
import { checkHitl, checkHitlRead } from './check.js';
|
|
25
25
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
26
26
|
import { processResourceBindings } from '../../../core/process-resource.js';
|
|
27
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
27
28
|
const BASE = 'uipath.human-in-the-loop';
|
|
28
29
|
const QUICK_FORM = 'uipath.human-in-the-loop.quick-form';
|
|
29
30
|
const ACTION_APP = 'uipath.human-in-the-loop.coded-action-app';
|
|
@@ -948,9 +949,12 @@ function hitlAt(typeName, version, factory) {
|
|
|
948
949
|
&& (inputs?.outcomes ?? []).some((o, i) => port === `outcome-${outcomeIdOf(o, i)}`),
|
|
949
950
|
};
|
|
950
951
|
}
|
|
952
|
+
/** Every key of `hitl()`'s options (builder-sdk#1990); `tsc` holds the list to `HitlInputs`. */
|
|
953
|
+
const HITL_OPTIONS = { inputs: declareKeys({ variant: true, app: true, title: true, priority: true, fields: true, outcomes: true, recipient: true, labels: true, outcomePorts: true, exposeError: true, legacyCompleted: true, document: true }) };
|
|
951
954
|
function hitlType(typeName, versions, factory, variant) {
|
|
952
955
|
return {
|
|
953
956
|
kind: 'hitl', typeName, factory: 'hitl', defaultVersion: '1.0',
|
|
957
|
+
optionKeys: HITL_OPTIONS,
|
|
954
958
|
versions: Object.fromEntries(versions.map((v) => [v, hitlAt(typeName, v, factory)])),
|
|
955
959
|
// The base node is the one an absent or UNKNOWN variant resolves to, as it
|
|
956
960
|
// always has: its serialize refuses the unknown one (HITL_VARIANT_UNKNOWN).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { nearestName } from '../../../core/edit-distance.js';
|
|
2
2
|
import { escapeRegExp } from '../../../core/escape-regexp.js';
|
|
3
3
|
import { isJsExpressionValue } from '../../../core/wire-expr.js';
|
|
4
|
+
import { Expr } from '../../../core/expr.js';
|
|
4
5
|
export const HTTP_DIAGNOSTICS = {
|
|
5
6
|
HTTP_V1_RETIRED: { severity: 'warning', summary: 'the plain node is retired on the tenant registry' },
|
|
6
7
|
HTTP_BINDING_REQUIRES_MANAGED: { severity: 'error', summary: 'connection settings on the standalone node' },
|
|
@@ -18,6 +19,7 @@ export const HTTP_DIAGNOSTICS = {
|
|
|
18
19
|
HTTP_READ_UNKNOWN_FIELD: { severity: 'error', summary: 'a read outside the response envelope or the declared body' },
|
|
19
20
|
HTTP_READ_WITHOUT_RETURNS: { severity: 'error', summary: 'a body field read with no `returns`' },
|
|
20
21
|
HTTP_ONERROR_V1: { severity: 'error', summary: '.onError() on the plain node' },
|
|
22
|
+
HTTP_LITERAL_SECRET_HEADER: { severity: 'warning', summary: 'a literal credential in an Authorization or API-key header, stored in the .flow as plain text' },
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
25
|
* An ISO-8601 DURATION, which is what both http definitions declare `timeout` to
|
|
@@ -37,6 +39,58 @@ const ISO8601_DURATION = /^P(?!$)(\d+(?:\.\d+)?Y)?(\d+(?:\.\d+)?M)?(\d+(?:\.\d+)
|
|
|
37
39
|
* (it refuses something that works); a too-wide one costs nothing.
|
|
38
40
|
*/
|
|
39
41
|
const RETRY_COUNT_SOFT_MAX = 5;
|
|
42
|
+
/**
|
|
43
|
+
* Header names that carry a credential: `Authorization` and
|
|
44
|
+
* `Proxy-Authorization`, and any name with an `api-key`, `apikey`, `token`,
|
|
45
|
+
* `secret`, `password` or `subscription-key` part (`X-Api-Key`, `api-key`,
|
|
46
|
+
* `X-Auth-Token`, `PRIVATE-TOKEN`, `Ocp-Apim-Subscription-Key`). Matched on
|
|
47
|
+
* `-`/`_`-separated parts, so `X-Token-Count` or `Accept` do not match.
|
|
48
|
+
*/
|
|
49
|
+
const SECRET_HEADER = /^(?:proxy-)?authorization$|(?:^|[-_])(?:api[-_]?key|apikey|token|secret|password|passwd|subscription[-_]key|functions[-_]key)$/i;
|
|
50
|
+
/** An HTTP auth scheme word on its own (`Bearer`, `Basic`), which carries no credential yet. */
|
|
51
|
+
const AUTH_SCHEME_ONLY = /^(?:bearer|basic|token|apikey|digest)?$/i;
|
|
52
|
+
/**
|
|
53
|
+
* The text a header value carries when it is a constant: a plain string, a
|
|
54
|
+
* `lit()`, or a `js` expression that is nothing but a string literal
|
|
55
|
+
* (`` js`"Bearer abc"` ``). `undefined` for anything evaluated at run time.
|
|
56
|
+
*/
|
|
57
|
+
function literalHeaderText(value) {
|
|
58
|
+
if (typeof value === 'string')
|
|
59
|
+
return isJsExpressionValue(value) ? undefined : value;
|
|
60
|
+
if (!(value instanceof Expr))
|
|
61
|
+
return undefined;
|
|
62
|
+
if (value.literal)
|
|
63
|
+
return typeof value.value === 'string' ? value.value : undefined;
|
|
64
|
+
try {
|
|
65
|
+
const parsed = JSON.parse(value.js.trim());
|
|
66
|
+
return typeof parsed === 'string' ? parsed : undefined;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A literal credential in a request header (#1977). The value is written into
|
|
74
|
+
* the `.flow` as plain text, so it is in the source, in every exported
|
|
75
|
+
* solution and in the designer, readable by anyone who can open the flow. A
|
|
76
|
+
* warning, not an error: the request still works, and a designer flow that
|
|
77
|
+
* already carries one should not stop an unrelated edit. An empty value and a
|
|
78
|
+
* scheme word alone (`'Bearer '`) carry nothing, so they are not reported.
|
|
79
|
+
*/
|
|
80
|
+
function checkSecretHeaders(inputs, ctx) {
|
|
81
|
+
for (const [name, value] of Object.entries(inputs?.headers ?? {})) {
|
|
82
|
+
if (!SECRET_HEADER.test(name.trim()))
|
|
83
|
+
continue;
|
|
84
|
+
const text = literalHeaderText(value);
|
|
85
|
+
if (text === undefined || AUTH_SCHEME_ONLY.test(text.trim()))
|
|
86
|
+
continue;
|
|
87
|
+
ctx.report('HTTP_LITERAL_SECRET_HEADER', `Step "${ctx.step}" sets the "${name}" header to a literal value. A literal is written into the .flow as `
|
|
88
|
+
+ `plain text, so the credential is readable by anyone who can open the flow or its exported solution. `
|
|
89
|
+
+ `Keep it in an Integration Service HTTP connection (managed: true with connection and folder, which `
|
|
90
|
+
+ `authenticates the request, and drop the header), or read it from a flow input with no \`default\`, which `
|
|
91
|
+
+ `the caller supplies at run time. A \`default\` on an input or a .var() is written into the .flow too.`, `http({ url: …, managed: true, connection, folder })`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
40
94
|
/**
|
|
41
95
|
* The two http settings every deployed request node carries.
|
|
42
96
|
*
|
|
@@ -117,6 +171,7 @@ function comparesFailingCode(js, step) {
|
|
|
117
171
|
export function checkHttpStep(inputs, ctx) {
|
|
118
172
|
const step = ctx.step;
|
|
119
173
|
checkHttp(inputs, ctx);
|
|
174
|
+
checkSecretHeaders(inputs, ctx);
|
|
120
175
|
// A managed step's binding labels are the serializer's (BINDING_*), as a
|
|
121
176
|
// connector step's are.
|
|
122
177
|
const seen = new Set();
|
|
@@ -13,6 +13,7 @@ import { isRecord } from '../../../core/node-envelope.js';
|
|
|
13
13
|
import { wireExprBody } from '../../../core/wire-expr.js';
|
|
14
14
|
import { checkHttpRead, checkHttpStep, plainHttpOnErrorMessage } from './check.js';
|
|
15
15
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
16
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
16
17
|
const PLAIN = 'core.action.http';
|
|
17
18
|
const MANAGED = 'core.action.http.v2';
|
|
18
19
|
/** The definition's `inputDefaults` at the version being emitted. */
|
|
@@ -104,10 +105,9 @@ function managedHttpBinding(i, ctx) {
|
|
|
104
105
|
// The same resolution a connector step gets: a self-referential binding is an
|
|
105
106
|
// error, a stub is a warning.
|
|
106
107
|
const where = `managed http "${ctx.step}"`;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
108
|
+
const { connectionId, folderKey } = ctx.resolveBindingPair(i, where);
|
|
109
|
+
// Both labels are non-empty strings (refused above otherwise), so both resolve.
|
|
110
|
+
return { connectionId: connectionId, folderKey: folderKey };
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* The MANAGED HTTP node's inputs (`core.action.http.v2`).
|
|
@@ -410,9 +410,12 @@ function httpAt(typeName, version, managed) {
|
|
|
410
410
|
exits: httpExits,
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
|
+
/** Every key of `http()`'s options (builder-sdk#1990); `tsc` holds the list to `HttpInputs`. */
|
|
414
|
+
const HTTP_OPTIONS = { inputs: declareKeys({ branches: true, method: true, url: true, headers: true, query: true, body: true, contentType: true, managed: true, returns: true, timeout: true, retryCount: true, connection: true, folder: true, targetConnector: true }) };
|
|
413
415
|
function httpType(typeName, version, managed) {
|
|
414
416
|
return {
|
|
415
417
|
kind: 'http', typeName, factory: 'http', defaultVersion: version,
|
|
418
|
+
optionKeys: HTTP_OPTIONS,
|
|
416
419
|
versions: { [version]: httpAt(typeName, version, managed) },
|
|
417
420
|
matches: ({ inputs }) => Boolean(inputs?.managed) === managed,
|
|
418
421
|
};
|
|
@@ -19,6 +19,7 @@ import { resourceNodeSortOrder } from '../../../core/process-resource-sort-order
|
|
|
19
19
|
import { processResourceBindings, processResourceLocation } from '../../../core/process-resource.js';
|
|
20
20
|
import { checkAgent, checkAgentRead, checkAgenticProcess, checkAgenticProcessRead, checkApiWorkflow, checkApiWorkflowRead, checkPublishedFunction, checkPublishedFunctionRead, checkRpaWorkflow, rpaWorkflowRead, } from './check.js';
|
|
21
21
|
import { refuseLossyProcess } from './refusals.js';
|
|
22
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
22
23
|
/** The RPA-workflow node type family. The process's release key is the suffix. */
|
|
23
24
|
const RPA_WORKFLOW_PREFIX = 'uipath.core.rpa-workflow.';
|
|
24
25
|
/**
|
|
@@ -831,6 +832,14 @@ function processCheck(spec, ctx) {
|
|
|
831
832
|
case 'agent': return checkAgent(spec.inputs, ctx);
|
|
832
833
|
}
|
|
833
834
|
}
|
|
835
|
+
/** Every key of each factory's options (builder-sdk#1990), by kind; `tsc` holds each list to its type. */
|
|
836
|
+
const PROCESS_OPTIONS = {
|
|
837
|
+
rpaWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
|
|
838
|
+
apiWorkflow: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
|
|
839
|
+
publishedFunction: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true }) },
|
|
840
|
+
agenticProcess: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, form: true, completion: true, returns: true }) },
|
|
841
|
+
agent: { inputs: declareKeys({ key: true, name: true, location: true, folderPath: true, projectId: true, inputs: true, returns: true, flavour: true }) },
|
|
842
|
+
};
|
|
834
843
|
function processType(kind, prefix, factory, form) {
|
|
835
844
|
const impl = {
|
|
836
845
|
kind, typeName: `${prefix}*`, version: '1.0.0', factory, definition: 'per-tenant',
|
|
@@ -852,6 +861,7 @@ function processType(kind, prefix, factory, form) {
|
|
|
852
861
|
};
|
|
853
862
|
return {
|
|
854
863
|
kind, typeName: `${prefix}*`, typeNamePrefix: prefix, factory, defaultVersion: '1.0.0',
|
|
864
|
+
optionKeys: ownEntry(PROCESS_OPTIONS, kind),
|
|
855
865
|
versions: { '1.0.0': impl },
|
|
856
866
|
// The agentic process's three forms share its kind; an absent or unknown form
|
|
857
867
|
// is the default `bpmn` one, as the definition builder reads it.
|
|
@@ -4,6 +4,7 @@ import { isRecord } from '../../../core/node-envelope.js';
|
|
|
4
4
|
import { checkQueueItem, itemDataIsString, itemIsNotObject, queueItemExprMessage, queueItemNotObjectMessage, queueReturnsWithoutWaitMessage, } from './check.js';
|
|
5
5
|
import { QUEUE_ITEM_RECORD_SCHEMA } from './record.js';
|
|
6
6
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
7
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
7
8
|
const CREATE = 'core.action.queue.create';
|
|
8
9
|
const CREATE_AND_WAIT = 'core.action.queue.create-and-wait';
|
|
9
10
|
/**
|
|
@@ -356,9 +357,12 @@ function queueAt(typeName, wait) {
|
|
|
356
357
|
output: ({ inputs }) => queueOutput(inputs, wait),
|
|
357
358
|
};
|
|
358
359
|
}
|
|
360
|
+
/** Every key of `queueItem()`'s options (builder-sdk#1990); `tsc` holds the list to `QueueItemInputs`. */
|
|
361
|
+
const QUEUE_ITEM_OPTIONS = { inputs: declareKeys({ queue: true, folderPath: true, key: true, item: true, priority: true, reference: true, deferDate: true, dueDate: true, wait: true, returns: true }) };
|
|
359
362
|
function queueType(typeName, wait) {
|
|
360
363
|
return {
|
|
361
364
|
kind: 'queueItem', typeName, factory: 'queueItem', defaultVersion: '1.2',
|
|
365
|
+
optionKeys: QUEUE_ITEM_OPTIONS,
|
|
362
366
|
versions: { '1.2': queueAt(typeName, wait) },
|
|
363
367
|
matches: ({ inputs }) => Boolean(inputs?.wait) === wait,
|
|
364
368
|
};
|
|
@@ -10,6 +10,7 @@ import { unknownMetadataKeys } from '../../../core/flow-metadata.js';
|
|
|
10
10
|
import { scriptBodyEarlyError, scriptBodySyntaxError, scriptBodyTypeScriptSyntax, tryLowerScriptFunction } from '../../../core/script-function.js';
|
|
11
11
|
import { FLOW_SCRIPT_RUNTIME } from './runtime.js';
|
|
12
12
|
import { checkScript } from './check.js';
|
|
13
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
13
14
|
/**
|
|
14
15
|
* Declare what a `core.action.script` node actually publishes.
|
|
15
16
|
*
|
|
@@ -213,7 +214,10 @@ function scriptAt(version) {
|
|
|
213
214
|
output: () => ({ kind: 'opaque' }),
|
|
214
215
|
};
|
|
215
216
|
}
|
|
217
|
+
/** Every key of `script()`'s options (builder-sdk#1990); `tsc` holds the list to `ScriptInputs`. */
|
|
218
|
+
const SCRIPT_OPTIONS = { inputs: declareKeys({ code: true, returns: true }) };
|
|
216
219
|
export const scriptNodeType = {
|
|
217
220
|
kind: 'script', typeName: 'core.action.script', factory: 'script', defaultVersion: '1.0.0',
|
|
221
|
+
optionKeys: SCRIPT_OPTIONS,
|
|
218
222
|
versions: { '1.0.0': scriptAt('1.0.0'), '1.1': scriptAt('1.1') },
|
|
219
223
|
};
|
|
@@ -12,6 +12,7 @@ import { jsonClone } from '../../../core/json-clone.js';
|
|
|
12
12
|
import { VARIANT_OPERATION } from './spec.js';
|
|
13
13
|
import { checkTransform, nearestIn } from './check.js';
|
|
14
14
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
15
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
15
16
|
/**
|
|
16
17
|
* Emit a transform's `inputs` in the canonical shape the node's runtime reads:
|
|
17
18
|
* `collection` as a BARE variable path (not `=js:`-prefixed — it is a path
|
|
@@ -277,9 +278,12 @@ function transformAt(typeName, variant, version, factory) {
|
|
|
277
278
|
output: () => ({ kind: 'opaque' }),
|
|
278
279
|
};
|
|
279
280
|
}
|
|
281
|
+
/** Every key of `transform()`'s options (builder-sdk#1990); `tsc` holds the list to `TransformInputs`. */
|
|
282
|
+
const TRANSFORM_OPTIONS = { inputs: declareKeys({ collection: true, variant: true, operations: true }) };
|
|
280
283
|
function transformType(typeName, variant, factory) {
|
|
281
284
|
return {
|
|
282
285
|
kind: 'transform', typeName, factory: 'transform', defaultVersion: '1.0.0',
|
|
286
|
+
optionKeys: TRANSFORM_OPTIONS,
|
|
283
287
|
versions: { '1.0.0': transformAt(typeName, variant, '1.0.0', factory), '1.1': transformAt(typeName, variant, '1.1', factory) },
|
|
284
288
|
// The generic type is the one for any spec without a KNOWN variant — an unknown
|
|
285
289
|
// one included, so check still reports it (see serialize above).
|
|
@@ -19,6 +19,7 @@ import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
|
19
19
|
import { checkSchedule, checkStartingPrompts, fitsScheduleV12, isIsoInterval } from './check.js';
|
|
20
20
|
import { isJsExpressionValue } from '../../../core/wire-expr.js';
|
|
21
21
|
import { SCHEDULE_PRESETS } from './spec.js';
|
|
22
|
+
import { declareKeys } from '../../../core/option-keys.js';
|
|
22
23
|
/** A Quartz cron expression: 6–7 whitespace-separated fields, none of them an ISO `R/` interval. */
|
|
23
24
|
function isQuartz(every) {
|
|
24
25
|
// An `=js:` expression can have six tokens too; it is not cron.
|
|
@@ -175,8 +176,12 @@ export const manualTriggerType = {
|
|
|
175
176
|
// survives recompilation (design §5.3).
|
|
176
177
|
print: () => ({ factory: 'manual' }),
|
|
177
178
|
};
|
|
179
|
+
/** Every key of each trigger factory's options (builder-sdk#1990); `tsc` holds each list to its type. */
|
|
180
|
+
const SCHEDULED_OPTIONS = { inputs: declareKeys({ every: true }) };
|
|
181
|
+
const CONVERSATION_TRIGGER_OPTIONS = { appearance: declareKeys({ welcomeTitle: true, welcomeDescription: true, startingPrompts: true, personalWorkspaceConnectionsOnly: true }) };
|
|
178
182
|
export const scheduledTriggerType = {
|
|
179
183
|
kind: 'scheduled', typeName: 'core.trigger.scheduled', factory: 'scheduled',
|
|
184
|
+
optionKeys: SCHEDULED_OPTIONS,
|
|
180
185
|
noun: 'schedule',
|
|
181
186
|
serialize: (spec, ctx) => {
|
|
182
187
|
const version = scheduledVersion(spec.inputs, ctx.version);
|
|
@@ -289,6 +294,7 @@ function liftAppearance(node) {
|
|
|
289
294
|
}
|
|
290
295
|
export const conversationTriggerType = {
|
|
291
296
|
kind: 'conversation', typeName: 'core.trigger.conversation', factory: 'conversationTrigger',
|
|
297
|
+
optionKeys: CONVERSATION_TRIGGER_OPTIONS,
|
|
292
298
|
onePerFlow: 'SINGLE_CONVERSATION_TRIGGER',
|
|
293
299
|
serialize: (spec, ctx) => {
|
|
294
300
|
const version = ctx.version ?? CONVERSATION_DEFAULT_VERSION;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an installed copy of this SDK says about itself, and the project floor.
|
|
3
|
+
*
|
|
4
|
+
* A caller that needs a feature asks the copy in use instead of guessing its
|
|
5
|
+
* release from what it ships (a symbol in `dist/api-index.md`, a word in a
|
|
6
|
+
* generated pipeline). `flow-sdk capabilities` prints the same answer.
|
|
7
|
+
*
|
|
8
|
+
* The capability list is the `cliCapabilities` array of this package's own
|
|
9
|
+
* `package.json`, the list `uip` already reads before it forwards an option.
|
|
10
|
+
* A name, once listed, is never renamed or dropped.
|
|
11
|
+
*
|
|
12
|
+
* The version is the one the release stamps into `package.json`. The source
|
|
13
|
+
* tree keeps it at `0.0.0-local` (docs/RELEASE.md) and the eval image stamps
|
|
14
|
+
* `9999.0.0-local`: a version ending in `-local` is a build of a checkout, and
|
|
15
|
+
* {@link sdkVersionSatisfies} lets it meet any floor.
|
|
16
|
+
*/
|
|
17
|
+
/** The answer of {@link sdkCapabilities}. */
|
|
18
|
+
export interface SdkCapabilities {
|
|
19
|
+
/** The package name, `@uipath/maestro-builder-sdk`. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** The installed version, for instance `6.97.0`; `0.0.0-local` in a checkout. */
|
|
22
|
+
version: string;
|
|
23
|
+
/** The commit the release was built from, or `null` when none was stamped. */
|
|
24
|
+
gitref: string | null;
|
|
25
|
+
/** The stable feature names this copy supports, for instance `flow-check-baseline`. */
|
|
26
|
+
capabilities: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read the name, version, gitref and capability list of this installed copy
|
|
30
|
+
* from its `package.json`. Needs Node: it reads the file through
|
|
31
|
+
* `node:module`'s `createRequire`, loaded on call.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { sdkCapabilities } from '@uipath/maestro-builder-sdk';
|
|
36
|
+
* if (!sdkCapabilities().capabilities.includes('flow-check-baseline')) {
|
|
37
|
+
* throw new Error('upgrade @uipath/maestro-builder-sdk');
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function sdkCapabilities(): SdkCapabilities;
|
|
42
|
+
/** Whether `floor` is a plain release version (`6.97.0`), the only form `flowSdk.minVersion` takes. */
|
|
43
|
+
export declare function isSdkVersionFloor(floor: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether an installed SDK `version` meets `floor`, a release version such as
|
|
46
|
+
* `6.97.0`. A version ending in `-local` (a build of a checkout) meets every
|
|
47
|
+
* floor. Another prerelease (`6.97.0-beta.1`) sits below its release, as in
|
|
48
|
+
* semver. A `version` or `floor` that is not a version meets nothing.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* sdkVersionSatisfies('6.97.1', '6.97.0'); // true
|
|
53
|
+
* sdkVersionSatisfies('6.90.0', '6.97.0'); // false
|
|
54
|
+
* sdkVersionSatisfies('0.0.0-local', '6.97.0'); // true
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function sdkVersionSatisfies(version: string, floor: string): boolean;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an installed copy of this SDK says about itself, and the project floor.
|
|
3
|
+
*
|
|
4
|
+
* A caller that needs a feature asks the copy in use instead of guessing its
|
|
5
|
+
* release from what it ships (a symbol in `dist/api-index.md`, a word in a
|
|
6
|
+
* generated pipeline). `flow-sdk capabilities` prints the same answer.
|
|
7
|
+
*
|
|
8
|
+
* The capability list is the `cliCapabilities` array of this package's own
|
|
9
|
+
* `package.json`, the list `uip` already reads before it forwards an option.
|
|
10
|
+
* A name, once listed, is never renamed or dropped.
|
|
11
|
+
*
|
|
12
|
+
* The version is the one the release stamps into `package.json`. The source
|
|
13
|
+
* tree keeps it at `0.0.0-local` (docs/RELEASE.md) and the eval image stamps
|
|
14
|
+
* `9999.0.0-local`: a version ending in `-local` is a build of a checkout, and
|
|
15
|
+
* {@link sdkVersionSatisfies} lets it meet any floor.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Read the name, version, gitref and capability list of this installed copy
|
|
19
|
+
* from its `package.json`. Needs Node: it reads the file through
|
|
20
|
+
* `node:module`'s `createRequire`, loaded on call.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { sdkCapabilities } from '@uipath/maestro-builder-sdk';
|
|
25
|
+
* if (!sdkCapabilities().capabilities.includes('flow-check-baseline')) {
|
|
26
|
+
* throw new Error('upgrade @uipath/maestro-builder-sdk');
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function sdkCapabilities() {
|
|
31
|
+
const load = globalThis.process?.getBuiltinModule;
|
|
32
|
+
const mod = load?.('node:module');
|
|
33
|
+
if (!mod?.createRequire)
|
|
34
|
+
throw new Error('sdkCapabilities() needs Node 22.3 or later (process.getBuiltinModule)');
|
|
35
|
+
const pkg = mod.createRequire(import.meta.url)('../package.json');
|
|
36
|
+
return {
|
|
37
|
+
name: typeof pkg.name === 'string' ? pkg.name : '',
|
|
38
|
+
version: typeof pkg.version === 'string' ? pkg.version : '',
|
|
39
|
+
gitref: typeof pkg.gitref === 'string' && pkg.gitref !== '' ? pkg.gitref : null,
|
|
40
|
+
capabilities: Array.isArray(pkg.cliCapabilities) ? pkg.cliCapabilities.filter((c) => typeof c === 'string') : [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const RELEASE = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
44
|
+
const INSTALLED = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
|
|
45
|
+
/** Whether `floor` is a plain release version (`6.97.0`), the only form `flowSdk.minVersion` takes. */
|
|
46
|
+
export function isSdkVersionFloor(floor) {
|
|
47
|
+
return RELEASE.test(floor);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether an installed SDK `version` meets `floor`, a release version such as
|
|
51
|
+
* `6.97.0`. A version ending in `-local` (a build of a checkout) meets every
|
|
52
|
+
* floor. Another prerelease (`6.97.0-beta.1`) sits below its release, as in
|
|
53
|
+
* semver. A `version` or `floor` that is not a version meets nothing.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* sdkVersionSatisfies('6.97.1', '6.97.0'); // true
|
|
58
|
+
* sdkVersionSatisfies('6.90.0', '6.97.0'); // false
|
|
59
|
+
* sdkVersionSatisfies('0.0.0-local', '6.97.0'); // true
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function sdkVersionSatisfies(version, floor) {
|
|
63
|
+
const want = RELEASE.exec(floor);
|
|
64
|
+
const have = INSTALLED.exec(version);
|
|
65
|
+
if (!want || !have)
|
|
66
|
+
return false;
|
|
67
|
+
const prerelease = have[4];
|
|
68
|
+
if (version.endsWith('-local'))
|
|
69
|
+
return true;
|
|
70
|
+
for (let i = 1; i <= 3; i++) {
|
|
71
|
+
const delta = Number(have[i]) - Number(want[i]);
|
|
72
|
+
if (delta !== 0)
|
|
73
|
+
return delta > 0;
|
|
74
|
+
}
|
|
75
|
+
return prerelease === undefined;
|
|
76
|
+
}
|