UNPKG

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

Version:
96 lines 4.03 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const RequestUtils_1 = __importDefault(require("../../../help/utils/RequestUtils")); const description_1 = require("../../../help/description"); const AttachmentDeleteOperate = { name: '删除附件', value: 'attachment:delete', order: 40, description: '在指定工作项的一个附件类型字段中删除附件。', options: [ { displayName: '该接口用于在指定工作项的一个附件类型字段中删除附件。', name: 'deleteNotice', type: 'notice', default: '', }, description_1.DESCRIPTIONS.PROJECT_KEY, { displayName: '工作项类型 Name or ID', name: 'work_item_type_key', type: 'options', default: '', required: true, description: '空间下工作项类型,需要先选择空间,详见:<a href="https://project.feishu.cn/b/helpcenter/2.0.0/1p8d7djs/3pjp854w">获取空间下工作项类型</a>. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.', typeOptions: { loadOptionsMethod: 'loadWorkItemTypes', }, }, { displayName: '工作项实例ID', name: 'work_item_id', type: 'string', required: true, default: '', description: '工作项实例 ID,在工作项实例详情中,展开右上角 ··· > ID 获取。', }, { displayName: '附件字段 Name or ID', name: 'field_key', type: 'options', default: '', required: true, description: '选择要删除附件的目标字段。需要先选择空间和工作项类型. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.', typeOptions: { loadOptionsMethod: 'loadAttachmentFields', }, }, { displayName: '附件UUID列表', name: 'uuids', type: 'string', default: '', required: true, description: '需要删除的附件唯一标识列表,多个UUID用英文逗号分隔,也支持表达式传递数组。可通过工作项详情接口下的附件字段(multi_file类型)获取', }, ], async call(index) { const project_key = this.getNodeParameter('project_key', index, '', { extractValue: true, }); const work_item_id = this.getNodeParameter('work_item_id', index); const field_key = this.getNodeParameter('field_key', index); const uuids = this.getNodeParameter('uuids', index); let uuidsArray; if (Array.isArray(uuids)) { uuidsArray = uuids.map((uuid) => String(uuid).trim()).filter((uuid) => uuid); } else { uuidsArray = String(uuids || '') .split(',') .map((uuid) => uuid.trim()) .filter((uuid) => uuid); } if (uuidsArray.length === 0) { throw new Error('uuids 参数不能为空,请至少提供一个附件UUID'); } const body = { work_item_id: Number(work_item_id), project_key: project_key, uuids: uuidsArray, }; if (field_key === null || field_key === void 0 ? void 0 : field_key.trim()) { body.field_key = field_key.trim(); } return RequestUtils_1.default.request.call(this, { method: 'POST', url: `/open_api/file/delete`, body: body, }); } }; exports.default = AttachmentDeleteOperate; //# sourceMappingURL=AttachmentDeleteOperate.js.map