diff --git a/packages/nocodb/src/lib/db/sql-client/lib/KnexClient.ts b/packages/nocodb/src/lib/db/sql-client/lib/KnexClient.ts index a09366e25c..78270235c7 100644 --- a/packages/nocodb/src/lib/db/sql-client/lib/KnexClient.ts +++ b/packages/nocodb/src/lib/db/sql-client/lib/KnexClient.ts @@ -892,7 +892,7 @@ class KnexClient extends SqlClient { getMinMax(_columnObject) {} async mockDb(_args) { - // todo: remove method + // todo: remove method } async dbCacheInitAsyncKnex(_cbk = null) { diff --git a/packages/nocodb/src/lib/db/sql-client/lib/mssql/MssqlClient.ts b/packages/nocodb/src/lib/db/sql-client/lib/mssql/MssqlClient.ts index 2b0bfeb5bc..2b16305679 100644 --- a/packages/nocodb/src/lib/db/sql-client/lib/mssql/MssqlClient.ts +++ b/packages/nocodb/src/lib/db/sql-client/lib/mssql/MssqlClient.ts @@ -356,12 +356,14 @@ class MssqlClient extends KnexClient { try { /** ************** START : create _evolution table if not exists *************** */ - const exists = await this.sqlClient.schema.withSchema(this.schema).hasTable(args.tn); + const exists = await this.sqlClient.schema + .withSchema(this.schema) + .hasTable(args.tn); if (!exists) { - await this.sqlClient.schema.withSchema(this.schema).createTable( - args.tn, - function (table) { + await this.sqlClient.schema + .withSchema(this.schema) + .createTable(args.tn, function (table) { table.increments(); table.string('title').notNullable(); table.string('titleDown').nullable(); @@ -371,8 +373,7 @@ class MssqlClient extends KnexClient { table.integer('status').nullable(); table.dateTime('created'); table.timestamps(); - } - ); + }); log.debug('Table created:', `${this.getTnPath(args.tn)}`); } else { log.debug(`${this.getTnPath(args.tn)} tables exists`); @@ -394,7 +395,9 @@ class MssqlClient extends KnexClient { log.api(`${_func}:args:`, args); try { - result.data.value = await this.sqlClient.schema.withSchema(this.schema).hasTable(args.tn); + result.data.value = await this.sqlClient.schema + .withSchema(this.schema) + .hasTable(args.tn); } catch (e) { log.ppe(e, _func); throw e; @@ -1814,7 +1817,10 @@ class MssqlClient extends KnexClient { const downStatement = this.querySeparator() + - this.sqlClient.schema.withSchema(this.schema).dropTable(args.table).toString(); + this.sqlClient.schema + .withSchema(this.schema) + .dropTable(args.table) + .toString(); this.emit(`Success : ${upQuery}`); @@ -1856,7 +1862,15 @@ class MssqlClient extends KnexClient { BEGIN SET NOCOUNT ON; UPDATE ?? Set ?? = GetDate() where ?? in (SELECT ?? FROM Inserted) - END;`, [triggerName, this.getTnPath(args.table_name), this.getTnPath(args.table_name), column.column_name, pk.column_name, pk.column_name] + END;`, + [ + triggerName, + this.getTnPath(args.table_name), + this.getTnPath(args.table_name), + column.column_name, + pk.column_name, + pk.column_name, + ] ); upQuery += triggerCreateQuery; @@ -2058,7 +2072,10 @@ class MssqlClient extends KnexClient { /** ************** create up & down statements *************** */ const upStatement = this.querySeparator() + - this.sqlClient.schema.withSchema(this.schema).dropTable(args.tn).toString(); + this.sqlClient.schema + .withSchema(this.schema) + .dropTable(args.tn) + .toString(); let downQuery = this.querySeparator() + this.createTable(args.tn, args); this.emit(`Success : ${upStatement}`); @@ -2072,8 +2089,9 @@ class MssqlClient extends KnexClient { for (const relation of relationsList) { downQuery += this.querySeparator() + - (await this.sqlClient.withSchema(this.schema).schema - .table(relation.tn, (table) => { + (await this.sqlClient + .withSchema(this.schema) + .schema.table(relation.tn, (table) => { table = table .foreign(relation.cn, null) .references(relation.rcn) @@ -2116,7 +2134,8 @@ class MssqlClient extends KnexClient { )) { downQuery += this.querySeparator() + - this.sqlClient.schema.withSchema(this.schema) + this.sqlClient.schema + .withSchema(this.schema) .table(tn, function (table) { if (non_unique) { table.index(columns, key_name); @@ -2152,7 +2171,7 @@ class MssqlClient extends KnexClient { * @param {String} - args.childTable * @returns {Promise<{upStatement, downStatement}>} */ - async relationCreate(args) { + async relationCreate(args) { const _func = this.relationCreate.name; const result = new Result(); log.api(`${_func}:args:`, args); @@ -2161,19 +2180,22 @@ class MssqlClient extends KnexClient { try { const self = this; - 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)); - - if (args.onUpdate) { - table = table.onUpdate(args.onUpdate); - } - if (args.onDelete) { - table = table.onDelete(args.onDelete); + 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)); + + if (args.onUpdate) { + table = table.onUpdate(args.onUpdate); + } + if (args.onDelete) { + table = table.onDelete(args.onDelete); + } } - }); + ); const upStatement = this.querySeparator() + @@ -2234,9 +2256,12 @@ class MssqlClient extends KnexClient { try { const self = this; - await this.sqlClient.schema.table(this.getTnPath(args.childTable), function (table) { - table.dropForeign(args.childColumn, foreignKeyName); - }); + await this.sqlClient.schema.table( + this.getTnPath(args.childTable), + function (table) { + table.dropForeign(args.childColumn, foreignKeyName); + } + ); const upStatement = this.querySeparator() + diff --git a/packages/nocodb/src/lib/db/sql-client/lib/pg/PgClient.ts b/packages/nocodb/src/lib/db/sql-client/lib/pg/PgClient.ts index eec0e0d779..29e1d422a3 100644 --- a/packages/nocodb/src/lib/db/sql-client/lib/pg/PgClient.ts +++ b/packages/nocodb/src/lib/db/sql-client/lib/pg/PgClient.ts @@ -468,7 +468,9 @@ class PGClient extends KnexClient { } if (rows.length === 0) { log.debug('creating database:', args); - await tempSqlClient.raw(`CREATE DATABASE ?? ENCODING 'UTF8'`, [args.database]); + await tempSqlClient.raw(`CREATE DATABASE ?? ENCODING 'UTF8'`, [ + args.database, + ]); } // if (this.connectionConfig.searchPath && this.connectionConfig.searchPath[0]) { diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts index 07ee28d5c9..8a542c3d53 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/BaseModel.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/ban-types,prefer-const */ -import { Knex } from 'knex'; +import { Knex } from 'knex'; import Filter from '../../../models/Filter'; import Sort from '../../../models/Sort'; @@ -220,10 +220,7 @@ abstract class BaseModel { const query = this.$db.insert(data); - if ( - this.dbDriver.client === 'pg' || - this.dbDriver.client === 'mssql' - ) { + if (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') { query.returning('*'); response = await this._run(query); } else { @@ -265,10 +262,7 @@ abstract class BaseModel { const query = this.$db.insert(data); - if ( - this.dbDriver.client === 'pg' || - this.dbDriver.client === 'mssql' - ) { + if (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') { query.returning('*'); response = await this._run(query); } else { @@ -302,13 +296,13 @@ abstract class BaseModel { for (const d of data) { await this.validate(d); } - - const response = (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') ? - this.dbDriver - .batchInsert(this.tn, data, 50) - .returning(this.pks?.[0]?.cn || '*') : - this.dbDriver - .batchInsert(this.tn, data, 50); + + const response = + this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql' + ? this.dbDriver + .batchInsert(this.tn, data, 50) + .returning(this.pks?.[0]?.cn || '*') + : this.dbDriver.batchInsert(this.tn, data, 50); await this.afterInsertb(data); diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts index 24fc43fbc6..74a10ee349 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSql.ts @@ -417,10 +417,7 @@ class BaseModelSql extends BaseModel { const query = dbDriver(this.tnPath).insert(insertObj); - if ( - this.dbDriver.client === 'pg' || - this.dbDriver.client === 'mssql' - ) { + if (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') { query.returning(this.selectQuery('')); response = await this._run(query); } @@ -608,12 +605,12 @@ class BaseModelSql extends BaseModel { await this.validate(d1); } - const response = (this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql') ? - await this.dbDriver - .batchInsert(this.tn, insertDatas, 50) - .returning(this.pks[0].cn) : - await this.dbDriver - .batchInsert(this.tn, insertDatas, 50); + const response = + this.dbDriver.client === 'pg' || this.dbDriver.client === 'mssql' + ? await this.dbDriver + .batchInsert(this.tn, insertDatas, 50) + .returning(this.pks[0].cn) + : await this.dbDriver.batchInsert(this.tn, insertDatas, 50); await this.afterInsertb(insertDatas, null); diff --git a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts index 1b2dc45001..82658b312c 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts @@ -270,7 +270,8 @@ async function getGroupedDataList(model, view: View, req) { data = data.map((item) => { // todo: use map to avoid loop const count = - countArr.find((countItem: any) => countItem.key === item.key)?.count ?? 0; + countArr.find((countItem: any) => countItem.key === item.key)?.count ?? + 0; item.value = new PagedResponseImpl(item.value, { ...req.query, diff --git a/packages/nocodb/src/lib/meta/api/index.ts b/packages/nocodb/src/lib/meta/api/index.ts index 082fe97d24..ee1d8ab7fc 100644 --- a/packages/nocodb/src/lib/meta/api/index.ts +++ b/packages/nocodb/src/lib/meta/api/index.ts @@ -1,5 +1,5 @@ import { Tele } from 'nc-help'; -import orgLicenseApis from './orgLicenseApis' +import orgLicenseApis from './orgLicenseApis'; import orgTokenApis from './orgTokenApis'; import orgUserApis from './orgUserApis'; import projectApis from './projectApis'; @@ -61,7 +61,7 @@ export default function (router: Router, server) { projectApis(router); utilApis(router); - if(process.env['PLAYWRIGHT_TEST'] === 'true') { + if (process.env['PLAYWRIGHT_TEST'] === 'true') { router.use(testApis); } router.use(columnApis); diff --git a/packages/nocodb/src/lib/meta/api/orgLicenseApis.ts b/packages/nocodb/src/lib/meta/api/orgLicenseApis.ts index 072f9281d2..1a9df7dde3 100644 --- a/packages/nocodb/src/lib/meta/api/orgLicenseApis.ts +++ b/packages/nocodb/src/lib/meta/api/orgLicenseApis.ts @@ -1,12 +1,10 @@ import { Router } from 'express'; import { OrgUserRoles } from 'nocodb-sdk'; -import { NC_LICENSE_KEY } from '../../constants' +import { NC_LICENSE_KEY } from '../../constants'; import Store from '../../models/Store'; import { metaApiMetrics } from '../helpers/apiMetrics'; import ncMetaAclMw from '../helpers/ncMetaAclMw'; - - async function licenseGet(_req, res) { const license = await Store.get(NC_LICENSE_KEY); diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts index 073c89f01b..90eaddeabf 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicDataApis.ts @@ -157,7 +157,8 @@ async function getGroupedDataList(model, view: View, req) { data = data.map((item) => { // todo: use map to avoid loop const count = - countArr.find((countItem: any) => countItem.key === item.key)?.count ?? 0; + countArr.find((countItem: any) => countItem.key === item.key)?.count ?? + 0; item.value = new PagedResponseImpl(item.value, { ...req.query, diff --git a/packages/nocodb/src/lib/meta/api/swagger/swaggerApis.ts b/packages/nocodb/src/lib/meta/api/swagger/swaggerApis.ts index 48e395f8b0..1b35f7ac1b 100644 --- a/packages/nocodb/src/lib/meta/api/swagger/swaggerApis.ts +++ b/packages/nocodb/src/lib/meta/api/swagger/swaggerApis.ts @@ -2,7 +2,7 @@ import catchError, { NcError } from '../../helpers/catchError'; import { Router } from 'express'; import Model from '../../../models/Model'; -import ncMetaAclMw from '../../helpers/ncMetaAclMw' +import ncMetaAclMw from '../../helpers/ncMetaAclMw'; import getSwaggerJSON from './helpers/getSwaggerJSON'; import Project from '../../../models/Project'; import swaggerHtml from './swaggerHtml'; diff --git a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts index 29f5acb912..58eacc7495 100644 --- a/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts +++ b/packages/nocodb/src/lib/meta/api/sync/helpers/job.ts @@ -2237,9 +2237,12 @@ export default async ( for (let i = 0; i < ncTblList.list.length; i++) { // not a migrated table, skip - if (undefined === aTblSchema.find((x) => x.name === ncTblList.list[i].title)) + if ( + undefined === + aTblSchema.find((x) => x.name === ncTblList.list[i].title) + ) continue; - + const _perfStart = recordPerfStart(); const ncTbl = await api.dbTable.read(ncTblList.list[i].id); recordPerfStats(_perfStart, 'dbTable.read'); @@ -2265,7 +2268,10 @@ export default async ( logBasic('Configuring Record Links...'); for (let i = 0; i < ncTblList.list.length; i++) { // not a migrated table, skip - if (undefined === aTblSchema.find((x) => x.name === ncTblList.list[i].title)) + if ( + undefined === + aTblSchema.find((x) => x.name === ncTblList.list[i].title) + ) continue; const ncTbl = await api.dbTable.read(ncTblList.list[i].id); diff --git a/packages/nocodb/src/lib/meta/api/testApis.ts b/packages/nocodb/src/lib/meta/api/testApis.ts index 73cba3ceb4..506f9d4474 100644 --- a/packages/nocodb/src/lib/meta/api/testApis.ts +++ b/packages/nocodb/src/lib/meta/api/testApis.ts @@ -6,7 +6,7 @@ export async function reset(req: Request, res) { parallelId: req.body.parallelId, dbType: req.body.dbType, isEmptyProject: req.body.isEmptyProject, - workerId: req.body.workerId + workerId: req.body.workerId, }); res.json(await service.process()); diff --git a/packages/nocodb/src/lib/services/test/TestResetService/index.ts b/packages/nocodb/src/lib/services/test/TestResetService/index.ts index ae9837ce3e..020069e152 100644 --- a/packages/nocodb/src/lib/services/test/TestResetService/index.ts +++ b/packages/nocodb/src/lib/services/test/TestResetService/index.ts @@ -23,7 +23,7 @@ const loginRootUser = async () => { const projectTitleByType = { sqlite: 'sampleREST', mysql: 'externalREST', - pg: 'pgExtREST' + pg: 'pgExtREST', }; export class TestResetService { @@ -37,7 +37,7 @@ export class TestResetService { parallelId, dbType, isEmptyProject, - workerId + workerId, }: { parallelId: string; dbType: string; @@ -73,7 +73,7 @@ export class TestResetService { token, dbType: this.dbType, parallelId: this.parallelId, - workerId: this.workerId + workerId: this.workerId, }); try { @@ -96,7 +96,7 @@ export class TestResetService { token, dbType, parallelId, - workerId + workerId, }: { token: string; dbType: string; @@ -123,7 +123,7 @@ export class TestResetService { token, title, parallelId, - isEmptyProject: this.isEmptyProject + isEmptyProject: this.isEmptyProject, }); } else if (dbType == 'mysql') { await resetMysqlSakilaProject({ @@ -131,7 +131,7 @@ export class TestResetService { title, parallelId, oldProject: project, - isEmptyProject: this.isEmptyProject + isEmptyProject: this.isEmptyProject, }); } else if (dbType == 'pg') { await resetPgSakilaProject({ @@ -139,12 +139,12 @@ export class TestResetService { title, parallelId: workerId, oldProject: project, - isEmptyProject: this.isEmptyProject + isEmptyProject: this.isEmptyProject, }); } return { - project: await Project.getByTitle(title) + project: await Project.getByTitle(title), }; } } @@ -177,7 +177,7 @@ const removeProjectUsersFromCache = async (project: Project) => { const projectUsers: ProjectUser[] = await ProjectUser.getUsersList({ project_id: project.id, limit: 1000, - offset: 0 + offset: 0, }); for (const projectUser of projectUsers) { diff --git a/packages/nocodb/src/lib/utils/projectAcl.ts b/packages/nocodb/src/lib/utils/projectAcl.ts index 6ec4b5a35f..b9c1317313 100644 --- a/packages/nocodb/src/lib/utils/projectAcl.ts +++ b/packages/nocodb/src/lib/utils/projectAcl.ts @@ -157,7 +157,7 @@ export default { dataCount: true, upload: true, uploadViaURL: true, - swaggerJson:true + swaggerJson: true, }, }, commenter: { @@ -217,7 +217,7 @@ export default { xcAuditModelCommentsCount: true, xcExportAsCsv: true, dataCount: true, - swaggerJson:true + swaggerJson: true, }, }, viewer: { @@ -273,7 +273,7 @@ export default { list: true, xcExportAsCsv: true, dataCount: true, - swaggerJson:true + swaggerJson: true, }, }, [OrgUserRoles.VIEWER]: {