chore: Move factories and helpers to a better place (#4551)
* chore: Move factories and helpers to a better place * align factory product variant * fix factory cart * add simple store fac * fix tests * fix tests * fix * fix cart seeder
This commit is contained in:
1 parent
26e2f81c24
commit
4d326fbbdf
197 files changed
+1073
-4332
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { DataSource } from "typeorm"
|
||||
import { BatchJob, BatchJobStatus } from "@medusajs/medusa"
|
||||
|
||||
export type BatchJobFactoryData = {
|
||||
id?: string
|
||||
type?: string
|
||||
status?: BatchJobStatus
|
||||
created_by?: string
|
||||
context?: Record<string, unknown>
|
||||
awaiting_confirmation_at?: Date | string
|
||||
completed_at?: Date | string
|
||||
}
|
||||
|
||||
export const simpleBatchJobFactory = async (
|
||||
dataSource: DataSource,
|
||||
data: BatchJobFactoryData = {}
|
||||
): Promise<BatchJob> => {
|
||||
const manager = dataSource.manager
|
||||
|
||||
const job = manager.create<BatchJob>(BatchJob, {
|
||||
id: data.id,
|
||||
status: data.status ?? BatchJobStatus.CREATED,
|
||||
completed_at: data.completed_at ?? null,
|
||||
type: data.type ?? "test-job",
|
||||
created_by: data.created_by ?? null,
|
||||
context: data.context ?? {},
|
||||
})
|
||||
|
||||
return await manager.save<BatchJob>(job)
|
||||
}
|
||||
Reference in new issue
Block a user