import { mirrorStub } from "./mirror-do";
import type { MirrorInput } from "./mirror-do";
import type { MirrorStatus, MirrorTrigger } from "~/lib/mirror";
/** Plain-typed wrappers over the RepoMirror RPC stub (results lose the stub's Disposable branding). */
export async function mirrorStatus(repoId: string): Promise<MirrorStatus | null> {
const status: MirrorStatus | null = await mirrorStub(repoId).status();
return status;
}
export async function configureMirror(
repoId: string,
createdBy: string,
input: MirrorInput,
token: string | null | undefined,
): Promise<{ webhookSecret: string | null }> {
const { webhookSecret } = await mirrorStub(repoId).configure(repoId, createdBy, input, token);
return { webhookSecret };
}
export async function requestMirrorSync(
repoId: string,
trigger: MirrorTrigger,
): Promise<{ ok: true; at: number } | { ok: false; reason: string }> {
const result = await mirrorStub(repoId).requestSync(trigger);
return result.ok ? { ok: true, at: result.at } : { ok: false, reason: result.reason };
}
export async function rotateMirrorWebhookSecret(repoId: string): Promise<string | null> {
return mirrorStub(repoId).rotateWebhookSecret();
}
export async function removeMirror(repoId: string): Promise<void> {
await mirrorStub(repoId).remove(repoId);
}