import type { MaybeAsync } from "@welshman/lib"; import type { IEventRef } from "./EventRef.js"; export type RelayRoute = { type: "userInbox"; } | { type: "userOutbox"; } | { type: "userMessaging"; } | { type: "pubkeyInbox"; pubkey: string; } | { type: "pubkeyOutbox"; pubkey: string; } | { type: "pubkeyMessaging"; pubkey: string; } | { type: "eventInbox"; ref: IEventRef; } | { type: "eventOutbox"; ref: IEventRef; } | { type: "seen"; ref: IEventRef; } | { type: "relay"; url: string; } | { type: "index"; } | { type: "search"; }; export type RelaySelection = { route: RelayRoute; weight: number; }; export declare const inbox: (pubkey: string, weight?: number) => RelaySelection; export declare const outbox: (pubkey: string, weight?: number) => RelaySelection; export declare const messaging: (pubkey: string, weight?: number) => RelaySelection; export declare const userInbox: (weight?: number) => RelaySelection; export declare const userOutbox: (weight?: number) => RelaySelection; export declare const userMessaging: (weight?: number) => RelaySelection; export declare const eventInbox: (ref: IEventRef, weight?: number) => RelaySelection; export declare const eventOutbox: (ref: IEventRef, weight?: number) => RelaySelection; export declare const seen: (ref: IEventRef, weight?: number) => RelaySelection; export declare const relay: (url: string, weight?: number) => RelaySelection; export declare const relays: (urls: string[], weight?: number) => RelaySelection[]; export declare const inboxes: (pubkeys: string[], weight?: number) => RelaySelection[]; export declare const indexers: (weight?: number) => RelaySelection; export declare const searchRelays: (weight?: number) => RelaySelection; export type Selection = { weight: number; relays: string[]; }; export declare const makeSelection: (relays: string[], weight?: number) => Selection; export type FallbackPolicy = (count: number, limit: number) => number; export declare const addNoFallbacks: (count: number, limit: number) => number; export declare const addMinimalFallbacks: (count: number, limit: number) => 1 | 0; export declare const addMaximalFallbacks: (count: number, limit: number) => number; export type RelayScenarioOptions = { policy?: FallbackPolicy; limit?: number; allowLocal?: boolean; allowOnion?: boolean; allowInsecure?: boolean; getRelayQuality?: (url: string) => number; getDefaultRelays?: () => string[]; }; export declare class RelayScenario { readonly selections: Selection[]; readonly options: RelayScenarioOptions; constructor(selections: Selection[], options?: RelayScenarioOptions); clone: (options: RelayScenarioOptions) => RelayScenario; limit: (limit: number) => RelayScenario; policy: (policy: FallbackPolicy) => RelayScenario; allowLocal: (allowLocal: boolean) => RelayScenario; allowOnion: (allowOnion: boolean) => RelayScenario; allowInsecure: (allowInsecure: boolean) => RelayScenario; getLimit: () => number; getPolicy: () => (count: number, limit: number) => number; getAllUrls: () => string[]; getUrls: () => string[]; getUrl: () => string | undefined; } export type ResolveRoute = (route: RelayRoute) => MaybeAsync; export type RouteOverrides = { [T in RelayRoute["type"]]?: (route: Extract) => MaybeAsync; }; export declare class Resolver { readonly routeResolver: ResolveRoute; readonly options: RelayScenarioOptions; constructor(routeResolver: ResolveRoute, options?: RelayScenarioOptions); scenario(selections: RelaySelection[]): Promise; relays(selections: RelaySelection[]): Promise; relay(selections: RelaySelection[]): Promise; } //# sourceMappingURL=RelaySelection.d.ts.map