@uipath/maestro-builder-sdk 5.2.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/LICENSE +21 -0
- package/README.md +322 -0
- package/dist/bindings-v2.d.ts +37 -0
- package/dist/bindings-v2.js +155 -0
- package/dist/bindings.d.ts +6 -0
- package/dist/bindings.js +6 -0
- package/dist/bpmn/bpmn-expr-check.d.ts +41 -0
- package/dist/bpmn/bpmn-expr-check.js +218 -0
- package/dist/bpmn/bpmn-sdk.d.ts +2257 -0
- package/dist/bpmn/bpmn-sdk.js +1476 -0
- package/dist/bpmn/check-cli.d.ts +3 -0
- package/dist/bpmn/check-cli.js +32 -0
- package/dist/bpmn/check.d.ts +25 -0
- package/dist/bpmn/check.js +430 -0
- package/dist/bpmn/compile-cli.d.ts +3 -0
- package/dist/bpmn/compile-cli.js +60 -0
- package/dist/bpmn/connector.d.ts +56 -0
- package/dist/bpmn/connector.js +199 -0
- package/dist/bpmn/decompile-cli.d.ts +8 -0
- package/dist/bpmn/decompile-cli.js +54 -0
- package/dist/bpmn/decompile.d.ts +6 -0
- package/dist/bpmn/decompile.js +1108 -0
- package/dist/bpmn/format-profile.d.ts +27 -0
- package/dist/bpmn/format-profile.js +11 -0
- package/dist/bpmn/intsvc.d.ts +77 -0
- package/dist/bpmn/intsvc.js +155 -0
- package/dist/bpmn/load.d.ts +4 -0
- package/dist/bpmn/load.js +22 -0
- package/dist/bpmn/merge-cli.d.ts +3 -0
- package/dist/bpmn/merge-cli.js +45 -0
- package/dist/bpmn/merge.d.ts +19 -0
- package/dist/bpmn/merge.js +293 -0
- package/dist/bpmn/registry-types.json +1869 -0
- package/dist/bpmn/serialize.d.ts +28 -0
- package/dist/bpmn/serialize.js +757 -0
- package/dist/bpmn/tidy-cli.d.ts +2 -0
- package/dist/bpmn/tidy-cli.js +39 -0
- package/dist/bpmn/typed-node.d.ts +382 -0
- package/dist/bpmn/typed-node.js +551 -0
- package/dist/bpmn/uipath-moddle.v1.json +823 -0
- package/dist/bpmn/xml-ranges.d.ts +45 -0
- package/dist/bpmn/xml-ranges.js +151 -0
- package/dist/case/case-expr-check.d.ts +35 -0
- package/dist/case/case-expr-check.js +85 -0
- package/dist/case/case-sdk.d.ts +1282 -0
- package/dist/case/case-sdk.js +923 -0
- package/dist/case/check-cli.d.ts +3 -0
- package/dist/case/check-cli.js +31 -0
- package/dist/case/check.d.ts +18 -0
- package/dist/case/check.js +456 -0
- package/dist/case/compile-cli.d.ts +3 -0
- package/dist/case/compile-cli.js +291 -0
- package/dist/case/decompile-cli.d.ts +9 -0
- package/dist/case/decompile-cli.js +117 -0
- package/dist/case/decompile.d.ts +187 -0
- package/dist/case/decompile.js +1170 -0
- package/dist/case/entry-points.d.ts +79 -0
- package/dist/case/entry-points.js +118 -0
- package/dist/case/format-profile.d.ts +60 -0
- package/dist/case/format-profile.js +79 -0
- package/dist/case/ids.d.ts +24 -0
- package/dist/case/ids.js +76 -0
- package/dist/case/load.d.ts +12 -0
- package/dist/case/load.js +32 -0
- package/dist/case/preserve.d.ts +133 -0
- package/dist/case/preserve.js +105 -0
- package/dist/case/serialize.d.ts +10 -0
- package/dist/case/serialize.js +1414 -0
- package/dist/check-cli.d.ts +3 -0
- package/dist/check-cli.js +118 -0
- package/dist/check.d.ts +146 -0
- package/dist/check.js +4898 -0
- package/dist/cli/commands/bpmn.d.ts +2 -0
- package/dist/cli/commands/bpmn.js +73 -0
- package/dist/cli/commands/case.d.ts +2 -0
- package/dist/cli/commands/case.js +60 -0
- package/dist/cli/commands/flow.d.ts +2 -0
- package/dist/cli/commands/flow.js +99 -0
- package/dist/cli/commands/registry.d.ts +10 -0
- package/dist/cli/commands/registry.js +170 -0
- package/dist/cli/common.d.ts +30 -0
- package/dist/cli/common.js +92 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli-run.d.ts +2 -0
- package/dist/cli-run.js +42 -0
- package/dist/compile-cli.d.ts +3 -0
- package/dist/compile-cli.js +160 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.js +201 -0
- package/dist/core/actions.d.ts +3244 -0
- package/dist/core/actions.js +1062 -0
- package/dist/core/binding-messages.d.ts +1 -0
- package/dist/core/binding-messages.js +16 -0
- package/dist/core/bindings.d.ts +12 -0
- package/dist/core/bindings.js +67 -0
- package/dist/core/ceql.d.ts +73 -0
- package/dist/core/ceql.js +272 -0
- package/dist/core/cli-spelling.d.ts +39 -0
- package/dist/core/cli-spelling.js +62 -0
- package/dist/core/connector-raw-node.d.ts +21 -0
- package/dist/core/connector-raw-node.js +47 -0
- package/dist/core/connectors.d.ts +184 -0
- package/dist/core/connectors.js +128 -0
- package/dist/core/expr-check.d.ts +93 -0
- package/dist/core/expr-check.js +186 -0
- package/dist/core/expr.d.ts +323 -0
- package/dist/core/expr.js +400 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +10 -0
- package/dist/core/library.d.ts +440 -0
- package/dist/core/library.js +1183 -0
- package/dist/core/list-envelope.d.ts +45 -0
- package/dist/core/list-envelope.js +97 -0
- package/dist/core/lookup-store.d.ts +22 -0
- package/dist/core/lookup-store.js +85 -0
- package/dist/core/lookups.d.ts +227 -0
- package/dist/core/lookups.js +231 -0
- package/dist/core/node-classes.d.ts +234 -0
- package/dist/core/node-classes.js +158 -0
- package/dist/core/script-return.d.ts +68 -0
- package/dist/core/script-return.js +197 -0
- package/dist/core/stable-id.d.ts +28 -0
- package/dist/core/stable-id.js +37 -0
- package/dist/core-definitions.json +16249 -0
- package/dist/decompile-cli.d.ts +3 -0
- package/dist/decompile-cli.js +131 -0
- package/dist/decompile.d.ts +138 -0
- package/dist/decompile.js +2482 -0
- package/dist/emit.d.ts +10 -0
- package/dist/emit.js +60 -0
- package/dist/event-filters.d.ts +130 -0
- package/dist/event-filters.js +137 -0
- package/dist/flow-expr-check.d.ts +17 -0
- package/dist/flow-expr-check.js +193 -0
- package/dist/flow-sdk.d.ts +1341 -0
- package/dist/flow-sdk.js +1164 -0
- package/dist/flow-variables.d.ts +13 -0
- package/dist/flow-variables.js +42 -0
- package/dist/format-profile.d.ts +72 -0
- package/dist/format-profile.js +97 -0
- package/dist/generators/_connections.py +287 -0
- package/dist/generators/_events.py +355 -0
- package/dist/generators/_lookups.py +114 -0
- package/dist/generators/_naming.py +185 -0
- package/dist/generators/_objects.py +299 -0
- package/dist/generators/_resolve.py +273 -0
- package/dist/generators/convert_library_to_md.py +1441 -0
- package/dist/generators/extract_library.py +125 -0
- package/dist/generators/generate_connectors_ts.py +936 -0
- package/dist/generators/generate_library_json.py +2527 -0
- package/dist/generators/generate_triggers_ts.py +110 -0
- package/dist/generators/materialize_registry.py +155 -0
- package/dist/generators/prepare_connector.py +1688 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +35 -0
- package/dist/ixp-definition.json +1982 -0
- package/dist/library.d.ts +6 -0
- package/dist/library.js +6 -0
- package/dist/load.d.ts +16 -0
- package/dist/load.js +95 -0
- package/dist/merge-cli.d.ts +3 -0
- package/dist/merge-cli.js +47 -0
- package/dist/merge.d.ts +125 -0
- package/dist/merge.js +0 -0
- package/dist/migrate.d.ts +15 -0
- package/dist/migrate.js +245 -0
- package/dist/node-runtime.d.ts +3 -0
- package/dist/node-runtime.js +22 -0
- package/dist/package-name.d.ts +17 -0
- package/dist/package-name.js +17 -0
- package/dist/ref-resolve.d.ts +77 -0
- package/dist/ref-resolve.js +170 -0
- package/dist/registry/cache.d.ts +55 -0
- package/dist/registry/cache.js +134 -0
- package/dist/registry/curated-overlay.d.ts +16 -0
- package/dist/registry/curated-overlay.js +62 -0
- package/dist/registry/extractor.d.ts +22 -0
- package/dist/registry/extractor.js +18 -0
- package/dist/registry/materialize-bin.d.ts +2 -0
- package/dist/registry/materialize-bin.js +7 -0
- package/dist/registry/materialize-cli.d.ts +1 -0
- package/dist/registry/materialize-cli.js +46 -0
- package/dist/registry/materializer.d.ts +23 -0
- package/dist/registry/materializer.js +34 -0
- package/dist/registry/path-cli.d.ts +1 -0
- package/dist/registry/path-cli.js +56 -0
- package/dist/registry/prepare-cli.d.ts +62 -0
- package/dist/registry/prepare-cli.js +185 -0
- package/dist/registry/pull-cli.d.ts +1 -0
- package/dist/registry/pull-cli.js +274 -0
- package/dist/registry/python.d.ts +26 -0
- package/dist/registry/python.js +46 -0
- package/dist/registry/search-cli.d.ts +52 -0
- package/dist/registry/search-cli.js +159 -0
- package/dist/schema-version.d.ts +165 -0
- package/dist/schema-version.js +148 -0
- package/dist/serialize.d.ts +64 -0
- package/dist/serialize.js +6398 -0
- package/lib/README.md +112 -0
- package/lib/library-json.samples/index.json +158 -0
- package/lib/library-json.samples/invariant-collections.json +83 -0
- package/lib/library-json.samples/list-envelopes.json +123 -0
- package/lib/library-json.samples/uipath-atlassian-jira/create-issue@1.0.0.json +131 -0
- package/lib/library-json.samples/uipath-atlassian-jira/create-issue@1.0.0.v1def.json +306 -0
- package/lib/library-json.samples/uipath-atlassian-jira/generic/create_issue/create@1.0.0.json +86 -0
- package/lib/library-json.samples/uipath-atlassian-jira/generic/create_issue/create@1.0.0.v1def.json +208 -0
- package/lib/library-json.samples/uipath-atlassian-jira/get-issue@1.0.0.json +2040 -0
- package/lib/library-json.samples/uipath-atlassian-jira/get-issue@1.0.0.v1def.json +195 -0
- package/lib/library-json.samples/uipath-google-vertex/execute-google-vertex-agent@1.0.0.json +169 -0
- package/lib/library-json.samples/uipath-google-vertex/execute-google-vertex-agent@1.0.0.v1def.json +209 -0
- package/lib/library-json.samples/uipath-http-webhook/event-http-webhook@1.0.0.json +63 -0
- package/lib/library-json.samples/uipath-http-webhook/event-http-webhook@1.0.0.v1def.json +262 -0
- package/lib/library-json.samples/uipath-http-webhook/trigger-http-webhook@1.0.0.json +63 -0
- package/lib/library-json.samples/uipath-http-webhook/trigger-http-webhook@1.0.0.v1def.json +213 -0
- package/lib/library-json.samples/uipath-microsoft-azureactivedirectory/list-groups@1.0.0.json +227 -0
- package/lib/library-json.samples/uipath-microsoft-azureactivedirectory/list-groups@1.0.0.v1def.json +373 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-file-created@1.0.0.json +116 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-file-created@1.0.0.v1def.json +369 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-list-item-added@1.0.0.json +56 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/event-list-item-added@1.0.0.v1def.json +256 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-file-created@1.0.0.json +116 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-file-created@1.0.0.v1def.json +320 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-list-item-added@1.0.0.json +56 -0
- package/lib/library-json.samples/uipath-microsoft-onedrive/trigger-list-item-added@1.0.0.v1def.json +207 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/event-email-received@1.0.0.json +107 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/event-email-received@1.0.0.v1def.json +264 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/send-email@1.0.0.json +142 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/send-email@1.0.0.v1def.json +306 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/trigger-email-received@1.0.0.json +107 -0
- package/lib/library-json.samples/uipath-microsoft-outlook365/trigger-email-received@1.0.0.v1def.json +217 -0
- package/lib/library-json.samples/uipath-microsoft-powerautomate/invoke-a-microsoft-power-automate-flow@1.0.0.json +85 -0
- package/lib/library-json.samples/uipath-microsoft-powerautomate/invoke-a-microsoft-power-automate-flow@1.0.0.v1def.json +209 -0
- package/lib/library-json.samples/uipath-salesforce-slack/send-message-to-user@1.0.0.json +755 -0
- package/lib/library-json.samples/uipath-salesforce-slack/send-message-to-user@1.0.0.v1def.json +513 -0
- package/lib/library-json.samples/uipath-uipath-dataservice/query-entity-records@1.0.0.json +122 -0
- package/lib/library-json.samples/uipath-uipath-dataservice/query-entity-records@1.0.0.v1def.json +227 -0
- package/package.json +85 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* decompile-cli — <original>.flow → <Name>.flow.ts (bin `flow-decompile`)
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* flow-decompile <original.flow> [-o Name.flow.ts] [--import <specifier>] [--strict]
|
|
7
|
+
*
|
|
8
|
+
* The reverse of compile-cli: reads a `.flow` JSON and emits Flow SDK builder
|
|
9
|
+
* source whose default export re-serializes to the same graph (same node ids,
|
|
10
|
+
* same logical edges). `--import` sets the module specifier of the emitted
|
|
11
|
+
* `import { flow, … }` line (default the published package) so the file resolves
|
|
12
|
+
* wherever you place it. `--strict` turns off best-effort mode, so an
|
|
13
|
+
* unsupported construct is a hard error instead of a `// TODO` marker.
|
|
14
|
+
*
|
|
15
|
+
* Besides the `.flow.ts`, this also emits a per-flow pipeline wrapper
|
|
16
|
+
* (`<Name>.pipeline.mjs`) that chains decompile → [edit] → compile → merge, so an
|
|
17
|
+
* agent can run one script for the whole brownfield write-back loop. Pass
|
|
18
|
+
* `--no-pipeline` to skip it.
|
|
19
|
+
*/
|
|
20
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { basename, resolve } from 'node:path';
|
|
22
|
+
import { decompile } from './decompile.js';
|
|
23
|
+
import { resolveFlowRefs } from './ref-resolve.js';
|
|
24
|
+
import { runWhenInvokedDirectly } from './cli-run.js';
|
|
25
|
+
import { PACKAGE_NAME } from './package-name.js';
|
|
26
|
+
function opt(argv, name) {
|
|
27
|
+
const i = argv.indexOf(name);
|
|
28
|
+
return i >= 0 ? argv[i + 1] : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** Derive a PascalCase base name from the flow name/id for the default output file. */
|
|
31
|
+
function baseName(flow) {
|
|
32
|
+
const src = flow.name ?? flow.id ?? 'Flow';
|
|
33
|
+
const pascal = src
|
|
34
|
+
.split(/[^A-Za-z0-9]+/)
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.map((w) => w[0].toUpperCase() + w.slice(1))
|
|
37
|
+
.join('');
|
|
38
|
+
return pascal || 'Flow';
|
|
39
|
+
}
|
|
40
|
+
export function run(argv) {
|
|
41
|
+
if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
|
|
42
|
+
console.error('usage: flow-decompile <original.flow> [-o Name.flow.ts] [--import <specifier>] [--strict]');
|
|
43
|
+
return 2;
|
|
44
|
+
}
|
|
45
|
+
const flags = new Set(['-o', '--import']);
|
|
46
|
+
const pos = argv.find((a, i) => !flags.has(a) && !flags.has(argv[i - 1]) && !a.startsWith('--'));
|
|
47
|
+
if (!pos) {
|
|
48
|
+
console.error('flow-decompile: missing <original.flow>');
|
|
49
|
+
return 2;
|
|
50
|
+
}
|
|
51
|
+
// A `.flow` may be SPLIT across sibling files with JSON Reference — resolve
|
|
52
|
+
// those into one object model before decompiling (design §5; the format's own
|
|
53
|
+
// read path does the same). A single-file flow walks through untouched.
|
|
54
|
+
const flow = resolveFlowRefs(JSON.parse(readFileSync(pos, 'utf8')), {
|
|
55
|
+
baseUri: pos,
|
|
56
|
+
read: (path) => readFileSync(path, 'utf8'),
|
|
57
|
+
});
|
|
58
|
+
const ts = decompile(flow, {
|
|
59
|
+
importSpecifier: opt(argv, '--import') ?? PACKAGE_NAME,
|
|
60
|
+
bestEffort: !argv.includes('--strict'),
|
|
61
|
+
// Findings the source cannot carry on its own (a node no trigger reaches, a
|
|
62
|
+
// pinned core version this SDK lacks, a file-format version outside the
|
|
63
|
+
// writable band) go to stderr, where the agent running the brownfield loop
|
|
64
|
+
// reads them before compile refuses.
|
|
65
|
+
warn: (message) => console.error(`flow-decompile: warning: ${message}`),
|
|
66
|
+
});
|
|
67
|
+
const out = opt(argv, '-o') ?? `${baseName(flow)}.flow.ts`;
|
|
68
|
+
writeFileSync(out, ts);
|
|
69
|
+
console.log(`flow-decompile: wrote ${basename(out)}`);
|
|
70
|
+
if (!argv.includes('--no-pipeline')) {
|
|
71
|
+
const pipelinePath = out.replace(/\.flow\.ts$|\.ts$/, '') + '.pipeline.mjs';
|
|
72
|
+
writeFileSync(pipelinePath, pipelineScript(resolve(pos), resolve(out)));
|
|
73
|
+
console.log(`flow-decompile: wrote ${basename(pipelinePath)}`);
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A per-flow wrapper that runs the whole brownfield write-back loop with one
|
|
79
|
+
* command. First run: decompile the original into `<Name>.flow.ts` and capture a
|
|
80
|
+
* baseline. You then EDIT `<Name>.flow.ts`. Re-run: it compiles your edits and
|
|
81
|
+
* merges them back into the original, producing `<Name>.merged.flow`. It shells
|
|
82
|
+
* out through the public `uip maestro flow` authoring commands. Until a UiPath
|
|
83
|
+
* CLI carrying those preview commands is installed, it falls back to the SDK's
|
|
84
|
+
* retained `flow-sdk` bin from this workspace.
|
|
85
|
+
*/
|
|
86
|
+
function pipelineScript(originalPath, tsPath) {
|
|
87
|
+
const base = tsPath.replace(/\.flow\.ts$|\.ts$/, '');
|
|
88
|
+
return `#!/usr/bin/env node
|
|
89
|
+
// Generated by flow-decompile — the brownfield read/modify/write pipeline for
|
|
90
|
+
// ${basename(originalPath)}. Run it, edit ${basename(tsPath)}, run it again.
|
|
91
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
92
|
+
import { existsSync } from 'node:fs';
|
|
93
|
+
|
|
94
|
+
const ORIGINAL = ${JSON.stringify(originalPath)};
|
|
95
|
+
const TS = ${JSON.stringify(tsPath)};
|
|
96
|
+
const BASELINE = ${JSON.stringify(base + '.baseline.flow')};
|
|
97
|
+
const EDITED = ${JSON.stringify(base + '.edited.flow')};
|
|
98
|
+
const MERGED = ${JSON.stringify(base + '.merged.flow')};
|
|
99
|
+
|
|
100
|
+
const uipProbe = spawnSync('uip', ['maestro', 'flow', 'compile', '--help'], { stdio: 'ignore' });
|
|
101
|
+
const frontDoor = !uipProbe.error && uipProbe.status === 0
|
|
102
|
+
? { file: 'uip', prefix: ['maestro', 'flow'] }
|
|
103
|
+
: { file: 'npx', prefix: ['--no-install', 'flow-sdk', 'flow'] };
|
|
104
|
+
const run = (verb, args) =>
|
|
105
|
+
execFileSync(frontDoor.file, [...frontDoor.prefix, verb, ...args], { stdio: 'inherit' });
|
|
106
|
+
|
|
107
|
+
// Ensure the decompiled source exists (a fresh clone may have only the .flow).
|
|
108
|
+
if (!existsSync(TS)) run('decompile', [ORIGINAL, '-o', TS, '--no-pipeline']);
|
|
109
|
+
|
|
110
|
+
if (!existsSync(BASELINE)) {
|
|
111
|
+
// ── Step 1: capture the baseline = compile of the PRISTINE decompiled code,
|
|
112
|
+
// BEFORE any edit. Run this once right after decompiling, then edit. ──
|
|
113
|
+
run('compile', [TS, '-o', BASELINE, '--no-check']);
|
|
114
|
+
console.log('\\n>>> Baseline captured. Now EDIT ' + ${JSON.stringify(basename(tsPath))} + ', then re-run this script to compile + merge.');
|
|
115
|
+
} else {
|
|
116
|
+
// ── Step 2: compile your edits, then merge them back into the original. ──
|
|
117
|
+
run('compile', [TS, '-o', EDITED, '--no-check']);
|
|
118
|
+
|
|
119
|
+
// ── DIFF GATE (seam) ──────────────────────────────────────────────────────
|
|
120
|
+
// A future step can diff ORIGINAL vs the about-to-be-written MERGED here and
|
|
121
|
+
// ask for confirmation before the write. Left as a no-op for now.
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
const args = [ORIGINAL, EDITED, '-o', MERGED];
|
|
125
|
+
if (existsSync(BASELINE)) args.push('--baseline', BASELINE);
|
|
126
|
+
run('merge', args);
|
|
127
|
+
console.log('\\n>>> Wrote ' + ${JSON.stringify(base + '.merged.flow')});
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
130
|
+
}
|
|
131
|
+
runWhenInvokedDirectly(import.meta.url, 'flow-decompile', run);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* decompile — the reverse of `serialize.ts`: turn a real UiPath `.flow` JSON
|
|
3
|
+
* back into Flow SDK builder source (`.flow.ts`) that, when re-compiled,
|
|
4
|
+
* serializes to the **same** graph (same node ids, same logical edges).
|
|
5
|
+
*
|
|
6
|
+
* Unlike the case decompiler (`case/decompile.ts`), a flow is a directed GRAPH
|
|
7
|
+
* (`nodes[]` + `edges[]` with `sourcePort`/`targetPort`), not a hierarchy, and
|
|
8
|
+
* the builder is structured (`.branch()` / `.switch()` / `.loop()` /
|
|
9
|
+
* `.parallel()` / `.onError()` / `.return()`). Decompiling therefore means
|
|
10
|
+
* reconstructing structured control flow from the graph — the inverse of
|
|
11
|
+
* serialize's `emit()` walker. This module is built in layers:
|
|
12
|
+
*
|
|
13
|
+
* - Phase 1 (here): the linear core — header, variables, trigger, and a
|
|
14
|
+
* straight-line chain of action steps ending in `.return()` / `.terminate()`.
|
|
15
|
+
* - Phase 2: the full node reverse-map (http / transform / connectors / hitl /
|
|
16
|
+
* agents / queue / …) and connector reverse-lookup.
|
|
17
|
+
* - Phase 3: control-flow reconstruction (branch / switch / loop / parallel /
|
|
18
|
+
* onError / stepToRef / subflow) via graph analysis.
|
|
19
|
+
*
|
|
20
|
+
* The linchpin is **node-id stability**: serialize derives each node id from the
|
|
21
|
+
* author's step NAME (`claimId`: `[^A-Za-z0-9_]→_`, then de-dup `base`/`base2`/…),
|
|
22
|
+
* so if we name every step with its original node id, serialize reproduces
|
|
23
|
+
* byte-identical ids. A happy consequence: serialize's `renameRefs`
|
|
24
|
+
* (`$vars.<stepName>`→`$vars.<nodeId>`) becomes the identity, so expression
|
|
25
|
+
* references need no un-renaming.
|
|
26
|
+
*
|
|
27
|
+
* The round-trip is **semantically** lossless, not byte-for-byte: layout,
|
|
28
|
+
* display labels on plain steps, and formatting are not preserved (layout is
|
|
29
|
+
* re-attached by `flow-merge`; see `docs/FLOW_PARITY.md`).
|
|
30
|
+
*/
|
|
31
|
+
import { type FlowGlobalDeclaration } from './flow-variables.js';
|
|
32
|
+
/** An expression envelope as written by `migrate.ts` (`{type,expression,fieldType}`). */
|
|
33
|
+
interface WrappedSource {
|
|
34
|
+
type: string;
|
|
35
|
+
expression: string;
|
|
36
|
+
fieldType?: string;
|
|
37
|
+
}
|
|
38
|
+
/** A node output descriptor (`node.outputs[name]`). */
|
|
39
|
+
interface OutputDesc {
|
|
40
|
+
type?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
source?: string | WrappedSource;
|
|
43
|
+
var?: string;
|
|
44
|
+
}
|
|
45
|
+
/** A canvas point, as persisted in an edge route. */
|
|
46
|
+
interface UiPoint {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
id?: string;
|
|
50
|
+
}
|
|
51
|
+
/** One node's designer layout, as persisted on `node.ui` or in `layout.nodes`. */
|
|
52
|
+
interface NodeUi {
|
|
53
|
+
position?: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
size?: {
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
};
|
|
61
|
+
collapsed?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** One edge's route, as persisted on `edge.ui` or in `layout.edges`. */
|
|
64
|
+
interface EdgeUi {
|
|
65
|
+
waypoints?: UiPoint[];
|
|
66
|
+
routedWaypoints?: UiPoint[];
|
|
67
|
+
}
|
|
68
|
+
interface FlowNode {
|
|
69
|
+
id: string;
|
|
70
|
+
type: string;
|
|
71
|
+
typeVersion?: string;
|
|
72
|
+
parentId?: string;
|
|
73
|
+
inputs?: Record<string, unknown>;
|
|
74
|
+
outputs?: Record<string, OutputDesc>;
|
|
75
|
+
display?: {
|
|
76
|
+
label?: string;
|
|
77
|
+
icon?: string;
|
|
78
|
+
};
|
|
79
|
+
model?: unknown;
|
|
80
|
+
ui?: NodeUi;
|
|
81
|
+
}
|
|
82
|
+
interface FlowEdge {
|
|
83
|
+
id?: string;
|
|
84
|
+
sourceNodeId: string;
|
|
85
|
+
sourcePort: string;
|
|
86
|
+
targetNodeId: string;
|
|
87
|
+
targetPort: string;
|
|
88
|
+
ui?: EdgeUi;
|
|
89
|
+
}
|
|
90
|
+
type Global = FlowGlobalDeclaration;
|
|
91
|
+
interface VariableUpdate {
|
|
92
|
+
variableId: string;
|
|
93
|
+
expression: string | WrappedSource;
|
|
94
|
+
}
|
|
95
|
+
interface FlowVariables {
|
|
96
|
+
globals?: Global[];
|
|
97
|
+
nodes?: unknown[];
|
|
98
|
+
variableUpdates?: Record<string, VariableUpdate[]>;
|
|
99
|
+
[name: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
interface FlowFile {
|
|
102
|
+
id?: string;
|
|
103
|
+
name?: string;
|
|
104
|
+
version?: string;
|
|
105
|
+
definitions?: Array<{
|
|
106
|
+
nodeType?: string;
|
|
107
|
+
version?: string;
|
|
108
|
+
}>;
|
|
109
|
+
nodes?: FlowNode[];
|
|
110
|
+
edges?: FlowEdge[];
|
|
111
|
+
variables?: FlowVariables;
|
|
112
|
+
subflows?: Record<string, FlowFile>;
|
|
113
|
+
layout?: {
|
|
114
|
+
nodes?: Record<string, NodeUi>;
|
|
115
|
+
edges?: Record<string, EdgeUi>;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export interface DecompileOptions {
|
|
119
|
+
/** Module specifier for the `import { flow, … } from …` line. Default `./flow-sdk.js`. */
|
|
120
|
+
importSpecifier?: string;
|
|
121
|
+
/**
|
|
122
|
+
* When true (the default), a node type the reverse-map does not yet handle is
|
|
123
|
+
* emitted as a `mock()` placeholder carrying a `// TODO` marker rather than
|
|
124
|
+
* throwing — so a validating flow always produces usable code. Set false to
|
|
125
|
+
* make an unsupported construct a hard error instead.
|
|
126
|
+
*/
|
|
127
|
+
bestEffort?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Receives each non-fatal finding about the file, one message per finding:
|
|
130
|
+
* a node no trigger reaches (the builder cannot express a detached node, so
|
|
131
|
+
* the source omits it — strict mode throws instead), and a core
|
|
132
|
+
* `(type, typeVersion)` pair this SDK does not bundle (the source keeps it;
|
|
133
|
+
* `compile` will refuse it). The CLI prints these on stderr.
|
|
134
|
+
*/
|
|
135
|
+
warn?: (message: string) => void;
|
|
136
|
+
}
|
|
137
|
+
export declare function decompile(flow: FlowFile, options?: DecompileOptions): string;
|
|
138
|
+
export {};
|