@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/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSchema, DefaultPreview, useDocumentPreviewStore, SanityDefaultPreview, getPreviewValueWithFallback, getPreviewStateObservable, typed, unset, setIfMissing, set,
|
|
1
|
+
import { useSchema, DefaultPreview, useDocumentPreviewStore, SanityDefaultPreview, getPreviewValueWithFallback, getPreviewStateObservable, useClient, typed, unset, setIfMissing, set, definePlugin, isObjectInputProps } from 'sanity';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { Card, Button, Box, Flex, Autocomplete, Text, Stack, Label, TextInput, TextArea, Dialog, Spinner, Heading, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
4
4
|
import { ErrorOutlineIcon, EarthGlobeIcon, LinkIcon, AddIcon, SearchIcon, EllipsisVerticalIcon, TrashIcon, UndoIcon } from '@sanity/icons';
|
|
@@ -1879,6 +1879,22 @@ function deleteIndex(indexName, client) {
|
|
|
1879
1879
|
function publicId(id) {
|
|
1880
1880
|
return id.replace("drafts.", "");
|
|
1881
1881
|
}
|
|
1882
|
+
function useApiClient() {
|
|
1883
|
+
const client = useClient({
|
|
1884
|
+
apiVersion: "vX"
|
|
1885
|
+
});
|
|
1886
|
+
return useMemo(() => {
|
|
1887
|
+
const customHost = localStorage.getItem("embeddings-index-host");
|
|
1888
|
+
if (customHost) {
|
|
1889
|
+
return client.withConfig({
|
|
1890
|
+
apiHost: customHost,
|
|
1891
|
+
useProjectHostname: false,
|
|
1892
|
+
withCredentials: false
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
return client;
|
|
1896
|
+
}, [client]);
|
|
1897
|
+
}
|
|
1882
1898
|
const NO_OPTIONS = [];
|
|
1883
1899
|
const NO_FILTER = () => true;
|
|
1884
1900
|
function SemanticSearchReferenceInput(props) {
|
|
@@ -1919,12 +1935,6 @@ function useDebouncedValue(value, ms) {
|
|
|
1919
1935
|
}, [value, ms]);
|
|
1920
1936
|
return debouncedValue;
|
|
1921
1937
|
}
|
|
1922
|
-
function useApiClient$2() {
|
|
1923
|
-
const client = useClient({
|
|
1924
|
-
apiVersion: "vX"
|
|
1925
|
-
});
|
|
1926
|
-
return useMemo(() => client, [client]);
|
|
1927
|
-
}
|
|
1928
1938
|
function SemanticSearchInput(props) {
|
|
1929
1939
|
const {
|
|
1930
1940
|
onPathFocus,
|
|
@@ -1945,7 +1955,7 @@ function SemanticSearchInput(props) {
|
|
|
1945
1955
|
const prevDebouncedQuery = useRef(debouncedQuery);
|
|
1946
1956
|
const [searching, setSearching] = useState(false);
|
|
1947
1957
|
const [options, setOptions] = useState(NO_OPTIONS);
|
|
1948
|
-
const client = useApiClient
|
|
1958
|
+
const client = useApiClient();
|
|
1949
1959
|
useEffect(() => {
|
|
1950
1960
|
docRef.current = currentDocument;
|
|
1951
1961
|
}, [currentDocument]);
|
|
@@ -2084,12 +2094,6 @@ const embeddingsIndexReferenceInput = definePlugin({
|
|
|
2084
2094
|
}
|
|
2085
2095
|
}
|
|
2086
2096
|
});
|
|
2087
|
-
function useApiClient$1(customApiClient) {
|
|
2088
|
-
const client = useClient({
|
|
2089
|
-
apiVersion: "vX"
|
|
2090
|
-
});
|
|
2091
|
-
return useMemo(() => customApiClient ? customApiClient(client) : client, [client, customApiClient]);
|
|
2092
|
-
}
|
|
2093
2097
|
const defaultProjection = "{...}";
|
|
2094
2098
|
function useDefaultIndex(schema, dataset) {
|
|
2095
2099
|
const defaultFilter = useMemo(() => "_type in [".concat(schema.getTypeNames().map(n => schema.get(n)).filter(schemaType => Boolean(schemaType && isType(schemaType, "document"))).filter(documentType => !documentType.name.startsWith("sanity.") && !documentType.name.startsWith("assist.") && documentType.name !== "document").map(documentType => '"'.concat(documentType.name, '"')).join(",\n"), "]"), [schema]);
|
|
@@ -2206,7 +2210,7 @@ function IndexEditor(props) {
|
|
|
2206
2210
|
index: selectedIndex,
|
|
2207
2211
|
onSubmit
|
|
2208
2212
|
} = props;
|
|
2209
|
-
const client = useApiClient
|
|
2213
|
+
const client = useApiClient();
|
|
2210
2214
|
const schema = useSchema();
|
|
2211
2215
|
const defaultIndex = useDefaultIndex(schema, (_a = client.config().dataset) != null ? _a : "");
|
|
2212
2216
|
const [errors, setErrors] = useState();
|
|
@@ -2426,7 +2430,7 @@ function QueryIndex(props) {
|
|
|
2426
2430
|
const [query, setQuery] = useState("");
|
|
2427
2431
|
const [searching, setSearching] = useState(false);
|
|
2428
2432
|
const [results, setResults] = useState(NO_RESULTS);
|
|
2429
|
-
const client = useApiClient
|
|
2433
|
+
const client = useApiClient();
|
|
2430
2434
|
const search = useCallback(queryString => {
|
|
2431
2435
|
setSearching(true);
|
|
2432
2436
|
return queryIndex({
|
|
@@ -2644,12 +2648,6 @@ function IndexStatus(_ref4) {
|
|
|
2644
2648
|
})]
|
|
2645
2649
|
});
|
|
2646
2650
|
}
|
|
2647
|
-
function useApiClient() {
|
|
2648
|
-
const client = useClient({
|
|
2649
|
-
apiVersion: "vX"
|
|
2650
|
-
});
|
|
2651
|
-
return useMemo(() => client, [client]);
|
|
2652
|
-
}
|
|
2653
2651
|
function EmbeddingsIndexTool() {
|
|
2654
2652
|
return /* @__PURE__ */jsx(Card, {
|
|
2655
2653
|
children: /* @__PURE__ */jsx(Flex, {
|