From c26b0d842369ed9346c0798557bf9bacb9fa3af3 Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Tue, 2 Dec 2025 10:50:14 +0100 Subject: [PATCH] Add datum operations Signed-off-by: Bryan Frimin --- packages/n8n-node/nodes/Probo/Probo.node.ts | 5 + .../Probo/actions/datum/create.operation.ts | 139 ++++++++++++++++++ .../Probo/actions/datum/delete.operation.ts | 42 ++++++ .../Probo/actions/datum/get.operation.ts | 52 +++++++ .../Probo/actions/datum/getAll.operation.ts | 97 ++++++++++++ .../nodes/Probo/actions/datum/index.ts | 61 ++++++++ .../Probo/actions/datum/update.operation.ts | 131 +++++++++++++++++ .../n8n-node/nodes/Probo/actions/index.ts | 2 + 8 files changed, 529 insertions(+) create mode 100644 packages/n8n-node/nodes/Probo/actions/datum/create.operation.ts create mode 100644 packages/n8n-node/nodes/Probo/actions/datum/delete.operation.ts create mode 100644 packages/n8n-node/nodes/Probo/actions/datum/get.operation.ts create mode 100644 packages/n8n-node/nodes/Probo/actions/datum/getAll.operation.ts create mode 100644 packages/n8n-node/nodes/Probo/actions/datum/index.ts create mode 100644 packages/n8n-node/nodes/Probo/actions/datum/update.operation.ts diff --git a/packages/n8n-node/nodes/Probo/Probo.node.ts b/packages/n8n-node/nodes/Probo/Probo.node.ts index 336efe7ff..57a736410 100644 --- a/packages/n8n-node/nodes/Probo/Probo.node.ts +++ b/packages/n8n-node/nodes/Probo/Probo.node.ts @@ -72,6 +72,11 @@ export class Probo implements INodeType { value: 'control', description: 'Manage controls', }, + { + name: 'Data', + value: 'datum', + description: 'Manage data', + }, { name: 'Execute', value: 'execute', diff --git a/packages/n8n-node/nodes/Probo/actions/datum/create.operation.ts b/packages/n8n-node/nodes/Probo/actions/datum/create.operation.ts new file mode 100644 index 000000000..7e2764a8d --- /dev/null +++ b/packages/n8n-node/nodes/Probo/actions/datum/create.operation.ts @@ -0,0 +1,139 @@ +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: ['datum'], + operation: ['create'], + }, + }, + default: '', + description: 'The ID of the organization', + required: true, + }, + { + displayName: 'Name', + name: 'name', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['create'], + }, + }, + default: '', + description: 'The name of the datum', + required: true, + }, + { + displayName: 'Data Classification', + name: 'dataClassification', + type: 'options', + displayOptions: { + show: { + resource: ['datum'], + operation: ['create'], + }, + }, + options: [ + { + name: 'Public', + value: 'PUBLIC', + }, + { + name: 'Internal', + value: 'INTERNAL', + }, + { + name: 'Confidential', + value: 'CONFIDENTIAL', + }, + { + name: 'Secret', + value: 'SECRET', + }, + ], + default: 'INTERNAL', + description: 'The classification of the data', + required: true, + }, + { + displayName: 'Owner ID', + name: 'ownerId', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['create'], + }, + }, + default: '', + description: 'The ID of the owner (People)', + required: true, + }, + { + displayName: 'Vendor IDs', + name: 'vendorIds', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['create'], + }, + }, + default: '', + description: 'Comma-separated list of vendor IDs', + }, +]; + +export async function execute( + this: IExecuteFunctions, + itemIndex: number, +): Promise { + const organizationId = this.getNodeParameter('organizationId', itemIndex) as string; + const name = this.getNodeParameter('name', itemIndex) as string; + const dataClassification = this.getNodeParameter('dataClassification', itemIndex) as string; + const ownerId = this.getNodeParameter('ownerId', itemIndex) as string; + const vendorIdsStr = this.getNodeParameter('vendorIds', itemIndex, '') as string; + + const query = ` + mutation CreateDatum($input: CreateDatumInput!) { + createDatum(input: $input) { + datumEdge { + node { + id + name + dataClassification + createdAt + updatedAt + } + } + } + } + `; + + const vendorIds = vendorIdsStr ? vendorIdsStr.split(',').map((id) => id.trim()).filter(Boolean) : undefined; + + const variables = { + input: { + organizationId, + name, + dataClassification, + ownerId, + ...(vendorIds && vendorIds.length > 0 && { vendorIds }), + }, + }; + + const responseData = await proboApiRequest.call(this, query, variables); + + return { + json: responseData, + pairedItem: { item: itemIndex }, + }; +} + diff --git a/packages/n8n-node/nodes/Probo/actions/datum/delete.operation.ts b/packages/n8n-node/nodes/Probo/actions/datum/delete.operation.ts new file mode 100644 index 000000000..68cef7f45 --- /dev/null +++ b/packages/n8n-node/nodes/Probo/actions/datum/delete.operation.ts @@ -0,0 +1,42 @@ +import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; +import { proboApiRequest } from '../../GenericFunctions'; + +export const description: INodeProperties[] = [ + { + displayName: 'Datum ID', + name: 'datumId', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['delete'], + }, + }, + default: '', + description: 'The ID of the datum to delete', + required: true, + }, +]; + +export async function execute( + this: IExecuteFunctions, + itemIndex: number, +): Promise { + const datumId = this.getNodeParameter('datumId', itemIndex) as string; + + const query = ` + mutation DeleteDatum($input: DeleteDatumInput!) { + deleteDatum(input: $input) { + deletedDatumId + } + } + `; + + const responseData = await proboApiRequest.call(this, query, { input: { datumId } }); + + return { + json: responseData, + pairedItem: { item: itemIndex }, + }; +} + diff --git a/packages/n8n-node/nodes/Probo/actions/datum/get.operation.ts b/packages/n8n-node/nodes/Probo/actions/datum/get.operation.ts new file mode 100644 index 000000000..0727ea11f --- /dev/null +++ b/packages/n8n-node/nodes/Probo/actions/datum/get.operation.ts @@ -0,0 +1,52 @@ +import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; +import { proboApiRequest } from '../../GenericFunctions'; + +export const description: INodeProperties[] = [ + { + displayName: 'Datum ID', + name: 'datumId', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['get'], + }, + }, + default: '', + description: 'The ID of the datum', + required: true, + }, +]; + +export async function execute( + this: IExecuteFunctions, + itemIndex: number, +): Promise { + const datumId = this.getNodeParameter('datumId', itemIndex) as string; + + const query = ` + query GetDatum($datumId: ID!) { + node(id: $datumId) { + ... on Datum { + id + name + dataClassification + createdAt + updatedAt + } + } + } + `; + + const variables = { + datumId, + }; + + const responseData = await proboApiRequest.call(this, query, variables); + + return { + json: responseData, + pairedItem: { item: itemIndex }, + }; +} + diff --git a/packages/n8n-node/nodes/Probo/actions/datum/getAll.operation.ts b/packages/n8n-node/nodes/Probo/actions/datum/getAll.operation.ts new file mode 100644 index 000000000..20ba5e6f8 --- /dev/null +++ b/packages/n8n-node/nodes/Probo/actions/datum/getAll.operation.ts @@ -0,0 +1,97 @@ +import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; +import { proboApiRequestAllItems } from '../../GenericFunctions'; + +export const description: INodeProperties[] = [ + { + displayName: 'Organization ID', + name: 'organizationId', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['getAll'], + }, + }, + default: '', + description: 'The ID of the organization', + required: true, + }, + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + resource: ['datum'], + operation: ['getAll'], + }, + }, + default: false, + description: 'Whether to return all results or only up to a given limit', + }, + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + resource: ['datum'], + operation: ['getAll'], + returnAll: [false], + }, + }, + typeOptions: { + minValue: 1, + }, + default: 50, + description: 'Max number of results to return', + }, +]; + +export async function execute( + this: IExecuteFunctions, + itemIndex: number, +): Promise { + const organizationId = this.getNodeParameter('organizationId', itemIndex) as string; + const returnAll = this.getNodeParameter('returnAll', itemIndex) as boolean; + const limit = this.getNodeParameter('limit', itemIndex, 50) as number; + + const query = ` + query GetData($organizationId: ID!, $first: Int, $after: CursorKey) { + node(id: $organizationId) { + ... on Organization { + data(first: $first, after: $after) { + edges { + node { + id + name + dataClassification + createdAt + updatedAt + } + } + pageInfo { + hasNextPage + endCursor + } + } + } + } + } + `; + + const data = await proboApiRequestAllItems.call( + this, + query, + { organizationId }, + (response) => response?.data?.node?.data, + returnAll, + limit, + ); + + return { + json: { data }, + pairedItem: { item: itemIndex }, + }; +} + diff --git a/packages/n8n-node/nodes/Probo/actions/datum/index.ts b/packages/n8n-node/nodes/Probo/actions/datum/index.ts new file mode 100644 index 000000000..10472f274 --- /dev/null +++ b/packages/n8n-node/nodes/Probo/actions/datum/index.ts @@ -0,0 +1,61 @@ +import type { INodeProperties } from 'n8n-workflow'; +import * as createOp from './create.operation'; +import * as updateOp from './update.operation'; +import * as deleteOp from './delete.operation'; +import * as getOp from './get.operation'; +import * as getAllOp from './getAll.operation'; + +export const description: INodeProperties[] = [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + noDataExpression: true, + displayOptions: { + show: { + resource: ['datum'], + }, + }, + options: [ + { + name: 'Create', + value: 'create', + description: 'Create a new datum', + action: 'Create a datum', + }, + { + name: 'Delete', + value: 'delete', + description: 'Delete a datum', + action: 'Delete a datum', + }, + { + name: 'Get', + value: 'get', + description: 'Get a datum', + action: 'Get a datum', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get all data', + action: 'Get all data', + }, + { + name: 'Update', + value: 'update', + description: 'Update an existing datum', + action: 'Update a datum', + }, + ], + default: 'create', + }, + ...createOp.description, + ...updateOp.description, + ...deleteOp.description, + ...getOp.description, + ...getAllOp.description, +]; + +export { createOp as create, updateOp as update, deleteOp as delete, getOp as get, getAllOp as getAll }; + diff --git a/packages/n8n-node/nodes/Probo/actions/datum/update.operation.ts b/packages/n8n-node/nodes/Probo/actions/datum/update.operation.ts new file mode 100644 index 000000000..1e320289e --- /dev/null +++ b/packages/n8n-node/nodes/Probo/actions/datum/update.operation.ts @@ -0,0 +1,131 @@ +import type { INodeProperties, IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; +import { proboApiRequest } from '../../GenericFunctions'; + +export const description: INodeProperties[] = [ + { + displayName: 'Datum ID', + name: 'id', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['update'], + }, + }, + default: '', + description: 'The ID of the datum to update', + required: true, + }, + { + displayName: 'Name', + name: 'name', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['update'], + }, + }, + default: '', + description: 'The name of the datum', + }, + { + displayName: 'Data Classification', + name: 'dataClassification', + type: 'options', + displayOptions: { + show: { + resource: ['datum'], + operation: ['update'], + }, + }, + options: [ + { + name: 'Public', + value: 'PUBLIC', + }, + { + name: 'Internal', + value: 'INTERNAL', + }, + { + name: 'Confidential', + value: 'CONFIDENTIAL', + }, + { + name: 'Secret', + value: 'SECRET', + }, + ], + default: '', + description: 'The classification of the data', + }, + { + displayName: 'Owner ID', + name: 'ownerId', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['update'], + }, + }, + default: '', + description: 'The ID of the owner (People)', + }, + { + displayName: 'Vendor IDs', + name: 'vendorIds', + type: 'string', + displayOptions: { + show: { + resource: ['datum'], + operation: ['update'], + }, + }, + default: '', + description: 'Comma-separated list of vendor IDs', + }, +]; + +export async function execute( + this: IExecuteFunctions, + itemIndex: number, +): Promise { + const id = this.getNodeParameter('id', itemIndex) as string; + const name = this.getNodeParameter('name', itemIndex, '') as string; + const dataClassification = this.getNodeParameter('dataClassification', itemIndex, '') as string; + const ownerId = this.getNodeParameter('ownerId', itemIndex, '') as string; + const vendorIdsStr = this.getNodeParameter('vendorIds', itemIndex, '') as string; + + const query = ` + mutation UpdateDatum($input: UpdateDatumInput!) { + updateDatum(input: $input) { + datum { + id + name + dataClassification + createdAt + updatedAt + } + } + } + `; + + const input: Record = { id }; + if (name) input.name = name; + if (dataClassification) input.dataClassification = dataClassification; + if (ownerId) input.ownerId = ownerId; + if (vendorIdsStr) { + const vendorIds = vendorIdsStr.split(',').map((vid) => vid.trim()).filter(Boolean); + if (vendorIds.length > 0) input.vendorIds = vendorIds; + } + + const responseData = await proboApiRequest.call(this, query, { input }); + + return { + json: responseData, + pairedItem: { item: itemIndex }, + }; +} + diff --git a/packages/n8n-node/nodes/Probo/actions/index.ts b/packages/n8n-node/nodes/Probo/actions/index.ts index dfe9bdd8f..d45ac75e8 100644 --- a/packages/n8n-node/nodes/Probo/actions/index.ts +++ b/packages/n8n-node/nodes/Probo/actions/index.ts @@ -1,6 +1,7 @@ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow'; import * as asset from './asset'; import * as control from './control'; +import * as datum from './datum'; import * as execute from './execute'; import * as framework from './framework'; import * as measure from './measure'; @@ -18,6 +19,7 @@ export interface OperationModule { export const resources: Record = { asset: asset as ResourceModule, control: control as ResourceModule, + datum: datum as ResourceModule, execute: execute as ResourceModule, framework: framework as ResourceModule, measure: measure as ResourceModule,