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

@@ -103,7 +103,7 @@ export const description: INodeProperties[] = [
},
},
default: '',
description: 'The content of the document in markdown format',
description: 'The content of the document as a ProseMirror document JSON string',
},
{
displayName: 'Additional Fields',

View File

@@ -1,70 +0,0 @@
// Copyright (c) 2025-2026 Probo Inc <hello@probo.com>.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { proboApiRequest } from '../../GenericFunctions';
export const description: INodeProperties[] = [
{
displayName: 'Document ID',
name: 'documentId',
type: 'string',
displayOptions: {
show: {
resource: ['document'],
operation: ['createDraftVersion'],
},
},
default: '',
description: 'The ID of the document',
required: true,
},
];
export async function execute(
this: IExecuteFunctions,
itemIndex: number,
): Promise<INodeExecutionData> {
const documentId = this.getNodeParameter('documentId', itemIndex) as string;
const query = `
mutation CreateDraftDocumentVersion($input: CreateDraftDocumentVersionInput!) {
createDraftDocumentVersion(input: $input) {
documentVersionEdge {
node {
id
title
major
minor
status
content
changelog
classification
documentType
publishedAt
createdAt
updatedAt
}
}
}
}
`;
const responseData = await proboApiRequest.call(this, query, { input: { documentID: documentId } });
return {
json: responseData,
pairedItem: { item: itemIndex },
};
}

View File

@@ -23,7 +23,6 @@ import * as unarchiveOp from './unarchive.operation';
import * as getVersionOp from './getVersion.operation';
import * as getLatestPublishedVersionIdOp from './getLatestPublishedVersionId.operation';
import * as getAllVersionsOp from './getAllVersions.operation';
import * as createDraftVersionOp from './createDraftVersion.operation';
import * as updateVersionOp from './updateVersion.operation';
import * as deleteDraftVersionOp from './deleteDraftVersion.operation';
import * as publishOp from './publish.operation';
@@ -67,12 +66,6 @@ export const description: INodeProperties[] = [
description: 'Create a new document',
action: 'Create a document',
},
{
name: 'Create Draft Version',
value: 'createDraftVersion',
description: 'Create a new draft version from the latest published version',
action: 'Create a draft document version',
},
{
name: 'Delete',
value: 'delete',
@@ -200,7 +193,6 @@ export const description: INodeProperties[] = [
...getVersionOp.description,
...getLatestPublishedVersionIdOp.description,
...getAllVersionsOp.description,
...createDraftVersionOp.description,
...updateVersionOp.description,
...deleteDraftVersionOp.description,
...publishOp.description,
@@ -226,7 +218,6 @@ export {
getVersionOp as getVersion,
getLatestPublishedVersionIdOp as getLatestPublishedVersionId,
getAllVersionsOp as getAllVersions,
createDraftVersionOp as createDraftVersion,
updateVersionOp as updateVersion,
deleteDraftVersionOp as deleteDraftVersion,
publishOp as publish,

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);

View File

@@ -58,7 +58,7 @@ export const description: INodeProperties[] = [
rows: 6,
},
default: '',
description: 'The content of the document in markdown format',
description: 'The content of the document as a ProseMirror document JSON string',
},
{
displayName: 'Classification',