@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
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import {SanityClient, SanityDocument, useClient} from 'sanity'
|
|
2
|
-
import {useCallback, useEffect, useState} from 'react'
|
|
3
|
-
import {Box, Button, Card, Dialog, Spinner, Stack, Text, useToast} from '@sanity/ui'
|
|
4
|
-
import {CheckmarkIcon} from '@sanity/icons'
|
|
5
|
-
import {
|
|
6
|
-
LegacyAssistDocument,
|
|
7
|
-
legacyAssistDocumentIdPrefix,
|
|
8
|
-
legacyAssistDocumentTypeName,
|
|
9
|
-
legacyAssistStatusDocumentTypeName,
|
|
10
|
-
LegacyContextBlock,
|
|
11
|
-
legacyContextDocumentTypeName,
|
|
12
|
-
LegacyFieldRef,
|
|
13
|
-
LegacyPromptBlock,
|
|
14
|
-
LegacyPromptTextBlock,
|
|
15
|
-
LegacyUserInputBlock,
|
|
16
|
-
} from '../legacy-types'
|
|
17
|
-
import {assistDocumentId} from '../helpers/ids'
|
|
18
|
-
import {
|
|
19
|
-
assistDocumentIdPrefix,
|
|
20
|
-
assistDocumentTypeName,
|
|
21
|
-
AssistField,
|
|
22
|
-
assistFieldTypeName,
|
|
23
|
-
contextDocumentTypeName,
|
|
24
|
-
fieldReferenceTypeName,
|
|
25
|
-
InlinePromptBlock,
|
|
26
|
-
instructionContextTypeName,
|
|
27
|
-
instructionTypeName,
|
|
28
|
-
PromptBlock,
|
|
29
|
-
userInputTypeName,
|
|
30
|
-
} from '../types'
|
|
31
|
-
import {PortableTextSpan} from '@portabletext/types'
|
|
32
|
-
import {pluginTitle} from '../constants'
|
|
33
|
-
|
|
34
|
-
const NO_ASSIST_DOCS: LegacyAssistDocument[] = []
|
|
35
|
-
const NO_CONTEXT_DOCS: SanityDocument[] = []
|
|
36
|
-
const NO_IDS: string[] = []
|
|
37
|
-
|
|
38
|
-
interface MigratedContextDoc {
|
|
39
|
-
_id: string
|
|
40
|
-
_alphaId: string
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type Task = (subtaskProgress: (percentage: number) => void) => Promise<void>
|
|
44
|
-
|
|
45
|
-
export function AlphaMigration() {
|
|
46
|
-
const [alphaAssistDocs, setAlphaAssistDocs] = useState(NO_ASSIST_DOCS)
|
|
47
|
-
const [contextDocs, setContextDocs] = useState(NO_CONTEXT_DOCS)
|
|
48
|
-
const [staleStatusDocIds, setStaleStatusDocs] = useState(NO_IDS)
|
|
49
|
-
const [error, setError] = useState<Error | undefined>(undefined)
|
|
50
|
-
const [progress, setProgress] = useState<number | undefined>(undefined)
|
|
51
|
-
const toast = useToast()
|
|
52
|
-
const client = useClient({apiVersion: '2023-06-01'})
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
let canUpdate = true
|
|
56
|
-
client
|
|
57
|
-
.fetch<{
|
|
58
|
-
assistDocs?: LegacyAssistDocument[]
|
|
59
|
-
staleStatusDocIds?: string[]
|
|
60
|
-
contextDocs?: SanityDocument[]
|
|
61
|
-
}>(
|
|
62
|
-
`
|
|
63
|
-
{
|
|
64
|
-
"assistDocs": *[_type=="${legacyAssistDocumentTypeName}"],
|
|
65
|
-
"staleStatusDocIds": *[_type=="${legacyAssistStatusDocumentTypeName}"]._id,
|
|
66
|
-
"contextDocs": *[_type=="${legacyContextDocumentTypeName}"],
|
|
67
|
-
}
|
|
68
|
-
`
|
|
69
|
-
)
|
|
70
|
-
.then((result) => {
|
|
71
|
-
if (!canUpdate || !result) {
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
setAlphaAssistDocs(result?.assistDocs ?? NO_ASSIST_DOCS)
|
|
75
|
-
setStaleStatusDocs(result?.staleStatusDocIds ?? NO_IDS)
|
|
76
|
-
setContextDocs(result?.contextDocs ?? NO_CONTEXT_DOCS)
|
|
77
|
-
})
|
|
78
|
-
return () => {
|
|
79
|
-
canUpdate = false
|
|
80
|
-
}
|
|
81
|
-
}, [client, setAlphaAssistDocs, setStaleStatusDocs, setContextDocs])
|
|
82
|
-
|
|
83
|
-
const convert = useCallback(async () => {
|
|
84
|
-
try {
|
|
85
|
-
setProgress(0.0001)
|
|
86
|
-
|
|
87
|
-
const tasks: Task[] = [
|
|
88
|
-
() => convertContextDocs(client, contextDocs),
|
|
89
|
-
(subtaskProgress) => deleteDocs(client, staleStatusDocIds, subtaskProgress),
|
|
90
|
-
(subtaskProgress) => convertDocs(client, alphaAssistDocs, subtaskProgress),
|
|
91
|
-
(subtaskProgress) =>
|
|
92
|
-
deleteDocs(
|
|
93
|
-
client,
|
|
94
|
-
contextDocs.map((d) => d._id),
|
|
95
|
-
subtaskProgress
|
|
96
|
-
),
|
|
97
|
-
]
|
|
98
|
-
|
|
99
|
-
const taskSize = 1 / tasks.length
|
|
100
|
-
for (let i = 0; i < tasks.length; i++) {
|
|
101
|
-
const startProgress = i / tasks.length
|
|
102
|
-
await tasks[i]((subProgress) => setProgress(startProgress + subProgress * taskSize))
|
|
103
|
-
setProgress((i + 1) / tasks.length)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
setProgress(1)
|
|
107
|
-
setAlphaAssistDocs(NO_ASSIST_DOCS)
|
|
108
|
-
setContextDocs(NO_CONTEXT_DOCS)
|
|
109
|
-
setStaleStatusDocs(NO_IDS)
|
|
110
|
-
toast.push({
|
|
111
|
-
title: `Converted instructions to new format.`,
|
|
112
|
-
status: 'success',
|
|
113
|
-
closable: true,
|
|
114
|
-
})
|
|
115
|
-
} catch (e: any) {
|
|
116
|
-
console.error(e)
|
|
117
|
-
toast.push({
|
|
118
|
-
title: `An error occurred`,
|
|
119
|
-
status: 'error',
|
|
120
|
-
closable: true,
|
|
121
|
-
})
|
|
122
|
-
setError(e)
|
|
123
|
-
setProgress(undefined)
|
|
124
|
-
}
|
|
125
|
-
}, [contextDocs, client, alphaAssistDocs, staleStatusDocIds, setProgress, toast])
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
(alphaAssistDocs.length || staleStatusDocIds.length || contextDocs.length) &&
|
|
129
|
-
(!progress || progress < 1)
|
|
130
|
-
) {
|
|
131
|
-
return (
|
|
132
|
-
<Dialog id="outdated-assist-docs" header={pluginTitle}>
|
|
133
|
-
<Card padding={3}>
|
|
134
|
-
<Stack space={4} style={{maxWidth: 500}}>
|
|
135
|
-
<Text size={1}>
|
|
136
|
-
It seems like this workspace contains documents from an{' '}
|
|
137
|
-
<strong>older version of {pluginTitle}</strong>.
|
|
138
|
-
</Text>
|
|
139
|
-
<Text size={1}>Cleanup is required.</Text>
|
|
140
|
-
{error ? (
|
|
141
|
-
<Card padding={2} tone="critical" border>
|
|
142
|
-
<Text size={1}>An error occurred. See console for details.</Text>{' '}
|
|
143
|
-
</Card>
|
|
144
|
-
) : null}
|
|
145
|
-
<Button
|
|
146
|
-
icon={
|
|
147
|
-
progress ? (
|
|
148
|
-
<Box style={{marginTop: 5}}>
|
|
149
|
-
<Spinner />
|
|
150
|
-
</Box>
|
|
151
|
-
) : (
|
|
152
|
-
CheckmarkIcon
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
disabled={!!progress}
|
|
156
|
-
text={progress ? `${Math.floor(progress * 100)}%` : 'Ok, convert to new format!'}
|
|
157
|
-
tone="primary"
|
|
158
|
-
onClick={convert}
|
|
159
|
-
/>
|
|
160
|
-
</Stack>
|
|
161
|
-
</Card>
|
|
162
|
-
</Dialog>
|
|
163
|
-
)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return null
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async function deleteDocs(
|
|
170
|
-
client: SanityClient,
|
|
171
|
-
ids: string[],
|
|
172
|
-
updateProgress: (percentage: number) => void
|
|
173
|
-
) {
|
|
174
|
-
const chunkSize = 50
|
|
175
|
-
for (let i = 0; i < ids.length; i += chunkSize) {
|
|
176
|
-
const progressCount = Math.min(ids.length, i + chunkSize)
|
|
177
|
-
const chunk = ids.slice(i, progressCount)
|
|
178
|
-
const trans = client.transaction()
|
|
179
|
-
chunk.forEach((id) => trans.delete(id))
|
|
180
|
-
await trans.commit()
|
|
181
|
-
updateProgress(progressCount / ids.length)
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async function convertContextDocs(client: SanityClient, docs: SanityDocument[]) {
|
|
186
|
-
const trans = client.transaction()
|
|
187
|
-
|
|
188
|
-
for (const doc of docs) {
|
|
189
|
-
const {_id, _type, ...rest} = doc
|
|
190
|
-
trans.createOrReplace({
|
|
191
|
-
...rest,
|
|
192
|
-
_id: `port.${_id}`,
|
|
193
|
-
_alphaId: _id,
|
|
194
|
-
_type: contextDocumentTypeName,
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
await trans.commit()
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
async function convertDocs(
|
|
202
|
-
client: SanityClient,
|
|
203
|
-
docs: LegacyAssistDocument[],
|
|
204
|
-
updateProgress: (percentage: number) => void
|
|
205
|
-
) {
|
|
206
|
-
const chunkSize = 10
|
|
207
|
-
for (let i = 0; i < docs.length; i += chunkSize) {
|
|
208
|
-
const progressCount = Math.min(docs.length, i + chunkSize)
|
|
209
|
-
const chunk = docs.slice(i, progressCount)
|
|
210
|
-
|
|
211
|
-
const trans = client.transaction()
|
|
212
|
-
const contextDocs: MigratedContextDoc[] = await client.fetch(
|
|
213
|
-
`*[_type=="${contextDocumentTypeName}" && _alphaId != null]{_id, _alphaId}`
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
chunk.forEach((oldDoc) => {
|
|
217
|
-
const documentType = oldDoc._id.replace(
|
|
218
|
-
new RegExp(`^(${legacyAssistDocumentIdPrefix}|${assistDocumentIdPrefix})`),
|
|
219
|
-
''
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
const id = assistDocumentId(documentType)
|
|
223
|
-
|
|
224
|
-
const fields: AssistField[] = (oldDoc.fields ?? [])
|
|
225
|
-
.filter((field) => field.instructions?.length)
|
|
226
|
-
.map((oldField) => {
|
|
227
|
-
const instructions = (oldField.instructions ?? []).map((inst) => {
|
|
228
|
-
// eslint-disable-next-line max-nested-callbacks
|
|
229
|
-
const prompt = (inst.prompt ?? []).map((block) => {
|
|
230
|
-
return mapBlock(block, contextDocs) as PromptBlock
|
|
231
|
-
})
|
|
232
|
-
return {
|
|
233
|
-
...inst,
|
|
234
|
-
_type: instructionTypeName,
|
|
235
|
-
prompt,
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
return {
|
|
239
|
-
...oldField,
|
|
240
|
-
_type: assistFieldTypeName,
|
|
241
|
-
instructions,
|
|
242
|
-
}
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
if (fields.length) {
|
|
246
|
-
trans.createOrReplace({
|
|
247
|
-
_id: id,
|
|
248
|
-
_type: assistDocumentTypeName,
|
|
249
|
-
fields,
|
|
250
|
-
})
|
|
251
|
-
}
|
|
252
|
-
trans.delete(oldDoc._id)
|
|
253
|
-
})
|
|
254
|
-
await trans.commit()
|
|
255
|
-
updateProgress(progressCount / docs.length)
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
type Blocks = LegacyPromptBlock | LegacyPromptTextBlock | PortableTextSpan
|
|
260
|
-
|
|
261
|
-
function isFieldRef(block: Blocks): block is LegacyFieldRef {
|
|
262
|
-
return block._type === 'sanity.ai.prompt.fieldRef'
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function isContext(block: Blocks): block is LegacyContextBlock {
|
|
266
|
-
return block._type === 'sanity.ai.prompt.context'
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function isUserInput(block: Blocks): block is LegacyUserInputBlock {
|
|
270
|
-
return block._type === 'sanity.ai.prompt.userInput'
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
function isSpan(block: Blocks): block is PortableTextSpan {
|
|
274
|
-
return block._type === 'span'
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function mapBlock(
|
|
278
|
-
block: Blocks,
|
|
279
|
-
migratedContexts: MigratedContextDoc[]
|
|
280
|
-
): PromptBlock | InlinePromptBlock {
|
|
281
|
-
if (isFieldRef(block)) {
|
|
282
|
-
return {...block, _type: fieldReferenceTypeName}
|
|
283
|
-
}
|
|
284
|
-
if (isUserInput(block)) {
|
|
285
|
-
return {...block, _type: userInputTypeName}
|
|
286
|
-
}
|
|
287
|
-
if (isContext(block)) {
|
|
288
|
-
const newBlock = {
|
|
289
|
-
...block,
|
|
290
|
-
_type: instructionContextTypeName,
|
|
291
|
-
reference: {
|
|
292
|
-
_type: 'reference',
|
|
293
|
-
_ref:
|
|
294
|
-
migratedContexts.find((c) => c._alphaId === block.reference?._ref)?._id ??
|
|
295
|
-
block.reference?._ref,
|
|
296
|
-
},
|
|
297
|
-
} as const
|
|
298
|
-
return newBlock
|
|
299
|
-
}
|
|
300
|
-
if (isSpan(block)) {
|
|
301
|
-
return block
|
|
302
|
-
}
|
|
303
|
-
const textBlock = block
|
|
304
|
-
return {
|
|
305
|
-
...textBlock,
|
|
306
|
-
children: (textBlock.children ?? []).map(
|
|
307
|
-
(child) => mapBlock(child, migratedContexts) as InlinePromptBlock
|
|
308
|
-
),
|
|
309
|
-
}
|
|
310
|
-
}
|
package/src/legacy-types.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {SanityDocument} from 'sanity'
|
|
2
|
-
import {PortableTextBlock, PortableTextMarkDefinition, PortableTextSpan} from '@portabletext/types'
|
|
3
|
-
|
|
4
|
-
//id prefixes
|
|
5
|
-
export const legacyAssistDocumentIdPrefix = 'sanity.ai.'
|
|
6
|
-
|
|
7
|
-
export const legacyAssistDocumentTypeName = 'sanity.ai.docType' as const
|
|
8
|
-
const aiFieldTypeName = 'sanity.ai.docType.field' as const
|
|
9
|
-
const instructionTypeName = 'sanity.ai.field.instruction' as const
|
|
10
|
-
|
|
11
|
-
const userInputTypeName = 'sanity.ai.prompt.userInput' as const
|
|
12
|
-
const promptContextTypeName = 'sanity.ai.prompt.context' as const
|
|
13
|
-
const fieldReferenceTypeName = 'sanity.ai.prompt.fieldRef' as const
|
|
14
|
-
|
|
15
|
-
export const legacyContextDocumentTypeName = 'ai.instruction.context' as const
|
|
16
|
-
|
|
17
|
-
export const legacyAssistStatusDocumentTypeName = 'sanity.ai.instructionStatus' as const
|
|
18
|
-
|
|
19
|
-
export interface FieldPrompts {
|
|
20
|
-
_key: string
|
|
21
|
-
_type: typeof aiFieldTypeName
|
|
22
|
-
path?: string
|
|
23
|
-
instructions?: LegacyInstruction[]
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface LegacyAssistDocument extends SanityDocument {
|
|
27
|
-
fields: FieldPrompts[]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface LegacyFieldRef extends PortableTextMarkDefinition {
|
|
31
|
-
_type: typeof fieldReferenceTypeName
|
|
32
|
-
path?: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface LegacyContextBlock {
|
|
36
|
-
_type: typeof promptContextTypeName
|
|
37
|
-
reference?: {
|
|
38
|
-
_type: 'reference'
|
|
39
|
-
_ref?: string
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface LegacyUserInputBlock {
|
|
44
|
-
_type: typeof userInputTypeName
|
|
45
|
-
_key: string
|
|
46
|
-
message?: string
|
|
47
|
-
description?: string
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type LegacyPromptTextBlock = PortableTextBlock<
|
|
51
|
-
never,
|
|
52
|
-
PortableTextSpan | LegacyFieldRef | LegacyUserInputBlock | LegacyContextBlock,
|
|
53
|
-
'normal',
|
|
54
|
-
never
|
|
55
|
-
>
|
|
56
|
-
|
|
57
|
-
export type LegacyPromptBlock =
|
|
58
|
-
| LegacyPromptTextBlock
|
|
59
|
-
| LegacyFieldRef
|
|
60
|
-
| LegacyContextBlock
|
|
61
|
-
| LegacyUserInputBlock
|
|
62
|
-
|
|
63
|
-
export interface LegacyInstruction {
|
|
64
|
-
_key: string
|
|
65
|
-
_type: typeof instructionTypeName
|
|
66
|
-
prompt?: LegacyPromptBlock[]
|
|
67
|
-
|
|
68
|
-
icon?: string
|
|
69
|
-
userId?: string
|
|
70
|
-
title?: string
|
|
71
|
-
placeholder?: string
|
|
72
|
-
}
|