mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,21 +1,10 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
flow,
|
||||
} from 'lodash';
|
||||
import { flow } from 'lodash';
|
||||
|
||||
import type { Zammad } from './types';
|
||||
|
||||
@@ -37,8 +26,9 @@ export async function zammadApiRequest(
|
||||
const authentication = this.getNodeParameter('authentication', 0) as 'basicAuth' | 'tokenAuth';
|
||||
|
||||
if (authentication === 'basicAuth') {
|
||||
|
||||
const credentials = await this.getCredentials('zammadBasicAuthApi') as Zammad.BasicAuthCredentials;
|
||||
const credentials = (await this.getCredentials(
|
||||
'zammadBasicAuthApi',
|
||||
)) as Zammad.BasicAuthCredentials;
|
||||
|
||||
const baseUrl = tolerateTrailingSlash(credentials.baseUrl);
|
||||
|
||||
@@ -50,10 +40,10 @@ export async function zammadApiRequest(
|
||||
};
|
||||
|
||||
options.rejectUnauthorized = !credentials.allowUnauthorizedCerts;
|
||||
|
||||
} else {
|
||||
|
||||
const credentials = await this.getCredentials('zammadTokenAuthApi') as Zammad.TokenAuthCredentials;
|
||||
const credentials = (await this.getCredentials(
|
||||
'zammadTokenAuthApi',
|
||||
)) as Zammad.TokenAuthCredentials;
|
||||
|
||||
const baseUrl = tolerateTrailingSlash(credentials.baseUrl);
|
||||
|
||||
@@ -64,7 +54,6 @@ export async function zammadApiRequest(
|
||||
};
|
||||
|
||||
options.rejectUnauthorized = !credentials.allowUnauthorizedCerts;
|
||||
|
||||
}
|
||||
|
||||
if (!Object.keys(body).length) {
|
||||
@@ -117,9 +106,7 @@ export async function zammadApiRequestAllItems(
|
||||
}
|
||||
|
||||
export function tolerateTrailingSlash(url: string) {
|
||||
return url.endsWith('/')
|
||||
? url.substr(0, url.length - 1)
|
||||
: url;
|
||||
return url.endsWith('/') ? url.substr(0, url.length - 1) : url;
|
||||
}
|
||||
|
||||
export function throwOnEmptyUpdate(this: IExecuteFunctions, resource: string) {
|
||||
@@ -143,18 +130,19 @@ export const isCustomer = (user: Zammad.User) =>
|
||||
user.role_ids.includes(3) && !user.email.endsWith('@zammad.org');
|
||||
|
||||
export async function getAllFields(this: ILoadOptionsFunctions) {
|
||||
return await zammadApiRequest.call(this, 'GET', '/object_manager_attributes') as Zammad.Field[];
|
||||
return (await zammadApiRequest.call(this, 'GET', '/object_manager_attributes')) as Zammad.Field[];
|
||||
}
|
||||
|
||||
const isTypeField = (resource: 'Group' | 'Organization' | 'Ticket' | 'User') =>
|
||||
(arr: Zammad.Field[]) => arr.filter(i => i.object === resource);
|
||||
const isTypeField =
|
||||
(resource: 'Group' | 'Organization' | 'Ticket' | 'User') => (arr: Zammad.Field[]) =>
|
||||
arr.filter((i) => i.object === resource);
|
||||
|
||||
export const getGroupFields = isTypeField('Group');
|
||||
export const getOrganizationFields = isTypeField('Organization');
|
||||
export const getUserFields = isTypeField('User');
|
||||
export const getTicketFields = isTypeField('Ticket');
|
||||
|
||||
const getCustomFields = (arr: Zammad.Field[]) => arr.filter(i => i.created_by_id !== 1);
|
||||
const getCustomFields = (arr: Zammad.Field[]) => arr.filter((i) => i.created_by_id !== 1);
|
||||
|
||||
export const getGroupCustomFields = flow(getGroupFields, getCustomFields);
|
||||
export const getOrganizationCustomFields = flow(getOrganizationFields, getCustomFields);
|
||||
@@ -163,4 +151,5 @@ export const getTicketCustomFields = flow(getTicketFields, getCustomFields);
|
||||
|
||||
export const isNotZammadFoundation = (i: Zammad.Organization) => i.name !== 'Zammad Foundation';
|
||||
|
||||
export const doesNotBelongToZammad = (i: Zammad.User) => !i.email.endsWith('@zammad.org') && i.login !== '-';
|
||||
export const doesNotBelongToZammad = (i: Zammad.User) =>
|
||||
!i.email.endsWith('@zammad.org') && i.login !== '-';
|
||||
|
||||
Reference in New Issue
Block a user