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,37 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as deleteSpreadsheet from './delete.operation';
|
||||
|
||||
export { create, deleteSpreadsheet };
|
||||
|
||||
export const descriptions: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['spreadsheet'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a spreadsheet',
|
||||
action: 'Create spreadsheet',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'deleteSpreadsheet',
|
||||
description: 'Delete a spreadsheet',
|
||||
action: 'Delete spreadsheet',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
...create.description,
|
||||
...deleteSpreadsheet.description,
|
||||
];
|
||||
@@ -0,0 +1,160 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { wrapData } from '../../../../../../utils/utilities';
|
||||
import type { SpreadSheetProperties } from '../../helpers/GoogleSheets.types';
|
||||
import { apiRequest } from '../../transport';
|
||||
|
||||
export const description: SpreadSheetProperties = [
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['spreadsheet'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'The title of the spreadsheet',
|
||||
},
|
||||
{
|
||||
displayName: 'Sheets',
|
||||
name: 'sheetsUi',
|
||||
placeholder: 'Add Sheet',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
name: 'sheetValues',
|
||||
displayName: 'Sheet',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Title of the property to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Hidden',
|
||||
name: 'hidden',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the Sheet should be hidden in the UI',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['spreadsheet'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['spreadsheet'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Locale',
|
||||
name: 'locale',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'en_US',
|
||||
description: `The locale of the spreadsheet in one of the following formats:
|
||||
<ul>
|
||||
<li>en (639-1)</li>
|
||||
<li>fil (639-2 if no 639-1 format exists)</li>
|
||||
<li>en_US (combination of ISO language an country)</li>
|
||||
<ul>`,
|
||||
},
|
||||
{
|
||||
displayName: 'Recalculation Interval',
|
||||
name: 'autoRecalc',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Default',
|
||||
value: '',
|
||||
description: 'Default value',
|
||||
},
|
||||
{
|
||||
name: 'On Change',
|
||||
value: 'ON_CHANGE',
|
||||
description: 'Volatile functions are updated on every change',
|
||||
},
|
||||
{
|
||||
name: 'Minute',
|
||||
value: 'MINUTE',
|
||||
description: 'Volatile functions are updated on every change and every minute',
|
||||
},
|
||||
{
|
||||
name: 'Hour',
|
||||
value: 'HOUR',
|
||||
description: 'Volatile functions are updated on every change and hourly',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Cell recalculation interval options',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(this: IExecuteFunctions): Promise<INodeExecutionData[]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const sheetsUi = this.getNodeParameter('sheetsUi', i, {}) as IDataObject;
|
||||
|
||||
const body = {
|
||||
properties: {
|
||||
title,
|
||||
autoRecalc: undefined as undefined | string,
|
||||
locale: undefined as undefined | string,
|
||||
},
|
||||
sheets: [] as IDataObject[],
|
||||
};
|
||||
|
||||
const options = this.getNodeParameter('options', i, {});
|
||||
|
||||
if (Object.keys(sheetsUi).length) {
|
||||
const data = [];
|
||||
const sheets = sheetsUi.sheetValues as IDataObject[];
|
||||
for (const properties of sheets) {
|
||||
data.push({ properties });
|
||||
}
|
||||
body.sheets = data;
|
||||
}
|
||||
|
||||
body.properties.autoRecalc = options.autoRecalc ? (options.autoRecalc as string) : undefined;
|
||||
body.properties.locale = options.locale ? (options.locale as string) : undefined;
|
||||
|
||||
const response = await apiRequest.call(this, 'POST', '/v4/spreadsheets', body);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
wrapData(response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { wrapData } from '../../../../../../utils/utilities';
|
||||
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../../../../constants';
|
||||
import type { SpreadSheetProperties } from '../../helpers/GoogleSheets.types';
|
||||
import { apiRequest } from '../../transport';
|
||||
|
||||
export const description: SpreadSheetProperties = [
|
||||
{
|
||||
displayName: 'Document',
|
||||
name: 'documentId',
|
||||
type: 'resourceLocator',
|
||||
default: { mode: 'list', value: '' },
|
||||
required: true,
|
||||
modes: [
|
||||
{
|
||||
displayName: 'From List',
|
||||
name: 'list',
|
||||
type: 'list',
|
||||
typeOptions: {
|
||||
searchListMethod: 'spreadSheetsSearch',
|
||||
searchable: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'By URL',
|
||||
name: 'url',
|
||||
type: 'string',
|
||||
extractValue: {
|
||||
type: 'regex',
|
||||
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
|
||||
},
|
||||
validation: [
|
||||
{
|
||||
type: 'regex',
|
||||
properties: {
|
||||
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
|
||||
errorMessage: 'Not a valid Google Drive File URL',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'By ID',
|
||||
name: 'id',
|
||||
type: 'string',
|
||||
validation: [
|
||||
{
|
||||
type: 'regex',
|
||||
properties: {
|
||||
regex: '[a-zA-Z0-9\\-_]{2,}',
|
||||
errorMessage: 'Not a valid Google Drive File ID',
|
||||
},
|
||||
},
|
||||
],
|
||||
url: '=https://docs.google.com/spreadsheets/d/{{$value}}/edit',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['spreadsheet'],
|
||||
operation: ['deleteSpreadsheet'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export async function execute(this: IExecuteFunctions): Promise<INodeExecutionData[]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const documentId = this.getNodeParameter('documentId', i, undefined, {
|
||||
extractValue: true,
|
||||
}) as string;
|
||||
|
||||
await apiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
'',
|
||||
{},
|
||||
{},
|
||||
`https://www.googleapis.com/drive/v3/files/${documentId}`,
|
||||
);
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(wrapData({ success: true }), {
|
||||
itemData: { item: i },
|
||||
});
|
||||
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
Reference in New Issue
Block a user