Skip to main content

data-layer-advanced

Structure a Ledger Wallet data layer where one API response serves several entities. Use when creating or reviewing cross-entity domain/api orchestration with RTK Query, createAsyncThunk, or both, including response validation and tests spanning multiple domain/entity packages.

ソース情報

リポジトリ
LedgerHQ/ledger-live
ソースの最終更新活動
2026年9月18日 13:12
検出された SKILL.md の言語
英語
スター
622
フォーク
491

インストール方法

デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。

ソースファイルを確認

インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。

SKILL.md を表示中

SKILL.md
ソースの指示 · 読み取り専用プレビュー
name
data-layer-advanced
description
Structure a Ledger Wallet data layer where one API response serves several entities. Use when creating or reviewing cross-entity domain/api orchestration with RTK Query, createAsyncThunk, or both, including response validation and tests spanning multiple domain/entity packages.
# Data Layer: Multiple Entities Apply only when one API response maps to several autonomous entities. Use `types-state-mocks` for the rules inside each entity package. Source: [Data Layer Advanced Use Case](https://ledgerhq.atlassian.net/wiki/spaces/WXP/pages/6112641121) ## Split Ownership ```text domain/entity/<first>/src/schema.ts domain/entity/<second>/src/schema.ts domain/api/<orchestrator>/src/api.ts ``` - Let each entity own its schema and inferred type. Add state, selectors, mocks, and tests only when that entity needs them. - Let one `domain/api` package own the cross-entity response contract, request, transformation, and validation. - Keep UI and feature state in `features/flow`. - Keep app composition out of the domain package. ## Process The Response 1. Fetch with RTK Query, `createAsyncThunk`, or both. 2. In the API layer, validate and transform each response collection with its owning entity schema. 3. Keep the result in RTK Query or dispatch the validated entities when slices must be hydrated. Validate the collection before iterating over it: prefer `entitySchema.array().parse(value)` to `.map()` on untrusted data. ## Test The Orchestration - Use entity mock builders when available; otherwise build schema-valid fixtures. - Test RTK Query endpoints, thunks, or their integration according to the chosen orchestration. - When reducers are involved, create a minimal local store or use an existing domain test harness. - Never import an app store or app alias into a domain test. - Assert the validated result, cache entry, and any hydrated slice that the orchestration owns. - Cover transport failure, invalid collection shape, and invalid entity data when relevant.
GitHubで見る