@tmlmobilidade/types
Version:
This package provides shared Zod validation schemas and their corresponding TypeScript types for use across projects. All types are automatically inferred from the schemas to ensure full type safety and reduce maintenance overhead.
112 lines (111 loc) • 4.42 kB
TypeScript
import { type UnixTimestamp } from './unix-timestamp.js';
import { z } from 'zod';
export declare const scopeSchema: z.ZodEnum<["stop", "lines"]>;
export declare const statusSchema: z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>;
export declare const ProposedChangeSchema: z.ZodObject<{
_id: z.ZodString;
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
} & {
field_path: z.ZodString;
field_value: z.ZodAny;
scope: z.ZodEnum<["stop", "lines"]>;
status: z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>;
target_id: z.ZodString;
user_id: z.ZodString;
}, "strict", z.ZodTypeAny, {
_id: string;
status: "pending" | "accepted" | "declined";
user_id: string;
field_path: string;
scope: "stop" | "lines";
target_id: string;
created_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
updated_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
field_value?: any;
}, {
_id: string;
user_id: string;
field_path: string;
scope: "stop" | "lines";
target_id: string;
created_at?: number | null | undefined;
updated_at?: number | null | undefined;
status?: "pending" | "accepted" | "declined" | undefined;
field_value?: any;
}>;
export declare const CreateProposedChangeSchema: z.ZodObject<Omit<{
_id: z.ZodString;
created_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
updated_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
} & {
field_path: z.ZodString;
field_value: z.ZodAny;
scope: z.ZodEnum<["stop", "lines"]>;
status: z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>;
target_id: z.ZodString;
user_id: z.ZodString;
}, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
status: "pending" | "accepted" | "declined";
user_id: string;
field_path: string;
scope: "stop" | "lines";
target_id: string;
field_value?: any;
}, {
user_id: string;
field_path: string;
scope: "stop" | "lines";
target_id: string;
status?: "pending" | "accepted" | "declined" | undefined;
field_value?: any;
}>;
export declare const UpdateProposedChangeSchema: z.ZodObject<{
status: z.ZodOptional<z.ZodDefault<z.ZodEnum<["pending", "accepted", "declined"]>>>;
user_id: z.ZodOptional<z.ZodString>;
field_path: z.ZodOptional<z.ZodString>;
field_value: z.ZodOptional<z.ZodAny>;
scope: z.ZodOptional<z.ZodEnum<["stop", "lines"]>>;
target_id: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
status?: "pending" | "accepted" | "declined" | undefined;
user_id?: string | undefined;
field_path?: string | undefined;
field_value?: any;
scope?: "stop" | "lines" | undefined;
target_id?: string | undefined;
}, {
status?: "pending" | "accepted" | "declined" | undefined;
user_id?: string | undefined;
field_path?: string | undefined;
field_value?: any;
scope?: "stop" | "lines" | undefined;
target_id?: string | undefined;
}>;
export type Scope = z.infer<typeof scopeSchema>;
export type Status = z.infer<typeof statusSchema>;
export interface ProposedChange extends Omit<z.infer<typeof ProposedChangeSchema>, 'created_at' | 'field_path' | 'field_value' | 'scope' | 'status' | 'target_id' | 'updated_at' | 'user_id'> {
created_at: UnixTimestamp;
field_path: string;
field_value: unknown;
scope: Scope;
status: Status;
target_id: string;
updated_at: UnixTimestamp;
user_id: string;
}
export interface CreateProposedChangeDto extends Omit<z.infer<typeof CreateProposedChangeSchema>, 'created_at' | 'field_path' | 'field_value' | 'scope' | 'status' | 'target_id' | 'updated_at' | 'user_id'> {
created_at: UnixTimestamp;
field_path: string;
field_value: unknown;
scope: Scope;
status: Status;
target_id: string;
updated_at: UnixTimestamp;
user_id: string;
}
export type UpdateProposedChangeDto = Partial<Omit<CreateProposedChangeDto, 'created_by'>>;