@sanity/assist 1.2.14 → 1.2.15-lang.10
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 +546 -24
- package/dist/index.cjs.mjs +1 -0
- package/dist/index.d.ts +253 -11
- package/dist/index.esm.js +2367 -393
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2361 -386
- package/dist/index.js.map +1 -1
- package/package.json +15 -14
- package/src/_lib/form/DocumentForm.tsx +3 -2
- package/src/_lib/form/constants.ts +1 -0
- package/src/assistDocument/AssistDocumentInput.tsx +24 -4
- package/src/assistDocument/RequestRunInstructionProvider.tsx +37 -21
- package/src/assistDocument/components/instruction/InstructionInput.tsx +5 -4
- package/src/assistDocument/components/instruction/InstructionOutputField.tsx +45 -0
- package/src/assistDocument/components/instruction/InstructionOutputInput.tsx +205 -0
- package/src/assistDocument/hooks/useStudioAssistDocument.ts +5 -32
- package/src/assistFormComponents/AssistField.tsx +11 -5
- package/src/assistFormComponents/AssistFormBlock.tsx +2 -3
- package/src/assistFormComponents/validation/listItem.tsx +2 -2
- package/src/assistInspector/AssistInspector.tsx +6 -0
- package/src/assistInspector/FieldAutocomplete.tsx +1 -0
- package/src/assistInspector/InstructionTaskHistoryButton.tsx +2 -3
- package/src/assistInspector/helpers.ts +9 -11
- package/src/assistLayout/AssistLayout.tsx +9 -9
- package/src/components/ImageContext.tsx +19 -9
- package/src/components/SafeValueInput.tsx +4 -1
- package/src/coverage/.tmp/coverage-0.json +1 -0
- package/src/coverage/base.css +224 -0
- package/src/coverage/block-navigation.js +87 -0
- package/src/coverage/clover.xml +8613 -0
- package/src/coverage/coverage-final.json +107 -0
- package/src/coverage/favicon.png +0 -0
- package/src/coverage/index.html +461 -0
- package/src/coverage/lcov-report/base.css +224 -0
- package/src/coverage/lcov-report/block-navigation.js +87 -0
- package/src/coverage/lcov-report/favicon.png +0 -0
- package/src/coverage/lcov-report/index.html +461 -0
- package/src/coverage/lcov-report/prettify.css +1 -0
- package/src/coverage/lcov-report/prettify.js +2 -0
- package/src/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/src/coverage/lcov-report/sorter.js +196 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectFromRegion.tsx.html +157 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectToRegion.tsx.html +151 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorRegion.tsx.html +154 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorsProvider.tsx.html +142 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorsStore.ts.html +451 -0
- package/src/coverage/lcov-report/src/_lib/connector/ConnectorsStoreContext.ts.html +97 -0
- package/src/coverage/lcov-report/src/_lib/connector/helpers.ts.html +100 -0
- package/src/coverage/lcov-report/src/_lib/connector/index.html +281 -0
- package/src/coverage/lcov-report/src/_lib/connector/index.ts.html +112 -0
- package/src/coverage/lcov-report/src/_lib/connector/mapConnectorToLine.ts.html +334 -0
- package/src/coverage/lcov-report/src/_lib/connector/types.ts.html +253 -0
- package/src/coverage/lcov-report/src/_lib/connector/useConnectorsStore.ts.html +124 -0
- package/src/coverage/lcov-report/src/_lib/connector/useRegionRects.ts.html +508 -0
- package/src/coverage/lcov-report/src/_lib/fixedListenQuery.ts.html +388 -0
- package/src/coverage/lcov-report/src/_lib/form/DocumentForm.tsx.html +676 -0
- package/src/coverage/lcov-report/src/_lib/form/helpers.ts.html +178 -0
- package/src/coverage/lcov-report/src/_lib/form/index.html +146 -0
- package/src/coverage/lcov-report/src/_lib/form/index.ts.html +88 -0
- package/src/coverage/lcov-report/src/_lib/index.html +161 -0
- package/src/coverage/lcov-report/src/_lib/randomKey.ts.html +172 -0
- package/src/coverage/lcov-report/src/_lib/useListeningQuery.ts.html +268 -0
- package/src/coverage/lcov-report/src/_lib/usePrevious.ts.html +112 -0
- package/src/coverage/lcov-report/src/assistConnectors/AssistConnectorsOverlay.tsx.html +481 -0
- package/src/coverage/lcov-report/src/assistConnectors/ConnectorPath.tsx.html +271 -0
- package/src/coverage/lcov-report/src/assistConnectors/draw/arrowPath.ts.html +112 -0
- package/src/coverage/lcov-report/src/assistConnectors/draw/connectorPath.ts.html +511 -0
- package/src/coverage/lcov-report/src/assistConnectors/draw/index.html +131 -0
- package/src/coverage/lcov-report/src/assistConnectors/index.html +146 -0
- package/src/coverage/lcov-report/src/assistConnectors/index.ts.html +88 -0
- package/src/coverage/lcov-report/src/assistDocument/AssistDocumentContext.tsx.html +178 -0
- package/src/coverage/lcov-report/src/assistDocument/AssistDocumentContextProvider.tsx.html +136 -0
- package/src/coverage/lcov-report/src/assistDocument/AssistDocumentInput.tsx.html +280 -0
- package/src/coverage/lcov-report/src/assistDocument/RequestRunInstructionProvider.tsx.html +283 -0
- package/src/coverage/lcov-report/src/assistDocument/components/AssistDocumentForm.tsx.html +775 -0
- package/src/coverage/lcov-report/src/assistDocument/components/FieldRefPreview.tsx.html +166 -0
- package/src/coverage/lcov-report/src/assistDocument/components/InstructionsArrayField.tsx.html +109 -0
- package/src/coverage/lcov-report/src/assistDocument/components/InstructionsArrayInput.tsx.html +163 -0
- package/src/coverage/lcov-report/src/assistDocument/components/SelectedFieldContext.tsx.html +115 -0
- package/src/coverage/lcov-report/src/assistDocument/components/generic/HiddenFieldTitle.tsx.html +100 -0
- package/src/coverage/lcov-report/src/assistDocument/components/generic/index.html +116 -0
- package/src/coverage/lcov-report/src/assistDocument/components/helpers.ts.html +148 -0
- package/src/coverage/lcov-report/src/assistDocument/components/index.html +191 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/BackToInstructionsLink.tsx.html +178 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/FieldRefInput.tsx.html +244 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/InstructionInput.tsx.html +349 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/InstructionOutputField.tsx.html +220 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/InstructionOutputInput.tsx.html +700 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/PromptInput.tsx.html +241 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/appearance/IconInput.tsx.html +223 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx.html +196 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/appearance/index.html +131 -0
- package/src/coverage/lcov-report/src/assistDocument/components/instruction/index.html +191 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/index.html +161 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useAssistDocumentContextValue.tsx.html +289 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useDocumentState.ts.html +103 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useInstructionToaster.tsx.html +307 -0
- package/src/coverage/lcov-report/src/assistDocument/hooks/useStudioAssistDocument.ts.html +379 -0
- package/src/coverage/lcov-report/src/assistDocument/index.html +176 -0
- package/src/coverage/lcov-report/src/assistDocument/index.ts.html +88 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistField.tsx.html +301 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistFormBlock.tsx.html +175 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistInlineFormBlock.tsx.html +124 -0
- package/src/coverage/lcov-report/src/assistFormComponents/AssistItem.tsx.html +145 -0
- package/src/coverage/lcov-report/src/assistFormComponents/index.html +161 -0
- package/src/coverage/lcov-report/src/assistFormComponents/validation/index.html +131 -0
- package/src/coverage/lcov-report/src/assistFormComponents/validation/listItem.tsx.html +274 -0
- package/src/coverage/lcov-report/src/assistFormComponents/validation/validationList.tsx.html +352 -0
- package/src/coverage/lcov-report/src/assistInspector/AssistInspector.tsx.html +1318 -0
- package/src/coverage/lcov-report/src/assistInspector/FieldAutocomplete.tsx.html +505 -0
- package/src/coverage/lcov-report/src/assistInspector/InstructionTaskHistoryButton.tsx.html +865 -0
- package/src/coverage/lcov-report/src/assistInspector/constants.ts.html +88 -0
- package/src/coverage/lcov-report/src/assistInspector/helpers.ts.html +724 -0
- package/src/coverage/lcov-report/src/assistInspector/index.html +191 -0
- package/src/coverage/lcov-report/src/assistInspector/index.ts.html +163 -0
- package/src/coverage/lcov-report/src/assistLayout/AiAssistanceConfigContext.tsx.html +331 -0
- package/src/coverage/lcov-report/src/assistLayout/AssistLayout.tsx.html +199 -0
- package/src/coverage/lcov-report/src/assistLayout/RunInstructionProvider.tsx.html +751 -0
- package/src/coverage/lcov-report/src/assistLayout/index.html +146 -0
- package/src/coverage/lcov-report/src/components/AssistFeatureBadge.tsx.html +112 -0
- package/src/coverage/lcov-report/src/components/FadeInContent.tsx.html +205 -0
- package/src/coverage/lcov-report/src/components/HideReferenceChangedBannerInput.tsx.html +160 -0
- package/src/coverage/lcov-report/src/components/ImageContext.tsx.html +229 -0
- package/src/coverage/lcov-report/src/components/SafeValueInput.tsx.html +313 -0
- package/src/coverage/lcov-report/src/components/TimeAgo.tsx.html +139 -0
- package/src/coverage/lcov-report/src/components/index.html +191 -0
- package/src/coverage/lcov-report/src/constants.ts.html +145 -0
- package/src/coverage/lcov-report/src/fieldActions/PrivateIcon.tsx.html +145 -0
- package/src/coverage/lcov-report/src/fieldActions/assistFieldActions.tsx.html +907 -0
- package/src/coverage/lcov-report/src/fieldActions/generateCaptionActions.tsx.html +259 -0
- package/src/coverage/lcov-report/src/fieldActions/generateImageActions.tsx.html +256 -0
- package/src/coverage/lcov-report/src/fieldActions/index.html +161 -0
- package/src/coverage/lcov-report/src/helpers/assistSupported.ts.html +226 -0
- package/src/coverage/lcov-report/src/helpers/conditionalMembers.ts.html +466 -0
- package/src/coverage/lcov-report/src/helpers/ids.ts.html +142 -0
- package/src/coverage/lcov-report/src/helpers/index.html +191 -0
- package/src/coverage/lcov-report/src/helpers/misc.ts.html +133 -0
- package/src/coverage/lcov-report/src/helpers/typeUtils.ts.html +208 -0
- package/src/coverage/lcov-report/src/helpers/useAssistSupported.ts.html +106 -0
- package/src/coverage/lcov-report/src/index.html +176 -0
- package/src/coverage/lcov-report/src/index.ts.html +112 -0
- package/src/coverage/lcov-report/src/onboarding/FieldActionsOnboarding.tsx.html +286 -0
- package/src/coverage/lcov-report/src/onboarding/FirstAssistedPathProvider.tsx.html +172 -0
- package/src/coverage/lcov-report/src/onboarding/InspectorOnboarding.tsx.html +223 -0
- package/src/coverage/lcov-report/src/onboarding/index.html +161 -0
- package/src/coverage/lcov-report/src/onboarding/onboardingStore.ts.html +184 -0
- package/src/coverage/lcov-report/src/plugin.tsx.html +427 -0
- package/src/coverage/lcov-report/src/presence/AiFieldPresence.tsx.html +163 -0
- package/src/coverage/lcov-report/src/presence/AssistAvatar.tsx.html +373 -0
- package/src/coverage/lcov-report/src/presence/AssistDocumentPresence.tsx.html +259 -0
- package/src/coverage/lcov-report/src/presence/index.html +161 -0
- package/src/coverage/lcov-report/src/presence/useAssistPresence.ts.html +268 -0
- package/src/coverage/lcov-report/src/schemas/assistDocumentSchema.tsx.html +1552 -0
- package/src/coverage/lcov-report/src/schemas/contextDocumentSchema.tsx.html +253 -0
- package/src/coverage/lcov-report/src/schemas/index.html +176 -0
- package/src/coverage/lcov-report/src/schemas/index.ts.html +277 -0
- package/src/coverage/lcov-report/src/schemas/serialize/SchemTypeTool.tsx.html +391 -0
- package/src/coverage/lcov-report/src/schemas/serialize/index.html +146 -0
- package/src/coverage/lcov-report/src/schemas/serialize/schemaUtils.ts.html +196 -0
- package/src/coverage/lcov-report/src/schemas/serialize/serializeSchema.ts.html +754 -0
- package/src/coverage/lcov-report/src/schemas/serializedSchemaTypeSchema.ts.html +262 -0
- package/src/coverage/lcov-report/src/schemas/typeDefExtensions.ts.html +397 -0
- package/src/coverage/lcov-report/src/translate/FieldTranslationProvider.tsx.html +1003 -0
- package/src/coverage/lcov-report/src/translate/getLanguageParams.ts.html +163 -0
- package/src/coverage/lcov-report/src/translate/index.html +191 -0
- package/src/coverage/lcov-report/src/translate/languageStore.ts.html +139 -0
- package/src/coverage/lcov-report/src/translate/paths.ts.html +577 -0
- package/src/coverage/lcov-report/src/translate/translateActions.tsx.html +637 -0
- package/src/coverage/lcov-report/src/translate/types.ts.html +565 -0
- package/src/coverage/lcov-report/src/types.ts.html +649 -0
- package/src/coverage/lcov-report/src/useApiClient.ts.html +1015 -0
- package/src/coverage/lcov.info +9519 -0
- package/src/coverage/prettify.css +1 -0
- package/src/coverage/prettify.js +2 -0
- package/src/coverage/sort-arrow-sprite.png +0 -0
- package/src/coverage/sorter.js +196 -0
- package/src/coverage/src/_lib/connector/ConnectFromRegion.tsx.html +157 -0
- package/src/coverage/src/_lib/connector/ConnectToRegion.tsx.html +151 -0
- package/src/coverage/src/_lib/connector/ConnectorRegion.tsx.html +154 -0
- package/src/coverage/src/_lib/connector/ConnectorsProvider.tsx.html +142 -0
- package/src/coverage/src/_lib/connector/ConnectorsStore.ts.html +451 -0
- package/src/coverage/src/_lib/connector/ConnectorsStoreContext.ts.html +97 -0
- package/src/coverage/src/_lib/connector/helpers.ts.html +100 -0
- package/src/coverage/src/_lib/connector/index.html +281 -0
- package/src/coverage/src/_lib/connector/index.ts.html +112 -0
- package/src/coverage/src/_lib/connector/mapConnectorToLine.ts.html +334 -0
- package/src/coverage/src/_lib/connector/types.ts.html +253 -0
- package/src/coverage/src/_lib/connector/useConnectorsStore.ts.html +124 -0
- package/src/coverage/src/_lib/connector/useRegionRects.ts.html +508 -0
- package/src/coverage/src/_lib/fixedListenQuery.ts.html +388 -0
- package/src/coverage/src/_lib/form/DocumentForm.tsx.html +676 -0
- package/src/coverage/src/_lib/form/helpers.ts.html +178 -0
- package/src/coverage/src/_lib/form/index.html +146 -0
- package/src/coverage/src/_lib/form/index.ts.html +88 -0
- package/src/coverage/src/_lib/index.html +161 -0
- package/src/coverage/src/_lib/randomKey.ts.html +172 -0
- package/src/coverage/src/_lib/useListeningQuery.ts.html +268 -0
- package/src/coverage/src/_lib/usePrevious.ts.html +112 -0
- package/src/coverage/src/assistConnectors/AssistConnectorsOverlay.tsx.html +481 -0
- package/src/coverage/src/assistConnectors/ConnectorPath.tsx.html +271 -0
- package/src/coverage/src/assistConnectors/draw/arrowPath.ts.html +112 -0
- package/src/coverage/src/assistConnectors/draw/connectorPath.ts.html +511 -0
- package/src/coverage/src/assistConnectors/draw/index.html +131 -0
- package/src/coverage/src/assistConnectors/index.html +146 -0
- package/src/coverage/src/assistConnectors/index.ts.html +88 -0
- package/src/coverage/src/assistDocument/AssistDocumentContext.tsx.html +178 -0
- package/src/coverage/src/assistDocument/AssistDocumentContextProvider.tsx.html +136 -0
- package/src/coverage/src/assistDocument/AssistDocumentInput.tsx.html +280 -0
- package/src/coverage/src/assistDocument/RequestRunInstructionProvider.tsx.html +283 -0
- package/src/coverage/src/assistDocument/components/AssistDocumentForm.tsx.html +775 -0
- package/src/coverage/src/assistDocument/components/FieldRefPreview.tsx.html +166 -0
- package/src/coverage/src/assistDocument/components/InstructionsArrayField.tsx.html +109 -0
- package/src/coverage/src/assistDocument/components/InstructionsArrayInput.tsx.html +163 -0
- package/src/coverage/src/assistDocument/components/SelectedFieldContext.tsx.html +115 -0
- package/src/coverage/src/assistDocument/components/generic/HiddenFieldTitle.tsx.html +100 -0
- package/src/coverage/src/assistDocument/components/generic/index.html +116 -0
- package/src/coverage/src/assistDocument/components/helpers.ts.html +148 -0
- package/src/coverage/src/assistDocument/components/index.html +191 -0
- package/src/coverage/src/assistDocument/components/instruction/BackToInstructionsLink.tsx.html +178 -0
- package/src/coverage/src/assistDocument/components/instruction/FieldRefInput.tsx.html +244 -0
- package/src/coverage/src/assistDocument/components/instruction/InstructionInput.tsx.html +349 -0
- package/src/coverage/src/assistDocument/components/instruction/InstructionOutputField.tsx.html +220 -0
- package/src/coverage/src/assistDocument/components/instruction/InstructionOutputInput.tsx.html +700 -0
- package/src/coverage/src/assistDocument/components/instruction/PromptInput.tsx.html +241 -0
- package/src/coverage/src/assistDocument/components/instruction/appearance/IconInput.tsx.html +223 -0
- package/src/coverage/src/assistDocument/components/instruction/appearance/InstructionVisibility.tsx.html +196 -0
- package/src/coverage/src/assistDocument/components/instruction/appearance/index.html +131 -0
- package/src/coverage/src/assistDocument/components/instruction/index.html +191 -0
- package/src/coverage/src/assistDocument/hooks/index.html +161 -0
- package/src/coverage/src/assistDocument/hooks/useAssistDocumentContextValue.tsx.html +289 -0
- package/src/coverage/src/assistDocument/hooks/useDocumentState.ts.html +103 -0
- package/src/coverage/src/assistDocument/hooks/useInstructionToaster.tsx.html +307 -0
- package/src/coverage/src/assistDocument/hooks/useStudioAssistDocument.ts.html +379 -0
- package/src/coverage/src/assistDocument/index.html +176 -0
- package/src/coverage/src/assistDocument/index.ts.html +88 -0
- package/src/coverage/src/assistFormComponents/AssistField.tsx.html +301 -0
- package/src/coverage/src/assistFormComponents/AssistFormBlock.tsx.html +175 -0
- package/src/coverage/src/assistFormComponents/AssistInlineFormBlock.tsx.html +124 -0
- package/src/coverage/src/assistFormComponents/AssistItem.tsx.html +145 -0
- package/src/coverage/src/assistFormComponents/index.html +161 -0
- package/src/coverage/src/assistFormComponents/validation/index.html +131 -0
- package/src/coverage/src/assistFormComponents/validation/listItem.tsx.html +274 -0
- package/src/coverage/src/assistFormComponents/validation/validationList.tsx.html +352 -0
- package/src/coverage/src/assistInspector/AssistInspector.tsx.html +1318 -0
- package/src/coverage/src/assistInspector/FieldAutocomplete.tsx.html +505 -0
- package/src/coverage/src/assistInspector/InstructionTaskHistoryButton.tsx.html +865 -0
- package/src/coverage/src/assistInspector/constants.ts.html +88 -0
- package/src/coverage/src/assistInspector/helpers.ts.html +724 -0
- package/src/coverage/src/assistInspector/index.html +191 -0
- package/src/coverage/src/assistInspector/index.ts.html +163 -0
- package/src/coverage/src/assistLayout/AiAssistanceConfigContext.tsx.html +331 -0
- package/src/coverage/src/assistLayout/AssistLayout.tsx.html +199 -0
- package/src/coverage/src/assistLayout/RunInstructionProvider.tsx.html +751 -0
- package/src/coverage/src/assistLayout/index.html +146 -0
- package/src/coverage/src/components/AssistFeatureBadge.tsx.html +112 -0
- package/src/coverage/src/components/FadeInContent.tsx.html +205 -0
- package/src/coverage/src/components/HideReferenceChangedBannerInput.tsx.html +160 -0
- package/src/coverage/src/components/ImageContext.tsx.html +229 -0
- package/src/coverage/src/components/SafeValueInput.tsx.html +313 -0
- package/src/coverage/src/components/TimeAgo.tsx.html +139 -0
- package/src/coverage/src/components/index.html +191 -0
- package/src/coverage/src/constants.ts.html +145 -0
- package/src/coverage/src/fieldActions/PrivateIcon.tsx.html +145 -0
- package/src/coverage/src/fieldActions/assistFieldActions.tsx.html +907 -0
- package/src/coverage/src/fieldActions/generateCaptionActions.tsx.html +259 -0
- package/src/coverage/src/fieldActions/generateImageActions.tsx.html +256 -0
- package/src/coverage/src/fieldActions/index.html +161 -0
- package/src/coverage/src/helpers/assistSupported.ts.html +226 -0
- package/src/coverage/src/helpers/conditionalMembers.ts.html +466 -0
- package/src/coverage/src/helpers/ids.ts.html +142 -0
- package/src/coverage/src/helpers/index.html +191 -0
- package/src/coverage/src/helpers/misc.ts.html +133 -0
- package/src/coverage/src/helpers/typeUtils.ts.html +208 -0
- package/src/coverage/src/helpers/useAssistSupported.ts.html +106 -0
- package/src/coverage/src/index.html +176 -0
- package/src/coverage/src/index.ts.html +112 -0
- package/src/coverage/src/onboarding/FieldActionsOnboarding.tsx.html +286 -0
- package/src/coverage/src/onboarding/FirstAssistedPathProvider.tsx.html +172 -0
- package/src/coverage/src/onboarding/InspectorOnboarding.tsx.html +223 -0
- package/src/coverage/src/onboarding/index.html +161 -0
- package/src/coverage/src/onboarding/onboardingStore.ts.html +184 -0
- package/src/coverage/src/plugin.tsx.html +427 -0
- package/src/coverage/src/presence/AiFieldPresence.tsx.html +163 -0
- package/src/coverage/src/presence/AssistAvatar.tsx.html +373 -0
- package/src/coverage/src/presence/AssistDocumentPresence.tsx.html +259 -0
- package/src/coverage/src/presence/index.html +161 -0
- package/src/coverage/src/presence/useAssistPresence.ts.html +268 -0
- package/src/coverage/src/schemas/assistDocumentSchema.tsx.html +1552 -0
- package/src/coverage/src/schemas/contextDocumentSchema.tsx.html +253 -0
- package/src/coverage/src/schemas/index.html +176 -0
- package/src/coverage/src/schemas/index.ts.html +277 -0
- package/src/coverage/src/schemas/serialize/SchemTypeTool.tsx.html +391 -0
- package/src/coverage/src/schemas/serialize/index.html +146 -0
- package/src/coverage/src/schemas/serialize/schemaUtils.ts.html +196 -0
- package/src/coverage/src/schemas/serialize/serializeSchema.ts.html +754 -0
- package/src/coverage/src/schemas/serializedSchemaTypeSchema.ts.html +262 -0
- package/src/coverage/src/schemas/typeDefExtensions.ts.html +397 -0
- package/src/coverage/src/translate/FieldTranslationProvider.tsx.html +1003 -0
- package/src/coverage/src/translate/getLanguageParams.ts.html +163 -0
- package/src/coverage/src/translate/index.html +191 -0
- package/src/coverage/src/translate/languageStore.ts.html +139 -0
- package/src/coverage/src/translate/paths.ts.html +577 -0
- package/src/coverage/src/translate/translateActions.tsx.html +637 -0
- package/src/coverage/src/translate/types.ts.html +565 -0
- package/src/coverage/src/types.ts.html +649 -0
- package/src/coverage/src/useApiClient.ts.html +1015 -0
- package/src/fieldActions/assistFieldActions.tsx +42 -13
- package/src/fieldActions/generateCaptionActions.tsx +2 -2
- package/src/fieldActions/generateImageActions.tsx +57 -0
- package/src/helpers/assistSupported.ts +10 -16
- package/src/helpers/conditionalMembers.test.ts +200 -0
- package/src/helpers/conditionalMembers.ts +127 -0
- package/src/helpers/typeUtils.ts +19 -5
- package/src/index.ts +3 -0
- package/src/node_modules/.vitest/deps/_metadata.json +8 -0
- package/src/node_modules/.vitest/deps/package.json +3 -0
- package/src/node_modules/.vitest/results.json +1 -0
- package/src/plugin.tsx +14 -5
- package/src/presence/AssistAvatar.tsx +1 -1
- package/src/schemas/assistDocumentSchema.tsx +40 -1
- package/src/schemas/serialize/serializeSchema.test.ts +239 -8
- package/src/schemas/serialize/serializeSchema.ts +77 -10
- package/src/schemas/typeDefExtensions.ts +89 -5
- package/src/translate/FieldTranslationProvider.tsx +306 -0
- package/src/translate/getLanguageParams.ts +26 -0
- package/src/translate/languageStore.ts +18 -0
- package/src/translate/paths.test.ts +133 -0
- package/src/translate/paths.ts +175 -0
- package/src/translate/translateActions.tsx +186 -0
- package/src/translate/types.ts +160 -0
- package/src/types.ts +33 -12
- package/src/useApiClient.ts +130 -2
- package/src/assistLayout/AlphaMigration.tsx +0 -310
- package/src/legacy-types.ts +0 -72
package/src/plugin.tsx
CHANGED
|
@@ -15,12 +15,11 @@ import {createAssistDocumentPresence} from './presence/AssistDocumentPresence'
|
|
|
15
15
|
import {isSchemaAssistEnabled} from './helpers/assistSupported'
|
|
16
16
|
import {isImage} from './helpers/typeUtils'
|
|
17
17
|
import {ImageContextProvider} from './components/ImageContext'
|
|
18
|
+
import {TranslationConfig} from './translate/types'
|
|
19
|
+
import {assistDocumentTypeName} from './types'
|
|
18
20
|
|
|
19
21
|
export interface AssistPluginConfig {
|
|
20
|
-
|
|
21
|
-
* Set this to false to disable model migration from the alpha version of this plugin
|
|
22
|
-
*/
|
|
23
|
-
alphaMigration?: boolean
|
|
22
|
+
translate?: TranslationConfig
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* @internal
|
|
@@ -36,16 +35,23 @@ export const assist = definePlugin<AssistPluginConfig | void>((config) => {
|
|
|
36
35
|
schema: {
|
|
37
36
|
types: schemaTypes,
|
|
38
37
|
},
|
|
38
|
+
i18n: {
|
|
39
|
+
bundles: [{}],
|
|
40
|
+
},
|
|
39
41
|
|
|
40
42
|
document: {
|
|
41
43
|
inspectors: (prev, context) => {
|
|
42
|
-
const
|
|
44
|
+
const documentType = context.documentType
|
|
45
|
+
const docSchema = context.schema.get(documentType)
|
|
43
46
|
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
44
47
|
return [...prev, assistInspector]
|
|
45
48
|
}
|
|
46
49
|
return prev
|
|
47
50
|
},
|
|
48
51
|
unstable_fieldActions: (prev, {documentType, schema}) => {
|
|
52
|
+
if (documentType === assistDocumentTypeName) {
|
|
53
|
+
return []
|
|
54
|
+
}
|
|
49
55
|
const docSchema = schema.get(documentType)
|
|
50
56
|
if (docSchema && isSchemaAssistEnabled(docSchema)) {
|
|
51
57
|
return [...prev, assistFieldActions]
|
|
@@ -53,6 +59,9 @@ export const assist = definePlugin<AssistPluginConfig | void>((config) => {
|
|
|
53
59
|
return prev
|
|
54
60
|
},
|
|
55
61
|
unstable_languageFilter: (prev, {documentId, schema, schemaType}) => {
|
|
62
|
+
if (schemaType === assistDocumentTypeName) {
|
|
63
|
+
return []
|
|
64
|
+
}
|
|
56
65
|
const docSchema = schema.get(schemaType)
|
|
57
66
|
if (docSchema && isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema)) {
|
|
58
67
|
return [...prev, createAssistDocumentPresence(documentId, docSchema)]
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
instructionContextTypeName,
|
|
19
19
|
instructionTaskTypeName,
|
|
20
20
|
instructionTypeName,
|
|
21
|
+
outputFieldTypeName,
|
|
22
|
+
outputTypeTypeName,
|
|
21
23
|
promptTypeName,
|
|
22
24
|
userInputTypeName,
|
|
23
25
|
} from '../types'
|
|
@@ -37,11 +39,13 @@ import {PromptInput} from '../assistDocument/components/instruction/PromptInput'
|
|
|
37
39
|
import {instructionGuideUrl} from '../constants'
|
|
38
40
|
import {InstructionsArrayField} from '../assistDocument/components/InstructionsArrayField'
|
|
39
41
|
import {getFieldRefsWithDocument} from '../assistInspector/helpers'
|
|
42
|
+
import {InstructionOutputField} from '../assistDocument/components/instruction/InstructionOutputField'
|
|
43
|
+
import {InstructionOutputInput} from '../assistDocument/components/instruction/InstructionOutputInput'
|
|
40
44
|
|
|
41
45
|
export const fieldReference = defineType({
|
|
42
46
|
type: 'object',
|
|
43
47
|
name: fieldReferenceTypeName,
|
|
44
|
-
title: '
|
|
48
|
+
title: 'Field',
|
|
45
49
|
icon: ThListIcon,
|
|
46
50
|
|
|
47
51
|
fields: [
|
|
@@ -329,6 +333,41 @@ export const instruction = defineType({
|
|
|
329
333
|
return context.currentUser?.id ?? ''
|
|
330
334
|
},
|
|
331
335
|
}),
|
|
336
|
+
defineField({
|
|
337
|
+
type: 'array',
|
|
338
|
+
name: 'output',
|
|
339
|
+
title: 'Output filter',
|
|
340
|
+
components: {
|
|
341
|
+
input: InstructionOutputInput,
|
|
342
|
+
field: InstructionOutputField,
|
|
343
|
+
},
|
|
344
|
+
of: [
|
|
345
|
+
defineArrayMember({
|
|
346
|
+
type: 'object' as const,
|
|
347
|
+
name: outputFieldTypeName,
|
|
348
|
+
title: 'Output field',
|
|
349
|
+
fields: [
|
|
350
|
+
{
|
|
351
|
+
type: 'string',
|
|
352
|
+
name: 'path',
|
|
353
|
+
title: 'Path',
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
}),
|
|
357
|
+
defineArrayMember({
|
|
358
|
+
type: 'object' as const,
|
|
359
|
+
name: outputTypeTypeName,
|
|
360
|
+
title: 'Output type',
|
|
361
|
+
fields: [
|
|
362
|
+
{
|
|
363
|
+
type: 'string',
|
|
364
|
+
name: 'type',
|
|
365
|
+
title: 'Type',
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
}),
|
|
369
|
+
],
|
|
370
|
+
}),
|
|
332
371
|
],
|
|
333
372
|
})
|
|
334
373
|
|
|
@@ -32,7 +32,7 @@ describe('serializeSchema', () => {
|
|
|
32
32
|
name: 'article',
|
|
33
33
|
fields: [{type: 'string', name: 'title'}],
|
|
34
34
|
options: {
|
|
35
|
-
|
|
35
|
+
aiAssist: {
|
|
36
36
|
exclude: true,
|
|
37
37
|
},
|
|
38
38
|
},
|
|
@@ -123,7 +123,7 @@ describe('serializeSchema', () => {
|
|
|
123
123
|
})
|
|
124
124
|
|
|
125
125
|
test('should not serialize excluded fields or types or types with every member excluded', () => {
|
|
126
|
-
const options: AssistOptions = {
|
|
126
|
+
const options: AssistOptions = {aiAssist: {exclude: true}}
|
|
127
127
|
|
|
128
128
|
const schema = Schema.compile({
|
|
129
129
|
name: 'test',
|
|
@@ -138,14 +138,14 @@ describe('serializeSchema', () => {
|
|
|
138
138
|
name: 'excludedObject',
|
|
139
139
|
// all fields excluded should exclude field
|
|
140
140
|
fields: [{type: 'string', name: 'title', options}],
|
|
141
|
-
options: {
|
|
141
|
+
options: {aiAssist: {exclude: true}},
|
|
142
142
|
}),
|
|
143
143
|
defineField({
|
|
144
144
|
type: 'array',
|
|
145
145
|
name: 'excludedArray',
|
|
146
146
|
// all items excluded should exclude field
|
|
147
147
|
of: [{type: 'object', name: 'remove', options}, {type: 'excluded'}],
|
|
148
|
-
options: {
|
|
148
|
+
options: {aiAssist: {exclude: true}},
|
|
149
149
|
}),
|
|
150
150
|
//image without extra fields should be excluded
|
|
151
151
|
defineField({type: 'image', name: 'image'}),
|
|
@@ -169,7 +169,7 @@ describe('serializeSchema', () => {
|
|
|
169
169
|
type: 'object',
|
|
170
170
|
name: 'excluded',
|
|
171
171
|
fields: [{type: 'string', name: 'title', options}],
|
|
172
|
-
options: {
|
|
172
|
+
options: {aiAssist: {exclude: true}},
|
|
173
173
|
}),
|
|
174
174
|
...mockStudioTypes,
|
|
175
175
|
],
|
|
@@ -484,7 +484,7 @@ describe('serializeSchema', () => {
|
|
|
484
484
|
])
|
|
485
485
|
})
|
|
486
486
|
|
|
487
|
-
test('should
|
|
487
|
+
test('should annotate truthy readonly', () => {
|
|
488
488
|
const schema = Schema.compile({
|
|
489
489
|
name: 'test',
|
|
490
490
|
types: [
|
|
@@ -492,7 +492,7 @@ describe('serializeSchema', () => {
|
|
|
492
492
|
type: 'document',
|
|
493
493
|
name: 'article',
|
|
494
494
|
fields: [
|
|
495
|
-
{type: 'string', name: 'title',
|
|
495
|
+
{type: 'string', name: 'title', readOnly: () => true},
|
|
496
496
|
{type: 'some', name: 'some'},
|
|
497
497
|
],
|
|
498
498
|
},
|
|
@@ -507,6 +507,237 @@ describe('serializeSchema', () => {
|
|
|
507
507
|
|
|
508
508
|
const serializedTypes = serializeSchema(schema, {leanFormat: true})
|
|
509
509
|
|
|
510
|
-
expect(serializedTypes).toEqual([
|
|
510
|
+
expect(serializedTypes).toEqual([
|
|
511
|
+
{
|
|
512
|
+
name: 'article',
|
|
513
|
+
title: 'Article',
|
|
514
|
+
type: 'document',
|
|
515
|
+
fields: [
|
|
516
|
+
{name: 'title', readOnly: 'function', title: 'Title', type: 'string'},
|
|
517
|
+
{name: 'some', readOnly: true, title: 'Some', type: 'some'},
|
|
518
|
+
],
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: 'some',
|
|
522
|
+
readOnly: true,
|
|
523
|
+
title: 'Some',
|
|
524
|
+
type: 'object',
|
|
525
|
+
fields: [{name: 'title', title: 'Title', type: 'string'}],
|
|
526
|
+
},
|
|
527
|
+
])
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
test('should annotate truthy hidden', () => {
|
|
531
|
+
const schema = Schema.compile({
|
|
532
|
+
name: 'test',
|
|
533
|
+
types: [
|
|
534
|
+
{
|
|
535
|
+
type: 'document',
|
|
536
|
+
name: 'article',
|
|
537
|
+
fields: [
|
|
538
|
+
{type: 'string', name: 'title', hidden: true},
|
|
539
|
+
{type: 'some', name: 'some'},
|
|
540
|
+
],
|
|
541
|
+
},
|
|
542
|
+
defineType({
|
|
543
|
+
type: 'object',
|
|
544
|
+
name: 'some',
|
|
545
|
+
hidden: () => true,
|
|
546
|
+
fields: [{type: 'string', name: 'title'}],
|
|
547
|
+
}),
|
|
548
|
+
],
|
|
549
|
+
})
|
|
550
|
+
|
|
551
|
+
const serializedTypes = serializeSchema(schema, {leanFormat: true})
|
|
552
|
+
|
|
553
|
+
expect(serializedTypes).toEqual([
|
|
554
|
+
{
|
|
555
|
+
name: 'article',
|
|
556
|
+
title: 'Article',
|
|
557
|
+
type: 'document',
|
|
558
|
+
fields: [
|
|
559
|
+
{hidden: true, name: 'title', title: 'Title', type: 'string'},
|
|
560
|
+
{hidden: 'function', name: 'some', title: 'Some', type: 'some'},
|
|
561
|
+
],
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
hidden: 'function',
|
|
565
|
+
name: 'some',
|
|
566
|
+
title: 'Some',
|
|
567
|
+
type: 'object',
|
|
568
|
+
fields: [{name: 'title', title: 'Title', type: 'string'}],
|
|
569
|
+
},
|
|
570
|
+
])
|
|
571
|
+
})
|
|
572
|
+
|
|
573
|
+
test('should serialize annotations', () => {
|
|
574
|
+
const schema = Schema.compile({
|
|
575
|
+
name: 'test',
|
|
576
|
+
types: [
|
|
577
|
+
defineType({
|
|
578
|
+
type: 'object',
|
|
579
|
+
name: 'annotation',
|
|
580
|
+
fields: [defineField({type: 'string', name: 'fact', title: 'Fact'})],
|
|
581
|
+
}),
|
|
582
|
+
defineType({
|
|
583
|
+
name: 'blockAlias',
|
|
584
|
+
type: 'block',
|
|
585
|
+
marks: {annotations: [{type: 'annotation'}]},
|
|
586
|
+
}),
|
|
587
|
+
defineType({
|
|
588
|
+
type: 'document',
|
|
589
|
+
name: 'article',
|
|
590
|
+
fields: [
|
|
591
|
+
{
|
|
592
|
+
type: 'array',
|
|
593
|
+
name: 'inlinePte',
|
|
594
|
+
of: [
|
|
595
|
+
defineArrayMember({
|
|
596
|
+
type: 'block',
|
|
597
|
+
marks: {
|
|
598
|
+
annotations: [
|
|
599
|
+
defineArrayMember({
|
|
600
|
+
type: 'object',
|
|
601
|
+
name: 'inline-annotation',
|
|
602
|
+
fields: [defineField({type: 'string', name: 'fact', title: 'Fact'})],
|
|
603
|
+
}),
|
|
604
|
+
],
|
|
605
|
+
},
|
|
606
|
+
}),
|
|
607
|
+
],
|
|
608
|
+
},
|
|
609
|
+
{type: 'array', name: 'pte', of: [{type: 'blockAlias'}]},
|
|
610
|
+
],
|
|
611
|
+
}),
|
|
612
|
+
],
|
|
613
|
+
})
|
|
614
|
+
|
|
615
|
+
const serializedTypes = serializeSchema(schema, {leanFormat: true})
|
|
616
|
+
|
|
617
|
+
expect(serializedTypes).toEqual([
|
|
618
|
+
{
|
|
619
|
+
name: 'annotation',
|
|
620
|
+
title: 'Annotation',
|
|
621
|
+
type: 'object',
|
|
622
|
+
fields: [{name: 'fact', title: 'Fact', type: 'string'}],
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
name: 'article',
|
|
626
|
+
title: 'Article',
|
|
627
|
+
type: 'document',
|
|
628
|
+
fields: [
|
|
629
|
+
{
|
|
630
|
+
name: 'inlinePte',
|
|
631
|
+
title: 'Inline Pte',
|
|
632
|
+
type: 'array',
|
|
633
|
+
of: [
|
|
634
|
+
{
|
|
635
|
+
name: 'block',
|
|
636
|
+
title: 'Block',
|
|
637
|
+
type: 'block',
|
|
638
|
+
inlineOf: [],
|
|
639
|
+
annotations: [
|
|
640
|
+
{
|
|
641
|
+
name: 'inline-annotation',
|
|
642
|
+
title: 'Inline Annotation',
|
|
643
|
+
type: 'object',
|
|
644
|
+
fields: [{name: 'fact', title: 'Fact', type: 'string'}],
|
|
645
|
+
},
|
|
646
|
+
],
|
|
647
|
+
},
|
|
648
|
+
],
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: 'pte',
|
|
652
|
+
of: [{name: 'blockAlias', title: 'Block', type: 'blockAlias'}],
|
|
653
|
+
title: 'Pte',
|
|
654
|
+
type: 'array',
|
|
655
|
+
},
|
|
656
|
+
],
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
name: 'blockAlias',
|
|
660
|
+
title: 'Block',
|
|
661
|
+
type: 'block',
|
|
662
|
+
annotations: [{name: 'annotation', title: 'Annotation', type: 'annotation'}],
|
|
663
|
+
inlineOf: [],
|
|
664
|
+
},
|
|
665
|
+
])
|
|
666
|
+
})
|
|
667
|
+
|
|
668
|
+
test('should serialize inline block types', () => {
|
|
669
|
+
const schema = Schema.compile({
|
|
670
|
+
name: 'test',
|
|
671
|
+
types: [
|
|
672
|
+
defineType({
|
|
673
|
+
type: 'object',
|
|
674
|
+
name: 'inline-block',
|
|
675
|
+
fields: [
|
|
676
|
+
defineField({type: 'string', name: 'fact', title: 'Fact'}),
|
|
677
|
+
defineField({type: 'blockAlias', name: 'recurse', title: 'Recursive'}),
|
|
678
|
+
],
|
|
679
|
+
}),
|
|
680
|
+
defineType({
|
|
681
|
+
name: 'blockAlias',
|
|
682
|
+
type: 'block',
|
|
683
|
+
of: [{type: 'inline-block'}],
|
|
684
|
+
}),
|
|
685
|
+
defineType({
|
|
686
|
+
type: 'document',
|
|
687
|
+
name: 'article',
|
|
688
|
+
fields: [{type: 'array', name: 'pte', of: [{type: 'blockAlias'}]}],
|
|
689
|
+
}),
|
|
690
|
+
],
|
|
691
|
+
})
|
|
692
|
+
|
|
693
|
+
const serializedTypes = serializeSchema(schema, {leanFormat: true})
|
|
694
|
+
|
|
695
|
+
expect(serializedTypes).toEqual([
|
|
696
|
+
{
|
|
697
|
+
name: 'article',
|
|
698
|
+
title: 'Article',
|
|
699
|
+
type: 'document',
|
|
700
|
+
fields: [
|
|
701
|
+
{
|
|
702
|
+
name: 'pte',
|
|
703
|
+
of: [
|
|
704
|
+
{
|
|
705
|
+
name: 'blockAlias',
|
|
706
|
+
title: 'Block',
|
|
707
|
+
type: 'blockAlias',
|
|
708
|
+
},
|
|
709
|
+
],
|
|
710
|
+
title: 'Pte',
|
|
711
|
+
type: 'array',
|
|
712
|
+
},
|
|
713
|
+
],
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
name: 'blockAlias',
|
|
717
|
+
title: 'Block',
|
|
718
|
+
type: 'block',
|
|
719
|
+
annotations: [],
|
|
720
|
+
inlineOf: [
|
|
721
|
+
{
|
|
722
|
+
name: 'inline-block',
|
|
723
|
+
title: 'Inline Block',
|
|
724
|
+
type: 'inline-block',
|
|
725
|
+
},
|
|
726
|
+
],
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: 'inline-block',
|
|
730
|
+
title: 'Inline Block',
|
|
731
|
+
type: 'object',
|
|
732
|
+
fields: [
|
|
733
|
+
{name: 'fact', title: 'Fact', type: 'string'},
|
|
734
|
+
{
|
|
735
|
+
name: 'recurse',
|
|
736
|
+
title: 'Recursive',
|
|
737
|
+
type: 'blockAlias',
|
|
738
|
+
},
|
|
739
|
+
],
|
|
740
|
+
},
|
|
741
|
+
])
|
|
511
742
|
})
|
|
512
743
|
})
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ArraySchemaType,
|
|
3
3
|
ImageOptions,
|
|
4
|
+
isArraySchemaType,
|
|
4
5
|
ObjectSchemaType,
|
|
6
|
+
ReferenceOptions,
|
|
5
7
|
ReferenceSchemaType,
|
|
6
8
|
Schema,
|
|
7
9
|
SchemaType,
|
|
8
10
|
typed,
|
|
9
11
|
} from 'sanity'
|
|
10
12
|
import {
|
|
13
|
+
assistSchemaIdPrefix,
|
|
11
14
|
assistSerializedFieldTypeName,
|
|
12
15
|
assistSerializedTypeName,
|
|
13
16
|
SerializedSchemaMember,
|
|
14
17
|
SerializedSchemaType,
|
|
15
|
-
assistSchemaIdPrefix,
|
|
16
18
|
} from '../../types'
|
|
17
19
|
import {hiddenTypes} from './schemaUtils'
|
|
18
20
|
import {isAssistSupported} from '../../helpers/assistSupported'
|
|
21
|
+
import {isType} from '../../helpers/typeUtils'
|
|
19
22
|
|
|
20
23
|
interface Options {
|
|
21
24
|
leanFormat?: boolean
|
|
@@ -31,7 +34,6 @@ export function serializeSchema(schema: Schema, options?: Options): SerializedSc
|
|
|
31
34
|
.filter((t): t is SchemaType => !!t)
|
|
32
35
|
// because a field can override exclude at the type level, we have to also serialize excluded types
|
|
33
36
|
// so don't do this: .filter((t) => isAssistSupported(t))
|
|
34
|
-
.filter((t) => !t.hidden && !t.readOnly)
|
|
35
37
|
.map((t) => getSchemaStub(t, schema, options))
|
|
36
38
|
.filter((t) => {
|
|
37
39
|
if ('to' in t && t.to && !t.to.length) {
|
|
@@ -78,13 +80,12 @@ function getBaseFields(
|
|
|
78
80
|
typeName: string,
|
|
79
81
|
options: Options | undefined
|
|
80
82
|
) {
|
|
81
|
-
const
|
|
83
|
+
const schemaOptions: SerializedSchemaType['options'] = removeUndef({
|
|
84
|
+
imagePromptField: (type.options as ImageOptions)?.aiAssist?.imageInstructionField,
|
|
85
|
+
embeddingsIndex: (type.options as ReferenceOptions)?.aiAssist?.embeddingsIndex,
|
|
86
|
+
})
|
|
82
87
|
return removeUndef({
|
|
83
|
-
options:
|
|
84
|
-
? {
|
|
85
|
-
imagePromptField: imagePromptField,
|
|
86
|
-
}
|
|
87
|
-
: undefined,
|
|
88
|
+
options: Object.keys(schemaOptions).length ? schemaOptions : undefined,
|
|
88
89
|
values: Array.isArray(type?.options?.list)
|
|
89
90
|
? type?.options?.list.map((v: string | {value: string; title: string}) =>
|
|
90
91
|
typeof v === 'string' ? v : v.value ?? `${v.title}`
|
|
@@ -99,6 +100,22 @@ function getBaseFields(
|
|
|
99
100
|
'fields' in type && inlineTypes.includes(typeName)
|
|
100
101
|
? serializeFields(schema, type, options)
|
|
101
102
|
: undefined,
|
|
103
|
+
annotations:
|
|
104
|
+
typeName === 'block' && 'fields' in type
|
|
105
|
+
? serializeAnnotations(type, schema, options)
|
|
106
|
+
: undefined,
|
|
107
|
+
inlineOf:
|
|
108
|
+
typeName === 'block' && 'fields' in type
|
|
109
|
+
? serializeInlineOf(type, schema, options)
|
|
110
|
+
: undefined,
|
|
111
|
+
hidden:
|
|
112
|
+
typeof type.hidden === 'function' ? ('function' as const) : type.hidden ? true : undefined,
|
|
113
|
+
readOnly:
|
|
114
|
+
typeof type.readOnly === 'function'
|
|
115
|
+
? ('function' as const)
|
|
116
|
+
: type.readOnly
|
|
117
|
+
? true
|
|
118
|
+
: undefined,
|
|
102
119
|
})
|
|
103
120
|
}
|
|
104
121
|
|
|
@@ -107,10 +124,27 @@ function serializeFields(
|
|
|
107
124
|
schemaType: ObjectSchemaType,
|
|
108
125
|
options: Options | undefined
|
|
109
126
|
) {
|
|
110
|
-
|
|
127
|
+
const fields = schemaType.fieldsets
|
|
128
|
+
? schemaType.fieldsets.flatMap((fs) =>
|
|
129
|
+
fs.single
|
|
130
|
+
? fs.field
|
|
131
|
+
: fs.fields.map((f) => ({
|
|
132
|
+
...f,
|
|
133
|
+
type: {
|
|
134
|
+
...f.type,
|
|
135
|
+
// if fieldset is (conditionally) hidden, the field must be considered the same way
|
|
136
|
+
// ie, if the field does not show up in conditionalMembers, it is hidden
|
|
137
|
+
// regardless of weather or not it is the field function or the fieldset function that hides it
|
|
138
|
+
hidden:
|
|
139
|
+
typeof fs.hidden === 'function' ? fs.hidden : fs.hidden ? true : f.type.hidden,
|
|
140
|
+
},
|
|
141
|
+
}))
|
|
142
|
+
)
|
|
143
|
+
: schemaType.fields
|
|
144
|
+
|
|
145
|
+
return fields
|
|
111
146
|
.filter((f) => !['sanity.imageHotspot', 'sanity.imageCrop'].includes(f.type?.name ?? ''))
|
|
112
147
|
.filter((f) => isAssistSupported(f.type))
|
|
113
|
-
.filter((f) => !f.type.hidden && !f.type.readOnly)
|
|
114
148
|
.map((field) => serializeMember(schema, field.type, field.name, options))
|
|
115
149
|
}
|
|
116
150
|
|
|
@@ -131,6 +165,39 @@ function serializeMember(
|
|
|
131
165
|
})
|
|
132
166
|
}
|
|
133
167
|
|
|
168
|
+
function serializeInlineOf(
|
|
169
|
+
blockSchemaType: ObjectSchemaType,
|
|
170
|
+
schema: Schema,
|
|
171
|
+
options: Options | undefined
|
|
172
|
+
): SerializedSchemaMember[] | undefined {
|
|
173
|
+
const childrenField = blockSchemaType.fields.find((f) => f.name === 'children')
|
|
174
|
+
const childrenType = childrenField?.type
|
|
175
|
+
if (!childrenType || !isArraySchemaType(childrenType)) {
|
|
176
|
+
return undefined
|
|
177
|
+
}
|
|
178
|
+
return arrayOf(
|
|
179
|
+
{
|
|
180
|
+
...childrenType,
|
|
181
|
+
of: childrenType.of.filter((t) => !isType(t, 'span')),
|
|
182
|
+
},
|
|
183
|
+
schema,
|
|
184
|
+
options
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function serializeAnnotations(
|
|
189
|
+
blockSchemaType: ObjectSchemaType,
|
|
190
|
+
schema: Schema,
|
|
191
|
+
options: Options | undefined
|
|
192
|
+
): SerializedSchemaMember[] | undefined {
|
|
193
|
+
const markDefs = blockSchemaType.fields.find((f) => f.name === 'markDefs')
|
|
194
|
+
const marksType = markDefs?.type
|
|
195
|
+
if (!marksType || !isArraySchemaType(marksType)) {
|
|
196
|
+
return undefined
|
|
197
|
+
}
|
|
198
|
+
return arrayOf(marksType, schema, options)
|
|
199
|
+
}
|
|
200
|
+
|
|
134
201
|
function arrayOf(
|
|
135
202
|
arrayType: ArraySchemaType,
|
|
136
203
|
schema: Schema,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/* eslint-disable no-unused-vars */
|
|
2
2
|
export interface AssistOptions {
|
|
3
|
-
|
|
3
|
+
aiAssist?: {
|
|
4
4
|
/** Set to true to disable assistance for this field or type */
|
|
5
5
|
exclude?: boolean
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Set to true to add translation field-action to the field.
|
|
9
|
+
* Only has an effect in document types configured for document or field level translations.
|
|
10
|
+
*/
|
|
11
|
+
translateAction?: boolean
|
|
6
12
|
}
|
|
7
13
|
}
|
|
8
14
|
|
|
@@ -16,13 +22,91 @@ declare module 'sanity' {
|
|
|
16
22
|
interface DocumentOptions extends AssistOptions {}
|
|
17
23
|
interface FileOptions extends AssistOptions {}
|
|
18
24
|
interface GeopointOptions extends AssistOptions {}
|
|
19
|
-
interface ImageOptions
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
interface ImageOptions {
|
|
26
|
+
aiAssist?: AssistOptions['aiAssist'] & {
|
|
27
|
+
/**
|
|
28
|
+
* When set, an image will be created whenever the `imageInstructionField` is written to by
|
|
29
|
+
* an AI Assist instruction.
|
|
30
|
+
*
|
|
31
|
+
* The value output by AI Assist will be use as an image prompt for an generative image AI.
|
|
32
|
+
*
|
|
33
|
+
* This means that instructions directly for the field or instructions that visit the field when running,
|
|
34
|
+
* will result in the image being changed.
|
|
35
|
+
*
|
|
36
|
+
* `imageInstructionField` must be a child-path relative to the image field, ie:
|
|
37
|
+
* * field
|
|
38
|
+
* * path.to.field
|
|
39
|
+
*
|
|
40
|
+
* ### Example
|
|
41
|
+
* ```ts
|
|
42
|
+
* defineType({
|
|
43
|
+
* type: 'image',
|
|
44
|
+
* name: 'articleImage',
|
|
45
|
+
* fields: [
|
|
46
|
+
* defineField({
|
|
47
|
+
* type: 'text',
|
|
48
|
+
* name: 'imagePrompt',
|
|
49
|
+
* title: 'Image prompt',
|
|
50
|
+
* rows: 2,
|
|
51
|
+
* }),
|
|
52
|
+
* ],
|
|
53
|
+
* options: {
|
|
54
|
+
* aiAssist: {
|
|
55
|
+
* imageInstructionField: 'imagePrompt',
|
|
56
|
+
* }
|
|
57
|
+
* },
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
imageInstructionField?: string
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* When set, an image description will be automatically created for the image.
|
|
65
|
+
*
|
|
66
|
+
* `imageDescriptionField` must be a child-path relative to the image field, ie:
|
|
67
|
+
* * field
|
|
68
|
+
* * path.to.field
|
|
69
|
+
*
|
|
70
|
+
* Whenever the image asset for the field is changed in the Studio,
|
|
71
|
+
* an image description is generated and set into the `imageDescriptionField`.
|
|
72
|
+
*
|
|
73
|
+
* ### Example
|
|
74
|
+
* ```ts
|
|
75
|
+
* defineType({
|
|
76
|
+
* type: 'image',
|
|
77
|
+
* name: 'articleImage',
|
|
78
|
+
* fields: [
|
|
79
|
+
* defineField({
|
|
80
|
+
* type: 'string',
|
|
81
|
+
* name: 'altText',
|
|
82
|
+
* title: 'Alt text',
|
|
83
|
+
* }),
|
|
84
|
+
* ],
|
|
85
|
+
* options: {
|
|
86
|
+
* aiAssist: {
|
|
87
|
+
* imageDescriptionField: 'altText',
|
|
88
|
+
* }
|
|
89
|
+
* },
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
imageDescriptionField?: string
|
|
94
|
+
}
|
|
22
95
|
}
|
|
23
96
|
interface NumberOptions extends AssistOptions {}
|
|
24
97
|
interface ObjectOptions extends AssistOptions {}
|
|
25
|
-
interface ReferenceBaseOptions
|
|
98
|
+
interface ReferenceBaseOptions {
|
|
99
|
+
aiAssist?: {
|
|
100
|
+
/** Set to true to disable assistance for this field or type */
|
|
101
|
+
exclude?: boolean
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* When set, the reference field will allow instructions to be added to it.
|
|
105
|
+
* Should be the name of the embeddings-index where assist will look for contextually relevant documents
|
|
106
|
+
* */
|
|
107
|
+
embeddingsIndex?: string
|
|
108
|
+
}
|
|
109
|
+
}
|
|
26
110
|
interface SlugOptions extends AssistOptions {}
|
|
27
111
|
interface StringOptions extends AssistOptions {}
|
|
28
112
|
interface TextOptions extends AssistOptions {}
|