Browse Source

refactor(nocodb): lint

pull/5773/head
Wing-Kam Wong 1 year ago
parent
commit
267e51af55
  1. 2
      packages/nocodb/src/cache/RedisCacheMgr.ts
  2. 2
      packages/nocodb/src/cache/RedisMockCacheMgr.ts
  3. 1
      packages/nocodb/src/controllers/api-tokens.controller.ts
  4. 1
      packages/nocodb/src/controllers/attachments.controller.ts
  5. 1
      packages/nocodb/src/controllers/audits.controller.ts
  6. 1
      packages/nocodb/src/controllers/bases.controller.ts
  7. 1
      packages/nocodb/src/controllers/bulk-data-alias.controller.ts
  8. 1
      packages/nocodb/src/controllers/columns.controller.ts
  9. 1
      packages/nocodb/src/controllers/data-alias-export.controller.ts
  10. 3
      packages/nocodb/src/controllers/data-alias-nested.controller.ts
  11. 1
      packages/nocodb/src/controllers/data-alias.controller.ts
  12. 2
      packages/nocodb/src/controllers/filters.controller.ts
  13. 1
      packages/nocodb/src/controllers/form-columns.controller.ts
  14. 1
      packages/nocodb/src/controllers/galleries.controller.ts
  15. 1
      packages/nocodb/src/controllers/grid-columns.controller.ts
  16. 1
      packages/nocodb/src/controllers/grids.controller.ts
  17. 1
      packages/nocodb/src/controllers/maps.controller.ts
  18. 1
      packages/nocodb/src/controllers/meta-diffs.controller.ts
  19. 1
      packages/nocodb/src/controllers/model-visibilities.controller.ts
  20. 1
      packages/nocodb/src/controllers/old-datas/old-datas.controller.ts
  21. 10
      packages/nocodb/src/controllers/plugins.controller.ts
  22. 1
      packages/nocodb/src/controllers/project-users.controller.ts
  23. 2
      packages/nocodb/src/controllers/projects.controller.ts
  24. 1
      packages/nocodb/src/controllers/shared-bases.controller.ts
  25. 1
      packages/nocodb/src/controllers/sorts.controller.ts
  26. 1
      packages/nocodb/src/controllers/tables.controller.ts
  27. 3
      packages/nocodb/src/controllers/view-columns.controller.ts
  28. 6
      packages/nocodb/src/db/BaseModelSql.ts
  29. 11
      packages/nocodb/src/db/BaseModelSqlv2.ts
  30. 2
      packages/nocodb/src/db/CustomKnex.ts
  31. 2
      packages/nocodb/src/db/conditionV2.ts
  32. 2
      packages/nocodb/src/db/sql-client/lib/SqlClientFactory.ts
  33. 1
      packages/nocodb/src/interceptors/is-upload-allowed/is-upload-allowed.interceptor.ts
  34. 8
      packages/nocodb/src/middlewares/extract-project-id/extract-project-id.middleware.ts
  35. 1
      packages/nocodb/src/models/Model.ts
  36. 1
      packages/nocodb/src/modules/datas/helpers.ts
  37. 2
      packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts
  38. 5
      packages/nocodb/src/modules/users/users.module.ts
  39. 1
      packages/nocodb/src/run/docker.ts
  40. 1
      packages/nocodb/src/run/dockerRunPG_CyQuick.ts
  41. 5
      packages/nocodb/src/services/bulk-data-alias.service.ts
  42. 1
      packages/nocodb/src/services/public-metas.service.ts
  43. 1
      packages/nocodb/src/version-upgrader/v1-legacy/gql/GqlApiBuilder.ts
  44. 5
      packages/nocodb/src/version-upgrader/v1-legacy/rest/RestApiBuilder.ts

2
packages/nocodb/src/cache/RedisCacheMgr.ts vendored

