UNPKG

@speckle/shared

Version:

Shared code between various Speckle JS packages

44 lines 1.35 kB
import z from 'zod'; const job = z.object({ jobId: z.string() }); export const jobPayload = job.merge(z.object({ url: z.string(), token: z.string(), responseQueue: z.string() })); const previewPageResult = z.object({ durationSeconds: z.number().describe('Duration to generate the preview, in seconds'), screenshots: z.record(z.string(), z.string()) }); const durationDetail = z.object({ loadDurationSeconds: z .number() .describe('Duration to load the object from the server in seconds') .optional(), renderDurationSeconds: z .number() .describe('Duration to render the preview images in seconds') .optional() }); const previewJobResult = previewPageResult.merge(durationDetail); const previewSuccessPayload = job.merge(z.object({ status: z.literal('success'), result: previewJobResult })); const previewErrorPayload = job.merge(z.object({ status: z.literal('error'), reason: z.string(), result: z .object({ durationSeconds: z .number() .describe('Duration spent processing the job before erroring, in seconds') }) .merge(durationDetail) })); export const previewResultPayload = z.discriminatedUnion('status', [ previewSuccessPayload, previewErrorPayload ]); //# sourceMappingURL=job.js.map