Uecko_ERP/modules/customer-invoices/src/web/schemas/customer-invoices.api.schema.ts

30 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-09-24 17:30:35 +00:00
import { z } from "zod/v4";
2025-09-24 15:09:37 +00:00
2025-10-02 16:30:46 +00:00
import { ArrayElement } from "@repo/rdx-utils";
2025-09-24 17:30:35 +00:00
import {
2025-09-29 18:22:59 +00:00
CreateCustomerInvoiceRequestSchema,
2025-09-24 17:30:35 +00:00
GetCustomerInvoiceByIdResponseSchema,
ListCustomerInvoicesResponseDTO,
2025-09-29 18:22:59 +00:00
UpdateCustomerInvoiceByIdRequestSchema,
} from "../../common";
2025-09-24 15:09:37 +00:00
2025-10-02 16:30:46 +00:00
// Esquemas (Zod) provenientes del servidor
2025-09-29 18:22:59 +00:00
export const CustomerInvoiceSchema = GetCustomerInvoiceByIdResponseSchema.omit({
2025-09-24 15:09:37 +00:00
metadata: true,
});
2025-10-02 16:30:46 +00:00
export const CustomerInvoiceCreateSchema = CreateCustomerInvoiceRequestSchema;
export const CustomerInvoiceUpdateSchema = UpdateCustomerInvoiceByIdRequestSchema;
// Tipos (derivados de Zod o DTOs del backend)
export type CustomerInvoice = z.infer<typeof CustomerInvoiceSchema>;
2025-10-06 17:40:37 +00:00
export type CustomerInvoiceItem = ArrayElement<CustomerInvoice["items"]>;
2025-10-02 16:30:46 +00:00
export type CustomerInvoiceCreateInput = z.infer<typeof CustomerInvoiceCreateSchema>; // Cuerpo para crear
export type CustomerInvoiceUpdateInput = z.infer<typeof CustomerInvoiceUpdateSchema>; // Cuerpo para actualizar
2025-09-24 15:09:37 +00:00
2025-10-02 16:30:46 +00:00
// Resultado de consulta con criteria (paginado, etc.)
export type CustomerInvoicesPage = ListCustomerInvoicesResponseDTO;
2025-09-24 15:09:37 +00:00
2025-10-02 16:30:46 +00:00
// Ítem simplificado dentro del listado (no toda la entidad)
export type CustomerInvoiceSummary = Omit<ArrayElement<CustomerInvoicesPage["items"]>, "metadata">;