-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnotification-subscription.object.ts
More file actions
61 lines (53 loc) · 2.11 KB
/
Copy pathnotification-subscription.object.ts
File metadata and controls
61 lines (53 loc) · 2.11 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
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* `sys_notification_subscription` — who is subscribed to a topic (ADR-0030
* Layer 3).
*
* Declares standing interest in a `topic` by a `principal` (`role:x`, `team:x`,
* `user:id`, or a bare user id). Where a producer emits with `audience:
* 'subscribers'` (or no explicit audience), the resolver expands the topic's
* subscriptions into recipients — the opt-in counterpart to the explicit
* audience most producers pass today.
*
* Distinct from `sys_notification_preference`: a subscription says "include me
* for this topic"; a preference says "but mute it on this channel".
*
* Belongs to `service-messaging`.
*/
export const NotificationSubscription = ObjectSchema.create({
name: 'sys_notification_subscription',
label: 'Notification Subscription',
pluralLabel: 'Notification Subscriptions',
icon: 'rss',
isSystem: true,
managedBy: 'system',
description: 'Standing subscription of a principal (role/team/user) to a notification topic.',
titleFormat: '{principal} · {topic}',
highlightFields: ['topic', 'principal', 'enabled', 'created_at'],
fields: {
id: Field.text({ label: 'Subscription ID', required: true, readonly: true }),
topic: Field.text({
label: 'Topic',
required: true,
searchable: true,
description: 'Notification topic this principal subscribes to.',
}),
principal: Field.text({
label: 'Principal',
required: true,
searchable: true,
description: "Subscriber selector: 'role:x' | 'team:x' | 'user:id' | bare user id.",
}),
enabled: Field.boolean({
label: 'Enabled',
defaultValue: true,
description: 'When false, the subscription is inactive.',
}),
created_at: Field.datetime({ label: 'Created At', readonly: true }),
},
indexes: [
{ fields: ['topic', 'principal'], unique: true },
{ fields: ['topic'] },
],
});