diff --git a/packages/nocodb/src/controllers/attachments-secure.controller.ts b/packages/nocodb/src/controllers/attachments-secure.controller.ts index 9a41df56e1..e19b300077 100644 --- a/packages/nocodb/src/controllers/attachments-secure.controller.ts +++ b/packages/nocodb/src/controllers/attachments-secure.controller.ts @@ -15,7 +15,8 @@ import { import hash from 'object-hash'; import moment from 'moment'; import { AnyFilesInterceptor } from '@nestjs/platform-express'; -import { Request, Response } from 'express'; +import { Response } from 'express'; +import type { Request } from 'express'; import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import { GlobalGuard } from '~/guards/global/global.guard'; import { AttachmentsService } from '~/services/attachments.service'; @@ -66,10 +67,7 @@ export class AttachmentsSecureController { } @Get('/dltemp/:param(*)') - async fileReadv3( - @Param('param') param: string, - @Res() res: Response, - ) { + async fileReadv3(@Param('param') param: string, @Res() res: Response) { try { const fpath = await PresignedUrl.getPath(`dltemp/${param}`); diff --git a/packages/nocodb/src/controllers/attachments.controller.ts b/packages/nocodb/src/controllers/attachments.controller.ts index 3ec0c2da82..00a471e1e5 100644 --- a/packages/nocodb/src/controllers/attachments.controller.ts +++ b/packages/nocodb/src/controllers/attachments.controller.ts @@ -30,10 +30,7 @@ export class AttachmentsController { @Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload']) @HttpCode(200) @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) - async upload( - @UploadedFiles() files: Array, - @Req() req: Request, - ) { + async upload(@UploadedFiles() files: Array, @Req() req: Request) { const attachments = await this.attachmentsService.upload({ files: files, path: req.query?.path?.toString(), @@ -65,10 +62,7 @@ export class AttachmentsController { // , getCacheMiddleware(), catchError(fileRead)); @Get('/download/:filename(*)') // This route will match any URL that starts with - async fileRead( - @Param('filename') filename: string, - @Res() res: Response, - ) { + async fileRead(@Param('filename') filename: string, @Res() res: Response) { try { const file = await this.attachmentsService.getFile({ path: path.join('nc', 'uploads', filename), @@ -107,10 +101,7 @@ export class AttachmentsController { } @Get('/dltemp/:param(*)') - async fileReadv3( - @Param('param') param: string, - @Res() res: Response, - ) { + async fileReadv3(@Param('param') param: string, @Res() res: Response) { try { const fpath = await PresignedUrl.getPath(`dltemp/${param}`); diff --git a/packages/nocodb/src/controllers/auth/auth.controller.ts b/packages/nocodb/src/controllers/auth/auth.controller.ts index d21fe8efe7..70a7a7d269 100644 --- a/packages/nocodb/src/controllers/auth/auth.controller.ts +++ b/packages/nocodb/src/controllers/auth/auth.controller.ts @@ -42,7 +42,7 @@ export class AuthController { ]) @UseGuards(PublicApiLimiterGuard) @HttpCode(200) - async signup(@Req() req: Request, @Res() res:Response): Promise { + async signup(@Req() req: Request, @Res() res: Response): Promise { if (this.config.get('auth', { infer: true }).disableEmailAuth) { NcError.forbidden('Email authentication is disabled'); } @@ -62,7 +62,7 @@ export class AuthController { ]) @UseGuards(PublicApiLimiterGuard) @HttpCode(200) - async refreshToken(@Req() req: Request, @Res() res:Response): Promise { + async refreshToken(@Req() req: Request, @Res() res: Response): Promise { res.json( await this.usersService.refreshToken({ body: req.body, @@ -79,7 +79,7 @@ export class AuthController { ]) @UseGuards(PublicApiLimiterGuard, AuthGuard('local')) @HttpCode(200) - async signin(@Req() req:Request, @Res() res:Response) { + async signin(@Req() req: Request, @Res() res: Response) { if (this.config.get('auth', { infer: true }).disableEmailAuth) { NcError.forbidden('Email authentication is disabled'); } @@ -90,7 +90,7 @@ export class AuthController { @UseGuards(GlobalGuard) @Post('/api/v1/auth/user/signout') @HttpCode(200) - async signOut(@Req() req:Request, @Res() res:Response): Promise { + async signOut(@Req() req: Request, @Res() res: Response): Promise { if (!(req as any).isAuthenticated()) { NcError.forbidden('Not allowed'); } @@ -105,7 +105,7 @@ export class AuthController { @Post(`/auth/google/genTokenByCode`) @HttpCode(200) @UseGuards(PublicApiLimiterGuard, AuthGuard('google')) - async googleSignin(@Req() req:Request, @Res() res:Response) { + async googleSignin(@Req() req: Request, @Res() res: Response) { await this.setRefreshToken({ req, res }); res.json(await this.usersService.login(req.user, req)); } @@ -118,7 +118,7 @@ export class AuthController { @Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me']) @UseGuards(MetaApiLimiterGuard, GlobalGuard) - async me(@Req() req:Request) { + async me(@Req() req: Request) { const user = { ...req.user, roles: extractRolesObj(req.user.roles), @@ -229,7 +229,7 @@ export class AuthController { @UseGuards(PublicApiLimiterGuard) async renderPasswordReset( @Req() req: Request, - @Res() res:Response, + @Res() res: Response, @Param('tokenId') tokenId: string, ): Promise { try { diff --git a/packages/nocodb/src/controllers/form-columns.controller.ts b/packages/nocodb/src/controllers/form-columns.controller.ts index 8d412c86cf..865ddf765e 100644 --- a/packages/nocodb/src/controllers/form-columns.controller.ts +++ b/packages/nocodb/src/controllers/form-columns.controller.ts @@ -1,11 +1,4 @@ -import { - Body, - Controller, - Param, - Patch, - Req, - UseGuards, -} from '@nestjs/common'; +import { Body, Controller, Param, Patch, Req, UseGuards } from '@nestjs/common'; import { Request } from 'express'; import { GlobalGuard } from '~/guards/global/global.guard'; import { FormColumnsService } from '~/services/form-columns.service'; diff --git a/packages/nocodb/src/controllers/notifications.controller.ts b/packages/nocodb/src/controllers/notifications.controller.ts index 24c1d5addb..73247a217f 100644 --- a/packages/nocodb/src/controllers/notifications.controller.ts +++ b/packages/nocodb/src/controllers/notifications.controller.ts @@ -37,7 +37,7 @@ export class NotificationsController { async notificationUpdate( @Param('notificationId') notificationId, @Body() body, - @Req() req:Request, + @Req() req: Request, ) { return this.notificationsService.notificationUpdate({ notificationId, @@ -48,7 +48,7 @@ export class NotificationsController { @Post('/api/v1/notifications/mark-all-read') @HttpCode(200) - async markAllRead(@Req() req:Request) { + async markAllRead(@Req() req: Request) { return this.notificationsService.markAllRead({ user: req.user, }); @@ -58,7 +58,7 @@ export class NotificationsController { // @Acl('notificationDelete') async notificationDelete( @Param('notificationId') notificationId, - @Req() req:Request, + @Req() req: Request, ) { return this.notificationsService.notificationUpdate({ notificationId, diff --git a/packages/nocodb/src/controllers/org-tokens.controller.ts b/packages/nocodb/src/controllers/org-tokens.controller.ts index 6654de192a..49540aef0c 100644 --- a/packages/nocodb/src/controllers/org-tokens.controller.ts +++ b/packages/nocodb/src/controllers/org-tokens.controller.ts @@ -47,7 +47,7 @@ export class OrgTokensController { scope: 'org', blockApiTokenAccess: true, }) - async apiTokenCreate(@Req() req:Request, @Body() body: ApiTokenReqType) { + async apiTokenCreate(@Req() req: Request, @Body() body: ApiTokenReqType) { return await this.orgTokensService.apiTokenCreate({ apiToken: body, user: req['user'], @@ -61,7 +61,7 @@ export class OrgTokensController { // allowedRoles: [OrgUserRoles.SUPER], blockApiTokenAccess: true, }) - async apiTokenDelete(@Req() req:Request, @Param('token') token: string) { + async apiTokenDelete(@Req() req: Request, @Param('token') token: string) { await this.orgTokensService.apiTokenDelete({ token, user: req['user'], diff --git a/packages/nocodb/src/controllers/shared-bases.controller.ts b/packages/nocodb/src/controllers/shared-bases.controller.ts index 5d8f73b377..0466974170 100644 --- a/packages/nocodb/src/controllers/shared-bases.controller.ts +++ b/packages/nocodb/src/controllers/shared-bases.controller.ts @@ -28,7 +28,7 @@ export class SharedBasesController { @HttpCode(200) @Acl('createSharedBaseLink') async createSharedBaseLink( - @Req() req:Request, + @Req() req: Request, @Body() body: any, @Param('baseId') baseId: string, ): Promise { @@ -49,7 +49,7 @@ export class SharedBasesController { ]) @Acl('updateSharedBaseLink') async updateSharedBaseLink( - @Req() req:Request, + @Req() req: Request, @Body() body: any, @Param('baseId') baseId: string, ): Promise { @@ -87,7 +87,7 @@ export class SharedBasesController { ]) @Acl('getSharedBaseLink') async getSharedBaseLink( - @Req() req:Request, + @Req() req: Request, @Param('baseId') baseId: string, ): Promise { const sharedBase = await this.sharedBasesService.getSharedBaseLink({ diff --git a/packages/nocodb/src/controllers/views.controller.ts b/packages/nocodb/src/controllers/views.controller.ts index 3f5213ef7c..d7d4d7a112 100644 --- a/packages/nocodb/src/controllers/views.controller.ts +++ b/packages/nocodb/src/controllers/views.controller.ts @@ -102,7 +102,7 @@ export class ViewsController { ]) @HttpCode(200) @Acl('shareView') - async shareView(@Param('viewId') viewId: string, @Req() req:Request) { + async shareView(@Param('viewId') viewId: string, @Req() req: Request) { return await this.viewsService.shareView({ viewId, user: req.user, req }); } @@ -127,7 +127,7 @@ export class ViewsController { async shareViewUpdate( @Param('viewId') viewId: string, @Body() body: ViewUpdateReqType, - @Req() req:Request, + @Req() req: Request, ) { return await this.viewsService.shareViewUpdate({ viewId, @@ -142,7 +142,7 @@ export class ViewsController { '/api/v2/meta/views/:viewId/share', ]) @Acl('shareViewDelete') - async shareViewDelete(@Param('viewId') viewId: string, @Req() req:Request) { + async shareViewDelete(@Param('viewId') viewId: string, @Req() req: Request) { return await this.viewsService.shareViewDelete({ viewId, user: req.user, diff --git a/packages/nocodb/src/guards/global/global.guard.ts b/packages/nocodb/src/guards/global/global.guard.ts index f0ccf8874d..8a4a93365c 100644 --- a/packages/nocodb/src/guards/global/global.guard.ts +++ b/packages/nocodb/src/guards/global/global.guard.ts @@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; import { lastValueFrom, Observable } from 'rxjs'; import { extractRolesObj } from 'nocodb-sdk'; +import type { Request } from 'express'; import type { ExecutionContext } from '@nestjs/common'; import { JwtStrategy } from '~/strategies/jwt.strategy'; -import {Request} from 'express' @Injectable() export class GlobalGuard extends AuthGuard(['jwt']) { diff --git a/packages/nocodb/src/helpers/catchError.ts b/packages/nocodb/src/helpers/catchError.ts index ce6ab3d288..0cb8109447 100644 --- a/packages/nocodb/src/helpers/catchError.ts +++ b/packages/nocodb/src/helpers/catchError.ts @@ -1,5 +1,5 @@ +import type { NextFunction, Request, Response } from 'express'; import type { ErrorObject } from 'ajv'; -import {NextFunction,Request,Response} from "express"; export enum DBError { TABLE_EXIST = 'TABLE_EXIST', diff --git a/packages/nocodb/src/interface/config.ts b/packages/nocodb/src/interface/config.ts index 9fffdcc59e..57498647a5 100644 --- a/packages/nocodb/src/interface/config.ts +++ b/packages/nocodb/src/interface/config.ts @@ -1,9 +1,9 @@ +import type { UserType } from 'nocodb-sdk'; import type { ReqId } from 'pino-http'; import type { Handler } from 'express'; import type * as e from 'express'; import type { Knex } from 'knex'; -import {UserType} from "nocodb-sdk"; -import {User} from "~/models"; +import type { User } from '~/models'; export interface Route { path: string; diff --git a/packages/nocodb/src/modules/jobs/jobs.controller.ts b/packages/nocodb/src/modules/jobs/jobs.controller.ts index 8fc4992d3c..7d371f9821 100644 --- a/packages/nocodb/src/modules/jobs/jobs.controller.ts +++ b/packages/nocodb/src/modules/jobs/jobs.controller.ts @@ -8,11 +8,12 @@ import { Res, UseGuards, } from '@nestjs/common'; -import { Request, Response } from 'express'; +import { Request } from 'express'; import { OnEvent } from '@nestjs/event-emitter'; import { customAlphabet } from 'nanoid'; import { ModuleRef } from '@nestjs/core'; import { JobsRedisService } from './redis/jobs-redis.service'; +import type { Response } from 'express'; import type { OnModuleInit } from '@nestjs/common'; import { JobStatus } from '~/interface/Jobs'; import { JobEvents } from '~/interface/Jobs'; @@ -47,7 +48,7 @@ export class JobsController implements OnModuleInit { @Post('/jobs/listen') @HttpCode(200) async listen( - @Res() res:Response &{resId?:string}, + @Res() res: Response & { resId?: string }, @Req() req: Request, @Body() body: { _mid: number; data: { id: string } }, ) { 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 a9b58627e2..4a21f4ea66 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 @@ -7,6 +7,7 @@ import { elapsedTime, initTime } from '../../helpers'; import type { Readable } from 'stream'; import type { UserType, ViewCreateReqType } from 'nocodb-sdk'; import type { LinkToAnotherRecordColumn, User, View } from '~/models'; +import type { NcRequest } from '~/interface/config'; import { findWithIdentifier, generateUniqueName, @@ -35,7 +36,6 @@ import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import { BulkDataAliasService } from '~/services/bulk-data-alias.service'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import { sanitizeColumnName } from '~/helpers'; -import {NcRequest} from "~/interface/config"; @Injectable() export class ImportService { diff --git a/packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts b/packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts index 0b236c67b9..df403e1c00 100644 --- a/packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts @@ -1,9 +1,9 @@ import debug from 'debug'; import { Process, Processor } from '@nestjs/bull'; import { Job } from 'bull'; +import type { NcRequest } from '~/interface/config'; import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; import { MetaDiffsService } from '~/services/meta-diffs.service'; -import {NcRequest} from "~/interface/config"; @Processor(JOBS_QUEUE) export class MetaSyncProcessor { diff --git a/packages/nocodb/src/services/api-tokens.service.ts b/packages/nocodb/src/services/api-tokens.service.ts index bcd669e57c..caed7622a7 100644 --- a/packages/nocodb/src/services/api-tokens.service.ts +++ b/packages/nocodb/src/services/api-tokens.service.ts @@ -2,11 +2,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk'; import type { User } from '~/models'; import type { ApiTokenReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { NcError } from '~/helpers/catchError'; import { validatePayload } from '~/helpers'; import { ApiToken } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class ApiTokensService { diff --git a/packages/nocodb/src/services/attachments.service.ts b/packages/nocodb/src/services/attachments.service.ts index 7c7e965442..ead5f4c4bb 100644 --- a/packages/nocodb/src/services/attachments.service.ts +++ b/packages/nocodb/src/services/attachments.service.ts @@ -4,13 +4,13 @@ import { Injectable } from '@nestjs/common'; import { nanoid } from 'nanoid'; import slash from 'slash'; import type { AttachmentReqType, FileType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import Local from '~/plugins/storage/Local'; import mimetypes, { mimeIcons } from '~/utils/mimeTypes'; import { PresignedUrl } from '~/models'; import { utf8ify } from '~/helpers/stringHelpers'; -import {NcRequest} from "~/interface/config"; @Injectable() export class AttachmentsService { diff --git a/packages/nocodb/src/services/base-users/base-users.service.ts b/packages/nocodb/src/services/base-users/base-users.service.ts index 6f466cc1bd..b7d7899523 100644 --- a/packages/nocodb/src/services/base-users/base-users.service.ts +++ b/packages/nocodb/src/services/base-users/base-users.service.ts @@ -10,6 +10,7 @@ import { v4 as uuidv4 } from 'uuid'; import * as ejs from 'ejs'; import validator from 'validator'; import type { ProjectUserReqType, UserType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import NocoCache from '~/cache/NocoCache'; import { validatePayload } from '~/helpers'; import Noco from '~/Noco'; @@ -23,7 +24,6 @@ import { Base, BaseUser, User } from '~/models'; import { CacheGetType, CacheScope, MetaTable } from '~/utils/globals'; import { extractProps } from '~/helpers/extractProps'; import { getProjectRolePower } from '~/utils/roleHelper'; -import {NcRequest} from "~/interface/config"; @Injectable() export class BaseUsersService { diff --git a/packages/nocodb/src/services/bases.service.ts b/packages/nocodb/src/services/bases.service.ts index 8a179bb385..a9cadcb7ee 100644 --- a/packages/nocodb/src/services/bases.service.ts +++ b/packages/nocodb/src/services/bases.service.ts @@ -13,6 +13,7 @@ import type { ProjectUpdateReqType, UserType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { populateMeta, validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; @@ -24,7 +25,6 @@ import { getToolDir } from '~/utils/nc-config'; import { MetaService } from '~/meta/meta.service'; import { MetaTable } from '~/utils/globals'; import { TablesService } from '~/services/tables.service'; -import {NcRequest} from "~/interface/config"; const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 4); @@ -37,7 +37,7 @@ export class BasesService { ) {} async baseList(param: { - user: { id: string; roles?: string | Record}; + user: { id: string; roles?: string | Record }; query?: any; }) { const bases = extractRolesObj(param.user?.roles)[OrgUserRoles.SUPER_ADMIN] diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts index db3126b8d4..18bacbd890 100644 --- a/packages/nocodb/src/services/columns.service.ts +++ b/packages/nocodb/src/services/columns.service.ts @@ -21,6 +21,7 @@ import type { import type CustomKnex from '~/db/CustomKnex'; import type SqlClient from '~/db/sql-client/lib/SqlClient'; import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2'; import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2'; @@ -47,7 +48,6 @@ import Noco from '~/Noco'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import { MetaTable } from '~/utils/globals'; import { MetaService } from '~/meta/meta.service'; -import {NcRequest} from "~/interface/config"; // todo: move export enum Altered { diff --git a/packages/nocodb/src/services/filters.service.ts b/packages/nocodb/src/services/filters.service.ts index 23e7e9295b..168bcfa7a7 100644 --- a/packages/nocodb/src/services/filters.service.ts +++ b/packages/nocodb/src/services/filters.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { FilterReqType, UserType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { Filter, Hook, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class FiltersService { diff --git a/packages/nocodb/src/services/form-columns.service.ts b/packages/nocodb/src/services/form-columns.service.ts index cddf40b133..0811314b3d 100644 --- a/packages/nocodb/src/services/form-columns.service.ts +++ b/packages/nocodb/src/services/form-columns.service.ts @@ -1,9 +1,9 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { FormViewColumn } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class FormColumnsService { diff --git a/packages/nocodb/src/services/forms.service.ts b/packages/nocodb/src/services/forms.service.ts index be76e6f051..31cdb7ec21 100644 --- a/packages/nocodb/src/services/forms.service.ts +++ b/packages/nocodb/src/services/forms.service.ts @@ -5,11 +5,11 @@ import type { UserType, ViewCreateReqType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { FormView, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class FormsService { diff --git a/packages/nocodb/src/services/galleries.service.ts b/packages/nocodb/src/services/galleries.service.ts index 7f20af63ea..32406ca4c4 100644 --- a/packages/nocodb/src/services/galleries.service.ts +++ b/packages/nocodb/src/services/galleries.service.ts @@ -5,11 +5,11 @@ import type { UserType, ViewCreateReqType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { GalleryView, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class GalleriesService { diff --git a/packages/nocodb/src/services/grid-columns.service.ts b/packages/nocodb/src/services/grid-columns.service.ts index 6cf59a14e0..e72f23472c 100644 --- a/packages/nocodb/src/services/grid-columns.service.ts +++ b/packages/nocodb/src/services/grid-columns.service.ts @@ -1,10 +1,10 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { GridColumnReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { GridViewColumn } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class GridColumnsService { diff --git a/packages/nocodb/src/services/grids.service.ts b/packages/nocodb/src/services/grids.service.ts index 31fd69d7b1..9c616e209d 100644 --- a/packages/nocodb/src/services/grids.service.ts +++ b/packages/nocodb/src/services/grids.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents, ViewTypes } from 'nocodb-sdk'; import type { GridUpdateReqType, ViewCreateReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { GridView, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class GridsService { diff --git a/packages/nocodb/src/services/hooks.service.ts b/packages/nocodb/src/services/hooks.service.ts index bdd0625e4f..cca803a0ae 100644 --- a/packages/nocodb/src/services/hooks.service.ts +++ b/packages/nocodb/src/services/hooks.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; @@ -10,7 +11,6 @@ import { } from '~/helpers/populateSamplePayload'; import { invokeWebhook } from '~/helpers/webhookHelpers'; import { Hook, HookLog, Model } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class HooksService { @@ -38,7 +38,11 @@ export class HooksService { return await HookLog.list({ fk_hook_id: param.hookId }, param.query); } - async hookCreate(param: { tableId: string; hook: HookReqType; req: NcRequest }) { + async hookCreate(param: { + tableId: string; + hook: HookReqType; + req: NcRequest; + }) { validatePayload('swagger.json#/components/schemas/HookReq', param.hook); this.validateHookPayload(param.hook.notification); @@ -71,7 +75,11 @@ export class HooksService { return true; } - async hookUpdate(param: { hookId: string; hook: HookReqType; req: NcRequest }) { + async hookUpdate(param: { + hookId: string; + hook: HookReqType; + req: NcRequest; + }) { validatePayload('swagger.json#/components/schemas/HookReq', param.hook); const hook = await Hook.get(param.hookId); diff --git a/packages/nocodb/src/services/kanbans.service.ts b/packages/nocodb/src/services/kanbans.service.ts index 645cf8bebe..c21880792d 100644 --- a/packages/nocodb/src/services/kanbans.service.ts +++ b/packages/nocodb/src/services/kanbans.service.ts @@ -5,11 +5,11 @@ import type { UserType, ViewCreateReqType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { KanbanView, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class KanbansService { diff --git a/packages/nocodb/src/services/maps.service.ts b/packages/nocodb/src/services/maps.service.ts index 15d5d775c1..1ea51a41f3 100644 --- a/packages/nocodb/src/services/maps.service.ts +++ b/packages/nocodb/src/services/maps.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents, ViewTypes } from 'nocodb-sdk'; import type { MapUpdateReqType, UserType, ViewCreateReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { MapView, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class MapsService { diff --git a/packages/nocodb/src/services/model-visibilities.service.ts b/packages/nocodb/src/services/model-visibilities.service.ts index ef316f2417..71db96f994 100644 --- a/packages/nocodb/src/services/model-visibilities.service.ts +++ b/packages/nocodb/src/services/model-visibilities.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { VisibilityRuleReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { Base, Model, ModelRoleVisibility, View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class ModelVisibilitiesService { diff --git a/packages/nocodb/src/services/notifications.service.ts b/packages/nocodb/src/services/notifications.service.ts index f50101dc12..864d7481df 100644 --- a/packages/nocodb/src/services/notifications.service.ts +++ b/packages/nocodb/src/services/notifications.service.ts @@ -6,11 +6,11 @@ import type { } from '~/services/app-hooks/interfaces'; import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'; import type { UserType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { NcError } from '~/helpers/catchError'; import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { Notification } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class NotificationsService implements OnModuleInit, OnModuleDestroy { diff --git a/packages/nocodb/src/services/org-tokens.service.ts b/packages/nocodb/src/services/org-tokens.service.ts index 399a61367b..a0d499220b 100644 --- a/packages/nocodb/src/services/org-tokens.service.ts +++ b/packages/nocodb/src/services/org-tokens.service.ts @@ -2,12 +2,12 @@ import { Injectable } from '@nestjs/common'; import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk'; import type { User } from '~/models'; import type { ApiTokenReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { ApiToken } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class OrgTokensService { diff --git a/packages/nocodb/src/services/org-users.service.ts b/packages/nocodb/src/services/org-users.service.ts index d5dd80ab53..bfa8f694fe 100644 --- a/packages/nocodb/src/services/org-users.service.ts +++ b/packages/nocodb/src/services/org-users.service.ts @@ -8,6 +8,7 @@ import { import { v4 as uuidv4 } from 'uuid'; import validator from 'validator'; import type { UserType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { BaseUsersService } from '~/services/base-users/base-users.service'; import { NC_APP_SETTINGS } from '~/constants'; @@ -19,7 +20,6 @@ import { BaseUser, Store, SyncSource, User } from '~/models'; import Noco from '~/Noco'; import { MetaTable } from '~/utils/globals'; -import {NcRequest} from "~/interface/config"; @Injectable() export class OrgUsersService { @@ -194,7 +194,10 @@ export class OrgUsersService { NcError.notImplemented(); } - async userInviteResend(param: { userId: string; req: NcRequest }): Promise { + async userInviteResend(param: { + userId: string; + req: NcRequest; + }): Promise { const user = await User.get(param.userId); if (!user) { diff --git a/packages/nocodb/src/services/plugins.service.ts b/packages/nocodb/src/services/plugins.service.ts index 8dd1fac0ea..9ee7e7d17e 100644 --- a/packages/nocodb/src/services/plugins.service.ts +++ b/packages/nocodb/src/services/plugins.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { PluginTestReqType, PluginType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import { Plugin } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class PluginsService { diff --git a/packages/nocodb/src/services/shared-bases.service.ts b/packages/nocodb/src/services/shared-bases.service.ts index 894bb4b2e1..057f1992dd 100644 --- a/packages/nocodb/src/services/shared-bases.service.ts +++ b/packages/nocodb/src/services/shared-bases.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import { v4 as uuidv4 } from 'uuid'; import { ConfigService } from '@nestjs/config'; -import type {AppConfig, NcRequest} from '~/interface/config'; +import type { AppConfig, NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; diff --git a/packages/nocodb/src/services/sorts.service.ts b/packages/nocodb/src/services/sorts.service.ts index df0bff9dff..1443dc4826 100644 --- a/packages/nocodb/src/services/sorts.service.ts +++ b/packages/nocodb/src/services/sorts.service.ts @@ -1,11 +1,11 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { SortReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { Sort } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class SortsService { diff --git a/packages/nocodb/src/services/sources.service.ts b/packages/nocodb/src/services/sources.service.ts index 387866b7a6..9c96d25c3b 100644 --- a/packages/nocodb/src/services/sources.service.ts +++ b/packages/nocodb/src/services/sources.service.ts @@ -1,13 +1,13 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { BaseReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { populateMeta, validatePayload } from '~/helpers'; import { populateRollupColumnAndHideLTAR } from '~/helpers/populateMeta'; import { syncBaseMigration } from '~/helpers/syncMigration'; import { Base, Source } from '~/models'; import { NcError } from '~/helpers/catchError'; -import {NcRequest} from "~/interface/config"; @Injectable() export class SourcesService { diff --git a/packages/nocodb/src/services/sync.service.ts b/packages/nocodb/src/services/sync.service.ts index 5524216195..19ce24a740 100644 --- a/packages/nocodb/src/services/sync.service.ts +++ b/packages/nocodb/src/services/sync.service.ts @@ -1,10 +1,10 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { NcError } from '~/helpers/catchError'; import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { Base, SyncSource } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class SyncService { diff --git a/packages/nocodb/src/services/tables.service.ts b/packages/nocodb/src/services/tables.service.ts index 8d21d0873c..3ccd278b0d 100644 --- a/packages/nocodb/src/services/tables.service.ts +++ b/packages/nocodb/src/services/tables.service.ts @@ -18,6 +18,7 @@ import type { TableReqType, UserType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2'; import { NcError } from '~/helpers/catchError'; @@ -29,7 +30,6 @@ import { Base, Column, Model, ModelRoleVisibility } from '~/models'; import Noco from '~/Noco'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import { sanitizeColumnName, validatePayload } from '~/helpers'; -import {NcRequest} from "~/interface/config"; @Injectable() export class TablesService { diff --git a/packages/nocodb/src/services/users/users.service.ts b/packages/nocodb/src/services/users/users.service.ts index 4076b5be53..a87d3f595f 100644 --- a/packages/nocodb/src/services/users/users.service.ts +++ b/packages/nocodb/src/services/users/users.service.ts @@ -13,6 +13,7 @@ import type { SignUpReqType, UserType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { genJwt, setTokenCookie } from '~/services/users/helpers'; import { NC_APP_SETTINGS } from '~/constants'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; @@ -26,7 +27,6 @@ import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import { NcError } from '~/helpers/catchError'; import { BasesService } from '~/services/bases.service'; import { extractProps } from '~/helpers/extractProps'; -import {NcRequest} from "~/interface/config"; @Injectable() export class UsersService { diff --git a/packages/nocodb/src/services/view-columns.service.ts b/packages/nocodb/src/services/view-columns.service.ts index 09daf25abb..333ebfbba5 100644 --- a/packages/nocodb/src/services/view-columns.service.ts +++ b/packages/nocodb/src/services/view-columns.service.ts @@ -1,10 +1,10 @@ import { Injectable } from '@nestjs/common'; import { AppEvents } from 'nocodb-sdk'; import type { ViewColumnReqType, ViewColumnUpdateReqType } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { View } from '~/models'; -import {NcRequest} from "~/interface/config"; @Injectable() export class ViewColumnsService { diff --git a/packages/nocodb/src/services/views.service.ts b/packages/nocodb/src/services/views.service.ts index 664c5e182d..7cb0ab0a21 100644 --- a/packages/nocodb/src/services/views.service.ts +++ b/packages/nocodb/src/services/views.service.ts @@ -5,11 +5,11 @@ import type { UserType, ViewUpdateReqType, } from 'nocodb-sdk'; +import type { NcRequest } from '~/interface/config'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { validatePayload } from '~/helpers'; import { NcError } from '~/helpers/catchError'; import { Model, ModelRoleVisibility, View } from '~/models'; -import {NcRequest} from "~/interface/config"; // todo: move async function xcVisibilityMetaGet(param: { @@ -70,7 +70,7 @@ export class ViewsService { async viewList(param: { tableId: string; user: { - roles?: Record | string, + roles?: Record | string; base_roles?: Record; }; }) { @@ -187,7 +187,11 @@ export class ViewsService { return result; } - async shareViewDelete(param: { viewId: string; user: UserType; req: NcRequest }) { + async shareViewDelete(param: { + viewId: string; + user: UserType; + req: NcRequest; + }) { const view = await View.get(param.viewId); if (!view) { diff --git a/packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts b/packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts index 8010f172f0..26327d8887 100644 --- a/packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts +++ b/packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts @@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { extractRolesObj, ProjectRoles } from 'nocodb-sdk'; import { Strategy } from 'passport-custom'; +import type { Request } from 'express'; import { ApiToken, BaseUser, User } from '~/models'; import { sanitiseUserObj } from '~/utils'; -import {Request} from 'express' @Injectable() export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') { diff --git a/packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts b/packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts index 4db70ccb27..022fc3b67b 100644 --- a/packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts +++ b/packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts @@ -2,9 +2,8 @@ import { Injectable, UnauthorizedException } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { Strategy } from 'passport-custom'; import { extractRolesObj } from 'nocodb-sdk'; +import type { Request } from 'express'; import { Base } from '~/models'; -import {Request} from 'express' - @Injectable() export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') { diff --git a/packages/nocodb/src/strategies/google.strategy/google.strategy.ts b/packages/nocodb/src/strategies/google.strategy/google.strategy.ts index 6d310d6491..f7eaea5b73 100644 --- a/packages/nocodb/src/strategies/google.strategy/google.strategy.ts +++ b/packages/nocodb/src/strategies/google.strategy/google.strategy.ts @@ -3,13 +3,13 @@ import { Injectable, Optional } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { Strategy } from 'passport-google-oauth20'; import bcrypt from 'bcryptjs'; +import type { Request } from 'express'; import type { VerifyCallback } from 'passport-google-oauth20'; import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface'; import Noco from '~/Noco'; import { UsersService } from '~/services/users/users.service'; import { BaseUser, Plugin, User } from '~/models'; import { sanitiseUserObj } from '~/utils'; -import {Request} from 'express' @Injectable() export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { diff --git a/packages/nocodb/src/types/express.d.ts b/packages/nocodb/src/types/express.d.ts index c74cd6cca6..dc68aac2cc 100644 --- a/packages/nocodb/src/types/express.d.ts +++ b/packages/nocodb/src/types/express.d.ts @@ -1,23 +1,4 @@ -import * as express from 'express'; -import { Express } from 'express-serve-static-core'; import type { UserType } from 'nocodb-sdk'; -import { User } from '~/models'; - -// declare global { -// namespace Express { -// interface Request { -// id?: string; -// ncWorkspaceId?: string; -// ncProjectId?: string; -// user?: any; -// } -// } -// } -// -// interface TokenData { -// userId: string; -// iat: string; -// } declare module 'express-serve-static-core' { interface Request { ncWorkspaceId?: string; diff --git a/packages/nocodb/tests/unit/test_meta.db b/packages/nocodb/tests/unit/test_meta.db index 767c6c59c5..f348c5026b 100644 Binary files a/packages/nocodb/tests/unit/test_meta.db and b/packages/nocodb/tests/unit/test_meta.db differ diff --git a/packages/nocodb/tests/unit/tsconfig.ee.json b/packages/nocodb/tests/unit/tsconfig.ee.json index 8263593f20..adf6aeec5e 100644 --- a/packages/nocodb/tests/unit/tsconfig.ee.json +++ b/packages/nocodb/tests/unit/tsconfig.ee.json @@ -50,7 +50,8 @@ "dom" ], "types": [ - "mocha", "node" + "mocha", + "node" ], "typeRoots": [ "../../src/types", diff --git a/packages/nocodb/tests/unit/tsconfig.json b/packages/nocodb/tests/unit/tsconfig.json index 35ec0b3c1f..377a5d6e71 100644 --- a/packages/nocodb/tests/unit/tsconfig.json +++ b/packages/nocodb/tests/unit/tsconfig.json @@ -50,9 +50,9 @@ "dom" ], "types": [ - "mocha", "node" + "mocha", + "node" ], - "typeRoots": [ "../../src/types", "../../node_modules/@types" diff --git a/packages/nocodb/tsconfig.json b/packages/nocodb/tsconfig.json index 7e2cd8aa22..a9f79b3ffb 100644 --- a/packages/nocodb/tsconfig.json +++ b/packages/nocodb/tsconfig.json @@ -1,6 +1,8 @@ { "ts-node": { - "require": ["tsconfig-paths/register"] + "require": [ + "tsconfig-paths/register" + ] }, "compilerOptions": { "module": "commonjs", @@ -23,10 +25,19 @@ "resolveJsonModule": true, "esModuleInterop": true, "paths": { - "src/*": ["./src/*"], - "~/*": ["./src/*"], - "@/*": ["./src/*"] + "src/*": [ + "./src/*" + ], + "~/*": [ + "./src/*" + ], + "@/*": [ + "./src/*" + ] }, - "typeRoots": ["./src/types","./node_modules/@types", ] + "typeRoots": [ + "./src/types", + "./node_modules/@types" + ] } }