From 51364c70b79b23b29e8113c449ba89929a39da31 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 2 Aug 2023 21:35:05 +0800 Subject: [PATCH] fix(nocodb): lint errors --- .../test/TestResetService/index.ts | 2 +- packages/nocodb/src/db/BaseModelSqlv2.ts | 104 +----------------- .../db/sql-client/lib/mssql/MssqlClient.ts | 41 +++---- .../db/sql-client/lib/oracle/OracleClient.ts | 2 +- .../src/db/sql-client/lib/pg/PgClient.ts | 2 +- .../lib/snowflake/SnowflakeClient.ts | 73 ++++++------ .../db/sql-client/lib/sqlite/SqliteClient.ts | 1 + .../src/db/sql-data-mapper/lib/BaseModel.ts | 43 ++++---- .../src/db/sql-migrator/lib/KnexMigrator.ts | 2 + .../src/db/sql-migrator/lib/KnexMigratorv2.ts | 1 + packages/nocodb/src/helpers/apiMetrics.ts | 2 +- .../v1/nc_011_remove_old_ses_plugin.ts | 2 +- packages/nocodb/src/models/Model.ts | 1 + packages/nocodb/src/models/View.ts | 1 - .../jobs/at-import/at-import.controller.ts | 2 +- .../jobs/at-import/at-import.processor.ts | 69 ------------ .../jobs/jobs/export-import/import.service.ts | 1 + packages/nocodb/src/services/auth.service.ts | 4 +- .../nocodb/src/services/tables.service.ts | 8 +- packages/nocodb/src/utils/common/XcAudit.ts | 1 + 20 files changed, 99 insertions(+), 263 deletions(-) diff --git a/packages/nocodb/src/controllers/test/TestResetService/index.ts b/packages/nocodb/src/controllers/test/TestResetService/index.ts index ddf1d8d108..6b7e0d7df8 100644 --- a/packages/nocodb/src/controllers/test/TestResetService/index.ts +++ b/packages/nocodb/src/controllers/test/TestResetService/index.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import Project from '../../../models/Project'; -import NcConnectionMgrv2 from '../../../utils/common/NcConnectionMgrv2'; +// import NcConnectionMgrv2 from '../../../utils/common/NcConnectionMgrv2'; import Noco from '../../../Noco'; import User from '../../../models/User'; import NocoCache from '../../../cache/NocoCache'; diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 81856cd50f..0ee6b03437 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -43,6 +43,7 @@ import genRollupSelectv2 from './genRollupSelectv2'; import conditionV2 from './conditionV2'; import sortV2 from './sortV2'; import { customValidators } from './util/customValidators'; +import Transaction = Knex.Transaction; import type { XKnex } from './CustomKnex'; import type { XcFilter, @@ -58,7 +59,6 @@ import type { SelectOption, } from '../models'; import type { SortType } from 'nocodb-sdk'; -import Transaction = Knex.Transaction; dayjs.extend(utc); dayjs.extend(timezone); @@ -2706,18 +2706,16 @@ class BaseModelSqlv2 { await parentTable.getColumns(); const childTn = this.getTnPath(childTable); - const parentTn = this.getTnPath(parentTable); switch (colOptions.type) { case 'mm': { const vChildCol = await colOptions.getMMChildColumn(); - const vParentCol = await colOptions.getMMParentColumn(); const vTable = await colOptions.getMMModel(); const vTn = this.getTnPath(vTable); - execQueries.push((trx, qb) => + execQueries.push(() => this.dbDriver(vTn) .where({ [vChildCol.column_name]: this.dbDriver(childTn) @@ -2977,104 +2975,12 @@ class BaseModelSqlv2 { modelId: this.model.id, tnPath: this.tnPath, }); - - /* - const view = await View.get(this.viewId); - - // handle form view data submission - if ( - (hookName === 'after.insert' || hookName === 'after.bulkInsert') && - view.type === ViewTypes.FORM - ) { - try { - const formView = await view.getView(); - const { columns } = await FormView.getWithInfo(formView.fk_view_id); - const allColumns = await this.model.getColumns(); - const fieldById = columns.reduce( - (o: Record, f: Record) => ({ - ...o, - [f.fk_column_id]: f, - }), - {}, - ); - let order = 1; - const filteredColumns = allColumns - ?.map((c: Record) => ({ - ...c, - fk_column_id: c.id, - fk_view_id: formView.fk_view_id, - ...(fieldById[c.id] ? fieldById[c.id] : {}), - order: (fieldById[c.id] && fieldById[c.id].order) || order++, - id: fieldById[c.id] && fieldById[c.id].id, - })) - .sort( - (a: Record, b: Record) => - a.order - b.order, - ) - .filter( - (f: Record) => - f.show && - f.uidt !== UITypes.Rollup && - f.uidt !== UITypes.Lookup && - f.uidt !== UITypes.Formula && - f.uidt !== UITypes.QrCode && - f.uidt !== UITypes.Barcode && - f.uidt !== UITypes.SpecificDBType, - ) - .sort( - (a: Record, b: Record) => - a.order - b.order, - ) - .map((c: Record) => ({ - ...c, - required: !!(c.required || 0), - })); - - const emails = Object.entries(JSON.parse(formView?.email) || {}) - .filter((a) => a[1]) - .map((a) => a[0]); - if (emails?.length) { - const transformedData = _transformSubmittedFormDataForEmail( - newData, - formView, - filteredColumns, - ); - (await NcPluginMgrv2.emailAdapter(false))?.mailSend({ - to: emails.join(','), - subject: 'NocoDB Form', - html: ejs.render(formSubmissionEmailTemplate, { - data: transformedData, - tn: this.tnPath, - _tn: this.model.title, - }), - }); - } - } catch (e) { - console.log(e); - } - } - - try { - const [event, operation] = hookName.split('.'); - const hooks = await Hook.list({ - fk_model_id: this.model.id, - event, - operation, - }); - for (const hook of hooks) { - if (hook.active) { - invokeWebhook(hook, this.model, view, prevData, newData, req?.user); - } - } - } catch (e) { - console.log('hooks :: error', hookName, e); - }*/ } - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars protected async errorInsert(e, data, trx, cookie) {} - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars protected async errorUpdate(e, data, trx, cookie) {} // todo: handle composite primary key @@ -3088,7 +2994,7 @@ class BaseModelSqlv2 { ); } - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars protected async errorDelete(e, id, trx, cookie) {} async validate(columns) { diff --git a/packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts b/packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts index 6e08545867..732d4aada7 100644 --- a/packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts +++ b/packages/nocodb/src/db/sql-client/lib/mssql/MssqlClient.ts @@ -2101,7 +2101,7 @@ class MssqlClient extends KnexClient { table = table.onUpdate(relation.ur); } if (relation.dr) { - table = table.onDelete(relation.dr); + table.onDelete(relation.dr); } }) .toQuery()); @@ -2192,28 +2192,31 @@ class MssqlClient extends KnexClient { table = table.onUpdate(args.onUpdate); } if (args.onDelete) { - table = table.onDelete(args.onDelete); + table.onDelete(args.onDelete); } }, ); - const upStatement = - this.querySeparator() + - (await this.sqlClient.schema - .table(this.getTnPath(args.childTable), function (table) { - table = table - .foreign(args.childColumn, foreignKeyName) - .references(args.parentColumn) - .on(self.getTnPath(args.parentTable)); + const upQb = this.sqlClient.schema.table( + this.getTnPath(args.childTable), + function (table) { + table = table + .foreign(args.childColumn, foreignKeyName) + .references(args.parentColumn) + .on(self.getTnPath(args.parentTable)); - if (args.onUpdate) { - table = table.onUpdate(args.onUpdate); - } - if (args.onDelete) { - table = table.onDelete(args.onDelete); - } - }) - .toQuery()); + if (args.onUpdate) { + table = table.onUpdate(args.onUpdate); + } + if (args.onDelete) { + table.onDelete(args.onDelete); + } + }, + ); + + await upQb; + + const upStatement = this.querySeparator() + upQb.toQuery(); this.emit(`Success : ${upStatement}`); @@ -2221,7 +2224,7 @@ class MssqlClient extends KnexClient { this.querySeparator() + this.sqlClient.schema .table(this.getTnPath(args.childTable), function (table) { - table = table.dropForeign(args.childColumn, foreignKeyName); + table.dropForeign(args.childColumn, foreignKeyName); }) .toQuery(); diff --git a/packages/nocodb/src/db/sql-client/lib/oracle/OracleClient.ts b/packages/nocodb/src/db/sql-client/lib/oracle/OracleClient.ts index 573eef665b..21deda8581 100644 --- a/packages/nocodb/src/db/sql-client/lib/oracle/OracleClient.ts +++ b/packages/nocodb/src/db/sql-client/lib/oracle/OracleClient.ts @@ -1914,7 +1914,7 @@ class OracleClient extends KnexClient { * @returns {String} message */ async totalRecords(_args: any = {}): Promise { - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars const func = this.totalRecords.name; throw new Error('Function not supported for oracle yet'); } diff --git a/packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts b/packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts index 9d6623dfa2..f98216277c 100644 --- a/packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts +++ b/packages/nocodb/src/db/sql-client/lib/pg/PgClient.ts @@ -2359,7 +2359,7 @@ class PGClient extends KnexClient { table = table.onUpdate(relation.ur); } if (relation.dr) { - table = table.onDelete(relation.dr); + table.onDelete(relation.dr); } }) .toQuery()); diff --git a/packages/nocodb/src/db/sql-client/lib/snowflake/SnowflakeClient.ts b/packages/nocodb/src/db/sql-client/lib/snowflake/SnowflakeClient.ts index 167b7954c8..00bcb96549 100644 --- a/packages/nocodb/src/db/sql-client/lib/snowflake/SnowflakeClient.ts +++ b/packages/nocodb/src/db/sql-client/lib/snowflake/SnowflakeClient.ts @@ -1970,23 +1970,24 @@ class SnowflakeClient extends KnexClient { relationsList = relationsList.data.list; for (const relation of relationsList) { - downQuery += - this.querySeparator() + - (await this.sqlClient.schema - .table(relation.tn, function (table) { - table = table - .foreign(relation.cn, null) - .references(relation.rcn) - .on(relation.rtn); - - if (relation.ur) { - table = table.onUpdate(relation.ur); - } - if (relation.dr) { - table = table.onDelete(relation.dr); - } - }) - .toQuery()); + const downQb = this.sqlClient.schema.table( + relation.tn, + function (table) { + table = table + .foreign(relation.cn, null) + .references(relation.rcn) + .on(relation.rtn); + + if (relation.ur) { + table = table.onUpdate(relation.ur); + } + if (relation.dr) { + table.onDelete(relation.dr); + } + }, + ); + await downQb; + downQuery += this.querySeparator() + downQb.toQuery(); } let indexList: any = await this.indexList(args); @@ -2060,8 +2061,6 @@ class SnowflakeClient extends KnexClient { const foreignKeyName = args.foreignKeyName || null; try { - // s = await this.sqlClient.schema.index(Object.keys(args.columns)); - await this.sqlClient.schema.table(args.childTable, (table) => { table = table .foreign(args.childColumn, foreignKeyName) @@ -2072,27 +2071,27 @@ class SnowflakeClient extends KnexClient { table = table.onUpdate(args.onUpdate); } if (args.onDelete) { - table = table.onDelete(args.onDelete); + table.onDelete(args.onDelete); } }); - const upStatement = - this.querySeparator() + - (await this.sqlClient.schema - .table(args.childTable, (table) => { - table = table - .foreign(args.childColumn, foreignKeyName) - .references(args.parentColumn) - .on(this.getTnPath(args.parentTable)); + const upQb = this.sqlClient.schema.table(args.childTable, (table) => { + table = table + .foreign(args.childColumn, foreignKeyName) + .references(args.parentColumn) + .on(this.getTnPath(args.parentTable)); - if (args.onUpdate) { - table = table.onUpdate(args.onUpdate); - } - if (args.onDelete) { - table = table.onDelete(args.onDelete); - } - }) - .toQuery()); + if (args.onUpdate) { + table = table.onUpdate(args.onUpdate); + } + if (args.onDelete) { + table.onDelete(args.onDelete); + } + }); + + await upQb; + + const upStatement = this.querySeparator() + upQb.toQuery(); this.emit(`Success : ${upStatement}`); @@ -2100,7 +2099,7 @@ class SnowflakeClient extends KnexClient { this.querySeparator() + this.sqlClient.schema .table(args.childTable, (table) => { - table = table.dropForeign(args.childColumn, foreignKeyName); + table.dropForeign(args.childColumn, foreignKeyName); }) .toQuery(); diff --git a/packages/nocodb/src/db/sql-client/lib/sqlite/SqliteClient.ts b/packages/nocodb/src/db/sql-client/lib/sqlite/SqliteClient.ts index 00ecca611d..1b82233962 100644 --- a/packages/nocodb/src/db/sql-client/lib/sqlite/SqliteClient.ts +++ b/packages/nocodb/src/db/sql-client/lib/sqlite/SqliteClient.ts @@ -1866,6 +1866,7 @@ class SqliteClient extends KnexClient { /* Filter relations for current table */ if (args.tn) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars relations = relations.filter( (r) => r.tn === args.tn || r.rtn === args.tn, ); diff --git a/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts b/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts index 4da3d275f9..157baaa75f 100644 --- a/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts +++ b/packages/nocodb/src/db/sql-data-mapper/lib/BaseModel.ts @@ -321,7 +321,7 @@ abstract class BaseModel { * @returns {Object} Table row data */ // @ts-ignore - async readByPk(id, { conditionGraph }) { + async readByPk(id) { try { return await this._run( this.$db.select().where(this._wherePk(id)).first(), @@ -704,10 +704,7 @@ abstract class BaseModel { */ async exists(id, _) { try { - return ( - Object.keys(await this.readByPk(id, { conditionGraph: null })) - .length !== 0 - ); + return Object.keys(await this.readByPk(id)).length !== 0; } catch (e) { console.log(e); throw e; @@ -1341,7 +1338,7 @@ abstract class BaseModel { * @param {Object} data - insert data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async beforeInsert(data, trx?: any, cookie?: {}) {} /** @@ -1350,7 +1347,7 @@ abstract class BaseModel { * @param {Object} response - inserted data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async afterInsert(response, trx?: any, cookie?: {}) {} /** @@ -1360,7 +1357,7 @@ abstract class BaseModel { * @param {Object} data - insert data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async errorInsert(err, data, trx?: any, cookie?: {}) {} /** @@ -1369,7 +1366,7 @@ abstract class BaseModel { * @param {Object} data - update data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async beforeUpdate(data, trx?: any, cookie?: {}) {} /** @@ -1378,7 +1375,7 @@ abstract class BaseModel { * @param {Object} response - updated data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async afterUpdate(response, trx?: any, cookie?: {}) {} /** @@ -1388,7 +1385,7 @@ abstract class BaseModel { * @param {Object} data - update data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async errorUpdate(err, data, trx?: any, cookie?: {}) {} /** @@ -1397,7 +1394,7 @@ abstract class BaseModel { * @param {Object} data - delete data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async beforeDelete(data, trx?: any, cookie?: {}) {} /** @@ -1406,7 +1403,7 @@ abstract class BaseModel { * @param {Object} response - Deleted data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async afterDelete(response, trx?: any, cookie?: {}) {} /** @@ -1416,7 +1413,7 @@ abstract class BaseModel { * @param {Object} data - delete data * @param {Object} trx? - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async errorDelete(err, data, trx?: any, cookie?: {}) {} /** @@ -1425,7 +1422,7 @@ abstract class BaseModel { * @param {Object[]} data - insert data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async beforeInsertb(data, trx?: any) {} /** @@ -1434,7 +1431,7 @@ abstract class BaseModel { * @param {Object[]} response - inserted data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async afterInsertb(response, trx?: any) {} /** @@ -1444,7 +1441,7 @@ abstract class BaseModel { * @param {Object} data - delete data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async errorInsertb(err, data, trx?: any) {} /** @@ -1453,7 +1450,7 @@ abstract class BaseModel { * @param {Object[]} data - update data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async beforeUpdateb(data, trx?: any) {} /** @@ -1462,7 +1459,7 @@ abstract class BaseModel { * @param {Object[]} response - updated data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async afterUpdateb(response, trx?: any) {} /** @@ -1472,7 +1469,7 @@ abstract class BaseModel { * @param {Object[]} data - delete data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async errorUpdateb(err, data, trx?: any) {} /** @@ -1481,7 +1478,7 @@ abstract class BaseModel { * @param {Object[]} data - delete data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async beforeDeleteb(data, trx?: any) {} /** @@ -1490,7 +1487,7 @@ abstract class BaseModel { * @param {Object[]} response - deleted data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async afterDeleteb(response, trx?: any) {} /** @@ -1500,7 +1497,7 @@ abstract class BaseModel { * @param {Object[]} data - delete data * @param {Object} trx - knex transaction reference */ - // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async errorDeleteb(err, data, trx?: any) {} } diff --git a/packages/nocodb/src/db/sql-migrator/lib/KnexMigrator.ts b/packages/nocodb/src/db/sql-migrator/lib/KnexMigrator.ts index 5f1c6bb291..ce84302552 100644 --- a/packages/nocodb/src/db/sql-migrator/lib/KnexMigrator.ts +++ b/packages/nocodb/src/db/sql-migrator/lib/KnexMigrator.ts @@ -137,6 +137,7 @@ export default class KnexMigrator extends SqlMigrator { ), ); // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars const dirStat = await promisify(fs.stat)( path.join( this.toolDir, @@ -232,6 +233,7 @@ export default class KnexMigrator extends SqlMigrator { ); // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars const metaStat = await promisify(fs.stat)( path.join( this.toolDir, diff --git a/packages/nocodb/src/db/sql-migrator/lib/KnexMigratorv2.ts b/packages/nocodb/src/db/sql-migrator/lib/KnexMigratorv2.ts index 8fd7949e59..9a11b462cb 100644 --- a/packages/nocodb/src/db/sql-migrator/lib/KnexMigratorv2.ts +++ b/packages/nocodb/src/db/sql-migrator/lib/KnexMigratorv2.ts @@ -114,6 +114,7 @@ export default class KnexMigratorv2 { }*/ // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars async _initDbOnFs(base: Base) { // this.emit( // 'Creating folder: ', diff --git a/packages/nocodb/src/helpers/apiMetrics.ts b/packages/nocodb/src/helpers/apiMetrics.ts index 494105cd66..10dbd3b737 100644 --- a/packages/nocodb/src/helpers/apiMetrics.ts +++ b/packages/nocodb/src/helpers/apiMetrics.ts @@ -3,7 +3,7 @@ import type { Request } from 'express'; const countMap = {}; -// @ts-ignore +// eslint-disable-next-line @typescript-eslint/no-unused-vars const metrics = async (req: Request, c = 150) => { if (!req?.route?.path) return; const event = `a:api:${req.route.path}:${req.method}`; diff --git a/packages/nocodb/src/meta/migrations/v1/nc_011_remove_old_ses_plugin.ts b/packages/nocodb/src/meta/migrations/v1/nc_011_remove_old_ses_plugin.ts index fb36849426..5d69ffe71b 100644 --- a/packages/nocodb/src/meta/migrations/v1/nc_011_remove_old_ses_plugin.ts +++ b/packages/nocodb/src/meta/migrations/v1/nc_011_remove_old_ses_plugin.ts @@ -5,7 +5,7 @@ const up = async (knex: Knex) => { await knex('nc_plugins').del().where({ title: 'SES' }); }; -const down = async (knex: Knex) => { +const down = async (_: Knex) => { // await knex('nc_plugins').insert([ses]); }; diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index 00eed04002..099f8fc0d4 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -65,6 +65,7 @@ export default class Model implements TableType { } // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars public async getViews(force = false, ncMeta = Noco.ncMeta): Promise { this.views = await View.listWithInfo(this.id, ncMeta); return this.views; diff --git a/packages/nocodb/src/models/View.ts b/packages/nocodb/src/models/View.ts index 9a4fd88f2f..3135666e86 100644 --- a/packages/nocodb/src/models/View.ts +++ b/packages/nocodb/src/models/View.ts @@ -1,4 +1,3 @@ -import { title } from 'process'; import { isSystemColumn, UITypes, ViewTypes } from 'nocodb-sdk'; import Noco from '../Noco'; import { diff --git a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts index d1d2a54857..11a84b2d9a 100644 --- a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts +++ b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts @@ -65,7 +65,7 @@ export class AtImportController { @Post('/api/v1/db/meta/syncs/:syncId/abort') @HttpCode(200) - async abortImport(@Request() req) { + async abortImport(@Request() _) { return {}; } } diff --git a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts index bc9a247dad..a2b8a8b46e 100644 --- a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts @@ -348,32 +348,6 @@ export class AtImportProcessor { } }; - const nc_DumpTableSchema = async () => { - console.log('['); - // const ncTblList = await api.base.tableList( - // ncCreatedProjectSchema.id, - // syncDB.baseId - // ); - - const ncTblList = { list: [] }; - ncTblList['list'] = await this.tablesService.getAccessibleTables({ - projectId: ncCreatedProjectSchema.id, - baseId: syncDB.baseId, - roles: userRole, - }); - - for (let i = 0; i < ncTblList.list.length; i++) { - // const ncTbl = await api.dbTable.read(ncTblList.list[i].id); - const ncTbl = await this.tablesService.getTableWithAccessibleViews({ - tableId: ncTblList.list[i].id, - user: syncDB.user, - }); - console.log(JSON.stringify(ncTbl, null, 2)); - console.log(','); - } - console.log(']'); - }; - // retrieve nc column schema from using aTbl field ID as reference // const nc_getColumnSchema = async (aTblFieldId) => { @@ -1563,45 +1537,6 @@ export class AtImportProcessor { return rec; }; - const nocoReadDataSelected = async (projName, table, callback, fields) => { - return new Promise((resolve, reject) => { - base(table.title) - .select({ - pageSize: 100, - // maxRecords: 100, - fields: fields, - }) - .eachPage( - async function page(records, fetchNextPage) { - // This function (`page`) will get called for each page of records. - // records.forEach(record => callback(table, record)); - logBasic( - `:: ${table.title} / ${fields} : ${ - recordCnt + 1 - } ~ ${(recordCnt += 100)}`, - ); - await Promise.all( - records.map((r) => callback(projName, table, r, fields)), - ); - - // To fetch the next page of records, call `fetchNextPage`. - // If there are more records, `page` will get called again. - // If there are no more records, `done` will get called. - fetchNextPage(); - }, - function done(err) { - if (err) { - console.error(err); - reject(err); - } - resolve(null); - }, - ); - }); - }; - - ////////// - const nc_isLinkExists = (airtableFieldId) => { return !!ncLinkMappingTable.find( (x) => x.aTbl.typeOptions.symmetricColumnId === airtableFieldId, @@ -2294,7 +2229,6 @@ export class AtImportProcessor { }; /////////////////////////////////////////////////////////////////////////////// - let recordCnt = 0; try { logBasic('SDK initialized'); logDetailed('Project initialization started'); @@ -2374,7 +2308,6 @@ export class AtImportProcessor { if (syncDB.options.syncData) { try { - // await nc_DumpTableSchema(); const _perfStart = recordPerfStart(); const ncTblList = { list: [] }; ncTblList['list'] = await this.tablesService.getAccessibleTables({ @@ -2404,8 +2337,6 @@ export class AtImportProcessor { }); recordPerfStats(_perfStart, 'dbTable.read'); - recordCnt = 0; - recordsMap[ncTbl.id] = await importData({ projectName: syncDB.projectName, table: ncTbl, diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts index ad4b83a82b..a4a0b2e4e6 100644 --- a/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts +++ b/packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts @@ -1214,6 +1214,7 @@ export class ImportService { storageAdapter as any ).fileReadByStream(linkFile); + // eslint-disable-next-line @typescript-eslint/no-unused-vars handledLinks = await this.importLinkFromCsvStream({ idMap, linkStream: linkReadStream, diff --git a/packages/nocodb/src/services/auth.service.ts b/packages/nocodb/src/services/auth.service.ts index 287cb16391..a03e82de4e 100644 --- a/packages/nocodb/src/services/auth.service.ts +++ b/packages/nocodb/src/services/auth.service.ts @@ -40,8 +40,8 @@ export class AuthService { email: _email, firstname, lastname, - token, - ignore_subscribe, + // token, + // ignore_subscribe, } = createUserDto as any; let { password } = createUserDto; diff --git a/packages/nocodb/src/services/tables.service.ts b/packages/nocodb/src/services/tables.service.ts index b656efe362..4f27fb5b0b 100644 --- a/packages/nocodb/src/services/tables.service.ts +++ b/packages/nocodb/src/services/tables.service.ts @@ -14,13 +14,7 @@ import getColumnPropsFromUIDT from '../helpers/getColumnPropsFromUIDT'; import getColumnUiType from '../helpers/getColumnUiType'; import getTableNameAlias, { getColumnNameAlias } from '../helpers/getTableName'; import mapDefaultDisplayValue from '../helpers/mapDefaultDisplayValue'; -import { - Audit, - Column, - Model, - ModelRoleVisibility, - Project, -} from '../models'; +import { Audit, Column, Model, ModelRoleVisibility, Project } from '../models'; import Noco from '../Noco'; import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2'; import { validatePayload } from '../helpers'; diff --git a/packages/nocodb/src/utils/common/XcAudit.ts b/packages/nocodb/src/utils/common/XcAudit.ts index 1c5573f704..bb20ef57ef 100644 --- a/packages/nocodb/src/utils/common/XcAudit.ts +++ b/packages/nocodb/src/utils/common/XcAudit.ts @@ -9,5 +9,6 @@ export default class XcAudit { private static app: Noco; // @ts-ignore + // eslint-disable-next-line @typescript-eslint/no-unused-vars public static async log(data: { project }) {} }