@@ -36,11 +36,9 @@ export interface IModuleCollector {
3636export interface IRequestInfoCollector {
3737 getRequestInfo ( context : EventPluginContext ) : IRequestInfo ;
3838}
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 ;
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 < any > ;
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 < 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 ) ;
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 < Object > ;
184+ storage : IStorageProvider ;
192185 queue : IEventQueue ;
193186 private _plugins ;
194187 constructor ( configSettings ?: IConfigurationSettings ) ;
@@ -215,6 +208,7 @@ export declare class Configuration implements IConfigurationSettings {
215208 userAgent : string ;
216209 useSessions ( sendHeartbeats ?: boolean ) : void ;
217210 useReferenceIds ( ) : void ;
211+ useLocalStorage ( ) : void ;
218212 useDebugLogger ( ) : void ;
219213 static defaults : IConfigurationSettings ;
220214}
@@ -414,10 +408,15 @@ export declare class DuplicateCheckerPlugin implements IEventPlugin {
414408export interface IError extends IInnerError {
415409 modules ?: IModule [ ] ;
416410}
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 ;
421420}
422421export interface SubmissionCallback {
423422 ( status : number , message : string , data ?: string , headers ?: Object ) : void ;
@@ -438,10 +437,50 @@ export declare class SettingsResponse {
438437 exception : any ;
439438 constructor ( success : boolean , settings : any , settingsVersion ?: number , exception ?: any , message ?: string ) ;
440439}
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+ }
441450export interface IClientConfiguration {
442451 settings : Object ;
443452 version : number ;
444453}
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+ }
445484export declare class DefaultErrorParser implements IErrorParser {
446485 parse ( context : EventPluginContext , exception : Error ) : IError ;
447486}
@@ -454,3 +493,8 @@ export declare class DefaultRequestInfoCollector implements IRequestInfoCollecto
454493export declare class DefaultSubmissionAdapter implements ISubmissionAdapter {
455494 sendRequest ( request : SubmissionRequest , callback : SubmissionCallback , isAppExiting ?: boolean ) : void ;
456495}
496+ export declare class BrowserStorageProvider implements IStorageProvider {
497+ queue : IStorage ;
498+ settings : IStorage ;
499+ constructor ( prefix ?: string , maxQueueItems ?: number ) ;
500+ }
0 commit comments