@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,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"}
@@ -0,0 +1,353 @@
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 { CONNECTOR_LABELS, DETAIL_TITLES } from './flowLabels.js';
8
+ import { arr, bool, connectorTarget, formatValue, str, unwrapRule, } from './xmlPrimitives.js';
9
+ /** Short, kind-specific subtitle shown under a node's label. */
10
+ export function deriveDetail(kind, record) {
11
+ switch (kind) {
12
+ case 'recordCreate':
13
+ case 'recordLookup':
14
+ case 'recordUpdate':
15
+ case 'recordDelete': {
16
+ const object = str(record.object);
17
+ return object ? `Object: ${object}` : undefined;
18
+ }
19
+ case 'subflow': {
20
+ const ref = str(record.flowName);
21
+ return ref ? `Flow: ${ref}` : undefined;
22
+ }
23
+ case 'action': {
24
+ // Orchestrator stage — no actionName/Type, but has <stageSteps>.
25
+ if (Array.isArray(record.stageSteps) ||
26
+ (record.stageSteps && typeof record.stageSteps === 'object')) {
27
+ const count = arr(record.stageSteps).length;
28
+ return `${count} step${count === 1 ? '' : 's'}`;
29
+ }
30
+ const type = str(record.actionType);
31
+ const name = str(record.actionName);
32
+ return [type, name].filter(Boolean).join(': ') || undefined;
33
+ }
34
+ case 'decision': {
35
+ const ruleCount = arr(record.rules).length;
36
+ return `${ruleCount} outcome${ruleCount === 1 ? '' : 's'} + default`;
37
+ }
38
+ case 'loop': {
39
+ const coll = str(record.collectionReference);
40
+ return coll ? `Over: ${coll}` : undefined;
41
+ }
42
+ default:
43
+ return undefined;
44
+ }
45
+ }
46
+ /**
47
+ * A label looks auto-generated when it's absent, identical to the API name, or
48
+ * the API name is just the label with spaces swapped for underscores (Flow
49
+ * Builder's default when you don't type a custom label).
50
+ */
51
+ export function isAutoLabel(apiName, label) {
52
+ if (!label) {
53
+ return true;
54
+ }
55
+ if (label === apiName) {
56
+ return true;
57
+ }
58
+ const norm = (s) => s.replace(/[\s_]+/g, '').toLowerCase();
59
+ return norm(label) === norm(apiName);
60
+ }
61
+ /** Render a filter/condition row: "Field operator value". */
62
+ function formatCondition(cond) {
63
+ const field = str(cond.field) ?? str(cond.leftValueReference) ?? '';
64
+ const op = str(cond.operator) ?? '';
65
+ const val = formatValue(cond.value) ?? formatValue(cond.rightValue) ?? '';
66
+ return [field, op, val].filter(Boolean).join(' ');
67
+ }
68
+ const rowsFromConditions = (conds) => arr(conds)
69
+ .map((c) => c)
70
+ .map((c, i) => ({ label: `Condition ${i + 1}`, value: formatCondition(c) }))
71
+ .filter((r) => r.value.length > 0);
72
+ /** Screen fields can nest (`<fields>` containing `<fields>`); flatten one level deep enough for display. */
73
+ function collectScreenFields(record) {
74
+ const out = [];
75
+ const walk = (fields) => {
76
+ for (const f of arr(fields)) {
77
+ const rec = f;
78
+ const name = str(rec.name);
79
+ if (name) {
80
+ out.push({ name, type: str(rec.fieldType) ?? str(rec.dataType) ?? 'Component' });
81
+ }
82
+ if (rec.fields) {
83
+ walk(rec.fields);
84
+ }
85
+ }
86
+ };
87
+ walk(record.fields);
88
+ return out;
89
+ }
90
+ /** Renderer shared by all four `record*` kinds. */
91
+ const recordRenderer = (record, kind) => {
92
+ const groups = [];
93
+ const verb = kind === 'recordCreate'
94
+ ? 'Create'
95
+ : kind === 'recordUpdate'
96
+ ? 'Update'
97
+ : kind === 'recordDelete'
98
+ ? 'Delete'
99
+ : 'Get';
100
+ const object = str(record.object);
101
+ if (object) {
102
+ groups.push({
103
+ title: `${verb} Records of This Object`,
104
+ rows: [{ label: 'Object', value: object }],
105
+ });
106
+ }
107
+ const filters = rowsFromConditions(record.filters);
108
+ if (filters.length) {
109
+ const logic = str(record.filterLogic);
110
+ groups.push({
111
+ title: `Filter ${object ?? ''} Records`.replace(/\s+/g, ' ').trim(),
112
+ rows: [...(logic ? [{ label: 'Condition Requirements', value: logic }] : []), ...filters],
113
+ });
114
+ }
115
+ if (kind === 'recordLookup') {
116
+ const store = [];
117
+ if (str(record.getFirstRecordOnly)) {
118
+ store.push({
119
+ label: 'Records to Store',
120
+ value: bool(record.getFirstRecordOnly) ? 'First record only' : 'All records',
121
+ });
122
+ }
123
+ if (str(record.storeOutputAutomatically)) {
124
+ store.push({
125
+ label: 'How to Store',
126
+ value: bool(record.storeOutputAutomatically) ? 'Automatically' : 'Manually',
127
+ });
128
+ }
129
+ if (store.length) {
130
+ groups.push({ title: DETAIL_TITLES.howManyToStore, rows: store });
131
+ }
132
+ const fields = arr(record.queriedFields)
133
+ .map((f) => str(f))
134
+ .filter((f) => Boolean(f));
135
+ if (fields.length) {
136
+ groups.push({
137
+ title: DETAIL_TITLES.fieldsToStore,
138
+ rows: fields.map((f) => ({ label: f, value: '' })),
139
+ });
140
+ }
141
+ }
142
+ const inputAssignments = arr(record.inputAssignments)
143
+ .map((a) => a)
144
+ .map((a) => ({ label: str(a.field) ?? '', value: formatValue(a.value) ?? '' }))
145
+ .filter((r) => r.label);
146
+ if (inputAssignments.length) {
147
+ groups.push({ title: DETAIL_TITLES.setFieldValues, rows: inputAssignments });
148
+ }
149
+ const outputAssignments = arr(record.outputAssignments)
150
+ .map((a) => a)
151
+ .map((a) => ({
152
+ label: formatValue(a.value) ?? str(a.field) ?? '',
153
+ value: `→ {!${str(a.assignToReference) ?? ''}}`,
154
+ }))
155
+ .filter((r) => r.label);
156
+ if (outputAssignments.length) {
157
+ groups.push({ title: DETAIL_TITLES.storeOutputValues, rows: outputAssignments });
158
+ }
159
+ return groups;
160
+ };
161
+ const assignmentRenderer = (record) => {
162
+ const items = arr(record.assignmentItems)
163
+ .map((a) => a)
164
+ .map((a) => ({
165
+ label: `{!${str(a.assignToReference) ?? ''}}`,
166
+ value: `${str(a.operator) ?? '='} ${formatValue(a.value) ?? ''}`.trim(),
167
+ }))
168
+ .filter((r) => r.label !== '{!}');
169
+ // Flow Builder labels this section "Set Variable Values".
170
+ return items.length ? [{ title: DETAIL_TITLES.setVariableValues, rows: items }] : [];
171
+ };
172
+ const decisionRenderer = (record) => {
173
+ const groups = [];
174
+ for (const rule of arr(record.rules)) {
175
+ const r = unwrapRule(rule);
176
+ const conds = rowsFromConditions(r.conditions);
177
+ const logic = str(r.conditionLogic);
178
+ const dest = connectorTarget(r.connector);
179
+ const title = `Outcome: ${str(r.label) ?? str(r.name) ?? ''}`.trim();
180
+ groups.push({
181
+ title,
182
+ rows: [
183
+ ...(logic ? [{ label: 'Condition Logic', value: logic }] : []),
184
+ ...conds,
185
+ ...(dest ? [{ label: 'Go to', value: dest }] : []),
186
+ ],
187
+ note: conds.length === 0 ? 'Always (no conditions)' : undefined,
188
+ });
189
+ }
190
+ // The default outcome (the path taken when no rule matches) is real config
191
+ // too — surface its label + destination so the inspector isn't missing a
192
+ // branch the canvas shows.
193
+ const defLabel = str(record.defaultConnectorLabel) ?? CONNECTOR_LABELS.defaultOutcome;
194
+ const defDest = connectorTarget(record.defaultConnector);
195
+ if (defDest) {
196
+ groups.push({
197
+ title: `Outcome: ${defLabel}`,
198
+ rows: [{ label: 'Go to', value: defDest }],
199
+ note: 'Taken when no other outcome matches',
200
+ });
201
+ }
202
+ return groups;
203
+ };
204
+ const loopRenderer = (record) => {
205
+ // Flow Builder: "Loop Through this Collection" + iteration direction.
206
+ const rows = [];
207
+ const coll = str(record.collectionReference);
208
+ if (coll) {
209
+ rows.push({ label: 'Collection Variable', value: `{!${coll}}` });
210
+ }
211
+ const order = str(record.iterationOrder);
212
+ if (order) {
213
+ rows.push({
214
+ label: 'Direction',
215
+ value: /desc/i.test(order) ? 'Last to first item' : 'First to last item',
216
+ });
217
+ }
218
+ return rows.length ? [{ title: DETAIL_TITLES.loopThrough, rows }] : [];
219
+ };
220
+ const actionOrSubflowRenderer = (record, kind) => {
221
+ const groups = [];
222
+ // Orchestrator stage: list each stage step (name + action + type) under a
223
+ // dedicated "Steps" section instead of the action-call layout.
224
+ if (kind === 'action' &&
225
+ (Array.isArray(record.stageSteps) ||
226
+ (record.stageSteps && typeof record.stageSteps === 'object'))) {
227
+ const stepRows = arr(record.stageSteps)
228
+ .map((s) => s)
229
+ .map((s) => {
230
+ const label = str(s.label) ?? str(s.name) ?? '';
231
+ const action = str(s.actionName);
232
+ const type = str(s.stepSubtype) ?? str(s.actionType);
233
+ const detail = [action, type].filter(Boolean).join(' · ');
234
+ return { label, value: detail };
235
+ })
236
+ .filter((r) => r.label);
237
+ if (stepRows.length) {
238
+ groups.push({ title: DETAIL_TITLES.steps, rows: stepRows });
239
+ }
240
+ return groups;
241
+ }
242
+ // Section names mirror Flow Builder's Action panel: Set Input Values,
243
+ // Store Output Values, with the referenced action/flow under "Action".
244
+ const inputs = arr(record.inputParameters)
245
+ .map((p) => p)
246
+ .map((p) => ({ label: str(p.name) ?? '', value: formatValue(p.value) ?? '' }))
247
+ .filter((r) => r.label);
248
+ if (inputs.length) {
249
+ groups.push({ title: DETAIL_TITLES.setInputValues, rows: inputs });
250
+ }
251
+ const outputs = arr(record.outputParameters)
252
+ .map((p) => p)
253
+ .map((p) => ({ label: str(p.name) ?? '', value: `→ {!${str(p.assignToReference) ?? ''}}` }))
254
+ .filter((r) => r.label);
255
+ if (outputs.length) {
256
+ groups.push({ title: DETAIL_TITLES.storeOutputValues, rows: outputs });
257
+ }
258
+ const actionRows = [];
259
+ const actionType = str(record.actionType);
260
+ const actionName = str(record.actionName) ?? str(record.flowName);
261
+ if (actionName) {
262
+ actionRows.push({
263
+ label: kind === 'subflow' ? 'Referenced Flow' : 'Action Name',
264
+ value: actionName,
265
+ });
266
+ }
267
+ if (actionType) {
268
+ actionRows.push({ label: 'Type', value: actionType });
269
+ }
270
+ if (actionRows.length) {
271
+ groups.push({
272
+ title: kind === 'subflow' ? DETAIL_TITLES.subflow : DETAIL_TITLES.action,
273
+ rows: actionRows,
274
+ });
275
+ }
276
+ return groups;
277
+ };
278
+ const screenRenderer = (record) => {
279
+ const fields = collectScreenFields(record);
280
+ if (!fields.length) {
281
+ return [];
282
+ }
283
+ return [
284
+ {
285
+ title: DETAIL_TITLES.screenComponents,
286
+ rows: fields.map((f) => ({ label: f.name, value: f.type })),
287
+ },
288
+ ];
289
+ };
290
+ const transformRenderer = (record) => {
291
+ // Transform is metadata-heavy (Formulas/Join/Sum sub-areas per Flow Version
292
+ // Comparison). We surface what's safely readable and note the rest rather
293
+ // than rendering a wall of nested mappings.
294
+ const rows = [];
295
+ const inputRef = str(record.transformInputReference) ?? formatValue(record.inputReference);
296
+ if (inputRef) {
297
+ rows.push({ label: 'Input', value: inputRef });
298
+ }
299
+ const valueCount = arr(record.transformValues).length;
300
+ if (valueCount) {
301
+ rows.push({ label: 'Mappings', value: String(valueCount) });
302
+ }
303
+ return [
304
+ {
305
+ title: DETAIL_TITLES.transform,
306
+ rows,
307
+ note: valueCount > 0
308
+ ? 'Mapping details (Formula/Join/Sum) shown in Flow Builder'
309
+ : 'No mappings captured',
310
+ },
311
+ ];
312
+ };
313
+ const waitRenderer = (record) => {
314
+ const events = arr(record.waitEvents)
315
+ .map((e) => e)
316
+ .map((e) => ({ label: str(e.label) ?? str(e.name) ?? '', value: str(e.eventType) ?? '' }))
317
+ .filter((r) => r.label);
318
+ return events.length ? [{ title: DETAIL_TITLES.pauseConditions, rows: events }] : [];
319
+ };
320
+ /**
321
+ * Kind → renderer. Kinds not present here contribute no kind-specific groups
322
+ * (fault handling is still appended universally in `deriveDetails`).
323
+ */
324
+ const DETAIL_RENDERERS = {
325
+ recordCreate: recordRenderer,
326
+ recordLookup: recordRenderer,
327
+ recordUpdate: recordRenderer,
328
+ recordDelete: recordRenderer,
329
+ assignment: assignmentRenderer,
330
+ decision: decisionRenderer,
331
+ loop: loopRenderer,
332
+ action: actionOrSubflowRenderer,
333
+ subflow: actionOrSubflowRenderer,
334
+ screen: screenRenderer,
335
+ transform: transformRenderer,
336
+ wait: waitRenderer,
337
+ };
338
+ /**
339
+ * Builds the structured, grouped detail for an element. Each group becomes a
340
+ * collapsible section on the card.
341
+ */
342
+ export function deriveDetails(kind, record) {
343
+ const renderer = DETAIL_RENDERERS[kind];
344
+ const groups = renderer ? renderer(record, kind) : [];
345
+ // Universal: fault handling presence is useful context on the card.
346
+ if (connectorTarget(record.faultConnector)) {
347
+ groups.push({
348
+ title: DETAIL_TITLES.faultHandling,
349
+ rows: [{ label: 'On error', value: '→ fault path' }],
350
+ });
351
+ }
352
+ return groups;
353
+ }
@@ -0,0 +1,53 @@
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
+ * Edge materialization pass.
9
+ *
10
+ * `EdgeBuilder` owns the mutable state that used to live as closures inside the
11
+ * old `buildModel`:
12
+ * - a monotonic end-id counter (one End node per terminal branch),
13
+ * - the running `edges` array (with `prepend` support for Start edges),
14
+ * - the `resolve()` helper that either returns an existing node id or mints
15
+ * a fresh End node when a branch dead-ends.
16
+ *
17
+ * `wireElementEdges` walks the authored elements and emits branch-aware
18
+ * connectors (decision outcomes, loop branches, wait events, faults, linear
19
+ * successors). `wireStartEdges` handles the synthetic Start node's outgoing
20
+ * fan-out (explicit connector, scheduledPaths, or indegree-0 fallback).
21
+ */
22
+ import type { FlowEdge, FlowNode } from '../types/FlowData.js';
23
+ /**
24
+ * Accumulates edges and mints per-branch End nodes on demand. Constructed once
25
+ * per flow; the produced `edges` and freshly-minted end nodes are folded into
26
+ * the model in `buildModel`.
27
+ */
28
+ export declare class EdgeBuilder {
29
+ private readonly knownIds;
30
+ private readonly nodes;
31
+ private readonly endIdBase;
32
+ readonly edges: FlowEdge[];
33
+ private endSeq;
34
+ constructor(knownIds: Set<string>, nodes: FlowNode[], endIdBase: string);
35
+ addEdge(from: string, target: string | undefined, extra?: Partial<FlowEdge>, prepend?: boolean): void;
36
+ /**
37
+ * Resolve a target reference to a real node id. A missing target, or one
38
+ * pointing at "End"/an unknown element, terminates the branch — so we mint a
39
+ * fresh End node for it rather than funneling every branch into one sink.
40
+ */
41
+ private resolve;
42
+ private mintEnd;
43
+ }
44
+ /** Second pass: branch-aware connectors per element kind. */
45
+ export declare function wireElementEdges(flow: Record<string, unknown>, builder: EdgeBuilder): void;
46
+ /**
47
+ * Third pass: fan-out from the synthetic Start node. Prefer the explicit
48
+ * `<start><connector>` or legacy `<startElementReference>`. Otherwise (common
49
+ * in autolaunched flows that omit a start node), every element with no
50
+ * incoming edge is an entry point.
51
+ */
52
+ export declare function wireStartEdges(flow: Record<string, unknown>, nodes: FlowNode[], builder: EdgeBuilder, startId: string): void;
53
+ //# sourceMappingURL=edges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flow/parser/edges.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAY/D;;;;GAIG;AACH,qBAAa,WAAW;IAKpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAN5B,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAM;IAChC,OAAO,CAAC,MAAM,CAAK;gBAGA,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EACrB,KAAK,EAAE,QAAQ,EAAE,EACjB,SAAS,EAAE,MAAM;IAGpC,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,EACzB,OAAO,UAAQ,GACd,IAAI;IASP;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,OAAO;CAahB;AAED,6DAA6D;AAC7D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAuG1F;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,GACd,IAAI,CAmDN"}
@@ -0,0 +1,197 @@
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 { ELEMENT_TYPES } from './elementTypes.js';
8
+ import { CONNECTOR_LABELS } from './flowLabels.js';
9
+ import { arr, connectorIsGoTo, connectorTarget, str, unwrapRule, } from './xmlPrimitives.js';
10
+ /**
11
+ * Accumulates edges and mints per-branch End nodes on demand. Constructed once
12
+ * per flow; the produced `edges` and freshly-minted end nodes are folded into
13
+ * the model in `buildModel`.
14
+ */
15
+ export class EdgeBuilder {
16
+ constructor(knownIds, nodes, endIdBase) {
17
+ this.knownIds = knownIds;
18
+ this.nodes = nodes;
19
+ this.endIdBase = endIdBase;
20
+ this.edges = [];
21
+ this.endSeq = 0;
22
+ }
23
+ addEdge(from, target, extra, prepend = false) {
24
+ const edge = { from, to: this.resolve(target), ...extra };
25
+ if (prepend) {
26
+ this.edges.unshift(edge);
27
+ }
28
+ else {
29
+ this.edges.push(edge);
30
+ }
31
+ }
32
+ /**
33
+ * Resolve a target reference to a real node id. A missing target, or one
34
+ * pointing at "End"/an unknown element, terminates the branch — so we mint a
35
+ * fresh End node for it rather than funneling every branch into one sink.
36
+ */
37
+ resolve(target) {
38
+ return target && this.knownIds.has(target) ? target : this.mintEnd();
39
+ }
40
+ mintEnd() {
41
+ const id = `${this.endIdBase}_${++this.endSeq}`;
42
+ this.nodes.push({
43
+ id,
44
+ kind: 'end',
45
+ label: 'End',
46
+ typeLabel: 'End',
47
+ metaTypeLabel: 'End',
48
+ details: [],
49
+ autoLabel: false,
50
+ });
51
+ return id;
52
+ }
53
+ }
54
+ /** Second pass: branch-aware connectors per element kind. */
55
+ export function wireElementEdges(flow, builder) {
56
+ for (const { tag, kind } of ELEMENT_TYPES) {
57
+ for (const el of arr(flow[tag])) {
58
+ if (!el || typeof el !== 'object') {
59
+ continue;
60
+ }
61
+ const record = el;
62
+ const id = str(record.name);
63
+ if (!id) {
64
+ continue;
65
+ }
66
+ // Skip `<stages>` entries that aren't canvas stages (no `<stageSteps>`) —
67
+ // those are non-canvas orchestrator resources authored on classic flows,
68
+ // not nodes participating in the diagram. Mirrors the nodes pass.
69
+ if (tag === 'stages' && !arr(record.stageSteps).length) {
70
+ continue;
71
+ }
72
+ // Fault connector applies to most data/action elements. A fault connector
73
+ // may itself carry `<isGoTo>true</isGoTo>` — the target already lives
74
+ // elsewhere on the canvas (e.g., a decision's default outcome), so the
75
+ // fault path renders as a `→ Target` chip on the source rather than
76
+ // dragging the target into the fault lane.
77
+ const faultTarget = connectorTarget(record.faultConnector);
78
+ if (faultTarget) {
79
+ const faultIsGoTo = connectorIsGoTo(record.faultConnector);
80
+ builder.addEdge(id, faultTarget, {
81
+ label: CONNECTOR_LABELS.fault,
82
+ isFault: true,
83
+ ...(faultIsGoTo ? { isGoTo: true } : {}),
84
+ });
85
+ }
86
+ if (kind === 'decision') {
87
+ for (const rule of arr(record.rules)) {
88
+ const ruleRecord = unwrapRule(rule);
89
+ const isGoTo = connectorIsGoTo(ruleRecord.connector);
90
+ builder.addEdge(id, connectorTarget(ruleRecord.connector), {
91
+ label: str(ruleRecord.label) ?? str(ruleRecord.name),
92
+ ...(isGoTo ? { isGoTo: true } : {}),
93
+ });
94
+ }
95
+ const defaultIsGoTo = connectorIsGoTo(record.defaultConnector);
96
+ builder.addEdge(id, connectorTarget(record.defaultConnector), {
97
+ label: str(record.defaultConnectorLabel) ?? CONNECTOR_LABELS.defaultOutcome,
98
+ isDefault: true,
99
+ ...(defaultIsGoTo ? { isGoTo: true } : {}),
100
+ });
101
+ continue;
102
+ }
103
+ if (kind === 'loop') {
104
+ const nextIsGoTo = connectorIsGoTo(record.nextValueConnector);
105
+ builder.addEdge(id, connectorTarget(record.nextValueConnector), {
106
+ label: CONNECTOR_LABELS.loopForEach,
107
+ ...(nextIsGoTo ? { isGoTo: true } : {}),
108
+ });
109
+ const noMoreIsGoTo = connectorIsGoTo(record.noMoreValuesConnector);
110
+ builder.addEdge(id, connectorTarget(record.noMoreValuesConnector), {
111
+ label: CONNECTOR_LABELS.loopAfterLast,
112
+ isDefault: true,
113
+ ...(noMoreIsGoTo ? { isGoTo: true } : {}),
114
+ });
115
+ continue;
116
+ }
117
+ if (kind === 'wait') {
118
+ for (const evt of arr(record.waitEvents)) {
119
+ const evtRecord = evt;
120
+ const evtIsGoTo = connectorIsGoTo(evtRecord.connector);
121
+ builder.addEdge(id, connectorTarget(evtRecord.connector), {
122
+ label: str(evtRecord.label) ?? str(evtRecord.name),
123
+ ...(evtIsGoTo ? { isGoTo: true } : {}),
124
+ });
125
+ }
126
+ // Wait's default path. Emit an edge whenever EITHER
127
+ // `<defaultConnector>` OR `<defaultConnectorLabel>` is authored — Flow
128
+ // Builder renders the Default Path branch (dead-ending in an End
129
+ // marker if no target) whenever the label is set, matching the
130
+ // visible branches in the Auto-Layout Canvas.
131
+ const waitDefault = connectorTarget(record.defaultConnector);
132
+ const waitDefaultLabel = str(record.defaultConnectorLabel);
133
+ if (waitDefault || waitDefaultLabel) {
134
+ const waitDefaultIsGoTo = connectorIsGoTo(record.defaultConnector);
135
+ builder.addEdge(id, waitDefault, {
136
+ label: waitDefaultLabel ?? CONNECTOR_LABELS.defaultPath,
137
+ isDefault: true,
138
+ ...(waitDefaultIsGoTo ? { isGoTo: true } : {}),
139
+ });
140
+ }
141
+ continue;
142
+ }
143
+ // Linear elements: a single `<connector>`. If absent, the element is a
144
+ // terminal leaf and flows into the synthetic End node.
145
+ const linearIsGoTo = connectorIsGoTo(record.connector);
146
+ builder.addEdge(id, connectorTarget(record.connector), linearIsGoTo ? { isGoTo: true } : undefined);
147
+ }
148
+ }
149
+ }
150
+ /**
151
+ * Third pass: fan-out from the synthetic Start node. Prefer the explicit
152
+ * `<start><connector>` or legacy `<startElementReference>`. Otherwise (common
153
+ * in autolaunched flows that omit a start node), every element with no
154
+ * incoming edge is an entry point.
155
+ */
156
+ export function wireStartEdges(flow, nodes, builder, startId) {
157
+ const startEl = flow.start;
158
+ const declaredStart = connectorTarget(startEl?.connector) ?? str(flow.startElementReference);
159
+ // Record-triggered flows can also fan out from Start via <scheduledPaths>
160
+ // (each an async branch). These are peer outcomes of Start, not fault edges —
161
+ // they need to be edges on the main spine so downstream elements land on it
162
+ // instead of being pushed into the fault lane.
163
+ const scheduledPaths = arr(startEl?.scheduledPaths)
164
+ .map((p) => p)
165
+ .map((p) => ({
166
+ target: connectorTarget(p.connector),
167
+ label: str(p.label) ?? str(p.name) ?? str(p.pathType) ?? CONNECTOR_LABELS.scheduledPath,
168
+ }))
169
+ .filter((p) => Boolean(p.target));
170
+ if (declaredStart) {
171
+ // If there are scheduled paths, label the main connector so the two
172
+ // branches read as sibling outcomes (Flow Builder's "Run Immediately" vs.
173
+ // "Run Asynchronously"). Prepend all Start edges so they render first.
174
+ for (const p of [...scheduledPaths].reverse()) {
175
+ builder.addEdge(startId, p.target, { label: p.label }, /* prepend */ true);
176
+ }
177
+ builder.addEdge(startId, declaredStart, scheduledPaths.length ? { label: CONNECTOR_LABELS.runImmediately } : undefined,
178
+ /* prepend */ true);
179
+ return;
180
+ }
181
+ if (scheduledPaths.length) {
182
+ for (const p of [...scheduledPaths].reverse()) {
183
+ builder.addEdge(startId, p.target, { label: p.label }, /* prepend */ true);
184
+ }
185
+ return;
186
+ }
187
+ const hasIncoming = new Set(builder.edges.map((e) => e.to));
188
+ const entries = nodes.filter((n) => n.kind !== 'start' && n.kind !== 'end' && !hasIncoming.has(n.id));
189
+ // Prepend so Start edges render first; fall back to the first element if
190
+ // the graph is fully cyclic and nothing has indegree 0.
191
+ const targets = entries.length > 0
192
+ ? entries
193
+ : nodes.filter((n) => n.kind !== 'start' && n.kind !== 'end').slice(0, 1);
194
+ for (const entry of targets.reverse()) {
195
+ builder.addEdge(startId, entry.id, undefined, true);
196
+ }
197
+ }