fix(wholesale): remove internal scope helpers from barrel re-export

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.
This commit is contained in:
Nora
2026-06-25 17:32:52 -06:00
parent d69b892117
commit 68a749f7af
+1 -3
View File
@@ -9,7 +9,7 @@
* - deposits.ts — deposit recording + bulk actions * - deposits.ts — deposit recording + bulk actions
* - notifications.ts — email/SMS notification queue * - notifications.ts — email/SMS notification queue
* - webhooks.ts — outbound webhook settings + dispatch * - 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 * - types.ts — shared type definitions
* *
* Existing imports of `@/actions/wholesale` keep working. New code should * Existing imports of `@/actions/wholesale` keep working. New code should
@@ -28,8 +28,6 @@ export type {
WebhookSettings, WebhookSettings,
} from "./types"; } from "./types";
export { resolveBrandId, enforceBrandScope } from "./scope";
export { export {
getWholesaleOrders, getWholesaleOrders,
getWholesalePickupOrders, getWholesalePickupOrders,