@uipath/maestro-builder-sdk 6.59.0 → 6.60.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.
@@ -1,9 +1,41 @@
1
1
  /**
2
- * What a Flow script body can read: the language's ES2020 built-ins, `console`,
3
- * and the runtime's `$vars`. From the Flow skill's `references/script.md` ("The
4
- * JavaScript runtime"), which also lists what reads `undefined` in a real run and
5
- * is therefore absent here: `Intl`, `URL`, `TextEncoder`, `Buffer`, `fetch`,
6
- * `require`, `structuredClone`. Change this when the runtime changes.
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
+ ]);
21
+ /**
22
+ * What a Flow script body can read: the language's ES2020 built-ins, the
23
+ * globals the engine registers, `console`, and the runtime's `$vars`.
24
+ *
25
+ * Measured against UiPath/PO.BpmnEngine, which runs a script body with
26
+ * Jint 4.4.0 (`ScriptTaskService.InvokeScriptAsync`,
27
+ * `src/BpmnEngine/UiPath.PO.Worker/Services/ElementExecution/Script/ScriptTaskService.cs`):
28
+ * the body goes to `Engine.Evaluate` as a script, after `btoa`/`atob` (UTF-8),
29
+ * `randomUUID` and `crypto` (holding only `randomUUID`) are set
30
+ * (`src/BpmnEngine/UiPath.PO.BpmnEngine/Expressions/JavaScriptEvaluator.cs`) and
31
+ * two preludes declare {@link FLOW_SCRIPT_CONST_GLOBALS} with `const`. `Intl`,
32
+ * `URL`, `TextEncoder`, `Buffer`, `fetch`, `require` and `structuredClone` read
33
+ * `undefined` there, so they are absent here. Change this when the engine does.
34
+ *
35
+ * `aggregate`, `_aggregate`, `_pipe` and `uipath` exist but are the engine's
36
+ * undocumented helpers, so a script function may not read them; it may not
37
+ * redeclare or assign them either (`constGlobals`). Of `crypto` and `console`
38
+ * it may read only the members the engine's have (`globalMembers`).
7
39
  *
8
40
  * Annex B's `escape`/`unescape` are left off on purpose: they URL-encode, and
9
41
  * `escape` is the likeliest name for an author's own HTML-escape helper, which
@@ -15,8 +47,11 @@
15
47
  export const FLOW_SCRIPT_RUNTIME = {
16
48
  scopeGlobal: '$vars',
17
49
  name: 'the Flow script runtime',
50
+ constGlobals: FLOW_SCRIPT_CONST_GLOBALS,
51
+ globalMembers: FLOW_SCRIPT_GLOBAL_MEMBERS,
18
52
  globals: new Set([
19
53
  'undefined', 'NaN', 'Infinity', 'globalThis', 'console',
54
+ 'btoa', 'atob', 'randomUUID', 'crypto',
20
55
  'Object', 'Function', 'Array', 'Number', 'Boolean', 'String', 'Symbol', 'BigInt', 'Date', 'RegExp', 'Math', 'JSON',
21
56
  'Promise', 'Proxy', 'Reflect', 'Map', 'Set', 'WeakMap', 'WeakSet',
22
57
  'Error', 'EvalError', 'RangeError', 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The globals the Flow script runtime gives a script body beyond the language,
3
+ * as types, for a `.flow.ts` that type-checks its script functions.
4
+ *
5
+ * Opt in from the file that uses them:
6
+ *
7
+ * ```ts
8
+ * /// <reference types="@uipath/maestro-builder-sdk/script-globals" />
9
+ * ```
10
+ *
11
+ * Types only. A script function is never called in Node; its body runs on the
12
+ * engine, which provides these names (UiPath/PO.BpmnEngine,
13
+ * `src/BpmnEngine/UiPath.PO.BpmnEngine/Expressions/JavaScriptEvaluator.cs`).
14
+ * Importing an implementation instead would not work: `compile` refuses a script
15
+ * function that reads a name from its module.
16
+ *
17
+ * Opt-in rather than part of the package entry, so importing the SDK does not
18
+ * add globals to every program that does.
19
+ *
20
+ * `btoa` and `atob` repeat the signatures `@types/node` and the DOM library
21
+ * declare, so they merge with either; they are here for a program that has
22
+ * neither. Note the engine's are UTF-8, where Node's and the browser's are
23
+ * Latin-1 and throw on a character above U+00FF. `crypto` is not declared:
24
+ * the engine's holds only `randomUUID`, and both of those libraries already
25
+ * type `crypto.randomUUID()`.
26
+ */
27
+ export {};
28
+ declare global {
29
+ /** A fresh lowercase, hyphenated v4 UUID. The engine also exposes it as `crypto.randomUUID`. */
30
+ function randomUUID(): string;
31
+ /** Base64 of a string's UTF-8 bytes, in the engine (Node's and the browser's take Latin-1). */
32
+ function btoa(data: string): string;
33
+ /** The string whose UTF-8 bytes a Base64 string encodes, in the engine. */
34
+ function atob(data: string): string;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.59.0",
3
+ "version": "6.60.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",
@@ -37,6 +37,10 @@
37
37
  "types": "./dist/cli/index.d.ts",
38
38
  "import": "./dist/cli/index.js"
39
39
  },
40
+ "./script-globals": {
41
+ "types": "./dist/script-globals.d.ts",
42
+ "import": "./dist/script-globals.js"
43
+ },
40
44
  "./registry-materializer": {
41
45
  "types": "./dist/registry/materializer.d.ts",
42
46
  "import": "./dist/registry/materializer.js"
@@ -96,5 +100,5 @@
96
100
  "@types/node": "^22.7.0",
97
101
  "esbuild": "^0.28.1"
98
102
  },
99
- "gitref": "ddebc637dab91373bb326fd4da5590f6e7d3b9c2"
103
+ "gitref": "d9059695caec0a3b1f3b215f5b830451dbdbdad9"
100
104
  }