@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,57 +0,0 @@
|
|
|
1
|
-
import {DocumentTextIcon, TokenIcon} from '@sanity/icons'
|
|
2
|
-
import {defineArrayMember, defineField, defineType} from 'sanity'
|
|
3
|
-
|
|
4
|
-
import {HideReferenceChangedBannerInput} from '../components/HideReferenceChangedBannerInput'
|
|
5
|
-
import {contextDocumentTypeName} from '../types'
|
|
6
|
-
|
|
7
|
-
export const contextDocumentSchema = defineType({
|
|
8
|
-
type: 'document',
|
|
9
|
-
name: contextDocumentTypeName,
|
|
10
|
-
title: 'AI context',
|
|
11
|
-
liveEdit: true,
|
|
12
|
-
icon: TokenIcon,
|
|
13
|
-
components: {
|
|
14
|
-
input: HideReferenceChangedBannerInput,
|
|
15
|
-
},
|
|
16
|
-
fields: [
|
|
17
|
-
defineField({
|
|
18
|
-
type: 'string',
|
|
19
|
-
name: 'title',
|
|
20
|
-
title: 'Title',
|
|
21
|
-
}),
|
|
22
|
-
defineField({
|
|
23
|
-
name: 'context',
|
|
24
|
-
type: 'array',
|
|
25
|
-
title: 'Context',
|
|
26
|
-
of: [
|
|
27
|
-
defineArrayMember({
|
|
28
|
-
type: 'block',
|
|
29
|
-
styles: [{title: 'Normal', value: 'normal'}],
|
|
30
|
-
lists: [],
|
|
31
|
-
marks: {
|
|
32
|
-
decorators: [],
|
|
33
|
-
annotations: [],
|
|
34
|
-
},
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
37
|
-
}),
|
|
38
|
-
],
|
|
39
|
-
preview: {
|
|
40
|
-
select: {
|
|
41
|
-
title: 'title',
|
|
42
|
-
context: 'context',
|
|
43
|
-
},
|
|
44
|
-
prepare({title, context}) {
|
|
45
|
-
const text = context
|
|
46
|
-
?.flatMap((block: any) => block?.children)
|
|
47
|
-
.flatMap((child: any) => child?.text?.split(' '))
|
|
48
|
-
.filter(Boolean)
|
|
49
|
-
const words = text?.length ?? 0
|
|
50
|
-
return {
|
|
51
|
-
title,
|
|
52
|
-
subtitle: `Words: ${words}`,
|
|
53
|
-
media: DocumentTextIcon,
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
})
|
package/src/schemas/index.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
import {ArrayOfType, FieldProps, SchemaTypeDefinition} from 'sanity'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
assistDocumentSchema,
|
|
6
|
-
documentInstructionStatus,
|
|
7
|
-
fieldInstructions,
|
|
8
|
-
fieldReference,
|
|
9
|
-
instruction,
|
|
10
|
-
instructionTask,
|
|
11
|
-
outputFieldType,
|
|
12
|
-
outputTypeType,
|
|
13
|
-
prompt,
|
|
14
|
-
promptContext,
|
|
15
|
-
userInput,
|
|
16
|
-
} from './assistDocumentSchema'
|
|
17
|
-
import {contextDocumentSchema} from './contextDocumentSchema'
|
|
18
|
-
|
|
19
|
-
function excludeComments<T extends SchemaTypeDefinition | ArrayOfType>(type: T): T {
|
|
20
|
-
const existingRender = (type as any)?.components?.field
|
|
21
|
-
return {
|
|
22
|
-
...type,
|
|
23
|
-
...('components' in type
|
|
24
|
-
? {
|
|
25
|
-
components: {
|
|
26
|
-
...type.components,
|
|
27
|
-
field: (props: FieldProps) => {
|
|
28
|
-
const newProps = {...props, ...{__internal_comments: undefined}}
|
|
29
|
-
if (typeof existingRender === 'function') {
|
|
30
|
-
return existingRender(newProps)
|
|
31
|
-
}
|
|
32
|
-
return props.renderDefault(newProps)
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
}
|
|
36
|
-
: {}),
|
|
37
|
-
...('fields' in type
|
|
38
|
-
? {
|
|
39
|
-
// recursively disable comments in fields
|
|
40
|
-
fields: type.fields?.map((field) => excludeComments(field)),
|
|
41
|
-
}
|
|
42
|
-
: {}),
|
|
43
|
-
...('of' in type
|
|
44
|
-
? {
|
|
45
|
-
// recursively disable comments in array items
|
|
46
|
-
of: type.of?.map((arrayItemType) => excludeComments(arrayItemType)),
|
|
47
|
-
}
|
|
48
|
-
: {}),
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const instructionForm = [
|
|
53
|
-
fieldInstructions,
|
|
54
|
-
instruction,
|
|
55
|
-
fieldReference,
|
|
56
|
-
prompt,
|
|
57
|
-
userInput,
|
|
58
|
-
promptContext,
|
|
59
|
-
].map(excludeComments)
|
|
60
|
-
|
|
61
|
-
export const schemaTypes = [
|
|
62
|
-
...instructionForm,
|
|
63
|
-
outputFieldType,
|
|
64
|
-
outputTypeType,
|
|
65
|
-
assistDocumentSchema,
|
|
66
|
-
documentInstructionStatus,
|
|
67
|
-
instructionTask,
|
|
68
|
-
contextDocumentSchema,
|
|
69
|
-
]
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {SyncIcon} from '@sanity/icons'
|
|
2
|
-
import {Box, Button, Card, Flex, Label, Spinner, Stack} from '@sanity/ui'
|
|
3
|
-
import {useCallback, useMemo, useState} from 'react'
|
|
4
|
-
import {useClient, useSchema} from 'sanity'
|
|
5
|
-
|
|
6
|
-
import {useListeningQuery} from '../../_lib/useListeningQuery'
|
|
7
|
-
import {assistSerializedTypeName, SerializedSchemaType} from '../../types'
|
|
8
|
-
import {serializeSchema} from './serializeSchema'
|
|
9
|
-
|
|
10
|
-
const NO_DATA: SerializedSchemaType[] = []
|
|
11
|
-
|
|
12
|
-
const defaultTitle = 'Sync schema'
|
|
13
|
-
|
|
14
|
-
export function SchemaTypeTool() {
|
|
15
|
-
const schema = useSchema()
|
|
16
|
-
const client = useClient({apiVersion: '2023-01-01'})
|
|
17
|
-
const [saving, setSaving] = useState(false)
|
|
18
|
-
const [syncTitle, setSyncTitle] = useState(defaultTitle)
|
|
19
|
-
|
|
20
|
-
const {data} = useListeningQuery<SerializedSchemaType[]>('*[_type==$type] | order(_type)', {
|
|
21
|
-
type: assistSerializedTypeName,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const types = useMemo(() => {
|
|
25
|
-
return serializeSchema(schema)
|
|
26
|
-
}, [schema])
|
|
27
|
-
|
|
28
|
-
const storeTypes = useCallback(() => {
|
|
29
|
-
setSaving(true)
|
|
30
|
-
let canSave = true
|
|
31
|
-
async function store() {
|
|
32
|
-
setSyncTitle(`Syncing 0/${types.length}`)
|
|
33
|
-
const transaction = client.transaction()
|
|
34
|
-
for (let i = 0; i < types.length; i++) {
|
|
35
|
-
if (!canSave) {
|
|
36
|
-
break
|
|
37
|
-
}
|
|
38
|
-
const type = types[i]
|
|
39
|
-
await transaction.createOrReplace(type as Required<typeof type>)
|
|
40
|
-
if (i > 0 && i % 50 === 0) {
|
|
41
|
-
await transaction.commit()
|
|
42
|
-
transaction.reset()
|
|
43
|
-
setSyncTitle(`Syncing ${i}/${types.length}`)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
await transaction.commit()
|
|
47
|
-
}
|
|
48
|
-
store()
|
|
49
|
-
.catch(console.error)
|
|
50
|
-
.finally(() => {
|
|
51
|
-
setSaving(false)
|
|
52
|
-
setSyncTitle(defaultTitle)
|
|
53
|
-
})
|
|
54
|
-
return () => {
|
|
55
|
-
canSave = false
|
|
56
|
-
setSaving(false)
|
|
57
|
-
setSyncTitle(defaultTitle)
|
|
58
|
-
}
|
|
59
|
-
}, [types, client, setSaving, setSyncTitle])
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<Card padding={4} overflow="auto" style={{height: 'calc(100vh - 81px)'}}>
|
|
63
|
-
<Stack space={4}>
|
|
64
|
-
<Box>
|
|
65
|
-
<Button
|
|
66
|
-
icon={saving ? <Spinner style={{marginTop: 5}} /> : SyncIcon}
|
|
67
|
-
text={syncTitle}
|
|
68
|
-
disabled={saving}
|
|
69
|
-
onClick={storeTypes}
|
|
70
|
-
/>
|
|
71
|
-
</Box>
|
|
72
|
-
<Flex gap={2}>
|
|
73
|
-
<Stack space={2}>
|
|
74
|
-
<Label>Studio schema</Label>
|
|
75
|
-
<ul>
|
|
76
|
-
{types.map((type) => (
|
|
77
|
-
<li key={type.name}>
|
|
78
|
-
<SchemaEntry schemaStub={type} />
|
|
79
|
-
</li>
|
|
80
|
-
))}
|
|
81
|
-
</ul>
|
|
82
|
-
</Stack>
|
|
83
|
-
|
|
84
|
-
<Stack space={2}>
|
|
85
|
-
<Label>Stored schema</Label>
|
|
86
|
-
<ul>
|
|
87
|
-
{(data ?? NO_DATA).map((type) => (
|
|
88
|
-
<li key={type.name}>
|
|
89
|
-
<SchemaEntry schemaStub={type} />
|
|
90
|
-
</li>
|
|
91
|
-
))}
|
|
92
|
-
</ul>
|
|
93
|
-
</Stack>
|
|
94
|
-
</Flex>
|
|
95
|
-
</Stack>
|
|
96
|
-
</Card>
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function SchemaEntry({schemaStub}: {schemaStub: SerializedSchemaType}) {
|
|
101
|
-
const out = useMemo(() => JSON.stringify(schemaStub, null, 2), [schemaStub])
|
|
102
|
-
return <pre>{out}</pre>
|
|
103
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {assistSerializedFieldTypeName, assistSerializedTypeName} from '../../types'
|
|
2
|
-
|
|
3
|
-
export const hiddenTypes = [
|
|
4
|
-
'any',
|
|
5
|
-
'array',
|
|
6
|
-
'block',
|
|
7
|
-
'boolean',
|
|
8
|
-
'crossDatasetReference',
|
|
9
|
-
'date',
|
|
10
|
-
'datetime',
|
|
11
|
-
'document',
|
|
12
|
-
'email',
|
|
13
|
-
'file',
|
|
14
|
-
'globalDocumentReference',
|
|
15
|
-
'image',
|
|
16
|
-
'number',
|
|
17
|
-
'object',
|
|
18
|
-
'reference',
|
|
19
|
-
'span',
|
|
20
|
-
'string',
|
|
21
|
-
'text',
|
|
22
|
-
'url',
|
|
23
|
-
'slug',
|
|
24
|
-
'geopoint',
|
|
25
|
-
'sanity.assetSourceData',
|
|
26
|
-
'sanity.imageAsset',
|
|
27
|
-
'sanity.fileAsset',
|
|
28
|
-
'sanity.imageCrop',
|
|
29
|
-
'sanity.imageHotspot',
|
|
30
|
-
'sanity.imageMetadata',
|
|
31
|
-
'sanity.imageDimensions',
|
|
32
|
-
'sanity.imagePalette',
|
|
33
|
-
'sanity.imagePaletteSwatch',
|
|
34
|
-
|
|
35
|
-
assistSerializedTypeName,
|
|
36
|
-
assistSerializedFieldTypeName,
|
|
37
|
-
'sanity-agent.job.document',
|
|
38
|
-
]
|