n8n-nodes-axonaut-antislash
Version:
n8n community node for Axonaut API integration
1,236 lines (1,235 loc) • 247 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Axonaut = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const GenericFunctions_1 = require("./GenericFunctions");
// Helper function to get resource lists for dynamic dropdowns
async function getResourceList(endpoint, idField, nameField, resourceType, filter) {
try {
const resources = await GenericFunctions_1.axonautApiRequest.call(this, 'GET', endpoint);
const results = {
results: [],
};
if (Array.isArray(resources)) {
for (const resource of resources) {
// Build display name
let displayName = '';
if (Array.isArray(nameField)) {
displayName = nameField
.map(field => resource[field] || '')
.filter(value => value.trim() !== '')
.join(' ');
}
else {
displayName = resource[nameField] || '';
}
// Fallback if no name
if (!displayName.trim()) {
displayName = `${resourceType} ${resource[idField]}`;
}
// Apply filter if provided
if (!filter || displayName.toLowerCase().includes(filter.toLowerCase())) {
results.results.push({
name: displayName,
value: resource[idField].toString(),
});
}
}
// Sort results by name
results.results.sort((a, b) => a.name.localeCompare(b.name));
}
return results;
}
catch (error) {
// Return empty results on error
return { results: [] };
}
}
class Axonaut {
constructor() {
this.description = {
displayName: 'Axonaut',
name: 'axonaut',
icon: 'file:axonaut.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Interact with Axonaut API - Complete coverage of all endpoints',
defaults: {
name: 'Axonaut',
},
inputs: ["main" /* NodeConnectionType.Main */],
outputs: ["main" /* NodeConnectionType.Main */],
credentials: [
{
name: 'axonautApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Address',
value: 'address',
},
{
name: 'Bank Transaction',
value: 'bank-transaction',
},
{
name: 'Company',
value: 'company',
},
{
name: 'Contract (Order)',
value: 'contract',
},
{
name: 'Document',
value: 'document',
},
{
name: 'Employee (Contact)',
value: 'employee',
},
{
name: 'Event',
value: 'event',
},
{
name: 'Expense',
value: 'expense',
},
{
name: 'Expense Payment',
value: 'expense-payment',
},
{
name: 'Invoice',
value: 'invoice',
},
{
name: 'Invoice Payment',
value: 'invoice-payment',
},
{
name: 'Opportunity',
value: 'opportunity',
},
{
name: 'Product',
value: 'product',
},
{
name: 'Project',
value: 'project',
},
{
name: 'Quotation',
value: 'quotation',
},
{
name: 'Supplier',
value: 'supplier',
},
{
name: 'Supplier Contract',
value: 'supplier-contract',
},
{
name: 'Supplier Delivery',
value: 'supplier-delivery',
},
{
name: 'Diverse Operations',
value: 'diverse-operations',
},
{
name: 'Delivery Forms',
value: 'delivery-forms',
},
{
name: 'Task',
value: 'task',
},
{
name: 'Ticket',
value: 'ticket',
},
{
name: 'Timetracking',
value: 'timetracking',
},
{
name: 'Themes',
value: 'theme',
},
{
name: 'Bank Accounts',
value: 'bank-account',
},
{
name: 'Company Categories',
value: 'company-category',
},
{
name: 'Task Natures',
value: 'task-nature',
},
{
name: 'Project Natures',
value: 'project-nature',
},
{
name: 'Tax Rates',
value: 'tax-rate',
},
{
name: 'Accounting Codes',
value: 'accounting-code',
},
{
name: 'Languages',
value: 'language',
},
{
name: 'Workforces',
value: 'workforce',
},
{
name: 'Payslips',
value: 'payslip',
},
{
name: 'Pipes',
value: 'pipe',
},
{
name: 'Account',
value: 'account',
},
],
default: 'company',
},
// Company Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['company'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new company',
action: 'Create a company',
},
{
name: 'Get',
value: 'get',
description: 'Get a company by ID',
action: 'Get a company',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all companies',
action: 'Get many companies',
},
{
name: 'Update',
value: 'update',
description: 'Update a company',
action: 'Update a company',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a company',
action: 'Delete a company',
},
{
name: 'Upsert',
value: 'upsert',
description: 'Create or update a company based on unique identifier',
action: 'Upsert a company',
},
],
default: 'get',
},
// Employee Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['employee'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new employee',
action: 'Create an employee',
},
{
name: 'Get',
value: 'get',
description: 'Get an employee by ID',
action: 'Get an employee',
},
{
name: 'Get Company Employees',
value: 'getCompanyEmployees',
description: 'Get all employees of a specific company',
action: 'Get company employees',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all employees',
action: 'Get many employees',
},
{
name: 'Update',
value: 'update',
description: 'Update an employee',
action: 'Update an employee',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete an employee',
action: 'Delete an employee',
},
{
name: 'Upsert',
value: 'upsert',
description: 'Create or update an employee based on email',
action: 'Upsert an employee',
},
],
default: 'get',
},
// Invoice Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['invoice'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get an invoice by ID',
action: 'Get an invoice',
},
{
name: 'Get Company Invoices',
value: 'getCompanyInvoices',
description: 'Get all invoices of a specific company',
action: 'Get company invoices',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all invoices',
action: 'Get many invoices',
},
],
default: 'get',
},
// Opportunity Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['opportunity'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new opportunity',
action: 'Create an opportunity',
},
{
name: 'Get',
value: 'get',
description: 'Get an opportunity by ID',
action: 'Get an opportunity',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all opportunities',
action: 'Get many opportunities',
},
{
name: 'Update',
value: 'update',
description: 'Update an opportunity',
action: 'Update an opportunity',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete an opportunity',
action: 'Delete an opportunity',
},
{
name: 'Upsert',
value: 'upsert',
description: 'Create or update an opportunity based on name',
action: 'Upsert an opportunity',
},
{
name: 'Mark as Won',
value: 'markWon',
description: 'Register an opportunity as won',
action: 'Mark opportunity as won',
},
{
name: 'Mark as Lost',
value: 'markLost',
description: 'Register an opportunity as lost',
action: 'Mark opportunity as lost',
},
],
default: 'get',
},
// Product Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['product'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new product',
action: 'Create a product',
},
{
name: 'Get',
value: 'get',
description: 'Get a product by ID',
action: 'Get a product',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all products',
action: 'Get many products',
},
{
name: 'Update',
value: 'update',
description: 'Update a product',
action: 'Update a product',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a product',
action: 'Delete a product',
},
{
name: 'Upsert',
value: 'upsert',
description: 'Create or update a product based on unique identifier',
action: 'Upsert a product',
},
{
name: 'Get Stock',
value: 'getStock',
description: 'Get the stock of a product',
action: 'Get product stock',
},
{
name: 'Update Stock',
value: 'updateStock',
description: 'Update the stock of a product',
action: 'Update product stock',
},
],
default: 'get',
},
// Quotation Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['quotation'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new quotation',
action: 'Create a quotation',
},
{
name: 'Get',
value: 'get',
description: 'Get a quotation by ID',
action: 'Get a quotation',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all quotations',
action: 'Get many quotations',
},
{
name: 'Get Company Quotations',
value: 'getCompanyQuotations',
description: 'Get all quotations of a specific company',
action: 'Get company quotations',
},
],
default: 'get',
},
// Project Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['project'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new project',
action: 'Create a project',
},
{
name: 'Get',
value: 'get',
description: 'Get a project by ID',
action: 'Get a project',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all projects',
action: 'Get many projects',
},
{
name: 'Update',
value: 'update',
description: 'Update a project',
action: 'Update a project',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a project',
action: 'Delete a project',
},
{
name: 'Upsert',
value: 'upsert',
description: 'Create or update a project based on unique identifier',
action: 'Upsert a project',
},
],
default: 'get',
},
// Expense Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['expense'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get an expense by ID',
action: 'Get an expense',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all expenses',
action: 'Get many expenses',
},
{
name: 'Create Payment',
value: 'createPayment',
description: 'Create an expense payment',
action: 'Create expense payment',
},
],
default: 'get',
},
// Event Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['event'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new event',
action: 'Create an event',
},
{
name: 'Get',
value: 'get',
description: 'Get an event by ID',
action: 'Get an event',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all events',
action: 'Get many events',
},
{
name: 'Update',
value: 'update',
description: 'Update an event',
action: 'Update an event',
},
{
name: 'Get Company Events',
value: 'getCompanyEvents',
description: 'Get all events of a specific company',
action: 'Get company events',
},
{
name: 'Send Email',
value: 'send',
description: 'Send an event as email',
action: 'Send event email',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete an event',
action: 'Delete an event',
},
],
default: 'get',
},
// Address Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['address'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new address',
action: 'Create a address',
},
{
name: 'Get',
value: 'get',
description: 'Get a address by ID',
action: 'Get a address',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all addresses of a company',
action: 'Get many addresses',
},
{
name: 'Update',
value: 'update',
description: 'Update a address',
action: 'Update a address',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a address',
action: 'Delete a address',
},
],
default: 'getAll',
},
// Bank transaction Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['bank-transaction'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get a bank transaction by ID',
action: 'Get a bank transaction',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all bank transactions',
action: 'Get many bank transactions',
},
],
default: 'getAll',
},
// Contract Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['contract'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new contract',
action: 'Create a contract',
},
{
name: 'Get',
value: 'get',
description: 'Get a contract by ID',
action: 'Get a contract',
},
{
name: 'Get Company Contracts',
value: 'getCompanyContracts',
description: 'Get all contracts of a specific company',
action: 'Get company contracts',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all contracts',
action: 'Get many contracts',
},
{
name: 'Update',
value: 'update',
description: 'Update a contract',
action: 'Update a contract',
},
],
default: 'get',
},
// Document Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['document'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new document',
action: 'Create a document',
},
{
name: 'Get',
value: 'get',
description: 'Get a document by ID',
action: 'Get a document',
},
{
name: 'Get Company Documents',
value: 'getCompanyDocuments',
description: 'Get all documents of a specific company',
action: 'Get company documents',
},
{
name: 'Update',
value: 'update',
description: 'Update a document',
action: 'Update a document',
},
{
name: 'Download',
value: 'download',
description: 'Download a document file',
action: 'Download a document',
},
],
default: 'get',
},
// Expense payment Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['expense-payment'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new expense payment',
action: 'Create a expense payment',
},
{
name: 'Get',
value: 'get',
description: 'Get an expense payment by ID',
action: 'Get an expense payment',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all expense payments',
action: 'Get many expense payments',
},
],
default: 'create',
},
// Invoice payment Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['invoice-payment'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new invoice payment',
action: 'Create a invoice payment',
},
{
name: 'Get',
value: 'get',
description: 'Get an invoice payment by ID',
action: 'Get an invoice payment',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all invoice payments',
action: 'Get many invoice payments',
},
],
default: 'create',
},
// Supplier Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['supplier'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new supplier',
action: 'Create a supplier',
},
{
name: 'Get',
value: 'get',
description: 'Get a supplier by ID',
action: 'Get a supplier',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all suppliers',
action: 'Get many suppliers',
},
],
default: 'get',
},
// Supplier contract Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['supplier-contract'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new supplier contract',
action: 'Create a supplier contract',
},
{
name: 'Get',
value: 'get',
description: 'Get a supplier contract by ID',
action: 'Get a supplier contract',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all supplier contracts',
action: 'Get many supplier contracts',
},
],
default: 'get',
},
// Task Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['task'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new task',
action: 'Create a task',
},
{
name: 'Get',
value: 'get',
description: 'Get a task by ID',
action: 'Get a task',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all tasks',
action: 'Get many tasks',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a task',
action: 'Delete a task',
},
],
default: 'get',
},
// Ticket Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['ticket'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new ticket',
action: 'Create a ticket',
},
{
name: 'Get',
value: 'get',
description: 'Get a ticket by ID',
action: 'Get a ticket',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all tickets',
action: 'Get many tickets',
},
{
name: 'Update',
value: 'update',
description: 'Update a ticket',
action: 'Update a ticket',
},
],
default: 'get',
},
// Supplier Delivery Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['supplier-delivery'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get a supplier delivery by ID',
action: 'Get a supplier delivery',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all supplier deliveries',
action: 'Get many supplier deliveries',
},
{
name: 'Create Receipt',
value: 'createReceipt',
description: 'Receive merchandise for a supplier delivery',
action: 'Create delivery receipt',
},
{
name: 'Delete Receipt',
value: 'deleteReceipt',
description: 'Delete a merchandise receipt',
action: 'Delete delivery receipt',
},
],
default: 'getAll',
},
// Diverse Operations Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['diverse-operations'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get a diverse operation by ID',
action: 'Get a diverse operation',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all diverse operations',
action: 'Get many diverse operations',
},
],
default: 'getAll',
},
// Delivery Forms Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['delivery-forms'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a delivery note from an invoice',
action: 'Create a delivery note',
},
{
name: 'Get',
value: 'get',
description: 'Get a delivery note by ID',
action: 'Get a delivery note',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all delivery notes',
action: 'Get many delivery notes',
},
{
name: 'Download',
value: 'download',
description: 'Download a delivery note',
action: 'Download delivery note',
},
],
default: 'getAll',
},
// Timetracking Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['timetracking'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a new timetracking',
action: 'Create a timetracking',
},
{
name: 'Get',
value: 'get',
description: 'Get a timetracking by ID (client-side filtered)',
action: 'Get a timetracking',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all timetrackings',
action: 'Get many timetrackings',
},
{
name: 'Get Task Timetrackings',
value: 'getTaskTimetrackings',
description: 'Get timetrackings on a specific task',
action: 'Get task timetrackings',
},
{
name: 'Get Ticket Timetrackings',
value: 'getTicketTimetrackings',
description: 'Get timetrackings on a specific ticket',
action: 'Get ticket timetrackings',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a timetracking',
action: 'Delete a timetracking',
},
],
default: 'create',
},
// Themes Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['theme'],
},
},
options: [
{
name: 'Get',
value: 'get',
description: 'Get a theme by ID',
action: 'Get a theme',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get all themes',
action: 'Get many themes',
},
],
default: 'get',
},
// Bank Accounts Operations
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['bank-account'],
},
},
options: [
{
name: 'Get',
value: 'get',