@expo/entity 0.36.0 → 0.38.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/build/EntityFieldDefinition.d.ts +35 -1
- package/build/EntityFieldDefinition.js +29 -1
- package/build/EntityFieldDefinition.js.map +1 -1
- package/build/index.d.ts +26 -21
- package/build/index.js +38 -29
- package/build/index.js.map +1 -1
- package/build/testfixtures/TestEntity.d.ts +4 -4
- package/build/testfixtures/TestEntity.js +4 -4
- package/build/testfixtures/TestEntity.js.map +1 -1
- package/build/utils/EntityPrivacyUtils.js +28 -7
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts +1 -0
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +178 -0
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +1 -0
- package/package.json +3 -3
- package/src/EntityFieldDefinition.ts +38 -1
- package/src/index.ts +26 -21
- package/src/testfixtures/TestEntity.ts +7 -4
- package/src/utils/EntityPrivacyUtils.ts +45 -12
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +254 -0
|
@@ -31,6 +31,33 @@ export declare enum EntityEdgeDeletionBehavior {
|
|
|
31
31
|
*/
|
|
32
32
|
SET_NULL = 3
|
|
33
33
|
}
|
|
34
|
+
export declare enum EntityEdgeDeletionAuthorizationInferenceBehavior {
|
|
35
|
+
/**
|
|
36
|
+
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
37
|
+
* (when SET_NULL_INVALIDATE_CACHE_ONLY or SET_NULL) all entities at the ends of edges of this type
|
|
38
|
+
* cannot be inferred from authorization of any single entity at the end of an edge of this type.
|
|
39
|
+
*
|
|
40
|
+
* To evaluate canViewerDeleteAsync for the source entity, canViewerDeleteAsync must be called on all
|
|
41
|
+
* entities at the ends of all edges of this type.
|
|
42
|
+
*/
|
|
43
|
+
NONE = 0,
|
|
44
|
+
/**
|
|
45
|
+
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
46
|
+
* (when SET_NULL_INVALIDATE_CACHE_ONLY or SET_NULL) all entities at the ends of edges of this type
|
|
47
|
+
* may be inferred from authorization of any single entity at the end of an edge of this type.
|
|
48
|
+
*
|
|
49
|
+
* To evaluate canViewerDeleteAsync for the source entity, canViewerDeleteAsync must only be called on
|
|
50
|
+
* a single entity at the end of one edge of this type chosen at random.
|
|
51
|
+
*
|
|
52
|
+
* This should only be the case when the entity at the other end of this edge can be implicitly
|
|
53
|
+
* deleted/updated by virtue of the source entity deletion being authorized and a single authorization check
|
|
54
|
+
* on one edge of this type.
|
|
55
|
+
*
|
|
56
|
+
* Note that this is not used during actual deletions, only as an optimistic optimization during execution
|
|
57
|
+
* of canViewerDeleteAsync. Each entity being deleted will still check deletion privacy during actual deletion.
|
|
58
|
+
*/
|
|
59
|
+
ONE_IMPLIES_ALL = 1
|
|
60
|
+
}
|
|
34
61
|
/**
|
|
35
62
|
* Defines an association between entities. An association is primarily used to define cascading deletion behavior.
|
|
36
63
|
*/
|
|
@@ -45,7 +72,7 @@ export interface EntityAssociationDefinition<TViewerContext extends ViewerContex
|
|
|
45
72
|
*/
|
|
46
73
|
associatedEntityLookupByField?: keyof TAssociatedFields;
|
|
47
74
|
/**
|
|
48
|
-
* What action to perform on the
|
|
75
|
+
* What action to perform on the entity at the other end of this edge when the entity on the source end of
|
|
49
76
|
* this edge is deleted.
|
|
50
77
|
*
|
|
51
78
|
* @remarks
|
|
@@ -61,6 +88,13 @@ export interface EntityAssociationDefinition<TViewerContext extends ViewerContex
|
|
|
61
88
|
* integrity is recommended.
|
|
62
89
|
*/
|
|
63
90
|
edgeDeletionBehavior: EntityEdgeDeletionBehavior;
|
|
91
|
+
/**
|
|
92
|
+
* Optimization setting for evaluation of this edge in canViewerDeleteAsync. Can be used to optimize permission checks
|
|
93
|
+
* for edge cascading deletions based on application-specific design of the entity association. Not used during actual deletions.
|
|
94
|
+
*
|
|
95
|
+
* Defaults to EntityEdgeDeletionAuthorizationInferenceBehavior.NONE.
|
|
96
|
+
*/
|
|
97
|
+
edgeDeletionAuthorizationInferenceBehavior?: EntityEdgeDeletionAuthorizationInferenceBehavior;
|
|
64
98
|
}
|
|
65
99
|
/**
|
|
66
100
|
* Options for EntityFieldDefinition
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityFieldDefinition = exports.EntityEdgeDeletionBehavior = void 0;
|
|
3
|
+
exports.EntityFieldDefinition = exports.EntityEdgeDeletionAuthorizationInferenceBehavior = exports.EntityEdgeDeletionBehavior = void 0;
|
|
4
4
|
var EntityEdgeDeletionBehavior;
|
|
5
5
|
(function (EntityEdgeDeletionBehavior) {
|
|
6
6
|
/**
|
|
@@ -31,6 +31,34 @@ var EntityEdgeDeletionBehavior;
|
|
|
31
31
|
*/
|
|
32
32
|
EntityEdgeDeletionBehavior[EntityEdgeDeletionBehavior["SET_NULL"] = 3] = "SET_NULL";
|
|
33
33
|
})(EntityEdgeDeletionBehavior || (exports.EntityEdgeDeletionBehavior = EntityEdgeDeletionBehavior = {}));
|
|
34
|
+
var EntityEdgeDeletionAuthorizationInferenceBehavior;
|
|
35
|
+
(function (EntityEdgeDeletionAuthorizationInferenceBehavior) {
|
|
36
|
+
/**
|
|
37
|
+
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
38
|
+
* (when SET_NULL_INVALIDATE_CACHE_ONLY or SET_NULL) all entities at the ends of edges of this type
|
|
39
|
+
* cannot be inferred from authorization of any single entity at the end of an edge of this type.
|
|
40
|
+
*
|
|
41
|
+
* To evaluate canViewerDeleteAsync for the source entity, canViewerDeleteAsync must be called on all
|
|
42
|
+
* entities at the ends of all edges of this type.
|
|
43
|
+
*/
|
|
44
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior[EntityEdgeDeletionAuthorizationInferenceBehavior["NONE"] = 0] = "NONE";
|
|
45
|
+
/**
|
|
46
|
+
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
47
|
+
* (when SET_NULL_INVALIDATE_CACHE_ONLY or SET_NULL) all entities at the ends of edges of this type
|
|
48
|
+
* may be inferred from authorization of any single entity at the end of an edge of this type.
|
|
49
|
+
*
|
|
50
|
+
* To evaluate canViewerDeleteAsync for the source entity, canViewerDeleteAsync must only be called on
|
|
51
|
+
* a single entity at the end of one edge of this type chosen at random.
|
|
52
|
+
*
|
|
53
|
+
* This should only be the case when the entity at the other end of this edge can be implicitly
|
|
54
|
+
* deleted/updated by virtue of the source entity deletion being authorized and a single authorization check
|
|
55
|
+
* on one edge of this type.
|
|
56
|
+
*
|
|
57
|
+
* Note that this is not used during actual deletions, only as an optimistic optimization during execution
|
|
58
|
+
* of canViewerDeleteAsync. Each entity being deleted will still check deletion privacy during actual deletion.
|
|
59
|
+
*/
|
|
60
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior[EntityEdgeDeletionAuthorizationInferenceBehavior["ONE_IMPLIES_ALL"] = 1] = "ONE_IMPLIES_ALL";
|
|
61
|
+
})(EntityEdgeDeletionAuthorizationInferenceBehavior || (exports.EntityEdgeDeletionAuthorizationInferenceBehavior = EntityEdgeDeletionAuthorizationInferenceBehavior = {}));
|
|
34
62
|
/**
|
|
35
63
|
* Definition for a field referencing a column in the underlying database. Specifies things like
|
|
36
64
|
* cache behavior and associations, and handles input validation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFieldDefinition.js","sourceRoot":"","sources":["../src/EntityFieldDefinition.ts"],"names":[],"mappings":";;;AAKA,IAAY,0BA+BX;AA/BD,WAAY,0BAA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;CAEF;AA3BD,sDA2BC"}
|
package/build/index.d.ts
CHANGED
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module @expo/entity
|
|
4
4
|
*/
|
|
5
|
+
export { default as AuthorizationResultBasedEntityLoader } from './AuthorizationResultBasedEntityLoader';
|
|
5
6
|
export { default as ComposedEntityCacheAdapter } from './ComposedEntityCacheAdapter';
|
|
6
7
|
export { default as ComposedSecondaryEntityCache } from './ComposedSecondaryEntityCache';
|
|
7
|
-
export { default as GenericSecondaryEntityCache } from './GenericSecondaryEntityCache';
|
|
8
8
|
export { default as EnforcingEntityLoader } from './EnforcingEntityLoader';
|
|
9
9
|
export { default as Entity } from './Entity';
|
|
10
10
|
export * from './Entity';
|
|
11
11
|
export { default as EntityAssociationLoader } from './EntityAssociationLoader';
|
|
12
12
|
export * from './EntityAssociationLoader';
|
|
13
|
-
export { default as IEntityCacheAdapter } from './IEntityCacheAdapter';
|
|
14
|
-
export { default as GenericEntityCacheAdapter } from './GenericEntityCacheAdapter';
|
|
15
13
|
export { default as EntityCompanion } from './EntityCompanion';
|
|
16
14
|
export * from './EntityCompanion';
|
|
17
15
|
export { default as EntityCompanionProvider } from './EntityCompanionProvider';
|
|
@@ -19,32 +17,28 @@ export * from './EntityCompanionProvider';
|
|
|
19
17
|
export { default as EntityConfiguration } from './EntityConfiguration';
|
|
20
18
|
export { default as EntityDatabaseAdapter } from './EntityDatabaseAdapter';
|
|
21
19
|
export * from './EntityDatabaseAdapter';
|
|
22
|
-
export { default as EntityDatabaseAdapterError } from './errors/EntityDatabaseAdapterError';
|
|
23
|
-
export * from './errors/EntityDatabaseAdapterError';
|
|
24
|
-
export { default as EntityCacheAdapterError } from './errors/EntityCacheAdapterError';
|
|
25
|
-
export * from './errors/EntityCacheAdapterError';
|
|
26
|
-
export * from './errors/EntityError';
|
|
27
|
-
export { default as EntityError } from './errors/EntityError';
|
|
28
|
-
export { default as EntityNotAuthorizedError } from './errors/EntityNotAuthorizedError';
|
|
29
|
-
export { default as EntityNotFoundError } from './errors/EntityNotFoundError';
|
|
30
|
-
export * from './EntityFields';
|
|
31
20
|
export * from './EntityFieldDefinition';
|
|
21
|
+
export * from './EntityFields';
|
|
32
22
|
export { default as EntityLoader } from './EntityLoader';
|
|
33
23
|
export { default as EntityLoaderFactory } from './EntityLoaderFactory';
|
|
34
|
-
export { default as
|
|
35
|
-
export * from './EntitySecondaryCacheLoader';
|
|
36
|
-
export * from './EntityMutator';
|
|
37
|
-
export { default as EntityMutationValidator } from './EntityMutationValidator';
|
|
24
|
+
export { default as EntityLoaderUtils } from './EntityLoaderUtils';
|
|
38
25
|
export * from './EntityMutationInfo';
|
|
39
|
-
export * from './EntityMutationTriggerConfiguration';
|
|
40
26
|
export { default as EntityMutationTriggerConfiguration } from './EntityMutationTriggerConfiguration';
|
|
27
|
+
export * from './EntityMutationTriggerConfiguration';
|
|
28
|
+
export { default as EntityMutationValidator } from './EntityMutationValidator';
|
|
29
|
+
export * from './EntityMutator';
|
|
41
30
|
export { default as EntityMutatorFactory } from './EntityMutatorFactory';
|
|
42
31
|
export { default as EntityPrivacyPolicy } from './EntityPrivacyPolicy';
|
|
43
32
|
export * from './EntityPrivacyPolicy';
|
|
44
33
|
export * from './EntityQueryContext';
|
|
34
|
+
export { default as EntityQueryContextProvider } from './EntityQueryContextProvider';
|
|
35
|
+
export { default as EntitySecondaryCacheLoader } from './EntitySecondaryCacheLoader';
|
|
36
|
+
export * from './EntitySecondaryCacheLoader';
|
|
37
|
+
export { default as GenericEntityCacheAdapter } from './GenericEntityCacheAdapter';
|
|
38
|
+
export { default as GenericSecondaryEntityCache } from './GenericSecondaryEntityCache';
|
|
39
|
+
export { default as IEntityCacheAdapter } from './IEntityCacheAdapter';
|
|
45
40
|
export { default as IEntityCacheAdapterProvider } from './IEntityCacheAdapterProvider';
|
|
46
41
|
export { default as IEntityDatabaseAdapterProvider } from './IEntityDatabaseAdapterProvider';
|
|
47
|
-
export { default as EntityQueryContextProvider } from './EntityQueryContextProvider';
|
|
48
42
|
export { default as IEntityGenericCacher } from './IEntityGenericCacher';
|
|
49
43
|
export { default as ReadonlyEntity } from './ReadonlyEntity';
|
|
50
44
|
export { default as ViewerContext } from './ViewerContext';
|
|
@@ -53,8 +47,18 @@ export { default as ViewerScopedEntityCompanionProvider } from './ViewerScopedEn
|
|
|
53
47
|
export { default as ViewerScopedEntityLoaderFactory } from './ViewerScopedEntityLoaderFactory';
|
|
54
48
|
export { default as ViewerScopedEntityMutatorFactory } from './ViewerScopedEntityMutatorFactory';
|
|
55
49
|
export * from './entityUtils';
|
|
50
|
+
export { default as EntityCacheAdapterError } from './errors/EntityCacheAdapterError';
|
|
51
|
+
export * from './errors/EntityCacheAdapterError';
|
|
52
|
+
export { default as EntityDatabaseAdapterError } from './errors/EntityDatabaseAdapterError';
|
|
53
|
+
export * from './errors/EntityDatabaseAdapterError';
|
|
54
|
+
export { default as EntityError } from './errors/EntityError';
|
|
55
|
+
export * from './errors/EntityError';
|
|
56
|
+
export { default as EntityInvalidFieldValueError } from './errors/EntityInvalidFieldValueError';
|
|
57
|
+
export { default as EntityNotAuthorizedError } from './errors/EntityNotAuthorizedError';
|
|
58
|
+
export { default as EntityNotFoundError } from './errors/EntityNotFoundError';
|
|
56
59
|
export { default as EntityDataManager } from './internal/EntityDataManager';
|
|
57
60
|
export * from './internal/EntityFieldTransformationUtils';
|
|
61
|
+
export { default as EntityTableDataCoordinator } from './internal/EntityTableDataCoordinator';
|
|
58
62
|
export { default as ReadThroughEntityCache } from './internal/ReadThroughEntityCache';
|
|
59
63
|
export * from './internal/ReadThroughEntityCache';
|
|
60
64
|
export * from './metrics/EntityMetricsUtils';
|
|
@@ -66,12 +70,13 @@ export { default as AlwaysDenyPrivacyPolicyRule } from './rules/AlwaysDenyPrivac
|
|
|
66
70
|
export { default as AlwaysSkipPrivacyPolicyRule } from './rules/AlwaysSkipPrivacyPolicyRule';
|
|
67
71
|
export { default as PrivacyPolicyRule } from './rules/PrivacyPolicyRule';
|
|
68
72
|
export * from './rules/PrivacyPolicyRule';
|
|
73
|
+
export * from './utils/EntityPrivacyUtils';
|
|
74
|
+
export * from './utils/mergeEntityMutationTriggerConfigurations';
|
|
75
|
+
export * from './utils/collections/maps';
|
|
69
76
|
export * from './utils/testing/PrivacyPolicyRuleTestUtils';
|
|
70
77
|
export * from './utils/testing/StubCacheAdapter';
|
|
71
|
-
export { default as describeFieldTestCase } from './utils/testing/describeFieldTestCase';
|
|
72
78
|
export { default as StubDatabaseAdapter } from './utils/testing/StubDatabaseAdapter';
|
|
73
79
|
export { default as StubDatabaseAdapterProvider } from './utils/testing/StubDatabaseAdapterProvider';
|
|
74
80
|
export { default as StubQueryContextProvider } from './utils/testing/StubQueryContextProvider';
|
|
75
81
|
export * from './utils/testing/createUnitTestEntityCompanionProvider';
|
|
76
|
-
export
|
|
77
|
-
export * from './utils/EntityPrivacyUtils';
|
|
82
|
+
export { default as describeFieldTestCase } from './utils/testing/describeFieldTestCase';
|
package/build/index.js
CHANGED
|
@@ -22,13 +22,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.describeFieldTestCase = exports.StubQueryContextProvider = exports.StubDatabaseAdapterProvider = exports.StubDatabaseAdapter = exports.PrivacyPolicyRule = exports.AlwaysSkipPrivacyPolicyRule = exports.AlwaysDenyPrivacyPolicyRule = exports.AlwaysAllowPrivacyPolicyRule = exports.NoOpEntityMetricsAdapter = exports.ReadThroughEntityCache = exports.EntityTableDataCoordinator = exports.EntityDataManager = exports.EntityNotFoundError = exports.EntityNotAuthorizedError = exports.EntityInvalidFieldValueError = exports.EntityError = exports.EntityDatabaseAdapterError = exports.EntityCacheAdapterError = exports.ViewerScopedEntityMutatorFactory = exports.ViewerScopedEntityLoaderFactory = exports.ViewerScopedEntityCompanionProvider = exports.ViewerScopedEntityCompanion = exports.ViewerContext = exports.ReadonlyEntity = exports.GenericSecondaryEntityCache = exports.GenericEntityCacheAdapter = exports.EntitySecondaryCacheLoader = exports.EntityQueryContextProvider = exports.EntityPrivacyPolicy = exports.EntityMutatorFactory = exports.EntityMutationValidator = exports.EntityLoaderUtils = exports.EntityLoaderFactory = exports.EntityLoader = exports.EntityDatabaseAdapter = exports.EntityConfiguration = exports.EntityCompanionProvider = exports.EntityCompanion = exports.EntityAssociationLoader = exports.Entity = exports.EnforcingEntityLoader = exports.ComposedSecondaryEntityCache = exports.ComposedEntityCacheAdapter = exports.AuthorizationResultBasedEntityLoader = void 0;
|
|
26
|
+
var AuthorizationResultBasedEntityLoader_1 = require("./AuthorizationResultBasedEntityLoader");
|
|
27
|
+
Object.defineProperty(exports, "AuthorizationResultBasedEntityLoader", { enumerable: true, get: function () { return __importDefault(AuthorizationResultBasedEntityLoader_1).default; } });
|
|
26
28
|
var ComposedEntityCacheAdapter_1 = require("./ComposedEntityCacheAdapter");
|
|
27
29
|
Object.defineProperty(exports, "ComposedEntityCacheAdapter", { enumerable: true, get: function () { return __importDefault(ComposedEntityCacheAdapter_1).default; } });
|
|
28
30
|
var ComposedSecondaryEntityCache_1 = require("./ComposedSecondaryEntityCache");
|
|
29
31
|
Object.defineProperty(exports, "ComposedSecondaryEntityCache", { enumerable: true, get: function () { return __importDefault(ComposedSecondaryEntityCache_1).default; } });
|
|
30
|
-
var GenericSecondaryEntityCache_1 = require("./GenericSecondaryEntityCache");
|
|
31
|
-
Object.defineProperty(exports, "GenericSecondaryEntityCache", { enumerable: true, get: function () { return __importDefault(GenericSecondaryEntityCache_1).default; } });
|
|
32
32
|
var EnforcingEntityLoader_1 = require("./EnforcingEntityLoader");
|
|
33
33
|
Object.defineProperty(exports, "EnforcingEntityLoader", { enumerable: true, get: function () { return __importDefault(EnforcingEntityLoader_1).default; } });
|
|
34
34
|
var Entity_1 = require("./Entity");
|
|
@@ -37,8 +37,6 @@ __exportStar(require("./Entity"), exports);
|
|
|
37
37
|
var EntityAssociationLoader_1 = require("./EntityAssociationLoader");
|
|
38
38
|
Object.defineProperty(exports, "EntityAssociationLoader", { enumerable: true, get: function () { return __importDefault(EntityAssociationLoader_1).default; } });
|
|
39
39
|
__exportStar(require("./EntityAssociationLoader"), exports);
|
|
40
|
-
var GenericEntityCacheAdapter_1 = require("./GenericEntityCacheAdapter");
|
|
41
|
-
Object.defineProperty(exports, "GenericEntityCacheAdapter", { enumerable: true, get: function () { return __importDefault(GenericEntityCacheAdapter_1).default; } });
|
|
42
40
|
var EntityCompanion_1 = require("./EntityCompanion");
|
|
43
41
|
Object.defineProperty(exports, "EntityCompanion", { enumerable: true, get: function () { return __importDefault(EntityCompanion_1).default; } });
|
|
44
42
|
__exportStar(require("./EntityCompanion"), exports);
|
|
@@ -50,33 +48,19 @@ Object.defineProperty(exports, "EntityConfiguration", { enumerable: true, get: f
|
|
|
50
48
|
var EntityDatabaseAdapter_1 = require("./EntityDatabaseAdapter");
|
|
51
49
|
Object.defineProperty(exports, "EntityDatabaseAdapter", { enumerable: true, get: function () { return __importDefault(EntityDatabaseAdapter_1).default; } });
|
|
52
50
|
__exportStar(require("./EntityDatabaseAdapter"), exports);
|
|
53
|
-
var EntityDatabaseAdapterError_1 = require("./errors/EntityDatabaseAdapterError");
|
|
54
|
-
Object.defineProperty(exports, "EntityDatabaseAdapterError", { enumerable: true, get: function () { return __importDefault(EntityDatabaseAdapterError_1).default; } });
|
|
55
|
-
__exportStar(require("./errors/EntityDatabaseAdapterError"), exports);
|
|
56
|
-
var EntityCacheAdapterError_1 = require("./errors/EntityCacheAdapterError");
|
|
57
|
-
Object.defineProperty(exports, "EntityCacheAdapterError", { enumerable: true, get: function () { return __importDefault(EntityCacheAdapterError_1).default; } });
|
|
58
|
-
__exportStar(require("./errors/EntityCacheAdapterError"), exports);
|
|
59
|
-
__exportStar(require("./errors/EntityError"), exports);
|
|
60
|
-
var EntityError_1 = require("./errors/EntityError");
|
|
61
|
-
Object.defineProperty(exports, "EntityError", { enumerable: true, get: function () { return __importDefault(EntityError_1).default; } });
|
|
62
|
-
var EntityNotAuthorizedError_1 = require("./errors/EntityNotAuthorizedError");
|
|
63
|
-
Object.defineProperty(exports, "EntityNotAuthorizedError", { enumerable: true, get: function () { return __importDefault(EntityNotAuthorizedError_1).default; } });
|
|
64
|
-
var EntityNotFoundError_1 = require("./errors/EntityNotFoundError");
|
|
65
|
-
Object.defineProperty(exports, "EntityNotFoundError", { enumerable: true, get: function () { return __importDefault(EntityNotFoundError_1).default; } });
|
|
66
|
-
__exportStar(require("./EntityFields"), exports);
|
|
67
51
|
__exportStar(require("./EntityFieldDefinition"), exports);
|
|
52
|
+
__exportStar(require("./EntityFields"), exports);
|
|
68
53
|
var EntityLoader_1 = require("./EntityLoader");
|
|
69
54
|
Object.defineProperty(exports, "EntityLoader", { enumerable: true, get: function () { return __importDefault(EntityLoader_1).default; } });
|
|
70
55
|
var EntityLoaderFactory_1 = require("./EntityLoaderFactory");
|
|
71
56
|
Object.defineProperty(exports, "EntityLoaderFactory", { enumerable: true, get: function () { return __importDefault(EntityLoaderFactory_1).default; } });
|
|
72
|
-
var
|
|
73
|
-
Object.defineProperty(exports, "
|
|
74
|
-
__exportStar(require("./EntitySecondaryCacheLoader"), exports);
|
|
75
|
-
__exportStar(require("./EntityMutator"), exports);
|
|
76
|
-
var EntityMutationValidator_1 = require("./EntityMutationValidator");
|
|
77
|
-
Object.defineProperty(exports, "EntityMutationValidator", { enumerable: true, get: function () { return __importDefault(EntityMutationValidator_1).default; } });
|
|
57
|
+
var EntityLoaderUtils_1 = require("./EntityLoaderUtils");
|
|
58
|
+
Object.defineProperty(exports, "EntityLoaderUtils", { enumerable: true, get: function () { return __importDefault(EntityLoaderUtils_1).default; } });
|
|
78
59
|
__exportStar(require("./EntityMutationInfo"), exports);
|
|
79
60
|
__exportStar(require("./EntityMutationTriggerConfiguration"), exports);
|
|
61
|
+
var EntityMutationValidator_1 = require("./EntityMutationValidator");
|
|
62
|
+
Object.defineProperty(exports, "EntityMutationValidator", { enumerable: true, get: function () { return __importDefault(EntityMutationValidator_1).default; } });
|
|
63
|
+
__exportStar(require("./EntityMutator"), exports);
|
|
80
64
|
var EntityMutatorFactory_1 = require("./EntityMutatorFactory");
|
|
81
65
|
Object.defineProperty(exports, "EntityMutatorFactory", { enumerable: true, get: function () { return __importDefault(EntityMutatorFactory_1).default; } });
|
|
82
66
|
var EntityPrivacyPolicy_1 = require("./EntityPrivacyPolicy");
|
|
@@ -85,6 +69,13 @@ __exportStar(require("./EntityPrivacyPolicy"), exports);
|
|
|
85
69
|
__exportStar(require("./EntityQueryContext"), exports);
|
|
86
70
|
var EntityQueryContextProvider_1 = require("./EntityQueryContextProvider");
|
|
87
71
|
Object.defineProperty(exports, "EntityQueryContextProvider", { enumerable: true, get: function () { return __importDefault(EntityQueryContextProvider_1).default; } });
|
|
72
|
+
var EntitySecondaryCacheLoader_1 = require("./EntitySecondaryCacheLoader");
|
|
73
|
+
Object.defineProperty(exports, "EntitySecondaryCacheLoader", { enumerable: true, get: function () { return __importDefault(EntitySecondaryCacheLoader_1).default; } });
|
|
74
|
+
__exportStar(require("./EntitySecondaryCacheLoader"), exports);
|
|
75
|
+
var GenericEntityCacheAdapter_1 = require("./GenericEntityCacheAdapter");
|
|
76
|
+
Object.defineProperty(exports, "GenericEntityCacheAdapter", { enumerable: true, get: function () { return __importDefault(GenericEntityCacheAdapter_1).default; } });
|
|
77
|
+
var GenericSecondaryEntityCache_1 = require("./GenericSecondaryEntityCache");
|
|
78
|
+
Object.defineProperty(exports, "GenericSecondaryEntityCache", { enumerable: true, get: function () { return __importDefault(GenericSecondaryEntityCache_1).default; } });
|
|
88
79
|
var ReadonlyEntity_1 = require("./ReadonlyEntity");
|
|
89
80
|
Object.defineProperty(exports, "ReadonlyEntity", { enumerable: true, get: function () { return __importDefault(ReadonlyEntity_1).default; } });
|
|
90
81
|
var ViewerContext_1 = require("./ViewerContext");
|
|
@@ -98,9 +89,26 @@ Object.defineProperty(exports, "ViewerScopedEntityLoaderFactory", { enumerable:
|
|
|
98
89
|
var ViewerScopedEntityMutatorFactory_1 = require("./ViewerScopedEntityMutatorFactory");
|
|
99
90
|
Object.defineProperty(exports, "ViewerScopedEntityMutatorFactory", { enumerable: true, get: function () { return __importDefault(ViewerScopedEntityMutatorFactory_1).default; } });
|
|
100
91
|
__exportStar(require("./entityUtils"), exports);
|
|
92
|
+
var EntityCacheAdapterError_1 = require("./errors/EntityCacheAdapterError");
|
|
93
|
+
Object.defineProperty(exports, "EntityCacheAdapterError", { enumerable: true, get: function () { return __importDefault(EntityCacheAdapterError_1).default; } });
|
|
94
|
+
__exportStar(require("./errors/EntityCacheAdapterError"), exports);
|
|
95
|
+
var EntityDatabaseAdapterError_1 = require("./errors/EntityDatabaseAdapterError");
|
|
96
|
+
Object.defineProperty(exports, "EntityDatabaseAdapterError", { enumerable: true, get: function () { return __importDefault(EntityDatabaseAdapterError_1).default; } });
|
|
97
|
+
__exportStar(require("./errors/EntityDatabaseAdapterError"), exports);
|
|
98
|
+
var EntityError_1 = require("./errors/EntityError");
|
|
99
|
+
Object.defineProperty(exports, "EntityError", { enumerable: true, get: function () { return __importDefault(EntityError_1).default; } });
|
|
100
|
+
__exportStar(require("./errors/EntityError"), exports);
|
|
101
|
+
var EntityInvalidFieldValueError_1 = require("./errors/EntityInvalidFieldValueError");
|
|
102
|
+
Object.defineProperty(exports, "EntityInvalidFieldValueError", { enumerable: true, get: function () { return __importDefault(EntityInvalidFieldValueError_1).default; } });
|
|
103
|
+
var EntityNotAuthorizedError_1 = require("./errors/EntityNotAuthorizedError");
|
|
104
|
+
Object.defineProperty(exports, "EntityNotAuthorizedError", { enumerable: true, get: function () { return __importDefault(EntityNotAuthorizedError_1).default; } });
|
|
105
|
+
var EntityNotFoundError_1 = require("./errors/EntityNotFoundError");
|
|
106
|
+
Object.defineProperty(exports, "EntityNotFoundError", { enumerable: true, get: function () { return __importDefault(EntityNotFoundError_1).default; } });
|
|
101
107
|
var EntityDataManager_1 = require("./internal/EntityDataManager");
|
|
102
108
|
Object.defineProperty(exports, "EntityDataManager", { enumerable: true, get: function () { return __importDefault(EntityDataManager_1).default; } });
|
|
103
109
|
__exportStar(require("./internal/EntityFieldTransformationUtils"), exports);
|
|
110
|
+
var EntityTableDataCoordinator_1 = require("./internal/EntityTableDataCoordinator");
|
|
111
|
+
Object.defineProperty(exports, "EntityTableDataCoordinator", { enumerable: true, get: function () { return __importDefault(EntityTableDataCoordinator_1).default; } });
|
|
104
112
|
var ReadThroughEntityCache_1 = require("./internal/ReadThroughEntityCache");
|
|
105
113
|
Object.defineProperty(exports, "ReadThroughEntityCache", { enumerable: true, get: function () { return __importDefault(ReadThroughEntityCache_1).default; } });
|
|
106
114
|
__exportStar(require("./internal/ReadThroughEntityCache"), exports);
|
|
@@ -117,10 +125,11 @@ Object.defineProperty(exports, "AlwaysSkipPrivacyPolicyRule", { enumerable: true
|
|
|
117
125
|
var PrivacyPolicyRule_1 = require("./rules/PrivacyPolicyRule");
|
|
118
126
|
Object.defineProperty(exports, "PrivacyPolicyRule", { enumerable: true, get: function () { return __importDefault(PrivacyPolicyRule_1).default; } });
|
|
119
127
|
__exportStar(require("./rules/PrivacyPolicyRule"), exports);
|
|
128
|
+
__exportStar(require("./utils/EntityPrivacyUtils"), exports);
|
|
129
|
+
__exportStar(require("./utils/mergeEntityMutationTriggerConfigurations"), exports);
|
|
130
|
+
__exportStar(require("./utils/collections/maps"), exports);
|
|
120
131
|
__exportStar(require("./utils/testing/PrivacyPolicyRuleTestUtils"), exports);
|
|
121
132
|
__exportStar(require("./utils/testing/StubCacheAdapter"), exports);
|
|
122
|
-
var describeFieldTestCase_1 = require("./utils/testing/describeFieldTestCase");
|
|
123
|
-
Object.defineProperty(exports, "describeFieldTestCase", { enumerable: true, get: function () { return __importDefault(describeFieldTestCase_1).default; } });
|
|
124
133
|
var StubDatabaseAdapter_1 = require("./utils/testing/StubDatabaseAdapter");
|
|
125
134
|
Object.defineProperty(exports, "StubDatabaseAdapter", { enumerable: true, get: function () { return __importDefault(StubDatabaseAdapter_1).default; } });
|
|
126
135
|
var StubDatabaseAdapterProvider_1 = require("./utils/testing/StubDatabaseAdapterProvider");
|
|
@@ -128,6 +137,6 @@ Object.defineProperty(exports, "StubDatabaseAdapterProvider", { enumerable: true
|
|
|
128
137
|
var StubQueryContextProvider_1 = require("./utils/testing/StubQueryContextProvider");
|
|
129
138
|
Object.defineProperty(exports, "StubQueryContextProvider", { enumerable: true, get: function () { return __importDefault(StubQueryContextProvider_1).default; } });
|
|
130
139
|
__exportStar(require("./utils/testing/createUnitTestEntityCompanionProvider"), exports);
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
var describeFieldTestCase_1 = require("./utils/testing/describeFieldTestCase");
|
|
141
|
+
Object.defineProperty(exports, "describeFieldTestCase", { enumerable: true, get: function () { return __importDefault(describeFieldTestCase_1).default; } });
|
|
133
142
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC;;;GAGG;;;;;;;;;;;;;;;;;;;;AAEH,2EAAqF;AAA5E,yJAAA,OAAO,OAA8B;AAC9C,+EAAyF;AAAhF,6JAAA,OAAO,OAAgC;AAChD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC;;;GAGG;;;;;;;;;;;;;;;;;;;;AAEH,+FAAyG;AAAhG,6KAAA,OAAO,OAAwC;AACxD,2EAAqF;AAA5E,yJAAA,OAAO,OAA8B;AAC9C,+EAAyF;AAAhF,6JAAA,OAAO,OAAgC;AAChD,iEAA2E;AAAlE,+IAAA,OAAO,OAAyB;AACzC,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,2CA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A,OAAO,OAAe;AAC/B,uDAAqC;AACrC,sFAAgG;AAAvF,6JAAA,OAAO,OAAgC;AAChD,8EAAwF;AAA/E,qJAAA,OAAO,OAA4B;AAC5C,oEAA8E;AAArE,2IAAA,OAAO,OAAuB;AACvC,kEAA4E;AAAnE,uIAAA,OAAO,OAAqB;AACrC,4EAA0D;AAC1D,oFAA8F;AAArF,yJAAA,OAAO,OAA8B;AAC9C,4EAAsF;AAA7E,iJAAA,OAAO,OAA0B;AAC1C,oEAAkD;AAClD,+DAA6C;AAE7C,kEAAgD;AAChD,+EAAyF;AAAhF,qJAAA,OAAO,OAA4B;AAC5C,qFAA+F;AAAtF,6JAAA,OAAO,OAAgC;AAChD,mFAA6F;AAApF,2JAAA,OAAO,OAA+B;AAC/C,mFAA6F;AAApF,2JAAA,OAAO,OAA+B;AAC/C,+DAAyE;AAAhE,uIAAA,OAAO,OAAqB;AACrC,4DAA0C;AAC1C,6DAA2C;AAC3C,mFAAiE;AACjE,2DAAyC;AACzC,6EAA2D;AAC3D,mEAAiD;AACjD,2EAAqF;AAA5E,2IAAA,OAAO,OAAuB;AACvC,2FAAqG;AAA5F,2JAAA,OAAO,OAA+B;AAC/C,qFAA+F;AAAtF,qJAAA,OAAO,OAA4B;AAC5C,wFAAsE;AACtE,+EAAyF;AAAhF,+IAAA,OAAO,OAAyB"}
|
|
@@ -23,8 +23,8 @@ export declare class TestEntityPrivacyPolicy extends EntityPrivacyPolicy<TestFie
|
|
|
23
23
|
export default class TestEntity extends Entity<TestFields, string, ViewerContext> {
|
|
24
24
|
static defineCompanionDefinition(): EntityCompanionDefinition<TestFields, string, ViewerContext, TestEntity, TestEntityPrivacyPolicy>;
|
|
25
25
|
getBlah(): string;
|
|
26
|
-
static
|
|
27
|
-
static
|
|
28
|
-
static
|
|
29
|
-
static
|
|
26
|
+
static helloAsync(viewerContext: ViewerContext, testValue: string): Promise<Result<TestEntity>>;
|
|
27
|
+
static returnErrorAsync(_viewerContext: ViewerContext): Promise<Result<TestEntity>>;
|
|
28
|
+
static throwErrorAsync(_viewerContext: ViewerContext): Promise<Result<TestEntity>>;
|
|
29
|
+
static nonResultAsync(_viewerContext: ViewerContext, testValue: string): Promise<string>;
|
|
30
30
|
}
|
|
@@ -63,7 +63,7 @@ class TestEntity extends Entity_1.default {
|
|
|
63
63
|
getBlah() {
|
|
64
64
|
return 'Hello World!';
|
|
65
65
|
}
|
|
66
|
-
static async
|
|
66
|
+
static async helloAsync(viewerContext, testValue) {
|
|
67
67
|
const fields = {
|
|
68
68
|
customIdField: testValue,
|
|
69
69
|
testIndexedField: 'hello',
|
|
@@ -79,13 +79,13 @@ class TestEntity extends Entity_1.default {
|
|
|
79
79
|
selectedFields: fields,
|
|
80
80
|
}));
|
|
81
81
|
}
|
|
82
|
-
static async
|
|
82
|
+
static async returnErrorAsync(_viewerContext) {
|
|
83
83
|
return (0, results_1.result)(new Error('return entity'));
|
|
84
84
|
}
|
|
85
|
-
static async
|
|
85
|
+
static async throwErrorAsync(_viewerContext) {
|
|
86
86
|
throw new Error('threw entity');
|
|
87
87
|
}
|
|
88
|
-
static async
|
|
88
|
+
static async nonResultAsync(_viewerContext, testValue) {
|
|
89
89
|
return testValue;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestEntity.js","sourceRoot":"","sources":["../../src/testfixtures/TestEntity.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA+C;AAE/C,uDAA+B;AAE/B,iFAAyD;AACzD,kDAA8E;AAC9E,iFAAyD;AAEzD,yGAAiF;AAWpE,QAAA,uBAAuB,GAAG,IAAI,6BAAmB,CAAa;IACzE,OAAO,EAAE,eAAe;IACxB,SAAS,EAAE,oCAAoC;IAC/C,MAAM,EAAE;QACN,aAAa,EAAE,IAAI,wBAAS,CAAC;YAC3B,UAAU,EAAE,WAAW;SACxB,CAAC;QACF,gBAAgB,EAAE,IAAI,0BAAW,CAAC;YAChC,UAAU,EAAE,YAAY;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AO;YACzB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,aAAa,EAAE,IAAI;SACpB,CAAC;QACF,OAAO,IAAA,gBAAM,EACX,IAAI,UAAU,CAAC;YACb,aAAa;YACb,EAAE,EAAE,SAAS;YACb,cAAc,EAAE,MAAM;YACtB,cAAc,EAAE,MAAM;SACvB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,cAA6B;QACzD,OAAO,IAAA,gBAAM,EAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,cAA6B;QACxD,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,cAA6B,EAAE,SAAiB;QAC1E,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AApDD,6BAoDC"}
|
|
@@ -119,12 +119,33 @@ async function canViewerDeleteInternalAsync(entityClass, sourceEntity, cascading
|
|
|
119
119
|
if (associatedConfiguration !== entityConfiguration) {
|
|
120
120
|
continue;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
const edgeDeletionPermissionInferenceBehavior = association.edgeDeletionAuthorizationInferenceBehavior;
|
|
123
|
+
let entityResultsToCheckForInboundEdge;
|
|
124
|
+
if (edgeDeletionPermissionInferenceBehavior ===
|
|
125
|
+
EntityFieldDefinition_1.EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL) {
|
|
126
|
+
const singleEntityToTestForInboundEdge = await loader
|
|
127
|
+
.withAuthorizationResults()
|
|
128
|
+
.loadFirstByFieldEqualityConjunctionAsync([
|
|
129
|
+
{
|
|
130
|
+
fieldName,
|
|
131
|
+
fieldValue: association.associatedEntityLookupByField
|
|
132
|
+
? sourceEntity.getField(association.associatedEntityLookupByField)
|
|
133
|
+
: sourceEntity.getID(),
|
|
134
|
+
},
|
|
135
|
+
], { orderBy: [] });
|
|
136
|
+
entityResultsToCheckForInboundEdge = singleEntityToTestForInboundEdge
|
|
137
|
+
? [singleEntityToTestForInboundEdge]
|
|
138
|
+
: [];
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const entityResultsForInboundEdge = await loader
|
|
142
|
+
.withAuthorizationResults()
|
|
143
|
+
.loadManyByFieldEqualingAsync(fieldName, association.associatedEntityLookupByField
|
|
144
|
+
? sourceEntity.getField(association.associatedEntityLookupByField)
|
|
145
|
+
: sourceEntity.getID());
|
|
146
|
+
entityResultsToCheckForInboundEdge = entityResultsForInboundEdge;
|
|
147
|
+
}
|
|
148
|
+
const failedEntityLoadResults = (0, entityUtils_1.failedResults)(entityResultsToCheckForInboundEdge);
|
|
128
149
|
for (const failedResult of failedEntityLoadResults) {
|
|
129
150
|
if (failedResult.reason instanceof EntityNotAuthorizedError_1.default) {
|
|
130
151
|
return false;
|
|
@@ -134,7 +155,7 @@ async function canViewerDeleteInternalAsync(entityClass, sourceEntity, cascading
|
|
|
134
155
|
}
|
|
135
156
|
}
|
|
136
157
|
// all results should be success at this point due to check above
|
|
137
|
-
const entitiesForInboundEdge =
|
|
158
|
+
const entitiesForInboundEdge = entityResultsToCheckForInboundEdge.map((r) => r.enforceValue());
|
|
138
159
|
switch (association.edgeDeletionBehavior) {
|
|
139
160
|
case EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE:
|
|
140
161
|
case EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE_ONLY: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityPrivacyUtils.js","sourceRoot":"","sources":["../../src/utils/EntityPrivacyUtils.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
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AC1B,WAAW,EACX,MAAM,EACN,uBAAuB,EACvB,YAAY,CACb,CACF,CACF,CACF,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;oBAElB,IAAI,CAAC,YAAY,EAAE,CAAC;wBAClB,OAAO,KAAK,CAAC;oBACf,CAAC;oBACD,MAAM;gBACR,CAAC;gBAED,KAAK,kDAA0B,CAAC,QAAQ,CAAC;gBACzC,KAAK,kDAA0B,CAAC,8BAA8B,CAAC,CAAC,CAAC;oBAC/D,MAAM,YAAY,GAAG,CACnB,MAAM,OAAO,CAAC,GAAG,CACf,sBAAsB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACpC,4BAA4B,CAC1B,WAAW,EACX,MAAM,EACN,uBAAuB,EACvB,YAAY,CACb,CACF,CACF,CACF,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;oBAElB,IAAI,CAAC,YAAY,EAAE,CAAC;wBAClB,OAAO,KAAK,CAAC;oBACf,CAAC;oBACD,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Entity_1 = __importDefault(require("../../Entity"));
|
|
7
|
+
const EntityConfiguration_1 = __importDefault(require("../../EntityConfiguration"));
|
|
8
|
+
const EntityFieldDefinition_1 = require("../../EntityFieldDefinition");
|
|
9
|
+
const EntityFields_1 = require("../../EntityFields");
|
|
10
|
+
const EntityPrivacyPolicy_1 = __importDefault(require("../../EntityPrivacyPolicy"));
|
|
11
|
+
const ViewerContext_1 = __importDefault(require("../../ViewerContext"));
|
|
12
|
+
const AlwaysAllowPrivacyPolicyRule_1 = __importDefault(require("../../rules/AlwaysAllowPrivacyPolicyRule"));
|
|
13
|
+
const AlwaysDenyPrivacyPolicyRule_1 = __importDefault(require("../../rules/AlwaysDenyPrivacyPolicyRule"));
|
|
14
|
+
const EntityPrivacyUtils_1 = require("../EntityPrivacyUtils");
|
|
15
|
+
const createUnitTestEntityCompanionProvider_1 = require("../testing/createUnitTestEntityCompanionProvider");
|
|
16
|
+
describe(EntityPrivacyUtils_1.canViewerDeleteAsync, () => {
|
|
17
|
+
describe('edgeDeletionPermissionInferenceBehavior', () => {
|
|
18
|
+
it('optimizes when EntityEdgeDeletionPermissionInferenceBehavior.ONE_IMPLIES_ALL', async () => {
|
|
19
|
+
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
20
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
21
|
+
// create root
|
|
22
|
+
const testEntity = await TestEntity.creator(viewerContext).enforceCreateAsync();
|
|
23
|
+
// create a bunch of leaves referencing root with
|
|
24
|
+
// edgeDeletionPermissionInferenceBehavior = EntityEdgeDeletionPermissionInferenceBehavior.ONE_IMPLIES_ALL
|
|
25
|
+
for (let i = 0; i < 10; i++) {
|
|
26
|
+
await TestLeafEntity.creator(viewerContext)
|
|
27
|
+
.setField('test_entity_id', testEntity.getID())
|
|
28
|
+
.enforceCreateAsync();
|
|
29
|
+
}
|
|
30
|
+
for (let i = 0; i < 10; i++) {
|
|
31
|
+
await TestLeafLookupByFieldEntity.creator(viewerContext)
|
|
32
|
+
.setField('test_entity_id', testEntity.getID())
|
|
33
|
+
.enforceCreateAsync();
|
|
34
|
+
}
|
|
35
|
+
const testLeafEntityCompanion = viewerContext.getViewerScopedEntityCompanionForClass(TestLeafEntity);
|
|
36
|
+
const testLeafEntityAuthorizeDeleteSpy = jest.spyOn(testLeafEntityCompanion.entityCompanion.privacyPolicy, 'authorizeDeleteAsync');
|
|
37
|
+
const testLeafLookupByFieldEntityCompanion = viewerContext.getViewerScopedEntityCompanionForClass(TestLeafLookupByFieldEntity);
|
|
38
|
+
const testLeafLookupByFieldEntityAuthorizeDeleteSpy = jest.spyOn(testLeafLookupByFieldEntityCompanion.entityCompanion.privacyPolicy, 'authorizeDeleteAsync');
|
|
39
|
+
const canViewerDelete = await (0, EntityPrivacyUtils_1.canViewerDeleteAsync)(TestEntity, testEntity);
|
|
40
|
+
expect(canViewerDelete).toBe(true);
|
|
41
|
+
expect(testLeafEntityAuthorizeDeleteSpy).toHaveBeenCalledTimes(1);
|
|
42
|
+
expect(testLeafLookupByFieldEntityAuthorizeDeleteSpy).toHaveBeenCalledTimes(1);
|
|
43
|
+
});
|
|
44
|
+
it('does not optimize when undefined', async () => {
|
|
45
|
+
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
46
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
47
|
+
// create root
|
|
48
|
+
const testEntity = await TestEntity.creator(viewerContext).enforceCreateAsync();
|
|
49
|
+
// create a bunch of leaves with no edgeDeletionPermissionInferenceBehavior
|
|
50
|
+
for (let i = 0; i < 10; i++) {
|
|
51
|
+
await TestLeafNoInferenceEntity.creator(viewerContext)
|
|
52
|
+
.setField('test_entity_id', testEntity.getID())
|
|
53
|
+
.enforceCreateAsync();
|
|
54
|
+
}
|
|
55
|
+
const companion = viewerContext.getViewerScopedEntityCompanionForClass(TestLeafNoInferenceEntity);
|
|
56
|
+
const authorizeDeleteSpy = jest.spyOn(companion.entityCompanion.privacyPolicy, 'authorizeDeleteAsync');
|
|
57
|
+
const canViewerDelete = await (0, EntityPrivacyUtils_1.canViewerDeleteAsync)(TestEntity, testEntity);
|
|
58
|
+
expect(canViewerDelete).toBe(true);
|
|
59
|
+
expect(authorizeDeleteSpy).toHaveBeenCalledTimes(10);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
class AlwaysAllowEntityPrivacyPolicy extends EntityPrivacyPolicy_1.default {
|
|
64
|
+
readRules = [
|
|
65
|
+
new AlwaysAllowPrivacyPolicyRule_1.default(),
|
|
66
|
+
];
|
|
67
|
+
createRules = [
|
|
68
|
+
new AlwaysAllowPrivacyPolicyRule_1.default(),
|
|
69
|
+
];
|
|
70
|
+
updateRules = [
|
|
71
|
+
new AlwaysDenyPrivacyPolicyRule_1.default(),
|
|
72
|
+
];
|
|
73
|
+
deleteRules = [
|
|
74
|
+
new AlwaysAllowPrivacyPolicyRule_1.default(),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
class TestEntity extends Entity_1.default {
|
|
78
|
+
static defineCompanionDefinition() {
|
|
79
|
+
return {
|
|
80
|
+
entityClass: TestEntity,
|
|
81
|
+
entityConfiguration: new EntityConfiguration_1.default({
|
|
82
|
+
idField: 'id',
|
|
83
|
+
tableName: 'blah',
|
|
84
|
+
inboundEdges: [TestLeafEntity, TestLeafLookupByFieldEntity, TestLeafNoInferenceEntity],
|
|
85
|
+
schema: {
|
|
86
|
+
id: new EntityFields_1.UUIDField({
|
|
87
|
+
columnName: 'custom_id',
|
|
88
|
+
}),
|
|
89
|
+
},
|
|
90
|
+
databaseAdapterFlavor: 'postgres',
|
|
91
|
+
cacheAdapterFlavor: 'redis',
|
|
92
|
+
}),
|
|
93
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class TestLeafEntity extends Entity_1.default {
|
|
98
|
+
static defineCompanionDefinition() {
|
|
99
|
+
return {
|
|
100
|
+
entityClass: TestLeafEntity,
|
|
101
|
+
entityConfiguration: new EntityConfiguration_1.default({
|
|
102
|
+
idField: 'id',
|
|
103
|
+
tableName: 'blah_2',
|
|
104
|
+
schema: {
|
|
105
|
+
id: new EntityFields_1.UUIDField({
|
|
106
|
+
columnName: 'custom_id',
|
|
107
|
+
}),
|
|
108
|
+
test_entity_id: new EntityFields_1.UUIDField({
|
|
109
|
+
columnName: 'test_entity_id',
|
|
110
|
+
association: {
|
|
111
|
+
associatedEntityClass: TestEntity,
|
|
112
|
+
edgeDeletionBehavior: EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE,
|
|
113
|
+
edgeDeletionAuthorizationInferenceBehavior: EntityFieldDefinition_1.EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL,
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
},
|
|
117
|
+
databaseAdapterFlavor: 'postgres',
|
|
118
|
+
cacheAdapterFlavor: 'redis',
|
|
119
|
+
}),
|
|
120
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
class TestLeafLookupByFieldEntity extends Entity_1.default {
|
|
125
|
+
static defineCompanionDefinition() {
|
|
126
|
+
return {
|
|
127
|
+
entityClass: TestLeafEntity,
|
|
128
|
+
entityConfiguration: new EntityConfiguration_1.default({
|
|
129
|
+
idField: 'id',
|
|
130
|
+
tableName: 'blah_4',
|
|
131
|
+
schema: {
|
|
132
|
+
id: new EntityFields_1.UUIDField({
|
|
133
|
+
columnName: 'custom_id',
|
|
134
|
+
}),
|
|
135
|
+
test_entity_id: new EntityFields_1.UUIDField({
|
|
136
|
+
columnName: 'test_entity_id',
|
|
137
|
+
association: {
|
|
138
|
+
associatedEntityClass: TestEntity,
|
|
139
|
+
edgeDeletionBehavior: EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE,
|
|
140
|
+
associatedEntityLookupByField: 'id',
|
|
141
|
+
edgeDeletionAuthorizationInferenceBehavior: EntityFieldDefinition_1.EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL,
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
},
|
|
145
|
+
databaseAdapterFlavor: 'postgres',
|
|
146
|
+
cacheAdapterFlavor: 'redis',
|
|
147
|
+
}),
|
|
148
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
class TestLeafNoInferenceEntity extends Entity_1.default {
|
|
153
|
+
static defineCompanionDefinition() {
|
|
154
|
+
return {
|
|
155
|
+
entityClass: TestLeafNoInferenceEntity,
|
|
156
|
+
entityConfiguration: new EntityConfiguration_1.default({
|
|
157
|
+
idField: 'id',
|
|
158
|
+
tableName: 'blah_3',
|
|
159
|
+
schema: {
|
|
160
|
+
id: new EntityFields_1.UUIDField({
|
|
161
|
+
columnName: 'custom_id',
|
|
162
|
+
}),
|
|
163
|
+
test_entity_id: new EntityFields_1.UUIDField({
|
|
164
|
+
columnName: 'test_entity_id',
|
|
165
|
+
association: {
|
|
166
|
+
associatedEntityClass: TestEntity,
|
|
167
|
+
edgeDeletionBehavior: EntityFieldDefinition_1.EntityEdgeDeletionBehavior.CASCADE_DELETE,
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
databaseAdapterFlavor: 'postgres',
|
|
172
|
+
cacheAdapterFlavor: 'redis',
|
|
173
|
+
}),
|
|
174
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferen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,EAAE,IAAI,6BAAmB,CAAuB;gBACjE,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,QAAQ;gBACnB,MAAM,EAAE;oBACN,EAAE,EAAE,IAAI,wBAAS,CAAC;wBAChB,UAAU,EAAE,WAAW;qBACxB,CAAC;oBACF,cAAc,EAAE,IAAI,wBAAS,CAAC;wBAC5B,UAAU,EAAE,gBAAgB;wBAC5B,WAAW,EAAE;4BACX,qBAAqB,EAAE,UAAU;4BACjC,oBAAoB,EAAE,kDAA0B,CAAC,cAAc;yBAChE;qBACF,CAAC;iBACH;gBACD,qBAAqB,EAAE,UAAU;gBACjC,kBAAkB,EAAE,OAAO;aAC5B,CAAC;YACF,kBAAkB,EAAE,8BAA8B;SACnD,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/entity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "A privacy-first data model",
|
|
5
5
|
"files": [
|
|
6
6
|
"build",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test": "jest --rootDir . --config ../../resources/jest.config.js",
|
|
17
17
|
"integration": "../../resources/run-with-docker yarn integration-no-setup",
|
|
18
18
|
"integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests",
|
|
19
|
-
"barrelsby": "barrelsby --
|
|
19
|
+
"barrelsby": "barrelsby --config ../../.barrelsby.json"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=16"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"uuid": "^8.3.0",
|
|
35
35
|
"uuidv7": "^1.0.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "d7cc0c23b983eccca9ca4e7ca620a5aaef6846c4"
|
|
38
38
|
}
|
|
@@ -36,6 +36,35 @@ export enum EntityEdgeDeletionBehavior {
|
|
|
36
36
|
SET_NULL,
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export enum EntityEdgeDeletionAuthorizationInferenceBehavior {
|
|
40
|
+
/**
|
|
41
|
+
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
42
|
+
* (when SET_NULL_INVALIDATE_CACHE_ONLY or SET_NULL) all entities at the ends of edges of this type
|
|
43
|
+
* cannot be inferred from authorization of any single entity at the end of an edge of this type.
|
|
44
|
+
*
|
|
45
|
+
* To evaluate canViewerDeleteAsync for the source entity, canViewerDeleteAsync must be called on all
|
|
46
|
+
* entities at the ends of all edges of this type.
|
|
47
|
+
*/
|
|
48
|
+
NONE,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Authorization to delete (when CASCADE_DELETE_INVALIDATE_CACHE_ONLY or CASCADE_DELETE) or update
|
|
52
|
+
* (when SET_NULL_INVALIDATE_CACHE_ONLY or SET_NULL) all entities at the ends of edges of this type
|
|
53
|
+
* may be inferred from authorization of any single entity at the end of an edge of this type.
|
|
54
|
+
*
|
|
55
|
+
* To evaluate canViewerDeleteAsync for the source entity, canViewerDeleteAsync must only be called on
|
|
56
|
+
* a single entity at the end of one edge of this type chosen at random.
|
|
57
|
+
*
|
|
58
|
+
* This should only be the case when the entity at the other end of this edge can be implicitly
|
|
59
|
+
* deleted/updated by virtue of the source entity deletion being authorized and a single authorization check
|
|
60
|
+
* on one edge of this type.
|
|
61
|
+
*
|
|
62
|
+
* Note that this is not used during actual deletions, only as an optimistic optimization during execution
|
|
63
|
+
* of canViewerDeleteAsync. Each entity being deleted will still check deletion privacy during actual deletion.
|
|
64
|
+
*/
|
|
65
|
+
ONE_IMPLIES_ALL,
|
|
66
|
+
}
|
|
67
|
+
|
|
39
68
|
/**
|
|
40
69
|
* Defines an association between entities. An association is primarily used to define cascading deletion behavior.
|
|
41
70
|
*/
|
|
@@ -77,7 +106,7 @@ export interface EntityAssociationDefinition<
|
|
|
77
106
|
associatedEntityLookupByField?: keyof TAssociatedFields;
|
|
78
107
|
|
|
79
108
|
/**
|
|
80
|
-
* What action to perform on the
|
|
109
|
+
* What action to perform on the entity at the other end of this edge when the entity on the source end of
|
|
81
110
|
* this edge is deleted.
|
|
82
111
|
*
|
|
83
112
|
* @remarks
|
|
@@ -93,6 +122,14 @@ export interface EntityAssociationDefinition<
|
|
|
93
122
|
* integrity is recommended.
|
|
94
123
|
*/
|
|
95
124
|
edgeDeletionBehavior: EntityEdgeDeletionBehavior;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Optimization setting for evaluation of this edge in canViewerDeleteAsync. Can be used to optimize permission checks
|
|
128
|
+
* for edge cascading deletions based on application-specific design of the entity association. Not used during actual deletions.
|
|
129
|
+
*
|
|
130
|
+
* Defaults to EntityEdgeDeletionAuthorizationInferenceBehavior.NONE.
|
|
131
|
+
*/
|
|
132
|
+
edgeDeletionAuthorizationInferenceBehavior?: EntityEdgeDeletionAuthorizationInferenceBehavior;
|
|
96
133
|
}
|
|
97
134
|
|
|
98
135
|
/**
|
package/src/index.ts
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
* @module @expo/entity
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
export { default as AuthorizationResultBasedEntityLoader } from './AuthorizationResultBasedEntityLoader';
|
|
7
8
|
export { default as ComposedEntityCacheAdapter } from './ComposedEntityCacheAdapter';
|
|
8
9
|
export { default as ComposedSecondaryEntityCache } from './ComposedSecondaryEntityCache';
|
|
9
|
-
export { default as GenericSecondaryEntityCache } from './GenericSecondaryEntityCache';
|
|
10
10
|
export { default as EnforcingEntityLoader } from './EnforcingEntityLoader';
|
|
11
11
|
export { default as Entity } from './Entity';
|
|
12
12
|
export * from './Entity';
|
|
13
13
|
export { default as EntityAssociationLoader } from './EntityAssociationLoader';
|
|
14
14
|
export * from './EntityAssociationLoader';
|
|
15
|
-
export { default as IEntityCacheAdapter } from './IEntityCacheAdapter';
|
|
16
|
-
export { default as GenericEntityCacheAdapter } from './GenericEntityCacheAdapter';
|
|
17
15
|
export { default as EntityCompanion } from './EntityCompanion';
|
|
18
16
|
export * from './EntityCompanion';
|
|
19
17
|
export { default as EntityCompanionProvider } from './EntityCompanionProvider';
|
|
@@ -21,32 +19,28 @@ export * from './EntityCompanionProvider';
|
|
|
21
19
|
export { default as EntityConfiguration } from './EntityConfiguration';
|
|
22
20
|
export { default as EntityDatabaseAdapter } from './EntityDatabaseAdapter';
|
|
23
21
|
export * from './EntityDatabaseAdapter';
|
|
24
|
-
export { default as EntityDatabaseAdapterError } from './errors/EntityDatabaseAdapterError';
|
|
25
|
-
export * from './errors/EntityDatabaseAdapterError';
|
|
26
|
-
export { default as EntityCacheAdapterError } from './errors/EntityCacheAdapterError';
|
|
27
|
-
export * from './errors/EntityCacheAdapterError';
|
|
28
|
-
export * from './errors/EntityError';
|
|
29
|
-
export { default as EntityError } from './errors/EntityError';
|
|
30
|
-
export { default as EntityNotAuthorizedError } from './errors/EntityNotAuthorizedError';
|
|
31
|
-
export { default as EntityNotFoundError } from './errors/EntityNotFoundError';
|
|
32
|
-
export * from './EntityFields';
|
|
33
22
|
export * from './EntityFieldDefinition';
|
|
23
|
+
export * from './EntityFields';
|
|
34
24
|
export { default as EntityLoader } from './EntityLoader';
|
|
35
25
|
export { default as EntityLoaderFactory } from './EntityLoaderFactory';
|
|
36
|
-
export { default as
|
|
37
|
-
export * from './EntitySecondaryCacheLoader';
|
|
38
|
-
export * from './EntityMutator';
|
|
39
|
-
export { default as EntityMutationValidator } from './EntityMutationValidator';
|
|
26
|
+
export { default as EntityLoaderUtils } from './EntityLoaderUtils';
|
|
40
27
|
export * from './EntityMutationInfo';
|
|
41
|
-
export * from './EntityMutationTriggerConfiguration';
|
|
42
28
|
export { default as EntityMutationTriggerConfiguration } from './EntityMutationTriggerConfiguration';
|
|
29
|
+
export * from './EntityMutationTriggerConfiguration';
|
|
30
|
+
export { default as EntityMutationValidator } from './EntityMutationValidator';
|
|
31
|
+
export * from './EntityMutator';
|
|
43
32
|
export { default as EntityMutatorFactory } from './EntityMutatorFactory';
|
|
44
33
|
export { default as EntityPrivacyPolicy } from './EntityPrivacyPolicy';
|
|
45
34
|
export * from './EntityPrivacyPolicy';
|
|
46
35
|
export * from './EntityQueryContext';
|
|
36
|
+
export { default as EntityQueryContextProvider } from './EntityQueryContextProvider';
|
|
37
|
+
export { default as EntitySecondaryCacheLoader } from './EntitySecondaryCacheLoader';
|
|
38
|
+
export * from './EntitySecondaryCacheLoader';
|
|
39
|
+
export { default as GenericEntityCacheAdapter } from './GenericEntityCacheAdapter';
|
|
40
|
+
export { default as GenericSecondaryEntityCache } from './GenericSecondaryEntityCache';
|
|
41
|
+
export { default as IEntityCacheAdapter } from './IEntityCacheAdapter';
|
|
47
42
|
export { default as IEntityCacheAdapterProvider } from './IEntityCacheAdapterProvider';
|
|
48
43
|
export { default as IEntityDatabaseAdapterProvider } from './IEntityDatabaseAdapterProvider';
|
|
49
|
-
export { default as EntityQueryContextProvider } from './EntityQueryContextProvider';
|
|
50
44
|
export { default as IEntityGenericCacher } from './IEntityGenericCacher';
|
|
51
45
|
export { default as ReadonlyEntity } from './ReadonlyEntity';
|
|
52
46
|
export { default as ViewerContext } from './ViewerContext';
|
|
@@ -55,8 +49,18 @@ export { default as ViewerScopedEntityCompanionProvider } from './ViewerScopedEn
|
|
|
55
49
|
export { default as ViewerScopedEntityLoaderFactory } from './ViewerScopedEntityLoaderFactory';
|
|
56
50
|
export { default as ViewerScopedEntityMutatorFactory } from './ViewerScopedEntityMutatorFactory';
|
|
57
51
|
export * from './entityUtils';
|
|
52
|
+
export { default as EntityCacheAdapterError } from './errors/EntityCacheAdapterError';
|
|
53
|
+
export * from './errors/EntityCacheAdapterError';
|
|
54
|
+
export { default as EntityDatabaseAdapterError } from './errors/EntityDatabaseAdapterError';
|
|
55
|
+
export * from './errors/EntityDatabaseAdapterError';
|
|
56
|
+
export { default as EntityError } from './errors/EntityError';
|
|
57
|
+
export * from './errors/EntityError';
|
|
58
|
+
export { default as EntityInvalidFieldValueError } from './errors/EntityInvalidFieldValueError';
|
|
59
|
+
export { default as EntityNotAuthorizedError } from './errors/EntityNotAuthorizedError';
|
|
60
|
+
export { default as EntityNotFoundError } from './errors/EntityNotFoundError';
|
|
58
61
|
export { default as EntityDataManager } from './internal/EntityDataManager';
|
|
59
62
|
export * from './internal/EntityFieldTransformationUtils';
|
|
63
|
+
export { default as EntityTableDataCoordinator } from './internal/EntityTableDataCoordinator';
|
|
60
64
|
export { default as ReadThroughEntityCache } from './internal/ReadThroughEntityCache';
|
|
61
65
|
export * from './internal/ReadThroughEntityCache';
|
|
62
66
|
export * from './metrics/EntityMetricsUtils';
|
|
@@ -68,12 +72,13 @@ export { default as AlwaysDenyPrivacyPolicyRule } from './rules/AlwaysDenyPrivac
|
|
|
68
72
|
export { default as AlwaysSkipPrivacyPolicyRule } from './rules/AlwaysSkipPrivacyPolicyRule';
|
|
69
73
|
export { default as PrivacyPolicyRule } from './rules/PrivacyPolicyRule';
|
|
70
74
|
export * from './rules/PrivacyPolicyRule';
|
|
75
|
+
export * from './utils/EntityPrivacyUtils';
|
|
76
|
+
export * from './utils/mergeEntityMutationTriggerConfigurations';
|
|
77
|
+
export * from './utils/collections/maps';
|
|
71
78
|
export * from './utils/testing/PrivacyPolicyRuleTestUtils';
|
|
72
79
|
export * from './utils/testing/StubCacheAdapter';
|
|
73
|
-
export { default as describeFieldTestCase } from './utils/testing/describeFieldTestCase';
|
|
74
80
|
export { default as StubDatabaseAdapter } from './utils/testing/StubDatabaseAdapter';
|
|
75
81
|
export { default as StubDatabaseAdapterProvider } from './utils/testing/StubDatabaseAdapterProvider';
|
|
76
82
|
export { default as StubQueryContextProvider } from './utils/testing/StubQueryContextProvider';
|
|
77
83
|
export * from './utils/testing/createUnitTestEntityCompanionProvider';
|
|
78
|
-
export
|
|
79
|
-
export * from './utils/EntityPrivacyUtils';
|
|
84
|
+
export { default as describeFieldTestCase } from './utils/testing/describeFieldTestCase';
|
|
@@ -84,7 +84,10 @@ export default class TestEntity extends Entity<TestFields, string, ViewerContext
|
|
|
84
84
|
return 'Hello World!';
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
static async
|
|
87
|
+
static async helloAsync(
|
|
88
|
+
viewerContext: ViewerContext,
|
|
89
|
+
testValue: string,
|
|
90
|
+
): Promise<Result<TestEntity>> {
|
|
88
91
|
const fields = {
|
|
89
92
|
customIdField: testValue,
|
|
90
93
|
testIndexedField: 'hello',
|
|
@@ -103,15 +106,15 @@ export default class TestEntity extends Entity<TestFields, string, ViewerContext
|
|
|
103
106
|
);
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
static async
|
|
109
|
+
static async returnErrorAsync(_viewerContext: ViewerContext): Promise<Result<TestEntity>> {
|
|
107
110
|
return result(new Error('return entity'));
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
static async
|
|
113
|
+
static async throwErrorAsync(_viewerContext: ViewerContext): Promise<Result<TestEntity>> {
|
|
111
114
|
throw new Error('threw entity');
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
static async
|
|
117
|
+
static async nonResultAsync(_viewerContext: ViewerContext, testValue: string): Promise<string> {
|
|
115
118
|
return testValue;
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { asyncResult } from '@expo/results';
|
|
1
|
+
import { Result, asyncResult } from '@expo/results';
|
|
2
2
|
|
|
3
3
|
import Entity, { IEntityClass } from '../Entity';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
EntityEdgeDeletionBehavior,
|
|
6
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior,
|
|
7
|
+
} from '../EntityFieldDefinition';
|
|
5
8
|
import { EntityCascadingDeletionInfo } from '../EntityMutationInfo';
|
|
6
9
|
import EntityPrivacyPolicy from '../EntityPrivacyPolicy';
|
|
7
10
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
@@ -254,16 +257,44 @@ async function canViewerDeleteInternalAsync<
|
|
|
254
257
|
continue;
|
|
255
258
|
}
|
|
256
259
|
|
|
257
|
-
const
|
|
258
|
-
.
|
|
259
|
-
.loadManyByFieldEqualingAsync(
|
|
260
|
-
fieldName,
|
|
261
|
-
association.associatedEntityLookupByField
|
|
262
|
-
? sourceEntity.getField(association.associatedEntityLookupByField as any)
|
|
263
|
-
: sourceEntity.getID(),
|
|
264
|
-
);
|
|
260
|
+
const edgeDeletionPermissionInferenceBehavior =
|
|
261
|
+
association.edgeDeletionAuthorizationInferenceBehavior;
|
|
265
262
|
|
|
266
|
-
|
|
263
|
+
let entityResultsToCheckForInboundEdge: readonly Result<any>[];
|
|
264
|
+
|
|
265
|
+
if (
|
|
266
|
+
edgeDeletionPermissionInferenceBehavior ===
|
|
267
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL
|
|
268
|
+
) {
|
|
269
|
+
const singleEntityToTestForInboundEdge = await loader
|
|
270
|
+
.withAuthorizationResults()
|
|
271
|
+
.loadFirstByFieldEqualityConjunctionAsync(
|
|
272
|
+
[
|
|
273
|
+
{
|
|
274
|
+
fieldName,
|
|
275
|
+
fieldValue: association.associatedEntityLookupByField
|
|
276
|
+
? sourceEntity.getField(association.associatedEntityLookupByField as any)
|
|
277
|
+
: sourceEntity.getID(),
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
{ orderBy: [] },
|
|
281
|
+
);
|
|
282
|
+
entityResultsToCheckForInboundEdge = singleEntityToTestForInboundEdge
|
|
283
|
+
? [singleEntityToTestForInboundEdge]
|
|
284
|
+
: [];
|
|
285
|
+
} else {
|
|
286
|
+
const entityResultsForInboundEdge = await loader
|
|
287
|
+
.withAuthorizationResults()
|
|
288
|
+
.loadManyByFieldEqualingAsync(
|
|
289
|
+
fieldName,
|
|
290
|
+
association.associatedEntityLookupByField
|
|
291
|
+
? sourceEntity.getField(association.associatedEntityLookupByField as any)
|
|
292
|
+
: sourceEntity.getID(),
|
|
293
|
+
);
|
|
294
|
+
entityResultsToCheckForInboundEdge = entityResultsForInboundEdge;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const failedEntityLoadResults = failedResults(entityResultsToCheckForInboundEdge);
|
|
267
298
|
for (const failedResult of failedEntityLoadResults) {
|
|
268
299
|
if (failedResult.reason instanceof EntityNotAuthorizedError) {
|
|
269
300
|
return false;
|
|
@@ -273,7 +304,9 @@ async function canViewerDeleteInternalAsync<
|
|
|
273
304
|
}
|
|
274
305
|
|
|
275
306
|
// all results should be success at this point due to check above
|
|
276
|
-
const entitiesForInboundEdge =
|
|
307
|
+
const entitiesForInboundEdge = entityResultsToCheckForInboundEdge.map((r) =>
|
|
308
|
+
r.enforceValue(),
|
|
309
|
+
);
|
|
277
310
|
|
|
278
311
|
switch (association.edgeDeletionBehavior) {
|
|
279
312
|
case EntityEdgeDeletionBehavior.CASCADE_DELETE:
|
package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import Entity from '../../Entity';
|
|
2
|
+
import { EntityCompanionDefinition } from '../../EntityCompanionProvider';
|
|
3
|
+
import EntityConfiguration from '../../EntityConfiguration';
|
|
4
|
+
import {
|
|
5
|
+
EntityEdgeDeletionBehavior,
|
|
6
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior,
|
|
7
|
+
} from '../../EntityFieldDefinition';
|
|
8
|
+
import { UUIDField } from '../../EntityFields';
|
|
9
|
+
import EntityPrivacyPolicy from '../../EntityPrivacyPolicy';
|
|
10
|
+
import ReadonlyEntity from '../../ReadonlyEntity';
|
|
11
|
+
import ViewerContext from '../../ViewerContext';
|
|
12
|
+
import AlwaysAllowPrivacyPolicyRule from '../../rules/AlwaysAllowPrivacyPolicyRule';
|
|
13
|
+
import AlwaysDenyPrivacyPolicyRule from '../../rules/AlwaysDenyPrivacyPolicyRule';
|
|
14
|
+
import { canViewerDeleteAsync } from '../EntityPrivacyUtils';
|
|
15
|
+
import { createUnitTestEntityCompanionProvider } from '../testing/createUnitTestEntityCompanionProvider';
|
|
16
|
+
|
|
17
|
+
describe(canViewerDeleteAsync, () => {
|
|
18
|
+
describe('edgeDeletionPermissionInferenceBehavior', () => {
|
|
19
|
+
it('optimizes when EntityEdgeDeletionPermissionInferenceBehavior.ONE_IMPLIES_ALL', async () => {
|
|
20
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
21
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
22
|
+
|
|
23
|
+
// create root
|
|
24
|
+
const testEntity = await TestEntity.creator(viewerContext).enforceCreateAsync();
|
|
25
|
+
|
|
26
|
+
// create a bunch of leaves referencing root with
|
|
27
|
+
// edgeDeletionPermissionInferenceBehavior = EntityEdgeDeletionPermissionInferenceBehavior.ONE_IMPLIES_ALL
|
|
28
|
+
for (let i = 0; i < 10; i++) {
|
|
29
|
+
await TestLeafEntity.creator(viewerContext)
|
|
30
|
+
.setField('test_entity_id', testEntity.getID())
|
|
31
|
+
.enforceCreateAsync();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
for (let i = 0; i < 10; i++) {
|
|
35
|
+
await TestLeafLookupByFieldEntity.creator(viewerContext)
|
|
36
|
+
.setField('test_entity_id', testEntity.getID())
|
|
37
|
+
.enforceCreateAsync();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const testLeafEntityCompanion =
|
|
41
|
+
viewerContext.getViewerScopedEntityCompanionForClass(TestLeafEntity);
|
|
42
|
+
const testLeafEntityAuthorizeDeleteSpy = jest.spyOn(
|
|
43
|
+
testLeafEntityCompanion.entityCompanion.privacyPolicy,
|
|
44
|
+
'authorizeDeleteAsync',
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const testLeafLookupByFieldEntityCompanion =
|
|
48
|
+
viewerContext.getViewerScopedEntityCompanionForClass(TestLeafLookupByFieldEntity);
|
|
49
|
+
const testLeafLookupByFieldEntityAuthorizeDeleteSpy = jest.spyOn(
|
|
50
|
+
testLeafLookupByFieldEntityCompanion.entityCompanion.privacyPolicy,
|
|
51
|
+
'authorizeDeleteAsync',
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const canViewerDelete = await canViewerDeleteAsync(TestEntity, testEntity);
|
|
55
|
+
expect(canViewerDelete).toBe(true);
|
|
56
|
+
|
|
57
|
+
expect(testLeafEntityAuthorizeDeleteSpy).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(testLeafLookupByFieldEntityAuthorizeDeleteSpy).toHaveBeenCalledTimes(1);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('does not optimize when undefined', async () => {
|
|
62
|
+
const companionProvider = createUnitTestEntityCompanionProvider();
|
|
63
|
+
const viewerContext = new ViewerContext(companionProvider);
|
|
64
|
+
|
|
65
|
+
// create root
|
|
66
|
+
const testEntity = await TestEntity.creator(viewerContext).enforceCreateAsync();
|
|
67
|
+
|
|
68
|
+
// create a bunch of leaves with no edgeDeletionPermissionInferenceBehavior
|
|
69
|
+
for (let i = 0; i < 10; i++) {
|
|
70
|
+
await TestLeafNoInferenceEntity.creator(viewerContext)
|
|
71
|
+
.setField('test_entity_id', testEntity.getID())
|
|
72
|
+
.enforceCreateAsync();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const companion =
|
|
76
|
+
viewerContext.getViewerScopedEntityCompanionForClass(TestLeafNoInferenceEntity);
|
|
77
|
+
const authorizeDeleteSpy = jest.spyOn(
|
|
78
|
+
companion.entityCompanion.privacyPolicy,
|
|
79
|
+
'authorizeDeleteAsync',
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const canViewerDelete = await canViewerDeleteAsync(TestEntity, testEntity);
|
|
83
|
+
expect(canViewerDelete).toBe(true);
|
|
84
|
+
|
|
85
|
+
expect(authorizeDeleteSpy).toHaveBeenCalledTimes(10);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
type TestEntityFields = {
|
|
91
|
+
id: string;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type TestLeafEntityFields = {
|
|
95
|
+
id: string;
|
|
96
|
+
test_entity_id: string | null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
class AlwaysAllowEntityPrivacyPolicy<
|
|
100
|
+
TFields extends object,
|
|
101
|
+
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
102
|
+
TViewerContext extends ViewerContext,
|
|
103
|
+
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
104
|
+
TSelectedFields extends keyof TFields = keyof TFields,
|
|
105
|
+
> extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields> {
|
|
106
|
+
protected override readonly readRules = [
|
|
107
|
+
new AlwaysAllowPrivacyPolicyRule<TFields, TID, TViewerContext, TEntity, TSelectedFields>(),
|
|
108
|
+
];
|
|
109
|
+
protected override readonly createRules = [
|
|
110
|
+
new AlwaysAllowPrivacyPolicyRule<TFields, TID, TViewerContext, TEntity, TSelectedFields>(),
|
|
111
|
+
];
|
|
112
|
+
protected override readonly updateRules = [
|
|
113
|
+
new AlwaysDenyPrivacyPolicyRule<TFields, TID, TViewerContext, TEntity, TSelectedFields>(),
|
|
114
|
+
];
|
|
115
|
+
protected override readonly deleteRules = [
|
|
116
|
+
new AlwaysAllowPrivacyPolicyRule<TFields, TID, TViewerContext, TEntity, TSelectedFields>(),
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
class TestEntity extends Entity<TestEntityFields, string, ViewerContext> {
|
|
121
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
122
|
+
TestEntityFields,
|
|
123
|
+
string,
|
|
124
|
+
ViewerContext,
|
|
125
|
+
TestEntity,
|
|
126
|
+
AlwaysAllowEntityPrivacyPolicy<TestEntityFields, string, ViewerContext, TestEntity>
|
|
127
|
+
> {
|
|
128
|
+
return {
|
|
129
|
+
entityClass: TestEntity,
|
|
130
|
+
entityConfiguration: new EntityConfiguration<TestEntityFields>({
|
|
131
|
+
idField: 'id',
|
|
132
|
+
tableName: 'blah',
|
|
133
|
+
inboundEdges: [TestLeafEntity, TestLeafLookupByFieldEntity, TestLeafNoInferenceEntity],
|
|
134
|
+
schema: {
|
|
135
|
+
id: new UUIDField({
|
|
136
|
+
columnName: 'custom_id',
|
|
137
|
+
}),
|
|
138
|
+
},
|
|
139
|
+
databaseAdapterFlavor: 'postgres',
|
|
140
|
+
cacheAdapterFlavor: 'redis',
|
|
141
|
+
}),
|
|
142
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
class TestLeafEntity extends Entity<TestLeafEntityFields, string, ViewerContext> {
|
|
148
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
149
|
+
TestLeafEntityFields,
|
|
150
|
+
string,
|
|
151
|
+
ViewerContext,
|
|
152
|
+
TestLeafEntity,
|
|
153
|
+
AlwaysAllowEntityPrivacyPolicy<TestLeafEntityFields, string, ViewerContext, TestLeafEntity>
|
|
154
|
+
> {
|
|
155
|
+
return {
|
|
156
|
+
entityClass: TestLeafEntity,
|
|
157
|
+
entityConfiguration: new EntityConfiguration<TestLeafEntityFields>({
|
|
158
|
+
idField: 'id',
|
|
159
|
+
tableName: 'blah_2',
|
|
160
|
+
schema: {
|
|
161
|
+
id: new UUIDField({
|
|
162
|
+
columnName: 'custom_id',
|
|
163
|
+
}),
|
|
164
|
+
test_entity_id: new UUIDField({
|
|
165
|
+
columnName: 'test_entity_id',
|
|
166
|
+
association: {
|
|
167
|
+
associatedEntityClass: TestEntity,
|
|
168
|
+
edgeDeletionBehavior: EntityEdgeDeletionBehavior.CASCADE_DELETE,
|
|
169
|
+
edgeDeletionAuthorizationInferenceBehavior:
|
|
170
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL,
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
},
|
|
174
|
+
databaseAdapterFlavor: 'postgres',
|
|
175
|
+
cacheAdapterFlavor: 'redis',
|
|
176
|
+
}),
|
|
177
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
class TestLeafLookupByFieldEntity extends Entity<TestLeafEntityFields, string, ViewerContext> {
|
|
183
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
184
|
+
TestLeafEntityFields,
|
|
185
|
+
string,
|
|
186
|
+
ViewerContext,
|
|
187
|
+
TestLeafEntity,
|
|
188
|
+
AlwaysAllowEntityPrivacyPolicy<TestLeafEntityFields, string, ViewerContext, TestLeafEntity>
|
|
189
|
+
> {
|
|
190
|
+
return {
|
|
191
|
+
entityClass: TestLeafEntity,
|
|
192
|
+
entityConfiguration: new EntityConfiguration<TestLeafEntityFields>({
|
|
193
|
+
idField: 'id',
|
|
194
|
+
tableName: 'blah_4',
|
|
195
|
+
schema: {
|
|
196
|
+
id: new UUIDField({
|
|
197
|
+
columnName: 'custom_id',
|
|
198
|
+
}),
|
|
199
|
+
test_entity_id: new UUIDField({
|
|
200
|
+
columnName: 'test_entity_id',
|
|
201
|
+
association: {
|
|
202
|
+
associatedEntityClass: TestEntity,
|
|
203
|
+
edgeDeletionBehavior: EntityEdgeDeletionBehavior.CASCADE_DELETE,
|
|
204
|
+
associatedEntityLookupByField: 'id',
|
|
205
|
+
edgeDeletionAuthorizationInferenceBehavior:
|
|
206
|
+
EntityEdgeDeletionAuthorizationInferenceBehavior.ONE_IMPLIES_ALL,
|
|
207
|
+
},
|
|
208
|
+
}),
|
|
209
|
+
},
|
|
210
|
+
databaseAdapterFlavor: 'postgres',
|
|
211
|
+
cacheAdapterFlavor: 'redis',
|
|
212
|
+
}),
|
|
213
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class TestLeafNoInferenceEntity extends Entity<TestLeafEntityFields, string, ViewerContext> {
|
|
219
|
+
static defineCompanionDefinition(): EntityCompanionDefinition<
|
|
220
|
+
TestLeafEntityFields,
|
|
221
|
+
string,
|
|
222
|
+
ViewerContext,
|
|
223
|
+
TestLeafNoInferenceEntity,
|
|
224
|
+
AlwaysAllowEntityPrivacyPolicy<
|
|
225
|
+
TestLeafEntityFields,
|
|
226
|
+
string,
|
|
227
|
+
ViewerContext,
|
|
228
|
+
TestLeafNoInferenceEntity
|
|
229
|
+
>
|
|
230
|
+
> {
|
|
231
|
+
return {
|
|
232
|
+
entityClass: TestLeafNoInferenceEntity,
|
|
233
|
+
entityConfiguration: new EntityConfiguration<TestLeafEntityFields>({
|
|
234
|
+
idField: 'id',
|
|
235
|
+
tableName: 'blah_3',
|
|
236
|
+
schema: {
|
|
237
|
+
id: new UUIDField({
|
|
238
|
+
columnName: 'custom_id',
|
|
239
|
+
}),
|
|
240
|
+
test_entity_id: new UUIDField({
|
|
241
|
+
columnName: 'test_entity_id',
|
|
242
|
+
association: {
|
|
243
|
+
associatedEntityClass: TestEntity,
|
|
244
|
+
edgeDeletionBehavior: EntityEdgeDeletionBehavior.CASCADE_DELETE,
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
247
|
+
},
|
|
248
|
+
databaseAdapterFlavor: 'postgres',
|
|
249
|
+
cacheAdapterFlavor: 'redis',
|
|
250
|
+
}),
|
|
251
|
+
privacyPolicyClass: AlwaysAllowEntityPrivacyPolicy,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
}
|