@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,140 @@
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 { arr, bool, str, unwrapRule } from './xmlPrimitives.js';
8
+ /**
9
+ * Emit one `recordOutput` resource per Create/Update-style element that keeps
10
+ * automatic outputs enabled. Called from `collectResources` for the specific
11
+ * tags (currently just `recordCreates`) that produce a single record variable.
12
+ */
13
+ function autoStoresRecord(tag, flow, out) {
14
+ for (const raw of arr(flow[tag])) {
15
+ const el = raw;
16
+ const name = str(el.name);
17
+ if (!name) {
18
+ continue;
19
+ }
20
+ if (str(el.storeOutputAutomatically) === 'false') {
21
+ continue;
22
+ }
23
+ const label = str(el.label) ?? name;
24
+ const object = str(el.object) ?? 'Record';
25
+ out.push({
26
+ name: `${object} from ${label}`,
27
+ category: 'recordOutput',
28
+ dataType: object,
29
+ detail: `from ${label}`,
30
+ });
31
+ }
32
+ }
33
+ /** Build the Toolbox resource list — see file-level docstring. */
34
+ export function collectResources(flow, formulas, constants, choices, textTemplates, stages) {
35
+ const out = [];
36
+ for (const raw of arr(flow.variables)) {
37
+ const v = raw;
38
+ const name = str(v.name);
39
+ if (!name) {
40
+ continue;
41
+ }
42
+ const dataType = str(v.dataType) ?? 'String';
43
+ const isCollection = bool(v.isCollection);
44
+ const objectType = str(v.objectType); // set when the variable is an SObject
45
+ const ioHint = bool(v.isInput) && bool(v.isOutput)
46
+ ? 'In/Out'
47
+ : bool(v.isInput)
48
+ ? 'Input'
49
+ : bool(v.isOutput)
50
+ ? 'Output'
51
+ : undefined;
52
+ let category;
53
+ let typeLabel = dataType;
54
+ if (dataType === 'Apex') {
55
+ category = 'apexVariable';
56
+ typeLabel = str(v.apexClass) ?? 'Apex';
57
+ }
58
+ else if (objectType || dataType === 'SObject') {
59
+ category = 'recordVariable';
60
+ typeLabel = objectType ?? 'SObject';
61
+ }
62
+ else if (isCollection) {
63
+ category = 'collectionVariable';
64
+ }
65
+ else {
66
+ category = 'variable';
67
+ }
68
+ out.push({
69
+ name,
70
+ category,
71
+ dataType: `${typeLabel}${isCollection ? '[]' : ''}`,
72
+ detail: ioHint,
73
+ });
74
+ }
75
+ for (const c of constants) {
76
+ out.push({ name: c.name, category: 'constant', dataType: c.dataType, detail: c.value });
77
+ }
78
+ for (const f of formulas) {
79
+ out.push({ name: f.name, category: 'formula', dataType: f.dataType, detail: f.expression });
80
+ }
81
+ for (const c of choices) {
82
+ out.push({
83
+ name: c.name,
84
+ category: 'choice',
85
+ dataType: c.dataType,
86
+ detail: c.kind === 'dynamic' ? 'Dynamic' : undefined,
87
+ });
88
+ }
89
+ for (const t of textTemplates) {
90
+ out.push({ name: t.name, category: 'textTemplate', detail: t.detail });
91
+ }
92
+ for (const s of stages) {
93
+ out.push({ name: s.name, category: 'stage', detail: s.detail });
94
+ }
95
+ // Synthesized: automatic outputs from action/subflow + record elements.
96
+ const autoStores = (tag, makeName, category, objKey) => {
97
+ for (const raw of arr(flow[tag])) {
98
+ const el = raw;
99
+ const name = str(el.name);
100
+ if (!name) {
101
+ continue;
102
+ }
103
+ // Record lookups default to auto-store unless explicitly false; others
104
+ // require storeOutputAutomatically=true.
105
+ const auto = bool(el.storeOutputAutomatically) ||
106
+ (tag === 'recordLookups' && str(el.storeOutputAutomatically) !== 'false');
107
+ if (!auto) {
108
+ continue;
109
+ }
110
+ const label = str(el.label) ?? name;
111
+ out.push({
112
+ name: makeName(label, name),
113
+ category,
114
+ dataType: objKey ? str(el[objKey]) : undefined,
115
+ detail: `from ${label}`,
116
+ });
117
+ }
118
+ };
119
+ autoStores('actionCalls', (label) => `Outputs from ${label}`, 'actionOutput');
120
+ autoStores('subflows', (label) => `Outputs from ${label}`, 'actionOutput');
121
+ autoStores('recordLookups', (label) => label, 'recordOutput', 'object');
122
+ // Create/Update record elements expose a "{Object} from {Label}" record var.
123
+ autoStoresRecord('recordCreates', flow, out);
124
+ // Synthesized: each decision rule is a referenceable "Decision Outcome".
125
+ for (const raw of arr(flow.decisions)) {
126
+ const d = raw;
127
+ for (const ruleRaw of arr(d.rules)) {
128
+ const rule = unwrapRule(ruleRaw);
129
+ const name = str(rule.label) ?? str(rule.name);
130
+ if (name) {
131
+ out.push({
132
+ name,
133
+ category: 'decisionOutcome',
134
+ detail: `from ${str(d.label) ?? str(d.name)}`,
135
+ });
136
+ }
137
+ }
138
+ }
139
+ return out;
140
+ }
@@ -0,0 +1,29 @@
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
+ * Parsing + presentation of the flow's Start element:
9
+ * - `readStartConfig` — raw trigger / schedule / entry-filter shape
10
+ * - `startDetails` — trigger-aware inspector groups
11
+ * - `readCanvasMode` — AUTO_LAYOUT vs FREE_FORM from `<processMetadataValues>`
12
+ * - `humanizeProcessType` — camel-case process-type → display label
13
+ */
14
+ import type { FlowDetailGroup, FlowModel, FlowStartConfig } from '../types/FlowData.js';
15
+ /** Read a `CanvasMode` value from `<processMetadataValues>`. */
16
+ export declare function readCanvasMode(flow: Record<string, unknown>): FlowModel['canvasMode'];
17
+ /** Parse the Start element configuration (trigger, schedule, entry filters). */
18
+ export declare function readStartConfig(startEl: Record<string, unknown> | undefined): FlowStartConfig;
19
+ /**
20
+ * The Start element's configuration as inspector detail groups — so clicking
21
+ * the Start node opens the SAME element-details panel every other element uses
22
+ * (instead of a bespoke flow-level section). Sections are trigger-aware: a
23
+ * record-triggered flow shows its object + entry conditions, a scheduled flow
24
+ * its schedule, an autolaunched/screen flow just "Runs when launched".
25
+ */
26
+ export declare function startDetails(processType: string | undefined, start: FlowStartConfig): FlowDetailGroup[];
27
+ /** "AutoLaunchedFlow" → "Autolaunched Flow", "Flow" → "Screen Flow", etc. */
28
+ export declare function humanizeProcessType(pt: string): string;
29
+ //# sourceMappingURL=startConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startConfig.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flow/parser/startConfig.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,eAAe,EAEf,SAAS,EACT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAI9B,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,YAAY,CAAC,CAWrF;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,eAAe,CAyB7F;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,KAAK,EAAE,eAAe,GACrB,eAAe,EAAE,CAkDnB;AAED,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAWtD"}
@@ -0,0 +1,117 @@
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 { DETAIL_TITLES } from './flowLabels.js';
8
+ import { arr, formatValue, str } from './xmlPrimitives.js';
9
+ /** Read a `CanvasMode` value from `<processMetadataValues>`. */
10
+ export function readCanvasMode(flow) {
11
+ for (const pmv of arr(flow.processMetadataValues)) {
12
+ const rec = pmv;
13
+ if (str(rec.name) === 'CanvasMode') {
14
+ const val = formatValue(rec.value);
15
+ if (val === 'AUTO_LAYOUT_CANVAS' || val === 'FREE_FORM_CANVAS') {
16
+ return val;
17
+ }
18
+ }
19
+ }
20
+ return undefined;
21
+ }
22
+ /** Parse the Start element configuration (trigger, schedule, entry filters). */
23
+ export function readStartConfig(startEl) {
24
+ if (!startEl) {
25
+ return { filters: [] };
26
+ }
27
+ const schedule = startEl.schedule;
28
+ return {
29
+ triggerType: str(startEl.triggerType),
30
+ object: str(startEl.object),
31
+ recordTriggerType: str(startEl.recordTriggerType),
32
+ schedule: schedule
33
+ ? {
34
+ frequency: str(schedule.frequency),
35
+ startDate: str(schedule.startDate),
36
+ startTime: str(schedule.startTime),
37
+ }
38
+ : undefined,
39
+ filterLogic: str(startEl.filterLogic),
40
+ filters: arr(startEl.filters)
41
+ .map((c) => c)
42
+ .map((c) => ({
43
+ label: str(c.field) ?? '',
44
+ value: `${str(c.operator) ?? ''} ${formatValue(c.value) ?? ''}`.trim(),
45
+ }))
46
+ .filter((r) => r.label),
47
+ };
48
+ }
49
+ /**
50
+ * The Start element's configuration as inspector detail groups — so clicking
51
+ * the Start node opens the SAME element-details panel every other element uses
52
+ * (instead of a bespoke flow-level section). Sections are trigger-aware: a
53
+ * record-triggered flow shows its object + entry conditions, a scheduled flow
54
+ * its schedule, an autolaunched/screen flow just "Runs when launched".
55
+ */
56
+ export function startDetails(processType, start) {
57
+ const groups = [];
58
+ const trigger = [];
59
+ if (processType) {
60
+ trigger.push({ label: 'Flow Type', value: humanizeProcessType(processType) });
61
+ }
62
+ if (start.triggerType) {
63
+ trigger.push({ label: 'Trigger', value: start.triggerType });
64
+ }
65
+ if (start.object) {
66
+ trigger.push({ label: 'Object', value: start.object });
67
+ }
68
+ if (start.recordTriggerType) {
69
+ trigger.push({ label: 'Triggered When', value: start.recordTriggerType });
70
+ }
71
+ if (start.schedule?.frequency) {
72
+ trigger.push({ label: 'Frequency', value: start.schedule.frequency });
73
+ }
74
+ if (start.schedule?.startDate) {
75
+ trigger.push({ label: 'Start Date', value: start.schedule.startDate });
76
+ }
77
+ if (start.schedule?.startTime) {
78
+ trigger.push({ label: 'Start Time', value: start.schedule.startTime });
79
+ }
80
+ if (trigger.length) {
81
+ groups.push({ title: DETAIL_TITLES.startConfiguration, rows: trigger });
82
+ }
83
+ else {
84
+ // No trigger metadata (autolaunched / screen flow) — make that explicit.
85
+ groups.push({
86
+ title: DETAIL_TITLES.startConfiguration,
87
+ rows: processType ? [{ label: 'Flow Type', value: humanizeProcessType(processType) }] : [],
88
+ note: 'Runs when the flow is launched (no trigger).',
89
+ });
90
+ }
91
+ // Entry conditions (record-triggered flows that filter which records run).
92
+ if (start.filters.length) {
93
+ groups.push({
94
+ title: DETAIL_TITLES.entryConditions,
95
+ rows: [
96
+ ...(start.filterLogic
97
+ ? [{ label: 'Condition Requirements', value: start.filterLogic }]
98
+ : []),
99
+ ...start.filters,
100
+ ],
101
+ });
102
+ }
103
+ return groups;
104
+ }
105
+ /** "AutoLaunchedFlow" → "Autolaunched Flow", "Flow" → "Screen Flow", etc. */
106
+ export function humanizeProcessType(pt) {
107
+ const map = {
108
+ Flow: 'Screen Flow',
109
+ AutoLaunchedFlow: 'Autolaunched Flow',
110
+ Orchestrator: 'Orchestration',
111
+ };
112
+ if (map[pt]) {
113
+ return map[pt];
114
+ }
115
+ // Generic: split CamelCase into words.
116
+ return pt.replace(/([a-z])([A-Z])/g, '$1 $2');
117
+ }
@@ -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
+ * XML coercion helpers used across the flow parser.
9
+ *
10
+ * The XML parser we consume returns loose `unknown` shapes: attributes may be
11
+ * strings, numbers, booleans, or objects with a `#text` payload; repeated
12
+ * elements collapse to a single object when there is only one occurrence. These
13
+ * helpers normalize those shapes so downstream parser code can treat every
14
+ * value uniformly.
15
+ */
16
+ import { SalesforceXMLParser } from '@salesforce/metadata-core-sdk';
17
+ /** A raw value pulled from the parsed XML tree. */
18
+ export type XmlValue = unknown;
19
+ /** Ensure repeated XML elements are always seen as an array. */
20
+ export declare const arr: typeof SalesforceXMLParser.arrayify;
21
+ /** Read an XML value as a trimmed non-empty string, or undefined. */
22
+ export declare function str(value: XmlValue): string | undefined;
23
+ /** Read an XML value as a finite number, or undefined. */
24
+ export declare function num(value: XmlValue): number | undefined;
25
+ /** Read an XML value as a boolean (case-insensitive "true"). */
26
+ export declare function bool(value: XmlValue): boolean;
27
+ /**
28
+ * Format a `{!ref}`-style reference or literal value for display. Handles the
29
+ * various `<*Value>` wrappers Flow XML uses for typed literals.
30
+ */
31
+ export declare function formatValue(value: XmlValue): string | undefined;
32
+ /**
33
+ * Normalizes a decision `<rules>` entry. Standard Salesforce metadata puts
34
+ * `connector`/`label`/`name` directly inside each repeated `<rules>` element,
35
+ * but some hand-authored / legacy files nest them under an extra `<rule>`
36
+ * wrapper. Descend through `.rule` when present so both shapes resolve.
37
+ */
38
+ export declare function unwrapRule(rule: XmlValue): Record<string, unknown>;
39
+ /** Pulls `<connector><targetReference>` from any element-shaped object. */
40
+ export declare function connectorTarget(connector: XmlValue): string | undefined;
41
+ /**
42
+ * Detect `<isGoTo>true</isGoTo>` on a connector. Flow Builder marks a "Go To"
43
+ * connector this way when the source element jumps to an already-placed
44
+ * downstream element rather than nesting it as a fan-out child.
45
+ */
46
+ export declare function connectorIsGoTo(connector: XmlValue): boolean;
47
+ /**
48
+ * Iterate a repeated XML container and produce a typed list. Skips entries
49
+ * that fail the `name` filter, so callers don't need to repeat the arrify +
50
+ * record-cast + name-filter dance for every resource kind.
51
+ */
52
+ export declare function mapNamedList<T>(container: XmlValue, build: (record: Record<string, unknown>, name: string) => T): T[];
53
+ //# sourceMappingURL=xmlPrimitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmlPrimitives.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flow/parser/xmlPrimitives.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,mDAAmD;AACnD,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC;AAE/B,gEAAgE;AAChE,eAAO,MAAM,GAAG,qCAA+B,CAAC;AAuBhD,qEAAqE;AACrE,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAevD;AAED,0DAA0D;AAC1D,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAOvD;AAED,gEAAgE;AAChE,wBAAgB,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAE7C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAyB/D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASlE;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAKvE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAK5D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,SAAS,EAAE,QAAQ,EACnB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,GAC1D,CAAC,EAAE,CAcL"}
@@ -0,0 +1,152 @@
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
+ * XML coercion helpers used across the flow parser.
9
+ *
10
+ * The XML parser we consume returns loose `unknown` shapes: attributes may be
11
+ * strings, numbers, booleans, or objects with a `#text` payload; repeated
12
+ * elements collapse to a single object when there is only one occurrence. These
13
+ * helpers normalize those shapes so downstream parser code can treat every
14
+ * value uniformly.
15
+ */
16
+ import { SalesforceXMLParser } from '@salesforce/metadata-core-sdk';
17
+ /** Ensure repeated XML elements are always seen as an array. */
18
+ export const arr = SalesforceXMLParser.arrayify;
19
+ /**
20
+ * Decode the five predefined XML entities plus numeric character references.
21
+ * `SalesforceXMLParser` runs with `processEntities: false` for DoS safety, so
22
+ * strings arrive with `&apos;`, `&amp;`, etc. still encoded — we decode here so
23
+ * user-facing text renders as authored (e.g. `variant&apos;s` → `variant's`).
24
+ * `&amp;` is decoded last to avoid double-decoding sequences like `&amp;lt;`.
25
+ */
26
+ function decodeXmlEntities(input) {
27
+ if (input.indexOf('&') === -1) {
28
+ return input;
29
+ }
30
+ return input
31
+ .replace(/&apos;/g, "'")
32
+ .replace(/&quot;/g, '"')
33
+ .replace(/&lt;/g, '<')
34
+ .replace(/&gt;/g, '>')
35
+ .replace(/&#(\d+);/g, (_, dec) => String.fromCodePoint(Number(dec)))
36
+ .replace(/&#[xX]([0-9a-fA-F]+);/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)))
37
+ .replace(/&amp;/g, '&');
38
+ }
39
+ /** Read an XML value as a trimmed non-empty string, or undefined. */
40
+ export function str(value) {
41
+ if (value === undefined || value === null) {
42
+ return undefined;
43
+ }
44
+ if (typeof value === 'string') {
45
+ const trimmed = value.trim();
46
+ return trimmed ? decodeXmlEntities(trimmed) : undefined;
47
+ }
48
+ if (typeof value === 'number' || typeof value === 'boolean') {
49
+ return String(value);
50
+ }
51
+ if (typeof value === 'object' && '#text' in value) {
52
+ return str(value['#text']);
53
+ }
54
+ return undefined;
55
+ }
56
+ /** Read an XML value as a finite number, or undefined. */
57
+ export function num(value) {
58
+ const s = str(value);
59
+ if (s === undefined) {
60
+ return undefined;
61
+ }
62
+ const n = Number(s);
63
+ return Number.isFinite(n) ? n : undefined;
64
+ }
65
+ /** Read an XML value as a boolean (case-insensitive "true"). */
66
+ export function bool(value) {
67
+ return /^true$/i.test(str(value) ?? '');
68
+ }
69
+ /**
70
+ * Format a `{!ref}`-style reference or literal value for display. Handles the
71
+ * various `<*Value>` wrappers Flow XML uses for typed literals.
72
+ */
73
+ export function formatValue(value) {
74
+ if (value === undefined || value === null) {
75
+ return undefined;
76
+ }
77
+ if (typeof value === 'object') {
78
+ const v = value;
79
+ const ref = str(v.elementReference);
80
+ if (ref) {
81
+ return `{!${ref}}`;
82
+ }
83
+ for (const key of [
84
+ 'stringValue',
85
+ 'numberValue',
86
+ 'booleanValue',
87
+ 'dateValue',
88
+ 'dateTimeValue',
89
+ ]) {
90
+ const found = str(v[key]);
91
+ if (found !== undefined) {
92
+ return found;
93
+ }
94
+ }
95
+ return undefined;
96
+ }
97
+ return str(value);
98
+ }
99
+ /**
100
+ * Normalizes a decision `<rules>` entry. Standard Salesforce metadata puts
101
+ * `connector`/`label`/`name` directly inside each repeated `<rules>` element,
102
+ * but some hand-authored / legacy files nest them under an extra `<rule>`
103
+ * wrapper. Descend through `.rule` when present so both shapes resolve.
104
+ */
105
+ export function unwrapRule(rule) {
106
+ if (!rule || typeof rule !== 'object') {
107
+ return {};
108
+ }
109
+ const record = rule;
110
+ if (record.rule && typeof record.rule === 'object' && !Array.isArray(record.rule)) {
111
+ return record.rule;
112
+ }
113
+ return record;
114
+ }
115
+ /** Pulls `<connector><targetReference>` from any element-shaped object. */
116
+ export function connectorTarget(connector) {
117
+ if (!connector || typeof connector !== 'object') {
118
+ return undefined;
119
+ }
120
+ return str(connector.targetReference);
121
+ }
122
+ /**
123
+ * Detect `<isGoTo>true</isGoTo>` on a connector. Flow Builder marks a "Go To"
124
+ * connector this way when the source element jumps to an already-placed
125
+ * downstream element rather than nesting it as a fan-out child.
126
+ */
127
+ export function connectorIsGoTo(connector) {
128
+ if (!connector || typeof connector !== 'object') {
129
+ return false;
130
+ }
131
+ return bool(connector.isGoTo);
132
+ }
133
+ /**
134
+ * Iterate a repeated XML container and produce a typed list. Skips entries
135
+ * that fail the `name` filter, so callers don't need to repeat the arrify +
136
+ * record-cast + name-filter dance for every resource kind.
137
+ */
138
+ export function mapNamedList(container, build) {
139
+ const out = [];
140
+ for (const raw of arr(container)) {
141
+ if (!raw || typeof raw !== 'object') {
142
+ continue;
143
+ }
144
+ const record = raw;
145
+ const name = str(record.name);
146
+ if (!name) {
147
+ continue;
148
+ }
149
+ out.push(build(record, name));
150
+ }
151
+ return out;
152
+ }