@sanity/embeddings-index-ui 3.0.1 → 4.0.1

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.
@@ -1,44 +0,0 @@
1
- import {definePlugin, isObjectInputProps, ObjectInputProps, ReferenceSchemaType} from 'sanity'
2
-
3
- import {FeatureEnabledProvider} from '../api/isEnabled'
4
- import {EmbeddingsIndexConfig} from '../schemas/typeDefExtensions'
5
- import {isType} from '../utils/types'
6
- import {SemanticSearchReferenceInput} from './SemanticSearchReferenceInput'
7
-
8
- export const embeddingsIndexReferenceInput = definePlugin<EmbeddingsIndexConfig | void>(
9
- (defaultConfig) => {
10
- const config = typeof defaultConfig === 'object' ? defaultConfig : undefined
11
-
12
- return {
13
- name: '@sanity/embeddings-index-reference-input',
14
- studio: {
15
- components: {
16
- layout: (props) => {
17
- return <FeatureEnabledProvider>{props.renderDefault(props)}</FeatureEnabledProvider>
18
- },
19
- },
20
- },
21
- form: {
22
- components: {
23
- input: (props) => {
24
- const embeddingsIndexConfig = (props.schemaType as ReferenceSchemaType)?.options
25
- ?.embeddingsIndex
26
- if (
27
- isObjectInputProps(props) &&
28
- isType(props.schemaType, 'reference') &&
29
- (embeddingsIndexConfig === true || embeddingsIndexConfig?.indexName)
30
- ) {
31
- return (
32
- <SemanticSearchReferenceInput
33
- {...(props as ObjectInputProps)}
34
- defaultConfig={config}
35
- />
36
- )
37
- }
38
- return props.renderDefault(props)
39
- },
40
- },
41
- },
42
- }
43
- },
44
- )
File without changes
@@ -1,27 +0,0 @@
1
- import 'sanity'
2
-
3
- export interface EmbeddingsIndexConfig {
4
- /**
5
- * Name of the index
6
- */
7
- indexName: string
8
- maxResults?: number
9
- /**
10
- * Determines if which search mode is enabled by default for the reference field.
11
- * Default is the studio default search, while 'embeddings' enables
12
- * Defaults to 'default' behaviour
13
- */
14
- searchMode?: 'embeddings' | 'default'
15
- }
16
-
17
- /* eslint-disable no-unused-vars */
18
- declare module 'sanity' {
19
- interface ReferenceBaseOptions {
20
- /**
21
- * Enables toggleable semantic search for a reference field.
22
- *
23
- * When `true`: will use default plugin configuration (if no config has been for the plugin provided ,this will throw an error)
24
- */
25
- embeddingsIndex?: true | EmbeddingsIndexConfig
26
- }
27
- }
package/src/utils/id.ts DELETED
@@ -1,3 +0,0 @@
1
- export function publicId(id: string): string {
2
- return id.replace('drafts.', '')
3
- }
@@ -1,11 +0,0 @@
1
- import {SchemaType} from 'sanity'
2
-
3
- export function isType(schemaType: SchemaType, typeName: string): boolean {
4
- if (schemaType.name === typeName) {
5
- return true
6
- }
7
- if (!schemaType.type) {
8
- return false
9
- }
10
- return isType(schemaType.type, typeName)
11
- }
@@ -1,11 +0,0 @@
1
- const {showIncompatiblePluginDialog} = require('@sanity/incompatible-plugin')
2
- const {name, version, sanityExchangeUrl} = require('./package.json')
3
-
4
- export default showIncompatiblePluginDialog({
5
- name: name,
6
- versions: {
7
- v3: version,
8
- v2: undefined,
9
- },
10
- sanityExchangeUrl,
11
- })