@openfin/notifications-router 2.13.0-alpha-4294

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.
@@ -0,0 +1,2264 @@
1
+ /// <reference types="node" />
2
+ import OpenFin from '@openfin/core';
3
+ import { ThemeSet, ColorSchemeType } from '@openfin/ui-library';
4
+ import { DefaultTheme } from 'styled-components';
5
+
6
+ type Context = any;
7
+ /**
8
+ * Signature for an aggregator function.
9
+ *
10
+ * On signals that allow callbacks to return a value (i.e. where `R != void`), an aggregator can be used to determine
11
+ * how the values returned by the signal callbacks are returned back to the code that emitted the signal.
12
+ *
13
+ * If no aggregator is provided, the `emit()` function on a signal has a `void` return type.
14
+ */
15
+ type Aggregator<R, R2> = (items: R[]) => R2;
16
+ /**
17
+ * Represents a slot that exists on a signal.
18
+ */
19
+ interface SignalSlot<T extends (...args: any[]) => any> {
20
+ callback: T;
21
+ context: Context;
22
+ remove(): void;
23
+ }
24
+ /**
25
+ * Signal implementation, a messaging paradigm similar to standard JavaScript events, only more object-based.
26
+ *
27
+ * Create a signal for each event type, specifying the types of any callback parameters. Listeners (known as "slots")
28
+ * can then be added to (and removed from) the signal.
29
+ *
30
+ * Unlike events, callbacks are also able to return a value. To make use of these return values, pass an aggregator
31
+ * function when defining the signal. The static functions within {@link Aggregators} are a set of aggregators that
32
+ * cover typical use-cases.
33
+ */
34
+ declare class Signal<A extends any[], R = void, R2 = R> {
35
+ #private;
36
+ constructor(aggregator?: Aggregator<R, R2>);
37
+ get slots(): ReadonlyArray<SignalSlot<(...args: A) => R>>;
38
+ add(callback: (...args: A) => R, context?: Context): SignalSlot<(...args: A) => R>;
39
+ remove(callback: (...args: A) => R, context?: Context): boolean;
40
+ has(callback: (...args: A) => R, context?: Context): boolean;
41
+ emit(...args: A): R2;
42
+ }
43
+
44
+ /**
45
+ * @module Notifications
46
+ */
47
+ /**
48
+ * @deprecated
49
+ * Lists possible semantic use-cases for notifications, which can alter how the notification is presented to the user.
50
+ */
51
+ declare enum IndicatorType {
52
+ FAILURE = "failure",
53
+ WARNING = "warning",
54
+ SUCCESS = "success"
55
+ }
56
+ /**
57
+ * Lists possible colors available for use as NotificationIndicator background color.
58
+ */
59
+ declare enum IndicatorColor {
60
+ RED = "red",
61
+ GREEN = "green",
62
+ YELLOW = "yellow",
63
+ BLUE = "blue",
64
+ PURPLE = "purple",
65
+ GRAY = "gray",
66
+ ORANGE = "orange",
67
+ MAGENTA = "magenta",
68
+ TEAL = "teal"
69
+ }
70
+ interface NotificationIndicator {
71
+ /**
72
+ * @deprecated
73
+ *
74
+ * Deprecated - use the priority field instead.
75
+ *
76
+ * Indicates the semantic intent behind the indicator - this determines the visual styling of the indicator when
77
+ * seen by the user.
78
+ *
79
+ * For example - an indicator could be used to:
80
+ * - `IndicatorType.FAILURE`: Indicate a failure has occurred from an action the user has taken.
81
+ * - `IndicatorType.WARNING`: Warn a user that they have a limited amount of time to buy.
82
+ * - `IndicatorType.SUCCESS`: Inform the user that an item has been successfully ordered.
83
+ */
84
+ type?: IndicatorType;
85
+ /**
86
+ * The indicator banner color. Defaults to red.
87
+ */
88
+ color?: IndicatorColor;
89
+ /**
90
+ * Customized text to be displayed in the indicator. When set, this will override the default indicator text.
91
+ * Text is limited to 32 characters including spaces.
92
+ */
93
+ text?: string;
94
+ }
95
+ interface NotificationIndicatorWithCustomColor extends Omit<NotificationIndicator, 'color'> {
96
+ /**
97
+ * Custom color string for indicator banner. This string must be defined in `theme` during Workspace Platform initialization.
98
+ */
99
+ color: string;
100
+ /**
101
+ * Fallback color if custom color could not be found in theme.
102
+ */
103
+ fallback: IndicatorColor;
104
+ }
105
+
106
+ declare const WidgetType: {
107
+ readonly Time: "Time";
108
+ readonly Date: "Date";
109
+ readonly RadioGroup: "RadioGroup";
110
+ readonly CheckboxGroup: "CheckboxGroup";
111
+ readonly Toggle: "Toggle";
112
+ readonly Checkbox: "Checkbox";
113
+ readonly Number: "Number";
114
+ readonly Text: "Text";
115
+ readonly Dropdown: "Dropdown";
116
+ };
117
+ interface BaseWidgetSpec<T extends keyof typeof WidgetType> {
118
+ /**
119
+ * The type of widget to be used. Widgets can only be used with matching specific data types.
120
+ * For example the `Text` widget can be used with the `string` field type.
121
+ */
122
+ type: T;
123
+ }
124
+ /**
125
+ * A simple text field input widget.
126
+ */
127
+ interface TextWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Text']> {
128
+ placeholder?: string;
129
+ multiline?: boolean;
130
+ rows?: number;
131
+ }
132
+ /**
133
+ * String field input widget.
134
+ */
135
+ type StringWidget = TextWidgetSpec | DropdownWidgetSpec;
136
+ interface NumberWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Number']> {
137
+ placeholder?: string;
138
+ min?: number;
139
+ max?: number;
140
+ currencyChar?: string;
141
+ decimalPlaces?: number;
142
+ step?: number;
143
+ }
144
+ interface CheckboxGroupWidgetSpec extends BaseWidgetSpec<typeof WidgetType['CheckboxGroup']> {
145
+ group: Array<{
146
+ value: string;
147
+ label: string;
148
+ }>;
149
+ }
150
+ type CheckboxGroupWidget = CheckboxGroupWidgetSpec;
151
+ interface RadioGroupWidgetSpec extends BaseWidgetSpec<typeof WidgetType['RadioGroup']> {
152
+ group: Array<{
153
+ value: string;
154
+ label: string;
155
+ }>;
156
+ }
157
+ type RadioGroupWidget = RadioGroupWidgetSpec;
158
+ interface DateWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Date']> {
159
+ minDate?: Date | null;
160
+ maxDate?: Date | null;
161
+ }
162
+ type TimeWidgetSpec = BaseWidgetSpec<typeof WidgetType['Time']>;
163
+ type DateWidget = DateWidgetSpec;
164
+ type TimeWidget = TimeWidgetSpec;
165
+ interface DropdownWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Dropdown']> {
166
+ placeholder?: string;
167
+ options: Array<{
168
+ value: string;
169
+ label: string;
170
+ }>;
171
+ }
172
+ /**
173
+ * Number field input widget.
174
+ */
175
+ type NumberWidget = NumberWidgetSpec;
176
+ type ToggleWidgetSpec = BaseWidgetSpec<typeof WidgetType['Toggle']>;
177
+ type CheckboxWidgetSpec = BaseWidgetSpec<typeof WidgetType['Checkbox']>;
178
+ type BooleanWidget = ToggleWidgetSpec | CheckboxWidgetSpec;
179
+
180
+ /**
181
+ * When you make a form, you provide a list of [[FormFields]]. Each FormField contains the ingredients to make a single widget in the form.
182
+ * The actual definitions of the widgets are derived from [[BaseWidgetSpec]].
183
+ *
184
+ * A FormField contains the type of data, the key to store the user input into [[CustomDataWithForms]], and some additional configuration.
185
+ * @module FormFields
186
+ */
187
+ /**
188
+ * imports.
189
+ */
190
+
191
+ /**
192
+ * Data type of a fields. e.g. string, number
193
+ */
194
+ declare const FieldType: {
195
+ readonly string: "string";
196
+ readonly number: "number";
197
+ readonly boolean: "boolean";
198
+ readonly date: "date";
199
+ readonly checkboxGroup: "checkboxGroup";
200
+ readonly radioGroup: "radioGroup";
201
+ readonly time: "time";
202
+ };
203
+ /**
204
+ * An abstract validation entry.
205
+ */
206
+ interface ValidationEntry<T = any> {
207
+ /**
208
+ * Message displayed to the user when input is invalid.
209
+ */
210
+ invalidMessage?: string;
211
+ /**
212
+ * Validation argument to test against.
213
+ */
214
+ arg?: T;
215
+ }
216
+ /**
217
+ * The base type for form fields.
218
+ */
219
+ interface BaseField<T extends keyof typeof FieldType, D = unknown> {
220
+ /**
221
+ * Field data type.
222
+ */
223
+ type: T;
224
+ /**
225
+ * The property key that this field value will appear in the returned {@link NotificationFormSubmittedEvent.form|form} object.
226
+ */
227
+ key: string;
228
+ /**
229
+ * Default value for field, and where it will be written to
230
+ */
231
+ value?: D;
232
+ /**
233
+ * Validation rules used to validate user input.
234
+ */
235
+ validation?: Record<string, any>;
236
+ /**
237
+ * Input label.
238
+ */
239
+ label?: string;
240
+ /**
241
+ * Helper text.
242
+ */
243
+ helperText?: string;
244
+ }
245
+ /**
246
+ * String field within a form.
247
+ */
248
+ interface StringField<W extends StringWidget = StringWidget> extends BaseField<'string', string> {
249
+ validation?: Partial<{
250
+ /**
251
+ * Minimum number of characters.
252
+ */
253
+ min: ValidationEntry<number>;
254
+ /**
255
+ * Maximum number of characters.
256
+ */
257
+ max: ValidationEntry<number>;
258
+ /**
259
+ * Length of the input string.
260
+ */
261
+ length: ValidationEntry<number>;
262
+ /**
263
+ * The field is required to be filled in by the user.
264
+ */
265
+ required: ValidationEntry;
266
+ /**
267
+ * Provide a regex string that will be tested against the input value.
268
+ */
269
+ match: ValidationEntry<string>;
270
+ }>;
271
+ /**
272
+ * What input widget is used.
273
+ * @default StringWidgets {@link StringWidgets}
274
+ */
275
+ widget: W;
276
+ }
277
+ /**
278
+ * Number field within a form.
279
+ */
280
+ interface NumberField<W extends NumberWidget = NumberWidget> extends BaseField<'number', number> {
281
+ validation?: Partial<{
282
+ /**
283
+ * Minimum number of characters.
284
+ */
285
+ min: ValidationEntry<number>;
286
+ /**
287
+ * Maximum number of characters.
288
+ */
289
+ max: ValidationEntry<number>;
290
+ /**
291
+ * Number must be less than this.
292
+ */
293
+ lessThan: ValidationEntry<number>;
294
+ /**
295
+ * Number must be more than this.
296
+ */
297
+ moreThan: ValidationEntry<number>;
298
+ /**
299
+ * Number must be positive.
300
+ */
301
+ positive: ValidationEntry;
302
+ /**
303
+ * Number must be negative.
304
+ */
305
+ negative: ValidationEntry;
306
+ /**
307
+ * The field is required to be filled in by the user.
308
+ */
309
+ required: ValidationEntry;
310
+ }>;
311
+ widget: W;
312
+ }
313
+ interface BooleanField<W extends BooleanWidget = BooleanWidget> extends BaseField<'boolean', boolean> {
314
+ widget: W;
315
+ }
316
+ type DateFieldValue = {
317
+ date?: number;
318
+ month?: number;
319
+ year?: number;
320
+ };
321
+ interface DateField<W extends DateWidget = DateWidget> extends BaseField<'date', DateFieldValue> {
322
+ widget: W;
323
+ }
324
+ type TimeFieldValue = {
325
+ hour?: number;
326
+ minute?: number;
327
+ };
328
+ interface TimeField<W extends TimeWidget = TimeWidget> extends BaseField<'time', TimeFieldValue> {
329
+ widget: W;
330
+ }
331
+ interface RadioGroupField<W extends RadioGroupWidget = RadioGroupWidget> extends BaseField<'radioGroup', string> {
332
+ widget: W;
333
+ }
334
+ interface CheckboxGroupField<W extends CheckboxGroupWidget = CheckboxGroupWidget> extends BaseField<'checkboxGroup', Array<string>> {
335
+ widget: W;
336
+ }
337
+ /**
338
+ * A field in a form.
339
+ */
340
+ type FormField = StringField | NumberField | BooleanField | DateField | RadioGroupField | CheckboxGroupField | TimeField;
341
+ /**
342
+ * A field in a form.
343
+ *
344
+ * The difference with [[FormField]] is that the label property is required.
345
+ */
346
+ type FormFieldWithRequiredLabel = MakePropertyRequired<FormField, 'label'>;
347
+ /**
348
+ * An ordered array of fields representing a form.
349
+ * When the form is displayed to the user the fields will appear in the same order they are in the array.
350
+ */
351
+ type NotificationFormData = ReadonlyArray<FormField>;
352
+ /**
353
+ * An ordered array of fields representing a form.
354
+ * When the form is displayed to the user the fields will appear in the same order they are in the array.
355
+ *
356
+ * The difference with [[NotificationFormData]] is that the label property is required for each field.
357
+ */
358
+ type NotificationFormDataWithRequiredLabel = ReadonlyArray<FormFieldWithRequiredLabel>;
359
+
360
+ type FormStatus = 'not-submitted' | 'submitting' | 'submitted';
361
+ interface FormStatusOptions {
362
+ /**
363
+ * Controls form status,
364
+ */
365
+ formStatus: FormStatus;
366
+ /**
367
+ * Sets error message at the top of the form.
368
+ */
369
+ error?: string;
370
+ _notificationId: string;
371
+ }
372
+ type CustomValidationError = {
373
+ fieldKey: string;
374
+ error: string;
375
+ };
376
+
377
+ /**
378
+ * OpenFin Notification Templates API Version 1
379
+ *
380
+ * @module Templates
381
+ */
382
+ /**
383
+ * imports
384
+ */
385
+
386
+ type SectionAlignment = 'left' | 'center' | 'right';
387
+ type ListPairs = [string, string][];
388
+ type CustomTemplateData = Record<string, string | ListPairs>;
389
+ /**
390
+ * The options you pass to the [[create]] function to generate a notification.
391
+ */
392
+ type NotificationOptions = TemplateMarkdown | TemplateList | TemplateCustom;
393
+ /**
394
+ * The options to build your custom template composition layout.
395
+ */
396
+ type TemplateFragment = ContainerTemplateFragment | TextTemplateFragment | ListTemplateFragment | ImageTemplateFragment | ActionableTextTemplateFragment;
397
+ declare const TemplateNames: {
398
+ readonly markdown: "markdown";
399
+ readonly list: "list";
400
+ readonly custom: "custom";
401
+ };
402
+ declare const PresentationTemplateFragmentNames: {
403
+ readonly text: "text";
404
+ readonly image: "image";
405
+ readonly list: "list";
406
+ readonly actionableText: "actionableText";
407
+ };
408
+ declare const TemplateFragmentNames: {
409
+ readonly text: "text";
410
+ readonly image: "image";
411
+ readonly list: "list";
412
+ readonly actionableText: "actionableText";
413
+ readonly container: "container";
414
+ };
415
+ interface TemplateComposition {
416
+ /**
417
+ * Minimum Template API version required for the service to render this composition.
418
+ *
419
+ * For example, a composition that consists only of container, text, image, or list
420
+ * fragments must declare a minimum template API version of "1".
421
+ *
422
+ * See {@link BodyTemplateOptions} for more details.
423
+ */
424
+ minTemplateAPIVersion: string;
425
+ /**
426
+ * Root of the template composition tree. See {@link ContainerTemplateFragment} for nesting.
427
+ */
428
+ layout: TemplateFragment;
429
+ }
430
+ interface IndicatorTemplateOptions {
431
+ /**
432
+ * Alignment of the notification's indicator section.
433
+ *
434
+ * Can be `left`, `center` or `right`.
435
+ *
436
+ * The default value is `center`.
437
+ */
438
+ align?: SectionAlignment;
439
+ /**
440
+ * Color of the indicator bar.
441
+ *
442
+ * Note: {@link BaseNotificationOptions|Notification's indicator color} definition has precedence over Template definition.
443
+ * Template's indicator color value will be taken into account only if the notification itself doesn't have the indicator color
444
+ * specified.
445
+ */
446
+ color?: IndicatorColor;
447
+ }
448
+ interface ButtonTemplateOptions {
449
+ /**
450
+ * Alignment of the notification's button section.
451
+ *
452
+ * Can be `left`, `center` or `right`.
453
+ *
454
+ * The default value is `right`.
455
+ */
456
+ align?: SectionAlignment;
457
+ }
458
+ interface BodyTemplateOptions {
459
+ /**
460
+ * A list of template compositions.
461
+ *
462
+ * You can include multiple compositions with different minimum Template API version to create fallback compositions and support the
463
+ * earlier versions of Notification Center (Starting from the Template API version 1).
464
+ *
465
+ * The service will search for the composition with the version number matching the Template API version it is supporting.
466
+ * If this doesn't exist, the service will then select the composition with the nearest version number smaller than the Template API version
467
+ * it is supporting and render the notification card with that composition.
468
+ */
469
+ compositions: TemplateComposition[];
470
+ /**
471
+ * Composition fallback text.
472
+ *
473
+ * The service will render this text instead of the notification body section if there are no compatible compositions found in the template.
474
+ *
475
+ * (E.g. All of the compositions in the template declare a greater minimum Template API version than the version supported by the running
476
+ * service instance.)
477
+ *
478
+ */
479
+ fallbackText?: string;
480
+ }
481
+ interface BaseTemplateFragment<T extends keyof typeof TemplateFragmentNames> {
482
+ /**
483
+ * Type of the template fragment.
484
+ */
485
+ type: T;
486
+ /**
487
+ * CSS style properties of the fragment.
488
+ *
489
+ * All the available custom template fragments support all of the React's inline style properties (with camelCase keys)
490
+ *
491
+ * Note: "position: fixed" is disallowed in the fragments.
492
+ */
493
+ style?: Record<string, string | number>;
494
+ }
495
+ interface ContainerTemplateFragment extends BaseTemplateFragment<'container'>, ActionableFragment {
496
+ /**
497
+ * Sub-fragments of the container.
498
+ *
499
+ * You can use container template fragment to create nested composition structures.
500
+ */
501
+ children?: TemplateFragment[];
502
+ }
503
+ interface PresentationTemplateFragment<T extends keyof typeof PresentationTemplateFragmentNames> extends BaseTemplateFragment<T> {
504
+ /**
505
+ * Optional flag.
506
+ *
507
+ * If a presentation template fragment is flagged as optional, The service will not require
508
+ * the fragment's `dataKey` to exist in `templateData`. If a fragment is optional and its data
509
+ * is missing, the fragment will be omitted quietly by the server.
510
+ */
511
+ optional?: boolean;
512
+ /**
513
+ * Data key of the template fragment.
514
+ *
515
+ * The data associated with this fragment will be looked up in `templateData` map with this key.
516
+ *
517
+ * Example:
518
+ * ```ts
519
+ * const myTemplate = {
520
+ * body: {
521
+ * compositions: [{
522
+ * minTemplateAPIVersion: '1',
523
+ * layout: {
524
+ * type: CustomTemplateFragmentNames.text,
525
+ * dataKey: 'message',
526
+ * },
527
+ * }],
528
+ * },
529
+ * }
530
+ *
531
+ * const notificationOption: TemplateCustom = {
532
+ * //...
533
+ * templateOptions: myTemplate,
534
+ * templateData: {
535
+ * message: 'My Custom Notification Message',
536
+ * }
537
+ * };
538
+ * ```
539
+ *
540
+ */
541
+ dataKey: string;
542
+ }
543
+ interface ActionableFragment {
544
+ /**
545
+ * onClick object that is user defined.
546
+ *
547
+ * If provided, notification-action event will be raised when clicking on the fragment.
548
+ *
549
+ *
550
+ * Example:
551
+ * ```ts
552
+ * {
553
+ * "type": "actionableText",
554
+ * "dataKey": "titlexyz",
555
+ * "tooltipKey": "some_key",
556
+ * "onClick": { // contents are user-defined
557
+ * "task": "schedule-reminder",
558
+ * "eventId": 142341,
559
+ * "intervalMs": 5000
560
+ * }
561
+ * }
562
+ *
563
+ * import { addEventListener, clear } from 'openfin-notifications';
564
+ *
565
+ * addEventListener('notification-action', (event: NotificationActionEvent<MyAction>)) => {
566
+ * if (event.result.task === 'schedule-reminder') {
567
+ * scheduleReminder(event.result.eventId, Date.now() + event.result.intervalMs);
568
+ * }
569
+ * clear(event.notification.id);
570
+ * });
571
+ * ```
572
+ *
573
+ */
574
+ onClick?: ActionDeclaration<never, never> | null;
575
+ /**
576
+ * Tooltip key of the template fragment.
577
+ *
578
+ * The string tooltip associated with this fragment will be looked up in templateData map with this key.
579
+ *
580
+ *
581
+ * Example:
582
+ * ```ts
583
+ * const myTemplate = {
584
+ * body: {
585
+ * compositions: [{
586
+ * minTemplateAPIVersion: '1',
587
+ * layout: {
588
+ * type: "actionableText",
589
+ * dataKey: 'message',
590
+ * tooltipKey: 'tooltipxyz',
591
+ * },
592
+ * }],
593
+ * },
594
+ * }
595
+ *
596
+ * const notificationOption: TemplateCustom = {
597
+ * //...
598
+ * templateOptions: myTemplate,
599
+ * templateData: {
600
+ * message: 'view stock tracker',
601
+ * tooltipxyz: 'My Custom Tooltip',
602
+ * }
603
+ * };
604
+ * ```
605
+ *
606
+ */
607
+ tooltipKey?: string;
608
+ }
609
+ type TextTemplateFragment = PresentationTemplateFragment<'text'>;
610
+ type ImageTemplateFragment = PresentationTemplateFragment<'image'> & ActionableFragment;
611
+ type ListTemplateFragment = PresentationTemplateFragment<'list'>;
612
+ type ActionableTextTemplateFragment = PresentationTemplateFragment<'actionableText'> & ActionableFragment;
613
+ /**
614
+ * Configuration options for the custom notification template.
615
+ */
616
+ interface CustomTemplateOptions {
617
+ /**
618
+ * Configuration options for the custom notification template body.
619
+ */
620
+ body: BodyTemplateOptions;
621
+ /**
622
+ * Configuration options for the custom notification template's modifications on the notification's indicator section.
623
+ */
624
+ indicator?: IndicatorTemplateOptions;
625
+ /**
626
+ * Configuration options for the custom notification template's modifications on the notification's button section.
627
+ */
628
+ buttons?: ButtonTemplateOptions;
629
+ }
630
+ /**
631
+ * Default markdown template. Contains a markdown body and forms data.
632
+ */
633
+ interface TemplateMarkdown extends Omit<BaseNotificationOptions<'markdown'>, 'template'> {
634
+ template?: 'markdown';
635
+ /**
636
+ * Notification body text.
637
+ *
638
+ * This is the main notification content, displayed below the notification title. The notification will expand to fit the length of this text.
639
+ * Markdown may be used in the body text to control how it is styled when rendered.
640
+ * With the exception of links and code blocks, all basic syntax as documented [here](https://www.markdownguide.org/basic-syntax) is supported.
641
+ */
642
+ body: string;
643
+ /**
644
+ * A collection of form fields or a form definition (Form<FormField>)
645
+ * @example
646
+ * ```ts
647
+ * [
648
+ * {
649
+ * key: 'phone',
650
+ * type: 'string',
651
+ * label: 'Phone',
652
+ * helperText:
653
+ * 'Must be in the following formats 123-456-7890, 123 456 7890, (123) 456 7890 or 1234567890',
654
+ * widget: {
655
+ * type: 'Text'
656
+ * },
657
+ * validation: {
658
+ * required: {
659
+ * arg: true
660
+ * }
661
+ * }
662
+ * },
663
+ * {
664
+ * key: 'email',
665
+ * type: 'string',
666
+ * label: 'Email',
667
+ * helperText: 'We will use this email to send you the report after we crawl your website',
668
+ * widget: {
669
+ * type: 'Text'
670
+ * },
671
+ * validation: {
672
+ * required: {
673
+ * arg: true
674
+ * }
675
+ * }
676
+ * }
677
+ * ]
678
+ * ```
679
+ */
680
+ form?: NotificationFormData | Form<FormField> | null;
681
+ }
682
+ /**
683
+ * Simple template that can render a list of name-value pairs.
684
+ */
685
+ interface TemplateList extends BaseNotificationOptions<'list'> {
686
+ /**
687
+ * Notification list template data.
688
+ */
689
+ list: Record<string, string>;
690
+ }
691
+ /**
692
+ * Notification that renders custom templates.
693
+ */
694
+ interface TemplateCustom extends BaseNotificationOptions<'custom'> {
695
+ templateOptions: CustomTemplateOptions;
696
+ /**
697
+ * Data associated with the custom notification template's presentation fragments.
698
+ */
699
+ templateData: CustomTemplateData;
700
+ /**
701
+ * A collection of form fields or a form definition (Form<FormField>)
702
+ * @example
703
+ * ```ts
704
+ * [
705
+ * {
706
+ * key: 'phone',
707
+ * type: 'string',
708
+ * label: 'Phone',
709
+ * helperText:
710
+ * 'Must be in the following formats 123-456-7890, 123 456 7890, (123) 456 7890 or 1234567890',
711
+ * widget: {
712
+ * type: 'Text'
713
+ * },
714
+ * validation: {
715
+ * required: {
716
+ * arg: true
717
+ * }
718
+ * }
719
+ * },
720
+ * {
721
+ * key: 'email',
722
+ * type: 'string',
723
+ * label: 'Email',
724
+ * helperText: 'We will use this email to send you the report after we crawl your website',
725
+ * widget: {
726
+ * type: 'Text'
727
+ * },
728
+ * validation: {
729
+ * required: {
730
+ * arg: true
731
+ * }
732
+ * }
733
+ * }
734
+ * ]
735
+ * ```
736
+ */
737
+ form?: NotificationFormDataWithRequiredLabel | Form<FormFieldWithRequiredLabel> | null;
738
+ }
739
+ interface FormSettings {
740
+ /**
741
+ * Controls that display of (Required) or (Optional) labels next to form fields.
742
+ */
743
+ displayFieldRequirementStatus?: boolean;
744
+ }
745
+ interface Form<T extends FormField | FormFieldWithRequiredLabel> extends FormSettings {
746
+ /**
747
+ * A collection of form fields.
748
+ * @example
749
+ * ```ts
750
+ * [
751
+ * {
752
+ * key: 'phone',
753
+ * type: 'string',
754
+ * label: 'Phone',
755
+ * helperText:
756
+ * 'Must be in the following formats 123-456-7890, 123 456 7890, (123) 456 7890 or 1234567890',
757
+ * widget: {
758
+ * type: 'Text'
759
+ * },
760
+ * validation: {
761
+ * required: {
762
+ * arg: true
763
+ * }
764
+ * }
765
+ * },
766
+ * {
767
+ * key: 'email',
768
+ * type: 'string',
769
+ * label: 'Email',
770
+ * helperText: 'We will use this email to send you the report after we crawl your website',
771
+ * widget: {
772
+ * type: 'Text'
773
+ * },
774
+ * validation: {
775
+ * required: {
776
+ * arg: true
777
+ * }
778
+ * }
779
+ * }
780
+ * ]
781
+ * ```
782
+ */
783
+ fields: ReadonlyArray<T>;
784
+ }
785
+
786
+ /**
787
+ * Core notification features.
788
+ *
789
+ * @module BaseNotificationOptions
790
+ */
791
+ /**
792
+ * imports
793
+ */
794
+
795
+ /**
796
+ * Configuration options for constructing a Notifications object, shared between all templates.
797
+ */
798
+ interface BaseNotificationOptions<T extends keyof typeof TemplateNames> {
799
+ /**
800
+ * A unique identifier for the notification.
801
+ *
802
+ * If not provided at time of creation, one will be generated for you and returned as part of the {@link create} method.
803
+ */
804
+ id?: string;
805
+ /**
806
+ * Template of the notification payload.
807
+ */
808
+ template: T;
809
+ /**
810
+ * Title of the notification.
811
+ *
812
+ * Displayed as the first line of the notification, in a heading style.
813
+ */
814
+ title: string;
815
+ /**
816
+ * If set to false, the user won't be able to set a reminder for this notification in the Notification Center.
817
+ *
818
+ * Default value is `true`.
819
+ */
820
+ allowReminder?: boolean;
821
+ /**
822
+ * Describes the context of this notification. Allows users to control different notification types that are raised
823
+ * by an application.
824
+ *
825
+ * This string is not displayed on the notification itself, but should be user-readable. It will be displayed in
826
+ * the Notification Center preferences section, and any string passed as a `category` should make sense when
827
+ * displayed in that context.
828
+ *
829
+ * Event categories should list all the different types of notifications raised by your app. As a general guide, if
830
+ * a user may want to have different preferences for some subset of notifications created by your app, then
831
+ * applications should ensure that those notifications have a distinct category.
832
+ *
833
+ * @deprecated This property is deprecated and will be removed in a future release.
834
+ */
835
+ category?: string;
836
+ /**
837
+ * Add a semantic visual indicator to a notification, to signal to the user the nature of the event that they are
838
+ * being notified about.
839
+ *
840
+ * This should not be treated as a priority.
841
+ */
842
+ indicator?: NotificationIndicator | NotificationIndicatorWithCustomColor | null;
843
+ /**
844
+ * URL of the icon to be displayed in the notification.
845
+ */
846
+ icon?: string;
847
+ /**
848
+ * Application-defined context data that can be attached to buttons on notifications.
849
+ *
850
+ * When using forms, form data submitted will be written to `customData` and returned to your app by
851
+ * listening to the submit {@link NotificationActionEvent|`notification-action`} with the trigger {@link ActionTrigger.SUBMIT|submit}.
852
+ */
853
+ customData?: CustomData;
854
+ /**
855
+ * The timestamp shown on the notification. If omitted, the current date/time will be used.
856
+ *
857
+ * This is presentational only - a date in the future does not incur a scheduling action.
858
+ */
859
+ date?: Date;
860
+ /**
861
+ * The expiry date and time of the notification. If specified, the notification will be removed at this time, or as
862
+ * soon as possible after. If not specified, the notification will never expire, and will persist until it
863
+ * is closed.
864
+ */
865
+ expires?: Date | null;
866
+ /**
867
+ * When set to `sticky` this settings enables the notification toast to stay visible on the desktop
868
+ * until the user interacts with it. When set to `transient` the toasts will follow the default behavior
869
+ * of fading away after a short duration. When set to `none` the toasts will not appear and the notification
870
+ * will only appear in the Notification Center.
871
+ *
872
+ * This property has a precedence over `sticky` propery.
873
+ *
874
+ */
875
+ toast?: 'sticky' | 'transient' | 'none';
876
+ /**
877
+ * @deprecated
878
+ *
879
+ * This property is deprecated. Use `toast` instead.
880
+ */
881
+ sticky?: 'sticky' | 'transient';
882
+ /**
883
+ * A list of buttons to display below the notification text.
884
+ *
885
+ * Notifications support up to four buttons. Attempting to add more than four will result in the notification
886
+ * being rejected by the service.
887
+ */
888
+ buttons?: ButtonOptions[];
889
+ /**
890
+ * Notification Stream
891
+ *
892
+ * If the notification belongs to a stream, the user will be able to group notifications by stream.
893
+ */
894
+ stream?: NotificationStream | null;
895
+ /**
896
+ * Id of the platform this notification belongs to.
897
+ *
898
+ * If the application belongs to a platform, the user interaction with the notification will be dispatched
899
+ * back to the platform provider.
900
+ */
901
+ platform?: string | null;
902
+ /**
903
+ * An {@link NotificationActionResult|action result} to be passed back to the application inside the
904
+ * {@link NotificationActionEvent|`notification-action`} event fired when the notification is clicked.
905
+ *
906
+ * This action will only be raised on clicks to the notification body. Interactions with buttons (both
907
+ * application-defined buttons, and the default 'X' close button) or with actionable fragments will not trigger a
908
+ * {@link ActionTrigger.SELECT|select} action.
909
+ *
910
+ * See {@link Actions} for more details on notification actions, and receiving action events from notifications.
911
+ */
912
+ onSelect?: (ActionDeclaration<never, never> & ActionNoop & ActionBodyClick) | null;
913
+ /**
914
+ * An {@link NotificationActionResult|action result} to be passed back to the application inside the
915
+ * {@link NotificationActionEvent|`notification-action`} event fired when the notification the expires.
916
+ *
917
+ * If `expires` is specified for the notification, this action will be raised when the notification expires. If
918
+ * `expires` is not specified for the notification, this action will never be raised. Note that if an `onClose`
919
+ * action result is also specified, both actions will be raised if and when the notification expires.
920
+ *
921
+ * See {@link Actions} for more details on notification actions, and receiving action events from notifications.
922
+ */
923
+ onExpire?: ActionDeclaration<never, never> | null;
924
+ /**
925
+ * An {@link NotificationActionResult|action result} to be passed back to the application inside the
926
+ * {@link NotificationActionEvent|`notification-action`} event fired when the notification is closed.
927
+ *
928
+ * This action is raised regardless of how the notification is closed, whether from user interaction, expiration,
929
+ * or programmatic removal -- such as a call to `clear`.
930
+ *
931
+ * See {@link Actions} for more details on notification actions, and receiving action events from notifications.
932
+ */
933
+ onClose?: ActionDeclaration<never, never> | null;
934
+ /**
935
+ * A priority for this notification. It's from 1 - 4.
936
+ */
937
+ priority?: number;
938
+ /**
939
+ * Sound options for a notification.
940
+ */
941
+ soundOptions?: NotificationSoundOptions;
942
+ }
943
+
944
+ /**
945
+ * Configuration options for constructing an updatable Notifications object, shared between all templates.
946
+ */
947
+ interface BaseUpdatableNotificationOptions<T extends keyof typeof TemplateNames> {
948
+ /**
949
+ * A unique identifier for the notification.
950
+ *
951
+ * Mandatory field for Notification updates.
952
+ */
953
+ id: string;
954
+ /**
955
+ * description of update type 'markdown', 'list' or 'custom'
956
+ */
957
+ template?: T;
958
+ /**
959
+ * Application-defined context data that can be attached to buttons on notifications.
960
+ *
961
+ * When using forms, form data submitted will be written to `customData` and returned to your app by
962
+ * listening to the submit {@link NotificationActionEvent|`notification-action`} with the trigger {@link ActionTrigger.SUBMIT|submit}.
963
+ */
964
+ customData?: CustomData;
965
+ /**
966
+ * A list of buttons to display below the notification text.
967
+ *
968
+ * Notifications support up to four buttons. Attempting to add more than four will result in the notification
969
+ * being rejected by the service.
970
+ */
971
+ buttons?: ButtonOptions[];
972
+ }
973
+
974
+ /**
975
+ * Default markdown template update.
976
+ */
977
+ interface UpdatableNotificationTemplateMarkdown extends Omit<BaseUpdatableNotificationOptions<'markdown'>, 'template'> {
978
+ template?: 'markdown';
979
+ body?: string;
980
+ form?: NotificationFormData | null;
981
+ }
982
+ /**
983
+ * Simple template that can render a list of name-value pairs.
984
+ */
985
+ interface UpdatableNotificationTemplateList extends BaseUpdatableNotificationOptions<'list'> {
986
+ /**
987
+ * Notification list template data.
988
+ */
989
+ list?: Record<string, string>;
990
+ }
991
+ /**
992
+ * Update Payload for Custom Template Notification.
993
+ * This will let you update the template data associated with the existing template
994
+ * composition of the notification template.
995
+ */
996
+ interface UpdatableNotificationTemplateCustom extends BaseUpdatableNotificationOptions<'custom'> {
997
+ /**
998
+ * Data associated with the custom notification template's presentation fragments.
999
+ */
1000
+ templateData?: CustomTemplateData;
1001
+ form?: NotificationFormData | null;
1002
+ }
1003
+ type UpdatableNotificationOptions = UpdatableNotificationTemplateMarkdown | UpdatableNotificationTemplateList | UpdatableNotificationTemplateCustom;
1004
+
1005
+ /**
1006
+ * Notifications allow additional UI components to be specified by applications. The service controls the
1007
+ * positioning and styling of these components.
1008
+ *
1009
+ * @module Controls
1010
+ */
1011
+ /**
1012
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1013
+ * import below.
1014
+ *
1015
+ * @hidden
1016
+ */
1017
+
1018
+ /**
1019
+ * Helper to make the `type` field required on any type that defines it as being optional.
1020
+ */
1021
+ type WithExplicitType<T extends {
1022
+ type?: string;
1023
+ }> = T & {
1024
+ type: string;
1025
+ };
1026
+ /**
1027
+ * *Not yet implemented*
1028
+ *
1029
+ * Union of the options objects of all "primary control" components supported by the service.
1030
+ */
1031
+ type PrimaryControlOptions = never;
1032
+ /**
1033
+ * Union of options objects of all components that can be added to a notification, includes both buttons and primary
1034
+ * controls.
1035
+ */
1036
+ type ControlOptions = Required<PrimaryControlOptions | WithExplicitType<ButtonOptions>> | WithExplicitType<ActionableTextTemplateFragment> | WithExplicitType<ImageTemplateFragment> | WithExplicitType<ContainerTemplateFragment>;
1037
+ /**
1038
+ * Configuration options for constructing a button within a notification.
1039
+ */
1040
+ interface ButtonOptions {
1041
+ /**
1042
+ * The type of the control. Optional, added automatically if `NotificationOptions.buttons` includes the `onClick`
1043
+ * property and therefore generates a `notification-action` event.
1044
+ */
1045
+ type?: 'button';
1046
+ /**
1047
+ * User-facing button text.
1048
+ *
1049
+ * The button caption should be kept short, particularly if there are multiple buttons. Notifications are
1050
+ * fixed-width, and all buttons will be displayed on the same row.
1051
+ */
1052
+ title: string;
1053
+ /**
1054
+ * Indicates that this button will be visually displayed as a 'Call to Action' button. In this case a Call To Action
1055
+ * means the button is made more prominent. We recommend you use this for true calls to action. For example, if you
1056
+ * have a notification which contains a report, it might have an 'OK' button which takes you to the report, and a
1057
+ * 'Dismiss' button which simply closes the notification. We suggest you make only the 'OK' button a CTA here.'
1058
+ *
1059
+ * If set as `false` or `undefined`, the default simple text button will be used instead.
1060
+ */
1061
+ cta?: boolean;
1062
+ /**
1063
+ * Indicates that this button should submit a form.
1064
+ * If a form is invalid, based on your validation rules provided, the button will be disabled until the users input within the form is valid.
1065
+ */
1066
+ submit?: boolean;
1067
+ /**
1068
+ * @deprecated
1069
+ * Optional icon URL, if an icon should be placed on the button.
1070
+ *
1071
+ * Icons are placed to the left of the button text.
1072
+ */
1073
+ iconUrl?: string;
1074
+ /**
1075
+ * Defines the data to be passed back to the application when the button is clicked.
1076
+ *
1077
+ * The {@link NotificationActionResult} specified here will be returned to the application via a
1078
+ * `notification-action` event when the button is clicked.
1079
+ *
1080
+ * If omitted or `null`, applications will not receive a {@link NotificationActionEvent|`notification-action`}
1081
+ * event when the button is clicked. This may be appropriate if the button represents a "dismiss" or some other
1082
+ * side-effect-free interaction. Even if `onClick` is omitted or `null`, a `notification-closed` event will still be
1083
+ * raised after the button click.
1084
+ *
1085
+ */
1086
+ onClick?: ActionDeclaration<never, never> | null;
1087
+ /**
1088
+ * Button index used for events. This gets set when hydrating.
1089
+ *
1090
+ * @hidden
1091
+ */
1092
+ index?: number;
1093
+ formOptions?: {
1094
+ /**
1095
+ * Title to display on a button when form is submitting.
1096
+ */
1097
+ submittingTitle?: string | null;
1098
+ /**
1099
+ * Title to display on a button when form is in the error state.
1100
+ */
1101
+ errorTitle?: string | null;
1102
+ /**
1103
+ * Title to display on a button when form is in the success state.
1104
+ */
1105
+ successTitle?: string | null;
1106
+ } | null;
1107
+ }
1108
+
1109
+ /**
1110
+ * @module Provider
1111
+ */
1112
+ /**
1113
+ * Status object returned by the Provider.
1114
+ */
1115
+ interface ProviderStatus {
1116
+ /**
1117
+ * The current connection status from the Client to the Provider.
1118
+ */
1119
+ connected: boolean;
1120
+ /**
1121
+ * The version number of the Provider. If the Provider is not connected, this will be `null`.
1122
+ */
1123
+ version: string | null;
1124
+ /**
1125
+ * The version number of the Templates API. If the Provider is not connected, this will be `null`.
1126
+ */
1127
+ templateAPIVersion?: string | null;
1128
+ }
1129
+
1130
+ /**
1131
+ * @hidden
1132
+ */
1133
+ /**
1134
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1135
+ * import below.
1136
+ *
1137
+ * @hidden
1138
+ */
1139
+ /**
1140
+ * For notifications that have originated from an application running on the same machine as the provider.
1141
+ */
1142
+ interface NotificationSourceDesktop {
1143
+ type: 'desktop';
1144
+ /**
1145
+ * The identity of the window that raised this notification.
1146
+ *
1147
+ * This will always be a window of the current application - but
1148
+ * could have been raised by an instance of this application
1149
+ * running on a different machine.
1150
+ */
1151
+ identity: OpenFin.Identity;
1152
+ /**
1153
+ * The origin of the notification, which is the url of the window that raised the notification.
1154
+ * This property is optional to support backward compatibility with sources that do not have the origin starting with version 2.7.1.
1155
+ */
1156
+ origin?: string;
1157
+ }
1158
+ /**
1159
+ * Union of all possible notification sources.
1160
+ */
1161
+ type NotificationSource = NotificationSourceDesktop;
1162
+
1163
+ /**
1164
+ * @module Notifications
1165
+ */
1166
+ /**
1167
+ * Sound options for a notification
1168
+ */
1169
+ interface NotificationSoundOptions {
1170
+ /**
1171
+ * Determines the sound that will be played when a notification is received.
1172
+ *
1173
+ * @default 'default' plays the default notification sound.
1174
+ */
1175
+ mode: 'default' | 'silent';
1176
+ }
1177
+
1178
+ /**
1179
+ * @module Notifications
1180
+ */
1181
+ /**
1182
+ * Details of the application that will handle any actions coming from a particular stream.
1183
+ */
1184
+ interface NotificationStream {
1185
+ /**
1186
+ * Unique id of the stream.
1187
+ */
1188
+ id: string;
1189
+ /**
1190
+ * Stream title.
1191
+ *
1192
+ * Providing a different displayName for an existing stream id will update the
1193
+ * displayName of the stream stored in Notification Center.
1194
+ *
1195
+ */
1196
+ displayName: string;
1197
+ /**
1198
+ * ID of the application source of this stream.
1199
+ */
1200
+ appId: string;
1201
+ }
1202
+
1203
+ interface NotificationsThemeSet extends ThemeSet {
1204
+ light: ThemeExtension;
1205
+ dark: ThemeExtension;
1206
+ }
1207
+ interface ThemeExtension extends DefaultTheme {
1208
+ notificationIndicatorColors?: Record<string, NotificationIndicatorColorsSet>;
1209
+ }
1210
+ interface NotificationIndicatorColorsSet {
1211
+ background: string;
1212
+ foreground: string;
1213
+ }
1214
+ declare module 'styled-components' {
1215
+ interface DefaultTheme {
1216
+ notificationIndicatorColors?: Record<string, NotificationIndicatorColorsSet>;
1217
+ }
1218
+ }
1219
+
1220
+ interface NotificationsPlatform {
1221
+ /**
1222
+ * Unique identifier of the platform.
1223
+ */
1224
+ id: string;
1225
+ /**
1226
+ * Stream title.
1227
+ *
1228
+ * Providing a different displayName for an existing stream id will update the
1229
+ * displayName of the stream stored in Notification Center.
1230
+ *
1231
+ */
1232
+ title: string;
1233
+ /**
1234
+ * URL of the icon to be displayed for this platform.
1235
+ */
1236
+ icon: string;
1237
+ /**
1238
+ * This is the theme associated with this platform. The center will be themed accordingly
1239
+ * when the platform is selected.
1240
+ */
1241
+ theme?: NotificationsThemeSet;
1242
+ /**
1243
+ * This is the scheme associated with this platform.
1244
+ */
1245
+ scheme?: ColorSchemeOption;
1246
+ /**
1247
+ * Workspace platform that registers this platform
1248
+ */
1249
+ workspacePlatform?: {
1250
+ /**
1251
+ * @deprecated
1252
+ */
1253
+ identity: OpenFin.ApplicationIdentity;
1254
+ analytics: {
1255
+ isSupported: boolean;
1256
+ };
1257
+ };
1258
+ platformIdentity: OpenFin.ApplicationIdentity;
1259
+ }
1260
+ type PlatformRegisterPayload<T extends NotificationsPlatform = NotificationsPlatform> = Omit<T, 'platformIdentity'>;
1261
+ interface PlatformDeregisterPayload {
1262
+ id: string;
1263
+ }
1264
+
1265
+ /**
1266
+ * @module NotificationCenter
1267
+ */
1268
+ /**
1269
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1270
+ * import below.
1271
+ *
1272
+ * @hidden
1273
+ */
1274
+
1275
+ /**
1276
+ * Application-defined context data that can be attached to buttons on notifications.
1277
+ */
1278
+ type CustomData = Record<string, any>;
1279
+ /**
1280
+ * A fully-hydrated form of {@link NotificationOptions}.
1281
+ *
1282
+ * After {@link create|creating} a notification, the service will return an object of this type. This will be the given
1283
+ * options object, with any unspecified fields filled-in with default values.
1284
+ *
1285
+ * This object should be treated as immutable. Modifying its state will not have any effect on the notification or the
1286
+ * state of the service.
1287
+ */
1288
+ type Notification<T extends NotificationOptions = NotificationOptions> = Readonly<Required<DistributiveOmit<T, 'buttons'>> & {
1289
+ readonly buttons: ReadonlyArray<Required<ButtonOptions>>;
1290
+ }>;
1291
+ /**
1292
+ * Event fired when an action is raised for a notification due to a specified trigger. It is important to note that
1293
+ * applications will only receive these events if they indicate to the service that they want to receive these events.
1294
+ * See {@link actions} for a full example of how actions are defined, and how an application can listen to and handle
1295
+ * them.
1296
+ *
1297
+ * This can be fired due to interaction with notification buttons or the notification itself, the notification being
1298
+ * closed (either by user interaction or by API call), or by the notification expiring. Later versions of the service
1299
+ * will add additional control types that may raise actions from user interaction. All actions, for all control types,
1300
+ * will be returned to the application via the same `notification-action` event type.
1301
+ *
1302
+ * The event object will contain the application-defined {@link NotificationActionResult|metadata} that allowed this
1303
+ * action to be raised, and details on what triggered this action and which control the user interacted with.
1304
+ *
1305
+ * Unlike other event types, `notification-action` events will be buffered by the service until the application has
1306
+ * added a listener for this event type, at which point it will receive all buffered `notification-action` events. The
1307
+ * service will also attempt to restart the application if it is not running when the event is fired.
1308
+ *
1309
+ * This type includes a generic type argument, should applications wish to define their own interface for action
1310
+ * results. See {@link NotificationActionResult} for details.
1311
+ *
1312
+ * @event "notification-action"
1313
+ */
1314
+ interface NotificationActionEvent<T = CustomData> {
1315
+ type: 'notification-action';
1316
+ /**
1317
+ * The notification that created this action
1318
+ */
1319
+ notification: Readonly<Notification>;
1320
+ /**
1321
+ * This property allows the application handling the action to identify where this notification originated.
1322
+ */
1323
+ source: NotificationSource;
1324
+ /**
1325
+ * Indicates what triggered this action.
1326
+ *
1327
+ * Note that the `programmatic` trigger is not yet implemented.
1328
+ */
1329
+ trigger: ActionTrigger;
1330
+ /**
1331
+ * The control whose interaction resulted in this action being raised. Will only be present when {@link trigger} is
1332
+ * {@link ActionTrigger.CONTROL}.
1333
+ *
1334
+ * Future versions of the service will add additional controls beyond buttons, and interactions with these new
1335
+ * control types will also come through this one event type. For best forward-compatibility, applications should
1336
+ * always check the `type` property of this control, and not assume that the type will always be `'button'`.
1337
+ *
1338
+ * This field is marked optional as future versions of the service will also include alternate methods of raising
1339
+ * `notification-action` events that do not originate from a button or other control.
1340
+ *
1341
+ * When present, the object here will always be strictly equal to one of the control definitions within
1342
+ * `notification`. This means `indexOf` checks and other equality checks can be performed on this field if
1343
+ * required, such as:
1344
+ *
1345
+ * ```ts
1346
+ * function onNotificationAction(event: NotificationActionEvent): void {
1347
+ * if (event.control && event.control.type === 'button') {
1348
+ * const butttonIndex = event.notification.buttons.indexOf(event.control);
1349
+ *
1350
+ * // Handle button click
1351
+ * // . . .
1352
+ * }
1353
+ * }
1354
+ * ```
1355
+ */
1356
+ control?: Readonly<ControlOptions>;
1357
+ /**
1358
+ * Application-defined metadata that this event is passing back to the application.
1359
+ *
1360
+ * A `notification-action` event is only fired for a given trigger if the
1361
+ * {@link NotificationOptions|notification options} included an action result for that trigger.
1362
+ *
1363
+ * See the comment on the {@link NotificationActionEvent} type for an example of buttons that do and don't raise
1364
+ * actions.
1365
+ */
1366
+ result: NotificationActionResult<T>;
1367
+ }
1368
+ /**
1369
+ * Event fired whenever notification toast has been dismissed. This could be either by pressing notification dismiss `-` button or
1370
+ * by clicking notification body if BODY_CLICK action has been set to "dismiss_event".
1371
+ *
1372
+ * @event "notification-toast-dismissed"
1373
+ */
1374
+ interface NotificationToastDismissedEvent {
1375
+ type: 'notification-toast-dismissed';
1376
+ notification: Notification;
1377
+ }
1378
+ /**
1379
+ * Event fired whenever the notification has been closed.
1380
+ *
1381
+ * This event is fired regardless of how the notification was closed - i.e.: via a call to `clear`/`clearAll`, the
1382
+ * notification expiring, or by a user clicking either the notification itself, the notification's close button, or
1383
+ * a button on the notification.
1384
+ *
1385
+ * @event "notification-closed"
1386
+ */
1387
+ interface NotificationClosedEvent {
1388
+ type: 'notification-closed';
1389
+ /**
1390
+ * The notification that has just been closed.
1391
+ *
1392
+ * This object will match what is returned from the `create` call when the notification was first created.
1393
+ */
1394
+ notification: Notification;
1395
+ }
1396
+ /**
1397
+ * Event fired whenever a new notification has been created.
1398
+ *
1399
+ * @event "notification-created"
1400
+ */
1401
+ interface NotificationCreatedEvent {
1402
+ type: 'notification-created';
1403
+ /**
1404
+ * The notification that has just been created.
1405
+ *
1406
+ * This object will match what is returned from the `create` call.
1407
+ */
1408
+ notification: Notification;
1409
+ }
1410
+ /**
1411
+ * Event fired whenever a reminder has been created either via the Notifications API
1412
+ * or by the user on the Notification Center UI
1413
+ *
1414
+ * @event "notification-reminder-created"
1415
+ */
1416
+ interface NotificationReminderCreatedEvent {
1417
+ type: 'notification-reminder-created';
1418
+ /**
1419
+ * The reminder notification that has just been created.
1420
+ *
1421
+ * This object will match what is returned from the `create` call when the notification
1422
+ * was first created.
1423
+ */
1424
+ notification: Notification;
1425
+ /**
1426
+ * The reminder time-out timestamp.
1427
+ */
1428
+ reminderDate: Date;
1429
+ }
1430
+ /**
1431
+ * Event fired whenever a reminder has been canceled by the user, reminder notification is deleted or the reminder timeout has reached.
1432
+ *
1433
+ * @event "notification-reminder-removed"
1434
+ */
1435
+ interface NotificationReminderRemovedEvent {
1436
+ type: 'notification-reminder-removed';
1437
+ /**
1438
+ * The notification associated with the reminder that has just been removed.
1439
+ *
1440
+ * This object will match what is returned from the `create` call when the notification was first created.
1441
+ */
1442
+ notification: Notification;
1443
+ }
1444
+ /**
1445
+ * Event fired whenever the total number of notifications from **all** sources changes.
1446
+ *
1447
+ * @event "notifications-count-changed"
1448
+ */
1449
+ interface NotificationsCountChanged {
1450
+ type: 'notifications-count-changed';
1451
+ /**
1452
+ * Number of notifications in the Center.
1453
+ */
1454
+ count: number;
1455
+ }
1456
+ /**
1457
+ * Event fired whenever any of the notification form fields changes.
1458
+ *
1459
+ * @event "notification-form-value-changed"
1460
+ */
1461
+ interface NotificationFormValuesChangedEvent {
1462
+ type: 'notification-form-values-changed';
1463
+ notification: Notification;
1464
+ form: Record<string, unknown>;
1465
+ /**
1466
+ * Allows to set validation errors for the form fields.
1467
+ * If validation errors are set, the submit button will be disabled.
1468
+ * @param validationErrors
1469
+ * Array of objects with fieldKey and error properties.
1470
+ * @returns
1471
+ * Promise that resolves when the validation errors are set.
1472
+ *
1473
+ * @example
1474
+ * addEventListener(
1475
+ * 'notification-form-values-changed',
1476
+ * async (formValueChanged: NotificationFormValuesChangedEvent) => {
1477
+ * const errors = [];
1478
+ *
1479
+ * // Simpler regular expression to test for a valid HTTP or HTTPS URL
1480
+ * const phonePattern = /^\(?([0-9]{3})\)?[- ]?([0-9]{3})[- ]?([0-9]{4})$/;
1481
+ *
1482
+ * // Simpler regular expression to test for a valid email address
1483
+ * const emailPattern = /^\S+@\S+\.\S+$/;
1484
+ *
1485
+ * // Fields to validate
1486
+ * const sourcePhone = formValueChanged.form.sourcePhone as string;
1487
+ * const email = formValueChanged.form.sourceEmail as string;
1488
+ *
1489
+ * // Validate sourceUrl if it's not null or undefined
1490
+ * if (sourcePhone && !phonePattern.test(sourcePhone)) {
1491
+ * errors.push({
1492
+ * fieldKey: 'sourcePhone',
1493
+ * error: 'Invalid phone format'
1494
+ * });
1495
+ * }
1496
+ *
1497
+ * // Validate email if it's not null or undefined
1498
+ * if (email && !emailPattern.test(email)) {
1499
+ * errors.push({
1500
+ * fieldKey: 'sourceEmail',
1501
+ * error: 'Invalid email format'
1502
+ * });
1503
+ * }
1504
+ *
1505
+ * // If there are any errors, set them all at once
1506
+ * if (errors.length > 0) {
1507
+ * await formValueChanged.setErrors(errors);
1508
+ * }
1509
+ * }
1510
+ * );
1511
+ */
1512
+ setErrors: (validationErrors: Array<CustomValidationError>) => Promise<void>;
1513
+ }
1514
+ /**
1515
+ * Event fired whenever submit button is clicked on a notification form.
1516
+ *
1517
+ * @event "notification-form-submitted"
1518
+ */
1519
+ interface NotificationFormSubmittedEvent {
1520
+ type: 'notification-form-submitted';
1521
+ notification: Notification;
1522
+ button: ButtonOptions;
1523
+ form: Record<string, unknown>;
1524
+ /**
1525
+ * Prevents the default behaviour of notification form submit, where notification card gets dismissed right after submit.
1526
+ *
1527
+ * @example
1528
+ * addEventListener('notification-form-submitted', async (event) => {
1529
+ * // preventing the default submit behaviour
1530
+ * event.preventDefault();
1531
+ *
1532
+ * // setting the form status to processing
1533
+ * event.setFormStatus({
1534
+ * formStatus: 'Processing'
1535
+ * });
1536
+ *
1537
+ * const longOperationResult = await ...();
1538
+ *
1539
+ * if (longOperationResult.hasError) {
1540
+ * // setting error if long-running operation has failed.
1541
+ * event.setFormStatus({
1542
+ * formStatus: 'not-submitted',
1543
+ * error: longOperationResult.operationErrorMessage
1544
+ * });
1545
+ * } else {
1546
+ * // setting form status to submitted
1547
+ * event.setFormStatus({
1548
+ * formStatus: 'submitted'
1549
+ * });
1550
+ * }
1551
+ * });
1552
+ */
1553
+ preventDefault: () => void;
1554
+ /**
1555
+ *
1556
+ * @param formStatusOptions
1557
+ * Allows to set the status of the form. The form status reflects the state of the submit button which includes its text.
1558
+ * Submit button text for different statuses is defined using `formOptions` property for a submit button when creating a notification.
1559
+ *
1560
+ * @example
1561
+ * addEventListener('notification-form-submitted', async (event) => {
1562
+ * // preventing the default submit behaviour
1563
+ * event.preventDefault();
1564
+ *
1565
+ * // setting the form status to processing
1566
+ * event.setFormStatus({
1567
+ * formStatus: 'Processing'
1568
+ * });
1569
+ *
1570
+ * const longOperationResult = await ...();
1571
+ *
1572
+ * if (longOperationResult.hasError) {
1573
+ * // setting error if long-running operation has failed.
1574
+ * event.setFormStatus({
1575
+ * formStatus: 'not-submitted',
1576
+ * error: longOperationResult.operationErrorMessage
1577
+ * });
1578
+ * } else {
1579
+ * // setting form status to submitted
1580
+ * event.setFormStatus({
1581
+ * formStatus: 'submitted'
1582
+ * });
1583
+ * }
1584
+ * });
1585
+ */
1586
+ setFormStatus: (formStatusOptions: Omit<FormStatusOptions, '_notificationId'>) => Promise<void>;
1587
+ }
1588
+ /**
1589
+ * Event fired whenever the Notification Sound Enabled setting is toggled in Notification Center.
1590
+ *
1591
+ * @event "notification-sound-toggled"
1592
+ */
1593
+ interface ToggleNotificationSound {
1594
+ type: 'notification-sound-toggled';
1595
+ notificationSoundEnabled: boolean;
1596
+ }
1597
+ /**
1598
+ * Extended configuration options for the notification creation.
1599
+ */
1600
+ interface NotificationCreationOptions {
1601
+ /**
1602
+ * The date on which the notification will be removed from reminders category and recreated
1603
+ * created as regular notification.
1604
+ *
1605
+ * If this date is earlier than the notification creation time, the notification will be created
1606
+ * immediately.
1607
+ * Cannot be earlier than the expiry date, if set.
1608
+ *
1609
+ */
1610
+ reminderDate?: Date;
1611
+ }
1612
+ /**
1613
+ * Creates a new notification.
1614
+ *
1615
+ * If a reminder is not set, the notification will immediately appear in the Notification Center and as a toast if the Center is not visible.
1616
+ * If a reminder is set, the notification will appear in the Center when the reminder date is reached.
1617
+ *
1618
+ * If a notification is created with an `id` of an already existing notification, the existing notification will be recreated with the new content.
1619
+ *
1620
+ * ```ts
1621
+ * import {create} from 'openfin-notifications';
1622
+ *
1623
+ * create({
1624
+ * id: 'uniqueNotificationId',
1625
+ * title: 'Notification Title',
1626
+ * body: 'Text to display within the notification body',
1627
+ * icon: 'https://openfin.co/favicon.ico'
1628
+ * }, {
1629
+ * reminderDate: new Date('October 21, 2025 07:28:00');
1630
+ * });
1631
+ * ```
1632
+ *
1633
+ * @param options Notification configuration options.
1634
+ * @param creationOptions Extended configuration options for the notification creation.
1635
+ */
1636
+ declare function create<T extends NotificationOptions>(options: T, creationOptions?: NotificationCreationOptions): Promise<Notification<T>>;
1637
+ /**
1638
+ * Updates an existing notification. Requires id of original Notification and one of:
1639
+ * - buttons
1640
+ * - customData
1641
+ * - Template
1642
+ *
1643
+ * The updated Notification will then show in Notification Centre and in the Toast stack if not expired.
1644
+ *
1645
+ * Example:
1646
+ * ```ts
1647
+ * import {update} from 'openfin-notifications';
1648
+ *
1649
+ * update({
1650
+ * id: uniqueNotificationId,
1651
+ * body: 'i am an update! - ' + Date.now().toString(),
1652
+ * template: 'markdown',
1653
+ * });
1654
+ * ```
1655
+ * @param options
1656
+ * @returns
1657
+ */
1658
+ declare function update<T extends UpdatableNotificationOptions>(options: T): Promise<Notification>;
1659
+ /**
1660
+ * Clears a specific notification from the Notification Center.
1661
+ *
1662
+ * Returns true if the notification was successfully cleared. Returns false if the notification was not cleared, without errors.
1663
+ *
1664
+ * ```ts
1665
+ * import {clear} from 'openfin-notifications';
1666
+ *
1667
+ * clear('uniqueNotificationId');
1668
+ * ```
1669
+ *
1670
+ * @param id ID of the notification to clear.
1671
+ */
1672
+ declare function clear(id: string): Promise<boolean>;
1673
+ /**
1674
+ * Sets a reminder for a specific notification. Reminder must be a date in the future.
1675
+ *
1676
+ * ```ts
1677
+ * import {setReminder} from 'openfin-notifications';
1678
+ *
1679
+ * // Set a reminder 1 minute from now
1680
+ * setReminder('uniqueNotificationId', new Date(Date.now() + 60_000));
1681
+ *
1682
+ * // Set a reminder for a specific date
1683
+ * setReminder('uniqueNotificationId', new Date('October 21, 2025 07:28:00'));
1684
+ * ```
1685
+ *
1686
+ * @param id ID of the notification to set the reminder for.
1687
+ * @param reminderDate Reminder date.
1688
+ * @returns True if the reminder was set successfully, false otherwise.
1689
+ */
1690
+ declare function setReminder(id: string, reminderDate: Date): Promise<boolean>;
1691
+ /**
1692
+ * Cancels a reminder for a specific notification.
1693
+ *
1694
+ * ```ts
1695
+ * import {cancelReminder} from 'openfin-notifications';
1696
+ *
1697
+ * cancelReminder('uniqueNotificationId');
1698
+ * ```
1699
+ * @param id ID of the notification to cancel the reminder for.
1700
+ * @returns True if the reminder was canceled successfully, false otherwise.
1701
+ */
1702
+ declare function cancelReminder(id: string): Promise<boolean>;
1703
+ /**
1704
+ * Retrieves all Notifications which were created by the calling application, including child windows.
1705
+ * Child window notifications will only be included if the notification security rules allow it.
1706
+ *
1707
+ * ```ts
1708
+ * import {getAll} from 'openfin-notifications'
1709
+ *
1710
+ * getAll().then((notifications: Notification[]) => {
1711
+ * console.log(`Service has ${notifications.length} notifications for this app:`, notifications);
1712
+ * });
1713
+ * ```
1714
+ *
1715
+ * There is deliberately no mechanism provided for fetching notifications that were created by a different application.
1716
+ */
1717
+ declare function getAll(): Promise<Notification[]>;
1718
+ /**
1719
+ * Clears all Notifications which were created by the calling application, including child windows.
1720
+ * Child window notifications will only be cleared if the notification security rules allow it.
1721
+ *
1722
+ * Returns the number of successfully cleared Notifications.
1723
+ *
1724
+ * ```ts
1725
+ * import {clearAll} from 'openfin-notifications';
1726
+ *
1727
+ * clearAll();
1728
+ * ```
1729
+ */
1730
+ declare function clearAll(): Promise<number>;
1731
+ /**
1732
+ * Options to modify the Notification Center behaviour when show() API is called.
1733
+ */
1734
+ interface ShowOptions {
1735
+ navigateToAll?: boolean;
1736
+ }
1737
+ /**
1738
+ * Sets the visibility of the Notification Center to true.
1739
+ *
1740
+ * ```ts
1741
+ * import { show } from 'openfin-notifications';
1742
+ *
1743
+ * show({ navigateToAll: false });
1744
+ * ```
1745
+ * @param showOptions
1746
+ */
1747
+ declare function show(options?: ShowOptions): Promise<void>;
1748
+ declare const enum UserSettings {
1749
+ SOUND_ENABLED = "soundEnabled"
1750
+ }
1751
+ type UserSettingStatus = {
1752
+ [UserSettings.SOUND_ENABLED]: boolean;
1753
+ };
1754
+
1755
+ /**
1756
+ * Actions are the mechanism through which notifications send messages back to the application that created them. The
1757
+ * service defines a number of ways in which actions can be raised (a notification being interacted with by the user,
1758
+ * being closed, expiring, etc.), and it is up to each application to decide if it wishes to be informed when each of
1759
+ * these triggers occur.
1760
+ *
1761
+ * For an action to be raised when one of these triggers occurs, the application must specify an
1762
+ * {@link NotificationActionResult|action result} for each trigger it is interested in. The application should then
1763
+ * listen for when these actions are raised by listening for the {@link NotificationActionEvent|`notification-action`}
1764
+ * event.
1765
+ *
1766
+ * This event is fired once each time an action is raised, and will contain the
1767
+ * {@link NotificationActionResult|action result} the application specified for that trigger. The application may then
1768
+ * use the {@link NotificationActionResult|action result} to determine which trigger occurred and respond appropriately.
1769
+ *
1770
+ * If an {@link NotificationActionResult|action result} is not specified for a particular trigger, or it is set to
1771
+ * `null`, the application will not receive a corresponding {@link NotificationActionEvent|`notification-action`} when
1772
+ * that trigger occurs.
1773
+ *
1774
+ * Unlike other event types, {@link NotificationActionEvent|`notification-action`} events will be buffered by the
1775
+ * service until the application has added a listener for this event type, at which point it will receive all buffered
1776
+ * {@link NotificationActionEvent|`notification-action`} events. The service will also attempt to restart the
1777
+ * application if it is not running when the event is fired.
1778
+ *
1779
+ * For an overview of actions, consider the sample notification below:
1780
+ * ```ts
1781
+ * import {addEventListener, create} from 'openfin-notifications';
1782
+ *
1783
+ * // Create a notification with two buttons
1784
+ * create({
1785
+ * // Basic info
1786
+ * title: 'Reminder',
1787
+ * body: 'Event "Weekly Meeting" is starting soon...',
1788
+ *
1789
+ * // We'll use the 'customData' field to store metadata about the event
1790
+ * customData: {eventId: '12345'},
1791
+ *
1792
+ * // We want the user clicking the notification to open the associated event, so register an 'onSelect' action
1793
+ * onSelect: {task: 'view-calendar-event', target: 'popup'},
1794
+ *
1795
+ * buttons: [
1796
+ * // A button that will schedule another reminder for 5 minutes from now. Since the application will be
1797
+ * // responsible for snoozing the event, it will need to know about the user clicking this button. By setting
1798
+ * // a NotificationActionResult for 'onClick', the service will raise a "notification-action" event when this
1799
+ * // button is clicked, and will pass the value of 'onClick' as the 'result' field within the event
1800
+ * {
1801
+ * title: 'Snooze for 5 minutes',
1802
+ * iconUrl: 'https://www.example.com/timer.png',
1803
+ * onClick: {
1804
+ * task: 'schedule-reminder',
1805
+ * intervalMs: 5 * 60 * 1000
1806
+ * }
1807
+ * },
1808
+ *
1809
+ * // A button that closes the notification and doesn't prompt the user about this event again. Since the
1810
+ * // application doesn't need to do anything when the user clicks this button, we leave 'onClick' undefined
1811
+ * // rather than specifying a NotificationActionResult. This means that no action will be raised when the
1812
+ * // button is clicked, and hence no "notification-action" event will be fired
1813
+ * {
1814
+ * title: 'Dismiss',
1815
+ * iconUrl: 'https://www.example.com/cancel.png'
1816
+ * }
1817
+ * ]
1818
+ * });
1819
+ *
1820
+ * // Create a listener that will be called for each action
1821
+ * // Note: This handler will be used for ALL actions, from ALL notifications that are created by this application.
1822
+ * addEventListener('notification-action', (event: NotificationActionEvent) => {
1823
+ * const {result, notification} = event;
1824
+ *
1825
+ * if (result['task'] === 'view-calendar-event') {
1826
+ * // Open a window with full details of the associated event
1827
+ * openEventDetails(notification.customData.eventId, result['target']);
1828
+ * } else if (result['task'] === 'schedule-reminder') {
1829
+ * // Schedule a new notification
1830
+ * scheduleReminder(notification.customData.eventId, Date.now() + result['intervalMs']);
1831
+ * } // Etc...
1832
+ * });
1833
+ * ```
1834
+ *
1835
+ * The example above uses `customData` to store details about the notification subject (in this case, a calendar
1836
+ * event), and `onClick` actions to inform the application about how it should respond when the user interacts with the
1837
+ * notification. This is our intended usage and recommended best-practice, but the service doesn't require applications
1838
+ * to follow this convention - application developers are free to decide how to manage notification state.
1839
+ *
1840
+ * Within the `notification-action` handler, the application must be able to understand which notification is being
1841
+ * handled, and how to decide what it should do next. The example above uses an application-defined `action` field to
1842
+ * determine the correct action, but the notification's `id`, `customData` and other fields are also useful
1843
+ * selectors.
1844
+ *
1845
+ * @module Actions
1846
+ */
1847
+ /**
1848
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1849
+ * import below.
1850
+ *
1851
+ * @hidden
1852
+ */
1853
+
1854
+ /**
1855
+ * Denotes a field as being an action. Defining this field (with a non-`undefined` value) will result in actions being
1856
+ * raised and sent back to the source application when the corresponding event happens.
1857
+ *
1858
+ * For example, providing a value for the `onClick` field of {@link ButtonOptions} will result in a
1859
+ * {@link NotificationActionEvent|`notification-action`} event being fired when that button is clicked.
1860
+ *
1861
+ * The `NotificationActionResult returned back to an application is static
1862
+ * and must be defined at the point where the notification is created.
1863
+ */
1864
+ type ActionDeclaration<T extends never, E extends never> = NotificationActionResult;
1865
+ /**
1866
+ * Data type used to represent the action result returned back to applications when an action is raised. Applications
1867
+ * capture these responses by adding a `notification-action` listener. The contents of this type are entirely
1868
+ * application-defined, the only requirement is that the item is serializable by `JSON.stringify`.
1869
+ *
1870
+ * Since this type is entirely application-specific, the type is used in these definitions. However, there is an
1871
+ * optional generic argument here, which can be used if an application were to define its own conventions for the shape
1872
+ * of this field (which is recommended). To make use of this, define a `notification-action` handler that includes the
1873
+ * application-defined type as a template argument. This type is then propagated up to {@link NotificationActionEvent}.
1874
+ * The example below demonstrates this, using the same use-case as at the top of this page.
1875
+ *
1876
+ * ```ts
1877
+ * interface MyAction = SnoozeAction | DetailsAction;
1878
+ *
1879
+ * interface SnoozeAction {
1880
+ * task: 'schedule-reminder';
1881
+ * intervalMs: number;
1882
+ * }
1883
+ *
1884
+ * interface DetailsAction {
1885
+ * task: 'view-calendar-event';
1886
+ * target: 'self'|'popup';
1887
+ * }
1888
+ *
1889
+ * addEventListener('notification-action', (event: NotificationActionEvent<MyAction>)) => {
1890
+ * if (event.result.task === 'schedule-reminder') {
1891
+ * // 'event.result' will now be strongly-typed as an instance of SnoozeAction
1892
+ * scheduleReminder(notification.customData.eventId, Date.now() + result.intervalMs);
1893
+ * }
1894
+ * // Etc...
1895
+ * };
1896
+ * ```
1897
+ */
1898
+ type NotificationActionResult<T = CustomData> = T;
1899
+ /**
1900
+ * Lists the different triggers that can raise an {@link Actions|action}. Each action that is raised will result in a
1901
+ * {@link NotificationActionEvent|`notification-action`} event, which can be captured by the application that created
1902
+ * the notification.
1903
+ */
1904
+ declare enum ActionTrigger {
1905
+ /**
1906
+ * The user interacted with one of the controls in the notification: a button or an actionable fragment.
1907
+ */
1908
+ CONTROL = "control",
1909
+ /**
1910
+ * The user clicked the body of the notification itself. Any clicks of the notification that don't hit a control
1911
+ * or the close button will fire an event with the `'select'` action trigger.
1912
+ */
1913
+ SELECT = "select",
1914
+ /**
1915
+ * The notification was closed, either by user interaction, programmatically by an application, or by the notification expiring.
1916
+ */
1917
+ CLOSE = "close",
1918
+ /**
1919
+ * The notification expired.
1920
+ */
1921
+ EXPIRE = "expire",
1922
+ /**
1923
+ * The action was triggered programmatically by an application.
1924
+ *
1925
+ * *Not currently supported*
1926
+ */
1927
+ PROGRAMMATIC = "programmatic"
1928
+ }
1929
+ /**
1930
+ * Noop action types see {@link ActionNoop|ActionNoop}.
1931
+ */
1932
+ declare enum ActionNoopType {
1933
+ /**
1934
+ * No event will be raised and no dismissal of the notification on action.
1935
+ */
1936
+ EVENT_DISMISS = "event_dismiss"
1937
+ }
1938
+ /**
1939
+ * BODY_CLICK action types see {@link ActionBodyClick|ActionBodyClick}.
1940
+ */
1941
+ declare enum ActionBodyClickType {
1942
+ /**
1943
+ * Dissmisal/Clearing event will be raised
1944
+ */
1945
+ DISMISS_EVENT = "dismiss_event"
1946
+ }
1947
+ /**
1948
+ * @depracated {__NOOP__} has been deprecated. Notifications now default to not triggering the dismiss action when the body is clicked
1949
+ *
1950
+ * Setting the `__NOOP__` field on an action with a {@link ActionNoopType|type} allows you to override default user interaction with a notification.
1951
+ *
1952
+ * @example
1953
+ * ```
1954
+ * const notification = {
1955
+ * //...
1956
+ * onSelect: {__NOOP__: ActionNoopType.EVENT_DISMISS}
1957
+ * };
1958
+ * ```
1959
+ *
1960
+ * When a user clicks the notification body, the notification will not be dismissed and no event will be raised to the client application.
1961
+ *
1962
+ * <li> Currently <code>ActionBodyClickType.DISMISS_EVENT</code> is only supported by <code>ActionTrigger.SELECT/onSelect</code></li>
1963
+ */
1964
+ interface ActionNoop {
1965
+ __NOOP__?: ActionNoopType;
1966
+ }
1967
+ /**
1968
+ * Set the `BODY_CLICK` field on an action with a {@link ActionBodyClickType|type} to allow the end-user to click the body of the notification to dismiss it. This was the default behavior in earlier releases. An event is also sent to the client application.
1969
+ *
1970
+ * Note the following restrictions:
1971
+ *
1972
+ * <ul>
1973
+ * <li>This override is ignored if buttons are passed to notification options.</li>
1974
+ * <li>The <code>ActionBodyClickType.DISMISS_EVENT</code> is supported only by <code>ActionTrigger.SELECT/onSelect</code></li>
1975
+ *
1976
+ * @example
1977
+ * ```
1978
+ * const notification = {
1979
+ * //...
1980
+ * onSelect: {BODY_CLICK: ActionBodyClickType.DISMISS_EVENT}
1981
+ * };
1982
+ * ```
1983
+ *
1984
+ */
1985
+ interface ActionBodyClick {
1986
+ BODY_CLICK?: ActionBodyClickType;
1987
+ }
1988
+
1989
+ /**
1990
+ * A rule that specifies the allowed origins that can access
1991
+ * the stored notification data and update the notifications
1992
+ */
1993
+ interface NotificationSecurityRule {
1994
+ /**
1995
+ * Array of [match patterns](https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns)
1996
+ * specifying the allowed origins that can access to the notification(s) for the client.
1997
+ * If an empty array is provided, then no origins are allowed to access the stored notifications for the client.
1998
+ */
1999
+ allowedOrigins: string[];
2000
+ }
2001
+
2002
+ declare global {
2003
+ interface Window {
2004
+ search: SearchWindow;
2005
+ }
2006
+ }
2007
+ interface SearchWindow {
2008
+ minLength: number;
2009
+ useQueryLength: boolean;
2010
+ queryLengthMinus: number;
2011
+ threshold: number;
2012
+ useExtendedSearch: boolean;
2013
+ logging: boolean;
2014
+ }
2015
+
2016
+ /**
2017
+ * Persisted modifiers to a notification.
2018
+ * Store changes to a notification here so we do not alter the original notification for historical purposes.
2019
+ */
2020
+ interface NotificationModifiers {
2021
+ /**
2022
+ * When a sticky notification has been minimized track its sticky state change here.
2023
+ */
2024
+ notSticky?: boolean;
2025
+ /**
2026
+ * When Notifications are updated a revision number is generated to allow for easier update rendering
2027
+ */
2028
+ revision?: number;
2029
+ /**
2030
+ * The timestamp at which this notification is set to be recreated.
2031
+ */
2032
+ reminder?: number;
2033
+ /**
2034
+ * A flag that indicates that this is a tutorial notification created by the center.
2035
+ * No events dispatch attempts will be done for tutorial notifications.
2036
+ */
2037
+ tutorial?: boolean;
2038
+ }
2039
+
2040
+ type Immutable<T> = {
2041
+ readonly [K in keyof T]: T[K] extends Date ? T[K] : T[K] extends [infer U, infer V] ? Readonly<[Immutable<U>, Immutable<V>]> : T[K] extends (infer U)[] ? ReadonlyArray<U extends object ? Immutable<U> : U> : T[K] extends object ? Immutable<T[K]> : Readonly<T[K]>;
2042
+ };
2043
+
2044
+ /**
2045
+ * Shape of the data that will be used internally by the service.
2046
+ *
2047
+ * The id property is the encoded notification id (i.e. "{app uuid}/{notification ID}")
2048
+ *
2049
+ */
2050
+ type StoredNotification<T extends NotificationOptions = NotificationOptions> = Immutable<{
2051
+ id: string;
2052
+ source: NotificationSource;
2053
+ notification: NotificationInternal<T>;
2054
+ title: string;
2055
+ modifiers?: NotificationModifiers;
2056
+ /**
2057
+ * Stripped text contents of the body without HTML/Markdown. Use this for search
2058
+ */
2059
+ bodyText: string;
2060
+ }>;
2061
+
2062
+ /**
2063
+ * @hidden
2064
+ */
2065
+ /**
2066
+ * File contains types used to communicate between client and provider.
2067
+ *
2068
+ * These types are a part of the client, but are not required by applications wishing to interact with the service.
2069
+ * This file is excluded from the public-facing TypeScript documentation.
2070
+ */
2071
+
2072
+ declare const enum APITopic {
2073
+ CREATE_NOTIFICATION = "create-notification",
2074
+ UPDATE_NOTIFICATION = "update-notification",
2075
+ CLEAR_NOTIFICATION = "clear-notification",
2076
+ SET_REMINDER = "set-reminder",
2077
+ CANCEL_REMINDER = "cancel-reminder",
2078
+ GET_APP_NOTIFICATIONS = "fetch-app-notifications",
2079
+ CLEAR_APP_NOTIFICATIONS = "clear-app-notifications",
2080
+ TOGGLE_NOTIFICATION_CENTER = "toggle-notification-center",
2081
+ ADD_EVENT_LISTENER = "add-event-listener",
2082
+ REMOVE_EVENT_LISTENER = "remove-event-listener",
2083
+ GET_PROVIDER_STATUS = "get-provider-status",
2084
+ GET_NOTIFICATIONS_COUNT = "get-notifications-count",
2085
+ SHOW_NOTIFICATION_CENTER = "show-notification-center",
2086
+ HIDE_NOTIFICATION_CENTER = "hide-notification-center",
2087
+ REGISTER_PLATFORM = "register-notifications-platform",
2088
+ DEREGISTER_PLATFORM = "deregister-notifications-platform",
2089
+ SET_FORM_STATUS_OPTIONS = "set-form-status-options",
2090
+ SET_FORM_VALIDATION_ERRORS = "set-form-validation-errors",
2091
+ GET_USER_SETTINGS_STATUS = "get-user-settings-status",
2092
+ SET_DEFAULT_PLATFORM_SHORTCUT = "set-default-platform-shortcut",
2093
+ SET_NOTIFICATION_SECURITY_RULE = "set-notification-security-rule"
2094
+ }
2095
+ interface API {
2096
+ [APITopic.CREATE_NOTIFICATION]: [CreatePayload, NotificationInternal];
2097
+ [APITopic.UPDATE_NOTIFICATION]: [UpdatePayload, NotificationInternal];
2098
+ [APITopic.CLEAR_NOTIFICATION]: [ClearPayload, boolean];
2099
+ [APITopic.SET_REMINDER]: [SetReminderPayload, boolean];
2100
+ [APITopic.CANCEL_REMINDER]: [CancelReminderPayload, boolean];
2101
+ [APITopic.CLEAR_APP_NOTIFICATIONS]: [undefined, number];
2102
+ [APITopic.GET_APP_NOTIFICATIONS]: [undefined, NotificationInternal[]];
2103
+ [APITopic.TOGGLE_NOTIFICATION_CENTER]: [undefined, void];
2104
+ [APITopic.ADD_EVENT_LISTENER]: [Events['type'], void];
2105
+ [APITopic.REMOVE_EVENT_LISTENER]: [Events['type'], void];
2106
+ [APITopic.GET_PROVIDER_STATUS]: [undefined, ProviderStatus];
2107
+ [APITopic.GET_NOTIFICATIONS_COUNT]: [undefined, number];
2108
+ [APITopic.SHOW_NOTIFICATION_CENTER]: [ShowPayload | undefined, void];
2109
+ [APITopic.HIDE_NOTIFICATION_CENTER]: [undefined, void];
2110
+ [APITopic.REGISTER_PLATFORM]: [
2111
+ PlatformRegisterPayload,
2112
+ Pick<RegistrationMetaInfo, 'notificationsVersion'> | undefined
2113
+ ];
2114
+ [APITopic.DEREGISTER_PLATFORM]: [PlatformDeregisterPayload, void];
2115
+ [APITopic.SET_FORM_STATUS_OPTIONS]: [FormStatusOptions, void];
2116
+ [APITopic.SET_FORM_VALIDATION_ERRORS]: [SetFormValidationErrorsPayload, void];
2117
+ [APITopic.GET_USER_SETTINGS_STATUS]: [UserSettings, UserSettingStatus[UserSettings]];
2118
+ [APITopic.SET_DEFAULT_PLATFORM_SHORTCUT]: [string, void];
2119
+ [APITopic.SET_NOTIFICATION_SECURITY_RULE]: [NotificationSecurityRule, void];
2120
+ }
2121
+ type Events = NotificationActionEvent | NotificationToastDismissedEvent | NotificationClosedEvent | NotificationCreatedEvent | NotificationsCountChanged | Omit<NotificationFormSubmittedEvent, 'setFormStatus' | 'preventDefault'> | NotificationReminderCreatedEvent | NotificationReminderRemovedEvent | Omit<NotificationFormValuesChangedEvent, 'setErrors'> | ToggleNotificationSound;
2122
+ type TransportMappings<T> = T extends NotificationActionEvent ? NotificationActionEventTransport : never;
2123
+ type TransportMemberMappings<T> = T extends Notification ? NotificationInternal : T;
2124
+ type CreatePayload<T extends NotificationOptions = NotificationOptions> = DistributiveOmit<T, 'date' | 'expires'> & {
2125
+ date?: number;
2126
+ expires?: number | null;
2127
+ reminder?: number | null;
2128
+ };
2129
+ type SetFormValidationErrorsPayload = {
2130
+ errors: Array<CustomValidationError>;
2131
+ notificationId: string;
2132
+ };
2133
+ type UpdatePayload<T extends UpdatableNotificationOptions = UpdatableNotificationOptions> = T;
2134
+ type NotificationInternal<T extends NotificationOptions = NotificationOptions> = DistributiveOmit<Notification<T>, 'date' | 'expires'> & {
2135
+ date: number;
2136
+ expires: number | null;
2137
+ _fragments?: (ActionableTextTemplateFragment | ImageTemplateFragment | ContainerTemplateFragment)[];
2138
+ };
2139
+ type SetReminderPayload<T extends NotificationOptions = NotificationOptions> = {
2140
+ id: string;
2141
+ reminder: number;
2142
+ } | {
2143
+ notification: StoredNotification<T>;
2144
+ reminder: number;
2145
+ };
2146
+ interface CancelReminderPayload {
2147
+ id: string;
2148
+ }
2149
+ interface ClearPayload {
2150
+ id: string;
2151
+ }
2152
+ type ShowPayload = ShowOptions;
2153
+ type ColorSchemeOption = ColorSchemeType;
2154
+ interface NotificationActionEventTransport {
2155
+ type: 'notification-action';
2156
+ notification: Readonly<NotificationInternal>;
2157
+ source: NotificationSource;
2158
+ result: NotificationActionResult;
2159
+ trigger: ActionTrigger;
2160
+ controlSource?: 'buttons' | '_fragments';
2161
+ controlIndex?: number;
2162
+ }
2163
+ /**
2164
+ * Distribute Omit across all union types instead of Omitting the union.
2165
+ * https://davidgomes.com/pick-omit-over-union-types-in-typescript/
2166
+ */
2167
+ type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
2168
+ /**
2169
+ * Data returned by the service when registering a platform.
2170
+ */
2171
+ interface RegistrationMetaInfo {
2172
+ /**
2173
+ * Version of the client API.
2174
+ */
2175
+ clientAPIVersion: string;
2176
+ /**
2177
+ * Version of the notification service that is running.
2178
+ * A response of 'unknown' indicates that an older version of the service is runningthat does not support returning the service version.
2179
+ */
2180
+ notificationsVersion: string;
2181
+ }
2182
+ type MakePropertyRequired<T, Prop extends keyof T> = Omit<T, Prop> & Required<Pick<T, Prop>>;
2183
+
2184
+ /**
2185
+ * @hidden
2186
+ */
2187
+ /**
2188
+ * Acts as a central point for routing all events received from the provider.
2189
+ */
2190
+
2191
+ interface EventSpecification {
2192
+ type: string;
2193
+ }
2194
+ interface EventTarget {
2195
+ type: string;
2196
+ id: string;
2197
+ }
2198
+ type Targeted<T extends EventSpecification> = T & {
2199
+ /**
2200
+ * Indicates which emitter the client should use to dispatch this event.
2201
+ *
2202
+ * Allows events to be raised from client-side objects that mirror a corresponding provider-side object. If there
2203
+ * is no such model of client-side objects, pass `default` to emit the event from a shared top-level/"global" event
2204
+ * emitter.
2205
+ */
2206
+ target: EventTarget | 'default';
2207
+ };
2208
+ type Transport<T extends EventSpecification> = TransportMappings<T> extends never ? {
2209
+ [K in keyof T]: TransportMemberMappings<T[K]>;
2210
+ } : TransportMappings<T>;
2211
+
2212
+ /**
2213
+ * Defines a tuple that stores the payload and return type of an API method.
2214
+ *
2215
+ * The first element will be an interface containing the "payload" of the API - an object containing any parameters
2216
+ * that need to be passed from client to provider.
2217
+ *
2218
+ * The second element is the return type of the API - the type (possibly `void`) that is passed from the provider back
2219
+ * to the client.
2220
+ */
2221
+ type APIDefinition = [unknown, unknown];
2222
+
2223
+ /**
2224
+ * Options for using privately hosted notification service.
2225
+ * @deprecated This option is not supported anymore. This configuration must be provided via the host platform's manifest.
2226
+ */
2227
+ type CustomManifestOptions = {
2228
+ /**
2229
+ * A custom manifest location to start the notification service from.
2230
+ * The UUID cannot be OpenFin hosted Notification Service UUID, 'notifications-service'.
2231
+ */
2232
+ manifestUrl: string;
2233
+ /**
2234
+ * The UUID of the provided custom notifications service manifest.
2235
+ * This value **MUST** match the UUID of the manifest provided in `manifestUrl`.
2236
+ */
2237
+ manifestUuid: string;
2238
+ };
2239
+
2240
+ type APIPayloadTranformer<T extends APIDefinition> = (payload: T[0]) => T[0] | Promise<T[0]>;
2241
+ type APIPayloadTransformerMap = {
2242
+ [K in APITopic]: APIPayloadTranformer<API[K]>;
2243
+ };
2244
+ type APIOverrides = Partial<APIPayloadTransformerMap>;
2245
+ type NotificationCenterEvent = Targeted<Transport<Events>>;
2246
+ type WakeUpCallback = (contentId: string, eventType: Events['type']) => Promise<void>;
2247
+ type OnNotificationCenterEvent = (payload: NotificationCenterEvent, contentId?: string) => Promise<void>;
2248
+ type APIRouterConfig = {
2249
+ providerChannelName: string;
2250
+ onWakeUpRequired: WakeUpCallback;
2251
+ onNotificationCenterEvent?: OnNotificationCenterEvent;
2252
+ overrides?: APIOverrides;
2253
+ customManifest?: CustomManifestOptions;
2254
+ };
2255
+ declare class APIRouter {
2256
+ #private;
2257
+ readonly onConnection: Signal<[OpenFin.Identity]>;
2258
+ readonly onDisconnection: Signal<[OpenFin.Identity]>;
2259
+ constructor(config: APIRouterConfig);
2260
+ initialize(): Promise<void>;
2261
+ }
2262
+
2263
+ export { APIRouter, APITopic, cancelReminder, clear, clearAll, create, getAll, setReminder, show, update };
2264
+ export type { API, APIOverrides, APIPayloadTranformer, APIPayloadTransformerMap, APIRouterConfig, CancelReminderPayload, ClearPayload, CreatePayload, Events, NotificationCenterEvent, NotificationInternal, NotificationOptions, OnNotificationCenterEvent, SetFormValidationErrorsPayload, SetReminderPayload, ShowPayload, UpdatableNotificationOptions, UpdatePayload, WakeUpCallback };