import type { SyncItem } from '../contentful/types'; import { Syncable } from '../syncEngine'; export interface Exportable { /** * Exports the current state of the data source to a backup key-value store */ export(): Generator | AsyncGenerator; } /** * The writable part of the AsyncStorage interface */ export interface WritableKeyValueStorage { setItem: (key: string, value: string) => Promise; } /** * The readable part of the AsyncStorage interface */ export interface ReadableKeyValueStorage { getItem: (key: string) => Promise; } /** * */ export interface DataSourceWithBackup { backup(): Promise; restore(): Promise; } /** * Enhances a DataSource with AsyncStorage to make a convenient backup and * restore system. * @param dataSource The data source with canonical data eg InMemoryDataSource * @param storage A Key-Value Pair storage system like AsyncStorage * @param prefix The key prefix under which to store the data * @returns The same DataSource enhanced with the backup() and restore() methods */ export declare function addBackup(dataSource: TDataSource, storage: WritableKeyValueStorage & ReadableKeyValueStorage, prefix: string): asserts dataSource is TDataSource & DataSourceWithBackup; /** * Enhances a DataSource with AsyncStorage to make a convenient backup and * restore system. * @param dataSource The data source with canonical data eg InMemoryDataSource * @param storage A Key-Value Pair storage system like AsyncStorage * @param prefix The key prefix under which to store the data * @returns The same DataSource enhanced with the backup() and restore() methods */ export declare function withBackup(dataSource: TDataSource, storage: WritableKeyValueStorage & ReadableKeyValueStorage, prefix: string): TDataSource & DataSourceWithBackup; export declare function isExportable(dataSource: any): dataSource is Exportable; export declare function hasBackup(dataSource: any): dataSource is DataSourceWithBackup;