37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const registerRequestSchema = z.object({
|
|
email: z.string().trim().email().max(254),
|
|
password: z.string().min(1),
|
|
password_confirmation: z.string().min(1),
|
|
display_name: z.string().trim().max(80).nullable().optional(),
|
|
});
|
|
export const loginRequestSchema = z.object({
|
|
email: z.string().trim().email().max(254),
|
|
password: z.string().min(1),
|
|
});
|
|
|
|
export const authUserSchema = z.object({
|
|
id: z.uuid(),
|
|
email: z.string().email(),
|
|
display_name: z.string().nullable(),
|
|
email_verified_at: z.iso.datetime().nullable(),
|
|
created_at: z.iso.datetime(),
|
|
});
|
|
export const workspaceSchema = z.object({
|
|
id: z.uuid(),
|
|
name: z.string(),
|
|
role: z.enum(['owner', 'admin', 'editor', 'viewer']),
|
|
});
|
|
export const authSessionResponseSchema = z.object({
|
|
access_token: z.string(),
|
|
access_token_expires_in: z.number().int().positive(),
|
|
user: authUserSchema,
|
|
workspace: workspaceSchema,
|
|
});
|
|
export type RegisterRequest = z.infer<typeof registerRequestSchema>;
|
|
export type LoginRequest = z.infer<typeof loginRequestSchema>;
|
|
export type AuthUser = z.infer<typeof authUserSchema>;
|
|
export type Workspace = z.infer<typeof workspaceSchema>;
|
|
export type AuthSessionResponse = z.infer<typeof authSessionResponseSchema>;
|