import { Injector } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; import 'rxjs/add/observable/throw'; import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/repeat'; import 'rxjs/add/observable/concat'; import 'rxjs/add/observable/defer'; import 'rxjs/add/operator/defaultIfEmpty'; import { AuthService } from '../auth/auth.service'; import { EventsManagerService } from '../common/events-manager.service'; import { AppConfigurationService } from '../common/app-configuration.service'; import { APIClientService } from '../common/api-client.service'; import { DataQueryService } from '../common/data-query.service'; import { WebSocketsService } from '../websockets/websockets.service'; import { DatabaseService } from './database.service'; import { HttpInterceptor } from '../common/http-interceptor.service'; export declare class SyncService extends APIClientService { private webSocketsService; private dbService; private dataQueryService; eventsService: EventsManagerService; AppConfiguration: AppConfigurationService; private useLocalStorage; private useSynchronization; private useOfflineOperations; private syncCollection; private syncSubscription; private offlineCollection; private eventsSubscription; syncChangeSubject: Subject; readonly onSyncChange: Observable; constructor(http: HttpInterceptor, authService: AuthService, webSocketsService: WebSocketsService, dbService: DatabaseService, dataQueryService: DataQueryService, injector: Injector, eventsService: EventsManagerService, AppConfiguration: AppConfigurationService); /** * Starts the async listener for events */ startAsyncListener(): void; /** * Stops the async listener for events */ stopAsyncListener(): void; /** * Process the sync events received asynchronously */ private configureEventsListener(); /** * Start the synchronization timeout process */ startSync(): void; /** * Stop the synchronization timeout process */ stopSync(): void; /** * Retrieves resources available for sync changes */ private getSyncInfo(); /** * Request and process the changes for a resource since a given date * @param resource Resource name * @param lastSyncDate Last date of synchronization */ private syncResource(resource, lastSyncDate); /** * Retrieves all changes for a resource since a given date * @param resource Resource name * @param lastSyncDate Last date of synchronization * @param page Current page of total data */ private retrieveAllChanges(resource, lastSyncDate, page?); /** * Process a single synchronization change * @param operation Operation type (save/delete) * @param resource Name of the resource * @param resourceId Id of the resource * @param resourceService Service associated with the resource */ private processSyncChange(operation, resource, resourceId, resourceService?); /** * Sync all data for the resource * @param resource Resource name */ syncFromBeggining(resource: string): Observable; /** * Indicates if the use of local storage is enabled */ canUseLocalStorage(): boolean; /** * Indicates if the synchronization is enabled */ canUseSynchronization(): boolean; /** * Indicates if this resource has been * sinchronized previously * @param resource Resource name */ hasSynchronized(resource: string): Observable; /** * Synchronize all operations made in offline mode */ syncOfflineOperations(): void; private syncOfflineOperation(key, value); private syncOfflineSave(key, saveOperation); private syncOfflineUpdate(key, updateOperation); private syncOfflineDelete(key, deleteOperation); /** * Update all the id references in the offline operations * @param newId Id retrieved from the server * @param oldId Id generated locally */ private updateLocalIdReferences(resourceId, newId, oldId); /** * Process an offline save operation record * @param resource Name of the resource * @param data Data associated with the save operation */ processOfflineSave(resource: string, data: any): Observable; private addOfflineSave(resource, data); /** * Process an offline delete operation record * @param resource Name of the resource * @param resourceId Id of the resource */ processOfflineDelete(resource: string, resourceId: string): Observable; private addOfflineDelete(resource, resourceId); }