@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.
526 lines (525 loc) • 20.1 kB
TypeScript
import { type UnixTimestamp } from './_common/unix-timestamp.js';
import { z } from 'zod';
export declare const PermissionSchema: 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;
}>;
export interface Permission<T> {
action: string;
resource?: Partial<Record<keyof T, T[keyof T]>>;
scope: string;
}
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>>;
role_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
session_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
verification_token_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
}, "strict", z.ZodTypeAny, {
_id: string;
email: string;
first_name: string;
last_name: string;
organization_ids: string[];
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
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;
}, {
_id: string;
email: string;
first_name: string;
last_name: string;
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
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;
role_ids?: string[] | undefined;
session_ids?: string[] | 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>>;
role_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
session_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
verification_token_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
}, "_id" | "created_at" | "updated_at" | "password_hash">, "strict", z.ZodTypeAny, {
email: string;
first_name: string;
last_name: string;
organization_ids: string[];
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
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;
}, {
email: string;
first_name: string;
last_name: string;
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
phone?: string | null | undefined;
avatar?: string | null | undefined;
bio?: string | null | undefined;
email_verified?: number | null | undefined;
organization_ids?: string[] | undefined;
role_ids?: string[] | undefined;
session_ids?: string[] | undefined;
verification_token_ids?: string[] | undefined;
}>;
export declare const UpdateUserSchema: z.ZodObject<{
email: z.ZodOptional<z.ZodString>;
phone: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
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">>>;
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">>;
role_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
session_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
verification_token_ids: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
password_hash: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
email?: string | undefined;
phone?: string | null | 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 | undefined;
permissions?: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[] | undefined;
role_ids?: string[] | undefined;
session_ids?: string[] | undefined;
verification_token_ids?: string[] | undefined;
}, {
email?: string | undefined;
phone?: string | null | 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 | undefined;
permissions?: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[] | undefined;
role_ids?: string[] | undefined;
session_ids?: string[] | undefined;
verification_token_ids?: string[] | undefined;
}>;
export interface User extends Omit<z.infer<typeof UserSchema>, 'created_at' | 'email_verified' | 'updated_at'> {
created_at: UnixTimestamp;
email_verified?: null | UnixTimestamp;
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;
};
export declare const LoginDtoSchema: z.ZodObject<{
email: z.ZodString;
password: z.ZodString;
}, "strict", z.ZodTypeAny, {
email: string;
password: string;
}, {
email: string;
password: string;
}>;
export type LoginDto = z.infer<typeof LoginDtoSchema>;
export declare const PasswordRequirementsSchema: z.ZodEffects<z.ZodObject<{
password: z.ZodString;
}, "strip", z.ZodTypeAny, {
password: string;
}, {
password: string;
}>, {
password: string;
}, {
password: string;
}>;
export type PasswordRequirements = z.infer<typeof PasswordRequirementsSchema>;
export declare const RoleSchema: 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">>>;
} & {
name: 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">;
}, "strict", z.ZodTypeAny, {
_id: string;
name: string;
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
created_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
updated_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
}, {
_id: string;
name: string;
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
created_at?: number | null | undefined;
updated_at?: number | null | undefined;
}>;
export declare const CreateRoleSchema: 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">>>;
} & {
name: 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">;
}, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
name: string;
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
}, {
name: string;
permissions: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[];
}>;
export declare const UpdateRoleSchema: z.ZodObject<{
name: 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">>;
}, "strict", z.ZodTypeAny, {
name?: string | undefined;
permissions?: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[] | undefined;
}, {
name?: string | undefined;
permissions?: {
scope: string;
action: string;
resource?: Record<string, any> | null | undefined;
}[] | undefined;
}>;
export interface Role extends Omit<z.infer<typeof RoleSchema>, 'created_at' | 'updated_at'> {
created_at: UnixTimestamp;
updated_at: UnixTimestamp;
}
export type CreateRoleDto = z.infer<typeof CreateRoleSchema>;
export type UpdateRoleDto = Partial<CreateRoleDto>;
export declare const VerificationTokenSchema: 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">>>;
} & {
expires_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
token: z.ZodString;
user_id: z.ZodString;
}, "strict", z.ZodTypeAny, {
_id: string;
user_id: string;
expires_at: number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">;
token: string;
created_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
updated_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
}, {
_id: string;
user_id: string;
expires_at: number;
token: string;
created_at?: number | null | undefined;
updated_at?: number | null | undefined;
}>;
export declare const CreateVerificationTokenSchema: 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">>>;
} & {
expires_at: z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">;
token: z.ZodString;
user_id: z.ZodString;
}, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
user_id: string;
expires_at: number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">;
token: string;
}, {
user_id: string;
expires_at: number;
token: string;
}>;
export declare const UpdateVerificationTokenSchema: z.ZodObject<{
user_id: z.ZodOptional<z.ZodString>;
expires_at: z.ZodOptional<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>;
token: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
user_id?: string | undefined;
expires_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | undefined;
token?: string | undefined;
}, {
user_id?: string | undefined;
expires_at?: number | undefined;
token?: string | undefined;
}>;
export interface VerificationToken extends Omit<z.infer<typeof VerificationTokenSchema>, 'created_at' | 'expires_at' | 'updated_at'> {
created_at: UnixTimestamp;
expires_at: UnixTimestamp;
updated_at: UnixTimestamp;
}
export type CreateVerificationTokenDto = Omit<z.infer<typeof CreateVerificationTokenSchema>, 'expires_at'> & {
expires_at: UnixTimestamp;
};
export type UpdateVerificationTokenDto = Partial<CreateVerificationTokenDto>;
export declare const SessionSchema: 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">>>;
} & {
expires_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
token: z.ZodString;
user_id: z.ZodString;
}, "strict", z.ZodTypeAny, {
_id: string;
user_id: string;
token: string;
created_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
updated_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
expires_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
}, {
_id: string;
user_id: string;
token: string;
created_at?: number | null | undefined;
updated_at?: number | null | undefined;
expires_at?: number | null | undefined;
}>;
export declare const CreateSessionSchema: 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">>>;
} & {
expires_at: z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>;
token: z.ZodString;
user_id: z.ZodString;
}, "_id" | "created_at" | "updated_at">, "strict", z.ZodTypeAny, {
user_id: string;
token: string;
expires_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
}, {
user_id: string;
token: string;
expires_at?: number | null | undefined;
}>;
export declare const UpdateSessionSchema: z.ZodObject<{
user_id: z.ZodOptional<z.ZodString>;
expires_at: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodBranded<z.ZodEffects<z.ZodNumber, UnixTimestamp, number>, "UnixTimestamp">>>>;
token: z.ZodOptional<z.ZodString>;
}, "strict", z.ZodTypeAny, {
user_id?: string | undefined;
expires_at?: (number & {
__brand: "UnixTimestamp";
} & z.BRAND<"UnixTimestamp">) | null | undefined;
token?: string | undefined;
}, {
user_id?: string | undefined;
expires_at?: number | null | undefined;
token?: string | undefined;
}>;
export interface Session extends Omit<z.infer<typeof SessionSchema>, 'created_at' | 'expires_at' | 'updated_at'> {
created_at: UnixTimestamp;
expires_at?: UnixTimestamp;
updated_at: UnixTimestamp;
}
export interface CreateSessionDto extends Omit<z.infer<typeof CreateSessionSchema>, 'expires_at'> {
expires_at?: UnixTimestamp;
}
export type UpdateSessionDto = Partial<CreateSessionDto>;