feat(Microsoft Excel 365 Node): Overhaul

This commit is contained in:
Michael Kret
2023-05-02 12:44:25 +03:00
committed by GitHub
parent 25fe14be56
commit 5364a2dff3
75 changed files with 8049 additions and 675 deletions

View File

@@ -1,4 +1,10 @@
import type { IDataObject, IDisplayOptions, INodeProperties } from 'n8n-workflow';
import type {
IDataObject,
IDisplayOptions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { jsonParse } from 'n8n-workflow';
import { isEqual, isNull, merge } from 'lodash';
@@ -73,6 +79,25 @@ export function updateDisplayOptions(
});
}
export function processJsonInput<T>(jsonData: T, inputName?: string) {
let values;
const input = `'${inputName}' ` || '';
if (typeof jsonData === 'string') {
try {
values = jsonParse(jsonData);
} catch (error) {
throw new Error(`Input ${input}must contain a valid JSON`);
}
} else if (typeof jsonData === 'object') {
values = jsonData;
} else {
throw new Error(`Input ${input}must contain a valid JSON`);
}
return values;
}
function isFalsy<T>(value: T) {
if (isNull(value)) return true;
if (typeof value === 'string' && value === '') return true;
@@ -173,6 +198,15 @@ export const fuzzyCompare = (useFuzzyCompare: boolean, compareVersion = 1) => {
};
};
export function wrapData(data: IDataObject | IDataObject[]): INodeExecutionData[] {
if (!Array.isArray(data)) {
return [{ json: data }];
}
return data.map((item) => ({
json: item,
}));
}
export const keysToLowercase = <T>(headers: T) => {
if (typeof headers !== 'object' || Array.isArray(headers) || headers === null) return headers;
return Object.entries(headers).reduce((acc, [key, value]) => {