@payloadcms/plugin-mcp 3.78.0-canary.0 → 3.78.0-canary.2
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/mcp/getMcpHandler.d.ts.map +1 -1
- package/dist/mcp/getMcpHandler.js +8 -2
- package/dist/mcp/getMcpHandler.js.map +1 -1
- package/dist/mcp/helpers/config.d.ts +1 -9
- package/dist/mcp/helpers/config.d.ts.map +1 -1
- package/dist/mcp/helpers/config.js +0 -62
- package/dist/mcp/helpers/config.js.map +1 -1
- package/dist/mcp/helpers/fields.d.ts +6 -25
- package/dist/mcp/helpers/fields.d.ts.map +1 -1
- package/dist/mcp/helpers/fields.js +35 -29
- package/dist/mcp/helpers/fields.js.map +1 -1
- package/dist/mcp/helpers/fileValidation.d.ts +0 -2
- package/dist/mcp/helpers/fileValidation.d.ts.map +1 -1
- package/dist/mcp/helpers/fileValidation.js +44 -82
- package/dist/mcp/helpers/fileValidation.js.map +1 -1
- package/dist/mcp/tools/collection/create.d.ts.map +1 -1
- package/dist/mcp/tools/collection/create.js +2 -25
- package/dist/mcp/tools/collection/create.js.map +1 -1
- package/dist/mcp/tools/collection/delete.d.ts.map +1 -1
- package/dist/mcp/tools/collection/delete.js +1 -12
- package/dist/mcp/tools/collection/delete.js.map +1 -1
- package/dist/mcp/tools/config/update.d.ts +1 -1
- package/dist/mcp/tools/config/update.d.ts.map +1 -1
- package/dist/mcp/tools/config/update.js +3 -3
- package/dist/mcp/tools/config/update.js.map +1 -1
- package/dist/mcp/tools/global/update.d.ts.map +1 -1
- package/dist/mcp/tools/global/update.js +3 -0
- package/dist/mcp/tools/global/update.js.map +1 -1
- package/dist/mcp/tools/job/create.d.ts.map +1 -1
- package/dist/mcp/tools/job/create.js +3 -6
- package/dist/mcp/tools/job/create.js.map +1 -1
- package/dist/mcp/tools/job/run.d.ts +1 -1
- package/dist/mcp/tools/job/run.d.ts.map +1 -1
- package/dist/mcp/tools/job/run.js +5 -26
- package/dist/mcp/tools/job/run.js.map +1 -1
- package/dist/mcp/tools/job/update.d.ts.map +1 -1
- package/dist/mcp/tools/job/update.js +10 -38
- package/dist/mcp/tools/job/update.js.map +1 -1
- package/dist/mcp/tools/resource/create.d.ts.map +1 -1
- package/dist/mcp/tools/resource/create.js +3 -0
- package/dist/mcp/tools/resource/create.js.map +1 -1
- package/dist/mcp/tools/resource/update.d.ts.map +1 -1
- package/dist/mcp/tools/resource/update.js +3 -0
- package/dist/mcp/tools/resource/update.js.map +1 -1
- package/dist/mcp/tools/schemas.d.ts +2 -5
- package/dist/mcp/tools/schemas.d.ts.map +1 -1
- package/dist/mcp/tools/schemas.js +0 -1
- package/dist/mcp/tools/schemas.js.map +1 -1
- package/dist/utils/getVirtualFieldNames.d.ts +14 -0
- package/dist/utils/getVirtualFieldNames.d.ts.map +1 -0
- package/dist/utils/getVirtualFieldNames.js +35 -0
- package/dist/utils/getVirtualFieldNames.js.map +1 -0
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +1 -1
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +1 -2
- package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +1 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +7 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +20 -0
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -0
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +5 -0
- package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +1 -1
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js +38 -0
- package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +1 -1
- package/package.json +3 -3
- package/src/mcp/getMcpHandler.ts +22 -2
- package/src/mcp/helpers/config.ts +1 -114
- package/src/mcp/helpers/fields.ts +46 -50
- package/src/mcp/helpers/fileValidation.ts +38 -93
- package/src/mcp/tools/collection/create.ts +2 -30
- package/src/mcp/tools/collection/delete.ts +1 -19
- package/src/mcp/tools/config/update.ts +0 -4
- package/src/mcp/tools/global/update.ts +8 -0
- package/src/mcp/tools/job/create.ts +5 -11
- package/src/mcp/tools/job/run.ts +14 -38
- package/src/mcp/tools/job/update.ts +29 -77
- package/src/mcp/tools/resource/create.ts +7 -0
- package/src/mcp/tools/resource/update.ts +7 -0
- package/src/mcp/tools/schemas.ts +0 -1
- package/src/utils/getVirtualFieldNames.ts +53 -0
- package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +1 -3
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +27 -0
- package/src/utils/schemaConversion/sanitizeJsonSchema.ts +41 -0
- package/dist/mcp/helpers/conversion.d.ts +0 -2
- package/dist/mcp/helpers/conversion.d.ts.map +0 -1
- package/dist/mcp/helpers/conversion.js +0 -5
- package/dist/mcp/helpers/conversion.js.map +0 -1
- package/dist/mcp/helpers/validation.d.ts +0 -9
- package/dist/mcp/helpers/validation.d.ts.map +0 -1
- package/dist/mcp/helpers/validation.js +0 -22
- package/dist/mcp/helpers/validation.js.map +0 -1
- package/src/mcp/helpers/conversion.ts +0 -3
- package/src/mcp/helpers/validation.ts +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMcpHandler.d.ts","sourceRoot":"","sources":["../../src/mcp/getMcpHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,KAAK,cAAc,EAAkB,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"getMcpHandler.d.ts","sourceRoot":"","sources":["../../src/mcp/getMcpHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgC,KAAK,cAAc,EAAkB,MAAM,SAAS,CAAA;AAE3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAuC3E,eAAO,MAAM,aAAa,kBACT,qBAAqB,qBACjB,iBAAiB,OAC/B,cAAc,4CA6epB,CAAA"}
|
|
@@ -3,6 +3,8 @@ import { join } from 'path';
|
|
|
3
3
|
import { APIError, configToJSONSchema } from 'payload';
|
|
4
4
|
import { toCamelCase } from '../utils/camelCase.js';
|
|
5
5
|
import { getEnabledSlugs } from '../utils/getEnabledSlugs.js';
|
|
6
|
+
import { getCollectionVirtualFieldNames, getGlobalVirtualFieldNames } from '../utils/getVirtualFieldNames.js';
|
|
7
|
+
import { removeVirtualFieldsFromSchema } from '../utils/schemaConversion/removeVirtualFieldsFromSchema.js';
|
|
6
8
|
import { registerTool } from './registerTool.js';
|
|
7
9
|
// Tools
|
|
8
10
|
import { findGlobalTool } from './tools/global/find.js';
|
|
@@ -68,7 +70,9 @@ export const getMCPHandler = (pluginOptions, mcpAccessSettings, req)=>{
|
|
|
68
70
|
// Collection Operation Tools
|
|
69
71
|
enabledCollectionSlugs.forEach((enabledCollectionSlug)=>{
|
|
70
72
|
try {
|
|
71
|
-
const
|
|
73
|
+
const rawSchema = configSchema.definitions?.[enabledCollectionSlug];
|
|
74
|
+
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, enabledCollectionSlug);
|
|
75
|
+
const schema = removeVirtualFieldsFromSchema(JSON.parse(JSON.stringify(rawSchema)), virtualFieldNames);
|
|
72
76
|
const toolCapabilities = mcpAccessSettings?.[`${toCamelCase(enabledCollectionSlug)}`];
|
|
73
77
|
const allowCreate = toolCapabilities?.create;
|
|
74
78
|
const allowUpdate = toolCapabilities?.update;
|
|
@@ -94,7 +98,9 @@ export const getMCPHandler = (pluginOptions, mcpAccessSettings, req)=>{
|
|
|
94
98
|
const enabledGlobalSlugs = getEnabledSlugs(globalsPluginConfig, 'global');
|
|
95
99
|
enabledGlobalSlugs.forEach((enabledGlobalSlug)=>{
|
|
96
100
|
try {
|
|
97
|
-
const
|
|
101
|
+
const rawSchema = configSchema.definitions?.[enabledGlobalSlug];
|
|
102
|
+
const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, enabledGlobalSlug);
|
|
103
|
+
const schema = removeVirtualFieldsFromSchema(JSON.parse(JSON.stringify(rawSchema)), virtualFieldNames);
|
|
98
104
|
const toolCapabilities = mcpAccessSettings?.[`${toCamelCase(enabledGlobalSlug)}`];
|
|
99
105
|
const allowFind = toolCapabilities?.['find'];
|
|
100
106
|
const allowUpdate = toolCapabilities?.['update'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/getMcpHandler.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createMcpHandler } from 'mcp-handler'\nimport { join } from 'path'\nimport { APIError, configToJSONSchema, type PayloadRequest, type TypedUser } from 'payload'\n\nimport type { MCPAccessSettings, PluginMCPServerConfig } from '../types.js'\n\nimport { toCamelCase } from '../utils/camelCase.js'\nimport { getEnabledSlugs } from '../utils/getEnabledSlugs.js'\nimport { registerTool } from './registerTool.js'\n\n// Tools\nimport { findGlobalTool } from './tools/global/find.js'\nimport { updateGlobalTool } from './tools/global/update.js'\nimport { createResourceTool } from './tools/resource/create.js'\nimport { deleteResourceTool } from './tools/resource/delete.js'\nimport { findResourceTool } from './tools/resource/find.js'\nimport { updateResourceTool } from './tools/resource/update.js'\n\n// Experimental Tools\n/**\n * @experimental This tools are experimental and may change or be removed in the future.\n */\nimport { authTool } from './tools/auth/auth.js'\nimport { forgotPasswordTool } from './tools/auth/forgotPassword.js'\nimport { loginTool } from './tools/auth/login.js'\nimport { resetPasswordTool } from './tools/auth/resetPassword.js'\nimport { unlockTool } from './tools/auth/unlock.js'\nimport { verifyTool } from './tools/auth/verify.js'\nimport { createCollectionTool } from './tools/collection/create.js'\nimport { deleteCollectionTool } from './tools/collection/delete.js'\nimport { findCollectionTool } from './tools/collection/find.js'\nimport { updateCollectionTool } from './tools/collection/update.js'\nimport { findConfigTool } from './tools/config/find.js'\nimport { updateConfigTool } from './tools/config/update.js'\nimport { createJobTool } from './tools/job/create.js'\nimport { runJobTool } from './tools/job/run.js'\nimport { updateJobTool } from './tools/job/update.js'\n\nexport const getMCPHandler = (\n pluginOptions: PluginMCPServerConfig,\n mcpAccessSettings: MCPAccessSettings,\n req: PayloadRequest,\n) => {\n const { payload } = req\n const configSchema = configToJSONSchema(payload.config, payload.db.defaultIDType, req.i18n)\n\n // Handler wrapper that injects req before the _extra argument\n const wrapHandler = (handler: (...args: any[]) => any) => {\n return async (...args: any[]) => {\n const _extra = args[args.length - 1]\n const handlerArgs = args.slice(0, -1)\n return await handler(...handlerArgs, req, _extra)\n }\n }\n\n const payloadToolHandler = (\n handler: NonNullable<NonNullable<PluginMCPServerConfig['mcp']>['tools']>[number]['handler'],\n ) => wrapHandler(handler)\n\n const payloadPromptHandler = (\n handler: NonNullable<NonNullable<PluginMCPServerConfig['mcp']>['prompts']>[number]['handler'],\n ) => wrapHandler(handler)\n\n const payloadResourceHandler = (\n handler: NonNullable<NonNullable<PluginMCPServerConfig['mcp']>['resources']>[number]['handler'],\n ) => wrapHandler(handler)\n\n // User\n const user = mcpAccessSettings.user\n\n // MCP Server and Handler Options\n const MCPOptions = pluginOptions.mcp || {}\n const customMCPTools = MCPOptions.tools || []\n const customMCPPrompts = MCPOptions.prompts || []\n const customMCPResources = MCPOptions.resources || []\n const MCPHandlerOptions = MCPOptions.handlerOptions || {}\n const serverOptions = MCPOptions.serverOptions || {}\n const useVerboseLogs = MCPHandlerOptions.verboseLogs ?? false\n\n // Experimental MCP Tool Requirements\n const isDevelopment = process.env.NODE_ENV === 'development'\n const experimentalTools: NonNullable<PluginMCPServerConfig['experimental']>['tools'] =\n pluginOptions?.experimental?.tools || {}\n const collectionsPluginConfig = pluginOptions.collections || {}\n const globalsPluginConfig = pluginOptions.globals || {}\n const collectionsDirPath =\n experimentalTools && experimentalTools.collections?.collectionsDirPath\n ? experimentalTools.collections.collectionsDirPath\n : join(process.cwd(), 'src/collections')\n const configFilePath =\n experimentalTools && experimentalTools.config?.configFilePath\n ? experimentalTools.config.configFilePath\n : join(process.cwd(), 'src/payload.config.ts')\n const jobsDirPath =\n experimentalTools && experimentalTools.jobs?.jobsDirPath\n ? experimentalTools.jobs.jobsDirPath\n : join(process.cwd(), 'src/jobs')\n\n try {\n return createMcpHandler(\n (server) => {\n // Get enabled collections\n const enabledCollectionSlugs = getEnabledSlugs(collectionsPluginConfig, 'collection')\n\n // Collection Operation Tools\n enabledCollectionSlugs.forEach((enabledCollectionSlug) => {\n try {\n const schema = configSchema.definitions?.[enabledCollectionSlug] as JSONSchema4\n\n const toolCapabilities = mcpAccessSettings?.[\n `${toCamelCase(enabledCollectionSlug)}`\n ] as Record<string, unknown>\n const allowCreate: boolean | undefined = toolCapabilities?.create as boolean\n const allowUpdate: boolean | undefined = toolCapabilities?.update as boolean\n const allowFind: boolean | undefined = toolCapabilities?.find as boolean\n const allowDelete: boolean | undefined = toolCapabilities?.delete as boolean\n\n if (allowCreate) {\n registerTool(\n allowCreate,\n `Create ${enabledCollectionSlug}`,\n () =>\n createResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n schema,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowUpdate) {\n registerTool(\n allowUpdate,\n `Update ${enabledCollectionSlug}`,\n () =>\n updateResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n schema,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowFind) {\n registerTool(\n allowFind,\n `Find ${enabledCollectionSlug}`,\n () =>\n findResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowDelete) {\n registerTool(\n allowDelete,\n `Delete ${enabledCollectionSlug}`,\n () =>\n deleteResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n ),\n payload,\n useVerboseLogs,\n )\n }\n } catch (error) {\n throw new APIError(\n `Error registering tools for collection ${enabledCollectionSlug}: ${String(error)}`,\n 500,\n )\n }\n })\n\n // Global Operation Tools\n const enabledGlobalSlugs = getEnabledSlugs(globalsPluginConfig, 'global')\n\n enabledGlobalSlugs.forEach((enabledGlobalSlug) => {\n try {\n const schema = configSchema.definitions?.[enabledGlobalSlug] as JSONSchema4\n\n const toolCapabilities = mcpAccessSettings?.[\n `${toCamelCase(enabledGlobalSlug)}`\n ] as Record<string, unknown>\n const allowFind: boolean | undefined = toolCapabilities?.['find'] as boolean\n const allowUpdate: boolean | undefined = toolCapabilities?.['update'] as boolean\n\n if (allowFind) {\n registerTool(\n allowFind,\n `Find ${enabledGlobalSlug}`,\n () =>\n findGlobalTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledGlobalSlug,\n globalsPluginConfig,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowUpdate) {\n registerTool(\n allowUpdate,\n `Update ${enabledGlobalSlug}`,\n () =>\n updateGlobalTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledGlobalSlug,\n globalsPluginConfig,\n schema,\n ),\n payload,\n useVerboseLogs,\n )\n }\n } catch (error) {\n throw new APIError(\n `Error registering tools for global ${enabledGlobalSlug}: ${String(error)}`,\n 500,\n )\n }\n })\n\n // Custom tools\n customMCPTools.forEach((tool) => {\n const camelCasedToolName = toCamelCase(tool.name)\n const isToolEnabled = mcpAccessSettings['payload-mcp-tool']?.[camelCasedToolName] ?? false\n\n registerTool(\n isToolEnabled,\n tool.name,\n () =>\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n inputSchema: tool.parameters,\n },\n payloadToolHandler(tool.handler),\n ),\n payload,\n useVerboseLogs,\n )\n })\n\n // Custom prompts\n customMCPPrompts.forEach((prompt) => {\n const camelCasedPromptName = toCamelCase(prompt.name)\n const isPromptEnabled =\n mcpAccessSettings['payload-mcp-prompt']?.[camelCasedPromptName] ?? false\n\n if (isPromptEnabled) {\n server.registerPrompt(\n prompt.name,\n {\n argsSchema: prompt.argsSchema,\n description: prompt.description,\n title: prompt.title,\n },\n payloadPromptHandler(prompt.handler),\n )\n if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ✅ Prompt: ${prompt.title} Registered.`)\n }\n } else if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ⏭️ Prompt: ${prompt.title} Skipped.`)\n }\n })\n\n // Custom resources\n customMCPResources.forEach((resource) => {\n const camelCasedResourceName = toCamelCase(resource.name)\n const isResourceEnabled =\n mcpAccessSettings['payload-mcp-resource']?.[camelCasedResourceName] ?? false\n\n if (isResourceEnabled) {\n server.registerResource(\n resource.name,\n // @ts-expect-error - Overload type is not working however -- ResourceTemplate OR String is a valid type\n resource.uri,\n {\n description: resource.description,\n mimeType: resource.mimeType,\n title: resource.title,\n },\n payloadResourceHandler(resource.handler),\n )\n\n if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ✅ Resource: ${resource.title} Registered.`)\n }\n } else if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ⏭️ Resource: ${resource.title} Skipped.`)\n }\n })\n\n // Experimental - Collection Schema Modfication Tools\n if (\n mcpAccessSettings.collections?.create &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.create,\n 'Create Collection',\n () =>\n createCollectionTool(server, req, useVerboseLogs, collectionsDirPath, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n if (\n mcpAccessSettings.collections?.delete &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.delete,\n 'Delete Collection',\n () =>\n deleteCollectionTool(server, req, useVerboseLogs, collectionsDirPath, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (\n mcpAccessSettings.collections?.find &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.find,\n 'Find Collection',\n () => findCollectionTool(server, req, useVerboseLogs, collectionsDirPath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (\n mcpAccessSettings.collections?.update &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.update,\n 'Update Collection',\n () =>\n updateCollectionTool(server, req, useVerboseLogs, collectionsDirPath, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n // Experimental - Payload Config Modification Tools\n if (mcpAccessSettings.config?.find && experimentalTools.config?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.config.find,\n 'Find Config',\n () => findConfigTool(server, req, useVerboseLogs, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (\n mcpAccessSettings.config?.update &&\n experimentalTools.config?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.config.update,\n 'Update Config',\n () => updateConfigTool(server, req, useVerboseLogs, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n // Experimental - Job Modification Tools\n if (mcpAccessSettings.jobs?.create && experimentalTools.jobs?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.jobs.create,\n 'Create Job',\n () => createJobTool(server, req, useVerboseLogs, jobsDirPath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.jobs?.update && experimentalTools.jobs?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.jobs.update,\n 'Update Job',\n () => updateJobTool(server, req, useVerboseLogs, jobsDirPath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.jobs?.run && experimentalTools.jobs?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.jobs.run,\n 'Run Job',\n () => runJobTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n // Experimental - Auth Modification Tools\n if (mcpAccessSettings.auth?.auth && experimentalTools.auth?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.auth.auth,\n 'Auth',\n () => authTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.login && experimentalTools.auth?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.auth.login,\n 'Login',\n () => loginTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.verify && experimentalTools.auth?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.auth.verify,\n 'Verify',\n () => verifyTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.resetPassword && experimentalTools.auth?.enabled) {\n registerTool(\n mcpAccessSettings.auth.resetPassword,\n 'Reset Password',\n () => resetPasswordTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.forgotPassword && experimentalTools.auth?.enabled) {\n registerTool(\n mcpAccessSettings.auth.forgotPassword,\n 'Forgot Password',\n () => forgotPasswordTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.unlock && experimentalTools.auth?.enabled) {\n registerTool(\n mcpAccessSettings.auth.unlock,\n 'Unlock',\n () => unlockTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (useVerboseLogs) {\n payload.logger.info('[payload-mcp] 🚀 MCP Server Ready.')\n }\n },\n {\n serverInfo: serverOptions.serverInfo,\n },\n {\n basePath: MCPHandlerOptions.basePath || payload.config.routes?.api || '/api',\n disableSse: MCPHandlerOptions.disableSse ?? true,\n maxDuration: MCPHandlerOptions.maxDuration || 60,\n onEvent: MCPHandlerOptions.onEvent,\n redisUrl: MCPHandlerOptions.redisUrl,\n verboseLogs: useVerboseLogs,\n },\n )\n } catch (error) {\n throw new APIError(`Error initializing MCP handler: ${String(error)}`, 500)\n }\n}\n"],"names":["createMcpHandler","join","APIError","configToJSONSchema","toCamelCase","getEnabledSlugs","registerTool","findGlobalTool","updateGlobalTool","createResourceTool","deleteResourceTool","findResourceTool","updateResourceTool","authTool","forgotPasswordTool","loginTool","resetPasswordTool","unlockTool","verifyTool","createCollectionTool","deleteCollectionTool","findCollectionTool","updateCollectionTool","findConfigTool","updateConfigTool","createJobTool","runJobTool","updateJobTool","getMCPHandler","pluginOptions","mcpAccessSettings","req","payload","configSchema","config","db","defaultIDType","i18n","wrapHandler","handler","args","_extra","length","handlerArgs","slice","payloadToolHandler","payloadPromptHandler","payloadResourceHandler","user","MCPOptions","mcp","customMCPTools","tools","customMCPPrompts","prompts","customMCPResources","resources","MCPHandlerOptions","handlerOptions","serverOptions","useVerboseLogs","verboseLogs","isDevelopment","process","env","NODE_ENV","experimentalTools","experimental","collectionsPluginConfig","collections","globalsPluginConfig","globals","collectionsDirPath","cwd","configFilePath","jobsDirPath","jobs","server","enabledCollectionSlugs","forEach","enabledCollectionSlug","schema","definitions","toolCapabilities","allowCreate","create","allowUpdate","update","allowFind","find","allowDelete","delete","error","String","enabledGlobalSlugs","enabledGlobalSlug","tool","camelCasedToolName","name","isToolEnabled","description","inputSchema","parameters","prompt","camelCasedPromptName","isPromptEnabled","registerPrompt","argsSchema","title","logger","info","resource","camelCasedResourceName","isResourceEnabled","registerResource","uri","mimeType","enabled","run","auth","login","verify","resetPassword","forgotPassword","unlock","serverInfo","basePath","routes","api","disableSse","maxDuration","onEvent","redisUrl"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,cAAa;AAC9C,SAASC,IAAI,QAAQ,OAAM;AAC3B,SAASC,QAAQ,EAAEC,kBAAkB,QAA6C,UAAS;AAI3F,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,QAAQ;AACR,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,S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AAI,EAAEI,kBAAkBzD,kBAAkBqD,IAAI,EAAEF,SAAS;gBAC7E/G,aACEwB,kBAAkByF,IAAI,CAACI,cAAc,EACrC,mBACA,IAAM7G,mBAAmB+D,QAAQ9C,KAAK6B,iBACtC5B,SACA4B;YAEJ;YAEA,IAAI9B,kBAAkByF,IAAI,EAAEK,UAAU1D,kBAAkBqD,IAAI,EAAEF,SAAS;gBACrE/G,aACEwB,kBAAkByF,IAAI,CAACK,MAAM,EAC7B,UACA,IAAM3G,WAAW4D,QAAQ9C,KAAK6B,iBAC9B5B,SACA4B;YAEJ;YAEA,IAAIA,gBAAgB;gBAClB5B,QAAQ6E,MAAM,CAACC,IAAI,CAAC;YACtB;QACF,GACA;YACEe,YAAYlE,cAAckE,UAAU;QACtC,GACA;YACEC,UAAUrE,kBAAkBqE,QAAQ,IAAI9F,QAAQE,MAAM,CAAC6F,MAAM,EAAEC,OAAO;YACtEC,YAAYxE,kBAAkBwE,UAAU,IAAI;YAC5CC,aAAazE,kBAAkByE,WAAW,IAAI;YAC9CC,SAAS1E,kBAAkB0E,OAAO;YAClCC,UAAU3E,kBAAkB2E,QAAQ;YACpCvE,aAAaD;QACf;IAEJ,EAAE,OAAOgC,OAAO;QACd,MAAM,IAAI1F,SAAS,CAAC,gCAAgC,EAAE2F,OAAOD,QAAQ,EAAE;IACzE;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/getMcpHandler.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createMcpHandler } from 'mcp-handler'\nimport { join } from 'path'\nimport { APIError, configToJSONSchema, type PayloadRequest, type TypedUser } from 'payload'\n\nimport type { MCPAccessSettings, PluginMCPServerConfig } from '../types.js'\n\nimport { toCamelCase } from '../utils/camelCase.js'\nimport { getEnabledSlugs } from '../utils/getEnabledSlugs.js'\nimport {\n getCollectionVirtualFieldNames,\n getGlobalVirtualFieldNames,\n} from '../utils/getVirtualFieldNames.js'\nimport { removeVirtualFieldsFromSchema } from '../utils/schemaConversion/removeVirtualFieldsFromSchema.js'\nimport { registerTool } from './registerTool.js'\n\n// Tools\nimport { findGlobalTool } from './tools/global/find.js'\nimport { updateGlobalTool } from './tools/global/update.js'\nimport { createResourceTool } from './tools/resource/create.js'\nimport { deleteResourceTool } from './tools/resource/delete.js'\nimport { findResourceTool } from './tools/resource/find.js'\nimport { updateResourceTool } from './tools/resource/update.js'\n\n// Experimental Tools\n/**\n * @experimental This tools are experimental and may change or be removed in the future.\n */\nimport { authTool } from './tools/auth/auth.js'\nimport { forgotPasswordTool } from './tools/auth/forgotPassword.js'\nimport { loginTool } from './tools/auth/login.js'\nimport { resetPasswordTool } from './tools/auth/resetPassword.js'\nimport { unlockTool } from './tools/auth/unlock.js'\nimport { verifyTool } from './tools/auth/verify.js'\nimport { createCollectionTool } from './tools/collection/create.js'\nimport { deleteCollectionTool } from './tools/collection/delete.js'\nimport { findCollectionTool } from './tools/collection/find.js'\nimport { updateCollectionTool } from './tools/collection/update.js'\nimport { findConfigTool } from './tools/config/find.js'\nimport { updateConfigTool } from './tools/config/update.js'\nimport { createJobTool } from './tools/job/create.js'\nimport { runJobTool } from './tools/job/run.js'\nimport { updateJobTool } from './tools/job/update.js'\n\nexport const getMCPHandler = (\n pluginOptions: PluginMCPServerConfig,\n mcpAccessSettings: MCPAccessSettings,\n req: PayloadRequest,\n) => {\n const { payload } = req\n const configSchema = configToJSONSchema(payload.config, payload.db.defaultIDType, req.i18n)\n\n // Handler wrapper that injects req before the _extra argument\n const wrapHandler = (handler: (...args: any[]) => any) => {\n return async (...args: any[]) => {\n const _extra = args[args.length - 1]\n const handlerArgs = args.slice(0, -1)\n return await handler(...handlerArgs, req, _extra)\n }\n }\n\n const payloadToolHandler = (\n handler: NonNullable<NonNullable<PluginMCPServerConfig['mcp']>['tools']>[number]['handler'],\n ) => wrapHandler(handler)\n\n const payloadPromptHandler = (\n handler: NonNullable<NonNullable<PluginMCPServerConfig['mcp']>['prompts']>[number]['handler'],\n ) => wrapHandler(handler)\n\n const payloadResourceHandler = (\n handler: NonNullable<NonNullable<PluginMCPServerConfig['mcp']>['resources']>[number]['handler'],\n ) => wrapHandler(handler)\n\n // User\n const user = mcpAccessSettings.user\n\n // MCP Server and Handler Options\n const MCPOptions = pluginOptions.mcp || {}\n const customMCPTools = MCPOptions.tools || []\n const customMCPPrompts = MCPOptions.prompts || []\n const customMCPResources = MCPOptions.resources || []\n const MCPHandlerOptions = MCPOptions.handlerOptions || {}\n const serverOptions = MCPOptions.serverOptions || {}\n const useVerboseLogs = MCPHandlerOptions.verboseLogs ?? false\n\n // Experimental MCP Tool Requirements\n const isDevelopment = process.env.NODE_ENV === 'development'\n const experimentalTools: NonNullable<PluginMCPServerConfig['experimental']>['tools'] =\n pluginOptions?.experimental?.tools || {}\n const collectionsPluginConfig = pluginOptions.collections || {}\n const globalsPluginConfig = pluginOptions.globals || {}\n const collectionsDirPath =\n experimentalTools && experimentalTools.collections?.collectionsDirPath\n ? experimentalTools.collections.collectionsDirPath\n : join(process.cwd(), 'src/collections')\n const configFilePath =\n experimentalTools && experimentalTools.config?.configFilePath\n ? experimentalTools.config.configFilePath\n : join(process.cwd(), 'src/payload.config.ts')\n const jobsDirPath =\n experimentalTools && experimentalTools.jobs?.jobsDirPath\n ? experimentalTools.jobs.jobsDirPath\n : join(process.cwd(), 'src/jobs')\n\n try {\n return createMcpHandler(\n (server) => {\n // Get enabled collections\n const enabledCollectionSlugs = getEnabledSlugs(collectionsPluginConfig, 'collection')\n\n // Collection Operation Tools\n enabledCollectionSlugs.forEach((enabledCollectionSlug) => {\n try {\n const rawSchema = configSchema.definitions?.[enabledCollectionSlug] as JSONSchema4\n\n const virtualFieldNames = getCollectionVirtualFieldNames(\n payload.config,\n enabledCollectionSlug,\n )\n const schema = removeVirtualFieldsFromSchema(\n JSON.parse(JSON.stringify(rawSchema)) as JSONSchema4,\n virtualFieldNames,\n )\n\n const toolCapabilities = mcpAccessSettings?.[\n `${toCamelCase(enabledCollectionSlug)}`\n ] as Record<string, unknown>\n const allowCreate: boolean | undefined = toolCapabilities?.create as boolean\n const allowUpdate: boolean | undefined = toolCapabilities?.update as boolean\n const allowFind: boolean | undefined = toolCapabilities?.find as boolean\n const allowDelete: boolean | undefined = toolCapabilities?.delete as boolean\n\n if (allowCreate) {\n registerTool(\n allowCreate,\n `Create ${enabledCollectionSlug}`,\n () =>\n createResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n schema,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowUpdate) {\n registerTool(\n allowUpdate,\n `Update ${enabledCollectionSlug}`,\n () =>\n updateResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n schema,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowFind) {\n registerTool(\n allowFind,\n `Find ${enabledCollectionSlug}`,\n () =>\n findResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowDelete) {\n registerTool(\n allowDelete,\n `Delete ${enabledCollectionSlug}`,\n () =>\n deleteResourceTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledCollectionSlug,\n collectionsPluginConfig,\n ),\n payload,\n useVerboseLogs,\n )\n }\n } catch (error) {\n throw new APIError(\n `Error registering tools for collection ${enabledCollectionSlug}: ${String(error)}`,\n 500,\n )\n }\n })\n\n // Global Operation Tools\n const enabledGlobalSlugs = getEnabledSlugs(globalsPluginConfig, 'global')\n\n enabledGlobalSlugs.forEach((enabledGlobalSlug) => {\n try {\n const rawSchema = configSchema.definitions?.[enabledGlobalSlug] as JSONSchema4\n\n const virtualFieldNames = getGlobalVirtualFieldNames(payload.config, enabledGlobalSlug)\n const schema = removeVirtualFieldsFromSchema(\n JSON.parse(JSON.stringify(rawSchema)) as JSONSchema4,\n virtualFieldNames,\n )\n\n const toolCapabilities = mcpAccessSettings?.[\n `${toCamelCase(enabledGlobalSlug)}`\n ] as Record<string, unknown>\n const allowFind: boolean | undefined = toolCapabilities?.['find'] as boolean\n const allowUpdate: boolean | undefined = toolCapabilities?.['update'] as boolean\n\n if (allowFind) {\n registerTool(\n allowFind,\n `Find ${enabledGlobalSlug}`,\n () =>\n findGlobalTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledGlobalSlug,\n globalsPluginConfig,\n ),\n payload,\n useVerboseLogs,\n )\n }\n if (allowUpdate) {\n registerTool(\n allowUpdate,\n `Update ${enabledGlobalSlug}`,\n () =>\n updateGlobalTool(\n server,\n req,\n user,\n useVerboseLogs,\n enabledGlobalSlug,\n globalsPluginConfig,\n schema,\n ),\n payload,\n useVerboseLogs,\n )\n }\n } catch (error) {\n throw new APIError(\n `Error registering tools for global ${enabledGlobalSlug}: ${String(error)}`,\n 500,\n )\n }\n })\n\n // Custom tools\n customMCPTools.forEach((tool) => {\n const camelCasedToolName = toCamelCase(tool.name)\n const isToolEnabled = mcpAccessSettings['payload-mcp-tool']?.[camelCasedToolName] ?? false\n\n registerTool(\n isToolEnabled,\n tool.name,\n () =>\n server.registerTool(\n tool.name,\n {\n description: tool.description,\n inputSchema: tool.parameters,\n },\n payloadToolHandler(tool.handler),\n ),\n payload,\n useVerboseLogs,\n )\n })\n\n // Custom prompts\n customMCPPrompts.forEach((prompt) => {\n const camelCasedPromptName = toCamelCase(prompt.name)\n const isPromptEnabled =\n mcpAccessSettings['payload-mcp-prompt']?.[camelCasedPromptName] ?? false\n\n if (isPromptEnabled) {\n server.registerPrompt(\n prompt.name,\n {\n argsSchema: prompt.argsSchema,\n description: prompt.description,\n title: prompt.title,\n },\n payloadPromptHandler(prompt.handler),\n )\n if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ✅ Prompt: ${prompt.title} Registered.`)\n }\n } else if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ⏭️ Prompt: ${prompt.title} Skipped.`)\n }\n })\n\n // Custom resources\n customMCPResources.forEach((resource) => {\n const camelCasedResourceName = toCamelCase(resource.name)\n const isResourceEnabled =\n mcpAccessSettings['payload-mcp-resource']?.[camelCasedResourceName] ?? false\n\n if (isResourceEnabled) {\n server.registerResource(\n resource.name,\n // @ts-expect-error - Overload type is not working however -- ResourceTemplate OR String is a valid type\n resource.uri,\n {\n description: resource.description,\n mimeType: resource.mimeType,\n title: resource.title,\n },\n payloadResourceHandler(resource.handler),\n )\n\n if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ✅ Resource: ${resource.title} Registered.`)\n }\n } else if (useVerboseLogs) {\n payload.logger.info(`[payload-mcp] ⏭️ Resource: ${resource.title} Skipped.`)\n }\n })\n\n // Experimental - Collection Schema Modfication Tools\n if (\n mcpAccessSettings.collections?.create &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.create,\n 'Create Collection',\n () =>\n createCollectionTool(server, req, useVerboseLogs, collectionsDirPath, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n if (\n mcpAccessSettings.collections?.delete &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.delete,\n 'Delete Collection',\n () =>\n deleteCollectionTool(server, req, useVerboseLogs, collectionsDirPath, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (\n mcpAccessSettings.collections?.find &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.find,\n 'Find Collection',\n () => findCollectionTool(server, req, useVerboseLogs, collectionsDirPath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (\n mcpAccessSettings.collections?.update &&\n experimentalTools.collections?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.collections.update,\n 'Update Collection',\n () =>\n updateCollectionTool(server, req, useVerboseLogs, collectionsDirPath, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n // Experimental - Payload Config Modification Tools\n if (mcpAccessSettings.config?.find && experimentalTools.config?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.config.find,\n 'Find Config',\n () => findConfigTool(server, req, useVerboseLogs, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (\n mcpAccessSettings.config?.update &&\n experimentalTools.config?.enabled &&\n isDevelopment\n ) {\n registerTool(\n mcpAccessSettings.config.update,\n 'Update Config',\n () => updateConfigTool(server, req, useVerboseLogs, configFilePath),\n payload,\n useVerboseLogs,\n )\n }\n\n // Experimental - Job Modification Tools\n if (mcpAccessSettings.jobs?.create && experimentalTools.jobs?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.jobs.create,\n 'Create Job',\n () => createJobTool(server, req, useVerboseLogs, jobsDirPath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.jobs?.update && experimentalTools.jobs?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.jobs.update,\n 'Update Job',\n () => updateJobTool(server, req, useVerboseLogs, jobsDirPath),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.jobs?.run && experimentalTools.jobs?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.jobs.run,\n 'Run Job',\n () => runJobTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n // Experimental - Auth Modification Tools\n if (mcpAccessSettings.auth?.auth && experimentalTools.auth?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.auth.auth,\n 'Auth',\n () => authTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.login && experimentalTools.auth?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.auth.login,\n 'Login',\n () => loginTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.verify && experimentalTools.auth?.enabled && isDevelopment) {\n registerTool(\n mcpAccessSettings.auth.verify,\n 'Verify',\n () => verifyTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.resetPassword && experimentalTools.auth?.enabled) {\n registerTool(\n mcpAccessSettings.auth.resetPassword,\n 'Reset Password',\n () => resetPasswordTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.forgotPassword && experimentalTools.auth?.enabled) {\n registerTool(\n mcpAccessSettings.auth.forgotPassword,\n 'Forgot Password',\n () => forgotPasswordTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (mcpAccessSettings.auth?.unlock && experimentalTools.auth?.enabled) {\n registerTool(\n mcpAccessSettings.auth.unlock,\n 'Unlock',\n () => unlockTool(server, req, useVerboseLogs),\n payload,\n useVerboseLogs,\n )\n }\n\n if (useVerboseLogs) {\n payload.logger.info('[payload-mcp] 🚀 MCP Server Ready.')\n }\n },\n {\n serverInfo: serverOptions.serverInfo,\n },\n {\n basePath: MCPHandlerOptions.basePath || payload.config.routes?.api || '/api',\n disableSse: MCPHandlerOptions.disableSse ?? true,\n maxDuration: MCPHandlerOptions.maxDuration || 60,\n onEvent: MCPHandlerOptions.onEvent,\n redisUrl: MCPHandlerOptions.redisUrl,\n verboseLogs: useVerboseLogs,\n },\n )\n } catch (error) {\n throw new APIError(`Error initializing MCP handler: ${String(error)}`, 500)\n }\n}\n"],"names":["createMcpHandler","join","APIError","configToJSONSchema","toCamelCase","getEnabledSlugs","getCollectionVirtualFieldNames","getGlobalVirtualFieldNames","removeVirtualFieldsFromSchema","registerTool","findGlobalTool","updateGlobalTool","createResourceTool","deleteResourceTool","findResourceTool","updateResourceTool","authTool","forgotPasswordTool","loginTool","resetPasswordTool","unlockTool","verifyTool","createCollectionTool","deleteCollectionTool","findCollectionTool","updateCollectionTool","findConfigTool","updateConfigTool","createJobTool","runJobTool","updateJobTool","getMCPHandler","pluginOptions","mcpAccessSettings","req","payload","configSchema","config","db","defaultIDType","i18n","wrapHandler","handler","args","_extra","length","handlerArgs","slice","payloadToolHandler","payloadPromptHandler","payloadResourceHandler","user","MCPOptions","mcp","customMCPTools","tools","customMCPPrompts","prompts","customMCPResources","resources","MCPHandlerOptions","handlerOptions","serverOptions","useVerboseLogs","verboseLogs","isDevelopment","process","env","NODE_ENV","experimentalTools","experimental","collectionsPluginConfig","collections","globalsPluginConfig","globals","collectionsDirPath","cwd","configFilePath","jobsDirPath","jobs","server","enabledCollectionSlugs","forEach","enabledCollectionSlug","rawSchema","definitions","virtualFieldNames","schema","JSON","parse","stringify","toolCapabilities","allowCreate","create","allowUpdate","update","allowFind","find","allowDelete","delete","error","String","enabledGlobalSlugs","enabledGlobalSlug","tool","camelCasedToolName","name","isToolEnabled","description","inputSchema","parameters","prompt","camelCasedPromptName","isPromptEnabled","registerPrompt","argsSchema","title","logger","info","resource","camelCasedResourceName","isResourceEnabled","registerResource","uri","mimeType","enabled","run","auth","login","verify","resetPassword","forgotPassword","unlock","serverInfo","basePath","routes","api","disableSse","maxDuration","onEvent","redisUrl"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,cAAa;AAC9C,SAASC,IAAI,QAAQ,OAAM;AAC3B,SAASC,QAAQ,EAAEC,kBAAkB,QAA6C,UAAS;AAI3F,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SACEC,8BAA8B,EAC9BC,0BAA0B,QACrB,mCAAkC;AACzC,SAASC,6BAA6B,QAAQ,6DAA4D;AAC1G,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,QAAQ;AACR,SAASC,cAAc,QAAQ,yBAAwB;AACvD,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,qBAAqB;AACrB;;CAEC,GACD,SAASC,QAAQ,QAAQ,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7D,kBAAkB0D,IAAI,EAAEF,SAAS;gBAC5EpH,aACEwB,kBAAkB8F,IAAI,CAACG,aAAa,EACpC,kBACA,IAAM/G,kBAAkB6D,QAAQ9C,KAAK6B,iBACrC5B,SACA4B;YAEJ;YAEA,IAAI9B,kBAAkB8F,IAAI,EAAEI,kBAAkB9D,kBAAkB0D,IAAI,EAAEF,SAAS;gBAC7EpH,aACEwB,kBAAkB8F,IAAI,CAACI,cAAc,EACrC,mBACA,IAAMlH,mBAAmB+D,QAAQ9C,KAAK6B,iBACtC5B,SACA4B;YAEJ;YAEA,IAAI9B,kBAAkB8F,IAAI,EAAEK,UAAU/D,kBAAkB0D,IAAI,EAAEF,SAAS;gBACrEpH,aACEwB,kBAAkB8F,IAAI,CAACK,MAAM,EAC7B,UACA,IAAMhH,WAAW4D,QAAQ9C,KAAK6B,iBAC9B5B,SACA4B;YAEJ;YAEA,IAAIA,gBAAgB;gBAClB5B,QAAQkF,MAAM,CAACC,IAAI,CAAC;YACtB;QACF,GACA;YACEe,YAAYvE,cAAcuE,UAAU;QACtC,GACA;YACEC,UAAU1E,kBAAkB0E,QAAQ,IAAInG,QAAQE,MAAM,CAACkG,MAAM,EAAEC,OAAO;YACtEC,YAAY7E,kBAAkB6E,UAAU,IAAI;YAC5CC,aAAa9E,kBAAkB8E,WAAW,IAAI;YAC9CC,SAAS/E,kBAAkB+E,OAAO;YAClCC,UAAUhF,kBAAkBgF,QAAQ;YACpC5E,aAAaD;QACf;IAEJ,EAAE,OAAOqC,OAAO;QACd,MAAM,IAAIlG,SAAS,CAAC,gCAAgC,EAAEmG,OAAOD,QAAQ,EAAE;IACzE;AACF,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminConfig,
|
|
1
|
+
import type { AdminConfig, DatabaseConfig, PluginUpdates } from '../../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Adds a collection to the payload.config.ts file
|
|
4
4
|
*/
|
|
@@ -19,12 +19,4 @@ export declare function updateDatabaseConfig(content: string, databaseConfig: Da
|
|
|
19
19
|
* Updates plugins configuration in payload.config.ts
|
|
20
20
|
*/
|
|
21
21
|
export declare function updatePluginsConfig(content: string, pluginUpdates: PluginUpdates): string;
|
|
22
|
-
/**
|
|
23
|
-
* Updates general configuration options in payload.config.ts
|
|
24
|
-
*/
|
|
25
|
-
export declare function updateGeneralConfig(content: string, generalConfig: GeneralConfig): string;
|
|
26
|
-
/**
|
|
27
|
-
* Updates collection-level configuration in a collection file
|
|
28
|
-
*/
|
|
29
|
-
export declare function updateCollectionConfig(content: string, updates: CollectionConfigUpdates, collectionName: string): string;
|
|
30
22
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEhF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAwCrF;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAgC1F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,CAoDnF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,CAkB5F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,MAAM,CA6CzF"}
|
|
@@ -149,67 +149,5 @@
|
|
|
149
149
|
}
|
|
150
150
|
return content;
|
|
151
151
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Updates general configuration options in payload.config.ts
|
|
154
|
-
*/ export function updateGeneralConfig(content, generalConfig) {
|
|
155
|
-
// Update various general configuration options
|
|
156
|
-
Object.entries(generalConfig).forEach(([key, value])=>{
|
|
157
|
-
if (value !== undefined && value !== null) {
|
|
158
|
-
const configRegex = new RegExp(`${key}:\\s*[^,}]*`, 'g');
|
|
159
|
-
if (content.match(configRegex)) {
|
|
160
|
-
if (typeof value === 'string') {
|
|
161
|
-
content = content.replace(configRegex, `${key}: '${value}'`);
|
|
162
|
-
} else if (typeof value === 'boolean') {
|
|
163
|
-
content = content.replace(configRegex, `${key}: ${value}`);
|
|
164
|
-
} else if (typeof value === 'object') {
|
|
165
|
-
content = content.replace(configRegex, `${key}: ${JSON.stringify(value, null, 2)}`);
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
// Add new config option
|
|
169
|
-
const configValue = typeof value === 'string' ? `'${value}'` : typeof value === 'object' ? JSON.stringify(value, null, 2) : value;
|
|
170
|
-
content = content.replace(/export default buildConfig\(\{/, `export default buildConfig({\n ${key}: ${configValue},`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return content;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Updates collection-level configuration in a collection file
|
|
178
|
-
*/ export function updateCollectionConfig(content, updates, collectionName) {
|
|
179
|
-
let updatedContent = content;
|
|
180
|
-
if (updates.slug) {
|
|
181
|
-
updatedContent = updatedContent.replace(/slug:\s*'[^']*'/, `slug: '${updates.slug}'`);
|
|
182
|
-
}
|
|
183
|
-
if (updates.access) {
|
|
184
|
-
const accessRegex = /access:\s*\{[^}]*\}/;
|
|
185
|
-
if (updatedContent.match(accessRegex)) {
|
|
186
|
-
// Update existing access config
|
|
187
|
-
Object.entries(updates.access).forEach(([key, value])=>{
|
|
188
|
-
if (value !== undefined) {
|
|
189
|
-
updatedContent = updatedContent.replace(new RegExp(`${key}:\\s*[^,}]*`), `${key}: ${value}`);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
} else {
|
|
193
|
-
// Add access config
|
|
194
|
-
const accessConfig = Object.entries(updates.access).filter(([, value])=>value !== undefined).map(([key, value])=>` ${key}: ${value}`).join(',\n');
|
|
195
|
-
updatedContent = updatedContent.replace(/slug:\s*'[^']*',/, `slug: '${collectionName}',\n access: {\n${accessConfig}\n },`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if (updates.timestamps !== undefined) {
|
|
199
|
-
if (updatedContent.includes('timestamps:')) {
|
|
200
|
-
updatedContent = updatedContent.replace(/timestamps:[^,}]*/, `timestamps: ${updates.timestamps}`);
|
|
201
|
-
} else {
|
|
202
|
-
updatedContent = updatedContent.replace(/fields:\s*\[/, `timestamps: ${updates.timestamps},\n fields: [`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (updates.versioning !== undefined) {
|
|
206
|
-
if (updatedContent.includes('versioning:')) {
|
|
207
|
-
updatedContent = updatedContent.replace(/versioning:[^,}]*/, `versioning: ${updates.versioning}`);
|
|
208
|
-
} else {
|
|
209
|
-
updatedContent = updatedContent.replace(/fields:\s*\[/, `versioning: ${updates.versioning},\n fields: [`);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return updatedContent;
|
|
213
|
-
}
|
|
214
152
|
|
|
215
153
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mcp/helpers/config.ts"],"sourcesContent":["import type {\n AdminConfig,\n CollectionConfigUpdates,\n DatabaseConfig,\n GeneralConfig,\n PluginUpdates,\n} from '../../types.js'\n\n/**\n * Adds a collection to the payload.config.ts file\n */\nexport function addCollectionToConfig(content: string, collectionName: string): string {\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n\n // Add import statement\n const importRegex = /import.*from\\s*['\"]\\.\\/collections\\/.*['\"]/g\n const importMatches = content.match(importRegex)\n\n if (importMatches && importMatches.length > 0) {\n const lastImport = importMatches[importMatches.length - 1]\n const newImport = `import { ${capitalizedName} } from './collections/${capitalizedName}'`\n\n // Check if import already exists\n if (lastImport && !content.includes(newImport)) {\n content = content.replace(lastImport, `${lastImport}\\n${newImport}`)\n }\n } else {\n // Add import after existing imports\n const importInsertPoint = content.indexOf(\"import sharp from 'sharp'\")\n if (importInsertPoint !== -1) {\n const lineEnd = content.indexOf('\\n', importInsertPoint)\n const newImport = `import { ${capitalizedName} } from './collections/${capitalizedName}'`\n content = content.slice(0, lineEnd + 1) + newImport + '\\n' + content.slice(lineEnd + 1)\n }\n }\n\n // Add to collections array\n const collectionsRegex = /collections:\\s*\\[([\\s\\S]*?)\\]/\n const collectionsMatch = content.match(collectionsRegex)\n\n if (collectionsMatch && collectionsMatch[1]) {\n const collectionsContent = collectionsMatch[1].trim()\n if (!collectionsContent.includes(capitalizedName)) {\n const newCollections = collectionsContent\n ? `${collectionsContent}, ${capitalizedName}`\n : capitalizedName\n content = content.replace(collectionsRegex, `collections: [${newCollections}]`)\n }\n }\n\n return content\n}\n\n/**\n * Removes a collection from the payload.config.ts file\n */\nexport function removeCollectionFromConfig(content: string, collectionName: string): string {\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n\n // Remove import statement\n const importRegex = new RegExp(\n `import\\\\s*{\\\\s*${capitalizedName}\\\\s*}\\\\s*from\\\\s*['\"]\\\\./collections/${capitalizedName}['\"]\\\\s*\\\\n?`,\n 'g',\n )\n content = content.replace(importRegex, '')\n\n // Remove from collections array\n const collectionsRegex = /collections:\\s*\\[([\\s\\S]*?)\\]/\n const collectionsMatch = content.match(collectionsRegex)\n\n if (collectionsMatch && collectionsMatch[1]) {\n let collectionsContent = collectionsMatch[1]\n\n // Remove the collection name and clean up commas\n collectionsContent = collectionsContent.replace(\n new RegExp(`\\\\s*,?\\\\s*${capitalizedName}\\\\s*,?`, 'g'),\n '',\n )\n collectionsContent = collectionsContent.replace(/,\\s*,/g, ',') // Remove double commas\n collectionsContent = collectionsContent.replace(/^\\s*,|,\\s*$/g, '') // Remove leading/trailing commas\n\n content = content.replace(collectionsRegex, `collections: [${collectionsContent}]`)\n }\n\n // Clean up any double newlines from removed imports\n content = content.replace(/\\n{3,}/g, '\\n\\n')\n\n return content\n}\n\n/**\n * Updates admin configuration in payload.config.ts\n */\nexport function updateAdminConfig(content: string, adminConfig: AdminConfig): string {\n const adminRegex = /admin:\\s*\\{([^}]*)\\}/\n const adminMatch = content.match(adminRegex)\n\n if (adminMatch && adminMatch[1]) {\n let adminContent = adminMatch[1]\n\n // Update specific admin properties\n if (adminConfig.user) {\n if (adminContent.includes('user:')) {\n adminContent = adminContent.replace(/user:[^,}]*/, `user: ${adminConfig.user}.slug`)\n } else {\n adminContent = `\\n user: ${adminConfig.user}.slug,${adminContent}`\n }\n }\n\n if (adminConfig.meta) {\n const metaConfig = Object.entries(adminConfig.meta)\n .map(([key, value]) => ` ${key}: '${value}'`)\n .join(',\\n')\n\n if (adminContent.includes('meta:')) {\n adminContent = adminContent.replace(/meta:\\s*\\{[^}]*\\}/, `meta: {\\n${metaConfig}\\n }`)\n } else {\n adminContent = `${adminContent}\\n meta: {\\n${metaConfig}\\n },`\n }\n }\n\n content = content.replace(adminRegex, `admin: {${adminContent}\\n }`)\n } else {\n // Add admin config if it doesn't exist\n const adminConfigEntries = []\n\n if (adminConfig.user) {\n adminConfigEntries.push(` user: ${adminConfig.user}.slug`)\n }\n\n if (adminConfig.meta) {\n const metaConfig = Object.entries(adminConfig.meta)\n .map(([key, value]) => ` ${key}: '${value}'`)\n .join(',\\n')\n adminConfigEntries.push(` meta: {\\n${metaConfig}\\n }`)\n }\n\n const adminConfigString = `admin: {\\n${adminConfigEntries.join(',\\n')}\\n },`\n content = content.replace(\n /export default buildConfig\\(\\{/,\n `export default buildConfig({\\n ${adminConfigString}`,\n )\n }\n\n return content\n}\n\n/**\n * Updates database configuration in payload.config.ts\n */\nexport function updateDatabaseConfig(content: string, databaseConfig: DatabaseConfig): string {\n if (databaseConfig.type === 'mongodb') {\n // Update to MongoDB adapter\n const dbRegex = /db:[^,}]*(?:,|\\})/\n const mongoImportRegex = /import.*mongooseAdapter.*from.*@payloadcms\\/db-mongodb.*/\n\n if (!content.match(mongoImportRegex)) {\n content = content.replace(\n /(import.*from.*payload.*\\n)/,\n `$1import { mongooseAdapter } from '@payloadcms/db-mongodb'\\n`,\n )\n }\n\n const dbConfig = `db: mongooseAdapter({\\n url: process.env.DATABASE_URL || '${databaseConfig.url || ''}',\\n })`\n content = content.replace(dbRegex, `${dbConfig},`)\n }\n\n return content\n}\n\n/**\n * Updates plugins configuration in payload.config.ts\n */\nexport function updatePluginsConfig(content: string, pluginUpdates: PluginUpdates): string {\n // Add plugin imports\n if (pluginUpdates.add) {\n pluginUpdates.add.forEach((pluginImport: string) => {\n if (!content.includes(pluginImport)) {\n content = content.replace(/(import.*from.*payload.*\\n)/, `$1${pluginImport}\\n`)\n }\n })\n }\n\n // Handle plugins array\n const pluginsRegex = /plugins:\\s*\\[([\\s\\S]*?)\\]/\n const pluginsMatch = content.match(pluginsRegex)\n\n if (pluginsMatch && pluginsMatch[1]) {\n let pluginsContent = pluginsMatch[1]\n\n // Remove plugins\n if (pluginUpdates.remove) {\n pluginUpdates.remove.forEach((pluginName: string) => {\n const pluginRegex = new RegExp(`\\\\s*${pluginName}\\\\(\\\\)\\\\s*,?`, 'g')\n pluginsContent = pluginsContent.replace(pluginRegex, '')\n })\n }\n\n // Add plugins\n if (pluginUpdates.add) {\n pluginUpdates.add.forEach((pluginImport: string) => {\n // This will match: import { PluginName } from '...';\n const match = pluginImport.match(/import\\s*\\{\\s*(\\w+)\\s*\\}/)\n if (match && match[1]) {\n const pluginName = match[1]\n if (!pluginsContent.includes(`${pluginName}(`)) {\n pluginsContent = pluginsContent.trim()\n ? `${pluginsContent}\\n ${pluginName}(),`\n : `\\n ${pluginName}(),`\n }\n }\n })\n }\n\n content = content.replace(pluginsRegex, `plugins: [${pluginsContent}\\n ]`)\n }\n\n return content\n}\n\n/**\n * Updates general configuration options in payload.config.ts\n */\nexport function updateGeneralConfig(content: string, generalConfig: GeneralConfig): string {\n // Update various general configuration options\n Object.entries(generalConfig).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n const configRegex = new RegExp(`${key}:\\\\s*[^,}]*`, 'g')\n\n if (content.match(configRegex)) {\n if (typeof value === 'string') {\n content = content.replace(configRegex, `${key}: '${value}'`)\n } else if (typeof value === 'boolean') {\n content = content.replace(configRegex, `${key}: ${value}`)\n } else if (typeof value === 'object') {\n content = content.replace(configRegex, `${key}: ${JSON.stringify(value, null, 2)}`)\n }\n } else {\n // Add new config option\n const configValue =\n typeof value === 'string'\n ? `'${value}'`\n : typeof value === 'object'\n ? JSON.stringify(value, null, 2)\n : value\n content = content.replace(\n /export default buildConfig\\(\\{/,\n `export default buildConfig({\\n ${key}: ${configValue},`,\n )\n }\n }\n })\n\n return content\n}\n\n/**\n * Updates collection-level configuration in a collection file\n */\nexport function updateCollectionConfig(\n content: string,\n updates: CollectionConfigUpdates,\n collectionName: string,\n): string {\n let updatedContent = content\n\n if (updates.slug) {\n updatedContent = updatedContent.replace(/slug:\\s*'[^']*'/, `slug: '${updates.slug}'`)\n }\n\n if (updates.access) {\n const accessRegex = /access:\\s*\\{[^}]*\\}/\n if (updatedContent.match(accessRegex)) {\n // Update existing access config\n Object.entries(updates.access).forEach(([key, value]) => {\n if (value !== undefined) {\n updatedContent = updatedContent.replace(\n new RegExp(`${key}:\\\\s*[^,}]*`),\n `${key}: ${value}`,\n )\n }\n })\n } else {\n // Add access config\n const accessConfig = Object.entries(updates.access)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => ` ${key}: ${value}`)\n .join(',\\n')\n\n updatedContent = updatedContent.replace(\n /slug:\\s*'[^']*',/,\n `slug: '${collectionName}',\\n access: {\\n${accessConfig}\\n },`,\n )\n }\n }\n\n if (updates.timestamps !== undefined) {\n if (updatedContent.includes('timestamps:')) {\n updatedContent = updatedContent.replace(\n /timestamps:[^,}]*/,\n `timestamps: ${updates.timestamps}`,\n )\n } else {\n updatedContent = updatedContent.replace(\n /fields:\\s*\\[/,\n `timestamps: ${updates.timestamps},\\n fields: [`,\n )\n }\n }\n\n if (updates.versioning !== undefined) {\n if (updatedContent.includes('versioning:')) {\n updatedContent = updatedContent.replace(\n /versioning:[^,}]*/,\n `versioning: ${updates.versioning}`,\n )\n } else {\n updatedContent = updatedContent.replace(\n /fields:\\s*\\[/,\n `versioning: ${updates.versioning},\\n fields: [`,\n )\n }\n }\n\n return updatedContent\n}\n"],"names":["addCollectionToConfig","content","collectionName","capitalizedName","charAt","toUpperCase","slice","importRegex","importMatches","match","length","lastImport","newImport","includes","replace","importInsertPoint","indexOf","lineEnd","collectionsRegex","collectionsMatch","collectionsContent","trim","newCollections","removeCollectionFromConfig","RegExp","updateAdminConfig","adminConfig","adminRegex","adminMatch","adminContent","user","meta","metaConfig","Object","entries","map","key","value","join","adminConfigEntries","push","adminConfigString","updateDatabaseConfig","databaseConfig","type","dbRegex","mongoImportRegex","dbConfig","url","updatePluginsConfig","pluginUpdates","add","forEach","pluginImport","pluginsRegex","pluginsMatch","pluginsContent","remove","pluginName","pluginRegex","updateGeneralConfig","generalConfig","undefined","configRegex","JSON","stringify","configValue","updateCollectionConfig","updates","updatedContent","slug","access","accessRegex","accessConfig","filter","timestamps","versioning"],"mappings":"AAQA;;CAEC,GACD,OAAO,SAASA,sBAAsBC,OAAe,EAAEC,cAAsB;IAC3E,MAAMC,kBAAkBD,eAAeE,MAAM,CAAC,GAAGC,WAAW,KAAKH,eAAeI,KAAK,CAAC;IAEtF,uBAAuB;IACvB,MAAMC,cAAc;IACpB,MAAMC,gBAAgBP,QAAQQ,KAAK,CAACF;IAEpC,IAAIC,iBAAiBA,cAAcE,MAAM,GAAG,GAAG;QAC7C,MAAMC,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E;QAEvC,OAAO;YACLN,iBAAiBA,eAAevD,OAAO,CACrC,gBACA,CAAC,YAAY,EAAEsD,QAAQO,UAAU,CAAC,cAAc,CAAC;QAErD;IACF;IAEA,IAAIP,QAAQQ,UAAU,KAAKd,WAAW;QACpC,IAAIO,eAAexD,QAAQ,CAAC,gBAAgB;YAC1CwD,iBAAiBA,eAAevD,OAAO,CACrC,qBACA,CAAC,YAAY,EAAEsD,QAAQQ,UAAU,EAAE;QAEvC,OAAO;YACLP,iBAAiBA,eAAevD,OAAO,CACrC,gBACA,CAAC,YAAY,EAAEsD,QAAQQ,UAAU,CAAC,cAAc,CAAC;QAErD;IACF;IAEA,OAAOP;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../src/mcp/helpers/config.ts"],"sourcesContent":["import type { AdminConfig, DatabaseConfig, PluginUpdates } from '../../types.js'\n\n/**\n * Adds a collection to the payload.config.ts file\n */\nexport function addCollectionToConfig(content: string, collectionName: string): string {\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n\n // Add import statement\n const importRegex = /import.*from\\s*['\"]\\.\\/collections\\/.*['\"]/g\n const importMatches = content.match(importRegex)\n\n if (importMatches && importMatches.length > 0) {\n const lastImport = importMatches[importMatches.length - 1]\n const newImport = `import { ${capitalizedName} } from './collections/${capitalizedName}'`\n\n // Check if import already exists\n if (lastImport && !content.includes(newImport)) {\n content = content.replace(lastImport, `${lastImport}\\n${newImport}`)\n }\n } else {\n // Add import after existing imports\n const importInsertPoint = content.indexOf(\"import sharp from 'sharp'\")\n if (importInsertPoint !== -1) {\n const lineEnd = content.indexOf('\\n', importInsertPoint)\n const newImport = `import { ${capitalizedName} } from './collections/${capitalizedName}'`\n content = content.slice(0, lineEnd + 1) + newImport + '\\n' + content.slice(lineEnd + 1)\n }\n }\n\n // Add to collections array\n const collectionsRegex = /collections:\\s*\\[([\\s\\S]*?)\\]/\n const collectionsMatch = content.match(collectionsRegex)\n\n if (collectionsMatch && collectionsMatch[1]) {\n const collectionsContent = collectionsMatch[1].trim()\n if (!collectionsContent.includes(capitalizedName)) {\n const newCollections = collectionsContent\n ? `${collectionsContent}, ${capitalizedName}`\n : capitalizedName\n content = content.replace(collectionsRegex, `collections: [${newCollections}]`)\n }\n }\n\n return content\n}\n\n/**\n * Removes a collection from the payload.config.ts file\n */\nexport function removeCollectionFromConfig(content: string, collectionName: string): string {\n const capitalizedName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1)\n\n // Remove import statement\n const importRegex = new RegExp(\n `import\\\\s*{\\\\s*${capitalizedName}\\\\s*}\\\\s*from\\\\s*['\"]\\\\./collections/${capitalizedName}['\"]\\\\s*\\\\n?`,\n 'g',\n )\n content = content.replace(importRegex, '')\n\n // Remove from collections array\n const collectionsRegex = /collections:\\s*\\[([\\s\\S]*?)\\]/\n const collectionsMatch = content.match(collectionsRegex)\n\n if (collectionsMatch && collectionsMatch[1]) {\n let collectionsContent = collectionsMatch[1]\n\n // Remove the collection name and clean up commas\n collectionsContent = collectionsContent.replace(\n new RegExp(`\\\\s*,?\\\\s*${capitalizedName}\\\\s*,?`, 'g'),\n '',\n )\n collectionsContent = collectionsContent.replace(/,\\s*,/g, ',') // Remove double commas\n collectionsContent = collectionsContent.replace(/^\\s*,|,\\s*$/g, '') // Remove leading/trailing commas\n\n content = content.replace(collectionsRegex, `collections: [${collectionsContent}]`)\n }\n\n // Clean up any double newlines from removed imports\n content = content.replace(/\\n{3,}/g, '\\n\\n')\n\n return content\n}\n\n/**\n * Updates admin configuration in payload.config.ts\n */\nexport function updateAdminConfig(content: string, adminConfig: AdminConfig): string {\n const adminRegex = /admin:\\s*\\{([^}]*)\\}/\n const adminMatch = content.match(adminRegex)\n\n if (adminMatch && adminMatch[1]) {\n let adminContent = adminMatch[1]\n\n // Update specific admin properties\n if (adminConfig.user) {\n if (adminContent.includes('user:')) {\n adminContent = adminContent.replace(/user:[^,}]*/, `user: ${adminConfig.user}.slug`)\n } else {\n adminContent = `\\n user: ${adminConfig.user}.slug,${adminContent}`\n }\n }\n\n if (adminConfig.meta) {\n const metaConfig = Object.entries(adminConfig.meta)\n .map(([key, value]) => ` ${key}: '${value}'`)\n .join(',\\n')\n\n if (adminContent.includes('meta:')) {\n adminContent = adminContent.replace(/meta:\\s*\\{[^}]*\\}/, `meta: {\\n${metaConfig}\\n }`)\n } else {\n adminContent = `${adminContent}\\n meta: {\\n${metaConfig}\\n },`\n }\n }\n\n content = content.replace(adminRegex, `admin: {${adminContent}\\n }`)\n } else {\n // Add admin config if it doesn't exist\n const adminConfigEntries = []\n\n if (adminConfig.user) {\n adminConfigEntries.push(` user: ${adminConfig.user}.slug`)\n }\n\n if (adminConfig.meta) {\n const metaConfig = Object.entries(adminConfig.meta)\n .map(([key, value]) => ` ${key}: '${value}'`)\n .join(',\\n')\n adminConfigEntries.push(` meta: {\\n${metaConfig}\\n }`)\n }\n\n const adminConfigString = `admin: {\\n${adminConfigEntries.join(',\\n')}\\n },`\n content = content.replace(\n /export default buildConfig\\(\\{/,\n `export default buildConfig({\\n ${adminConfigString}`,\n )\n }\n\n return content\n}\n\n/**\n * Updates database configuration in payload.config.ts\n */\nexport function updateDatabaseConfig(content: string, databaseConfig: DatabaseConfig): string {\n if (databaseConfig.type === 'mongodb') {\n // Update to MongoDB adapter\n const dbRegex = /db:[^,}]*(?:,|\\})/\n const mongoImportRegex = /import.*mongooseAdapter.*from.*@payloadcms\\/db-mongodb.*/\n\n if (!content.match(mongoImportRegex)) {\n content = content.replace(\n /(import.*from.*payload.*\\n)/,\n `$1import { mongooseAdapter } from '@payloadcms/db-mongodb'\\n`,\n )\n }\n\n const dbConfig = `db: mongooseAdapter({\\n url: process.env.DATABASE_URL || '${databaseConfig.url || ''}',\\n })`\n content = content.replace(dbRegex, `${dbConfig},`)\n }\n\n return content\n}\n\n/**\n * Updates plugins configuration in payload.config.ts\n */\nexport function updatePluginsConfig(content: string, pluginUpdates: PluginUpdates): string {\n // Add plugin imports\n if (pluginUpdates.add) {\n pluginUpdates.add.forEach((pluginImport: string) => {\n if (!content.includes(pluginImport)) {\n content = content.replace(/(import.*from.*payload.*\\n)/, `$1${pluginImport}\\n`)\n }\n })\n }\n\n // Handle plugins array\n const pluginsRegex = /plugins:\\s*\\[([\\s\\S]*?)\\]/\n const pluginsMatch = content.match(pluginsRegex)\n\n if (pluginsMatch && pluginsMatch[1]) {\n let pluginsContent = pluginsMatch[1]\n\n // Remove plugins\n if (pluginUpdates.remove) {\n pluginUpdates.remove.forEach((pluginName: string) => {\n const pluginRegex = new RegExp(`\\\\s*${pluginName}\\\\(\\\\)\\\\s*,?`, 'g')\n pluginsContent = pluginsContent.replace(pluginRegex, '')\n })\n }\n\n // Add plugins\n if (pluginUpdates.add) {\n pluginUpdates.add.forEach((pluginImport: string) => {\n // This will match: import { PluginName } from '...';\n const match = pluginImport.match(/import\\s*\\{\\s*(\\w+)\\s*\\}/)\n if (match && match[1]) {\n const pluginName = match[1]\n if (!pluginsContent.includes(`${pluginName}(`)) {\n pluginsContent = pluginsContent.trim()\n ? `${pluginsContent}\\n ${pluginName}(),`\n : `\\n ${pluginName}(),`\n }\n }\n })\n }\n\n content = content.replace(pluginsRegex, `plugins: [${pluginsContent}\\n ]`)\n }\n\n return content\n}\n"],"names":["addCollectionToConfig","content","collectionName","capitalizedName","charAt","toUpperCase","slice","importRegex","importMatches","match","length","lastImport","newImport","includes","replace","importInsertPoint","indexOf","lineEnd","collectionsRegex","collectionsMatch","collectionsContent","trim","newCollections","removeCollectionFromConfig","RegExp","updateAdminConfig","adminConfig","adminRegex","adminMatch","adminContent","user","meta","metaConfig","Object","entries","map","key","value","join","adminConfigEntries","push","adminConfigString","updateDatabaseConfig","databaseConfig","type","dbRegex","mongoImportRegex","dbConfig","url","updatePluginsConfig","pluginUpdates","add","forEach","pluginImport","pluginsRegex","pluginsMatch","pluginsContent","remove","pluginName","pluginRegex"],"mappings":"AAEA;;CAEC,GACD,OAAO,SAASA,sBAAsBC,OAAe,EAAEC,cAAsB;IAC3E,MA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cC,GAAG,EAAE;YACrBD,cAAcC,GAAG,CAACC,OAAO,CAAC,CAACC;gBACzB,qDAAqD;gBACrD,MAAM5C,QAAQ4C,aAAa5C,KAAK,CAAC;gBACjC,IAAIA,SAASA,KAAK,CAAC,EAAE,EAAE;oBACrB,MAAMiD,aAAajD,KAAK,CAAC,EAAE;oBAC3B,IAAI,CAAC+C,eAAe3C,QAAQ,CAAC,GAAG6C,WAAW,CAAC,CAAC,GAAG;wBAC9CF,iBAAiBA,eAAenC,IAAI,KAChC,GAAGmC,eAAe,MAAM,EAAEE,WAAW,GAAG,CAAC,GACzC,CAAC,MAAM,EAAEA,WAAW,GAAG,CAAC;oBAC9B;gBACF;YACF;QACF;QAEAzD,UAAUA,QAAQa,OAAO,CAACwC,cAAc,CAAC,UAAU,EAAEE,eAAe,KAAK,CAAC;IAC5E;IAEA,OAAOvD;AACT"}
|
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
type FieldDefinition
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}[];
|
|
8
|
-
position?: 'main' | 'sidebar';
|
|
9
|
-
required?: boolean;
|
|
10
|
-
type: string;
|
|
11
|
-
};
|
|
12
|
-
type FieldModification = {
|
|
13
|
-
changes: {
|
|
14
|
-
description?: string;
|
|
15
|
-
options?: {
|
|
16
|
-
label: string;
|
|
17
|
-
value: string;
|
|
18
|
-
}[];
|
|
19
|
-
position?: 'main' | 'sidebar';
|
|
20
|
-
required?: boolean;
|
|
21
|
-
type?: string;
|
|
22
|
-
};
|
|
23
|
-
fieldName: string;
|
|
24
|
-
};
|
|
1
|
+
import type { FieldDefinition, FieldModification } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates the TypeScript source string for a single field definition block.
|
|
4
|
+
* Used when writing collection files to disk.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateFieldDefinitionString(field: FieldDefinition): string;
|
|
25
7
|
/**
|
|
26
8
|
* Adds new fields to a collection file content
|
|
27
9
|
*/
|
|
@@ -34,5 +16,4 @@ export declare function removeFieldsFromCollection(content: string, fieldNames:
|
|
|
34
16
|
* Modifies existing fields in a collection file content
|
|
35
17
|
*/
|
|
36
18
|
export declare function modifyFieldsInCollection(content: string, modifications: FieldModification[]): string;
|
|
37
|
-
export {};
|
|
38
19
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/fields.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAWxE;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAiC5E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,MAAM,CAqB3F;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAiBxF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,iBAAiB,EAAE,GACjC,MAAM,CAiDR"}
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
/** Escapes a value for safe embedding inside a single-quoted TypeScript string literal. */ function escapeSingleQuotedString(value) {
|
|
2
|
+
return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\r/g, '\\r').replace(/\n/g, '\\n');
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Generates the TypeScript source string for a single field definition block.
|
|
6
|
+
* Used when writing collection files to disk.
|
|
7
|
+
*/ export function generateFieldDefinitionString(field) {
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push(` {`);
|
|
10
|
+
lines.push(` name: '${escapeSingleQuotedString(field.name)}',`);
|
|
11
|
+
lines.push(` type: '${escapeSingleQuotedString(field.type)}',`);
|
|
12
|
+
if (field.required) {
|
|
13
|
+
lines.push(` required: true,`);
|
|
14
|
+
}
|
|
15
|
+
if (field.description || field.position) {
|
|
16
|
+
lines.push(` admin: {`);
|
|
17
|
+
if (field.description) {
|
|
18
|
+
lines.push(` description: '${escapeSingleQuotedString(field.description)}',`);
|
|
19
|
+
}
|
|
20
|
+
if (field.position) {
|
|
21
|
+
lines.push(` position: '${escapeSingleQuotedString(field.position)}',`);
|
|
22
|
+
}
|
|
23
|
+
lines.push(` },`);
|
|
24
|
+
}
|
|
25
|
+
if (field.options && field.type === 'select') {
|
|
26
|
+
lines.push(` options: [`);
|
|
27
|
+
field.options.forEach((option)=>{
|
|
28
|
+
lines.push(` { label: '${escapeSingleQuotedString(option.label)}', value: '${escapeSingleQuotedString(option.value)}' },`);
|
|
29
|
+
});
|
|
30
|
+
lines.push(` ],`);
|
|
31
|
+
}
|
|
32
|
+
lines.push(` },`);
|
|
33
|
+
return lines.join('\n');
|
|
34
|
+
}
|
|
1
35
|
/**
|
|
2
36
|
* Adds new fields to a collection file content
|
|
3
37
|
*/ export function addFieldsToCollection(content, newFields) {
|
|
@@ -7,35 +41,7 @@
|
|
|
7
41
|
if (!match) {
|
|
8
42
|
throw new Error('Could not find fields array in collection file');
|
|
9
43
|
}
|
|
10
|
-
|
|
11
|
-
const newFieldDefinitions = newFields.map((field)=>{
|
|
12
|
-
const fieldConfig = [];
|
|
13
|
-
fieldConfig.push(` {`);
|
|
14
|
-
fieldConfig.push(` name: '${field.name}',`);
|
|
15
|
-
fieldConfig.push(` type: '${field.type}',`);
|
|
16
|
-
if (field.required) {
|
|
17
|
-
fieldConfig.push(` required: true,`);
|
|
18
|
-
}
|
|
19
|
-
if (field.description || field.position) {
|
|
20
|
-
fieldConfig.push(` admin: {`);
|
|
21
|
-
if (field.description) {
|
|
22
|
-
fieldConfig.push(` description: '${field.description}',`);
|
|
23
|
-
}
|
|
24
|
-
if (field.position) {
|
|
25
|
-
fieldConfig.push(` position: '${field.position}',`);
|
|
26
|
-
}
|
|
27
|
-
fieldConfig.push(` },`);
|
|
28
|
-
}
|
|
29
|
-
if (field.options && field.type === 'select') {
|
|
30
|
-
fieldConfig.push(` options: [`);
|
|
31
|
-
field.options.forEach((option)=>{
|
|
32
|
-
fieldConfig.push(` { label: '${option.label}', value: '${option.value}' },`);
|
|
33
|
-
});
|
|
34
|
-
fieldConfig.push(` ],`);
|
|
35
|
-
}
|
|
36
|
-
fieldConfig.push(` },`);
|
|
37
|
-
return fieldConfig.join('\n');
|
|
38
|
-
}).join('\n');
|
|
44
|
+
const newFieldDefinitions = newFields.map(generateFieldDefinitionString).join('\n');
|
|
39
45
|
// Add new fields before the closing bracket
|
|
40
46
|
const existingFields = match[1] || '';
|
|
41
47
|
const hasTrailingComma = existingFields.trim().endsWith(',');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mcp/helpers/fields.ts"],"sourcesContent":["type FieldDefinition
|
|
1
|
+
{"version":3,"sources":["../../../src/mcp/helpers/fields.ts"],"sourcesContent":["import type { FieldDefinition, FieldModification } from '../../types.js'\n\n/** Escapes a value for safe embedding inside a single-quoted TypeScript string literal. */\nfunction escapeSingleQuotedString(value: string): string {\n return value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\r/g, '\\\\r')\n .replace(/\\n/g, '\\\\n')\n}\n\n/**\n * Generates the TypeScript source string for a single field definition block.\n * Used when writing collection files to disk.\n */\nexport function generateFieldDefinitionString(field: FieldDefinition): string {\n const lines: string[] = []\n lines.push(` {`)\n lines.push(` name: '${escapeSingleQuotedString(field.name)}',`)\n lines.push(` type: '${escapeSingleQuotedString(field.type)}',`)\n\n if (field.required) {\n lines.push(` required: true,`)\n }\n\n if (field.description || field.position) {\n lines.push(` admin: {`)\n if (field.description) {\n lines.push(` description: '${escapeSingleQuotedString(field.description)}',`)\n }\n if (field.position) {\n lines.push(` position: '${escapeSingleQuotedString(field.position)}',`)\n }\n lines.push(` },`)\n }\n\n if (field.options && field.type === 'select') {\n lines.push(` options: [`)\n field.options.forEach((option) => {\n lines.push(\n ` { label: '${escapeSingleQuotedString(option.label)}', value: '${escapeSingleQuotedString(option.value)}' },`,\n )\n })\n lines.push(` ],`)\n }\n\n lines.push(` },`)\n return lines.join('\\n')\n}\n\n/**\n * Adds new fields to a collection file content\n */\nexport function addFieldsToCollection(content: string, newFields: FieldDefinition[]): string {\n // Find the fields array closing bracket\n const fieldsRegex = /fields:\\s*\\[([\\s\\S]*?)\\]\\s*(?:,\\s*)?\\}/\n const match = content.match(fieldsRegex)\n\n if (!match) {\n throw new Error('Could not find fields array in collection file')\n }\n\n const newFieldDefinitions = newFields.map(generateFieldDefinitionString).join('\\n')\n\n // Add new fields before the closing bracket\n const existingFields = match[1] || ''\n const hasTrailingComma = existingFields.trim().endsWith(',')\n const separator = hasTrailingComma ? '\\n' : ',\\n'\n\n return content.replace(\n fieldsRegex,\n `fields: [${existingFields}${separator}${newFieldDefinitions}\\n ],\n}`,\n )\n}\n\n/**\n * Removes fields from a collection file content\n */\nexport function removeFieldsFromCollection(content: string, fieldNames: string[]): string {\n let updatedContent = content\n\n fieldNames.forEach((fieldName) => {\n // Create regex to match the field definition\n const fieldRegex = new RegExp(\n `\\\\s*{[^}]*name:\\\\s*['\"]${fieldName}['\"][^}]*}[^}]*(?:},?|,?\\\\s*})`,\n 'gs',\n )\n updatedContent = updatedContent.replace(fieldRegex, '')\n })\n\n // Clean up any double commas or trailing commas\n updatedContent = updatedContent.replace(/,\\s*,/g, ',')\n updatedContent = updatedContent.replace(/,\\s*\\]/g, '\\n ]')\n\n return updatedContent\n}\n\n/**\n * Modifies existing fields in a collection file content\n */\nexport function modifyFieldsInCollection(\n content: string,\n modifications: FieldModification[],\n): string {\n let updatedContent = content\n\n modifications.forEach((mod) => {\n const { changes, fieldName } = mod\n\n // Find the field definition\n const fieldRegex = new RegExp(`({[^}]*name:\\\\s*['\"]${fieldName}['\"][^}]*})`, 'gs')\n const fieldMatch = updatedContent.match(fieldRegex)\n\n if (fieldMatch) {\n let fieldDef = fieldMatch[0]\n\n // Apply changes\n if (changes.type) {\n fieldDef = fieldDef.replace(/type:\\s*'[^']*'/, `type: '${changes.type}'`)\n }\n\n if (changes.required !== undefined) {\n if (fieldDef.includes('required:')) {\n fieldDef = fieldDef.replace(/required:[^,]*/, `required: ${changes.required}`)\n } else {\n fieldDef = fieldDef.replace(\n /type:\\s*'[^']*',/,\n `type: '${changes.type}',\\n required: ${changes.required},`,\n )\n }\n }\n\n if (changes.description) {\n const adminRegex = /admin:\\s*\\{[^}]*\\}/\n if (fieldDef.match(adminRegex)) {\n fieldDef = fieldDef.replace(\n /description:\\s*'[^']*'/,\n `description: '${changes.description}'`,\n )\n } else {\n fieldDef = fieldDef.replace(\n /\\},?\\s*$/,\n `,\\n admin: {\\n description: '${changes.description}',\\n },\\n }`,\n )\n }\n }\n\n updatedContent = updatedContent.replace(fieldRegex, fieldDef)\n }\n })\n\n return updatedContent\n}\n"],"names":["escapeSingleQuotedString","value","replace","generateFieldDefinitionString","field","lines","push","name","type","required","description","position","options","forEach","option","label","join","addFieldsToCollection","content","newFields","fieldsRegex","match","Error","newFieldDefinitions","map","existingFields","hasTrailingComma","trim","endsWith","separator","removeFieldsFromCollection","fieldNames","updatedContent","fieldName","fieldRegex","RegExp","modifyFieldsInCollection","modifications","mod","changes","fieldMatch","fieldDef","undefined","includes","adminRegex"],"mappings":"AAEA,yFAAyF,GACzF,SAASA,yBAAyBC,KAAa;IAC7C,OAAOA,MACJC,OAAO,CAAC,OAAO,QACfA,OAAO,CAAC,MAAM,OACdA,OAAO,CAAC,OAAO,OACfA,OAAO,CAAC,OAAO;AACpB;AAEA;;;CAGC,GACD,OAAO,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AE5B,gBAAgB;YAChB,IAAID,QAAQ/B,IAAI,EAAE;gBAChBiC,WAAWA,SAASvC,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAEqC,QAAQ/B,IAAI,CAAC,CAAC,CAAC;YAC1E;YAEA,IAAI+B,QAAQ9B,QAAQ,KAAKiC,WAAW;gBAClC,IAAID,SAASE,QAAQ,CAAC,cAAc;oBAClCF,WAAWA,SAASvC,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAEqC,QAAQ9B,QAAQ,EAAE;gBAC/E,OAAO;oBACLgC,WAAWA,SAASvC,OAAO,CACzB,oBACA,CAAC,OAAO,EAAEqC,QAAQ/B,IAAI,CAAC,oBAAoB,EAAE+B,QAAQ9B,QAAQ,CAAC,CAAC,CAAC;gBAEpE;YACF;YAEA,IAAI8B,QAAQ7B,WAAW,EAAE;gBACvB,MAAMkC,aAAa;gBACnB,IAAIH,SAASpB,KAAK,CAACuB,aAAa;oBAC9BH,WAAWA,SAASvC,OAAO,CACzB,0BACA,CAAC,cAAc,EAAEqC,QAAQ7B,WAAW,CAAC,CAAC,CAAC;gBAE3C,OAAO;oBACL+B,WAAWA,SAASvC,OAAO,CACzB,YACA,CAAC,yCAAyC,EAAEqC,QAAQ7B,WAAW,CAAC,mBAAmB,CAAC;gBAExF;YACF;YAEAsB,iBAAiBA,eAAe9B,OAAO,CAACgC,YAAYO;QACtD;IACF;IAEA,OAAOT;AACT"}
|
|
@@ -64,6 +64,4 @@ export interface WorkflowConfig {
|
|
|
64
64
|
*/
|
|
65
65
|
export declare const validatePayloadFile: <T = CollectionConfig | TaskConfig | WorkflowConfig>(fileName: string, type: ValidationType) => Promise<ValidationResult<T>>;
|
|
66
66
|
export declare const validateCollectionFile: (fileName: string) => Promise<ValidationResult<CollectionConfig>>;
|
|
67
|
-
export declare const validateTaskFile: (fileName: string) => Promise<ValidationResult<TaskConfig>>;
|
|
68
|
-
export declare const validateWorkflowFile: (fileName: string) => Promise<ValidationResult<WorkflowConfig>>;
|
|
69
67
|
//# sourceMappingURL=fileValidation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileValidation.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/fileValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAA;AAE/D,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,MAAM,CAAC,EAAE,CAAC,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB;AAGD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,CAAC,IAAI,EAAE;QACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC/B,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,WAAW,CAAC,EAAE,KAAK,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QACjD,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM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