@payloadcms/plugin-mcp 3.78.0-internal-debug.f663370 → 3.78.0-internal.ab11ffa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/mcp/getMcpHandler.d.ts.map +1 -1
  6. package/dist/mcp/getMcpHandler.js +8 -2
  7. package/dist/mcp/getMcpHandler.js.map +1 -1
  8. package/dist/mcp/helpers/config.d.ts +1 -9
  9. package/dist/mcp/helpers/config.d.ts.map +1 -1
  10. package/dist/mcp/helpers/config.js +0 -62
  11. package/dist/mcp/helpers/config.js.map +1 -1
  12. package/dist/mcp/helpers/fields.d.ts +6 -25
  13. package/dist/mcp/helpers/fields.d.ts.map +1 -1
  14. package/dist/mcp/helpers/fields.js +35 -29
  15. package/dist/mcp/helpers/fields.js.map +1 -1
  16. package/dist/mcp/helpers/fileValidation.d.ts +0 -2
  17. package/dist/mcp/helpers/fileValidation.d.ts.map +1 -1
  18. package/dist/mcp/helpers/fileValidation.js +44 -82
  19. package/dist/mcp/helpers/fileValidation.js.map +1 -1
  20. package/dist/mcp/tools/collection/create.d.ts.map +1 -1
  21. package/dist/mcp/tools/collection/create.js +2 -25
  22. package/dist/mcp/tools/collection/create.js.map +1 -1
  23. package/dist/mcp/tools/collection/delete.d.ts.map +1 -1
  24. package/dist/mcp/tools/collection/delete.js +1 -12
  25. package/dist/mcp/tools/collection/delete.js.map +1 -1
  26. package/dist/mcp/tools/config/update.d.ts +1 -1
  27. package/dist/mcp/tools/config/update.d.ts.map +1 -1
  28. package/dist/mcp/tools/config/update.js +3 -3
  29. package/dist/mcp/tools/config/update.js.map +1 -1
  30. package/dist/mcp/tools/global/update.d.ts.map +1 -1
  31. package/dist/mcp/tools/global/update.js +3 -0
  32. package/dist/mcp/tools/global/update.js.map +1 -1
  33. package/dist/mcp/tools/job/create.d.ts.map +1 -1
  34. package/dist/mcp/tools/job/create.js +3 -6
  35. package/dist/mcp/tools/job/create.js.map +1 -1
  36. package/dist/mcp/tools/job/run.d.ts +1 -1
  37. package/dist/mcp/tools/job/run.d.ts.map +1 -1
  38. package/dist/mcp/tools/job/run.js +5 -26
  39. package/dist/mcp/tools/job/run.js.map +1 -1
  40. package/dist/mcp/tools/job/update.d.ts.map +1 -1
  41. package/dist/mcp/tools/job/update.js +10 -38
  42. package/dist/mcp/tools/job/update.js.map +1 -1
  43. package/dist/mcp/tools/resource/create.d.ts.map +1 -1
  44. package/dist/mcp/tools/resource/create.js +3 -0
  45. package/dist/mcp/tools/resource/create.js.map +1 -1
  46. package/dist/mcp/tools/resource/update.d.ts.map +1 -1
  47. package/dist/mcp/tools/resource/update.js +3 -0
  48. package/dist/mcp/tools/resource/update.js.map +1 -1
  49. package/dist/mcp/tools/schemas.d.ts +2 -5
  50. package/dist/mcp/tools/schemas.d.ts.map +1 -1
  51. package/dist/mcp/tools/schemas.js +0 -1
  52. package/dist/mcp/tools/schemas.js.map +1 -1
  53. package/dist/utils/getVirtualFieldNames.d.ts +14 -0
  54. package/dist/utils/getVirtualFieldNames.d.ts.map +1 -0
  55. package/dist/utils/getVirtualFieldNames.js +35 -0
  56. package/dist/utils/getVirtualFieldNames.js.map +1 -0
  57. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.d.ts.map +1 -1
  58. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js +1 -2
  59. package/dist/utils/schemaConversion/convertCollectionSchemaToZod.js.map +1 -1
  60. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +7 -0
  61. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +1 -0
  62. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +20 -0
  63. package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +1 -0
  64. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts +5 -0
  65. package/dist/utils/schemaConversion/sanitizeJsonSchema.d.ts.map +1 -1
  66. package/dist/utils/schemaConversion/sanitizeJsonSchema.js +38 -0
  67. package/dist/utils/schemaConversion/sanitizeJsonSchema.js.map +1 -1
  68. package/package.json +4 -4
  69. package/src/index.ts +0 -1
  70. package/src/mcp/getMcpHandler.ts +22 -2
  71. package/src/mcp/helpers/config.ts +1 -114
  72. package/src/mcp/helpers/fields.ts +46 -50
  73. package/src/mcp/helpers/fileValidation.ts +38 -93
  74. package/src/mcp/tools/collection/create.ts +2 -30
  75. package/src/mcp/tools/collection/delete.ts +1 -19
  76. package/src/mcp/tools/config/update.ts +0 -4
  77. package/src/mcp/tools/global/update.ts +8 -0
  78. package/src/mcp/tools/job/create.ts +5 -11
  79. package/src/mcp/tools/job/run.ts +14 -38
  80. package/src/mcp/tools/job/update.ts +29 -77
  81. package/src/mcp/tools/resource/create.ts +7 -0
  82. package/src/mcp/tools/resource/update.ts +7 -0
  83. package/src/mcp/tools/schemas.ts +0 -1
  84. package/src/utils/getVirtualFieldNames.ts +53 -0
  85. package/src/utils/schemaConversion/convertCollectionSchemaToZod.ts +1 -3
  86. package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +27 -0
  87. package/src/utils/schemaConversion/sanitizeJsonSchema.ts +41 -0
  88. package/dist/mcp/helpers/conversion.d.ts +0 -2
  89. package/dist/mcp/helpers/conversion.d.ts.map +0 -1
  90. package/dist/mcp/helpers/conversion.js +0 -5
  91. package/dist/mcp/helpers/conversion.js.map +0 -1
  92. package/dist/mcp/helpers/validation.d.ts +0 -9
  93. package/dist/mcp/helpers/validation.d.ts.map +0 -1
  94. package/dist/mcp/helpers/validation.js +0 -22
  95. package/dist/mcp/helpers/validation.js.map +0 -1
  96. package/src/mcp/helpers/conversion.ts +0 -3
  97. package/src/mcp/helpers/validation.ts +0 -32
