From db646c22e43b6a796ad830bc61bbee4799a48efa Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Tue, 12 May 2026 21:46:33 +0200 Subject: [PATCH] feat(auth): bind signIn through ProductionUseCase branded slot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds explicit ProductionUseCase type annotation to wrappedSignIn in bind-production.ts. To satisfy the Instrumented & Captured intersection requirement, withSpan gains a brand-preserving overload so composing withSpan ∘ withCapture returns Instrumented & Captured. Co-Authored-By: Claude Sonnet 4.6 --- packages/auth/src/di/bind-production.ts | 12 +++++++++++- .../core-shared/src/instrumentation/with-span.ts | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/di/bind-production.ts b/packages/auth/src/di/bind-production.ts index 2af12a1..94d5868 100644 --- a/packages/auth/src/di/bind-production.ts +++ b/packages/auth/src/di/bind-production.ts @@ -6,6 +6,12 @@ import { type ILogger, } from "@repo/core-shared/instrumentation"; import type { BindProductionContext } from "@repo/core-shared/di"; +import type { ProductionUseCase } from "@repo/core-shared/conformance"; +import type { AuthManifest } from "../feature.manifest"; +import type { + SignInInput, + SignInOutput, +} from "../application/use-cases/sign-in.use-case"; import { authContainer } from "./container"; import { AUTH_SYMBOLS } from "./symbols"; import { UsersRepository } from "../infrastructure/repositories/users.repository"; @@ -53,7 +59,11 @@ export function bindProductionAuth(ctx: BindProductionContext): void { .toConstantValue(authService); // Use cases — wrapped with span + capture at bind time - const wrappedSignIn = withSpan( + const wrappedSignIn: ProductionUseCase< + SignInInput, + SignInOutput, + AuthManifest["useCases"]["signIn"] + > = withSpan( tracer, { name: "auth.signIn", op: "use-case" }, withCapture( diff --git a/packages/core-shared/src/instrumentation/with-span.ts b/packages/core-shared/src/instrumentation/with-span.ts index eeb6b09..0685b0c 100644 --- a/packages/core-shared/src/instrumentation/with-span.ts +++ b/packages/core-shared/src/instrumentation/with-span.ts @@ -1,6 +1,16 @@ import type { ITracer, SpanOpts } from "./tracer.interface"; import type { Instrumented } from "../conformance/brands"; +export function withSpan( + tracer: ITracer, + opts: SpanOpts | ((args: Args) => SpanOpts), + fn: ((...args: Args) => Promise) & Extra, +): Instrumented<((...args: Args) => Promise) & Extra>; +export function withSpan( + tracer: ITracer, + opts: SpanOpts | ((args: Args) => SpanOpts), + fn: (...args: Args) => Promise, +): Instrumented<(...args: Args) => Promise>; export function withSpan( tracer: ITracer, opts: SpanOpts | ((args: Args) => SpanOpts),