11import {
2- Body ,
3- Controller ,
4- Delete ,
5- Get ,
6- HttpException ,
7- HttpStatus ,
8- Inject ,
9- Injectable ,
10- Put ,
11- UseGuards ,
12- UseInterceptors ,
2+ Body ,
3+ Controller ,
4+ Delete ,
5+ Get ,
6+ HttpException ,
7+ HttpStatus ,
8+ Inject ,
9+ Injectable ,
10+ Put ,
11+ UseGuards ,
12+ UseInterceptors ,
1313} from '@nestjs/common' ;
1414import { ApiBearerAuth , ApiBody , ApiOperation , ApiParam , ApiQuery , ApiResponse , ApiTags } from '@nestjs/swagger' ;
1515import { SentryInterceptor } from '../../../interceptors/sentry.interceptor.js' ;
1616import { UseCaseType } from '../../../common/data-injection.tokens.js' ;
1717import {
18- ICreateUpdatePersonalTableSettings ,
19- IDeletePersonalTableSettings ,
20- IFindPersonalTableSettings ,
18+ ICreateUpdatePersonalTableSettings ,
19+ IDeletePersonalTableSettings ,
20+ IFindPersonalTableSettings ,
2121} from './use-cases/personal-table-settings.use-cases.interface.js' ;
2222import { TableReadGuard } from '../../../guards/table-read.guard.js' ;
2323import { UserId } from '../../../decorators/user-id.decorator.js' ;
@@ -37,123 +37,123 @@ import { CreatePersonalTableSettingsDto } from './dto/create-personal-table-sett
3737@ApiTags ( 'Personal table settings' )
3838@Injectable ( )
3939export class PersonalTableSettingsController {
40- constructor (
41- @Inject ( UseCaseType . FIND_PERSONAL_TABLE_SETTINGS )
42- private readonly findPersonalTableSettingsUseCase : IFindPersonalTableSettings ,
43- @Inject ( UseCaseType . CREATE_UPDATE_PERSONAL_TABLE_SETTINGS )
44- private readonly createUpdatePersonalTableSettingsUseCase : ICreateUpdatePersonalTableSettings ,
45- @Inject ( UseCaseType . DELETE_PERSONAL_TABLE_SETTINGS )
46- private readonly deletePersonalTableSettingsUseCase : IDeletePersonalTableSettings ,
47- ) { }
40+ constructor (
41+ @Inject ( UseCaseType . FIND_PERSONAL_TABLE_SETTINGS )
42+ private readonly findPersonalTableSettingsUseCase : IFindPersonalTableSettings ,
43+ @Inject ( UseCaseType . CREATE_UPDATE_PERSONAL_TABLE_SETTINGS )
44+ private readonly createUpdatePersonalTableSettingsUseCase : ICreateUpdatePersonalTableSettings ,
45+ @Inject ( UseCaseType . DELETE_PERSONAL_TABLE_SETTINGS )
46+ private readonly deletePersonalTableSettingsUseCase : IDeletePersonalTableSettings ,
47+ ) { }
4848
49- @ApiOperation ( { summary : 'Find user personal table settings' } )
50- @ApiResponse ( {
51- status : 200 ,
52- description : 'Table settings found.' ,
53- type : FoundPersonalTableSettingsDto ,
54- } )
55- @ApiParam ( { name : 'connectionId' , required : true } )
56- @ApiQuery ( { name : 'tableName' , required : true } )
57- @UseGuards ( TableReadGuard )
58- @Get ( '/settings/personal/:connectionId' )
59- async findAll (
60- @SlugUuid ( 'connectionId' ) connectionId : string ,
61- @QueryTableName ( ) tableName : string ,
62- @MasterPassword ( ) masterPwd : string ,
63- @UserId ( ) userId : string ,
64- ) : Promise < FoundPersonalTableSettingsDto > {
65- if ( ! connectionId ) {
66- throw new HttpException (
67- {
68- message : Messages . CONNECTION_ID_MISSING ,
69- } ,
70- HttpStatus . BAD_REQUEST ,
71- ) ;
72- }
73- const inputData : FindPersonalTableSettingsDs = {
74- connectionId,
75- tableName,
76- userId,
77- masterPassword : masterPwd ,
78- } ;
79- return await this . findPersonalTableSettingsUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
80- }
49+ @ApiOperation ( { summary : 'Find user personal table settings' } )
50+ @ApiResponse ( {
51+ status : 200 ,
52+ description : 'Table settings found.' ,
53+ type : FoundPersonalTableSettingsDto ,
54+ } )
55+ @ApiParam ( { name : 'connectionId' , required : true } )
56+ @ApiQuery ( { name : 'tableName' , required : true } )
57+ @UseGuards ( TableReadGuard )
58+ @Get ( '/settings/personal/:connectionId' )
59+ async findAll (
60+ @SlugUuid ( 'connectionId' ) connectionId : string ,
61+ @QueryTableName ( ) tableName : string ,
62+ @MasterPassword ( ) masterPwd : string ,
63+ @UserId ( ) userId : string ,
64+ ) : Promise < FoundPersonalTableSettingsDto > {
65+ if ( ! connectionId ) {
66+ throw new HttpException (
67+ {
68+ message : Messages . CONNECTION_ID_MISSING ,
69+ } ,
70+ HttpStatus . BAD_REQUEST ,
71+ ) ;
72+ }
73+ const inputData : FindPersonalTableSettingsDs = {
74+ connectionId,
75+ tableName,
76+ userId,
77+ masterPassword : masterPwd ,
78+ } ;
79+ return await this . findPersonalTableSettingsUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
80+ }
8181
82- @ApiOperation ( { summary : 'Create or update user personal table settings' } )
83- @ApiResponse ( {
84- status : 200 ,
85- description : 'Table settings crated/updated.' ,
86- type : FoundPersonalTableSettingsDto ,
87- } )
88- @ApiBody ( { type : CreatePersonalTableSettingsDto } )
89- @ApiParam ( { name : 'connectionId' , required : true } )
90- @ApiQuery ( { name : 'tableName' , required : true } )
91- @UseGuards ( TableReadGuard )
92- @Put ( '/settings/personal/:connectionId' )
93- async createOrUpdate (
94- @SlugUuid ( 'connectionId' ) connectionId : string ,
95- @QueryTableName ( ) tableName : string ,
96- @MasterPassword ( ) masterPwd : string ,
97- @UserId ( ) userId : string ,
98- @Body ( ) personalSettingsData : CreatePersonalTableSettingsDto ,
99- ) : Promise < FoundPersonalTableSettingsDto > {
100- if ( ! connectionId ) {
101- throw new HttpException (
102- {
103- message : Messages . CONNECTION_ID_MISSING ,
104- } ,
105- HttpStatus . BAD_REQUEST ,
106- ) ;
107- }
108- const inputData : CreatePersonalTableSettingsDs = {
109- table_settings_metadata : {
110- connection_id : connectionId ,
111- table_name : tableName ,
112- user_id : userId ,
113- master_password : masterPwd ,
114- } ,
115- table_settings_data : {
116- columns_view : personalSettingsData . columns_view || null ,
117- list_fields : personalSettingsData . list_fields || null ,
118- list_per_page : personalSettingsData . list_per_page || null ,
119- ordering : personalSettingsData . ordering || null ,
120- ordering_field : personalSettingsData . ordering_field || null ,
121- original_names : personalSettingsData . original_names || null ,
122- } ,
123- } ;
124- return await this . createUpdatePersonalTableSettingsUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
125- }
82+ @ApiOperation ( { summary : 'Create or update user personal table settings' } )
83+ @ApiResponse ( {
84+ status : 200 ,
85+ description : 'Table settings crated/updated.' ,
86+ type : FoundPersonalTableSettingsDto ,
87+ } )
88+ @ApiBody ( { type : CreatePersonalTableSettingsDto } )
89+ @ApiParam ( { name : 'connectionId' , required : true } )
90+ @ApiQuery ( { name : 'tableName' , required : true } )
91+ @UseGuards ( TableReadGuard )
92+ @Put ( '/settings/personal/:connectionId' )
93+ async createOrUpdate (
94+ @SlugUuid ( 'connectionId' ) connectionId : string ,
95+ @QueryTableName ( ) tableName : string ,
96+ @MasterPassword ( ) masterPwd : string ,
97+ @UserId ( ) userId : string ,
98+ @Body ( ) personalSettingsData : CreatePersonalTableSettingsDto ,
99+ ) : Promise < FoundPersonalTableSettingsDto > {
100+ if ( ! connectionId ) {
101+ throw new HttpException (
102+ {
103+ message : Messages . CONNECTION_ID_MISSING ,
104+ } ,
105+ HttpStatus . BAD_REQUEST ,
106+ ) ;
107+ }
108+ const inputData : CreatePersonalTableSettingsDs = {
109+ table_settings_metadata : {
110+ connection_id : connectionId ,
111+ table_name : tableName ,
112+ user_id : userId ,
113+ master_password : masterPwd ,
114+ } ,
115+ table_settings_data : {
116+ columns_view : personalSettingsData . columns_view || null ,
117+ list_fields : personalSettingsData . list_fields || null ,
118+ list_per_page : personalSettingsData . list_per_page || null ,
119+ ordering : personalSettingsData . ordering || null ,
120+ ordering_field : personalSettingsData . ordering_field || null ,
121+ original_names : personalSettingsData . original_names || null ,
122+ } ,
123+ } ;
124+ return await this . createUpdatePersonalTableSettingsUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
125+ }
126126
127- @ApiOperation ( { summary : 'Clear user personal table settings' } )
128- @ApiResponse ( {
129- status : 200 ,
130- description : 'Table settings removed.' ,
131- type : FoundPersonalTableSettingsDto ,
132- } )
133- @ApiParam ( { name : 'connectionId' , required : true } )
134- @ApiQuery ( { name : 'tableName' , required : true } )
135- @UseGuards ( TableReadGuard )
136- @Delete ( '/settings/personal/:connectionId' )
137- async clearTableSettings (
138- @SlugUuid ( 'connectionId' ) connectionId : string ,
139- @QueryTableName ( ) tableName : string ,
140- @MasterPassword ( ) masterPwd : string ,
141- @UserId ( ) userId : string ,
142- ) : Promise < FoundPersonalTableSettingsDto > {
143- if ( ! connectionId ) {
144- throw new HttpException (
145- {
146- message : Messages . CONNECTION_ID_MISSING ,
147- } ,
148- HttpStatus . BAD_REQUEST ,
149- ) ;
150- }
151- const inputData : FindPersonalTableSettingsDs = {
152- connectionId,
153- tableName,
154- userId,
155- masterPassword : masterPwd ,
156- } ;
157- return await this . deletePersonalTableSettingsUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
158- }
127+ @ApiOperation ( { summary : 'Clear user personal table settings' } )
128+ @ApiResponse ( {
129+ status : 200 ,
130+ description : 'Table settings removed.' ,
131+ type : FoundPersonalTableSettingsDto ,
132+ } )
133+ @ApiParam ( { name : 'connectionId' , required : true } )
134+ @ApiQuery ( { name : 'tableName' , required : true } )
135+ @UseGuards ( TableReadGuard )
136+ @Delete ( '/settings/personal/:connectionId' )
137+ async clearTableSettings (
138+ @SlugUuid ( 'connectionId' ) connectionId : string ,
139+ @QueryTableName ( ) tableName : string ,
140+ @MasterPassword ( ) masterPwd : string ,
141+ @UserId ( ) userId : string ,
142+ ) : Promise < FoundPersonalTableSettingsDto > {
143+ if ( ! connectionId ) {
144+ throw new HttpException (
145+ {
146+ message : Messages . CONNECTION_ID_MISSING ,
147+ } ,
148+ HttpStatus . BAD_REQUEST ,
149+ ) ;
150+ }
151+ const inputData : FindPersonalTableSettingsDs = {
152+ connectionId,
153+ tableName,
154+ userId,
155+ masterPassword : masterPwd ,
156+ } ;
157+ return await this . deletePersonalTableSettingsUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
158+ }
159159}
0 commit comments