-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabaseConfig.ts
35 lines (31 loc) · 1.12 KB
/
DatabaseConfig.ts
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
import { MatchAccuracyMethod } from "./MatchAccuracyMethod";
import { PlaceholderHandling } from "./kfDataModel";
import { base642hex, hex2base64 } from "./Hex";
export class DatabaseConfig {
public version: number;
public rootUUID: string;
public defaultMatchAccuracy: MatchAccuracyMethod;
public matchedURLAccuracyOverrides: { [url: string]: MatchAccuracyMethod; };
public defaultPlaceholderHandling: PlaceholderHandling;
public constructor () {
this.version = 3;
this.defaultMatchAccuracy = MatchAccuracyMethod.Domain;
this.matchedURLAccuracyOverrides = {};
this.defaultPlaceholderHandling = PlaceholderHandling.Disabled;
}
public static fromJSON (json: string) {
const conf = JSON.parse(json) as DatabaseConfig;
if (conf.rootUUID) {
conf.rootUUID = hex2base64(conf.rootUUID);
}
return conf;
}
public toJSON () {
const conf = Object.assign({}, this);
if (conf.rootUUID) {
conf.rootUUID = base642hex(conf.rootUUID);
}
const json = JSON.stringify(conf);
return json;
}
}