@@ -6,6 +6,7 @@ import { join } from 'path'
6
6
 
7
7
  import type { JobConfigUpdate, SchemaField, TaskSequenceItem } from '../../../types.js'
8
8
 
9
+ import { toCamelCase } from '../../../utils/camelCase.js'
9
10
  import { validatePayloadFile } from '../../helpers/fileValidation.js'
10
11
  import { toolSchemas } from '../schemas.js'
11
12
 
@@ -199,40 +200,33 @@ export const updateJob = async (
199
200
  }
200
201
  }
201
202
 
202
- // Helper function to convert to camel case
203
- function toCamelCase(str: string): string {
204
- return str
205
- .replace(/[-_\s]+(.)?/g, (_, chr) => (chr ? chr.toUpperCase() : ''))
206
- .replace(/^(.)/, (_, chr) => chr.toLowerCase())
207
- }
208
-
209
203
  // Helper functions for different update types
210
204
  function updateSchema(
211
205
  content: string,
212
- camelCaseJobSlug: string,
213
- inputSchema?: SchemaField[],
214
- outputSchema?: SchemaField[],
206
+ _camelCaseJobSlug: string,
207
+ _inputSchema?: SchemaField[],
208
+ _outputSchema?: SchemaField[],
215
209
  ): string {
216
210
  // TODO: Implementation for schema updates
217
- // This would modify the inputSchema and outputSchema in the job file
218
211
  return content
219
212
  }
220
213
 
