diff --git a/.github/workflows/typedoc.yml b/.github/workflows/typedoc.yml index 77d2a5e3..3f0afb33 100644 --- a/.github/workflows/typedoc.yml +++ b/.github/workflows/typedoc.yml @@ -9,21 +9,32 @@ jobs: name: Generate & publish API docs runs-on: ubuntu-latest permissions: - # peaceiris/actions-gh-pages pushes to the gh-pages branch, which needs - # write access to repo contents. The default GITHUB_TOKEN is read-only. + # peaceiris/actions-gh-pages needs write access to push to the gh-pages branch. contents: write steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: '20' cache: npm - - run: npm ci || npm install - - run: npx prisma generate - - run: npm run docs:openapi - - run: npx typedoc + + # Install deps (Prisma client is a peer of typedoc-plugin-* if ever added) + - name: Install dependencies + run: npm ci + + # Prisma generate is required so TypeDoc can resolve @prisma/client types + # when it processes db.ts and other modules that import from it. + - name: Generate Prisma client + run: npx prisma generate + + - name: Build TypeDoc HTML + run: npx typedoc + - name: Deploy to gh-pages - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs + # Overwrite only the docs output; keep any other files already on the branch. + keep_files: true diff --git a/docs/cookbook/dashboard-preview.jpg b/docs/cookbook/dashboard-preview.jpg deleted file mode 100644 index 91bee1e3..00000000 Binary files a/docs/cookbook/dashboard-preview.jpg and /dev/null differ diff --git a/docs/cookbook/portfolio.md b/docs/cookbook/portfolio.md deleted file mode 100644 index 08b061bb..00000000 --- a/docs/cookbook/portfolio.md +++ /dev/null @@ -1,52 +0,0 @@ -# Recipe: Portfolio Tracker - -This recipe demonstrates how to build a React dashboard connecting the Wraith API's `/summary` and `/transfers` endpoints to display an address's token holdings and recent activity. - -![Portfolio Dashboard Preview](./dashboard-preview.jpg) - -## Overview - -While Wraith natively indexes Soroban contract events, it exposes a robust REST API perfect for building user-facing dashboards. In this example, we connect two powerful endpoints: - -1. `GET /summary/:address` to calculate the current token balances (net flow) along with total tokens received and sent. -2. `GET /transfers/address/:address` to get a chronological history of all incoming and outgoing token transfers. - -## Runnable Example - -We have provided a complete, deployable Vite + React application in the repository under `examples/portfolio-dashboard`. - -### Quick Start - -1. Ensure the Wraith backend is running locally on port 3000 (see [Quick Start](../../README.md#quick-start)). -2. Navigate to the example directory and start the frontend: - -```bash -cd examples/portfolio-dashboard -npm install -npm run dev -``` - -3. Open `http://localhost:5173` in your browser. - -## Code Walkthrough - -The core logic uses `Promise.all` to fetch data from both endpoints concurrently, minimizing the loading time for the user. - -```typescript -// From examples/portfolio-dashboard/src/App.tsx - -const [summaryRes, transfersRes] = await Promise.all([ - fetch(`${API_URL}/summary/${targetAddress}`), - fetch(`${API_URL}/transfers/address/${targetAddress}?limit=10`) -]); - -const summaryData = await summaryRes.json(); -const transfersData = await transfersRes.json(); -``` - -### Data Structures - -- **Summary endpoint** returns an array of `tokens`, giving us the `displayNetFlow` (current balance) and `contractId`. -- **Transfers endpoint** returns `transfers` containing individual ledger events, marked with a `direction` of `incoming` or `outgoing`. - -By simply formatting this data into a grid of holdings and a table of transfers, you get a fully functional portfolio tracker without needing complex indexer logic on the frontend. diff --git a/typedoc.json b/typedoc.json index ed731a2a..e8d27bc2 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,4 +1,5 @@ { + "name": "Wraith — API Reference", "entryPoints": [ "src/index.ts", "src/api.ts", @@ -9,6 +10,7 @@ "src/events.ts", "src/indexer.ts" ], + "entryPointStrategy": "resolve", "out": "docs", "theme": "default", "readme": "README.md", @@ -18,5 +20,8 @@ "excludeExternals": true, "hideGenerator": false, "sort": "source-order", - "searchInComments": true + "searchInComments": true, + "navigationLinks": { + "GitHub": "https://github.com/Miracle656/wraith" + } }