@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.
@@ -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 { collection, doc } = target;
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: { ...req.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: collection.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: collection.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 ${collection.slug} draft: ${error instanceof Error ? error.message : "unknown error"}`);
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",
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",