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

teableio / teable / 8419847094

25 Mar 2024 12:12PM UTC coverage: 26.087% (-53.9%) from 79.94%
8419847094

push

github

web-flow
chore: husky to v9 and upgrade more deps (#494)

2100 of 3363 branches covered (62.44%)

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✔
44
  @Get(':tableId')
×
45
  async getTable(
×
46
    @Param('baseId') baseId: string,
×
47
    @Param('tableId') tableId: string,
×
48
    @Query(new ZodValidationPipe(getTableQuerySchema)) query: IGetTableQuery
×
49
  ): Promise<ITableVo> {
×
50
    return await this.tableOpenApiService.getTable(baseId, tableId, query);
×
51
  }
×
52

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

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

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

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

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

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

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

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

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

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