mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)
This commit is contained in:
@@ -22,6 +22,15 @@ import {
|
||||
ZohoOAuth2ApiCredentials,
|
||||
} from './types';
|
||||
|
||||
export function throwOnErrorStatus(
|
||||
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
responseData: { data?: Array<{ status: string; message: string }> },
|
||||
) {
|
||||
if (responseData?.data?.[0].status === 'error') {
|
||||
throw new NodeOperationError(this.getNode(), responseData as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function zohoApiRequest(
|
||||
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
@@ -133,19 +142,16 @@ export function throwOnMissingProducts(
|
||||
}
|
||||
}
|
||||
|
||||
export function throwOnErrorStatus(
|
||||
this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
responseData: { data?: Array<{ status: string; message: string }> },
|
||||
) {
|
||||
if (responseData?.data?.[0].status === 'error') {
|
||||
throw new NodeOperationError(this.getNode(), responseData as Error);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// required field adjusters
|
||||
// ----------------------------------------
|
||||
|
||||
/**
|
||||
* Create a copy of an object without a specific property.
|
||||
*/
|
||||
const omit = (propertyToOmit: string, { [propertyToOmit]: _, ...remainingObject }) =>
|
||||
remainingObject;
|
||||
|
||||
/**
|
||||
* Place a product ID at a nested position in a product details field.
|
||||
*/
|
||||
@@ -317,18 +323,29 @@ export const adjustProductPayload = adjustCustomFields;
|
||||
// helpers
|
||||
// ----------------------------------------
|
||||
|
||||
/**
|
||||
* Create a copy of an object without a specific property.
|
||||
*/
|
||||
const omit = (propertyToOmit: string, { [propertyToOmit]: _, ...remainingObject }) =>
|
||||
remainingObject;
|
||||
|
||||
/**
|
||||
* Convert items in a Zoho CRM API response into n8n load options.
|
||||
*/
|
||||
export const toLoadOptions = (items: ResourceItems, nameProperty: NameType) =>
|
||||
items.map((item) => ({ name: item[nameProperty], value: item.id }));
|
||||
|
||||
export function getModuleName(resource: string) {
|
||||
const map: { [key: string]: string } = {
|
||||
account: 'Accounts',
|
||||
contact: 'Contacts',
|
||||
deal: 'Deals',
|
||||
invoice: 'Invoices',
|
||||
lead: 'Leads',
|
||||
product: 'Products',
|
||||
purchaseOrder: 'Purchase_Orders',
|
||||
salesOrder: 'Sales_Orders',
|
||||
vendor: 'Vendors',
|
||||
quote: 'Quotes',
|
||||
};
|
||||
|
||||
return map[resource];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all fields for a resource, sorted alphabetically.
|
||||
*/
|
||||
@@ -359,21 +376,13 @@ export async function getFields(
|
||||
return sortBy(options, (o) => o.name);
|
||||
}
|
||||
|
||||
export function getModuleName(resource: string) {
|
||||
const map: { [key: string]: string } = {
|
||||
account: 'Accounts',
|
||||
contact: 'Contacts',
|
||||
deal: 'Deals',
|
||||
invoice: 'Invoices',
|
||||
lead: 'Leads',
|
||||
product: 'Products',
|
||||
purchaseOrder: 'Purchase_Orders',
|
||||
salesOrder: 'Sales_Orders',
|
||||
vendor: 'Vendors',
|
||||
quote: 'Quotes',
|
||||
};
|
||||
export const capitalizeInitial = (str: string) => str[0].toUpperCase() + str.slice(1);
|
||||
|
||||
return map[resource];
|
||||
function getSectionApiName(resource: string) {
|
||||
if (resource === 'purchaseOrder') return 'Purchase Order Information';
|
||||
if (resource === 'salesOrder') return 'Sales Order Information';
|
||||
|
||||
return `${capitalizeInitial(resource)} Information`;
|
||||
}
|
||||
|
||||
export async function getPicklistOptions(
|
||||
@@ -402,13 +411,6 @@ export async function getPicklistOptions(
|
||||
}));
|
||||
}
|
||||
|
||||
function getSectionApiName(resource: string) {
|
||||
if (resource === 'purchaseOrder') return 'Purchase Order Information';
|
||||
if (resource === 'salesOrder') return 'Sales Order Information';
|
||||
|
||||
return `${capitalizeInitial(resource)} Information`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add filter options to a query string object.
|
||||
*/
|
||||
@@ -418,5 +420,3 @@ export const addGetAllFilterOptions = (qs: IDataObject, options: GetAllFilterOpt
|
||||
Object.assign(qs, fields && { fields: fields.join(',') }, rest);
|
||||
}
|
||||
};
|
||||
|
||||
export const capitalizeInitial = (str: string) => str[0].toUpperCase() + str.slice(1);
|
||||
|
||||
Reference in New Issue
Block a user