feat(nbstore): add sqlite implementation (#8811)

This commit is contained in:
forehalo
2024-12-13 06:13:05 +00:00
parent 932e1da7f3
commit 8c24f2b906
66 changed files with 2932 additions and 397 deletions

View File

@@ -1,5 +1,43 @@
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class DocStorage {
constructor(path: string)
/** Initialize the database and run migrations. */
connect(): Promise<void>
close(): Promise<void>
get isClosed(): Promise<boolean>
/**
* Flush the WAL file to the database file.
* See https://www.sqlite.org/pragma.html#pragma_wal_checkpoint:~:text=PRAGMA%20schema.wal_checkpoint%3B
*/
checkpoint(): Promise<void>
validate(): Promise<boolean>
setSpaceId(spaceId: string): Promise<void>
pushUpdate(docId: string, update: Uint8Array): Promise<Date>
getDocSnapshot(docId: string): Promise<DocRecord | null>
setDocSnapshot(snapshot: DocRecord): Promise<boolean>
getDocUpdates(docId: string): Promise<Array<DocUpdate>>
markUpdatesMerged(docId: string, updates: Array<Date>): Promise<number>
deleteDoc(docId: string): Promise<void>
getDocClocks(after?: Date | undefined | null): Promise<Array<DocClock>>
getDocClock(docId: string): Promise<DocClock | null>
getBlob(key: string): Promise<Blob | null>
setBlob(blob: SetBlob): Promise<void>
deleteBlob(key: string, permanently: boolean): Promise<void>
releaseBlobs(): Promise<void>
listBlobs(): Promise<Array<ListedBlob>>
getPeerRemoteClocks(peer: string): Promise<Array<DocClock>>
getPeerRemoteClock(peer: string, docId: string): Promise<DocClock>
setPeerRemoteClock(peer: string, docId: string, clock: Date): Promise<void>
getPeerPulledRemoteClocks(peer: string): Promise<Array<DocClock>>
getPeerPulledRemoteClock(peer: string, docId: string): Promise<DocClock>
setPeerPulledRemoteClock(peer: string, docId: string, clock: Date): Promise<void>
getPeerPushedClocks(peer: string): Promise<Array<DocClock>>
getPeerPushedClock(peer: string, docId: string): Promise<DocClock>
setPeerPushedClock(peer: string, docId: string, clock: Date): Promise<void>
clearClocks(): Promise<void>
}
export declare class SqliteConnection {
constructor(path: string)
connect(): Promise<void>
@@ -37,19 +75,57 @@ export declare class SqliteConnection {
checkpoint(): Promise<void>
}
export interface Blob {
key: string
data: Uint8Array
mime: string
size: number
createdAt: Date
}
export interface BlobRow {
key: string
data: Buffer
timestamp: Date
}
export interface DocClock {
docId: string
timestamp: Date
}
export interface DocRecord {
docId: string
data: Uint8Array
timestamp: Date
}
export interface DocUpdate {
docId: string
createdAt: Date
data: Uint8Array
}
export interface InsertRow {
docId?: string
data: Uint8Array
}
export interface ListedBlob {
key: string
size: number
mime: string
createdAt: Date
}
export declare function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export interface SetBlob {
key: string
data: Uint8Array
mime: string
}
export interface UpdateRow {
id: number
timestamp: Date
@@ -66,4 +142,3 @@ export declare enum ValidationResult {
}
export declare function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>