2026-04-28 17:46:34 +02:00
|
|
|
import { usersId, type UsersId } from './Users';
|
|
|
|
|
import { prezziarioIdprezziario, type PrezziarioIdprezziario } from './Prezziario';
|
|
|
|
|
import { servizioServizioId, type ServizioServizioId } from './Servizio';
|
|
|
|
|
import { orderTypeEnum, type default as OrderTypeEnum } from './OrderTypeEnum';
|
|
|
|
|
import { paymentStatusEnum, type default as PaymentStatusEnum } from './PaymentStatusEnum';
|
|
|
|
|
import { rinnoviId, type RinnoviId } from './Rinnovi';
|
2025-10-21 18:42:03 +02:00
|
|
|
import type { ColumnType, Selectable, Insertable, Updateable } from 'kysely';
|
2026-04-28 17:46:34 +02:00
|
|
|
import { z } from 'zod';
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
/** Identifier type for public.ordini */
|
2025-10-21 18:42:03 +02:00
|
|
|
export type OrdiniOrdineId = string & { __brand: 'public.ordini' };
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
/** Represents the table public.ordini */
|
|
|
|
|
export default interface OrdiniTable {
|
2025-10-21 18:42:03 +02:00
|
|
|
ordine_id: ColumnType<OrdiniOrdineId, OrdiniOrdineId | undefined, OrdiniOrdineId>;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-21 18:42:03 +02:00
|
|
|
userid: ColumnType<UsersId, UsersId, UsersId>;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-21 18:42:03 +02:00
|
|
|
created_at: ColumnType<Date, Date | string | undefined, Date | string>;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-21 18:42:03 +02:00
|
|
|
packid: ColumnType<PrezziarioIdprezziario, PrezziarioIdprezziario, PrezziarioIdprezziario>;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2026-03-17 18:46:43 +01:00
|
|
|
servizio_id: ColumnType<ServizioServizioId | null, ServizioServizioId | null, ServizioServizioId | null>;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-21 18:42:03 +02:00
|
|
|
type: ColumnType<OrderTypeEnum, OrderTypeEnum, OrderTypeEnum>;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-10-21 18:42:03 +02:00
|
|
|
isActive: ColumnType<boolean, boolean | undefined, boolean>;
|
2026-03-08 01:02:57 +01:00
|
|
|
|
|
|
|
|
amount_cent: ColumnType<number, number, number>;
|
|
|
|
|
|
|
|
|
|
paymentmethod: ColumnType<string | null, string | null, string | null>;
|
|
|
|
|
|
|
|
|
|
paid_at: ColumnType<Date | null, Date | string | null, Date | string | null>;
|
|
|
|
|
|
|
|
|
|
intent_id: ColumnType<string | null, string | null, string | null>;
|
|
|
|
|
|
|
|
|
|
paymentstatus: ColumnType<PaymentStatusEnum | null, PaymentStatusEnum | null, PaymentStatusEnum | null>;
|
|
|
|
|
|
|
|
|
|
sconto: ColumnType<number, number | undefined, number>;
|
2026-03-17 18:46:43 +01:00
|
|
|
|
|
|
|
|
rinnovo_id: ColumnType<RinnoviId | null, RinnoviId | null, RinnoviId | null>;
|
2025-08-04 17:45:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type Ordini = Selectable<OrdiniTable>;
|
|
|
|
|
|
|
|
|
|
export type NewOrdini = Insertable<OrdiniTable>;
|
|
|
|
|
|
2026-04-28 17:46:34 +02:00
|
|
|
export type OrdiniUpdate = Updateable<OrdiniTable>;
|
|
|
|
|
|
|
|
|
|
export const ordiniOrdineId = z.uuid().transform(value => value as OrdiniOrdineId);
|
|
|
|
|
|
|
|
|
|
export const OrdiniSchema = z.object({
|
|
|
|
|
ordine_id: ordiniOrdineId,
|
|
|
|
|
userid: usersId,
|
|
|
|
|
created_at: z.date(),
|
|
|
|
|
packid: prezziarioIdprezziario,
|
|
|
|
|
servizio_id: servizioServizioId.nullable(),
|
|
|
|
|
type: orderTypeEnum,
|
|
|
|
|
isActive: z.boolean(),
|
|
|
|
|
amount_cent: z.number(),
|
|
|
|
|
paymentmethod: z.string().nullable(),
|
|
|
|
|
paid_at: z.date().nullable(),
|
|
|
|
|
intent_id: z.string().nullable(),
|
|
|
|
|
paymentstatus: paymentStatusEnum.nullable(),
|
|
|
|
|
sconto: z.number(),
|
|
|
|
|
rinnovo_id: rinnoviId.nullable(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const NewOrdiniSchema = z.object({
|
|
|
|
|
ordine_id: ordiniOrdineId.optional(),
|
|
|
|
|
userid: usersId,
|
2026-04-28 20:32:19 +02:00
|
|
|
created_at: z.union([z.date(), z.string()]).pipe(z.coerce.date()).optional(),
|
2026-04-28 17:46:34 +02:00
|
|
|
packid: prezziarioIdprezziario,
|
|
|
|
|
servizio_id: servizioServizioId.optional().nullable(),
|
|
|
|
|
type: orderTypeEnum,
|
|
|
|
|
isActive: z.boolean().optional(),
|
|
|
|
|
amount_cent: z.number(),
|
|
|
|
|
paymentmethod: z.string().optional().nullable(),
|
2026-04-28 20:32:19 +02:00
|
|
|
paid_at: z.union([z.date(), z.string()]).pipe(z.coerce.date()).optional().nullable(),
|
2026-04-28 17:46:34 +02:00
|
|
|
intent_id: z.string().optional().nullable(),
|
|
|
|
|
paymentstatus: paymentStatusEnum.optional().nullable(),
|
|
|
|
|
sconto: z.number().optional(),
|
|
|
|
|
rinnovo_id: rinnoviId.optional().nullable(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const OrdiniUpdateSchema = z.object({
|
|
|
|
|
ordine_id: ordiniOrdineId.optional(),
|
|
|
|
|
userid: usersId.optional(),
|
2026-04-28 20:32:19 +02:00
|
|
|
created_at: z.union([z.date(), z.string()]).pipe(z.coerce.date()).optional(),
|
2026-04-28 17:46:34 +02:00
|
|
|
packid: prezziarioIdprezziario.optional(),
|
|
|
|
|
servizio_id: servizioServizioId.optional().nullable(),
|
|
|
|
|
type: orderTypeEnum.optional(),
|
|
|
|
|
isActive: z.boolean().optional(),
|
|
|
|
|
amount_cent: z.number().optional(),
|
|
|
|
|
paymentmethod: z.string().optional().nullable(),
|
2026-04-28 20:32:19 +02:00
|
|
|
paid_at: z.union([z.date(), z.string()]).pipe(z.coerce.date()).optional().nullable(),
|
2026-04-28 17:46:34 +02:00
|
|
|
intent_id: z.string().optional().nullable(),
|
|
|
|
|
paymentstatus: paymentStatusEnum.optional().nullable(),
|
|
|
|
|
sconto: z.number().optional(),
|
|
|
|
|
rinnovo_id: rinnoviId.optional().nullable(),
|
|
|
|
|
});
|