@sprucelabs/spruce-test-fixtures 62.3.102 → 62.4.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,20 @@
|
|
1
|
-
import { Authorizer, AuthorizerCanOptions, SavePermissionsOptions } from '@sprucelabs/heartwood-view-controllers';
|
1
|
+
import { Authorizer, AuthorizerCanOptions, AuthorizerDoesHonorOptions, SavePermissionsOptions } from '@sprucelabs/heartwood-view-controllers';
|
2
2
|
import { PermissionContractId, PermissionId } from '@sprucelabs/mercury-types';
|
3
3
|
export default class FakeAuthorizer implements Authorizer {
|
4
4
|
private fakedContracts;
|
5
5
|
private lastSavePermissionOptions?;
|
6
6
|
private lastCanOptions?;
|
7
|
+
private lastDoesHonorContractOptions?;
|
7
8
|
fakePermissions<ContractId extends PermissionContractId = PermissionContractId>(options: FakeOptions<ContractId>): void;
|
8
9
|
can<ContractId extends PermissionContractId, Ids extends PermissionId<ContractId>>(options: AuthorizerCanOptions<ContractId, Ids>): Promise<Record<Ids, boolean>>;
|
10
|
+
private getContractFromId;
|
9
11
|
getLastCanOptions(): AuthorizerCanOptions<any> | undefined;
|
10
12
|
savePermissions<ContractId extends PermissionContractId, Ids extends PermissionId<ContractId>>(options: SavePermissionsOptions<ContractId, Ids>): Promise<void>;
|
11
13
|
getLastSavePermissionsOptions<ContractId extends PermissionContractId = PermissionContractId, Ids extends PermissionId<ContractId> = PermissionId<ContractId>>(): SavePermissionsOptions<ContractId, Ids>;
|
12
14
|
private assertValidPermission;
|
13
15
|
private assertValidContractId;
|
16
|
+
doesHonorPermissionContract<ContractId extends PermissionContractId>(options: AuthorizerDoesHonorOptions<ContractId>): Promise<boolean>;
|
17
|
+
getLastDoesHonorContractOptions(): AuthorizerDoesHonorOptions<"authorizer-contract" | "chatbot-contract" | "events-contract" | "feed-contract" | "hiring-and-promoting-contract" | "listeners-contract" | "locations-contract" | "messaging-contract" | "organizations-contract" | "people-contract" | "permission-contract" | "roles-contract" | "skills-contract"> | undefined;
|
14
18
|
}
|
15
19
|
interface Perm<ContractId extends PermissionContractId> {
|
16
20
|
id: PermissionId<ContractId>;
|
@@ -20,8 +20,7 @@ export default class FakeAuthorizer {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
21
21
|
this.lastCanOptions = options;
|
22
22
|
const { contractId, permissionIds } = assertOptions(options, ['contractId', 'permissionIds']);
|
23
|
-
const fakedContract = this.
|
24
|
-
this.assertValidContractId(fakedContract, contractId);
|
23
|
+
const fakedContract = this.getContractFromId(contractId);
|
25
24
|
const results = {};
|
26
25
|
permissionIds.reverse();
|
27
26
|
for (const actual of permissionIds) {
|
@@ -32,6 +31,11 @@ export default class FakeAuthorizer {
|
|
32
31
|
return results;
|
33
32
|
});
|
34
33
|
}
|
34
|
+
getContractFromId(contractId) {
|
35
|
+
const fakedContract = this.fakedContracts.find((f) => f.contractId === contractId);
|
36
|
+
this.assertValidContractId(fakedContract, contractId);
|
37
|
+
return fakedContract;
|
38
|
+
}
|
35
39
|
getLastCanOptions() {
|
36
40
|
return this.lastCanOptions;
|
37
41
|
}
|
@@ -57,4 +61,15 @@ Valid contracts are:
|
|
57
61
|
|
58
62
|
${this.fakedContracts.map((p) => p.contractId).join('\n')}`);
|
59
63
|
}
|
64
|
+
doesHonorPermissionContract(options) {
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
66
|
+
const { contractId } = assertOptions(options, ['contractId']);
|
67
|
+
this.lastDoesHonorContractOptions = options;
|
68
|
+
const contract = this.getContractFromId(contractId);
|
69
|
+
return contract.permissions.filter((p) => p.can).length > 0;
|
70
|
+
});
|
71
|
+
}
|
72
|
+
getLastDoesHonorContractOptions() {
|
73
|
+
return this.lastDoesHonorContractOptions;
|
74
|
+
}
|
60
75
|
}
|
@@ -1,16 +1,20 @@
|
|
1
|
-
import { Authorizer, AuthorizerCanOptions, SavePermissionsOptions } from '@sprucelabs/heartwood-view-controllers';
|
1
|
+
import { Authorizer, AuthorizerCanOptions, AuthorizerDoesHonorOptions, SavePermissionsOptions } from '@sprucelabs/heartwood-view-controllers';
|
2
2
|
import { PermissionContractId, PermissionId } from '@sprucelabs/mercury-types';
|
3
3
|
export default class FakeAuthorizer implements Authorizer {
|
4
4
|
private fakedContracts;
|
5
5
|
private lastSavePermissionOptions?;
|
6
6
|
private lastCanOptions?;
|
7
|
+
private lastDoesHonorContractOptions?;
|
7
8
|
fakePermissions<ContractId extends PermissionContractId = PermissionContractId>(options: FakeOptions<ContractId>): void;
|
8
9
|
can<ContractId extends PermissionContractId, Ids extends PermissionId<ContractId>>(options: AuthorizerCanOptions<ContractId, Ids>): Promise<Record<Ids, boolean>>;
|
10
|
+
private getContractFromId;
|
9
11
|
getLastCanOptions(): AuthorizerCanOptions<any> | undefined;
|
10
12
|
savePermissions<ContractId extends PermissionContractId, Ids extends PermissionId<ContractId>>(options: SavePermissionsOptions<ContractId, Ids>): Promise<void>;
|
11
13
|
getLastSavePermissionsOptions<ContractId extends PermissionContractId = PermissionContractId, Ids extends PermissionId<ContractId> = PermissionId<ContractId>>(): SavePermissionsOptions<ContractId, Ids>;
|
12
14
|
private assertValidPermission;
|
13
15
|
private assertValidContractId;
|
16
|
+
doesHonorPermissionContract<ContractId extends PermissionContractId>(options: AuthorizerDoesHonorOptions<ContractId>): Promise<boolean>;
|
17
|
+
getLastDoesHonorContractOptions(): AuthorizerDoesHonorOptions<"authorizer-contract" | "chatbot-contract" | "events-contract" | "feed-contract" | "hiring-and-promoting-contract" | "listeners-contract" | "locations-contract" | "messaging-contract" | "organizations-contract" | "people-contract" | "permission-contract" | "roles-contract" | "skills-contract"> | undefined;
|
14
18
|
}
|
15
19
|
interface Perm<ContractId extends PermissionContractId> {
|
16
20
|
id: PermissionId<ContractId>;
|
@@ -12,8 +12,7 @@ class FakeAuthorizer {
|
|
12
12
|
async can(options) {
|
13
13
|
this.lastCanOptions = options;
|
14
14
|
const { contractId, permissionIds } = (0, schema_1.assertOptions)(options, ['contractId', 'permissionIds']);
|
15
|
-
const fakedContract = this.
|
16
|
-
this.assertValidContractId(fakedContract, contractId);
|
15
|
+
const fakedContract = this.getContractFromId(contractId);
|
17
16
|
const results = {};
|
18
17
|
permissionIds.reverse();
|
19
18
|
for (const actual of permissionIds) {
|
@@ -23,6 +22,11 @@ class FakeAuthorizer {
|
|
23
22
|
}
|
24
23
|
return results;
|
25
24
|
}
|
25
|
+
getContractFromId(contractId) {
|
26
|
+
const fakedContract = this.fakedContracts.find((f) => f.contractId === contractId);
|
27
|
+
this.assertValidContractId(fakedContract, contractId);
|
28
|
+
return fakedContract;
|
29
|
+
}
|
26
30
|
getLastCanOptions() {
|
27
31
|
return this.lastCanOptions;
|
28
32
|
}
|
@@ -46,5 +50,14 @@ Valid contracts are:
|
|
46
50
|
|
47
51
|
${this.fakedContracts.map((p) => p.contractId).join('\n')}`);
|
48
52
|
}
|
53
|
+
async doesHonorPermissionContract(options) {
|
54
|
+
const { contractId } = (0, schema_1.assertOptions)(options, ['contractId']);
|
55
|
+
this.lastDoesHonorContractOptions = options;
|
56
|
+
const contract = this.getContractFromId(contractId);
|
57
|
+
return contract.permissions.filter((p) => p.can).length > 0;
|
58
|
+
}
|
59
|
+
getLastDoesHonorContractOptions() {
|
60
|
+
return this.lastDoesHonorContractOptions;
|
61
|
+
}
|
49
62
|
}
|
50
63
|
exports.default = FakeAuthorizer;
|
package/package.json
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
"@sprucelabs/spruce-test-fixtures"
|
14
14
|
]
|
15
15
|
},
|
16
|
-
"version": "62.
|
16
|
+
"version": "62.4.0",
|
17
17
|
"files": [
|
18
18
|
"build/**/*",
|
19
19
|
"!build/__tests__",
|
@@ -63,15 +63,15 @@
|
|
63
63
|
"dependencies": {
|
64
64
|
"@sprucelabs/data-stores": "^28.3.205",
|
65
65
|
"@sprucelabs/error": "^6.0.536",
|
66
|
-
"@sprucelabs/heartwood-view-controllers": "^
|
66
|
+
"@sprucelabs/heartwood-view-controllers": "^111.0.0",
|
67
67
|
"@sprucelabs/mercury-client": "^42.0.588",
|
68
68
|
"@sprucelabs/mercury-core-events": "^25.0.33",
|
69
69
|
"@sprucelabs/mercury-event-emitter": "^42.0.588",
|
70
70
|
"@sprucelabs/schema": "^30.0.552",
|
71
71
|
"@sprucelabs/spruce-core-schemas": "^40.1.538",
|
72
72
|
"@sprucelabs/spruce-event-utils": "^40.1.312",
|
73
|
-
"@sprucelabs/spruce-permission-utils": "^8.0
|
74
|
-
"@sprucelabs/spruce-skill-booter": "^62.
|
73
|
+
"@sprucelabs/spruce-permission-utils": "^8.1.0",
|
74
|
+
"@sprucelabs/spruce-skill-booter": "^62.4.0",
|
75
75
|
"@sprucelabs/spruce-skill-utils": "^31.0.612",
|
76
76
|
"@sprucelabs/test-utils": "^5.1.494",
|
77
77
|
"dotenv": "^16.4.5",
|
@@ -114,5 +114,5 @@
|
|
114
114
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
115
115
|
}
|
116
116
|
},
|
117
|
-
"gitHead": "
|
117
|
+
"gitHead": "2ce9914e233f0626c108c35a03f79ee4a0c42fa0"
|
118
118
|
}
|