7
7
8
8
import { LoggerInterface } from './logger/loggerTypes' ;
9
9
import { TelemetryServiceInterface } from './telemetry/telemetryTypes' ;
10
+ import { LLMServiceInterface } from './llmService' ;
10
11
11
12
export const SFDX_CORE_EXTENSION_NAME = 'salesforcedx-vscode-core' ;
12
13
13
14
export enum ServiceType {
14
15
Logger = 'Logger' ,
15
- Telemetry = 'Telemetry'
16
+ Telemetry = 'Telemetry' ,
17
+ LLMService = 'LLMService'
16
18
}
17
19
18
20
// Define a mapping from service types to their corresponding parameter types
19
21
interface ServiceParamsMap {
20
22
[ ServiceType . Logger ] : [ string ] ; // Logger requires a string parameter
21
23
[ ServiceType . Telemetry ] : [ string | undefined ] ;
24
+ [ ServiceType . LLMService ] : [ string ] ;
25
+ }
26
+
27
+ // Define a mapping from service types to their corresponding return types
28
+ interface ServiceReturnTypeMap {
29
+ [ ServiceType . Telemetry ] : TelemetryServiceInterface ;
30
+ [ ServiceType . Logger ] : LoggerInterface ;
31
+ [ ServiceType . LLMService ] : LLMServiceInterface ;
22
32
}
23
33
24
34
// Define a type that represents the parameter types for a given service type
@@ -27,11 +37,7 @@ export type ServiceParams<T extends ServiceType> =
27
37
28
38
// Define a type that represents the return type for a given service type
29
39
export type ServiceReturnType < T extends ServiceType > =
30
- T extends ServiceType . Telemetry
31
- ? TelemetryServiceInterface
32
- : T extends ServiceType . Logger
33
- ? LoggerInterface
34
- : never ;
40
+ T extends keyof ServiceReturnTypeMap ? ServiceReturnTypeMap [ T ] : never ;
35
41
36
42
// Define a ServiceValidator interface
37
43
interface ServiceValidator < T extends ServiceType > {
@@ -55,8 +61,14 @@ export const ServiceValidators: {
55
61
) : ServiceParams < ServiceType . Telemetry > {
56
62
return params ;
57
63
}
64
+ } ,
65
+ [ ServiceType . LLMService ] : {
66
+ validateAndCorrect (
67
+ params : ServiceParams < ServiceType . LLMService >
68
+ ) : ServiceParams < ServiceType . LLMService > {
69
+ return params ;
70
+ }
58
71
}
59
- // Add more validators as needed
60
72
} ;
61
73
62
74
// Define a ServiceInstanceValidator interface
@@ -78,8 +90,16 @@ export const ServiceInstanceValidators: {
78
90
validateAndCorrect ( instanceName : string ) : string {
79
91
return instanceName || SFDX_CORE_EXTENSION_NAME ;
80
92
}
93
+ } ,
94
+ [ ServiceType . LLMService ] : {
95
+ validateAndCorrect ( extensionName : string ) : string {
96
+ if ( ! extensionName ) {
97
+ throw new Error ( 'Extension name is required for LLM service' ) ;
98
+ }
99
+ return extensionName ;
100
+ }
81
101
}
82
- // Add more validators as needed
83
102
} ;
84
103
export * from './logger/loggerTypes' ;
85
104
export * from './telemetry/telemetryTypes' ;
105
+ export * from './llmService' ;
0 commit comments