Skip to content
Sarj Workspace Sync

workspace-directory/d1-workspace-ledger-history-index

@sarj-ai/workspace-sync/workspace-directory/d1-workspace-ledger-history-index ยท Source

import type { D1Database } from "@cloudflare/workers-types";
import { z } from "zod";
import { LEDGER_HISTORY_SQL } from "./ledger-history-sql.ts";
declare const ScopeSchema: z.ZodObject<{
teamId: z.ZodString;
channelId: z.ZodString;
botId: z.ZodString;
}, z.core.$strict>;
declare const EntrySchema: z.ZodObject<{
changeKey: z.ZodString;
timestamp: z.ZodString;
}, z.core.$strict>;
declare const PageSchema: z.ZodObject<{
timestamps: z.ZodArray<z.ZodString>;
entries: z.ZodArray<z.ZodObject<{
changeKey: z.ZodString;
timestamp: z.ZodString;
}, z.core.$strict>>;
hasMore: z.ZodBoolean;
}, z.core.$strict>;
export type WorkspaceLedgerHistoryScope = z.output<typeof ScopeSchema>;
export type WorkspaceLedgerHistoryEntry = z.output<typeof EntrySchema>;
export type WorkspaceLedgerHistoryPage = z.output<typeof PageSchema>;
export interface WorkspaceLedgerHistoryBounds {
latest: null | string;
oldest: null | string;
}
export interface WorkspaceLedgerHistoryIndex {
findTimestamp(scope: WorkspaceLedgerHistoryScope, changeKey: string): Promise<null | string>;
record(scope: WorkspaceLedgerHistoryScope, entry: WorkspaceLedgerHistoryEntry): Promise<void>;
synchronize(scope: WorkspaceLedgerHistoryScope, read: (bounds: WorkspaceLedgerHistoryBounds) => Promise<WorkspaceLedgerHistoryPage>): Promise<boolean>;
}
export declare class D1WorkspaceLedgerHistoryIndex implements WorkspaceLedgerHistoryIndex {
#private;
constructor(db: D1Database, ledger?: keyof typeof LEDGER_HISTORY_SQL);
synchronize(input: WorkspaceLedgerHistoryScope, read: (bounds: WorkspaceLedgerHistoryBounds) => Promise<WorkspaceLedgerHistoryPage>): Promise<boolean>;
findTimestamp(input: WorkspaceLedgerHistoryScope, changeKey: string): Promise<null | string>;
record(input: WorkspaceLedgerHistoryScope, rawEntry: WorkspaceLedgerHistoryEntry): Promise<void>;
}
export {};