@payloadcms/plugin-mcp 4.0.0-internal.bc5cf8c → 4.0.0-internal.bf4bcce
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/LICENSE.md +1 -1
- package/dist/defaultAccess.d.ts.map +1 -1
- package/dist/defineTool.d.ts +8 -8
- package/dist/defineTool.d.ts.map +1 -1
- package/dist/endpoint/access.d.ts +2 -7
- package/dist/endpoint/access.d.ts.map +1 -1
- package/dist/endpoint/access.js +17 -14
- package/dist/endpoint/access.js.map +1 -1
- package/dist/endpoint/index.d.ts +1 -1
- package/dist/endpoint/index.d.ts.map +1 -1
- package/dist/endpoint/index.js +91 -16
- package/dist/endpoint/index.js.map +1 -1
- package/dist/endpoint/oauth.d.ts +27 -0
- package/dist/endpoint/oauth.d.ts.map +1 -0
- package/dist/endpoint/oauth.js +61 -0
- package/dist/endpoint/oauth.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +6 -6
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +68 -34
- package/dist/mcp/buildMcpServer.js.map +1 -1
- package/dist/mcp/builtin/collections/authTools.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/authTools.js +80 -56
- package/dist/mcp/builtin/collections/authTools.js.map +1 -1
- package/dist/mcp/builtin/collections/countTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/countTool.js +10 -16
- package/dist/mcp/builtin/collections/countTool.js.map +1 -1
- package/dist/mcp/builtin/collections/countVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/countVersionsTool.js +10 -15
- package/dist/mcp/builtin/collections/countVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts +1 -1
- package/dist/mcp/builtin/collections/createTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/createTool.js +104 -54
- package/dist/mcp/builtin/collections/createTool.js.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/deleteTool.js +45 -45
- package/dist/mcp/builtin/collections/deleteTool.js.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/duplicateTool.js +32 -39
- package/dist/mcp/builtin/collections/duplicateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/fileInput.d.ts +28 -0
- package/dist/mcp/builtin/collections/fileInput.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/fileInput.js +88 -0
- package/dist/mcp/builtin/collections/fileInput.js.map +1 -0
- package/dist/mcp/builtin/collections/findDistinctTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findDistinctTool.js +12 -28
- package/dist/mcp/builtin/collections/findDistinctTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findTool.js +29 -48
- package/dist/mcp/builtin/collections/findTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findVersionByIDTool.js +18 -28
- package/dist/mcp/builtin/collections/findVersionByIDTool.js.map +1 -1
- package/dist/mcp/builtin/collections/findVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/findVersionsTool.js +17 -32
- package/dist/mcp/builtin/collections/findVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js +68 -12
- package/dist/mcp/builtin/collections/getCollectionSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/restoreVersionTool.js +15 -28
- package/dist/mcp/builtin/collections/restoreVersionTool.js.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/collections/updateTool.js +67 -87
- package/dist/mcp/builtin/collections/updateTool.js.map +1 -1
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts +2 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.d.ts.map +1 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js +55 -0
- package/dist/mcp/builtin/collections/uploadInstructionsTool.js.map +1 -0
- package/dist/mcp/builtin/formatEntityError.d.ts +16 -0
- package/dist/mcp/builtin/formatEntityError.d.ts.map +1 -0
- package/dist/mcp/builtin/formatEntityError.js +55 -0
- package/dist/mcp/builtin/formatEntityError.js.map +1 -0
- package/dist/mcp/builtin/getConfigInfoTool.d.ts.map +1 -1
- package/dist/mcp/builtin/getConfigInfoTool.js +5 -7
- package/dist/mcp/builtin/getConfigInfoTool.js.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/countVersionsTool.js +10 -15
- package/dist/mcp/builtin/globals/countVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findTool.js +12 -18
- package/dist/mcp/builtin/globals/findTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findVersionByIDTool.js +14 -26
- package/dist/mcp/builtin/globals/findVersionByIDTool.js.map +1 -1
- package/dist/mcp/builtin/globals/findVersionsTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/findVersionsTool.js +14 -31
- package/dist/mcp/builtin/globals/findVersionsTool.js.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js +46 -12
- package/dist/mcp/builtin/globals/getGlobalSchemaTool.js.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/restoreVersionTool.js +16 -24
- package/dist/mcp/builtin/globals/restoreVersionTool.js.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.d.ts.map +1 -1
- package/dist/mcp/builtin/globals/updateTool.js +28 -37
- package/dist/mcp/builtin/globals/updateTool.js.map +1 -1
- package/dist/mcp/builtinTools.d.ts +6 -0
- package/dist/mcp/builtinTools.d.ts.map +1 -1
- package/dist/mcp/builtinTools.js +9 -3
- package/dist/mcp/builtinTools.js.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.d.ts.map +1 -1
- package/dist/mcp/sanitizeMCPConfig.js +6 -1
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts +3 -4
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +65 -45
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +94 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/camelCase.d.ts.map +1 -1
- package/dist/utils/resolveProjectRoot.d.ts.map +1 -1
- package/dist/utils/toStandardSchema.d.ts.map +1 -1
- package/package.json +9 -13
- package/src/endpoint/access.ts +14 -14
- package/src/endpoint/index.ts +79 -14
- package/src/endpoint/oauth.ts +72 -0
- package/src/index.ts +11 -4
- package/src/mcp/buildMcpServer.ts +80 -50
- package/src/mcp/builtin/collections/authTools.ts +80 -69
- package/src/mcp/builtin/collections/countTool.ts +10 -23
- package/src/mcp/builtin/collections/countVersionsTool.ts +10 -20
- package/src/mcp/builtin/collections/createTool.ts +110 -77
- package/src/mcp/builtin/collections/deleteTool.ts +36 -65
- package/src/mcp/builtin/collections/duplicateTool.ts +36 -87
- package/src/mcp/builtin/collections/fileInput.spec.ts +93 -0
- package/src/mcp/builtin/collections/fileInput.ts +127 -0
- package/src/mcp/builtin/collections/findDistinctTool.ts +12 -65
- package/src/mcp/builtin/collections/findTool.ts +25 -108
- package/src/mcp/builtin/collections/findVersionByIDTool.ts +16 -60
- package/src/mcp/builtin/collections/findVersionsTool.ts +15 -87
- package/src/mcp/builtin/collections/getCollectionSchemaTool.ts +60 -15
- package/src/mcp/builtin/collections/restoreVersionTool.ts +15 -58
- package/src/mcp/builtin/collections/updateTool.ts +63 -101
- package/src/mcp/builtin/collections/uploadInstructionsTool.ts +64 -0
- package/src/mcp/builtin/formatEntityError.ts +77 -0
- package/src/mcp/builtin/getConfigInfoTool.ts +4 -5
- package/src/mcp/builtin/globals/countVersionsTool.ts +10 -19
- package/src/mcp/builtin/globals/findTool.ts +14 -53
- package/src/mcp/builtin/globals/findVersionByIDTool.ts +14 -54
- package/src/mcp/builtin/globals/findVersionsTool.ts +15 -94
- package/src/mcp/builtin/globals/getGlobalSchemaTool.ts +41 -9
- package/src/mcp/builtin/globals/restoreVersionTool.ts +15 -47
- package/src/mcp/builtin/globals/updateTool.ts +39 -62
- package/src/mcp/builtinTools.ts +9 -2
- package/src/mcp/sanitizeMCPConfig.ts +6 -1
- package/src/stdio.ts +63 -45
- package/src/types.ts +95 -16
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts +0 -9
- package/dist/mcp/builtin/collections/formatCollectionError.d.ts.map +0 -1
- package/dist/mcp/builtin/collections/formatCollectionError.js +0 -60
- package/dist/mcp/builtin/collections/formatCollectionError.js.map +0 -1
- package/dist/mcp/builtin/validateEntityData.d.ts +0 -14
- package/dist/mcp/builtin/validateEntityData.d.ts.map +0 -1
- package/dist/mcp/builtin/validateEntityData.js +0 -82
- package/dist/mcp/builtin/validateEntityData.js.map +0 -1
- package/dist/utils/getVirtualFieldNames.d.ts +0 -14
- package/dist/utils/getVirtualFieldNames.d.ts.map +0 -1
- package/dist/utils/getVirtualFieldNames.js +0 -35
- package/dist/utils/getVirtualFieldNames.js.map +0 -1
- package/dist/utils/localAPIDefaults.d.ts +0 -20
- package/dist/utils/localAPIDefaults.d.ts.map +0 -1
- package/dist/utils/localAPIDefaults.js +0 -19
- package/dist/utils/localAPIDefaults.js.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts +0 -11
- package/dist/utils/schemaConversion/getEntityInputSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/getEntityInputSchema.js +0 -34
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts +0 -7
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js +0 -20
- package/dist/utils/schemaConversion/removeVirtualFieldsFromSchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -15
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -464
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -158
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js.map +0 -1
- package/dist/utils/transformPointDataToPayload.d.ts +0 -7
- package/dist/utils/transformPointDataToPayload.d.ts.map +0 -1
- package/dist/utils/transformPointDataToPayload.js +0 -28
- package/dist/utils/transformPointDataToPayload.js.map +0 -1
- package/dist/utils/whereSchema.d.ts +0 -9
- package/dist/utils/whereSchema.d.ts.map +0 -1
- package/dist/utils/whereSchema.js +0 -13
- package/dist/utils/whereSchema.js.map +0 -1
- package/src/@types/assets.d.ts +0 -3
- package/src/mcp/builtin/collections/formatCollectionError.ts +0 -84
- package/src/mcp/builtin/validateEntityData.ts +0 -132
- package/src/utils/getVirtualFieldNames.ts +0 -53
- package/src/utils/localAPIDefaults.ts +0 -22
- package/src/utils/schemaConversion/getEntityInputSchema.ts +0 -78
- package/src/utils/schemaConversion/removeVirtualFieldsFromSchema.ts +0 -27
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -103
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -529
- package/src/utils/transformPointDataToPayload.ts +0 -40
- package/src/utils/whereSchema.ts +0 -24
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deleteDocumentsInputSchema, parseDocumentID } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineCollectionTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
|
-
import { whereSchema } from '../../../utils/whereSchema.js';
|
|
7
5
|
const DEFAULT_DESCRIPTION = 'Delete documents in any collection by passing the collection slug and ID or where clause.';
|
|
8
6
|
export const deleteDocumentsTool = defineCollectionTool({
|
|
9
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.delete),
|
|
10
8
|
annotations: {
|
|
11
9
|
destructiveHint: true,
|
|
12
10
|
idempotentHint: false,
|
|
@@ -15,25 +13,44 @@ export const deleteDocumentsTool = defineCollectionTool({
|
|
|
15
13
|
title: 'Delete Documents'
|
|
16
14
|
},
|
|
17
15
|
description: DEFAULT_DESCRIPTION,
|
|
18
|
-
input:
|
|
19
|
-
|
|
20
|
-
z.string(),
|
|
21
|
-
z.number()
|
|
22
|
-
]).describe('Optional: specific document ID to delete').optional(),
|
|
23
|
-
depth: z.number().int().min(0).max(10).describe('Depth of population for relationships in response').optional().default(0),
|
|
24
|
-
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
25
|
-
locale: z.string().describe('Optional: locale code for the operation (e.g., "en", "es"). Defaults to the default locale').optional(),
|
|
26
|
-
where: whereSchema.describe('Optional: where clause to delete multiple documents. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}').optional()
|
|
27
|
-
})
|
|
28
|
-
}).handler(async ({ authorizedMCP, collectionSlug, input, req })=>{
|
|
16
|
+
input: deleteDocumentsInputSchema
|
|
17
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
29
18
|
const payload = req.payload;
|
|
30
19
|
const logger = getLogger({
|
|
31
20
|
payload
|
|
32
21
|
});
|
|
33
22
|
const { id, depth, fallbackLocale, locale, where } = input;
|
|
34
|
-
logger.info(`Deleting document from collection: ${
|
|
23
|
+
logger.info(`Deleting document from collection: ${slug}${id ? ` with ID: ${id}` : ' with where clause'}${locale ? `, locale: ${locale}` : ''}`);
|
|
35
24
|
try {
|
|
36
|
-
if (
|
|
25
|
+
if (id !== undefined) {
|
|
26
|
+
const result = await payload.delete({
|
|
27
|
+
id: parseDocumentID({
|
|
28
|
+
id,
|
|
29
|
+
collectionSlug: slug,
|
|
30
|
+
payload
|
|
31
|
+
}),
|
|
32
|
+
collection: slug,
|
|
33
|
+
depth,
|
|
34
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
35
|
+
req,
|
|
36
|
+
...locale && {
|
|
37
|
+
locale
|
|
38
|
+
},
|
|
39
|
+
...fallbackLocale !== undefined && {
|
|
40
|
+
fallbackLocale
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
text: `Document deleted successfully from collection "${slug}"!\nDeleted document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
doc: result
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (where === undefined) {
|
|
37
54
|
return {
|
|
38
55
|
content: [
|
|
39
56
|
{
|
|
@@ -43,39 +60,22 @@ export const deleteDocumentsTool = defineCollectionTool({
|
|
|
43
60
|
]
|
|
44
61
|
};
|
|
45
62
|
}
|
|
46
|
-
const
|
|
47
|
-
collection:
|
|
63
|
+
const result = await payload.delete({
|
|
64
|
+
collection: slug,
|
|
48
65
|
depth,
|
|
66
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
49
67
|
req,
|
|
50
|
-
|
|
68
|
+
where,
|
|
51
69
|
...locale && {
|
|
52
70
|
locale
|
|
53
71
|
},
|
|
54
|
-
...fallbackLocale && {
|
|
72
|
+
...fallbackLocale !== undefined && {
|
|
55
73
|
fallbackLocale
|
|
56
74
|
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
deleteOptions.where = where;
|
|
62
|
-
}
|
|
63
|
-
const result = await payload.delete(deleteOptions);
|
|
64
|
-
if (id) {
|
|
65
|
-
return {
|
|
66
|
-
content: [
|
|
67
|
-
{
|
|
68
|
-
type: 'text',
|
|
69
|
-
text: `Document deleted successfully from collection "${collectionSlug}"!\nDeleted document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
doc: result
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
const bulkResult = result;
|
|
76
|
-
const docs = bulkResult.docs || [];
|
|
77
|
-
const errors = bulkResult.errors || [];
|
|
78
|
-
let responseText = `Document deleted successfully from collection "${collectionSlug}"!\nDeleted: ${docs.length} documents\nErrors: ${errors.length}\n---`;
|
|
75
|
+
});
|
|
76
|
+
const docs = result.docs || [];
|
|
77
|
+
const errors = result.errors || [];
|
|
78
|
+
let responseText = `Document deleted successfully from collection "${slug}"!\nDeleted: ${docs.length} documents\nErrors: ${errors.length}\n---`;
|
|
79
79
|
if (docs.length > 0) {
|
|
80
80
|
responseText += `\n\nDeleted documents:\n\`\`\`json\n${JSON.stringify(docs)}\n\`\`\``;
|
|
81
81
|
}
|
|
@@ -96,12 +96,12 @@ export const deleteDocumentsTool = defineCollectionTool({
|
|
|
96
96
|
};
|
|
97
97
|
} catch (error) {
|
|
98
98
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
99
|
-
logger.error(`Error deleting document from ${
|
|
99
|
+
logger.error(`Error deleting document from ${slug}: ${errorMessage}`);
|
|
100
100
|
return {
|
|
101
101
|
content: [
|
|
102
102
|
{
|
|
103
103
|
type: 'text',
|
|
104
|
-
text: `Error deleting document from collection "${
|
|
104
|
+
text: `Error deleting document from collection "${slug}": ${errorMessage}`
|
|
105
105
|
}
|
|
106
106
|
]
|
|
107
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/collections/deleteTool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/deleteTool.ts"],"sourcesContent":["import { deleteDocumentsInputSchema, parseDocumentID } from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Delete documents in any collection by passing the collection slug and ID or where clause.'\n\nexport const deleteDocumentsTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.delete),\n annotations: {\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Delete Documents',\n },\n description: DEFAULT_DESCRIPTION,\n input: deleteDocumentsInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n\n const { id, depth, fallbackLocale, locale, where } = input\n\n logger.info(\n `Deleting document from collection: ${slug}${id ? ` with ID: ${id}` : ' with where clause'}${locale ? `, locale: ${locale}` : ''}`,\n )\n\n try {\n if (id !== undefined) {\n const result = await payload.delete({\n id: parseDocumentID({ id, collectionSlug: slug, payload }),\n collection: slug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(locale && { locale }),\n ...(fallbackLocale !== undefined && { fallbackLocale }),\n })\n\n return {\n content: [\n {\n type: 'text',\n text: `Document deleted successfully from collection \"${slug}\"!\\nDeleted document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n }\n\n if (where === undefined) {\n return {\n content: [{ type: 'text', text: 'Error: Either id or where clause must be provided' }],\n }\n }\n\n const result = await payload.delete({\n collection: slug,\n depth,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n where,\n ...(locale && { locale }),\n ...(fallbackLocale !== undefined && { fallbackLocale }),\n })\n const docs = result.docs || []\n const errors = result.errors || []\n\n let responseText = `Document deleted successfully from collection \"${slug}\"!\\nDeleted: ${docs.length} documents\\nErrors: ${errors.length}\\n---`\n if (docs.length > 0) {\n responseText += `\\n\\nDeleted documents:\\n\\`\\`\\`json\\n${JSON.stringify(docs)}\\n\\`\\`\\``\n }\n if (errors.length > 0) {\n responseText += `\\n\\nErrors:\\n\\`\\`\\`json\\n${JSON.stringify(errors)}\\n\\`\\`\\``\n }\n\n return {\n content: [{ type: 'text', text: responseText }],\n doc: { docs, errors } as unknown as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error deleting document from ${slug}: ${errorMessage}`)\n return {\n content: [\n {\n type: 'text',\n text: `Error deleting document from collection \"${slug}\": ${errorMessage}`,\n },\n ],\n }\n }\n})\n"],"names":["deleteDocumentsInputSchema","parseDocumentID","defaultAccess","defineCollectionTool","getLogger","DEFAULT_DESCRIPTION","deleteDocumentsTool","access","args","Boolean","permissions","collections","slug","delete","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","id","depth","fallbackLocale","locale","where","info","undefined","result","collectionSlug","collection","overrideAccess","content","type","text","JSON","stringify","doc","docs","errors","responseText","length","error","errorMessage","Error","message"],"mappings":"AAAA,SAASA,0BAA0B,EAAEC,eAAe,QAAQ,UAAS;AAErE,SAASC,aAAa,QAAQ,4BAA2B;AACzD,SAASC,oBAAoB,QAAQ,yB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-
{"version":3,"file":"duplicateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/duplicateTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"duplicateTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/duplicateTool.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,qBAAqB,4CAkEhC,CAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { duplicateDocumentInputSchema, getCollectionVirtualFieldNames, parseDocumentID, stripVirtualFields, transformPointDataToPayload, validateCollectionData } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineCollectionTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import {
|
|
6
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
7
|
-
import { transformPointDataToPayload } from '../../../utils/transformPointDataToPayload.js';
|
|
8
|
-
import { formatCollectionError } from './formatCollectionError.js';
|
|
5
|
+
import { formatEntityError } from '../formatEntityError.js';
|
|
9
6
|
const DEFAULT_DESCRIPTION = 'Duplicate a document in any collection by passing the collection slug and source document ID.';
|
|
10
7
|
export const duplicateDocumentTool = defineCollectionTool({
|
|
11
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.
|
|
8
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.create),
|
|
12
9
|
annotations: {
|
|
13
10
|
destructiveHint: false,
|
|
14
11
|
idempotentHint: false,
|
|
@@ -17,77 +14,73 @@ export const duplicateDocumentTool = defineCollectionTool({
|
|
|
17
14
|
title: 'Duplicate Document'
|
|
18
15
|
},
|
|
19
16
|
description: DEFAULT_DESCRIPTION,
|
|
20
|
-
input:
|
|
21
|
-
|
|
22
|
-
z.string(),
|
|
23
|
-
z.number()
|
|
24
|
-
]).describe('The ID of the document to duplicate'),
|
|
25
|
-
data: z.record(z.string(), z.unknown()).describe('Optional: fields to override on the duplicated document').optional(),
|
|
26
|
-
depth: z.number().int().min(0).max(10).describe('How many levels deep to populate relationships in response').optional().default(0),
|
|
27
|
-
draft: z.boolean().describe('Whether to create the duplicate as a draft').optional().default(false),
|
|
28
|
-
fallbackLocale: z.string().describe('Optional: fallback locale code to use when requested locale is not available').optional(),
|
|
29
|
-
locale: z.string().describe('Optional: locale code to duplicate in (e.g., "en", "es"). Defaults to the default locale').optional(),
|
|
30
|
-
populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
|
|
31
|
-
select: z.record(z.string(), z.unknown()).describe('Optional: define exactly which fields you\'d like to return in the response, e.g., {"title": true}').optional(),
|
|
32
|
-
selectedLocales: z.array(z.string()).describe('Optional: localized field locales to include in the duplicated document').optional(),
|
|
33
|
-
showHiddenFields: z.boolean().describe('Optional: include hidden fields in the duplicated document response').optional()
|
|
34
|
-
})
|
|
35
|
-
}).handler(async ({ authorizedMCP, collectionSlug, input, req })=>{
|
|
17
|
+
input: duplicateDocumentInputSchema
|
|
18
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
36
19
|
const payload = req.payload;
|
|
37
20
|
const logger = getLogger({
|
|
38
21
|
payload
|
|
39
22
|
});
|
|
40
|
-
const { id, data, depth, draft, fallbackLocale, locale, populate, select, selectedLocales
|
|
41
|
-
logger.info(`Duplicating document in collection: ${
|
|
23
|
+
const { id, data, depth, draft, fallbackLocale, locale, populate, select, selectedLocales } = input;
|
|
24
|
+
logger.info(`Duplicating document in collection: ${slug} with ID: ${id}`);
|
|
42
25
|
try {
|
|
43
|
-
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config,
|
|
26
|
+
const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, slug);
|
|
44
27
|
const inputData = data ? stripVirtualFields(data, virtualFieldNames) : undefined;
|
|
28
|
+
if (inputData) {
|
|
29
|
+
validateCollectionData({
|
|
30
|
+
slug,
|
|
31
|
+
data: inputData,
|
|
32
|
+
partial: true,
|
|
33
|
+
req
|
|
34
|
+
});
|
|
35
|
+
}
|
|
45
36
|
const parsedData = inputData ? transformPointDataToPayload(inputData) : undefined;
|
|
46
37
|
const result = await payload.duplicate({
|
|
47
|
-
id
|
|
48
|
-
|
|
38
|
+
id: parseDocumentID({
|
|
39
|
+
id,
|
|
40
|
+
collectionSlug: slug,
|
|
41
|
+
payload
|
|
42
|
+
}),
|
|
43
|
+
collection: slug,
|
|
49
44
|
depth,
|
|
50
45
|
draft,
|
|
46
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
51
47
|
req,
|
|
52
|
-
...localAPIDefaults(authorizedMCP),
|
|
53
48
|
...parsedData ? {
|
|
54
49
|
data: parsedData
|
|
55
50
|
} : {},
|
|
56
51
|
...locale ? {
|
|
57
52
|
locale
|
|
58
53
|
} : {},
|
|
59
|
-
...fallbackLocale ? {
|
|
54
|
+
...fallbackLocale !== undefined ? {
|
|
60
55
|
fallbackLocale
|
|
61
56
|
} : {},
|
|
62
57
|
...populate ? {
|
|
63
|
-
populate
|
|
58
|
+
populate
|
|
64
59
|
} : {},
|
|
65
60
|
...select ? {
|
|
66
|
-
select
|
|
61
|
+
select
|
|
67
62
|
} : {},
|
|
68
63
|
...selectedLocales ? {
|
|
69
64
|
selectedLocales
|
|
70
|
-
} : {},
|
|
71
|
-
...showHiddenFields !== undefined ? {
|
|
72
|
-
showHiddenFields
|
|
73
65
|
} : {}
|
|
74
66
|
});
|
|
75
|
-
logger.info(`Successfully duplicated document in ${
|
|
67
|
+
logger.info(`Successfully duplicated document in ${slug} from ID: ${id}`);
|
|
76
68
|
return {
|
|
77
69
|
content: [
|
|
78
70
|
{
|
|
79
71
|
type: 'text',
|
|
80
|
-
text: `Document duplicated successfully in collection "${
|
|
72
|
+
text: `Document duplicated successfully in collection "${slug}"!\nDuplicated document:\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
81
73
|
}
|
|
82
74
|
],
|
|
83
75
|
doc: result
|
|
84
76
|
};
|
|
85
77
|
} catch (error) {
|
|
86
78
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
87
|
-
logger.error(`Error duplicating document in ${
|
|
88
|
-
return
|
|
79
|
+
logger.error(`Error duplicating document in ${slug}: ${errorMessage}`);
|
|
80
|
+
return formatEntityError({
|
|
81
|
+
slug,
|
|
89
82
|
action: 'duplicating',
|
|
90
|
-
|
|
83
|
+
entity: 'collection',
|
|
91
84
|
error,
|
|
92
85
|
req
|
|
93
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/mcp/builtin/collections/duplicateTool.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/duplicateTool.ts"],"sourcesContent":["import {\n duplicateDocumentInputSchema,\n getCollectionVirtualFieldNames,\n parseDocumentID,\n stripVirtualFields,\n transformPointDataToPayload,\n validateCollectionData,\n} from 'payload'\n\nimport { defaultAccess } from '../../../defaultAccess.js'\nimport { defineCollectionTool } from '../../../defineTool.js'\nimport { getLogger } from '../../../utils/getLogger.js'\nimport { formatEntityError } from '../formatEntityError.js'\n\nconst DEFAULT_DESCRIPTION =\n 'Duplicate a document in any collection by passing the collection slug and source document ID.'\n\nexport const duplicateDocumentTool = defineCollectionTool({\n access: (args) =>\n defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.create),\n annotations: {\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: false,\n readOnlyHint: false,\n title: 'Duplicate Document',\n },\n description: DEFAULT_DESCRIPTION,\n input: duplicateDocumentInputSchema,\n}).handler(async ({ slug, authorizedMCP, input, req }) => {\n const payload = req.payload\n const logger = getLogger({ payload })\n const { id, data, depth, draft, fallbackLocale, locale, populate, select, selectedLocales } =\n input\n\n logger.info(`Duplicating document in collection: ${slug} with ID: ${id}`)\n\n try {\n const virtualFieldNames = getCollectionVirtualFieldNames(payload.config, slug)\n const inputData = data ? stripVirtualFields(data, virtualFieldNames) : undefined\n\n if (inputData) {\n validateCollectionData({\n slug,\n data: inputData,\n partial: true,\n req,\n })\n }\n\n const parsedData = inputData ? transformPointDataToPayload(inputData) : undefined\n\n const result = await payload.duplicate({\n id: parseDocumentID({ id, collectionSlug: slug, payload }),\n collection: slug,\n depth,\n draft,\n overrideAccess: authorizedMCP.overrideAccess,\n req,\n ...(parsedData ? { data: parsedData } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n ...(populate ? { populate } : {}),\n ...(select ? { select } : {}),\n ...(selectedLocales ? { selectedLocales } : {}),\n })\n\n logger.info(`Successfully duplicated document in ${slug} from ID: ${id}`)\n\n return {\n content: [\n {\n type: 'text',\n text: `Document duplicated successfully in collection \"${slug}\"!\\nDuplicated document:\\n\\`\\`\\`json\\n${JSON.stringify(result)}\\n\\`\\`\\``,\n },\n ],\n doc: result as Record<string, unknown>,\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Unknown error'\n logger.error(`Error duplicating document in ${slug}: ${errorMessage}`)\n return formatEntityError({ slug, action: 'duplicating', entity: 'collection', error, req })\n }\n})\n"],"names":["duplicateDocumentInputSchema","getCollectionVirtualFieldNames","parseDocumentID","stripVirtualFields","transformPointDataToPayload","validateCollectionData","defaultAccess","defineCollectionTool","getLogger","formatEntityError","DEFAULT_DESCRIPTION","duplicateDocumentTool","access","args","Boolean","permissions","collections","slug","create","annotations","destructiveHint","idempotentHint","openWorldHint","readOnlyHint","title","description","input","handler","authorizedMCP","req","payload","logger","id","data","depth","draft","fallbackLocale","locale","populate","select","selectedLocales","info","virtualFieldNames","config","inputData","undefined","partial","parsedData","result","duplicate","collectionSlug","collection","overrideAccess","content","type","text","JSON","stringify","doc","error","errorMessage","Error","message","action","entity"],"mappings":"AAAA,SACEA,4BAA4B,EAC5BC,8BAA8B,EAC9BC,eAAe,EACfC,kBAAkB,EAClBC,2BAA2B,EAC3BC,s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iB;YACAC;YACAiB,gBAAgBxB,cAAcwB,cAAc;YAC5CvB;YACA,GAAIkB,aAAa;gBAAEd,MAAMc;YAAW,IAAI,CAAC,CAAC;YAC1C,GAAIV,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAID,mBAAmBS,YAAY;gBAAET;YAAe,IAAI,CAAC,CAAC;YAC1D,GAAIE,WAAW;gBAAEA;YAAS,IAAI,CAAC,CAAC;YAChC,GAAIC,SAAS;gBAAEA;YAAO,IAAI,CAAC,CAAC;YAC5B,GAAIC,kBAAkB;gBAAEA;YAAgB,IAAI,CAAC,CAAC;QAChD;QAEAT,OAAOU,IAAI,CAAC,CAAC,oCAAoC,EAAExB,KAAK,UAAU,EAAEe,IAAI;QAExE,OAAO;YACLqB,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC,gDAAgD,EAAEtC,KAAK,sCAAsC,EAAEuC,KAAKC,SAAS,CAACT,QAAQ,QAAQ,CAAC;gBACxI;aACD;YACDU,KAAKV;QACP;IACF,EAAE,OAAOW,OAAO;QACd,MAAMC,eAAeD,iBAAiBE,QAAQF,MAAMG,OAAO,GAAG;QAC9D/B,OAAO4B,KAAK,CAAC,CAAC,8BAA8B,EAAE1C,KAAK,EAAE,EAAE2C,cAAc;QACrE,OAAOnD,kBAAkB;YAAEQ;YAAM8C,QAAQ;YAAeC,QAAQ;YAAcL;YAAO9B;QAAI;IAC3F;AACF,GAAE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CollectionSlug, File, PayloadRequest } from 'payload';
|
|
2
|
+
import { z } from 'payload';
|
|
3
|
+
export declare const fileInputSchema: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
4
|
+
name: z.ZodMiniString<string>;
|
|
5
|
+
data: z.ZodMiniString<string>;
|
|
6
|
+
mimeType: z.ZodMiniString<string>;
|
|
7
|
+
source: z.ZodMiniLiteral<"base64">;
|
|
8
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
9
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
10
|
+
source: z.ZodMiniLiteral<"externalURL">;
|
|
11
|
+
url: z.ZodMiniURL;
|
|
12
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
13
|
+
file: z.ZodMiniObject<{
|
|
14
|
+
filename: z.ZodMiniString<string>;
|
|
15
|
+
mimeType: z.ZodMiniString<string>;
|
|
16
|
+
size: z.ZodMiniInt;
|
|
17
|
+
uploadReference: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
source: z.ZodMiniLiteral<"uploadReference">;
|
|
20
|
+
}, z.core.$strict>], "source">;
|
|
21
|
+
type FileInput = z.infer<typeof fileInputSchema>;
|
|
22
|
+
export declare function resolveFile({ slug, input, req, }: {
|
|
23
|
+
input?: FileInput;
|
|
24
|
+
req: PayloadRequest;
|
|
25
|
+
slug: CollectionSlug;
|
|
26
|
+
}): Promise<File | undefined>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=fileInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileInput.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/fileInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEnE,OAAO,EAAY,CAAC,EAAE,MAAM,SAAS,CAAA;AAwBrC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;8BAoBzB,CAAA;AAEH,KAAK,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEhD,wBAAsB,WAAW,CAAC,EAChC,IAAI,EACJ,KAAK,EACL,GAAG,GACJ,EAAE;IACD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,CAAA;CACrB,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CA2C5B"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { APIError, z } from 'payload';
|
|
2
|
+
import { externalURLInputSchema, getFileFromUploadInstructions, resolveURLUploadInput } from 'payload/internal';
|
|
3
|
+
import { sanitizeFilename } from 'payload/shared';
|
|
4
|
+
const mimeTypeSchema = z.string().check(z.regex(/^[!#$%&'*+.^`|~\w-]+\/[!#$%&'*+.^`|~\w-]+$/, 'MIME type must use the type/subtype format'));
|
|
5
|
+
const uploadFileSchema = z.strictObject({
|
|
6
|
+
filename: z.string(),
|
|
7
|
+
mimeType: z.string(),
|
|
8
|
+
size: z.int().check(z.nonnegative()),
|
|
9
|
+
uploadReference: z.record(z.string(), z.unknown())
|
|
10
|
+
});
|
|
11
|
+
export const fileInputSchema = z.discriminatedUnion('source', [
|
|
12
|
+
z.strictObject({
|
|
13
|
+
name: z.string().check(z.minLength(1), z.describe('The file name, including its extension.')),
|
|
14
|
+
data: z.string().check(z.describe('The base64-encoded file bytes, without a data URL prefix.')),
|
|
15
|
+
mimeType: mimeTypeSchema.check(z.describe('The file MIME type, for example image/png.')),
|
|
16
|
+
source: z.literal('base64')
|
|
17
|
+
}),
|
|
18
|
+
externalURLInputSchema,
|
|
19
|
+
z.strictObject({
|
|
20
|
+
file: uploadFileSchema.check(z.describe('getUploadInstructions file field post-upload.')),
|
|
21
|
+
source: z.literal('uploadReference')
|
|
22
|
+
})
|
|
23
|
+
]).check(z.describe('A file for an upload collection. Prefer uploadReference after its upload succeeds; use base64 only for small local files or externalURL for an online file.'));
|
|
24
|
+
export async function resolveFile({ slug, input, req }) {
|
|
25
|
+
if (!input) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
if (input.source === 'uploadReference') {
|
|
29
|
+
try {
|
|
30
|
+
return await getFileFromUploadInstructions({
|
|
31
|
+
collectionSlug: slug,
|
|
32
|
+
file: input.file,
|
|
33
|
+
req
|
|
34
|
+
});
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (error instanceof Error && error.message === 'Staged upload was not found.') {
|
|
37
|
+
throw new APIError('Staged upload not found. Complete the upload action first, or use base64 for small local files.', 400);
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (input.source === 'externalURL') {
|
|
43
|
+
return resolveURLUploadInput({
|
|
44
|
+
slug,
|
|
45
|
+
input,
|
|
46
|
+
req
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const uploadConfig = req.payload.collections[slug]?.config.upload;
|
|
50
|
+
if (!uploadConfig) {
|
|
51
|
+
throw new APIError(`Collection "${slug}" does not support file uploads.`, 400);
|
|
52
|
+
}
|
|
53
|
+
const maxFileSize = req.payload.config.upload.limits?.fileSize;
|
|
54
|
+
const data = decodeBase64({
|
|
55
|
+
maxFileSize,
|
|
56
|
+
value: input.data
|
|
57
|
+
});
|
|
58
|
+
const file = {
|
|
59
|
+
name: sanitizeFilename(input.name),
|
|
60
|
+
data,
|
|
61
|
+
mimetype: input.mimeType,
|
|
62
|
+
size: data.length
|
|
63
|
+
};
|
|
64
|
+
if (maxFileSize !== undefined && Number.isFinite(maxFileSize) && file.size > maxFileSize) {
|
|
65
|
+
throw new APIError(`File exceeds the ${maxFileSize} byte upload limit.`, 400);
|
|
66
|
+
}
|
|
67
|
+
return file;
|
|
68
|
+
}
|
|
69
|
+
function decodeBase64({ maxFileSize, value }) {
|
|
70
|
+
const normalized = value.replace(/\s/g, '');
|
|
71
|
+
if (!/^[a-z0-9+/]*={0,2}$/i.test(normalized) || normalized.length % 4 === 1) {
|
|
72
|
+
throw new APIError('File data must be valid base64.', 400);
|
|
73
|
+
}
|
|
74
|
+
if (maxFileSize !== undefined && Number.isFinite(maxFileSize)) {
|
|
75
|
+
const paddingLength = normalized.endsWith('==') ? 2 : normalized.endsWith('=') ? 1 : 0;
|
|
76
|
+
const decodedSize = Math.floor(normalized.length * 3 / 4) - paddingLength;
|
|
77
|
+
if (decodedSize > maxFileSize) {
|
|
78
|
+
throw new APIError(`File exceeds the ${maxFileSize} byte upload limit.`, 400);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const data = Buffer.from(normalized, 'base64');
|
|
82
|
+
if (data.toString('base64').replace(/=+$/, '') !== normalized.replace(/=+$/, '')) {
|
|
83
|
+
throw new APIError('File data must be valid base64.', 400);
|
|
84
|
+
}
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=fileInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/mcp/builtin/collections/fileInput.ts"],"sourcesContent":["import type { CollectionSlug, File, PayloadRequest } from 'payload'\n\nimport { APIError, z } from 'payload'\nimport {\n externalURLInputSchema,\n getFileFromUploadInstructions,\n resolveURLUploadInput,\n} from 'payload/internal'\nimport { sanitizeFilename } from 'payload/shared'\n\nconst mimeTypeSchema = z\n .string()\n .check(\n z.regex(\n /^[!#$%&'*+.^`|~\\w-]+\\/[!#$%&'*+.^`|~\\w-]+$/,\n 'MIME type must use the type/subtype format',\n ),\n )\n\nconst uploadFileSchema = z.strictObject({\n filename: z.string(),\n mimeType: z.string(),\n size: z.int().check(z.nonnegative()),\n uploadReference: z.record(z.string(), z.unknown()),\n})\n\nexport const fileInputSchema = z\n .discriminatedUnion('source', [\n z.strictObject({\n name: z.string().check(z.minLength(1), z.describe('The file name, including its extension.')),\n data: z\n .string()\n .check(z.describe('The base64-encoded file bytes, without a data URL prefix.')),\n mimeType: mimeTypeSchema.check(z.describe('The file MIME type, for example image/png.')),\n source: z.literal('base64'),\n }),\n externalURLInputSchema,\n z.strictObject({\n file: uploadFileSchema.check(z.describe('getUploadInstructions file field post-upload.')),\n source: z.literal('uploadReference'),\n }),\n ])\n .check(\n z.describe(\n 'A file for an upload collection. Prefer uploadReference after its upload succeeds; use base64 only for small local files or externalURL for an online file.',\n ),\n )\n\ntype FileInput = z.infer<typeof fileInputSchema>\n\nexport async function resolveFile({\n slug,\n input,\n req,\n}: {\n input?: FileInput\n req: PayloadRequest\n slug: CollectionSlug\n}): Promise<File | undefined> {\n if (!input) {\n return undefined\n }\n\n if (input.source === 'uploadReference') {\n try {\n return await getFileFromUploadInstructions({ collectionSlug: slug, file: input.file, req })\n } catch (error) {\n if (error instanceof Error && error.message === 'Staged upload was not found.') {\n throw new APIError(\n 'Staged upload not found. Complete the upload action first, or use base64 for small local files.',\n 400,\n )\n }\n throw error\n }\n }\n\n if (input.source === 'externalURL') {\n return resolveURLUploadInput({ slug, input, req })\n }\n\n const uploadConfig = req.payload.collections[slug]?.config.upload\n\n if (!uploadConfig) {\n throw new APIError(`Collection \"${slug}\" does not support file uploads.`, 400)\n }\n\n const maxFileSize = req.payload.config.upload.limits?.fileSize\n const data = decodeBase64({ maxFileSize, value: input.data })\n const file: File = {\n name: sanitizeFilename(input.name),\n data,\n mimetype: input.mimeType,\n size: data.length,\n }\n\n if (maxFileSize !== undefined && Number.isFinite(maxFileSize) && file.size > maxFileSize) {\n throw new APIError(`File exceeds the ${maxFileSize} byte upload limit.`, 400)\n }\n\n return file\n}\n\nfunction decodeBase64({ maxFileSize, value }: { maxFileSize?: number; value: string }): Buffer {\n const normalized = value.replace(/\\s/g, '')\n\n if (!/^[a-z0-9+/]*={0,2}$/i.test(normalized) || normalized.length % 4 === 1) {\n throw new APIError('File data must be valid base64.', 400)\n }\n\n if (maxFileSize !== undefined && Number.isFinite(maxFileSize)) {\n const paddingLength = normalized.endsWith('==') ? 2 : normalized.endsWith('=') ? 1 : 0\n const decodedSize = Math.floor((normalized.length * 3) / 4) - paddingLength\n\n if (decodedSize > maxFileSize) {\n throw new APIError(`File exceeds the ${maxFileSize} byte upload limit.`, 400)\n }\n }\n\n const data = Buffer.from(normalized, 'base64')\n\n if (data.toString('base64').replace(/=+$/, '') !== normalized.replace(/=+$/, '')) {\n throw new APIError('File data must be valid base64.', 400)\n }\n\n return data\n}\n"],"names":["APIError","z","externalURLInputSchema","getFileFromUploadInstructions","resolveURLUploadInput","sanitizeFilename","mimeTypeSchema","string","check","regex","uploadFileSchema","strictObject","filename","mimeType","size","int","nonnegative","uploadReference","record","unknown","fileInputSchema","discriminatedUnion","name","minLength","describe","data","source","literal","file","resolveFile","slug","input","req","undefined","collectionSlug","error","Error","message","uploadConfig","payload","collections","config","upload","maxFileSize","limits","fileSize","decodeBase64","value","mimetype","length","Number","isFinite","normalized","replace","test","paddingLength","endsWith","decodedSize","Math","floor","Buffer","from","toString"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,CAAC,QAAQ,UAAS;AACrC,SACEC,sBAAsB,EACtBC,6BAA6B,EAC7BC,qBAAqB,QAChB,mBAAkB;AACzB,SAASC,gBAAgB,QAAQ,iBAAgB;AAEjD,MAAMC,iBAAiBL,EACpBM,MAAM,GACNC,KAAK,CACJP,EAAEQ,KAAK,CACL,8CACA;AAIN,MAAMC,mBAAmBT,EAAEU,YAAY,CAAC;IACtCC,UAAUX,EAAEM,MAAM;IAClBM,UAAUZ,EAAEM,MAAM;IAClBO,MAAMb,EAAEc,GAAG,GAAGP,KAAK,CAACP,EAAEe,WAAW;IACjCC,iBAAiBhB,EAAEiB,MAAM,CAACjB,EAAEM,MAAM,IAAIN,EAAEkB,OAAO;AACjD;AAEA,OAAO,MAAMC,kBAAkBnB,EAC5BoB,kBAAkB,CAAC,UAAU;IAC5BpB,EAAEU,YAAY,CAAC;QACbW,MAAMrB,EAAEM,MAAM,GAAGC,KAAK,CAACP,EAAEsB,SAAS,CAAC,IAAItB,EAAEuB,QAAQ,CAAC;QAClDC,MAAMxB,EACHM,MAAM,GACNC,KAAK,CAACP,EAAEuB,QAAQ,CAAC;QACpBX,UAAUP,eAAeE,KAAK,CAACP,EAAEuB,QAAQ,CAAC;QAC1CE,QAAQzB,EAAE0B,OAAO,CAAC;IACpB;IACAzB;IACAD,EAAEU,YAAY,CAAC;QACb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EAAE2C,YAAY,mBAAmB,CAAC,EAAE;IAC3E;IAEA,OAAOf;AACT;AAEA,SAASkB,aAAa,EAAEH,WAAW,EAAEI,KAAK,EAA2C;IACnF,MAAMK,aAAaL,MAAMM,OAAO,CAAC,OAAO;IAExC,IAAI,CAAC,uBAAuBC,IAAI,CAACF,eAAeA,WAAWH,MAAM,GAAG,MAAM,GAAG;QAC3E,MAAM,IAAIjD,SAAS,mCAAmC;IACxD;IAEA,IAAI2C,gBAAgBV,aAAaiB,OAAOC,QAAQ,CAACR,cAAc;QAC7D,MAAMY,gBAAgBH,WAAWI,QAAQ,CAAC,QAAQ,IAAIJ,WAAWI,QAAQ,CAAC,OAAO,IAAI;QACrF,MAAMC,cAAcC,KAAKC,KAAK,CAAC,AAACP,WAAWH,MAAM,GAAG,IAAK,KAAKM;QAE9D,IAAIE,cAAcd,aAAa;YAC7B,MAAM,IAAI3C,SAAS,CAAC,iBAAiB,EAAE2C,YAAY,mBAAmB,CAAC,EAAE;QAC3E;IACF;IAEA,MAAMlB,OAAOmC,OAAOC,IAAI,CAACT,YAAY;IAErC,IAAI3B,KAAKqC,QAAQ,CAAC,UAAUT,OAAO,CAAC,OAAO,QAAQD,WAAWC,OAAO,CAAC,OAAO,KAAK;QAChF,MAAM,IAAIrD,SAAS,mCAAmC;IACxD;IAEA,OAAOyB;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findDistinctTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/findDistinctTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findDistinctTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/builtin/collections/findDistinctTool.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,4CAyD3B,CAAA"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findDistinctInputSchema } from 'payload';
|
|
2
2
|
import { defaultAccess } from '../../../defaultAccess.js';
|
|
3
3
|
import { defineCollectionTool } from '../../../defineTool.js';
|
|
4
4
|
import { getLogger } from '../../../utils/getLogger.js';
|
|
5
|
-
import { localAPIDefaults } from '../../../utils/localAPIDefaults.js';
|
|
6
|
-
import { whereSchema } from '../../../utils/whereSchema.js';
|
|
7
5
|
const DEFAULT_DESCRIPTION = 'Find distinct values for a field in any collection by passing the collection slug and field path.';
|
|
8
6
|
export const findDistinctTool = defineCollectionTool({
|
|
9
|
-
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.
|
|
7
|
+
access: (args)=>defaultAccess(args) && Boolean(args.permissions?.collections?.[args.slug]?.read),
|
|
10
8
|
annotations: {
|
|
11
9
|
destructiveHint: false,
|
|
12
10
|
idempotentHint: true,
|
|
@@ -15,32 +13,21 @@ export const findDistinctTool = defineCollectionTool({
|
|
|
15
13
|
title: 'Find Distinct'
|
|
16
14
|
},
|
|
17
15
|
description: DEFAULT_DESCRIPTION,
|
|
18
|
-
input:
|
|
19
|
-
|
|
20
|
-
field: z.string().describe('The field path to get distinct values for'),
|
|
21
|
-
limit: z.number().int().min(1).max(100).describe('Maximum number of distinct values to return (max: 100)').optional(),
|
|
22
|
-
locale: z.string().describe('Optional: locale code to retrieve data in (e.g., "en", "es"). Use "all" to retrieve all locales for localized fields').optional(),
|
|
23
|
-
page: z.number().int().min(1).describe('Page number for pagination').optional(),
|
|
24
|
-
populate: z.record(z.string(), z.unknown()).describe('Optional: control which fields to include from populated relationship or upload documents.').optional(),
|
|
25
|
-
showHiddenFields: z.boolean().describe('Optional: include hidden fields in the distinct query').optional(),
|
|
26
|
-
sort: z.string().describe('Field to sort by (e.g., "createdAt", "-updatedAt" for descending)').optional(),
|
|
27
|
-
trash: z.boolean().describe('Optional: include soft-deleted documents when trash is enabled on the collection').optional(),
|
|
28
|
-
where: whereSchema.describe('Optional: where clause for filtering. Use field names with Payload operators, and/or arrays for grouping. Example: {"title":{"contains":"test"}}').optional()
|
|
29
|
-
})
|
|
30
|
-
}).handler(async ({ authorizedMCP, collectionSlug, input, req })=>{
|
|
16
|
+
input: findDistinctInputSchema
|
|
17
|
+
}).handler(async ({ slug, authorizedMCP, input, req })=>{
|
|
31
18
|
const payload = req.payload;
|
|
32
19
|
const logger = getLogger({
|
|
33
20
|
payload
|
|
34
21
|
});
|
|
35
|
-
const { depth, field, limit, locale, page, populate,
|
|
36
|
-
logger.info(`Finding distinct values in collection: ${
|
|
22
|
+
const { depth, field, limit, locale, page, populate, sort, trash, where } = input;
|
|
23
|
+
logger.info(`Finding distinct values in collection: ${slug}, field: ${field}`);
|
|
37
24
|
try {
|
|
38
25
|
const result = await payload.findDistinct({
|
|
39
|
-
collection:
|
|
26
|
+
collection: slug,
|
|
40
27
|
depth,
|
|
41
28
|
field,
|
|
29
|
+
overrideAccess: authorizedMCP.overrideAccess,
|
|
42
30
|
req,
|
|
43
|
-
...localAPIDefaults(authorizedMCP),
|
|
44
31
|
...limit ? {
|
|
45
32
|
limit
|
|
46
33
|
} : {},
|
|
@@ -51,10 +38,7 @@ export const findDistinctTool = defineCollectionTool({
|
|
|
51
38
|
page
|
|
52
39
|
} : {},
|
|
53
40
|
...populate ? {
|
|
54
|
-
populate
|
|
55
|
-
} : {},
|
|
56
|
-
...showHiddenFields !== undefined ? {
|
|
57
|
-
showHiddenFields
|
|
41
|
+
populate
|
|
58
42
|
} : {},
|
|
59
43
|
...sort ? {
|
|
60
44
|
sort
|
|
@@ -70,19 +54,19 @@ export const findDistinctTool = defineCollectionTool({
|
|
|
70
54
|
content: [
|
|
71
55
|
{
|
|
72
56
|
type: 'text',
|
|
73
|
-
text: `Distinct values for "${field}" in collection "${
|
|
57
|
+
text: `Distinct values for "${field}" in collection "${slug}":\n\`\`\`json\n${JSON.stringify(result)}\n\`\`\``
|
|
74
58
|
}
|
|
75
59
|
],
|
|
76
60
|
doc: result
|
|
77
61
|
};
|
|
78
62
|
} catch (error) {
|
|
79
63
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
80
|
-
logger.error(`Error finding distinct values in ${
|
|
64
|
+
logger.error(`Error finding distinct values in ${slug}: ${errorMessage}`);
|
|
81
65
|
return {
|
|
82
66
|
content: [
|
|
83
67
|
{
|
|
84
68
|
type: 'text',
|
|
85
|
-
text: `❌ **Error finding distinct values in collection "${
|
|
69
|
+
text: `❌ **Error finding distinct values in collection "${slug}":** ${errorMessage}`
|
|
86
70
|
}
|
|
87
71
|
],
|
|
88
72
|
isError: true
|