This commit is contained in:
Drew Ansbacher
2021-07-21 14:44:08 -06:00
parent 7fb8e9b6da
commit 0ef388e055
3 changed files with 14 additions and 9 deletions

View File

@@ -3,9 +3,9 @@ import { Operation } from './json-patch-lib'
// revise a collection of nodes.
export type Revision = { id: number, patch: Operation[], expireId: string | null }
// dump/replace the entire store with T
export type Dump<T> = { id: number, value: T, expireId: string | null }
export type Dump<T extends HashMap> = { id: number, value: T, expireId: string | null }
export type Update<T> = Revision | Dump<T>
export type Update<T extends HashMap> = Revision | Dump<T>
export enum PatchOp {
ADD = 'add',
@@ -13,17 +13,20 @@ export enum PatchOp {
REPLACE = 'replace',
}
export interface Http<T> {
export interface Http<T extends HashMap> {
getRevisions (since: number): Promise<Revision[] | Dump<T>>
getDump (): Promise<Dump<T>>
}
export interface Bootstrapper<T> {
export interface Bootstrapper<T extends HashMap> {
init (): Promise<DBCache<T>>
update (cache: DBCache<T>): Promise<void>
}
export interface DBCache<T>{
export interface DBCache<T extends HashMap>{
sequence: number,
data: T
}
export type HashMap = { [type: string]: any }