-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.ts
109 lines (88 loc) · 2.6 KB
/
entry.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { Type, Static } from '@sinclair/typebox'
import { TypeCompiler } from '@sinclair/typebox/compiler'
import { randomUUID } from 'crypto'
export enum StatusNames {
Capture = 'Capture',
Draft = 'Draft',
Rework = 'Rework',
Clarify = 'Clarify',
Incubate = 'Incubate',
Backlog = 'Backlog',
Icebox = 'Icebox',
Ready = 'Ready',
Next = 'Next',
Started = 'Started',
Check = 'Check',
Done = 'Done',
Reflect = 'Reflect',
Stalled = 'Stalled',
Aborted = 'Aborted',
Archive = 'Archive',
Deleted = 'Deleted',
}
export enum EntryTypes {
Transient = 'Transient',
Note = 'Note',
Area = 'Area',
Objective = 'Objective',
Project = 'Project',
Task = 'Task',
}
export enum Priority {
NONE = 0,
LOW = 1,
MED = 2,
HIGH = 3,
VERY = 4,
MAX = 5
}
export const Default = {
date: () => new Date,
id: 1,
path: '/',
uid: () => randomUUID().slice(0,8)
}
// TODO
// define:
// TAG
// REFERENCE
// UID
// PATH
// URI
// DATE(fmt)
// EntryUpdate (compose)
export const Entry = Type.Object({
id: Type.Number(), // required
uid: Type.String(), // required
path: Type.String(), // required
type: Type.String({ default: EntryTypes.Transient }),
status: Type.String({ default: StatusNames.Capture }),
position: Type.Number({ default: 1}),
text: Type.String(),
uri: Type.Optional(Type.String()),
tags: Type.Array(Type.String(), { default: [] }), // TODO
meta: Type.Array(Type.String(), { default: [] }), // TODO
priority: Type.Optional(Type.Enum(Priority)),
// urgency -- compute at runtime
// urgency: Type.Optional(Type.Number({ default: 1.0 })),
depends: Type.Array(Type.String(), { default: [] }), // TODO
parents: Type.Array(Type.String(), { default: [] }), // TODO
recur: Type.Array(Type.String(), { default: [] }), // TODO
repeat: Type.Array(Type.String(), { default: [] }), // TODO
review: Type.Array(Type.String(), { default: [] }), // TODO
// when now > cron, needs processing for recurrence etc
cron: Type.Optional(Type.Date()),
due: Type.Optional(Type.Date()),
end: Type.Optional(Type.Date()),
scheduled: Type.Optional(Type.Date()),
until: Type.Optional(Type.Date()),
wait: Type.Optional(Type.Date()),
start: Type.Optional(Type.Date()),
reviewed: Type.Optional(Type.Date()),
created: Type.Date(),
modified: Type.Optional(Type.Date()),
})
export type Entry = Static<typeof Entry>
// this is expensive
// TODO benchmark
export const C = TypeCompiler.Compile(Entry)