1import type { ProviderUsageLimitsUpdate, ServerProvider } from "@t3tools/contracts";
2import type * as Effect from "effect/Effect";
3import type * as Stream from "effect/Stream";
4import type { ProviderMaintenanceCapabilities } from "./maintenance.ts";
5
6export interface ManagedServerProvider {
7 /**
8 * Ownership-derived update capabilities. Cached between reads; pass
9 * `{ fresh: true }` before executing an update so it never trusts a
10 * resolution older than the click.
11 */
12 readonly resolveMaintenance: (options?: {
13 readonly fresh?: boolean;
14 }) => Effect.Effect<ProviderMaintenanceCapabilities>;
15 readonly getSnapshot: Effect.Effect<ServerProvider>;
16 readonly refresh: Effect.Effect<ServerProvider>;
17 readonly streamChanges: Stream.Stream<ServerProvider>;
18 /**
19 * Fold a runtime rate-limit update into the published snapshot without
20 * waiting for the next status probe. Sparse: windows merge by id and an
21 * update with no usable window leaves the snapshot untouched.
22 */
23 readonly applyUsageLimits: (
24 update: ProviderUsageLimitsUpdate & { readonly checkedAt: string },
25 ) => Effect.Effect<void>;
26}