@salesforce/metadata-plugins 1.4.0 → 1.5.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/README.md +30 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/plugins/flow/FlowParser.d.ts +36 -0
- package/dist/plugins/flow/FlowParser.d.ts.map +1 -0
- package/dist/plugins/flow/FlowParser.js +240 -0
- package/dist/plugins/flow/FlowVisualizer.d.ts +28 -0
- package/dist/plugins/flow/FlowVisualizer.d.ts.map +1 -0
- package/dist/plugins/flow/FlowVisualizer.js +36 -0
- package/dist/plugins/flow/parser/details.d.ts +33 -0
- package/dist/plugins/flow/parser/details.d.ts.map +1 -0
- package/dist/plugins/flow/parser/details.js +353 -0
- package/dist/plugins/flow/parser/edges.d.ts +53 -0
- package/dist/plugins/flow/parser/edges.d.ts.map +1 -0
- package/dist/plugins/flow/parser/edges.js +197 -0
- package/dist/plugins/flow/parser/elementTypes.d.ts +47 -0
- package/dist/plugins/flow/parser/elementTypes.d.ts.map +1 -0
- package/dist/plugins/flow/parser/elementTypes.js +176 -0
- package/dist/plugins/flow/parser/flowLabels.d.ts +43 -0
- package/dist/plugins/flow/parser/flowLabels.d.ts.map +1 -0
- package/dist/plugins/flow/parser/flowLabels.js +42 -0
- package/dist/plugins/flow/parser/groups.d.ts +26 -0
- package/dist/plugins/flow/parser/groups.d.ts.map +1 -0
- package/dist/plugins/flow/parser/groups.js +56 -0
- package/dist/plugins/flow/parser/nodes.d.ts +25 -0
- package/dist/plugins/flow/parser/nodes.d.ts.map +1 -0
- package/dist/plugins/flow/parser/nodes.js +86 -0
- package/dist/plugins/flow/parser/resources.d.ts +21 -0
- package/dist/plugins/flow/parser/resources.d.ts.map +1 -0
- package/dist/plugins/flow/parser/resources.js +140 -0
- package/dist/plugins/flow/parser/startConfig.d.ts +29 -0
- package/dist/plugins/flow/parser/startConfig.d.ts.map +1 -0
- package/dist/plugins/flow/parser/startConfig.js +117 -0
- package/dist/plugins/flow/parser/xmlPrimitives.d.ts +53 -0
- package/dist/plugins/flow/parser/xmlPrimitives.d.ts.map +1 -0
- package/dist/plugins/flow/parser/xmlPrimitives.js +152 -0
- package/dist/plugins/flow/types/FlowData.d.ts +294 -0
- package/dist/plugins/flow/types/FlowData.d.ts.map +1 -0
- package/dist/plugins/flow/types/FlowData.js +7 -0
- package/dist/plugins/flow/ui/assets/index-Cb-x8fUq.css +1 -0
- package/dist/plugins/flow/ui/assets/index-DDfQ7eDI.js +48 -0
- package/dist/plugins/flow/ui/index.html +14 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ This package provides metadata visualization plugins that parse Salesforce XML m
|
|
|
15
15
|
| ------------- | ------------------------------------- | ----------- | ------------------------------------------------------------------- |
|
|
16
16
|
| FlexiPages | `.flexipage-meta.xml` | `flexipage` | Lightning Page layout visualization |
|
|
17
17
|
| Data Model | `.object-meta.xml`, `.field-meta.xml` | `schema` | Interactive ERD visualization of objects, fields, and relationships |
|
|
18
|
+
| Agent Script | `.agent` | `agent` | Agent script visualization |
|
|
19
|
+
| Flow | `.flow-meta.xml` | `flow` | Interactive Flow diagram with decisions, loops, and fault paths |
|
|
18
20
|
|
|
19
21
|
## Installation
|
|
20
22
|
|
|
@@ -54,10 +56,17 @@ const plugins = getAllVisualizers(config);
|
|
|
54
56
|
### Using Individual Plugins
|
|
55
57
|
|
|
56
58
|
```typescript
|
|
57
|
-
import {
|
|
59
|
+
import {
|
|
60
|
+
FlexipageVisualizer,
|
|
61
|
+
SchemaVisualizer,
|
|
62
|
+
AgentVisualizer,
|
|
63
|
+
FlowVisualizer,
|
|
64
|
+
} from '@salesforce/metadata-plugins';
|
|
58
65
|
|
|
59
66
|
const flexipageViz = new FlexipageVisualizer();
|
|
60
67
|
const schemaViz = new SchemaVisualizer();
|
|
68
|
+
const agentViz = new AgentVisualizer();
|
|
69
|
+
const flowViz = new FlowVisualizer();
|
|
61
70
|
|
|
62
71
|
// Check plugin metadata
|
|
63
72
|
const info = schemaViz.getMetadataPluginInfo();
|
|
@@ -75,16 +84,22 @@ console.log(info.filePatterns); // ['.object-meta.xml', '.field-meta.xml']
|
|
|
75
84
|
|
|
76
85
|
- **`FlexipageVisualizer`** — Implements `IVisualizationPlugin<FlexipageMetadata>` for Lightning Page metadata
|
|
77
86
|
- **`SchemaVisualizer`** — Implements `IVisualizationPlugin<SchemaERDData>` for Custom Object and Field metadata
|
|
87
|
+
- **`AgentVisualizer`** — Implements `IVisualizationPlugin<AgentScriptData>` for Agent script metadata
|
|
88
|
+
- **`FlowVisualizer`** — Implements `IVisualizationPlugin<FlowModel>` for Flow metadata
|
|
78
89
|
|
|
79
90
|
### Parsers
|
|
80
91
|
|
|
81
92
|
- **`FlexipageParser`** — Implements `IMetadataParser<FlexipageMetadata>`
|
|
82
93
|
- **`SchemaParser`** — Implements `IMetadataParser<SchemaERDData>`
|
|
94
|
+
- **`AgentParser`** — Implements `IMetadataParser<AgentScriptData>`
|
|
95
|
+
- **`FlowParser`** — Implements `IMetadataParser<FlowModel>`
|
|
83
96
|
|
|
84
97
|
### Types
|
|
85
98
|
|
|
86
99
|
- **`FlexipageMetadata`** — Parsed FlexiPage structure
|
|
87
100
|
- **`SchemaERDData`** — Parsed ERD data with objects, fields, and relationships
|
|
101
|
+
- **`AgentScriptData`** — Parsed Agent script structure
|
|
102
|
+
- **`FlowModel`** — Parsed Flow structure with nodes, connectors, and metadata
|
|
88
103
|
|
|
89
104
|
## Package Exports
|
|
90
105
|
|
|
@@ -93,14 +108,26 @@ console.log(info.filePatterns); // ['.object-meta.xml', '.field-meta.xml']
|
|
|
93
108
|
import {
|
|
94
109
|
FlexipageVisualizer,
|
|
95
110
|
SchemaVisualizer,
|
|
111
|
+
AgentVisualizer,
|
|
112
|
+
FlowVisualizer,
|
|
96
113
|
getAllVisualizers,
|
|
97
114
|
} from '@salesforce/metadata-plugins';
|
|
98
115
|
|
|
99
116
|
// Parsers
|
|
100
|
-
import {
|
|
117
|
+
import {
|
|
118
|
+
FlexipageParser,
|
|
119
|
+
SchemaParser,
|
|
120
|
+
AgentParser,
|
|
121
|
+
FlowParser,
|
|
122
|
+
} from '@salesforce/metadata-plugins';
|
|
101
123
|
|
|
102
124
|
// Types
|
|
103
|
-
import type {
|
|
125
|
+
import type {
|
|
126
|
+
FlexipageMetadata,
|
|
127
|
+
SchemaERDData,
|
|
128
|
+
AgentScriptData,
|
|
129
|
+
FlowModel,
|
|
130
|
+
} from '@salesforce/metadata-plugins';
|
|
104
131
|
```
|
|
105
132
|
|
|
106
133
|
## Creating a New Plugin
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
export { FlexipageVisualizer } from './plugins/flexipage/FlexipageVisualizer.js';
|
|
8
8
|
export { SchemaVisualizer } from './plugins/schema/SchemaVisualizer.js';
|
|
9
9
|
export { AgentVisualizer } from './plugins/agent/AgentVisualizer.js';
|
|
10
|
+
export { FlowVisualizer } from './plugins/flow/FlowVisualizer.js';
|
|
10
11
|
export { FlexipageParser } from './plugins/flexipage/FlexipageParser.js';
|
|
11
12
|
export { SchemaParser } from './plugins/schema/SchemaParser.js';
|
|
12
13
|
export { AgentParser } from './plugins/agent/AgentParser.js';
|
|
14
|
+
export { FlowParser } from './plugins/flow/FlowParser.js';
|
|
13
15
|
export type { FlexipageMetadata } from './plugins/flexipage/types/FlexipageMetadata.js';
|
|
14
16
|
export type { SchemaERDData } from './plugins/schema/types/SchemaERDData.js';
|
|
15
17
|
export type { AgentScriptData } from './plugins/agent/types/AgentScriptData.js';
|
|
18
|
+
export type { FlowModel } from './plugins/flow/types/FlowData.js';
|
|
16
19
|
import { IVisualizationPlugin, PluginConfig } from '@salesforce/metadata-core-sdk';
|
|
17
20
|
/**
|
|
18
21
|
* Get all visualization plugins
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAoBJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACxF,YAAY,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC7E,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAChF,YAAY,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEnF;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,oBAAoB,EAAE,CAiB/E"}
|
package/dist/index.js
CHANGED
|
@@ -18,14 +18,17 @@
|
|
|
18
18
|
import { FlexipageVisualizer } from './plugins/flexipage/FlexipageVisualizer.js';
|
|
19
19
|
import { SchemaVisualizer } from './plugins/schema/SchemaVisualizer.js';
|
|
20
20
|
import { AgentVisualizer } from './plugins/agent/AgentVisualizer.js';
|
|
21
|
+
import { FlowVisualizer } from './plugins/flow/FlowVisualizer.js';
|
|
21
22
|
// Export visualization plugins
|
|
22
23
|
export { FlexipageVisualizer } from './plugins/flexipage/FlexipageVisualizer.js';
|
|
23
24
|
export { SchemaVisualizer } from './plugins/schema/SchemaVisualizer.js';
|
|
24
25
|
export { AgentVisualizer } from './plugins/agent/AgentVisualizer.js';
|
|
26
|
+
export { FlowVisualizer } from './plugins/flow/FlowVisualizer.js';
|
|
25
27
|
// Export parsers
|
|
26
28
|
export { FlexipageParser } from './plugins/flexipage/FlexipageParser.js';
|
|
27
29
|
export { SchemaParser } from './plugins/schema/SchemaParser.js';
|
|
28
30
|
export { AgentParser } from './plugins/agent/AgentParser.js';
|
|
31
|
+
export { FlowParser } from './plugins/flow/FlowParser.js';
|
|
29
32
|
/**
|
|
30
33
|
* Get all visualization plugins
|
|
31
34
|
*
|
|
@@ -41,6 +44,7 @@ export function getAllVisualizers(config) {
|
|
|
41
44
|
new FlexipageVisualizer(),
|
|
42
45
|
new SchemaVisualizer(),
|
|
43
46
|
new AgentVisualizer(),
|
|
47
|
+
new FlowVisualizer(),
|
|
44
48
|
];
|
|
45
49
|
if (!config?.pluginSettings) {
|
|
46
50
|
return all;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Flow metadata parser.
|
|
9
|
+
*
|
|
10
|
+
* Reads a `.flow-meta.xml` source through the platform file system and builds a
|
|
11
|
+
* `FlowModel` — synthetic Start/End bookends, one node per element, branch-aware
|
|
12
|
+
* connectors (decision outcomes, loop branches, wait events, fault paths),
|
|
13
|
+
* categorized Toolbox resources, Start configuration, and 264 canvas groups.
|
|
14
|
+
* Layout/collapse are the renderer's concern; this stays a pure XML → model map.
|
|
15
|
+
*/
|
|
16
|
+
import { IMetadataParser, IPlatformContext, MetadataFileInfo, VersionInfo } from '@salesforce/metadata-core-sdk';
|
|
17
|
+
import { FlowModel } from './types/FlowData.js';
|
|
18
|
+
export declare class FlowParser implements IMetadataParser<FlowModel> {
|
|
19
|
+
private context?;
|
|
20
|
+
private logger?;
|
|
21
|
+
private telemetry?;
|
|
22
|
+
setPlatformContext(context: IPlatformContext): void;
|
|
23
|
+
parse(filePath: string, versionInfo: VersionInfo): Promise<FlowModel>;
|
|
24
|
+
validate(_data: FlowModel): {
|
|
25
|
+
valid: boolean;
|
|
26
|
+
errors: never[];
|
|
27
|
+
warnings: never[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Derive the Flow's display label from already-parsed data. The parser puts
|
|
31
|
+
* the source `<label>` (falling back to `<fullName>`/filename) into
|
|
32
|
+
* `data.label`, so we can return it without re-reading the file.
|
|
33
|
+
*/
|
|
34
|
+
extractMetadataInfo(data: FlowModel): MetadataFileInfo | null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=FlowParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/flow/FlowParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;GAQG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAGhB,gBAAgB,EAEhB,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAIL,SAAS,EAGV,MAAM,qBAAqB,CAAC;AAuB7B,qBAAa,UAAW,YAAW,eAAe,CAAC,SAAS,CAAC;IAC3D,OAAO,CAAC,OAAO,CAAC,CAAmB;IACnC,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,SAAS,CAAC,CAAa;IAE/B,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAM7C,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAuF3E,QAAQ,CAAC,KAAK,EAAE,SAAS;;;;;IAOzB;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,gBAAgB,GAAG,IAAI;CAI9D"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Flow metadata parser.
|
|
9
|
+
*
|
|
10
|
+
* Reads a `.flow-meta.xml` source through the platform file system and builds a
|
|
11
|
+
* `FlowModel` — synthetic Start/End bookends, one node per element, branch-aware
|
|
12
|
+
* connectors (decision outcomes, loop branches, wait events, fault paths),
|
|
13
|
+
* categorized Toolbox resources, Start configuration, and 264 canvas groups.
|
|
14
|
+
* Layout/collapse are the renderer's concern; this stays a pure XML → model map.
|
|
15
|
+
*/
|
|
16
|
+
import { SalesforceXMLParser, ErrorBuilder, ErrorCategory, } from '@salesforce/metadata-core-sdk';
|
|
17
|
+
import { isPluginError } from '../../shared/utils/isPluginError.js';
|
|
18
|
+
import { FLOW_END, FLOW_START } from './parser/flowLabels.js';
|
|
19
|
+
import { arr, bool, num, str } from './parser/xmlPrimitives.js';
|
|
20
|
+
import { collectGroups } from './parser/groups.js';
|
|
21
|
+
import { collectResources } from './parser/resources.js';
|
|
22
|
+
import { readCanvasMode, readStartConfig, startDetails } from './parser/startConfig.js';
|
|
23
|
+
import { collectNodes } from './parser/nodes.js';
|
|
24
|
+
import { EdgeBuilder, wireElementEdges, wireStartEdges } from './parser/edges.js';
|
|
25
|
+
const START_ID = FLOW_START;
|
|
26
|
+
const END_ID = FLOW_END;
|
|
27
|
+
/**
|
|
28
|
+
* Extract basename from a file path without importing Node's `path` module.
|
|
29
|
+
* The basename is retained for local error `context` (host-side error chrome
|
|
30
|
+
* shows it to the user) but is intentionally NEVER shipped in a telemetry
|
|
31
|
+
* event — `.flow-meta.xml` filenames are customer-authored and can reveal
|
|
32
|
+
* product / feature names.
|
|
33
|
+
*/
|
|
34
|
+
function basename(filePath) {
|
|
35
|
+
return filePath.split(/[\\/]/).pop() ?? filePath;
|
|
36
|
+
}
|
|
37
|
+
export class FlowParser {
|
|
38
|
+
setPlatformContext(context) {
|
|
39
|
+
this.context = context;
|
|
40
|
+
this.logger = context.logger.createChild('FlowParser');
|
|
41
|
+
this.telemetry = context.telemetry.createChild({ component: 'FlowParser' });
|
|
42
|
+
}
|
|
43
|
+
async parse(filePath, versionInfo) {
|
|
44
|
+
const fileName = basename(filePath);
|
|
45
|
+
if (!this.context) {
|
|
46
|
+
throw ErrorBuilder.create()
|
|
47
|
+
.category(ErrorCategory.Configuration)
|
|
48
|
+
.message('FlowParser is not initialized with platform context')
|
|
49
|
+
.context({ fileName })
|
|
50
|
+
.build();
|
|
51
|
+
}
|
|
52
|
+
const ctx = this.context;
|
|
53
|
+
const log = this.logger ?? ctx.logger.createChild('FlowParser');
|
|
54
|
+
const telemetry = this.telemetry ?? ctx.telemetry.createChild({ component: 'FlowParser' });
|
|
55
|
+
return telemetry.withSpan('flow.parse', async (span) => {
|
|
56
|
+
try {
|
|
57
|
+
const read = await ctx.fileSystem.readFile(filePath);
|
|
58
|
+
if (!read.success || typeof read.data !== 'string') {
|
|
59
|
+
throw ErrorBuilder.create()
|
|
60
|
+
.category(ErrorCategory.Dependency)
|
|
61
|
+
.message(`Failed to read flow file: ${read.error?.message ?? fileName}`)
|
|
62
|
+
.context({ fileName })
|
|
63
|
+
.build();
|
|
64
|
+
}
|
|
65
|
+
span.setAttribute('sourceLength', String(read.data.length));
|
|
66
|
+
const model = buildModel(read.data, filePath, versionInfo ?? {});
|
|
67
|
+
const nodeCount = model.nodes.length;
|
|
68
|
+
const edgeCount = model.edges.length;
|
|
69
|
+
const decisionCount = model.metadata.decisionCount;
|
|
70
|
+
const elementCount = model.nodes.filter((n) => n.kind !== 'start' && n.kind !== 'end').length;
|
|
71
|
+
// Shape metrics for the completed parse. Counts only — no
|
|
72
|
+
// customer-authored labels or ids ever land in telemetry.
|
|
73
|
+
span.setAttribute('nodeCount', String(nodeCount));
|
|
74
|
+
span.setAttribute('edgeCount', String(edgeCount));
|
|
75
|
+
span.setAttribute('decisionCount', String(decisionCount));
|
|
76
|
+
// Parse reliability: a flow that only produced a Start node is
|
|
77
|
+
// legitimate for ApprovalWorkflow etc., but worth tracking so a
|
|
78
|
+
// regression in the element extractor doesn't hide behind that
|
|
79
|
+
// exception. `reason` is a fixed low-cardinality string.
|
|
80
|
+
if (elementCount === 0) {
|
|
81
|
+
telemetry.sendEvent('flow.parse_incomplete', { pluginId: 'flow', reason: 'no_elements' }, { nodeCount, edgeCount });
|
|
82
|
+
log.warn(`Flow parse produced no authored elements (nodes=${nodeCount}, edges=${edgeCount})`);
|
|
83
|
+
}
|
|
84
|
+
telemetry.sendEvent('flow.parse_complete', { pluginId: 'flow' }, { nodeCount, edgeCount, decisionCount, elementCount });
|
|
85
|
+
log.info(`Parsed flow (nodes=${nodeCount}, edges=${edgeCount}, decisions=${decisionCount})`);
|
|
86
|
+
return model;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (isPluginError(error)) {
|
|
90
|
+
telemetry.sendEvent('flow.parse_error', { pluginId: 'flow' }, {});
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
telemetry.sendEvent('flow.parse_error', { pluginId: 'flow' }, {});
|
|
94
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
95
|
+
throw ErrorBuilder.create()
|
|
96
|
+
.category(ErrorCategory.Parsing)
|
|
97
|
+
.message(message)
|
|
98
|
+
.context({ fileName })
|
|
99
|
+
.build();
|
|
100
|
+
}
|
|
101
|
+
}, { pluginId: 'flow' });
|
|
102
|
+
}
|
|
103
|
+
validate(_data) {
|
|
104
|
+
// A flow with only a Start node is legitimate — e.g. ApprovalWorkflow
|
|
105
|
+
// process types carry their logic in approval metadata rather than flow
|
|
106
|
+
// elements. Render whatever we have; the canvas handles the Start-only case.
|
|
107
|
+
return { valid: true, errors: [], warnings: [] };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Derive the Flow's display label from already-parsed data. The parser puts
|
|
111
|
+
* the source `<label>` (falling back to `<fullName>`/filename) into
|
|
112
|
+
* `data.label`, so we can return it without re-reading the file.
|
|
113
|
+
*/
|
|
114
|
+
extractMetadataInfo(data) {
|
|
115
|
+
const label = typeof data.label === 'string' ? data.label.trim() : '';
|
|
116
|
+
return label ? { label } : null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function buildModel(source, filePath, versionInfo) {
|
|
120
|
+
const parser = new SalesforceXMLParser();
|
|
121
|
+
const parsed = parser.parse(source);
|
|
122
|
+
if (!parsed.Flow || typeof parsed.Flow !== 'object') {
|
|
123
|
+
throw ErrorBuilder.create()
|
|
124
|
+
.category(ErrorCategory.Parsing)
|
|
125
|
+
.message('Invalid flow file: missing <Flow> root element')
|
|
126
|
+
.context({ fileName: basename(filePath) })
|
|
127
|
+
.build();
|
|
128
|
+
}
|
|
129
|
+
const flow = parsed.Flow;
|
|
130
|
+
// The flow's display name, used as the Start node's title (Flow Builder shows
|
|
131
|
+
// the flow name on the Start element, not the literal words "Flow Start").
|
|
132
|
+
const flowLabel = str(flow.label) ?? (filePath.split('/').pop() ?? 'Flow').replace(/\.flow-meta\.xml$/, '');
|
|
133
|
+
// First pass: one node per authored element. Reserve Start/End so mintable
|
|
134
|
+
// end nodes never collide with real element ids.
|
|
135
|
+
const { nodes, knownIds, sawCoordinates } = collectNodes(flow, [START_ID, END_ID]);
|
|
136
|
+
// Synthetic Start bookend, anchored to the flow's <start> coords when present.
|
|
137
|
+
const startEl = flow.start;
|
|
138
|
+
const startConfig = readStartConfig(startEl);
|
|
139
|
+
nodes.unshift({
|
|
140
|
+
id: START_ID,
|
|
141
|
+
kind: 'start',
|
|
142
|
+
label: flowLabel,
|
|
143
|
+
typeLabel: 'Start',
|
|
144
|
+
metaTypeLabel: 'Start',
|
|
145
|
+
details: startDetails(str(flow.processType), startConfig),
|
|
146
|
+
autoLabel: false,
|
|
147
|
+
locationX: num(startEl?.locationX),
|
|
148
|
+
locationY: num(startEl?.locationY),
|
|
149
|
+
});
|
|
150
|
+
// Second + third passes: element connectors, then Start fan-out. EdgeBuilder
|
|
151
|
+
// owns per-branch End node minting so terminal branches don't collide.
|
|
152
|
+
const builder = new EdgeBuilder(knownIds, nodes, END_ID);
|
|
153
|
+
wireElementEdges(flow, builder);
|
|
154
|
+
wireStartEdges(flow, nodes, builder, START_ID);
|
|
155
|
+
const edges = builder.edges;
|
|
156
|
+
const variables = arr(flow.variables)
|
|
157
|
+
.map((v) => v)
|
|
158
|
+
.filter((v) => str(v.name))
|
|
159
|
+
.map((v) => ({
|
|
160
|
+
name: str(v.name),
|
|
161
|
+
dataType: str(v.dataType) ?? 'String',
|
|
162
|
+
isCollection: bool(v.isCollection),
|
|
163
|
+
isInput: bool(v.isInput),
|
|
164
|
+
isOutput: bool(v.isOutput),
|
|
165
|
+
}));
|
|
166
|
+
const formulas = arr(flow.formulas)
|
|
167
|
+
.map((f) => f)
|
|
168
|
+
.filter((f) => str(f.name))
|
|
169
|
+
.map((f) => ({
|
|
170
|
+
name: str(f.name),
|
|
171
|
+
dataType: str(f.dataType),
|
|
172
|
+
expression: str(f.expression),
|
|
173
|
+
}));
|
|
174
|
+
const constants = arr(flow.constants)
|
|
175
|
+
.map((c) => c)
|
|
176
|
+
.filter((c) => str(c.name))
|
|
177
|
+
.map((c) => ({
|
|
178
|
+
name: str(c.name),
|
|
179
|
+
dataType: str(c.dataType),
|
|
180
|
+
value: str(c.value),
|
|
181
|
+
}));
|
|
182
|
+
const choices = [
|
|
183
|
+
...arr(flow.choices)
|
|
184
|
+
.map((c) => c)
|
|
185
|
+
.filter((c) => str(c.name))
|
|
186
|
+
.map((c) => ({ name: str(c.name), dataType: str(c.dataType), kind: 'choice' })),
|
|
187
|
+
...arr(flow.dynamicChoiceSets)
|
|
188
|
+
.map((c) => c)
|
|
189
|
+
.filter((c) => str(c.name))
|
|
190
|
+
.map((c) => ({ name: str(c.name), dataType: str(c.dataType), kind: 'dynamic' })),
|
|
191
|
+
];
|
|
192
|
+
const textTemplates = arr(flow.textTemplates)
|
|
193
|
+
.map((t) => t)
|
|
194
|
+
.filter((t) => str(t.name))
|
|
195
|
+
.map((t) => ({
|
|
196
|
+
name: str(t.name),
|
|
197
|
+
detail: bool(t.isViewedAsPlainText) ? 'Plain text' : 'Rich text',
|
|
198
|
+
}));
|
|
199
|
+
// Canvas stages (Flow Orchestrator, with `<stageSteps>`) surface as nodes on
|
|
200
|
+
// the diagram; only the resource-only variant (classic <stages>) belongs in
|
|
201
|
+
// the Toolbox stage list.
|
|
202
|
+
const stages = arr(flow.stages)
|
|
203
|
+
.map((s) => s)
|
|
204
|
+
.filter((s) => str(s.name) && !arr(s.stageSteps).length)
|
|
205
|
+
.map((s) => ({ name: str(s.name), detail: str(s.label) }));
|
|
206
|
+
// Groups: gated `ALC_GENERIC_GROUP` (GA 264). The upstream metadata tag isn't
|
|
207
|
+
// finalized, so read from candidate containers and also back-fill membership
|
|
208
|
+
// from each element's own group pointer (readGroupId).
|
|
209
|
+
const groups = collectGroups(flow, nodes);
|
|
210
|
+
// Toolbox resources, categorized + synthesized the way Flow Builder does.
|
|
211
|
+
const resources = collectResources(flow, formulas, constants, choices, textTemplates, stages);
|
|
212
|
+
return {
|
|
213
|
+
flowName: (filePath.split('/').pop() ?? 'Flow').replace(/\.flow-meta\.xml$/, ''),
|
|
214
|
+
label: flowLabel,
|
|
215
|
+
processType: str(flow.processType),
|
|
216
|
+
status: str(flow.status),
|
|
217
|
+
description: str(flow.description),
|
|
218
|
+
apiVersion: str(flow.apiVersion) ?? versionInfo.sourceApiVersion ?? versionInfo.packageVersion,
|
|
219
|
+
interviewLabel: str(flow.interviewLabel),
|
|
220
|
+
canvasMode: readCanvasMode(flow),
|
|
221
|
+
start: startConfig,
|
|
222
|
+
nodes,
|
|
223
|
+
edges,
|
|
224
|
+
variables,
|
|
225
|
+
formulas,
|
|
226
|
+
constants,
|
|
227
|
+
choices,
|
|
228
|
+
textTemplates,
|
|
229
|
+
stages,
|
|
230
|
+
resources,
|
|
231
|
+
groups,
|
|
232
|
+
hasDesignerCoordinates: sawCoordinates,
|
|
233
|
+
sourcePath: filePath,
|
|
234
|
+
metadata: {
|
|
235
|
+
nodeCount: nodes.length,
|
|
236
|
+
edgeCount: edges.length,
|
|
237
|
+
decisionCount: nodes.filter((n) => n.kind === 'decision').length,
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Flow Visualizer Plugin
|
|
9
|
+
*
|
|
10
|
+
* Handles `.flow-meta.xml` files and renders the flow as a Flow Builder–style
|
|
11
|
+
* flowchart (start → screens, decisions, record operations, actions, …) with a
|
|
12
|
+
* right-side fault lane, collapsible branches/groups, an element inspector, and
|
|
13
|
+
* a docked Flow Information panel.
|
|
14
|
+
*/
|
|
15
|
+
import { IVisualizationPlugin, MetadataPluginInfo, IPlatformContext } from '@salesforce/metadata-core-sdk';
|
|
16
|
+
import { FlowModel } from './types/FlowData.js';
|
|
17
|
+
import { FlowParser } from './FlowParser.js';
|
|
18
|
+
export declare class FlowVisualizer implements IVisualizationPlugin<FlowModel> {
|
|
19
|
+
private readonly pluginMetadata;
|
|
20
|
+
readonly parser: FlowParser;
|
|
21
|
+
private logger?;
|
|
22
|
+
constructor();
|
|
23
|
+
getMetadataPluginInfo(): MetadataPluginInfo;
|
|
24
|
+
canHandle(filePath: string): boolean;
|
|
25
|
+
initialize(context: IPlatformContext): Promise<void>;
|
|
26
|
+
dispose?(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=FlowVisualizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowVisualizer.d.ts","sourceRoot":"","sources":["../../../src/plugins/flow/FlowVisualizer.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;GAOG;AAEH,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,qBAAa,cAAe,YAAW,oBAAoB,CAAC,SAAS,CAAC;IACpE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAQ7B;IAEF,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAE5B,OAAO,CAAC,MAAM,CAAC,CAAU;;IAMzB,qBAAqB,IAAI,kBAAkB;IAI3C,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAM9B,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAO1D,OAAO,CAAC,IAAI,IAAI;CAGjB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import { FlowParser } from './FlowParser.js';
|
|
8
|
+
import { matchesFilePattern } from '../../shared/utils/patternMatcher.js';
|
|
9
|
+
export class FlowVisualizer {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.pluginMetadata = {
|
|
12
|
+
id: 'flow',
|
|
13
|
+
name: 'Salesforce Flow Visualizer',
|
|
14
|
+
displayName: 'Flow',
|
|
15
|
+
description: 'Interactive diagram of Salesforce Flow (.flow-meta.xml) elements and connectors',
|
|
16
|
+
author: 'Metadata Visualizer Team',
|
|
17
|
+
filePatterns: ['.flow-meta.xml'],
|
|
18
|
+
priority: 10,
|
|
19
|
+
};
|
|
20
|
+
this.parser = new FlowParser();
|
|
21
|
+
}
|
|
22
|
+
getMetadataPluginInfo() {
|
|
23
|
+
return this.pluginMetadata;
|
|
24
|
+
}
|
|
25
|
+
canHandle(filePath) {
|
|
26
|
+
return this.getMetadataPluginInfo().filePatterns.some((pattern) => matchesFilePattern(filePath, pattern));
|
|
27
|
+
}
|
|
28
|
+
async initialize(context) {
|
|
29
|
+
this.logger = context.logger.createChild(this.getMetadataPluginInfo().id);
|
|
30
|
+
this.logger.info('Flow visualizer initialized');
|
|
31
|
+
this.parser.setPlatformContext(context);
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
this.logger?.info(`Disposing ${this.getMetadataPluginInfo().name}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Per-element detail rendering for the inspector panel.
|
|
9
|
+
*
|
|
10
|
+
* `deriveDetail` — one-line subtitle shown under a node's label.
|
|
11
|
+
* `deriveDetails` — structured, grouped rows shown in the sidebar's element
|
|
12
|
+
* inspector. Each `FlowNodeKind` maps to a renderer that
|
|
13
|
+
* pushes `FlowDetailGroup`s. Anything a renderer can't
|
|
14
|
+
* cleanly destructure degrades to a `note` rather than
|
|
15
|
+
* dumping raw XML.
|
|
16
|
+
* `isAutoLabel` — whether a node's display label looks auto-generated (used
|
|
17
|
+
* for the "Auto-labeled" chip in the inspector).
|
|
18
|
+
*/
|
|
19
|
+
import type { FlowDetailGroup, FlowNodeKind } from '../types/FlowData.js';
|
|
20
|
+
/** Short, kind-specific subtitle shown under a node's label. */
|
|
21
|
+
export declare function deriveDetail(kind: FlowNodeKind, record: Record<string, unknown>): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* A label looks auto-generated when it's absent, identical to the API name, or
|
|
24
|
+
* the API name is just the label with spaces swapped for underscores (Flow
|
|
25
|
+
* Builder's default when you don't type a custom label).
|
|
26
|
+
*/
|
|
27
|
+
export declare function isAutoLabel(apiName: string, label: string | undefined): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Builds the structured, grouped detail for an element. Each group becomes a
|
|
30
|
+
* collapsible section on the card.
|
|
31
|
+
*/
|
|
32
|
+
export declare function deriveDetails(kind: FlowNodeKind, record: Record<string, unknown>): FlowDetailGroup[];
|
|
33
|
+
//# sourceMappingURL=details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"details.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flow/parser/details.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAiB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAYzF,gEAAgE;AAChE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,GAAG,SAAS,CAqCpB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAS/E;AAyTD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,eAAe,EAAE,CAanB"}
|