// Copyright (c) 2025-2026 Probo Inc . // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; import { proboApiRequest } from '../../GenericFunctions'; export const description: INodeProperties[] = [ { displayName: 'Organization ID', name: 'organizationId', type: 'string', displayOptions: { show: { resource: ['finding'], operation: ['create'], }, }, default: '', description: 'The ID of the organization', required: true, }, { displayName: 'Kind', name: 'kind', type: 'options', displayOptions: { show: { resource: ['finding'], operation: ['create'], }, }, options: [ { name: 'Minor Nonconformity', value: 'MINOR_NONCONFORMITY', }, { name: 'Major Nonconformity', value: 'MAJOR_NONCONFORMITY', }, { name: 'Observation', value: 'OBSERVATION', }, { name: 'Exception', value: 'EXCEPTION', }, ], default: 'MINOR_NONCONFORMITY', description: 'The kind of finding', required: true, }, { displayName: 'Description', name: 'description', type: 'string', displayOptions: { show: { resource: ['finding'], operation: ['create'], }, }, default: '', description: 'The description of the finding', required: true, }, { displayName: 'Additional Fields', name: 'additionalFields', type: 'collection', placeholder: 'Add Field', default: {}, displayOptions: { show: { resource: ['finding'], operation: ['create'], }, }, options: [ { displayName: 'Corrective Action', name: 'correctiveAction', type: 'string', default: '', description: 'The corrective action for the finding', }, { displayName: 'Due Date', name: 'dueDate', type: 'string', default: '', description: 'The due date for the finding (ISO 8601 format)', }, { displayName: 'Effectiveness Check', name: 'effectivenessCheck', type: 'string', default: '', description: 'The effectiveness check for the finding', }, { displayName: 'Identified On', name: 'identifiedOn', type: 'string', default: '', description: 'The date the finding was identified (ISO 8601 format)', }, { displayName: 'Owner ID', name: 'ownerId', type: 'string', default: '', description: 'The ID of the person who owns this finding', }, { displayName: 'Priority', name: 'priority', type: 'options', options: [ { name: 'Low', value: 'LOW', }, { name: 'Medium', value: 'MEDIUM', }, { name: 'High', value: 'HIGH', }, ], default: 'MEDIUM', description: 'The priority of the finding', }, { displayName: 'Risk ID', name: 'riskId', type: 'string', default: '', description: 'The ID of the associated risk', }, { displayName: 'Root Cause', name: 'rootCause', type: 'string', default: '', description: 'The root cause of the finding', }, { displayName: 'Source', name: 'source', type: 'string', default: '', description: 'The source of the finding', }, { displayName: 'Status', name: 'status', type: 'options', options: [ { name: 'Closed', value: 'CLOSED', }, { name: 'False Positive', value: 'FALSE_POSITIVE', }, { name: 'In Progress', value: 'IN_PROGRESS', }, { name: 'Mitigated', value: 'MITIGATED', }, { name: 'Open', value: 'OPEN', }, { name: 'Risk Accepted', value: 'RISK_ACCEPTED', }, ], default: 'OPEN', description: 'The status of the finding', }, ], }, ]; export async function execute( this: IExecuteFunctions, itemIndex: number, ): Promise { const organizationId = this.getNodeParameter('organizationId', itemIndex) as string; const kind = this.getNodeParameter('kind', itemIndex) as string; const description = this.getNodeParameter('description', itemIndex) as string; const additionalFields = this.getNodeParameter('additionalFields', itemIndex, {}) as { source?: string; identifiedOn?: string; rootCause?: string; correctiveAction?: string; ownerId?: string; dueDate?: string; status?: string; priority?: string; riskId?: string; effectivenessCheck?: string; }; const query = ` mutation CreateFinding($input: CreateFindingInput!) { createFinding(input: $input) { findingEdge { node { id kind description source identifiedOn rootCause correctiveAction dueDate status priority effectivenessCheck createdAt updatedAt } } } } `; const input: Record = { organizationId, kind, description, }; if (additionalFields.source) input.source = additionalFields.source; if (additionalFields.identifiedOn) input.identifiedOn = additionalFields.identifiedOn; if (additionalFields.rootCause) input.rootCause = additionalFields.rootCause; if (additionalFields.correctiveAction) input.correctiveAction = additionalFields.correctiveAction; if (additionalFields.ownerId) input.ownerId = additionalFields.ownerId; if (additionalFields.dueDate) input.dueDate = additionalFields.dueDate; if (additionalFields.status) input.status = additionalFields.status; if (additionalFields.priority) input.priority = additionalFields.priority; if (additionalFields.riskId) input.riskId = additionalFields.riskId; if (additionalFields.effectivenessCheck) input.effectivenessCheck = additionalFields.effectivenessCheck; const responseData = await proboApiRequest.call(this, query, { input }); return { json: responseData, pairedItem: { item: itemIndex }, }; }