@interopio/search-api 3.2.1 → 3.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.
package/README.md CHANGED
@@ -1,244 +1,73 @@
1
- # IO Connect Search API
2
-
3
- Apps can perform searches and provide results for others' searches.
4
-
5
- For example, let's say an app provides Seinfeld quotes, and wants to make those quotes available to any other app. The Seinfeld app could register itself as a search provider with this:
6
-
7
- ```js
8
- // Registering as a provider
9
- const provider = await glue.search.registerProvider({
10
- name: "Seinfeld-Quotes"
11
- });
12
-
13
- // Registering how the provider will respond to queries
14
- provider.onQuery(({search, sendResults, done}) => {
15
- const textOfQuote = doStuffInternally(search);
16
-
17
- sendResults({
18
- type: {
19
- name: "tv-quote",
20
- displayName: "Seinfeld Quotes"
21
- },
22
- id: "quote-123",
23
- description: textOfQuote
24
- });
25
-
26
- done();
27
- })
28
- ```
29
-
30
- Now, let's say an app is interested to see if there are any Seinfeld quotes with the word "architect". It would use the following function:
31
-
32
- ```js
33
- const query = await glue.search.query({search: "architect"});
34
- query.onResults((result) => {
35
- /*
36
- // Example value for result -
37
- {
38
- provider: {
39
- id: "INTERNAL_ID",
40
- interopId: "INTERNAL_INSTANCE_ID",
41
- name: "Seinfeld-Quotes" // The search provider's name
42
- appName: "seinfeld-app", // The app that registered the search provider
43
- },
44
- result: {
45
- type: {
46
- name: "tv-quote",
47
- displayName: "Seinfeld Quotes"
48
- },
49
- id: "quote-123",
50
- description: "You know I always wanted to pretend I was an architect.
51
- }
52
- }
53
- */
54
- })
55
- ```
1
+ # @interopio/search-api
56
2
 
57
- ## Checklists
3
+ ## Overview
58
4
 
