sf-plugin-permission-sets 0.0.0-dev.19 → 0.0.0-dev.21

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 (71) hide show
  1. package/README.md +31 -28
  2. package/lib/adapters/connection-org-client.d.ts +7 -3
  3. package/lib/adapters/connection-org-client.js +173 -4
  4. package/lib/adapters/connection-org-client.js.map +1 -1
  5. package/lib/commands/ps/apply.d.ts +25 -0
  6. package/lib/commands/ps/apply.js +116 -0
  7. package/lib/commands/ps/apply.js.map +1 -0
  8. package/lib/commands/ps/check.d.ts +1 -1
  9. package/lib/commands/ps/check.js +1 -1
  10. package/lib/commands/ps/check.js.map +1 -1
  11. package/lib/commands/ps/export.d.ts +17 -0
  12. package/lib/commands/ps/export.js +29 -0
  13. package/lib/commands/ps/export.js.map +1 -0
  14. package/lib/commands/ps/plan.d.ts +21 -0
  15. package/lib/commands/ps/plan.js +74 -0
  16. package/lib/commands/ps/plan.js.map +1 -0
  17. package/lib/commands/ps/validate.d.ts +1 -1
  18. package/lib/commands/ps/validate.js +1 -1
  19. package/lib/commands/ps/validate.js.map +1 -1
  20. package/lib/core/diff.d.ts +8 -0
  21. package/lib/core/diff.js +35 -0
  22. package/lib/core/diff.js.map +1 -0
  23. package/lib/core/finding.d.ts +27 -0
  24. package/lib/core/finding.js +22 -0
  25. package/lib/core/finding.js.map +1 -0
  26. package/lib/core/load.js +2 -1
  27. package/lib/core/load.js.map +1 -1
  28. package/lib/core/model.d.ts +38 -7
  29. package/lib/core/normalize.d.ts +5 -1
  30. package/lib/core/normalize.js +6 -9
  31. package/lib/core/normalize.js.map +1 -1
  32. package/lib/core/parse.d.ts +1 -1
  33. package/lib/core/parse.js +3 -8
  34. package/lib/core/parse.js.map +1 -1
  35. package/lib/core/report.d.ts +6 -8
  36. package/lib/core/report.js +45 -11
  37. package/lib/core/report.js.map +1 -1
  38. package/lib/core/resolve.d.ts +6 -1
  39. package/lib/core/resolve.js +31 -12
  40. package/lib/core/resolve.js.map +1 -1
  41. package/lib/core/schema.d.ts +1 -1
  42. package/lib/core/schema.js +2 -6
  43. package/lib/core/schema.js.map +1 -1
  44. package/lib/core/serialize.d.ts +7 -0
  45. package/lib/core/serialize.js +27 -0
  46. package/lib/core/serialize.js.map +1 -0
  47. package/lib/services/adapters/org-client.d.ts +19 -0
  48. package/lib/services/adapters/org-client.js.map +1 -0
  49. package/lib/services/apply.d.ts +40 -0
  50. package/lib/services/apply.js +115 -0
  51. package/lib/services/apply.js.map +1 -0
  52. package/lib/services/check.d.ts +2 -1
  53. package/lib/services/check.js +1 -1
  54. package/lib/services/check.js.map +1 -1
  55. package/lib/services/export.d.ts +13 -0
  56. package/lib/services/export.js +25 -0
  57. package/lib/services/export.js.map +1 -0
  58. package/lib/services/plan.d.ts +35 -0
  59. package/lib/services/plan.js +70 -0
  60. package/lib/services/plan.js.map +1 -0
  61. package/lib/services/validate.d.ts +3 -2
  62. package/lib/services/validate.js +2 -2
  63. package/lib/services/validate.js.map +1 -1
  64. package/messages/ps.apply.md +81 -0
  65. package/messages/ps.export.md +25 -0
  66. package/messages/ps.plan.md +45 -0
  67. package/oclif.manifest.json +267 -1
  68. package/package.json +10 -7
  69. package/lib/services/org-client.d.ts +0 -11
  70. package/lib/services/org-client.js.map +0 -1
  71. /package/lib/services/{org-client.js → adapters/org-client.js} +0 -0
