n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -9,12 +7,19 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function lineApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function lineApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
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> {
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -33,8 +38,9 @@ export async function lineApiRequest(this: IExecuteFunctions | IExecuteSingleFun
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
return await this.helpers.requestOAuth2.call(this, 'lineNotifyOAuth2Api', options, { tokenType: 'Bearer' });
|
||||
|
||||
return await this.helpers.requestOAuth2.call(this, 'lineNotifyOAuth2Api', options, {
|
||||
tokenType: 'Bearer',
|
||||
});
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IBinaryKeyData,
|
||||
@@ -11,14 +9,9 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
lineApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { lineApiRequest } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
notificationFields,
|
||||
notificationOperations,
|
||||
} from './NotificationDescription';
|
||||
import { notificationFields, notificationOperations } from './NotificationDescription';
|
||||
|
||||
export class Line implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -41,9 +34,7 @@ export class Line implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
resource: ['notification'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -76,7 +67,6 @@ export class Line implements INodeType {
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
for (let i = 0; i < length; i++) {
|
||||
|
||||
try {
|
||||
if (resource === 'notification') {
|
||||
//https://notify-bot.line.me/doc/en/
|
||||
@@ -92,7 +82,7 @@ export class Line implements INodeType {
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.hasOwnProperty('notificationDisabled')) {
|
||||
body.notificationDisabled = (body.notificationDisabled) ? 'true' : 'false';
|
||||
body.notificationDisabled = body.notificationDisabled ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if (body.stickerUi) {
|
||||
@@ -109,15 +99,26 @@ export class Line implements INodeType {
|
||||
|
||||
if (image && image.binaryData === true) {
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
//@ts-ignore
|
||||
if (items[i].binary[image.binaryProperty] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${image.binaryProperty}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${image.binaryProperty}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[image.binaryProperty as string];
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, image.binaryProperty as string);
|
||||
const binaryData = (items[i].binary as IBinaryKeyData)[
|
||||
image.binaryProperty as string
|
||||
];
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
|
||||
i,
|
||||
image.binaryProperty as string,
|
||||
);
|
||||
|
||||
body.imageFile = {
|
||||
value: binaryDataBuffer,
|
||||
@@ -131,12 +132,19 @@ export class Line implements INodeType {
|
||||
}
|
||||
delete body.imageUi;
|
||||
}
|
||||
responseData = await lineApiRequest.call(this, 'POST', '', {}, {}, 'https://notify-api.line.me/api/notify', { formData: body });
|
||||
responseData = await lineApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
'',
|
||||
{},
|
||||
{},
|
||||
'https://notify-api.line.me/api/notify',
|
||||
{ formData: body },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const notificationOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const notificationOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
resource: ['notification'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -28,7 +24,6 @@ export const notificationOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const notificationFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* notification:send */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -39,12 +34,8 @@ export const notificationFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
operation: ['send'],
|
||||
resource: ['notification'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -57,12 +48,8 @@ export const notificationFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
operation: ['send'],
|
||||
resource: ['notification'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -93,9 +80,7 @@ export const notificationFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryData: [
|
||||
false,
|
||||
],
|
||||
binaryData: [false],
|
||||
},
|
||||
},
|
||||
description: 'HTTP/HTTPS URL. Maximum size of 2048×2048px JPEG.',
|
||||
@@ -106,9 +91,7 @@ export const notificationFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryData: [
|
||||
false,
|
||||
],
|
||||
binaryData: [false],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -120,9 +103,7 @@ export const notificationFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryData: [
|
||||
true,
|
||||
],
|
||||
binaryData: [true],
|
||||
},
|
||||
},
|
||||
default: 'data',
|
||||
@@ -138,7 +119,8 @@ export const notificationFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: '<p>true: The user doesn\'t receive a push notification when the message is sent.</p><p>false: The user receives a push notification when the message is sent</p>',
|
||||
description:
|
||||
"<p>true: The user doesn't receive a push notification when the message is sent.</p><p>false: The user receives a push notification when the message is sent</p>",
|
||||
},
|
||||
{
|
||||
displayName: 'Sticker',
|
||||
|
||||
Reference in New Issue
Block a user