UNPKG

alinea

Version:
32 lines (31 loc) 1.32 kB
import type { ChangesBatch } from './Change.js'; import type { ReadonlyTree } from './Tree.js'; export interface RemoteSource { getTreeIfDifferent(sha: string): Promise<ReadonlyTree | undefined>; getBlobs(shas: Array<string>): AsyncGenerator<[sha: string, blob: Uint8Array]>; } export interface Source extends RemoteSource { getTree(): Promise<ReadonlyTree>; applyChanges(batch: ChangesBatch): Promise<void>; } export declare function bundleContents(source: RemoteSource, batch: ChangesBatch): Promise<ChangesBatch>; export declare function diff(source: Source, remote: RemoteSource): Promise<ChangesBatch>; export declare function syncWith(source: Source, remote: RemoteSource): Promise<ChangesBatch>; export declare function transaction(source: Source): Promise<SourceTransaction>; export declare class SourceTransaction { #private; constructor(source: Source, from: ReadonlyTree); add(path: string, contents: Uint8Array): this; remove(path: string): this; rename(from: string, to: string): this; compile(): Promise<{ from: ReadonlyTree; into: ReadonlyTree; changes: (import("./Change.js").DeleteChange | { contents: Uint8Array | undefined; op: "add"; path: string; sha: string; })[]; }>; }