@simplysf/simply-permissions 1.3.13 → 1.4.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.
package/README.md CHANGED
@@ -66,7 +66,7 @@ FLAG DESCRIPTIONS
66
66
  The path to write the generated HTML report to.
67
67
  ```
68
68
 
69
- _See code: [lib/commands/simply/permissions/analyze.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@1.3.8/packages/simply-permissions/lib/commands/simply/permissions/analyze.js)_
69
+ _See code: [lib/commands/simply/permissions/analyze.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@1.3.14/packages/simply-permissions/lib/commands/simply/permissions/analyze.js)_
70
70
 
71
71
  ## `sf simply permissions assignment delete`
72
72
 
@@ -109,26 +109,27 @@ EXAMPLES
109
109
  $ sf simply permissions assignment delete --permission-set-group-name My_Permission_Set_Group --target-org myOrg
110
110
  ```
111
111
 
112
- _See code: [lib/commands/simply/permissions/assignment/delete.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@1.3.8/packages/simply-permissions/lib/commands/simply/permissions/assignment/delete.js)_
112
+ _See code: [lib/commands/simply/permissions/assignment/delete.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@1.3.14/packages/simply-permissions/lib/commands/simply/permissions/assignment/delete.js)_
113
113
 
114
114
  ## `sf simply permissions build`
115
115
 
116
- Generate a permission set from Salesforce source metadata.
116
+ Generate permission sets from Salesforce source metadata.
117
117
 
118
118
  ```
119
119
  USAGE
120
- $ sf simply permissions build --type read-only|view-all|modify-all -n <value> -d <value> --output <value> [--json]
121
- [--flags-dir <value>] [-c <value>] [--include-record-types] [--label <value>] [--description <value>]
120
+ $ sf simply permissions build [--json] [--flags-dir <value>] [-f <value> | --type read-only|view-all|modify-all | -n <value>
121
+ | -d <value> | --output <value> | -c <value> | --include-record-types | --label <value> | --description <value>]
122
122
 
123
123
  FLAGS
124
124
  -c, --config=<value> Path to a permission set configuration file
125
- -d, --directory=<value> (required) Path to the Salesforce project directory
126
- -n, --name=<value> (required) API name for the permission set
125
+ -d, --directory=<value> Path to the Salesforce project directory
126
+ -f, --file=<value> Path to a permission sets file declaring every permission set to generate
127
+ -n, --name=<value> API name for the permission set
127
128
  --description=<value> Description for the permission set
128
129
  --include-record-types Include record type visibilities
129
130
  --label=<value> Label for the permission set
130
- --output=<value> (required) Output directory
131
- --type=<option> (required) Baseline permission type
131
+ --output=<value> Output directory
132
+ --type=<option> Baseline permission type
132
133
  <options: read-only|view-all|modify-all>
133
134
 
134
135
  GLOBAL FLAGS
@@ -136,18 +137,52 @@ GLOBAL FLAGS
136
137
  --json Format output as json.
137
138
 
138
139
  DESCRIPTION
139
- Generate a permission set from Salesforce source metadata.
140
+ Generate permission sets from Salesforce source metadata.
140
141
 
141
142
  Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally) record types, then generates a
142
143
  permission set XML file with a baseline of permissions determined by --type. An optional JSON --config file can
143
144
  override individual object, field, tab, record type, and user permission settings, as well as whether the permission
144
145
  set requires activation.
145
146
 
147
+ To regenerate every permission set in a project with one command, declare them all in a JSON file and pass it with
148
+ --file instead of the other flags. Each entry in the file's "permissionSets" array takes the same settings as one run
149
+ of this command; a top-level "defaults" object supplies the "directory", "output", and "includeRecordTypes" values
150
+ shared by every entry, and any entry can override them. An entry's "config" is either a path to a --config file or the
151
+ same overrides inline. Relative paths are resolved against the current directory, as they are for flags. The whole
152
+ file, including referenced override files and source directories, is validated before anything is written, and each
153
+ source directory is scanned only once.
154
+
155
+ {
156
+ "defaults": {
157
+ "directory": "force-app",
158
+ "output": "force-app/main/default/permissionsets"
159
+ },
160
+ "permissionSets": [
161
+ { "name": "App_Read_Only", "type": "read-only" },
162
+ {
163
+ "name": "App_Admin",
164
+ "type": "modify-all",
165
+ "label": "App Admin",
166
+ "includeRecordTypes": true,
167
+ "config": "config/app-admin-overrides.json"
168
+ },
169
+ {
170
+ "name": "App_Support",
171
+ "type": "view-all",
172
+ "config": { "userPermissions": { "ViewSetup": true } }
173
+ }
174
+ ]
175
+ }
176
+
146
177
  EXAMPLES
147
178
  $ sf simply permissions build --type read-only --name My_Read_Only_Access --directory force-app --output force-app/main/default/permissionsets
148
179
 
149
180
  $ sf simply permissions build --type modify-all --name My_Admin_Access --directory force-app --config config/permission-overrides.json --output force-app/main/default/permissionsets --include-record-types
150
181
 
182
+ Regenerate every permission set declared in a permission sets file:
183
+
184
+ $ sf simply permissions build --file config/permission-sets.json
185
+
151
186
  FLAG DESCRIPTIONS
152
187
  -c, --config=<value> Path to a permission set configuration file
153
188
 
@@ -156,11 +191,19 @@ FLAG DESCRIPTIONS
156
191
 
157
192
  -d, --directory=<value> Path to the Salesforce project directory
158
193
 
159
- The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types.
194
+ The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required
195
+ unless --file is used.
196
+
197
+ -f, --file=<value> Path to a permission sets file declaring every permission set to generate
198
+
199
+ The path to a JSON file with a "permissionSets" array, each entry describing one permission set to generate ("name",
200
+ "type", and optionally "label", "description", "directory", "output", "includeRecordTypes", "config"), and an
201
+ optional "defaults" object. Can't be combined with the flags that describe a single permission set.
160
202
 
161
203
  -n, --name=<value> API name for the permission set
162
204
 
163
- The API name for the generated permission set; also used to derive the output filename.
205
+ The API name for the generated permission set; also used to derive the output filename. Required unless --file is
206
+ used.
164
207
 
165
208
  --include-record-types Include record type visibilities
166
209
 
@@ -168,15 +211,16 @@ FLAG DESCRIPTIONS
168
211
 
169
212
  --output=<value> Output directory
170
213
 
171
- The directory to write the generated permission set XML file to.
214
+ The directory to write the generated permission set XML file to. Required unless --file is used.
172
215
 
173
216
  --type=read-only|view-all|modify-all Baseline permission type
174
217
 
175
218
  The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields,
176
219
  'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access.
220
+ Required unless --file is used.
177
221
  ```
