@salesforce/metadata-plugins 1.8.0 → 1.9.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 (26) hide show
  1. package/README.md +15 -6
  2. package/dist/plugins/flow/ui/assets/{index-DJP9DbPL.js → index-OhJU6yxp.js} +1 -1
  3. package/dist/plugins/flow/ui/index.html +1 -1
  4. package/dist/plugins/permissionset/PermissionSetParser.d.ts +9 -1
  5. package/dist/plugins/permissionset/PermissionSetParser.d.ts.map +1 -1
  6. package/dist/plugins/permissionset/PermissionSetParser.js +12 -0
  7. package/dist/plugins/permissionset/objectGrouping.d.ts +112 -0
  8. package/dist/plugins/permissionset/objectGrouping.d.ts.map +1 -0
  9. package/dist/plugins/permissionset/objectGrouping.js +140 -0
  10. package/dist/plugins/permissionset/permissionsetSelectionGraph.d.ts +88 -0
  11. package/dist/plugins/permissionset/permissionsetSelectionGraph.d.ts.map +1 -0
  12. package/dist/plugins/permissionset/permissionsetSelectionGraph.js +277 -0
  13. package/dist/plugins/permissionset/sectionKeys.d.ts +45 -0
  14. package/dist/plugins/permissionset/sectionKeys.d.ts.map +1 -0
  15. package/dist/plugins/permissionset/sectionKeys.js +58 -0
  16. package/dist/plugins/permissionset/types/PermissionSetData.d.ts +9 -0
  17. package/dist/plugins/permissionset/types/PermissionSetData.d.ts.map +1 -1
  18. package/dist/plugins/permissionset/ui/assets/index-CMInRbR2.js +48 -0
  19. package/dist/plugins/permissionset/ui/assets/index-DqEUhEQc.css +1 -0
  20. package/dist/plugins/permissionset/ui/index.html +2 -2
  21. package/dist/plugins/schema/ui/assets/{index-BHwyhVGF.js → index-CWvLR0Fz.js} +9 -9
  22. package/dist/plugins/schema/ui/assets/{index-Cp1nVgsx.css → index-EHPZb2E3.css} +1 -1
  23. package/dist/plugins/schema/ui/index.html +2 -2
  24. package/package.json +1 -1
  25. package/dist/plugins/permissionset/ui/assets/index-C13KEtFH.js +0 -48
  26. package/dist/plugins/permissionset/ui/assets/index-CMOgdp7q.css +0 -1
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Salesforce Flow Visualizer</title>
7
- <script type="module" crossorigin src="./assets/index-DJP9DbPL.js"></script>
7
+ <script type="module" crossorigin src="./assets/index-OhJU6yxp.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="./assets/index-H7g-xvR-.css">
9
9
  <link rel="stylesheet" href="@dist/design-system/platform.css" data-platform-styles="true">
10
10
  </head>
@@ -18,7 +18,7 @@
18
18
  * `IPlatformContext.fileSystem` and parses with the shared `SalesforceXMLParser`
19
19
  * — no Node `fs`, no bespoke XML library.
20
20
  */
21
- import { IMetadataParser, MetadataFileInfo, ValidationResult, IPlatformContext, SalesforceXMLParser, VersionInfo } from '@salesforce/metadata-core-sdk';
21
+ import { IMetadataParser, MetadataFileInfo, ValidationResult, IPlatformContext, SalesforceXMLParser, VersionInfo, type SelectableNode } from '@salesforce/metadata-core-sdk';
22
22
  import { PermissionSetData } from './types/PermissionSetData.js';
