UNPKG

n8n-nodes-feishu-lark

Version:

n8n custom nodes for n8n to interact with Feishu/Lark, including Lark Bot, Lark MCP, and Lark Trigger.

64 lines 2.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const n8n_workflow_1 = require("n8n-workflow"); class NodeUtils { static getNodeFixedCollection(data, collectionName) { return data[collectionName] || []; } static getNodeFixedCollectionList(data, collectionName, propertyName) { const list = this.getNodeFixedCollection(data, collectionName); const result = []; for (const item of list) { result.push(item[propertyName]); } return result; } static async buildUploadFileData(inputDataFieldName, index = 0) { const binaryData = this.helpers.assertBinaryData(index, inputDataFieldName); if (!binaryData) { throw new Error('未找到二进制数据'); } const buffer = await this.helpers.getBinaryDataBuffer(index, inputDataFieldName); return { value: buffer, options: { filename: binaryData.fileName, filelength: binaryData.fileSize, contentType: binaryData.mimeType, }, }; } static getNodeJsonData(data, propertyName, index, failValue) { const text = data.getNodeParameter(propertyName, index, failValue); if (!text) { return failValue; } try { return JSON.parse(text); } catch (e) { throw new n8n_workflow_1.NodeOperationError(data.getNode(), `Can't parse [${propertyName}] JSON data: ${e.message}`); } } static getObjectData(context, index, propertyName, failValue) { const dataObject = context.getNodeParameter(propertyName || 'body', index, failValue); return typeof dataObject === 'string' ? (0, n8n_workflow_1.jsonParse)(dataObject) : dataObject; } static getArrayData(context, propertyName, index, validator, failValue) { const arrayJson = context.getNodeParameter(propertyName, index, failValue); const parsedArrayObject = typeof arrayJson === 'string' ? (0, n8n_workflow_1.jsonParse)(arrayJson) : arrayJson; (0, n8n_workflow_1.assertParamIsArray)(propertyName, parsedArrayObject, validator, context.getNode()); if (parsedArrayObject.length === 0) { throw new n8n_workflow_1.NodeOperationError(context.getNode(), `The ${propertyName} can not be empty`); } return parsedArrayObject; } static getNodeParameter(context, propertyName, failValue) { if ('getInputData' in context) { return context.getNodeParameter(propertyName, 0, failValue); } return context.getNodeParameter(propertyName, failValue); } } exports.default = NodeUtils; //# sourceMappingURL=node.js.map