diff --git a/packages/core/src/lib/core/decorators/entity/relations/many-to-many.decorator.ts b/packages/core/src/lib/core/decorators/entity/relations/many-to-many.decorator.ts index 7a4673c0599..d8e33ff9a9b 100644 --- a/packages/core/src/lib/core/decorators/entity/relations/many-to-many.decorator.ts +++ b/packages/core/src/lib/core/decorators/entity/relations/many-to-many.decorator.ts @@ -2,7 +2,7 @@ import { Cascade, EntityName, ManyToManyOptions } from '@mikro-orm/core'; import { RelationOptions as TypeOrmRelationOptions } from 'typeorm'; import { omit } from 'underscore'; import { deepClone, isObject } from '@gauzy/utils'; -import { MultiORMEnum } from '../../../../core/utils'; +import { MultiORMEnum, getORMType } from '../../../../core/utils'; import { TypeOrmManyToMany } from './type-orm'; import { MikroOrmManyToMany } from './mikro-orm'; import { MikroORMInverseSide, TypeORMInverseSide, TypeORMRelationOptions, TypeORMTarget } from './shared-types'; @@ -56,21 +56,28 @@ export function MultiORMManyToMany( // If options are not provided, initialize an empty object if (!options) options = {} as RelationOptions; - // Use TypeORM decorator for Many-to-Many - TypeOrmManyToMany( - typeFunctionOrTarget as TypeORMTarget, - inverseSideProperty as TypeORMInverseSide, - options as TypeORMRelationOptions - )(target, propertyKey); - - // Use MikroORM decorator for Many-to-Many - MikroOrmManyToMany( - mapManyToManyArgsForMikroORM({ - typeFunctionOrTarget, - inverseSide: inverseSideProperty as InverseSide, - options - }) - )(target, propertyKey); + // Determine which ORM is in use + const ormType = getORMType(); + + // Apply TypeORM decorator when using TypeORM + if (ormType === MultiORMEnum.TypeORM) { + TypeOrmManyToMany( + typeFunctionOrTarget as TypeORMTarget, + inverseSideProperty as TypeORMInverseSide, + options as TypeORMRelationOptions + )(target, propertyKey); + } + + // Apply MikroORM decorator when using MikroORM + if (ormType === MultiORMEnum.MikroORM) { + MikroOrmManyToMany( + mapManyToManyArgsForMikroORM({ + typeFunctionOrTarget, + inverseSide: inverseSideProperty as InverseSide, + options + }) + )(target, propertyKey); + } }; } diff --git a/packages/core/src/lib/core/decorators/entity/relations/many-to-one.decorator.ts b/packages/core/src/lib/core/decorators/entity/relations/many-to-one.decorator.ts index 14919389ed9..f99c2ebb71e 100644 --- a/packages/core/src/lib/core/decorators/entity/relations/many-to-one.decorator.ts +++ b/packages/core/src/lib/core/decorators/entity/relations/many-to-one.decorator.ts @@ -1,6 +1,7 @@ import { Cascade, EntityName, ManyToOneOptions } from '@mikro-orm/core'; import { omit } from 'underscore'; import { deepClone, isObject } from '@gauzy/utils'; +import { MultiORMEnum, getORMType } from '../../../../core/utils'; import { TypeOrmManyToOne } from './type-orm'; import { MikroOrmManyToOne } from './mikro-orm'; import { @@ -66,23 +67,30 @@ export function MultiORMManyToOne( // If options are not provided, initialize an empty object if (!options) options = {} as RelationOptions; - // Use TypeORM decorator for Many-to-One - TypeOrmManyToOne( - typeFunctionOrTarget as TypeORMTarget, - inverseSideOrOptions as TypeORMInverseSide, - options as TypeORMRelationOptions - )(target, propertyKey); - - // Use MikroORM decorator for Many-to-One - MikroOrmManyToOne( - mapManyToOneArgsForMikroORM({ - typeFunctionOrTarget, - inverseSideOrOptions: inverseSideProperty as InverseSide, - options, - propertyKey, - target - }) - )(target, propertyKey); + // Determine which ORM is in use + const ormType = getORMType(); + + // Apply TypeORM decorator when using TypeORM + if (ormType === MultiORMEnum.TypeORM) { + TypeOrmManyToOne( + typeFunctionOrTarget as TypeORMTarget, + inverseSideOrOptions as TypeORMInverseSide, + options as TypeORMRelationOptions + )(target, propertyKey); + } + + // Apply MikroORM decorator when using MikroORM + if (ormType === MultiORMEnum.MikroORM) { + MikroOrmManyToOne( + mapManyToOneArgsForMikroORM({ + typeFunctionOrTarget, + inverseSideOrOptions: inverseSideProperty as InverseSide, + options, + propertyKey, + target + }) + )(target, propertyKey); + } }; } diff --git a/packages/core/src/lib/core/decorators/entity/relations/one-to-many.decorator.ts b/packages/core/src/lib/core/decorators/entity/relations/one-to-many.decorator.ts index 56eac44ff15..87e0c75031d 100644 --- a/packages/core/src/lib/core/decorators/entity/relations/one-to-many.decorator.ts +++ b/packages/core/src/lib/core/decorators/entity/relations/one-to-many.decorator.ts @@ -2,6 +2,7 @@ import { Cascade, EntityName, OneToManyOptions } from '@mikro-orm/core'; import { RelationOptions as TypeOrmRelationOptions } from 'typeorm'; import { omit } from 'underscore'; import { deepClone, isObject } from '@gauzy/utils'; +import { MultiORMEnum, getORMType } from '../../../../core/utils'; import { TypeOrmOneToMany } from './type-orm'; import { MikroOrmOneToMany } from './mikro-orm'; import { MikroORMInverseSide, TypeORMInverseSide, TypeORMRelationOptions, TypeORMTarget } from './shared-types'; @@ -55,21 +56,28 @@ export function MultiORMOneToMany( // If options are not provided, initialize an empty object if (!options) options = {} as RelationOptions; - // Apply TypeORM One-to-Many decorator - TypeOrmOneToMany( - typeFunctionOrTarget as TypeORMTarget, - inverseSideProperty as TypeORMInverseSide, - options as TypeORMRelationOptions - )(target, propertyKey); + // Determine which ORM is in use + const ormType = getORMType(); - // Apply MikroORM One-to-Many decorator - MikroOrmOneToMany( - mapOneToManyArgsForMikroORM({ - typeFunctionOrTarget, - inverseSide: inverseSideProperty as InverseSide, - options - }) - )(target, propertyKey); + // Apply TypeORM One-to-Many decorator when using TypeORM + if (ormType === MultiORMEnum.TypeORM) { + TypeOrmOneToMany( + typeFunctionOrTarget as TypeORMTarget, + inverseSideProperty as TypeORMInverseSide, + options as TypeORMRelationOptions + )(target, propertyKey); + } + + // Apply MikroORM One-to-Many decorator when using MikroORM + if (ormType === MultiORMEnum.MikroORM) { + MikroOrmOneToMany( + mapOneToManyArgsForMikroORM({ + typeFunctionOrTarget, + inverseSide: inverseSideProperty as InverseSide, + options + }) + )(target, propertyKey); + } }; } diff --git a/packages/core/src/lib/core/decorators/entity/relations/one-to-one.decorator.ts b/packages/core/src/lib/core/decorators/entity/relations/one-to-one.decorator.ts index eb8695ffc70..74e12a2406a 100644 --- a/packages/core/src/lib/core/decorators/entity/relations/one-to-one.decorator.ts +++ b/packages/core/src/lib/core/decorators/entity/relations/one-to-one.decorator.ts @@ -1,7 +1,7 @@ import { Cascade, EntityName, OneToOneOptions } from '@mikro-orm/core'; import { omit } from 'underscore'; import { deepClone, isObject } from '@gauzy/utils'; -import { MultiORMEnum } from '../../../../core/utils'; +import { MultiORMEnum, getORMType } from '../../../../core/utils'; import { MikroORMInverseSide, TypeORMInverseSide, @@ -67,22 +67,29 @@ export function MultiORMOneToOne( // If options are not provided, initialize an empty object if (!options) options = {} as RelationOptions; - // Use TypeORM decorator for One-to-One - TypeOrmOneToOne( - typeFunctionOrTarget as TypeORMTarget, - inverseSideOrOptions as TypeORMInverseSide, - options as TypeORMRelationOptions - )(target, propertyKey); - - // Use MikroORM decorator for One-to-One - MikroOrmOneToOne( - mapOneToOneArgsForMikroORM({ - typeFunctionOrTarget, - inverseSideOrOptions: inverseSideProperty as InverseSide, - options, - propertyKey - }) - )(target, propertyKey); + // Determine which ORM is in use + const ormType = getORMType(); + + // Apply TypeORM decorator when using TypeORM + if (ormType === MultiORMEnum.TypeORM) { + TypeOrmOneToOne( + typeFunctionOrTarget as TypeORMTarget, + inverseSideOrOptions as TypeORMInverseSide, + options as TypeORMRelationOptions + )(target, propertyKey); + } + + // Apply MikroORM decorator when using MikroORM + if (ormType === MultiORMEnum.MikroORM) { + MikroOrmOneToOne( + mapOneToOneArgsForMikroORM({ + typeFunctionOrTarget, + inverseSideOrOptions: inverseSideProperty as InverseSide, + options, + propertyKey + }) + )(target, propertyKey); + } }; } diff --git a/packages/ui-config/project.json b/packages/ui-config/project.json index ad10f9c59de..326784f6aee 100644 --- a/packages/ui-config/project.json +++ b/packages/ui-config/project.json @@ -13,7 +13,8 @@ "dependsOn": [ { "target": "setup-env", - "projects": "self" + "projects": "self", + "params": "forward" } ], "options": { diff --git a/packages/ui-core/project.json b/packages/ui-core/project.json index 27b6113422c..454c3e2dc46 100644 --- a/packages/ui-core/project.json +++ b/packages/ui-core/project.json @@ -5,22 +5,17 @@ "prefix": "lib", "projectType": "library", "tags": [], - "implicitDependencies": [ - "constants", - "contracts", - "ui-config" - ], + "implicitDependencies": ["constants", "contracts", "ui-config"], "targets": { "build": { "executor": "@nx/angular:package", - "outputs": [ - "{workspaceRoot}/dist/{projectRoot}" - ], + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], "dependsOn": [ "^build", { "target": "config", - "projects": "self" + "projects": "self", + "params": "forward" } ], "options": { @@ -41,23 +36,17 @@ "executor": "nx:run-commands", "configurations": { "production": { - "commands": [ - "nx build ui-config --configuration=production" - ] + "commands": ["nx build ui-config --configuration=production"] }, "development": { - "commands": [ - "nx build ui-config --configuration=development" - ] + "commands": ["nx build ui-config --configuration=development"] } }, "defaultConfiguration": "development" }, "test": { "executor": "@nx/jest:jest", - "outputs": [ - "{workspaceRoot}/coverage/{projectRoot}" - ], + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { "jestConfig": "packages/ui-core/jest.config.ts", "tsConfig": "packages/ui-core/tsconfig.spec.json"