Implement ClientUser based on a new concept
Create a new mutable ClientEntity type and implement ClientUser on top of it. The mutable concept is intended to replace the immutable concept used by the ClientSchedule entities as updating immutable types in a deep interconnected structure is a lot of hassle for little benefit.
This commit is contained in:
parent
ebf7bdcc9c
commit
5edea4dd72
2 changed files with 183 additions and 1 deletions
|
@ -1,9 +1,17 @@
|
|||
import { z } from "zod/v4-mini";
|
||||
import { defineEntity, idSchema, type Id } from "~/shared/types/common";
|
||||
|
||||
export const apiUserTypeSchema = z.union([
|
||||
z.literal("anonymous"),
|
||||
z.literal("regular"),
|
||||
z.literal("crew"),
|
||||
z.literal("admin"),
|
||||
])
|
||||
export type ApiUserType = z.infer<typeof apiUserTypeSchema>;
|
||||
|
||||
export interface ApiAccount {
|
||||
id: Id,
|
||||
type: "anonymous" | "regular" | "crew" | "admin",
|
||||
type: ApiUserType,
|
||||
/** Name of the account. Not present on anonymous accounts */
|
||||
name?: string,
|
||||
interestedEventIds?: number[],
|
||||
|
@ -96,6 +104,12 @@ export const apiScheduleSchema = defineEntity({
|
|||
});
|
||||
export type ApiSchedule = z.infer<typeof apiScheduleSchema>;
|
||||
|
||||
export const apiUserSchema = defineEntity({
|
||||
type: apiUserTypeSchema,
|
||||
name: z.optional(z.string()),
|
||||
});
|
||||
export type ApiUser = z.infer<typeof apiUserSchema>;
|
||||
|
||||
export interface ApiAccountUpdate {
|
||||
type: "account-update",
|
||||
data: ApiAccount,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue