From 68a749f7afa6d74cb06634703e0ce1fdfcf006bf Mon Sep 17 00:00:00 2001 From: Nora Date: Thu, 25 Jun 2026 17:32:52 -0600 Subject: [PATCH] fix(wholesale): remove internal scope helpers from barrel re-export MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The barrel src/actions/wholesale/index.ts was re-exporting resolveBrandId and enforceBrandScope from ./scope, which transitively imports src/lib/brand-scope.ts ("server-only"). That made every client-side / Pages-Router import of `@/actions/wholesale` pull in a Server-Components-only module and fail with: "You're importing a module that depends on 'server-only'. This API is only available in Server Components in the App Router, but you are using it in the Pages Router." Caught by `npm run build`, surfaced via src/app/wholesale/employee/page.tsx → @/actions/wholesale → scope → brand-scope. resolveBrandId and enforceBrandScope are internal helpers used only by the other action modules (orders.ts, customers.ts, products.ts) via direct `./scope` imports. They were never part of the old wholesale.ts public surface — added to the barrel in commit bd16900 by mistake. Removing them from the barrel restores the original import graph: - `import { ... } from "@/actions/wholesale"` → barrel → only types and action functions, no server-only transitive imports - Action modules still import `./scope` directly (unchanged) Verified: `npm run build` now compiles successfully (fails only on the pre-existing Stripe API version type errors that are unrelated to this refactor). `npx vitest run` still 175/175 passing. --- src/actions/wholesale/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/actions/wholesale/index.ts b/src/actions/wholesale/index.ts index f004db0..8f94ad2 100644 --- a/src/actions/wholesale/index.ts +++ b/src/actions/wholesale/index.ts @@ -9,7 +9,7 @@ * - deposits.ts — deposit recording + bulk actions * - notifications.ts — email/SMS notification queue * - webhooks.ts — outbound webhook settings + dispatch - * - scope.ts — brand-scoping helpers (resolveBrandId, enforceBrandScope) + * - scope.ts — internal brand-scoping helpers (NOT re-exported here) * - types.ts — shared type definitions * * Existing imports of `@/actions/wholesale` keep working. New code should @@ -28,8 +28,6 @@ export type { WebhookSettings, } from "./types"; -export { resolveBrandId, enforceBrandScope } from "./scope"; - export { getWholesaleOrders, getWholesalePickupOrders,