@ai-stack/payloadcms 3.76.0-beta.1 → 3.76.0-beta.3
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/dist/ai/core/generateObject.js +1 -4
- package/dist/ai/core/generateObject.js.map +1 -1
- package/dist/ai/core/generateText.js +1 -5
- package/dist/ai/core/generateText.js.map +1 -1
- package/dist/ai/core/media/generateMedia.js +1 -4
- package/dist/ai/core/media/generateMedia.js.map +1 -1
- package/dist/ai/core/media/image/generateImage.js +4 -14
- package/dist/ai/core/media/image/generateImage.js.map +1 -1
- package/dist/ai/core/media/image/handlers/multimodal.js +7 -24
- package/dist/ai/core/media/image/handlers/multimodal.js.map +1 -1
- package/dist/ai/core/media/image/handlers/standard.js +7 -2
- package/dist/ai/core/media/image/handlers/standard.js.map +1 -1
- package/dist/ai/core/media/speech/generateSpeech.js +2 -3
- package/dist/ai/core/media/speech/generateSpeech.js.map +1 -1
- package/dist/ai/core/media/types.d.ts +2 -3
- package/dist/ai/core/media/types.js.map +1 -1
- package/dist/ai/core/streamObject.js +0 -3
- package/dist/ai/core/streamObject.js.map +1 -1
- package/dist/ai/core/streamText.js +1 -4
- package/dist/ai/core/streamText.js.map +1 -1
- package/dist/ai/core/types.d.ts +2 -2
- package/dist/ai/core/types.js.map +1 -1
- package/dist/ai/providers/blocks/anthropic.js +2 -44
- package/dist/ai/providers/blocks/anthropic.js.map +1 -1
- package/dist/ai/providers/blocks/elevenlabs.js +4 -109
- package/dist/ai/providers/blocks/elevenlabs.js.map +1 -1
- package/dist/ai/providers/blocks/fal.js +2 -120
- package/dist/ai/providers/blocks/fal.js.map +1 -1
- package/dist/ai/providers/blocks/google.js +6 -240
- package/dist/ai/providers/blocks/google.js.map +1 -1
- package/dist/ai/providers/blocks/openai-compatible.js +2 -146
- package/dist/ai/providers/blocks/openai-compatible.js.map +1 -1
- package/dist/ai/providers/blocks/openai.js +2 -202
- package/dist/ai/providers/blocks/openai.js.map +1 -1
- package/dist/ai/providers/blocks/xai.js +2 -55
- package/dist/ai/providers/blocks/xai.js.map +1 -1
- package/dist/ai/providers/index.d.ts +1 -1
- package/dist/ai/providers/index.js +0 -2
- package/dist/ai/providers/index.js.map +1 -1
- package/dist/ai/providers/registry.d.ts +24 -28
- package/dist/ai/providers/registry.js +184 -138
- package/dist/ai/providers/registry.js.map +1 -1
- package/dist/ai/providers/types.d.ts +12 -33
- package/dist/ai/providers/types.js +0 -1
- package/dist/ai/providers/types.js.map +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.js +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
- package/dist/ai/utilities/filterEditorSchemaByNodes.js.map +1 -0
- package/dist/ai/utilities/generateFileNameByPrompt.js.map +1 -0
- package/dist/ai/utilities/isObjectSchema.js.map +1 -0
- package/dist/ai/{utils → utilities}/nodeToSchemaMap.js +6 -6
- package/dist/ai/utilities/nodeToSchemaMap.js.map +1 -0
- package/dist/ai/{prompts.d.ts → utilities/prompts.d.ts} +1 -1
- package/dist/ai/utilities/prompts.js.map +1 -0
- package/dist/ai/utilities/systemGenerate.js.map +1 -0
- package/dist/collections/AIJobs.js +3 -12
- package/dist/collections/AIJobs.js.map +1 -1
- package/dist/collections/AIProviders.js +56 -29
- package/dist/collections/AIProviders.js.map +1 -1
- package/dist/collections/Instructions.js +91 -59
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/collections/shared.d.ts +30 -0
- package/dist/collections/shared.js +15 -0
- package/dist/collections/shared.js.map +1 -0
- package/dist/endpoints/fetchFields.js +14 -6
- package/dist/endpoints/fetchFields.js.map +1 -1
- package/dist/endpoints/fetchVoices.js +1 -1
- package/dist/endpoints/fetchVoices.js.map +1 -1
- package/dist/endpoints/generate.d.ts +7 -0
- package/dist/endpoints/generate.js +268 -0
- package/dist/endpoints/generate.js.map +1 -0
- package/dist/endpoints/index.js +9 -639
- package/dist/endpoints/index.js.map +1 -1
- package/dist/endpoints/promptMentions.d.ts +2 -0
- package/dist/endpoints/promptMentions.js +166 -0
- package/dist/endpoints/promptMentions.js.map +1 -0
- package/dist/endpoints/upload.d.ts +7 -0
- package/dist/endpoints/upload.js +294 -0
- package/dist/endpoints/upload.js.map +1 -0
- package/dist/endpoints/videogenWebhook.d.ts +7 -0
- package/dist/endpoints/videogenWebhook.js +132 -0
- package/dist/endpoints/videogenWebhook.js.map +1 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/fields.d.ts +2 -1
- package/dist/exports/fields.js +2 -1
- package/dist/exports/fields.js.map +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.js +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.js.map +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.jsx +1 -1
- package/dist/fields/ComposeField/ComposeField.d.ts +1 -0
- package/dist/fields/ComposeField/ComposeField.js +18 -8
- package/dist/fields/ComposeField/ComposeField.js.map +1 -1
- package/dist/fields/ComposeField/ComposeField.jsx +12 -7
- package/dist/fields/LexicalEditor/feature.server.js +1 -1
- package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
- package/dist/fields/PromptEditorField/feature.client.d.ts +1 -0
- package/dist/fields/PromptEditorField/feature.client.js +173 -0
- package/dist/fields/PromptEditorField/feature.client.js.map +1 -0
- package/dist/fields/PromptEditorField/feature.client.jsx +148 -0
- package/dist/fields/PromptEditorField/feature.server.d.ts +1 -0
- package/dist/fields/PromptEditorField/feature.server.js +30 -0
- package/dist/fields/PromptEditorField/feature.server.js.map +1 -0
- package/dist/fields/PromptField.d.ts +4 -0
- package/dist/fields/PromptField.js +18 -0
- package/dist/fields/PromptField.js.map +1 -0
- package/dist/fields/SelectField/SelectField.js +0 -1
- package/dist/fields/SelectField/SelectField.js.map +1 -1
- package/dist/fields/SelectField/SelectField.jsx +0 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/libraries/handlebars/helpers.js +2 -2
- package/dist/libraries/handlebars/helpers.js.map +1 -1
- package/dist/libraries/handlebars/replacePlaceholders.js +5 -1
- package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -1
- package/dist/payload-ai.d.ts +5 -19
- package/dist/plugin.js +18 -21
- package/dist/plugin.js.map +1 -1
- package/dist/providers/FieldProvider/FieldProvider.js +11 -20
- package/dist/providers/FieldProvider/FieldProvider.js.map +1 -1
- package/dist/providers/FieldProvider/FieldProvider.jsx +8 -18
- package/dist/providers/InstructionsProvider/InstructionsProvider.js +5 -2
- package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.jsx +5 -2
- package/dist/translations/de.json +47 -0
- package/dist/translations/en.json +45 -2
- package/dist/translations/es.json +45 -2
- package/dist/translations/fa.json +45 -2
- package/dist/translations/fr.json +46 -3
- package/dist/translations/hi.json +47 -0
- package/dist/translations/index.d.ts +88 -26
- package/dist/translations/index.js +18 -32
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/ja.json +47 -0
- package/dist/translations/nb.json +47 -0
- package/dist/translations/nl.json +47 -0
- package/dist/translations/pl.json +45 -2
- package/dist/translations/pt.json +47 -0
- package/dist/translations/ru.json +45 -2
- package/dist/translations/th.json +47 -0
- package/dist/translations/translation-schema.json +184 -11
- package/dist/translations/uk.json +45 -2
- package/dist/translations/zh.json +47 -0
- package/dist/types.d.ts +64 -28
- package/dist/types.js.map +1 -1
- package/dist/ui/Compose/Compose.js +42 -79
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/Compose.jsx +32 -86
- package/dist/ui/Compose/ComposePlaceholder.js +1 -1
- package/dist/ui/Compose/ComposePlaceholder.js.map +1 -1
- package/dist/ui/Compose/ComposePlaceholder.jsx +1 -1
- package/dist/ui/Compose/{compose.module.css → compose.module.scss} +3 -5
- package/dist/ui/Compose/hooks/menu/Item.d.ts +1 -1
- package/dist/ui/Compose/hooks/menu/Item.js +7 -3
- package/dist/ui/Compose/hooks/menu/Item.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/Item.jsx +11 -5
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js +15 -5
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +11 -5
- package/dist/ui/Compose/hooks/menu/items.d.ts +8 -8
- package/dist/ui/Compose/hooks/menu/itemsMap.d.ts +2 -1
- package/dist/ui/Compose/hooks/menu/itemsMap.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/types.d.ts +21 -0
- package/dist/ui/Compose/hooks/menu/types.js +3 -0
- package/dist/ui/Compose/hooks/menu/types.js.map +1 -0
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts +2 -2
- package/dist/ui/Compose/hooks/menu/useMenu.js +45 -23
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.jsx +43 -23
- package/dist/ui/Compose/hooks/mergeGeneratedValue.d.ts +14 -0
- package/dist/ui/Compose/hooks/mergeGeneratedValue.js +38 -0
- package/dist/ui/Compose/hooks/mergeGeneratedValue.js.map +1 -0
- package/dist/ui/Compose/hooks/useGenerate.js +37 -12
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerateUpload.js +66 -24
- package/dist/ui/Compose/hooks/useGenerateUpload.js.map +1 -1
- package/dist/ui/Compose/hooks/useHistory.js +1 -1
- package/dist/ui/Compose/hooks/useHistory.js.map +1 -1
- package/dist/ui/Compose/hooks/useStreamingUpdate.js +4 -4
- package/dist/ui/Compose/hooks/useStreamingUpdate.js.map +1 -1
- package/dist/ui/ConfigDashboard/configDashboard.module.css +94 -0
- package/dist/ui/ConfigDashboard/index.js +27 -92
- package/dist/ui/ConfigDashboard/index.js.map +1 -1
- package/dist/ui/ConfigDashboard/index.jsx +24 -77
- package/dist/ui/DynamicModelSelect/index.js +6 -27
- package/dist/ui/DynamicModelSelect/index.js.map +1 -1
- package/dist/ui/DynamicModelSelect/index.jsx +6 -29
- package/dist/ui/DynamicProviderSelect/index.js +6 -27
- package/dist/ui/DynamicProviderSelect/index.js.map +1 -1
- package/dist/ui/DynamicProviderSelect/index.jsx +6 -29
- package/dist/ui/DynamicVoiceSelect/index.js +34 -83
- package/dist/ui/DynamicVoiceSelect/index.js.map +1 -1
- package/dist/ui/DynamicVoiceSelect/index.jsx +16 -53
- package/dist/ui/GlobalProviderOptions/index.d.ts +2 -0
- package/dist/ui/GlobalProviderOptions/index.js +118 -0
- package/dist/ui/GlobalProviderOptions/index.js.map +1 -0
- package/dist/ui/GlobalProviderOptions/index.jsx +60 -0
- package/dist/ui/Icons/Icons.js +1 -1
- package/dist/ui/Icons/Icons.js.map +1 -1
- package/dist/ui/Icons/Icons.jsx +1 -1
- package/dist/ui/Icons/LottieAnimation.js +1 -1
- package/dist/ui/Icons/LottieAnimation.js.map +1 -1
- package/dist/ui/Icons/LottieAnimation.jsx +1 -1
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.d.ts +12 -0
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.js +166 -0
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.js.map +1 -0
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.jsx +83 -0
- package/dist/ui/InstructionProviderOptions/index.d.ts +2 -0
- package/dist/ui/InstructionProviderOptions/index.js +157 -0
- package/dist/ui/InstructionProviderOptions/index.js.map +1 -0
- package/dist/ui/InstructionProviderOptions/index.jsx +92 -0
- package/dist/ui/VoicesFetcher/index.js.map +1 -1
- package/dist/ui/hooks/useAISettings.d.ts +26 -0
- package/dist/ui/hooks/useAISettings.js +73 -0
- package/dist/ui/hooks/useAISettings.js.map +1 -0
- package/dist/ui/providerOptions/updateProviderOptionsValue.d.ts +6 -0
- package/dist/ui/providerOptions/updateProviderOptionsValue.js +50 -0
- package/dist/ui/providerOptions/updateProviderOptionsValue.js.map +1 -0
- package/dist/ui/shared/handleSelectChange.d.ts +5 -0
- package/dist/ui/shared/handleSelectChange.js +12 -0
- package/dist/ui/shared/handleSelectChange.js.map +1 -0
- package/dist/ui/shared/types.d.ts +11 -0
- package/dist/ui/shared/types.js +5 -0
- package/dist/ui/shared/types.js.map +1 -0
- package/dist/utilities/ai/resolveEffectiveInstructionSettings.d.ts +15 -0
- package/dist/utilities/ai/resolveEffectiveInstructionSettings.js +136 -0
- package/dist/utilities/ai/resolveEffectiveInstructionSettings.js.map +1 -0
- package/dist/{endpoints → utilities}/buildPromptUtils.js +14 -5
- package/dist/utilities/buildPromptUtils.js.map +1 -0
- package/dist/utilities/buildSmartPrompt.js +3 -3
- package/dist/utilities/buildSmartPrompt.js.map +1 -1
- package/dist/utilities/fields/fieldToJsonSchema.js.map +1 -0
- package/dist/utilities/fields/getFieldBySchemaPath.js.map +1 -0
- package/dist/utilities/fields/getFieldInfo.js.map +1 -0
- package/dist/utilities/{updateFieldsConfig.js → fields/updateFieldsConfig.js} +8 -3
- package/dist/utilities/fields/updateFieldsConfig.js.map +1 -0
- package/dist/utilities/images/extractImageData.js.map +1 -0
- package/dist/utilities/images/extractPromptAttachments.js.map +1 -0
- package/dist/utilities/{fetchImages.d.ts → images/fetchImages.d.ts} +1 -1
- package/dist/utilities/images/fetchImages.js +49 -0
- package/dist/utilities/images/fetchImages.js.map +1 -0
- package/dist/utilities/images/resolveImageReferences.js +183 -0
- package/dist/utilities/images/resolveImageReferences.js.map +1 -0
- package/dist/utilities/init/autoSetupProviders.d.ts +3 -0
- package/dist/utilities/init/autoSetupProviders.js +216 -0
- package/dist/utilities/init/autoSetupProviders.js.map +1 -0
- package/dist/utilities/lexical/editorSchemaValidator.js.map +1 -0
- package/dist/utilities/lexical/lexicalToHTML.js.map +1 -0
- package/dist/utilities/lexical/lexicalToPromptTemplate.d.ts +2 -0
- package/dist/utilities/lexical/lexicalToPromptTemplate.js +50 -0
- package/dist/utilities/lexical/lexicalToPromptTemplate.js.map +1 -0
- package/dist/utilities/lexical/setSafeLexicalState.js.map +1 -0
- package/dist/utilities/lexical/stringToLexicalJSON.d.ts +2 -0
- package/dist/utilities/lexical/stringToLexicalJSON.js +39 -0
- package/dist/utilities/lexical/stringToLexicalJSON.js.map +1 -0
- package/dist/utilities/sanitizeLog.d.ts +1 -0
- package/dist/utilities/sanitizeLog.js +39 -0
- package/dist/utilities/sanitizeLog.js.map +1 -0
- package/dist/utilities/seedProperties.js +54 -22
- package/dist/utilities/seedProperties.js.map +1 -1
- package/package.json +36 -2
- package/dist/ai/analyse.d.ts +0 -1
- package/dist/ai/analyse.js +0 -3
- package/dist/ai/analyse.js.map +0 -1
- package/dist/ai/index.d.ts +0 -11
- package/dist/ai/index.js +0 -25
- package/dist/ai/index.js.map +0 -1
- package/dist/ai/prompts.js.map +0 -1
- package/dist/ai/utils/filterEditorSchemaByNodes.js.map +0 -1
- package/dist/ai/utils/generateFileNameByPrompt.js.map +0 -1
- package/dist/ai/utils/isObjectSchema.js.map +0 -1
- package/dist/ai/utils/nodeToSchemaMap.js.map +0 -1
- package/dist/ai/utils/systemGenerate.js.map +0 -1
- package/dist/endpoints/buildPromptUtils.js.map +0 -1
- package/dist/endpoints/chat.d.ts +0 -4
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts +0 -3
- package/dist/fields/PromptEditorField/PromptEditorField.js +0 -217
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +0 -1
- package/dist/fields/PromptEditorField/PromptEditorField.jsx +0 -160
- package/dist/ui/AIConfigDashboard/index.d.ts +0 -2
- package/dist/ui/AIConfigDashboard/index.js +0 -224
- package/dist/ui/AIConfigDashboard/index.js.map +0 -1
- package/dist/ui/AIConfigDashboard/index.jsx +0 -175
- package/dist/ui/ProviderOptionsEditor/index.d.ts +0 -7
- package/dist/ui/ProviderOptionsEditor/index.js +0 -291
- package/dist/ui/ProviderOptionsEditor/index.js.map +0 -1
- package/dist/ui/ProviderOptionsEditor/index.jsx +0 -210
- package/dist/utilities/editorSchemaValidator.js.map +0 -1
- package/dist/utilities/extractImageData.js.map +0 -1
- package/dist/utilities/extractPromptAttachments.js.map +0 -1
- package/dist/utilities/fetchImages.js +0 -38
- package/dist/utilities/fetchImages.js.map +0 -1
- package/dist/utilities/fieldToJsonSchema.js.map +0 -1
- package/dist/utilities/getFieldBySchemaPath.js.map +0 -1
- package/dist/utilities/getFieldInfo.js.map +0 -1
- package/dist/utilities/getProviderOptionsFields.d.ts +0 -16
- package/dist/utilities/getProviderOptionsFields.js +0 -80
- package/dist/utilities/getProviderOptionsFields.js.map +0 -1
- package/dist/utilities/isPluginActivated.d.ts +0 -2
- package/dist/utilities/isPluginActivated.js +0 -5
- package/dist/utilities/isPluginActivated.js.map +0 -1
- package/dist/utilities/lexicalToHTML.js.map +0 -1
- package/dist/utilities/resolveImageReferences.js +0 -167
- package/dist/utilities/resolveImageReferences.js.map +0 -1
- package/dist/utilities/schemaConverter.d.ts +0 -3
- package/dist/utilities/schemaConverter.js +0 -93
- package/dist/utilities/schemaConverter.js.map +0 -1
- package/dist/utilities/setSafeLexicalState.js.map +0 -1
- package/dist/utilities/updateFieldsConfig.js.map +0 -1
- /package/dist/ai/{utils → utilities}/filterEditorSchemaByNodes.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/filterEditorSchemaByNodes.js +0 -0
- /package/dist/ai/{utils → utilities}/generateFileNameByPrompt.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/generateFileNameByPrompt.js +0 -0
- /package/dist/ai/{utils → utilities}/isObjectSchema.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/isObjectSchema.js +0 -0
- /package/dist/ai/{utils → utilities}/nodeToSchemaMap.d.ts +0 -0
- /package/dist/ai/{prompts.js → utilities/prompts.js} +0 -0
- /package/dist/ai/{utils → utilities}/systemGenerate.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/systemGenerate.js +0 -0
- /package/dist/ui/Icons/{icons.module.css → icons.module.scss} +0 -0
- /package/dist/{endpoints → utilities}/buildPromptUtils.d.ts +0 -0
- /package/dist/utilities/{fieldToJsonSchema.d.ts → fields/fieldToJsonSchema.d.ts} +0 -0
- /package/dist/utilities/{fieldToJsonSchema.js → fields/fieldToJsonSchema.js} +0 -0
- /package/dist/utilities/{getFieldBySchemaPath.d.ts → fields/getFieldBySchemaPath.d.ts} +0 -0
- /package/dist/utilities/{getFieldBySchemaPath.js → fields/getFieldBySchemaPath.js} +0 -0
- /package/dist/utilities/{getFieldInfo.d.ts → fields/getFieldInfo.d.ts} +0 -0
- /package/dist/utilities/{getFieldInfo.js → fields/getFieldInfo.js} +0 -0
- /package/dist/utilities/{updateFieldsConfig.d.ts → fields/updateFieldsConfig.d.ts} +0 -0
- /package/dist/utilities/{extractImageData.d.ts → images/extractImageData.d.ts} +0 -0
- /package/dist/utilities/{extractImageData.js → images/extractImageData.js} +0 -0
- /package/dist/utilities/{extractPromptAttachments.d.ts → images/extractPromptAttachments.d.ts} +0 -0
- /package/dist/utilities/{extractPromptAttachments.js → images/extractPromptAttachments.js} +0 -0
- /package/dist/utilities/{resolveImageReferences.d.ts → images/resolveImageReferences.d.ts} +0 -0
- /package/dist/utilities/{editorSchemaValidator.d.ts → lexical/editorSchemaValidator.d.ts} +0 -0
- /package/dist/utilities/{editorSchemaValidator.js → lexical/editorSchemaValidator.js} +0 -0
- /package/dist/utilities/{lexicalToHTML.d.ts → lexical/lexicalToHTML.d.ts} +0 -0
- /package/dist/utilities/{lexicalToHTML.js → lexical/lexicalToHTML.js} +0 -0
- /package/dist/utilities/{setSafeLexicalState.d.ts → lexical/setSafeLexicalState.d.ts} +0 -0
- /package/dist/utilities/{setSafeLexicalState.js → lexical/setSafeLexicalState.js} +0 -0
|
@@ -1,16 +1,189 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"type": "object",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"$schema": {
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"ai-plugin": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"additionalProperties": false,
|
|
12
|
+
"properties": {
|
|
13
|
+
"configDashboard": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"additionalProperties": false,
|
|
16
|
+
"properties": {
|
|
17
|
+
"loadingConfiguration": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"configureTitle": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"configureSubtitle": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"providers": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"saveChanges": {
|
|
30
|
+
"type": "string"
|
|
31
|
+
},
|
|
32
|
+
"saving": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"selectCollectionsBody": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
},
|
|
38
|
+
"settingsSaved": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
},
|
|
41
|
+
"failedToSave": {
|
|
42
|
+
"type": "string"
|
|
43
|
+
},
|
|
44
|
+
"errorSaving": {
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"actions": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"additionalProperties": false,
|
|
52
|
+
"properties": {
|
|
53
|
+
"proofread": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"rephrase": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
},
|
|
59
|
+
"translate": {
|
|
60
|
+
"type": "string"
|
|
61
|
+
},
|
|
62
|
+
"expand": {
|
|
63
|
+
"type": "string"
|
|
64
|
+
},
|
|
65
|
+
"summarize": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
},
|
|
68
|
+
"simplify": {
|
|
69
|
+
"type": "string"
|
|
70
|
+
},
|
|
71
|
+
"compose": {
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"settings": {
|
|
75
|
+
"type": "string"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"actionLoading": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"additionalProperties": false,
|
|
82
|
+
"properties": {
|
|
83
|
+
"proofreading": {
|
|
84
|
+
"type": "string"
|
|
85
|
+
},
|
|
86
|
+
"rephrasing": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"translating": {
|
|
90
|
+
"type": "string"
|
|
91
|
+
},
|
|
92
|
+
"expanding": {
|
|
93
|
+
"type": "string"
|
|
94
|
+
},
|
|
95
|
+
"summarizing": {
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"simplifying": {
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"composing": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"general": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"additionalProperties": false,
|
|
109
|
+
"properties": {
|
|
110
|
+
"search": {
|
|
111
|
+
"type": "string"
|
|
112
|
+
},
|
|
113
|
+
"queued": {
|
|
114
|
+
"type": "string"
|
|
115
|
+
},
|
|
116
|
+
"video": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
},
|
|
119
|
+
"loading": {
|
|
120
|
+
"type": "string"
|
|
121
|
+
},
|
|
122
|
+
"clickToStop": {
|
|
123
|
+
"type": "string"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"localization": {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"additionalProperties": false,
|
|
132
|
+
"properties": {
|
|
133
|
+
"selectedLocales": {
|
|
134
|
+
"type": "string"
|
|
135
|
+
},
|
|
136
|
+
"selectLocaleToDuplicate": {
|
|
137
|
+
"type": "string"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
8
141
|
},
|
|
142
|
+
"required": [
|
|
143
|
+
"ai-plugin"
|
|
144
|
+
],
|
|
9
145
|
"ai-plugin": {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
146
|
+
"configDashboard": {
|
|
147
|
+
"loadingConfiguration": "Loading configuration...",
|
|
148
|
+
"configureTitle": "Let's configure your AI Plugin",
|
|
149
|
+
"configureSubtitle": "Set up the provider \u2192 Choose the content \u2192 Refine the behavior.",
|
|
150
|
+
"providers": "Providers",
|
|
151
|
+
"saveChanges": "Save Changes",
|
|
152
|
+
"saving": "Saving...",
|
|
153
|
+
"selectCollectionsBody": "Select the collections where AI features should be available, toggle them on or off, and save your changes.",
|
|
154
|
+
"settingsSaved": "Settings saved successfully",
|
|
155
|
+
"failedToSave": "Failed to save settings",
|
|
156
|
+
"errorSaving": "Error saving settings"
|
|
157
|
+
},
|
|
158
|
+
"actions": {
|
|
159
|
+
"proofread": "Proofread",
|
|
160
|
+
"rephrase": "Rephrase",
|
|
161
|
+
"translate": "Translate",
|
|
162
|
+
"expand": "Expand",
|
|
163
|
+
"summarize": "Summarize",
|
|
164
|
+
"simplify": "Simplify",
|
|
165
|
+
"compose": "Compose",
|
|
166
|
+
"settings": "Settings"
|
|
167
|
+
},
|
|
168
|
+
"actionLoading": {
|
|
169
|
+
"proofreading": "Proofreading",
|
|
170
|
+
"rephrasing": "Rephrasing",
|
|
171
|
+
"translating": "Translating",
|
|
172
|
+
"expanding": "Expanding",
|
|
173
|
+
"summarizing": "Summarizing",
|
|
174
|
+
"simplifying": "Simplifying",
|
|
175
|
+
"composing": "Composing"
|
|
176
|
+
},
|
|
177
|
+
"general": {
|
|
178
|
+
"search": "Search...",
|
|
179
|
+
"queued": "Queued",
|
|
180
|
+
"video": "Video",
|
|
181
|
+
"loading": "Loading...",
|
|
182
|
+
"clickToStop": "Click to stop"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"localization": {
|
|
186
|
+
"selectedLocales": "Selected locales",
|
|
187
|
+
"selectLocaleToDuplicate": "Select locale to duplicate"
|
|
13
188
|
}
|
|
14
|
-
},
|
|
15
|
-
"required": ["ai-plugin"]
|
|
16
189
|
}
|
|
@@ -1,4 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "./translation-schema.json",
|
|
3
|
+
"ai-plugin": {
|
|
4
|
+
"configDashboard": {
|
|
5
|
+
"loadingConfiguration": "Завантаження конфігурації...",
|
|
6
|
+
"configureTitle": "Налаштуймо ваш AI-плагін",
|
|
7
|
+
"configureSubtitle": "Налаштуйте провайдера → Виберіть контент → Уточніть поведінку.",
|
|
8
|
+
"providers": "Провайдери",
|
|
9
|
+
"saveChanges": "Зберегти зміни",
|
|
10
|
+
"saving": "Збереження...",
|
|
11
|
+
"selectCollectionsBody": "Виберіть колекції, де мають бути доступні функції AI, увімкніть або вимкніть їх і збережіть зміни.",
|
|
12
|
+
"settingsSaved": "Налаштування успішно збережено",
|
|
13
|
+
"failedToSave": "Не вдалося зберегти налаштування",
|
|
14
|
+
"errorSaving": "Помилка під час збереження налаштувань"
|
|
15
|
+
},
|
|
16
|
+
"actions": {
|
|
17
|
+
"proofread": "Вичитка",
|
|
18
|
+
"rephrase": "Перефразувати",
|
|
19
|
+
"translate": "Перекласти",
|
|
20
|
+
"expand": "Розширити",
|
|
21
|
+
"summarize": "Підсумувати",
|
|
22
|
+
"simplify": "Спрощувати",
|
|
23
|
+
"compose": "Скласти",
|
|
24
|
+
"settings": "Налаштування"
|
|
25
|
+
},
|
|
26
|
+
"actionLoading": {
|
|
27
|
+
"proofreading": "Вичитка",
|
|
28
|
+
"rephrasing": "Перефразування",
|
|
29
|
+
"translating": "Переклад",
|
|
30
|
+
"expanding": "Розширення",
|
|
31
|
+
"summarizing": "Підсумування",
|
|
32
|
+
"simplifying": "Спрощення",
|
|
33
|
+
"composing": "Складання"
|
|
34
|
+
},
|
|
35
|
+
"general": {
|
|
36
|
+
"search": "Пошук...",
|
|
37
|
+
"queued": "У черзі",
|
|
38
|
+
"video": "Відео",
|
|
39
|
+
"loading": "Завантаження...",
|
|
40
|
+
"clickToStop": "Натисніть, щоб зупинити"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"localization": {
|
|
44
|
+
"selectedLocales": "Selected locales",
|
|
45
|
+
"selectLocaleToDuplicate": "Select locale to duplicate"
|
|
46
|
+
}
|
|
4
47
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./translation-schema.json",
|
|
3
|
+
"ai-plugin": {
|
|
4
|
+
"configDashboard": {
|
|
5
|
+
"loadingConfiguration": "正在加载配置...",
|
|
6
|
+
"configureTitle": "让我们配置你的 AI 插件",
|
|
7
|
+
"configureSubtitle": "设置提供商 → 选择内容 → 优化行为。",
|
|
8
|
+
"providers": "提供商",
|
|
9
|
+
"saveChanges": "保存更改",
|
|
10
|
+
"saving": "正在保存...",
|
|
11
|
+
"selectCollectionsBody": "选择需要启用 AI 功能的集合,开启或关闭它们并保存更改。",
|
|
12
|
+
"settingsSaved": "设置已成功保存",
|
|
13
|
+
"failedToSave": "保存设置失败",
|
|
14
|
+
"errorSaving": "保存设置时出错"
|
|
15
|
+
},
|
|
16
|
+
"actions": {
|
|
17
|
+
"proofread": "校对",
|
|
18
|
+
"rephrase": "改写",
|
|
19
|
+
"translate": "翻译",
|
|
20
|
+
"expand": "扩展",
|
|
21
|
+
"summarize": "总结",
|
|
22
|
+
"simplify": "简化",
|
|
23
|
+
"compose": "撰写",
|
|
24
|
+
"settings": "设置"
|
|
25
|
+
},
|
|
26
|
+
"actionLoading": {
|
|
27
|
+
"proofreading": "正在校对",
|
|
28
|
+
"rephrasing": "正在改写",
|
|
29
|
+
"translating": "正在翻译",
|
|
30
|
+
"expanding": "正在扩展",
|
|
31
|
+
"summarizing": "正在总结",
|
|
32
|
+
"simplifying": "正在简化",
|
|
33
|
+
"composing": "正在撰写"
|
|
34
|
+
},
|
|
35
|
+
"general": {
|
|
36
|
+
"search": "搜索...",
|
|
37
|
+
"queued": "排队中",
|
|
38
|
+
"video": "视频",
|
|
39
|
+
"loading": "正在加载...",
|
|
40
|
+
"clickToStop": "点击停止"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"localization": {
|
|
44
|
+
"selectedLocales": "Selected locales",
|
|
45
|
+
"selectLocaleToDuplicate": "Select locale to duplicate"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { GenerateObjectResult, ModelMessage } from 'ai';
|
|
2
2
|
import type { JSONSchema } from 'openai/lib/jsonschema';
|
|
3
3
|
import type { ImageGenerateParams } from 'openai/resources/images';
|
|
4
|
-
import type {
|
|
5
|
-
import type { CSSProperties, MouseEventHandler } from 'react';
|
|
4
|
+
import type { CollectionSlug, DataFromCollectionSlug, Endpoint, Field, File, GlobalConfig, GroupField, PayloadRequest, TypedCollection } from 'payload';
|
|
6
5
|
import type { MediaResult } from './ai/core/index.js';
|
|
7
6
|
import type { PLUGIN_INSTRUCTIONS_TABLE } from './defaults.js';
|
|
8
7
|
export interface PluginConfigAccess {
|
|
@@ -46,6 +45,29 @@ export interface PluginConfig {
|
|
|
46
45
|
nodes: JSONSchema[];
|
|
47
46
|
};
|
|
48
47
|
fields?: Field[];
|
|
48
|
+
/**
|
|
49
|
+
* Defines default provider and models to be selected
|
|
50
|
+
* when creating initial database records for Generation Defaults.
|
|
51
|
+
*/
|
|
52
|
+
generationDefaults?: {
|
|
53
|
+
image?: {
|
|
54
|
+
model: string;
|
|
55
|
+
provider: string;
|
|
56
|
+
};
|
|
57
|
+
text?: {
|
|
58
|
+
model: string;
|
|
59
|
+
provider: string;
|
|
60
|
+
};
|
|
61
|
+
tts?: {
|
|
62
|
+
model: string;
|
|
63
|
+
provider: string;
|
|
64
|
+
voice?: string;
|
|
65
|
+
};
|
|
66
|
+
video?: {
|
|
67
|
+
model: string;
|
|
68
|
+
provider: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
49
71
|
generationModels?: ((defaultModels: GenerationModel[]) => GenerationModel[]) | GenerationModel[];
|
|
50
72
|
globals?: {
|
|
51
73
|
[key: GlobalConfig['slug']]: boolean;
|
|
@@ -53,14 +75,21 @@ export interface PluginConfig {
|
|
|
53
75
|
interfaceName?: string;
|
|
54
76
|
mediaUpload?: PluginConfigMediaUploadFunction;
|
|
55
77
|
options?: PluginOptions;
|
|
56
|
-
overrideInstructions?:
|
|
57
|
-
promptFields?:
|
|
78
|
+
overrideInstructions?: any;
|
|
79
|
+
promptFields?: any[];
|
|
80
|
+
prompts?: ActionPrompt[];
|
|
58
81
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* You can access default prompts by importing { defaultPrompts } from '@ai-stack/payloadcms'
|
|
82
|
+
* Pre-configured options that get passed directly to AI SDK providers.
|
|
83
|
+
* This allows devs to define AI options safely via payload.config.ts.
|
|
62
84
|
*/
|
|
63
|
-
|
|
85
|
+
providerOptions?: {
|
|
86
|
+
[key: string]: Record<string, any> | undefined;
|
|
87
|
+
anthropic?: Record<string, any>;
|
|
88
|
+
elevenlabs?: Record<string, any>;
|
|
89
|
+
fal?: Record<string, any>;
|
|
90
|
+
google?: Record<string, any>;
|
|
91
|
+
openai?: Record<string, any>;
|
|
92
|
+
};
|
|
64
93
|
/**
|
|
65
94
|
* Custom seed prompt function for generating field-specific prompts
|
|
66
95
|
* If not provided, fields will have empty prompts by default
|
|
@@ -91,6 +120,7 @@ export type GenerateTextarea<T = any> = (args: {
|
|
|
91
120
|
}) => Promise<string> | string;
|
|
92
121
|
export interface Endpoints {
|
|
93
122
|
fetchVoices?: Omit<Endpoint, 'root'>;
|
|
123
|
+
promptMentions: Endpoint;
|
|
94
124
|
textarea: Omit<Endpoint, 'root'>;
|
|
95
125
|
upload: Omit<Endpoint, 'root'>;
|
|
96
126
|
videogenWebhook?: Omit<Endpoint, 'root'>;
|
|
@@ -122,26 +152,6 @@ export type SeedPromptResult = {
|
|
|
122
152
|
system: string;
|
|
123
153
|
} | false | undefined | void;
|
|
124
154
|
export type SeedPromptFunction = (options: SeedPromptOptions) => Promise<SeedPromptResult> | SeedPromptResult;
|
|
125
|
-
export type ActionMenuEvents = 'onCompose' | 'onExpand' | 'onProofread' | 'onRephrase' | 'onSettings' | 'onSimplify' | 'onSummarize' | 'onTone' | 'onTranslate';
|
|
126
|
-
export type UseMenuEvents = {
|
|
127
|
-
[key in ActionMenuEvents]?: (data?: unknown) => void;
|
|
128
|
-
};
|
|
129
|
-
export type UseMenuOptions = {
|
|
130
|
-
isConfigAllowed: boolean;
|
|
131
|
-
};
|
|
132
|
-
export type BaseItemProps<T = any> = {
|
|
133
|
-
children?: React.ReactNode;
|
|
134
|
-
className?: string;
|
|
135
|
-
disabled?: boolean;
|
|
136
|
-
hideIcon?: boolean;
|
|
137
|
-
isActive?: boolean;
|
|
138
|
-
isMenu?: boolean;
|
|
139
|
-
onClick: (data?: unknown) => void;
|
|
140
|
-
onMouseEnter?: MouseEventHandler<T> | undefined;
|
|
141
|
-
onMouseLeave?: MouseEventHandler<T> | undefined;
|
|
142
|
-
style?: CSSProperties | undefined;
|
|
143
|
-
title?: string;
|
|
144
|
-
};
|
|
145
155
|
export type ImageReference = {
|
|
146
156
|
data: Blob;
|
|
147
157
|
name: string;
|
|
@@ -196,5 +206,31 @@ export type AfterGenerateHook<T = any> = (args: AfterGenerateArgs<T>) => Promise
|
|
|
196
206
|
export interface AIFieldConfig {
|
|
197
207
|
[key: string]: unknown;
|
|
198
208
|
afterGenerate?: AfterGenerateHook[];
|
|
209
|
+
/**
|
|
210
|
+
* When true, the Compose button is always visible on this field,
|
|
211
|
+
* bypassing the focus-based show/hide system.
|
|
212
|
+
* Admin `disabled` in Instructions still takes priority.
|
|
213
|
+
*/
|
|
214
|
+
alwaysShow?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* When true and the field hasMany, generated values are appended
|
|
217
|
+
* instead of replacing current field value(s).
|
|
218
|
+
*/
|
|
219
|
+
appendGenerated?: boolean;
|
|
199
220
|
beforeGenerate?: BeforeGenerateHook[];
|
|
221
|
+
/**
|
|
222
|
+
* Default hidden state for Compose in instructions.
|
|
223
|
+
* When true, Compose is hidden for this field.
|
|
224
|
+
*/
|
|
225
|
+
disabled?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Set to false to opt-out of compose button injection for this field.
|
|
228
|
+
* When false, no compose button is injected at build time.
|
|
229
|
+
* @default true (compose is auto-injected on supported field types)
|
|
230
|
+
*/
|
|
231
|
+
enabled?: boolean;
|
|
232
|
+
/** Custom prompt template for this field */
|
|
233
|
+
prompt?: string;
|
|
234
|
+
/** Custom system prompt for this field */
|
|
235
|
+
system?: string;
|
|
200
236
|
}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { GenerateObjectResult, ModelMessage } from 'ai'\nimport type { JSONSchema } from 'openai/lib/jsonschema'\nimport type { ImageGenerateParams } from 'openai/resources/images'\nimport type {\n CollectionConfig,\n CollectionSlug,\n DataFromCollectionSlug,\n Endpoint,\n Field,\n File,\n GlobalConfig,\n GroupField,\n PayloadRequest,\n TypedCollection,\n} from 'payload'\
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { GenerateObjectResult, ModelMessage } from 'ai'\nimport type { JSONSchema } from 'openai/lib/jsonschema'\nimport type { ImageGenerateParams } from 'openai/resources/images'\nimport type {\n CollectionConfig,\n CollectionSlug,\n DataFromCollectionSlug,\n Endpoint,\n Field,\n File,\n GlobalConfig,\n GroupField,\n PayloadRequest,\n TypedCollection,\n} from 'payload'\n\nimport type { MediaResult } from './ai/core/index.js'\nimport type { PLUGIN_INSTRUCTIONS_TABLE } from './defaults.js'\n\nexport interface PluginConfigAccess {\n /**\n * Control access to AI generation features (generate text, images, audio)\n * @default () => !!req.user (requires authentication)\n */\n generate?: ({ req }: { req: PayloadRequest }) => boolean | Promise<boolean>\n /**\n * Control access to AI settings/configuration\n * @default () => !!req.user (requires authentication)\n */\n settings?: ({ req }: { req: PayloadRequest }) => boolean | Promise<boolean>\n}\n\nexport interface PluginOptions {\n /**\n * Provide local tags to filter language options from the Translate Menu\n * Check for the available local tags,\n * visit: https://www.npmjs.com/package/locale-codes\n * Example: [\"en-US\", \"zh-SG\", \"zh-CN\", \"en\"]\n */\n enabledLanguages?: string[]\n}\n\nexport type PluginConfigMediaUploadFunction = (\n result: MediaResult,\n {\n collection,\n request,\n }: {\n collection: CollectionSlug\n request: PayloadRequest\n },\n) => Promise<DataFromCollectionSlug<CollectionSlug>>\n\nexport interface PluginConfig {\n /**\n * Access control configuration for AI features\n * By default, all AI features require authentication\n */\n access?: PluginConfigAccess\n debugging?: boolean\n disableSponsorMessage?: boolean\n editorConfig?: { nodes: JSONSchema[] }\n fields?: Field[]\n /**\n * Defines default provider and models to be selected\n * when creating initial database records for Generation Defaults.\n */\n generationDefaults?: {\n image?: { model: string; provider: string }\n text?: { model: string; provider: string }\n tts?: { model: string; provider: string; voice?: string }\n video?: { model: string; provider: string }\n }\n generationModels?: ((defaultModels: GenerationModel[]) => GenerationModel[]) | GenerationModel[]\n globals?: {\n [key: GlobalConfig['slug']]: boolean\n }\n interfaceName?: string\n mediaUpload?: PluginConfigMediaUploadFunction\n options?: PluginOptions\n overrideInstructions?: any\n promptFields?: any[]\n prompts?: ActionPrompt[]\n /**\n * Pre-configured options that get passed directly to AI SDK providers.\n * This allows devs to define AI options safely via payload.config.ts.\n */\n providerOptions?: {\n [key: string]: Record<string, any> | undefined // generic fallback\n anthropic?: Record<string, any>\n elevenlabs?: Record<string, any>\n fal?: Record<string, any>\n google?: Record<string, any>\n openai?: Record<string, any>\n }\n /**\n * Custom seed prompt function for generating field-specific prompts\n * If not provided, fields will have empty prompts by default\n */\n seedPrompts?: SeedPromptFunction\n uploadCollectionSlug?: CollectionSlug\n}\n\nexport interface GenerationModel {\n fields: string[]\n generateText?: (prompt: string, system: string) => Promise<string>\n handler?: (prompt: string, options: any) => File | Promise<any> | Response\n id: string\n name: string\n output: 'audio' | 'file' | 'image' | 'json' | 'text' | 'video'\n settings?: GroupField\n supportsPromptOptimization?: boolean\n}\n\nexport interface GenerationConfig {\n models: GenerationModel[]\n provider: string\n}\n\nexport type GenerateTextarea<T = any> = (args: {\n collectionSlug: CollectionSlug\n doc: T\n documentId?: number | string\n locale?: string\n options?: any\n}) => Promise<string> | string\n\nexport interface Endpoints {\n fetchVoices?: Omit<Endpoint, 'root'>\n promptMentions: Endpoint\n textarea: Omit<Endpoint, 'root'>\n upload: Omit<Endpoint, 'root'>\n videogenWebhook?: Omit<Endpoint, 'root'>\n}\n\nexport type ActionMenuItems =\n | 'Compose'\n | 'Expand'\n | 'Proofread'\n | 'Rephrase'\n | 'Settings'\n | 'Simplify'\n | 'Summarize'\n | 'Tone'\n | 'Translate'\n\nexport type ActionPromptOptions = {\n layout?: string\n locale?: string\n prompt?: string\n systemPrompt?: string\n}\n\nexport type ActionPrompt = {\n layout?: (options?: ActionPromptOptions) => string\n name: ActionMenuItems\n system: (options: ActionPromptOptions) => string\n}\n\nexport type SeedPromptOptions = {\n fieldLabel: string\n fieldSchemaPaths: Record<string, any>\n fieldType: string\n path: string\n}\n\nexport type SeedPromptData = Omit<\n TypedCollection[typeof PLUGIN_INSTRUCTIONS_TABLE],\n 'createdAt' | 'id' | 'updatedAt'\n>\n\nexport type SeedPromptResult =\n | {\n data?: SeedPromptData\n }\n | {\n data?: SeedPromptData\n prompt: string\n system: string\n }\n | false\n | undefined\n | void\n\nexport type SeedPromptFunction = (\n options: SeedPromptOptions,\n) => Promise<SeedPromptResult> | SeedPromptResult\n\nexport type ImageReference = {\n data: Blob\n name: string\n size: number\n type: string\n url: string\n}\n\nexport type GenerateImageParams = {\n images?: ImageReference[]\n size?: ImageGenerateParams['size']\n style?: ImageGenerateParams['style']\n version?: ImageGenerateParams['model']\n}\n\nexport type SerializedPromptField = {\n collections?: CollectionSlug[]\n name: string\n}\n\nexport type PromptFieldGetterContext = {\n collection: CollectionSlug\n type: string\n}\n\nexport type PromptField = {\n // If not provided, the value will be returned from the data object as-is\n getter?: (data: object, ctx: PromptFieldGetterContext) => Promise<string> | string\n} & SerializedPromptField\n\nexport interface BeforeGenerateArgs<T = any> {\n doc: T\n field: Field\n headers: Record<string, string>\n instructions: Record<string, unknown> // The instruction document\n messages?: ModelMessage[]\n payload: PayloadRequest['payload']\n prompt: string\n req: PayloadRequest\n system: string\n}\n\nexport type BeforeGenerateResult = {\n messages?: ModelMessage[]\n prompt?: string\n system?: string\n} | void\n\nexport type BeforeGenerateHook<T = any> = (\n args: BeforeGenerateArgs<T>,\n) => BeforeGenerateResult | Promise<BeforeGenerateResult>\n\nexport interface AfterGenerateArgs<T = any> {\n doc: T\n field: Field\n headers: Record<string, string>\n instructions: Record<string, unknown>\n payload: PayloadRequest['payload']\n req: PayloadRequest\n result: GenerateObjectResult<any> | MediaResult | string // depends on context\n}\n\nexport type AfterGenerateHook<T = any> = (args: AfterGenerateArgs<T>) => Promise<void> | void\n\n// Add to PluginConfig or a new interface if accessed via custom.ai\nexport interface AIFieldConfig {\n [key: string]: unknown\n afterGenerate?: AfterGenerateHook[]\n /**\n * When true, the Compose button is always visible on this field,\n * bypassing the focus-based show/hide system.\n * Admin `disabled` in Instructions still takes priority.\n */\n alwaysShow?: boolean\n /**\n * When true and the field hasMany, generated values are appended\n * instead of replacing current field value(s).\n */\n appendGenerated?: boolean\n beforeGenerate?: BeforeGenerateHook[]\n /**\n * Default hidden state for Compose in instructions.\n * When true, Compose is hidden for this field.\n */\n disabled?: boolean\n /**\n * Set to false to opt-out of compose button injection for this field.\n * When false, no compose button is injected at build time.\n * @default true (compose is auto-injected on supported field types)\n */\n enabled?: boolean\n /** Custom prompt template for this field */\n prompt?: string\n /** Custom system prompt for this field */\n system?: string\n}\n"],"names":[],"mappings":"AA4PA,mEAAmE;AACnE,WA8BC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEditorConfigContext } from '@payloadcms/richtext-lexical/client';
|
|
4
|
-
import { Popup, useField } from '@payloadcms/ui';
|
|
4
|
+
import { Popup, useField, useTranslation } from '@payloadcms/ui';
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
import { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js';
|
|
7
|
-
import { setSafeLexicalState } from '../../utilities/setSafeLexicalState.js';
|
|
7
|
+
import { setSafeLexicalState } from '../../utilities/lexical/setSafeLexicalState.js';
|
|
8
8
|
import { PluginIcon } from '../Icons/Icons.js';
|
|
9
|
-
import styles from './compose.module.
|
|
9
|
+
import styles from './compose.module.scss';
|
|
10
10
|
import { useMenu } from './hooks/menu/useMenu.js';
|
|
11
11
|
import { useActiveFieldTracking } from './hooks/useActiveFieldTracking.js';
|
|
12
12
|
import { useGenerate } from './hooks/useGenerate.js';
|
|
@@ -18,96 +18,51 @@ export const Compose = ({ descriptionProps, forceVisible, instructionId, isConfi
|
|
|
18
18
|
const { openDrawer } = useInstructions();
|
|
19
19
|
// Initialize global active-field tracking
|
|
20
20
|
useActiveFieldTracking();
|
|
21
|
+
const { t } = useTranslation();
|
|
21
22
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
22
23
|
const { generate, isJobActive, isLoading, jobProgress, jobStatus, stop } = useGenerate({
|
|
23
24
|
instructionId
|
|
24
25
|
});
|
|
25
|
-
//
|
|
26
|
-
const
|
|
27
|
-
console.log('Composing...');
|
|
26
|
+
// Single factory for all action callbacks, eliminating duplication
|
|
27
|
+
const createAction = useCallback((action, params)=>{
|
|
28
28
|
setIsProcessing(true);
|
|
29
29
|
generate({
|
|
30
|
-
action
|
|
30
|
+
action,
|
|
31
|
+
params
|
|
31
32
|
}).catch((reason)=>{
|
|
32
|
-
console.error(
|
|
33
|
+
console.error(`AI Plugin — ${action}:`, reason);
|
|
33
34
|
}).finally(()=>{
|
|
34
35
|
setIsProcessing(false);
|
|
35
36
|
});
|
|
36
37
|
}, [
|
|
37
38
|
generate
|
|
38
39
|
]);
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
generate({
|
|
42
|
-
action: 'Expand'
|
|
43
|
-
}).catch((reason)=>{
|
|
44
|
-
console.error('Compose : ', reason);
|
|
45
|
-
}).finally(()=>{
|
|
46
|
-
setIsProcessing(false);
|
|
47
|
-
});
|
|
48
|
-
}, [
|
|
49
|
-
generate
|
|
40
|
+
const onCompose = useCallback(()=>createAction('Compose'), [
|
|
41
|
+
createAction
|
|
50
42
|
]);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
generate({
|
|
54
|
-
action: 'Proofread'
|
|
55
|
-
}).catch((reason)=>{
|
|
56
|
-
console.error('Compose : ', reason);
|
|
57
|
-
}).finally(()=>{
|
|
58
|
-
setIsProcessing(false);
|
|
59
|
-
});
|
|
60
|
-
}, [
|
|
61
|
-
generate
|
|
43
|
+
const onExpand = useCallback(()=>createAction('Expand'), [
|
|
44
|
+
createAction
|
|
62
45
|
]);
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
generate({
|
|
66
|
-
action: 'Rephrase'
|
|
67
|
-
}).catch((reason)=>{
|
|
68
|
-
console.error('Compose : ', reason);
|
|
69
|
-
}).finally(()=>{
|
|
70
|
-
setIsProcessing(false);
|
|
71
|
-
});
|
|
72
|
-
}, [
|
|
73
|
-
generate
|
|
46
|
+
const onProofread = useCallback(()=>createAction('Proofread'), [
|
|
47
|
+
createAction
|
|
74
48
|
]);
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
generate({
|
|
78
|
-
action: 'Simplify'
|
|
79
|
-
}).catch((reason)=>{
|
|
80
|
-
console.error('Compose : ', reason);
|
|
81
|
-
}).finally(()=>{
|
|
82
|
-
setIsProcessing(false);
|
|
83
|
-
});
|
|
84
|
-
}, [
|
|
85
|
-
generate
|
|
49
|
+
const onRephrase = useCallback(()=>createAction('Rephrase'), [
|
|
50
|
+
createAction
|
|
86
51
|
]);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
console.error('Compose : ', reason);
|
|
93
|
-
}).finally(()=>{
|
|
94
|
-
setIsProcessing(false);
|
|
95
|
-
});
|
|
96
|
-
}, [
|
|
97
|
-
generate
|
|
52
|
+
const onSimplify = useCallback(()=>createAction('Simplify'), [
|
|
53
|
+
createAction
|
|
54
|
+
]);
|
|
55
|
+
const onSummarize = useCallback(()=>createAction('Summarize'), [
|
|
56
|
+
createAction
|
|
98
57
|
]);
|
|
99
58
|
const onTranslate = useCallback((data)=>{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.error('Compose : ', reason);
|
|
106
|
-
}).finally(()=>{
|
|
107
|
-
setIsProcessing(false);
|
|
108
|
-
});
|
|
59
|
+
// If the action is triggered directly via the button click,
|
|
60
|
+
// it passes a React SyntheticEvent which cannot (and should not) be stringified.
|
|
61
|
+
// We only want to pass data if it's the actual payload containing { locale }.
|
|
62
|
+
const isEvent = data && typeof data === 'object' && 'nativeEvent' in data;
|
|
63
|
+
return createAction('Translate', isEvent ? undefined : data);
|
|
109
64
|
}, [
|
|
110
|
-
|
|
65
|
+
createAction
|
|
111
66
|
]);
|
|
112
67
|
const handleOpenSettings = useCallback(()=>{
|
|
113
68
|
if (isConfigAllowed) {
|
|
@@ -190,14 +145,22 @@ export const Compose = ({ descriptionProps, forceVisible, instructionId, isConfi
|
|
|
190
145
|
memoizedPopup,
|
|
191
146
|
/*#__PURE__*/ _jsx(ActiveComponent, {
|
|
192
147
|
isLoading: isProcessing || isLoading || isJobActive,
|
|
193
|
-
loadingLabel: isJobActive ? jobStatus === 'running' ?
|
|
148
|
+
loadingLabel: isJobActive ? jobStatus === 'running' ? `${t('ai-plugin:general:video')} ${Math.max(0, Math.min(100, Math.round(jobProgress ?? 0)))}%` : jobStatus || t('ai-plugin:general:queued') : undefined,
|
|
194
149
|
stop: stop
|
|
195
150
|
}),
|
|
196
|
-
/*#__PURE__*/ _jsx(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
151
|
+
/*#__PURE__*/ _jsx("div", {
|
|
152
|
+
style: {
|
|
153
|
+
alignItems: 'center',
|
|
154
|
+
display: 'flex',
|
|
155
|
+
gap: '10px',
|
|
156
|
+
marginLeft: 'auto'
|
|
157
|
+
},
|
|
158
|
+
children: /*#__PURE__*/ _jsx(UndoRedoActions, {
|
|
159
|
+
onChange: (val)=>{
|
|
160
|
+
setValue(val);
|
|
161
|
+
setIfValueIsLexicalState(val);
|
|
162
|
+
}
|
|
163
|
+
})
|
|
201
164
|
})
|
|
202
165
|
]
|
|
203
166
|
});
|