2022-01-03 13:42:42 -08:00
import { IExecuteFunctions } from 'n8n-core' ;
2020-06-06 11:57:42 -07:00
2019-10-27 13:44:21 -07:00
import {
IDataObject ,
INodeExecutionData ,
INodeType ,
2020-10-01 05:01:39 -07:00
INodeTypeDescription ,
2021-04-16 09:33:36 -07:00
NodeOperationError ,
2019-10-27 13:44:21 -07:00
} from 'n8n-workflow' ;
2020-06-06 11:57:42 -07:00
import {
googleApiRequest ,
2021-01-19 09:02:52 -08:00
googleApiRequestAllItems ,
2020-06-06 11:57:42 -07:00
} from './GenericFunctions' ;
2019-10-27 13:44:21 -07:00
2021-06-13 10:17:39 -07:00
import { v4 as uuid } from 'uuid' ;
2021-02-15 00:02:47 -08:00
2019-10-27 13:44:21 -07:00
export class GoogleDrive implements INodeType {
description : INodeTypeDescription = {
displayName : 'Google Drive' ,
name : 'googleDrive' ,
2021-01-19 09:02:52 -08:00
icon : 'file:googleDrive.svg' ,
2019-10-27 13:44:21 -07:00
group : [ 'input' ] ,
version : 1 ,
subtitle : '={{$parameter["operation"] + ": " + $parameter["resource"]}}' ,
description : 'Access data on Google Drive' ,
defaults : {
name : 'Google Drive' ,
} ,
inputs : [ 'main' ] ,
outputs : [ 'main' ] ,
credentials : [
{
name : 'googleApi' ,
required : true ,
2020-06-06 11:57:42 -07:00
displayOptions : {
show : {
authentication : [
'serviceAccount' ,
] ,
} ,
} ,
} ,
{
name : 'googleDriveOAuth2Api' ,
required : true ,
displayOptions : {
show : {
authentication : [
'oAuth2' ,
] ,
} ,
} ,
} ,
2019-10-27 13:44:21 -07:00
] ,
properties : [
2020-06-06 11:57:42 -07:00
{
displayName : 'Authentication' ,
name : 'authentication' ,
type : 'options' ,
options : [
{
name : 'Service Account' ,
value : 'serviceAccount' ,
} ,
{
name : 'OAuth2' ,
value : 'oAuth2' ,
} ,
] ,
default : 'serviceAccount' ,
} ,
2019-10-27 13:44:21 -07:00
{
displayName : 'Resource' ,
name : 'resource' ,
type : 'options' ,
options : [
2021-01-19 09:02:52 -08:00
{
name : 'Drive' ,
value : 'drive' ,
} ,
2019-10-27 13:44:21 -07:00
{
name : 'File' ,
value : 'file' ,
} ,
{
name : 'Folder' ,
value : 'folder' ,
} ,
] ,
default : 'file' ,
description : 'The resource to operate on.' ,
} ,
// ----------------------------------
// operations
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'file' ,
] ,
} ,
} ,
options : [
2019-12-13 09:04:01 -08:00
{
name : 'Copy' ,
value : 'copy' ,
description : 'Copy a file' ,
} ,
2019-10-27 13:44:21 -07:00
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a file' ,
} ,
{
name : 'Download' ,
value : 'download' ,
description : 'Download a file' ,
} ,
{
name : 'List' ,
value : 'list' ,
2020-07-24 03:56:41 -07:00
description : 'List files and folders' ,
2019-10-27 13:44:21 -07:00
} ,
2020-09-18 00:50:54 -07:00
{
name : 'Share' ,
value : 'share' ,
description : 'Share a file' ,
} ,
2021-03-12 02:24:40 -08:00
{
name : 'Update' ,
value : 'update' ,
description : 'Update a file' ,
} ,
2019-10-27 13:44:21 -07:00
{
name : 'Upload' ,
value : 'upload' ,
description : 'Upload a file' ,
} ,
] ,
default : 'upload' ,
description : 'The operation to perform.' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'folder' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a folder' ,
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a folder' ,
} ,
2020-09-18 00:50:54 -07:00
{
name : 'Share' ,
value : 'share' ,
description : 'Share a folder' ,
} ,
2019-10-27 13:44:21 -07:00
] ,
default : 'create' ,
description : 'The operation to perform.' ,
} ,
// ----------------------------------
// file
// ----------------------------------
2019-12-13 09:04:01 -08:00
// ----------------------------------
// file:copy
// ----------------------------------
{
displayName : 'ID' ,
name : 'fileId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'copy' ,
2019-12-13 09:04:01 -08:00
] ,
resource : [
'file' ,
] ,
} ,
} ,
description : 'The ID of the file to copy.' ,
} ,
2019-10-27 13:44:21 -07:00
// ----------------------------------
// file/folder:delete
// ----------------------------------
{
displayName : 'ID' ,
name : 'fileId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'delete' ,
2019-10-27 13:44:21 -07:00
] ,
resource : [
'file' ,
'folder' ,
] ,
} ,
} ,
description : 'The ID of the file/folder to delete.' ,
} ,
// ----------------------------------
// file:download
// ----------------------------------
{
2021-12-21 14:36:37 -08:00
displayName : 'File ID' ,
2019-10-27 13:44:21 -07:00
name : 'fileId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'download' ,
2019-10-27 13:44:21 -07:00
] ,
resource : [
'file' ,
] ,
} ,
} ,
description : 'The ID of the file to download.' ,
} ,
{
displayName : 'Binary Property' ,
name : 'binaryPropertyName' ,
type : 'string' ,
required : true ,
default : 'data' ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'download' ,
2019-10-27 13:44:21 -07:00
] ,
resource : [
'file' ,
] ,
} ,
} ,
2021-10-27 13:00:13 -07:00
description : 'Name of the binary property to which to write the data of the read file.' ,
2019-10-27 13:44:21 -07:00
} ,
2021-04-30 13:29:10 -07:00
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'download' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
options : [
2021-12-21 14:36:37 -08:00
{
displayName : 'Google File Conversion' ,
name : 'googleFileConversion' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : false ,
} ,
default : { } ,
placeholder : 'Add Conversion' ,
options : [
{
displayName : 'Conversion' ,
name : 'conversion' ,
values : [
{
displayName : 'Google Docs' ,
name : 'docsToFormat' ,
type : 'options' ,
options : [
{
name : 'To MS Word' ,
value : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ,
} ,
{
name : 'To PDF' ,
value : 'application/pdf' ,
} ,
{
name : 'To OpenOffice Doc' ,
value : 'application/vnd.oasis.opendocument.text' ,
} ,
{
name : 'To HTML' ,
value : 'text/html' ,
} ,
{
name : 'To Rich Text' ,
value : 'application/rtf' ,
} ,
] ,
default : 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ,
description : 'Format used to export when downloading Google Docs files' ,
} ,
{
displayName : 'Google Drawings' ,
name : 'drawingsToFormat' ,
type : 'options' ,
options : [
{
name : 'To JPEG' ,
value : 'image/jpeg' ,
} ,
{
name : 'To PNG' ,
value : 'image/png' ,
} ,
{
name : 'To SVG' ,
value : 'image/svg+xml' ,
} ,
{
name : 'To PDF' ,
value : 'application/pdf' ,
} ,
] ,
default : 'image/jpeg' ,
description : 'Format used to export when downloading Google Drawings files' ,
} ,
{
displayName : 'Google Slides' ,
name : 'slidesToFormat' ,
type : 'options' ,
options : [
{
name : 'To MS PowerPoint' ,
value : 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ,
} ,
{
name : 'To PDF' ,
value : 'application/pdf' ,
} ,
{
name : 'To OpenOffice Presentation' ,
value : 'application/vnd.oasis.opendocument.presentation' ,
} ,
{
name : 'To Plain Text' ,
value : 'text/plain' ,
} ,
] ,
default : 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ,
description : 'Format used to export when downloading Google Slides files' ,
} ,
{
displayName : 'Google Sheets' ,
name : 'sheetsToFormat' ,
type : 'options' ,
options : [
{
name : 'To MS Excel' ,
value : 'application/x-vnd.oasis.opendocument.spreadsheet' ,
} ,
{
name : 'To PDF' ,
value : 'application/pdf' ,
} ,
{
name : 'To CSV' ,
value : 'text/csv' ,
} ,
] ,
default : 'application/x-vnd.oasis.opendocument.spreadsheet' ,
description : 'Format used to export when downloading Google Spreadsheets files' ,
} ,
] ,
} ,
] ,
} ,
2021-04-30 13:29:10 -07:00
{
displayName : 'File Name' ,
name : 'fileName' ,
type : 'string' ,
default : '' ,
description : 'File name. Ex: data.pdf' ,
} ,
] ,
} ,
2019-10-27 13:44:21 -07:00
// ----------------------------------
// file:list
// ----------------------------------
{
displayName : 'Use Query String' ,
name : 'useQueryString' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'list' ,
2019-10-27 13:44:21 -07:00
] ,
resource : [
'file' ,
] ,
} ,
} ,
description : 'If a query string should be used to filter results.' ,
} ,
{
displayName : 'Query String' ,
name : 'queryString' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
operation : [
'list' ,
] ,
useQueryString : [
true ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
placeholder : 'name contains \'invoice\'' ,
description : 'Query to use to return only specific files.' ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'list' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 1000 ,
} ,
default : 100 ,
description : 'How many files to return.' ,
} ,
{
displayName : 'Filters' ,
name : 'queryFilters' ,
placeholder : 'Add Filter' ,
description : 'Filters to use to return only specific files.' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
displayOptions : {
show : {
operation : [
'list' ,
] ,
useQueryString : [
false ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
options : [
{
name : 'name' ,
displayName : 'Name' ,
values : [
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
options : [
{
name : 'Contains' ,
2020-10-22 06:46:03 -07:00
value : 'contains' ,
2019-10-27 13:44:21 -07:00
} ,
{
name : 'Is' ,
2020-10-22 06:46:03 -07:00
value : 'is' ,
2019-10-27 13:44:21 -07:00
} ,
{
name : 'Is Not' ,
2020-10-22 06:46:03 -07:00
value : 'isNot' ,
2019-10-27 13:44:21 -07:00
} ,
] ,
default : 'contains' ,
description : 'Operation to perform.' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
description : 'The value for operation.' ,
} ,
2020-10-22 06:46:03 -07:00
] ,
2019-10-27 13:44:21 -07:00
} ,
{
name : 'mimeType' ,
displayName : 'Mime Type' ,
values : [
{
displayName : 'Mime Type' ,
name : 'mimeType' ,
type : 'options' ,
options : [
{
name : 'Custom Mime Type' ,
value : 'custom' ,
} ,
{
name : ' 3rd party shortcut' ,
value : 'application/vnd.google-apps.drive-sdk' ,
} ,
{
name : 'Audio' ,
value : 'application/vnd.google-apps.audio' ,
} ,
{
name : 'Google Apps Scripts' ,
value : 'application/vnd.google-apps.script' ,
} ,
{
name : 'Google Docs' ,
value : 'application/vnd.google-apps.document' ,
} ,
{
name : 'Google Drawing' ,
value : 'application/vnd.google-apps.drawing' ,
} ,
{
name : 'Google Drive file' ,
value : 'application/vnd.google-apps.file' ,
} ,
{
name : 'Google Drive folder' ,
value : 'application/vnd.google-apps.folder' ,
} ,
{
name : 'Google Forms' ,
value : 'application/vnd.google-apps.form' ,
} ,
{
name : 'Google Fusion Tables' ,
value : 'application/vnd.google-apps.fusiontable' ,
} ,
{
name : 'Google My Maps' ,
value : 'application/vnd.google-apps.map' ,
} ,
{
name : 'Google Sheets' ,
value : 'application/vnd.google-apps.spreadsheet' ,
} ,
{
name : 'Google Sites' ,
value : 'application/vnd.google-apps.site' ,
} ,
{
name : 'Google Slides' ,
value : 'application/vnd.google-apps.presentation' ,
} ,
{
name : 'Photo' ,
value : 'application/vnd.google-apps.photo' ,
} ,
{
name : 'Unknown' ,
value : 'application/vnd.google-apps.unknown' ,
} ,
{
name : 'Video' ,
value : 'application/vnd.google-apps.video' ,
} ,
] ,
default : 'application/vnd.google-apps.file' ,
description : 'The Mime-Type of the files to return.' ,
} ,
{
displayName : 'Custom Mime Type' ,
name : 'customMimeType' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
mimeType : [
'custom' ,
] ,
} ,
} ,
description : 'Custom Mime Type' ,
} ,
2020-10-22 06:46:03 -07:00
] ,
} ,
2019-10-27 13:44:21 -07:00
] ,
} ,
2020-09-18 00:50:54 -07:00
// ----------------------------------
// file:share
// ----------------------------------
{
displayName : 'File ID' ,
name : 'fileId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
resource : [
'file' ,
'folder' ,
] ,
} ,
} ,
description : 'The ID of the file or shared drive.' ,
} ,
{
displayName : 'Permissions' ,
name : 'permissionsUi' ,
placeholder : 'Add Permission' ,
type : 'fixedCollection' ,
2021-03-02 03:54:42 -08:00
default : { } ,
2020-09-18 00:50:54 -07:00
typeOptions : {
multipleValues : false ,
} ,
displayOptions : {
show : {
resource : [
'file' ,
2021-02-06 07:12:30 -08:00
'folder' ,
2020-09-18 00:50:54 -07:00
] ,
operation : [
'share' ,
] ,
} ,
} ,
options : [
{
displayName : 'Permission' ,
name : 'permissionsValues' ,
values : [
{
displayName : 'Role' ,
name : 'role' ,
type : 'options' ,
options : [
{
name : 'Owner' ,
value : 'owner' ,
} ,
{
name : 'Organizer' ,
value : 'organizer' ,
} ,
{
name : 'File Organizer' ,
value : 'fileOrganizer' ,
} ,
{
name : 'Writer' ,
value : 'writer' ,
} ,
{
name : 'Commenter' ,
value : 'commenter' ,
} ,
{
name : 'Reader' ,
value : 'reader' ,
} ,
] ,
default : '' ,
} ,
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'User' ,
value : 'user' ,
} ,
{
name : 'Group' ,
value : 'group' ,
} ,
{
name : 'Domain' ,
value : 'domain' ,
} ,
{
2020-09-18 00:57:05 -07:00
name : 'Anyone' ,
2020-09-18 00:50:54 -07:00
value : 'anyone' ,
} ,
] ,
default : '' ,
2021-08-26 10:42:38 -07:00
description : 'Information about the different types can be found <a href="https://developers.google.com/drive/api/v3/ref-roles">here</a>.' ,
2020-09-18 00:50:54 -07:00
} ,
{
displayName : 'Email Address' ,
name : 'emailAddress' ,
type : 'string' ,
displayOptions : {
show : {
type : [
'user' ,
'group' ,
] ,
} ,
} ,
default : '' ,
description : 'The email address of the user or group to which this permission refers' ,
} ,
{
displayName : 'Domain' ,
name : 'domain' ,
type : 'string' ,
displayOptions : {
show : {
type : [
'domain' ,
] ,
} ,
} ,
default : '' ,
description : 'The domain to which this permission refers' ,
} ,
{
displayName : 'Allow File Discovery' ,
name : 'allowFileDiscovery' ,
type : 'boolean' ,
displayOptions : {
show : {
type : [
'domain' ,
'anyone' ,
] ,
} ,
} ,
default : false ,
description : 'Whether the permission allows the file to be discovered through search' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Binary Data' ,
name : 'binaryData' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'upload' ,
2020-09-18 00:50:54 -07:00
] ,
resource : [
'file' ,
] ,
} ,
} ,
description : 'If the data to upload should be taken from binary field.' ,
} ,
{
displayName : 'File Content' ,
name : 'fileContent' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'upload' ,
2020-09-18 00:50:54 -07:00
] ,
resource : [
'file' ,
] ,
binaryData : [
2020-10-22 06:46:03 -07:00
false ,
2020-09-18 00:50:54 -07:00
] ,
} ,
} ,
placeholder : '' ,
description : 'The text content of the file to upload.' ,
} ,
{
displayName : 'Binary Property' ,
name : 'binaryPropertyName' ,
type : 'string' ,
default : 'data' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'upload' ,
2020-09-18 00:50:54 -07:00
] ,
resource : [
'file' ,
] ,
binaryData : [
2020-10-22 06:46:03 -07:00
true ,
2020-09-18 00:50:54 -07:00
] ,
} ,
} ,
placeholder : '' ,
2021-10-27 13:00:13 -07:00
description : 'Name of the binary property which contains the data for the file to be uploaded.' ,
2020-09-18 00:50:54 -07:00
} ,
2021-06-08 20:34:11 -07:00
2021-03-12 02:24:40 -08:00
// ----------------------------------
// file:update
// ----------------------------------
{
displayName : 'ID' ,
name : 'fileId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
'update' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
description : 'The ID of the file to update.' ,
} ,
{
displayName : 'Update Fields' ,
name : 'updateFields' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'update' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
options : [
2021-08-11 10:48:31 -07:00
{
displayName : 'File Name' ,
name : 'fileName' ,
type : 'string' ,
default : '' ,
description : ` The name of the file ` ,
} ,
2021-03-12 02:24:40 -08:00
{
displayName : 'Keep Revision Forever' ,
name : 'keepRevisionForever' ,
type : 'boolean' ,
default : false ,
2021-11-25 09:10:06 -08:00
description : ` Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions. ` ,
2021-03-12 02:24:40 -08:00
} ,
{
displayName : 'OCR Language' ,
name : 'ocrLanguage' ,
type : 'string' ,
default : '' ,
description : ` A language hint for OCR processing during image import (ISO 639-1 code). ` ,
} ,
{
displayName : 'Parent ID' ,
name : 'parentId' ,
type : 'string' ,
default : '' ,
description : ` The ID of the parent to set. ` ,
} ,
{
displayName : 'Use Content As Indexable Text' ,
name : 'useContentAsIndexableText' ,
type : 'boolean' ,
default : false ,
description : ` Whether to use the uploaded content as indexable text. ` ,
} ,
] ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'update' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
options : [
{
displayName : 'Fields' ,
name : 'fields' ,
type : 'multiOptions' ,
options : [
{
name : '*' ,
value : '*' ,
description : 'All fields.' ,
} ,
{
name : 'explicitlyTrashed' ,
value : 'explicitlyTrashed' ,
} ,
{
name : 'exportLinks' ,
value : 'exportLinks' ,
} ,
{
name : 'iconLink' ,
value : 'iconLink' ,
} ,
{
name : 'hasThumbnail' ,
value : 'hasThumbnail' ,
} ,
{
name : 'id' ,
value : 'id' ,
} ,
{
name : 'kind' ,
value : 'kind' ,
} ,
{
name : 'name' ,
value : 'name' ,
} ,
{
name : 'mimeType' ,
value : 'mimeType' ,
} ,
{
name : 'permissions' ,
value : 'permissions' ,
} ,
{
name : 'shared' ,
value : 'shared' ,
} ,
{
name : 'spaces' ,
value : 'spaces' ,
} ,
{
name : 'starred' ,
value : 'starred' ,
} ,
{
name : 'thumbnailLink' ,
value : 'thumbnailLink' ,
} ,
{
name : 'trashed' ,
value : 'trashed' ,
} ,
{
name : 'version' ,
value : 'version' ,
} ,
{
name : 'webViewLink' ,
value : 'webViewLink' ,
} ,
] ,
required : true ,
default : [ ] ,
description : 'The fields to return.' ,
} ,
] ,
} ,
2019-10-27 13:44:21 -07:00
// ----------------------------------
// file:upload
// ----------------------------------
{
displayName : 'File Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'upload' ,
2019-10-27 13:44:21 -07:00
] ,
resource : [
'file' ,
] ,
} ,
} ,
placeholder : 'invoice_1.pdf' ,
description : 'The name the file should be saved as.' ,
} ,
2021-02-15 00:02:47 -08:00
// ----------------------------------
{
displayName : 'Resolve Data' ,
name : 'resolveData' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
operation : [
'upload' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
2021-11-25 09:10:06 -08:00
description : 'By default the response only contain the ID of the file. If this option gets activated, it will resolve the data automatically.' ,
2021-02-15 00:02:47 -08:00
} ,
2019-10-27 13:44:21 -07:00
{
displayName : 'Parents' ,
name : 'parents' ,
type : 'string' ,
typeOptions : {
multipleValues : true ,
} ,
default : [ ] ,
displayOptions : {
show : {
operation : [
'upload' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
description : 'The IDs of the parent folders which contain the file.' ,
} ,
// ----------------------------------
// folder
// ----------------------------------
// ----------------------------------
// folder:create
// ----------------------------------
{
displayName : 'Folder' ,
name : 'name' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
operation : [
2020-10-22 06:46:03 -07:00
'create' ,
2019-10-27 13:44:21 -07:00
] ,
resource : [
'folder' ,
] ,
} ,
} ,
placeholder : 'invoices' ,
description : 'The name of folder to create.' ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
2021-01-19 09:02:52 -08:00
displayOptions : {
2021-02-15 00:02:47 -08:00
show : {
'/operation' : [
'copy' ,
'list' ,
'share' ,
2021-02-24 14:33:06 -08:00
'create' ,
2021-02-15 00:02:47 -08:00
] ,
'/resource' : [
'file' ,
'folder' ,
2021-01-19 09:02:52 -08:00
] ,
} ,
} ,
2019-10-27 13:44:21 -07:00
options : [
2020-09-18 00:50:54 -07:00
{
displayName : 'Email Message' ,
name : 'emailMessage' ,
type : 'string' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
default : '' ,
description : 'A plain text custom message to include in the notification email.' ,
} ,
{
displayName : 'Enforce Single Parent' ,
name : 'enforceSingleParent' ,
type : 'boolean' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
default : false ,
2021-11-25 09:10:06 -08:00
description : ` Set to true to opt in to API behavior that aims for all items to have exactly one parent. This parameter only takes effect if the item is not in a shared drive. ` ,
2020-09-18 00:50:54 -07:00
} ,
2019-10-27 13:44:21 -07:00
{
displayName : 'Fields' ,
name : 'fields' ,
type : 'multiOptions' ,
2020-09-18 00:50:54 -07:00
displayOptions : {
show : {
'/operation' : [
2021-02-15 00:02:47 -08:00
'list' ,
'copy' ,
2020-09-18 00:50:54 -07:00
] ,
} ,
} ,
2019-10-27 13:44:21 -07:00
options : [
{
name : '*' ,
value : '*' ,
description : 'All fields.' ,
} ,
{
name : 'explicitlyTrashed' ,
value : 'explicitlyTrashed' ,
} ,
{
name : 'exportLinks' ,
value : 'exportLinks' ,
} ,
{
name : 'iconLink' ,
value : 'iconLink' ,
} ,
{
name : 'hasThumbnail' ,
value : 'hasThumbnail' ,
} ,
{
name : 'id' ,
value : 'id' ,
} ,
{
name : 'kind' ,
value : 'kind' ,
} ,
{
name : 'name' ,
value : 'name' ,
} ,
{
name : 'mimeType' ,
value : 'mimeType' ,
} ,
{
name : 'permissions' ,
value : 'permissions' ,
} ,
{
name : 'shared' ,
value : 'shared' ,
} ,
{
name : 'spaces' ,
value : 'spaces' ,
} ,
{
name : 'starred' ,
value : 'starred' ,
} ,
{
name : 'thumbnailLink' ,
value : 'thumbnailLink' ,
} ,
{
name : 'trashed' ,
value : 'trashed' ,
} ,
{
name : 'version' ,
value : 'version' ,
} ,
{
name : 'webViewLink' ,
value : 'webViewLink' ,
} ,
] ,
required : true ,
default : [ ] ,
description : 'The fields to return.' ,
} ,
2020-09-18 00:50:54 -07:00
{
displayName : 'Move To New Owners Root' ,
name : 'moveToNewOwnersRoot' ,
type : 'boolean' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
default : '' ,
2021-11-25 09:10:06 -08:00
description : ` <p>This parameter only takes effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item.</p><p>When set to true, the item is moved to the new owner's My Drive root folder and all prior parents removed.</p> ` ,
2020-09-18 00:50:54 -07:00
} ,
{
displayName : 'Send Notification Email' ,
name : 'sendNotificationEmail' ,
type : 'boolean' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
2021-01-23 06:22:31 -08:00
default : false ,
2020-09-18 00:50:54 -07:00
description : 'Whether to send a notification email when sharing to users or groups' ,
} ,
{
displayName : 'Supports All Drives' ,
name : 'supportsAllDrives' ,
type : 'boolean' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
default : false ,
description : 'Whether the requesting application supports both My Drives and shared drives' ,
} ,
{
displayName : 'Transfer Ownership' ,
name : 'transferOwnership' ,
type : 'boolean' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
default : false ,
description : 'Whether to transfer ownership to the specified user and downgrade the current owner to a writer.' ,
} ,
{
displayName : 'Use Domain Admin Access' ,
name : 'useDomainAdminAccess' ,
type : 'boolean' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'share' ,
2020-09-18 00:50:54 -07:00
] ,
'/resource' : [
'file' ,
'folder' ,
] ,
} ,
} ,
default : false ,
2021-01-19 09:02:52 -08:00
description : ` Perform the operation as domain administrator, i.e. if you are an administrator of the domain to which the shared drive belongs, you will be granted access automatically ` ,
2020-09-18 00:50:54 -07:00
} ,
2019-12-13 09:04:01 -08:00
{
displayName : 'File Name' ,
name : 'name' ,
type : 'string' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'copy' ,
2019-12-13 09:04:01 -08:00
] ,
'/resource' : [
'file' ,
] ,
} ,
} ,
default : '' ,
placeholder : 'invoice_1.pdf' ,
description : 'The name the file should be saved as.' ,
} ,
{
displayName : 'Parents' ,
name : 'parents' ,
type : 'string' ,
displayOptions : {
show : {
'/operation' : [
2020-01-29 13:07:53 -08:00
'copy' ,
'create' ,
2019-12-13 09:04:01 -08:00
] ,
'/resource' : [
'file' ,
2020-01-29 13:07:53 -08:00
'folder' ,
2019-12-13 09:04:01 -08:00
] ,
} ,
} ,
typeOptions : {
multipleValues : true ,
} ,
default : [ ] ,
2020-01-29 13:07:53 -08:00
description : 'The IDs of the parent folders the file/folder should be saved in.' ,
2019-12-13 09:04:01 -08:00
} ,
2019-10-27 13:44:21 -07:00
{
displayName : 'Spaces' ,
name : 'spaces' ,
type : 'multiOptions' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'list' ,
2019-10-27 13:44:21 -07:00
] ,
'/resource' : [
'file' ,
] ,
} ,
} ,
options : [
{
name : '*' ,
value : '*' ,
description : 'All spaces.' ,
} ,
{
name : 'appDataFolder' ,
value : 'appDataFolder' ,
} ,
{
name : 'drive' ,
value : 'drive' ,
} ,
{
name : 'photos' ,
value : 'photos' ,
} ,
] ,
required : true ,
default : [ ] ,
description : 'The spaces to operate on.' ,
} ,
2019-12-05 07:21:14 -08:00
{
displayName : 'Corpora' ,
name : 'corpora' ,
type : 'options' ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'list' ,
2019-12-05 07:21:14 -08:00
] ,
'/resource' : [
'file' ,
] ,
} ,
} ,
options : [
{
name : 'user' ,
value : 'user' ,
description : 'All files in "My Drive" and "Shared with me"' ,
} ,
{
name : 'domain' ,
value : 'domain' ,
2020-06-13 04:47:49 -07:00
description : 'All files shared to the user\'s domain that are searchable' ,
2019-12-05 07:21:14 -08:00
} ,
{
name : 'drive' ,
value : 'drive' ,
description : 'All files contained in a single shared drive' ,
} ,
{
name : 'allDrives' ,
value : 'allDrives' ,
description : 'All drives' ,
} ,
] ,
required : true ,
2020-01-04 20:19:10 -08:00
default : '' ,
2019-12-05 07:21:14 -08:00
description : 'The corpora to operate on.' ,
} ,
{
2021-01-19 09:02:52 -08:00
displayName : 'Drive ID' ,
2019-12-05 07:21:14 -08:00
name : 'driveId' ,
type : 'string' ,
default : '' ,
required : false ,
displayOptions : {
show : {
'/operation' : [
2020-10-22 06:46:03 -07:00
'list' ,
2019-12-05 07:21:14 -08:00
] ,
'/resource' : [
'file' ,
] ,
corpora : [
2020-10-22 06:46:03 -07:00
'drive' ,
] ,
2019-12-05 07:21:14 -08:00
} ,
} ,
description : 'ID of the shared drive to search. The driveId parameter must be specified if and only if corpora is set to drive.' ,
} ,
2019-10-27 13:44:21 -07:00
] ,
} ,
2021-01-19 09:02:52 -08:00
// ----------------------------------
// drive
// ----------------------------------
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'drive' ,
] ,
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
description : 'Create a drive' ,
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a drive' ,
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a drive' ,
} ,
{
name : 'List' ,
value : 'list' ,
description : 'List all drives' ,
} ,
{
name : 'Update' ,
value : 'update' ,
description : 'Update a drive' ,
} ,
] ,
default : 'create' ,
description : 'The operation to perform.' ,
} ,
// ----------------------------------
// drive:create
// ----------------------------------
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
required : false ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
description : 'The name of this shared drive.' ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'create' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
options : [
{
displayName : 'Capabilities' ,
name : 'capabilities' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
options : [
{
displayName : 'Can Add Children' ,
name : 'canAddChildren' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can add children to folders in this shared drive. ` ,
} ,
{
displayName : 'Can Change Copy Requires Writer Permission Restriction' ,
name : 'canChangeCopyRequiresWriterPermissionRestriction' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can change the copyRequiresWriterPermission restriction of this shared drive. ` ,
} ,
{
displayName : 'Can Change Domain Users Only Restriction' ,
name : 'canChangeDomainUsersOnlyRestriction' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can change the domainUsersOnly restriction of this shared drive. ` ,
} ,
{
displayName : 'Can Change Drive Background' ,
name : 'canChangeDriveBackground' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can change the background of this shared drive. ` ,
} ,
{
displayName : 'Can Change Drive Members Only Restriction' ,
name : 'canChangeDriveMembersOnlyRestriction' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can change the driveMembersOnly restriction of this shared drive. ` ,
} ,
{
displayName : 'Can Comment' ,
name : 'canComment' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can comment on files in this shared drive. ` ,
} ,
{
displayName : 'Can Copy' ,
name : 'canCopy' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can copy files in this shared drive. ` ,
} ,
{
displayName : 'Can Delete Children' ,
name : 'canDeleteChildren' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can delete children from folders in this shared drive. ` ,
} ,
{
displayName : 'Can Delete Drive' ,
name : 'canDeleteDrive' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can delete this shared drive. Attempting to delete the shared drive may still fail if there are untrashed items inside the shared drive. ` ,
} ,
{
displayName : 'Can Download' ,
name : 'canDownload' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can download files in this shared drive. ` ,
} ,
{
displayName : 'Can Edit' ,
name : 'canEdit' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can edit files in this shared drive ` ,
} ,
{
displayName : 'Can List Children' ,
name : 'canListChildren' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can list the children of folders in this shared drive. ` ,
} ,
{
displayName : 'Can Manage Members' ,
name : 'canManageMembers' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can add members to this shared drive or remove them or change their role. ` ,
} ,
{
displayName : 'Can Read Revisions' ,
name : 'canReadRevisions' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can read the revisions resource of files in this shared drive. ` ,
} ,
{
displayName : 'Can Rename' ,
name : 'canRename' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can rename files or folders in this shared drive. ` ,
} ,
{
displayName : 'Can Rename Drive' ,
name : 'canRenameDrive' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can rename this shared drive. ` ,
} ,
{
displayName : 'Can Share' ,
name : 'canShare' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can rename this shared drive. ` ,
} ,
{
displayName : 'Can Trash Children' ,
name : 'canTrashChildren' ,
type : 'boolean' ,
default : false ,
description : ` Whether the current user can trash children from folders in this shared drive. ` ,
} ,
] ,
} ,
{
displayName : 'Color RGB' ,
name : 'colorRgb' ,
type : 'color' ,
default : '' ,
description : 'The color of this shared drive as an RGB hex string' ,
} ,
{
displayName : 'Created Time' ,
name : 'createdTime' ,
type : 'dateTime' ,
default : '' ,
description : 'The time at which the shared drive was created (RFC 3339 date-time).' ,
} ,
{
displayName : 'Hidden' ,
name : 'hidden' ,
type : 'boolean' ,
default : false ,
description : 'Whether the shared drive is hidden from default view.' ,
} ,
{
displayName : 'Restrictions' ,
name : 'restrictions' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
options : [
{
displayName : 'Admin Managed Restrictions' ,
name : 'adminManagedRestrictions' ,
type : 'boolean' ,
default : false ,
2021-10-27 13:00:13 -07:00
description : ` Whether the options to copy, print, or download files inside this shared drive,
should be disabled for readers and commenters . When this restriction is set to true , it will
2021-01-19 09:02:52 -08:00
override the similarly named field to true for any file inside this shared drive . ` ,
} ,
{
displayName : 'Copy Requires Writer Permission' ,
name : 'copyRequiresWriterPermission' ,
type : 'boolean' ,
default : false ,
2021-10-27 13:00:13 -07:00
description : ` Whether the options to copy, print, or download files inside this shared drive,
should be disabled for readers and commenters . When this restriction is set to true , it will
2021-01-19 09:02:52 -08:00
override the similarly named field to true for any file inside this shared drive . ` ,
} ,
{
displayName : 'Domain Users Only' ,
name : 'domainUsersOnly' ,
type : 'boolean' ,
default : false ,
2021-10-27 13:00:13 -07:00
description : ` Whether access to this shared drive and items inside this shared drive
is restricted to users of the domain to which this shared drive belongs . This restriction
2021-01-19 09:02:52 -08:00
may be overridden by other sharing policies controlled outside of this shared drive . ` ,
} ,
{
displayName : 'Drive Members Only' ,
name : 'driveMembersOnly' ,
type : 'boolean' ,
default : false ,
description : ` Whether access to items inside this shared drive is restricted to its members. ` ,
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
// drive:delete
// ----------------------------------
{
displayName : 'Drive ID' ,
name : 'driveId' ,
type : 'string' ,
default : '' ,
required : false ,
displayOptions : {
show : {
operation : [
'delete' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
description : 'The ID of the shared drive.' ,
} ,
// ----------------------------------
// drive:get
// ----------------------------------
{
displayName : 'Drive ID' ,
name : 'driveId' ,
type : 'string' ,
default : '' ,
required : false ,
displayOptions : {
show : {
operation : [
'get' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
description : 'The ID of the shared drive.' ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'get' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
options : [
{
displayName : 'Use Domain Admin Access' ,
name : 'useDomainAdminAccess' ,
type : 'boolean' ,
default : false ,
description : 'Issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs. (Default: false)' ,
} ,
] ,
} ,
// ----------------------------------
// drive:list
// ----------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'list' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
default : false ,
description : 'If all results should be returned or only up to a given limit.' ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'list' ,
] ,
resource : [
'drive' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 200 ,
} ,
default : 100 ,
description : 'How many results to return.' ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'list' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
options : [
{
displayName : 'Query' ,
name : 'q' ,
type : 'string' ,
default : '' ,
2021-08-26 10:42:38 -07:00
description : 'Query string for searching shared drives. See the <a href="https://developers.google.com/drive/api/v3/search-shareddrives">"Search for shared drives"</a> guide for supported syntax.' ,
2021-01-19 09:02:52 -08:00
} ,
{
displayName : 'Use Domain Admin Access' ,
name : 'useDomainAdminAccess' ,
type : 'boolean' ,
default : false ,
description : 'Issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs. (Default: false)' ,
} ,
] ,
} ,
// ----------------------------------
// drive:update
// ----------------------------------
{
displayName : 'Drive ID' ,
name : 'driveId' ,
type : 'string' ,
default : '' ,
required : false ,
displayOptions : {
show : {
operation : [
'update' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
description : 'The ID of the shared drive.' ,
} ,
{
displayName : 'Update Fields' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'update' ,
] ,
resource : [
'drive' ,
] ,
} ,
} ,
options : [
{
displayName : 'Color RGB' ,
name : 'colorRgb' ,
type : 'color' ,
default : '' ,
description : 'The color of this shared drive as an RGB hex string' ,
} ,
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
description : 'The name of this shared drive.' ,
} ,
{
displayName : 'Restrictions' ,
name : 'restrictions' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
options : [
{
displayName : 'Admin Managed Restrictions' ,
name : 'adminManagedRestrictions' ,
type : 'boolean' ,
default : false ,
2021-10-27 13:00:13 -07:00
description : ` Whether the options to copy, print, or download files inside this shared drive,
should be disabled for readers and commenters . When this restriction is set to true , it will
2021-01-19 09:02:52 -08:00
override the similarly named field to true for any file inside this shared drive . ` ,
} ,
{
displayName : 'Copy Requires Writer Permission' ,
name : 'copyRequiresWriterPermission' ,
type : 'boolean' ,
default : false ,
2021-10-27 13:00:13 -07:00
description : ` Whether the options to copy, print, or download files inside this shared drive,
should be disabled for readers and commenters . When this restriction is set to true , it will
2021-01-19 09:02:52 -08:00
override the similarly named field to true for any file inside this shared drive . ` ,
} ,
{
displayName : 'Domain Users Only' ,
name : 'domainUsersOnly' ,
type : 'boolean' ,
default : false ,
2021-10-27 13:00:13 -07:00
description : ` Whether access to this shared drive and items inside this shared drive
is restricted to users of the domain to which this shared drive belongs . This restriction
2021-01-19 09:02:52 -08:00
may be overridden by other sharing policies controlled outside of this shared drive . ` ,
} ,
{
displayName : 'Drive Members Only' ,
name : 'driveMembersOnly' ,
type : 'boolean' ,
default : false ,
description : ` Whether access to items inside this shared drive is restricted to its members. ` ,
} ,
] ,
} ,
] ,
} ,
2021-06-08 20:34:11 -07:00
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Option' ,
default : { } ,
displayOptions : {
show : {
operation : [
'upload' ,
] ,
resource : [
'file' ,
] ,
} ,
} ,
options : [
{
displayName : 'APP Properties' ,
name : 'appPropertiesUi' ,
placeholder : 'Add Property' ,
type : 'fixedCollection' ,
default : '' ,
typeOptions : {
multipleValues : true ,
} ,
description : 'A collection of arbitrary key-value pairs which are private to the requesting app' ,
options : [
{
name : 'appPropertyValues' ,
displayName : 'APP Property' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
description : 'Name of the key to add.' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
description : 'Value to set for the key.' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Properties' ,
name : 'propertiesUi' ,
placeholder : 'Add Property' ,
type : 'fixedCollection' ,
default : '' ,
typeOptions : {
multipleValues : true ,
} ,
description : 'A collection of arbitrary key-value pairs which are visible to all apps.' ,
options : [
{
name : 'propertyValues' ,
displayName : 'Property' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
description : 'Name of the key to add.' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
description : 'Value to set for the key.' ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
2019-10-27 13:44:21 -07:00
] ,
} ;
async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
const items = this . getInputData ( ) ;
const returnData : IDataObject [ ] = [ ] ;
const resource = this . getNodeParameter ( 'resource' , 0 ) as string ;
const operation = this . getNodeParameter ( 'operation' , 0 ) as string ;
for ( let i = 0 ; i < items . length ; i ++ ) {
2021-07-19 23:58:54 -07:00
try {
const options = this . getNodeParameter ( 'options' , i , { } ) as IDataObject ;
let queryFields = 'id, name' ;
if ( options && options . fields ) {
const fields = options . fields as string [ ] ;
if ( fields . includes ( '*' ) ) {
queryFields = '*' ;
} else {
queryFields = fields . join ( ', ' ) ;
}
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'drive' ) {
if ( operation === 'create' ) {
// ----------------------------------
// create
// ----------------------------------
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const name = this . getNodeParameter ( 'name' , i ) as string ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const body : IDataObject = {
name ,
} ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( body , options ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'POST' , ` /drive/v3/drives ` , body , { requestId : uuid ( ) } ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
}
if ( operation === 'delete' ) {
// ----------------------------------
// delete
// ----------------------------------
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const driveId = this . getNodeParameter ( 'driveId' , i ) as string ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
await googleApiRequest . call ( this , 'DELETE' , ` /drive/v3/drives/ ${ driveId } ` ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
returnData . push ( { success : true } ) ;
}
if ( operation === 'get' ) {
// ----------------------------------
// get
// ----------------------------------
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const driveId = this . getNodeParameter ( 'driveId' , i ) as string ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const qs : IDataObject = { } ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( qs , options ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/drives/ ${ driveId } ` , { } , qs ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
}
if ( operation === 'list' ) {
// ----------------------------------
// list
// ----------------------------------
const returnAll = this . getNodeParameter ( 'returnAll' , i ) as boolean ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const qs : IDataObject = { } ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
let response : IDataObject [ ] = [ ] ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( qs , options ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
if ( returnAll === true ) {
response = await googleApiRequestAllItems . call ( this , 'drives' , 'GET' , ` /drive/v3/drives ` , { } , qs ) ;
} else {
qs . pageSize = this . getNodeParameter ( 'limit' , i ) as number ;
const data = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/drives ` , { } , qs ) ;
response = data . drives as IDataObject [ ] ;
}
returnData . push . apply ( returnData , response ) ;
2021-01-19 09:02:52 -08:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'update' ) {
// ----------------------------------
// update
// ----------------------------------
2021-05-24 14:51:06 -07:00
2021-07-19 23:58:54 -07:00
const driveId = this . getNodeParameter ( 'driveId' , i ) as string ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const body : IDataObject = { } ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( body , options ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'PATCH' , ` /drive/v3/drives/ ${ driveId } ` , body ) ;
2021-01-19 09:02:52 -08:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
}
2021-01-19 09:02:52 -08:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'file' ) {
if ( operation === 'copy' ) {
// ----------------------------------
// copy
// ----------------------------------
const fileId = this . getNodeParameter ( 'fileId' , i ) as string ;
const body : IDataObject = {
fields : queryFields ,
} ;
const optionProperties = [ 'name' , 'parents' ] ;
for ( const propertyName of optionProperties ) {
if ( options [ propertyName ] !== undefined ) {
body [ propertyName ] = options [ propertyName ] ;
}
2019-12-13 09:04:01 -08:00
}
2021-07-19 23:58:54 -07:00
const qs = {
supportsAllDrives : true ,
} ;
2021-05-24 14:51:06 -07:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'POST' , ` /drive/v3/files/ ${ fileId } /copy ` , body , qs ) ;
2019-12-13 09:04:01 -08:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
2019-12-13 09:04:01 -08:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'download' ) {
// ----------------------------------
// download
// ----------------------------------
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const fileId = this . getNodeParameter ( 'fileId' , i ) as string ;
const options = this . getNodeParameter ( 'options' , i ) as IDataObject ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const requestOptions = {
resolveWithFullResponse : true ,
encoding : null ,
json : false ,
} ;
2020-06-06 11:57:42 -07:00
2021-12-21 14:36:37 -08:00
const file = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/files/ ${ fileId } ` , { } , { fields : 'mimeType' } ) ;
let response ;
if ( file . mimeType . includes ( 'vnd.google-apps' ) ) {
const parameterKey = 'options.googleFileConversion.conversion' ;
const type = file . mimeType . split ( '.' ) [ 2 ] ;
let mime ;
if ( type === 'document' ) {
mime = this . getNodeParameter ( ` ${ parameterKey } .docsToFormat ` , i , 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ) as string ;
} else if ( type === 'presentation' ) {
mime = this . getNodeParameter ( ` ${ parameterKey } .slidesToFormat ` , i , 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ) as string ;
} else if ( type === 'spreadsheet' ) {
mime = this . getNodeParameter ( ` ${ parameterKey } .sheetsToFormat ` , i , 'application/x-vnd.oasis.opendocument.spreadsheet' ) as string ;
} else {
mime = this . getNodeParameter ( ` ${ parameterKey } .drawingsToFormat ` , i , 'image/jpeg' ) as string ;
}
response = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/files/ ${ fileId } /export ` , { } , { mimeType : mime } , undefined , requestOptions ) ;
} else {
response = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/files/ ${ fileId } ` , { } , { alt : 'media' } , undefined , requestOptions ) ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
let mimeType : string | undefined ;
let fileName : string | undefined = undefined ;
if ( response . headers [ 'content-type' ] ) {
mimeType = response . headers [ 'content-type' ] ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
if ( options . fileName ) {
fileName = options . fileName as string ;
}
2021-04-30 13:29:10 -07:00
2021-07-19 23:58:54 -07:00
const newItem : INodeExecutionData = {
json : items [ i ] . json ,
binary : { } ,
} ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
if ( items [ i ] . binary !== undefined ) {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Object . assign ( newItem . binary , items [ i ] . binary ) ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
items [ i ] = newItem ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const dataPropertyNameDownload = this . getNodeParameter ( 'binaryPropertyName' , i ) as string ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const data = Buffer . from ( response . body as string ) ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
items [ i ] . binary ! [ dataPropertyNameDownload ] = await this . helpers . prepareBinaryData ( data as unknown as Buffer , fileName , mimeType ) ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'list' ) {
// ----------------------------------
// list
// ----------------------------------
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
let querySpaces = '' ;
if ( options . spaces ) {
const spaces = options . spaces as string [ ] ;
if ( spaces . includes ( '*' ) ) {
querySpaces = 'appDataFolder, drive, photos' ;
} else {
querySpaces = spaces . join ( ', ' ) ;
}
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
let queryCorpora = '' ;
if ( options . corpora ) {
queryCorpora = options . corpora as string ;
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
let driveId : string | undefined ;
driveId = options . driveId as string ;
if ( driveId === '' ) {
driveId = undefined ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
let queryString = '' ;
const useQueryString = this . getNodeParameter ( 'useQueryString' , i ) as boolean ;
if ( useQueryString === true ) {
// Use the user defined query string
queryString = this . getNodeParameter ( 'queryString' , i ) as string ;
} else {
// Build query string out of parameters set by user
const queryFilters = this . getNodeParameter ( 'queryFilters' , i ) as IDataObject ;
const queryFilterFields : string [ ] = [ ] ;
if ( queryFilters . name ) {
( queryFilters . name as IDataObject [ ] ) . forEach ( nameFilter = > {
let operation = nameFilter . operation ;
if ( operation === 'is' ) {
operation = '=' ;
} else if ( operation === 'isNot' ) {
operation = '!=' ;
}
queryFilterFields . push ( ` name ${ operation } ' ${ nameFilter . value } ' ` ) ;
} ) ;
2019-10-27 13:44:21 -07:00
queryString += queryFilterFields . join ( ' or ' ) ;
}
2021-07-19 23:58:54 -07:00
queryFilterFields . length = 0 ;
if ( queryFilters . mimeType ) {
( queryFilters . mimeType as IDataObject [ ] ) . forEach ( mimeTypeFilter = > {
let mimeType = mimeTypeFilter . mimeType ;
if ( mimeTypeFilter . mimeType === 'custom' ) {
mimeType = mimeTypeFilter . customMimeType ;
}
queryFilterFields . push ( ` mimeType = ' ${ mimeType } ' ` ) ;
} ) ;
if ( queryFilterFields . length ) {
if ( queryString !== '' ) {
queryString += ' and ' ;
}
queryString += queryFilterFields . join ( ' or ' ) ;
}
}
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
const pageSize = this . getNodeParameter ( 'limit' , i ) as number ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const qs = {
pageSize ,
orderBy : 'modifiedTime' ,
fields : ` nextPageToken, files( ${ queryFields } ) ` ,
spaces : querySpaces ,
q : queryString ,
includeItemsFromAllDrives : ( queryCorpora !== '' || driveId !== '' ) ,
supportsAllDrives : ( queryCorpora !== '' || driveId !== '' ) ,
} ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/files ` , { } , qs ) ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const files = response ! . files ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
return [ this . helpers . returnJsonArray ( files as IDataObject [ ] ) ] ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
} else if ( operation === 'upload' ) {
// ----------------------------------
// upload
// ----------------------------------
const resolveData = this . getNodeParameter ( 'resolveData' , 0 ) as boolean ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
let mimeType = 'text/plain' ;
let body ;
let originalFilename : string | undefined ;
if ( this . getNodeParameter ( 'binaryData' , i ) === true ) {
// Is binary file to upload
const item = items [ i ] ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
if ( item . binary === undefined ) {
throw new NodeOperationError ( this . getNode ( ) , 'No binary data exists on item!' ) ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const propertyNameUpload = this . getNodeParameter ( 'binaryPropertyName' , i ) as string ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
if ( item . binary [ propertyNameUpload ] === undefined ) {
throw new NodeOperationError ( this . getNode ( ) , ` No binary data property " ${ propertyNameUpload } " does not exists on item! ` ) ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
if ( item . binary [ propertyNameUpload ] . mimeType ) {
mimeType = item . binary [ propertyNameUpload ] . mimeType ;
}
if ( item . binary [ propertyNameUpload ] . fileName ) {
originalFilename = item . binary [ propertyNameUpload ] . fileName ;
}
2019-10-27 13:44:21 -07:00
2022-01-03 13:42:42 -08:00
body = await this . helpers . getBinaryDataBuffer ( i , propertyNameUpload ) ;
2021-07-19 23:58:54 -07:00
} else {
// Is text file
body = Buffer . from ( this . getNodeParameter ( 'fileContent' , i ) as string , 'utf8' ) ;
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
const name = this . getNodeParameter ( 'name' , i ) as string ;
const parents = this . getNodeParameter ( 'parents' , i ) as string [ ] ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
let qs : IDataObject = {
fields : queryFields ,
uploadType : 'media' ,
} ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const requestOptions = {
headers : {
'Content-Type' : mimeType ,
'Content-Length' : body . byteLength ,
} ,
encoding : null ,
json : false ,
} ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
let response = await googleApiRequest . call ( this , 'POST' , ` /upload/drive/v3/files ` , body , qs , undefined , requestOptions ) ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
body = {
mimeType ,
name ,
originalFilename ,
} ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
const properties = this . getNodeParameter ( 'options.propertiesUi.propertyValues' , i , [ ] ) as IDataObject [ ] ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
if ( properties . length ) {
2021-12-21 14:36:37 -08:00
Object . assign ( body , { properties : properties.reduce ( ( obj , value ) = > Object . assign ( obj , { [ ` ${ value . key } ` ] : value . value } ) , { } ) } ) ;
2021-07-19 23:58:54 -07:00
}
2021-06-08 20:34:11 -07:00
2021-07-19 23:58:54 -07:00
const appProperties = this . getNodeParameter ( 'options.appPropertiesUi.appPropertyValues' , i , [ ] ) as IDataObject [ ] ;
2021-06-08 20:34:11 -07:00
2021-07-19 23:58:54 -07:00
if ( properties . length ) {
Object . assign ( body , { appProperties : appProperties.reduce ( ( obj , value ) = > Object . assign ( obj , { [ ` ${ value . key } ` ] : value . value } ) , { } ) } ) ;
}
2021-06-08 20:34:11 -07:00
2021-07-19 23:58:54 -07:00
qs = {
addParents : parents.join ( ',' ) ,
// When set to true shared drives can be used.
supportsAllDrives : true ,
} ;
2021-06-08 20:34:11 -07:00
2021-07-19 23:58:54 -07:00
response = await googleApiRequest . call ( this , 'PATCH' , ` /drive/v3/files/ ${ JSON . parse ( response ) . id } ` , body , qs ) ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
if ( resolveData === true ) {
response = await googleApiRequest . call ( this , 'GET' , ` /drive/v3/files/ ${ response . id } ` , { } , { fields : '*' } ) ;
}
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
} else if ( operation === 'update' ) {
// ----------------------------------
// file:update
// ----------------------------------
2021-02-15 00:02:47 -08:00
2021-07-19 23:58:54 -07:00
const id = this . getNodeParameter ( 'fileId' , i ) as string ;
const updateFields = this . getNodeParameter ( 'updateFields' , i , { } ) as IDataObject ;
2021-03-12 02:24:40 -08:00
2021-07-19 23:58:54 -07:00
const qs : IDataObject = {
supportsAllDrives : true ,
} ;
2021-03-12 02:24:40 -08:00
2021-07-19 23:58:54 -07:00
Object . assign ( qs , options ) ;
2021-03-12 02:24:40 -08:00
2021-07-19 23:58:54 -07:00
qs . fields = queryFields ;
2021-03-12 02:24:40 -08:00
2021-08-11 10:37:18 -07:00
const body : IDataObject = { } ;
2021-08-11 10:48:31 -07:00
if ( updateFields . fileName ) {
body . name = updateFields . fileName ;
2021-08-11 10:37:18 -07:00
}
2021-07-19 23:58:54 -07:00
if ( updateFields . parentId && updateFields . parentId !== '' ) {
qs . addParents = updateFields . parentId ;
}
2021-03-12 02:24:40 -08:00
2021-08-11 10:37:18 -07:00
const responseData = await googleApiRequest . call ( this , 'PATCH' , ` /drive/v3/files/ ${ id } ` , body , qs ) ;
2021-07-19 23:58:54 -07:00
returnData . push ( responseData as IDataObject ) ;
2021-03-12 02:51:35 -08:00
}
2021-03-12 02:24:40 -08:00
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
if ( resource === 'folder' ) {
if ( operation === 'create' ) {
// ----------------------------------
// folder:create
// ----------------------------------
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const name = this . getNodeParameter ( 'name' , i ) as string ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const body = {
name ,
mimeType : 'application/vnd.google-apps.folder' ,
parents : options.parents || [ ] ,
} ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const qs = {
fields : queryFields ,
supportsAllDrives : true ,
} ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'POST' , '/drive/v3/files' , body , qs ) ;
2020-06-06 11:57:42 -07:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
}
2019-10-27 13:44:21 -07:00
}
2021-07-19 23:58:54 -07:00
if ( [ 'file' , 'folder' ] . includes ( resource ) ) {
if ( operation === 'delete' ) {
// ----------------------------------
// delete
// ----------------------------------
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const fileId = this . getNodeParameter ( 'fileId' , i ) as string ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'DELETE' , ` /drive/v3/files/ ${ fileId } ` ) ;
2019-10-27 13:44:21 -07:00
2021-07-19 23:58:54 -07:00
// If we are still here it did succeed
returnData . push ( {
fileId ,
success : true ,
} ) ;
}
if ( operation === 'share' ) {
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
const fileId = this . getNodeParameter ( 'fileId' , i ) as string ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
const permissions = this . getNodeParameter ( 'permissionsUi' , i ) as IDataObject ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
const options = this . getNodeParameter ( 'options' , i ) as IDataObject ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
const body : IDataObject = { } ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
const qs : IDataObject = { } ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
if ( permissions . permissionsValues ) {
Object . assign ( body , permissions . permissionsValues ) ;
}
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
Object . assign ( qs , options ) ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
const response = await googleApiRequest . call ( this , 'POST' , ` /drive/v3/files/ ${ fileId } /permissions ` , body , qs ) ;
2020-09-18 00:50:54 -07:00
2021-07-19 23:58:54 -07:00
returnData . push ( response as IDataObject ) ;
}
}
} catch ( error ) {
if ( this . continueOnFail ( ) ) {
if ( resource === 'file' && operation === 'download' ) {
items [ i ] . json = { error : error.message } ;
} else {
returnData . push ( { error : error.message } ) ;
}
continue ;
2020-09-18 00:50:54 -07:00
}
2021-07-19 23:58:54 -07:00
throw error ;
2019-10-27 13:44:21 -07:00
}
}
if ( resource === 'file' && operation === 'download' ) {
// For file downloads the files get attached to the existing items
return this . prepareOutputData ( items ) ;
} else {
// For all other ones does the output items get replaced
return [ this . helpers . returnJsonArray ( returnData ) ] ;
}
}
}