mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const deployOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const deployOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
resource: ['deploy'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -55,17 +51,12 @@ export const deployFields: INodeProperties[] = [
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSites',
|
||||
},
|
||||
description: 'Enter the Site ID. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
displayOptions:{
|
||||
description:
|
||||
'Enter the Site ID. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'create',
|
||||
'getAll',
|
||||
],
|
||||
resource: ['deploy'],
|
||||
operation: ['get', 'create', 'getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -75,31 +66,22 @@ export const deployFields: INodeProperties[] = [
|
||||
required: true,
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions:{
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'cancel',
|
||||
],
|
||||
resource: ['deploy'],
|
||||
operation: ['get', 'cancel'],
|
||||
},
|
||||
},
|
||||
},
|
||||
// ----- Get All Deploys ------ //
|
||||
// ----- Get All Deploys ------ //
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['deploy'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -111,15 +93,9 @@ export const deployFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['deploy'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -138,12 +114,8 @@ export const deployFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['deploy'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -9,12 +7,19 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function netlifyApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
export async function netlifyApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
method,
|
||||
headers: {
|
||||
@@ -45,8 +50,15 @@ export async function netlifyApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||
}
|
||||
}
|
||||
|
||||
export async function netlifyRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function netlifyRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -54,12 +66,12 @@ export async function netlifyRequestAllItems(this: IExecuteFunctions | ILoadOpti
|
||||
query.per_page = 100;
|
||||
|
||||
do {
|
||||
responseData = await netlifyApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true });
|
||||
responseData = await netlifyApiRequest.call(this, method, endpoint, body, query, undefined, {
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
query.page++;
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
} while (
|
||||
responseData.headers.link.includes('next')
|
||||
);
|
||||
} while (responseData.headers.link.includes('next'));
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -11,20 +9,11 @@ import {
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
netlifyApiRequest,
|
||||
netlifyRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { netlifyApiRequest, netlifyRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
deployFields,
|
||||
deployOperations
|
||||
} from './DeployDescription';
|
||||
import { deployFields, deployOperations } from './DeployDescription';
|
||||
|
||||
import {
|
||||
siteFields,
|
||||
siteOperations
|
||||
} from './SiteDescription';
|
||||
import { siteFields, siteOperations } from './SiteDescription';
|
||||
|
||||
export class Netlify implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -76,11 +65,7 @@ export class Netlify implements INodeType {
|
||||
loadOptions: {
|
||||
async getSites(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const sites = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/sites',
|
||||
);
|
||||
const sites = await netlifyApiRequest.call(this, 'GET', '/sites');
|
||||
for (const site of sites) {
|
||||
returnData.push({
|
||||
name: site.name,
|
||||
@@ -105,10 +90,15 @@ export class Netlify implements INodeType {
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
if (resource === 'deploy') {
|
||||
|
||||
if (operation === 'cancel') {
|
||||
const deployId = this.getNodeParameter('deployId', i);
|
||||
responseData = await netlifyApiRequest.call(this, 'POST', `/deploys/${deployId}/cancel`, body, qs);
|
||||
responseData = await netlifyApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/deploys/${deployId}/cancel`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'create') {
|
||||
@@ -122,28 +112,49 @@ export class Netlify implements INodeType {
|
||||
delete body.title;
|
||||
}
|
||||
|
||||
responseData = await netlifyApiRequest.call(this, 'POST', `/sites/${siteId}/deploys`, body, qs);
|
||||
responseData = await netlifyApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/sites/${siteId}/deploys`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const siteId = this.getNodeParameter('siteId', i);
|
||||
const deployId = this.getNodeParameter('deployId', i);
|
||||
responseData = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}/deploys/${deployId}`, body, qs);
|
||||
responseData = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/deploys/${deployId}`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const siteId = this.getNodeParameter('siteId', i);
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll === true) {
|
||||
responseData = await netlifyRequestAllItems.call(this, 'GET', `/sites/${siteId}/deploys`);
|
||||
responseData = await netlifyRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/deploys`,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}/deploys`, {}, { per_page: limit });
|
||||
responseData = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/deploys`,
|
||||
{},
|
||||
{ per_page: limit },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'site') {
|
||||
|
||||
if (operation === 'delete') {
|
||||
const siteId = this.getNodeParameter('siteId', i);
|
||||
responseData = await netlifyApiRequest.call(this, 'DELETE', `/sites/${siteId}`);
|
||||
@@ -157,10 +168,22 @@ export class Netlify implements INodeType {
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll === true) {
|
||||
responseData = await netlifyRequestAllItems.call(this, 'GET', `/sites`, {}, { filter: 'all' });
|
||||
responseData = await netlifyRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites`,
|
||||
{},
|
||||
{ filter: 'all' },
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await netlifyApiRequest.call(this, 'GET', `/sites`, {}, { filter: 'all', per_page: limit });
|
||||
responseData = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites`,
|
||||
{},
|
||||
{ filter: 'all', per_page: limit },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,4 +203,4 @@ export class Netlify implements INodeType {
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,14 +9,9 @@ import {
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { netlifyApiRequest } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
netlifyApiRequest,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
snakeCase,
|
||||
} from 'change-case';
|
||||
import { snakeCase } from 'change-case';
|
||||
|
||||
export class NetlifyTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -59,7 +51,8 @@ export class NetlifyTrigger implements INodeType {
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSites',
|
||||
},
|
||||
description: 'Select the Site ID. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Select the Site ID. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Event',
|
||||
@@ -93,16 +86,15 @@ export class NetlifyTrigger implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: [
|
||||
'submissionCreated',
|
||||
],
|
||||
event: ['submissionCreated'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getForms',
|
||||
},
|
||||
description: 'Select a form. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Select a form. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
@@ -110,13 +102,12 @@ export class NetlifyTrigger implements INodeType {
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: [
|
||||
'submissionCreated',
|
||||
],
|
||||
event: ['submissionCreated'],
|
||||
},
|
||||
},
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
description:
|
||||
'Whether to return a simplified version of the response instead of the raw data',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -179,11 +170,7 @@ export class NetlifyTrigger implements INodeType {
|
||||
loadOptions: {
|
||||
async getSites(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const sites = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/sites',
|
||||
);
|
||||
const sites = await netlifyApiRequest.call(this, 'GET', '/sites');
|
||||
for (const site of sites) {
|
||||
returnData.push({
|
||||
name: site.name,
|
||||
@@ -196,11 +183,7 @@ export class NetlifyTrigger implements INodeType {
|
||||
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const siteId = this.getNodeParameter('siteId');
|
||||
const forms = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/forms`,
|
||||
);
|
||||
const forms = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}/forms`);
|
||||
for (const form of forms) {
|
||||
returnData.push({
|
||||
name: form.name,
|
||||
@@ -224,9 +207,7 @@ export class NetlifyTrigger implements INodeType {
|
||||
}
|
||||
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(response),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(response)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const siteOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const siteOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
resource: ['site'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -48,13 +44,8 @@ export const siteFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'delete',
|
||||
],
|
||||
resource: ['site'],
|
||||
operation: ['get', 'delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -64,12 +55,8 @@ export const siteFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['site'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -81,15 +68,9 @@ export const siteFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['site'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
|
||||
Reference in New Issue
Block a user