sf-plugin-permission-sets 0.0.0-dev.4 → 0.0.0-dev.41
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 +157 -93
- 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/adapters/index.d.ts +2 -0
- package/lib/adapters/index.d.ts.map +1 -0
- package/lib/adapters/index.js +2 -0
- package/lib/adapters/index.js.map +1 -0
- package/lib/commands/ps/apply.d.ts +30 -0
- package/lib/commands/ps/apply.d.ts.map +1 -0
- package/lib/commands/ps/apply.js +153 -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 +49 -0
- package/lib/commands/ps/check.js.map +1 -0
- 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 +32 -0
- package/lib/commands/ps/export.js.map +1 -0
- package/lib/commands/ps/plan.d.ts +51 -0
- package/lib/commands/ps/plan.d.ts.map +1 -0
- package/lib/commands/ps/plan.js +181 -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 +50 -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 +54 -0
- package/lib/core/diff.js.map +1 -0
- package/lib/core/finding.d.ts +41 -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/index.d.ts +8 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +7 -0
- package/lib/core/index.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 +60 -0
- package/lib/core/load.js.map +1 -0
- package/lib/core/model.d.ts +73 -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 +15 -0
- package/lib/core/report.d.ts.map +1 -0
- package/lib/core/report.js +114 -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 +23 -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/index.d.ts +2 -0
- package/lib/services/adapters/index.d.ts.map +1 -0
- package/lib/services/adapters/index.js +2 -0
- package/lib/services/adapters/index.js.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 +39 -0
- package/lib/services/apply.d.ts.map +1 -0
- package/lib/services/apply.js +102 -0
- package/lib/services/apply.js.map +1 -0
- package/lib/services/check.d.ts +14 -0
- package/lib/services/check.d.ts.map +1 -0
- package/lib/services/check.js +18 -0
- package/lib/services/check.js.map +1 -0
- package/lib/services/export.d.ts +13 -0
- package/lib/services/export.d.ts.map +1 -0
- package/lib/services/export.js +23 -0
- package/lib/services/export.js.map +1 -0
- package/lib/services/index.d.ts +6 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +6 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/plan.d.ts +29 -0
- package/lib/services/plan.d.ts.map +1 -0
- package/lib/services/plan.js +45 -0
- package/lib/services/plan.js.map +1 -0
- package/lib/services/resolution.d.ts +15 -0
- package/lib/services/resolution.d.ts.map +1 -0
- package/lib/services/resolution.js +37 -0
- package/lib/services/resolution.js.map +1 -0
- package/lib/services/validate.d.ts +19 -0
- package/lib/services/validate.d.ts.map +1 -0
- package/lib/services/validate.js +42 -0
- package/lib/services/validate.js.map +1 -0
- package/messages/ps.apply.md +85 -0
- package/messages/ps.check.md +33 -0
- package/messages/ps.export.md +25 -0
- package/messages/ps.plan.md +85 -0
- package/messages/ps.validate.md +29 -0
- package/package.json +112 -181
- 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 -7781
- package/oclif.manifest.json +0 -51
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Finding } from '../../core/index.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;AAK/D,OAAO,EAAkB,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK9D,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;CAoChD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
3
|
+
import { ConnectionOrgClient } from '../../adapters/index.js';
|
|
4
|
+
import { ValidateService } from '../../services/index.js';
|
|
5
|
+
import { formatFindings } from '../../core/index.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);
|
|
26
|
+
const result = await service.run(flags.file);
|
|
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', [
|
|
33
|
+
String(result.errors),
|
|
34
|
+
String(result.warnings),
|
|
35
|
+
]));
|
|
36
|
+
if (result.failed) {
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
if (!this.jsonEnabled()) {
|
|
39
|
+
this.error(messages.getMessage('error.failed'), { exit: 1 });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
files: result.files.length,
|
|
44
|
+
users: assignees.size,
|
|
45
|
+
assignments: result.assignments.length,
|
|
46
|
+
findings: result.findings,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# 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;AAE5C,OAAO,EAAE,mBAAmB,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AK,MAAM,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEvF,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,CACJ,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE;YAClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YACrB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC1B,CAAC,CACL,CAAC;QAEF,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,CAsC9F"}
|
package/lib/core/diff.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
previousExpiration: existing.expiration,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const toRemove = actual.filter((assignment) => !desiredKeys.has(assignmentKey(assignment.assignee, assignment.kind, assignment.target)));
|
|
52
|
+
return { toAdd, toUpdate, toRemove, unchanged };
|
|
53
|
+
}
|
|
54
|
+
//# 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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C;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;gBACjC,kBAAkB,EAAE,QAAQ,CAAC,UAAU;aAC1C,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,41 @@
|
|
|
1
|
+
type FindingLevel = 'error' | 'warning';
|
|
2
|
+
/** The closed vocabulary of finding codes. Adding one here is required to emit it. */
|
|
3
|
+
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
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=finding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding.d.ts","sourceRoot":"","sources":["../../src/core/finding.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;AAExC,sFAAsF;AACtF,KAAK,WAAW,GACV,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,gBAAgB,GAChB,eAAe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BAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1E;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE3E;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAK5D;AAED,+BAA+B;AAC/B,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finding.js","sourceRoot":"","sources":["../../src/core/finding.ts"],"names":[],"mappings":"AA2BA,2FAA2F;AAC3F,SAAS,KAAK,CAAC,IAAiB,EAAE,OAAe,EAAE,QAAe,EAAE;IAChE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACvD,CAAC;AAED,4FAA4F;AAC5F,SAAS,OAAO,CAAC,IAAiB,EAAE,OAAe,EAAE,QAAe,EAAE;IAClE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACzD,CAAC;AAED,2EAA2E;AAE3E,sDAAsD;AACtD,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAY,EAAE,IAAa;IAClE,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,sCAAsC;AACtC,MAAM,UAAU,gBAAgB,CAAC,IAAY;IACzC,OAAO,OAAO,CAAC,YAAY,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAe,EAAE,IAAY;IACnE,OAAO,KAAK,CAAC,QAAQ,EAAE,GAAG,IAAI,KAAK,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,QAAgB,EA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AkB,EAAE,GAAG,MAAM,KAAK,KAAK,uBAAuB,CAAC,CAAC;AACjF,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,cAAc,CAAC,QAAmB;IAC9C,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,OAAO,GAAG,OAAO,CAAC,KAAK,KAAK,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,aAAa,CAAC,QAAmB;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { diffAssignments } from './diff.js';
|
|
2
|
+
export { Finding, formatFindings, countFindings } from './finding.js';
|
|
3
|
+
export { loadFiles } from './load.js';
|
|
4
|
+
export { ActualAssignment, AssignmentOutcome, AssignmentUpdate, DesiredAssignment, Diff, Kind, OrgTarget, OrgUser, ReconcileMode, ResolvedAddition, TargetRef, } from './model.js';
|
|
5
|
+
export { formatDiff } from './report.js';
|
|
6
|
+
export { kinds, distinctAssignees, distinctTargets, evaluateUsers, evaluateTargets, indexUsersById, indexTargetsById, } from './resolve.js';
|
|
7
|
+
export { serializeAssignments } from './serialize.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { diffAssignments } from './diff.js';
|
|
2
|
+
export { formatFindings, countFindings } from './finding.js';
|
|
3
|
+
export { loadFiles } from './load.js';
|
|
4
|
+
export { formatDiff } from './report.js';
|
|
5
|
+
export { kinds, distinctAssignees, distinctTargets, evaluateUsers, evaluateTargets, indexUsersById, indexTargetsById, } from './resolve.js';
|
|
6
|
+
export { serializeAssignments } from './serialize.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAW,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AActC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/core/load.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAC;AAgC3D,oFAAoF;AACpF,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CA+BvE"}
|
package/lib/core/load.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { globby } from 'globby';
|
|
3
|
+
import { parseFile } from './parse.js';
|
|
4
|
+
import { validateFile } from './schema.js';
|
|
5
|
+
import { normalize } from './normalize.js';
|
|
6
|
+
import { noFilesError } from './finding.js';
|
|
7
|
+
/** Process one file's text through parse, validate, and normalize. Pure, no disk. */
|
|
8
|
+
function checkContent(text, file) {
|
|
9
|
+
const parsed = parseFile(text, file);
|
|
10
|
+
if (!parsed.data) {
|
|
11
|
+
return { assignments: [], findings: parsed.findings };
|
|
12
|
+
}
|
|
13
|
+
const validated = validateFile(parsed.data, file);
|
|
14
|
+
if (!validated.data) {
|
|
15
|
+
return {
|
|
16
|
+
assignments: [],
|
|
17
|
+
findings: [
|
|
18
|
+
...parsed.findings,
|
|
19
|
+
...validated.findings,
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const normalized = normalize(validated.data, file);
|
|
24
|
+
return {
|
|
25
|
+
assignments: normalized.assignments,
|
|
26
|
+
findings: [
|
|
27
|
+
...parsed.findings,
|
|
28
|
+
...validated.findings,
|
|
29
|
+
...normalized.findings,
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Expand the globs, read every matched file, and merge into one model by union. */
|
|
34
|
+
export async function loadFiles(patterns) {
|
|
35
|
+
const files = await globby(patterns);
|
|
36
|
+
if (files.length === 0) {
|
|
37
|
+
return {
|
|
38
|
+
files,
|
|
39
|
+
assignments: [],
|
|
40
|
+
findings: [noFilesError(patterns)],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const checked = await Promise.all(files.map(async (file) => {
|
|
44
|
+
const text = await readFile(file, 'utf8');
|
|
45
|
+
return checkContent(text, file);
|
|
46
|
+
}));
|
|
47
|
+
const findings = checked.flatMap((entry) => entry.findings);
|
|
48
|
+
const collected = checked.flatMap((entry) => entry.assignments);
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
const assignments = [];
|
|
51
|
+
for (const assignment of collected) {
|
|
52
|
+
const dedupeKey = `${assignment.assignee} ${assignment.kind} ${assignment.target}`;
|
|
53
|
+
if (seen.has(dedupeKey))
|
|
54
|
+
continue;
|
|
55
|
+
seen.add(dedupeKey);
|
|
56
|
+
assignments.push(assignment);
|
|
57
|
+
}
|
|
58
|
+
return { files, assignments, findings };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/core/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CA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AAG,MAAM,OAAO,CAAC,GAAG,CAC7B,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC,CAAC,CACL,CAAC;IAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAEhE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,WAAW,GAAwB,EAAE,CAAC;IAE5C,KAAK,MAAM,UAAU,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,GAAG,UAAU,CAAC,QAAQ,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACnF,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,SAAS;QAClC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACpB,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Finding } from './finding.js';
|
|
2
|
+
export type Kind = 'permissionSet' | 'permissionSetGroup' | 'permissionSetLicense';
|
|
3
|
+
/** Which half of the reconcile a run acts on. Shared by plan, apply, and the report. */
|
|
4
|
+
export type ReconcileMode = 'additive' | 'destructive' | 'sync';
|
|
5
|
+
export type DesiredAssignment = {
|
|
6
|
+
assignee: string;
|
|
7
|
+
kind: Kind;
|
|
8
|
+
target: string;
|
|
9
|
+
/** ISO 8601 datetime the grant should expire, if any. Only permission sets and groups support it. */
|
|
10
|
+
expiration?: string;
|
|
11
|
+
};
|
|
12
|
+
/** A user as it exists in the org, in domain terms (no SObject field names). */
|
|
13
|
+
export type OrgUser = {
|
|
14
|
+
id: string;
|
|
15
|
+
username: string;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** A target (permission set, group, or license) as it exists in the org. */
|
|
19
|
+
export type OrgTarget = {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
/** An assignment that currently exists in the org, carrying its record id for deletion. */
|
|
24
|
+
export type ActualAssignment = {
|
|
25
|
+
recordId: string;
|
|
26
|
+
assignee: string;
|
|
27
|
+
kind: Kind;
|
|
28
|
+
target: string;
|
|
29
|
+
/** The expiration the org has on record, if any. */
|
|
30
|
+
expiration?: string;
|
|
31
|
+
};
|
|
32
|
+
/** An existing assignment whose expiration should change. `expiration` undefined clears it. */
|
|
33
|
+
export type AssignmentUpdate = {
|
|
34
|
+
recordId: string;
|
|
35
|
+
assignee: string;
|
|
36
|
+
kind: Kind;
|
|
37
|
+
target: string;
|
|
38
|
+
expiration?: string;
|
|
39
|
+
/** The expiration the org has now, before the update. Undefined means it had none. */
|
|
40
|
+
previousExpiration?: string;
|
|
41
|
+
};
|
|
42
|
+
/** A resolved managed target: its kind and the org id it resolved to. */
|
|
43
|
+
export type TargetRef = {
|
|
44
|
+
kind: Kind;
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
/** A desired assignment resolved to the ids needed to insert it. */
|
|
48
|
+
export type ResolvedAddition = DesiredAssignment & {
|
|
49
|
+
assigneeId: string;
|
|
50
|
+
targetId: string;
|
|
51
|
+
};
|
|
52
|
+
/** The change set between the desired model and the org's current state. */
|
|
53
|
+
export type Diff = {
|
|
54
|
+
toAdd: DesiredAssignment[];
|
|
55
|
+
toUpdate: AssignmentUpdate[];
|
|
56
|
+
toRemove: ActualAssignment[];
|
|
57
|
+
unchanged: ActualAssignment[];
|
|
58
|
+
};
|
|
59
|
+
/** The per-record result of one add or remove, for partial-success reporting. */
|
|
60
|
+
export type AssignmentOutcome = {
|
|
61
|
+
assignee: string;
|
|
62
|
+
kind: Kind;
|
|
63
|
+
target: string;
|
|
64
|
+
operation: 'add' | 'update' | 'remove';
|
|
65
|
+
success: boolean;
|
|
66
|
+
message?: string;
|
|
67
|
+
};
|
|
68
|
+
export type LoadResult = {
|
|
69
|
+
files: string[];
|
|
70
|
+
assignments: DesiredAssignment[];
|
|
71
|
+
findings: Finding[];
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/core/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,MAAM,IAAI,GAAG,eAAe,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAEnF,wFAAwF;AACxF,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,MAAM,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,qGAAqG;IACrG,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,OAAO,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,2FAA2F;AAC3F,MAAM,M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UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/core/model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FileShape } from './schema.js';
|
|
2
|
+
import { DesiredAssignment, Kind } from './model.js';
|
|
3
|
+
import { Finding } from './finding.js';
|
|
4
|
+
export type ScopeKey = 'permissionSets' | 'permissionSetGroups' | 'permissionSetLicenses';
|
|
5
|
+
/** The (kind, file scope key) pairing, in canonical order. Shared with serialize. */
|
|
6
|
+
export declare const kindKeys: Array<[Kind, ScopeKey]>;
|
|
7
|
+
/**
|
|
8
|
+
* Turn a validated file into canonical (assignee, kind, target) tuples, and
|
|
9
|
+
* emit the structural findings: duplicate targets, empty lists, empty users.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalize(data: FileShape, file: string): {
|
|
12
|
+
assignments: DesiredAssignment[];
|
|
13
|
+
findings: Finding[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/core/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,EAAwD,MAAM,cAAc,CAAC;AAE7F,MAAM,MAAM,QAAQ,GAAG,gBAAgB,GAAG,qBAAqB,GAAG,uBAAuB,CAAC;AAE1F,qFAAqF;AACrF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAI5C,CAAC;AA8DF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAWlH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { emptyListWarning, dupTargetWarning, emptyUserWarning } from './finding.js';
|
|
2
|
+
/** The (kind, file scope key) pairing, in canonical order. Shared with serialize. */
|
|
3
|
+
export const kindKeys = [
|
|
4
|
+
['permissionSet', 'permissionSets'],
|
|
5
|
+
['permissionSetGroup', 'permissionSetGroups'],
|
|
6
|
+
['permissionSetLicense', 'permissionSetLicenses'],
|
|
7
|
+
];
|
|
8
|
+
function normalizeScope(username, kind, key, list, file) {
|
|
9
|
+
const items = list.map((item) => ({
|
|
10
|
+
target: typeof item === 'string' ? item : item.name,
|
|
11
|
+
expiration: typeof item === 'string' ? undefined : item.expiration,
|
|
12
|
+
}));
|
|
13
|
+
const assignments = [];
|
|
14
|
+
const findings = [];
|
|
15
|
+
const seen = new Set();
|
|
16
|
+
for (const { target, expiration } of items) {
|
|
17
|
+
if (seen.has(target)) {
|
|
18
|
+
findings.push(dupTargetWarning(username, target, key, file));
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
seen.add(target);
|
|
22
|
+
assignments.push({ assignee: username, kind, target, ...(expiration ? { expiration } : {}) });
|
|
23
|
+
}
|
|
24
|
+
return { assignments, findings };
|
|
25
|
+
}
|
|
26
|
+
function normalizeUser(username, entry, file) {
|
|
27
|
+
const assignments = [];
|
|
28
|
+
const findings = [];
|
|
29
|
+
let scopeCount = 0;
|
|
30
|
+
for (const [kind, key] of kindKeys) {
|
|
31
|
+
const list = entry[key];
|
|
32
|
+
if (!list)
|
|
33
|
+
continue;
|
|
34
|
+
if (list.length === 0) {
|
|
35
|
+
findings.push(emptyListWarning(username, key, file));
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
scopeCount += 1;
|
|
39
|
+
const scope = normalizeScope(username, kind, key, list, file);
|
|
40
|
+
assignments.push(...scope.assignments);
|
|
41
|
+
findings.push(...scope.findings);
|
|
42
|
+
}
|
|
43
|
+
if (scopeCount === 0) {
|
|
44
|
+
findings.push(emptyUserWarning(username, file));
|
|
45
|
+
}
|
|
46
|
+
return { assignments, findings };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Turn a validated file into canonical (assignee, kind, target) tuples, and
|
|
50
|
+
* emit the structural findings: duplicate targets, empty lists, empty users.
|
|
51
|
+
*/
|
|
52
|
+
export function normalize(data, file) {
|
|
53
|
+
const assignments = [];
|
|
54
|
+
const findings = [];
|
|
55
|
+
for (const [username, entry] of Object.entries(data.users)) {
|
|
56
|
+
const user = normalizeUser(username, entry, file);
|
|
57
|
+
assignments.push(...user.assignments);
|
|
58
|
+
findings.push(...user.findings);
|
|
59
|
+
}
|
|
60
|
+
return { assignments, findings };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/core/normalize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAI7F,qFAAqF;AACrF,MAAM,CAAC,MAAM,QAAQ,GAA4B;IAC7C,CAAC,eAAe,EAAE,gBAAgB,CAAC;IACnC,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;IAC7C,CAAC,sBAAsB,EAAE,uBAAuB,CAAC;CACpD,CAAC;AAIF,SAAS,cAAc,CACnB,QAAgB,EAChB,IAAU,EACV,GAAa,EACb,IAAiB,EACjB,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,EAAE,OAAO,IAAI,KAAK,QAAQ,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';
|
|
2
|
+
/**
|
|
3
|
+
* Read one file's text into a plain object. Reports invalid YAML and duplicate
|
|
4
|
+
* keys (uniqueKeys), and treats an empty document as a warning.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseFile(text: string, file: string): {
|
|
7
|
+
data?: unknown;
|
|
8
|
+
findings: Finding[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/core/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA+B,MAAM,cAAc,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;CAAE,CAe7F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { parseDocument } from 'yaml';
|
|
2
|
+
import { yamlError, emptyFileWarning } from './finding.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read one file's text into a plain object. Reports invalid YAML and duplicate
|
|
5
|
+
* keys (uniqueKeys), and treats an empty document as a warning.
|
|
6
|
+
*/
|
|
7
|
+
export function parseFile(text, file) {
|
|
8
|
+
const doc = parseDocument(text, { uniqueKeys: true });
|
|
9
|
+
if (doc.errors.length > 0) {
|
|
10
|
+
return {
|
|
11
|
+
findings: doc.errors.map((err) => yamlError(err.message, file, err.linePos?.[0]?.line)),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const data = doc.toJS();
|
|
15
|
+
if (data == null) {
|
|
16
|
+
return { findings: [emptyFileWarning(file)] };
|
|
17
|
+
}
|
|
18
|
+
return { data, findings: [] };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/core/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAW,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEpE;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,IAAY;IAChD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtD,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO;YACH,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;SAC1F,CAAC;IACN,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAa,CAAC;IACnC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACf,OAAO,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;IAClD,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Diff, ReconcileMode } from './model.js';
|
|
2
|
+
/** What the report shows: the mode selects which operations, plus whether to list unchanged. */
|
|
3
|
+
type ReportOptions = {
|
|
4
|
+
mode: ReconcileMode;
|
|
5
|
+
showUnchanged: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Render a diff as a plan body, grouped by kind then target, with `+` adds, `~` expiration
|
|
9
|
+
* updates, `-` removes, and `=` unchanged. The mode scopes which operations appear (additive
|
|
10
|
+
* hides removes, destructive hides adds and updates), unchanged lines appear only when asked,
|
|
11
|
+
* and targets with nothing to show are omitted. Shared by plan and apply.
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatDiff(diff: Diff, options: ReportOptions): string[];
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/core/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAQ,aAAa,EAAE,MAAM,YAAY,CAAC;AAiBvD,gGAAgG;AAChG,KAAK,aAAa,GAAG;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;CAC1B,CAAC;AA2FF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,EAAE,CAoBvE"}
|