@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.js CHANGED
@@ -1890,6 +1890,22 @@ function deleteIndex(indexName, client) {
1890
1890
  function publicId(id) {
1891
1891
  return id.replace("drafts.", "");
1892
1892
  }
1893
+ function useApiClient() {
1894
+ const client = sanity.useClient({
1895
+ apiVersion: "vX"
1896
+ });
1897
+ return require$$0.useMemo(() => {
1898
+ const customHost = localStorage.getItem("embeddings-index-host");
1899
+ if (customHost) {
1900
+ return client.withConfig({
1901
+ apiHost: customHost,
1902
+ useProjectHostname: false,
1903
+ withCredentials: false
1904
+ });
1905
+ }
1906
+ return client;
1907
+ }, [client]);
1908
+ }
1893
1909
  const NO_OPTIONS = [];
1894
1910
  const NO_FILTER = () => true;
1895
1911
  function SemanticSearchReferenceInput(props) {
@@ -1930,12 +1946,6 @@ function useDebouncedValue(value, ms) {
1930
1946
  }, [value, ms]);
1931
1947
  return debouncedValue;
1932
1948
  }
1933
- function useApiClient$2() {
1934
- const client = sanity.useClient({
1935
- apiVersion: "vX"
1936
- });
1937
- return require$$0.useMemo(() => client, [client]);
1938
- }
1939
1949
  function SemanticSearchInput(props) {
1940
1950
  const {
1941
1951
  onPathFocus,
@@ -1956,7 +1966,7 @@ function SemanticSearchInput(props) {
1956
1966
  const prevDebouncedQuery = require$$0.useRef(debouncedQuery);
1957
1967
  const [searching, setSearching] = require$$0.useState(false);
1958
1968
  const [options, setOptions] = require$$0.useState(NO_OPTIONS);
1959
- const client = useApiClient$2();
1969
+ const client = useApiClient();
1960
1970
  require$$0.useEffect(() => {
1961
1971
  docRef.current = currentDocument;
1962
1972
  }, [currentDocument]);
@@ -2095,12 +2105,6 @@ const embeddingsIndexReferenceInput = sanity.definePlugin({
2095
2105
  }
2096
2106
  }
2097
2107
  });
2098
- function useApiClient$1(customApiClient) {
2099
- const client = sanity.useClient({
2100
- apiVersion: "vX"
2101
- });
2102
- return require$$0.useMemo(() => customApiClient ? customApiClient(client) : client, [client, customApiClient]);
2103
- }
2104
2108
  const defaultProjection = "{...}";
2105
2109
  function useDefaultIndex(schema, dataset) {
2106
2110
  const defaultFilter = require$$0.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]);
@@ -2217,7 +2221,7 @@ function IndexEditor(props) {
2217
2221
  index: selectedIndex,
2218
2222
  onSubmit
2219
2223
  } = props;
2220
- const client = useApiClient$1();
2224
+ const client = useApiClient();
2221
2225
  const schema = sanity.useSchema();
2222
2226
  const defaultIndex = useDefaultIndex(schema, (_a = client.config().dataset) != null ? _a : "");
2223
2227
  const [errors, setErrors] = require$$0.useState();
@@ -2437,7 +2441,7 @@ function QueryIndex(props) {
2437
2441
  const [query, setQuery] = require$$0.useState("");
2438
2442
  const [searching, setSearching] = require$$0.useState(false);
2439
2443
  const [results, setResults] = require$$0.useState(NO_RESULTS);
2440
- const client = useApiClient$1();
2444
+ const client = useApiClient();
2441
2445
  const search = require$$0.useCallback(queryString => {
2442
2446
  setSearching(true);
2443
2447
  return queryIndex({
@@ -2655,12 +2659,6 @@ function IndexStatus(_ref4) {
2655
2659
  })]
2656
2660
  });
2657
2661
  }
2658
- function useApiClient() {
2659
- const client = sanity.useClient({
2660
- apiVersion: "vX"
2661
- });
2662
- return require$$0.useMemo(() => client, [client]);
2663
- }
2664
2662
  function EmbeddingsIndexTool() {
2665
2663
  return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
2666
2664
  children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {