@salesforce/metadata-plugins 1.4.0 → 1.6.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 (89) hide show
  1. package/README.md +30 -3
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4 -0
  5. package/dist/plugins/agent/AgentParser.d.ts +7 -1
  6. package/dist/plugins/agent/AgentParser.d.ts.map +1 -1
  7. package/dist/plugins/agent/AgentParser.js +9 -0
  8. package/dist/plugins/agent/agentSelectionGraph.d.ts +101 -0
  9. package/dist/plugins/agent/agentSelectionGraph.d.ts.map +1 -0
  10. package/dist/plugins/agent/agentSelectionGraph.js +407 -0
  11. package/dist/plugins/agent/extract/ast-to-graph.d.ts +2 -0
  12. package/dist/plugins/agent/extract/ast-to-graph.d.ts.map +1 -1
  13. package/dist/plugins/agent/extract/ast-to-graph.js +1 -0
  14. package/dist/plugins/agent/ui/assets/index-C_Q6Mc2L.js +71 -0
  15. package/dist/plugins/agent/ui/assets/index-DX8JtDoL.css +1 -0
  16. package/dist/plugins/agent/ui/index.html +2 -2
  17. package/dist/plugins/flexipage/FlexipageParser.d.ts +12 -1
  18. package/dist/plugins/flexipage/FlexipageParser.d.ts.map +1 -1
  19. package/dist/plugins/flexipage/FlexipageParser.js +14 -0
  20. package/dist/plugins/flexipage/ui/assets/index-CuJYcAx_.js +48 -0
  21. package/dist/plugins/flexipage/ui/assets/index-DBy19jKB.css +1 -0
  22. package/dist/plugins/flexipage/ui/index.html +2 -2
  23. package/dist/plugins/flow/FlowParser.d.ts +43 -0
  24. package/dist/plugins/flow/FlowParser.d.ts.map +1 -0
  25. package/dist/plugins/flow/FlowParser.js +250 -0
  26. package/dist/plugins/flow/FlowVisualizer.d.ts +28 -0
  27. package/dist/plugins/flow/FlowVisualizer.d.ts.map +1 -0
  28. package/dist/plugins/flow/FlowVisualizer.js +36 -0
  29. package/dist/plugins/flow/flowSelectionGraph.d.ts +71 -0
  30. package/dist/plugins/flow/flowSelectionGraph.d.ts.map +1 -0
  31. package/dist/plugins/flow/flowSelectionGraph.js +196 -0
  32. package/dist/plugins/flow/parser/details.d.ts +33 -0
  33. package/dist/plugins/flow/parser/details.d.ts.map +1 -0
  34. package/dist/plugins/flow/parser/details.js +353 -0
  35. package/dist/plugins/flow/parser/edges.d.ts +53 -0
  36. package/dist/plugins/flow/parser/edges.d.ts.map +1 -0
  37. package/dist/plugins/flow/parser/edges.js +197 -0
  38. package/dist/plugins/flow/parser/elementTypes.d.ts +47 -0
  39. package/dist/plugins/flow/parser/elementTypes.d.ts.map +1 -0
  40. package/dist/plugins/flow/parser/elementTypes.js +176 -0
  41. package/dist/plugins/flow/parser/flowLabels.d.ts +43 -0
  42. package/dist/plugins/flow/parser/flowLabels.d.ts.map +1 -0
  43. package/dist/plugins/flow/parser/flowLabels.js +42 -0
  44. package/dist/plugins/flow/parser/groups.d.ts +26 -0
  45. package/dist/plugins/flow/parser/groups.d.ts.map +1 -0
  46. package/dist/plugins/flow/parser/groups.js +56 -0
  47. package/dist/plugins/flow/parser/nodes.d.ts +25 -0
  48. package/dist/plugins/flow/parser/nodes.d.ts.map +1 -0
  49. package/dist/plugins/flow/parser/nodes.js +86 -0
  50. package/dist/plugins/flow/parser/resources.d.ts +21 -0
  51. package/dist/plugins/flow/parser/resources.d.ts.map +1 -0
  52. package/dist/plugins/flow/parser/resources.js +140 -0
  53. package/dist/plugins/flow/parser/startConfig.d.ts +29 -0
  54. package/dist/plugins/flow/parser/startConfig.d.ts.map +1 -0
  55. package/dist/plugins/flow/parser/startConfig.js +117 -0
  56. package/dist/plugins/flow/parser/xmlPrimitives.d.ts +53 -0
  57. package/dist/plugins/flow/parser/xmlPrimitives.d.ts.map +1 -0
  58. package/dist/plugins/flow/parser/xmlPrimitives.js +152 -0
  59. package/dist/plugins/flow/types/FlowData.d.ts +294 -0
  60. package/dist/plugins/flow/types/FlowData.d.ts.map +1 -0
  61. package/dist/plugins/flow/types/FlowData.js +7 -0
  62. package/dist/plugins/flow/ui/assets/index-DJP9DbPL.js +48 -0
  63. package/dist/plugins/flow/ui/assets/index-H7g-xvR-.css +1 -0
  64. package/dist/plugins/flow/ui/index.html +14 -0
  65. package/dist/plugins/schema/SchemaParser.d.ts +12 -1
  66. package/dist/plugins/schema/SchemaParser.d.ts.map +1 -1
  67. package/dist/plugins/schema/SchemaParser.js +14 -0
  68. package/dist/plugins/schema/schemaSelectionGraph.d.ts +34 -0
  69. package/dist/plugins/schema/schemaSelectionGraph.d.ts.map +1 -0
  70. package/dist/plugins/schema/schemaSelectionGraph.js +77 -0
  71. package/dist/plugins/schema/ui/assets/index-BHwyhVGF.js +70 -0
  72. package/dist/plugins/schema/ui/assets/index-Cp1nVgsx.css +1 -0
  73. package/dist/plugins/schema/ui/index.html +2 -2
  74. package/dist/shared/bootstrap/createPluginApp.d.ts +14 -0
  75. package/dist/shared/bootstrap/createPluginApp.d.ts.map +1 -1
  76. package/dist/shared/bootstrap/createPluginApp.js +4 -0
  77. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.d.ts +9 -1
  78. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.d.ts.map +1 -1
  79. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.js +55 -30
  80. package/dist/shared/utils/uemTreeUtils.d.ts +33 -3
  81. package/dist/shared/utils/uemTreeUtils.d.ts.map +1 -1
  82. package/dist/shared/utils/uemTreeUtils.js +82 -5
  83. package/package.json +5 -5
  84. package/dist/plugins/agent/ui/assets/index-CTzSDPPx.css +0 -1
  85. package/dist/plugins/agent/ui/assets/index-D0wb9GBs.js +0 -71
  86. package/dist/plugins/flexipage/ui/assets/index-DT5lcUwK.js +0 -48
  87. package/dist/plugins/flexipage/ui/assets/index-U3SB2gLS.css +0 -1
  88. package/dist/plugins/schema/ui/assets/index-DCLgZby3.css +0 -1
  89. package/dist/plugins/schema/ui/assets/index-jqcasNAD.js +0 -70
