refactor: reorganize package exports under namespaced paths

- Prefix feature exports with `features/` (auth, admin, provider)
- Prefix shared exports with `shared/` (components, icons, lib, config, logger, rate-limit)
- Add new explicit exports for `shared/logger`, `shared/config`, and `shared/rate-limit`
- Update internal imports to use package self-referencing (`@zen/core/shared/*`) instead of relative paths
This commit is contained in:
2026-04-14 19:57:48 -04:00
parent cee521b0e4
commit 7ef37e3ebd
36 changed files with 103 additions and 91 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
* Exported separately from admin/index.js to avoid bundling
* server-side code (which includes database imports) into client components.
*
* Usage: import { getDashboardStats } from '@zen/core/admin/actions';
* Usage: import { getDashboardStats } from '@zen/core/features/admin/actions';
*/
export { getDashboardStats } from './actions/statsActions.js';
+4 -4
View File
@@ -6,9 +6,9 @@
*
* ```javascript
* // app/(admin)/admin/[...admin]/page.js
* import { protectAdmin } from '@zen/core/admin';
* import { getDashboardStats } from '@zen/core/admin/actions';
* import { AdminPagesClient } from '@zen/core/admin/pages';
* import { protectAdmin } from '@zen/core/features/admin';
* import { getDashboardStats } from '@zen/core/features/admin/actions';
* import { AdminPagesClient } from '@zen/core/features/admin/pages';
*
* export default async function AdminPage({ params }) {
* const { user } = await protectAdmin();
@@ -30,7 +30,7 @@
'use server';
import { query } from '@zen/core/database';
import { fail } from '../../../shared/lib/logger.js';
import { fail } from '@zen/core/shared/logger';
/**
* Get total number of users
+1 -1
View File
@@ -3,7 +3,7 @@
import React from 'react';
import { Menu, Transition } from '@headlessui/react';
import { Fragment } from 'react';
import { ChevronDownIcon } from '../../../shared/Icons.js';
import { ChevronDownIcon } from '@zen/core/shared/icons';
import { useRouter } from 'next/navigation';
import ThemeToggle from './ThemeToggle';
@@ -3,8 +3,8 @@
import React, { useState, useEffect } from 'react';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import * as Icons from '../../../shared/Icons.js';
import { ChevronDownIcon } from '../../../shared/Icons.js';
import * as Icons from '@zen/core/shared/icons';
import { ChevronDownIcon } from '@zen/core/shared/icons';
/**
* Resolve icon name (string) to icon component
+1 -1
View File
@@ -1,7 +1,7 @@
'use client';
import { useState, useEffect } from 'react';
import { Sun01Icon, Moon02Icon, SunCloud02Icon, MoonCloudIcon } from '../../../shared/Icons.js';
import { Sun01Icon, Moon02Icon, SunCloud02Icon, MoonCloudIcon } from '@zen/core/shared/icons';
function getNextTheme(current) {
const systemIsDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
@@ -1,7 +1,7 @@
'use client';
import { StatCard } from '../../../../shared/components';
import { UserMultiple02Icon } from '../../../../shared/Icons.js';
import { StatCard } from '@zen/core/shared/components';
import { UserMultiple02Icon } from '@zen/core/shared/icons';
export default function DashboardPage({ user, stats }) {
const loading = !stats;
@@ -1,7 +1,7 @@
'use client';
import React, { useState, useEffect, useRef } from 'react';
import { Card, Input, Button } from '../../../../shared/components';
import { Card, Input, Button } from '@zen/core/shared/components';
import { useToast } from '@zen/core/toast';
const ProfilePage = ({ user: initialUser }) => {
@@ -2,7 +2,7 @@
import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { Button, Card, Input, Select, Loading } from '../../../../shared/components';
import { Button, Card, Input, Select, Loading } from '@zen/core/shared/components';
import { useToast } from '@zen/core/toast';
/**
@@ -2,8 +2,8 @@
import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { Card, Table, StatusBadge, Pagination, Button } from '../../../../shared/components';
import { PencilEdit01Icon } from '../../../../shared/Icons.js';
import { Card, Table, StatusBadge, Pagination, Button } from '@zen/core/shared/components';
import { PencilEdit01Icon } from '@zen/core/shared/icons';
import { useToast } from '@zen/core/toast';
const UsersPageClient = () => {
+3 -3
View File
@@ -3,7 +3,7 @@
* Utilities to protect admin routes and require admin role
*/
import { getSession } from '../../auth/actions/authActions.js';
import { getSession } from '@zen/core/features/auth/actions';
import { redirect } from 'next/navigation';
/**
@@ -17,7 +17,7 @@ import { redirect } from 'next/navigation';
*
* @example
* // In a server component:
* import { protectAdmin } from '@zen/core/admin';
* import { protectAdmin } from '@zen/core/features/admin';
*
* export default async function AdminPage() {
* const session = await protectAdmin();
@@ -47,7 +47,7 @@ async function protectAdmin(options = {}) {
* @returns {Promise<boolean>} True if user is admin
*
* @example
* import { isAdmin } from '@zen/core/admin';
* import { isAdmin } from '@zen/core/features/admin';
*
* export default async function Page() {
* const admin = await isAdmin();
+6 -6
View File
@@ -2,14 +2,14 @@
* Admin Page - Server Component Wrapper for Next.js App Router
*
* Re-export this in your app/admin/[...admin]/page.js:
* export { default } from '@zen/core/admin/page';
* export { default } from '@zen/core/features/admin/page';
*/
import { AdminPagesLayout, AdminPagesClient } from '@zen/core/admin/pages';
import { protectAdmin } from '@zen/core/admin';
import { buildNavigationSections } from '@zen/core/admin/navigation';
import { getDashboardStats } from '@zen/core/admin/actions';
import { logoutAction } from '@zen/core/auth/actions';
import { AdminPagesLayout, AdminPagesClient } from '@zen/core/features/admin/pages';
import { protectAdmin } from '@zen/core/features/admin';
import { buildNavigationSections } from '@zen/core/features/admin/navigation';
import { getDashboardStats } from '@zen/core/features/admin/actions';
import { logoutAction } from '@zen/core/features/auth/actions';
import { getAppName } from '@zen/core';
export default async function AdminPage({ params }) {