🔀 Merge master

This commit is contained in:
Iván Ovejero
2021-12-13 09:50:26 +01:00
72 changed files with 2348 additions and 767 deletions

View File

@@ -0,0 +1,18 @@
import {
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class FigmaApi implements ICredentialType {
name = 'figmaApi';
displayName = 'Figma API';
documentationUrl = 'figma';
properties: INodeProperties[] = [
{
displayName: 'Access Token',
name: 'accessToken',
type: 'string',
default: '',
},
];
}

View File

@@ -4,7 +4,12 @@ import {
} from 'n8n-workflow';
const scopes = [
'contacts',
'crm.objects.contacts.read',
'crm.schemas.contacts.read',
'crm.objects.companies.read',
'crm.schemas.companies.read',
'crm.objects.deals.read',
'crm.schemas.deals.read',
];
export class HubspotDeveloperApi implements ICredentialType {

View File

@@ -4,7 +4,16 @@ import {
} from 'n8n-workflow';
const scopes = [
'contacts',
'crm.schemas.deals.read',
'crm.objects.owners.read',
'crm.objects.contacts.write',
'crm.objects.companies.write',
'crm.objects.companies.read',
'crm.objects.deals.read',
'crm.schemas.contacts.read',
'crm.objects.deals.write',
'crm.objects.contacts.read',
'crm.schemas.companies.read',
'forms',
'tickets',
];

View File

@@ -33,7 +33,7 @@ export class PagerDutyOAuth2Api implements ICredentialType {
displayName: 'Scope',
name: 'scope',
type: 'hidden',
default: '',
default: 'write',
},
{
displayName: 'Authentication',

View File

@@ -0,0 +1,24 @@
import {
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class WorkableApi implements ICredentialType {
name = 'workableApi';
displayName = 'Workable API';
documentationUrl = 'workable';
properties: INodeProperties[] = [
{
displayName: 'Subdomain',
name: 'subdomain',
type: 'string',
default: '',
},
{
displayName: 'Access Token',
name: 'accessToken',
type: 'string',
default: '',
},
];
}

View File

@@ -452,7 +452,10 @@ export class ApiTemplateIo implements INodeType {
try {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
let options: IDataObject = {};
if (download) {
options = this.getNodeParameter('options', i) as IDataObject;
}
const qs = {
template_id: this.getNodeParameter('imageTemplateId', i),
@@ -529,7 +532,10 @@ export class ApiTemplateIo implements INodeType {
try {
const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
let options: IDataObject = {};
if (download) {
options = this.getNodeParameter('options', i) as IDataObject;
}
const qs = {
template_id: this.getNodeParameter('pdfTemplateId', i),

View File

@@ -0,0 +1,183 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import {
IDataObject,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from 'n8n-workflow';
import {
figmaApiRequest,
} from './GenericFunctions';
import {
snakeCase,
} from 'change-case';
import {
randomBytes,
} from 'crypto';
export class FigmaTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'Figma Trigger (Beta)',
name: 'figmaTrigger',
icon: 'file:figma.svg',
group: ['trigger'],
version: 1,
subtitle: '={{$parameter["triggerOn"]}}',
description: 'Starts the workflow when Figma events occur',
defaults: {
name: 'Figma Trigger (Beta)',
color: '#29b6f6',
},
inputs: [],
outputs: ['main'],
credentials: [
{
name: 'figmaApi',
required: true,
},
],
webhooks: [
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
path: 'webhook',
},
],
properties: [
{
displayName: 'Team ID',
name: 'teamId',
type: 'string',
required: true,
default: '',
description: 'Trigger will monitor this Figma Team for changes. Team ID can be found in the URL of a Figma Team page when viewed in a web browser: figma.com/files/team/{TEAM-ID}/',
},
{
displayName: 'Trigger On',
name: 'triggerOn',
type: 'options',
options: [
{
name: 'File Commented',
value: 'fileComment',
description: 'Triggers when someone comments on a file',
},
{
name: 'File Deleted',
value: 'fileDelete',
description: 'Triggers whenever a file has been deleted. Does not trigger on all files within a folder, if the folder is deleted',
},
{
name: 'File Updated',
value: 'fileUpdate',
description: 'Triggers whenever a file saves or is deleted. This occurs whenever a file is closed or within 30 seconds after changes have been made',
},
{
name: 'File Version Updated',
value: 'fileVersionUpdate',
description: 'Triggers whenever a named version is created in the version history of a file',
},
{
name: 'Library Publish',
value: 'libraryPublish',
description: 'Triggers whenever a library file is published',
},
],
default: '',
required: true,
},
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const webhookData = this.getWorkflowStaticData('node');
const teamId = this.getNodeParameter('teamId') as string;
const triggerOn = this.getNodeParameter('triggerOn') as string;
// Check all the webhooks which exist already if it is identical to the
// one that is supposed to get created.
const { webhooks } = await figmaApiRequest.call(this, 'GET', `/v2/teams/${teamId}/webhooks`);
for (const webhook of webhooks) {
if (webhook.endpoint === webhookUrl
&& webhook.team_id === teamId
&& webhook.event_type === snakeCase(triggerOn).toUpperCase()
&& webhook.status === 'ACTIVE') {
webhookData.webhookId = webhook.id as string;
return true;
}
}
return false;
},
async create(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
const webhookUrl = this.getNodeWebhookUrl('default');
const triggerOn = this.getNodeParameter('triggerOn') as string;
const teamId = this.getNodeParameter('teamId') as string;
const endpoint = '/v2/webhooks';
const body: IDataObject = {
event_type: snakeCase(triggerOn).toUpperCase(),
team_id: teamId,
description: `n8n-webhook:${webhookUrl}`,
endpoint: webhookUrl,
passcode: randomBytes(10).toString('hex') as string,
};
const responseData = await figmaApiRequest.call(this, 'POST', endpoint, body);
if (responseData.id === undefined) {
// Required data is missing so was not successful
return false;
}
webhookData.webhookId = responseData.id as string;
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId !== undefined) {
const endpoint = `/v2/webhooks/${webhookData.webhookId}`;
try {
await figmaApiRequest.call(this, 'DELETE', endpoint);
} catch (error) {
return false;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registred anymore
delete webhookData.webhookId;
}
return true;
},
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData();
if (bodyData.event_type === 'PING') {
const res = this.getResponseObject();
res.status(200).end();
return {
noWebhookResponse: true,
};
}
return {
workflowData: [
this.helpers.returnJsonArray(bodyData),
],
};
}
}

View File

@@ -0,0 +1,36 @@
import {
OptionsWithUri,
} from 'request';
import {
IExecuteFunctions,
IExecuteSingleFunctions,
IHookFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject,
NodeApiError,
} from 'n8n-workflow';
export async function figmaApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('figmaApi') as { accessToken: string };
let options: OptionsWithUri = {
headers: { 'X-FIGMA-TOKEN': credentials.accessToken },
method,
body,
uri: uri || `https://api.figma.com${resource}`,
json: true,
};
options = Object.assign({}, options, option);
if (Object.keys(options.body).length === 0) {
delete options.body;
}
try {
return await this.helpers.request!(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}

View File

@@ -0,0 +1 @@
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 300" width="1667" height="2500"><style type="text/css">.st0{fill:#0acf83}.st1{fill:#a259ff}.st2{fill:#f24e1e}.st3{fill:#ff7262}.st4{fill:#1abcfe}</style><title>Figma.logo</title><desc>Created using Figma</desc><path id="path0_fill" class="st0" d="M50 300c27.6 0 50-22.4 50-50v-50H50c-27.6 0-50 22.4-50 50s22.4 50 50 50z"/><path id="path1_fill" class="st1" d="M0 150c0-27.6 22.4-50 50-50h50v100H50c-27.6 0-50-22.4-50-50z"/><path id="path1_fill_1_" class="st2" d="M0 50C0 22.4 22.4 0 50 0h50v100H50C22.4 100 0 77.6 0 50z"/><path id="path2_fill" class="st3" d="M100 0h50c27.6 0 50 22.4 50 50s-22.4 50-50 50h-50V0z"/><path id="path3_fill" class="st4" d="M200 150c0 27.6-22.4 50-50 50s-50-22.4-50-50 22.4-50 50-50 50 22.4 50 50z"/></svg>

After

Width:  |  Height:  |  Size: 802 B

View File

@@ -887,6 +887,43 @@ export const contactFields: INodeProperties[] = [
default: '',
description: 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.',
},
{
displayName: 'Use Query',
name: 'useQuery',
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'contact',
],
},
},
default: false,
description: `Whether or not to use a query to filter the results`,
},
{
displayName: 'Query',
name: 'query',
type: 'string',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'contact',
],
useQuery: [
true,
],
},
},
default: '',
description: `The plain-text query for the request. The query is used to match prefix phrases of the fields on a person. For example, a person with name "foo name" matches queries such as "f", "fo", "foo", "foo n", "nam", etc., but not "oo n".`,
},
{
displayName: 'RAW Data',
name: 'rawData',
@@ -918,6 +955,9 @@ export const contactFields: INodeProperties[] = [
resource: [
'contact',
],
useQuery: [
false,
],
},
},
options: [

View File

@@ -24,6 +24,7 @@ import {
} from './ContactDescription';
import * as moment from 'moment';
import { IData } from '../Analytics/Interfaces';
export class GoogleContacts implements INodeType {
description: INodeTypeDescription = {
@@ -264,11 +265,19 @@ export class GoogleContacts implements INodeType {
responseData.contactId = responseData.resourceName.split('/')[1];
}
//https://developers.google.com/people/api/rest/v1/people.connections/list
//https://developers.google.com/people/api/rest/v1/people/searchContacts
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const fields = this.getNodeParameter('fields', i) as string[];
const options = this.getNodeParameter('options', i) as IDataObject;
const options = this.getNodeParameter('options', i, {}) as IDataObject;
const rawData = this.getNodeParameter('rawData', i) as boolean;
const useQuery = this.getNodeParameter('useQuery', i) as boolean;
const endpoint = (useQuery) ? ':searchContacts' : '/me/connections';
if (useQuery) {
qs.query = this.getNodeParameter('query', i) as string;
}
if (options.sortOrder) {
qs.sortOrder = options.sortOrder as number;
@@ -280,25 +289,36 @@ export class GoogleContacts implements INodeType {
qs.personFields = (fields as string[]).join(',');
}
if (useQuery) {
qs.readMask = qs.personFields;
delete qs.personFields;
}
if (returnAll) {
responseData = await googleApiRequestAllItems.call(
this,
'connections',
(useQuery) ? 'results' : 'connections',
'GET',
`/people/me/connections`,
`/people${endpoint}`,
{},
qs,
);
if (useQuery) {
responseData = responseData.map((result: IDataObject) => result.person);
}
} else {
qs.pageSize = this.getNodeParameter('limit', i) as number;
responseData = await googleApiRequest.call(
this,
'GET',
`/people/me/connections`,
`/people${endpoint}`,
{},
qs,
);
responseData = responseData.connections;
responseData = responseData.connections || responseData.results?.map((result: IDataObject) => result.person) || [];
}
if (!rawData) {

View File

@@ -33,7 +33,10 @@ export const cameraProxyFields: INodeProperties[] = [
{
displayName: 'Camera Entity ID',
name: 'cameraEntityId',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCameraEntities',
},
default: '',
required: true,
displayOptions: {

View File

@@ -4,15 +4,17 @@ import {
import {
IExecuteFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject,
INodePropertyOptions,
NodeApiError,
NodeOperationError,
} from 'n8n-workflow';
export async function homeAssistantApiRequest(this: IExecuteFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) {
export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) {
const credentials = await this.getCredentials('homeAssistantApi');
if (credentials === undefined) {
@@ -35,8 +37,51 @@ export async function homeAssistantApiRequest(this: IExecuteFunctions, method: s
delete options.body;
}
try {
return await this.helpers.request(options);
if (this.helpers.request) {
return await this.helpers.request(options);
}
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
export async function getHomeAssistantEntities(this: IExecuteFunctions | ILoadOptionsFunctions, domain = '') {
const returnData: INodePropertyOptions[] = [];
const entities = await homeAssistantApiRequest.call(this, 'GET', '/states');
for (const entity of entities) {
const entityId = entity.entity_id as string;
if (domain === '' || domain && entityId.startsWith(domain)) {
const entityName = entity.attributes.friendly_name as string || entityId;
returnData.push({
name: entityName,
value: entityId,
});
}
}
return returnData;
}
export async function getHomeAssistantServices(this: IExecuteFunctions | ILoadOptionsFunctions, domain = '') {
const returnData: INodePropertyOptions[] = [];
const services = await homeAssistantApiRequest.call(this, 'GET', '/services');
if (domain === '') {
// If no domain specified return domains
const domains = services.map(({ domain }: IDataObject) => domain as string).sort();
returnData.push(...domains.map((service: string) => ({ name: service, value: service })));
return returnData;
} else {
// If we have a domain, return all relevant services
const domainServices = services.filter((service: IDataObject) => service.domain === domain);
for (const domainService of domainServices) {
for (const [serviceID, value] of Object.entries(domainService.services)) {
const serviceProperties = value as IDataObject;
const serviceName = serviceProperties.description || serviceID;
returnData.push({
name: serviceName as string,
value: serviceID,
});
}
}
}
return returnData;
}

View File

@@ -6,7 +6,9 @@ import {
ICredentialsDecrypted,
ICredentialTestFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
NodeCredentialTestResult,
@@ -52,6 +54,8 @@ import {
} from './CameraProxyDescription';
import {
getHomeAssistantEntities,
getHomeAssistantServices,
homeAssistantApiRequest,
} from './GenericFunctions';
@@ -169,9 +173,29 @@ export class HomeAssistant implements INodeType {
status: 'OK',
message: 'Authentication successful!',
};
},
},
loadOptions: {
async getAllEntities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await getHomeAssistantEntities.call(this);
},
async getCameraEntities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await getHomeAssistantEntities.call(this, 'camera');
},
async getDomains(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
return await getHomeAssistantServices.call(this);
},
async getDomainServices(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const currentDomain = this.getCurrentNodeParameter('domain') as string;
if (currentDomain) {
return await getHomeAssistantServices.call(this, currentDomain);
} else {
return [];
}
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {

View File

@@ -83,7 +83,10 @@ export const serviceFields: INodeProperties[] = [
{
displayName: 'Domain',
name: 'domain',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getDomains',
},
default: '',
required: true,
displayOptions: {
@@ -100,7 +103,13 @@ export const serviceFields: INodeProperties[] = [
{
displayName: 'Service',
name: 'service',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsDependsOn: [
'domain',
],
loadOptionsMethod: 'getDomainServices',
},
default: '',
required: true,
displayOptions: {

View File

@@ -43,7 +43,10 @@ export const stateFields: INodeProperties[] = [
{
displayName: 'Entity ID',
name: 'entityId',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getAllEntities',
},
displayOptions: {
show: {
operation: [
@@ -110,7 +113,10 @@ export const stateFields: INodeProperties[] = [
{
displayName: 'Entity ID',
name: 'entityId',
type: 'string',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getAllEntities',
},
displayOptions: {
show: {
operation: [

View File

@@ -39,12 +39,16 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
return await this.helpers.request!(options);
} else if (authenticationMethod === 'developerApi') {
const credentials = await this.getCredentials('hubspotDeveloperApi');
if (endpoint.includes('webhooks')) {
options.qs.hapikey = credentials!.apiKey as string;
return await this.helpers.request!(options);
const credentials = await this.getCredentials('hubspotDeveloperApi');
options.qs.hapikey = credentials!.apiKey as string;
return await this.helpers.request!(options);
} else {
return await this.helpers.requestOAuth2!.call(this, 'hubspotDeveloperApi', options, { tokenType: 'Bearer', includeCredentialsOnRefreshOnBody: true });
}
} else {
// @ts-ignore
return await this.helpers.requestOAuth2!.call(this, 'hubspotOAuth2Api', options, { tokenType: 'Bearer', includeCredentialsOnRefreshOnBody: true });
}
} catch (error) {

View File

@@ -143,6 +143,9 @@ export class HubspotTrigger implements INodeType {
name: 'property',
type: 'options',
typeOptions: {
loadOptionsDependsOn: [
'contact.propertyChange',
],
loadOptionsMethod: 'getContactProperties',
},
displayOptions: {
@@ -160,6 +163,9 @@ export class HubspotTrigger implements INodeType {
name: 'property',
type: 'options',
typeOptions: {
loadOptionsDependsOn: [
'company.propertyChange',
],
loadOptionsMethod: 'getCompanyProperties',
},
displayOptions: {
@@ -177,6 +183,9 @@ export class HubspotTrigger implements INodeType {
name: 'property',
type: 'options',
typeOptions: {
loadOptionsDependsOn: [
'deal.propertyChange',
],
loadOptionsMethod: 'getDealProperties',
},
displayOptions: {
@@ -220,51 +229,48 @@ export class HubspotTrigger implements INodeType {
// select them easily
async getContactProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
for (const field of contactFields) {
const endpoint = '/properties/v2/contacts/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
for (const property of properties) {
const propertyName = property.label;
const propertyId = property.name;
returnData.push({
name: capitalCase(field.label),
value: field.id,
name: propertyName,
value: propertyId,
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
// Get all the available companies to display them to user so that he can
// select them easily
async getCompanyProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
for (const field of companyFields) {
const endpoint = '/properties/v2/companies/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
for (const property of properties) {
const propertyName = property.label;
const propertyId = property.name;
returnData.push({
name: capitalCase(field.label),
value: field.id,
name: propertyName,
value: propertyId,
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
// Get all the available deals to display them to user so that he can
// select them easily
async getDealProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
for (const field of dealFields) {
const endpoint = '/properties/v2/deals/properties';
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
for (const property of properties) {
const propertyName = property.label;
const propertyId = property.name;
returnData.push({
name: capitalCase(field.label),
value: field.id,
name: propertyName,
value: propertyId,
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
},

View File

@@ -506,9 +506,15 @@ export class Jira implements INodeType {
}
}
if (additionalFields.reporter) {
fields.reporter = {
id: additionalFields.reporter as string,
};
if (jiraVersion === 'server') {
fields.reporter = {
name: additionalFields.reporter as string,
};
} else {
fields.reporter = {
id: additionalFields.reporter as string,
};
}
}
if (additionalFields.description) {
fields.description = additionalFields.description as string;
@@ -586,9 +592,15 @@ export class Jira implements INodeType {
}
}
if (updateFields.reporter) {
fields.reporter = {
id: updateFields.reporter as string,
};
if (jiraVersion === 'server') {
fields.reporter = {
name: updateFields.reporter as string,
};
} else {
fields.reporter = {
id: updateFields.reporter as string,
};
}
}
if (updateFields.description) {
fields.description = updateFields.description as string;

View File

@@ -43,6 +43,10 @@ export class OneSimpleApi implements INodeType {
name: 'Information',
value: 'information',
},
{
name: 'Social Profile',
value: 'socialProfile',
},
{
name: 'Utility',
value: 'utility',
@@ -55,7 +59,7 @@ export class OneSimpleApi implements INodeType {
default: 'website',
required: true,
},
// Generation
// website
{
displayName: 'Operation',
name: 'operation',
@@ -86,6 +90,32 @@ export class OneSimpleApi implements INodeType {
],
default: 'pdf',
},
// socialProfile
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'socialProfile',
],
},
},
options: [
{
name: 'Instagram',
value: 'instagramProfile',
description: 'Get details about an Instagram profile',
},
{
name: 'Spotify',
value: 'spotifyArtistProfile',
description: 'Get details about a Spotify Artist',
},
],
default: 'instagramProfile',
},
// Information
{
displayName: 'Operation',
@@ -113,7 +143,7 @@ export class OneSimpleApi implements INodeType {
default: 'exchangeRate',
description: 'The operation to perform.',
},
// Utiliy
// Utility
{
displayName: 'Operation',
name: 'operation',
@@ -279,7 +309,7 @@ export class OneSimpleApi implements INodeType {
type: 'boolean',
default: false,
description: `Normally the API will reuse a previously taken screenshot of the URL to give a faster response.
This option allows you to retake the screenshot at that exact time, for those times when it's necessary`,
This option allows you to retake the screenshot at that exact time, for those times when it's necessary`,
},
],
},
@@ -508,7 +538,7 @@ export class OneSimpleApi implements INodeType {
type: 'boolean',
default: false,
description: `Normally the API will reuse a previously taken screenshot of the URL to give a faster response.
This option allows you to retake the screenshot at that exact time, for those times when it's necessary`,
This option allows you to retake the screenshot at that exact time, for those times when it's necessary`,
},
{
displayName: 'Full Page',
@@ -519,6 +549,44 @@ export class OneSimpleApi implements INodeType {
},
],
},
// socialProfile: instagramProfile
{
displayName: 'Profile Name',
name: 'profileName',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'instagramProfile',
],
resource: [
'socialProfile',
],
},
},
default: '',
description: 'Profile name to get details of',
},
// socialProfile: spotifyArtistProfile
{
displayName: 'Artist Name',
name: 'artistName',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'spotifyArtistProfile',
],
resource: [
'socialProfile',
],
},
},
default: '',
description: 'Artist name to get details for',
},
// information: exchangeRate
{
displayName: 'Value',
@@ -778,6 +846,20 @@ export class OneSimpleApi implements INodeType {
}
}
if (resource === 'socialProfile') {
if (operation === 'instagramProfile') {
const profileName = this.getNodeParameter('profileName', i) as string;
qs.profile = profileName;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/instagram_profile', {}, qs);
}
if (operation === 'spotifyArtistProfile') {
const artistName = this.getNodeParameter('artistName', i) as string;
qs.profile = artistName;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/spotify_profile', {}, qs);
}
}
if (resource === 'information') {
if (operation === 'exchangeRate') {
const value = this.getNodeParameter('value', i) as string;
@@ -865,3 +947,4 @@ export class OneSimpleApi implements INodeType {
return [this.helpers.returnJsonArray(returnData)];
}
}

View File

@@ -1744,8 +1744,8 @@ export class Salesforce implements INodeType {
if (additionalFields.type !== undefined) {
body.Type = additionalFields.type as string;
}
if (additionalFields.ammount !== undefined) {
body.Amount = additionalFields.ammount as number;
if (additionalFields.amount !== undefined) {
body.Amount = additionalFields.amount as number;
}
if (additionalFields.owner !== undefined) {
body.OwnerId = additionalFields.owner as string;
@@ -1813,8 +1813,8 @@ export class Salesforce implements INodeType {
if (updateFields.type !== undefined) {
body.Type = updateFields.type as string;
}
if (updateFields.ammount !== undefined) {
body.Amount = updateFields.ammount as number;
if (updateFields.amount !== undefined) {
body.Amount = updateFields.amount as number;
}
if (updateFields.owner !== undefined) {
body.OwnerId = updateFields.owner as string;

View File

@@ -0,0 +1,37 @@
import {
OptionsWithUri,
} from 'request';
import {
IExecuteFunctions,
IExecuteSingleFunctions,
IHookFunctions,
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject,
NodeApiError,
} from 'n8n-workflow';
export async function workableApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('workableApi') as { accessToken: string, subdomain: string };
let options: OptionsWithUri = {
headers: { 'Authorization': `Bearer ${credentials.accessToken}` },
method,
qs,
body,
uri: uri || `https://${credentials.subdomain}.workable.com/spi/v3${resource}`,
json: true,
};
options = Object.assign({}, options, option);
if (Object.keys(options.body).length === 0) {
delete options.body;
}
try {
return await this.helpers.request!(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}

View File

@@ -0,0 +1,201 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import {
IDataObject,
ILoadOptionsFunctions,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from 'n8n-workflow';
import {
workableApiRequest,
} from './GenericFunctions';
import {
snakeCase,
} from 'change-case';
export class WorkableTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'Workable Trigger',
name: 'workableTrigger',
icon: 'file:workable.png',
group: ['trigger'],
version: 1,
subtitle: '={{$parameter["triggerOn"]}}',
description: 'Starts the workflow when Workable events occur',
defaults: {
name: 'Workable Trigger',
color: '#29b6f6',
},
inputs: [],
outputs: ['main'],
credentials: [
{
name: 'workableApi',
required: true,
},
],
webhooks: [
{
name: 'default',
httpMethod: 'POST',
responseMode: 'onReceived',
path: 'webhook',
},
],
properties: [
{
displayName: 'Trigger On',
name: 'triggerOn',
type: 'options',
options: [
{
name: 'Candidate Created',
value: 'candidateCreated',
},
{
name: 'Candidate Moved',
value: 'candidateMoved',
},
],
default: '',
required: true,
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
options: [
{
displayName: 'Job',
name: 'job',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getJobs',
},
default: '',
description: `Get notifications only for one job`,
},
{
displayName: 'Stage',
name: 'stage',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getStages',
},
default: '',
description: `Get notifications for specific stages. e.g. 'hired'`,
},
],
},
],
};
methods = {
loadOptions: {
async getJobs(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { jobs } = await workableApiRequest.call(this, 'GET', '/jobs');
for (const job of jobs) {
returnData.push({
name: job.full_title,
value: job.shortcode,
});
}
return returnData;
},
async getStages(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const { stages } = await workableApiRequest.call(this, 'GET', '/stages');
for (const stage of stages) {
returnData.push({
name: stage.name,
value: stage.slug,
});
}
return returnData;
},
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const webhookData = this.getWorkflowStaticData('node');
// Check all the webhooks which exist already if it is identical to the
// one that is supposed to get created.
const { subscriptions } = await workableApiRequest.call(this, 'GET', `/subscriptions`);
for (const subscription of subscriptions) {
if (subscription.target === webhookUrl) {
webhookData.webhookId = subscription.id as string;
return true;
}
}
return false;
},
async create(this: IHookFunctions): Promise<boolean> {
const credentials = await this.getCredentials('workableApi') as { accessToken: string, subdomain: string };
const webhookData = this.getWorkflowStaticData('node');
const webhookUrl = this.getNodeWebhookUrl('default');
const triggerOn = this.getNodeParameter('triggerOn') as string;
const { stage, job } = this.getNodeParameter('filters') as IDataObject;
const endpoint = '/subscriptions';
const body: IDataObject = {
event: snakeCase(triggerOn).toLowerCase(),
args: {
account_id: credentials.subdomain,
...(job) && { job_shortcode: job },
...(stage) && { stage_slug: stage },
},
target: webhookUrl,
};
const responseData = await workableApiRequest.call(this, 'POST', endpoint, body);
if (responseData.id === undefined) {
// Required data is missing so was not successful
return false;
}
webhookData.webhookId = responseData.id as string;
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId !== undefined) {
const endpoint = `/subscriptions/${webhookData.webhookId}`;
try {
await workableApiRequest.call(this, 'DELETE', endpoint);
} catch (error) {
return false;
}
// Remove from the static workflow data so that it is clear
// that no webhooks are registred anymore
delete webhookData.webhookId;
}
return true;
},
},
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const bodyData = this.getBodyData();
return {
workflowData: [
this.helpers.returnJsonArray(bodyData),
],
};
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@@ -1,6 +1,6 @@
{
"name": "n8n-nodes-base",
"version": "0.149.0",
"version": "0.150.0",
"description": "Base nodes of n8n",
"license": "SEE LICENSE IN LICENSE.md",
"homepage": "https://n8n.io",
@@ -89,6 +89,7 @@
"dist/credentials/EventbriteOAuth2Api.credentials.js",
"dist/credentials/FacebookGraphApi.credentials.js",
"dist/credentials/FacebookGraphAppApi.credentials.js",
"dist/credentials/FigmaApi.credentials.js",
"dist/credentials/FileMaker.credentials.js",
"dist/credentials/FlowApi.credentials.js",
"dist/credentials/FormIoApi.credentials.js",
@@ -301,6 +302,7 @@
"dist/credentials/WiseApi.credentials.js",
"dist/credentials/WooCommerceApi.credentials.js",
"dist/credentials/WordpressApi.credentials.js",
"dist/credentials/WorkableApi.credentials.js",
"dist/credentials/WufooApi.credentials.js",
"dist/credentials/XeroOAuth2Api.credentials.js",
"dist/credentials/YourlsApi.credentials.js",
@@ -402,6 +404,7 @@
"dist/nodes/ExecuteWorkflow/ExecuteWorkflow.node.js",
"dist/nodes/Facebook/FacebookGraphApi.node.js",
"dist/nodes/Facebook/FacebookTrigger.node.js",
"dist/nodes/Figma/FigmaTrigger.node.js",
"dist/nodes/FileMaker/FileMaker.node.js",
"dist/nodes/Flow/Flow.node.js",
"dist/nodes/Flow/FlowTrigger.node.js",
@@ -637,6 +640,7 @@
"dist/nodes/WooCommerce/WooCommerce.node.js",
"dist/nodes/WooCommerce/WooCommerceTrigger.node.js",
"dist/nodes/Wordpress/Wordpress.node.js",
"dist/nodes/Workable/WorkableTrigger.node.js",
"dist/nodes/WorkflowTrigger/WorkflowTrigger.node.js",
"dist/nodes/WriteBinaryFile/WriteBinaryFile.node.js",
"dist/nodes/Wufoo/WufooTrigger.node.js",