mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
✨ Add Netlify regular and trigger node (#2177)
* ✨ Add Netlify node * ⚡ Add Sites resource * ✨ Add regular Netlify node * ⚡ Add Netlify Trigger node * 🔨 Fix issue with body parameter * ⚡ Improvements * ⚡ Improvements Co-authored-by: Harshil <ghagrawal17@gmail.com>
This commit is contained in:
parent
8a0c0115e5
commit
469ac1d912
18
packages/nodes-base/credentials/NetlifyApi.credentials.ts
Normal file
18
packages/nodes-base/credentials/NetlifyApi.credentials.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class NetlifyApi implements ICredentialType {
|
||||
name = 'netlifyApi';
|
||||
displayName = 'Netlify API';
|
||||
documentationUrl = 'netlify';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'Access Token',
|
||||
name: 'accessToken',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
];
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// import {
|
||||
// ICredentialType,
|
||||
// NodePropertyTypes,
|
||||
// } from 'n8n-workflow';
|
||||
|
||||
// export class NetlifyOAuth2Api implements ICredentialType {
|
||||
// name = 'netlifyOAuth2Api';
|
||||
// extends = [
|
||||
// 'oAuth2Api',
|
||||
// ];
|
||||
// displayName = 'Netlify OAuth2 API';
|
||||
// documentationUrl = 'netlify';
|
||||
// properties = [
|
||||
// {
|
||||
// displayName: 'Authorization URL',
|
||||
// name: 'authUrl',
|
||||
// type: 'hidden' as NodePropertyTypes,
|
||||
// default: 'https://app.netlify.com/authorize',
|
||||
// required: true,
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Client ID',
|
||||
// name: 'clientId',
|
||||
// type: 'string' as NodePropertyTypes,
|
||||
// default: '',
|
||||
// required: true,
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Client Secret',
|
||||
// name: 'clientSecret',
|
||||
// type: 'string' as NodePropertyTypes,
|
||||
// default: '',
|
||||
// required: true,
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Authentication',
|
||||
// name: 'authentication',
|
||||
// type: 'hidden' as NodePropertyTypes,
|
||||
// default: 'body',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Access Token URL',
|
||||
// name: 'accessTokenUrl',
|
||||
// type: 'hidden' as NodePropertyTypes,
|
||||
// default: 'https://api.netlify.com/api/v1/oauth/tickets',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Scope',
|
||||
// name: 'scope',
|
||||
// type: 'hidden' as NodePropertyTypes,
|
||||
// default: '',
|
||||
// },
|
||||
// {
|
||||
// displayName: 'Auth URI Query Parameters',
|
||||
// name: 'authQueryParameters',
|
||||
// type: 'hidden' as NodePropertyTypes,
|
||||
// default: '',
|
||||
// }
|
||||
// ];
|
||||
// }
|
158
packages/nodes-base/nodes/Netlify/DeployDescription.ts
Normal file
158
packages/nodes-base/nodes/Netlify/DeployDescription.ts
Normal file
|
@ -0,0 +1,158 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const deployOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Cancel',
|
||||
value: 'cancel',
|
||||
description: 'Cancel a deployment',
|
||||
},
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new deployment',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a deployment',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Get all deployments',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const deployFields = [
|
||||
{
|
||||
displayName: 'Site ID',
|
||||
name: 'siteId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSites',
|
||||
},
|
||||
description: 'Enter the Site ID',
|
||||
displayOptions:{
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'create',
|
||||
'getAll',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Deploy ID',
|
||||
name: 'deployId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions:{
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'cancel',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
// ----- Get All Deploys ------ //
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 200,
|
||||
},
|
||||
default: 50,
|
||||
description: 'How many results to return',
|
||||
},
|
||||
// ---- Create Site Deploy ---- //
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Fields',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'deploy',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Branch',
|
||||
name: 'branch',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
70
packages/nodes-base/nodes/Netlify/GenericFunctions.ts
Normal file
70
packages/nodes-base/nodes/Netlify/GenericFunctions.ts
Normal file
|
@ -0,0 +1,70 @@
|
|||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
IHookFunctions,
|
||||
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
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
qs: query,
|
||||
body,
|
||||
uri: uri || `https://api.netlify.com/api/v1${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (!Object.keys(body).length) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
if (Object.keys(option)) {
|
||||
Object.assign(options, option);
|
||||
}
|
||||
console.log(options);
|
||||
|
||||
try {
|
||||
const credentials = await this.getCredentials('netlifyApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
||||
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function netlifyRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
query.page = 0;
|
||||
query.per_page = 100;
|
||||
|
||||
do {
|
||||
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')
|
||||
);
|
||||
|
||||
return returnData;
|
||||
}
|
184
packages/nodes-base/nodes/Netlify/Netlify.node.ts
Normal file
184
packages/nodes-base/nodes/Netlify/Netlify.node.ts
Normal file
|
@ -0,0 +1,184 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
netlifyApiRequest,
|
||||
netlifyRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
deployFields,
|
||||
deployOperations
|
||||
} from './DeployDescription';
|
||||
|
||||
import {
|
||||
siteFields,
|
||||
siteOperations
|
||||
} from './SiteDescription';
|
||||
|
||||
export class Netlify implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Netlify',
|
||||
name: 'netlify',
|
||||
icon: 'file:netlify.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Netlify API',
|
||||
defaults: {
|
||||
name: 'Netlify',
|
||||
color: '#1A82e2',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'netlifyApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Deploy',
|
||||
value: 'deploy',
|
||||
},
|
||||
{
|
||||
name: 'Site',
|
||||
value: 'site',
|
||||
},
|
||||
],
|
||||
default: 'deploy',
|
||||
description: 'Resource to consume',
|
||||
required: true,
|
||||
},
|
||||
...deployOperations,
|
||||
...deployFields,
|
||||
...siteOperations,
|
||||
...siteFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async getSites(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const sites = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/sites',
|
||||
);
|
||||
for (const site of sites) {
|
||||
returnData.push({
|
||||
name: site.name,
|
||||
value: site.site_id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const length = items.length as unknown as number;
|
||||
let responseData;
|
||||
const returnData: IDataObject[] = [];
|
||||
const qs: IDataObject = {};
|
||||
const body: IDataObject = {};
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (operation === 'create') {
|
||||
const siteId = this.getNodeParameter('siteId', i);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.title) {
|
||||
qs.title = body.title;
|
||||
delete body.title;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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`);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
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}`);
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const siteId = this.getNodeParameter('siteId', i);
|
||||
responseData = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}`);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll === true) {
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
233
packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts
Normal file
233
packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts
Normal file
|
@ -0,0 +1,233 @@
|
|||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
import {
|
||||
netlifyApiRequest,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
snakeCase,
|
||||
} from 'change-case';
|
||||
|
||||
export class NetlifyTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Netlify Trigger',
|
||||
name: 'netlifyTrigger',
|
||||
icon: 'file:netlify.svg',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["event"]}}',
|
||||
description: 'Handle netlify events via webhooks',
|
||||
defaults: {
|
||||
name: 'Netlify Trigger',
|
||||
color: '#6ad7b9',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: ['main'],
|
||||
credentials: [
|
||||
{
|
||||
name: 'netlifyApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Site Name/ID',
|
||||
name: 'siteId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSites',
|
||||
},
|
||||
description: 'Select the Site ID',
|
||||
},
|
||||
{
|
||||
displayName: 'Event',
|
||||
name: 'event',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: '',
|
||||
options: [
|
||||
{
|
||||
name: 'Deploy Building',
|
||||
value: 'deployBuilding',
|
||||
},
|
||||
{
|
||||
name: 'Deploy Failed',
|
||||
value: 'deployFailed',
|
||||
},
|
||||
{
|
||||
name: 'Deploy Created',
|
||||
value: 'deployCreated',
|
||||
},
|
||||
{
|
||||
name: 'Form Submitted',
|
||||
value: 'submissionCreated',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Form ID',
|
||||
name: 'formId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: [
|
||||
'submissionCreated',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getForms',
|
||||
},
|
||||
description: 'Select a form',
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify Response',
|
||||
name: 'simple',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
event: [
|
||||
'submissionCreated',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const qs: IDataObject = {};
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
qs.site_id = this.getNodeParameter('siteId') as string;
|
||||
const webhooks = await netlifyApiRequest.call(this, 'GET', '/hooks', {}, qs);
|
||||
for (const webhook of webhooks) {
|
||||
if (webhook.type === 'url') {
|
||||
if (webhook.data.url === webhookUrl && webhook.event === snakeCase(event)) {
|
||||
webhookData.webhookId = webhook.id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
//TODO - implement missing events
|
||||
// alL posible events can be found doing a GET /hooks/types
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const body: IDataObject = {
|
||||
event: snakeCase(event),
|
||||
data: {
|
||||
url: webhookUrl,
|
||||
},
|
||||
site_id: this.getNodeParameter('siteId') as string,
|
||||
};
|
||||
const formId = this.getNodeParameter('formId', '*') as string;
|
||||
if (event === 'submissionCreated' && formId !== '*') {
|
||||
body.form_id = this.getNodeParameter('formId') as string;
|
||||
}
|
||||
const webhook = await netlifyApiRequest.call(this, 'POST', '/hooks', body);
|
||||
webhookData.webhookId = webhook.id;
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
try {
|
||||
await netlifyApiRequest.call(this, 'DELETE', `/hooks/${webhookData.webhookId}`);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async getSites(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const sites = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/sites',
|
||||
);
|
||||
for (const site of sites) {
|
||||
returnData.push({
|
||||
name: site.name,
|
||||
value: site.site_id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
|
||||
async getForms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const siteId = this.getNodeParameter('siteId');
|
||||
const forms = await netlifyApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/forms`,
|
||||
);
|
||||
for (const form of forms) {
|
||||
returnData.push({
|
||||
name: form.name,
|
||||
value: form.id,
|
||||
});
|
||||
}
|
||||
returnData.unshift({ name: '[All Forms]', value: '*' });
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
const simple = this.getNodeParameter('simple', false) as boolean;
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
let response = req.body;
|
||||
|
||||
if (simple === true && event === 'submissionCreated') {
|
||||
response = response.data;
|
||||
}
|
||||
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(response),
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
98
packages/nodes-base/nodes/Netlify/SiteDescription.ts
Normal file
98
packages/nodes-base/nodes/Netlify/SiteDescription.ts
Normal file
|
@ -0,0 +1,98 @@
|
|||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export const siteOperations = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a site',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a site',
|
||||
},
|
||||
{
|
||||
name: 'Get All',
|
||||
value: 'getAll',
|
||||
description: 'Returns all sites',
|
||||
},
|
||||
],
|
||||
default: 'delete',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
||||
export const siteFields = [
|
||||
{
|
||||
displayName: 'Site ID',
|
||||
name: 'siteId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
'delete',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'site',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 200,
|
||||
},
|
||||
default: 50,
|
||||
description: 'How many results to return',
|
||||
},
|
||||
] as INodeProperties[];
|
9
packages/nodes-base/nodes/Netlify/netlify.svg
Normal file
9
packages/nodes-base/nodes/Netlify/netlify.svg
Normal file
|
@ -0,0 +1,9 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40">
|
||||
<defs>
|
||||
<radialGradient id="a" cy="0%" r="100.11%" fx="50%" fy="0%" gradientTransform="matrix(0 .9989 -1.152 0 .5 -.5)">
|
||||
<stop offset="0%" stop-color="#20C6B7"/>
|
||||
<stop offset="100%" stop-color="#4D9ABF"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<path fill="url(#a)" d="M28.589 14.135l-.014-.006c-.008-.003-.016-.006-.023-.013a.11.11 0 0 1-.028-.093l.773-4.726 3.625 3.626-3.77 1.604a.083.083 0 0 1-.033.006h-.015c-.005-.003-.01-.007-.02-.017a1.716 1.716 0 0 0-.495-.381zm5.258-.288l3.876 3.876c.805.806 1.208 1.208 1.355 1.674.022.069.04.138.054.209l-9.263-3.923a.728.728 0 0 0-.015-.006c-.037-.015-.08-.032-.08-.07 0-.038.044-.056.081-.071l.012-.005 3.98-1.684zm5.127 7.003c-.2.376-.59.766-1.25 1.427l-4.37 4.369-5.652-1.177-.03-.006c-.05-.008-.103-.017-.103-.062a1.706 1.706 0 0 0-.655-1.193c-.023-.023-.017-.059-.01-.092 0-.005 0-.01.002-.014l1.063-6.526.004-.022c.006-.05.015-.108.06-.108a1.73 1.73 0 0 0 1.16-.665c.009-.01.015-.021.027-.027.032-.015.07 0 .103.014l9.65 4.082zm-6.625 6.801l-7.186 7.186 1.23-7.56.002-.01c.001-.01.003-.02.006-.029.01-.024.036-.034.061-.044l.012-.005a1.85 1.85 0 0 0 .695-.517c.024-.028.053-.055.09-.06a.09.09 0 0 1 .029 0l5.06 1.04zm-8.707 8.707l-.81.81-8.955-12.942a.424.424 0 0 0-.01-.014c-.014-.019-.029-.038-.026-.06.001-.016.011-.03.022-.042l.01-.013c.027-.04.05-.08.075-.123l.02-.035.003-.003c.014-.024.027-.047.051-.06.021-.01.05-.006.073-.001l9.921 2.046a.164.164 0 0 1 .076.033c.013.013.016.027.019.043a1.757 1.757 0 0 0 1.028 1.175c.028.014.016.045.003.078a.238.238 0 0 0-.015.045c-.125.76-1.197 7.298-1.485 9.063zm-1.692 1.691c-.597.591-.949.904-1.347 1.03a2 2 0 0 1-1.206 0c-.466-.148-.869-.55-1.674-1.356L8.73 28.73l2.349-3.643c.011-.018.022-.034.04-.047.025-.018.061-.01.091 0a2.434 2.434 0 0 0 1.638-.083c.027-.01.054-.017.075.002a.19.19 0 0 1 .028.032L21.95 38.05zM7.863 27.863L5.8 25.8l4.074-1.738a.084.084 0 0 1 .033-.007c.034 0 .054.034.072.065a2.91 2.91 0 0 0 .13.184l.013.016c.012.017.004.034-.008.05l-2.25 3.493zm-2.976-2.976l-2.61-2.61c-.444-.444-.766-.766-.99-1.043l7.936 1.646a.84.84 0 0 0 .03.005c.049.008.103.017.103.063 0 .05-.059.073-.109.092l-.023.01-4.337 1.837zM.831 19.892a2 2 0 0 1 .09-.495c.148-.466.55-.868 1.356-1.674l3.34-3.34a2175.525 2175.525 0 0 0 4.626 6.687c.027.036.057.076.026.106-.146.161-.292.337-.395.528a.16.16 0 0 1-.05.062c-.013.008-.027.005-.042.002H9.78L.831 19.891zm5.68-6.403l4.491-4.491c.422.185 1.958.834 3.332 1.414 1.04.44 1.988.84 2.286.97.03.012.057.024.07.054.008.018.004.041 0 .06a2.003 2.003 0 0 0 .523 1.828c.03.03 0 .073-.026.11l-.014.021-4.56 7.063c-.012.02-.023.037-.043.05-.024.015-.058.008-.086.001a2.274 2.274 0 0 0-.543-.074c-.164 0-.342.03-.522.063h-.001c-.02.003-.038.007-.054-.005a.21.21 0 0 1-.045-.051l-4.808-7.013zm5.398-5.398l5.814-5.814c.805-.805 1.208-1.208 1.674-1.355a2 2 0 0 1 1.206 0c.466.147.869.55 1.674 1.355l1.26 1.26-4.135 6.404a.155.155 0 0 1-.041.048c-.025.017-.06.01-.09 0a2.097 2.097 0 0 0-1.92.37c-.027.028-.067.012-.101-.003-.54-.235-4.74-2.01-5.341-2.265zm12.506-3.676l3.818 3.818-.92 5.698v.015a.135.135 0 0 1-.008.038c-.01.02-.03.024-.05.03a1.83 1.83 0 0 0-.548.273.154.154 0 0 0-.02.017c-.011.012-.022.023-.04.025a.114.114 0 0 1-.043-.007l-5.818-2.472-.011-.005c-.037-.015-.081-.033-.081-.071a2.198 2.198 0 0 0-.31-.915c-.028-.046-.059-.094-.035-.141l4.066-6.303zm-3.932 8.606l5.454 2.31c.03.014.063.027.076.058a.106.106 0 0 1 0 .057c-.016.08-.03.171-.03.263v.153c0 .038-.039.054-.075.069l-.011.004c-.864.369-12.13 5.173-12.147 5.173-.017 0-.035 0-.052-.017-.03-.03 0-.072.027-.11a.76.76 0 0 0 .014-.02l4.482-6.94.008-.012c.026-.042.056-.089.104-.089l.045.007c.102.014.192.027.283.027.68 0 1.31-.331 1.69-.897a.16.16 0 0 1 .034-.04c.027-.02.067-.01.098.004zm-6.246 9.185l12.28-5.237s.018 0 .035.017c.067.067.124.112.179.154l.027.017c.025.014.05.03.052.056 0 .01 0 .016-.002.025L25.756 23.7l-.004.026c-.007.05-.014.107-.061.107a1.729 1.729 0 0 0-1.373.847l-.005.008c-.014.023-.027.045-.05.057-.021.01-.048.006-.07.001l-9.793-2.02c-.01-.002-.152-.519-.163-.52z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 4 KiB |
|
@ -188,6 +188,7 @@
|
|||
"dist/credentials/Msg91Api.credentials.js",
|
||||
"dist/credentials/MySql.credentials.js",
|
||||
"dist/credentials/NasaApi.credentials.js",
|
||||
"dist/credentials/NetlifyApi.credentials.js",
|
||||
"dist/credentials/NextCloudApi.credentials.js",
|
||||
"dist/credentials/NextCloudOAuth2Api.credentials.js",
|
||||
"dist/credentials/NocoDb.credentials.js",
|
||||
|
@ -494,6 +495,8 @@
|
|||
"dist/nodes/MySql/MySql.node.js",
|
||||
"dist/nodes/N8nTrigger.node.js",
|
||||
"dist/nodes/Nasa/Nasa.node.js",
|
||||
"dist/nodes/Netlify/Netlify.node.js",
|
||||
"dist/nodes/Netlify/NetlifyTrigger.node.js",
|
||||
"dist/nodes/NextCloud/NextCloud.node.js",
|
||||
"dist/nodes/NoOp.node.js",
|
||||
"dist/nodes/NocoDB/NocoDB.node.js",
|
||||
|
|
Loading…
Reference in a new issue