Browse Source

Merge pull request #6894 from nocodb/nc-fix/test-connection

refactor: Include request context in app-hooks
pull/6897/head
Pranav C 11 months ago committed by GitHub
parent
commit
fa5d4f9d89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nocodb/src/controllers/api-tokens.controller.ts
  2. 2
      packages/nocodb/src/controllers/attachments-secure.controller.ts
  3. 3
      packages/nocodb/src/controllers/attachments.controller.ts
  4. 4
      packages/nocodb/src/controllers/auth/auth.controller.ts
  5. 3
      packages/nocodb/src/controllers/bases.controller.ts
  6. 6
      packages/nocodb/src/controllers/filters.controller.ts
  7. 12
      packages/nocodb/src/controllers/form-columns.controller.ts
  8. 9
      packages/nocodb/src/controllers/forms.controller.ts
  9. 4
      packages/nocodb/src/controllers/galleries.controller.ts
  10. 13
      packages/nocodb/src/controllers/grid-columns.controller.ts
  11. 10
      packages/nocodb/src/controllers/grids.controller.ts
  12. 15
      packages/nocodb/src/controllers/hooks.controller.ts
  13. 4
      packages/nocodb/src/controllers/kanbans.controller.ts
  14. 4
      packages/nocodb/src/controllers/maps.controller.ts
  15. 3
      packages/nocodb/src/controllers/model-visibilities.controller.ts
  16. 2
      packages/nocodb/src/controllers/org-tokens.controller.ts
  17. 12
      packages/nocodb/src/controllers/plugins.controller.ts
  18. 8
      packages/nocodb/src/controllers/shared-bases.controller.ts
  19. 9
      packages/nocodb/src/controllers/sorts.controller.ts
  20. 12
      packages/nocodb/src/controllers/sources.controller.ts
  21. 11
      packages/nocodb/src/controllers/sync.controller.ts
  22. 1
      packages/nocodb/src/controllers/tables.controller.ts
  23. 5
      packages/nocodb/src/controllers/view-columns.controller.ts
  24. 11
      packages/nocodb/src/controllers/views.controller.ts
  25. 2
      packages/nocodb/src/helpers/exportImportHelpers.ts
  26. 5
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts
  27. 12
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts
  28. 5
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  29. 2
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.processor.ts
  30. 33
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
  31. 10
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts
  32. 7
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts
  33. 12
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts
  34. 3
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.processor.ts
  35. 16
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts
  36. 3
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.processor.ts
  37. 10
      packages/nocodb/src/services/api-tokens.service.ts
  38. 75
      packages/nocodb/src/services/app-hooks/interfaces.ts
  39. 10
      packages/nocodb/src/services/attachments.service.ts
  40. 4
      packages/nocodb/src/services/base-users/base-users.service.ts
  41. 12
      packages/nocodb/src/services/bases.service.ts
  42. 5
      packages/nocodb/src/services/columns.service.ts
  43. 9
      packages/nocodb/src/services/filters.service.ts
  44. 5
      packages/nocodb/src/services/form-columns.service.ts
  45. 10
      packages/nocodb/src/services/forms.service.ts
  46. 5
      packages/nocodb/src/services/galleries.service.ts
  47. 5
      packages/nocodb/src/services/grid-columns.service.ts
  48. 18
      packages/nocodb/src/services/grids.service.ts
  49. 16
      packages/nocodb/src/services/hooks.service.ts
  50. 5
      packages/nocodb/src/services/kanbans.service.ts
  51. 10
      packages/nocodb/src/services/maps.service.ts
  52. 10
      packages/nocodb/src/services/meta-diffs.service.ts
  53. 2
      packages/nocodb/src/services/model-visibilities.service.ts
  54. 44
      packages/nocodb/src/services/notifications.service.ts
  55. 11
      packages/nocodb/src/services/org-tokens.service.ts
  56. 2
      packages/nocodb/src/services/org-users.service.ts
  57. 10
      packages/nocodb/src/services/plugins.service.ts
  58. 11
      packages/nocodb/src/services/shared-bases.service.ts
  59. 10
      packages/nocodb/src/services/sorts.service.ts
  60. 8
      packages/nocodb/src/services/sources.service.ts
  61. 8
      packages/nocodb/src/services/sync.service.ts
  62. 4
      packages/nocodb/src/services/tables.service.ts
  63. 19
      packages/nocodb/src/services/users/users.service.ts
  64. 9
      packages/nocodb/src/services/view-columns.service.ts
  65. 14
      packages/nocodb/src/services/views.service.ts
  66. 1
      packages/nocodb/src/strategies/google.strategy/google.strategy.ts

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

@ -41,6 +41,7 @@ export class ApiTokensController {
return await this.apiTokensService.apiTokenCreate({
tokenBody: body,
userId: req['user'].id,
req,
});
}
@ -53,6 +54,7 @@ export class ApiTokensController {
return await this.apiTokensService.apiTokenDelete({
token,
user: req['user'],
req,
});
}
}

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

@ -41,6 +41,7 @@ export class AttachmentsSecureController {
const attachments = await this.attachmentsService.upload({
files: files,
path: path,
req,
});
return attachments;
@ -59,6 +60,7 @@ export class AttachmentsSecureController {
const attachments = await this.attachmentsService.uploadViaURL({
urls: body,
path,
req,
});
return attachments;

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

@ -37,6 +37,7 @@ export class AttachmentsController {
const attachments = await this.attachmentsService.upload({
files: files,
path: req.query?.path?.toString(),
req,
});
return attachments;
@ -49,10 +50,12 @@ export class AttachmentsController {
async uploadViaURL(
@Body() body: Array<AttachmentReqType>,
@Query('path') path: string,
@Request() req: any,
) {
const attachments = await this.attachmentsService.uploadViaURL({
urls: body,
path,
req,
});
return attachments;

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

@ -83,7 +83,7 @@ export class AuthController {
NcError.forbidden('Email authentication is disabled');
}
await this.setRefreshToken({ req, res });
res.json(await this.usersService.login(req.user));
res.json(await this.usersService.login(req.user, req));
}
@UseGuards(GlobalGuard)
@ -106,7 +106,7 @@ export class AuthController {
@UseGuards(PublicApiLimiterGuard, AuthGuard('google'))
async googleSignin(@Request() req, @Response() res) {
await this.setRefreshToken({ req, res });
res.json(await this.usersService.login(req.user));
res.json(await this.usersService.login(req.user, req));
}
@Get('/auth/google')

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

@ -82,6 +82,7 @@ export class BasesController {
baseId,
base: body,
user: req.user,
req,
});
return base;
@ -93,6 +94,7 @@ export class BasesController {
const deleted = await this.projectsService.baseSoftDelete({
baseId,
user: req.user,
req,
});
return deleted;
@ -106,6 +108,7 @@ export class BasesController {
async baseCreate(@Body() baseBody: ProjectReqType, @Request() req) {
const base = await this.projectsService.baseCreate({
base: baseBody,
req,
user: req['user'],
});

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

@ -50,6 +50,7 @@ export class FiltersController {
filter: body,
viewId: viewId,
user: req.user,
req,
});
return filter;
}
@ -69,6 +70,7 @@ export class FiltersController {
filter: body,
hookId,
user: req.user,
req,
});
return filter;
}
@ -106,6 +108,7 @@ export class FiltersController {
filterId: filterId,
filter: body,
user: req.user,
req,
});
return filter;
}
@ -115,8 +118,9 @@ 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) {
const filter = await this.filtersService.filterDelete({
req,
filterId,
});
return filter;

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

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

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

@ -7,6 +7,7 @@ import {
Patch,
Post,
Req,
Request,
UseGuards,
} from '@nestjs/common';
import { ViewCreateReqType } from 'nocodb-sdk';
@ -44,6 +45,7 @@ export class FormsController {
body,
tableId,
user: req.user,
req,
});
return view;
}
@ -52,10 +54,15 @@ export class FormsController {
'/api/v2/meta/forms/:formViewId',
])
@Acl('formViewUpdate')
async formViewUpdate(@Param('formViewId') formViewId: string, @Body() body) {
async formViewUpdate(
@Param('formViewId') formViewId: string,
@Body() body,
@Request() req: any,
) {
return await this.formsService.formViewUpdate({
formViewId,
form: body,
req,
});
}
}

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

