run lintfix

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-06-26 13:16:20 +02:00 committed by Christoph Dyllick-Brenzinger
parent 4f41decdda
commit 0184e65904
21 changed files with 72 additions and 67 deletions

View file

@ -2,9 +2,12 @@ import type { ICredentialTestRequest, ICredentialType, INodeProperties } from 'n
export class SeaTableApi implements ICredentialType {
name = 'seaTableApi';
displayName = 'SeaTable API';
documentationUrl =
'https://seatable.io/docs/n8n-integration/erstellen-eines-api-tokens-fuer-n8n/?lang=auto';
properties: INodeProperties[] = [
{
displayName: 'Environment',

View file

@ -1,3 +1,4 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
import type { INodeTypeDescription } from 'n8n-workflow';
import { rowFields, rowOperations } from './RowDescription';

View file

@ -9,8 +9,8 @@ export type TSeaTableServerEdition = 'enterprise edition';
// dtable
// ----------------------------------
import type { IDtableMetadataColumn, IDtableMetadataTable, TDtableViewColumn } from './Interfaces';
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
import type { IDtableMetadataColumn, IDtableMetadataTable, TDtableViewColumn } from './Interfaces';
export type TInheritColumnTypeTime = 'ctime' | 'mtime';
export type TInheritColumnTypeUser = 'creator' | 'last-modifier';

View file

@ -1,4 +1,4 @@
import FormData from 'form-data';
import type FormData from 'form-data';
import type {
IDataObject,
@ -11,6 +11,7 @@ import type {
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
import moment from 'moment';
import type { TDtableMetadataColumns, TEndpointVariableName } from './types';
import { schema } from './Schema';
@ -29,8 +30,6 @@ import type {
IFile,
} from './actions/Interfaces';
import moment from 'moment';
// remove last backslash
const userBaseUri = (uri?: string) => {
if (uri === undefined) return uri;
@ -135,7 +134,7 @@ export async function seaTableApiRequest(
}
try {
return this.helpers.requestWithAuthentication.call(this, 'seaTableApi', options);
return await this.helpers.requestWithAuthentication.call(this, 'seaTableApi', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
@ -144,13 +143,13 @@ export async function seaTableApiRequest(
export async function getBaseCollaborators(
this: ILoadOptionsFunctions | IExecuteFunctions | IPollFunctions,
): Promise<any> {
let collaboratorsResult: ICollaboratorsResult = await seaTableApiRequest.call(
const collaboratorsResult: ICollaboratorsResult = await seaTableApiRequest.call(
this,
{},
'GET',
'/dtable-server/api/v1/dtables/{{dtable_uuid}}/related-users/',
);
let collaborators: ICollaborator[] = collaboratorsResult.user_list || [];
const collaborators: ICollaborator[] = collaboratorsResult.user_list || [];
return collaborators;
}
@ -188,7 +187,6 @@ export const nameOfPredicate = (names: readonly IName[]) => (name: string) =>
const normalize = (subject: string): string => (subject ? subject.normalize() : '');
/* will ich diesen call ? */
export const split = (subject: string): string[] =>
normalize(subject)
.split(/\s*((?:[^\\,]*?(?:\\[\s\S])*)*?)\s*(?:,|$)/)
@ -199,12 +197,14 @@ export const split = (subject: string): string[] =>
function getCollaboratorInfo(
authLocal: string | null | undefined,
collaboratorList: ICollaborator[],
) {
let collaboratorDetails: ICollaborator;
collaboratorDetails = collaboratorList.find(
(singleCollaborator) => singleCollaborator['email'] === authLocal,
) || { contact_email: 'unknown', name: 'unkown', email: 'unknown' };
return collaboratorDetails;
): ICollaborator {
return (
collaboratorList.find((singleCollaborator) => singleCollaborator.email === authLocal) || {
contact_email: 'unknown',
name: 'unkown',
email: 'unknown',
}
);
}
// INTERNAL: split asset path.
@ -222,18 +222,18 @@ export function enrichColumns(
collaboratorList: ICollaborator[],
): IRow {
Object.keys(row).forEach((key) => {
let columnDef = metadata.find((obj) => obj.name === key || obj.key === key);
const columnDef = metadata.find((obj) => obj.name === key || obj.key === key);
if (columnDef?.type === 'collaborator') {
// collaborator is an array of strings.
let collaborators = (row[key] as string[]) || [];
const collaborators = (row[key] as string[]) || [];
if (collaborators.length > 0) {
let newArray = collaborators.map((email) => {
let collaboratorDetails = getCollaboratorInfo(email, collaboratorList);
let newColl = {
email: email,
contact_email: collaboratorDetails['contact_email'],
name: collaboratorDetails['name'],
const newArray = collaborators.map((email) => {
const collaboratorDetails = getCollaboratorInfo(email, collaboratorList);
const newColl = {
email,
contact_email: collaboratorDetails.contact_email,
name: collaboratorDetails.name,
};
return newColl;
});
@ -248,22 +248,22 @@ export function enrichColumns(
columnDef?.key === '_last_modifier'
) {
// creator or last-modifier are always a single string.
let collaboratorDetails = getCollaboratorInfo(row[key] as string, collaboratorList);
const collaboratorDetails = getCollaboratorInfo(row[key] as string, collaboratorList);
row[key] = {
email: row[key],
contact_email: collaboratorDetails['contact_email'],
name: collaboratorDetails['name'],
contact_email: collaboratorDetails.contact_email,
name: collaboratorDetails.name,
};
}
if (columnDef?.type === 'image') {
let pictures = (row[key] as string[]) || [];
const pictures = (row[key] as string[]) || [];
if (pictures.length > 0) {
let newArray = pictures.map((url) => ({
const newArray = pictures.map((url) => ({
name: url.split('/').pop(),
size: 0,
type: 'image',
url: url,
url,
path: getAssetPath('images', url),
}));
row[key] = newArray;
@ -271,18 +271,18 @@ export function enrichColumns(
}
if (columnDef?.type === 'file') {
let files = (row[key] as IFile[]) || [];
const files = (row[key] as IFile[]) || [];
files.forEach((file) => {
file.path = getAssetPath('files', file.url);
});
}
if (columnDef?.type === 'digital-sign') {
let digitalSignature: IColumnDigitalSignature | any = row[key];
let collaboratorDetails = getCollaboratorInfo(digitalSignature?.username, collaboratorList);
const digitalSignature: IColumnDigitalSignature | any = row[key];
const collaboratorDetails = getCollaboratorInfo(digitalSignature?.username, collaboratorList);
if (digitalSignature?.username) {
digitalSignature.contact_email = collaboratorDetails['contact_email'];
digitalSignature.name = collaboratorDetails['name'];
digitalSignature.contact_email = collaboratorDetails.contact_email;
digitalSignature.name = collaboratorDetails.name;
}
}
@ -340,7 +340,7 @@ export function splitStringColumnsToArrays(
// remove nonUpdateColumnTypes and only use allowed columns!
export function rowExport(row: IRowObject, columns: TDtableMetadataColumns): IRowObject {
let rowAllowed = {} as IRowObject;
const rowAllowed = {} as IRowObject;
columns.map((column) => {
if (row[column.name]) {
rowAllowed[column.name] = row[column.name];

View file

@ -22,6 +22,6 @@ export class SeaTableV2 implements INodeType {
methods = { loadOptions };
async execute(this: IExecuteFunctions) {
return router.call(this);
return await router.call(this);
}
}

View file

@ -17,5 +17,5 @@ export async function getPublicURL(
);
}
return this.helpers.returnJsonArray(responseData as IDataObject[]);
return this.helpers.returnJsonArray(responseData);
}

View file

@ -1,6 +1,6 @@
import type { INodeProperties } from 'n8n-workflow';
import * as upload from './upload';
import * as getPublicURL from './getPublicURL';
import type { INodeProperties } from 'n8n-workflow';
export { upload, getPublicURL };

View file

@ -9,7 +9,7 @@ export async function upload(
const uploadColumn = this.getNodeParameter('uploadColumn', index) as any;
const uploadColumnType = uploadColumn.split(':::')[1];
const uploadColumnName = uploadColumn.split(':::')[0];
const dataPropertyName = this.getNodeParameter('dataPropertyName', index) as string;
const dataPropertyName = this.getNodeParameter('dataPropertyName', index);
const tableName = this.getNodeParameter('tableName', index) as string;
const rowId = this.getNodeParameter('rowId', index) as string;
const uploadLink = (await seaTableApiRequest.call(
@ -43,7 +43,7 @@ export async function upload(
// if there are already assets attached to the column
let existingAssetArray = [];
if (append) {
let rowToUpdate = await seaTableApiRequest.call(
const rowToUpdate = await seaTableApiRequest.call(
this,
{},
'GET',
@ -75,7 +75,7 @@ export async function upload(
};
// Send the upload request
let uploadAsset = await seaTableApiRequest.call(
const uploadAsset = await seaTableApiRequest.call(
this,
{},
'POST',
@ -93,7 +93,7 @@ export async function upload(
row_id: rowId,
row: {},
} as IDataObject;
let rowInput = {} as IRowObject;
const rowInput = {} as IRowObject;
const filePath = `${serverURL}/workspace/${workspaceId}${uploadLink.parent_path}/${relativePath}/${uploadAsset[c].name}`;
@ -127,7 +127,7 @@ export async function upload(
body,
);
uploadAsset[c]['upload_successful'] = responseData.success;
uploadAsset[c].upload_successful = responseData.success;
}
return this.helpers.returnJsonArray(uploadAsset as IDataObject[]);

View file

@ -56,7 +56,8 @@ export const baseApiCallDescription: BaseProperties = [
required: true,
default: '',
placeholder: '/dtable-server/...',
description: 'The URL has to start with /dtable-server/ or /dtable-db/. All possible requests can be found at the SeaTable API Reference at https://api.seatable.io Please be aware that only request from the section Base Operations that use an Base-Token for the authentication are allowed to use.',
description:
'The URL has to start with /dtable-server/ or /dtable-db/. All possible requests can be found at the SeaTable API Reference at https://api.seatable.io Please be aware that only request from the section Base Operations that use an Base-Token for the authentication are allowed to use.',
},
{
displayName: 'Query String Parameters',

View file

@ -1,6 +1,6 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import { seaTableApiRequest } from '../../../GenericFunctions';
import { APITypes } from '../../../types';
import type { APITypes } from '../../../types';
export async function apiCall(
this: IExecuteFunctions,

View file

@ -1,6 +1,6 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import { seaTableApiRequest } from '../../../GenericFunctions';
import { ICollaborator } from '../../Interfaces';
import type { ICollaborator } from '../../Interfaces';
export async function collaborator(
this: IExecuteFunctions,
@ -16,10 +16,10 @@ export async function collaborator(
);
const collaborators = collaboratorsResult.user_list || [];
const collaborator = collaborators.filter(
const data = collaborators.filter(
(col: ICollaborator) =>
col.contact_email.includes(searchString) || col.name.includes(searchString),
);
return this.helpers.returnJsonArray(collaborator as IDataObject[]);
return this.helpers.returnJsonArray(data as IDataObject[]);
}

View file

@ -1,10 +1,9 @@
import type { INodeProperties } from 'n8n-workflow';
import * as snapshot from './snapshot';
import * as metadata from './metadata';
import * as apiCall from './apiCall';
import * as collaborator from './collaborator';
import type { INodeProperties } from 'n8n-workflow';
export { snapshot, metadata, apiCall, collaborator };
export const descriptions: INodeProperties[] = [

View file

@ -1,7 +1,7 @@
import type { INodeProperties } from 'n8n-workflow';
import * as add from './add';
import * as list from './list';
import * as remove from './remove';
import type { INodeProperties } from 'n8n-workflow';
export { add, list, remove };

View file

@ -8,7 +8,7 @@ export async function list(this: IExecuteFunctions, index: number): Promise<INod
const rowId = this.getNodeParameter('rowId', index) as string;
// get rows
let responseData = await seaTableApiRequest.call(
const responseData = await seaTableApiRequest.call(
this,
{},
'POST',

View file

@ -1,11 +1,11 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import type { IRow, IRowResponse, IDtableMetadataColumn } from './../../Interfaces';
import {
seaTableApiRequest,
enrichColumns,
simplify_new,
getBaseCollaborators,
} from '../../../GenericFunctions';
import type { IRowResponse, IDtableMetadataColumn } from './../../Interfaces';
export async function get(this: IExecuteFunctions, index: number): Promise<INodeExecutionData[]> {
// get parameters
@ -17,7 +17,7 @@ export async function get(this: IExecuteFunctions, index: number): Promise<INode
const collaborators = await getBaseCollaborators.call(this);
// get rows
let sqlResult = (await seaTableApiRequest.call(
const sqlResult = (await seaTableApiRequest.call(
this,
{},
'POST',
@ -27,8 +27,8 @@ export async function get(this: IExecuteFunctions, index: number): Promise<INode
convert_keys: true,
},
)) as IRowResponse;
let metadata = sqlResult.metadata as IDtableMetadataColumn[];
let rows = sqlResult.results as IRow[];
const metadata = sqlResult.metadata as IDtableMetadataColumn[];
const rows = sqlResult.results;
// hide columns like button
rows.map((row) => enrichColumns(row, metadata, collaborators));

View file

@ -1,3 +1,4 @@
import type { INodeProperties } from 'n8n-workflow';
import * as create from './create';
import * as get from './get';
import * as list from './list';
@ -6,7 +7,6 @@ import * as update from './update';
import * as remove from './remove';
import * as lock from './lock';
import * as unlock from './unlock';
import type { INodeProperties } from 'n8n-workflow';
export { create, get, search, update, remove, lock, unlock, list };

View file

@ -1,11 +1,11 @@
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import type { IRow } from './../../Interfaces';
import {
seaTableApiRequest,
enrichColumns,
simplify_new,
getBaseCollaborators,
} from '../../../GenericFunctions';
import type { IRow } from './../../Interfaces';
export async function list(this: IExecuteFunctions, index: number): Promise<INodeExecutionData[]> {
// get parameters
@ -17,14 +17,14 @@ export async function list(this: IExecuteFunctions, index: number): Promise<INod
const collaborators = await getBaseCollaborators.call(this);
// get rows
let requestMeta = await seaTableApiRequest.call(
const requestMeta = await seaTableApiRequest.call(
this,
{},
'GET',
'/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata/',
);
let requestRows = await seaTableApiRequest.call(
const requestRows = await seaTableApiRequest.call(
this,
{},
'GET',
@ -37,10 +37,10 @@ export async function list(this: IExecuteFunctions, index: number): Promise<INod
},
);
let metadata =
const metadata =
requestMeta.metadata.tables.find((table: { name: string }) => table.name === tableName)
?.columns ?? [];
let rows = requestRows.rows as IRow[];
const rows = requestRows.rows as IRow[];
// hide columns like button
rows.map((row) => enrichColumns(row, metadata, collaborators));

View file

@ -5,7 +5,7 @@ import {
simplify_new,
getBaseCollaborators,
} from '../../../GenericFunctions';
import { IDtableMetadataColumn, IRow, IRowResponse } from '../../Interfaces';
import type { IDtableMetadataColumn, IRowResponse } from '../../Interfaces';
export async function search(
this: IExecuteFunctions,
@ -14,7 +14,7 @@ export async function search(
const tableName = this.getNodeParameter('tableName', index) as string;
const searchColumn = this.getNodeParameter('searchColumn', index) as string;
const searchTerm = this.getNodeParameter('searchTerm', index) as string | number;
let searchTermString = String(searchTerm) as string;
let searchTermString = String(searchTerm);
const insensitive = this.getNodeParameter('insensitive', index) as boolean;
const wildcard = this.getNodeParameter('wildcard', index) as boolean;
const simple = this.getNodeParameter('simple', index) as boolean;
@ -44,7 +44,7 @@ export async function search(
},
)) as IRowResponse;
const metadata = sqlResult.metadata as IDtableMetadataColumn[];
let rows = sqlResult.results as IRow[];
const rows = sqlResult.results;
// hide columns like button
rows.map((row) => enrichColumns(row, metadata, collaborators));

View file

@ -1,3 +1,4 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
import type { INodeTypeDescription } from 'n8n-workflow';
import * as row from './row';
import * as base from './base';

View file

@ -37,7 +37,7 @@ export async function getTableNameAndId(
for (const table of tables) {
returnData.push({
name: table.name,
value: table.name + ':::' + table['_id'],
value: table.name + ':::' + table._id,
});
}
return returnData;
@ -232,7 +232,7 @@ export async function getRowIds(this: ILoadOptionsFunctions): Promise<INodePrope
convert_keys: false,
},
);
let rows = sqlResult.results as IRow[];
const rows = sqlResult.results as IRow[];
for (const row of rows) {
returnData.push({

View file

@ -9,12 +9,12 @@ export type TSeaTableServerEdition = 'enterprise edition';
// dtable
// ----------------------------------
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
import type {
IDtableMetadataColumn,
IDtableMetadataTable,
TDtableViewColumn,
} from './actions/Interfaces';
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
export type TColumnType =
| 'text'