|
| 1 | +/** |
| 2 | + * Subscription service types — request/response shapes for user subscription preferences. |
| 3 | + */ |
| 4 | + |
| 5 | +import { NotificationCategory, NotificationMode } from './notifications.types'; |
| 6 | + |
| 7 | +/** |
| 8 | + * Status of a notification mode (channel) for a publisher — whether the user has |
| 9 | + * activated this channel. |
| 10 | + */ |
| 11 | +export interface AllowedMode { |
| 12 | + /** Notification channel. */ |
| 13 | + name: NotificationMode; |
| 14 | + /** Whether the user has activated this channel for the publisher. */ |
| 15 | + isActive: boolean; |
| 16 | +} |
| 17 | + |
| 18 | +/** |
| 19 | + * Per-mode subscription state for a topic. |
| 20 | + */ |
| 21 | +export interface SubscriptionMode { |
| 22 | + /** Notification channel. */ |
| 23 | + name: NotificationMode; |
| 24 | + /** Whether the user is subscribed to this topic via this channel. */ |
| 25 | + isSubscribed: boolean; |
| 26 | + /** Whether the topic is subscribed by default via this channel. */ |
| 27 | + isSubscribedByDefault: boolean; |
| 28 | +} |
| 29 | + |
| 30 | +/** |
| 31 | + * Base topic shape — identity/discovery fields only, with no subscription state. |
| 32 | + */ |
| 33 | +export interface SubscriptionTopicBase { |
| 34 | + /** Topic GUID. */ |
| 35 | + id: string; |
| 36 | + /** Stable topic identifier (e.g. `Process.JobExecution.Faulted`). */ |
| 37 | + name: string; |
| 38 | + /** Human-readable topic name. */ |
| 39 | + displayName: string | null; |
| 40 | + /** Topic description. */ |
| 41 | + description: string | null; |
| 42 | + /** Topic group name. */ |
| 43 | + group: string | null; |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * A topic that the user can subscribe to, with full subscription state — as returned by `getAll()`. |
| 48 | + */ |
| 49 | +export interface SubscriptionTopic extends SubscriptionTopicBase { |
| 50 | + /** Severity category. Only populated on `getAll()`. */ |
| 51 | + category?: NotificationCategory; |
| 52 | + /** Parent topic group name. Often `null`. */ |
| 53 | + parentGroup?: string | null; |
| 54 | + /** Whether the user is currently subscribed to this topic. Only populated on `getAll()`. */ |
| 55 | + isSubscribed?: boolean; |
| 56 | + /** Whether the topic is mandatory — cannot be unsubscribed. Only populated on `getAll()`. */ |
| 57 | + isMandatory?: boolean; |
| 58 | + /** Whether the topic should be visible in the user-facing subscription UI. */ |
| 59 | + isVisible?: boolean; |
| 60 | + /** Whether the topic is subscribed by default for new users. */ |
| 61 | + isDefault?: boolean; |
| 62 | + /** Whether notifications for this topic can be batched. */ |
| 63 | + isAllowedToBeDispatchedInBatch?: boolean; |
| 64 | + /** Whether the topic is marked as infrequent (lower-priority delivery). */ |
| 65 | + isInfrequent?: boolean; |
| 66 | + /** Number of days notifications for this topic are retained. */ |
| 67 | + retentionDays?: number; |
| 68 | + /** Display ordering hint. */ |
| 69 | + orderingSequence?: number; |
| 70 | + /** Per-channel subscription state. Only populated on `getAll()`. */ |
| 71 | + modes?: SubscriptionMode[]; |
| 72 | +} |
| 73 | + |
| 74 | +/** |
| 75 | + * An entity reference used in publisher / topic-group subscription requests. |
| 76 | + */ |
| 77 | +export interface SubscriptionEntity { |
| 78 | + /** Entity GUID. */ |
| 79 | + id?: string; |
| 80 | + /** Entity name. */ |
| 81 | + name?: string; |
| 82 | + /** Entity type. */ |
| 83 | + type?: string; |
| 84 | + /** Parent name (e.g. folder name for a sub-folder). */ |
| 85 | + parentName?: string; |
| 86 | + /** Whether the user is subscribed to notifications for this entity. */ |
| 87 | + isSubscribed?: boolean; |
| 88 | +} |
| 89 | + |
| 90 | +/** |
| 91 | + * Group of entities that belong to a topic group. |
| 92 | + */ |
| 93 | +export interface TopicGroupEntity { |
| 94 | + /** Topic group name. */ |
| 95 | + name?: string; |
| 96 | + /** Entities belonging to this group. */ |
| 97 | + entities?: SubscriptionEntity[]; |
| 98 | +} |
| 99 | + |
| 100 | +/** |
| 101 | + * Entity types supported by a topic group. |
| 102 | + */ |
| 103 | +export interface TopicGroupEntityType { |
| 104 | + /** Topic group name. */ |
| 105 | + name?: string; |
| 106 | + /** Entity type names. */ |
| 107 | + entityTypes?: string[]; |
| 108 | +} |
| 109 | + |
| 110 | +/** |
| 111 | + * Base publisher shape — identity/discovery fields and the topic catalogue, with no subscription state. |
| 112 | + */ |
| 113 | +export interface SubscriptionPublisherBase { |
| 114 | + /** Publisher GUID. */ |
| 115 | + id: string; |
| 116 | + /** Stable publisher name (e.g. `Orchestrator`, `Actions`). */ |
| 117 | + name: string; |
| 118 | + /** Human-readable publisher name. */ |
| 119 | + displayName: string | null; |
| 120 | + /** Topics published under this publisher. */ |
| 121 | + topics: SubscriptionTopicBase[]; |
| 122 | +} |
| 123 | + |
| 124 | +/** |
| 125 | + * A publisher with its topics, channels, and subscription state — as returned by `getAll()`. |
| 126 | + */ |
| 127 | +export interface SubscriptionPublisher extends SubscriptionPublisherBase { |
| 128 | + /** Topics published under this publisher, with full per-topic subscription state. */ |
| 129 | + topics: SubscriptionTopic[]; |
| 130 | + /** URL to navigate to when a publisher notification is clicked. */ |
| 131 | + redirectionUrl?: string | null; |
| 132 | + /** Number of days notifications from this publisher are retained. */ |
| 133 | + retentionDays?: number; |
| 134 | + /** Whether notifications from this publisher are included in summary digests. */ |
| 135 | + addToSummary?: boolean; |
| 136 | + /** Whether the user has opted in to receive notifications from this publisher. */ |
| 137 | + isUserOptin?: boolean; |
| 138 | + /** Channels available for this publisher and their activation state. */ |
| 139 | + modes?: AllowedMode[]; |
| 140 | + /** Entities (e.g. folders) that the publisher exposes. */ |
| 141 | + entities?: SubscriptionEntity[]; |
| 142 | + /** Entity types the publisher exposes. */ |
| 143 | + entityTypes?: string[]; |
| 144 | + /** Topic-group entity sets. */ |
| 145 | + topicGroupEntities?: TopicGroupEntity[]; |
| 146 | + /** Topic-group entity types. */ |
| 147 | + topicGroupEntityTypes?: TopicGroupEntityType[]; |
| 148 | +} |
| 149 | + |
| 150 | +/** |
| 151 | + * Channel availability returned by `getSupportedChannels()`. |
| 152 | + * |
| 153 | + * Note: `InApp` is never returned — it is always implicitly available. |
| 154 | + */ |
| 155 | +export interface SupportedChannel { |
| 156 | + /** Notification channel. */ |
| 157 | + name: NotificationMode; |
| 158 | + /** Whether the channel is enabled for the current tenant. */ |
| 159 | + isEnabled: boolean; |
| 160 | +} |
| 161 | + |
| 162 | +/** |
| 163 | + * Options for `Subscriptions.getAll()`. |
| 164 | + */ |
| 165 | +export interface SubscriptionGetAllOptions { |
| 166 | + /** Filter to specific publisher names. When omitted, all publishers are returned. */ |
| 167 | + publishers?: string[]; |
| 168 | +} |
| 169 | + |
| 170 | +/** |
| 171 | + * Options for `Subscriptions.getPublishers()`. |
| 172 | + */ |
| 173 | +export interface SubscriptionGetPublishersOptions { |
| 174 | + /** Filter to a specific publisher name. When omitted, all publishers are returned. */ |
| 175 | + name?: string; |
| 176 | +} |
| 177 | + |
| 178 | +/** |
| 179 | + * Response from `getAll()` — publishers with their topics, channels, and full subscription state. |
| 180 | + */ |
| 181 | +export interface SubscriptionGetResponse { |
| 182 | + /** Publishers with their topics and subscription state. */ |
| 183 | + publishers: SubscriptionPublisher[]; |
| 184 | +} |
| 185 | + |
| 186 | +/** |
| 187 | + * Response from `getPublishers()` — the publisher/topic discovery catalogue. |
| 188 | + * |
| 189 | + * Publishers and topics carry only identity/discovery fields (no subscription state); |
| 190 | + * use `getAll()` to inspect subscription state. |
| 191 | + */ |
| 192 | +export interface SubscriptionGetPublishersResponse { |
| 193 | + /** Publishers with their topic catalogue. */ |
| 194 | + publishers: SubscriptionPublisherBase[]; |
| 195 | +} |
| 196 | + |
| 197 | +/** |
| 198 | + * Response from `getSupportedChannels()`. |
| 199 | + */ |
| 200 | +export interface SubscriptionGetSupportedChannelsResponse { |
| 201 | + /** Notification channels supported in the current tenant. `InApp` is not listed — it is always available. */ |
| 202 | + channels: SupportedChannel[]; |
| 203 | +} |
0 commit comments