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.

153 lines (152 loc) • 7.39 kB
import { type UnixTimestamp } from '../_common/unix-timestamp.js'; import { z } from 'zod'; export declare const UniqueSamSchema: z.ZodObject<{ 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">>>; } & { _id: z.ZodNumber; agency_id: z.ZodString; device_id: z.ZodString; latest_apex_version: z.ZodNullable<z.ZodString>; seen_first_at: z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>; seen_last_at: z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>; status: z.ZodDefault<z.ZodEnum<["missing_transactions", "complete", "error", "pending"]>>; status_message: z.ZodNullable<z.ZodString>; transactions_expected: z.ZodNullable<z.ZodNumber>; transactions_found: z.ZodNullable<z.ZodNumber>; transactions_missing: z.ZodNullable<z.ZodNumber>; }, "strict", z.ZodTypeAny, { _id: number; status: "pending" | "error" | "complete" | "missing_transactions"; agency_id: string; seen_first_at: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null; seen_last_at: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null; device_id: string; latest_apex_version: string | null; status_message: string | null; transactions_expected: number | null; transactions_found: number | null; transactions_missing: number | null; created_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; updated_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; }, { _id: number; agency_id: string; seen_first_at: number | null; seen_last_at: number | null; device_id: string; latest_apex_version: string | null; status_message: string | null; transactions_expected: number | null; transactions_found: number | null; transactions_missing: number | null; created_at?: number | null | undefined; updated_at?: number | null | undefined; status?: "pending" | "error" | "complete" | "missing_transactions" | undefined; }>; export declare const CreateUniqueSamSchema: z.ZodObject<Omit<{ 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">>>; } & { _id: z.ZodNumber; agency_id: z.ZodString; device_id: z.ZodString; latest_apex_version: z.ZodNullable<z.ZodString>; seen_first_at: z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>; seen_last_at: z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>; status: z.ZodDefault<z.ZodEnum<["missing_transactions", "complete", "error", "pending"]>>; status_message: z.ZodNullable<z.ZodString>; transactions_expected: z.ZodNullable<z.ZodNumber>; transactions_found: z.ZodNullable<z.ZodNumber>; transactions_missing: z.ZodNullable<z.ZodNumber>; }, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, { status: "pending" | "error" | "complete" | "missing_transactions"; agency_id: string; seen_first_at: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null; seen_last_at: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null; device_id: string; latest_apex_version: string | null; status_message: string | null; transactions_expected: number | null; transactions_found: number | null; transactions_missing: number | null; }, { agency_id: string; seen_first_at: number | null; seen_last_at: number | null; device_id: string; latest_apex_version: string | null; status_message: string | null; transactions_expected: number | null; transactions_found: number | null; transactions_missing: number | null; status?: "pending" | "error" | "complete" | "missing_transactions" | undefined; }>; export declare const UpdateUniqueSamSchema: z.ZodObject<{ status: z.ZodOptional<z.ZodDefault<z.ZodEnum<["missing_transactions", "complete", "error", "pending"]>>>; agency_id: z.ZodOptional<z.ZodString>; seen_first_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; seen_last_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; device_id: z.ZodOptional<z.ZodString>; latest_apex_version: z.ZodOptional<z.ZodNullable<z.ZodString>>; status_message: z.ZodOptional<z.ZodNullable<z.ZodString>>; transactions_expected: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; transactions_found: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; transactions_missing: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; }, "strict", z.ZodTypeAny, { status?: "pending" | "error" | "complete" | "missing_transactions" | undefined; agency_id?: string | undefined; seen_first_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; seen_last_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; device_id?: string | undefined; latest_apex_version?: string | null | undefined; status_message?: string | null | undefined; transactions_expected?: number | null | undefined; transactions_found?: number | null | undefined; transactions_missing?: number | null | undefined; }, { status?: "pending" | "error" | "complete" | "missing_transactions" | undefined; agency_id?: string | undefined; seen_first_at?: number | null | undefined; seen_last_at?: number | null | undefined; device_id?: string | undefined; latest_apex_version?: string | null | undefined; status_message?: string | null | undefined; transactions_expected?: number | null | undefined; transactions_found?: number | null | undefined; transactions_missing?: number | null | undefined; }>; /** * SAMs are the chips that contain the keys used to sign APEX transactions. * They live in the validator machines and produce an incrementing counter value * every time a transaction is signed. This counter value is used to ensure that * the transactions are real, unique and incremental. This allows the system to * detect if a transaction has been tampered with or if any transactions are missing. */ export interface UniqueSam extends Omit<z.infer<typeof UniqueSamSchema>, 'created_at' | 'seen_first_at' | 'seen_last_at' | 'updated_at'> { created_at: UnixTimestamp; seen_first_at: null | UnixTimestamp; seen_last_at: null | UnixTimestamp; updated_at: UnixTimestamp; } export interface CreateUniqueSamDto extends Omit<z.infer<typeof CreateUniqueSamSchema>, 'seen_first_at' | 'seen_last_at'> { seen_first_at: null | UnixTimestamp; seen_last_at: null | UnixTimestamp; } export type UpdateUniqueSamDto = Partial<CreateUniqueSamDto>;