Browse Source

feat: meta diff apis

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
f80a154d51
  1. 3
      packages/nocodb-nest/src/app.module.ts
  2. 20
      packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.controller.spec.ts
  3. 51
      packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.controller.ts
  4. 9
      packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.module.ts
  5. 18
      packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.service.spec.ts
  6. 1113
      packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.service.ts

3
packages/nocodb-nest/src/app.module.ts

@ -33,9 +33,10 @@ import { AttachmentsModule } from './modules/attachments/attachments.module';
import { OrgLcenseModule } from './modules/org-lcense/org-lcense.module'; import { OrgLcenseModule } from './modules/org-lcense/org-lcense.module';
import { OrgTokensModule } from './modules/org-tokens/org-tokens.module'; import { OrgTokensModule } from './modules/org-tokens/org-tokens.module';
import { OrgUsersModule } from './modules/org-users/org-users.module'; import { OrgUsersModule } from './modules/org-users/org-users.module';
import { MetaDiffsModule } from './modules/meta-diffs/meta-diffs.module';
@Module({ @Module({
imports: [AuthModule, UsersModule, UtilsModule, ProjectsModule, TablesModule, ViewsModule, FiltersModule, SortsModule, ColumnsModule, ViewColumnsModule, BasesModule, HooksModule, SharedBasesModule, FormsModule, GridsModule, KanbansModule, GalleriesModule, FormColumnsModule, GridColumnsModule, MapsModule, ProjectUsersModule, ModelVisibilitiesModule, HookFiltersModule, ApiTokensModule, AttachmentsModule, OrgLcenseModule, OrgTokensModule, OrgUsersModule], imports: [AuthModule, UsersModule, UtilsModule, ProjectsModule, TablesModule, ViewsModule, FiltersModule, SortsModule, ColumnsModule, ViewColumnsModule, BasesModule, HooksModule, SharedBasesModule, FormsModule, GridsModule, KanbansModule, GalleriesModule, FormColumnsModule, GridColumnsModule, MapsModule, ProjectUsersModule, ModelVisibilitiesModule, HookFiltersModule, ApiTokensModule, AttachmentsModule, OrgLcenseModule, OrgTokensModule, OrgUsersModule, MetaDiffsModule],
controllers: [], controllers: [],
providers: [Connection, MetaService, JwtStrategy, ExtractProjectIdMiddleware], providers: [Connection, MetaService, JwtStrategy, ExtractProjectIdMiddleware],
exports: [Connection, MetaService], exports: [Connection, MetaService],

20
packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.controller.spec.ts

@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { MetaDiffsController } from './meta-diffs.controller';
import { MetaDiffsService } from './meta-diffs.service';
describe('MetaDiffsController', () => {
let controller: MetaDiffsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [MetaDiffsController],
providers: [MetaDiffsService],
}).compile();
controller = module.get<MetaDiffsController>(MetaDiffsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});

51
packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.controller.ts

@ -0,0 +1,51 @@
import { Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import {
Acl,
ExtractProjectIdMiddleware,
} from '../../middlewares/extract-project-id/extract-project-id.middleware';
import { MetaDiffsService } from './meta-diffs.service';
import { AuthGuard } from '@nestjs/passport';
@Controller('meta-diffs')
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt'))
export class MetaDiffsController {
constructor(private readonly metaDiffsService: MetaDiffsService) {}
@Get('/api/v1/db/meta/projects/:projectId/meta-diff')
@Acl('metaDiff')
async metaDiff(@Param('projectId') projectId: string) {
return await this.metaDiffsService.metaDiff({ projectId });
}
@Get('/api/v1/db/meta/projects/:projectId/meta-diff/:baseId')
async baseMetaDiff(
@Param('projectId') projectId: string,
@Param('baseId') baseId: string,
) {
return await this.metaDiffsService.baseMetaDiff({
baseId,
projectId,
});
}
@Post('/api/v1/db/meta/projects/:projectId/meta-diff')
@Acl('metaDiffSync')
async metaDiffSync(@Param('projectId') projectId: string) {
await this.metaDiffsService.metaDiffSync({ projectId });
return { msg: 'The meta has been synchronized successfully' };
}
@Post('/api/v1/db/meta/projects/:projectId/meta-diff/:baseId')
@Acl('baseMetaDiffSync')
async baseMetaDiffSync(
@Param('projectId') projectId: string,
@Param('baseId') baseId: string,
) {
await this.metaDiffsService.baseMetaDiffSync({
projectId,
baseId,
});
return { msg: 'The base meta has been synchronized successfully' };
}
}

9
packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.module.ts

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { MetaDiffsService } from './meta-diffs.service';
import { MetaDiffsController } from './meta-diffs.controller';
@Module({
controllers: [MetaDiffsController],
providers: [MetaDiffsService]
})
export class MetaDiffsModule {}

18
packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.service.spec.ts

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { MetaDiffsService } from './meta-diffs.service';
describe('MetaDiffsService', () => {
let service: MetaDiffsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [MetaDiffsService],
}).compile();
service = module.get<MetaDiffsService>(MetaDiffsService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

1113
packages/nocodb-nest/src/modules/meta-diffs/meta-diffs.service.ts

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save