@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.
117 lines (116 loc) • 4.02 kB
TypeScript
import { type UnixTimestamp } from '../_common/unix-timestamp.js';
import { z } from 'zod';
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>;