@expo/entity 0.39.0 → 0.41.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/AuthorizationResultBasedEntityAssociationLoader.d.ts +99 -0
- package/build/AuthorizationResultBasedEntityAssociationLoader.js +122 -0
- package/build/AuthorizationResultBasedEntityAssociationLoader.js.map +1 -0
- package/build/AuthorizationResultBasedEntityLoader.d.ts +1 -1
- package/build/AuthorizationResultBasedEntityLoader.js.map +1 -1
- package/build/{EntityMutator.d.ts → AuthorizationResultBasedEntityMutator.d.ts} +5 -17
- package/build/{EntityMutator.js → AuthorizationResultBasedEntityMutator.js} +22 -48
- package/build/AuthorizationResultBasedEntityMutator.js.map +1 -0
- package/build/EnforcingEntityAssociationLoader.d.ts +79 -0
- package/build/EnforcingEntityAssociationLoader.js +62 -0
- package/build/EnforcingEntityAssociationLoader.js.map +1 -0
- package/build/EnforcingEntityCreator.d.ts +24 -0
- package/build/EnforcingEntityCreator.js +32 -0
- package/build/EnforcingEntityCreator.js.map +1 -0
- package/build/EnforcingEntityDeleter.d.ts +17 -0
- package/build/EnforcingEntityDeleter.js +22 -0
- package/build/EnforcingEntityDeleter.js.map +1 -0
- package/build/EnforcingEntityUpdater.d.ts +24 -0
- package/build/EnforcingEntityUpdater.js +32 -0
- package/build/EnforcingEntityUpdater.js.map +1 -0
- package/build/Entity.d.ts +26 -8
- package/build/Entity.js +38 -25
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +12 -91
- package/build/EntityAssociationLoader.js +20 -126
- package/build/EntityAssociationLoader.js.map +1 -1
- package/build/EntityCreator.d.ts +27 -0
- package/build/EntityCreator.js +39 -0
- package/build/EntityCreator.js.map +1 -0
- package/build/EntityDeleter.d.ts +27 -0
- package/build/EntityDeleter.js +40 -0
- package/build/EntityDeleter.js.map +1 -0
- package/build/EntityLoader.d.ts +4 -14
- package/build/EntityLoader.js +7 -20
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityLoaderFactory.d.ts +2 -2
- package/build/EntityLoaderFactory.js +4 -2
- package/build/EntityLoaderFactory.js.map +1 -1
- package/build/EntityMutatorFactory.d.ts +4 -4
- package/build/EntityMutatorFactory.js +4 -4
- package/build/EntityMutatorFactory.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +3 -3
- package/build/EntitySecondaryCacheLoader.js +1 -3
- package/build/EntitySecondaryCacheLoader.js.map +1 -1
- package/build/EntityUpdater.d.ts +27 -0
- package/build/EntityUpdater.js +40 -0
- package/build/EntityUpdater.js.map +1 -0
- package/build/ReadonlyEntity.d.ts +24 -5
- package/build/ReadonlyEntity.js +33 -7
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerScopedEntityLoaderFactory.d.ts +2 -2
- package/build/ViewerScopedEntityLoaderFactory.js.map +1 -1
- package/build/ViewerScopedEntityMutatorFactory.d.ts +4 -4
- package/build/ViewerScopedEntityMutatorFactory.js.map +1 -1
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.d.ts +1 -0
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js +242 -0
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +1 -0
- package/build/__tests__/{EntityLoader-constructor-test.js → AuthorizationResultBasedEntityLoader-constructor-test.js} +10 -10
- package/build/__tests__/AuthorizationResultBasedEntityLoader-constructor-test.js.map +1 -0
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.d.ts +1 -0
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js +401 -0
- package/build/__tests__/AuthorizationResultBasedEntityLoader-test.js.map +1 -0
- package/build/__tests__/EnforcingEntityAssociationLoader-test.d.ts +1 -0
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js +115 -0
- package/build/__tests__/EnforcingEntityAssociationLoader-test.js.map +1 -0
- package/build/__tests__/Entity-test.js +63 -5
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +14 -184
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +34 -20
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityCompanion-test.js +17 -7
- package/build/__tests__/EntityCompanion-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +57 -71
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +22 -386
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +6 -9
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +67 -70
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntityPrivacyPolicy-test.js +17 -7
- package/build/__tests__/EntityPrivacyPolicy-test.js.map +1 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +7 -7
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +47 -81
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ReadonlyEntity-test.js +40 -7
- package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +6 -10
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +10 -22
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/errors/EntityCacheAdapterError.js +17 -7
- package/build/errors/EntityCacheAdapterError.js.map +1 -1
- package/build/errors/EntityDatabaseAdapterError.js +17 -7
- package/build/errors/EntityDatabaseAdapterError.js.map +1 -1
- package/build/errors/EntityInvalidFieldValueError.js +17 -7
- package/build/errors/EntityInvalidFieldValueError.js.map +1 -1
- package/build/errors/EntityNotAuthorizedError.js +17 -7
- package/build/errors/EntityNotAuthorizedError.js.map +1 -1
- package/build/errors/EntityNotFoundError.js +17 -7
- package/build/errors/EntityNotFoundError.js.map +1 -1
- package/build/index.d.ts +19 -11
- package/build/index.js +24 -7
- package/build/index.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +42 -32
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/internal/__tests__/ReadThroughEntityCache-test.js +17 -7
- package/build/internal/__tests__/ReadThroughEntityCache-test.js.map +1 -1
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js +17 -7
- package/build/rules/AlwaysAllowPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js +17 -7
- package/build/rules/AlwaysDenyPrivacyPolicyRule.js.map +1 -1
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js +17 -7
- package/build/rules/AlwaysSkipPrivacyPolicyRule.js.map +1 -1
- package/build/utils/EntityPrivacyUtils.js +4 -8
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +38 -28
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +1 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +5 -5
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +1 -1
- package/build/utils/testing/StubDatabaseAdapter.js +17 -7
- package/build/utils/testing/StubDatabaseAdapter.js.map +1 -1
- package/build/utils/testing/StubQueryContextProvider.d.ts +1 -3
- package/build/utils/testing/StubQueryContextProvider.js +1 -3
- package/build/utils/testing/StubQueryContextProvider.js.map +1 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js +2 -1
- package/build/utils/testing/createUnitTestEntityCompanionProvider.js.map +1 -1
- package/package.json +19 -3
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +490 -0
- package/src/AuthorizationResultBasedEntityLoader.ts +1 -1
- package/src/{EntityMutator.ts → AuthorizationResultBasedEntityMutator.ts} +62 -58
- package/src/EnforcingEntityAssociationLoader.ts +390 -0
- package/src/EnforcingEntityCreator.ts +55 -0
- package/src/EnforcingEntityDeleter.ts +44 -0
- package/src/EnforcingEntityUpdater.ts +55 -0
- package/src/Entity.ts +140 -29
- package/src/EntityAssociationLoader.ts +38 -495
- package/src/EntityCreator.ts +73 -0
- package/src/EntityDeleter.ts +73 -0
- package/src/EntityLoader.ts +10 -49
- package/src/EntityLoaderFactory.ts +20 -3
- package/src/EntityMutatorFactory.ts +32 -7
- package/src/EntitySecondaryCacheLoader.ts +5 -7
- package/src/EntityUpdater.ts +73 -0
- package/src/ReadonlyEntity.ts +121 -7
- package/src/ViewerScopedEntityLoaderFactory.ts +9 -2
- package/src/ViewerScopedEntityMutatorFactory.ts +29 -4
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +323 -0
- package/src/__tests__/{EntityLoader-constructor-test.ts → AuthorizationResultBasedEntityLoader-constructor-test.ts} +16 -9
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +730 -0
- package/src/__tests__/EnforcingEntityAssociationLoader-test.ts +253 -0
- package/src/__tests__/Entity-test.ts +77 -5
- package/src/__tests__/EntityAssociationLoader-test.ts +15 -260
- package/src/__tests__/EntityCommonUseCases-test.ts +24 -15
- package/src/__tests__/EntityEdges-test.ts +44 -64
- package/src/__tests__/EntityLoader-test.ts +29 -681
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +8 -9
- package/src/__tests__/EntityMutator-test.ts +116 -103
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +7 -7
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +65 -81
- package/src/__tests__/ReadonlyEntity-test.ts +47 -7
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +15 -15
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +19 -22
- package/src/index.ts +19 -11
- package/src/internal/__tests__/EntityDataManager-test.ts +25 -25
- package/src/utils/EntityPrivacyUtils.ts +10 -13
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +21 -23
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +5 -5
- package/src/utils/testing/StubQueryContextProvider.ts +1 -3
- package/src/utils/testing/createUnitTestEntityCompanionProvider.ts +3 -1
- package/build/EntityMutator.js.map +0 -1
- package/build/__tests__/EntityLoader-constructor-test.js.map +0 -1
- /package/build/__tests__/{EntityLoader-constructor-test.d.ts → AuthorizationResultBasedEntityLoader-constructor-test.d.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
1
|
+
import AuthorizationResultBasedEntityAssociationLoader from './AuthorizationResultBasedEntityAssociationLoader';
|
|
2
|
+
import EnforcingEntityAssociationLoader from './EnforcingEntityAssociationLoader';
|
|
4
3
|
import { EntityQueryContext } from './EntityQueryContext';
|
|
5
4
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
5
|
import ViewerContext from './ViewerContext';
|
|
@@ -11,96 +10,18 @@ import ViewerContext from './ViewerContext';
|
|
|
11
10
|
*/
|
|
12
11
|
export default class EntityAssociationLoader<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
13
12
|
private readonly entity;
|
|
14
|
-
|
|
13
|
+
private readonly queryContext;
|
|
14
|
+
constructor(entity: TEntity, queryContext?: EntityQueryContext);
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param associatedEntityClass - class of the associated entity
|
|
20
|
-
* @param queryContext - query context in which to perform the load
|
|
16
|
+
* Enforcing entity association loader. All loads through this loader are
|
|
17
|
+
* guaranteed to be the values of successful results (or null for some loader methods),
|
|
18
|
+
* and will throw otherwise.
|
|
21
19
|
*/
|
|
22
|
-
|
|
20
|
+
enforcing(): EnforcingEntityAssociationLoader<TFields, TID, TViewerContext, TEntity, TSelectedFields>;
|
|
23
21
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* where this entity has many associated entities.
|
|
28
|
-
* @param associatedEntityClass - class of the associated entities
|
|
29
|
-
* @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity
|
|
30
|
-
* @param queryContext - query context in which to perform the load
|
|
22
|
+
* Authorization-result-based entity loader. All loads through this
|
|
23
|
+
* loader are results, where an unsuccessful result
|
|
24
|
+
* means an authorization error or entity construction error occurred. Other errors are thrown.
|
|
31
25
|
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Load an associated entity identified by a field value of this entity. In a relational database,
|
|
35
|
-
* the field in this entity is a foreign key to a unique field of the associated entity.
|
|
36
|
-
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entity
|
|
37
|
-
* @param associatedEntityClass - class of the associated entity
|
|
38
|
-
* @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity
|
|
39
|
-
* @param queryContext - query context in which to perform the load
|
|
40
|
-
*/
|
|
41
|
-
loadAssociatedEntityByFieldEqualingAsync<TAssociatedFields extends object, TAssociatedID extends NonNullable<TAssociatedFields[TAssociatedSelectedFields]>, TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields>, TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields>, TAssociatedSelectedFields extends keyof TAssociatedFields = keyof TAssociatedFields>(fieldIdentifyingAssociatedEntity: keyof Pick<TFields, TSelectedFields>, associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>, associatedEntityLookupByField: keyof Pick<TAssociatedFields, TAssociatedSelectedFields>, queryContext?: EntityQueryContext): Promise<Result<TAssociatedEntity> | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Load many associated entities identified by a field value of this entity. In a relational database,
|
|
44
|
-
* the field in this entity refers to a field of the associated entity.
|
|
45
|
-
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entities
|
|
46
|
-
* @param associatedEntityClass - class of the associated entities
|
|
47
|
-
* @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities
|
|
48
|
-
* @param queryContext - query context in which to perform the load
|
|
49
|
-
*/
|
|
50
|
-
loadManyAssociatedEntitiesByFieldEqualingAsync<TAssociatedFields extends object, TAssociatedID extends NonNullable<TAssociatedFields[TAssociatedSelectedFields]>, TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields>, TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields>, TAssociatedSelectedFields extends keyof TAssociatedFields = keyof TAssociatedFields>(fieldIdentifyingAssociatedEntity: keyof Pick<TFields, TSelectedFields>, associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>, associatedEntityLookupByField: keyof Pick<TAssociatedFields, TAssociatedSelectedFields>, queryContext?: EntityQueryContext): Promise<readonly Result<TAssociatedEntity>[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
53
|
-
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
54
|
-
* @param loadDirectives - associated entity load directives instructing each step of the fold
|
|
55
|
-
* @param queryContext - query context in which to perform the loads
|
|
56
|
-
*/
|
|
57
|
-
loadAssociatedEntityThroughAsync<TFields2 extends object, TID2 extends NonNullable<TFields2[TSelectedFields2]>, TEntity2 extends ReadonlyEntity<TFields2, TID2, TViewerContext, TSelectedFields2>, TPrivacyPolicy2 extends EntityPrivacyPolicy<TFields2, TID2, TViewerContext, TEntity2, TSelectedFields2>, TSelectedFields2 extends keyof TFields2 = keyof TFields2>(loadDirectives: [
|
|
58
|
-
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>
|
|
59
|
-
], queryContext?: EntityQueryContext): Promise<Result<TEntity2> | null>;
|
|
60
|
-
/**
|
|
61
|
-
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
62
|
-
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
63
|
-
* @param loadDirectives - associated entity load directives instructing each step of the fold
|
|
64
|
-
* @param queryContext - query context in which to perform the loads
|
|
65
|
-
*/
|
|
66
|
-
loadAssociatedEntityThroughAsync<TFields2 extends object, TID2 extends NonNullable<TFields2[TSelectedFields2]>, TEntity2 extends ReadonlyEntity<TFields2, TID2, TViewerContext, TSelectedFields2>, TPrivacyPolicy2 extends EntityPrivacyPolicy<TFields2, TID2, TViewerContext, TEntity2, TSelectedFields2>, TFields3 extends object, TID3 extends NonNullable<TFields3[TSelectedFields3]>, TEntity3 extends ReadonlyEntity<TFields3, TID3, TViewerContext, TSelectedFields3>, TPrivacyPolicy3 extends EntityPrivacyPolicy<TFields3, TID3, TViewerContext, TEntity3, TSelectedFields3>, TSelectedFields2 extends keyof TFields2 = keyof TFields2, TSelectedFields3 extends keyof TFields3 = keyof TFields3>(loadDirectives: [
|
|
67
|
-
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>,
|
|
68
|
-
EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>
|
|
69
|
-
], queryContext?: EntityQueryContext): Promise<Result<TEntity3> | null>;
|
|
70
|
-
/**
|
|
71
|
-
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
72
|
-
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
73
|
-
* @param loadDirectives - associated entity load directives instructing each step of the fold
|
|
74
|
-
* @param queryContext - query context in which to perform the loads
|
|
75
|
-
*/
|
|
76
|
-
loadAssociatedEntityThroughAsync<TFields2 extends object, TID2 extends NonNullable<TFields2[TSelectedFields2]>, TEntity2 extends ReadonlyEntity<TFields2, TID2, TViewerContext, TSelectedFields2>, TPrivacyPolicy2 extends EntityPrivacyPolicy<TFields2, TID2, TViewerContext, TEntity2, TSelectedFields2>, TFields3 extends object, TID3 extends NonNullable<TFields3[TSelectedFields3]>, TEntity3 extends ReadonlyEntity<TFields3, TID3, TViewerContext, TSelectedFields3>, TPrivacyPolicy3 extends EntityPrivacyPolicy<TFields3, TID3, TViewerContext, TEntity3, TSelectedFields3>, TFields4 extends object, TID4 extends NonNullable<TFields4[TSelectedFields4]>, TEntity4 extends ReadonlyEntity<TFields4, TID4, TViewerContext, TSelectedFields4>, TPrivacyPolicy4 extends EntityPrivacyPolicy<TFields4, TID4, TViewerContext, TEntity4, TSelectedFields4>, TSelectedFields2 extends keyof TFields2 = keyof TFields2, TSelectedFields3 extends keyof TFields3 = keyof TFields3, TSelectedFields4 extends keyof TFields4 = keyof TFields4>(loadDirectives: [
|
|
77
|
-
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>,
|
|
78
|
-
EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>,
|
|
79
|
-
EntityLoadThroughDirective<TViewerContext, TFields3, TFields4, TID4, TEntity4, TPrivacyPolicy4, TSelectedFields3, TSelectedFields4>
|
|
80
|
-
], queryContext?: EntityQueryContext): Promise<Result<TEntity4> | null>;
|
|
81
|
-
/**
|
|
82
|
-
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
83
|
-
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
84
|
-
* @param loadDirectives - associated entity load directives instructing each step of the fold
|
|
85
|
-
* @param queryContext - query context in which to perform the loads
|
|
86
|
-
*/
|
|
87
|
-
loadAssociatedEntityThroughAsync(loadDirectives: EntityLoadThroughDirective<TViewerContext, any, any, any, any, any, any, any>[], queryContext?: EntityQueryContext): Promise<Result<ReadonlyEntity<any, any, any, any>> | null>;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Instruction for each step of a load-associated-through method.
|
|
91
|
-
*/
|
|
92
|
-
export interface EntityLoadThroughDirective<TViewerContext extends ViewerContext, TFields, TAssociatedFields extends object, TAssociatedID extends NonNullable<TAssociatedFields[TAssociatedSelectedFields]>, TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields>, TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields>, TSelectedFields extends keyof TFields = keyof TFields, TAssociatedSelectedFields extends keyof TAssociatedFields = keyof TAssociatedFields> {
|
|
93
|
-
/**
|
|
94
|
-
* Class of entity to load at this step.
|
|
95
|
-
*/
|
|
96
|
-
associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>;
|
|
97
|
-
/**
|
|
98
|
-
* Field of the current entity with which to load an instance of associatedEntityClass.
|
|
99
|
-
*/
|
|
100
|
-
fieldIdentifyingAssociatedEntity: keyof Pick<TFields, TSelectedFields>;
|
|
101
|
-
/**
|
|
102
|
-
* Field by which to load the instance of associatedEntityClass. If not provided, the
|
|
103
|
-
* associatedEntityClass instance is fetched by its ID.
|
|
104
|
-
*/
|
|
105
|
-
associatedEntityLookupByField?: keyof Pick<TAssociatedFields, TAssociatedSelectedFields>;
|
|
26
|
+
withAuthorizationResults(): AuthorizationResultBasedEntityAssociationLoader<TFields, TID, TViewerContext, TEntity, TSelectedFields>;
|
|
106
27
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
6
|
+
const AuthorizationResultBasedEntityAssociationLoader_1 = __importDefault(require("./AuthorizationResultBasedEntityAssociationLoader"));
|
|
7
|
+
const EnforcingEntityAssociationLoader_1 = __importDefault(require("./EnforcingEntityAssociationLoader"));
|
|
4
8
|
/**
|
|
5
9
|
* An association loader is a set of convenience methods for loading entities
|
|
6
10
|
* associated with an entity. In relational databases, these entities are often referenced
|
|
@@ -8,140 +12,30 @@ const results_1 = require("@expo/results");
|
|
|
8
12
|
*/
|
|
9
13
|
class EntityAssociationLoader {
|
|
10
14
|
entity;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Load an associated entity identified by a field value of this entity. In a relational database,
|
|
16
|
-
* the field in this entity is a foreign key to the ID of the associated entity.
|
|
17
|
-
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the ID of the associated entity
|
|
18
|
-
* @param associatedEntityClass - class of the associated entity
|
|
19
|
-
* @param queryContext - query context in which to perform the load
|
|
20
|
-
*/
|
|
21
|
-
async loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, queryContext = this.entity
|
|
22
|
-
.getViewerContext()
|
|
23
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
24
|
-
.getQueryContextProvider()
|
|
25
|
-
.getQueryContext()) {
|
|
26
|
-
const associatedEntityID = this.entity.getField(fieldIdentifyingAssociatedEntity);
|
|
27
|
-
if (!associatedEntityID) {
|
|
28
|
-
return (0, results_1.result)(null);
|
|
29
|
-
}
|
|
30
|
-
const loader = this.entity
|
|
31
|
-
.getViewerContext()
|
|
32
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
33
|
-
.getLoaderFactory()
|
|
34
|
-
.forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null });
|
|
35
|
-
return (await loader
|
|
36
|
-
.withAuthorizationResults()
|
|
37
|
-
.loadByIDAsync(associatedEntityID));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Load many entities associated with this entity, often referred to as entites belonging
|
|
41
|
-
* to this entity. In a relational database, the field in the foreign entity is a
|
|
42
|
-
* foreign key to the ID of this entity. Also commonly referred to as a has many relationship,
|
|
43
|
-
* where this entity has many associated entities.
|
|
44
|
-
* @param associatedEntityClass - class of the associated entities
|
|
45
|
-
* @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity
|
|
46
|
-
* @param queryContext - query context in which to perform the load
|
|
47
|
-
*/
|
|
48
|
-
async loadManyAssociatedEntitiesAsync(associatedEntityClass, associatedEntityFieldContainingThisID, queryContext = this.entity
|
|
15
|
+
queryContext;
|
|
16
|
+
constructor(entity, queryContext = entity
|
|
49
17
|
.getViewerContext()
|
|
50
|
-
.getViewerScopedEntityCompanionForClass(
|
|
18
|
+
.getViewerScopedEntityCompanionForClass(entity.constructor)
|
|
51
19
|
.getQueryContextProvider()
|
|
52
20
|
.getQueryContext()) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.getViewerContext()
|
|
56
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
57
|
-
.getLoaderFactory()
|
|
58
|
-
.forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null });
|
|
59
|
-
return await loader
|
|
60
|
-
.withAuthorizationResults()
|
|
61
|
-
.loadManyByFieldEqualingAsync(associatedEntityFieldContainingThisID, thisID);
|
|
21
|
+
this.entity = entity;
|
|
22
|
+
this.queryContext = queryContext;
|
|
62
23
|
}
|
|
63
24
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @param associatedEntityClass - class of the associated entity
|
|
68
|
-
* @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity
|
|
69
|
-
* @param queryContext - query context in which to perform the load
|
|
25
|
+
* Enforcing entity association loader. All loads through this loader are
|
|
26
|
+
* guaranteed to be the values of successful results (or null for some loader methods),
|
|
27
|
+
* and will throw otherwise.
|
|
70
28
|
*/
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
74
|
-
.getQueryContextProvider()
|
|
75
|
-
.getQueryContext()) {
|
|
76
|
-
const associatedFieldValue = this.entity.getField(fieldIdentifyingAssociatedEntity);
|
|
77
|
-
if (!associatedFieldValue) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
const loader = this.entity
|
|
81
|
-
.getViewerContext()
|
|
82
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
83
|
-
.getLoaderFactory()
|
|
84
|
-
.forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null });
|
|
85
|
-
return await loader
|
|
86
|
-
.withAuthorizationResults()
|
|
87
|
-
.loadByFieldEqualingAsync(associatedEntityLookupByField, associatedFieldValue);
|
|
29
|
+
enforcing() {
|
|
30
|
+
return new EnforcingEntityAssociationLoader_1.default(this.withAuthorizationResults());
|
|
88
31
|
}
|
|
89
32
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @param associatedEntityClass - class of the associated entities
|
|
94
|
-
* @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities
|
|
95
|
-
* @param queryContext - query context in which to perform the load
|
|
33
|
+
* Authorization-result-based entity loader. All loads through this
|
|
34
|
+
* loader are results, where an unsuccessful result
|
|
35
|
+
* means an authorization error or entity construction error occurred. Other errors are thrown.
|
|
96
36
|
*/
|
|
97
|
-
|
|
98
|
-
.
|
|
99
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
100
|
-
.getQueryContextProvider()
|
|
101
|
-
.getQueryContext()) {
|
|
102
|
-
const associatedFieldValue = this.entity.getField(fieldIdentifyingAssociatedEntity);
|
|
103
|
-
if (!associatedFieldValue) {
|
|
104
|
-
return [];
|
|
105
|
-
}
|
|
106
|
-
const loader = this.entity
|
|
107
|
-
.getViewerContext()
|
|
108
|
-
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
109
|
-
.getLoaderFactory()
|
|
110
|
-
.forLoad(queryContext, { previousValue: null, cascadingDeleteCause: null });
|
|
111
|
-
return await loader
|
|
112
|
-
.withAuthorizationResults()
|
|
113
|
-
.loadManyByFieldEqualingAsync(associatedEntityLookupByField, associatedFieldValue);
|
|
114
|
-
}
|
|
115
|
-
async loadAssociatedEntityThroughAsync(loadDirectives, queryContext) {
|
|
116
|
-
let currentEntity = this.entity;
|
|
117
|
-
for (const loadDirective of loadDirectives) {
|
|
118
|
-
const { associatedEntityClass, fieldIdentifyingAssociatedEntity, associatedEntityLookupByField, } = loadDirective;
|
|
119
|
-
let associatedEntityResult;
|
|
120
|
-
if (associatedEntityLookupByField) {
|
|
121
|
-
associatedEntityResult = await currentEntity
|
|
122
|
-
.associationLoader()
|
|
123
|
-
.loadAssociatedEntityByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, queryContext);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
const associatedEntityResultLocal = await currentEntity
|
|
127
|
-
.associationLoader()
|
|
128
|
-
.loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, queryContext);
|
|
129
|
-
if (associatedEntityResultLocal.ok && associatedEntityResultLocal.value === null) {
|
|
130
|
-
associatedEntityResult = null;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
associatedEntityResult = associatedEntityResultLocal;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (!associatedEntityResult) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
if (!associatedEntityResult.ok) {
|
|
140
|
-
return (0, results_1.result)(associatedEntityResult.reason);
|
|
141
|
-
}
|
|
142
|
-
currentEntity = associatedEntityResult.value;
|
|
143
|
-
}
|
|
144
|
-
return (0, results_1.result)(currentEntity);
|
|
37
|
+
withAuthorizationResults() {
|
|
38
|
+
return new AuthorizationResultBasedEntityAssociationLoader_1.default(this.entity, this.queryContext);
|
|
145
39
|
}
|
|
146
40
|
}
|
|
147
41
|
exports.default = EntityAssociationLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityAssociationLoader.js","sourceRoot":"","sources":["../src/EntityAssociationLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EntityAssociationLoader.js","sourceRoot":"","sources":["../src/EntityAssociationLoader.ts"],"names":[],"mappings":";;;;;AAAA,wIAAgH;AAChH,0GAAkF;AAMlF;;;;GAIG;AACH,MAAqB,uBAAuB;IAQvB;IACA;IAFnB,YACmB,MAAe,EACf,eAAmC,MAAM;SACvD,gBAAgB,EAAE;SAClB,sCAAsC,CACrC,MAAM,CAAC,WAON,CACF;SACA,uBAAuB,EAAE;SACzB,eAAe,EAAE;QAdH,WAAM,GAAN,MAAM,CAAS;QACf,iBAAY,GAAZ,YAAY,CAaT;IACnB,CAAC;IAEJ;;;;OAIG;IACH,SAAS;QAOP,OAAO,IAAI,0CAAgC,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;OAIG;IACH,wBAAwB;QAOtB,OAAO,IAAI,yDAA+C,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7F,CAAC;CACF;AAtDD,0CAsDC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AuthorizationResultBasedCreateMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
+
import EnforcingEntityCreator from './EnforcingEntityCreator';
|
|
3
|
+
import { IEntityClass } from './Entity';
|
|
4
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
5
|
+
import { EntityQueryContext } from './EntityQueryContext';
|
|
6
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
7
|
+
import ViewerContext from './ViewerContext';
|
|
8
|
+
/**
|
|
9
|
+
* The primary interface for creating entities.
|
|
10
|
+
*/
|
|
11
|
+
export default class EntityCreator<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TViewerContext2 extends TViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
12
|
+
private readonly viewerContext;
|
|
13
|
+
private readonly queryContext;
|
|
14
|
+
private readonly entityClass;
|
|
15
|
+
constructor(viewerContext: TViewerContext2, queryContext: EntityQueryContext, entityClass: IEntityClass<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
16
|
+
/**
|
|
17
|
+
* Enforcing entity creator. All creates through this creator are
|
|
18
|
+
* guaranteed to be successful and will throw otherwise.
|
|
19
|
+
*/
|
|
20
|
+
enforcing(): EnforcingEntityCreator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
21
|
+
/**
|
|
22
|
+
* Authorization-result-based entity creator. All creates through this
|
|
23
|
+
* creator are results, where an unsuccessful result means an authorization
|
|
24
|
+
* error or entity construction error occurred. Other errors are thrown.
|
|
25
|
+
*/
|
|
26
|
+
withAuthorizationResults(): AuthorizationResultBasedCreateMutator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 EnforcingEntityCreator_1 = __importDefault(require("./EnforcingEntityCreator"));
|
|
7
|
+
/**
|
|
8
|
+
* The primary interface for creating entities.
|
|
9
|
+
*/
|
|
10
|
+
class EntityCreator {
|
|
11
|
+
viewerContext;
|
|
12
|
+
queryContext;
|
|
13
|
+
entityClass;
|
|
14
|
+
constructor(viewerContext, queryContext, entityClass) {
|
|
15
|
+
this.viewerContext = viewerContext;
|
|
16
|
+
this.queryContext = queryContext;
|
|
17
|
+
this.entityClass = entityClass;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Enforcing entity creator. All creates through this creator are
|
|
21
|
+
* guaranteed to be successful and will throw otherwise.
|
|
22
|
+
*/
|
|
23
|
+
enforcing() {
|
|
24
|
+
return new EnforcingEntityCreator_1.default(this.withAuthorizationResults());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Authorization-result-based entity creator. All creates through this
|
|
28
|
+
* creator are results, where an unsuccessful result means an authorization
|
|
29
|
+
* error or entity construction error occurred. Other errors are thrown.
|
|
30
|
+
*/
|
|
31
|
+
withAuthorizationResults() {
|
|
32
|
+
return this.viewerContext
|
|
33
|
+
.getViewerScopedEntityCompanionForClass(this.entityClass)
|
|
34
|
+
.getMutatorFactory()
|
|
35
|
+
.forCreate(this.queryContext);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = EntityCreator;
|
|
39
|
+
//# sourceMappingURL=EntityCreator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityCreator.js","sourceRoot":"","sources":["../src/EntityCreator.ts"],"names":[],"mappings":";;;;;AACA,sFAA8D;AAO9D;;GAEG;AACH,MAAqB,aAAa;IAgBb;IACA;IACA;IAHnB,YACmB,aAA8B,EAC9B,YAAgC,EAChC,WAOhB;QATgB,kBAAa,GAAb,aAAa,CAAiB;QAC9B,iBAAY,GAAZ,YAAY,CAAoB;QAChC,gBAAW,GAAX,WAAW,CAO3B;IACA,CAAC;IAEJ;;;OAGG;IACH,SAAS;QAQP,OAAO,IAAI,gCAAsB,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,wBAAwB;QAQtB,OAAO,IAAI,CAAC,aAAa;aACtB,sCAAsC,CAAC,IAAI,CAAC,WAAW,CAAC;aACxD,iBAAiB,EAAE;aACnB,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;CACF;AA7DD,gCA6DC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AuthorizationResultBasedDeleteMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
+
import EnforcingEntityDeleter from './EnforcingEntityDeleter';
|
|
3
|
+
import { IEntityClass } from './Entity';
|
|
4
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
5
|
+
import { EntityQueryContext } from './EntityQueryContext';
|
|
6
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
7
|
+
import ViewerContext from './ViewerContext';
|
|
8
|
+
/**
|
|
9
|
+
* The primary interface for deleting entities.
|
|
10
|
+
*/
|
|
11
|
+
export default class EntityDeleter<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
12
|
+
private readonly existingEntity;
|
|
13
|
+
private readonly queryContext;
|
|
14
|
+
private readonly entityClass;
|
|
15
|
+
constructor(existingEntity: TEntity, queryContext: EntityQueryContext, entityClass: IEntityClass<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
16
|
+
/**
|
|
17
|
+
* Enforcing entity deleter. All deletes through this deleter are
|
|
18
|
+
* guaranteed to be successful and will throw otherwise.
|
|
19
|
+
*/
|
|
20
|
+
enforcing(): EnforcingEntityDeleter<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
21
|
+
/**
|
|
22
|
+
* Authorization-result-based entity deleter. All deletes through this
|
|
23
|
+
* deleter are results, where an unsuccessful result means an authorization
|
|
24
|
+
* error or entity construction error occurred. Other errors are thrown.
|
|
25
|
+
*/
|
|
26
|
+
withAuthorizationResults(): AuthorizationResultBasedDeleteMutator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 EnforcingEntityDeleter_1 = __importDefault(require("./EnforcingEntityDeleter"));
|
|
7
|
+
/**
|
|
8
|
+
* The primary interface for deleting entities.
|
|
9
|
+
*/
|
|
10
|
+
class EntityDeleter {
|
|
11
|
+
existingEntity;
|
|
12
|
+
queryContext;
|
|
13
|
+
entityClass;
|
|
14
|
+
constructor(existingEntity, queryContext, entityClass) {
|
|
15
|
+
this.existingEntity = existingEntity;
|
|
16
|
+
this.queryContext = queryContext;
|
|
17
|
+
this.entityClass = entityClass;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Enforcing entity deleter. All deletes through this deleter are
|
|
21
|
+
* guaranteed to be successful and will throw otherwise.
|
|
22
|
+
*/
|
|
23
|
+
enforcing() {
|
|
24
|
+
return new EnforcingEntityDeleter_1.default(this.withAuthorizationResults());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Authorization-result-based entity deleter. All deletes through this
|
|
28
|
+
* deleter are results, where an unsuccessful result means an authorization
|
|
29
|
+
* error or entity construction error occurred. Other errors are thrown.
|
|
30
|
+
*/
|
|
31
|
+
withAuthorizationResults() {
|
|
32
|
+
return this.existingEntity
|
|
33
|
+
.getViewerContext()
|
|
34
|
+
.getViewerScopedEntityCompanionForClass(this.entityClass)
|
|
35
|
+
.getMutatorFactory()
|
|
36
|
+
.forDelete(this.existingEntity, this.queryContext);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = EntityDeleter;
|
|
40
|
+
//# sourceMappingURL=EntityDeleter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityDeleter.js","sourceRoot":"","sources":["../src/EntityDeleter.ts"],"names":[],"mappings":";;;;;AACA,sFAA8D;AAO9D;;GAEG;AACH,MAAqB,aAAa;IAeb;IACA;IACA;IAHnB,YACmB,cAAuB,EACvB,YAAgC,EAChC,WAOhB;QATgB,mBAAc,GAAd,cAAc,CAAS;QACvB,iBAAY,GAAZ,YAAY,CAAoB;QAChC,gBAAW,GAAX,WAAW,CAO3B;IACA,CAAC;IAEJ;;;OAGG;IACH,SAAS;QAQP,OAAO,IAAI,gCAAsB,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACH,wBAAwB;QAQtB,OAAO,IAAI,CAAC,cAAc;aACvB,gBAAgB,EAAE;aAClB,sCAAsC,CAAC,IAAI,CAAC,WAAW,CAAC;aACxD,iBAAiB,EAAE;aACnB,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;CACF;AA7DD,gCA6DC"}
|
package/build/EntityLoader.d.ts
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import AuthorizationResultBasedEntityLoader from './AuthorizationResultBasedEntityLoader';
|
|
2
2
|
import EnforcingEntityLoader from './EnforcingEntityLoader';
|
|
3
3
|
import { IEntityClass } from './Entity';
|
|
4
|
-
import EntityConfiguration from './EntityConfiguration';
|
|
5
4
|
import EntityLoaderUtils from './EntityLoaderUtils';
|
|
6
|
-
import EntityPrivacyPolicy
|
|
5
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
7
6
|
import { EntityQueryContext } from './EntityQueryContext';
|
|
8
7
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
9
8
|
import ViewerContext from './ViewerContext';
|
|
10
|
-
import EntityDataManager from './internal/EntityDataManager';
|
|
11
|
-
import IEntityMetricsAdapter from './metrics/IEntityMetricsAdapter';
|
|
12
9
|
/**
|
|
13
10
|
* The primary interface for loading entities. All normal loads are batched,
|
|
14
11
|
* cached, and authorized against the entity's EntityPrivacyPolicy.
|
|
15
12
|
*/
|
|
16
|
-
export default class EntityLoader<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
13
|
+
export default class EntityLoader<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TViewerContext2 extends TViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TPrivacyPolicy extends EntityPrivacyPolicy<TFields, TID, TViewerContext, TEntity, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
17
14
|
private readonly viewerContext;
|
|
18
15
|
private readonly queryContext;
|
|
19
|
-
private readonly privacyPolicyEvaluationContext;
|
|
20
|
-
private readonly entityConfiguration;
|
|
21
16
|
private readonly entityClass;
|
|
22
|
-
|
|
23
|
-
private readonly privacyPolicy;
|
|
24
|
-
private readonly dataManager;
|
|
25
|
-
protected readonly metricsAdapter: IEntityMetricsAdapter;
|
|
26
|
-
private readonly utilsPrivate;
|
|
27
|
-
constructor(viewerContext: TViewerContext, queryContext: EntityQueryContext, privacyPolicyEvaluationContext: EntityPrivacyPolicyEvaluationContext<TFields, TID, TViewerContext, TEntity, TSelectedFields>, entityConfiguration: EntityConfiguration<TFields>, entityClass: IEntityClass<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>, entitySelectedFields: TSelectedFields[] | undefined, privacyPolicy: TPrivacyPolicy, dataManager: EntityDataManager<TFields>, metricsAdapter: IEntityMetricsAdapter);
|
|
17
|
+
constructor(viewerContext: TViewerContext2, queryContext: EntityQueryContext, entityClass: IEntityClass<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
28
18
|
/**
|
|
29
19
|
* Enforcing entity loader. All loads through this loader are
|
|
30
20
|
* guaranteed to be the values of successful results (or null for some loader methods),
|
|
@@ -33,7 +23,7 @@ export default class EntityLoader<TFields extends object, TID extends NonNullabl
|
|
|
33
23
|
enforcing(): EnforcingEntityLoader<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
34
24
|
/**
|
|
35
25
|
* Authorization-result-based entity loader. All loads through this
|
|
36
|
-
* loader are
|
|
26
|
+
* loader are results (or null for some loader methods), where an unsuccessful result
|
|
37
27
|
* means an authorization error or entity construction error occurred. Other errors are thrown.
|
|
38
28
|
*/
|
|
39
29
|
withAuthorizationResults(): AuthorizationResultBasedEntityLoader<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
package/build/EntityLoader.js
CHANGED
|
@@ -3,9 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const AuthorizationResultBasedEntityLoader_1 = __importDefault(require("./AuthorizationResultBasedEntityLoader"));
|
|
7
6
|
const EnforcingEntityLoader_1 = __importDefault(require("./EnforcingEntityLoader"));
|
|
8
|
-
const EntityLoaderUtils_1 = __importDefault(require("./EntityLoaderUtils"));
|
|
9
7
|
/**
|
|
10
8
|
* The primary interface for loading entities. All normal loads are batched,
|
|
11
9
|
* cached, and authorized against the entity's EntityPrivacyPolicy.
|
|
@@ -13,25 +11,11 @@ const EntityLoaderUtils_1 = __importDefault(require("./EntityLoaderUtils"));
|
|
|
13
11
|
class EntityLoader {
|
|
14
12
|
viewerContext;
|
|
15
13
|
queryContext;
|
|
16
|
-
privacyPolicyEvaluationContext;
|
|
17
|
-
entityConfiguration;
|
|
18
14
|
entityClass;
|
|
19
|
-
|
|
20
|
-
privacyPolicy;
|
|
21
|
-
dataManager;
|
|
22
|
-
metricsAdapter;
|
|
23
|
-
utilsPrivate;
|
|
24
|
-
constructor(viewerContext, queryContext, privacyPolicyEvaluationContext, entityConfiguration, entityClass, entitySelectedFields, privacyPolicy, dataManager, metricsAdapter) {
|
|
15
|
+
constructor(viewerContext, queryContext, entityClass) {
|
|
25
16
|
this.viewerContext = viewerContext;
|
|
26
17
|
this.queryContext = queryContext;
|
|
27
|
-
this.privacyPolicyEvaluationContext = privacyPolicyEvaluationContext;
|
|
28
|
-
this.entityConfiguration = entityConfiguration;
|
|
29
18
|
this.entityClass = entityClass;
|
|
30
|
-
this.entitySelectedFields = entitySelectedFields;
|
|
31
|
-
this.privacyPolicy = privacyPolicy;
|
|
32
|
-
this.dataManager = dataManager;
|
|
33
|
-
this.metricsAdapter = metricsAdapter;
|
|
34
|
-
this.utilsPrivate = new EntityLoaderUtils_1.default(this.viewerContext, this.queryContext, this.privacyPolicyEvaluationContext, this.entityConfiguration, this.entityClass, this.entitySelectedFields, this.privacyPolicy, this.dataManager, this.metricsAdapter);
|
|
35
19
|
}
|
|
36
20
|
/**
|
|
37
21
|
* Enforcing entity loader. All loads through this loader are
|
|
@@ -43,18 +27,21 @@ class EntityLoader {
|
|
|
43
27
|
}
|
|
44
28
|
/**
|
|
45
29
|
* Authorization-result-based entity loader. All loads through this
|
|
46
|
-
* loader are
|
|
30
|
+
* loader are results (or null for some loader methods), where an unsuccessful result
|
|
47
31
|
* means an authorization error or entity construction error occurred. Other errors are thrown.
|
|
48
32
|
*/
|
|
49
33
|
withAuthorizationResults() {
|
|
50
|
-
return
|
|
34
|
+
return this.viewerContext
|
|
35
|
+
.getViewerScopedEntityCompanionForClass(this.entityClass)
|
|
36
|
+
.getLoaderFactory()
|
|
37
|
+
.forLoad(this.queryContext, { previousValue: null, cascadingDeleteCause: null });
|
|
51
38
|
}
|
|
52
39
|
/**
|
|
53
40
|
* Entity loader utilities for things like cache invalidation, entity construction, and authorization.
|
|
54
41
|
* Calling into these should only be necessary in rare cases.
|
|
55
42
|
*/
|
|
56
43
|
utils() {
|
|
57
|
-
return this.
|
|
44
|
+
return this.withAuthorizationResults().utils;
|
|
58
45
|
}
|
|
59
46
|
}
|
|
60
47
|
exports.default = EntityLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityLoader.js","sourceRoot":"","sources":["../src/EntityLoader.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"EntityLoader.js","sourceRoot":"","sources":["../src/EntityLoader.ts"],"names":[],"mappings":";;;;;AACA,oFAA4D;AAQ5D;;;GAGG;AACH,MAAqB,YAAY;IAgBZ;IACA;IACA;IAHnB,YACmB,aAA8B,EAC9B,YAAgC,EAChC,WAOhB;QATgB,kBAAa,GAAb,aAAa,CAAiB;QAC9B,iBAAY,GAAZ,YAAY,CAAoB;QAChC,gBAAW,GAAX,WAAW,CAO3B;IACA,CAAC;IAEJ;;;;OAIG;IACH,SAAS;QAQP,OAAO,IAAI,+BAAqB,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,wBAAwB;QAQtB,OAAO,IAAI,CAAC,aAAa;aACtB,sCAAsC,CAAC,IAAI,CAAC,WAAW,CAAC;aACxD,gBAAgB,EAAE;aAClB,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;OAGG;IACI,KAAK;QAQV,OAAO,IAAI,CAAC,wBAAwB,EAAE,CAAC,KAAK,CAAC;IAC/C,CAAC;CACF;AA7ED,+BA6EC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import AuthorizationResultBasedEntityLoader from './AuthorizationResultBasedEntityLoader';
|
|
1
2
|
import EntityCompanion from './EntityCompanion';
|
|
2
|
-
import EntityLoader from './EntityLoader';
|
|
3
3
|
import EntityPrivacyPolicy, { EntityPrivacyPolicyEvaluationContext } from './EntityPrivacyPolicy';
|
|
4
4
|
import { EntityQueryContext } from './EntityQueryContext';
|
|
5
5
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
@@ -19,5 +19,5 @@ export default class EntityLoaderFactory<TFields extends object, TID extends Non
|
|
|
19
19
|
* @param viewerContext - viewer context of loading user
|
|
20
20
|
* @param queryContext - query context in which to perform the load
|
|
21
21
|
*/
|
|
22
|
-
forLoad(viewerContext: TViewerContext, queryContext: EntityQueryContext, privacyPolicyEvaluationContext: EntityPrivacyPolicyEvaluationContext<TFields, TID, TViewerContext, TEntity, TSelectedFields>):
|
|
22
|
+
forLoad(viewerContext: TViewerContext, queryContext: EntityQueryContext, privacyPolicyEvaluationContext: EntityPrivacyPolicyEvaluationContext<TFields, TID, TViewerContext, TEntity, TSelectedFields>): AuthorizationResultBasedEntityLoader<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>;
|
|
23
23
|
}
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const AuthorizationResultBasedEntityLoader_1 = __importDefault(require("./AuthorizationResultBasedEntityLoader"));
|
|
7
|
+
const EntityLoaderUtils_1 = __importDefault(require("./EntityLoaderUtils"));
|
|
7
8
|
/**
|
|
8
9
|
* The primary entry point for loading entities.
|
|
9
10
|
*/
|
|
@@ -22,7 +23,8 @@ class EntityLoaderFactory {
|
|
|
22
23
|
* @param queryContext - query context in which to perform the load
|
|
23
24
|
*/
|
|
24
25
|
forLoad(viewerContext, queryContext, privacyPolicyEvaluationContext) {
|
|
25
|
-
|
|
26
|
+
const utils = new EntityLoaderUtils_1.default(viewerContext, queryContext, privacyPolicyEvaluationContext, this.entityCompanion.entityCompanionDefinition.entityConfiguration, this.entityCompanion.entityCompanionDefinition.entityClass, this.entityCompanion.entityCompanionDefinition.entitySelectedFields, this.entityCompanion.privacyPolicy, this.dataManager, this.metricsAdapter);
|
|
27
|
+
return new AuthorizationResultBasedEntityLoader_1.default(queryContext, this.entityCompanion.entityCompanionDefinition.entityConfiguration, this.entityCompanion.entityCompanionDefinition.entityClass, this.dataManager, this.metricsAdapter, utils);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
exports.default = EntityLoaderFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityLoaderFactory.js","sourceRoot":"","sources":["../src/EntityLoaderFactory.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"EntityLoaderFactory.js","sourceRoot":"","sources":["../src/EntityLoaderFactory.ts"],"names":[],"mappings":";;;;;AAAA,kHAA0F;AAE1F,4EAAoD;AAQpD;;GAEG;AACH,MAAqB,mBAAmB;IAenB;IAQA;IACE;IAVrB,YACmB,eAOhB,EACgB,WAAuC,EACrC,cAAqC;QATvC,oBAAe,GAAf,eAAe,CAO/B;QACgB,gBAAW,GAAX,WAAW,CAA4B;QACrC,mBAAc,GAAd,cAAc,CAAuB;IACvD,CAAC;IAEJ;;;;OAIG;IACH,OAAO,CACL,aAA6B,EAC7B,YAAgC,EAChC,8BAMC;QASD,MAAM,KAAK,GAAG,IAAI,2BAAiB,CACjC,aAAa,EACb,YAAY,EACZ,8BAA8B,EAC9B,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,mBAAmB,EAClE,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,WAAW,EAC1D,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,oBAAoB,EACnE,IAAI,CAAC,eAAe,CAAC,aAAa,EAClC,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,cAAc,CACpB,CAAC;QAEF,OAAO,IAAI,8CAAoC,CAC7C,YAAY,EACZ,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,mBAAmB,EAClE,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,WAAW,EAC1D,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,cAAc,EACnB,KAAK,CACN,CAAC;IACJ,CAAC;CACF;AAvED,sCAuEC"}
|