@uipath/maestro-builder-sdk 6.100.0 → 6.101.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/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/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/sdk-capabilities.d.ts +57 -0
- package/dist/sdk-capabilities.js +76 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -214,6 +214,9 @@ result itself (`registry search`, `registry path`, `bpmn check --graph`) prints
|
|
|
214
214
|
only as that object under `--json`, never a second copy on stderr. `package.json` lists the optional
|
|
215
215
|
surface a caller may probe for in `cliCapabilities` (`json-result`; `fetch-definitions` when a
|
|
216
216
|
connector definition no library carries is fetched through `uip`, so no library has to be pulled).
|
|
217
|
+
`flow-sdk capabilities` prints that list with the installed version (`--json` for one
|
|
218
|
+
object), and `flowSdk.minVersion` in a project's `package.json` makes the `flow`, `case`
|
|
219
|
+
and `bpmn` verbs refuse an older SDK (`website/reference/CLI-LOOP.md`).
|
|
217
220
|
|
|
218
221
|
The stable argv grammar is family first: `flow|case|bpmn`, then the SDK verb and
|
|
219
222
|
its documented options. The process exit contract is `0` for success, `1` for
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* `flow-sdk capabilities` (#1991): what this installed copy supports, so a
|
|
4
|
+
* caller asks instead of guessing the release from what the package ships.
|
|
5
|
+
*
|
|
6
|
+
* Plain output is the name and version on the first line, then one capability
|
|
7
|
+
* per line, so `flow-sdk capabilities | grep -qx flow-check-baseline` works.
|
|
8
|
+
* With `--json`: `{"ok":true,"name":…,"version":…,"gitref":…,"capabilities":[…]}`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerCapabilitiesCommand(program: Command): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsonResultRequested, recordJsonFields } from '../common.js';
|
|
2
|
+
/**
|
|
3
|
+
* `flow-sdk capabilities` (#1991): what this installed copy supports, so a
|
|
4
|
+
* caller asks instead of guessing the release from what the package ships.
|
|
5
|
+
*
|
|
6
|
+
* Plain output is the name and version on the first line, then one capability
|
|
7
|
+
* per line, so `flow-sdk capabilities | grep -qx flow-check-baseline` works.
|
|
8
|
+
* With `--json`: `{"ok":true,"name":…,"version":…,"gitref":…,"capabilities":[…]}`.
|
|
9
|
+
*/
|
|
10
|
+
export function registerCapabilitiesCommand(program) {
|
|
11
|
+
program.command('capabilities')
|
|
12
|
+
.description('Print this SDK\'s name, version, gitref and the stable names of the features it supports.')
|
|
13
|
+
.action(async () => {
|
|
14
|
+
const { sdkCapabilities } = await import('../../sdk-capabilities.js');
|
|
15
|
+
const caps = sdkCapabilities();
|
|
16
|
+
if (jsonResultRequested()) {
|
|
17
|
+
recordJsonFields({ ...caps });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
console.log(`${caps.name} ${caps.version}${caps.gitref === null ? '' : ` (gitref ${caps.gitref})`}`);
|
|
21
|
+
for (const capability of caps.capabilities)
|
|
22
|
+
console.log(capability);
|
|
23
|
+
});
|
|
24
|
+
}
|
package/dist/cli/common.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare function invoke(label: string, load: () => Promise<{
|
|
|
11
11
|
export declare function refuse(message: string, exitCode?: number): void;
|
|
12
12
|
/** Record why the verb failed before any tool ran, for the `--json` object. */
|
|
13
13
|
export declare function recordJsonError(message: string): void;
|
|
14
|
+
/** Add a verb's own fields to the `--json` object. */
|
|
15
|
+
export declare function recordJsonFields(fields: Record<string, unknown>): void;
|
|
14
16
|
/** Turn `--json` on for this run (the umbrella's `preAction` hook). */
|
|
15
17
|
export declare function requestJsonResult(): void;
|
|
16
18
|
export declare function jsonResultRequested(): boolean;
|
|
@@ -22,26 +24,24 @@ export declare function jsonResultRequested(): boolean;
|
|
|
22
24
|
*/
|
|
23
25
|
export declare function emitJsonResult(): void;
|
|
24
26
|
export declare function addValue(argv: string[], flag: string, value: unknown): void;
|
|
27
|
+
/** Is emit-only mode on for the PROJECT containing `cwd`? See {@link nearestSetting}. */
|
|
28
|
+
export declare function emitOnlyEnabled(cwd?: string, env?: NodeJS.ProcessEnv): boolean;
|
|
25
29
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* Refuse a `flow`, `case` or `bpmn` verb (exit 2) when its project declares
|
|
31
|
+
* `flowSdk.minVersion` and this installed SDK is older (#1991). The project is
|
|
32
|
+
* looked up from the working directory and from each input path
|
|
33
|
+
* ({@link floorAnchors}); a floor any of them finds must be met. Returns whether
|
|
34
|
+
* it refused.
|
|
31
35
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* `
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* that says nothing about `flowSdk` must not lift an ancestor's emit-only, since
|
|
40
|
-
* scaffolders (`uip solution init`) drop exactly such a file into a subdirectory
|
|
41
|
-
* of an emit-only project. A nested package that explicitly sets
|
|
42
|
-
* `emitOnly: false` still opts out — silence and denial are different answers.
|
|
36
|
+
* The floor lets a project, or a skill that writes its package.json, state the
|
|
37
|
+
* one release it was written for, instead of probing the SDK for each feature.
|
|
38
|
+
* The nearest declaration wins, as for `emitOnly`. A value that is not a release
|
|
39
|
+
* version (`"^6.1"`, `6`) is refused too: a typo must not switch the floor off.
|
|
40
|
+
* A build of a checkout (`0.0.0-local`, `9999.0.0-local`) meets every floor.
|
|
41
|
+
* Registry verbs and `capabilities` are not gated: they are how a caller finds
|
|
42
|
+
* out what it has.
|
|
43
43
|
*/
|
|
44
|
-
export declare function
|
|
44
|
+
export declare function refuseBelowMinVersion(label: string, argv?: readonly string[], cwd?: string): Promise<boolean>;
|
|
45
45
|
export type CheckMode = 'source' | 'compiled';
|
|
46
46
|
export declare function inferCheckMode(family: 'flow' | 'case' | 'bpmn', input: string, source: boolean, compiled: boolean): CheckMode;
|
|
47
47
|
/**
|
package/dist/cli/common.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, join, resolve } from 'node:path';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
3
4
|
import { Option } from 'commander';
|
|
4
5
|
export async function invoke(label, load, argv) {
|
|
6
|
+
if (await refuseBelowMinVersion(label, argv))
|
|
7
|
+
return;
|
|
5
8
|
// In `--json` mode stdout carries exactly one JSON object, printed by
|
|
6
9
|
// `emitJsonResult` once the verb is done. The tool's own human lines go to
|
|
7
10
|
// stderr meanwhile, so they are still seen but never mixed into it.
|
|
@@ -48,6 +51,10 @@ export function refuse(message, exitCode = 2) {
|
|
|
48
51
|
export function recordJsonError(message) {
|
|
49
52
|
resultSlot().fields.error ??= message.replace(/^error: /, '');
|
|
50
53
|
}
|
|
54
|
+
/** Add a verb's own fields to the `--json` object. */
|
|
55
|
+
export function recordJsonFields(fields) {
|
|
56
|
+
Object.assign(resultSlot().fields, fields);
|
|
57
|
+
}
|
|
51
58
|
/** Turn `--json` on for this run (the umbrella's `preAction` hook). */
|
|
52
59
|
export function requestJsonResult() {
|
|
53
60
|
resultSlot().json = true;
|
|
@@ -80,29 +87,30 @@ export function addValue(argv, flag, value) {
|
|
|
80
87
|
argv.push(flag, value);
|
|
81
88
|
}
|
|
82
89
|
/**
|
|
83
|
-
* `flowSdk
|
|
84
|
-
* file says nothing about it — absent, unreadable, malformed, or
|
|
85
|
-
* "Says nothing" is deliberately distinct from "says false": only the
|
|
86
|
-
* lets the search continue to the parent directory.
|
|
90
|
+
* The value `flowSdk.<key>` has in ONE package.json, or `undefined` when that
|
|
91
|
+
* file says nothing about it — absent, unreadable, malformed, or rejected by
|
|
92
|
+
* `accept`. "Says nothing" is deliberately distinct from "says false": only the
|
|
93
|
+
* former lets the search continue to the parent directory.
|
|
87
94
|
*/
|
|
88
|
-
function
|
|
95
|
+
function declaredSetting(packagePath, key, accept) {
|
|
89
96
|
if (!existsSync(packagePath))
|
|
90
97
|
return undefined;
|
|
91
98
|
try {
|
|
92
99
|
const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
93
|
-
const declared = pkg.flowSdk?.
|
|
94
|
-
return
|
|
100
|
+
const declared = pkg.flowSdk?.[key];
|
|
101
|
+
return declared === undefined ? undefined : accept(declared);
|
|
95
102
|
}
|
|
96
103
|
catch {
|
|
97
104
|
return undefined;
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
/**
|
|
101
|
-
*
|
|
108
|
+
* The nearest `flowSdk.<key>` declaration at or above `cwd`, with the
|
|
109
|
+
* package.json that made it; `undefined` when no ancestor declares one.
|
|
102
110
|
*
|
|
103
|
-
*
|
|
104
|
-
* standing in, so this walks up for the nearest `package.json`
|
|
105
|
-
* declares
|
|
111
|
+
* A setting under `flowSdk` is a property of the project, not of the directory
|
|
112
|
+
* you happen to be standing in, so this walks up for the nearest `package.json`
|
|
113
|
+
* that actually declares it — the way Node tooling resolves project config.
|
|
106
114
|
*
|
|
107
115
|
* Anchoring it to `process.cwd()` alone was #392. Compiling the same project from
|
|
108
116
|
* a subdirectory found no `package.json`, silently re-armed the checker, and —
|
|
@@ -111,23 +119,109 @@ function declaredEmitOnly(packagePath) {
|
|
|
111
119
|
* past its own emit-only refusal simply by being run one directory down.
|
|
112
120
|
*
|
|
113
121
|
* Nearest DECLARATION wins, not nearest package.json: a nested `package.json`
|
|
114
|
-
* that says nothing about `flowSdk` must not lift an ancestor's
|
|
122
|
+
* that says nothing about `flowSdk` must not lift an ancestor's setting, since
|
|
115
123
|
* scaffolders (`uip solution init`) drop exactly such a file into a subdirectory
|
|
116
|
-
* of
|
|
117
|
-
*
|
|
124
|
+
* of a project. A nested package that explicitly sets `emitOnly: false` still
|
|
125
|
+
* opts out — silence and denial are different answers.
|
|
118
126
|
*/
|
|
127
|
+
function nearestSetting(cwd, key, accept) {
|
|
128
|
+
for (let dir = resolve(cwd);;) {
|
|
129
|
+
const path = join(dir, 'package.json');
|
|
130
|
+
const value = declaredSetting(path, key, accept);
|
|
131
|
+
if (value !== undefined)
|
|
132
|
+
return { value, path };
|
|
133
|
+
const parent = dirname(dir);
|
|
134
|
+
if (parent === dir)
|
|
135
|
+
return undefined; // filesystem root, nothing declared it
|
|
136
|
+
dir = parent;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** Is emit-only mode on for the PROJECT containing `cwd`? See {@link nearestSetting}. */
|
|
119
140
|
export function emitOnlyEnabled(cwd = process.cwd(), env = process.env) {
|
|
120
141
|
if (env.FLOW_SDK_EMIT_ONLY === '1')
|
|
121
142
|
return true;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
143
|
+
return nearestSetting(cwd, 'emitOnly', (value) => (typeof value === 'boolean' ? value : undefined))?.value ?? false;
|
|
144
|
+
}
|
|
145
|
+
/** The families whose verbs read or write an artifact, and so honor the project floor. */
|
|
146
|
+
const FLOOR_FAMILIES = new Set(['flow', 'case', 'bpmn']);
|
|
147
|
+
/**
|
|
148
|
+
* The directories a verb's floor is looked up from: the working directory, and
|
|
149
|
+
* the directory of each input path, the leading positional arguments before the
|
|
150
|
+
* first option (`[source]`, `[input]`, `[original, edited]`). A verb run from
|
|
151
|
+
* outside its project (`flow check proj/sub/X.flow.ts`) is still in that project.
|
|
152
|
+
*/
|
|
153
|
+
function floorAnchors(cwd, argv) {
|
|
154
|
+
const anchors = [resolve(cwd)];
|
|
155
|
+
for (const arg of argv) {
|
|
156
|
+
if (arg.startsWith('-'))
|
|
157
|
+
break;
|
|
158
|
+
const dir = dirname(resolve(cwd, arg));
|
|
159
|
+
if (!anchors.includes(dir))
|
|
160
|
+
anchors.push(dir);
|
|
161
|
+
}
|
|
162
|
+
return anchors;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The npm command that upgrades THIS copy of the SDK. A copy under a project's
|
|
166
|
+
* `node_modules` is used before a global one, so upgrading the global copy would
|
|
167
|
+
* leave the refusal in place; name `--save-dev` and the project then. `@latest`
|
|
168
|
+
* meets any published floor and needs no shell quoting (`>=` is a redirect in
|
|
169
|
+
* `cmd.exe`, quoted or not).
|
|
170
|
+
*/
|
|
171
|
+
function upgradeCommand(name, packageRoot) {
|
|
172
|
+
for (let dir = packageRoot;;) {
|
|
126
173
|
const parent = dirname(dir);
|
|
127
174
|
if (parent === dir)
|
|
128
|
-
|
|
175
|
+
break;
|
|
176
|
+
if (basename(dir) === 'node_modules') {
|
|
177
|
+
if (existsSync(join(parent, 'package.json')))
|
|
178
|
+
return `\`npm install --save-dev ${name}@latest\` in ${parent}`;
|
|
179
|
+
break; // <prefix>/lib/node_modules, %APPDATA%\npm\node_modules: the global copy
|
|
180
|
+
}
|
|
129
181
|
dir = parent;
|
|
130
182
|
}
|
|
183
|
+
return `\`npm install -g ${name}@latest\``;
|
|
184
|
+
}
|
|
185
|
+
/** This package's root, from `dist/cli/common.js`. */
|
|
186
|
+
const PACKAGE_ROOT = resolve(fileURLToPath(new URL('../../', import.meta.url)));
|
|
187
|
+
/**
|
|
188
|
+
* Refuse a `flow`, `case` or `bpmn` verb (exit 2) when its project declares
|
|
189
|
+
* `flowSdk.minVersion` and this installed SDK is older (#1991). The project is
|
|
190
|
+
* looked up from the working directory and from each input path
|
|
191
|
+
* ({@link floorAnchors}); a floor any of them finds must be met. Returns whether
|
|
192
|
+
* it refused.
|
|
193
|
+
*
|
|
194
|
+
* The floor lets a project, or a skill that writes its package.json, state the
|
|
195
|
+
* one release it was written for, instead of probing the SDK for each feature.
|
|
196
|
+
* The nearest declaration wins, as for `emitOnly`. A value that is not a release
|
|
197
|
+
* version (`"^6.1"`, `6`) is refused too: a typo must not switch the floor off.
|
|
198
|
+
* A build of a checkout (`0.0.0-local`, `9999.0.0-local`) meets every floor.
|
|
199
|
+
* Registry verbs and `capabilities` are not gated: they are how a caller finds
|
|
200
|
+
* out what it has.
|
|
201
|
+
*/
|
|
202
|
+
export async function refuseBelowMinVersion(label, argv = [], cwd = process.cwd()) {
|
|
203
|
+
if (!FLOOR_FAMILIES.has(label.split(' ')[0]))
|
|
204
|
+
return false;
|
|
205
|
+
const found = floorAnchors(cwd, argv)
|
|
206
|
+
.map((dir) => nearestSetting(dir, 'minVersion', (value) => value))
|
|
207
|
+
.filter((declared) => declared !== undefined);
|
|
208
|
+
if (found.length === 0)
|
|
209
|
+
return false;
|
|
210
|
+
const { isSdkVersionFloor, sdkCapabilities, sdkVersionSatisfies } = await import('../sdk-capabilities.js');
|
|
211
|
+
const { name, version } = sdkCapabilities();
|
|
212
|
+
for (const declared of found) {
|
|
213
|
+
const floor = declared.value;
|
|
214
|
+
if (typeof floor !== 'string' || !isSdkVersionFloor(floor)) {
|
|
215
|
+
refuse(`flow-sdk ${label}: flowSdk.minVersion in ${declared.path} is ${JSON.stringify(floor)}; write a plain release version, X.Y.Z`);
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
if (sdkVersionSatisfies(version, floor))
|
|
219
|
+
continue;
|
|
220
|
+
refuse(`flow-sdk ${label}: this project needs ${name} >= ${floor} (flowSdk.minVersion in ${declared.path}); found ${version} at ${PACKAGE_ROOT}. ` +
|
|
221
|
+
`Upgrade that copy: ${upgradeCommand(name, PACKAGE_ROOT)}.`);
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
131
225
|
}
|
|
132
226
|
export function inferCheckMode(family, input, source, compiled) {
|
|
133
227
|
if (source && compiled)
|
package/dist/cli/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFileSync } from 'node:fs';
|
|
|
3
3
|
import { Command, CommanderError } from 'commander';
|
|
4
4
|
import { emitJsonResult, recordJsonError, requestJsonResult } from './common.js';
|
|
5
5
|
import { registerBpmnCommands } from './commands/bpmn.js';
|
|
6
|
+
import { registerCapabilitiesCommand } from './commands/capabilities.js';
|
|
6
7
|
import { registerCaseCommands } from './commands/case.js';
|
|
7
8
|
import { registerFlowCommands } from './commands/flow.js';
|
|
8
9
|
import { registerRegistryCommands } from './commands/registry.js';
|
|
@@ -16,6 +17,7 @@ registerFlowCommands(program);
|
|
|
16
17
|
registerCaseCommands(program);
|
|
17
18
|
registerBpmnCommands(program);
|
|
18
19
|
registerRegistryCommands(program);
|
|
20
|
+
registerCapabilitiesCommand(program);
|
|
19
21
|
// `--json` on every verb (#809): one JSON object on stdout, human lines on
|
|
20
22
|
// stderr. Added here, once, so a new verb cannot ship without it.
|
|
21
23
|
const addJson = (command) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export { Library } from './library.js';
|
|
|
21
21
|
export { Bindings } from './bindings.js';
|
|
22
22
|
export { check } from './check.js';
|
|
23
23
|
export type { Diagnostic } from './check.js';
|
|
24
|
+
export { sdkCapabilities, sdkVersionSatisfies, isSdkVersionFloor } from './sdk-capabilities.js';
|
|
25
|
+
export type { SdkCapabilities } from './sdk-capabilities.js';
|
|
24
26
|
export { casePlan, preserveCaseJson, rule, when } from './case/case-sdk.js';
|
|
25
27
|
export type { CaseRule, CaseRuleInput, CaseRuleGrid, WhenExpression, CaseJsonPreservation, CaseLayout, CaseNodeLayout, PreservedCaseNode, PreservedTaskFields, PreservedVariableLane, CaseRuleType, RuleOpts, BuiltCase, BuiltStage, BuiltTask, TaskKind, UnresolvedReferenceTaskKind, ExternalEventPair, ExternalExecutionMode, ExternalTaskOptions, } from './case/case-sdk.js';
|
|
26
28
|
export { serialize as serializeCase } from './case/serialize.js';
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,9 @@ export { MergeRefusedError as FlowMergeRefusedError } from './merge.js';
|
|
|
24
24
|
export { Library } from './library.js';
|
|
25
25
|
export { Bindings } from './bindings.js';
|
|
26
26
|
export { check } from './check.js';
|
|
27
|
+
// What this installed copy supports, and the version test behind the project
|
|
28
|
+
// floor (`flowSdk.minVersion`) that `flow-sdk` enforces (#1991).
|
|
29
|
+
export { sdkCapabilities, sdkVersionSatisfies, isSdkVersionFloor } from './sdk-capabilities.js';
|
|
27
30
|
// Case authoring API (reference-mode). `casePlan()` exposes only case methods.
|
|
28
31
|
export { casePlan, preserveCaseJson, rule, when } from './case/case-sdk.js';
|
|
29
32
|
export { serialize as serializeCase } from './case/serialize.js';
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.101.0",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -78,7 +78,13 @@
|
|
|
78
78
|
"bpmn-merge-source",
|
|
79
79
|
"flow-merge-source",
|
|
80
80
|
"fetch-definitions",
|
|
81
|
-
"bpmn-check-baseline"
|
|
81
|
+
"bpmn-check-baseline",
|
|
82
|
+
"capabilities-command",
|
|
83
|
+
"project-min-version",
|
|
84
|
+
"flow-check-baseline",
|
|
85
|
+
"flow-decompile-scripts",
|
|
86
|
+
"flow-script-metadata",
|
|
87
|
+
"flow-pipeline-strict"
|
|
82
88
|
],
|
|
83
89
|
"files": [
|
|
84
90
|
"dist",
|
|
@@ -115,5 +121,5 @@
|
|
|
115
121
|
"@types/node": "^22.7.0",
|
|
116
122
|
"esbuild": "^0.28.1"
|
|
117
123
|
},
|
|
118
|
-
"gitref": "
|
|
124
|
+
"gitref": "a61a8ae8c2fc41973228083ad52eb07a55eb5893"
|
|
119
125
|
}
|