Adrià Vilanova MartÃnez | 9344d61 | 2024-05-11 14:16:38 +0200 | [diff] [blame^] | 1 | export enum KillSwitchType { |
| 2 | Option = 'option', |
| 3 | Experiment = 'experiment', |
| 4 | Ignore = 'ignore', |
| 5 | Deprecated = 'deprecated', |
| 6 | InternalKillSwitch = 'internalKillSwitch', |
| 7 | } |
| 8 | |
| 9 | export enum OptionContext { |
| 10 | Options = 'options', |
| 11 | Experiments = 'experiments', |
| 12 | Internal = 'internal', |
| 13 | Deprecated = 'deprecated', |
| 14 | } |
| 15 | |
| 16 | export interface OptionConfig<T> { |
| 17 | codename: string; |
| 18 | context: OptionContext; |
| 19 | defaultValue: T; |
| 20 | killSwitchType: KillSwitchType; |
| 21 | optionalPermissions?: string[]; |
| 22 | } |
| 23 | |
| 24 | export class Option<T> implements OptionConfig<T> { |
| 25 | public codename: string; |
| 26 | public context: OptionContext; |
| 27 | public defaultValue: T; |
| 28 | public killSwitchType: KillSwitchType; |
| 29 | public optionalPermissions: string[]; |
| 30 | |
| 31 | constructor(config: OptionConfig<T>) { |
| 32 | this.codename = config.codename; |
| 33 | this.context = config.context; |
| 34 | this.defaultValue = config.defaultValue; |
| 35 | this.killSwitchType = config.killSwitchType; |
| 36 | this.optionalPermissions = config.optionalPermissions ?? []; |
| 37 | } |
| 38 | } |