n8n-nodes-base
Version:
Base nodes of n8n
93 lines • 3.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.description = void 0;
exports.execute = execute;
const utilities_1 = require("../../../../../../utils/utilities");
const interfaces_1 = require("../../helpers/interfaces");
const utils_1 = require("../../helpers/utils");
const transport_1 = require("../../transport");
const common_descriptions_1 = require("../common.descriptions");
const properties = [
{
displayName: 'Folder Name',
name: 'name',
type: 'string',
default: '',
placeholder: 'e.g. New Folder',
description: "The name of the new folder. If not set, 'Untitled' will be used.",
},
{
...common_descriptions_1.driveRLC,
displayName: 'Parent Drive',
description: 'The drive where to create the new folder',
},
{
...common_descriptions_1.folderRLC,
displayName: 'Parent Folder',
description: 'The parent folder where to create the new folder',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
options: [
{
displayName: 'Simplify Output',
name: 'simplifyOutput',
type: 'boolean',
default: true,
description: 'Whether to return a simplified version of the response instead of all fields',
},
{
displayName: 'Folder Color',
name: 'folderColorRgb',
type: 'color',
default: '',
description: 'The color of the folder as an RGB hex string. If an unsupported color is specified, the closest color in the palette will be used instead.',
},
],
},
];
const displayOptions = {
show: {
resource: ['folder'],
operation: ['create'],
},
};
exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties);
async function execute(i) {
const name = this.getNodeParameter('name', i) || 'Untitled';
const driveId = this.getNodeParameter('driveId', i, undefined, {
extractValue: true,
});
const folderId = this.getNodeParameter('folderId', i, undefined, {
extractValue: true,
});
const body = {
name,
mimeType: interfaces_1.DRIVE.FOLDER,
parents: [(0, utils_1.setParentFolder)(folderId, driveId)],
};
const folderColorRgb = this.getNodeParameter('options.folderColorRgb', i, '') || undefined;
if (folderColorRgb) {
body.folderColorRgb = folderColorRgb;
}
const simplifyOutput = this.getNodeParameter('options.simplifyOutput', i, true);
let fields;
if (!simplifyOutput) {
fields = '*';
}
const qs = {
fields,
includeItemsFromAllDrives: true,
supportsAllDrives: true,
spaces: 'appDataFolder, drive',
corpora: 'allDrives',
};
const response = await transport_1.googleApiRequest.call(this, 'POST', '/drive/v3/files', body, qs);
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } });
return executionData;
}
//# sourceMappingURL=create.operation.js.map