Browse Source

Merge pull request #6914 from nocodb/nc-refactor/misc

refactor: Use proper request type in controller
pull/6918/head
Pranav C 1 year ago committed by GitHub
parent
commit
b2e32bc443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/nocodb/src/controllers/api-tokens.controller.ts
  2. 17
      packages/nocodb/src/controllers/attachments-secure.controller.ts
  3. 25
      packages/nocodb/src/controllers/attachments.controller.ts
  4. 13
      packages/nocodb/src/controllers/audits.controller.ts
  5. 29
      packages/nocodb/src/controllers/auth/auth.controller.ts
  6. 15
      packages/nocodb/src/controllers/base-users.controller.ts
  7. 11
      packages/nocodb/src/controllers/bases.controller.ts
  8. 17
      packages/nocodb/src/controllers/bulk-data-alias.controller.ts
  9. 11
      packages/nocodb/src/controllers/columns.controller.ts
  10. 7
      packages/nocodb/src/controllers/data-alias-export.controller.ts
  11. 17
      packages/nocodb/src/controllers/data-alias-nested.controller.ts
  12. 33
      packages/nocodb/src/controllers/data-alias.controller.ts
  13. 27
      packages/nocodb/src/controllers/data-table.controller.ts
  14. 27
      packages/nocodb/src/controllers/datas.controller.ts
  15. 9
      packages/nocodb/src/controllers/filters.controller.ts
  16. 12
      packages/nocodb/src/controllers/form-columns.controller.ts
  17. 6
      packages/nocodb/src/controllers/forms.controller.ts
  18. 5
      packages/nocodb/src/controllers/galleries.controller.ts
  19. 2
      packages/nocodb/src/controllers/grid-columns.controller.ts
  20. 4
      packages/nocodb/src/controllers/grids.controller.ts
  21. 13
      packages/nocodb/src/controllers/hooks.controller.ts
  22. 5
      packages/nocodb/src/controllers/kanbans.controller.ts
  23. 5
      packages/nocodb/src/controllers/maps.controller.ts
  24. 2
      packages/nocodb/src/controllers/model-visibilities.controller.ts
  25. 11
      packages/nocodb/src/controllers/notifications.controller.ts
  26. 9
      packages/nocodb/src/controllers/org-tokens.controller.ts
  27. 11
      packages/nocodb/src/controllers/org-users.controller.ts
  28. 4
      packages/nocodb/src/controllers/plugins.controller.ts
  29. 19
      packages/nocodb/src/controllers/public-datas.controller.ts
  30. 5
      packages/nocodb/src/controllers/public-metas.controller.ts
  31. 11
      packages/nocodb/src/controllers/shared-bases.controller.ts
  32. 6
      packages/nocodb/src/controllers/sorts.controller.ts
  33. 5
      packages/nocodb/src/controllers/sources.controller.ts
  34. 6
      packages/nocodb/src/controllers/sync.controller.ts
  35. 7
      packages/nocodb/src/controllers/utils.controller.ts
  36. 4
      packages/nocodb/src/controllers/view-columns.controller.ts
  37. 15
      packages/nocodb/src/controllers/views.controller.ts
  38. 3
      packages/nocodb/src/guards/global/global.guard.ts
  39. 5
      packages/nocodb/src/helpers/catchError.ts
  40. 12
      packages/nocodb/src/interface/config.ts
  41. 12
      packages/nocodb/src/modules/jobs/jobs.controller.ts
  42. 7
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts
  43. 9
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  44. 7
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
  45. 7
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts
  46. 3
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts
  47. 3
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts
  48. 3
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts
  49. 5
      packages/nocodb/src/services/api-tokens.service.ts
  50. 2
      packages/nocodb/src/services/app-hooks/interfaces.ts
  51. 5
      packages/nocodb/src/services/attachments.service.ts
  52. 3
      packages/nocodb/src/services/base-users/base-users.service.ts
  53. 11
      packages/nocodb/src/services/bases.service.ts
  54. 5
      packages/nocodb/src/services/columns.service.ts
  55. 9
      packages/nocodb/src/services/filters.service.ts
  56. 3
      packages/nocodb/src/services/form-columns.service.ts
  57. 5
      packages/nocodb/src/services/forms.service.ts
  58. 5
      packages/nocodb/src/services/galleries.service.ts
  59. 3
      packages/nocodb/src/services/grid-columns.service.ts
  60. 5
      packages/nocodb/src/services/grids.service.ts
  61. 17
      packages/nocodb/src/services/hooks.service.ts
  62. 5
      packages/nocodb/src/services/kanbans.service.ts
  63. 5
      packages/nocodb/src/services/maps.service.ts
  64. 3
      packages/nocodb/src/services/model-visibilities.service.ts
  65. 3
      packages/nocodb/src/services/notifications.service.ts
  66. 5
      packages/nocodb/src/services/org-tokens.service.ts
  67. 8
      packages/nocodb/src/services/org-users.service.ts
  68. 5
      packages/nocodb/src/services/plugins.service.ts
  69. 8
      packages/nocodb/src/services/shared-bases.service.ts
  70. 7
      packages/nocodb/src/services/sorts.service.ts
  71. 7
      packages/nocodb/src/services/sources.service.ts
  72. 7
      packages/nocodb/src/services/sync.service.ts
  73. 3
      packages/nocodb/src/services/tables.service.ts
  74. 11
      packages/nocodb/src/services/users/users.service.ts
  75. 5
      packages/nocodb/src/services/view-columns.service.ts
  76. 19
      packages/nocodb/src/services/views.service.ts
  77. 3
      packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts
  78. 3
      packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts
  79. 5
      packages/nocodb/src/strategies/google.strategy/google.strategy.ts
  80. 14
      packages/nocodb/src/types/express.d.ts
  81. BIN
      packages/nocodb/tests/unit/test_meta.db
  82. 7
      packages/nocodb/tests/unit/tsconfig.ee.json
  83. 12
      packages/nocodb/tests/unit/tsconfig.json
  84. 22
      packages/nocodb/tsconfig.json

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

