UNPKG

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

Version:
126 lines 5.71 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 NodeUtils_1 = __importDefault(require("../../../help/utils/NodeUtils")); const sharedOptions_1 = require("../../../help/utils/sharedOptions"); const description_1 = require("../../../help/description"); const WorkItemInstanceBatchUpdateOperate = { name: '批量更新工作项字段值', value: 'work_item_instance:batch_update', order: 50, options: [ 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_ids', type: 'string', default: '', required: true, description: '工作项ID列表,多个ID用逗号分隔,也支持表达式数组。一次请求最大50个', }, { displayName: '更新模式', name: 'update_mode', type: 'options', options: [ { name: 'APPEND - 追加', value: 'APPEND', description: '仅支持 多选人员、多选、多选关联工作项(非级联)三种字段类型', }, { name: 'UPDATE - 覆盖', value: 'UPDATE', description: '不支持 计算字段、系统外信号 字段类型', }, { name: 'REPLACE - 替换', value: 'REPLACE', description: '仅支持 单选、级联单选、多选、单选按钮、单选人员、多选人员、单选关联工作项、多选关联工作项(非级联)', }, ], default: 'UPDATE', required: true, description: '本次批量操作的更新方式', }, { displayName: '字段Key', name: 'field_key', type: 'string', default: '', required: true, description: '待修改字段ID,批量修改仅支持单个字段修改(可修改字段类型见 update_mode 参数说明)', }, { displayName: '被替换的字段值', name: 'before_field_value', type: 'json', default: '', required: true, displayOptions: { show: { update_mode: ['REPLACE'], }, }, description: '被替换的字段值(当 update_mode=REPLACE 时必填,其余情况下忽略),JSON格式。可参考<a href="https://project.feishu.cn/b/helpcenter/1p8d7djs/1tj6ggll">字段与属性解析格式</a>', }, { displayName: '目标字段值', name: 'after_field_value', type: 'json', default: '', required: true, description: '操作类型的目标字段值,JSON格式。允许 field_value 为空,等价于删除。可参考<a href="https://project.feishu.cn/b/helpcenter/1p8d7djs/1tj6ggll">字段与属性解析格式</a>', }, sharedOptions_1.commonOptions, ], async call(index) { const project_key = this.getNodeParameter('project_key', index, '', { extractValue: true, }); const work_item_type_key = this.getNodeParameter('work_item_type_key', index); const work_item_ids_raw = this.getNodeParameter('work_item_ids', index); const update_mode = this.getNodeParameter('update_mode', index); const field_key = this.getNodeParameter('field_key', index); const after_field_value_param = this.getNodeParameter('after_field_value', index); const options = this.getNodeParameter('options', index, {}); const work_item_ids = NodeUtils_1.default.parseNumericIdList(work_item_ids_raw); const after_field_value = NodeUtils_1.default.parseJsonParameter(after_field_value_param, '目标字段值'); const body = { project_key, work_item_type_key, work_item_ids, update_mode, field_key, after_field_value, }; if (update_mode === 'REPLACE') { const before_field_value_param = this.getNodeParameter('before_field_value', index, ''); if (before_field_value_param) { body.before_field_value = NodeUtils_1.default.parseJsonParameter(before_field_value_param, '被替换的字段值'); } } return RequestUtils_1.default.request.call(this, { method: 'POST', url: `/open_api/work_item/batch_update`, body: body, timeout: options.timeout, }); } }; exports.default = WorkItemInstanceBatchUpdateOperate; //# sourceMappingURL=WorkItemInstanceBatchUpdateOperate.js.map