n8n-nodes-base
Version:
Base nodes of n8n
57 lines • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.description = void 0;
exports.execute = execute;
const utilities_1 = require("../../../../../../utils/utilities");
const transport_1 = require("../../transport");
const common_descriptions_1 = require("../common.descriptions");
const properties = [
{
...common_descriptions_1.fileRLC,
description: 'The file to delete',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
options: [
{
displayName: 'Delete Permanently',
name: 'deletePermanently',
type: 'boolean',
default: false,
description: 'Whether to delete the file immediately. If false, the file will be moved to the trash.',
},
],
},
];
const displayOptions = {
show: {
resource: ['file'],
operation: ['deleteFile'],
},
};
exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties);
async function execute(i) {
const fileId = this.getNodeParameter('fileId', i, undefined, {
extractValue: true,
});
const deletePermanently = this.getNodeParameter('options.deletePermanently', i, false);
const qs = {
supportsAllDrives: true,
};
if (deletePermanently) {
await transport_1.googleApiRequest.call(this, 'DELETE', `/drive/v3/files/${fileId}`, undefined, qs);
}
else {
await transport_1.googleApiRequest.call(this, 'PATCH', `/drive/v3/files/${fileId}`, { trashed: true }, qs);
}
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({
id: fileId,
success: true,
}), { itemData: { item: i } });
return executionData;
}
//# sourceMappingURL=deleteFile.operation.js.map