@interopio/browser 3.1.3 → 3.2.0

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.
package/browser.d.ts CHANGED
@@ -122,6 +122,7 @@ export namespace IOConnectBrowser {
122
122
  workspaces?: IOConnectWorkspaces.API;
123
123
  search?: IOConnectSearch.API;
124
124
  webPlatform?: IOConnectBrowser.WebPlatform.API;
125
+ prefs: IOConnectBrowser.Prefs.API;
125
126
  }
126
127
 
127
128
  /**
@@ -709,6 +710,23 @@ export namespace IOConnectBrowser {
709
710
  */
710
711
  onClosed(callback: (notification: { id: string }) => void): UnsubscribeFunction;
711
712
 
713
+ /**
714
+ * Notifies when the global notification settings are changed.
715
+ * @param callback Callback function for handling the event.
716
+ */
717
+ onConfigurationChanged(callback: (configuration: Configuration) => void): UnsubscribeFunction;
718
+
719
+ /**
720
+ * Notifies when the number of active notification is changed.
721
+ * @param callback Callback function for handling the event.
722
+ */
723
+ onActiveCountChanged(callback: (info: { count: number; }) => void): UnsubscribeFunction;
724
+
725
+ /** Notifies when the state of a notification is changed.
726
+ * @param callback Callback function for handling the event.
727
+ */
728
+ onStateChanged(callback: (notification: { id: string; }, state: State) => void): UnsubscribeFunction;
729
+
712
730
  /**
713
731
  * Issues a programmatic click on a notification.
714
732
  * @param id The id of the notification to click on.
@@ -724,8 +742,48 @@ export namespace IOConnectBrowser {
724
742
 
725
743
  /** Removes all known notifications from the system. */
726
744
  clearAll(): Promise<void>;
745
+
746
+ /** Clears all notifications that the user has already seen. */
747
+ clearOld(): Promise<void>;
748
+
749
+ /**
750
+ * Configures the Global notification settings.
751
+ * @param options configuration options
752
+ */
753
+ configure(options: Configuration): Promise<void>;
754
+
755
+ /** Retrieves the current global notification settings. */
756
+ getConfiguration(): Promise<Configuration>;
757
+
758
+ /** Retrieves the current filter with apps allowed or not allowed to raise notifications. */
759
+ getFilter(): Promise<NotificationFilter>;
760
+
761
+ /**
762
+ * Sets a filter with apps allowed or not allowed to raise notifications.
763
+ * @param filter Filter with names of apps allowed or not allowed to raise notifications.
764
+ */
765
+ setFilter(filter: NotificationFilter): Promise<NotificationFilter>;
766
+
767
+ /**
768
+ * Sets the state of a notification.
769
+ * @param id ID of the notification to change.
770
+ * @param state Value for the new notification state.
771
+ */
772
+ setState(id: string, state: State): Promise<void>;
727
773
  }
728
774
 
