-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSettings.ts
More file actions
181 lines (166 loc) · 4.96 KB
/
Settings.ts
File metadata and controls
181 lines (166 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import { DeepReadonly } from 'ts-essentials';
import { AwsRegion } from '../utils/Region';
// Core Settings Types
export type Toggleable<T = Record<string, unknown>> = {
enabled: boolean;
} & T;
export type CfnLintInitializationSettings = {
maxRetries: number;
initialDelayMs: number;
maxDelayMs: number;
backoffMultiplier: number;
totalTimeoutMs: number;
};
export type ProfileSettings = {
region: AwsRegion;
profile: string;
};
export type HoverSettings = Toggleable<object>;
export type CompletionSettings = Toggleable<{
maxCompletions: number;
}>;
export type CfnLintSettings = Toggleable<{
delayMs: number;
lintOnChange: boolean;
path?: string;
initialization: CfnLintInitializationSettings;
ignoreChecks: readonly string[];
includeChecks: readonly string[];
mandatoryChecks: readonly string[];
includeExperimental: boolean;
configureRules: readonly string[];
regions: readonly string[];
customRules: readonly string[];
appendRules: readonly string[];
overrideSpec: string;
registrySchemas: readonly string[];
}>;
export type GuardSettings = Toggleable<{
delayMs: number;
validateOnChange: boolean;
enabledRulePacks: readonly string[];
rulesFile?: string;
timeout: number;
maxConcurrentValidations: number;
maxQueueSize: number;
memoryCleanupInterval: number;
maxMemoryUsage: number;
defaultSeverity: 'error' | 'warning' | 'information' | 'hint';
}>;
export type DiagnosticsSettings = {
cfnLint: CfnLintSettings;
cfnGuard: GuardSettings;
};
export type EditorSettings = {
tabSize: number;
insertSpaces: boolean;
detectIndentation: boolean;
};
export type AwsClientSettings = {
cloudformation: {
waiter: {
changeSet: {
minDelay: number;
maxDelay: number;
maxWaitTime: number;
};
stack: {
minDelay: number;
maxDelay: number;
maxWaitTime: number;
};
};
};
};
export interface Settings {
profile: ProfileSettings;
hover: HoverSettings;
completion: CompletionSettings;
diagnostics: DiagnosticsSettings;
editor: EditorSettings;
awsClient: AwsClientSettings;
}
export const DefaultSettings: DeepReadonly<Settings> = {
profile: {
region: AwsRegion.US_EAST_1,
profile: 'default',
},
hover: {
enabled: true,
},
completion: {
enabled: true,
maxCompletions: 100,
},
diagnostics: {
cfnLint: {
enabled: true,
delayMs: 3000, // 3 seconds default delay
lintOnChange: true,
initialization: {
maxRetries: 3,
initialDelayMs: 1000,
maxDelayMs: 30_000,
backoffMultiplier: 2,
totalTimeoutMs: 120_000, // 2 minutes total timeout
},
ignoreChecks: [],
includeChecks: [],
mandatoryChecks: [],
includeExperimental: false,
configureRules: [],
regions: [],
customRules: [],
appendRules: [],
overrideSpec: '',
registrySchemas: [],
},
cfnGuard: {
enabled: true,
delayMs: 1000, // Same as cfnLint for consistency
validateOnChange: true,
enabledRulePacks: ['cis-aws-benchmark-level-1'], // Default essential packs
timeout: 30_000, // 30 seconds timeout
maxConcurrentValidations: 3, // Maximum concurrent validations
maxQueueSize: 10, // Maximum queued validation requests
memoryCleanupInterval: 60_000, // Memory cleanup interval (1 minute)
maxMemoryUsage: 100 * 1024 * 1024, // 100MB memory threshold
defaultSeverity: 'information', // Default severity for Guard rules
},
},
editor: {
tabSize: 2,
insertSpaces: true,
detectIndentation: true,
},
awsClient: {
cloudformation: {
waiter: {
changeSet: {
minDelay: 1,
maxDelay: 8,
maxWaitTime: 600,
},
stack: {
minDelay: 3,
maxDelay: 10,
maxWaitTime: 1800,
},
},
},
},
} as const;
export class SettingsState implements Settings {
profile = structuredClone(DefaultSettings.profile);
hover = structuredClone(DefaultSettings.hover);
completion = structuredClone(DefaultSettings.completion);
diagnostics = structuredClone(DefaultSettings.diagnostics);
editor = structuredClone(DefaultSettings.editor);
awsClient = structuredClone(DefaultSettings.awsClient);
update(settings: Settings): void {
Object.assign(this, structuredClone(settings));
}
toSettings(): Settings {
return structuredClone(this);
}
}