@ai-stack/payloadcms 3.68.0 → 3.76.0-beta.1

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 (187) hide show
  1. package/dist/ai/core/media/image/generateImage.js +2 -6
  2. package/dist/ai/core/media/image/generateImage.js.map +1 -1
  3. package/dist/ai/core/media/image/handlers/multimodal.js +13 -28
  4. package/dist/ai/core/media/image/handlers/multimodal.js.map +1 -1
  5. package/dist/ai/core/media/image/handlers/standard.js +10 -7
  6. package/dist/ai/core/media/image/handlers/standard.js.map +1 -1
  7. package/dist/ai/core/media/speech/generateSpeech.js +8 -8
  8. package/dist/ai/core/media/speech/generateSpeech.js.map +1 -1
  9. package/dist/ai/core/media/types.d.ts +1 -1
  10. package/dist/ai/core/media/types.js.map +1 -1
  11. package/dist/ai/core/streamObject.js +3 -3
  12. package/dist/ai/core/streamObject.js.map +1 -1
  13. package/dist/ai/core/types.d.ts +3 -0
  14. package/dist/ai/core/types.js.map +1 -1
  15. package/dist/ai/prompts.d.ts +1 -2
  16. package/dist/ai/prompts.js +0 -110
  17. package/dist/ai/prompts.js.map +1 -1
  18. package/dist/ai/providers/blocks/anthropic.js +2 -1
  19. package/dist/ai/providers/blocks/anthropic.js.map +1 -1
  20. package/dist/ai/providers/blocks/elevenlabs.js +3 -2
  21. package/dist/ai/providers/blocks/elevenlabs.js.map +1 -1
  22. package/dist/ai/providers/blocks/fal.js +2 -1
  23. package/dist/ai/providers/blocks/fal.js.map +1 -1
  24. package/dist/ai/providers/blocks/google.js +12 -6
  25. package/dist/ai/providers/blocks/google.js.map +1 -1
  26. package/dist/ai/providers/blocks/openai-compatible.js +2 -1
  27. package/dist/ai/providers/blocks/openai-compatible.js.map +1 -1
  28. package/dist/ai/providers/blocks/openai.js +3 -2
  29. package/dist/ai/providers/blocks/openai.js.map +1 -1
  30. package/dist/ai/providers/blocks/xai.js +2 -1
  31. package/dist/ai/providers/blocks/xai.js.map +1 -1
  32. package/dist/ai/providers/icons.d.ts +7 -0
  33. package/dist/ai/providers/icons.js +9 -0
  34. package/dist/ai/providers/icons.js.map +1 -0
  35. package/dist/ai/providers/registry.js +36 -26
  36. package/dist/ai/providers/registry.js.map +1 -1
  37. package/dist/ai/utils/filterEditorSchemaByNodes.d.ts +9 -0
  38. package/dist/ai/utils/filterEditorSchemaByNodes.js +30 -3
  39. package/dist/ai/utils/filterEditorSchemaByNodes.js.map +1 -1
  40. package/dist/ai/utils/nodeToSchemaMap.d.ts +22 -0
  41. package/dist/ai/utils/nodeToSchemaMap.js +72 -0
  42. package/dist/ai/utils/nodeToSchemaMap.js.map +1 -0
  43. package/dist/collections/AIJobs.js +1 -1
  44. package/dist/collections/AIJobs.js.map +1 -1
  45. package/dist/collections/AIProviders.d.ts +2 -0
  46. package/dist/collections/{AISettings.js → AIProviders.js} +53 -25
  47. package/dist/collections/AIProviders.js.map +1 -0
  48. package/dist/collections/Instructions.js +45 -4
  49. package/dist/collections/Instructions.js.map +1 -1
  50. package/dist/defaults.d.ts +1 -0
  51. package/dist/defaults.js +8 -0
  52. package/dist/defaults.js.map +1 -1
  53. package/dist/endpoints/chat.d.ts +4 -0
  54. package/dist/endpoints/fetchFields.js +10 -0
  55. package/dist/endpoints/fetchFields.js.map +1 -1
  56. package/dist/endpoints/fetchVoices.js +42 -25
  57. package/dist/endpoints/fetchVoices.js.map +1 -1
  58. package/dist/endpoints/index.js +248 -35
  59. package/dist/endpoints/index.js.map +1 -1
  60. package/dist/exports/client.d.ts +1 -1
  61. package/dist/exports/client.js +1 -1
  62. package/dist/exports/client.js.map +1 -1
  63. package/dist/exports/fields.d.ts +1 -0
  64. package/dist/exports/fields.js +1 -0
  65. package/dist/exports/fields.js.map +1 -1
  66. package/dist/fields/ArrayComposeField/ArrayComposeField.d.ts +15 -0
  67. package/dist/fields/ArrayComposeField/ArrayComposeField.js +87 -0
  68. package/dist/fields/ArrayComposeField/ArrayComposeField.js.map +1 -0
  69. package/dist/fields/ArrayComposeField/ArrayComposeField.jsx +73 -0
  70. package/dist/fields/PromptEditorField/PromptEditorField.js +7 -2
  71. package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
  72. package/dist/fields/PromptEditorField/PromptEditorField.jsx +5 -2
  73. package/dist/index.d.ts +3 -1
  74. package/dist/index.js +2 -1
  75. package/dist/index.js.map +1 -1
  76. package/dist/payload-ai.d.ts +152 -0
  77. package/dist/plugin.js +18 -34
  78. package/dist/plugin.js.map +1 -1
  79. package/dist/providers/InstructionsProvider/InstructionsProvider.js +47 -15
  80. package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
  81. package/dist/providers/InstructionsProvider/InstructionsProvider.jsx +39 -16
  82. package/dist/providers/InstructionsProvider/context.d.ts +3 -0
  83. package/dist/providers/InstructionsProvider/context.js +2 -0
  84. package/dist/providers/InstructionsProvider/context.js.map +1 -1
  85. package/dist/providers/InstructionsProvider/useInstructions.js +22 -3
  86. package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -1
  87. package/dist/styles.d.ts +11 -0
  88. package/dist/types/handlebars-async-helpers.d.ts +1 -0
  89. package/dist/types/handlebars-dist-handlebars.d.ts +1 -0
  90. package/dist/types/react-mentions.d.ts +1 -0
  91. package/dist/types.d.ts +36 -7
  92. package/dist/types.js +1 -0
  93. package/dist/types.js.map +1 -1
  94. package/dist/ui/AIConfigDashboard/index.d.ts +1 -1
  95. package/dist/ui/AIConfigDashboard/index.js +201 -23
  96. package/dist/ui/AIConfigDashboard/index.js.map +1 -1
  97. package/dist/ui/AIConfigDashboard/index.jsx +166 -15
  98. package/dist/ui/Compose/Compose.d.ts +1 -0
  99. package/dist/ui/Compose/Compose.js +23 -4
  100. package/dist/ui/Compose/Compose.js.map +1 -1
  101. package/dist/ui/Compose/Compose.jsx +23 -4
  102. package/dist/ui/Compose/UndoRedoActions.d.ts +2 -2
  103. package/dist/ui/Compose/UndoRedoActions.js +8 -5
  104. package/dist/ui/Compose/UndoRedoActions.js.map +1 -1
  105. package/dist/ui/Compose/UndoRedoActions.jsx +6 -5
  106. package/dist/ui/Compose/compose.module.css +56 -16
  107. package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts +5 -0
  108. package/dist/ui/Compose/hooks/menu/TranslateMenu.js +45 -4
  109. package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
  110. package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +41 -5
  111. package/dist/ui/Compose/hooks/menu/itemsMap.js +12 -6
  112. package/dist/ui/Compose/hooks/menu/itemsMap.js.map +1 -1
  113. package/dist/ui/Compose/hooks/menu/menu.module.scss +4 -1
  114. package/dist/ui/Compose/hooks/menu/useMenu.js +26 -15
  115. package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
  116. package/dist/ui/Compose/hooks/menu/useMenu.jsx +25 -12
  117. package/dist/ui/Compose/hooks/useActiveFieldTracking.js +34 -0
  118. package/dist/ui/Compose/hooks/useActiveFieldTracking.js.map +1 -1
  119. package/dist/ui/Compose/hooks/useGenerate.js +26 -174
  120. package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
  121. package/dist/ui/Compose/hooks/useGenerateUpload.d.ts +11 -0
  122. package/dist/ui/Compose/hooks/useGenerateUpload.js +156 -0
  123. package/dist/ui/Compose/hooks/useGenerateUpload.js.map +1 -0
  124. package/dist/ui/Compose/hooks/useHistory.d.ts +0 -1
  125. package/dist/ui/Compose/hooks/useHistory.js +65 -25
  126. package/dist/ui/Compose/hooks/useHistory.js.map +1 -1
  127. package/dist/ui/Compose/hooks/useStreamingUpdate.d.ts +8 -0
  128. package/dist/ui/Compose/hooks/useStreamingUpdate.js +48 -0
  129. package/dist/ui/Compose/hooks/useStreamingUpdate.js.map +1 -0
  130. package/dist/ui/ConfigDashboard/index.d.ts +2 -0
  131. package/dist/ui/ConfigDashboard/index.js +224 -0
  132. package/dist/ui/ConfigDashboard/index.js.map +1 -0
  133. package/dist/ui/ConfigDashboard/index.jsx +175 -0
  134. package/dist/ui/DynamicModelSelect/index.js +1 -1
  135. package/dist/ui/DynamicModelSelect/index.js.map +1 -1
  136. package/dist/ui/DynamicModelSelect/index.jsx +1 -1
  137. package/dist/ui/DynamicProviderSelect/index.js +1 -1
  138. package/dist/ui/DynamicProviderSelect/index.js.map +1 -1
  139. package/dist/ui/DynamicProviderSelect/index.jsx +1 -1
  140. package/dist/ui/DynamicVoiceSelect/index.js +63 -11
  141. package/dist/ui/DynamicVoiceSelect/index.js.map +1 -1
  142. package/dist/ui/DynamicVoiceSelect/index.jsx +47 -14
  143. package/dist/ui/EncryptedTextField/index.js +4 -4
  144. package/dist/ui/EncryptedTextField/index.js.map +1 -1
  145. package/dist/ui/EncryptedTextField/index.jsx +4 -4
  146. package/dist/ui/ProviderOptionsEditor/index.js +1 -1
  147. package/dist/ui/ProviderOptionsEditor/index.js.map +1 -1
  148. package/dist/ui/ProviderOptionsEditor/index.jsx +1 -1
  149. package/dist/ui/VoicesFetcher/index.js +34 -16
  150. package/dist/ui/VoicesFetcher/index.js.map +1 -1
  151. package/dist/ui/VoicesFetcher/index.jsx +32 -15
  152. package/dist/utilities/buildSmartPrompt.d.ts +22 -0
  153. package/dist/utilities/buildSmartPrompt.js +141 -0
  154. package/dist/utilities/buildSmartPrompt.js.map +1 -0
  155. package/dist/utilities/encryption.js +2 -1
  156. package/dist/utilities/encryption.js.map +1 -1
  157. package/dist/utilities/fieldToJsonSchema.js +32 -3
  158. package/dist/utilities/fieldToJsonSchema.js.map +1 -1
  159. package/dist/utilities/resolveImageReferences.d.ts +3 -1
  160. package/dist/utilities/resolveImageReferences.js +21 -2
  161. package/dist/utilities/resolveImageReferences.js.map +1 -1
  162. package/dist/utilities/seedProperties.d.ts +7 -0
  163. package/dist/utilities/seedProperties.js +100 -0
  164. package/dist/utilities/seedProperties.js.map +1 -0
  165. package/dist/utilities/setSafeLexicalState.js +79 -6
  166. package/dist/utilities/setSafeLexicalState.js.map +1 -1
  167. package/dist/utilities/updateFieldsConfig.d.ts +1 -1
  168. package/dist/utilities/updateFieldsConfig.js +9 -2
  169. package/dist/utilities/updateFieldsConfig.js.map +1 -1
  170. package/package.json +35 -33
  171. package/dist/collections/AISettings.d.ts +0 -2
  172. package/dist/collections/AISettings.js.map +0 -1
  173. package/dist/endpoints/chat.d.js +0 -3
  174. package/dist/endpoints/chat.d.js.map +0 -1
  175. package/dist/init.d.ts +0 -7
  176. package/dist/init.js +0 -135
  177. package/dist/init.js.map +0 -1
  178. package/dist/payload-ai.d.js +0 -3
  179. package/dist/payload-ai.d.js.map +0 -1
  180. package/dist/styles.d.js +0 -2
  181. package/dist/styles.d.js.map +0 -1
  182. package/dist/types/handlebars-async-helpers.d.js +0 -2
  183. package/dist/types/handlebars-async-helpers.d.js.map +0 -1
  184. package/dist/types/handlebars-dist-handlebars.d.js +0 -2
  185. package/dist/types/handlebars-dist-handlebars.d.js.map +0 -1
  186. package/dist/types/react-mentions.d.js +0 -2
  187. package/dist/types/react-mentions.d.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Maps Lexical node type values to JSON schema definition names.
