mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 17:00:54 +01:00
* feat: add everyone group through seed * feat: add reserved group name check in group router actions * feat: improve user interface for everyone group * fix: reserved group alert is a server component * feat: add all users to everyone group * chore: update lockfile * fix: format issues * fix: lint issues * fix: lint format issues * test: add unit tests for everyone group * refactor: add codegen for documentation urls by sitemap * refactor: change group query to count * chore: remove migrations temporarily * chore: add migrations again * chore: add lint rule to prevent usage of raw documentation links * fix: format issues
34 lines
814 B
TypeScript
34 lines
814 B
TypeScript
import { z } from "zod";
|
|
|
|
import { everyoneGroup, groupPermissionKeys } from "@homarr/definitions";
|
|
|
|
import { byIdSchema } from "./common";
|
|
import { zodEnumFromArray } from "./enums";
|
|
|
|
const createSchema = z.object({
|
|
name: z
|
|
.string()
|
|
.trim()
|
|
.min(1)
|
|
.max(64)
|
|
.refine((value) => value !== everyoneGroup, {
|
|
message: "'everyone' is a reserved group name",
|
|
}),
|
|
});
|
|
|
|
const updateSchema = createSchema.merge(byIdSchema);
|
|
|
|
const savePermissionsSchema = z.object({
|
|
groupId: z.string(),
|
|
permissions: z.array(zodEnumFromArray(groupPermissionKeys)),
|
|
});
|
|
|
|
const groupUserSchema = z.object({ groupId: z.string(), userId: z.string() });
|
|
|
|
export const groupSchemas = {
|
|
create: createSchema,
|
|
update: updateSchema,
|
|
savePermissions: savePermissionsSchema,
|
|
groupUser: groupUserSchema,
|
|
};
|