221
- function updateWorkflowTasks(content: string, taskSequence: TaskSequenceItem[]): string {
214
+ function updateWorkflowTasks(content: string, _taskSequence: TaskSequenceItem[]): string {
222
215
  // TODO: Implementation for updating workflow tasks
223
- // This would modify the steps array in the workflow
224
216
  return content
225
217
  }
226
218
 
227
- function updateConfig(content: string, jobSlug: string, configUpdate: JobConfigUpdate): string {
219
+ function updateConfig(content: string, _jobSlug: string, _configUpdate: JobConfigUpdate): string {
228
220
  // TODO: Implementation for updating job configuration
229
- // This would modify various config properties
230
221
  return content
231
222
  }
232
223
 
233
- function updateHandler(content: string, handlerCode: string, jobType: 'task' | 'workflow'): string {
224
+ function updateHandler(
225
+ content: string,
226
+ _handlerCode: string,
227
+ _jobType: 'task' | 'workflow',
228
+ ): string {
234
229
  // TODO: Implementation for replacing handler code
235
- // This would replace the handler function in the job file
236
230
  return content
237
231
  }
238
232
 
@@ -242,55 +236,6 @@ export const updateJobTool = (
242
236
  verboseLogs: boolean,
243
237
  jobsDir: string,
244
238
  ) => {
245
- const tool = async (
246
- jobSlug: string,
247
- updateType: string,
248
- inputSchema?: SchemaField[],
249
- outputSchema?: SchemaField[],
250
- taskSequence?: TaskSequenceItem[],
251
- configUpdate?: JobConfigUpdate,
252
- handlerCode?: string,
253
- ) => {
254
- if (verboseLogs) {
255
- req.payload.logger.info(
256
- `[payload-mcp] Update Job Tool called with: ${jobSlug}, ${updateType}`,
257
- )
258
- }
259
-
260
- try {
261
- const result = await updateJob(
262
- req,
263
- verboseLogs,
264
- jobsDir,
265
- jobSlug,
266
- updateType,
267
- inputSchema,
268
- outputSchema,
269
- taskSequence,
270
- configUpdate,
271
- handlerCode,
272
- )
273
-
274
- if (verboseLogs) {
275
- req.payload.logger.info(`[payload-mcp] Update Job Tool completed successfully`)
276
- }
277
-
278
- return result
279
- } catch (error) {
280
- const errorMessage = error instanceof Error ? error.message : 'Unknown error'
281
- req.payload.logger.error(`[payload-mcp] Error in Update Job Tool: ${errorMessage}`)
282
-
283
- return {
284
- content: [
285
- {
286
- type: 'text' as const,
287
- text: `❌ **Error in Update Job Tool**: ${errorMessage}`,
288
- },
289
- ],
290
- }
291
- }
292
- }
293
-
294
239
  server.registerTool(
295
240
  'updateJob',
296
241
  {
@@ -298,17 +243,24 @@ export const updateJobTool = (
298
243
  'Updates an existing Payload job with new configuration, schema, or handler code',
299
244
  inputSchema: toolSchemas.updateJob.parameters.shape,
300
245
  },
301
- async (args) => {
302
- const {
303
- configUpdate,
304
- handlerCode,
305
- inputSchema,
306
- jobSlug,
307
- outputSchema,
308
- taskSequence,
309
- updateType,
310
- } = args
311
- return await tool(
246
+ async ({
247
+ configUpdate,
248
+ handlerCode,
249
+ inputSchema,
250
+ jobSlug,
251
+ outputSchema,
252
+ taskSequence,
253
+ updateType,
254
+ }) => {
255
+ if (verboseLogs) {
256
+ req.payload.logger.info(
257
+ `[payload-mcp] Update Job Tool called with: ${jobSlug}, ${updateType}`,
258
+ )
259
+ }
260
+ return updateJob(
261
+ req,
262
+ verboseLogs,
263
+ jobsDir,
312
264
  jobSlug,
313
265
  updateType,
314
266
  inputSchema as unknown as SchemaField[],
@@ -7,6 +7,10 @@ import { z } from 'zod'
7
7
  import type { PluginMCPServerConfig } from '../../../types.js'
8
8
 
9
9
  import { toCamelCase } from '../../../utils/camelCase.js'
10
+ import {
11
+ getCollectionVirtualFieldNames,
12
+ stripVirtualFields,
13
+ } from '../../../utils/getVirtualFieldNames.js'
10
14
  import { convertCollectionSchemaToZod } from '../../../utils/schemaConversion/convertCollectionSchemaToZod.js'
11
15
  import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
12
16
  import { toolSchemas } from '../schemas.js'
@@ -49,6 +53,9 @@ export const createResourceTool = (
49
53
  // Transform point fields from object format to tuple array
50
54
  parsedData = transformPointDataToPayload(parsedData)
51
55
 
56
+ const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)
57
+ parsedData = stripVirtualFields(parsedData, virtualFieldNames)
58
+
52
59
  if (verboseLogs) {
53
60
  payload.logger.info(
54
61
  `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,
@@ -7,6 +7,10 @@ import { z } from 'zod'
7
7
  import type { PluginMCPServerConfig } from '../../../types.js'
8
8
 
9
9
  import { toCamelCase } from '../../../utils/camelCase.js'
10
+ import {
11
+ getCollectionVirtualFieldNames,
12
+ stripVirtualFields,
13
+ } from '../../../utils/getVirtualFieldNames.js'
10
14
  import { convertCollectionSchemaToZod } from '../../../utils/schemaConversion/convertCollectionSchemaToZod.js'
11
15
  import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js'
12
16
  import { toolSchemas } from '../schemas.js'
@@ -54,6 +58,9 @@ export const updateResourceTool = (
54
58
  // Transform point fields from object format to tuple array
55
59
  parsedData = transformPointDataToPayload(parsedData)
56
60
 
61
+ const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, collectionSlug)
62
+ parsedData = stripVirtualFields(parsedData, virtualFieldNames)
63
+
57
64
  if (verboseLogs) {
58
65
  payload.logger.info(
59
66
  `[payload-mcp] Parsed data for ${collectionSlug}: ${JSON.stringify(parsedData)}`,
@@ -350,7 +350,6 @@ export const toolSchemas = {
350
350
  .any()
351
351
  .optional()
352
352
  .describe('Database configuration updates (for update_database type)'),
353
- generalConfig: z.any().optional().describe('General configuration updates'),
354
353
  newContent: z
355
354
  .string()
356
355
  .optional()
@@ -0,0 +1,53 @@
1
+ import type { SanitizedConfig } from 'payload'
2
+
3
+ import { fieldIsVirtual } from 'payload/shared'
4
+
5
+ /**
6
+ * Returns the names of all top-level virtual fields for a given collection slug.
7
+ */
8
+ export function getCollectionVirtualFieldNames(config: SanitizedConfig, slug: string): string[] {
9
+ const collection = config.collections.find((c) => c.slug === slug)
10
+
11
+ if (!collection) {
12
+ return []
13
+ }
14
+
15
+ return collection.flattenedFields
16
+ .filter((field) => 'name' in field && fieldIsVirtual(field))
17
+ .map((field) => (field as { name: string }).name)
18
+ }
19
+
20
+ /**
21
+ * Returns the names of all top-level virtual fields for a given global slug.
22
+ */
23
+ export function getGlobalVirtualFieldNames(config: SanitizedConfig, slug: string): string[] {
24
+ const global = config.globals.find((g) => g.slug === slug)
25
+
26
+ if (!global) {
27
+ return []
28
+ }
29
+
30
+ return global.flattenedFields
31
+ .filter((field) => 'name' in field && fieldIsVirtual(field))
32
+ .map((field) => (field as { name: string }).name)
33
+ }
34
+
35
+ /**
36
+ * Strips virtual field values from a data object given a list of virtual field names.
37
+ */
38
+ export function stripVirtualFields(
39
+ data: Record<string, unknown>,
40
+ virtualFieldNames: string[],
41
+ ): Record<string, unknown> {
42
+ if (virtualFieldNames.length === 0) {
43
+ return data
44
+ }
45
+
46
+ const stripped = { ...data }
47
+
48
+ for (const name of virtualFieldNames) {
49
+ delete stripped[name]
50
+ }
51
+
52
+ return stripped
53
+ }
@@ -14,9 +14,7 @@ export const convertCollectionSchemaToZod = (schema: JSONSchema4) => {
14
14
 
15
15
  const sanitized = sanitizeJsonSchema(schemaClone)
16
16
  const pointTransformed = transformPointFieldsForMCP(sanitized)
17
- const simplifiedSchema = simplifyRelationshipFields(pointTransformed)
18
-
19
- const zodSchemaAsString = jsonSchemaToZod(simplifiedSchema)
17
+ const zodSchemaAsString = jsonSchemaToZod(simplifyRelationshipFields(pointTransformed))
20
18
 
21
19
  // Transpile TypeScript to JavaScript
22
20
  const transpileResult = ts.transpileModule(zodSchemaAsString, {
@@ -0,0 +1,27 @@
1
+ import type { JSONSchema4 } from 'json-schema'
2
+
3
+ /**
4
+ * Removes virtual fields from a JSON Schema by name so they don't appear
5
+ * in the generated MCP tool input schema.
6
+ */
7
+ export function removeVirtualFieldsFromSchema(
8
+ schema: JSONSchema4,
9
+ virtualFieldNames: string[],
10
+ ): JSONSchema4 {
11
+ if (virtualFieldNames.length === 0) {
12
+ return schema
13
+ }
14
+
15
+ for (const name of virtualFieldNames) {
16
+ delete schema?.properties?.[name]
17
+ }
18
+
19
+ if (Array.isArray(schema.required)) {
20
+ schema.required = schema.required.filter((field) => !virtualFieldNames.includes(field))
21
+ if (schema.required.length === 0) {
22
+ delete schema.required
23
+ }
24
+ }
25
+
26
+ return schema
27
+ }
@@ -4,6 +4,11 @@ import type { JSONSchema4 } from 'json-schema'
4
4
  * Removes internal Payload properties (id, createdAt, updatedAt) from a
5
5
  * JSON Schema so they don't appear in the generated Zod validation schema.
6
6
  * Also strips `id` from the `required` array when present.
7
+ *
8
+ * Additionally normalizes nullable type arrays (e.g. `['array', 'null']` →
9
+ * `'array'`) throughout the schema tree. Without this, `json-schema-to-zod`
10
+ * emits a Zod union which the MCP SDK serialises back as `anyOf`, stripping
11
+ * the concrete `type` from the output and breaking schema introspection.
7
12
  */
8
13
  export function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4 {
9
14
  delete schema?.properties?.id
@@ -17,5 +22,41 @@ export function sanitizeJsonSchema(schema: JSONSchema4): JSONSchema4 {
17
22
  }
18
23
  }
19
24
 
25
+ if (schema.properties && typeof schema.properties === 'object') {
26
+ for (const key of Object.keys(schema.properties)) {
27
+ const prop = schema.properties[key] as JSONSchema4
28
+ if (!prop || typeof prop !== 'object') {
29
+ continue
30
+ }
31
+ normalizeNullableType(prop)
32
+ if (prop.properties) {
33
+ sanitizeJsonSchema(prop)
34
+ }
35
+ if (prop.items && typeof prop.items === 'object' && !Array.isArray(prop.items)) {
36
+ sanitizeJsonSchema(prop.items)
37
+ }
38
+ }
39
+ }
40
+
20
41
  return schema
21
42
  }
43
+
44
+ /**
45
+ * Strips `'null'` from a `type` array only when the remaining type is a
46
+ * complex structural type (`array` or `object`).
47
+ *
48
+ * Simple scalar types (`string`, `number`, `boolean`) are intentionally
49
+ * preserved as `['string', 'null']` so that the MCP SDK serialises them as a
50
+ * compact inline `type` array. Complex types however cause `zodToJsonSchema`
51
+ * to emit `anyOf: [{ type: 'array', items: ... }, { type: 'null' }]`, which
52
+ * has no top-level `type` property and breaks schema introspection by clients.
53
+ */
54
+ function normalizeNullableType(schema: JSONSchema4): void {
55
+ if (!Array.isArray(schema.type)) {
56
+ return
57
+ }
58
+ const nonNullTypes = schema.type.filter((t) => t !== 'null')
59
+ if (nonNullTypes.length === 1 && (nonNullTypes[0] === 'array' || nonNullTypes[0] === 'object')) {
60
+ schema.type = nonNullTypes[0]
61
+ }
62
+ }
@@ -1,2 +0,0 @@
1
- export declare const toCamelCase: (str: string) => string;
2
- //# sourceMappingURL=conversion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversion.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/conversion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,MAEzC,CAAA"}
@@ -1,5 +0,0 @@
1
- export const toCamelCase = (str)=>{
2
- return str.replace(/-([a-z])/g, (match, letter)=>letter.toUpperCase());
3
- };
4
-
5
- //# sourceMappingURL=conversion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/mcp/helpers/conversion.ts"],"sourcesContent":["export const toCamelCase = (str: string): string => {\n return str.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase())\n}\n"],"names":["toCamelCase","str","replace","match","letter","toUpperCase"],"mappings":"AAAA,OAAO,MAAMA,cAAc,CAACC;IAC1B,OAAOA,IAAIC,OAAO,CAAC,aAAa,CAACC,OAAOC,SAAWA,OAAOC,WAAW;AACvE,EAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Validates collection-specific data for resource creation
3
- */
4
- export declare function validateCollectionData(collection: string, data: Record<string, unknown>, availableCollections: string[]): null | string;
5
- /**
6
- * Checks if a collection slug is valid
7
- */
8
- export declare function validateCollectionSlug(collection: string, collections: Partial<Record<string, true>>): string | undefined;
9
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/mcp/helpers/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,oBAAoB,EAAE,MAAM,EAAE,GAC7B,IAAI,GAAG,MAAM,CAWf;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,sBAM3C"}
@@ -1,22 +0,0 @@
1
- /**
2
- * Validates collection-specific data for resource creation
3
- */ export function validateCollectionData(collection, data, availableCollections) {
4
- // Check if collection exists
5
- if (!availableCollections.includes(collection)) {
6
- return `Unknown collection: ${collection}. Available collections: ${availableCollections.join(', ')}`;
7
- }
8
- if (!data || typeof data !== 'object' || Object.keys(data).length === 0) {
9
- return `Collection "${collection}" requires data to be provided`;
10
- }
11
- return null;
12
- }
13
- /**
14
- * Checks if a collection slug is valid
15
- */ export function validateCollectionSlug(collection, collections) {
16
- const collectionSlugs = Object.keys(collections);
17
- if (!collectionSlugs.includes(collection)) {
18
- return `Collection "${collection}" is not valid`;
19
- }
20
- }
21
-
22
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/mcp/helpers/validation.ts"],"sourcesContent":["/**\n * Validates collection-specific data for resource creation\n */\nexport function validateCollectionData(\n collection: string,\n data: Record<string, unknown>,\n availableCollections: string[],\n): null | string {\n // Check if collection exists\n if (!availableCollections.includes(collection)) {\n return `Unknown collection: ${collection}. Available collections: ${availableCollections.join(', ')}`\n }\n\n if (!data || typeof data !== 'object' || Object.keys(data).length === 0) {\n return `Collection \"${collection}\" requires data to be provided`\n }\n\n return null\n}\n\n/**\n * Checks if a collection slug is valid\n */\nexport function validateCollectionSlug(\n collection: string,\n collections: Partial<Record<string, true>>,\n) {\n const collectionSlugs = Object.keys(collections)\n if (!collectionSlugs.includes(collection)) {\n return `Collection \"${collection}\" is not valid`\n }\n}\n"],"names":["validateCollectionData","collection","data","availableCollections","includes","join","Object","keys","length","validateCollectionSlug","collections","collectionSlugs"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,uBACdC,UAAkB,EAClBC,IAA6B,EAC7BC,oBAA8B;IAE9B,6BAA6B;IAC7B,IAAI,CAACA,qBAAqBC,QAAQ,CAACH,aAAa;QAC9C,OAAO,CAAC,oBAAoB,EAAEA,WAAW,yBAAyB,EAAEE,qBAAqBE,IAAI,CAAC,OAAO;IACvG;IAEA,IAAI,CAACH,QAAQ,OAAOA,SAAS,YAAYI,OAAOC,IAAI,CAACL,MAAMM,MAAM,KAAK,GAAG;QACvE,OAAO,CAAC,YAAY,EAAEP,WAAW,8BAA8B,CAAC;IAClE;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASQ,uBACdR,UAAkB,EAClBS,WAA0C;IAE1C,MAAMC,kBAAkBL,OAAOC,IAAI,CAACG;IACpC,IAAI,CAACC,gBAAgBP,QAAQ,CAACH,aAAa;QACzC,OAAO,CAAC,YAAY,EAAEA,WAAW,cAAc,CAAC;IAClD;AACF"}
@@ -1,3 +0,0 @@
1
- export const toCamelCase = (str: string): string => {
2
- return str.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase())
3
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Validates collection-specific data for resource creation
3
- */
4
- export function validateCollectionData(
5
- collection: string,
6
- data: Record<string, unknown>,
7
- availableCollections: string[],
8
- ): null | string {
9
- // Check if collection exists
10
- if (!availableCollections.includes(collection)) {
11
- return `Unknown collection: ${collection}. Available collections: ${availableCollections.join(', ')}`
12
- }
13
-
14
- if (!data || typeof data !== 'object' || Object.keys(data).length === 0) {
15
- return `Collection "${collection}" requires data to be provided`
16
- }
17
-
18
- return null
19
- }
20
-
21
- /**
22
- * Checks if a collection slug is valid
23
- */
24
- export function validateCollectionSlug(
25
- collection: string,
26
- collections: Partial<Record<string, true>>,
27
- ) {
28
- const collectionSlugs = Object.keys(collections)
29
- if (!collectionSlugs.includes(collection)) {
30
- return `Collection "${collection}" is not valid`
31
- }
32
- }