diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 92176b62..e9afc38e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,8 +1,26 @@ { - "version": "0.1.0", + "version": "2.0.0", "command": "tsc", - "isShellCommand": true, "args": ["-w", "-p", ".", "--noEmit"], "isBackground": true, - "problemMatcher": "$tsc-watch" + "problemMatcher": "$tsc-watch", + "tasks": [ + { + "label": "tsc", + "type": "shell", + "command": "tsc", + "args": [ + "-w", + "-p", + ".", + "--noEmit" + ], + "isBackground": true, + "problemMatcher": "$tsc-watch", + "group": { + "_id": "build", + "isDefault": false + } + } + ] } diff --git a/src/Cache.ts b/src/Cache.ts index 4bfd3e49..d42325b8 100644 --- a/src/Cache.ts +++ b/src/Cache.ts @@ -1,11 +1,11 @@ import { ApolloCache } from '@apollo/client/core'; import { ApolloPersistOptions, PersistedData } from './types'; -export default class Cache { +export default class CacheLog { cache: ApolloCache; serialize: boolean; - constructor(options: ApolloPersistOptions) { + constructor(options: ApolloPersistOptions) { const { cache, serialize = true } = options; this.cache = cache; diff --git a/src/CachePersistor.ts b/src/CachePersistor.ts index c24594b4..26d3fc09 100644 --- a/src/CachePersistor.ts +++ b/src/CachePersistor.ts @@ -6,14 +6,14 @@ import Trigger from './Trigger'; import { ApolloPersistOptions, LogLine } from './types'; -export default class CachePersistor { +export default class CachePersistor { log: Log; cache: Cache; storage: Storage; persistor: Persistor; trigger: Trigger; - constructor(options: ApolloPersistOptions) { + constructor(options: ApolloPersistOptions) { if (!options.cache) { throw new Error( 'In order to persist your Apollo Cache, you need to pass in a cache. ' + diff --git a/src/Log.ts b/src/Log.ts index 0acdfefa..b43d436d 100644 --- a/src/Log.ts +++ b/src/Log.ts @@ -1,13 +1,13 @@ import { ApolloPersistOptions, LogLevel, LogLine } from './types'; -export default class Log { +export default class Log { debug: boolean; lines: Array; static buffer = 30; static prefix = '[apollo-cache-persist]'; - constructor(options: ApolloPersistOptions) { + constructor(options: ApolloPersistOptions) { const { debug = false } = options; this.debug = debug; diff --git a/src/Persistor.ts b/src/Persistor.ts index bdc55f0a..47de8f6d 100644 --- a/src/Persistor.ts +++ b/src/Persistor.ts @@ -10,7 +10,7 @@ export interface PersistorConfig { storage: Storage; } -export default class Persistor { +export default class Persistor { log: Log; cache: Cache; storage: Storage; @@ -20,7 +20,7 @@ export default class Persistor { constructor( { log, cache, storage }: PersistorConfig, - options: ApolloPersistOptions, + options: ApolloPersistOptions, ) { const { maxSize = 1024 * 1024, diff --git a/src/Storage.ts b/src/Storage.ts index c458fdab..55dbf930 100644 --- a/src/Storage.ts +++ b/src/Storage.ts @@ -4,11 +4,11 @@ import { PersistedData, } from './types'; -export default class Storage { +export default class Storage { storage: PersistentStorage>; key: string; - constructor(options: ApolloPersistOptions) { + constructor(options: ApolloPersistOptions) { const { storage, key = 'apollo-cache-persist' } = options; this.storage = storage; diff --git a/src/Trigger.ts b/src/Trigger.ts index 15312675..f6544bd1 100644 --- a/src/Trigger.ts +++ b/src/Trigger.ts @@ -10,7 +10,7 @@ export interface TriggerConfig { persistor: Persistor; } -export default class Trigger { +export default class Trigger { debounce: number; persistor: Persistor; paused: boolean; @@ -21,7 +21,7 @@ export default class Trigger { constructor( { log, persistor }: TriggerConfig, - options: ApolloPersistOptions + options: ApolloPersistOptions ) { const { defaultDebounce } = Trigger; const { cache, debounce, trigger = 'write' } = options; diff --git a/src/persistCacheSync.ts b/src/persistCacheSync.ts index 120fe303..3bc99864 100644 --- a/src/persistCacheSync.ts +++ b/src/persistCacheSync.ts @@ -5,11 +5,11 @@ import Storage from './Storage'; /** * Add cache to persist engine using synchronous API - * + * * @see SynchronousCachePersistor for advanced use cases * @param options options for persist engine */ -export const persistCacheSync = (options: ApolloPersistOptions) => { +export const persistCacheSync = (options: ApolloPersistOptions) => { const cachePersistor = new SynchronousCachePersistor(options); cachePersistor.restoreSync(); }; @@ -17,10 +17,10 @@ export const persistCacheSync = (options: ApolloPersistOptions) => { /** * Persistor engine that is going to use synchronous api */ -export class SynchronousCachePersistor extends CachePersistor { +export class SynchronousCachePersistor extends CachePersistor { persistor: SynchronousPersistor; - constructor(options: ApolloPersistOptions) { + constructor(options: ApolloPersistOptions) { super(options); this.storage = new SynchronousStorage(options); @@ -35,12 +35,12 @@ export class SynchronousCachePersistor extends CachePersistor { } } -export class SynchronousPersistor extends Persistor { - storage: SynchronousStorage; +export class SynchronousPersistor extends Persistor { + storage: SynchronousStorage; constructor( { log, cache, storage }: PersistorConfig, - options: ApolloPersistOptions, + options: ApolloPersistOptions, ) { super({ log, cache, storage }, options); } @@ -50,8 +50,8 @@ export class SynchronousPersistor extends Persistor { } } -export class SynchronousStorage extends Storage { - constructor(options: ApolloPersistOptions) { +export class SynchronousStorage extends Storage { + constructor(options: ApolloPersistOptions) { super(options); }