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. 47
      packages/nocodb/src/modules/jobs/jobs/export-import/import.service.ts
  3. 2
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.processor.ts
  4. 9
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts
  5. 9
      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;
} }

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;

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

@ -17,7 +17,7 @@ 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;

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,

9
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';

Loading…
Cancel
Save