UNPKG

@tmlmobilidade/types

Version:
270 lines (269 loc) • 9.13 kB
import { z } from 'zod'; export declare const CommentTypeSchema: z.ZodEnum<["field_changed", "note", "crud"]>; export type CommentType = z.infer<typeof CommentTypeSchema>; export declare const CrudCommentSchemaActionSchema: z.ZodEnum<["create", "update", "delete", "archive", "restore"]>; export type CrudCommentSchemaAction = z.infer<typeof CrudCommentSchemaActionSchema>; export declare const NoteCommentSchema: z.ZodObject<{ _id: z.ZodOptional<z.ZodString>; created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; created_by: z.ZodOptional<z.ZodString>; updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; updated_by: z.ZodOptional<z.ZodString>; message: z.ZodString; type: z.ZodLiteral<"note">; }, "strip", z.ZodTypeAny, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; message: string; type: "note"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }, { created_at: number; updated_at: number; message: string; type: "note"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }>; export declare const FieldChangedCommentSchema: z.ZodObject<{ _id: z.ZodOptional<z.ZodString>; created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; created_by: z.ZodOptional<z.ZodString>; updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; updated_by: z.ZodOptional<z.ZodString>; type: z.ZodLiteral<"field_changed">; metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>; curr_value: z.ZodAny; field: z.ZodString; prev_value: z.ZodAny; }, "strip", z.ZodTypeAny, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; type: "field_changed"; field: string; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; metadata?: Record<string, unknown> | null | undefined; curr_value?: any; prev_value?: any; }, { created_at: number; updated_at: number; type: "field_changed"; field: string; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; metadata?: Record<string, unknown> | null | undefined; curr_value?: any; prev_value?: any; }>; export declare const CrudCommentSchema: z.ZodObject<{ _id: z.ZodOptional<z.ZodString>; created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; created_by: z.ZodOptional<z.ZodString>; updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; updated_by: z.ZodOptional<z.ZodString>; type: z.ZodLiteral<"crud">; action: z.ZodEnum<["create", "update", "delete", "archive", "restore"]>; }, "strip", z.ZodTypeAny, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; type: "crud"; action: "create" | "update" | "delete" | "archive" | "restore"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }, { created_at: number; updated_at: number; type: "crud"; action: "create" | "update" | "delete" | "archive" | "restore"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }>; export declare const CommentSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{ _id: z.ZodOptional<z.ZodString>; created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; created_by: z.ZodOptional<z.ZodString>; updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; updated_by: z.ZodOptional<z.ZodString>; message: z.ZodString; type: z.ZodLiteral<"note">; }, "strip", z.ZodTypeAny, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; message: string; type: "note"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }, { created_at: number; updated_at: number; message: string; type: "note"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }>, z.ZodObject<{ _id: z.ZodOptional<z.ZodString>; created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; created_by: z.ZodOptional<z.ZodString>; updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; updated_by: z.ZodOptional<z.ZodString>; type: z.ZodLiteral<"field_changed">; metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>; curr_value: z.ZodAny; field: z.ZodString; prev_value: z.ZodAny; }, "strip", z.ZodTypeAny, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; type: "field_changed"; field: string; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; metadata?: Record<string, unknown> | null | undefined; curr_value?: any; prev_value?: any; }, { created_at: number; updated_at: number; type: "field_changed"; field: string; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; metadata?: Record<string, unknown> | null | undefined; curr_value?: any; prev_value?: any; }>, z.ZodObject<{ _id: z.ZodOptional<z.ZodString>; created_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; created_by: z.ZodOptional<z.ZodString>; updated_at: z.ZodEffects<z.ZodNumber, import("./unix-timestamp.js").UnixTimestamp, number>; updated_by: z.ZodOptional<z.ZodString>; type: z.ZodLiteral<"crud">; action: z.ZodEnum<["create", "update", "delete", "archive", "restore"]>; }, "strip", z.ZodTypeAny, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; type: "crud"; action: "create" | "update" | "delete" | "archive" | "restore"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }, { created_at: number; updated_at: number; type: "crud"; action: "create" | "update" | "delete" | "archive" | "restore"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }>]>, { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; message: string; type: "note"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; } | { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; type: "field_changed"; field: string; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; metadata?: Record<string, unknown> | null | undefined; curr_value?: any; prev_value?: any; } | { created_at: number & { __brand: "UnixTimestamp"; }; updated_at: number & { __brand: "UnixTimestamp"; }; type: "crud"; action: "create" | "update" | "delete" | "archive" | "restore"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }, { created_at: number; updated_at: number; message: string; type: "note"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; } | { created_at: number; updated_at: number; type: "field_changed"; field: string; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; metadata?: Record<string, unknown> | null | undefined; curr_value?: any; prev_value?: any; } | { created_at: number; updated_at: number; type: "crud"; action: "create" | "update" | "delete" | "archive" | "restore"; _id?: string | undefined; created_by?: string | undefined; updated_by?: string | undefined; }>; export type Comment = z.infer<typeof CommentSchema>; export type NoteComment = z.infer<typeof NoteCommentSchema>; export type CrudComment = z.infer<typeof CrudCommentSchema>; export interface FieldChangedComment<T, K extends keyof T> extends Omit<z.infer<typeof FieldChangedCommentSchema>, 'curr_value' | 'field' | 'prev_value'> { curr_value: T[K]; field: K; prev_value: T[K]; }