@@ -10,7 +10,9 @@ import { isTest } from '../../helpers/app/is-test.js';
1010import { SentryInterceptor } from '../../interceptors/sentry.interceptor.js' ;
1111import {
1212 AiConnectionContextRO ,
13+ AiConnectionTablesRO ,
1314 AiQueryResultRO ,
15+ CompanySubscriptionInfoRO ,
1416 PermissionAllowedRO ,
1517 ValidatedUserTokenRO ,
1618} from './data-structures/agents-responses.ds.js' ;
@@ -21,11 +23,14 @@ import {
2123 GetAiTableStructureDto ,
2224} from './dto/agents-ai-data.dtos.js' ;
2325import { ValidateConnectionEditDto , ValidateTableAiRequestDto , ValidateUserTokenDto } from './dto/agents-auth.dtos.js' ;
26+ import { GetCompanySubscriptionInfoDto } from './dto/agents-company.dtos.js' ;
2427import {
2528 IExecuteAiAggregationPipeline ,
2629 IExecuteAiRawQuery ,
2730 IGetAiConnectionContext ,
31+ IGetAiConnectionTables ,
2832 IGetAiTableStructure ,
33+ IGetCompanySubscriptionInfo ,
2934 IScanAndCreateSettings ,
3035 IValidateConnectionEdit ,
3136 IValidateTableAiRequest ,
@@ -48,6 +53,8 @@ export class AgentsController {
4853 private readonly validateConnectionEditUseCase : IValidateConnectionEdit ,
4954 @Inject ( UseCaseType . AGENTS_GET_AI_CONNECTION_CONTEXT )
5055 private readonly getAiConnectionContextUseCase : IGetAiConnectionContext ,
56+ @Inject ( UseCaseType . AGENTS_GET_AI_CONNECTION_TABLES )
57+ private readonly getAiConnectionTablesUseCase : IGetAiConnectionTables ,
5158 @Inject ( UseCaseType . AGENTS_GET_AI_TABLE_STRUCTURE )
5259 private readonly getAiTableStructureUseCase : IGetAiTableStructure ,
5360 @Inject ( UseCaseType . AGENTS_EXECUTE_AI_RAW_QUERY )
@@ -56,6 +63,8 @@ export class AgentsController {
5663 private readonly executeAiAggregationPipelineUseCase : IExecuteAiAggregationPipeline ,
5764 @Inject ( UseCaseType . AGENTS_SCAN_AND_CREATE_SETTINGS )
5865 private readonly scanAndCreateSettingsUseCase : IScanAndCreateSettings ,
66+ @Inject ( UseCaseType . AGENTS_GET_COMPANY_SUBSCRIPTION_INFO )
67+ private readonly getCompanySubscriptionInfoUseCase : IGetCompanySubscriptionInfo ,
5968 ) { }
6069
6170 @ApiOperation ( { summary : 'Validate an end-user JWT on behalf of the agents microservice' } )
@@ -102,6 +111,21 @@ export class AgentsController {
102111 ) ;
103112 }
104113
114+ @ApiOperation ( { summary : 'List connection tables the user may read (grounds website feasibility)' } )
115+ @ApiResponse ( { status : 201 , type : AiConnectionTablesRO } )
116+ @ApiBody ( { type : AiDataRequestBaseDto } )
117+ @Timeout ( ! isTest ( ) ? TimeoutDefaults . EXTENDED : TimeoutDefaults . EXTENDED_TEST )
118+ @Post ( '/ai/data/:connectionId/tables' )
119+ public async getAiConnectionTables (
120+ @SlugUuid ( 'connectionId' ) connectionId : string ,
121+ @Body ( ) body : AiDataRequestBaseDto ,
122+ ) : Promise < AiConnectionTablesRO > {
123+ return await this . getAiConnectionTablesUseCase . execute (
124+ { connectionId, userId : body . userId , masterPassword : body . masterPassword ?? null } ,
125+ InTransactionEnum . OFF ,
126+ ) ;
127+ }
128+
105129 @ApiOperation ( { summary : 'Get permission-aware table structure for the AI tool loop' } )
106130 @ApiResponse ( { status : 201 , description : 'Table structure with related tables.' } )
107131 @ApiBody ( { type : GetAiTableStructureDto } )
@@ -184,4 +208,14 @@ export class AgentsController {
184208 InTransactionEnum . OFF ,
185209 ) ;
186210 }
211+
212+ @ApiOperation ( { summary : "Read a user's company subscription metadata (agents-core owns all feature policy)" } )
213+ @ApiResponse ( { status : 201 , type : CompanySubscriptionInfoRO } )
214+ @ApiBody ( { type : GetCompanySubscriptionInfoDto } )
215+ @Post ( '/company/subscription-info' )
216+ public async getCompanySubscriptionInfo (
217+ @Body ( ) body : GetCompanySubscriptionInfoDto ,
218+ ) : Promise < CompanySubscriptionInfoRO > {
219+ return await this . getCompanySubscriptionInfoUseCase . execute ( { userId : body . userId } , InTransactionEnum . OFF ) ;
220+ }
187221}
0 commit comments