775
+ /**
776
+ * Notification states that are used by the platform when handling notifications. These states can also be used in your custom logic for processing notifications on the client or on the server side. Defaults to `"Active"`.
777
+ * - `"Active"` - a notification can be marked as active when it is raised, but the user hasn't seen it, or interacted in any way with it yet;
778
+ * - `"Acknowledged"` - a notification can be marked as acknowledged when the user has interacted with it by clicking on the notification or on an action in it;
779
+ * - `"Seen"` - a notification can be marked as seen when the user has seen it (e.g., by opening the Notification Panel);
780
+ * - `"Closed"` - a notification can be marked as closed when the user has closed the notification in the Notification Panel;
781
+ * - `"Stale"` - a notification can be marked as stale after a predefined period of time;
782
+ * - `"Snoozed"` - a notification can be marked as snoozed when the user snoozes it from the UI;
783
+ * - `"Processing"` - a notification can be marked as `"Processing"` when its state is in the process of changing (e.g., the user interacts with a notification from the UI, you make a request to a remote service to update the notification state, and you are still waiting for a response);
784
+ */
785
+ export type State = "Active" | "Acknowledged" | "Seen" | "Closed" | "Stale" | "Snoozed" | "Processing";
786
+
729
787
  export interface NotificationDefinition {
730
788
  badge?: string;
731
789
  body?: string;
@@ -749,14 +807,16 @@ export namespace IOConnectBrowser {
749
807
  clickInterop?: InteropActionSettings;
750
808
  /** List of action attached to the notification. Those will appear as buttons in the notification UI */
751
809
  actions?: NotificationAction[];
752
- /** **io.Connect Browser** only. If set to true, the platform app will be focused when the user clicks on the notification. Defaults to false. */
810
+ /** **io.Connect Browser** only. If set to `true`, the platform app will be focused when the user clicks on the notification. Defaults to false. */
753
811
  focusPlatformOnDefaultClick?: boolean;
754
812
  /** Severity of the alert */
755
813
  severity?: "Low" | "Medium" | "High" | "Critical" | "None";
756
- /** Indicates whether a native toast will be shown or not. Defaults to true */
814
+ /** Indicates whether a native toast will be shown or not. Defaults to `true` */
757
815
  showToast?: boolean;
758
- /** Indicates whether the notification should appear in notification panels. Defaults to true */
816
+ /** Indicates whether the notification should appear in notification panels. Defaults to `true` */
759
817
  showInPanel?: boolean;
818
+ /** Notification state. Defaults to `"Active"` */
819
+ state?: State;
760
820
  }
761
821
 
762
822
  export interface NotificationData extends RaiseOptions {
@@ -793,6 +853,24 @@ export namespace IOConnectBrowser {
793
853
  defaultClick: NotificationClickHandler;
794
854
  actionClicks: ActionClickHandler[];
795
855
  }
856
+
857
+ /** Global notification settings */
858
+ export interface Configuration {
859
+ /** If `true`, will enable all notifications. */
860
+ enable?: boolean;
861
+ /** If `true`, will enable notification toasts. */
862
+ enableToasts?: boolean;
863
+ /** Filter with names of apps that are allowed or not allowed to raise notifications. */
864
+ sourceFilter?: NotificationFilter;
865
+ }
866
+
867
+ /** Filter with names of apps that are allowed or not allowed to raise notifications. */
868
+ export interface NotificationFilter {
869
+ /** Array of names of apps allowed to raise notifications. */
870
+ allowed?: string[];
871
+ /** Array of names of apps not allowed to raise notifications. */
872
+ blocked?: string[];
873
+ }
796
874
  }
797
875
 
798
876
  /**
@@ -960,7 +1038,7 @@ export namespace IOConnectBrowser {
960
1038
  /** Describes the window instance. */
961
1039
  window: IOConnectBrowser.Windows.WebWindow
962
1040
  }
963
-
1041
+
964
1042
  }
965
1043
 
966
1044
  /**
@@ -1658,9 +1736,21 @@ export namespace IOConnectBrowser {
1658
1736
  find(intentFilter?: string | IntentFilter): Promise<Intent[]>;
1659
1737
 
1660
1738
  /**
1661
- * An object, through which IntentsResolver API is exposed.
1739
+ * Filters Intent handlers by specified criteria. If there are more than one valid Intent handlers and the Intents Resolver UI is enabled, it will open and display the available handlers.
1740
+ * @param handlerFilter Filter for the list of Intent handlers to return.
1741
+ */
1742
+ filterHandlers(handlerFilter: HandlerFilter): Promise<FilterHandlersResult>;
1743
+
1744
+ /**
1745
+ * Retrieves all Intents associated with an Intent handler.
1746
+ * @param handler Intent handler whose Intents to retrieve.
1747
+ */
1748
+ getIntents(handler: IntentHandler): Promise<GetIntentsResult>;
1749
+
1750
+ /**
1751
+ * An object, which exposes the Intents Resolver API.
1662
1752
  */
1663
- resolver?: Resolver
1753
+ resolver?: Resolver;
1664
1754
  }
