-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtask.object.ts
More file actions
211 lines (184 loc) · 5.79 KB
/
Copy pathtask.object.ts
File metadata and controls
211 lines (184 loc) · 5.79 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import { P, tmpl } from '@objectstack/spec';
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
export const Task = ObjectSchema.create({
name: 'todo_task',
label: 'Task',
pluralLabel: 'Tasks',
icon: 'check-square',
description: 'Personal tasks and to-do items',
fields: {
// Task Information
subject: Field.text({
label: 'Subject',
required: true,
searchable: true,
maxLength: 255,
}),
description: Field.markdown({
label: 'Description',
}),
// Task Management
status: Field.select({
label: 'Status',
required: true,
options: [
{ label: 'Not Started', value: 'not_started', color: '#808080', default: true },
{ label: 'In Progress', value: 'in_progress', color: '#3B82F6' },
{ label: 'Waiting', value: 'waiting', color: '#F59E0B' },
{ label: 'Completed', value: 'completed', color: '#10B981' },
{ label: 'Deferred', value: 'deferred', color: '#6B7280' },
]
}),
priority: Field.select({
label: 'Priority',
required: true,
options: [
{ label: 'Low', value: 'low', color: '#60A5FA', default: true },
{ label: 'Normal', value: 'normal', color: '#10B981' },
{ label: 'High', value: 'high', color: '#F59E0B' },
{ label: 'Urgent', value: 'urgent', color: '#EF4444' },
]
}),
category: Field.select({
label: 'Category',
options: [
{ label: 'Personal', value: 'personal' },
{ label: 'Work', value: 'work' },
{ label: 'Shopping', value: 'shopping' },
{ label: 'Health', value: 'health' },
{ label: 'Finance', value: 'finance' },
{ label: 'Other', value: 'other' },
]
}),
// Dates
due_date: Field.date({
label: 'Due Date',
}),
reminder_date: Field.datetime({
label: 'Reminder Date/Time',
}),
completed_date: Field.datetime({
label: 'Completed Date',
readonly: true,
}),
// Assignment — the platform user object is `sys_user` (better-auth managed);
// `user` is not a registered object/table, so the old reference resolved to
// a non-existent `user` table at seed/lookup time ("no such table: user").
owner: Field.lookup('sys_user', {
label: 'Assigned To',
}),
// Tags
tags: Field.select({
label: 'Tags',
multiple: true,
options: [
{ label: 'Important', value: 'important', color: '#EF4444' },
{ label: 'Quick Win', value: 'quick_win', color: '#10B981' },
{ label: 'Blocked', value: 'blocked', color: '#F59E0B' },
{ label: 'Follow Up', value: 'follow_up', color: '#3B82F6' },
{ label: 'Review', value: 'review', color: '#8B5CF6' },
]
}),
// Recurrence
is_recurring: Field.boolean({
label: 'Recurring Task',
defaultValue: false,
}),
recurrence_type: Field.select({
label: 'Recurrence Type',
options: [
{ label: 'Daily', value: 'daily' },
{ label: 'Weekly', value: 'weekly' },
{ label: 'Monthly', value: 'monthly' },
{ label: 'Yearly', value: 'yearly' },
]
}),
recurrence_interval: Field.number({
label: 'Recurrence Interval',
defaultValue: 1,
min: 1,
}),
// Flags
is_completed: Field.boolean({
label: 'Is Completed',
defaultValue: false,
readonly: true,
}),
is_overdue: Field.boolean({
label: 'Is Overdue',
defaultValue: false,
readonly: true,
}),
// Progress
progress_percent: Field.percent({
label: 'Progress (%)',
min: 0,
max: 100,
defaultValue: 0,
}),
// Time Tracking
estimated_hours: Field.number({
label: 'Estimated Hours',
scale: 2,
min: 0,
}),
actual_hours: Field.number({
label: 'Actual Hours',
scale: 2,
min: 0,
}),
// Additional fields
notes: Field.richtext({
label: 'Notes',
description: 'Rich text notes with formatting',
}),
category_color: Field.color({
label: 'Category Color',
}),
},
enable: {
trackHistory: true,
searchable: true,
apiEnabled: true,
files: true,
feeds: true,
activities: true,
trash: true,
mru: true,
},
// Database indexes for performance
indexes: [
{ fields: ['status'] },
{ fields: ['priority'] },
{ fields: ['owner'] },
{ fields: ['due_date'] },
{ fields: ['category'] },
],
titleFormat: tmpl`{{record.subject}}`,
compactLayout: ['subject', 'status', 'priority', 'due_date', 'owner'],
validations: [
{
name: 'completed_date_required',
type: 'script',
severity: 'error',
message: 'Completed date is required when status is Completed',
condition: P`record.status == "completed" && isBlank(record.completed_date)`,
},
{
name: 'recurrence_fields_required',
type: 'script',
severity: 'error',
message: 'Recurrence type is required for recurring tasks',
condition: P`record.is_recurring == true && isBlank(record.recurrence_type)`,
},
],
// NOTE (#1535): object-level `workflows[]` is NOT a supported ObjectSchema
// field — it was silently stripped at build and never ran (ADR-0032 "no
// silent failure"). Record-triggered automation for this object lives in the
// supported mechanisms instead:
// • `task.hook.ts` — lifecycle hook (defaults, completion logic)
// • `actions/task.handlers.ts` — stamps `completed_date` on completion
// • `flows/task.flow.ts` — record_change + schedule flows (completion /
// recurrence, reminders, overdue escalation)
});