@salesforce/metadata-plugins 1.8.0 → 1.10.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 (28) hide show
  1. package/README.md +15 -6
  2. package/dist/plugins/agent/AgentParser.d.ts.map +1 -1
  3. package/dist/plugins/agent/AgentParser.js +70 -27
  4. package/dist/plugins/flow/ui/assets/{index-DJP9DbPL.js → index-OhJU6yxp.js} +1 -1
  5. package/dist/plugins/flow/ui/index.html +1 -1
  6. package/dist/plugins/permissionset/PermissionSetParser.d.ts +9 -1
  7. package/dist/plugins/permissionset/PermissionSetParser.d.ts.map +1 -1
  8. package/dist/plugins/permissionset/PermissionSetParser.js +12 -0
  9. package/dist/plugins/permissionset/objectGrouping.d.ts +112 -0
  10. package/dist/plugins/permissionset/objectGrouping.d.ts.map +1 -0
  11. package/dist/plugins/permissionset/objectGrouping.js +140 -0
  12. package/dist/plugins/permissionset/permissionsetSelectionGraph.d.ts +88 -0
  13. package/dist/plugins/permissionset/permissionsetSelectionGraph.d.ts.map +1 -0
  14. package/dist/plugins/permissionset/permissionsetSelectionGraph.js +277 -0
  15. package/dist/plugins/permissionset/sectionKeys.d.ts +45 -0
  16. package/dist/plugins/permissionset/sectionKeys.d.ts.map +1 -0
  17. package/dist/plugins/permissionset/sectionKeys.js +58 -0
  18. package/dist/plugins/permissionset/types/PermissionSetData.d.ts +9 -0
  19. package/dist/plugins/permissionset/types/PermissionSetData.d.ts.map +1 -1
  20. package/dist/plugins/permissionset/ui/assets/index-CMInRbR2.js +48 -0
  21. package/dist/plugins/permissionset/ui/assets/index-DqEUhEQc.css +1 -0
  22. package/dist/plugins/permissionset/ui/index.html +2 -2
  23. package/dist/plugins/schema/ui/assets/{index-BHwyhVGF.js → index-CWvLR0Fz.js} +9 -9
  24. package/dist/plugins/schema/ui/assets/{index-Cp1nVgsx.css → index-EHPZb2E3.css} +1 -1
  25. package/dist/plugins/schema/ui/index.html +2 -2
  26. package/package.json +2 -2
  27. package/dist/plugins/permissionset/ui/assets/index-C13KEtFH.js +0 -48
  28. package/dist/plugins/permissionset/ui/assets/index-CMOgdp7q.css +0 -1
package/README.md CHANGED
@@ -11,12 +11,13 @@ This package provides metadata visualization plugins that parse Salesforce XML m
11
11
 
12
12
  ## Supported Metadata Types
13
13
 
14
- | Metadata Type | File Pattern | Plugin ID | Description |
15
- | ------------- | ------------------------------------- | ----------- | ------------------------------------------------------------------- |
16
- | FlexiPages | `.flexipage-meta.xml` | `flexipage` | Lightning Page layout visualization |
17
- | Data Model | `.object-meta.xml`, `.field-meta.xml` | `schema` | Interactive ERD visualization of objects, fields, and relationships |
18
- | Agent Script | `.agent` | `agent` | Agent script visualization |
19
- | Flow | `.flow-meta.xml` | `flow` | Interactive Flow diagram with decisions, loops, and fault paths |
14
+ | Metadata Type | File Pattern | Plugin ID | Description |
15
+ | -------------- | ------------------------------------------- | --------------- | ---------------------------------------------------------------------------------- |
16
+ | FlexiPages | `.flexipage-meta.xml` | `flexipage` | Lightning Page layout visualization |
17
+ | Data Model | `.object-meta.xml`, `.field-meta.xml` | `schema` | Interactive ERD visualization of objects, fields, and relationships |
18
+ | Agent Script | `.agent` | `agent` | Agent script visualization |
19
+ | Flow | `.flow-meta.xml` | `flow` | Interactive Flow diagram with decisions, loops, and fault paths |
20
+ | Permission Set | `.permissionset-meta.xml`, `.permissionset` | `permissionset` | Permission set overview — object, field, tab, record-type, and named-access grants |
20
21
 
