-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinbox-message.object.ts
More file actions
100 lines (87 loc) · 3.27 KB
/
Copy pathinbox-message.object.ts
File metadata and controls
100 lines (87 loc) · 3.27 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* `sys_inbox_message` — user-facing in-app notification rows (ADR-0012 §4, §11;
* ADR-0030 Layer 5).
*
* Written by the always-on `inbox` messaging channel, one row per
* `(notification, recipient)`, as the **materialization** of an L2
* `sys_notification` event delivered to the in-app channel. The Console bell
* pulls these (ADR-0030 re-points the bell here from `sys_notification`);
* `service-realtime` decides when to ping an online user. Belongs to
* `service-messaging` per the "protocol + service ownership" pattern.
*
* Read-state is **not** stored here — it lives in `sys_notification_receipt`
* (ADR-0030), so cross-channel read semantics stay reachable. `notification_id`
* links back to the event; `delivery_id` links to the outbox row (P1).
*/
export const InboxMessage = ObjectSchema.create({
name: 'sys_inbox_message',
label: 'Inbox Message',
pluralLabel: 'Inbox Messages',
icon: 'inbox',
description: 'User-facing in-app notification rows materialized by the inbox messaging channel.',
nameField: 'title', // [ADR-0079] canonical primary-title pointer (single-field titleFormat)
titleFormat: '{title}',
highlightFields: ['title', 'user_id', 'severity', 'created_at'],
listViews: {
mine: {
type: 'grid',
name: 'mine',
label: 'Notifications',
data: { provider: 'object', object: 'sys_inbox_message' },
columns: ['title', 'topic', 'severity', 'created_at'],
filter: [{ field: 'user_id', operator: 'equals', value: '{current_user_id}' }],
sort: [{ field: 'created_at', order: 'desc' }],
pagination: { pageSize: 50 },
emptyState: { title: 'Inbox zero', message: 'No notifications.' },
},
},
fields: {
id: Field.text({
label: 'Inbox Message ID',
required: true,
readonly: true,
}),
user_id: Field.text({
label: 'Recipient User',
required: true,
searchable: true,
}),
notification_id: Field.text({
label: 'Notification Event',
searchable: true,
description: 'FK → sys_notification (the L2 event this row materializes)',
}),
delivery_id: Field.text({
label: 'Delivery',
description: 'FK → sys_notification_delivery (outbox row); null until P1',
}),
topic: Field.text({
label: 'Topic',
searchable: true,
}),
title: Field.text({
label: 'Title',
required: true,
}),
body_md: Field.markdown({
label: 'Body',
}),
severity: Field.select({
label: 'Severity',
options: [
{ label: 'Info', value: 'info' },
{ label: 'Warning', value: 'warning' },
{ label: 'Critical', value: 'critical' },
],
}),
action_url: Field.text({
label: 'Action URL',
}),
created_at: Field.datetime({
label: 'Created At',
readonly: true,
}),
},
});