@interopio/search-api 2.5.1 → 3.0.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/search.d.ts CHANGED
@@ -1,102 +1,378 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { IOConnectCore } from "@interopio/core";
3
3
 
4
+ /**
5
+ * @docname Search
6
+ * @intro
7
+ * The Search API offers two distinct functionalities: you can use it to create both search providers and search clients.
8
+ * Search providers are apps that respond to search queries, whereas search clients are apps that initiate searches.
9
+ * For instance, a search provider may return a list of instruments as a response to a search query, and may also support
10
+ * one or more actions - like showing a chart for the selected instrument. Actions may be executed when the user clicks
11
+ * on a result in the UI of a search client app. You may present multiple actions as options to the user via the search
12
+ * client UI, so that they may choose how to handle the search result depending on their current needs.
13
+ * The Search API also enables you to define search types, set debounce time for search queries,
14
+ * set limits for search results and more.
15
+ *
16
+ * The Search API is accessible via the `io.search` object.
17
+ */
4
18
  export namespace IOConnectSearch {
5
19
 
6
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
7
- export interface Config {}
20
+ /**
21
+ * @ignore
22
+ */
23
+ export interface Config {} // eslint-disable-line @typescript-eslint/no-empty-interface
8
24
 
25
+ /**
26
+ * Search API.
27
+ */
9
28
  export interface API {
29
+
30
+ /**
31
+ * Search API version.
32
+ */
10
33
  version: string;
34
+
35
+ /**
36
+ * Sets the debounce interval for search queries.
37
+ * @param milliseconds Interval in milliseconds to use as debounce interval.
38
+ */
11
39
  setDebounceMS(milliseconds: number): void;
40
+
41
+ /**
42
+ * Retrieves the current debounce interval for search queries.
43
+ */
12
44
  getDebounceMS(): number;
45
+
46
+ /**
47
+ * Retrieves a list of all available search providers.
48
+ */
13
49
  listProviders(): Promise<ProviderData[]>;
50
+
51
+ /**
52
+ * Retrieves a list of all available search types from all search providers.
53
+ */
14
54
  listTypes(): Promise<SearchType[]>;
55
+
56
+ /**
57
+ * Creates a search query.
58
+ * @param queryConfig Settings for creating a search query.
59
+ */
15
60
  query(queryConfig: QueryConfig): Promise<Query>;
61
+
62
+ /**
63
+ * Registers a search provider.
64
+ * @param config Settings for registering a search provider.
65
+ */
16
66
  registerProvider(config: ProviderRegistrationConfig): Promise<Provider>;
17
67
  }
18
68
 
69
+ /**
70
+ * Describes a created search query.
71
+ */
19
72
  export interface Query {
73
+
74
+ /**
75
+ * Cancels the search query.
76
+ */
20
77
  cancel(): Promise<void>;
78
+
79
+ /**
80
+ * Notifies when a batch with results from the search query is received.
81
+ * @param callback Callback function for handling the event. Receives as an argument an object holding
82
+ * a list of the available search result and details about the search provider that has sent the results.
83
+ */
21
84
  onResults(callback: (resultBatch: QueryResultBatch) => void): UnsubscribeFunction;
85
+
86
+ /**
87
+ * Notifies when the search query is completed, i.e. when all search operations
88
+ * in all search providers have been completed.
89
+ * @param callback Callback function for handling the event.
90
+ */
22
91
  onCompleted(callback: () => void): UnsubscribeFunction;
92
+
93
+ /**
94
+ * Notifies when there is an error in the search process.
95
+ * @param callback Callback function for handling the event. Receives as an argument an object holding
96
+ * the error message sent by the search provider and data describing the provider that has sent the error.
97
+ */
23
98
  onError(callback: (error: QueryError) => void): UnsubscribeFunction;
24
99
  }
25
100
 
101
+ /**
102
+ * Describes a registered search provider.
103
+ */
26
104
  export interface Provider extends ProviderData {
105
+
106
+ /**
107
+ * Notifies when a search query is received.
108
+ * @param callback Callback function for handling the event. Receives as an argument an object describing the search query.
109
+ */
27
110
  onQuery(callback: (query: ProviderQuery) => void): UnsubscribeFunction;
111
+
112
+ /**
113
+ * Notifies when a search query is canceled.
114
+ * @param callback Callback function for handling the event. Receives as an argument an object with an `id` property
115
+ * holding the ID of the canceled search query.
116
+ */
28
117
  onQueryCancel(callback: (query: { id: string }) => void): UnsubscribeFunction;
118
+
119
+ /**
120
+ * Unregisters the search provider from the framework.
121
+ */
29
122
  unregister(): Promise<void>;
30
123
  }
31
124
 
125
+ /**
126
+ * Search provider details.
127
+ */
32
128
  export interface ProviderData {
129
+
130
+ /**
131
+ * Unique ID of the Interop instance of the app.
132
+ */
33
133
  interopId: string;
134
+
135
+ /**
136
+ * Unique app ID within the framework.
137
+ */
34
138
  id: string;
139
+
140
+ /**
141
+ * Name of the search provider.
142
+ */
35
143
  name: string;
144
+
145
+ /**
146
+ * Name of the app that has registered the search provider.
147
+ */
36
148
  appName?: string;
149
+
150
+ /**
151
+ * List of search types with which the search provider works.
152
+ */
37
153
  types?: SearchType[];
38
154
  }
39
155
 
156
+ /**
157
+ * Settings for creating a search query.
158
+ */
40
159
  export interface QueryConfig {
160
+
161
+ /**
162
+ * String for which to query the search providers.
163
+ */
41
164
  search: string;
165
+
166
+ /**
167
+ * List of search providers to query.
168
+ */
42
169
  providers?: ProviderData[];
170
+
171
+ /**
172
+ * List of search types in which the search client app is interested.
173
+ */
43
174
  types?: SearchType[];
175
+
176
+ /**
177
+ * Specifies the maximum total results and/or the maximum results per search type to return.
178
+ */
44
179
  providerLimits?: ProviderLimits;
45
180
  }
46
181
 
182
+ /**
183
+ * Describes the search query received by the search provider and provides methods for responding to it.
184
+ */
47
185
  export interface ProviderQuery extends QueryConfig {
186
+
187
+ /**
188
+ * ID for the search query (assigned by the framework).
189
+ */
48
190
  id: string;
191
+
192
+ /**
193
+ * Sends individual results back to search clients.
194
+ * @param result Individual search result to send back to search clients.
195
+ */
49
196
  sendResult(result: QueryResult): void;
197
+
198
+ /**
199
+ * Sends errors back to search clients.
200
+ * @param error Error message to send back to search clients.
201
+ */
50
202
  error(error: string): void;
203
+
204
+ /**
205
+ * Signals the framework that the search operation has been completed.
206
+ */
51
207
  done(): void;
52
208
  }
53
209
 
210
+ /**
211
+ * Settings for registering a search provider.
212
+ */
54
213
  export interface ProviderRegistrationConfig {
214
+
215
+ /**
216
+ * Name for the search provider.
217
+ */
55
218
  name: string;
219
+
220
+ /**
221
+ * Search types with which the provider works.
222
+ */
56
223
  types?: SearchType[];
57
224
  }
58
225
 
226
+ /**
227
+ * Describes a batch of search results received by search clients.
228
+ */
59
229
  export interface QueryResultBatch {
230
+
231
+ /**
232
+ * List of individual search results received by search clients.
233
+ */
60
234
  results: QueryResult[];
235
+
236
+ /**
237
+ * Details about the search provider that has sent the results.
238
+ */
61
239
  provider?: ProviderData;
62
240
  }
63
241
 
242
+ /**
243
+ * Describes a search operation error received by search clients.
244
+ */
64
245
  export interface QueryError {
246
+
247
+ /**
248
+ * Error message.
249
+ */
65
250
  error: string;
251
+
252
+ /**
253
+ * Details about the search provider that has sent the error.
254
+ */
66
255
  provider?: ProviderData;
67
256
  }
68
257
 
258
+ /**
259
+ * Describes the maximum total results and/or the maximum results per search type to return.
260
+ */
69
261
  export interface ProviderLimits {
262
+
263
+ /**
264
+ * Maximum total results per search operation to return.
265
+ */
70
266
  maxResults?: number;
267
+
268
+ /**
269
+ * Maximum results per search type to return.
270
+ */
71
271
  maxResultsPerType?: number;
72
272
  }
73
273
 
274
+ /**
275
+ * Describes an individual search result received by search clients.
276
+ */
74
277
  export interface QueryResult {
278
+
279
+ /**
280
+ * The predefined search type of the result.
281
+ */
75
282
  type: SearchType;
283
+
284
+ /**
285
+ * ID for the search result that can be used by the search client when handling the result.
286
+ */
76
287
  id?: string;
288
+
289
+ /**
290
+ * Display name for the search result that can be used in a UI.
291
+ */
77
292
  displayName?: string;
293
+
294
+ /**
295
+ * Description for the search result that can be used in a UI.
296
+ */
78
297
  description?: string;
298
+
299
+ /**
300
+ * URL pointing to an icon for the search result that can be used in a UI.
301
+ */
79
302
  iconURL?: string;
303
+
304
+ /**
305
+ * Metadata for the search result that can be used by the search client when handling the result.
306
+ */
80
307
  metadata?: any;
308
+
309
+ /**
310
+ * A main action that can be used to invoke an already registered Interop method when the user clicks on the search result displayed in a UI.
311
+ * If you need to define multiple actions when handling search results, you can use the `secondaryActions` property instead.
312
+ */
81
313
  action?: MainAction;
314
+
315
+ /**
316
+ * Secondary actions can be used to invoke different already registered Interop methods if, for example, you want to present the user
317
+ * with a choice of options related to the search result. The `secondaryActions` property can be used independently,
318
+ * without defining a `MainAction` in the `action` property.
319
+ */
82
320
  secondaryActions?: SecondaryAction[];
83
321
  }
84
322
 
323
+ /**
324
+ * Describes an already registered Interop method to be assigned as a main action to a search result.
325
+ * This allows search clients to invoke the specified Interop method if, for example, the user clicks on the search result in a UI.
326
+ */
85
327
  export interface MainAction {
328
+
329
+ /**
330
+ * Name of an Interop method to assign as an action for a search result.
331
+ */
86
332
  method: string;
333
+
334
+ /**
335
+ * Defines the Interop servers that will be targeted when invoking the specified method. Set to `"all"` to invoke the method on all Interop servers offering it.
336
+ * Alternatively, you can pass the Interop ID of a specific Interop server you want to target.
337
+ */
87
338
  target?: { instance: string } | "all";
339
+
340
+ /**
341
+ * Arguments to be passed to the specified Interop method when a search client invokes it.
342
+ */
88
343
  params?: any;
89
344
  }
90
345
 
346
+ /**
347
+ * Describes an already registered Interop method to be assigned as a secondary action to a search result.
348
+ */
91
349
  export interface SecondaryAction extends MainAction {
350
+
351
+ /**
352
+ * Name for the assigned action. May be used to differentiate between actions on the client side.
353
+ */
92
354
  name: string;
93
355
  }
94
356
 
357
+ /**
358
+ * Describes an entity with which a search provided works.
359
+ */
95
360
  export interface SearchType {
361
+
362
+ /**
363
+ * Name for the search type.
364
+ */
96
365
  name: string;
366
+
367
+ /**
368
+ * User-friendly name for the search type that can be displayed in UIs.
369
+ */
97
370
  displayName?: string;
98
371
  }
99
372
 
373
+ /**
374
+ * Function that can be used to stop receiving notifications about events.
375
+ */
100
376
  type UnsubscribeFunction = () => void;
101
377
  }
102
378