@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/dist/index.js CHANGED
@@ -19,19 +19,32 @@ var require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
19
19
  function publicId(id) {
20
20
  return id.replace("drafts.", "");
21
21
  }
22
- const featureName = "embeddingsIndexApi";
23
- const FeatureEnabledContext = require$$0.createContext("loading");
24
- function useIsFeatureEnabled() {
22
+ function useApiClient() {
25
23
  const client = sanity.useClient({
26
- apiVersion: "2023-09-01"
24
+ apiVersion: "vX"
27
25
  });
26
+ return require$$0.useMemo(() => {
27
+ const customHost = localStorage.getItem("embeddings-index-host");
28
+ if (customHost) {
29
+ return client.withConfig({
30
+ apiHost: customHost,
31
+ useProjectHostname: false,
32
+ withCredentials: false
33
+ });
34
+ }
35
+ return client;
36
+ }, [client]);
37
+ }
38
+ const FeatureEnabledContext = require$$0.createContext("loading");
39
+ function useIsFeatureEnabled() {
40
+ const client = useApiClient();
28
41
  const [status, setStatus] = require$$0.useState("loading");
29
42
  require$$0.useEffect(() => {
30
43
  client.request({
31
44
  method: "GET",
32
- url: "/projects/".concat(client.config().projectId, "/features/").concat(featureName)
33
- }).then(isEnabled => {
34
- setStatus(isEnabled === "true" || isEnabled === true ? "enabled" : "disabled");
45
+ url: "/embeddings-index/status"
46
+ }).then(response => {
47
+ setStatus(response.enabled ? "enabled" : "disabled");
35
48
  }).catch(err => {
36
49
  console.error(err);
37
50
  setStatus("disabled");
@@ -1936,22 +1949,6 @@ function deleteIndex(indexName, client) {
1936
1949
  url: "/embeddings-index/".concat(dataset, "/").concat(indexName, "?projectId=").concat(projectId)
1937
1950
  });
1938
1951
  }
1939
- function useApiClient() {
1940
- const client = sanity.useClient({
1941
- apiVersion: "vX"
1942
- });
1943
- return require$$0.useMemo(() => {
1944
- const customHost = localStorage.getItem("embeddings-index-host");
1945
- if (customHost) {
1946
- return client.withConfig({
1947
- apiHost: customHost,
1948
- useProjectHostname: false,
1949
- withCredentials: false
1950
- });
1951
- }
1952
- return client;
1953
- }, [client]);
1954
- }
1955
1952
  const NO_RESULTS_VALUE = "";
1956
1953
  const NO_OPTIONS = [];
1957
1954
  const NO_FILTER = () => true;