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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -7,9 +7,10 @@ import {
Param,
Patch,
Post,
Request,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { ColumnReqType } from 'nocodb-sdk';
import type { Column } from '~/models';
import { GlobalGuard } from '~/guards/global/global.guard';
@ -31,7 +32,7 @@ export class ColumnsController {
async columnAdd(
@Param('tableId') tableId: string,
@Body() body: ColumnReqType,
@Request() req: any,
@Req() req: Request,
) {
return await this.columnsService.columnAdd({
tableId,
@ -49,7 +50,7 @@ export class ColumnsController {
async columnUpdate(
@Param('columnId') columnId: string,
@Body() body: ColumnReqType,
@Request() req: any,
@Req() req: Request,
) {
return await this.columnsService.columnUpdate({
columnId: columnId,
@ -64,7 +65,7 @@ export class ColumnsController {
'/api/v2/meta/columns/:columnId',
])
@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({
columnId,
req,
@ -113,7 +114,7 @@ export class ColumnsController {
column: Partial<Column>;
}[];
},
@Request() req: any,
@Req() req: Request,
) {
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 { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service';
@ -17,7 +18,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/views/:viewName/export/excel',
])
@Acl('exportExcel')
async excelDataExport(@Request() req, @Response() res) {
async excelDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view;
@ -44,7 +45,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/export/csv',
])
@Acl('exportCsv')
async csvDataExport(@Request() req, @Response() res) {
async csvDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -8,9 +8,10 @@ import {
Patch,
Post,
Query,
Request,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { ViewUpdateReqType } from 'nocodb-sdk';
import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { GlobalGuard } from '~/guards/global/global.guard';
@ -28,7 +29,7 @@ export class ViewsController {
'/api/v2/meta/tables/:tableId/views',
])
@Acl('viewList')
async viewList(@Param('tableId') tableId: string, @Request() req) {
async viewList(@Param('tableId') tableId: string, @Req() req: Request) {
return new PagedResponseImpl(
await this.viewsService.viewList({
tableId,
@ -42,7 +43,7 @@ export class ViewsController {
async viewUpdate(
@Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType,
@Request() req,
@Req() req: Request,
) {
const result = await this.viewsService.viewUpdate({
viewId,
@ -55,7 +56,7 @@ export class ViewsController {
@Delete(['/api/v1/db/meta/views/:viewId', '/api/v2/meta/views/:viewId'])
@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({
viewId,
user: req.user,
@ -101,7 +102,7 @@ export class ViewsController {
])
@HttpCode(200)
@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 });
}
@ -126,7 +127,7 @@ export class ViewsController {
async shareViewUpdate(
@Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType,
@Request() req,
@Req() req: Request,
) {
return await this.viewsService.shareViewUpdate({
viewId,
@ -141,7 +142,7 @@ export class ViewsController {
'/api/v2/meta/views/:viewId/share',
])
@Acl('shareViewDelete')
async shareViewDelete(@Param('viewId') viewId: string, @Request() req) {
async shareViewDelete(@Param('viewId') viewId: string, @Req() req: Request) {
return await this.viewsService.shareViewDelete({
viewId,
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 { lastValueFrom, Observable } from 'rxjs';
import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import type { ExecutionContext } from '@nestjs/common';
import { JwtStrategy } from '~/strategies/jwt.strategy';
@ -75,7 +76,7 @@ export class GlobalGuard extends AuthGuard(['jwt']) {
}
private async authenticate(
req: any,
req: Request,
user: any = {
roles: {
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';
export enum DBError {
@ -384,9 +385,9 @@ export function extractDBError(error): {
}
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 {
return await requestHandler(req, res, next);
} 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 * as e from 'express';
import type { Knex } from 'knex';
import type { User } from '~/models';
export interface Route {
path: string;
@ -319,3 +322,12 @@ export interface AppConfig {
mainSubDomain: 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,
Inject,
Post,
Request,
Response,
Req,
Res,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { OnEvent } from '@nestjs/event-emitter';
import { customAlphabet } from 'nanoid';
import { ModuleRef } from '@nestjs/core';
import { JobsRedisService } from './redis/jobs-redis.service';
import type { Response } from 'express';
import type { OnModuleInit } from '@nestjs/common';
import { JobStatus } from '~/interface/Jobs';
import { JobEvents } from '~/interface/Jobs';
@ -46,8 +48,8 @@ export class JobsController implements OnModuleInit {
@Post('/jobs/listen')
@HttpCode(200)
async listen(
@Response() res,
@Request() req,
@Res() res: Response & { resId?: string },
@Req() req: Request,
@Body() body: { _mid: number; data: { id: string } },
) {
const { _mid = 0, data } = body;
@ -134,7 +136,7 @@ export class JobsController implements OnModuleInit {
res.on('close', () => {
if (jobId && this.jobRooms[jobId]?.listeners) {
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,
Inject,
Post,
Request,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { SyncSource } from '~/models';
@ -24,7 +25,7 @@ export class AtImportController {
])
@Acl('airtableImport')
@HttpCode(200)
async triggerSync(@Request() req) {
async triggerSync(@Req() req: Request) {
const jobs = await this.jobsService.jobList();
const fnd = jobs.find((j) => j.data.syncId === req.params.syncId);
@ -69,7 +70,7 @@ export class AtImportController {
])
@Acl('airtableImport')
@HttpCode(200)
async abortImport(@Request() _) {
async abortImport() {
return {};
}
}

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

@ -5,9 +5,10 @@ import {
Inject,
Param,
Post,
Request,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { ProjectStatus } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -34,7 +35,7 @@ export class DuplicateController {
scope: 'org',
})
public async duplicateSharedBase(
@Request() req,
@Req() req: Request,
@Param('workspaceId') _workspaceId: string,
@Param('sharedBaseId') sharedBaseId: string,
@Body()
@ -101,7 +102,7 @@ export class DuplicateController {
@HttpCode(200)
@Acl('duplicateBase')
async duplicateBase(
@Request() req,
@Req() req: Request,
@Param('baseId') baseId: string,
@Param('sourceId') sourceId?: string,
@Body()
@ -168,7 +169,7 @@ export class DuplicateController {
@HttpCode(200)
@Acl('duplicateModel')
async duplicateModel(
@Request() req,
@Req() req: Request,
@Param('baseId') baseId: string,
@Param('modelId') modelId?: string,
@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 { UserType, ViewCreateReqType } from 'nocodb-sdk';
import type { LinkToAnotherRecordColumn, User, View } from '~/models';
import type { NcRequest } from '~/interface/config';
import {
findWithIdentifier,
generateUniqueName,
@ -64,7 +65,7 @@ export class ImportService {
data:
| { models: { model: any; views: any[]; hooks?: any[] }[] }
| { model: any; views: any[]; hooks?: any[] }[];
req: any;
req: NcRequest;
externalModels?: Model[];
}) {
const hrTime = initTime();
@ -1051,7 +1052,7 @@ export class ImportService {
vw: Partial<View>,
views: View[],
user: UserType,
req: any,
req: NcRequest,
): Promise<View> {
if (vw.is_default) {
const view = views.find((a) => a.is_default);
@ -1197,7 +1198,7 @@ export class ImportService {
url?: string;
file?: any;
};
req: any;
req: NcRequest;
}) {
const hrTime = initTime();

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

@ -4,9 +4,10 @@ import {
Inject,
Param,
Post,
Request,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { NcError } from '~/helpers/catchError';
@ -24,7 +25,7 @@ export class MetaSyncController {
])
@HttpCode(200)
@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 fnd = jobs.find(
(j) => j.name === JobTypes.MetaSync && j.data.baseId === baseId,
@ -57,7 +58,7 @@ export class MetaSyncController {
async baseMetaDiffSync(
@Param('baseId') baseId: string,
@Param('sourceId') sourceId: string,
@Request() req,
@Req() req: Request,
) {
const jobs = await this.jobsService.jobList();
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 { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull';
import type { NcRequest } from '~/interface/config';
import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs';
import { MetaDiffsService } from '~/services/meta-diffs.service';
@ -18,7 +19,7 @@ export class MetaSyncProcessor {
baseId: string;
sourceId: string;
user: any;
req: any;
req: NcRequest;
} = job.data;
if (info.sourceId === 'all') {

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

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

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

@ -6,6 +6,7 @@ import {
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { NcError } from '~/helpers/catchError';
@ -26,7 +27,7 @@ export class SourceDeleteController {
'/api/v2/meta/bases/:baseId/sources/:sourceId',
])
@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 fnd = jobs.find(
(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 type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError';
import { validatePayload } from '~/helpers';
@ -17,7 +18,7 @@ export class ApiTokensService {
async apiTokenCreate(param: {
userId: string;
tokenBody: ApiTokenReqType;
req: any;
req: NcRequest;
}) {
validatePayload(
'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);
if (
!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';
export interface NcBaseEvent extends NcBaseEvent {
req: any;
req: NcRequest;
clientId?: string;
}

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

@ -4,6 +4,7 @@ import { Injectable } from '@nestjs/common';
import { nanoid } from 'nanoid';
import slash from 'slash';
import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import Local from '~/plugins/storage/Local';
@ -15,7 +16,7 @@ import { utf8ify } from '~/helpers/stringHelpers';
export class AttachmentsService {
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
const filePath = this.sanitizeUrlPath(
param.path?.toString()?.split('/') || [''],
@ -92,7 +93,7 @@ export class AttachmentsService {
async uploadViaURL(param: {
path?: string;
urls: AttachmentReqType[];
req: any;
req: NcRequest;
}) {
// TODO: add getAjvValidatorMw
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 validator from 'validator';
import type { ProjectUserReqType, UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import NocoCache from '~/cache/NocoCache';
import { validatePayload } from '~/helpers';
import Noco from '~/Noco';
@ -47,7 +48,7 @@ export class BaseUsersService {
async userInvite(param: {
baseId: string;
baseUser: ProjectUserReqType;
req: any;
req: NcRequest;
}): Promise<any> {
validatePayload(
'swagger.json#/components/schemas/ProjectUserReq',

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

@ -13,6 +13,7 @@ import type {
ProjectUpdateReqType,
UserType,
} from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -36,7 +37,7 @@ export class BasesService {
) {}
async baseList(param: {
user: { id: string; roles: Record<string, boolean> };
user: { id: string; roles?: string | Record<string, boolean> };
query?: any;
}) {
const bases = extractRolesObj(param.user?.roles)[OrgUserRoles.SUPER_ADMIN]
@ -63,7 +64,7 @@ export class BasesService {
baseId: string;
base: ProjectUpdateReqType;
user: UserType;
req: any;
req: NcRequest;
}) {
validatePayload(
'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);
if (!base) {
@ -119,7 +120,7 @@ export class BasesService {
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);
const baseId = await this.metaService.genNanoid(MetaTable.PROJECT);
@ -225,7 +226,7 @@ export class BasesService {
return base;
}
async createDefaultBase(param: { user: UserType; req: any }) {
async createDefaultBase(param: { user: UserType; req: NcRequest }) {
const base = await this.baseCreate({
base: {
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 SqlClient from '~/db/sql-client/lib/SqlClient';
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2';
import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2';
@ -1030,7 +1031,7 @@ export class ColumnsService {
}
async columnAdd(param: {
req: any;
req: NcRequest;
tableId: string;
column: ColumnReqType;
user: UserType;
@ -2194,7 +2195,7 @@ export class ColumnsService {
column: Partial<Column>;
}[];
},
req: any,
req: NcRequest,
) {
// TODO validatePayload

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

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk';
import type { FilterReqType, UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -14,7 +15,7 @@ export class FiltersService {
filter: FilterReqType;
hookId: any;
user: UserType;
req: any;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -41,7 +42,7 @@ export class FiltersService {
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);
if (!filter) {
@ -62,7 +63,7 @@ export class FiltersService {
filter: FilterReqType;
viewId: string;
user: UserType;
req: any;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -86,7 +87,7 @@ export class FiltersService {
filter: FilterReqType;
filterId: string;
user: UserType;
req: any;
req: NcRequest;
}) {
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 { AppEvents } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { FormViewColumn } from '~/models';
@ -12,7 +13,7 @@ export class FormColumnsService {
formViewColumnId: string;
// todo: replace with FormColumnReq
formViewColumn: FormViewColumn;
req: any;
req: NcRequest;
}) {
validatePayload(
'swagger.json#/components/schemas/FormColumnReq',

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -6,6 +6,7 @@ import type {
} from '~/services/app-hooks/interfaces';
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import type { UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -17,7 +18,7 @@ export class NotificationsService implements OnModuleInit, OnModuleDestroy {
protected async insertNotification(
insertData: Partial<Notification>,
req: any,
req: NcRequest,
) {
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 type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -38,7 +39,7 @@ export class OrgTokensService {
async apiTokenCreate(param: {
user: User;
apiToken: ApiTokenReqType;
req: any;
req: NcRequest;
}) {
validatePayload(
'swagger.json#/components/schemas/ApiTokenReq',
@ -60,7 +61,7 @@ export class OrgTokensService {
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 apiToken = await ApiToken.getByToken(param.token);
if (

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

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

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

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk';
import type { PluginTestReqType, PluginType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
@ -14,7 +15,7 @@ export class PluginsService {
return await Plugin.list();
}
async pluginTest(param: { body: PluginTestReqType; req: any }) {
async pluginTest(param: { body: PluginTestReqType; req: NcRequest }) {
validatePayload(
'swagger.json#/components/schemas/PluginTestReq',
param.body,
@ -33,7 +34,7 @@ export class PluginsService {
async pluginUpdate(param: {
pluginId: string;
plugin: PluginType;
req: any;
req: NcRequest;
}) {
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 { v4 as uuidv4 } from 'uuid';
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 { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -26,7 +26,7 @@ export class SharedBasesService {
password: string;
siteUrl: string;
req: any;
req: NcRequest;
}): Promise<any> {
validatePayload('swagger.json#/components/schemas/SharedBaseReq', param);
@ -74,7 +74,7 @@ export class SharedBasesService {
roles: string;
password: string;
siteUrl: string;
req: any;
req: NcRequest;
}): Promise<any> {
validatePayload('swagger.json#/components/schemas/SharedBaseReq', param);
@ -132,7 +132,7 @@ export class SharedBasesService {
async disableSharedBaseLink(param: {
baseId: string;
req: any;
req: NcRequest;
}): Promise<any> {
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 { AppEvents } from 'nocodb-sdk';
import type { SortReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -14,7 +15,7 @@ export class SortsService {
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);
if (!sort) {
@ -30,7 +31,7 @@ export class SortsService {
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);
const sort = await Sort.get(param.sortId);
@ -50,7 +51,7 @@ export class SortsService {
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);
const sort = await Sort.insert({

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

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk';
import type { BaseReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers';
import { populateRollupColumnAndHideLTAR } from '~/helpers/populateMeta';
@ -24,7 +25,7 @@ export class SourcesService {
sourceId: string;
source: BaseReqType;
baseId: string;
req: any;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/BaseReq', param.source);
@ -53,7 +54,7 @@ export class SourcesService {
return sources;
}
async baseDelete(param: { sourceId: string; req: any }) {
async baseDelete(param: { sourceId: string; req: NcRequest }) {
try {
const source = await Source.get(param.sourceId, true);
await source.delete();
@ -81,7 +82,7 @@ export class SourcesService {
baseId: string;
source: BaseReqType;
logger?: (message: string) => void;
req: any;
req: NcRequest;
}) {
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 { AppEvents } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -20,7 +21,7 @@ export class SyncService {
sourceId?: string;
userId: string;
syncPayload: Partial<SyncSource>;
req: any;
req: NcRequest;
}) {
const base = await Base.getWithInfo(param.baseId);
@ -39,7 +40,7 @@ export class SyncService {
return sync;
}
async syncDelete(param: { syncId: string; req: any }) {
async syncDelete(param: { syncId: string; req: NcRequest }) {
const syncSource = await SyncSource.get(param.syncId);
if (!syncSource) {
@ -58,7 +59,7 @@ export class SyncService {
async syncUpdate(param: {
syncId: string;
syncPayload: Partial<SyncSource>;
req: any;
req: NcRequest;
}) {
const syncSource = await SyncSource.get(param.syncId);

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

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

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

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

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

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

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

@ -5,6 +5,7 @@ import type {
UserType,
ViewUpdateReqType,
} from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -69,8 +70,8 @@ export class ViewsService {
async viewList(param: {
tableId: string;
user: {
roles: Record<string, boolean>;
base_roles: Record<string, boolean>;
roles?: Record<string, boolean> | string;
base_roles?: Record<string, boolean>;
};
}) {
const model = await Model.get(param.tableId);
@ -91,7 +92,7 @@ export class ViewsService {
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 view = await View.get(param.viewId);
@ -113,7 +114,7 @@ export class ViewsService {
viewId: string;
view: ViewUpdateReqType;
user: UserType;
req: any;
req: NcRequest;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewUpdateReq',
@ -140,7 +141,7 @@ export class ViewsService {
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);
if (!view) {
@ -162,7 +163,7 @@ export class ViewsService {
viewId: string;
sharedView: SharedViewReqType;
user: UserType;
req: any;
req: NcRequest;
}) {
validatePayload(
'swagger.json#/components/schemas/SharedViewReq',
@ -186,7 +187,11 @@ export class ViewsService {
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);
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 { extractRolesObj, ProjectRoles } from 'nocodb-sdk';
import { Strategy } from 'passport-custom';
import type { Request } from 'express';
import { ApiToken, BaseUser, User } from '~/models';
import { sanitiseUserObj } from '~/utils';
@Injectable()
export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') {
// eslint-disable-next-line @typescript-eslint/ban-types
async validate(req: any, callback: Function) {
async validate(req: Request, callback: Function) {
try {
let user;
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 { Strategy } from 'passport-custom';
import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import { Base } from '~/models';
@Injectable()
export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') {
// eslint-disable-next-line @typescript-eslint/ban-types
async validate(req: any, callback: Function) {
async validate(req: Request, callback: Function) {
try {
let user;
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 { Strategy } from 'passport-google-oauth20';
import bcrypt from 'bcryptjs';
import type { Request } from 'express';
import type { VerifyCallback } from 'passport-google-oauth20';
import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
import Noco from '~/Noco';
@ -20,7 +21,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
}
async validate(
req: any,
req: Request,
accessToken: string,
refreshToken: string,
profile: any,
@ -72,7 +73,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
return params;
}
async authenticate(req: any, options?: any): Promise<void> {
async authenticate(req: Request, options?: any): Promise<void> {
const googlePlugin = await Plugin.getPluginByTitle('Google');
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"
],
"types": [
"mocha", "node"
"mocha",
"node"
],
"typeRoots": [
"node_modules/@types",
"src/types"
"../../src/types",
"../../node_modules/@types"
]
},
"parserOptions": {

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

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

22
packages/nocodb/tsconfig.json

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

Loading…
Cancel
Save