21
22
  ## Installation
22
23
 
@@ -61,12 +62,14 @@ import {
61
62
  SchemaVisualizer,
62
63
  AgentVisualizer,
63
64
  FlowVisualizer,
65
+ PermissionSetVisualizer,
64
66
  } from '@salesforce/metadata-plugins';
65
67
 
66
68
  const flexipageViz = new FlexipageVisualizer();
67
69
  const schemaViz = new SchemaVisualizer();
68
70
  const agentViz = new AgentVisualizer();
69
71
  const flowViz = new FlowVisualizer();
72
+ const permissionSetViz = new PermissionSetVisualizer();
70
73
 
71
74
  // Check plugin metadata
72
75
  const info = schemaViz.getMetadataPluginInfo();
@@ -86,6 +89,7 @@ console.log(info.filePatterns); // ['.object-meta.xml', '.field-meta.xml']
86
89
  - **`SchemaVisualizer`** — Implements `IVisualizationPlugin<SchemaERDData>` for Custom Object and Field metadata
87
90
  - **`AgentVisualizer`** — Implements `IVisualizationPlugin<AgentScriptData>` for Agent script metadata
88
91
  - **`FlowVisualizer`** — Implements `IVisualizationPlugin<FlowModel>` for Flow metadata
92
+ - **`PermissionSetVisualizer`** — Implements `IVisualizationPlugin<PermissionSetData>` for Permission Set metadata
89
93
 
90
94
  ### Parsers
91
95
 
@@ -93,6 +97,7 @@ console.log(info.filePatterns); // ['.object-meta.xml', '.field-meta.xml']
93
97
  - **`SchemaParser`** — Implements `IMetadataParser<SchemaERDData>`
94
98
  - **`AgentParser`** — Implements `IMetadataParser<AgentScriptData>`
95
99
  - **`FlowParser`** — Implements `IMetadataParser<FlowModel>`
100
+ - **`PermissionSetParser`** — Implements `IMetadataParser<PermissionSetData>`
96
101
 
97
102
  ### Types
98
103
 
@@ -100,6 +105,7 @@ console.log(info.filePatterns); // ['.object-meta.xml', '.field-meta.xml']
100
105
  - **`SchemaERDData`** — Parsed ERD data with objects, fields, and relationships
101
106
  - **`AgentScriptData`** — Parsed Agent script structure
102
107
  - **`FlowModel`** — Parsed Flow structure with nodes, connectors, and metadata
108
+ - **`PermissionSetData`** — Parsed Permission Set structure with object, field, tab, record-type, and named-access grants
103
109
 
104
110
  ## Package Exports
105
111
 
@@ -110,6 +116,7 @@ import {
110
116
  SchemaVisualizer,
111
117
  AgentVisualizer,
112
118
  FlowVisualizer,
119
+ PermissionSetVisualizer,
113
120
  getAllVisualizers,
114
121
  } from '@salesforce/metadata-plugins';
115
122
 
@@ -119,6 +126,7 @@ import {
119
126
  SchemaParser,
120
127
  AgentParser,
121
128
  FlowParser,
129
+ PermissionSetParser,
122
130
  } from '@salesforce/metadata-plugins';
123
131
 
124
132
  // Types
@@ -127,6 +135,7 @@ import type {
127
135
  SchemaERDData,
128
136
  AgentScriptData,
129
137
  FlowModel,
138
+ PermissionSetData,
130
139
  } from '@salesforce/metadata-plugins';
