chore: improve mikro orm serializer circular ref and link serialization (#9411)

This commit is contained in:
Adrien de Peretti
2024-10-03 08:22:11 +02:00
committed by GitHub
parent 2d1cf12dac
commit 225d00cd09
12 changed files with 142 additions and 105 deletions

View File

@@ -22,7 +22,7 @@ export function getModuleService(
)
}
return class LinkService extends LinkModuleService<unknown> {
return class LinkService extends LinkModuleService {
override __joinerConfig(): ModuleJoinerConfig {
return joinerConfig_ as ModuleJoinerConfig
}

View File

@@ -35,9 +35,9 @@ type InjectedDependencies = {
[Modules.EVENT_BUS]?: IEventBusModuleService
}
export default class LinkModuleService<TLink> implements ILinkModule {
export default class LinkModuleService implements ILinkModule {
protected baseRepository_: DAL.RepositoryService
protected readonly linkService_: LinkService<TLink>
protected readonly linkService_: LinkService<any>
protected readonly eventBusModuleService_?: IEventBusModuleService
protected readonly entityName_: string
protected readonly serviceName_: string
@@ -151,7 +151,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
const rows = await this.linkService_.list(filters, config, sharedContext)
return await this.baseRepository_.serialize<object[]>(rows)
return rows.map((row) => row.toJSON())
}
@InjectManager()
@@ -170,7 +170,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
sharedContext
)
return [await this.baseRepository_.serialize<object[]>(rows), count]
return [rows.map((row) => row.toJSON()), count]
}
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
@@ -219,7 +219,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
}))
)
return await this.baseRepository_.serialize<object[]>(links)
return links.map((row) => row.toJSON())
}
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")
@@ -244,7 +244,7 @@ export default class LinkModuleService<TLink> implements ILinkModule {
const links = await this.linkService_.dismiss(data, sharedContext)
return await this.baseRepository_.serialize<object[]>(links)
return links.map((row) => row.toJSON())
}
@InjectTransactionManager(shouldForceTransaction, "baseRepository_")