@ -46,6 +46,7 @@ export class GalleriesController {
gallery: body,
// todo: sanitize
tableId,
req,
user: req.user,
});
}
@ -58,10 +59,13 @@ export class GalleriesController {
async galleryViewUpdate(
@Param('galleryViewId') galleryViewId: string,
@Body() body: GalleryUpdateReqType,
@Req() req: any,
) {
return await this.galleriesService.galleryViewUpdate({
galleryViewId,
gallery: body,
req,
});
}
}

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

@ -1,4 +1,12 @@
import { Body, Controller, Get, Param, Patch, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
Get,
Param,
Patch,
Req,
UseGuards,
} from '@nestjs/common';
import { GridColumnReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard';
import { GridColumnsService } from '~/services/grid-columns.service';
@ -28,10 +36,13 @@ export class GridColumnsController {
async gridColumnUpdate(
@Param('gridViewColumnId') gridViewColumnId: string,
@Body() body: GridColumnReqType,
@Req() req: any,
) {
return this.gridColumnsService.gridColumnUpdate({
gridViewColumnId,
grid: body,
req,
});
}
}

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

@ -28,20 +28,26 @@ export class GridsController {
async gridViewCreate(
@Param('tableId') tableId: string,
@Body() body: ViewCreateReqType,
@Req() _req: any,
@Req() req: any,
) {
const view = await this.gridsService.gridViewCreate({
grid: body,
tableId,
req,
});
return view;
}
@Patch(['/api/v1/db/meta/grids/:viewId', '/api/v2/meta/grids/:viewId'])
@Acl('gridViewUpdate')
async gridViewUpdate(@Param('viewId') viewId: string, @Body() body) {
async gridViewUpdate(
@Param('viewId') viewId: string,
@Body() body,
@Req() req: any,
) {
return await this.gridsService.gridViewUpdate({
viewId,
grid: body,
req,
});
}
}

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

@ -41,24 +41,30 @@ export class HooksController {
async hookCreate(
@Param('tableId') tableId: string,
@Body() body: HookReqType,
@Request() req: any,
) {
const hook = await this.hooksService.hookCreate({
hook: body,
tableId,
req,
});
return hook;
}
@Delete(['/api/v1/db/meta/hooks/:hookId', '/api/v2/meta/hooks/:hookId'])
@Acl('hookDelete')
async hookDelete(@Param('hookId') hookId: string) {
return await this.hooksService.hookDelete({ hookId });
async hookDelete(@Param('hookId') hookId: string, @Request() req: any) {
return await this.hooksService.hookDelete({ hookId, req });
}
@Patch(['/api/v1/db/meta/hooks/:hookId', '/api/v2/meta/hooks/:hookId'])
@Acl('hookUpdate')
async hookUpdate(@Param('hookId') hookId: string, @Body() body: HookReqType) {
return await this.hooksService.hookUpdate({ hookId, hook: body });
async hookUpdate(
@Param('hookId') hookId: string,
@Body() body: HookReqType,
@Request() req: any,
) {
return await this.hooksService.hookUpdate({ hookId, hook: body, req });
}
@Post([
@ -78,6 +84,7 @@ export class HooksController {
},
},
tableId: req.params.tableId,
req,
});
return { msg: 'The hook has been tested successfully' };
} catch (e) {

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

@ -46,6 +46,7 @@ export class KanbansController {
tableId,
kanban: body,
user: req.user,
req,
});
}
@ -57,10 +58,13 @@ export class KanbansController {
async kanbanViewUpdate(
@Param('kanbanViewId') kanbanViewId: string,
@Body() body,
@Req() req: any,
) {
return await this.kanbansService.kanbanViewUpdate({
kanbanViewId,
kanban: body,
req,
});
}
}

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

@ -41,6 +41,7 @@ export class MapsController {
tableId,
map: body,
user: req.user,
req,
});
return view;
}
@ -50,10 +51,13 @@ export class MapsController {
async mapViewUpdate(
@Param('mapViewId') mapViewId: string,
@Body() body: MapUpdateReqType,
@Req() req: any,
) {
return await this.mapsService.mapViewUpdate({
mapViewId: mapViewId,
map: body,
req,
});
}
}

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

@ -6,6 +6,7 @@ import {
Param,
Post,
Query,
Req,
UseGuards,
} from '@nestjs/common';
import { GlobalGuard } from '~/guards/global/global.guard';
@ -29,10 +30,12 @@ export class ModelVisibilitiesController {
async xcVisibilityMetaSetAll(
@Param('baseId') baseId: string,
@Body() body: any,
@Req() req: any,
) {
await this.modelVisibilitiesService.xcVisibilityMetaSetAll({
visibilityRule: body,
baseId,
req,
});
return { msg: 'UI ACL has been created successfully' };

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

@ -50,6 +50,7 @@ export class OrgTokensController {
return await this.orgTokensService.apiTokenCreate({
apiToken: body,
user: req['user'],
req,
});
}
@ -63,6 +64,7 @@ export class OrgTokensController {
await this.orgTokensService.apiTokenDelete({
token,
user: req['user'],
req,
});
}
}

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

@ -6,6 +6,7 @@ import {
Param,
Patch,
Post,
Req,
UseGuards,
} from '@nestjs/common';
import { GlobalGuard } from '~/guards/global/global.guard';
@ -47,8 +48,8 @@ export class PluginsController {
@Acl('pluginTest', {
scope: 'org',
})
async pluginTest(@Body() body: any) {
return await this.pluginsService.pluginTest({ body: body });
async pluginTest(@Body() body: any, @Req() req: any) {
return await this.pluginsService.pluginTest({ body: body, req });
}
@Get(['/api/v1/db/meta/plugins/:pluginId', '/api/v2/meta/plugins/:pluginId'])
@ -66,10 +67,15 @@ export class PluginsController {
@Acl('pluginUpdate', {
scope: 'org',
})
async pluginUpdate(@Body() body: any, @Param('pluginId') pluginId: string) {
async pluginUpdate(
@Body() body: any,
@Param('pluginId') pluginId: string,
@Req() req: any,
) {
const plugin = await this.pluginsService.pluginUpdate({
pluginId: pluginId,
plugin: body,
req,
});
return plugin;
}

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

@ -36,6 +36,7 @@ export class SharedBasesController {
roles: body?.roles,
password: body?.password,
siteUrl: req.ncSiteUrl,
req,
});
return sharedBase;
@ -56,6 +57,7 @@ export class SharedBasesController {
roles: body?.roles,
password: body?.password,
siteUrl: req.ncSiteUrl,
req,
});
return sharedBase;
@ -66,9 +68,13 @@ export class SharedBasesController {
'/api/v2/meta/bases/:baseId/shared',
])
@Acl('disableSharedBaseLink')
async disableSharedBaseLink(@Param('baseId') baseId: string): Promise<any> {
async disableSharedBaseLink(
@Param('baseId') baseId: string,
@Request() req: any,
): Promise<any> {
const sharedBase = await this.sharedBasesService.disableSharedBaseLink({
baseId,
req,
});
return sharedBase;

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

@ -44,11 +44,12 @@ export class SortsController {
async sortCreate(
@Param('viewId') viewId: string,
@Body() body: SortReqType,
@Req() _req,
@Req() req,
) {
const sort = await this.sortsService.sortCreate({
sort: body,
viewId,
req,
});
return sort;
}
@ -67,20 +68,22 @@ export class SortsController {
async sortUpdate(
@Param('sortId') sortId: string,
@Body() body: SortReqType,
@Req() _req,
@Req() req,
) {
const sort = await this.sortsService.sortUpdate({
sortId,
sort: body,
req,
});
return sort;
}
@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) {
const sort = await this.sortsService.sortDelete({
sortId,
req,
});
return sort;
}

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

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

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

@ -56,23 +56,30 @@ export class SyncController {
sourceId: sourceId,
userId: (req as any).user.id,
syncPayload: body,
req,
});
}
@Delete(['/api/v1/db/meta/syncs/:syncId', '/api/v2/meta/syncs/:syncId'])
@Acl('syncSourceDelete')
async syncDelete(@Param('syncId') syncId: string) {
async syncDelete(@Param('syncId') syncId: string, @Req() req: any) {
return await this.syncService.syncDelete({
syncId: syncId,
req,
});
}
@Patch(['/api/v1/db/meta/syncs/:syncId', '/api/v2/meta/syncs/:syncId'])
@Acl('syncSourceUpdate')
async syncUpdate(@Param('syncId') syncId: string, @Body() body: any) {
async syncUpdate(
@Param('syncId') syncId: string,
@Body() body: any,
@Req() req: any,
) {
return await this.syncService.syncUpdate({
syncId: syncId,
syncPayload: body,
req,
});
}
}

1
packages/nocodb/src/controllers/tables.controller.ts

@ -93,6 +93,7 @@ export class TablesController {
table: body,
baseId: req.ncProjectId,
user: req.ncProjectId,
req,
});
return { msg: 'The table has been updated successfully' };
}

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

@ -6,6 +6,7 @@ import {
Param,
Patch,
Post,
Req,
UseGuards,
} from '@nestjs/common';
import { ViewColumnReqType } from 'nocodb-sdk';
@ -42,10 +43,12 @@ export class ViewColumnsController {
async columnAdd(
@Param('viewId') viewId: string,
@Body() body: ViewColumnReqType,
@Req() req: any,
) {
const viewColumn = await this.viewColumnsService.columnAdd({
viewId,
column: body,
req,
});
return viewColumn;
}
@ -59,11 +62,13 @@ export class ViewColumnsController {
@Param('viewId') viewId: string,
@Param('columnId') columnId: string,
@Body() body: ViewColumnReqType,
@Req() req: any,
) {
const result = await this.viewColumnsService.columnUpdate({
viewId,
columnId,
column: body,
req,
});
return result;
}

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

@ -48,6 +48,7 @@ export class ViewsController {
viewId,
view: body,
user: req.user,
req,
});
return result;
}
@ -58,6 +59,7 @@ export class ViewsController {
const result = await this.viewsService.viewDelete({
viewId,
user: req.user,
req,
});
return result;
}
@ -100,7 +102,7 @@ export class ViewsController {
@HttpCode(200)
@Acl('shareView')
async shareView(@Param('viewId') viewId: string, @Request() req) {
return await this.viewsService.shareView({ viewId, user: req.user });
return await this.viewsService.shareView({ viewId, user: req.user, req });
}
@Get([
@ -130,6 +132,7 @@ export class ViewsController {
viewId,
sharedView: body,
user: req.user,
req,
});
}
@ -139,6 +142,10 @@ export class ViewsController {
])
@Acl('shareViewDelete')
async shareViewDelete(@Param('viewId') viewId: string, @Request() req) {
return await this.viewsService.shareViewDelete({ viewId, user: req.user });
return await this.viewsService.shareViewDelete({
viewId,
user: req.user,
req,
});
}
}

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

