import * as v from "@badrap/valita"; import { HTTPError, APIError, type ClientConfig } from "./client.ts"; import { Kv } from "./kv.ts"; import type * as KvTypes from "./kv.ts"; export { HTTPError, APIError }; export declare class UpdateFailed extends Error { constructor(cause: APIError); } type InstallationStatus = "active" | "paused" | "uninstalled"; declare const InstallationStatus: v.Type; type InstallationOwner = { type: "team"; name: string; } | { type: "user"; email: string; }; declare const InstallationOwner: v.Type; export type Installation> = { id: string; state: State; owner?: InstallationOwner; status: InstallationStatus; }; export type Asset = Readonly<{ type: "ip" | "email" | "domain" | "opaque"; value: string; key?: string; props?: Record; }>; export type Event = Readonly<{ type: "ip" | "email" | "domain" | "opaque"; value: string; key?: string; props?: Record; }>; type MaybePromise = Promise | T; interface Config extends ClientConfig { stateType?: v.Type; } export declare class API = Record> { #private; readonly kv: Kv; constructor(config: Config); checkAuthToken(token: string): Promise<{ installationId: string; sessionId: string; expiresAt: number; }>; listInstallations(options?: { status?: InstallationStatus | InstallationStatus[]; }): AsyncIterable<{ id: string; owner?: { type: "team"; name: string; } | { type: "user"; email: string; }; status: InstallationStatus; }>; createInstallationCallback(installationId: string, sessionId: string, callback?: { action?: unknown; clientState?: Record; }): Promise; getInstallation(installationId: string): Promise>; updateInstallation(installationId: string, callback: (installation: Installation) => MaybePromise<{ assets?: Asset[]; state?: InstallationState; } | undefined>, options?: { retry?: false | number; }): Promise>; removeInstallation(installationId: string): Promise; listOwnerAssets(installationId: string): AsyncIterable<{ type: "ip" | "email" | "domain"; value: string; }>; ensureFeed(name: string, config?: { title?: string; summaryTemplate?: unknown; detailsTemplate?: unknown; }): Promise; feedEventsForInstallation(installationId: string, feedName: string, events: Event[]): Promise; } export declare namespace API { type Kv = KvTypes.Kv; type KvKey = KvTypes.KvKey; type KvEntry = KvTypes.KvEntry; type KvEntryMaybe = KvTypes.KvEntryMaybe; type KvCheck = KvTypes.KvCheck; type KvMutation = KvTypes.KvMutation; type KvCommitResult = KvTypes.KvCommitResult; type KvCommitError = KvTypes.KvCommitError; type KvListSelector = KvTypes.KvListSelector; type KvListOptions = KvTypes.KvListOptions; type KvListIterator = KvTypes.KvListIterator; type KvAtomicOperation = KvTypes.KvAtomicOperation; }