From 3432615a17b23658ff9bd1117b95b5c060d1961a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20M?= Date: Mon, 6 Nov 2023 15:49:06 +0100 Subject: [PATCH] fix: small tenant refactor fixes (#2375) --- .../field-metadata-target-column-map.interface.ts | 2 +- .../factories/create-many-resolver.factory.ts | 6 ++++-- .../factories/create-one-resolver.factory.ts | 6 ++++-- .../factories/delete-one-resolver.factory.ts | 6 ++++-- .../factories/find-many-resolver.factory.ts | 6 ++++-- .../factories/find-one-resolver.factory.ts | 4 ++-- .../factories/update-one-resolver.factory.ts | 6 ++++-- ....interface.ts => resolver-builder-factory.interface.ts} | 2 +- server/src/tenant/resolver-builder/resolver.factory.ts | 7 +++++-- 9 files changed, 29 insertions(+), 16 deletions(-) rename server/src/tenant/resolver-builder/interfaces/{factory.interface.ts => resolver-builder-factory.interface.ts} (81%) diff --git a/server/src/metadata/field-metadata/interfaces/field-metadata-target-column-map.interface.ts b/server/src/metadata/field-metadata/interfaces/field-metadata-target-column-map.interface.ts index 20ca304721..65580c811b 100644 --- a/server/src/metadata/field-metadata/interfaces/field-metadata-target-column-map.interface.ts +++ b/server/src/metadata/field-metadata/interfaces/field-metadata-target-column-map.interface.ts @@ -10,7 +10,7 @@ export interface FieldMetadataTargetColumnMapUrl { } export interface FieldMetadataTargetColumnMapMoney { - value: number; + amount: number; currency: string; } diff --git a/server/src/tenant/resolver-builder/factories/create-many-resolver.factory.ts b/server/src/tenant/resolver-builder/factories/create-many-resolver.factory.ts index 93a8272827..78a432270d 100644 --- a/server/src/tenant/resolver-builder/factories/create-many-resolver.factory.ts +++ b/server/src/tenant/resolver-builder/factories/create-many-resolver.factory.ts @@ -5,13 +5,15 @@ import { Resolver, } from 'src/tenant/resolver-builder/interfaces/resolvers-builder.interface'; import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schema-builder-context.interface'; -import { FactoryInterface } from 'src/tenant/resolver-builder/interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from 'src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface'; import { DataSourceService } from 'src/metadata/data-source/data-source.service'; import { PGGraphQLQueryRunner } from 'src/tenant/resolver-builder/pg-graphql/pg-graphql-query-runner'; @Injectable() -export class CreateManyResolverFactory implements FactoryInterface { +export class CreateManyResolverFactory + implements ResolverBuilderFactoryInterface +{ public static methodName = 'createMany' as const; constructor(private readonly dataSourceService: DataSourceService) {} diff --git a/server/src/tenant/resolver-builder/factories/create-one-resolver.factory.ts b/server/src/tenant/resolver-builder/factories/create-one-resolver.factory.ts index a0f743cb23..c599682fba 100644 --- a/server/src/tenant/resolver-builder/factories/create-one-resolver.factory.ts +++ b/server/src/tenant/resolver-builder/factories/create-one-resolver.factory.ts @@ -5,14 +5,16 @@ import { Resolver, } from 'src/tenant/resolver-builder/interfaces/resolvers-builder.interface'; import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schema-builder-context.interface'; -import { FactoryInterface } from 'src/tenant/resolver-builder/interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from 'src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface'; import { DataSourceService } from 'src/metadata/data-source/data-source.service'; import { PGGraphQLQueryRunner } from 'src/tenant/resolver-builder/pg-graphql/pg-graphql-query-runner'; import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity'; @Injectable() -export class CreateOneResolverFactory implements FactoryInterface { +export class CreateOneResolverFactory + implements ResolverBuilderFactoryInterface +{ public static methodName = 'createOne' as const; constructor(private readonly dataSourceService: DataSourceService) {} diff --git a/server/src/tenant/resolver-builder/factories/delete-one-resolver.factory.ts b/server/src/tenant/resolver-builder/factories/delete-one-resolver.factory.ts index 984e1c43a2..4bd2f00cf3 100644 --- a/server/src/tenant/resolver-builder/factories/delete-one-resolver.factory.ts +++ b/server/src/tenant/resolver-builder/factories/delete-one-resolver.factory.ts @@ -5,14 +5,16 @@ import { Resolver, } from 'src/tenant/resolver-builder/interfaces/resolvers-builder.interface'; import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schema-builder-context.interface'; -import { FactoryInterface } from 'src/tenant/resolver-builder/interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from 'src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface'; import { DataSourceService } from 'src/metadata/data-source/data-source.service'; import { PGGraphQLQueryRunner } from 'src/tenant/resolver-builder/pg-graphql/pg-graphql-query-runner'; import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity'; @Injectable() -export class DeleteOneResolverFactory implements FactoryInterface { +export class DeleteOneResolverFactory + implements ResolverBuilderFactoryInterface +{ public static methodName = 'deleteOne' as const; constructor(private readonly dataSourceService: DataSourceService) {} diff --git a/server/src/tenant/resolver-builder/factories/find-many-resolver.factory.ts b/server/src/tenant/resolver-builder/factories/find-many-resolver.factory.ts index 2b3da97099..450c8ae4b8 100644 --- a/server/src/tenant/resolver-builder/factories/find-many-resolver.factory.ts +++ b/server/src/tenant/resolver-builder/factories/find-many-resolver.factory.ts @@ -5,13 +5,15 @@ import { Resolver, } from 'src/tenant/resolver-builder/interfaces/resolvers-builder.interface'; import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schema-builder-context.interface'; -import { FactoryInterface } from 'src/tenant/resolver-builder/interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from 'src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface'; import { DataSourceService } from 'src/metadata/data-source/data-source.service'; import { PGGraphQLQueryRunner } from 'src/tenant/resolver-builder/pg-graphql/pg-graphql-query-runner'; @Injectable() -export class FindManyResolverFactory implements FactoryInterface { +export class FindManyResolverFactory + implements ResolverBuilderFactoryInterface +{ public static methodName = 'findMany' as const; constructor(private readonly dataSourceService: DataSourceService) {} diff --git a/server/src/tenant/resolver-builder/factories/find-one-resolver.factory.ts b/server/src/tenant/resolver-builder/factories/find-one-resolver.factory.ts index 200ecd2f5b..806fac3ecc 100644 --- a/server/src/tenant/resolver-builder/factories/find-one-resolver.factory.ts +++ b/server/src/tenant/resolver-builder/factories/find-one-resolver.factory.ts @@ -5,14 +5,14 @@ import { Resolver, } from 'src/tenant/resolver-builder/interfaces/resolvers-builder.interface'; import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schema-builder-context.interface'; -import { FactoryInterface } from 'src/tenant/resolver-builder/interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from 'src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface'; import { DataSourceService } from 'src/metadata/data-source/data-source.service'; import { PGGraphQLQueryRunner } from 'src/tenant/resolver-builder/pg-graphql/pg-graphql-query-runner'; import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity'; @Injectable() -export class FindOneResolverFactory implements FactoryInterface { +export class FindOneResolverFactory implements ResolverBuilderFactoryInterface { public static methodName = 'findOne' as const; constructor(private readonly dataSourceService: DataSourceService) {} diff --git a/server/src/tenant/resolver-builder/factories/update-one-resolver.factory.ts b/server/src/tenant/resolver-builder/factories/update-one-resolver.factory.ts index 9c9bb31190..8374681294 100644 --- a/server/src/tenant/resolver-builder/factories/update-one-resolver.factory.ts +++ b/server/src/tenant/resolver-builder/factories/update-one-resolver.factory.ts @@ -5,14 +5,16 @@ import { UpdateOneResolverArgs, } from 'src/tenant/resolver-builder/interfaces/resolvers-builder.interface'; import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schema-builder-context.interface'; -import { FactoryInterface } from 'src/tenant/resolver-builder/interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from 'src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface'; import { DataSourceService } from 'src/metadata/data-source/data-source.service'; import { PGGraphQLQueryRunner } from 'src/tenant/resolver-builder/pg-graphql/pg-graphql-query-runner'; import { FieldMetadata } from 'src/metadata/field-metadata/field-metadata.entity'; @Injectable() -export class UpdateOneResolverFactory implements FactoryInterface { +export class UpdateOneResolverFactory + implements ResolverBuilderFactoryInterface +{ public static methodName = 'updateOne' as const; constructor(private readonly dataSourceService: DataSourceService) {} diff --git a/server/src/tenant/resolver-builder/interfaces/factory.interface.ts b/server/src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface.ts similarity index 81% rename from server/src/tenant/resolver-builder/interfaces/factory.interface.ts rename to server/src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface.ts index 158030efa9..eaabfa121a 100644 --- a/server/src/tenant/resolver-builder/interfaces/factory.interface.ts +++ b/server/src/tenant/resolver-builder/interfaces/resolver-builder-factory.interface.ts @@ -2,6 +2,6 @@ import { SchemaBuilderContext } from 'src/tenant/schema-builder/interfaces/schem import { Resolver } from './resolvers-builder.interface'; -export interface FactoryInterface { +export interface ResolverBuilderFactoryInterface { create(context: SchemaBuilderContext): Resolver; } diff --git a/server/src/tenant/resolver-builder/resolver.factory.ts b/server/src/tenant/resolver-builder/resolver.factory.ts index 2c4a9c8909..6d9cb2faad 100644 --- a/server/src/tenant/resolver-builder/resolver.factory.ts +++ b/server/src/tenant/resolver-builder/resolver.factory.ts @@ -16,7 +16,7 @@ import { ResolverBuilderMethodNames, ResolverBuilderMethods, } from './interfaces/resolvers-builder.interface'; -import { FactoryInterface } from './interfaces/factory.interface'; +import { ResolverBuilderFactoryInterface } from './interfaces/resolver-builder-factory.interface'; @Injectable() export class ResolverFactory { @@ -36,7 +36,10 @@ export class ResolverFactory { objectMetadataCollection: ObjectMetadataInterface[], resolverBuilderMethods: ResolverBuilderMethods, ): Promise { - const factories = new Map([ + const factories = new Map< + ResolverBuilderMethodNames, + ResolverBuilderFactoryInterface + >([ ['findMany', this.findManyResolverFactory], ['findOne', this.findOneResolverFactory], ['createMany', this.createManyResolverFactory],