mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -18,7 +12,16 @@ import {
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: object = {}, query: object = {}, headers: {} | undefined = undefined, option: {} = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function slackApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
resource: string,
|
||||
body: object = {},
|
||||
query: object = {},
|
||||
headers: {} | undefined = undefined,
|
||||
option: {} = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string;
|
||||
let options: OptionsWithUri = {
|
||||
method,
|
||||
@@ -46,16 +49,27 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu
|
||||
try {
|
||||
let response: any; // tslint:disable-line:no-any
|
||||
const credentialType = authenticationMethod === 'accessToken' ? 'slackApi' : 'slackOAuth2Api';
|
||||
response = await this.helpers.requestWithAuthentication.call(this, credentialType, options, { oauth2: oAuth2Options });
|
||||
response = await this.helpers.requestWithAuthentication.call(this, credentialType, options, {
|
||||
oauth2: oAuth2Options,
|
||||
});
|
||||
|
||||
if (response.ok === false) {
|
||||
if (response.error === 'paid_teams_only') {
|
||||
throw new NodeOperationError(this.getNode(), `Your current Slack plan does not include the resource '${this.getNodeParameter('resource', 0) as string}'`, {
|
||||
description: `Hint: Upgrate to the Slack plan that includes the funcionality you want to use.`,
|
||||
});
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Your current Slack plan does not include the resource '${
|
||||
this.getNodeParameter('resource', 0) as string
|
||||
}'`,
|
||||
{
|
||||
description: `Hint: Upgrate to the Slack plan that includes the funcionality you want to use.`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
throw new NodeOperationError(this.getNode(), 'Slack error response: ' + JSON.stringify(response));
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Slack error response: ' + JSON.stringify(response),
|
||||
);
|
||||
}
|
||||
|
||||
return response;
|
||||
@@ -64,7 +78,16 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu
|
||||
}
|
||||
}
|
||||
|
||||
export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function slackApiRequestAllItems(
|
||||
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;
|
||||
query.page = 1;
|
||||
@@ -88,14 +111,14 @@ export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOpt
|
||||
(responseData.paging !== undefined &&
|
||||
responseData.paging.pages !== undefined &&
|
||||
responseData.paging.page !== undefined &&
|
||||
responseData.paging.page < responseData.paging.pages
|
||||
)
|
||||
responseData.paging.page < responseData.paging.pages)
|
||||
);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
||||
// tslint:disable-next-line:no-any
|
||||
export function validateJSON(json: string | undefined): any {
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
|
||||
Reference in New Issue
Block a user