@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,160 +0,0 @@
1
- 'use client';
2
- import { FieldDescription, FieldLabel, useConfig, useField } from '@payloadcms/ui';
3
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { Mention, MentionsInput } from 'react-mentions/dist/react-mentions.cjs.js';
5
- import { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js';
6
- import { defaultStyle } from './defaultStyle.js';
7
- export const PromptEditorField = (props) => {
8
- const { field, path: pathFromContext } = props;
9
- const { setValue, value: payloadValue } = useField({
10
- path: pathFromContext,
11
- });
12
- const [localValue, setLocalValue] = useState(payloadValue || '');
13
- const hasInitialized = useRef(false);
14
- const { activeCollection, promptEditorSuggestions } = useInstructions();
15
- const { config } = useConfig();
16
- const suggestions = useMemo(() => promptEditorSuggestions.map((suggestion) => ({
17
- id: suggestion,
18
- display: suggestion,
19
- })), [promptEditorSuggestions]);
20
- // Extract document ID from URL if available (to get specific filenames)
21
- const [documentData, setDocumentData] = useState(null);
22
- useEffect(() => {
23
- // Only run in browser
24
- if (typeof window === 'undefined') {
25
- return;
26
- }
27
- // Allow time for verify window.location is stable (unlikely to change but good practice)
28
- const segments = window.location.pathname.split('/');
29
- const collectionsIndex = segments.indexOf('collections');
30
- if (collectionsIndex > -1 && segments.length > collectionsIndex + 2) {
31
- const urlCollectionSlug = segments[collectionsIndex + 1];
32
- const urlId = segments[collectionsIndex + 2];
33
- // Only fetch if we are editing instructions for the same collection we are viewing
34
- // and we haven't fetched yet (or ID changed)
35
- if (urlCollectionSlug === activeCollection && urlId && urlId !== 'create') {
36
- const fetchDocument = async () => {
37
- try {
38
- const response = await fetch(`${String(config.serverURL)}${String(config.routes.api)}/${String(urlCollectionSlug)}/${String(urlId)}`);
39
- if (response.ok) {
40
- const data = await response.json();
41
- setDocumentData(data);
42
- }
43
- }
44
- catch (_err) {
45
- // Ignore error
46
- }
47
- };
48
- void fetchDocument();
49
- }
50
- }
51
- }, [activeCollection, config]);
52
- // Extract all upload fields from the current collection schema
53
- const imageFieldSuggestions = useMemo(() => {
54
- const suggestions = [];
55
- // Use activeCollection from context which holds the target collection slug
56
- const targetSlug = activeCollection;
57
- if (!targetSlug || !config?.collections) {
58
- return [];
59
- }
60
- const collection = config.collections.find((c) => c.slug === targetSlug);
61
- if (!collection?.fields) {
62
- return [];
63
- }
64
- const uploadFields = [];
65
- // Recursive function to find upload fields
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
- const findUploadFields = (fields, prefix = '') => {
68
- for (const field of fields) {
69
- if (field.type === 'upload' && field.name) {
70
- const fieldPath = prefix ? `${prefix}.${String(field.name)}` : String(field.name);
71
- uploadFields.push({ name: fieldPath, hasMany: field.hasMany === true });
72
- }
73
- // Check nested fields in groups, arrays, etc.
74
- if (field.fields && Array.isArray(field.fields)) {
75
- const newPrefix = field.name ? (prefix ? `${prefix}.${String(field.name)}` : String(field.name)) : prefix;
76
- findUploadFields(field.fields, newPrefix);
77
- }
78
- }
79
- };
80
- findUploadFields(collection.fields);
81
- // Add generic field names (base suggestions) - ONLY for single uploads (not hasMany arrays)
82
- uploadFields.forEach(({ name, hasMany }) => {
83
- // User requested to hide the array itself for hasMany fields
84
- if (!hasMany) {
85
- suggestions.push({ id: name, display: name });
86
- }
87
- });
88
- // If we have document data, add specific filename suggestions
89
- if (documentData) {
90
- uploadFields.forEach(({ name, hasMany }) => {
91
- const value = documentData[name]; // Note: nested access logic simplified for now
92
- // Helper to extract filename from media doc (which might be ID or object)
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
- const getFilename = (item) => {
95
- if (typeof item === 'object' && item && (item.filename || item.name)) {
96
- return item.filename || item.name;
97
- }
98
- // If it's just an ID, we can't show filename without populating.
99
- // Assuming compose view usually fetches with depth > 0 or we rely on what we have.
100
- return null;
101
- };
102
- if (value) {
103
- if (hasMany && Array.isArray(value)) {
104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
- value.forEach((item) => {
106
- const fname = getFilename(item);
107
- if (fname) {
108
- const suggestion = `${name}:${fname}`;
109
- suggestions.push({ id: suggestion, display: suggestion });
110
- }
111
- });
112
- }
113
- else if (!hasMany) {
114
- // Single image - we already added the base name above.
115
- // We can optionally add the specific filename too if desired,
116
- // but user request focused on arrays.
117
- // Adding the specific filename option for Single images too as it's explicit.
118
- const fname = getFilename(value);
119
- if (fname) {
120
- const suggestion = `${name}:${fname}`;
121
- suggestions.push({ id: suggestion, display: suggestion });
122
- }
123
- }
124
- }
125
- });
126
- }
127
- return suggestions;
128
- }, [activeCollection, config, documentData]);
129
- useEffect(() => {
130
- if (!hasInitialized.current || payloadValue === '') {
131
- setLocalValue(payloadValue || '');
132
- hasInitialized.current = true;
133
- }
134
- }, [payloadValue]);
135
- const handleChange = useCallback((e) => {
136
- const newValue = e.target.value;
137
- setLocalValue(newValue);
138
- // Also update Payload value immediately to prevent loss when Save is clicked
139
- setValue(newValue);
140
- }, [setValue]);
141
- const handleBlur = useCallback(() => {
142
- setValue(localValue);
143
- }, [localValue, setValue]);
144
- const displayTransform = useCallback((id) => `{{ ${id} }}`, []);
145
- const imageDisplayTransform = useCallback((id) => `@${id}`, []);
146
- return (<div className="field-type textarea">
147
- <FieldLabel label={field.label}/>
148
- <MentionsInput onBlur={handleBlur} onChange={handleChange} placeholder="Type {{ for fields }} or @imageField for images. For specific images use @imageField:filename.jpg" style={defaultStyle} value={localValue}>
149
- <Mention data={suggestions} displayTransform={displayTransform} markup="{{__id__}}" style={{
150
- backgroundColor: 'var(--theme-elevation-100)',
151
- padding: '2px 0',
152
- }} trigger="{"/>
153
- <Mention data={imageFieldSuggestions} displayTransform={imageDisplayTransform} markup="@__id__" style={{
154
- backgroundColor: 'var(--theme-elevation-150)',
155
- padding: '2px 0',
156
- }} trigger="@"/>
157
- </MentionsInput>
158
- <FieldDescription description={field?.admin?.description} path=""/>
159
- </div>);
160
- };
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const ConfigDashboard: React.FC;
@@ -1,224 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Button, toast, useConfig } from '@payloadcms/ui';
4
- // @ts-expect-error - Next.js types are not resolving correctly with nodenext but runtime is fine
5
- import { useRouter } from 'next/navigation';
6
- import React, { use, useEffect, useState } from 'react';
7
- import { excludeCollections } from '../../defaults.js';
8
- import { InstructionsContext } from '../../providers/InstructionsProvider/context.js';
9
- export const ConfigDashboard = ()=>{
10
- const { config: { collections, routes: { admin: adminRoute, api: apiRoute } } } = useConfig();
11
- const router = useRouter();
12
- const { refresh, setEnabledCollections: setEnabledCollectionsInContext } = use(InstructionsContext);
13
- const [enabledCollections, setEnabledCollections] = useState([]);
14
- const [isLoading, setIsLoading] = useState(true);
15
- const [isSaving, setIsSaving] = useState(false);
16
- const availableCollections = collections.filter((c)=>!excludeCollections.includes(c.slug) && !c.admin?.hidden);
17
- useEffect(()=>{
18
- const fetchSettings = async ()=>{
19
- try {
20
- const response = await fetch(`${apiRoute}/globals/ai-providers`);
21
- if (response.ok) {
22
- const data = await response.json();
23
- // Handle both simple array and object wrapper if Payload wraps it
24
- const storedEnabled = data.enabledCollections || [];
25
- setEnabledCollections(Array.isArray(storedEnabled) ? storedEnabled : []);
26
- }
27
- } catch (error) {
28
- console.error('Failed to fetch AI settings:', error);
29
- } finally{
30
- setIsLoading(false);
31
- }
32
- };
33
- fetchSettings().catch((e)=>{
34
- console.log(e);
35
- });
36
- }, [
37
- apiRoute
38
- ]);
39
- const handleToggle = (slug)=>{
40
- setEnabledCollections((prev)=>{
41
- if (prev.includes(slug)) {
42
- return prev.filter((s)=>s !== slug);
43
- }
44
- return [
45
- ...prev,
46
- slug
47
- ];
48
- });
49
- };
50
- const handleSave = async ()=>{
51
- setIsSaving(true);
52
- try {
53
- // First fetch current settings to get ID or just rely on global update behavior
54
- // We need to adhere to Payload's global update API
55
- const response = await fetch(`${apiRoute}/globals/ai-providers`, {
56
- body: JSON.stringify({
57
- enabledCollections
58
- }),
59
- headers: {
60
- 'Content-Type': 'application/json'
61
- },
62
- method: 'POST'
63
- });
64
- if (response.ok) {
65
- toast.success('Settings saved successfully');
66
- if (setEnabledCollectionsInContext) {
67
- setEnabledCollectionsInContext(enabledCollections);
68
- }
69
- if (refresh) {
70
- await refresh();
71
- }
72
- router.refresh();
73
- } else {
74
- toast.error('Failed to save settings');
75
- }
76
- } catch (error) {
77
- console.error('Error saving settings:', error);
78
- toast.error('Error saving settings');
79
- } finally{
80
- setIsSaving(false);
81
- }
82
- };
83
- if (isLoading) {
84
- return /*#__PURE__*/ _jsx("div", {
85
- style: {
86
- padding: '20px',
87
- textAlign: 'center'
88
- },
89
- children: "Loading configuration..."
90
- });
91
- }
92
- return /*#__PURE__*/ _jsxs("div", {
93
- style: {
94
- background: 'var(--theme-elevation-50)',
95
- // border: '1px solid var(--theme-elevation-150)',
96
- // borderRadius: '8px',
97
- // borderBottom: '1px solid var(--theme-elevation-150)',
98
- // borderTop: '1px solid var(--theme-elevation-150)',
99
- marginBottom: '20px',
100
- overflow: 'hidden'
101
- },
102
- children: [
103
- /*#__PURE__*/ _jsxs("div", {
104
- style: {
105
- alignItems: 'center',
106
- borderBottom: '1px solid var(--theme-elevation-150)',
107
- display: 'flex',
108
- justifyContent: 'space-between',
109
- padding: '8px var(--gutter-h)'
110
- },
111
- children: [
112
- /*#__PURE__*/ _jsxs("div", {
113
- children: [
114
- /*#__PURE__*/ _jsx("h2", {
115
- style: {
116
- margin: '0 0 5px 0'
117
- },
118
- children: "Let's configure your AI Plugin"
119
- }),
120
- /*#__PURE__*/ _jsx("p", {
121
- style: {
122
- color: 'var(--theme-elevation-500)',
123
- fontSize: '14px',
124
- margin: '0'
125
- },
126
- children: "Set up the provider → Choose the content → Refine the behavior."
127
- })
128
- ]
129
- }),
130
- /*#__PURE__*/ _jsxs("div", {
131
- style: {
132
- display: 'flex',
133
- gap: '10px'
134
- },
135
- children: [
136
- /*#__PURE__*/ _jsx(Button, {
137
- buttonStyle: "secondary",
138
- el: "link",
139
- to: `${adminRoute}/globals/ai-providers`,
140
- children: "Providers"
141
- }),
142
- /*#__PURE__*/ _jsx(Button, {
143
- disabled: isSaving,
144
- onClick: handleSave,
145
- children: isSaving ? 'Saving...' : 'Save Changes'
146
- })
147
- ]
148
- })
149
- ]
150
- }),
151
- /*#__PURE__*/ _jsxs("div", {
152
- style: {
153
- padding: '24px var(--gutter-h)'
154
- },
155
- children: [
156
- /*#__PURE__*/ _jsx("h5", {
157
- style: {
158
- marginBottom: '15px'
159
- },
160
- children: "Select the collections where AI features should be available, toggle them on or off, and save your changes."
161
- }),
162
- /*#__PURE__*/ _jsx("div", {
163
- style: {
164
- display: 'grid',
165
- gap: '15px',
166
- gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))'
167
- },
168
- children: availableCollections.map((collection)=>{
169
- const isEnabled = enabledCollections.includes(collection.slug);
170
- return /*#__PURE__*/ _jsxs("button", {
171
- onClick: ()=>handleToggle(collection.slug),
172
- style: {
173
- alignItems: 'center',
174
- background: isEnabled ? 'var(--theme-elevation-100)' : 'var(--theme-elevation-50)',
175
- border: `1px solid ${isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)'}`,
176
- borderRadius: '6px',
177
- cursor: 'pointer',
178
- display: 'flex',
179
- gap: '10px',
180
- padding: '10px 15px',
181
- textAlign: 'left',
182
- transition: 'all 0.2s ease',
183
- width: '100%'
184
- },
185
- type: "button",
186
- children: [
187
- /*#__PURE__*/ _jsx("div", {
188
- style: {
189
- alignItems: 'center',
190
- background: isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)',
191
- borderRadius: '12px',
192
- display: 'flex',
193
- height: '24px',
194
- justifyContent: isEnabled ? 'flex-end' : 'flex-start',
195
- padding: '2px',
196
- transition: 'all 0.2s ease',
197
- width: '44px'
198
- },
199
- children: /*#__PURE__*/ _jsx("div", {
200
- style: {
201
- background: 'white',
202
- borderRadius: '50%',
203
- height: '20px',
204
- width: '20px'
205
- }
206
- })
207
- }),
208
- /*#__PURE__*/ _jsx("span", {
209
- style: {
210
- fontWeight: 500
211
- },
212
- children: typeof collection.labels?.singular === 'string' ? collection.labels.singular : collection.labels?.singular?.en || collection.slug
213
- })
214
- ]
215
- }, collection.slug);
216
- })
217
- })
218
- ]
219
- })
220
- ]
221
- });
222
- };
223
-
224
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ui/AIConfigDashboard/index.tsx"],"sourcesContent":["'use client'\n\nimport { Button, toast, useConfig } from '@payloadcms/ui'\n// @ts-expect-error - Next.js types are not resolving correctly with nodenext but runtime is fine\nimport { useRouter } from 'next/navigation'\nimport React, { use, useEffect, useState } from 'react'\n\nimport { excludeCollections } from '../../defaults.js'\nimport { InstructionsContext } from '../../providers/InstructionsProvider/context.js'\n\nexport const ConfigDashboard: React.FC = () => {\n const {\n config: {\n collections,\n routes: { admin: adminRoute, api: apiRoute },\n },\n } = useConfig()\n const router = useRouter()\n const { refresh, setEnabledCollections: setEnabledCollectionsInContext } =\n use(InstructionsContext)\n\n const [enabledCollections, setEnabledCollections] = useState<string[]>([])\n const [isLoading, setIsLoading] = useState(true)\n const [isSaving, setIsSaving] = useState(false)\n\n const availableCollections = collections.filter(\n (c) =>\n !excludeCollections.includes(c.slug) &&\n !(c.admin as unknown as { hidden?: ((args: any) => boolean) | boolean })?.hidden,\n )\n\n useEffect(() => {\n const fetchSettings = async () => {\n try {\n const response = await fetch(`${apiRoute}/globals/ai-providers`)\n if (response.ok) {\n const data = await response.json()\n // Handle both simple array and object wrapper if Payload wraps it\n const storedEnabled = data.enabledCollections || []\n setEnabledCollections(Array.isArray(storedEnabled) ? storedEnabled : [])\n }\n } catch (error) {\n console.error('Failed to fetch AI settings:', error)\n } finally {\n setIsLoading(false)\n }\n }\n\n fetchSettings().catch((e) => {\n console.log(e)\n })\n }, [apiRoute])\n\n const handleToggle = (slug: string) => {\n setEnabledCollections((prev) => {\n if (prev.includes(slug)) {\n return prev.filter((s) => s !== slug)\n }\n return [...prev, slug]\n })\n }\n\n const handleSave = async () => {\n setIsSaving(true)\n try {\n // First fetch current settings to get ID or just rely on global update behavior\n // We need to adhere to Payload's global update API\n const response = await fetch(`${apiRoute}/globals/ai-providers`, {\n body: JSON.stringify({\n enabledCollections,\n }),\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n })\n\n if (response.ok) {\n toast.success('Settings saved successfully')\n if (setEnabledCollectionsInContext) {\n setEnabledCollectionsInContext(enabledCollections)\n }\n if (refresh) {\n await refresh()\n }\n router.refresh()\n } else {\n toast.error('Failed to save settings')\n }\n } catch (error) {\n console.error('Error saving settings:', error)\n toast.error('Error saving settings')\n } finally {\n setIsSaving(false)\n }\n }\n\n if (isLoading) {\n return <div style={{ padding: '20px', textAlign: 'center' }}>Loading configuration...</div>\n }\n\n return (\n <div\n style={{\n background: 'var(--theme-elevation-50)',\n // border: '1px solid var(--theme-elevation-150)',\n // borderRadius: '8px',\n // borderBottom: '1px solid var(--theme-elevation-150)',\n // borderTop: '1px solid var(--theme-elevation-150)',\n marginBottom: '20px',\n overflow: 'hidden',\n }}\n >\n <div\n style={{\n alignItems: 'center',\n borderBottom: '1px solid var(--theme-elevation-150)',\n display: 'flex',\n justifyContent: 'space-between',\n padding: '8px var(--gutter-h)',\n }}\n >\n <div>\n <h2 style={{ margin: '0 0 5px 0' }}>Let's configure your AI Plugin</h2>\n <p style={{ color: 'var(--theme-elevation-500)', fontSize: '14px', margin: '0' }}>\n Set up the provider → Choose the content → Refine the behavior.\n </p>\n </div>\n <div style={{ display: 'flex', gap: '10px' }}>\n <Button buttonStyle=\"secondary\" el=\"link\" to={`${adminRoute}/globals/ai-providers`}>\n Providers\n </Button>\n <Button disabled={isSaving} onClick={handleSave}>\n {isSaving ? 'Saving...' : 'Save Changes'}\n </Button>\n </div>\n </div>\n\n <div style={{ padding: '24px var(--gutter-h)' }}>\n <h5 style={{ marginBottom: '15px' }}>\n Select the collections where AI features should be available, toggle them on or off, and\n save your changes.\n </h5>\n <div\n style={{\n display: 'grid',\n gap: '15px',\n gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))',\n }}\n >\n {availableCollections.map((collection) => {\n const isEnabled = enabledCollections.includes(collection.slug)\n return (\n <button\n key={collection.slug}\n onClick={() => handleToggle(collection.slug)}\n style={{\n alignItems: 'center',\n background: isEnabled\n ? 'var(--theme-elevation-100)'\n : 'var(--theme-elevation-50)',\n border: `1px solid ${isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)'}`,\n borderRadius: '6px',\n cursor: 'pointer',\n display: 'flex',\n gap: '10px',\n padding: '10px 15px',\n textAlign: 'left',\n transition: 'all 0.2s ease',\n width: '100%',\n }}\n type=\"button\"\n >\n <div\n style={{\n alignItems: 'center',\n background: isEnabled\n ? 'var(--theme-text-success)'\n : 'var(--theme-elevation-200)',\n borderRadius: '12px',\n display: 'flex',\n height: '24px',\n justifyContent: isEnabled ? 'flex-end' : 'flex-start',\n padding: '2px',\n transition: 'all 0.2s ease',\n width: '44px',\n }}\n >\n <div\n style={{\n background: 'white',\n borderRadius: '50%',\n height: '20px',\n width: '20px',\n }}\n />\n </div>\n <span style={{ fontWeight: 500 }}>\n {typeof collection.labels?.singular === 'string'\n ? collection.labels.singular\n : collection.labels?.singular?.en || collection.slug}\n </span>\n </button>\n )\n })}\n </div>\n </div>\n </div>\n )\n}\n"],"names":["Button","toast","useConfig","useRouter","React","use","useEffect","useState","excludeCollections","InstructionsContext","ConfigDashboard","config","collections","routes","admin","adminRoute","api","apiRoute","router","refresh","setEnabledCollections","setEnabledCollectionsInContext","enabledCollections","isLoading","setIsLoading","isSaving","setIsSaving","availableCollections","filter","c","includes","slug","hidden","fetchSettings","response","fetch","ok","data","json","storedEnabled","Array","isArray","error","console","catch","e","log","handleToggle","prev","s","handleSave","body","JSON","stringify","headers","method","success","div","style","padding","textAlign","background","marginBottom","overflow","alignItems","borderBottom","display","justifyContent","h2","margin","p","color","fontSize","gap","buttonStyle","el","to","disabled","onClick","h5","gridTemplateColumns","map","collection","isEnabled","button","border","borderRadius","cursor","transition","width","type","height","span","fontWeight","labels","singular","en"],"mappings":"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"}
@@ -1,175 +0,0 @@
1
- 'use client';
2
- import { Button, toast, useConfig } from '@payloadcms/ui';
3
- // @ts-expect-error - Next.js types are not resolving correctly with nodenext but runtime is fine
4
- import { useRouter } from 'next/navigation';
5
- import React, { use, useEffect, useState } from 'react';
6
- import { excludeCollections } from '../../defaults.js';
7
- import { InstructionsContext } from '../../providers/InstructionsProvider/context.js';
8
- export const ConfigDashboard = () => {
9
- const { config: { collections, routes: { admin: adminRoute, api: apiRoute }, }, } = useConfig();
10
- const router = useRouter();
11
- const { refresh, setEnabledCollections: setEnabledCollectionsInContext } = use(InstructionsContext);
12
- const [enabledCollections, setEnabledCollections] = useState([]);
13
- const [isLoading, setIsLoading] = useState(true);
14
- const [isSaving, setIsSaving] = useState(false);
15
- const availableCollections = collections.filter((c) => !excludeCollections.includes(c.slug) &&
16
- !c.admin?.hidden);
17
- useEffect(() => {
18
- const fetchSettings = async () => {
19
- try {
20
- const response = await fetch(`${apiRoute}/globals/ai-providers`);
21
- if (response.ok) {
22
- const data = await response.json();
23
- // Handle both simple array and object wrapper if Payload wraps it
24
- const storedEnabled = data.enabledCollections || [];
25
- setEnabledCollections(Array.isArray(storedEnabled) ? storedEnabled : []);
26
- }
27
- }
28
- catch (error) {
29
- console.error('Failed to fetch AI settings:', error);
30
- }
31
- finally {
32
- setIsLoading(false);
33
- }
34
- };
35
- fetchSettings().catch((e) => {
36
- console.log(e);
37
- });
38
- }, [apiRoute]);
39
- const handleToggle = (slug) => {
40
- setEnabledCollections((prev) => {
41
- if (prev.includes(slug)) {
42
- return prev.filter((s) => s !== slug);
43
- }
44
- return [...prev, slug];
45
- });
46
- };
47
- const handleSave = async () => {
48
- setIsSaving(true);
49
- try {
50
- // First fetch current settings to get ID or just rely on global update behavior
51
- // We need to adhere to Payload's global update API
52
- const response = await fetch(`${apiRoute}/globals/ai-providers`, {
53
- body: JSON.stringify({
54
- enabledCollections,
55
- }),
56
- headers: {
57
- 'Content-Type': 'application/json',
58
- },
59
- method: 'POST',
60
- });
61
- if (response.ok) {
62
- toast.success('Settings saved successfully');
63
- if (setEnabledCollectionsInContext) {
64
- setEnabledCollectionsInContext(enabledCollections);
65
- }
66
- if (refresh) {
67
- await refresh();
68
- }
69
- router.refresh();
70
- }
71
- else {
72
- toast.error('Failed to save settings');
73
- }
74
- }
75
- catch (error) {
76
- console.error('Error saving settings:', error);
77
- toast.error('Error saving settings');
78
- }
79
- finally {
80
- setIsSaving(false);
81
- }
82
- };
83
- if (isLoading) {
84
- return <div style={{ padding: '20px', textAlign: 'center' }}>Loading configuration...</div>;
85
- }
86
- return (<div style={{
87
- background: 'var(--theme-elevation-50)',
88
- // border: '1px solid var(--theme-elevation-150)',
89
- // borderRadius: '8px',
90
- // borderBottom: '1px solid var(--theme-elevation-150)',
91
- // borderTop: '1px solid var(--theme-elevation-150)',
92
- marginBottom: '20px',
93
- overflow: 'hidden',
94
- }}>
95
- <div style={{
96
- alignItems: 'center',
97
- borderBottom: '1px solid var(--theme-elevation-150)',
98
- display: 'flex',
99
- justifyContent: 'space-between',
100
- padding: '8px var(--gutter-h)',
101
- }}>
102
- <div>
103
- <h2 style={{ margin: '0 0 5px 0' }}>Let's configure your AI Plugin</h2>
104
- <p style={{ color: 'var(--theme-elevation-500)', fontSize: '14px', margin: '0' }}>
105
- Set up the provider → Choose the content → Refine the behavior.
106
- </p>
107
- </div>
108
- <div style={{ display: 'flex', gap: '10px' }}>
109
- <Button buttonStyle="secondary" el="link" to={`${adminRoute}/globals/ai-providers`}>
110
- Providers
111
- </Button>
112
- <Button disabled={isSaving} onClick={handleSave}>
113
- {isSaving ? 'Saving...' : 'Save Changes'}
114
- </Button>
115
- </div>
116
- </div>
117
-
118
- <div style={{ padding: '24px var(--gutter-h)' }}>
119
- <h5 style={{ marginBottom: '15px' }}>
120
- Select the collections where AI features should be available, toggle them on or off, and
121
- save your changes.
122
- </h5>
123
- <div style={{
124
- display: 'grid',
125
- gap: '15px',
126
- gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))',
127
- }}>
128
- {availableCollections.map((collection) => {
129
- const isEnabled = enabledCollections.includes(collection.slug);
130
- return (<button key={collection.slug} onClick={() => handleToggle(collection.slug)} style={{
131
- alignItems: 'center',
132
- background: isEnabled
133
- ? 'var(--theme-elevation-100)'
134
- : 'var(--theme-elevation-50)',
135
- border: `1px solid ${isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)'}`,
136
- borderRadius: '6px',
137
- cursor: 'pointer',
138
- display: 'flex',
139
- gap: '10px',
140
- padding: '10px 15px',
141
- textAlign: 'left',
142
- transition: 'all 0.2s ease',
143
- width: '100%',
144
- }} type="button">
145
- <div style={{
146
- alignItems: 'center',
147
- background: isEnabled
148
- ? 'var(--theme-text-success)'
149
- : 'var(--theme-elevation-200)',
150
- borderRadius: '12px',
151
- display: 'flex',
152
- height: '24px',
153
- justifyContent: isEnabled ? 'flex-end' : 'flex-start',
154
- padding: '2px',
155
- transition: 'all 0.2s ease',
156
- width: '44px',
157
- }}>
158
- <div style={{
159
- background: 'white',
160
- borderRadius: '50%',
161
- height: '20px',
162
- width: '20px',
163
- }}/>
164
- </div>
165
- <span style={{ fontWeight: 500 }}>
166
- {typeof collection.labels?.singular === 'string'
167
- ? collection.labels.singular
168
- : collection.labels?.singular?.en || collection.slug}
169
- </span>
170
- </button>);
171
- })}
172
- </div>
173
- </div>
174
- </div>);
175
- };
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface ProviderOptionsEditorProps {
3
- name?: string;
4
- path: string;
5
- }
6
- export declare const ProviderOptionsEditor: React.FC<ProviderOptionsEditorProps>;
7
- export {};