@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.
Files changed (341) hide show
  1. package/dist/ai/core/generateObject.js +1 -4
  2. package/dist/ai/core/generateObject.js.map +1 -1
  3. package/dist/ai/core/generateText.js +1 -5
  4. package/dist/ai/core/generateText.js.map +1 -1
  5. package/dist/ai/core/media/generateMedia.js +1 -4
  6. package/dist/ai/core/media/generateMedia.js.map +1 -1
  7. package/dist/ai/core/media/image/generateImage.js +4 -14
  8. package/dist/ai/core/media/image/generateImage.js.map +1 -1
  9. package/dist/ai/core/media/image/handlers/multimodal.js +7 -24
  10. package/dist/ai/core/media/image/handlers/multimodal.js.map +1 -1
  11. package/dist/ai/core/media/image/handlers/standard.js +7 -2
  12. package/dist/ai/core/media/image/handlers/standard.js.map +1 -1
  13. package/dist/ai/core/media/speech/generateSpeech.js +2 -3
  14. package/dist/ai/core/media/speech/generateSpeech.js.map +1 -1
  15. package/dist/ai/core/media/types.d.ts +2 -3
  16. package/dist/ai/core/media/types.js.map +1 -1
  17. package/dist/ai/core/streamObject.js +0 -3
  18. package/dist/ai/core/streamObject.js.map +1 -1
  19. package/dist/ai/core/streamText.js +1 -4
  20. package/dist/ai/core/streamText.js.map +1 -1
  21. package/dist/ai/core/types.d.ts +2 -2
  22. package/dist/ai/core/types.js.map +1 -1
  23. package/dist/ai/providers/blocks/anthropic.js +2 -44
  24. package/dist/ai/providers/blocks/anthropic.js.map +1 -1
  25. package/dist/ai/providers/blocks/elevenlabs.js +4 -109
  26. package/dist/ai/providers/blocks/elevenlabs.js.map +1 -1
  27. package/dist/ai/providers/blocks/fal.js +2 -120
  28. package/dist/ai/providers/blocks/fal.js.map +1 -1
  29. package/dist/ai/providers/blocks/google.js +6 -240
  30. package/dist/ai/providers/blocks/google.js.map +1 -1
  31. package/dist/ai/providers/blocks/openai-compatible.js +2 -146
  32. package/dist/ai/providers/blocks/openai-compatible.js.map +1 -1
  33. package/dist/ai/providers/blocks/openai.js +2 -202
  34. package/dist/ai/providers/blocks/openai.js.map +1 -1
  35. package/dist/ai/providers/blocks/xai.js +2 -55
  36. package/dist/ai/providers/blocks/xai.js.map +1 -1
  37. package/dist/ai/providers/index.d.ts +1 -1
  38. package/dist/ai/providers/index.js +0 -2
  39. package/dist/ai/providers/index.js.map +1 -1
  40. package/dist/ai/providers/registry.d.ts +24 -28
  41. package/dist/ai/providers/registry.js +184 -138
  42. package/dist/ai/providers/registry.js.map +1 -1
  43. package/dist/ai/providers/types.d.ts +12 -33
  44. package/dist/ai/providers/types.js +0 -1
  45. package/dist/ai/providers/types.js.map +1 -1
  46. package/dist/ai/schemas/lexicalJsonSchema.js +1 -1
  47. package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
  48. package/dist/ai/utilities/filterEditorSchemaByNodes.js.map +1 -0
  49. package/dist/ai/utilities/generateFileNameByPrompt.js.map +1 -0
  50. package/dist/ai/utilities/isObjectSchema.js.map +1 -0
  51. package/dist/ai/{utils → utilities}/nodeToSchemaMap.js +6 -6
  52. package/dist/ai/utilities/nodeToSchemaMap.js.map +1 -0
  53. package/dist/ai/{prompts.d.ts → utilities/prompts.d.ts} +1 -1
  54. package/dist/ai/utilities/prompts.js.map +1 -0
  55. package/dist/ai/utilities/systemGenerate.js.map +1 -0
  56. package/dist/collections/AIJobs.js +3 -12
  57. package/dist/collections/AIJobs.js.map +1 -1
  58. package/dist/collections/AIProviders.js +56 -29
  59. package/dist/collections/AIProviders.js.map +1 -1
  60. package/dist/collections/Instructions.js +91 -59
  61. package/dist/collections/Instructions.js.map +1 -1
  62. package/dist/collections/shared.d.ts +30 -0
  63. package/dist/collections/shared.js +15 -0
  64. package/dist/collections/shared.js.map +1 -0
  65. package/dist/endpoints/fetchFields.js +14 -6
  66. package/dist/endpoints/fetchFields.js.map +1 -1
  67. package/dist/endpoints/fetchVoices.js +1 -1
  68. package/dist/endpoints/fetchVoices.js.map +1 -1
  69. package/dist/endpoints/generate.d.ts +7 -0
  70. package/dist/endpoints/generate.js +268 -0
  71. package/dist/endpoints/generate.js.map +1 -0
  72. package/dist/endpoints/index.js +9 -639
  73. package/dist/endpoints/index.js.map +1 -1
  74. package/dist/endpoints/promptMentions.d.ts +2 -0
  75. package/dist/endpoints/promptMentions.js +166 -0
  76. package/dist/endpoints/promptMentions.js.map +1 -0
  77. package/dist/endpoints/upload.d.ts +7 -0
  78. package/dist/endpoints/upload.js +294 -0
  79. package/dist/endpoints/upload.js.map +1 -0
  80. package/dist/endpoints/videogenWebhook.d.ts +7 -0
  81. package/dist/endpoints/videogenWebhook.js +132 -0
  82. package/dist/endpoints/videogenWebhook.js.map +1 -0
  83. package/dist/exports/client.d.ts +2 -1
  84. package/dist/exports/client.js +2 -1
  85. package/dist/exports/client.js.map +1 -1
  86. package/dist/exports/fields.d.ts +2 -1
  87. package/dist/exports/fields.js +2 -1
  88. package/dist/exports/fields.js.map +1 -1
  89. package/dist/fields/ArrayComposeField/ArrayComposeField.js +1 -1
  90. package/dist/fields/ArrayComposeField/ArrayComposeField.js.map +1 -1
  91. package/dist/fields/ArrayComposeField/ArrayComposeField.jsx +1 -1
  92. package/dist/fields/ComposeField/ComposeField.d.ts +1 -0
  93. package/dist/fields/ComposeField/ComposeField.js +18 -8
  94. package/dist/fields/ComposeField/ComposeField.js.map +1 -1
  95. package/dist/fields/ComposeField/ComposeField.jsx +12 -7
  96. package/dist/fields/LexicalEditor/feature.server.js +1 -1
  97. package/dist/fields/LexicalEditor/feature.server.js.map +1 -1
  98. package/dist/fields/PromptEditorField/feature.client.d.ts +1 -0
  99. package/dist/fields/PromptEditorField/feature.client.js +173 -0
  100. package/dist/fields/PromptEditorField/feature.client.js.map +1 -0
  101. package/dist/fields/PromptEditorField/feature.client.jsx +148 -0
  102. package/dist/fields/PromptEditorField/feature.server.d.ts +1 -0
  103. package/dist/fields/PromptEditorField/feature.server.js +30 -0
  104. package/dist/fields/PromptEditorField/feature.server.js.map +1 -0
  105. package/dist/fields/PromptField.d.ts +4 -0
  106. package/dist/fields/PromptField.js +18 -0
  107. package/dist/fields/PromptField.js.map +1 -0
  108. package/dist/fields/SelectField/SelectField.js +0 -1
  109. package/dist/fields/SelectField/SelectField.js.map +1 -1
  110. package/dist/fields/SelectField/SelectField.jsx +0 -1
  111. package/dist/index.d.ts +4 -3
  112. package/dist/index.js +4 -2
  113. package/dist/index.js.map +1 -1
  114. package/dist/libraries/handlebars/helpers.js +2 -2
  115. package/dist/libraries/handlebars/helpers.js.map +1 -1
  116. package/dist/libraries/handlebars/replacePlaceholders.js +5 -1
  117. package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -1
  118. package/dist/payload-ai.d.ts +5 -19
  119. package/dist/plugin.js +18 -21
  120. package/dist/plugin.js.map +1 -1
  121. package/dist/providers/FieldProvider/FieldProvider.js +11 -20
  122. package/dist/providers/FieldProvider/FieldProvider.js.map +1 -1
  123. package/dist/providers/FieldProvider/FieldProvider.jsx +8 -18
  124. package/dist/providers/InstructionsProvider/InstructionsProvider.js +5 -2
  125. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  126. package/dist/providers/InstructionsProvider/InstructionsProvider.jsx +5 -2
  127. package/dist/translations/de.json +47 -0
  128. package/dist/translations/en.json +45 -2
  129. package/dist/translations/es.json +45 -2
  130. package/dist/translations/fa.json +45 -2
  131. package/dist/translations/fr.json +46 -3
  132. package/dist/translations/hi.json +47 -0
  133. package/dist/translations/index.d.ts +88 -26
  134. package/dist/translations/index.js +18 -32
  135. package/dist/translations/index.js.map +1 -1
  136. package/dist/translations/ja.json +47 -0
  137. package/dist/translations/nb.json +47 -0
  138. package/dist/translations/nl.json +47 -0
  139. package/dist/translations/pl.json +45 -2
  140. package/dist/translations/pt.json +47 -0
  141. package/dist/translations/ru.json +45 -2
  142. package/dist/translations/th.json +47 -0
  143. package/dist/translations/translation-schema.json +184 -11
  144. package/dist/translations/uk.json +45 -2
  145. package/dist/translations/zh.json +47 -0
  146. package/dist/types.d.ts +64 -28
  147. package/dist/types.js.map +1 -1
  148. package/dist/ui/Compose/Compose.js +42 -79
  149. package/dist/ui/Compose/Compose.js.map +1 -1
  150. package/dist/ui/Compose/Compose.jsx +32 -86
  151. package/dist/ui/Compose/ComposePlaceholder.js +1 -1
  152. package/dist/ui/Compose/ComposePlaceholder.js.map +1 -1
  153. package/dist/ui/Compose/ComposePlaceholder.jsx +1 -1
  154. package/dist/ui/Compose/{compose.module.css → compose.module.scss} +3 -5
  155. package/dist/ui/Compose/hooks/menu/Item.d.ts +1 -1
  156. package/dist/ui/Compose/hooks/menu/Item.js +7 -3
  157. package/dist/ui/Compose/hooks/menu/Item.js.map +1 -1
  158. package/dist/ui/Compose/hooks/menu/Item.jsx +11 -5
  159. package/dist/ui/Compose/hooks/menu/TranslateMenu.js +15 -5
  160. package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
  161. package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +11 -5
  162. package/dist/ui/Compose/hooks/menu/items.d.ts +8 -8
  163. package/dist/ui/Compose/hooks/menu/itemsMap.d.ts +2 -1
  164. package/dist/ui/Compose/hooks/menu/itemsMap.js.map +1 -1
  165. package/dist/ui/Compose/hooks/menu/types.d.ts +21 -0
  166. package/dist/ui/Compose/hooks/menu/types.js +3 -0
  167. package/dist/ui/Compose/hooks/menu/types.js.map +1 -0
  168. package/dist/ui/Compose/hooks/menu/useMenu.d.ts +2 -2
  169. package/dist/ui/Compose/hooks/menu/useMenu.js +45 -23
  170. package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
  171. package/dist/ui/Compose/hooks/menu/useMenu.jsx +43 -23
  172. package/dist/ui/Compose/hooks/mergeGeneratedValue.d.ts +14 -0
  173. package/dist/ui/Compose/hooks/mergeGeneratedValue.js +38 -0
  174. package/dist/ui/Compose/hooks/mergeGeneratedValue.js.map +1 -0
  175. package/dist/ui/Compose/hooks/useGenerate.js +37 -12
  176. package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
  177. package/dist/ui/Compose/hooks/useGenerateUpload.js +66 -24
  178. package/dist/ui/Compose/hooks/useGenerateUpload.js.map +1 -1
  179. package/dist/ui/Compose/hooks/useHistory.js +1 -1
  180. package/dist/ui/Compose/hooks/useHistory.js.map +1 -1
  181. package/dist/ui/Compose/hooks/useStreamingUpdate.js +4 -4
  182. package/dist/ui/Compose/hooks/useStreamingUpdate.js.map +1 -1
  183. package/dist/ui/ConfigDashboard/configDashboard.module.css +94 -0
  184. package/dist/ui/ConfigDashboard/index.js +27 -92
  185. package/dist/ui/ConfigDashboard/index.js.map +1 -1
  186. package/dist/ui/ConfigDashboard/index.jsx +24 -77
  187. package/dist/ui/DynamicModelSelect/index.js +6 -27
  188. package/dist/ui/DynamicModelSelect/index.js.map +1 -1
  189. package/dist/ui/DynamicModelSelect/index.jsx +6 -29
  190. package/dist/ui/DynamicProviderSelect/index.js +6 -27
  191. package/dist/ui/DynamicProviderSelect/index.js.map +1 -1
  192. package/dist/ui/DynamicProviderSelect/index.jsx +6 -29
  193. package/dist/ui/DynamicVoiceSelect/index.js +34 -83
  194. package/dist/ui/DynamicVoiceSelect/index.js.map +1 -1
  195. package/dist/ui/DynamicVoiceSelect/index.jsx +16 -53
  196. package/dist/ui/GlobalProviderOptions/index.d.ts +2 -0
  197. package/dist/ui/GlobalProviderOptions/index.js +118 -0
  198. package/dist/ui/GlobalProviderOptions/index.js.map +1 -0
  199. package/dist/ui/GlobalProviderOptions/index.jsx +60 -0
  200. package/dist/ui/Icons/Icons.js +1 -1
  201. package/dist/ui/Icons/Icons.js.map +1 -1
  202. package/dist/ui/Icons/Icons.jsx +1 -1
  203. package/dist/ui/Icons/LottieAnimation.js +1 -1
  204. package/dist/ui/Icons/LottieAnimation.js.map +1 -1
  205. package/dist/ui/Icons/LottieAnimation.jsx +1 -1
  206. package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.d.ts +12 -0
  207. package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.js +166 -0
  208. package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.js.map +1 -0
  209. package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.jsx +83 -0
  210. package/dist/ui/InstructionProviderOptions/index.d.ts +2 -0
  211. package/dist/ui/InstructionProviderOptions/index.js +157 -0
  212. package/dist/ui/InstructionProviderOptions/index.js.map +1 -0
  213. package/dist/ui/InstructionProviderOptions/index.jsx +92 -0
  214. package/dist/ui/VoicesFetcher/index.js.map +1 -1
  215. package/dist/ui/hooks/useAISettings.d.ts +26 -0
  216. package/dist/ui/hooks/useAISettings.js +73 -0
  217. package/dist/ui/hooks/useAISettings.js.map +1 -0
  218. package/dist/ui/providerOptions/updateProviderOptionsValue.d.ts +6 -0
  219. package/dist/ui/providerOptions/updateProviderOptionsValue.js +50 -0
  220. package/dist/ui/providerOptions/updateProviderOptionsValue.js.map +1 -0
  221. package/dist/ui/shared/handleSelectChange.d.ts +5 -0
  222. package/dist/ui/shared/handleSelectChange.js +12 -0
  223. package/dist/ui/shared/handleSelectChange.js.map +1 -0
  224. package/dist/ui/shared/types.d.ts +11 -0
  225. package/dist/ui/shared/types.js +5 -0
  226. package/dist/ui/shared/types.js.map +1 -0
  227. package/dist/utilities/ai/resolveEffectiveInstructionSettings.d.ts +15 -0
  228. package/dist/utilities/ai/resolveEffectiveInstructionSettings.js +136 -0
  229. package/dist/utilities/ai/resolveEffectiveInstructionSettings.js.map +1 -0
  230. package/dist/{endpoints → utilities}/buildPromptUtils.js +14 -5
  231. package/dist/utilities/buildPromptUtils.js.map +1 -0
  232. package/dist/utilities/buildSmartPrompt.js +3 -3
  233. package/dist/utilities/buildSmartPrompt.js.map +1 -1
  234. package/dist/utilities/fields/fieldToJsonSchema.js.map +1 -0
  235. package/dist/utilities/fields/getFieldBySchemaPath.js.map +1 -0
  236. package/dist/utilities/fields/getFieldInfo.js.map +1 -0
  237. package/dist/utilities/{updateFieldsConfig.js → fields/updateFieldsConfig.js} +8 -3
  238. package/dist/utilities/fields/updateFieldsConfig.js.map +1 -0
  239. package/dist/utilities/images/extractImageData.js.map +1 -0
  240. package/dist/utilities/images/extractPromptAttachments.js.map +1 -0
  241. package/dist/utilities/{fetchImages.d.ts → images/fetchImages.d.ts} +1 -1
  242. package/dist/utilities/images/fetchImages.js +49 -0
  243. package/dist/utilities/images/fetchImages.js.map +1 -0
  244. package/dist/utilities/images/resolveImageReferences.js +183 -0
  245. package/dist/utilities/images/resolveImageReferences.js.map +1 -0
  246. package/dist/utilities/init/autoSetupProviders.d.ts +3 -0
  247. package/dist/utilities/init/autoSetupProviders.js +216 -0
  248. package/dist/utilities/init/autoSetupProviders.js.map +1 -0
  249. package/dist/utilities/lexical/editorSchemaValidator.js.map +1 -0
  250. package/dist/utilities/lexical/lexicalToHTML.js.map +1 -0
  251. package/dist/utilities/lexical/lexicalToPromptTemplate.d.ts +2 -0
  252. package/dist/utilities/lexical/lexicalToPromptTemplate.js +50 -0
  253. package/dist/utilities/lexical/lexicalToPromptTemplate.js.map +1 -0
  254. package/dist/utilities/lexical/setSafeLexicalState.js.map +1 -0
  255. package/dist/utilities/lexical/stringToLexicalJSON.d.ts +2 -0
  256. package/dist/utilities/lexical/stringToLexicalJSON.js +39 -0
  257. package/dist/utilities/lexical/stringToLexicalJSON.js.map +1 -0
  258. package/dist/utilities/sanitizeLog.d.ts +1 -0
  259. package/dist/utilities/sanitizeLog.js +39 -0
  260. package/dist/utilities/sanitizeLog.js.map +1 -0
  261. package/dist/utilities/seedProperties.js +54 -22
  262. package/dist/utilities/seedProperties.js.map +1 -1
  263. package/package.json +36 -2
  264. package/dist/ai/analyse.d.ts +0 -1
  265. package/dist/ai/analyse.js +0 -3
  266. package/dist/ai/analyse.js.map +0 -1
  267. package/dist/ai/index.d.ts +0 -11
  268. package/dist/ai/index.js +0 -25
  269. package/dist/ai/index.js.map +0 -1
  270. package/dist/ai/prompts.js.map +0 -1
  271. package/dist/ai/utils/filterEditorSchemaByNodes.js.map +0 -1
  272. package/dist/ai/utils/generateFileNameByPrompt.js.map +0 -1
  273. package/dist/ai/utils/isObjectSchema.js.map +0 -1
  274. package/dist/ai/utils/nodeToSchemaMap.js.map +0 -1
  275. package/dist/ai/utils/systemGenerate.js.map +0 -1
  276. package/dist/endpoints/buildPromptUtils.js.map +0 -1
  277. package/dist/endpoints/chat.d.ts +0 -4
  278. package/dist/fields/PromptEditorField/PromptEditorField.d.ts +0 -3
  279. package/dist/fields/PromptEditorField/PromptEditorField.js +0 -217
  280. package/dist/fields/PromptEditorField/PromptEditorField.js.map +0 -1
  281. package/dist/fields/PromptEditorField/PromptEditorField.jsx +0 -160
  282. package/dist/ui/AIConfigDashboard/index.d.ts +0 -2
  283. package/dist/ui/AIConfigDashboard/index.js +0 -224
  284. package/dist/ui/AIConfigDashboard/index.js.map +0 -1
  285. package/dist/ui/AIConfigDashboard/index.jsx +0 -175
  286. package/dist/ui/ProviderOptionsEditor/index.d.ts +0 -7
  287. package/dist/ui/ProviderOptionsEditor/index.js +0 -291
  288. package/dist/ui/ProviderOptionsEditor/index.js.map +0 -1
  289. package/dist/ui/ProviderOptionsEditor/index.jsx +0 -210
  290. package/dist/utilities/editorSchemaValidator.js.map +0 -1
  291. package/dist/utilities/extractImageData.js.map +0 -1
  292. package/dist/utilities/extractPromptAttachments.js.map +0 -1
  293. package/dist/utilities/fetchImages.js +0 -38
  294. package/dist/utilities/fetchImages.js.map +0 -1
  295. package/dist/utilities/fieldToJsonSchema.js.map +0 -1
  296. package/dist/utilities/getFieldBySchemaPath.js.map +0 -1
  297. package/dist/utilities/getFieldInfo.js.map +0 -1
  298. package/dist/utilities/getProviderOptionsFields.d.ts +0 -16
  299. package/dist/utilities/getProviderOptionsFields.js +0 -80
  300. package/dist/utilities/getProviderOptionsFields.js.map +0 -1
  301. package/dist/utilities/isPluginActivated.d.ts +0 -2
  302. package/dist/utilities/isPluginActivated.js +0 -5
  303. package/dist/utilities/isPluginActivated.js.map +0 -1
  304. package/dist/utilities/lexicalToHTML.js.map +0 -1
  305. package/dist/utilities/resolveImageReferences.js +0 -167
  306. package/dist/utilities/resolveImageReferences.js.map +0 -1
  307. package/dist/utilities/schemaConverter.d.ts +0 -3
  308. package/dist/utilities/schemaConverter.js +0 -93
  309. package/dist/utilities/schemaConverter.js.map +0 -1
  310. package/dist/utilities/setSafeLexicalState.js.map +0 -1
  311. package/dist/utilities/updateFieldsConfig.js.map +0 -1
  312. /package/dist/ai/{utils → utilities}/filterEditorSchemaByNodes.d.ts +0 -0
  313. /package/dist/ai/{utils → utilities}/filterEditorSchemaByNodes.js +0 -0
  314. /package/dist/ai/{utils → utilities}/generateFileNameByPrompt.d.ts +0 -0
  315. /package/dist/ai/{utils → utilities}/generateFileNameByPrompt.js +0 -0
  316. /package/dist/ai/{utils → utilities}/isObjectSchema.d.ts +0 -0
  317. /package/dist/ai/{utils → utilities}/isObjectSchema.js +0 -0
  318. /package/dist/ai/{utils → utilities}/nodeToSchemaMap.d.ts +0 -0
  319. /package/dist/ai/{prompts.js → utilities/prompts.js} +0 -0
  320. /package/dist/ai/{utils → utilities}/systemGenerate.d.ts +0 -0
  321. /package/dist/ai/{utils → utilities}/systemGenerate.js +0 -0
  322. /package/dist/ui/Icons/{icons.module.css → icons.module.scss} +0 -0
  323. /package/dist/{endpoints → utilities}/buildPromptUtils.d.ts +0 -0
  324. /package/dist/utilities/{fieldToJsonSchema.d.ts → fields/fieldToJsonSchema.d.ts} +0 -0
  325. /package/dist/utilities/{fieldToJsonSchema.js → fields/fieldToJsonSchema.js} +0 -0
  326. /package/dist/utilities/{getFieldBySchemaPath.d.ts → fields/getFieldBySchemaPath.d.ts} +0 -0
  327. /package/dist/utilities/{getFieldBySchemaPath.js → fields/getFieldBySchemaPath.js} +0 -0
  328. /package/dist/utilities/{getFieldInfo.d.ts → fields/getFieldInfo.d.ts} +0 -0
  329. /package/dist/utilities/{getFieldInfo.js → fields/getFieldInfo.js} +0 -0
  330. /package/dist/utilities/{updateFieldsConfig.d.ts → fields/updateFieldsConfig.d.ts} +0 -0
  331. /package/dist/utilities/{extractImageData.d.ts → images/extractImageData.d.ts} +0 -0
  332. /package/dist/utilities/{extractImageData.js → images/extractImageData.js} +0 -0
  333. /package/dist/utilities/{extractPromptAttachments.d.ts → images/extractPromptAttachments.d.ts} +0 -0
  334. /package/dist/utilities/{extractPromptAttachments.js → images/extractPromptAttachments.js} +0 -0
  335. /package/dist/utilities/{resolveImageReferences.d.ts → images/resolveImageReferences.d.ts} +0 -0
  336. /package/dist/utilities/{editorSchemaValidator.d.ts → lexical/editorSchemaValidator.d.ts} +0 -0
  337. /package/dist/utilities/{editorSchemaValidator.js → lexical/editorSchemaValidator.js} +0 -0
  338. /package/dist/utilities/{lexicalToHTML.d.ts → lexical/lexicalToHTML.d.ts} +0 -0
  339. /package/dist/utilities/{lexicalToHTML.js → lexical/lexicalToHTML.js} +0 -0
  340. /package/dist/utilities/{setSafeLexicalState.d.ts → lexical/setSafeLexicalState.d.ts} +0 -0
  341. /package/dist/utilities/{setSafeLexicalState.js → lexical/setSafeLexicalState.js} +0 -0
