@salesforce/metadata-plugins 1.12.0 → 1.14.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 (47) hide show
  1. package/README.md +16 -7
  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/ui/assets/VibeEditComposer-D5GykTkw.js +1 -0
  6. package/dist/plugins/agent/ui/assets/index-nYWtX5pm.js +72 -0
  7. package/dist/plugins/agent/ui/index.html +1 -1
  8. package/dist/plugins/flexipage/ui/assets/VibeEditComposer-CwNZdtC5.js +1 -0
  9. package/dist/plugins/flexipage/ui/assets/index-hFZPLB6p.js +49 -0
  10. package/dist/plugins/flexipage/ui/index.html +1 -1
  11. package/dist/plugins/flow/ui/assets/VibeEditComposer-C36-RsSl.js +1 -0
  12. package/dist/plugins/flow/ui/assets/index-CdpIq7gH.js +49 -0
  13. package/dist/plugins/flow/ui/index.html +1 -1
  14. package/dist/plugins/flowintent/ui/assets/{index-keTVUkzt.js → index-CzlE9StJ.js} +10 -10
  15. package/dist/plugins/flowintent/ui/index.html +1 -1
  16. package/dist/plugins/keyvaluetable/KeyValueTableParser.d.ts +36 -0
  17. package/dist/plugins/keyvaluetable/KeyValueTableParser.d.ts.map +1 -0
  18. package/dist/plugins/keyvaluetable/KeyValueTableParser.js +429 -0
  19. package/dist/plugins/keyvaluetable/KeyValueTableVisualizer.d.ts +29 -0
  20. package/dist/plugins/keyvaluetable/KeyValueTableVisualizer.d.ts.map +1 -0
  21. package/dist/plugins/keyvaluetable/KeyValueTableVisualizer.js +63 -0
  22. package/dist/plugins/keyvaluetable/humanize.d.ts +9 -0
  23. package/dist/plugins/keyvaluetable/humanize.d.ts.map +1 -0
  24. package/dist/plugins/keyvaluetable/humanize.js +15 -0
  25. package/dist/plugins/keyvaluetable/types/KeyValueTableData.d.ts +78 -0
  26. package/dist/plugins/keyvaluetable/types/KeyValueTableData.d.ts.map +1 -0
  27. package/dist/plugins/keyvaluetable/types/KeyValueTableData.js +7 -0
  28. package/dist/plugins/keyvaluetable/ui/assets/index-BMYDJ7MA.js +50 -0
  29. package/dist/plugins/keyvaluetable/ui/assets/index-CxfJGu2l.css +1 -0
  30. package/dist/plugins/keyvaluetable/ui/index.html +14 -0
  31. package/dist/plugins/permissionset/ui/assets/VibeEditComposer-HYu9RPHQ.js +1 -0
  32. package/dist/plugins/permissionset/ui/assets/index-DilBd-cG.js +49 -0
  33. package/dist/plugins/permissionset/ui/index.html +1 -1
  34. package/dist/plugins/schema/ui/assets/VibeEditComposer-Ce9dBbb3.js +1 -0
  35. package/dist/plugins/schema/ui/assets/index-DSSQ6K8b.js +71 -0
  36. package/dist/plugins/schema/ui/index.html +1 -1
  37. package/package.json +3 -3
  38. package/dist/plugins/agent/ui/assets/VibeEditComposer-DUcVZj7o.js +0 -1
  39. package/dist/plugins/agent/ui/assets/index-CQBR1py8.js +0 -72
  40. package/dist/plugins/flexipage/ui/assets/VibeEditComposer-D_ghyOEX.js +0 -1
  41. package/dist/plugins/flexipage/ui/assets/index-Drx_jFoz.js +0 -49
  42. package/dist/plugins/flow/ui/assets/VibeEditComposer-BQFkBtQQ.js +0 -1
  43. package/dist/plugins/flow/ui/assets/index-Bf5YooV4.js +0 -49
  44. package/dist/plugins/permissionset/ui/assets/VibeEditComposer-5LPv39S7.js +0 -1
  45. package/dist/plugins/permissionset/ui/assets/index-B8VEt8Sy.js +0 -49
  46. package/dist/plugins/schema/ui/assets/VibeEditComposer-BDtlZdpl.js +0 -1
  47. package/dist/plugins/schema/ui/assets/index-D0sqEMwp.js +0 -71
