export type ServerboundPacket = Sync | Handshake | ListTasks | ListInstances | UpdateTask | RemoveTask export type ClientboundPacket = Handshake | Error | TaskList | InstanceList | Sync interface Sync { type: "sync", data: null } interface Error { type: "error", data: { kind: "unknown_task", details: null } | { kind: "format_error", details: string } } interface Handshake { type: "handshake", data: { version: string } } interface ListTasks { type: "list_tasks", data: null } interface TaskList { type: "task_list", data: Task[] } interface ListInstances { type: "list_instances", data: null } interface InstanceList { type: "instance_list", data: Instance[] } interface UpdateTask { type: "update_task", data: Task } interface RemoveTask { type: "remove_task", data: number } interface Instance { of: number, at: Range } interface Range { start?: number, end?: number } interface Task { id: number name: string, description: string, tags: string[], priority: number, completed?: number, scheduled?: number, occurence?: Condition, deadline?: Condition, } export type Condition = { from?: Condition } | { or?: Condition[] } | { and?: Condition[] } | { equal?: { prop: Thing, value: number, mod?: number } } | { range?: { prop: Thing, min: number, max: number, mod?: number } } type Thing = "year" | "monthofyear" | "weekofmonth" | "dayofyear" | "dayofmonth" | "dayofweek" | "hour" | "minute" | "second" | "unix" /* examples: 11:00 - 12:00 every first monday of the month and: [ { range: { prop: "hour", min: 11, max: 12 } }, { equal: { prop: "dayofweek", value: 0 } }, { equal: { prop: "weekofmonth", value: 0 } } ] */