@@ -1,16 +1,189 @@
1
1
  {
2
- "type": "object",
3
- "$schema": "http://json-schema.org/draft-04/schema#",
4
- "additionalProperties": false,
5
- "properties": {
6
- "$schema": {
7
- "type": "string"
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
- "type": "object",
11
- "additionalProperties": false,
12
- "properties": {}
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
- "$schema": "./translation-schema.json",
3
- "ai-plugin": {}
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 { CollectionConfig, CollectionSlug, DataFromCollectionSlug, Endpoint, Field, File, GlobalConfig, GroupField, PayloadRequest, TypedCollection } from 'payload';
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?: Partial<CollectionConfig>;
57
- promptFields?: PromptField[];
78
+ overrideInstructions?: any;
79
+ promptFields?: any[];
80
+ prompts?: ActionPrompt[];
58
81
  /**
59
- * Custom action prompts for AI text generation
60
- * If not provided, uses default prompts
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
- prompts?: ActionPrompt[];
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'\nimport type { CSSProperties, MouseEventHandler } from 'react'\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 generationModels?: ((defaultModels: GenerationModel[]) => GenerationModel[]) | GenerationModel[]\n globals?: {\n [key: GlobalConfig['slug']]: boolean\n }\n interfaceName?: string\n mediaUpload?: PluginConfigMediaUploadFunction\n options?: PluginOptions\n // Override the instructions collection config\n overrideInstructions?: Partial<CollectionConfig>\n promptFields?: PromptField[]\n /**\n * Custom action prompts for AI text generation\n * If not provided, uses default prompts\n * You can access default prompts by importing { defaultPrompts } from '@ai-stack/payloadcms'\n */\n prompts?: ActionPrompt[]\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 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 ActionMenuEvents =\n | 'onCompose'\n | 'onExpand'\n | 'onProofread'\n | 'onRephrase'\n | 'onSettings'\n | 'onSimplify'\n | 'onSummarize'\n | 'onTone'\n | 'onTranslate'\n\nexport type UseMenuEvents = {\n [key in ActionMenuEvents]?: (data?: unknown) => void\n}\n\nexport type UseMenuOptions = {\n isConfigAllowed: boolean\n}\n\nexport type BaseItemProps<T = any> = {\n children?: React.ReactNode\n className?: string\n disabled?: boolean\n hideIcon?: boolean\n isActive?: boolean\n isMenu?: boolean\n onClick: (data?: unknown) => void\n onMouseEnter?: MouseEventHandler<T> | undefined\n onMouseLeave?: MouseEventHandler<T> | undefined\n style?: CSSProperties | undefined\n title?: string\n}\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 beforeGenerate?: BeforeGenerateHook[]\n}\n"],"names":[],"mappings":"AA6QA,mEAAmE;AACnE,WAIC"}
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.css';
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
- // Memoize menu event handlers to prevent recreation on every render
26
- const onCompose = useCallback(()=>{
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: 'Compose'
30
+ action,
31
+ params
31
32
  }).catch((reason)=>{
32
- console.error('Compose : ', reason);
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 onExpand = useCallback(()=>{
40
- console.log('Expanding...');
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 onProofread = useCallback(()=>{
52
- console.log('Proofreading...');
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 onRephrase = useCallback(()=>{
64
- console.log('Rephrasing...');
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 onSimplify = useCallback(()=>{
76
- console.log('Simplifying...');
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 onSummarize = useCallback(()=>{
88
- console.log('Summarizing...');
89
- generate({
90
- action: 'Summarize'
91
- }).catch((reason)=>{
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
- console.log('Translating...');
101
- generate({
102
- action: 'Translate',
103
- params: data
104
- }).catch((reason)=>{
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
- generate
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' ? `Video ${Math.max(0, Math.min(100, Math.round(jobProgress ?? 0)))}%` : jobStatus || 'Queued' : undefined,
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(UndoRedoActions, {
197
- onChange: (val)=>{
198
- setValue(val);
199
- setIfValueIsLexicalState(val);
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
  });