@webagent-cloud/n8n-nodes-webagent
Version:
Webagent n8n nodes package
89 lines • 2.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Webagent = void 0;
const WebagentDescription_1 = require("./WebagentDescription");
async function getAuthContexts() {
const responseData = await this.helpers.requestWithAuthentication.call(this, 'webagentApi', {
baseURL: `https://api.webagent.cloud`,
url: `/auth-contexts`,
method: 'GET',
json: true,
});
const options = responseData.map((authContext) => {
const name = authContext.name;
const value = authContext.id;
return { name, value };
});
return [{ name: 'No Auth Context', value: '' }, ...options];
}
async function getTasks() {
const responseData = await this.helpers.requestWithAuthentication.call(this, 'webagentApi', {
baseURL: `https://api.webagent.cloud`,
url: `/tasks`,
method: 'GET',
json: true,
});
const options = responseData.map((authContext) => {
const name = authContext.name;
const value = authContext.id;
return { name, value };
});
return options;
}
class Webagent {
constructor() {
this.description = {
displayName: 'Webagent',
name: 'webagent',
icon: 'file:webagent.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Interact with Webagent',
defaults: {
name: 'Webagent',
},
inputs: ["main"],
outputs: ["main"],
credentials: [
{
name: 'webagentApi',
required: true,
},
],
requestDefaults: {
baseURL: '={{$credentials?.domain || "https://api.webagent.cloud"}}',
url: '',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
},
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Task Run',
value: 'run',
},
],
default: 'run',
},
...WebagentDescription_1.runOperations,
...WebagentDescription_1.runFields,
],
};
this.methods = {
loadOptions: {
getAuthContexts,
getTasks,
},
};
}
}
exports.Webagent = Webagent;
//# sourceMappingURL=Webagent.node.js.map