1665
1755
  export interface Config {
1666
1756
  /**
@@ -1724,6 +1814,54 @@ export namespace IOConnectBrowser {
1724
1814
  resultType?: string;
1725
1815
  }
1726
1816
 
1817
+ /**
1818
+ * Provides additional information about an Intent (e.g., when an Intent is retrieved with the `getIntents()` method).
1819
+ */
1820
+ export interface IntentInfo extends AddIntentListenerRequest {}
1821
+
1822
+
1823
+ /**
1824
+ * Specifies the criteria for filtering the available Intent handlers when using the `filterHandlers()` method.
1825
+ */
1826
+ export interface HandlerFilter {
1827
+ /**
1828
+ * Title for the search operation that will be provided to the Intents Resolver UI.
1829
+ */
1830
+ title?: string;
1831
+
1832
+ /**
1833
+ * Flag indicating whether the Intents Resolver UI will open to provide the user with the list of valid Intent handlers.
1834
+ * @default true
1835
+ */
1836
+ openResolver?: boolean;
1837
+
1838
+ /**
1839
+ * Interval in milliseconds to wait for the `filterHandlers()` method to resolve if more than one Intent handler is available and the Intents Resolver UI is enabled.
1840
+ * @default 90000
1841
+ */
1842
+ timeout?: number;
1843
+
1844
+ /**
1845
+ * Intent name to be used a filter criterion.
1846
+ */
1847
+ intent?: string;
1848
+
1849
+ /**
1850
+ * List of context types with which the Intent handlers work to be used as filter criteria.
1851
+ */
1852
+ contextTypes?: string[];
1853
+
1854
+ /**
1855
+ * Result type returned by the Intent handlers to be used as a filter criterion.
1856
+ */
1857
+ resultType?: string;
1858
+
1859
+ /**
1860
+ * List of application names which will be used as a filter criteria
1861
+ */
1862
+ applicationNames?: string[];
1863
+ }
1864
+
1727
1865
  /**
1728
1866
  * Specifies the search criteria for the Intent API's `find()` method.
1729
1867
  */
@@ -1894,6 +2032,26 @@ export namespace IOConnectBrowser {
1894
2032
  */
1895
2033
  result?: any;
1896
2034
  }
2035
+
2036
+ /**
2037
+ * Describes the result returned by the `filterHandlers()` method.
2038
+ */
2039
+ export interface FilterHandlersResult {
2040
+ /**
2041
+ * List of Intent handlers that satisfy the filter criteria.
2042
+ */
2043
+ handlers: IntentHandler[];
2044
+ }
2045
+
2046
+ /**
2047
+ * Describes the result returned by the `getIntents()` method.
2048
+ */
2049
+ export interface GetIntentsResult {
2050
+ /**
2051
+ * List of objects describing the Intents associated with the specified Intent handler.
2052
+ */
2053
+ intents: IntentInfo[];
2054
+ }
1897
2055
  }
1898
2056
 
