UNPKG

@solinker/nodes-baidu-wangpan

Version:

百度网盘是百度为用户精心打造的云存储产品,已覆盖主流PC和手机操作系统,包含Web版、Windows版、Mac版、Android版等不同版本,免费提供2T超大存储空间,用户将可以轻松将自己的文件上传到网盘上,并可跨端随时随地查看和分享。

189 lines 6.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaiduWangpanV1 = void 0; const n8n_workflow_1 = require("n8n-workflow"); const descriptionV1 = { defaults: { name: '百度网盘', }, displayName: '百度网盘', description: '百度网盘', name: 'baiduWangpan', inputs: ["main"], outputs: ['main'], group: ['group'], version: 1, credentials: [{ name: 'baiduWangpanOAuth2Api', required: true }], properties: [ { displayName: 'Operation', name: 'operation', type: 'options', options: [ { displayName: '获取文件列表', name: '获取文件列表', value: 'queryFileList', action: '获取文件列表', }, ], default: 'queryFileList', noDataExpression: true, }, { displayName: '目录路径', name: 'dir', type: 'string', default: '', description: '以/开头的绝对路径, 默认为/', displayOptions: { show: { operation: ['queryFileList'], }, }, }, { displayName: '操作类型', name: 'opera', type: 'options', default: 'copy', displayOptions: { show: { operation: ['managerFile'], }, }, options: [ { displayName: '复制', name: '复制', value: 'copy', }, { displayName: '重命名', name: '重命名', value: 'rename', }, { displayName: '删除', name: '删除', value: 'delete', }, { displayName: '移动', name: '移动', value: 'move', }, ], }, { displayName: '执行方式', name: 'async', type: 'options', default: 0, displayOptions: { show: { operation: ['managerFile'], }, }, options: [ { displayName: '同步', name: '同步', value: 0, }, { displayName: '自适应', name: '自适应', value: 1, }, { displayName: '异步', name: '异步', value: 2, }, ], }, { displayName: '选择的文件', name: 'fsids', type: 'options', default: '', description: '选择的文件,可多选', displayOptions: { show: { operation: ['queryFileDetail'], }, }, typeOptions: { loadOptionsMethod: 'queryFileList', }, }, ], }; class BaiduWangpanV1 { constructor(baseDescription) { this.methods = { loadOptions: { async queryFileList() { var _a; const credentials = (await this.getCredentials('baiduWangpanOAuth2Api')); const parameters = {}; Object.keys(this.getNode().parameters).forEach((key) => { parameters[key] = this.getNodeParameter(key); }); return this.helpers.httpRequest({ baseURL: `${(_a = process.env.N8N_STORE_API_URL) !== null && _a !== void 0 ? _a : 'https://api.n8n.store'}/api/baidu-wangpan`, url: '/operation', method: 'POST', body: { ...parameters, operation: 'queryFileList', credentials, }, headers: { 'X-Instance-Id': this.getInstanceId(), }, }); }, }, }; this.description = { ...baseDescription, ...descriptionV1, }; } async execute() { var _a; const returnData = []; const credentials = await this.getCredentials('baiduWangpanOAuth2Api'); const items = this.getInputData(); for (let index = 0; index < items.length; index++) { const parameters = {}; Object.keys(this.getNode().parameters).forEach((key) => { parameters[key] = this.getNodeParameter(key, index); }); try { returnData.push({ json: await this.helpers.httpRequest({ baseURL: `${(_a = process.env.N8N_STORE_API_URL) !== null && _a !== void 0 ? _a : 'https://api.n8n.store'}/api/baidu-wangpan`, url: '/operation', method: 'POST', body: { ...parameters, credentials, }, headers: { 'X-Instance-Id': this.getInstanceId(), }, }), }); } catch (error) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, { itemIndex: index }); } } return this.prepareOutputData(returnData); } } exports.BaiduWangpanV1 = BaiduWangpanV1; //# sourceMappingURL=BaiduWangpanV1.js.map