@openfin/cloud-notification-core-api 0.0.1-alpha.090d19e → 0.0.1-alpha.093329a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/README.md +2 -2
  2. package/bundle.d.ts +591 -330
  3. package/index.cjs +292 -53
  4. package/index.mjs +292 -54
  5. package/package.json +6 -8
package/bundle.d.ts CHANGED
@@ -1,16 +1,41 @@
1
- import z from 'zod';
1
+ import { z } from 'zod';
2
2
 
3
3
  export declare class AuthorizationError extends CloudNotificationAPIError {
4
4
  constructor(message?: string, code?: string);
5
5
  }
6
6
 
7
+ /**
8
+ * Represents common properties for all notification events
9
+ */
7
10
  export declare type BaseNotificationReceivedEvent = {
11
+ /**
12
+ * The action that was performed on the notification
13
+ */
8
14
  action: 'new' | 'update' | 'delete';
15
+ /**
16
+ * The unique identifier for the notification
17
+ */
9
18
  notificationId: string;
19
+ /**
20
+ * The correlation identifier for the notification
21
+ */
10
22
  correlationId?: string;
23
+ /**
24
+ * The identifier of the target of the notification
25
+ */
11
26
  target: string;
27
+ /**
28
+ * The name of the target i.e, the group or user that the notification was sent to
29
+ */
12
30
  targetName?: string;
13
- targetType: string;
31
+ /**
32
+ * The type of the target i.e, 'groups' or 'users'
33
+ */
34
+ targetType: TARGET_TYPE;
35
+ /**
36
+ * The payload of the notification.
37
+ * See the documentation for the notification center events for more information on the payload
38
+ */
14
39
  payload: unknown;
15
40
  };
16
41
 
