Commit Graph

52 Commits

Author SHA1 Message Date
hykocx 18270540cc refactor(admin): replace inline avatar logic with shared UserAvatar component 2026-04-22 15:14:07 -04:00
hykocx 1613bd5275 feat(admin): add dynamic role color support for user badges 2026-04-22 15:08:46 -04:00
hykocx 96c8352dcf refactor(ui): move system badge to dedicated column and update Badge styles 2026-04-22 15:02:10 -04:00
hykocx 7ca818da5a fix(ui): fix missing space between rounded-lg and transition-all in Button class 2026-04-22 14:55:19 -04:00
hykocx f5c8dc842d refactor(auth): make COOKIE_NAME a private module-level constant 2026-04-22 14:41:53 -04:00
hykocx d64423c1ad docs(tsup): update build config comments and fix jsx import extensions 2026-04-22 14:40:09 -04:00
hykocx 0106bc4ea0 feat(core)!: introduce runtime extension registry and flat module conventions
BREAKING CHANGE: sup config now derives entries from package.json#exports and a server/client glob instead of manual lists; module structure follows flat + barrel convention with .server.js/.client.js runtime suffixes
2026-04-22 14:13:30 -04:00
hykocx 61388f04a6 refactor: reorganize feature modules with consistent naming conventions and flattened structure 2026-04-22 14:12:15 -04:00
hykocx 12f66a2115 feat(admin): add core users widget and reorganize dashboard widget registration 2026-04-22 13:27:04 -04:00
hykocx cdcd704d84 style(admin): refine header user menu typography and layout 2026-04-22 13:03:07 -04:00
hykocx e00d6b3c42 refactor(admin): replace inline SVGs with icon components and fix icon imports 2026-04-22 12:58:28 -04:00
hykocx c08c0a622f style(admin): update dropdown menu layout and remove user info section 2026-04-22 12:50:20 -04:00
hykocx 7bd5aedb3b style(admin): update user avatar and name styling in AdminHeader 2026-04-22 12:46:29 -04:00
hykocx 83672e9325 style(admin): standardize subtitle text size and color across admin pages 2026-04-22 12:43:20 -04:00
hykocx 8752ce168e style(ui): update sidebar width to 230px and refactor StatCard layout 2026-04-22 12:38:26 -04:00
hykocx f45322736f style(admin): move font-normal from base to inactive class in AdminSidebar 2026-04-22 12:33:54 -04:00
hykocx 836134f701 refactor(admin): rename sidebar CSS class variables for clarity 2026-04-22 12:10:22 -04:00
hykocx 384eadf7b7 style(admin): update sidebar width to 240px and refine nav item styles 2026-04-22 12:05:46 -04:00
hykocx e8d87b0a8f style(admin): adjust sidebar nav item spacing and remove sub-item icons 2026-04-22 11:57:25 -04:00
hykocx 408653452c style(admin): add active parent style for expanded sidebar sections 2026-04-22 11:50:36 -04:00
hykocx 2420a2cb1d fix(admin): correct active state condition for collapsed sidebar sections 2026-04-22 11:49:24 -04:00
hykocx d6506eab5a style(admin): update layout font, max-width, and sidebar active item styles 2026-04-22 11:46:48 -04:00
hykocx 138183f3a8 refactor(style): apply new design 2026-04-22 11:30:33 -04:00
hykocx 345371d43c style(admin): reduce header height and simplify layout spacing and menu item focus styles 2026-04-22 11:09:12 -04:00
hykocx 6b71818531 feat(admin): navigate to first section item when expanding collapsed sidebar section 2026-04-19 17:15:52 -04:00
hykocx f387511c40 refactor(admin): remove group toggle feature and simplify permissions UI in RoleEditPage 2026-04-19 17:04:29 -04:00
hykocx dcd4d9b9f9 refactor(admin): replace raw form elements with shared Input, Textarea, and Switch components in RoleEditPage 2026-04-19 16:56:50 -04:00
hykocx f08376d979 feat(users): refactor users system 2026-04-19 16:42:33 -04:00
hykocx 692a014dd8 refactor(storage): replace configureStorageApi with additive registration pattern 2026-04-19 16:06:32 -04:00
hykocx 41edccc1a3 refactor(admin): replace static dashboard stats with dynamic widget registry 2026-04-15 20:43:10 -04:00
hykocx 73a8639324 fix(admin): prevent menu from closing when toggling theme in header dropdown 2026-04-15 19:57:46 -04:00
hykocx 1d64ffd6f5 refactor(admin): replace ThemeToggle component with inline theme hook in AdminHeader 2026-04-15 19:55:38 -04:00
hykocx a3cb55814f feat: extract ThemeWatcher component for system theme detection 2026-04-15 17:50:43 -04:00
hykocx 0d940e3997 refactor: extract theme logic into shared core module 2026-04-15 17:06:37 -04:00
hykocx 7ef37e3ebd 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
2026-04-14 19:57:48 -04:00
hykocx cee521b0e4 refactor(auth): replace relative imports with @zen/core alias
Update BaseLayout imports in auth email templates to use the
`@zen/core/email/templates` module alias instead of relative paths,
improving maintainability and consistency across the codebase.
2026-04-14 19:35:19 -04:00
hykocx 9584b23ed7 fix: correct import paths and remove DatabaseError export
- Fix BaseLayout import paths in auth email templates from
  `../../core/...` to `../../../core/...` to match correct
  directory depth
