32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import type { PaginationSchema } from "@erp/core";
|
|
import type { ArrayElement } from "@repo/rdx-utils";
|
|
import type { z } from "zod/v4";
|
|
|
|
import {
|
|
CreateCustomerRequestSchema,
|
|
GetCustomerByIdResponseSchema,
|
|
ListCustomersResponseSchema,
|
|
UpdateCustomerByIdRequestSchema,
|
|
} from "../../common";
|
|
|
|
// Esquemas (Zod) provenientes del servidor
|
|
export const CustomerSchema = GetCustomerByIdResponseSchema.omit({ metadata: true });
|
|
export const CustomerCreateSchema = CreateCustomerRequestSchema;
|
|
export const CustomerUpdateSchema = UpdateCustomerByIdRequestSchema;
|
|
|
|
// Tipos (derivados de Zod o DTOs del backend)
|
|
export type Customer = z.infer<typeof CustomerSchema>; // Entidad completa (GET/POST/PUT result)
|
|
export type CustomerCreateInput = z.infer<typeof CustomerCreateSchema>; // Cuerpo para crear
|
|
export type CustomerUpdateInput = z.infer<typeof CustomerUpdateSchema>; // Cuerpo para actualizar
|
|
|
|
// Resultado de consulta con criteria (paginado, etc.)
|
|
export const CustomersPageSchema = ListCustomersResponseSchema.omit({
|
|
metadata: true,
|
|
});
|
|
|
|
export type PaginatedResponse = z.infer<typeof PaginationSchema>;
|
|
export type CustomersPage = z.infer<typeof CustomersPageSchema>;
|
|
|
|
// Ítem simplificado dentro del listado (no toda la entidad)
|
|
export type CustomerSummary = Omit<ArrayElement<CustomersPage["items"]>, "metadata">;
|