Skip to content

feat(core): typed REST client + error model + idempotency#23

Merged
aguilar1x merged 1 commit into
PACTO-LAT:mainfrom
gabvega08:feat/typed-rest-client-idempotency
Jun 17, 2026
Merged

feat(core): typed REST client + error model + idempotency#23
aguilar1x merged 1 commit into
PACTO-LAT:mainfrom
gabvega08:feat/typed-rest-client-idempotency

Conversation

@gabvega08

@gabvega08 gabvega08 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add typed REST client (PactoApiClient) for listings, quotes, and escrows, exposed via client.api(session) using the session clientSecret.
  • Implement error hierarchy: PactoAuthError, PactoRateLimitError, PactoEscrowError, PactoApiError with HTTP-to-class mapping via errorFromResponse.
  • Add HTTP layer with Idempotency-Key on write operations (reused across retries), exponential backoff + jitter for 5xx/429/network failures.

Closes #13

Test plan

  • npm run lint
  • npm run type-check
  • npm run test
  • Idempotency-Key reused on retry (same key on 500 → 200)
  • Error mapping: 401/403 → Auth, 429 → RateLimit, escrow → EscrowError
  • GET requests do not send Idempotency-Key
  • Manual: create session, call client.api(session).escrows.create(...) against Gateway once proxy routes exist

@aguilar1x aguilar1x merged commit 2707cd2 into PACTO-LAT:main Jun 17, 2026
1 check passed
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.

feat(core): typed REST client + error model + idempotency

2 participants