sf-plugin-permission-sets 0.4.0 → 0.6.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 +135 -79
- package/lib/adapters/connection-org-client.d.ts +8 -6
- package/lib/adapters/connection-org-client.d.ts.map +1 -1
- package/lib/adapters/connection-org-client.js +187 -96
- package/lib/adapters/connection-org-client.js.map +1 -1
- package/lib/commands/ps/apply.d.ts +1 -15
- package/lib/commands/ps/apply.d.ts.map +1 -1
- package/lib/commands/ps/apply.js +11 -81
- package/lib/commands/ps/apply.js.map +1 -1
- package/lib/commands/ps/check.d.ts.map +1 -1
- package/lib/commands/ps/check.js +3 -3
- package/lib/commands/ps/check.js.map +1 -1
- package/lib/commands/ps/export.js +2 -2
- package/lib/commands/ps/export.js.map +1 -1
- package/lib/commands/ps/plan.d.ts +2 -8
- package/lib/commands/ps/plan.d.ts.map +1 -1
- package/lib/commands/ps/plan.js +31 -84
- package/lib/commands/ps/plan.js.map +1 -1
- package/lib/commands/ps/validate.d.ts.map +1 -1
- package/lib/commands/ps/validate.js +3 -3
- package/lib/commands/ps/validate.js.map +1 -1
- package/lib/core/diff.d.ts +37 -1
- package/lib/core/diff.d.ts.map +1 -1
- package/lib/core/diff.js +68 -4
- package/lib/core/diff.js.map +1 -1
- package/lib/core/finding.d.ts +9 -7
- package/lib/core/finding.d.ts.map +1 -1
- package/lib/core/finding.js +16 -8
- package/lib/core/finding.js.map +1 -1
- package/lib/core/index.d.ts +4 -4
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +3 -3
- package/lib/core/index.js.map +1 -1
- package/lib/core/load.js +1 -1
- package/lib/core/load.js.map +1 -1
- package/lib/core/model.d.ts +24 -25
- package/lib/core/model.d.ts.map +1 -1
- package/lib/core/normalize.d.ts.map +1 -1
- package/lib/core/normalize.js +13 -8
- package/lib/core/normalize.js.map +1 -1
- package/lib/core/report.d.ts +2 -1
- package/lib/core/report.d.ts.map +1 -1
- package/lib/core/report.js +30 -17
- package/lib/core/report.js.map +1 -1
- package/lib/core/resolve.d.ts +8 -6
- package/lib/core/resolve.d.ts.map +1 -1
- package/lib/core/resolve.js +18 -14
- package/lib/core/resolve.js.map +1 -1
- package/lib/core/serialize.d.ts.map +1 -1
- package/lib/core/serialize.js +29 -13
- package/lib/core/serialize.js.map +1 -1
- package/lib/core/target-name.d.ts +20 -0
- package/lib/core/target-name.d.ts.map +1 -0
- package/lib/core/target-name.js +32 -0
- package/lib/core/target-name.js.map +1 -0
- package/lib/core/username.d.ts +23 -0
- package/lib/core/username.d.ts.map +1 -0
- package/lib/core/username.js +35 -0
- package/lib/core/username.js.map +1 -0
- package/lib/services/adapters/org-client.d.ts +9 -5
- package/lib/services/adapters/org-client.d.ts.map +1 -1
- package/lib/services/apply.d.ts +1 -18
- package/lib/services/apply.d.ts.map +1 -1
- package/lib/services/apply.js +9 -38
- package/lib/services/apply.js.map +1 -1
- package/lib/services/export.d.ts.map +1 -1
- package/lib/services/export.js +3 -2
- package/lib/services/export.js.map +1 -1
- package/lib/services/index.d.ts +0 -1
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +0 -1
- package/lib/services/index.js.map +1 -1
- package/lib/services/plan.d.ts +4 -14
- package/lib/services/plan.d.ts.map +1 -1
- package/lib/services/plan.js +9 -22
- package/lib/services/plan.js.map +1 -1
- package/lib/services/resolution.d.ts +17 -9
- package/lib/services/resolution.d.ts.map +1 -1
- package/lib/services/resolution.js +43 -16
- package/lib/services/resolution.js.map +1 -1
- package/lib/services/validate.d.ts +2 -1
- package/lib/services/validate.d.ts.map +1 -1
- package/lib/services/validate.js +10 -1
- package/lib/services/validate.js.map +1 -1
- package/messages/ps.apply.md +2 -34
- package/messages/ps.plan.md +0 -8
- package/messages/ps.validate.md +1 -1
- package/package.json +10 -6
- package/lib/core/mode.d.ts +0 -18
- package/lib/core/mode.d.ts.map +0 -1
- package/lib/core/mode.js +0 -16
- package/lib/core/mode.js.map +0 -1
- package/lib/core/plan-file.d.ts +0 -61
- package/lib/core/plan-file.d.ts.map +0 -1
- package/lib/core/plan-file.js +0 -74
- package/lib/core/plan-file.js.map +0 -1
package/lib/services/apply.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { loadFiles, diffAssignments,
|
|
2
|
-
import { ResolutionService
|
|
3
|
-
const noDrift = { adds: 0, updates: 0, removes: 0 };
|
|
4
|
-
const emptyDiff = { toAdd: [], toUpdate: [], toRemove: [], unchanged: [] };
|
|
1
|
+
import { loadFiles, diffAssignments, Diff, countFindings, } from '../core/index.js';
|
|
2
|
+
import { ResolutionService } from './resolution.js';
|
|
5
3
|
/** An aborted-before-any-change result, carrying the findings that explain why. */
|
|
6
4
|
function invalidResult(files, findings) {
|
|
7
5
|
return {
|
|
8
6
|
files,
|
|
9
7
|
findings,
|
|
10
|
-
diff:
|
|
11
|
-
drift: { adds: 0, updates: 0, removes: 0 },
|
|
8
|
+
diff: Diff.empty(),
|
|
12
9
|
outcomes: [],
|
|
13
10
|
status: 'invalid',
|
|
14
11
|
failed: true,
|
|
@@ -42,58 +39,32 @@ export class ApplyService {
|
|
|
42
39
|
if (findingCounts.errors > 0) {
|
|
43
40
|
return invalidResult(loaded.files, findings);
|
|
44
41
|
}
|
|
45
|
-
const actual = await this.org.
|
|
42
|
+
const actual = await this.org.listCurrentAssignments(resolution.managedTargets());
|
|
46
43
|
const diff = diffAssignments(loaded.assignments, actual);
|
|
47
44
|
const { mode, maxDeletes, dryRun } = input;
|
|
48
|
-
const { additions, updates, removals
|
|
45
|
+
const { additions, updates, removals } = diff.scopeTo(mode);
|
|
49
46
|
if (removals.length > maxDeletes) {
|
|
50
47
|
return {
|
|
51
48
|
files: loaded.files,
|
|
52
49
|
findings,
|
|
53
50
|
diff,
|
|
54
|
-
drift,
|
|
55
51
|
outcomes: [],
|
|
56
52
|
status: 'max-deletes-exceeded',
|
|
57
53
|
failed: true,
|
|
58
54
|
};
|
|
59
55
|
}
|
|
60
56
|
if (dryRun) {
|
|
61
|
-
return { files: loaded.files, findings, diff,
|
|
57
|
+
return { files: loaded.files, findings, diff, outcomes: [], status: 'dry-run', failed: false };
|
|
62
58
|
}
|
|
63
59
|
if (removals.length > 0) {
|
|
64
60
|
const confirmed = await this.confirmDeletions(removals.length);
|
|
65
61
|
if (!confirmed) {
|
|
66
|
-
return { files: loaded.files, findings, diff,
|
|
62
|
+
return { files: loaded.files, findings, diff, outcomes: [], status: 'declined', failed: false };
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
|
-
const outcomes = await this.executeResolved(resolveAdditions(additions
|
|
65
|
+
const outcomes = await this.executeResolved(resolution.resolveAdditions(additions), updates, removals);
|
|
70
66
|
const failed = outcomes.some((outcome) => !outcome.success);
|
|
71
|
-
return { files: loaded.files, findings, diff,
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Apply a saved plan verbatim: no load, resolve, or diff. The plan is already
|
|
75
|
-
* mode-scoped and resolved, so there is no drift and no findings. maxDeletes and
|
|
76
|
-
* the deletion confirmation still guard the run.
|
|
77
|
-
*/
|
|
78
|
-
async runPlan(plan, input) {
|
|
79
|
-
const diff = { toAdd: plan.add, toUpdate: plan.update, toRemove: plan.remove, unchanged: [] };
|
|
80
|
-
const { maxDeletes, dryRun } = input;
|
|
81
|
-
const base = { files: [], findings: [], diff, drift: noDrift, outcomes: [] };
|
|
82
|
-
if (plan.remove.length > maxDeletes) {
|
|
83
|
-
return { ...base, status: 'max-deletes-exceeded', failed: true };
|
|
84
|
-
}
|
|
85
|
-
if (dryRun) {
|
|
86
|
-
return { ...base, status: 'dry-run', failed: false };
|
|
87
|
-
}
|
|
88
|
-
if (plan.remove.length > 0) {
|
|
89
|
-
const confirmed = await this.confirmDeletions(plan.remove.length);
|
|
90
|
-
if (!confirmed) {
|
|
91
|
-
return { ...base, status: 'declined', failed: false };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const outcomes = await this.executeResolved(plan.add, plan.update, plan.remove);
|
|
95
|
-
const failed = outcomes.some((outcome) => !outcome.success);
|
|
96
|
-
return { ...base, outcomes, status: 'applied', failed };
|
|
67
|
+
return { files: loaded.files, findings, diff, outcomes, status: 'applied', failed };
|
|
97
68
|
}
|
|
98
69
|
async executeResolved(additions, updates, removals) {
|
|
99
70
|
const [added, updated, removed] = await Promise.all([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/services/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,eAAe,
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/services/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,eAAe,EAIf,IAAI,EAGJ,aAAa,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAyBpD,mFAAmF;AACnF,SAAS,aAAa,CAAC,KAAe,EAAE,QAAmB;IACvD,OAAO;QACH,KAAK;QACL,QAAQ;QACR,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE;QAClB,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,IAAI;KACf,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,YAAY;IAEA;IACA;IAFrB,YACqB,GAAc,EACd,gBAAkC;QADlC,QAAG,GAAH,GAAG,CAAW;QACd,qBAAgB,GAAhB,gBAAgB,CAAkB;IACpD,CAAC;IAEG,KAAK,CAAC,GAAG,CAAC,KAAe,EAAE,KAAiB;QAC/C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,MA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C,CAAC,CAAC,OAAO,CAAC,OAAO,CAAsB,EAAE,CAAC;YACnG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAsB,EAAE,CAAC;SACxG,CAAC,CAAC;QAEH,OAAO;YACH,GAAG,KAAK;YACR,GAAG,OAAO;YACV,GAAG,OAAO;SACb,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG;IACvB,6FAA6F;IAC7F,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,qEAAqE;AACrE,qBAAa,aAAa;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG;IACvB,6FAA6F;IAC7F,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,qEAAqE;AACrE,qBAAa,aAAa;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAsBrG"}
|
package/lib/services/export.js
CHANGED
|
@@ -14,9 +14,10 @@ export class ExportService {
|
|
|
14
14
|
await mkdir(dirname(outputFile), { recursive: true });
|
|
15
15
|
await writeFile(outputFile, content, 'utf8');
|
|
16
16
|
}
|
|
17
|
-
const assignees = new Set(assignments.map((assignment) => assignment.assignee));
|
|
17
|
+
const assignees = new Set(assignments.map((assignment) => assignment.assignee.asKey()));
|
|
18
18
|
const requested = filter?.usernames ?? [];
|
|
19
|
-
const
|
|
19
|
+
const unmatched = requested.filter((username) => !assignees.has(username.asKey()));
|
|
20
|
+
const unmatchedUsers = unmatched.map((username) => username.toString());
|
|
20
21
|
return {
|
|
21
22
|
outputFile: outputFile ?? null,
|
|
22
23
|
content,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAoB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAc1E,qEAAqE;AACrE,MAAM,OAAO,aAAa;IACc;IAApC,YAAoC,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IA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EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACxF,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACnF,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QAExE,OAAO;YACH,UAAU,EAAE,UAAU,IAAI,IAAI;YAC9B,OAAO;YACP,KAAK,EAAE,SAAS,CAAC,IAAI;YACrB,WAAW,EAAE,WAAW,CAAC,MAAM;YAC/B,cAAc;SACjB,CAAC;IACN,CAAC;CACJ"}
|
package/lib/services/index.d.ts
CHANGED
|
@@ -2,6 +2,5 @@ export { ApplyService, ConfirmDeletions, ApplyResult } from './apply.js';
|
|
|
2
2
|
export { CheckService } from './check.js';
|
|
3
3
|
export { ExportService } from './export.js';
|
|
4
4
|
export { PlanService } from './plan.js';
|
|
5
|
-
export { Resolution, resolveAdditions } from './resolution.js';
|
|
6
5
|
export { ValidateService } from './validate.js';
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/services/index.js
CHANGED
|
@@ -2,6 +2,5 @@ export { ApplyService } from './apply.js';
|
|
|
2
2
|
export { CheckService } from './check.js';
|
|
3
3
|
export { ExportService } from './export.js';
|
|
4
4
|
export { PlanService } from './plan.js';
|
|
5
|
-
export { resolveAdditions } from './resolution.js';
|
|
6
5
|
export { ValidateService } from './validate.js';
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/services/plan.d.ts
CHANGED
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { Diff, Finding } from '../core/index.js';
|
|
2
2
|
import { OrgClient } from './adapters/index.js';
|
|
3
|
-
import { Resolution } from './resolution.js';
|
|
4
|
-
export type PlanMode = 'additive' | 'destructive' | 'sync';
|
|
5
3
|
/** How a run ended, so the command can report and set the exit code. */
|
|
6
4
|
export type PlanStatus = 'planned' | 'invalid';
|
|
7
5
|
export type PlanResult = {
|
|
8
6
|
files: string[];
|
|
9
7
|
findings: Finding[];
|
|
10
8
|
diff: Diff;
|
|
11
|
-
/** What the chosen mode would not act on (surfaced as drift). */
|
|
12
|
-
drift: {
|
|
13
|
-
adds: number;
|
|
14
|
-
updates: number;
|
|
15
|
-
removes: number;
|
|
16
|
-
};
|
|
17
|
-
/** The resolved id maps, so callers can freeze a plan without re-resolving. */
|
|
18
|
-
resolution: Resolution;
|
|
19
9
|
status: PlanStatus;
|
|
20
10
|
};
|
|
21
11
|
/**
|
|
22
12
|
* Read-only preview: load the files, resolve every reference to an org id, fetch the
|
|
23
|
-
* current state, and diff. The
|
|
24
|
-
*
|
|
25
|
-
*
|
|
13
|
+
* current state, and diff. The whole diff comes back, adds and would-be removes alike:
|
|
14
|
+
* narrowing it to a mode is the caller's call, through Diff.scopeTo. Never changes the
|
|
15
|
+
* org. This is the apply pipeline stopping before any DML.
|
|
26
16
|
*/
|
|
27
17
|
export declare class PlanService {
|
|
28
18
|
private readonly org;
|
|
29
19
|
constructor(org: OrgClient);
|
|
30
|
-
run(files: string[]
|
|
20
|
+
run(files: string[]): Promise<PlanResult>;
|
|
31
21
|
}
|
|
32
22
|
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;CACtB,CAAC;AAYF;;;;;GAKG;AACH,qBAAa,WAAW;IACD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAuBzD"}
|
package/lib/services/plan.js
CHANGED
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
import { loadFiles, diffAssignments, countFindings } from '../core/index.js';
|
|
2
|
-
import { ResolutionService
|
|
3
|
-
const emptyDiff = { toAdd: [], toUpdate: [], toRemove: [], unchanged: [] };
|
|
4
|
-
const emptyResolution = {
|
|
5
|
-
findings: [],
|
|
6
|
-
userIds: new Map(),
|
|
7
|
-
targetIds: {},
|
|
8
|
-
};
|
|
1
|
+
import { loadFiles, diffAssignments, Diff, countFindings } from '../core/index.js';
|
|
2
|
+
import { ResolutionService } from './resolution.js';
|
|
9
3
|
/** An aborted-before-the-diff result, carrying the findings that explain why. */
|
|
10
4
|
function invalidResult(files, findings) {
|
|
11
5
|
return {
|
|
12
6
|
files,
|
|
13
7
|
findings,
|
|
14
|
-
diff:
|
|
15
|
-
drift: { adds: 0, updates: 0, removes: 0 },
|
|
16
|
-
resolution: emptyResolution,
|
|
8
|
+
diff: Diff.empty(),
|
|
17
9
|
status: 'invalid',
|
|
18
10
|
};
|
|
19
11
|
}
|
|
20
12
|
/**
|
|
21
13
|
* Read-only preview: load the files, resolve every reference to an org id, fetch the
|
|
22
|
-
* current state, and diff. The
|
|
23
|
-
*
|
|
24
|
-
*
|
|
14
|
+
* current state, and diff. The whole diff comes back, adds and would-be removes alike:
|
|
15
|
+
* narrowing it to a mode is the caller's call, through Diff.scopeTo. Never changes the
|
|
16
|
+
* org. This is the apply pipeline stopping before any DML.
|
|
25
17
|
*/
|
|
26
18
|
export class PlanService {
|
|
27
19
|
org;
|
|
28
20
|
constructor(org) {
|
|
29
21
|
this.org = org;
|
|
30
22
|
}
|
|
31
|
-
async run(files
|
|
23
|
+
async run(files) {
|
|
32
24
|
const loaded = await loadFiles(files);
|
|
33
25
|
const loadCounts = countFindings(loaded.findings);
|
|
34
26
|
if (loadCounts.errors > 0) {
|
|
@@ -44,14 +36,9 @@ export class PlanService {
|
|
|
44
36
|
if (findingCounts.errors > 0) {
|
|
45
37
|
return invalidResult(loaded.files, findings);
|
|
46
38
|
}
|
|
47
|
-
const actual = await this.org.
|
|
39
|
+
const actual = await this.org.listCurrentAssignments(resolution.managedTargets());
|
|
48
40
|
const diff = diffAssignments(loaded.assignments, actual);
|
|
49
|
-
|
|
50
|
-
adds: mode === 'destructive' ? diff.toAdd.length : 0,
|
|
51
|
-
updates: mode === 'destructive' ? diff.toUpdate.length : 0,
|
|
52
|
-
removes: mode === 'additive' ? diff.toRemove.length : 0,
|
|
53
|
-
};
|
|
54
|
-
return { files: loaded.files, findings, diff, drift, resolution, status: 'planned' };
|
|
41
|
+
return { files: loaded.files, findings, diff, status: 'planned' };
|
|
55
42
|
}
|
|
56
43
|
}
|
|
57
44
|
//# sourceMappingURL=plan.js.map
|
package/lib/services/plan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[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YAC3B,OAAO,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;QAClF,MAAM,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACtE,CAAC;CACJ"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { DesiredAssignment, Kind, ResolvedAddition, TargetRef, Finding } from '../core/index.js';
|
|
1
|
+
import { DesiredAssignment, Kind, OrgTarget, ResolvedAddition, TargetName, TargetRef, Finding } from '../core/index.js';
|
|
2
2
|
import { OrgClient } from './adapters/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
/**
|
|
4
|
+
* What the org answered for every declared reference: the findings, plus the org ids of
|
|
5
|
+
* the references that did resolve. The indexes stay private because they are keyed by the
|
|
6
|
+
* identifiers' comparison key, and that rule belongs here rather than at every lookup.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Resolution {
|
|
9
|
+
readonly findings: Finding[];
|
|
10
|
+
private readonly userIds;
|
|
11
|
+
private readonly targetIds;
|
|
12
|
+
constructor(findings: Finding[], userIds: Map<string, string>, targetIds: Record<Kind, Map<string, string>>);
|
|
13
|
+
/** Every target that resolved, as the managed set to compare the org's state against. */
|
|
14
|
+
managedTargets(): TargetRef[];
|
|
15
|
+
/** Attach the resolved assignee and target ids to each addition, so it can be inserted. */
|
|
16
|
+
resolveAdditions(additions: DesiredAssignment[]): ResolvedAddition[];
|
|
17
|
+
}
|
|
11
18
|
/** Look every declared reference up in the org, returning findings and the resolved id maps. */
|
|
12
19
|
export declare class ResolutionService {
|
|
13
20
|
private readonly org;
|
|
14
21
|
constructor(org: OrgClient);
|
|
15
22
|
run(assignments: DesiredAssignment[]): Promise<Resolution>;
|
|
23
|
+
findTargetsOfKind(kind: Kind, names: TargetName[]): Promise<OrgTarget[]>;
|
|
16
24
|
}
|
|
17
25
|
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,IAAI,
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,IAAI,EACJ,SAAS,EAET,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,OAAO,EAQV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,UAAU;aAEC,QAAQ,EAAE,OAAO,EAAE;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAFV,QAAQ,EAAE,OAAO,EAAE,EAClB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAGjE,yFAAyF;IAClF,cAAc,IAAI,SAAS,EAAE;IAUpC,2FAA2F;IACpF,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,gBAAgB,EAAE;CAO9E;AAED,gGAAgG;AAChG,qBAAa,iBAAiB;IACP,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAuCvE,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAO3E"}
|
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
import { kinds, distinctAssignees, distinctTargets, evaluateUsers, evaluateTargets, indexUsersById, indexTargetsById, } from '../core/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* What the org answered for every declared reference: the findings, plus the org ids of
|
|
4
|
+
* the references that did resolve. The indexes stay private because they are keyed by the
|
|
5
|
+
* identifiers' comparison key, and that rule belongs here rather than at every lookup.
|
|
6
|
+
*/
|
|
7
|
+
export class Resolution {
|
|
8
|
+
findings;
|
|
9
|
+
userIds;
|
|
10
|
+
targetIds;
|
|
11
|
+
constructor(findings, userIds, targetIds) {
|
|
12
|
+
this.findings = findings;
|
|
13
|
+
this.userIds = userIds;
|
|
14
|
+
this.targetIds = targetIds;
|
|
15
|
+
}
|
|
16
|
+
/** Every target that resolved, as the managed set to compare the org's state against. */
|
|
17
|
+
managedTargets() {
|
|
18
|
+
const refs = [];
|
|
19
|
+
for (const kind of kinds) {
|
|
20
|
+
for (const id of this.targetIds[kind].values()) {
|
|
21
|
+
refs.push({ kind, id });
|
|
22
|
+
}
|
|
7
23
|
}
|
|
24
|
+
return refs;
|
|
25
|
+
}
|
|
26
|
+
/** Attach the resolved assignee and target ids to each addition, so it can be inserted. */
|
|
27
|
+
resolveAdditions(additions) {
|
|
28
|
+
return additions.map((addition) => ({
|
|
29
|
+
...addition,
|
|
30
|
+
assigneeId: this.userIds.get(addition.assignee.asKey()) ?? '',
|
|
31
|
+
targetId: this.targetIds[addition.kind].get(addition.target.asKey()) ?? '',
|
|
32
|
+
}));
|
|
8
33
|
}
|
|
9
|
-
return refs;
|
|
10
|
-
}
|
|
11
|
-
/** Attach the resolved assignee and target ids to each addition, so it can be inserted. */
|
|
12
|
-
export function resolveAdditions(additions, resolution) {
|
|
13
|
-
return additions.map((addition) => ({
|
|
14
|
-
...addition,
|
|
15
|
-
assigneeId: resolution.userIds.get(addition.assignee.toLowerCase()) ?? '',
|
|
16
|
-
targetId: resolution.targetIds[addition.kind].get(addition.target.toLowerCase()) ?? '',
|
|
17
|
-
}));
|
|
18
34
|
}
|
|
19
35
|
/** Look every declared reference up in the org, returning findings and the resolved id maps. */
|
|
20
36
|
export class ResolutionService {
|
|
@@ -27,7 +43,9 @@ export class ResolutionService {
|
|
|
27
43
|
const targetsByKind = kinds.map((kind) => ({ kind, targets: distinctTargets(assignments, kind) }));
|
|
28
44
|
const usersTask = usernames.length > 0 ? this.org.findUsers(usernames) : Promise.resolve([]);
|
|
29
45
|
const targetsTask = Promise.all(targetsByKind.map(async ({ kind, targets }) => {
|
|
30
|
-
|
|
46
|
+
if (targets.length === 0)
|
|
47
|
+
return { kind, targets, found: [] };
|
|
48
|
+
const found = await this.findTargetsOfKind(kind, targets);
|
|
31
49
|
return { kind, targets, found };
|
|
32
50
|
}));
|
|
33
51
|
const [foundUsers, perKind] = await Promise.all([
|
|
@@ -42,7 +60,16 @@ export class ResolutionService {
|
|
|
42
60
|
for (const { kind, found } of perKind) {
|
|
43
61
|
targetIds[kind] = indexTargetsById(found);
|
|
44
62
|
}
|
|
45
|
-
return
|
|
63
|
+
return new Resolution(findings, indexUsersById(foundUsers), targetIds);
|
|
64
|
+
}
|
|
65
|
+
findTargetsOfKind(kind, names) {
|
|
66
|
+
if (kind === 'permissionSet')
|
|
67
|
+
return this.org.findPermissionSets(names);
|
|
68
|
+
if (kind === 'permissionSetGroup')
|
|
69
|
+
return this.org.findPermissionSetGroups(names);
|
|
70
|
+
if (kind === 'permissionSetLicense')
|
|
71
|
+
return this.org.findPermissionSetLicenses(names);
|
|
72
|
+
throw new Error(`Unsupported kind: ${String(kind)}`);
|
|
46
73
|
}
|
|
47
74
|
}
|
|
48
75
|
//# sourceMappingURL=resolution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,GACnB,MAAM,kBAAkB,CAAC;AAG1B;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAEC;IACC;IACA;IAHrB,YACoB,QAAmB,EAClB,OAA4B,EAC5B,SAA4C;QAF7C,aAAQ,GAAR,QAAQ,CAAW;QAClB,YAAO,GAAP,OAAO,CAAqB;QAC5B,cAAS,GAAT,SAAS,CAAmC;IAC9D,CAAC;IAEJ,yFAAyF;IAClF,cAAc;QACjB,MAAM,IAAI,GAAgB,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC7C,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,2FAA2F;IACpF,gBAAgB,CAAC,SAA8B;QAClD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAChC,GAAG,QAAQ;YACX,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE;YAC7D,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CA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,GAAc,CAAC,GAAG,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;QACtE,KAAK,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC;YAC7C,QAAQ,CAAC,IAAI,CACT,GAAG,eAAe,CACd,IAAI,EACJ,OAAO,EACP,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CACrC,CACJ,CAAC;QACN,CAAC;QAED,MAAM,SAAS,GAAG,EAAuC,CAAC;QAC1D,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC;YACpC,SAAS,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;IAC3E,CAAC;IAED,iBAAiB,CAAC,IAAU,EAAE,KAAmB;QAC7C,IAAI,IAAI,KAAK,eAAe;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAClF,IAAI,IAAI,KAAK,sBAAsB;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAEtF,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DesiredAssignment, Finding } from '../core/index.js';
|
|
1
|
+
import { DesiredAssignment, Finding, Kind, OrgTarget, TargetName } from '../core/index.js';
|
|
2
2
|
import { OrgClient } from './adapters/index.js';
|
|
3
3
|
export type ValidateResult = {
|
|
4
4
|
files: string[];
|
|
@@ -17,5 +17,6 @@ export declare class ValidateService {
|
|
|
17
17
|
private resolve;
|
|
18
18
|
private evaluateUserRefs;
|
|
19
19
|
private evaluateTargetRefs;
|
|
20
|
+
findTargetsOfKind(kind: Kind, names: TargetName[]): Promise<OrgTarget[]>;
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,iBAAiB,EACjB,OAAO,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,iBAAiB,EACjB,OAAO,EACP,IAAI,EAEJ,SAAS,EACT,UAAU,EAEb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oEAAoE;AACpE,qBAAa,eAAe;IACL,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAoB1D,iFAAiF;YACnE,OAAO;YAmBP,gBAAgB;YAKhB,kBAAkB;IAShC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAO3E"}
|
package/lib/services/validate.js
CHANGED
|
@@ -43,8 +43,17 @@ export class ValidateService {
|
|
|
43
43
|
return evaluateUsers(usernames, found);
|
|
44
44
|
}
|
|
45
45
|
async evaluateTargetRefs(kind, targets) {
|
|
46
|
-
const found = await this.
|
|
46
|
+
const found = await this.findTargetsOfKind(kind, targets);
|
|
47
47
|
return evaluateTargets(kind, targets, found.map((target) => target.name));
|
|
48
48
|
}
|
|
49
|
+
findTargetsOfKind(kind, names) {
|
|
50
|
+
if (kind === 'permissionSet')
|
|
51
|
+
return this.org.findPermissionSets(names);
|
|
52
|
+
if (kind === 'permissionSetGroup')
|
|
53
|
+
return this.org.findPermissionSetGroups(names);
|
|
54
|
+
if (kind === 'permissionSetLicense')
|
|
55
|
+
return this.org.findPermissionSetLicenses(names);
|
|
56
|
+
throw new Error(`Unsupported kind: ${String(kind)}`);
|
|
57
|
+
}
|
|
49
58
|
}
|
|
50
59
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EAIf,aAAa,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EAIf,aAAa,GAIhB,MAAM,kBAAkB,CAAC;AAY1B,oEAAoE;AACpE,MAAM,OAAO,eAAe;IACY;IAApC,YAAoC,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAI,CAAC;IAEhD,KAAK,CAAC,GAAG,CAAC,KAAe;QAC5B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAA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EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,IAAU,EAAE,OAAqB;QAC9D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1D,OAAO,eAAe,CAClB,IAAI,EACJ,OAAO,EACP,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CACrC,CAAC;IACN,CAAC;IAED,iBAAiB,CAAC,IAAU,EAAE,KAAmB;QAC7C,IAAI,IAAI,KAAK,eAAe;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,IAAI,KAAK,oBAAoB;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAClF,IAAI,IAAI,KAAK,sBAAsB;YAAE,OAAO,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAEtF,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ"}
|
package/messages/ps.apply.md
CHANGED
|
@@ -8,15 +8,11 @@ Load the files, resolve every user and target against the org, diff the desired
|
|
|
8
8
|
|
|
9
9
|
# flags.file.summary
|
|
10
10
|
|
|
11
|
-
YAML file or glob to apply. Repeatable.
|
|
12
|
-
|
|
13
|
-
# flags.plan.summary
|
|
14
|
-
|
|
15
|
-
Apply a saved plan file from plan --out, running the reviewed change set verbatim. Provide either this or --file.
|
|
11
|
+
YAML file or glob to apply. Repeatable.
|
|
16
12
|
|
|
17
13
|
# flags.mode.summary
|
|
18
14
|
|
|
19
|
-
Which half of the reconcile to run: additive adds missing assignments and updates expirations, destructive removes only, sync does both.
|
|
15
|
+
Which half of the reconcile to run: additive adds missing assignments and updates expirations, destructive removes only, sync does both.
|
|
20
16
|
|
|
21
17
|
# flags.max-deletes.summary
|
|
22
18
|
|
|
@@ -34,10 +30,6 @@ List assignments that already match, instead of only counting them.
|
|
|
34
30
|
|
|
35
31
|
Skip the deletion confirmation prompt. Required to delete in JSON or other non-interactive runs.
|
|
36
32
|
|
|
37
|
-
# info.applyingPlan
|
|
38
|
-
|
|
39
|
-
Applying saved plan (mode %s).
|
|
40
|
-
|
|
41
33
|
# confirm.delete
|
|
42
34
|
|
|
43
35
|
This will remove %s assignment(s) from the org. Continue?
|
|
@@ -62,30 +54,6 @@ Aborted at the confirmation prompt. Nothing was changed.
|
|
|
62
54
|
|
|
63
55
|
failed to %s %s on %s: %s
|
|
64
56
|
|
|
65
|
-
# error.sourceConflict
|
|
66
|
-
|
|
67
|
-
Pass either --file or --plan, not both. --plan runs a saved plan; --file reads and diffs the YAML now.
|
|
68
|
-
|
|
69
|
-
# error.sourceMissing
|
|
70
|
-
|
|
71
|
-
Provide a source to apply: --file <glob> to read the YAML now, or --plan <file> to run a saved plan.
|
|
72
|
-
|
|
73
|
-
# error.modeWithPlan
|
|
74
|
-
|
|
75
|
-
--mode cannot be combined with --plan. A saved plan already carries the mode it was computed for. Re-run plan with the mode you want to get a new plan.
|
|
76
|
-
|
|
77
|
-
# error.planRead
|
|
78
|
-
|
|
79
|
-
Could not read the plan file: %s
|
|
80
|
-
|
|
81
|
-
# error.planInvalid
|
|
82
|
-
|
|
83
|
-
The plan file %s is not a valid plan: %s. Regenerate it with plan --out.
|
|
84
|
-
|
|
85
|
-
# error.planOrg
|
|
86
|
-
|
|
87
|
-
This plan was built for org %s but the target org is %s. Regenerate the plan against the target org.
|
|
88
|
-
|
|
89
57
|
# error.invalid
|
|
90
58
|
|
|
91
59
|
The files do not resolve cleanly against the org. Fix the errors above, then re-run.
|
package/messages/ps.plan.md
CHANGED
|
@@ -18,14 +18,6 @@ Which half of the reconcile to preview: additive adds and updates expirations, d
|
|
|
18
18
|
|
|
19
19
|
List assignments that already match, instead of only counting them.
|
|
20
20
|
|
|
21
|
-
# flags.out.summary
|
|
22
|
-
|
|
23
|
-
Write the computed change set to a plan file that apply can run verbatim with --plan.
|
|
24
|
-
|
|
25
|
-
# summary.wrotePlan
|
|
26
|
-
|
|
27
|
-
Wrote a plan with %s change(s) to %s. Apply it with: ps apply --plan %s
|
|
28
|
-
|
|
29
21
|
# header.title
|
|
30
22
|
|
|
31
23
|
Permission Set Assignments Plan
|
package/messages/ps.validate.md
CHANGED
|
@@ -22,7 +22,7 @@ Validation found problems. See the output above.
|
|
|
22
22
|
|
|
23
23
|
- Validate every file under permissions against the dev org:
|
|
24
24
|
|
|
25
|
-
<%= config.bin %> <%= command.id %> --file "permissions
|
|
25
|
+
<%= config.bin %> <%= command.id %> --file "permissions/*.yml" --target-org dev
|
|
26
26
|
|
|
27
27
|
- Validate specific files against a named org:
|
|
28
28
|
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@eslint/js": "^10",
|
|
22
22
|
"eslint": "^10",
|
|
23
|
-
"execa": "^
|
|
23
|
+
"execa": "^10",
|
|
24
24
|
"globals": "^17",
|
|
25
25
|
"ts-node": "^10",
|
|
26
26
|
"typescript": "^6",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"wireit": "^0"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=22.13.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"/lib",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"files": [
|
|
100
100
|
"src/**/*.ts",
|
|
101
101
|
"messages/**",
|
|
102
|
-
"
|
|
102
|
+
"eslint.config.js",
|
|
103
103
|
"**/tsconfig.json"
|
|
104
104
|
],
|
|
105
105
|
"output": []
|
|
@@ -110,11 +110,15 @@
|
|
|
110
110
|
"compile"
|
|
111
111
|
],
|
|
112
112
|
"env": {
|
|
113
|
-
"FORCE_COLOR": "2"
|
|
113
|
+
"FORCE_COLOR": "2",
|
|
114
|
+
"PS_TARGET_ORG": {
|
|
115
|
+
"external": true
|
|
116
|
+
}
|
|
114
117
|
},
|
|
115
118
|
"files": [
|
|
116
119
|
"test/**",
|
|
117
|
-
"vitest.config.js"
|
|
120
|
+
"vitest.config.js",
|
|
121
|
+
".env"
|
|
118
122
|
],
|
|
119
123
|
"output": []
|
|
120
124
|
}
|
|
@@ -122,5 +126,5 @@
|
|
|
122
126
|
"exports": "./lib/index.js",
|
|
123
127
|
"type": "module",
|
|
124
128
|
"author": "Isaac Ferreira",
|
|
125
|
-
"version": "0.
|
|
129
|
+
"version": "0.6.0"
|
|
126
130
|
}
|
package/lib/core/mode.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ActualAssignment, AssignmentUpdate, DesiredAssignment, Diff, ReconcileMode } from './model.js';
|
|
2
|
-
/** A diff scoped to one mode: what it acts on, and the drift it deliberately leaves alone. */
|
|
3
|
-
export type ScopedChange = {
|
|
4
|
-
additions: DesiredAssignment[];
|
|
5
|
-
updates: AssignmentUpdate[];
|
|
6
|
-
removals: ActualAssignment[];
|
|
7
|
-
drift: {
|
|
8
|
-
adds: number;
|
|
9
|
-
updates: number;
|
|
10
|
-
removes: number;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Split a diff into what the chosen mode acts on versus the drift it leaves alone.
|
|
15
|
-
* additive skips removals, destructive skips adds and updates, sync acts on all.
|
|
16
|
-
*/
|
|
17
|
-
export declare function scopeToMode(diff: Diff, mode: ReconcileMode): ScopedChange;
|
|
18
|
-
//# sourceMappingURL=mode.d.ts.map
|