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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 { Handler } from 'express';
import type * as e from 'express';
import type { Knex } from 'knex';
import {UserType} from "nocodb-sdk";
import {User} from "~/models";
import type { User } from '~/models';
export interface Route {
path: string;

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

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

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

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

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

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 type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { NcError } from '~/helpers/catchError';
import { validatePayload } from '~/helpers';
import { ApiToken } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable()
export class ApiTokensService {

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

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

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 validator from 'validator';
import type { ProjectUserReqType, UserType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import NocoCache from '~/cache/NocoCache';
import { validatePayload } from '~/helpers';
import Noco from '~/Noco';
@ -23,7 +24,6 @@ import { Base, BaseUser, User } from '~/models';
import { CacheGetType, CacheScope, MetaTable } from '~/utils/globals';
import { extractProps } from '~/helpers/extractProps';
import { getProjectRolePower } from '~/utils/roleHelper';
import {NcRequest} from "~/interface/config";
@Injectable()
export class BaseUsersService {

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

@ -13,6 +13,7 @@ import type {
ProjectUpdateReqType,
UserType,
} from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { populateMeta, validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
@ -24,7 +25,6 @@ import { getToolDir } from '~/utils/nc-config';
import { MetaService } from '~/meta/meta.service';
import { MetaTable } from '~/utils/globals';
import { TablesService } from '~/services/tables.service';
import {NcRequest} from "~/interface/config";
const nanoid = customAlphabet('1234567890abcdefghijklmnopqrstuvwxyz_', 4);
@ -37,7 +37,7 @@ export class BasesService {
) {}
async baseList(param: {
user: { id: string; roles?: string | Record<string, boolean>};
user: { id: string; roles?: string | Record<string, boolean> };
query?: any;
}) {
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 SqlClient from '~/db/sql-client/lib/SqlClient';
import type { BaseModelSqlv2 } from '~/db/BaseModelSqlv2';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import formulaQueryBuilderv2 from '~/db/formulav2/formulaQueryBuilderv2';
import ProjectMgrv2 from '~/db/sql-mgr/v2/ProjectMgrv2';
@ -47,7 +48,6 @@ import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
import { MetaTable } from '~/utils/globals';
import { MetaService } from '~/meta/meta.service';
import {NcRequest} from "~/interface/config";
// todo: move
export enum Altered {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 type { User } from '~/models';
import type { ApiTokenReqType } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
import { AppHooksService } from '~/services/app-hooks/app-hooks.service';
import { validatePayload } from '~/helpers';
import { NcError } from '~/helpers/catchError';
import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { ApiToken } from '~/models';
import {NcRequest} from "~/interface/config";
@Injectable()
export class OrgTokensService {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 { extractRolesObj, ProjectRoles } from 'nocodb-sdk';
import { Strategy } from 'passport-custom';
import type { Request } from 'express';
import { ApiToken, BaseUser, User } from '~/models';
import { sanitiseUserObj } from '~/utils';
import {Request} from 'express'
@Injectable()
export class AuthTokenStrategy extends PassportStrategy(Strategy, 'authtoken') {

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 { Strategy } from 'passport-custom';
import { extractRolesObj } from 'nocodb-sdk';
import type { Request } from 'express';
import { Base } from '~/models';
import {Request} from 'express'
@Injectable()
export class BaseViewStrategy extends PassportStrategy(Strategy, 'base-view') {

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

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 { User } from '~/models';
// declare global {
// namespace Express {
// interface Request {
// id?: string;
// ncWorkspaceId?: string;
// ncProjectId?: string;
// user?: any;
// }
// }
// }
//
// interface TokenData {
// userId: string;
// iat: string;
// }
declare module 'express-serve-static-core' {
interface Request {
ncWorkspaceId?: string;

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"
],
"types": [
"mocha", "node"
"mocha",
"node"
],
"typeRoots": [
"../../src/types",

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

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

21
packages/nocodb/tsconfig.json

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

Loading…
Cancel
Save