178
222
 
179
- _See code: [lib/commands/simply/permissions/build.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@1.3.8/packages/simply-permissions/lib/commands/simply/permissions/build.js)_
223
+ _See code: [lib/commands/simply/permissions/build.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@1.3.14/packages/simply-permissions/lib/commands/simply/permissions/build.js)_
180
224
  <!-- commandsstop -->
181
225
 
182
226
  ## Configuration Files
@@ -1,35 +1,36 @@
1
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
- /** Baseline permission profile applied before `--config` overrides. */
3
- type PermissionSetType = 'read-only' | 'view-all' | 'modify-all';
4
- /** Where the generated permission set was written, and how many permissions it grants. */
5
- export type PermissionsBuildResult = {
6
- path: string;
7
- objectPermissionCount: number;
8
- fieldPermissionCount: number;
9
- };
2
+ import { PermissionSetBuildResult, PermissionSetType } from '@simplysf/simply-permissions-core';
3
+ /** Where a single generated permission set was written, and how many permissions it grants. */
4
+ export type PermissionsBuildResult = Omit<PermissionSetBuildResult, 'name'>;
5
+ /** With `--file`: one entry per permission set declared in the file, in file order. */
6
+ export type PermissionsBuildFileResult = PermissionSetBuildResult[];
10
7
  /**
11
8
  * Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally)
12
9
  * record types, then generates a permission set XML file with a baseline of permissions
13
10
  * determined by `--type`. An optional JSON `--config` file can override individual object,
14
11
  * field, tab, record type, and user permission settings, as well as whether the permission set
15
12
  * requires activation.
13
+ *
14
+ * With `--file`, generates every permission set declared in a JSON permission sets file instead,
15
+ * validating the whole file before writing anything.
16
16
  */
