kibana/x-pack/plugins/global_search
Alejandro Fernández Haro 11b750b10a
Minimize shared-common everywhere (#188606)
## Summary


![8xfggo](https://github.com/user-attachments/assets/f3d9312f-2ad3-4fa2-9daf-01e2b1ad6cac)

At the moment, our package generator creates all packages with the type
`shared-common`. This means that we cannot enforce boundaries between
server-side-only code and the browser, and vice-versa.

- [x] I started fixing `packages/core/*`
- [x] It took me to fixing `src/core/` type to be identified by the
`plugin` pattern (`public` and `server` directories) vs. a package
(either common, or single-scoped)
- [x] Unsurprisingly, this extended to packages importing core packages
hitting the boundaries eslint rules. And other packages importing the
latter.
- [x] Also a bunch of `common` logic that shouldn't be so _common_ 🙃 

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-29 12:47:46 -06:00
..
common Minimize shared-common everywhere (#188606) 2024-07-29 12:47:46 -06:00
public Minimize shared-common everywhere (#188606) 2024-07-29 12:47:46 -06:00
server Use rxjs instead of rxjs/operators (#179553) 2024-04-02 11:41:33 -07:00
jest.config.js
jest.integration.config.js
kibana.jsonc Core to SharedOX ownership Transfer: Updates code owners for handover to sharedUX (#151213) 2023-02-15 11:33:39 -07:00
README.md
tsconfig.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00

Kibana GlobalSearch plugin

The GlobalSearch plugin provides an easy way to search for various objects, such as applications or dashboards from the Kibana instance, from both server and client-side plugins

Consuming the globalSearch API

startDeps.globalSearch.find('some term').subscribe({
  next: ({ results }) => {
    addNewResultsToList(results);
  },
  error: () => {},
  complete: () => {
    showAsyncSearchIndicator(false);
  }
});

Registering custom result providers

The GlobalSearch API allows to extend provided results by registering your own provider.

setupDeps.globalSearch.registerResultProvider({
  id: 'my_provider',
  find: (term, options, context) => {
    const resultPromise = myService.search(term, context.core.savedObjects.client);
    return from(resultPromise).pipe(takeUntil(options.aborted$);
  },
});

Known limitations

Client-side registered providers

Results from providers registered from the client-side registerResultProvider API will not be available when performing a search from the server-side. For this reason, prefer registering providers using the server-side API when possible.

Refer to the RFC for more details

Search completion cause

There is currently no way to identify globalSearch.find observable completion cause: searches completing because all providers returned all their results and searches completing because the consumer aborted the search using the aborted$ option or because the internal timout period has been reaches will both complete the same way.