@@ -0,0 +1,43 @@
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, type SelectableNode } 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
+ * Vibe-edit contribution: project the parsed flow into normalized selectable
37
+ * nodes (elements + Orchestrator stage steps). Delegates entirely to the pure
38
+ * `flowSelectionGraph` module so the ids emitted here stay byte-identical to
39
+ * the `data-mv-id`s the canvas cards render.
40
+ */
41
+ getSelectableNodes(data: FlowModel): SelectableNode[];
42
+ }
43
+ //# 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,EAGX,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;AAGvC,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;IAK7D;;;;;OAKG;IACH,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,EAAE;CAGtD"}
@@ -0,0 +1,250 @@
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 { flowSelectableNodes } from './flowSelectionGraph.js';
18
+ import { isPluginError } from '../../shared/utils/isPluginError.js';
19
+ import { FLOW_END, FLOW_START } from './parser/flowLabels.js';
20
+ import { arr, bool, num, str } from './parser/xmlPrimitives.js';
21
+ import { collectGroups } from './parser/groups.js';
22
+ import { collectResources } from './parser/resources.js';
23
+ import { readCanvasMode, readStartConfig, startDetails } from './parser/startConfig.js';
24
+ import { collectNodes } from './parser/nodes.js';
25
+ import { EdgeBuilder, wireElementEdges, wireStartEdges } from './parser/edges.js';
26
+ const START_ID = FLOW_START;
27
+ const END_ID = FLOW_END;
28
+ /**
29
+ * Extract basename from a file path without importing Node's `path` module.
30
+ * The basename is retained for local error `context` (host-side error chrome
31
+ * shows it to the user) but is intentionally NEVER shipped in a telemetry
32
+ * event — `.flow-meta.xml` filenames are customer-authored and can reveal
33
+ * product / feature names.
34
+ */
35
+ function basename(filePath) {
36
+ return filePath.split(/[\\/]/).pop() ?? filePath;
37
+ }
38
+ export class FlowParser {
39
+ setPlatformContext(context) {
40
+ this.context = context;
41
+ this.logger = context.logger.createChild('FlowParser');
42
+ this.telemetry = context.telemetry.createChild({ component: 'FlowParser' });
43
+ }
44
+ async parse(filePath, versionInfo) {
45
+ const fileName = basename(filePath);
46
+ if (!this.context) {
47
+ throw ErrorBuilder.create()
48
+ .category(ErrorCategory.Configuration)
49
+ .message('FlowParser is not initialized with platform context')
50
+ .context({ fileName })
51
+ .build();
52
+ }
53
+ const ctx = this.context;
54
+ const log = this.logger ?? ctx.logger.createChild('FlowParser');
55
+ const telemetry = this.telemetry ?? ctx.telemetry.createChild({ component: 'FlowParser' });
56
+ return telemetry.withSpan('flow.parse', async (span) => {
57
+ try {
58
+ const read = await ctx.fileSystem.readFile(filePath);
59
+ if (!read.success || typeof read.data !== 'string') {
60
+ throw ErrorBuilder.create()
61
+ .category(ErrorCategory.Dependency)
62
+ .message(`Failed to read flow file: ${read.error?.message ?? fileName}`)
63
+ .context({ fileName })
64
+ .build();
65
+ }
66
+ span.setAttribute('sourceLength', String(read.data.length));
67
+ const model = buildModel(read.data, filePath, versionInfo ?? {});
68
+ const nodeCount = model.nodes.length;
69
+ const edgeCount = model.edges.length;
70
+ const decisionCount = model.metadata.decisionCount;
71
+ const elementCount = model.nodes.filter((n) => n.kind !== 'start' && n.kind !== 'end').length;
72
+ // Shape metrics for the completed parse. Counts only — no
73
+ // customer-authored labels or ids ever land in telemetry.
74
+ span.setAttribute('nodeCount', String(nodeCount));
75
+ span.setAttribute('edgeCount', String(edgeCount));
76
+ span.setAttribute('decisionCount', String(decisionCount));
77
+ // Parse reliability: a flow that only produced a Start node is
78
+ // legitimate for ApprovalWorkflow etc., but worth tracking so a
79
+ // regression in the element extractor doesn't hide behind that
80
+ // exception. `reason` is a fixed low-cardinality string.
81
+ if (elementCount === 0) {
82
+ telemetry.sendEvent('flow.parse_incomplete', { pluginId: 'flow', reason: 'no_elements' }, { nodeCount, edgeCount });
83
+ log.warn(`Flow parse produced no authored elements (nodes=${nodeCount}, edges=${edgeCount})`);
84
+ }
85
+ telemetry.sendEvent('flow.parse_complete', { pluginId: 'flow' }, { nodeCount, edgeCount, decisionCount, elementCount });
86
+ log.info(`Parsed flow (nodes=${nodeCount}, edges=${edgeCount}, decisions=${decisionCount})`);
87
+ return model;
88
+ }
89
+ catch (error) {
90
+ if (isPluginError(error)) {
91
+ telemetry.sendEvent('flow.parse_error', { pluginId: 'flow' }, {});
92
+ throw error;
93
+ }
94
+ telemetry.sendEvent('flow.parse_error', { pluginId: 'flow' }, {});
95
+ const message = error instanceof Error ? error.message : String(error);
96
+ throw ErrorBuilder.create()
97
+ .category(ErrorCategory.Parsing)
98
+ .message(message)
99
+ .context({ fileName })
100
+ .build();
101
+ }
102
+ }, { pluginId: 'flow' });
103
+ }
104
+ validate(_data) {
105
+ // A flow with only a Start node is legitimate — e.g. ApprovalWorkflow
106
+ // process types carry their logic in approval metadata rather than flow
107
+ // elements. Render whatever we have; the canvas handles the Start-only case.
108
+ return { valid: true, errors: [], warnings: [] };
109
+ }
110
+ /**
111
+ * Derive the Flow's display label from already-parsed data. The parser puts
112
+ * the source `<label>` (falling back to `<fullName>`/filename) into
113
+ * `data.label`, so we can return it without re-reading the file.
114
+ */
115
+ extractMetadataInfo(data) {
116
+ const label = typeof data.label === 'string' ? data.label.trim() : '';
117
+ return label ? { label } : null;
118
+ }
119
+ /**
120
+ * Vibe-edit contribution: project the parsed flow into normalized selectable
121
+ * nodes (elements + Orchestrator stage steps). Delegates entirely to the pure
122
+ * `flowSelectionGraph` module so the ids emitted here stay byte-identical to
123
+ * the `data-mv-id`s the canvas cards render.
124
+ */
125
+ getSelectableNodes(data) {
126
+ return flowSelectableNodes(data);
127
+ }
128
+ }
129
+ function buildModel(source, filePath, versionInfo) {
130
+ const parser = new SalesforceXMLParser();
131
+ const parsed = parser.parse(source);
132
+ if (!parsed.Flow || typeof parsed.Flow !== 'object') {
133
+ throw ErrorBuilder.create()
134
+ .category(ErrorCategory.Parsing)
135
+ .message('Invalid flow file: missing <Flow> root element')
136
+ .context({ fileName: basename(filePath) })
137
+ .build();
138
+ }
139
+ const flow = parsed.Flow;
140
+ // The flow's display name, used as the Start node's title (Flow Builder shows
141
+ // the flow name on the Start element, not the literal words "Flow Start").
142
+ const flowLabel = str(flow.label) ?? (filePath.split('/').pop() ?? 'Flow').replace(/\.flow-meta\.xml$/, '');
143
+ // First pass: one node per authored element. Reserve Start/End so mintable
144
+ // end nodes never collide with real element ids.
145
+ const { nodes, knownIds, sawCoordinates } = collectNodes(flow, [START_ID, END_ID]);
146
+ // Synthetic Start bookend, anchored to the flow's <start> coords when present.
147
+ const startEl = flow.start;
148
+ const startConfig = readStartConfig(startEl);
149
+ nodes.unshift({
150
+ id: START_ID,
151
+ kind: 'start',
152
+ label: flowLabel,
153
+ typeLabel: 'Start',
154
+ metaTypeLabel: 'Start',
155
+ details: startDetails(str(flow.processType), startConfig),
156
+ autoLabel: false,
157
+ locationX: num(startEl?.locationX),
158
+ locationY: num(startEl?.locationY),
159
+ });
160
+ // Second + third passes: element connectors, then Start fan-out. EdgeBuilder
161
+ // owns per-branch End node minting so terminal branches don't collide.
162
+ const builder = new EdgeBuilder(knownIds, nodes, END_ID);
163
+ wireElementEdges(flow, builder);
164
+ wireStartEdges(flow, nodes, builder, START_ID);
165
+ const edges = builder.edges;
166
+ const variables = arr(flow.variables)
167
+ .map((v) => v)
168
+ .filter((v) => str(v.name))
169
+ .map((v) => ({
170
+ name: str(v.name),
171
+ dataType: str(v.dataType) ?? 'String',
172
+ isCollection: bool(v.isCollection),
173
+ isInput: bool(v.isInput),
174
+ isOutput: bool(v.isOutput),
175
+ }));
176
+ const formulas = arr(flow.formulas)
177
+ .map((f) => f)
178
+ .filter((f) => str(f.name))
179
+ .map((f) => ({
180
+ name: str(f.name),
181
+ dataType: str(f.dataType),
182
+ expression: str(f.expression),
183
+ }));
184
+ const constants = arr(flow.constants)
185
+ .map((c) => c)
186
+ .filter((c) => str(c.name))
187
+ .map((c) => ({
188
+ name: str(c.name),
189
+ dataType: str(c.dataType),
190
+ value: str(c.value),
191
+ }));
192
+ const choices = [
193
+ ...arr(flow.choices)
194
+ .map((c) => c)
195
+ .filter((c) => str(c.name))
196
+ .map((c) => ({ name: str(c.name), dataType: str(c.dataType), kind: 'choice' })),
197
+ ...arr(flow.dynamicChoiceSets)
198
+ .map((c) => c)
199
+ .filter((c) => str(c.name))
200
+ .map((c) => ({ name: str(c.name), dataType: str(c.dataType), kind: 'dynamic' })),
201
+ ];
202
+ const textTemplates = arr(flow.textTemplates)
203
+ .map((t) => t)
204
+ .filter((t) => str(t.name))
205
+ .map((t) => ({
206
+ name: str(t.name),
207
+ detail: bool(t.isViewedAsPlainText) ? 'Plain text' : 'Rich text',
208
+ }));
209
+ // Canvas stages (Flow Orchestrator, with `<stageSteps>`) surface as nodes on
210
+ // the diagram; only the resource-only variant (classic <stages>) belongs in
211
+ // the Toolbox stage list.
212
+ const stages = arr(flow.stages)
213
+ .map((s) => s)
214
+ .filter((s) => str(s.name) && !arr(s.stageSteps).length)
215
+ .map((s) => ({ name: str(s.name), detail: str(s.label) }));
216
+ // Groups: gated `ALC_GENERIC_GROUP` (GA 264). The upstream metadata tag isn't
217
+ // finalized, so read from candidate containers and also back-fill membership
218
+ // from each element's own group pointer (readGroupId).
219
+ const groups = collectGroups(flow, nodes);
220
+ // Toolbox resources, categorized + synthesized the way Flow Builder does.
221
+ const resources = collectResources(flow, formulas, constants, choices, textTemplates, stages);
222
+ return {
223
+ flowName: (filePath.split('/').pop() ?? 'Flow').replace(/\.flow-meta\.xml$/, ''),
224
+ label: flowLabel,
225
+ processType: str(flow.processType),
226
+ status: str(flow.status),
227
+ description: str(flow.description),
228
+ apiVersion: str(flow.apiVersion) ?? versionInfo.sourceApiVersion ?? versionInfo.packageVersion,
229
+ interviewLabel: str(flow.interviewLabel),
230
+ canvasMode: readCanvasMode(flow),
231
+ start: startConfig,
232
+ nodes,
233
+ edges,
234
+ variables,
235
+ formulas,
236
+ constants,
237
+ choices,
238
+ textTemplates,
239
+ stages,
240
+ resources,
241
+ groups,
242
+ hasDesignerCoordinates: sawCoordinates,
243
+ sourcePath: filePath,
244
+ metadata: {
245
+ nodeCount: nodes.length,
246
+ edgeCount: edges.length,
247
+ decisionCount: nodes.filter((n) => n.kind === 'decision').length,
248
+ },
249
+ };
250
+ }
@@ -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,71 @@
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 SelectionGraph (C1) — the plugin's ENTIRE vibe-edit contribution.
9
+ *
10
+ * One forward projection of the parsed `FlowModel` into the normalized
11
+ * `SelectableNode` contract. Because a Flow element's `id` is already its
12
+ * globally-unique API name (`<name>` in the `.flow-meta.xml`), we reuse it
13
+ * VERBATIM as the SelectableNode id — no `structuralId` needed for elements.
14
+ * The id the parser emits here and the id the canvas cards render as
15
+ * `data-mv-id` are therefore identical BY CONSTRUCTION, so the generic core-sdk
16
+ * engine resolves a selected element by a pure `Map.get(id)` — no per-element
17
+ * buildContext, no inverse resolver, no descriptor.
18
+ *
19
+ * The only derived id is for a Flow Orchestrator **stage step** (`<stageSteps>`),
20
+ * which has no standalone element id: it is keyed deterministically on
21
+ * `(stageId, stepName)` via the shared `structuralId`, so `flowStepId` gives the
22
+ * same byte-identical id at parse-time (host, DOM-less) and render-time (iframe).
23
+ *
24
+ * What is NOT projected (and correspondingly never stamped in the DOM):
25
+ * - the synthetic `start` / `end` bookends the parser injects (graph
26
+ * terminators, not editable elements); and
27
+ * - the renderer-only `group` summary kind (synthesized by the collapse
28
+ * transform in the view model — the parser never emits it).
29
+ */
30
+ import { type SelectableNode } from '@salesforce/metadata-core-sdk';
31
+ import type { FlowModel } from './types/FlowData.js';
32
+ /**
33
+ * Deterministic id for a Flow Orchestrator stage step. Stage steps have no
34
+ * standalone API name at the element level, so their id is derived from the
35
+ * owning stage's (already unique) id plus the step's `<name>`. StageCard renders
36
+ * each step row with this exact id as `data-mv-id`.
37
+ */
38
+ export declare function flowStepId(stageId: string, stepName: string): string;
39
+ /**
40
+ * The synthetic group key used for the leading "Properties" block (Label / API
41
+ * Name / Description) that every element inspector shows. It is NOT one of the
42
+ * parser's `details` groups — it's rendered directly by `PropertiesGroup` — so
43
+ * it gets a fixed key here that both the projection and the sidebar agree on.
44
+ */
45
+ export declare const FLOW_PROPERTIES_GROUP_KEY = "Properties";
46
+ /**
47
+ * Deterministic id for one label/value ROW inside an element's inspector panel
48
+ * (a Properties row or a detail-group row). Sidebar rows have no standalone API
49
+ * name, so — exactly like a stage step — the id is derived from the owning
50
+ * element's id plus the row's coordinates within the panel:
51
+ *
52
+ * - `groupKey` identifies the containing block. For the leading Properties
53
+ * block it is {@link FLOW_PROPERTIES_GROUP_KEY}; for a detail group it is
54
+ * `"<groupIndex>:<groupTitle>"` so duplicate group titles can't collide.
55
+ * - `rowLabel` the row's left-column label ("Object", "API Name", …).
56
+ * - `index` the row's position within its group, disambiguating rows that
57
+ * share a label.
58
+ *
59
+ * The sidebar renders each row with this exact id as `data-mv-id`, so the
60
+ * engine's `Map.get(id)` inversion resolves a clicked row to this projected
61
+ * node. Host (DOM-less) and render (iframe) compute byte-identical ids.
62
+ */
63
+ export declare function flowRowId(elementId: string, groupKey: string, rowLabel: string, index: number): string;
64
+ /**
65
+ * Emit the full Flow SelectionGraph. Used by `FlowParser.getSelectableNodes()`
66
+ * (host-side) and — because element ids are the elements' own API names and
67
+ * step ids are identity-derived — matched exactly by the ids the canvas cards
68
+ * render as `data-mv-id`.
69
+ */
70
+ export declare function flowSelectableNodes(data: FlowModel): SelectableNode[];
71
+ //# sourceMappingURL=flowSelectionGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowSelectionGraph.d.ts","sourceRoot":"","sources":["../../../src/plugins/flow/flowSelectionGraph.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,qBAAqB,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,eAAe,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,MAAM,CAER;AAyID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,EAAE,CAKrE"}
@@ -0,0 +1,196 @@
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 SelectionGraph (C1) — the plugin's ENTIRE vibe-edit contribution.
9
+ *
10
+ * One forward projection of the parsed `FlowModel` into the normalized
11
+ * `SelectableNode` contract. Because a Flow element's `id` is already its
12
+ * globally-unique API name (`<name>` in the `.flow-meta.xml`), we reuse it
13
+ * VERBATIM as the SelectableNode id — no `structuralId` needed for elements.
14
+ * The id the parser emits here and the id the canvas cards render as
15
+ * `data-mv-id` are therefore identical BY CONSTRUCTION, so the generic core-sdk
16
+ * engine resolves a selected element by a pure `Map.get(id)` — no per-element
17
+ * buildContext, no inverse resolver, no descriptor.
18
+ *
19
+ * The only derived id is for a Flow Orchestrator **stage step** (`<stageSteps>`),
20
+ * which has no standalone element id: it is keyed deterministically on
21
+ * `(stageId, stepName)` via the shared `structuralId`, so `flowStepId` gives the
22
+ * same byte-identical id at parse-time (host, DOM-less) and render-time (iframe).
23
+ *
24
+ * What is NOT projected (and correspondingly never stamped in the DOM):
25
+ * - the synthetic `start` / `end` bookends the parser injects (graph
26
+ * terminators, not editable elements); and
27
+ * - the renderer-only `group` summary kind (synthesized by the collapse
28
+ * transform in the view model — the parser never emits it).
29
+ */
30
+ import { structuralId } from '@salesforce/metadata-core-sdk';
31
+ /**
32
+ * Deterministic id for a Flow Orchestrator stage step. Stage steps have no
33
+ * standalone API name at the element level, so their id is derived from the
34
+ * owning stage's (already unique) id plus the step's `<name>`. StageCard renders
35
+ * each step row with this exact id as `data-mv-id`.
36
+ */
37
+ export function flowStepId(stageId, stepName) {
38
+ return structuralId(stageId, 'step', stepName);
39
+ }
40
+ /**
41
+ * The synthetic group key used for the leading "Properties" block (Label / API
42
+ * Name / Description) that every element inspector shows. It is NOT one of the
43
+ * parser's `details` groups — it's rendered directly by `PropertiesGroup` — so
44
+ * it gets a fixed key here that both the projection and the sidebar agree on.
45
+ */
46
+ export const FLOW_PROPERTIES_GROUP_KEY = 'Properties';
47
+ /**
48
+ * Deterministic id for one label/value ROW inside an element's inspector panel
49
+ * (a Properties row or a detail-group row). Sidebar rows have no standalone API
50
+ * name, so — exactly like a stage step — the id is derived from the owning
51
+ * element's id plus the row's coordinates within the panel:
52
+ *
53
+ * - `groupKey` identifies the containing block. For the leading Properties
54
+ * block it is {@link FLOW_PROPERTIES_GROUP_KEY}; for a detail group it is
55
+ * `"<groupIndex>:<groupTitle>"` so duplicate group titles can't collide.
56
+ * - `rowLabel` the row's left-column label ("Object", "API Name", …).
57
+ * - `index` the row's position within its group, disambiguating rows that
58
+ * share a label.
59
+ *
60
+ * The sidebar renders each row with this exact id as `data-mv-id`, so the
61
+ * engine's `Map.get(id)` inversion resolves a clicked row to this projected
62
+ * node. Host (DOM-less) and render (iframe) compute byte-identical ids.
63
+ */
64
+ export function flowRowId(elementId, groupKey, rowLabel, index) {
65
+ return structuralId(elementId, 'detail', `${groupKey}::${rowLabel}`, index);
66
+ }
67
+ /**
68
+ * Element kinds that are graph scaffolding rather than editable elements, so
69
+ * they are excluded from the selection graph (and never stamped in the DOM):
70
+ * - `end` — the synthetic terminal bookend the parser injects (a bare glyph
71
+ * with no editable configuration).
72
+ * - `group` — a renderer-only collapsed-group summary node (view model only).
73
+ *
74
+ * NOTE: `start` is intentionally NOT here. The Start element carries real,
75
+ * editable configuration (trigger / entry criteria — see `startDetails`) and
76
+ * Flow Builder treats it as a first-class selectable element, so it IS
77
+ * projected into the graph and stamped in the DOM (its stable `FLOW_START` id).
78
+ */
79
+ const NON_SELECTABLE_KINDS = new Set(['end', 'group']);
80
+ /** Salient, JSON-safe attributes surfaced to the agent for one element. */
81
+ function elementAttributes(node) {
82
+ const attributes = {
83
+ label: node.label,
84
+ typeLabel: node.typeLabel,
85
+ };
86
+ if (node.metaTypeLabel) {
87
+ attributes.metaTypeLabel = node.metaTypeLabel;
88
+ }
89
+ if (node.detail) {
90
+ attributes.detail = node.detail;
91
+ }
92
+ if (node.description) {
93
+ attributes.description = node.description;
94
+ }
95
+ if (node.groupId) {
96
+ attributes.groupId = node.groupId;
97
+ }
98
+ return attributes;
99
+ }
100
+ /**
101
+ * Project the element's inspector-panel ROWS into child selectable nodes — one
102
+ * per label/value row the sidebar's `SelectedElement` renders, so each row is
103
+ * individually selectable for vibe-edit (parented to the element).
104
+ *
105
+ * This MIRRORS the render side exactly (DetailGroup.tsx's `PropertiesGroup` +
106
+ * `DetailGroup`), because the sidebar stamps each row with `flowRowId(...)` as
107
+ * its `data-mv-id` and the engine resolves the click by a pure id lookup — the
108
+ * projected id and the rendered id MUST be byte-identical:
109
+ *
110
+ * - the leading "Properties" block: Label (always), API Name (every kind
111
+ * except the synthetic Start bookend, which has no real API name), and
112
+ * Description (only when present); then
113
+ * - every row of every element-specific detail group (`node.details`).
114
+ */
115
+ function elementRowNodes(node, filePath) {
116
+ const rows = [];
117
+ const rowNode = (groupKey, groupTitle, rowLabel, index, value) => ({
118
+ id: flowRowId(node.id, groupKey, rowLabel, index),
119
+ type: 'detail',
120
+ apiName: rowLabel,
121
+ parentId: node.id,
122
+ attributes: {
123
+ group: groupTitle,
124
+ label: rowLabel,
125
+ ...(value ? { value } : {}),
126
+ },
127
+ ...(filePath ? { filePath } : {}),
128
+ });
129
+ // Properties block — the fixed leading group rendered by PropertiesGroup.
130
+ // Labels are distinct within it, so index 0 keeps every id unique.
131
+ rows.push(rowNode(FLOW_PROPERTIES_GROUP_KEY, 'Properties', 'Label', 0, node.label));
132
+ // API Name is shown for every genuine element; the synthetic Start bookend
133
+ // carries a prefixed id that isn't a real API name, so it's omitted there
134
+ // (PropertiesGroup skips it for kind 'group' / 'start'; 'group' never reaches
135
+ // this projection).
136
+ if (node.kind !== 'group' && node.kind !== 'start') {
137
+ rows.push(rowNode(FLOW_PROPERTIES_GROUP_KEY, 'Properties', 'API Name', 0, node.id));
138
+ }
139
+ if (node.description) {
140
+ rows.push(rowNode(FLOW_PROPERTIES_GROUP_KEY, 'Properties', 'Description', 0, node.description));
141
+ }
142
+ // Element-specific detail groups. The group key carries the group's INDEX so
143
+ // duplicate group titles (e.g. two "Outcome: …" decision groups) can't
144
+ // collide; the row index disambiguates rows sharing a label within a group.
145
+ (node.details ?? []).forEach((group, gi) => {
146
+ const groupKey = `${gi}:${group.title}`;
147
+ (group.rows ?? []).forEach((row, i) => {
148
+ rows.push(rowNode(groupKey, group.title, row.label, i, row.value));
149
+ });
150
+ });
151
+ return rows;
152
+ }
153
+ /** Project one element (+ its inspector rows and stage steps) into selectable nodes. */
154
+ function elementToNodes(node, filePath) {
155
+ const element = {
156
+ id: node.id,
157
+ type: node.kind,
158
+ apiName: node.id,
159
+ attributes: elementAttributes(node),
160
+ ...(filePath ? { filePath } : {}),
161
+ };
162
+ const rowNodes = elementRowNodes(node, filePath);
163
+ const steps = node.steps ?? [];
164
+ if (steps.length === 0) {
165
+ return [element, ...rowNodes];
166
+ }
167
+ // Flow Orchestrator stage: each `<stageSteps>` row is a child selectable
168
+ // node parented to the stage, mirroring how StageCard renders the rows inside
169
+ // the stage container.
170
+ const stepNodes = steps.map((step) => ({
171
+ id: flowStepId(node.id, step.name),
172
+ type: 'step',
173
+ apiName: step.name,
174
+ parentId: node.id,
175
+ attributes: {
176
+ label: step.label,
177
+ ...(step.actionName ? { actionName: step.actionName } : {}),
178
+ ...(step.actionType ? { actionType: step.actionType } : {}),
179
+ ...(step.stepSubtype ? { stepSubtype: step.stepSubtype } : {}),
180
+ },
181
+ ...(filePath ? { filePath } : {}),
182
+ }));
183
+ return [element, ...rowNodes, ...stepNodes];
184
+ }
185
+ /**
186
+ * Emit the full Flow SelectionGraph. Used by `FlowParser.getSelectableNodes()`
187
+ * (host-side) and — because element ids are the elements' own API names and
188
+ * step ids are identity-derived — matched exactly by the ids the canvas cards
189
+ * render as `data-mv-id`.
190
+ */
191
+ export function flowSelectableNodes(data) {
192
+ const filePath = data.sourcePath || undefined;
193
+ return data.nodes
194
+ .filter((node) => !NON_SELECTABLE_KINDS.has(node.kind))
195
+ .flatMap((node) => elementToNodes(node, filePath));
196
+ }