openfin-notifications 1.10.2-alpha-730 → 1.10.2-alpha-741

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.
@@ -14,6 +14,7 @@ import * as provider from './provider';
14
14
  import { NotificationSource } from './source';
15
15
  import { NotificationIndicator, IndicatorType, IndicatorColor } from './indicator';
16
16
  import { NotificationOptions } from './templates/templates';
17
+ import { UpdatableNotificationOptions } from './templates/updatableNotificationTemplates';
17
18
  export * from './actions';
18
19
  export * from './controls';
19
20
  export * from './source';
@@ -44,6 +45,9 @@ export declare type CustomData = Record<string, any>;
44
45
  export declare type Notification<T extends NotificationOptions = NotificationOptions> = Readonly<Required<DistributiveOmit<T, 'buttons'>> & {
45
46
  readonly buttons: ReadonlyArray<Required<ButtonOptions>>;
46
47
  }>;
48
+ export declare type UpdatableNotification<T extends UpdatableNotificationOptions = UpdatableNotificationOptions> = Readonly<DistributiveOmit<T, 'buttons'> & {
49
+ readonly buttons?: ReadonlyArray<Required<ButtonOptions>>;
50
+ }>;
47
51
  /**
48
52
  * Event fired when an action is raised for a notification due to a specified trigger. It is important to note that
49
53
  * applications will only receive these events if they indicate to the service that they want to receive these events.
@@ -202,6 +206,28 @@ export declare function removeEventListener(eventType: 'notifications-count-chan
202
206
  * @param options Notification configuration options.
203
207
  */
204
208
  export declare function create<T extends NotificationOptions>(options: T): Promise<Notification<T>>;
209
+ /**
210
+ * Updates an existing notification. Requires id of original Notification and one of:
211
+ * - buttons
212
+ * - customData
213
+ * - Template
214
+ *
215
+ * The updated Notification will then show in Notification Centre and in the Toast stack if not expired.
216
+ *
217
+ * Example:
218
+ * ```ts
219
+ * import {update} from 'openfin-notifications';
220
+ *
221
+ * update({
222
+ id: uniqueNotificationId,
223
+ body: 'i am an update! - ' + Date.now().toString(),
224
+ template: 'markdown',
225
+ });
226
+ * ```
227
+ * @param options
228
+ * @returns
229
+ */
230
+ export declare function update<T extends UpdatableNotificationOptions>(options: T): Promise<Notification>;
205
231
  /**
206
232
  * Clears a specific notification from the Notification Center.
207
233
  *
@@ -10,7 +10,8 @@
10
10
  import { NotificationActionResult, ActionTrigger } from './actions';
11
11
  import { ProviderStatus } from './provider';
12
12
  import { NotificationSource } from './source';
13
- import { NotificationOptions, Notification, NotificationActionEvent, NotificationClosedEvent, NotificationCreatedEvent, NotificationsCountChanged, NotificationFormSubmittedEvent } from './index';
13
+ import { NotificationOptions, Notification, NotificationActionEvent, NotificationClosedEvent, NotificationCreatedEvent, NotificationsCountChanged, NotificationFormSubmittedEvent, UpdatableNotification } from './index';
14
+ import { UpdatableNotificationOptions } from './templates/updatableNotificationTemplates';
14
15
  /**
15
16
  * The identity of the main application window of the service provider
16
17
  */