@@ -20,11 +45,30 @@ export declare type BaseNotificationReceivedEvent = {
20
45
  */
21
46
  export declare class CloudNotificationAPI {
22
47
  #private;
23
- deDuplicator: SetWithTTL<string>;
48
+ /**
49
+ * Constructs a new instance of the CloudNotificationAPI
50
+ *
51
+ * @param cloudNotificationSettings - The settings for the Cloud Notification API.
52
+ */
24
53
  constructor(cloudNotificationSettings: CloudNotificationSettings);
25
54
  /**
26
55
  * Connects and creates a session on the Cloud Notifications service.
27
56
  *
57
+ * @example
58
+ * ```typescript
59
+ * const notificationApi = new CloudNotificationAPI({
60
+ * url: process.env.NOTIFICATION_SERVER_HOST
61
+ * });
62
+ *
63
+ * let connectionResult: ConnectionResult;
64
+ * try {
65
+ * connectionResult = await notificationApi.connect(connectSettings);
66
+ * } catch (errorConnect) {
67
+ * terminal.write(chalk.red(`\nError connecting to notification server: ${errorConnect}\n`));
68
+ * process.exit(1);
69
+ * }
70
+ * ```
71
+ *
28
72
  * @param parameters - The parameters to use to connect.
29
73
  * @returns A promise that resolves when the connection is established.
30
74
  * @throws {@link CloudNotificationAPIError} If an error occurs during connection.
@@ -41,369 +85,586 @@ export declare class CloudNotificationAPI {
41
85
  /**
42
86
  * Posts a notification event to the Cloud Notification service.
43
87
  *
44
- * @param notificationId - The ID of the notification.
88
+ * @param notificationId - The ID of the notification or an array of notification IDs.
45
89
  * @param event - The event details, including category, type, and optional payload.
46
90
  * @returns A promise that resolves when the event is posted.
47
91
  * @throws {@link SessionNotConnectedError} If the session is not connected.
48
92
  * @throws {@link PublishError} If an error occurs during publishing.
49
93
  */
50
- postNotificationEvent(notificationId: string, event: {
94
+ postNotificationEvent(notificationId: string | string[], event: {
51
95
  category: string;
52
96
  type: string;
53
97
  payload?: unknown;
54
- }): Promise<void>;
98
+ }, options?: NotificationEventOptions): Promise<void>;
55
99
  /**
56
- * Raises a notification to the Cloud Notification service.
100
+ * Removes a notification from the notification center for a given set of users or user groups.
57
101
  *
58
- * @param options - The options for the notification.
59
- * @param payload - The payload of the notification.
60
- * @returns A promise that resolves with the notification raise result.
102
+ * @param notificationId - The ID of the notification to remove.
103
+ * @param targets - The targets to remove the notification from.
104
+ * @returns A promise that resolves when the notification is removed.
105
+ */
106
+ removeFromNotificationCenter(notificationId: string, targets: NotificationTargets): Promise<void>;
107
+ /**
108
+ * Post a notification-reminder-created event to the Cloud Notification service.
109
+ *
110
+ * @param notificationId - The ID of the notification or an array of notification IDs to mark as a reminder.
111
+ * @param payload - The payload of the reminder.
112
+ * @returns A promise that resolves when the notification-reminder-created event is posted.
61
113
  * @throws {@link SessionNotConnectedError} If the session is not connected.
62
- * @throws {@link PublishError} If an error occurs during publishing.
63
- */
64
- raiseNotification(options: NotificationOptions_2, payload: unknown): Promise<NotificationRaiseResult>;
65
- /**
66
- * Raises a notification update to the Cloud Notification service.
67
- *
68
- * @param notificationId - The ID of the notification to update.
69
- * @param options - The options for the notification update.
70
- * @param payload - The new payload of the notification.
71
- * @throws {@link SessionNotConnectedError} If the session is not connected.
72
- * @throws {@link PublishError} If an error occurs during publishing of the update.
73
- */
74
- updateNotification(notificationId: string, options: NotificationUpdateOptions, payload: unknown): Promise<void>;
75
- /**
76
- * Marks a notification as deleted in the Cloud Notification service.
77
- *
78
- * @param notificationId - The ID of the notification to delete.
79
- * @returns A promise that resolves when the notification is deleted.
80
- * @throws {@link SessionNotConnectedError} If the session is not connected.
81
- */
82
- deleteNotification(notificationId: string): Promise<void>;
83
- /**
84
- * Replays notifications from the Cloud Notification service.
85
- *
86
- * @param pageItemLimit - The maximum number of items per page.
87
- * @param pageStartCursor - The cursor to start the page from.
88
- * @returns A promise that resolves with the notifications replay details.
89
- * @throws {@link SessionNotConnectedError} If the session is not connected.
90
- * @throws {@link NotificationRetrievalError} If an error occurs during retrieval.
91
- */
92
- replayNotifications(pageItemLimit: number | undefined, pageStartCursor: string | undefined): Promise<NotificationsReplayDetails>;
93
- /**
94
- * Adds an event listener for a specific event type.
95
- *
96
- * @param type - The event type.
97
- * @param callback - The callback function to invoke when the event occurs.
98
- */
99
- addEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
100
- /**
101
- * Removes an event listener for a specific event type.
102
- *
103
- * @param type - The event type.
104
- * @param callback - The callback function to remove.
105
- */
106
- removeEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
107
- /**
108
- * Adds a one-time event listener for a specific event type.
109
- *
110
- * @param type - The event type.
111
- * @param callback - The callback function to invoke once when the event occurs.
112
- */
113
- once<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
114
- }
114
+ */
115
+ setReminder<T extends {
116
+ reminderDate: Date;
117
+ }>(notificationId: string | string[], payload: T, targets: NotificationTargets): Promise<void>;
118
+ /**
119
+ * Post a notification-reminder-removed event to the Cloud Notification service.
120
+ *
121
+ * @param notificationId - The ID of the notification or an array of notification IDs to cancel the reminder for.
122
+ * @returns A promise that resolves when the notification-reminder-removed event is posted.
123
+ * @throws {@link SessionNotConnectedError} If the session is not connected.
124
+ */
125
+ cancelReminder(notificationId: string | string[], targets: NotificationTargets): Promise<void>;
126
+ /**
127
+ * Raises a notification to the Cloud Notification service.
128
+ *
129
+ * @param options - The options for the notification.
130
+ * @param payload - The payload of the notification which should generally conform to the notification center schema
131
+ * @returns A promise that resolves with the notification raise result.
132
+ * @throws {@link SessionNotConnectedError} If the session is not connected.
133
+ * @throws {@link PublishError} If an error occurs during publishing.
134
+ */
135
+ raiseNotification(options: NotificationOptions_2, payload: unknown): Promise<NotificationRaiseResult>;
136
+ /**
137
+ * Raises a notification to the connected user via the Cloud Notification service.
138
+ *
139
+ * Unlike {@link raiseNotification}, no notification raise permissions are required and the notification
140
+ * is always targeted at the connected user only.
141
+ *
142
+ * @param options - The options for the notification.
143
+ * @param payload - The payload of the notification which should generally conform to the notification center schema
144
+ * @returns A promise that resolves with the notification raise result.
145
+ * @throws {@link SessionNotConnectedError} If the session is not connected.
146
+ * @throws {@link PublishError} If an error occurs during publishing.
147
+ */
148
+ raiseNotificationToMe(options: NotificationToMeOptions, payload: unknown): Promise<NotificationRaiseResult>;
149
+ /**
150
+ * Raises a notification update to the Cloud Notification service.
151
+ *
152
+ * @param notificationId - The ID of the notification to update.
153
+ * @param options - The options for the notification update.
154
+ * @param payload - The new payload of the notification which should generally conform to the notification center update schema
155
+ * @throws {@link SessionNotConnectedError} If the session is not connected.
156
+ * @throws {@link PublishError} If an error occurs during publishing of the update.
157
+ */
158
+ updateNotification(notificationId: string, options: NotificationUpdateOptions, payload: unknown): Promise<void>;
159
+ /**
160
+ * Marks a notification as deleted in the Cloud Notification service.
161
+ *
162
+ * This in turn causes notification events to be raised for the notification
163
+ *
164
+ * @param notificationId - The ID of the notification to delete.
165
+ * @returns A promise that resolves when the notification is deleted.
166
+ * @throws {@link SessionNotConnectedError} If the session is not connected.
167
+ */
168
+ deleteNotification(notificationId: string | string[]): Promise<void>;
169
+ /**
170
+ * Replays notifications from the Cloud Notification service.
171
+ *
172
+ * This is called at platform startup to populate the notification center with notifications that were missed since the last time the platform was started.
173
+ *
174
+ * @param pageItemLimit - The maximum number of items per page.
175
+ * @param pageStartCursor - The cursor to start the page from. This is retrieved from the pageInfo property.
176
+ * @returns A promise that resolves with the notifications replay details.
177
+ * @throws {@link SessionNotConnectedError} If the session is not connected.
178
+ * @throws {@link NotificationRetrievalError} If an error occurs during retrieval.
179
+ */
180
+ replayNotifications(pageItemLimit: number | undefined, pageStartCursor: string | undefined): Promise<NotificationsReplayDetails>;
181
+ /**
182
+ * Adds an event listener for a specific event type.
183
+ *
184
+ * @param type - The event type.
185
+ * @param callback - The callback function to invoke when the event occurs.
186
+ */
187
+ addEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
188
+ /**
189
+ * Removes an event listener for a specific event type.
190
+ *
191
+ * @param type - The event type.
192
+ * @param callback - The callback function to remove.
193
+ */
194
+ removeEventListener<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
195
+ /**
196
+ * Adds a one-time event listener for a specific event type.
197
+ *
198
+ * @param type - The event type.
199
+ * @param callback - The callback function to invoke once when the event occurs.
200
+ */
201
+ once<K extends keyof EventMap>(type: K, callback: EventMap[K]): void;
202
+ }
115
203
 
