@luka-cat-mimi/n8n-nodes-feishu-project
Version:
飞书项目 N8N 集成插件,支持附件管理等功能
139 lines • 6.16 kB
JavaScript
;
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 description_1 = require("../../../help/description");
const WorkItemInstanceQueryOperate = {
name: '获取工作项详情',
value: 'work_item_instance:query',
order: 10,
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',
required: true,
default: '',
description: '工作项ID列表,多个ID用逗号分隔,也支持表达式数组',
},
{
displayName: '返回字段',
name: 'fields',
type: 'string',
default: '',
description: '工作项中的字段标识,非必填,默认返回全部。字段格式可查看<a href="https://project.feishu.cn/b/helpcenter/2.0.0/1p8d7djs/1tj6ggll">字段与属性解析格式</a>。支持两种模式(不可混用):指定字段 - 仅返回列出的字段,如 ["aborted","role_owners"];排除字段 - 以 - 开头排除该字段,如 ["-aborted","-role_owners"]',
},
{
displayName: '选项',
name: 'options',
type: 'collection',
placeholder: '添加选项',
default: {},
options: [
{
displayName: '返回用户详细信息',
name: 'need_user_detail',
type: 'boolean',
default: true,
description: '是否返回用户详细信息',
},
{
displayName: '返回工作流信息',
name: 'need_workflow',
type: 'boolean',
default: true,
description: '是否返回工作流信息 (目前只支持节点流工作项类型实例,状态流工作项类型实例会返回空结构)',
},
{
displayName: '返回富文本信息',
name: 'need_multi_text',
type: 'boolean',
default: true,
description: '是否返回富文本信息',
},
{
displayName: '返回关联详细信息',
name: 'relation_fields_detail',
type: 'boolean',
default: true,
description: '是否返回关联详细信息',
},
{
displayName: '补充复合字段组标识',
name: 'need_group_uuid_for_compound',
type: 'boolean',
default: false,
description: '是否补充复合字段组标识',
},
{
displayName: '超时时间',
name: 'timeout',
type: 'number',
default: 60000,
description: '请求超时时间(毫秒)',
},
],
},
],
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 fields_raw = this.getNodeParameter('fields', index, '');
const options = this.getNodeParameter('options', index, {});
const body = {};
body.work_item_ids = NodeUtils_1.default.parseIdList(work_item_ids_raw);
if (fields_raw) {
if (Array.isArray(fields_raw)) {
body.fields = fields_raw.map(f => String(f).trim()).filter(f => f);
}
else if (typeof fields_raw === 'string' && fields_raw.trim()) {
body.fields = fields_raw.split(',').map(f => f.trim()).filter(f => f);
}
}
const expand = {};
if (options.need_user_detail !== undefined) {
expand.need_user_detail = options.need_user_detail;
}
if (options.need_workflow !== undefined) {
expand.need_workflow = options.need_workflow;
}
if (options.need_multi_text !== undefined) {
expand.need_multi_text = options.need_multi_text;
}
if (options.relation_fields_detail !== undefined) {
expand.relation_fields_detail = options.relation_fields_detail;
}
if (options.need_group_uuid_for_compound !== undefined) {
expand.need_group_uuid_for_compound = options.need_group_uuid_for_compound;
}
if (Object.keys(expand).length > 0) {
body.expand = expand;
}
return RequestUtils_1.default.request.call(this, {
method: 'POST',
url: `/open_api/${project_key}/work_item/${work_item_type_key}/query`,
body: body,
timeout: options.timeout,
});
}
};
exports.default = WorkItemInstanceQueryOperate;
//# sourceMappingURL=WorkItemInstanceQueryOperate.js.map