1899
2057
  /**
@@ -1958,4 +2116,110 @@ export namespace IOConnectBrowser {
1958
2116
  version: string;
1959
2117
  }
1960
2118
  }
2119
+
2120
+ /**
2121
+ * @intro
2122
+ * The App Preferences API enables apps to store custom user-specific data and retrieve it when necessary. This allows you to enhance the UX of your apps by instrumenting them to preserve specific user settings and apply them when the app is relaunched.
2123
+ *
2124
+ * The App Preferences API provides methods for updating, replacing and clearing user settings stored for the current or a specific app, as well as for all apps of the current user.
2125
+ *
2126
+ * The App Preferences API is accessible through the `io.prefs` object.
2127
+ */
2128
+ namespace Prefs {
2129
+ /**
2130
+ * App Preferences API.
2131
+ */
2132
+ export interface API {
2133
+ /**
2134
+ * Removes the user preferences for the current app.
2135
+ * @returns Promise that resolves when the user preferences for the current app have been removed.
2136
+ */
2137
+ clear(): Promise<void>;
2138
+
2139
+ /**
2140
+ * Removes all preferences stored for the current user.
2141
+ * @returns Promise that resolves when all preferences stored for the current user have been removed.
2142
+ */
2143
+ clearAll(): Promise<void>;
2144
+
2145
+ /**
2146
+ * Removes the user preferences for a specified app.
2147
+ * @param app Name of the app whose user preferences to remove.
2148
+ * @returns Promise that resolves when the user preferences for a specified app have been removed.
2149
+ */
2150
+ clearFor(app: string): Promise<void>;
2151
+
2152
+ /**
2153
+ * Retrieves the user preferences for the current app.
2154
+ * @param app Name of the app for which to retrieve the user preferences.
2155
+ * @returns Promise that resolves with the user preferences for the current app.
2156
+ */
2157
+ get(app?: string): Promise<AppPreferences>;
2158
+
2159
+ /**
2160
+ * Retrieves all preferences stored for the current user.
2161
+ * @returns Promise that resolves with all preferences stored for the current user.
2162
+ */
2163
+ getAll(): Promise<{ all: AppPreferences[] }>;
2164
+
2165
+ /**
2166
+ * Replaces the user preferences for the current app. All existing properties will be removed and replaced with the ones supplied in the `data` object.
2167
+ * @param data Data to replace the existing user preferences.
2168
+ * @param options Object with an `app` property that accepts an app name as a value. Can be used to target a specific app whose user preferences to replace.
2169
+ * @returns Promise that resolves when the user preferences for the current app have been replaced.
2170
+ */
2171
+ set(data: any, options?: { app: string }): Promise<void>;
2172
+
2173
+ /**
2174
+ * Replaces the user preferences of a specified app. All existing properties will be removed and replaced with the ones supplied in the `data` object.
2175
+ * @param app Name of the app whose user preferences to replace.
2176
+ * @param data Data to replace the existing user preferences.
2177
+ * @returns Promise that resolves when the user preferences of a specified app have been replaced.
2178
+ */
2179
+ setFor(app: string, data: any): Promise<void>;
2180
+
2181
+ /**
2182
+ * Subscribes for changes to the user preferences of the current app.
2183
+ * @param callback Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.
2184
+ * @returns Unsubscribe function.
2185
+ */
2186
+ subscribe(callback: (prefs: AppPreferences) => void): UnsubscribeFunction;
2187
+
2188
+ /**
2189
+ * Subscribes for changes to the user preferences of a specified app.
2190
+ * @param app Name of the app to which to subscribe.
2191
+ * @param callback Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.
2192
+ * @returns Unsubscribe function.
2193
+ */
2194
+ subscribeFor(app: string, callback: (prefs: AppPreferences) => void): UnsubscribeFunction;
2195
+
2196
+ /**
2197
+ * Updates the preferences for the current app. The properties specified in the `data` object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.
2198
+ * @param data Data to be merged with the existing user preferences.
2199
+ * @param options Object with an `app` property that accepts an app name as a value. Can be used to target a specific app whose user preferences to update.
2200
+ * @returns Promise that resolves when the preferences for the current app have been updated.
2201
+ */
2202
+ update(data: any, options?: { app: string }): Promise<void>;
2203
+
2204
+ /**
2205
+ * Updates the preferences for a specified app. The properties specified in the `data` object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.
2206
+ * @param app Name of the app whose user preferences to update.
2207
+ * @param data Data to be merged with the existing user preferences.
2208
+ * @returns Promise that resolves when the preferences for a specified app have been updated.
2209
+ */
2210
+ updateFor(app: string, data: any): Promise<void>;
2211
+ }
2212
+
2213
+ /**
2214
+ * App preferences object.
2215
+ */
2216
+ export interface AppPreferences {
2217
+ /** Name of the app. */
2218
+ app: string;
2219
+ /** Object holding the user preferences as key/value pairs. */
2220
+ data: any;
2221
+ /** Timestamp of the last update of the user preferences. */
2222
+ lastUpdate?: string;
2223
+ }
2224
+ }
1961
2225
  }