116
- export declare class CloudNotificationAPIError extends Error {
117
- code: string;
118
- constructor(message?: string, code?: string, cause?: unknown);
119
- }
204
+ export declare class CloudNotificationAPIError extends Error {
205
+ code: string;
206
+ constructor(message?: string, code?: string, cause?: unknown);
207
+ }
120
208
 
121
- /**
122
- * Represents a logging function to be used by the cloud notification client
123
- */
124
- export declare type CloudNotificationLogger = (level: LogLevel, message: string) => void;
209
+ /**
210
+ * Represents a logging function to be used by the cloud notification client
211
+ */
212
+ export declare type CloudNotificationLogger = (level: LogLevel, message: string) => void;
125
213
 
126
- export declare type CloudNotificationSettings = {
127
- /**
128
- * The URL of the notification server to connect to
129
- */
130
- url: string;
131
- /**
132
- * The maximum number of times to retry connecting to the cloud notification service when the connection is dropped
133
- * defaults to 30
134
- */
135
- reconnectRetryLimit?: number;
136
- /**
137
- * Specifies how often keep alive messages should be sent to the cloud notification service in seconds
138
- * defaults to 30
139
- */
140
- keepAliveIntervalSeconds?: number;
141
- /**
142
- * Optional function to call with any logging messages to allow integration with the host application's logging
143
- *
144
- * defaults to console.log
145
- */
146
- logger?: CloudNotificationLogger;
147
- /**
148
- * The time used to deduplicate notifications
149
- */
150
- deduplicationTTLms?: number;
151
- /**
152
- * Will cause the api to calculate the time offset between the local machine and the notification server
153
- * defaults to true
154
- */
155
- syncTime?: boolean;
156
- };
214
+ export declare type CloudNotificationSettings = {
215
+ /**
216
+ * The URL of the notification server to connect to
217
+ *
218
+ * @example 'https://the-environment.example.com/notifications'
219
+ */
220
+ url: string;
221
+ /**
222
+ * The maximum number of times to retry connecting to the cloud notification service when the connection is dropped
223
+ * defaults to 30
224
+ */
225
+ reconnectRetryLimit?: number;
226
+ /**
227
+ * Specifies how often keep alive messages should be sent to the cloud notification service in seconds
228
+ * defaults to 30
229
+ */
230
+ keepAliveIntervalSeconds?: number;
231
+ /**
232
+ * Optional function to call with any logging messages to allow integration with the host application's logging
233
+ *
234
+ * Defaults to console.log
235
+ */
236
+ logger?: CloudNotificationLogger;
237
+ /**
238
+ * The time used to deduplicate notifications
239
+ */
240
+ deduplicationTTLms?: number;
241
+ /**
242
+ * Will cause the api to calculate the time offset between the local machine and the notification server
243
+ * defaults to true
244
+ */
245
+ syncTime?: boolean;
246
+ };
157
247
 
