You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
808 B
27 lines
808 B
import { z } from "zod";
|
|
|
|
export const userInfoConfigSchema = z.object({
|
|
includeEmail: z.boolean().default(true),
|
|
includeAvatar: z.boolean().default(true),
|
|
includeRole: z.boolean().default(true),
|
|
includeStatus: z.boolean().default(false),
|
|
includeCreatedAt: z.boolean().default(false),
|
|
});
|
|
|
|
export type UserInfoToolConfig = z.infer<typeof userInfoConfigSchema>;
|
|
|
|
export const DEFAULT_USER_INFO_CONFIG: UserInfoToolConfig = {
|
|
includeEmail: true,
|
|
includeAvatar: true,
|
|
includeRole: true,
|
|
includeStatus: false,
|
|
includeCreatedAt: false,
|
|
};
|
|
|
|
export function parseUserInfoConfig(raw: unknown): UserInfoToolConfig {
|
|
const parsed = userInfoConfigSchema.safeParse(raw);
|
|
if (!parsed.success) {
|
|
throw new Error(`Invalid user-info config: ${parsed.error.message}`);
|
|
}
|
|
return parsed.data;
|
|
}
|
|
|