UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

60 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.description = void 0; exports.execute = execute; const utilities_1 = require("../../../../../../utils/utilities"); const utils_1 = require("../../helpers/utils"); const transport_1 = require("../../transport"); const common_descriptions_1 = require("../common.descriptions"); const properties = [ { ...common_descriptions_1.fileRLC, description: 'The file to move', }, { ...common_descriptions_1.driveRLC, displayName: 'Parent Drive', description: 'The drive where to move the file', }, { ...common_descriptions_1.folderRLC, displayName: 'Parent Folder', description: 'The folder where to move the file', }, ]; const displayOptions = { show: { resource: ['file'], operation: ['move'], }, }; exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties); async function execute(i) { const fileId = this.getNodeParameter('fileId', i, undefined, { extractValue: true, }); const driveId = this.getNodeParameter('driveId', i, undefined, { extractValue: true, }); const folderId = this.getNodeParameter('folderId', i, undefined, { extractValue: true, }); const qs = { includeItemsFromAllDrives: true, supportsAllDrives: true, spaces: 'appDataFolder, drive', corpora: 'allDrives', }; const { parents } = await transport_1.googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}`, undefined, { ...qs, fields: 'parents', }); const response = await transport_1.googleApiRequest.call(this, 'PATCH', `/drive/v3/files/${fileId}`, undefined, { ...qs, addParents: (0, utils_1.setParentFolder)(folderId, driveId), removeParents: (parents || []).join(','), }); const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } }); return executionData; } //# sourceMappingURL=move.operation.js.map