158
- /**
159
- * Repesents the result of a successful connection to the server
160
- */
161
- export declare type ConnectionResult = {
162
- /**
163
- * The unique identifier for the session
164
- */
165
- sessionId: string;
166
- /**
167
- * The platform identifier
168
- */
169
- platformId: string;
170
- /**
171
- * The source identifier
172
- */
173
- sourceId: string;
174
- /**
175
- * The user identifier
176
- */
177
- userId: string;
178
- /**
179
- * A collection of groups that the user is either a direct or indirect member of
180
- */
181
- groups: {
182
- uuid: string;
183
- name: string;
184
- }[];
185
- };
248
+ /**
249
+ * Represents the result of a successful connection to the server
250
+ */
251
+ export declare type ConnectionResult = {
252
+ /**
253
+ * The unique identifier for the session
254
+ */
255
+ sessionId: string;
256
+ /**
257
+ * The platform identifier
258
+ */
259
+ platformId: string;
260
+ /**
261
+ * The source identifier
262
+ */
263
+ sourceId: string;
264
+ /**
265
+ * The user identifier
266
+ */
267
+ userId: string;
268
+ /**
269
+ * A collection of groups that the user is either a direct or indirect member of
270
+ */
271
+ groups: {
272
+ uuid: string;
273
+ name: string;
274
+ }[];
275
+ };
186
276
 
