@payloadcms/plugin-mcp 4.0.0-internal.fa345ef → 4.0.0-internal.fec2230
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/bin.js +7 -0
- 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 +6 -13
- package/dist/endpoint/access.js.map +1 -1
- package/dist/mcp/buildMcpServer.d.ts +1 -1
- package/dist/mcp/buildMcpServer.d.ts.map +1 -1
- package/dist/mcp/buildMcpServer.js +35 -23
- 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 +79 -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/fileInput.spec.js +86 -0
- package/dist/mcp/builtin/collections/fileInput.spec.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 +51 -11
- 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 +28 -10
- 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 +4 -1
- package/dist/mcp/sanitizeMCPConfig.js.map +1 -1
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +2 -1
- package/dist/stdio.js.map +1 -1
- package/dist/types.d.ts +48 -11
- 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 +5 -7
- package/src/endpoint/access.ts +5 -13
- package/src/mcp/buildMcpServer.ts +39 -29
- package/src/mcp/builtin/collections/authTools.ts +77 -69
- package/src/mcp/builtin/collections/countTool.ts +10 -23
- package/src/mcp/builtin/collections/countVersionsTool.ts +10 -23
- 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 -64
- 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 +48 -14
- 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 -22
- 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 +30 -8
- package/src/mcp/builtin/globals/restoreVersionTool.ts +17 -48
- package/src/mcp/builtin/globals/updateTool.ts +39 -62
- package/src/mcp/builtinTools.ts +9 -2
- package/src/mcp/sanitizeMCPConfig.ts +4 -1
- package/src/stdio.ts +2 -1
- package/src/types.ts +47 -11
- 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 -32
- package/dist/utils/schemaConversion/getEntityInputSchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts +0 -10
- package/dist/utils/schemaConversion/sanitizeEntitySchema.d.ts.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js +0 -384
- package/dist/utils/schemaConversion/sanitizeEntitySchema.js.map +0 -1
- package/dist/utils/schemaConversion/sanitizeEntitySchema.spec.js +0 -133
- 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/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 -62
- package/src/utils/schemaConversion/sanitizeEntitySchema.spec.ts +0 -96
- package/src/utils/schemaConversion/sanitizeEntitySchema.ts +0 -432
- package/src/utils/transformPointDataToPayload.ts +0 -40
- package/src/utils/whereSchema.ts +0 -24
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { sanitizeEntitySchema } from './sanitizeEntitySchema.js';
|
|
3
|
-
describe('sanitizeEntitySchema', ()=>{
|
|
4
|
-
it('renames the Lexical node-union definition to a short name and keeps it a strict oneOf', ()=>{
|
|
5
|
-
// Shaped like the schema the MCP server prepares for a collection with a Lexical richText field
|
|
6
|
-
// (Payload's `input` variant): a `$defs` node union (a `oneOf` of node shapes). The input variant
|
|
7
|
-
// already types the relationship node's `value` as a bare ID - there is no populated-doc `$ref` to
|
|
8
|
-
// reduce here (the variant did that upstream), so sanitize leaves the value untouched.
|
|
9
|
-
const standalone = {
|
|
10
|
-
type: 'object',
|
|
11
|
-
$defs: {
|
|
12
|
-
LexicalNodes_ABCDEF12: {
|
|
13
|
-
oneOf: [
|
|
14
|
-
{
|
|
15
|
-
type: 'object',
|
|
16
|
-
additionalProperties: false,
|
|
17
|
-
properties: {
|
|
18
|
-
type: {
|
|
19
|
-
const: 'paragraph'
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
required: [
|
|
23
|
-
'type'
|
|
24
|
-
]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: 'object',
|
|
28
|
-
additionalProperties: false,
|
|
29
|
-
properties: {
|
|
30
|
-
type: {
|
|
31
|
-
const: 'relationship'
|
|
32
|
-
},
|
|
33
|
-
value: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
description: 'The related document ID.'
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
required: [
|
|
39
|
-
'type'
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
properties: {
|
|
46
|
-
id: {
|
|
47
|
-
type: 'string'
|
|
48
|
-
},
|
|
49
|
-
content: {
|
|
50
|
-
type: 'object',
|
|
51
|
-
properties: {
|
|
52
|
-
root: {
|
|
53
|
-
type: 'object',
|
|
54
|
-
properties: {
|
|
55
|
-
children: {
|
|
56
|
-
type: 'array',
|
|
57
|
-
items: {
|
|
58
|
-
$ref: '#/$defs/LexicalNodes_ABCDEF12'
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
expect(sanitizeEntitySchema(standalone)).toStrictEqual({
|
|
68
|
-
type: 'object',
|
|
69
|
-
$defs: {
|
|
70
|
-
// The node union is renamed to a short, readable `node`, and stays a strict discriminated
|
|
71
|
-
// `oneOf` - not loosened to `anyOf`.
|
|
72
|
-
node: {
|
|
73
|
-
oneOf: [
|
|
74
|
-
{
|
|
75
|
-
type: 'object',
|
|
76
|
-
additionalProperties: false,
|
|
77
|
-
properties: {
|
|
78
|
-
type: {
|
|
79
|
-
const: 'paragraph'
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
required: [
|
|
83
|
-
'type'
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
type: 'object',
|
|
88
|
-
additionalProperties: false,
|
|
89
|
-
properties: {
|
|
90
|
-
type: {
|
|
91
|
-
const: 'relationship'
|
|
92
|
-
},
|
|
93
|
-
// The value is already ID-only from the input variant - left as-is.
|
|
94
|
-
value: {
|
|
95
|
-
type: 'string',
|
|
96
|
-
description: 'The related document ID.'
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
required: [
|
|
100
|
-
'type'
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
properties: {
|
|
107
|
-
// Managed fields (createdAt/updatedAt/_status) are excluded upstream by the `input` variant;
|
|
108
|
-
// `id` stays because it's a valid optional input (a client may supply a custom ID).
|
|
109
|
-
id: {
|
|
110
|
-
type: 'string'
|
|
111
|
-
},
|
|
112
|
-
content: {
|
|
113
|
-
type: 'object',
|
|
114
|
-
properties: {
|
|
115
|
-
root: {
|
|
116
|
-
type: 'object',
|
|
117
|
-
properties: {
|
|
118
|
-
children: {
|
|
119
|
-
type: 'array',
|
|
120
|
-
items: {
|
|
121
|
-
$ref: '#/$defs/node'
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
//# sourceMappingURL=sanitizeEntitySchema.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/schemaConversion/sanitizeEntitySchema.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport type { JsonSchemaType } from '../../types.js'\n\nimport { sanitizeEntitySchema } from './sanitizeEntitySchema.js'\n\ndescribe('sanitizeEntitySchema', () => {\n it('renames the Lexical node-union definition to a short name and keeps it a strict oneOf', () => {\n // Shaped like the schema the MCP server prepares for a collection with a Lexical richText field\n // (Payload's `input` variant): a `$defs` node union (a `oneOf` of node shapes). The input variant\n // already types the relationship node's `value` as a bare ID - there is no populated-doc `$ref` to\n // reduce here (the variant did that upstream), so sanitize leaves the value untouched.\n const standalone: JsonSchemaType = {\n type: 'object',\n $defs: {\n LexicalNodes_ABCDEF12: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: { type: { const: 'paragraph' } },\n required: ['type'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { const: 'relationship' },\n value: { type: 'string', description: 'The related document ID.' },\n },\n required: ['type'],\n },\n ],\n },\n },\n properties: {\n id: { type: 'string' },\n content: {\n type: 'object',\n properties: {\n root: {\n type: 'object',\n properties: {\n children: { type: 'array', items: { $ref: '#/$defs/LexicalNodes_ABCDEF12' } },\n },\n },\n },\n },\n },\n }\n\n expect(sanitizeEntitySchema(standalone)).toStrictEqual({\n type: 'object',\n $defs: {\n // The node union is renamed to a short, readable `node`, and stays a strict discriminated\n // `oneOf` - not loosened to `anyOf`.\n node: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: { type: { const: 'paragraph' } },\n required: ['type'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { const: 'relationship' },\n // The value is already ID-only from the input variant - left as-is.\n value: { type: 'string', description: 'The related document ID.' },\n },\n required: ['type'],\n },\n ],\n },\n },\n properties: {\n // Managed fields (createdAt/updatedAt/_status) are excluded upstream by the `input` variant;\n // `id` stays because it's a valid optional input (a client may supply a custom ID).\n id: { type: 'string' },\n content: {\n type: 'object',\n properties: {\n root: {\n type: 'object',\n properties: {\n children: { type: 'array', items: { $ref: '#/$defs/node' } },\n },\n },\n },\n },\n },\n })\n })\n})\n"],"names":["describe","expect","it","sanitizeEntitySchema","standalone","type","$defs","LexicalNodes_ABCDEF12","oneOf","additionalProperties","properties","const","required","value","description","id","content","root","children","items","$ref","toStrictEqual","node"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAI7C,SAASC,oBAAoB,QAAQ,4BAA2B;AAEhEH,SAAS,wBAAwB;IAC/BE,GAAG,yFAAyF;QAC1F,gGAAgG;QAChG,kGAAkG;QAClG,mGAAmG;QACnG,uFAAuF;QACvF,MAAME,aAA6B;YACjCC,MAAM;YACNC,OAAO;gBACLC,uBAAuB;oBACrBC,OAAO;wBACL;4BACEH,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCAAEL,MAAM;oCAAEM,OAAO;gCAAY;4BAAE;4BAC3CC,UAAU;gCAAC;6BAAO;wBACpB;wBACA;4BACEP,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCACVL,MAAM;oCAAEM,OAAO;gCAAe;gCAC9BE,OAAO;oCAAER,MAAM;oCAAUS,aAAa;gCAA2B;4BACnE;4BACAF,UAAU;gCAAC;6BAAO;wBACpB;qBACD;gBACH;YACF;YACAF,YAAY;gBACVK,IAAI;oBAAEV,MAAM;gBAAS;gBACrBW,SAAS;oBACPX,MAAM;oBACNK,YAAY;wBACVO,MAAM;4BACJZ,MAAM;4BACNK,YAAY;gCACVQ,UAAU;oCAAEb,MAAM;oCAASc,OAAO;wCAAEC,MAAM;oCAAgC;gCAAE;4BAC9E;wBACF;oBACF;gBACF;YACF;QACF;QAEAnB,OAAOE,qBAAqBC,aAAaiB,aAAa,CAAC;YACrDhB,MAAM;YACNC,OAAO;gBACL,0FAA0F;gBAC1F,qCAAqC;gBACrCgB,MAAM;oBACJd,OAAO;wBACL;4BACEH,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCAAEL,MAAM;oCAAEM,OAAO;gCAAY;4BAAE;4BAC3CC,UAAU;gCAAC;6BAAO;wBACpB;wBACA;4BACEP,MAAM;4BACNI,sBAAsB;4BACtBC,YAAY;gCACVL,MAAM;oCAAEM,OAAO;gCAAe;gCAC9B,oEAAoE;gCACpEE,OAAO;oCAAER,MAAM;oCAAUS,aAAa;gCAA2B;4BACnE;4BACAF,UAAU;gCAAC;6BAAO;wBACpB;qBACD;gBACH;YACF;YACAF,YAAY;gBACV,6FAA6F;gBAC7F,oFAAoF;gBACpFK,IAAI;oBAAEV,MAAM;gBAAS;gBACrBW,SAAS;oBACPX,MAAM;oBACNK,YAAY;wBACVO,MAAM;4BACJZ,MAAM;4BACNK,YAAY;gCACVQ,UAAU;oCAAEb,MAAM;oCAASc,OAAO;wCAAEC,MAAM;oCAAe;gCAAE;4BAC7D;wBACF;oBACF;gBACF;YACF;QACF;IACF;AACF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transforms incoming MCP tool data from object format to tuple array format.
|
|
3
|
-
* Converts { longitude: number, latitude: number } back to [longitude, latitude]
|
|
4
|
-
* for Payload's internal point field representation.
|
|
5
|
-
*/
|
|
6
|
-
export declare function transformPointDataToPayload(data: Record<string, unknown>): Record<string, unknown>;
|
|
7
|
-
//# sourceMappingURL=transformPointDataToPayload.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformPointDataToPayload.d.ts","sourceRoot":"","sources":["../../src/utils/transformPointDataToPayload.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgCzB"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transforms incoming MCP tool data from object format to tuple array format.
|
|
3
|
-
* Converts { longitude: number, latitude: number } back to [longitude, latitude]
|
|
4
|
-
* for Payload's internal point field representation.
|
|
5
|
-
*/ export function transformPointDataToPayload(data) {
|
|
6
|
-
if (!data || typeof data !== 'object') {
|
|
7
|
-
return data;
|
|
8
|
-
}
|
|
9
|
-
const transformed = {};
|
|
10
|
-
for (const [key, value] of Object.entries(data)){
|
|
11
|
-
if (value && typeof value === 'object' && 'longitude' in value && 'latitude' in value && typeof value.longitude === 'number' && typeof value.latitude === 'number') {
|
|
12
|
-
// Transform to tuple array [longitude, latitude]
|
|
13
|
-
transformed[key] = [
|
|
14
|
-
value.longitude,
|
|
15
|
-
value.latitude
|
|
16
|
-
];
|
|
17
|
-
} else if (Array.isArray(value)) {
|
|
18
|
-
transformed[key] = value.map((item)=>typeof item === 'object' ? transformPointDataToPayload(item) : item);
|
|
19
|
-
} else if (value && typeof value === 'object') {
|
|
20
|
-
transformed[key] = transformPointDataToPayload(value);
|
|
21
|
-
} else {
|
|
22
|
-
transformed[key] = value;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return transformed;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=transformPointDataToPayload.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/transformPointDataToPayload.ts"],"sourcesContent":["/**\n * Transforms incoming MCP tool data from object format to tuple array format.\n * Converts { longitude: number, latitude: number } back to [longitude, latitude]\n * for Payload's internal point field representation.\n */\nexport function transformPointDataToPayload(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n if (!data || typeof data !== 'object') {\n return data\n }\n\n const transformed: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(data)) {\n if (\n value &&\n typeof value === 'object' &&\n 'longitude' in value &&\n 'latitude' in value &&\n typeof value.longitude === 'number' &&\n typeof value.latitude === 'number'\n ) {\n // Transform to tuple array [longitude, latitude]\n transformed[key] = [value.longitude, value.latitude]\n } else if (Array.isArray(value)) {\n transformed[key] = value.map((item) =>\n typeof item === 'object'\n ? transformPointDataToPayload(item as Record<string, unknown>)\n : item,\n )\n } else if (value && typeof value === 'object') {\n transformed[key] = transformPointDataToPayload(value as Record<string, unknown>)\n } else {\n transformed[key] = value\n }\n }\n\n return transformed\n}\n"],"names":["transformPointDataToPayload","data","transformed","key","value","Object","entries","longitude","latitude","Array","isArray","map","item"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,SAASA,4BACdC,IAA6B;IAE7B,IAAI,CAACA,QAAQ,OAAOA,SAAS,UAAU;QACrC,OAAOA;IACT;IAEA,MAAMC,cAAuC,CAAC;IAE9C,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,MAAO;QAC/C,IACEG,SACA,OAAOA,UAAU,YACjB,eAAeA,SACf,cAAcA,SACd,OAAOA,MAAMG,SAAS,KAAK,YAC3B,OAAOH,MAAMI,QAAQ,KAAK,UAC1B;YACA,iDAAiD;YACjDN,WAAW,CAACC,IAAI,GAAG;gBAACC,MAAMG,SAAS;gBAAEH,MAAMI,QAAQ;aAAC;QACtD,OAAO,IAAIC,MAAMC,OAAO,CAACN,QAAQ;YAC/BF,WAAW,CAACC,IAAI,GAAGC,MAAMO,GAAG,CAAC,CAACC,OAC5B,OAAOA,SAAS,WACZZ,4BAA4BY,QAC5BA;QAER,OAAO,IAAIR,SAAS,OAAOA,UAAU,UAAU;YAC7CF,WAAW,CAACC,IAAI,GAAGH,4BAA4BI;QACjD,OAAO;YACLF,WAAW,CAACC,IAAI,GAAGC;QACrB;IACF;IAEA,OAAOF;AACT"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Where } from 'payload';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
/**
|
|
4
|
-
* - Validates the `where` input of collection tools against Payload's `Where` shape
|
|
5
|
-
* - Field keys map to operator objects restricted to `validOperators`
|
|
6
|
-
* - `and` / `or` nest recursively
|
|
7
|
-
*/
|
|
8
|
-
export declare const whereSchema: z.ZodType<Where>;
|
|
9
|
-
//# sourceMappingURL=whereSchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whereSchema.d.ts","sourceRoot":"","sources":["../../src/utils/whereSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAGpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CASqD,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { validOperators } from 'payload/shared';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
const whereFieldSchema = z.partialRecord(z.enum(validOperators), z.unknown()).describe('Field query operators');
|
|
4
|
-
/**
|
|
5
|
-
* - Validates the `where` input of collection tools against Payload's `Where` shape
|
|
6
|
-
* - Field keys map to operator objects restricted to `validOperators`
|
|
7
|
-
* - `and` / `or` nest recursively
|
|
8
|
-
*/ export const whereSchema = z.lazy(()=>z.object({
|
|
9
|
-
and: z.array(whereSchema).optional(),
|
|
10
|
-
or: z.array(whereSchema).optional()
|
|
11
|
-
}).catchall(whereFieldSchema)).describe('Where clause using field names with Payload query operators, plus and/or groups');
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=whereSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/whereSchema.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { validOperators } from 'payload/shared'\nimport { z } from 'zod'\n\nconst whereFieldSchema = z\n .partialRecord(z.enum(validOperators), z.unknown())\n .describe('Field query operators')\n\n/**\n * - Validates the `where` input of collection tools against Payload's `Where` shape\n * - Field keys map to operator objects restricted to `validOperators`\n * - `and` / `or` nest recursively\n */\nexport const whereSchema: z.ZodType<Where> = z\n .lazy(() =>\n z\n .object({\n and: z.array(whereSchema).optional(),\n or: z.array(whereSchema).optional(),\n })\n .catchall(whereFieldSchema),\n )\n .describe('Where clause using field names with Payload query operators, plus and/or groups')\n"],"names":["validOperators","z","whereFieldSchema","partialRecord","enum","unknown","describe","whereSchema","lazy","object","and","array","optional","or","catchall"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,CAAC,QAAQ,MAAK;AAEvB,MAAMC,mBAAmBD,EACtBE,aAAa,CAACF,EAAEG,IAAI,CAACJ,iBAAiBC,EAAEI,OAAO,IAC/CC,QAAQ,CAAC;AAEZ;;;;CAIC,GACD,OAAO,MAAMC,cAAgCN,EAC1CO,IAAI,CAAC,IACJP,EACGQ,MAAM,CAAC;QACNC,KAAKT,EAAEU,KAAK,CAACJ,aAAaK,QAAQ;QAClCC,IAAIZ,EAAEU,KAAK,CAACJ,aAAaK,QAAQ;IACnC,GACCE,QAAQ,CAACZ,mBAEbI,QAAQ,CAAC,mFAAkF"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { CollectionSlug, PayloadRequest } from 'payload'
|
|
2
|
-
|
|
3
|
-
import type { MCPToolResponse } from '../../../types.js'
|
|
4
|
-
|
|
5
|
-
import { getCollectionInputSchema } from '../../../utils/schemaConversion/getEntityInputSchema.js'
|
|
6
|
-
|
|
7
|
-
const getValidationErrors = (error: unknown): undefined | unknown[] => {
|
|
8
|
-
if (!error || typeof error !== 'object') {
|
|
9
|
-
return undefined
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const data = 'data' in error ? error.data : undefined
|
|
13
|
-
if (!data || typeof data !== 'object' || !('errors' in data) || !Array.isArray(data.errors)) {
|
|
14
|
-
return undefined
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return data.errors
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const isSchemaError = (error: unknown, message: string): boolean => {
|
|
21
|
-
if (getValidationErrors(error)) {
|
|
22
|
-
return true
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const name = error && typeof error === 'object' && 'name' in error ? error.name : undefined
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
name === 'CastError' ||
|
|
29
|
-
name === 'ValidationError' ||
|
|
30
|
-
message.includes('Cast to ') ||
|
|
31
|
-
message.includes('validation failed')
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const formatCollectionError = ({
|
|
36
|
-
action,
|
|
37
|
-
collectionSlug,
|
|
38
|
-
error,
|
|
39
|
-
req,
|
|
40
|
-
}: {
|
|
41
|
-
action: 'creating' | 'duplicating' | 'updating'
|
|
42
|
-
collectionSlug: CollectionSlug
|
|
43
|
-
error: unknown
|
|
44
|
-
req: PayloadRequest
|
|
45
|
-
}): MCPToolResponse => {
|
|
46
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error'
|
|
47
|
-
const errors = getValidationErrors(error) ?? [{ message: errorMessage }]
|
|
48
|
-
|
|
49
|
-
if (!isSchemaError(error, errorMessage)) {
|
|
50
|
-
return {
|
|
51
|
-
content: [
|
|
52
|
-
{
|
|
53
|
-
type: 'text',
|
|
54
|
-
text: `Error ${action} document in collection "${collectionSlug}": ${errorMessage}`,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
isError: true,
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const schema = getCollectionInputSchema({ collectionSlug, req })
|
|
62
|
-
const schemaText = schema
|
|
63
|
-
? `\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``
|
|
64
|
-
: ''
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
content: [
|
|
68
|
-
{
|
|
69
|
-
type: 'text',
|
|
70
|
-
text: `Error ${action} document in collection "${collectionSlug}": ${errorMessage}${schemaText}`,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
isError: true,
|
|
74
|
-
...(schema
|
|
75
|
-
? {
|
|
76
|
-
structuredContent: {
|
|
77
|
-
collectionSlug,
|
|
78
|
-
errors,
|
|
79
|
-
schema,
|
|
80
|
-
},
|
|
81
|
-
}
|
|
82
|
-
: {}),
|
|
83
|
-
}
|
|
84
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { CollectionSlug, GlobalSlug, PayloadRequest, SanitizedConfig } from 'payload'
|
|
2
|
-
|
|
3
|
-
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/server/validators/cf-worker'
|
|
4
|
-
|
|
5
|
-
import type { JsonSchemaType, MCPToolResponse } from '../../types.js'
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
getCollectionInputSchema,
|
|
9
|
-
getGlobalInputSchema,
|
|
10
|
-
} from '../../utils/schemaConversion/getEntityInputSchema.js'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Keep the default `shortcircuit: true` - `false` makes validating nested rich text exponentially slow.
|
|
14
|
-
*/
|
|
15
|
-
const validator = new CfWorkerJsonSchemaValidator({ shortcircuit: true })
|
|
16
|
-
|
|
17
|
-
type EntityValidator = {
|
|
18
|
-
schema: JsonSchemaType
|
|
19
|
-
validate: ReturnType<(typeof validator)['getValidator']>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* - Caches each entity's schema and validator, so both are only built on the first request.
|
|
24
|
-
* - Keyed by payload config, then by entity type, slug, partial and language.
|
|
25
|
-
*/
|
|
26
|
-
const validatorCache = new WeakMap<SanitizedConfig, Map<string, EntityValidator>>()
|
|
27
|
-
|
|
28
|
-
export const validateCollectionData = ({
|
|
29
|
-
collectionSlug,
|
|
30
|
-
data,
|
|
31
|
-
partial,
|
|
32
|
-
req,
|
|
33
|
-
}: {
|
|
34
|
-
collectionSlug: CollectionSlug
|
|
35
|
-
data: Record<string, unknown>
|
|
36
|
-
partial?: boolean
|
|
37
|
-
req: PayloadRequest
|
|
38
|
-
}): MCPToolResponse | null =>
|
|
39
|
-
validateData({
|
|
40
|
-
slug: collectionSlug,
|
|
41
|
-
buildSchema: () => getCollectionInputSchema({ collectionSlug, req }),
|
|
42
|
-
data,
|
|
43
|
-
entity: 'collection',
|
|
44
|
-
partial,
|
|
45
|
-
req,
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
export const validateGlobalData = ({
|
|
49
|
-
data,
|
|
50
|
-
globalSlug,
|
|
51
|
-
req,
|
|
52
|
-
}: {
|
|
53
|
-
data: Record<string, unknown>
|
|
54
|
-
globalSlug: GlobalSlug
|
|
55
|
-
req: PayloadRequest
|
|
56
|
-
}): MCPToolResponse | null =>
|
|
57
|
-
validateData({
|
|
58
|
-
slug: globalSlug,
|
|
59
|
-
buildSchema: () => getGlobalInputSchema({ globalSlug, req }),
|
|
60
|
-
data,
|
|
61
|
-
entity: 'global',
|
|
62
|
-
partial: true,
|
|
63
|
-
req,
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const validateData = ({
|
|
67
|
-
slug,
|
|
68
|
-
buildSchema,
|
|
69
|
-
data,
|
|
70
|
-
entity,
|
|
71
|
-
partial,
|
|
72
|
-
req,
|
|
73
|
-
}: {
|
|
74
|
-
buildSchema: () => JsonSchemaType | null
|
|
75
|
-
data: Record<string, unknown>
|
|
76
|
-
entity: 'collection' | 'global'
|
|
77
|
-
partial?: boolean
|
|
78
|
-
req: PayloadRequest
|
|
79
|
-
slug: string
|
|
80
|
-
}): MCPToolResponse | null => {
|
|
81
|
-
let cache = validatorCache.get(req.payload.config)
|
|
82
|
-
if (!cache) {
|
|
83
|
-
cache = new Map()
|
|
84
|
-
validatorCache.set(req.payload.config, cache)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const cacheKey = `${entity}:${slug}:${partial ? 'partial' : 'full'}:${req.i18n.language}`
|
|
88
|
-
let entityValidator = cache.get(cacheKey)
|
|
89
|
-
|
|
90
|
-
if (!entityValidator) {
|
|
91
|
-
const schema = buildSchema()
|
|
92
|
-
|
|
93
|
-
if (!schema) {
|
|
94
|
-
return null
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
entityValidator = {
|
|
98
|
-
schema,
|
|
99
|
-
validate: validator.getValidator(partial ? withoutRequired(schema) : schema),
|
|
100
|
-
}
|
|
101
|
-
cache.set(cacheKey, entityValidator)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const result = entityValidator.validate(data)
|
|
105
|
-
|
|
106
|
-
if (result.valid) {
|
|
107
|
-
return null
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const { schema } = entityValidator
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
content: [
|
|
114
|
-
{
|
|
115
|
-
type: 'text',
|
|
116
|
-
text: `Invalid data for ${entity} "${slug}": ${result.errorMessage}\n\nUse this schema for data:\n\`\`\`json\n${JSON.stringify(schema)}\n\`\`\``,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
isError: true,
|
|
120
|
-
structuredContent: {
|
|
121
|
-
[`${entity}Slug`]: slug,
|
|
122
|
-
errors: [{ message: result.errorMessage }],
|
|
123
|
-
schema,
|
|
124
|
-
},
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** Updates are partial — drop the schema's top-level `required` before validating. */
|
|
129
|
-
const withoutRequired = (schema: JsonSchemaType): JsonSchemaType => {
|
|
130
|
-
const { required: _required, ...rest } = schema
|
|
131
|
-
return rest
|
|
132
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AuthorizedMCP } from '../types.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the `user` and `overrideAccess` arguments every Payload local API call
|
|
5
|
-
* should receive when initiated from an MCP request. Spread the result into the
|
|
6
|
-
* call's arg object so the two pieces of caller state can't drift apart.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* await req.payload.create({
|
|
11
|
-
* collection: 'posts',
|
|
12
|
-
* data,
|
|
13
|
-
* ...localAPIDefaults(authorizedMCP),
|
|
14
|
-
* })
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export const localAPIDefaults = (
|
|
18
|
-
authorizedMCP: AuthorizedMCP,
|
|
19
|
-
): { overrideAccess: boolean; user: AuthorizedMCP['user'] } => ({
|
|
20
|
-
overrideAccess: authorizedMCP.overrideAccess,
|
|
21
|
-
user: authorizedMCP.user,
|
|
22
|
-
})
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CollectionSlug,
|
|
3
|
-
entityToStandaloneJSONSchema,
|
|
4
|
-
type GlobalSlug,
|
|
5
|
-
type PayloadRequest,
|
|
6
|
-
type SanitizedCollectionConfig,
|
|
7
|
-
type SanitizedGlobalConfig,
|
|
8
|
-
} from 'payload'
|
|
9
|
-
|
|
10
|
-
import type { JsonSchemaType } from '../../types.js'
|
|
11
|
-
|
|
12
|
-
import { sanitizeEntitySchema } from './sanitizeEntitySchema.js'
|
|
13
|
-
|
|
14
|
-
export const getCollectionInputSchema = ({
|
|
15
|
-
collectionSlug,
|
|
16
|
-
req,
|
|
17
|
-
}: {
|
|
18
|
-
collectionSlug: CollectionSlug
|
|
19
|
-
req: PayloadRequest
|
|
20
|
-
}): JsonSchemaType | null => {
|
|
21
|
-
const collection = req.payload.collections[collectionSlug]?.config
|
|
22
|
-
|
|
23
|
-
if (!collection) {
|
|
24
|
-
return null
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return buildEntityInputSchema({ entity: collection, req })
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const getGlobalInputSchema = ({
|
|
31
|
-
globalSlug,
|
|
32
|
-
req,
|
|
33
|
-
}: {
|
|
34
|
-
globalSlug: GlobalSlug
|
|
35
|
-
req: PayloadRequest
|
|
36
|
-
}): JsonSchemaType | null => {
|
|
37
|
-
const global = req.payload.config.globals.find((globalConfig) => globalConfig.slug === globalSlug)
|
|
38
|
-
|
|
39
|
-
if (!global) {
|
|
40
|
-
return null
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return buildEntityInputSchema({ entity: global, req })
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const buildEntityInputSchema = ({
|
|
47
|
-
entity,
|
|
48
|
-
req,
|
|
49
|
-
}: {
|
|
50
|
-
entity: SanitizedCollectionConfig | SanitizedGlobalConfig
|
|
51
|
-
req: PayloadRequest
|
|
52
|
-
}): JsonSchemaType =>
|
|
53
|
-
// The `input` variant is already the write shape; sanitizeEntitySchema only adds MCP-specific passes.
|
|
54
|
-
sanitizeEntitySchema(
|
|
55
|
-
entityToStandaloneJSONSchema({
|
|
56
|
-
config: req.payload.config,
|
|
57
|
-
defaultIDType: req.payload.db.defaultIDType,
|
|
58
|
-
entity,
|
|
59
|
-
i18n: req.i18n,
|
|
60
|
-
variant: 'input',
|
|
61
|
-
}) as unknown as JsonSchemaType,
|
|
62
|
-
)
|