@simplysf/simply-permissions 1.2.8 → 1.2.9

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.
@@ -13,91 +13,50 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- /**
17
- * @param value - The raw string to escape.
18
- * @returns `value` with HTML special characters (`& < > "`) replaced by their entity references.
19
- */
20
- function escapeHtml(value) {
21
- return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
22
- }
23
- /** @returns An HTML `<table>` of object permissions, or a placeholder `<p>` if `perms` is empty. */
24
- function renderObjectPermsTable(perms) {
25
- if (perms.length === 0) {
26
- return '<p>No object permissions.</p>';
27
- }
28
- const rows = perms
29
- .map((permission) => `<tr><td>${escapeHtml(permission.SobjectType)}</td><td>${permission.PermissionsRead}</td><td>${permission.PermissionsCreate}</td><td>${permission.PermissionsEdit}</td><td>${permission.PermissionsDelete}</td><td>${permission.PermissionsViewAllRecords}</td><td>${permission.PermissionsModifyAllRecords}</td></tr>`)
30
- .join('');
31
- return `<table><thead><tr><th>Object</th><th>Read</th><th>Create</th><th>Edit</th><th>Delete</th><th>View All</th><th>Modify All</th></tr></thead><tbody>${rows}</tbody></table>`;
32
- }
33
- /** @returns An HTML `<table>` of field permissions, or a placeholder `<p>` if `perms` is empty. */
34
- function renderFieldPermsTable(perms) {
35
- if (perms.length === 0) {
36
- return '<p>No field permissions.</p>';
37
- }
38
- const rows = perms
39
- .map((permission) => `<tr><td>${escapeHtml(permission.SobjectType)}</td><td>${escapeHtml(permission.Field.split('.')[1] ?? permission.Field)}</td><td>${permission.PermissionsRead}</td><td>${permission.PermissionsEdit}</td></tr>`)
40
- .join('');
41
- return `<table><thead><tr><th>Object</th><th>Field</th><th>Read</th><th>Edit</th></tr></thead><tbody>${rows}</tbody></table>`;
42
- }
43
- /** @returns A collapsible `<details>` section summarizing one permission set's permissions. */
44
- function renderPermissionSet(permissionSet) {
45
- return `
46
- <details>
47
- <summary>${escapeHtml(permissionSet.Label)} (${escapeHtml(permissionSet.Name)})</summary>
48
- <div class="content">
49
- ${permissionSet.Description ? `<p>${escapeHtml(permissionSet.Description)}</p>` : ''}
50
- <h4>Object Permissions</h4>
51
- ${renderObjectPermsTable(permissionSet.objectPerms)}
52
- <h4>Field Permissions</h4>
53
- ${renderFieldPermsTable(permissionSet.fieldPerms)}
54
- </div>
55
- </details>`;
56
- }
57
- /** @returns A collapsible `<details>` section summarizing one permission set group's permissions. */
58
- function renderPermissionSetGroup(permissionSetGroup) {
59
- return `
60
- <details>
61
- <summary>${escapeHtml(permissionSetGroup.MasterLabel)} (${escapeHtml(permissionSetGroup.DeveloperName)}) [Group]</summary>
62
- <div class="content">
63
- ${permissionSetGroup.Description ? `<p>${escapeHtml(permissionSetGroup.Description)}</p>` : ''}
64
- <p><strong>Components:</strong> ${permissionSetGroup.components.map(escapeHtml).join(', ') || 'None'}</p>
65
- <h4>Object Permissions</h4>
66
- ${renderObjectPermsTable(permissionSetGroup.objectPerms)}
67
- <h4>Field Permissions</h4>
68
- ${renderFieldPermsTable(permissionSetGroup.fieldPerms)}
69
- </div>
70
- </details>`;
71
- }
72
- /**
73
- * Render a complete, self-contained HTML report of permission sets and permission set groups,
74
- * grouped by package, with each permission set/group collapsible for browsing.
75
- *
76
- * @param options.username - The org username the report was generated against.
77
- * @param options.reportDate - The report generation date/time, displayed as-is.
78
- * @param options.groupedData - The permission sets/groups to render, grouped by package.
79
- * @returns The rendered HTML document.
80
- */
81
- export function buildPermissionsReportHtml(options) {
82
- const { username, reportDate, groupedData } = options;
83
- const sortedPackages = [...groupedData.keys()].sort();
84
- const sections = sortedPackages
85
- .map((pkg) => {
86
- const data = groupedData.get(pkg);
87
- if (!data) {
88
- return '';
89
- }
90
- return `
91
- <div class="package-section" data-package="${escapeHtml(pkg)}">
92
- <h2>Package: ${escapeHtml(pkg)}</h2>
93
- <h3>Permission Sets (${data.permissionSets.length})</h3>
94
- ${data.permissionSets.map(renderPermissionSet).join('')}
95
- <h3>Permission Set Groups (${data.permissionSetGroups.length})</h3>
96
- ${data.permissionSetGroups.map(renderPermissionSetGroup).join('')}
97
- </div>`;
98
- })
99
- .join('');
100
- return `<!DOCTYPE html>
16
+ import Handlebars from 'handlebars';
17
+ // Handlebars auto-escapes every `{{expression}}` (unlike `{{{expression}}}`, which is left raw),
18
+ // so none of the templates below need a hand-rolled escapeHtml() call.
19
+ const handlebars = Handlebars.create();
20
+ // `Field` is the fully-qualified `Object.Field` name; the report only displays the field half.
21
+ handlebars.registerHelper('fieldName', (field) => field.split('.')[1] ?? field);
22
+ const objectPermsTableSource = `
23
+ {{~#if perms}}
24
+ <table><thead><tr><th>Object</th><th>Read</th><th>Create</th><th>Edit</th><th>Delete</th><th>View All</th><th>Modify All</th></tr></thead><tbody>{{#each perms}}<tr><td>{{SobjectType}}</td><td>{{PermissionsRead}}</td><td>{{PermissionsCreate}}</td><td>{{PermissionsEdit}}</td><td>{{PermissionsDelete}}</td><td>{{PermissionsViewAllRecords}}</td><td>{{PermissionsModifyAllRecords}}</td></tr>{{/each}}</tbody></table>
25
+ {{~else~}}
26
+ <p>No object permissions.</p>
27
+ {{~/if~}}
28
+ `;
29
+ const fieldPermsTableSource = `
30
+ {{~#if perms}}
31
+ <table><thead><tr><th>Object</th><th>Field</th><th>Read</th><th>Edit</th></tr></thead><tbody>{{#each perms}}<tr><td>{{SobjectType}}</td><td>{{fieldName Field}}</td><td>{{PermissionsRead}}</td><td>{{PermissionsEdit}}</td></tr>{{/each}}</tbody></table>
32
+ {{~else~}}
33
+ <p>No field permissions.</p>
34
+ {{~/if~}}
35
+ `;
36
+ const permissionSetSource = `
37
+ <details>
38
+ <summary>{{Label}} ({{Name}})</summary>
39
+ <div class="content">
40
+ {{#if Description}}<p>{{Description}}</p>{{/if}}
41
+ <h4>Object Permissions</h4>
42
+ {{> objectPermsTable perms=objectPerms}}
43
+ <h4>Field Permissions</h4>
44
+ {{> fieldPermsTable perms=fieldPerms}}
45
+ </div>
46
+ </details>`;
47
+ const permissionSetGroupSource = `
48
+ <details>
49
+ <summary>{{MasterLabel}} ({{DeveloperName}}) [Group]</summary>
50
+ <div class="content">
51
+ {{#if Description}}<p>{{Description}}</p>{{/if}}
52
+ <p><strong>Components:</strong> {{componentsDisplay}}</p>
53
+ <h4>Object Permissions</h4>
54
+ {{> objectPermsTable perms=objectPerms}}
55
+ <h4>Field Permissions</h4>
56
+ {{> fieldPermsTable perms=fieldPerms}}
57
+ </div>
58
+ </details>`;
59
+ const reportSource = `<!DOCTYPE html>
101
60
  <html lang="en">
102
61
  <head>
103
62
  <meta charset="UTF-8">
@@ -118,9 +77,45 @@ export function buildPermissionsReportHtml(options) {
118
77
  </head>
119
78
  <body>
120
79
  <h1>Permissions Report</h1>
121
- <p>Org: <strong>${escapeHtml(username)}</strong> | Generated: ${escapeHtml(reportDate)}</p>
122
- ${sections}
80
+ <p>Org: <strong>{{username}}</strong> | Generated: {{reportDate}}</p>
81
+ {{#each packages}}
82
+ <div class="package-section" data-package="{{name}}">
83
+ <h2>Package: {{name}}</h2>
84
+ <h3>Permission Sets ({{permissionSets.length}})</h3>
85
+ {{#each permissionSets}}{{> permissionSet}}{{/each}}
86
+ <h3>Permission Set Groups ({{permissionSetGroups.length}})</h3>
87
+ {{#each permissionSetGroups}}{{> permissionSetGroup}}{{/each}}
88
+ </div>
89
+ {{/each}}
123
90
  </body>
124
91
  </html>`;
92
+ handlebars.registerPartial('objectPermsTable', objectPermsTableSource);
93
+ handlebars.registerPartial('fieldPermsTable', fieldPermsTableSource);
94
+ handlebars.registerPartial('permissionSet', permissionSetSource);
95
+ handlebars.registerPartial('permissionSetGroup', permissionSetGroupSource);
96
+ const renderReport = handlebars.compile(reportSource);
97
+ /**
98
+ * Render a complete, self-contained HTML report of permission sets and permission set groups,
99
+ * grouped by package, with each permission set/group collapsible for browsing.
100
+ *
101
+ * @param options.username - The org username the report was generated against.
102
+ * @param options.reportDate - The report generation date/time, displayed as-is.
103
+ * @param options.groupedData - The permission sets/groups to render, grouped by package.
104
+ * @returns The rendered HTML document.
105
+ */
106
+ export function buildPermissionsReportHtml(options) {
107
+ const { username, reportDate, groupedData } = options;
108
+ const packages = [...groupedData.keys()].sort().map((name) => {
109
+ const data = groupedData.get(name);
110
+ return {
111
+ name,
112
+ permissionSets: data?.permissionSets ?? [],
113
+ permissionSetGroups: (data?.permissionSetGroups ?? []).map((group) => ({
114
+ ...group,
115
+ componentsDisplay: group.components.length > 0 ? group.components.join(', ') : 'None',
116
+ })),
117
+ };
118
+ });
119
+ return renderReport({ username, reportDate, packages });
125
120
  }
126
121
  //# sourceMappingURL=permissionsReportTemplate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissionsReportTemplate.js","sourceRoot":"","sources":["../../src/common/permissionsReportTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgDH;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC1G,CAAC;AAED,oGAAoG;AACpG,SAAS,sBAAsB,CAAC,KAA8B;IAC5D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,+BAA+B,CAAC;IACzC,CAAC;IAED,MAAM,IAAI,GAAG,KAAK;SACf,GAAG,CACF,CAAC,UAAU,EAAE,EAAE,CACb,WAAW,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,UAAU,CAAC,eAAe,YAAY,UAAU,CAAC,iBAAiB,YAAY,UAAU,CAAC,eAAe,YAAY,UAAU,CAAC,iBAAiB,YAAY,UAAU,CAAC,yBAAyB,YAAY,UAAU,CA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AAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7E,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEnC,OAAO;YACL,IAAI;YACJ,cAAc,EAAE,IAAI,EAAE,cAAc,IAAI,EAAE;YAC1C,mBAAmB,EAAE,CAAC,IAAI,EAAE,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACrE,GAAG,KAAK;gBACR,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;aACtF,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC1D,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplysf/simply-permissions",
3
3
  "description": "Utilities for working with permissions",
4
- "version": "1.2.8",
4
+ "version": "1.2.9",
5
5
  "author": "@ClayChipps",
6
6
  "homepage": "https://github.com/SimplySF/simply",
7
7
  "bugs": "https://github.com/SimplySF/simply/issues",
@@ -61,7 +61,8 @@
61
61
  "@salesforce/kit": "^3.2.6",
62
62
  "@salesforce/sf-plugins-core": "^12.2.16",
63
63
  "@salesforce/source-deploy-retrieve": "^12.37.2",
64
- "@simplysf/simply-core": "^1.1.4",
64
+ "@simplysf/simply-core": "^1.1.5",
65
+ "handlebars": "^4.7.9",
65
66
  "xmlbuilder2": "^4.0.3",
66
67
  "zod": "^4.1.12"
67
68
  },
@@ -209,5 +210,5 @@
209
210
  "output": []
210
211
  }
211
212
  },
212
- "gitHead": "6fadc80de8d12b2d91070cd8c35e60d727a3391d"
213
+ "gitHead": "99fde0b9705ed0bdd1b30a973a9e1dae92c724c8"
213
214
  }