Skip to content

Move DotrainRegistry core logic from js_api into common#2695

Merged
thedavidmeister merged 5 commits into
mainfrom
2026-06-10-issue-2470
Jun 14, 2026
Merged

Move DotrainRegistry core logic from js_api into common#2695
thedavidmeister merged 5 commits into
mainfrom
2026-06-10-issue-2470

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Summary

Resolves #2470.

DotrainRegistry in crates/js_api/src/registry.rs held platform-agnostic
business logic (registry file parsing, HTTP/data-URI fetching, format
validation, order/deployment metadata extraction, order-builder construction)
trapped in the WASM-only js_api crate, so no native crate (CLI, integration
tests) could reuse it.

This is a scoped move that mirrors the RaindexOrderBuilder extraction
(#2471): the core logic moves into a new platform-agnostic
raindex_common::registry module, and js_api keeps a thin WASM wrapper over
it.

What moved into raindex_common::registry

  • RaindexRegistry core 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 common RaindexOrderBuilder core
    type and no longer threads a js_sys::Function callback (it restores from
    serialized state and falls back to deployment defaults).
  • The native get_raindex_client helper 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::registry

A thin #[wasm_bindgen] / #[wasm_export] wrapper, DotrainRegistry, that:

  • wraps the core RaindexRegistry (inner) and delegates every method,
  • attaches the optional js_sys::Function state-update callback to the builder
    returned by getOrderBuilder,
  • converts core errors into WasmEncodedError / JsValue,
  • keeps the WASM-only getRaindexYaml / getRaindexClient bindings.

The exported JS class name DotrainRegistry is unchanged, so the
@rainlanguage/raindex npm package and its TS/Svelte consumers keep working
without 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.lock change is a pre-existing drift the --locked lint
surfaced (a syn patch bump and removal of the now-unused trezor-client
entry); no dependencies were added by this PR.

🤖 Generated with Claude Code

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>
@thedavidmeister thedavidmeister self-assigned this Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@thedavidmeister, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8ec45a68-ef1d-47ca-abc9-62ca0967dd87

📥 Commits

Reviewing files that changed from the base of the PR and between 9e9af9d and 70a9aea.

📒 Files selected for processing (4)
  • crates/common/src/lib.rs
  • crates/common/src/registry.rs
  • crates/js_api/src/raindex_order_builder/mod.rs
  • crates/js_api/src/registry.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-10-issue-2470

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

thedavidmeister and others added 2 commits June 10, 2026 17:59
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>
@thedavidmeister thedavidmeister changed the title Move RaindexRegistry core logic from js_api into common Move DotrainRegistry core logic from js_api into common Jun 14, 2026
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>
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

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.

@thedavidmeister thedavidmeister merged commit f245737 into main Jun 14, 2026
17 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

@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:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move RaindexRegistry core logic from js_api to common

2 participants