sf-plugin-permission-sets 0.1.0 → 0.3.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 +65 -42
- 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 +27 -0
- package/lib/commands/ps/apply.d.ts.map +1 -0
- package/lib/commands/ps/apply.js +124 -0
- package/lib/commands/ps/apply.js.map +1 -0
- package/lib/commands/ps/check.d.ts +2 -1
- package/lib/commands/ps/check.d.ts.map +1 -0
- package/lib/commands/ps/check.js +5 -4
- package/lib/commands/ps/check.js.map +1 -1
- package/lib/commands/ps/export.d.ts +17 -0
- package/lib/commands/ps/export.d.ts.map +1 -0
- package/lib/commands/ps/export.js +28 -0
- package/lib/commands/ps/export.js.map +1 -0
- package/lib/commands/ps/plan.d.ts +22 -0
- package/lib/commands/ps/plan.d.ts.map +1 -0
- package/lib/commands/ps/plan.js +77 -0
- package/lib/commands/ps/plan.js.map +1 -0
- package/lib/commands/ps/validate.d.ts +19 -0
- package/lib/commands/ps/validate.d.ts.map +1 -0
- package/lib/commands/ps/validate.js +47 -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 +2 -6
- package/lib/core/load.d.ts.map +1 -0
- package/lib/core/load.js +6 -5
- package/lib/core/load.js.map +1 -1
- package/lib/core/model.d.ts +57 -7
- package/lib/core/model.d.ts.map +1 -0
- package/lib/core/normalize.d.ts +6 -1
- package/lib/core/normalize.d.ts.map +1 -0
- package/lib/core/normalize.js +46 -29
- package/lib/core/normalize.js.map +1 -1
- package/lib/core/parse.d.ts +2 -1
- package/lib/core/parse.d.ts.map +1 -0
- package/lib/core/parse.js +4 -9
- package/lib/core/parse.js.map +1 -1
- package/lib/core/report.d.ts +8 -8
- package/lib/core/report.d.ts.map +1 -0
- package/lib/core/report.js +59 -12
- package/lib/core/report.js.map +1 -1
- 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 +18 -5
- package/lib/core/schema.d.ts.map +1 -0
- package/lib/core/schema.js +19 -10
- package/lib/core/schema.js.map +1 -1
- 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 +9 -6
- package/lib/services/check.d.ts.map +1 -0
- package/lib/services/check.js +21 -13
- package/lib/services/check.js.map +1 -1
- 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.export.md +25 -0
- package/messages/ps.plan.md +45 -0
- package/messages/ps.validate.md +29 -0
- package/package.json +27 -42
- package/lib/commands/ps/info.d.ts +0 -11
- package/lib/commands/ps/info.js +0 -17
- package/lib/commands/ps/info.js.map +0 -1
- package/messages/ps.info.md +0 -17
- package/oclif.lock +0 -7888
- package/oclif.manifest.json +0 -113
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
file: Flags.string({
|
|
16
|
+
char: 'f',
|
|
17
|
+
summary: messages.getMessage('flags.file.summary'),
|
|
18
|
+
required: true,
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
mode: Flags.option({
|
|
22
|
+
summary: messages.getMessage('flags.mode.summary'),
|
|
23
|
+
options: ['additive', 'destructive', 'sync'],
|
|
24
|
+
default: 'additive',
|
|
25
|
+
})(),
|
|
26
|
+
'max-deletes': Flags.integer({
|
|
27
|
+
summary: messages.getMessage('flags.max-deletes.summary'),
|
|
28
|
+
default: 50,
|
|
29
|
+
min: 0,
|
|
30
|
+
}),
|
|
31
|
+
'dry-run': Flags.boolean({
|
|
32
|
+
summary: messages.getMessage('flags.dry-run.summary'),
|
|
33
|
+
}),
|
|
34
|
+
'no-prompt': Flags.boolean({
|
|
35
|
+
summary: messages.getMessage('flags.no-prompt.summary'),
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
async run() {
|
|
39
|
+
const { flags } = await this.parse(Apply);
|
|
40
|
+
const connection = flags['target-org'].getConnection();
|
|
41
|
+
const orgClient = new ConnectionOrgClient(connection);
|
|
42
|
+
const confirmDeletions = async (count) => {
|
|
43
|
+
if (flags['no-prompt'])
|
|
44
|
+
return true;
|
|
45
|
+
if (this.jsonEnabled())
|
|
46
|
+
throw messages.createError('error.promptInJson');
|
|
47
|
+
return this.confirm({ message: messages.getMessage('confirm.delete', [String(count)]) });
|
|
48
|
+
};
|
|
49
|
+
const service = new ApplyService(orgClient, flags.file, { mode: flags.mode, maxDeletes: flags['max-deletes'], dryRun: flags['dry-run'] }, confirmDeletions);
|
|
50
|
+
const result = await service.run();
|
|
51
|
+
for (const line of formatFindings(result.findings)) {
|
|
52
|
+
this.log(line);
|
|
53
|
+
}
|
|
54
|
+
const added = result.outcomes.filter((outcome) => outcome.operation === 'add' && outcome.success).length;
|
|
55
|
+
const updated = result.outcomes.filter((outcome) => outcome.operation === 'update' && 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
|
+
toUpdate: result.diff.toUpdate.length,
|
|
62
|
+
toRemove: result.diff.toRemove.length,
|
|
63
|
+
added,
|
|
64
|
+
updated,
|
|
65
|
+
removed,
|
|
66
|
+
failures: failures.length,
|
|
67
|
+
};
|
|
68
|
+
if (result.status === 'invalid') {
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
if (!this.jsonEnabled())
|
|
71
|
+
this.error(messages.getMessage('error.invalid'), { exit: 1 });
|
|
72
|
+
return summary;
|
|
73
|
+
}
|
|
74
|
+
this.log('');
|
|
75
|
+
for (const line of formatDiff(result.diff)) {
|
|
76
|
+
this.log(line);
|
|
77
|
+
}
|
|
78
|
+
this.log('');
|
|
79
|
+
if (result.status === 'max-deletes-exceeded') {
|
|
80
|
+
process.exitCode = 1;
|
|
81
|
+
const tokens = [String(result.diff.toRemove.length), String(flags['max-deletes'])];
|
|
82
|
+
if (!this.jsonEnabled())
|
|
83
|
+
this.error(messages.getMessage('error.maxDeletes', tokens), { exit: 1 });
|
|
84
|
+
return summary;
|
|
85
|
+
}
|
|
86
|
+
this.reportDrift(result.drift, flags.mode);
|
|
87
|
+
if (result.status === 'dry-run') {
|
|
88
|
+
this.log(messages.getMessage('summary.dryRun', [
|
|
89
|
+
String(summary.toAdd),
|
|
90
|
+
String(summary.toUpdate),
|
|
91
|
+
String(summary.toRemove),
|
|
92
|
+
]));
|
|
93
|
+
return summary;
|
|
94
|
+
}
|
|
95
|
+
if (result.status === 'declined') {
|
|
96
|
+
this.log(messages.getMessage('summary.declined'));
|
|
97
|
+
return summary;
|
|
98
|
+
}
|
|
99
|
+
this.log(messages.getMessage('summary.applied', [String(added), String(updated), String(removed)]));
|
|
100
|
+
for (const failure of failures) {
|
|
101
|
+
this.log(messages.getMessage('failure.line', [
|
|
102
|
+
failure.operation,
|
|
103
|
+
failure.assignee,
|
|
104
|
+
failure.target,
|
|
105
|
+
failure.message ?? '',
|
|
106
|
+
]));
|
|
107
|
+
}
|
|
108
|
+
if (result.failed) {
|
|
109
|
+
process.exitCode = 1;
|
|
110
|
+
if (!this.jsonEnabled())
|
|
111
|
+
this.error(messages.getMessage('error.failed'), { exit: 1 });
|
|
112
|
+
}
|
|
113
|
+
return summary;
|
|
114
|
+
}
|
|
115
|
+
reportDrift(drift, mode) {
|
|
116
|
+
if (drift.adds > 0)
|
|
117
|
+
this.log(messages.getMessage('drift.note', [String(drift.adds), mode]));
|
|
118
|
+
if (drift.updates > 0)
|
|
119
|
+
this.log(messages.getMessage('drift.note', [String(drift.updates), mode]));
|
|
120
|
+
if (drift.removes > 0)
|
|
121
|
+
this.log(messages.getMessage('drift.note', [String(drift.removes), mode]));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# 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;AACvD,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,UAAU,CAAC,CAAC;AAahF,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,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE;QACjC,IAAI,EAAE,KAAK,CAA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AI,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,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
-
import { Finding } from '../../core/
|
|
2
|
+
import { Finding } from '../../core/finding.js';
|
|
3
3
|
export type PsCheckResult = {
|
|
4
4
|
files: number;
|
|
5
5
|
users: number;
|
|
@@ -16,3 +16,4 @@ export default class Check extends SfCommand<PsCheckResult> {
|
|
|
16
16
|
};
|
|
17
17
|
run(): Promise<PsCheckResult>;
|
|
18
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"}
|
package/lib/commands/ps/check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
2
2
|
import { Messages } from '@salesforce/core';
|
|
3
|
-
import {
|
|
4
|
-
import { formatFindings } from '../../core/
|
|
3
|
+
import { CheckService } from '../../services/check.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 {
|
|
@@ -21,11 +21,12 @@ export default class Check extends SfCommand {
|
|
|
21
21
|
};
|
|
22
22
|
async run() {
|
|
23
23
|
const { flags } = await this.parse(Check);
|
|
24
|
-
const
|
|
24
|
+
const service = new CheckService(flags.file, flags.strict);
|
|
25
|
+
const result = await service.run();
|
|
25
26
|
for (const line of formatFindings(result.findings)) {
|
|
26
27
|
this.log(line);
|
|
27
28
|
}
|
|
28
|
-
const assignees = new Set(result.assignments.map((
|
|
29
|
+
const assignees = new Set(result.assignments.map((assignment) => assignment.assignee));
|
|
29
30
|
this.log('');
|
|
30
31
|
this.log(messages.getMessage('summary.counts', [String(result.errors), String(result.warnings)]));
|
|
31
32
|
if (result.failed) {
|
|
@@ -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,
|
|
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,QAA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AE,MAAM,CAAC,KAAK,CAAC,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,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
|
+
'output-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<PsExportResult>;
|
|
16
|
+
}
|
|
17
|
+
//# 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;;;MAM1B;IAEW,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;CAY9C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
'output-file': Flags.string({
|
|
14
|
+
summary: messages.getMessage('flags.output-file.summary'),
|
|
15
|
+
required: true,
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
async run() {
|
|
19
|
+
const { flags } = await this.parse(Export);
|
|
20
|
+
const connection = flags['target-org'].getConnection();
|
|
21
|
+
const orgClient = new ConnectionOrgClient(connection);
|
|
22
|
+
const service = new ExportService(orgClient, flags['output-file']);
|
|
23
|
+
const result = await service.run();
|
|
24
|
+
this.log(messages.getMessage('success', [String(result.assignments), String(result.users), result.outputFile]));
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# 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,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,aAA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,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAEhH,OAAO,MAAM,CAAC;IAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
file: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
mode: import("@oclif/core/interfaces").OptionFlag<"additive" | "destructive" | "sync", import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<PsPlanResult>;
|
|
20
|
+
private reportDrift;
|
|
21
|
+
}
|
|
22
|
+
//# 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;;;;MAa1B;IAEW,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC;IAmDzC,OAAO,CAAC,WAAW;CAKtB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
file: Flags.string({
|
|
16
|
+
char: 'f',
|
|
17
|
+
summary: messages.getMessage('flags.file.summary'),
|
|
18
|
+
required: true,
|
|
19
|
+
multiple: true,
|
|
20
|
+
}),
|
|
21
|
+
mode: Flags.option({
|
|
22
|
+
summary: messages.getMessage('flags.mode.summary'),
|
|
23
|
+
options: ['additive', 'destructive', 'sync'],
|
|
24
|
+
default: 'additive',
|
|
25
|
+
})(),
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
const { flags } = await this.parse(Plan);
|
|
29
|
+
const connection = flags['target-org'].getConnection();
|
|
30
|
+
const orgClient = new ConnectionOrgClient(connection);
|
|
31
|
+
const service = new PlanService(orgClient, flags.file, { mode: flags.mode });
|
|
32
|
+
const result = await service.run();
|
|
33
|
+
for (const line of formatFindings(result.findings)) {
|
|
34
|
+
this.log(line);
|
|
35
|
+
}
|
|
36
|
+
const summary = {
|
|
37
|
+
status: result.status,
|
|
38
|
+
toAdd: result.diff.toAdd.length,
|
|
39
|
+
toUpdate: result.diff.toUpdate.length,
|
|
40
|
+
toRemove: result.diff.toRemove.length,
|
|
41
|
+
unchanged: result.diff.unchanged.length,
|
|
42
|
+
drift: result.drift.adds + result.drift.updates + result.drift.removes,
|
|
43
|
+
};
|
|
44
|
+
if (result.status === 'invalid') {
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
if (!this.jsonEnabled())
|
|
47
|
+
this.error(messages.getMessage('error.invalid'), { exit: 1 });
|
|
48
|
+
return summary;
|
|
49
|
+
}
|
|
50
|
+
this.log('');
|
|
51
|
+
for (const line of formatDiff(result.diff)) {
|
|
52
|
+
this.log(line);
|
|
53
|
+
}
|
|
54
|
+
this.log('');
|
|
55
|
+
this.reportDrift(result.drift, flags.mode);
|
|
56
|
+
this.log(messages.getMessage('summary.counts', [
|
|
57
|
+
String(summary.toAdd),
|
|
58
|
+
String(summary.toUpdate),
|
|
59
|
+
String(summary.toRemove),
|
|
60
|
+
String(summary.unchanged),
|
|
61
|
+
]));
|
|
62
|
+
const pending = summary.toAdd + summary.toUpdate + summary.toRemove;
|
|
63
|
+
if (pending > 0) {
|
|
64
|
+
this.log(messages.getMessage('summary.next', [flags.mode]));
|
|
65
|
+
}
|
|
66
|
+
return summary;
|
|
67
|
+
}
|
|
68
|
+
reportDrift(drift, mode) {
|
|
69
|
+
if (drift.adds > 0)
|
|
70
|
+
this.log(messages.getMessage('drift.note', [String(drift.adds), mode]));
|
|
71
|
+
if (drift.updates > 0)
|
|
72
|
+
this.log(messages.getMessage('drift.note', [String(drift.updates), mode]));
|
|
73
|
+
if (drift.removes > 0)
|
|
74
|
+
this.log(messages.getMessage('drift.note', [String(drift.removes), mode]));
|
|
75
|
+
}
|
|
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U,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,19 @@
|
|
|
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
|
+
file: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<PsValidateResult>;
|
|
18
|
+
}
|
|
19
|
+
//# 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;;;MAQ1B;IAEW,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC;CA+BhD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
file: Flags.string({
|
|
15
|
+
char: 'f',
|
|
16
|
+
summary: messages.getMessage('flags.file.summary'),
|
|
17
|
+
required: true,
|
|
18
|
+
multiple: true,
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { flags } = await this.parse(Validate);
|
|
23
|
+
const connection = flags['target-org'].getConnection();
|
|
24
|
+
const orgClient = new ConnectionOrgClient(connection);
|
|
25
|
+
const service = new ValidateService(orgClient, flags.file);
|
|
26
|
+
const result = await service.run();
|
|
27
|
+
for (const line of formatFindings(result.findings)) {
|
|
28
|
+
this.log(line);
|
|
29
|
+
}
|
|
30
|
+
const assignees = new Set(result.assignments.map((assignment) => assignment.assignee));
|
|
31
|
+
this.log('');
|
|
32
|
+
this.log(messages.getMessage('summary.counts', [String(result.errors), String(result.warnings)]));
|
|
33
|
+
if (result.failed) {
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
if (!this.jsonEnabled()) {
|
|
36
|
+
this.error(messages.getMessage('error.failed'), { exit: 1 });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
files: result.files.length,
|
|
41
|
+
users: assignees.size,
|
|
42
|
+
assignments: result.assignments.length,
|
|
43
|
+
findings: result.findings,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/ps/validate.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,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,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,aAAa,CAAC,CAAC;AASnF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAA2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C,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAElG,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBACtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YACjE,CAAC;QACL,CAAC;QAED,OAAO;YACH,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,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,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,GAAG,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;AACvE,CAAC;AAED,kFAAkF;AAClF,SAAS,cAAc,CAAC,IAAwB,EAAE,KAAyB;IACvE,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,IAAI,KAAK,KAAK,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,OAA4B,EAAE,MAA0B;IACpF,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IACxD,KAAK,MAAM,UAAU,IAAI,MAAM,EAAE,CAAC;QAC9B,WAAW,CAAC,GAAG,CAAC,aAAa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AAW,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,CAAC;AAE/C,sFAAsF;AACtF,MAAM,MAAM,WAAW,GACjB,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,kBAAkB,CAAC;AAEzB,MAAM,MAAM,OAAO,GAAG;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAiBF,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAE/E;AAED,sCAAsC;AACtC,wBAAgB,gBAAgB,CA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AAE,CAKvF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Construct an error-level finding. Private: callers use the named constructors below. */
|
|
2
|
+
function error(code, message, where = {}) {
|
|
3
|
+
return { level: 'error', code, message, ...where };
|
|
4
|
+
}
|
|
5
|
+
/** Construct a warning-level finding. Private: callers use the named constructors below. */
|
|
6
|
+
function warning(code, message, where = {}) {
|
|
7
|
+
return { level: 'warning', code, message, ...where };
|
|
8
|
+
}
|
|
9
|
+
// Offline findings, raised while reading and structurally checking a file.
|
|
10
|
+
/** Invalid YAML: the parser rejected the document. */
|
|
11
|
+
export function yamlError(message, file, line) {
|
|
12
|
+
return error('YAML', message, { file, line });
|
|
13
|
+
}
|
|
14
|
+
/** The document parsed to nothing. */
|
|
15
|
+
export function emptyFileWarning(file) {
|
|
16
|
+
return warning('EMPTY_FILE', 'file is empty', { file });
|
|
17
|
+
}
|
|
18
|
+
/** The file violates the schema at `path`. */
|
|
19
|
+
export function schemaError(path, message, file) {
|
|
20
|
+
return error('SCHEMA', `${path}: ${message}`, { file });
|
|
21
|
+
}
|
|
22
|
+
/** A scope key is present but its list is empty. */
|
|
23
|
+
export function emptyListWarning(username, scopeKey, file) {
|
|
24
|
+
return warning('EMPTY_LIST', `${username}: ${scopeKey} is empty`, { file });
|
|
25
|
+
}
|
|
26
|
+
/** A target appears more than once under one scope for one user. */
|
|
27
|
+
export function dupTargetWarning(username, target, scopeKey, file) {
|
|
28
|
+
return warning('DUP_TARGET', `${username}: ${target} is listed twice under ${scopeKey}`, { file });
|
|
29
|
+
}
|
|
30
|
+
/** A user declares no scopes at all. */
|
|
31
|
+
export function emptyUserWarning(username, file) {
|
|
32
|
+
return warning('EMPTY_USER', `${username}: no scopes declared`, { file });
|
|
33
|
+
}
|
|
34
|
+
/** No file on disk matched the given glob patterns. */
|
|
35
|
+
export function noFilesError(patterns) {
|
|
36
|
+
return error('NO_FILES', `no files matched: ${patterns.join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
// Org-side findings, raised while resolving declarations against the org. No file or line.
|
|
39
|
+
/** A declared user does not exist in the org. */
|
|
40
|
+
export function userNotFoundError(username) {
|
|
41
|
+
return error('USER_NOT_FOUND', `${username}: user not found in org`);
|
|
42
|
+
}
|
|
43
|
+
/** A declared user exists but is inactive. */
|
|
44
|
+
export function userInactiveError(username) {
|
|
45
|
+
return error('USER_INACTIVE', `${username}: user is inactive`);
|
|
46
|
+
}
|
|
47
|
+
/** A declared target does not exist in the org. `label` is the kind's human name. */
|
|
48
|
+
export function targetNotFoundError(target, label) {
|
|
49
|
+
return error('TARGET_NOT_FOUND', `${target}: ${label} not found in org`);
|
|
50
|
+
}
|
|
51
|
+
/** A declared target resolves to more than one record in the org. */
|
|
52
|
+
export function targetAmbiguousError(target, label) {
|
|
53
|
+
return error('TARGET_AMBIGUOUS', `${target}: ${label} is not unique in org`);
|
|
54
|
+
}
|
|
55
|
+
/** Render findings as human-readable lines. Shared by check, validate, and apply. */
|
|
56
|
+
export function formatFindings(findings) {
|
|
57
|
+
return findings.map((finding) => {
|
|
58
|
+
const where = finding.file ? `${finding.file}${finding.line ? `:${finding.line}` : ''} ` : '';
|
|
59
|
+
return `${finding.level}: ${where}${finding.message}`;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Count findings by level. */
|
|
63
|
+
export function countFindings(findings) {
|
|
64
|
+
const errors = findings.filter((finding) => finding.level === 'error');
|
|
65
|
+
const warnings = findings.filter((finding) => finding.level === 'warning');
|
|
66
|
+
return { errors: errors.length, warnings: warnings.length };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=finding.js.map
|