- Remove unused `DatabaseError` from db.js exports
2026-04-14 19:31:00 -04:00
hykocx 3131df2b71 refactor: remove module system integration from admin and CLI
Removes all module-related logic from the admin dashboard, CLI database
initialization, and AdminPages component:

- Drop `initModules` call from `db init` CLI command and simplify the
  completion message to only reflect core feature tables
- Remove `getModuleDashboardStats` and module page routing from admin
  stats actions and update usage documentation accordingly
- Simplify `AdminPagesClient` to remove module page loading, lazy
  components, and module-specific props (`moduleStats`, `modulePageInfo`,
  `routeInfo`, `enabledModules`)
2026-04-14 19:26:48 -04:00
hykocx 242ea69664 feat(storage): refactor storage config and remove module registry
Introduce a dedicated `storage-config.js` for registering public
prefixes and access policies via `configureStorageApi()`, replacing the
previous `getAllStoragePublicPrefixes` / `getAllStorageAccessPolicies`
imports from the module registry.

Remove `getAllApiRoutes()` from the router so module-level routes are no
longer auto-collected; feature routes must now be registered explicitly
via `registerFeatureRoutes()` during `initializeZen()`.

Update `.env.example` to document separate `ZEN_STORAGE_PROVIDER`,
`ZEN_STORAGE_B2_*` variables for Backblaze B2 alongside the existing
Cloudflare R2 variables, making provider selection explicit.

Clean up admin navigation and page components to drop module-injected
nav entries, keeping only core and system sections.
2026-04-14 17:43:06 -04:00
hykocx 2e348a1608 feat(storage): add configurable storage access policies
Replace hardcoded `users/` path-based access control with a
declarative `storageAccessPolicies` system defined per module via
`defineModule()`.

- Add `storageAccessPolicies` field to `defineModule()` defaults with
  support for `owner` and `admin` policy types
- Expose `getAllStorageAccessPolicies()` from the modules/storage layer
- Refactor `handleGetFile` in `storage/api.js` to resolve access
  control dynamically from registered policies instead of hardcoded
  path checks
- Add `ZEN_STORAGE_ENDPOINT` env var and update `.env.example` to
  support S3-compatible backends (Cloudflare R2, Backblaze B2)
- Document the env/doc sync convention in `DEV.md`
2026-04-14 17:09:27 -04:00
hykocx 87a04db04b feat(email): refactor email module and improve config handling
- Simplify `sendEmail` by extracting `resolveFrom` and `buildPayload` helpers
- Remove `sendAuthEmail` and `sendAppEmail` exports, keeping only `sendEmail` and `sendBatchEmails`
- Replace hardcoded fallback sender with env-based validation (throws if missing)
- Update `BaseLayout` to resolve `supportEmail` from `ZEN_SUPPORT_EMAIL` env var instead of hardcoded default
- Conditionally render support section only when a support email is available
- Remove verbose JSDoc comments and reduce overall code verbosity
2026-04-13 18:37:06 -04:00
hykocx 59fce3cd91 refactor(api): update README and refactor api route registration
Restructure the core API to separate infrastructure routes from feature
routes. Key changes:

- Add `runtime.js` for global state: session resolver and feature route
  registry
- Add `file-response.js` for streaming file responses (storage endpoint)
- Remove feature routes (auth/users) from `core-routes.js`, keeping only
  true infrastructure routes (health, storage)
- Introduce `registerFeatureRoutes()` so features self-register during
  `initializeZen()` instead of being hardcoded in `core-routes.js`