187
- /**
188
- * Represents the parameters to use to connect to an notification server
189
- */
190
- export declare type ConnectParameters = {
191
- /**
192
- * ID for a group of shared applications.
193
- * This acts as a namespace for the notification messages that allows separation of messages between different groups of applications for the same user
194
- */
195
- platformId: string;
196
- /**
197
- * A value that distinguishes the host the application is running in. For example this could be the hostname of the current machine
198
- */
199
- sourceId: string;
200
- /**
201
- * Determines the type of authentication to use with the service gateway
202
- * defaults to 'none'
203
- *
204
- * 'jwt' - Use JWT authentication, in this case jwtAuthenticationParameters must also be provided
205
- * 'basic' - Use basic authentication, in this case basicAuthenticationParameters must also be provided
206
- * 'default' - Authentication will be inherited from the current session
207
- */
208
- authenticationType?: 'jwt' | 'basic' | 'default';
209
- /**
210
- * Optional parameters for basic authentication
211
- */
212
- basicAuthenticationParameters?: {
213
- /**
214
- * The username to use for basic authentication
215
- */
216
- username: string;
217
- /**
218
- * The password to use for basic authentication
219
- */
220
- password: string;
221
- };
222
- /**
223
- * Optional parameters for JWT authentication
224
- */
225
- jwtAuthenticationParameters?: {
226
- /**
227
- * When JWT authentication is being used, this will be invoked just whenever a JWT token is required for a request
228
- */
229
- jwtRequestCallback: () => string | object;
230
- /**
231
- * The id of the service gateway JWT authentication definition to use
232
- *
233
- * Note: Contact Here support to to get your organization's authentication id
234
- */
235
- authenticationId: string;
236
- };
237
- };
277
+ /**
278
+ * Represents the parameters to use to connect to an notification server
279
+ */
280
+ export declare type ConnectParameters = {
281
+ /**
282
+ * ID for a group of shared applications.
283
+ *
284
+ * This acts as a namespace for the notification messages that allows separation of messages between different groups of applications for the same user
285
+ *
286
+ * This, in general, should be the uuid of the platform that you are communicating
287
+ */
288
+ platformId: string;
289
+ /**
290
+ * A value that distinguishes the host the application is running in. For example this could be the hostname of the current machine
291
+ */
292
+ sourceId: string;
293
+ /**
294
+ * Determines the type of authentication to use with the service gateway
295
+ *
296
+ * - 'jwt' - Use JWT authentication, in this case jwtAuthenticationParameters must also be provided
297
+ * - 'basic' - Use basic authentication, in this case basicAuthenticationParameters must also be provided
298
+ * - 'default' - Authentication will be inherited from the current session
299
+ */
300
+ authenticationType?: 'jwt' | 'basic' | 'default';
301
+ /**
302
+ * Optional parameters for basic authentication
303
+ */
304
+ basicAuthenticationParameters?: {
305
+ /**
306
+ * The username to use for basic authentication
307
+ */
308
+ username: string;
309
+ /**
310
+ * The password to use for basic authentication
311
+ */
312
+ password: string;
313
+ };
314
+ /**
315
+ * Optional parameters for JWT authentication
316
+ */
317
+ jwtAuthenticationParameters?: {
318
+ /**
319
+ * When JWT authentication is being used, this will be invoked just whenever a JWT token is required for a request
320
+ *
321
+ * This token should be conform to the configuration set within your environment. Contact Here support for more details
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * const jwtRequestCallback = () => {
326
+ * return 'your-jwt-token';
327
+ * };
328
+ * ```
329
+ */
330
+ jwtRequestCallback: () => string | object;
331
+ /**
332
+ * The id of the service gateway JWT authentication definition to use
333
+ *
334
+ * Note: Contact Here support to to get your organization's authentication id
335
+ */
336
+ authenticationId: string;
337
+ };
338
+ };
238
339
 
239
- export declare type DeleteNotificationEvent = BaseNotificationReceivedEvent & {
240
- action: 'delete';
241
- };
340
+ export declare type DeleteNotificationEvent = BaseNotificationReceivedEvent & {
341
+ action: 'delete';
342
+ };
242
343
 
243
- export declare type EventListenersMap = Map<keyof EventMap, Array<(...args: Parameters<EventMap[keyof EventMap]>) => void>>;
344
+ export declare type EventMap = {
345
+ /**
346
+ * Emitted when the connection has been re-established
347
+ * @returns void
348
+ */
349
+ reconnected: () => void;
350
+ /**
351
+ * Emitted when the connection has been disconnected
352
+ * @returns void
353
+ */
354
+ reconnecting: (attemptNo: number) => void;
355
+ /**
356
+ * Emitted when the connection has been disconnected
357
+ * @returns void
358
+ */
359
+ disconnected: () => void;
360
+ /**
361
+ * Emitted when an error occurs
362
+ * @returns void
363
+ */
364
+ error: (error: Error) => void;
365
+ /**
366
+ * Emitted when the session has expired
367
+ * @returns void
368
+ */
369
+ 'session-expired': () => void;
370
+ /**
371
+ * Emitted when the session has been extended
372
+ * @returns void
373
+ */
374
+ 'session-extended': () => void;
375
+ /**
376
+ * Emitted when a new notification is received
377
+ * @returns void
378
+ */
379
+ 'new-notification': (event: NewNotificationEvent) => void;
380
+ /**
381
+ * Emitted when an update to a notification is received
382
+ * @returns void
383
+ */
384
+ 'update-notification': (event: UpdateNotificationEvent) => void;
385
+ /**
386
+ * Emitted when a notification is deleted
387
+ * @returns void
388
+ */
389
+ 'delete-notification': (event: DeleteNotificationEvent) => void;
390
+ /**
391
+ * Emitted when a notification event is received for this specific session
392
+ * @returns void
393
+ */
394
+ 'notification-event': (event: NotificationEvent) => void;
395
+ /**
396
+ * Emitted when a notification event is received for all sessions
397
+ * @returns void
398
+ */
399
+ 'global-notification-event': (event: NotificationEvent) => void;
400
+ };
244
401
 
