-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsys-activity.object.ts
More file actions
206 lines (187 loc) · 6.08 KB
/
Copy pathsys-activity.object.ts
File metadata and controls
206 lines (187 loc) · 6.08 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* sys_activity — Lightweight Activity Stream
*
* Append-only "recent activity" feed shown on dashboards / overview
* pages. Distinct from `sys_audit_log` (compliance-grade, structured
* before/after diffs) and `feed_item` (record-scoped Chatter timeline
* with comments/reactions/threads). Activity entries are denormalized
* snapshots optimized for chronological "what happened lately" reads.
*
* Typical write sources: data triggers, plugin events, UI actions.
* Typical readers: Studio dashboard, mobile inbox, notification jobs.
*
* @namespace sys
*/
export const SysActivity = ObjectSchema.create({
name: 'sys_activity',
label: 'Activity',
pluralLabel: 'Activities',
icon: 'activity',
isSystem: true,
managedBy: 'append-only',
description: 'Recent activity stream entries (lightweight, denormalized)',
displayNameField: 'summary',
nameField: 'summary', // [ADR-0079] canonical primary-title pointer (mirrors deprecated displayNameField)
titleFormat: '{type} · {summary}',
highlightFields: ['timestamp', 'type', 'actor_name', 'summary'],
fields: {
id: Field.text({
label: 'Activity ID',
required: true,
readonly: true,
group: 'System',
}),
timestamp: Field.datetime({
label: 'Timestamp',
required: true,
defaultValue: 'NOW()',
readonly: true,
group: 'Event',
}),
type: Field.select(
[
'created',
'updated',
'deleted',
'commented',
'mentioned',
'shared',
'assigned',
'completed',
'login',
'logout',
'system',
],
{
label: 'Type',
required: true,
readonly: true,
searchable: true,
group: 'Event',
},
),
summary: Field.text({
label: 'Summary',
required: true,
readonly: true,
maxLength: 500,
searchable: true,
description: 'Human-readable one-line summary',
group: 'Event',
}),
// ── Actor ───────────────────────────────────────────────────
actor_id: Field.lookup('sys_user', {
label: 'Actor',
required: false,
readonly: true,
searchable: true,
group: 'Actor',
}),
actor_name: Field.text({
label: 'Actor Name',
required: false,
readonly: true,
group: 'Actor',
}),
actor_avatar_url: Field.url({
label: 'Actor Avatar',
required: false,
readonly: true,
group: 'Actor',
}),
// ── Target ───────────────────────────────────────────────────
object_name: Field.text({
label: 'Object',
required: false,
readonly: true,
searchable: true,
maxLength: 255,
description: 'Target object short name (e.g. account, sys_user)',
group: 'Target',
}),
record_id: Field.text({
label: 'Record ID',
required: false,
readonly: true,
searchable: true,
group: 'Target',
}),
record_label: Field.text({
label: 'Record Label',
required: false,
readonly: true,
maxLength: 255,
description: 'Display label of the target record at write time',
group: 'Target',
}),
// ── Source pointer (ADR-0052 §5 — ActivityPointer model) ─────────
// `object_name`/`record_id` say WHICH record this activity belongs to (the
// "regarding" record, e.g. the contact). `source_object`/`source_id` point
// to the RICH ENTITY this activity was derived from — the email row in
// `sys_email`, the call/meeting in a task object, the `sys_comment` — so the
// timeline can drill from a one-line summary to the full record. This is the
// queryable, structured equivalent of cramming an id into `metadata`
// (cf. Dataverse ActivityPointer → Email/PhoneCall/Appointment subtypes,
// Salesforce ActivityTimeline → EmailMessage/Task/Event). Optional: most
// CRUD activities have no distinct source (the record IS the source).
source_object: Field.text({
label: 'Source Object',
required: false,
readonly: true,
searchable: true,
maxLength: 255,
description: 'Object name of the rich source entity this activity was derived from (e.g. "sys_email"). Null when the activity is about the target record itself.',
group: 'Target',
}),
source_id: Field.text({
label: 'Source ID',
required: false,
readonly: true,
searchable: true,
maxLength: 255,
description: 'Record id of the rich source entity (paired with source_object) — lets the timeline drill to the full email/call/meeting record.',
group: 'Target',
}),
url: Field.url({
label: 'URL',
required: false,
readonly: true,
description: 'Optional deep-link to the activity target',
group: 'Target',
}),
// ── Context ──────────────────────────────────────────────────
environment_id: Field.lookup('sys_environment', {
label: 'Environment',
required: false,
readonly: true,
searchable: true,
description: 'Environment context (multi-environment deployments)',
group: 'Context',
}),
metadata: Field.textarea({
label: 'Metadata',
required: false,
readonly: true,
description: 'JSON-serialized additional context',
group: 'Context',
}),
},
indexes: [
{ fields: ['timestamp'] },
{ fields: ['actor_id'] },
{ fields: ['object_name', 'record_id'] },
{ fields: ['type'] },
{ fields: ['environment_id'] },
],
enable: {
trackHistory: false,
searchable: true,
apiEnabled: true,
apiMethods: ['get', 'list'],
trash: false,
mru: false,
clone: false,
},
});