Files
speckle-server/packages/server/modules/backgroundjobs/domain.ts
T
Gergő Jedlicska a5d624166b feat(backgroundjobs): add new background jobs module for file imports (#5041)
* feat(backgroundjobs): add new background jobs module for file imports
queueing

* fix(fileuploads): a merge gone wrong

* feat(backgroundjobs): rename rhino queue env var

* test(backgroundjob): use deep equal claude

* fix(fileuploads): sync PR review

* feat(backgroundjobs): add origin server url to the background jobs table

* test(backgroundjobs): make tests pass
2025-07-10 18:04:16 +01:00

40 lines
1002 B
TypeScript

import { z } from 'zod'
export const BackgroundJobStatus = {
Queued: 'queued',
// Processing: 'processing',
Succeeded: 'succeeded',
Failed: 'failed'
} as const
export type BackgroundJobStatus =
(typeof BackgroundJobStatus)[keyof typeof BackgroundJobStatus]
export const BackgroundJobPayload = z.object({
jobType: z.string(),
payloadVersion: z.number()
})
export type BackgroundJobPayload = z.infer<typeof BackgroundJobPayload>
export type BackgroundJobConfig = {
maxAttempt: number
timeoutMs: number
}
export type BackgroundJob<T extends BackgroundJobPayload> = BackgroundJobConfig & {
id: string
jobType: T['jobType']
payload: T
status: BackgroundJobStatus
attempt: number
createdAt: Date
updatedAt: Date
}
export type StoreBackgroundJob = (args: {
job: BackgroundJob<BackgroundJobPayload>
}) => Promise<void>
export type GetBackgroundJob<T extends BackgroundJobPayload = BackgroundJobPayload> =
(args: { jobId: string }) => Promise<BackgroundJob<T> | null>