@govcraft/payload-cms-mcp 1.0.1

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 (121) hide show
  1. package/README.md +164 -0
  2. package/dist/config/index.d.ts +27 -0
  3. package/dist/config/index.js +31 -0
  4. package/dist/config/index.js.map +1 -0
  5. package/dist/controllers/mcp.controller.d.ts +7 -0
  6. package/dist/controllers/mcp.controller.js +328 -0
  7. package/dist/controllers/mcp.controller.js.map +1 -0
  8. package/dist/controllers/payload-mcp.controller.d.ts +4 -0
  9. package/dist/controllers/payload-mcp.controller.js +185 -0
  10. package/dist/controllers/payload-mcp.controller.js.map +1 -0
  11. package/dist/generate-tools.d.ts +1 -0
  12. package/dist/generate-tools.js +1417 -0
  13. package/dist/generate-tools.js.map +1 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +16 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/mcp/anthropic-mcp.d.ts +3 -0
  18. package/dist/mcp/anthropic-mcp.js +332 -0
  19. package/dist/mcp/anthropic-mcp.js.map +1 -0
  20. package/dist/mcp/generated/index.d.ts +44 -0
  21. package/dist/mcp/generated/index.js +45 -0
  22. package/dist/mcp/generated/index.js.map +1 -0
  23. package/dist/mcp/generated/payload-tools.d.ts +7 -0
  24. package/dist/mcp/generated/payload-tools.js +69 -0
  25. package/dist/mcp/generated/payload-tools.js.map +1 -0
  26. package/dist/mcp/generated/payload-tools.json +13024 -0
  27. package/dist/mcp/generated/tools/create.json +9138 -0
  28. package/dist/mcp/generated/tools/createAccess.json +10 -0
  29. package/dist/mcp/generated/tools/createAfterChangeHook.json +9 -0
  30. package/dist/mcp/generated/tools/createAfterDeleteHook.json +9 -0
  31. package/dist/mcp/generated/tools/createAfterErrorHook.json +9 -0
  32. package/dist/mcp/generated/tools/createAfterForgotPasswordHook.json +9 -0
  33. package/dist/mcp/generated/tools/createAfterLoginHook.json +9 -0
  34. package/dist/mcp/generated/tools/createAfterLogoutHook.json +9 -0
  35. package/dist/mcp/generated/tools/createAfterMeHook.json +9 -0
  36. package/dist/mcp/generated/tools/createAfterOperationHook.json +9 -0
  37. package/dist/mcp/generated/tools/createAfterReadHook.json +9 -0
  38. package/dist/mcp/generated/tools/createAfterRefreshHook.json +9 -0
  39. package/dist/mcp/generated/tools/createArrayField.json +90 -0
  40. package/dist/mcp/generated/tools/createBeforeChangeHook.json +9 -0
  41. package/dist/mcp/generated/tools/createBeforeDeleteHook.json +9 -0
  42. package/dist/mcp/generated/tools/createBeforeLoginHook.json +9 -0
  43. package/dist/mcp/generated/tools/createBeforeOperationHook.json +9 -0
  44. package/dist/mcp/generated/tools/createBeforeReadHook.json +9 -0
  45. package/dist/mcp/generated/tools/createBeforeValidateHook.json +9 -0
  46. package/dist/mcp/generated/tools/createBlocksField.json +79 -0
  47. package/dist/mcp/generated/tools/createCodeField.json +79 -0
  48. package/dist/mcp/generated/tools/createCollection.json +422 -0
  49. package/dist/mcp/generated/tools/createCollectionAdminOptions.json +2789 -0
  50. package/dist/mcp/generated/tools/createDateField.json +84 -0
  51. package/dist/mcp/generated/tools/createEmailField.json +87 -0
  52. package/dist/mcp/generated/tools/createField.json +31 -0
  53. package/dist/mcp/generated/tools/createGlobal.json +220 -0
  54. package/dist/mcp/generated/tools/createGroupField.json +79 -0
  55. package/dist/mcp/generated/tools/createJSONField.json +79 -0
  56. package/dist/mcp/generated/tools/createJoinField.json +79 -0
  57. package/dist/mcp/generated/tools/createMeHook.json +9 -0
  58. package/dist/mcp/generated/tools/createNumberField.json +31 -0
  59. package/dist/mcp/generated/tools/createPointField.json +79 -0
  60. package/dist/mcp/generated/tools/createPolymorphicRelationshipField.json +31 -0
  61. package/dist/mcp/generated/tools/createRadioField.json +94 -0
  62. package/dist/mcp/generated/tools/createRefreshHook.json +9 -0
  63. package/dist/mcp/generated/tools/createRelationshipField.json +31 -0
  64. package/dist/mcp/generated/tools/createRichTextField.json +79 -0
  65. package/dist/mcp/generated/tools/createSelectField.json +31 -0
  66. package/dist/mcp/generated/tools/createSingleRelationshipField.json +31 -0
  67. package/dist/mcp/generated/tools/createTextField.json +31 -0
  68. package/dist/mcp/generated/tools/createTextareaField.json +87 -0
  69. package/dist/mcp/generated/tools/createUploadField.json +31 -0
  70. package/dist/mcp/handler.d.ts +6 -0
  71. package/dist/mcp/handler.js +147 -0
  72. package/dist/mcp/handler.js.map +1 -0
  73. package/dist/mcp/index.d.ts +1 -0
  74. package/dist/mcp/index.js +28 -0
  75. package/dist/mcp/index.js.map +1 -0
  76. package/dist/mcp/io/index.d.ts +2 -0
  77. package/dist/mcp/io/index.js +31 -0
  78. package/dist/mcp/io/index.js.map +1 -0
  79. package/dist/mcp/io/stdin.d.ts +2 -0
  80. package/dist/mcp/io/stdin.js +118 -0
  81. package/dist/mcp/io/stdin.js.map +1 -0
  82. package/dist/mcp/session.d.ts +16 -0
  83. package/dist/mcp/session.js +85 -0
  84. package/dist/mcp/session.js.map +1 -0
  85. package/dist/mcp/sse.d.ts +10 -0
  86. package/dist/mcp/sse.js +86 -0
  87. package/dist/mcp/sse.js.map +1 -0
  88. package/dist/mcp/tools/calculator.d.ts +2 -0
  89. package/dist/mcp/tools/calculator.js +68 -0
  90. package/dist/mcp/tools/calculator.js.map +1 -0
  91. package/dist/mcp/tools/index.d.ts +3 -0
  92. package/dist/mcp/tools/index.js +6 -0
  93. package/dist/mcp/tools/index.js.map +1 -0
  94. package/dist/mcp/tools/list-tools.d.ts +2 -0
  95. package/dist/mcp/tools/list-tools.js +47 -0
  96. package/dist/mcp/tools/list-tools.js.map +1 -0
  97. package/dist/mcp/tools/payload-tools-loader.d.ts +2 -0
  98. package/dist/mcp/tools/payload-tools-loader.js +21 -0
  99. package/dist/mcp/tools/payload-tools-loader.js.map +1 -0
  100. package/dist/mcp/types.d.ts +69 -0
  101. package/dist/mcp/types.js +2 -0
  102. package/dist/mcp/types.js.map +1 -0
  103. package/dist/middleware/errorHandler.d.ts +14 -0
  104. package/dist/middleware/errorHandler.js +25 -0
  105. package/dist/middleware/errorHandler.js.map +1 -0
  106. package/dist/middleware/notFoundHandler.d.ts +2 -0
  107. package/dist/middleware/notFoundHandler.js +8 -0
  108. package/dist/middleware/notFoundHandler.js.map +1 -0
  109. package/dist/routes/health.d.ts +2 -0
  110. package/dist/routes/health.js +18 -0
  111. package/dist/routes/health.js.map +1 -0
  112. package/dist/routes/mcp.d.ts +2 -0
  113. package/dist/routes/mcp.js +11 -0
  114. package/dist/routes/mcp.js.map +1 -0
  115. package/dist/routes/payload-mcp.routes.d.ts +3 -0
  116. package/dist/routes/payload-mcp.routes.js +8 -0
  117. package/dist/routes/payload-mcp.routes.js.map +1 -0
  118. package/dist/utils/logger.d.ts +2 -0
  119. package/dist/utils/logger.js +35 -0
  120. package/dist/utils/logger.js.map +1 -0
  121. package/package.json +64 -0
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "createAccess",
3
+ "description": "Creates a Payload CMS 3.0 Access configuration\n\nAccess function runs on the server\nand is sent to the client allowing the dashboard to show accessible data and actions.\n@see ://payloadcms.com/docs/access-control/overview",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {},
7
+ "description": "Access function runs on the server\nand is sent to the client allowing the dashboard to show accessible data and actions.\n@see ://payloadcms.com/docs/access-control/overview"
8
+ },
9
+ "template": "/**\n * Access control function to determine if the operation is allowed\n * Returns true if access is granted, false if denied\n * Can also return a string with an error message if denied\n */\nconst accessControl = ({ req, id, data, doc }) => {\n // 'req' is the Express request object with the Payload instance and user\n // 'id' is the ID of the document being accessed (for operations on existing documents)\n // 'data' contains the data for create/update operations\n // 'doc' is the existing document for update operations\n \n // Example: Only allow access if user is logged in\n if (!req.user) {\n return false; // Or return 'You must be logged in'\n }\n \n // Example: Check user roles\n if (req.user.role === 'admin') {\n return true; // Admins have full access\n }\n \n // Example: Users can only access their own documents\n if (id && doc && doc.createdBy === req.user.id) {\n return true;\n }\n \n // Deny access with a custom message\n return 'You do not have permission to access this resource';\n};"
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterChangeHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterChangeHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs after a document has been saved to the database\n * It allows you to perform side effects but cannot modify the saved data\n */\nconst afterChangeHook = ({ doc, req, operation, previousDoc }) => {\n // 'doc' contains the saved document\n // 'req' is the Express request object with the Payload instance\n // 'operation' is either 'create' or 'update'\n // 'previousDoc' is the document before changes (for updates)\n \n // Example: Send a notification\n if (operation === 'create') {\n // Send notification about new document\n logger.info(`New document created: ${doc.id}`);\n }\n \n // Return the document (cannot be modified)\n return doc;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterDeleteHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterDeleteHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs after a document has been deleted\n * It allows you to perform side effects\n */\nconst afterDeleteHook = ({ req, id, doc }) => {\n // 'req' is the Express request object with the Payload instance\n // 'id' is the ID of the document that was deleted\n // 'doc' is the document that was deleted\n \n // Example: Clean up related data\n logger.info(`Document deleted: ${id}`);\n \n // No return value is expected\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterErrorHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterErrorHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterForgotPasswordHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterForgotPasswordHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterLoginHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterLoginHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterLogoutHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterLogoutHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterMeHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterMeHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterOperationHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterOperationHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterReadHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterReadHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs before/after documents are returned from the database\n * It allows you to modify the data before it's sent to the client\n */\nconst readHook = ({ doc, req }) => {\n // 'doc' contains the document(s) being read\n // 'req' is the Express request object with the Payload instance\n \n // Example: Add computed properties\n return {\n ...doc,\n computedProperty: `${doc.firstName} ${doc.lastName}`,\n };\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createAfterRefreshHook",
3
+ "description": "Creates a Payload CMS 3.0 AfterRefreshHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "createArrayField",
3
+ "description": "Creates a Payload CMS 3.0 ArrayField configuration\n\nExample:\n```typescript\n{\n name: 'items',\n type: 'array',\n label: 'Items',\n minRows: 1,\n maxRows: 10,\n fields: [\n {\n name: 'name',\n type: 'text',\n required: true\n },\n {\n name: 'quantity',\n type: 'number',\n required: true,\n min: 1\n }\n ],\n // Custom validation example\n validate: (value) => {\n if (value && value.length > 0) {\n const totalQuantity = value.reduce((sum, item) => sum + (item.quantity || 0), 0);\n if (totalQuantity > 100) {\n return 'Total quantity cannot exceed 100';\n }\n }\n return true;\n }\n}\n```",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "items": {
7
+ "type": "object"
8
+ },
9
+ "description": "Array of items",
10
+ "properties": {
11
+ "name": {
12
+ "type": "string",
13
+ "description": "The name of the field, used as the property name in the database"
14
+ },
15
+ "type": {
16
+ "type": "string",
17
+ "enum": [
18
+ "array"
19
+ ],
20
+ "description": "The type of field"
21
+ },
22
+ "label": {
23
+ "type": "string",
24
+ "description": "The label shown in the admin UI"
25
+ },
26
+ "required": {
27
+ "type": "boolean",
28
+ "description": "Whether this field is required"
29
+ },
30
+ "admin": {
31
+ "type": "object",
32
+ "description": "Admin panel configuration for this field",
33
+ "properties": {
34
+ "description": {
35
+ "type": "string",
36
+ "description": "Additional description shown in the admin UI"
37
+ },
38
+ "position": {
39
+ "type": "string",
40
+ "enum": [
41
+ "sidebar"
42
+ ],
43
+ "description": "Position of the field in the admin UI"
44
+ },
45
+ "width": {
46
+ "type": "string",
47
+ "description": "Width of the field in the admin UI"
48
+ },
49
+ "style": {
50
+ "type": "object",
51
+ "description": "Custom CSS styles for the field"
52
+ },
53
+ "className": {
54
+ "type": "string",
55
+ "description": "CSS class name for the field"
56
+ },
57
+ "readOnly": {
58
+ "type": "boolean",
59
+ "description": "Whether the field is read-only in the admin UI"
60
+ },
61
+ "hidden": {
62
+ "type": "boolean",
63
+ "description": "Whether the field is hidden in the admin UI"
64
+ },
65
+ "condition": {
66
+ "type": "string",
67
+ "description": "Condition for showing/hiding the field"
68
+ }
69
+ }
70
+ },
71
+ "minRows": {
72
+ "type": "number",
73
+ "description": "Minimum number of rows"
74
+ },
75
+ "maxRows": {
76
+ "type": "number",
77
+ "description": "Maximum number of rows"
78
+ },
79
+ "validate": {
80
+ "type": "string",
81
+ "description": "Custom validation function that returns true if valid or an error message string if invalid"
82
+ }
83
+ },
84
+ "required": [
85
+ "name",
86
+ "type"
87
+ ]
88
+ },
89
+ "template": "{\n name: '{name}', // Database field name\n type: 'array',\n label: 'Array Field', // Label shown in the admin UI\n required: true,\n // Add field-specific properties here\n \n // Optional: Add custom validation\n validate: (value, { siblingData, operation }) => {\n // Custom validation logic based on the value, sibling data, or operation\n if (!value && operation === 'create') {\n return 'This field is required for new records';\n }\n return true; // Return true if valid\n },\n ...{rest}\n}"
90
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createBeforeChangeHook",
3
+ "description": "Creates a Payload CMS 3.0 BeforeChangeHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs before a document is saved to the database\n * It allows you to modify the data or perform validation\n */\nconst beforeChangeHook = ({ data, req, operation, originalDoc }) => {\n // 'data' contains the data being saved\n // 'req' is the Express request object with the Payload instance\n // 'operation' is either 'create' or 'update'\n // 'originalDoc' is the document before changes (for updates)\n \n // Example: Add a timestamp\n return {\n ...data,\n modifiedAt: new Date().toISOString(),\n modifiedBy: req.user?.id,\n };\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createBeforeDeleteHook",
3
+ "description": "Creates a Payload CMS 3.0 BeforeDeleteHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs before a document is deleted\n * It allows you to perform validation or prevent deletion\n */\nconst beforeDeleteHook = ({ req, id }) => {\n // 'req' is the Express request object with the Payload instance\n // 'id' is the ID of the document being deleted\n \n // Example: Check if deletion is allowed\n // If you return a string, it will prevent deletion with that error message\n // If you throw an error, it will prevent deletion with that error\n \n // To allow deletion, return undefined or void\n return;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createBeforeLoginHook",
3
+ "description": "Creates a Payload CMS 3.0 BeforeLoginHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createBeforeOperationHook",
3
+ "description": "Creates a Payload CMS 3.0 BeforeOperationHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * Generic Payload CMS hook\n * See documentation for specific hook parameters\n */\nconst hook = (args) => {\n // Extract relevant properties from args based on hook type\n const { req } = args;\n \n // Example: Log hook execution\n logger.info('Hook executed');\n \n // For hooks that modify data, return the modified data\n // For other hooks, return as appropriate for the hook type\n return args.data ? { ...args.data, modified: true } : undefined;\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createBeforeReadHook",
3
+ "description": "Creates a Payload CMS 3.0 BeforeReadHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs before/after documents are returned from the database\n * It allows you to modify the data before it's sent to the client\n */\nconst readHook = ({ doc, req }) => {\n // 'doc' contains the document(s) being read\n // 'req' is the Express request object with the Payload instance\n \n // Example: Add computed properties\n return {\n ...doc,\n computedProperty: `${doc.firstName} ${doc.lastName}`,\n };\n};"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "createBeforeValidateHook",
3
+ "description": "Creates a Payload CMS 3.0 BeforeValidateHook configuration",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "properties": {}
7
+ },
8
+ "template": "/**\n * This hook runs before validation occurs\n * It allows you to modify the data before validation\n */\nconst beforeValidateHook = ({ data, req, operation, originalDoc }) => {\n // 'data' contains the data to be validated\n // 'req' is the Express request object with the Payload instance\n // 'operation' is either 'create' or 'update'\n // 'originalDoc' is the document before changes (for updates)\n \n // Example: Set default values\n return {\n ...data,\n status: data.status || 'draft',\n };\n};"
9
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "createBlocksField",
3
+ "description": "Creates a Payload CMS 3.0 BlocksField configuration\n\nExample:\n```typescript\n{\n name: 'blocksField',\n type: 'blocks',\n required: true,\n label: 'Blocks Field',\n // Custom validation example\n validate: (value, { siblingData, operation }) => {\n // Validation logic based on the value, sibling data, or operation\n if (operation === 'create' && !value) {\n return 'This field is required for new records';\n }\n return true;\n }\n}\n```",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "description": "Payload.BlocksField configuration object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "The name of the field, used as the property name in the database"
11
+ },
12
+ "type": {
13
+ "type": "string",
14
+ "enum": [
15
+ "blocks"
16
+ ],
17
+ "description": "The type of field"
18
+ },
19
+ "label": {
20
+ "type": "string",
21
+ "description": "The label shown in the admin UI"
22
+ },
23
+ "required": {
24
+ "type": "boolean",
25
+ "description": "Whether this field is required"
26
+ },
27
+ "admin": {
28
+ "type": "object",
29
+ "description": "Admin panel configuration for this field",
30
+ "properties": {
31
+ "description": {
32
+ "type": "string",
33
+ "description": "Additional description shown in the admin UI"
34
+ },
35
+ "position": {
36
+ "type": "string",
37
+ "enum": [
38
+ "sidebar"
39
+ ],
40
+ "description": "Position of the field in the admin UI"
41
+ },
42
+ "width": {
43
+ "type": "string",
44
+ "description": "Width of the field in the admin UI"
45
+ },
46
+ "style": {
47
+ "type": "object",
48
+ "description": "Custom CSS styles for the field"
49
+ },
50
+ "className": {
51
+ "type": "string",
52
+ "description": "CSS class name for the field"
53
+ },
54
+ "readOnly": {
55
+ "type": "boolean",
56
+ "description": "Whether the field is read-only in the admin UI"
57
+ },
58
+ "hidden": {
59
+ "type": "boolean",
60
+ "description": "Whether the field is hidden in the admin UI"
61
+ },
62
+ "condition": {
63
+ "type": "string",
64
+ "description": "Condition for showing/hiding the field"
65
+ }
66
+ }
67
+ },
68
+ "validate": {
69
+ "type": "string",
70
+ "description": "Custom validation function that returns true if valid or an error message string if invalid"
71
+ }
72
+ },
73
+ "required": [
74
+ "name",
75
+ "type"
76
+ ]
77
+ },
78
+ "template": "{\n name: '{name}', // Database field name\n type: 'blocks',\n label: 'Blocks Field', // Label shown in the admin UI\n minRows: 1,\n maxRows: 10,\n blocks: [\n {\n slug: 'textBlock',\n fields: [\n {\n name: 'text',\n type: 'richText',\n required: true,\n },\n ],\n },\n {\n slug: 'imageBlock',\n fields: [\n {\n name: 'image',\n type: 'upload',\n relationTo: 'media',\n required: true,\n },\n ],\n },\n // Add more block types as needed\n ],\n // Optional: Add custom validation\n validate: (value) => {\n if (value && value.length > 0) {\n // Validate the blocks as a whole\n return true;\n }\n return 'Please add at least one block';\n },\n}"
79
+ }
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "createCodeField",
3
+ "description": "Creates a Payload CMS 3.0 CodeField configuration\n\nExample:\n```typescript\n{\n name: 'codeField',\n type: 'code',\n required: true,\n label: 'Code Field',\n // Custom validation example\n validate: (value, { siblingData, operation }) => {\n // Validation logic based on the value, sibling data, or operation\n if (operation === 'create' && !value) {\n return 'This field is required for new records';\n }\n return true;\n }\n}\n```",
4
+ "inputSchema": {
5
+ "type": "object",
6
+ "description": "Payload.CodeField configuration object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "The name of the field, used as the property name in the database"
11
+ },
12
+ "type": {
13
+ "type": "string",
14
+ "enum": [
15
+ "code"
16
+ ],
17
+ "description": "The type of field"
18
+ },
19
+ "label": {
20
+ "type": "string",
21
+ "description": "The label shown in the admin UI"
22
+ },
23
+ "required": {
24
+ "type": "boolean",
25
+ "description": "Whether this field is required"
26
+ },
27
+ "admin": {
28
+ "type": "object",
29
+ "description": "Admin panel configuration for this field",
30
+ "properties": {
31
+ "description": {
32
+ "type": "string",
33
+ "description": "Additional description shown in the admin UI"
34
+ },
35
+ "position": {
36
+ "type": "string",
37
+ "enum": [
38
+ "sidebar"
39
+ ],
40
+ "description": "Position of the field in the admin UI"
41
+ },
42
+ "width": {
43
+ "type": "string",
44
+ "description": "Width of the field in the admin UI"
45
+ },
46
+ "style": {
47
+ "type": "object",
48
+ "description": "Custom CSS styles for the field"
49
+ },
50
+ "className": {
51
+ "type": "string",
52
+ "description": "CSS class name for the field"
53
+ },
54
+ "readOnly": {
55
+ "type": "boolean",
56
+ "description": "Whether the field is read-only in the admin UI"
57
+ },
58
+ "hidden": {
59
+ "type": "boolean",
60
+ "description": "Whether the field is hidden in the admin UI"
61
+ },
62
+ "condition": {
63
+ "type": "string",
64
+ "description": "Condition for showing/hiding the field"
65
+ }
66
+ }
67
+ },
68
+ "validate": {
69
+ "type": "string",
70
+ "description": "Custom validation function that returns true if valid or an error message string if invalid"
71
+ }
72
+ },
73
+ "required": [
74
+ "name",
75
+ "type"
76
+ ]
77
+ },
78
+ "template": "{\n name: '{name}', // Database field name\n type: 'code',\n label: 'Code Field', // Label shown in the admin UI\n admin: {\n language: 'javascript', // The language for syntax highlighting\n },\n // Optional: Add custom validation\n validate: (value) => {\n if (value && value.length < 10) {\n return 'Please enter more code';\n }\n return true; // Return true if valid\n },\n}"
79
+ }