UNPKG

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

Version:
78 lines 2.88 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 sharedOptions_1 = require("../../../help/utils/sharedOptions"); const SpaceListDetailOperate = { name: '获取空间列表详情(自定义封装)', value: 'space:list_detail', order: 40, options: [ { displayName: '排序方式', name: 'order', type: 'options', options: [ { name: '不排序', value: '', }, { name: '按最近访问时间升序 (Last Visited)', value: 'last_visited', }, { name: '按最近访问时间升序 (+Last Visited)', value: '+last_visited', }, { name: '按最近访问时间降序 (-Last Visited)', value: '-last_visited', }, ], default: '', description: '排序字段,格式为前缀+排序字段。+号表示升序;-表示降序;不加默认为升序。目前仅支持对 last_visited (最近访问时间)排序。', }, sharedOptions_1.commonOptions, ], async call(index) { const orderValue = this.getNodeParameter('order', index); const options = this.getNodeParameter('options', index, {}); const credentials = await this.getCredentials('feishuProjectApi'); const userKey = credentials.userId; const listBody = { user_key: userKey, }; if (orderValue) { listBody.order = [orderValue]; } const spaceIds = await RequestUtils_1.default.request.call(this, { method: 'POST', url: '/open_api/projects', body: listBody, timeout: options.timeout, }); if (!Array.isArray(spaceIds) || spaceIds.length === 0) { return []; } const limitedKeys = spaceIds.slice(0, 100); const detailBody = { project_keys: limitedKeys, user_key: userKey, }; const response = await RequestUtils_1.default.request.call(this, { method: 'POST', url: '/open_api/projects/detail', body: detailBody, timeout: options.timeout, }); if (response && typeof response === 'object') { return Object.values(response); } return []; }, }; exports.default = SpaceListDetailOperate; //# sourceMappingURL=SpaceListDetailOperate.js.map