Skip to content

feat(client): publish typed API client package and consume in frontend and agent - #912

Open
xtep103 wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
xtep103:feat/832-typed-api-client
Open

feat(client): publish typed API client package and consume in frontend and agent#912
xtep103 wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
xtep103:feat/832-typed-api-client

Conversation

@xtep103

@xtep103 xtep103 commented Aug 30, 2026

Copy link
Copy Markdown

Resolves #832

Summary of Changes

  1. Created @lodestar/client Package (packages/client/):

    • OpenAPI 3.0.3 Spec (openapi.json): Formal specification covering all backend system, registry, reputation, agent scoring/policy, and activity endpoints.
    • TypeScript Typings (index.d.ts): Typed interfaces for data models, request/response payloads, and the LodestarClient instance.
    • HTTP Client Implementation (index.js): ESM client handling JSON serialization, query formatting, custom timeouts, error wrapping (LodestarApiError), and custom fetch support.
    • Unit Tests (client.test.js): 28 tests verifying all client methods, options, headers, and error handling.
    • Documentation (README.md): Usage examples and reference for JavaScript/TypeScript integrators.
  2. Frontend Refactoring (frontend/lib/contract.ts):

    • Instantiated LodestarClient to manage all backend API calls with strong types.
    • Re-exported shared schemas in frontend/lib/types.ts.
  3. Agent Refactoring (agent/agent.js):

    • Swapped hand-crafted fetchWithTimeout calls in ensureRegistered, checkSpend, recordOutcome, fetchServices, and submitReputation with typed apiClient methods.

Verification

  • Backend & client tests: 26 test files, 399 tests passing (npx vitest run).
  • Agent tests: 2 test files, 50 tests passing (npx vitest run).
  • Frontend tests & build: 22 test suites, 149 tests passing (npm test), and production bundle built successfully (npm run build).

…d and agent

- Add OpenAPI 3.0 spec in packages/client/openapi.json
- Add TypeScript types in packages/client/index.d.ts
- Implement LodestarClient in packages/client/index.js
- Add unit test suite with 28 tests in packages/client/client.test.js
- Refactor frontend/lib/contract.ts to consume LodestarClient
- Refactor agent/agent.js to consume LodestarClient
- Fixes Stellar-Ecosystem#832
@xtep103
xtep103 requested a review from ritik4ever as a code owner August 30, 2026 06:29
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@xtep103 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2aad3d1d-8f96-4304-b19b-281a52c705db


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.

@xtep103

xtep103 commented Sep 6, 2026

Copy link
Copy Markdown
Author

@Stellar-Ecosystem Hi! This PR is open and ready for review — happy to address any feedback. Thanks!

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.

Publish a typed API client package for the backend

1 participant