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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user