@ -6,9 +6,10 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { ApiTokensService } from '~/services/api-tokens.service'; import { ApiTokensService } from '~/services/api-tokens.service';
@ -25,7 +26,7 @@ export class ApiTokensController {
'/api/v2/meta/bases/:baseId/api-tokens', '/api/v2/meta/bases/:baseId/api-tokens',
]) ])
@Acl('baseApiTokenList') @Acl('baseApiTokenList')
async apiTokenList(@Request() req) { async apiTokenList(@Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.apiTokensService.apiTokenList({ userId: req['user'].id }), await this.apiTokensService.apiTokenList({ userId: req['user'].id }),
); );
@ -37,7 +38,7 @@ export class ApiTokensController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('baseApiTokenCreate') @Acl('baseApiTokenCreate')
async apiTokenCreate(@Request() req, @Body() body) { async apiTokenCreate(@Req() req: Request, @Body() body) {
return await this.apiTokensService.apiTokenCreate({ return await this.apiTokensService.apiTokenCreate({
tokenBody: body, tokenBody: body,
userId: req['user'].id, userId: req['user'].id,
@ -50,7 +51,7 @@ export class ApiTokensController {
'/api/v2/meta/bases/:baseId/api-tokens/:token', '/api/v2/meta/bases/:baseId/api-tokens/:token',
]) ])
@Acl('baseApiTokenDelete') @Acl('baseApiTokenDelete')
async apiTokenDelete(@Request() req, @Param('token') token: string) { async apiTokenDelete(@Req() req: Request, @Param('token') token: string) {
return await this.apiTokensService.apiTokenDelete({ return await this.apiTokensService.apiTokenDelete({
token, token,
user: req['user'], user: req['user'],

17
packages/nocodb/src/controllers/attachments-secure.controller.ts

@ -6,8 +6,8 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
Response, Res,
UploadedFiles, UploadedFiles,
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
@ -15,8 +15,8 @@ import {
import hash from 'object-hash'; import hash from 'object-hash';
import moment from 'moment'; import moment from 'moment';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { Response as ResponseType } from 'express'; import { Response } from 'express';
import type { Request as RequestType } from 'express'; import type { Request } from 'express';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { AttachmentsService } from '~/services/attachments.service'; import { AttachmentsService } from '~/services/attachments.service';
@ -34,7 +34,7 @@ export class AttachmentsSecureController {
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload( async upload(
@UploadedFiles() files: Array<FileType>, @UploadedFiles() files: Array<FileType>,
@Request() req: RequestType & { user: { id: string } }, @Req() req: Request & { user: { id: string } },
) { ) {
const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`; const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`;
@ -53,7 +53,7 @@ export class AttachmentsSecureController {
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
async uploadViaURL( async uploadViaURL(
@Body() body: Array<AttachmentReqType>, @Body() body: Array<AttachmentReqType>,
@Request() req: RequestType & { user: { id: string } }, @Req() req: Request & { user: { id: string } },
) { ) {
const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`; const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`;
@ -67,10 +67,7 @@ export class AttachmentsSecureController {
} }
@Get('/dltemp/:param(*)') @Get('/dltemp/:param(*)')
async fileReadv3( async fileReadv3(@Param('param') param: string, @Res() res: Response) {
@Param('param') param: string,
@Response() res: ResponseType,
) {
try { try {
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); const fpath = await PresignedUrl.getPath(`dltemp/${param}`);

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

@ -7,14 +7,14 @@ import {
Param, Param,
Post, Post,
Query, Query,
Request, Req,
Response, Res,
UploadedFiles, UploadedFiles,
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { Request as RequestType, Response as ResponseType } from 'express'; import { Request, Response } from 'express';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import { UploadAllowedInterceptor } from '~/interceptors/is-upload-allowed/is-upload-allowed.interceptor'; import { UploadAllowedInterceptor } from '~/interceptors/is-upload-allowed/is-upload-allowed.interceptor';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
@ -30,10 +30,7 @@ export class AttachmentsController {
@Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload']) @Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload'])
@HttpCode(200) @HttpCode(200)
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload( async upload(@UploadedFiles() files: Array<FileType>, @Req() req: Request) {
@UploadedFiles() files: Array<FileType>,
@Request() req: RequestType,
) {
const attachments = await this.attachmentsService.upload({ const attachments = await this.attachmentsService.upload({
files: files, files: files,
path: req.query?.path?.toString(), path: req.query?.path?.toString(),
@ -50,7 +47,7 @@ export class AttachmentsController {
async uploadViaURL( async uploadViaURL(
@Body() body: Array<AttachmentReqType>, @Body() body: Array<AttachmentReqType>,
@Query('path') path: string, @Query('path') path: string,
@Request() req: any, @Req() req: Request,
) { ) {
const attachments = await this.attachmentsService.uploadViaURL({ const attachments = await this.attachmentsService.uploadViaURL({
urls: body, urls: body,
@ -65,10 +62,7 @@ export class AttachmentsController {
// , getCacheMiddleware(), catchError(fileRead)); // , getCacheMiddleware(), catchError(fileRead));
@Get('/download/:filename(*)') @Get('/download/:filename(*)')
// This route will match any URL that starts with // This route will match any URL that starts with
async fileRead( async fileRead(@Param('filename') filename: string, @Res() res: Response) {
@Param('filename') filename: string,
@Response() res: ResponseType,
) {
try { try {
const file = await this.attachmentsService.getFile({ const file = await this.attachmentsService.getFile({
path: path.join('nc', 'uploads', filename), path: path.join('nc', 'uploads', filename),
@ -87,7 +81,7 @@ export class AttachmentsController {
@Param('param1') param1: string, @Param('param1') param1: string,
@Param('param2') param2: string, @Param('param2') param2: string,
@Param('filename') filename: string, @Param('filename') filename: string,
@Response() res: ResponseType, @Res() res: Response,
) { ) {
try { try {
const file = await this.attachmentsService.getFile({ const file = await this.attachmentsService.getFile({
@ -107,10 +101,7 @@ export class AttachmentsController {
} }
@Get('/dltemp/:param(*)') @Get('/dltemp/:param(*)')
async fileReadv3( async fileReadv3(@Param('param') param: string, @Res() res: Response) {
@Param('param') param: string,
@Response() res: ResponseType,
) {
try { try {
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); const fpath = await PresignedUrl.getPath(`dltemp/${param}`);

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

@ -7,9 +7,10 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { AuditsService } from '~/services/audits.service'; import { AuditsService } from '~/services/audits.service';
@ -24,7 +25,7 @@ export class AuditsController {
@Post(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments']) @Post(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments'])
@HttpCode(200) @HttpCode(200)
@Acl('commentRow') @Acl('commentRow')
async commentRow(@Request() req) { async commentRow(@Req() req: Request) {
return await this.auditsService.commentRow({ return await this.auditsService.commentRow({
user: (req as any).user, user: (req as any).user,
body: req.body, body: req.body,
@ -46,7 +47,7 @@ export class AuditsController {
@Get(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments']) @Get(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments'])
@Acl('commentList') @Acl('commentList')
async commentList(@Request() req) { async commentList(@Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.auditsService.commentList({ query: req.query }), await this.auditsService.commentList({ query: req.query }),
); );
@ -59,7 +60,7 @@ export class AuditsController {
@Acl('commentUpdate') @Acl('commentUpdate')
async commentUpdate( async commentUpdate(
@Param('auditId') auditId: string, @Param('auditId') auditId: string,
@Request() req, @Req() req: Request,
@Body() body: any, @Body() body: any,
) { ) {
return await this.auditsService.commentUpdate({ return await this.auditsService.commentUpdate({
@ -74,14 +75,14 @@ export class AuditsController {
'/api/v2/meta/bases/:baseId/audits/', '/api/v2/meta/bases/:baseId/audits/',
]) ])
@Acl('auditList') @Acl('auditList')
async auditList(@Request() req, @Param('baseId') baseId: string) { async auditList(@Req() req: Request, @Param('baseId') baseId: string) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.auditsService.auditList({ await this.auditsService.auditList({
query: req.query, query: req.query,
baseId, baseId,
}), }),
{ {
count: this.auditsService.auditCount({ baseId }), count: await this.auditsService.auditCount({ baseId }),
...req.query, ...req.query,
}, },
); );

29
packages/nocodb/src/controllers/auth/auth.controller.ts

@ -5,10 +5,11 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { extractRolesObj } from 'nocodb-sdk'; import { extractRolesObj } from 'nocodb-sdk';
@ -41,7 +42,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async signup(@Request() req: any, @Response() res: any): Promise<any> { async signup(@Req() req: Request, @Res() res: Response): Promise<any> {
if (this.config.get('auth', { infer: true }).disableEmailAuth) { if (this.config.get('auth', { infer: true }).disableEmailAuth) {
NcError.forbidden('Email authentication is disabled'); NcError.forbidden('Email authentication is disabled');
} }
@ -61,7 +62,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async refreshToken(@Request() req: any, @Response() res: any): Promise<any> { async refreshToken(@Req() req: Request, @Res() res: Response): Promise<any> {
res.json( res.json(
await this.usersService.refreshToken({ await this.usersService.refreshToken({
body: req.body, body: req.body,
@ -78,7 +79,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard, AuthGuard('local')) @UseGuards(PublicApiLimiterGuard, AuthGuard('local'))
@HttpCode(200) @HttpCode(200)
async signin(@Request() req, @Response() res) { async signin(@Req() req: Request, @Res() res: Response) {
if (this.config.get('auth', { infer: true }).disableEmailAuth) { if (this.config.get('auth', { infer: true }).disableEmailAuth) {
NcError.forbidden('Email authentication is disabled'); NcError.forbidden('Email authentication is disabled');
} }
@ -89,7 +90,7 @@ export class AuthController {
@UseGuards(GlobalGuard) @UseGuards(GlobalGuard)
@Post('/api/v1/auth/user/signout') @Post('/api/v1/auth/user/signout')
@HttpCode(200) @HttpCode(200)
async signOut(@Request() req, @Response() res): Promise<any> { async signOut(@Req() req: Request, @Res() res: Response): Promise<any> {
if (!(req as any).isAuthenticated()) { if (!(req as any).isAuthenticated()) {
NcError.forbidden('Not allowed'); NcError.forbidden('Not allowed');
} }
@ -104,7 +105,7 @@ export class AuthController {
@Post(`/auth/google/genTokenByCode`) @Post(`/auth/google/genTokenByCode`)
@HttpCode(200) @HttpCode(200)
@UseGuards(PublicApiLimiterGuard, AuthGuard('google')) @UseGuards(PublicApiLimiterGuard, AuthGuard('google'))
async googleSignin(@Request() req, @Response() res) { async googleSignin(@Req() req: Request, @Res() res: Response) {
await this.setRefreshToken({ req, res }); await this.setRefreshToken({ req, res });
res.json(await this.usersService.login(req.user, req)); res.json(await this.usersService.login(req.user, req));
} }
@ -117,7 +118,7 @@ export class AuthController {
@Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me']) @Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me'])
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
async me(@Request() req) { async me(@Req() req: Request) {
const user = { const user = {
...req.user, ...req.user,
roles: extractRolesObj(req.user.roles), roles: extractRolesObj(req.user.roles),
@ -137,7 +138,7 @@ export class AuthController {
scope: 'org', scope: 'org',
}) })
@HttpCode(200) @HttpCode(200)
async passwordChange(@Request() req: any): Promise<any> { async passwordChange(@Req() req: Request): Promise<any> {
if (!(req as any).isAuthenticated()) { if (!(req as any).isAuthenticated()) {
NcError.forbidden('Not allowed'); NcError.forbidden('Not allowed');
} }
@ -158,7 +159,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async passwordForgot(@Request() req: any): Promise<any> { async passwordForgot(@Req() req: Request): Promise<any> {
await this.usersService.passwordForgot({ await this.usersService.passwordForgot({
siteUrl: (req as any).ncSiteUrl, siteUrl: (req as any).ncSiteUrl,
body: req.body, body: req.body,
@ -190,7 +191,7 @@ export class AuthController {
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async passwordReset( async passwordReset(
@Request() req: any, @Req() req: Request,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
@Body() body: any, @Body() body: any,
): Promise<any> { ): Promise<any> {
@ -210,7 +211,7 @@ export class AuthController {
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async emailVerification( async emailVerification(
@Request() req: any, @Req() req: Request,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
): Promise<any> { ): Promise<any> {
await this.usersService.emailVerification({ await this.usersService.emailVerification({
@ -227,8 +228,8 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
async renderPasswordReset( async renderPasswordReset(
@Request() req: any, @Req() req: Request,
@Response() res: any, @Res() res: Response,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
): Promise<any> { ): Promise<any> {
try { try {

15
packages/nocodb/src/controllers/base-users.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ProjectUserReqType } from 'nocodb-sdk'; import { ProjectUserReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { BaseUsersService } from '~/services/base-users/base-users.service'; import { BaseUsersService } from '~/services/base-users/base-users.service';
@ -27,7 +28,7 @@ export class BaseUsersController {
'/api/v2/meta/bases/:baseId/users', '/api/v2/meta/bases/:baseId/users',
]) ])
@Acl('userList') @Acl('userList')
async userList(@Param('baseId') baseId: string, @Request() req) { async userList(@Param('baseId') baseId: string, @Req() req: Request) {
return { return {
users: await this.baseUsersService.userList({ users: await this.baseUsersService.userList({
baseId, baseId,
@ -44,7 +45,7 @@ export class BaseUsersController {
@Acl('userInvite') @Acl('userInvite')
async userInvite( async userInvite(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Request() req, @Req() req: Request,
@Body() body: ProjectUserReqType, @Body() body: ProjectUserReqType,
): Promise<any> { ): Promise<any> {
// todo: move this to a service // todo: move this to a service
@ -66,7 +67,7 @@ export class BaseUsersController {
async baseUserUpdate( async baseUserUpdate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('userId') userId: string, @Param('userId') userId: string,
@Request() req, @Req() req: Request,
@Body() @Body()
body: ProjectUserReqType & { body: ProjectUserReqType & {
base_id: string; base_id: string;
@ -91,7 +92,7 @@ export class BaseUsersController {
async baseUserDelete( async baseUserDelete(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('userId') userId: string, @Param('userId') userId: string,
@Request() req, @Req() req: Request,
): Promise<any> { ): Promise<any> {
await this.baseUsersService.baseUserDelete({ await this.baseUsersService.baseUserDelete({
baseId, baseId,
@ -112,7 +113,7 @@ export class BaseUsersController {
async baseUserInviteResend( async baseUserInviteResend(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('userId') userId: string, @Param('userId') userId: string,
@Request() req, @Req() req: Request,
@Body() body: ProjectUserReqType, @Body() body: ProjectUserReqType,
): Promise<any> { ): Promise<any> {
await this.baseUsersService.baseUserInviteResend({ await this.baseUsersService.baseUserInviteResend({
@ -133,7 +134,7 @@ export class BaseUsersController {
@Acl('baseUserMetaUpdate') @Acl('baseUserMetaUpdate')
async baseUserMetaUpdate( async baseUserMetaUpdate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Request() req, @Req() req: Request,
@Body() body: ProjectUserReqType, @Body() body: ProjectUserReqType,
): Promise<any> { ): Promise<any> {
return await this.baseUsersService.baseUserMetaUpdate({ return await this.baseUsersService.baseUserMetaUpdate({

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

@ -8,9 +8,10 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import isDocker from 'is-docker'; import isDocker from 'is-docker';
import { ProjectReqType } from 'nocodb-sdk'; import { ProjectReqType } from 'nocodb-sdk';
import type { BaseType } from 'nocodb-sdk'; import type { BaseType } from 'nocodb-sdk';
@ -32,7 +33,7 @@ export class BasesController {
scope: 'org', scope: 'org',
}) })
@Get(['/api/v1/db/meta/projects/', '/api/v2/meta/bases/']) @Get(['/api/v1/db/meta/projects/', '/api/v2/meta/bases/'])
async list(@Query() queryParams: Record<string, any>, @Request() req) { async list(@Query() queryParams: Record<string, any>, @Req() req: Request) {
const bases = await this.projectsService.baseList({ const bases = await this.projectsService.baseList({
user: req.user, user: req.user,
query: queryParams, query: queryParams,
@ -76,7 +77,7 @@ export class BasesController {
async baseUpdate( async baseUpdate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: Record<string, any>, @Body() body: Record<string, any>,
@Request() req, @Req() req: Request,
) { ) {
const base = await this.projectsService.baseUpdate({ const base = await this.projectsService.baseUpdate({
baseId, baseId,
@ -90,7 +91,7 @@ export class BasesController {
@Acl('baseDelete') @Acl('baseDelete')
@Delete(['/api/v1/db/meta/projects/:baseId', '/api/v2/meta/bases/:baseId']) @Delete(['/api/v1/db/meta/projects/:baseId', '/api/v2/meta/bases/:baseId'])
async baseDelete(@Param('baseId') baseId: string, @Request() req) { async baseDelete(@Param('baseId') baseId: string, @Req() req: Request) {
const deleted = await this.projectsService.baseSoftDelete({ const deleted = await this.projectsService.baseSoftDelete({
baseId, baseId,
user: req.user, user: req.user,
@ -105,7 +106,7 @@ export class BasesController {
}) })
@Post(['/api/v1/db/meta/projects', '/api/v2/meta/bases']) @Post(['/api/v1/db/meta/projects', '/api/v2/meta/bases'])
@HttpCode(200) @HttpCode(200)
async baseCreate(@Body() baseBody: ProjectReqType, @Request() req) { async baseCreate(@Body() baseBody: ProjectReqType, @Req() req: Request) {
const base = await this.projectsService.baseCreate({ const base = await this.projectsService.baseCreate({
base: baseBody, base: baseBody,
req, req,

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

@ -6,10 +6,11 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { BulkDataAliasService } from '~/services/bulk-data-alias.service'; import { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -24,8 +25,8 @@ export class BulkDataAliasController {
@HttpCode(200) @HttpCode(200)
@Acl('bulkDataInsert') @Acl('bulkDataInsert')
async bulkDataInsert( async bulkDataInsert(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -43,7 +44,7 @@ export class BulkDataAliasController {
@Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName']) @Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName'])
@Acl('bulkDataUpdate') @Acl('bulkDataUpdate')
async bulkDataUpdate( async bulkDataUpdate(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -60,7 +61,7 @@ export class BulkDataAliasController {
@Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all']) @Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all'])
@Acl('bulkDataUpdateAll') @Acl('bulkDataUpdateAll')
async bulkDataUpdateAll( async bulkDataUpdateAll(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -77,7 +78,7 @@ export class BulkDataAliasController {
@Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName']) @Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName'])
@Acl('bulkDataDelete') @Acl('bulkDataDelete')
async bulkDataDelete( async bulkDataDelete(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -95,7 +96,7 @@ export class BulkDataAliasController {
@Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all']) @Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all'])
@Acl('bulkDataDeleteAll') @Acl('bulkDataDeleteAll')
async bulkDataDeleteAll( async bulkDataDeleteAll(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
) { ) {

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

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ColumnReqType } from 'nocodb-sdk'; import { ColumnReqType } from 'nocodb-sdk';
import type { Column } from '~/models'; import type { Column } from '~/models';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
@ -31,7 +32,7 @@ export class ColumnsController {
async columnAdd( async columnAdd(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ColumnReqType, @Body() body: ColumnReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.columnsService.columnAdd({ return await this.columnsService.columnAdd({
tableId, tableId,
@ -49,7 +50,7 @@ export class ColumnsController {
async columnUpdate( async columnUpdate(
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@Body() body: ColumnReqType, @Body() body: ColumnReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.columnsService.columnUpdate({ return await this.columnsService.columnUpdate({
columnId: columnId, columnId: columnId,
@ -64,7 +65,7 @@ export class ColumnsController {
'/api/v2/meta/columns/:columnId', '/api/v2/meta/columns/:columnId',
]) ])
@Acl('columnDelete') @Acl('columnDelete')
async columnDelete(@Param('columnId') columnId: string, @Request() req: any) { async columnDelete(@Param('columnId') columnId: string, @Req() req: Request) {
return await this.columnsService.columnDelete({ return await this.columnsService.columnDelete({
columnId, columnId,
req, req,
@ -113,7 +114,7 @@ export class ColumnsController {
column: Partial<Column>; column: Partial<Column>;
}[]; }[];
}, },
@Request() req: any, @Req() req: Request,
) { ) {
return await this.columnsService.columnBulk(tableId, body, req); return await this.columnsService.columnBulk(tableId, body, req);
} }

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

@ -1,4 +1,5 @@
import { Controller, Get, Request, Response, UseGuards } from '@nestjs/common'; import { Controller, Get, Req, Res, UseGuards } from '@nestjs/common';
import { Request, Response } from 'express';
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service'; import { DatasService } from '~/services/datas.service';
@ -17,7 +18,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/views/:viewName/export/excel', '/api/v1/db/data/:orgs/:baseName/:tableName/views/:viewName/export/excel',
]) ])
@Acl('exportExcel') @Acl('exportExcel')
async excelDataExport(@Request() req, @Response() res) { async excelDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } = const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req); await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view; let targetView = view;
@ -44,7 +45,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/export/csv', '/api/v1/db/data/:orgs/:baseName/:tableName/export/csv',
]) ])
@Acl('exportCsv') @Acl('exportCsv')
async csvDataExport(@Request() req, @Response() res) { async csvDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } = const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req); await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view; let targetView = view;

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

@ -5,9 +5,10 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { DataAliasNestedService } from '~/services/data-alias-nested.service'; import { DataAliasNestedService } from '~/services/data-alias-nested.service';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -22,7 +23,7 @@ export class DataAliasNestedController {
@Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/mm/:columnName']) @Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/mm/:columnName'])
@Acl('mmList') @Acl('mmList')
async mmList( async mmList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -42,7 +43,7 @@ export class DataAliasNestedController {
]) ])
@Acl('mmExcludedList') @Acl('mmExcludedList')
async mmExcludedList( async mmExcludedList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -62,7 +63,7 @@ export class DataAliasNestedController {
]) ])
@Acl('hmExcludedList') @Acl('hmExcludedList')
async hmExcludedList( async hmExcludedList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -82,7 +83,7 @@ export class DataAliasNestedController {
]) ])
@Acl('btExcludedList') @Acl('btExcludedList')
async btExcludedList( async btExcludedList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -102,7 +103,7 @@ export class DataAliasNestedController {
@Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/hm/:columnName']) @Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/hm/:columnName'])
@Acl('hmList') @Acl('hmList')
async hmList( async hmList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -122,7 +123,7 @@ export class DataAliasNestedController {
]) ])
@Acl('relationDataRemove') @Acl('relationDataRemove')
async relationDataRemove( async relationDataRemove(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -148,7 +149,7 @@ export class DataAliasNestedController {
@Acl('relationDataAdd') @Acl('relationDataAdd')
@HttpCode(200) @HttpCode(200)
async relationDataAdd( async relationDataAdd(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,

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

@ -8,10 +8,11 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { parseHrtimeToMilliSeconds } from '~/helpers'; import { parseHrtimeToMilliSeconds } from '~/helpers';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -30,8 +31,8 @@ export class DataAliasController {
]) ])
@Acl('dataList') @Acl('dataList')
async dataList( async dataList(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -62,7 +63,7 @@ export class DataAliasController {
]) ])
@Acl('dataFindOne') @Acl('dataFindOne')
async dataFindOne( async dataFindOne(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -81,7 +82,7 @@ export class DataAliasController {
]) ])
@Acl('dataGroupBy') @Acl('dataGroupBy')
async dataGroupBy( async dataGroupBy(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -100,8 +101,8 @@ export class DataAliasController {
]) ])
@Acl('dataCount') @Acl('dataCount')
async dataCount( async dataCount(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -123,7 +124,7 @@ export class DataAliasController {
@HttpCode(200) @HttpCode(200)
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -146,7 +147,7 @@ export class DataAliasController {
]) ])
@Acl('dataUpdate') @Acl('dataUpdate')
async dataUpdate( async dataUpdate(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -170,7 +171,7 @@ export class DataAliasController {
]) ])
@Acl('dataDelete') @Acl('dataDelete')
async dataDelete( async dataDelete(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -191,7 +192,7 @@ export class DataAliasController {
]) ])
@Acl('dataRead') @Acl('dataRead')
async dataRead( async dataRead(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -216,8 +217,8 @@ export class DataAliasController {
]) ])
@Acl('dataExist') @Acl('dataExist')
async dataExist( async dataExist(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -242,8 +243,8 @@ export class DataAliasController {
]) ])
@Acl('groupedDataList') @Acl('groupedDataList')
async groupedDataList( async groupedDataList(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,

27
packages/nocodb/src/controllers/data-table.controller.ts

@ -8,10 +8,11 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { DataTableService } from '~/services/data-table.service'; import { DataTableService } from '~/services/data-table.service';
import { parseHrtimeToMilliSeconds } from '~/helpers'; import { parseHrtimeToMilliSeconds } from '~/helpers';
@ -27,8 +28,8 @@ export class DataTableController {
@Get('/api/v2/tables/:modelId/records') @Get('/api/v2/tables/:modelId/records')
@Acl('dataList') @Acl('dataList')
async dataList( async dataList(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
) { ) {
@ -46,8 +47,8 @@ export class DataTableController {
@Get(['/api/v2/tables/:modelId/records/count']) @Get(['/api/v2/tables/:modelId/records/count'])
@Acl('dataCount') @Acl('dataCount')
async dataCount( async dataCount(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
) { ) {
@ -64,7 +65,7 @@ export class DataTableController {
@HttpCode(200) @HttpCode(200)
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Body() body: any, @Body() body: any,
@ -80,7 +81,7 @@ export class DataTableController {
@Patch(['/api/v2/tables/:modelId/records']) @Patch(['/api/v2/tables/:modelId/records'])
@Acl('dataUpdate') @Acl('dataUpdate')
async dataUpdate( async dataUpdate(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('rowId') _rowId: string, @Param('rowId') _rowId: string,
@ -96,7 +97,7 @@ export class DataTableController {
@Delete(['/api/v2/tables/:modelId/records']) @Delete(['/api/v2/tables/:modelId/records'])
@Acl('dataDelete') @Acl('dataDelete')
async dataDelete( async dataDelete(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('rowId') _rowId: string, @Param('rowId') _rowId: string,
@ -112,7 +113,7 @@ export class DataTableController {
@Get(['/api/v2/tables/:modelId/records/:rowId']) @Get(['/api/v2/tables/:modelId/records/:rowId'])
@Acl('dataRead') @Acl('dataRead')
async dataRead( async dataRead(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -128,7 +129,7 @@ export class DataTableController {
@Get(['/api/v2/tables/:modelId/links/:columnId/records/:rowId']) @Get(['/api/v2/tables/:modelId/links/:columnId/records/:rowId'])
@Acl('nestedDataList') @Acl('nestedDataList')
async nestedDataList( async nestedDataList(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@ -146,7 +147,7 @@ export class DataTableController {
@Post(['/api/v2/tables/:modelId/links/:columnId/records/:rowId']) @Post(['/api/v2/tables/:modelId/links/:columnId/records/:rowId'])
@Acl('nestedDataLink') @Acl('nestedDataLink')
async nestedLink( async nestedLink(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@ -168,7 +169,7 @@ export class DataTableController {
@Delete(['/api/v2/tables/:modelId/links/:columnId/records/:rowId']) @Delete(['/api/v2/tables/:modelId/links/:columnId/records/:rowId'])
@Acl('nestedDataUnlink') @Acl('nestedDataUnlink')
async nestedUnlink( async nestedUnlink(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,

27
packages/nocodb/src/controllers/datas.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service'; import { DatasService } from '~/services/datas.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -22,7 +23,7 @@ export class DatasController {
@Get('/data/:viewId/') @Get('/data/:viewId/')
@Acl('dataList') @Acl('dataList')
async dataList(@Request() req, @Param('viewId') viewId: string) { async dataList(@Req() req: Request, @Param('viewId') viewId: string) {
return await this.datasService.dataListByViewId({ return await this.datasService.dataListByViewId({
viewId: viewId, viewId: viewId,
query: req.query, query: req.query,
@ -32,7 +33,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/mm/:colId') @Get('/data/:viewId/:rowId/mm/:colId')
@Acl('mmList') @Acl('mmList')
async mmList( async mmList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -48,7 +49,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/mm/:colId/exclude') @Get('/data/:viewId/:rowId/mm/:colId/exclude')
@Acl('mmExcludedList') @Acl('mmExcludedList')
async mmExcludedList( async mmExcludedList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -64,7 +65,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/hm/:colId/exclude') @Get('/data/:viewId/:rowId/hm/:colId/exclude')
@Acl('hmExcludedList') @Acl('hmExcludedList')
async hmExcludedList( async hmExcludedList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -80,7 +81,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/bt/:colId/exclude') @Get('/data/:viewId/:rowId/bt/:colId/exclude')
@Acl('btExcludedList') @Acl('btExcludedList')
async btExcludedList( async btExcludedList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -96,7 +97,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/hm/:colId') @Get('/data/:viewId/:rowId/hm/:colId')
@Acl('hmList') @Acl('hmList')
async hmList( async hmList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -112,7 +113,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId') @Get('/data/:viewId/:rowId')
@Acl('dataRead') @Acl('dataRead')
async dataRead( async dataRead(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
) { ) {
@ -127,7 +128,7 @@ export class DatasController {
@HttpCode(200) @HttpCode(200)
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: any, @Body() body: any,
) { ) {
@ -141,7 +142,7 @@ export class DatasController {
@Patch('/data/:viewId/:rowId') @Patch('/data/:viewId/:rowId')
@Acl('dataUpdate') @Acl('dataUpdate')
async dataUpdate( async dataUpdate(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Body() body: any, @Body() body: any,
@ -157,7 +158,7 @@ export class DatasController {
@Delete('/data/:viewId/:rowId') @Delete('/data/:viewId/:rowId')
@Acl('dataDelete') @Acl('dataDelete')
async dataDelete( async dataDelete(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
) { ) {
@ -171,7 +172,7 @@ export class DatasController {
@Delete('/data/:viewId/:rowId/:relationType/:colId/:childId') @Delete('/data/:viewId/:rowId/:relationType/:colId/:childId')
@Acl('relationDataDelete') @Acl('relationDataDelete')
async relationDataDelete( async relationDataDelete(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('relationType') relationType: string, @Param('relationType') relationType: string,
@ -193,7 +194,7 @@ export class DatasController {
@HttpCode(200) @HttpCode(200)
@Acl('relationDataAdd') @Acl('relationDataAdd')
async relationDataAdd( async relationDataAdd(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('relationType') relationType: string, @Param('relationType') relationType: string,

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

@ -10,6 +10,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { FilterReqType } from 'nocodb-sdk'; import { FilterReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -44,7 +45,7 @@ export class FiltersController {
async filterCreate( async filterCreate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: FilterReqType, @Body() body: FilterReqType,
@Req() req, @Req() req: Request,
) { ) {
const filter = await this.filtersService.filterCreate({ const filter = await this.filtersService.filterCreate({
filter: body, filter: body,
@ -64,7 +65,7 @@ export class FiltersController {
async hookFilterCreate( async hookFilterCreate(
@Param('hookId') hookId: string, @Param('hookId') hookId: string,
@Body() body: FilterReqType, @Body() body: FilterReqType,
@Req() req, @Req() req: Request,
) { ) {
const filter = await this.filtersService.hookFilterCreate({ const filter = await this.filtersService.hookFilterCreate({
filter: body, filter: body,
@ -102,7 +103,7 @@ export class FiltersController {
async filterUpdate( async filterUpdate(
@Param('filterId') filterId: string, @Param('filterId') filterId: string,
@Body() body: FilterReqType, @Body() body: FilterReqType,
@Req() req, @Req() req: Request,
) { ) {
const filter = await this.filtersService.filterUpdate({ const filter = await this.filtersService.filterUpdate({
filterId: filterId, filterId: filterId,
@ -118,7 +119,7 @@ export class FiltersController {
'/api/v2/meta/filters/:filterId', '/api/v2/meta/filters/:filterId',
]) ])
@Acl('filterDelete') @Acl('filterDelete')
async filterDelete(@Param('filterId') filterId: string, @Req() req) { async filterDelete(@Param('filterId') filterId: string, @Req() req: Request) {
const filter = await this.filtersService.filterDelete({ const filter = await this.filtersService.filterDelete({
req, req,
filterId, filterId,

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

@ -1,11 +1,5 @@
import { import { Body, Controller, Param, Patch, Req, UseGuards } from '@nestjs/common';
Body, import { Request } from 'express';
Controller,
Param,
Patch,
Request,
UseGuards,
} from '@nestjs/common';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { FormColumnsService } from '~/services/form-columns.service'; import { FormColumnsService } from '~/services/form-columns.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -27,7 +21,7 @@ export class FormColumnsController {
@Param('formViewColumnId') formViewColumnId: string, @Param('formViewColumnId') formViewColumnId: string,
@Body() formViewColumnbody: FormColumnUpdateReqType, @Body() formViewColumnbody: FormColumnUpdateReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.formColumnsService.columnUpdate({ return await this.formColumnsService.columnUpdate({
formViewColumnId, formViewColumnId,

6
packages/nocodb/src/controllers/forms.controller.ts

@ -7,9 +7,9 @@ import {
Patch, Patch,
Post, Post,
Req, Req,
Request,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ViewCreateReqType } from 'nocodb-sdk'; import { ViewCreateReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { FormsService } from '~/services/forms.service'; import { FormsService } from '~/services/forms.service';
@ -39,7 +39,7 @@ export class FormsController {
async formViewCreate( async formViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const view = await this.formsService.formViewCreate({ const view = await this.formsService.formViewCreate({
body, body,
@ -57,7 +57,7 @@ export class FormsController {
async formViewUpdate( async formViewUpdate(
@Param('formViewId') formViewId: string, @Param('formViewId') formViewId: string,
@Body() body, @Body() body,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.formsService.formViewUpdate({ return await this.formsService.formViewUpdate({
formViewId, formViewId,

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

@ -9,6 +9,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GalleryUpdateReqType, ViewCreateReqType } from 'nocodb-sdk'; import { GalleryUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { GalleriesService } from '~/services/galleries.service'; import { GalleriesService } from '~/services/galleries.service';
@ -40,7 +41,7 @@ export class GalleriesController {
async galleryViewCreate( async galleryViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.galleriesService.galleryViewCreate({ return await this.galleriesService.galleryViewCreate({
gallery: body, gallery: body,
@ -60,7 +61,7 @@ export class GalleriesController {
@Param('galleryViewId') galleryViewId: string, @Param('galleryViewId') galleryViewId: string,
@Body() body: GalleryUpdateReqType, @Body() body: GalleryUpdateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.galleriesService.galleryViewUpdate({ return await this.galleriesService.galleryViewUpdate({
galleryViewId, galleryViewId,

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

@ -37,7 +37,7 @@ export class GridColumnsController {
@Param('gridViewColumnId') gridViewColumnId: string, @Param('gridViewColumnId') gridViewColumnId: string,
@Body() body: GridColumnReqType, @Body() body: GridColumnReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return this.gridColumnsService.gridColumnUpdate({ return this.gridColumnsService.gridColumnUpdate({
gridViewColumnId, gridViewColumnId,

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

@ -28,7 +28,7 @@ export class GridsController {
async gridViewCreate( async gridViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const view = await this.gridsService.gridViewCreate({ const view = await this.gridsService.gridViewCreate({
grid: body, grid: body,
@ -42,7 +42,7 @@ export class GridsController {
async gridViewUpdate( async gridViewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body, @Body() body,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.gridsService.gridViewUpdate({ return await this.gridsService.gridViewUpdate({
viewId, viewId,

13
packages/nocodb/src/controllers/hooks.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { HookReqType, HookTestReqType } from 'nocodb-sdk'; import { HookReqType, HookTestReqType } from 'nocodb-sdk';
import type { HookType } from 'nocodb-sdk'; import type { HookType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
@ -41,7 +42,7 @@ export class HooksController {
async hookCreate( async hookCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: HookReqType, @Body() body: HookReqType,
@Request() req: any, @Req() req: Request,
) { ) {
const hook = await this.hooksService.hookCreate({ const hook = await this.hooksService.hookCreate({
hook: body, hook: body,
@ -53,7 +54,7 @@ export class HooksController {
@Delete(['/api/v1/db/meta/hooks/:hookId', '/api/v2/meta/hooks/:hookId']) @Delete(['/api/v1/db/meta/hooks/:hookId', '/api/v2/meta/hooks/:hookId'])
@Acl('hookDelete') @Acl('hookDelete')
async hookDelete(@Param('hookId') hookId: string, @Request() req: any) { async hookDelete(@Param('hookId') hookId: string, @Req() req: Request) {
return await this.hooksService.hookDelete({ hookId, req }); return await this.hooksService.hookDelete({ hookId, req });
} }
@ -62,7 +63,7 @@ export class HooksController {
async hookUpdate( async hookUpdate(
@Param('hookId') hookId: string, @Param('hookId') hookId: string,
@Body() body: HookReqType, @Body() body: HookReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.hooksService.hookUpdate({ hookId, hook: body, req }); return await this.hooksService.hookUpdate({ hookId, hook: body, req });
} }
@ -73,7 +74,7 @@ export class HooksController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('hookTest') @Acl('hookTest')
async hookTest(@Body() body: HookTestReqType, @Request() req: any) { async hookTest(@Body() body: HookTestReqType, @Req() req: Request) {
try { try {
await this.hooksService.hookTest({ await this.hooksService.hookTest({
hookTest: { hookTest: {
@ -115,7 +116,7 @@ export class HooksController {
'/api/v2/meta/hooks/:hookId/logs', '/api/v2/meta/hooks/:hookId/logs',
]) ])
@Acl('hookLogList') @Acl('hookLogList')
async hookLogList(@Param('hookId') hookId: string, @Request() req: any) { async hookLogList(@Param('hookId') hookId: string, @Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.hooksService.hookLogList({ await this.hooksService.hookLogList({
query: req.query, query: req.query,

5
packages/nocodb/src/controllers/kanbans.controller.ts

@ -9,6 +9,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ViewCreateReqType } from 'nocodb-sdk'; import { ViewCreateReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { KanbansService } from '~/services/kanbans.service'; import { KanbansService } from '~/services/kanbans.service';
@ -40,7 +41,7 @@ export class KanbansController {
async kanbanViewCreate( async kanbanViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.kanbansService.kanbanViewCreate({ return await this.kanbansService.kanbanViewCreate({
tableId, tableId,
@ -59,7 +60,7 @@ export class KanbansController {
@Param('kanbanViewId') kanbanViewId: string, @Param('kanbanViewId') kanbanViewId: string,
@Body() body, @Body() body,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.kanbansService.kanbanViewUpdate({ return await this.kanbansService.kanbanViewUpdate({
kanbanViewId, kanbanViewId,

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

@ -9,6 +9,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { MapUpdateReqType, ViewCreateReqType } from 'nocodb-sdk'; import { MapUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { MapsService } from '~/services/maps.service'; import { MapsService } from '~/services/maps.service';
@ -35,7 +36,7 @@ export class MapsController {
async mapViewCreate( async mapViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const view = await this.mapsService.mapViewCreate({ const view = await this.mapsService.mapViewCreate({
tableId, tableId,
@ -52,7 +53,7 @@ export class MapsController {
@Param('mapViewId') mapViewId: string, @Param('mapViewId') mapViewId: string,
@Body() body: MapUpdateReqType, @Body() body: MapUpdateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.mapsService.mapViewUpdate({ return await this.mapsService.mapViewUpdate({
mapViewId: mapViewId, mapViewId: mapViewId,

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

@ -30,7 +30,7 @@ export class ModelVisibilitiesController {
async xcVisibilityMetaSetAll( async xcVisibilityMetaSetAll(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: any, @Body() body: any,
@Req() req: any, @Req() req: Request,
) { ) {
await this.modelVisibilitiesService.xcVisibilityMetaSetAll({ await this.modelVisibilitiesService.xcVisibilityMetaSetAll({
visibilityRule: body, visibilityRule: body,

11
packages/nocodb/src/controllers/notifications.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { NotificationsService } from '~/services/notifications.service'; import { NotificationsService } from '~/services/notifications.service';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { extractProps } from '~/helpers/extractProps'; import { extractProps } from '~/helpers/extractProps';
@ -22,7 +23,7 @@ export class NotificationsController {
@Get('/api/v1/notifications') @Get('/api/v1/notifications')
// @Acl('notificationList') // @Acl('notificationList')
async notificationList(@Request() req) { async notificationList(@Req() req: Request) {
return this.notificationsService.notificationList({ return this.notificationsService.notificationList({
user: req.user, user: req.user,
is_deleted: false, is_deleted: false,
@ -36,7 +37,7 @@ export class NotificationsController {
async notificationUpdate( async notificationUpdate(
@Param('notificationId') notificationId, @Param('notificationId') notificationId,
@Body() body, @Body() body,
@Request() req, @Req() req: Request,
) { ) {
return this.notificationsService.notificationUpdate({ return this.notificationsService.notificationUpdate({
notificationId, notificationId,
@ -47,7 +48,7 @@ export class NotificationsController {
@Post('/api/v1/notifications/mark-all-read') @Post('/api/v1/notifications/mark-all-read')
@HttpCode(200) @HttpCode(200)
async markAllRead(@Request() req) { async markAllRead(@Req() req: Request) {
return this.notificationsService.markAllRead({ return this.notificationsService.markAllRead({
user: req.user, user: req.user,
}); });
@ -57,7 +58,7 @@ export class NotificationsController {
// @Acl('notificationDelete') // @Acl('notificationDelete')
async notificationDelete( async notificationDelete(
@Param('notificationId') notificationId, @Param('notificationId') notificationId,
@Request() req, @Req() req: Request,
) { ) {
return this.notificationsService.notificationUpdate({ return this.notificationsService.notificationUpdate({
notificationId, notificationId,

9
packages/nocodb/src/controllers/org-tokens.controller.ts

@ -6,9 +6,10 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ApiTokenReqType } from 'nocodb-sdk'; import { ApiTokenReqType } from 'nocodb-sdk';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { getConditionalHandler } from '~/helpers/getHandler'; import { getConditionalHandler } from '~/helpers/getHandler';
@ -30,7 +31,7 @@ export class OrgTokensController {
scope: 'org', scope: 'org',
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async apiTokenList(@Request() req) { async apiTokenList(@Req() req: Request) {
return await getConditionalHandler( return await getConditionalHandler(
this.orgTokensService.apiTokenList, this.orgTokensService.apiTokenList,
this.orgTokensEeService.apiTokenListEE, this.orgTokensEeService.apiTokenListEE,
@ -46,7 +47,7 @@ export class OrgTokensController {
scope: 'org', scope: 'org',
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async apiTokenCreate(@Request() req, @Body() body: ApiTokenReqType) { async apiTokenCreate(@Req() req: Request, @Body() body: ApiTokenReqType) {
return await this.orgTokensService.apiTokenCreate({ return await this.orgTokensService.apiTokenCreate({
apiToken: body, apiToken: body,
user: req['user'], user: req['user'],
@ -60,7 +61,7 @@ export class OrgTokensController {
// allowedRoles: [OrgUserRoles.SUPER], // allowedRoles: [OrgUserRoles.SUPER],
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async apiTokenDelete(@Request() req, @Param('token') token: string) { async apiTokenDelete(@Req() req: Request, @Param('token') token: string) {
await this.orgTokensService.apiTokenDelete({ await this.orgTokensService.apiTokenDelete({
token, token,
user: req['user'], user: req['user'],

11
packages/nocodb/src/controllers/org-users.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { OrgUserRoles } from 'nocodb-sdk'; import { OrgUserRoles } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -29,7 +30,7 @@ export class OrgUsersController {
allowedRoles: [OrgUserRoles.SUPER_ADMIN], allowedRoles: [OrgUserRoles.SUPER_ADMIN],
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async userList(@Request() req) { async userList(@Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.orgUsersService.userList({ await this.orgUsersService.userList({
query: req.query, query: req.query,
@ -75,7 +76,7 @@ export class OrgUsersController {
allowedRoles: [OrgUserRoles.SUPER_ADMIN], allowedRoles: [OrgUserRoles.SUPER_ADMIN],
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async userAdd(@Body() body, @Request() req) { async userAdd(@Body() body, @Req() req: Request) {
const result = await this.orgUsersService.userAdd({ const result = await this.orgUsersService.userAdd({
user: req.body, user: req.body,
req, req,
@ -104,7 +105,7 @@ export class OrgUsersController {
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async userInviteResend( async userInviteResend(
@Request() req, @Req() req: Request,
@Param('userId') userId: string, @Param('userId') userId: string,
): Promise<any> { ): Promise<any> {
await this.orgUsersService.userInviteResend({ await this.orgUsersService.userInviteResend({
@ -122,7 +123,7 @@ export class OrgUsersController {
allowedRoles: [OrgUserRoles.SUPER_ADMIN], allowedRoles: [OrgUserRoles.SUPER_ADMIN],
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async generateResetUrl(@Request() req, @Param('userId') userId: string) { async generateResetUrl(@Req() req: Request, @Param('userId') userId: string) {
const result = await this.orgUsersService.generateResetUrl({ const result = await this.orgUsersService.generateResetUrl({
siteUrl: req.ncSiteUrl, siteUrl: req.ncSiteUrl,
userId, userId,

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

@ -48,7 +48,7 @@ export class PluginsController {
@Acl('pluginTest', { @Acl('pluginTest', {
scope: 'org', scope: 'org',
}) })
async pluginTest(@Body() body: any, @Req() req: any) { async pluginTest(@Body() body: any, @Req() req: Request) {
return await this.pluginsService.pluginTest({ body: body, req }); return await this.pluginsService.pluginTest({ body: body, req });
} }
@ -70,7 +70,7 @@ export class PluginsController {
async pluginUpdate( async pluginUpdate(
@Body() body: any, @Body() body: any,
@Param('pluginId') pluginId: string, @Param('pluginId') pluginId: string,
@Req() req: any, @Req() req: Request,
) { ) {
const plugin = await this.pluginsService.pluginUpdate({ const plugin = await this.pluginsService.pluginUpdate({
pluginId: pluginId, pluginId: pluginId,

19
packages/nocodb/src/controllers/public-datas.controller.ts

@ -4,10 +4,11 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { PublicDatasService } from '~/services/public-datas.service'; import { PublicDatasService } from '~/services/public-datas.service';
import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard'; import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard';
@ -22,7 +23,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/rows', '/api/v2/public/shared-view/:sharedViewUuid/rows',
]) ])
async dataList( async dataList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
const pagedResponse = await this.publicDatasService.dataList({ const pagedResponse = await this.publicDatasService.dataList({
@ -38,7 +39,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/groupby', '/api/v2/public/shared-view/:sharedViewUuid/groupby',
]) ])
async dataGroupBy( async dataGroupBy(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
return await this.publicDatasService.dataGroupBy({ return await this.publicDatasService.dataGroupBy({
@ -53,7 +54,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/group/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/group/:columnId',
]) ])
async groupedDataList( async groupedDataList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
) { ) {
@ -73,7 +74,7 @@ export class PublicDatasController {
@HttpCode(200) @HttpCode(200)
@UseInterceptors(AnyFilesInterceptor()) @UseInterceptors(AnyFilesInterceptor())
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
const insertResult = await this.publicDatasService.dataInsert({ const insertResult = await this.publicDatasService.dataInsert({
@ -81,7 +82,7 @@ export class PublicDatasController {
password: req.headers?.['xc-password'] as string, password: req.headers?.['xc-password'] as string,
body: req.body?.data, body: req.body?.data,
siteUrl: (req as any).ncSiteUrl, siteUrl: (req as any).ncSiteUrl,
files: req.files, files: req.files as any[],
}); });
return insertResult; return insertResult;
@ -92,7 +93,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/nested/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/nested/:columnId',
]) ])
async relDataList( async relDataList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
) { ) {
@ -111,7 +112,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId',
]) ])
async publicMmList( async publicMmList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@ -131,7 +132,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId',
]) ])
async publicHmList( async publicHmList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,

5
packages/nocodb/src/controllers/public-metas.controller.ts

@ -1,4 +1,5 @@
import { Controller, Get, Param, Request, UseGuards } from '@nestjs/common'; import { Controller, Get, Param, Req, UseGuards } from '@nestjs/common';
import { Request } from 'express';
import { PublicMetasService } from '~/services/public-metas.service'; import { PublicMetasService } from '~/services/public-metas.service';
import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard'; import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard';
@ -12,7 +13,7 @@ export class PublicMetasController {
'/api/v2/public/shared-view/:sharedViewUuid/meta', '/api/v2/public/shared-view/:sharedViewUuid/meta',
]) ])
async viewMetaGet( async viewMetaGet(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
return await this.publicMetasService.viewMetaGet({ return await this.publicMetasService.viewMetaGet({

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

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { SharedBasesService } from '~/services/shared-bases.service'; import { SharedBasesService } from '~/services/shared-bases.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -27,7 +28,7 @@ export class SharedBasesController {
@HttpCode(200) @HttpCode(200)
@Acl('createSharedBaseLink') @Acl('createSharedBaseLink')
async createSharedBaseLink( async createSharedBaseLink(
@Request() req, @Req() req: Request,
@Body() body: any, @Body() body: any,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
): Promise<any> { ): Promise<any> {
@ -48,7 +49,7 @@ export class SharedBasesController {
]) ])
@Acl('updateSharedBaseLink') @Acl('updateSharedBaseLink')
async updateSharedBaseLink( async updateSharedBaseLink(
@Request() req, @Req() req: Request,
@Body() body: any, @Body() body: any,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
): Promise<any> { ): Promise<any> {
@ -70,7 +71,7 @@ export class SharedBasesController {
@Acl('disableSharedBaseLink') @Acl('disableSharedBaseLink')
async disableSharedBaseLink( async disableSharedBaseLink(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Request() req: any, @Req() req: Request,
): Promise<any> { ): Promise<any> {
const sharedBase = await this.sharedBasesService.disableSharedBaseLink({ const sharedBase = await this.sharedBasesService.disableSharedBaseLink({
baseId, baseId,
@ -86,7 +87,7 @@ export class SharedBasesController {
]) ])
@Acl('getSharedBaseLink') @Acl('getSharedBaseLink')
async getSharedBaseLink( async getSharedBaseLink(
@Request() req, @Req() req: Request,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
): Promise<any> { ): Promise<any> {
const sharedBase = await this.sharedBasesService.getSharedBaseLink({ const sharedBase = await this.sharedBasesService.getSharedBaseLink({

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

@ -44,7 +44,7 @@ export class SortsController {
async sortCreate( async sortCreate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: SortReqType, @Body() body: SortReqType,
@Req() req, @Req() req: Request,
) { ) {
const sort = await this.sortsService.sortCreate({ const sort = await this.sortsService.sortCreate({
sort: body, sort: body,
@ -68,7 +68,7 @@ export class SortsController {
async sortUpdate( async sortUpdate(
@Param('sortId') sortId: string, @Param('sortId') sortId: string,
@Body() body: SortReqType, @Body() body: SortReqType,
@Req() req, @Req() req: Request,
) { ) {
const sort = await this.sortsService.sortUpdate({ const sort = await this.sortsService.sortUpdate({
sortId, sortId,
@ -80,7 +80,7 @@ export class SortsController {
@Delete(['/api/v1/db/meta/sorts/:sortId', '/api/v2/meta/sorts/:sortId']) @Delete(['/api/v1/db/meta/sorts/:sortId', '/api/v2/meta/sorts/:sortId'])
@Acl('sortDelete') @Acl('sortDelete')
async sortDelete(@Param('sortId') sortId: string, @Req() req) { async sortDelete(@Param('sortId') sortId: string, @Req() req: Request) {
const sort = await this.sortsService.sortDelete({ const sort = await this.sortsService.sortDelete({
sortId, sortId,
req, req,

5
packages/nocodb/src/controllers/sources.controller.ts

@ -4,9 +4,10 @@ import {
Get, Get,
Param, Param,
Patch, Patch,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { BaseReqType } from 'nocodb-sdk'; import { BaseReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -45,7 +46,7 @@ export class SourcesController {
@Param('sourceId') sourceId: string, @Param('sourceId') sourceId: string,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: BaseReqType, @Body() body: BaseReqType,
@Request() req: any, @Req() req: Request,
) { ) {
const source = await this.sourcesService.baseUpdate({ const source = await this.sourcesService.baseUpdate({
sourceId, sourceId,

6
packages/nocodb/src/controllers/sync.controller.ts

@ -48,7 +48,7 @@ export class SyncController {
async syncCreate( async syncCreate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: any, @Body() body: any,
@Req() req, @Req() req: Request,
@Param('sourceId') sourceId?: string, @Param('sourceId') sourceId?: string,
) { ) {
return await this.syncService.syncCreate({ return await this.syncService.syncCreate({
@ -62,7 +62,7 @@ export class SyncController {
@Delete(['/api/v1/db/meta/syncs/:syncId', '/api/v2/meta/syncs/:syncId']) @Delete(['/api/v1/db/meta/syncs/:syncId', '/api/v2/meta/syncs/:syncId'])
@Acl('syncSourceDelete') @Acl('syncSourceDelete')
async syncDelete(@Param('syncId') syncId: string, @Req() req: any) { async syncDelete(@Param('syncId') syncId: string, @Req() req: Request) {
return await this.syncService.syncDelete({ return await this.syncService.syncDelete({
syncId: syncId, syncId: syncId,
req, req,
@ -74,7 +74,7 @@ export class SyncController {
async syncUpdate( async syncUpdate(
@Param('syncId') syncId: string, @Param('syncId') syncId: string,
@Body() body: any, @Body() body: any,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.syncService.syncUpdate({ return await this.syncService.syncUpdate({
syncId: syncId, syncId: syncId,

7
packages/nocodb/src/controllers/utils.controller.ts

@ -6,9 +6,10 @@ import {
Get, Get,
HttpCode, HttpCode,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { UtilsService } from '~/services/utils.service'; import { UtilsService } from '~/services/utils.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -48,7 +49,7 @@ export class UtilsController {
scope: 'org', scope: 'org',
}) })
@HttpCode(200) @HttpCode(200)
async testConnection(@Body() body: any, @Request() _req: any) { async testConnection(@Body() body: any, @Req() _req: Request) {
body.pool = { body.pool = {
min: 0, min: 0,
max: 1, max: 1,
@ -63,7 +64,7 @@ export class UtilsController {
'/api/v2/meta/nocodb/info', '/api/v2/meta/nocodb/info',
'/api/v1/meta/nocodb/info', '/api/v1/meta/nocodb/info',
]) ])
async appInfo(@Request() req) { async appInfo(@Req() req: Request) {
return await this.utilsService.appInfo({ return await this.utilsService.appInfo({
req: { req: {
ncSiteUrl: (req as any).ncSiteUrl, ncSiteUrl: (req as any).ncSiteUrl,

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

@ -43,7 +43,7 @@ export class ViewColumnsController {
async columnAdd( async columnAdd(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewColumnReqType, @Body() body: ViewColumnReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const viewColumn = await this.viewColumnsService.columnAdd({ const viewColumn = await this.viewColumnsService.columnAdd({
viewId, viewId,
@ -62,7 +62,7 @@ export class ViewColumnsController {
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@Body() body: ViewColumnReqType, @Body() body: ViewColumnReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const result = await this.viewColumnsService.columnUpdate({ const result = await this.viewColumnsService.columnUpdate({
viewId, viewId,

15
packages/nocodb/src/controllers/views.controller.ts

@ -8,9 +8,10 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ViewUpdateReqType } from 'nocodb-sdk'; import { ViewUpdateReqType } from 'nocodb-sdk';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
@ -28,7 +29,7 @@ export class ViewsController {
'/api/v2/meta/tables/:tableId/views', '/api/v2/meta/tables/:tableId/views',
]) ])
@Acl('viewList') @Acl('viewList')
async viewList(@Param('tableId') tableId: string, @Request() req) { async viewList(@Param('tableId') tableId: string, @Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.viewsService.viewList({ await this.viewsService.viewList({
tableId, tableId,
@ -42,7 +43,7 @@ export class ViewsController {
async viewUpdate( async viewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType, @Body() body: ViewUpdateReqType,
@Request() req, @Req() req: Request,
) { ) {
const result = await this.viewsService.viewUpdate({ const result = await this.viewsService.viewUpdate({
viewId, viewId,
@ -55,7 +56,7 @@ export class ViewsController {
@Delete(['/api/v1/db/meta/views/:viewId', '/api/v2/meta/views/:viewId']) @Delete(['/api/v1/db/meta/views/:viewId', '/api/v2/meta/views/:viewId'])
@Acl('viewDelete') @Acl('viewDelete')
async viewDelete(@Param('viewId') viewId: string, @Request() req) { async viewDelete(@Param('viewId') viewId: string, @Req() req: Request) {
const result = await this.viewsService.viewDelete({ const result = await this.viewsService.viewDelete({
viewId, viewId,
user: req.user, user: req.user,
@ -101,7 +102,7 @@ export class ViewsController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('shareView') @Acl('shareView')
async shareView(@Param('viewId') viewId: string, @Request() req) { async shareView(@Param('viewId') viewId: string, @Req() req: Request) {
return await this.viewsService.shareView({ viewId, user: req.user, req }); return await this.viewsService.shareView({ viewId, user: req.user, req });
} }
@ -126,7 +127,7 @@ export class ViewsController {
async shareViewUpdate( async shareViewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType, @Body() body: ViewUpdateReqType,
@Request() req, @Req() req: Request,
) { ) {
return await this.viewsService.shareViewUpdate({ return await this.viewsService.shareViewUpdate({
viewId, viewId,
@ -141,7 +142,7 @@ export class ViewsController {
'/api/v2/meta/views/:viewId/share', '/api/v2/meta/views/:viewId/share',
]) ])
@Acl('shareViewDelete') @Acl('shareViewDelete')
async shareViewDelete(@Param('viewId') viewId: string, @Request() req) { async shareViewDelete(@Param('viewId') viewId: string, @Req() req: Request) {
return await this.viewsService.shareViewDelete({ return await this.viewsService.shareViewDelete({
viewId, viewId,
user: req.user, user: req.user,

3
packages/nocodb/src/guards/global/global.guard.ts

@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { lastValueFrom, Observable } from 'rxjs'; import { lastValueFrom, Observable } from 'rxjs';
import { extractRolesObj } from 'nocodb-sdk'; import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import type { ExecutionContext } from '@nestjs/common'; import type { ExecutionContext } from '@nestjs/common';
import { JwtStrategy } from '~/strategies/jwt.strategy'; import { JwtStrategy } from '~/strategies/jwt.strategy';
@ -75,7 +76,7 @@ export class GlobalGuard extends AuthGuard(['jwt']) {
} }
private async authenticate( private async authenticate(
req: any, req: Request,
user: any = { user: any = {
roles: { roles: {
guest: true, guest: true,

5
packages/nocodb/src/helpers/catchError.ts

@ -1,3 +1,4 @@
import type { NextFunction, Request, Response } from 'express';
import type { ErrorObject } from 'ajv'; import type { ErrorObject } from 'ajv';
export enum DBError { export enum DBError {
@ -384,9 +385,9 @@ export function extractDBError(error): {
} }
export default function ( export default function (
requestHandler: (req: any, res: any, next?: any) => any, requestHandler: (req: Request, res: Response, next?: NextFunction) => any,
) { ) {
return async function (req: any, res: any, next: any) { return async function (req: Request, res: Response, next?: NextFunction) {
try { try {
return await requestHandler(req, res, next); return await requestHandler(req, res, next);
} catch (e) { } catch (e) {

12
packages/nocodb/src/interface/config.ts

@ -1,6 +1,9 @@
import type { UserType } from 'nocodb-sdk';
import type { ReqId } from 'pino-http';
import type { Handler } from 'express'; import type { Handler } from 'express';
import type * as e from 'express'; import type * as e from 'express';
import type { Knex } from 'knex'; import type { Knex } from 'knex';
import type { User } from '~/models';
export interface Route { export interface Route {
path: string; path: string;
@ -319,3 +322,12 @@ export interface AppConfig {
mainSubDomain: string; mainSubDomain: string;
dashboardPath: string; dashboardPath: string;
} }
export interface NcRequest {
id?: ReqId;
user?: UserType | User;
ncWorkspaceId?: string;
ncProjectId?: string;
headers?: Record<string, string | undefined> | IncomingHttpHeaders;
clientIp?: string;
}

12
packages/nocodb/src/modules/jobs/jobs.controller.ts

@ -4,14 +4,16 @@ import {
HttpCode, HttpCode,
Inject, Inject,
Post, Post,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { OnEvent } from '@nestjs/event-emitter'; import { OnEvent } from '@nestjs/event-emitter';
import { customAlphabet } from 'nanoid'; import { customAlphabet } from 'nanoid';
import { ModuleRef } from '@nestjs/core'; import { ModuleRef } from '@nestjs/core';
import { JobsRedisService } from './redis/jobs-redis.service'; import { JobsRedisService } from './redis/jobs-redis.service';
import type { Response } from 'express';
import type { OnModuleInit } from '@nestjs/common'; import type { OnModuleInit } from '@nestjs/common';
import { JobStatus } from '~/interface/Jobs'; import { JobStatus } from '~/interface/Jobs';
import { JobEvents } from '~/interface/Jobs'; import { JobEvents } from '~/interface/Jobs';
@ -46,8 +48,8 @@ export class JobsController implements OnModuleInit {
@Post('/jobs/listen') @Post('/jobs/listen')
@HttpCode(200) @HttpCode(200)
async listen( async listen(
@Response() res, @Res() res: Response & { resId?: string },
@Request() req, @Req() req: Request,
@Body() body: { _mid: number; data: { id: string } }, @Body() body: { _mid: number; data: { id: string } },
) { ) {
const { _mid = 0, data } = body; const { _mid = 0, data } = body;
@ -134,7 +136,7 @@ export class JobsController implements OnModuleInit {
res.on('close', () => { res.on('close', () => {
if (jobId && this.jobRooms[jobId]?.listeners) { if (jobId && this.jobRooms[jobId]?.listeners) {
this.jobRooms[jobId].listeners = this.jobRooms[jobId].listeners.filter( this.jobRooms[jobId].listeners = this.jobRooms[jobId].listeners.filter(
(r) => r.resId !== res.resId, (r) => r.resId !== (res as any).resId,
); );
} }
}); });

7
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts

@ -3,9 +3,10 @@ import {
HttpCode, HttpCode,
Inject, Inject,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { SyncSource } from '~/models'; import { SyncSource } from '~/models';
@ -24,7 +25,7 @@ export class AtImportController {
]) ])
@Acl('airtableImport') @Acl('airtableImport')
@HttpCode(200) @HttpCode(200)
async triggerSync(@Request() req) { async triggerSync(@Req() req: Request) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find((j) => j.data.syncId === req.params.syncId); const fnd = jobs.find((j) => j.data.syncId === req.params.syncId);
@ -69,7 +70,7 @@ export class AtImportController {
]) ])
@Acl('airtableImport') @Acl('airtableImport')
@HttpCode(200) @HttpCode(200)
async abortImport(@Request() _) { async abortImport() {
return {}; return {};
} }
} }

9
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts

@ -5,9 +5,10 @@ import {
Inject, Inject,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ProjectStatus } from 'nocodb-sdk'; import { ProjectStatus } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -34,7 +35,7 @@ export class DuplicateController {
scope: 'org', scope: 'org',
}) })
public async duplicateSharedBase( public async duplicateSharedBase(
@Request() req, @Req() req: Request,
@Param('workspaceId') _workspaceId: string, @Param('workspaceId') _workspaceId: string,
@Param('sharedBaseId') sharedBaseId: string, @Param('sharedBaseId') sharedBaseId: string,
@Body() @Body()
@ -101,7 +102,7 @@ export class DuplicateController {
@HttpCode(200) @HttpCode(200)
@Acl('duplicateBase') @Acl('duplicateBase')
async duplicateBase( async duplicateBase(
@Request() req, @Req() req: Request,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('sourceId') sourceId?: string, @Param('sourceId') sourceId?: string,
@Body() @Body()
@ -168,7 +169,7 @@ export class DuplicateController {
@HttpCode(200) @HttpCode(200)
@Acl('duplicateModel') @Acl('duplicateModel')
async duplicateModel( async duplicateModel(
@Request() req, @Req() req: Request,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('modelId') modelId?: string, @Param('modelId') modelId?: string,
@Body() @Body()

7
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 { Readable } from 'stream';
import type { UserType, ViewCreateReqType } from 'nocodb-sdk'; import type { UserType, ViewCreateReqType } from 'nocodb-sdk';
import type { LinkToAnotherRecordColumn, User, View } from '~/models'; import type { LinkToAnotherRecordColumn, User, View } from '~/models';
import type { NcRequest } from '~/interface/config';
import { import {
findWithIdentifier, findWithIdentifier,
generateUniqueName, generateUniqueName,
@ -64,7 +65,7 @@ export class ImportService {
data: data:
| { models: { model: any; views: any[]; hooks?: any[] }[] } | { models: { model: any; views: any[]; hooks?: any[] }[] }
| { model: any; views: any[]; hooks?: any[] }[]; | { model: any; views: any[]; hooks?: any[] }[];
req: any; req: NcRequest;
externalModels?: Model[]; externalModels?: Model[];
}) { }) {
const hrTime = initTime(); const hrTime = initTime();
@ -1051,7 +1052,7 @@ export class ImportService {
vw: Partial<View>, vw: Partial<View>,
views: View[], views: View[],
user: UserType, user: UserType,
req: any, req: NcRequest,
): Promise<View> { ): Promise<View> {
if (vw.is_default) { if (vw.is_default) {
const view = views.find((a) => a.is_default); const view = views.find((a) => a.is_default);
@ -1197,7 +1198,7 @@ export class ImportService {
url?: string; url?: string;
file?: any; file?: any;
}; };
req: any; req: NcRequest;
}) { }) {
const hrTime = initTime(); const hrTime = initTime();

7
packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts

@ -4,9 +4,10 @@ import {
Inject, Inject,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -24,7 +25,7 @@ export class MetaSyncController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('metaDiffSync') @Acl('metaDiffSync')
async metaDiffSync(@Param('baseId') baseId: string, @Request() req) { async metaDiffSync(@Param('baseId') baseId: string, @Req() req: Request) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(
(j) => j.name === JobTypes.MetaSync && j.data.baseId === baseId, (j) => j.name === JobTypes.MetaSync && j.data.baseId === baseId,
@ -57,7 +58,7 @@ export class MetaSyncController {
async baseMetaDiffSync( async baseMetaDiffSync(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('sourceId') sourceId: string, @Param('sourceId') sourceId: string,
@Request() req, @Req() req: Request,
) { ) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(

3
packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts

@ -1,6 +1,7 @@
import debug from 'debug'; import debug from 'debug';
import { Process, Processor } from '@nestjs/bull'; import { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull'; import { Job } from 'bull';
import type { NcRequest } from '~/interface/config';
import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs';
import { MetaDiffsService } from '~/services/meta-diffs.service'; import { MetaDiffsService } from '~/services/meta-diffs.service';
@ -18,7 +19,7 @@ export class MetaSyncProcessor {
baseId: string; baseId: string;
sourceId: string; sourceId: string;
user: any; user: any;
req: any; req: NcRequest;
} = job.data; } = job.data;
if (info.sourceId === 'all') { if (info.sourceId === 'all') {

3
packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts

@ -8,6 +8,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { BaseReqType } from 'nocodb-sdk'; import { BaseReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -29,7 +30,7 @@ export class SourceCreateController {
async baseCreate( async baseCreate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: BaseReqType, @Body() body: BaseReqType,
@Req() req, @Req() req: Request,
) { ) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(

3
packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts

@ -6,6 +6,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -26,7 +27,7 @@ export class SourceDeleteController {
'/api/v2/meta/bases/:baseId/sources/:sourceId', '/api/v2/meta/bases/:baseId/sources/:sourceId',
]) ])
@Acl('baseDelete') @Acl('baseDelete')
async baseDelete(@Param('sourceId') sourceId: string, @Req() req) { async baseDelete(@Param('sourceId') sourceId: string, @Req() req: Request) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(
(j) => j.name === JobTypes.BaseDelete && j.data.sourceId === sourceId, (j) => j.name === JobTypes.BaseDelete && j.data.sourceId === sourceId,

5
packages/nocodb/src/services/api-tokens.service.ts

@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk'; import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk';
import type { User } from '~/models'; import type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk'; import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
@ -17,7 +18,7 @@ export class ApiTokensService {
async apiTokenCreate(param: { async apiTokenCreate(param: {
userId: string; userId: string;
tokenBody: ApiTokenReqType; tokenBody: ApiTokenReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ApiTokenReq', 'swagger.json#/components/schemas/ApiTokenReq',
@ -36,7 +37,7 @@ export class ApiTokensService {
}); });
} }
async apiTokenDelete(param: { token; user: User; req: any }) { async apiTokenDelete(param: { token; user: User; req: NcRequest }) {
const apiToken = await ApiToken.getByToken(param.token); const apiToken = await ApiToken.getByToken(param.token);
if ( if (
!extractRolesObj(param.user.roles)[OrgUserRoles.SUPER_ADMIN] && !extractRolesObj(param.user.roles)[OrgUserRoles.SUPER_ADMIN] &&

2
packages/nocodb/src/services/app-hooks/interfaces.ts

@ -18,7 +18,7 @@ import type {
} from 'nocodb-sdk'; } from 'nocodb-sdk';
export interface NcBaseEvent extends NcBaseEvent { export interface NcBaseEvent extends NcBaseEvent {
req: any; req: NcRequest;
clientId?: string; clientId?: string;
} }

5
packages/nocodb/src/services/attachments.service.ts

@ -4,6 +4,7 @@ import { Injectable } from '@nestjs/common';
import { nanoid } from 'nanoid'; import { nanoid } from 'nanoid';
import slash from 'slash'; import slash from 'slash';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import Local from '~/plugins/storage/Local'; import Local from '~/plugins/storage/Local';
@ -15,7 +16,7 @@ import { utf8ify } from '~/helpers/stringHelpers';
export class AttachmentsService { export class AttachmentsService {
constructor(private readonly appHooksService: AppHooksService) {} constructor(private readonly appHooksService: AppHooksService) {}
async upload(param: { path?: string; files: FileType[]; req: any }) { async upload(param: { path?: string; files: FileType[]; req: NcRequest }) {
// TODO: add getAjvValidatorMw // TODO: add getAjvValidatorMw
const filePath = this.sanitizeUrlPath( const filePath = this.sanitizeUrlPath(
param.path?.toString()?.split('/') || [''], param.path?.toString()?.split('/') || [''],
@ -92,7 +93,7 @@ export class AttachmentsService {
async uploadViaURL(param: { async uploadViaURL(param: {
path?: string; path?: string;
urls: AttachmentReqType[]; urls: AttachmentReqType[];
req: any; req: NcRequest;
}) { }) {
// TODO: add getAjvValidatorMw // TODO: add getAjvValidatorMw
const filePath = this.sanitizeUrlPath( const filePath = this.sanitizeUrlPath(

3
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 * as ejs from 'ejs';
import validator from 'validator'; import validator from 'validator';
import type { ProjectUserReqType, UserType } from 'nocodb-sdk'; import type { ProjectUserReqType, UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import NocoCache from '~/cache/NocoCache'; import NocoCache from '~/cache/NocoCache';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import Noco from '~/Noco'; import Noco from '~/Noco';
@ -47,7 +48,7 @@ export class BaseUsersService {
async userInvite(param: { async userInvite(param: {
baseId: string; baseId: string;
baseUser: ProjectUserReqType; baseUser: ProjectUserReqType;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ProjectUserReq', 'swagger.json#/components/schemas/ProjectUserReq',

11
packages/nocodb/src/services/bases.service.ts

@ -13,6 +13,7 @@ import type {
ProjectUpdateReqType, ProjectUpdateReqType,
UserType, UserType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers'; import { populateMeta, validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -36,7 +37,7 @@ export class BasesService {
) {} ) {}
async baseList(param: { async baseList(param: {
user: { id: string; roles: Record<string, boolean> }; user: { id: string; roles?: string | Record<string, boolean> };
query?: any; query?: any;
}) { }) {
const bases = extractRolesObj(param.user?.roles)[OrgUserRoles.SUPER_ADMIN] const bases = extractRolesObj(param.user?.roles)[OrgUserRoles.SUPER_ADMIN]
@ -63,7 +64,7 @@ export class BasesService {
baseId: string; baseId: string;
base: ProjectUpdateReqType; base: ProjectUpdateReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ProjectUpdateReq', 'swagger.json#/components/schemas/ProjectUpdateReq',
@ -101,7 +102,7 @@ export class BasesService {
} }
} }
async baseSoftDelete(param: { baseId: any; user: UserType; req: any }) { async baseSoftDelete(param: { baseId: any; user: UserType; req: NcRequest }) {
const base = await Base.getWithInfo(param.baseId); const base = await Base.getWithInfo(param.baseId);
if (!base) { if (!base) {
@ -119,7 +120,7 @@ export class BasesService {
return true; return true;
} }
async baseCreate(param: { base: ProjectReqType; user: any; req: any }) { async baseCreate(param: { base: ProjectReqType; user: any; req: NcRequest }) {
validatePayload('swagger.json#/components/schemas/ProjectReq', param.base); validatePayload('swagger.json#/components/schemas/ProjectReq', param.base);
const baseId = await this.metaService.genNanoid(MetaTable.PROJECT); const baseId = await this.metaService.genNanoid(MetaTable.PROJECT);
@ -225,7 +226,7 @@ export class BasesService {
return base; return base;
} }
async createDefaultBase(param: { user: UserType; req: any }) { async createDefaultBase(param: { user: UserType; req: NcRequest }) {
const base = await this.baseCreate({ const base = await this.baseCreate({
base: { base: {
title: 'Getting Started', title: 'Getting Started',

5
packages/nocodb/src/services/columns.service.ts

@ -21,6 +21,7 @@ import type {
import type CustomKnex from '~/db/CustomKnex'; import type CustomKnex from '~/db/CustomKnex';
import type SqlClient from '~/db/sql-client/lib/SqlClient'; import type SqlClient from '~/db/sql-client/lib/SqlClient';
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2'; import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2';
import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2'; import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2';
@ -1030,7 +1031,7 @@ export class ColumnsService {
} }
async columnAdd(param: { async columnAdd(param: {
req: any; req: NcRequest;
tableId: string; tableId: string;
column: ColumnReqType; column: ColumnReqType;
user: UserType; user: UserType;
@ -2194,7 +2195,7 @@ export class ColumnsService {
column: Partial<Column>; column: Partial<Column>;
}[]; }[];
}, },
req: any, req: NcRequest,
) { ) {
// TODO validatePayload // TODO validatePayload

9
packages/nocodb/src/services/filters.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { FilterReqType, UserType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -14,7 +15,7 @@ export class FiltersService {
filter: FilterReqType; filter: FilterReqType;
hookId: any; hookId: any;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter); validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -41,7 +42,7 @@ export class FiltersService {
return Filter.rootFilterListByHook({ hookId: param.hookId }); return Filter.rootFilterListByHook({ hookId: param.hookId });
} }
async filterDelete(param: { filterId: string; req: any }) { async filterDelete(param: { filterId: string; req: NcRequest }) {
const filter = await Filter.get(param.filterId); const filter = await Filter.get(param.filterId);
if (!filter) { if (!filter) {
@ -62,7 +63,7 @@ export class FiltersService {
filter: FilterReqType; filter: FilterReqType;
viewId: string; viewId: string;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter); validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -86,7 +87,7 @@ export class FiltersService {
filter: FilterReqType; filter: FilterReqType;
filterId: string; filterId: string;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter); validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);

3
packages/nocodb/src/services/form-columns.service.ts

@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { FormViewColumn } from '~/models'; import { FormViewColumn } from '~/models';
@ -12,7 +13,7 @@ export class FormColumnsService {
formViewColumnId: string; formViewColumnId: string;
// todo: replace with FormColumnReq // todo: replace with FormColumnReq
formViewColumn: FormViewColumn; formViewColumn: FormViewColumn;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/FormColumnReq', 'swagger.json#/components/schemas/FormColumnReq',

5
packages/nocodb/src/services/forms.service.ts

@ -5,6 +5,7 @@ import type {
UserType, UserType,
ViewCreateReqType, ViewCreateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -23,7 +24,7 @@ export class FormsService {
tableId: string; tableId: string;
body: ViewCreateReqType; body: ViewCreateReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewCreateReq', 'swagger.json#/components/schemas/ViewCreateReq',
@ -55,7 +56,7 @@ export class FormsService {
async formViewUpdate(param: { async formViewUpdate(param: {
formViewId: string; formViewId: string;
form: FormUpdateReqType; form: FormUpdateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/FormUpdateReq', 'swagger.json#/components/schemas/FormUpdateReq',

5
packages/nocodb/src/services/galleries.service.ts

@ -5,6 +5,7 @@ import type {
UserType, UserType,
ViewCreateReqType, ViewCreateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -23,7 +24,7 @@ export class GalleriesService {
gallery: ViewCreateReqType; gallery: ViewCreateReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewCreateReq', 'swagger.json#/components/schemas/ViewCreateReq',
@ -48,7 +49,7 @@ export class GalleriesService {
async galleryViewUpdate(param: { async galleryViewUpdate(param: {
galleryViewId: string; galleryViewId: string;
gallery: GalleryUpdateReqType; gallery: GalleryUpdateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/GalleryUpdateReq', 'swagger.json#/components/schemas/GalleryUpdateReq',

3
packages/nocodb/src/services/grid-columns.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { GridColumnReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { GridViewColumn } from '~/models'; import { GridViewColumn } from '~/models';
@ -16,7 +17,7 @@ export class GridColumnsService {
async gridColumnUpdate(param: { async gridColumnUpdate(param: {
gridViewColumnId: string; gridViewColumnId: string;
grid: GridColumnReqType; grid: GridColumnReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/GridColumnReq', 'swagger.json#/components/schemas/GridColumnReq',

5
packages/nocodb/src/services/grids.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents, ViewTypes } from 'nocodb-sdk'; import { AppEvents, ViewTypes } from 'nocodb-sdk';
import type { GridUpdateReqType, ViewCreateReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -13,7 +14,7 @@ export class GridsService {
async gridViewCreate(param: { async gridViewCreate(param: {
tableId: string; tableId: string;
grid: ViewCreateReqType; grid: ViewCreateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewCreateReq', 'swagger.json#/components/schemas/ViewCreateReq',
@ -39,7 +40,7 @@ export class GridsService {
async gridViewUpdate(param: { async gridViewUpdate(param: {
viewId: string; viewId: string;
grid: GridUpdateReqType; grid: GridUpdateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/GridUpdateReq', 'swagger.json#/components/schemas/GridUpdateReq',

17
packages/nocodb/src/services/hooks.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { HookReqType, HookTestReqType, HookType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -37,7 +38,11 @@ export class HooksService {
return await HookLog.list({ fk_hook_id: param.hookId }, param.query); return await HookLog.list({ fk_hook_id: param.hookId }, param.query);
} }
async hookCreate(param: { tableId: string; hook: HookReqType; req: any }) { async hookCreate(param: {
tableId: string;
hook: HookReqType;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/HookReq', param.hook); validatePayload('swagger.json#/components/schemas/HookReq', param.hook);
this.validateHookPayload(param.hook.notification); this.validateHookPayload(param.hook.notification);
@ -55,7 +60,7 @@ export class HooksService {
return hook; return hook;
} }
async hookDelete(param: { hookId: string; req: any }) { async hookDelete(param: { hookId: string; req: NcRequest }) {
const hook = await Hook.get(param.hookId); const hook = await Hook.get(param.hookId);
if (!hook) { if (!hook) {
@ -70,7 +75,11 @@ export class HooksService {
return true; return true;
} }
async hookUpdate(param: { hookId: string; hook: HookReqType; req: any }) { async hookUpdate(param: {
hookId: string;
hook: HookReqType;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/HookReq', param.hook); validatePayload('swagger.json#/components/schemas/HookReq', param.hook);
const hook = await Hook.get(param.hookId); const hook = await Hook.get(param.hookId);
@ -97,7 +106,7 @@ export class HooksService {
async hookTest(param: { async hookTest(param: {
tableId: string; tableId: string;
hookTest: HookTestReqType; hookTest: HookTestReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/HookTestReq', 'swagger.json#/components/schemas/HookTestReq',

5
packages/nocodb/src/services/kanbans.service.ts

@ -5,6 +5,7 @@ import type {
UserType, UserType,
ViewCreateReqType, ViewCreateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -22,7 +23,7 @@ export class KanbansService {
tableId: string; tableId: string;
kanban: ViewCreateReqType; kanban: ViewCreateReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewCreateReq', 'swagger.json#/components/schemas/ViewCreateReq',
@ -50,7 +51,7 @@ export class KanbansService {
async kanbanViewUpdate(param: { async kanbanViewUpdate(param: {
kanbanViewId: string; kanbanViewId: string;
kanban: KanbanUpdateReqType; kanban: KanbanUpdateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/KanbanUpdateReq', 'swagger.json#/components/schemas/KanbanUpdateReq',

5
packages/nocodb/src/services/maps.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents, ViewTypes } from 'nocodb-sdk'; import { AppEvents, ViewTypes } from 'nocodb-sdk';
import type { MapUpdateReqType, UserType, ViewCreateReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -18,7 +19,7 @@ export class MapsService {
tableId: string; tableId: string;
map: ViewCreateReqType; map: ViewCreateReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewCreateReq', 'swagger.json#/components/schemas/ViewCreateReq',
@ -44,7 +45,7 @@ export class MapsService {
async mapViewUpdate(param: { async mapViewUpdate(param: {
mapViewId: string; mapViewId: string;
map: MapUpdateReqType; map: MapUpdateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/MapUpdateReq', param.map); validatePayload('swagger.json#/components/schemas/MapUpdateReq', param.map);

3
packages/nocodb/src/services/model-visibilities.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { VisibilityRuleReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -13,7 +14,7 @@ export class ModelVisibilitiesService {
async xcVisibilityMetaSetAll(param: { async xcVisibilityMetaSetAll(param: {
visibilityRule: VisibilityRuleReqType; visibilityRule: VisibilityRuleReqType;
baseId: string; baseId: string;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/VisibilityRuleReq', 'swagger.json#/components/schemas/VisibilityRuleReq',

3
packages/nocodb/src/services/notifications.service.ts

@ -6,6 +6,7 @@ import type {
} from '~/services/app-hooks/interfaces'; } from '~/services/app-hooks/interfaces';
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'; import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import type { UserType } from 'nocodb-sdk'; import type { UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -17,7 +18,7 @@ export class NotificationsService implements OnModuleInit, OnModuleDestroy {
protected async insertNotification( protected async insertNotification(
insertData: Partial<Notification>, insertData: Partial<Notification>,
req: any, req: NcRequest,
) { ) {
this.appHooks.emit('notification' as any, { ...insertData, req } as any); this.appHooks.emit('notification' as any, { ...insertData, req } as any);

5
packages/nocodb/src/services/org-tokens.service.ts

@ -2,6 +2,7 @@ import { Injectable } from '@nestjs/common';
import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk'; import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk';
import type { User } from '~/models'; import type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk'; import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -38,7 +39,7 @@ export class OrgTokensService {
async apiTokenCreate(param: { async apiTokenCreate(param: {
user: User; user: User;
apiToken: ApiTokenReqType; apiToken: ApiTokenReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ApiTokenReq', 'swagger.json#/components/schemas/ApiTokenReq',
@ -60,7 +61,7 @@ export class OrgTokensService {
return apiToken; return apiToken;
} }
async apiTokenDelete(param: { user: User; token: string; req: any }) { async apiTokenDelete(param: { user: User; token: string; req: NcRequest }) {
const fk_user_id = param.user.id; const fk_user_id = param.user.id;
const apiToken = await ApiToken.getByToken(param.token); const apiToken = await ApiToken.getByToken(param.token);
if ( if (

8
packages/nocodb/src/services/org-users.service.ts

@ -8,6 +8,7 @@ import {
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import validator from 'validator'; import validator from 'validator';
import type { UserType } from 'nocodb-sdk'; import type { UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { BaseUsersService } from '~/services/base-users/base-users.service'; import { BaseUsersService } from '~/services/base-users/base-users.service';
import { NC_APP_SETTINGS } from '~/constants'; import { NC_APP_SETTINGS } from '~/constants';
@ -91,7 +92,7 @@ export class OrgUsersService {
async userAdd(param: { async userAdd(param: {
user: UserType; user: UserType;
// todo: refactor // todo: refactor
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/OrgUserReq', param.user); validatePayload('swagger.json#/components/schemas/OrgUserReq', param.user);
@ -193,7 +194,10 @@ export class OrgUsersService {
NcError.notImplemented(); NcError.notImplemented();
} }
async userInviteResend(param: { userId: string; req: any }): Promise<any> { async userInviteResend(param: {
userId: string;
req: NcRequest;
}): Promise<any> {
const user = await User.get(param.userId); const user = await User.get(param.userId);
if (!user) { if (!user) {

5
packages/nocodb/src/services/plugins.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { PluginTestReqType, PluginType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
@ -14,7 +15,7 @@ export class PluginsService {
return await Plugin.list(); return await Plugin.list();
} }
async pluginTest(param: { body: PluginTestReqType; req: any }) { async pluginTest(param: { body: PluginTestReqType; req: NcRequest }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/PluginTestReq', 'swagger.json#/components/schemas/PluginTestReq',
param.body, param.body,
@ -33,7 +34,7 @@ export class PluginsService {
async pluginUpdate(param: { async pluginUpdate(param: {
pluginId: string; pluginId: string;
plugin: PluginType; plugin: PluginType;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/PluginReq', param.plugin); validatePayload('swagger.json#/components/schemas/PluginReq', param.plugin);

8
packages/nocodb/src/services/shared-bases.service.ts

@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import type { AppConfig } from '~/interface/config'; import type { AppConfig, NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -26,7 +26,7 @@ export class SharedBasesService {
password: string; password: string;
siteUrl: string; siteUrl: string;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
validatePayload('swagger.json#/components/schemas/SharedBaseReq', param); validatePayload('swagger.json#/components/schemas/SharedBaseReq', param);
@ -74,7 +74,7 @@ export class SharedBasesService {
roles: string; roles: string;
password: string; password: string;
siteUrl: string; siteUrl: string;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
validatePayload('swagger.json#/components/schemas/SharedBaseReq', param); validatePayload('swagger.json#/components/schemas/SharedBaseReq', param);
@ -132,7 +132,7 @@ export class SharedBasesService {
async disableSharedBaseLink(param: { async disableSharedBaseLink(param: {
baseId: string; baseId: string;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
const base = await Base.get(param.baseId); const base = await Base.get(param.baseId);

7
packages/nocodb/src/services/sorts.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { SortReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -14,7 +15,7 @@ export class SortsService {
return Sort.get(param.sortId); return Sort.get(param.sortId);
} }
async sortDelete(param: { sortId: string; req: any }) { async sortDelete(param: { sortId: string; req: NcRequest }) {
const sort = await Sort.get(param.sortId); const sort = await Sort.get(param.sortId);
if (!sort) { if (!sort) {
@ -30,7 +31,7 @@ export class SortsService {
return true; return true;
} }
async sortUpdate(param: { sortId: any; sort: SortReqType; req: any }) { async sortUpdate(param: { sortId: any; sort: SortReqType; req: NcRequest }) {
validatePayload('swagger.json#/components/schemas/SortReq', param.sort); validatePayload('swagger.json#/components/schemas/SortReq', param.sort);
const sort = await Sort.get(param.sortId); const sort = await Sort.get(param.sortId);
@ -50,7 +51,7 @@ export class SortsService {
return res; return res;
} }
async sortCreate(param: { viewId: any; sort: SortReqType; req: any }) { async sortCreate(param: { viewId: any; sort: SortReqType; req: NcRequest }) {
validatePayload('swagger.json#/components/schemas/SortReq', param.sort); validatePayload('swagger.json#/components/schemas/SortReq', param.sort);
const sort = await Sort.insert({ const sort = await Sort.insert({

7
packages/nocodb/src/services/sources.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { BaseReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers'; import { populateMeta, validatePayload } from '~/helpers';
import { populateRollupColumnAndHideLTAR } from '~/helpers/populateMeta'; import { populateRollupColumnAndHideLTAR } from '~/helpers/populateMeta';
@ -24,7 +25,7 @@ export class SourcesService {
sourceId: string; sourceId: string;
source: BaseReqType; source: BaseReqType;
baseId: string; baseId: string;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/BaseReq', param.source); validatePayload('swagger.json#/components/schemas/BaseReq', param.source);
@ -53,7 +54,7 @@ export class SourcesService {
return sources; return sources;
} }
async baseDelete(param: { sourceId: string; req: any }) { async baseDelete(param: { sourceId: string; req: NcRequest }) {
try { try {
const source = await Source.get(param.sourceId, true); const source = await Source.get(param.sourceId, true);
await source.delete(); await source.delete();
@ -81,7 +82,7 @@ export class SourcesService {
baseId: string; baseId: string;
source: BaseReqType; source: BaseReqType;
logger?: (message: string) => void; logger?: (message: string) => void;
req: any; req: NcRequest;
}) { }) {
validatePayload('swagger.json#/components/schemas/BaseReq', param.source); validatePayload('swagger.json#/components/schemas/BaseReq', param.source);

7
packages/nocodb/src/services/sync.service.ts

@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -20,7 +21,7 @@ export class SyncService {
sourceId?: string; sourceId?: string;
userId: string; userId: string;
syncPayload: Partial<SyncSource>; syncPayload: Partial<SyncSource>;
req: any; req: NcRequest;
}) { }) {
const base = await Base.getWithInfo(param.baseId); const base = await Base.getWithInfo(param.baseId);
@ -39,7 +40,7 @@ export class SyncService {
return sync; return sync;
} }
async syncDelete(param: { syncId: string; req: any }) { async syncDelete(param: { syncId: string; req: NcRequest }) {
const syncSource = await SyncSource.get(param.syncId); const syncSource = await SyncSource.get(param.syncId);
if (!syncSource) { if (!syncSource) {
@ -58,7 +59,7 @@ export class SyncService {
async syncUpdate(param: { async syncUpdate(param: {
syncId: string; syncId: string;
syncPayload: Partial<SyncSource>; syncPayload: Partial<SyncSource>;
req: any; req: NcRequest;
}) { }) {
const syncSource = await SyncSource.get(param.syncId); const syncSource = await SyncSource.get(param.syncId);

3
packages/nocodb/src/services/tables.service.ts

@ -18,6 +18,7 @@ import type {
TableReqType, TableReqType,
UserType, UserType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2'; import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -43,7 +44,7 @@ export class TablesService {
table: TableReqType & { base_id?: string }; table: TableReqType & { base_id?: string };
baseId?: string; baseId?: string;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
const model = await Model.get(param.tableId); const model = await Model.get(param.tableId);

11
packages/nocodb/src/services/users/users.service.ts

@ -13,6 +13,7 @@ import type {
SignUpReqType, SignUpReqType,
UserType, UserType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { genJwt, setTokenCookie } from '~/services/users/helpers'; import { genJwt, setTokenCookie } from '~/services/users/helpers';
import { NC_APP_SETTINGS } from '~/constants'; import { NC_APP_SETTINGS } from '~/constants';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
@ -97,7 +98,7 @@ export class UsersService {
salt: any; salt: any;
password; password;
email_verification_token; email_verification_token;
req: any; req: NcRequest;
}) { }) {
this.validateEmailPattern(email); this.validateEmailPattern(email);
@ -149,7 +150,7 @@ export class UsersService {
async passwordChange(param: { async passwordChange(param: {
body: PasswordChangeReqType; body: PasswordChangeReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
validatePayload( validatePayload(
'swagger.json#/components/schemas/PasswordChangeReq', 'swagger.json#/components/schemas/PasswordChangeReq',
@ -202,7 +203,7 @@ export class UsersService {
async passwordForgot(param: { async passwordForgot(param: {
body: PasswordForgotReqType; body: PasswordForgotReqType;
siteUrl: string; siteUrl: string;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
validatePayload( validatePayload(
'swagger.json#/components/schemas/PasswordForgotReq', 'swagger.json#/components/schemas/PasswordForgotReq',
@ -279,7 +280,7 @@ export class UsersService {
async passwordReset(param: { async passwordReset(param: {
body: PasswordResetReqType; body: PasswordResetReqType;
token: string; token: string;
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
validatePayload( validatePayload(
'swagger.json#/components/schemas/PasswordResetReq', 'swagger.json#/components/schemas/PasswordResetReq',
@ -332,7 +333,7 @@ export class UsersService {
async emailVerification(param: { async emailVerification(param: {
token: string; token: string;
// todo: exclude // todo: exclude
req: any; req: NcRequest;
}): Promise<any> { }): Promise<any> {
const { token, req } = param; const { token, req } = param;

5
packages/nocodb/src/services/view-columns.service.ts

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { ViewColumnReqType, ViewColumnUpdateReqType } 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 { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { View } from '~/models'; import { View } from '~/models';
@ -15,7 +16,7 @@ export class ViewColumnsService {
async columnAdd(param: { async columnAdd(param: {
viewId: string; viewId: string;
column: ViewColumnReqType; column: ViewColumnReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewColumnReq', 'swagger.json#/components/schemas/ViewColumnReq',
@ -42,7 +43,7 @@ export class ViewColumnsService {
viewId: string; viewId: string;
columnId: string; columnId: string;
column: ViewColumnUpdateReqType; column: ViewColumnUpdateReqType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewColumnUpdateReq', 'swagger.json#/components/schemas/ViewColumnUpdateReq',

19
packages/nocodb/src/services/views.service.ts

@ -5,6 +5,7 @@ import type {
UserType, UserType,
ViewUpdateReqType, ViewUpdateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -69,8 +70,8 @@ export class ViewsService {
async viewList(param: { async viewList(param: {
tableId: string; tableId: string;
user: { user: {
roles: Record<string, boolean>; roles?: Record<string, boolean> | string;
base_roles: Record<string, boolean>; base_roles?: Record<string, boolean>;
}; };
}) { }) {
const model = await Model.get(param.tableId); const model = await Model.get(param.tableId);
@ -91,7 +92,7 @@ export class ViewsService {
return filteredViewList; return filteredViewList;
} }
async shareView(param: { viewId: string; user: UserType; req: any }) { async shareView(param: { viewId: string; user: UserType; req: NcRequest }) {
const res = await View.share(param.viewId); const res = await View.share(param.viewId);
const view = await View.get(param.viewId); const view = await View.get(param.viewId);
@ -113,7 +114,7 @@ export class ViewsService {
viewId: string; viewId: string;
view: ViewUpdateReqType; view: ViewUpdateReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/ViewUpdateReq', 'swagger.json#/components/schemas/ViewUpdateReq',
@ -140,7 +141,7 @@ export class ViewsService {
return result; return result;
} }
async viewDelete(param: { viewId: string; user: UserType; req: any }) { async viewDelete(param: { viewId: string; user: UserType; req: NcRequest }) {
const view = await View.get(param.viewId); const view = await View.get(param.viewId);
if (!view) { if (!view) {
@ -162,7 +163,7 @@ export class ViewsService {
viewId: string; viewId: string;
sharedView: SharedViewReqType; sharedView: SharedViewReqType;
user: UserType; user: UserType;
req: any; req: NcRequest;
}) { }) {
validatePayload( validatePayload(
'swagger.json#/components/schemas/SharedViewReq', 'swagger.json#/components/schemas/SharedViewReq',
@ -186,7 +187,11 @@ export class ViewsService {
return result; return result;
} }
async shareViewDelete(param: { viewId: string; user: UserType; req: any }) { async shareViewDelete(param: {
viewId: string;
user: UserType;
req: NcRequest;
}) {
const view = await View.get(param.viewId); const view = await View.get(param.viewId);
if (!view) { if (!view) {

3
packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts

@ -2,13 +2,14 @@ import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport'; import { PassportStrategy } from '@nestjs/passport';
import { extractRolesObj, ProjectRoles } from 'nocodb-sdk'; import { extractRolesObj, ProjectRoles } from 'nocodb-sdk';
import { Strategy } from 'passport-custom'; import { Strategy } from 'passport-custom';
import type { Request } from 'express';
import { ApiToken, BaseUser, User } from '~/models'; import { ApiToken, BaseUser, User } from '~/models';
import { sanitiseUserObj } from '~/utils'; import { sanitiseUserObj } from '~/utils';
@Injectable() @Injectable()
export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') { export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') {
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
async validate(req: any, callback: Function) { async validate(req: Request, callback: Function) {
try { try {
let user; let user;
if (req.headers['xc-token']) { if (req.headers['xc-token']) {

3
packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts

@ -2,12 +2,13 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport'; import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-custom'; import { Strategy } from 'passport-custom';
import { extractRolesObj } from 'nocodb-sdk'; import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import { Base } from '~/models'; import { Base } from '~/models';
@Injectable() @Injectable()
export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') { export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') {
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
async validate(req: any, callback: Function) { async validate(req: Request, callback: Function) {
try { try {
let user; let user;
if (req.headers['xc-shared-base-id']) { if (req.headers['xc-shared-base-id']) {

5
packages/nocodb/src/strategies/google.strategy/google.strategy.ts

@ -3,6 +3,7 @@ import { Injectable, Optional } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport'; import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-google-oauth20'; import { Strategy } from 'passport-google-oauth20';
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import type { Request } from 'express';
import type { VerifyCallback } from 'passport-google-oauth20'; import type { VerifyCallback } from 'passport-google-oauth20';
import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface'; import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
import Noco from '~/Noco'; import Noco from '~/Noco';
@ -20,7 +21,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
} }
async validate( async validate(
req: any, req: Request,
accessToken: string, accessToken: string,
refreshToken: string, refreshToken: string,
profile: any, profile: any,
@ -72,7 +73,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
return params; return params;
} }
async authenticate(req: any, options?: any): Promise<void> { async authenticate(req: Request, options?: any): Promise<void> {
const googlePlugin = await Plugin.getPluginByTitle('Google'); const googlePlugin = await Plugin.getPluginByTitle('Google');
if (googlePlugin && googlePlugin.input) { if (googlePlugin && googlePlugin.input) {

14
packages/nocodb/src/types/express.d.ts vendored

@ -0,0 +1,14 @@
import type { UserType } from 'nocodb-sdk';
declare module 'express-serve-static-core' {
interface Request {
ncWorkspaceId?: string;
ncProjectId?: string;
user: UserType & {
base_roles?: Record<string, boolean>;
workspace_roles?: Record<string, boolean>;
provider?: string;
};
ncSiteUrl: string;
clientIp: string;
}
}

BIN
packages/nocodb/tests/unit/test_meta.db

Binary file not shown.

7
packages/nocodb/tests/unit/tsconfig.ee.json

@ -50,11 +50,12 @@
"dom" "dom"
], ],
"types": [ "types": [
"mocha", "node" "mocha",
"node"
], ],
"typeRoots": [ "typeRoots": [
"node_modules/@types", "../../src/types",
"src/types" "../../node_modules/@types"
] ]
}, },
"parserOptions": { "parserOptions": {

12
packages/nocodb/tests/unit/tsconfig.json

@ -50,18 +50,14 @@
"dom" "dom"
], ],
"types": [ "types": [
"mocha", "node" "mocha",
"node"
], ],
"typeRoots": [ "typeRoots": [
"node_modules/@types", "../../src/types",
"src/types" "../../node_modules/@types"
] ]
}, },
"parserOptions": {
"sourceType": "module",
"tsconfigRootDir": "./",
"project": "./tsconfig.json"
},
"include": [ "include": [
"./tests/**/**/**.ts", "./tests/**/**/**.ts",
"./tests/**/**.ts" "./tests/**/**.ts"

22
packages/nocodb/tsconfig.json

@ -1,6 +1,8 @@
{ {
"ts-node": { "ts-node": {
"require": ["tsconfig-paths/register"] "require": [
"tsconfig-paths/register"
]
}, },
"compilerOptions": { "compilerOptions": {
"module": "commonjs", "module": "commonjs",
@ -23,9 +25,19 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"esModuleInterop": true, "esModuleInterop": true,
"paths": { "paths": {
"src/*": ["./src/*"], "src/*": [
"~/*": ["./src/*"], "./src/*"
"@/*": ["./src/*"] ],
} "~/*": [
"./src/*"
],
"@/*": [
"./src/*"
]
},
"typeRoots": [
"./src/types",
"./node_modules/@types"
]
} }
} }

Loading…
Cancel
Save