-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsys-comment.object.ts
More file actions
160 lines (141 loc) · 4.4 KB
/
Copy pathsys-comment.object.ts
File metadata and controls
160 lines (141 loc) · 4.4 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* sys_comment — Threaded Record Comments
*
* Generic threaded discussion attached to any record via `thread_id`.
* `thread_id` is conventionally formatted as `{object}:{record_id}`
* (e.g. `sys_user:abc123`, `account:9001`) so a single index covers
* "all comments on this record" lookups across every object.
*
* Distinct from `feed_item` (Salesforce-style Chatter timeline that
* mixes comments with field changes / events / approvals). Use
* `sys_comment` when you want a focused threaded discussion surface
* without the heavier Chatter envelope.
*
* @namespace sys
*/
export const SysComment = ObjectSchema.create({
name: 'sys_comment',
label: 'Comment',
pluralLabel: 'Comments',
icon: 'message-square',
isSystem: true,
managedBy: 'platform',
description: 'Threaded comments attached to records via thread_id',
displayNameField: 'body',
nameField: 'body', // [ADR-0079] canonical primary-title pointer (mirrors deprecated displayNameField)
titleFormat: '{author_name}: {body}',
highlightFields: ['created_at', 'author_name', 'body'],
fields: {
id: Field.text({
label: 'Comment ID',
required: true,
readonly: true,
group: 'System',
}),
// ── Thread ───────────────────────────────────────────────────
thread_id: Field.text({
label: 'Thread',
required: true,
searchable: true,
maxLength: 255,
description:
'Thread identifier — conventionally `{object}:{record_id}` (e.g. `sys_user:abc123`)',
group: 'Thread',
}),
parent_id: Field.lookup('sys_comment', {
label: 'Parent Comment',
required: false,
description: 'Optional parent comment for nested replies',
group: 'Thread',
}),
reply_count: Field.number({
label: 'Reply Count',
defaultValue: 0,
readonly: true,
group: 'Thread',
}),
// ── Author ───────────────────────────────────────────────────
author_id: Field.lookup('sys_user', {
label: 'Author',
required: true,
searchable: true,
group: 'Author',
}),
author_name: Field.text({
label: 'Author Name',
required: false,
group: 'Author',
}),
author_avatar_url: Field.url({
label: 'Author Avatar',
required: false,
group: 'Author',
}),
// ── Body ─────────────────────────────────────────────────────
body: Field.textarea({
label: 'Body',
required: true,
searchable: true,
description: 'Comment text (Markdown supported)',
group: 'Body',
}),
mentions: Field.textarea({
label: 'Mentions',
required: false,
description: 'JSON array of @mention objects',
group: 'Body',
}),
reactions: Field.textarea({
label: 'Reactions',
required: false,
description: 'JSON array of emoji reaction objects',
group: 'Body',
}),
// ── Lifecycle ────────────────────────────────────────────────
is_edited: Field.boolean({
label: 'Edited',
defaultValue: false,
group: 'Lifecycle',
}),
edited_at: Field.datetime({
label: 'Edited At',
required: false,
group: 'Lifecycle',
}),
visibility: Field.select(
['public', 'internal', 'private'],
{
label: 'Visibility',
defaultValue: 'public',
group: 'Lifecycle',
},
),
created_at: Field.datetime({
label: 'Created At',
required: true,
defaultValue: 'NOW()',
readonly: true,
group: 'System',
}),
updated_at: Field.datetime({
label: 'Updated At',
required: false,
group: 'System',
}),
},
indexes: [
{ fields: ['thread_id', 'created_at'] },
{ fields: ['parent_id'] },
{ fields: ['author_id'] },
],
enable: {
trackHistory: true,
searchable: true,
apiEnabled: true,
trash: true,
mru: false,
clone: false,
},
});