package/README.md CHANGED
@@ -18,8 +18,8 @@ Stop clicking through Setup to grant access. Commit a YAML file, open a PR, let
18
18
  - [Quick start](#quick-start)
19
19
  - [Permission files](#permission-files)
20
20
  - [Organizing files](#organizing-files)
21
- - [Validations](#validations)
22
21
  - [Modes](#modes)
22
+ - [Validations](#validations)
23
23
  - [Commands](#commands)
24
24
  - [Inspiration & equivalents](#inspiration--equivalents)
25
25
  - [Versioning](#versioning)
@@ -59,7 +59,7 @@ Requires Salesforce CLI (`sf`) and Node.js 18+.
59
59
 
60
60
  ```bash
61
61
  # 1. Bootstrap YAML from an existing org (so you don't start from scratch)
62
- sf ps export --target-org dev --output-dir permissions
62
+ sf ps export --target-org dev --output-file permissions.yml
63
63
 
64
64
  # 2. Edit the files, commit, open a PR. Validate offline, no org needed:
65
65
  sf ps check --file "./permissions/*.yml"
@@ -159,6 +159,18 @@ sf ps apply -o qa --file "permissions/qa/*.yml"
159
159
 
160
160
  The two compose: a directory per environment, each split into functional files.
161
161
 
162
+ ## Modes
163
+
164
+ A run performs two atomic operations: **add** missing assignments and **remove** undeclared ones. The mode selects which it actually executes. Set it with `--mode` (default `additive`):
165
+
166
+ | Mode | Adds missing | Removes undeclared | Use when… |
167
+ | ------------- | :----------: | :----------------: | --------------------------------------------------------------------- |
168
+ | `additive` | ✅ | ❌ | **Default.** Grant access, never revoke. Safe rollout. |
169
+ | `destructive` | ❌ | ✅ | Prune/revoke access that isn't declared, without granting anything new. |
170
+ | `sync` | ✅ | ✅ | Full reconcile: make the org exactly match the YAML (`sync` = `additive` + `destructive`). |
171
+
172
+ `plan` always shows the *full* picture (both adds **and** would-be removes) regardless of mode, so you can preview the impact before running it. Whatever the chosen mode won't act on is surfaced as **drift**.
173
+
162
174
  ## Validations
163
175
 
164
176
  Every run checks the files first. `check` runs the offline checks with no org, and `validate` adds the org-side checks. When files merge, most overlaps are unions rather than errors.
@@ -171,25 +183,13 @@ Every run checks the files first. `check` runs the offline checks with no org, a
171
183
  | Same user in two files with different targets | `check` (offline) | ✅ ok | Merged into one model, the point of slicing |
172
184
  | Declared user, permission set, group, or license missing or not unique | `validate` (online) | ❌ error | Run fails before any change |
173
185
 
174
- ## Modes
175
-
176
- A run performs two atomic operations: **add** missing assignments and **remove** undeclared ones. The mode selects which it actually executes. Set it with `--mode` (default `additive`):
177
-
178
- | Mode | Adds missing | Removes undeclared | Use when… |
179
- | ------------- | :----------: | :----------------: | --------------------------------------------------------------------- |
180
- | `additive` | ✅ | ❌ | **Default.** Grant access, never revoke. Safe rollout. |
181
- | `destructive` | ❌ | ✅ | Prune/revoke access that isn't declared, without granting anything new. |
182
- | `sync` | ✅ | ✅ | Full reconcile: make the org exactly match the YAML (`sync` = `additive` + `destructive`). |
183
-
184
- `plan` always shows the *full* picture (both adds **and** would-be removes) regardless of mode, so you can preview the impact before running it. Whatever the chosen mode won't act on is surfaced as **drift**. Gate CI on it with `--fail-on-drift`.
185
-
186
186
  ## Commands
187
187
 
188
188
  | Command | Purpose |
189
189
  | ---------------- | ---------------------------------------------------------------------- |
190
190
  | `sf ps check` | Static analysis of the files alone: schema, duplicates, conflicts, identifier shape. No org, no auth. |
191
191
  | `sf ps validate` | Everything `check` does, plus resolving every user/permission set against the org. |
192
- | `sf ps plan` | Compute and display the change set. Optionally fail on drift. |
192
+ | `sf ps plan` | Compute and display the change set: a read-only preview of what `apply` would do. |
193
193
  | `sf ps apply` | Reconcile the org. Honors `--mode`, prompts before deletes, enforces guardrails. |
194
194
  | `sf ps export` | Generate YAML from the current org state to bootstrap adoption. |
195
195
 
@@ -235,13 +235,12 @@ group, and license referenced actually exists and resolves uniquely.
235
235
 
236
236
  ```
237
237
  USAGE
238
- $ sf ps plan -o <org> -f <glob>... [--mode <value>] [--fail-on-drift] [--watch] [--json]
238
+ $ sf ps plan -o <org> -f <glob>... [--mode <value>] [--watch] [--json]
239
239
 
240
240
  FLAGS
241
241
  -o, --target-org=<org> (required)
242
242
  -f, --file=<glob>... (required) YAML file(s) to read. Repeatable, globs expanded by the plugin.
243
243
  --mode=<value> additive | destructive | sync [default: additive]
244
- --fail-on-drift Exit non-zero if any change is pending (for CI gates).
245
244
  -w, --watch Re-diff against the org on every change to a matched file. Read-only (never applies), but each run queries the org.
246
245
  ```
247
246
 
@@ -288,18 +287,19 @@ Deletions always prompt for confirmation unless `--no-prompt` is set, and are ha
288
287
 
289
288
  ### `sf ps export`
290
289
 
290
+ Read-only. Snapshots the org's current assignments into a single YAML file you can commit and then feed back into the other commands.
291
+
291
292
  ```
292
293
  USAGE
293
- $ sf ps export -o <org> [--output-dir <dir>] [--layout <value>]
294
- [--permission-sets <names>] [--json]
294
+ $ sf ps export -o <org> --output-file <file> [--json]
295
295
 
296
296
  FLAGS
297
- -o, --target-org=<org> (required)
298
- --output-dir=<dir> [default: permissions] Where to write the generated YAML.
299
- --layout=<value> by-permission-set | by-user [default: by-permission-set]
300
- --permission-sets=<names> Comma-separated list to export (default: all assignable).
297
+ -o, --target-org=<org> (required) Org to read assignments from.
298
+ --output-file=<file> (required) Path of the YAML file to write. Parent directories are created; an existing file is overwritten.
301
299
  ```
302
300
 
301
+ It exports every assignable permission set, group, and license assignment held by active users, keyed by username, so the result is immediately valid input for `check`, `validate`, `plan`, and `apply`. Profile-owned permission sets and inactive users are skipped.
302
+
303
303
  ## Inspiration & equivalents
304
304
 
305
305
  This plugin's command surface borrows ideas from tools you already know:
@@ -350,21 +350,24 @@ The `next` tag is selected whenever the version contains a hyphen, not by GitHub
350
350
  The plugin is layered so every command reuses the same core. Commands stay thin, services hold the orchestration, core holds the reusable primitives, and a thin adapter layer isolates the Salesforce SDK.
351
351
 
352
352
  - **Commands** (`src/commands/ps/`): oclif only. They parse flags, construct the service (wiring in the org adapter when the command needs one), render output, and set the exit code.
353
- - **Services** (`src/services/`): one per command (`check` and `validate` today, then `plan`, `apply`, `export`). Each is a class built from its dependencies and inputs, with a parameterless `run()` that turns the core into a command's behavior. A service also declares the ports it needs from the outside, like the `OrgClient` interface its adapter implements.
353
+ - **Services** (`src/services/`): one per command (`check`, `validate`, `export`, `apply`, and `plan`). Each is a class built from its dependencies and inputs, with a parameterless `run()` that turns the core into a command's behavior. A service also declares the ports it needs from the outside, like the `OrgClient` interface its adapter implements.
354
354
  - **Core** (`src/core/`): the reusable building blocks. Pure, with no `@salesforce/*` imports, so every piece is unit-testable on its own.
355
355
  - **Adapters** (`src/adapters/`): the boundary to the outside world. `ConnectionOrgClient` implements the `OrgClient` port (declared in services) with a Salesforce `Connection`, and owns all the SOQL and SObject detail. Services depend on the port, not the SDK, so they test against a fake and stay free of connection detail.
356
356
 
357
357
  | Core module | Responsibility |
358
358
  | --- | --- |
359
- | `model` | Shared domain types (assignment, finding, result). |
359
+ | `model` | Shared domain types (assignment, org, diff). |
360
+ | `finding` | The finding type and code vocabulary, plus constructors, formatting, and counting. |
360
361
  | `schema` | The zod contract for a file, plus validation. |
361
362
  | `parse` | File text to an object, with YAML and duplicate-key errors. |
362
363
  | `normalize` | A validated file to canonical `(assignee, kind, target)` tuples, plus structural findings. |
364
+ | `serialize` | Canonical tuples back to a user-keyed YAML document (the inverse of `normalize`). |
363
365
  | `load` | Expand globs, run parse then validate then normalize per file, and merge by union. |
364
- | `resolve` | Pure rules that turn declared references and the org's answers into findings. No SOQL: the adapter owns that. |
365
- | `report` | Format and count findings. |
366
+ | `resolve` | Pure rules that turn declared references and the org's answers into findings, plus id lookups for assigning. No SOQL: the adapter owns that. |
367
+ | `diff` | The desired model vs. the org's current state, producing adds, removes, and unchanged. |
368
+ | `report` | Format a diff as a plan. |
366
369
 
367
- Commands are slices of one pipeline. `check` runs the offline **load** stage only. `validate` adds **resolve**: it looks the declared references up through the `OrgClient` port (the adapter builds the SOQL) and evaluates the org's answers with resolve's pure rules. The remaining online commands layer **fetch** (current org state), **diff** (desired vs actual), and **apply** (DML) on top, reusing load, resolve, report, model, and schema unchanged.
370
+ Commands are slices of one pipeline. `check` runs the offline **load** stage only. `validate` adds **resolve**: it looks the declared references up through the `OrgClient` port (the adapter builds the SOQL) and evaluates the org's answers with resolve's pure rules. `export` runs in the opposite direction: it **fetch**es the org's current assignments through the port and **serialize**s them straight back to YAML, skipping load entirely. `apply` is the full pipeline: load, resolve to ids, **fetch** current state, **diff**, then insert and delete through the Collections API per the mode (guarded by `--max-deletes` and a confirmation). `plan` is that same pipeline stopping before the DML: load, resolve to ids, **fetch** current state, **diff**, and report, the same preview `apply --dry-run` produces.
368
371
 
369
372
  ## License
370
373
 
@@ -1,11 +1,15 @@
1
1
  import { Connection } from '@salesforce/core';
2
- import { Kind, OrgUser } from '../core/model.js';
3
- import { OrgClient } from '../services/org-client.js';
2
+ import { ActualAssignment, AssignmentOutcome, DesiredAssignment, Kind, OrgTarget, OrgUser, ResolvedAddition, TargetRef } from '../core/model.js';
3
+ import { OrgClient } from '../services/adapters/org-client.js';
4
4
  /** Adapter backing OrgClient with a Salesforce Connection. autoFetchQuery pages past 2000 rows. */
5
5
  export declare class ConnectionOrgClient implements OrgClient {
6
6
  private readonly connection;
7
7
  constructor(connection: Connection);
8
8
  findUsers(usernames: string[]): Promise<OrgUser[]>;
9
- findTargets(kind: Kind, names: string[]): Promise<string[]>;
9
+ findTargets(kind: Kind, names: string[]): Promise<OrgTarget[]>;
10
+ listAssignments(): Promise<DesiredAssignment[]>;
11
+ currentAssignments(targets: TargetRef[]): Promise<ActualAssignment[]>;
12
+ addAssignments(additions: ResolvedAddition[]): Promise<AssignmentOutcome[]>;
13
+ removeAssignments(removals: ActualAssignment[]): Promise<AssignmentOutcome[]>;
10
14
  private query;
11
15
  }
@@ -4,6 +4,14 @@ const targetObjects = {
4
4
  permissionSetGroup: { sobject: 'PermissionSetGroup', field: 'DeveloperName' },
5
5
  permissionSetLicense: { sobject: 'PermissionSetLicense', field: 'DeveloperName' },
6
6
  };
7
+ /** SObject + foreign-key field to set per kind when assigning. */
8
+ const assignmentObjects = {
9
+ permissionSet: { sobject: 'PermissionSetAssignment', idField: 'PermissionSetId' },
10
+ permissionSetGroup: { sobject: 'PermissionSetAssignment', idField: 'PermissionSetGroupId' },
11
+ permissionSetLicense: { sobject: 'PermissionSetLicenseAssign', idField: 'PermissionSetLicenseId' },
12
+ };
13
+ /** The sObject Collections API caps each create/delete call at 200 records. */
14
+ const collectionBatchSize = 200;
7
15
  /** Escape a value for safe inclusion in a SOQL string literal. */
8
16
  function soqlLiteral(value) {
9
17
  return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
@@ -12,6 +20,65 @@ function soqlLiteral(value) {
12
20
  function inList(values) {
13
21
  return values.map((value) => `'${soqlLiteral(value)}'`).join(', ');
14
22
  }
23
+ /** Split items into chunks of at most `size`. */
24
+ function chunk(items, size) {
25
+ const chunks = [];
26
+ for (let index = 0; index < items.length; index += size) {
27
+ chunks.push(items.slice(index, index + size));
28
+ }
29
+ return chunks;
30
+ }
31
+ /** Turn a per-record DML result into a domain outcome, capturing the error message on failure. */
32
+ function outcomeOf(assignment, operation, result) {
33
+ const success = result?.success ?? false;
34
+ const message = result && !result.success ? result.errors.map((error) => error.message).join('; ') : undefined;
35
+ return {
36
+ assignee: assignment.assignee,
37
+ kind: assignment.kind,
38
+ target: assignment.target,
39
+ operation,
40
+ success,
41
+ message,
42
+ };
43
+ }
44
+ /** Group additions by sObject and chunk them for the Collections API, keeping each record's source. */
45
+ function additionBatches(additions) {
46
+ const bySobject = new Map();
47
+ for (const addition of additions) {
48
+ const { sobject } = assignmentObjects[addition.kind];
49
+ const grouped = bySobject.get(sobject) ?? [];
50
+ grouped.push(addition);
51
+ bySobject.set(sobject, grouped);
52
+ }
53
+ const batches = [];
54
+ for (const [sobject, grouped] of bySobject) {
55
+ for (const batch of chunk(grouped, collectionBatchSize)) {
56
+ const records = batch.map((addition) => ({
57
+ AssigneeId: addition.assigneeId,
58
+ [assignmentObjects[addition.kind].idField]: addition.targetId,
59
+ }));
60
+ batches.push({ sobject, additions: batch, records });
61
+ }
62
+ }
63
+ return batches;
64
+ }
65
+ /** Group removals by sObject and chunk them for the Collections API. */
66
+ function removalBatches(removals) {
67
+ const bySobject = new Map();
68
+ for (const removal of removals) {
69
+ const { sobject } = assignmentObjects[removal.kind];
70
+ const grouped = bySobject.get(sobject) ?? [];
71
+ grouped.push(removal);
72
+ bySobject.set(sobject, grouped);
73
+ }
74
+ const batches = [];
75
+ for (const [sobject, grouped] of bySobject) {
76
+ for (const batch of chunk(grouped, collectionBatchSize)) {
77
+ batches.push({ sobject, removals: batch });
78
+ }
79
+ }
80
+ return batches;
81
+ }
15
82
  /** Adapter backing OrgClient with a Salesforce Connection. autoFetchQuery pages past 2000 rows. */
16
83
  export class ConnectionOrgClient {
17
84
  connection;
@@ -19,13 +86,115 @@ export class ConnectionOrgClient {
19
86
  this.connection = connection;
20
87
  }
21
88
  async findUsers(usernames) {
22
- const records = await this.query(`SELECT Username, IsActive FROM User WHERE Username IN (${inList(usernames)})`);
23
- return records.map((record) => ({ username: record.Username, isActive: record.IsActive }));
89
+ const records = await this.query(`SELECT Id, Username, IsActive FROM User WHERE Username IN (${inList(usernames)})`);
90
+ return records.map((record) => ({ id: record.Id, username: record.Username, isActive: record.IsActive }));
24
91
  }
25
92
  async findTargets(kind, names) {
26
93
  const { sobject, field } = targetObjects[kind];
27
- const records = await this.query(`SELECT ${field} FROM ${sobject} WHERE ${field} IN (${inList(names)})`);
28
- return records.map((record) => record[field]);
94
+ const records = await this.query(`SELECT Id, ${field} FROM ${sobject} WHERE ${field} IN (${inList(names)})`);
95
+ return records.map((record) => ({ id: record.Id, name: record[field] }));
96
+ }
97
+ async listAssignments() {
98
+ const [memberships, licenses] = await Promise.all([
99
+ this.query('SELECT Id, Assignee.Username, PermissionSet.Name, PermissionSetGroup.DeveloperName, PermissionSetGroupId ' +
100
+ 'FROM PermissionSetAssignment ' +
101
+ 'WHERE Assignee.IsActive = true AND PermissionSet.IsOwnedByProfile = false'),
102
+ this.query('SELECT Id, Assignee.Username, PermissionSetLicense.DeveloperName ' +
103
+ 'FROM PermissionSetLicenseAssign ' +
104
+ 'WHERE Assignee.IsActive = true'),
105
+ ]);
106
+ const assignments = [];
107
+ for (const record of memberships) {
108
+ if (record.PermissionSetGroupId && record.PermissionSetGroup) {
109
+ assignments.push({
110
+ assignee: record.Assignee.Username,
111
+ kind: 'permissionSetGroup',
112
+ target: record.PermissionSetGroup.DeveloperName,
113
+ });
114
+ }
115
+ else {
116
+ assignments.push({
117
+ assignee: record.Assignee.Username,
118
+ kind: 'permissionSet',
119
+ target: record.PermissionSet.Name,
120
+ });
121
+ }
122
+ }
123
+ for (const record of licenses) {
124
+ assignments.push({
125
+ assignee: record.Assignee.Username,
126
+ kind: 'permissionSetLicense',
127
+ target: record.PermissionSetLicense.DeveloperName,
128
+ });
129
+ }
130
+ return assignments;
131
+ }
132
+ async currentAssignments(targets) {
133
+ const permissionSetIds = targets.filter((ref) => ref.kind === 'permissionSet').map((ref) => ref.id);
134
+ const groupIds = targets.filter((ref) => ref.kind === 'permissionSetGroup').map((ref) => ref.id);
135
+ const licenseIds = targets.filter((ref) => ref.kind === 'permissionSetLicense').map((ref) => ref.id);
136
+ const tasks = [];
137
+ const memberClauses = [];
138
+ if (permissionSetIds.length > 0)
139
+ memberClauses.push(`PermissionSetId IN (${inList(permissionSetIds)})`);
140
+ if (groupIds.length > 0)
141
+ memberClauses.push(`PermissionSetGroupId IN (${inList(groupIds)})`);
142
+ if (memberClauses.length > 0) {
143
+ const soql = 'SELECT Id, Assignee.Username, PermissionSet.Name, PermissionSetGroup.DeveloperName, PermissionSetGroupId ' +
144
+ `FROM PermissionSetAssignment WHERE ${memberClauses.join(' OR ')}`;
145
+ tasks.push(this.query(soql).then((records) => records.map((record) => record.PermissionSetGroupId && record.PermissionSetGroup
146
+ ? {
147
+ recordId: record.Id,
148
+ assignee: record.Assignee.Username,
149
+ kind: 'permissionSetGroup',
150
+ target: record.PermissionSetGroup.DeveloperName,
151
+ }
152
+ : {
153
+ recordId: record.Id,
154
+ assignee: record.Assignee.Username,
155
+ kind: 'permissionSet',
156
+ target: record.PermissionSet.Name,
157
+ })));
158
+ }
159
+ if (licenseIds.length > 0) {
160
+ const soql = 'SELECT Id, Assignee.Username, PermissionSetLicense.DeveloperName ' +
161
+ `FROM PermissionSetLicenseAssign WHERE PermissionSetLicenseId IN (${inList(licenseIds)})`;
162
+ tasks.push(this.query(soql).then((records) => records.map((record) => ({
163
+ recordId: record.Id,
164
+ assignee: record.Assignee.Username,
165
+ kind: 'permissionSetLicense',
166
+ target: record.PermissionSetLicense.DeveloperName,
167
+ }))));
168
+ }
169
+ const results = await Promise.all(tasks);
170
+ return results.flat();
171
+ }
172
+ async addAssignments(additions) {
173
+ const batches = additionBatches(additions);
174
+ const settled = await Promise.all(batches.map((batch) => this.connection.create(batch.sobject, batch.records, { allOrNone: false }).then((results) => ({
175
+ batch,
176
+ results: results,
177
+ }))));
178
+ const outcomes = [];
179
+ for (const { batch, results } of settled) {
180
+ batch.additions.forEach((addition, index) => {
181
+ outcomes.push(outcomeOf(addition, 'add', results[index]));
182
+ });
183
+ }
184
+ return outcomes;
185
+ }
186
+ async removeAssignments(removals) {
187
+ const batches = removalBatches(removals);
188
+ const settled = await Promise.all(batches.map((batch) => this.connection
189
+ .destroy(batch.sobject, batch.removals.map((removal) => removal.recordId), { allOrNone: false })
190
+ .then((results) => ({ batch, results: results }))));
191
+ const outcomes = [];
192
+ for (const { batch, results } of settled) {
193
+ batch.removals.forEach((removal, index) => {
194
+ outcomes.push(outcomeOf(removal, 'remove', results[index]));
195
+ });
196
+ }
197
+ return outcomes;
29
198
  }
30
199
  async query(soql) {
31
200
  const result = await this.connection.autoFetchQuery(soql);
@@ -1 +1 @@
1
- {"version":3,"file":"connection-org-client.js","sourceRoot":"","sources":["../../src/adapters/connection-org-client.ts"],"names":[],"mappings":"AAMA,gGAAgG;AAChG,MAAM,aAAa,GAA+B;IAC9C,aAAa,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE;IAC1D,kBAAkB,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,eAAe,EAAE;IAC7E,oBAAoB,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,eAAe,EAAE;CACpF,CAAC;AAEF,kEAAkE;AAClE,SAAS,WAAW,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,+DAA+D;AAC/D,SAAS,MAAM,CAAC,MAAgB;IAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAA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M,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,MAAM,CAAC,OAAyB,CAAC;IAC5C,CAAC;CACJ"}
@@ -0,0 +1,25 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type PsApplyResult = {
3
+ status: string;
4
+ toAdd: number;
5
+ toRemove: number;
6
+ added: number;
7
+ removed: number;
8
+ failures: number;
9
+ };
10
+ export default class Apply extends SfCommand<PsApplyResult> {
11
+ static readonly summary: string;
12
+ static readonly description: string;
13
+ static readonly examples: string[];
14
+ static readonly flags: {
15
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
16
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ file: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
18
+ mode: import("@oclif/core/interfaces").OptionFlag<"additive" | "destructive" | "sync", import("@oclif/core/interfaces").CustomOptions>;
19
+ 'max-deletes': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
+ 'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
22
+ };
23
+ run(): Promise<PsApplyResult>;
24
+ private reportDrift;
25
+ }
@@ -0,0 +1,116 @@
1
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
2
+ import { Messages } from '@salesforce/core';
3
+ import { ConnectionOrgClient } from '../../adapters/connection-org-client.js';
4
+ import { ApplyService } from '../../services/apply.js';
5
+ import { formatDiff } from '../../core/report.js';
6
+ import { formatFindings } from '../../core/finding.js';
7
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
8
+ const messages = Messages.loadMessages('sf-plugin-permission-sets', 'ps.apply');
9
+ export default class Apply extends SfCommand {
10
+ static summary = messages.getMessage('summary');
11
+ static description = messages.getMessage('description');
12
+ static examples = messages.getMessages('examples');
13
+ static flags = {
14
+ 'target-org': Flags.requiredOrg(),
15
+ 'api-version': Flags.orgApiVersion(),
16
+ file: Flags.string({
17
+ char: 'f',
18
+ summary: messages.getMessage('flags.file.summary'),
19
+ required: true,
20
+ multiple: true,
21
+ }),
22
+ mode: Flags.option({
23
+ summary: messages.getMessage('flags.mode.summary'),
24
+ options: ['additive', 'destructive', 'sync'],
25
+ default: 'additive',
26
+ })(),
27
+ 'max-deletes': Flags.integer({
28
+ summary: messages.getMessage('flags.max-deletes.summary'),
29
+ default: 50,
30
+ min: 0,
31
+ }),
32
+ 'dry-run': Flags.boolean({
33
+ summary: messages.getMessage('flags.dry-run.summary'),
34
+ }),
35
+ 'no-prompt': Flags.boolean({
36
+ summary: messages.getMessage('flags.no-prompt.summary'),
37
+ }),
38
+ };
39
+ async run() {
40
+ const { flags } = await this.parse(Apply);
41
+ const connection = flags['target-org'].getConnection(flags['api-version']);
42
+ const orgClient = new ConnectionOrgClient(connection);
43
+ const confirmDeletions = async (count) => {
44
+ if (flags['no-prompt'])
45
+ return true;
46
+ if (this.jsonEnabled())
47
+ throw messages.createError('error.promptInJson');
48
+ return this.confirm({ message: messages.getMessage('confirm.delete', [String(count)]) });
49
+ };
50
+ const service = new ApplyService(orgClient, flags.file, { mode: flags.mode, maxDeletes: flags['max-deletes'], dryRun: flags['dry-run'] }, confirmDeletions);
51
+ const result = await service.run();
52
+ for (const line of formatFindings(result.findings)) {
53
+ this.log(line);
54
+ }
55
+ const added = result.outcomes.filter((outcome) => outcome.operation === 'add' && outcome.success).length;
56
+ const removed = result.outcomes.filter((outcome) => outcome.operation === 'remove' && outcome.success).length;
57
+ const failures = result.outcomes.filter((outcome) => !outcome.success);
58
+ const summary = {
59
+ status: result.status,
60
+ toAdd: result.diff.toAdd.length,
61
+ toRemove: result.diff.toRemove.length,
62
+ added,
63
+ removed,
64
+ failures: failures.length,
65
+ };
66
+ if (result.status === 'invalid') {
67
+ process.exitCode = 1;
68
+ if (!this.jsonEnabled())
69
+ this.error(messages.getMessage('error.invalid'), { exit: 1 });
70
+ return summary;
71
+ }
72
+ this.log('');
73
+ for (const line of formatDiff(result.diff)) {
74
+ this.log(line);
75
+ }
76
+ this.log('');
77
+ if (result.status === 'max-deletes-exceeded') {
78
+ process.exitCode = 1;
79
+ const tokens = [String(result.diff.toRemove.length), String(flags['max-deletes'])];
80
+ if (!this.jsonEnabled())
81
+ this.error(messages.getMessage('error.maxDeletes', tokens), { exit: 1 });
82
+ return summary;
83
+ }
84
+ this.reportDrift(result.drift, flags.mode);
85
+ if (result.status === 'dry-run') {
86
+ this.log(messages.getMessage('summary.dryRun', [String(summary.toAdd), String(summary.toRemove)]));
87
+ return summary;
88
+ }
89
+ if (result.status === 'declined') {
90
+ this.log(messages.getMessage('summary.declined'));
91
+ return summary;
92
+ }
93
+ this.log(messages.getMessage('summary.applied', [String(added), String(removed)]));
94
+ for (const failure of failures) {
95
+ this.log(messages.getMessage('failure.line', [
96
+ failure.operation,
97
+ failure.assignee,
98
+ failure.target,
99
+ failure.message ?? '',
100
+ ]));
101
+ }
102
+ if (result.failed) {
103
+ process.exitCode = 1;
104
+ if (!this.jsonEnabled())
105
+ this.error(messages.getMessage('error.failed'), { exit: 1 });
106
+ }
107
+ return summary;
108
+ }
109
+ reportDrift(drift, mode) {
110
+ if (drift.adds > 0)
111
+ this.log(messages.getMessage('drift.note', [String(drift.adds), mode]));
112
+ if (drift.removes > 0)
113
+ this.log(messages.getMessage('drift.note', [String(drift.removes), mode]));
114
+ }
115
+ }
116
+ //# sourceMappingURL=apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../src/commands/ps/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OA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,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,GAAG,CACJ,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE;gBAChC,OAAO,CAAC,SAAS;gBACjB,OAAO,CAAC,QAAQ;gBAChB,OAAO,CAAC,MAAM;gBACd,OAAO,CAAC,OAAO,IAAI,EAAE;aACxB,CAAC,CACL,CAAC;QACN,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,WAAW,CAAC,KAAwC,EAAE,IAAY;QACtE,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5F,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACtG,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { SfCommand } from '@salesforce/sf-plugins-core';
2
- import { Finding } from '../../core/model.js';
2
+ import { Finding } from '../../core/finding.js';
3
3
  export type PsCheckResult = {
4
4
  files: number;
5
5
  users: number;
@@ -1,7 +1,7 @@
1
1
  import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
2
2
  import { Messages } from '@salesforce/core';
3
3
  import { CheckService } from '../../services/check.js';
4
- import { formatFindings } from '../../core/report.js';
4
+ import { formatFindings } from '../../core/finding.js';
5
5
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
6
6
  const messages = Messages.loadMessages('sf-plugin-permission-sets', 'ps.check');
7
7
  export default class Check extends SfCommand {
@@ -1 +1 @@
1
- {"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/commands/ps/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,2BAA2B,EAAE,UAAU,CAAC,CAAC;AAShF,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,SAAwB;IAChD,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC3B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC;YACf,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;YAClD,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,MA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N,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ export type PsExportResult = {
3
+ outputFile: string;
4
+ users: number;
5
+ assignments: number;
6
+ };
7
+ export default class Export extends SfCommand<PsExportResult> {
8
+ static readonly summary: string;
9
+ static readonly description: string;
10
+ static readonly examples: string[];
11
+ static readonly flags: {
12
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
13
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'output-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ };
16
+ run(): Promise<PsExportResult>;
17
+ }
@@ -0,0 +1,29 @@
1
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
2
+ import { Messages } from '@salesforce/core';
3
+ import { ConnectionOrgClient } from '../../adapters/connection-org-client.js';
4
+ import { ExportService } from '../../services/export.js';
5
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
6
+ const messages = Messages.loadMessages('sf-plugin-permission-sets', 'ps.export');
7
+ export default class Export extends SfCommand {
8
+ static summary = messages.getMessage('summary');
9
+ static description = messages.getMessage('description');
10
+ static examples = messages.getMessages('examples');
11
+ static flags = {
12
+ 'target-org': Flags.requiredOrg(),
13
+ 'api-version': Flags.orgApiVersion(),
14
+ 'output-file': Flags.string({
15
+ summary: messages.getMessage('flags.output-file.summary'),
16
+ required: true,
17
+ }),
18
+ };
19
+ async run() {
20
+ const { flags } = await this.parse(Export);
21
+ const connection = flags['target-org'].getConnection(flags['api-version']);
22
+ const orgClient = new ConnectionOrgClient(connection);
23
+ const service = new ExportService(orgClient, flags['output-file']);
24
+ const result = await service.run();
25
+ this.log(messages.getMessage('success', [String(result.assignments), String(result.users), result.outputFile]));
26
+ return result;
27
+ }
28
+ }
29
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 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