245
- export declare type EventMap = {
246
- reconnected: () => void;
247
- disconnected: () => void;
248
- reconnecting: (attemptNo: number) => void;
249
- error: (error: Error) => void;
250
- 'session-expired': () => void;
251
- 'session-extended': () => void;
252
- 'new-notification': (event: NewNotificationEvent) => void;
253
- 'update-notification': (event: UpdateNotificationEvent) => void;
254
- 'delete-notification': (event: DeleteNotificationEvent) => void;
255
- 'notification-event': (event: NotificationEvent) => void;
256
- };
402
+ export declare class EventPublishError extends CloudNotificationAPIError {
403
+ constructor(message?: string, code?: string, cause?: unknown);
404
+ }
257
405
 
258
- export declare class EventPublishError extends CloudNotificationAPIError {
259
- constructor(message?: string, code?: string, cause?: unknown);
260
- }
406
+ export declare class EventRetrievalError extends CloudNotificationAPIError {
407
+ constructor(message?: string, code?: string, cause?: unknown);
408
+ }
261
409
 
262
- export declare class EventRetrievalError extends CloudNotificationAPIError {
263
- constructor(message?: string, code?: string, cause?: unknown);
264
- }
410
+ export declare class InvalidMessageFormatError extends CloudNotificationAPIError {
411
+ constructor(zodParseResult: z.SafeParseReturnType<unknown, unknown>);
412
+ }
265
413
 
266
- export declare class InvalidMessageFormatError extends CloudNotificationAPIError {
267
- constructor(zodParseResult: z.SafeParseReturnType<unknown, unknown>);
268
- }
414
+ export declare type LogLevel = 'log' | 'debug' | 'info' | 'warn' | 'error';
269
415
 
270
- export declare type LogLevel = 'log' | 'debug' | 'info' | 'warn' | 'error';
416
+ export declare type NewNotificationEvent = BaseNotificationReceivedEvent & {
417
+ action: 'new';
418
+ };
271
419
 
272
- export declare type NewNotificationEvent = BaseNotificationReceivedEvent & {
273
- action: 'new';
274
- };
420
+ /**
421
+ * Represents a notification event
422
+ */
423
+ export declare type NotificationEvent = {
424
+ /**
425
+ * The unique identifier for the notification
426
+ */
427
+ notificationId: string;
428
+ /**
429
+ * The correlation identifier for the notification
430
+ */
431
+ correlationId?: string;
432
+ /**
433
+ * The source identifier
434
+ */
435
+ sourceId: string;
436
+ /**
437
+ * The originating session identifier
438
+ */
439
+ originatingSessionId: string;
440
+ /**
441
+ * The platform identifier
442
+ */
443
+ platformId: string;
444
+ /**
445
+ * The unique platform identifier for the user
446
+ */
447
+ userId: string;
448
+ /**
449
+ * The resolved username of the user
450
+ */
451
+ userName?: string;
452
+ /**
453
+ * The category of the notification.
454
+ * For notification center events this will be 'notification-center-event'
455
+ */
456
+ category: string;
457
+ /**
458
+ * The type of the notification.
459
+ * For example 'notification-close' when a user closes a notification in the notification center
460
+ */
461
+ type: string;
462
+ /**
463
+ * The payload of the notification.
464
+ * See the documentation for the notification center events for more information on the payload
465
+ */
466
+ payload?: unknown;
467
+ };
275
468
 
276
- export declare type NotificationEvent = {
277
- notificationId: string;
278
- correlationId?: string;
279
- category: string;
280
- type: string;
281
- payload?: unknown;
282
- };
469
+ /**
470
+ * Represents the options for a notification event publish
471
+ */
472
+ export declare type NotificationEventOptions = {
473
+ /**
474
+ * The targets to send the event to
475
+ *
476
+ * This is a set of groups and users that the notification event will direct to. You may use to explicitly remove the notification
477
+ * from a subset of the original targets that received it.
478
+ *
479
+ * For example you send a notification to *all-users* and then want to remove the notification from a specific group. You can do this by
480
+ * specifying the group name in the targets.
481
+ *
482
+ * @example
483
+ * ```typescript
484
+ * const notificationEventOptions: NotificationEventOptions = {
485
+ * targets: {
486
+ * groups: ['all-users'],
487
+ * users: ['someuser@company.com']
488
+ * }
489
+ * };
490
+ * ```
491
+ */
492
+ targets: NotificationTargets;
493
+ };
283
494
 
