import type { Settings } from "@opengeni/config"; import type { SubscriptionCoreConnectionRead } from "@opengeni/subscriptions"; import { type Database } from "../database.js"; import type { SubscriptionCoreConnectionReadRun, SubscriptionCoreUsageProbe } from "./operation-connections.js"; import { type SubscriptionCoreConnectionRefreshDeps, type SubscriptionCoreFetch } from "./operations.js"; import { type SubscriptionCoreProvider } from "./provider.js"; /** Who reads the connection, and in which context. */ export type SubscriptionCoreAdministeredScope = { /** An organization administrator on the organization route (no workspace). */ kind: "organization_administrator"; accountId: string; subjectId: string; } | { /** The owner of a personal connection, in their own Personal workspace. */ kind: "personal_owner"; accountId: string; workspaceId: string; subjectId: string; }; export type SubscriptionCoreAdministeredProbeDeps = { /** * The physical transport (default: global fetch). Anything other than * native fetch must abort and join its local work for a signal * (`SubscriptionCoreAdministeredJoinedFetch`); any other transport is * refused before a credential is loaded. */ fetchImpl?: SubscriptionCoreFetch | SubscriptionCoreAdministeredJoinedFetch; /** As for the workspace probe: the product models the connection can serve. */ modelIds?: readonly string[]; refresh?: SubscriptionCoreConnectionRefreshDeps; }; /** * An injected transport must cancel and join its local work for this exact * signal before the returned promise resolves, as for the organization usage * inspection of the first core provider: the custody transaction awaits it, * so no request outlives the transaction that rechecked its authority. */ export type SubscriptionCoreAdministeredJoinedFetch = SubscriptionCoreFetch & { abortAndJoin: (signal: AbortSignal) => Promise; }; /** * The request deadline, including the locks and recheck before it: on the * organization route (which holds the organization membership lock for the * request) the five seconds of the first core provider's organization * inspection, and ten seconds for an owner's personal read. */ export declare const SUBSCRIPTION_CORE_ADMINISTERED_READ_TIMEOUT_MS: { readonly organization_administrator: 5000; readonly personal_owner: 10000; }; /** Administered connection reads bound to one provider (memoized per binding). */ export declare const subscriptionCoreAdministeredConnections: (provider: SubscriptionCoreProvider) => { probeSubscriptionCoreAdministeredConnectionUsage: (db: Database, settings: Settings, scope: SubscriptionCoreAdministeredScope, connectionId: string, deps?: SubscriptionCoreAdministeredProbeDeps) => Promise; runSubscriptionCoreAdministeredConnectionRead: (db: Database, settings: Settings, scope: SubscriptionCoreAdministeredScope, connectionId: string, run: (read: SubscriptionCoreConnectionRead) => Promise, deps?: SubscriptionCoreAdministeredProbeDeps) => Promise>; };