// Copyright (c) 2026 Probo Inc . // // 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: 'Process ID', name: 'processId', type: 'string', displayOptions: { show: { resource: ['riskAssessment'], operation: ['updateProcess'], }, }, default: '', description: 'The ID of the process to update', required: true, }, { displayName: 'Additional Fields', name: 'additionalFields', type: 'collection', placeholder: 'Add Field', default: {}, displayOptions: { show: { resource: ['riskAssessment'], operation: ['updateProcess'], }, }, options: [ { displayName: 'Name', name: 'name', type: 'string', default: '', description: 'The name of the process', }, { displayName: 'Source Node ID', name: 'sourceNodeId', type: 'string', default: '', description: 'The ID of the source node', }, { displayName: 'Target Node ID', name: 'targetNodeId', type: 'string', default: '', description: 'The ID of the target node', }, ], }, ]; export async function execute( this: IExecuteFunctions, itemIndex: number, ): Promise { const processId = this.getNodeParameter('processId', itemIndex) as string; const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}) as { name?: string; sourceNodeId?: string; targetNodeId?: string; }; const query = ` mutation UpdateRiskAssessmentProcess($input: UpdateRiskAssessmentProcessInput!) { updateRiskAssessmentProcess(input: $input) { riskAssessmentProcess { id riskAssessmentScopeId sourceNodeId targetNodeId name createdAt updatedAt } } } `; const input: Record = { id: processId }; if (additionalFields.name) input.name = additionalFields.name; if (additionalFields.sourceNodeId) input.sourceNodeId = additionalFields.sourceNodeId; if (additionalFields.targetNodeId) input.targetNodeId = additionalFields.targetNodeId; if (Object.keys(input).length === 1) { throw new Error('At least one field must be provided to update'); } const responseData = await proboApiRequest.call(this, query, { input }); return { json: responseData, pairedItem: { item: itemIndex }, }; }