35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-valibot";
|
|
import { pipe, picklist } from "valibot";
|
|
import { projects, tasks, PROJECT_STATUSES, TASK_STATUSES, PRIORITIES } from "./drizzle/index";
|
|
|
|
const createProjectStatusSchema = (schema: any) => pipe(schema, picklist([...PROJECT_STATUSES])) as any;
|
|
const createTaskStatusSchema = (schema: any) => pipe(schema, picklist([...TASK_STATUSES])) as any;
|
|
const createPrioritySchema = (schema: any) => pipe(schema, picklist([...PRIORITIES])) as any;
|
|
|
|
export const projectSelect = createSelectSchema(projects, {
|
|
status: createProjectStatusSchema,
|
|
});
|
|
|
|
export const taskSelect = createSelectSchema(tasks, {
|
|
status: createTaskStatusSchema,
|
|
priority: createPrioritySchema,
|
|
});
|
|
|
|
export const projectInsert = createInsertSchema(projects, {
|
|
status: createProjectStatusSchema,
|
|
});
|
|
|
|
export const projectUpdate = createUpdateSchema(projects, {
|
|
status: createProjectStatusSchema,
|
|
});
|
|
|
|
export const taskInsert = createInsertSchema(tasks, {
|
|
status: createTaskStatusSchema,
|
|
priority: createPrioritySchema,
|
|
});
|
|
|
|
export const taskUpdate = createUpdateSchema(tasks, {
|
|
status: createTaskStatusSchema,
|
|
priority: createPrioritySchema,
|
|
});
|