TypeScript
refactor(relay): import HookInboxObject once, as a namespace (#16307)
Julius Marminge8bd7745f0af9
diff --git a/infra/relay/src/hooks/HookInboxObject.ts b/infra/relay/src/hooks/HookInboxObject.tsindex e3ba8dfc39f..d5a9f455c61 100644--- a/infra/relay/src/hooks/HookInboxObject.ts+++ b/infra/relay/src/hooks/HookInboxObject.ts@@ -23,14 +23,6 @@ const RUN_FAILURE_RETRY_MS = 60_000;type Call<A> = Effect.Effect<A, never, Alchemy.RuntimeContext>;-export interface HookInboxObjectShape {- /** Holds a request for `baseUrl`; false when the inbox is full and nothing was stored. */- readonly hold: (hook: HookInboxStore.HeldHook, baseUrl: string) => Call<boolean>;- /** The environment is back at `baseUrl`: deliver what is waiting now. */- readonly wake: (baseUrl: string) => Call<boolean>;- readonly clear: () => Call<void>;-}-/*** One per managed endpoint, addressed by endpoint key. Holds webhook requests* the environment could not take, in SQLite, and pushes them back through@@ -38,7 +30,13 @@ export interface HookInboxObjectShape {*/export class HookInboxObject extends Cloudflare.DurableObject<HookInboxObject,- HookInboxObjectShape+ {+ /** Holds a request for `baseUrl`; false when the inbox is full and nothing was stored. */+ readonly hold: (hook: HookInboxStore.HeldHook, baseUrl: string) => Call<boolean>;+ /** The environment is back at `baseUrl`: deliver what is waiting now. */+ readonly wake: (baseUrl: string) => Call<boolean>;+ readonly clear: () => Call<void>;+ }>()("HookInboxObject") {}/**diff --git a/infra/relay/src/worker.ts b/infra/relay/src/worker.tsindex 42400488136..8a5872fd190 100644--- a/infra/relay/src/worker.ts+++ b/infra/relay/src/worker.ts@@ -67,8 +67,7 @@ import * as MobileRegistrations from "./agentActivity/MobileRegistrations.ts";import * as HookForwarder from "./hooks/HookForwarder.ts";import * as HeldHooks from "./hooks/HeldHooks.ts";import * as HookInbox from "./hooks/HookInbox.ts";-import { HookInboxObject } from "./hooks/HookInboxObject.ts";-import * as HookInboxObjectLayer from "./hooks/HookInboxObject.ts";+import * as HookInboxObject from "./hooks/HookInboxObject.ts";const layerWebcrypto = Layer.succeed(Crypto.Crypto,@@ -201,7 +200,7 @@ export const layer = Api.make(period: HookForwarder.RELAY_HOOK_ENDPOINT_RATE_LIMIT.periodSeconds,},});- const hookInboxes = yield* HookInboxObject;+ const hookInboxes = yield* HookInboxObject.HookInboxObject;//// 3. Runtime layers and app construction@@ -470,7 +469,7 @@ export const layer = Api.make(Layer.provideMerge(Cloudflare.Tunnel.ReadWriteTunnelBinding),Layer.provideMerge(Cloudflare.DNS.ReadWriteDnsHttp),Layer.provideMerge(Cloudflare.Workers.RateLimitBinding),- Layer.provideMerge(HookInboxObjectLayer.layer),+ Layer.provideMerge(HookInboxObject.layer),// The worker runtime opens its own HTTP span around ours. For webhook// paths it would record the raw URL, token included, and adopt the// sender's traceparent, so only our redacted span covers those.