@dxos/plugin-search 0.8.1 → 0.8.2-main.10c050d

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.
Files changed (52) hide show
  1. package/dist/lib/browser/app-graph-builder-NZN3MIDZ.mjs +77 -0
  2. package/dist/lib/browser/app-graph-builder-NZN3MIDZ.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-J6YWSQTW.mjs → chunk-ARZYMSFF.mjs} +3 -3
  4. package/dist/lib/browser/{chunk-J6YWSQTW.mjs.map → chunk-ARZYMSFF.mjs.map} +1 -1
  5. package/dist/lib/browser/{chunk-NFZSXZMP.mjs → chunk-CKQAVN5U.mjs} +23 -17
  6. package/dist/lib/browser/chunk-CKQAVN5U.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-LXHJVTYG.mjs → chunk-VMEXQBHE.mjs} +7 -7
  8. package/dist/lib/browser/chunk-VMEXQBHE.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +6 -6
  10. package/dist/lib/browser/{intent-resolver-G76A35DX.mjs → intent-resolver-RWC63UGI.mjs} +3 -3
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/{react-surface-QBBLEI2Q.mjs → react-surface-UJOSZGP5.mjs} +293 -258
  13. package/dist/lib/browser/react-surface-UJOSZGP5.mjs.map +7 -0
  14. package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
  15. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/index.d.ts +1 -177
  17. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  18. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  19. package/dist/types/src/components/SearchDialog.d.ts.map +1 -1
  20. package/dist/types/src/components/SearchResults/SearchResults.d.ts.map +1 -1
  21. package/dist/types/src/components/Searchbar/Searchbar.d.ts.map +1 -1
  22. package/dist/types/src/hooks/sync.d.ts.map +1 -1
  23. package/dist/types/src/hooks/useGlobalSearch.d.ts.map +1 -1
  24. package/dist/types/src/hooks/useSearchResults.d.ts.map +1 -1
  25. package/dist/types/src/hooks/useWebSearch.d.ts +1 -1
  26. package/dist/types/src/hooks/useWebSearch.d.ts.map +1 -1
  27. package/dist/types/src/search/exa.d.ts +4 -4
  28. package/dist/types/src/search/exa.d.ts.map +1 -1
  29. package/dist/types/src/types/action.d.ts +5 -5
  30. package/dist/types/src/types/action.d.ts.map +1 -1
  31. package/dist/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +35 -28
  33. package/src/capabilities/app-graph-builder.ts +59 -41
  34. package/src/capabilities/react-surface.tsx +4 -7
  35. package/src/components/SearchDialog.tsx +8 -7
  36. package/src/components/SearchMain.tsx +4 -4
  37. package/src/components/SearchResults/SearchResults.tsx +1 -1
  38. package/src/components/Searchbar/Searchbar.tsx +2 -2
  39. package/src/hooks/sync.test.ts +4 -4
  40. package/src/hooks/sync.ts +8 -7
  41. package/src/hooks/useSearchResults.ts +2 -2
  42. package/src/hooks/useWebSearch.ts +6 -8
  43. package/src/meta.ts +2 -2
  44. package/src/search/exa.test.ts +7 -8
  45. package/src/search/exa.ts +32 -26
  46. package/src/types/action.tsx +4 -4
  47. package/dist/lib/browser/app-graph-builder-RHZORTY2.mjs +0 -76
  48. package/dist/lib/browser/app-graph-builder-RHZORTY2.mjs.map +0 -7
  49. package/dist/lib/browser/chunk-LXHJVTYG.mjs.map +0 -7
  50. package/dist/lib/browser/chunk-NFZSXZMP.mjs.map +0 -7
  51. package/dist/lib/browser/react-surface-QBBLEI2Q.mjs.map +0 -7
  52. /package/dist/lib/browser/{intent-resolver-G76A35DX.mjs.map → intent-resolver-RWC63UGI.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-search",
3
- "version": "0.8.1",
3
+ "version": "0.8.2-main.10c050d",
4
4
  "description": "Braneframe sketch plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -23,48 +23,55 @@
23
23
  "src"
24
24
  ],
