learning_ai_common_plat/packages/sync/src/index.ts
2026-03-19 21:25:30 -07:00

53 lines
1.3 KiB
TypeScript

/**
* @bytelyst/sync
*
* Offline-first sync engine with configurable storage adapters and conflict resolution.
*
* @example
* ```typescript
* import { createSyncEngine, LocalStorageAdapter } from '@bytelyst/sync';
* import { createApiClient } from '@bytelyst/api-client';
*
* const sync = createSyncEngine({
* productId: 'myapp',
* entities: {
* tasks: {
* endpoint: '/api/tasks',
* partitionKey: 'userId',
* conflictStrategy: 'server-wins',
* },
* },
* storage: new LocalStorageAdapter(),
* apiClient: createApiClient({ baseURL: 'https://api.example.com' }),
* });
*
* // Push changes
* await sync.push('tasks', { title: 'New Task' });
*
* // Sync with server
* const result = await sync.fullSync();
* console.log(`Pushed: ${result.pushed}, Pulled: ${result.pulled}`);
* ```
*/
export { createSyncEngine, SyncEngineImpl, SyncConflictError, computeBackoff } from './engine.js';
export { LocalStorageAdapter, InMemoryAdapter, MMKVAdapter, type MMKVInstance } from './storage.js';
export type {
SyncEngine,
SyncEngineConfig,
EntityName,
EntityConfig,
ConflictStrategy,
SyncStatus,
SyncOperation,
SyncItem,
SyncResult,
SyncStatusInfo,
SyncStatusCallback,
PullHandler,
StorageAdapter,
Conflict,
} from './types.js';