n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,23 +1,15 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
apiRequest,
|
||||
apiRequestAllItems,
|
||||
} from '../../../transport';
|
||||
import { apiRequest, apiRequestAllItems } from '../../../transport';
|
||||
|
||||
import {
|
||||
snakeCase,
|
||||
} from 'change-case';
|
||||
import { snakeCase } from 'change-case';
|
||||
|
||||
export async function getAll(this: IExecuteFunctions, index: number): Promise<INodeExecutionData[]> {
|
||||
export async function getAll(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const returnAll = this.getNodeParameter('returnAll', index) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', index) as IDataObject;
|
||||
|
||||
@@ -53,27 +45,51 @@ export async function getAll(this: IExecuteFunctions, index: number): Promise<IN
|
||||
|
||||
if (additionalFields.sort) {
|
||||
if (additionalFields.inTeam !== undefined || additionalFields.inChannel !== undefined) {
|
||||
|
||||
if (additionalFields.inTeam !== undefined
|
||||
&& !validRules.inTeam.includes(snakeCase(additionalFields.sort as string))) {
|
||||
throw new NodeOperationError(this.getNode(), `When In Team is set the only valid values for sorting are ${validRules.inTeam.join(',')}`, { itemIndex: index });
|
||||
if (
|
||||
additionalFields.inTeam !== undefined &&
|
||||
!validRules.inTeam.includes(snakeCase(additionalFields.sort as string))
|
||||
) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`When In Team is set the only valid values for sorting are ${validRules.inTeam.join(
|
||||
',',
|
||||
)}`,
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
if (additionalFields.inChannel !== undefined
|
||||
&& !validRules.inChannel.includes(snakeCase(additionalFields.sort as string))) {
|
||||
throw new NodeOperationError(this.getNode(), `When In Channel is set the only valid values for sorting are ${validRules.inChannel.join(',')}`, { itemIndex: index });
|
||||
if (
|
||||
additionalFields.inChannel !== undefined &&
|
||||
!validRules.inChannel.includes(snakeCase(additionalFields.sort as string))
|
||||
) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`When In Channel is set the only valid values for sorting are ${validRules.inChannel.join(
|
||||
',',
|
||||
)}`,
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
if (additionalFields.inChannel === ''
|
||||
&& additionalFields.sort !== 'username') {
|
||||
throw new NodeOperationError(this.getNode(), 'When sort is different than username In Channel must be set', { itemIndex: index });
|
||||
if (additionalFields.inChannel === '' && additionalFields.sort !== 'username') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'When sort is different than username In Channel must be set',
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
|
||||
if (additionalFields.inTeam === ''
|
||||
&& additionalFields.sort !== 'username') {
|
||||
throw new NodeOperationError(this.getNode(), 'When sort is different than username In Team must be set', { itemIndex: index });
|
||||
if (additionalFields.inTeam === '' && additionalFields.sort !== 'username') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'When sort is different than username In Team must be set',
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), `When sort is defined either 'in team' or 'in channel' must be defined`, { itemIndex: index });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`When sort is defined either 'in team' or 'in channel' must be defined`,
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +101,6 @@ export async function getAll(this: IExecuteFunctions, index: number): Promise<IN
|
||||
qs.per_page = this.getNodeParameter('limit', index) as number;
|
||||
}
|
||||
|
||||
|
||||
let responseData;
|
||||
|
||||
if (returnAll) {
|
||||
|
||||
Reference in New Issue
Block a user