diff --git a/package.json b/package.json index 7ece208d..d4fc24fd 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "tsc": "lerna run tsc", "clean": "lerna run clean", "lint": "lerna run lint", + "lint-fix": "lerna run lint-fix", "test": "lerna run test", "integration": "./resources/run-with-docker lerna run integration-no-setup", "prepublish": "lerna link && lerna run clean", @@ -32,7 +33,7 @@ "lerna": "^4.0.0", "nullthrows": "^1.1.1", "pg": "^8.6.0", - "prettier": "^2.1.0", + "prettier": "^2.3.2", "ts-jest": "~26.4.4", "ts-mockito": "^2.6.1", "typedoc": "^0.21.9", diff --git a/packages/entity-cache-adapter-redis/package.json b/packages/entity-cache-adapter-redis/package.json index 3f05f41c..453bb0ef 100644 --- a/packages/entity-cache-adapter-redis/package.json +++ b/packages/entity-cache-adapter-redis/package.json @@ -12,6 +12,7 @@ "tsc": "tsc", "clean": "rm -rf build coverage coverage-integration", "lint": "eslint src", + "lint-fix": "eslint src --fix", "test": "jest --rootDir . --config ../../resources/jest.config.js", "integration": "../../resources/run-with-docker yarn integration-no-setup", "integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests", diff --git a/packages/entity-cache-adapter-redis/src/testfixtures/RedisTestEntity.ts b/packages/entity-cache-adapter-redis/src/testfixtures/RedisTestEntity.ts index 30bc4db7..6c3d1f1b 100644 --- a/packages/entity-cache-adapter-redis/src/testfixtures/RedisTestEntity.ts +++ b/packages/entity-cache-adapter-redis/src/testfixtures/RedisTestEntity.ts @@ -34,7 +34,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, RedisTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, @@ -42,7 +42,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< RedisTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, @@ -50,7 +50,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< RedisTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, @@ -58,7 +58,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< RedisTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, diff --git a/packages/entity-database-adapter-knex/package.json b/packages/entity-database-adapter-knex/package.json index 9c0c9cd2..53aea9d7 100644 --- a/packages/entity-database-adapter-knex/package.json +++ b/packages/entity-database-adapter-knex/package.json @@ -12,6 +12,7 @@ "tsc": "tsc", "clean": "rm -rf build coverage coverage-integration", "lint": "eslint src", + "lint-fix": "eslint src --fix", "test": "jest --rootDir . --config ../../resources/jest.config.js --passWithNoTests", "integration": "../../resources/run-with-docker yarn integration-no-setup", "integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests", diff --git a/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapter.ts b/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapter.ts index 509e9337..cf1d502f 100644 --- a/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapter.ts +++ b/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapter.ts @@ -89,12 +89,10 @@ export default class PostgresEntityDatabaseAdapter extends EntityDataba if (tableFieldSingleValueEqualityOperands.length > 0) { const whereObject: { [key: string]: any } = {}; - const nonNullTableFieldSingleValueEqualityOperands = tableFieldSingleValueEqualityOperands.filter( - ({ tableValue }) => tableValue !== null - ); - const nullTableFieldSingleValueEqualityOperands = tableFieldSingleValueEqualityOperands.filter( - ({ tableValue }) => tableValue === null - ); + const nonNullTableFieldSingleValueEqualityOperands = + tableFieldSingleValueEqualityOperands.filter(({ tableValue }) => tableValue !== null); + const nullTableFieldSingleValueEqualityOperands = + tableFieldSingleValueEqualityOperands.filter(({ tableValue }) => tableValue === null); if (nonNullTableFieldSingleValueEqualityOperands.length > 0) { for (const { tableField, tableValue } of nonNullTableFieldSingleValueEqualityOperands) { diff --git a/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapterProvider.ts b/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapterProvider.ts index 1f6909a2..79183a5e 100644 --- a/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapterProvider.ts +++ b/packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapterProvider.ts @@ -7,7 +7,8 @@ import { import PostgresEntityDatabaseAdapter from './PostgresEntityDatabaseAdapter'; export default class PostgresEntityDatabaseAdapterProvider - implements IEntityDatabaseAdapterProvider { + implements IEntityDatabaseAdapterProvider +{ getDatabaseAdapter( entityConfiguration: EntityConfiguration ): EntityDatabaseAdapter { diff --git a/packages/entity-database-adapter-knex/src/testfixtures/ErrorsTestEntity.ts b/packages/entity-database-adapter-knex/src/testfixtures/ErrorsTestEntity.ts index c4ee07e3..ef1a17a0 100644 --- a/packages/entity-database-adapter-knex/src/testfixtures/ErrorsTestEntity.ts +++ b/packages/entity-database-adapter-knex/src/testfixtures/ErrorsTestEntity.ts @@ -106,7 +106,7 @@ class ErrorsTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, ErrorsTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< ErrorsTestEntityFields, number, @@ -114,7 +114,7 @@ class ErrorsTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ErrorsTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< ErrorsTestEntityFields, number, @@ -122,7 +122,7 @@ class ErrorsTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ErrorsTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< ErrorsTestEntityFields, number, @@ -130,7 +130,7 @@ class ErrorsTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ErrorsTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< ErrorsTestEntityFields, number, diff --git a/packages/entity-database-adapter-knex/src/testfixtures/InvalidTestEntity.ts b/packages/entity-database-adapter-knex/src/testfixtures/InvalidTestEntity.ts index 8d0831c2..1101d92d 100644 --- a/packages/entity-database-adapter-knex/src/testfixtures/InvalidTestEntity.ts +++ b/packages/entity-database-adapter-knex/src/testfixtures/InvalidTestEntity.ts @@ -57,7 +57,7 @@ class InvalidTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, InvalidTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< InvalidTestEntityFields, number, @@ -65,7 +65,7 @@ class InvalidTestEntityPrivacyPolicy extends EntityPrivacyPolicy< InvalidTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< InvalidTestEntityFields, number, @@ -73,7 +73,7 @@ class InvalidTestEntityPrivacyPolicy extends EntityPrivacyPolicy< InvalidTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< InvalidTestEntityFields, number, @@ -81,7 +81,7 @@ class InvalidTestEntityPrivacyPolicy extends EntityPrivacyPolicy< InvalidTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< InvalidTestEntityFields, number, diff --git a/packages/entity-database-adapter-knex/src/testfixtures/PostgresTestEntity.ts b/packages/entity-database-adapter-knex/src/testfixtures/PostgresTestEntity.ts index 94dc7532..c285ac44 100644 --- a/packages/entity-database-adapter-knex/src/testfixtures/PostgresTestEntity.ts +++ b/packages/entity-database-adapter-knex/src/testfixtures/PostgresTestEntity.ts @@ -81,7 +81,7 @@ class PostgresTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, PostgresTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTestEntityFields, string, @@ -89,7 +89,7 @@ class PostgresTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTestEntityFields, string, @@ -97,7 +97,7 @@ class PostgresTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTestEntityFields, string, @@ -105,7 +105,7 @@ class PostgresTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTestEntityFields, string, diff --git a/packages/entity-database-adapter-knex/src/testfixtures/PostgresTriggerTestEntity.ts b/packages/entity-database-adapter-knex/src/testfixtures/PostgresTriggerTestEntity.ts index 44bb43c0..2f27cb92 100644 --- a/packages/entity-database-adapter-knex/src/testfixtures/PostgresTriggerTestEntity.ts +++ b/packages/entity-database-adapter-knex/src/testfixtures/PostgresTriggerTestEntity.ts @@ -63,7 +63,7 @@ class PostgresTriggerTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, PostgresTriggerTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTriggerTestEntityFields, string, @@ -71,7 +71,7 @@ class PostgresTriggerTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresTriggerTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTriggerTestEntityFields, string, @@ -79,7 +79,7 @@ class PostgresTriggerTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresTriggerTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTriggerTestEntityFields, string, @@ -87,7 +87,7 @@ class PostgresTriggerTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresTriggerTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresTriggerTestEntityFields, string, @@ -144,23 +144,22 @@ class ThrowConditionallyNonTransactionalTrigger extends EntityNonTransactionalMu } } -export const postgresTestEntityConfiguration = new EntityConfiguration< - PostgresTriggerTestEntityFields ->({ - idField: 'id', - tableName: 'postgres_test_entities', - schema: { - id: new UUIDField({ - columnName: 'id', - cache: true, - }), - name: new StringField({ - columnName: 'name', - }), - }, - databaseAdapterFlavor: 'postgres', - cacheAdapterFlavor: 'redis', -}); +export const postgresTestEntityConfiguration = + new EntityConfiguration({ + idField: 'id', + tableName: 'postgres_test_entities', + schema: { + id: new UUIDField({ + columnName: 'id', + cache: true, + }), + name: new StringField({ + columnName: 'name', + }), + }, + databaseAdapterFlavor: 'postgres', + cacheAdapterFlavor: 'redis', + }); const postgresTestEntityCompanionDefinition = new EntityCompanionDefinition({ entityClass: PostgresTriggerTestEntity, diff --git a/packages/entity-database-adapter-knex/src/testfixtures/PostgresValidatorTestEntity.ts b/packages/entity-database-adapter-knex/src/testfixtures/PostgresValidatorTestEntity.ts index 4aaf2386..ea7086a2 100644 --- a/packages/entity-database-adapter-knex/src/testfixtures/PostgresValidatorTestEntity.ts +++ b/packages/entity-database-adapter-knex/src/testfixtures/PostgresValidatorTestEntity.ts @@ -62,7 +62,7 @@ class PostgresValidatorTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, PostgresValidatorTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresValidatorTestEntityFields, string, @@ -70,7 +70,7 @@ class PostgresValidatorTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresValidatorTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresValidatorTestEntityFields, string, @@ -78,7 +78,7 @@ class PostgresValidatorTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresValidatorTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresValidatorTestEntityFields, string, @@ -86,7 +86,7 @@ class PostgresValidatorTestEntityPrivacyPolicy extends EntityPrivacyPolicy< PostgresValidatorTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< PostgresValidatorTestEntityFields, string, @@ -126,23 +126,22 @@ class ThrowConditionallyTrigger extends EntityMutationTrigger< } } -export const postgresTestEntityConfiguration = new EntityConfiguration< - PostgresValidatorTestEntityFields ->({ - idField: 'id', - tableName: 'postgres_test_entities', - schema: { - id: new UUIDField({ - columnName: 'id', - cache: true, - }), - name: new StringField({ - columnName: 'name', - }), - }, - databaseAdapterFlavor: 'postgres', - cacheAdapterFlavor: 'redis', -}); +export const postgresTestEntityConfiguration = + new EntityConfiguration({ + idField: 'id', + tableName: 'postgres_test_entities', + schema: { + id: new UUIDField({ + columnName: 'id', + cache: true, + }), + name: new StringField({ + columnName: 'name', + }), + }, + databaseAdapterFlavor: 'postgres', + cacheAdapterFlavor: 'redis', + }); const postgresTestEntityCompanionDefinition = new EntityCompanionDefinition({ entityClass: PostgresValidatorTestEntity, diff --git a/packages/entity-example/package.json b/packages/entity-example/package.json index d7c94fd7..5afdfa05 100644 --- a/packages/entity-example/package.json +++ b/packages/entity-example/package.json @@ -7,6 +7,7 @@ "tsc": "tsc", "clean": "rm -rf build coverage coverage-integration", "lint": "eslint src", + "lint-fix": "eslint src --fix", "test": "jest --rootDir . --config ../../resources/jest.config.js", "integration": "../../resources/run-with-docker yarn integration-no-setup", "integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests", diff --git a/packages/entity-example/src/entities/NotePrivacyPolicy.ts b/packages/entity-example/src/entities/NotePrivacyPolicy.ts index 4226001a..d0763e06 100644 --- a/packages/entity-example/src/entities/NotePrivacyPolicy.ts +++ b/packages/entity-example/src/entities/NotePrivacyPolicy.ts @@ -13,16 +13,16 @@ export default class NotePrivacyPolicy extends EntityPrivacyPolicy< ExampleViewerContext, NoteEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AllowIfUserOwnerPrivacyRule('userID'), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AllowIfUserOwnerPrivacyRule('userID'), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AllowIfUserOwnerPrivacyRule('userID'), ]; } diff --git a/packages/entity-full-integration-tests/package.json b/packages/entity-full-integration-tests/package.json index b4e32961..ea374c03 100644 --- a/packages/entity-full-integration-tests/package.json +++ b/packages/entity-full-integration-tests/package.json @@ -7,6 +7,7 @@ "tsc": "tsc", "clean": "rm -rf build coverage coverage-integration", "lint": "eslint src", + "lint-fix": "eslint src --fix", "test": "jest --rootDir . --config ../../resources/jest.config.js --passWithNoTests", "integration": "../../resources/run-with-docker yarn integration-no-setup", "integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests", diff --git a/packages/entity-full-integration-tests/src/__integration-tests__/EntityCacheInconsistency-test.ts b/packages/entity-full-integration-tests/src/__integration-tests__/EntityCacheInconsistency-test.ts index c508cbe6..36ccccbc 100644 --- a/packages/entity-full-integration-tests/src/__integration-tests__/EntityCacheInconsistency-test.ts +++ b/packages/entity-full-integration-tests/src/__integration-tests__/EntityCacheInconsistency-test.ts @@ -28,16 +28,16 @@ class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, TestEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity-full-integration-tests/src/__integration-tests__/EntitySelfReferentialEdgesIntegration-test.ts b/packages/entity-full-integration-tests/src/__integration-tests__/EntitySelfReferentialEdgesIntegration-test.ts index 54f2502b..d04c533f 100644 --- a/packages/entity-full-integration-tests/src/__integration-tests__/EntitySelfReferentialEdgesIntegration-test.ts +++ b/packages/entity-full-integration-tests/src/__integration-tests__/EntitySelfReferentialEdgesIntegration-test.ts @@ -28,16 +28,16 @@ interface OtherFields { } class PrivacyPolicy extends EntityPrivacyPolicy { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity-full-integration-tests/src/__integration-tests__/entities/ChildEntity.ts b/packages/entity-full-integration-tests/src/__integration-tests__/entities/ChildEntity.ts index 042098a4..5384ae73 100644 --- a/packages/entity-full-integration-tests/src/__integration-tests__/entities/ChildEntity.ts +++ b/packages/entity-full-integration-tests/src/__integration-tests__/entities/ChildEntity.ts @@ -17,16 +17,16 @@ interface ChildFields { } class TestEntityPrivacyPolicy extends EntityPrivacyPolicy { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity-full-integration-tests/src/__integration-tests__/entities/ParentEntity.ts b/packages/entity-full-integration-tests/src/__integration-tests__/entities/ParentEntity.ts index cdebeab6..07663d13 100644 --- a/packages/entity-full-integration-tests/src/__integration-tests__/entities/ParentEntity.ts +++ b/packages/entity-full-integration-tests/src/__integration-tests__/entities/ParentEntity.ts @@ -15,16 +15,16 @@ interface ParentFields { } class TestEntityPrivacyPolicy extends EntityPrivacyPolicy { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity-secondary-cache-redis/package.json b/packages/entity-secondary-cache-redis/package.json index 6d53f6c1..5bea01c5 100644 --- a/packages/entity-secondary-cache-redis/package.json +++ b/packages/entity-secondary-cache-redis/package.json @@ -12,6 +12,7 @@ "tsc": "tsc", "clean": "rm -rf build coverage coverage-integration", "lint": "eslint src", + "lint-fix": "eslint src --fix", "test": "jest --rootDir . --config ../../resources/jest.config.js --passWithNoTests", "integration": "../../resources/run-with-docker yarn integration-no-setup", "integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests", diff --git a/packages/entity-secondary-cache-redis/src/RedisSecondaryEntityCache.ts b/packages/entity-secondary-cache-redis/src/RedisSecondaryEntityCache.ts index 302aed86..9d473ae2 100644 --- a/packages/entity-secondary-cache-redis/src/RedisSecondaryEntityCache.ts +++ b/packages/entity-secondary-cache-redis/src/RedisSecondaryEntityCache.ts @@ -20,7 +20,8 @@ import invariant from 'invariant'; * a call to {@link EntityLoader.loadManyByFieldEqualityConjunctionAsync} is guaranteed to return at most one entity. */ export default class RedisSecondaryEntityCache - implements ISecondaryEntityCache { + implements ISecondaryEntityCache +{ private readonly genericRedisCacher: GenericRedisCacher; constructor( diff --git a/packages/entity-secondary-cache-redis/src/testfixtures/RedisTestEntity.ts b/packages/entity-secondary-cache-redis/src/testfixtures/RedisTestEntity.ts index 7984b453..252ea888 100644 --- a/packages/entity-secondary-cache-redis/src/testfixtures/RedisTestEntity.ts +++ b/packages/entity-secondary-cache-redis/src/testfixtures/RedisTestEntity.ts @@ -32,7 +32,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, RedisTestEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, @@ -40,7 +40,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< RedisTestEntity >(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, @@ -48,7 +48,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< RedisTestEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, @@ -56,7 +56,7 @@ export class RedisTestEntityPrivacyPolicy extends EntityPrivacyPolicy< RedisTestEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< RedisTestEntityFields, string, diff --git a/packages/entity/package.json b/packages/entity/package.json index e8ae42d3..ceced440 100644 --- a/packages/entity/package.json +++ b/packages/entity/package.json @@ -12,6 +12,7 @@ "tsc": "tsc", "clean": "rm -rf build coverage coverage-integration", "lint": "eslint src", + "lint-fix": "eslint src --fix", "test": "jest --rootDir . --config ../../resources/jest.config.js", "integration": "../../resources/run-with-docker yarn integration-no-setup", "integration-no-setup": "jest --config ../../resources/jest-integration.config.js --rootDir . --runInBand --passWithNoTests", diff --git a/packages/entity/src/EntityAssociationLoader.ts b/packages/entity/src/EntityAssociationLoader.ts index bfe5610e..485c588f 100644 --- a/packages/entity/src/EntityAssociationLoader.ts +++ b/packages/entity/src/EntityAssociationLoader.ts @@ -71,7 +71,7 @@ export default class EntityAssociationLoader< .getLoaderFactory() .forLoad(queryContext); - return (await loader.loadByIDAsync((associatedEntityID as unknown) as TAssociatedID)) as Result< + return (await loader.loadByIDAsync(associatedEntityID as unknown as TAssociatedID)) as Result< null extends TFields[TIdentifyingField] ? TAssociatedEntity | null : TAssociatedEntity >; } diff --git a/packages/entity/src/EntityCompanionProvider.ts b/packages/entity/src/EntityCompanionProvider.ts index 3029de9f..17dbc1fa 100644 --- a/packages/entity/src/EntityCompanionProvider.ts +++ b/packages/entity/src/EntityCompanionProvider.ts @@ -162,14 +162,10 @@ export class EntityCompanionDefinition< * {@link EntityCompanion} for each type of {@link Entity}. */ export default class EntityCompanionProvider { - private readonly companionMap: Map< - string, - EntityCompanion - > = new Map(); - private readonly tableDataCoordinatorMap: Map< - string, - EntityTableDataCoordinator - > = new Map(); + private readonly companionMap: Map> = + new Map(); + private readonly tableDataCoordinatorMap: Map> = + new Map(); /** * Instantiate an Entity framework. diff --git a/packages/entity/src/EntityFields.ts b/packages/entity/src/EntityFields.ts index 30f96028..777fbf71 100644 --- a/packages/entity/src/EntityFields.ts +++ b/packages/entity/src/EntityFields.ts @@ -131,7 +131,7 @@ export class StringField extends EntityFieldDefinition { } } export class UUIDField extends StringField { - protected validateInputValueInternal(value: string): boolean { + protected override validateInputValueInternal(value: string): boolean { return validateUUID(value); } } diff --git a/packages/entity/src/EntityMutator.ts b/packages/entity/src/EntityMutator.ts index 9cf52abf..1c5e5357 100644 --- a/packages/entity/src/EntityMutator.ts +++ b/packages/entity/src/EntityMutator.ts @@ -211,10 +211,10 @@ export class CreateMutator< ): Promise> { this.validateFields(this.fieldsForEntity); - const temporaryEntityForPrivacyCheck = new this.entityClass(this.viewerContext, ({ + const temporaryEntityForPrivacyCheck = new this.entityClass(this.viewerContext, { [this.entityConfiguration.idField]: '00000000-0000-0000-0000-000000000000', // zero UUID ...this.fieldsForEntity, - } as unknown) as TFields); + } as unknown as TFields); const authorizeCreateResult = await asyncResult( this.privacyPolicy.authorizeCreateAsync( @@ -680,7 +680,9 @@ export class DeleteMutator< } processedEntityIdentifiers.add(entity.getUniqueIdentifier()); - const companionDefinition = (entity.constructor as any).getCompanionDefinition() as EntityCompanionDefinition< + const companionDefinition = ( + entity.constructor as any + ).getCompanionDefinition() as EntityCompanionDefinition< TFields, TID, TViewerContext, diff --git a/packages/entity/src/ReadonlyEntity.ts b/packages/entity/src/ReadonlyEntity.ts index 57b1982e..52b6816d 100644 --- a/packages/entity/src/ReadonlyEntity.ts +++ b/packages/entity/src/ReadonlyEntity.ts @@ -37,8 +37,9 @@ export default abstract class ReadonlyEntity< private readonly viewerContext: TViewerContext, private readonly databaseFields: Readonly ) { - const companionDefinition = (this - .constructor as any).getCompanionDefinition() as EntityCompanionDefinition< + const companionDefinition = ( + this.constructor as any + ).getCompanionDefinition() as EntityCompanionDefinition< TFields, TID, TViewerContext, diff --git a/packages/entity/src/__tests__/Entity-test.ts b/packages/entity/src/__tests__/Entity-test.ts index 06e145f8..4938b8d2 100644 --- a/packages/entity/src/__tests__/Entity-test.ts +++ b/packages/entity/src/__tests__/Entity-test.ts @@ -102,7 +102,7 @@ class SimpleTestDenyUpdateEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, SimpleTestDenyUpdateEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< TestEntityFields, string, @@ -110,7 +110,7 @@ class SimpleTestDenyUpdateEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestDenyUpdateEntity >(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< TestEntityFields, string, @@ -118,7 +118,7 @@ class SimpleTestDenyUpdateEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestDenyUpdateEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysDenyPrivacyPolicyRule< TestEntityFields, string, @@ -126,7 +126,7 @@ class SimpleTestDenyUpdateEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestDenyUpdateEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< TestEntityFields, string, @@ -142,7 +142,7 @@ class SimpleTestDenyDeleteEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, SimpleTestDenyDeleteEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< TestEntityFields, string, @@ -150,7 +150,7 @@ class SimpleTestDenyDeleteEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestDenyDeleteEntity >(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< TestEntityFields, string, @@ -158,7 +158,7 @@ class SimpleTestDenyDeleteEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestDenyDeleteEntity >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< TestEntityFields, string, @@ -166,7 +166,7 @@ class SimpleTestDenyDeleteEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestDenyDeleteEntity >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysDenyPrivacyPolicyRule< TestEntityFields, string, diff --git a/packages/entity/src/__tests__/EntityCommonUseCases-test.ts b/packages/entity/src/__tests__/EntityCommonUseCases-test.ts index 1e2968d0..f7492ede 100644 --- a/packages/entity/src/__tests__/EntityCommonUseCases-test.ts +++ b/packages/entity/src/__tests__/EntityCommonUseCases-test.ts @@ -66,19 +66,19 @@ class BlahEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, BlahEntity > { - protected readonly createRules = [ + protected override readonly createRules = [ new DenyIfNotOwnerPrivacyPolicyRule(), new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new DenyIfNotOwnerPrivacyPolicyRule(), new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new DenyIfNotOwnerPrivacyPolicyRule(), new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysDenyPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/__tests__/EntityEdges-test.ts b/packages/entity/src/__tests__/EntityEdges-test.ts index 46bd7cd7..5b6a149f 100644 --- a/packages/entity/src/__tests__/EntityEdges-test.ts +++ b/packages/entity/src/__tests__/EntityEdges-test.ts @@ -30,16 +30,16 @@ class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< any, any > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/__tests__/EntityLoader-constructor-test.ts b/packages/entity/src/__tests__/EntityLoader-constructor-test.ts index 8140bdfc..fd9265bd 100644 --- a/packages/entity/src/__tests__/EntityLoader-constructor-test.ts +++ b/packages/entity/src/__tests__/EntityLoader-constructor-test.ts @@ -40,7 +40,7 @@ export class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< TestEntity, TestFieldSelection > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< TestFields, string, @@ -49,7 +49,7 @@ export class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< TestFieldSelection >(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< TestFields, string, @@ -58,7 +58,7 @@ export class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< TestFieldSelection >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< TestFields, string, @@ -67,7 +67,7 @@ export class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< TestFieldSelection >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< TestFields, string, diff --git a/packages/entity/src/__tests__/EntityMutator-test.ts b/packages/entity/src/__tests__/EntityMutator-test.ts index 9f5bf403..c91db366 100644 --- a/packages/entity/src/__tests__/EntityMutator-test.ts +++ b/packages/entity/src/__tests__/EntityMutator-test.ts @@ -527,28 +527,25 @@ describe(EntityMutatorFactory, () => { const id1 = uuidv4(); const id2 = uuidv4(); - const { - privacyPolicy, - entityMutatorFactory, - entityLoaderFactory, - } = createEntityMutatorFactory([ - { - customIdField: id1, - stringField: 'huh', - testIndexedField: '3', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - { - customIdField: id2, - stringField: 'huh', - testIndexedField: '4', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - ]); + const { privacyPolicy, entityMutatorFactory, entityLoaderFactory } = + createEntityMutatorFactory([ + { + customIdField: id1, + stringField: 'huh', + testIndexedField: '3', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + { + customIdField: id2, + stringField: 'huh', + testIndexedField: '4', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + ]); const spiedPrivacyPolicy = spy(privacyPolicy); @@ -576,28 +573,25 @@ describe(EntityMutatorFactory, () => { const id1 = uuidv4(); const id2 = uuidv4(); - const { - mutationTriggers, - entityMutatorFactory, - entityLoaderFactory, - } = createEntityMutatorFactory([ - { - customIdField: id1, - stringField: 'huh', - testIndexedField: '3', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - { - customIdField: id2, - stringField: 'huh', - testIndexedField: '4', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - ]); + const { mutationTriggers, entityMutatorFactory, entityLoaderFactory } = + createEntityMutatorFactory([ + { + customIdField: id1, + stringField: 'huh', + testIndexedField: '3', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + { + customIdField: id2, + stringField: 'huh', + testIndexedField: '4', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + ]); const triggerSpies = setUpMutationTriggerSpies(mutationTriggers); @@ -630,28 +624,25 @@ describe(EntityMutatorFactory, () => { const id1 = uuidv4(); const id2 = uuidv4(); - const { - mutationValidators, - entityMutatorFactory, - entityLoaderFactory, - } = createEntityMutatorFactory([ - { - customIdField: id1, - stringField: 'huh', - testIndexedField: '3', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - { - customIdField: id2, - stringField: 'huh', - testIndexedField: '4', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - ]); + const { mutationValidators, entityMutatorFactory, entityLoaderFactory } = + createEntityMutatorFactory([ + { + customIdField: id1, + stringField: 'huh', + testIndexedField: '3', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + { + customIdField: id2, + stringField: 'huh', + testIndexedField: '4', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + ]); const validatorSpies = setUpMutationValidatorSpies(mutationValidators); @@ -707,20 +698,17 @@ describe(EntityMutatorFactory, () => { const queryContext = StubQueryContextProvider.getQueryContext(); const id1 = uuidv4(); - const { - privacyPolicy, - entityMutatorFactory, - entityLoaderFactory, - } = createEntityMutatorFactory([ - { - customIdField: id1, - stringField: 'huh', - testIndexedField: '3', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - ]); + const { privacyPolicy, entityMutatorFactory, entityLoaderFactory } = + createEntityMutatorFactory([ + { + customIdField: id1, + stringField: 'huh', + testIndexedField: '3', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + ]); const spiedPrivacyPolicy = spy(privacyPolicy); @@ -744,20 +732,17 @@ describe(EntityMutatorFactory, () => { const queryContext = StubQueryContextProvider.getQueryContext(); const id1 = uuidv4(); - const { - mutationTriggers, - entityMutatorFactory, - entityLoaderFactory, - } = createEntityMutatorFactory([ - { - customIdField: id1, - stringField: 'huh', - testIndexedField: '3', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - ]); + const { mutationTriggers, entityMutatorFactory, entityLoaderFactory } = + createEntityMutatorFactory([ + { + customIdField: id1, + stringField: 'huh', + testIndexedField: '3', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + ]); const triggerSpies = setUpMutationTriggerSpies(mutationTriggers); @@ -787,20 +772,17 @@ describe(EntityMutatorFactory, () => { const queryContext = StubQueryContextProvider.getQueryContext(); const id1 = uuidv4(); - const { - mutationValidators, - entityMutatorFactory, - entityLoaderFactory, - } = createEntityMutatorFactory([ - { - customIdField: id1, - stringField: 'huh', - testIndexedField: '3', - intField: 3, - dateField: new Date(), - nullableField: null, - }, - ]); + const { mutationValidators, entityMutatorFactory, entityLoaderFactory } = + createEntityMutatorFactory([ + { + customIdField: id1, + stringField: 'huh', + testIndexedField: '3', + intField: 3, + dateField: new Date(), + nullableField: null, + }, + ]); const validatorSpies = setUpMutationValidatorSpies(mutationValidators); diff --git a/packages/entity/src/__tests__/EntityPrivacyPolicy-test.ts b/packages/entity/src/__tests__/EntityPrivacyPolicy-test.ts index a5c62033..a95e6842 100644 --- a/packages/entity/src/__tests__/EntityPrivacyPolicy-test.ts +++ b/packages/entity/src/__tests__/EntityPrivacyPolicy-test.ts @@ -33,16 +33,16 @@ class BlahEntity extends Entity { } class AlwaysDenyPolicy extends EntityPrivacyPolicy { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysDenyPrivacyPolicyRule(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysDenyPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysDenyPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysDenyPrivacyPolicyRule(), ]; } @@ -53,7 +53,7 @@ class DryRunAlwaysDenyPolicy extends AlwaysDenyPolicy { _error: EntityNotAuthorizedError ): void {} - protected getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< + protected override getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< BlahFields, string, ViewerContext, @@ -72,7 +72,7 @@ class LoggingEnforceAlwaysDenyPolicy extends AlwaysDenyPolicy { _error: EntityNotAuthorizedError ): void {} - protected getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< + protected override getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< BlahFields, string, ViewerContext, @@ -86,16 +86,16 @@ class LoggingEnforceAlwaysDenyPolicy extends AlwaysDenyPolicy { } class AlwaysAllowPolicy extends EntityPrivacyPolicy { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } @@ -106,7 +106,7 @@ class DryRunAlwaysAllowPolicy extends AlwaysAllowPolicy { _error: EntityNotAuthorizedError ): void {} - protected getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< + protected override getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< BlahFields, string, ViewerContext, @@ -125,7 +125,7 @@ class LoggingEnforceAlwaysAllowPolicy extends AlwaysAllowPolicy { _error: EntityNotAuthorizedError ): void {} - protected getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< + protected override getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< BlahFields, string, ViewerContext, @@ -139,16 +139,16 @@ class LoggingEnforceAlwaysAllowPolicy extends AlwaysAllowPolicy { } class SkipAllPolicy extends EntityPrivacyPolicy { - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysSkipPrivacyPolicyRule(), ]; - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysSkipPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysSkipPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysSkipPrivacyPolicyRule(), ]; } @@ -169,10 +169,10 @@ class AlwaysThrowPrivacyPolicyRule extends PrivacyPolicyRule< } class ThrowAllPolicy extends EntityPrivacyPolicy { - protected readonly createRules = [new AlwaysThrowPrivacyPolicyRule()]; - protected readonly readRules = [new AlwaysThrowPrivacyPolicyRule()]; - protected readonly updateRules = [new AlwaysThrowPrivacyPolicyRule()]; - protected readonly deleteRules = [new AlwaysThrowPrivacyPolicyRule()]; + protected override readonly createRules = [new AlwaysThrowPrivacyPolicyRule()]; + protected override readonly readRules = [new AlwaysThrowPrivacyPolicyRule()]; + protected override readonly updateRules = [new AlwaysThrowPrivacyPolicyRule()]; + protected override readonly deleteRules = [new AlwaysThrowPrivacyPolicyRule()]; } class DryRunThrowAllPolicy extends ThrowAllPolicy { @@ -181,7 +181,7 @@ class DryRunThrowAllPolicy extends ThrowAllPolicy { _error: EntityNotAuthorizedError ): void {} - protected getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< + protected override getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< BlahFields, string, ViewerContext, @@ -200,7 +200,7 @@ class LoggingEnforceThrowAllPolicy extends ThrowAllPolicy { _error: EntityNotAuthorizedError ): void {} - protected getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< + protected override getPrivacyPolicyEvaluator(): EntityPrivacyPolicyEvaluator< BlahFields, string, ViewerContext, @@ -214,10 +214,10 @@ class LoggingEnforceThrowAllPolicy extends ThrowAllPolicy { } class EmptyPolicy extends EntityPrivacyPolicy { - protected readonly createRules = []; - protected readonly readRules = []; - protected readonly updateRules = []; - protected readonly deleteRules = []; + protected override readonly createRules = []; + protected override readonly readRules = []; + protected override readonly updateRules = []; + protected override readonly deleteRules = []; } const blahEntityCompanionDefinition = new EntityCompanionDefinition({ diff --git a/packages/entity/src/__tests__/EntitySecondaryCacheLoader-test.ts b/packages/entity/src/__tests__/EntitySecondaryCacheLoader-test.ts index 0eb30d13..55fb3d28 100644 --- a/packages/entity/src/__tests__/EntitySecondaryCacheLoader-test.ts +++ b/packages/entity/src/__tests__/EntitySecondaryCacheLoader-test.ts @@ -35,9 +35,8 @@ describe(EntitySecondaryCacheLoader, () => { const createdEntity = await SimpleTestEntity.creator(vc1).enforceCreateAsync(); const loadParams = { id: createdEntity.getID() }; - const secondaryEntityCacheMock = mock< - ISecondaryEntityCache - >(); + const secondaryEntityCacheMock = + mock>(); when( secondaryEntityCacheMock.loadManyThroughAsync(deepEqual([loadParams]), anything()) ).thenResolve(new Map()); @@ -61,9 +60,8 @@ describe(EntitySecondaryCacheLoader, () => { const createdEntity = await SimpleTestEntity.creator(vc1).enforceCreateAsync(); const loadParams = { id: createdEntity.getID() }; - const secondaryEntityCacheMock = mock< - ISecondaryEntityCache - >(); + const secondaryEntityCacheMock = + mock>(); when( secondaryEntityCacheMock.loadManyThroughAsync(deepEqual([loadParams]), anything()) ).thenResolve(new Map([[loadParams, createdEntity.getAllFields()]])); @@ -93,9 +91,8 @@ describe(EntitySecondaryCacheLoader, () => { const createdEntity = await SimpleTestEntity.creator(vc1).enforceCreateAsync(); const loadParams = { id: createdEntity.getID() }; - const secondaryEntityCacheMock = mock< - ISecondaryEntityCache - >(); + const secondaryEntityCacheMock = + mock>(); const secondaryEntityCache = instance(secondaryEntityCacheMock); const loader = SimpleTestEntity.loader(vc1); const secondaryCacheLoader = new TestSecondaryRedisCacheLoader(secondaryEntityCache, loader); diff --git a/packages/entity/src/__tests__/EntitySelfReferentialEdges-test.ts b/packages/entity/src/__tests__/EntitySelfReferentialEdges-test.ts index 070b8086..0fa2a396 100644 --- a/packages/entity/src/__tests__/EntitySelfReferentialEdges-test.ts +++ b/packages/entity/src/__tests__/EntitySelfReferentialEdges-test.ts @@ -21,16 +21,16 @@ class CategoryPrivacyPolicy extends EntityPrivacyPolicy< any, any > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/__tests__/ViewerContext-test.ts b/packages/entity/src/__tests__/ViewerContext-test.ts index 978fee1a..45fa1ad3 100644 --- a/packages/entity/src/__tests__/ViewerContext-test.ts +++ b/packages/entity/src/__tests__/ViewerContext-test.ts @@ -17,12 +17,13 @@ describe(ViewerContext, () => { it('creates a new transactional query context', async () => { const companionProvider = createUnitTestEntityCompanionProvider(); const viewerContext = new ViewerContext(companionProvider); - const didCreateTransaction = await viewerContext.runInTransactionForDatabaseAdaptorFlavorAsync( - 'postgres', - async (queryContext) => { - return queryContext.isInTransaction(); - } - ); + const didCreateTransaction = + await viewerContext.runInTransactionForDatabaseAdaptorFlavorAsync( + 'postgres', + async (queryContext) => { + return queryContext.isInTransaction(); + } + ); expect(didCreateTransaction).toBe(true); }); }); diff --git a/packages/entity/src/__tests__/ViewerScopedEntityCompanion-test.ts b/packages/entity/src/__tests__/ViewerScopedEntityCompanion-test.ts index fe4a467d..d71a202c 100644 --- a/packages/entity/src/__tests__/ViewerScopedEntityCompanion-test.ts +++ b/packages/entity/src/__tests__/ViewerScopedEntityCompanion-test.ts @@ -10,16 +10,17 @@ import TestEntity, { TestFields, TestEntityPrivacyPolicy } from '../testfixtures describe(ViewerScopedEntityCompanion, () => { it('returns viewer scoped loader and mutator factory', () => { const vc = instance(mock(ViewerContext)); - const entityCompanion = mock< - EntityCompanion< - TestFields, - string, - ViewerContext, - TestEntity, - TestEntityPrivacyPolicy, - keyof TestFields - > - >(); + const entityCompanion = + mock< + EntityCompanion< + TestFields, + string, + ViewerContext, + TestEntity, + TestEntityPrivacyPolicy, + keyof TestFields + > + >(); const viewerScopedEntityCompanion = new ViewerScopedEntityCompanion(entityCompanion, vc); expect(viewerScopedEntityCompanion.getLoaderFactory()).toBeInstanceOf( ViewerScopedEntityLoaderFactory diff --git a/packages/entity/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts b/packages/entity/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts index 2d4d468e..d8949941 100644 --- a/packages/entity/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts +++ b/packages/entity/src/__tests__/ViewerScopedEntityMutatorFactory-test.ts @@ -10,9 +10,10 @@ describe(ViewerScopedEntityMutatorFactory, () => { it('correctly scopes viewer to entity mutations', async () => { const viewerContext = instance(mock(ViewerContext)); const queryContext = instance(mock(EntityQueryContext)); - const baseMutatorFactory = mock< - EntityMutatorFactory - >(EntityMutatorFactory); + const baseMutatorFactory = + mock< + EntityMutatorFactory + >(EntityMutatorFactory); const baseMutatorFactoryInstance = instance(baseMutatorFactory); const viewerScopedEntityLoader = new ViewerScopedEntityMutatorFactory< diff --git a/packages/entity/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts b/packages/entity/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts index 1c1e2147..0bf6d8b2 100644 --- a/packages/entity/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts +++ b/packages/entity/src/__tests__/cases/TwoEntitySameTableDisjointRows-test.ts @@ -107,16 +107,16 @@ const testEntityConfiguration = new EntityConfiguration({ }); class TestEntityPrivacyPolicy extends EntityPrivacyPolicy { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts b/packages/entity/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts index 5f2c1a1a..dad3b5eb 100644 --- a/packages/entity/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts +++ b/packages/entity/src/__tests__/cases/TwoEntitySameTableOverlappingRows-test.ts @@ -115,16 +115,16 @@ const testEntityConfiguration = new EntityConfiguration({ }); class TestEntityPrivacyPolicy extends EntityPrivacyPolicy { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/internal/__tests__/ReadThroughEntityCache-test.ts b/packages/entity/src/internal/__tests__/ReadThroughEntityCache-test.ts index 3e6eb6c0..505628cc 100644 --- a/packages/entity/src/internal/__tests__/ReadThroughEntityCache-test.ts +++ b/packages/entity/src/internal/__tests__/ReadThroughEntityCache-test.ts @@ -20,19 +20,21 @@ const makeEntityConfiguration = (cacheIdField: boolean): EntityConfiguration async ( - fetcherFieldValues: readonly NonNullable[] -): Promise, readonly Readonly[]>> => { - const results = new Map(); - fetcherFieldValues.forEach((v) => { - if (ids.includes(v)) { - results.set(v, [{ id: v }]); - } else { - results.set(v, []); - } - }); - return results; -}; +const createIdFetcher = + (ids: string[]) => + async ( + fetcherFieldValues: readonly NonNullable[] + ): Promise, readonly Readonly[]>> => { + const results = new Map(); + fetcherFieldValues.forEach((v) => { + if (ids.includes(v)) { + results.set(v, [{ id: v }]); + } else { + results.set(v, []); + } + }); + return results; + }; describe(ReadThroughEntityCache, () => { describe('readManyThroughAsync', () => { diff --git a/packages/entity/src/metrics/EntityMetricsUtils.ts b/packages/entity/src/metrics/EntityMetricsUtils.ts index 744d00de..9790518a 100644 --- a/packages/entity/src/metrics/EntityMetricsUtils.ts +++ b/packages/entity/src/metrics/EntityMetricsUtils.ts @@ -4,62 +4,68 @@ import IEntityMetricsAdapter, { EntityMetricsMutationType, } from './IEntityMetricsAdapter'; -export const timeAndLogLoadEventAsync = ( - metricsAdapter: IEntityMetricsAdapter, - loadType: EntityMetricsLoadType, - entityClassName: string -) => async (promise: Promise[]>) => { - const startTime = Date.now(); - const result = await promise; - const endTime = Date.now(); +export const timeAndLogLoadEventAsync = + ( + metricsAdapter: IEntityMetricsAdapter, + loadType: EntityMetricsLoadType, + entityClassName: string + ) => + async (promise: Promise[]>) => { + const startTime = Date.now(); + const result = await promise; + const endTime = Date.now(); - metricsAdapter.logDataManagerLoadEvent({ - type: loadType, - entityClassName, - duration: endTime - startTime, - count: result.length, - }); + metricsAdapter.logDataManagerLoadEvent({ + type: loadType, + entityClassName, + duration: endTime - startTime, + count: result.length, + }); - return result; -}; + return result; + }; -export const timeAndLogLoadMapEventAsync = ( - metricsAdapter: IEntityMetricsAdapter, - loadType: EntityMetricsLoadType, - entityClassName: string -) => async ( - promise: Promise, readonly Readonly[]>> -) => { - const startTime = Date.now(); - const result = await promise; - const endTime = Date.now(); +export const timeAndLogLoadMapEventAsync = + ( + metricsAdapter: IEntityMetricsAdapter, + loadType: EntityMetricsLoadType, + entityClassName: string + ) => + async ( + promise: Promise, readonly Readonly[]>> + ) => { + const startTime = Date.now(); + const result = await promise; + const endTime = Date.now(); - const count = reduceMap(result, (acc, v) => acc + v.length, 0); + const count = reduceMap(result, (acc, v) => acc + v.length, 0); - metricsAdapter.logDataManagerLoadEvent({ - type: loadType, - entityClassName, - duration: endTime - startTime, - count, - }); + metricsAdapter.logDataManagerLoadEvent({ + type: loadType, + entityClassName, + duration: endTime - startTime, + count, + }); - return result; -}; + return result; + }; -export const timeAndLogMutationEventAsync = ( - metricsAdapter: IEntityMetricsAdapter, - mutationType: EntityMetricsMutationType, - entityClassName: string -) => async (promise: Promise) => { - const startTime = Date.now(); - const result = await promise; - const endTime = Date.now(); +export const timeAndLogMutationEventAsync = + ( + metricsAdapter: IEntityMetricsAdapter, + mutationType: EntityMetricsMutationType, + entityClassName: string + ) => + async (promise: Promise) => { + const startTime = Date.now(); + const result = await promise; + const endTime = Date.now(); - metricsAdapter.logMutatorMutationEvent({ - type: mutationType, - entityClassName, - duration: endTime - startTime, - }); + metricsAdapter.logMutatorMutationEvent({ + type: mutationType, + entityClassName, + duration: endTime - startTime, + }); - return result; -}; + return result; + }; diff --git a/packages/entity/src/testfixtures/DateIDTestEntity.ts b/packages/entity/src/testfixtures/DateIDTestEntity.ts index 42da704b..4359eb2b 100644 --- a/packages/entity/src/testfixtures/DateIDTestEntity.ts +++ b/packages/entity/src/testfixtures/DateIDTestEntity.ts @@ -28,16 +28,16 @@ export class DateIDTestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, DateIDTestEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/testfixtures/SimpleTestEntity.ts b/packages/entity/src/testfixtures/SimpleTestEntity.ts index 5ad4ac51..cfe4d737 100644 --- a/packages/entity/src/testfixtures/SimpleTestEntity.ts +++ b/packages/entity/src/testfixtures/SimpleTestEntity.ts @@ -31,7 +31,7 @@ export class SimpleTestEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestEntity, SimpleTestFieldSelection > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule< SimpleTestFields, string, @@ -40,7 +40,7 @@ export class SimpleTestEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestFieldSelection >(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule< SimpleTestFields, string, @@ -49,7 +49,7 @@ export class SimpleTestEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestFieldSelection >(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule< SimpleTestFields, string, @@ -58,7 +58,7 @@ export class SimpleTestEntityPrivacyPolicy extends EntityPrivacyPolicy< SimpleTestFieldSelection >(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule< SimpleTestFields, string, diff --git a/packages/entity/src/testfixtures/TestEntity.ts b/packages/entity/src/testfixtures/TestEntity.ts index eae36feb..eb8325c3 100644 --- a/packages/entity/src/testfixtures/TestEntity.ts +++ b/packages/entity/src/testfixtures/TestEntity.ts @@ -51,16 +51,16 @@ export class TestEntityPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, TestEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/testfixtures/TestEntity2.ts b/packages/entity/src/testfixtures/TestEntity2.ts index e9f89da5..4b1c1b9a 100644 --- a/packages/entity/src/testfixtures/TestEntity2.ts +++ b/packages/entity/src/testfixtures/TestEntity2.ts @@ -32,16 +32,16 @@ export class TestEntity2PrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, TestEntity2 > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/packages/entity/src/testfixtures/TestEntityNumberKey.ts b/packages/entity/src/testfixtures/TestEntityNumberKey.ts index 87dc095c..99f67d07 100644 --- a/packages/entity/src/testfixtures/TestEntityNumberKey.ts +++ b/packages/entity/src/testfixtures/TestEntityNumberKey.ts @@ -28,16 +28,16 @@ export class NumberKeyPrivacyPolicy extends EntityPrivacyPolicy< ViewerContext, NumberKeyEntity > { - protected readonly readRules = [ + protected override readonly readRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly createRules = [ + protected override readonly createRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly updateRules = [ + protected override readonly updateRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; - protected readonly deleteRules = [ + protected override readonly deleteRules = [ new AlwaysAllowPrivacyPolicyRule(), ]; } diff --git a/tsconfig.json b/tsconfig.json index a4ef22a3..b750f3af 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "noUncheckedIndexedAccess": true, "noPropertyAccessFromIndexSignature": true, "exactOptionalPropertyTypes": true, + "noImplicitOverride": true, "esModuleInterop": true, "types": ["jest", "node"] } diff --git a/yarn.lock b/yarn.lock index f21a4b8c..06ef497e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7804,10 +7804,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.0.tgz#5a9789f767a243118c60f3e56d95cb6544914fbb" - integrity sha512-lz28cCbA1cDFHVuY8vvj6QuqOwIpyIfPUYkSl8AZ/vxH8qBXMMjE2knfLHCrZCmUsK/H1bg1P0tOo0dJkTJHvw== +prettier@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" + integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== pretty-format@^25.2.1, pretty-format@^25.5.0: version "25.5.0"