@sanity/assist 5.0.4 → 6.0.0
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/LICENSE +1 -1
- package/README.md +28 -254
- package/dist/index.d.ts +322 -410
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3181 -2649
- package/dist/index.js.map +1 -1
- package/package.json +38 -78
- package/dist/index.cjs +0 -4239
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -791
- package/sanity.json +0 -8
- package/src/_lib/connector/ConnectFromRegion.tsx +0 -25
- package/src/_lib/connector/ConnectToRegion.tsx +0 -23
- package/src/_lib/connector/ConnectorRegion.tsx +0 -24
- package/src/_lib/connector/ConnectorsProvider.tsx +0 -20
- package/src/_lib/connector/ConnectorsStore.ts +0 -122
- package/src/_lib/connector/ConnectorsStoreContext.ts +0 -5
- package/src/_lib/connector/helpers.ts +0 -5
- package/src/_lib/connector/index.ts +0 -9
- package/src/_lib/connector/mapConnectorToLine.ts +0 -83
- package/src/_lib/connector/types.ts +0 -56
- package/src/_lib/connector/useConnectorsStore.ts +0 -14
- package/src/_lib/connector/useRegionRects.ts +0 -142
- package/src/_lib/fixedListenQuery.ts +0 -101
- package/src/_lib/form/DocumentForm.tsx +0 -201
- package/src/_lib/form/constants.ts +0 -1
- package/src/_lib/form/helpers.ts +0 -32
- package/src/_lib/form/index.ts +0 -1
- package/src/_lib/randomKey.ts +0 -29
- package/src/_lib/useListeningQuery.ts +0 -62
- package/src/_lib/usePrevious.ts +0 -9
- package/src/assistConnectors/AssistConnectorsOverlay.tsx +0 -133
- package/src/assistConnectors/ConnectorPath.tsx +0 -63
- package/src/assistConnectors/draw/arrowPath.ts +0 -9
- package/src/assistConnectors/draw/connectorPath.ts +0 -142
- package/src/assistConnectors/index.ts +0 -1
- package/src/assistDocument/AssistDocumentContext.tsx +0 -51
- package/src/assistDocument/AssistDocumentContextProvider.tsx +0 -17
- package/src/assistDocument/AssistDocumentInput.tsx +0 -61
- package/src/assistDocument/AssistDocumentLayout.tsx +0 -12
- package/src/assistDocument/RequestRunInstructionProvider.tsx +0 -61
- package/src/assistDocument/components/AssistDocumentForm.tsx +0 -287
- package/src/assistDocument/components/AssistTypeContext.tsx +0 -7
- package/src/assistDocument/components/FieldRefPreview.tsx +0 -26
- package/src/assistDocument/components/InstructionsArrayField.tsx +0 -8
- package/src/assistDocument/components/InstructionsArrayInput.tsx +0 -27
- package/src/assistDocument/components/SelectedFieldContext.tsx +0 -10
- package/src/assistDocument/components/generic/HiddenFieldTitle.tsx +0 -5
- package/src/assistDocument/components/helpers.ts +0 -21
- package/src/assistDocument/components/instruction/BackToInstructionsLink.tsx +0 -32
- package/src/assistDocument/components/instruction/FieldRefInput.tsx +0 -54
- package/src/assistDocument/components/instruction/InstructionInput.tsx +0 -89
- package/src/assistDocument/components/instruction/InstructionOutputField.tsx +0 -46
- package/src/assistDocument/components/instruction/InstructionOutputInput.tsx +0 -206
- package/src/assistDocument/components/instruction/PromptInput.tsx +0 -59
- package/src/assistDocument/components/instruction/appearance/IconInput.tsx +0 -46
- package/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx +0 -37
- package/src/assistDocument/hooks/useAssistDocumentContextValue.tsx +0 -127
- package/src/assistDocument/hooks/useDocumentState.ts +0 -6
- package/src/assistDocument/hooks/useInstructionToaster.tsx +0 -75
- package/src/assistDocument/hooks/useStudioAssistDocument.ts +0 -99
- package/src/assistDocument/index.ts +0 -1
- package/src/assistFormComponents/AssistField.tsx +0 -63
- package/src/assistFormComponents/AssistFormBlock.tsx +0 -31
- package/src/assistFormComponents/AssistInlineFormBlock.tsx +0 -13
- package/src/assistFormComponents/AssistItem.tsx +0 -21
- package/src/assistFormComponents/validation/listItem.tsx +0 -63
- package/src/assistFormComponents/validation/validationList.tsx +0 -90
- package/src/assistInspector/AssistInspector.tsx +0 -419
- package/src/assistInspector/FieldAutocomplete.tsx +0 -146
- package/src/assistInspector/InstructionTaskHistoryButton.tsx +0 -262
- package/src/assistInspector/constants.ts +0 -1
- package/src/assistInspector/helpers.ts +0 -211
- package/src/assistInspector/index.ts +0 -27
- package/src/assistLayout/AiAssistanceConfigContext.tsx +0 -32
- package/src/assistLayout/AiAssistanceConfigProvider.tsx +0 -98
- package/src/assistLayout/AssistLayout.tsx +0 -39
- package/src/assistLayout/RunInstructionProvider.tsx +0 -278
- package/src/assistLayout/fieldRefCache.tsx +0 -34
- package/src/assistTypes.ts +0 -83
- package/src/components/AssistFeatureBadge.tsx +0 -9
- package/src/components/FadeInContent.tsx +0 -40
- package/src/components/HideReferenceChangedBannerInput.tsx +0 -25
- package/src/components/ImageContext.tsx +0 -85
- package/src/components/SafeValueInput.tsx +0 -74
- package/src/components/TimeAgo.tsx +0 -18
- package/src/constants.ts +0 -20
- package/src/fieldActions/PrivateIcon.tsx +0 -20
- package/src/fieldActions/assistFieldActions.tsx +0 -320
- package/src/fieldActions/customFieldActions.tsx +0 -333
- package/src/fieldActions/generateCaptionActions.tsx +0 -77
- package/src/fieldActions/generateImageActions.tsx +0 -58
- package/src/fieldActions/useUserInput.ts +0 -107
- package/src/globals.d.ts +0 -4
- package/src/helpers/assistSupported.ts +0 -49
- package/src/helpers/conditionalMembers.test.ts +0 -319
- package/src/helpers/conditionalMembers.ts +0 -134
- package/src/helpers/ids.test.ts +0 -28
- package/src/helpers/ids.ts +0 -23
- package/src/helpers/misc.ts +0 -25
- package/src/helpers/styleguide.ts +0 -24
- package/src/helpers/typeUtils.ts +0 -60
- package/src/helpers/useAssistSupported.ts +0 -8
- package/src/index.ts +0 -26
- package/src/onboarding/FirstAssistedPathProvider.tsx +0 -30
- package/src/onboarding/InspectorOnboarding.tsx +0 -47
- package/src/onboarding/onboardingStore.ts +0 -32
- package/src/plugin.tsx +0 -162
- package/src/presence/AiFieldPresence.tsx +0 -28
- package/src/presence/AssistAvatar.tsx +0 -96
- package/src/presence/AssistDocumentPresence.tsx +0 -50
- package/src/presence/useAssistPresence.ts +0 -64
- package/src/schemas/assistDocumentSchema.tsx +0 -497
- package/src/schemas/contextDocumentSchema.tsx +0 -57
- package/src/schemas/index.ts +0 -69
- package/src/schemas/serialize/SchemTypeTool.tsx +0 -103
- package/src/schemas/serialize/schemaUtils.ts +0 -38
- package/src/schemas/serialize/serializeSchema.test.ts +0 -819
- package/src/schemas/serialize/serializeSchema.ts +0 -224
- package/src/schemas/serializedSchemaTypeSchema.ts +0 -60
- package/src/schemas/typeDefExtensions.ts +0 -127
- package/src/translate/FieldTranslationProvider.tsx +0 -382
- package/src/translate/getLanguageParams.ts +0 -26
- package/src/translate/languageStore.ts +0 -18
- package/src/translate/paths.test.ts +0 -181
- package/src/translate/paths.ts +0 -183
- package/src/translate/translateActions.tsx +0 -205
- package/src/translate/types.ts +0 -197
- package/src/types.ts +0 -220
- package/src/useApiClient.ts +0 -338
- package/v2-incompatible.js +0 -11
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArraySchemaType,
|
|
3
|
-
ImageOptions,
|
|
4
|
-
isArraySchemaType,
|
|
5
|
-
ObjectSchemaType,
|
|
6
|
-
ReferenceOptions,
|
|
7
|
-
ReferenceSchemaType,
|
|
8
|
-
Schema,
|
|
9
|
-
SchemaType,
|
|
10
|
-
typed,
|
|
11
|
-
} from 'sanity'
|
|
12
|
-
|
|
13
|
-
import {isAssistSupported} from '../../helpers/assistSupported'
|
|
14
|
-
import {isType} from '../../helpers/typeUtils'
|
|
15
|
-
import {
|
|
16
|
-
assistSchemaIdPrefix,
|
|
17
|
-
assistSerializedFieldTypeName,
|
|
18
|
-
assistSerializedTypeName,
|
|
19
|
-
SerializedSchemaMember,
|
|
20
|
-
SerializedSchemaType,
|
|
21
|
-
} from '../../types'
|
|
22
|
-
import {hiddenTypes} from './schemaUtils'
|
|
23
|
-
|
|
24
|
-
interface Options {
|
|
25
|
-
leanFormat?: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const inlineTypes = ['document', 'object', 'image', 'file']
|
|
29
|
-
|
|
30
|
-
export function serializeSchema(schema: Schema, options?: Options): SerializedSchemaType[] {
|
|
31
|
-
const list = schema
|
|
32
|
-
.getTypeNames()
|
|
33
|
-
.filter((t) => !(hiddenTypes.includes(t) || t.startsWith('sanity.')))
|
|
34
|
-
.map((t) => schema.get(t))
|
|
35
|
-
.filter((t): t is SchemaType => !!t)
|
|
36
|
-
// because a field can override exclude at the type level, we have to also serialize excluded types
|
|
37
|
-
// so don't do this: .filter((t) => isAssistSupported(t))
|
|
38
|
-
.map((t) => getSchemaStub(t, schema, options))
|
|
39
|
-
.filter((t) => {
|
|
40
|
-
if ('to' in t && t.to && !t.to.length) {
|
|
41
|
-
return false
|
|
42
|
-
}
|
|
43
|
-
if ('of' in t && t.of && !t.of.length) {
|
|
44
|
-
return false
|
|
45
|
-
}
|
|
46
|
-
if ('fields' in t && t.fields && !t.fields.length) {
|
|
47
|
-
return false
|
|
48
|
-
}
|
|
49
|
-
return true
|
|
50
|
-
})
|
|
51
|
-
list.sort((a, b) => (a?.name ?? '').localeCompare(b?.name ?? ''))
|
|
52
|
-
return list
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getSchemaStub(
|
|
56
|
-
schemaType: SchemaType,
|
|
57
|
-
schema: Schema,
|
|
58
|
-
options?: Options,
|
|
59
|
-
): SerializedSchemaType {
|
|
60
|
-
if (!schemaType.type?.name) {
|
|
61
|
-
// eslint-disable-next-line no-console -- log error
|
|
62
|
-
console.error('Missing type name', schemaType.type)
|
|
63
|
-
throw new Error('Type is missing name!')
|
|
64
|
-
}
|
|
65
|
-
const baseSchema: SerializedSchemaType = {
|
|
66
|
-
// we dont need type or id when we send using POST, so leave these out to save bandwidth
|
|
67
|
-
...(options?.leanFormat
|
|
68
|
-
? {}
|
|
69
|
-
: {_id: `${assistSchemaIdPrefix}${schemaType.name}`, _type: assistSerializedTypeName}),
|
|
70
|
-
name: schemaType.name,
|
|
71
|
-
title: schemaType.title,
|
|
72
|
-
type: schemaType.type.name,
|
|
73
|
-
...getBaseFields(schema, schemaType, schemaType.type.name, options),
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return removeUndef(baseSchema)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function getBaseFields(
|
|
80
|
-
schema: Schema,
|
|
81
|
-
type: SchemaType,
|
|
82
|
-
typeName: string,
|
|
83
|
-
options: Options | undefined,
|
|
84
|
-
) {
|
|
85
|
-
const schemaOptions: SerializedSchemaType['options'] = removeUndef({
|
|
86
|
-
imagePromptField: (type.options as ImageOptions)?.aiAssist?.imageInstructionField,
|
|
87
|
-
embeddingsIndex: (type.options as ReferenceOptions)?.aiAssist?.embeddingsIndex,
|
|
88
|
-
})
|
|
89
|
-
return removeUndef({
|
|
90
|
-
options: Object.keys(schemaOptions).length ? schemaOptions : undefined,
|
|
91
|
-
values: Array.isArray(type?.options?.list)
|
|
92
|
-
? type?.options?.list.map((v: string | {value: string; title: string}) =>
|
|
93
|
-
typeof v === 'string' ? v : (v.value ?? `${v.title}`),
|
|
94
|
-
)
|
|
95
|
-
: undefined,
|
|
96
|
-
of: 'of' in type && typeName === 'array' ? arrayOf(type, schema, options) : undefined,
|
|
97
|
-
to:
|
|
98
|
-
'to' in type && typeName === 'reference'
|
|
99
|
-
? refToTypeNames(type as ReferenceSchemaType)
|
|
100
|
-
: undefined,
|
|
101
|
-
fields:
|
|
102
|
-
'fields' in type && inlineTypes.includes(typeName)
|
|
103
|
-
? serializeFields(schema, type, options)
|
|
104
|
-
: undefined,
|
|
105
|
-
annotations:
|
|
106
|
-
typeName === 'block' && 'fields' in type
|
|
107
|
-
? serializeAnnotations(type, schema, options)
|
|
108
|
-
: undefined,
|
|
109
|
-
inlineOf:
|
|
110
|
-
typeName === 'block' && 'fields' in type
|
|
111
|
-
? serializeInlineOf(type, schema, options)
|
|
112
|
-
: undefined,
|
|
113
|
-
hidden:
|
|
114
|
-
typeof type.hidden === 'function' ? ('function' as const) : type.hidden ? true : undefined,
|
|
115
|
-
readOnly:
|
|
116
|
-
typeof type.readOnly === 'function'
|
|
117
|
-
? ('function' as const)
|
|
118
|
-
: type.readOnly
|
|
119
|
-
? true
|
|
120
|
-
: undefined,
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function serializeFields(
|
|
125
|
-
schema: Schema,
|
|
126
|
-
schemaType: ObjectSchemaType,
|
|
127
|
-
options: Options | undefined,
|
|
128
|
-
) {
|
|
129
|
-
const fields = schemaType.fieldsets
|
|
130
|
-
? schemaType.fieldsets.flatMap((fs) =>
|
|
131
|
-
fs.single
|
|
132
|
-
? fs.field
|
|
133
|
-
: fs.fields.map((f) => ({
|
|
134
|
-
...f,
|
|
135
|
-
type: {
|
|
136
|
-
...f.type,
|
|
137
|
-
// if fieldset is (conditionally) hidden, the field must be considered the same way
|
|
138
|
-
// ie, if the field does not show up in conditionalMembers, it is hidden
|
|
139
|
-
// regardless of weather or not it is the field function or the fieldset function that hides it
|
|
140
|
-
hidden:
|
|
141
|
-
typeof fs.hidden === 'function' ? fs.hidden : fs.hidden ? true : f.type.hidden,
|
|
142
|
-
},
|
|
143
|
-
})),
|
|
144
|
-
)
|
|
145
|
-
: schemaType.fields
|
|
146
|
-
|
|
147
|
-
return fields
|
|
148
|
-
.filter((f) => !['sanity.imageHotspot', 'sanity.imageCrop'].includes(f.type?.name ?? ''))
|
|
149
|
-
.filter((f) => isAssistSupported(f.type))
|
|
150
|
-
.map((field) => serializeMember(schema, field.type, field.name, options))
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function serializeMember(
|
|
154
|
-
schema: Schema,
|
|
155
|
-
type: SchemaType,
|
|
156
|
-
name: string,
|
|
157
|
-
options: Options | undefined,
|
|
158
|
-
): SerializedSchemaMember {
|
|
159
|
-
const typeNameExists = !!schema.get(type?.name)
|
|
160
|
-
const typeName = typeNameExists ? type.name : (type.type?.name ?? '')
|
|
161
|
-
return removeUndef({
|
|
162
|
-
...(options?.leanFormat ? {} : {_type: assistSerializedFieldTypeName}),
|
|
163
|
-
name: name,
|
|
164
|
-
type: typeName,
|
|
165
|
-
title: type.title,
|
|
166
|
-
...getBaseFields(schema, type, typeName, options),
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function serializeInlineOf(
|
|
171
|
-
blockSchemaType: ObjectSchemaType,
|
|
172
|
-
schema: Schema,
|
|
173
|
-
options: Options | undefined,
|
|
174
|
-
): SerializedSchemaMember[] | undefined {
|
|
175
|
-
const childrenField = blockSchemaType.fields.find((f) => f.name === 'children')
|
|
176
|
-
const childrenType = childrenField?.type
|
|
177
|
-
if (!childrenType || !isArraySchemaType(childrenType)) {
|
|
178
|
-
return undefined
|
|
179
|
-
}
|
|
180
|
-
return arrayOf(
|
|
181
|
-
{
|
|
182
|
-
...childrenType,
|
|
183
|
-
of: childrenType.of.filter((t) => !isType(t, 'span')),
|
|
184
|
-
},
|
|
185
|
-
schema,
|
|
186
|
-
options,
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function serializeAnnotations(
|
|
191
|
-
blockSchemaType: ObjectSchemaType,
|
|
192
|
-
schema: Schema,
|
|
193
|
-
options: Options | undefined,
|
|
194
|
-
): SerializedSchemaMember[] | undefined {
|
|
195
|
-
const markDefs = blockSchemaType.fields.find((f) => f.name === 'markDefs')
|
|
196
|
-
const marksType = markDefs?.type
|
|
197
|
-
if (!marksType || !isArraySchemaType(marksType)) {
|
|
198
|
-
return undefined
|
|
199
|
-
}
|
|
200
|
-
return arrayOf(marksType, schema, options)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function arrayOf(
|
|
204
|
-
arrayType: ArraySchemaType,
|
|
205
|
-
schema: Schema,
|
|
206
|
-
options: Options | undefined,
|
|
207
|
-
): SerializedSchemaMember[] {
|
|
208
|
-
return arrayType.of
|
|
209
|
-
.filter((type) => isAssistSupported(type))
|
|
210
|
-
.map((t) => {
|
|
211
|
-
return serializeMember(schema, t, t.name, options)
|
|
212
|
-
})
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function refToTypeNames(type: ReferenceSchemaType) {
|
|
216
|
-
return type.to.map((t) => ({
|
|
217
|
-
type: typed<string>(t.name),
|
|
218
|
-
}))
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function removeUndef<T extends Record<string, any>>(obj: T): T {
|
|
222
|
-
Object.keys(obj).forEach((key) => (obj[key] === undefined ? delete obj[key] : {}))
|
|
223
|
-
return obj
|
|
224
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {CodeIcon, StarIcon} from '@sanity/icons'
|
|
2
|
-
import {defineField, defineType} from 'sanity'
|
|
3
|
-
|
|
4
|
-
import {assistSerializedFieldTypeName, assistSerializedTypeName} from '../types'
|
|
5
|
-
|
|
6
|
-
export const serializedSchemaField = defineType({
|
|
7
|
-
type: 'object',
|
|
8
|
-
name: assistSerializedFieldTypeName,
|
|
9
|
-
title: 'Field',
|
|
10
|
-
icon: CodeIcon,
|
|
11
|
-
fields: [
|
|
12
|
-
defineField({
|
|
13
|
-
name: 'name',
|
|
14
|
-
title: 'Name',
|
|
15
|
-
type: 'string',
|
|
16
|
-
}),
|
|
17
|
-
defineField({
|
|
18
|
-
name: 'type',
|
|
19
|
-
title: 'Type',
|
|
20
|
-
type: 'string',
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
preview: {
|
|
24
|
-
select: {
|
|
25
|
-
title: 'title',
|
|
26
|
-
subtitle: 'type',
|
|
27
|
-
},
|
|
28
|
-
prepare: ({title, subtitle}) => {
|
|
29
|
-
return {
|
|
30
|
-
title,
|
|
31
|
-
subtitle,
|
|
32
|
-
media: CodeIcon,
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
export const serializedSchemaType = defineType({
|
|
39
|
-
name: assistSerializedTypeName,
|
|
40
|
-
type: 'document',
|
|
41
|
-
title: 'Meta schema',
|
|
42
|
-
icon: StarIcon,
|
|
43
|
-
fields: [
|
|
44
|
-
defineField({
|
|
45
|
-
name: 'name',
|
|
46
|
-
title: 'Name',
|
|
47
|
-
type: 'string',
|
|
48
|
-
}),
|
|
49
|
-
defineField({
|
|
50
|
-
name: 'type',
|
|
51
|
-
title: 'Type',
|
|
52
|
-
type: 'string',
|
|
53
|
-
}),
|
|
54
|
-
defineField({
|
|
55
|
-
name: 'fields',
|
|
56
|
-
type: 'array',
|
|
57
|
-
of: [{type: serializedSchemaField.name}],
|
|
58
|
-
}),
|
|
59
|
-
],
|
|
60
|
-
})
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import 'sanity'
|
|
2
|
-
/* eslint-disable no-unused-vars */
|
|
3
|
-
export interface AssistOptions {
|
|
4
|
-
aiAssist?: {
|
|
5
|
-
/** Set to true to disable assistance for this field or type */
|
|
6
|
-
exclude?: boolean
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Set to true to add translation field-action to the field.
|
|
10
|
-
* Only has an effect in document types configured for document or field level translations.
|
|
11
|
-
*/
|
|
12
|
-
translateAction?: boolean
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
declare module 'sanity' {
|
|
17
|
-
interface ArrayOptions extends AssistOptions {}
|
|
18
|
-
interface BlockOptions extends AssistOptions {}
|
|
19
|
-
interface BooleanOptions extends AssistOptions {}
|
|
20
|
-
interface CrossDatasetReferenceOptions extends AssistOptions {}
|
|
21
|
-
interface DateOptions extends AssistOptions {}
|
|
22
|
-
interface DatetimeOptions extends AssistOptions {}
|
|
23
|
-
interface DocumentOptions extends AssistOptions {}
|
|
24
|
-
interface FileOptions extends AssistOptions {}
|
|
25
|
-
interface GeopointOptions extends AssistOptions {}
|
|
26
|
-
interface ImageOptions {
|
|
27
|
-
aiAssist?: AssistOptions['aiAssist'] & {
|
|
28
|
-
/**
|
|
29
|
-
* When set, an image will be created whenever the `imageInstructionField` is written to by
|
|
30
|
-
* an AI Assist instruction.
|
|
31
|
-
*
|
|
32
|
-
* The value output by AI Assist will be use as an image prompt for an generative image AI.
|
|
33
|
-
*
|
|
34
|
-
* This means that instructions directly for the field or instructions that visit the field when running,
|
|
35
|
-
* will result in the image being changed.
|
|
36
|
-
*
|
|
37
|
-
* `imageInstructionField` must be a child-path relative to the image field, ie:
|
|
38
|
-
* * field
|
|
39
|
-
* * path.to.field
|
|
40
|
-
*
|
|
41
|
-
* ### Example
|
|
42
|
-
* ```ts
|
|
43
|
-
* defineType({
|
|
44
|
-
* type: 'image',
|
|
45
|
-
* name: 'articleImage',
|
|
46
|
-
* fields: [
|
|
47
|
-
* defineField({
|
|
48
|
-
* type: 'text',
|
|
49
|
-
* name: 'imagePrompt',
|
|
50
|
-
* title: 'Image prompt',
|
|
51
|
-
* rows: 2,
|
|
52
|
-
* }),
|
|
53
|
-
* ],
|
|
54
|
-
* options: {
|
|
55
|
-
* aiAssist: {
|
|
56
|
-
* imageInstructionField: 'imagePrompt',
|
|
57
|
-
* }
|
|
58
|
-
* },
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
imageInstructionField?: string
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* When set, an image description will be automatically created for the image.
|
|
66
|
-
*
|
|
67
|
-
* `imageDescriptionField` must be a child-path relative to the image field, ie:
|
|
68
|
-
* * field
|
|
69
|
-
* * path.to.field
|
|
70
|
-
*
|
|
71
|
-
* Whenever the image asset for the field is changed in the Studio,
|
|
72
|
-
* an image description is generated and set into the `imageDescriptionField`.
|
|
73
|
-
*
|
|
74
|
-
* ### Example
|
|
75
|
-
* ```ts
|
|
76
|
-
* defineType({
|
|
77
|
-
* type: 'image',
|
|
78
|
-
* name: 'articleImage',
|
|
79
|
-
* fields: [
|
|
80
|
-
* defineField({
|
|
81
|
-
* type: 'string',
|
|
82
|
-
* name: 'altText',
|
|
83
|
-
* title: 'Alt text',
|
|
84
|
-
* }),
|
|
85
|
-
* ],
|
|
86
|
-
* options: {
|
|
87
|
-
* aiAssist: {
|
|
88
|
-
* imageDescriptionField: 'altText',
|
|
89
|
-
* }
|
|
90
|
-
* },
|
|
91
|
-
* })
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
imageDescriptionField?:
|
|
95
|
-
| string
|
|
96
|
-
| {
|
|
97
|
-
path: string
|
|
98
|
-
/**
|
|
99
|
-
* When updateOnImageChange is true (or undefined), whenever the
|
|
100
|
-
* image asset changes, imageDescriptionField will be regenerated.
|
|
101
|
-
*
|
|
102
|
-
* default: true
|
|
103
|
-
* */
|
|
104
|
-
updateOnImageChange?: boolean
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
interface NumberOptions extends AssistOptions {}
|
|
109
|
-
interface ObjectOptions extends AssistOptions {}
|
|
110
|
-
interface ReferenceBaseOptions {
|
|
111
|
-
aiAssist?: {
|
|
112
|
-
/** Set to true to disable assistance for this field or type */
|
|
113
|
-
exclude?: boolean
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* When set, the reference field will allow instructions to be added to it.
|
|
117
|
-
* Should be the name of the embeddings-index where assist will look for contextually relevant documents
|
|
118
|
-
* */
|
|
119
|
-
embeddingsIndex?: string
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
interface SlugOptions extends AssistOptions {}
|
|
123
|
-
interface StringOptions extends AssistOptions {}
|
|
124
|
-
interface TextOptions extends AssistOptions {}
|
|
125
|
-
interface UrlOptions extends AssistOptions {}
|
|
126
|
-
interface EmailOptions extends AssistOptions {}
|
|
127
|
-
}
|