mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,28 +1,30 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeProperties,
|
||||
INodePropertyOptions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeProperties, INodePropertyOptions, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = await this.getCredentials('microsoftDynamicsOAuth2Api') as { subdomain: string, region: string };
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = (await this.getCredentials('microsoftDynamicsOAuth2Api')) as {
|
||||
subdomain: string;
|
||||
region: string;
|
||||
};
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'accept': 'application/json',
|
||||
'Prefer': 'return=representation',
|
||||
accept: 'application/json',
|
||||
Prefer: 'return=representation',
|
||||
},
|
||||
method,
|
||||
body,
|
||||
@@ -36,14 +38,24 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
options = Object.assign({}, options, option);
|
||||
}
|
||||
//@ts-ignore
|
||||
return await this.helpers.requestOAuth2.call(this, 'microsoftDynamicsOAuth2Api', options, { property: 'id_token' });
|
||||
return await this.helpers.requestOAuth2.call(this, 'microsoftDynamicsOAuth2Api', options, {
|
||||
property: 'id_token',
|
||||
});
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -54,17 +66,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa
|
||||
responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri);
|
||||
uri = responseData['@odata.nextLink'];
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
} while (
|
||||
responseData['@odata.nextLink'] !== undefined
|
||||
);
|
||||
} while (responseData['@odata.nextLink'] !== undefined);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getPicklistOptions(this: ILoadOptionsFunctions, entityName: string, attributeName: string): Promise<INodePropertyOptions[]> {
|
||||
export async function getPicklistOptions(
|
||||
this: ILoadOptionsFunctions,
|
||||
entityName: string,
|
||||
attributeName: string,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const endpoint = `/EntityDefinitions(LogicalName='${entityName}')/Attributes(LogicalName='${attributeName}')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options),GlobalOptionSet($select=Options)`;
|
||||
const { OptionSet: { Options: options } } = await microsoftApiRequest.call(this, 'GET', endpoint);
|
||||
const {
|
||||
OptionSet: { Options: options },
|
||||
} = await microsoftApiRequest.call(this, 'GET', endpoint);
|
||||
for (const option of options) {
|
||||
returnData.push({
|
||||
name: option.Label.UserLocalizedLabel.Label,
|
||||
@@ -74,7 +90,10 @@ export async function getPicklistOptions(this: ILoadOptionsFunctions, entityName
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export async function getEntityFields(this: ILoadOptionsFunctions, entityName: string): Promise<IField[]> {
|
||||
export async function getEntityFields(
|
||||
this: ILoadOptionsFunctions,
|
||||
entityName: string,
|
||||
): Promise<IField[]> {
|
||||
const endpoint = `/EntityDefinitions(LogicalName='${entityName}')/Attributes`;
|
||||
const { value } = await microsoftApiRequest.call(this, 'GET', endpoint);
|
||||
return value;
|
||||
@@ -103,13 +122,15 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getAccountCategories',
|
||||
},
|
||||
default: '',
|
||||
description: 'Category to indicate whether the customer account is standard or preferred. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Category to indicate whether the customer account is standard or preferred. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Account Rating Name or ID',
|
||||
name: 'accountratingcode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getAccountRatingCodes',
|
||||
},
|
||||
@@ -133,7 +154,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
displayName: 'Address Type Name or ID',
|
||||
name: 'addresstypecode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getAddressTypes',
|
||||
},
|
||||
@@ -223,13 +245,15 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getBusinessTypes',
|
||||
},
|
||||
default: '',
|
||||
description: 'The legal designation or other business type of the account for contracts or reporting purposes. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The legal designation or other business type of the account for contracts or reporting purposes. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Customer Size Name or ID',
|
||||
name: 'customersizecode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCustomerSizeCodes',
|
||||
},
|
||||
@@ -239,7 +263,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
displayName: 'Customer Type Name or ID',
|
||||
name: 'customertypecode',
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCustomerTypeCodes',
|
||||
},
|
||||
@@ -250,7 +275,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Additional information to describe the account, such as an excerpt from the company’s website',
|
||||
description:
|
||||
'Additional information to describe the account, such as an excerpt from the company’s website',
|
||||
},
|
||||
{
|
||||
displayName: 'Email Address 1',
|
||||
@@ -284,7 +310,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'ftpsiteurl',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'URL for the account’s FTP site to enable users to access data and share documents',
|
||||
description:
|
||||
'URL for the account’s FTP site to enable users to access data and share documents',
|
||||
},
|
||||
{
|
||||
displayName: 'Industry Name or ID',
|
||||
@@ -294,7 +321,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getIndustryCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'The account’s primary industry for use in marketing segmentation and demographic analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The account’s primary industry for use in marketing segmentation and demographic analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
@@ -303,12 +331,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/resource': [
|
||||
'account',
|
||||
],
|
||||
'/operation': [
|
||||
'update',
|
||||
],
|
||||
'/resource': ['account'],
|
||||
'/operation': ['update'],
|
||||
},
|
||||
},
|
||||
description: 'Company o business name',
|
||||
@@ -318,14 +342,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'creditlimit',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'Credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.',
|
||||
description:
|
||||
'Credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Number Of Employees',
|
||||
name: 'numberofemployees',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
description: 'Number of employees that work at the account for use in marketing segmentation and demographic analysis',
|
||||
description:
|
||||
'Number of employees that work at the account for use in marketing segmentation and demographic analysis',
|
||||
},
|
||||
{
|
||||
displayName: 'Payment Terms Name or ID',
|
||||
@@ -335,7 +361,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPaymentTermsCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'The payment terms to indicate when the customer needs to pay the total amount. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The payment terms to indicate when the customer needs to pay the total amount. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Preferred Appointment Day Name or ID',
|
||||
@@ -345,7 +372,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPreferredAppointmentDayCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Preferred Appointment Time Name or ID',
|
||||
@@ -355,7 +383,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPreferredAppointmentTimeCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Preferred Contact Method Name or ID',
|
||||
@@ -365,7 +394,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getPreferredContactMethodCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Satori ID',
|
||||
@@ -384,14 +414,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'revenue',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'The annual revenue for the account, used as an indicator in financial performance analysis',
|
||||
description:
|
||||
'The annual revenue for the account, used as an indicator in financial performance analysis',
|
||||
},
|
||||
{
|
||||
displayName: 'Shares Outstanding',
|
||||
name: 'sharesoutstanding',
|
||||
type: 'number',
|
||||
default: '',
|
||||
description: 'The number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.',
|
||||
description:
|
||||
'The number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.',
|
||||
},
|
||||
{
|
||||
displayName: 'Shipping Method Name or ID',
|
||||
@@ -401,14 +433,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getShippingMethodCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Shipping method for deliveries sent to the account’s address to designate the preferred carrier or other delivery option. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Shipping method for deliveries sent to the account’s address to designate the preferred carrier or other delivery option. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'SIC',
|
||||
name: 'sic',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The Standard Industrial Classification (SIC) code that indicates the account’s primary industry of business, for use in marketing segmentation and demographic analysis',
|
||||
description:
|
||||
'The Standard Industrial Classification (SIC) code that indicates the account’s primary industry of business, for use in marketing segmentation and demographic analysis',
|
||||
},
|
||||
{
|
||||
displayName: 'Stage ID',
|
||||
@@ -421,7 +455,8 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'stockexchange',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The stock exchange at which the account is listed to track their stock and financial performance of the company',
|
||||
description:
|
||||
'The stock exchange at which the account is listed to track their stock and financial performance of the company',
|
||||
},
|
||||
{
|
||||
displayName: 'Telephone 1',
|
||||
@@ -452,14 +487,16 @@ export function getAccountFields(): INodeProperties[] {
|
||||
loadOptionsMethod: 'getTerritoryCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Region or territory for the account for use in segmentation and analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Region or territory for the account for use in segmentation and analysis. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Ticker Symbol',
|
||||
name: 'tickersymbol',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.',
|
||||
description:
|
||||
'Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.',
|
||||
},
|
||||
{
|
||||
displayName: 'Website URL',
|
||||
@@ -473,14 +510,19 @@ export function getAccountFields(): INodeProperties[] {
|
||||
name: 'yominame',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications',
|
||||
description:
|
||||
'The phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export const sort = (a: { name: string }, b: { name: string }) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -493,11 +535,11 @@ export interface IField {
|
||||
CanBeSecuredForRead: string;
|
||||
AttributeType: string;
|
||||
IsSortableEnabled: {
|
||||
Value: boolean,
|
||||
Value: boolean;
|
||||
};
|
||||
DisplayName: {
|
||||
UserLocalizedLabel: {
|
||||
Label: string
|
||||
}
|
||||
Label: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user