284
- /**
285
- * Represents the options for a notification publish
286
- */
287
- declare type NotificationOptions_2 = {
288
- /**
289
- * A caller specified identifier for the notification
290
- * This is used to identify the notification in the system when events and responses are received
291
- */
292
- correlationId?: string;
293
- /**
294
- * The targets to send the notification to
295
- * This is a set of groups and users that the notification will be sent to
296
- */
297
- targets: NotificationTargets;
298
- /**
299
- * Optional number of seconds to keep the notification alive
300
- * After this time the notification will be expired and a delete update will be raised
301
- */
302
- ttlSeconds?: number;
303
- };
304
- export { NotificationOptions_2 as NotificationOptions }
495
+ /**
496
+ * Represents the options for a notification publish
497
+ */
498
+ declare type NotificationOptions_2 = {
499
+ /**
500
+ * A caller specified identifier for the notification
501
+ *
502
+ * This is used to identify the notification in the system when events and responses are received
503
+ */
504
+ correlationId?: string;
505
+ /**
506
+ * The targets to send the notification to
507
+ *
508
+ * This is a set of groups and users that the notification will be sent to
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * const notificationOptions: NotificationOptions = {
513
+ * targets: {
514
+ * groups: ['all-users'],
515
+ * users: ['someuser@company.com']
516
+ * }
517
+ * };
518
+ * ```
519
+ */
520
+ targets: NotificationTargets;
521
+ /**
522
+ * Optional number of seconds to keep the notification alive
523
+ *
524
+ * After this time the notification will be expired and a delete update will be raised
525
+ */
526
+ ttlSeconds?: number;
527
+ };
528
+ export { NotificationOptions_2 as NotificationOptions }
305
529
 
306
- /**
307
- * Represents the response from raising a notification
308
- */
309
- export declare type NotificationRaiseResult = {
310
- /**
311
- * The unique identifier for the notification
312
- */
313
- notificationId: string;
314
- /**
315
- * The correlation ID that was provided when raising the notification
316
- */
317
- correlationId?: string;
318
- };
530
+ /**
531
+ * Represents the response from raising a notification
532
+ */
533
+ export declare type NotificationRaiseResult = {
534
+ /**
535
+ * The unique identifier for the notification
536
+ */
537
+ notificationId: string;
538
+ /**
539
+ * The correlation ID that was provided when raising the notification
540
+ */
541
+ correlationId?: string;
542
+ };
319
543
 
320
- export declare class NotificationRetrievalError extends CloudNotificationAPIError {
321
- constructor(message?: string, code?: string, cause?: unknown);
322
- }
544
+ export declare class NotificationRetrievalError extends CloudNotificationAPIError {
545
+ constructor(message?: string, code?: string, cause?: unknown);
546
+ }
323
547
 
324
- export declare type NotificationsReplayDetail = {
325
- cursor: string;
326
- sessionId: string;
327
- notificationId: string;
328
- version: number;
329
- action: 'new' | 'update' | 'delete';
330
- payload?: unknown;
331
- correlationId?: string | null;
332
- timestamp: Date;
333
- };
548
+ /**
549
+ * Represents a single notification replay detail.
550
+ */
551
+ export declare type NotificationsReplayDetail = {
552
+ /**
553
+ * The cursor of the notification.
554
+ */
555
+ cursor: string;
556
+ /**
557
+ * The session ID of the notification.
558
+ */
559
+ sessionId: string;
560
+ /**
561
+ * The notification ID.
562
+ */
563
+ notificationId: string;
564
+ /**
565
+ * The version of the notification.
566
+ */
567
+ version: number;
568
+ /**
569
+ * The type of notification record.
570
+ */
571
+ action: 'new' | 'update' | 'delete';
572
+ /**
573
+ * The payload of the notification.
574
+ */
575
+ payload?: unknown;
576
+ /**
577
+ * The original correlation ID of the notification if specified.
578
+ */
579
+ correlationId?: string | null;
580
+ /**
581
+ * The timestamp of the notification.
582
+ */
583
+ timestamp: Date;
584
+ /**
585
+ * The payload of the latest reminder event for the notification.
586
+ */
587
+ latestReminderPayload?: unknown;
588
+ };
334
589
 
