@sprucelabs/spruce-test-fixtures 74.1.38 → 74.1.40

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.
@@ -21,7 +21,7 @@ interface Perm<ContractId extends PermissionContractId> {
21
21
  id: PermissionId<ContractId>;
22
22
  can: boolean;
23
23
  }
24
- export type PermissionContractTarget = SpruceSchemas.Mercury.v2020_12_25.DoesHonorPermissionContractEmitTarget;
24
+ export type PermissionContractTarget = SpruceSchemas.Mercury.v2020_12_25.GetResolvedPermissionsContractEmitTarget;
25
25
  export interface FakePermissionOptions<ContractId extends PermissionContractId = PermissionContractId> {
26
26
  contractId: ContractId;
27
27
  permissions: Perm<ContractId>[];
@@ -18,7 +18,7 @@ export default class FakeAuthorizer {
18
18
  }
19
19
  can(options) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- var _a, _b;
21
+ var _a, _b, _c, _d;
22
22
  this.lastCanOptions = options;
23
23
  const { contractId, permissionIds, target } = assertOptions(options, ['contractId', 'permissionIds']);
24
24
  const fakedContracts = this.getContractsFromId(contractId);
@@ -32,14 +32,19 @@ export default class FakeAuthorizer {
32
32
  for (const actual of permissionIds) {
33
33
  const fakedPerm = fakedPermissions.find((p) => p.id === actual);
34
34
  this.assertValidPermission(fakedPerm, actual, fakedContract);
35
+ const doesOrganizationMatch = ((_a = fakedContract.target) === null || _a === void 0 ? void 0 : _a.organizationId) ===
36
+ (target === null || target === void 0 ? void 0 : target.organizationId);
37
+ const doesLocationMatch = ((_b = fakedContract.target) === null || _b === void 0 ? void 0 : _b.locationId) === (target === null || target === void 0 ? void 0 : target.locationId);
38
+ const doesPersonMatch = !((_c = fakedContract.target) === null || _c === void 0 ? void 0 : _c.contractPersonId) ||
39
+ (target === null || target === void 0 ? void 0 : target.contractPersonId) ===
40
+ ((_d = fakedContract.target) === null || _d === void 0 ? void 0 : _d.contractPersonId);
35
41
  results[fakedPerm.id] =
36
42
  results[fakedPerm.id] ||
37
43
  (fakedPerm.can &&
38
44
  (!fakedContract.target ||
39
- (((_a = fakedContract.target) === null || _a === void 0 ? void 0 : _a.organizationId) ===
40
- (target === null || target === void 0 ? void 0 : target.organizationId) &&
41
- ((_b = fakedContract.target) === null || _b === void 0 ? void 0 : _b.locationId) ===
42
- (target === null || target === void 0 ? void 0 : target.locationId))));
45
+ (doesOrganizationMatch &&
46
+ doesPersonMatch &&
47
+ doesLocationMatch)));
43
48
  }
44
49
  }
45
50
  return results;
@@ -21,7 +21,7 @@ interface Perm<ContractId extends PermissionContractId> {
21
21
  id: PermissionId<ContractId>;
22
22
  can: boolean;
23
23
  }
24
- export type PermissionContractTarget = SpruceSchemas.Mercury.v2020_12_25.DoesHonorPermissionContractEmitTarget;
24
+ export type PermissionContractTarget = SpruceSchemas.Mercury.v2020_12_25.GetResolvedPermissionsContractEmitTarget;
25
25
  export interface FakePermissionOptions<ContractId extends PermissionContractId = PermissionContractId> {
26
26
  contractId: ContractId;
27
27
  permissions: Perm<ContractId>[];
@@ -23,14 +23,19 @@ class FakeAuthorizer {
23
23
  for (const actual of permissionIds) {
24
24
  const fakedPerm = fakedPermissions.find((p) => p.id === actual);
25
25
  this.assertValidPermission(fakedPerm, actual, fakedContract);
26
+ const doesOrganizationMatch = fakedContract.target?.organizationId ===
27
+ target?.organizationId;
28
+ const doesLocationMatch = fakedContract.target?.locationId === target?.locationId;
29
+ const doesPersonMatch = !fakedContract.target?.contractPersonId ||
30
+ target?.contractPersonId ===
31
+ fakedContract.target?.contractPersonId;
26
32
  results[fakedPerm.id] =
27
33
  results[fakedPerm.id] ||
28
34
  (fakedPerm.can &&
29
35
  (!fakedContract.target ||
30
- (fakedContract.target?.organizationId ===
31
- target?.organizationId &&
32
- fakedContract.target?.locationId ===
33
- target?.locationId)));
36
+ (doesOrganizationMatch &&
37
+ doesPersonMatch &&
38
+ doesLocationMatch)));
34
39
  }
35
40
  }
36
41
  return results;
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "@sprucelabs/spruce-test-fixtures"
14
14
  ]
15
15
  },
16
- "version": "74.1.38",
16
+ "version": "74.1.40",
17
17
  "files": [
18
18
  "build/**/*",
19
19
  "!build/__tests__",
@@ -63,15 +63,15 @@
63
63
  "dependencies": {
64
64
  "@sprucelabs/data-stores": "^30.0.85",
65
65
  "@sprucelabs/error": "^7.1.30",
66
- "@sprucelabs/heartwood-view-controllers": "^126.12.1",
66
+ "@sprucelabs/heartwood-view-controllers": "^126.12.2",
67
67
  "@sprucelabs/mercury-client": "^43.0.155",
68
- "@sprucelabs/mercury-core-events": "^27.4.9",
68
+ "@sprucelabs/mercury-core-events": "^27.4.10",
69
69
  "@sprucelabs/mercury-event-emitter": "^43.0.155",
70
70
  "@sprucelabs/schema": "^32.1.62",
71
71
  "@sprucelabs/spruce-core-schemas": "^41.3.11",
72
72
  "@sprucelabs/spruce-event-utils": "^41.0.130",
73
73
  "@sprucelabs/spruce-permission-utils": "^19.0.87",
74
- "@sprucelabs/spruce-skill-booter": "^74.1.38",
74
+ "@sprucelabs/spruce-skill-booter": "^74.1.40",
75
75
  "@sprucelabs/spruce-skill-utils": "^32.0.123",
76
76
  "@sprucelabs/test-utils": "^6.0.98",
77
77
  "dotenv": "^17.2.3",
@@ -114,5 +114,5 @@
114
114
  "^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
115
115
  }
116
116
  },
117
- "gitHead": "ccf69205e53e781109aa34655bb7faa1f4591ba1"
117
+ "gitHead": "b0c6809b65c8763c4cc65ea9f56593641419c5d9"
118
118
  }