@@ -24,6 +25,7 @@ export declare const SERVICE_IDENTITY: {
24
25
  export declare const SERVICE_CHANNEL = "of-notifications-service-v1";
25
26
  export declare const enum APITopic {
26
27
  CREATE_NOTIFICATION = "create-notification",
28
+ UPDATE_NOTIFICATION = "update-notification",
27
29
  CLEAR_NOTIFICATION = "clear-notification",
28
30
  GET_APP_NOTIFICATIONS = "fetch-app-notifications",
29
31
  CLEAR_APP_NOTIFICATIONS = "clear-app-notifications",
@@ -35,6 +37,7 @@ export declare const enum APITopic {
35
37
  }
36
38
  export interface API {
37
39
  [APITopic.CREATE_NOTIFICATION]: [CreatePayload, NotificationInternal];
40
+ [APITopic.UPDATE_NOTIFICATION]: [UpdatePayload, NotificationInternal];
38
41
  [APITopic.CLEAR_NOTIFICATION]: [ClearPayload, boolean];
39
42
  [APITopic.CLEAR_APP_NOTIFICATIONS]: [undefined, number];
40
43
  [APITopic.GET_APP_NOTIFICATIONS]: [undefined, NotificationInternal[]];
@@ -51,10 +54,15 @@ export declare type CreatePayload<T extends NotificationOptions = NotificationOp
51
54
  date?: number;
52
55
  expires?: number | null;
53
56
  };
57
+ export declare type UpdatePayload<T extends UpdatableNotificationOptions = UpdatableNotificationOptions> = T;
54
58
  export declare type NotificationInternal<T extends NotificationOptions = NotificationOptions> = DistributiveOmit<Notification<T>, 'date' | 'expires'> & {
55
59
  date: number;
56
60
  expires: number | null;
57
61
  };
62
+ export declare type UpdatableNotificationInternal<T extends UpdatableNotificationOptions = UpdatableNotificationOptions> = UpdatableNotification<T> & {
63
+ bodyText?: string;
64
+ body?: string;
65
+ };
58
66
  export interface ClearPayload {
59
67
  id: string;
60
68
  }
@@ -119,6 +119,7 @@ exports.SERVICE_CHANNEL = 'of-notifications-service-v1';
119
119
  var APITopic;
120
120
  (function (APITopic) {
121
121
  APITopic["CREATE_NOTIFICATION"] = "create-notification";
122
+ APITopic["UPDATE_NOTIFICATION"] = "update-notification";
122
123
  APITopic["CLEAR_NOTIFICATION"] = "clear-notification";
123
124
  APITopic["GET_APP_NOTIFICATIONS"] = "fetch-app-notifications";
124
125
  APITopic["CLEAR_APP_NOTIFICATIONS"] = "clear-app-notifications";
@@ -391,7 +392,7 @@ async function getServicePromise() {
391
392
  }, 5000);
392
393
  channelPromise = fin.InterApplicationBus.Channel.connect(internal_1.SERVICE_CHANNEL, {
393
394
  wait: true,
394
- payload: { version: '1.10.2-alpha-730' },
395
+ payload: { version: '1.10.2-alpha-741' },
395
396
  }).then((channel) => {
396
397
  window.clearTimeout(timeoutHandle);
397
398
  const eventRouter = getEventRouter();
@@ -558,7 +559,7 @@ var __rest = (this && this.__rest) || function (s, e) {
558
559
  return t;
559
560
  };
560
561
  Object.defineProperty(exports, "__esModule", { value: true });
561
- exports.getNotificationsCount = exports.toggleNotificationCenter = exports.clearAll = exports.getAll = exports.clear = exports.create = exports.removeEventListener = exports.addEventListener = exports.VERSION = exports.NotificationIndicatorType = exports.IndicatorColor = exports.NotificationIndicator = exports.NotificationOptions = exports.provider = void 0;
562
+ exports.getNotificationsCount = exports.toggleNotificationCenter = exports.clearAll = exports.getAll = exports.clear = exports.update = exports.create = exports.removeEventListener = exports.addEventListener = exports.VERSION = exports.NotificationIndicatorType = exports.IndicatorColor = exports.NotificationIndicator = exports.NotificationOptions = exports.provider = void 0;
562
563
  /**
563
564
  * @module NotificationCenter
564
565
  */
@@ -591,7 +592,7 @@ __exportStar(__webpack_require__(20), exports);
591
592
  *
592
593
  * This is the version which you are currently using.
593
594
  */
594
- exports.VERSION = '1.10.2-alpha-730';
595
+ exports.VERSION = '1.10.2-alpha-741';
595
596
  const eventHandler = connection_1.getEventRouter();
596
597
  function parseEventWithNotification(event) {
597
598
  const { notification } = event;
@@ -691,6 +692,38 @@ async function create(options) {
691
692
  return Object.assign(Object.assign({}, response), { date: new Date(response.date), expires: response.expires !== null ? new Date(response.expires) : null });
692
693
  }
693
694
  exports.create = create;
695
+ /**
696
+ * Updates an existing notification. Requires id of original Notification and one of:
697
+ * - buttons
698
+ * - customData
699
+ * - Template
700
+ *
701
+ * The updated Notification will then show in Notification Centre and in the Toast stack if not expired.
702
+ *
703
+ * Example:
704
+ * ```ts
705
+ * import {update} from 'openfin-notifications';
706
+ *
707
+ * update({
708
+ id: uniqueNotificationId,
709
+ body: 'i am an update! - ' + Date.now().toString(),
710
+ template: 'markdown',
711
+ });
712
+ * ```
713
+ * @param options
714
+ * @returns
715
+ */
716
+ async function update(options) {
717
+ if (typeof options !== 'object' || options === null) {
718
+ throw new Error('Invalid argument passed to create: argument must be an object and must not be null');
719
+ }
720
+ if (!options.id) {
721
+ throw new Error('Invalid argument passed to create: "id" must be Id of previously created Notification');
722
+ }
723
+ const response = await connection_1.tryServiceDispatch(internal_1.APITopic.UPDATE_NOTIFICATION, Object.assign({}, options));
724
+ return Object.assign({}, response);
725
+ }
726
+ exports.update = update;
694
727
  /**
695
728
  * Clears a specific notification from the Notification Center.
696
729
  *
@@ -1826,6 +1859,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1826
1859
  Object.defineProperty(exports, "__esModule", { value: true });
1827
1860
  __exportStar(__webpack_require__(21), exports);
1828
1861
  __exportStar(__webpack_require__(5), exports);
1862
+ __exportStar(__webpack_require__(22), exports);
1829
1863
 
1830
1864
 
1831
1865
  /***/ }),
@@ -1842,6 +1876,15 @@ __exportStar(__webpack_require__(5), exports);
1842
1876
  Object.defineProperty(exports, "__esModule", { value: true });
1843
1877
 
1844
1878
 
1879
+ /***/ }),
1880
+ /* 22 */
1881
+ /***/ (function(module, exports, __webpack_require__) {
1882
+
1883
+ "use strict";
1884
+
1885
+ Object.defineProperty(exports, "__esModule", { value: true });
1886
+
1887
+
1845
1888
  /***/ })
1846
1889
  /******/ ]);
1847
1890
  });