25
25
  "dependencies": {
26
- "effect": "3.13.3",
26
+ "@preact-signals/safe-react": "^0.9.0",
27
27
  "exa-js": "^1.5.12",
28
28
  "main-thread-scheduling": "^14.1.1",
29
- "@dxos/app-framework": "0.8.1",
30
- "@dxos/debug": "0.8.1",
31
- "@dxos/artifact": "0.8.1",
32
- "@dxos/echo-protocol": "0.8.1",
33
- "@dxos/echo-schema": "0.8.1",
34
- "@dxos/effect": "0.8.1",
35
- "@dxos/invariant": "0.8.1",
36
- "@dxos/assistant": "0.8.1",
37
- "@dxos/live-object": "0.8.1",
38
- "@dxos/log": "0.8.1",
39
- "@dxos/plugin-client": "0.8.1",
40
- "@dxos/plugin-deck": "0.8.1",
41
- "@dxos/plugin-graph": "0.8.1",
42
- "@dxos/plugin-markdown": "0.8.1",
43
- "@dxos/plugin-space": "0.8.1",
44
- "@dxos/react-client": "0.8.1",
45
- "@dxos/react-ui-searchlist": "0.8.1",
46
- "@dxos/react-ui-card": "0.8.1",
47
- "@dxos/schema": "0.8.1",
48
- "@dxos/util": "0.8.1"
29
+ "@dxos/app-framework": "0.8.2-main.10c050d",
30
+ "@dxos/ai": "0.8.2-main.10c050d",
31
+ "@dxos/artifact": "0.8.2-main.10c050d",
32
+ "@dxos/assistant": "0.8.2-main.10c050d",
33
+ "@dxos/debug": "0.8.2-main.10c050d",
34
+ "@dxos/echo": "0.8.2-main.10c050d",
35
+ "@dxos/echo-schema": "0.8.2-main.10c050d",
36
+ "@dxos/echo-protocol": "0.8.2-main.10c050d",
37
+ "@dxos/effect": "0.8.2-main.10c050d",
38
+ "@dxos/invariant": "0.8.2-main.10c050d",
39
+ "@dxos/live-object": "0.8.2-main.10c050d",
40
+ "@dxos/plugin-client": "0.8.2-main.10c050d",
41
+ "@dxos/plugin-graph": "0.8.2-main.10c050d",
42
+ "@dxos/log": "0.8.2-main.10c050d",
43
+ "@dxos/plugin-space": "0.8.2-main.10c050d",
44
+ "@dxos/plugin-deck": "0.8.2-main.10c050d",
45
+ "@dxos/react-client": "0.8.2-main.10c050d",
46
+ "@dxos/react-ui-card": "0.8.2-main.10c050d",
47
+ "@dxos/react-ui-searchlist": "0.8.2-main.10c050d",
48
+ "@dxos/schema": "0.8.2-main.10c050d",
49
+ "@dxos/util": "0.8.2-main.10c050d"
49
50
  },
50
51
  "devDependencies": {
52
+ "@effect-rx/rx-react": "^0.34.1",
53
+ "@effect/platform": "0.80.12",
51
54
  "@phosphor-icons/react": "^2.1.5",
52
55
  "@types/react": "~18.2.0",
53
56
  "@types/react-dom": "~18.2.0",
57
+ "effect": "3.14.21",
54
58
  "react": "~18.2.0",
55
59
  "react-dom": "~18.2.0",
56
60
  "vite": "5.4.7",
57
- "@dxos/react-ui": "0.8.1",
58
- "@dxos/react-ui-theme": "0.8.1",
59
- "@dxos/storybook-utils": "0.8.1",
60
- "@dxos/random": "0.8.1"
61
+ "@dxos/random": "0.8.2-main.10c050d",
62
+ "@dxos/react-ui-theme": "0.8.2-main.10c050d",
63
+ "@dxos/react-ui": "0.8.2-main.10c050d",
64
+ "@dxos/storybook-utils": "0.8.2-main.10c050d"
61
65
  },
62
66
  "peerDependencies": {
67
+ "@effect-rx/rx-react": "^0.34.1",
68
+ "@effect/platform": "0.80.12",
63
69
  "@phosphor-icons/react": "^2.1.5",
70
+ "effect": "^3.13.3",
64
71
  "react": "~18.2.0",
65
72
  "react-dom": "~18.2.0",
66
- "@dxos/react-ui": "0.8.1",
67
- "@dxos/react-ui-theme": "0.8.1"
73
+ "@dxos/react-ui": "0.8.2-main.10c050d",
74
+ "@dxos/react-ui-theme": "0.8.2-main.10c050d"
68
75
  },
