From 81a791c5fd4a137fe50bd2e5bef3adb7b4c75530 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Wed, 13 May 2026 18:08:42 +0000 Subject: [PATCH] refactor(navigation): migrate binders to wireUseCase for getHeader Co-Authored-By: Claude Sonnet 4.6 --- coverage/summary.json | 36 ++++++++--------- packages/navigation/src/di/bind-dev-seed.ts | 40 ++++++++----------- packages/navigation/src/di/bind-production.ts | 36 +++++++---------- 3 files changed, 50 insertions(+), 62 deletions(-) diff --git a/coverage/summary.json b/coverage/summary.json index c3ab91d..fbb89e4 100644 --- a/coverage/summary.json +++ b/coverage/summary.json @@ -1,16 +1,16 @@ { - "generatedAt": "2026-05-13T17:59:49.208Z", - "commit": "0867efb", + "generatedAt": "2026-05-13T18:08:34.469Z", + "commit": "57e9d98", "repo": { "statements": 95.86, - "branches": 88.93, + "branches": 88.91, "functions": 100, "lines": 95.86, "counts": { - "lf": 3115, - "lh": 2986, - "brf": 488, - "brh": 434, + "lf": 3113, + "lh": 2984, + "brf": 487, + "brh": 433, "fnf": 142, "fnh": 142 } @@ -45,13 +45,13 @@ } }, "@repo/marketing-pages": { - "statements": 95.66, + "statements": 95.64, "branches": 83.93, "functions": 100, - "lines": 95.66, + "lines": 95.64, "counts": { - "lf": 715, - "lh": 684, + "lf": 711, + "lh": 680, "brf": 112, "brh": 94, "fnf": 32, @@ -73,15 +73,15 @@ } }, "@repo/navigation": { - "statements": 98.05, - "branches": 95.12, + "statements": 98.06, + "branches": 95, "functions": 100, - "lines": 98.05, + "lines": 98.06, "counts": { - "lf": 307, - "lh": 301, - "brf": 41, - "brh": 39, + "lf": 309, + "lh": 303, + "brf": 40, + "brh": 38, "fnf": 13, "fnh": 13 } diff --git a/packages/navigation/src/di/bind-dev-seed.ts b/packages/navigation/src/di/bind-dev-seed.ts index e7b90e7..709e39f 100644 --- a/packages/navigation/src/di/bind-dev-seed.ts +++ b/packages/navigation/src/di/bind-dev-seed.ts @@ -6,7 +6,10 @@ import { type ILogger, } from "@repo/core-shared/instrumentation"; import type { BindContext } from "@repo/core-shared/di"; -import { assertFeatureConformance } from "@repo/core-shared/conformance"; +import { + assertFeatureConformance, + wireUseCase, +} from "@repo/core-shared/conformance"; import { navigationManifest } from "../feature.manifest.js"; import { navigationContainer } from "./container.js"; import { NAVIGATION_SYMBOLS } from "./symbols.js"; @@ -52,31 +55,22 @@ export async function bindDevSeedNavigation(ctx: BindContext): Promise { .bind(NAVIGATION_SYMBOLS.IHeaderRepository) .toConstantValue(repo); - // Wrap use case + controller identically to bind-production - const wrappedGetHeader = withSpan( + // Use case + const wrappedGetHeader = wireUseCase({ + container: navigationContainer, + symbol: NAVIGATION_SYMBOLS.IGetHeaderUseCase, + factory: getHeaderUseCase, + deps: [repo], + feature: "navigation", + layer: "use-case", + name: "getHeader", tracer, - { name: "navigation.getHeader", op: "use-case" }, - withCapture( - logger, - { - feature: "navigation", - layer: "use-case", - name: "navigation.getHeader", - }, - getHeaderUseCase(repo), - ), - ); + logger, + }); - for (const sym of [ - NAVIGATION_SYMBOLS.IGetHeaderUseCase, - NAVIGATION_SYMBOLS.IGetHeaderController, - ]) { - if (navigationContainer.isBound(sym)) navigationContainer.unbind(sym); + if (navigationContainer.isBound(NAVIGATION_SYMBOLS.IGetHeaderController)) { + navigationContainer.unbind(NAVIGATION_SYMBOLS.IGetHeaderController); } - navigationContainer - .bind(NAVIGATION_SYMBOLS.IGetHeaderUseCase) - .toConstantValue(wrappedGetHeader); - navigationContainer .bind(NAVIGATION_SYMBOLS.IGetHeaderController) .toConstantValue( diff --git a/packages/navigation/src/di/bind-production.ts b/packages/navigation/src/di/bind-production.ts index 54f57c4..e3a769a 100644 --- a/packages/navigation/src/di/bind-production.ts +++ b/packages/navigation/src/di/bind-production.ts @@ -6,7 +6,10 @@ import { type ILogger, } from "@repo/core-shared/instrumentation"; import type { BindProductionContext } from "@repo/core-shared/di"; -import { assertFeatureConformance } from "@repo/core-shared/conformance"; +import { + assertFeatureConformance, + wireUseCase, +} from "@repo/core-shared/conformance"; import { navigationContainer } from "./container"; import { NAVIGATION_SYMBOLS } from "./symbols"; import { navigationManifest } from "../feature.manifest"; @@ -41,27 +44,18 @@ export function bindProductionNavigation(ctx: BindProductionContext): void { .bind(NAVIGATION_SYMBOLS.IHeaderRepository) .toConstantValue(repo); - // Use case — wrapped with span + capture at bind time - const wrappedGetHeader = withSpan( + // Use case + const wrappedGetHeader = wireUseCase({ + container: navigationContainer, + symbol: NAVIGATION_SYMBOLS.IGetHeaderUseCase, + factory: getHeaderUseCase, + deps: [repo], + feature: "navigation", + layer: "use-case", + name: "getHeader", tracer, - { name: "navigation.getHeader", op: "use-case" }, - withCapture( - logger, - { - feature: "navigation", - layer: "use-case", - name: "navigation.getHeader", - }, - getHeaderUseCase(repo), - ), - ); - - if (navigationContainer.isBound(NAVIGATION_SYMBOLS.IGetHeaderUseCase)) { - navigationContainer.unbind(NAVIGATION_SYMBOLS.IGetHeaderUseCase); - } - navigationContainer - .bind(NAVIGATION_SYMBOLS.IGetHeaderUseCase) - .toConstantValue(wrappedGetHeader); + logger, + }); // Controller — wrapped with span at bind time if (navigationContainer.isBound(NAVIGATION_SYMBOLS.IGetHeaderController)) {