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.

249 lines (248 loc) • 10.6 kB
import { type UnixTimestamp } from '../_common/unix-timestamp.js'; import { type Permission } from './permission.js'; import { z } from 'zod'; export declare const UserSchema: 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">>>; } & { avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>; bio: z.ZodOptional<z.ZodNullable<z.ZodString>>; email: z.ZodString; email_verified: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; first_name: z.ZodString; last_name: z.ZodString; organization_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; password_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>; permissions: z.ZodArray<z.ZodObject<{ action: z.ZodString; resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>; scope: z.ZodString; }, "strip", z.ZodTypeAny, { scope: string; action: string; resource?: Record<string, any> | null | undefined; }, { scope: string; action: string; resource?: Record<string, any> | null | undefined; }>, "many">; phone: z.ZodOptional<z.ZodNullable<z.ZodString>>; preferences: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>; role_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; session_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; theme_id: z.ZodOptional<z.ZodNullable<z.ZodString>>; verification_token_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; }, "strict", z.ZodTypeAny, { _id: string; email: string; permissions: { scope: string; action: string; resource?: Record<string, any> | null | undefined; }[]; first_name: string; last_name: string; organization_ids: string[]; role_ids: string[]; session_ids: string[]; verification_token_ids: string[]; created_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; updated_at?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; phone?: string | null | undefined; avatar?: string | null | undefined; bio?: string | null | undefined; email_verified?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; password_hash?: string | null | undefined; preferences?: Record<string, Record<string, any>> | null | undefined; theme_id?: string | null | undefined; }, { _id: string; email: string; permissions: { scope: string; action: string; resource?: Record<string, any> | null | undefined; }[]; first_name: string; last_name: string; created_at?: number | null | undefined; updated_at?: number | null | undefined; phone?: string | null | undefined; avatar?: string | null | undefined; bio?: string | null | undefined; email_verified?: number | null | undefined; organization_ids?: string[] | undefined; password_hash?: string | null | undefined; preferences?: Record<string, Record<string, any>> | null | undefined; role_ids?: string[] | undefined; session_ids?: string[] | undefined; theme_id?: string | null | undefined; verification_token_ids?: string[] | undefined; }>; export declare const CreateUserSchema: 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">>>; } & { avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>; bio: z.ZodOptional<z.ZodNullable<z.ZodString>>; email: z.ZodString; email_verified: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>; first_name: z.ZodString; last_name: z.ZodString; organization_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; password_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>; permissions: z.ZodArray<z.ZodObject<{ action: z.ZodString; resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>; scope: z.ZodString; }, "strip", z.ZodTypeAny, { scope: string; action: string; resource?: Record<string, any> | null | undefined; }, { scope: string; action: string; resource?: Record<string, any> | null | undefined; }>, "many">; phone: z.ZodOptional<z.ZodNullable<z.ZodString>>; preferences: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>; role_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; session_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; theme_id: z.ZodOptional<z.ZodNullable<z.ZodString>>; verification_token_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>; }, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, { email: string; permissions: { scope: string; action: string; resource?: Record<string, any> | null | undefined; }[]; first_name: string; last_name: string; organization_ids: string[]; role_ids: string[]; session_ids: string[]; verification_token_ids: string[]; phone?: string | null | undefined; avatar?: string | null | undefined; bio?: string | null | undefined; email_verified?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; password_hash?: string | null | undefined; preferences?: Record<string, Record<string, any>> | null | undefined; theme_id?: string | null | undefined; }, { email: string; permissions: { scope: string; action: string; resource?: Record<string, any> | null | undefined; }[]; first_name: string; last_name: string; phone?: string | null | undefined; avatar?: string | null | undefined; bio?: string | null | undefined; email_verified?: number | null | undefined; organization_ids?: string[] | undefined; password_hash?: string | null | undefined; preferences?: Record<string, Record<string, any>> | null | undefined; role_ids?: string[] | undefined; session_ids?: string[] | undefined; theme_id?: string | null | undefined; verification_token_ids?: string[] | undefined; }>; export declare const UpdateUserSchema: z.ZodObject<{ phone: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>; email: z.ZodOptional<z.ZodString>; permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{ action: z.ZodString; resource: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>; scope: z.ZodString; }, "strip", z.ZodTypeAny, { scope: string; action: string; resource?: Record<string, any> | null | undefined; }, { scope: string; action: string; resource?: Record<string, any> | null | undefined; }>, "many">>; avatar: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>; bio: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>; email_verified: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>; first_name: z.ZodOptional<z.ZodString>; last_name: z.ZodOptional<z.ZodString>; organization_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>; password_hash: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>; preferences: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>>>>>; role_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>; session_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>; theme_id: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>; verification_token_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>; }, "strict", z.ZodTypeAny, { phone?: string | null | undefined; email?: string | undefined; permissions?: { scope: string; action: string; resource?: Record<string, any> | null | undefined; }[] | undefined; avatar?: string | null | undefined; bio?: string | null | undefined; email_verified?: (number & { __brand: "UnixTimestamp"; } & z.BRAND<"UnixTimestamp">) | null | undefined; first_name?: string | undefined; last_name?: string | undefined; organization_ids?: string[] | undefined; password_hash?: string | null | undefined; preferences?: Record<string, Record<string, any>> | null | undefined; role_ids?: string[] | undefined; session_ids?: string[] | undefined; theme_id?: string | null | undefined; verification_token_ids?: string[] | undefined; }, { phone?: string | null | undefined; email?: string | undefined; permissions?: { scope: string; action: string; resource?: Record<string, any> | null | undefined; }[] | undefined; avatar?: string | null | undefined; bio?: string | null | undefined; email_verified?: number | null | undefined; first_name?: string | undefined; last_name?: string | undefined; organization_ids?: string[] | undefined; password_hash?: string | null | undefined; preferences?: Record<string, Record<string, any>> | null | undefined; role_ids?: string[] | undefined; session_ids?: string[] | undefined; theme_id?: string | null | undefined; verification_token_ids?: string[] | undefined; }>; export interface User extends Omit<z.infer<typeof UserSchema>, 'created_at' | 'email_verified' | 'permissions' | 'updated_at'> { created_at: UnixTimestamp; email_verified?: null | UnixTimestamp; permissions: Permission<unknown>[]; updated_at: UnixTimestamp; } export interface CreateUserDto extends Omit<z.infer<typeof CreateUserSchema>, 'created_at' | 'email_verified' | 'updated_at'> { created_at?: UnixTimestamp; email_verified?: null | UnixTimestamp; updated_at?: UnixTimestamp; } export type UpdateUserDto = Partial<CreateUserDto> & { password_hash?: string; };