mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(api): 🐛 Don't use null in Role properties
This commit is contained in:
parent
8f339669b5
commit
eb405d33cd
|
|
@ -24,11 +24,11 @@ export class Role extends BaseInterface<typeof Roles> {
|
||||||
public static schema = z.object({
|
public static schema = z.object({
|
||||||
id: z.string().uuid(),
|
id: z.string().uuid(),
|
||||||
name: z.string().min(1).max(128),
|
name: z.string().min(1).max(128),
|
||||||
permissions: z.array(z.nativeEnum(RolePermission)),
|
permissions: z.array(z.nativeEnum(RolePermission)).default([]),
|
||||||
priority: z.number().int(),
|
priority: z.number().int().default(0),
|
||||||
description: z.string().min(0).max(1024).nullable(),
|
description: z.string().min(0).max(1024).optional(),
|
||||||
visible: z.boolean(),
|
visible: z.boolean().default(true),
|
||||||
icon: z.string().url().nullable(),
|
icon: z.string().url().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
public static $type: RoleType;
|
public static $type: RoleType;
|
||||||
|
|
@ -225,9 +225,9 @@ export class Role extends BaseInterface<typeof Roles> {
|
||||||
name: this.data.name,
|
name: this.data.name,
|
||||||
permissions: this.data.permissions as unknown as RolePermission[],
|
permissions: this.data.permissions as unknown as RolePermission[],
|
||||||
priority: this.data.priority,
|
priority: this.data.priority,
|
||||||
description: this.data.description,
|
description: this.data.description ?? undefined,
|
||||||
visible: this.data.visible,
|
visible: this.data.visible,
|
||||||
icon: proxyUrl(this.data.icon),
|
icon: proxyUrl(this.data.icon) ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ type UserWithRelations = UserWithInstance & {
|
||||||
* Gives helpers to fetch users from database in a nice format
|
* Gives helpers to fetch users from database in a nice format
|
||||||
*/
|
*/
|
||||||
export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
|
// @ts-expect-error Roles are weird
|
||||||
public static schema: z.ZodType<ApiAccount> = z.object({
|
public static schema: z.ZodType<ApiAccount> = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
username: z.string(),
|
username: z.string(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue