UNPKG

@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.

307 lines (306 loc) • 17.2 kB
import { type UnixTimestamp } from './_common/unix-timestamp.js'; import { z } from 'zod'; export declare const causeSchema: z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>; export declare const effectSchema: z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>; export declare const publishStatusSchema: z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>; export declare const alertTypeSchema: z.ZodEnum<["PLANNED", "REALTIME"]>; export declare const referenceTypeSchema: z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>; export declare const AlertSchema: 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">>>; } & { active_period_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; active_period_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">; cause: z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>; coordinates: z.ZodOptional<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>; created_by: z.ZodString; description: z.ZodString; effect: z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>; file_id: z.ZodOptional<z.ZodNullable<z.ZodString>>; info_url: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>; modified_by: z.ZodString; municipality_ids: z.ZodArray<z.ZodString, "many">; publish_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; publish_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">; publish_status: z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>; reference_type: z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>; references: z.ZodArray<z.ZodObject<{ child_ids: z.ZodArray<z.ZodString, "many">; parent_id: z.ZodString; }, "strip", z.ZodTypeAny, { child_ids: string[]; parent_id: string; }, { child_ids: string[]; parent_id: string; }>, "many">; title: z.ZodString; type: z.ZodEnum<["PLANNED", "REALTIME"]>; }, "strict", z.ZodTypeAny, { _id: string; type: "PLANNED" | "REALTIME"; created_by: string; municipality_ids: string[]; active_period_start_date: number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">; cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER"; description: string; effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT"; modified_by: string; publish_start_date: number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">; publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT"; reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP"; references: { child_ids: string[]; parent_id: string; }[]; title: string; created_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; updated_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; active_period_end_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; coordinates?: [number, number] | null | undefined; file_id?: string | null | undefined; info_url?: string | undefined; publish_end_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; }, { _id: string; type: "PLANNED" | "REALTIME"; created_by: string; municipality_ids: string[]; active_period_start_date: number; cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER"; description: string; effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT"; modified_by: string; publish_start_date: number; publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT"; reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP"; references: { child_ids: string[]; parent_id: string; }[]; title: string; created_at?: number | null | undefined; updated_at?: number | null | undefined; active_period_end_date?: number | null | undefined; coordinates?: [number, number] | null | undefined; file_id?: string | null | undefined; info_url?: string | undefined; publish_end_date?: number | null | undefined; }>; export declare const CreateAlertSchema: 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">>>; } & { active_period_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; active_period_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">; cause: z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>; coordinates: z.ZodOptional<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>; created_by: z.ZodString; description: z.ZodString; effect: z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>; file_id: z.ZodOptional<z.ZodNullable<z.ZodString>>; info_url: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>; modified_by: z.ZodString; municipality_ids: z.ZodArray<z.ZodString, "many">; publish_end_date: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; publish_start_date: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">; publish_status: z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>; reference_type: z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>; references: z.ZodArray<z.ZodObject<{ child_ids: z.ZodArray<z.ZodString, "many">; parent_id: z.ZodString; }, "strip", z.ZodTypeAny, { child_ids: string[]; parent_id: string; }, { child_ids: string[]; parent_id: string; }>, "many">; title: z.ZodString; type: z.ZodEnum<["PLANNED", "REALTIME"]>; }, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, { type: "PLANNED" | "REALTIME"; created_by: string; municipality_ids: string[]; active_period_start_date: number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">; cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER"; description: string; effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT"; modified_by: string; publish_start_date: number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">; publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT"; reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP"; references: { child_ids: string[]; parent_id: string; }[]; title: string; active_period_end_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; coordinates?: [number, number] | null | undefined; file_id?: string | null | undefined; info_url?: string | undefined; publish_end_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; }, { type: "PLANNED" | "REALTIME"; created_by: string; municipality_ids: string[]; active_period_start_date: number; cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER"; description: string; effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT"; modified_by: string; publish_start_date: number; publish_status: "PUBLISHED" | "ARCHIVED" | "DRAFT"; reference_type: "LINE" | "STOP" | "AGENCY" | "TRIP"; references: { child_ids: string[]; parent_id: string; }[]; title: string; active_period_end_date?: number | null | undefined; coordinates?: [number, number] | null | undefined; file_id?: string | null | undefined; info_url?: string | undefined; publish_end_date?: number | null | undefined; }>; export declare const UpdateAlertSchema: z.ZodObject<{ type: z.ZodOptional<z.ZodEnum<["PLANNED", "REALTIME"]>>; created_by: z.ZodOptional<z.ZodString>; municipality_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; active_period_end_date: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>; active_period_start_date: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>; cause: z.ZodOptional<z.ZodEnum<["ACCIDENT", "CONSTRUCTION", "DEMONSTRATION", "HOLIDAY", "MAINTENANCE", "MEDICAL_EMERGENCY", "OTHER_CAUSE", "POLICE_ACTIVITY", "STRIKE", "TECHNICAL_PROBLEM", "UNKNOWN_CAUSE", "WEATHER"]>>; coordinates: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>>; description: z.ZodOptional<z.ZodString>; effect: z.ZodOptional<z.ZodEnum<["ACCESSIBILITY_ISSUE", "ADDITIONAL_SERVICE", "DETOUR", "MODIFIED_SERVICE", "NO_EFFECT", "NO_SERVICE", "OTHER_EFFECT", "REDUCED_SERVICE", "SIGNIFICANT_DELAYS", "STOP_MOVED", "UNKNOWN_EFFECT"]>>; file_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>; info_url: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>>; modified_by: z.ZodOptional<z.ZodString>; publish_end_date: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>; publish_start_date: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>; publish_status: z.ZodOptional<z.ZodEnum<["PUBLISHED", "ARCHIVED", "DRAFT"]>>; reference_type: z.ZodOptional<z.ZodEnum<["LINE", "STOP", "AGENCY", "TRIP"]>>; references: z.ZodOptional<z.ZodArray<z.ZodObject<{ child_ids: z.ZodArray<z.ZodString, "many">; parent_id: z.ZodString; }, "strip", z.ZodTypeAny, { child_ids: string[]; parent_id: string; }, { child_ids: string[]; parent_id: string; }>, "many">>; title: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { type?: "PLANNED" | "REALTIME" | undefined; created_by?: string | undefined; municipality_ids?: string[] | undefined; active_period_end_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; active_period_start_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | undefined; cause?: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | undefined; coordinates?: [number, number] | null | undefined; description?: string | undefined; effect?: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT" | undefined; file_id?: string | null | undefined; info_url?: string | undefined; modified_by?: string | undefined; publish_end_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; publish_start_date?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | undefined; publish_status?: "PUBLISHED" | "ARCHIVED" | "DRAFT" | undefined; reference_type?: "LINE" | "STOP" | "AGENCY" | "TRIP" | undefined; references?: { child_ids: string[]; parent_id: string; }[] | undefined; title?: string | undefined; }, { type?: "PLANNED" | "REALTIME" | undefined; created_by?: string | undefined; municipality_ids?: string[] | undefined; active_period_end_date?: number | null | undefined; active_period_start_date?: number | undefined; cause?: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "HOLIDAY" | "MAINTENANCE" | "MEDICAL_EMERGENCY" | "OTHER_CAUSE" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_PROBLEM" | "UNKNOWN_CAUSE" | "WEATHER" | undefined; coordinates?: [number, number] | null | undefined; description?: string | undefined; effect?: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_EFFECT" | "NO_SERVICE" | "OTHER_EFFECT" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "UNKNOWN_EFFECT" | undefined; file_id?: string | null | undefined; info_url?: string | undefined; modified_by?: string | undefined; publish_end_date?: number | null | undefined; publish_start_date?: number | undefined; publish_status?: "PUBLISHED" | "ARCHIVED" | "DRAFT" | undefined; reference_type?: "LINE" | "STOP" | "AGENCY" | "TRIP" | undefined; references?: { child_ids: string[]; parent_id: string; }[] | undefined; title?: string | undefined; }>; export type Cause = z.infer<typeof causeSchema>; export type Effect = z.infer<typeof effectSchema>; export type PublishStatus = z.infer<typeof publishStatusSchema>; export type AlertType = z.infer<typeof alertTypeSchema>; export type ReferenceType = z.infer<typeof referenceTypeSchema>; export interface Alert extends Omit<z.infer<typeof AlertSchema>, 'active_period_end_date' | 'active_period_start_date' | 'cause' | 'created_at' | 'effect' | 'publish_end_date' | 'publish_start_date' | 'publish_status' | 'reference_type' | 'type' | 'updated_at'> { active_period_end_date: null | undefined | UnixTimestamp; active_period_start_date: UnixTimestamp; cause: Cause; created_at: UnixTimestamp; effect: Effect; publish_end_date: null | undefined | UnixTimestamp; publish_start_date: UnixTimestamp; publish_status: PublishStatus; reference_type: ReferenceType; type: AlertType; updated_at: UnixTimestamp; } export interface CreateAlertDto extends Omit<z.infer<typeof CreateAlertSchema>, 'active_period_end_date' | 'active_period_start_date' | 'cause' | 'effect' | 'publish_end_date' | 'publish_start_date' | 'publish_status' | 'reference_type' | 'type'> { active_period_end_date: null | undefined | UnixTimestamp; active_period_start_date: UnixTimestamp; cause: Cause; effect: Effect; publish_end_date: null | undefined | UnixTimestamp; publish_start_date: UnixTimestamp; publish_status: PublishStatus; reference_type: ReferenceType; type: AlertType; } export type UpdateAlertDto = Partial<Omit<CreateAlertDto, 'created_by'>>; export declare const AlertPermissionSchema: z.ZodObject<{ agency_ids: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { agency_ids: string[]; }, { agency_ids: string[]; }>; export type AlertPermission = z.infer<typeof AlertPermissionSchema>;