From 62836238f63688b45760929bdc2715f8f9991f2f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Jun 2022 16:33:08 +0200 Subject: move protocol.d.ts --- karlcommon/protocol.d.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ karld/protocol.d.ts | 60 ------------------------------------------------ 2 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 karlcommon/protocol.d.ts delete mode 100644 karld/protocol.d.ts diff --git a/karlcommon/protocol.d.ts b/karlcommon/protocol.d.ts new file mode 100644 index 0000000..f48b283 --- /dev/null +++ b/karlcommon/protocol.d.ts @@ -0,0 +1,60 @@ + +export type ServerboundPacket = Sync | Handshake | ListTasks | ListInstances | UpdateTask | RemoveTask +export type ClientboundPacket = Handshake | Error | TaskList | InstanceList | Sync + +export interface Sync { type: "sync", data: null } +export interface Error { type: "error", data: { kind: "unknown_task", details: null } | { kind: "format_error", details: string } } +export interface Handshake { type: "handshake", data: { version: string } } +export interface ListTasks { type: "list_tasks", data: null } +export interface TaskList { type: "task_list", data: Task[] } +export interface ListInstances { type: "list_instances", data: { task: number, range: Range } } +export interface InstanceList { type: "instance_list", data: Instance[] } +export interface UpdateTask { type: "update_task", data: Task } +export interface RemoveTask { type: "remove_task", data: number } + +export interface Instance { of: number, at: Range } + +export interface Range { start?: number, end?: number } + +export interface Task { + id: number + name: string, + description: string, + tags: string[], + schedule: Schedule +} + +export type Schedule = { type: "never" } + | { type: "static", options: Range } + | { type: "condition", options: Condition } + | { type: "dynamic", options: { priority: number, scheduled?: number, 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 } } + +export 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 } } + ] + +*/ diff --git a/karld/protocol.d.ts b/karld/protocol.d.ts deleted file mode 100644 index f48b283..0000000 --- a/karld/protocol.d.ts +++ /dev/null @@ -1,60 +0,0 @@ - -export type ServerboundPacket = Sync | Handshake | ListTasks | ListInstances | UpdateTask | RemoveTask -export type ClientboundPacket = Handshake | Error | TaskList | InstanceList | Sync - -export interface Sync { type: "sync", data: null } -export interface Error { type: "error", data: { kind: "unknown_task", details: null } | { kind: "format_error", details: string } } -export interface Handshake { type: "handshake", data: { version: string } } -export interface ListTasks { type: "list_tasks", data: null } -export interface TaskList { type: "task_list", data: Task[] } -export interface ListInstances { type: "list_instances", data: { task: number, range: Range } } -export interface InstanceList { type: "instance_list", data: Instance[] } -export interface UpdateTask { type: "update_task", data: Task } -export interface RemoveTask { type: "remove_task", data: number } - -export interface Instance { of: number, at: Range } - -export interface Range { start?: number, end?: number } - -export interface Task { - id: number - name: string, - description: string, - tags: string[], - schedule: Schedule -} - -export type Schedule = { type: "never" } - | { type: "static", options: Range } - | { type: "condition", options: Condition } - | { type: "dynamic", options: { priority: number, scheduled?: number, 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 } } - -export 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 } } - ] - -*/ -- cgit v1.2.3-70-g09d2