@@ -36,11 +36,9 @@ export interface IModuleCollector {
36
36
export interface IRequestInfoCollector {
37
37
getRequestInfo ( context : EventPluginContext ) : IRequestInfo ;
38
38
}
39
- export interface IStorage {
40
- save ( path : string , value : any ) : boolean ;
41
- get ( path : string ) : any ;
42
- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem [ ] ;
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 ;
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 implements IStorage {
147
- private _items ;
148
- private _maxItems ;
149
- constructor ( maxItems ?: number ) ;
150
- save ( path : string , value : any ) : boolean ;
151
- get ( path : string ) : any ;
152
- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem [ ] ;
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 ;
184
+ storage : IStorageProvider ;
192
185
queue : IEventQueue ;
193
186
private _plugins ;
194
187
constructor ( configSettings ?: IConfigurationSettings ) ;
@@ -416,10 +409,15 @@ export interface IError extends IInnerError {
416
409
modules ?: IModule [ ] ;
417
410
}
418
411
export interface IStorageItem {
419
- created : number ;
420
- path : string ;
412
+ timestamp : number ;
421
413
value : any ;
422
414
}
415
+ export interface IStorage {
416
+ save ( value : any ) : number ;
417
+ get ( limit ?: number ) : IStorageItem [ ] ;
418
+ remove ( timestamp : number ) : void ;
419
+ clear ( ) : void ;
420
+ }
423
421
export interface SubmissionCallback {
424
422
( status : number , message : string , data ?: string , headers ?: Object ) : void ;
425
423
}
@@ -439,38 +437,50 @@ export declare class SettingsResponse {
439
437
exception : any ;
440
438
constructor ( success : boolean , settings : any , settingsVersion ?: number , exception ?: any , message ?: string ) ;
441
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
+ }
442
450
export interface IClientConfiguration {
443
451
settings : Object ;
444
452
version : number ;
445
453
}
446
454
export declare abstract class KeyValueStorageBase implements IStorage {
447
455
private maxItems ;
448
- private timestamp ;
449
- private index ;
456
+ private items ;
457
+ private lastTimestamp ;
450
458
constructor ( maxItems : any ) ;
451
- save ( path : string , value : any ) : boolean ;
452
- get ( path : string ) : any ;
453
- getList ( searchPattern ?: string , limit ?: number ) : IStorageItem [ ] ;
454
- remove ( path : string ) : void ;
459
+ save ( value : any , single ?: boolean ) : number ;
460
+ get ( limit ?: number ) : IStorageItem [ ] ;
461
+ remove ( timestamp : number ) : void ;
462
+ clear ( ) : void ;
455
463
protected abstract write ( key : string , value : string ) : void ;
456
464
protected abstract read ( key : string ) : string ;
457
- protected abstract readDate ( key : string ) : number ;
465
+ protected abstract readAllKeys ( ) : string [ ] ;
458
466
protected abstract delete ( key : string ) : any ;
459
- protected abstract getEntries ( ) : string [ ] ;
460
- protected getKey ( entry : {
461
- name : string ;
462
- timestamp : number ;
463
- } ) : string ;
464
- protected getEntry ( encodedEntry : string ) : {
465
- name : string ;
466
- timestamp : number ;
467
- } ;
467
+ protected abstract getKey ( timestamp : number ) : string ;
468
+ protected abstract getTimestamp ( key : string ) : number ;
468
469
private ensureIndex ( ) ;
469
- private loadEntry ( entry ) ;
470
- private findEntry ( path ) ;
471
- private removeEntry ( entry ) ;
470
+ private safeDelete ( key ) ;
472
471
private createIndex ( ) ;
473
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
+ }
474
484
export declare class DefaultErrorParser implements IErrorParser {
475
485
parse ( context : EventPluginContext , exception : Error ) : IError ;
476
486
}
@@ -483,14 +493,8 @@ export declare class DefaultRequestInfoCollector implements IRequestInfoCollecto
483
493
export declare class DefaultSubmissionAdapter implements ISubmissionAdapter {
484
494
sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
485
495
}
486
- export declare class BrowserStorage extends KeyValueStorageBase {
487
- private prefix ;
488
- static isAvailable ( ) : boolean ;
489
- constructor ( prefix ?: string , maxItems ?: number , fs ?: any ) ;
490
- write ( key : string , value : string ) : void ;
491
- read ( key : string ) : any ;
492
- readDate ( key : string ) : number ;
493
- delete ( key : string ) : void ;
494
- getEntries ( ) : string [ ] ;
495
- getKey ( entry : any ) : string ;
496
+ export declare class BrowserStorageProvider implements IStorageProvider {
497
+ queue : IStorage ;
498
+ settings : IStorage ;
499
+ constructor ( prefix ?: string , maxQueueItems ?: number ) ;
496
500
}
0 commit comments