@tuanltntu/n8n-nodes-bitrix24
Version:
Comprehensive n8n community node for Bitrix24 API integration with CRM, Tasks, Chat, Telephony, and more
666 lines • 22.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.automationFields = exports.automationOptionsFields = exports.automationListFields = exports.automationTriggerFields = exports.automationEntityFields = exports.automationOperations = exports.automationOperationFields = void 0;
const ModuleManager_1 = require("../ModuleManager");
// Automation operations
const operationField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Operation",
name: "operation",
type: "options",
noDataExpression: true,
options: [
{
name: "Execute Trigger",
value: "executeTrigger",
description: "Execute automation trigger",
action: "Execute automation trigger",
},
{
name: "Get Automation Rules",
value: "getAutomationRules",
description: "Get automation rules",
action: "Get automation rules",
},
{
name: "Get Trigger",
value: "getTrigger",
description: "Get trigger information",
action: "Get trigger information",
},
{
name: "Get Triggers",
value: "getTriggers",
description: "Get list of triggers",
action: "Get list of triggers",
},
],
default: "getTriggers",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION);
// Entity Type field
const entityTypeField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Entity Type",
name: "entityType",
type: "options",
required: true,
options: [
{ name: "Deal", value: "DEAL" },
{ name: "Lead", value: "LEAD" },
{ name: "Contact", value: "CONTACT" },
{ name: "Company", value: "COMPANY" },
],
default: "DEAL",
description: "Type of entity for automation",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {
operation: ["executeTrigger", "getAutomationRules", "getTriggers"],
});
// Trigger Code field
const triggerCodeField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Trigger Code",
name: "triggerCode",
type: "string",
required: true,
default: "",
description: "Code of the trigger",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {
operation: ["executeTrigger", "getTrigger"],
});
// Entity ID field
const entityIdField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Entity ID",
name: "entityId",
type: "string",
required: true,
default: "",
description: "ID of the entity",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {
operation: ["executeTrigger"],
});
// Parameters field
const parametersField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Parameters",
name: "parameters",
type: "json",
default: "{}",
description: "Trigger parameters in JSON format",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {
operation: ["executeTrigger"],
});
// Return All field
const returnAllField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Return All",
name: "returnAll",
type: "boolean",
default: false,
description: "Whether to return all results or only up to the limit",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {
operation: ["getAutomationRules", "getTriggers"],
});
// Limit field
const limitField = ModuleManager_1.ModuleManager.createSimpleField({
displayName: "Limit",
name: "limit",
type: "number",
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 50,
description: "Max number of results to return",
}, ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {
operation: ["getAutomationRules", "getTriggers"],
returnAll: [false],
});
// Options collection
const optionsCollection = ModuleManager_1.ModuleManager.createSimpleCollection("Options", ModuleManager_1.BITRIX24_MODULES.AUTOMATION, {}, [
{
displayName: "Access Token",
name: "accessToken",
type: "string",
default: "",
description: "Access token for authentication",
},
{
displayName: "Filter",
name: "filter",
type: "json",
default: "{}",
description: "Filter criteria",
},
]);
exports.automationOperationFields = [operationField];
// Alias for backward compatibility
exports.automationOperations = exports.automationOperationFields;
exports.automationEntityFields = [
entityTypeField,
entityIdField,
];
exports.automationTriggerFields = [
triggerCodeField,
parametersField,
];
exports.automationListFields = [
returnAllField,
limitField,
];
exports.automationOptionsFields = [optionsCollection];
exports.automationFields = [
/* Common Fields */
{
displayName: "Code",
name: "ruleId",
type: "string",
required: true,
default: "",
displayOptions: {
show: {
operation: ["getRule", "deleteRule", "updateRule"],
},
},
description: "ID of the automation rule",
},
/* Document Type Field - Required for all operations except delete */
{
displayName: "Document Type",
name: "documentType",
type: "options",
typeOptions: {
loadOptionsMethod: "getDynamicTypes",
},
required: false,
default: "crm_deal",
displayOptions: {
show: {
operation: ["createRule", "updateRule", "getAllRules", "getRule"],
},
},
description: "Type of document to which the automation rule applies",
},
/* SPA Placement field - shown only when Document Type is SPA */
{
displayName: "Smart Process",
name: "spaPlacement",
type: "options",
typeOptions: {
loadOptionsMethod: "getSpaPlacementOptions",
},
required: true,
default: "",
displayOptions: {
show: {
operation: ["createRule", "updateRule", "getAllRules", "getRule"],
documentType: ["spa_placement"],
},
},
description: "Select a Smart Process with automation enabled",
},
/* Create/Update Operation */
{
displayName: "Code",
name: "code",
type: "string",
required: true,
default: "",
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Internal identifier of the Automation rule. Must be unique within the application.",
placeholder: "my_rule_code",
hint: "Allowed characters: a-z, A-Z, 0-9, dot, hyphen, and underscore",
},
{
displayName: "Handler URL",
name: "handler",
type: "string",
required: true,
default: "",
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "URL to which the Automation rule will send data via the Bitrix24 queue server",
placeholder: "https://yourdomain.com/webhook/handler",
hint: "The link must have the same domain as where the application is installed",
},
{
displayName: "Name",
name: "name",
type: "string",
required: true,
default: "",
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Name of the Automation rule",
placeholder: "My Automation Rule",
},
{
displayName: "Localized Names",
name: "useLocalizedNames",
type: "boolean",
default: false,
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Whether to use localized names for different languages",
},
{
displayName: "Localized Names",
name: "localizedNames",
placeholder: "Add Localized Names",
type: "fixedCollection",
default: {},
typeOptions: {
multipleValues: true,
},
options: [
{
name: "names",
displayName: "Names",
values: [
{
displayName: "Language Code",
name: "langCode",
type: "string",
default: "en",
description: "Language code (e.g., en, de, fr, ru)",
},
{
displayName: "Name",
name: "name",
type: "string",
default: "",
description: "Name in the specified language",
},
],
},
],
description: "Localized names for different languages",
},
{
displayName: "Description",
name: "description",
type: "string",
default: "",
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Description of the Automation rule",
placeholder: "This rule handles...",
},
{
displayName: "Localized Descriptions",
name: "useLocalizedDescriptions",
type: "boolean",
default: false,
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Whether to use localized descriptions for different languages",
},
{
displayName: "Localized Descriptions",
name: "localizedDescriptions",
placeholder: "Add Localized Descriptions",
type: "fixedCollection",
default: {},
typeOptions: {
multipleValues: true,
},
options: [
{
name: "descriptions",
displayName: "Descriptions",
values: [
{
displayName: "Language Code",
name: "langCode",
type: "string",
default: "en",
description: "Language code (e.g., en, de, fr, ru)",
},
{
displayName: "Description",
name: "description",
type: "string",
default: "",
description: "Description in the specified language",
},
],
},
],
description: "Localized descriptions for different languages",
},
{
displayName: "Auth User ID",
name: "authUserId",
type: "number",
default: 1,
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Identifier of the user whose token will be passed to the application",
placeholder: "1",
},
{
displayName: "Sync Rule",
name: "syncRule",
type: "boolean",
default: false,
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Whether the Automation rule should wait for a response from the application",
},
/* Properties as Add Field format */
{
displayName: "Common Properties",
name: "commonProperties",
type: "collection",
default: {},
options: [
{
displayName: "Placement",
name: "PLACEMENT",
type: "options",
options: [
{ name: "Trigger List", value: "TRIGGER_LIST" },
{ name: "Details Card", value: "DETAIL_CARD" },
{ name: "Activity Panel", value: "ACTIVITY_PANEL" },
],
default: "TRIGGER_LIST",
description: "Where the automation rule should be displayed in the interface",
},
{
displayName: "Status IDs",
name: "STATUS_ID",
type: "multiOptions",
typeOptions: {
multipleValues: true,
},
options: [
{ name: "New", value: "NEW" },
{ name: "In Progress", value: "IN_PROGRESS" },
{ name: "Completed", value: "COMPLETED" },
{ name: "Pending", value: "PENDING" },
{ name: "In Process", value: "PROCESS" },
{ name: "Failed", value: "FAILED" },
],
default: [],
description: "Status IDs that trigger the automation (used with ON_STATUS event type)",
},
{
displayName: "Current Status",
name: "DOCUMENT_STATUS",
type: "options",
options: [
{ name: "New", value: "NEW" },
{ name: "In Progress", value: "IN_PROGRESS" },
{ name: "Completed", value: "COMPLETED" },
{ name: "Pending", value: "PENDING" },
{ name: "In Process", value: "PROCESS" },
{ name: "Failed", value: "FAILED" },
],
default: "NEW",
description: "Current status of the document for status-based rules",
},
{
displayName: "Trigger Order",
name: "TRIGGER_ORDER",
type: "number",
default: 100,
description: "Execution order of the trigger (lower numbers execute first)",
},
{
displayName: "Icon Type",
name: "ICON_TYPE",
type: "options",
options: [
{ name: "Standard", value: "STANDARD" },
{ name: "Custom", value: "CUSTOM" },
],
default: "STANDARD",
description: "Type of icon to use for the automation rule",
},
{
displayName: "Icon File URL",
name: "ICON_FILE",
type: "string",
displayOptions: {
show: {
ICON_TYPE: ["CUSTOM"],
},
},
default: "",
description: "URL to the custom icon file (used with ICON_TYPE=CUSTOM)",
},
{
displayName: "Icon",
name: "ICON",
type: "options",
options: [
{ name: "Default", value: "default" },
{ name: "Robot", value: "robot" },
{ name: "Code", value: "code" },
{ name: "Automation", value: "automation" },
{ name: "Integration", value: "integration" },
{ name: "Mail", value: "mail" },
{ name: "Calendar", value: "calendar" },
{ name: "Task", value: "task" },
],
displayOptions: {
show: {
ICON_TYPE: ["STANDARD"],
},
},
default: "default",
description: "Predefined icon to use (used with ICON_TYPE=STANDARD)",
},
{
displayName: "Sync",
name: "SYNC",
type: "boolean",
default: false,
description: "Whether the automation should sync with external systems",
},
{
displayName: "Template ID",
name: "TEMPLATE_ID",
type: "string",
default: "",
description: "ID of the template to associate with this automation",
},
],
description: "Common properties for the automation rule",
},
/* Custom properties as Add Field format */
{
displayName: "Custom Properties",
name: "propertiesCollection",
type: "fixedCollection",
typeOptions: {
multipleValues: true,
},
default: {},
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
options: [
{
name: "properties",
displayName: "Custom Property",
values: [
{
displayName: "Property Name",
name: "name",
type: "string",
required: true,
default: "",
description: "Name of the custom property (e.g., CUSTOM_FIELD, MY_PARAMETER)",
},
{
displayName: "Property Type",
name: "type",
type: "options",
options: [
{
name: "String",
value: "string",
},
{
name: "Number",
value: "number",
},
{
name: "Boolean",
value: "boolean",
},
{
name: "Array",
value: "array",
},
{
name: "Object",
value: "object",
},
],
default: "string",
description: "Type of the property value",
},
{
displayName: "String Value",
name: "stringValue",
type: "string",
default: "",
description: "String value of the property",
},
{
displayName: "Number Value",
name: "numberValue",
type: "number",
default: 0,
description: "Number value of the property",
},
{
displayName: "Boolean Value",
name: "booleanValue",
type: "boolean",
default: false,
description: "Boolean value of the property",
},
{
displayName: "Array or Object Value",
name: "complexValue",
type: "json",
default: "",
description: "Array or object value as JSON",
},
],
},
],
description: "Additional custom properties for the automation rule",
},
/* Keep the original properties field for backward compatibility */
{
displayName: "Use JSON for Properties",
name: "useJsonProperties",
type: "boolean",
default: false,
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
},
},
description: "Whether to set properties as a JSON object instead of individual fields",
},
{
displayName: "Properties JSON",
name: "properties",
type: "json",
default: "",
displayOptions: {
show: {
operation: ["createRule", "updateRule"],
useJsonProperties: [true],
},
},
description: "Additional properties for the automation rule as JSON",
placeholder: '{\n "PLACEMENT": "TRIGGER_LIST",\n "STATUS_ID": ["NEW", "IN_PROGRESS"]\n}',
},
/* Options for Get All Operation */
{
displayName: "Options",
name: "options",
type: "collection",
placeholder: "Add Option",
default: {},
options: [
{
displayName: "Access Token",
name: "accessToken",
type: "string",
default: "",
placeholder: "Enter the access token to use instead of credentials.",
description: "Access token to use for API requests. If provided, will take priority over token in credentials.",
},
{
displayName: "Filter",
name: "filter",
type: "json",
default: "",
description: "Filter to apply to the query",
placeholder: '{ "PROPERTY_VALUE": "yes" }',
},
{
displayName: "Order",
name: "order",
type: "json",
default: "",
description: "Sort order for the results",
placeholder: '{ "ID": "ASC" }',
},
],
},
{
displayName: "Use JSON Configuration",
name: "useJsonConfig",
type: "boolean",
displayOptions: {
show: {
operation: ["addRobot"],
},
},
default: false,
description: "Enable to use direct JSON configuration instead of individual fields",
},
{
displayName: "JSON Configuration",
name: "jsonConfig",
type: "json",
displayOptions: {
show: {
operation: ["addRobot"],
useJsonConfig: [true],
},
},
default: "{}",
description: "Complete robot configuration in JSON format",
},
];
//# sourceMappingURL=AutomationDescription.js.map