23
23
  export declare class PermissionSetParser implements IMetadataParser<PermissionSetData> {
24
24
  private platformContext?;
@@ -27,6 +27,14 @@ export declare class PermissionSetParser implements IMetadataParser<PermissionSe
27
27
  readonly xmlParser: SalesforceXMLParser;
28
28
  setPlatformContext(context: IPlatformContext): void;
29
29
  parse(filePath: string, _versionInfo: VersionInfo): Promise<PermissionSetData>;
30
+ /**
31
+ * SelectionGraph projection (vibe-edit). Thin delegate — all logic lives in
32
+ * `permissionsetSelectionGraph.ts` so it's unit-testable without the parser
33
+ * and shares its id helpers with the UI (C4 determinism). The framework calls
34
+ * this once per visualize, error-isolates it, and forwards the array on
35
+ * PLUGIN_DATA_RESPONSE / PLUGIN_DATA_UPDATE.
36
+ */
37
+ getSelectableNodes(data: PermissionSetData): SelectableNode[];
30
38
  /** Reuse the parser output so the framework skips its generic label extraction. */
31
39
  extractMetadataInfo(data: PermissionSetData): MetadataFileInfo | null;
32
40
  validate?(data: PermissionSetData): ValidationResult;
@@ -1 +1 @@
1
- {"version":3,"file":"PermissionSetParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/permissionset/PermissionSetParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAGhB,mBAAmB,EACnB,WAAW,EAGZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAoCjE,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;IAE/B,QAAQ,CAAC,SAAS,sBAA6B;IAE/C,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAM7C,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6GpF,mFAAmF;IACnF,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI;IAKrE,QAAQ,CAAC,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB;IA+BpD,OAAO,CAAC,SAAS;IA0FjB;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAItB"}
1
+ {"version":3,"file":"PermissionSetParser.d.ts","sourceRoot":"","sources":["../../../src/plugins/permissionset/PermissionSetParser.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAGhB,mBAAmB,EACnB,WAAW,EAGX,KAAK,cAAc,EACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAqCjE,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;IAE/B,QAAQ,CAAC,SAAS,sBAA6B;IAE/C,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAM7C,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA6GpF;;;;;;OAMG;IACH,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,EAAE;IAI7D,mFAAmF;IACnF,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI;IAKrE,QAAQ,CAAC,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB;IA+BpD,OAAO,CAAC,SAAS;IA2FjB;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAItB"}
@@ -19,6 +19,7 @@
19
19
  * — no Node `fs`, no bespoke XML library.
20
20
  */
21
21
  import { SalesforceXMLParser, ErrorBuilder, ErrorCategory, } from '@salesforce/metadata-core-sdk';
22
+ import { permissionsetSelectableNodes } from './permissionsetSelectionGraph.js';
22
23
  import { isPluginError } from '../../shared/utils/isPluginError.js';
23
24
  import { str, bool } from './parser/xmlHelpers.js';
24
25
  import { parseObjectPermissions, parseFieldPermissions, parseUserPermissions, parseApexClasses, parseApexPages, parseCustomPermissions, parseFlowAccesses, parseTabSettings, parseApplicationVisibilities, parseRecordTypeVisibilities, parseCustomMetadataTypeAccesses, parseCustomSettingAccesses, parseExternalDataSourceAccesses, parseExternalCredentialPrincipalAccesses, parseAgentAccesses, parseServicePresenceStatusAccesses, parseGenComputingSummaryDefAccesses, parseEmailRoutingAddressAccesses, } from './parser/parseGrants.js';
@@ -121,6 +122,16 @@ export class PermissionSetParser {
121
122
  }
122
123
  }, { pluginId: 'permissionset' });
123
124
  }
125
+ /**
126
+ * SelectionGraph projection (vibe-edit). Thin delegate — all logic lives in
127
+ * `permissionsetSelectionGraph.ts` so it's unit-testable without the parser
128
+ * and shares its id helpers with the UI (C4 determinism). The framework calls
129
+ * this once per visualize, error-isolates it, and forwards the array on
130
+ * PLUGIN_DATA_RESPONSE / PLUGIN_DATA_UPDATE.
131
+ */
132
+ getSelectableNodes(data) {
133
+ return permissionsetSelectableNodes(data);
134
+ }
124
135
  /** Reuse the parser output so the framework skips its generic label extraction. */
