@openfin/cloud-notification-core-api 0.0.1-alpha.ce2c445 → 0.0.1-alpha.ce9c8f0

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