Files
AFFiNE/packages/frontend/native/index.d.ts
T
DarkSky 3d25727076 feat(core): improve sync stability (#15883)
#### PR Dependency Tree


* **PR #15883** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Document creation can now recover incomplete registrations without
recreating document content.
* Document updates can detect revision conflicts, helping prevent
changes from overwriting newer edits.
* **Improvements**
* Document sync and update handling are improved across desktop,
Android, and iOS.
* Workspace metadata and legacy document pages are handled more
consistently during migration and recovery.
* Creator and editor details are better preserved when documents are
recovered or compacted.
* **Configuration**
  * Removed the experimental document-merge setting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-22 01:37:22 +08:00

470 lines
14 KiB
TypeScript

/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class ApplicationInfo {
processId: number
name: string
objectId: number
constructor(processId: number, name: string, objectId: number)
get processGroupId(): number
get bundleIdentifier(): string
get icon(): Buffer
}
export declare class ApplicationListChangedSubscriber {
unsubscribe(): void
}
export declare class ApplicationStateChangedSubscriber {
unsubscribe(): void
}
export declare class ShareableContent {
static onApplicationListChanged(callback: ((err: Error | null, ) => void)): ApplicationListChangedSubscriber
static onAppStateChanged(app: ApplicationInfo, callback: ((err: Error | null, ) => void)): ApplicationStateChangedSubscriber
constructor()
static applications(): Array<ApplicationInfo>
static applicationWithProcessId(processId: number): ApplicationInfo | null
static isUsingMicrophone(processId: number): boolean
}
export declare function abortRecording(id: string): Promise<void>
export declare function decodeAudio(buf: Uint8Array, destSampleRate?: number | undefined | null, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<Float32Array>
/** Decode audio file into a Float32Array */
export declare function decodeAudioSync(buf: Uint8Array, destSampleRate?: number | undefined | null, filename?: string | undefined | null): Float32Array
export interface RecordingArtifact {
id: string
filepath: string
sampleRate: number
channels: number
durationMs: number
size: number
degraded: boolean
overflowCount: number
}
export interface RecordingSessionMeta {
id: string
filepath: string
sampleRate: number
channels: number
startedAt: number
}
export interface RecordingStartOptions {
appProcessId?: number
excludeProcessIds?: Array<number>
outputDir: string
format?: string
sampleRate?: number
channels?: number
id?: string
}
export declare function startRecording(opts: RecordingStartOptions): Promise<RecordingSessionMeta>
export declare function stopRecording(id: string): Promise<RecordingArtifact>
export declare class DiskSync {
constructor()
startSession(sessionId: string, options: DiskSessionOptions): Promise<void>
stopSession(sessionId: string): Promise<void>
applyLocalUpdate(sessionId: string, update: DiskDocUpdateInput): Promise<DiskDocClock>
acknowledgeSourceUpdate(sessionId: string, docId: string, snapshot: Uint8Array): Promise<void>
prepareSourceDoc(sessionId: string, docId: string, localSnapshot?: Uint8Array | undefined | null, localRoot?: Uint8Array | undefined | null): Promise<Uint8Array | null>
subscribeEvents(sessionId: string, callback: ((err: Error | null, arg: DiskSyncEvent) => void)): Promise<DiskSyncSubscriber>
}
export declare class DiskSyncSubscriber {
unsubscribe(): Promise<void>
}
export declare function cancelImportSession(sessionId: string): void
export declare function compactDocUpdatesV1(updates: Array<Uint8Array>): Uint8Array
export interface CreateImportBatchLimits {
maxDocs?: number
maxBlobs?: number
maxBlobBytes?: number
}
export declare function createImportSession(options: CreateImportSessionOptions): string
export interface CreateImportSessionOptions {
format: string
source: CreateImportSessionSource
batchLimits?: CreateImportBatchLimits
}
export interface CreateImportSessionSource {
kind: string
path: string
}
export interface DiskDocClock {
docId: string
timestamp: Date
reviewRequired?: string
exportError?: string
}
export interface DiskDocUpdateInput {
docId: string
bin: Uint8Array
editor?: string
}
export interface DiskSessionOptions {
workspaceId: string
syncFolder: string
}
export interface DiskSyncDocUpdateEvent {
docId: string
bin: Uint8Array
timestamp: Date
editor?: string
}
export interface DiskSyncEvent {
type: string
update?: DiskSyncDocUpdateEvent
docId?: string
timestamp?: Date
origin?: string
message?: string
}
export declare function disposeImportSession(sessionId: string): void
export interface MermaidRenderOptions {
theme?: string
fontFamily?: string
fontSize?: number
}
export interface MermaidRenderRequest {
code: string
options?: MermaidRenderOptions
}
export interface MermaidRenderResult {
svg: string
}
export declare function mintChallengeResponse(resource: string, bits?: number | undefined | null): Promise<string>
export declare function nextImportBatch(sessionId: string): string | null
export declare function parseWorkspaceRootDocMeta(updates: Array<Uint8Array>): WorkspaceRootDocMeta
export declare function renderMermaidSvg(request: MermaidRenderRequest): MermaidRenderResult
export declare function renderTypstSvg(request: TypstRenderRequest): TypstRenderResult
export interface TypstRenderOptions {
fontUrls?: Array<string>
fontDirs?: Array<string>
}
export interface TypstRenderRequest {
code: string
options?: TypstRenderOptions
}
export interface TypstRenderResult {
svg: string
}
export declare function verifyChallengeResponse(response: string, bits: number, resource: string): Promise<boolean>
export interface WorkspaceRootDocMeta {
name?: string
avatar?: string
pageCount?: number
}
export declare class DocStorage {
constructor(path: string)
validate(): Promise<boolean>
validateImportSchema(): Promise<boolean>
vacuumInto(path: string): Promise<void>
setSpaceId(spaceId: string): Promise<void>
}
export declare class DocStoragePool {
constructor()
/** Initialize the database and run migrations. */
connect(universalId: string, path: string): Promise<void>
disconnect(universalId: string): Promise<void>
checkpoint(universalId: string): Promise<void>
vacuumInto(universalId: string, path: string): Promise<void>
crawlDocData(universalId: string, docId: string): Promise<NativeCrawlResult>
setSpaceId(universalId: string, spaceId: string): Promise<void>
pushUpdate(universalId: string, docId: string, update: Uint8Array, createForPeer?: string | undefined | null): Promise<Date>
getPeerWorkspaceState(universalId: string, peer: string, rootDocId: string): Promise<PeerWorkspaceState>
invalidatePeerWorkspaceState(universalId: string, peer: string, rootDocId: string): Promise<void>
installPeerWorkspaceState(universalId: string, peer: string, rootDocId: string, cacheToken: number, docs: Array<WorkspaceDoc>, clocks: Record<string, number>): Promise<boolean>
confirmPeerDocCreate(universalId: string, peer: string, docId: string): Promise<void>
getDoc(universalId: string, docId: string): Promise<DocRecord | null>
mergeUpdates(updates: Array<Uint8Array>): Uint8Array
getDocDiff(universalId: string, docId: string, state?: Uint8Array | undefined | null): Promise<DocDiff | null>
readDocRecordsReadonly(path: string, docId: string): Promise<ReadonlyDocRecords>
readBlobReadonly(path: string, key: string): Promise<Blob | null>
deleteDoc(universalId: string, docId: string): Promise<void>
getDocClocks(universalId: string, after?: Date | undefined | null): Promise<Array<DocClock>>
getDocClock(universalId: string, docId: string): Promise<DocClock | null>
getDocIndexedClock(universalId: string, docId: string): Promise<DocIndexedClock | null>
setDocIndexedClock(universalId: string, docId: string, indexedClock: Date, indexerVersion: number): Promise<void>
setDocIndexedClocks(universalId: string, clocks: Array<DocIndexedClock>): Promise<void>
clearDocIndexedClock(universalId: string, docId: string): Promise<void>
getBlob(universalId: string, key: string): Promise<Blob | null>
setBlob(universalId: string, blob: SetBlob): Promise<void>
deleteBlob(universalId: string, key: string, permanently: boolean): Promise<void>
releaseBlobs(universalId: string): Promise<void>
listBlobs(universalId: string): Promise<Array<ListedBlob>>
getPeerRemoteClocks(universalId: string, peer: string): Promise<Array<DocClock>>
getPeerRemoteClock(universalId: string, peer: string, docId: string): Promise<DocClock | null>
setPeerRemoteClock(universalId: string, peer: string, docId: string, clock: Date): Promise<void>
getPeerPulledRemoteClocks(universalId: string, peer: string): Promise<Array<DocClock>>
getPeerPulledRemoteClock(universalId: string, peer: string, docId: string): Promise<DocClock | null>
setPeerPulledRemoteClock(universalId: string, peer: string, docId: string, clock: Date): Promise<void>
getPeerPushedClocks(universalId: string, peer: string): Promise<Array<DocClock>>
getPeerPushedClock(universalId: string, peer: string, docId: string): Promise<DocClock | null>
setPeerPushedClock(universalId: string, peer: string, docId: string, clock: Date): Promise<void>
clearClocks(universalId: string): Promise<void>
setBlobUploadedAt(universalId: string, peer: string, blobId: string, uploadedAt?: Date | undefined | null): Promise<void>
getBlobUploadedAt(universalId: string, peer: string, blobId: string): Promise<Date | null>
indexUpsert(id: string, table: string, document: NativeIndexDocument): Promise<void>
indexFlush(id: string): Promise<void>
indexVersion(): Promise<number>
indexDelete(id: string, table: string, docId: string): Promise<void>
indexSearch(id: string, table: string, query: NativeIndexQuery, options: NativeIndexSearchOptions): Promise<NativeIndexSearchResult>
indexAggregate(id: string, table: string, query: NativeIndexQuery, field: string, limit: number, offset: number, hits?: NativeIndexSearchOptions | undefined | null): Promise<NativeIndexAggregateResult>
indexDeleteByQuery(id: string, table: string, query: NativeIndexQuery): Promise<number>
}
export interface Blob {
key: string
data: Uint8Array
mime: string
size: number
createdAt: Date
}
export interface DocClock {
docId: string
timestamp: Date
}
export interface DocDiff {
docId: string
missing: Uint8Array
state: Uint8Array
timestamp: Date
}
export interface DocIndexedClock {
docId: string
timestamp: Date
indexerVersion: number
}
export interface DocRecord {
docId: string
bin: Uint8Array
timestamp: Date
}
export interface DocUpdate {
docId: string
timestamp: Date
bin: Uint8Array
}
export interface ListedBlob {
key: string
size: number
mime: string
createdAt: Date
}
export interface NativeBlockInfo {
blockId: string
flavour: string
content?: Array<string>
blob?: Array<string>
refDocId?: Array<string>
refInfo?: Array<string>
parentFlavour?: string
parentBlockId?: string
additional?: string
}
export interface NativeCrawlResult {
blocks: Array<NativeBlockInfo>
title: string
summary: string
}
export interface NativeIndexAggregateResult {
total: number
buckets: Array<NativeIndexBucket>
}
export interface NativeIndexBucket {
key: string
count: number
score: number
hits: Array<NativeIndexHit>
}
export interface NativeIndexDocument {
id: string
fields: Array<NativeIndexField>
}
export interface NativeIndexField {
field: string
values: Array<string>
}
export interface NativeIndexHighlight {
field: string
values: Array<NativeIndexHighlightValue>
}
export interface NativeIndexHighlightValue {
valueIndex: number
spans: Array<NativeIndexSpan>
}
export interface NativeIndexHit {
id: string
score: number
fields: Array<NativeIndexField>
highlights: Array<NativeIndexHighlight>
}
export interface NativeIndexQuery {
kind: string
field?: string
value?: string
occur?: string
clauses?: Array<NativeIndexQuery>
boost?: number
}
export interface NativeIndexSearchOptions {
limit: number
offset: number
fields: Array<string>
highlights: Array<string>
}
export interface NativeIndexSearchResult {
total: number
hits: Array<NativeIndexHit>
}
export interface NativeIndexSpan {
start: number
end: number
}
export interface PeerWorkspaceState {
cacheToken: number
ready: boolean
docs: Array<WorkspaceDoc>
clocks: Record<string, number>
}
export interface ReadonlyDocRecords {
snapshot?: DocRecord
updates: Array<DocUpdate>
}
export interface SetBlob {
key: string
data: Uint8Array
mime: string
}
export interface WorkspaceDoc {
docId: string
timestamp: number
lifecycle: 'trashed' | null
lifecycleChangedAt: number | null
pendingCreate: boolean
}
export declare class SqliteConnection {
constructor(path: string)
connect(): Promise<void>
addBlob(key: string, blob: Uint8Array): Promise<void>
getBlob(key: string): Promise<BlobRow | null>
deleteBlob(key: string): Promise<void>
getBlobKeys(): Promise<Array<string>>
getUpdates(docId?: string | undefined | null): Promise<Array<UpdateRow>>
getDocTimestamps(): Promise<Array<DocTimestampRow>>
deleteUpdates(docId?: string | undefined | null): Promise<void>
getUpdatesCount(docId?: string | undefined | null): Promise<number>
getAllUpdates(): Promise<Array<UpdateRow>>
insertUpdates(updates: Array<InsertRow>): Promise<void>
replaceUpdates(docId: string | undefined | null, updates: Array<InsertRow>): Promise<void>
getServerClock(key: string): Promise<BlobRow | null>
setServerClock(key: string, data: Uint8Array): Promise<void>
getServerClockKeys(): Promise<Array<string>>
clearServerClock(): Promise<void>
delServerClock(key: string): Promise<void>
getSyncMetadata(key: string): Promise<BlobRow | null>
setSyncMetadata(key: string, data: Uint8Array): Promise<void>
getSyncMetadataKeys(): Promise<Array<string>>
clearSyncMetadata(): Promise<void>
delSyncMetadata(key: string): Promise<void>
initVersion(): Promise<void>
setVersion(version: number): Promise<void>
getMaxVersion(): Promise<number>
close(): Promise<void>
get isClose(): boolean
static validate(path: string): Promise<ValidationResult>
validateImportSchema(): Promise<boolean>
migrateAddDocId(): Promise<void>
/** * 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>
vacuumInto(path: string): Promise<void>
}
export interface BlobRow {
key: string
data: Buffer
timestamp: Date
}
export interface DocTimestampRow {
docId?: string
timestamp: Date
}
export interface InsertRow {
docId?: string
data: Uint8Array
}
export interface UpdateRow {
id: number
timestamp: Date
data: Buffer
docId?: string
}
export declare enum ValidationResult {
MissingTables = 0,
MissingDocIdColumn = 1,
MissingVersionColumn = 2,
GeneralError = 3,
Valid = 4
}