chore: Update module test runner to support DmlEntities when needed (#7799)

* chore: Update module test runner to support DmlEntities when needed

* update es version for core test utils

* fix test

* update swc config
This commit is contained in:
Adrien de Peretti
2024-06-24 09:44:01 +02:00
committed by GitHub
parent 8fa43a6db3
commit ae6dbc06be
20 changed files with 202 additions and 52 deletions
@@ -632,4 +632,24 @@ export function createMikrORMEntity() {
}
}
export const toMikroORMEntity = createMikrORMEntity()
/**
* Takes a DML entity and returns a Mikro ORM entity otherwise
* return the input idempotently
* @param entity
*/
export const toMikroORMEntity = (entity: any) => {
if (DmlEntity.isDmlEntity(entity)) {
return createMikrORMEntity()(entity)
}
return entity
}
/**
* Takes any DmlEntity or mikro orm entities and return mikro orm entities only.
* This action is idempotent if non of the entities are DmlEntity
* @param entities
*/
export const toMikroOrmEntities = function (entities: any[]) {
return entities.map(toMikroORMEntity)
}