@ -46,7 +46,7 @@ export function reverseGet(map: Map<string, string>, vl: string) {
return undefined;
}
export function withoutId(obj: any) {
export function withoutId(obj: any): any {
const { id, ...rest } = obj;
return rest;
}

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

@ -53,6 +53,11 @@ export class AtImportController {
authToken: '',
baseURL,
user: user,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

12
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts

@ -680,6 +680,7 @@ export class AtImportProcessor {
viewId: view.list[0].id,
view: { title: aTbl_grid.name },
user: syncDB.user,
req: {},
});
recordPerfStats(_perfStart, 'dbView.update');
@ -1527,6 +1528,7 @@ export class AtImportProcessor {
size: attachment.size,
mimetype: attachment.type,
})),
req: {},
});
} catch (e) {
console.log(e);
@ -1569,6 +1571,7 @@ export class AtImportProcessor {
ncCreatedProjectSchema = await this.basesService.baseCreate({
base: { title: projName },
user: { id: syncDB.user.id },
req: {},
});
recordPerfStats(_perfStart, 'base.create');
@ -1619,6 +1622,7 @@ export class AtImportProcessor {
title: viewName,
},
user: syncDB.user,
req: {},
});
recordPerfStats(_perfStart, 'dbView.galleryCreate');
@ -1685,6 +1689,7 @@ export class AtImportProcessor {
tableId: tblId,
body: formData,
user: syncDB.user,
req: {},
});
recordPerfStats(_perfStart, 'dbView.formCreate');
@ -1764,6 +1769,7 @@ export class AtImportProcessor {
grid: {
title: viewName,
},
req: {},
});
recordPerfStats(_perfStart, 'dbView.gridCreate');
@ -2140,6 +2146,7 @@ export class AtImportProcessor {
viewId: viewId,
filter: ncFilters[i],
user: syncDB.user,
req: {},
});
recordPerfStats(_perfStart, 'dbTableFilter.create');
@ -2218,6 +2225,7 @@ export class AtImportProcessor {
group_by_sort:
ncGroup[i].direction === 'ascending' ? 'asc' : 'desc',
},
req: {},
});
} catch (e) {
// ignore
@ -2239,6 +2247,7 @@ export class AtImportProcessor {
fk_column_id: columnId,
direction: s.sortSet[i].ascending ? 'asc' : 'desc',
},
req: {},
});
recordPerfStats(_perfStart, 'dbTableSort.create');
}
@ -2303,6 +2312,7 @@ export class AtImportProcessor {
show: false,
order: j + 1 + c.length,
},
req: {},
});
recordPerfStats(_perfStart, 'dbViewColumn.update');
}
@ -2330,6 +2340,7 @@ export class AtImportProcessor {
await this.formColumnsService.columnUpdate({
formViewColumnId: ncViewColumnId,
formViewColumn: formData,
req: {},
});
recordPerfStats(_perfStart, 'dbView.formColumnUpdate');
}
@ -2339,6 +2350,7 @@ export class AtImportProcessor {
viewId: viewId,
columnId: ncViewColumnId,
column: configData,
req: {},
});
recordPerfStats(_perfStart, 'dbViewColumn.update');
}

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