59
- If you're writing a custom search provider, here are things to make sure you implement:
5
+ The [`@interopio/search-api`](https://www.npmjs.com/package/@interopio/search-api) library enables you to create both search providers and search clients in **io.Connect Desktop** and **io.Connect Browser** projects.
60
6
 
61
- Basics
62
- - [ ] Registering provider
63
- - [ ] Generate and send results
7
+ ## Installation
64
8
 
65
- Other considerations:
66
- - [ ] Call `done()` once you are done (in case queriers are waiting on `onCompleted()`)
67
- - [ ] Are you checking the `types` property? You don't want to ignore the restrictions the querier placed on their query.
68
- - [ ] Are you checking the `maxResults` property? You don't want to return more that the querier asked for.
69
- - [ ] Ditto for `maxResultsByType`
70
- - [ ] Did you set up error handling, and include the `error()` callback if necessary?
71
- - [ ] Do your queries take a long enough time that they might get cancelled? If so, are you handling `onQueryCancel`?
9
+ To install the library, execute the following command:
72
10
 
11
+ ```cmd
12
+ npm install @interopio/search-api
13
+ ```
73
14
 
74
- If you're querying a search providerm here are things to make sure you implement:
75
- - [ ] Call the query (eg `const query = await glue.search.query({search: "My search string"})`)
76
- - [ ] Handle `onResults` (eg `query.onResults(displaySearchResult)`)
77
- - [ ] Handle `onError`
78
-
79
- Other considerations:
80
- - [ ] Is there a situation where you need to `cancel()` your query?
81
- - [ ] Do you need to limit the quantity of results you receive (using `providerLimits`)?
82
- - [ ] Do you need `onCompleted`, to see when different search providers have finished? If so, does it also make sense to include a timeout (in case a search provider *doesn't* indicate when they're `done()`?)
83
- - [ ] Are you interested in only certain **types** of content? Would it make sense to call `listTypes()` to see if the type you're looking is being provided? Would it makse sense to limit your search results to a certain type?
84
- - [ ] Are you interested in only certain **providers**? Would it make sense to call `listProviders()` to see if the provider you're looking is present? Would it makse sense to limit your search results to certain providers?
85
- - [ ] Sometimes, search results include `actions`. If that makes sense for your use cases, are you handling incoming actions?
15
+ ## Usage
86
16
 
17
+ The following examples demonstrate basic initialization of the `@interopio/search-api` library in **io.Connect Desktop** and **io.Connect Browser** projects.
87
18
 
88
- ## API
19
+ > ℹ️ *For more details on using the `@interopio/search-api` library in **io.Connect Desktop** projects, see the **io.Connect Desktop** [official documentation](https://docs.interop.io/desktop/capabilities/search/overview/index.html).*
89
20
 
90
- glue.search has the following methods:
91
- - getDebounceMS
92
- - listProviders
93
- - listTypes
94
- - query
95
- - registerProvider
96
- - setDebounceMS
97
- - version
21
+ > ℹ️ *For more details on using the `@interopio/search-api` library in **io.Connect Browser** projects, see the **io.Connect Browser** [official documentation](https://docs.interop.io/browser/capabilities/search/setup/index.html).*
98
22
 
99
- ### registerProvider
23
+ ### io.Connect Desktop
100
24
 
101
- Config options for `.registerProvider()` are:
102
- - `name` (required)
103
- - `types` (optional but recommended). If you register a custom type, it will appear in the `.listTypes` method.
25
+ Initializing the `@interopio/search-api` library in a client app of an **io.Connect Desktop** project:
104
26
 
105
- ```js
106
- const provider = await glue.search.registerProvider({name: "test"});
107
- ```
27
+ ```javascript
28
+ import IODesktop from "@interopio/desktop";
29
+ import IOSearch from "@interopio/search-api";
108
30
 
109
- ```js
110
- const provider = await glue.search.registerProvider({
111
- name: "test",
112
- types: [
113
- {name: "application"}
114
- ]
115
- });
116
- ```
31
+ const config = {
32
+ libraries: [IOSearch]
33
+ };
117
34
 
118
- `registerProvider` returns a promise that resolves to a `Provider` object. This has the following available methods:
119
- - `onQuery` - callback when search queries are executed
120
- - `onQueryCancel` - callback when an app cancels its search query
121
- - `unregister` - an unregistration method.
122
-
123
- :::tip
124
- Search providers are automatically unregistered when windows are closed. Unregistration is a good cleanup action, but may not be required.
125
- :::
126
-
127
- The `onQuery` callback provides a `ProviderQuery` object, with the following properties:
128
- - id - referenced when cancelling the query
129
- - search - the text being searched for
130
- - providers - the providers the querier is interested in
131
- - types - the SearchTypes the querier is interested in
132
- - providerLimits.maxResults - the maximum number of results the querier wants to receive from each provider
133
- - providerLimits.maxResultsPerType - the maximum number of results PER TYPE the querier wants to recevie from each provider
134
- - sendResult - callback for sending an individual result. (The querier receives this with the `query.onResults()` callback)
135
- - error - callback if there's an error (The querier receives this with the `query.onError()` callback)
136
- - done - callback once all results have been sent (The querier receives this with the `query.done()` callback)
137
-
138
- When sending a result, you supply a `QueryResult` object. The properties of that object are:
139
- - type (required) - a `SearchType` (eg: `{name: "application"}`)
140
- - id
141
- - displayName
142
- - description
143
- - iconURL
144
- - metadata
145
- - action - metadata information about a method you'd want to invoke
146
- - secondaryActions - more actions
147
-
148
- ### query
149
-
150
- You create a query object with the `query()` method:
151
- ```js
152
- const query = await glue.search.query({search: "My search query"});
153
- ```
35
+ const io = await IODesktop(config);
154
36
 
155
- The `query` method takes the following properties:
156
- - `search` (required) (string) - what you're searching for
157
- - `providers` (`ProviderData[]`) - providers you want to limit your search to
158
- - `types` (`SearchType[]`) - the types of results you want to limit your search to
159
- - `providerLimits.maxResults` (number) - the maximum number of results the querier wants to receive from each provider
160
- - `providerLimits.maxResultsPerType` (number) - the maximum number of results PER TYPE the querier wants to recevie from each provider
161
-
162
-
163
- The query object you receive has the following methods:
164
- - `cancel()` - Cancels the query. (See provider's `onQueryCancel()`)
165
- - `onResults()` - Callback to receive results (See provider's query handling for `sendResult()`)
166
- - `onCompleted()` - Callback when provider is done (See provider's query handling for `done()`)
167
- - `onError()` - Callback when provider has an error (See provider's query handling for `error()`)
168
-
169
- ### listProviders
170
-
171
- ```js
172
- await glue.search.listProviders();
173
- /*
174
- Example results: [
175
- {
176
- appName: "fsbl-test-butler",
177
- id: "INTERNAL_ID",
178
- interopId: "INSTANCE_ID",
179
- name: "registered-search-provider-custom-name",
180
- },
181
- {
182
- appName: "tester",
183
- id: "INTERNAL_ID",
184
- interopId: "INSTANCE_ID",
185
- name: "my-tester",
186
- types: [{name: "test-type"}]
187
- }
188
- ]
189
- */
37
+ // Now you can access the Search API via `io.search`.
190
38
  ```
191
39
 
192
- ### listTypes
193
-
194
- You can see what search types are available. This is especially useful if you are relying on a custom search type from another app, and want to confirm that that app has already been registered.
195
-
196
- ```js
197
- await glue.search.listTypes();
198
- /*
199
- Example results: [
200
- {name: "customSearchType"},
201
- {name: "application"},
202
- {name: "layout"},
203
- {name: "workspace"},
204
- {name: "swimlane"},
205
- {name: "action"}
206
- ]
207
- */
208
- ```
40
+ ### io.Connect Browser
209
41
 
210
- ### getDebounceMS, setDebounceMS
42
+ Initializing the `@interopio/search-api` library in the Main app of an **io.Connect Browser** project:
211
43
 
212
- **Default debounce: 0ms**
44
+ ```javascript
45
+ import IOBrowserPlatform from "@interopio/browser-platform";
46
+ import IOSearch from "@interopio/search-api";
213
47
 
214
- Queries can be debounced. If you plan on querying based on individual keystrokes or mouse movements, you can potentially generate an unnecessarily large message flurry. Debouncing the queries will reduce search query traffic.
48
+ const config = {
49
+ licenseKey: "my-license-key",
50
+ browser: {
51
+ libraries: [IOSearch]
52
+ }
53
+ };
215
54
 
216
- Here are examples of getting/setting the debounce time:
217
- ```js
218
- // Get the debounce time:
219
- glue.search.getDebounceMS(); // returns 0 by default
55
+ const { io } = await IOBrowserPlatform(config);
220
56
 
221
- // Set the debounce time to 20ms:
222
- glue.search.setDebounceMS(20);
57
+ // Now you can access the Search API via `io.search`.
223
58
  ```
224
59
 
225
- ## Actions
226
- TBD
60
+ Initializing the `@interopio/search-api` library in a Browser Client app of an **io.Connect Browser** project:
227
61
 
62
+ ```javascript
63
+ import IOBrowser from "@interopio/browser";
64
+ import IOSearch from "@interopio/search-api";
228
65
 
229
- ## Developer notes
66
+ const config = {
67
+ libraries: [IOSearch]
68
+ };
230
69
 
231
- /* eslint-disable @typescript-eslint/no-explicit-any */
70
+ const io = await IOBrowser(config);
232
71
 
233
- // package name: @interopio/search-api -> adds the Search API
234
-
235
- // @interopio/browser-platform -> can use the package to register as a provider or use as a client, by default register as a provider for applications, workspaces, layouts and optionally actions
236
- // @interopio/browser -> can use the package to register as a provider or use as a client
237
- // GD3 -> by default register as a provider for applications, workspaces, layouts and optionally actions
238
-
239
- // Foundation: Interop and Shared Context
240
- // lib registers: lazily two methods
241
- // lib uses: shared context to providers state management
242
- // method used when registered as provider to accept queries
243
-
244
- // category = display name for type
72
+ // Now you can access the Search API via `io.search`.
73
+ ```
package/changelog.md CHANGED
@@ -1,3 +1,5 @@
1
+ 3.3.0
2
+ feat: io.Connect Browser 4.3
1
3
  3.2.0
2
4
  feat: io.Connect Browser 4.2
3
5
  3.1.0
@@ -1741,7 +1741,7 @@ class ProviderController {
1741
1741
  }
1742
1742
  }
1743
1743
 
1744
- var version = "3.2.1";
1744
+ var version = "3.3.0";
1745
1745
 
1746
1746
  class SearchFacade {
1747
1747
  main;
@@ -1747,7 +1747,7 @@
1747
1747
  }
1748
1748
  }
1749
1749
 
1750
- var version = "3.2.1";
1750
+ var version = "3.3.0";
1751
1751
 
1752
1752
  class SearchFacade {
1753
1753
  main;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/search-api",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "Glue42 Search API",
5
5
  "main": "./dist/search-api.umd.js",
6
6
  "module": "./dist/search-api.es.js",
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@interopio/core": "^6.8.1"
33
+ "@interopio/core": "^6.10.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "@interopio:registry": "https://registry.npmjs.org",
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "cd8bec6c31acddd1478d6cc185641a16b8e60af4"
39
+ "gitHead": "41c6ecb07b59a228eecc8597d7bd4862a0c1dfa0"
40
40
  }