@@ -8,7 +8,7 @@
8
8
  <meta charset="UTF-8" />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>Flow Intent Visualizer</title>
11
- <script type="module" crossorigin src="./assets/index-keTVUkzt.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-CzlE9StJ.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-Di3MtBl5.css">
13
13
  <link rel="stylesheet" href="@dist/design-system/platform.css" data-platform-styles="true">
14
14
  </head>
@@ -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 { IMetadataParser, MetadataFileInfo, ValidationResult, IPlatformContext, SalesforceXMLParser, VersionInfo } from '@salesforce/metadata-core-sdk';
8
+ import { KeyValueTableData } from './types/KeyValueTableData.js';
9
+ /**
10
+ * Decode predefined XML entities and numeric character references.
11
+ * `SalesforceXMLParser` runs with `processEntities: false`, so text arrives still
12
+ * encoded (a WebLink's `&amp;` in a URL, JavaScript with `&lt;`). Single pass, so
13
+ * `&amp;lt;` becomes `&lt;`.
14
+ */
15
+ export declare function decodeEntities(text: string): string;
16
+ /** Attribute / text-node keys the XML parser adds alongside real elements. */
17
+ export declare function isAttributeKey(key: string): boolean;
18
+ /** Flatten an XML value to display text; undefined when it has nothing to show. */
19
+ export declare function toText(value: unknown): string | undefined;
20
+ export declare function basename(filePath: string): string;
21
+ export declare class KeyValueTableParser implements IMetadataParser<KeyValueTableData> {
22
+ private platformContext?;
23
+ private logger?;
24
+ private telemetry?;
25
+ readonly xmlParser: SalesforceXMLParser;
26
+ setPlatformContext(context: IPlatformContext): void;
27
+ parse(filePath: string, _versionInfo: VersionInfo): Promise<KeyValueTableData>;
28
+ extractMetadataInfo(data: KeyValueTableData): MetadataFileInfo | null;
29
+ validate(data: KeyValueTableData): ValidationResult;
30
+ private transform;
31
+ private deriveStatus;
32
+ /** ".../objects/Book__c/webLinks/X.webLink-meta.xml" (or fieldSets/, listViews/, ...) → "Book__c" */
33
+ private deriveObjectName;
34
+ private buildList;
35
+ }
36
+ //# sourceMappingURL=KeyValueTableParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyValueTableParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/keyvaluetable/KeyValueTableParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAYJ,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAGhB,mBAAmB,EACnB,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,iBAAiB,EAIlB,MAAM,8BAA8B,CAAC;AA+EtC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWnD;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEnD;AAOD,mFAAmF;AACnF,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CA2BzD;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjD;AA6HD,qBAAa,mBAAoB,YAAW,eAAe,CAAC,iBAAiB,CAAC;IAC5E,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,SAAS,CAAC,CAAa;IAG/B,QAAQ,CAAC,SAAS,sBAAqD;IAEvE,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAM7C,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8EpF,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI;IAIrE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB;IAUnD,OAAO,CAAC,SAAS;IAyGjB,OAAO,CAAC,YAAY;IASpB,qGAAqG;IACrG,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,SAAS;CAqBlB"}
@@ -0,0 +1,429 @@
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
+ * Key/value + list metadata parser.
9
+ *
10
+ * Maps the root element's top-level children to key/value entries. Nothing is
11
+ * configured per metadata type: the layout is inferred from the XML. Repeated object
12
+ * children become tables (one column per distinct child key), a wide lone object
13
+ * becomes a Field / Value table, and anything nested deeper becomes a tree.
14
+ */
15
+ import { humanize } from './humanize.js';
16
+ import { SalesforceXMLParser, ErrorBuilder, ErrorCategory, } from '@salesforce/metadata-core-sdk';
17
+ import { isPluginError } from '../../shared/utils/isPluginError.js';
18
+ /** A lone object with more keys than this reads better as a Field / Value table than as one wide row. */
19
+ const MAX_ROW_COLUMNS = 4;
20
+ /**
21
+ * Root element names of the metadata types this plugin claims. `metadataType` comes
22
+ * from the file's own root element, so only these values may reach telemetry or logs.
23
+ */
24
+ const KNOWN_METADATA_TYPES = new Set([
25
+ 'CustomMetadata',
26
+ 'CustomPermission',
27
+ 'CustomTab',
28
+ 'FieldSet',
29
+ 'GlobalValueSet',
30
+ 'CustomLabels',
31
+ 'ListView',
32
+ 'StandardValueSet',
33
+ 'GlobalValueSetTranslation',
34
+ 'StandardValueSetTranslation',
35
+ 'WorkflowAlert',
36
+ 'BusinessProcess',
37
+ 'WebLink',
38
+ 'RemoteSiteSetting',
39
+ 'FieldSrcTrgtRelationship',
40
+ 'SharingReason',
41
+ 'FeatureParameterInteger',
42
+ 'FeatureParameterBoolean',
43
+ 'CompactLayout',
44
+ 'Role',
45
+ 'Group',
46
+ 'Profile',
47
+ 'ReportFolder',
48
+ 'DocumentFolder',
49
+ 'EmailFolder',
50
+ 'WorkflowFieldUpdate',
51
+ ]);
52
+ /** Telemetry-safe metadata type: the known root name, or `unknown`. */
53
+ function telemetryMetadataType(metadataType) {
54
+ return KNOWN_METADATA_TYPES.has(metadataType) ? metadataType : 'unknown';
55
+ }
56
+ /** Fixed `parse_error` reason from the error category — never the message text. */
57
+ function errorReason(error) {
58
+ if (!isPluginError(error)) {
59
+ return 'unexpected';
60
+ }
61
+ switch (error.category) {
62
+ case ErrorCategory.Dependency:
63
+ return 'read_failed';
64
+ case ErrorCategory.Parsing:
65
+ return 'parse_failed';
66
+ default:
67
+ return 'unexpected';
68
+ }
69
+ }
70
+ const XML_ENTITIES = {
71
+ lt: '<',
72
+ gt: '>',
73
+ amp: '&',
74
+ quot: '"',
75
+ apos: "'",
76
+ };
77
+ /**
78
+ * Decode predefined XML entities and numeric character references.
79
+ * `SalesforceXMLParser` runs with `processEntities: false`, so text arrives still
80
+ * encoded (a WebLink's `&amp;` in a URL, JavaScript with `&lt;`). Single pass, so
81
+ * `&amp;lt;` becomes `&lt;`.
82
+ */
83
+ export function decodeEntities(text) {
84
+ return text.replace(/&(?:#(\d+)|#x([0-9a-fA-F]+)|(lt|gt|amp|quot|apos));/g, (m, dec, hex, name) => {
85
+ if (name) {
86
+ return XML_ENTITIES[name];
87
+ }
88
+ const code = dec !== undefined ? parseInt(dec, 10) : parseInt(hex ?? '', 16);
89
+ return code <= 0x10ffff ? String.fromCodePoint(code) : m;
90
+ });
91
+ }
92
+ /** Attribute / text-node keys the XML parser adds alongside real elements. */
93
+ export function isAttributeKey(key) {
94
+ return key.startsWith('@_') || key === '#text' || key.startsWith('?');
95
+ }
96
+ /** True when the object holds at least one child element (not just attributes / text). */
97
+ function hasElementChildren(obj) {
98
+ return Object.keys(obj).some((k) => !isAttributeKey(k));
99
+ }
100
+ /** Flatten an XML value to display text; undefined when it has nothing to show. */
101
+ export function toText(value) {
102
+ if (typeof value === 'string') {
103
+ return decodeEntities(value).trim() || undefined;
104
+ }
105
+ if (typeof value === 'number' || typeof value === 'boolean') {
106
+ return String(value);
107
+ }
108
+ if (Array.isArray(value)) {
109
+ const parts = value.map(toText).filter((v) => v !== undefined);
110
+ return parts.length ? parts.join(', ') : undefined;
111
+ }
112
+ if (value && typeof value === 'object') {
113
+ const obj = value;
114
+ // `<url xml:lang="en">text</url>`: attributes plus text, no child elements.
115
+ if (!hasElementChildren(obj) && '#text' in obj) {
116
+ return toText(obj['#text']);
117
+ }
118
+ const lines = Object.entries(obj)
119
+ .filter(([k]) => !isAttributeKey(k))
120
+ .map(([k, v]) => {
121
+ const text = toText(v);
122
+ return text === undefined ? undefined : `${k}: ${text}`;
123
+ })
124
+ .filter((v) => v !== undefined);
125
+ return lines.length ? lines.join('\n') : undefined;
126
+ }
127
+ return undefined;
128
+ }
129
+ export function basename(filePath) {
130
+ return filePath.split(/[\\/]/).pop() ?? filePath;
131
+ }
132
+ /** One XML value as a table cell text; nested elements fall back to `key: value` lines. */
133
+ function cell(value) {
134
+ return toText(value) ?? '';
135
+ }
136
+ /** First non-empty text among the given XML values (label, masterLabel, name, ...). */
137
+ function firstText(...values) {
138
+ return values.map(cell).find((v) => v !== '');
139
+ }
140
+ function toArray(value) {
141
+ return value === undefined || value === null ? [] : Array.isArray(value) ? value : [value];
142
+ }
143
+ /** Levels and nodes rendered per tree; recursive types (Report blocks, bot steps) hit these, not the end. */
144
+ const MAX_TREE_DEPTH = 10;
145
+ const MAX_TREE_NODES = 1500;
146
+ /** 0 for text, 1 for an element of text children, 2 once an element holds another element, ... */
147
+ function depthOf(value, level = 0) {
148
+ if (level > MAX_TREE_DEPTH) {
149
+ return level;
150
+ }
151
+ if (Array.isArray(value)) {
152
+ return value.reduce((max, v) => Math.max(max, depthOf(v, level)), 0);
153
+ }
154
+ if (value && typeof value === 'object') {
155
+ const kids = Object.entries(value).filter(([k]) => !isAttributeKey(k));
156
+ // `<x xml:lang="en">text</x>`: attributes plus text is a scalar, not a nested element.
157
+ if (kids.length === 0 && '#text' in value) {
158
+ return 0;
159
+ }
160
+ return 1 + kids.reduce((max, [, v]) => Math.max(max, depthOf(v, level + 1)), 0);
161
+ }
162
+ return 0;
163
+ }
164
+ function summaryOf(obj) {
165
+ return firstText(obj.name, obj.label, obj.fullName, obj.masterLabel, obj.apiName, obj.field, obj.title, obj.header, obj.developerName);
166
+ }
167
+ function buildTreeNodes(key, raw, level, budget) {
168
+ if (Array.isArray(raw)) {
169
+ return raw.flatMap((item) => buildTreeNodes(key, item, level, budget));
170
+ }
171
+ if (budget.left <= 0) {
172
+ budget.truncated = true;
173
+ return [];
174
+ }
175
+ budget.left -= 1;
176
+ if (!raw || typeof raw !== 'object') {
177
+ const value = toText(raw);
178
+ return value === undefined ? [] : [{ key, value }];
179
+ }
180
+ const obj = raw;
181
+ if (!hasElementChildren(obj)) {
182
+ const value = toText(obj);
183
+ return value === undefined ? [] : [{ key, value }];
184
+ }
185
+ const node = { key, summary: summaryOf(obj) };
186
+ const entries = Object.entries(obj).filter(([k]) => !isAttributeKey(k));
187
+ if (level >= MAX_TREE_DEPTH) {
188
+ // Too deep to expand further: keep this element's own fields, drop nested elements.
189
+ node.children = entries
190
+ .filter(([, v]) => depthOf(v) === 0)
191
+ .flatMap(([k, v]) => buildTreeNodes(k, v, level + 1, budget));
192
+ node.truncated = true;
193
+ budget.truncated = true;
194
+ return [node];
195
+ }
196
+ node.children = entries.flatMap(([k, v]) => buildTreeNodes(k, v, level + 1, budget));
197
+ return [node];
198
+ }
199
+ function buildTree(element, raw) {
200
+ const budget = { left: MAX_TREE_NODES, truncated: false };
201
+ const nodes = buildTreeNodes(element, raw, 1, budget);
202
+ return {
203
+ title: humanize(element),
204
+ nodes,
205
+ nodeCount: MAX_TREE_NODES - budget.left,
206
+ truncated: budget.truncated,
207
+ };
208
+ }
209
+ /** Table layout for a repeated element: one column per distinct child key, in first-seen order. */
210
+ function tableSpecFor(element, items) {
211
+ const keys = [];
212
+ for (const item of items) {
213
+ if (item && typeof item === 'object') {
214
+ for (const k of Object.keys(item)) {
215
+ if (!isAttributeKey(k) && !keys.includes(k)) {
216
+ keys.push(k);
217
+ }
218
+ }
219
+ }
220
+ }
221
+ return {
222
+ element,
223
+ title: humanize(element),
224
+ columns: keys.length
225
+ ? keys.map((k) => ({ header: humanize(k), key: k }))
226
+ : [{ header: humanize(element) }],
227
+ };
228
+ }
229
+ export class KeyValueTableParser {
230
+ constructor() {
231
+ // Keep every value as text: `005xx...`-style IDs and `007` must not become numbers.
232
+ this.xmlParser = new SalesforceXMLParser({ parseTagValue: false });
233
+ }
234
+ setPlatformContext(context) {
235
+ this.platformContext = context;
236
+ this.logger = context.logger.createChild('KeyValueTableParser');
237
+ this.telemetry = context.telemetry.createChild({ component: 'KeyValueTableParser' });
238
+ }
239
+ async parse(filePath, _versionInfo) {
240
+ const fileName = basename(filePath);
241
+ if (!this.platformContext) {
242
+ throw ErrorBuilder.create()
243
+ .category(ErrorCategory.Configuration)
244
+ .message('KeyValueTableParser not initialized with platform context')
245
+ .context({ fileName })
246
+ .build();
247
+ }
248
+ const ctx = this.platformContext;
249
+ const log = this.logger ?? ctx.logger.createChild('KeyValueTableParser');
250
+ const telemetry = this.telemetry ?? ctx.telemetry.createChild({ component: 'KeyValueTableParser' });
251
+ return telemetry.withSpan('keyvaluetable.parse', async (span) => {
252
+ try {
253
+ const readResult = await ctx.fileSystem.readFile(filePath);
254
+ if (!readResult.success || !readResult.data) {
255
+ throw ErrorBuilder.create()
256
+ .category(ErrorCategory.Dependency)
257
+ .message(`Failed to read file: ${readResult.error?.message ?? 'file is empty or unreadable'}`)
258
+ .context({ fileName })
259
+ .build();
260
+ }
261
+ span.setAttribute('sourceLength', String(readResult.data.length));
262
+ const data = this.transform(readResult.data, filePath);
263
+ data.filePath = filePath;
264
+ // Counts and allowlisted names only — customer-authored names and values never
265
+ // reach telemetry or logs.
266
+ const metadataType = telemetryMetadataType(data.metadataType);
267
+ const entryCount = data.metadata.entryCount;
268
+ const listRowCount = data.lists.reduce((n, l) => n + l.rows.length, 0);
269
+ // A file with nothing in it is legitimate but worth tracking, so a regression in
270
+ // layout inference doesn't hide behind it.
271
+ if (entryCount === 0 && listRowCount === 0 && !data.trees?.length) {
272
+ telemetry.sendEvent('keyvaluetable.parse_incomplete', { pluginId: 'keyvaluetable', metadataType, reason: 'no_entries' }, { entryCount, listRowCount });
273
+ log.warn(`Parsed ${metadataType} with no entries or rows`);
274
+ }
275
+ telemetry.sendEvent('keyvaluetable.parse_complete', { pluginId: 'keyvaluetable', metadataType }, { entryCount, listRowCount });
276
+ log.info(`Parsed ${metadataType} (entries=${entryCount})`);
277
+ return data;
278
+ }
279
+ catch (error) {
280
+ telemetry.sendEvent('keyvaluetable.parse_error', { pluginId: 'keyvaluetable', reason: errorReason(error) }, {});
281
+ if (isPluginError(error)) {
282
+ throw error;
283
+ }
284
+ throw ErrorBuilder.create()
285
+ .category(ErrorCategory.Parsing)
286
+ .message(error instanceof Error ? error.message : String(error))
287
+ .context({ fileName })
288
+ .build();
289
+ }
290
+ }, { pluginId: 'keyvaluetable' });
291
+ }
292
+ extractMetadataInfo(data) {
293
+ return data.apiName ? { label: data.title } : null;
294
+ }
295
+ validate(data) {
296
+ const warnings = [];
297
+ if (data.status && !data.status.active) {
298
+ warnings.push(`${data.apiName}: ${data.metadataTypeLabel} is inactive`);
299
+ }
300
+ return { valid: true, errors: [], warnings };
301
+ }
302
+ // ─── Private helpers ───────────────────────────────────────────────
303
+ transform(xmlContent, filePath) {
304
+ const fileName = basename(filePath);
305
+ let parsed;
306
+ try {
307
+ parsed = this.xmlParser.parse(xmlContent);
308
+ }
309
+ catch {
310
+ throw ErrorBuilder.create()
311
+ .category(ErrorCategory.Parsing)
312
+ .message('Invalid XML in metadata file')
313
+ .context({ fileName })
314
+ .build();
315
+ }
316
+ const metadataType = Object.keys(parsed).find((k) => !isAttributeKey(k));
317
+ // A self-closed root (`<WebLink/>`) parses to '': a valid file with nothing in it.
318
+ const root = metadataType
319
+ ? parsed[metadataType] === ''
320
+ ? {}
321
+ : parsed[metadataType]
322
+ : undefined;
323
+ if (!metadataType || !root || typeof root !== 'object' || Array.isArray(root)) {
324
+ throw ErrorBuilder.create()
325
+ .category(ErrorCategory.Parsing)
326
+ .message('Invalid metadata: expected a single root element with child elements')
327
+ .context({ fileName })
328
+ .build();
329
+ }
330
+ const fields = root;
331
+ const entries = [];
332
+ const trees = [];
333
+ const lists = [];
334
+ const objectLists = [];
335
+ for (const [key, raw] of Object.entries(fields)) {
336
+ if (isAttributeKey(key)) {
337
+ continue;
338
+ }
339
+ if (depthOf(raw) > 1) {
340
+ trees.push(buildTree(key, raw));
341
+ continue;
342
+ }
343
+ if (raw &&
344
+ typeof raw === 'object' &&
345
+ !Array.isArray(raw) &&
346
+ hasElementChildren(raw)) {
347
+ const obj = raw;
348
+ const keys = Object.keys(obj).filter((k) => !isAttributeKey(k));
349
+ // A narrow lone object is a one-row table, so it looks the same whether the file has one
350
+ // or two of them (`values`). Field / Value rows fit better when it is wide (`loginHours`),
351
+ // repeats a child (`sharedTo`'s `<role>`s) or holds only empty children (`<allInternalUsers/>`).
352
+ const asFieldValue = keys.length > MAX_ROW_COLUMNS ||
353
+ keys.some((k) => Array.isArray(obj[k])) ||
354
+ keys.every((k) => cell(obj[k]) === '');
355
+ if (!asFieldValue) {
356
+ lists.push(this.buildList(tableSpecFor(key, [raw]), raw));
357
+ continue;
358
+ }
359
+ const rows = keys.flatMap((k) => toArray(obj[k]).map((item) => [humanize(k), cell(item)]));
360
+ objectLists.push({ title: humanize(key), columns: ['Field', 'Value'], rows });
361
+ continue;
362
+ }
363
+ // Several objects or several plain values of one element read best as a table.
364
+ if (Array.isArray(raw) &&
365
+ (raw.length > 1 || raw.some((item) => item && typeof item === 'object'))) {
366
+ lists.push(this.buildList(tableSpecFor(key, raw), raw));
367
+ continue;
368
+ }
369
+ const value = toText(raw);
370
+ if (value !== undefined) {
371
+ entries.push({ key, value });
372
+ }
373
+ }
374
+ const nonEmptyLists = lists.filter((l) => l.rows.length > 0);
375
+ nonEmptyLists.push(...objectLists);
376
+ // `Name.suffix-meta.xml` → `Name`; the name itself may contain dots (custom metadata records).
377
+ const baseName = basename(filePath);
378
+ const fileBase = /\.[^.]+-meta\.xml$/.test(baseName)
379
+ ? baseName.replace(/\.[^.]+-meta\.xml$/, '')
380
+ : baseName.replace(/\.[^.]+$/, '');
381
+ const apiName = toText(fields.fullName) ?? fileBase;
382
+ return {
383
+ apiName,
384
+ filePath,
385
+ metadataType,
386
+ metadataTypeLabel: humanize(metadataType),
387
+ objectName: this.deriveObjectName(filePath),
388
+ title: firstText(fields.label, fields.masterLabel, fields.name, fields.fullName) ?? fileBase,
389
+ description: toText(fields.description),
390
+ status: this.deriveStatus(fields),
391
+ license: firstText(fields.license, fields.userLicense),
392
+ entries,
393
+ lists: nonEmptyLists,
394
+ ...(trees.length ? { trees } : {}),
395
+ metadata: { parsedAt: new Date().toISOString(), entryCount: entries.length },
396
+ };
397
+ }
398
+ deriveStatus(fields) {
399
+ const raw = toText(fields.isActive);
400
+ if (raw === undefined) {
401
+ return undefined;
402
+ }
403
+ const active = raw.toLowerCase() === 'true';
404
+ return { label: active ? 'Active' : 'Inactive', active };
405
+ }
406
+ /** ".../objects/Book__c/webLinks/X.webLink-meta.xml" (or fieldSets/, listViews/, ...) → "Book__c" */
407
+ deriveObjectName(filePath) {
408
+ return (filePath.match(/[\\/]objects[\\/]([^\\/]+)[\\/](?:fieldSets|listViews|businessProcesses|webLinks|sharingReasons|compactLayouts)[\\/]/)?.[1] ?? filePath.match(/[\\/]workflows[\\/]([^\\/]+)[\\/]/)?.[1]);
409
+ }
410
+ buildList(spec, raw) {
411
+ const columns = spec.columns.map((c) => c.header);
412
+ const rows = toArray(raw)
413
+ .map((item) => spec.columns.map((c, i) => {
414
+ if (c.key && item && typeof item === 'object' && !Array.isArray(item)) {
415
+ return cell(item[c.key]);
416
+ }
417
+ // A bare string fills the first column only, not every column.
418
+ return c.key && i > 0 ? '' : cell(item);
419
+ }))
420
+ .filter((row) => row.some((v) => v !== ''));
421
+ // Drop columns no row fills, so a sparse union of keys stays readable.
422
+ const keep = spec.columns.map((_, i) => rows.some((r) => r[i] !== ''));
423
+ return {
424
+ title: spec.title,
425
+ columns: columns.filter((_, i) => keep[i]),
426
+ rows: rows.map((r) => r.filter((_, i) => keep[i])),
427
+ };
428
+ }
429
+ }
@@ -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
+ * Key/Value Table Visualizer Plugin
9
+ *
10
+ * Flat metadata with optional repeated child lists, for the 26 file patterns below (the parser
11
+ * infers each file's layout from its XML, so a type needs only a pattern here): CustomMetadata, Custom Labels, List Views, Field Sets,
12
+ * Value Sets and their translations, Custom Tabs, Profiles, the Report/Document/Email Folders,
13
+ * Compact Layouts and the rest. Overview card, a Field / Value table for the scalar fields,
14
+ * and one table per repeated list.
15
+ */
16
+ import { IVisualizationPlugin, MetadataPluginInfo, IPlatformContext } from '@salesforce/metadata-core-sdk';
17
+ import { KeyValueTableData } from './types/KeyValueTableData.js';
18
+ import { KeyValueTableParser } from './KeyValueTableParser.js';
19
+ export declare class KeyValueTableVisualizer implements IVisualizationPlugin<KeyValueTableData> {
20
+ private readonly pluginMetadata;
21
+ readonly parser: KeyValueTableParser;
22
+ private logger?;
23
+ constructor();
24
+ getMetadataPluginInfo(): MetadataPluginInfo;
25
+ canHandle(filePath: string): boolean;
26
+ initialize(context: IPlatformContext): Promise<void>;
27
+ dispose?(): void;
28
+ }
29
+ //# sourceMappingURL=KeyValueTableVisualizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyValueTableVisualizer.d.ts","sourceRoot":"","sources":["../../../src/plugins/keyvaluetable/KeyValueTableVisualizer.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;GAQG;AAEH,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,qBAAa,uBAAwB,YAAW,oBAAoB,CAAC,iBAAiB,CAAC;IACrF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAoC7B;IAEF,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAErC,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,63 @@
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 { KeyValueTableParser } from './KeyValueTableParser.js';
8
+ import { matchesFilePattern } from '../../shared/utils/patternMatcher.js';
9
+ export class KeyValueTableVisualizer {
10
+ constructor() {
11
+ this.pluginMetadata = {
12
+ id: 'keyvaluetable',
13
+ name: 'Salesforce Key-Value Table Metadata Visualizer',
14
+ displayName: 'Key-Value Table',
15
+ description: 'Overview, field table and list tables for Custom Metadata records, Custom Permissions, Field Sets, Global/Standard Value Sets, List Views, Custom Tabs, Custom Labels, Value Set Translations, Workflow Alerts, Business Processes, Web Links, Remote Site Settings, Field Source-Target Relationships, Sharing Reasons, Feature Parameters, Compact Layouts, Workflow Field Updates, Roles, Public Groups, Profiles, Report/Document/Email Folders',
16
+ author: 'Metadata Visualizer Team',
17
+ filePatterns: [
18
+ '.md-meta.xml',
19
+ '.customPermission-meta.xml',
20
+ '.tab-meta.xml',
21
+ '.fieldSet-meta.xml',
22
+ '.globalValueSet-meta.xml',
23
+ '.labels-meta.xml',
24
+ '.listView-meta.xml',
25
+ '.standardValueSet-meta.xml',
26
+ '.globalValueSetTranslation-meta.xml',
27
+ '.standardValueSetTranslation-meta.xml',
28
+ '.workflowAlert-meta.xml',
29
+ '.businessProcess-meta.xml',
30
+ '.webLink-meta.xml',
31
+ '.remoteSite-meta.xml',
32
+ '.fieldSrcTrgtRelationship-meta.xml',
33
+ '.sharingReason-meta.xml',
34
+ '.featureParameterInteger-meta.xml',
35
+ '.featureParameterBoolean-meta.xml',
36
+ '.compactLayout-meta.xml',
37
+ '.role-meta.xml',
38
+ '.group-meta.xml',
39
+ '.profile-meta.xml',
40
+ '.reportFolder-meta.xml',
41
+ '.documentFolder-meta.xml',
42
+ '.emailFolder-meta.xml',
43
+ '.workflowFieldUpdate-meta.xml',
44
+ ],
45
+ priority: 10,
46
+ };
47
+ this.parser = new KeyValueTableParser();
48
+ }
49
+ getMetadataPluginInfo() {
50
+ return this.pluginMetadata;
51
+ }
52
+ canHandle(filePath) {
53
+ return this.getMetadataPluginInfo().filePatterns.some((pattern) => matchesFilePattern(filePath, pattern));
54
+ }
55
+ async initialize(context) {
56
+ this.logger = context.logger.createChild(this.getMetadataPluginInfo().id);
57
+ this.logger.info('Key-Value Table visualizer initialized');
58
+ this.parser.setPlatformContext(context);
59
+ }
60
+ dispose() {
61
+ this.logger?.info(`Disposing ${this.getMetadataPluginInfo().name}`);
62
+ }
63
+ }
@@ -0,0 +1,9 @@
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
+ /** `disableProtocolSecurity` / `remote_site` / `ISBNCode` → `Disable Protocol Security` / `Remote site` / `ISBN Code`. */
8
+ export declare function humanize(name: string): string;
9
+ //# sourceMappingURL=humanize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"humanize.d.ts","sourceRoot":"","sources":["../../../src/plugins/keyvaluetable/humanize.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,0HAA0H;AAC1H,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO7C"}
@@ -0,0 +1,15 @@
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
+ /** `disableProtocolSecurity` / `remote_site` / `ISBNCode` → `Disable Protocol Security` / `Remote site` / `ISBN Code`. */
8
+ export function humanize(name) {
9
+ const spaced = name
10
+ .replace(/[_-]+/g, ' ')
11
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
12
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
13
+ .trim();
14
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
15
+ }