UNPKG

@luka-cat-mimi/n8n-nodes-feishu-project

Version:

飞书项目 N8N 集成插件,支持附件管理等功能

95 lines 3.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FeishuProject = void 0; const n8n_workflow_1 = require("n8n-workflow"); const ResourceFactory_1 = __importDefault(require("../help/builder/ResourceFactory")); const resourceBuilder = ResourceFactory_1.default.build(__dirname); class FeishuProject { constructor() { this.description = { displayName: '飞书项目', subtitle: '={{ $parameter.resource }}:{{ $parameter.operation }}', name: 'feishuProject', icon: 'file:icon.svg', group: ['transform'], version: 1, description: '飞书项目管理 API 集成,支持工作项、空间、用户、工作流等完整功能', defaults: { name: '飞书项目', }, usableAsTool: true, inputs: ['main'], outputs: ['main'], credentials: [ { name: 'feishuProjectApi', required: true, }, ], properties: [ ...resourceBuilder.build(), ], }; } async execute() { var _a; const items = this.getInputData(); let responseData = {}; let returnData = []; const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); const callFunc = resourceBuilder.getCall(resource, operation); if (!callFunc) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), '未实现方法: ' + resource + '.' + operation); } for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { try { this.logger.debug('call function', { resource, operation, itemIndex, }); responseData = await callFunc.call(this, itemIndex); } catch (error) { this.logger.error('call function error', { resource, operation, itemIndex, errorMessage: error.message, stack: error.stack, }); if (this.continueOnFail()) { let errorJson = { error: error.message }; if (error.name === 'NodeApiError') { errorJson.error = (_a = error === null || error === void 0 ? void 0 : error.cause) === null || _a === void 0 ? void 0 : _a.error; } returnData.push({ json: errorJson, pairedItem: itemIndex, }); continue; } else if (error.name === 'NodeApiError') { throw error; } else { throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { message: error.message, itemIndex, }); } } const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: itemIndex } }); returnData.push(...executionData); } return [returnData]; } } exports.FeishuProject = FeishuProject; //# sourceMappingURL=FeishuProject.node.js.map