UNPKG

@tuanltntu/n8n-nodes-bitrix24

Version:

Comprehensive n8n community node for Bitrix24 API integration with CRM, Tasks, Chat, Telephony, and more

1,224 lines 37.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bizprocOptions = exports.bizprocApproveDisapproveTaskFields = exports.bizprocDelegateTaskFields = exports.bizprocWorkflowInstancesFields = exports.bizprocMiscFields = exports.bizprocActivityFields = exports.bizprocRobotFields = exports.bizprocTemplateFields = exports.bizprocCompleteTaskFields = exports.bizprocWorkflowTasksFields = exports.bizprocAvailableWorkflowsFields = exports.bizprocWorkflowStatusFields = exports.bizprocStartWorkflowFields = exports.bizprocOperationFields = void 0; const ModuleManager_1 = require("../ModuleManager"); // Bizproc operations const operationField = ModuleManager_1.ModuleManager.createSimpleField({ displayName: "Operation", name: "operation", type: "options", noDataExpression: true, options: [ { name: "Start Workflow", value: "startWorkflow", description: "Start a workflow", action: "Start a workflow", }, { name: "Get Task", value: "getTask", description: "Get workflow task", action: "Get workflow task", }, { name: "Get Tasks", value: "getTasks", description: "Get workflow tasks", action: "Get workflow tasks", }, { name: "Complete Task", value: "completeTask", description: "Complete workflow task", action: "Complete workflow task", }, { name: "Get Workflow", value: "getWorkflow", description: "Get workflow information", action: "Get workflow information", }, { name: "Get Workflows", value: "getWorkflows", description: "Get workflows", action: "Get workflows", }, ], default: "getWorkflows", }, ModuleManager_1.BITRIX24_MODULES.BIZPROC); // Template ID field const templateIdField = ModuleManager_1.ModuleManager.createSimpleField({ displayName: "Template ID", name: "templateId", type: "string", required: true, default: "", description: "ID of the workflow template", }, ModuleManager_1.BITRIX24_MODULES.BIZPROC, { operation: ["startWorkflow"], }); // Workflow ID field const workflowIdField = ModuleManager_1.ModuleManager.createSimpleField({ displayName: "Workflow ID", name: "workflowId", type: "string", required: true, default: "", description: "ID of the workflow", }, ModuleManager_1.BITRIX24_MODULES.BIZPROC, { operation: ["startWorkflow", "getWorkflow"], }); // Task ID field const taskIdField = ModuleManager_1.ModuleManager.createSimpleField({ displayName: "Task ID", name: "taskId", type: "string", required: true, default: "", description: "ID of the task", }, ModuleManager_1.BITRIX24_MODULES.BIZPROC, { operation: ["getTask", "completeTask"], }); // Document ID field const documentIdField = ModuleManager_1.ModuleManager.createSimpleField({ displayName: "Document ID", name: "documentId", type: "string", required: true, default: "", description: "ID of the document to start workflow for", }, ModuleManager_1.BITRIX24_MODULES.BIZPROC, { operation: ["startWorkflow"], }); // Parameters field const parametersField = ModuleManager_1.ModuleManager.createSimpleField({ displayName: "Parameters", name: "parameters", type: "json", default: "{}", description: "Workflow parameters in JSON format", }, ModuleManager_1.BITRIX24_MODULES.BIZPROC, { operation: ["startWorkflow", "completeTask"], }); // 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.BIZPROC, { operation: ["getTasks", "getWorkflows"], }); // 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.BIZPROC, { operation: ["getTasks", "getWorkflows"], returnAll: [false], }); // Options collection const optionsCollection = ModuleManager_1.ModuleManager.createSimpleCollection("Options", ModuleManager_1.BITRIX24_MODULES.BIZPROC, {}, [ { displayName: "Access Token", name: "accessToken", type: "string", default: "", description: "Access token for authentication", }, { displayName: "Filter", name: "filter", type: "json", default: "{}", description: "Filter criteria", }, { displayName: "Order", name: "order", type: "json", default: "{}", description: "Sort order", }, ]); // Common fields used in Bizproc operations exports.bizprocOperationFields = [ // Operation selector for bizproc operations { displayName: "Operation", name: "operation", type: "options", noDataExpression: true, displayOptions: { show: {}, }, options: [ // Workflow operations { name: "Start Workflow", value: "startWorkflow", description: "Start a business process on an element (bizproc.workflow.start)", action: "Start a workflow", }, { name: "Get Workflow Status", value: "getWorkflowStatus", description: "Get status of a running workflow (bizproc.workflow.instance.get)", action: "Get workflow status", }, { name: "Get Available Workflows", value: "getAvailableWorkflows", description: "Get list of available workflows for an element (bizproc.workflow.instances.list)", action: "Get available workflows", }, { name: "Get Workflow Instances", value: "getWorkflowInstances", description: "Get list of running workflow instances (bizproc.workflow.instances.list)", action: "Get workflow instances", }, { name: "Terminate Workflow", value: "terminateWorkflow", description: "Terminate a running workflow (bizproc.workflow.terminate)", action: "Terminate a workflow", }, // Task operations { name: "Get Workflow Tasks", value: "getWorkflowTasks", description: "Get tasks for running workflows (bizproc.task.list)", action: "Get workflow tasks", }, { name: "Get Task", value: "getTask", description: "Get a single task by ID (bizproc.task.get)", action: "Get a workflow task", }, { name: "Complete Task", value: "completeTask", description: "Complete a workflow task (bizproc.task.complete)", action: "Complete a workflow task", }, { name: "Delegate Task", value: "delegateTask", description: "Delegate a workflow task to another user (bizproc.task.delegate)", action: "Delegate a workflow task", }, { name: "Approve Task", value: "approveTask", description: "Approve a workflow task (bizproc.task.approve)", action: "Approve a workflow task", }, { name: "Disapprove Task", value: "disapproveTask", description: "Disapprove a workflow task (bizproc.task.disapprove)", action: "Disapprove a workflow task", }, // Template operations { name: "Get Workflow Templates", value: "getTemplates", description: "Get workflow templates for an entity type (bizproc.workflow.template.list)", action: "Get workflow templates", }, { name: "Get Workflow Template", value: "getTemplate", description: "Get single workflow template by ID (bizproc.workflow.template.get)", action: "Get a workflow template", }, { name: "Add Workflow Template", value: "addTemplate", description: "Add a new workflow template (bizproc.workflow.template.add)", action: "Add a workflow template", }, { name: "Update Workflow Template", value: "updateTemplate", description: "Update an existing workflow template (bizproc.workflow.template.update)", action: "Update a workflow template", }, { name: "Delete Workflow Template", value: "deleteTemplate", description: "Delete a workflow template (bizproc.workflow.template.delete)", action: "Delete a workflow template", }, // Document operations { name: "Get Document Types", value: "getDocumentTypes", description: "Get list of available document types (bizproc.document.types.list)", action: "Get document types", }, { name: "Get Document Type Fields", value: "getDocumentTypeFields", description: "Get fields for a specific document type (bizproc.document.fields.get)", action: "Get document type fields", }, { name: "Add Document", value: "addDocument", description: "Add a new document (bizproc.document.add)", action: "Add a document", }, { name: "Update Document", value: "updateDocument", description: "Update an existing document (bizproc.document.update)", action: "Update a document", }, { name: "Delete Document", value: "deleteDocument", description: "Delete a document (bizproc.document.delete)", action: "Delete a document", }, { name: "Get Document", value: "getDocument", description: "Get a document by ID (bizproc.document.get)", action: "Get a document", }, { name: "List Documents", value: "listDocuments", description: "List documents (bizproc.document.list)", action: "List documents", }, // Robot operations { name: "Get Robot Properties", value: "getRobotProperties", description: "Get available robot properties for workflow templates (bizproc.robot.properties)", action: "Get robot properties", }, { name: "Add Robot", value: "addRobot", description: "Register a new Automation Rule (bizproc.robot.add)", action: "Add a robot", }, { name: "Update Robot", value: "updateRobot", description: "Update fields of an already added Automation Rule (bizproc.robot.update)", action: "Update a robot", }, { name: "List Robots", value: "listRobots", description: "List all robots registered in Bitrix24 (bizproc.robot.list)", action: "List robots", }, { name: "Delete Robot", value: "deleteRobot", description: "Delete an Automation Rule (bizproc.robot.delete)", action: "Delete a robot", }, ], default: "getWorkflowTasks", }, ]; // Fields for starting a workflow exports.bizprocStartWorkflowFields = [ { displayName: "Entity Type", name: "entityType", type: "options", required: true, displayOptions: { show: { operation: ["startWorkflow"], }, }, options: [ { name: "CRM Lead", value: "crm_lead", }, { name: "CRM Deal", value: "crm_deal", }, { name: "CRM Contact", value: "crm_contact", }, { name: "CRM Company", value: "crm_company", }, { name: "CRM Smart Process", value: "crm_item", }, { name: "Task", value: "tasks_task", }, { name: "Lists Item", value: "lists_element", }, ], default: "crm_lead", description: "Type of entity to start workflow on", }, { displayName: "Entity ID", name: "entityId", type: "string", required: true, displayOptions: { show: { operation: ["startWorkflow"], }, }, default: "", description: "ID of the entity to start workflow on", }, { displayName: "Template ID", name: "templateId", type: "string", required: true, displayOptions: { show: { operation: ["startWorkflow"], }, }, default: "", description: "ID of the workflow template to start", }, { displayName: "Parameters", name: "parameters", type: "json", displayOptions: { show: { operation: ["startWorkflow"], }, }, default: "{}", description: "Workflow parameters as JSON", }, ]; // Fields for getting workflow status exports.bizprocWorkflowStatusFields = [ { displayName: "Workflow ID", name: "workflowId", type: "string", required: true, displayOptions: { show: { operation: ["getWorkflowStatus", "terminateWorkflow"], }, }, default: "", description: "ID of the workflow to check status or terminate", }, ]; // Fields for getting available workflows exports.bizprocAvailableWorkflowsFields = [ { displayName: "Entity Type", name: "entityType", type: "options", required: true, displayOptions: { show: { operation: [ "getAvailableWorkflows", "getTemplates", "addTemplate", "updateTemplate", "getDocumentTypeFields", "updateRobot", "listRobots", ], }, }, options: [ { name: "CRM Lead", value: "crm_lead", }, { name: "CRM Deal", value: "crm_deal", }, { name: "CRM Contact", value: "crm_contact", }, { name: "CRM Company", value: "crm_company", }, { name: "CRM Smart Process", value: "crm_item", }, { name: "Task", value: "tasks_task", }, { name: "Lists Item", value: "lists_element", }, ], default: "crm_lead", description: "Type of entity to get workflows for", }, { displayName: "Entity ID", name: "entityId", type: "string", required: true, displayOptions: { show: { operation: ["getAvailableWorkflows"], }, }, default: "", description: "ID of the entity to get workflows for", }, ]; // Fields for getting workflow tasks exports.bizprocWorkflowTasksFields = [ { displayName: "User ID", name: "userId", type: "string", default: "", required: false, displayOptions: { show: { operation: ["getWorkflowTasks"], }, }, description: "Filter tasks by user ID", }, { displayName: "Entity Type", name: "entityType", type: "string", default: "", required: false, displayOptions: { show: { operation: ["getWorkflowTasks"], }, }, description: "Filter tasks by entity type", }, { displayName: "Entity ID", name: "entityId", type: "string", default: "", required: false, displayOptions: { show: { operation: ["getWorkflowTasks"], }, }, description: "Filter tasks by entity ID", }, { displayName: "Order", name: "order", type: "options", options: [ { name: "Ascending", value: "asc", }, { name: "Descending", value: "desc", }, ], default: "desc", displayOptions: { show: { operation: ["getWorkflowTasks"], }, }, description: "Order of tasks", }, ]; // Fields for completing a task exports.bizprocCompleteTaskFields = [ { displayName: "Task ID", name: "taskId", type: "string", required: true, displayOptions: { show: { operation: ["completeTask", "getTask"], }, }, default: "", description: "ID of the task to complete or get", }, { displayName: "Task Result", name: "taskResult", type: "options", required: true, displayOptions: { show: { operation: ["completeTask"], }, }, options: [ { name: "Approve", value: "Y", }, { name: "Reject", value: "N", }, ], default: "Y", description: "Result of the task completion", }, { displayName: "Comment", name: "comment", type: "string", displayOptions: { show: { operation: ["completeTask"], }, }, default: "", description: "Comment for the task completion", }, { displayName: "Task Parameters", name: "taskParameters", type: "json", displayOptions: { show: { operation: ["completeTask"], }, }, default: "{}", description: "Additional parameters for task completion as JSON", }, ]; // Fields for template operations exports.bizprocTemplateFields = [ { displayName: "Template ID", name: "templateId", type: "string", required: true, displayOptions: { show: { operation: ["getTemplate", "updateTemplate", "deleteTemplate"], }, }, default: "", description: "ID of the workflow template", }, { displayName: "Template Data", name: "templateData", type: "json", required: true, displayOptions: { show: { operation: ["addTemplate", "updateTemplate"], }, }, default: "{}", description: "Template data as JSON", }, ]; // Fields for robot operations exports.bizprocRobotFields = [ // Các trường bắt buộc cho việc thêm robot - theo đúng ví dụ API { displayName: "Document Type", name: "documentType", type: "options", options: [ { name: "CRM Lead", value: '["crm","CCrmDocumentLead","LEAD"]' }, { name: "CRM Deal", value: '["crm","CCrmDocumentDeal","DEAL"]' }, { name: "CRM Contact", value: '["crm","CCrmDocumentContact","CONTACT"]' }, { name: "CRM Company", value: '["crm","CCrmDocumentCompany","COMPANY"]' }, ], required: true, default: '["crm","CCrmDocumentDeal","DEAL"]', displayOptions: { show: { operation: ["startWorkflow"], }, }, description: "Document type for the workflow", }, { displayName: "Document ID", name: "documentId", type: "string", required: true, default: "", displayOptions: { show: { operation: ["startWorkflow"], }, }, description: "ID of the document to process", }, { displayName: "Parameters", name: "parameters", type: "json", default: "{}", displayOptions: { show: { operation: ["startWorkflow"], }, }, description: "Parameters for the workflow (as JSON object)", }, { displayName: "Robot Code", name: "robotCode", type: "string", required: true, displayOptions: { show: { operation: ["addRobot"], }, }, default: "", description: "Unique code identifier for the robot", }, { displayName: "Robot Name", name: "robotName", type: "string", required: true, displayOptions: { show: { operation: ["addRobot"], }, }, default: "", description: "Name of the automation rule", }, { displayName: "Handler URL", name: "handlerUrl", type: "string", required: true, displayOptions: { show: { operation: ["addRobot"], }, }, default: "", description: "URL handler for the robot (e.g., https://your_domain/robot.php)", placeholder: "https://your_domain/robot.php", }, { displayName: "Auth User ID", name: "authUserId", type: "number", required: true, displayOptions: { show: { operation: ["addRobot"], }, }, default: 1, description: "ID of the user to authenticate the robot", }, { displayName: "Use Subscription", name: "useSubscription", type: "boolean", required: true, displayOptions: { show: { operation: ["addRobot"], }, }, default: true, description: "Whether to use subscription", }, { displayName: "Description", name: "robotDescription", type: "string", required: false, displayOptions: { show: { operation: ["addRobot"], }, }, default: "", description: "Description of the automation rule", }, { displayName: "Properties", name: "properties", type: "json", required: true, displayOptions: { show: { operation: ["addRobot"], }, }, default: '{\n "datetime": {\n "Name": "When",\n "Type": "datetime"\n },\n "text": {\n "Name": "Text",\n "Type": "text"\n },\n "user": {\n "Name": "To Whom",\n "Type": "user",\n "Default": "Author;"\n }\n}', description: "Properties of the robot as JSON", }, { displayName: "Filter", name: "filter", type: "fixedCollection", default: {}, options: [ { name: "include", displayName: "Include Document Types", values: [ { displayName: "Document Types", name: "documentTypes", type: "multiOptions", options: [ { name: "CRM Lead", value: '["crm","CCrmDocumentLead","LEAD"]' }, { name: "CRM Deal", value: '["crm","CCrmDocumentDeal","DEAL"]' }, { name: "CRM Contact", value: '["crm","CCrmDocumentContact","CONTACT"]', }, { name: "CRM Company", value: '["crm","CCrmDocumentCompany","COMPANY"]', }, { name: "CRM Quote", value: '["crm","Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\Quote","QUOTE"]', }, { name: "CRM Smart Invoice", value: '["crm","Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\SmartInvoice","SMART_INVOICE"]', }, { name: "CRM Smart Process", value: '["crm","Bitrix\\\\Crm\\\\Integration\\\\BizProc\\\\Document\\\\Dynamic","DYNAMIC_XXX"]', }, ], default: [], description: "Document types to include in filter", }, ], }, ], description: "Filter settings for the robot", }, { 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: "Robot Configuration (JSON)", name: "robotConfig", type: "json", required: true, displayOptions: { show: { operation: ["addRobot"], useJsonConfig: [true], }, }, default: '{\n "CODE": "test_robot",\n "HANDLER": "https://your_domain/robot.php",\n "AUTH_USER_ID": 1,\n "USE_SUBSCRIPTION": "Y",\n "NAME": "Send Message",\n "PROPERTIES": {\n "datetime": {\n "Name": "When",\n "Type": "datetime"\n },\n "text": {\n "Name": "Text",\n "Type": "text"\n },\n "user": {\n "Name": "To Whom",\n "Type": "user",\n "Default": "Author;"\n }\n },\n "FILTER": {\n "INCLUDE": [\n ["crm", "CCrmDocumentDeal"],\n ["crm", "CCrmDocumentLead"]\n ]\n }\n}', description: "Complete robot configuration as JSON (using Bitrix24 API format)", }, // Fields for robot operations { displayName: "Robot ID", name: "robotId", type: "string", required: true, displayOptions: { show: { operation: ["updateRobot", "deleteRobot"], }, }, default: "", description: "ID of the automation rule", }, { displayName: "Robot Data (JSON)", name: "robotData", type: "json", required: true, displayOptions: { show: { operation: ["updateRobot"], }, }, default: '{\n "CODE": "test_robot",\n "HANDLER": "https://your_domain/robot.php",\n "AUTH_USER_ID": 1,\n "USE_SUBSCRIPTION": "Y",\n "NAME": "Send Message",\n "PROPERTIES": {\n "datetime": {\n "Name": "When",\n "Type": "datetime"\n },\n "text": {\n "Name": "Text",\n "Type": "text"\n },\n "user": {\n "Name": "To Whom",\n "Type": "user",\n "Default": "Author;"\n }\n },\n "FILTER": {\n "INCLUDE": [\n ["crm", "CCrmDocumentDeal"],\n ["crm", "CCrmDocumentLead"]\n ]\n }\n}', description: "Complete robot configuration as JSON (for advanced users or update operations)", }, // Fields for sendEvent operation { displayName: "Event Name", name: "eventName", type: "string", required: true, displayOptions: { show: { operation: ["sendEvent"], }, }, default: "", description: "Name of the event to send", }, { displayName: "Event Parameters", name: "eventParameters", type: "json", displayOptions: { show: { operation: ["sendEvent"], }, }, default: "{}", description: "Event parameters as JSON", }, // Additional fields for document operations { displayName: "Entity Type", name: "entityType", type: "options", required: true, displayOptions: { show: { operation: ["getDocumentOperations"], }, }, options: [ { name: "CRM Lead", value: "crm_lead", }, { name: "CRM Deal", value: "crm_deal", }, { name: "CRM Contact", value: "crm_contact", }, { name: "CRM Company", value: "crm_company", }, { name: "CRM Smart Process", value: "crm_item", }, { name: "Task", value: "tasks_task", }, { name: "Lists Item", value: "lists_element", }, ], default: "crm_lead", description: "Type of entity to get operations for", }, { displayName: "Entity ID", name: "entityId", type: "string", required: false, displayOptions: { show: { operation: ["getDocumentOperations"], }, }, default: "", description: "ID of the entity to get operations for", }, // Script operations { displayName: "Script ID", name: "scriptId", type: "string", required: true, displayOptions: { show: { operation: [ "getScriptOperations", "getScript", "updateScript", "deleteScript", ], }, }, default: "", description: "ID of the script", }, ]; // Fields for activity operations exports.bizprocActivityFields = [ { displayName: "Activity Code", name: "activityCode", type: "string", required: true, displayOptions: { show: { operation: ["updateActivity", "deleteActivity", "logActivity"], }, }, default: "", description: "Code identifier of the activity", }, { displayName: "Activity Data", name: "activityData", type: "json", required: true, displayOptions: { show: { operation: ["addActivity", "updateActivity"], }, }, default: "{}", description: "Activity configuration data as JSON", }, { displayName: "Log Message", name: "logMessage", type: "string", required: true, displayOptions: { show: { operation: ["logActivity"], }, }, default: "", description: "Message to record in the workflow log", }, { displayName: "Workflow ID", name: "workflowId", type: "string", required: true, displayOptions: { show: { operation: ["logActivity"], }, }, default: "", description: "ID of the workflow to log information for", }, ]; // Fields for activity, robot and document type operations exports.bizprocMiscFields = [ { displayName: "Module ID", name: "moduleId", type: "string", displayOptions: { show: { operation: ["getDocumentTypes"], }, }, default: "", description: "ID of the module to get document types for (e.g. 'crm', 'tasks')", }, ]; // Fields for getting workflow instances exports.bizprocWorkflowInstancesFields = [ { displayName: "Filter", name: "instanceFilter", type: "json", default: "{}", description: "Filter criteria in JSON format for workflow instances", displayOptions: { show: { operation: ["getWorkflowInstances"], }, }, }, { displayName: "Order", name: "instanceOrder", type: "json", default: "{}", description: "Order by fields in JSON format for workflow instances", displayOptions: { show: { operation: ["getWorkflowInstances"], }, }, }, { displayName: "Select", name: "instanceSelect", type: "string", default: "", description: "List of fields to include in the workflow instances response", displayOptions: { show: { operation: ["getWorkflowInstances"], }, }, }, ]; // Fields for delegate task exports.bizprocDelegateTaskFields = [ { displayName: "Task ID", name: "taskId", type: "string", required: true, displayOptions: { show: { operation: ["delegateTask"], }, }, default: "", description: "ID of the task to delegate", }, { displayName: "User ID", name: "userId", type: "string", required: true, displayOptions: { show: { operation: ["delegateTask"], }, }, default: "", description: "ID of the user to delegate the task to", }, { displayName: "Parameters", name: "parameters", type: "json", displayOptions: { show: { operation: ["delegateTask"], }, }, default: "{}", description: "Additional parameters for task delegation", }, ]; // Fields for approve/disapprove task exports.bizprocApproveDisapproveTaskFields = [ { displayName: "Task ID", name: "taskId", type: "string", required: true, displayOptions: { show: { operation: ["approveTask", "disapproveTask"], }, }, default: "", description: "ID of the task to approve/disapprove", }, { displayName: "Parameters", name: "parameters", type: "json", displayOptions: { show: { operation: ["approveTask", "disapproveTask"], }, }, default: "{}", description: "Parameters for task approval/disapproval", }, { displayName: "Comment", name: "comment", type: "string", displayOptions: { show: { operation: ["approveTask", "disapproveTask"], }, }, default: "", description: "Comment for task approval/disapproval", }, ]; // Move the options collection to the end of the file exports.bizprocOptions = [ { 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: "Custom Parameters", name: "customParameters", type: "json", default: "{}", description: "Additional parameters to include in the request", }, ], }, ]; //# sourceMappingURL=BizprocDescription.js.map