Files
probo/packages/n8n-node/nodes/Probo/actions/execute/execute.operation.ts
Sacha Al Himdani 4982c67891 Fix npm deprecation warnings and minimize dependency overrides
Bump @n8n/node-cli to 0.37.1 (the `^0.24.1` range was trapping it at
0.24.x), which pulls an updated toolchain and clears the eslint@8,
glob@7, inflight, rimraf@3, @humanwhocodes/*, node-domexception and
uuid@10 deprecation warnings at the source.

Add a glob override (^13.0.6) so rimraf@6 no longer pulls the
deprecated glob@11, and trim the overrides list down to the three that
actually do work (uuid, js-yaml, glob); the rest were redundant or dead.
npm audit reports 0 vulnerabilities.

The upgraded @n8n/eslint-plugin-community-nodes rules flagged two
pre-existing issues in the Probo node, now fixed: handle
continueOnFail() in execute() and throw NodeOperationError instead of
raw Error.

The only remaining warning is @langchain/community, whose entire
package is deprecated upstream and is a hard dependency of
@n8n/ai-utilities.

Signed-off-by: Sacha Al Himdani <sacha@probo.com>
2026-06-29 15:20:07 +02:00

120 lines
3.7 KiB
TypeScript

// 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 { NodeOperationError } from 'n8n-workflow';
import { proboApiRequest, proboConnectApiRequest } from '../../GenericFunctions';
export const description: INodeProperties[] = [
{
displayName: 'API',
name: 'api',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['execute'],
},
},
options: [
{
name: 'Console API',
value: 'console',
description: 'Call the Console GraphQL API (/api/console/v1/graphql)',
},
{
name: 'Connect API',
value: 'connect',
description: 'Call the Connect GraphQL API (/api/connect/v1/graphql)',
},
],
default: 'console',
description: 'Which Probo API to call',
},
{
displayName: 'Query',
name: 'query',
type: 'string',
typeOptions: {
rows: 5,
},
displayOptions: {
show: {
resource: ['execute'],
},
},
default: '',
description: 'The complete GraphQL operation including operation name and variable declarations (e.g., "query GetUser($userId: ID!) { node(ID: $userId) { ID } }" or "mutation UpdateUser($input: UpdateUserInput!) { updateUser(input: $input) { ID } }")',
required: true,
},
{
displayName: 'Variables',
name: 'variables',
type: 'json',
displayOptions: {
show: {
resource: ['execute'],
},
},
default: '{}',
description: 'GraphQL variables as JSON object',
},
];
export async function execute(
this: IExecuteFunctions,
itemIndex: number,
): Promise<INodeExecutionData> {
const api = this.getNodeParameter('api', itemIndex, 'console') as string;
const query = this.getNodeParameter('query', itemIndex) as string;
const variablesParam = this.getNodeParameter('variables', itemIndex) as string;
// Basic validation: check if query contains a GraphQL operation
const trimmedQuery = query.trim();
if (!trimmedQuery) {
throw new NodeOperationError(this.getNode(), 'GraphQL query cannot be empty', { itemIndex });
}
// Check for operation type (query, mutation, or subscription)
const operationMatch = trimmedQuery.match(/^\s*(query|mutation|subscription)\s+(\w+)/i);
if (!operationMatch) {
throw new NodeOperationError(
this.getNode(),
'GraphQL operation must start with "query", "mutation", or "subscription" followed by an operation name (e.g., "query GetUser { ... }" or "mutation UpdateUser { ... }")',
{ itemIndex },
);
}
let variables = {};
if (variablesParam) {
try {
variables =
typeof variablesParam === 'string' ? JSON.parse(variablesParam) : variablesParam;
} catch (error) {
throw new NodeOperationError(this.getNode(), error as Error, {
itemIndex,
description: 'Invalid JSON in Variables',
});
}
}
const requestFn = api === 'connect' ? proboConnectApiRequest : proboApiRequest;
const responseData = await requestFn.call(this, query, variables);
return {
json: responseData,
pairedItem: { item: itemIndex },
};
}