@salesforce/metadata-plugins 1.3.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.
Files changed (111) hide show
  1. package/README.md +30 -3
  2. package/dist/index.d.ts +7 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +13 -2
  5. package/dist/plugins/agent/AgentParser.d.ts +34 -0
  6. package/dist/plugins/agent/AgentParser.d.ts.map +1 -0
  7. package/dist/plugins/agent/AgentParser.js +189 -0
  8. package/dist/plugins/agent/AgentVisualizer.d.ts +27 -0
  9. package/dist/plugins/agent/AgentVisualizer.d.ts.map +1 -0
  10. package/dist/plugins/agent/AgentVisualizer.js +36 -0
  11. package/dist/plugins/agent/extract/assertNever.d.ts +23 -0
  12. package/dist/plugins/agent/extract/assertNever.d.ts.map +1 -0
  13. package/dist/plugins/agent/extract/assertNever.js +24 -0
  14. package/dist/plugins/agent/extract/ast-to-graph.d.ts +137 -0
  15. package/dist/plugins/agent/extract/ast-to-graph.d.ts.map +1 -0
  16. package/dist/plugins/agent/extract/ast-to-graph.js +523 -0
  17. package/dist/plugins/agent/extract/ast-utils.d.ts +61 -0
  18. package/dist/plugins/agent/extract/ast-utils.d.ts.map +1 -0
  19. package/dist/plugins/agent/extract/ast-utils.js +7 -0
  20. package/dist/plugins/agent/extract/parseNamespacedRef.d.ts +31 -0
  21. package/dist/plugins/agent/extract/parseNamespacedRef.d.ts.map +1 -0
  22. package/dist/plugins/agent/extract/parseNamespacedRef.js +31 -0
  23. package/dist/plugins/agent/extract/reasoningParser.d.ts +112 -0
  24. package/dist/plugins/agent/extract/reasoningParser.d.ts.map +1 -0
  25. package/dist/plugins/agent/extract/reasoningParser.js +804 -0
  26. package/dist/plugins/agent/types/AgentScriptData.d.ts +31 -0
  27. package/dist/plugins/agent/types/AgentScriptData.d.ts.map +1 -0
  28. package/dist/plugins/agent/types/AgentScriptData.js +7 -0
  29. package/dist/plugins/agent/ui/assets/index-CTzSDPPx.css +1 -0
  30. package/dist/plugins/agent/ui/assets/index-D0wb9GBs.js +71 -0
  31. package/dist/plugins/agent/ui/index.html +14 -0
  32. package/dist/plugins/flexipage/FlexipageParser.d.ts +1 -1
  33. package/dist/plugins/flexipage/FlexipageParser.js +1 -1
  34. package/dist/plugins/flexipage/FlexipageVisualizer.d.ts +1 -1
  35. package/dist/plugins/flexipage/FlexipageVisualizer.js +1 -1
  36. package/dist/plugins/flexipage/transformer/FlexipageToUemTransformer.d.ts +1 -1
  37. package/dist/plugins/flexipage/transformer/FlexipageToUemTransformer.js +1 -1
  38. package/dist/plugins/flexipage/transformer/FlexipageTransformerUtils.d.ts +1 -1
  39. package/dist/plugins/flexipage/transformer/FlexipageTransformerUtils.js +1 -1
  40. package/dist/plugins/flexipage/types/FlexipageMetadata.d.ts +1 -1
  41. package/dist/plugins/flexipage/types/FlexipageMetadata.js +1 -1
  42. package/dist/plugins/flow/FlowParser.d.ts +36 -0
  43. package/dist/plugins/flow/FlowParser.d.ts.map +1 -0
  44. package/dist/plugins/flow/FlowParser.js +240 -0
  45. package/dist/plugins/flow/FlowVisualizer.d.ts +28 -0
  46. package/dist/plugins/flow/FlowVisualizer.d.ts.map +1 -0
  47. package/dist/plugins/flow/FlowVisualizer.js +36 -0
  48. package/dist/plugins/flow/parser/details.d.ts +33 -0
  49. package/dist/plugins/flow/parser/details.d.ts.map +1 -0
  50. package/dist/plugins/flow/parser/details.js +353 -0
  51. package/dist/plugins/flow/parser/edges.d.ts +53 -0
  52. package/dist/plugins/flow/parser/edges.d.ts.map +1 -0
  53. package/dist/plugins/flow/parser/edges.js +197 -0
  54. package/dist/plugins/flow/parser/elementTypes.d.ts +47 -0
  55. package/dist/plugins/flow/parser/elementTypes.d.ts.map +1 -0
  56. package/dist/plugins/flow/parser/elementTypes.js +176 -0
  57. package/dist/plugins/flow/parser/flowLabels.d.ts +43 -0
  58. package/dist/plugins/flow/parser/flowLabels.d.ts.map +1 -0
  59. package/dist/plugins/flow/parser/flowLabels.js +42 -0
  60. package/dist/plugins/flow/parser/groups.d.ts +26 -0
  61. package/dist/plugins/flow/parser/groups.d.ts.map +1 -0
  62. package/dist/plugins/flow/parser/groups.js +56 -0
  63. package/dist/plugins/flow/parser/nodes.d.ts +25 -0
  64. package/dist/plugins/flow/parser/nodes.d.ts.map +1 -0
  65. package/dist/plugins/flow/parser/nodes.js +86 -0
  66. package/dist/plugins/flow/parser/resources.d.ts +21 -0
  67. package/dist/plugins/flow/parser/resources.d.ts.map +1 -0
  68. package/dist/plugins/flow/parser/resources.js +140 -0
  69. package/dist/plugins/flow/parser/startConfig.d.ts +29 -0
  70. package/dist/plugins/flow/parser/startConfig.d.ts.map +1 -0
  71. package/dist/plugins/flow/parser/startConfig.js +117 -0
  72. package/dist/plugins/flow/parser/xmlPrimitives.d.ts +53 -0
  73. package/dist/plugins/flow/parser/xmlPrimitives.d.ts.map +1 -0
  74. package/dist/plugins/flow/parser/xmlPrimitives.js +152 -0
  75. package/dist/plugins/flow/types/FlowData.d.ts +294 -0
  76. package/dist/plugins/flow/types/FlowData.d.ts.map +1 -0
  77. package/dist/plugins/flow/types/FlowData.js +7 -0
  78. package/dist/plugins/flow/ui/assets/index-Cb-x8fUq.css +1 -0
  79. package/dist/plugins/flow/ui/assets/index-DDfQ7eDI.js +48 -0
  80. package/dist/plugins/flow/ui/index.html +14 -0
  81. package/dist/plugins/schema/SchemaParser.d.ts +1 -1
  82. package/dist/plugins/schema/SchemaParser.js +1 -1
  83. package/dist/plugins/schema/SchemaVisualizer.d.ts +1 -1
  84. package/dist/plugins/schema/SchemaVisualizer.js +1 -1
  85. package/dist/plugins/schema/types/SchemaERDData.d.ts +1 -1
  86. package/dist/plugins/schema/types/SchemaERDData.js +1 -1
  87. package/dist/shared/bootstrap/createPluginApp.d.ts +1 -1
  88. package/dist/shared/bootstrap/createPluginApp.js +1 -1
  89. package/dist/shared/components/ErrorBoundary.d.ts +1 -1
  90. package/dist/shared/components/ErrorBoundary.js +1 -1
  91. package/dist/shared/uem/transformer/ITransformer.d.ts +1 -1
  92. package/dist/shared/uem/transformer/ITransformer.js +1 -1
  93. package/dist/shared/uem/transformer/TransformerRegistry.d.ts +1 -1
  94. package/dist/shared/uem/transformer/TransformerRegistry.js +1 -1
  95. package/dist/shared/uem/transformer/UemBasedVisualizer.d.ts +1 -1
  96. package/dist/shared/uem/transformer/UemBasedVisualizer.js +1 -1
  97. package/dist/shared/uem/types/UemMetadata.d.ts +1 -1
  98. package/dist/shared/uem/types/UemMetadata.js +1 -1
  99. package/dist/shared/uem/ui/components/PropertyRenderer/PropertyRenderer.d.ts +1 -1
  100. package/dist/shared/uem/ui/components/PropertyRenderer/PropertyRenderer.js +1 -1
  101. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.d.ts +1 -1
  102. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.js +1 -1
  103. package/dist/shared/utils/isPluginError.d.ts +1 -1
  104. package/dist/shared/utils/isPluginError.js +1 -1
  105. package/dist/shared/utils/patternMatcher.d.ts +1 -1
  106. package/dist/shared/utils/patternMatcher.js +1 -1
  107. package/dist/shared/utils/uemTreeUtils.d.ts +1 -1
  108. package/dist/shared/utils/uemTreeUtils.js +1 -1
  109. package/dist/shared/utils/vizDependentPathsHelper.d.ts +1 -1
  110. package/dist/shared/utils/vizDependentPathsHelper.js +1 -1
  111. package/package.json +8 -5
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Agent Script Visualizer</title>
7
+ <script type="module" crossorigin src="./assets/index-D0wb9GBs.js"></script>
8
+ <link rel="stylesheet" crossorigin href="./assets/index-CTzSDPPx.css">
9
+ <link rel="stylesheet" href="@dist/design-system/platform.css" data-platform-styles="true">
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ </body>
14
+ </html>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2025, Salesforce, Inc.
2
+ * Copyright (c) 2026, Salesforce, Inc.
3
3
  * All rights reserved.
4
4
  * Licensed under the BSD 3-Clause license.
5
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -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"}