Skip to content

Move RaindexRegistry core logic from js_api to common #2470

@findolor

Description

@findolor

Summary

DotrainRegistry in crates/js_api/src/registry.rs (~1,639 lines) contains platform-agnostic business logic trapped in the WASM-only crate. No other Rust crate can depend on js_api, so CLI and integration tests can't reuse registry functionality. Rename from DotrainRegistry to RaindexRegistry for consistency with Raindex* naming convention.

What needs to move

Core logic (~90% of the file):

  • Registry file format parsing (parse_registry_content)
  • HTTP fetching of registry, settings, and order files
  • Registry format validation
  • Order metadata extraction (name/description from dotrain configs)
  • Error type: DotrainRegistryErrorRaindexRegistryError

Key renames

  • DotrainRegistryRaindexRegistry
  • DotrainRegistryErrorRaindexRegistryError

What stays in js_api

Thin WASM wrapper (~10%):

  • #[wasm_bindgen] struct decorator and #[wasm_export] method attributes
  • js_sys::Function callback parameter for state updates
  • JsValue error conversions
  • Wrapper methods that delegate to the core implementation

Proposed approach

  1. Create common::registry module with the core RaindexRegistry struct and logic
  2. Keep js_api::registry as a thin wrapper that re-exports/wraps the core type with WASM annotations
  3. Replace js_sys::Function callbacks with a Rust trait or generic callback

Benefits

  • CLI can implement native registry support
  • Integration tests can test registry logic without WASM
  • Reduces coupling between business logic and platform bindings
  • Consistent Raindex* naming across the codebase

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions