mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
+ added new tools
This commit is contained in:
@@ -7,7 +7,7 @@ export class UProcApi implements ICredentialType {
|
|||||||
name = 'uprocApi';
|
name = 'uprocApi';
|
||||||
displayName = 'uProc API';
|
displayName = 'uProc API';
|
||||||
properties = [
|
properties = [
|
||||||
{
|
{
|
||||||
displayName: 'Email',
|
displayName: 'Email',
|
||||||
name: 'email',
|
name: 'email',
|
||||||
type: 'string' as NodePropertyTypes,
|
type: 'string' as NodePropertyTypes,
|
||||||
|
|||||||
@@ -20,12 +20,15 @@ export async function uprocApiRequest(this: IHookFunctions | IExecuteFunctions |
|
|||||||
}
|
}
|
||||||
const token = Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString('base64');
|
const token = Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString('base64');
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: { Authorization: `Basic ${token}` },
|
headers: {
|
||||||
|
Authorization: `Basic ${token}`,
|
||||||
|
"User-agent": "n8n"
|
||||||
|
},
|
||||||
method,
|
method,
|
||||||
qs,
|
qs,
|
||||||
body,
|
body,
|
||||||
uri: uri || `https://api.uproc.io/api/v2/process`,
|
uri: uri || `https://api.uproc.io/api/v2/process`,
|
||||||
json: true,
|
json: true
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
IDataObject,
|
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
|
IDataObject,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -18,7 +18,7 @@ const finalGroups = {
|
|||||||
|
|
||||||
const options = [];
|
const options = [];
|
||||||
|
|
||||||
for (const group of (groups as IDataObject).groups as IDataObject[]) {
|
for(const group of (groups as IDataObject).groups as IDataObject[]){
|
||||||
const item = {
|
const item = {
|
||||||
name: group.translated,
|
name: group.translated,
|
||||||
value: group.name,
|
value: group.name,
|
||||||
|
|||||||
@@ -1,36 +1,36 @@
|
|||||||
export const groups = {
|
export const groups = {
|
||||||
groups: [{
|
groups: [{
|
||||||
'translated': 'Audio',
|
"translated": "Audio",
|
||||||
'name': 'audio',
|
"name": "audio"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Communication',
|
"translated": "Communication",
|
||||||
'name': 'communication',
|
"name": "communication"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Company',
|
"translated": "Company",
|
||||||
'name': 'company',
|
"name": "company"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Finance',
|
"translated": "Finance",
|
||||||
'name': 'finance',
|
"name": "finance"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Geographical',
|
"translated": "Geographical",
|
||||||
'name': 'geographic',
|
"name": "geographic"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Image',
|
"translated": "Image",
|
||||||
'name': 'image',
|
"name": "image"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Internet',
|
"translated": "Internet",
|
||||||
'name': 'internet',
|
"name": "internet"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Personal',
|
"translated": "Personal",
|
||||||
'name': 'personal',
|
"name": "personal"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Product',
|
"translated": "Product",
|
||||||
'name': 'product',
|
"name": "product"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Security',
|
"translated": "Security",
|
||||||
'name': 'security',
|
"name": "security"
|
||||||
}, {
|
}, {
|
||||||
'translated': 'Text',
|
"translated": "Text",
|
||||||
'name': 'text',
|
"name": "text"
|
||||||
}],
|
}]
|
||||||
};
|
};
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
IDataObject,
|
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
|
IDataObject,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -21,7 +21,7 @@ function capitalize(str: string): string {
|
|||||||
|
|
||||||
const operations = [];
|
const operations = [];
|
||||||
|
|
||||||
for (const group of (groups as IDataObject).groups as IDataObject[]) {
|
for(const group of (groups as IDataObject).groups as IDataObject[]) {
|
||||||
const item = {
|
const item = {
|
||||||
displayName: 'Operation',
|
displayName: 'Operation',
|
||||||
name: 'tool',
|
name: 'tool',
|
||||||
@@ -30,30 +30,30 @@ for (const group of (groups as IDataObject).groups as IDataObject[]) {
|
|||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
group: [
|
group: [
|
||||||
group.name,
|
group.name
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
options: [],
|
options: []
|
||||||
};
|
};
|
||||||
|
|
||||||
const options = [];
|
const options = [];
|
||||||
for (const tool of (tools as IDataObject).processors as IDataObject[]) {
|
for(const tool of (tools as IDataObject).processors as IDataObject[]){
|
||||||
if (tool.g === group.name) {
|
if (tool.g === group.name) {
|
||||||
const link = 'https://app.uproc.io/#/tools/processor/' + (tool.k as string).replace(/([A-Z]+)/g, '-$1').toLowerCase().replace('-', '/').replace('-', '/');
|
const link = 'https://app.uproc.io/#/tools/processor/' + (tool.k as string).replace(/([A-Z]+)/g, "-$1").toLowerCase().replace('-', '/').replace('-', '/');
|
||||||
const option = {
|
const option = {
|
||||||
name: tool.d as string,
|
name: tool.d as string,
|
||||||
value: tool.k,
|
value: tool.k,
|
||||||
description: (tool.ed as string) + ` <a href="${link}" target='_blank'>Info</a>`,
|
description: (tool.ed as string) + " <a href='" + link + "' target='_blank'>Info</a>"
|
||||||
};
|
};
|
||||||
options.push(option);
|
options.push(option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Tool
|
//Tool
|
||||||
item.options = (options.sort((a, b) => (a.name > b.name) ? 1 : -1) as any); // tslint:disable-line:no-any
|
item.options = <any>options.sort((a, b) => (a.name > b.name) ? 1 : -1);
|
||||||
item.default = (options[0].value as string);
|
item.default = <string>options[0].value;
|
||||||
operations.push(item);
|
operations.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,12 +61,12 @@ export const toolOperations = operations as INodeProperties[];
|
|||||||
|
|
||||||
let parameters = [];
|
let parameters = [];
|
||||||
//all tools
|
//all tools
|
||||||
for (const tool of (tools as IDataObject).processors as IDataObject[]) {
|
for(const tool of (tools as IDataObject).processors as IDataObject[]) {
|
||||||
//all parameters in tool
|
//all parameters in tool
|
||||||
for (const param of (tool as IDataObject).p as IDataObject[]) {
|
for (const param of (tool as IDataObject).p as IDataObject[]) {
|
||||||
const displayName = param.n as string;
|
const displayName = param.n as string;
|
||||||
const capitalizedDisplayName = capitalize(displayName.replace(/_/g, ' '));
|
const capitalizedDisplayName = capitalize(displayName.replace(/_/g, " "));
|
||||||
const description = `The "${capitalizedDisplayName}" value to use as a parameter for this Operation`;
|
const description = "The '" + capitalizedDisplayName + "' value to use as a parameter for this Operation";
|
||||||
const parameter = {
|
const parameter = {
|
||||||
displayName: capitalizedDisplayName,
|
displayName: capitalizedDisplayName,
|
||||||
name: param.n,
|
name: param.n,
|
||||||
@@ -82,7 +82,7 @@ for (const tool of (tools as IDataObject).processors as IDataObject[]) {
|
|||||||
tool.g,
|
tool.g,
|
||||||
],
|
],
|
||||||
tool: [
|
tool: [
|
||||||
tool.k,
|
tool.k
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,143 +1,145 @@
|
|||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IDataObject,
|
IDataObject,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
uprocApiRequest,
|
uprocApiRequest,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
groupOptions,
|
groupOptions,
|
||||||
} from './GroupDescription';
|
} from './GroupDescription';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
toolOperations,
|
toolOperations,
|
||||||
toolParameters,
|
toolParameters,
|
||||||
} from './ToolDescription';
|
} from './ToolDescription';
|
||||||
|
|
||||||
export class UProc implements INodeType {
|
export class UProc implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'uProc',
|
displayName: 'uProc',
|
||||||
name: 'uproc',
|
name: 'uproc',
|
||||||
icon: 'file:uproc.png',
|
icon: 'file:uproc.png',
|
||||||
group: ['output'],
|
group: ['output'],
|
||||||
version: 1,
|
version: 1,
|
||||||
subtitle: '={{$parameter["tool"]}}',
|
subtitle: '={{$parameter["tool"]}}',
|
||||||
description: 'Consume uProc API',
|
description: 'Consume uProc API',
|
||||||
defaults: {
|
defaults: {
|
||||||
name: 'uProc',
|
name: 'uProc',
|
||||||
color: '#219ef9',
|
color: '#219ef9',
|
||||||
},
|
},
|
||||||
inputs: ['main'],
|
inputs: ['main'],
|
||||||
outputs: ['main'],
|
outputs: ['main'],
|
||||||
credentials: [
|
credentials: [
|
||||||
{
|
{
|
||||||
name: 'uprocApi',
|
name: 'uprocApi',
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
...groupOptions,
|
...groupOptions,
|
||||||
...toolOperations,
|
...toolOperations,
|
||||||
...toolParameters,
|
...toolParameters,
|
||||||
{
|
{
|
||||||
displayName: 'Additional Options',
|
displayName: 'Additional Options',
|
||||||
name: 'additionalOptions',
|
name: 'additionalOptions',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Option',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
group: [
|
group: [
|
||||||
'audio',
|
'audio',
|
||||||
'communication',
|
'communication',
|
||||||
'company',
|
'company',
|
||||||
'finance',
|
'finance',
|
||||||
'geographic',
|
'geographic',
|
||||||
'image',
|
'image',
|
||||||
'internet',
|
'internet',
|
||||||
'personal',
|
'personal',
|
||||||
'product',
|
'product',
|
||||||
'security',
|
'security',
|
||||||
'text',
|
'text',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Data Webhook',
|
displayName: 'Data Webhook',
|
||||||
name: 'dataWebhook',
|
name: 'dataWebhook',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'URL to send tool response when tool has resolved your request. You can create your own webhook at <a href="https://beeceptor.com" target="_blank">Beeceptor</a>, <a href="https://www.integromat.com/" target="_blank">Integromat</a>, <a href="https://zapier.com/" target="_blank">Zapier</a> or <a href="https://n8n.io/" target="_blank">n8n</a>',
|
description: 'URL to send tool response when tool has resolved your request. You can create your own webhook at en <a href="https://beeceptor.com" target="_blank">Beeceptor</a>, <a href="https://www.integromat.com/" target="_blank">Integromat</a>, <a href="https://zapier.com/" target="_blank">Zapier</a> or <a href="https://n8n.io/" target="_blank">n8n</a>',
|
||||||
default: '',
|
default: '',
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
const length = items.length as unknown as number;
|
const length = items.length as unknown as number;
|
||||||
let responseData;
|
let responseData;
|
||||||
const group = this.getNodeParameter('group', 0) as string;
|
const group = this.getNodeParameter('group', 0) as string;
|
||||||
const tool = this.getNodeParameter('tool', 0) as string;
|
const tool = this.getNodeParameter('tool', 0) as string;
|
||||||
const additionalOptions = this.getNodeParameter('additionalOptions', 0) as IDataObject;
|
const additionalOptions = this.getNodeParameter('additionalOptions', 0) as IDataObject;
|
||||||
|
|
||||||
|
|
||||||
const dataWebhook = additionalOptions.dataWebhook as string;
|
const dataWebhook = additionalOptions.dataWebhook as string;
|
||||||
|
|
||||||
interface LooseObject {
|
interface LooseObject {
|
||||||
[key: string]: any; // tslint:disable-line:no-any
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fields = toolParameters.filter((field) => {
|
const fields = toolParameters.filter((field) => {
|
||||||
return field && field.displayOptions && field.displayOptions.show && field.displayOptions.show.group && field.displayOptions.show.tool &&
|
return field && field.displayOptions && field.displayOptions.show && field.displayOptions.show.group && field.displayOptions.show.tool &&
|
||||||
field.displayOptions.show.group.indexOf(group) !== -1 && field.displayOptions.show.tool.indexOf(tool) !== -1;
|
field.displayOptions.show.group.indexOf(group) !== -1 && field.displayOptions.show.tool.indexOf(tool) !== -1;
|
||||||
}).map((field) => {
|
}).map((field) => {
|
||||||
return field.name;
|
return field.name;
|
||||||
});
|
});
|
||||||
|
|
||||||
const requestPromises = [];
|
const requestPromises = [];
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const toolKey = tool.replace(/([A-Z]+)/g, '-$1').toLowerCase();
|
const toolKey = tool.replace(/([A-Z]+)/g, "-$1").toLowerCase();
|
||||||
const body: LooseObject = {
|
const body: LooseObject = {
|
||||||
processor: toolKey,
|
processor: toolKey,
|
||||||
params: {},
|
params: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
fields.forEach((field) => {
|
//console.log(fields);
|
||||||
if (field && field.length) {
|
fields.forEach((field) => {
|
||||||
const data = this.getNodeParameter(field, i) as string;
|
if (field && field.length) {
|
||||||
body.params[field] = data + '';
|
const data = this.getNodeParameter(field, i) as string;
|
||||||
}
|
//console.log(field, data);
|
||||||
});
|
body.params[field] = data + "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (dataWebhook && dataWebhook.length) {
|
if (dataWebhook && dataWebhook.length) {
|
||||||
body.callback = {};
|
body.callback = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataWebhook && dataWebhook.length) {
|
if (dataWebhook && dataWebhook.length) {
|
||||||
body.callback.data = dataWebhook;
|
body.callback.data = dataWebhook;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Change to multiple requests
|
//Change to multiple requests
|
||||||
responseData = await uprocApiRequest.call(this, 'POST', body);
|
responseData = await uprocApiRequest.call(this, 'POST', body);
|
||||||
|
|
||||||
if (Array.isArray(responseData)) {
|
if (Array.isArray(responseData)) {
|
||||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||||
} else {
|
} else {
|
||||||
returnData.push(responseData as IDataObject);
|
returnData.push(responseData as IDataObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [this.helpers.returnJsonArray(returnData)];
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user