@sanity/embeddings-index-ui 1.1.5 → 1.1.6

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sanity Embeddings Index UI
2
2
 
3
- > Using this feature requires Sanity to send data to OpenAI[.]com, and Pinecone[.]io for storing vector interpretations of documents.
3
+ > Using this feature requires Sanity to send data to OpenAI.com, and Pinecone.io for storing vector interpretations of documents.
4
4
 
5
5
  Sanity Studio v3 plugins that interact with the `/embeddings-index` HTTP API.
6
6
 
package/dist/index.esm.js CHANGED
@@ -2,25 +2,38 @@ import { useClient, useProjectId, useSchema, DefaultPreview, useDocumentPreviewS
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { Card, Text, Button, Box, Autocomplete, Flex, Spinner, Stack, Label, TextInput, TextArea, Dialog, Heading, MenuButton, Menu, MenuItem } from '@sanity/ui';
4
4
  import { ErrorOutlineIcon, EarthGlobeIcon, LinkIcon, AddIcon, EllipsisVerticalIcon, TrashIcon, UndoIcon } from '@sanity/icons';
5
- import require$$0, { createContext, useState, useEffect, useContext, useMemo, useRef, forwardRef, useId, useCallback } from 'react';
5
+ import require$$0, { useMemo, createContext, useState, useEffect, useContext, useRef, forwardRef, useId, useCallback } from 'react';
6
6
  import { useDocumentPane } from 'sanity/desk';
7
7
  import { useIntentLink, useRouter } from 'sanity/router';
8
8
  function publicId(id) {
9
9
  return id.replace("drafts.", "");
10
10
  }
11
- const featureName = "embeddingsIndexApi";
12
- const FeatureEnabledContext = createContext("loading");
13
- function useIsFeatureEnabled() {
11
+ function useApiClient() {
14
12
  const client = useClient({
15
- apiVersion: "2023-09-01"
13
+ apiVersion: "vX"
16
14
  });
15
+ return useMemo(() => {
16
+ const customHost = localStorage.getItem("embeddings-index-host");
17
+ if (customHost) {
18
+ return client.withConfig({
19
+ apiHost: customHost,
20
+ useProjectHostname: false,
21
+ withCredentials: false
22
+ });
23
+ }
24
+ return client;
25
+ }, [client]);
26
+ }
27
+ const FeatureEnabledContext = createContext("loading");
28
+ function useIsFeatureEnabled() {
29
+ const client = useApiClient();
17
30
  const [status, setStatus] = useState("loading");
18
31
  useEffect(() => {
19
32
  client.request({
20
33
  method: "GET",
21
- url: "/projects/".concat(client.config().projectId, "/features/").concat(featureName)
22
- }).then(isEnabled => {
23
- setStatus(isEnabled === "true" || isEnabled === true ? "enabled" : "disabled");
34
+ url: "/embeddings-index/status"
35
+ }).then(response => {
36
+ setStatus(response.enabled ? "enabled" : "disabled");
24
37
  }).catch(err => {
25
38
  console.error(err);
26
39
  setStatus("disabled");
@@ -1925,22 +1938,6 @@ function deleteIndex(indexName, client) {
1925
1938
  url: "/embeddings-index/".concat(dataset, "/").concat(indexName, "?projectId=").concat(projectId)
1926
1939
  });
1927
1940
  }
1928
- function useApiClient() {
1929
- const client = useClient({
1930
- apiVersion: "vX"
1931
- });
1932
- return useMemo(() => {
1933
- const customHost = localStorage.getItem("embeddings-index-host");
1934
- if (customHost) {
1935
- return client.withConfig({
1936
- apiHost: customHost,
1937
- useProjectHostname: false,
1938
- withCredentials: false
1939
- });
1940
- }
1941
- return client;
1942
- }, [client]);
1943
- }
1944
1941
  const NO_RESULTS_VALUE = "";
1945
1942
  const NO_OPTIONS = [];
1946
1943
  const NO_FILTER = () => true;