refactor(api): extract system role config support
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { Prisma } from "@capakraken/db";
|
||||
import { z } from "zod";
|
||||
|
||||
export const systemRoleConfigUpdateInputSchema = z.object({
|
||||
role: z.string(),
|
||||
label: z.string().min(1).optional(),
|
||||
description: z.string().nullable().optional(),
|
||||
color: z.string().nullable().optional(),
|
||||
defaultPermissions: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
export type SystemRoleConfigUpdateInput = z.infer<typeof systemRoleConfigUpdateInputSchema>;
|
||||
|
||||
export function buildSystemRoleConfigUpdateData(
|
||||
input: SystemRoleConfigUpdateInput,
|
||||
): Prisma.SystemRoleConfigUpdateInput {
|
||||
return {
|
||||
...(input.label !== undefined ? { label: input.label } : {}),
|
||||
...(input.description !== undefined ? { description: input.description } : {}),
|
||||
...(input.color !== undefined ? { color: input.color } : {}),
|
||||
...(input.defaultPermissions !== undefined ? { defaultPermissions: input.defaultPermissions } : {}),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user