Skip to content

feat(sdk): build validation, unit tests, and npm publish prep#36

Open
Depo-dev wants to merge 3 commits into
devfrom
feat/issue-20-sdk-build-tests
Open

feat(sdk): build validation, unit tests, and npm publish prep#36
Depo-dev wants to merge 3 commits into
devfrom
feat/issue-20-sdk-build-tests

Conversation

@Depo-dev

@Depo-dev Depo-dev commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Completes the TypeScript SDK for Phase 1 ship readiness.

Tests (Vitest, 8 tests — all pass)

Test Description
queryEvents — correct URL + params contractId and limit appear in query string
queryEvents — X-API-Key header Header is set from config
queryEvents — snake→camelCase mapping Response transformed to SorobanEvent
queryEvents — 401 throws UNAUTHORIZED TridentError.code === "UNAUTHORIZED"
queryEvents — 429 throws RATE_LIMITED TridentError.code === "RATE_LIMITED"
getEventById — 200 returns event Correct URL, contractId mapped
getEventById — 404 throws NOT_FOUND TridentError instance with NOT_FOUND code
getEventById — 401 throws UNAUTHORIZED

All tests use vi.stubGlobal('fetch', ...) — no real network calls.

Build

npm run builddist/index.js (CJS), dist/index.mjs (ESM), dist/index.d.ts (types). Build warnings resolved (exports condition order fixed).

npm publish prep

  • version: "0.1.0", name: "@trident-indexer/sdk"
  • "files": ["dist"]
  • README.md with install, usage examples, and full API reference
  • npm pack --dry-run produces trident-indexer-sdk-0.1.0.tgz with 6 files (25.4 kB)

Closes #20

Depo-dev added 3 commits June 3, 2026 16:49
Adds Vitest test suite (8 tests): queryEvents serialises params and sets
X-API-Key header correctly, maps snake_case to camelCase SorobanEvent,
throws TridentError(UNAUTHORIZED/RATE_LIMITED) on 4xx; getEventById
returns parsed event on 200, throws TridentError(NOT_FOUND) on 404 and
TridentError(UNAUTHORIZED) on 401. All tests use vi.stubGlobal(fetch).

Build: npm run build produces dist/index.cjs, dist/index.mjs,
dist/index.d.ts via tsup. npm pack dry-run succeeds.

Package updates: version 0.1.0, test/test:watch scripts, exports
conditions reordered (types first), README with install + usage + error
handling + API reference docs.
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.

1 participant