69
76
  "publishConfig": {
70
77
  "access": "public"
@@ -2,60 +2,78 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
5
+ import { Rx } from '@effect-rx/rx-react';
6
+ import { Option, pipe } from 'effect';
7
+
8
+ import { Capabilities, contributes, createIntent, type PluginContext } from '@dxos/app-framework';
6
9
  import { ClientCapabilities } from '@dxos/plugin-client';
7
10
  import { ATTENDABLE_PATH_SEPARATOR, DECK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
8
- import { createExtension, type Node } from '@dxos/plugin-graph';
11
+ import { createExtension, ROOT_ID, rxFromSignal } from '@dxos/plugin-graph';
9
12
  import { parseId } from '@dxos/react-client/echo';
10
13
 
11
14
  import { SEARCH_PLUGIN } from '../meta';
12
15
  import { SearchAction } from '../types';
13
16
 
14
- export default (context: PluginsContext) =>
17
+ export default (context: PluginContext) =>
15
18
  contributes(Capabilities.AppGraphBuilder, [
16
19
  createExtension({
17
20
  id: `${SEARCH_PLUGIN}/space-search`,
18
- filter: (node): node is Node<null> => node.id === 'root',
19
- connector: ({ node }) => {
20
- const layout = context.requestCapability(Capabilities.Layout);
21
- const client = context.requestCapability(ClientCapabilities.Client);
22
- const { spaceId } = parseId(layout.workspace);
23
- const space = spaceId ? client.spaces.get(spaceId) : null;
21
+ connector: (node) =>
22
+ Rx.make((get) =>
23
+ pipe(
24
+ get(node),
25
+ Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
26
+ Option.map((node) => {
27
+ const workspace = get(rxFromSignal(() => context.getCapability(Capabilities.Layout).workspace));
28
+ const client = context.getCapability(ClientCapabilities.Client);
29
+ const { spaceId } = parseId(workspace);
30
+ const space = spaceId ? client.spaces.get(spaceId) : null;
24
31
 
25
- return [
26
- {
27
- id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),
28
- type: DECK_COMPANION_TYPE,
29
- data: space,
30
- properties: {
31
- label: ['search label', { ns: SEARCH_PLUGIN }],
32
- icon: 'ph--magnifying-glass--regular',
33
- disposition: 'hidden',
34
- },
35
- },
36
- ];
37
- },
32
+ return [
33
+ {
34
+ id: [node.id, 'search'].join(ATTENDABLE_PATH_SEPARATOR),
35
+ type: DECK_COMPANION_TYPE,
36
+ data: space,
37
+ properties: {
38
+ label: ['search label', { ns: SEARCH_PLUGIN }],
39
+ icon: 'ph--magnifying-glass--regular',
40
+ disposition: 'hidden',
41
+ },
42
+ },
43
+ ];
44
+ }),
45
+ Option.getOrElse(() => []),
46
+ ),
47
+ ),
38
48
  }),
39
49
  createExtension({
40
50
  id: SEARCH_PLUGIN,
41
- filter: (node): node is Node<null> => node.id === 'root',
42
- actions: () => [
43
- {
44
- id: SearchAction.OpenSearch._tag,
45
- data: async () => {
46
- const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
47
- await dispatch(createIntent(SearchAction.OpenSearch));
48
- },
49
- properties: {
50
- label: ['search action label', { ns: SEARCH_PLUGIN }],
51
- icon: 'ph--magnifying-glass--regular',
52
- keyBinding: {
53
- macos: 'shift+meta+f',
54
- windows: 'shift+alt+f',
55
- },
56
- testId: 'searchPlugin.search',
57
- },
58
- },
59
- ],
51
+ actions: (node) =>
52
+ Rx.make((get) =>
53
+ pipe(
54
+ get(node),
55
+ Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
56
+ Option.map(() => {
57
+ return [
58
+ {
59
+ id: SearchAction.OpenSearch._tag,
60
+ data: async () => {
61
+ const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
62
+ await dispatch(createIntent(SearchAction.OpenSearch));
63
+ },
64
+ properties: {
65
+ label: ['search action label', { ns: SEARCH_PLUGIN }],
66
+ icon: 'ph--magnifying-glass--regular',
67
+ keyBinding: {
68
+ macos: 'shift+meta+f',
69
+ windows: 'shift+alt+f',
70
+ },
71
+ },
72
+ },
73
+ ];
74
+ }),
75
+ Option.getOrElse(() => []),
76
+ ),
77
+ ),
60
78
  }),
61
79
  ]);
@@ -4,8 +4,8 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Capabilities, contributes, createSurface, useLayout, useAppGraph } from '@dxos/app-framework';
8
- import { getActiveSpace } from '@dxos/plugin-space';
7
+ import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
+ import { useActiveSpace } from '@dxos/plugin-space';
9
9
  import { isSpace, type Space } from '@dxos/react-client/echo';
