@@ -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',
|
||||
|
||||
139
packages/n8n-node/nodes/Probo/actions/datum/create.operation.ts
Normal file
139
packages/n8n-node/nodes/Probo/actions/datum/create.operation.ts
Normal file
@@ -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<INodeExecutionData> {
|
||||
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 },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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<INodeExecutionData> {
|
||||
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 },
|
||||
};
|
||||
}
|
||||
|
||||
52
packages/n8n-node/nodes/Probo/actions/datum/get.operation.ts
Normal file
52
packages/n8n-node/nodes/Probo/actions/datum/get.operation.ts
Normal file
@@ -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<INodeExecutionData> {
|
||||
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 },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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<INodeExecutionData> {
|
||||
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 },
|
||||
};
|
||||
}
|
||||
|
||||
61
packages/n8n-node/nodes/Probo/actions/datum/index.ts
Normal file
61
packages/n8n-node/nodes/Probo/actions/datum/index.ts
Normal file
@@ -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 };
|
||||
|
||||
131
packages/n8n-node/nodes/Probo/actions/datum/update.operation.ts
Normal file
131
packages/n8n-node/nodes/Probo/actions/datum/update.operation.ts
Normal file
@@ -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<INodeExecutionData> {
|
||||
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<string, any> = { 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 },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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<string, ResourceModule> = {
|
||||
asset: asset as ResourceModule,
|
||||
control: control as ResourceModule,
|
||||
datum: datum as ResourceModule,
|
||||
execute: execute as ResourceModule,
|
||||
framework: framework as ResourceModule,
|
||||
measure: measure as ResourceModule,
|
||||
|
||||
Reference in New Issue
Block a user