mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,31 +10,15 @@ import {
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
xeroApiRequest,
|
||||
xeroApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { xeroApiRequest, xeroApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
invoiceFields,
|
||||
invoiceOperations
|
||||
} from './InvoiceDescription';
|
||||
import { invoiceFields, invoiceOperations } from './InvoiceDescription';
|
||||
|
||||
import {
|
||||
contactFields,
|
||||
contactOperations,
|
||||
} from './ContactDescription';
|
||||
import { contactFields, contactOperations } from './ContactDescription';
|
||||
|
||||
import {
|
||||
IInvoice,
|
||||
ILineItem,
|
||||
} from './InvoiceInterface';
|
||||
import { IInvoice, ILineItem } from './InvoiceInterface';
|
||||
|
||||
import {
|
||||
IAddress,
|
||||
IContact,
|
||||
IPhone,
|
||||
} from './IContactInterface';
|
||||
import { IAddress, IContact, IPhone } from './IContactInterface';
|
||||
|
||||
export class Xero implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -92,7 +74,9 @@ export class Xero implements INodeType {
|
||||
async getItemCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const organizationId = this.getCurrentNodeParameter('organizationId');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { Items: items } = await xeroApiRequest.call(this, 'GET', '/items', { organizationId });
|
||||
const { Items: items } = await xeroApiRequest.call(this, 'GET', '/items', {
|
||||
organizationId,
|
||||
});
|
||||
for (const item of items) {
|
||||
const itemName = item.Description;
|
||||
const itemId = item.Code;
|
||||
@@ -108,7 +92,9 @@ export class Xero implements INodeType {
|
||||
async getAccountCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const organizationId = this.getCurrentNodeParameter('organizationId');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { Accounts: accounts } = await xeroApiRequest.call(this, 'GET', '/Accounts', { organizationId });
|
||||
const { Accounts: accounts } = await xeroApiRequest.call(this, 'GET', '/Accounts', {
|
||||
organizationId,
|
||||
});
|
||||
for (const account of accounts) {
|
||||
const accountName = account.Name;
|
||||
const accountId = account.Code;
|
||||
@@ -123,7 +109,14 @@ export class Xero implements INodeType {
|
||||
// select them easily
|
||||
async getTenants(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const tenants = await xeroApiRequest.call(this, 'GET', '', {}, {}, 'https://api.xero.com/connections');
|
||||
const tenants = await xeroApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'',
|
||||
{},
|
||||
{},
|
||||
'https://api.xero.com/connections',
|
||||
);
|
||||
for (const tenant of tenants) {
|
||||
const tenantName = tenant.tenantName;
|
||||
const tenantId = tenant.tenantId;
|
||||
@@ -139,7 +132,12 @@ export class Xero implements INodeType {
|
||||
async getBrandingThemes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const organizationId = this.getCurrentNodeParameter('organizationId');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { BrandingThemes: themes } = await xeroApiRequest.call(this, 'GET', '/BrandingThemes', { organizationId });
|
||||
const { BrandingThemes: themes } = await xeroApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/BrandingThemes',
|
||||
{ organizationId },
|
||||
);
|
||||
for (const theme of themes) {
|
||||
const themeName = theme.Name;
|
||||
const themeId = theme.BrandingThemeID;
|
||||
@@ -155,7 +153,9 @@ export class Xero implements INodeType {
|
||||
async getCurrencies(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const organizationId = this.getCurrentNodeParameter('organizationId');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { Currencies: currencies } = await xeroApiRequest.call(this, 'GET', '/Currencies', { organizationId });
|
||||
const { Currencies: currencies } = await xeroApiRequest.call(this, 'GET', '/Currencies', {
|
||||
organizationId,
|
||||
});
|
||||
for (const currency of currencies) {
|
||||
const currencyName = currency.Code;
|
||||
const currencyId = currency.Description;
|
||||
@@ -171,7 +171,12 @@ export class Xero implements INodeType {
|
||||
async getTrakingCategories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const organizationId = this.getCurrentNodeParameter('organizationId');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { TrackingCategories: categories } = await xeroApiRequest.call(this, 'GET', '/TrackingCategories', { organizationId });
|
||||
const { TrackingCategories: categories } = await xeroApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/TrackingCategories',
|
||||
{ organizationId },
|
||||
);
|
||||
for (const category of categories) {
|
||||
const categoryName = category.Name;
|
||||
const categoryId = category.TrackingCategoryID;
|
||||
@@ -220,7 +225,8 @@ export class Xero implements INodeType {
|
||||
const type = this.getNodeParameter('type', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
const lineItemsValues = ((this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as IDataObject[]);
|
||||
const lineItemsValues = (this.getNodeParameter('lineItemsUi', i) as IDataObject)
|
||||
.lineItemsValues as IDataObject[];
|
||||
|
||||
const body: IInvoice = {
|
||||
organizationId,
|
||||
@@ -316,7 +322,8 @@ export class Xero implements INodeType {
|
||||
};
|
||||
|
||||
if (updateFields.lineItemsUi) {
|
||||
const lineItemsValues = (updateFields.lineItemsUi as IDataObject).lineItemsValues as IDataObject[];
|
||||
const lineItemsValues = (updateFields.lineItemsUi as IDataObject)
|
||||
.lineItemsValues as IDataObject[];
|
||||
if (lineItemsValues) {
|
||||
const lineItems: ILineItem[] = [];
|
||||
for (const lineItemValue of lineItemsValues) {
|
||||
@@ -405,7 +412,9 @@ export class Xero implements INodeType {
|
||||
if (operation === 'get') {
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const invoiceId = this.getNodeParameter('invoiceId', i) as string;
|
||||
responseData = await xeroApiRequest.call(this, 'GET', `/Invoices/${invoiceId}`, { organizationId });
|
||||
responseData = await xeroApiRequest.call(this, 'GET', `/Invoices/${invoiceId}`, {
|
||||
organizationId,
|
||||
});
|
||||
responseData = responseData.Invoices;
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -416,7 +425,9 @@ export class Xero implements INodeType {
|
||||
qs.statuses = (options.statuses as string[]).join(',');
|
||||
}
|
||||
if (options.orderBy) {
|
||||
qs.order = `${options.orderBy} ${(options.sortOrder === undefined) ? 'DESC' : options.sortOrder}`;
|
||||
qs.order = `${options.orderBy} ${
|
||||
options.sortOrder === undefined ? 'DESC' : options.sortOrder
|
||||
}`;
|
||||
}
|
||||
if (options.where) {
|
||||
qs.where = options.where;
|
||||
@@ -425,10 +436,23 @@ export class Xero implements INodeType {
|
||||
qs.createdByMyApp = options.createdByMyApp as boolean;
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await xeroApiRequestAllItems.call(this, 'Invoices', 'GET', '/Invoices', { organizationId }, qs);
|
||||
responseData = await xeroApiRequestAllItems.call(
|
||||
this,
|
||||
'Invoices',
|
||||
'GET',
|
||||
'/Invoices',
|
||||
{ organizationId },
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await xeroApiRequest.call(this, 'GET', `/Invoices`, { organizationId }, qs);
|
||||
responseData = await xeroApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/Invoices`,
|
||||
{ organizationId },
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.Invoices;
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
@@ -479,7 +503,8 @@ export class Xero implements INodeType {
|
||||
}
|
||||
|
||||
if (additionalFields.purchasesDefaultAccountCode) {
|
||||
body.PurchasesDefaultAccountCode = additionalFields.purchasesDefaultAccountCode as string;
|
||||
body.PurchasesDefaultAccountCode =
|
||||
additionalFields.purchasesDefaultAccountCode as string;
|
||||
}
|
||||
|
||||
if (additionalFields.salesDefaultAccountCode) {
|
||||
@@ -534,13 +559,18 @@ export class Xero implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await xeroApiRequest.call(this, 'POST', '/Contacts', { organizationId, Contacts: [body] });
|
||||
responseData = await xeroApiRequest.call(this, 'POST', '/Contacts', {
|
||||
organizationId,
|
||||
Contacts: [body],
|
||||
});
|
||||
responseData = responseData.Contacts;
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
responseData = await xeroApiRequest.call(this, 'GET', `/Contacts/${contactId}`, { organizationId });
|
||||
responseData = await xeroApiRequest.call(this, 'GET', `/Contacts/${contactId}`, {
|
||||
organizationId,
|
||||
});
|
||||
responseData = responseData.Contacts;
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -551,20 +581,34 @@ export class Xero implements INodeType {
|
||||
qs.includeArchived = options.includeArchived as boolean;
|
||||
}
|
||||
if (options.orderBy) {
|
||||
qs.order = `${options.orderBy} ${(options.sortOrder === undefined) ? 'DESC' : options.sortOrder}`;
|
||||
qs.order = `${options.orderBy} ${
|
||||
options.sortOrder === undefined ? 'DESC' : options.sortOrder
|
||||
}`;
|
||||
}
|
||||
if (options.where) {
|
||||
qs.where = options.where;
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await xeroApiRequestAllItems.call(this, 'Contacts', 'GET', '/Contacts', { organizationId }, qs);
|
||||
responseData = await xeroApiRequestAllItems.call(
|
||||
this,
|
||||
'Contacts',
|
||||
'GET',
|
||||
'/Contacts',
|
||||
{ organizationId },
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await xeroApiRequest.call(this, 'GET', `/Contacts`, { organizationId }, qs);
|
||||
responseData = await xeroApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/Contacts`,
|
||||
{ organizationId },
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.Contacts;
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const organizationId = this.getNodeParameter('organizationId', i) as string;
|
||||
@@ -667,7 +711,10 @@ export class Xero implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await xeroApiRequest.call(this, 'POST', `/Contacts/${contactId}`, { organizationId, Contacts: [body] });
|
||||
responseData = await xeroApiRequest.call(this, 'POST', `/Contacts/${contactId}`, {
|
||||
organizationId,
|
||||
Contacts: [body],
|
||||
});
|
||||
responseData = responseData.Contacts;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user