-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cdb792
commit 95655a3
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @desc Generic Base Class for All Caching actions using SQLite or LocalForage ensuring consistency between all Database implementations | ||
* @property { RepoMetadata } _ All Details contained by a Metadata Entry | ||
* @property { RepositoryDownloadRequestSpec } _ Information details for a Download e.g. API Url, Cache Targets, bounding boxes | ||
* @property { ProgressCallbackParams } _ Details for Callback Functionality, used for Progress bars, updates | ||
* @property { RepositoryStatusSchema } _ Enum for Cache Statuses, e.g. READY, CACHED, ERROR, etc | ||
* @example Implementation abstract Class Demo extends BaseCacheService< | ||
* RepoMetadataType | ||
* RepositoryDownloadRequestSpecType | ||
* RepoProgressCallbackParamsType | ||
* RepositoryStatusSchemeType> | ||
*/ | ||
abstract class BaseCacheService< | ||
RepoMetadata, | ||
RepositoryDownloadRequestSpec, | ||
ProgressCallbackParams, | ||
RepositoryStatusSchema | ||
> { | ||
/** Update any details for a Repository */ | ||
protected abstract addOrUpdateRepository(repositoryId: RepoMetadata): Promise<void>; | ||
|
||
/** Remove one Repository from the collection along with its contentes */ | ||
public abstract deleteRepository(repositoryId: string): Promise<void>; | ||
|
||
/** Pull metadata for one Repository in the Collection */ | ||
public abstract getRepository(repositoryId: string): Promise<RepoMetadata | null>; | ||
|
||
/** List metadata for all Repositories */ | ||
public abstract listRepositories(): Promise<RepoMetadata[]>; | ||
|
||
/** Change the status for a given Repository */ | ||
public abstract setRepositoryStatus(repositoryId: string, status: RepositoryStatusSchema): Promise<void>; | ||
|
||
/** Download a new Repository along with its contents */ | ||
public abstract download( | ||
spec: RepositoryDownloadRequestSpec, | ||
progressCallback?: (currentProgress: ProgressCallbackParams) => void | ||
): Promise<boolean | void>; | ||
|
||
protected constructor() {} | ||
} | ||
|
||
export default BaseCacheService; |