@abinnovision/payloadcms-mcpx 1.0.0-beta.4 → 1.0.0-beta.5
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/README.md +65 -16
- package/dist/api-keys/fields.mjs +27 -12
- package/dist/capabilities.mjs +16 -3
- package/dist/endpoint/handler.mjs +3 -1
- package/dist/endpoint/server.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/options.d.mts +2 -0
- package/dist/options.mjs +38 -0
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +3 -2
- package/dist/schema/describe.mjs +11 -10
- package/dist/schema/pointer.mjs +2 -2
- package/dist/schema/walk.d.mts +1 -0
- package/dist/schema/walk.mjs +4 -4
- package/dist/tools/create-document.mjs +9 -8
- package/dist/tools/describe-schema.mjs +12 -6
- package/dist/tools/find-documents.mjs +4 -3
- package/dist/tools/get-document.mjs +24 -11
- package/dist/tools/list-capabilities.mjs +19 -1
- package/dist/tools/patch-document.mjs +34 -20
- package/dist/tools/shared.mjs +54 -21
- package/dist/tools/target.d.mts +3 -0
- package/dist/tools/target.mjs +49 -0
- package/dist/tools/types.d.mts +5 -0
- package/dist/tools/validate-document.mjs +22 -15
- package/dist/types.d.mts +25 -2
- package/dist/write/draft-guard.mjs +51 -8
- package/dist/write/patch.mjs +4 -4
- package/dist/write/publish-blockers.d.mts +1 -0
- package/dist/write/publish-blockers.mjs +8 -7
- package/package.json +1 -1
|
@@ -19,19 +19,20 @@ import { beforeChangeTraverseFields, beforeValidateTraverseFields } from "payloa
|
|
|
19
19
|
* Limits: only the locale the doc was read in is checked, and field-level
|
|
20
20
|
* `beforeChange` hooks run again, which is safe only for pure ones.
|
|
21
21
|
*/ const collectPublishBlockers = async (req, target) => {
|
|
22
|
-
const {
|
|
22
|
+
const { doc, entity } = target;
|
|
23
23
|
const id = doc["id"];
|
|
24
24
|
const errors = [];
|
|
25
25
|
const data = {
|
|
26
26
|
...structuredClone(doc),
|
|
27
27
|
_status: "published"
|
|
28
28
|
};
|
|
29
|
+
const context = { ...req.context };
|
|
29
30
|
const shared = {
|
|
30
|
-
collection,
|
|
31
|
-
context
|
|
31
|
+
collection: entity.kind === "collection" ? entity.config : null,
|
|
32
|
+
context,
|
|
32
33
|
data,
|
|
33
34
|
doc,
|
|
34
|
-
global: null,
|
|
35
|
+
global: entity.kind === "global" ? entity.config : null,
|
|
35
36
|
operation: "update",
|
|
36
37
|
overrideAccess: true,
|
|
37
38
|
parentIndexPath: "",
|
|
@@ -45,7 +46,7 @@ import { beforeChangeTraverseFields, beforeValidateTraverseFields } from "payloa
|
|
|
45
46
|
try {
|
|
46
47
|
await beforeValidateTraverseFields({
|
|
47
48
|
...shared,
|
|
48
|
-
fields:
|
|
49
|
+
fields: entity.config.fields,
|
|
49
50
|
siblingData: data
|
|
50
51
|
});
|
|
51
52
|
await beforeChangeTraverseFields({
|
|
@@ -53,14 +54,14 @@ import { beforeChangeTraverseFields, beforeValidateTraverseFields } from "payloa
|
|
|
53
54
|
docWithLocales: doc,
|
|
54
55
|
errors,
|
|
55
56
|
fieldLabelPath: "",
|
|
56
|
-
fields:
|
|
57
|
+
fields: entity.config.fields,
|
|
57
58
|
mergeLocaleActions: [],
|
|
58
59
|
siblingData: data,
|
|
59
60
|
siblingDocWithLocales: doc,
|
|
60
61
|
skipValidation: false
|
|
61
62
|
});
|
|
62
63
|
} catch (error) {
|
|
63
|
-
req.payload.logger.warn(`[payloadcms-mcpx] Could not validate the ${
|
|
64
|
+
req.payload.logger.warn(`[payloadcms-mcpx] Could not validate the ${entity.slug} draft: ${error instanceof Error ? error.message : "unknown error"}`);
|
|
64
65
|
return [];
|
|
65
66
|
}
|
|
66
67
|
return errors.map((error) => ({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@abinnovision/payloadcms-mcpx",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.5",
|
|
5
5
|
"description": "Payload CMS plugin exposing a fixed, schema-aware MCP tool surface with draft-only writes and per-API-key capabilities.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"payload",
|