drupal-mcp-connector 3.1.0 → 3.2.0

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.
@@ -198,6 +198,22 @@ export async function writeComponentDraft(backend, input, { dryRun = false } = {
198
198
  }
199
199
  }
200
200
 
201
+ const pinHost = working
202
+ ? await backend.getEntity({ entityType, bundle, id, resourceVersion: `id:${working}` })
203
+ : await backend.getEntity({ entityType, bundle, id });
204
+ if (!pinHost) {
205
+ throw new Error("The host revision could not be read. No write was attempted, and no direct paragraph write was tried.");
206
+ }
207
+ const directIds = new Set(paragraphPinsFromEntity(pinHost).map((pin) => pin.id.toLowerCase()));
208
+ for (const component of components) {
209
+ if (!directIds.has(component.id.toLowerCase())) {
210
+ throw new Error(
211
+ `${component.id} is not a direct paragraph of this host. Nested paragraphs are not component edits. ` +
212
+ "Use drupal_draft_nested_components. No write was attempted, and no direct paragraph write was tried."
213
+ );
214
+ }
215
+ }
216
+
201
217
  const data = { type: `${entityType}--${bundle}`, id, attributes };
202
218
  if (relationships && Object.keys(relationships).length) data.relationships = relationships;
203
219
  const request = { entityType, bundle, id, data, components, live, working, langcode: defaultLang };