@@ -36,11 +36,9 @@ export interface IModuleCollector {
36
36
export interface IRequestInfoCollector {
37
37
getRequestInfo ( context : EventPluginContext ) : IRequestInfo ;
38
38
}
39
- export interface IStorage < T > {
40
- save ( path : string , value : T ) : boolean ;
41
- get ( path : string ) : T ;
42
- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem < T > [ ] ;
43
- remove ( path : string ) : void ;
39
+ export interface IStorageProvider {
40
+ queue : IStorage ;
41
+ settings : IStorage ;
44
42
}
45
43
export interface ISubmissionAdapter {
46
44
sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
@@ -62,11 +60,10 @@ export interface IConfigurationSettings {
62
60
submissionBatchSize ?: number ;
63
61
submissionClient ?: ISubmissionClient ;
64
62
submissionAdapter ?: ISubmissionAdapter ;
65
- storage ?: IStorage < any > ;
63
+ storage ?: IStorageProvider ;
66
64
queue ?: IEventQueue ;
67
65
}
68
66
export declare class SettingsManager {
69
- private static _configPath ;
70
67
private static _handlers ;
71
68
static onChanged ( handler : ( config : Configuration ) => void ) : void ;
72
69
static applySavedServerSettings ( config : Configuration ) : void ;
@@ -143,14 +140,10 @@ export declare class DefaultEventQueue implements IEventQueue {
143
140
private processSubmissionResponse ( response , events ) ;
144
141
private removeEvents ( events ) ;
145
142
}
146
- export declare class InMemoryStorage < T > implements IStorage < T > {
147
- private _items ;
148
- private _maxItems ;
149
- constructor ( maxItems ?: number ) ;
150
- save ( path : string , value : T ) : boolean ;
151
- get ( path : string ) : T ;
152
- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem < T > [ ] ;
153
- remove ( path : string ) : void ;
143
+ export declare class InMemoryStorageProvider implements IStorageProvider {
144
+ queue : IStorage ;
145
+ settings : IStorage ;
146
+ constructor ( maxQueueItems ?: number ) ;
154
147
}
155
148
export declare class DefaultSubmissionClient implements ISubmissionClient {
156
149
configurationVersionHeader : string ;
@@ -188,7 +181,7 @@ export declare class Configuration implements IConfigurationSettings {
188
181
submissionAdapter : ISubmissionAdapter ;
189
182
submissionClient : ISubmissionClient ;
190
183
settings : Object ;
191
- storage : IStorage < Object > ;
184
+ storage : IStorageProvider ;
192
185
queue : IEventQueue ;
193
186
private _plugins ;
194
187
constructor ( configSettings ?: IConfigurationSettings ) ;
@@ -215,6 +208,7 @@ export declare class Configuration implements IConfigurationSettings {
215
208
userAgent : string ;
216
209
useSessions ( sendHeartbeats ?: boolean ) : void ;
217
210
useReferenceIds ( ) : void ;
211
+ useLocalStorage ( ) : void ;
218
212
useDebugLogger ( ) : void ;
219
213
static defaults : IConfigurationSettings ;
220
214
}
@@ -414,10 +408,15 @@ export declare class DuplicateCheckerPlugin implements IEventPlugin {
414
408
export interface IError extends IInnerError {
415
409
modules ?: IModule [ ] ;
416
410
}
417
- export interface IStorageItem < T > {
418
- created : number ;
419
- path : string ;
420
- value : T ;
411
+ export interface IStorageItem {
412
+ timestamp : number ;
413
+ value : any ;
414
+ }
415
+ export interface IStorage {
416
+ save ( value : any ) : number ;
417
+ get ( limit ?: number ) : IStorageItem [ ] ;
418
+ remove ( timestamp : number ) : void ;
419
+ clear ( ) : void ;
421
420
}
422
421
export interface SubmissionCallback {
423
422
( status : number , message : string , data ?: string , headers ?: Object ) : void ;
@@ -438,10 +437,50 @@ export declare class SettingsResponse {
438
437
exception : any ;
439
438
constructor ( success : boolean , settings : any , settingsVersion ?: number , exception ?: any , message ?: string ) ;
440
439
}
440
+ export declare class InMemoryStorage implements IStorage {
441
+ private maxItems ;
442
+ private items ;
443
+ private lastTimestamp ;
444
+ constructor ( maxItems : number ) ;
445
+ save ( value : any ) : number ;
446
+ get ( limit ?: number ) : IStorageItem [ ] ;
447
+ remove ( timestamp : number ) : void ;
448
+ clear ( ) : void ;
449
+ }
441
450
export interface IClientConfiguration {
442
451
settings : Object ;
443
452
version : number ;
444
453
}
454
+ export declare abstract class KeyValueStorageBase implements IStorage {
455
+ private maxItems ;
456
+ private items ;
457
+ private lastTimestamp ;
458
+ constructor ( maxItems : any ) ;
459
+ save ( value : any , single ?: boolean ) : number ;
460
+ get ( limit ?: number ) : IStorageItem [ ] ;
461
+ remove ( timestamp : number ) : void ;
462
+ clear ( ) : void ;
463
+ protected abstract write ( key : string , value : string ) : void ;
464
+ protected abstract read ( key : string ) : string ;
465
+ protected abstract readAllKeys ( ) : string [ ] ;
466
+ protected abstract delete ( key : string ) : any ;
467
+ protected abstract getKey ( timestamp : number ) : string ;
468
+ protected abstract getTimestamp ( key : string ) : number ;
469
+ private ensureIndex ( ) ;
470
+ private safeDelete ( key ) ;
471
+ private createIndex ( ) ;
472
+ }
473
+ export declare class BrowserStorage extends KeyValueStorageBase {
474
+ private prefix ;
475
+ static isAvailable ( ) : boolean ;
476
+ constructor ( namespace : string , prefix ?: string , maxItems ?: number ) ;
477
+ write ( key : string , value : string ) : void ;
478
+ read ( key : string ) : any ;
479
+ readAllKeys ( ) : string [ ] ;
480
+ delete ( key : string ) : void ;
481
+ getKey ( timestamp : any ) : string ;
482
+ getTimestamp ( key : any ) : number ;
483
+ }
445
484
export declare class DefaultErrorParser implements IErrorParser {
446
485
parse ( context : EventPluginContext , exception : Error ) : IError ;
447
486
}
@@ -454,3 +493,8 @@ export declare class DefaultRequestInfoCollector implements IRequestInfoCollecto
454
493
export declare class DefaultSubmissionAdapter implements ISubmissionAdapter {
455
494
sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
456
495
}
496
+ export declare class BrowserStorageProvider implements IStorageProvider {
497
+ queue : IStorage ;
498
+ settings : IStorage ;
499
+ constructor ( prefix ?: string , maxQueueItems ?: number ) ;
500
+ }
0 commit comments