sf-plugin-permission-sets 0.3.1 → 0.5.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/LICENSE.md +28 -0
- package/README.md +181 -29
- package/lib/adapters/connection-org-client.d.ts +11 -5
- package/lib/adapters/connection-org-client.d.ts.map +1 -1
- package/lib/adapters/connection-org-client.js +219 -106
- package/lib/adapters/connection-org-client.js.map +1 -1
- 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 +13 -0
- package/lib/commands/ps/apply.d.ts.map +1 -1
- package/lib/commands/ps/apply.js +83 -34
- package/lib/commands/ps/apply.js.map +1 -1
- package/lib/commands/ps/check.d.ts +3 -1
- package/lib/commands/ps/check.d.ts.map +1 -1
- package/lib/commands/ps/check.js +15 -6
- package/lib/commands/ps/check.js.map +1 -1
- package/lib/commands/ps/export.d.ts +11 -2
- package/lib/commands/ps/export.d.ts.map +1 -1
- package/lib/commands/ps/export.js +53 -7
- package/lib/commands/ps/export.js.map +1 -1
- package/lib/commands/ps/plan.d.ts +13 -1
- package/lib/commands/ps/plan.d.ts.map +1 -1
- package/lib/commands/ps/plan.js +87 -30
- package/lib/commands/ps/plan.js.map +1 -1
- package/lib/commands/ps/validate.d.ts +3 -1
- package/lib/commands/ps/validate.d.ts.map +1 -1
- package/lib/commands/ps/validate.js +16 -7
- package/lib/commands/ps/validate.js.map +1 -1
- package/lib/core/diff.js +1 -1
- package/lib/core/diff.js.map +1 -1
- package/lib/core/finding.d.ts +3 -2
- package/lib/core/finding.d.ts.map +1 -1
- package/lib/core/finding.js +10 -2
- package/lib/core/finding.js.map +1 -1
- package/lib/core/index.d.ts +10 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +9 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/load.d.ts.map +1 -1
- package/lib/core/load.js +17 -10
- package/lib/core/load.js.map +1 -1
- package/lib/core/mode.d.ts +18 -0
- package/lib/core/mode.d.ts.map +1 -0
- package/lib/core/mode.js +16 -0
- package/lib/core/mode.js.map +1 -0
- package/lib/core/model.d.ts +13 -8
- package/lib/core/model.d.ts.map +1 -1
- package/lib/core/normalize.d.ts +2 -0
- package/lib/core/normalize.d.ts.map +1 -1
- package/lib/core/normalize.js +15 -5
- package/lib/core/normalize.js.map +1 -1
- package/lib/core/report.d.ts +2 -1
- package/lib/core/report.d.ts.map +1 -1
- package/lib/core/report.js +43 -24
- package/lib/core/report.js.map +1 -1
- package/lib/core/schema.d.ts +2 -12
- package/lib/core/schema.d.ts.map +1 -1
- package/lib/core/schema.js +2 -2
- package/lib/core/schema.js.map +1 -1
- package/lib/core/serialize.d.ts.map +1 -1
- package/lib/core/serialize.js +3 -1
- package/lib/core/serialize.js.map +1 -1
- 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 +10 -6
- package/lib/services/adapters/org-client.d.ts.map +1 -1
- package/lib/services/apply.d.ts +10 -11
- package/lib/services/apply.d.ts.map +1 -1
- package/lib/services/apply.js +29 -38
- package/lib/services/apply.js.map +1 -1
- package/lib/services/check.d.ts +3 -7
- package/lib/services/check.d.ts.map +1 -1
- package/lib/services/check.js +5 -12
- package/lib/services/check.js.map +1 -1
- package/lib/services/export.d.ts +11 -6
- package/lib/services/export.d.ts.map +1 -1
- package/lib/services/export.js +14 -10
- package/lib/services/export.js.map +1 -1
- 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 +4 -10
- package/lib/services/plan.d.ts.map +1 -1
- package/lib/services/plan.js +22 -18
- package/lib/services/plan.js.map +1 -1
- package/lib/services/resolution.d.ts +7 -6
- package/lib/services/resolution.d.ts.map +1 -1
- package/lib/services/resolution.js +32 -9
- package/lib/services/resolution.js.map +1 -1
- package/lib/services/validate.d.ts +8 -7
- package/lib/services/validate.d.ts.map +1 -1
- package/lib/services/validate.js +29 -13
- package/lib/services/validate.js.map +1 -1
- package/messages/ps.check.md +1 -1
- package/messages/ps.export.md +21 -1
- package/messages/ps.validate.md +2 -2
- package/package.json +25 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG;IACvB,6FAA6F;IAC7F,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,qEAAqE;AACrE,qBAAa,aAAa;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAqBrG"}
|
package/lib/services/export.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { writeFile, mkdir } from 'node:fs/promises';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
|
-
import { serializeAssignments } from '../core/
|
|
4
|
-
/**
|
|
3
|
+
import { serializeAssignments } from '../core/index.js';
|
|
4
|
+
/** Read the org's current assignments and serialize them as YAML. */
|
|
5
5
|
export class ExportService {
|
|
6
6
|
org;
|
|
7
|
-
|
|
8
|
-
constructor(org, outputFile) {
|
|
7
|
+
constructor(org) {
|
|
9
8
|
this.org = org;
|
|
10
|
-
this.outputFile = outputFile;
|
|
11
9
|
}
|
|
12
|
-
async run() {
|
|
13
|
-
const assignments = await this.org.listAssignments();
|
|
10
|
+
async run(outputFile, filter) {
|
|
11
|
+
const assignments = await this.org.listAssignments(filter);
|
|
14
12
|
const content = serializeAssignments(assignments);
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (outputFile) {
|
|
14
|
+
await mkdir(dirname(outputFile), { recursive: true });
|
|
15
|
+
await writeFile(outputFile, content, 'utf8');
|
|
16
|
+
}
|
|
17
17
|
const assignees = new Set(assignments.map((assignment) => assignment.assignee));
|
|
18
|
+
const requested = filter?.usernames ?? [];
|
|
19
|
+
const unmatchedUsers = requested.filter((username) => !assignees.has(username));
|
|
18
20
|
return {
|
|
19
|
-
outputFile:
|
|
21
|
+
outputFile: outputFile ?? null,
|
|
22
|
+
content,
|
|
20
23
|
users: assignees.size,
|
|
21
24
|
assignments: assignments.length,
|
|
25
|
+
unmatchedUsers,
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/services/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAoB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAc1E,qEAAqE;AACrE,MAAM,OAAO,aAAa;IACc;IAApC,YAAoC,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,KAAK,CAAC,GAAG,CAAC,UAA8B,EAAE,MAAyB;QACtE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAElD,IAAI,UAAU,EAAE,CAAC;YACb,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,MAAM,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChF,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;QAC1C,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEhF,OAAO;YACH,UAAU,EAAE,UAAU,IAAI,IAAI;YAC9B,OAAO;YACP,KAAK,EAAE,SAAS,CAAC,IAAI;YACrB,WAAW,EAAE,WAAW,CAAC,MAAM;YAC/B,cAAc;SACjB,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { ApplyService, ConfirmDeletions, ApplyResult } from './apply.js';
|
|
2
|
+
export { CheckService } from './check.js';
|
|
3
|
+
export { ExportService } from './export.js';
|
|
4
|
+
export { PlanService } from './plan.js';
|
|
5
|
+
export { ValidateService } from './validate.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/services/plan.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { Diff } from '../core/
|
|
2
|
-
import {
|
|
3
|
-
import { OrgClient } from './adapters/org-client.js';
|
|
1
|
+
import { Diff, Finding } from '../core/index.js';
|
|
2
|
+
import { OrgClient } from './adapters/index.js';
|
|
4
3
|
export type PlanMode = 'additive' | 'destructive' | 'sync';
|
|
5
|
-
export type PlanInput = {
|
|
6
|
-
mode: PlanMode;
|
|
7
|
-
};
|
|
8
4
|
/** How a run ended, so the command can report and set the exit code. */
|
|
9
5
|
export type PlanStatus = 'planned' | 'invalid';
|
|
10
6
|
export type PlanResult = {
|
|
@@ -27,9 +23,7 @@ export type PlanResult = {
|
|
|
27
23
|
*/
|
|
28
24
|
export declare class PlanService {
|
|
29
25
|
private readonly org;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
constructor(org: OrgClient, files: string[], input: PlanInput);
|
|
33
|
-
run(): Promise<PlanResult>;
|
|
26
|
+
constructor(org: OrgClient);
|
|
27
|
+
run(files: string[], mode: PlanMode): Promise<PlanResult>;
|
|
34
28
|
}
|
|
35
29
|
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,MAAM,CAAC;AAE3D,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,iEAAiE;IACjE,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,MAAM,EAAE,UAAU,CAAC;CACtB,CAAC;AAeF;;;;;GAKG;AACH,qBAAa,WAAW;IACD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;CA4BzE"}
|
package/lib/services/plan.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { loadFiles } from '../core/
|
|
2
|
-
import { diffAssignments } from '../core/diff.js';
|
|
3
|
-
import { countFindings } from '../core/finding.js';
|
|
1
|
+
import { loadFiles, diffAssignments, countFindings } from '../core/index.js';
|
|
4
2
|
import { ResolutionService, managedTargets } from './resolution.js';
|
|
5
3
|
const emptyDiff = { toAdd: [], toUpdate: [], toRemove: [], unchanged: [] };
|
|
6
4
|
/** An aborted-before-the-diff result, carrying the findings that explain why. */
|
|
7
5
|
function invalidResult(files, findings) {
|
|
8
|
-
return {
|
|
6
|
+
return {
|
|
7
|
+
files,
|
|
8
|
+
findings,
|
|
9
|
+
diff: emptyDiff,
|
|
10
|
+
drift: { adds: 0, updates: 0, removes: 0 },
|
|
11
|
+
status: 'invalid',
|
|
12
|
+
};
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Read-only preview: load the files, resolve every reference to an org id, fetch the
|
|
@@ -15,27 +19,27 @@ function invalidResult(files, findings) {
|
|
|
15
19
|
*/
|
|
16
20
|
export class PlanService {
|
|
17
21
|
org;
|
|
18
|
-
|
|
19
|
-
input;
|
|
20
|
-
constructor(org, files, input) {
|
|
22
|
+
constructor(org) {
|
|
21
23
|
this.org = org;
|
|
22
|
-
this.files = files;
|
|
23
|
-
this.input = input;
|
|
24
24
|
}
|
|
25
|
-
async run() {
|
|
26
|
-
const loaded = await loadFiles(
|
|
27
|
-
|
|
25
|
+
async run(files, mode) {
|
|
26
|
+
const loaded = await loadFiles(files);
|
|
27
|
+
const loadCounts = countFindings(loaded.findings);
|
|
28
|
+
if (loadCounts.errors > 0) {
|
|
28
29
|
return invalidResult(loaded.files, loaded.findings);
|
|
29
30
|
}
|
|
30
|
-
const resolutionService = new ResolutionService(this.org
|
|
31
|
-
const resolution = await resolutionService.run();
|
|
32
|
-
const findings = [
|
|
33
|
-
|
|
31
|
+
const resolutionService = new ResolutionService(this.org);
|
|
32
|
+
const resolution = await resolutionService.run(loaded.assignments);
|
|
33
|
+
const findings = [
|
|
34
|
+
...loaded.findings,
|
|
35
|
+
...resolution.findings,
|
|
36
|
+
];
|
|
37
|
+
const findingCounts = countFindings(findings);
|
|
38
|
+
if (findingCounts.errors > 0) {
|
|
34
39
|
return invalidResult(loaded.files, findings);
|
|
35
40
|
}
|
|
36
|
-
const actual = await this.org.
|
|
41
|
+
const actual = await this.org.listCurrentAssignments(managedTargets(resolution));
|
|
37
42
|
const diff = diffAssignments(loaded.assignments, actual);
|
|
38
|
-
const { mode } = this.input;
|
|
39
43
|
const drift = {
|
|
40
44
|
adds: mode === 'destructive' ? diff.toAdd.length : 0,
|
|
41
45
|
updates: mode === 'destructive' ? diff.toUpdate.length : 0,
|
package/lib/services/plan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/services/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAiB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAgBpE,MAAM,SAAS,GAAS,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AAEjF,iFAAiF;AACjF,SAAS,aAAa,CAAC,KAAe,EAAE,QAAmB;IACvD,OAAO;QACH,KAAK;QACL,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;QAC1C,MAAM,EAAE,SAAS;KACpB,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,WAAW;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AC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC1D,OAAO,EAAE,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;SAC1D,CAAC;QAEF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC7E,CAAC;CACJ"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { DesiredAssignment, Kind, TargetRef } from '../core/
|
|
2
|
-
import {
|
|
3
|
-
import { OrgClient } from './adapters/org-client.js';
|
|
1
|
+
import { DesiredAssignment, Kind, OrgTarget, ResolvedAddition, TargetRef, Finding } from '../core/index.js';
|
|
2
|
+
import { OrgClient } from './adapters/index.js';
|
|
4
3
|
export type Resolution = {
|
|
5
4
|
findings: Finding[];
|
|
6
5
|
userIds: Map<string, string>;
|
|
7
6
|
targetIds: Record<Kind, Map<string, string>>;
|
|
8
7
|
};
|
|
9
8
|
export declare function managedTargets(resolution: Resolution): TargetRef[];
|
|
9
|
+
/** Attach the resolved assignee and target ids to each addition, so it can be inserted. */
|
|
10
|
+
export declare function resolveAdditions(additions: DesiredAssignment[], resolution: Resolution): ResolvedAddition[];
|
|
10
11
|
/** Look every declared reference up in the org, returning findings and the resolved id maps. */
|
|
11
12
|
export declare class ResolutionService {
|
|
12
13
|
private readonly org;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
constructor(org: OrgClient);
|
|
15
|
+
run(assignments: DesiredAssignment[]): Promise<Resolution>;
|
|
16
|
+
findTargetsOfKind(kind: Kind, names: string[]): Promise<OrgTarget[]>;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,IAAI,EACJ,SAAS,EAET,gBAAgB,EAChB,SAAS,EACT,OAAO,EAQV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG;IACrB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,CAQlE;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,EAAE,EAAE,UAAU,EAAE,UAAU,GAAG,gBAAgB,EAAE,CAM3G;AAED,gGAAgG;AAChG,qBAAa,iBAAiB;IACP,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAuCvE,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAOvE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { kinds, distinctAssignees, distinctTargets, evaluateUsers, evaluateTargets, indexUsersById, indexTargetsById, } from '../core/
|
|
1
|
+
import { kinds, distinctAssignees, distinctTargets, evaluateUsers, evaluateTargets, indexUsersById, indexTargetsById, } from '../core/index.js';
|
|
2
2
|
export function managedTargets(resolution) {
|
|
3
3
|
const refs = [];
|
|
4
4
|
for (const kind of kinds) {
|
|
@@ -8,20 +8,34 @@ export function managedTargets(resolution) {
|
|
|
8
8
|
}
|
|
9
9
|
return refs;
|
|
10
10
|
}
|
|
11
|
+
/** Attach the resolved assignee and target ids to each addition, so it can be inserted. */
|
|
12
|
+
export function resolveAdditions(additions, resolution) {
|
|
13
|
+
return additions.map((addition) => ({
|
|
14
|
+
...addition,
|
|
15
|
+
assigneeId: resolution.userIds.get(addition.assignee.toLowerCase()) ?? '',
|
|
16
|
+
targetId: resolution.targetIds[addition.kind].get(addition.target.toLowerCase()) ?? '',
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
11
19
|
/** Look every declared reference up in the org, returning findings and the resolved id maps. */
|
|
12
20
|
export class ResolutionService {
|
|
13
21
|
org;
|
|
14
|
-
|
|
15
|
-
constructor(org, assignments) {
|
|
22
|
+
constructor(org) {
|
|
16
23
|
this.org = org;
|
|
17
|
-
this.assignments = assignments;
|
|
18
24
|
}
|
|
19
|
-
async run() {
|
|
20
|
-
const usernames = distinctAssignees(
|
|
21
|
-
const targetsByKind = kinds.map((kind) => ({ kind, targets: distinctTargets(
|
|
25
|
+
async run(assignments) {
|
|
26
|
+
const usernames = distinctAssignees(assignments);
|
|
27
|
+
const targetsByKind = kinds.map((kind) => ({ kind, targets: distinctTargets(assignments, kind) }));
|
|
22
28
|
const usersTask = usernames.length > 0 ? this.org.findUsers(usernames) : Promise.resolve([]);
|
|
23
|
-
const targetsTask = Promise.all(targetsByKind.map(({ kind, targets }) =>
|
|
24
|
-
|
|
29
|
+
const targetsTask = Promise.all(targetsByKind.map(async ({ kind, targets }) => {
|
|
30
|
+
if (targets.length === 0)
|
|
31
|
+
return { kind, targets, found: [] };
|
|
32
|
+
const found = await this.findTargetsOfKind(kind, targets);
|
|
33
|
+
return { kind, targets, found };
|
|
34
|
+
}));
|
|
35
|
+
const [foundUsers, perKind] = await Promise.all([
|
|
36
|
+
usersTask,
|
|
37
|
+
targetsTask,
|
|
38
|
+
]);
|
|
25
39
|
const findings = [...evaluateUsers(usernames, foundUsers)];
|
|
26
40
|
for (const { kind, targets, found } of perKind) {
|
|
27
41
|
findings.push(...evaluateTargets(kind, targets, found.map((target) => target.name)));
|
|
@@ -32,5 +46,14 @@ export class ResolutionService {
|
|
|
32
46
|
}
|
|
33
47
|
return { findings, userIds: indexUsersById(foundUsers), targetIds };
|
|
34
48
|
}
|
|
49
|
+
findTargetsOfKind(kind, names) {
|
|
50
|
+
if (kind === 'permissionSet')
|
|
51
|
+
return this.org.findPermissionSets(names);
|
|
52
|
+
if (kind === 'permissionSetGroup')
|
|
53
|
+
return this.org.findPermissionSetGroups(names);
|
|
54
|
+
if (kind === 'permissionSetLicense')
|
|
55
|
+
return this.org.findPermissionSetLicenses(names);
|
|
56
|
+
throw new Error(`Unsupported kind: ${String(kind)}`);
|
|
57
|
+
}
|
|
35
58
|
}
|
|
36
59
|
//# sourceMappingURL=resolution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/services/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,GACnB,MAAM,kBAAkB,CAAC;AAS1B,MAAM,UAAU,cAAc,CAAC,UAAsB;IACjD,MAAM,IAAI,GAAgB,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,MAAM,EAAE,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,2FAA2F;A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AC,GAAG,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAEtF,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DesiredAssignment } from '../core/
|
|
2
|
-
import {
|
|
3
|
-
import { OrgClient } from './adapters/org-client.js';
|
|
1
|
+
import { DesiredAssignment, Finding, Kind, OrgTarget } from '../core/index.js';
|
|
2
|
+
import { OrgClient } from './adapters/index.js';
|
|
4
3
|
export type ValidateResult = {
|
|
5
4
|
files: string[];
|
|
6
5
|
assignments: DesiredAssignment[];
|
|
@@ -9,13 +8,15 @@ export type ValidateResult = {
|
|
|
9
8
|
warnings: number;
|
|
10
9
|
failed: boolean;
|
|
11
10
|
};
|
|
12
|
-
/**
|
|
11
|
+
/** Load the files, then resolve every reference against the org. */
|
|
13
12
|
export declare class ValidateService {
|
|
14
13
|
private readonly org;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
run(): Promise<ValidateResult>;
|
|
14
|
+
constructor(org: OrgClient);
|
|
15
|
+
run(files: string[]): Promise<ValidateResult>;
|
|
18
16
|
/** Look every reference up in the org (in parallel) and evaluate the results. */
|
|
19
17
|
private resolve;
|
|
18
|
+
private evaluateUserRefs;
|
|
19
|
+
private evaluateTargetRefs;
|
|
20
|
+
findTargetsOfKind(kind: Kind, names: string[]): Promise<OrgTarget[]>;
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,iBAAiB,EACjB,OAAO,EACP,IAAI,EAEJ,SAAS,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,oEAAoE;AACpE,qBAAa,eAAe;IACL,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAoB1D,iFAAiF;YACnE,OAAO;YAmBP,gBAAgB;YAKhB,kBAAkB;IAShC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAOvE"}
|
package/lib/services/validate.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { loadFiles } from '../core/
|
|
2
|
-
|
|
3
|
-
import { countFindings } from '../core/finding.js';
|
|
4
|
-
/** Online validate: run the offline load, then resolve every reference against the org. */
|
|
1
|
+
import { loadFiles, kinds, distinctAssignees, distinctTargets, evaluateUsers, evaluateTargets, countFindings, } from '../core/index.js';
|
|
2
|
+
/** Load the files, then resolve every reference against the org. */
|
|
5
3
|
export class ValidateService {
|
|
6
4
|
org;
|
|
7
|
-
|
|
8
|
-
constructor(org, files) {
|
|
5
|
+
constructor(org) {
|
|
9
6
|
this.org = org;
|
|
10
|
-
this.files = files;
|
|
11
7
|
}
|
|
12
|
-
async run() {
|
|
13
|
-
const loaded = await loadFiles(
|
|
14
|
-
const
|
|
15
|
-
const findings = [
|
|
8
|
+
async run(files) {
|
|
9
|
+
const loaded = await loadFiles(files);
|
|
10
|
+
const resolved = await this.resolve(loaded.assignments);
|
|
11
|
+
const findings = [
|
|
12
|
+
...loaded.findings,
|
|
13
|
+
...resolved,
|
|
14
|
+
];
|
|
16
15
|
const { errors, warnings } = countFindings(findings);
|
|
17
16
|
return {
|
|
18
17
|
files: loaded.files,
|
|
@@ -28,16 +27,33 @@ export class ValidateService {
|
|
|
28
27
|
const tasks = [];
|
|
29
28
|
const usernames = distinctAssignees(assignments);
|
|
30
29
|
if (usernames.length > 0) {
|
|
31
|
-
tasks.push(this.
|
|
30
|
+
tasks.push(this.evaluateUserRefs(usernames));
|
|
32
31
|
}
|
|
33
32
|
for (const kind of kinds) {
|
|
34
33
|
const targets = distinctTargets(assignments, kind);
|
|
35
34
|
if (targets.length > 0) {
|
|
36
|
-
tasks.push(this.
|
|
35
|
+
tasks.push(this.evaluateTargetRefs(kind, targets));
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
const results = await Promise.all(tasks);
|
|
40
39
|
return results.flat();
|
|
41
40
|
}
|
|
41
|
+
async evaluateUserRefs(usernames) {
|
|
42
|
+
const found = await this.org.findUsers(usernames);
|
|
43
|
+
return evaluateUsers(usernames, found);
|
|
44
|
+
}
|
|
45
|
+
async evaluateTargetRefs(kind, targets) {
|
|
46
|
+
const found = await this.findTargetsOfKind(kind, targets);
|
|
47
|
+
return evaluateTargets(kind, targets, found.map((target) => target.name));
|
|
48
|
+
}
|
|
49
|
+
findTargetsOfKind(kind, names) {
|
|
50
|
+
if (kind === 'permissionSet')
|
|
51
|
+
return this.org.findPermissionSets(names);
|
|
52
|
+
if (kind === 'permissionSetGroup')
|
|
53
|
+
return this.org.findPermissionSetGroups(names);
|
|
54
|
+
if (kind === 'permissionSetLicense')
|
|
55
|
+
return this.org.findPermissionSetLicenses(names);
|
|
56
|
+
throw new Error(`Unsupported kind: ${String(kind)}`);
|
|
57
|
+
}
|
|
42
58
|
}
|
|
43
59
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/services/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EAIf,aAAa,GAEhB,MAAM,kBAAkB,CAAC;AAY1B,oEAAoE;AACpE,MAAM,OAAO,eAAe;IACY;IAApC,YAAoC,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAI,CAAC;IAEhD,KAAK,CAAC,GAAG,CAAC,KAAe;QAC5B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAExD,MAAM,QAAQ,GAAG;YACb,GAAG,MAAM,CAAC,QAAQ;YAClB,GAAG,QAAQ;SACd,CAAC;QACF,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;QAErD,OAAO;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ;YACR,MAAM;YACN,QAAQ;YACR,MAAM,EAAE,MAAM,GAAG,CAAC;SACrB,CAAC;IACN,CAAC;IAED,iFAAiF;IACzE,KAAK,CAAC,OAAO,CAAC,WAAgC;QAClD,MAAM,KAAK,GAA8B,EAAE,CAAC;QAE5C,MAAM,SAAS,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CA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CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ"}
|
package/messages/ps.check.md
CHANGED
|
@@ -4,7 +4,7 @@ Statically check permission set assignment files, with no org connection.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Parse and validate the YAML files
|
|
7
|
+
Parse and validate the YAML files, no org needed. Reports invalid YAML, schema violations, duplicate keys, duplicate targets, and empty entries. Run it in a pre-commit hook or in CI before validate, plan, or apply.
|
|
8
8
|
|
|
9
9
|
# flags.file.summary
|
|
10
10
|
|
package/messages/ps.export.md
CHANGED
|
@@ -8,12 +8,24 @@ Query the target org for every assignable permission set, group, and license ass
|
|
|
8
8
|
|
|
9
9
|
# flags.output-file.summary
|
|
10
10
|
|
|
11
|
-
Path of the YAML file to write. Created (and its parent directories) if missing, overwritten if present.
|
|
11
|
+
Path of the YAML file to write. Created (and its parent directories) if missing, overwritten if present. Omit to write the document to stdout.
|
|
12
|
+
|
|
13
|
+
# flags.user.summary
|
|
14
|
+
|
|
15
|
+
Only export these users, matched on exact username. Repeatable; multiple values are a union.
|
|
16
|
+
|
|
17
|
+
# flags.kind.summary
|
|
18
|
+
|
|
19
|
+
Only export these scopes: permissionSets, permissionSetGroups, or permissionSetLicenses. Repeatable; combined with --user as an intersection.
|
|
12
20
|
|
|
13
21
|
# success
|
|
14
22
|
|
|
15
23
|
Exported %s assignments across %s users to %s.
|
|
16
24
|
|
|
25
|
+
# warnNoAssignments
|
|
26
|
+
|
|
27
|
+
No assignments in scope for user %s, it was skipped.
|
|
28
|
+
|
|
17
29
|
# examples
|
|
18
30
|
|
|
19
31
|
- Export the dev org's assignments to permissions.yml:
|
|
@@ -23,3 +35,11 @@ Exported %s assignments across %s users to %s.
|
|
|
23
35
|
- Export a production org into an environment folder:
|
|
24
36
|
|
|
25
37
|
<%= config.bin %> <%= command.id %> --target-org prod --output-file permissions/prod.yml
|
|
38
|
+
|
|
39
|
+
- Write to stdout and diff against a committed snapshot:
|
|
40
|
+
|
|
41
|
+
<%= config.bin %> <%= command.id %> --target-org prod | diff - permissions/prod.yml
|
|
42
|
+
|
|
43
|
+
- Export two users' permission sets and groups only:
|
|
44
|
+
|
|
45
|
+
<%= config.bin %> <%= command.id %> --target-org prod --output-file team.yml --user jdoe@acme.com --user asmith@acme.com --kind permissionSets --kind permissionSetGroups
|
package/messages/ps.validate.md
CHANGED
|
@@ -4,7 +4,7 @@ Validate permission set assignment files against a target org.
|
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
7
|
-
Run
|
|
7
|
+
Run the same file checks as check, then resolve each referenced user, permission set, group, and license against the org. Reports users that are missing or inactive and targets that are missing or not unique. Read-only: it queries the org but never changes it. Run it before plan or apply.
|
|
8
8
|
|
|
9
9
|
# flags.file.summary
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ Validation found problems. See the output above.
|
|
|
22
22
|
|
|
23
23
|
- Validate every file under permissions against the dev org:
|
|
24
24
|
|
|
25
|
-
<%= config.bin %> <%= command.id %> --file "permissions
|
|
25
|
+
<%= config.bin %> <%= command.id %> --file "permissions/*.yml" --target-org dev
|
|
26
26
|
|
|
27
27
|
- Validate specific files against a named org:
|
|
28
28
|
|
package/package.json
CHANGED
|
@@ -5,27 +5,31 @@
|
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/zaclummys/sf-plugin-permission-sets.git"
|
|
7
7
|
},
|
|
8
|
+
"homepage": "https://github.com/zaclummys/sf-plugin-permission-sets#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/zaclummys/sf-plugin-permission-sets/issues"
|
|
11
|
+
},
|
|
8
12
|
"dependencies": {
|
|
9
13
|
"@oclif/core": "^4",
|
|
10
14
|
"@salesforce/core": "^8",
|
|
11
15
|
"@salesforce/sf-plugins-core": "^12",
|
|
12
|
-
"globby": "^16
|
|
13
|
-
"yaml": "^2
|
|
14
|
-
"zod": "^4
|
|
16
|
+
"globby": "^16",
|
|
17
|
+
"yaml": "^2",
|
|
18
|
+
"zod": "^4"
|
|
15
19
|
},
|
|
16
20
|
"devDependencies": {
|
|
17
|
-
"@eslint/js": "^10
|
|
18
|
-
"eslint": "^10
|
|
19
|
-
"execa": "^9
|
|
20
|
-
"globals": "^17
|
|
21
|
-
"ts-node": "^10
|
|
22
|
-
"typescript": "^6
|
|
23
|
-
"typescript-eslint": "^8
|
|
24
|
-
"vitest": "^4
|
|
25
|
-
"wireit": "^0
|
|
21
|
+
"@eslint/js": "^10",
|
|
22
|
+
"eslint": "^10",
|
|
23
|
+
"execa": "^9",
|
|
24
|
+
"globals": "^17",
|
|
25
|
+
"ts-node": "^10",
|
|
26
|
+
"typescript": "^6",
|
|
27
|
+
"typescript-eslint": "^8",
|
|
28
|
+
"vitest": "^4",
|
|
29
|
+
"wireit": "^0"
|
|
26
30
|
},
|
|
27
31
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
32
|
+
"node": ">=20.0.0"
|
|
29
33
|
},
|
|
30
34
|
"files": [
|
|
31
35
|
"/lib",
|
|
@@ -95,7 +99,7 @@
|
|
|
95
99
|
"files": [
|
|
96
100
|
"src/**/*.ts",
|
|
97
101
|
"messages/**",
|
|
98
|
-
"
|
|
102
|
+
"eslint.config.js",
|
|
99
103
|
"**/tsconfig.json"
|
|
100
104
|
],
|
|
101
105
|
"output": []
|
|
@@ -106,11 +110,15 @@
|
|
|
106
110
|
"compile"
|
|
107
111
|
],
|
|
108
112
|
"env": {
|
|
109
|
-
"FORCE_COLOR": "2"
|
|
113
|
+
"FORCE_COLOR": "2",
|
|
114
|
+
"PS_TARGET_ORG": {
|
|
115
|
+
"external": true
|
|
116
|
+
}
|
|
110
117
|
},
|
|
111
118
|
"files": [
|
|
112
119
|
"test/**",
|
|
113
|
-
"vitest.config.js"
|
|
120
|
+
"vitest.config.js",
|
|
121
|
+
".env"
|
|
114
122
|
],
|
|
115
123
|
"output": []
|
|
116
124
|
}
|
|
@@ -118,5 +126,5 @@
|
|
|
118
126
|
"exports": "./lib/index.js",
|
|
119
127
|
"type": "module",
|
|
120
128
|
"author": "Isaac Ferreira",
|
|
121
|
-
"version": "0.
|
|
129
|
+
"version": "0.5.0"
|
|
122
130
|
}
|