@vireocodedev/sqlite · 0.2.3

@vireocodedev/sqlite/offline

20 public exports generated from the shipped declaration graph.

Showing all 20 exports

export type FetchPage<TRow> = (page: number) => Promise<PageResult<TRow>>;
typeMapRow
export type MapRow<TRow, TSnapshotRow> = (row: TRow) => TSnapshotRow | null;
export type OfflineStatusRuntime = {
    start: () => () => void;
    getSnapshot: () => OfflineStatusSnapshot;
    setHeartbeatEnabled: (enabled: boolean) => void;
    markHeartbeatConnected: () => void;
    markHeartbeatDisconnected: () => void;
    markHeartbeatReceived: (syncInProgress: boolean) => void;
    markBackendUnavailable: () => void;
    markBackendAvailable: () => void;
};
export type OfflineStatusRuntimeOptions = {
    staleAfterMs?: number;
    bootstrapAssumeOnlineMs?: number;
    tickMs?: number;
    now?: () => number;
};
export type OfflineStatusSnapshot = {
    online: boolean;
    heartbeatEnabled: boolean;
    heartbeatConnected: boolean;
    syncInProgress: boolean;
    lastHeartbeatAt: number | null;
};
export type OfflineSyncCommand = {
    commandId: string;
    method: string;
    url: string;
    body: unknown | null;
    headers: Record<string, string>;
    createdAt: number;
};
export type PageResult<TRow> = {
    content: TRow[];
    totalPages: number;
};
export type QueueableRequest = {
    method?: string;
    url: string;
};
export type QueueingPolicyOptions = {
    includeMethods?: string[];
    apiPrefix?: string;
    excludedPrefixes?: string[];
    excludeSearchPosts?: boolean;
};
export type ReplaceSnapshot<TSnapshotRow> = (rows: TSnapshotRow[]) => Promise<void>;
export declare function createOfflineStatusRuntime(options?: OfflineStatusRuntimeOptions): OfflineStatusRuntime;
export declare function extractReplayHeaders(headers: Record<string, unknown> | undefined): Record<string, string>;
export declare function hydratePagedSnapshot<TRow, TSnapshotRow>(args: {
    fetchPage: FetchPage<TRow>;
    mapRow: MapRow<TRow, TSnapshotRow>;
    replaceSnapshot: ReplaceSnapshot<TSnapshotRow>;
}): Promise<{
    rowCount: number;
}>;
export declare function isOfflineQueueableRequest(request: QueueableRequest, options?: QueueingPolicyOptions): boolean;
export declare function normalizeHeaders(input: Record<string, unknown> | undefined): Record<string, string>;
export declare function runOfflineCreateWithTempId<TCreate, TTempId, TEntity extends {
    id: TTempId;
}>(args: {
    input: TCreate;
    allocateTempId: () => TTempId;
    buildLocalEntity: (input: TCreate, tempId: TTempId) => TEntity;
    persistLocal: (entity: TEntity) => Promise<void>;
    enqueue: (input: TCreate, tempId: TTempId) => Promise<void>;
}): Promise<TEntity>;
export declare function runOfflineDelete<TId>(args: {
    id: TId;
    deleteLocal: (id: TId) => Promise<void>;
    enqueue: (id: TId) => Promise<void>;
}): Promise<void>;
export declare function runOfflineUpdate<TInput, TResult>(args: {
    input: TInput;
    persistLocal: (input: TInput) => Promise<void>;
    enqueue: (input: TInput) => Promise<void>;
    buildResult: (input: TInput) => TResult;
}): Promise<TResult>;