@uipath/maestro-builder-sdk 6.95.6 → 6.96.1

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.
@@ -32,24 +32,42 @@ export declare function compileDraftTolerant(built: BuiltFlow, opts?: Omit<Seria
32
32
  export declare function compileSourceDraftTolerant(file: string, opts?: Omit<SerializeOpts, 'draft' | 'collect'>): Promise<DraftTolerantCompile & {
33
33
  built: BuiltFlow;
34
34
  }>;
35
+ /**
36
+ * How the original is decompiled for the baseline: `flow decompile`'s options. A
37
+ * stamped source records them (decompile-stamp.ts); without a stamp, the defaults.
38
+ */
39
+ export interface OriginalDecompileOptions {
40
+ /** As `flow decompile --scripts` (default `function`). */
41
+ scripts?: 'function' | 'string';
42
+ /** As `flow decompile --strict`. */
43
+ strict?: boolean;
44
+ }
35
45
  /**
36
46
  * The baseline of `originalPath`: decompile it (reading agent sidecars beside
37
47
  * it, as `flow decompile` does), then compile the source with draft tolerance,
38
- * in collect mode ({@link compileDraftTolerant}).
48
+ * in collect mode ({@link compileDraftTolerant}). `source` is the decompiled
49
+ * text, for the stamp check.
39
50
  * The source goes to a temporary directory that is removed afterwards.
40
51
  */
41
- export declare function baselineFromOriginal(originalPath: string, opts?: Omit<SerializeOpts, 'draft' | 'collect'>, warn?: (message: string) => void): Promise<DraftTolerantCompile & {
52
+ export declare function baselineFromOriginal(originalPath: string, opts?: Omit<SerializeOpts, 'draft' | 'collect'>, warn?: (message: string) => void, decompileOpts?: OriginalDecompileOptions): Promise<DraftTolerantCompile & {
42
53
  built: BuiltFlow;
54
+ source: string;
43
55
  }>;
44
56
  /**
45
- * Decompile the `.flow` at `originalPath` (reading agent sidecars beside it, as
46
- * `flow decompile` does), load the source, and hand the built flow to `use`
47
- * while the source is still on disk. `flow merge --baseline-from` compiles it
57
+ * The source `flow decompile` makes of the `.flow` at `path` with `opts`, the SDK
58
+ * imported by its package name: what a stamp's digest is taken of.
59
+ */
60
+ export declare function decompileOriginal(path: string, opts?: OriginalDecompileOptions, warn?: (message: string) => void): string;
61
+ /**
62
+ * Decompile the `.flow` at `originalPath` as `flow decompile` does
63
+ * ({@link decompileOriginal}), load the source, and hand the built flow and the
64
+ * source text to `use` while the source is still on disk. `flow merge
65
+ * --baseline-from` and the source form of merge compile it
48
66
  * ({@link baselineFromOriginal}); `flow check --baseline` checks it. The source
49
67
  * goes to a temporary directory that is removed afterwards. The caller has
50
68
  * already called `ensureTypeScriptRuntime()`.
51
69
  */
52
- export declare function withDecompiledOriginal<T>(originalPath: string, use: (built: BuiltFlow) => T | Promise<T>, warn?: (message: string) => void): Promise<T>;
70
+ export declare function withDecompiledOriginal<T>(originalPath: string, use: (built: BuiltFlow, source: string) => T | Promise<T>, warn?: (message: string) => void, decompileOpts?: OriginalDecompileOptions): Promise<T>;
53
71
  /**
54
72
  * Run `check()` on the edited source, as `compile` does, and place each
55
73
  * diagnostic on its node ({@link placeDiagnostics}). The `check()` call stays
@@ -10,10 +10,10 @@
10
10
  * these compiles produce is written to disk. Which nodes count as edited, and
11
11
  * how each finding is sorted, is edit-scope.ts's.
12
12
  */
13
- import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
13
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
14
14
  import { tmpdir } from 'node:os';
15
15
  import { dirname, join, resolve } from 'node:path';
16
- import { decompile } from './decompile.js';
16
+ import { decompileFlowFile, readFlowFile } from './decompile-file.js';
17
17
  import { loadBuiltFlow } from './load.js';
18
18
  import { serialize } from './serialize.js';
19
19
  import { CompileRefusal } from './core/compile-refusal.js';
@@ -51,38 +51,40 @@ export async function compileSourceDraftTolerant(file, opts = {}) {
51
51
  /**
52
52
  * The baseline of `originalPath`: decompile it (reading agent sidecars beside
53
53
  * it, as `flow decompile` does), then compile the source with draft tolerance,
54
- * in collect mode ({@link compileDraftTolerant}).
54
+ * in collect mode ({@link compileDraftTolerant}). `source` is the decompiled
55
+ * text, for the stamp check.
55
56
  * The source goes to a temporary directory that is removed afterwards.
56
57
  */
57
- export async function baselineFromOriginal(originalPath, opts = {}, warn) {
58
+ export async function baselineFromOriginal(originalPath, opts = {}, warn, decompileOpts = {}) {
58
59
  // The baseline reproduces the original, so a connection label it carries stays
59
60
  // as written: resolving it through the project's bindings.json would make a
60
61
  // label-to-id edit identical to the baseline and merge would drop it.
61
62
  const asSaved = { ...opts, bindings: new Bindings() };
62
- return withDecompiledOriginal(originalPath, (built) => ({ ...compileDraftTolerant(built, asSaved), built }), warn);
63
+ return withDecompiledOriginal(originalPath, (built, source) => ({ ...compileDraftTolerant(built, asSaved), built, source }), warn, decompileOpts);
63
64
  }
64
65
  /**
65
- * Decompile the `.flow` at `originalPath` (reading agent sidecars beside it, as
66
- * `flow decompile` does), load the source, and hand the built flow to `use`
67
- * while the source is still on disk. `flow merge --baseline-from` compiles it
68
- * ({@link baselineFromOriginal}); `flow check --baseline` checks it. The source
69
- * goes to a temporary directory that is removed afterwards. The caller has
70
- * already called `ensureTypeScriptRuntime()`.
66
+ * The source `flow decompile` makes of the `.flow` at `path` with `opts`, the SDK
67
+ * imported by its package name: what a stamp's digest is taken of.
71
68
  */
72
- export async function withDecompiledOriginal(originalPath, use, warn) {
73
- const original = JSON.parse(readFileSync(originalPath, 'utf8'));
74
- const source = decompile(original, {
69
+ export function decompileOriginal(path, opts = {}, warn) {
70
+ return decompileFlowFile(path, readFlowFile(path), {
75
71
  importSpecifier: PACKAGE_NAME,
72
+ bestEffort: opts.strict !== true,
73
+ scripts: opts.scripts ?? 'function',
76
74
  warn,
77
- readSidecar: (relativePath) => {
78
- try {
79
- return readFileSync(join(dirname(resolve(originalPath)), relativePath), 'utf8');
80
- }
81
- catch {
82
- return undefined;
83
- }
84
- },
85
75
  });
76
+ }
77
+ /**
78
+ * Decompile the `.flow` at `originalPath` as `flow decompile` does
79
+ * ({@link decompileOriginal}), load the source, and hand the built flow and the
80
+ * source text to `use` while the source is still on disk. `flow merge
81
+ * --baseline-from` and the source form of merge compile it
82
+ * ({@link baselineFromOriginal}); `flow check --baseline` checks it. The source
83
+ * goes to a temporary directory that is removed afterwards. The caller has
84
+ * already called `ensureTypeScriptRuntime()`.
85
+ */
86
+ export async function withDecompiledOriginal(originalPath, use, warn, decompileOpts = {}) {
87
+ const source = decompileOriginal(originalPath, decompileOpts, warn);
86
88
  // Beside the original, not in the system temp dir: the decompiled source imports
87
89
  // the SDK, which `useThisSdkForAuthoredSource` resolves from anywhere, and any
88
90
  // NODE-TYPE PACKAGE the original was written with, which Node resolves only by
@@ -93,7 +95,7 @@ export async function withDecompiledOriginal(originalPath, use, warn) {
93
95
  writeFileSync(join(dir, 'package.json'), '{"type":"module"}\n');
94
96
  const file = join(dir, 'Baseline.flow.ts');
95
97
  writeFileSync(file, source);
96
- return await use(await loadBuiltFlow(file));
98
+ return await use(await loadBuiltFlow(file), source);
97
99
  }
98
100
  finally {
99
101
  rmSync(dir, { recursive: true, force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.95.6",
3
+ "version": "6.96.1",
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",
@@ -75,7 +75,8 @@
75
75
  "prepare-action-option",
76
76
  "json-result",
77
77
  "prepare-resource",
78
- "bpmn-merge-source"
78
+ "bpmn-merge-source",
79
+ "flow-merge-source"
79
80
  ],
80
81
  "files": [
81
82
  "dist",
@@ -112,5 +113,5 @@
112
113
  "@types/node": "^22.7.0",
113
114
  "esbuild": "^0.28.1"
114
115
  },
115
- "gitref": "a338c75fc5efff55716b4e8aaac369d24a770950"
116
+ "gitref": "8e43949aa536978e4bba34b4441dda320958a195"
116
117
  }