pull:初次提交
This commit is contained in:
18
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/Autopilot.node.json
Executable file
18
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/Autopilot.node.json
Executable file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.autopilot",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Marketing"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/autopilot/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.autopilot/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
320
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts
Executable file
320
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts
Executable file
@@ -0,0 +1,320 @@
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type IDataObject,
|
||||
type ILoadOptionsFunctions,
|
||||
type INodeExecutionData,
|
||||
type INodePropertyOptions,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
type IHttpRequestMethods,
|
||||
NodeConnectionTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { contactFields, contactOperations } from './ContactDescription';
|
||||
import { contactJourneyFields, contactJourneyOperations } from './ContactJourneyDescription';
|
||||
import { contactListFields, contactListOperations } from './ContactListDescription';
|
||||
import { autopilotApiRequest, autopilotApiRequestAllItems } from './GenericFunctions';
|
||||
import { listFields, listOperations } from './ListDescription';
|
||||
|
||||
export class Autopilot implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Autopilot',
|
||||
name: 'autopilot',
|
||||
icon: 'file:autopilot.svg',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Autopilot API',
|
||||
defaults: {
|
||||
name: 'Autopilot',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'autopilotApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Contact',
|
||||
value: 'contact',
|
||||
},
|
||||
{
|
||||
name: 'Contact Journey',
|
||||
value: 'contactJourney',
|
||||
},
|
||||
{
|
||||
name: 'Contact List',
|
||||
value: 'contactList',
|
||||
},
|
||||
{
|
||||
name: 'List',
|
||||
value: 'list',
|
||||
},
|
||||
],
|
||||
default: 'contact',
|
||||
},
|
||||
|
||||
...contactOperations,
|
||||
...contactFields,
|
||||
...contactJourneyOperations,
|
||||
...contactJourneyFields,
|
||||
...contactListOperations,
|
||||
...contactListFields,
|
||||
...listOperations,
|
||||
...listFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async getCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const customFields = await autopilotApiRequest.call(this, 'GET', '/contacts/custom_fields');
|
||||
for (const customField of customFields) {
|
||||
returnData.push({
|
||||
name: customField.name,
|
||||
value: `${customField.name}-${customField.fieldType}`,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
async getLists(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { lists } = await autopilotApiRequest.call(this, 'GET', '/lists');
|
||||
for (const list of lists) {
|
||||
returnData.push({
|
||||
name: list.title,
|
||||
value: list.list_id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
async getTriggers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { triggers } = await autopilotApiRequest.call(this, 'GET', '/triggers');
|
||||
for (const trigger of triggers) {
|
||||
returnData.push({
|
||||
name: trigger.journey,
|
||||
value: trigger.trigger_id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
const length = items.length;
|
||||
const qs: IDataObject = {};
|
||||
let responseData;
|
||||
const resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
if (resource === 'contact') {
|
||||
if (operation === 'upsert') {
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
Email: email,
|
||||
};
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.customFieldsUi) {
|
||||
const customFieldsValues = (body.customFieldsUi as IDataObject)
|
||||
.customFieldsValues as IDataObject[];
|
||||
|
||||
body.custom = {};
|
||||
|
||||
for (const customField of customFieldsValues) {
|
||||
const [name, fieldType] = (customField.key as string).split('-');
|
||||
|
||||
const fieldName = name.replace(/\s/g, '--');
|
||||
|
||||
//@ts-ignore
|
||||
body.custom[`${fieldType}--${fieldName}`] = customField.value;
|
||||
}
|
||||
delete body.customFieldsUi;
|
||||
}
|
||||
|
||||
if (body.autopilotList) {
|
||||
body._autopilot_list = body.autopilotList;
|
||||
delete body.autopilotList;
|
||||
}
|
||||
|
||||
if (body.autopilotSessionId) {
|
||||
body._autopilot_session_id = body.autopilotSessionId;
|
||||
delete body.autopilotSessionId;
|
||||
}
|
||||
|
||||
if (body.newEmail) {
|
||||
body._NewEmail = body.newEmail;
|
||||
delete body.newEmail;
|
||||
}
|
||||
|
||||
responseData = await autopilotApiRequest.call(this, 'POST', '/contact', {
|
||||
contact: body,
|
||||
});
|
||||
}
|
||||
|
||||
if (operation === 'delete') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
|
||||
responseData = await autopilotApiRequest.call(this, 'DELETE', `/contact/${contactId}`);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
|
||||
if (operation === 'get') {
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
|
||||
responseData = await autopilotApiRequest.call(this, 'GET', `/contact/${contactId}`);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (!returnAll) {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
}
|
||||
responseData = await autopilotApiRequestAllItems.call(
|
||||
this,
|
||||
'contacts',
|
||||
'GET',
|
||||
'/contacts',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
if (!returnAll) {
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'contactJourney') {
|
||||
if (operation === 'add') {
|
||||
const triggerId = this.getNodeParameter('triggerId', i) as string;
|
||||
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
|
||||
responseData = await autopilotApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/trigger/${triggerId}/contact/${contactId}`,
|
||||
);
|
||||
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
if (resource === 'contactList') {
|
||||
if (['add', 'remove', 'exist'].includes(operation)) {
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
|
||||
const contactId = this.getNodeParameter('contactId', i) as string;
|
||||
|
||||
const method: { [key: string]: IHttpRequestMethods } = {
|
||||
add: 'POST',
|
||||
remove: 'DELETE',
|
||||
exist: 'GET',
|
||||
};
|
||||
|
||||
const endpoint = `/list/${listId}/contact/${contactId}`;
|
||||
|
||||
if (operation === 'exist') {
|
||||
try {
|
||||
await autopilotApiRequest.call(this, method[operation], endpoint);
|
||||
responseData = { exist: true };
|
||||
} catch (error) {
|
||||
responseData = { exist: false };
|
||||
}
|
||||
} else if (operation === 'add' || operation === 'remove') {
|
||||
responseData = await autopilotApiRequest.call(this, method[operation], endpoint);
|
||||
responseData.success = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
|
||||
if (!returnAll) {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
}
|
||||
responseData = await autopilotApiRequestAllItems.call(
|
||||
this,
|
||||
'contacts',
|
||||
'GET',
|
||||
`/list/${listId}/contacts`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
if (!returnAll) {
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'list') {
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
|
||||
responseData = await autopilotApiRequest.call(this, 'POST', '/list', body);
|
||||
}
|
||||
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (!returnAll) {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
}
|
||||
responseData = await autopilotApiRequest.call(this, 'GET', '/lists');
|
||||
|
||||
responseData = responseData.lists;
|
||||
|
||||
if (!returnAll) {
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
const exectionErrorWithMetaData = this.helpers.constructExecutionMetaData(
|
||||
[{ json: { error: error.message } }],
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
responseData.push(...exectionErrorWithMetaData);
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return [returnData as INodeExecutionData[]];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.autopilotTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Marketing"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/autopilot/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.autopilottrigger/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
129
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts
Executable file
129
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts
Executable file
@@ -0,0 +1,129 @@
|
||||
import { snakeCase } from 'change-case';
|
||||
import type {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
IDataObject,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { autopilotApiRequest } from './GenericFunctions';
|
||||
|
||||
export class AutopilotTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Autopilot Trigger',
|
||||
name: 'autopilotTrigger',
|
||||
icon: 'file:autopilot.svg',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["event"]}}',
|
||||
description: 'Handle Autopilot events via webhooks',
|
||||
defaults: {
|
||||
name: 'Autopilot Trigger',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'autopilotApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Event',
|
||||
name: 'event',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: '',
|
||||
options: [
|
||||
{
|
||||
name: 'Contact Added',
|
||||
value: 'contactAdded',
|
||||
},
|
||||
{
|
||||
name: 'Contact Added To List',
|
||||
value: 'contactAddedToList',
|
||||
},
|
||||
{
|
||||
name: 'Contact Entered Segment',
|
||||
value: 'contactEnteredSegment',
|
||||
},
|
||||
{
|
||||
name: 'Contact Left Segment',
|
||||
value: 'contactLeftSegment',
|
||||
},
|
||||
{
|
||||
name: 'Contact Removed From List',
|
||||
value: 'contactRemovedFromList',
|
||||
},
|
||||
{
|
||||
name: 'Contact Unsubscribed',
|
||||
value: 'contactUnsubscribed',
|
||||
},
|
||||
{
|
||||
name: 'Contact Updated',
|
||||
value: 'contactUpdated',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const { hooks: webhooks } = await autopilotApiRequest.call(this, 'GET', '/hooks');
|
||||
for (const webhook of webhooks) {
|
||||
if (webhook.target_url === webhookUrl && webhook.event === snakeCase(event)) {
|
||||
webhookData.webhookId = webhook.hook_id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const body: IDataObject = {
|
||||
event: snakeCase(event),
|
||||
target_url: webhookUrl,
|
||||
};
|
||||
const webhook = await autopilotApiRequest.call(this, 'POST', '/hook', body);
|
||||
webhookData.webhookId = webhook.hook_id;
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
try {
|
||||
await autopilotApiRequest.call(this, 'DELETE', `/hook/${webhookData.webhookId}`);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
return {
|
||||
workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])],
|
||||
};
|
||||
}
|
||||
}
|
||||
349
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/ContactDescription.ts
Executable file
349
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/ContactDescription.ts
Executable file
@@ -0,0 +1,349 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const contactOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create or Update',
|
||||
value: 'upsert',
|
||||
description:
|
||||
'Create a new contact, or update the current one if it already exists (upsert)',
|
||||
action: 'Create or Update a contact',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete a contact',
|
||||
action: 'Delete a contact',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a contact',
|
||||
action: 'Get a contact',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many contacts',
|
||||
action: 'Get many contacts',
|
||||
},
|
||||
],
|
||||
default: 'upsert',
|
||||
},
|
||||
];
|
||||
|
||||
export const contactFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:upsert */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
required: true,
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['upsert'],
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Email address of the contact',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['upsert'],
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
placeholder: 'Add Field',
|
||||
options: [
|
||||
{
|
||||
displayName: 'Company',
|
||||
name: 'Company',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Fields',
|
||||
name: 'customFieldsUi',
|
||||
type: 'fixedCollection',
|
||||
default: {},
|
||||
placeholder: 'Add Custom Field',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
loadOptionsMethod: 'getCustomFields',
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'customFieldsValues',
|
||||
displayName: 'Custom Field',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Key Name or ID',
|
||||
name: 'key',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCustomFields',
|
||||
},
|
||||
description:
|
||||
'User-specified key of user-defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
description: 'User-specified value of user-defined data',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Fax',
|
||||
name: 'Fax',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'FirstName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Industry',
|
||||
name: 'Industry',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'LastName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Lead Source',
|
||||
name: 'LeadSource',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'LinkedIn URL',
|
||||
name: 'LinkedIn',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'List Name or ID',
|
||||
name: 'autopilotList',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getLists',
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'List to which this contact will be added on creation. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Mailing Country',
|
||||
name: 'MailingCountry',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Mailing Postal Code',
|
||||
name: 'MailingPostalCode',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Mailing State',
|
||||
name: 'MailingState',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Mailing Street',
|
||||
name: 'MailingStreet',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Mailing City',
|
||||
name: 'MailingCity',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Mobile Phone',
|
||||
name: 'MobilePhone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'New Email',
|
||||
name: 'newEmail',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description:
|
||||
'If provided, will change the email address of the contact identified by the Email field',
|
||||
},
|
||||
{
|
||||
displayName: 'Notify',
|
||||
name: 'notify',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description:
|
||||
'By default Autopilot notifies registered REST hook endpoints for contact_added/contact_updated events when a new contact is added or an existing contact is updated via API. Disable to skip notifications.',
|
||||
},
|
||||
{
|
||||
displayName: 'Number of Employees',
|
||||
name: 'NumberOfEmployees',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
},
|
||||
{
|
||||
displayName: 'Owner Name',
|
||||
name: 'owner_name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
name: 'Phone',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Salutation',
|
||||
name: 'Salutation',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Session ID',
|
||||
name: 'autopilotSessionId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Used to associate a contact with a session',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'Status',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'Title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Subscribe',
|
||||
name: 'unsubscribed',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to subscribe or un-subscribe a contact',
|
||||
},
|
||||
{
|
||||
displayName: 'Website URL',
|
||||
name: 'Website',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['delete'],
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Can be ID or email',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['get'],
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Can be ID or email',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contact:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['contact'],
|
||||
},
|
||||
},
|
||||
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: ['contact'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,62 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const contactJourneyOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contactJourney'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add',
|
||||
value: 'add',
|
||||
description: 'Add contact to list',
|
||||
action: 'Add a contact journey',
|
||||
},
|
||||
],
|
||||
default: 'add',
|
||||
},
|
||||
];
|
||||
|
||||
export const contactJourneyFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contactJourney:add */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Trigger Name or ID',
|
||||
name: 'triggerId',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTriggers',
|
||||
},
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['add'],
|
||||
resource: ['contactJourney'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'List ID. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['add'],
|
||||
resource: ['contactJourney'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Can be ID or email',
|
||||
},
|
||||
];
|
||||
115
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/ContactListDescription.ts
Executable file
115
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/ContactListDescription.ts
Executable file
@@ -0,0 +1,115 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const contactListOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['contactList'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add',
|
||||
value: 'add',
|
||||
description: 'Add contact to list',
|
||||
action: 'Add a contact to a list',
|
||||
},
|
||||
{
|
||||
name: 'Exist',
|
||||
value: 'exist',
|
||||
description: 'Check if contact is on list',
|
||||
action: 'Check if a contact list exists',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many contacts from a list',
|
||||
action: 'Get many contact lists',
|
||||
},
|
||||
{
|
||||
name: 'Remove',
|
||||
value: 'remove',
|
||||
description: 'Remove a contact from a list',
|
||||
action: 'Remove a contact from a list',
|
||||
},
|
||||
],
|
||||
default: 'add',
|
||||
},
|
||||
];
|
||||
|
||||
export const contactListFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contactList:add */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'List Name or ID',
|
||||
name: 'listId',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getLists',
|
||||
},
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['add', 'remove', 'exist', 'getAll'],
|
||||
resource: ['contactList'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'ID of the list to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Contact ID',
|
||||
name: 'contactId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['add', 'remove', 'exist'],
|
||||
resource: ['contactList'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Can be ID or email',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* contactList:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['contactList'],
|
||||
},
|
||||
},
|
||||
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: ['contactList'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
76
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts
Executable file
76
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts
Executable file
@@ -0,0 +1,76 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
JsonObject,
|
||||
IRequestOptions,
|
||||
IHttpRequestMethods,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function autopilotApiRequest(
|
||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
uri?: string,
|
||||
_option: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials<{ apiKey: string }>('autopilotApi');
|
||||
|
||||
const endpoint = 'https://api2.autopilothq.com/v1';
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
autopilotapikey: credentials.apiKey,
|
||||
},
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
uri: uri || `${endpoint}${resource}`,
|
||||
json: true,
|
||||
};
|
||||
if (!Object.keys(body as IDataObject).length) {
|
||||
delete options.body;
|
||||
}
|
||||
if (!Object.keys(query).length) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.helpers.request(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export async function autopilotApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean;
|
||||
|
||||
const base = endpoint;
|
||||
|
||||
let responseData;
|
||||
do {
|
||||
responseData = await autopilotApiRequest.call(this, method, endpoint, body, query);
|
||||
endpoint = `${base}/${responseData.bookmark}`;
|
||||
returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]);
|
||||
const limit = query.limit as number | undefined;
|
||||
if (limit && returnData.length >= limit && !returnAll) {
|
||||
return returnData;
|
||||
}
|
||||
} while (responseData.bookmark !== undefined);
|
||||
return returnData;
|
||||
}
|
||||
85
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/ListDescription.ts
Executable file
85
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/ListDescription.ts
Executable file
@@ -0,0 +1,85 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const listOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a list',
|
||||
action: 'Create a list',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many lists',
|
||||
action: 'Get many lists',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const listFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* list:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
required: true,
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Name of the list to create',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* list:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['getAll'],
|
||||
resource: ['list'],
|
||||
},
|
||||
},
|
||||
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: ['list'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 500,
|
||||
},
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
];
|
||||
1
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/autopilot.svg
Executable file
1
n8n-n8n-1.109.2/packages/nodes-base/nodes/Autopilot/autopilot.svg
Executable file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="38 26 35 35"><circle cx="50" cy="50" r="40" fill="#18d4b2" stroke="#18d4b2" stroke-width="3"/><path fill="#fff" d="M45.4 42.6h19.9l3.4-4.8H42zm3.1 8.3h13.1l3.4-4.8H45.4zm54-.7"/></svg>
|
||||
|
After Width: | Height: | Size: 233 B |
Reference in New Issue
Block a user