10
10
 
11
11
  import { SEARCH_DIALOG, SearchDialog, type SearchDialogProps, SearchMain } from '../components';
@@ -24,13 +24,10 @@ export default () =>
24
24
  ),
25
25
  }),
26
26
  createSurface({
27
- // id: `${SEARCH_DIALOG}/search-input`,
28
- id: 'search-input',
27
+ id: `${SEARCH_DIALOG}/search-input`,
29
28
  role: 'search-input',
30
29
  component: () => {
31
- const layout = useLayout();
32
- const { graph } = useAppGraph();
33
- const space = graph ? getActiveSpace(graph, layout.active[0]) : undefined;
30
+ const space = useActiveSpace();
34
31
  if (!space) {
35
32
  return null;
36
33
  }
@@ -2,6 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Option } from 'effect';
5
6
  import React, { forwardRef, useCallback, useState } from 'react';
6
7
 
7
8
  import { LayoutAction, createIntent, useAppGraph, useIntentDispatcher, useLayout } from '@dxos/app-framework';
@@ -47,11 +48,11 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
47
48
  const { graph } = useAppGraph();
48
49
  const layout = useLayout();
49
50
  const closed = (Array.isArray(layout.inactive) ? layout.inactive : [layout.inactive])
50
- .map((id) => graph?.findNode(id))
51
+ .map((id) => graph?.getNode(id))
51
52
  .filter(Boolean);
52
53
  const [queryString, setQueryString] = useState('');
53
54
  const client = useClient();
54
- const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.all());
55
+ const dangerouslyLoadAllObjects = useQuery(client.spaces, Filter.everything());
55
56
  const [pending, results] = useSearchResults(queryString, dangerouslyLoadAllObjects);
56
57
  const resultObjects = Array.from(results.keys());
57
58
  const { dispatchPromise: dispatch } = useIntentDispatcher();
@@ -96,17 +97,17 @@ export const SearchDialog = ({ pivotId }: SearchDialogProps) => {
96
97
  {queryString.length > 0 ? (
97
98
  resultObjects.length > 0 ? (
98
99
  resultObjects
99
- .map((object) => graph?.findNode(fullyQualifiedId(object)))
100
- .filter(Boolean)
101
- .map((node) => <SearchListResult key={node!.id} node={node!} onSelect={handleSelect} />)
100
+ .map((object) => graph.getNode(fullyQualifiedId(object)))
101
+ .filter(Option.isSome)
102
+ .map((node) => <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />)
102
103
  ) : (
103
104
  <p className='pli-1'>{t(pending ? 'pending results message' : 'empty results message')}</p>
104
105
  )
105
106
  ) : (
106
107
  <>
107
108
  {closed.length > 0 && <h2 className={mx('mlb-1', descriptionText)}>{t('recently closed heading')}</h2>}
108
- {closed.map((node) => (
109
- <SearchListResult key={node!.id} node={node!} onSelect={handleSelect} />
109
+ {closed.filter(Option.isSome).map((node) => (
110
+ <SearchListResult key={node.value.id} node={node.value} onSelect={handleSelect} />
110
111
  ))}
111
112
  </>
112
113
  )}
@@ -8,7 +8,7 @@ import { log } from '@dxos/log';
8
8
  import { useClient } from '@dxos/react-client';
9
9
  import { Filter, useQuery, type Space } from '@dxos/react-client/echo';
10
10
  import { type ThemedClassName, useTranslation } from '@dxos/react-ui';
11
- import { groupSurface, mx } from '@dxos/react-ui-theme';
11
+ import { activeSurface, mx } from '@dxos/react-ui-theme';
12
12
 
13
13
  import { SearchResults } from './SearchResults';
14
14
  import { Searchbar } from './Searchbar';
@@ -25,7 +25,7 @@ export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames,
25
25
  const allSpaces = false;
26
26
 
27
27
  // TODO(burdon): Returns ALL objects (e.g., incl. Text objects that are fields of parent objects).
28
- const objects = useQuery(allSpaces ? client.spaces : space, Filter.all());
28
+ const objects = useQuery(allSpaces ? client.spaces : space, Filter.everything());
29
29
  const results = useGlobalSearchResults(objects);
30
30
 
31
31
  const {
@@ -56,9 +56,9 @@ export const SearchMain: FC<ThemedClassName<{ space: Space }>> = ({ classNames,
56
56
  }}
57
57
  onSubmit={runSearch}
58
58
  />
59
- {isLoading && <div className={mx('flex flex-col grow overflow-hidden', groupSurface)}>Loading...</div>}
59
+ {isLoading && <div className={mx('flex flex-col grow overflow-hidden', activeSurface)}>Loading...</div>}
60
60
  {allResults.length > 0 && (
61
- <div className={mx('flex flex-col grow overflow-hidden', groupSurface)}>
61
+ <div className={mx('flex flex-col grow overflow-hidden', activeSurface)}>
62
62
  <SearchResults items={allResults} selected={selected} onSelect={handleSelect} />
63
63
  </div>
64
64
  )}
@@ -49,7 +49,7 @@ export const SearchItem = forwardRef<HTMLDivElement, SearchItemProps>((item, for
49
49
  return (
50
50
  <Card.Root
51
51
  ref={forwardRef}
52
- classNames={mx('mx-2 mt-2 cursor-pointer', selected && '!bg-groupSurface', ghostHover)}
52
+ classNames={mx('mx-2 mt-2 cursor-pointer', selected && '!bg-activeSurface', ghostHover)}
53
53
  onClick={() => onSelect?.(id)}
54
54
  >
55
55
  {objectType && (
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import { MagnifyingGlass } from '@phosphor-icons/react';
6
- import React, { useEffect, useRef, useState } from 'react';
6
+ import React, { type KeyboardEvent, useEffect, useRef, useState } from 'react';
7
7
 
8
8
  import { Input, type TextInputProps } from '@dxos/react-ui';
9
9
  import { getSize, mx } from '@dxos/react-ui-theme';
@@ -35,7 +35,7 @@ export const Searchbar = ({ classes, variant, placeholder, value, onChange, onSu
35
35
  inputRef.current?.focus();
36
36
  };
37
37
 
38
- const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
38
+ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
39
39
  switch (event.key) {
40
40
  case 'Enter':
41
41
  onSubmit?.(text);
@@ -5,8 +5,8 @@
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
7
  import { Client } from '@dxos/client';
8
- import { Expando } from '@dxos/echo-schema';
9
- import { create } from '@dxos/live-object';
8
+ import { Expando, Filter } from '@dxos/echo-schema';
9
+ import { live } from '@dxos/live-object';
10
10
  import { faker } from '@dxos/random';
11
11
 
12
12
  import { filterObjectsSync } from './sync';
@@ -26,10 +26,10 @@ describe('Search', () => {
26
26
  Array.from({ length: 20 }).map((_, i) => {
27
27
  const content =
28
28
  i === 10 ? faker.lorem.sentence() + ` ${match}}. ` + faker.lorem.sentence() : faker.lorem.sentences();
29
- return space.db.add(create(Expando, { title: faker.lorem.sentence(), content }));
29
+ return space.db.add(live(Expando, { title: faker.lorem.sentence(), content }));
30
30
  });
31
31
 
32
- const { objects } = await space.db.query().run();
32
+ const { objects } = await space.db.query(Filter.everything()).run();
33
33
  const results = filterObjectsSync(objects, new RegExp(match, 'i'));
34
34
  expect(results).to.have.length(1);
35
35
  });
package/src/hooks/sync.ts CHANGED
@@ -2,9 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { AST, type S } from '@dxos/echo-schema';
6
- import { getSchema } from '@dxos/live-object';
7
- import { TextType } from '@dxos/schema';
5
+ import { type Schema, SchemaAST } from 'effect';
6
+
7
+ import { getSchema } from '@dxos/echo-schema';
8
+ import { DataType } from '@dxos/schema';
8
9
 
9
10
  import { type SearchResult } from '../types';
10
11
 
@@ -14,8 +15,8 @@ export const queryStringToMatch = (queryString?: string): RegExp | undefined =>
14
15
  };
15
16
 
16
17
  // TODO(burdon): Type name registry linked to schema?
17
- const getIcon = (schema: S.Schema.AnyNoContext | undefined): string | undefined => {
18
- if (!(schema && AST.isTypeLiteral(schema.ast))) {
18
+ const getIcon = (schema: Schema.Schema.AnyNoContext | undefined): string | undefined => {
19
+ if (!(schema && SchemaAST.isTypeLiteral(schema.ast))) {
19
20
  return undefined;
20
21
  }
21
22
  const keys = schema.ast.propertySignatures.map((p) => p.name);
@@ -44,7 +45,7 @@ export const filterObjectsSync = <T extends Record<string, any>>(objects: T[], m
44
45
 
45
46
  return objects.reduce<SearchResult[]>((results, object) => {
46
47
  // TODO(burdon): Hack to ignore Text objects.
47
- if (object instanceof TextType) {
48
+ if (object instanceof DataType.Text) {
48
49
  return results;
49
50
  }
50
51
 
@@ -110,7 +111,7 @@ const getKeys = (object: Record<string, unknown>): string[] => {
110
111
  export const mapObjectToTextFields = <T extends Record<string, unknown>>(object: T): TextFields => {
111
112
  return getKeys(object).reduce<TextFields>((fields, key) => {
112
113
  const value = object[key] as any;
113
- if (typeof value === 'string' || value instanceof TextType) {
114
+ if (typeof value === 'string' || value instanceof DataType.Text) {
114
115
  try {
115
116
  fields[key] = String(value);
116
117
  } catch (err) {
@@ -5,7 +5,7 @@
5
5
  import { yieldOrContinue } from 'main-thread-scheduling';
6
6
  import { useEffect, useState } from 'react';
7
7
 
8
- import { TextType } from '@dxos/schema';
8
+ import { DataType } from '@dxos/schema';
9
9
 
10
10
  // TODO(thure): Deprecate search-sync, move still-relevant utilities elsewhere (here, probably).
11
11
  import { mapObjectToTextFields, queryStringToMatch } from './sync';
@@ -20,7 +20,7 @@ export const filterObjects = async <T extends Record<string, any>>(
20
20
  }
21
21
  await Promise.all(
22
22
  objects
23
- .filter((object) => !(object instanceof TextType))
23
+ .filter((object) => !(object instanceof DataType.Text))
24
24
  .map(async (object) => {
25
25
  await yieldOrContinue('interactive');
26
26
  const fields = mapObjectToTextFields<T>(object);
@@ -4,20 +4,17 @@
4
4
 
5
5
  import { useState } from 'react';
6
6
 
7
- import { AIServiceEdgeClient } from '@dxos/assistant';
8
- import { AI_SERVICE_ENDPOINT } from '@dxos/assistant/testing';
7
+ import { AIServiceEdgeClient } from '@dxos/ai';
8
+ import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
9
9
  import { getSchema, getTypename } from '@dxos/echo-schema';
10
- import type { DXN } from '@dxos/keys';
10
+ import { type DXN } from '@dxos/keys';
11
11
  import { log } from '@dxos/log';
12
12
  import { getIconAnnotation } from '@dxos/schema';
13
13
  import { Testing } from '@dxos/schema/testing';
14
14
 
15
15
  import { getStringProperty } from './sync';
16
16
  import { search } from '../search';
17
- import type { SearchResult } from '../types';
18
-
19
- // TODO(dmaretskyi): Get from config/credentials
20
- const EXA_API_KEY = '9c7e17ff-0c85-4cd5-827a-8b489f139e03';
17
+ import { type SearchResult } from '../types';
21
18
 
22
19
  export const useWebSearch = ({ query, context }: { query?: string; context?: string }) => {
23
20
  const aiService = new AIServiceEdgeClient({
@@ -34,7 +31,7 @@ export const useWebSearch = ({ query, context }: { query?: string; context?: str
34
31
  const results = await search({
35
32
  query,
36
33
  context,
37
- schema: [Testing.Project, Testing.Org, Testing.Contact],
34
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
38
35
  aiService,
39
36
  exaApiKey: EXA_API_KEY,
40
37
  });
@@ -56,5 +53,6 @@ export const useWebSearch = ({ query, context }: { query?: string; context?: str
56
53
  setIsLoading(false);
57
54
  }
58
55
  };
56
+
59
57
  return { runSearch, results, isLoading };
60
58
  };
package/src/meta.ts CHANGED
@@ -12,6 +12,6 @@ export const meta: PluginMeta = {
12
12
  name: 'Search',
13
13
  description: 'Search ECHO spaces for content.',
14
14
  icon: 'ph--magnifying-glass--regular',
15
- source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-search',
16
- tags: ['experimental'],
15
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-search',
16
+ tags: ['labs'],
17
17
  };
@@ -4,14 +4,13 @@
4
4
 
5
5
  import { describe, test } from 'vitest';
6
6
 
7
- import { AIServiceEdgeClient, OllamaClient } from '@dxos/assistant';
8
- import { AI_SERVICE_ENDPOINT } from '@dxos/assistant/testing';
7
+ import { AIServiceEdgeClient, OllamaClient } from '@dxos/ai';
8
+ import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
9
9
  import { log } from '@dxos/log';
10
10
  import { Testing } from '@dxos/schema/testing';
11
11
 
12
12
  import { search } from './exa';
13
13
 
14
- const EXA_API_KEY = '9c7e17ff-0c85-4cd5-827a-8b489f139e03';
15
14
  const REMOTE_AI = true;
16
15
 
17
16
  const aiService = REMOTE_AI
@@ -40,7 +39,7 @@ describe.skip('Search', () => {
40
39
  test.skip('contacts projects and orgs', { timeout: 60_000 }, async () => {
41
40
  const objects = await search({
42
41
  query: 'top executives at google',
43
- schema: [Testing.Contact, Testing.Project, Testing.Org],
42
+ schema: [Testing.Contact, Testing.Project, Testing.Organization],
44
43
  aiService,
45
44
  exaApiKey: EXA_API_KEY,
46
45
  });
@@ -51,7 +50,7 @@ describe.skip('Search', () => {
51
50
  test('a19z org, projects they invest in and team', { timeout: 60_000 }, async () => {
52
51
  const objects = await search({
53
52
  query: 'a19z org, projects they invest in and team',
54
- schema: [Testing.Project, Testing.Org, Testing.Contact],
53
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
55
54
  aiService,
56
55
  exaApiKey: EXA_API_KEY,
57
56
  });
@@ -62,7 +61,7 @@ describe.skip('Search', () => {
62
61
  test('companies building CRDTs', { timeout: 60_000 }, async () => {
63
62
  const objects = await search({
64
63
  query: 'companies building CRDTs',
65
- schema: [Testing.Project, Testing.Org, Testing.Contact],
64
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
66
65
  aiService,
67
66
  exaApiKey: EXA_API_KEY,
68
67
  });
@@ -75,7 +74,7 @@ describe.skip('Search', () => {
75
74
  test('composer context-based search', { timeout: 60_000 }, async () => {
76
75
  const objects = await search({
77
76
  context: COMPOSER_DXOS_DOC,
78
- schema: [Testing.Project, Testing.Org, Testing.Contact],
77
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
79
78
  aiService,
80
79
  exaApiKey: EXA_API_KEY,
81
80
  });
@@ -86,7 +85,7 @@ describe.skip('Search', () => {
86
85
  test.only('edge architecture', { timeout: 60_000 }, async () => {
87
86
  const objects = await search({
88
87
  context: EDGE_ARCHITECTURE_DOC,
89
- schema: [Testing.Project, Testing.Org, Testing.Contact],
88
+ schema: [Testing.Project, Testing.Organization, Testing.Contact],
90
89
  aiService,
91
90
  exaApiKey: EXA_API_KEY,
92
91
  });