125
136
  extractMetadataInfo(data) {
126
137
  const label = data.label?.trim();
@@ -193,6 +204,7 @@ export class PermissionSetParser {
193
204
  const emailRoutingAddressAccesses = parseEmailRoutingAddressAccesses(root);
194
205
  return {
195
206
  apiName,
207
+ filePath,
196
208
  label: str(root.label) ?? apiName,
197
209
  description: str(root.description),
198
210
  license: str(root.license),
@@ -0,0 +1,112 @@
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
+ * The SINGLE source of truth for the permission set's "Object Settings"
9
+ * grouping — the rules that decide, from the flat grants, which object rows
10
+ * exist (real vs synthetic), in what order, and which field / tab / record-type
11
+ * grants fold under each.
12
+ *
13
+ * Two consumers depend on this grouping producing an IDENTICAL set of rows:
14
+ * • the parser projection (`permissionsetSelectionGraph.ts`) emits one
15
+ * `SelectableNode` per row + nested grant, keyed by structural id; and
16
+ * • the panel (`ui/.../objectRows.ts`) renders those same rows and stamps the
17
+ * matching `data-mv-id`.
18
+ * If the two derivations ever disagreed on an object key, a field/record-type
19
+ * name, or whether a synthetic row exists, the id the panel stamps would not
20
+ * resolve to any parser node and selection would silently break. Extracting the
21
+ * grouping here — consumed by BOTH sides — makes that class of divergence
22
+ * impossible: there is only one implementation to keep correct.
23
+ *
24
+ * Kept deliberately PURE and generic (no `ui/`, no React, no data-shape
25
+ * imports): the parser reads raw `PermissionSetData` and the panel reads the
26
+ * normalized `PermissionSetView`, whose member field names differ, so each
27
+ * caller supplies accessors and the grouper passes the ORIGINAL source items
28
+ * back through untouched (`.source`) for the caller to decorate. Living outside
29
+ * `ui/` also keeps the parser's static import graph free of the Vite-wiped
30
+ * `ui/` tree and of `react` (see the packaging guard test).
31
+ */
32
+ /**
33
+ * Split a field's qualified `"Object.Field"` on the first dot. An UNDOTTED
34
+ * value gets the `'—'` object sentinel — such a field keys to no real object
35
+ * and (because `'—'` is never promoted to a synthetic row, see below) surfaces
36
+ * nowhere, matching the panel's long-standing behavior.
37
+ */
38
+ export declare function splitFieldName(qualified: string): {
39
+ object: string;
40
+ field: string;
41
+ };
42
+ /**
43
+ * Split a record type's qualified `"Object.RecordType"` on the first dot.
44
+ * Distinct from {@link splitFieldName}: an UNDOTTED record type keeps the whole
45
+ * string as BOTH the object key and the name (no `'—'` sentinel), so it still
46
+ * mints a synthetic object row. Preserved exactly as both derivations did it.
47
+ */
48
+ export declare function splitRecordTypeName(qualified: string): {
49
+ object: string;
50
+ name: string;
51
+ };
52
+ /**
53
+ * The object a tab keys to. A custom-object tab's name IS the object api name
54
+ * (e.g. `"Space_Station__c"`); a standard-object tab is prefixed `"standard-"`
55
+ * (e.g. `"standard-Account"`), so strip that to match. VF-page / web tabs match
56
+ * no object and fall through to a synthetic row. The RAW value is retained
57
+ * separately (see `GroupedTab.rawTab`) for the tab node's apiName.
58
+ */
59
+ export declare function tabToObject(tab: string): string;
60
+ /** A field grant folded under its object; `field` is unqualified. */
61
+ export interface GroupedField<F> {
62
+ field: string;
63
+ source: F;
64
+ }
65
+ /** A tab grant folded under its object; `rawTab` is the source `<tab>` value. */
66
+ export interface GroupedTab<T> {
67
+ rawTab: string;
68
+ source: T;
69
+ }
70
+ /** A record-type grant folded under its object; `name` is unqualified. */
71
+ export interface GroupedRecordType<R> {
72
+ name: string;
73
+ source: R;
74
+ }
75
+ /** One "Object Settings" row with its nested grants folded in. */
76
+ export interface GroupedObjectRow<O, F, T, R> {
77
+ /** Object api name (or, for a tab-only synthetic row, the raw tab value). */
78
+ object: string;
79
+ /**
80
+ * The real ObjectPermission this row was built from, passed straight through
81
+ * for the caller to read CRUD flags off. `undefined` ⇔ `synthetic` — the row
82
+ * exists only because a field / tab / record type referenced this object.
83
+ */
84
+ objectSource?: O;
85
+ synthetic: boolean;
86
+ fields: GroupedField<F>[];
87
+ tab?: GroupedTab<T>;
88
+ recordTypes: GroupedRecordType<R>[];
89
+ }
90
+ /** The grants + accessors a caller feeds in; accessors normalize shape differences. */
91
+ export interface GroupingSources<O, F, T, R> {
92
+ objectPermissions: readonly O[];
93
+ objectKey: (o: O) => string;
94
+ fieldPermissions: readonly F[];
95
+ /** Qualified `"Object.Field"`. */
96
+ fieldName: (f: F) => string;
97
+ tabSettings: readonly T[];
98
+ /** Raw `<tab>` value. */
99
+ tabValue: (t: T) => string;
100
+ recordTypeVisibilities: readonly R[];
101
+ /** Qualified `"Object.RecordType"`. */
102
+ recordTypeName: (r: R) => string;
103
+ }
104
+ /**
105
+ * Group the flat grants into "Object Settings" rows: real objectPermission rows
106
+ * in source order, then synthetic rows (first-seen order across fields → record
107
+ * types → tabs) for objects referenced only by a field / record type / tab.
108
+ * Within a row, fields / record types keep source order. Deterministic and
109
+ * side-effect-free.
110
+ */
111
+ export declare function groupObjectSettings<O, F, T, R>(s: GroupingSources<O, F, T, R>): GroupedObjectRow<O, F, T, R>[];
112
+ //# sourceMappingURL=objectGrouping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectGrouping.d.ts","sourceRoot":"","sources":["../../../src/plugins/permissionset/objectGrouping.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,S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CAAC;IAC5B,gBAAgB,EAAE,SAAS,CAAC,EAAE,CAAC;IAC/B,kCAAkC;IAClC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;IAC5B,WAAW,EAAE,SAAS,CAAC,EAAE,CAAC;IAC1B,yBAAyB;IACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;IAC3B,sBAAsB,EAAE,SAAS,CAAC,EAAE,CAAC;IACrC,uCAAuC;IACvC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAC5C,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC7B,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAwEhC"}
@@ -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
+ /**
8
+ * The SINGLE source of truth for the permission set's "Object Settings"
9
+ * grouping — the rules that decide, from the flat grants, which object rows
10
+ * exist (real vs synthetic), in what order, and which field / tab / record-type
11
+ * grants fold under each.
12
+ *
13
+ * Two consumers depend on this grouping producing an IDENTICAL set of rows:
14
+ * • the parser projection (`permissionsetSelectionGraph.ts`) emits one
15
+ * `SelectableNode` per row + nested grant, keyed by structural id; and
16
+ * • the panel (`ui/.../objectRows.ts`) renders those same rows and stamps the
17
+ * matching `data-mv-id`.
18
+ * If the two derivations ever disagreed on an object key, a field/record-type
19
+ * name, or whether a synthetic row exists, the id the panel stamps would not
20
+ * resolve to any parser node and selection would silently break. Extracting the
21
+ * grouping here — consumed by BOTH sides — makes that class of divergence
22
+ * impossible: there is only one implementation to keep correct.
23
+ *
24
+ * Kept deliberately PURE and generic (no `ui/`, no React, no data-shape
25
+ * imports): the parser reads raw `PermissionSetData` and the panel reads the
26
+ * normalized `PermissionSetView`, whose member field names differ, so each
27
+ * caller supplies accessors and the grouper passes the ORIGINAL source items
28
+ * back through untouched (`.source`) for the caller to decorate. Living outside
29
+ * `ui/` also keeps the parser's static import graph free of the Vite-wiped
30
+ * `ui/` tree and of `react` (see the packaging guard test).
31
+ */
32
+ // ─── name splitting (the parity-critical rules) ──────────────────────────────
33
+ /**
34
+ * Split a field's qualified `"Object.Field"` on the first dot. An UNDOTTED
35
+ * value gets the `'—'` object sentinel — such a field keys to no real object
36
+ * and (because `'—'` is never promoted to a synthetic row, see below) surfaces
37
+ * nowhere, matching the panel's long-standing behavior.
38
+ */
39
+ export function splitFieldName(qualified) {
40
+ const dot = qualified.indexOf('.');
41
+ return dot < 0
42
+ ? { object: '—', field: qualified }
43
+ : { object: qualified.slice(0, dot), field: qualified.slice(dot + 1) };
44
+ }
45
+ /**
46
+ * Split a record type's qualified `"Object.RecordType"` on the first dot.
47
+ * Distinct from {@link splitFieldName}: an UNDOTTED record type keeps the whole
48
+ * string as BOTH the object key and the name (no `'—'` sentinel), so it still
49
+ * mints a synthetic object row. Preserved exactly as both derivations did it.
50
+ */
51
+ export function splitRecordTypeName(qualified) {
52
+ const dot = qualified.indexOf('.');
53
+ return dot < 0
54
+ ? { object: qualified, name: qualified }
55
+ : { object: qualified.slice(0, dot), name: qualified.slice(dot + 1) };
56
+ }
57
+ /**
58
+ * The object a tab keys to. A custom-object tab's name IS the object api name
59
+ * (e.g. `"Space_Station__c"`); a standard-object tab is prefixed `"standard-"`
60
+ * (e.g. `"standard-Account"`), so strip that to match. VF-page / web tabs match
61
+ * no object and fall through to a synthetic row. The RAW value is retained
62
+ * separately (see `GroupedTab.rawTab`) for the tab node's apiName.
63
+ */
64
+ export function tabToObject(tab) {
65
+ return tab.startsWith('standard-') ? tab.slice('standard-'.length) : tab;
66
+ }
67
+ /**
68
+ * Group the flat grants into "Object Settings" rows: real objectPermission rows
69
+ * in source order, then synthetic rows (first-seen order across fields → record
70
+ * types → tabs) for objects referenced only by a field / record type / tab.
71
+ * Within a row, fields / record types keep source order. Deterministic and
72
+ * side-effect-free.
73
+ */
74
+ export function groupObjectSettings(s) {
75
+ // Fields grouped by their (unqualified-owning) object, in source order.
76
+ const fieldsByObject = new Map();
77
+ for (const f of s.fieldPermissions) {
78
+ const { object, field } = splitFieldName(s.fieldName(f));
79
+ const entry = { field, source: f };
80
+ const list = fieldsByObject.get(object);
81
+ if (list) {
82
+ list.push(entry);
83
+ }
84
+ else {
85
+ fieldsByObject.set(object, [entry]);
86
+ }
87
+ }
88
+ // Tabs keyed by (stripped) object; raw value retained for the node apiName.
89
+ const tabByObject = new Map();
90
+ for (const t of s.tabSettings) {
91
+ const rawTab = s.tabValue(t);
92
+ tabByObject.set(tabToObject(rawTab), { rawTab, source: t });
93
+ }
94
+ // Record types keyed by their object prefix; unqualified name retained.
95
+ const rtsByObject = new Map();
96
+ for (const r of s.recordTypeVisibilities) {
97
+ const { object, name } = splitRecordTypeName(s.recordTypeName(r));
98
+ const entry = { name, source: r };
99
+ const list = rtsByObject.get(object);
100
+ if (list) {
101
+ list.push(entry);
102
+ }
103
+ else {
104
+ rtsByObject.set(object, [entry]);
105
+ }
106
+ }
107
+ const buildRow = (object, objectSource) => ({
108
+ object,
109
+ objectSource,
110
+ synthetic: objectSource === undefined,
111
+ fields: fieldsByObject.get(object) ?? [],
112
+ tab: tabByObject.get(object),
113
+ recordTypes: rtsByObject.get(object) ?? [],
114
+ });
115
+ const rows = s.objectPermissions.map((o) => buildRow(s.objectKey(o), o));
116
+ const covered = new Set(s.objectPermissions.map((o) => s.objectKey(o)));
117
+ // Objects referenced only via fields / record types / tabs still get a
118
+ // (synthetic) row so their nested grants surface. First-seen order across the
119
+ // three sources. `'—'` (undotted-field sentinel) is never promoted.
120
+ const extra = new Set();
121
+ for (const object of fieldsByObject.keys()) {
122
+ if (object !== '—' && !covered.has(object)) {
123
+ extra.add(object);
124
+ }
125
+ }
126
+ for (const object of rtsByObject.keys()) {
127
+ if (!covered.has(object)) {
128
+ extra.add(object);
129
+ }
130
+ }
131
+ for (const object of tabByObject.keys()) {
132
+ if (!covered.has(object)) {
133
+ extra.add(object);
134
+ }
135
+ }
136
+ for (const object of extra) {
137
+ rows.push(buildRow(object, undefined));
138
+ }
139
+ return rows;
140
+ }
@@ -0,0 +1,88 @@
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
+ * Permission Set SelectionGraph (C1) — the plugin's ENTIRE vibe-edit
9
+ * contribution: one forward projection of the parsed permission set into the
10
+ * normalized `SelectableNode` contract, plus the id helpers the panel
11
+ * components stamp as `data-mv-id`. Because both the parser (host) and the UI
12
+ * import the SAME helpers, the id the parser emits and the id the UI renders
13
+ * are identical BY CONSTRUCTION — the generic core-sdk engine then resolves a
14
+ * selected element to its node by pure `Map.get(id)`.
15
+ *
16
+ * SELF-CONTAINED, like `schema`/`agent`: this module projects DIRECTLY off the
17
+ * raw `PermissionSetData` and imports only `./types/`, `./objectGrouping.js`,
18
+ * and core-sdk. It reuses NOTHING from `ui/`, so the panel's own render code
19
+ * (`objectRows.ts`, `toPermissionSetView.ts`, `constants.ts`, `helpers.ts`)
20
+ * stays as it was — vibe-edit is added purely on top. This is also what keeps
21
+ * the parser's static import graph free of the `ui/` tree (which Vite wipes
22
+ * from `dist` via `emptyOutDir`) and of `react` (a devDependency), so
23
+ * `getAllVisualizers()` loads cleanly in a pure-Node host.
24
+ *
25
+ * The projection reproduces the panel's "Object Settings" grouping so the
26
+ * emitted nodes match the DOM 1:1: each object row (real OR synthetic) parents
27
+ * its field / tab / record-type children, and the 14 flat named-access
28
+ * sections hang off the root. The grouping itself — which object rows exist, in
29
+ * what order, and which field/tab/record-type grants fold under each — is NOT
30
+ * re-implemented here: it comes from the SHARED `groupObjectSettings`
31
+ * (`./objectGrouping.js`) that the panel's `useObjectRows` also consumes, so the
32
+ * ids emitted here and the `data-mv-id`s the panel stamps cannot drift apart.
33
+ * This projection only reads the grant PAYLOADS (CRUD flags, readable/editable,
34
+ * visibility) off each grouped row's passed-through `.source`.
35
+ *
36
+ * Hierarchy (parentId chains):
37
+ *
38
+ * permissionset (root)
39
+ * ├─ objectPermission (one per Object Settings row — real OR synthetic)
40
+ * │ ├─ fieldPermission (unqualified field name)
41
+ * │ ├─ tabSetting (raw <tab> value)
42
+ * │ └─ recordTypeVisibility (unqualified record-type name)
43
+ * └─ <14 namedAccess-family sections> (flat children of root; type === section key)
44
+ *
45
+ * filePath: EVERY node carries `data.filePath` (the `.permissionset-meta.xml`).
46
+ * We deliberately do NOT use `sfdxPath()` — editing any grant edits the
47
+ * permission-set file, not the referenced object/field's own metadata file.
48
+ */
49
+ import { type SelectableNode } from '@salesforce/metadata-core-sdk';
50
+ import type { PermissionSetData } from './types/PermissionSetData.js';
51
+ import type { NamedAccessSectionKey } from './sectionKeys.js';
52
+ /** Root permission-set node — keyed on the PS api name. */
53
+ export declare function permissionSetNodeId(apiName: string): string;
54
+ /**
55
+ * The overview-card title (the permission set's label) — a pure-label heading
56
+ * child of the root. Selecting it targets JUST the label, without pulling in the
57
+ * whole permission set. Mirrors the agent plugin's header-card title heading.
58
+ */
59
+ export declare function permissionSetTitleNodeId(psApiName: string): string;
60
+ /**
61
+ * The overview-card description paragraph — a child of the root, selectable on
62
+ * its own so the user can edit just the description. Mirrors the agent plugin's
63
+ * standalone description node.
64
+ */
65
+ export declare function permissionSetDescriptionNodeId(psApiName: string): string;
66
+ /** An Object Settings row (real or synthetic) — child of the root. */
67
+ export declare function objectPermissionNodeId(psApiName: string, objectApiName: string): string;
68
+ /** A field-level-security row — child of its object. `fieldApiName` is unqualified. */
69
+ export declare function fieldPermissionNodeId(psApiName: string, objectApiName: string, fieldApiName: string): string;
70
+ /** A record-type-visibility row — child of its object. `recordTypeName` is unqualified. */
71
+ export declare function recordTypeVisibilityNodeId(psApiName: string, objectApiName: string, recordTypeName: string): string;
72
+ /** A tab-setting row — child of its object. `tab` is the RAW `<tab>` value. */
73
+ export declare function tabSettingNodeId(psApiName: string, objectApiName: string, tab: string): string;
74
+ export type { NamedAccessSectionKey };
75
+ /**
76
+ * A flat named-access grant (apexClassAccesses, userPermissions, …). Scoped by
77
+ * the SECTION KEY as the `type` so the SAME name granted in two different
78
+ * sections yields two DISTINCT ids (otherwise both `<li>`s share a `data-mv-id`
79
+ * and selection is ambiguous).
80
+ */
81
+ export declare function namedAccessNodeId(psApiName: string, sectionKey: NamedAccessSectionKey, name: string): string;
82
+ /**
83
+ * Emit the full Permission Set SelectionGraph. Used by
84
+ * `PermissionSetParser.getSelectableNodes()` (host) and matched exactly by the
85
+ * `data-mv-id` the panel components render (both via the helpers above).
86
+ */
87
+ export declare function permissionsetSelectableNodes(data: PermissionSetData): SelectableNode[];
88
+ //# sourceMappingURL=permissionsetSelectionGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionsetSelectionGraph.d.ts","sourceRoot":"","sources":["../../../src/plugins/permissionset/permissionsetSelectionGraph.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EACV,iBAAiB,EAGlB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAO9D,2DAA2D;AAC3D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;GAIG;AACH,wBA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