first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as deleteFolder from './deleteFolder.operation';
|
||||
import * as share from './share.operation';
|
||||
|
||||
export { create, deleteFolder, share };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a folder',
|
||||
action: 'Create folder',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'deleteFolder',
|
||||
description: 'Permanently delete a folder',
|
||||
action: 'Delete folder',
|
||||
},
|
||||
{
|
||||
name: 'Share',
|
||||
value: 'share',
|
||||
description: 'Add sharing permissions to a folder',
|
||||
action: 'Share folder',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
...create.description,
|
||||
...deleteFolder.description,
|
||||
...share.description,
|
||||
];
|
||||
@@ -0,0 +1,114 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { DRIVE } from '../../helpers/interfaces';
|
||||
import { setParentFolder } from '../../helpers/utils';
|
||||
import { googleApiRequest } from '../../transport';
|
||||
import { driveRLC, folderRLC } from '../common.descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
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.",
|
||||
},
|
||||
{
|
||||
...driveRLC,
|
||||
displayName: 'Parent Drive',
|
||||
description: 'The drive where to create the new folder',
|
||||
},
|
||||
{
|
||||
...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'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
|
||||
const name = (this.getNodeParameter('name', i) as string) || 'Untitled';
|
||||
|
||||
const driveId = this.getNodeParameter('driveId', i, undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const folderId = this.getNodeParameter('folderId', i, undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
mimeType: DRIVE.FOLDER,
|
||||
parents: [setParentFolder(folderId, driveId)],
|
||||
};
|
||||
|
||||
const folderColorRgb =
|
||||
(this.getNodeParameter('options.folderColorRgb', i, '') as string) || undefined;
|
||||
if (folderColorRgb) {
|
||||
body.folderColorRgb = folderColorRgb;
|
||||
}
|
||||
|
||||
const simplifyOutput = this.getNodeParameter('options.simplifyOutput', i, true) as boolean;
|
||||
let fields;
|
||||
if (!simplifyOutput) {
|
||||
fields = '*';
|
||||
}
|
||||
|
||||
const qs = {
|
||||
fields,
|
||||
includeItemsFromAllDrives: true,
|
||||
supportsAllDrives: true,
|
||||
spaces: 'appDataFolder, drive',
|
||||
corpora: 'allDrives',
|
||||
};
|
||||
|
||||
const response = await googleApiRequest.call(this, 'POST', '/drive/v3/files', body, qs);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
return executionData;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { googleApiRequest } from '../../transport';
|
||||
import { folderNoRootRLC } from '../common.descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
...folderNoRootRLC,
|
||||
description: 'The folder 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 folder immediately. If false, the folder will be moved to the trash.',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['folder'],
|
||||
operation: ['deleteFolder'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const folderId = this.getNodeParameter('folderNoRootId', i, undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const deletePermanently = this.getNodeParameter('options.deletePermanently', i, false) as boolean;
|
||||
|
||||
const qs = {
|
||||
supportsAllDrives: true,
|
||||
};
|
||||
|
||||
if (deletePermanently) {
|
||||
await googleApiRequest.call(this, 'DELETE', `/drive/v3/files/${folderId}`, undefined, qs);
|
||||
} else {
|
||||
await googleApiRequest.call(
|
||||
this,
|
||||
'PATCH',
|
||||
`/drive/v3/files/${folderId}`,
|
||||
{ trashed: true },
|
||||
qs,
|
||||
);
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({
|
||||
fileId: folderId,
|
||||
success: true,
|
||||
}),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { updateDisplayOptions } from '@utils/utilities';
|
||||
|
||||
import { googleApiRequest } from '../../transport';
|
||||
import { folderNoRootRLC, permissionsOptions, shareOptions } from '../common.descriptions';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{
|
||||
...folderNoRootRLC,
|
||||
description: 'The folder to share',
|
||||
},
|
||||
permissionsOptions,
|
||||
shareOptions,
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['folder'],
|
||||
operation: ['share'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
|
||||
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
const folderId = this.getNodeParameter('folderNoRootId', i, undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
const permissions = this.getNodeParameter('permissionsUi', i) as IDataObject;
|
||||
|
||||
const shareOption = this.getNodeParameter('options', i);
|
||||
|
||||
const body: IDataObject = {};
|
||||
|
||||
const qs: IDataObject = {
|
||||
supportsAllDrives: true,
|
||||
};
|
||||
|
||||
if (permissions.permissionsValues) {
|
||||
Object.assign(body, permissions.permissionsValues);
|
||||
}
|
||||
|
||||
Object.assign(qs, shareOption);
|
||||
|
||||
const response = await googleApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/drive/v3/files/${folderId}/permissions`,
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(response as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
Reference in New Issue
Block a user