- Add `UserFacingError` class to safely surface client-facing errors
  without leaking internal details
- Fix import path for `rateLimit.js` to use shared lib location
- Update README to reflect new two-step registration flow and clarify
  the role of `core-routes.js`
2026-04-13 17:20:14 -04:00
hykocx a3921a0b98 feat(database): refactor CLI, add column whitelist, and SSL config
- Add `ZEN_DB_SSL_DISABLED` env variable to allow disabling SSL for database connections
- Refactor database CLI to split init logic into `initFeatures` and `initModules` for modular table initialization, with graceful fallback when modules are absent
- Extract `printHelp` and `askConfirmation` helpers for cleaner CLI structure
- Ensure `closePool` is called on both success and error paths in CLI
- Add `filterAllowedColumns` utility in `crud.js` to enforce column whitelists, preventing mass-assignment of privileged fields (e.g. `role`, `email_verified`)
- Update drop command description from "auth tables" to "all tables"
2026-04-13 16:35:23 -04:00
hykocx 4ddf834990 refactor(api): refactor API module with route definitions and response utilities
Restructure the core API module to improve clarity, consistency, and
maintainability:

- Introduce `defineApiRoutes()` helper for declarative route definitions
  with built-in config validation at startup
- Add `apiSuccess()` / `apiError()` response utilities; enforce their
  use across all handlers (core and modules)
- Move auth enforcement to route definitions (`auth: 'public' | 'user' |
  'admin'`), removing manual auth checks from handlers
- Extract core routes into `core-routes.js`; router now has no knowledge
  of specific features
- Rename `nx-route.js` to `route-handler.js` and update package.json
  export accordingly
- Update ARCHITECTURE.md to reflect new API conventions and point to
  `src/core/api/README.md` for details
2026-04-13 15:13:03 -04:00
hykocx e87bd05fa4 refactor: replace console.log with structured logger calls
Replace raw `console.log`/`console.error` calls across CLI, API
handlers, and module files with structured logger functions (`step`,
`done`, `warn`, `fail`) from the shared logger library.

This improves log consistency, readability, and makes it easier to
control output formatting and log levels from a single place.
2026-04-12 21:44:00 -04:00
hykocx 3e633e981a docs/refactor: rename getModuleMetadata and update route auth format
- Rename `getModuleMetadata` to `getModuleMetadataGenerator` in registry,
  index, and client exports to clarify its purpose (returns a generator
  function, not a metadata object)
- Add new `getModuleMetadata` and `getMetadataGenerator` exports from
  `modules.metadata.js` for server-side metadata object retrieval
- Update route auth format in docs from `requireAuth`/`requireAdmin`
  flags to a single `auth` field with values: `'admin'`, `'user'`,
  or `'public'`
- Fix `isModuleEnabledInEnv` to replace hyphens with underscores in
  env var names (e.g. `my-module` → `ZEN_MODULE_MY_MODULE`)
- Replace `useState` initializer in `ZenProvider` with `useRef` guard
  to avoid React strict mode double-invocation issues
2026-04-12 18:58:01 -04:00
hykocx 98f1cd9688 fix: harden API security against info leakage and MIME sniffing
- Sanitize route handler errors: only surface known auth messages
  ('Unauthorized', 'Admin access required'); log all other exceptions
  server-side and return a generic 'Internal Server Error' to clients
- Derive profile picture content-type from validated file extension
  instead of attacker-controlled file.type to prevent MIME spoofing
- Always emit explicit Content-Disposition headers on file responses;
  serve known image types as 'inline', force download for all others
  to prevent in-browser rendering of potentially dangerous content
- Add X-Content-Type-Options: nosniff and X-Frame-Options: DENY to
  file response headers
2026-04-12 18:26:33 -04:00
hykocx 81172bda94 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.
2026-04-12 15:09:26 -04:00
hykocx 1b53ba8d58 refactor: remove setup feature from build exports and config
Removes the `./setup` export entry from `package.json` and the
corresponding `src/features/setup/index.js` entry point from
`tsup.config.js`, eliminating the standalone setup feature module
from the public API and build output.
2026-04-12 14:40:34 -04:00
hykocx 390133808b refactor: consolidate CLI entry points into dedicated cli/ directory
Move `database` and `setup` CLI scripts from their respective feature
directories into a unified `src/cli/` directory. Update `tsup.config.js`
build entries and `package.json` bin paths to reflect the new locations.
2026-04-12 14:39:17 -04:00