201 lines
12 KiB
Rust
201 lines
12 KiB
Rust
// file: crates/ksp-app-config-desk/src/lib.rs
|
|
// version: 16
|
|
|
|
//! Tauri desktop application for managing and validating KSP configuration.
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![deny(unreachable_pub)]
|
|
#![warn(missing_docs)]
|
|
|
|
mod app_state;
|
|
mod bootstrap;
|
|
mod constants;
|
|
mod documents;
|
|
mod dto_common;
|
|
mod environment;
|
|
mod errors;
|
|
mod frontend_logging;
|
|
mod logging_editor;
|
|
mod logging_runtime;
|
|
mod logging_test;
|
|
mod profiles;
|
|
mod secrets;
|
|
mod splash;
|
|
mod tauri;
|
|
mod tw_main;
|
|
mod tw_splash;
|
|
|
|
/// Runs the KSP configuration desktop application.
|
|
pub use self::tauri::run;
|
|
|
|
/// Shared Config Desk application state managed by Tauri.
|
|
pub(crate) use self::app_state::AppState;
|
|
/// Crate-internal `LoggingStartup` state shared across the owning crate.
|
|
pub(crate) use self::bootstrap::LoggingStartup;
|
|
/// Executes the crate-internal config management operation for the owning module.
|
|
pub(crate) use self::bootstrap::config_management;
|
|
/// Executes the crate-internal initialize logging operation for the owning module.
|
|
pub(crate) use self::bootstrap::initialize_logging;
|
|
/// Structured domain used while bootstrapping Config and Logging.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_BOOTSTRAP;
|
|
/// Structured domain for Config document inventory, diagnostics and repair.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_DOCUMENTS;
|
|
/// Structured domain for safe Config environment reports.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_ENVIRONMENT;
|
|
/// Structured domain used by technical frontend events.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_FRONTEND;
|
|
/// Structured domain for typed Logging editor inspection.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_LOGGING_EDITOR;
|
|
/// Structured domain for active Logging runtime metadata and explicit profile application.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_LOGGING_RUNTIME;
|
|
/// Structured domain used by controlled Logging test events.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_LOGGING_TEST;
|
|
/// Structured domain for Config profile selection and provenance inspection.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_PROFILES;
|
|
/// Structured domain for explicit privileged Secret reveal operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_SECRETS;
|
|
/// Structured domain used by Tauri window lifecycle operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WINDOWS;
|
|
/// Owning target for backend events emitted by Config Desk.
|
|
pub(crate) use self::constants::TRACING_TARGET;
|
|
/// Owning target for generic frontend events emitted through the KSP bridge.
|
|
pub(crate) use self::constants::TRACING_TARGET_FRONTEND;
|
|
/// Owning target for main-window frontend events.
|
|
pub(crate) use self::constants::TRACING_TARGET_FRONTEND_MAIN;
|
|
/// Owning target for splash-window frontend events.
|
|
pub(crate) use self::constants::TRACING_TARGET_FRONTEND_SPLASH;
|
|
/// Dedicated target used by the controlled Logging test panel.
|
|
pub(crate) use self::constants::TRACING_TARGET_LOGGING_TEST;
|
|
/// Detailed management view for one registered Config document.
|
|
pub(crate) use self::documents::ConfigDocumentDetailDto;
|
|
/// Safe document-specific command error with backend-owned diagnostic classification.
|
|
pub(crate) use self::documents::ConfigDocumentErrorDto;
|
|
/// Result of one validated raw-source repair attempt that reached persistence successfully.
|
|
pub(crate) use self::documents::ConfigDocumentSaveResultDto;
|
|
/// Safe inventory row for one Config document registered by `ksp-config-lib`.
|
|
pub(crate) use self::documents::ConfigDocumentSummaryDto;
|
|
/// Loads one Config document detail, including raw source when Config can read it.
|
|
pub(crate) use self::documents::document_detail;
|
|
/// Lists all Config-kind documents from the Config registry and evaluates their current backend validation state.
|
|
pub(crate) use self::documents::document_inventory;
|
|
/// Validates and atomically persists one raw Config source candidate, then reloads the document detail.
|
|
pub(crate) use self::documents::save_document_source;
|
|
/// Initial application/runtime snapshot exposed to the frontend.
|
|
pub(crate) use self::dto_common::AppSnapshotDto;
|
|
/// Safe command error projection that never serializes arbitrary KSP error context or source values.
|
|
pub(crate) use self::dto_common::CommandErrorDto;
|
|
/// Safe result metadata for one `.env` mutation.
|
|
pub(crate) use self::environment::ConfigEnvironmentChangeDto;
|
|
/// Safe desired/effective environment view exposed to the ordinary Config Desk frontend.
|
|
pub(crate) use self::environment::ConfigEnvironmentReportDto;
|
|
/// Returns the safe environment report owned by Config.
|
|
pub(crate) use self::environment::environment_report;
|
|
/// Removes one `.env` entry exclusively through ConfigManagement.
|
|
pub(crate) use self::environment::remove_environment_value;
|
|
/// Creates or replaces one `.env` entry exclusively through ConfigManagement.
|
|
pub(crate) use self::environment::set_environment_value;
|
|
/// Shared Config Desk application state is internally inconsistent.
|
|
pub(crate) use self::errors::ERROR_CODE_APP_STATE_INVALID;
|
|
/// Shared Config Desk runtime state cannot be locked safely.
|
|
pub(crate) use self::errors::ERROR_CODE_APP_STATE_LOCK_FAILED;
|
|
/// A Documents command requested a registered file that is not a Config-kind document.
|
|
pub(crate) use self::errors::ERROR_CODE_DOCUMENT_KIND_INVALID;
|
|
/// Frontend logging requested an unsupported level.
|
|
pub(crate) use self::errors::ERROR_CODE_FRONTEND_LOG_LEVEL_INVALID;
|
|
/// Frontend logging requested a target outside the application whitelist.
|
|
pub(crate) use self::errors::ERROR_CODE_FRONTEND_LOG_TARGET_INVALID;
|
|
/// Config Desk could not install the managed Logging runtime or its safe fallback.
|
|
pub(crate) use self::errors::ERROR_CODE_LOGGING_BOOTSTRAP_FAILED;
|
|
/// Config Desk persisted a Logging candidate but could not restore the previous source after runtime application failed.
|
|
pub(crate) use self::errors::ERROR_CODE_LOGGING_SOURCE_ROLLBACK_FAILED;
|
|
/// Controlled Logging test request contains an unsupported or invalid selector.
|
|
pub(crate) use self::errors::ERROR_CODE_LOGGING_TEST_REQUEST_INVALID;
|
|
/// A validated Config document does not expose the standard profile contract expected by the Profiles panel.
|
|
pub(crate) use self::errors::ERROR_CODE_PROFILE_CONTRACT_MISSING;
|
|
/// Config profile data could not be projected safely for the frontend.
|
|
pub(crate) use self::errors::ERROR_CODE_PROFILE_PROJECTION_FAILED;
|
|
/// Privileged reveal was requested for a non-Secret KSP/KSPB namespace.
|
|
pub(crate) use self::errors::ERROR_CODE_SECRET_REVEAL_REQUIRES_SECRET;
|
|
/// Privileged reveal requested an unsupported source selector.
|
|
pub(crate) use self::errors::ERROR_CODE_SECRET_REVEAL_SOURCE_INVALID;
|
|
/// Splash readiness was invoked from a window other than the splash window.
|
|
pub(crate) use self::errors::ERROR_CODE_SPLASH_ORIGIN_INVALID;
|
|
/// A KSP desk splash environment duration is malformed or exceeds its safety bound.
|
|
pub(crate) use self::errors::ERROR_CODE_SPLASH_SETTING_INVALID;
|
|
/// Tauri runtime assembly or execution failed.
|
|
pub(crate) use self::errors::ERROR_CODE_TAURI_RUNTIME_FAILED;
|
|
/// A required Tauri window is missing from the configured application runtime.
|
|
pub(crate) use self::errors::ERROR_CODE_TAURI_WINDOW_MISSING;
|
|
/// A Tauri window show/focus/destroy/event operation failed.
|
|
pub(crate) use self::errors::ERROR_CODE_TAURI_WINDOW_OPERATION_FAILED;
|
|
/// Log payload sent by Config Desk frontend scripts.
|
|
pub(crate) use self::frontend_logging::FrontendLogPayloadDto;
|
|
/// Emits one validated frontend event through the KSP Logging facade.
|
|
pub(crate) use self::frontend_logging::emit_frontend_log_event;
|
|
/// Console sink configuration exposed to the editor.
|
|
pub(crate) use self::logging_editor::LoggingConsoleDto;
|
|
/// Complete editable Logging candidate accepted from the frontend.
|
|
pub(crate) use self::logging_editor::LoggingDocumentCandidateDto;
|
|
/// Complete typed Logging document exposed to the editor.
|
|
pub(crate) use self::logging_editor::LoggingDocumentDto;
|
|
/// Result of one validated typed Logging persistence operation.
|
|
pub(crate) use self::logging_editor::LoggingDocumentSaveResultDto;
|
|
/// One persistent file sink exposed to the editor.
|
|
pub(crate) use self::logging_editor::LoggingFileDto;
|
|
/// One Logging sink selector/filter exposed to the editor.
|
|
pub(crate) use self::logging_editor::LoggingOutputFilterDto;
|
|
/// One typed Logging profile exposed to the editor.
|
|
pub(crate) use self::logging_editor::LoggingProfileDto;
|
|
/// One global Logging target override exposed to the editor.
|
|
pub(crate) use self::logging_editor::LoggingTargetFilterDto;
|
|
/// Loads the typed Logging source through ConfigManagement and projects it for the frontend.
|
|
pub(crate) use self::logging_editor::logging_document;
|
|
/// Validates, atomically persists and hot-reloads one typed Logging candidate through ConfigManagement and `ksp-logging-lib`.
|
|
pub(crate) use self::logging_editor::save_logging_document;
|
|
/// Metadata for one currently active persistent Logging file output.
|
|
pub(crate) use self::logging_runtime::LoggingRuntimeFileDto;
|
|
/// Safe observable state of the currently active KSP Logging runtime.
|
|
pub(crate) use self::logging_runtime::LoggingRuntimeStatusDto;
|
|
/// Applies one persisted Logging profile explicitly without changing `default_profile` or the source document.
|
|
pub(crate) use self::logging_runtime::apply_logging_profile;
|
|
/// Executes the crate-internal count to u64 operation for the owning module.
|
|
pub(crate) use self::logging_runtime::count_to_u64;
|
|
/// Creates the stable runtime identity for this Config Desk process launch.
|
|
pub(crate) use self::logging_runtime::launch_identity;
|
|
/// Returns safe metadata for the currently active Logging runtime.
|
|
pub(crate) use self::logging_runtime::logging_runtime_status;
|
|
/// Executes the crate-internal project logging file operation for the owning module.
|
|
pub(crate) use self::logging_runtime::project_logging_file;
|
|
/// Controlled request emitted through the backend KSP Logging facade.
|
|
pub(crate) use self::logging_test::LoggingTestRequestDto;
|
|
/// Safe result metadata for one controlled backend Logging test request.
|
|
pub(crate) use self::logging_test::LoggingTestResultDto;
|
|
/// Emits one controlled backend test request through `ksp-logging-lib` only.
|
|
pub(crate) use self::logging_test::emit_logging_test;
|
|
/// Safe detailed view of one resolved Config profile.
|
|
pub(crate) use self::profiles::ConfigProfileDetailDto;
|
|
/// One Config document that exposes the standard `default_profile` / `profiles` contract.
|
|
pub(crate) use self::profiles::ConfigProfileDocumentDto;
|
|
/// Resolves one default or explicitly selected profile into a safe inspection DTO.
|
|
pub(crate) use self::profiles::profile_detail;
|
|
/// Lists validated Config documents that expose standard profiles.
|
|
pub(crate) use self::profiles::profile_inventory;
|
|
/// Privileged reveal request kept separate from ordinary environment-report DTOs.
|
|
pub(crate) use self::secrets::SecretRevealRequestDto;
|
|
/// Privileged reveal response. This type deliberately does not derive `Clone` or `Debug`.
|
|
pub(crate) use self::secrets::SecretRevealResponseDto;
|
|
/// Reveals one real Secret value only after the dedicated Tauri command has been explicitly invoked.
|
|
pub(crate) use self::secrets::reveal_secret;
|
|
/// Command emitted by Rust to the splash frontend.
|
|
pub(crate) use self::splash::SplashOrderDto;
|
|
/// Runtime timings used by the common desk splash lifecycle.
|
|
pub(crate) use self::splash::SplashSettings;
|
|
/// Resolves the required main window or returns a typed error.
|
|
pub(crate) use self::tw_main::require_main_window;
|
|
/// Shows main window.
|
|
pub(crate) use self::tw_main::show_main_window;
|
|
/// Resolves the required splash window or returns a typed error.
|
|
pub(crate) use self::tw_splash::require_splash_window;
|
|
/// Executes the crate-internal splash frontend ready service operation for the owning module.
|
|
pub(crate) use self::tw_splash::splash_frontend_ready_service;
|