@uipath/maestro-builder-sdk 6.87.0 → 6.87.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.
@@ -35,6 +35,7 @@ export function registerBpmnCommands(program) {
35
35
  .option('--bindings <file>', 'bindings.json path')
36
36
  .addOption(retiredCompiledOption())
37
37
  .option('--resources <file>', 'resource ledger that registry prepare writes (default .flow-sdk/resources.json)')
38
+ .option('--no-types', 'skip the TypeScript type check of the source')
38
39
  .action(async (input, options) => {
39
40
  let mode;
40
41
  try {
@@ -51,6 +52,8 @@ export function registerBpmnCommands(program) {
51
52
  const argv = [input];
52
53
  if (options.graph)
53
54
  argv.push('--graph');
55
+ if (options.types === false)
56
+ argv.push('--no-types');
54
57
  addValue(argv, '--library', options.library);
55
58
  addValue(argv, '--connectors-local', options.connectorsLocal);
56
59
  addValue(argv, '--bindings', options.bindings);
package/dist/decompile.js CHANGED
@@ -2936,7 +2936,9 @@ function canonicalJson(v) {
2936
2936
  * a script body, a decision or switch `expression`, a loop's `condition` and
2937
2937
  * `completionCondition`, an HTTP branch's `conditionExpression`, a transform's
2938
2938
  * `collection`. `serialize` renames `$vars` reads in exactly these and in
2939
- * `=js:` values.
2939
+ * `=js:` values. A loop's `completionCondition` is listed for files written
2940
+ * before #1763: the SDK now writes it as a jsExpression envelope, because the
2941
+ * runtime ignores the bare string.
2940
2942
  */
2941
2943
  const RAW_JS_FIELDS = new Set(['script', 'expression', 'condition', 'completionCondition', 'conditionExpression', 'collection']);
2942
2944
  /**
@@ -34,6 +34,68 @@ function liftPageRange(node) {
34
34
  const p = node.inputs?.pageRange;
35
35
  return typeof p === 'string' && p !== '' ? p : undefined;
36
36
  }
37
+ /**
38
+ * An object input of the node when it differs from the definition's default for
39
+ * it, as the lift keeps it: the designer writes the default on every node, and
40
+ * an author who leaves the field out gets that default back from serialize.
41
+ * Absent: undefined. Present but not a plain object (an expression such as
42
+ * `=js:vars.taxonomy`): reported as lossy, since the option takes an object only.
43
+ */
44
+ function liftObjectInput(node, key, ctx) {
45
+ const value = node.inputs?.[key];
46
+ if (value === undefined)
47
+ return undefined;
48
+ const raw = ctx.plainValue(value);
49
+ // sourceText is defined for a string and for an expression envelope.
50
+ const text = ctx.sourceText(raw);
51
+ if (text !== undefined || raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
52
+ ctx.lossy(classifyLoss(ctx, key, `is ${JSON.stringify(text ?? raw)}, not an object`));
53
+ return undefined;
54
+ }
55
+ const fallback = ctx.definition()?.inputDefaults?.[key];
56
+ return JSON.stringify(raw) === JSON.stringify(fallback) ? undefined : raw;
57
+ }
58
+ function classifyLoss(ctx, key, what) {
59
+ return `classify step ${JSON.stringify(ctx.nodeId)}: ${key} ${what}, which documentClassify() cannot express, `
60
+ + `so compile writes the definition's default instead.`;
61
+ }
62
+ const SCHEMA_KEYS = new Set(['generalInstructions', 'classes']);
63
+ const CLASS_KEYS = new Set(['id', 'name', 'instructions']);
64
+ const optionalString = (v) => v === undefined || typeof v === 'string';
65
+ /** Why a lifted `classificationSchema` does not fit {@link ClassificationSchema}; undefined when it does. */
66
+ function classificationSchemaMismatch(raw) {
67
+ const extra = Object.keys(raw).filter((k) => !SCHEMA_KEYS.has(k));
68
+ if (extra.length > 0)
69
+ return `has key(s) ${extra.join(', ')}`;
70
+ if (!optionalString(raw.generalInstructions))
71
+ return 'has a generalInstructions that is not a string';
72
+ if (!Array.isArray(raw.classes))
73
+ return 'has no classes array';
74
+ for (const [i, c] of raw.classes.entries()) {
75
+ if (c === null || typeof c !== 'object' || Array.isArray(c))
76
+ return `has a classes[${i}] that is not an object`;
77
+ const cls = c;
78
+ const extraC = Object.keys(cls).filter((k) => !CLASS_KEYS.has(k));
79
+ if (extraC.length > 0)
80
+ return `has classes[${i}] key(s) ${extraC.join(', ')}`;
81
+ if (typeof cls.id !== 'string' || typeof cls.name !== 'string' || !optionalString(cls.instructions)) {
82
+ return `has a classes[${i}] whose id, name or instructions is not a string`;
83
+ }
84
+ }
85
+ return undefined;
86
+ }
87
+ /** `classificationSchema` as the lift keeps it: only a value that type-checks as {@link ClassificationSchema}. */
88
+ function liftClassificationSchema(node, ctx) {
89
+ const raw = liftObjectInput(node, 'classificationSchema', ctx);
90
+ if (raw === undefined)
91
+ return undefined;
92
+ const mismatch = classificationSchemaMismatch(raw);
93
+ if (mismatch !== undefined) {
94
+ ctx.lossy(classifyLoss(ctx, 'classificationSchema', mismatch));
95
+ return undefined;
96
+ }
97
+ return raw;
98
+ }
37
99
  export const documentClassifyNodeType = {
38
100
  kind: 'documentClassify', typeName: 'uipath.document.classify', version: '1.0', factory: 'documentClassify',
39
101
  definition: 'bundled', rawNode: { factory: 'documentClassify()' },
@@ -50,18 +112,23 @@ export const documentClassifyNodeType = {
50
112
  ...(inputs.modelConfig !== undefined
51
113
  ? { modelConfig: { ...(d.modelConfig ?? {}), ...inputs.modelConfig } }
52
114
  : {}),
115
+ ...(inputs.classificationSchema !== undefined ? { classificationSchema: jsonClone(inputs.classificationSchema) } : {}),
53
116
  },
54
117
  };
55
118
  },
56
119
  deserialize: (node, ctx) => {
57
120
  const pageRange = liftPageRange(node);
58
121
  const split = ctx.plainValue(node.inputs?.splitPages);
122
+ const modelConfig = liftObjectInput(node, 'modelConfig', ctx);
123
+ const classificationSchema = liftClassificationSchema(node, ctx);
59
124
  return {
60
125
  kind: 'documentClassify',
61
126
  inputs: {
62
127
  fileRef: liftFileRef(node, ctx),
63
128
  ...(pageRange !== undefined ? { pageRange } : {}),
64
129
  ...(split === true ? { splitPages: true } : {}),
130
+ ...(modelConfig !== undefined ? { modelConfig } : {}),
131
+ ...(classificationSchema !== undefined ? { classificationSchema } : {}),
65
132
  },
66
133
  };
67
134
  },
@@ -71,6 +138,8 @@ export const documentClassifyNodeType = {
71
138
  ['fileRef', ctx.value(inputs.fileRef)],
72
139
  ['pageRange', inputs.pageRange !== undefined ? ctx.string(inputs.pageRange) : undefined],
73
140
  ['splitPages', inputs.splitPages === true ? 'true' : undefined],
141
+ ['modelConfig', inputs.modelConfig !== undefined ? ctx.json(inputs.modelConfig) : undefined],
142
+ ['classificationSchema', inputs.classificationSchema !== undefined ? ctx.json(inputs.classificationSchema) : undefined],
74
143
  ],
75
144
  }),
76
145
  check: ({ inputs }, ctx) => checkFileRef(inputs, 'classify', ctx),
@@ -17,6 +17,41 @@ export interface DocumentClassifyInputs {
17
17
  splitPages?: boolean;
18
18
  /** Model configuration overrides; omit for the platform defaults (gemini_2_5_flash). */
19
19
  modelConfig?: Record<string, unknown>;
20
+ /**
21
+ * The document types to classify into (the node's taxonomy), as the
22
+ * designer's Classes editor writes it. Omit for the definition's default.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * documentClassify({
27
+ * fileRef: input('file'),
28
+ * classificationSchema: {
29
+ * generalInstructions: 'Classify supplier paperwork.',
30
+ * classes: [
31
+ * { id: 'c1', name: 'invoice', instructions: 'A bill asking for payment.' },
32
+ * { id: 'c2', name: 'receipt', instructions: 'Proof that a payment was made.' },
33
+ * ],
34
+ * },
35
+ * })
36
+ * ```
37
+ */
38
+ classificationSchema?: ClassificationSchema;
39
+ }
40
+ /** The taxonomy of a `documentClassify()` step: what the classifier chooses between. */
41
+ export interface ClassificationSchema {
42
+ /** Instructions that apply to every class. */
43
+ generalInstructions?: string;
44
+ /** One entry per document type, in the order the designer lists them. */
45
+ classes: ClassificationClass[];
46
+ }
47
+ /** One document type in a {@link ClassificationSchema}. */
48
+ export interface ClassificationClass {
49
+ /** The class's id, unique in the schema (the designer mints a UUID). */
50
+ id: string;
51
+ /** The document type's name, which the classifier answers with, e.g. `'invoice'`. */
52
+ name: string;
53
+ /** What makes a document this type. */
54
+ instructions?: string;
20
55
  }
21
56
  /** What `dynamicExtract()` takes: the document and the fields to extract from it. */
22
57
  export interface DynamicExtractInputs {
@@ -1,3 +1,31 @@
1
+ /**
2
+ * script-function-scope — the names a `script(fn)` function takes from its module.
3
+ *
4
+ * `script(fn)` lowers a function from its `toString()` alone (core/script-function.ts),
5
+ * so it cannot see the module the function was written in. A free name off the
6
+ * runtime's list is refused there; one ON the list is accepted, because the
7
+ * runtime has a global of that name. If the author's module also declares or
8
+ * imports that name, the author's code calls the module's binding while the
9
+ * lowered body calls the runtime's: a helper named `escape` that HTML-escapes,
10
+ * or lodash's `escape`, becomes the Annex B global that URL-encodes. Nothing
11
+ * else notices: `check` and `validate` both pass.
12
+ *
13
+ * This pass closes that where the module IS visible: the CLIs that load a
14
+ * `.flow.ts` (compile, check, merge) have its path. It builds a program over the
15
+ * source, finds each `script(<function>)` call, follows the argument to its
16
+ * declaration (through imports between the author's files), and reports every
17
+ * name in the function that resolves to a binding outside it — a module
18
+ * declaration, an import, or an enclosing function's local. The lowering already
19
+ * refused such a name when it is off the runtime's list, so in practice this
20
+ * reports the collisions.
21
+ *
22
+ * The `script` call is recognised by its imported name, not by resolving the
23
+ * SDK package, because the CLI may supply the SDK from somewhere the source's
24
+ * own resolution cannot see (`sdk-resolve.ts`). A call through a re-exporting
25
+ * helper module is not recognised. A host that has no source file (the SDK run
26
+ * in a page) does not get this pass.
27
+ */
28
+ import type * as TS from 'typescript';
1
29
  /** One name a script function reads from outside itself. */
2
30
  export interface ScriptFunctionCapture {
3
31
  /** How the call is named in messages: `script(renderSafe)`. */
@@ -42,6 +70,16 @@ export interface ScriptFunctionScope {
42
70
  * options passed by name) is the string form and is not a script function.
43
71
  */
44
72
  export declare function scriptFunctionScope(file: string): ScriptFunctionScope;
73
+ /**
74
+ * A compiler host that resolves the SDK's own specifiers (the package name and
75
+ * its subpaths) from inside this package, as `sdk-resolve-hook.ts` does at run
76
+ * time. The author's folder may have no `node_modules` (a global install): a
77
+ * plain NodeNext program then cannot find the SDK's declarations, a Case
78
+ * task's `t` is `any`, and `.script(fn)` is not recognised. Package
79
+ * self-reference maps the name to the declarations beside this file. Any other
80
+ * specifier resolves as before.
81
+ */
82
+ export declare function sdkResolvingHost(ts: typeof TS, options: TS.CompilerOptions): TS.CompilerHost;
45
83
  /** A whitespace-free key for comparing function texts. */
46
84
  export declare function functionTextKey(text: string): string;
47
85
  /**
@@ -72,7 +72,7 @@ export function scriptFunctionScope(file) {
72
72
  * self-reference maps the name to the declarations beside this file. Any other
73
73
  * specifier resolves as before.
74
74
  */
75
- function sdkResolvingHost(ts, options) {
75
+ export function sdkResolvingHost(ts, options) {
76
76
  const host = ts.createCompilerHost(options);
77
77
  const self = fileURLToPath(import.meta.url);
78
78
  host.resolveModuleNameLiterals = (literals, containingFile, redirected, opts, containing) => literals.map((literal) => {
package/dist/serialize.js CHANGED
@@ -3254,7 +3254,8 @@ function serializeFlow(built, opts) {
3254
3254
  collection: renderValue(step.collection, scope.rename),
3255
3255
  parallel: o.parallel ?? false,
3256
3256
  ...(o.completionCondition !== undefined && (v24 || 'completionCondition' in declared)
3257
- ? { completionCondition: renameRefs(o.completionCondition.js, scope.rename) }
3257
+ // =js: so migrate writes the envelope; a bare string reaches the BPMN condition as text and never fires (#1763).
3258
+ ? { completionCondition: '=js:' + renameRefs(o.completionCondition.js, scope.rename) }
3258
3259
  : {}),
3259
3260
  ...(v24 || 'breakEnabled' in declared ? { breakEnabled: (o.breakEnabled ?? false) || usesBreak } : {}),
3260
3261
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.87.0",
3
+ "version": "6.87.2",
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",
@@ -110,5 +110,5 @@
110
110
  "@types/node": "^22.7.0",
111
111
  "esbuild": "^0.28.1"
112
112
  },
113
- "gitref": "a1d69f012ec03f34c177c6b1d358b21d5ea2b09c"
113
+ "gitref": "bac06e6a74bed3582399978cf4180a49d9946def"
114
114
  }