@expo/entity 0.34.0 → 0.35.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/Entity.d.ts +6 -6
- package/build/Entity.js +29 -6
- package/build/Entity.js.map +1 -1
- package/build/EntityAssociationLoader.d.ts +8 -8
- package/build/EntityAssociationLoader.js +20 -4
- package/build/EntityAssociationLoader.js.map +1 -1
- package/build/EntityQueryContextProvider.d.ts +1 -1
- package/build/EntityQueryContextProvider.js +1 -1
- package/build/EntityQueryContextProvider.js.map +1 -1
- package/build/ReadonlyEntity.d.ts +1 -1
- package/build/ReadonlyEntity.js +4 -1
- package/build/ReadonlyEntity.js.map +1 -1
- package/build/ViewerContext.d.ts +2 -2
- package/build/ViewerContext.js +3 -3
- package/build/ViewerContext.js.map +1 -1
- package/build/__tests__/Entity-test.js +13 -13
- package/build/__tests__/Entity-test.js.map +1 -1
- package/build/__tests__/EntityAssociationLoader-test.js +37 -69
- package/build/__tests__/EntityAssociationLoader-test.js.map +1 -1
- package/build/__tests__/EntityCommonUseCases-test.js +11 -19
- package/build/__tests__/EntityCommonUseCases-test.js.map +1 -1
- package/build/__tests__/EntityEdges-test.js +40 -72
- package/build/__tests__/EntityEdges-test.js.map +1 -1
- package/build/__tests__/EntityLoader-constructor-test.js +1 -1
- package/build/__tests__/EntityLoader-constructor-test.js.map +1 -1
- package/build/__tests__/EntityLoader-test.js +19 -19
- package/build/__tests__/EntityLoader-test.js.map +1 -1
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js +6 -6
- package/build/__tests__/EntityMutator-MutationCacheConsistency-test.js.map +1 -1
- package/build/__tests__/EntityMutator-test.js +20 -20
- package/build/__tests__/EntityMutator-test.js.map +1 -1
- package/build/__tests__/EntitySecondaryCacheLoader-test.js +10 -10
- package/build/__tests__/EntitySecondaryCacheLoader-test.js.map +1 -1
- package/build/__tests__/EntitySelfReferentialEdges-test.js +47 -79
- package/build/__tests__/EntitySelfReferentialEdges-test.js.map +1 -1
- package/build/__tests__/ReadonlyEntity-test.js +13 -13
- package/build/__tests__/ReadonlyEntity-test.js.map +1 -1
- package/build/__tests__/ViewerContext-test.js +2 -2
- package/build/__tests__/ViewerContext-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js +8 -12
- package/build/__tests__/cases/TwoEntitySameTableDisjointRows-test.js.map +1 -1
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js +13 -15
- package/build/__tests__/cases/TwoEntitySameTableOverlappingRows-test.js.map +1 -1
- package/build/internal/EntityDataManager.js +1 -1
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/__tests__/EntityDataManager-test.js +11 -11
- package/build/internal/__tests__/EntityDataManager-test.js.map +1 -1
- package/build/testfixtures/SimpleTestEntity.d.ts +8 -8
- package/build/testfixtures/SimpleTestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity.d.ts +12 -12
- package/build/testfixtures/TestEntity.js.map +1 -1
- package/build/testfixtures/TestEntity2.d.ts +8 -8
- package/build/testfixtures/TestEntity2.js.map +1 -1
- package/build/testfixtures/TestViewerContext.d.ts +0 -3
- package/build/testfixtures/TestViewerContext.js +0 -6
- package/build/testfixtures/TestViewerContext.js.map +1 -1
- package/package.json +2 -2
- package/src/Entity.ts +29 -6
- package/src/EntityAssociationLoader.ts +25 -9
- package/src/EntityQueryContextProvider.ts +1 -1
- package/src/ReadonlyEntity.ts +4 -1
- package/src/ViewerContext.ts +5 -5
- package/src/__tests__/Entity-test.ts +27 -43
- package/src/__tests__/EntityAssociationLoader-test.ts +86 -168
- package/src/__tests__/EntityCommonUseCases-test.ts +18 -36
- package/src/__tests__/EntityEdges-test.ts +40 -102
- package/src/__tests__/EntityLoader-constructor-test.ts +1 -1
- package/src/__tests__/EntityLoader-test.ts +19 -19
- package/src/__tests__/EntityMutator-MutationCacheConsistency-test.ts +16 -19
- package/src/__tests__/EntityMutator-test.ts +61 -67
- package/src/__tests__/EntitySecondaryCacheLoader-test.ts +11 -20
- package/src/__tests__/EntitySelfReferentialEdges-test.ts +47 -115
- package/src/__tests__/ReadonlyEntity-test.ts +13 -15
- package/src/__tests__/ViewerContext-test.ts +2 -3
- package/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +22 -33
- package/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +22 -30
- package/src/internal/EntityDataManager.ts +1 -1
- package/src/internal/__tests__/EntityDataManager-test.ts +11 -11
- package/src/testfixtures/SimpleTestEntity.ts +8 -8
- package/src/testfixtures/TestEntity.ts +12 -15
- package/src/testfixtures/TestEntity2.ts +8 -8
- package/src/testfixtures/TestViewerContext.ts +1 -12
package/build/Entity.d.ts
CHANGED
|
@@ -30,26 +30,26 @@ export default abstract class Entity<TFields extends object, TID extends NonNull
|
|
|
30
30
|
* @param queryContext - query context in which to perform the create
|
|
31
31
|
* @returns mutator for creating an entity
|
|
32
32
|
*/
|
|
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
|
|
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): CreateMutator<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
34
34
|
/**
|
|
35
35
|
* Vend mutator for updating an existing entity in given query context.
|
|
36
36
|
* @param existingEntity - entity to update
|
|
37
37
|
* @param queryContext - query context in which to perform the update
|
|
38
38
|
* @returns mutator for updating existingEntity
|
|
39
39
|
*/
|
|
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
|
|
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): UpdateMutator<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
41
41
|
/**
|
|
42
42
|
* Delete an existing entity in given query context.
|
|
43
43
|
* @param existingEntity - entity to delete
|
|
44
44
|
* @param queryContext - query context in which to perform the delete
|
|
45
45
|
*/
|
|
46
|
-
static deleteAsync<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
|
|
46
|
+
static deleteAsync<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<Result<void>>;
|
|
47
47
|
/**
|
|
48
48
|
* Delete an existing entity in given query context, throwing if deletion is unsuccessful.
|
|
49
49
|
* @param existingEntity - entity to delete
|
|
50
50
|
* @param queryContext - query context in which to perform the delete
|
|
51
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
|
|
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>;
|
|
53
53
|
/**
|
|
54
54
|
* Check whether an entity loaded by a viewer can be updated by that same viewer.
|
|
55
55
|
*
|
|
@@ -66,7 +66,7 @@ export default abstract class Entity<TFields extends object, TID extends NonNull
|
|
|
66
66
|
* @param existingEntity - entity loaded by viewer
|
|
67
67
|
* @param queryContext - query context in which to perform the check
|
|
68
68
|
*/
|
|
69
|
-
static canViewerUpdateAsync<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
|
|
69
|
+
static canViewerUpdateAsync<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<boolean>;
|
|
70
70
|
/**
|
|
71
71
|
* Check whether an entity loaded by a viewer can be deleted by that same viewer.
|
|
72
72
|
*
|
|
@@ -76,7 +76,7 @@ export default abstract class Entity<TFields extends object, TID extends NonNull
|
|
|
76
76
|
* @param existingEntity - entity loaded by viewer
|
|
77
77
|
* @param queryContext - query context in which to perform the check
|
|
78
78
|
*/
|
|
79
|
-
static canViewerDeleteAsync<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
|
|
79
|
+
static canViewerDeleteAsync<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<boolean>;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* An interface to pass in constructor (class) of an Entity as a function argument.
|
package/build/Entity.js
CHANGED
|
@@ -30,7 +30,10 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
30
30
|
* @param queryContext - query context in which to perform the create
|
|
31
31
|
* @returns mutator for creating an entity
|
|
32
32
|
*/
|
|
33
|
-
static creator(viewerContext, queryContext
|
|
33
|
+
static creator(viewerContext, queryContext = viewerContext
|
|
34
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
35
|
+
.getQueryContextProvider()
|
|
36
|
+
.getQueryContext()) {
|
|
34
37
|
return viewerContext
|
|
35
38
|
.getViewerScopedEntityCompanionForClass(this)
|
|
36
39
|
.getMutatorFactory()
|
|
@@ -42,7 +45,11 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
42
45
|
* @param queryContext - query context in which to perform the update
|
|
43
46
|
* @returns mutator for updating existingEntity
|
|
44
47
|
*/
|
|
45
|
-
static updater(existingEntity, queryContext
|
|
48
|
+
static updater(existingEntity, queryContext = existingEntity
|
|
49
|
+
.getViewerContext()
|
|
50
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
51
|
+
.getQueryContextProvider()
|
|
52
|
+
.getQueryContext()) {
|
|
46
53
|
return existingEntity
|
|
47
54
|
.getViewerContext()
|
|
48
55
|
.getViewerScopedEntityCompanionForClass(this)
|
|
@@ -54,7 +61,11 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
54
61
|
* @param existingEntity - entity to delete
|
|
55
62
|
* @param queryContext - query context in which to perform the delete
|
|
56
63
|
*/
|
|
57
|
-
static deleteAsync(existingEntity, queryContext
|
|
64
|
+
static deleteAsync(existingEntity, queryContext = existingEntity
|
|
65
|
+
.getViewerContext()
|
|
66
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
67
|
+
.getQueryContextProvider()
|
|
68
|
+
.getQueryContext()) {
|
|
58
69
|
return existingEntity
|
|
59
70
|
.getViewerContext()
|
|
60
71
|
.getViewerScopedEntityCompanionForClass(this)
|
|
@@ -67,7 +78,11 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
67
78
|
* @param existingEntity - entity to delete
|
|
68
79
|
* @param queryContext - query context in which to perform the delete
|
|
69
80
|
*/
|
|
70
|
-
static enforceDeleteAsync(existingEntity, queryContext
|
|
81
|
+
static enforceDeleteAsync(existingEntity, queryContext = existingEntity
|
|
82
|
+
.getViewerContext()
|
|
83
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
84
|
+
.getQueryContextProvider()
|
|
85
|
+
.getQueryContext()) {
|
|
71
86
|
return existingEntity
|
|
72
87
|
.getViewerContext()
|
|
73
88
|
.getViewerScopedEntityCompanionForClass(this)
|
|
@@ -91,7 +106,11 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
91
106
|
* @param existingEntity - entity loaded by viewer
|
|
92
107
|
* @param queryContext - query context in which to perform the check
|
|
93
108
|
*/
|
|
94
|
-
static async canViewerUpdateAsync(existingEntity, queryContext
|
|
109
|
+
static async canViewerUpdateAsync(existingEntity, queryContext = existingEntity
|
|
110
|
+
.getViewerContext()
|
|
111
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
112
|
+
.getQueryContextProvider()
|
|
113
|
+
.getQueryContext()) {
|
|
95
114
|
const companion = existingEntity
|
|
96
115
|
.getViewerContext()
|
|
97
116
|
.getViewerScopedEntityCompanionForClass(this);
|
|
@@ -108,7 +127,11 @@ class Entity extends ReadonlyEntity_1.default {
|
|
|
108
127
|
* @param existingEntity - entity loaded by viewer
|
|
109
128
|
* @param queryContext - query context in which to perform the check
|
|
110
129
|
*/
|
|
111
|
-
static async canViewerDeleteAsync(existingEntity, queryContext
|
|
130
|
+
static async canViewerDeleteAsync(existingEntity, queryContext = existingEntity
|
|
131
|
+
.getViewerContext()
|
|
132
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
133
|
+
.getQueryContextProvider()
|
|
134
|
+
.getQueryContext()) {
|
|
112
135
|
const companion = existingEntity
|
|
113
136
|
.getViewerContext()
|
|
114
137
|
.getViewerScopedEntityCompanionForClass(this);
|
package/build/Entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AAMpD,sEAA8C;AAG9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAA8B,MAK5B,SAAQ,wBAA6D;IACrE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAuBZ,aAA+B,EAC/B,
|
|
1
|
+
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../src/Entity.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AAMpD,sEAA8C;AAG9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAA8B,MAK5B,SAAQ,wBAA6D;IACrE;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAuBZ,aAA+B,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
|
|
@@ -19,7 +19,7 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
19
19
|
* @param associatedEntityClass - class of the associated entity
|
|
20
20
|
* @param queryContext - query context in which to perform the load
|
|
21
21
|
*/
|
|
22
|
-
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>, queryContext
|
|
22
|
+
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>, queryContext?: EntityQueryContext): Promise<Result<null extends TFields[TIdentifyingField] ? TAssociatedEntity | null : TAssociatedEntity>>;
|
|
23
23
|
/**
|
|
24
24
|
* Load many entities associated with this entity, often referred to as entites belonging
|
|
25
25
|
* to this entity. In a relational database, the field in the foreign entity is a
|
|
@@ -29,7 +29,7 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
29
29
|
* @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity
|
|
30
30
|
* @param queryContext - query context in which to perform the load
|
|
31
31
|
*/
|
|
32
|
-
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>, queryContext
|
|
32
|
+
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>, queryContext?: EntityQueryContext): Promise<readonly Result<TAssociatedEntity>[]>;
|
|
33
33
|
/**
|
|
34
34
|
* Load an associated entity identified by a field value of this entity. In a relational database,
|
|
35
35
|
* the field in this entity is a foreign key to a unique field of the associated entity.
|
|
@@ -38,7 +38,7 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
38
38
|
* @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity
|
|
39
39
|
* @param queryContext - query context in which to perform the load
|
|
40
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
|
|
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
42
|
/**
|
|
43
43
|
* Load many associated entities identified by a field value of this entity. In a relational database,
|
|
44
44
|
* the field in this entity refers to a field of the associated entity.
|
|
@@ -47,7 +47,7 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
47
47
|
* @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities
|
|
48
48
|
* @param queryContext - query context in which to perform the load
|
|
49
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
|
|
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
51
|
/**
|
|
52
52
|
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
53
53
|
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
@@ -56,7 +56,7 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
56
56
|
*/
|
|
57
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
58
|
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>
|
|
59
|
-
], queryContext
|
|
59
|
+
], queryContext?: EntityQueryContext): Promise<Result<TEntity2> | null>;
|
|
60
60
|
/**
|
|
61
61
|
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
62
62
|
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
@@ -66,7 +66,7 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
66
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
67
|
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>,
|
|
68
68
|
EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>
|
|
69
|
-
], queryContext
|
|
69
|
+
], queryContext?: EntityQueryContext): Promise<Result<TEntity3> | null>;
|
|
70
70
|
/**
|
|
71
71
|
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
72
72
|
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
@@ -77,14 +77,14 @@ export default class EntityAssociationLoader<TFields extends object, TID extends
|
|
|
77
77
|
EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>,
|
|
78
78
|
EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>,
|
|
79
79
|
EntityLoadThroughDirective<TViewerContext, TFields3, TFields4, TID4, TEntity4, TPrivacyPolicy4, TSelectedFields3, TSelectedFields4>
|
|
80
|
-
], queryContext
|
|
80
|
+
], queryContext?: EntityQueryContext): Promise<Result<TEntity4> | null>;
|
|
81
81
|
/**
|
|
82
82
|
* Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each
|
|
83
83
|
* fold step, load an associated entity identified by a field value of the current fold value.
|
|
84
84
|
* @param loadDirectives - associated entity load directives instructing each step of the fold
|
|
85
85
|
* @param queryContext - query context in which to perform the loads
|
|
86
86
|
*/
|
|
87
|
-
loadAssociatedEntityThroughAsync(loadDirectives: EntityLoadThroughDirective<TViewerContext, any, any, any, any, any, any, any>[], queryContext
|
|
87
|
+
loadAssociatedEntityThroughAsync(loadDirectives: EntityLoadThroughDirective<TViewerContext, any, any, any, any, any, any, any>[], queryContext?: EntityQueryContext): Promise<Result<ReadonlyEntity<any, any, any, any>> | null>;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Instruction for each step of a load-associated-through method.
|
|
@@ -17,7 +17,11 @@ class EntityAssociationLoader {
|
|
|
17
17
|
* @param associatedEntityClass - class of the associated entity
|
|
18
18
|
* @param queryContext - query context in which to perform the load
|
|
19
19
|
*/
|
|
20
|
-
async loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, queryContext
|
|
20
|
+
async loadAssociatedEntityAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, queryContext = this.entity
|
|
21
|
+
.getViewerContext()
|
|
22
|
+
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
23
|
+
.getQueryContextProvider()
|
|
24
|
+
.getQueryContext()) {
|
|
21
25
|
const associatedEntityID = this.entity.getField(fieldIdentifyingAssociatedEntity);
|
|
22
26
|
if (!associatedEntityID) {
|
|
23
27
|
return (0, results_1.result)(null);
|
|
@@ -38,7 +42,11 @@ class EntityAssociationLoader {
|
|
|
38
42
|
* @param associatedEntityFieldContainingThisID - field of associated entity which contains the ID of this entity
|
|
39
43
|
* @param queryContext - query context in which to perform the load
|
|
40
44
|
*/
|
|
41
|
-
async loadManyAssociatedEntitiesAsync(associatedEntityClass, associatedEntityFieldContainingThisID, queryContext
|
|
45
|
+
async loadManyAssociatedEntitiesAsync(associatedEntityClass, associatedEntityFieldContainingThisID, queryContext = this.entity
|
|
46
|
+
.getViewerContext()
|
|
47
|
+
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
48
|
+
.getQueryContextProvider()
|
|
49
|
+
.getQueryContext()) {
|
|
42
50
|
const thisID = this.entity.getID();
|
|
43
51
|
const loader = this.entity
|
|
44
52
|
.getViewerContext()
|
|
@@ -55,7 +63,11 @@ class EntityAssociationLoader {
|
|
|
55
63
|
* @param associatedEntityLookupByField - field of associated entity with which to look up the associated entity
|
|
56
64
|
* @param queryContext - query context in which to perform the load
|
|
57
65
|
*/
|
|
58
|
-
async loadAssociatedEntityByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, queryContext
|
|
66
|
+
async loadAssociatedEntityByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, queryContext = this.entity
|
|
67
|
+
.getViewerContext()
|
|
68
|
+
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
69
|
+
.getQueryContextProvider()
|
|
70
|
+
.getQueryContext()) {
|
|
59
71
|
const associatedFieldValue = this.entity.getField(fieldIdentifyingAssociatedEntity);
|
|
60
72
|
if (!associatedFieldValue) {
|
|
61
73
|
return null;
|
|
@@ -75,7 +87,11 @@ class EntityAssociationLoader {
|
|
|
75
87
|
* @param associatedEntityLookupByField - field of associated entities with which to look up the associated entities
|
|
76
88
|
* @param queryContext - query context in which to perform the load
|
|
77
89
|
*/
|
|
78
|
-
async loadManyAssociatedEntitiesByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, queryContext
|
|
90
|
+
async loadManyAssociatedEntitiesByFieldEqualingAsync(fieldIdentifyingAssociatedEntity, associatedEntityClass, associatedEntityLookupByField, queryContext = this.entity
|
|
91
|
+
.getViewerContext()
|
|
92
|
+
.getViewerScopedEntityCompanionForClass(associatedEntityClass)
|
|
93
|
+
.getQueryContextProvider()
|
|
94
|
+
.getQueryContext()) {
|
|
79
95
|
const associatedFieldValue = this.entity.getField(fieldIdentifyingAssociatedEntity);
|
|
80
96
|
if (!associatedFieldValue) {
|
|
81
97
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityAssociationLoader.js","sourceRoot":"","sources":["../src/EntityAssociationLoader.ts"],"names":[],"mappings":";;AAAA,2CAA+C;AAQ/C;;;;GAIG;AACH,MAAqB,uBAAuB;IAO1C,YAA6B,MAAe;QAAf,WAA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EAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;aAC9C;YACD,aAAa,GAAG,sBAAsB,CAAC,KAAK,CAAC;SAC9C;QACD,OAAO,IAAA,gBAAM,EAAC,aAAa,CAAC,CAAC;IAC/B,CAAC;CACF;AA/cD,0CA+cC"}
|
|
@@ -6,7 +6,7 @@ export default abstract class EntityQueryContextProvider {
|
|
|
6
6
|
/**
|
|
7
7
|
* Vend a regular (non-transactional) entity query context.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
getQueryContext(): EntityNonTransactionalQueryContext;
|
|
10
10
|
/**
|
|
11
11
|
* Get the query interface for constructing a query context.
|
|
12
12
|
*/
|
|
@@ -8,7 +8,7 @@ class EntityQueryContextProvider {
|
|
|
8
8
|
/**
|
|
9
9
|
* Vend a regular (non-transactional) entity query context.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
getQueryContext() {
|
|
12
12
|
return new EntityQueryContext_1.EntityNonTransactionalQueryContext(this.getQueryInterface(), this);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityQueryContextProvider.js","sourceRoot":"","sources":["../src/EntityQueryContextProvider.ts"],"names":[],"mappings":";;AAAA,6DAK8B;AAE9B;;GAEG;AACH,MAA8B,0BAA0B;IACtD;;OAEG;IACI
|
|
1
|
+
{"version":3,"file":"EntityQueryContextProvider.js","sourceRoot":"","sources":["../src/EntityQueryContextProvider.ts"],"names":[],"mappings":";;AAAA,6DAK8B;AAE9B;;GAEG;AACH,MAA8B,0BAA0B;IACtD;;OAEG;IACI,eAAe;QACpB,OAAO,IAAI,uDAAkC,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;IAkBD;;;OAGG;IACH,KAAK,CAAC,qBAAqB,CACzB,gBAA+E,EAC/E,iBAAqC;QAErC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAEtE,iBAAiB,CAAC,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE;YAC5C,MAAM,YAAY,GAAG,IAAI,oDAA+B,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YAC/E,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC,CAAC;YACpD,MAAM,YAAY,CAAC,0BAA0B,EAAE,CAAC;YAChD,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QACH,MAAM,YAAY,CAAC,2BAA2B,EAAE,CAAC;QACjD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,2BAA2B,CAC/B,iBAAkD,EAClD,gBAA0F;QAE1F,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,GAAG,MAAM,IAAI,CAAC,6BAA6B,CAEjF,iBAAiB,CAAC,iBAAiB,EAAE,CAAC,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE;YACrE,MAAM,iBAAiB,GAAG,IAAI,0DAAqC,CACjE,mBAAmB,EACnB,iBAAiB,EACjB,IAAI,CACL,CAAC;YACF,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;YACzD,MAAM,iBAAiB,CAAC,0BAA0B,EAAE,CAAC;YACrD,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,wHAAwH;QACxH,iBAAiB,CAAC,mCAAmC,EAAE,CAAC;QACxD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAtED,6CAsEC"}
|
|
@@ -70,5 +70,5 @@ export default abstract class ReadonlyEntity<TFields extends object, TID extends
|
|
|
70
70
|
* @param viewerContext - viewer context of loading user
|
|
71
71
|
* @param queryContext - query context in which to perform the load
|
|
72
72
|
*/
|
|
73
|
-
static loader<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends ReadonlyEntity<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
|
|
73
|
+
static loader<TMFields extends object, TMID extends NonNullable<TMFields[TMSelectedFields]>, TMViewerContext extends ViewerContext, TMViewerContext2 extends TMViewerContext, TMEntity extends ReadonlyEntity<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): EntityLoader<TMFields, TMID, TMViewerContext, TMEntity, TMPrivacyPolicy, TMSelectedFields>;
|
|
74
74
|
}
|
package/build/ReadonlyEntity.js
CHANGED
|
@@ -84,7 +84,10 @@ class ReadonlyEntity {
|
|
|
84
84
|
* @param viewerContext - viewer context of loading user
|
|
85
85
|
* @param queryContext - query context in which to perform the load
|
|
86
86
|
*/
|
|
87
|
-
static loader(viewerContext, queryContext
|
|
87
|
+
static loader(viewerContext, queryContext = viewerContext
|
|
88
|
+
.getViewerScopedEntityCompanionForClass(this)
|
|
89
|
+
.getQueryContextProvider()
|
|
90
|
+
.getQueryContext()) {
|
|
88
91
|
return viewerContext
|
|
89
92
|
.getViewerScopedEntityCompanionForClass(this)
|
|
90
93
|
.getLoaderFactory()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadonlyEntity.js","sourceRoot":"","sources":["../src/ReadonlyEntity.ts"],"names":[],"mappings":";;;;;AAAA,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,aAAa;SAC7C,sCAAsC,CAAC,IAAI,CAAC;SAC5C,uBAAuB,EAAE;SACzB,eAAe,EAAE;QAEpB,OAAO,aAAa;aACjB,sCAAsC,CAAC,IAAI,CAAC;aAC5C,gBAAgB,EAAE;aAClB,OAAO,CAAC,YAAY,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF;AA/ID,iCA+IC"}
|
package/build/ViewerContext.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IEntityClass } from './Entity';
|
|
2
2
|
import EntityCompanionProvider, { DatabaseAdapterFlavor } from './EntityCompanionProvider';
|
|
3
3
|
import EntityPrivacyPolicy from './EntityPrivacyPolicy';
|
|
4
|
-
import {
|
|
4
|
+
import { EntityQueryContext, EntityTransactionalQueryContext, TransactionConfig } from './EntityQueryContext';
|
|
5
5
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
6
|
import ViewerScopedEntityCompanion from './ViewerScopedEntityCompanion';
|
|
7
7
|
/**
|
|
@@ -20,7 +20,7 @@ export default class ViewerContext {
|
|
|
20
20
|
* Get the regular (non-transactional) query context for a database adaptor flavor.
|
|
21
21
|
* @param databaseAdaptorFlavor - database adaptor flavor
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
getQueryContextForDatabaseAdaptorFlavor(databaseAdaptorFlavor: DatabaseAdapterFlavor): EntityQueryContext;
|
|
24
24
|
/**
|
|
25
25
|
* Run a transaction of specified database adaptor flavor and execute the provided
|
|
26
26
|
* transaction-scoped closure within the transaction.
|
package/build/ViewerContext.js
CHANGED
|
@@ -25,10 +25,10 @@ class ViewerContext {
|
|
|
25
25
|
* Get the regular (non-transactional) query context for a database adaptor flavor.
|
|
26
26
|
* @param databaseAdaptorFlavor - database adaptor flavor
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
getQueryContextForDatabaseAdaptorFlavor(databaseAdaptorFlavor) {
|
|
29
29
|
return this.entityCompanionProvider
|
|
30
30
|
.getQueryContextProviderForDatabaseAdaptorFlavor(databaseAdaptorFlavor)
|
|
31
|
-
.
|
|
31
|
+
.getQueryContext();
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Run a transaction of specified database adaptor flavor and execute the provided
|
|
@@ -39,7 +39,7 @@ class ViewerContext {
|
|
|
39
39
|
async runInTransactionForDatabaseAdaptorFlavorAsync(databaseAdaptorFlavor, transactionScope, transactionConfig) {
|
|
40
40
|
return await this.entityCompanionProvider
|
|
41
41
|
.getQueryContextProviderForDatabaseAdaptorFlavor(databaseAdaptorFlavor)
|
|
42
|
-
.
|
|
42
|
+
.getQueryContext()
|
|
43
43
|
.runInTransactionIfNotInTransactionAsync(transactionScope, transactionConfig);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewerContext.js","sourceRoot":"","sources":["../src/ViewerContext.ts"],"names":[],"mappings":";;;;;AAUA,gHAAwF;AAExF;;;;;GAKG;AACH,MAAqB,aAAa;IAGhC,YAA4B,uBAAgD;QAAhD,4BAAuB,GAAvB,uBAAuB,CAAyB;QAC1E,IAAI,CAAC,mCAAmC,GAAG,IAAI,6CAAmC,CAChF,uBAAuB,EACvB,IAAI,CACL,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,sCAAsC,CAcpC,WAOC;QASD,OAAO,IAAI,CAAC,mCAAmC,CAAC,iCAAiC,CAAC,WAAW,CAAC,CAAC;IACjG,CAAC;IAED;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"ViewerContext.js","sourceRoot":"","sources":["../src/ViewerContext.ts"],"names":[],"mappings":";;;;;AAUA,gHAAwF;AAExF;;;;;GAKG;AACH,MAAqB,aAAa;IAGhC,YAA4B,uBAAgD;QAAhD,4BAAuB,GAAvB,uBAAuB,CAAyB;QAC1E,IAAI,CAAC,mCAAmC,GAAG,IAAI,6CAAmC,CAChF,uBAAuB,EACvB,IAAI,CACL,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,sCAAsC,CAcpC,WAOC;QASD,OAAO,IAAI,CAAC,mCAAmC,CAAC,iCAAiC,CAAC,WAAW,CAAC,CAAC;IACjG,CAAC;IAED;;;OAGG;IACH,uCAAuC,CACrC,qBAA4C;QAE5C,OAAO,IAAI,CAAC,uBAAuB;aAChC,+CAA+C,CAAC,qBAAqB,CAAC;aACtE,eAAe,EAAE,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,6CAA6C,CACjD,qBAA4C,EAC5C,gBAAqF,EACrF,iBAAqC;QAErC,OAAO,MAAM,IAAI,CAAC,uBAAuB;aACtC,+CAA+C,CAAC,qBAAqB,CAAC;aACtE,eAAe,EAAE;aACjB,uCAAuC,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAClF,CAAC;CACF;AA3ED,gCA2EC"}
|
|
@@ -8,23 +8,23 @@ const EntityConfiguration_1 = __importDefault(require("../EntityConfiguration"))
|
|
|
8
8
|
const EntityFields_1 = require("../EntityFields");
|
|
9
9
|
const EntityMutator_1 = require("../EntityMutator");
|
|
10
10
|
const EntityPrivacyPolicy_1 = __importDefault(require("../EntityPrivacyPolicy"));
|
|
11
|
+
const ViewerContext_1 = __importDefault(require("../ViewerContext"));
|
|
11
12
|
const AlwaysAllowPrivacyPolicyRule_1 = __importDefault(require("../rules/AlwaysAllowPrivacyPolicyRule"));
|
|
12
13
|
const AlwaysDenyPrivacyPolicyRule_1 = __importDefault(require("../rules/AlwaysDenyPrivacyPolicyRule"));
|
|
13
14
|
const SimpleTestEntity_1 = __importDefault(require("../testfixtures/SimpleTestEntity"));
|
|
14
|
-
const TestViewerContext_1 = __importDefault(require("../testfixtures/TestViewerContext"));
|
|
15
15
|
const createUnitTestEntityCompanionProvider_1 = require("../utils/testing/createUnitTestEntityCompanionProvider");
|
|
16
16
|
describe(Entity_1.default, () => {
|
|
17
17
|
describe('creator', () => {
|
|
18
18
|
it('creates a new CreateMutator', () => {
|
|
19
19
|
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
20
|
-
const viewerContext = new
|
|
21
|
-
expect(SimpleTestEntity_1.default.creator(viewerContext
|
|
20
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
21
|
+
expect(SimpleTestEntity_1.default.creator(viewerContext)).toBeInstanceOf(EntityMutator_1.CreateMutator);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
describe('updater', () => {
|
|
25
25
|
it('creates a new UpdateMutator', () => {
|
|
26
26
|
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
27
|
-
const viewerContext = new
|
|
27
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
28
28
|
const data = {
|
|
29
29
|
id: 'what',
|
|
30
30
|
};
|
|
@@ -34,13 +34,13 @@ describe(Entity_1.default, () => {
|
|
|
34
34
|
databaseFields: data,
|
|
35
35
|
selectedFields: data,
|
|
36
36
|
});
|
|
37
|
-
expect(SimpleTestEntity_1.default.updater(testEntity
|
|
37
|
+
expect(SimpleTestEntity_1.default.updater(testEntity)).toBeInstanceOf(EntityMutator_1.UpdateMutator);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
describe('canViewerUpdateAsync', () => {
|
|
41
41
|
it('appropriately executes update privacy policy', async () => {
|
|
42
42
|
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
43
|
-
const viewerContext = new
|
|
43
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
44
44
|
const data = {
|
|
45
45
|
id: 'what',
|
|
46
46
|
};
|
|
@@ -50,12 +50,12 @@ describe(Entity_1.default, () => {
|
|
|
50
50
|
databaseFields: data,
|
|
51
51
|
selectedFields: data,
|
|
52
52
|
});
|
|
53
|
-
const canViewerUpdate = await SimpleTestDenyDeleteEntity.canViewerUpdateAsync(testEntity
|
|
53
|
+
const canViewerUpdate = await SimpleTestDenyDeleteEntity.canViewerUpdateAsync(testEntity);
|
|
54
54
|
expect(canViewerUpdate).toBe(true);
|
|
55
55
|
});
|
|
56
56
|
it('denies when policy denies', async () => {
|
|
57
57
|
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
58
|
-
const viewerContext = new
|
|
58
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
59
59
|
const data = {
|
|
60
60
|
id: 'what',
|
|
61
61
|
};
|
|
@@ -65,14 +65,14 @@ describe(Entity_1.default, () => {
|
|
|
65
65
|
databaseFields: data,
|
|
66
66
|
selectedFields: data,
|
|
67
67
|
});
|
|
68
|
-
const canViewerUpdate = await SimpleTestDenyUpdateEntity.canViewerUpdateAsync(testEntity
|
|
68
|
+
const canViewerUpdate = await SimpleTestDenyUpdateEntity.canViewerUpdateAsync(testEntity);
|
|
69
69
|
expect(canViewerUpdate).toBe(false);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
describe('canViewerDeleteAsync', () => {
|
|
73
73
|
it('appropriately executes update privacy policy', async () => {
|
|
74
74
|
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
75
|
-
const viewerContext = new
|
|
75
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
76
76
|
const data = {
|
|
77
77
|
id: 'what',
|
|
78
78
|
};
|
|
@@ -82,12 +82,12 @@ describe(Entity_1.default, () => {
|
|
|
82
82
|
databaseFields: data,
|
|
83
83
|
selectedFields: data,
|
|
84
84
|
});
|
|
85
|
-
const canViewerDelete = await SimpleTestDenyUpdateEntity.canViewerDeleteAsync(testEntity
|
|
85
|
+
const canViewerDelete = await SimpleTestDenyUpdateEntity.canViewerDeleteAsync(testEntity);
|
|
86
86
|
expect(canViewerDelete).toBe(true);
|
|
87
87
|
});
|
|
88
88
|
it('denies when policy denies', async () => {
|
|
89
89
|
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
90
|
-
const viewerContext = new
|
|
90
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
91
91
|
const data = {
|
|
92
92
|
id: 'what',
|
|
93
93
|
};
|
|
@@ -97,7 +97,7 @@ describe(Entity_1.default, () => {
|
|
|
97
97
|
databaseFields: data,
|
|
98
98
|
selectedFields: data,
|
|
99
99
|
});
|
|
100
|
-
const canViewerDelete = await SimpleTestDenyDeleteEntity.canViewerDeleteAsync(testEntity
|
|
100
|
+
const canViewerDelete = await SimpleTestDenyDeleteEntity.canViewerDeleteAsync(testEntity);
|
|
101
101
|
expect(canViewerDelete).toBe(false);
|
|
102
102
|
});
|
|
103
103
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity-test.js","sourceRoot":"","sources":["../../src/__tests__/Entity-test.ts"],"names":[],"mappings":";;;;;AAAA,uDAA+B;AAE/B,iFAAyD;AACzD,kDAA4C;AAC5C,oDAAgE;AAChE,iFAAyD;AACzD,yGAAiF;AACjF,uGAA+E;AAC/E,wFAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"Entity-test.js","sourceRoot":"","sources":["../../src/__tests__/Entity-test.ts"],"names":[],"mappings":";;;;;AAAA,uDAA+B;AAE/B,iFAAyD;AACzD,kDAA4C;AAC5C,oDAAgE;AAChE,iFAAyD;AACzD,qEAA6C;AAC7C,yGAAiF;AACjF,uGAA+E;AAC/E,wFAAgE;AAChE,kHAA+G;AAE/G,QAAQ,CAAC,gBAAM,EAAE,GAAG,EAAE;IACpB,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACvB,EAAE,CAAC,6BAA6B,EAAE,GAAG,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