-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathplugin-chart.controller.ts
More file actions
97 lines (90 loc) · 3.3 KB
/
plugin-chart.controller.ts
File metadata and controls
97 lines (90 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import {
getDashboardInstallPluginQueryRoSchema,
getPluginPanelInstallPluginQueryRoSchema,
IGetPluginPanelInstallPluginQueryRo,
ITestSqlRo,
testSqlRoSchema,
IGetDashboardInstallPluginQueryRo,
} from '@teable/openapi';
import type { IBaseQueryVoV2, IBaseQueryVo, IBaseTableSchemaVo } from '@teable/openapi';
import { ZodValidationPipe } from '../../../../zod.validation.pipe';
import { Permissions } from '../../../auth/decorators/permissions.decorator';
import { ResourceMeta } from '../../../auth/decorators/resource_meta.decorator';
import { PluginChartService } from './plugin-chart.service';
@Controller('api/plugin/chart')
export class PluginChartController {
constructor(private readonly pluginChartService: PluginChartService) {}
@Get(':pluginInstallId/plugin-panel/:positionId/query')
@Permissions('table|read')
@ResourceMeta('tableId', 'query')
getPluginPanelPluginQuery(
@Param('pluginInstallId') pluginInstallId: string,
@Param('positionId') positionId: string,
@Query(new ZodValidationPipe(getPluginPanelInstallPluginQueryRoSchema))
query: IGetPluginPanelInstallPluginQueryRo
): Promise<IBaseQueryVo> {
const { tableId, cellFormat } = query;
return this.pluginChartService.getPluginPanelPluginQuery(
pluginInstallId,
positionId,
tableId,
cellFormat
);
}
@Get(':pluginInstallId/dashboard/:positionId/query')
@Permissions('base|read')
@ResourceMeta('baseId', 'query')
getDashboardPluginQuery(
@Param('pluginInstallId') pluginInstallId: string,
@Param('positionId') positionId: string,
@Query(new ZodValidationPipe(getDashboardInstallPluginQueryRoSchema))
query: IGetDashboardInstallPluginQueryRo
): Promise<IBaseQueryVo> {
const { baseId, cellFormat } = query;
return this.pluginChartService.getDashboardPluginQuery(
pluginInstallId,
positionId,
baseId,
cellFormat
);
}
@Get(':pluginInstallId/dashboard/:positionId/query/v2')
@Permissions('base|read')
@ResourceMeta('baseId', 'query')
getDashboardPluginQueryV2(
@Param('pluginInstallId') pluginInstallId: string,
@Param('positionId') positionId: string,
@Query('baseId') baseId: string
): Promise<IBaseQueryVoV2> {
return this.pluginChartService.getDashboardPluginQueryV2(baseId, pluginInstallId, positionId);
}
@Get(':pluginInstallId/plugin-panel/:positionId/query/v2')
@Permissions('table|read')
@ResourceMeta('tableId', 'query')
getPluginPanelPluginQueryV2(
@Param('pluginInstallId') pluginInstallId: string,
@Param('positionId') positionId: string,
@Query('tableId') tableId: string
): Promise<IBaseQueryVoV2> {
return this.pluginChartService.getPluginPanelPluginQueryV2(
tableId,
pluginInstallId,
positionId
);
}
@Post('test-sql')
@Permissions('base|read')
@ResourceMeta('baseId', 'body')
testSql(
@Body(new ZodValidationPipe(testSqlRoSchema)) testSqlRo: ITestSqlRo
): Promise<IBaseQueryVoV2> {
return this.pluginChartService.testSql(testSqlRo);
}
@Get(':baseId/schema')
@Permissions('base|read')
@ResourceMeta('baseId', 'params')
getSchemaByBaseId(@Param('baseId') baseId: string): Promise<IBaseTableSchemaVo> {
return this.pluginChartService.getSchemaByBaseId(baseId);
}
}