@openfin/workspace-platform 6.2.2 → 6.3.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.
@@ -0,0 +1,5 @@
1
+ export type { Action, DispatchedSearchResult, SearchListenerRequest, SearchListenerResponse, SearchProviderInfo, SearchResult, ScoreOrder, SearchTag, SearchProvider, UserInputListener, ResultDispatchListener, SearchResponse } from '../../../search-api/src/index';
2
+ export type { Workspace } from '../../../common/src/api/workspaces';
3
+ export type { LayoutExtended, LayoutContentExtended, LayoutSettingsExtended, LayoutContentItemExtended, LayoutComponentExtended, LayoutComponentStateExtended, LayoutStack } from '../../../common/src/utils/layout';
4
+ export type { Page, PageLayout, PageLayoutDetails } from '../../../common/src/api/pages/shapes';
5
+ export { SearchTagBackground } from '../../../search-api/src/shapes';
@@ -0,0 +1,415 @@
1
+ /**
2
+ * Use relative paths here rather than aliases which mess
3
+ * up the packaged typing files. When writing code examples,
4
+ * for documentation, please use async/await syntax over .then()!
5
+ */
6
+ import type { Page } from '../../../common/src/api/pages/shapes';
7
+ import type { Workspace } from '../../../common/src/api/workspaces';
8
+ import type { Action, DispatchedSearchResult, SearchListenerRequest, SearchListenerResponse, SearchProvider, SearchResult } from '../../../search-api/src/index';
9
+ import { CustomTemplate, ListPairs } from './templates';
10
+ export declare type CLISearchListenerRequest = SearchListenerRequest;
11
+ /**
12
+ * Representation of a search request from a specific invocation of a {@link HomeProvider | HomeProvider's} `onUserInput` listener function.
13
+ */
14
+ export interface HomeSearchListenerRequest extends CLISearchListenerRequest {
15
+ context: {
16
+ /**
17
+ * Denotes that this Home search request was triggered via
18
+ * the user selecting a suggestion from this provider.
19
+ */
20
+ isSuggestion: boolean;
21
+ /**
22
+ * Denotes that this search request should return search results
23
+ * that represent content that a user has saved. (Workspaces, Pages)
24
+ */
25
+ isSaved: boolean;
26
+ /**
27
+ * Denotes that this search request should return search results
28
+ * that represents content that is stored in the platform.
29
+ * This should exclude content that the user has saved.
30
+ * (Workspaces, Pages, Views, Apps)
31
+ */
32
+ isStore: boolean;
33
+ /**
34
+ * Denotes that this search request should return search results
35
+ * that represent other Home search providers. If the user chooses to
36
+ * launch one of these apps, they should register a Home provider.
37
+ */
38
+ isSearchEngines: boolean;
39
+ /**
40
+ * any user-selected filters will be populated here
41
+ * e.g [{
42
+ * title: 'Currency Pairs',
43
+ * type: FilterOptionType.MultiSelect,
44
+ * options: [{ value: 'GBPUSD', isSelected: true}]
45
+ * }]
46
+ */
47
+ selectedFilters?: CLIFilter[];
48
+ };
49
+ }
50
+ export declare type CLISearchListenerResponse = SearchListenerResponse;
51
+ /**
52
+ * Representation of a search response from a specific invocation of a {@link HomeProvider | HomeProvider's} `onUserInput` listener function.
53
+ * Can optionally be used to push search results to the Home UI.
54
+ *
55
+ * ```ts
56
+ * function onUserInput(req: HomeSearchListenerRequest, res: HomeSearchListenerResponse) {
57
+ * searchListenerResponse.open();
58
+ *
59
+ * const myLongRunningQuery = makeMyLongRunningQuery(searchListenerRequest.query);
60
+ * myLongRunningQuery.onNewResults(myNewResults => {
61
+ * searchListenerResponse.respond(myNewResults);
62
+ * });
63
+ *
64
+ * searchListenerRequest.onClose(() => {
65
+ * myLongRunningQuery.close();
66
+ * });
67
+ * }
68
+ * ```
69
+ */
70
+ export declare type HomeSearchListenerResponse = Omit<CLISearchListenerResponse, 'respond'> & {
71
+ respond(results: HomeSearchResult[]): void;
72
+ };
73
+ /**
74
+ * Enumerator for different types of actions that are built into the Home API.
75
+ */
76
+ export declare enum CLIAction {
77
+ Suggestion = "suggestion"
78
+ }
79
+ /**
80
+ * An action that is built into Home.
81
+ */
82
+ export interface CLIBuiltInAction<T extends CLIAction> extends Action {
83
+ name: T;
84
+ }
85
+ /**
86
+ * Built in action for suggesting another search to execute to the user.
87
+ */
88
+ export interface CLISuggestion extends CLIBuiltInAction<CLIAction.Suggestion> {
89
+ /**
90
+ * The query to search for if this action is selected.
91
+ */
92
+ query: string;
93
+ }
94
+ /**
95
+ * Union type that includes Home's built in search result actions.
96
+ */
97
+ export declare type HomeAction = CLISuggestion | Action;
98
+ /**
99
+ * A search result that can be rendered by a Workspace component.
100
+ */
101
+ export declare type CLISearchResult<A extends Action> = SearchResult<A>;
102
+ /**
103
+ * A list of template types that determine how a search result is rendered.
104
+ */
105
+ export declare enum CLITemplate {
106
+ /**
107
+ * Contact Information Template
108
+ */
109
+ Contact = "Contact",
110
+ /**
111
+ * Custom Template
112
+ */
113
+ Custom = "Custom",
114
+ /**
115
+ * Definition List Template
116
+ */
117
+ List = "List",
118
+ /**
119
+ * Non-Template search result.
120
+ */
121
+ Plain = "Plain",
122
+ /**
123
+ * Simple Text Template
124
+ */
125
+ SimpleText = "SimpleText"
126
+ }
127
+ /**
128
+ * {@link SearchResult | Search result} template definition
129
+ */
130
+ export interface CLISearchResultWithTemplate<T extends keyof typeof CLITemplate, C, A extends Action> extends CLISearchResult<A> {
131
+ template: T;
132
+ templateContent: C;
133
+ }
134
+ /**
135
+ * Contact Data.
136
+ */
137
+ export interface ContactInfo {
138
+ /**
139
+ * Name of the contact.
140
+ */
141
+ name: string;
142
+ /**
143
+ * Title of the contact.
144
+ */
145
+ title?: string;
146
+ /**
147
+ * URL for the contact's profile photo.
148
+ */
149
+ photoUrl?: string;
150
+ /**
151
+ * A flag to indicate that the contact card should display the contact's initials as profile photo if the photo url is undefined.
152
+ */
153
+ useInitials?: boolean;
154
+ /**
155
+ * An array of detail list objects that can be used for logical grouping of contact details.
156
+ */
157
+ details: ListPairs[];
158
+ }
159
+ /**
160
+ * Contact Info Search Result
161
+ */
162
+ export interface CLISearchResultContact<A extends Action = Action> extends CLISearchResultWithTemplate<CLITemplate.Contact, ContactInfo, A> {
163
+ }
164
+ /**
165
+ * A Search Result that renders custom templates.
166
+ */
167
+ export interface CLISearchResultCustom<A extends Action = Action> extends CLISearchResultWithTemplate<CLITemplate.Custom, CustomTemplate, A> {
168
+ }
169
+ /**
170
+ * Definition List Search Result
171
+ */
172
+ export interface CLISearchResultList<A extends Action = Action> extends CLISearchResultWithTemplate<CLITemplate.List, ListPairs, A> {
173
+ }
174
+ /**
175
+ * Non-Template Search Result
176
+ */
177
+ export interface CLISearchResultPlain<A extends Action = Action> extends CLISearchResultWithTemplate<CLITemplate.Plain, undefined, A> {
178
+ }
179
+ /**
180
+ * Simple Text Search Result
181
+ */
182
+ export interface CLISearchResultSimpleText<A extends Action = Action> extends CLISearchResultWithTemplate<CLITemplate.SimpleText, string, A> {
183
+ }
184
+ /**
185
+ * A search result that can be rendered by Home UI.
186
+ */
187
+ export declare type HomeSearchResult = CLISearchResultContact<HomeAction> | CLISearchResultSimpleText<HomeAction> | CLISearchResultList<HomeAction> | CLISearchResultPlain<HomeAction> | CLISearchResultCustom<HomeAction>;
188
+ export declare enum CLIFilterOptionType {
189
+ /**
190
+ * Display a multi-select drop down for the options
191
+ */
192
+ MultiSelect = "MultiSelect"
193
+ }
194
+ /**
195
+ * An option object containing values to filter
196
+ */
197
+ export interface CLIFilterOption {
198
+ value: string;
199
+ isSelected?: boolean;
200
+ }
201
+ /**
202
+ * A search filter that will be rendered by a Workspace component.
203
+ */
204
+ export interface CLIFilter {
205
+ id: string;
206
+ title: string;
207
+ type?: CLIFilterOptionType;
208
+ options: CLIFilterOption[] | CLIFilterOption;
209
+ }
210
+ /**
211
+ * An object returned from a CLI provider's 'onUserInput' function containing search results.
212
+ */
213
+ export interface CLISearchResponse {
214
+ /**
215
+ * The search results to render in the Workspace component.
216
+ */
217
+ results: CLISearchResult<Action>[];
218
+ /**
219
+ * Additional custom context to pass back to the Workspace component.
220
+ */
221
+ context?: any;
222
+ }
223
+ /**
224
+ * An object resolved from 'onUserInput' function containing search results and optional filters.
225
+ */
226
+ export interface HomeSearchResponse extends CLISearchResponse {
227
+ /**
228
+ * The search results to render in the Home UI.
229
+ */
230
+ results: HomeSearchResult[];
231
+ /**
232
+ * Filters to render in the Home UI.
233
+ */
234
+ context?: {
235
+ filters?: CLIFilter[];
236
+ };
237
+ }
238
+ /**
239
+ * A rendered search result that has been actioned by a user.
240
+ */
241
+ export declare type CLIDispatchedSearchResult = DispatchedSearchResult;
242
+ /**
243
+ * A CLI provider responds to search requests from Workspace components.
244
+ * Upon receiving a search request, a CLI provider can return search results that can be rendered and interacted with
245
+ * by a user by the requesting Workspace component.
246
+ */
247
+ export interface CLIProvider extends SearchProvider {
248
+ /**
249
+ * Function that is called when a search request is triggered due to user input.
250
+ *
251
+ * ```ts
252
+ *
253
+ * import { getAllData, getResultsByQuery } from './get-all-data';
254
+ *
255
+ * const onUserInput = async({ query }): Promise<CLISearchResponse> => {
256
+ * if (!query) {
257
+ * return getAllData();
258
+ * }
259
+ *
260
+ * // Provide an implmentation to fetch query-filtered search results
261
+ * return getResultsByQuery(query);
262
+ * }
263
+ * ```
264
+ * @param req describes search request.
265
+ * @param res can be used to stream search results back to the requesting Workspace component.
266
+ * @returns an object that contains the search results to render in the requesting Workspace component.
267
+ */
268
+ onUserInput(req: CLISearchListenerRequest, res: CLISearchListenerResponse): Promise<CLISearchResponse>;
269
+ /**
270
+ * Callback that is invoked when ever a search result returned by this provider
271
+ * is interacted with from a Workspace component. (clicked, pressed enter, hotkey pressed, etc.)
272
+ *
273
+ *
274
+ * ```ts
275
+ * import { getAvailableCommands } from './my-commands';
276
+ *
277
+ * const onResultDispatch = async(result: CLIDispatchedSearchResult): Promise<void> => {
278
+ * try {
279
+ * //Grab the command corresponding to the result
280
+ * const availableCommands = await getAvailableCommands();
281
+ * const commandToExecute = availableCommands.find((command) => command.key === result.key);
282
+ *
283
+ * if (commantToExecute != undefined) {
284
+ * await commandToExecute.action();
285
+ * }
286
+ * } catch (err) {
287
+ * //Handle the error
288
+ * log.error('Error trying to action show command %s', err, result.key);
289
+ * }
290
+ * }
291
+ *```
292
+ * @param result the search result with the action that was selected by the user.
293
+ */
294
+ onResultDispatch?(result: CLIDispatchedSearchResult): Promise<void>;
295
+ }
296
+ /**
297
+ * A CLI provider responds to search requests from Home UI.
298
+ * Exposes search features that are specifically supported by Home.
299
+ */
300
+ export interface HomeProvider extends CLIProvider {
301
+ onUserInput(req: HomeSearchListenerRequest, res: HomeSearchListenerResponse): Promise<HomeSearchResponse>;
302
+ }
303
+ /**
304
+ * Interface that contains functions for integrating with Home.
305
+ */
306
+ export interface HomeAPI {
307
+ /**
308
+ * Register a provider that can return search results to Home.
309
+ *
310
+ * ```ts
311
+ * import { Home, CLIProvider } from "@openfin/workspace";
312
+ *
313
+ * import { fetchMySearchResults } from "./my-fetch-implementation";
314
+ *
315
+ * const myCLIProvider: CLIProvider = {
316
+ * name: "my-cli-provider",
317
+ * title: "My CLI Provider",
318
+ * icon: "https://google.com/favicon.ico",
319
+ * onUserInput: (req) => fetchMySearchResults(req.query)
320
+ * };
321
+ *
322
+ * const register = async () => {
323
+ * await Home.register(myCLIProvider);
324
+ * }
325
+ * ```
326
+ *
327
+ * @param provider the provider implementation.
328
+ */
329
+ register(provider: HomeProvider | CLIProvider): Promise<void>;
330
+ /**
331
+ * Deregister a provider.
332
+ *
333
+ * ```ts
334
+ * import { Home , CLIProvider } from "@openfin/workspace";
335
+ *
336
+ * import { fetchMySearchResults } from "./my-fetch-implementation";
337
+ *
338
+ * const myCLIProvider: CLIProvider = {
339
+ * name: "my-cli-provider",
340
+ * title: "My CLI Provider",
341
+ * icon: "https://google.com/favicon.ico",
342
+ * onUserInput: (req) => fetchMySearchResults(req.query)
343
+ * };
344
+ *
345
+ * // Register and do some work with the provider
346
+ *
347
+ * const deregister = async () => {
348
+ * await Home.deregister("my-cli-provider");
349
+ * }
350
+ * ```
351
+ * @param providerId the name of the provider.
352
+ */
353
+ deregister(providerId: string): Promise<void>;
354
+ /**
355
+ * Show the Home UI.
356
+ *
357
+ * ```ts
358
+ * import { Home } from './home'
359
+ *
360
+ * const show = async () => {
361
+ * await Home.show();
362
+ * // Do thing after show
363
+ * }
364
+ * ```
365
+ */
366
+ show(): Promise<void>;
367
+ /**
368
+ * Hide the Home UI.
369
+ *
370
+ * ```ts
371
+ * import { Home } from './home'
372
+ *
373
+ * const hide = async () => {
374
+ * await Home.hide();
375
+ * // Do thing after hide
376
+ * }
377
+ * ```
378
+ */
379
+ hide(): Promise<void>;
380
+ }
381
+ /**
382
+ * Interface that contains functions that aid in recovering legacy features of Workspace.
383
+ */
384
+ export interface LegacyAPI {
385
+ /**
386
+ * Get the pages that a user had saved in a legacy version of Workspace. (pre 5.0.0)
387
+ *
388
+ * ```ts
389
+ * import { Legacy } from "@openfin/workspace";
390
+ *
391
+ * async logPages() {
392
+ * const pages = await Legacy.getPages();
393
+ * console.log(pages);
394
+ * }
395
+ *
396
+ * logPages();
397
+ * ```
398
+ */
399
+ getPages(): Promise<Page[]>;
400
+ /**
401
+ * Get the workspaces that a user had saved in a legacy version of Workspace. (pre 5.0.0)
402
+ *
403
+ * ```ts
404
+ * import { Legacy } from "@openfin/workspace";
405
+ *
406
+ * async logWorkspaces() {
407
+ * const workspaces = await Legacy.getWorkspaces();
408
+ * console.log(workspaces);
409
+ * }
410
+ *
411
+ * logWorkspaces();
412
+ * ```
413
+ */
414
+ getWorkspaces(): Promise<Workspace[]>;
415
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * WARNING: Do not export from './notifications' here. Not unless we move 'openfin-notifications' here.
3
+ */
4
+ export * from './common';
5
+ export * from './home';
6
+ export * from './store';
7
+ export * from './templates';