Move DotrainRegistry core logic from js_api into common#2695
Conversation
The registry business logic (file-format parsing, HTTP/data-URI fetching, format validation, order/deployment metadata extraction, order-builder construction) lived in the WASM-only `js_api` crate, so no native crate could reuse it. Extract it into a new platform-agnostic `raindex_common::registry` module: - `RaindexRegistry` core struct + `RaindexRegistryError` carry all the fetching/parsing/validation logic with no WASM dependencies. The native `get_raindex_client` helper and all native (`httpmock`/`tokio`) tests move here too. - `RaindexRegistry::get_order_builder` returns the common `RaindexOrderBuilder` core type and no longer threads a `js_sys::Function` callback. `js_api::registry` keeps `DotrainRegistry` as a thin `#[wasm_bindgen]` / `#[wasm_export]` wrapper over the core: it delegates to the inner type, attaches the optional `js_sys::Function` state-update callback to the returned builder, converts errors to `WasmEncodedError`/`JsValue`, and keeps the WASM-only `getRaindexYaml`/`getRaindexClient` bindings. The exported JS class name `DotrainRegistry` is unchanged, so the npm package and its TS/Svelte consumers keep working. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 40 minutes and 7 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Harden the registry parse/validate/error-path tests that moved from js_api into raindex_common so mutations in the moved core are caught by discriminating assertions rather than bare is_err()/is_ok(): - test_parse_invalid_registry_content: assert the exact InvalidRegistryFormat message for the empty, first-line-with-space, and order-entry-format cases, and add a three-token entry case that exercises the parts.len() != 2 branch from the too-many side. - test_validate_invalid_registry: assert validate() surfaces the exact InvalidRegistryFormat variant and message from parse. - test_error_readable_messages: cover the remaining to_readable_msg arms (SettingsFetchError, OrderFetchError, InvalidRegistryFormat, HttpError, DataUriError, UrlParseError) with exact strings. - Add data-URI decode coverage for the missing-separator and non-UTF-8-payload branches of decode_data_uri_content. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR #2695 moved the registry core from js_api into crates/common/src/registry.rs but erroneously renamed the core struct and error to RaindexRegistry / RaindexRegistryError. The registry parses dotrain registry files and serves dotrain order strategies, so the correct name is DotrainRegistry. Rename the moved core back: - RaindexRegistry -> DotrainRegistry - RaindexRegistryError -> DotrainRegistryError and update the js_api import aliases to match (RaindexRegistryInner -> DotrainRegistryInner, RaindexRegistryCoreError -> DotrainRegistryCoreError). The public #[wasm_bindgen] class stays DotrainRegistry. Genuine raindex types (RaindexClient, RaindexOrderBuilder) are untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Resolve conflict in crates/js_api/src/registry.rs by taking the PR's thin-wrapper structure (registry core moved into raindex_common::registry). main's #2691 native get_raindex_yaml change and goldsky-URL test-fixture updates are already in this branch's history; the registry move supersedes the inline js_api implementation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Reviewed 70a9aea: moves DotrainRegistry core from js_api into common (approved incl. the unused get_raindex_yaml drop + the two infallible signatures); DotrainRegistry naming preserved, 1103 tests green, rebased on green main, all checks green. LGTM. |
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
Summary
Resolves #2470.
DotrainRegistryincrates/js_api/src/registry.rsheld platform-agnosticbusiness logic (registry file parsing, HTTP/data-URI fetching, format
validation, order/deployment metadata extraction, order-builder construction)
trapped in the WASM-only
js_apicrate, so no native crate (CLI, integrationtests) could reuse it.
This is a scoped move that mirrors the
RaindexOrderBuilderextraction(#2471): the core logic moves into a new platform-agnostic
raindex_common::registrymodule, andjs_apikeeps a thin WASM wrapper overit.
What moved into
raindex_common::registryRaindexRegistrycore struct +RaindexRegistryError— all fetching,parsing, validation, and metadata logic, with no WASM dependencies.
get_all_order_details/get_order_keys/get_deployment_details.get_order_builder, which now returns the commonRaindexOrderBuildercoretype and no longer threads a
js_sys::Functioncallback (it restores fromserialized state and falls back to deployment defaults).
get_raindex_clienthelper and all native (httpmock/tokio)tests, which now run on the standard host target. Pure-logic tests
(
parse_registry_content, getters, error messages, etc.) are now plain#[test]s instead of#[wasm_bindgen_test].What stays in
js_api::registryA thin
#[wasm_bindgen]/#[wasm_export]wrapper,DotrainRegistry, that:RaindexRegistry(inner) and delegates every method,js_sys::Functionstate-update callback to the builderreturned by
getOrderBuilder,WasmEncodedError/JsValue,getRaindexYaml/getRaindexClientbindings.The exported JS class name
DotrainRegistryis unchanged, so the@rainlanguage/raindexnpm package and its TS/Svelte consumers keep workingwithout any changes.
Testing
cargo build -p raindex_common -p raindex_js_api(host) — clean.cargo build -p raindex_js_api --target wasm32-unknown-unknown— clean.cargo test -p raindex_common registry::— 27 passed, 0 failed.rainix-rs-static(clippy-D warnings -D clippy::all,--locked) — clean.The only
Cargo.lockchange is a pre-existing drift the--lockedlintsurfaced (a
synpatch bump and removal of the now-unusedtrezor-cliententry); no dependencies were added by this PR.
🤖 Generated with Claude Code