Feat dock stacks and dock node#75
Open
Its4Nik wants to merge 17 commits into70-dockstore-refactor-into-dockstat-repositoryfrom
Open
Feat dock stacks and dock node#75Its4Nik wants to merge 17 commits into70-dockstore-refactor-into-dockstat-repositoryfrom
Its4Nik wants to merge 17 commits into70-dockstore-refactor-into-dockstat-repositoryfrom
Conversation
…agement - Introduce Dockerfile for containerizing the DockNode application. - Develop a comprehensive StackHandler for Docker Compose stack management, including: - CRUD operations (create, get, list, update, delete, rename, export). - Lifecycle commands (up, down, stop, restart, pull). - Information commands (ps, logs, config, network stats, version). - Execution commands (exec, run, rm, kill, port). - Expose stack management functionalities via new `/api/stacks` endpoints. - Integrate `docker-compose` for orchestration and `dockerode` for Docker API interaction. - Add `.dockerignore`, `.npmignore`, and update `.gitignore` for relevant file exclusions. - Update `README.md` with DockNode description and API examples. - Introduce application-specific logger and utility functions. - Configure `tsconfig.json` for ESNext and bundler module resolution. - Add necessary dependencies for Docker client, logger, typings, utilities, and OpenAPI.
…structor options The `DockerClient` class is now directly exportable and importable via `@dockstat/docker-client/client`, allowing for more flexible usage without needing to instantiate the `DockerClientManager`. Additionally, the `options` parameter in the `DockerClientBase` constructor has been made required, ensuring explicit configuration for client instances. The package version has been incremented to `2.0.1`.
…lass
Moved all source files into a dedicated 'src/' directory to improve project structure and maintainability. This refactor also includes a significant modularization of the 'DB' class.
Key changes include:
* All core logic previously in 'index.ts' has been moved to 'src/index.ts'.
* Extracted various concerns from the 'DB' class into new helper modules under 'src/lib':
* Backup and restore operations moved to 'src/lib/backup'.
* Index creation and dropping moved to 'src/lib/index'.
* SQL helper functions like 'isSQLFunction' moved to 'src/lib/sql'.
* Table creation logic ('buildColumnSQL', 'buildTableConstraints', 'isTableSchema', 'setTableComment', 'getTableComment') moved to 'src/lib/table'.
* Updated all relative imports in test files to point to the new 'src/' paths.
* Adjusted 'package.json' and 'tsconfig.json' to reflect the new file structure and module resolution.
* Bumped package version to 1.3.3.
- Renamed package from 'dockstore-cli' to '@dockstat/repo-cli' for consistent branding.
- Completely rewrote the README to provide comprehensive usage documentation:
- Added detailed installation instructions.
- Documented 'init', 'bundle', 'badges', and 'serve' commands with their options, descriptions, and requirement status.
- Included license information.
- Bumped package version to 1.0.4.
…on and WHERE methods - Introduce `safeStringify` utility in `WhereQueryBuilder` to robustly serialize complex values (including RegExp) for logging. - Add info-level logs to `SelectQueryBuilder` execution methods (`all`, `get`, `count`, `exists`, `value`, `pluck`) to display built queries, parameters, and results. - Add info-level logs to `WhereQueryBuilder` methods (`where`, `whereRgx`, `whereExpr`, `whereIn`, `whereOp`, `whereBetween`, `whereNull`, etc.) to track the construction of WHERE clauses and their parameters. - Remove duplicate `safeStringify` implementation from `SelectQueryBuilder` to utilize the new base class helper. - Bump package version to 1.3.4.
* feat(query-builder): Add detailed info-level logging to query execution and WHERE methods
- Introduce `safeStringify` utility in `WhereQueryBuilder` to robustly serialize complex values (including RegExp) for logging.
- Add info-level logs to `SelectQueryBuilder` execution methods (`all`, `get`, `count`, `exists`, `value`, `pluck`) to display built queries, parameters, and results.
- Add info-level logs to `WhereQueryBuilder` methods (`where`, `whereRgx`, `whereExpr`, `whereIn`, `whereOp`, `whereBetween`, `whereNull`, etc.) to track the construction of WHERE clauses and their parameters.
- Remove duplicate `safeStringify` implementation from `SelectQueryBuilder` to utilize the new base class helper.
- Bump package version to 1.3.4.
* formatting
* feat(theme-handler): Introduce theme-handler package for managing UI themes
This commit introduces the new `@dockstat/theme-handler` package, providing a comprehensive solution for managing UI themes across the application.
Key features include:
- **Client-side utilities**:
- React context (`ThemeContext`) for easily accessing theme data.
- Functions to dynamically apply theme variables (CSS custom properties) to the document.
- Local storage integration for persisting user theme preferences.
- **Server-side management**:
- `ThemeDB` class for robust SQLite database integration to store, retrieve, update, and delete themes.
- Elysia-based API routes (`/themes`) offering full CRUD capabilities for themes, including fetching by name or ID.
- **Default themes**:
- Ships with pre-defined "DockStat-Dark", "DockStat-Light", "DockStat-OLED", and "DockStat-UltraDark" themes, including their CSS variables and animation properties.
- **Bun & Elysia integration**:
- The package is set up with Bun for efficient dependency management and runtime, and Elysia for building high-performance API routes.
This package centralizes theme logic, making it easier to manage and apply consistent styling throughout the application.
* feat(ui): Add theme browser and selection functionality
This commit introduces a user interface for browsing and selecting application themes.
- **New `ThemeBrowser` Component**: A dedicated component is added to display available themes, each with a preview of its key color variables (background, primary text, accent, etc.). Users can select a theme from this browser.
- **Sidebar Integration**: The `Sidebar` component now includes a new 'Palette' icon button that opens a modal containing the `ThemeBrowser`.
- **`ThemeProps` Interface**: A `ThemeProps` interface is defined to facilitate passing theme-related data (list of themes, current theme ID, selection handler, open callback) from parent components to the `Sidebar` and subsequently to the `ThemeBrowser`.
- **Navbar Update**: The `Navbar` component is updated to accept and forward `themeProps` to the `Sidebar`, ensuring theme management can be controlled from higher up the component tree.
- Refactored the loading state check for pinned items in the Sidebar to use `mutationFn.isBusy` for a cleaner approach.
- Exports `ThemeBrowser` components for broader use within the `ui` package.
* refactor(sqlite-wrapper): Truncate excessively long stringified condition values
Introduce a `truncate` utility function to limit the length of strings.
Apply this utility within the `WhereQueryBuilder.safeStringify` method to prevent excessively long stringified values (e.g., from `JSON.stringify` or `String()`) from being returned. This improves readability in debugging logs or contexts where these values might be displayed, ensuring they don't consume too much space. The maximum length for truncated strings is set to 100 characters.
* feat(dockstat): Implement client-side theme management and provider
Introduce `ThemeProvider` to manage and apply themes within the DockStat UI. This includes:
- Adding `@dockstat/theme-handler` dependency.
- Creating `ThemeProviderContext` and `useTheme` hook for global theme state and access.
- Implementing `ThemeProvider` to handle theme fetching (by name/ID) from the API, applying themes to the document using `@dockstat/theme-handler/client` functions (`applyThemeToDocument`), and persisting user preferences (`saveThemePreference`, `loadThemePreference`).
- Integrating the `ThemeProvider` at the application root in `src/providers/index.tsx`.
- Updating `layout.tsx` to consume theme data and functions from `useTheme`, enabling theme selection capabilities in the sidebar.
- Adding a new `/stacks` route and a placeholder `StacksIndex` page.
* feat(api): Add theme management endpoints
* feat(docknode): Implement API key authentication
Introduces API key-based authentication to the docknode application. This implementation leverages the 'better-auth' library, configured to accept API keys via the 'x-docknode-key' header.
Key changes include:
- Addition of the 'better-auth' dependency to apps/docknode.
- Creation of 'src/auth/index.ts' to define the authentication setup.
- Updates to '.env.example' for `BETTER_AUTH_SECRET` and `BETTER_AUTH_URL` configuration.
- Minor updates to `bun.lock` and import reordering across various packages (e.g., `dockstat`, `sqlite-wrapper`, `theme-handler`) for consistency and dependency management.
* docs(all): Standardize formatting and add new content
- Refactored RSS feed websocket subscription path to `api.api.v2.misc.stats.rss` in `apps/dockstat/src/lib/websocketEffects/README.md`.
- Introduced a new documentation page for `Eden Query & Mutation Hooks` under `apps/docs/dockstat/patterns`, detailing `useEdenQuery` and `useEdenMutation` with code examples and type inference.
- Documented the `createIndex` method in `@dockstat/sqlite-wrapper`, providing comprehensive usage, options, and examples for index creation.
- Standardized Markdown table formatting across all documentation files for improved readability and consistency.
- Addressed minor formatting issues, including trailing commas in code snippets and ensuring all Markdown files end with a newline.
* Update apps/dockstat/src/providers/theme.tsx
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: ItsNik <info@itsnik.de>
* fix(db): Remove incomplete createIndex call
* refactor(dockstat/theme): Simplify API calls in theme provider
Remove `useEdenQuery` hooks from `ThemeProvider` and replace them with direct calls to the `api` client. This streamlines data fetching for themes (by name, by ID, and all themes) by eliminating an intermediate hook layer.
Consolidate theme application and persistence logic into a new `applyAndPersistTheme` callback for improved code reuse and clarity.
The `useTheme` hook also removes its explicit error throw for usage outside `ThemeProvider`, relying on `useContext` to return `undefined` when the context is not available.
* refactor(theme-handler): modularize server API routes and models
The `theme-handler` server API has been refactored into a more modular and organized structure.
Previously, all theme API routes and associated response models were defined in a single large file (`src/server/api.ts`). This commit breaks down this monolithic file into a clear directory structure:
* **`src/server/api/models/`**: Contains schema definitions for theme data (`themeModel.ts`), mutation payloads (`themePost.ts`), and standardized API responses (`themeResponses.ts`).
* **`src/server/api/routes/`**: Contains individual files for each set of API operations: `queries.ts` (GET), `mutations.ts` (POST), `update.ts` (PUT), and `delete.ts` (DELETE).
The main `createThemeRoutes` function now composes these smaller, focused route modules, improving maintainability and readability.
Additionally, the top-level `src/index.ts` has been updated to re-export `client` and `server` modules as namespaces (`export * as client from "./client"`), providing a clearer and more explicit import structure for consumers of the package.
This refactoring aims to improve code organization, reusability of API models, and overall maintainability of the `theme-handler` package.
* refactor(query-builder/logging): Centralize logging in Select and Where builders
Refactor logging logic within `SelectQueryBuilder` and `WhereQueryBuilder` by introducing dedicated private/protected helper methods.
This change:
- Consolidates common logging patterns for query initiation and results in `SelectQueryBuilder` into `logSelectStart` and `logSelectReturn`.
- Introduces `logColumnReturn` for consistent logging in `pluck` and `value` methods.
- Centralizes logging of `where` conditions and internal state in `WhereQueryBuilder` using `logWhere` and `logWhereState`.
- Improves consistency and readability of log messages across different query execution and condition building methods.
- Reduces code duplication for logging statements, making the code more maintainable.
* feat(ui, api, theme-handler): Implement user feedback toasts and enhance theme preview
- **`dockstat`**: Added toast notifications for successful pin/unpin operations and theme selection, providing immediate user feedback.
- **`ui`**: Overhauled the `ThemeBrowser` component to display a more dynamic and accurate color preview using validated theme variables. Extracted color constants and created a `getValidColors` utility.
- **`theme-handler`**:
- Introduced `onFinish` callback to `applyThemeToDocument` for client-side feedback integration.
- Corrected the logic in the theme creation route to prevent creating themes with duplicate names (bug fix).
- Updated theme response models to use `ThemeModel` consistently and refined the delete route's response type.
- **`api`**: Improved request completion logging by including the request URL path, enhancing observability.
* Update apps/docs/dockstat/patterns/eden-query-&-mutation-hooks/README.md
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: ItsNik <info@itsnik.de>
* refactor(components): Remove unused props and refine component types
Omit 'paths' from `RepoCard` props definition to align with actual usage.
Remove 'isLoading' from `ThemeProps` in `Sidebar` as it is no longer required.
Perform minor whitespace cleanup in the `WhereQueryBuilder`.
---------
Signed-off-by: ItsNik <info@itsnik.de>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
…gging, and add DockNode authentication
This commit introduces a comprehensive theme management system, integrates robust authentication into DockNode, and significantly enhances logging across the API and database layers for improved debuggability.
Key changes include:
**Theme Management:**
* **New `@dockstat/theme-handler` package:** Provides core logic for theme definition, storage, and application on both server and client.
* **API Integration (`apps/api`):** Adds new `/api/v2/themes` routes for CRUD operations on themes, enabling listing, retrieval, creation, updating, and deletion of custom themes.
* **Frontend Integration (`apps/dockstat`, `packages/ui`):**
* Introduces `ThemeProvider` and `useTheme` hook to manage theme state, persist user preference, and dynamically apply themes to the UI.
* Adds a "Theme Browser" modal to the sidebar, allowing users to preview and select from available themes.
* Includes default themes (Dark, Light, OLED, UltraDark) for immediate use.
* **Database Schema:** `ThemeDB` in `@dockstat/theme-handler` now manages theme data using `@dockstat/sqlite-wrapper`.
**DockNode Authentication:**
* **`better-auth` Integration (`apps/docknode`):** Implements API key-based authentication for the DockNode agent using the `better-auth` package, improving security for remote operations.
* Updates `.env.example` with relevant `BETTER_AUTH` configuration.
**Logging & Debugging Improvements:**
* **Enhanced `sqlite-wrapper` logging:** Introduces detailed logging for `SELECT` queries, including query strings, parameters, and truncated results, to aid in debugging database interactions.
* **Log Message Truncation:** Adds a `truncate` utility to `sqlite-wrapper` to prevent excessively long log messages.
* **API Middleware Logging:** Improves request logging in `apps/api` to include the specific path of incoming requests.
* **Frontend Log Viewer (`packages/ui`):** The sidebar now includes a "View Backend Logs" modal, presenting real-time log entries from the API for direct debugging within the UI.
**Additional Enhancements:**
* **New `stacks` page (`apps/dockstat`):** Introduces a placeholder page and routing for future stack management functionality.
* **UI/UX refinements (`packages/ui`, `apps/dockstat`):**
* Adds toast notifications for pinning/unpinning items in the sidebar.
* Updates `RepoCard` props for improved type safety.
* **Documentation:** Updates table formatting across various `README.md` files and adds new documentation for `sqlite-wrapper`'s `createIndex` method and Eden query/mutation hooks.
* **Websocket API path fix (`apps/dockstat`):** Corrects a websocket API endpoint prefix in a `README.md` example.
Contributor
There was a problem hiding this comment.
Sorry @Its4Nik, your pull request is larger than the review limit of 150000 diff characters
…pages This commit brings significant updates including configurable hotkeys, a new DockNode section, and various UI enhancements. **Hotkeys:** - Add `hotkeys` field to the global configuration schema (`DockStatConfigTable`) and context (`ConfigProviderData`). - Define `HotkeyAction` type for better type safety of configurable hotkey actions (e.g., "open:quicklinks"). - Set a default hotkey `k` for opening quick links in the database defaults. - Integrate configurable hotkeys into the `Navbar` and `LinkLookup` components, allowing customization of the quick links modal hotkey. **DockNode & Stacks:** - Create new pages for `/node` (DockNode overview) and `/node/stacks` (Stacks within a DockNode). - Refactor and move the existing `/stacks` functionality to the new `/node/stacks` route, deleting the old `/stacks` page. - Update the application router and sidebar navigation to reflect the new DockNode structure. **UI & Accessibility:** - Enhance the `Card` component with a `tabIndex` prop to improve keyboard navigation and focus management. - Adjust tab indexing within the `LinkLookup` modal for better accessibility. - Apply minor styling and structure adjustments to sidebar items, including child item formatting. **Refactoring:** - Streamline theme loading state management in the main layout by removing unnecessary `isLoading` prop from `useTheme` consumer.
Create a new `useHotkey` React hook in `@dockstat/utils/react` to provide a centralized and declarative way for components to manage keyboard shortcuts.
- Migrate existing hotkey handling logic in `LinkLookup` component (for quick links modal) to utilize the new `useHotkey` hook.
- Integrate the `useHotkey` hook into the `Navbar` component to manage sidebar `open`, `close`, and `toggle` actions, making hotkey management consistent.
- Add `toggle:sidebar` hotkey (`b` by default) to the default application configuration in `packages/db`.
- Refactor utility imports across `apps/api` and `packages/plugin-handler` to use barrel exports from `@dockstat/utils` (e.g., `import { repo } from "@dockstat/utils"` instead of direct path imports).
- Update various project dependencies.
…e registration
This commit introduces a comprehensive system for managing DockNode instances from the main DockStat API and frontend. Users can now register, monitor, and remove external DockNode servers, enhancing distributed management capabilities.
**Key Changes:**
* **API (`apps/api`):**
* Added `@dockstat/docknode` and `@elysiajs/eden` dependencies.
* Implemented `DockNodeHandler` to manage DockNode registration within a new `docknode-register` SQLite table. This includes functionality for checking node reachability, creating, and deleting entries.
* Exposed new `/api/v2/node` endpoints (`GET`, `POST`, `DELETE`) for performing CRUD operations on DockNode registrations.
* Defined Elysia TypeBox models for robust API request validation.
* **DockNode (`apps/docknode`):**
* Added a `GET /api/status` endpoint, allowing the main API to perform health checks and determine if a registered DockNode is online.
* Configured the SQLite database to use Write-Ahead Logging (WAL) journal mode for improved performance and data integrity.
* **Frontend (`apps/dockstat`):**
* Created a new "DockNodes" page (`src/pages/node/index.tsx`) in the UI to list, create, and delete DockNode registrations.
* Developed the `DockNodeCard` React component to visually represent each registered node, displaying its status, host, port, SSL usage, and providing options for interaction.
* Integrated new `useEdenQuery` and `useEdenMutation` hooks for seamless interaction with the API.
* **Database & Typings (`packages/db`, `packages/typings`):**
* Refactored the `tls_certs_and_keys` field in the main `config` table to a more generic `keys` object.
* Extended the `keys` object to include a dedicated slot for `docknode` specific API keys, enabling future secure communication.
* Improved type definitions for foreign keys in `packages/sqlite-wrapper`.
* **Utilities (`packages/utils`):**
* Introduced a new set of React Query-based utility hooks (`useEdenQuery`, `useEdenMutation`, `useEdenRouteMutation`) for `elysia/eden` clients. These hooks simplify data fetching and mutations, providing standardized error handling, loading states, and automatic query invalidation.
* Added `@tanstack/react-query` as a dependency.
* **Build & Development:**
* Updated the `dev:dockstat` script to include `--filter=@dockstat/docknode` for integrated development.
* Updated various dependencies across the monorepo.
This feature lays the groundwork for centralized management of distributed DockNode services.
Refactor the `Slides` component in `@packages/ui` to dynamically measure and animate content height. This change leverages `ResizeObserver` to ensure that slides with dynamic content automatically adjust their height during transitions, resulting in a smoother and more responsive user experience. The previous `collapseVariants` animation logic is replaced with direct height and opacity animations. Additionally, the `overflow-hidden` class is removed from the `Slides` `CardBody` as `SlideContent` now manages its own overflow for animation.
Redesign the `DockNodeCard` component in the `dockstat` application, introducing significant visual and structural improvements:
- Updated layout and spacing for better readability.
- Refined typography and enhanced status badges.
- Improved presentation of connection details.
- Restyled `CardFooter` with updated action button presentation and text ("Visit" changed to "Open").
- Minor adjustments to event handling for the delete action, including explicit `e.stopPropagation()`.
…kStat into feat-DockStacks-and-DockNode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.