Open History to see the last commit
1import type {
2 ProviderUsageLimitsUpdate,
3 ServerProvider,
4 ServerSettingsError,
5} from "@t3tools/contracts";
6import type * as Effect from "effect/Effect";
7import type * as Stream from "effect/Stream";
8import type { ProviderMaintenanceCapabilities } from "./maintenance.ts";
9
10/** authLabel names the plan, for drivers whose usage report carries it. */
11export type ProviderUsageLimitsReport = ProviderUsageLimitsUpdate & {
12 readonly checkedAt: string;
13 readonly authLabel?: string;
14 /** A full reading replaces sparse windows and clears a previous probe failure. */
15 readonly complete?: boolean;
16};
17
18export interface ManagedServerProvider {
19 /** Cached; pass { fresh: true } before executing updates. */
20 readonly resolveMaintenance: (options?: {
21 readonly fresh?: boolean;
22 }) => Effect.Effect<ProviderMaintenanceCapabilities>;
23 readonly getSnapshot: Effect.Effect<ServerProvider>;
24 /** True while getSnapshot still returns the placeholder from before the first completed check. */
25 readonly isAwaitingFirstCheck?: Effect.Effect<boolean>;
26 readonly refresh: Effect.Effect<ServerProvider>;
27 readonly refreshUsage?: Effect.Effect<void, ServerSettingsError>;
28 readonly streamChanges: Stream.Stream<ServerProvider>;
29 /** Merge windows by ID and set any authLabel; an update with no window leaves the snapshot untouched. */
30 readonly applyUsageLimits: (update: ProviderUsageLimitsReport) => Effect.Effect<void>;
31}