Merge release/1.0.1

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-07-06 08:33:45 +02:00
9 changed files with 209 additions and 55 deletions

View File

@@ -13,6 +13,7 @@ import { extractId, googleApiRequest, googleApiRequestAllItems } from './v1/Gene
import moment from 'moment';
import { fileSearch, folderSearch } from './v1/SearchFunctions';
import { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_DRIVE_FOLDER_URL_REGEX } from '../constants';
export class GoogleDriveTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -112,15 +113,13 @@ export class GoogleDriveTrigger implements INodeType {
placeholder: 'https://drive.google.com/file/d/1wroCSfK-hupQIYf_xzeoUEzOhvfTFH2P/edit',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},
@@ -192,15 +191,13 @@ export class GoogleDriveTrigger implements INodeType {
placeholder: 'https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},

View File

@@ -17,6 +17,7 @@ import type { Readable } from 'stream';
import { driveSearch, fileSearch, folderSearch } from './SearchFunctions';
import { oldVersionNotice } from '@utils/descriptions';
import { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_DRIVE_FOLDER_URL_REGEX } from '../../constants';
const UPLOAD_CHUNK_SIZE = 256 * 1024;
@@ -242,15 +243,13 @@ const versionDescription: INodeTypeDescription = {
'https://drive.google.com/file/d/1anGBg0b5re2VtF2bKu201_a-Vnz5BHq9Y4r-yBDAj5A/edit',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},
@@ -306,15 +305,13 @@ const versionDescription: INodeTypeDescription = {
placeholder: 'https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},
@@ -1489,15 +1486,13 @@ const versionDescription: INodeTypeDescription = {
placeholder: 'https://drive.google.com/drive/folders/0AaaaaAAAAAAAaa',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com\\/\\w+\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Drive URL',
},
},

View File

@@ -1,5 +1,6 @@
import type { INodeProperties } from 'n8n-workflow';
import { DRIVE, RLC_DRIVE_DEFAULT } from '../helpers/interfaces';
import { GOOGLE_DRIVE_FILE_URL_REGEX, GOOGLE_DRIVE_FOLDER_URL_REGEX } from '../../../constants';
export const fileRLC: INodeProperties = {
displayName: 'File',
@@ -26,15 +27,13 @@ export const fileRLC: INodeProperties = {
'e.g. https://drive.google.com/file/d/1anGBg0b5re2VtF2bKu201_a-Vnz5BHq9Y4r-yBDAj5A/edit',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com\\/\\w+\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},
@@ -84,15 +83,13 @@ export const folderNoRootRLC: INodeProperties = {
placeholder: 'e.g. https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},
@@ -142,15 +139,13 @@ export const folderRLC: INodeProperties = {
placeholder: 'e.g. https://drive.google.com/drive/folders/1Tx9WHbA3wBpPB4C_HcoZDH9WZFWYxAMU',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Folder URL',
},
},
@@ -200,15 +195,13 @@ export const driveRLC: INodeProperties = {
placeholder: 'https://drive.google.com/drive/folders/0AaaaaAAAAAAAaa',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Drive URL',
},
},
@@ -258,15 +251,13 @@ export const sharedDriveRLC: INodeProperties = {
placeholder: 'e.g. https://drive.google.com/drive/u/1/folders/0AIjtcbwnjtcbwn9PVA',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FOLDER_URL_REGEX,
errorMessage: 'Not a valid Google Drive Drive URL',
},
},

View File

@@ -20,6 +20,7 @@ import {
getRevisionFile,
sheetBinaryToArrayOfArrays,
} from './GoogleSheetsTrigger.utils';
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../constants';
export class GoogleSheetsTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -84,15 +85,13 @@ export class GoogleSheetsTrigger implements INodeType {
type: 'string',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},

View File

@@ -7,6 +7,7 @@ import * as del from './delete.operation';
import * as read from './read.operation';
import * as remove from './remove.operation';
import * as update from './update.operation';
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../../../../constants';
export { append, appendOrUpdate, clear, create, del as delete, read, remove, update };
@@ -96,15 +97,13 @@ export const descriptions: INodeProperties[] = [
type: 'string',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},

View File

