@expo/entity 0.38.0 → 0.40.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 +124 -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 +8 -12
- package/build/Entity.js +9 -34
- 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/EntityCompanionProvider.d.ts +2 -2
- package/build/EntityCompanionProvider.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/EntityDatabaseAdapter.js +2 -2
- package/build/EntityDatabaseAdapter.js.map +1 -1
- 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 +2 -2
- package/build/ReadonlyEntity.js +4 -6
- 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 +273 -0
- package/build/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.js.map +1 -0
- package/build/__tests__/{EntityLoader-constructor-test.js → AuthorizationResultBasedEntityLoader-constructor-test.js} +11 -11
- 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 +23 -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 -12
- 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__/EntityDatabaseAdapter-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +41 -23
- 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 +4 -3
- 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 +36 -24
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ReadonlyEntity-test.js +1 -1
- package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +4 -2
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +7 -4
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/__tests__/entityUtils-test.js +8 -0
- package/build/__tests__/entityUtils-test.js.map +1 -1
- package/build/entityUtils.d.ts +7 -0
- package/build/entityUtils.js +20 -10
- package/build/entityUtils.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/EntityFieldTransformationUtils.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.d.ts +32 -4
- package/build/utils/EntityPrivacyUtils.js +68 -24
- package/build/utils/EntityPrivacyUtils.js.map +1 -1
- package/build/utils/__tests__/EntityPrivacyUtils-test.js +148 -23
- package/build/utils/__tests__/EntityPrivacyUtils-test.js.map +1 -1
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js +8 -5
- package/build/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.js.map +1 -1
- package/build/utils/collections/__tests__/maps-test.js +1 -1
- package/build/utils/collections/__tests__/maps-test.js.map +1 -1
- package/build/utils/collections/maps.js +2 -2
- package/build/utils/collections/maps.js.map +1 -1
- package/build/utils/mergeEntityMutationTriggerConfigurations.js +1 -2
- package/build/utils/mergeEntityMutationTriggerConfigurations.js.map +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.js +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.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/build/utils/testing/describeFieldTestCase.js +1 -1
- package/build/utils/testing/describeFieldTestCase.js.map +1 -1
- package/package.json +19 -3
- package/src/AuthorizationResultBasedEntityAssociationLoader.ts +492 -0
- package/src/AuthorizationResultBasedEntityLoader.ts +2 -2
- 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 +20 -65
- package/src/EntityAssociationLoader.ts +38 -495
- package/src/EntityCompanionProvider.ts +5 -2
- 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 +14 -13
- package/src/ViewerScopedEntityLoaderFactory.ts +9 -2
- package/src/ViewerScopedEntityMutatorFactory.ts +29 -4
- package/src/__tests__/AuthorizationResultBasedEntityAssociationLoader-test.ts +354 -0
- package/src/__tests__/{EntityLoader-constructor-test.ts → AuthorizationResultBasedEntityLoader-constructor-test.ts} +17 -10
- package/src/__tests__/AuthorizationResultBasedEntityLoader-test.ts +730 -0
- package/src/__tests__/EnforcingEntityAssociationLoader-test.ts +253 -0
- package/src/__tests__/Entity-test.ts +24 -5
- package/src/__tests__/EntityAssociationLoader-test.ts +16 -259
- package/src/__tests__/EntityCommonUseCases-test.ts +20 -8
- package/src/__tests__/EntityCompanion-test.ts +1 -1
- package/src/__tests__/EntityDatabaseAdapter-test.ts +6 -6
- package/src/__tests__/EntityEdges-test.ts +24 -16
- package/src/__tests__/EntityLoader-test.ts +25 -675
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +4 -3
- package/src/__tests__/EntityMutator-test.ts +116 -103
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +7 -7
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +36 -24
- package/src/__tests__/ReadonlyEntity-test.ts +1 -1
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +4 -2
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +7 -4
- package/src/__tests__/entityUtils-test.ts +12 -0
- package/src/entityUtils.ts +24 -9
- package/src/index.ts +19 -11
- package/src/internal/EntityFieldTransformationUtils.ts +2 -2
- package/src/internal/__tests__/EntityDataManager-test.ts +29 -29
- package/src/utils/EntityPrivacyUtils.ts +188 -107
- package/src/utils/__tests__/EntityPrivacyUtils-test.ts +169 -29
- package/src/utils/__tests__/canViewerDeleteAsync-edgeDeletionPermissionInferenceBehavior-test.ts +8 -5
- package/src/utils/collections/__tests__/maps-test.ts +1 -1
- package/src/utils/testing/PrivacyPolicyRuleTestUtils.ts +1 -1
- package/src/utils/testing/StubDatabaseAdapter.ts +1 -1
- 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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import AuthorizationResultBasedEntityAssociationLoader, { EntityLoadThroughDirective } from './AuthorizationResultBasedEntityAssociationLoader';
|
|
2
|
+
import { IEntityClass } from './Entity';
|
|
3
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
4
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
5
|
+
import ViewerContext from './ViewerContext';
|
|
6
|
+
/**
|
|
7
|
+
* An association loader is a set of convenience methods for loading entities
|
|
8
|
+
* associated with an entity. In relational databases, these entities are often referenced
|
|
9
|
+
* by foreign keys.
|
|
10
|
+
*/
|
|
11
|
+
export default class EnforcingEntityAssociationLoader<TFields extends object, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> {
|
|
12
|
+
private readonly authorizationResultBasedEntityAssociationLoader;
|
|
13
|
+
constructor(authorizationResultBasedEntityAssociationLoader: AuthorizationResultBasedEntityAssociationLoader<TFields, TID, TViewerContext, TEntity, TSelectedFields>);
|
|
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
|
+
*/
|
|
20
|
+
loadAssociatedEntityAsync<TIdentifyingField extends keyof Pick<TFields, TSelectedFields>, 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: TIdentifyingField, associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>): Promise<null extends TFields[TIdentifyingField] ? TAssociatedEntity | null : TAssociatedEntity>;
|
|
21
|
+
/**
|
|
22
|
+
* Load many entities associated with this entity, often referred to as entites belonging
|
|
23
|
+
* to this entity. In a relational database, the field in the foreign entity is a
|
|
24
|
+
* foreign key to the ID of this entity. Also commonly referred to as a has many relationship,
|
|
25
|
+
* where this entity has many associated entities.
|
|
26
|
+
* @param associatedEntityClass - class of the associated entities
|
|
27
|
+
* @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity
|
|
28
|
+
*/
|
|
29
|
+
loadManyAssociatedEntitiesAsync<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>(associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>, associatedEntityFieldContainingThisID: keyof Pick<TAssociatedFields, TAssociatedSelectedFields>): Promise<readonly TAssociatedEntity[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Load an associated entity identified by a field value of this entity. In a relational database,
|
|
32
|
+
* the field in this entity is a foreign key to a unique field of the associated entity.
|
|
33
|
+
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entity
|
|
34
|
+
* @param associatedEntityClass - class of the associated entity
|
|
35
|
+
* @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity
|
|
36
|
+
*/
|
|
37
|
+
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>): Promise<TAssociatedEntity | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Load many associated entities identified by a field value of this entity. In a relational database,
|
|
40
|
+
* the field in this entity refers to a field of the associated entity.
|
|
41
|
+
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entities
|
|
42
|
+
* @param associatedEntityClass - class of the associated entities
|
|
43
|
+
* @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities
|
|
44
|
+
*/
|
|
45
|
+
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>): Promise<readonly TAssociatedEntity[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
48
|
+
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
49
|
+
* @param loadDirectives - associated entity load directives instructing each step of the folds
|
|
50
|
+
*/
|
|
51
|
+
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: [
|
|
52
|
+
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>
|
|
53
|
+
]): Promise<TEntity2 | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
56
|
+
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
57
|
+
* @param loadDirectives - associated entity load directives instructing each step of the folds
|
|
58
|
+
*/
|
|
59
|
+
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: [
|
|
60
|
+
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>,
|
|
61
|
+
EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>
|
|
62
|
+
]): Promise<TEntity3 | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
65
|
+
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
66
|
+
* @param loadDirectives - associated entity load directives instructing each step of the folds
|
|
67
|
+
*/
|
|
68
|
+
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: [
|
|
69
|
+
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>,
|
|
70
|
+
EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>,
|
|
71
|
+
EntityLoadThroughDirective<TViewerContext, TFields3, TFields4, TID4, TEntity4, TPrivacyPolicy4, TSelectedFields3, TSelectedFields4>
|
|
72
|
+
]): Promise<TEntity4 | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
75
|
+
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
76
|
+
* @param loadDirectives - associated entity load directives instructing each step of the folds
|
|
77
|
+
*/
|
|
78
|
+
loadAssociatedEntityThroughAsync(loadDirectives: EntityLoadThroughDirective<TViewerContext, any, any, any, any, any, any, any>[]): Promise<ReadonlyEntity<any, any, any, any> | null>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const results_1 = require("@expo/results");
|
|
4
|
+
const entityUtils_1 = require("./entityUtils");
|
|
5
|
+
/**
|
|
6
|
+
* An association loader is a set of convenience methods for loading entities
|
|
7
|
+
* associated with an entity. In relational databases, these entities are often referenced
|
|
8
|
+
* by foreign keys.
|
|
9
|
+
*/
|
|
10
|
+
class EnforcingEntityAssociationLoader {
|
|
11
|
+
authorizationResultBasedEntityAssociationLoader;
|
|
12
|
+
constructor(authorizationResultBasedEntityAssociationLoader) {
|
|
13
|
+
this.authorizationResultBasedEntityAssociationLoader = authorizationResultBasedEntityAssociationLoader;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load an associated entity identified by a field value of this entity. In a relational database,
|
|
17
|
+
* the field in this entity is a foreign key to the ID of the associated entity.
|
|
18
|
+
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the ID of the associated entity
|
|
19
|
+
* @param associatedEntityClass - class of the associated entity
|
|
20
|
+
*/
|
|
21
|
+
async loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass) {
|
|
22
|
+
return await (0, results_1.enforceAsyncResult)(this.authorizationResultBasedEntityAssociationLoader.loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Load many entities associated with this entity, often referred to as entites belonging
|
|
26
|
+
* to this entity. In a relational database, the field in the foreign entity is a
|
|
27
|
+
* foreign key to the ID of this entity. Also commonly referred to as a has many relationship,
|
|
28
|
+
* where this entity has many associated entities.
|
|
29
|
+
* @param associatedEntityClass - class of the associated entities
|
|
30
|
+
* @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity
|
|
31
|
+
*/
|
|
32
|
+
async loadManyAssociatedEntitiesAsync(associatedEntityClass, associatedEntityFieldContainingThisID) {
|
|
33
|
+
return await (0, entityUtils_1.enforceResultsAsync)(this.authorizationResultBasedEntityAssociationLoader.loadManyAssociatedEntitiesAsync(associatedEntityClass, associatedEntityFieldContainingThisID));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Load an associated entity identified by a field value of this entity. In a relational database,
|
|
37
|
+
* the field in this entity is a foreign key to a unique field of the associated entity.
|
|
38
|
+
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entity
|
|
39
|
+
* @param associatedEntityClass - class of the associated entity
|
|
40
|
+
* @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity
|
|
41
|
+
*/
|
|
42
|
+
async loadAssociatedEntityByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField) {
|
|
43
|
+
const result = await this.authorizationResultBasedEntityAssociationLoader.loadAssociatedEntityByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField);
|
|
44
|
+
return result?.enforceValue() ?? null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Load many associated entities identified by a field value of this entity. In a relational database,
|
|
48
|
+
* the field in this entity refers to a field of the associated entity.
|
|
49
|
+
* @param fieldIdentifyingAssociatedEntity - field of this entity containing the value with which to look up associated entities
|
|
50
|
+
* @param associatedEntityClass - class of the associated entities
|
|
51
|
+
* @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities
|
|
52
|
+
*/
|
|
53
|
+
async loadManyAssociatedEntitiesByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField) {
|
|
54
|
+
return await (0, entityUtils_1.enforceResultsAsync)(this.authorizationResultBasedEntityAssociationLoader.loadManyAssociatedEntitiesByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField));
|
|
55
|
+
}
|
|
56
|
+
async loadAssociatedEntityThroughAsync(loadDirectives) {
|
|
57
|
+
const result = await this.authorizationResultBasedEntityAssociationLoader.loadAssociatedEntityThroughAsync(loadDirectives);
|
|
58
|
+
return result?.enforceValue() ?? null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = EnforcingEntityAssociationLoader;
|
|
62
|
+
//# sourceMappingURL=EnforcingEntityAssociationLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnforcingEntityAssociationLoader.js","sourceRoot":"","sources":["../src/EnforcingEntityAssociationLoader.ts"],"names":[],"mappings":";;AAAA,2CAAmD;AASnD,+CAAoD;AAEpD;;;;GAIG;AACH,MAAqB,gCAAgC;IAQhC;IADnB,YACmB,+CAMhB;QANgB,oDAA+C,GAA/C,+CAA+C,CAM/D;IACA,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,yBAAyB,CAmB7B,gCAAmD,EACnD,qBAOC;QAID,OAAO,MAAM,IAAA,4BAAkB,EAC7B,IAAI,CAAC,+CAA+C,CAAC,yBAAyB,CAC5E,gCAAgC,EAChC,qBAAqB,CACtB,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,+BAA+B,CAkBnC,qBAOC,EACD,qCAA+F;QAE/F,OAAO,MAAM,IAAA,iCAAmB,EAC9B,IAAI,CAAC,+CAA+C,CAAC,+BAA+B,CAClF,qBAAqB,EACrB,qCAAqC,CACtC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,wCAAwC,CAkB5C,gCAAsE,EACtE,qBAOC,EACD,6BAAuF;QAEvF,MAAM,MAAM,GACV,MAAM,IAAI,CAAC,+CAA+C,CAAC,wCAAwC,CACjG,gCAAgC,EAChC,qBAAqB,EACrB,6BAA6B,CAC9B,CAAC;QACJ,OAAO,MAAM,EAAE,YAAY,EAAE,IAAI,IAAI,CAAC;IACxC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,8CAA8C,CAkBlD,gCAAsE,EACtE,qBAOC,EACD,6BAAuF;QAEvF,OAAO,MAAM,IAAA,iCAAmB,EAC9B,IAAI,CAAC,+CAA+C,CAAC,8CAA8C,CACjG,gCAAgC,EAChC,qBAAqB,EACrB,6BAA6B,CAC9B,CACF,CAAC;IACJ,CAAC;IA0KD,KAAK,CAAC,gCAAgC,CACpC,cAA+F;QAE/F,MAAM,MAAM,GACV,MAAM,IAAI,CAAC,+CAA+C,CAAC,gCAAgC,CACzF,cAAc,CACf,CAAC;QACJ,OAAO,MAAM,EAAE,YAAY,EAAE,IAAI,IAAI,CAAC;IACxC,CAAC;CACF;AArXD,mDAqXC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AuthorizationResultBasedCreateMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
3
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
4
|
+
import ViewerContext from './ViewerContext';
|
|
5
|
+
/**
|
|
6
|
+
* Enforcing entity creator. All updates
|
|
7
|
+
* through this creator will throw if authorization is not successful.
|
|
8
|
+
*/
|
|
9
|
+
export default class EnforcingEntityCreator<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> {
|
|
10
|
+
private readonly entityCreator;
|
|
11
|
+
constructor(entityCreator: AuthorizationResultBasedCreateMutator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
12
|
+
/**
|
|
13
|
+
* Set the value for entity field.
|
|
14
|
+
* @param fieldName - entity field being updated
|
|
15
|
+
* @param value - value for entity field
|
|
16
|
+
*/
|
|
17
|
+
setField<K extends keyof Pick<TFields, TSelectedFields>>(fieldName: K, value: TFields[K]): this;
|
|
18
|
+
/**
|
|
19
|
+
* Commit the new entity after authorizing against creation privacy rules. Invalidates all caches for
|
|
20
|
+
* queries that would return new entity.
|
|
21
|
+
* @returns authorized, cached, newly-created entity, throwing if unsuccessful
|
|
22
|
+
*/
|
|
23
|
+
createAsync(): Promise<TEntity>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const results_1 = require("@expo/results");
|
|
4
|
+
/**
|
|
5
|
+
* Enforcing entity creator. All updates
|
|
6
|
+
* through this creator will throw if authorization is not successful.
|
|
7
|
+
*/
|
|
8
|
+
class EnforcingEntityCreator {
|
|
9
|
+
entityCreator;
|
|
10
|
+
constructor(entityCreator) {
|
|
11
|
+
this.entityCreator = entityCreator;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set the value for entity field.
|
|
15
|
+
* @param fieldName - entity field being updated
|
|
16
|
+
* @param value - value for entity field
|
|
17
|
+
*/
|
|
18
|
+
setField(fieldName, value) {
|
|
19
|
+
this.entityCreator.setField(fieldName, value);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Commit the new entity after authorizing against creation privacy rules. Invalidates all caches for
|
|
24
|
+
* queries that would return new entity.
|
|
25
|
+
* @returns authorized, cached, newly-created entity, throwing if unsuccessful
|
|
26
|
+
*/
|
|
27
|
+
async createAsync() {
|
|
28
|
+
return await (0, results_1.enforceAsyncResult)(this.entityCreator.createAsync());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = EnforcingEntityCreator;
|
|
32
|
+
//# sourceMappingURL=EnforcingEntityCreator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnforcingEntityCreator.js","sourceRoot":"","sources":["../src/EnforcingEntityCreator.ts"],"names":[],"mappings":";;AAAA,2CAAmD;AAOnD;;;GAGG;AACH,MAAqB,sBAAsB;IAetB;IADnB,YACmB,aAOhB;QAPgB,kBAAa,GAAb,aAAa,CAO7B;IACA,CAAC;IAEJ;;;;OAIG;IACH,QAAQ,CAAiD,SAAY,EAAE,KAAiB;QACtF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAA,4BAAkB,EAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AA3CD,yCA2CC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthorizationResultBasedDeleteMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
3
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
4
|
+
import ViewerContext from './ViewerContext';
|
|
5
|
+
/**
|
|
6
|
+
* Enforcing entity deleter. All deletes
|
|
7
|
+
* through this deleter will throw if authorization is not successful.
|
|
8
|
+
*/
|
|
9
|
+
export default class EnforcingEntityDeleter<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> {
|
|
10
|
+
private readonly entityDeleter;
|
|
11
|
+
constructor(entityDeleter: AuthorizationResultBasedDeleteMutator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
12
|
+
/**
|
|
13
|
+
* Delete the entity after authorizing against delete privacy rules. The entity is invalidated in all caches.
|
|
14
|
+
* Throws when delete is not successful.
|
|
15
|
+
*/
|
|
16
|
+
deleteAsync(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const results_1 = require("@expo/results");
|
|
4
|
+
/**
|
|
5
|
+
* Enforcing entity deleter. All deletes
|
|
6
|
+
* through this deleter will throw if authorization is not successful.
|
|
7
|
+
*/
|
|
8
|
+
class EnforcingEntityDeleter {
|
|
9
|
+
entityDeleter;
|
|
10
|
+
constructor(entityDeleter) {
|
|
11
|
+
this.entityDeleter = entityDeleter;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Delete the entity after authorizing against delete privacy rules. The entity is invalidated in all caches.
|
|
15
|
+
* Throws when delete is not successful.
|
|
16
|
+
*/
|
|
17
|
+
async deleteAsync() {
|
|
18
|
+
await (0, results_1.enforceAsyncResult)(this.entityDeleter.deleteAsync());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.default = EnforcingEntityDeleter;
|
|
22
|
+
//# sourceMappingURL=EnforcingEntityDeleter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnforcingEntityDeleter.js","sourceRoot":"","sources":["../src/EnforcingEntityDeleter.ts"],"names":[],"mappings":";;AAAA,2CAAmD;AAOnD;;;GAGG;AACH,MAAqB,sBAAsB;IAetB;IADnB,YACmB,aAOhB;QAPgB,kBAAa,GAAb,aAAa,CAO7B;IACA,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAA,4BAAkB,EAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAhCD,yCAgCC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AuthorizationResultBasedUpdateMutator } from './AuthorizationResultBasedEntityMutator';
|
|
2
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
3
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
4
|
+
import ViewerContext from './ViewerContext';
|
|
5
|
+
/**
|
|
6
|
+
* Enforcing entity updater. All updates
|
|
7
|
+
* through this updater will throw if authorization is not successful.
|
|
8
|
+
*/
|
|
9
|
+
export default class EnforcingEntityUpdater<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> {
|
|
10
|
+
private readonly entityUpdater;
|
|
11
|
+
constructor(entityUpdater: AuthorizationResultBasedUpdateMutator<TFields, TID, TViewerContext, TEntity, TPrivacyPolicy, TSelectedFields>);
|
|
12
|
+
/**
|
|
13
|
+
* Set the value for entity field.
|
|
14
|
+
* @param fieldName - entity field being updated
|
|
15
|
+
* @param value - value for entity field
|
|
16
|
+
*/
|
|
17
|
+
setField<K extends keyof Pick<TFields, TSelectedFields>>(fieldName: K, value: TFields[K]): this;
|
|
18
|
+
/**
|
|
19
|
+
* Commit the changes to the entity after authorizing against update privacy rules.
|
|
20
|
+
* Invalidates all caches for pre-update entity.
|
|
21
|
+
* @returns authorized updated entity, throws upon update failure
|
|
22
|
+
*/
|
|
23
|
+
updateAsync(): Promise<TEntity>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const results_1 = require("@expo/results");
|
|
4
|
+
/**
|
|
5
|
+
* Enforcing entity updater. All updates
|
|
6
|
+
* through this updater will throw if authorization is not successful.
|
|
7
|
+
*/
|
|
8
|
+
class EnforcingEntityUpdater {
|
|
9
|
+
entityUpdater;
|
|
10
|
+
constructor(entityUpdater) {
|
|
11
|
+
this.entityUpdater = entityUpdater;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set the value for entity field.
|
|
15
|
+
* @param fieldName - entity field being updated
|
|
16
|
+
* @param value - value for entity field
|
|
17
|
+
*/
|
|
18
|
+
setField(fieldName, value) {
|
|
19
|
+
this.entityUpdater.setField(fieldName, value);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Commit the changes to the entity after authorizing against update privacy rules.
|
|
24
|
+
* Invalidates all caches for pre-update entity.
|
|
25
|
+
* @returns authorized updated entity, throws upon update failure
|
|
26
|
+
*/
|
|
27
|
+
async updateAsync() {
|
|
28
|
+
return await (0, results_1.enforceAsyncResult)(this.entityUpdater.updateAsync());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = EnforcingEntityUpdater;
|
|
32
|
+
//# sourceMappingURL=EnforcingEntityUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnforcingEntityUpdater.js","sourceRoot":"","sources":["../src/EnforcingEntityUpdater.ts"],"names":[],"mappings":";;AAAA,2CAAmD;AAOnD;;;GAGG;AACH,MAAqB,sBAAsB;IAetB;IADnB,YACmB,aAOhB;QAPgB,kBAAa,GAAb,aAAa,CAO7B;IACA,CAAC;IAEJ;;;;OAIG;IACH,QAAQ,CAAiD,SAAY,EAAE,KAAiB;QACtF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,MAAM,IAAA,4BAAkB,EAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AA3CD,yCA2CC"}
|
package/build/Entity.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Result } from '@expo/results';
|
|
2
1
|
import { EntityCompanionDefinition } from './EntityCompanionProvider';
|
|
3
|
-
import
|
|
2
|
+
import EntityCreator from './EntityCreator';
|
|
3
|
+
import EntityDeleter from './EntityDeleter';
|
|
4
4
|
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
5
5
|
import { EntityQueryContext } from './EntityQueryContext';
|
|
6
|
+
import EntityUpdater from './EntityUpdater';
|
|
6
7
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
7
8
|
import ViewerContext from './ViewerContext';
|
|
8
9
|
/**
|
|
@@ -30,26 +31,21 @@ export default abstract class Entity<TFields extends object, TID extends NonNull
|
|
|
30
31
|
* @param queryContext - query context in which to perform the create
|
|
31
32
|
* @returns mutator for creating an entity
|
|
32
33
|
*/
|
|
33
|
-
static creator<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext):
|
|
34
|
+
static creator<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, viewerContext: TMViewerContext2, queryContext?: EntityQueryContext): EntityCreator<TMFields, TMID, TMViewerContext, TMViewerContext2, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
34
35
|
/**
|
|
35
36
|
* Vend mutator for updating an existing entity in given query context.
|
|
36
37
|
* @param existingEntity - entity to update
|
|
37
38
|
* @param queryContext - query context in which to perform the update
|
|
38
39
|
* @returns mutator for updating existingEntity
|
|
39
40
|
*/
|
|
40
|
-
static updater<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext):
|
|
41
|
+
static updater<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EntityUpdater<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Vend mutator for deleting an existing entity in given query context.
|
|
43
44
|
* @param existingEntity - entity to delete
|
|
44
45
|
* @param queryContext - query context in which to perform the delete
|
|
46
|
+
* @returns mutator for deleting existingEntity
|
|
45
47
|
*/
|
|
46
|
-
static
|
|
47
|
-
/**
|
|
48
|
-
* Delete an existing entity in given query context, throwing if deletion is unsuccessful.
|
|
49
|
-
* @param existingEntity - entity to delete
|
|
50
|
-
* @param queryContext - query context in which to perform the delete
|
|
51
|
-
*/
|
|
52
|
-
static enforceDeleteAsync<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): Promise<void>;
|
|
48
|
+
static deleter<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>, TMPrivacyPolicy extends EntityPrivacyPolicy<TMFields, TMID, TMViewerContext, TMEntity, TMSelectedFields>, TMSelectedFields extends keyof TMFields = keyof TMFields>(this: IEntityClass<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>, existingEntity: TMEntity, queryContext?: EntityQueryContext): EntityDeleter<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
55
51
|
* An interface to pass in constructor (class) of an Entity as a function argument.
|
package/build/Entity.js
CHANGED
|
@@ -3,6 +3,9 @@ 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 EntityCreator_1 = __importDefault(require("./EntityCreator"));
|
|
7
|
+
const EntityDeleter_1 = __importDefault(require("./EntityDeleter"));
|
|
8
|
+
const EntityUpdater_1 = __importDefault(require("./EntityUpdater"));
|
|
6
9
|
const ReadonlyEntity_1 = __importDefault(require("./ReadonlyEntity"));
|
|
7
10
|
/**
|
|
8
11
|
* Entity is a privacy-first data model.
|
|
@@ -33,10 +36,7 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
33
36
|
.getViewerScopedEntityCompanionForClass(this)
|
|
34
37
|
.getQueryContextProvider()
|
|
35
38
|
.getQueryContext()) {
|
|
36
|
-
return viewerContext
|
|
37
|
-
.getViewerScopedEntityCompanionForClass(this)
|
|
38
|
-
.getMutatorFactory()
|
|
39
|
-
.forCreate(queryContext);
|
|
39
|
+
return new EntityCreator_1.default(viewerContext, queryContext, this);
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Vend mutator for updating an existing entity in given query context.
|
|
@@ -49,45 +49,20 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
49
49
|
.getViewerScopedEntityCompanionForClass(this)
|
|
50
50
|
.getQueryContextProvider()
|
|
51
51
|
.getQueryContext()) {
|
|
52
|
-
return existingEntity
|
|
53
|
-
.getViewerContext()
|
|
54
|
-
.getViewerScopedEntityCompanionForClass(this)
|
|
55
|
-
.getMutatorFactory()
|
|
56
|
-
.forUpdate(existingEntity, queryContext);
|
|
52
|
+
return new EntityUpdater_1.default(existingEntity, queryContext, this);
|
|
57
53
|
}
|
|
58
54
|
/**
|
|
59
|
-
*
|
|
55
|
+
* Vend mutator for deleting an existing entity in given query context.
|
|
60
56
|
* @param existingEntity - entity to delete
|
|
61
57
|
* @param queryContext - query context in which to perform the delete
|
|
58
|
+
* @returns mutator for deleting existingEntity
|
|
62
59
|
*/
|
|
63
|
-
static
|
|
60
|
+
static deleter(existingEntity, queryContext = existingEntity
|
|
64
61
|
.getViewerContext()
|
|
65
62
|
.getViewerScopedEntityCompanionForClass(this)
|
|
66
63
|
.getQueryContextProvider()
|
|
67
64
|
.getQueryContext()) {
|
|
68
|
-
return existingEntity
|
|
69
|
-
.getViewerContext()
|
|
70
|
-
.getViewerScopedEntityCompanionForClass(this)
|
|
71
|
-
.getMutatorFactory()
|
|
72
|
-
.forDelete(existingEntity, queryContext)
|
|
73
|
-
.deleteAsync();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Delete an existing entity in given query context, throwing if deletion is unsuccessful.
|
|
77
|
-
* @param existingEntity - entity to delete
|
|
78
|
-
* @param queryContext - query context in which to perform the delete
|
|
79
|
-
*/
|
|
80
|
-
static enforceDeleteAsync(existingEntity, queryContext = existingEntity
|
|
81
|
-
.getViewerContext()
|
|
82
|
-
.getViewerScopedEntityCompanionForClass(this)
|
|
83
|
-
.getQueryContextProvider()
|
|
84
|
-
.getQueryContext()) {
|
|
85
|
-
return existingEntity
|
|
86
|
-
.getViewerContext()
|
|
87
|
-
.getViewerScopedEntityCompanionForClass(this)
|
|
88
|
-
.getMutatorFactory()
|
|
89
|
-
.forDelete(existingEntity, queryContext)
|
|
90
|
-
.enforceDeleteAsync();
|
|
65
|
+
return new EntityDeleter_1.default(existingEntity, queryContext, this);
|
|
91
66
|
}
|
|
92
67
|
}
|
|
93
68
|
exports.default = Entity;
|
package/build/Entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;AACA,oEAA4C;AAC5C,oEAA4C;AAG5C,oEAA4C;AAC5C,sEAA8C;AAG9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAA8B,MAK5B,SAAQ,wBAA6D;IACrE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAuBZ,aAA+B,EAC/B,eAAmC,aAAa;SAC7C,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QAUpB,OAAO,IAAI,uBAAa,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAsBZ,cAAwB,EACxB,eAAmC,cAAc;SAC9C,gBAAgB,EAAE;SAClB,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QAEpB,OAAO,IAAI,uBAAa,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAsBZ,cAAwB,EACxB,eAAmC,cAAc;SAC9C,gBAAgB,EAAE;SAClB,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QAEpB,OAAO,IAAI,uBAAa,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IAC/D,CAAC;CACF;AA/HD,yBA+HC"}
|
|
@@ -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
|
}
|