n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function pushcutApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
import { IDataObject, IHookFunctions, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function pushcutApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
|
||||
method: string,
|
||||
path: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string | undefined,
|
||||
option = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('pushcutApi');
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -11,9 +9,7 @@ import {
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
pushcutApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { pushcutApiRequest } from './GenericFunctions';
|
||||
|
||||
export class Pushcut implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -57,9 +53,7 @@ export class Pushcut implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
resource: ['notification'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -76,18 +70,15 @@ export class Pushcut implements INodeType {
|
||||
displayName: 'Notification Name or ID',
|
||||
name: 'notificationName',
|
||||
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: 'getNotifications',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: ['notification'],
|
||||
operation: ['send'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -99,12 +90,8 @@ export class Pushcut implements INodeType {
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'send',
|
||||
],
|
||||
resource: [
|
||||
'notification',
|
||||
],
|
||||
operation: ['send'],
|
||||
resource: ['notification'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -117,7 +104,8 @@ export class Pushcut implements INodeType {
|
||||
loadOptionsMethod: 'getDevices',
|
||||
},
|
||||
default: [],
|
||||
description: 'List of devices this notification is sent to. (default is all devices). Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'List of devices this notification is sent to. (default is all devices). Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Input',
|
||||
@@ -185,7 +173,6 @@ export class Pushcut 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++) {
|
||||
|
||||
if (resource === 'notification') {
|
||||
if (operation === 'send') {
|
||||
const notificationName = this.getNodeParameter('notificationName', i) as string;
|
||||
@@ -207,10 +194,8 @@ export class Pushcut implements INodeType {
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
|
||||
}
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
pushcutApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { pushcutApiRequest } from './GenericFunctions';
|
||||
|
||||
export class PushcutTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -47,7 +37,8 @@ export class PushcutTrigger implements INodeType {
|
||||
displayName: 'Action Name',
|
||||
name: 'actionName',
|
||||
type: 'string',
|
||||
description: 'Choose any name you would like. It will show up as a server action in the app.',
|
||||
description:
|
||||
'Choose any name you would like. It will show up as a server action in the app.',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
@@ -66,8 +57,7 @@ export class PushcutTrigger implements INodeType {
|
||||
const webhooks = await pushcutApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
for (const webhook of webhooks) {
|
||||
if (webhook.url === webhookUrl &&
|
||||
webhook.actionName === actionName) {
|
||||
if (webhook.url === webhookUrl && webhook.actionName === actionName) {
|
||||
webhookData.webhookId = webhook.id;
|
||||
return true;
|
||||
}
|
||||
@@ -100,7 +90,6 @@ export class PushcutTrigger implements INodeType {
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId !== undefined) {
|
||||
|
||||
const endpoint = `/subscriptions/${webhookData.webhookId}`;
|
||||
|
||||
try {
|
||||
@@ -122,9 +111,7 @@ export class PushcutTrigger implements INodeType {
|
||||
const body = this.getBodyData() as IDataObject;
|
||||
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(body),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(body)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user