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 {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -9,10 +7,7 @@ import {
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function webflowApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
@@ -34,7 +29,6 @@ export async function webflowApiRequest(
|
||||
credentialsType = 'webflowOAuth2Api';
|
||||
}
|
||||
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
'accept-version': '1.0.0',
|
||||
@@ -68,7 +62,6 @@ export async function webflowApiRequestAllItems(
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
) {
|
||||
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -82,10 +75,7 @@ export async function webflowApiRequestAllItems(
|
||||
query.offset += query.limit;
|
||||
}
|
||||
returnData.push.apply(returnData, responseData.items);
|
||||
} while (
|
||||
returnData.length < responseData.total
|
||||
);
|
||||
} while (returnData.length < responseData.total);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const itemOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -38,9 +36,7 @@ export const itemOperations: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
resource: ['item'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -61,15 +57,12 @@ export const itemFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the site containing the collection whose items to add to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the site containing the collection whose items to add to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Collection Name or ID',
|
||||
@@ -78,22 +71,17 @@ export const itemFields: INodeProperties[] = [
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCollections',
|
||||
loadOptionsDependsOn: [
|
||||
'siteId',
|
||||
],
|
||||
loadOptionsDependsOn: ['siteId'],
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the collection to add an item to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the collection to add an item to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Live',
|
||||
@@ -103,12 +91,8 @@ export const itemFields: INodeProperties[] = [
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'Whether the item should be published on the live site',
|
||||
@@ -124,12 +108,8 @@ export const itemFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -143,12 +123,11 @@ export const itemFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getFields',
|
||||
loadOptionsDependsOn: [
|
||||
'collectionId',
|
||||
],
|
||||
loadOptionsDependsOn: ['collectionId'],
|
||||
},
|
||||
default: '',
|
||||
description: 'Field to set for the item to create. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Field to set for the item to create. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Field Value',
|
||||
@@ -176,16 +155,12 @@ export const itemFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['delete', 'get'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the site containing the collection whose items to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the site containing the collection whose items to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Collection Name or ID',
|
||||
@@ -194,23 +169,17 @@ export const itemFields: INodeProperties[] = [
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCollections',
|
||||
loadOptionsDependsOn: [
|
||||
'siteId',
|
||||
],
|
||||
loadOptionsDependsOn: ['siteId'],
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['delete', 'get'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the collection whose items to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the collection whose items to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Item ID',
|
||||
@@ -220,13 +189,8 @@ export const itemFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['delete', 'get'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the item to operate on',
|
||||
@@ -245,15 +209,12 @@ export const itemFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the site containing the collection whose items to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the site containing the collection whose items to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Collection Name or ID',
|
||||
@@ -262,22 +223,17 @@ export const itemFields: INodeProperties[] = [
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCollections',
|
||||
loadOptionsDependsOn: [
|
||||
'siteId',
|
||||
],
|
||||
loadOptionsDependsOn: ['siteId'],
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the collection whose items to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the collection whose items to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Item ID',
|
||||
@@ -287,12 +243,8 @@ export const itemFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the item to update',
|
||||
@@ -305,12 +257,8 @@ export const itemFields: INodeProperties[] = [
|
||||
default: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
description: 'Whether the item should be published on the live site',
|
||||
@@ -326,12 +274,8 @@ export const itemFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -345,12 +289,11 @@ export const itemFields: INodeProperties[] = [
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getFields',
|
||||
loadOptionsDependsOn: [
|
||||
'collectionId',
|
||||
],
|
||||
loadOptionsDependsOn: ['collectionId'],
|
||||
},
|
||||
default: '',
|
||||
description: 'Field to set for the item to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Field to set for the item to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Field Value',
|
||||
@@ -377,15 +320,12 @@ export const itemFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the site containing the collection whose items to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the site containing the collection whose items to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Collection Name or ID',
|
||||
@@ -394,22 +334,17 @@ export const itemFields: INodeProperties[] = [
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCollections',
|
||||
loadOptionsDependsOn: [
|
||||
'siteId',
|
||||
],
|
||||
loadOptionsDependsOn: ['siteId'],
|
||||
},
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
description: 'ID of the collection whose items to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'ID of the collection whose items to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
@@ -417,12 +352,8 @@ export const itemFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -434,15 +365,9 @@ export const itemFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'item',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['item'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -11,15 +9,9 @@ import {
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
webflowApiRequest,
|
||||
webflowApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { webflowApiRequest, webflowApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
itemFields,
|
||||
itemOperations,
|
||||
} from './ItemDescription';
|
||||
import { itemFields, itemOperations } from './ItemDescription';
|
||||
|
||||
export class Webflow implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -41,9 +33,7 @@ export class Webflow implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
authentication: ['accessToken'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -52,9 +42,7 @@ export class Webflow implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -110,7 +98,11 @@ export class Webflow implements INodeType {
|
||||
async getCollections(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const siteId = this.getCurrentNodeParameter('siteId');
|
||||
const collections = await webflowApiRequest.call(this, 'GET', `/sites/${siteId}/collections`);
|
||||
const collections = await webflowApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/collections`,
|
||||
);
|
||||
for (const collection of collections) {
|
||||
returnData.push({
|
||||
name: collection.name,
|
||||
@@ -122,10 +114,14 @@ export class Webflow implements INodeType {
|
||||
async getFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const collectionId = this.getCurrentNodeParameter('collectionId');
|
||||
const { fields } = await webflowApiRequest.call(this, 'GET', `/collections/${collectionId}`);
|
||||
const { fields } = await webflowApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/collections/${collectionId}`,
|
||||
);
|
||||
for (const field of fields) {
|
||||
returnData.push({
|
||||
name: `${field.name} (${field.type}) ${(field.required) ? ' (required)' : ''}`,
|
||||
name: `${field.name} (${field.type}) ${field.required ? ' (required)' : ''}`,
|
||||
value: field.slug,
|
||||
});
|
||||
}
|
||||
@@ -144,10 +140,8 @@ export class Webflow implements INodeType {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
||||
try {
|
||||
if (resource === 'item') {
|
||||
|
||||
// *********************************************************************
|
||||
// item
|
||||
// *********************************************************************
|
||||
@@ -155,7 +149,6 @@ export class Webflow implements INodeType {
|
||||
// https://developers.webflow.com/#item-model
|
||||
|
||||
if (operation === 'create') {
|
||||
|
||||
// ----------------------------------
|
||||
// item: create
|
||||
// ----------------------------------
|
||||
@@ -164,22 +157,30 @@ export class Webflow implements INodeType {
|
||||
|
||||
const collectionId = this.getNodeParameter('collectionId', i) as string;
|
||||
|
||||
const properties = this.getNodeParameter('fieldsUi.fieldValues', i, []) as IDataObject[];
|
||||
const properties = this.getNodeParameter(
|
||||
'fieldsUi.fieldValues',
|
||||
i,
|
||||
[],
|
||||
) as IDataObject[];
|
||||
|
||||
const live = this.getNodeParameter('live', i) as boolean;
|
||||
|
||||
const fields = {} as IDataObject;
|
||||
|
||||
properties.forEach(data => (fields[data.fieldId as string] = data.fieldValue));
|
||||
properties.forEach((data) => (fields[data.fieldId as string] = data.fieldValue));
|
||||
|
||||
const body: IDataObject = {
|
||||
fields,
|
||||
};
|
||||
|
||||
responseData = await webflowApiRequest.call(this, 'POST', `/collections/${collectionId}/items`, body, { live });
|
||||
|
||||
responseData = await webflowApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/collections/${collectionId}/items`,
|
||||
body,
|
||||
{ live },
|
||||
);
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------
|
||||
// item: delete
|
||||
// ----------------------------------
|
||||
@@ -188,10 +189,12 @@ export class Webflow implements INodeType {
|
||||
|
||||
const collectionId = this.getNodeParameter('collectionId', i) as string;
|
||||
const itemId = this.getNodeParameter('itemId', i) as string;
|
||||
responseData = await webflowApiRequest.call(this, 'DELETE', `/collections/${collectionId}/items/${itemId}`);
|
||||
|
||||
responseData = await webflowApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/collections/${collectionId}/items/${itemId}`,
|
||||
);
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------
|
||||
// item: get
|
||||
// ----------------------------------
|
||||
@@ -200,11 +203,13 @@ export class Webflow implements INodeType {
|
||||
|
||||
const collectionId = this.getNodeParameter('collectionId', i) as string;
|
||||
const itemId = this.getNodeParameter('itemId', i) as string;
|
||||
responseData = await webflowApiRequest.call(this, 'GET', `/collections/${collectionId}/items/${itemId}`);
|
||||
responseData = await webflowApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/collections/${collectionId}/items/${itemId}`,
|
||||
);
|
||||
responseData = responseData.items;
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------
|
||||
// item: getAll
|
||||
// ----------------------------------
|
||||
@@ -216,15 +221,25 @@ export class Webflow implements INodeType {
|
||||
const qs: IDataObject = {};
|
||||
|
||||
if (returnAll === true) {
|
||||
responseData = await webflowApiRequestAllItems.call(this, 'GET', `/collections/${collectionId}/items`, {}, qs);
|
||||
responseData = await webflowApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
`/collections/${collectionId}/items`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await webflowApiRequest.call(this, 'GET', `/collections/${collectionId}/items`, {}, qs);
|
||||
responseData = await webflowApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/collections/${collectionId}/items`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.items;
|
||||
}
|
||||
|
||||
} else if (operation === 'update') {
|
||||
|
||||
// ----------------------------------
|
||||
// item: update
|
||||
// ----------------------------------
|
||||
@@ -235,19 +250,29 @@ export class Webflow implements INodeType {
|
||||
|
||||
const itemId = this.getNodeParameter('itemId', i) as string;
|
||||
|
||||
const properties = this.getNodeParameter('fieldsUi.fieldValues', i, []) as IDataObject[];
|
||||
const properties = this.getNodeParameter(
|
||||
'fieldsUi.fieldValues',
|
||||
i,
|
||||
[],
|
||||
) as IDataObject[];
|
||||
|
||||
const live = this.getNodeParameter('live', i) as boolean;
|
||||
|
||||
const fields = {} as IDataObject;
|
||||
|
||||
properties.forEach(data => (fields[data.fieldId as string] = data.fieldValue));
|
||||
properties.forEach((data) => (fields[data.fieldId as string] = data.fieldValue));
|
||||
|
||||
const body: IDataObject = {
|
||||
fields,
|
||||
};
|
||||
|
||||
responseData = await webflowApiRequest.call(this, 'PUT', `/collections/${collectionId}/items/${itemId}`, body, { live });
|
||||
responseData = await webflowApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/collections/${collectionId}/items/${itemId}`,
|
||||
body,
|
||||
{ live },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,9 +9,7 @@ import {
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
webflowApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { webflowApiRequest } from './GenericFunctions';
|
||||
|
||||
export class WebflowTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -35,9 +30,7 @@ export class WebflowTrigger implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
authentication: ['accessToken'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -46,9 +39,7 @@ export class WebflowTrigger implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -87,7 +78,8 @@ export class WebflowTrigger implements INodeType {
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getSites',
|
||||
},
|
||||
description: 'Site that will trigger the events. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Site that will trigger the events. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Event',
|
||||
@@ -212,7 +204,11 @@ export class WebflowTrigger implements INodeType {
|
||||
const siteId = this.getNodeParameter('site') as string;
|
||||
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const registeredWebhooks = await webflowApiRequest.call(this, 'GET', `/sites/${siteId}/webhooks`) as IDataObject[];
|
||||
const registeredWebhooks = (await webflowApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/sites/${siteId}/webhooks`,
|
||||
)) as IDataObject[];
|
||||
|
||||
for (const webhook of registeredWebhooks) {
|
||||
if (webhook.url === webhookUrl && webhook.triggerType === event) {
|
||||
@@ -234,7 +230,6 @@ export class WebflowTrigger implements INodeType {
|
||||
site_id: siteId,
|
||||
triggerType: event,
|
||||
url: webhookUrl,
|
||||
|
||||
};
|
||||
|
||||
// if (event.startsWith('collection')) {
|
||||
@@ -273,9 +268,7 @@ export class WebflowTrigger implements INodeType {
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
return {
|
||||
workflowData: [
|
||||
this.helpers.returnJsonArray(req.body),
|
||||
],
|
||||
workflowData: [this.helpers.returnJsonArray(req.body)],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user