46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { z } from 'zod';
|
|
import { pageSchema } from '../identity/identity.schemas';
|
|
|
|
export const createBatchSchema = z
|
|
.object({
|
|
bomId: z.uuid(),
|
|
reference: z
|
|
.string()
|
|
.trim()
|
|
.toUpperCase()
|
|
.max(32)
|
|
.regex(/^[A-Z0-9][A-Z0-9_-]*$/),
|
|
plannedQuantity: z.number().int().min(1).max(100000),
|
|
scheduledDate: z.iso
|
|
.date()
|
|
.transform((value) => new Date(`${value}T00:00:00.000Z`))
|
|
.optional(),
|
|
})
|
|
.strict();
|
|
|
|
export const completeBatchSchema = z
|
|
.object({
|
|
goodQuantity: z.number().int().min(0).max(100000),
|
|
rejectedQuantity: z.number().int().min(0).max(100000),
|
|
rejectionReason: z.string().trim().min(1).max(500).optional(),
|
|
})
|
|
.strict();
|
|
|
|
export const cancelBatchSchema = z
|
|
.object({ reason: z.string().trim().min(1).max(500) })
|
|
.strict();
|
|
|
|
export const batchListQuery = pageSchema
|
|
.extend({
|
|
status: z
|
|
.enum(['DRAFT', 'IN_PROGRESS', 'COMPLETED', 'CANCELLED'])
|
|
.optional(),
|
|
variantId: z.uuid().optional(),
|
|
})
|
|
.strict();
|
|
|
|
export type CreateBatchInput = z.infer<typeof createBatchSchema>;
|
|
export type CompleteBatchInput = z.infer<typeof completeBatchSchema>;
|
|
export type CancelBatchInput = z.infer<typeof cancelBatchSchema>;
|
|
export type BatchListQuery = z.infer<typeof batchListQuery>;
|