• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 8389227144

22 Mar 2024 10:56AM UTC coverage: 26.087% (-53.9%) from 79.937%
8389227144

push

github

web-flow
refactor: move zod schema to openapi (#487)

2100 of 3363 branches covered (62.44%)

282 of 757 new or added lines in 74 files covered. (37.25%)

14879 existing lines in 182 files now uncovered.

25574 of 98035 relevant lines covered (26.09%)

5.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.29
/apps/nestjs-backend/src/features/table/open-api/table-open-api.controller.ts
1
/* eslint-disable sonarjs/no-duplicate-string */
1✔
2
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
1✔
3
import type { ITableFullVo, ITableListVo, ITableVo } from '@teable/openapi';
1✔
4
import {
1✔
5
  getTableQuerySchema,
1✔
6
  IGetTableQuery,
1✔
7
  tableRoSchema,
1✔
8
  ICreateTableWithDefault,
1✔
9
  dbTableNameRoSchema,
1✔
10
  getGraphRoSchema,
1✔
11
  IDbTableNameRo,
1✔
12
  IGetGraphRo,
1✔
13
  ISqlQuerySchema,
1✔
14
  ITableDescriptionRo,
1✔
15
  ITableIconRo,
1✔
16
  ITableNameRo,
1✔
17
  IUpdateOrderRo,
1✔
18
  sqlQuerySchema,
1✔
19
  tableDescriptionRoSchema,
1✔
20
  tableIconRoSchema,
1✔
21
  tableNameRoSchema,
1✔
22
  updateOrderRoSchema,
1✔
23
} from '@teable/openapi';
1✔
24
import { ZodValidationPipe } from '../../../zod.validation.pipe';
1✔
25
import { Permissions } from '../../auth/decorators/permissions.decorator';
1✔
26
import { TableService } from '../table.service';
1✔
27
import { TableOpenApiService } from './table-open-api.service';
1✔
28
import { TablePipe } from './table.pipe';
1✔
29

1✔
30
@Controller('api/base/:baseId/table')
1✔
31
export class TableController {
1✔
32
  constructor(
3✔
33
    private readonly tableService: TableService,
3✔
34
    private readonly tableOpenApiService: TableOpenApiService
3✔
35
  ) {}
3✔
36

3✔
37
  @Permissions('table|read')
3✔
38
  @Get(':tableId/default-view-id')
×
39
  async getDefaultViewId(@Param('tableId') tableId: string): Promise<{ id: string }> {
×
40
    return await this.tableService.getDefaultViewId(tableId);
×
41
  }
×
42

3✔
43
  @Permissions('table|read')
3✔
UNCOV
44
  @Get(':tableId')
×
UNCOV
45
  async getTable(
×
UNCOV
46
    @Param('baseId') baseId: string,
×
UNCOV
47
    @Param('tableId') tableId: string,
×
UNCOV
48
    @Query(new ZodValidationPipe(getTableQuerySchema)) query: IGetTableQuery
×
UNCOV
49
  ): Promise<ITableVo> {
×
UNCOV
50
    return await this.tableOpenApiService.getTable(baseId, tableId, query);
×
UNCOV
51
  }
×
52

3✔
53
  @Permissions('table|read')
3✔
UNCOV
54
  @Get()
×
UNCOV
55
  async getTables(@Param('baseId') baseId: string): Promise<ITableListVo> {
×
UNCOV
56
    return await this.tableOpenApiService.getTables(baseId);
×
UNCOV
57
  }
×
58

3✔
59
  @Permissions('table|update')
3✔
UNCOV
60
  @Put(':tableId/name')
×
UNCOV
61
  async updateName(
×
UNCOV
62
    @Param('baseId') baseId: string,
×
UNCOV
63
    @Param('tableId') tableId: string,
×
UNCOV
64
    @Body(new ZodValidationPipe(tableNameRoSchema)) tableNameRo: ITableNameRo
×
UNCOV
65
  ) {
×
UNCOV
66
    return await this.tableOpenApiService.updateName(baseId, tableId, tableNameRo.name);
×
UNCOV
67
  }
×
68

3✔
69
  @Permissions('table|update')
3✔
UNCOV
70
  @Put(':tableId/icon')
×
UNCOV
71
  async updateIcon(
×
UNCOV
72
    @Param('baseId') baseId: string,
×
UNCOV
73
    @Param('tableId') tableId: string,
×
UNCOV
74
    @Body(new ZodValidationPipe(tableIconRoSchema)) tableIconRo: ITableIconRo
×
UNCOV
75
  ) {
×
UNCOV
76
    return await this.tableOpenApiService.updateIcon(baseId, tableId, tableIconRo.icon);
×
UNCOV
77
  }
×
78

3✔
79
  @Permissions('table|update')
3✔
UNCOV
80
  @Put(':tableId/description')
×
UNCOV
81
  async updateDescription(
×
UNCOV
82
    @Param('baseId') baseId: string,
×
UNCOV
83
    @Param('tableId') tableId: string,
×
UNCOV
84
    @Body(new ZodValidationPipe(tableDescriptionRoSchema)) tableDescriptionRo: ITableDescriptionRo
×
UNCOV
85
  ) {
×
UNCOV
86
    return await this.tableOpenApiService.updateDescription(
×
UNCOV
87
      baseId,
×
UNCOV
88
      tableId,
×
UNCOV
89
      tableDescriptionRo.description
×
UNCOV
90
    );
×
UNCOV
91
  }
×
92

3✔
93
  @Permissions('table|update')
3✔
UNCOV
94
  @Put(':tableId/db-table-name')
×
UNCOV
95
  async updateDbTableName(
×
UNCOV
96
    @Param('baseId') baseId: string,
×
UNCOV
97
    @Param('tableId') tableId: string,
×
UNCOV
98
    @Body(new ZodValidationPipe(dbTableNameRoSchema)) dbTableNameRo: IDbTableNameRo
×
UNCOV
99
  ) {
×
UNCOV
100
    return await this.tableOpenApiService.updateDbTableName(
×
UNCOV
101
      baseId,
×
UNCOV
102
      tableId,
×
UNCOV
103
      dbTableNameRo.dbTableName
×
UNCOV
104
    );
×
UNCOV
105
  }
×
106

3✔
107
  @Permissions('table|update')
3✔
UNCOV
108
  @Put(':tableId/order')
×
UNCOV
109
  async updateOrder(
×
UNCOV
110
    @Param('baseId') baseId: string,
×
UNCOV
111
    @Param('tableId') tableId: string,
×
UNCOV
112
    @Body(new ZodValidationPipe(updateOrderRoSchema)) updateOrderRo: IUpdateOrderRo
×
UNCOV
113
  ) {
×
UNCOV
114
    return await this.tableOpenApiService.updateOrder(baseId, tableId, updateOrderRo);
×
UNCOV
115
  }
×
116

3✔
117
  @Post()
3✔
UNCOV
118
  @Permissions('table|create')
×
UNCOV
119
  async createTable(
×
UNCOV
120
    @Param('baseId') baseId: string,
×
UNCOV
121
    @Body(new ZodValidationPipe(tableRoSchema), TablePipe) createTableRo: ICreateTableWithDefault
×
UNCOV
122
  ): Promise<ITableFullVo> {
×
UNCOV
123
    return await this.tableOpenApiService.createTable(baseId, createTableRo);
×
UNCOV
124
  }
×
125

3✔
126
  @Delete(':tableId')
3✔
UNCOV
127
  @Permissions('table|delete')
×
UNCOV
128
  async archiveTable(@Param('baseId') baseId: string, @Param('tableId') tableId: string) {
×
UNCOV
129
    return await this.tableOpenApiService.deleteTable(baseId, tableId);
×
UNCOV
130
  }
×
131

3✔
132
  @Delete('arbitrary/:tableId')
3✔
133
  @Permissions('table|delete')
3✔
134
  deleteTableArbitrary(@Param('baseId') baseId: string, @Param('tableId') tableId: string) {
3✔
UNCOV
135
    return this.tableOpenApiService.deleteTable(baseId, tableId, true);
×
UNCOV
136
  }
×
137

3✔
138
  @Permissions('table|read')
3✔
UNCOV
139
  @Post(':tableId/graph')
×
UNCOV
140
  async getCellGraph(
×
UNCOV
141
    @Param('tableId') tableId: string,
×
UNCOV
142
    @Body(new ZodValidationPipe(getGraphRoSchema)) { cell }: IGetGraphRo
×
UNCOV
143
  ) {
×
UNCOV
144
    return await this.tableOpenApiService.getGraph(tableId, cell);
×
UNCOV
145
  }
×
146

3✔
147
  @Permissions('table|read')
3✔
148
  @Post(':tableId/sql-query')
×
149
  async sqlQuery(
×
150
    @Param('tableId') tableId: string,
×
151
    @Query(new ZodValidationPipe(sqlQuerySchema)) query: ISqlQuerySchema
×
152
  ) {
×
153
    return await this.tableOpenApiService.sqlQuery(tableId, query.viewId, query.sql);
×
154
  }
×
155
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc