feat: add services package

This commit is contained in:
Karol Sójko
2022-07-05 20:51:42 +02:00
parent b614c71e79
commit fbfed0a05c
85 changed files with 2418 additions and 28 deletions

View File

@@ -0,0 +1 @@
export type EventObserver<E, D> = (eventName: E, data?: D) => Promise<void> | void

View File

@@ -0,0 +1,25 @@
/* istanbul ignore file */
export enum SyncEvent {
/**
* A potentially multi-round trip that keeps syncing until all items have been uploaded.
* However, this event will still trigger if there are more items waiting to be downloaded on the
* server
*/
SyncCompletedWithAllItemsUploaded = 'SyncCompletedWithAllItemsUploaded',
SyncCompletedWithAllItemsUploadedAndDownloaded = 'SyncCompletedWithAllItemsUploadedAndDownloaded',
SingleRoundTripSyncCompleted = 'SingleRoundTripSyncCompleted',
SyncWillBegin = 'sync:will-begin',
DownloadFirstSyncCompleted = 'sync:download-first-completed',
SyncTakingTooLong = 'sync:taking-too-long',
SyncError = 'sync:error',
InvalidSession = 'sync:invalid-session',
MajorDataChange = 'major-data-change',
LocalDataIncrementalLoad = 'local-data-incremental-load',
LocalDataLoaded = 'local-data-loaded',
EnterOutOfSync = 'enter-out-of-sync',
ExitOutOfSync = 'exit-out-of-sync',
StatusChanged = 'status-changed',
DatabaseWriteError = 'database-write-error',
DatabaseReadError = 'database-read-error',
SyncRequestsIntegrityCheck = 'sync:requests-integrity-check',
}

View File

@@ -0,0 +1,3 @@
import { SyncEvent } from './SyncEvent'
export type SyncEventReceiver = (event: SyncEvent) => void