sf-plugin-permission-sets 0.0.0-dev.3 → 0.0.0-dev.30
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 +132 -85
- package/lib/adapters/connection-org-client.d.ts +17 -0
- package/lib/adapters/connection-org-client.d.ts.map +1 -0
- package/lib/adapters/connection-org-client.js +248 -0
- package/lib/adapters/connection-org-client.js.map +1 -0
- package/lib/commands/ps/apply.d.ts +28 -0
- package/lib/commands/ps/apply.d.ts.map +1 -0
- package/lib/commands/ps/apply.js +125 -0
- package/lib/commands/ps/apply.js.map +1 -0
- package/lib/commands/ps/check.d.ts +19 -0
- package/lib/commands/ps/check.d.ts.map +1 -0
- package/lib/commands/ps/check.js +46 -0
- package/lib/commands/ps/check.js.map +1 -0
- package/lib/commands/ps/export.d.ts +18 -0
- package/lib/commands/ps/export.d.ts.map +1 -0
- package/lib/commands/ps/export.js +29 -0
- package/lib/commands/ps/export.js.map +1 -0
- package/lib/commands/ps/plan.d.ts +23 -0
- package/lib/commands/ps/plan.d.ts.map +1 -0
- package/lib/commands/ps/plan.js +78 -0
- package/lib/commands/ps/plan.js.map +1 -0
- package/lib/commands/ps/validate.d.ts +20 -0
- package/lib/commands/ps/validate.d.ts.map +1 -0
- package/lib/commands/ps/validate.js +48 -0
- package/lib/commands/ps/validate.js.map +1 -0
- package/lib/core/diff.d.ts +10 -0
- package/lib/core/diff.d.ts.map +1 -0
- package/lib/core/diff.js +53 -0
- package/lib/core/diff.js.map +1 -0
- package/lib/core/finding.d.ts +40 -0
- package/lib/core/finding.d.ts.map +1 -0
- package/lib/core/finding.js +68 -0
- package/lib/core/finding.js.map +1 -0
- package/lib/core/load.d.ts +4 -0
- package/lib/core/load.d.ts.map +1 -0
- package/lib/core/load.js +53 -0
- package/lib/core/load.js.map +1 -0
- package/lib/core/model.d.ts +69 -0
- package/lib/core/model.d.ts.map +1 -0
- package/lib/core/model.js +2 -0
- package/lib/core/model.js.map +1 -0
- package/lib/core/normalize.d.ts +15 -0
- package/lib/core/normalize.d.ts.map +1 -0
- package/lib/core/normalize.js +62 -0
- package/lib/core/normalize.js.map +1 -0
- package/lib/core/parse.d.ts +10 -0
- package/lib/core/parse.d.ts.map +1 -0
- package/lib/core/parse.js +20 -0
- package/lib/core/parse.js.map +1 -0
- package/lib/core/report.d.ts +8 -0
- package/lib/core/report.d.ts.map +1 -0
- package/lib/core/report.js +62 -0
- package/lib/core/report.js.map +1 -0
- package/lib/core/resolve.d.ts +20 -0
- package/lib/core/resolve.d.ts.map +1 -0
- package/lib/core/resolve.js +88 -0
- package/lib/core/resolve.js.map +1 -0
- package/lib/core/schema.d.ts +33 -0
- package/lib/core/schema.d.ts.map +1 -0
- package/lib/core/schema.js +35 -0
- package/lib/core/schema.js.map +1 -0
- package/lib/core/serialize.d.ts +9 -0
- package/lib/core/serialize.d.ts.map +1 -0
- package/lib/core/serialize.js +34 -0
- package/lib/core/serialize.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/services/adapters/org-client.d.ts +22 -0
- package/lib/services/adapters/org-client.d.ts.map +1 -0
- package/lib/services/adapters/org-client.js +2 -0
- package/lib/services/adapters/org-client.js.map +1 -0
- package/lib/services/apply.d.ts +40 -0
- package/lib/services/apply.d.ts.map +1 -0
- package/lib/services/apply.js +94 -0
- package/lib/services/apply.js.map +1 -0
- package/lib/services/check.d.ts +18 -0
- package/lib/services/check.d.ts.map +1 -0
- package/lib/services/check.js +25 -0
- package/lib/services/check.js.map +1 -0
- package/lib/services/export.d.ts +14 -0
- package/lib/services/export.d.ts.map +1 -0
- package/lib/services/export.js +25 -0
- package/lib/services/export.js.map +1 -0
- package/lib/services/plan.d.ts +35 -0
- package/lib/services/plan.d.ts.map +1 -0
- package/lib/services/plan.js +47 -0
- package/lib/services/plan.js.map +1 -0
- package/lib/services/resolution.d.ts +17 -0
- package/lib/services/resolution.d.ts.map +1 -0
- package/lib/services/resolution.js +36 -0
- package/lib/services/resolution.js.map +1 -0
- package/lib/services/validate.d.ts +21 -0
- package/lib/services/validate.d.ts.map +1 -0
- package/lib/services/validate.js +43 -0
- package/lib/services/validate.js.map +1 -0
- package/messages/ps.apply.md +81 -0
- package/messages/ps.check.md +33 -0
- package/messages/ps.export.md +25 -0
- package/messages/ps.plan.md +45 -0
- package/messages/ps.validate.md +29 -0
- package/package.json +116 -181
- package/lib/commands/hello/world.d.ts +0 -14
- package/lib/commands/hello/world.js +0 -27
- package/lib/commands/hello/world.js.map +0 -1
- package/messages/hello.world.md +0 -29
- package/oclif.lock +0 -7618
- package/oclif.manifest.json +0 -62
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type PsApplyResult = {
|
|
3
|
+
status: string;
|
|
4
|
+
toAdd: number;
|
|
5
|
+
toUpdate: number;
|
|
6
|
+
toRemove: number;
|
|
7
|
+
added: number;
|
|
8
|
+
updated: number;
|
|
9
|
+
removed: number;
|
|
10
|
+
failures: number;
|
|
11
|
+
};
|
|
12
|
+
export default class Apply extends SfCommand<PsApplyResult> {
|
|
13
|
+
static readonly summary: string;
|
|
14
|
+
static readonly description: string;
|
|
15
|
+
static readonly examples: string[];
|
|
16
|
+
static readonly flags: {
|
|
17
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
file: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
mode: import("@oclif/core/interfaces").OptionFlag<"additive" | "destructive" | "sync", import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
'max-deletes': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
+
'no-prompt': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
24
|
+
};
|
|
25
|
+
run(): Promise<PsApplyResult>;
|
|
26
|
+
private reportDrift;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/commands/ps/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,6BAA6B,CAAC;AAU/D,MAAM,MAAM,aAAa,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,SAAS,CAAC,aAAa,CAAC;IACvD,gBAAuB,OAAO,SAAkC;IAChE,gBAAuB,WAAW,SAAsC;IACxE,gBAAuB,QAAQ,WAAoC;IAEnE,gBAAuB,KAAK;;;;;;;;MAyB1B;IAEW,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;IAiG1C,OAAO,CAAC,WAAW;CAKtB"}
|
|
@@ -0,0 +1,125 @@
|
|
|
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 updated = result.outcomes.filter((outcome) => outcome.operation === 'update' && outcome.success).length;
|
|
57
|
+
const removed = result.outcomes.filter((outcome) => outcome.operation === 'remove' && outcome.success).length;
|
|
58
|
+
const failures = result.outcomes.filter((outcome) => !outcome.success);
|
|
59
|
+
const summary = {
|
|
60
|
+
status: result.status,
|
|
61
|
+
toAdd: result.diff.toAdd.length,
|
|
62
|
+
toUpdate: result.diff.toUpdate.length,
|
|
63
|
+
toRemove: result.diff.toRemove.length,
|
|
64
|
+
added,
|
|
65
|
+
updated,
|
|
66
|
+
removed,
|
|
67
|
+
failures: failures.length,
|
|
68
|
+
};
|
|
69
|
+
if (result.status === 'invalid') {
|
|
70
|
+
process.exitCode = 1;
|
|
71
|
+
if (!this.jsonEnabled())
|
|
72
|
+
this.error(messages.getMessage('error.invalid'), { exit: 1 });
|
|
73
|
+
return summary;
|
|
74
|
+
}
|
|
75
|
+
this.log('');
|
|
76
|
+
for (const line of formatDiff(result.diff)) {
|
|
77
|
+
this.log(line);
|
|
78
|
+
}
|
|
79
|
+
this.log('');
|
|
80
|
+
if (result.status === 'max-deletes-exceeded') {
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
const tokens = [String(result.diff.toRemove.length), String(flags['max-deletes'])];
|
|
83
|
+
if (!this.jsonEnabled())
|
|
84
|
+
this.error(messages.getMessage('error.maxDeletes', tokens), { exit: 1 });
|
|
85
|
+
return summary;
|
|
86
|
+
}
|
|
87
|
+
this.reportDrift(result.drift, flags.mode);
|
|
88
|
+
if (result.status === 'dry-run') {
|
|
89
|
+
this.log(messages.getMessage('summary.dryRun', [
|
|
90
|
+
String(summary.toAdd),
|
|
91
|
+
String(summary.toUpdate),
|
|
92
|
+
String(summary.toRemove),
|
|
93
|
+
]));
|
|
94
|
+
return summary;
|
|
95
|
+
}
|
|
96
|
+
if (result.status === 'declined') {
|
|
97
|
+
this.log(messages.getMessage('summary.declined'));
|
|
98
|
+
return summary;
|
|
99
|
+
}
|
|
100
|
+
this.log(messages.getMessage('summary.applied', [String(added), String(updated), String(removed)]));
|
|
101
|
+
for (const failure of failures) {
|
|
102
|
+
this.log(messages.getMessage('failure.line', [
|
|
103
|
+
failure.operation,
|
|
104
|
+
failure.assignee,
|
|
105
|
+
failure.target,
|
|
106
|
+
failure.message ?? '',
|
|
107
|
+
]));
|
|
108
|
+
}
|
|
109
|
+
if (result.failed) {
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
if (!this.jsonEnabled())
|
|
112
|
+
this.error(messages.getMessage('error.failed'), { exit: 1 });
|
|
113
|
+
}
|
|
114
|
+
return summary;
|
|
115
|
+
}
|
|
116
|
+
reportDrift(drift, mode) {
|
|
117
|
+
if (drift.adds > 0)
|
|
118
|
+
this.log(messages.getMessage('drift.note', [String(drift.adds), mode]));
|
|
119
|
+
if (drift.updates > 0)
|
|
120
|
+
this.log(messages.getMessage('drift.note', [String(drift.updates), mode]));
|
|
121
|
+
if (drift.removes > 0)
|
|
122
|
+
this.log(messages.getMessage('drift.note', [String(drift.removes), mode]));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# 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,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACv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,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAClG,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Finding } from '../../core/finding.js';
|
|
3
|
+
export type PsCheckResult = {
|
|
4
|
+
files: number;
|
|
5
|
+
users: number;
|
|
6
|
+
assignments: number;
|
|
7
|
+
findings: Finding[];
|
|
8
|
+
};
|
|
9
|
+
export default class Check extends SfCommand<PsCheckResult> {
|
|
10
|
+
static readonly summary: string;
|
|
11
|
+
static readonly description: string;
|
|
12
|
+
static readonly examples: string[];
|
|
13
|
+
static readonly flags: {
|
|
14
|
+
file: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
strict: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<PsCheckResult>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../../src/commands/ps/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAkB,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKhE,MAAM,MAAM,aAAa,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,SAAS,CAAC,aAAa,CAAC;IACvD,gBAAuB,OAAO,SAAkC;IAChE,gBAAuB,WAAW,SAAsC;IACxE,gBAAuB,QAAQ,WAAoC;IAEnE,gBAAuB,KAAK;;;MAU1B;IAEW,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC;CA6B7C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
3
|
+
import { CheckService } from '../../services/check.js';
|
|
4
|
+
import { formatFindings } from '../../core/finding.js';
|
|
5
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
6
|
+
const messages = Messages.loadMessages('sf-plugin-permission-sets', 'ps.check');
|
|
7
|
+
export default class Check extends SfCommand {
|
|
8
|
+
static summary = messages.getMessage('summary');
|
|
9
|
+
static description = messages.getMessage('description');
|
|
10
|
+
static examples = messages.getMessages('examples');
|
|
11
|
+
static flags = {
|
|
12
|
+
file: Flags.string({
|
|
13
|
+
char: 'f',
|
|
14
|
+
summary: messages.getMessage('flags.file.summary'),
|
|
15
|
+
required: true,
|
|
16
|
+
multiple: true,
|
|
17
|
+
}),
|
|
18
|
+
strict: Flags.boolean({
|
|
19
|
+
summary: messages.getMessage('flags.strict.summary'),
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
const { flags } = await this.parse(Check);
|
|
24
|
+
const service = new CheckService(flags.file, flags.strict);
|
|
25
|
+
const result = await service.run();
|
|
26
|
+
for (const line of formatFindings(result.findings)) {
|
|
27
|
+
this.log(line);
|
|
28
|
+
}
|
|
29
|
+
const assignees = new Set(result.assignments.map((assignment) => assignment.assignee));
|
|
30
|
+
this.log('');
|
|
31
|
+
this.log(messages.getMessage('summary.counts', [String(result.errors), String(result.warnings)]));
|
|
32
|
+
if (result.failed) {
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
if (!this.jsonEnabled()) {
|
|
35
|
+
this.error(messages.getMessage('error.failed'), { exit: 1 });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
files: result.files.length,
|
|
40
|
+
users: assignees.size,
|
|
41
|
+
assignments: result.assignments.length,
|
|
42
|
+
findings: result.findings,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +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,EAAW,MAAM,uBAAuB,CAAC;AAEhE,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,CAA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C,MAAM;YAC1B,KAAK,EAAE,SAAS,CAAC,IAAI;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM;YACtC,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC5B,CAAC;IACN,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
18
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../../src/commands/ps/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,6BAA6B,CAAC;AAQ/D,MAAM,MAAM,cAAc,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,SAAS,CAAC,cAAc,CAAC;IACzD,gBAAuB,OAAO,SAAkC;IAChE,gBAAuB,WAAW,SAAsC;IACxE,gBAAuB,QAAQ,WAAoC;IAEnE,gBAAuB,KAAK;;;;MAO1B;IAEW,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;CAY9C"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../../src/commands/ps/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE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C,GAAG,EAAE,CAAC;QAEnC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAEhH,OAAO,MAAM,CAAC;IAClB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type PsPlanResult = {
|
|
3
|
+
status: string;
|
|
4
|
+
toAdd: number;
|
|
5
|
+
toUpdate: number;
|
|
6
|
+
toRemove: number;
|
|
7
|
+
unchanged: number;
|
|
8
|
+
drift: number;
|
|
9
|
+
};
|
|
10
|
+
export default class Plan extends SfCommand<PsPlanResult> {
|
|
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
|
+
};
|
|
20
|
+
run(): Promise<PsPlanResult>;
|
|
21
|
+
private reportDrift;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/commands/ps/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,6BAA6B,CAAC;AAU/D,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,SAAS,CAAC,YAAY,CAAC;IACrD,gBAAuB,OAAO,SAAkC;IAChE,gBAAuB,WAAW,SAAsC;IACxE,gBAAuB,QAAQ,WAAoC;IAEnE,gBAAuB,KAAK;;;;;MAc1B;IAEW,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;IAmDzC,OAAO,CAAC,WAAW;CAKtB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { PlanService } from '../../services/plan.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.plan');
|
|
9
|
+
export default class Plan 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
|
+
};
|
|
28
|
+
async run() {
|
|
29
|
+
const { flags } = await this.parse(Plan);
|
|
30
|
+
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
31
|
+
const orgClient = new ConnectionOrgClient(connection);
|
|
32
|
+
const service = new PlanService(orgClient, flags.file, { mode: flags.mode });
|
|
33
|
+
const result = await service.run();
|
|
34
|
+
for (const line of formatFindings(result.findings)) {
|
|
35
|
+
this.log(line);
|
|
36
|
+
}
|
|
37
|
+
const summary = {
|
|
38
|
+
status: result.status,
|
|
39
|
+
toAdd: result.diff.toAdd.length,
|
|
40
|
+
toUpdate: result.diff.toUpdate.length,
|
|
41
|
+
toRemove: result.diff.toRemove.length,
|
|
42
|
+
unchanged: result.diff.unchanged.length,
|
|
43
|
+
drift: result.drift.adds + result.drift.updates + result.drift.removes,
|
|
44
|
+
};
|
|
45
|
+
if (result.status === 'invalid') {
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
if (!this.jsonEnabled())
|
|
48
|
+
this.error(messages.getMessage('error.invalid'), { exit: 1 });
|
|
49
|
+
return summary;
|
|
50
|
+
}
|
|
51
|
+
this.log('');
|
|
52
|
+
for (const line of formatDiff(result.diff)) {
|
|
53
|
+
this.log(line);
|
|
54
|
+
}
|
|
55
|
+
this.log('');
|
|
56
|
+
this.reportDrift(result.drift, flags.mode);
|
|
57
|
+
this.log(messages.getMessage('summary.counts', [
|
|
58
|
+
String(summary.toAdd),
|
|
59
|
+
String(summary.toUpdate),
|
|
60
|
+
String(summary.toRemove),
|
|
61
|
+
String(summary.unchanged),
|
|
62
|
+
]));
|
|
63
|
+
const pending = summary.toAdd + summary.toUpdate + summary.toRemove;
|
|
64
|
+
if (pending > 0) {
|
|
65
|
+
this.log(messages.getMessage('summary.next', [flags.mode]));
|
|
66
|
+
}
|
|
67
|
+
return summary;
|
|
68
|
+
}
|
|
69
|
+
reportDrift(drift, mode) {
|
|
70
|
+
if (drift.adds > 0)
|
|
71
|
+
this.log(messages.getMessage('drift.note', [String(drift.adds), mode]));
|
|
72
|
+
if (drift.updates > 0)
|
|
73
|
+
this.log(messages.getMessage('drift.note', [String(drift.updates), mode]));
|
|
74
|
+
if (drift.removes > 0)
|
|
75
|
+
this.log(messages.getMessage('drift.note', [String(drift.removes), mode]));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../src/commands/ps/plan.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,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,2BAA2B,EAAE,SAAS,CAAC,CAAC;AAW/E,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,SAAuB;IAC9C,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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,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACpE,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAEO,WAAW,CAAC,KAAyD,EAAE,IAAY;QACvF,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;QAClG,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Finding } from '../../core/finding.js';
|
|
3
|
+
export type PsValidateResult = {
|
|
4
|
+
files: number;
|
|
5
|
+
users: number;
|
|
6
|
+
assignments: number;
|
|
7
|
+
findings: Finding[];
|
|
8
|
+
};
|
|
9
|
+
export default class Validate extends SfCommand<PsValidateResult> {
|
|
10
|
+
static readonly summary: string;
|
|
11
|
+
static readonly description: string;
|
|
12
|
+
static readonly examples: string[];
|
|
13
|
+
static readonly flags: {
|
|
14
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
file: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<PsValidateResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/ps/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,6BAA6B,CAAC;AAI/D,OAAO,EAAkB,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKhE,MAAM,MAAM,gBAAgB,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAS,CAAC,gBAAgB,CAAC;IAC7D,gBAAuB,OAAO,SAAkC;IAChE,gBAAuB,WAAW,SAAsC;IACxE,gBAAuB,QAAQ,WAAoC;IAEnE,gBAAuB,KAAK;;;;MAS1B;IAEW,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC;CA+BhD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { ValidateService } from '../../services/validate.js';
|
|
5
|
+
import { formatFindings } from '../../core/finding.js';
|
|
6
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
7
|
+
const messages = Messages.loadMessages('sf-plugin-permission-sets', 'ps.validate');
|
|
8
|
+
export default class Validate extends SfCommand {
|
|
9
|
+
static summary = messages.getMessage('summary');
|
|
10
|
+
static description = messages.getMessage('description');
|
|
11
|
+
static examples = messages.getMessages('examples');
|
|
12
|
+
static flags = {
|
|
13
|
+
'target-org': Flags.requiredOrg(),
|
|
14
|
+
'api-version': Flags.orgApiVersion(),
|
|
15
|
+
file: Flags.string({
|
|
16
|
+
char: 'f',
|
|
17
|
+
summary: messages.getMessage('flags.file.summary'),
|
|
18
|
+
required: true,
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
const { flags } = await this.parse(Validate);
|
|
24
|
+
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
25
|
+
const orgClient = new ConnectionOrgClient(connection);
|
|
26
|
+
const service = new ValidateService(orgClient, flags.file);
|
|
27
|
+
const result = await service.run();
|
|
28
|
+
for (const line of formatFindings(result.findings)) {
|
|
29
|
+
this.log(line);
|
|
30
|
+
}
|
|
31
|
+
const assignees = new Set(result.assignments.map((assignment) => assignment.assignee));
|
|
32
|
+
this.log('');
|
|
33
|
+
this.log(messages.getMessage('summary.counts', [String(result.errors), String(result.warnings)]));
|
|
34
|
+
if (result.failed) {
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
if (!this.jsonEnabled()) {
|
|
37
|
+
this.error(messages.getMessage('error.failed'), { exit: 1 });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
files: result.files.length,
|
|
42
|
+
users: assignees.size,
|
|
43
|
+
assignments: result.assignments.length,
|
|
44
|
+
findings: result.findings,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/ps/validate.ts"],"names":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1,10 @@
|
|
|
1
|
+
import { ActualAssignment, DesiredAssignment, Diff } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compare the desired assignments against the org's current memberships of the
|
|
4
|
+
* managed targets. `actual` must hold only assignments for targets that appear
|
|
5
|
+
* in `desired` (the managed set), so any actual row not in `desired` is an
|
|
6
|
+
* undeclared assignment eligible for removal. A declared assignment whose
|
|
7
|
+
* expiration differs from the org's is an update rather than unchanged.
|
|
8
|
+
*/
|
|
9
|
+
export declare function diffAssignments(desired: DesiredAssignment[], actual: ActualAssignment[]): Diff;
|
|
10
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/core/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,iBAAiB,EAAE,IAAI,EAAQ,MAAM,YAAY,CAAC;AAe/F;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAqC9F"}
|
package/lib/core/diff.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Case-insensitive key for an (assignee, kind, target) tuple, matching how the org compares them. */
|
|
2
|
+
function assignmentKey(assignee, kind, target) {
|
|
3
|
+
return `${assignee.toLowerCase()} ${kind} ${target.toLowerCase()}`;
|
|
4
|
+
}
|
|
5
|
+
/** Whether two expirations name the same instant. Both absent counts as equal. */
|
|
6
|
+
function sameExpiration(left, right) {
|
|
7
|
+
if (!left || !right) {
|
|
8
|
+
return left === right;
|
|
9
|
+
}
|
|
10
|
+
return Date.parse(left) === Date.parse(right);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Compare the desired assignments against the org's current memberships of the
|
|
14
|
+
* managed targets. `actual` must hold only assignments for targets that appear
|
|
15
|
+
* in `desired` (the managed set), so any actual row not in `desired` is an
|
|
16
|
+
* undeclared assignment eligible for removal. A declared assignment whose
|
|
17
|
+
* expiration differs from the org's is an update rather than unchanged.
|
|
18
|
+
*/
|
|
19
|
+
export function diffAssignments(desired, actual) {
|
|
20
|
+
const actualByKey = new Map();
|
|
21
|
+
for (const assignment of actual) {
|
|
22
|
+
actualByKey.set(assignmentKey(assignment.assignee, assignment.kind, assignment.target), assignment);
|
|
23
|
+
}
|
|
24
|
+
const desiredKeys = new Set();
|
|
25
|
+
const toAdd = [];
|
|
26
|
+
const toUpdate = [];
|
|
27
|
+
const unchanged = [];
|
|
28
|
+
for (const assignment of desired) {
|
|
29
|
+
const key = assignmentKey(assignment.assignee, assignment.kind, assignment.target);
|
|
30
|
+
if (desiredKeys.has(key))
|
|
31
|
+
continue;
|
|
32
|
+
desiredKeys.add(key);
|
|
33
|
+
const existing = actualByKey.get(key);
|
|
34
|
+
if (!existing) {
|
|
35
|
+
toAdd.push(assignment);
|
|
36
|
+
}
|
|
37
|
+
else if (sameExpiration(existing.expiration, assignment.expiration)) {
|
|
38
|
+
unchanged.push(existing);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
toUpdate.push({
|
|
42
|
+
recordId: existing.recordId,
|
|
43
|
+
assignee: existing.assignee,
|
|
44
|
+
kind: existing.kind,
|
|
45
|
+
target: existing.target,
|
|
46
|
+
expiration: assignment.expiration,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const toRemove = actual.filter((assignment) => !desiredKeys.has(assignmentKey(assignment.assignee, assignment.kind, assignment.target)));
|
|
51
|
+
return { toAdd, toUpdate, toRemove, unchanged };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/core/diff.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,SAAS,aAAa,CAAC,QAAgB,EAAE,IAAU,EAAE,MAAc;IAC/D,OAAO,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,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC;aAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACpE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACJ,QAAQ,CAAC,IAAI,CAAC;gBACV,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,UAAU,EAAE,UAAU,CAAC,UAAU;aACpC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC1B,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAC3G,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type FindingLevel = 'error' | 'warning';
|
|
2
|
+
/** The closed vocabulary of finding codes. Adding one here is required to emit it. */
|
|
3
|
+
export type FindingCode = 'YAML' | 'EMPTY_FILE' | 'SCHEMA' | 'EMPTY_LIST' | 'DUP_TARGET' | 'EMPTY_USER' | 'NO_FILES' | 'USER_NOT_FOUND' | 'USER_INACTIVE' | 'TARGET_NOT_FOUND' | 'TARGET_AMBIGUOUS';
|
|
4
|
+
export type Finding = {
|
|
5
|
+
level: FindingLevel;
|
|
6
|
+
code: FindingCode;
|
|
7
|
+
message: string;
|
|
8
|
+
file?: string;
|
|
9
|
+
line?: number;
|
|
10
|
+
};
|
|
11
|
+
/** Invalid YAML: the parser rejected the document. */
|
|
12
|
+
export declare function yamlError(message: string, file: string, line?: number): Finding;
|
|
13
|
+
/** The document parsed to nothing. */
|
|
14
|
+
export declare function emptyFileWarning(file: string): Finding;
|
|
15
|
+
/** The file violates the schema at `path`. */
|
|
16
|
+
export declare function schemaError(path: string, message: string, file: string): Finding;
|
|
17
|
+
/** A scope key is present but its list is empty. */
|
|
18
|
+
export declare function emptyListWarning(username: string, scopeKey: string, file: string): Finding;
|
|
19
|
+
/** A target appears more than once under one scope for one user. */
|
|
20
|
+
export declare function dupTargetWarning(username: string, target: string, scopeKey: string, file: string): Finding;
|
|
21
|
+
/** A user declares no scopes at all. */
|
|
22
|
+
export declare function emptyUserWarning(username: string, file: string): Finding;
|
|
23
|
+
/** No file on disk matched the given glob patterns. */
|
|
24
|
+
export declare function noFilesError(patterns: string[]): Finding;
|
|
25
|
+
/** A declared user does not exist in the org. */
|
|
26
|
+
export declare function userNotFoundError(username: string): Finding;
|
|
27
|
+
/** A declared user exists but is inactive. */
|
|
28
|
+
export declare function userInactiveError(username: string): Finding;
|
|
29
|
+
/** A declared target does not exist in the org. `label` is the kind's human name. */
|
|
30
|
+
export declare function targetNotFoundError(target: string, label: string): Finding;
|
|
31
|
+
/** A declared target resolves to more than one record in the org. */
|
|
32
|
+
export declare function targetAmbiguousError(target: string, label: string): Finding;
|
|
33
|
+
/** Render findings as human-readable lines. Shared by check, validate, and apply. */
|
|
34
|
+
export declare function formatFindings(findings: Finding[]): string[];
|
|
35
|
+
/** Count findings by level. */
|
|
36
|
+
export declare function countFindings(findings: Finding[]): {
|
|
37
|
+
errors: number;
|
|
38
|
+
warnings: number;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=finding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding.d.ts","sourceRoot":"","sources":["../../src/core/finding.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS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