1 import { Context } from "@medusajs/framework/types"
2 import { DALUtils } from "@medusajs/framework/utils"
3
4 class CustomRepository extends DALUtils.MikroOrmBaseRepository {
5 constructor({ manager }) {
6 // @ts-ignore
7 super(...arguments)
8 }
9
10 find = jest.fn().mockImplementation(async () => [])
11 findAndCount = jest.fn().mockImplementation(async () => [])
12 create = jest.fn()
13 update = jest.fn()
14 delete = jest.fn()
15 softDelete = jest.fn()
16 restore = jest.fn()
17
18 async transaction<TManager = unknown>(
19 task: (transactionManager: TManager) => Promise<any>,
20 options: {
21 isolationLevel?: string
22 enableNestedTransactions?: boolean
23 transaction?: TManager
24 } = {}
25 ): Promise<any> {
26 return super.transaction(task, options)
27 }
28
29 getActiveManager<TManager = unknown>({
30 transactionManager,
31 manager,
32 }: Context = {}): TManager {
33 return super.getActiveManager({ transactionManager, manager })
34 }
35
36 getFreshManager<TManager = unknown>(): TManager {
37 return super.getFreshManager()
38 }
39
40 async serialize<TOutput extends object | object[]>(
41 data: any,
42 options?: any
43 ): Promise<TOutput> {
44 return super.serialize(data, options)
45 }
46 }
47
48 export class ProductRepository extends CustomRepository {}
49 export class ProductTagRepository extends CustomRepository {}
50 export class ProductCollectionRepository extends CustomRepository {}
51 export class ProductVariantRepository extends CustomRepository {}
52 export class ProductCategoryRepository extends CustomRepository {}