@uipath/maestro-builder-sdk 6.80.0 → 6.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-index.md +82 -79
- package/dist/api-members.md +267 -250
- package/dist/case/case-sdk.d.ts +141 -20
- package/dist/case/case-sdk.js +112 -2
- package/dist/case/check.js +22 -0
- package/dist/case/decompile-document-extraction.d.ts +17 -0
- package/dist/case/decompile-document-extraction.js +76 -0
- package/dist/case/decompile-script.d.ts +23 -0
- package/dist/case/decompile-script.js +53 -0
- package/dist/case/decompile.d.ts +6 -0
- package/dist/case/decompile.js +41 -0
- package/dist/case/document-extraction-output-schema.json +132 -0
- package/dist/case/document-extraction-saved.d.ts +24 -0
- package/dist/case/document-extraction-saved.js +64 -0
- package/dist/case/document-extraction.d.ts +119 -0
- package/dist/case/document-extraction.js +161 -0
- package/dist/case/load.js +12 -0
- package/dist/case/preserve.d.ts +7 -0
- package/dist/case/preserve.js +6 -0
- package/dist/case/script.d.ts +75 -0
- package/dist/case/script.js +124 -0
- package/dist/case/serialize.js +174 -17
- package/dist/core/refusals.d.ts +11 -0
- package/dist/core/refusals.js +22 -0
- package/dist/core/script-engine.d.ts +34 -0
- package/dist/core/script-engine.js +48 -0
- package/dist/nodes/script/flow/runtime.d.ts +1 -1
- package/dist/nodes/script/flow/runtime.js +5 -35
- package/dist/script-function-scope.js +44 -6
- package/package.json +2 -2
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* The names the engine's preludes declare with `const` before the script runs
|
|
3
|
-
* (`ScriptTaskService.cs`, `WithBuiltInFunctions` and `WithConsole`). At the
|
|
4
|
-
* body's top level, a `const`, `let`, `var`, `function` or `class` of one fails
|
|
5
|
-
* with "Identifier '…' has already been declared", and an assignment to one with
|
|
6
|
-
* "Assignment to constant variable." (both measured on Jint 4.4.0). Inside a
|
|
7
|
-
* nested block or function the name is the author's own and is fine.
|
|
8
|
-
*/
|
|
9
|
-
const FLOW_SCRIPT_CONST_GLOBALS = new Set(['console', 'uipath', 'aggregate', '_aggregate', '_pipe']);
|
|
10
|
-
/**
|
|
11
|
-
* The members the engine's own objects have; any other member reads
|
|
12
|
-
* `undefined`, so calling it throws "Property '…' of object is not a function"
|
|
13
|
-
* (measured on Jint 4.4.0). `crypto` holds only `randomUUID`
|
|
14
|
-
* (`JavaScriptEvaluator.cs`), and `console` only the five no-ops `WithConsole`
|
|
15
|
-
* declares (`ScriptTaskService.cs`).
|
|
16
|
-
*/
|
|
17
|
-
const FLOW_SCRIPT_GLOBAL_MEMBERS = new Map([
|
|
18
|
-
['crypto', new Set(['randomUUID'])],
|
|
19
|
-
['console', new Set(['debug', 'error', 'info', 'log', 'warn'])],
|
|
20
|
-
]);
|
|
1
|
+
import { SCRIPT_ENGINE_CONST_GLOBALS, SCRIPT_ENGINE_GLOBAL_MEMBERS, SCRIPT_ENGINE_GLOBALS } from '../../../core/script-engine.js';
|
|
21
2
|
/**
|
|
22
3
|
* What a Flow script body can read: the language's ES2020 built-ins, the
|
|
23
4
|
* globals the engine registers, `console`, and the runtime's `$vars` and
|
|
@@ -35,7 +16,7 @@ const FLOW_SCRIPT_GLOBAL_MEMBERS = new Map([
|
|
|
35
16
|
* the body goes to `Engine.Evaluate` as a script, after `btoa`/`atob` (UTF-8),
|
|
36
17
|
* `randomUUID` and `crypto` (holding only `randomUUID`) are set
|
|
37
18
|
* (`src/BpmnEngine/UiPath.PO.BpmnEngine/Expressions/JavaScriptEvaluator.cs`) and
|
|
38
|
-
* two preludes declare {@link
|
|
19
|
+
* two preludes declare {@link SCRIPT_ENGINE_CONST_GLOBALS} with `const`. `Intl`,
|
|
39
20
|
* `URL`, `TextEncoder`, `Buffer`, `fetch`, `require` and `structuredClone` read
|
|
40
21
|
* `undefined` there, so they are absent here. Change this when the engine does.
|
|
41
22
|
*
|
|
@@ -63,18 +44,7 @@ export const FLOW_SCRIPT_RUNTIME = {
|
|
|
63
44
|
},
|
|
64
45
|
],
|
|
65
46
|
name: 'the Flow script runtime',
|
|
66
|
-
constGlobals:
|
|
67
|
-
globalMembers:
|
|
68
|
-
globals:
|
|
69
|
-
'undefined', 'NaN', 'Infinity', 'globalThis', 'console',
|
|
70
|
-
'btoa', 'atob', 'randomUUID', 'crypto',
|
|
71
|
-
'Object', 'Function', 'Array', 'Number', 'Boolean', 'String', 'Symbol', 'BigInt', 'Date', 'RegExp', 'Math', 'JSON',
|
|
72
|
-
'Promise', 'Proxy', 'Reflect', 'Map', 'Set', 'WeakMap', 'WeakSet',
|
|
73
|
-
'Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
|
|
74
|
-
'ArrayBuffer', 'SharedArrayBuffer', 'DataView', 'Atomics',
|
|
75
|
-
'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array',
|
|
76
|
-
'Float32Array', 'Float64Array', 'BigInt64Array', 'BigUint64Array',
|
|
77
|
-
'parseInt', 'parseFloat', 'isNaN', 'isFinite',
|
|
78
|
-
'encodeURI', 'encodeURIComponent', 'decodeURI', 'decodeURIComponent', 'eval',
|
|
79
|
-
]),
|
|
47
|
+
constGlobals: SCRIPT_ENGINE_CONST_GLOBALS,
|
|
48
|
+
globalMembers: SCRIPT_ENGINE_GLOBAL_MEMBERS,
|
|
49
|
+
globals: SCRIPT_ENGINE_GLOBALS,
|
|
80
50
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
2
3
|
import { typescript } from './core/typescript-module.js';
|
|
4
|
+
import { isSdkSpecifier } from './sdk-resolve-hook.js';
|
|
3
5
|
import { isReference } from './core/script-function.js';
|
|
4
6
|
/**
|
|
5
7
|
* Every name a `script(fn)` function in `file` (or a file it imports) reads from
|
|
@@ -18,7 +20,7 @@ export function scriptFunctionScope(file) {
|
|
|
18
20
|
noLib: true, types: [], noEmit: true, skipLibCheck: true, allowImportingTsExtensions: true,
|
|
19
21
|
target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.NodeNext, moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
|
20
22
|
};
|
|
21
|
-
const program = ts.createProgram([file], options);
|
|
23
|
+
const program = ts.createProgram([file], options, sdkResolvingHost(ts, options));
|
|
22
24
|
const checker = program.getTypeChecker();
|
|
23
25
|
const cwd = process.cwd();
|
|
24
26
|
const where = (n) => {
|
|
@@ -61,6 +63,25 @@ export function scriptFunctionScope(file) {
|
|
|
61
63
|
}
|
|
62
64
|
return { captures: out, unfollowed, untyped, followed: seen.size, followedTexts };
|
|
63
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* A compiler host that resolves the SDK's own specifiers (the package name and
|
|
68
|
+
* its subpaths) from inside this package, as `sdk-resolve-hook.ts` does at run
|
|
69
|
+
* time. The author's folder may have no `node_modules` (a global install): a
|
|
70
|
+
* plain NodeNext program then cannot find the SDK's declarations, a Case
|
|
71
|
+
* task's `t` is `any`, and `.script(fn)` is not recognised. Package
|
|
72
|
+
* self-reference maps the name to the declarations beside this file. Any other
|
|
73
|
+
* specifier resolves as before.
|
|
74
|
+
*/
|
|
75
|
+
function sdkResolvingHost(ts, options) {
|
|
76
|
+
const host = ts.createCompilerHost(options);
|
|
77
|
+
const self = fileURLToPath(import.meta.url);
|
|
78
|
+
host.resolveModuleNameLiterals = (literals, containingFile, redirected, opts, containing) => literals.map((literal) => {
|
|
79
|
+
const from = isSdkSpecifier(literal.text) ? self : containingFile;
|
|
80
|
+
const mode = ts.getModeForUsageLocation(containing, literal, opts);
|
|
81
|
+
return ts.resolveModuleName(literal.text, from, opts, host, undefined, redirected, mode);
|
|
82
|
+
});
|
|
83
|
+
return host;
|
|
84
|
+
}
|
|
64
85
|
/** A whitespace-free key for comparing function texts. */
|
|
65
86
|
export function functionTextKey(text) {
|
|
66
87
|
return text.replace(/\s+/g, '');
|
|
@@ -136,8 +157,11 @@ export function scriptFunctionCaptureMessage(captures) {
|
|
|
136
157
|
+ 'Move the helper\'s code inside the function, or give it a name the runtime does not have.';
|
|
137
158
|
}
|
|
138
159
|
/**
|
|
139
|
-
* Whether a call is `script(…)` from an import
|
|
140
|
-
* imported under the name `script`, or
|
|
160
|
+
* Whether a call is a script call: Flow's `script(…)` from an import (the
|
|
161
|
+
* callee is an identifier imported under the name `script`, or
|
|
162
|
+
* `<namespace import>.script`), or a Case task's `.script(…)`, a method the
|
|
163
|
+
* checker resolves to the SDK's own `TaskBuilder.script` (`case/case-sdk.ts`),
|
|
164
|
+
* so another library's `script` method is not one.
|
|
141
165
|
*/
|
|
142
166
|
function isScriptCall(ts, checker, call) {
|
|
143
167
|
const callee = call.expression;
|
|
@@ -145,12 +169,26 @@ function isScriptCall(ts, checker, call) {
|
|
|
145
169
|
const decl = checker.getSymbolAtLocation(callee)?.declarations?.[0];
|
|
146
170
|
return decl !== undefined && ts.isImportSpecifier(decl) && (decl.propertyName ?? decl.name).text === 'script';
|
|
147
171
|
}
|
|
148
|
-
if (ts.isPropertyAccessExpression(callee) && callee.name.text === 'script'
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
if (ts.isPropertyAccessExpression(callee) && callee.name.text === 'script') {
|
|
173
|
+
if (ts.isIdentifier(callee.expression)) {
|
|
174
|
+
const decl = checker.getSymbolAtLocation(callee.expression)?.declarations?.[0];
|
|
175
|
+
if (decl !== undefined && ts.isNamespaceImport(decl))
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return isCaseTaskScript(ts, checker, callee);
|
|
151
179
|
}
|
|
152
180
|
return false;
|
|
153
181
|
}
|
|
182
|
+
/** Whether `callee` is the Case `TaskBuilder.script` method, declared in the SDK's `case-sdk` module. */
|
|
183
|
+
function isCaseTaskScript(ts, checker, callee) {
|
|
184
|
+
const decl = checker.getSymbolAtLocation(callee.name)?.declarations?.[0];
|
|
185
|
+
if (!decl || !ts.isMethodDeclaration(decl))
|
|
186
|
+
return false;
|
|
187
|
+
const owner = decl.parent;
|
|
188
|
+
if (!ts.isClassDeclaration(owner) || owner.name?.text !== 'TaskBuilder')
|
|
189
|
+
return false;
|
|
190
|
+
return /(?:^|[\\/])case-sdk\.(?:d\.)?ts$/.test(decl.getSourceFile().fileName);
|
|
191
|
+
}
|
|
154
192
|
/** The function an argument is, or names: inline, a declaration, or a `const` bound to one, through imports. */
|
|
155
193
|
function functionOf(ts, checker, arg) {
|
|
156
194
|
const fnLike = (n) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.82.0",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"@types/node": "^22.7.0",
|
|
104
104
|
"esbuild": "^0.28.1"
|
|
105
105
|
},
|
|
106
|
-
"gitref": "
|
|
106
|
+
"gitref": "5cd8813ad867cef849279dd05ad8b216a618d147"
|
|
107
107
|
}
|