@expo/entity 0.26.1 → 0.28.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/LICENSE +21 -0
- package/build/ComposedEntityCacheAdapter.d.ts +1 -1
- package/build/ComposedEntityCacheAdapter.js +1 -1
- package/build/ComposedSecondaryEntityCache.d.ts +1 -1
- package/build/ComposedSecondaryEntityCache.js +1 -1
- package/build/EnforcingEntityLoader.d.ts +10 -10
- package/build/EnforcingEntityLoader.js +8 -8
- package/build/EnforcingEntityLoader.js.map +1 -1
- package/build/Entity.d.ts +5 -5
- package/build/Entity.js +5 -5
- package/build/EntityAssociationLoader.d.ts +4 -4
- package/build/EntityCacheAdapter.d.ts +1 -1
- package/build/EntityCompanion.d.ts +1 -1
- package/build/EntityCompanion.js +1 -1
- package/build/EntityCompanionProvider.d.ts +9 -9
- package/build/EntityCompanionProvider.js +3 -3
- package/build/EntityConfiguration.d.ts +2 -2
- package/build/EntityDatabaseAdapter.d.ts +25 -6
- package/build/EntityDatabaseAdapter.js +8 -2
- package/build/EntityDatabaseAdapter.js.map +1 -1
- package/build/EntityFieldDefinition.d.ts +2 -2
- package/build/EntityFields.d.ts +9 -22
- package/build/EntityFields.js +10 -29
- package/build/EntityFields.js.map +1 -1
- package/build/EntityLoader.d.ts +10 -10
- package/build/EntityLoader.js +8 -8
- package/build/EntityLoader.js.map +1 -1
- package/build/EntityMutationTriggerConfiguration.d.ts +1 -1
- package/build/EntityMutationTriggerConfiguration.js +1 -1
- package/build/EntityMutator.d.ts +1 -1
- package/build/EntityMutator.js +1 -1
- package/build/EntityPrivacyPolicy.d.ts +6 -6
- package/build/EntityPrivacyPolicy.js +6 -6
- package/build/EntityQueryContext.d.ts +23 -3
- package/build/EntityQueryContext.js +43 -6
- package/build/EntityQueryContext.js.map +1 -1
- package/build/EntityQueryContextProvider.d.ts +10 -2
- package/build/EntityQueryContextProvider.js +18 -1
- package/build/EntityQueryContextProvider.js.map +1 -1
- package/build/EntitySecondaryCacheLoader.d.ts +1 -1
- package/build/EntitySecondaryCacheLoader.js +1 -1
- package/build/GenericSecondaryEntityCache.d.ts +1 -1
- package/build/GenericSecondaryEntityCache.js +1 -1
- package/build/ReadonlyEntity.d.ts +1 -1
- package/build/ReadonlyEntity.js +1 -1
- package/build/ViewerContext.d.ts +2 -2
- package/build/ViewerContext.js +2 -2
- package/build/ViewerScopedEntityCompanion.d.ts +2 -2
- package/build/ViewerScopedEntityCompanion.js +2 -2
- package/build/ViewerScopedEntityLoaderFactory.d.ts +1 -1
- package/build/ViewerScopedEntityLoaderFactory.js +1 -1
- package/build/ViewerScopedEntityMutatorFactory.d.ts +1 -1
- package/build/ViewerScopedEntityMutatorFactory.js +1 -1
- package/build/__tests__/EntityFields-test.js +0 -4
- package/build/__tests__/EntityFields-test.js.map +1 -1
- package/build/__tests__/EntityQueryContext-test.js +39 -0
- package/build/__tests__/EntityQueryContext-test.js.map +1 -1
- package/build/internal/EntityDataManager.d.ts +5 -5
- package/build/internal/EntityDataManager.js +3 -3
- package/build/internal/EntityDataManager.js.map +1 -1
- package/build/internal/ReadThroughEntityCache.d.ts +2 -2
- package/build/internal/ReadThroughEntityCache.js +2 -2
- package/build/metrics/IEntityMetricsAdapter.d.ts +10 -10
- package/build/rules/PrivacyPolicyRule.d.ts +1 -1
- package/build/rules/PrivacyPolicyRule.js +1 -1
- package/build/utils/collections/maps.d.ts +1 -1
- package/build/utils/collections/maps.js +1 -1
- package/build/utils/testing/PrivacyPolicyRuleTestUtils.d.ts +1 -2
- package/build/utils/testing/StubQueryContextProvider.d.ts +2 -1
- package/build/utils/testing/StubQueryContextProvider.js +5 -0
- package/build/utils/testing/StubQueryContextProvider.js.map +1 -1
- package/package.json +3 -2
- package/src/ComposedEntityCacheAdapter.ts +1 -1
- package/src/ComposedSecondaryEntityCache.ts +1 -1
- package/src/EnforcingEntityLoader.ts +14 -10
- package/src/Entity.ts +5 -5
- package/src/EntityAssociationLoader.ts +4 -4
- package/src/EntityCacheAdapter.ts +1 -1
- package/src/EntityCompanion.ts +1 -1
- package/src/EntityCompanionProvider.ts +9 -9
- package/src/EntityConfiguration.ts +2 -2
- package/src/EntityDatabaseAdapter.ts +43 -6
- package/src/EntityFieldDefinition.ts +2 -2
- package/src/EntityFields.ts +9 -28
- package/src/EntityLoader.ts +10 -9
- package/src/EntityMutationTriggerConfiguration.ts +1 -1
- package/src/EntityMutator.ts +1 -1
- package/src/EntityPrivacyPolicy.ts +6 -6
- package/src/EntityQueryContext.ts +63 -3
- package/src/EntityQueryContextProvider.ts +34 -2
- package/src/EntitySecondaryCacheLoader.ts +1 -1
- package/src/GenericSecondaryEntityCache.ts +1 -1
- package/src/ReadonlyEntity.ts +1 -1
- package/src/ViewerContext.ts +2 -2
- package/src/ViewerScopedEntityCompanion.ts +2 -2
- package/src/ViewerScopedEntityLoaderFactory.ts +1 -1
- package/src/ViewerScopedEntityMutatorFactory.ts +1 -1
- package/src/__tests__/EntityFields-test.ts +0 -12
- package/src/__tests__/EntityQueryContext-test.ts +50 -0
- package/src/internal/EntityDataManager.ts +5 -4
- package/src/internal/ReadThroughEntityCache.ts +2 -2
- package/src/metrics/IEntityMetricsAdapter.ts +10 -10
- package/src/rules/PrivacyPolicyRule.ts +1 -1
- package/src/utils/collections/maps.ts +1 -1
- package/src/utils/testing/PrivacyPolicyRuleTestUtils.ts +1 -1
- package/src/utils/testing/StubQueryContextProvider.ts +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityQueryContext.js","sourceRoot":"","sources":["../src/EntityQueryContext.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAU5B;;;;;;GAMG;AACH,MAAsB,kBAAkB;IACtC,YAA6B,cAAmB;QAAnB,mBAAc,GAAd,cAAc,CAAK;IAAG,CAAC;IAIpD,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CAKF;AAZD,gDAYC;AAED;;;;;GAKG;AACH,MAAa,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J,CAAC;IAEM,mCAAmC;QACxC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,yCAAyC,EAAE;YACrE,IAAI,CAAC,kBAAkB,CAAC,oCAAoC,CAAC,QAAQ,CAAC,CAAC;SACxE;QAED,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,6BAA6B,EAAE;YACzD,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;SAC5D;IACH,CAAC;CACF;AAnCD,sFAmCC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityTransactionalQueryContext, EntityNonTransactionalQueryContext } from './EntityQueryContext';
|
|
1
|
+
import { EntityTransactionalQueryContext, EntityNonTransactionalQueryContext, EntityNestedTransactionalQueryContext } from './EntityQueryContext';
|
|
2
2
|
/**
|
|
3
3
|
* A query context provider vends transactional and non-transactional query contexts.
|
|
4
4
|
*/
|
|
@@ -12,12 +12,20 @@ export default abstract class EntityQueryContextProvider {
|
|
|
12
12
|
*/
|
|
13
13
|
protected abstract getQueryInterface(): any;
|
|
14
14
|
/**
|
|
15
|
-
* Vend a transaction runner for use in
|
|
15
|
+
* Vend a transaction runner for use in runInTransactionAsync.
|
|
16
16
|
*/
|
|
17
17
|
protected abstract createTransactionRunner<T>(): (transactionScope: (queryInterface: any) => Promise<T>) => Promise<T>;
|
|
18
|
+
protected abstract createNestedTransactionRunner<T>(outerQueryInterface: any): (transactionScope: (queryInterface: any) => Promise<T>) => Promise<T>;
|
|
18
19
|
/**
|
|
19
20
|
* Start a transaction and execute the provided transaction-scoped closure within the transaction.
|
|
20
21
|
* @param transactionScope - async callback to execute within the transaction
|
|
21
22
|
*/
|
|
22
23
|
runInTransactionAsync<T>(transactionScope: (queryContext: EntityTransactionalQueryContext) => Promise<T>): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Start a nested transaction from the specified parent transaction and execure the
|
|
26
|
+
* provided nested-transaction-scoped closure within the nested transaction.
|
|
27
|
+
* @param outerQueryContext - the query context of the parent transaction
|
|
28
|
+
* @param transactionScope - async callback to execute within the nested transaction
|
|
29
|
+
*/
|
|
30
|
+
runInNestedTransactionAsync<T>(outerQueryContext: EntityTransactionalQueryContext, transactionScope: (innerQueryContext: EntityNestedTransactionalQueryContext) => Promise<T>): Promise<T>;
|
|
23
31
|
}
|
|
@@ -17,7 +17,7 @@ class EntityQueryContextProvider {
|
|
|
17
17
|
*/
|
|
18
18
|
async runInTransactionAsync(transactionScope) {
|
|
19
19
|
const [returnedValue, queryContext] = await this.createTransactionRunner()(async (queryInterface) => {
|
|
20
|
-
const queryContext = new EntityQueryContext_1.EntityTransactionalQueryContext(queryInterface);
|
|
20
|
+
const queryContext = new EntityQueryContext_1.EntityTransactionalQueryContext(queryInterface, this);
|
|
21
21
|
const result = await transactionScope(queryContext);
|
|
22
22
|
await queryContext.runPreCommitCallbacksAsync();
|
|
23
23
|
return [result, queryContext];
|
|
@@ -25,6 +25,23 @@ class EntityQueryContextProvider {
|
|
|
25
25
|
await queryContext.runPostCommitCallbacksAsync();
|
|
26
26
|
return returnedValue;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Start a nested transaction from the specified parent transaction and execure the
|
|
30
|
+
* provided nested-transaction-scoped closure within the nested transaction.
|
|
31
|
+
* @param outerQueryContext - the query context of the parent transaction
|
|
32
|
+
* @param transactionScope - async callback to execute within the nested transaction
|
|
33
|
+
*/
|
|
34
|
+
async runInNestedTransactionAsync(outerQueryContext, transactionScope) {
|
|
35
|
+
const [returnedValue, innerQueryContext] = await this.createNestedTransactionRunner(outerQueryContext.getQueryInterface())(async (innerQueryInterface) => {
|
|
36
|
+
const innerQueryContext = new EntityQueryContext_1.EntityNestedTransactionalQueryContext(innerQueryInterface, outerQueryContext, this);
|
|
37
|
+
const result = await transactionScope(innerQueryContext);
|
|
38
|
+
await innerQueryContext.runPreCommitCallbacksAsync();
|
|
39
|
+
return [result, innerQueryContext];
|
|
40
|
+
});
|
|
41
|
+
// post-commit callbacks are appended to parent transaction instead of run, but only after the transaction has succeeded
|
|
42
|
+
innerQueryContext.transferPostCommitCallbacksToParent();
|
|
43
|
+
return returnedValue;
|
|
44
|
+
}
|
|
28
45
|
}
|
|
29
46
|
exports.default = EntityQueryContextProvider;
|
|
30
47
|
//# sourceMappingURL=EntityQueryContextProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityQueryContextProvider.js","sourceRoot":"","sources":["../src/EntityQueryContextProvider.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"EntityQueryContextProvider.js","sourceRoot":"","sources":["../src/EntityQueryContextProvider.ts"],"names":[],"mappings":";;AAAA,6DAI8B;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;QAE/E,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,GAAG,MAAM,IAAI,CAAC,uBAAuB,EAErE,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE;YAC3B,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;AArED,6CAqEC"}
|
|
@@ -30,7 +30,7 @@ export interface ISecondaryEntityCache<TFields, TLoadParams> {
|
|
|
30
30
|
* when the underlying data of a cache key could be stale.
|
|
31
31
|
*
|
|
32
32
|
* This is most commonly used to further optimize hot paths that cannot make use of normal entity cache loading
|
|
33
|
-
* due to use of a non-unique-field-based
|
|
33
|
+
* due to use of a non-unique-field-based EntityLoader method like `loadManyByFieldEqualityConjunctionAsync` or
|
|
34
34
|
* `loadManyByRawWhereClauseAsync`.
|
|
35
35
|
*/
|
|
36
36
|
export default abstract class EntitySecondaryCacheLoader<TLoadParams, TFields, 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 = keyof TFields> {
|
|
@@ -9,7 +9,7 @@ const maps_1 = require("./utils/collections/maps");
|
|
|
9
9
|
* when the underlying data of a cache key could be stale.
|
|
10
10
|
*
|
|
11
11
|
* This is most commonly used to further optimize hot paths that cannot make use of normal entity cache loading
|
|
12
|
-
* due to use of a non-unique-field-based
|
|
12
|
+
* due to use of a non-unique-field-based EntityLoader method like `loadManyByFieldEqualityConjunctionAsync` or
|
|
13
13
|
* `loadManyByRawWhereClauseAsync`.
|
|
14
14
|
*/
|
|
15
15
|
class EntitySecondaryCacheLoader {
|
|
@@ -3,7 +3,7 @@ import IEntityGenericCacher from './IEntityGenericCacher';
|
|
|
3
3
|
/**
|
|
4
4
|
* A custom secondary read-through entity cache is a way to add a custom second layer of caching for a particular
|
|
5
5
|
* single entity load. One common way this may be used is to add a second layer of caching in a hot path that makes
|
|
6
|
-
* a call to
|
|
6
|
+
* a call to EntityLoader.loadManyByFieldEqualityConjunctionAsync is guaranteed to return at most one entity.
|
|
7
7
|
*/
|
|
8
8
|
export default abstract class GenericSecondaryEntityCache<TFields, TLoadParams> implements ISecondaryEntityCache<TFields, TLoadParams> {
|
|
9
9
|
protected readonly cacher: IEntityGenericCacher<TFields>;
|
|
@@ -9,7 +9,7 @@ const maps_1 = require("./utils/collections/maps");
|
|
|
9
9
|
/**
|
|
10
10
|
* A custom secondary read-through entity cache is a way to add a custom second layer of caching for a particular
|
|
11
11
|
* single entity load. One common way this may be used is to add a second layer of caching in a hot path that makes
|
|
12
|
-
* a call to
|
|
12
|
+
* a call to EntityLoader.loadManyByFieldEqualityConjunctionAsync is guaranteed to return at most one entity.
|
|
13
13
|
*/
|
|
14
14
|
class GenericSecondaryEntityCache {
|
|
15
15
|
constructor(cacher, constructCacheKey) {
|
|
@@ -36,7 +36,7 @@ export default abstract class ReadonlyEntity<TFields, TID extends NonNullable<TF
|
|
|
36
36
|
*/
|
|
37
37
|
getID(): TID;
|
|
38
38
|
/**
|
|
39
|
-
* @returns
|
|
39
|
+
* @returns EntityAssociationLoader for this entity
|
|
40
40
|
*/
|
|
41
41
|
associationLoader(): EntityAssociationLoader<TFields, TID, TViewerContext, this, TSelectedFields>;
|
|
42
42
|
/**
|
package/build/ReadonlyEntity.js
CHANGED
package/build/ViewerContext.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { EntityQueryContext, EntityTransactionalQueryContext } from './EntityQue
|
|
|
5
5
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
6
|
import ViewerScopedEntityCompanion from './ViewerScopedEntityCompanion';
|
|
7
7
|
/**
|
|
8
|
-
* A viewer context encapsulates all information necessary to evaluate an
|
|
8
|
+
* A viewer context encapsulates all information necessary to evaluate an EntityPrivacyPolicy.
|
|
9
9
|
*
|
|
10
|
-
* In combination with an
|
|
10
|
+
* In combination with an EntityCompanionProvider, a viewer context is the
|
|
11
11
|
* entry point into the Entity framework.
|
|
12
12
|
*/
|
|
13
13
|
export default class ViewerContext {
|
package/build/ViewerContext.js
CHANGED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const ViewerScopedEntityCompanionProvider_1 = __importDefault(require("./ViewerScopedEntityCompanionProvider"));
|
|
7
7
|
/**
|
|
8
|
-
* A viewer context encapsulates all information necessary to evaluate an
|
|
8
|
+
* A viewer context encapsulates all information necessary to evaluate an EntityPrivacyPolicy.
|
|
9
9
|
*
|
|
10
|
-
* In combination with an
|
|
10
|
+
* In combination with an EntityCompanionProvider, a viewer context is the
|
|
11
11
|
* entry point into the Entity framework.
|
|
12
12
|
*/
|
|
13
13
|
class ViewerContext {
|
|
@@ -7,7 +7,7 @@ import ViewerScopedEntityLoaderFactory from './ViewerScopedEntityLoaderFactory';
|
|
|
7
7
|
import ViewerScopedEntityMutatorFactory from './ViewerScopedEntityMutatorFactory';
|
|
8
8
|
import IEntityMetricsAdapter from './metrics/IEntityMetricsAdapter';
|
|
9
9
|
/**
|
|
10
|
-
* Provides a simpler API for loading and mutating entities by injecting the
|
|
10
|
+
* Provides a simpler API for loading and mutating entities by injecting the ViewerContext
|
|
11
11
|
* from the viewer-scoped entity companion provider.
|
|
12
12
|
*/
|
|
13
13
|
export default class ViewerScopedEntityCompanion<TFields, 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> {
|
|
@@ -27,7 +27,7 @@ export default class ViewerScopedEntityCompanion<TFields, TID extends NonNullabl
|
|
|
27
27
|
*/
|
|
28
28
|
getQueryContextProvider(): EntityQueryContextProvider;
|
|
29
29
|
/**
|
|
30
|
-
* Get the
|
|
30
|
+
* Get the IEntityMetricsAdapter for this companion.
|
|
31
31
|
*/
|
|
32
32
|
getMetricsAdapter(): IEntityMetricsAdapter;
|
|
33
33
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const ViewerScopedEntityLoaderFactory_1 = __importDefault(require("./ViewerScopedEntityLoaderFactory"));
|
|
7
7
|
const ViewerScopedEntityMutatorFactory_1 = __importDefault(require("./ViewerScopedEntityMutatorFactory"));
|
|
8
8
|
/**
|
|
9
|
-
* Provides a simpler API for loading and mutating entities by injecting the
|
|
9
|
+
* Provides a simpler API for loading and mutating entities by injecting the ViewerContext
|
|
10
10
|
* from the viewer-scoped entity companion provider.
|
|
11
11
|
*/
|
|
12
12
|
class ViewerScopedEntityCompanion {
|
|
@@ -33,7 +33,7 @@ class ViewerScopedEntityCompanion {
|
|
|
33
33
|
return this.entityCompanion.getQueryContextProvider();
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Get the
|
|
36
|
+
* Get the IEntityMetricsAdapter for this companion.
|
|
37
37
|
*/
|
|
38
38
|
getMetricsAdapter() {
|
|
39
39
|
return this.entityCompanion.getMetricsAdapter();
|
|
@@ -5,7 +5,7 @@ import { EntityQueryContext } from './EntityQueryContext';
|
|
|
5
5
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
6
|
import ViewerContext from './ViewerContext';
|
|
7
7
|
/**
|
|
8
|
-
* Provides a cleaner API for loading entities by passing through the
|
|
8
|
+
* Provides a cleaner API for loading entities by passing through the ViewerContext.
|
|
9
9
|
*/
|
|
10
10
|
export default class ViewerScopedEntityLoaderFactory<TFields, 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> {
|
|
11
11
|
private readonly entityLoaderFactory;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
-
* Provides a cleaner API for loading entities by passing through the
|
|
4
|
+
* Provides a cleaner API for loading entities by passing through the ViewerContext.
|
|
5
5
|
*/
|
|
6
6
|
class ViewerScopedEntityLoaderFactory {
|
|
7
7
|
constructor(entityLoaderFactory, viewerContext) {
|
|
@@ -5,7 +5,7 @@ import { EntityQueryContext } from './EntityQueryContext';
|
|
|
5
5
|
import ReadonlyEntity from './ReadonlyEntity';
|
|
6
6
|
import ViewerContext from './ViewerContext';
|
|
7
7
|
/**
|
|
8
|
-
* Provides a cleaner API for mutating entities by passing through the
|
|
8
|
+
* Provides a cleaner API for mutating entities by passing through the ViewerContext.
|
|
9
9
|
*/
|
|
10
10
|
export default class ViewerScopedEntityMutatorFactory<TFields, 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> {
|
|
11
11
|
private readonly entityMutatorFactory;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
-
* Provides a cleaner API for mutating entities by passing through the
|
|
4
|
+
* Provides a cleaner API for mutating entities by passing through the ViewerContext.
|
|
5
5
|
*/
|
|
6
6
|
class ViewerScopedEntityMutatorFactory {
|
|
7
7
|
constructor(entityMutatorFactory, viewerContext) {
|
|
@@ -48,8 +48,4 @@ describe(EntityFieldDefinition_1.EntityFieldDefinition, () => {
|
|
|
48
48
|
['hello']);
|
|
49
49
|
(0, describeFieldTestCase_1.default)(new EntityFields_1.JSONObjectField({ columnName: 'wat' }), [{}], [true, 'hello']);
|
|
50
50
|
(0, describeFieldTestCase_1.default)(new EntityFields_1.EnumField({ columnName: 'wat' }), ['hello', 1], [true]);
|
|
51
|
-
(0, describeFieldTestCase_1.default)(new EntityFields_1.JSONArrayField({ columnName: 'wat' }), [[[1, 2]], [['hello']]], // jest test cases need extra wrapping array
|
|
52
|
-
[1, 'hello']);
|
|
53
|
-
(0, describeFieldTestCase_1.default)(new EntityFields_1.MaybeJSONArrayField({ columnName: 'wat' }), [1, 'hello', [['hello']]], // jest test cases need extra wrapping array
|
|
54
|
-
[]);
|
|
55
51
|
//# sourceMappingURL=EntityFields-test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityFields-test.js","sourceRoot":"","sources":["../../src/__tests__/EntityFields-test.ts"],"names":[],"mappings":";;;;;AAAA,+BAA8E;AAE9E,oEAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"EntityFields-test.js","sourceRoot":"","sources":["../../src/__tests__/EntityFields-test.ts"],"names":[],"mappings":";;;;;AAAA,+BAA8E;AAE9E,oEAAiE;AACjE,kDAUyB;AACzB,mGAA2E;AAE3E,MAAM,mBAAoB,SAAQ,6CAA6B;IACnD,0BAA0B,CAAC,KAAa;QAChD,OAAO,KAAK,KAAK,YAAY,CAAC;IAChC,CAAC;CACF;AAED,QAAQ,CAAC,6CAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,gBAAgB,GAAG,IAAI,mBAA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E,KAAK,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1F,IAAA,+BAAqB,EAAC,IAAI,uBAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAClF,IAAA,+BAAqB,EAAC,IAAI,yBAAU,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACpF,IAAA,+BAAqB,EACnB,IAAI,+BAAgB,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAC3C,CAAC,CAAC,CAAC,MAAM,CAAC,CAAQ,EAAE,CAAC,EAAE,CAAQ,CAAC,EAAE,4CAA4C;AAC9E,CAAC,OAAO,CAAC,CACV,CAAC;AACF,IAAA,+BAAqB,EAAC,IAAI,8BAAe,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AACzF,IAAA,+BAAqB,EAAC,IAAI,wBAAS,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -51,6 +51,45 @@ describe(EntityQueryContext_1.EntityQueryContext, () => {
|
|
|
51
51
|
expect(postCommitCallback).toHaveBeenCalledTimes(0);
|
|
52
52
|
expect(postCommitInvalidationCallback).toHaveBeenCalledTimes(0);
|
|
53
53
|
});
|
|
54
|
+
it('calls callbacks correctly for nested transactions', async () => {
|
|
55
|
+
const companionProvider = (0, createUnitTestEntityCompanionProvider_1.createUnitTestEntityCompanionProvider)();
|
|
56
|
+
const viewerContext = new ViewerContext_1.default(companionProvider);
|
|
57
|
+
const preCommitCallback = jest.fn(async () => { });
|
|
58
|
+
const preCommitNestedCallback = jest.fn(async () => { });
|
|
59
|
+
const preCommitNestedCallbackThrow = jest.fn(async () => {
|
|
60
|
+
throw new Error('wat');
|
|
61
|
+
});
|
|
62
|
+
const postCommitInvalidationCallback = jest.fn(async () => { });
|
|
63
|
+
const postCommitCallback = jest.fn(async () => { });
|
|
64
|
+
await viewerContext.runInTransactionForDatabaseAdaptorFlavorAsync('postgres', async (queryContext) => {
|
|
65
|
+
queryContext.appendPostCommitCallback(postCommitCallback);
|
|
66
|
+
queryContext.appendPostCommitInvalidationCallback(postCommitInvalidationCallback);
|
|
67
|
+
queryContext.appendPreCommitCallback(preCommitCallback, 0);
|
|
68
|
+
await Promise.all([
|
|
69
|
+
queryContext.runInNestedTransactionAsync(async (innerQueryContext) => {
|
|
70
|
+
innerQueryContext.appendPostCommitCallback(postCommitCallback);
|
|
71
|
+
innerQueryContext.appendPostCommitInvalidationCallback(postCommitInvalidationCallback);
|
|
72
|
+
innerQueryContext.appendPreCommitCallback(preCommitNestedCallback, 0);
|
|
73
|
+
}),
|
|
74
|
+
(async () => {
|
|
75
|
+
try {
|
|
76
|
+
await queryContext.runInNestedTransactionAsync(async (innerQueryContext) => {
|
|
77
|
+
// these two shouldn't be called
|
|
78
|
+
innerQueryContext.appendPostCommitCallback(postCommitCallback);
|
|
79
|
+
innerQueryContext.appendPostCommitInvalidationCallback(postCommitInvalidationCallback);
|
|
80
|
+
innerQueryContext.appendPreCommitCallback(preCommitNestedCallbackThrow, 0);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch { }
|
|
84
|
+
})(),
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
expect(preCommitCallback).toHaveBeenCalledTimes(1);
|
|
88
|
+
expect(preCommitNestedCallback).toHaveBeenCalledTimes(1);
|
|
89
|
+
expect(preCommitNestedCallbackThrow).toHaveBeenCalledTimes(1);
|
|
90
|
+
expect(postCommitCallback).toHaveBeenCalledTimes(2);
|
|
91
|
+
expect(postCommitInvalidationCallback).toHaveBeenCalledTimes(2);
|
|
92
|
+
});
|
|
54
93
|
});
|
|
55
94
|
});
|
|
56
95
|
//# sourceMappingURL=EntityQueryContext-test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityQueryContext-test.js","sourceRoot":"","sources":["../../src/__tests__/EntityQueryContext-test.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC,8DAA2D;AAC3D,qEAA6C;AAC7C,kHAA+G;AAE/G,QAAQ,CAAC,uCAAkB,EAAE,GAAG,EAAE;IAChC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;YACjE,MAAM,iBAAiB,GAAG,IAAA,6EAAqC,GAAE,CAAC;YAClE,MAAM,aAAa,GAAG,IAAI,uBAAa,CAAC,iBAAiB,CAAC,CAAC;YAE3D,MAAM,sBAAsB,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,IAAmB,EAAE,GAAE,CAAC,CAAC,CAAC;YACtE,MAAM,uBAAuB,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,IAAmB,EAAE,GAAE,CAAC,CAAC,CAAC;YACvE,MAAM,8BAA8B,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,IAAmB,EAAE;gBACvE,IAAA,mBAAS,EACP,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAC9C,0DAA0D,CAC3D,CAAC;gBACF,IAAA,mBAAS,EACP,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAC/C,0DAA0D,CAC3D,CAAC;YACJ,CAAC,CAAC,CAAC;YACH,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,IAA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QuerySelectionModifiers } from '../EntityDatabaseAdapter';
|
|
1
|
+
import EntityDatabaseAdapter, { FieldEqualityCondition, QuerySelectionModifiers, QuerySelectionModifiersWithOrderByRaw } from '../EntityDatabaseAdapter';
|
|
2
2
|
import { EntityQueryContext } from '../EntityQueryContext';
|
|
3
3
|
import EntityQueryContextProvider from '../EntityQueryContextProvider';
|
|
4
4
|
import IEntityMetricsAdapter from '../metrics/IEntityMetricsAdapter';
|
|
5
5
|
import ReadThroughEntityCache from './ReadThroughEntityCache';
|
|
6
6
|
/**
|
|
7
7
|
* A data manager is responsible for orchestrating multiple sources of entity
|
|
8
|
-
* data including local caches,
|
|
8
|
+
* data including local caches, EntityCacheAdapter, and EntityDatabaseAdapter.
|
|
9
9
|
*
|
|
10
|
-
* It is also responsible for invalidating all sources of data when mutated using
|
|
10
|
+
* It is also responsible for invalidating all sources of data when mutated using EntityMutator.
|
|
11
11
|
*/
|
|
12
12
|
export default class EntityDataManager<TFields> {
|
|
13
13
|
private readonly databaseAdapter;
|
|
@@ -45,10 +45,10 @@ export default class EntityDataManager<TFields> {
|
|
|
45
45
|
* @param queryContext - query context in which to perform the load
|
|
46
46
|
* @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
|
|
47
47
|
* @param bindings - array of positional bindings or object of named bindings
|
|
48
|
-
* @param querySelectionModifiers - limit, offset, and
|
|
48
|
+
* @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
|
|
49
49
|
* @returns array of objects matching the query
|
|
50
50
|
*/
|
|
51
|
-
loadManyByRawWhereClauseAsync(queryContext: EntityQueryContext, rawWhereClause: string, bindings: any[] | object, querySelectionModifiers:
|
|
51
|
+
loadManyByRawWhereClauseAsync(queryContext: EntityQueryContext, rawWhereClause: string, bindings: any[] | object, querySelectionModifiers: QuerySelectionModifiersWithOrderByRaw<TFields>): Promise<readonly Readonly<TFields>[]>;
|
|
52
52
|
private invalidateManyByFieldEqualingAsync;
|
|
53
53
|
/**
|
|
54
54
|
* Invalidate all caches, in-memory or otherwise, for an object.
|
|
@@ -10,9 +10,9 @@ const IEntityMetricsAdapter_1 = require("../metrics/IEntityMetricsAdapter");
|
|
|
10
10
|
const maps_1 = require("../utils/collections/maps");
|
|
11
11
|
/**
|
|
12
12
|
* A data manager is responsible for orchestrating multiple sources of entity
|
|
13
|
-
* data including local caches,
|
|
13
|
+
* data including local caches, EntityCacheAdapter, and EntityDatabaseAdapter.
|
|
14
14
|
*
|
|
15
|
-
* It is also responsible for invalidating all sources of data when mutated using
|
|
15
|
+
* It is also responsible for invalidating all sources of data when mutated using EntityMutator.
|
|
16
16
|
*/
|
|
17
17
|
class EntityDataManager {
|
|
18
18
|
constructor(databaseAdapter, entityCache, queryContextProvider, metricsAdapter, entityClassName) {
|
|
@@ -98,7 +98,7 @@ class EntityDataManager {
|
|
|
98
98
|
* @param queryContext - query context in which to perform the load
|
|
99
99
|
* @param rawWhereClause - parameterized SQL WHERE clause with positional binding placeholders or named binding placeholders
|
|
100
100
|
* @param bindings - array of positional bindings or object of named bindings
|
|
101
|
-
* @param querySelectionModifiers - limit, offset, and
|
|
101
|
+
* @param querySelectionModifiers - limit, offset, orderBy, and orderByRaw for the query
|
|
102
102
|
* @returns array of objects matching the query
|
|
103
103
|
*/
|
|
104
104
|
async loadManyByRawWhereClauseAsync(queryContext, rawWhereClause, bindings, querySelectionModifiers) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityDataManager.js","sourceRoot":"","sources":["../../src/internal/EntityDataManager.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;
|
|
1
|
+
{"version":3,"file":"EntityDataManager.js","sourceRoot":"","sources":["../../src/internal/EntityDataManager.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AASpC,gDAAiD;AACjD,sEAGuC;AACvC,4EAG0C;AAC1C,oDAAsE;AAGtE;;;;;GAKG;AACH,MAAqB,iBAAiB;IAMpC,YACmB,eAA+C,EAC/C,WAA4C,EAC5C,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AW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,2BAA2B,CAAC,YAA+B;QAC/D,6CAA6C;QAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAsB,CAAC;QAC5D,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAwB,EAAE,EAAE;YAC1C,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;YACtC,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvB,MAAM,IAAI,CAAC,kCAAkC,CAAC,SAAS,EAAE;oBACvD,KAA4C;iBAC7C,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAxMD,oCAwMC"}
|
|
@@ -14,8 +14,8 @@ export declare type CacheLoadResult<TFields> = {
|
|
|
14
14
|
status: CacheStatus.NEGATIVE;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* A read-through entity cache is responsible for coordinating
|
|
18
|
-
*
|
|
17
|
+
* A read-through entity cache is responsible for coordinating EntityDatabaseAdapter and
|
|
18
|
+
* EntityCacheAdapter within the EntityDataManager.
|
|
19
19
|
*/
|
|
20
20
|
export default class ReadThroughEntityCache<TFields> {
|
|
21
21
|
private readonly entityConfiguration;
|
|
@@ -13,8 +13,8 @@ var CacheStatus;
|
|
|
13
13
|
CacheStatus[CacheStatus["NEGATIVE"] = 2] = "NEGATIVE";
|
|
14
14
|
})(CacheStatus = exports.CacheStatus || (exports.CacheStatus = {}));
|
|
15
15
|
/**
|
|
16
|
-
* A read-through entity cache is responsible for coordinating
|
|
17
|
-
*
|
|
16
|
+
* A read-through entity cache is responsible for coordinating EntityDatabaseAdapter and
|
|
17
|
+
* EntityCacheAdapter within the EntityDataManager.
|
|
18
18
|
*/
|
|
19
19
|
class ReadThroughEntityCache {
|
|
20
20
|
constructor(entityConfiguration, entityCacheAdapter) {
|
|
@@ -5,15 +5,15 @@ export declare enum EntityMetricsLoadType {
|
|
|
5
5
|
LOAD_MANY_RAW = 2
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* Event about a single call to an
|
|
8
|
+
* Event about a single call to an EntityLoader method.
|
|
9
9
|
*/
|
|
10
10
|
export interface EntityMetricsLoadEvent {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* EntityMetricsLoadType for this load.
|
|
13
13
|
*/
|
|
14
14
|
type: EntityMetricsLoadType;
|
|
15
15
|
/**
|
|
16
|
-
* Class name of the
|
|
16
|
+
* Class name of the Entity being loaded.
|
|
17
17
|
*/
|
|
18
18
|
entityClassName: string;
|
|
19
19
|
/**
|
|
@@ -32,11 +32,11 @@ export declare enum EntityMetricsMutationType {
|
|
|
32
32
|
}
|
|
33
33
|
export interface EntityMetricsMutationEvent {
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* EntityMetricsMutationType for this mutation.
|
|
36
36
|
*/
|
|
37
37
|
type: EntityMetricsMutationType;
|
|
38
38
|
/**
|
|
39
|
-
* Class name of the
|
|
39
|
+
* Class name of the Entity being mutated.
|
|
40
40
|
*/
|
|
41
41
|
entityClassName: string;
|
|
42
42
|
/**
|
|
@@ -60,7 +60,7 @@ export declare enum IncrementLoadCountEventType {
|
|
|
60
60
|
DATABASE = 2
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* Event used to record dataloader, cache, and database load counts in
|
|
63
|
+
* Event used to record dataloader, cache, and database load counts in EntityDataManager.
|
|
64
64
|
*/
|
|
65
65
|
export interface IncrementLoadCountEvent {
|
|
66
66
|
/**
|
|
@@ -72,7 +72,7 @@ export interface IncrementLoadCountEvent {
|
|
|
72
72
|
*/
|
|
73
73
|
fieldValueCount: number;
|
|
74
74
|
/**
|
|
75
|
-
* Class name of the
|
|
75
|
+
* Class name of the Entity being loaded.
|
|
76
76
|
*/
|
|
77
77
|
entityClassName: string;
|
|
78
78
|
}
|
|
@@ -81,11 +81,11 @@ export declare enum EntityMetricsAuthorizationResult {
|
|
|
81
81
|
ALLOW = 1
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Event used to record a singe
|
|
84
|
+
* Event used to record a singe EntityPrivacyPolicy authorization.
|
|
85
85
|
*/
|
|
86
86
|
export interface EntityMetricsAuthorizationEvent {
|
|
87
87
|
/**
|
|
88
|
-
* Class name of the
|
|
88
|
+
* Class name of the Entity being authorized.
|
|
89
89
|
*/
|
|
90
90
|
entityClassName: string;
|
|
91
91
|
action: EntityAuthorizationAction;
|
|
@@ -98,7 +98,7 @@ export interface EntityMetricsAuthorizationEvent {
|
|
|
98
98
|
*/
|
|
99
99
|
export default interface IEntityMetricsAdapter {
|
|
100
100
|
/**
|
|
101
|
-
* Called when a
|
|
101
|
+
* Called when a EntityPrivacyPolicy authorization succeeds or fails.
|
|
102
102
|
* @param authorizationEvent - info about the authorization event
|
|
103
103
|
*/
|
|
104
104
|
logAuthorizationEvent(authorizationEvent: EntityMetricsAuthorizationEvent): void;
|
|
@@ -28,7 +28,7 @@ export declare enum RuleEvaluationResult {
|
|
|
28
28
|
* rule in the privacy policy. If all rules in the policy SKIP, the policy is denied.
|
|
29
29
|
*
|
|
30
30
|
* Returning DENY from a rule is useful in a few notable cases:
|
|
31
|
-
* - Preventing a CRUD action on an entity (
|
|
31
|
+
* - Preventing a CRUD action on an entity (AlwaysDenyPrivacyPolicyRule)
|
|
32
32
|
* - Blocking. For example, a user blocks another user from seeing their posts, and the rule
|
|
33
33
|
* would be named something like `DenyIfViewerHasBeenBlockedPrivacyPolicyRule`.
|
|
34
34
|
*/
|
|
@@ -28,7 +28,7 @@ var RuleEvaluationResult;
|
|
|
28
28
|
* rule in the privacy policy. If all rules in the policy SKIP, the policy is denied.
|
|
29
29
|
*
|
|
30
30
|
* Returning DENY from a rule is useful in a few notable cases:
|
|
31
|
-
* - Preventing a CRUD action on an entity (
|
|
31
|
+
* - Preventing a CRUD action on an entity (AlwaysDenyPrivacyPolicyRule)
|
|
32
32
|
* - Blocking. For example, a user blocks another user from seeing their posts, and the rule
|
|
33
33
|
* would be named something like `DenyIfViewerHasBeenBlockedPrivacyPolicyRule`.
|
|
34
34
|
*/
|
|
@@ -23,7 +23,7 @@ export declare const mapMap: <K, V, M>(map: ReadonlyMap<K, V>, mapper: (value: V
|
|
|
23
23
|
export declare const mapMapAsync: <K, V, M>(map: ReadonlyMap<K, V>, mapper: (value: V, key: K) => Promise<M>) => Promise<Map<K, M>>;
|
|
24
24
|
/**
|
|
25
25
|
* Create a new Map by associating the value of each key with mapper executed for each key in the source map.
|
|
26
|
-
* The opposite of
|
|
26
|
+
* The opposite of mapMap. In the event two source keys map to the same result key, the second source key's
|
|
27
27
|
* value will overwrite the first, in which case the cardinality of the returned map may be smaller than the
|
|
28
28
|
* source map's.
|
|
29
29
|
*
|
|
@@ -53,7 +53,7 @@ const mapMapAsync = async function (map, mapper) {
|
|
|
53
53
|
exports.mapMapAsync = mapMapAsync;
|
|
54
54
|
/**
|
|
55
55
|
* Create a new Map by associating the value of each key with mapper executed for each key in the source map.
|
|
56
|
-
* The opposite of
|
|
56
|
+
* The opposite of mapMap. In the event two source keys map to the same result key, the second source key's
|
|
57
57
|
* value will overwrite the first, in which case the cardinality of the returned map may be smaller than the
|
|
58
58
|
* source map's.
|
|
59
59
|
*
|
|
@@ -9,7 +9,7 @@ export interface Case<TFields, TID extends NonNullable<TFields[TSelectedFields]>
|
|
|
9
9
|
evaluationContext: EntityPrivacyPolicyEvaluationContext;
|
|
10
10
|
entity: TEntity;
|
|
11
11
|
}
|
|
12
|
-
declare type CaseMap<TFields, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> = Map<string, () => Promise<Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>>>;
|
|
12
|
+
export declare type CaseMap<TFields, TID extends NonNullable<TFields[TSelectedFields]>, TViewerContext extends ViewerContext, TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>, TSelectedFields extends keyof TFields> = Map<string, () => Promise<Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>>>;
|
|
13
13
|
/**
|
|
14
14
|
* Useful for defining test cases that have async preconditions.
|
|
15
15
|
*/
|
|
@@ -26,4 +26,3 @@ export declare const describePrivacyPolicyRule: <TFields, TID extends NonNullabl
|
|
|
26
26
|
skipCases?: Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
27
27
|
denyCases?: Case<TFields, TID, TViewerContext, TEntity, TSelectedFields>[];
|
|
28
28
|
}) => void;
|
|
29
|
-
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import EntityQueryContextProvider from '../../EntityQueryContextProvider';
|
|
2
|
-
declare class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
2
|
+
export declare class StubQueryContextProvider extends EntityQueryContextProvider {
|
|
3
3
|
protected getQueryInterface(): any;
|
|
4
4
|
protected createTransactionRunner<T>(): (transactionScope: (queryInterface: any) => Promise<T>) => Promise<T>;
|
|
5
|
+
protected createNestedTransactionRunner<T>(_outerQueryInterface: any): (transactionScope: (queryInterface: any) => Promise<T>) => Promise<T>;
|
|
5
6
|
}
|
|
6
7
|
declare const _default: StubQueryContextProvider;
|
|
7
8
|
export default _default;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StubQueryContextProvider = void 0;
|
|
6
7
|
const EntityQueryContextProvider_1 = __importDefault(require("../../EntityQueryContextProvider"));
|
|
7
8
|
class StubQueryContextProvider extends EntityQueryContextProvider_1.default {
|
|
8
9
|
getQueryInterface() {
|
|
@@ -11,6 +12,10 @@ class StubQueryContextProvider extends EntityQueryContextProvider_1.default {
|
|
|
11
12
|
createTransactionRunner() {
|
|
12
13
|
return (transactionScope) => Promise.resolve(transactionScope({}));
|
|
13
14
|
}
|
|
15
|
+
createNestedTransactionRunner(_outerQueryInterface) {
|
|
16
|
+
return (transactionScope) => Promise.resolve(transactionScope({}));
|
|
17
|
+
}
|
|
14
18
|
}
|
|
19
|
+
exports.StubQueryContextProvider = StubQueryContextProvider;
|
|
15
20
|
exports.default = new StubQueryContextProvider();
|
|
16
21
|
//# sourceMappingURL=StubQueryContextProvider.js.map
|