@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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { enforceAsyncResult } from '@expo/results';
|
|
2
|
+
|
|
3
|
+
import { AuthorizationResultBasedDeleteMutator } from './AuthorizationResultBasedEntityMutator';
|
|
4
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
5
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
|
+
import ViewerContext from './ViewerContext';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Enforcing entity deleter. All deletes
|
|
10
|
+
* through this deleter will throw if authorization is not successful.
|
|
11
|
+
*/
|
|
12
|
+
export default class EnforcingEntityDeleter<
|
|
13
|
+
TFields extends object,
|
|
14
|
+
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
15
|
+
TViewerContext extends ViewerContext,
|
|
16
|
+
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
17
|
+
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
18
|
+
TFields,
|
|
19
|
+
TID,
|
|
20
|
+
TViewerContext,
|
|
21
|
+
TEntity,
|
|
22
|
+
TSelectedFields
|
|
23
|
+
>,
|
|
24
|
+
TSelectedFields extends keyof TFields,
|
|
25
|
+
> {
|
|
26
|
+
constructor(
|
|
27
|
+
private readonly entityDeleter: AuthorizationResultBasedDeleteMutator<
|
|
28
|
+
TFields,
|
|
29
|
+
TID,
|
|
30
|
+
TViewerContext,
|
|
31
|
+
TEntity,
|
|
32
|
+
TPrivacyPolicy,
|
|
33
|
+
TSelectedFields
|
|
34
|
+
>,
|
|
35
|
+
) {}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Delete the entity after authorizing against delete privacy rules. The entity is invalidated in all caches.
|
|
39
|
+
* Throws when delete is not successful.
|
|
40
|
+
*/
|
|
41
|
+
async deleteAsync(): Promise<void> {
|
|
42
|
+
await enforceAsyncResult(this.entityDeleter.deleteAsync());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { enforceAsyncResult } from '@expo/results';
|
|
2
|
+
|
|
3
|
+
import { AuthorizationResultBasedUpdateMutator } from './AuthorizationResultBasedEntityMutator';
|
|
4
|
+
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
5
|
+
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
|
+
import ViewerContext from './ViewerContext';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Enforcing entity updater. All updates
|
|
10
|
+
* through this updater will throw if authorization is not successful.
|
|
11
|
+
*/
|
|
12
|
+
export default class EnforcingEntityUpdater<
|
|
13
|
+
TFields extends object,
|
|
14
|
+
TID extends NonNullable<TFields[TSelectedFields]>,
|
|
15
|
+
TViewerContext extends ViewerContext,
|
|
16
|
+
TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>,
|
|
17
|
+
TPrivacyPolicy extends EntityPrivacyPolicy<
|
|
18
|
+
TFields,
|
|
19
|
+
TID,
|
|
20
|
+
TViewerContext,
|
|
21
|
+
TEntity,
|
|
22
|
+
TSelectedFields
|
|
23
|
+
>,
|
|
24
|
+
TSelectedFields extends keyof TFields,
|
|
25
|
+
> {
|
|
26
|
+
constructor(
|
|
27
|
+
private readonly entityUpdater: AuthorizationResultBasedUpdateMutator<
|
|
28
|
+
TFields,
|
|
29
|
+
TID,
|
|
30
|
+
TViewerContext,
|
|
31
|
+
TEntity,
|
|
32
|
+
TPrivacyPolicy,
|
|
33
|
+
TSelectedFields
|
|
34
|
+
>,
|
|
35
|
+
) {}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set the value for entity field.
|
|
39
|
+
* @param fieldName - entity field being updated
|
|
40
|
+
* @param value - value for entity field
|
|
41
|
+
*/
|
|
42
|
+
setField<K extends keyof Pick<TFields, TSelectedFields>>(fieldName: K, value: TFields[K]): this {
|
|
43
|
+
this.entityUpdater.setField(fieldName, value);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Commit the changes to the entity after authorizing against update privacy rules.
|
|
49
|
+
* Invalidates all caches for pre-update entity.
|
|
50
|
+
* @returns authorized updated entity, throws upon update failure
|
|
51
|
+
*/
|
|
52
|
+
async updateAsync(): Promise<TEntity> {
|
|
53
|
+
return await enforceAsyncResult(this.entityUpdater.updateAsync());
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/Entity.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
AuthorizationResultBasedCreateMutator,
|
|
3
|
+
AuthorizationResultBasedDeleteMutator,
|
|
4
|
+
AuthorizationResultBasedUpdateMutator,
|
|
5
|
+
} from './AuthorizationResultBasedEntityMutator';
|
|
6
|
+
import EnforcingEntityCreator from './EnforcingEntityCreator';
|
|
7
|
+
import EnforcingEntityDeleter from './EnforcingEntityDeleter';
|
|
8
|
+
import EnforcingEntityUpdater from './EnforcingEntityUpdater';
|
|
3
9
|
import { EntityCompanionDefinition } from './EntityCompanionProvider';
|
|
4
|
-
import
|
|
10
|
+
import EntityCreator from './EntityCreator';
|
|
11
|
+
import EntityDeleter from './EntityDeleter';
|
|
5
12
|
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
6
13
|
import { EntityQueryContext } from './EntityQueryContext';
|
|
14
|
+
import EntityUpdater from './EntityUpdater';
|
|
7
15
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
8
16
|
import ViewerContext from './ViewerContext';
|
|
9
17
|
|
|
@@ -65,11 +73,60 @@ export default abstract class Entity<
|
|
|
65
73
|
.getViewerScopedEntityCompanionForClass(this)
|
|
66
74
|
.getQueryContextProvider()
|
|
67
75
|
.getQueryContext(),
|
|
68
|
-
):
|
|
69
|
-
|
|
76
|
+
): EnforcingEntityCreator<
|
|
77
|
+
TMFields,
|
|
78
|
+
TMID,
|
|
79
|
+
TMViewerContext,
|
|
80
|
+
TMEntity,
|
|
81
|
+
TMPrivacyPolicy,
|
|
82
|
+
TMSelectedFields
|
|
83
|
+
> {
|
|
84
|
+
return new EntityCreator(viewerContext, queryContext, this).enforcing();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Vend mutator for creating a new entity in given query context.
|
|
89
|
+
* @param viewerContext - viewer context of creating user
|
|
90
|
+
* @param queryContext - query context in which to perform the create
|
|
91
|
+
* @returns mutator for creating an entity
|
|
92
|
+
*/
|
|
93
|
+
static creatorWithAuthorizationResults<
|
|
94
|
+
TMFields extends object,
|
|
95
|
+
TMID extends NonNullable<TMFields[TMSelectedFields]>,
|
|
96
|
+
TMViewerContext extends ViewerContext,
|
|
97
|
+
TMViewerContext2 extends TMViewerContext,
|
|
98
|
+
TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>,
|
|
99
|
+
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
100
|
+
TMFields,
|
|
101
|
+
TMID,
|
|
102
|
+
TMViewerContext,
|
|
103
|
+
TMEntity,
|
|
104
|
+
TMSelectedFields
|
|
105
|
+
>,
|
|
106
|
+
TMSelectedFields extends keyof TMFields = keyof TMFields,
|
|
107
|
+
>(
|
|
108
|
+
this: IEntityClass<
|
|
109
|
+
TMFields,
|
|
110
|
+
TMID,
|
|
111
|
+
TMViewerContext,
|
|
112
|
+
TMEntity,
|
|
113
|
+
TMPrivacyPolicy,
|
|
114
|
+
TMSelectedFields
|
|
115
|
+
>,
|
|
116
|
+
viewerContext: TMViewerContext2,
|
|
117
|
+
queryContext: EntityQueryContext = viewerContext
|
|
70
118
|
.getViewerScopedEntityCompanionForClass(this)
|
|
71
|
-
.
|
|
72
|
-
.
|
|
119
|
+
.getQueryContextProvider()
|
|
120
|
+
.getQueryContext(),
|
|
121
|
+
): AuthorizationResultBasedCreateMutator<
|
|
122
|
+
TMFields,
|
|
123
|
+
TMID,
|
|
124
|
+
TMViewerContext,
|
|
125
|
+
TMEntity,
|
|
126
|
+
TMPrivacyPolicy,
|
|
127
|
+
TMSelectedFields
|
|
128
|
+
> {
|
|
129
|
+
return new EntityCreator(viewerContext, queryContext, this).withAuthorizationResults();
|
|
73
130
|
}
|
|
74
131
|
|
|
75
132
|
/**
|
|
@@ -106,20 +163,69 @@ export default abstract class Entity<
|
|
|
106
163
|
.getViewerScopedEntityCompanionForClass(this)
|
|
107
164
|
.getQueryContextProvider()
|
|
108
165
|
.getQueryContext(),
|
|
109
|
-
):
|
|
110
|
-
|
|
166
|
+
): EnforcingEntityUpdater<
|
|
167
|
+
TMFields,
|
|
168
|
+
TMID,
|
|
169
|
+
TMViewerContext,
|
|
170
|
+
TMEntity,
|
|
171
|
+
TMPrivacyPolicy,
|
|
172
|
+
TMSelectedFields
|
|
173
|
+
> {
|
|
174
|
+
return new EntityUpdater(existingEntity, queryContext, this).enforcing();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Vend mutator for updating an existing entity in given query context.
|
|
179
|
+
* @param existingEntity - entity to update
|
|
180
|
+
* @param queryContext - query context in which to perform the update
|
|
181
|
+
* @returns mutator for updating existingEntity
|
|
182
|
+
*/
|
|
183
|
+
static updaterWithAuthorizationResults<
|
|
184
|
+
TMFields extends object,
|
|
185
|
+
TMID extends NonNullable<TMFields[TMSelectedFields]>,
|
|
186
|
+
TMViewerContext extends ViewerContext,
|
|
187
|
+
TMEntity extends Entity<TMFields, TMID, TMViewerContext, TMSelectedFields>,
|
|
188
|
+
TMPrivacyPolicy extends EntityPrivacyPolicy<
|
|
189
|
+
TMFields,
|
|
190
|
+
TMID,
|
|
191
|
+
TMViewerContext,
|
|
192
|
+
TMEntity,
|
|
193
|
+
TMSelectedFields
|
|
194
|
+
>,
|
|
195
|
+
TMSelectedFields extends keyof TMFields = keyof TMFields,
|
|
196
|
+
>(
|
|
197
|
+
this: IEntityClass<
|
|
198
|
+
TMFields,
|
|
199
|
+
TMID,
|
|
200
|
+
TMViewerContext,
|
|
201
|
+
TMEntity,
|
|
202
|
+
TMPrivacyPolicy,
|
|
203
|
+
TMSelectedFields
|
|
204
|
+
>,
|
|
205
|
+
existingEntity: TMEntity,
|
|
206
|
+
queryContext: EntityQueryContext = existingEntity
|
|
111
207
|
.getViewerContext()
|
|
112
208
|
.getViewerScopedEntityCompanionForClass(this)
|
|
113
|
-
.
|
|
114
|
-
.
|
|
209
|
+
.getQueryContextProvider()
|
|
210
|
+
.getQueryContext(),
|
|
211
|
+
): AuthorizationResultBasedUpdateMutator<
|
|
212
|
+
TMFields,
|
|
213
|
+
TMID,
|
|
214
|
+
TMViewerContext,
|
|
215
|
+
TMEntity,
|
|
216
|
+
TMPrivacyPolicy,
|
|
217
|
+
TMSelectedFields
|
|
218
|
+
> {
|
|
219
|
+
return new EntityUpdater(existingEntity, queryContext, this).withAuthorizationResults();
|
|
115
220
|
}
|
|
116
221
|
|
|
117
222
|
/**
|
|
118
|
-
*
|
|
223
|
+
* Vend mutator for deleting an existing entity in given query context.
|
|
119
224
|
* @param existingEntity - entity to delete
|
|
120
225
|
* @param queryContext - query context in which to perform the delete
|
|
226
|
+
* @returns mutator for deleting existingEntity
|
|
121
227
|
*/
|
|
122
|
-
static
|
|
228
|
+
static deleter<
|
|
123
229
|
TMFields extends object,
|
|
124
230
|
TMID extends NonNullable<TMFields[TMSelectedFields]>,
|
|
125
231
|
TMViewerContext extends ViewerContext,
|
|
@@ -147,21 +253,24 @@ export default abstract class Entity<
|
|
|
147
253
|
.getViewerScopedEntityCompanionForClass(this)
|
|
148
254
|
.getQueryContextProvider()
|
|
149
255
|
.getQueryContext(),
|
|
150
|
-
):
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
256
|
+
): EnforcingEntityDeleter<
|
|
257
|
+
TMFields,
|
|
258
|
+
TMID,
|
|
259
|
+
TMViewerContext,
|
|
260
|
+
TMEntity,
|
|
261
|
+
TMPrivacyPolicy,
|
|
262
|
+
TMSelectedFields
|
|
263
|
+
> {
|
|
264
|
+
return new EntityDeleter(existingEntity, queryContext, this).enforcing();
|
|
157
265
|
}
|
|
158
266
|
|
|
159
267
|
/**
|
|
160
|
-
*
|
|
268
|
+
* Vend mutator for deleting an existing entity in given query context.
|
|
161
269
|
* @param existingEntity - entity to delete
|
|
162
270
|
* @param queryContext - query context in which to perform the delete
|
|
271
|
+
* @returns mutator for deleting existingEntity
|
|
163
272
|
*/
|
|
164
|
-
static
|
|
273
|
+
static deleterWithAuthorizationResults<
|
|
165
274
|
TMFields extends object,
|
|
166
275
|
TMID extends NonNullable<TMFields[TMSelectedFields]>,
|
|
167
276
|
TMViewerContext extends ViewerContext,
|
|
@@ -189,13 +298,15 @@ export default abstract class Entity<
|
|
|
189
298
|
.getViewerScopedEntityCompanionForClass(this)
|
|
190
299
|
.getQueryContextProvider()
|
|
191
300
|
.getQueryContext(),
|
|
192
|
-
):
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
301
|
+
): AuthorizationResultBasedDeleteMutator<
|
|
302
|
+
TMFields,
|
|
303
|
+
TMID,
|
|
304
|
+
TMViewerContext,
|
|
305
|
+
TMEntity,
|
|
306
|
+
TMPrivacyPolicy,
|
|
307
|
+
TMSelectedFields
|
|
308
|
+
> {
|
|
309
|
+
return new EntityDeleter(existingEntity, queryContext, this).withAuthorizationResults();
|
|
199
310
|
}
|
|
200
311
|
}
|
|
201
312
|
|