Browse Source

feat: column apis

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
7ba6b81e22
  1. 20
      packages/nocodb-nest/src/modules/columns/columns.controller.spec.ts
  2. 70
      packages/nocodb-nest/src/modules/columns/columns.controller.ts
  3. 9
      packages/nocodb-nest/src/modules/columns/columns.module.ts
  4. 18
      packages/nocodb-nest/src/modules/columns/columns.service.spec.ts
  5. 1816
      packages/nocodb-nest/src/modules/columns/columns.service.ts

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

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

70
packages/nocodb-nest/src/modules/columns/columns.controller.ts

@ -0,0 +1,70 @@
import {
Body,
Controller,
Param,
Post,
UseGuards,
Request,
Patch,
Delete,
Get,
} from '@nestjs/common';
import { ColumnReqType } from 'nocodb-sdk';
import {
Acl,
ExtractProjectIdMiddleware,
} from '../../middlewares/extract-project-id/extract-project-id.middleware';
import { ColumnsService } from './columns.service';
import { AuthGuard } from '@nestjs/passport';
@Controller('columns')
@UseGuards(ExtractProjectIdMiddleware, AuthGuard('jwt'))
export class ColumnsController {
constructor(private readonly columnsService: ColumnsService) {}
@Post('/api/v1/db/meta/tables/:tableId/columns/')
@Acl('columnAdd')
async columnAdd(
@Param('tableId') tableId: string,
@Body() body: ColumnReqType,
@Request() req: any,
) {
return await this.columnsService.columnAdd({
tableId,
column: body,
req,
});
}
@Patch('/api/v1/db/meta/columns/:columnId')
@Acl('columnUpdate')
async columnUpdate(
@Param('columnId') columnId: string,
@Body() body: ColumnReqType,
@Request() req: any,
) {
return await this.columnsService.columnUpdate({
columnId: columnId,
column: body,
req,
});
}
@Delete('/api/v1/db/meta/columns/:columnId')
@Acl('columnDelete')
async columnDelete(@Param('columnId') columnId: string, @Request() req: any) {
return await this.columnsService.columnDelete({ columnId, req });
}
@Get('/api/v1/db/meta/columns/:columnId')
@Acl('columnGet')
async columnGet(@Param('columnId') columnId: string) {
return await this.columnsService.columnGet({ columnId });
}
@Post('/api/v1/db/meta/columns/:columnId/primary')
@Acl('columnSetAsPrimary')
async columnSetAsPrimary(@Param('columnId') columnId: string) {
return await this.columnsService.columnSetAsPrimary({ columnId });
}
}

9
packages/nocodb-nest/src/modules/columns/columns.module.ts

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ColumnsService } from './columns.service';
import { ColumnsController } from './columns.controller';
@Module({
controllers: [ColumnsController],
providers: [ColumnsService]
})
export class ColumnsModule {}

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

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

1816
packages/nocodb-nest/src/modules/columns/columns.service.ts

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