@openfin/cloud-notification-core-api 0.0.1-alpha.fe136f4 → 0.0.1-alpha.fe19a6f

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