@sanity/embeddings-index-ui 1.1.4 → 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 +1 -1
- package/dist/index.esm.js +22 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +21 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/isEnabled.tsx +8 -9
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
|
-
|
|
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
50
|
setStatus("disabled");
|
|
@@ -58,7 +71,7 @@ function FeatureDisabledNotice(props) {
|
|
|
58
71
|
padding: 4,
|
|
59
72
|
children: /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
|
|
60
73
|
size: 1,
|
|
61
|
-
children: ["\u{1F48E} Unlock semantic search with Embeddings Index
|
|
74
|
+
children: ["\u{1F48E} Unlock semantic search with the Embeddings Index API \u2014 available on Team, Business, and Enterprise plans.", " ", /* @__PURE__ */jsxRuntime.jsx("a", {
|
|
62
75
|
href: "https://www.sanity.io/manage/project/".concat(projectId, "/plan").concat((_a = props.urlSuffix) != null ? _a : ""),
|
|
63
76
|
children: "Upgrade now \u2192"
|
|
64
77
|
})]
|
|
@@ -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;
|