@sanity/embeddings-index-ui 1.1.5 → 1.1.7
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 +1 -1
- package/dist/index.esm.js +46 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/isEnabled.tsx +17 -10
- package/src/embeddingsIndexDashboard/EmbeddingsIndexTool.tsx +20 -11
- package/src/referenceInput/SemanticSearchReferenceInput.tsx +7 -1
package/dist/index.js
CHANGED
|
@@ -19,22 +19,35 @@ var require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
|
|
|
19
19
|
function publicId(id) {
|
|
20
20
|
return id.replace("drafts.", "");
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
const FeatureEnabledContext = require$$0.createContext("loading");
|
|
24
|
-
function useIsFeatureEnabled() {
|
|
22
|
+
function useApiClient() {
|
|
25
23
|
const client = sanity.useClient({
|
|
26
|
-
apiVersion: "
|
|
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: "/
|
|
33
|
-
}).then(
|
|
34
|
-
setStatus(
|
|
45
|
+
url: "/embeddings-index/status"
|
|
46
|
+
}).then(response => {
|
|
47
|
+
setStatus(response.enabled ? "enabled" : "disabled");
|
|
35
48
|
}).catch(err => {
|
|
36
49
|
console.error(err);
|
|
37
|
-
setStatus("
|
|
50
|
+
setStatus("error");
|
|
38
51
|
});
|
|
39
52
|
}, [client]);
|
|
40
53
|
return status;
|
|
@@ -65,6 +78,14 @@ function FeatureDisabledNotice(props) {
|
|
|
65
78
|
})
|
|
66
79
|
});
|
|
67
80
|
}
|
|
81
|
+
function FeatureError() {
|
|
82
|
+
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
83
|
+
padding: 4,
|
|
84
|
+
border: true,
|
|
85
|
+
tone: "critical",
|
|
86
|
+
children: "An error occurred. See console for details."
|
|
87
|
+
});
|
|
88
|
+
}
|
|
68
89
|
|
|
69
90
|
/******************************************************************************
|
|
70
91
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1936,22 +1957,6 @@ function deleteIndex(indexName, client) {
|
|
|
1936
1957
|
url: "/embeddings-index/".concat(dataset, "/").concat(indexName, "?projectId=").concat(projectId)
|
|
1937
1958
|
});
|
|
1938
1959
|
}
|
|
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
1960
|
const NO_RESULTS_VALUE = "";
|
|
1956
1961
|
const NO_OPTIONS = [];
|
|
1957
1962
|
const NO_FILTER = () => true;
|
|
@@ -2144,6 +2149,9 @@ function SemanticSearchReferenceInput(props) {
|
|
|
2144
2149
|
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
|
|
2145
2150
|
}) : null, semantic && featureState == "disabled" ? /* @__PURE__ */jsxRuntime.jsx(FeatureDisabledNotice, {
|
|
2146
2151
|
urlSuffix: "?ref=embeddings-ref"
|
|
2152
|
+
}) : null, semantic && featureState === "error" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2153
|
+
padding: 4,
|
|
2154
|
+
children: /* @__PURE__ */jsxRuntime.jsx(FeatureError, {})
|
|
2147
2155
|
}) : null, /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2148
2156
|
flex: 1,
|
|
2149
2157
|
style: {
|
|
@@ -2752,25 +2760,31 @@ function IndexStatus(_ref4) {
|
|
|
2752
2760
|
function EmbeddingsIndexTool() {
|
|
2753
2761
|
const featureState = useIsFeatureEnabled();
|
|
2754
2762
|
return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2763
|
+
flex: 1,
|
|
2755
2764
|
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
|
|
2756
2765
|
justify: "center",
|
|
2757
2766
|
flex: 1,
|
|
2758
|
-
children: [featureState
|
|
2767
|
+
children: [featureState === "error" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2768
|
+
padding: 4,
|
|
2769
|
+
children: /* @__PURE__ */jsxRuntime.jsx(FeatureError, {})
|
|
2770
|
+
}) : null, featureState === "disabled" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2759
2771
|
padding: 4,
|
|
2760
2772
|
children: /* @__PURE__ */jsxRuntime.jsx(FeatureDisabledNotice, {
|
|
2761
2773
|
urlSuffix: "?ref=embeddings-tab"
|
|
2762
2774
|
})
|
|
2763
|
-
}) : null, /* @__PURE__ */jsxRuntime.
|
|
2775
|
+
}) : null, featureState === "loading" ? /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
|
|
2776
|
+
padding: 6,
|
|
2777
|
+
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {
|
|
2778
|
+
size: 4
|
|
2779
|
+
})
|
|
2780
|
+
}) : null, featureState === "enabled" ? /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
|
|
2764
2781
|
flex: 1,
|
|
2765
2782
|
style: {
|
|
2766
2783
|
maxWidth: 1200
|
|
2767
2784
|
},
|
|
2768
2785
|
padding: 5,
|
|
2769
|
-
children:
|
|
2770
|
-
|
|
2771
|
-
children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
|
|
2772
|
-
}) : null, featureState == "enabled" ? /* @__PURE__ */jsxRuntime.jsx(Indexes, {}) : null]
|
|
2773
|
-
})]
|
|
2786
|
+
children: /* @__PURE__ */jsxRuntime.jsx(Indexes, {})
|
|
2787
|
+
}) : null]
|
|
2774
2788
|
})
|
|
2775
2789
|
});
|
|
2776
2790
|
}
|