Drop n8n createDraftVersion, add body to update

Remove the createDraftVersion document operation from the n8n node and
instead expose the document body on the update operation. Updating the
body edits the current draft version, or creates one from the latest
published version when none exists, so a dedicated draft-creation
operation is redundant.

Also correct the content field help text across the document
operations: the API expects a ProseMirror document JSON string, not
markdown.

Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
Sacha Al Himdani
2026-07-03 14:00:48 +02:00
parent 73023fc2b8
commit 2955820ac6
5 changed files with 28 additions and 81 deletions

View File

@@ -43,6 +43,16 @@ export const description: INodeProperties[] = [
},
},
options: [
{
displayName: 'Content',
name: 'content',
type: 'string',
typeOptions: {
rows: 6,
},
default: '',
description: 'The body of the document as a ProseMirror document JSON string. Updating it edits the current draft version, creating one from the latest published version if none exists.',
},
{
displayName: 'Trust Center Visibility',
name: 'trustCenterVisibility',
@@ -72,6 +82,7 @@ export async function execute(
): Promise<INodeExecutionData> {
const documentId = this.getNodeParameter('documentId', itemIndex) as string;
const updateFields = this.getNodeParameter('updateFields', itemIndex, {}) as {
content?: string;
trustCenterVisibility?: string;
defaultApproverIds?: string;
};
@@ -89,11 +100,26 @@ export async function execute(
createdAt
updatedAt
}
documentVersion {
id
title
major
minor
status
content
changelog
classification
documentType
publishedAt
createdAt
updatedAt
}
}
}
`;
const input: Record<string, unknown> = { id: documentId };
if (updateFields.content !== undefined) input.content = updateFields.content;
if (updateFields.trustCenterVisibility !== undefined) input.trustCenterVisibility = updateFields.trustCenterVisibility;
if (updateFields.defaultApproverIds !== undefined && updateFields.defaultApproverIds !== '') {
input.defaultApproverIds = updateFields.defaultApproverIds.split(',').map(id => id.trim()).filter(Boolean);