Commit Graph

19 Commits

Author SHA1 Message Date
Eli Bosley
d08fc94afb fix: sign out correctly on error (#1452)
This actually doesn't fix the error but should make it more flexible.
Also adds some testing.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

* **Refactor**
* Enhanced error detection for invalid API key messages to improve
accuracy.
* **Tests**
* Added comprehensive tests verifying error handling and client
lifecycle behavior without network dependencies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-02 10:06:51 -04:00
Pujit Mehrotra
ffb2ac51a4 refactor: rm unused oauth token fields in connect model (#1451)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Updated theme settings now allow header background and primary text
colors to be optionally unset or left blank.

* **Bug Fixes**
* Removed unused authentication token fields from sign-in and
configuration forms for a streamlined user experience.

* **Style**
* Improved formatting and readability in several areas of the
application and tests.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-02 09:48:32 -04:00
Pujit Mehrotra
a8566e9e5a build: fix doinst.sh compatibility with installpkg --root (#1446)
- Isolate plugin concerns into `.plg` plugin & api file modifiers instead of the api's
slackware package.

## Summary by CodeRabbit

* **New Features**
* Installation process modularized into package installation,
post-install setup with verification, and service startup with cleanup.
* Added logging and error detection during installation, including
symlink verification.
  * Created required log directory to support service dependencies.
* Integrated nginx service with reload capability triggered by
configuration changes.
* Added automatic patching of nginx configuration and hosts file to
improve security and iframe compatibility.
* Enhanced file modification system to handle side effects and trigger
nginx reloads as needed.

* **Refactor**
* Restructured installation scripts for clarity; setup scripts now
separate steps.
  * Removed legacy installation logic and deprecated related scripts.
  * Enabled hard link addition during package creation.
* Simplified installation scripts by removing conditional branching and
detailed logging.
* Streamlined API environment setup by removing redundant post-install
steps.
* Updated dependency injection to explicitly provide nginx service
token.
  * Improved patch application error reporting with file path details.

* **Chores**
  * Disabled legacy scripts to streamline installation.
  * Removed `.gitignore` to track previously ignored files.
* Updated tests to include new dependencies and relaxed logger
assertions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210661184127051
2025-06-30 10:49:46 -04:00
Eli Bosley
86bea56272 feat: move api key fetching to use api key service (#1439)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Refactor**
- Simplified and streamlined the management of the local Connect API
key, renaming it to "ConnectInternal" and removing legacy keys.
- Updated internal logic to directly retrieve or create the Connect API
key without storing or emitting it in configuration or events.
- Replaced custom WebSocket handling with default implementation and
improved asynchronous API key retrieval for client connections.
- Enhanced asynchronous handling for subscription and query execution to
ensure proper client initialization.

- **Chores**
- Removed obsolete methods and test suites related to previous Connect
API key management logic.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-26 16:29:49 -04:00
Pujit Mehrotra
af6e56de60 test: fix connect plugin tests (#1441)
## Summary by CodeRabbit

* **Bug Fixes**
* Improved error handling to prevent runtime exceptions when certain
configuration fields are undefined.
  * Updated test expectations to reflect new error handling behaviors.

* **Refactor**
* Streamlined and modularized the legacy configuration migration process
for better maintainability.
* Removed obsolete configuration fields and related validation from the
configuration model.

* **Tests**
* Added and enhanced test suites to verify configuration migration,
parsing, and URL resolution logic.
* Improved test coverage and robustness with expanded mock data and
flexible assertions.

* **Chores**
* Updated test scripts and dependencies for improved reliability and
compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-26 15:04:26 -04:00
Pujit Mehrotra
c4c99843c7 fix: config migration from myservers.cfg (#1440)
## Summary by CodeRabbit

- **Bug Fixes**
- Improved handling and migration of legacy configuration values for
smoother upgrades and more accurate settings conversion.

- **Refactor**
- Streamlined the legacy configuration migration process for better
reliability and maintainability.
  - Removed the unused `ssoSubIds` property from configuration models.

- **Tests**
- Added comprehensive tests to ensure correct migration and conversion
of legacy configuration data.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-26 15:00:24 -04:00
Eli Bosley
22fe91cd56 fix: delete legacy connect keys and ensure description 2025-06-25 16:19:09 -04:00
Pujit Mehrotra
7bc583b186 fix: remote access lifecycle during boot & shutdown (#1422)
## Summary

- **New Features**
- Introduced a comprehensive Nginx control script for Unraid OS,
enabling advanced server management, SSL certificate handling, and
dynamic configuration based on system state.
https://github.com/unraid/webgui/pull/2269
- Added a utility function to safely execute code with error handling
support.

- **Improvements**
- Enhanced logging across remote access, WAN access, and settings
services for improved traceability.
- Added initialization and cleanup hooks to remote access and UPnP
services for better lifecycle management.
- Optimized configuration persistence by batching rapid changes for more
efficient updates.
- Refined URL resolution logic for improved configuration retrieval and
error handling.
  - Broadened pattern matching for domain keys in Nginx state parsing.
- Updated remote access settings to reload the network stack after
changes.
- Simplified remote access and WAN port configuration logic for clarity
and accuracy.
- Improved port mapping logic with explicit error handling in UPnP
service.
- Updated UI and form controls for remote access settings to reflect SSL
requirements and access type restrictions.

- **Configuration**
  - Updated the default path for module configuration files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-24 15:10:07 -04:00
Eli Bosley
b8035c207a feat: move to cron v4 (#1428)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**
- Updated internal dependencies for improved compatibility and
performance.
- Adjusted package configuration to include an additional built
dependency.

- **Bug Fixes**
- Improved the accuracy of task status reporting in the UPNP job
manager.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-20 17:32:12 -04:00
Eli Bosley
f12d231e63 fix: debounce is too long (#1426)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Reduced the delay before configuration changes are processed,
resulting in faster response times to configuration updates throughout
the application.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-20 11:07:53 -04:00
Pujit Mehrotra
70c790ff89 fix: alignment of settings on ManagementAccess settings page (#1421)
## Summary by CodeRabbit

- **Refactor**
- Removed description text display from a form field for a cleaner
interface.
- Enhanced form field matching to better target specific string array
inputs.
- Updated remote access settings UI for clearer layout and separation of
title and details.
  - Adjusted label container styling to allow more flexible width.
- Improved grouping of precondition information for better visual
structure.
  - Added a colon to the SSO users settings label for consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210572375587668
2025-06-19 08:46:18 -04:00
Eli Bosley
0788756b91 feat: add management page for API keys (#1408)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Added ability to update existing API keys, including name,
description, roles, and permissions, through the UI and GraphQL API.
- Introduced a modal-based interface for creating and editing API keys
with improved role and permission selection.
- Added a new API Key Manager page and custom element for centralized
API key management.
- Enhanced API key listing with detailed views, role badges, permission
counters, and copy-to-clipboard functionality.
- Introduced reusable dialog components for consistent modal
experiences.
- Added plugin management capabilities with mutations to add or remove
plugins.
- Added comprehensive support for managing remote access, network URLs,
and API key updates within the GraphQL schema.

- **Bug Fixes**
- Improved error handling and display for API key creation and update
operations.

- **Refactor**
- Centralized API key modal and editing state management using a
dedicated store.
- Updated GraphQL queries and mutations to use reusable fragments for
API key data.
- Removed deprecated or redundant remote access and allowed origins
configuration components and queries.
- Simplified and updated input types for connect settings and remote
access.

- **Tests**
- Added comprehensive tests for API key update logic and improved
coverage for API key loading.

- **Chores**
- Updated configuration files and cleaned up unused schema and component
files.
  - Added new dialog components and centralized exports for dialogs.
- Improved ESLint configuration and import statements for better type
handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-18 11:18:36 -04:00
Pujit Mehrotra
3dcbfbe489 feat: api plugin management via CLI (#1416)
implements unraid-api `plugins list`, `plugins install`, `plugins remove` commands via a new `DependencyService` that invokes npm.

## Summary by CodeRabbit

- **New Features**
- Enhanced plugin management with install, remove, and list commands
supporting bundled plugins and restart control.
- Added plugin persistence and configuration synchronization across API
settings and interfaces.
- Introduced dependency management service for streamlined npm
operations and vendor archive rebuilding.
- **Bug Fixes**
- Improved plugin listing accuracy with warnings for configured but
missing plugins.
- **Chores**
- Refactored CLI modules and services for unified plugin management and
dependency handling.
- Updated API configuration loading and persistence for better
separation of concerns.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-06-12 09:37:36 -04:00
Pujit Mehrotra
c132f28281 chore: extract connect to an API plugin (#1367)
separates Unraid Connect from the API

## Summary by CodeRabbit

- **New Features**
- Introduced a unified, JSON-schema-based settings system for API
configuration and plugin settings, accessible via new GraphQL queries
and mutations.
- Added modular NestJS plugin architecture for Unraid Connect, including
new modules for cloud, remote access, and system/network management.
- Added granular connection and remote access state tracking, with new
GraphQL types and resolvers for cloud and connection status.
- Implemented event-driven and service-based management for SSO users,
API keys, and dynamic remote access.
- Enhanced UI components and queries to support unified settings and
restart detection.

- **Improvements**
- Refactored configuration and state management to use service-based
patterns, replacing direct store access and Redux logic.
- Migrated legacy config files to new JSON formats with validation and
persistence helpers.
- Centralized global dependencies and shared services for plugins and
CLI modules.
- Improved logging, error handling, and lifecycle management for
connections and background jobs.
- Updated and expanded documentation for plugin development and settings
management.

- **Bug Fixes**
- Improved handling of missing config files and ensured safe
persistence.
- Enhanced error reporting and validation in remote access and
connection services.

- **Removals**
- Removed deprecated Redux slices, listeners, and legacy cloud/remote
access logic.
- Deleted obsolete test files, scripts, and unused code related to the
old state/store approach.

- **Tests**
- Added new unit tests for settings merging, URL resolution, and cloud
connectivity checks.

- **Style**
- Applied consistent formatting, import reorganization, and code style
improvements across modules.

- **Chores**
- Updated build scripts, Dockerfiles, and development environment setup
to support new dependencies and workflows.
- Expanded .gitignore and configuration files for improved build
artifact management.
2025-06-10 15:16:26 -04:00
renovate[bot]
106ea09399 fix(deps): update dependency commander to v14 (#1394)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [commander](https://redirect.github.com/tj/commander.js) | [`^13.1.0`
-> `^14.0.0`](https://renovatebot.com/diffs/npm/commander/13.1.0/14.0.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/commander/14.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/commander/14.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/commander/13.1.0/14.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/commander/13.1.0/14.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>tj/commander.js (commander)</summary>

###
[`v14.0.0`](https://redirect.github.com/tj/commander.js/blob/HEAD/CHANGELOG.md#1400-2025-05-18)

[Compare
Source](https://redirect.github.com/tj/commander.js/compare/v13.1.0...v14.0.0)

##### Added

- support for groups of options and commands in the help using low-level
`.helpGroup()` on `Option` and `Command`, and higher-level
`.optionsGroup()` and `.commandsGroup()` which can be used in chaining
way to specify group title for following options/commands
(\[[#&#8203;2328](https://redirect.github.com/tj/commander.js/issues/2328)])
- support for unescaped negative numbers as option-arguments and
command-arguments
(\[[#&#8203;2339](https://redirect.github.com/tj/commander.js/issues/2339)])
- TypeScript: add `parseArg` property to `Argument` class
(\[[#&#8203;2359](https://redirect.github.com/tj/commander.js/issues/2359)])

##### Fixed

- remove bogus leading space in help when option has default value but
not a description
(\[[#&#8203;2348](https://redirect.github.com/tj/commander.js/issues/2348)])
- `.configureOutput()` now makes copy of settings instead of modifying
in-place, fixing side-effects
(\[[#&#8203;2350](https://redirect.github.com/tj/commander.js/issues/2350)])

##### Changed

-   *Breaking:* Commander 14 requires Node.js v20 or higher
- internal refactor of `Help` class adding `.formatItemList()` and
`.groupItems()` methods
(\[[#&#8203;2328](https://redirect.github.com/tj/commander.js/issues/2328)])

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/unraid/api).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4xOCIsInVwZGF0ZWRJblZlciI6IjQwLjExLjE4IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-19 12:17:59 -04:00
Pujit Mehrotra
026b0b344c chore: cli commands for api plugin install & generation (#1352)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a CLI tool to scaffold new Unraid API plugins, including
templates for configuration, persistence, and GraphQL resolvers.
- Added plugin management commands to the CLI for installing, removing,
and listing plugins as peer dependencies.
- Implemented robust configuration state management with validation,
persistence, and error handling.
  - Added scheduled and debounced persistence for configuration changes.
  - Provided utilities for file existence checks and CSV string parsing.
- Enhanced GraphQL schema with new queries and mutations for health
checks and demo configuration.

- **Improvements**
- Updated configuration and environment handling to support modular,
persistent plugin configs.
- Improved logging and error handling throughout CLI and service layers.
- Refined dependency management for plugins, including support for
bundled dependencies.

- **Bug Fixes**
- Improved error handling during Docker service initialization to
prevent unhandled exceptions.

- **Chores**
- Added and updated development dependencies and TypeScript
configurations for better compatibility and type safety.

- **Refactor**
- Restructured internal modules to support dynamic plugin loading and
configuration injection.
  - Removed deprecated plugin schema extension logic and related code.

- **Documentation**
- Updated and added configuration files and templates for easier plugin
development and management.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-04-22 13:30:11 -04:00
Pujit Mehrotra
f65788aa94 refactor(api): use nestjs modules as the api plugin interface (#1321)
Changes plugin interface to expect Nest modules instead of a custom
plain JS object.

## Summary by CodeRabbit

- **New Features**
- Introduced updated health check plugins, including a new connect
plugin exposing a GraphQL health query and configuration logging.

- **Refactor**
- Streamlined the overall plugin registration and management across API,
CLI, and GraphQL modules for improved clarity and logging.
- Simplified the `CliModule` and `PluginService` to reduce complexity
and enhance maintainability.

- **Chores**
- Updated dependency configurations and build scripts while introducing
new TypeScript setups to enhance maintainability and consistency.
- Added new `package.json` and `tsconfig.json` files for the
`unraid-api-plugin-connect` and `unraid-api-plugin-health` projects.
- Modified GitHub Actions workflow to update tag format for pull
requests.
2025-04-08 10:08:32 -04:00
Pujit Mehrotra
4964cf557b chore: update license fields in package.json (#1298)
Sets license for all node.js packages to `GPL-2.0-or-later`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Simplified license compliance verification by removing legacy script
logic.
- Updated licensing terms across components to GPL-2.0-or-later for
broader compatibility.
- **Documentation**
- Revised setup instructions to indicate that the use of the Just build
tool is now optional.
- **New Features**
- Added fallback support in the build automation tool to ensure smoother
operations when targets are missing.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-03-31 14:52:49 -04:00
Pujit Mehrotra
9f492bf217 feat: api plugin system & offline versioned dependency vendoring (#1252)
- **New Features**
- Created a dynamic plugin system for the API to enable community
augmentation of GraphQL, CLI, and Cron functionalities capabilities.
- Included an example plugin under `packages/unraid-api-plugin-health`
that adds a new graphql query for API health checks.
- Added `rc.unraid-api` commands for backing up, restoring, and
installing production dependencies, streamlining maintenance and
deployment.
- Improved dependency vendoring by bundling a versioned pnpm store
(instead of `node_modules`). Versioning will allow users to add plugins
to a specific api release without requiring an internet connection on
subsequent reboots.

- **Chores**
- Upgraded build workflows and versioning processes to ensure more
reliable artifact handling and production packaging.
2025-03-27 13:23:55 -04:00