335
- export declare type NotificationsReplayDetails = {
336
- data: NotificationsReplayDetail[];
337
- pageInfo: {
338
- pageStart?: string;
339
- nextPage?: string;
340
- hasNextPage: boolean;
341
- };
342
- };
590
+ /**
591
+ * Represents the results of a notifications replay request.
592
+ */
593
+ export declare type NotificationsReplayDetails = {
594
+ /**
595
+ * The list of notifications replay details.
596
+ */
597
+ data: NotificationsReplayDetail[];
598
+ /**
599
+ * The pagination information for the notifications replay request.
600
+ */
601
+ pageInfo: {
602
+ /**
603
+ * The cursor of the first notification in the page.
604
+ */
605
+ pageStart?: string;
606
+ /**
607
+ * The cursor of the next page.
608
+ */
609
+ nextPage?: string;
610
+ /**
611
+ * Whether there is a next page of notifications.
612
+ */
613
+ hasNextPage: boolean;
614
+ };
615
+ };
343
616
 
344
- /**
345
- * Represents a set of targets for a notification publish
346
- */
347
- export declare type NotificationTargets = {
348
- /**
349
- * The groups to send the notification to
350
- */
351
- groups: string[];
352
- /**
353
- * The users to send the notification to
354
- */
355
- users: string[];
356
- };
617
+ /**
618
+ * Represents a set of targets for a notification publish
619
+ */
620
+ export declare type NotificationTargets = {
621
+ /**
622
+ * The optional groups to send the notification to
623
+ *
624
+ * This can be a collection of either group names e.g. all-users which can be retrieved from the admin console or the
625
+ * UUID of the group itself
626
+ */
627
+ groups: string[];
628
+ /**
629
+ * The optional specific users to send the notification to
630
+ *
631
+ * This can be the username e.g. someuser\@company.com or the UUID of the user itself
632
+ */
633
+ users: string[];
634
+ };
357
635
 
358
- /**
359
- * Represents the options for a notification update
360
- */
361
- export declare type NotificationUpdateOptions = {
362
- /**
363
- * Optional number of seconds to keep the notification alive
364
- * After this time the notification will be expired and a delete update will be raised
365
- */
366
- ttlSeconds?: number;
367
- };
636
+ /**
637
+ * Represents the options for a notification publish to the calling user
638
+ *
639
+ * The notification is always targeted at the connected user, so targets cannot be specified
640
+ */
641
+ export declare type NotificationToMeOptions = Omit<NotificationOptions_2, 'targets'>;
368
642
 
369
- export declare class PublishError extends CloudNotificationAPIError {
370
- constructor(message?: string, code?: string, cause?: unknown);
371
- }
643
+ /**
644
+ * Represents the options for a notification update
645
+ */
646
+ export declare type NotificationUpdateOptions = {
647
+ /**
648
+ * Optional number of seconds to keep the notification alive
649
+ * After this time the notification will be expired and a delete update will be raised
650
+ */
651
+ ttlSeconds?: number;
652
+ };
372
653
 
373
- export declare type PublishResult = {
374
- notificationId: string;
375
- correlationId: string | undefined;
376
- };
654
+ export declare class PublishError extends CloudNotificationAPIError {
655
+ constructor(message?: string, code?: string, cause?: unknown);
656
+ }
377
657
 
378
- export declare class SessionNotConnectedError extends CloudNotificationAPIError {
379
- constructor(message?: string, code?: string);
380
- }
658
+ export declare class SessionNotConnectedError extends CloudNotificationAPIError {
659
+ constructor(message?: string, code?: string);
660
+ }
381
661
 
382
- /**
383
- * Simple set-like structure that allows you to add values with a TTL (time to live).
384
- * Values are automatically removed from the set after the TTL expires.
385
- */
386
- declare class SetWithTTL<T> {
387
- #private;
388
- private ttl;
389
- private store;
390
- private nextCollection;
391
- private collectionDelay;
392
- constructor(ttl: number, collectionCheckInterval?: number);
393
- get size(): number;
394
- add(value: T, customTtl?: number): this;
395
- has(value: T): boolean;
396
- delete(value: T): this;
397
- }
662
+ export declare type TARGET_TYPE = z.infer<typeof targetTypeSchema>;
398
663
 
399
- export declare type UpdateNotificationEvent = BaseNotificationReceivedEvent & {
400
- action: 'update';
401
- };
664
+ export declare const targetTypeSchema: z.ZodEnum<["users", "groups"]>;
402
665
 
403
- export declare type UserGroupWithTopic = {
404
- uuid: string;
405
- name: string;
406
- topic?: string;
407
- };
666
+ export declare type UpdateNotificationEvent = BaseNotificationReceivedEvent & {
667
+ action: 'update';
668
+ };
408
669
 
409
- export { }
670
+ export { }