n8n-3867-progressively-apply-prettier-to-all (#3873)

* 🔨 formatting nodes with prettier
This commit is contained in:
Michael Kret
2022-08-17 18:50:24 +03:00
committed by GitHub
parent f2d326c7f0
commit 91d7e16c81
1072 changed files with 42357 additions and 59109 deletions

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
ICredentialsDecrypted,
@@ -36,14 +34,9 @@ import {
userOperations,
} from './descriptions';
import {
SplunkCredentials,
SplunkFeedResponse,
} from './types';
import { SplunkCredentials, SplunkFeedResponse } from './types';
import {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
export class Splunk implements INodeType {
description: INodeTypeDescription = {
@@ -112,11 +105,15 @@ export class Splunk implements INodeType {
loadOptions: {
async getRoles(this: ILoadOptionsFunctions) {
const endpoint = '/services/authorization/roles';
const responseData = await splunkApiRequest.call(this, 'GET', endpoint) as SplunkFeedResponse;
const responseData = (await splunkApiRequest.call(
this,
'GET',
endpoint,
)) as SplunkFeedResponse;
const { entry: entries } = responseData.feed;
return Array.isArray(entries)
? entries.map(entry => ({ name: entry.title, value: entry.title }))
? entries.map((entry) => ({ name: entry.title, value: entry.title }))
: [{ name: entries.title, value: entries.title }];
},
},
@@ -125,17 +122,13 @@ export class Splunk implements INodeType {
this: ICredentialTestFunctions,
credential: ICredentialsDecrypted,
): Promise<INodeCredentialTestResult> {
const {
authToken,
baseUrl,
allowUnauthorizedCerts,
} = credential.data as SplunkCredentials;
const { authToken, baseUrl, allowUnauthorizedCerts } = credential.data as SplunkCredentials;
const endpoint = '/services/alerts/fired_alerts';
const options: OptionsWithUri = {
headers: {
'Authorization': `Bearer ${authToken}`,
Authorization: `Bearer ${authToken}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
method: 'GET',
@@ -172,17 +165,13 @@ export class Splunk implements INodeType {
let responseData;
for (let i = 0; i < items.length; i++) {
try {
if (resource === 'firedAlert') {
// **********************************************************************
// firedAlert
// **********************************************************************
if (operation === 'getReport') {
// ----------------------------------------
// firedAlert: getReport
// ----------------------------------------
@@ -191,17 +180,13 @@ export class Splunk implements INodeType {
const endpoint = '/services/alerts/fired_alerts';
responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatFeed);
}
} else if (resource === 'searchConfiguration') {
// **********************************************************************
// searchConfiguration
// **********************************************************************
if (operation === 'delete') {
// ----------------------------------------
// searchConfiguration: delete
// ----------------------------------------
@@ -210,14 +195,15 @@ export class Splunk implements INodeType {
const partialEndpoint = '/services/saved/searches/';
const searchConfigurationId = getId.call(
this, i, 'searchConfigurationId', '/search/saved/searches/',
this,
i,
'searchConfigurationId',
'/search/saved/searches/',
); // id endpoint differs from operation endpoint
const endpoint = `${partialEndpoint}/${searchConfigurationId}`;
responseData = await splunkApiRequest.call(this, 'DELETE', endpoint);
} else if (operation === 'get') {
// ----------------------------------------
// searchConfiguration: get
// ----------------------------------------
@@ -226,14 +212,15 @@ export class Splunk implements INodeType {
const partialEndpoint = '/services/saved/searches/';
const searchConfigurationId = getId.call(
this, i, 'searchConfigurationId', '/search/saved/searches/',
this,
i,
'searchConfigurationId',
'/search/saved/searches/',
); // id endpoint differs from operation endpoint
const endpoint = `${partialEndpoint}/${searchConfigurationId}`;
responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatFeed);
} else if (operation === 'getAll') {
// ----------------------------------------
// searchConfiguration: getAll
// ----------------------------------------
@@ -247,18 +234,16 @@ export class Splunk implements INodeType {
setCount.call(this, qs);
const endpoint = '/services/saved/searches';
responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs).then(formatFeed);
responseData = await splunkApiRequest
.call(this, 'GET', endpoint, {}, qs)
.then(formatFeed);
}
} else if (resource === 'searchJob') {
// **********************************************************************
// searchJob
// **********************************************************************
if (operation === 'create') {
// ----------------------------------------
// searchJob: create
// ----------------------------------------
@@ -269,35 +254,31 @@ export class Splunk implements INodeType {
search: this.getNodeParameter('search', i),
} as IDataObject;
const {
earliest_time,
latest_time,
index_earliest,
index_latest,
...rest
} = this.getNodeParameter('additionalFields', i) as IDataObject & {
earliest_time?: string;
latest_time?: string;
index_earliest?: string,
index_latest?: string,
};
const { earliest_time, latest_time, index_earliest, index_latest, ...rest } =
this.getNodeParameter('additionalFields', i) as IDataObject & {
earliest_time?: string;
latest_time?: string;
index_earliest?: string;
index_latest?: string;
};
populate({
...earliest_time && { earliest_time: toUnixEpoch(earliest_time) },
...latest_time && { latest_time: toUnixEpoch(latest_time) },
...index_earliest && { index_earliest: toUnixEpoch(index_earliest) },
...index_latest && { index_latest: toUnixEpoch(index_latest) },
...rest,
}, body);
populate(
{
...(earliest_time && { earliest_time: toUnixEpoch(earliest_time) }),
...(latest_time && { latest_time: toUnixEpoch(latest_time) }),
...(index_earliest && { index_earliest: toUnixEpoch(index_earliest) }),
...(index_latest && { index_latest: toUnixEpoch(index_latest) }),
...rest,
},
body,
);
const endpoint = '/services/search/jobs';
responseData = await splunkApiRequest.call(this, 'POST', endpoint, body);
const getEndpoint = `/services/search/jobs/${responseData.response.sid}`;
responseData = await splunkApiRequest.call(this, 'GET', getEndpoint).then(formatSearch);
} else if (operation === 'delete') {
// ----------------------------------------
// searchJob: delete
// ----------------------------------------
@@ -308,9 +289,7 @@ export class Splunk implements INodeType {
const searchJobId = getId.call(this, i, 'searchJobId', partialEndpoint);
const endpoint = `${partialEndpoint}/${searchJobId}`;
responseData = await splunkApiRequest.call(this, 'DELETE', endpoint);
} else if (operation === 'get') {
// ----------------------------------------
// searchJob: get
// ----------------------------------------
@@ -321,9 +300,7 @@ export class Splunk implements INodeType {
const searchJobId = getId.call(this, i, 'searchJobId', partialEndpoint);
const endpoint = `${partialEndpoint}/${searchJobId}`;
responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatSearch);
} else if (operation === 'getAll') {
// ----------------------------------------
// searchJob: getAll
// ----------------------------------------
@@ -337,19 +314,21 @@ export class Splunk implements INodeType {
setCount.call(this, qs);
const endpoint = '/services/search/jobs';
responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs) as SplunkFeedResponse;
responseData = (await splunkApiRequest.call(
this,
'GET',
endpoint,
{},
qs,
)) as SplunkFeedResponse;
responseData = formatFeed(responseData);
}
} else if (resource === 'searchResult') {
// **********************************************************************
// searchResult
// **********************************************************************
if (operation === 'getAll') {
// ----------------------------------------
// searchResult: getAll
// ----------------------------------------
@@ -360,7 +339,7 @@ export class Splunk implements INodeType {
const qs = {} as IDataObject;
const filters = this.getNodeParameter('filters', i) as IDataObject & {
keyValueMatch?: { keyValuePair?: { key: string; value: string; } }
keyValueMatch?: { keyValuePair?: { key: string; value: string } };
};
const options = this.getNodeParameter('options', i) as IDataObject;
@@ -374,18 +353,16 @@ export class Splunk implements INodeType {
setCount.call(this, qs);
const endpoint = `/services/search/jobs/${searchJobId}/results`;
responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs).then(formatResults);
responseData = await splunkApiRequest
.call(this, 'GET', endpoint, {}, qs)
.then(formatResults);
}
} else if (resource === 'user') {
// **********************************************************************
// user
// **********************************************************************
if (operation === 'create') {
// ----------------------------------------
// user: create
// ----------------------------------------
@@ -405,11 +382,14 @@ export class Splunk implements INodeType {
populate(additionalFields, body);
const endpoint = '/services/authentication/users';
responseData = await splunkApiRequest.call(this, 'POST', endpoint, body) as SplunkFeedResponse;
responseData = (await splunkApiRequest.call(
this,
'POST',
endpoint,
body,
)) as SplunkFeedResponse;
responseData = formatFeed(responseData);
} else if (operation === 'delete') {
// ----------------------------------------
// user: delete
// ----------------------------------------
@@ -421,9 +401,7 @@ export class Splunk implements INodeType {
const endpoint = `${partialEndpoint}/${userId}`;
await splunkApiRequest.call(this, 'DELETE', endpoint);
responseData = { success: true };
} else if (operation === 'get') {
// ----------------------------------------
// user: get
// ----------------------------------------
@@ -434,9 +412,7 @@ export class Splunk implements INodeType {
const userId = getId.call(this, i, 'userId', '/services/authentication/users/');
const endpoint = `${partialEndpoint}/${userId}`;
responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatFeed);
} else if (operation === 'getAll') {
// ----------------------------------------
// user: getAll
// ----------------------------------------
@@ -447,10 +423,10 @@ export class Splunk implements INodeType {
setCount.call(this, qs);
const endpoint = '/services/authentication/users';
responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs).then(formatFeed);
responseData = await splunkApiRequest
.call(this, 'GET', endpoint, {}, qs)
.then(formatFeed);
} else if (operation === 'update') {
// ----------------------------------------
// user: update
// ----------------------------------------
@@ -462,20 +438,22 @@ export class Splunk implements INodeType {
roles: string[];
};
populate({
...roles && { roles },
...rest,
}, body);
populate(
{
...(roles && { roles }),
...rest,
},
body,
);
const partialEndpoint = '/services/authentication/users/';
const userId = getId.call(this, i, 'userId', partialEndpoint);
const endpoint = `${partialEndpoint}/${userId}`;
responseData = await splunkApiRequest.call(this, 'POST', endpoint, body).then(formatFeed);
responseData = await splunkApiRequest
.call(this, 'POST', endpoint, body)
.then(formatFeed);
}
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.cause.error });
@@ -488,7 +466,6 @@ export class Splunk implements INodeType {
Array.isArray(responseData)
? returnData.push(...responseData)
: returnData.push(responseData as IDataObject);
}
return [this.helpers.returnJsonArray(returnData)];