n8n-nodes-feishu-lite
Version:
92 lines • 3.51 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeishuNode = 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 FeishuNode {
constructor() {
this.description = {
displayName: 'Feishu Node',
name: 'feishuNode',
icon: 'file:icon.png',
group: ['transform'],
version: 1,
description: 'Feishu Node',
defaults: {
name: 'Feishu Node',
},
usableAsTool: true,
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'feishuCredentialsApi',
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.FeishuNode = FeishuNode;
//# sourceMappingURL=FeishuNode.node.js.map