Browse Source

fix: at-service corrections

pull/6894/head
Pranav C 1 year ago
parent
commit
d3e765f507
  1. 2
      packages/nocodb/src/helpers/exportImportHelpers.ts
  2. 4
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  3. 47
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
  4. 4
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts
  5. 4
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts
  6. 9
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts
  7. 11
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts

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

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

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

@ -151,7 +151,7 @@ export class DuplicateController {
sourceId: source.id, sourceId: source.id,
dupProjectId: dupProject.id, dupProjectId: dupProject.id,
options: body.options || {}, options: body.options || {},
req: { req: {
user: req.user, user: req.user,
clientIp: req.clientIp, clientIp: req.clientIp,
headers: req.headers, headers: req.headers,
@ -207,7 +207,7 @@ export class DuplicateController {
modelId: model.id, modelId: model.id,
title: uniqueTitle, title: uniqueTitle,
options: body.options || {}, options: body.options || {},
req: { req: {
user: req.user, user: req.user,
clientIp: req.clientIp, clientIp: req.clientIp,
headers: req.headers, headers: req.headers,

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

@ -391,7 +391,7 @@ export class ImportService {
ur: colOptions.ur, ur: colOptions.ur,
dr: colOptions.dr, dr: colOptions.dr,
}, },
}), }) as any,
req: param.req, req: param.req,
user: param.user, user: param.user,
}); });
@ -508,7 +508,7 @@ export class ImportService {
ur: colOptions.ur, ur: colOptions.ur,
dr: colOptions.dr, dr: colOptions.dr,
}, },
}), }) as any,
req: param.req, req: param.req,
user: param.user, user: param.user,
}); });
@ -630,7 +630,7 @@ export class ImportService {
ur: colOptions.ur, ur: colOptions.ur,
dr: colOptions.dr, dr: colOptions.dr,
}, },
}), }) as any,
req: param.req, req: param.req,
user: param.user, user: param.user,
}); });
@ -801,7 +801,7 @@ export class ImportService {
colOptions.fk_relation_column_id, colOptions.fk_relation_column_id,
), ),
}, },
}), }) as any,
req: param.req, req: param.req,
user: param.user, user: param.user,
}); });
@ -827,7 +827,7 @@ export class ImportService {
), ),
rollup_function: colOptions.rollup_function, rollup_function: colOptions.rollup_function,
}, },
}), }) as any,
req: param.req, req: param.req,
user: param.user, user: param.user,
}); });
@ -901,7 +901,7 @@ export class ImportService {
fk_parent_id: getIdOrExternalId(fl.fk_parent_id), fk_parent_id: getIdOrExternalId(fl.fk_parent_id),
}), }),
user: param.user, user: param.user,
req: {}, req: param.req,
}); });
idMap.set(fl.id, fg.id); idMap.set(fl.id, fg.id);
@ -915,7 +915,7 @@ export class ImportService {
...sr, ...sr,
fk_column_id: getIdOrExternalId(sr.fk_column_id), fk_column_id: getIdOrExternalId(sr.fk_column_id),
}), }),
req: {}, req: param.req,
}); });
} }
@ -936,7 +936,7 @@ export class ImportService {
show: fcl.show, show: fcl.show,
order: fcl.order, order: fcl.order,
}, },
req: {}, req: param.req,
}); });
} }
@ -953,7 +953,7 @@ export class ImportService {
grid: { grid: {
...withoutNull(rest), ...withoutNull(rest),
}, },
req: {}, req: param.req,
}); });
} }
break; break;
@ -969,7 +969,7 @@ export class ImportService {
formViewColumn: { formViewColumn: {
...withoutNull(rest), ...withoutNull(rest),
}, },
req: {}, req: param.req,
}); });
} }
break; break;
@ -986,7 +986,7 @@ export class ImportService {
order: view.order, order: view.order,
}, },
user: param.user, user: param.user,
req: {}, req: param.req,
}); });
} }
} }
@ -1013,8 +1013,8 @@ export class ImportService {
tableId: table.id, tableId: table.id,
hook: { hook: {
...hookData, ...hookData,
}, } as any,
req: {}, req: param.req,
}); });
if (!hk) continue; if (!hk) continue;
@ -1031,7 +1031,7 @@ export class ImportService {
fk_parent_id: getIdOrExternalId(fl.fk_parent_id), fk_parent_id: getIdOrExternalId(fl.fk_parent_id),
}), }),
user: param.user, user: param.user,
req: {}, req: param.req,
}); });
idMap.set(fl.id, fg.id); idMap.set(fl.id, fg.id);
@ -1050,6 +1050,7 @@ export class ImportService {
vw: Partial<View>, vw: Partial<View>,
views: View[], views: View[],
user: UserType, user: UserType,
req: any,
): Promise<View> { ): Promise<View> {
if (vw.is_default) { if (vw.is_default) {
const view = views.find((a) => a.is_default); const view = views.find((a) => a.is_default);
@ -1059,7 +1060,7 @@ export class ImportService {
await this.gridsService.gridViewUpdate({ await this.gridsService.gridViewUpdate({
viewId: view.id, viewId: view.id,
grid: gridData, grid: gridData,
req: {}, req,
}); });
} }
} }
@ -1071,14 +1072,14 @@ export class ImportService {
const gview = await this.gridsService.gridViewCreate({ const gview = await this.gridsService.gridViewCreate({
tableId: md.id, tableId: md.id,
grid: vw as ViewCreateReqType, grid: vw as ViewCreateReqType,
req: {}, req: param.req,
}); });
const gridData = withoutNull(vw.view); const gridData = withoutNull(vw.view);
if (gridData) { if (gridData) {
await this.gridsService.gridViewUpdate({ await this.gridsService.gridViewUpdate({
viewId: gview.id, viewId: gview.id,
grid: gridData, grid: gridData,
req: {}, req,
}); });
} }
return gview; return gview;
@ -1088,14 +1089,14 @@ export class ImportService {
tableId: md.id, tableId: md.id,
body: vw as ViewCreateReqType, body: vw as ViewCreateReqType,
user, user,
req: {}, req,
}); });
const formData = withoutNull(vw.view); const formData = withoutNull(vw.view);
if (formData) { if (formData) {
await this.formsService.formViewUpdate({ await this.formsService.formViewUpdate({
formViewId: fview.id, formViewId: fview.id,
form: formData, form: formData,
req: {}, req,
}); });
} }
return fview; return fview;
@ -1105,7 +1106,7 @@ export class ImportService {
tableId: md.id, tableId: md.id,
gallery: vw as ViewCreateReqType, gallery: vw as ViewCreateReqType,
user, user,
req: {}, req,
}); });
const galleryData = withoutNull(vw.view); const galleryData = withoutNull(vw.view);
if (galleryData) { if (galleryData) {
@ -1119,7 +1120,7 @@ export class ImportService {
await this.galleriesService.galleryViewUpdate({ await this.galleriesService.galleryViewUpdate({
galleryViewId: glview.id, galleryViewId: glview.id,
gallery: galleryData, gallery: galleryData,
req: {}, req,
}); });
} }
return glview; return glview;
@ -1129,7 +1130,7 @@ export class ImportService {
tableId: md.id, tableId: md.id,
kanban: vw as ViewCreateReqType, kanban: vw as ViewCreateReqType,
user, user,
req: {}, req,
}); });
const kanbanData = withoutNull(vw.view); const kanbanData = withoutNull(vw.view);
if (kanbanData) { if (kanbanData) {
@ -1175,7 +1176,7 @@ export class ImportService {
await this.kanbansService.kanbanViewUpdate({ await this.kanbansService.kanbanViewUpdate({
kanbanViewId: kview.id, kanbanViewId: kview.id,
kanban: kanbanData, kanban: kanbanData,
req: {}, req,
}); });
} }
return kview; return kview;

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

@ -38,7 +38,7 @@ export class MetaSyncController {
baseId, baseId,
sourceId: 'all', sourceId: 'all',
user: req.user, user: req.user,
req: { req: {
user: req.user, user: req.user,
clientIp: req.clientIp, clientIp: req.clientIp,
headers: req.headers, headers: req.headers,
@ -75,7 +75,7 @@ export class MetaSyncController {
baseId, baseId,
sourceId, sourceId,
user: req.user, user: req.user,
req: { req: {
user: req.user, user: req.user,
clientIp: req.clientIp, clientIp: req.clientIp,
headers: req.headers, headers: req.headers,

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

@ -17,8 +17,8 @@ export class MetaSyncProcessor {
const info: { const info: {
baseId: string; baseId: string;
sourceId: string; sourceId: string;
user: any user: any;
req:any; req: any;
} = job.data; } = job.data;
if (info.sourceId === 'all') { if (info.sourceId === 'all') {

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

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

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

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

Loading…
Cancel
Save