Browse Source

chore: lint

pull/6914/head
Pranav C 1 year ago
parent
commit
def91b99f3
  1. 8
      packages/nocodb/src/controllers/attachments-secure.controller.ts
  2. 15
      packages/nocodb/src/controllers/attachments.controller.ts
  3. 14
      packages/nocodb/src/controllers/auth/auth.controller.ts
  4. 9
      packages/nocodb/src/controllers/form-columns.controller.ts
  5. 6
      packages/nocodb/src/controllers/notifications.controller.ts
  6. 4
      packages/nocodb/src/controllers/org-tokens.controller.ts
  7. 6
      packages/nocodb/src/controllers/shared-bases.controller.ts
  8. 6
      packages/nocodb/src/controllers/views.controller.ts
  9. 2
      packages/nocodb/src/guards/global/global.guard.ts
  10. 2
      packages/nocodb/src/helpers/catchError.ts
  11. 4
      packages/nocodb/src/interface/config.ts
  12. 5
      packages/nocodb/src/modules/jobs/jobs.controller.ts
  13. 2
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
  14. 2
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts
  15. 2
      packages/nocodb/src/services/api-tokens.service.ts
  16. 2
      packages/nocodb/src/services/attachments.service.ts
  17. 2
      packages/nocodb/src/services/base-users/base-users.service.ts
  18. 4
      packages/nocodb/src/services/bases.service.ts
  19. 2
      packages/nocodb/src/services/columns.service.ts
  20. 2
      packages/nocodb/src/services/filters.service.ts
  21. 2
      packages/nocodb/src/services/form-columns.service.ts
  22. 2
      packages/nocodb/src/services/forms.service.ts
  23. 2
      packages/nocodb/src/services/galleries.service.ts
  24. 2
      packages/nocodb/src/services/grid-columns.service.ts
  25. 2
      packages/nocodb/src/services/grids.service.ts
  26. 14
      packages/nocodb/src/services/hooks.service.ts
  27. 2
      packages/nocodb/src/services/kanbans.service.ts
  28. 2
      packages/nocodb/src/services/maps.service.ts
  29. 2
      packages/nocodb/src/services/model-visibilities.service.ts
  30. 2
      packages/nocodb/src/services/notifications.service.ts
  31. 2
      packages/nocodb/src/services/org-tokens.service.ts
  32. 7
      packages/nocodb/src/services/org-users.service.ts
  33. 2
      packages/nocodb/src/services/plugins.service.ts
  34. 2
      packages/nocodb/src/services/shared-bases.service.ts
  35. 2
      packages/nocodb/src/services/sorts.service.ts
  36. 2
      packages/nocodb/src/services/sources.service.ts
  37. 2
      packages/nocodb/src/services/sync.service.ts
  38. 2
      packages/nocodb/src/services/tables.service.ts
  39. 2
      packages/nocodb/src/services/users/users.service.ts
  40. 2
      packages/nocodb/src/services/view-columns.service.ts
  41. 10
      packages/nocodb/src/services/views.service.ts
  42. 2
      packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.ts
  43. 3
      packages/nocodb/src/strategies/base-view.strategy/base-view.strategy.ts
  44. 2
      packages/nocodb/src/strategies/google.strategy/google.strategy.ts
  45. 19
      packages/nocodb/src/types/express.d.ts
  46. BIN
      packages/nocodb/tests/unit/test_meta.db
  47. 3
      packages/nocodb/tests/unit/tsconfig.ee.json
  48. 4
      packages/nocodb/tests/unit/tsconfig.json
  49. 21
      packages/nocodb/tsconfig.json

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

