@@ -9,14 +9,52 @@ import { TypeConstructor } from '../shared/utilities/typeConstructors'
99import { AuthUserState , AuthStatus } from '../shared/telemetry/telemetry.gen'
1010
1111/** 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'
1312
14- /** Generic condition where the type determines how the values are evaluated. */
15- export interface CriteriaCondition {
16- readonly type : Criteria
17- readonly values : string [ ]
13+ type OsCriteria = {
14+ type : 'OS'
15+ values : OperatingSystem [ ]
16+ }
17+
18+ type ComputeEnvCriteria = {
19+ type : 'ComputeEnv'
20+ values : EnvType [ ]
21+ }
22+
23+ type AuthTypeCriteria = {
24+ type : 'AuthType'
25+ values : AuthType [ ]
26+ }
27+
28+ type AuthRegionCriteria = {
29+ type : 'AuthRegion'
30+ values : string [ ]
31+ }
32+
33+ type AuthStateCriteria = {
34+ type : 'AuthState'
35+ values : AuthStatus [ ]
1836}
1937
38+ type AuthScopesCriteria = {
39+ type : 'AuthScopes'
40+ values : string [ ] // TODO: Scopes should be typed. Could import here, but don't want to import too much.
41+ }
42+
43+ type ActiveExtensionsCriteria = {
44+ type : 'ActiveExtensions'
45+ values : string [ ]
46+ }
47+
48+ /** Generic condition where the type determines how the values are evaluated. */
49+ export type CriteriaCondition =
50+ | OsCriteria
51+ | ComputeEnvCriteria
52+ | AuthTypeCriteria
53+ | AuthRegionCriteria
54+ | AuthStateCriteria
55+ | AuthScopesCriteria
56+ | ActiveExtensionsCriteria
57+
2058/** One of the subconditions (clauses) must match to be valid. */
2159export interface OR {
2260 readonly type : 'or'
@@ -39,8 +77,8 @@ export interface ExactMatch {
3977export type ConditionalClause = Range | ExactMatch | OR
4078
4179export type OnReceiveType = 'toast' | 'modal'
42- export type OnClickType = 'modal' | 'openTextDocument' | 'openUrl'
43- export type ActionType = 'openUrl' | 'updateAndReload' | 'openTxt '
80+ export type OnClickType = { type : 'modal' } | { type : 'openTextDocument' } | { type : 'openUrl' ; url : string }
81+ export type ActionType = 'openUrl' | 'updateAndReload' | 'openTextDocument '
4482
4583/** How to display the notification. */
4684export interface UIRenderInstructions {
@@ -51,11 +89,8 @@ export interface UIRenderInstructions {
5189 toastPreview ?: string // optional property for toast
5290 }
5391 }
54- onRecieve : OnReceiveType // TODO: typo
55- onClick : {
56- type : OnClickType
57- url ?: string // optional property for 'openUrl'
58- }
92+ onReceive : OnReceiveType
93+ onClick : OnClickType
5994 actions ?: Array < {
6095 type : ActionType
6196 displayText : {
@@ -119,12 +154,14 @@ export const NotificationsStateConstructor: TypeConstructor<NotificationsState>
119154
120155export type NotificationType = keyof Omit < NotificationsState , 'dismissed' | 'newlyReceived' >
121156
157+ type AuthType = 'credentials' | 'builderId' | 'identityCenter' | 'unknown'
158+
122159export interface RuleContext {
123160 readonly ideVersion : typeof vscode . version
124161 readonly extensionVersion : string
125162 readonly os : OperatingSystem
126163 readonly computeEnv : EnvType
127- readonly authTypes : ( 'credentials' | 'builderId' | 'identityCenter' | 'unknown' ) [ ]
164+ readonly authTypes : AuthType [ ]
128165 readonly authRegions : string [ ]
129166 readonly authStates : AuthStatus [ ]
130167 readonly authScopes : string [ ]
0 commit comments