@ -72,6 +72,7 @@ export class DuplicateController {
...(body.base || {}),
},
user: { id: req.user.id },
req,
});
const job = await this.jobsService.add(JobTypes.DuplicateBase, {
@ -86,6 +87,7 @@ export class DuplicateController {
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
@ -141,6 +143,7 @@ export class DuplicateController {
...(body.base || {}),
},
user: { id: req.user.id },
req,
});
const job = await this.jobsService.add(JobTypes.DuplicateBase, {
@ -151,6 +154,7 @@ export class DuplicateController {
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
@ -206,6 +210,7 @@ export class DuplicateController {
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});

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

@ -104,12 +104,14 @@ export class DuplicateProcessor {
status: null,
},
user: req.user,
req,
});
} catch (e) {
if (dupProject?.id) {
await this.projectsService.baseSoftDelete({
baseId: dupProject.id,
user: req.user,
req,
});
}
throw e;

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

@ -391,7 +391,7 @@ export class ImportService {
ur: colOptions.ur,
dr: colOptions.dr,
},
}),
}) as any,
req: param.req,
user: param.user,
});
@ -508,7 +508,7 @@ export class ImportService {
ur: colOptions.ur,
dr: colOptions.dr,
},
}),
}) as any,
req: param.req,
user: param.user,
});
@ -630,7 +630,7 @@ export class ImportService {
ur: colOptions.ur,
dr: colOptions.dr,
},
}),
}) as any,
req: param.req,
user: param.user,
});
@ -801,7 +801,7 @@ export class ImportService {
colOptions.fk_relation_column_id,
),
},
}),
}) as any,
req: param.req,
user: param.user,
});
@ -827,7 +827,7 @@ export class ImportService {
),
rollup_function: colOptions.rollup_function,
},
}),
}) as any,
req: param.req,
user: param.user,
});
@ -846,7 +846,7 @@ export class ImportService {
...{
formula_raw: colOptions.formula_raw,
},
}),
}) as any,
req: param.req,
user: param.user,
});
@ -883,6 +883,7 @@ export class ImportService {
viewData,
table.views,
param.user,
param.req,
);
if (!vw) continue;
@ -901,6 +902,7 @@ export class ImportService {
fk_parent_id: getIdOrExternalId(fl.fk_parent_id),
}),
user: param.user,
req: param.req,
});
idMap.set(fl.id, fg.id);
@ -914,6 +916,7 @@ export class ImportService {
...sr,
fk_column_id: getIdOrExternalId(sr.fk_column_id),
}),
req: param.req,
});
}
@ -934,6 +937,7 @@ export class ImportService {
show: fcl.show,
order: fcl.order,
},
req: param.req,
});
}
@ -950,6 +954,7 @@ export class ImportService {
grid: {
...withoutNull(rest),
},
req: param.req,
});
}
break;
@ -965,6 +970,7 @@ export class ImportService {
formViewColumn: {
...withoutNull(rest),
},
req: param.req,
});
}
break;
@ -981,6 +987,7 @@ export class ImportService {
order: view.order,
},
user: param.user,
req: param.req,
});
}
}
@ -1007,7 +1014,8 @@ export class ImportService {
tableId: table.id,
hook: {
...hookData,
},
} as any,
req: param.req,
});
if (!hk) continue;
@ -1024,6 +1032,7 @@ export class ImportService {
fk_parent_id: getIdOrExternalId(fl.fk_parent_id),
}),
user: param.user,
req: param.req,
});
idMap.set(fl.id, fg.id);
@ -1042,6 +1051,7 @@ export class ImportService {
vw: Partial<View>,
views: View[],
user: UserType,
req: any,
): Promise<View> {
if (vw.is_default) {
const view = views.find((a) => a.is_default);
@ -1051,6 +1061,7 @@ export class ImportService {
await this.gridsService.gridViewUpdate({
viewId: view.id,
grid: gridData,
req,
});
}
}
@ -1062,12 +1073,14 @@ export class ImportService {
const gview = await this.gridsService.gridViewCreate({
tableId: md.id,
grid: vw as ViewCreateReqType,
req,
});
const gridData = withoutNull(vw.view);
if (gridData) {
await this.gridsService.gridViewUpdate({
viewId: gview.id,
grid: gridData,
req,
});
}
return gview;
@ -1077,12 +1090,14 @@ export class ImportService {
tableId: md.id,
body: vw as ViewCreateReqType,
user,
req,
});
const formData = withoutNull(vw.view);
if (formData) {
await this.formsService.formViewUpdate({
formViewId: fview.id,
form: formData,
req,
});
}
return fview;
@ -1092,6 +1107,7 @@ export class ImportService {
tableId: md.id,
gallery: vw as ViewCreateReqType,
user,
req,
});
const galleryData = withoutNull(vw.view);
if (galleryData) {
@ -1105,6 +1121,7 @@ export class ImportService {
await this.galleriesService.galleryViewUpdate({
galleryViewId: glview.id,
gallery: galleryData,
req,
});
}
return glview;
@ -1114,6 +1131,7 @@ export class ImportService {
tableId: md.id,
kanban: vw as ViewCreateReqType,
user,
req,
});
const kanbanData = withoutNull(vw.view);
if (kanbanData) {
@ -1159,6 +1177,7 @@ export class ImportService {
await this.kanbansService.kanbanViewUpdate({
kanbanViewId: kview.id,
kanban: kanbanData,
req,
});
}
return kview;

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

@ -38,6 +38,11 @@ export class MetaSyncController {
baseId,
sourceId: 'all',
user: req.user,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };
@ -70,6 +75,11 @@ export class MetaSyncController {
baseId,
sourceId,
user: req.user,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

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

@ -18,14 +18,19 @@ export class MetaSyncProcessor {
baseId: string;
sourceId: string;
user: any;
req: any;
} = job.data;
if (info.sourceId === 'all') {
await this.metaDiffsService.metaDiffSync({ baseId: info.baseId });
await this.metaDiffsService.metaDiffSync({
baseId: info.baseId,
req: info.req,
});
} else {
await this.metaDiffsService.baseMetaDiffSync({
baseId: info.baseId,
sourceId: info.sourceId,
req: info.req,
});
}

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

@ -5,6 +5,7 @@ import {
Inject,
Param,
Post,
Req,
UseGuards,
} from '@nestjs/common';
import { BaseReqType } from 'nocodb-sdk';
@ -25,7 +26,11 @@ export class SourceCreateController {
])
@HttpCode(200)
@Acl('baseCreate')
async baseCreate(@Param('baseId') baseId: string, @Body() body: BaseReqType) {
async baseCreate(
@Param('baseId') baseId: string,
@Body() body: BaseReqType,
@Req() req,
) {
const jobs = await this.jobsService.jobList();
const fnd = jobs.find(
(j) => j.name === JobTypes.BaseCreate && j.data.baseId === baseId,
@ -40,6 +45,11 @@ export class SourceCreateController {
const job = await this.jobsService.add(JobTypes.BaseCreate, {
baseId,
source: body,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

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

@ -18,7 +18,7 @@ export class SourceCreateProcessor {
async job(job: Job) {
this.debugLog(`job started for ${job.id}`);
const { baseId, source } = job.data;
const { baseId, source, req } = job.data;
const logBasic = (log) => {
this.jobsLogService.sendLog(job, { message: log });
@ -29,6 +29,7 @@ export class SourceCreateProcessor {
baseId,
source,
logger: logBasic,
req,
});
if (createdBase.isMeta()) {

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

@ -1,4 +1,11 @@
import { Controller, Delete, Inject, Param, UseGuards } from '@nestjs/common';
import {
Controller,
Delete,
Inject,
Param,
Req,
UseGuards,
} from '@nestjs/common';
import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { NcError } from '~/helpers/catchError';
@ -19,7 +26,7 @@ export class SourceDeleteController {
'/api/v2/meta/bases/:baseId/sources/:sourceId',
])
@Acl('baseDelete')
async baseDelete(@Param('sourceId') sourceId: string) {
async baseDelete(@Param('sourceId') sourceId: string, @Req() req) {
const jobs = await this.jobsService.jobList();
const fnd = jobs.find(
(j) => j.name === JobTypes.BaseDelete && j.data.sourceId === sourceId,
@ -33,6 +40,11 @@ export class SourceDeleteController {
const job = await this.jobsService.add(JobTypes.BaseDelete, {
sourceId,
req: {
user: req.user,
clientIp: req.clientIp,
headers: req.headers,
},
});
return { id: job.id };

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

@ -14,10 +14,11 @@ export class SourceDeleteProcessor {
async job(job: Job) {
this.debugLog(`job started for ${job.id}`);
const { sourceId } = job.data;
const { sourceId, req } = job.data;
await this.sourcesService.baseDelete({
sourceId,
req,
});
this.debugLog(`job completed for ${job.id}`);

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

@ -14,7 +14,11 @@ export class ApiTokensService {
async apiTokenList(param: { userId: string }) {
return await ApiToken.list(param.userId);
}
async apiTokenCreate(param: { userId: string; tokenBody: ApiTokenReqType }) {
async apiTokenCreate(param: {
userId: string;
tokenBody: ApiTokenReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ApiTokenReq',
param.tokenBody,
@ -23,6 +27,7 @@ export class ApiTokensService {
this.appHooksService.emit(AppEvents.API_TOKEN_CREATE, {
userId: param.userId,
tokenBody: param.tokenBody,
req: param.req,
});
return await ApiToken.insert({
@ -31,7 +36,7 @@ export class ApiTokensService {
});
}
async apiTokenDelete(param: { token; user: User }) {
async apiTokenDelete(param: { token; user: User; req: any }) {
const apiToken = await ApiToken.getByToken(param.token);
if (
!extractRolesObj(param.user.roles)[OrgUserRoles.SUPER_ADMIN] &&
@ -43,6 +48,7 @@ export class ApiTokensService {
this.appHooksService.emit(AppEvents.API_TOKEN_DELETE, {
userId: param.user?.id,
token: param.token,
req: param.req,
});
// todo: verify token belongs to the user

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

@ -17,14 +17,19 @@ import type {
ViewType,
} from 'nocodb-sdk';
export interface ProjectInviteEvent {
export interface NcBaseEvent extends NcBaseEvent {
req: any;
clientId?: string;
}
export interface ProjectInviteEvent extends NcBaseEvent {
base: BaseType;
user: UserType;
invitedBy: UserType;
ip?: string;
}
export interface ProjectUserUpdateEvent {
export interface ProjectUserUpdateEvent extends NcBaseEvent {
base: BaseType;
user: UserType;
baseUser: ProjectUserReqType;
@ -32,7 +37,7 @@ export interface ProjectUserUpdateEvent {
ip?: string;
}
export interface ProjectUserResendInviteEvent {
export interface ProjectUserResendInviteEvent extends NcBaseEvent {
base: BaseType;
user: UserType;
baseUser: ProjectUserReqType;
@ -40,82 +45,82 @@ export interface ProjectUserResendInviteEvent {
ip?: string;
}
export interface ProjectCreateEvent {
export interface ProjectCreateEvent extends NcBaseEvent {
base: BaseType;
user: UserType;
xcdb: boolean;
}
export interface ProjectUpdateEvent {
export interface ProjectUpdateEvent extends NcBaseEvent {
base: BaseType;
user: UserType;
}
export interface ProjectDeleteEvent {
export interface ProjectDeleteEvent extends NcBaseEvent {
base: BaseType;
user: UserType;
}
export interface WelcomeEvent {
export interface WelcomeEvent extends NcBaseEvent {
user: UserType;
}
export interface UserSignupEvent {
export interface UserSignupEvent extends NcBaseEvent {
user: UserType;
ip?: string;
}
export interface UserSigninEvent {
export interface UserSigninEvent extends NcBaseEvent {
user: UserType;
ip?: string;
auditDescription?: string;
}
export interface ApiCreatedEvent {
export interface ApiCreatedEvent extends NcBaseEvent {
info: any;
}
export interface UserPasswordChangeEvent {
export interface UserPasswordChangeEvent extends NcBaseEvent {
user: UserType;
ip?: string;
}
export interface UserPasswordForgotEvent {
export interface UserPasswordForgotEvent extends NcBaseEvent {
user: UserType;
ip?: string;
}
export interface UserPasswordResetEvent {
export interface UserPasswordResetEvent extends NcBaseEvent {
user: UserType;
ip?: string;
}
export interface UserEmailVerificationEvent {
export interface UserEmailVerificationEvent extends NcBaseEvent {
user: UserType;
ip?: string;
}
export interface TableEvent {
export interface TableEvent extends NcBaseEvent {
table: TableType;
user: UserType;
ip?: string;
}
export interface ViewEvent {
export interface ViewEvent extends NcBaseEvent {
view: ViewType;
user?: UserType;
ip?: string;
showAs?: string;
}
export interface FilterEvent {
export interface FilterEvent extends NcBaseEvent {
filter: FilterType;
ip?: string;
hook?: HookType;
view?: ViewType;
}
export interface ColumnEvent {
export interface ColumnEvent extends NcBaseEvent {
table: TableType;
oldColumn?: ColumnType;
column: ColumnType;
@ -123,75 +128,75 @@ export interface ColumnEvent {
ip?: string;
}
export interface SortEvent {
export interface SortEvent extends NcBaseEvent {
sort: SortType;
ip?: string;
}
export interface OrgUserInviteEvent {
export interface OrgUserInviteEvent extends NcBaseEvent {
invitedBy: UserType;
user: UserType;
count?: number;
ip?: string;
}
export interface ViewColumnEvent {
export interface ViewColumnEvent extends NcBaseEvent {
// todo: type
viewColumn: any;
}
export interface RelationEvent {
export interface RelationEvent extends NcBaseEvent {
column: ColumnType;
}
export interface WebhookEvent {
export interface WebhookEvent extends NcBaseEvent {
hook: HookType;
}
export interface ApiTokenCreateEvent {
export interface ApiTokenCreateEvent extends NcBaseEvent {
userId: string;
tokenBody: ApiTokenReqType;
}
export interface ApiTokenDeleteEvent {
export interface ApiTokenDeleteEvent extends NcBaseEvent {
userId: string;
token: string;
}
export interface PluginTestEvent {
export interface PluginTestEvent extends NcBaseEvent {
testBody: PluginTestReqType;
}
export interface PluginEvent {
export interface PluginEvent extends NcBaseEvent {
plugin: PluginType;
}
export interface SharedBaseEvent {
export interface SharedBaseEvent extends NcBaseEvent {
link?: string;
base?: BaseType;
}
export interface BaseEvent {
export interface BaseEvent extends NcBaseEvent {
source: SourceType;
}
export interface AttachmentEvent {
export interface AttachmentEvent extends NcBaseEvent {
type: 'url' | 'file';
}
export interface FormColumnEvent {}
export interface FormColumnEvent extends NcBaseEvent {}
export interface GridColumnEvent {}
export interface GridColumnEvent extends NcBaseEvent {}
export interface MetaDiffEvent {
export interface MetaDiffEvent extends NcBaseEvent {
base: BaseType;
source?: SourceType;
}
export interface UIAclEvent {
export interface UIAclEvent extends NcBaseEvent {
base: BaseType;
}
export interface SyncSourceEvent {
export interface SyncSourceEvent extends NcBaseEvent {
syncSource: Partial<SyncSource>;
}

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

@ -15,7 +15,7 @@ import { utf8ify } from '~/helpers/stringHelpers';
export class AttachmentsService {
constructor(private readonly appHooksService: AppHooksService) {}
async upload(param: { path?: string; files: FileType[] }) {
async upload(param: { path?: string; files: FileType[]; req: any }) {
// TODO: add getAjvValidatorMw
const filePath = this.sanitizeUrlPath(
param.path?.toString()?.split('/') || [''],
@ -83,12 +83,17 @@ export class AttachmentsService {
this.appHooksService.emit(AppEvents.ATTACHMENT_UPLOAD, {
type: 'file',
req: param.req,
});
return attachments;
}
async uploadViaURL(param: { path?: string; urls: AttachmentReqType[] }) {
async uploadViaURL(param: {
path?: string;
urls: AttachmentReqType[];
req: any;
}) {
// TODO: add getAjvValidatorMw
const filePath = this.sanitizeUrlPath(
param?.path?.toString()?.split('/') || [''],
@ -133,6 +138,7 @@ export class AttachmentsService {
this.appHooksService.emit(AppEvents.ATTACHMENT_UPLOAD, {
type: 'url',
req: param.req,
});
return attachments;
}

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

@ -128,6 +128,7 @@ export class BaseUsersService {
user,
invitedBy: param.req.user,
ip: param.req.clientIp,
req: param.req,
});
const cachedUser = await NocoCache.get(
@ -165,6 +166,7 @@ export class BaseUsersService {
user,
invitedBy: param.req.user,
ip: param.req.clientIp,
req: param.req,
});
// in case of single user check for smtp failure
@ -271,6 +273,7 @@ export class BaseUsersService {
updatedBy: param.req.user,
ip: param.req.clientIp,
baseUser: param.baseUser,
req: param.req,
});
return {
@ -356,6 +359,7 @@ export class BaseUsersService {
invitedBy: param.req.user,
ip: param.req.clientIp,
baseUser: param.baseUser,
req: param.req,
});
return true;

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

@ -63,6 +63,7 @@ export class BasesService {
baseId: string;
base: ProjectUpdateReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ProjectUpdateReq',
@ -84,6 +85,7 @@ export class BasesService {
this.appHooksService.emit(AppEvents.PROJECT_UPDATE, {
base,
user: param.user,
req: param.req,
});
return result;
@ -99,7 +101,7 @@ export class BasesService {
}
}
async baseSoftDelete(param: { baseId: any; user: UserType }) {
async baseSoftDelete(param: { baseId: any; user: UserType; req: any }) {
const base = await Base.getWithInfo(param.baseId);
if (!base) {
@ -111,12 +113,13 @@ export class BasesService {
this.appHooksService.emit(AppEvents.PROJECT_DELETE, {
base,
user: param.user,
req: param.req,
});
return true;
}
async baseCreate(param: { base: ProjectReqType; user: any }) {
async baseCreate(param: { base: ProjectReqType; user: any; req: any }) {
validatePayload('swagger.json#/components/schemas/ProjectReq', param.base);
const baseId = await this.metaService.genNanoid(MetaTable.PROJECT);
@ -205,6 +208,7 @@ export class BasesService {
this.appHooksService.emit(AppEvents.APIS_CREATED, {
info,
req: param.req,
});
delete source.config;
@ -215,18 +219,20 @@ export class BasesService {
base,
user: param.user,
xcdb: !baseBody.external,
req: param.req,
});
return base;
}
async createDefaultBase(param: { user: UserType }) {
async createDefaultBase(param: { user: UserType; req: any }) {
const base = await this.baseCreate({
base: {
title: 'Getting Started',
type: 'database',
} as any,
user: param.user,
req: param.req,
});
const sqlUI = SqlUiFactory.create({ client: base.sources[0].type });

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

@ -1014,6 +1014,7 @@ export class ColumnsService {
column,
user: param.req?.user,
ip: param.req?.clientIp,
req: param.req,
});
return table;
@ -1150,6 +1151,7 @@ export class ColumnsService {
base_id: base.id,
source_id: source.id,
},
req: param.req,
});
break;
@ -1410,6 +1412,7 @@ export class ColumnsService {
},
user: param.req?.user,
ip: param.req?.clientIp,
req: param.req,
});
return table;
@ -1590,6 +1593,7 @@ export class ColumnsService {
}
this.appHooksService.emit(AppEvents.RELATION_DELETE, {
column,
req: param.req,
});
break;
case UITypes.ForeignKey: {
@ -1651,6 +1655,7 @@ export class ColumnsService {
column,
user: param.req?.user,
ip: param.req?.clientIp,
req: param.req,
});
return table;

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

@ -14,6 +14,7 @@ export class FiltersService {
filter: FilterReqType;
hookId: any;
user: UserType;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -31,6 +32,7 @@ export class FiltersService {
this.appHooksService.emit(AppEvents.FILTER_CREATE, {
filter,
hook,
req: param.req,
});
return filter;
}
@ -39,7 +41,7 @@ export class FiltersService {
return Filter.rootFilterListByHook({ hookId: param.hookId });
}
async filterDelete(param: { filterId: string }) {
async filterDelete(param: { filterId: string; req: any }) {
const filter = await Filter.get(param.filterId);
if (!filter) {
@ -50,6 +52,7 @@ export class FiltersService {
this.appHooksService.emit(AppEvents.FILTER_DELETE, {
filter,
req: param.req,
});
return true;
@ -59,6 +62,7 @@ export class FiltersService {
filter: FilterReqType;
viewId: string;
user: UserType;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -72,6 +76,7 @@ export class FiltersService {
this.appHooksService.emit(AppEvents.FILTER_CREATE, {
filter,
view,
req: param.req,
});
return filter;
@ -81,6 +86,7 @@ export class FiltersService {
filter: FilterReqType;
filterId: string;
user: UserType;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/FilterReq', param.filter);
@ -94,6 +100,7 @@ export class FiltersService {
this.appHooksService.emit(AppEvents.FILTER_UPDATE, {
filter,
req: param.req,
});
return res;

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

@ -12,6 +12,7 @@ export class FormColumnsService {
formViewColumnId: string;
// todo: replace with FormColumnReq
formViewColumn: FormViewColumn;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/FormColumnReq',
@ -23,7 +24,9 @@ export class FormColumnsService {
param.formViewColumn,
);
this.appHooksService.emit(AppEvents.FORM_COLUMN_UPDATE, {});
this.appHooksService.emit(AppEvents.FORM_COLUMN_UPDATE, {
req: param.req,
});
return res;
}

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

@ -23,6 +23,7 @@ export class FormsService {
tableId: string;
body: ViewCreateReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewCreateReq',
@ -39,17 +40,23 @@ export class FormsService {
this.appHooksService.emit(AppEvents.VIEW_CREATE, {
view,
showAs: 'form',
req: param.req,
});
this.appHooksService.emit(AppEvents.VIEW_CREATE, {
user: param.user,
view,
req: param.req,
});
return view;
}
async formViewUpdate(param: { formViewId: string; form: FormUpdateReqType }) {
async formViewUpdate(param: {
formViewId: string;
form: FormUpdateReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/FormUpdateReq',
param.form,
@ -65,6 +72,7 @@ export class FormsService {
this.appHooksService.emit(AppEvents.VIEW_UPDATE, {
view,
showAs: 'form',
req: param.req,
});
return res;

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

@ -22,6 +22,8 @@ export class GalleriesService {
tableId: string;
gallery: ViewCreateReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewCreateReq',
@ -38,6 +40,7 @@ export class GalleriesService {
this.appHooksService.emit(AppEvents.VIEW_CREATE, {
view,
showAs: 'gallery',
req: param.req,
});
return view;
}
@ -45,6 +48,7 @@ export class GalleriesService {
async galleryViewUpdate(param: {
galleryViewId: string;
gallery: GalleryUpdateReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/GalleryUpdateReq',
@ -62,6 +66,7 @@ export class GalleriesService {
this.appHooksService.emit(AppEvents.VIEW_UPDATE, {
view,
showAs: 'gallery',
req: param.req,
});
return res;

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

@ -16,6 +16,7 @@ export class GridColumnsService {
async gridColumnUpdate(param: {
gridViewColumnId: string;
grid: GridColumnReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/GridColumnReq',
@ -24,7 +25,9 @@ export class GridColumnsService {
const res = await GridViewColumn.update(param.gridViewColumnId, param.grid);
this.appHooksService.emit(AppEvents.GRID_COLUMN_UPDATE, {});
this.appHooksService.emit(AppEvents.GRID_COLUMN_UPDATE, {
req: param.req,
});
return res;
}

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

@ -10,7 +10,11 @@ import { GridView, View } from '~/models';
export class GridsService {
constructor(private readonly appHooksService: AppHooksService) {}
async gridViewCreate(param: { tableId: string; grid: ViewCreateReqType }) {
async gridViewCreate(param: {
tableId: string;
grid: ViewCreateReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewCreateReq',
param.grid,
@ -26,16 +30,17 @@ export class GridsService {
this.appHooksService.emit(AppEvents.VIEW_CREATE, {
view,
showAs: 'grid',
});
this.appHooksService.emit(AppEvents.VIEW_CREATE, {
view,
req: param.req,
});
return view;
}
async gridViewUpdate(param: { viewId: string; grid: GridUpdateReqType }) {
async gridViewUpdate(param: {
viewId: string;
grid: GridUpdateReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/GridUpdateReq',
param.grid,
@ -52,6 +57,7 @@ export class GridsService {
this.appHooksService.emit(AppEvents.VIEW_UPDATE, {
view,
showAs: 'map',
req: param.req,
});
return res;

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

@ -37,7 +37,7 @@ export class HooksService {
return await HookLog.list({ fk_hook_id: param.hookId }, param.query);
}
async hookCreate(param: { tableId: string; hook: HookReqType }) {
async hookCreate(param: { tableId: string; hook: HookReqType; req: any }) {
validatePayload('swagger.json#/components/schemas/HookReq', param.hook);
this.validateHookPayload(param.hook.notification);
@ -49,12 +49,13 @@ export class HooksService {
this.appHooksService.emit(AppEvents.WEBHOOK_CREATE, {
hook,
req: param.req,
});
return hook;
}
async hookDelete(param: { hookId: string }) {
async hookDelete(param: { hookId: string; req: any }) {
const hook = await Hook.get(param.hookId);
if (!hook) {
@ -64,11 +65,12 @@ export class HooksService {
await Hook.delete(param.hookId);
this.appHooksService.emit(AppEvents.WEBHOOK_DELETE, {
hook,
req: param.req,
});
return true;
}
async hookUpdate(param: { hookId: string; hook: HookReqType }) {
async hookUpdate(param: { hookId: string; hook: HookReqType; req: any }) {
validatePayload('swagger.json#/components/schemas/HookReq', param.hook);
const hook = await Hook.get(param.hookId);
@ -86,12 +88,17 @@ export class HooksService {
...hook,
...param.hook,
},
req: param.req,
});
return res;
}
async hookTest(param: { tableId: string; hookTest: HookTestReqType }) {
async hookTest(param: {
tableId: string;
hookTest: HookTestReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/HookTestReq',
param.hookTest,
@ -122,6 +129,7 @@ export class HooksService {
} finally {
this.appHooksService.emit(AppEvents.WEBHOOK_TEST, {
hook,
req: param.req,
});
}

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

@ -22,6 +22,7 @@ export class KanbansService {
tableId: string;
kanban: ViewCreateReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewCreateReq',
@ -39,6 +40,8 @@ export class KanbansService {
view,
showAs: 'kanban',
user: param.user,
req: param.req,
});
return view;
@ -47,6 +50,7 @@ export class KanbansService {
async kanbanViewUpdate(param: {
kanbanViewId: string;
kanban: KanbanUpdateReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/KanbanUpdateReq',
@ -64,6 +68,7 @@ export class KanbansService {
this.appHooksService.emit(AppEvents.VIEW_UPDATE, {
view,
showAs: 'kanban',
req: param.req,
});
return res;

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

@ -18,6 +18,7 @@ export class MapsService {
tableId: string;
map: ViewCreateReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewCreateReq',
@ -33,12 +34,18 @@ export class MapsService {
this.appHooksService.emit(AppEvents.VIEW_CREATE, {
view,
showAs: 'map',
req: param.req,
});
return view;
}
async mapViewUpdate(param: { mapViewId: string; map: MapUpdateReqType }) {
async mapViewUpdate(param: {
mapViewId: string;
map: MapUpdateReqType;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/MapUpdateReq', param.map);
const view = await View.get(param.mapViewId);
@ -52,6 +59,7 @@ export class MapsService {
this.appHooksService.emit(AppEvents.VIEW_UPDATE, {
view,
showAs: 'map',
req: param.req,
});
return res;

10
packages/nocodb/src/services/meta-diffs.service.ts

@ -882,7 +882,7 @@ export class MetaDiffsService {
await this.extractAndGenerateManyToManyRelations(await source.getModels());
}
async metaDiffSync(param: { baseId: string }) {
async metaDiffSync(param: { baseId: string; req: any }) {
const base = await Base.getWithInfo(param.baseId);
for (const source of base.sources) {
await this.syncBaseMeta(base, source);
@ -890,12 +890,17 @@ export class MetaDiffsService {
this.appHooksService.emit(AppEvents.META_DIFF_SYNC, {
base,
req: param.req,
});
return true;
}
async baseMetaDiffSync(param: { baseId: string; sourceId: string }) {
async baseMetaDiffSync(param: {
baseId: string;
sourceId: string;
req: any;
}) {
const base = await Base.getWithInfo(param.baseId);
const source = await Source.get(param.sourceId);
@ -904,6 +909,7 @@ export class MetaDiffsService {
this.appHooksService.emit(AppEvents.META_DIFF_SYNC, {
base,
source,
req: param.req,
});
return true;

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

@ -13,6 +13,7 @@ export class ModelVisibilitiesService {
async xcVisibilityMetaSetAll(param: {
visibilityRule: VisibilityRuleReqType;
baseId: string;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/VisibilityRuleReq',
@ -58,6 +59,7 @@ export class ModelVisibilitiesService {
}
this.appHooksService.emit(AppEvents.UI_ACL_UPDATE, {
base,
req: param.req,
});
return true;

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

@ -15,8 +15,11 @@ import { Notification } from '~/models';
export class NotificationsService implements OnModuleInit, OnModuleDestroy {
constructor(protected readonly appHooks: AppHooksService) {}
protected async insertNotification(insertData: Partial<Notification>) {
this.appHooks.emit('notification' as any, insertData);
protected async insertNotification(
insertData: Partial<Notification>,
req: any,
) {
this.appHooks.emit('notification' as any, { ...insertData, req } as any);
await Notification.insert(insertData);
}
@ -28,32 +31,39 @@ export class NotificationsService implements OnModuleInit, OnModuleDestroy {
event: AppEvents;
data: any;
}) {
const { req } = data;
switch (event) {
case AppEvents.PROJECT_INVITE:
{
const { base, user, invitedBy } = data as ProjectInviteEvent;
await this.insertNotification({
fk_user_id: user.id,
type: AppEvents.PROJECT_INVITE,
body: {
id: base.id,
title: base.title,
type: base.type,
invited_by: invitedBy.email,
await this.insertNotification(
{
fk_user_id: user.id,
type: AppEvents.PROJECT_INVITE,
body: {
id: base.id,
title: base.title,
type: base.type,
invited_by: invitedBy.email,
},
},
});
req,
);
}
break;
case AppEvents.WELCOME:
{
const { user } = data as WelcomeEvent;
const { user, req } = data as WelcomeEvent;
await this.insertNotification({
fk_user_id: user.id,
type: AppEvents.WELCOME,
body: {},
});
await this.insertNotification(
{
fk_user_id: user.id,
type: AppEvents.WELCOME,
body: {},
},
req,
);
}
break;
}

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

@ -35,7 +35,11 @@ export class OrgTokensService {
);
}
async apiTokenCreate(param: { user: User; apiToken: ApiTokenReqType }) {
async apiTokenCreate(param: {
user: User;
apiToken: ApiTokenReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ApiTokenReq',
param.apiToken,
@ -49,12 +53,14 @@ export class OrgTokensService {
this.appHooksService.emit(AppEvents.ORG_API_TOKEN_CREATE, {
tokenBody: param.apiToken,
userId: param.user?.id,
req: param.req,
});
return apiToken;
}
async apiTokenDelete(param: { user: User; token: string }) {
async apiTokenDelete(param: { user: User; token: string; req: any }) {
const fk_user_id = param.user.id;
const apiToken = await ApiToken.getByToken(param.token);
if (
@ -68,6 +74,7 @@ export class OrgTokensService {
this.appHooksService.emit(AppEvents.ORG_API_TOKEN_DELETE, {
token: param.token,
userId: param.user?.id,
req: param['req'],
});
return res;

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

@ -148,6 +148,7 @@ export class OrgUsersService {
user,
count,
ip: param.req.clientIp,
req: param.req,
});
// in case of single user check for smtp failure
@ -232,6 +233,7 @@ export class OrgUsersService {
invitedBy: param.req.user,
user,
ip: param.req.clientIp,
req: param.req,
});
return true;

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

@ -14,7 +14,7 @@ export class PluginsService {
return await Plugin.list();
}
async pluginTest(param: { body: PluginTestReqType }) {
async pluginTest(param: { body: PluginTestReqType; req: any }) {
validatePayload(
'swagger.json#/components/schemas/PluginTestReq',
param.body,
@ -22,6 +22,7 @@ export class PluginsService {
this.appHooksService.emit(AppEvents.PLUGIN_TEST, {
testBody: param.body,
req: param.req,
});
return await NcPluginMgrv2.test(param.body);
}
@ -29,7 +30,11 @@ export class PluginsService {
async pluginRead(param: { pluginId: string }) {
return await Plugin.get(param.pluginId);
}
async pluginUpdate(param: { pluginId: string; plugin: PluginType }) {
async pluginUpdate(param: {
pluginId: string;
plugin: PluginType;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/PluginReq', param.plugin);
const plugin = await Plugin.update(param.pluginId, param.plugin);
@ -38,6 +43,7 @@ export class PluginsService {
plugin.active ? AppEvents.PLUGIN_INSTALL : AppEvents.PLUGIN_UNINSTALL,
{
plugin,
req: param.req,
},
);

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

@ -25,6 +25,8 @@ export class SharedBasesService {
roles: string;
password: string;
siteUrl: string;
req: any;
}): Promise<any> {
validatePayload('swagger.json#/components/schemas/SharedBaseReq', param);
@ -61,6 +63,7 @@ export class SharedBasesService {
this.appHooksService.emit(AppEvents.SHARED_BASE_GENERATE_LINK, {
link: data.url,
base,
req: param.req,
});
return data;
@ -71,6 +74,7 @@ export class SharedBasesService {
roles: string;
password: string;
siteUrl: string;
req: any;
}): Promise<any> {
validatePayload('swagger.json#/components/schemas/SharedBaseReq', param);
@ -106,6 +110,7 @@ export class SharedBasesService {
this.appHooksService.emit(AppEvents.SHARED_BASE_GENERATE_LINK, {
link: data.url,
base,
req: param.req,
});
return data;
}
@ -125,7 +130,10 @@ export class SharedBasesService {
return `${siteUrl}${config.dashboardPath}#/base/${base.uuid}`;
}
async disableSharedBaseLink(param: { baseId: string }): Promise<any> {
async disableSharedBaseLink(param: {
baseId: string;
req: any;
}): Promise<any> {
const base = await Base.get(param.baseId);
if (!base) {
@ -139,6 +147,7 @@ export class SharedBasesService {
this.appHooksService.emit(AppEvents.SHARED_BASE_DELETE_LINK, {
base,
req: param.req,
});
return { uuid: null };
}

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

@ -14,7 +14,7 @@ export class SortsService {
return Sort.get(param.sortId);
}
async sortDelete(param: { sortId: string }) {
async sortDelete(param: { sortId: string; req: any }) {
const sort = await Sort.get(param.sortId);
if (!sort) {
@ -25,11 +25,12 @@ export class SortsService {
this.appHooksService.emit(AppEvents.SORT_CREATE, {
sort,
req: param.req,
});
return true;
}
async sortUpdate(param: { sortId: any; sort: SortReqType }) {
async sortUpdate(param: { sortId: any; sort: SortReqType; req: any }) {
validatePayload('swagger.json#/components/schemas/SortReq', param.sort);
const sort = await Sort.get(param.sortId);
@ -42,12 +43,14 @@ export class SortsService {
this.appHooksService.emit(AppEvents.SORT_UPDATE, {
sort,
req: param.req,
});
return res;
}
async sortCreate(param: { viewId: any; sort: SortReqType }) {
async sortCreate(param: { viewId: any; sort: SortReqType; req: any }) {
validatePayload('swagger.json#/components/schemas/SortReq', param.sort);
const sort = await Sort.insert({
@ -57,6 +60,7 @@ export class SortsService {
this.appHooksService.emit(AppEvents.SORT_CREATE, {
sort,
req: param.req,
});
return sort;

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

@ -24,6 +24,7 @@ export class SourcesService {
sourceId: string;
source: BaseReqType;
baseId: string;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/BaseReq', param.source);
@ -40,6 +41,7 @@ export class SourcesService {
this.appHooksService.emit(AppEvents.BASE_UPDATE, {
source,
req: param.req,
});
return source;
@ -51,12 +53,13 @@ export class SourcesService {
return sources;
}
async baseDelete(param: { sourceId: string }) {
async baseDelete(param: { sourceId: string; req: any }) {
try {
const source = await Source.get(param.sourceId, true);
await source.delete();
this.appHooksService.emit(AppEvents.BASE_DELETE, {
source,
req: param.req,
});
} catch (e) {
NcError.badRequest(e);
@ -78,6 +81,7 @@ export class SourcesService {
baseId: string;
source: BaseReqType;
logger?: (message: string) => void;
req: any;
}) {
validatePayload('swagger.json#/components/schemas/BaseReq', param.source);
@ -103,12 +107,14 @@ export class SourcesService {
this.appHooksService.emit(AppEvents.APIS_CREATED, {
info,
req: param.req,
});
delete source.config;
this.appHooksService.emit(AppEvents.BASE_CREATE, {
source,
req: param.req,
});
return source;

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

@ -20,6 +20,7 @@ export class SyncService {
sourceId?: string;
userId: string;
syncPayload: Partial<SyncSource>;
req: any;
}) {
const base = await Base.getWithInfo(param.baseId);
@ -32,12 +33,13 @@ export class SyncService {
this.appHooksService.emit(AppEvents.SYNC_SOURCE_CREATE, {
syncSource: sync,
req: param.req,
});
return sync;
}
async syncDelete(param: { syncId: string }) {
async syncDelete(param: { syncId: string; req: any }) {
const syncSource = await SyncSource.get(param.syncId);
if (!syncSource) {
@ -48,6 +50,7 @@ export class SyncService {
this.appHooksService.emit(AppEvents.SYNC_SOURCE_DELETE, {
syncSource,
req: param.req,
});
return res;
}
@ -55,6 +58,7 @@ export class SyncService {
async syncUpdate(param: {
syncId: string;
syncPayload: Partial<SyncSource>;
req: any;
}) {
const syncSource = await SyncSource.get(param.syncId);
@ -66,6 +70,8 @@ export class SyncService {
this.appHooksService.emit(AppEvents.SYNC_SOURCE_UPDATE, {
syncSource,
req: param.req,
});
return res;

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

@ -43,6 +43,7 @@ export class TablesService {
table: TableReqType & { base_id?: string };
baseId?: string;
user: UserType;
req: any;
}) {
const model = await Model.get(param.tableId);
@ -145,6 +146,7 @@ export class TablesService {
this.appHooksService.emit(AppEvents.TABLE_UPDATE, {
table: model,
user: param.user,
req: param.req,
});
return true;
@ -225,6 +227,7 @@ export class TablesService {
table,
user: param.user,
ip: param.req?.clientIp,
req: param.req,
});
result = await table.delete(ncMeta);
@ -528,6 +531,7 @@ export class TablesService {
table: result,
user: param.user,
ip: param.req?.clientIp,
req: param.req,
});
return result;

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

@ -91,11 +91,13 @@ export class UsersService {
salt,
password,
email_verification_token,
req,
}: {
email: string;
salt: any;
password;
email_verification_token;
req: any;
}) {
this.validateEmailPattern(email);
@ -137,7 +139,7 @@ export class UsersService {
// if first user and super admin, create a base
if (isFirstUser && process.env.NC_CLOUD !== 'true') {
// todo: update swagger type
(user as any).createdProject = await this.createDefaultProject(user);
(user as any).createdProject = await this.createDefaultProject(user, req);
}
// todo: update swagger type
@ -191,6 +193,7 @@ export class UsersService {
this.appHooksService.emit(AppEvents.USER_PASSWORD_CHANGE, {
user: user,
ip: param.req?.clientIp,
req: param.req,
});
return true;
@ -247,6 +250,7 @@ export class UsersService {
this.appHooksService.emit(AppEvents.USER_PASSWORD_FORGOT, {
user: user,
ip: param.req?.clientIp,
req: param.req,
});
} else {
return NcError.badRequest('Your email has not been registered.');
@ -319,6 +323,7 @@ export class UsersService {
this.appHooksService.emit(AppEvents.USER_PASSWORD_RESET, {
user: user,
ip: param.req?.clientIp,
req: param.req,
});
return true;
@ -348,6 +353,7 @@ export class UsersService {
this.appHooksService.emit(AppEvents.USER_EMAIL_VERIFICATION, {
user: user,
ip: req?.clientIp,
req,
});
return true;
@ -459,6 +465,7 @@ export class UsersService {
salt,
password,
email_verification_token,
req: param.req,
});
createdProject = _createdProject;
}
@ -497,18 +504,21 @@ export class UsersService {
this.appHooksService.emit(AppEvents.USER_SIGNUP, {
user: user,
ip: param.req?.clientIp,
req: param.req,
});
this.appHooksService.emit(AppEvents.WELCOME, {
user,
req: param.req,
});
return { ...(await this.login(user)), createdProject };
return { ...(await this.login(user, param.req)), createdProject };
}
async login(user: UserType & { provider?: string }) {
async login(user: UserType & { provider?: string }, req: any) {
this.appHooksService.emit(AppEvents.USER_SIGNIN, {
user,
req,
});
return {
token: genJwt(user, Noco.getConfig()),
@ -535,10 +545,11 @@ export class UsersService {
param.res.clearCookie('refresh_token');
}
private async createDefaultProject(user: User) {
private async createDefaultProject(user: User, req: any) {
// create new base for user
const base = await this.basesService.createDefaultBase({
user,
req,
});
return base;

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

@ -12,7 +12,11 @@ export class ViewColumnsService {
async columnList(param: { viewId: string }) {
return await View.getColumns(param.viewId, undefined);
}
async columnAdd(param: { viewId: string; column: ViewColumnReqType }) {
async columnAdd(param: {
viewId: string;
column: ViewColumnReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewColumnReq',
param.column,
@ -28,6 +32,7 @@ export class ViewColumnsService {
);
this.appHooksService.emit(AppEvents.VIEW_COLUMN_CREATE, {
viewColumn,
req: param.req,
});
return viewColumn;
@ -37,6 +42,7 @@ export class ViewColumnsService {
viewId: string;
columnId: string;
column: ViewColumnUpdateReqType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewColumnUpdateReq',
@ -51,6 +57,7 @@ export class ViewColumnsService {
this.appHooksService.emit(AppEvents.VIEW_COLUMN_UPDATE, {
viewColumn: param.column,
req: param.req,
});
return result;

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

@ -91,7 +91,7 @@ export class ViewsService {
return filteredViewList;
}
async shareView(param: { viewId: string; user: UserType }) {
async shareView(param: { viewId: string; user: UserType; req: any }) {
const res = await View.share(param.viewId);
const view = await View.get(param.viewId);
@ -103,6 +103,7 @@ export class ViewsService {
this.appHooksService.emit(AppEvents.SHARED_VIEW_CREATE, {
user: param.user,
view,
req: param.req,
});
return res;
@ -112,6 +113,7 @@ export class ViewsService {
viewId: string;
view: ViewUpdateReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/ViewUpdateReq',
@ -132,11 +134,13 @@ export class ViewsService {
...param.view,
},
user: param.user,
req: param.req,
});
return result;
}
async viewDelete(param: { viewId: string; user: UserType }) {
async viewDelete(param: { viewId: string; user: UserType; req: any }) {
const view = await View.get(param.viewId);
if (!view) {
@ -148,6 +152,7 @@ export class ViewsService {
this.appHooksService.emit(AppEvents.VIEW_DELETE, {
view,
user: param.user,
req: param.req,
});
return true;
@ -157,6 +162,7 @@ export class ViewsService {
viewId: string;
sharedView: SharedViewReqType;
user: UserType;
req: any;
}) {
validatePayload(
'swagger.json#/components/schemas/SharedViewReq',
@ -174,12 +180,13 @@ export class ViewsService {
this.appHooksService.emit(AppEvents.SHARED_VIEW_UPDATE, {
user: param.user,
view,
req: param.req,
});
return result;
}
async shareViewDelete(param: { viewId: string; user: UserType }) {
async shareViewDelete(param: { viewId: string; user: UserType; req: any }) {
const view = await View.get(param.viewId);
if (!view) {
@ -190,6 +197,7 @@ export class ViewsService {
this.appHooksService.emit(AppEvents.SHARED_VIEW_DELETE, {
user: param.user,
view,
req: param.req,
});
return true;

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

@ -53,6 +53,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
email: profile.emails[0].value,
password: '',
salt,
req,
});
return done(null, sanitiseUserObj(user));
}

Loading…
Cancel
Save