@ -45,7 +45,7 @@ export default class RedisCacheMgr extends CacheMgr {
}
// @ts-ignore
async get(key: string, type: string, config?: any): Promise<any> {
async get(key: string, type: string): Promise<any> {
log(`RedisCacheMgr::get: getting key ${key} with type ${type}`);
if (type === CacheGetType.TYPE_ARRAY) {
return this.client.smembers(key);

2
packages/nocodb/src/cache/RedisMockCacheMgr.ts vendored

@ -40,7 +40,7 @@ export default class RedisMockCacheMgr extends CacheMgr {
}
// @ts-ignore
async get(key: string, type: string, config?: any): Promise<any> {
async get(key: string, type: string): Promise<any> {
log(`RedisMockCacheMgr::get: getting key ${key} with type ${type}`);
if (type === CacheGetType.TYPE_ARRAY) {
return this.client.smembers(key);

1
packages/nocodb/src/controllers/api-tokens.controller.ts

@ -9,7 +9,6 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import { PagedResponseImpl } from '../helpers/PagedResponse';
import {

1
packages/nocodb/src/controllers/attachments.controller.ts

@ -30,7 +30,6 @@ export class AttachmentsController {
@UploadedFiles() files: Array<any>,
@Body() body: any,
@Request() req: any,
@Query('path') path: string,
) {
const attachments = await this.attachmentsService.upload({
files: files,

1
packages/nocodb/src/controllers/audits.controller.ts

@ -10,7 +10,6 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import { PagedResponseImpl } from '../helpers/PagedResponse';
import {

1
packages/nocodb/src/controllers/bases.controller.ts

@ -10,7 +10,6 @@ import {
UseGuards,
} from '@nestjs/common';
import { BaseReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import { PagedResponseImpl } from '../helpers/PagedResponse';
import {

1
packages/nocodb/src/controllers/bulk-data-alias.controller.ts

@ -10,7 +10,6 @@ import {
Response,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/columns.controller.ts

@ -11,7 +11,6 @@ import {
UseGuards,
} from '@nestjs/common';
import { ColumnReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/data-alias-export.controller.ts

@ -1,6 +1,5 @@
import { Controller, Get, Request, Response, UseGuards } from '@nestjs/common';
import * as XLSX from 'xlsx';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

3
packages/nocodb/src/controllers/data-alias-nested.controller.ts

@ -8,7 +8,6 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,
@ -131,7 +130,6 @@ export class DataAliasNestedController {
@Param('projectName') projectName: string,
@Param('tableName') tableName: string,
@Param('refRowId') refRowId: string,
@Param('relationType') relationType: string,
) {
await this.dataAliasNestedService.relationDataRemove({
columnName: columnName,
@ -158,7 +156,6 @@ export class DataAliasNestedController {
@Param('projectName') projectName: string,
@Param('tableName') tableName: string,
@Param('refRowId') refRowId: string,
@Param('relationType') relationType: string,
) {
await this.dataAliasNestedService.relationDataAdd({
columnName: columnName,

1
packages/nocodb/src/controllers/data-alias.controller.ts

@ -11,7 +11,6 @@ import {
Response,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import { parseHrtimeToSeconds } from '../helpers';
import {

2
packages/nocodb/src/controllers/filters.controller.ts

@ -9,14 +9,12 @@ import {
Post,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { FilterReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../guards/global/global.guard';
import { PagedResponseImpl } from '../helpers/PagedResponse';
import {
Acl,
ExtractProjectIdMiddleware,
UseAclMiddleware,
} from '../middlewares/extract-project-id/extract-project-id.middleware';
import { FiltersService } from '../services/filters.service';

1
packages/nocodb/src/controllers/form-columns.controller.ts

@ -1,5 +1,4 @@
import { Body, Controller, Param, Patch, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/galleries.controller.ts

@ -9,7 +9,6 @@ import {
UseGuards,
} from '@nestjs/common';
import { GalleryUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/grid-columns.controller.ts

@ -1,6 +1,5 @@
import { Body, Controller, Get, Param, Patch, UseGuards } from '@nestjs/common';
import { GridColumnReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/grids.controller.ts

@ -8,7 +8,6 @@ import {
UseGuards,
} from '@nestjs/common';
import { ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/maps.controller.ts

@ -9,7 +9,6 @@ import {
UseGuards,
} from '@nestjs/common';
import { MapUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/meta-diffs.controller.ts

@ -6,7 +6,6 @@ import {
Post,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/model-visibilities.controller.ts

@ -8,7 +8,6 @@ import {
Query,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/old-datas/old-datas.controller.ts

@ -11,7 +11,6 @@ import {
Response,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../../guards/global/global.guard';
import {
Acl,

10
packages/nocodb/src/controllers/plugins.controller.ts

@ -14,11 +14,11 @@ import { Acl } from '../middlewares/extract-project-id/extract-project-id.middle
import { PluginsService } from '../services/plugins.service';
// todo: move to a interceptor
const blockInCloudMw = (_req, res, next) => {
if (process.env.NC_CLOUD === 'true') {
res.status(403).send('Not allowed');
} else next();
};
// const blockInCloudMw = (_req, res, next) => {
// if (process.env.NC_CLOUD === 'true') {
// res.status(403).send('Not allowed');
// } else next();
// };
@Controller()
@UseGuards(GlobalGuard)

1
packages/nocodb/src/controllers/project-users.controller.ts

@ -11,7 +11,6 @@ import {
UseGuards,
} from '@nestjs/common';
import { ProjectUserReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

2
packages/nocodb/src/controllers/projects.controller.ts

@ -11,7 +11,6 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import isDocker from 'is-docker';
import { ProjectReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../guards/global/global.guard';
@ -19,7 +18,6 @@ import { PagedResponseImpl } from '../helpers/PagedResponse';
import {
ExtractProjectIdMiddleware,
UseAclMiddleware,
UseProjectIdMiddleware,
} from '../middlewares/extract-project-id/extract-project-id.middleware';
import Noco from '../Noco';
import { packageVersion } from '../utils/packageVersion';

1
packages/nocodb/src/controllers/shared-bases.controller.ts

@ -10,7 +10,6 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { GlobalGuard } from '../guards/global/global.guard';
import {
Acl,

1
packages/nocodb/src/controllers/sorts.controller.ts

@ -9,7 +9,6 @@ import {
Post,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { SortReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../guards/global/global.guard';
import { PagedResponseImpl } from '../helpers/PagedResponse';

1
packages/nocodb/src/controllers/tables.controller.ts

@ -11,7 +11,6 @@ import {
Request,
UseGuards,
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { TableReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../guards/global/global.guard';
import extractRolesObj from '../utils/extractRolesObj';

3
packages/nocodb/src/controllers/view-columns.controller.ts

@ -8,8 +8,7 @@ import {
Post,
UseGuards,
} from '@nestjs/common';
import { ColumnReqType, ViewColumnReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport';
import { ViewColumnReqType } from 'nocodb-sdk';
import { GlobalGuard } from '../guards/global/global.guard';
import { PagedResponseImpl } from '../helpers/PagedResponse';
import {

6
packages/nocodb/src/db/BaseModelSql.ts

@ -1613,7 +1613,7 @@ class BaseModelSql extends BaseModel {
}
}
async nestedRead(id, { where, fields: fields1, f, ...rest }, trx = null) {
async nestedRead(id, { fields: fields1, f, ...rest }, trx = null) {
rest = Object.assign({}, this.defaultNestedQueryParams, rest);
const { hm: childs = '', bt: parents = '', mm: many = '' } = rest;
@ -1852,7 +1852,7 @@ class BaseModelSql extends BaseModel {
return null;
}
// @ts-ignore
const { tn, cn, vtn, vcn, vrcn, rtn, rcn } =
const { vtn, vcn, vrcn, rtn, rcn } =
this.manyToManyRelations.find(({ vtn }) => assoc === vtn) || {};
const childModel = this.dbModels[rtn];
@ -1894,7 +1894,7 @@ class BaseModelSql extends BaseModel {
return null;
}
// @ts-ignore
const { tn, cn, vtn, vcn, vrcn, rtn, rcn } =
const { vtn, vcn, vrcn, rtn, rcn } =
this.manyToManyRelations.find(({ vtn }) => assoc === vtn) || {};
const childModel = this.dbModels[rtn];

11
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -19,16 +19,7 @@ import DOMPurify from 'isomorphic-dompurify';
import { v4 as uuidv4 } from 'uuid';
import { NcError } from '../helpers/catchError';
import getAst from '../helpers/getAst';
import {
Audit,
Base,
Column,
Filter,
Model,
Project,
Sort,
View,
} from '../models';
import { Audit, Column, Filter, Model, Project, Sort, View } from '../models';
import { sanitize, unsanitize } from '../helpers/sqlSanitize';
import {
COMPARISON_OPS,

2
packages/nocodb/src/db/CustomKnex.ts

@ -1,6 +1,6 @@
import { Knex, knex } from 'knex';
import { SnowflakeClient } from 'nc-help';
import pg, { types } from 'pg';
import { types } from 'pg';
import dayjs from 'dayjs';
import Filter from '../models/Filter';
import type { FilterType } from 'nocodb-sdk';

2
packages/nocodb/src/db/conditionV2.ts

@ -1,5 +1,5 @@
import { isNumericCol, RelationTypes, UITypes } from 'nocodb-sdk';
import dayjs, { extend } from 'dayjs';
import dayjs from 'dayjs';
// import customParseFormat from 'dayjs/plugin/customParseFormat.js';
import Filter from '../models/Filter';
import { sanitize } from '../helpers/sqlSanitize';

2
packages/nocodb/src/db/sql-client/lib/SqlClientFactory.ts

@ -1,7 +1,5 @@
import fs from 'fs';
import { promisify } from 'util';
import Noco from '../../../Noco';
import SqlClientFactoryEE from './ee/SqlClientFactoryEE';
import MySqlClient from './mysql/MysqlClient';
import MssqlClient from './mssql/MssqlClient';
import OracleClient from './oracle/OracleClient';

1
packages/nocodb/src/interceptors/is-upload-allowed/is-upload-allowed.interceptor.ts

@ -1,6 +1,5 @@
import { Injectable } from '@nestjs/common';
import { OrgUserRoles, ProjectRoles } from 'nocodb-sdk';
import { throwError } from 'rxjs';
import { NcError } from '../../helpers/catchError';
import Noco from '../../Noco';
import extractRolesObj from '../../utils/extractRolesObj';

8
packages/nocodb/src/middlewares/extract-project-id/extract-project-id.middleware.ts

@ -1,10 +1,7 @@
import { promisify } from 'util';
import { Injectable, SetMetadata, UseInterceptors } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { NextFunction, Request, Response } from 'express';
import { OrgUserRoles } from 'nocodb-sdk';
import passport from 'passport';
import { map, throwError } from 'rxjs';
import { map } from 'rxjs';
import {
Column,
Filter,
@ -19,8 +16,7 @@ import {
} from '../../models';
import extractRolesObj from '../../utils/extractRolesObj';
import projectAcl from '../../utils/projectAcl';
import catchError, { NcError } from '../catchError';
import extractProjectIdAndAuthenticate from '../extractProjectIdAndAuthenticate';
import { NcError } from '../catchError';
import type { Observable } from 'rxjs';
import type {
CallHandler,

1
packages/nocodb/src/models/Model.ts

@ -471,7 +471,6 @@ export default class Model implements TableType {
knex,
) {
const insertObj = {};
const base = await Base.get(this.base_id);
for (const col of await this.getColumns()) {
if (isVirtualCol(col)) continue;
let val =

1
packages/nocodb/src/modules/datas/helpers.ts

@ -12,7 +12,6 @@ import NcConnectionMgrv2 from '../../utils/common/NcConnectionMgrv2';
import type { BaseModelSqlv2 } from '../../db/BaseModelSqlv2';
import type LinkToAnotherRecordColumn from '../../models/LinkToAnotherRecordColumn';
import type LookupColumn from '../../models/LookupColumn';
import type { Request } from 'express';
export interface PathParams {
projectName: string;

2
packages/nocodb/src/modules/jobs/jobs/at-import/helpers/readAndProcessData.ts

@ -21,14 +21,12 @@ async function readAllData({
fields,
base,
logBasic = (_str) => {},
services,
}: {
table: { title?: string };
fields?;
base: AirtableBase;
logBasic?: (string) => void;
logDetailed?: (string) => void;
services: AirtableImportContext;
}): Promise<EntityMap> {
return new Promise((resolve, reject) => {
let data = null;

5
packages/nocodb/src/modules/users/users.module.ts

@ -1,9 +1,6 @@
import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import {
GoogleStrategy,
GoogleStrategyProvider,
} from '../../strategies/google.strategy/google.strategy';
import { GoogleStrategyProvider } from '../../strategies/google.strategy/google.strategy';
import { GlobalModule } from '../global/global.module';
import { UsersService } from '../../services/users/users.service';
import { UsersController } from '../../controllers/users/users.controller';

1
packages/nocodb/src/run/docker.ts

@ -1,4 +1,3 @@
import axios from 'axios';
import cors from 'cors';
import express from 'express';
import Noco from '../Noco';

1
packages/nocodb/src/run/dockerRunPG_CyQuick.ts

@ -1,7 +1,6 @@
import cors from 'cors';
import express from 'express';
import Noco from '../Noco';
import nocobuild from '../nocobuild';
const server = express();
server.enable('trust proxy');

5
packages/nocodb/src/services/bulk-data-alias.service.ts

@ -1,8 +1,5 @@
import { Injectable } from '@nestjs/common';
import { isSystemColumn, UITypes } from 'nocodb-sdk';
import * as XLSX from 'xlsx';
import { NcError } from '../helpers/catchError';
import { Base, Column, Model, Project, View } from '../models';
import { Base, Model } from '../models';
import NcConnectionMgrv2 from '../utils/common/NcConnectionMgrv2';
import { getViewAndModelByAliasOrId } from '../modules/datas/helpers';
import type { PathParams } from '../modules/datas/helpers';

1
packages/nocodb/src/services/public-metas.service.ts

@ -3,7 +3,6 @@ import { ErrorMessages, RelationTypes, UITypes } from 'nocodb-sdk';
import { NcError } from '../helpers/catchError';
import { Base, Column, Model, Project, View } from '../models';
import type { LinkToAnotherRecordColumn, LookupColumn } from '../models';
import type { LinkToAnotherRecordType } from 'nocodb-sdk';
@Injectable()
export class PublicMetasService {

1
packages/nocodb/src/version-upgrader/v1-legacy/gql/GqlApiBuilder.ts

@ -1,4 +1,3 @@
import debug from 'debug';
import { Router } from 'express';
import GqlXcSchemaFactory from '../../../db/sql-mgr/code/gql-schema/xc-ts/GqlXcSchemaFactory';
import BaseApiBuilder from '../BaseApiBuilder';

5
packages/nocodb/src/version-upgrader/v1-legacy/rest/RestApiBuilder.ts

@ -1,17 +1,14 @@
import debug from 'debug';
import autoBind from 'auto-bind';
import SwaggerXc from '../../../db/sql-mgr/code/routers/xc-ts/SwaggerXc';
import ExpressXcTsRoutes from '../../../db/sql-mgr/code/routes/xc-ts/ExpressXcTsRoutes';
import NcHelp from '../../../utils/NcHelp';
import BaseApiBuilder, { XcTablesPopulateParams } from '../BaseApiBuilder';
import BaseApiBuilder from '../BaseApiBuilder';
import type { MetaService } from '../../../meta/meta.service';
import type Noco from '../../../Noco';
import type { Router } from 'express';
import type { DbConfig, NcConfig } from '../../../interface/config';
import type NcProjectBuilder from '../NcProjectBuilder';
const log = debug('nc:api:rest');
export class RestApiBuilder extends BaseApiBuilder<Noco> {
public readonly type = 'rest';

Loading…
Cancel
Save