3
+ * This is used to filter the editor schema based on allowed editor nodes.
4
+ *
5
+ * The keys are the type values that appear in serialized Lexical JSON (e.g., 'heading', 'paragraph').
6
+ * The values are the schema definition names as defined in lexicalJsonSchema.ts.
7
+ */ export const nodeTypeToSchemaMap = {
8
+ // Core nodes (typically always included)
9
+ text: 'TextNode',
10
+ linebreak: 'LineBreakNode',
11
+ tab: 'TabNode',
12
+ root: 'RootNode',
13
+ // Block nodes
14
+ paragraph: 'ParagraphNode',
15
+ heading: 'HeadingNode',
16
+ quote: 'QuoteNode',
17
+ list: 'ListNode',
18
+ listitem: 'ListItemNode',
19
+ // Rich content nodes
20
+ link: 'LinkNode',
21
+ code: 'CodeNode',
22
+ horizontalrule: 'HorizontalRuleNode',
23
+ // Table nodes
24
+ table: 'TableNode',
25
+ tablerow: 'TableRowNode',
26
+ tablecell: 'TableCellNode',
27
+ // Media nodes
28
+ image: 'ImageNode'
29
+ };
30
+ /**
31
+ * Core nodes that should always be included in the filtered schema
32
+ */ export const coreNodeTypes = [
33
+ 'text',
34
+ 'linebreak',
35
+ 'tab',
36
+ 'root',
37
+ 'paragraph'
38
+ ];
39
+ /**
40
+ * Converts a Lexical node class name (e.g., 'HeadingNode') to its type value (e.g., 'heading').
41
+ * This handles the common pattern where node classes are named with the pattern `{Type}Node`.
42
+ */ export function nodeClassToType(nodeClassName) {
43
+ // Handle common formats:
44
+ // 'HeadingNode' -> 'heading'
45
+ // 'ParagraphNode' -> 'paragraph'
46
+ // 'HorizontalRuleNode' -> 'horizontalrule'
47
+ return nodeClassName.replace(/Node$/, '').toLowerCase();
48
+ }
49
+ /**
50
+ * Converts a set of Lexical node class names to their corresponding schema definition names.
51
+ * Includes core nodes automatically.
52
+ */ export function nodeClassesToSchemaDefinitions(nodeClassNames) {
53
+ const definitions = new Set();
54
+ // Always include core nodes
55
+ for (const coreType of coreNodeTypes){
56
+ const def = nodeTypeToSchemaMap[coreType];
57
+ if (def) {
58
+ definitions.add(def);
59
+ }
60
+ }
61
+ // Convert each node class to its definition
62
+ for (const className of nodeClassNames){
63
+ const type = nodeClassToType(className);
64
+ const def = nodeTypeToSchemaMap[type];
65
+ if (def) {
66
+ definitions.add(def);
67
+ }
68
+ }
69
+ return Array.from(definitions);
70
+ }
71
+
72
+ //# sourceMappingURL=nodeToSchemaMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ai/utils/nodeToSchemaMap.ts"],"sourcesContent":["/**\n * Maps Lexical node type values to JSON schema definition names.\n * This is used to filter the editor schema based on allowed editor nodes.\n *\n * The keys are the type values that appear in serialized Lexical JSON (e.g., 'heading', 'paragraph').\n * The values are the schema definition names as defined in lexicalJsonSchema.ts.\n */\nexport const nodeTypeToSchemaMap: Record<string, string> = {\n // Core nodes (typically always included)\n text: 'TextNode',\n linebreak: 'LineBreakNode',\n tab: 'TabNode',\n root: 'RootNode',\n\n // Block nodes\n paragraph: 'ParagraphNode',\n heading: 'HeadingNode',\n quote: 'QuoteNode',\n list: 'ListNode',\n listitem: 'ListItemNode',\n\n // Rich content nodes\n link: 'LinkNode',\n code: 'CodeNode',\n horizontalrule: 'HorizontalRuleNode',\n\n // Table nodes\n table: 'TableNode',\n tablerow: 'TableRowNode',\n tablecell: 'TableCellNode',\n\n // Media nodes\n image: 'ImageNode',\n}\n\n/**\n * Core nodes that should always be included in the filtered schema\n */\nexport const coreNodeTypes = ['text', 'linebreak', 'tab', 'root', 'paragraph']\n\n/**\n * Converts a Lexical node class name (e.g., 'HeadingNode') to its type value (e.g., 'heading').\n * This handles the common pattern where node classes are named with the pattern `{Type}Node`.\n */\nexport function nodeClassToType(nodeClassName: string): string {\n // Handle common formats:\n // 'HeadingNode' -> 'heading'\n // 'ParagraphNode' -> 'paragraph'\n // 'HorizontalRuleNode' -> 'horizontalrule'\n return nodeClassName.replace(/Node$/, '').toLowerCase()\n}\n\n/**\n * Converts a set of Lexical node class names to their corresponding schema definition names.\n * Includes core nodes automatically.\n */\nexport function nodeClassesToSchemaDefinitions(nodeClassNames: string[]): string[] {\n const definitions = new Set<string>()\n\n // Always include core nodes\n for (const coreType of coreNodeTypes) {\n const def = nodeTypeToSchemaMap[coreType]\n if (def) {\n definitions.add(def)\n }\n }\n\n // Convert each node class to its definition\n for (const className of nodeClassNames) {\n const type = nodeClassToType(className)\n const def = nodeTypeToSchemaMap[type]\n if (def) {\n definitions.add(def)\n }\n }\n\n return Array.from(definitions)\n}\n"],"names":["nodeTypeToSchemaMap","text","linebreak","tab","root","paragraph","heading","quote","list","listitem","link","code","horizontalrule","table","tablerow","tablecell","image","coreNodeTypes","nodeClassToType","nodeClassName","replace","toLowerCase","nodeClassesToSchemaDefinitions","nodeClassNames","definitions","Set","coreType","def","add","className","type","Array","from"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,MAAMA,sBAA8C;IACzD,yCAAyC;IACzCC,MAAM;IACNC,WAAW;IACXC,KAAK;IACLC,MAAM;IAEN,cAAc;IACdC,WAAW;IACXC,SAAS;IACTC,OAAO;IACPC,MAAM;IACNC,UAAU;IAEV,qBAAqB;IACrBC,MAAM;IACNC,MAAM;IACNC,gBAAgB;IAEhB,cAAc;IACdC,OAAO;IACPC,UAAU;IACVC,WAAW;IAEX,cAAc;IACdC,OAAO;AACT,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,gBAAgB;IAAC;IAAQ;IAAa;IAAO;IAAQ;CAAY,CAAA;AAE9E;;;CAGC,GACD,OAAO,SAASC,gBAAgBC,aAAqB;IACnD,yBAAyB;IACzB,6BAA6B;IAC7B,iCAAiC;IACjC,2CAA2C;IAC3C,OAAOA,cAAcC,OAAO,CAAC,SAAS,IAAIC,WAAW;AACvD;AAEA;;;CAGC,GACD,OAAO,SAASC,+BAA+BC,cAAwB;IACrE,MAAMC,cAAc,IAAIC;IAExB,4BAA4B;IAC5B,KAAK,MAAMC,YAAYT,cAAe;QACpC,MAAMU,MAAM3B,mBAAmB,CAAC0B,SAAS;QACzC,IAAIC,KAAK;YACPH,YAAYI,GAAG,CAACD;QAClB;IACF;IAEA,4CAA4C;IAC5C,KAAK,MAAME,aAAaN,eAAgB;QACtC,MAAMO,OAAOZ,gBAAgBW;QAC7B,MAAMF,MAAM3B,mBAAmB,CAAC8B,KAAK;QACrC,IAAIH,KAAK;YACPH,YAAYI,GAAG,CAACD;QAClB;IACF;IAEA,OAAOI,MAAMC,IAAI,CAACR;AACpB"}
@@ -7,7 +7,7 @@ const defaultAccessConfig = {
7
7
  };
8
8
  const defaultAdminConfig = {
9
9
  group: 'Plugins',
10
- hidden: false
10
+ hidden: true
11
11
  };
