@@ -21,7 +21,7 @@ export interface EnvironmentDetailsOptions {
21
21
/**
22
22
* Return details provided by the specific provider, throws error if provider not found.
23
23
*/
24
- providerId ?: ProviderID ;
24
+ extensionId ?: ExtensionID ;
25
25
}
26
26
27
27
export interface EnvironmentDetails {
@@ -30,13 +30,15 @@ export interface EnvironmentDetails {
30
30
bitness ?: Architecture ;
31
31
sysPrefix : string ;
32
32
} ;
33
- environment ?: {
34
- type : EnvType ;
35
- name ?: string ;
36
- path : string ;
37
- project ?: string ; // Any specific project environment is created for.
38
- source : EnvSource [ ] ;
39
- } ;
33
+ environment :
34
+ | {
35
+ type : EnvType ;
36
+ name ?: string ;
37
+ path : string ;
38
+ project ?: string ; // Any specific project environment is created for.
39
+ source : EnvSource [ ] ;
40
+ }
41
+ | undefined ;
40
42
version : StandardVersionInfo & {
41
43
sysVersion ?: string ;
42
44
} ;
@@ -51,9 +53,13 @@ export interface EnvironmentDetails {
51
53
* Provider is only required to provide the `executable` key, rest are optional. So construct a type using
52
54
* `EnvironmentDetails` where `executable` is the only required key.
53
55
*/
54
- type EnvironmentDetailsByProvider = Partial < EnvironmentDetails > & Pick < EnvironmentDetails , 'executable' > ;
56
+ type EnvironmentDetailsByProvider = Partial < EnvironmentDetails > &
57
+ Pick < EnvironmentDetails , 'executable' > &
58
+ Pick < EnvironmentDetails , 'environment' > ;
55
59
56
- export interface IInternalEnvironmentProvider extends ILocatorFactoryAPI , IInternalResolverAPI { }
60
+ export type IInternalEnvironmentProvider =
61
+ | ( ILocatorFactoryAPI & IInternalResolverAPI & IInternalIdentifierAPI )
62
+ | ( ILocatorFactoryAPI & IInternalResolverAPI ) ;
57
63
58
64
interface ILocatorFactoryAPI {
59
65
/**
@@ -65,38 +71,52 @@ interface ILocatorFactoryAPI {
65
71
export type ProposedDetailsAPI = ( env : BaseEnvInfo ) => Promise < EnvironmentDetailsByProvider | undefined > ;
66
72
export type InternalDetailsAPI = ( env : BasicEnvInfo ) => Promise < PythonEnvInfo | undefined > ;
67
73
68
- export interface IResolverAPI {
69
- /**
70
- * Returns true if provided environment is recognized by the provider.
71
- */
72
- canIdentifyEnvironment : ( path : UniquePathType ) => Promise < boolean > ;
74
+ export interface IDetailsAPI {
73
75
/**
74
- * This is only called if this provider can identify the environment.
76
+ * This is only called if the provider:
77
+ * * Can identify the environment.
78
+ * * Iterates out the environment.
75
79
* Returns details or `undefined` if it was found if env is invalid.
76
80
*/
77
81
getEnvironmentDetails : ProposedDetailsAPI ;
78
82
}
79
83
80
- export interface IInternalResolverAPI {
84
+ export type IResolverAPI = IDetailsAPI | ( IDetailsAPI & IIdentifierAPI ) ;
85
+
86
+ /**
87
+ * Identifier need not be registered
88
+ */
89
+ interface IIdentifierAPI {
90
+ /**
91
+ * Environment source the provider identifies.
92
+ */
93
+ readonly envSource : EnvSource ;
81
94
/**
82
95
* Returns true if provided environment is recognized by the provider.
83
96
*/
84
97
canIdentifyEnvironment : ( path : UniquePathType ) => Promise < boolean > ;
98
+ }
99
+
100
+ export interface IInternalResolverAPI {
101
+ getEnvironmentDetails : InternalDetailsAPI ;
102
+ }
103
+
104
+ interface IInternalIdentifierAPI {
105
+ readonly envKind : PythonEnvKind ;
85
106
/**
86
- * This is only called if this provider can identify the environment.
87
- * Returns details or `undefined` if it was found if env is invalid.
107
+ * Returns true if provided environment is recognized by the provider.
88
108
*/
89
- getEnvironmentDetails : InternalDetailsAPI ;
109
+ canIdentifyEnvironment : ( path : UniquePathType ) => Promise < boolean > ;
90
110
}
91
111
92
112
export type ILocatorFactory = IWorkspaceLocatorFactory | INonWorkspaceLocatorFactory ;
93
113
export type INonWorkspaceLocatorFactory = ( ) => ILocatorAPI ;
94
114
export type IWorkspaceLocatorFactory = ( root : string ) => ILocatorAPI ;
95
115
96
- export interface IEnvironmentProvider extends ILocatorFactoryAPI , IResolverAPI { }
116
+ export type IEnvironmentProvider = ILocatorFactoryAPI & IResolverAPI ;
97
117
export interface ILocatorAPI {
98
- iterEnvs ? ( ) : IPythonEnvsIterator < EnvInfo > ;
99
- readonly onChanged ? : Event < LocatorEnvsChangedEvent > ;
118
+ iterEnvs ( ) : IPythonEnvsIterator < EnvInfo > ;
119
+ readonly onChanged : Event < LocatorEnvsChangedEvent > ;
100
120
}
101
121
102
122
export type EnvInfo = BaseEnvInfo & {
@@ -108,7 +128,7 @@ export type BaseEnvInfo = {
108
128
envPath ?: string ;
109
129
} ;
110
130
111
- type ProviderID = string ;
131
+ type ExtensionID = string ;
112
132
113
133
/**
114
134
* These can be used when querying for a particular env.
@@ -118,11 +138,11 @@ export interface EnvironmentProviderMetadata {
118
138
* Details about the environments the locator provides.
119
139
* Useful when querying for a particular env.
120
140
*/
121
- readonly environments : EnvironmentMetaData ;
141
+ readonly environments ? : EnvironmentMetaData ;
122
142
/**
123
- * An Identifier for the provider.
143
+ * An Identifier for the extension registering the provider.
124
144
*/
125
- readonly providerId : ProviderID ;
145
+ readonly extensionId : ExtensionID ;
126
146
}
127
147
128
148
interface InternalEnvironmentMetaData {
@@ -138,10 +158,7 @@ export interface InternalEnvironmentProviderMetadata {
138
158
* Useful when querying for a particular env.
139
159
*/
140
160
readonly environments : InternalEnvironmentMetaData ;
141
- /**
142
- * An Identifier for the provider.
143
- */
144
- readonly providerId : ProviderID ;
161
+ readonly extensionId : ExtensionID ;
145
162
}
146
163
147
164
interface EnvironmentMetaData {
@@ -168,7 +185,6 @@ export enum KnownEnvTypes {
168
185
VirtualEnv = 'VirtualEnv' ,
169
186
Conda = 'Conda' ,
170
187
Unknown = 'Unknown' ,
171
- Global = 'Global' ,
172
188
}
173
189
174
190
export type EnvSource = KnownEnvSourceTypes | string ;
0 commit comments