MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / ClipperData

Class ClipperData

src/scripts/storage/clipperData.ts:16–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 * sanity-check for what information gets stored locally.
15 */
16export class ClipperData implements Storage {
17 private storage: Storage;
18 private storageGateStrategy: StorageGateStrategy;
19 private cachedHttp: ClipperCachedHttp;
20
21 constructor(storage: Storage, logger?: Logger) {
22 this.storage = storage;
23 this.storageGateStrategy = new ClipperStorageGateStrategy(storage);
24 // We pass 'this' as the Storage object as it handles all the sanity-check gating in the setValue
25 this.cachedHttp = new ClipperCachedHttp(this, logger);
26 }
27
28 public setLogger(logger: Logger) {
29 this.cachedHttp.setLogger(logger);
30 }
31
32 public getFreshValue(key: string, getRemoteValue: GetResponseAsync, updateInterval?: number): Promise<TimeStampedData> {
33 return this.cachedHttp.getFreshValue(key, getRemoteValue, updateInterval);
34 }
35
36 public getValue(key: string): string {
37 return this.storage.getValue(key);
38 }
39
40 public getValues(keys: string[]): {} {
41 return this.storage.getValues(keys);
42 }
43
44 public setValue(key: string, value: string): void {
45 if (this.storageGateStrategy.shouldSet(key, value)) {
46 this.storage.setValue(key, value);
47 }
48 }
49
50 public removeKey(key: string): boolean {
51 return this.storage.removeKey(key);
52 }
53}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected