@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/package.json
CHANGED
package/src/api/isEnabled.tsx
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {useProjectId} from 'sanity'
|
|
2
2
|
import {createContext, PropsWithChildren, useContext, useEffect, useState} from 'react'
|
|
3
3
|
import {Card, Text} from '@sanity/ui'
|
|
4
|
-
|
|
5
|
-
const featureName = 'embeddingsIndexApi'
|
|
4
|
+
import {useApiClient} from './embeddingsApiHooks'
|
|
6
5
|
|
|
7
6
|
export type FeatureStatus = 'enabled' | 'disabled' | 'loading'
|
|
8
7
|
export const FeatureEnabledContext = createContext<FeatureStatus>('loading')
|
|
9
8
|
|
|
10
9
|
export function useIsFeatureEnabled() {
|
|
11
|
-
const client =
|
|
10
|
+
const client = useApiClient()
|
|
12
11
|
const [status, setStatus] = useState<FeatureStatus>('loading')
|
|
13
12
|
|
|
14
13
|
useEffect(() => {
|
|
15
14
|
client
|
|
16
|
-
.request<
|
|
15
|
+
.request<{enabled: boolean}>({
|
|
17
16
|
method: 'GET',
|
|
18
|
-
url: `/
|
|
17
|
+
url: `/embeddings-index/status`,
|
|
19
18
|
})
|
|
20
|
-
.then((
|
|
21
|
-
setStatus(
|
|
19
|
+
.then((response) => {
|
|
20
|
+
setStatus(response.enabled ? 'enabled' : 'disabled')
|
|
22
21
|
})
|
|
23
22
|
.catch((err) => {
|
|
24
23
|
console.error(err)
|
|
@@ -46,7 +45,7 @@ export function FeatureDisabledNotice(props: {urlSuffix?: string}) {
|
|
|
46
45
|
return (
|
|
47
46
|
<Card tone="primary" border padding={4}>
|
|
48
47
|
<Text size={1}>
|
|
49
|
-
💎 Unlock semantic search with Embeddings Index
|
|
48
|
+
💎 Unlock semantic search with the Embeddings Index API — available on Team, Business, and
|
|
50
49
|
Enterprise plans.{' '}
|
|
51
50
|
<a href={`https://www.sanity.io/manage/project/${projectId}/plan${props.urlSuffix ?? ''}`}>
|
|
52
51
|
Upgrade now →
|