@sanity/embeddings-index-ui 1.0.1 → 1.0.2
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/dist/index.esm.js +20 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +19 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/embeddingsApiHooks.ts +12 -7
- package/src/embeddingsIndexDashboard/EmbeddingsIndexTool.tsx +2 -7
- package/src/referenceInput/SemanticSearchReferenceInput.tsx +2 -14
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import {SanityClient, useClient} from 'sanity'
|
|
2
2
|
import {useMemo} from 'react'
|
|
3
3
|
|
|
4
|
-
export function useApiClient(
|
|
5
|
-
customApiClient?: (defaultClient: SanityClient) => SanityClient,
|
|
6
|
-
): SanityClient {
|
|
4
|
+
export function useApiClient(): SanityClient {
|
|
7
5
|
const client = useClient({apiVersion: 'vX'})
|
|
8
|
-
return useMemo(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
const customHost = localStorage.getItem('embeddings-index-host')
|
|
8
|
+
if (customHost) {
|
|
9
|
+
return client.withConfig({
|
|
10
|
+
apiHost: customHost,
|
|
11
|
+
useProjectHostname: false,
|
|
12
|
+
withCredentials: false,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
return client
|
|
16
|
+
}, [client])
|
|
12
17
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import {Box, Button, Card, Flex, Heading, Spinner, Stack} from '@sanity/ui'
|
|
2
|
-
import {
|
|
3
|
-
import {useCallback, useEffect, useMemo, useState} from 'react'
|
|
2
|
+
import {useCallback, useEffect, useState} from 'react'
|
|
4
3
|
import {AddIcon, UndoIcon} from '@sanity/icons'
|
|
5
4
|
import {deleteIndex, getIndexes, IndexState, NamedIndex} from '../api/embeddingsApi'
|
|
6
5
|
import {EditIndexDialog} from './IndexEditor'
|
|
7
6
|
import {IndexList} from './IndexList'
|
|
8
7
|
import {IndexInfo} from './IndexInfo'
|
|
9
|
-
|
|
10
|
-
function useApiClient() {
|
|
11
|
-
const client = useClient({apiVersion: 'vX'})
|
|
12
|
-
return useMemo(() => client, [client])
|
|
13
|
-
}
|
|
8
|
+
import {useApiClient} from '../api/embeddingsApiHooks'
|
|
14
9
|
|
|
15
10
|
export function EmbeddingsIndexTool() {
|
|
16
11
|
return (
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ObjectInputProps,
|
|
3
|
-
ReferenceSchemaType,
|
|
4
|
-
set,
|
|
5
|
-
setIfMissing,
|
|
6
|
-
typed,
|
|
7
|
-
unset,
|
|
8
|
-
useClient,
|
|
9
|
-
} from 'sanity'
|
|
1
|
+
import {ObjectInputProps, ReferenceSchemaType, set, setIfMissing, typed, unset} from 'sanity'
|
|
10
2
|
import {Autocomplete, Box, Button, Flex, Text, AutocompleteOpenButtonProps} from '@sanity/ui'
|
|
11
3
|
import {EarthGlobeIcon, LinkIcon} from '@sanity/icons'
|
|
12
4
|
import {useCallback, useEffect, useId, useMemo, useRef, useState} from 'react'
|
|
@@ -14,6 +6,7 @@ import {DocumentPreview} from '../preview/DocumentPreview'
|
|
|
14
6
|
import {useDocumentPane} from 'sanity/desk'
|
|
15
7
|
import {queryIndex, QueryResult} from '../api/embeddingsApi'
|
|
16
8
|
import {publicId} from '../utils/id'
|
|
9
|
+
import {useApiClient} from '../api/embeddingsApiHooks'
|
|
17
10
|
|
|
18
11
|
interface Option {
|
|
19
12
|
result: QueryResult
|
|
@@ -60,11 +53,6 @@ function useDebouncedValue<T>(value: T, ms: number) {
|
|
|
60
53
|
return debouncedValue
|
|
61
54
|
}
|
|
62
55
|
|
|
63
|
-
function useApiClient() {
|
|
64
|
-
const client = useClient({apiVersion: 'vX'})
|
|
65
|
-
return useMemo(() => client, [client])
|
|
66
|
-
}
|
|
67
|
-
|
|
68
56
|
function SemanticSearchInput(props: ObjectInputProps) {
|
|
69
57
|
const {onPathFocus, onChange, readOnly, schemaType, value} = props
|
|
70
58
|
|