131
140
  ```
132
141
 
@@ -1 +1 @@
1
- {"version":3,"file":"AgentParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent/AgentParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EAGX,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAoD7D,qBAAa,WAAY,YAAW,eAAe,CAAC,eAAe,CAAC;IAClE,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,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,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IA+HlF;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI;IAKnE;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,EAAE;CAG5D"}
1
+ {"version":3,"file":"AgentParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/agent/AgentParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EAGX,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAqF7D,qBAAa,WAAY,YAAW,eAAe,CAAC,eAAe,CAAC;IAClE,OAAO,CAAC,eAAe,CAAC,CAAmB;IAC3C,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,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC;IA2IlF;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI;IAKnE;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,EAAE;CAG5D"}
@@ -31,6 +31,19 @@ import { astToOverviewGraph } from './extract/ast-to-graph.js';
31
31
  * blocks visualization — warnings/info/hints are non-fatal.
32
32
  */
33
33
  const LSP_SEVERITY_ERROR = 1;
34
+ /**
35
+ * Rule codes that the AgentScript parser flags at severity=Error but which
36
+ * leave the AST intact and the graph renderable. We surface these as warnings
37
+ * rather than failing the parse. Everything not in this allowlist — including
38
+ * other `agentscript-lint` codes like `config-missing-agent-name` or the
39
+ * undefined-reference checks — stays fatal, because those indicate the script
40
+ * is genuinely broken even though the grammar accepted it.
41
+ *
42
+ * Keep this list narrow: only add a code after confirming (a) the parser
43
+ * still produces a usable AST when it fires, and (b) failing on it would
44
+ * regress users who upgrade the parser without changing their scripts.
45
+ */
46
+ const NON_FATAL_DIAGNOSTIC_CODES = new Set(['config-missing-default-agent-user']);
34
47
  /**
35
48
  * Extract basename from a file path without importing Node's `path` module.
36
49
  * Handles both `/` and `\` separators.
@@ -39,31 +52,51 @@ function basename(filePath) {
39
52
  return filePath.split(/[\\/]/).pop() ?? filePath;
40
53
  }
41
54
  /**
42
- * Format diagnostics into a single-line summary for the thrown error message.
43
- * Each entry shows `Line L:C — message [code]` with 1-based positions (LSP
44
- * positions are zero-based; humans read 1-based). The first few errors are
45
- * inlined; the rest are summarized as "(+N more)" so a flood of cascading
46
- * errors doesn't produce an unreadable wall of text.
55
+ * Coerce the parser's diagnostics into a plain array. The public type is
56
+ * `readonly Diagnostic[]`, but older parser builds and recovery paths have
57
+ * been observed to return `undefined` or an iterable, so we defend against
58
+ * both shapes.
47
59
  */
48
- function formatErrorSummary(diagnostics) {
49
- // The parser's public type is `readonly Diagnostic[]`, but defend against
50
- // any shape — older parser builds and recovery paths have been observed
51
- // to return `undefined` or an iterable. Coerce to a plain array first so
52
- // the .filter below never blows up.
60
+ function toDiagnosticArray(diagnostics) {
53
61
  const list = Array.isArray(diagnostics)
54
62
  ? diagnostics
55
63
  : diagnostics && typeof diagnostics[Symbol.iterator] === 'function'
56
64
  ? Array.from(diagnostics)
57
65
  : [];
58
- const errors = list.filter((d) => !!d && typeof d === 'object' && d.severity === LSP_SEVERITY_ERROR);
66
+ return list.filter((d) => !!d && typeof d === 'object');
67
+ }
68
+ /**
69
+ * A diagnostic is fatal (blocks visualization) if it is severity=Error and
70
+ * its `code` is not in the explicit non-fatal allowlist. We match by code
71
+ * (a stable kebab-case identifier) rather than by `source` suffix, because
72
+ * sources like `agentscript-lint` cover both benign rules and genuinely
73
+ * blocking config/reference errors (e.g. `config-missing-agent-name`,
74
+ * undefined `@variable`/`@action` references).
75
+ */
76
+ function isFatalDiagnostic(d) {
77
+ if (d.severity !== LSP_SEVERITY_ERROR) {
78
+ return false;
79
+ }
80
+ const code = typeof d.code === 'string' ? d.code : '';
81
+ return !NON_FATAL_DIAGNOSTIC_CODES.has(code);
82
+ }
83
+ /**
84
+ * Format diagnostics into a single-line summary for the thrown error message.
85
+ * Each entry shows `Line L:C [code]` with 1-based positions (LSP positions are
86
+ * zero-based; humans read 1-based). Diagnostic `message` is intentionally
87
+ * omitted — parser messages routinely embed source excerpts (e.g.
88
+ * `Unrecognized syntax: <customer text>`), which is customer-authored content
89
+ * that must not flow into logs or telemetry. `code` is a fixed kebab-case
90
+ * identifier (`syntax-error`, `missing-token`, …) and is safe.
91
+ */
92
+ function formatErrorSummary(errors) {
59
93
  const MAX = 5;
60
94
  const head = errors.slice(0, MAX).map((d) => {
61
95
  const range = d.range;
62
96
  const line = typeof range?.start?.line === 'number' ? range.start.line + 1 : 1;
63
97
  const col = typeof range?.start?.character === 'number' ? range.start.character + 1 : 1;
64
98
  const code = typeof d.code === 'string' ? ` [${d.code}]` : '';
65
- const message = typeof d.message === 'string' ? d.message : String(d.message ?? '');
66
- return `Line ${line}:${col} — ${message}${code}`;
99
+ return `Line ${line}:${col}${code}`;
67
100
  });
68
101
  const overflow = errors.length > MAX ? ` (+${errors.length - MAX} more)` : '';
69
102
  return head.join('; ') + overflow;
@@ -113,18 +146,16 @@ export class AgentParser {
113
146
  }
114
147
  span.setAttribute('sourceLength', String(source.length));
115
148
  const doc = parse(source);
116
- // A script with parse errors must fail the plugin — there's no useful
117
- // visualization to show, and silently rendering a possibly-empty graph
118
- // hides the real problem from the user. The host surfaces this as a
119
- // plugin error in the webview chrome.
120
- if (doc.hasErrors) {
121
- const summary = formatErrorSummary(doc.diagnostics);
122
- const errorCount = Array.isArray(doc.diagnostics)
123
- ? doc.diagnostics.filter((d) => !!d &&
124
- typeof d === 'object' &&
125
- d.severity === LSP_SEVERITY_ERROR).length
126
- : 0;
127
- telemetry.sendEvent('agent.parse_error', { pluginId: 'agent' }, { errorCount });
149
+ // Filter to fatal errors only. The 2.10.x parser adds new severity=
150
+ // Error lint rules (e.g. `config-missing-default-agent-user`) that
151
+ // fire on a successfully parsed AST; those are allowlisted in
152
+ // NON_FATAL_DIAGNOSTIC_CODES so users still see their graph. Any
153
+ // other severity=Error diagnostic — grammar failures, missing
154
+ // required config, undefined references — remains blocking.
155
+ const fatalErrors = toDiagnosticArray(doc.diagnostics).filter(isFatalDiagnostic);
156
+ if (fatalErrors.length > 0) {
157
+ const summary = formatErrorSummary(fatalErrors);
158
+ telemetry.sendEvent('agent.parse_error', { pluginId: 'agent' }, { errorCount: fatalErrors.length });
128
159
  throw ErrorBuilder.create()
129
160
  .category(ErrorCategory.Parsing)
130
161
  .message(`Agent script has parse errors: ${summary}`)
@@ -170,11 +201,23 @@ export class AgentParser {
170
201
  };
171
202
  }
172
203
  catch (error) {
173
- log.error('Error parsing agent file:', error);
204
+ // Plugin errors were built with sanitized content above — safe to
205
+ // re-throw and safe to log by category. Non-plugin errors may carry
206
+ // raw source excerpts in their `message`/`stack` (parser library
207
+ // throws are not under our control), so we log only a fixed string
208
+ // and the error's constructor name — no message, no stack, no cause.
174
209
  if (isPluginError(error)) {
210
+ const category = error.category;
211
+ log.error(`Error parsing agent file (category=${category})`);
175
212
  throw error;
176
213
  }
177
- throw ErrorBuilder.fromError(ErrorCategory.Parsing, error, { fileName }).build();
214
+ const errorName = error instanceof Error ? error.constructor.name : 'unknown';
215
+ log.error(`Error parsing agent file (name=${errorName})`);
216
+ throw ErrorBuilder.create()
217
+ .category(ErrorCategory.Parsing)
218
+ .message('Agent script parsing failed')
219
+ .context({ fileName, errorName })
220
+ .build();
178
221
  }
179
222
  }, { pluginId: 'agent' });
180
223
  }