12
12
  export const aiJobsCollection = ()=>({
13
13
  slug: PLUGIN_AI_JOBS_TABLE,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/AIJobs.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { PLUGIN_AI_JOBS_TABLE, PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\nconst defaultAccessConfig = {\n create: ({ req }: { req: { user?: any } }) => !!req.user,\n delete: ({ req }: { req: { user?: any } }) => !!req.user,\n read: ({ req }: { req: { user?: any } }) => !!req.user,\n update: ({ req }: { req: { user?: any } }) => !!req.user,\n}\n\nconst defaultAdminConfig = {\n group: 'Plugins',\n hidden: false,\n}\n\nexport const aiJobsCollection = (): CollectionConfig => ({\n slug: PLUGIN_AI_JOBS_TABLE,\n access: defaultAccessConfig,\n admin: defaultAdminConfig,\n fields: [\n {\n name: 'instructionId',\n type: 'relationship',\n relationTo: PLUGIN_INSTRUCTIONS_TABLE,\n required: true,\n },\n {\n name: 'task_id',\n type: 'text',\n required: true,\n unique: true,\n },\n {\n name: 'status',\n type: 'select',\n defaultValue: 'queued',\n options: [\n { label: 'Queued', value: 'queued' },\n { label: 'Running', value: 'running' },\n { label: 'Completed', value: 'completed' },\n { label: 'Failed', value: 'failed' },\n { label: 'Canceled', value: 'canceled' },\n ],\n },\n {\n name: 'progress',\n type: 'number',\n max: 100,\n min: 0,\n },\n {\n name: 'result_id',\n type: 'text',\n },\n {\n name: 'error',\n type: 'textarea',\n },\n {\n name: 'meta',\n type: 'json',\n },\n ],\n labels: {\n plural: 'AI Jobs',\n singular: 'AI Job',\n },\n})\n"],"names":["PLUGIN_AI_JOBS_TABLE","PLUGIN_INSTRUCTIONS_TABLE","defaultAccessConfig","create","req","user","delete","read","update","defaultAdminConfig","group","hidden","aiJobsCollection","slug","access","admin","fields","name","type","relationTo","required","unique","defaultValue","options","label","value","max","min","labels","plural","singular"],"mappings":"AAEA,SAASA,oBAAoB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAEhF,MAAMC,sBAAsB;IAC1BC,QAAQ,CAAC,EAAEC,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;IACxDC,QAAQ,CAAC,EAAEF,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;IACxDE,MAAM,CAAC,EAAEH,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;IACtDG,QAAQ,CAAC,EAAEJ,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;AAC1D;AAEA,MAAMI,qBAAqB;IACzBC,OAAO;IACPC,QAAQ;AACV;AAEA,OAAO,MAAMC,mBAAmB,IAAyB,CAAA;QACvDC,MAAMb;QACNc,QAAQZ;QACRa,OAAON;QACPO,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,YAAYlB;gBACZmB,UAAU;YACZ;YACA;gBACEH,MAAM;gBACNC,MAAM;gBACNE,UAAU;gBACVC,QAAQ;YACV;YACA;gBACEJ,MAAM;gBACNC,MAAM;gBACNI,cAAc;gBACdC,SAAS;oBACP;wBAAEC,OAAO;wBAAUC,OAAO;oBAAS;oBACnC;wBAAED,OAAO;wBAAWC,OAAO;oBAAU;oBACrC;wBAAED,OAAO;wBAAaC,OAAO;oBAAY;oBACzC;wBAAED,OAAO;wBAAUC,OAAO;oBAAS;oBACnC;wBAAED,OAAO;wBAAYC,OAAO;oBAAW;iBACxC;YACH;YACA;gBACER,MAAM;gBACNC,MAAM;gBACNQ,KAAK;gBACLC,KAAK;YACP;YACA;gBACEV,MAAM;gBACNC,MAAM;YACR;YACA;gBACED,MAAM;gBACNC,MAAM;YACR;YACA;gBACED,MAAM;gBACNC,MAAM;YACR;SACD;QACDU,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../src/collections/AIJobs.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { PLUGIN_AI_JOBS_TABLE, PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\nconst defaultAccessConfig = {\n create: ({ req }: { req: { user?: any } }) => !!req.user,\n delete: ({ req }: { req: { user?: any } }) => !!req.user,\n read: ({ req }: { req: { user?: any } }) => !!req.user,\n update: ({ req }: { req: { user?: any } }) => !!req.user,\n}\n\nconst defaultAdminConfig = {\n group: 'Plugins',\n hidden: true,\n}\n\nexport const aiJobsCollection = (): CollectionConfig => ({\n slug: PLUGIN_AI_JOBS_TABLE,\n access: defaultAccessConfig,\n admin: defaultAdminConfig,\n fields: [\n {\n name: 'instructionId',\n type: 'relationship',\n relationTo: PLUGIN_INSTRUCTIONS_TABLE,\n required: true,\n },\n {\n name: 'task_id',\n type: 'text',\n required: true,\n unique: true,\n },\n {\n name: 'status',\n type: 'select',\n defaultValue: 'queued',\n options: [\n { label: 'Queued', value: 'queued' },\n { label: 'Running', value: 'running' },\n { label: 'Completed', value: 'completed' },\n { label: 'Failed', value: 'failed' },\n { label: 'Canceled', value: 'canceled' },\n ],\n },\n {\n name: 'progress',\n type: 'number',\n max: 100,\n min: 0,\n },\n {\n name: 'result_id',\n type: 'text',\n },\n {\n name: 'error',\n type: 'textarea',\n },\n {\n name: 'meta',\n type: 'json',\n },\n ],\n labels: {\n plural: 'AI Jobs',\n singular: 'AI Job',\n },\n})\n"],"names":["PLUGIN_AI_JOBS_TABLE","PLUGIN_INSTRUCTIONS_TABLE","defaultAccessConfig","create","req","user","delete","read","update","defaultAdminConfig","group","hidden","aiJobsCollection","slug","access","admin","fields","name","type","relationTo","required","unique","defaultValue","options","label","value","max","min","labels","plural","singular"],"mappings":"AAEA,SAASA,oBAAoB,EAAEC,yBAAyB,QAAQ,iBAAgB;AAEhF,MAAMC,sBAAsB;IAC1BC,QAAQ,CAAC,EAAEC,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;IACxDC,QAAQ,CAAC,EAAEF,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;IACxDE,MAAM,CAAC,EAAEH,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;IACtDG,QAAQ,CAAC,EAAEJ,GAAG,EAA2B,GAAK,CAAC,CAACA,IAAIC,IAAI;AAC1D;AAEA,MAAMI,qBAAqB;IACzBC,OAAO;IACPC,QAAQ;AACV;AAEA,OAAO,MAAMC,mBAAmB,IAAyB,CAAA;QACvDC,MAAMb;QACNc,QAAQZ;QACRa,OAAON;QACPO,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,YAAYlB;gBACZmB,UAAU;YACZ;YACA;gBACEH,MAAM;gBACNC,MAAM;gBACNE,UAAU;gBACVC,QAAQ;YACV;YACA;gBACEJ,MAAM;gBACNC,MAAM;gBACNI,cAAc;gBACdC,SAAS;oBACP;wBAAEC,OAAO;wBAAUC,OAAO;oBAAS;oBACnC;wBAAED,OAAO;wBAAWC,OAAO;oBAAU;oBACrC;wBAAED,OAAO;wBAAaC,OAAO;oBAAY;oBACzC;wBAAED,OAAO;wBAAUC,OAAO;oBAAS;oBACnC;wBAAED,OAAO;wBAAYC,OAAO;oBAAW;iBACxC;YACH;YACA;gBACER,MAAM;gBACNC,MAAM;gBACNQ,KAAK;gBACLC,KAAK;YACP;YACA;gBACEV,MAAM;gBACNC,MAAM;YACR;YACA;gBACED,MAAM;gBACNC,MAAM;YACR;YACA;gBACED,MAAM;gBACNC,MAAM;YACR;SACD;QACDU,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;IACF,CAAA,EAAE"}
@@ -0,0 +1,2 @@
1
+ import type { GlobalConfig } from 'payload';
2
+ export declare const AIProvidersGlobal: GlobalConfig;
@@ -1,30 +1,38 @@
1
1
  import { allProviderBlocks } from '../ai/providers/blocks/index.js';
2
- export const aiSettingsGlobal = {
3
- slug: 'ai-settings',
2
+ export const AIProvidersGlobal = {
3
+ slug: 'ai-providers',
4
4
  access: {
5
5
  read: ({ req })=>!!req.user,
6
6
  update: ({ req })=>!!req.user
7
7
  },
8
- // admin: {
9
- // description: 'Configure AI providers, models, and default settings',
10
- // },
8
+ admin: {
9
+ description: 'Connect your providers and choose the default models used across your project.',
10
+ group: false
11
+ },
11
12
  fields: [
12
13
  {
13
14
  name: 'providers',
14
15
  type: 'blocks',
15
16
  admin: {
16
- description: 'Configure which AI providers to use and their settings',
17
+ description: 'Add one or more providers and set their credentials and settings. You can keep multiple providers and switch defaults below.',
17
18
  initCollapsed: true
18
19
  },
19
20
  blocks: allProviderBlocks,
20
21
  label: 'AI Providers',
21
22
  required: true
22
23
  },
24
+ {
25
+ name: 'enabledCollections',
26
+ type: 'json',
27
+ admin: {
28
+ hidden: true
29
+ }
30
+ },
23
31
  {
24
32
  name: 'defaults',
25
33
  type: 'group',
26
34
  admin: {
27
- description: 'Default provider/model behavior for each use case'
35
+ description: 'Pick the default provider and model for each feature. These defaults are used unless a collection or field overrides them.'
28
36
  },
29
37
  fields: [
30
38
  {
@@ -119,7 +127,7 @@ export const aiSettingsGlobal = {
119
127
  {
120
128
  fields: [
121
129
  {
122
- name: 'video',
130
+ name: 'tts',
123
131
  type: 'group',
124
132
  fields: [
125
133
  {
@@ -142,6 +150,16 @@ export const aiSettingsGlobal = {
142
150
  },
143
151
  label: 'Default Model'
144
152
  },
153
+ {
154
+ name: 'voice',
155
+ type: 'text',
156
+ admin: {
157
+ components: {
158
+ Field: '@ai-stack/payloadcms/client#DynamicVoiceSelect'
159
+ }
160
+ },
161
+ label: 'Default Voice'
162
+ },
145
163
  {
146
164
  name: 'options',
147
165
  type: 'json',
@@ -157,12 +175,15 @@ export const aiSettingsGlobal = {
157
175
  label: ''
158
176
  }
159
177
  ],
160
- label: 'Video Generation'
178
+ label: 'Speech Generation'
161
179
  },
162
180
  {
181
+ admin: {
182
+ disabled: true
183
+ },
163
184
  fields: [
164
185
  {
165
- name: 'tts',
186
+ name: 'video',
166
187
  type: 'group',
167
188
  fields: [
168
189
  {
@@ -185,16 +206,6 @@ export const aiSettingsGlobal = {
185
206
  },
186
207
  label: 'Default Model'
187
208
  },
188
- {
189
- name: 'voice',
190
- type: 'text',
191
- admin: {
192
- components: {
193
- Field: '@ai-stack/payloadcms/client#DynamicVoiceSelect'
194
- }
195
- },
196
- label: 'Default Voice'
197
- },
198
209
  {
199
210
  name: 'options',
200
211
  type: 'json',
@@ -210,7 +221,7 @@ export const aiSettingsGlobal = {
210
221
  label: ''
211
222
  }
212
223
  ],
213
- label: 'Text-to-Speech'
224
+ label: 'Video Generation'
214
225
  }
215
226
  ]
216
227
  }
@@ -219,6 +230,18 @@ export const aiSettingsGlobal = {
219
230
  }
220
231
  ],
221
232
  hooks: {
233
+ afterChange: [
234
+ async ({ doc, req })=>{
235
+ if (doc.enabledCollections && doc.enabledCollections.length > 0) {
236
+ const { seedProperties } = await import('../utilities/seedProperties.js');
237
+ await seedProperties({
238
+ enabledCollections: doc.enabledCollections,
239
+ req
240
+ });
241
+ }
242
+ return doc;
243
+ }
244
+ ],
222
245
  afterRead: [
223
246
  async ({ context, doc, req })=>{
224
247
  if (!req.payload.secret) {
@@ -254,10 +277,15 @@ export const aiSettingsGlobal = {
254
277
  if (data.providers) {
255
278
  data.providers = data.providers.map((provider)=>{
256
279
  if (provider.apiKey) {
257
- // If it looks like a masked key, don't re-encrypt (it means it wasn't changed)
280
+ const originalProvider = originalDoc?.providers?.find((p)=>p.id === provider.id);
281
+ // If the key strictly equals the existing one (e.g. partial update merge), do nothing.
282
+ // This prevents re-encrypting an already encrypted key.
283
+ if (originalProvider?.apiKey && provider.apiKey === originalProvider.apiKey) {
284
+ return provider;
285
+ }
286
+ // If it looks like a masked key, don't re-encrypt (it means it wasn't changed via UI)
258
287
  if (provider.apiKey.startsWith('sk-') && provider.apiKey.includes('****')) {
259
288
  // Restore the original encrypted key from originalDoc
260
- const originalProvider = originalDoc?.providers?.find((p)=>p.id === provider.id);
261
289
  if (originalProvider?.apiKey) {
262
290
  provider.apiKey = originalProvider.apiKey;
263
291
  }
@@ -273,7 +301,7 @@ export const aiSettingsGlobal = {
273
301
  }
274
302
  ]
275
303
  },
276
- label: 'AI Configuration'
304
+ label: 'AI Providers'
277
305
  };
278
306
 
279
- //# sourceMappingURL=AISettings.js.map
307
+ //# sourceMappingURL=AIProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/collections/AIProviders.ts"],"sourcesContent":["import type { GlobalConfig } from 'payload'\n\nimport { allProviderBlocks } from '../ai/providers/blocks/index.js'\n\nexport const AIProvidersGlobal: GlobalConfig = {\n slug: 'ai-providers',\n access: {\n read: ({ req }) => !!req.user,\n update: ({ req }) => !!req.user,\n },\n admin: {\n description: 'Connect your providers and choose the default models used across your project.',\n group: false,\n },\n fields: [\n {\n name: 'providers',\n type: 'blocks',\n admin: {\n description:\n 'Add one or more providers and set their credentials and settings. You can keep multiple providers and switch defaults below.',\n initCollapsed: true,\n },\n blocks: allProviderBlocks,\n label: 'AI Providers',\n required: true,\n },\n {\n name: 'enabledCollections',\n type: 'json',\n admin: {\n hidden: true,\n },\n },\n {\n name: 'defaults',\n type: 'group',\n admin: {\n description:\n 'Pick the default provider and model for each feature. These defaults are used unless a collection or field overrides them.',\n },\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'text',\n type: 'group',\n fields: [\n {\n name: 'provider',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicProviderSelect',\n },\n },\n label: 'Default Provider',\n },\n {\n name: 'model',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicModelSelect',\n },\n },\n label: 'Default Model',\n },\n {\n name: 'options',\n type: 'json',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#ProviderOptionsEditor',\n },\n description: 'Default options for this model (global)',\n },\n label: 'Global Model Options',\n },\n ],\n label: '',\n },\n ],\n label: 'Text Generation',\n },\n {\n fields: [\n {\n name: 'image',\n type: 'group',\n fields: [\n {\n name: 'provider',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicProviderSelect',\n },\n },\n label: 'Default Provider',\n },\n {\n name: 'model',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicModelSelect',\n },\n },\n label: 'Default Model',\n },\n {\n name: 'options',\n type: 'json',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#ProviderOptionsEditor',\n },\n description: 'Default options for this model (global)',\n },\n label: 'Global Model Options',\n },\n ],\n label: '',\n },\n ],\n label: 'Image Generation',\n },\n {\n fields: [\n {\n name: 'tts',\n type: 'group',\n fields: [\n {\n name: 'provider',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicProviderSelect',\n },\n },\n label: 'Default Provider',\n },\n {\n name: 'model',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicModelSelect',\n },\n },\n label: 'Default Model',\n },\n {\n name: 'voice',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicVoiceSelect',\n },\n },\n label: 'Default Voice',\n },\n {\n name: 'options',\n type: 'json',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#ProviderOptionsEditor',\n },\n description: 'Default options for this model (global)',\n },\n label: 'Global Model Options',\n },\n ],\n label: '',\n },\n ],\n label: 'Speech Generation',\n },\n {\n admin: {\n disabled: true,\n },\n fields: [\n {\n name: 'video',\n type: 'group',\n fields: [\n {\n name: 'provider',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicProviderSelect',\n },\n },\n label: 'Default Provider',\n },\n {\n name: 'model',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicModelSelect',\n },\n },\n label: 'Default Model',\n },\n {\n name: 'options',\n type: 'json',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#ProviderOptionsEditor',\n },\n description: 'Default options for this model (global)',\n },\n label: 'Global Model Options',\n },\n ],\n label: '',\n },\n ],\n label: 'Video Generation',\n },\n ],\n },\n ],\n label: 'Default Models',\n },\n ],\n hooks: {\n afterChange: [\n async ({ doc, req }) => {\n if (doc.enabledCollections && doc.enabledCollections.length > 0) {\n const { seedProperties } = await import('../utilities/seedProperties.js')\n await seedProperties({\n enabledCollections: doc.enabledCollections,\n req,\n })\n }\n return doc\n },\n ],\n afterRead: [\n async ({ context, doc, req }) => {\n if (!req.payload.secret) {\n return doc\n }\n\n const { decrypt } = await import('../utilities/encryption.js')\n\n if (doc.providers) {\n doc.providers = doc.providers.map((provider: any) => {\n if (provider.apiKey) {\n if (context.unsafe) {\n // Internal use: decrypt\n provider.apiKey = decrypt(provider.apiKey, req.payload.secret)\n } else {\n // Admin UI: mask\n // We can't easily check if it's valid without decrypting, but for UI we just show mask\n // If we want to show \"present\", we can return a mask\n provider.apiKey = 'sk-****' + provider.apiKey.slice(-4)\n }\n }\n return provider\n })\n }\n return doc\n },\n ],\n beforeChange: [\n async ({ data, originalDoc, req }) => {\n if (!req.payload.secret) {\n return data\n }\n\n const { encrypt } = await import('../utilities/encryption.js')\n\n // Iterate over providers and encrypt API keys\n if (data.providers) {\n data.providers = data.providers.map((provider: any) => {\n if (provider.apiKey) {\n const originalProvider = originalDoc?.providers?.find(\n (p: any) => p.id === provider.id,\n )\n\n // If the key strictly equals the existing one (e.g. partial update merge), do nothing.\n // This prevents re-encrypting an already encrypted key.\n if (originalProvider?.apiKey && provider.apiKey === originalProvider.apiKey) {\n return provider\n }\n\n // If it looks like a masked key, don't re-encrypt (it means it wasn't changed via UI)\n if (provider.apiKey.startsWith('sk-') && provider.apiKey.includes('****')) {\n // Restore the original encrypted key from originalDoc\n if (originalProvider?.apiKey) {\n provider.apiKey = originalProvider.apiKey\n }\n } else {\n // Encrypt new key\n provider.apiKey = encrypt(provider.apiKey, req.payload.secret)\n }\n }\n return provider\n })\n }\n return data\n },\n ],\n },\n label: 'AI Providers',\n}\n"],"names":["allProviderBlocks","AIProvidersGlobal","slug","access","read","req","user","update","admin","description","group","fields","name","type","initCollapsed","blocks","label","required","hidden","tabs","components","Field","disabled","hooks","afterChange","doc","enabledCollections","length","seedProperties","afterRead","context","payload","secret","decrypt","providers","map","provider","apiKey","unsafe","slice","beforeChange","data","originalDoc","encrypt","originalProvider","find","p","id","startsWith","includes"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,kCAAiC;AAEnE,OAAO,MAAMC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,OAAO;wCACT;wCACA;4CACEJ,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;gDACAZ,aAAa;4CACf;4CACAO,OAAO;wCACT;qCACD;oCACDA,OAAO;gCACT;6BACD;4BACDA,OAAO;wBACT;wBACA;4BACEL,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNF,QAAQ;wCACN;4CACEC,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;4CACF;4CACAL,OAAO;wCACT;wCACA;4CACEJ,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;4CACF;4CACAL,OAAO;wCACT;wCACA;4CACEJ,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;4CACF;4CACAL,OAAO;wCACT;wCACA;4CACEJ,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;gDACAZ,aAAa;4CACf;4CACAO,OAAO;wCACT;qCACD;oCACDA,OAAO;gCACT;6BACD;4BACDA,OAAO;wBACT;wBACA;4BACER,OAAO;gCACLc,UAAU;4BACZ;4BACAX,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNF,QAAQ;wCACN;4CACEC,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;4CACF;4CACAL,OAAO;wCACT;wCACA;4CACEJ,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;4CACF;4CACAL,OAAO;wCACT;wCACA;4CACEJ,MAAM;4CACNC,MAAM;4CACNL,OAAO;gDACLY,YAAY;oDACVC,OAAO;gDACT;gDACAZ,aAAa;4CACf;4CACAO,OAAO;wCACT;qCACD;oCACDA,OAAO;gCACT;6BACD;4BACDA,OAAO;wBACT;qBACD;gBACH;aACD;YACDA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oBAClBO,KAAKP,SAAS,GAAGO,KAAKP,SAAS,CAACC,GAAG,CAAC,CAACC;wBACnC,IAAIA,SAASC,MAAM,EAAE;4BACnB,MAAMO,mBAAmBF,aAAaR,WAAWW,KAC/C,CAACC,IAAWA,EAAEC,EAAE,KAAKX,SAASW,EAAE;4BAGlC,uFAAuF;4BACvF,wDAAwD;4BACxD,IAAIH,kBAAkBP,UAAUD,SAASC,MAAM,KAAKO,iBAAiBP,MAAM,EAAE;gCAC3E,OAAOD;4BACT;4BAEA,sFAAsF;4BACtF,IAAIA,SAASC,MAAM,CAACW,UAAU,CAAC,UAAUZ,SAASC,MAAM,CAACY,QAAQ,CAAC,SAAS;gCACzE,sDAAsD;gCACtD,IAAIL,kBAAkBP,QAAQ;oCAC5BD,SAASC,MAAM,GAAGO,iBAAiBP,MAAM;gCAC3C;4BACF,OAAO;gCACL,kBAAkB;gCAClBD,SAASC,MAAM,GAAGM,QAAQP,SAASC,MAAM,EAAEhC,IAAI0B,OAAO,CAACC,MAAM;4BAC/D;wBACF;wBACA,OAAOI;oBACT;gBACF;gBACA,OAAOK;YACT;SACD;IACH;IACAzB,OAAO;AACT,EAAC"}
@@ -30,6 +30,13 @@ const CAPABILITIES = [
30
30
  fields: [
31
31
  'upload'
32
32
  ]
33
+ },
34
+ {
35
+ id: 'array',
36
+ name: 'Array Generation',
37
+ fields: [
38
+ 'array'
39
+ ]
33
40
  }
34
41
  ];
35
42
  const defaultAccessConfig = {
@@ -133,11 +140,12 @@ export const instructionsCollection = (pluginConfig)=>({
133
140
  ...pluginConfig.overrideInstructions?.access
134
141
  },
135
142
  admin: {
143
+ description: "Customize how AI interacts with specific fields within your enabled collections.",
136
144
  ...defaultAdminConfig,
137
145
  ...pluginConfig.overrideInstructions?.admin,
138
146
  components: {
139
147
  beforeList: [
140
- '@ai-stack/payloadcms/client#AIConfigDashboard'
148
+ '@ai-stack/payloadcms/client#ConfigDashboard'
141
149
  ]
142
150
  }
143
151
  },
@@ -146,7 +154,8 @@ export const instructionsCollection = (pluginConfig)=>({
146
154
  name: 'schema-path',
147
155
  type: 'text',
148
156
  admin: {
149
- description: "Please don't change this unless you're sure of what you're doing"
157
+ description: "Please don't change this unless you're sure of what you're doing",
158
+ hidden: !pluginConfig.debugging
150
159
  },
151
160
  unique: true
152
161
  },
@@ -154,7 +163,8 @@ export const instructionsCollection = (pluginConfig)=>({
154
163
  name: 'field-type',
155
164
  type: 'select',
156
165
  admin: {
157
- description: "Please don't change this unless you're sure of what you're doing"
166
+ description: "Please don't change this unless you're sure of what you're doing",
167
+ hidden: !pluginConfig.debugging
158
168
  },
159
169
  defaultValue: 'text',
160
170
  label: 'Field type',
@@ -174,6 +184,10 @@ export const instructionsCollection = (pluginConfig)=>({
174
184
  {
175
185
  label: 'richText',
176
186
  value: 'richText'
187
+ },
188
+ {
189
+ label: 'array',
190
+ value: 'array'
177
191
  }
178
192
  ]
179
193
  },
@@ -183,7 +197,8 @@ export const instructionsCollection = (pluginConfig)=>({
183
197
  admin: {
184
198
  condition: (_, current)=>{
185
199
  return current['field-type'] === 'upload';
186
- }
200
+ },
201
+ hidden: !pluginConfig.debugging
187
202
  },
188
203
  label: 'Relation to'
189
204
  },
@@ -391,6 +406,32 @@ informative and accurate but also captivating and beautifully structured.`,
391
406
  providerOptionsJson
392
407
  ],
393
408
  label: 'TTS Settings'
409
+ },
410
+ // Array Settings
411
+ // Array Settings
412
+ {
413
+ name: 'array-settings',
414
+ type: 'group',
415
+ admin: {
416
+ condition: (data)=>data['model-id'] === 'array'
417
+ },
418
+ fields: [
419
+ providerSelect,
420
+ modelSelect,
421
+ {
422
+ name: 'count',
423
+ type: 'number',
424
+ admin: {
425
+ description: 'Number of items to generate'
426
+ },
427
+ defaultValue: 3,
428
+ label: 'Items to Generate',
429
+ max: 20,
430
+ min: 1
431
+ },
432
+ providerOptionsJson
433
+ ],
434
+ label: 'Array Settings'
394
435
  }
395
436
  ]
396
437
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/Instructions.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\nimport type { PluginConfig } from 'src/types.js'\n\nimport { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\n// Defined capabilities replacing src/ai/models/\nconst CAPABILITIES = [\n {\n id: 'text',\n name: 'Text Generation',\n fields: ['text', 'textarea'],\n },\n {\n id: 'richtext',\n name: 'Rich Text Generation',\n fields: ['richText'],\n },\n {\n id: 'image',\n name: 'Image Generation',\n fields: ['upload'],\n },\n {\n id: 'tts',\n name: 'Text to Speech',\n fields: ['upload'],\n },\n]\n\nconst defaultAccessConfig = {\n create: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n delete: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n read: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n update: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n}\n\nconst defaultAdminConfig = {\n group: 'Plugins',\n hidden: true,\n}\n\nconst providerSelect = {\n name: 'provider',\n type: 'text' as const,\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicProviderSelect',\n },\n },\n label: 'Provider',\n}\n\nconst modelSelect = {\n name: 'model',\n type: 'text' as const,\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicModelSelect',\n },\n },\n label: 'Model',\n}\n\nconst providerOptionsJson = {\n name: 'providerOptions',\n type: 'json' as const,\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#ProviderOptionsEditor',\n },\n description: 'Provider-specific options. Defaults are inherited from AI Settings.',\n },\n label: 'Provider Options',\n}\n\nconst commonTextParams = [\n {\n type: 'row' as const,\n fields: [\n {\n name: 'maxTokens',\n type: 'number' as const,\n admin: {\n placeholder: 'Model Default',\n },\n label: 'Max Tokens',\n },\n {\n name: 'temperature',\n type: 'number' as const,\n defaultValue: 0.7,\n label: 'Temperature',\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox' as const,\n label: 'Extract Attachments',\n },\n]\n\nexport const instructionsCollection = (pluginConfig: PluginConfig) =>\n <CollectionConfig>{\n labels: {\n plural: 'Compose Settings',\n singular: 'Compose Setting',\n },\n ...pluginConfig.overrideInstructions,\n slug: PLUGIN_INSTRUCTIONS_TABLE,\n access: {\n ...defaultAccessConfig,\n ...pluginConfig.overrideInstructions?.access,\n },\n admin: {\n ...defaultAdminConfig,\n ...pluginConfig.overrideInstructions?.admin,\n components: {\n beforeList: ['@ai-stack/payloadcms/client#AIConfigDashboard'],\n },\n },\n fields: [\n {\n name: 'schema-path',\n type: 'text',\n admin: {\n description: \"Please don't change this unless you're sure of what you're doing\",\n },\n unique: true,\n },\n {\n name: 'field-type',\n type: 'select',\n admin: {\n description: \"Please don't change this unless you're sure of what you're doing\",\n },\n defaultValue: 'text',\n label: 'Field type',\n options: [\n {\n label: 'text',\n value: 'text',\n },\n {\n label: 'textarea',\n value: 'textarea',\n },\n {\n label: 'upload',\n value: 'upload',\n },\n {\n label: 'richText',\n value: 'richText',\n },\n ],\n },\n {\n name: 'relation-to',\n type: 'text',\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'upload'\n },\n },\n label: 'Relation to',\n },\n {\n name: 'model-id',\n type: 'select',\n admin: {\n components: {\n Field: {\n clientProps: {\n filterByField: 'field-type',\n options: CAPABILITIES.map((c) => ({\n fields: c.fields,\n label: c.name,\n value: c.id,\n })),\n },\n path: '@ai-stack/payloadcms/fields#SelectField',\n },\n },\n },\n label: 'Capability',\n options: CAPABILITIES.map((c) => ({\n label: c.name,\n value: c.id,\n })),\n },\n {\n name: 'disabled',\n type: 'checkbox',\n admin: {\n description: 'Please reload your collection after applying the changes',\n },\n defaultValue: false,\n label: 'Hide Compose button for this field',\n },\n {\n id: 'ai-prompts-tabs',\n type: 'tabs',\n tabs: [\n {\n description:\n 'Define dynamic templates using {{ fieldName }}. Type { to see available field suggestions.',\n fields: [\n {\n name: 'prompt',\n type: 'textarea',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/fields#PromptEditorField',\n },\n description: \"Click 'Compose' to run this custom prompt and generate content\",\n },\n label: '',\n },\n ],\n label: 'Prompt',\n },\n {\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'upload' && current['model-id'] === 'image'\n },\n },\n description:\n 'These images will be used to generate new visuals in a similar style, layout, or content.',\n fields: [\n {\n name: 'images',\n type: 'array',\n fields: [\n {\n name: 'image',\n type: 'upload',\n admin: {\n description: 'Please make sure the image is publicly accessible.',\n },\n relationTo: pluginConfig.uploadCollectionSlug\n ? pluginConfig.uploadCollectionSlug\n : 'media',\n },\n ],\n },\n ],\n label: 'Sample Images',\n },\n {\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'richText'\n },\n },\n description: '',\n fields: [\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\nYou are a highly skilled and professional blog writer,\nrenowned for crafting engaging and well-organized articles.\nWhen given a title, you meticulously create blogs that are not only\ninformative and accurate but also captivating and beautifully structured.`,\n label: '',\n },\n ],\n label: 'System prompt',\n },\n {\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'richText'\n },\n },\n description: '',\n fields: [\n {\n name: 'layout',\n type: 'textarea',\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'richText'\n },\n },\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: '',\n },\n ],\n label: 'Layout',\n },\n ],\n },\n \n // Inline Settings Groups by Capability\n \n // Text Settings\n {\n name: 'text-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'text',\n },\n fields: [\n providerSelect,\n modelSelect,\n ...commonTextParams,\n providerOptionsJson,\n ],\n label: 'Text Settings',\n },\n \n // Rich Text Settings\n {\n name: 'richtext-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'richtext',\n },\n fields: [\n providerSelect,\n modelSelect,\n ...commonTextParams,\n providerOptionsJson,\n ],\n label: 'Rich Text Settings',\n },\n \n // Image Settings\n {\n name: 'image-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'image',\n },\n fields: [\n providerSelect,\n modelSelect,\n providerOptionsJson,\n ],\n label: 'Image Settings',\n },\n \n // TTS Settings\n {\n name: 'tts-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'tts',\n },\n fields: [\n providerSelect,\n modelSelect,\n {\n name: 'voice',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicVoiceSelect',\n },\n },\n label: 'Voice',\n },\n providerOptionsJson,\n ],\n label: 'TTS Settings',\n },\n ],\n }\n"],"names":["PLUGIN_INSTRUCTIONS_TABLE","CAPABILITIES","id","name","fields","defaultAccessConfig","create","req","user","delete","read","update","defaultAdminConfig","group","hidden","providerSelect","type","admin","components","Field","label","modelSelect","providerOptionsJson","description","commonTextParams","placeholder","defaultValue","max","min","instructionsCollection","pluginConfig","labels","plural","singular","overrideInstructions","slug","access","beforeList","unique","options","value","condition","_","current","clientProps","filterByField","map","c","path","tabs","relationTo","uploadCollectionSlug","data"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,iBAAgB;AAE1D,gDAAgD;AAAhD,gDAAgD;AAChD,MAAMC,eAAe;IACnB;QACEC,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;YAAQ;SAAW;IAC9B;IACA;QACEF,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;SAAW;IACtB;IACA;Q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,WAAW,CAACC,GAAGC;wCACb,OAAOA,OAAO,CAAC,aAAa,KAAK;oCACnC;gCACF;gCACAjB,cAAc,CAAC;;;;;;;2HAO4F,CAAC;gCAC5GN,OAAO;4BACT;yBACD;wBACDA,OAAO;oBACT;iBACD;YACH;YAEA,uCAAuC;YAEvC,gBAAgB;YAFhB,uCAAuC;YAEvC,gBAAgB;YAChB;gBACEjB,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLwB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAhD,QAAQ;oBACNW;oBACAM;uBACGG;oBACHF;iBACD;gBACDF,OAAO;YACT;YAEA,qBAAqB;YAArB,qBAAqB;YACrB;gBACEjB,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLwB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAhD,QAAQ;oBACNW;oBACAM;uBACGG;oBACHF;iBACD;gBACDF,OAAO;YACT;YAEA,iBAAiB;YAAjB,iBAAiB;YACjB;gBACEjB,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLwB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAhD,QAAQ;oBACNW;oBACAM;oBACAC;iBACD;gBACDF,OAAO;YACT;YAEA,eAAe;YAAf,eAAe;YACf;gBACEjB,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLwB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAhD,QAAQ;oBACNW;oBACAM;oBACA;wBACElB,MAAM;wBACNa,MAAM;wBACNC,OAAO;4BACLC,YAAY;gCACVC,OAAO;4BACT;wBACF;wBACAC,OAAO;oBACT;oBACAE;iBACD;gBACDF,OAAO;YACT;SACD;IACH,CAAA,EAAC"}
1
+ {"version":3,"sources":["../../src/collections/Instructions.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\nimport type { PluginConfig } from 'src/types.js'\n\nimport { PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\n// Defined capabilities replacing src/ai/models/\nconst CAPABILITIES = [\n {\n id: 'text',\n name: 'Text Generation',\n fields: ['text', 'textarea'],\n },\n {\n id: 'richtext',\n name: 'Rich Text Generation',\n fields: ['richText'],\n },\n {\n id: 'image',\n name: 'Image Generation',\n fields: ['upload'],\n },\n {\n id: 'tts',\n name: 'Text to Speech',\n fields: ['upload'],\n },\n {\n id: 'array',\n name: 'Array Generation',\n fields: ['array'],\n },\n]\n\nconst defaultAccessConfig = {\n create: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n delete: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n read: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n update: ({ req }: { req: { user?: any } }) => {\n if (!req.user) {\n return false\n }\n return true\n },\n}\n\nconst defaultAdminConfig = {\n group: 'Plugins',\n hidden: true,\n}\n\nconst providerSelect = {\n name: 'provider',\n type: 'text' as const,\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicProviderSelect',\n },\n },\n label: 'Provider',\n}\n\nconst modelSelect = {\n name: 'model',\n type: 'text' as const,\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicModelSelect',\n },\n },\n label: 'Model',\n}\n\nconst providerOptionsJson = {\n name: 'providerOptions',\n type: 'json' as const,\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#ProviderOptionsEditor',\n },\n description: 'Provider-specific options. Defaults are inherited from AI Settings.',\n },\n label: 'Provider Options',\n}\n\nconst commonTextParams = [\n {\n type: 'row' as const,\n fields: [\n {\n name: 'maxTokens',\n type: 'number' as const,\n admin: {\n placeholder: 'Model Default',\n },\n label: 'Max Tokens',\n },\n {\n name: 'temperature',\n type: 'number' as const,\n defaultValue: 0.7,\n label: 'Temperature',\n max: 1,\n min: 0,\n },\n ],\n },\n {\n name: 'extractAttachments',\n type: 'checkbox' as const,\n label: 'Extract Attachments',\n },\n]\n\nexport const instructionsCollection = (pluginConfig: PluginConfig) =>\n <CollectionConfig>{\n labels: {\n plural: 'Compose Settings',\n singular: 'Compose Setting',\n },\n ...pluginConfig.overrideInstructions,\n slug: PLUGIN_INSTRUCTIONS_TABLE,\n access: {\n ...defaultAccessConfig,\n ...pluginConfig.overrideInstructions?.access,\n },\n admin: {\n description: \"Customize how AI interacts with specific fields within your enabled collections.\",\n ...defaultAdminConfig,\n ...pluginConfig.overrideInstructions?.admin,\n components: {\n beforeList: ['@ai-stack/payloadcms/client#ConfigDashboard'],\n },\n },\n fields: [\n {\n name: 'schema-path',\n type: 'text',\n admin: {\n description: \"Please don't change this unless you're sure of what you're doing\",\n hidden: !pluginConfig.debugging,\n },\n unique: true,\n },\n {\n name: 'field-type',\n type: 'select',\n admin: {\n description: \"Please don't change this unless you're sure of what you're doing\",\n hidden: !pluginConfig.debugging,\n },\n defaultValue: 'text',\n label: 'Field type',\n options: [\n {\n label: 'text',\n value: 'text',\n },\n {\n label: 'textarea',\n value: 'textarea',\n },\n {\n label: 'upload',\n value: 'upload',\n },\n {\n label: 'richText',\n value: 'richText',\n },\n {\n label: 'array',\n value: 'array',\n },\n ],\n },\n {\n name: 'relation-to',\n type: 'text',\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'upload'\n },\n hidden: !pluginConfig.debugging,\n },\n label: 'Relation to',\n },\n {\n name: 'model-id',\n type: 'select',\n admin: {\n components: {\n Field: {\n clientProps: {\n filterByField: 'field-type',\n options: CAPABILITIES.map((c) => ({\n fields: c.fields,\n label: c.name,\n value: c.id,\n })),\n },\n path: '@ai-stack/payloadcms/fields#SelectField',\n },\n },\n },\n label: 'Capability',\n options: CAPABILITIES.map((c) => ({\n label: c.name,\n value: c.id,\n })),\n },\n {\n name: 'disabled',\n type: 'checkbox',\n admin: {\n description: 'Please reload your collection after applying the changes',\n },\n defaultValue: false,\n label: 'Hide Compose button for this field',\n },\n {\n id: 'ai-prompts-tabs',\n type: 'tabs',\n tabs: [\n {\n description:\n 'Define dynamic templates using {{ fieldName }}. Type { to see available field suggestions.',\n fields: [\n {\n name: 'prompt',\n type: 'textarea',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/fields#PromptEditorField',\n },\n description: \"Click 'Compose' to run this custom prompt and generate content\",\n },\n label: '',\n },\n ],\n label: 'Prompt',\n },\n {\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'upload' && current['model-id'] === 'image'\n },\n },\n description:\n 'These images will be used to generate new visuals in a similar style, layout, or content.',\n fields: [\n {\n name: 'images',\n type: 'array',\n fields: [\n {\n name: 'image',\n type: 'upload',\n admin: {\n description: 'Please make sure the image is publicly accessible.',\n },\n relationTo: pluginConfig.uploadCollectionSlug\n ? pluginConfig.uploadCollectionSlug\n : 'media',\n },\n ],\n },\n ],\n label: 'Sample Images',\n },\n {\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'richText'\n },\n },\n description: '',\n fields: [\n {\n name: 'system',\n type: 'textarea',\n defaultValue: `INSTRUCTIONS:\nYou are a highly skilled and professional blog writer,\nrenowned for crafting engaging and well-organized articles.\nWhen given a title, you meticulously create blogs that are not only\ninformative and accurate but also captivating and beautifully structured.`,\n label: '',\n },\n ],\n label: 'System prompt',\n },\n {\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'richText'\n },\n },\n description: '',\n fields: [\n {\n name: 'layout',\n type: 'textarea',\n admin: {\n condition: (_, current) => {\n return current['field-type'] === 'richText'\n },\n },\n defaultValue: `[paragraph] - Write a concise introduction (2-3 sentences) that outlines the main topic.\n[horizontalrule] - Insert a horizontal rule to separate the introduction from the main content.\n[list] - Create a list with 3-5 items. Each list item should contain:\n a. [heading] - A brief, descriptive heading (up to 5 words)\n b. [paragraph] - A short explanation or elaboration (1-2 sentences)\n[horizontalrule] - Insert another horizontal rule to separate the main content from the conclusion.\n[paragraph] - Compose a brief conclusion (2-3 sentences) summarizing the key points.\n[quote] - Include a relevant quote from a famous person, directly related to the topic. Format: \"Quote text.\" - Author Name`,\n label: '',\n },\n ],\n label: 'Layout',\n },\n ],\n },\n \n // Inline Settings Groups by Capability\n \n // Text Settings\n {\n name: 'text-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'text',\n },\n fields: [\n providerSelect,\n modelSelect,\n ...commonTextParams,\n providerOptionsJson,\n ],\n label: 'Text Settings',\n },\n \n // Rich Text Settings\n {\n name: 'richtext-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'richtext',\n },\n fields: [\n providerSelect,\n modelSelect,\n ...commonTextParams,\n providerOptionsJson,\n ],\n label: 'Rich Text Settings',\n },\n \n // Image Settings\n {\n name: 'image-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'image',\n },\n fields: [\n providerSelect,\n modelSelect,\n providerOptionsJson,\n ],\n label: 'Image Settings',\n },\n \n // TTS Settings\n {\n name: 'tts-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'tts',\n },\n fields: [\n providerSelect,\n modelSelect,\n {\n name: 'voice',\n type: 'text',\n admin: {\n components: {\n Field: '@ai-stack/payloadcms/client#DynamicVoiceSelect',\n },\n },\n label: 'Voice',\n },\n providerOptionsJson,\n ],\n label: 'TTS Settings',\n },\n \n // Array Settings\n {\n name: 'array-settings',\n type: 'group',\n admin: {\n condition: (data) => data['model-id'] === 'array',\n },\n fields: [\n providerSelect,\n modelSelect,\n {\n name: 'count',\n type: 'number',\n admin: {\n description: 'Number of items to generate',\n },\n defaultValue: 3,\n label: 'Items to Generate',\n max: 20,\n min: 1,\n },\n providerOptionsJson,\n ],\n label: 'Array Settings',\n },\n ],\n }\n"],"names":["PLUGIN_INSTRUCTIONS_TABLE","CAPABILITIES","id","name","fields","defaultAccessConfig","create","req","user","delete","read","update","defaultAdminConfig","group","hidden","providerSelect","type","admin","components","Field","label","modelSelect","providerOptionsJson","description","commonTextParams","placeholder","defaultValue","max","min","instructionsCollection","pluginConfig","labels","plural","singular","overrideInstructions","slug","access","beforeList","debugging","unique","options","value","condition","_","current","clientProps","filterByField","map","c","path","tabs","relationTo","uploadCollectionSlug","data"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,iBAAgB;AAE1D,gDAAgD;AAAhD,gDAAgD;AAChD,MAAMC,eAAe;IACnB;QACEC,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;YAAQ;SAAW;IAC9B;IACA;QACEF,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;SAAW;IACtB;IACA;QACEF,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;SAAS;IACpB;IACA;QACEF,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;SAAS;IACpB;IACA;QACEF,IAAI;QACJC,MAAM;QACNC,QAAQ;YAAC;SAAQ;IACnB;CACD;AAED,MAAMC,sBAAsB;IAC1BC,QAAQ,CAAC,EAAEC,GAAG,EAA2B;QACvC,IAAI,CAACA,IAAIC,IAAI,EAAE;YACb,OAAO;QACT;QACA,OAAO;IACT;IACAC,QAAQ,CAAC,EAAEF,GAAG,EAA2B;QACvC,IAAI,CAACA,IAAIC,IAAI,EAAE;YACb,OAAO;QACT;QACA,OAAO;IACT;IACAE,MAAM,CAAC,EAAEH,GAAG,EAA2B;QACrC,IAAI,CAACA,IAAIC,IAAI,EAAE;YACb,OAAO;QACT;QACA,OAAO;IACT;IACAG,QAAQ,CAAC,EAAEJ,GAAG,EAA2B;QACvC,IAAI,CAACA,IAAIC,IAAI,EAAE;YACb,OAAO;QACT;QACA,OAAO;IACT;AACF;AAEA,MAAMI,qBAAqB;IACzBC,OAAO;IACPC,QAAQ;AACV;AAEA,MAAMC,iBAAiB;IACrBZ,MAAM;IACNa,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;IACAC,OAAO;AACT;AAEA,MAAMC,cAAc;IAClBlB,MAAM;IACNa,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;IACAC,OAAO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O;oBACLyB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAjD,QAAQ;oBACNW;oBACAM;oBACAC;iBACD;gBACDF,OAAO;YACT;YAEA,eAAe;YAAf,eAAe;YACf;gBACEjB,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLyB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAjD,QAAQ;oBACNW;oBACAM;oBACA;wBACElB,MAAM;wBACNa,MAAM;wBACNC,OAAO;4BACLC,YAAY;gCACVC,OAAO;4BACT;wBACF;wBACAC,OAAO;oBACT;oBACAE;iBACD;gBACDF,OAAO;YACT;YAEA,iBAAiB;YAAjB,iBAAiB;YACjB;gBACEjB,MAAM;gBACNa,MAAM;gBACNC,OAAO;oBACLyB,WAAW,CAACW,OAASA,IAAI,CAAC,WAAW,KAAK;gBAC5C;gBACAjD,QAAQ;oBACNW;oBACAM;oBACA;wBACElB,MAAM;wBACNa,MAAM;wBACNC,OAAO;4BACLM,aAAa;wBACf;wBACAG,cAAc;wBACdN,OAAO;wBACPO,KAAK;wBACLC,KAAK;oBACP;oBACAN;iBACD;gBACDF,OAAO;YACT;SACD;IACH,CAAA,EAAC"}
@@ -10,3 +10,4 @@ export declare const PLUGIN_API_ENDPOINT_VIDEOGEN_WEBHOOK = "/plugin-ai/videogen
10
10
  export declare const PLUGIN_API_ENDPOINT_FETCH_VOICES = "/plugin-ai/elevenlabs/fetch-voices";
11
11
  export declare const PLUGIN_DEFAULT_OPENAI_MODEL = "gpt-4o-mini";
12
12
  export declare const PLUGIN_DEFAULT_ANTHROPIC_MODEL = "claude-3-5-sonnet-latest";
13
+ export declare const excludeCollections: string[];
package/dist/defaults.js CHANGED
@@ -12,5 +12,13 @@ export const PLUGIN_API_ENDPOINT_FETCH_VOICES = `${PLUGIN_API_ENDPOINT_BASE}/ele
12
12
  // LLM Settings
13
13
  export const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`;
14
14
  export const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-5-sonnet-latest`;
15
+ export const excludeCollections = [
16
+ 'payload-preferences',
17
+ 'payload-migrations',
18
+ 'payload-locked-documents',
19
+ 'ai-providers',
20
+ PLUGIN_INSTRUCTIONS_TABLE,
21
+ PLUGIN_AI_JOBS_TABLE
22
+ ];
15
23
 
16
24
  //# sourceMappingURL=defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_AI_JOBS_TABLE = `${PLUGIN_NAME}-ai-jobs`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\nexport const PLUGIN_FETCH_FIELDS_ENDPOINT = `${PLUGIN_API_ENDPOINT_BASE}/fetch-fields`\nexport const PLUGIN_API_ENDPOINT_VIDEOGEN_WEBHOOK = `${PLUGIN_API_ENDPOINT_BASE}/videogen/webhook`\nexport const PLUGIN_API_ENDPOINT_FETCH_VOICES = `${PLUGIN_API_ENDPOINT_BASE}/elevenlabs/fetch-voices`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-5-sonnet-latest`\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_AI_JOBS_TABLE","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_FETCH_FIELDS_ENDPOINT","PLUGIN_API_ENDPOINT_VIDEOGEN_WEBHOOK","PLUGIN_API_ENDPOINT_FETCH_VOICES","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,CAAC,EAAED,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,uBAAuB,CAAC,EAAEF,YAAY,QAAQ,CAAC,CAAA;AAC5D,OAAO,MAAMG,gCAAgC,CAAC,EAAEH,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMI,2BAA2B,CAAC,CAAC,EAAEJ,YAAY,CAAC,CAAA;AACzD,OAAO,MAAMK,+BAA+B,CAAC,EAAED,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,CAAC,EAAED,6BAA6B,OAAO,CAAC,CAAA;AAC3F,OAAO,MAAME,+BAA+B,CAAC,EAAEH,yBAAyB,aAAa,CAAC,CAAA;AACtF,OAAO,MAAMI,uCAAuC,CAAC,EAAEJ,yBAAyB,iBAAiB,CAAC,CAAA;AAClG,OAAO,MAAMK,mCAAmC,CAAC,EAAEL,yBAAyB,wBAAwB,CAAC,CAAA;AAErG,eAAe;AACf,OAAO,MAAMM,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA"}
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["export const PLUGIN_NAME = 'plugin-ai'\nexport const PLUGIN_INSTRUCTIONS_TABLE = `${PLUGIN_NAME}-instructions`\nexport const PLUGIN_AI_JOBS_TABLE = `${PLUGIN_NAME}-ai-jobs`\nexport const PLUGIN_LEXICAL_EDITOR_FEATURE = `${PLUGIN_NAME}-actions-feature`\n\n// Endpoint defaults\nexport const PLUGIN_API_ENDPOINT_BASE = `/${PLUGIN_NAME}`\nexport const PLUGIN_API_ENDPOINT_GENERATE = `${PLUGIN_API_ENDPOINT_BASE}/generate`\nexport const PLUGIN_API_ENDPOINT_GENERATE_UPLOAD = `${PLUGIN_API_ENDPOINT_GENERATE}/upload`\nexport const PLUGIN_FETCH_FIELDS_ENDPOINT = `${PLUGIN_API_ENDPOINT_BASE}/fetch-fields`\nexport const PLUGIN_API_ENDPOINT_VIDEOGEN_WEBHOOK = `${PLUGIN_API_ENDPOINT_BASE}/videogen/webhook`\nexport const PLUGIN_API_ENDPOINT_FETCH_VOICES = `${PLUGIN_API_ENDPOINT_BASE}/elevenlabs/fetch-voices`\n\n// LLM Settings\nexport const PLUGIN_DEFAULT_OPENAI_MODEL = `gpt-4o-mini`\nexport const PLUGIN_DEFAULT_ANTHROPIC_MODEL = `claude-3-5-sonnet-latest`\n\nexport const excludeCollections = [\n 'payload-preferences',\n 'payload-migrations',\n 'payload-locked-documents',\n 'ai-providers',\n PLUGIN_INSTRUCTIONS_TABLE,\n PLUGIN_AI_JOBS_TABLE,\n]\n"],"names":["PLUGIN_NAME","PLUGIN_INSTRUCTIONS_TABLE","PLUGIN_AI_JOBS_TABLE","PLUGIN_LEXICAL_EDITOR_FEATURE","PLUGIN_API_ENDPOINT_BASE","PLUGIN_API_ENDPOINT_GENERATE","PLUGIN_API_ENDPOINT_GENERATE_UPLOAD","PLUGIN_FETCH_FIELDS_ENDPOINT","PLUGIN_API_ENDPOINT_VIDEOGEN_WEBHOOK","PLUGIN_API_ENDPOINT_FETCH_VOICES","PLUGIN_DEFAULT_OPENAI_MODEL","PLUGIN_DEFAULT_ANTHROPIC_MODEL","excludeCollections"],"mappings":"AAAA,OAAO,MAAMA,cAAc,YAAW;AACtC,OAAO,MAAMC,4BAA4B,CAAC,EAAED,YAAY,aAAa,CAAC,CAAA;AACtE,OAAO,MAAME,uBAAuB,CAAC,EAAEF,YAAY,QAAQ,CAAC,CAAA;AAC5D,OAAO,MAAMG,gCAAgC,CAAC,EAAEH,YAAY,gBAAgB,CAAC,CAAA;AAE7E,oBAAoB;AACpB,OAAO,MAAMI,2BAA2B,CAAC,CAAC,EAAEJ,YAAY,CAAC,CAAA;AACzD,OAAO,MAAMK,+BAA+B,CAAC,EAAED,yBAAyB,SAAS,CAAC,CAAA;AAClF,OAAO,MAAME,sCAAsC,CAAC,EAAED,6BAA6B,OAAO,CAAC,CAAA;AAC3F,OAAO,MAAME,+BAA+B,CAAC,EAAEH,yBAAyB,aAAa,CAAC,CAAA;AACtF,OAAO,MAAMI,uCAAuC,CAAC,EAAEJ,yBAAyB,iBAAiB,CAAC,CAAA;AAClG,OAAO,MAAMK,mCAAmC,CAAC,EAAEL,yBAAyB,wBAAwB,CAAC,CAAA;AAErG,eAAe;AACf,OAAO,MAAMM,8BAA8B,CAAC,WAAW,CAAC,CAAA;AACxD,OAAO,MAAMC,iCAAiC,CAAC,wBAAwB,CAAC,CAAA;AAExE,OAAO,MAAMC,qBAAqB;IAChC;IACA;IACA;IACA;IACAX;IACAC;CACD,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { Endpoint } from 'payload';
2
+
3
+ import type { PluginConfig } from '../types.js';
4
+ export declare const Chat: (pluginConfig: PluginConfig) => Endpoint;
@@ -9,6 +9,15 @@ export const fetchFields = (config)=>{
9
9
  });
10
10
  let isConfigAllowed = true // Users allowed to update prompts by default
11
11
  ;
12
+ let enabledCollections = [];
13
+ try {
14
+ const { enabledCollections: storedEnabledCollections } = await req.payload.findGlobal({
15
+ slug: 'ai-providers'
16
+ });
17
+ enabledCollections = storedEnabledCollections || [];
18
+ } catch (e) {
19
+ req.payload.logger.error('Failed to fetch AI settings');
20
+ }
12
21
  if (access?.settings) {
13
22
  try {
14
23
  isConfigAllowed = await access.settings({
@@ -29,6 +38,7 @@ export const fetchFields = (config)=>{
29
38
  return Response.json({
30
39
  ...options,
31
40
  debugging: config.debugging,
41
+ enabledCollections,
32
42
  fields: fieldMap,
33
43
  isConfigAllowed,
34
44
  promptFields: promptFields.map(({ getter: _getter, ...field })=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/endpoints/fetchFields.ts"],"sourcesContent":["import type { Endpoint, PayloadRequest } from 'payload'\n\nimport type { PluginConfig, SerializedPromptField } from '../types.js'\n\nimport { PLUGIN_FETCH_FIELDS_ENDPOINT, PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\nexport const fetchFields: (config: PluginConfig) => Endpoint = (config) => {\n const { access, options = {}, promptFields = [] } = config\n return {\n handler: async (req: PayloadRequest) => {\n const { docs = [] } = await req.payload.find({\n collection: PLUGIN_INSTRUCTIONS_TABLE,\n pagination: false,\n })\n\n let isConfigAllowed = true // Users allowed to update prompts by default\n\n if (access?.settings) {\n try {\n isConfigAllowed = await access.settings({ req })\n } catch (e) {\n req.payload.logger.error(req, 'Please check your \"access.settings\" for request')\n }\n }\n\n const fieldMap: Record<string, { disabled?: boolean; fieldType: any; id: any }> = {}\n docs.forEach((doc) => {\n fieldMap[doc['schema-path']] = {\n id: doc.id,\n disabled: !!doc['disabled'],\n fieldType: doc['field-type'],\n }\n })\n\n return Response.json({\n ...options,\n debugging: config.debugging,\n fields: fieldMap,\n isConfigAllowed,\n promptFields: promptFields.map(({ getter: _getter, ...field }): SerializedPromptField => {\n return field\n }),\n })\n },\n method: 'get',\n path: PLUGIN_FETCH_FIELDS_ENDPOINT,\n }\n}\n"],"names":["PLUGIN_FETCH_FIELDS_ENDPOINT","PLUGIN_INSTRUCTIONS_TABLE","fetchFields","config","access","options","promptFields","handler","req","docs","payload","find","collection","pagination","isConfigAllowed","settings","e","logger","error","fieldMap","forEach","doc","id","disabled","fieldType","Response","json","debugging","fields","map","getter","_getter","field","method","path"],"mappings":"AAIA,SAASA,4BAA4B,EAAEC,yBAAyB,QAAQ,iBAAgB;AAExF,OAAO,MAAMC,cAAkD,CAACC;IAC9D,MAAM,EAAEC,MAAM,EAAEC,UAAU,CAAC,CAAC,EAAEC,eAAe,EAAE,EAAE,GAAGH;IACpD,OAAO;QACLI,SAAS,OAAOC;YACd,MAAM,EAAEC,OAAO,EAAE,EAAE,GAAG,MAAMD,IAAIE,OAAO,CAACC,IAAI,CAAC;gBAC3CC,YAAYX;gBACZY,YAAY;YACd;YAEA,IAAIC,kBAAkB,KAAK,6CAA6C;;YAExE,IAAIV,QAAQW,UAAU;gBACpB,IAAI;oBACFD,kBAAkB,MAAMV,OAAOW,QAAQ,CAAC;wBAAEP;oBAAI;gBAChD,EAAE,OAAOQ,GAAG;oBACVR,IAAIE,OAAO,CAACO,MAAM,CAACC,KAAK,CAACV,KAAK;gBAChC;YACF;YAEA,MAAMW,WAA4E,CAAC;YACnFV,KAAKW,OAAO,CAAC,CAACC;gBACZF,QAAQ,CAACE,GAAG,CAAC,cAAc,CAAC,GAAG;oBAC7BC,IAAID,IAAIC,EAAE;oBACVC,UAAU,CAAC,CAACF,GAAG,CAAC,WAAW;oBAC3BG,WAAWH,GAAG,CAAC,aAAa;gBAC9B;YACF;YAEA,OAAOI,SAASC,IAAI,CAAC;gBACnB,GAAGrB,OAAO;gBACVsB,WAAWxB,OAAOwB,SAAS;gBAC3BC,QAAQT;gBACRL;gBACAR,cAAcA,aAAauB,GAAG,CAAC,CAAC,EAAEC,QAAQC,OAAO,EAAE,GAAGC,OAAO;oBAC3D,OAAOA;gBACT;YACF;QACF;QACAC,QAAQ;QACRC,MAAMlC;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/endpoints/fetchFields.ts"],"sourcesContent":["import type { Endpoint, PayloadRequest } from 'payload'\n\nimport type { PluginConfig, SerializedPromptField } from '../types.js'\n\nimport { PLUGIN_FETCH_FIELDS_ENDPOINT, PLUGIN_INSTRUCTIONS_TABLE } from '../defaults.js'\n\nexport const fetchFields: (config: PluginConfig) => Endpoint = (config) => {\n const { access, options = {}, promptFields = [] } = config\n return {\n handler: async (req: PayloadRequest) => {\n const { docs = [] } = await req.payload.find({\n collection: PLUGIN_INSTRUCTIONS_TABLE,\n pagination: false,\n })\n\n let isConfigAllowed = true // Users allowed to update prompts by default\n let enabledCollections: string[] = []\n\n try {\n const { enabledCollections: storedEnabledCollections } = await req.payload.findGlobal({\n slug: 'ai-providers',\n })\n enabledCollections = (storedEnabledCollections as string[]) || []\n } catch (e) {\n req.payload.logger.error('Failed to fetch AI settings')\n }\n\n if (access?.settings) {\n try {\n isConfigAllowed = await access.settings({ req })\n } catch (e) {\n req.payload.logger.error(req, 'Please check your \"access.settings\" for request')\n }\n }\n\n const fieldMap: Record<string, { disabled?: boolean; fieldType: any; id: any }> = {}\n docs.forEach((doc) => {\n fieldMap[doc['schema-path']] = {\n id: doc.id,\n disabled: !!doc['disabled'],\n fieldType: doc['field-type'],\n }\n })\n\n return Response.json({\n ...options,\n debugging: config.debugging,\n enabledCollections,\n fields: fieldMap,\n isConfigAllowed,\n promptFields: promptFields.map(({ getter: _getter, ...field }): SerializedPromptField => {\n return field\n }),\n })\n },\n method: 'get',\n path: PLUGIN_FETCH_FIELDS_ENDPOINT,\n }\n}\n"],"names":["PLUGIN_FETCH_FIELDS_ENDPOINT","PLUGIN_INSTRUCTIONS_TABLE","fetchFields","config","access","options","promptFields","handler","req","docs","payload","find","collection","pagination","isConfigAllowed","enabledCollections","storedEnabledCollections","findGlobal","slug","e","logger","error","settings","fieldMap","forEach","doc","id","disabled","fieldType","Response","json","debugging","fields","map","getter","_getter","field","method","path"],"mappings":"AAIA,SAASA,4BAA4B,EAAEC,yBAAyB,QAAQ,iBAAgB;AAExF,OAAO,MAAMC,cAAkD,CAACC;IAC9D,MAAM,EAAEC,MAAM,EAAEC,UAAU,CAAC,CAAC,EAAEC,eAAe,EAAE,EAAE,GAAGH;IACpD,OAAO;QACLI,SAAS,OAAOC;YACd,MAAM,EAAEC,OAAO,EAAE,EAAE,GAAG,MAAMD,IAAIE,OAAO,CAACC,IAAI,CAAC;gBAC3CC,YAAYX;gBACZY,YAAY;YACd;YAE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