@@ -36,11 +36,9 @@ export interface IModuleCollector {
3636export interface IRequestInfoCollector {
3737 getRequestInfo ( context : EventPluginContext ) : IRequestInfo ;
3838}
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 ;
4442}
4543export interface ISubmissionAdapter {
4644 sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
@@ -62,11 +60,10 @@ export interface IConfigurationSettings {
6260 submissionBatchSize ?: number ;
6361 submissionClient ?: ISubmissionClient ;
6462 submissionAdapter ?: ISubmissionAdapter ;
65- storage ?: IStorage ;
63+ storage ?: IStorageProvider ;
6664 queue ?: IEventQueue ;
6765}
6866export declare class SettingsManager {
69- private static _configPath ;
7067 private static _handlers ;
7168 static onChanged ( handler : ( config : Configuration ) => void ) : void ;
7269 static applySavedServerSettings ( config : Configuration ) : void ;
@@ -143,14 +140,10 @@ export declare class DefaultEventQueue implements IEventQueue {
143140 private processSubmissionResponse ( response , events ) ;
144141 private removeEvents ( events ) ;
145142}
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 ) ;
154147}
155148export declare class DefaultSubmissionClient implements ISubmissionClient {
156149 configurationVersionHeader : string ;
@@ -188,7 +181,7 @@ export declare class Configuration implements IConfigurationSettings {
188181 submissionAdapter : ISubmissionAdapter ;
189182 submissionClient : ISubmissionClient ;
190183 settings : Object ;
191- storage : IStorage ;
184+ storage : IStorageProvider ;
192185 queue : IEventQueue ;
193186 private _plugins ;
194187 constructor ( configSettings ?: IConfigurationSettings ) ;
@@ -416,10 +409,15 @@ export interface IError extends IInnerError {
416409 modules ?: IModule [ ] ;
417410}
418411export interface IStorageItem {
419- created : number ;
420- path : string ;
412+ timestamp : number ;
421413 value : any ;
422414}
415+ export interface IStorage {
416+ save ( value : any ) : number ;
417+ get ( limit ?: number ) : IStorageItem [ ] ;
418+ remove ( timestamp : number ) : void ;
419+ clear ( ) : void ;
420+ }
423421export interface SubmissionCallback {
424422 ( status : number , message : string , data ?: string , headers ?: Object ) : void ;
425423}
@@ -439,38 +437,50 @@ export declare class SettingsResponse {
439437 exception : any ;
440438 constructor ( success : boolean , settings : any , settingsVersion ?: number , exception ?: any , message ?: string ) ;
441439}
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+ }
442450export interface IClientConfiguration {
443451 settings : Object ;
444452 version : number ;
445453}
446454export declare abstract class KeyValueStorageBase implements IStorage {
447455 private maxItems ;
448- private timestamp ;
449- private index ;
456+ private items ;
457+ private lastTimestamp ;
450458 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 ;
455463 protected abstract write ( key : string , value : string ) : void ;
456464 protected abstract read ( key : string ) : string ;
457- protected abstract readDate ( key : string ) : number ;
465+ protected abstract readAllKeys ( ) : string [ ] ;
458466 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 ;
468469 private ensureIndex ( ) ;
469- private loadEntry ( entry ) ;
470- private findEntry ( path ) ;
471- private removeEntry ( entry ) ;
470+ private safeDelete ( key ) ;
472471 private createIndex ( ) ;
473472}
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+ }
474484export declare class DefaultErrorParser implements IErrorParser {
475485 parse ( context : EventPluginContext , exception : Error ) : IError ;
476486}
@@ -483,14 +493,8 @@ export declare class DefaultRequestInfoCollector implements IRequestInfoCollecto
483493export declare class DefaultSubmissionAdapter implements ISubmissionAdapter {
484494 sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
485495}
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 ) ;
496500}
0 commit comments