@ai-stack/payloadcms 3.68.0-beta.3 → 3.68.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/core/streamObject.js +3 -0
- package/dist/ai/core/streamObject.js.map +1 -1
- package/dist/ai/core/types.d.ts +3 -0
- package/dist/ai/core/types.js.map +1 -1
- package/dist/ai/prompts.d.ts +1 -2
- package/dist/ai/prompts.js +0 -110
- package/dist/ai/prompts.js.map +1 -1
- package/dist/ai/providers/registry.js +0 -1
- package/dist/ai/providers/registry.js.map +1 -1
- package/dist/ai/utils/filterEditorSchemaByNodes.d.ts +9 -0
- package/dist/ai/utils/filterEditorSchemaByNodes.js +30 -3
- package/dist/ai/utils/filterEditorSchemaByNodes.js.map +1 -1
- package/dist/ai/utils/nodeToSchemaMap.d.ts +22 -0
- package/dist/ai/utils/nodeToSchemaMap.js +72 -0
- package/dist/ai/utils/nodeToSchemaMap.js.map +1 -0
- package/dist/collections/AIJobs.js +1 -1
- package/dist/collections/AIJobs.js.map +1 -1
- package/dist/collections/AISettings.js +3 -3
- package/dist/collections/AISettings.js.map +1 -1
- package/dist/endpoints/fetchVoices.js +41 -24
- package/dist/endpoints/fetchVoices.js.map +1 -1
- package/dist/endpoints/index.js +108 -6
- package/dist/endpoints/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/payload-ai.d.ts +7 -4
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +34 -2
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/Compose/Compose.js +23 -6
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/Compose.jsx +23 -4
- package/dist/ui/Compose/hooks/useGenerate.js +21 -72
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerateUpload.d.ts +3 -3
- package/dist/ui/Compose/hooks/useGenerateUpload.js +37 -10
- package/dist/ui/Compose/hooks/useGenerateUpload.js.map +1 -1
- package/dist/ui/Compose/hooks/useStreamingUpdate.js.map +1 -1
- package/dist/ui/VoicesFetcher/index.js +33 -61
- package/dist/ui/VoicesFetcher/index.js.map +1 -1
- package/dist/ui/VoicesFetcher/index.jsx +31 -37
- package/dist/utilities/buildSmartPrompt.js +4 -6
- package/dist/utilities/buildSmartPrompt.js.map +1 -1
- package/dist/utilities/encryption.js +2 -1
- package/dist/utilities/encryption.js.map +1 -1
- package/dist/utilities/seedProperties.js +7 -24
- package/dist/utilities/seedProperties.js.map +1 -1
- package/dist/utilities/setSafeLexicalState.js +1 -2
- package/dist/utilities/setSafeLexicalState.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/core/streamObject.ts"],"sourcesContent":["import { type ImagePart, jsonSchema, streamObject as sdkStreamObject, type TextPart } from 'ai'\n\nimport type { PayloadGenerateObjectArgs } from './types.js'\n\nimport { getLanguageModel } from '../providers/registry.js'\n\nfunction isZodSchema(schema: unknown): boolean {\n return typeof schema === 'object' && schema !== null && '_def' in schema\n}\n\n/**\n * Stream structured output using AI SDK's streamObject\n * This is a thin wrapper that resolves the model from the registry\n * and passes everything directly to the AI SDK for streaming\n */\nexport async function streamObject(args: PayloadGenerateObjectArgs) {\n const { \n maxTokens, \n mode,\n model: modelId,\n payload,\n prompt,\n provider,\n providerOptions,\n schema,\n system,\n temperature,\n ...rest\n } = args\n \n // Resolve model from registry\n const model = await getLanguageModel(payload, provider, modelId, providerOptions)\n \n // Return streaming result from AI SDK\n const options: Record<string, unknown> = {\n mode: mode || 'auto',\n model,\n schema: schema ? (isZodSchema(schema) ? schema : jsonSchema(schema as Record<string, unknown>)) : undefined,\n system,\n temperature: temperature ?? 0.7,\n ...(maxTokens ? { maxOutputTokens: maxTokens } : {}),\n }\n\n // Handle multimodal input\n if ((args.images && args.images.length > 0) || (args.messages && args.messages.length > 0)) {\n if (args.messages) {\n options.messages = args.messages\n } else {\n // Construct multimodal message from prompt and images\n const content: Array<ImagePart | TextPart> = [\n { type: 'text', text: prompt },\n ...(args.images || []),\n ]\n\n options.messages = [\n { content, role: 'user' as const },\n ]\n }\n } else {\n options.prompt = prompt\n }\n\n\n if (providerOptions) {\n options.providerOptions = providerOptions\n }\n\n return sdkStreamObject(options as Parameters<typeof sdkStreamObject>[0])\n}\n"],"names":["jsonSchema","streamObject","sdkStreamObject","getLanguageModel","isZodSchema","schema","args","maxTokens","mode","model","modelId","payload","prompt","provider","providerOptions","system","temperature","rest","options","undefined","maxOutputTokens","images","length","messages","content","type","text","role"],"mappings":"AAAA,SAAyBA,UAAU,EAAEC,gBAAgBC,eAAe,QAAuB,KAAI;AAI/F,SAASC,gBAAgB,QAAQ,2BAA0B;AAE3D,SAASC,YAAYC,MAAe;IAClC,OAAO,OAAOA,WAAW,YAAYA,WAAW,QAAQ,UAAUA;AACpE;AAEA;;;;CAIC,GACD,OAAO,eAAeJ,aAAaK,IAA+B;IAChE,MAAM,EACJC,SAAS,EACTC,IAAI,EACJC,OAAOC,OAAO,EACdC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfT,MAAM,EACNU,MAAM,EACNC,WAAW,EACX,GAAGC,MACJ,GAAGX;IAEJ,8BAA8B;IAC9B,MAAMG,QAAQ,MAAMN,iBAAiBQ,SAASE,UAAUH,SAASI;IAEjE,sCAAsC;IACtC,MAAMI,UAAmC;QACvCV,MAAMA,QAAQ;QACdC;QACAJ,QAAQA,SAAUD,YAAYC,UAAUA,SAASL,WAAWK,UAAsCc;QAClGJ;QACAC,aAAaA,eAAe;QAC5B,GAAIT,YAAY;YAAEa,iBAAiBb;QAAU,IAAI,CAAC,CAAC;IACrD;IAEA,0BAA0B;IAC1B,IAAI,AAACD,KAAKe,MAAM,IAAIf,KAAKe,MAAM,CAACC,MAAM,GAAG,KAAOhB,KAAKiB,QAAQ,IAAIjB,KAAKiB,QAAQ,CAACD,MAAM,GAAG,GAAI;QAC1F,IAAIhB,KAAKiB,QAAQ,EAAE;YACjBL,QAAQK,QAAQ,GAAGjB,KAAKiB,QAAQ;QAClC,OAAO;YACL,sDAAsD;YACtD,MAAMC,UAAuC;gBAC3C;oBAAEC,MAAM;oBAAQC,MAAMd;gBAAO;mBACzBN,KAAKe,MAAM,IAAI,EAAE;aACtB;YAEDH,QAAQK,QAAQ,GAAG;gBACjB;oBAAEC;oBAASG,MAAM;gBAAgB;aAClC;QACH;IACF,OAAO;QACLT,QAAQN,MAAM,GAAGA;IACnB;IAGA,IAAIE,iBAAiB;QACnBI,QAAQJ,eAAe,GAAGA;IAC5B;IAEA,
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/core/streamObject.ts"],"sourcesContent":["import { type ImagePart, jsonSchema, streamObject as sdkStreamObject, type TextPart } from 'ai'\n\nimport type { PayloadGenerateObjectArgs } from './types.js'\n\nimport { getLanguageModel } from '../providers/registry.js'\n\nfunction isZodSchema(schema: unknown): boolean {\n return typeof schema === 'object' && schema !== null && '_def' in schema\n}\n\n/**\n * Stream structured output using AI SDK's streamObject\n * This is a thin wrapper that resolves the model from the registry\n * and passes everything directly to the AI SDK for streaming\n */\nexport async function streamObject(args: PayloadGenerateObjectArgs) {\n const { \n maxTokens, \n mode,\n model: modelId,\n payload,\n prompt,\n provider,\n providerOptions,\n schema,\n system,\n temperature,\n ...rest\n } = args\n \n // Resolve model from registry\n const model = await getLanguageModel(payload, provider, modelId, providerOptions)\n \n // Return streaming result from AI SDK\n const options: Record<string, unknown> = {\n mode: mode || 'auto',\n model,\n schema: schema ? (isZodSchema(schema) ? schema : jsonSchema(schema as Record<string, unknown>)) : undefined,\n system,\n temperature: temperature ?? 0.7,\n ...(maxTokens ? { maxOutputTokens: maxTokens } : {}),\n }\n\n // Handle multimodal input\n if ((args.images && args.images.length > 0) || (args.messages && args.messages.length > 0)) {\n if (args.messages) {\n options.messages = args.messages\n } else {\n // Construct multimodal message from prompt and images\n const content: Array<ImagePart | TextPart> = [\n { type: 'text', text: prompt },\n ...(args.images || []),\n ]\n\n options.messages = [\n { content, role: 'user' as const },\n ]\n }\n } else {\n options.prompt = prompt\n }\n\n\n if (providerOptions) {\n options.providerOptions = providerOptions\n }\n\n if (rest.onFinish) {\n options.onFinish = rest.onFinish\n }\n\n return sdkStreamObject(options as Parameters<typeof sdkStreamObject>[0])\n}\n"],"names":["jsonSchema","streamObject","sdkStreamObject","getLanguageModel","isZodSchema","schema","args","maxTokens","mode","model","modelId","payload","prompt","provider","providerOptions","system","temperature","rest","options","undefined","maxOutputTokens","images","length","messages","content","type","text","role","onFinish"],"mappings":"AAAA,SAAyBA,UAAU,EAAEC,gBAAgBC,eAAe,QAAuB,KAAI;AAI/F,SAASC,gBAAgB,QAAQ,2BAA0B;AAE3D,SAASC,YAAYC,MAAe;IAClC,OAAO,OAAOA,WAAW,YAAYA,WAAW,QAAQ,UAAUA;AACpE;AAEA;;;;CAIC,GACD,OAAO,eAAeJ,aAAaK,IAA+B;IAChE,MAAM,EACJC,SAAS,EACTC,IAAI,EACJC,OAAOC,OAAO,EACdC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,eAAe,EACfT,MAAM,EACNU,MAAM,EACNC,WAAW,EACX,GAAGC,MACJ,GAAGX;IAEJ,8BAA8B;IAC9B,MAAMG,QAAQ,MAAMN,iBAAiBQ,SAASE,UAAUH,SAASI;IAEjE,sCAAsC;IACtC,MAAMI,UAAmC;QACvCV,MAAMA,QAAQ;QACdC;QACAJ,QAAQA,SAAUD,YAAYC,UAAUA,SAASL,WAAWK,UAAsCc;QAClGJ;QACAC,aAAaA,eAAe;QAC5B,GAAIT,YAAY;YAAEa,iBAAiBb;QAAU,IAAI,CAAC,CAAC;IACrD;IAEA,0BAA0B;IAC1B,IAAI,AAACD,KAAKe,MAAM,IAAIf,KAAKe,MAAM,CAACC,MAAM,GAAG,KAAOhB,KAAKiB,QAAQ,IAAIjB,KAAKiB,QAAQ,CAACD,MAAM,GAAG,GAAI;QAC1F,IAAIhB,KAAKiB,QAAQ,EAAE;YACjBL,QAAQK,QAAQ,GAAGjB,KAAKiB,QAAQ;QAClC,OAAO;YACL,sDAAsD;YACtD,MAAMC,UAAuC;gBAC3C;oBAAEC,MAAM;oBAAQC,MAAMd;gBAAO;mBACzBN,KAAKe,MAAM,IAAI,EAAE;aACtB;YAEDH,QAAQK,QAAQ,GAAG;gBACjB;oBAAEC;oBAASG,MAAM;gBAAgB;aAClC;QACH;IACF,OAAO;QACLT,QAAQN,MAAM,GAAGA;IACnB;IAGA,IAAIE,iBAAiB;QACnBI,QAAQJ,eAAe,GAAGA;IAC5B;IAEA,IAAIG,KAAKW,QAAQ,EAAE;QACjBV,QAAQU,QAAQ,GAAGX,KAAKW,QAAQ;IAClC;IAEA,OAAO1B,gBAAgBgB;AACzB"}
|
package/dist/ai/core/types.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export interface PayloadGenerationBaseArgs {
|
|
|
27
27
|
export interface PayloadGenerateObjectArgs extends PayloadGenerationBaseArgs {
|
|
28
28
|
images?: ImagePart[];
|
|
29
29
|
mode?: 'auto' | 'json' | 'tool';
|
|
30
|
+
onFinish?: (event: {
|
|
31
|
+
object?: any;
|
|
32
|
+
}) => Promise<void> | void;
|
|
30
33
|
schema?: Record<string, unknown> | z.ZodTypeAny;
|
|
31
34
|
}
|
|
32
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/core/types.ts"],"sourcesContent":["import type { ImagePart, JSONValue, ModelMessage } from 'ai'\nimport type { Payload } from 'payload'\nimport type { z } from 'zod'\n\n/**\n * Provider options compatible with AI SDK's SharedV2ProviderOptions\n * SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>\n */\nexport type ProviderOptions = Record<string, Record<string, JSONValue>>\n\n/**\n * Base arguments for all generation methods\n */\nexport interface PayloadGenerationBaseArgs {\n extractAttachments?: boolean\n maxTokens?: number\n messages?: ModelMessage[]\n model?: string\n payload: Payload\n prompt: string\n provider?: string\n providerOptions?: ProviderOptions\n system?: string\n temperature?: number\n}\n\n/**\n * Arguments for generateObject - structured output generation\n */\nexport interface PayloadGenerateObjectArgs extends PayloadGenerationBaseArgs {\n images?: ImagePart[]\n mode?: 'auto' | 'json' | 'tool'\n schema?: Record<string, unknown> | z.ZodTypeAny\n}\n\n/**\n * Arguments for generateText - simple text generation\n */\nexport interface PayloadGenerateTextArgs extends PayloadGenerationBaseArgs {\n // No additional fields needed for basic text generation\n}\n\n/**\n * Arguments for generateMedia - image/video generation\n */\nexport interface PayloadGenerateMediaArgs {\n aspectRatio?: string\n audioFormat?: string\n callbackUrl?: string\n duration?: number\n fps?: number\n images?: ImagePart[]\n instructionId?: number | string\n mode?: 'i2v' | 't2v'\n model?: string\n n?: number\n payload: Payload\n prompt: string\n provider?: string\n providerOptions?: ProviderOptions\n seed?: number\n size?: { height: number; width: number }\n speed?: number\n voice?: string\n}\n\n/**\n * Result from generateMedia - can be immediate file or async job\n */\nexport interface MediaResult {\n // Immediate result (image generation)\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n }\n \n // Async job result (video generation)\n jobId?: string\n progress?: number\n status?: 'completed' | 'failed' | 'queued' | 'running'\n taskId?: string\n}\n\n/**\n * Internal type for multimodal image files\n */\nexport interface MultimodalImageFile {\n base64Data?: string\n mediaType?: string\n uint8Array?: Uint8Array\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/core/types.ts"],"sourcesContent":["import type { ImagePart, JSONValue, ModelMessage } from 'ai'\nimport type { Payload } from 'payload'\nimport type { z } from 'zod'\n\n/**\n * Provider options compatible with AI SDK's SharedV2ProviderOptions\n * SharedV2ProviderOptions = Record<string, Record<string, JSONValue>>\n */\nexport type ProviderOptions = Record<string, Record<string, JSONValue>>\n\n/**\n * Base arguments for all generation methods\n */\nexport interface PayloadGenerationBaseArgs {\n extractAttachments?: boolean\n maxTokens?: number\n messages?: ModelMessage[]\n model?: string\n payload: Payload\n prompt: string\n provider?: string\n providerOptions?: ProviderOptions\n system?: string\n temperature?: number\n}\n\n/**\n * Arguments for generateObject - structured output generation\n */\nexport interface PayloadGenerateObjectArgs extends PayloadGenerationBaseArgs {\n images?: ImagePart[]\n mode?: 'auto' | 'json' | 'tool'\n onFinish?: (event: { object?: any }) => Promise<void> | void\n schema?: Record<string, unknown> | z.ZodTypeAny\n}\n\n/**\n * Arguments for generateText - simple text generation\n */\nexport interface PayloadGenerateTextArgs extends PayloadGenerationBaseArgs {\n // No additional fields needed for basic text generation\n}\n\n/**\n * Arguments for generateMedia - image/video generation\n */\nexport interface PayloadGenerateMediaArgs {\n aspectRatio?: string\n audioFormat?: string\n callbackUrl?: string\n duration?: number\n fps?: number\n images?: ImagePart[]\n instructionId?: number | string\n mode?: 'i2v' | 't2v'\n model?: string\n n?: number\n payload: Payload\n prompt: string\n provider?: string\n providerOptions?: ProviderOptions\n seed?: number\n size?: { height: number; width: number }\n speed?: number\n voice?: string\n}\n\n/**\n * Result from generateMedia - can be immediate file or async job\n */\nexport interface MediaResult {\n // Immediate result (image generation)\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n }\n \n // Async job result (video generation)\n jobId?: string\n progress?: number\n status?: 'completed' | 'failed' | 'queued' | 'running'\n taskId?: string\n}\n\n/**\n * Internal type for multimodal image files\n */\nexport interface MultimodalImageFile {\n base64Data?: string\n mediaType?: string\n uint8Array?: Uint8Array\n}\n"],"names":[],"mappings":"AAsFA;;CAEC,GACD,WAIC"}
|
package/dist/ai/prompts.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ActionPrompt
|
|
1
|
+
import type { ActionPrompt } from '../types.js';
|
|
2
2
|
export declare const defaultSystemPrompt = "IMPORTANT INSTRUCTION:\nProduce only the requested output text.\nDo not add any explanations, comments, or engagement.\nDo not use quotation marks in the response.\nBEGIN OUTPUT:";
|
|
3
3
|
export declare const defaultPrompts: ActionPrompt[];
|
|
4
|
-
export declare const defaultSeedPrompts: SeedPromptFunction;
|
package/dist/ai/prompts.js
CHANGED
|
@@ -100,115 +100,5 @@ INSTRUCTIONS:
|
|
|
100
100
|
-------------`
|
|
101
101
|
}
|
|
102
102
|
];
|
|
103
|
-
export const defaultSeedPrompts = ({ fieldLabel, fieldSchemaPaths, fieldType, path })=>{
|
|
104
|
-
return {
|
|
105
|
-
prompt: `field-type: ${fieldType}
|
|
106
|
-
field-name: ${fieldLabel}
|
|
107
|
-
schema-path: ${path}
|
|
108
|
-
|
|
109
|
-
Give me a prompt that relate to the given field type and schema path.
|
|
110
|
-
|
|
111
|
-
Generated prompt:
|
|
112
|
-
`,
|
|
113
|
-
system: `# AI Assistant for CMS Prompt Generation
|
|
114
|
-
|
|
115
|
-
Your role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.
|
|
116
|
-
|
|
117
|
-
## Key Guidelines:
|
|
118
|
-
- Tailor prompts to specific field-type and purpose
|
|
119
|
-
- Use schema-path for context
|
|
120
|
-
- Include " {{ title }} " in every prompt
|
|
121
|
-
- Be clear, concise, and instructive
|
|
122
|
-
- Focus on content generation, not user perspective
|
|
123
|
-
- For Image, Voice, or Banner fields, use provided example prompts verbatim
|
|
124
|
-
- Image, Banner prompt MUST NOT CONTAIN ANY TYPOGRAPHY/TEXT DETAILS
|
|
125
|
-
|
|
126
|
-
## Field Types and Prompts:
|
|
127
|
-
|
|
128
|
-
1. richText:
|
|
129
|
-
- Craft detailed, structured content
|
|
130
|
-
- Include intro, sections, body, formatting, and conclusion
|
|
131
|
-
- Aim for engaging, informative, and valuable content
|
|
132
|
-
|
|
133
|
-
2. text:
|
|
134
|
-
- For titles: Generate concise, engaging titles
|
|
135
|
-
- For keywords: List relevant SEO terms
|
|
136
|
-
|
|
137
|
-
3. textarea:
|
|
138
|
-
- Provide comprehensive details (e.g., event information)
|
|
139
|
-
|
|
140
|
-
4. upload:
|
|
141
|
-
- Describe high-quality images or media
|
|
142
|
-
|
|
143
|
-
## Schema-path Examples:
|
|
144
|
-
- posts.title: Blog/article title
|
|
145
|
-
- products.name: Product name
|
|
146
|
-
|
|
147
|
-
## Must Follow:
|
|
148
|
-
- Adapt prompts to schema-path context
|
|
149
|
-
- Generate content directly, avoid personal pronouns
|
|
150
|
-
- Use provided examples as guidelines
|
|
151
|
-
|
|
152
|
-
### Examples for each field type along with generated prompt:
|
|
153
|
-
|
|
154
|
-
For richText:
|
|
155
|
-
field-type: richText
|
|
156
|
-
field-name: Content
|
|
157
|
-
schema-path: posts.content
|
|
158
|
-
Generated prompt: Craft compelling content for a blog post with the title " {{ title }} ". Develop a well-structured narrative that captivates readers from start to finish. Incorporate the following elements to create a polished and engaging piece:
|
|
159
|
-
|
|
160
|
-
- Engaging introduction that hooks the reader
|
|
161
|
-
- Clearly defined sections with relevant subheadings
|
|
162
|
-
- Well-researched and informative body paragraphs
|
|
163
|
-
- Creative use of formatting to enhance readability (e.g., bullet points, blockquotes, italics, headings, bolds, other text formats)
|
|
164
|
-
- Compelling conclusion that reinforces the main theme
|
|
165
|
-
- Make the format easily digestible and clear for enhanced readability and improved CTR.
|
|
166
|
-
- The user should be engaged, consistently interested, and feel that they’ve gained the knowledge they were seeking.
|
|
167
|
-
|
|
168
|
-
Infuse the content with your expertise and a touch of personality to make it both informative and enjoyable to read. Aim to provide value to your target audience while maintaining a professional tone that aligns with the blog's overall style.
|
|
169
|
-
Feel free to incorporate relevant anecdotes, statistics, or examples to support your points and add depth to the post. Remember, the goal is to create content that not only informs but also inspires and entertains your readers.
|
|
170
|
-
|
|
171
|
-
For text:
|
|
172
|
-
field-type: text
|
|
173
|
-
field-name: title
|
|
174
|
-
schema-path: posts.title
|
|
175
|
-
Generated prompt: Generate a captivating title for the blog post based on " {{ title }} " that effectively encapsulates the main theme and draws in readers. The title should be concise, engaging, and relevant to the content being presented. If no input is provided then generate creative title.
|
|
176
|
-
|
|
177
|
-
For text:
|
|
178
|
-
field-type: text
|
|
179
|
-
field-name: keywords
|
|
180
|
-
schema-path: posts.keywords
|
|
181
|
-
Generated prompt: Identify and list relevant keywords for the blog post titled " {{ title }} ". Focus on terms that enhance search engine optimization and accurately reflect the main themes and topics of the content.
|
|
182
|
-
keywords will with comma separated.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
For textarea:
|
|
186
|
-
field-type: textarea:
|
|
187
|
-
field-name: details
|
|
188
|
-
schema-path: posts.details
|
|
189
|
-
Generated prompt: Provide comprehensive details for the event " {{ title }} ". Include essential information such as date, time, location, and any specific instructions or requirements.
|
|
190
|
-
|
|
191
|
-
For upload:
|
|
192
|
-
field-type: upload
|
|
193
|
-
field-name: Featured Image
|
|
194
|
-
schema-path: posts.image
|
|
195
|
-
Generated prompt: Imagine {{ title }}
|
|
196
|
-
|
|
197
|
-
For upload:
|
|
198
|
-
field-type: upload
|
|
199
|
-
field-name: Voice
|
|
200
|
-
schema-path: posts.upload
|
|
201
|
-
Generated prompt: {{ title }} {{ toHTML [provide schema-path here...] }}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
Remember to adapt the prompts based on the specific schema-path provided, considering the context and purpose of the field within the CMS structure. The prompts should directly instruct the AI model on what content to generate or describe, without assuming a user perspective.
|
|
205
|
-
|
|
206
|
-
Schema Map Context:
|
|
207
|
-
${JSON.stringify(fieldSchemaPaths)}
|
|
208
|
-
|
|
209
|
-
${defaultSystemPrompt}
|
|
210
|
-
`
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
103
|
|
|
214
104
|
//# sourceMappingURL=prompts.js.map
|
package/dist/ai/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionPrompt, SeedPromptFunction } from '../types.js'\n\n//TODO: This is a temporary solution make use of structured output\nexport const defaultSystemPrompt = `IMPORTANT INSTRUCTION:\nProduce only the requested output text.\nDo not add any explanations, comments, or engagement.\nDo not use quotation marks in the response.\nBEGIN OUTPUT:`\n\nexport const defaultPrompts: ActionPrompt[] = [\n {\n name: 'Rephrase',\n system: ({\n prompt = '',\n systemPrompt = '',\n }) => `You are a skilled language expert. Rephrase the given text while maintaining its original meaning, tone, and emotional content. Use different words and sentence structures where possible, but preserve the overall style and sentiment of the original.\n \n -------------\n INSTRUCTIONS:\n - Rephrase the text according to the guidelines of the ORIGINAL SYSTEM PROMPT, if provided.\n - Retain the original meaning, tone, and emotional content.\n - Use different vocabulary and sentence structures where appropriate.\n - Ensure the rephrased text conveys the same message and feeling as the original.\n ${prompt ? '\\n\\nPrevious prompt:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n {\n name: 'Expand',\n system:\n () => `You are a creative writer and subject matter expert. Expand the given text by adding depth, detail, and relevant information while maintaining the original tone and style.\n \n -------------\n INSTRUCTIONS:\n - Understand the main ideas and tone of the text.\n - Add more details, examples, explanations, or context.\n - Maintain the original tone, style, and intent.\n - Ensure the expanded version flows naturally and coherently.\n - Do not contradict or alter the original meaning.\n -------------`,\n },\n {\n name: 'Proofread',\n system:\n () => `You are an English language expert. Proofread the given text, focusing on correcting grammar and spelling mistakes without altering the content, style, or tone.\n \n -------------\n INSTRUCTIONS:\n - Correct grammar and spelling errors.\n - Do not change the content, meaning, tone, or style.\n - Return the full text, whether corrections were made or not.\n - Do not provide additional comments or analysis.\n -------------`,\n },\n {\n name: 'Simplify',\n system: ({\n prompt = '',\n }) => `You are a skilled communicator specializing in clear and concise writing. Simplify the given text to make it easier to understand while retaining its core message.\n \n -------------\n INSTRUCTIONS:\n - Simplify the language, using more common words and shorter sentences.\n - Remove unnecessary details or jargon while keeping essential information.\n - Maintain the original meaning and key points.\n - Aim for clarity and readability for a general audience.\n - The simplified text should be more concise than the original.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n -------------`,\n },\n {\n name: 'Summarize',\n layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\n `,\n system: () =>\n `You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.\n\nINSTRUCTIONS:\n1. Carefully read and analyze the provided text.\n2. Identify and extract the main ideas and crucial supporting details.\n3. Condense the information into a clear and coherent summary that maintains the core message.\n4. Preserve the original tone and intent of the text.\n5. Ensure your summary is approximately 25-30% of the original text length.\n6. Use clear and precise language, avoiding unnecessary jargon or complexity.\n`,\n },\n {\n name: 'Tone',\n system: () =>\n `You are a tone adjustment specialist. Modify the tone of the given text as specified while keeping the original message and content intact.\n \n -------------\n INSTRUCTIONS:\n - Adjust the tone to match the specified style (e.g., formal, informal, professional, friendly).\n - Maintain the original content and meaning.\n - Ensure the adjusted text flows naturally with the new tone.\n -------------`,\n },\n {\n name: 'Translate',\n system: ({ locale, prompt = '', systemPrompt = '' }) =>\n `You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.\n \n -------------\n INSTRUCTIONS:\n - Accurately translate the text into ${locale}.\n - Preserve the original meaning, tone, and context.\n - Ensure the translation is culturally appropriate and natural in the target language.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n]\n\nexport const defaultSeedPrompts: SeedPromptFunction = ({\n fieldLabel,\n fieldSchemaPaths,\n fieldType,\n path,\n}: {\n fieldLabel: string\n fieldSchemaPaths: any\n fieldType: string\n path: string\n}) => {\n return {\n prompt: `field-type: ${fieldType}\nfield-name: ${fieldLabel}\nschema-path: ${path}\n\nGive me a prompt that relate to the given field type and schema path.\n\nGenerated prompt:\n`,\n system: `# AI Assistant for CMS Prompt Generation\n\nYour role: Generate prompts for Content Management System (CMS) fields based on field-type and schema-path.\n\n## Key Guidelines:\n- Tailor prompts to specific field-type and purpose\n- Use schema-path for context\n- Include \" {{ title }} \" in every prompt\n- Be clear, concise, and instructive\n- Focus on content generation, not user perspective\n- For Image, Voice, or Banner fields, use provided example prompts verbatim\n- Image, Banner prompt MUST NOT CONTAIN ANY TYPOGRAPHY/TEXT DETAILS\n\n## Field Types and Prompts:\n\n1. richText:\n - Craft detailed, structured content\n - Include intro, sections, body, formatting, and conclusion\n - Aim for engaging, informative, and valuable content\n\n2. text:\n - For titles: Generate concise, engaging titles\n - For keywords: List relevant SEO terms\n\n3. textarea:\n - Provide comprehensive details (e.g., event information)\n\n4. upload:\n - Describe high-quality images or media\n\n## Schema-path Examples:\n- posts.title: Blog/article title\n- products.name: Product name\n\n## Must Follow:\n- Adapt prompts to schema-path context\n- Generate content directly, avoid personal pronouns\n- Use provided examples as guidelines\n\n### Examples for each field type along with generated prompt:\n\nFor richText:\n field-type: richText\n field-name: Content\n schema-path: posts.content\n Generated prompt: Craft compelling content for a blog post with the title \" {{ title }} \". Develop a well-structured narrative that captivates readers from start to finish. Incorporate the following elements to create a polished and engaging piece:\n\n- Engaging introduction that hooks the reader\n- Clearly defined sections with relevant subheadings\n- Well-researched and informative body paragraphs\n- Creative use of formatting to enhance readability (e.g., bullet points, blockquotes, italics, headings, bolds, other text formats)\n- Compelling conclusion that reinforces the main theme\n- Make the format easily digestible and clear for enhanced readability and improved CTR. \n- The user should be engaged, consistently interested, and feel that they’ve gained the knowledge they were seeking. \n\nInfuse the content with your expertise and a touch of personality to make it both informative and enjoyable to read. Aim to provide value to your target audience while maintaining a professional tone that aligns with the blog's overall style.\nFeel free to incorporate relevant anecdotes, statistics, or examples to support your points and add depth to the post. Remember, the goal is to create content that not only informs but also inspires and entertains your readers.\n\nFor text:\n field-type: text\n field-name: title\n schema-path: posts.title\n Generated prompt: Generate a captivating title for the blog post based on \" {{ title }} \" that effectively encapsulates the main theme and draws in readers. The title should be concise, engaging, and relevant to the content being presented. If no input is provided then generate creative title.\n\nFor text:\n field-type: text\n field-name: keywords\n schema-path: posts.keywords\n Generated prompt: Identify and list relevant keywords for the blog post titled \" {{ title }} \". Focus on terms that enhance search engine optimization and accurately reflect the main themes and topics of the content.\nkeywords will with comma separated.\n\n\nFor textarea:\n field-type: textarea:\n field-name: details\n schema-path: posts.details\n Generated prompt: Provide comprehensive details for the event \" {{ title }} \". Include essential information such as date, time, location, and any specific instructions or requirements.\n\nFor upload:\n field-type: upload\n field-name: Featured Image\n schema-path: posts.image\n Generated prompt: Imagine {{ title }}\n\nFor upload:\n field-type: upload\n field-name: Voice\n schema-path: posts.upload\n Generated prompt: {{ title }} {{ toHTML [provide schema-path here...] }}\n\n\nRemember to adapt the prompts based on the specific schema-path provided, considering the context and purpose of the field within the CMS structure. The prompts should directly instruct the AI model on what content to generate or describe, without assuming a user perspective.\n\nSchema Map Context:\n${JSON.stringify(fieldSchemaPaths)}\n\n${defaultSystemPrompt}\n`,\n }\n}\n"],"names":["defaultSystemPrompt","defaultPrompts","name","system","prompt","systemPrompt","layout","locale","defaultSeedPrompts","fieldLabel","fieldSchemaPaths","fieldType","path","JSON","stringify"],"mappings":"AAEA,kEAAkE;AAClE,OAAO,MAAMA,sBAAsB,CAAC;;;;aAIvB,CAAC,CAAA;AAEd,OAAO,MAAMC,iBAAiC;IAC5C;QACEC,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACXC,eAAe,EAAE,EAClB,GAAK,CAAC;;;;;;;;MAQL,EAAED,SAAS,2BAA2BA,SAAS,GAAG;MAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;mBACxD,CAAC;IAClB;IACA;QACEH,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;;mBASM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;mBAQM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACZ,GAAK,CAAC;;;;;;;;;MASL,EAAEA,SAAS,2BAA2BA,SAAS,GAAG;mBACrC,CAAC;IAClB;IACA;QACEF,MAAM;QACNI,QAAQ,IAAM,CAAC;;;IAGf,CAAC;QACDH,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;IACC;IACA;QACED,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEI,MAAM,EAAEH,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAE,GACjD,CAAC,gEAAgE,EAAEE,OAAO;;;;yCAIvC,EAAEA,OAAO;;;IAG9C,EAAEH,SAAS,2BAA2BA,SAAS,GAAG;IAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;iBACxD,CAAC;IAChB;CACD,CAAA;AAED,OAAO,MAAMG,qBAAyC,CAAC,EACrDC,UAAU,EACVC,gBAAgB,EAChBC,SAAS,EACTC,IAAI,EAML;IACC,OAAO;QACLR,QAAQ,CAAC,YAAY,EAAEO,UAAU;YACzB,EAAEF,WAAW;aACZ,EAAEG,KAAK;;;;;AAKpB,CAAC;QACGT,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8Fb,EAAEU,KAAKC,SAAS,CAACJ,kBAAkB;;AAEnC,EAAEV,oBAAoB;AACtB,CAAC;IACC;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/ai/prompts.ts"],"sourcesContent":["import type { ActionPrompt } from '../types.js'\n\n//TODO: This is a temporary solution make use of structured output\nexport const defaultSystemPrompt = `IMPORTANT INSTRUCTION:\nProduce only the requested output text.\nDo not add any explanations, comments, or engagement.\nDo not use quotation marks in the response.\nBEGIN OUTPUT:`\n\nexport const defaultPrompts: ActionPrompt[] = [\n {\n name: 'Rephrase',\n system: ({\n prompt = '',\n systemPrompt = '',\n }) => `You are a skilled language expert. Rephrase the given text while maintaining its original meaning, tone, and emotional content. Use different words and sentence structures where possible, but preserve the overall style and sentiment of the original.\n \n -------------\n INSTRUCTIONS:\n - Rephrase the text according to the guidelines of the ORIGINAL SYSTEM PROMPT, if provided.\n - Retain the original meaning, tone, and emotional content.\n - Use different vocabulary and sentence structures where appropriate.\n - Ensure the rephrased text conveys the same message and feeling as the original.\n ${prompt ? '\\n\\nPrevious prompt:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n {\n name: 'Expand',\n system:\n () => `You are a creative writer and subject matter expert. Expand the given text by adding depth, detail, and relevant information while maintaining the original tone and style.\n \n -------------\n INSTRUCTIONS:\n - Understand the main ideas and tone of the text.\n - Add more details, examples, explanations, or context.\n - Maintain the original tone, style, and intent.\n - Ensure the expanded version flows naturally and coherently.\n - Do not contradict or alter the original meaning.\n -------------`,\n },\n {\n name: 'Proofread',\n system:\n () => `You are an English language expert. Proofread the given text, focusing on correcting grammar and spelling mistakes without altering the content, style, or tone.\n \n -------------\n INSTRUCTIONS:\n - Correct grammar and spelling errors.\n - Do not change the content, meaning, tone, or style.\n - Return the full text, whether corrections were made or not.\n - Do not provide additional comments or analysis.\n -------------`,\n },\n {\n name: 'Simplify',\n system: ({\n prompt = '',\n }) => `You are a skilled communicator specializing in clear and concise writing. Simplify the given text to make it easier to understand while retaining its core message.\n \n -------------\n INSTRUCTIONS:\n - Simplify the language, using more common words and shorter sentences.\n - Remove unnecessary details or jargon while keeping essential information.\n - Maintain the original meaning and key points.\n - Aim for clarity and readability for a general audience.\n - The simplified text should be more concise than the original.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n -------------`,\n },\n {\n name: 'Summarize',\n layout: () => `\n[heading] - Summary\n[paragraph] - Your summary goes here...\n `,\n system: () =>\n `You are an expert at summarizing information. Your task is to create a concise summary of the given text that captures its key points and essential details while preserving the original meaning.\n\nINSTRUCTIONS:\n1. Carefully read and analyze the provided text.\n2. Identify and extract the main ideas and crucial supporting details.\n3. Condense the information into a clear and coherent summary that maintains the core message.\n4. Preserve the original tone and intent of the text.\n5. Ensure your summary is approximately 25-30% of the original text length.\n6. Use clear and precise language, avoiding unnecessary jargon or complexity.\n`,\n },\n {\n name: 'Tone',\n system: () =>\n `You are a tone adjustment specialist. Modify the tone of the given text as specified while keeping the original message and content intact.\n \n -------------\n INSTRUCTIONS:\n - Adjust the tone to match the specified style (e.g., formal, informal, professional, friendly).\n - Maintain the original content and meaning.\n - Ensure the adjusted text flows naturally with the new tone.\n -------------`,\n },\n {\n name: 'Translate',\n system: ({ locale, prompt = '', systemPrompt = '' }) =>\n `You are a skilled translator. Translate the following text into ${locale}, ensuring the original meaning, tone, and context are preserved.\n \n -------------\n INSTRUCTIONS:\n - Accurately translate the text into ${locale}.\n - Preserve the original meaning, tone, and context.\n - Ensure the translation is culturally appropriate and natural in the target language.\n ${prompt ? '\\n\\nPREVIOUS PROMPT:\\n' + prompt : ''}\n ${systemPrompt ? '\\n\\nORIGINAL SYSTEM PROMPT:\\n' + systemPrompt : ''}\n -------------`,\n },\n]\n"],"names":["defaultSystemPrompt","defaultPrompts","name","system","prompt","systemPrompt","layout","locale"],"mappings":"AAEA,kEAAkE;AAClE,OAAO,MAAMA,sBAAsB,CAAC;;;;aAIvB,CAAC,CAAA;AAEd,OAAO,MAAMC,iBAAiC;IAC5C;QACEC,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACXC,eAAe,EAAE,EAClB,GAAK,CAAC;;;;;;;;MAQL,EAAED,SAAS,2BAA2BA,SAAS,GAAG;MAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;mBACxD,CAAC;IAClB;IACA;QACEH,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;;mBASM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QACE,IAAM,CAAC;;;;;;;;mBAQM,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EACPC,SAAS,EAAE,EACZ,GAAK,CAAC;;;;;;;;;MASL,EAAEA,SAAS,2BAA2BA,SAAS,GAAG;mBACrC,CAAC;IAClB;IACA;QACEF,MAAM;QACNI,QAAQ,IAAM,CAAC;;;IAGf,CAAC;QACDH,QAAQ,IACN,CAAC;;;;;;;;;AASP,CAAC;IACC;IACA;QACED,MAAM;QACNC,QAAQ,IACN,CAAC;;;;;;;mBAOY,CAAC;IAClB;IACA;QACED,MAAM;QACNC,QAAQ,CAAC,EAAEI,MAAM,EAAEH,SAAS,EAAE,EAAEC,eAAe,EAAE,EAAE,GACjD,CAAC,gEAAgE,EAAEE,OAAO;;;;yCAIvC,EAAEA,OAAO;;;IAG9C,EAAEH,SAAS,2BAA2BA,SAAS,GAAG;IAClD,EAAEC,eAAe,kCAAkCA,eAAe,GAAG;iBACxD,CAAC;IAChB;CACD,CAAA"}
|
|
@@ -207,7 +207,6 @@ export async function getImageModel(payload, providerId, modelId, options, isMul
|
|
|
207
207
|
return provider.instance;
|
|
208
208
|
}
|
|
209
209
|
if (provider.factory) {
|
|
210
|
-
console.log('modelId: ', modelId);
|
|
211
210
|
const instance = await provider.factory();
|
|
212
211
|
// Type-safe check for image support
|
|
213
212
|
if (!isMultimodalText && typeof instance === 'function' && 'image' in instance && typeof instance.image === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/providers/registry.ts"],"sourcesContent":["import type { LanguageModel } from 'ai'\nimport type { Payload } from 'payload'\n\nexport type { ProviderId } from './types.js'\n\nimport * as process from 'node:process'\n\nimport type {\n AIProvider,\n AISettingsData,\n AnthropicBlockData,\n ElevenLabsBlockData,\n FalBlockData,\n GoogleBlockData,\n OpenAIBlockData,\n OpenAICompatibleBlockData,\n ProviderBlockData,\n ProviderRegistry,\n XAIBlockData,\n} from './types.js'\n\n// Type-safe provider factory functions\nconst providerFactories = {\n anthropic: async (block: AnthropicBlockData) => {\n const { createAnthropic } = await import('@ai-sdk/anthropic')\n return createAnthropic({\n apiKey: block.apiKey,\n })\n },\n\n elevenlabs: async (block: ElevenLabsBlockData) => {\n const { createElevenLabs } = await import('@ai-sdk/elevenlabs')\n return createElevenLabs({\n apiKey: block.apiKey,\n })\n },\n\n fal: async (block: FalBlockData) => {\n const { fal } = await import('@ai-sdk/fal')\n // Fal uses global instance, configure with apiKey\n process.env.FAL_KEY = block.apiKey\n if (block.webhookSecret) {\n process.env.FAL_WEBHOOK_SECRET = block.webhookSecret\n }\n return fal\n },\n\n google: async (block: GoogleBlockData) => {\n const { createGoogleGenerativeAI } = await import('@ai-sdk/google')\n return createGoogleGenerativeAI({\n apiKey: block.apiKey,\n })\n },\n\n openai: async (block: OpenAIBlockData) => {\n const { createOpenAI } = await import('@ai-sdk/openai')\n return createOpenAI({\n apiKey: block.apiKey,\n baseURL: block.baseURL || 'https://api.openai.com/v1',\n organization: block.organization,\n })\n },\n\n 'openai-compatible': async (block: OpenAICompatibleBlockData) => {\n console.log('OpenAI compatible, ', block)\n const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible')\n return createOpenAICompatible({\n name: block.providerName,\n apiKey: block.apiKey || '',\n baseURL: block.baseURL,\n })\n },\n\n xai: async (block: XAIBlockData) => {\n const { createXai } = await import('@ai-sdk/xai')\n return createXai({\n apiKey: block.apiKey,\n })\n },\n}\n\n/**\n * Type guard to check provider block type\n */\nfunction isProviderBlock<T extends ProviderBlockData>(\n block: ProviderBlockData,\n blockType: T['blockType'],\n): block is T {\n return block.blockType === blockType\n}\n\n/**\n * Load provider registry from AI Settings (type-safe)\n */\nexport async function getProviderRegistry(payload: Payload): Promise<ProviderRegistry> {\n const settings = (await payload.findGlobal({\n slug: 'ai-settings',\n context: { unsafe: true },\n })) as unknown as AISettingsData\n\n const registry: ProviderRegistry = {}\n // console.log('settings - >', JSON.stringify(settings, null, 2))\n for (const providerBlock of settings.providers || []) {\n if (!providerBlock.enabled) {\n continue\n }\n\n const { blockType } = providerBlock\n\n // Type-safe factory lookup and invocation\n let factory: (() => Promise<any>) | undefined\n\n if (isProviderBlock<OpenAIBlockData>(providerBlock, 'openai')) {\n factory = () => providerFactories.openai(providerBlock)\n } else if (isProviderBlock<AnthropicBlockData>(providerBlock, 'anthropic')) {\n factory = () => providerFactories.anthropic(providerBlock)\n } else if (isProviderBlock<GoogleBlockData>(providerBlock, 'google')) {\n factory = () => providerFactories.google(providerBlock)\n } else if (isProviderBlock<XAIBlockData>(providerBlock, 'xai')) {\n factory = () => providerFactories.xai(providerBlock)\n } else if (isProviderBlock<FalBlockData>(providerBlock, 'fal')) {\n factory = () => providerFactories.fal(providerBlock)\n } else if (isProviderBlock<ElevenLabsBlockData>(providerBlock, 'elevenlabs')) {\n factory = () => providerFactories.elevenlabs(providerBlock)\n } else if (isProviderBlock<OpenAICompatibleBlockData>(providerBlock, 'openai-compatible')) {\n factory = () => providerFactories['openai-compatible'](providerBlock)\n }\n\n if (!factory) {\n console.warn(`No factory for provider: ${blockType}`)\n continue\n }\n\n // Filter enabled models only\n const enabledModels = providerBlock.models.filter((m) => m.enabled)\n\n // Extract provider options\n const options = {\n image:\n 'imageProviderOptions' in providerBlock ? providerBlock.imageProviderOptions : undefined,\n text: 'textProviderOptions' in providerBlock ? providerBlock.textProviderOptions : undefined,\n tts: 'ttsProviderOptions' in providerBlock ? providerBlock.ttsProviderOptions : undefined,\n }\n\n registry[blockType] = {\n id: blockType,\n name: 'providerName' in providerBlock ? providerBlock.providerName : blockType,\n apiKey: 'apiKey' in providerBlock ? providerBlock.apiKey : undefined,\n enabled: true,\n factory,\n instance: undefined, // Fal is now loaded dynamically via factory\n models: enabledModels,\n options,\n }\n }\n\n return registry\n}\n\n/**\n * Get global defaults from AI Settings\n */\nexport async function getGlobalDefaults(payload: Payload) {\n const settings = (await payload.findGlobal({\n slug: 'ai-settings',\n })) as unknown as AISettingsData\n return settings.defaults\n}\n\n/**\n * Get language model (type-safe, async)\n */\nexport async function getLanguageModel(\n payload: Payload,\n providerId?: string,\n modelId?: string,\n options?: Record<string, any>,\n): Promise<LanguageModel> {\n if (!providerId || !modelId) {\n const defaults = await getGlobalDefaults(payload)\n if (!providerId) {\n providerId = defaults?.text?.provider\n }\n if (!modelId) {\n modelId = defaults?.text?.model\n }\n }\n\n // Extract global default options if we are using the default provider\n let globalDefaultOptions = {}\n if (providerId) {\n const defaults = await getGlobalDefaults(payload)\n if (defaults?.text?.provider === providerId) {\n globalDefaultOptions = defaults?.text?.options || {}\n }\n }\n\n if (!providerId || !modelId) {\n throw new Error('Provider and model must be specified or configured in defaults')\n }\n\n const registry = await getProviderRegistry(payload)\n const provider = registry[providerId]\n\n if (!provider) {\n throw new Error(`Provider ${providerId} not found in registry`)\n }\n\n if (!provider.enabled) {\n throw new Error(`Provider ${providerId} is not enabled`)\n }\n\n // We only support factory now for dynamic loading, instance is legacy/cache\n let providerInstance: any\n if (provider.instance) {\n providerInstance = provider.instance\n } else if (provider.factory) {\n providerInstance = await provider.factory()\n } else {\n throw new Error(`Provider ${providerId} has no factory or instance`)\n }\n\n // Merge default settings with override options\n const finalOptions = {\n ...(provider.options?.text || {}),\n ...globalDefaultOptions,\n ...(options || {}),\n }\n\n return providerInstance(modelId, finalOptions)\n}\n\nexport async function getImageModel(\n payload: Payload,\n providerId?: string,\n modelId?: string,\n options?: Record<string, any>,\n isMultimodalText?: boolean,\n) {\n if (!providerId || !modelId) {\n const defaults = await getGlobalDefaults(payload)\n if (!providerId) {\n providerId = defaults?.image?.provider\n }\n if (!modelId) {\n modelId = defaults?.image?.model\n }\n }\n\n // Extract global default options if we are using the default provider\n let globalDefaultOptions = {}\n if (providerId) {\n const defaults = await getGlobalDefaults(payload)\n if (defaults?.image?.provider === providerId) {\n globalDefaultOptions = defaults?.image?.options || {}\n }\n }\n\n if (!providerId || !modelId) {\n throw new Error('Provider and model must be specified or configured in defaults')\n }\n\n const registry = await getProviderRegistry(payload)\n const provider = registry[providerId]\n\n if (!provider) {\n throw new Error(`Provider ${providerId} not found`)\n }\n\n // Merge default settings with override options\n const finalOptions = {\n ...(provider.options?.image || {}),\n ...globalDefaultOptions,\n ...(options || {}),\n }\n\n if (provider.instance) {\n return provider.instance\n }\n\n if (provider.factory) {\n console.log('modelId: ', modelId)\n const instance = await provider.factory()\n\n // Type-safe check for image support\n if (\n !isMultimodalText &&\n typeof instance === 'function' &&\n 'image' in instance &&\n typeof instance.image === 'function'\n ) {\n return instance.image(modelId, finalOptions)\n }\n\n // Also check if instance is an object with image method\n if (\n typeof instance === 'object' &&\n instance !== null &&\n 'image' in instance &&\n !isMultimodalText\n ) {\n return (instance as AIProvider).image?.(modelId, finalOptions)\n }\n\n // Fallback for providers that might return the model directly or use the default factory\n return typeof instance === 'function' ? instance(modelId, finalOptions) : instance\n }\n\n throw new Error(`Invalid provider configuration for ${providerId}`)\n}\n\nexport async function getTTSModel(\n payload: Payload,\n providerId?: string,\n modelId?: string,\n options?: Record<string, any>,\n) {\n if (!providerId || !modelId) {\n const defaults = await getGlobalDefaults(payload)\n if (!providerId) {\n providerId = defaults?.tts?.provider\n }\n if (!modelId) {\n modelId = defaults?.tts?.model\n }\n }\n\n // Extract global default options if we are using the default provider\n let globalDefaultOptions = {}\n if (providerId) {\n const defaults = await getGlobalDefaults(payload)\n if (defaults?.tts?.provider === providerId) {\n globalDefaultOptions = defaults?.tts?.options || {}\n }\n }\n\n if (!providerId || !modelId) {\n throw new Error('Provider and model must be specified or configured in defaults')\n }\n\n const registry = await getProviderRegistry(payload)\n const provider = registry[providerId]\n\n if (!provider) {\n throw new Error(`Provider ${providerId} not found`)\n }\n\n // Merge default settings with override options\n const finalOptions = {\n ...(provider.options?.tts || {}),\n ...globalDefaultOptions,\n ...(options || {}),\n }\n\n if (provider.factory) {\n const instance = await provider.factory()\n if (instance?.speech) {\n return instance.speech(modelId, finalOptions)\n }\n return typeof instance === 'function' ? instance(modelId, finalOptions) : instance\n }\n\n throw new Error(`Invalid provider configuration for ${providerId}`)\n}\n"],"names":["process","providerFactories","anthropic","block","createAnthropic","apiKey","elevenlabs","createElevenLabs","fal","env","FAL_KEY","webhookSecret","FAL_WEBHOOK_SECRET","google","createGoogleGenerativeAI","openai","createOpenAI","baseURL","organization","console","log","createOpenAICompatible","name","providerName","xai","createXai","isProviderBlock","blockType","getProviderRegistry","payload","settings","findGlobal","slug","context","unsafe","registry","providerBlock","providers","enabled","factory","warn","enabledModels","models","filter","m","options","image","imageProviderOptions","undefined","text","textProviderOptions","tts","ttsProviderOptions","id","instance","getGlobalDefaults","defaults","getLanguageModel","providerId","modelId","provider","model","globalDefaultOptions","Error","providerInstance","finalOptions","getImageModel","isMultimodalText","getTTSModel","speech"],"mappings":"AAKA,YAAYA,aAAa,eAAc;AAgBvC,uCAAuC;AACvC,MAAMC,oBAAoB;IACxBC,WAAW,OAAOC;QAChB,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,OAAOA,gBAAgB;YACrBC,QAAQF,MAAME,MAAM;QACtB;IACF;IAEAC,YAAY,OAAOH;QACjB,MAAM,EAAEI,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC;QAC1C,OAAOA,iBAAiB;YACtBF,QAAQF,MAAME,MAAM;QACtB;IACF;IAEAG,KAAK,OAAOL;QACV,MAAM,EAAEK,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC;QAC7B,kDAAkD;QAClDR,QAAQS,GAAG,CAACC,OAAO,GAAGP,MAAME,MAAM;QAClC,IAAIF,MAAMQ,aAAa,EAAE;YACvBX,QAAQS,GAAG,CAACG,kBAAkB,GAAGT,MAAMQ,aAAa;QACtD;QACA,OAAOH;IACT;IAEAK,QAAQ,OAAOV;QACb,MAAM,EAAEW,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC;QAClD,OAAOA,yBAAyB;YAC9BT,QAAQF,MAAME,MAAM;QACtB;IACF;IAEAU,QAAQ,OAAOZ;QACb,MAAM,EAAEa,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC;QACtC,OAAOA,aAAa;YAClBX,QAAQF,MAAME,MAAM;YACpBY,SAASd,MAAMc,OAAO,IAAI;YAC1BC,cAAcf,MAAMe,YAAY;Q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
|
1
|
+
{"version":3,"sources":["../../../src/ai/providers/registry.ts"],"sourcesContent":["import type { LanguageModel } from 'ai'\nimport type { Payload } from 'payload'\n\nexport type { ProviderId } from './types.js'\n\nimport * as process from 'node:process'\n\nimport type {\n AIProvider,\n AISettingsData,\n AnthropicBlockData,\n ElevenLabsBlockData,\n FalBlockData,\n GoogleBlockData,\n OpenAIBlockData,\n OpenAICompatibleBlockData,\n ProviderBlockData,\n ProviderRegistry,\n XAIBlockData,\n} from './types.js'\n\n// Type-safe provider factory functions\nconst providerFactories = {\n anthropic: async (block: AnthropicBlockData) => {\n const { createAnthropic } = await import('@ai-sdk/anthropic')\n return createAnthropic({\n apiKey: block.apiKey,\n })\n },\n\n elevenlabs: async (block: ElevenLabsBlockData) => {\n const { createElevenLabs } = await import('@ai-sdk/elevenlabs')\n return createElevenLabs({\n apiKey: block.apiKey,\n })\n },\n\n fal: async (block: FalBlockData) => {\n const { fal } = await import('@ai-sdk/fal')\n // Fal uses global instance, configure with apiKey\n process.env.FAL_KEY = block.apiKey\n if (block.webhookSecret) {\n process.env.FAL_WEBHOOK_SECRET = block.webhookSecret\n }\n return fal\n },\n\n google: async (block: GoogleBlockData) => {\n const { createGoogleGenerativeAI } = await import('@ai-sdk/google')\n return createGoogleGenerativeAI({\n apiKey: block.apiKey,\n })\n },\n\n openai: async (block: OpenAIBlockData) => {\n const { createOpenAI } = await import('@ai-sdk/openai')\n return createOpenAI({\n apiKey: block.apiKey,\n baseURL: block.baseURL || 'https://api.openai.com/v1',\n organization: block.organization,\n })\n },\n\n 'openai-compatible': async (block: OpenAICompatibleBlockData) => {\n console.log('OpenAI compatible, ', block)\n const { createOpenAICompatible } = await import('@ai-sdk/openai-compatible')\n return createOpenAICompatible({\n name: block.providerName,\n apiKey: block.apiKey || '',\n baseURL: block.baseURL,\n })\n },\n\n xai: async (block: XAIBlockData) => {\n const { createXai } = await import('@ai-sdk/xai')\n return createXai({\n apiKey: block.apiKey,\n })\n },\n}\n\n/**\n * Type guard to check provider block type\n */\nfunction isProviderBlock<T extends ProviderBlockData>(\n block: ProviderBlockData,\n blockType: T['blockType'],\n): block is T {\n return block.blockType === blockType\n}\n\n/**\n * Load provider registry from AI Settings (type-safe)\n */\nexport async function getProviderRegistry(payload: Payload): Promise<ProviderRegistry> {\n const settings = (await payload.findGlobal({\n slug: 'ai-settings',\n context: { unsafe: true },\n })) as unknown as AISettingsData\n\n const registry: ProviderRegistry = {}\n // console.log('settings - >', JSON.stringify(settings, null, 2))\n for (const providerBlock of settings.providers || []) {\n if (!providerBlock.enabled) {\n continue\n }\n\n const { blockType } = providerBlock\n\n // Type-safe factory lookup and invocation\n let factory: (() => Promise<any>) | undefined\n\n if (isProviderBlock<OpenAIBlockData>(providerBlock, 'openai')) {\n factory = () => providerFactories.openai(providerBlock)\n } else if (isProviderBlock<AnthropicBlockData>(providerBlock, 'anthropic')) {\n factory = () => providerFactories.anthropic(providerBlock)\n } else if (isProviderBlock<GoogleBlockData>(providerBlock, 'google')) {\n factory = () => providerFactories.google(providerBlock)\n } else if (isProviderBlock<XAIBlockData>(providerBlock, 'xai')) {\n factory = () => providerFactories.xai(providerBlock)\n } else if (isProviderBlock<FalBlockData>(providerBlock, 'fal')) {\n factory = () => providerFactories.fal(providerBlock)\n } else if (isProviderBlock<ElevenLabsBlockData>(providerBlock, 'elevenlabs')) {\n factory = () => providerFactories.elevenlabs(providerBlock)\n } else if (isProviderBlock<OpenAICompatibleBlockData>(providerBlock, 'openai-compatible')) {\n factory = () => providerFactories['openai-compatible'](providerBlock)\n }\n\n if (!factory) {\n console.warn(`No factory for provider: ${blockType}`)\n continue\n }\n\n // Filter enabled models only\n const enabledModels = providerBlock.models.filter((m) => m.enabled)\n\n // Extract provider options\n const options = {\n image:\n 'imageProviderOptions' in providerBlock ? providerBlock.imageProviderOptions : undefined,\n text: 'textProviderOptions' in providerBlock ? providerBlock.textProviderOptions : undefined,\n tts: 'ttsProviderOptions' in providerBlock ? providerBlock.ttsProviderOptions : undefined,\n }\n\n registry[blockType] = {\n id: blockType,\n name: 'providerName' in providerBlock ? providerBlock.providerName : blockType,\n apiKey: 'apiKey' in providerBlock ? providerBlock.apiKey : undefined,\n enabled: true,\n factory,\n instance: undefined, // Fal is now loaded dynamically via factory\n models: enabledModels,\n options,\n }\n }\n\n return registry\n}\n\n/**\n * Get global defaults from AI Settings\n */\nexport async function getGlobalDefaults(payload: Payload) {\n const settings = (await payload.findGlobal({\n slug: 'ai-settings',\n })) as unknown as AISettingsData\n return settings.defaults\n}\n\n/**\n * Get language model (type-safe, async)\n */\nexport async function getLanguageModel(\n payload: Payload,\n providerId?: string,\n modelId?: string,\n options?: Record<string, any>,\n): Promise<LanguageModel> {\n if (!providerId || !modelId) {\n const defaults = await getGlobalDefaults(payload)\n if (!providerId) {\n providerId = defaults?.text?.provider\n }\n if (!modelId) {\n modelId = defaults?.text?.model\n }\n }\n\n // Extract global default options if we are using the default provider\n let globalDefaultOptions = {}\n if (providerId) {\n const defaults = await getGlobalDefaults(payload)\n if (defaults?.text?.provider === providerId) {\n globalDefaultOptions = defaults?.text?.options || {}\n }\n }\n\n if (!providerId || !modelId) {\n throw new Error('Provider and model must be specified or configured in defaults')\n }\n\n const registry = await getProviderRegistry(payload)\n const provider = registry[providerId]\n\n if (!provider) {\n throw new Error(`Provider ${providerId} not found in registry`)\n }\n\n if (!provider.enabled) {\n throw new Error(`Provider ${providerId} is not enabled`)\n }\n\n // We only support factory now for dynamic loading, instance is legacy/cache\n let providerInstance: any\n if (provider.instance) {\n providerInstance = provider.instance\n } else if (provider.factory) {\n providerInstance = await provider.factory()\n } else {\n throw new Error(`Provider ${providerId} has no factory or instance`)\n }\n\n // Merge default settings with override options\n const finalOptions = {\n ...(provider.options?.text || {}),\n ...globalDefaultOptions,\n ...(options || {}),\n }\n\n return providerInstance(modelId, finalOptions)\n}\n\nexport async function getImageModel(\n payload: Payload,\n providerId?: string,\n modelId?: string,\n options?: Record<string, any>,\n isMultimodalText?: boolean,\n) {\n if (!providerId || !modelId) {\n const defaults = await getGlobalDefaults(payload)\n if (!providerId) {\n providerId = defaults?.image?.provider\n }\n if (!modelId) {\n modelId = defaults?.image?.model\n }\n }\n\n // Extract global default options if we are using the default provider\n let globalDefaultOptions = {}\n if (providerId) {\n const defaults = await getGlobalDefaults(payload)\n if (defaults?.image?.provider === providerId) {\n globalDefaultOptions = defaults?.image?.options || {}\n }\n }\n\n if (!providerId || !modelId) {\n throw new Error('Provider and model must be specified or configured in defaults')\n }\n\n const registry = await getProviderRegistry(payload)\n const provider = registry[providerId]\n\n if (!provider) {\n throw new Error(`Provider ${providerId} not found`)\n }\n\n // Merge default settings with override options\n const finalOptions = {\n ...(provider.options?.image || {}),\n ...globalDefaultOptions,\n ...(options || {}),\n }\n\n if (provider.instance) {\n return provider.instance\n }\n\n if (provider.factory) {\n const instance = await provider.factory()\n\n // Type-safe check for image support\n if (\n !isMultimodalText &&\n typeof instance === 'function' &&\n 'image' in instance &&\n typeof instance.image === 'function'\n ) {\n return instance.image(modelId, finalOptions)\n }\n\n // Also check if instance is an object with image method\n if (\n typeof instance === 'object' &&\n instance !== null &&\n 'image' in instance &&\n !isMultimodalText\n ) {\n return (instance as AIProvider).image?.(modelId, finalOptions)\n }\n\n // Fallback for providers that might return the model directly or use the default factory\n return typeof instance === 'function' ? instance(modelId, finalOptions) : instance\n }\n\n throw new Error(`Invalid provider configuration for ${providerId}`)\n}\n\nexport async function getTTSModel(\n payload: Payload,\n providerId?: string,\n modelId?: string,\n options?: Record<string, any>,\n) {\n if (!providerId || !modelId) {\n const defaults = await getGlobalDefaults(payload)\n if (!providerId) {\n providerId = defaults?.tts?.provider\n }\n if (!modelId) {\n modelId = defaults?.tts?.model\n }\n }\n\n // Extract global default options if we are using the default provider\n let globalDefaultOptions = {}\n if (providerId) {\n const defaults = await getGlobalDefaults(payload)\n if (defaults?.tts?.provider === providerId) {\n globalDefaultOptions = defaults?.tts?.options || {}\n }\n }\n\n if (!providerId || !modelId) {\n throw new Error('Provider and model must be specified or configured in defaults')\n }\n\n const registry = await getProviderRegistry(payload)\n const provider = registry[providerId]\n\n if (!provider) {\n throw new Error(`Provider ${providerId} not found`)\n }\n\n // Merge default settings with override options\n const finalOptions = {\n ...(provider.options?.tts || {}),\n ...globalDefaultOptions,\n ...(options || {}),\n }\n\n if (provider.factory) {\n const instance = await provider.factory()\n if (instance?.speech) {\n return instance.speech(modelId, finalOptions)\n }\n return typeof instance === 'function' ? instance(modelId, finalOptions) : instance\n }\n\n throw new Error(`Invalid provider configuration for ${providerId}`)\n}\n"],"names":["process","providerFactories","anthropic","block","createAnthropic","apiKey","elevenlabs","createElevenLabs","fal","env","FAL_KEY","webhookSecret","FAL_WEBHOOK_SECRET","google","createGoogleGenerativeAI","openai","createOpenAI","baseURL","organization","console","log","createOpenAICompatible","name","providerName","xai","createXai","isProviderBlock","blockType","getProviderRegistry","payload","settings","findGlobal","slug","context","unsafe","registry","providerBlock","providers","enabled","factory","warn","enabledModels","models","filter","m","options","image","imageProviderOptions","undefined","text","textProviderOptions","tts","ttsProviderOptions","id","instance","getGlobalDefaults","defaults","getLanguageModel","providerId","modelId","provider","model","globalDefaultOptions","Error","providerInstance","finalOptions","getImageModel","isMultimodalText","getTTSModel","speech"],"mappings":"AAKA,YAAYA,aAAa,eAAc;AAgBvC,uCAAuC;AACvC,MAAMC,oBAAoB;IACxBC,WAAW,OAAOC;QAChB,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,OAAOA,gBAAgB;YACrBC,QAAQF,MAAME,MAAM;QACtB;IACF;IAEAC,YAAY,OAAOH;QACjB,MAAM,EAAEI,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC;QAC1C,OAAOA,iBAAiB;YACtBF,QAAQF,MAAME,MAAM;QACtB;IACF;IAEAG,KAAK,OAAOL;QACV,MAAM,EAAEK,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC;QAC7B,kDAAkD;QAClDR,QAAQS,GAAG,CAACC,OAAO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D;IAEA,+CAA+C;IAC/C,MAAMO,eAAe;QACnB,GAAIL,SAASf,OAAO,EAAEM,OAAO,CAAC,CAAC;QAC/B,GAAGW,oBAAoB;QACvB,GAAIjB,WAAW,CAAC,CAAC;IACnB;IAEA,IAAIe,SAASrB,OAAO,EAAE;QACpB,MAAMe,WAAW,MAAMM,SAASrB,OAAO;QACvC,IAAIe,UAAUe,QAAQ;YACpB,OAAOf,SAASe,MAAM,CAACV,SAASM;QAClC;QACA,OAAO,OAAOX,aAAa,aAAaA,SAASK,SAASM,gBAAgBX;IAC5E;IAEA,MAAM,IAAIS,MAAM,CAAC,mCAAmC,EAAEL,WAAW,CAAC;AACpE"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { LexicalNodeSchema } from '../schemas/lexicalJsonSchema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Filters the Lexical JSON schema to only include definitions for allowed nodes.
|
|
4
|
+
*
|
|
5
|
+
* @param schema - The full Lexical JSON schema
|
|
6
|
+
* @param allowedNodes - Array of allowed node types. Can be either:
|
|
7
|
+
* - Node class names (e.g., 'HeadingNode', 'ParagraphNode')
|
|
8
|
+
* - Type values (e.g., 'heading', 'paragraph')
|
|
9
|
+
* @returns A filtered schema containing only the allowed definitions
|
|
10
|
+
*/
|
|
2
11
|
export declare function filterEditorSchemaByNodes(schema: LexicalNodeSchema, allowedNodes: string[]): {
|
|
3
12
|
definitions: Record<string, any>;
|
|
4
13
|
$schema?: string;
|
|
@@ -1,17 +1,44 @@
|
|
|
1
1
|
import { isObjectSchema } from './isObjectSchema.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { coreNodeTypes, nodeClassToType, nodeTypeToSchemaMap } from './nodeToSchemaMap.js';
|
|
3
|
+
/**
|
|
4
|
+
* Filters the Lexical JSON schema to only include definitions for allowed nodes.
|
|
5
|
+
*
|
|
6
|
+
* @param schema - The full Lexical JSON schema
|
|
7
|
+
* @param allowedNodes - Array of allowed node types. Can be either:
|
|
8
|
+
* - Node class names (e.g., 'HeadingNode', 'ParagraphNode')
|
|
9
|
+
* - Type values (e.g., 'heading', 'paragraph')
|
|
10
|
+
* @returns A filtered schema containing only the allowed definitions
|
|
11
|
+
*/ export function filterEditorSchemaByNodes(schema, allowedNodes) {
|
|
12
|
+
// Normalize node names to lowercase type values
|
|
13
|
+
const normalizedTypes = new Set();
|
|
14
|
+
// Always include core nodes
|
|
15
|
+
for (const coreType of coreNodeTypes){
|
|
16
|
+
normalizedTypes.add(coreType);
|
|
17
|
+
}
|
|
18
|
+
// Add user-specified allowed nodes
|
|
19
|
+
for (const node of allowedNodes){
|
|
20
|
+
// Handle both formats: 'HeadingNode' and 'heading'
|
|
21
|
+
const normalized = node.includes('Node') ? nodeClassToType(node) : node.toLowerCase();
|
|
22
|
+
normalizedTypes.add(normalized);
|
|
23
|
+
}
|
|
4
24
|
const filteredDefinitions = {};
|
|
5
25
|
// First pass: collect definitions whose "type.enum" includes an allowed type
|
|
6
26
|
for (const [key, def] of Object.entries(schema.definitions ?? {})){
|
|
7
27
|
if (isObjectSchema(def)) {
|
|
8
28
|
const typeEnum = def.properties?.type?.enum;
|
|
9
|
-
if (typeEnum && typeEnum.some((t)=>
|
|
29
|
+
if (typeEnum && typeEnum.some((t)=>normalizedTypes.has(t))) {
|
|
10
30
|
filteredDefinitions[key] = JSON.parse(JSON.stringify(def)) // Deep copy to safely mutate
|
|
11
31
|
;
|
|
12
32
|
}
|
|
13
33
|
}
|
|
14
34
|
}
|
|
35
|
+
// Ensure core schema definitions are included by checking the map
|
|
36
|
+
for (const coreType of coreNodeTypes){
|
|
37
|
+
const defName = nodeTypeToSchemaMap[coreType];
|
|
38
|
+
if (defName && schema.definitions?.[defName] && !filteredDefinitions[defName]) {
|
|
39
|
+
filteredDefinitions[defName] = JSON.parse(JSON.stringify(schema.definitions[defName]));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
15
42
|
// Helper to check if a $ref points to an allowed definition
|
|
16
43
|
const isAllowedRef = (ref)=>{
|
|
17
44
|
if (typeof ref !== 'string') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ai/utils/filterEditorSchemaByNodes.ts"],"sourcesContent":["import type { LexicalNodeSchema } from '../schemas/lexicalJsonSchema.js'\n\nimport { isObjectSchema } from './isObjectSchema.js'\n\nexport function filterEditorSchemaByNodes(schema: LexicalNodeSchema, allowedNodes: string[]) {\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/ai/utils/filterEditorSchemaByNodes.ts"],"sourcesContent":["import type { LexicalNodeSchema } from '../schemas/lexicalJsonSchema.js'\n\nimport { isObjectSchema } from './isObjectSchema.js'\nimport { coreNodeTypes, nodeClassToType, nodeTypeToSchemaMap } from './nodeToSchemaMap.js'\n\n/**\n * Filters the Lexical JSON schema to only include definitions for allowed nodes.\n *\n * @param schema - The full Lexical JSON schema\n * @param allowedNodes - Array of allowed node types. Can be either:\n * - Node class names (e.g., 'HeadingNode', 'ParagraphNode')\n * - Type values (e.g., 'heading', 'paragraph')\n * @returns A filtered schema containing only the allowed definitions\n */\nexport function filterEditorSchemaByNodes(schema: LexicalNodeSchema, allowedNodes: string[]) {\n // Normalize node names to lowercase type values\n const normalizedTypes = new Set<string>()\n\n // Always include core nodes\n for (const coreType of coreNodeTypes) {\n normalizedTypes.add(coreType)\n }\n\n // Add user-specified allowed nodes\n for (const node of allowedNodes) {\n // Handle both formats: 'HeadingNode' and 'heading'\n const normalized = node.includes('Node') ? nodeClassToType(node) : node.toLowerCase()\n normalizedTypes.add(normalized)\n }\n\n const filteredDefinitions: Record<string, any> = {}\n\n // First pass: collect definitions whose \"type.enum\" includes an allowed type\n for (const [key, def] of Object.entries(schema.definitions ?? {})) {\n if (isObjectSchema(def)) {\n const typeEnum = def.properties?.type?.enum\n if (typeEnum && typeEnum.some((t) => normalizedTypes.has(t))) {\n filteredDefinitions[key] = JSON.parse(JSON.stringify(def)) // Deep copy to safely mutate\n }\n }\n }\n\n // Ensure core schema definitions are included by checking the map\n for (const coreType of coreNodeTypes) {\n const defName = nodeTypeToSchemaMap[coreType]\n if (defName && schema.definitions?.[defName] && !filteredDefinitions[defName]) {\n filteredDefinitions[defName] = JSON.parse(JSON.stringify(schema.definitions[defName]))\n }\n }\n\n // Helper to check if a $ref points to an allowed definition\n const isAllowedRef = (ref: string) => {\n if (typeof ref !== 'string') {\n return false\n }\n const defName = ref.replace('#/definitions/', '')\n return defName in filteredDefinitions\n }\n\n // Second pass: update \"children\" in each definition to only include allowed refs\n for (const def of Object.values(filteredDefinitions)) {\n if (isObjectSchema(def) && def.properties?.children?.items) {\n const items = def.properties.children.items\n\n if (Array.isArray(items.anyOf)) {\n // Filter anyOf to only allowed $refs\n items.anyOf = items.anyOf.filter((entry) => isAllowedRef(entry.$ref))\n if (items.anyOf.length === 0) {\n delete def.properties.children\n }\n } else if (items.$ref && !isAllowedRef(items.$ref)) {\n delete def.properties.children\n }\n }\n }\n\n // Return the new schema with pruned definitions\n return {\n ...schema,\n definitions: filteredDefinitions,\n }\n}\n"],"names":["isObjectSchema","coreNodeTypes","nodeClassToType","nodeTypeToSchemaMap","filterEditorSchemaByNodes","schema","allowedNodes","normalizedTypes","Set","coreType","add","node","normalized","includes","toLowerCase","filteredDefinitions","key","def","Object","entries","definitions","typeEnum","properties","type","enum","some","t","has","JSON","parse","stringify","defName","isAllowedRef","ref","replace","values","children","items","Array","isArray","anyOf","filter","entry","$ref","length"],"mappings":"AAEA,SAASA,cAAc,QAAQ,sBAAqB;AACpD,SAASC,aAAa,EAAEC,eAAe,EAAEC,mBAAmB,QAAQ,uBAAsB;AAE1F;;;;;;;;CAQC,GACD,OAAO,SAASC,0BAA0BC,MAAyB,EAAEC,YAAsB;IACzF,gDAAgD;IAChD,MAAMC,kBAAkB,IAAIC;IAE5B,4BAA4B;IAC5B,KAAK,MAAMC,YAAYR,cAAe;QACpCM,gBAAgBG,GAAG,CAACD;IACtB;IAEA,mCAAmC;IACnC,KAAK,MAAME,QAAQL,aAAc;Q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F,MAAMG,KAAK,GAAG;gBAC9B,qCAAqC;gBACrCH,MAAMG,KAAK,GAAGH,MAAMG,KAAK,CAACC,MAAM,CAAC,CAACC,QAAUV,aAAaU,MAAMC,IAAI;gBACnE,IAAIN,MAAMG,KAAK,CAACI,MAAM,KAAK,GAAG;oBAC5B,OAAO3B,IAAIK,UAAU,CAACc,QAAQ;gBAChC;YACF,OAAO,IAAIC,MAAMM,IAAI,IAAI,CAACX,aAAaK,MAAMM,IAAI,GAAG;gBAClD,OAAO1B,IAAIK,UAAU,CAACc,QAAQ;YAChC;QACF;IACF;IAEA,gDAAgD;IAChD,OAAO;QACL,GAAG/B,MAAM;QACTe,aAAaL;IACf;AACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
*/
|
|
8
|
+
export declare const nodeTypeToSchemaMap: Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Core nodes that should always be included in the filtered schema
|
|
11
|
+
*/
|
|
12
|
+
export declare const coreNodeTypes: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Converts a Lexical node class name (e.g., 'HeadingNode') to its type value (e.g., 'heading').
|
|
15
|
+
* This handles the common pattern where node classes are named with the pattern `{Type}Node`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function nodeClassToType(nodeClassName: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a set of Lexical node class names to their corresponding schema definition names.
|
|
20
|
+
* Includes core nodes automatically.
|
|
21
|
+
*/
|
|
22
|
+
export declare function nodeClassesToSchemaDefinitions(nodeClassNames: string[]): string[];
|
|
@@ -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"}
|
|
@@ -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:
|
|
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"}
|
|
@@ -5,9 +5,9 @@ export const aiSettingsGlobal = {
|
|
|
5
5
|
read: ({ req })=>!!req.user,
|
|
6
6
|
update: ({ req })=>!!req.user
|
|
7
7
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
admin: {
|
|
9
|
+
group: false
|
|
10
|
+
},
|
|
11
11
|
fields: [
|
|
12
12
|
{
|
|
13
13
|
name: 'providers',
|