mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
export async function msGraphSecurityApiRequest(
|
||||
this: IExecuteFunctions,
|
||||
@@ -24,10 +16,10 @@ export async function msGraphSecurityApiRequest(
|
||||
oauthTokenData: {
|
||||
access_token, // tslint:disable-line variable-name
|
||||
},
|
||||
} = await this.getCredentials('microsoftGraphSecurityOAuth2Api') as {
|
||||
} = (await this.getCredentials('microsoftGraphSecurityOAuth2Api')) as {
|
||||
oauthTokenData: {
|
||||
access_token: string;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
@@ -72,7 +64,8 @@ export async function msGraphSecurityApiRequest(
|
||||
}
|
||||
|
||||
if (['Invalid filter clause', 'Invalid ODATA query filter'].includes(nestedMessage)) {
|
||||
error.error.error.message += ' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter';
|
||||
error.error.error.message +=
|
||||
' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter';
|
||||
}
|
||||
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
msGraphSecurityApiRequest,
|
||||
@@ -72,23 +65,21 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0) as 'secureScore'| 'secureScoreControlProfile';
|
||||
const resource = this.getNodeParameter('resource', 0) as
|
||||
| 'secureScore'
|
||||
| 'secureScoreControlProfile';
|
||||
const operation = this.getNodeParameter('operation', 0) as 'get' | 'getAll' | 'update';
|
||||
|
||||
let responseData;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
||||
try {
|
||||
|
||||
if (resource === 'secureScore') {
|
||||
|
||||
// **********************************************************************
|
||||
// secureScore
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScore: get
|
||||
// ----------------------------------------
|
||||
@@ -97,11 +88,13 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
|
||||
const secureScoreId = this.getNodeParameter('secureScoreId', i);
|
||||
|
||||
responseData = await msGraphSecurityApiRequest.call(this, 'GET', `/secureScores/${secureScoreId}`);
|
||||
responseData = await msGraphSecurityApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/secureScores/${secureScoreId}`,
|
||||
);
|
||||
delete responseData['@odata.context'];
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScore: getAll
|
||||
// ----------------------------------------
|
||||
@@ -110,10 +103,7 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
|
||||
const qs: IDataObject = {};
|
||||
|
||||
const {
|
||||
filter,
|
||||
includeControlScores,
|
||||
} = this.getNodeParameter('filters', i) as {
|
||||
const { filter, includeControlScores } = this.getNodeParameter('filters', i) as {
|
||||
filter?: string;
|
||||
includeControlScores?: boolean;
|
||||
};
|
||||
@@ -129,38 +119,35 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
qs.$top = this.getNodeParameter('limit', 0);
|
||||
}
|
||||
|
||||
responseData = await msGraphSecurityApiRequest
|
||||
responseData = (await msGraphSecurityApiRequest
|
||||
.call(this, 'GET', '/secureScores', {}, qs)
|
||||
.then(response => response.value) as Array<{ controlScores: object[] }>;
|
||||
.then((response) => response.value)) as Array<{ controlScores: object[] }>;
|
||||
|
||||
if (!includeControlScores) {
|
||||
responseData = responseData.map(({ controlScores, ...rest }) => rest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (resource === 'secureScoreControlProfile') {
|
||||
|
||||
// **********************************************************************
|
||||
// secureScoreControlProfile
|
||||
// **********************************************************************
|
||||
|
||||
if (operation === 'get') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScoreControlProfile: get
|
||||
// ----------------------------------------
|
||||
|
||||
// https://docs.microsoft.com/en-us/graph/api/securescorecontrolprofile-get
|
||||
|
||||
const secureScoreControlProfileId = this.getNodeParameter('secureScoreControlProfileId', i);
|
||||
const secureScoreControlProfileId = this.getNodeParameter(
|
||||
'secureScoreControlProfileId',
|
||||
i,
|
||||
);
|
||||
const endpoint = `/secureScoreControlProfiles/${secureScoreControlProfileId}`;
|
||||
|
||||
responseData = await msGraphSecurityApiRequest.call(this, 'GET', endpoint);
|
||||
delete responseData['@odata.context'];
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScoreControlProfile: getAll
|
||||
// ----------------------------------------
|
||||
@@ -184,10 +171,8 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
|
||||
responseData = await msGraphSecurityApiRequest
|
||||
.call(this, 'GET', '/secureScoreControlProfiles', {}, qs)
|
||||
.then(response => response.value);
|
||||
|
||||
.then((response) => response.value);
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------------
|
||||
// secureScoreControlProfile: update
|
||||
// ----------------------------------------
|
||||
@@ -215,13 +200,17 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
const endpoint = `/secureScoreControlProfiles/${id}`;
|
||||
const headers = { Prefer: 'return=representation' };
|
||||
|
||||
responseData = await msGraphSecurityApiRequest.call(this, 'PATCH', endpoint, body, {}, headers);
|
||||
responseData = await msGraphSecurityApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
endpoint,
|
||||
body,
|
||||
{},
|
||||
headers,
|
||||
);
|
||||
delete responseData['@odata.context'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
@@ -233,7 +222,6 @@ export class MicrosoftGraphSecurity implements INodeType {
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...responseData)
|
||||
: returnData.push(responseData);
|
||||
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const secureScoreControlProfileOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const secureScoreControlProfileOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -49,12 +45,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -70,12 +62,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -91,15 +79,9 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -111,23 +93,20 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Filter Query Parameter',
|
||||
name: 'filter',
|
||||
description: '<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
description:
|
||||
'<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'startsWith(id, \'AATP\')',
|
||||
placeholder: "startsWith(id, 'AATP')",
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -144,12 +123,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -163,12 +138,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -182,12 +153,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -199,12 +166,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScoreControlProfile',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['secureScoreControlProfile'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const secureScoreOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const secureScoreOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -44,12 +40,8 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -65,12 +57,8 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -86,15 +74,9 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -106,19 +88,16 @@ export const secureScoreFields: INodeProperties[] = [
|
||||
placeholder: 'Add Filter',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'secureScore',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['secureScore'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Filter Query Parameter',
|
||||
name: 'filter',
|
||||
description: '<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
description:
|
||||
'<a href="https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter">Query parameter</a> to filter results by',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'currentScore eq 13',
|
||||
|
||||
Reference in New Issue
Block a user