@ -15,7 +15,8 @@ import {
import hash from 'object-hash'; import hash from 'object-hash';
import moment from 'moment'; import moment from 'moment';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { Request, Response } from 'express'; import { Response } from 'express';
import type { Request } from 'express';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { AttachmentsService } from '~/services/attachments.service'; import { AttachmentsService } from '~/services/attachments.service';
@ -66,10 +67,7 @@ export class AttachmentsSecureController {
} }
@Get('/dltemp/:param(*)') @Get('/dltemp/:param(*)')
async fileReadv3( async fileReadv3(@Param('param') param: string, @Res() res: Response) {
@Param('param') param: string,
@Res() res: Response,
) {
try { try {
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); const fpath = await PresignedUrl.getPath(`dltemp/${param}`);

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

@ -30,10 +30,7 @@ export class AttachmentsController {
@Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload']) @Post(['/api/v1/db/storage/upload', '/api/v2/storage/upload'])
@HttpCode(200) @HttpCode(200)
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload( async upload(@UploadedFiles() files: Array<FileType>, @Req() req: Request) {
@UploadedFiles() files: Array<FileType>,
@Req() req: Request,
) {
const attachments = await this.attachmentsService.upload({ const attachments = await this.attachmentsService.upload({
files: files, files: files,
path: req.query?.path?.toString(), path: req.query?.path?.toString(),
@ -65,10 +62,7 @@ export class AttachmentsController {
// , getCacheMiddleware(), catchError(fileRead)); // , getCacheMiddleware(), catchError(fileRead));
@Get('/download/:filename(*)') @Get('/download/:filename(*)')
// This route will match any URL that starts with // This route will match any URL that starts with
async fileRead( async fileRead(@Param('filename') filename: string, @Res() res: Response) {
@Param('filename') filename: string,
@Res() res: Response,
) {
try { try {
const file = await this.attachmentsService.getFile({ const file = await this.attachmentsService.getFile({
path: path.join('nc', 'uploads', filename), path: path.join('nc', 'uploads', filename),
@ -107,10 +101,7 @@ export class AttachmentsController {
} }
@Get('/dltemp/:param(*)') @Get('/dltemp/:param(*)')
async fileReadv3( async fileReadv3(@Param('param') param: string, @Res() res: Response) {
@Param('param') param: string,
@Res() res: Response,
) {
try { try {
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); const fpath = await PresignedUrl.getPath(`dltemp/${param}`);

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

@ -42,7 +42,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async signup(@Req() req: Request, @Res() res:Response): Promise<any> { async signup(@Req() req: Request, @Res() res: Response): Promise<any> {
if (this.config.get('auth', { infer: true }).disableEmailAuth) { if (this.config.get('auth', { infer: true }).disableEmailAuth) {
NcError.forbidden('Email authentication is disabled'); NcError.forbidden('Email authentication is disabled');
} }
@ -62,7 +62,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async refreshToken(@Req() req: Request, @Res() res:Response): Promise<any> { async refreshToken(@Req() req: Request, @Res() res: Response): Promise<any> {
res.json( res.json(
await this.usersService.refreshToken({ await this.usersService.refreshToken({
body: req.body, body: req.body,
@ -79,7 +79,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard, AuthGuard('local')) @UseGuards(PublicApiLimiterGuard, AuthGuard('local'))
@HttpCode(200) @HttpCode(200)
async signin(@Req() req:Request, @Res() res:Response) { async signin(@Req() req: Request, @Res() res: Response) {
if (this.config.get('auth', { infer: true }).disableEmailAuth) { if (this.config.get('auth', { infer: true }).disableEmailAuth) {
NcError.forbidden('Email authentication is disabled'); NcError.forbidden('Email authentication is disabled');
} }
@ -90,7 +90,7 @@ export class AuthController {
@UseGuards(GlobalGuard) @UseGuards(GlobalGuard)
@Post('/api/v1/auth/user/signout') @Post('/api/v1/auth/user/signout')
@HttpCode(200) @HttpCode(200)
async signOut(@Req() req:Request, @Res() res:Response): Promise<any> { async signOut(@Req() req: Request, @Res() res: Response): Promise<any> {
if (!(req as any).isAuthenticated()) { if (!(req as any).isAuthenticated()) {
NcError.forbidden('Not allowed'); NcError.forbidden('Not allowed');
} }
@ -105,7 +105,7 @@ export class AuthController {
@Post(`/auth/google/genTokenByCode`) @Post(`/auth/google/genTokenByCode`)
@HttpCode(200) @HttpCode(200)
@UseGuards(PublicApiLimiterGuard, AuthGuard('google')) @UseGuards(PublicApiLimiterGuard, AuthGuard('google'))
async googleSignin(@Req() req:Request, @Res() res:Response) { async googleSignin(@Req() req: Request, @Res() res: Response) {
await this.setRefreshToken({ req, res }); await this.setRefreshToken({ req, res });
res.json(await this.usersService.login(req.user, req)); res.json(await this.usersService.login(req.user, req));
} }
@ -118,7 +118,7 @@ export class AuthController {
@Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me']) @Get(['/auth/user/me', '/api/v1/db/auth/user/me', '/api/v1/auth/user/me'])
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
async me(@Req() req:Request) { async me(@Req() req: Request) {
const user = { const user = {
...req.user, ...req.user,
roles: extractRolesObj(req.user.roles), roles: extractRolesObj(req.user.roles),
@ -229,7 +229,7 @@ export class AuthController {
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
async renderPasswordReset( async renderPasswordReset(
@Req() req: Request, @Req() req: Request,
@Res() res:Response, @Res() res: Response,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
): Promise<any> { ): Promise<any> {
try { try {

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

@ -1,11 +1,4 @@
import { import { Body, Controller, Param, Patch, Req, UseGuards } from '@nestjs/common';
Body,
Controller,
Param,
Patch,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express'; import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { FormColumnsService } from '~/services/form-columns.service'; import { FormColumnsService } from '~/services/form-columns.service';

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

@ -37,7 +37,7 @@ export class NotificationsController {
async notificationUpdate( async notificationUpdate(
@Param('notificationId') notificationId, @Param('notificationId') notificationId,
@Body() body, @Body() body,
@Req() req:Request, @Req() req: Request,
) { ) {
return this.notificationsService.notificationUpdate({ return this.notificationsService.notificationUpdate({
notificationId, notificationId,
@ -48,7 +48,7 @@ export class NotificationsController {
@Post('/api/v1/notifications/mark-all-read') @Post('/api/v1/notifications/mark-all-read')
@HttpCode(200) @HttpCode(200)
async markAllRead(@Req() req:Request) { async markAllRead(@Req() req: Request) {
return this.notificationsService.markAllRead({ return this.notificationsService.markAllRead({
user: req.user, user: req.user,
}); });
@ -58,7 +58,7 @@ export class NotificationsController {
// @Acl('notificationDelete') // @Acl('notificationDelete')
async notificationDelete( async notificationDelete(
@Param('notificationId') notificationId, @Param('notificationId') notificationId,
@Req() req:Request, @Req() req: Request,
) { ) {
return this.notificationsService.notificationUpdate({ return this.notificationsService.notificationUpdate({
notificationId, notificationId,

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

@ -47,7 +47,7 @@ export class OrgTokensController {
scope: 'org', scope: 'org',
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async apiTokenCreate(@Req() req:Request, @Body() body: ApiTokenReqType) { async apiTokenCreate(@Req() req: Request, @Body() body: ApiTokenReqType) {
return await this.orgTokensService.apiTokenCreate({ return await this.orgTokensService.apiTokenCreate({
apiToken: body, apiToken: body,
user: req['user'], user: req['user'],
@ -61,7 +61,7 @@ export class OrgTokensController {
// allowedRoles: [OrgUserRoles.SUPER], // allowedRoles: [OrgUserRoles.SUPER],
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async apiTokenDelete(@Req() req:Request, @Param('token') token: string) { async apiTokenDelete(@Req() req: Request, @Param('token') token: string) {
await this.orgTokensService.apiTokenDelete({ await this.orgTokensService.apiTokenDelete({
token, token,
user: req['user'], user: req['user'],

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

@ -28,7 +28,7 @@ export class SharedBasesController {
@HttpCode(200) @HttpCode(200)
@Acl('createSharedBaseLink') @Acl('createSharedBaseLink')
async createSharedBaseLink( async createSharedBaseLink(
@Req() req:Request, @Req() req: Request,
@Body() body: any, @Body() body: any,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
): Promise<any> { ): Promise<any> {
@ -49,7 +49,7 @@ export class SharedBasesController {
]) ])
@Acl('updateSharedBaseLink') @Acl('updateSharedBaseLink')
async updateSharedBaseLink( async updateSharedBaseLink(
@Req() req:Request, @Req() req: Request,
@Body() body: any, @Body() body: any,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
): Promise<any> { ): Promise<any> {
@ -87,7 +87,7 @@ export class SharedBasesController {
]) ])
@Acl('getSharedBaseLink') @Acl('getSharedBaseLink')
async getSharedBaseLink( async getSharedBaseLink(
@Req() req:Request, @Req() req: Request,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
): Promise<any> { ): Promise<any> {
const sharedBase = await this.sharedBasesService.getSharedBaseLink({ const sharedBase = await this.sharedBasesService.getSharedBaseLink({

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

@ -102,7 +102,7 @@ export class ViewsController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('shareView') @Acl('shareView')
async shareView(@Param('viewId') viewId: string, @Req() req:Request) { async shareView(@Param('viewId') viewId: string, @Req() req: Request) {
return await this.viewsService.shareView({ viewId, user: req.user, req }); return await this.viewsService.shareView({ viewId, user: req.user, req });
} }
@ -127,7 +127,7 @@ export class ViewsController {
async shareViewUpdate( async shareViewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType, @Body() body: ViewUpdateReqType,
@Req() req:Request, @Req() req: Request,
) { ) {
return await this.viewsService.shareViewUpdate({ return await this.viewsService.shareViewUpdate({
viewId, viewId,
@ -142,7 +142,7 @@ export class ViewsController {
'/api/v2/meta/views/:viewId/share', '/api/v2/meta/views/:viewId/share',
]) ])
@Acl('shareViewDelete') @Acl('shareViewDelete')
async shareViewDelete(@Param('viewId') viewId: string, @Req() req:Request) { async shareViewDelete(@Param('viewId') viewId: string, @Req() req: Request) {
return await this.viewsService.shareViewDelete({ return await this.viewsService.shareViewDelete({
viewId, viewId,
user: req.user, user: req.user,

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

@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport'; import { AuthGuard } from '@nestjs/passport';
import { lastValueFrom, Observable } from 'rxjs'; import { lastValueFrom, Observable } from 'rxjs';
import { extractRolesObj } from 'nocodb-sdk'; import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import type { ExecutionContext } from '@nestjs/common'; import type { ExecutionContext } from '@nestjs/common';
import { JwtStrategy } from '~/strategies/jwt.strategy'; import { JwtStrategy } from '~/strategies/jwt.strategy';
import {Request} from 'express'
@Injectable() @Injectable()
export class GlobalGuard extends AuthGuard(['jwt']) { export class GlobalGuard extends AuthGuard(['jwt']) {

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

@ -1,5 +1,5 @@
import type { NextFunction, Request, Response } from 'express';
import type { ErrorObject } from 'ajv'; import type { ErrorObject } from 'ajv';
import {NextFunction,Request,Response} from "express";
export enum DBError { export enum DBError {
TABLE_EXIST = 'TABLE_EXIST', TABLE_EXIST = 'TABLE_EXIST',

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

@ -1,9 +1,9 @@
import type { UserType } from 'nocodb-sdk';
import type { ReqId } from 'pino-http'; import type { ReqId } from 'pino-http';
import type { Handler } from 'express'; import type { Handler } from 'express';
import type * as e from 'express'; import type * as e from 'express';
import type { Knex } from 'knex'; import type { Knex } from 'knex';
import {UserType} from "nocodb-sdk"; import type { User } from '~/models';
import {User} from "~/models";
export interface Route { export interface Route {
path: string; path: string;

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

@ -8,11 +8,12 @@ import {
Res, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express'; import { Request } from 'express';
import { OnEvent } from '@nestjs/event-emitter'; import { OnEvent } from '@nestjs/event-emitter';
import { customAlphabet } from 'nanoid'; import { customAlphabet } from 'nanoid';
import { ModuleRef } from '@nestjs/core'; import { ModuleRef } from '@nestjs/core';
import { JobsRedisService } from './redis/jobs-redis.service'; import { JobsRedisService } from './redis/jobs-redis.service';
import type { Response } from 'express';
import type { OnModuleInit } from '@nestjs/common'; import type { OnModuleInit } from '@nestjs/common';
import { JobStatus } from '~/interface/Jobs'; import { JobStatus } from '~/interface/Jobs';
import { JobEvents } from '~/interface/Jobs'; import { JobEvents } from '~/interface/Jobs';
@ -47,7 +48,7 @@ export class JobsController implements OnModuleInit {
@Post('/jobs/listen') @Post('/jobs/listen')
@HttpCode(200) @HttpCode(200)
async listen( async listen(
@Res() res:Response &{resId?:string}, @Res() res: Response & { resId?: string },
@Req() req: Request, @Req() req: Request,
@Body() body: { _mid: number; data: { id: string } }, @Body() body: { _mid: number; data: { id: string } },
) { ) {

2
packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts

@ -7,6 +7,7 @@ import { elapsedTime, initTime } from '../../helpers';
import type { Readable } from 'stream'; import type { Readable } from 'stream';
import type { UserType, ViewCreateReqType } from 'nocodb-sdk'; import type { UserType, ViewCreateReqType } from 'nocodb-sdk';
import type { LinkToAnotherRecordColumn, User, View } from '~/models'; import type { LinkToAnotherRecordColumn, User, View } from '~/models';
import type { NcRequest } from '~/interface/config';
import { import {
findWithIdentifier, findWithIdentifier,
generateUniqueName, generateUniqueName,
@ -35,7 +36,6 @@ import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import { BulkDataAliasService } from '~/services/bulk-data-alias.service'; import { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { sanitizeColumnName } from '~/helpers'; import { sanitizeColumnName } from '~/helpers';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class ImportService { export class ImportService {

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

@ -1,9 +1,9 @@
import debug from 'debug'; import debug from 'debug';
import { Process, Processor } from '@nestjs/bull'; import { Process, Processor } from '@nestjs/bull';
import { Job } from 'bull'; import { Job } from 'bull';
import type { NcRequest } from '~/interface/config';
import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs';
import { MetaDiffsService } from '~/services/meta-diffs.service'; import { MetaDiffsService } from '~/services/meta-diffs.service';
import {NcRequest} from "~/interface/config";
@Processor(JOBS_QUEUE) @Processor(JOBS_QUEUE)
export class MetaSyncProcessor { export class MetaSyncProcessor {

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

@ -2,11 +2,11 @@ import { Injectable } from '@nestjs/common';
import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk'; import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk';
import type { User } from '~/models'; import type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk'; import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { ApiToken } from '~/models'; import { ApiToken } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class ApiTokensService { export class ApiTokensService {

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

@ -4,13 +4,13 @@ import { Injectable } from '@nestjs/common';
import { nanoid } from 'nanoid'; import { nanoid } from 'nanoid';
import slash from 'slash'; import slash from 'slash';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import Local from '~/plugins/storage/Local'; import Local from '~/plugins/storage/Local';
import mimetypes, { mimeIcons } from '~/utils/mimeTypes'; import mimetypes, { mimeIcons } from '~/utils/mimeTypes';
import { PresignedUrl } from '~/models'; import { PresignedUrl } from '~/models';
import { utf8ify } from '~/helpers/stringHelpers'; import { utf8ify } from '~/helpers/stringHelpers';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class AttachmentsService { export class AttachmentsService {

2
packages/nocodb/src/services/base-users/base-users.service.ts

@ -10,6 +10,7 @@ import { v4 as uuidv4 } from 'uuid';
import * as ejs from 'ejs'; import * as ejs from 'ejs';
import validator from 'validator'; import validator from 'validator';
import type { ProjectUserReqType, UserType } from 'nocodb-sdk'; import type { ProjectUserReqType, UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import NocoCache from '~/cache/NocoCache'; import NocoCache from '~/cache/NocoCache';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import Noco from '~/Noco'; import Noco from '~/Noco';
@ -23,7 +24,6 @@ import { Base, BaseUser, User } from '~/models';
import { CacheGetType, CacheScope, MetaTable } from '~/utils/globals'; import { CacheGetType, CacheScope, MetaTable } from '~/utils/globals';
import { extractProps } from '~/helpers/extractProps'; import { extractProps } from '~/helpers/extractProps';
import { getProjectRolePower } from '~/utils/roleHelper'; import { getProjectRolePower } from '~/utils/roleHelper';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class BaseUsersService { export class BaseUsersService {

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

@ -13,6 +13,7 @@ import type {
ProjectUpdateReqType, ProjectUpdateReqType,
UserType, UserType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers'; import { populateMeta, validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -24,7 +25,6 @@ import { getToolDir } from '~/utils/nc-config';
import { MetaService } from '~/meta/meta.service'; import { MetaService } from '~/meta/meta.service';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
import { TablesService } from '~/services/tables.service'; import { TablesService } from '~/services/tables.service';
import {NcRequest} from "~/interface/config";
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 4); const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 4);
@ -37,7 +37,7 @@ export class BasesService {
) {} ) {}
async baseList(param: { async baseList(param: {
user: { id: string; roles?: string | Record<string, boolean>}; user: { id: string; roles?: string | Record<string, boolean> };
query?: any; query?: any;
}) { }) {
const bases = extractRolesObj(param.user?.roles)[OrgUserRoles.SUPER_ADMIN] const bases = extractRolesObj(param.user?.roles)[OrgUserRoles.SUPER_ADMIN]

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

@ -21,6 +21,7 @@ import type {
import type CustomKnex from '~/db/CustomKnex'; import type CustomKnex from '~/db/CustomKnex';
import type SqlClient from '~/db/sql-client/lib/SqlClient'; import type SqlClient from '~/db/sql-client/lib/SqlClient';
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2'; import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2'; import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2';
import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2'; import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2';
@ -47,7 +48,6 @@ import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
import { MetaService } from '~/meta/meta.service'; import { MetaService } from '~/meta/meta.service';
import {NcRequest} from "~/interface/config";
// todo: move // todo: move
export enum Altered { export enum Altered {

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

@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { FilterReqType, UserType } from 'nocodb-sdk'; import type { FilterReqType, UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { Filter, Hook, View } from '~/models'; import { Filter, Hook, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class FiltersService { export class FiltersService {

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

@ -1,9 +1,9 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { FormViewColumn } from '~/models'; import { FormViewColumn } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class FormColumnsService { export class FormColumnsService {

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

@ -5,11 +5,11 @@ import type {
UserType, UserType,
ViewCreateReqType, ViewCreateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { FormView, View } from '~/models'; import { FormView, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class FormsService { export class FormsService {

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

@ -5,11 +5,11 @@ import type {
UserType, UserType,
ViewCreateReqType, ViewCreateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { GalleryView, View } from '~/models'; import { GalleryView, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class GalleriesService { export class GalleriesService {

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

@ -1,10 +1,10 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { GridColumnReqType } from 'nocodb-sdk'; import type { GridColumnReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { GridViewColumn } from '~/models'; import { GridViewColumn } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class GridColumnsService { export class GridColumnsService {

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

@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents, ViewTypes } from 'nocodb-sdk'; import { AppEvents, ViewTypes } from 'nocodb-sdk';
import type { GridUpdateReqType, ViewCreateReqType } from 'nocodb-sdk'; import type { GridUpdateReqType, ViewCreateReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { GridView, View } from '~/models'; import { GridView, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class GridsService { export class GridsService {

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

@ -1,6 +1,7 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk'; import type { HookReqType, HookTestReqType, HookType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -10,7 +11,6 @@ import {
} from '~/helpers/populateSamplePayload'; } from '~/helpers/populateSamplePayload';
import { invokeWebhook } from '~/helpers/webhookHelpers'; import { invokeWebhook } from '~/helpers/webhookHelpers';
import { Hook, HookLog, Model } from '~/models'; import { Hook, HookLog, Model } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class HooksService { export class HooksService {
@ -38,7 +38,11 @@ export class HooksService {
return await HookLog.list({ fk_hook_id: param.hookId }, param.query); return await HookLog.list({ fk_hook_id: param.hookId }, param.query);
} }
async hookCreate(param: { tableId: string; hook: HookReqType; req: NcRequest }) { async hookCreate(param: {
tableId: string;
hook: HookReqType;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/HookReq', param.hook); validatePayload('swagger.json#/components/schemas/HookReq', param.hook);
this.validateHookPayload(param.hook.notification); this.validateHookPayload(param.hook.notification);
@ -71,7 +75,11 @@ export class HooksService {
return true; return true;
} }
async hookUpdate(param: { hookId: string; hook: HookReqType; req: NcRequest }) { async hookUpdate(param: {
hookId: string;
hook: HookReqType;
req: NcRequest;
}) {
validatePayload('swagger.json#/components/schemas/HookReq', param.hook); validatePayload('swagger.json#/components/schemas/HookReq', param.hook);
const hook = await Hook.get(param.hookId); const hook = await Hook.get(param.hookId);

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

@ -5,11 +5,11 @@ import type {
UserType, UserType,
ViewCreateReqType, ViewCreateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { KanbanView, View } from '~/models'; import { KanbanView, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class KanbansService { export class KanbansService {

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

@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents, ViewTypes } from 'nocodb-sdk'; import { AppEvents, ViewTypes } from 'nocodb-sdk';
import type { MapUpdateReqType, UserType, ViewCreateReqType } from 'nocodb-sdk'; import type { MapUpdateReqType, UserType, ViewCreateReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { MapView, View } from '~/models'; import { MapView, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class MapsService { export class MapsService {

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

@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { VisibilityRuleReqType } from 'nocodb-sdk'; import type { VisibilityRuleReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { Base, Model, ModelRoleVisibility, View } from '~/models'; import { Base, Model, ModelRoleVisibility, View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class ModelVisibilitiesService { export class ModelVisibilitiesService {

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

@ -6,11 +6,11 @@ import type {
} from '~/services/app-hooks/interfaces'; } from '~/services/app-hooks/interfaces';
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'; import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import type { UserType } from 'nocodb-sdk'; import type { UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { Notification } from '~/models'; import { Notification } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class NotificationsService implements OnModuleInit, OnModuleDestroy { export class NotificationsService implements OnModuleInit, OnModuleDestroy {

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

@ -2,12 +2,12 @@ import { Injectable } from '@nestjs/common';
import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk'; import { AppEvents, extractRolesObj, OrgUserRoles } from 'nocodb-sdk';
import type { User } from '~/models'; import type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk'; import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { ApiToken } from '~/models'; import { ApiToken } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class OrgTokensService { export class OrgTokensService {

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

@ -8,6 +8,7 @@ import {
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import validator from 'validator'; import validator from 'validator';
import type { UserType } from 'nocodb-sdk'; import type { UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { BaseUsersService } from '~/services/base-users/base-users.service'; import { BaseUsersService } from '~/services/base-users/base-users.service';
import { NC_APP_SETTINGS } from '~/constants'; import { NC_APP_SETTINGS } from '~/constants';
@ -19,7 +20,6 @@ import { BaseUser, Store, SyncSource, User } from '~/models';
import Noco from '~/Noco'; import Noco from '~/Noco';
import { MetaTable } from '~/utils/globals'; import { MetaTable } from '~/utils/globals';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class OrgUsersService { export class OrgUsersService {
@ -194,7 +194,10 @@ export class OrgUsersService {
NcError.notImplemented(); NcError.notImplemented();
} }
async userInviteResend(param: { userId: string; req: NcRequest }): Promise<any> { async userInviteResend(param: {
userId: string;
req: NcRequest;
}): Promise<any> {
const user = await User.get(param.userId); const user = await User.get(param.userId);
if (!user) { if (!user) {

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

@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { PluginTestReqType, PluginType } from 'nocodb-sdk'; import type { PluginTestReqType, PluginType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2'; import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import { Plugin } from '~/models'; import { Plugin } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class PluginsService { export class PluginsService {

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

@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import type {AppConfig, NcRequest} from '~/interface/config'; import type { AppConfig, NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';

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

@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { SortReqType } from 'nocodb-sdk'; import type { SortReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { Sort } from '~/models'; import { Sort } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class SortsService { export class SortsService {

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

@ -1,13 +1,13 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { BaseReqType } from 'nocodb-sdk'; import type { BaseReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers'; import { populateMeta, validatePayload } from '~/helpers';
import { populateRollupColumnAndHideLTAR } from '~/helpers/populateMeta'; import { populateRollupColumnAndHideLTAR } from '~/helpers/populateMeta';
import { syncBaseMigration } from '~/helpers/syncMigration'; import { syncBaseMigration } from '~/helpers/syncMigration';
import { Base, Source } from '~/models'; import { Base, Source } from '~/models';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class SourcesService { export class SourcesService {

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

@ -1,10 +1,10 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { Base, SyncSource } from '~/models'; import { Base, SyncSource } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class SyncService { export class SyncService {

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

@ -18,6 +18,7 @@ import type {
TableReqType, TableReqType,
UserType, UserType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2'; import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -29,7 +30,6 @@ import { Base, Column, Model, ModelRoleVisibility } from '~/models';
import Noco from '~/Noco'; import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { sanitizeColumnName, validatePayload } from '~/helpers'; import { sanitizeColumnName, validatePayload } from '~/helpers';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class TablesService { export class TablesService {

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

@ -13,6 +13,7 @@ import type {
SignUpReqType, SignUpReqType,
UserType, UserType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { genJwt, setTokenCookie } from '~/services/users/helpers'; import { genJwt, setTokenCookie } from '~/services/users/helpers';
import { NC_APP_SETTINGS } from '~/constants'; import { NC_APP_SETTINGS } from '~/constants';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
@ -26,7 +27,6 @@ import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { BasesService } from '~/services/bases.service'; import { BasesService } from '~/services/bases.service';
import { extractProps } from '~/helpers/extractProps'; import { extractProps } from '~/helpers/extractProps';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class UsersService { export class UsersService {

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

@ -1,10 +1,10 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { AppEvents } from 'nocodb-sdk'; import { AppEvents } from 'nocodb-sdk';
import type { ViewColumnReqType, ViewColumnUpdateReqType } from 'nocodb-sdk'; import type { ViewColumnReqType, ViewColumnUpdateReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { View } from '~/models'; import { View } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable() @Injectable()
export class ViewColumnsService { export class ViewColumnsService {

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

@ -5,11 +5,11 @@ import type {
UserType, UserType,
ViewUpdateReqType, ViewUpdateReqType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers'; import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
import { Model, ModelRoleVisibility, View } from '~/models'; import { Model, ModelRoleVisibility, View } from '~/models';
import {NcRequest} from "~/interface/config";
// todo: move // todo: move
async function xcVisibilityMetaGet(param: { async function xcVisibilityMetaGet(param: {
@ -70,7 +70,7 @@ export class ViewsService {
async viewList(param: { async viewList(param: {
tableId: string; tableId: string;
user: { user: {
roles?: Record<string, boolean> | string, roles?: Record<string, boolean> | string;
base_roles?: Record<string, boolean>; base_roles?: Record<string, boolean>;
}; };
}) { }) {
@ -187,7 +187,11 @@ export class ViewsService {
return result; return result;
} }
async shareViewDelete(param: { viewId: string; user: UserType; req: NcRequest }) { async shareViewDelete(param: {
viewId: string;
user: UserType;
req: NcRequest;
}) {
const view = await View.get(param.viewId); const view = await View.get(param.viewId);
if (!view) { if (!view) {

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

@ -2,9 +2,9 @@ import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport'; import { PassportStrategy } from '@nestjs/passport';
import { extractRolesObj, ProjectRoles } from 'nocodb-sdk'; import { extractRolesObj, ProjectRoles } from 'nocodb-sdk';
import { Strategy } from 'passport-custom'; import { Strategy } from 'passport-custom';
import type { Request } from 'express';
import { ApiToken, BaseUser, User } from '~/models'; import { ApiToken, BaseUser, User } from '~/models';
import { sanitiseUserObj } from '~/utils'; import { sanitiseUserObj } from '~/utils';
import {Request} from 'express'
@Injectable() @Injectable()
export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') { export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') {

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

@ -2,9 +2,8 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport'; import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-custom'; import { Strategy } from 'passport-custom';
import { extractRolesObj } from 'nocodb-sdk'; import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import { Base } from '~/models'; import { Base } from '~/models';
import {Request} from 'express'
@Injectable() @Injectable()
export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') { export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') {

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

@ -3,13 +3,13 @@ import { Injectable, Optional } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport'; import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-google-oauth20'; import { Strategy } from 'passport-google-oauth20';
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import type { Request } from 'express';
import type { VerifyCallback } from 'passport-google-oauth20'; import type { VerifyCallback } from 'passport-google-oauth20';
import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface'; import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
import Noco from '~/Noco'; import Noco from '~/Noco';
import { UsersService } from '~/services/users/users.service'; import { UsersService } from '~/services/users/users.service';
import { BaseUser, Plugin, User } from '~/models'; import { BaseUser, Plugin, User } from '~/models';
import { sanitiseUserObj } from '~/utils'; import { sanitiseUserObj } from '~/utils';
import {Request} from 'express'
@Injectable() @Injectable()
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {

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

@ -1,23 +1,4 @@
import * as express from 'express';
import { Express } from 'express-serve-static-core';
import type { UserType } from 'nocodb-sdk'; import type { UserType } from 'nocodb-sdk';
import { User } from '~/models';
// declare global {
// namespace Express {
// interface Request {
// id?: string;
// ncWorkspaceId?: string;
// ncProjectId?: string;
// user?: any;
// }
// }
// }
//
// interface TokenData {
// userId: string;
// iat: string;
// }
declare module 'express-serve-static-core' { declare module 'express-serve-static-core' {
interface Request { interface Request {
ncWorkspaceId?: string; ncWorkspaceId?: string;

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

Binary file not shown.

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

@ -50,7 +50,8 @@
"dom" "dom"
], ],
"types": [ "types": [
"mocha", "node" "mocha",
"node"
], ],
"typeRoots": [ "typeRoots": [
"../../src/types", "../../src/types",

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

@ -50,9 +50,9 @@
"dom" "dom"
], ],
"types": [ "types": [
"mocha", "node" "mocha",
"node"
], ],
"typeRoots": [ "typeRoots": [
"../../src/types", "../../src/types",
"../../node_modules/@types" "../../node_modules/@types"

21
packages/nocodb/tsconfig.json

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

Loading…
Cancel
Save