@@ -51,8 +51,14 @@ export interface ContextProvider<T extends SupportedContextItem> {
51
51
selector : DocumentSelector ;
52
52
resolver : ContextResolver < T > ;
53
53
}
54
+
55
+ export type ResolveOnTimeoutResult < T > = T | readonly T [ ] ;
56
+ export type ResolveResult < T > = Promise < T > | Promise < readonly T [ ] > | AsyncIterable < T > ;
57
+
54
58
export interface ContextResolver < T extends SupportedContextItem > {
55
- resolve ( request : ResolveRequest , token : CancellationToken ) : Promise < T > | Promise < T [ ] > | AsyncIterable < T > ;
59
+ resolve ( request : ResolveRequest , token : CancellationToken ) : ResolveResult < T > ;
60
+ // Optional method to be invoked if the request timed out. This requests additional context items.
61
+ resolveOnTimeout ?( request : ResolveRequest ) : ResolveOnTimeoutResult < T > | undefined ;
56
62
}
57
63
58
64
/**
@@ -141,14 +147,6 @@ export interface ResolveRequest {
141
147
data ?: unknown ;
142
148
}
143
149
144
- /**
145
- * A context item marked as backup will only be used if the provider hits the timeout
146
- * and is not able to fully resolve.
147
- */
148
- export enum ContextItemTag {
149
- Backup = 'backup' ,
150
- }
151
-
152
150
/**
153
151
* These are the data types that can be provided by a context provider. Any non-conforming
154
152
* context items will be filtered out.
@@ -175,13 +173,6 @@ interface ContextItem {
175
173
* - update: context is provided via context/update
176
174
*/
177
175
origin ?: ContextItemOrigin ;
178
-
179
- /**
180
- * Tags are used to provide additional metadata about the context item. Valid tags
181
- * are defined in the ContextItemTag. The type is a string[] to allow arbitrary tags
182
- * to be passed without failing schema validation.
183
- */
184
- tags ?: string [ ] ;
185
176
}
186
177
187
178
// A key-value pair used for short string snippets.
0 commit comments