-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsys-presence.object.ts
More file actions
119 lines (104 loc) · 2.75 KB
/
sys-presence.object.ts
File metadata and controls
119 lines (104 loc) · 2.75 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* sys_presence — System Presence Object
*
* Tracks real-time user presence and activity across the platform.
* Fields align with the PresenceStateSchema protocol definition
* from `@objectstack/spec/api` (websocket.zod.ts).
*
* Owned by `service-realtime` as the canonical Presence domain object.
*
* @namespace sys
* @see PresenceStateSchema in packages/spec/src/api/websocket.zod.ts
*/
export const SysPresence = ObjectSchema.create({
namespace: 'sys',
name: 'presence',
label: 'Presence',
pluralLabel: 'Presences',
icon: 'wifi',
isSystem: true,
description: 'Real-time user presence and activity tracking',
titleFormat: '{user_id} ({status})',
compactLayout: ['user_id', 'status', 'last_seen'],
fields: {
id: Field.text({
label: 'Presence ID',
required: true,
readonly: true,
}),
created_at: Field.datetime({
label: 'Created At',
defaultValue: 'NOW()',
readonly: true,
}),
updated_at: Field.datetime({
label: 'Updated At',
defaultValue: 'NOW()',
readonly: true,
}),
user_id: Field.text({
label: 'User ID',
required: true,
searchable: true,
}),
session_id: Field.text({
label: 'Session ID',
required: true,
}),
status: Field.select({
label: 'Status',
required: true,
defaultValue: 'online',
options: [
{ value: 'online', label: 'Online' },
{ value: 'away', label: 'Away' },
{ value: 'busy', label: 'Busy' },
{ value: 'offline', label: 'Offline' },
],
}),
last_seen: Field.datetime({
label: 'Last Seen',
required: true,
defaultValue: 'NOW()',
}),
current_location: Field.text({
label: 'Current Location',
required: false,
maxLength: 500,
}),
device: Field.select({
label: 'Device',
required: false,
options: [
{ value: 'desktop', label: 'Desktop' },
{ value: 'mobile', label: 'Mobile' },
{ value: 'tablet', label: 'Tablet' },
{ value: 'other', label: 'Other' },
],
}),
custom_status: Field.text({
label: 'Custom Status',
required: false,
maxLength: 255,
}),
metadata: Field.textarea({
label: 'Metadata',
required: false,
}),
},
indexes: [
{ fields: ['user_id'], unique: false },
{ fields: ['session_id'], unique: true },
{ fields: ['status'], unique: false },
],
enable: {
trackHistory: false,
searchable: false,
apiEnabled: true,
apiMethods: ['get', 'list', 'create', 'update', 'delete'],
trash: false,
mru: false,
},
});