@@ -1,6 +1,7 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import type { SpreadSheetProperties } from '../../helpers/GoogleSheets.types';
import { apiRequest } from '../../transport';
import { GOOGLE_DRIVE_FILE_URL_REGEX } from '../../../../constants';
export const description: SpreadSheetProperties = [
// {
@@ -37,15 +38,13 @@ export const description: SpreadSheetProperties = [
type: 'string',
extractValue: {
type: 'regex',
regex:
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
},
validation: [
{
type: 'regex',
properties: {
regex:
'https:\\/\\/(?:drive|docs)\\.google.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)',
regex: GOOGLE_DRIVE_FILE_URL_REGEX,
errorMessage: 'Not a valid Google Drive File URL',
},
},

View File

@@ -0,0 +1,5 @@
export const GOOGLE_DRIVE_FILE_URL_REGEX =
'https:\\/\\/(?:drive|docs)\\.google\\.com(?:\\/.*|)\\/d\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)';
export const GOOGLE_DRIVE_FOLDER_URL_REGEX =
'https:\\/\\/drive\\.google\\.com(?:\\/.*|)\\/folders\\/([0-9a-zA-Z\\-_]+)(?:\\/.*|)';

View File

@@ -13,5 +13,5 @@
"subcategories": {
"Core Nodes": ["Helpers", "Data Transformation"]
},
"alias": ["extract", "template"]
"alias": ["extract", "template", "table"]
}

View File

@@ -12,6 +12,15 @@ import { getValue } from './utils';
import { getResolvables } from '@utils/utilities';
import type { IValueData } from './types';
export const capitalizeHeader = (header: string, capitalize?: boolean) => {
if (!capitalize) return header;
return header
.split('_')
.filter((word) => word)
.map((word) => word[0].toUpperCase() + word.slice(1))
.join(' ');
};
export class Html implements INodeType {
description: INodeTypeDescription = {
displayName: 'HTML',
@@ -44,6 +53,11 @@ export class Html implements INodeType {
value: 'extractHtmlContent',
action: 'Extract HTML Content',
},
{
name: 'Convert to HTML Table',
value: 'convertToHtmlTable',
action: 'Convert to HTML Table',
},
],
default: 'generateHtmlTemplate',
},
@@ -238,15 +252,170 @@ export class Html implements INodeType {
},
],
},
// ----------------------------------
// convertToHtmlTable
// ----------------------------------
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
operation: ['convertToHtmlTable'],
},
},
options: [
{
displayName: 'Capitalize Headers',
name: 'capitalize',
type: 'boolean',
default: false,
description: 'Whether to capitalize the headers',
},
{
displayName: 'Custom Styling',
name: 'customStyling',
type: 'boolean',
default: false,
description: 'Whether to use custom styling',
},
{
displayName: 'Caption',
name: 'caption',
type: 'string',
default: '',
description: 'Caption to add to the table',
},
{
displayName: 'Table Attributes',
name: 'tableAttributes',
type: 'string',
default: '',
description: 'Attributes to attach to the table',
placeholder: 'e.g. style="padding:10px"',
},
{
displayName: 'Header Attributes',
name: 'headerAttributes',
type: 'string',
default: '',
description: 'Attributes to attach to the table header',
placeholder: 'e.g. style="padding:10px"',
},
{
displayName: 'Row Attributes',
name: 'rowAttributes',
type: 'string',
default: '',
description: 'Attributes to attach to the table row',
placeholder: 'e.g. style="padding:10px"',
},
{
displayName: 'Cell Attributes',
name: 'cellAttributes',
type: 'string',
default: '',
description: 'Attributes to attach to the table cell',
placeholder: 'e.g. style="padding:10px"',
},
],
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
let item: INodeExecutionData;
const returnData: INodeExecutionData[] = [];
const operation = this.getNodeParameter('operation', 0);
if (operation === 'convertToHtmlTable' && items.length) {
let table = '';
const options = this.getNodeParameter('options', 0);
let tableStyle = '';
let headerStyle = '';
let cellStyle = '';
if (!options.customStyling) {
tableStyle = "style='border-spacing:0; font-family:helvetica,arial,sans-serif'";
headerStyle =
"style='margin:0; padding:7px 20px 7px 0px; border-bottom:1px solid #eee; text-align:left; color:#888; font-weight:normal'";
cellStyle = "style='margin:0; padding:7px 20px 7px 0px; border-bottom:1px solid #eee'";
}
const tableAttributes = (options.tableAttributes as string) || '';
const headerAttributes = (options.headerAttributes as string) || '';
const itemsData: IDataObject[] = [];
const itemsKeys = new Set<string>();
for (const entry of items) {
itemsData.push(entry.json);
for (const key of Object.keys(entry.json)) {
itemsKeys.add(key);
}
}
const headers = Array.from(itemsKeys);
table += `<table ${tableStyle} ${tableAttributes}>`;
if (options.caption) {
table += `<caption>${options.caption}</caption>`;
}
table += `<thead ${headerStyle} ${headerAttributes}>`;
table += '<tr>';
table += headers
.map((header) => '<th>' + capitalizeHeader(header, options.capitalize as boolean) + '</th>')
.join('');
table += '</tr>';
table += '</thead>';
table += '<tbody>';
itemsData.forEach((entry, entryIndex) => {
const rowsAttributes = this.getNodeParameter(
'options.rowsAttributes',
entryIndex,
'',
) as string;
table += `<tr ${rowsAttributes}>`;
const cellsAttributes = this.getNodeParameter(
'options.cellAttributes',
entryIndex,
'',
) as string;
table += headers
.map((header) => {
let td = `<td ${cellStyle} ${cellsAttributes}>`;
if (typeof entry[header] === 'boolean') {
const isChecked = entry[header] ? 'checked="checked"' : '';
td += `<input type="checkbox" ${isChecked}/>`;
} else {
td += entry[header];
}
td += '</td>';
return td;
})
.join('');
table += '</tr>';
});
table += '</tbody>';
table += '</table>';
return this.prepareOutputData([{ json: { table } }]);
}
let item: INodeExecutionData;
const returnData: INodeExecutionData[] = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
try {
if (operation === 'generateHtmlTemplate') {