mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Some improvements
This commit is contained in:
parent
0ba526dd67
commit
d8883fbefe
|
@ -22,13 +22,13 @@ export async function uprocApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Basic ${token}`,
|
Authorization: `Basic ${token}`,
|
||||||
"User-agent": "n8n"
|
'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 {
|
||||||
|
|
|
@ -30,12 +30,12 @@ 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 = [];
|
||||||
|
@ -45,7 +45,7 @@ for (const group of (groups as IDataObject).groups as IDataObject[]) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ for (const tool of (tools as IDataObject).processors as IDataObject[]) {
|
||||||
tool.g,
|
tool.g,
|
||||||
],
|
],
|
||||||
tool: [
|
tool: [
|
||||||
tool.k
|
tool.k,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -77,9 +77,9 @@ export class UProc implements INodeType {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
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>',
|
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: '',
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,11 +92,10 @@ export class UProc implements INodeType {
|
||||||
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;
|
[key: string]: any; // tslint:disable-line:no-any
|
||||||
}
|
}
|
||||||
|
|
||||||
const fields = toolParameters.filter((field) => {
|
const fields = toolParameters.filter((field) => {
|
||||||
|
@ -108,18 +107,16 @@ export class UProc implements INodeType {
|
||||||
|
|
||||||
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: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log(fields);
|
|
||||||
fields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
if (field && field.length) {
|
if (field && field.length) {
|
||||||
const data = this.getNodeParameter(field, i) as string;
|
const data = this.getNodeParameter(field, i) as string;
|
||||||
//console.log(field, data);
|
body.params[field] = data + '';
|
||||||
body.params[field] = data + "";
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue