UNPKG

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

Version:
107 lines 4.63 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 WorkItemInstanceWorkHourCreateOperate = { name: '新增工时登记记录', value: 'work_item_instance:work_hour_create', order: 130, 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_id', type: 'string', required: true, default: '', description: '工作项实例 ID,在工作项实例详情中,展开右上角 ··· > ID 获取。', }, { displayName: '工作开始日期', name: 'work_begin_date', type: 'dateTime', required: true, default: '', description: '工作开始日期,支持日期选择器或表达式传入毫秒时间戳', }, { displayName: '工作结束日期', name: 'work_end_date', type: 'dateTime', required: true, default: '', description: '工作结束日期,支持日期选择器或表达式传入毫秒时间戳', }, { displayName: '包含节假日', name: 'include_holidays', type: 'boolean', default: true, description: 'Whether to include holidays in the work hour record', }, { displayName: '请求体参数', name: 'body', type: 'json', default: JSON.stringify({ "working_hour_records": [ { "resource_type": "", "resource_id": "", "work_time": "", "work_description": "" } ] }, null, 2), description: '完整的请求体参数,JSON格式', }, 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_id = this.getNodeParameter('work_item_id', index); const work_begin_date_raw = this.getNodeParameter('work_begin_date', index); const work_end_date_raw = this.getNodeParameter('work_end_date', index); const include_holidays = this.getNodeParameter('include_holidays', index); const bodyParam = this.getNodeParameter('body', index); const body = NodeUtils_1.default.parseJsonParameter(bodyParam, '请求体参数'); const options = this.getNodeParameter('options', index, {}); const toTimestamp = (value) => { if (typeof value === 'number') return value; if (/^\d+$/.test(value)) return parseInt(value, 10); return new Date(value).getTime(); }; body.work_begin_date = toTimestamp(work_begin_date_raw); body.work_end_date = toTimestamp(work_end_date_raw); body.include_holidays = include_holidays; return RequestUtils_1.default.request.call(this, { method: 'POST', url: `/open_api/${project_key}/work_item/${work_item_type_key}/${work_item_id}/work_hour_record`, body: body, timeout: options.timeout, }); } }; exports.default = WorkItemInstanceWorkHourCreateOperate; //# sourceMappingURL=WorkItemInstanceWorkHourCreateOperate.js.map