@@ -7,16 +7,55 @@ import * as vscode from 'vscode'
77import { EnvType , OperatingSystem } from '../shared/telemetry/util'
88import { TypeConstructor } from '../shared/utilities/typeConstructors'
99import { AuthUserState , AuthStatus } from '../shared/telemetry/telemetry.gen'
10+ import { AuthType } from '../auth/connection'
1011
1112/** Types of information that we can use to determine whether to show a notification or not. */
12- export type Criteria = 'OS' | 'ComputeEnv' | 'AuthType' | 'AuthRegion' | 'AuthState' | 'AuthScopes' | 'ActiveExtensions'
1313
14- /** Generic condition where the type determines how the values are evaluated. */
15- export interface CriteriaCondition {
16- readonly type : Criteria
17- readonly values : string [ ]
14+ type OsCriteria = {
15+ type : 'OS'
16+ values : OperatingSystem [ ]
17+ }
18+
19+ type ComputeEnvCriteria = {
20+ type : 'ComputeEnv'
21+ values : EnvType [ ]
22+ }
23+
24+ type AuthTypeCriteria = {
25+ type : 'AuthType'
26+ values : AuthType [ ]
27+ }
28+
29+ type AuthRegionCriteria = {
30+ type : 'AuthRegion'
31+ values : string [ ]
32+ }
33+
34+ type AuthStateCriteria = {
35+ type : 'AuthState'
36+ values : AuthStatus [ ]
37+ }
38+
39+ type AuthScopesCriteria = {
40+ type : 'AuthScopes'
41+ values : string [ ] // TODO: Scopes should be typed. Could import here, but don't want to import too much.
42+ }
43+
44+ type ActiveExtensionsCriteria = {
45+ type : 'ActiveExtensions'
46+ values : string [ ]
1847}
1948
49+ /** Generic condition where the type determines how the values are evaluated. */
50+ export type CriteriaCondition =
51+ | OsCriteria
52+ | ComputeEnvCriteria
53+ | AuthTypeCriteria
54+ | AuthRegionCriteria
55+ | AuthStateCriteria
56+ | AuthScopesCriteria
57+ | ActiveExtensionsCriteria
58+
2059/** One of the subconditions (clauses) must match to be valid. */
2160export interface OR {
2261 readonly type : 'or'
@@ -39,8 +78,8 @@ export interface ExactMatch {
3978export type ConditionalClause = Range | ExactMatch | OR
4079
4180export type OnReceiveType = 'toast' | 'modal'
42- export type OnClickType = 'modal' | 'openTextDocument' | 'openUrl'
43- export type ActionType = 'openUrl' | 'updateAndReload' | 'openTxt '
81+ export type OnClickType = { type : 'modal' } | { type : 'openTextDocument' } | { type : 'openUrl' ; url : string }
82+ export type ActionType = 'openUrl' | 'updateAndReload' | 'openTextDocument '
4483
4584/** How to display the notification. */
4685export interface UIRenderInstructions {
@@ -51,11 +90,8 @@ export interface UIRenderInstructions {
5190 toastPreview ?: string // optional property for toast
5291 }
5392 }
54- onRecieve : OnReceiveType // TODO: typo
55- onClick : {
56- type : OnClickType
57- url ?: string // optional property for 'openUrl'
58- }
93+ onReceive : OnReceiveType
94+ onClick : OnClickType
5995 actions ?: Array < {
6096 type : ActionType
6197 displayText : {
@@ -124,7 +160,7 @@ export interface RuleContext {
124160 readonly extensionVersion : string
125161 readonly os : OperatingSystem
126162 readonly computeEnv : EnvType
127- readonly authTypes : ( 'credentials' | 'builderId' | 'identityCenter' | 'unknown' ) [ ]
163+ readonly authTypes : AuthType [ ]
128164 readonly authRegions : string [ ]
129165 readonly authStates : AuthStatus [ ]
130166 readonly authScopes : string [ ]
0 commit comments