17
- export default class PermissionsBuild extends SfCommand<PermissionsBuildResult> {
17
+ export default class PermissionsBuild extends SfCommand<PermissionsBuildResult | PermissionsBuildFileResult> {
18
18
  static readonly summary: string;
19
19
  static readonly description: string;
20
20
  static readonly examples: string[];
21
21
  static readonly flags: {
22
- type: import("@oclif/core/interfaces").OptionFlag<PermissionSetType, import("@oclif/core/interfaces").CustomOptions>;
23
- name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
24
- directory: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
22
+ file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ type: import("@oclif/core/interfaces").OptionFlag<PermissionSetType | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ directory: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
26
  config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
27
+ output: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
28
  'include-record-types': import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
29
  label: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
30
  description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
30
31
  'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
31
32
  };
32
- /** @returns The output file path and the number of object/field permissions written. */
33
- run(): Promise<PermissionsBuildResult>;
33
+ /** @returns The output file path and object/field permission counts — or, with `--file`, one such entry (plus its name) per permission set. */
34
+ run(): Promise<PermissionsBuildResult | PermissionsBuildFileResult>;
35
+ private buildFromFile;
34
36
  }
35
- export {};
@@ -13,24 +13,44 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- /* eslint-disable no-await-in-loop */
17
- /* eslint-disable complexity */
18
- import fs from 'node:fs/promises';
19
- import path from 'node:path';
20
16
  import { Messages } from '@salesforce/core';
21
17
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
22
- import { ComponentSet } from '@salesforce/source-deploy-retrieve';
23
- import { loadJsonConfig } from '@simplysf/simply-core';
24
- import { buildPermissionSetXml, } from '@simplysf/simply-permissions-core';
25
- import { PermissionSetBuildConfigSchema } from '../../../schemas/build/permissionConfig.js';
18
+ import { generatePermissionSets, loadPermissionSetBuildConfig, loadPermissionSetsFile, PermissionSetBuildError, } from '@simplysf/simply-permissions-core';
26
19
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
27
20
  const messages = Messages.loadMessages('@simplysf/simply-permissions', 'simply.permissions.build');
21
+ /** The flags that describe a single permission set, and so can't be combined with `--file`. */
22
+ const SINGLE_PERMISSION_SET_FLAGS = [
23
+ 'type',
24
+ 'name',
25
+ 'directory',
26
+ 'output',
27
+ 'config',
28
+ 'include-record-types',
29
+ 'label',
30
+ 'description',
31
+ ];
32
+ /** Maps `PermissionSetBuildError`'s structural codes to this command's own `Messages` catalog. */
33
+ function toCliError(error) {
34
+ switch (error.code) {
35
+ case 'scan-failed':
36
+ return messages.createError('error.scanFailed', error.args);
37
+ case 'invalid-config':
38
+ return messages.createError('error.invalidConfig', error.args);
39
+ case 'config-not-found':
40
+ return messages.createError('error.configNotFound', error.args);
41
+ case 'directory-not-found':
42
+ return messages.createError('error.directoryNotFound', error.args);
43
+ }
44
+ }
28
45
  /**
29
46
  * Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally)
30
47
  * record types, then generates a permission set XML file with a baseline of permissions
31
48
  * determined by `--type`. An optional JSON `--config` file can override individual object,
32
49
  * field, tab, record type, and user permission settings, as well as whether the permission set
33
50
  * requires activation.
51
+ *
52
+ * With `--file`, generates every permission set declared in a JSON permission sets file instead,
53
+ * validating the whole file before writing anything.
34
54
  */
35
55
  export default class PermissionsBuild extends SfCommand {
36
56
  static summary = messages.getMessage('summary');
@@ -38,25 +58,29 @@ export default class PermissionsBuild extends SfCommand {
38
58
  static examples = messages.getMessages('examples');
39
59
  static flags = {
40
60
  ...SfCommand.baseFlags,
61
+ file: Flags.file({
62
+ summary: messages.getMessage('flags.file.summary'),
63
+ description: messages.getMessage('flags.file.description'),
64
+ char: 'f',
65
+ exists: true,
66
+ exclusive: SINGLE_PERMISSION_SET_FLAGS,
67
+ }),
41
68
  type: Flags.custom({
42
69
  options: ['read-only', 'view-all', 'modify-all'],
43
70
  })({
44
71
  summary: messages.getMessage('flags.type.summary'),
45
72
  description: messages.getMessage('flags.type.description'),
46
- required: true,
47
73
  }),
48
74
  name: Flags.string({
49
75
  summary: messages.getMessage('flags.name.summary'),
50
76
  description: messages.getMessage('flags.name.description'),
51
77
  char: 'n',
52
- required: true,
53
78
  }),
54
79
  directory: Flags.directory({
55
80
  summary: messages.getMessage('flags.directory.summary'),
56
81
  description: messages.getMessage('flags.directory.description'),
57
82
  char: 'd',
58
83
  exists: true,
59
- required: true,
60
84
  }),
61
85
  config: Flags.file({
62
86
  summary: messages.getMessage('flags.config.summary'),
@@ -67,7 +91,6 @@ export default class PermissionsBuild extends SfCommand {
67
91
  output: Flags.directory({
68
92
  summary: messages.getMessage('flags.output.summary'),
69
93
  description: messages.getMessage('flags.output.description'),
70
- required: true,
71
94
  }),
72
95
  'include-record-types': Flags.boolean({
73
96
  summary: messages.getMessage('flags.include-record-types.summary'),
@@ -81,246 +104,70 @@ export default class PermissionsBuild extends SfCommand {
81
104
  summary: messages.getMessage('flags.description.summary'),
82
105
  }),
83
106
  };
84
- /** @returns The output file path and the number of object/field permissions written. */
107
+ /** @returns The output file path and object/field permission counts — or, with `--file`, one such entry (plus its name) per permission set. */
85
108
  async run() {
86
109
  const { flags } = await this.parse(PermissionsBuild);
87
- let config;
88
- if (flags.config) {
89
- this.spinner.start(messages.getMessage('info.readingConfig'));
90
- const parsed = await loadJsonConfig(flags.config, PermissionSetBuildConfigSchema);
91
- if (!parsed.success) {
92
- throw messages.createError('error.invalidConfig', [parsed.message]);
93
- }
94
- config = parsed.data;
95
- this.spinner.stop();
96
- }
97
- this.spinner.start(messages.getMessage('info.scanningProject'));
98
- const objectPermissions = new Map();
99
- const fieldPermissions = new Map();
100
- const tabSettings = new Map();
101
- const recordTypeVisibilities = new Map();
102
- let components;
103
110
  try {
104
- components = ComponentSet.fromSource(flags.directory);
105
- }
106
- catch (error) {
107
- throw messages.createError('error.scanFailed', [error.message]);
108
- }
109
- this.spinner.stop();
110
- this.spinner.start(messages.getMessage('info.compilingPermissions'));
111
- for (const rawComponent of components) {
112
- const component = rawComponent;
113
- if (component.type.name === 'CustomObject') {
114
- if (!objectPermissions.has(component.fullName)) {
115
- objectPermissions.set(component.fullName, {
116
- object: component.fullName,
117
- allowCreate: false,
118
- allowDelete: false,
119
- allowEdit: false,
120
- allowRead: true,
121
- modifyAllRecords: false,
122
- viewAllRecords: flags.type === 'view-all',
123
- viewAllFields: false,
124
- });
125
- }
126
- for (const child of component.getChildren()) {
127
- if (child.type.name === 'CustomField') {
128
- const fieldContent = await child.parseXml();
129
- const customField = fieldContent.CustomField;
130
- if (customField && (String(customField.required) === 'true' || customField.type === 'MasterDetail')) {
131
- continue;
132
- }
133
- if (!fieldPermissions.has(component.fullName)) {
134
- fieldPermissions.set(component.fullName, new Map());
135
- }
136
- fieldPermissions.get(component.fullName)?.set(child.fullName, {
137
- field: `${component.fullName}.${child.fullName}`,
138
- readable: true,
139
- editable: false,
140
- });
141
- }
142
- else if (child.type.name === 'RecordType' && flags['include-record-types']) {
143
- if (!recordTypeVisibilities.has(component.fullName)) {
144
- recordTypeVisibilities.set(component.fullName, new Map());
145
- }
146
- recordTypeVisibilities.get(component.fullName)?.set(child.fullName, {
147
- recordType: `${component.fullName}.${child.fullName}`,
148
- visible: true,
149
- });
150
- }
151
- }
152
- }
153
- else if (component.type.name === 'CustomField') {
154
- const fieldContent = await component.parseXml();
155
- const customField = fieldContent.CustomField;
156
- if (customField && (String(customField.required) === 'true' || customField.type === 'MasterDetail')) {
157
- continue;
158
- }
159
- const objectName = component.parent?.name ?? '';
160
- if (!fieldPermissions.has(objectName)) {
161
- fieldPermissions.set(objectName, new Map());
162
- }
163
- if (!fieldPermissions.get(objectName)?.has(component.name)) {
164
- fieldPermissions.get(objectName)?.set(component.name, {
165
- field: `${objectName}.${component.name}`,
166
- readable: true,
167
- editable: false,
168
- });
169
- }
111
+ if (flags.file) {
112
+ return await this.buildFromFile(flags.file);
170
113
  }
171
- else if (component.type.name === 'CustomTab') {
172
- if (!tabSettings.has(component.name)) {
173
- tabSettings.set(component.name, {
174
- tab: component.name,
175
- visible: true,
176
- });
177
- }
178
- }
179
- }
180
- if (flags.type === 'read-only' || flags.type === 'view-all') {
181
- for (const permission of objectPermissions.values()) {
182
- permission.viewAllFields = true;
114
+ const { type, name, directory, output } = flags;
115
+ if (!type || !name || !directory || !output) {
116
+ const missing = Object.entries({ type, name, directory, output })
117
+ .filter(([, value]) => !value)
118
+ .map(([flag]) => `--${flag}`);
119
+ throw messages.createError('error.missingRequiredFlags', [missing.join(', ')]);
183
120
  }
184
- }
185
- if (flags.type === 'modify-all') {
186
- for (const permission of objectPermissions.values()) {
187
- permission.allowCreate = true;
188
- permission.allowDelete = true;
189
- permission.allowEdit = true;
190
- permission.allowRead = true;
191
- permission.modifyAllRecords = true;
192
- permission.viewAllRecords = true;
193
- }
194
- for (const fields of fieldPermissions.values()) {
195
- for (const field of fields.values()) {
196
- field.editable = true;
197
- field.readable = true;
198
- }
199
- }
200
- }
201
- if (config?.objects) {
202
- for (const [objectName, objectPerms] of Object.entries(config.objects)) {
203
- if (!objectPermissions.has(objectName)) {
204
- objectPermissions.set(objectName, {
205
- object: objectName,
206
- allowCreate: false,
207
- allowDelete: false,
208
- allowEdit: false,
209
- allowRead: false,
210
- modifyAllRecords: false,
211
- viewAllRecords: false,
212
- viewAllFields: false,
213
- });
214
- }
215
- const permission = objectPermissions.get(objectName);
216
- if (permission) {
217
- permission.allowRead = objectPerms.read ?? permission.allowRead;
218
- permission.allowCreate = objectPerms.create ?? permission.allowCreate;
219
- permission.allowEdit = objectPerms.edit ?? permission.allowEdit;
220
- permission.allowDelete = objectPerms.delete ?? permission.allowDelete;
221
- permission.modifyAllRecords = objectPerms.modifyAll ?? permission.modifyAllRecords;
222
- permission.viewAllRecords = objectPerms.viewAll ?? permission.viewAllRecords;
223
- permission.viewAllFields = objectPerms.viewAllFields ?? permission.viewAllFields;
224
- }
225
- }
226
- }
227
- if (config?.fields) {
228
- for (const [fullFieldName, fieldPerms] of Object.entries(config.fields)) {
229
- const [objectName, fieldName] = fullFieldName.split('.');
230
- if (!fieldPermissions.has(objectName)) {
231
- fieldPermissions.set(objectName, new Map());
232
- }
233
- const fieldMap = fieldPermissions.get(objectName);
234
- let field = fieldMap?.get(fieldName);
235
- if (!field) {
236
- field = { field: fullFieldName, readable: false, editable: false };
237
- fieldMap?.set(fieldName, field);
238
- }
239
- field.readable = fieldPerms.readable ?? field.readable;
240
- field.editable = fieldPerms.editable ?? field.editable;
241
- }
242
- }
243
- if (config?.tabs) {
244
- for (const [tabName, tabPerms] of Object.entries(config.tabs)) {
245
- if (!tabSettings.has(tabName)) {
246
- tabSettings.set(tabName, { tab: tabName, visible: false });
247
- }
248
- const setting = tabSettings.get(tabName);
249
- if (setting) {
250
- setting.visible = tabPerms.visible ?? setting.visible;
251
- }
252
- }
253
- }
254
- if (config?.recordTypeVisibilities) {
255
- for (const [fullRecordTypeName, rtPerms] of Object.entries(config.recordTypeVisibilities)) {
256
- const [objectName, recordTypeName] = fullRecordTypeName.split('.');
257
- if (!recordTypeVisibilities.has(objectName)) {
258
- recordTypeVisibilities.set(objectName, new Map());
259
- }
260
- const rtMap = recordTypeVisibilities.get(objectName);
261
- let recordType = rtMap?.get(recordTypeName);
262
- if (!recordType) {
263
- recordType = { recordType: fullRecordTypeName, visible: false };
264
- rtMap?.set(recordTypeName, recordType);
265
- }
266
- recordType.visible = rtPerms.visible ?? recordType.visible;
267
- }
268
- }
269
- const label = flags.label ?? flags.name;
270
- const outputFilename = `${flags.name}.permissionset-meta.xml`;
271
- const outputPath = path.join(flags.output, outputFilename);
272
- const templateData = {
273
- label,
274
- description: flags.description,
275
- hasActivationRequired: config?.hasActivationRequired ?? false,
276
- objectPermissions: [],
277
- fieldPermissions: [],
278
- tabSettings: [],
279
- recordTypeVisibilities: [],
280
- userPermissions: [],
281
- };
282
- for (const objectPermission of objectPermissions.values()) {
283
- templateData.objectPermissions.push(objectPermission);
284
- }
285
- for (const [objectName, fields] of fieldPermissions.entries()) {
286
- const objectPerm = objectPermissions.get(objectName);
287
- if (objectPerm?.viewAllFields) {
288
- continue;
289
- }
290
- for (const fieldPermission of fields.values()) {
291
- templateData.fieldPermissions.push(fieldPermission);
292
- }
293
- }
294
- for (const tabSetting of tabSettings.values()) {
295
- templateData.tabSettings.push(tabSetting);
296
- }
297
- for (const recordTypes of recordTypeVisibilities.values()) {
298
- for (const recordType of recordTypes.values()) {
299
- templateData.recordTypeVisibilities.push(recordType);
121
+ let config;
122
+ if (flags.config) {
123
+ this.spinner.start(messages.getMessage('info.readingConfig'));
124
+ config = await loadPermissionSetBuildConfig(flags.config);
125
+ this.spinner.stop();
300
126
  }
127
+ const [built] = await generatePermissionSets([
128
+ {
129
+ type,
130
+ name,
131
+ label: flags.label,
132
+ description: flags.description,
133
+ includeRecordTypes: flags['include-record-types'],
134
+ config,
135
+ directory,
136
+ output,
137
+ },
138
+ ], () => this.spinner.start(messages.getMessage('info.buildingPermissionSet', [name])));
139
+ this.spinner.stop();
140
+ this.info(messages.getMessage('info.fileGenerated', [built.path]));
141
+ return {
142
+ path: built.path,
143
+ objectPermissionCount: built.objectPermissionCount,
144
+ fieldPermissionCount: built.fieldPermissionCount,
145
+ };
301
146
  }
302
- if (config?.userPermissions) {
303
- for (const [name, enabled] of Object.entries(config.userPermissions)) {
304
- templateData.userPermissions.push({ name, enabled });
305
- }
147
+ catch (error) {
148
+ throw error instanceof PermissionSetBuildError ? toCliError(error) : error;
306
149
  }
307
- templateData.objectPermissions.sort((a, b) => a.object.localeCompare(b.object));
308
- templateData.fieldPermissions.sort((a, b) => a.field.localeCompare(b.field));
309
- templateData.tabSettings.sort((a, b) => a.tab.localeCompare(b.tab));
310
- templateData.recordTypeVisibilities.sort((a, b) => a.recordType.localeCompare(b.recordType));
311
- templateData.userPermissions.sort((a, b) => a.name.localeCompare(b.name));
150
+ }
151
+ async buildFromFile(file) {
152
+ this.spinner.start(messages.getMessage('info.readingConfig'));
153
+ const specs = await loadPermissionSetsFile(file);
312
154
  this.spinner.stop();
313
- this.spinner.start(messages.getMessage('info.writingFile'));
314
- const xml = buildPermissionSetXml(templateData);
315
- await fs.mkdir(flags.output, { recursive: true });
316
- await fs.writeFile(outputPath, xml);
155
+ const results = await generatePermissionSets(specs, (name) => {
156
+ this.spinner.stop();
157
+ this.spinner.start(messages.getMessage('info.buildingPermissionSet', [name]));
158
+ });
317
159
  this.spinner.stop();
318
- this.info(messages.getMessage('info.fileGenerated', [outputPath]));
319
- return {
320
- path: outputPath,
321
- objectPermissionCount: templateData.objectPermissions.length,
322
- fieldPermissionCount: templateData.fieldPermissions.length,
323
- };
160
+ this.table({
161
+ data: results,
162
+ columns: [
163
+ { key: 'name', name: 'NAME' },
164
+ { key: 'path', name: 'PATH' },
165
+ { key: 'objectPermissionCount', name: 'OBJECT PERMISSIONS' },
166
+ { key: 'fieldPermissionCount', name: 'FIELD PERMISSIONS' },
167
+ ],
168
+ });
169
+ this.info(messages.getMessage('info.filesGenerated', [results.length]));
170
+ return results;
324
171
  }
325
172
  }
326
173
  //# sourceMappingURL=build.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/commands/simply/permissions/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qCAAqC;AACrC,+BAA+B;AAC/B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAA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AC7E,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,IAAY;QACtC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9D,MAAM,KAAK,GAAwB,MAAM,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YAC3D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,4BAA4B,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;gBAC7B,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;gBAC7B,EAAE,GAAG,EAAE,uBAAuB,EAAE,IAAI,EAAE,oBAAoB,EAAE;gBAC5D,EAAE,GAAG,EAAE,sBAAsB,EAAE,IAAI,EAAE,mBAAmB,EAAE;aAC3D;SACF,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAExE,OAAO,OAAO,CAAC;IACjB,CAAC"}
@@ -1,18 +1,50 @@
1
1
  # summary
2
2
 
3
- Generate a permission set from Salesforce source metadata.
3
+ Generate permission sets from Salesforce source metadata.
4
4
 
5
5
  # description
6
6
 
7
7
  Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally) record types, then generates a permission set XML file with a baseline of permissions determined by --type. An optional JSON --config file can override individual object, field, tab, record type, and user permission settings, as well as whether the permission set requires activation.
8
8
 
9
+ To regenerate every permission set in a project with one command, declare them all in a JSON file and pass it with --file instead of the other flags. Each entry in the file's "permissionSets" array takes the same settings as one run of this command; a top-level "defaults" object supplies the "directory", "output", and "includeRecordTypes" values shared by every entry, and any entry can override them. An entry's "config" is either a path to a --config file or the same overrides inline. Relative paths are resolved against the current directory, as they are for flags. The whole file, including referenced override files and source directories, is validated before anything is written, and each source directory is scanned only once.
10
+
11
+ {
12
+ "defaults": {
13
+ "directory": "force-app",
14
+ "output": "force-app/main/default/permissionsets"
15
+ },
16
+ "permissionSets": [
17
+ { "name": "App_Read_Only", "type": "read-only" },
18
+ {
19
+ "name": "App_Admin",
20
+ "type": "modify-all",
21
+ "label": "App Admin",
22
+ "includeRecordTypes": true,
23
+ "config": "config/app-admin-overrides.json"
24
+ },
25
+ {
26
+ "name": "App_Support",
27
+ "type": "view-all",
28
+ "config": { "userPermissions": { "ViewSetup": true } }
29
+ }
30
+ ]
31
+ }
32
+
33
+ # flags.file.summary
34
+
35
+ Path to a permission sets file declaring every permission set to generate
36
+
37
+ # flags.file.description
38
+
39
+ The path to a JSON file with a "permissionSets" array, each entry describing one permission set to generate ("name", "type", and optionally "label", "description", "directory", "output", "includeRecordTypes", "config"), and an optional "defaults" object. Can't be combined with the flags that describe a single permission set.
40
+
9
41
  # flags.type.summary
10
42
 
11
43
  Baseline permission type
12
44
 
13
45
  # flags.type.description
14
46
 
15
- The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields, 'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access.
47
+ The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields, 'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access. Required unless --file is used.
16
48
 
17
49
  # flags.name.summary
18
50
 
@@ -20,7 +52,7 @@ API name for the permission set
20
52
 
21
53
  # flags.name.description
22
54
 
23
- The API name for the generated permission set; also used to derive the output filename.
55
+ The API name for the generated permission set; also used to derive the output filename. Required unless --file is used.
24
56
 
25
57
  # flags.directory.summary
26
58
 
@@ -28,7 +60,7 @@ Path to the Salesforce project directory
28
60
 
29
61
  # flags.directory.description
30
62
 
31
- The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types.
63
+ The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required unless --file is used.
32
64
 
33
65
  # flags.config.summary
34
66
 
@@ -44,7 +76,7 @@ Output directory
44
76
 
45
77
  # flags.output.description
46
78
 
47
- The directory to write the generated permission set XML file to.
79
+ The directory to write the generated permission set XML file to. Required unless --file is used.
48
80
 
49
81
  # flags.include-record-types.summary
50
82
 
@@ -68,30 +100,42 @@ Description for the permission set
68
100
 
69
101
  - <%= config.bin %> <%= command.id %> --type modify-all --name My_Admin_Access --directory force-app --config config/permission-overrides.json --output force-app/main/default/permissionsets --include-record-types
70
102
 
103
+ - Regenerate every permission set declared in a permission sets file:
104
+
105
+ <%= config.bin %> <%= command.id %> --file config/permission-sets.json
106
+
107
+ # error.missingRequiredFlags
108
+
109
+ Missing required flag(s): %s. Provide them, or use --file to build every permission set declared in a permission sets file.
110
+
71
111
  # error.invalidConfig
72
112
 
73
- The permission set configuration file is invalid: %s
113
+ The configuration file %s is invalid: %s
74
114
 
75
- # error.scanFailed
115
+ # error.configNotFound
76
116
 
77
- Failed to scan the Salesforce project directory: %s
117
+ The configuration file %s does not exist.
78
118
 
79
- # info.readingConfig
119
+ # error.directoryNotFound
80
120
 
81
- Reading and validating configuration file...
121
+ The source directory %s for permission set %s does not exist.
82
122
 
83
- # info.scanningProject
123
+ # error.scanFailed
84
124
 
85
- Scanning Salesforce project directory...
125
+ Failed to scan the Salesforce project directory: %s
86
126
 
87
- # info.compilingPermissions
127
+ # info.readingConfig
88
128
 
89
- Compiling permissions baseline and configuration overrides...
129
+ Reading and validating configuration file...
90
130
 
91
- # info.writingFile
131
+ # info.buildingPermissionSet
92
132
 
93
- Generating and writing permission set XML file...
133
+ Building permission set %s...
94
134
 
95
135
  # info.fileGenerated
96
136
 
97
137
  Permission set successfully generated at %s
138
+
139
+ # info.filesGenerated
140
+
141
+ Successfully generated %s permission set(s).
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.3.13",
4
+ "version": "1.4.0",
5
5
  "author": "@ClayChipps",
6
6
  "homepage": "https://github.com/SimplySF/simply-plugins",
7
7
  "bugs": "https://github.com/SimplySF/simply-plugins/issues",
@@ -62,7 +62,7 @@
62
62
  "@salesforce/sf-plugins-core": "^12.2.16",
63
63
  "@salesforce/source-deploy-retrieve": "^12.37.2",
64
64
  "@simplysf/simply-core": "^1.6.7",
65
- "@simplysf/simply-permissions-core": "^0.2.2",
65
+ "@simplysf/simply-permissions-core": "^0.3.0",
66
66
  "@simplysf/simply-plugin-kit": "^1.0.9",
67
67
  "zod": "^4.6.5"
68
68
  },
@@ -199,5 +199,5 @@
199
199
  "output": []
200
200
  }
201
201
  },
202
- "gitHead": "957b4c8951ba95c2ffe609c26ec15b571c19de3c"
202
+ "gitHead": "754633e6e1f0de42dc6f03150fe725ca137c88fa"
203
203
  }
@@ -1,31 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Schema for the JSON config file consumed by `simply permissions build`. `objects`, `fields`,
4
- * `tabs`, and `recordTypeVisibilities` are keyed by `Object` / `Object.Field` / `Object.Tab` /
5
- * `Object.RecordType` API names; `hasActivationRequired` applies to the permission set as a whole.
6
- */
7
- export declare const PermissionSetBuildConfigSchema: z.ZodObject<{
8
- objects: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
9
- read: z.ZodOptional<z.ZodBoolean>;
10
- create: z.ZodOptional<z.ZodBoolean>;
11
- edit: z.ZodOptional<z.ZodBoolean>;
12
- delete: z.ZodOptional<z.ZodBoolean>;
13
- modifyAll: z.ZodOptional<z.ZodBoolean>;
14
- viewAll: z.ZodOptional<z.ZodBoolean>;
15
- viewAllFields: z.ZodOptional<z.ZodBoolean>;
16
- }, z.core.$strip>>>;
17
- fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
18
- readable: z.ZodOptional<z.ZodBoolean>;
19
- editable: z.ZodOptional<z.ZodBoolean>;
20
- }, z.core.$strip>>>;
21
- tabs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
22
- visible: z.ZodOptional<z.ZodBoolean>;
23
- }, z.core.$strip>>>;
24
- recordTypeVisibilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
25
- visible: z.ZodOptional<z.ZodBoolean>;
26
- }, z.core.$strip>>>;
27
- userPermissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
28
- hasActivationRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
29
- }, z.core.$strip>;
30
- /** A parsed, validated permission set build config. */
31
- export type PermissionSetBuildConfig = z.infer<typeof PermissionSetBuildConfigSchema>;
@@ -1,54 +0,0 @@
1
- /*
2
- * Copyright (c) 2026, SimplySF.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { z } from 'zod';
17
- /** Object-level CRUD/access permissions, as granted for a single sObject in `objects`. */
18
- const ObjectPermissionConfigSchema = z.object({
19
- read: z.boolean().optional(),
20
- create: z.boolean().optional(),
21
- edit: z.boolean().optional(),
22
- delete: z.boolean().optional(),
23
- modifyAll: z.boolean().optional(),
24
- viewAll: z.boolean().optional(),
25
- viewAllFields: z.boolean().optional(),
26
- });
27
- /** Field-level read/edit permissions, as granted for a single field in `fields`. */
28
- const FieldPermissionConfigSchema = z.object({
29
- readable: z.boolean().optional(),
30
- editable: z.boolean().optional(),
31
- });
32
- /** Tab visibility, as granted for a single tab in `tabs`. */
33
- const TabPermissionConfigSchema = z.object({
34
- visible: z.boolean().optional(),
35
- });
36
- /** Record type visibility, as granted for a single record type in `recordTypeVisibilities`. */
37
- const RecordTypeVisibilityConfigSchema = z.object({
38
- visible: z.boolean().optional(),
39
- });
40
- /**
41
- * Schema for the JSON config file consumed by `simply permissions build`. `objects`, `fields`,
42
- * `tabs`, and `recordTypeVisibilities` are keyed by `Object` / `Object.Field` / `Object.Tab` /
43
- * `Object.RecordType` API names; `hasActivationRequired` applies to the permission set as a whole.
44
- */
45
- export const PermissionSetBuildConfigSchema = z.object({
46
- objects: z.record(z.string(), ObjectPermissionConfigSchema).optional(),
47
- fields: z.record(z.string(), FieldPermissionConfigSchema).optional(),
48
- tabs: z.record(z.string(), TabPermissionConfigSchema).optional(),
49
- recordTypeVisibilities: z.record(z.string(), RecordTypeVisibilityConfigSchema).optional(),
50
- userPermissions: z.record(z.string(), z.boolean()).optional(),
51
- /** Whether the permission set requires activation before it grants access. Defaults to `false`. */
52
- hasActivationRequired: z.boolean().optional().default(false),
53
- });
54
- //# sourceMappingURL=permissionConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"permissionConfig.js","sourceRoot":"","sources":["../../../src/schemas/build/permissionConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0FAA0F;AAC1F,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;I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