chore: rename package from @hykocx/zen to @zen/core

Update all references across source files, documentation, and
configuration to reflect the new package scope and name. This includes
updating `.npmrc` registry config, install instructions, module
examples, and all import path comments throughout the codebase.
This commit is contained in:
2026-04-12 15:09:26 -04:00
parent 30067a699d
commit 81172bda94
52 changed files with 153 additions and 153 deletions
+1 -1
View File
@@ -1 +1 @@
@hykocx:registry=https://git.hyko.cx/api/packages/hykocx/npm/
@zen:registry=https://git.hyko.cx/api/packages/zen/npm/
+1 -1
View File
@@ -1,6 +1,6 @@
# zen
Un CMS construit sur l'essentiel, rien de plus, rien de moins.
Un CMS Next.js construit sur l'essentiel, rien de plus, rien de moins.
> [!WARNING]
> Ce projet est en développement actif et n'est pas encore prêt pour une utilisation en production. L'API, la structure et les fonctionnalités peuvent changer à tout moment.
+3 -3
View File
@@ -11,7 +11,7 @@ Créer un fichier `.npmrc` à la racine du projet avec le contenu suivant :
## 2. Installer le package
```bash
npm install @hykocx/zen
npm install @zen/core
```
## 3. Installer les styles
@@ -19,7 +19,7 @@ npm install @hykocx/zen
Ajouter la ligne suivante dans le fichier `globals.css` :
```css
@import '@hykocx/zen/styles/zen.css';
@import '@zen/core/styles/zen.css';
```
## 4. Ajouter ZenProvider au layout racine
@@ -29,7 +29,7 @@ Entourer l'application avec `ZenProvider` dans le layout racine pour activer les
```javascript
// app/layout.js
import './globals.css';
import { ZenProvider } from '@hykocx/zen/provider';
import { ZenProvider } from '@zen/core/provider';
export const metadata = {
title: 'My App',
+1 -1
View File
@@ -2,7 +2,7 @@
## Publier le package
Le package `@hykocx/zen` est publié sur le registre npm à `https://git.hyko.cx`.
Le package `@zen/core` est publié sur le registre npm à `https://git.hyko.cx`.
### 1. Configurer l'authentification
+10 -10
View File
@@ -1,6 +1,6 @@
# Créer un module externe
Un module externe est un package npm indépendant qui s'intègre dans une app qui utilise `@hykocx/zen`. Il n'a pas besoin de modifier le code source du CMS.
Un module externe est un package npm indépendant qui s'intègre dans une app qui utilise `@zen/core`. Il n'a pas besoin de modifier le code source du CMS.
---
@@ -10,7 +10,7 @@ Un module externe est un package npm indépendant qui s'intègre dans une app qu
@scope/zen-nom-du-module
```
Exemples : `@hykocx/zen-invoice`, `@hykocx/zen-nuage`.
Exemples : `@zen/core-invoice`, `@zen/core-nuage`.
---
@@ -34,11 +34,11 @@ zen-invoice/
## index.js
On utilise `defineModule()` importé depuis `@hykocx/zen/modules/define`.
On utilise `defineModule()` importé depuis `@zen/core/modules/define`.
```js
import { lazy } from 'react';
import { defineModule } from '@hykocx/zen/modules/define';
import { defineModule } from '@zen/core/modules/define';
import { createTables, dropTables } from './db.js';
import { getInvoiceByToken } from './actions.js';
@@ -149,7 +149,7 @@ async setup(ctx) {
```json
{
"name": "@hykocx/zen-invoice",
"name": "@zen/core-invoice",
"version": "1.0.0",
"type": "module",
"main": "./index.js",
@@ -157,7 +157,7 @@ async setup(ctx) {
".": "./index.js"
},
"peerDependencies": {
"@hykocx/zen": ">=1.0.0",
"@zen/core": ">=1.0.0",
"react": ">=19.0.0"
}
}
@@ -170,14 +170,14 @@ async setup(ctx) {
### 1. Installer le package
```bash
npm install @hykocx/zen-invoice
npm install @zen/core-invoice
```
### 2. Créer zen.config.js à la racine de l'app
```js
// zen.config.js
import invoiceModule from '@hykocx/zen-invoice';
import invoiceModule from '@zen/core-invoice';
export default {
modules: [invoiceModule],
@@ -192,7 +192,7 @@ import zenConfig from './zen.config.js';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const { initializeZen } = await import('@hykocx/zen');
const { initializeZen } = await import('@zen/core');
await initializeZen(zenConfig);
}
}
@@ -203,7 +203,7 @@ export async function register() {
```jsx
// app/layout.js
import zenConfig from './zen.config.js';
import { ZenProvider } from '@hykocx/zen/provider';
import { ZenProvider } from '@zen/core/provider';
export default function RootLayout({ children }) {
return (
+1 -1
View File
@@ -1,6 +1,6 @@
# Créer un module interne
Un module interne vit dans `src/modules/` et fait partie du package `@hykocx/zen`. Il a accès direct aux services du CMS sans passer par un contexte injecté.
Un module interne vit dans `src/modules/` et fait partie du package `@zen/core`. Il a accès direct aux services du CMS sans passer par un contexte injecté.
---
+4 -4
View File
@@ -1,12 +1,12 @@
{
"name": "@hykocx/zen",
"version": "1.3.2",
"name": "@zen/core",
"version": "1.3.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@hykocx/zen",
"version": "1.3.2",
"name": "@zen/core",
"version": "1.3.3",
"license": "GPL-3.0-only",
"dependencies": {
"@headlessui/react": "^2.0.0",
+4 -4
View File
@@ -1,13 +1,13 @@
{
"name": "@hykocx/zen",
"version": "1.3.2",
"name": "@zen/core",
"version": "1.3.3",
"description": "Un CMS construit sur l'essentiel, rien de plus, rien de moins.",
"repository": {
"type": "git",
"url": "https://git.hyko.cx/hykocx/zen.git"
"url": "https://git.hyko.cx/zen/core.git"
},
"publishConfig": {
"registry": "https://git.hyko.cx/api/packages/hykocx/npm/"
"registry": "https://git.hyko.cx/api/packages/zen/npm/"
},
"license": "GPL-3.0-only",
"author": "Hyko",
+6 -6
View File
@@ -15,7 +15,7 @@ const templates = {
instrumentation: `// instrumentation.js
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
const { initializeZen } = await import('@hykocx/zen');
const { initializeZen } = await import('@zen/core');
await initializeZen();
}
}
@@ -26,7 +26,7 @@ export default function Redirect() {
redirect('/auth/login/');
}
`,
authCatchAll: `export { default } from '@hykocx/zen/auth/page';
authCatchAll: `export { default } from '@zen/core/auth/page';
`,
adminRedirect: `import { redirect } from 'next/navigation';
@@ -34,11 +34,11 @@ export default function Redirect() {
redirect('/admin/dashboard');
}
`,
adminCatchAll: `export { default } from '@hykocx/zen/admin/page';
adminCatchAll: `export { default } from '@zen/core/admin/page';
`,
zenApiRoute: `export { GET, POST, PUT, DELETE, PATCH } from '@hykocx/zen/zen/api';
zenApiRoute: `export { GET, POST, PUT, DELETE, PATCH } from '@zen/core/zen/api';
`,
zenPageRoute: `export { default, generateMetadata } from '@hykocx/zen/modules/page';
zenPageRoute: `export { default, generateMetadata } from '@zen/core/modules/page';
`,
nextConfig: `// next.config.js
module.exports = {
@@ -144,7 +144,7 @@ async function setupZen(options = {}) {
console.log('\n🎉 Setup complete!');
console.log('\nNext steps:');
console.log(' 1. Add Zen styles to your globals.css:');
console.log(' @import \'@hykocx/zen/styles/zen.css\';');
console.log(' @import \'@zen/core/styles/zen.css\';');
console.log(' 2. Configure environment variables (see .env.example)');
console.log(' 3. Initialize the database:');
console.log(' npx zen-db init');
+1 -1
View File
@@ -6,7 +6,7 @@
import { validateSession } from '../../../features/auth/lib/session.js';
import { cookies } from 'next/headers';
import { getSessionCookieName } from '../../../shared/lib/appConfig.js';
import { getFile } from '@hykocx/zen/storage';
import { getFile } from '@zen/core/storage';
// Get cookie name from environment or use default
const COOKIE_NAME = getSessionCookieName();
+2 -2
View File
@@ -5,10 +5,10 @@
import { validateSession } from '../../../features/auth/lib/session.js';
import { cookies } from 'next/headers';
import { query, updateById } from '@hykocx/zen/database';
import { query, updateById } from '@zen/core/database';
import { getSessionCookieName } from '../../../shared/lib/appConfig.js';
import { updateUser } from '../../../features/auth/lib/auth.js';
import { uploadImage, deleteFile, generateUniqueFilename, generateUserFilePath, FILE_TYPE_PRESETS, FILE_SIZE_LIMITS, validateUpload } from '@hykocx/zen/storage';
import { uploadImage, deleteFile, generateUniqueFilename, generateUserFilePath, FILE_TYPE_PRESETS, FILE_SIZE_LIMITS, validateUpload } from '@zen/core/storage';
// Get cookie name from environment or use default
const COOKIE_NAME = getSessionCookieName();
+2 -2
View File
@@ -2,7 +2,7 @@
* Zen API Module
*
* This module exports API utilities for custom handlers
* For route setup, import from '@hykocx/zen/zen/api'
* For route setup, import from '@zen/core/zen/api'
*/
// Export router utilities (for custom handlers)
@@ -18,4 +18,4 @@ export {
} from './handlers/users.js';
// Module API handlers are now self-contained in their respective modules
// e.g., invoice handlers are in @hykocx/zen/modules/invoice/api
// e.g., invoice handlers are in @zen/core/modules/invoice/api
+1 -1
View File
@@ -3,7 +3,7 @@
* Wrapper around node-cron for scheduling tasks
*
* Usage in modules:
* import { schedule, validate } from '@hykocx/zen/cron';
* import { schedule, validate } from '@zen/core/cron';
*/
import cron from 'node-cron';
+1 -1
View File
@@ -29,4 +29,4 @@ export {
// NOTE: getModulePublicPages is NOT exported here because it relies on the
// server-side registry which is empty on the client. Use getModulePublicPageLoader()
// from '@hykocx/zen/modules/pages' instead for client-side public page loading.
// from '@zen/core/modules/pages' instead for client-side public page loading.
+1 -1
View File
@@ -3,7 +3,7 @@
* Generic Stripe integration for payment processing
*
* Usage in modules:
* import { createCheckoutSession, isEnabled } from '@hykocx/zen/stripe';
* import { createCheckoutSession, isEnabled } from '@zen/core/stripe';
*/
/**
+1 -1
View File
@@ -3,7 +3,7 @@
* Wrapper around @react-pdf/renderer for PDF generation
*
* Usage in modules:
* import { renderToBuffer } from '@hykocx/zen/pdf';
* import { renderToBuffer } from '@zen/core/pdf';
*/
import { renderToBuffer as reactPdfRenderToBuffer } from '@react-pdf/renderer';
+2 -2
View File
@@ -5,8 +5,8 @@
* server-side code (which includes database imports) into client components.
*
* Usage:
* import { getDashboardStats, getModuleDashboardStats } from '@hykocx/zen/admin/actions';
* import { getDashboardStats, getModuleDashboardStats } from '@zen/core/admin/actions';
*/
export { getDashboardStats } from './actions/statsActions.js';
export { getAllModuleDashboardStats as getModuleDashboardStats } from '@hykocx/zen/modules/actions';
export { getAllModuleDashboardStats as getModuleDashboardStats } from '@zen/core/modules/actions';
+4 -4
View File
@@ -9,9 +9,9 @@
*
* ```javascript
* // app/(admin)/admin/[...admin]/page.js
* import { protectAdmin } from '@hykocx/zen/admin';
* import { getDashboardStats, getModuleDashboardStats } from '@hykocx/zen/admin/actions';
* import { AdminPagesClient } from '@hykocx/zen/admin/pages';
* import { protectAdmin } from '@zen/core/admin';
* import { getDashboardStats, getModuleDashboardStats } from '@zen/core/admin/actions';
* import { AdminPagesClient } from '@zen/core/admin/pages';
*
* export default async function AdminPage({ params }) {
* const { user } = await protectAdmin();
@@ -37,7 +37,7 @@
'use server';
import { query } from '@hykocx/zen/database';
import { query } from '@zen/core/database';
/**
* Get total number of users
@@ -2,7 +2,7 @@
import React, { useState, useEffect, useRef } from 'react';
import { Card, Input, Button } from '../../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
const ProfilePage = ({ user: initialUser }) => {
const toast = useToast();
@@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { Button, Card, Input, Select, Loading } from '../../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
/**
* User Edit Page Component
@@ -4,7 +4,7 @@ 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 { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
const UsersPageClient = () => {
const router = useRouter();
+2 -2
View File
@@ -9,8 +9,8 @@ export { protectAdmin, isAdmin } from './middleware/protect.js';
// Component exports (for catch-all routes)
export { AdminPagesClient, AdminPagesLayout } from './pages.js';
// NOTE: Server-only navigation builder is in '@hykocx/zen/admin/navigation'
// NOTE: Server-only navigation builder is in '@zen/core/admin/navigation'
// Do NOT import from this file to avoid bundling database code into client
// NOTE: Admin server actions are exported separately to avoid bundling issues
// Import them from '@hykocx/zen/admin/actions' instead
// Import them from '@zen/core/admin/actions' instead
+2 -2
View File
@@ -17,7 +17,7 @@ import { redirect } from 'next/navigation';
*
* @example
* // In a server component:
* import { protectAdmin } from '@hykocx/zen/admin';
* import { protectAdmin } from '@zen/core/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 '@hykocx/zen/admin';
* import { isAdmin } from '@zen/core/admin';
*
* export default async function Page() {
* const admin = await isAdmin();
+3 -3
View File
@@ -7,16 +7,16 @@
* IMPORTANT: This file is NOT bundled to ensure it shares the same registry instance
* that was populated during module discovery.
*
* IMPORTANT: We import from '@hykocx/zen' (main package) to use the same registry
* IMPORTANT: We import from '@zen/core' (main package) to use the same registry
* instance that was populated during initializeZen(). DO NOT import from
* '@hykocx/zen/core/modules' as that's a separate bundle with its own registry.
* '@zen/core/core/modules' as that's a separate bundle with its own registry.
*
* IMPORTANT: Navigation data must be serializable (no functions/components).
* Icons are passed as string names and resolved on the client.
*/
// Import from the main package to use the same registry as discovery
import { moduleSystem } from '@hykocx/zen';
import { moduleSystem } from '@zen/core';
const { getAllAdminNavigation } = moduleSystem;
/**
+7 -7
View File
@@ -5,18 +5,18 @@
* Users can simply re-export this in their app/admin/[...admin]/page.js:
*
* ```javascript
* export { default } from '@hykocx/zen/admin/page';
* export { default } from '@zen/core/admin/page';
* ```
*
* This eliminates the need to manually import and pass all actions and props.
*/
import { AdminPagesLayout, AdminPagesClient } from '@hykocx/zen/admin/pages';
import { protectAdmin } from '@hykocx/zen/admin';
import { buildNavigationSections } from '@hykocx/zen/admin/navigation';
import { getDashboardStats, getModuleDashboardStats } from '@hykocx/zen/admin/actions';
import { logoutAction } from '@hykocx/zen/auth/actions';
import { getAppName, getModulesConfig, getAppConfig, moduleSystem } from '@hykocx/zen';
import { AdminPagesLayout, AdminPagesClient } from '@zen/core/admin/pages';
import { protectAdmin } from '@zen/core/admin';
import { buildNavigationSections } from '@zen/core/admin/navigation';
import { getDashboardStats, getModuleDashboardStats } from '@zen/core/admin/actions';
import { logoutAction } from '@zen/core/auth/actions';
import { getAppName, getModulesConfig, getAppConfig, moduleSystem } from '@zen/core';
const { getAdminPage } = moduleSystem;
+17 -17
View File
@@ -15,8 +15,8 @@ You can use a **custom page for every auth flow**:
| Confirm email | `ConfirmEmailPage` | `verifyEmailAction` |
| Logout | `LogoutPage` | `logoutAction`, `setSessionCookie` |
- **Components**: from `@hykocx/zen/auth/components`
- **Actions**: from `@hykocx/zen/auth/actions`
- **Components**: from `@zen/core/auth/components`
- **Actions**: from `@zen/core/auth/actions`
Create your own routes (e.g. `/login`, `/register`, `/auth/forgot`) and wrap Zens components in your layout. Each page follows the same pattern: a **server component** that loads data and passes actions, and a **client wrapper** that handles navigation and renders the Zen component.
@@ -58,7 +58,7 @@ Use this when wiring each custom page.
**Server:** `app/login/page.js` (or `app/auth/login/page.js`)
```js
import { getSession, loginAction, setSessionCookie } from '@hykocx/zen/auth/actions';
import { getSession, loginAction, setSessionCookie } from '@zen/core/auth/actions';
import { LoginPageWrapper } from './LoginPageWrapper';
export default async function LoginRoute() {
@@ -81,7 +81,7 @@ export default async function LoginRoute() {
'use client';
import { useRouter } from 'next/navigation';
import { LoginPage } from '@hykocx/zen/auth/components';
import { LoginPage } from '@zen/core/auth/components';
export function LoginPageWrapper({ loginAction, setSessionCookie, currentUser }) {
const router = useRouter();
@@ -104,7 +104,7 @@ export function LoginPageWrapper({ loginAction, setSessionCookie, currentUser })
**Server:** `app/register/page.js`
```js
import { getSession, registerAction } from '@hykocx/zen/auth/actions';
import { getSession, registerAction } from '@zen/core/auth/actions';
import { RegisterPageWrapper } from './RegisterPageWrapper';
export default async function RegisterRoute() {
@@ -126,7 +126,7 @@ export default async function RegisterRoute() {
'use client';
import { useRouter } from 'next/navigation';
import { RegisterPage } from '@hykocx/zen/auth/components';
import { RegisterPage } from '@zen/core/auth/components';
export function RegisterPageWrapper({ registerAction, currentUser }) {
const router = useRouter();
@@ -147,7 +147,7 @@ export function RegisterPageWrapper({ registerAction, currentUser }) {
**Server:** `app/forgot/page.js`
```js
import { getSession, forgotPasswordAction } from '@hykocx/zen/auth/actions';
import { getSession, forgotPasswordAction } from '@zen/core/auth/actions';
import { ForgotPasswordPageWrapper } from './ForgotPasswordPageWrapper';
export default async function ForgotRoute() {
@@ -169,7 +169,7 @@ export default async function ForgotRoute() {
'use client';
import { useRouter } from 'next/navigation';
import { ForgotPasswordPage } from '@hykocx/zen/auth/components';
import { ForgotPasswordPage } from '@zen/core/auth/components';
export function ForgotPasswordPageWrapper({ forgotPasswordAction, currentUser }) {
const router = useRouter();
@@ -192,7 +192,7 @@ Requires `email` and `token` from the reset link (e.g. `/auth/reset?email=...&to
**Server:** `app/auth/reset/page.js` (or `app/reset/page.js` with dynamic segment if needed)
```js
import { resetPasswordAction } from '@hykocx/zen/auth/actions';
import { resetPasswordAction } from '@zen/core/auth/actions';
import { ResetPasswordPageWrapper } from './ResetPasswordPageWrapper';
export default async function ResetRoute({ searchParams }) {
@@ -217,7 +217,7 @@ export default async function ResetRoute({ searchParams }) {
'use client';
import { useRouter } from 'next/navigation';
import { ResetPasswordPage } from '@hykocx/zen/auth/components';
import { ResetPasswordPage } from '@zen/core/auth/components';
export function ResetPasswordPageWrapper({ resetPasswordAction, email, token }) {
const router = useRouter();
@@ -241,7 +241,7 @@ Requires `email` and `token` from the verification link (e.g. `/auth/confirm?ema
**Server:** `app/auth/confirm/page.js`
```js
import { verifyEmailAction } from '@hykocx/zen/auth/actions';
import { verifyEmailAction } from '@zen/core/auth/actions';
import { ConfirmEmailPageWrapper } from './ConfirmEmailPageWrapper';
export default async function ConfirmRoute({ searchParams }) {
@@ -266,7 +266,7 @@ export default async function ConfirmRoute({ searchParams }) {
'use client';
import { useRouter } from 'next/navigation';
import { ConfirmEmailPage } from '@hykocx/zen/auth/components';
import { ConfirmEmailPage } from '@zen/core/auth/components';
export function ConfirmEmailPageWrapper({ verifyEmailAction, email, token }) {
const router = useRouter();
@@ -288,7 +288,7 @@ export function ConfirmEmailPageWrapper({ verifyEmailAction, email, token }) {
**Server:** `app/auth/logout/page.js`
```js
import { logoutAction, setSessionCookie } from '@hykocx/zen/auth/actions';
import { logoutAction, setSessionCookie } from '@zen/core/auth/actions';
import { LogoutPageWrapper } from './LogoutPageWrapper';
export default function LogoutRoute() {
@@ -308,7 +308,7 @@ export default function LogoutRoute() {
```js
'use client';
import { LogoutPage } from '@hykocx/zen/auth/components';
import { LogoutPage } from '@zen/core/auth/components';
export function LogoutPageWrapper({ logoutAction, setSessionCookie }) {
return (
@@ -324,10 +324,10 @@ export function LogoutPageWrapper({ logoutAction, setSessionCookie }) {
## Protecting routes
Use `protect()` from `@hykocx/zen/auth` and set `redirectTo` to your custom login path:
Use `protect()` from `@zen/core/auth` and set `redirectTo` to your custom login path:
```js
import { protect } from '@hykocx/zen/auth';
import { protect } from '@zen/core/auth';
export const middleware = protect({ redirectTo: '/login' });
```
@@ -341,7 +341,7 @@ So unauthenticated users are sent to your custom login page.
If you dont need a custom layout, keep using the built-in auth UI. In `app/auth/[...auth]/page.js`:
```js
export { default } from '@hykocx/zen/auth/page';
export { default } from '@zen/core/auth/page';
```
This serves login, register, forgot, reset, confirm, and logout under `/auth/*` with the default styling.
+20 -20
View File
@@ -7,11 +7,11 @@ This guide explains how to build a **client dashboard** in your Next.js app usin
| Need | Solution |
|------|----------|
| Require login on a page | `protect()` in a **server component** redirects to login if not authenticated |
| Get current user on server | `getSession()` from `@hykocx/zen/auth/actions` |
| Check auth without redirect | `checkAuth()` from `@hykocx/zen/auth` |
| Require a role | `requireRole(['admin', 'manager'])` from `@hykocx/zen/auth` |
| Show user in client (header/nav) | `UserMenu` or `UserAvatar` + `useCurrentUser` from `@hykocx/zen/auth/components` |
| Edit account (name + avatar) | `AccountSection` from `@hykocx/zen/auth/components` |
| Get current user on server | `getSession()` from `@zen/core/auth/actions` |
| Check auth without redirect | `checkAuth()` from `@zen/core/auth` |
| Require a role | `requireRole(['admin', 'manager'])` from `@zen/core/auth` |
| Show user in client (header/nav) | `UserMenu` or `UserAvatar` + `useCurrentUser` from `@zen/core/auth/components` |
| Edit account (name + avatar) | `AccountSection` from `@zen/core/auth/components` |
| Call user API from client | `GET /zen/api/users/me`, `PUT /zen/api/users/profile`, `POST/DELETE /zen/api/users/profile/picture` (with `credentials: 'include'`) |
All user APIs are **session-based**: the session cookie is read on the server. No token in client code. Avatar and profile updates are scoped to the current user; the API validates the session on every request.
@@ -24,7 +24,7 @@ Use `protect()` in a **server component**. If there is no valid session, the use
```js
// app/dashboard/page.js (Server Component)
import { protect } from '@hykocx/zen/auth';
import { protect } from '@zen/core/auth';
import { DashboardClient } from './DashboardClient';
export default async function DashboardPage() {
@@ -52,8 +52,8 @@ In your layout or header (server component), get the session and pass `user` to
```js
// app/layout.js or app/dashboard/layout.js
import { getSession } from '@hykocx/zen/auth/actions';
import { UserMenu } from '@hykocx/zen/auth/components';
import { getSession } from '@zen/core/auth/actions';
import { UserMenu } from '@zen/core/auth/components';
export default async function Layout({ children }) {
const session = await getSession();
@@ -80,7 +80,7 @@ If you prefer not to pass user from the server, use the hook in a client compone
```js
'use client';
import { UserMenu } from '@hykocx/zen/auth/components';
import { UserMenu } from '@zen/core/auth/components';
export function Header() {
return (
@@ -115,8 +115,8 @@ Use **`AccountSection`** on a page that is already protected (e.g. `/dashboard/a
```js
// app/dashboard/account/page.js
import { protect } from '@hykocx/zen/auth';
import { AccountSection } from '@hykocx/zen/auth/components';
import { protect } from '@zen/core/auth';
import { AccountSection } from '@zen/core/auth/components';
export default async function AccountPage() {
const session = await protect({ redirectTo: '/auth/login' });
@@ -139,7 +139,7 @@ export default async function AccountPage() {
- `POST /zen/api/users/profile/picture` for upload
- `DELETE /zen/api/users/profile/picture` for remove
All with `credentials: 'include'` (session cookie). Ensure your app uses **ToastProvider** (from `@hykocx/zen/toast`) if you want toasts.
All with `credentials: 'include'` (session cookie). Ensure your app uses **ToastProvider** (from `@zen/core/toast`) if you want toasts.
---
@@ -148,7 +148,7 @@ All with `credentials: 'include'` (session cookie). Ensure your app uses **Toast
Use **`checkAuth()`** in a server component when you only need to know whether someone is logged in:
```js
import { checkAuth } from '@hykocx/zen/auth';
import { checkAuth } from '@zen/core/auth';
export default async function Page() {
const session = await checkAuth();
@@ -159,7 +159,7 @@ export default async function Page() {
Use **`requireRole()`** when a page is only for certain roles:
```js
import { requireRole } from '@hykocx/zen/auth';
import { requireRole } from '@zen/core/auth';
export default async function ManagerPage() {
const session = await requireRole(['admin', 'manager'], {
@@ -201,8 +201,8 @@ app/
**dashboard/layout.js:**
```js
import { protect } from '@hykocx/zen/auth';
import { UserMenu } from '@hykocx/zen/auth/components';
import { protect } from '@zen/core/auth';
import { UserMenu } from '@zen/core/auth/components';
import Link from 'next/link';
export default async function DashboardLayout({ children }) {
@@ -227,7 +227,7 @@ export default async function DashboardLayout({ children }) {
**dashboard/page.js:**
```js
import { protect } from '@hykocx/zen/auth';
import { protect } from '@zen/core/auth';
export default async function DashboardPage() {
const session = await protect({ redirectTo: '/auth/login' });
@@ -244,8 +244,8 @@ export default async function DashboardPage() {
**dashboard/account/page.js:**
```js
import { protect } from '@hykocx/zen/auth';
import { AccountSection } from '@hykocx/zen/auth/components';
import { protect } from '@zen/core/auth';
import { AccountSection } from '@zen/core/auth/components';
export default async function AccountPage() {
const session = await protect({ redirectTo: '/auth/login' });
@@ -269,6 +269,6 @@ If you use the **Invoice** module and want logged-in users to see their own invo
- **Userclient link**: In the admin, link a user to a client (User edit → Client). Only invoices for that client are shown.
- **API**: `GET /zen/api/invoices/me` (session required) returns the current users linked client and that clients invoices.
- **Component**: Use `ClientInvoicesSection` from `@hykocx/zen/invoice/dashboard` on a protected page (e.g. `/dashboard/invoices`).
- **Component**: Use `ClientInvoicesSection` from `@zen/core/invoice/dashboard` on a protected page (e.g. `/dashboard/invoices`).
See the [Invoice module dashboard guide](../../modules/invoice/README-dashboard.md) for the full setup (API details, page example, linking users to clients, and security).
@@ -11,7 +11,7 @@
import React, { useState, useEffect, useRef } from 'react';
import { Card, Input, Button } from '../../../shared/components/index.js';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
import { useCurrentUser } from './useCurrentUser.js';
import UserAvatar from './UserAvatar.js';
+3 -3
View File
@@ -3,8 +3,8 @@
*
* Use these components to build custom auth pages for every flow (login, register, forgot,
* reset, confirm, logout) so they match your site's style.
* For a ready-made catch-all auth UI, use AuthPagesClient from '@hykocx/zen/auth/pages'.
* For the default full-page auth (no custom layout), re-export from '@hykocx/zen/auth/page'.
* For a ready-made catch-all auth UI, use AuthPagesClient from '@zen/core/auth/pages'.
* For the default full-page auth (no custom layout), re-export from '@zen/core/auth/page'.
*
* --- Custom auth pages (all types) ---
*
@@ -21,7 +21,7 @@
*
* onNavigate receives 'login' | 'register' | 'forgot' | 'reset'. Map to your routes (e.g. /auth/${page}).
* For reset/confirm, pass email and token from searchParams. Full guide: see README-custom-login.md in this package.
* Protect routes with protect() from '@hykocx/zen/auth', redirectTo your login path.
* Protect routes with protect() from '@zen/core/auth', redirectTo your login path.
*
* --- Dashboard / user display ---
*
+2 -2
View File
@@ -1,8 +1,8 @@
/**
* Zen Authentication Module - Server-side utilities
*
* For client components, use '@hykocx/zen/auth/pages'
* For server actions, use '@hykocx/zen/auth/actions'
* For client components, use '@zen/core/auth/pages'
* For server actions, use '@zen/core/auth/actions'
*/
// Authentication library (server-side only)
+2 -2
View File
@@ -16,7 +16,7 @@ import { redirect } from 'next/navigation';
*
* @example
* // In a server component:
* import { protect } from '@hykocx/zen/auth';
* import { protect } from '@zen/core/auth';
*
* export default async function ProtectedPage() {
* const session = await protect();
@@ -42,7 +42,7 @@ async function protect(options = {}) {
* @returns {Promise<Object|null>} Session object or null if not authenticated
*
* @example
* import { checkAuth } from '@hykocx/zen/auth';
* import { checkAuth } from '@zen/core/auth';
*
* export default async function Page() {
* const session = await checkAuth();
+4 -4
View File
@@ -2,14 +2,14 @@
* Auth Page - Server Component Wrapper for Next.js App Router
*
* Default auth UI: login, register, forgot, reset, confirm, logout at /auth/[...auth].
* Re-export in your app: export { default } from '@hykocx/zen/auth/page';
* Re-export in your app: export { default } from '@zen/core/auth/page';
*
* For custom auth pages (all flows) that match your site style, use components from
* '@hykocx/zen/auth/components' and actions from '@hykocx/zen/auth/actions'.
* '@zen/core/auth/components' and actions from '@zen/core/auth/actions'.
* See README-custom-login.md in this package. Basic sites can keep using this default page.
*/
import { AuthPagesClient } from '@hykocx/zen/auth/pages';
import { AuthPagesClient } from '@zen/core/auth/pages';
import {
registerAction,
loginAction,
@@ -19,7 +19,7 @@ import {
verifyEmailAction,
setSessionCookie,
getSession
} from '@hykocx/zen/auth/actions';
} from '@zen/core/auth/actions';
export default async function AuthPage({ params, searchParams }) {
const session = await getSession();
+1 -1
View File
@@ -1,7 +1,7 @@
'use client';
import { useState } from 'react';
import { ToastProvider, ToastContainer } from '@hykocx/zen/toast';
import { ToastProvider, ToastContainer } from '@zen/core/toast';
import { registerExternalModulePages } from '../../modules/modules.pages.js';
/**
+1 -1
View File
@@ -26,7 +26,7 @@ export * as pdf from "./core/pdf/index.js";
// Export module system as namespace
export * as moduleSystem from "./core/modules/index.js";
// NOTE: Toast components are CLIENT ONLY - import from '@hykocx/zen/toast'
// NOTE: Toast components are CLIENT ONLY - import from '@zen/core/toast'
// Do not export here to avoid mixing client/server boundaries
// Export modules system as namespace (legacy, includes invoice module)
+2 -2
View File
@@ -4,8 +4,8 @@
*
* NOTE: Individual modules (like invoice) should NOT be exported from here.
* Access module functionality directly via:
* - import { ... } from '@hykocx/zen/modules/invoice'
* - Or use the dynamic registry functions from @hykocx/zen/core/modules
* - import { ... } from '@zen/core/modules/invoice'
* - Or use the dynamic registry functions from @zen/core/core/modules
*/
// Module registry
+1 -1
View File
@@ -5,7 +5,7 @@
* External modules registered via zen.config.js are resolved through the runtime registry.
*
* Usage:
* import { getModuleActions } from '@hykocx/zen/modules/actions';
* import { getModuleActions } from '@zen/core/modules/actions';
* const { getInvoiceByToken } = getModuleActions('invoice');
*/
+1 -1
View File
@@ -5,7 +5,7 @@
* External modules registered via zen.config.js are resolved through the runtime registry.
*
* Usage:
* import { getMetadataGenerator } from '@hykocx/zen/modules/metadata';
* import { getMetadataGenerator } from '@zen/core/modules/metadata';
* const fn = getMetadataGenerator('invoice', 'payment');
* const meta = await fn(params.token);
*/
+5 -5
View File
@@ -5,16 +5,16 @@
* Users can simply re-export this in their app/zen/[...zen]/page.js:
*
* ```javascript
* export { default, generateMetadata } from '@hykocx/zen/modules/page';
* export { default, generateMetadata } from '@zen/core/modules/page';
* ```
*
* Module actions are loaded from the static modules.actions.js registry.
*/
import { PublicPagesLayout, PublicPagesClient } from '@hykocx/zen/modules/pages';
import { getMetadataGenerator } from '@hykocx/zen/modules/metadata';
import { getAppConfig } from '@hykocx/zen';
import { getModuleActions } from '@hykocx/zen/modules/actions';
import { PublicPagesLayout, PublicPagesClient } from '@zen/core/modules/pages';
import { getMetadataGenerator } from '@zen/core/modules/metadata';
import { getAppConfig } from '@zen/core';
import { getModuleActions } from '@zen/core/modules/actions';
/**
* Per-module path configuration.
+3 -3
View File
@@ -353,7 +353,7 @@ import {
upsertPost, // Créer ou mettre à jour (idempotent)
getPosts, // Liste avec pagination
deletePost, // Supprimer
} from '@hykocx/zen/modules/posts/crud';
} from '@zen/core/modules/posts/crud';
```
### `upsertPost(postType, rawData, uniqueField)`
@@ -384,7 +384,7 @@ Si les posts liés n'existent pas encore, les créer d'abord avec `upsertPost` p
```js
// src/cron/fetch-cves.js
import { upsertPost } from '@hykocx/zen/modules/posts/crud';
import { upsertPost } from '@zen/core/modules/posts/crud';
export async function fetchAndImportCVEs() {
const response = await fetch('https://api.example.com/cves/recent');
@@ -428,7 +428,7 @@ export async function fetchAndImportCVEs() {
### Exemple : fetcher d'actualités avec source
```js
import { upsertPost } from '@hykocx/zen/modules/posts/crud';
import { upsertPost } from '@zen/core/modules/posts/crud';
export async function fetchAndImportActualites(sourceName, articles) {
// S'assurer que la source existe
+1 -1
View File
@@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { Button, Card } from '../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
import { getTodayString } from '../../../shared/lib/dates.js';
import PostFormFields from './PostFormFields.js';
+1 -1
View File
@@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { Button, Card } from '../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
import { formatDateForInput, formatDateTimeForInput } from '../../../shared/lib/dates.js';
import PostFormFields from './PostFormFields.js';
+1 -1
View File
@@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { Book02Icon, Layers01Icon } from '../../../shared/Icons.js';
import { Card, Button } from '../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
/**
* Posts index page — shows all configured post types.
+1 -1
View File
@@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { PlusSignCircleIcon, PencilEdit01Icon, Delete02Icon, Layers01Icon } from '../../../shared/Icons.js';
import { Table, Button, Card, Pagination } from '../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
import { formatDateForDisplay, formatDateTimeForDisplay } from '../../../shared/lib/dates.js';
/**
+1 -1
View File
@@ -29,7 +29,7 @@ import {
validateUpload,
FILE_TYPE_PRESETS,
FILE_SIZE_LIMITS
} from '@hykocx/zen/storage';
} from '@zen/core/storage';
import { getPostsConfig, getPostType } from './config.js';
@@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { PlusSignCircleIcon, PencilEdit01Icon, Delete02Icon } from '../../../../shared/Icons.js';
import { Table, Button, StatusBadge, Card, Pagination } from '../../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
function getPostTypeFromPath(pathname) {
const segments = (pathname || '').split('/').filter(Boolean);
@@ -3,7 +3,7 @@
import React, { useState } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { Button, Card, Input, Textarea } from '../../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
function getPostTypeFromPath(pathname) {
const segments = (pathname || '').split('/').filter(Boolean);
@@ -3,7 +3,7 @@
import React, { useState, useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { Button, Card, Input, Textarea } from '../../../../shared/components';
import { useToast } from '@hykocx/zen/toast';
import { useToast } from '@zen/core/toast';
function getParamsFromPath(pathname) {
const segments = (pathname || '').split('/').filter(Boolean);
+1 -1
View File
@@ -3,7 +3,7 @@
* Categories are scoped by post_type.
*/
import { query } from '@hykocx/zen/database';
import { query } from '@zen/core/database';
/**
* Create a new category for a post type.
+2 -2
View File
@@ -4,8 +4,8 @@
* Relation fields are stored in zen_posts_relations (many-to-many).
*/
import { query } from '@hykocx/zen/database';
import { deleteFile } from '@hykocx/zen/storage';
import { query } from '@zen/core/database';
import { deleteFile } from '@zen/core/storage';
import { getPostType } from './config.js';
function slugify(text) {
+1 -1
View File
@@ -3,7 +3,7 @@
* Creates zen_posts and zen_posts_category tables.
*/
import { query } from '@hykocx/zen/database';
import { query } from '@zen/core/database';
import { getPostsConfig } from './config.js';
async function tableExists(tableName) {
+2 -2
View File
@@ -19,7 +19,7 @@ const ZEN_INIT_KEY = Symbol.for('__ZEN_INITIALIZED__');
* // instrumentation.js (Recommended) — internal modules only
* export async function register() {
* if (process.env.NEXT_RUNTIME === 'nodejs') {
* const { initializeZen } = await import('@hykocx/zen');
* const { initializeZen } = await import('@zen/core');
* await initializeZen();
* }
* }
@@ -29,7 +29,7 @@ const ZEN_INIT_KEY = Symbol.for('__ZEN_INITIALIZED__');
* import zenConfig from './zen.config.js';
* export async function register() {
* if (process.env.NEXT_RUNTIME === 'nodejs') {
* const { initializeZen } = await import('@hykocx/zen');
* const { initializeZen } = await import('@zen/core');
* await initializeZen(zenConfig);
* }
* }
+13 -13
View File
@@ -43,7 +43,7 @@ export default defineConfig([
splitting: false,
sourcemap: false,
clean: true,
external: ['react', 'react-dom', 'next', 'pg', 'dotenv', 'dotenv/config', 'resend', '@react-email/components', 'node-cron', 'readline', 'crypto', 'url', 'fs', 'path', 'net', 'dns', 'tls', '@hykocx/zen/database', '@hykocx/zen/email', '@hykocx/zen/email/templates', '@hykocx/zen/storage', '@hykocx/zen/toast', '@hykocx/zen/modules/actions', '@aws-sdk/client-s3', '@aws-sdk/s3-request-presigner'],
external: ['react', 'react-dom', 'next', 'pg', 'dotenv', 'dotenv/config', 'resend', '@react-email/components', 'node-cron', 'readline', 'crypto', 'url', 'fs', 'path', 'net', 'dns', 'tls', '@zen/core/database', '@zen/core/email', '@zen/core/email/templates', '@zen/core/storage', '@zen/core/toast', '@zen/core/modules/actions', '@aws-sdk/client-s3', '@aws-sdk/s3-request-presigner'],
noExternal: [],
bundle: true,
banner: {
@@ -77,18 +77,18 @@ export default defineConfig([
'react',
'react-dom',
'next',
'@hykocx/zen',
'@hykocx/zen/auth/pages',
'@hykocx/zen/auth/actions',
'@hykocx/zen/admin',
'@hykocx/zen/admin/pages',
'@hykocx/zen/admin/actions',
'@hykocx/zen/admin/navigation',
'@hykocx/zen/toast',
'@hykocx/zen/core/modules',
'@hykocx/zen/modules/pages',
'@hykocx/zen/modules/actions',
'@hykocx/zen/modules/metadata',
'@zen/core',
'@zen/core/auth/pages',
'@zen/core/auth/actions',
'@zen/core/admin',
'@zen/core/admin/pages',
'@zen/core/admin/actions',
'@zen/core/admin/navigation',
'@zen/core/toast',
'@zen/core/core/modules',
'@zen/core/modules/pages',
'@zen/core/modules/actions',
'@zen/core/modules/metadata',
],
bundle: false, // Don't bundle these files
esbuildOptions(options) {