feat(sdk): build validation, unit tests, and npm publish prep#36
Open
Depo-dev wants to merge 3 commits into
Open
feat(sdk): build validation, unit tests, and npm publish prep#36Depo-dev wants to merge 3 commits into
Depo-dev wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the TypeScript SDK for Phase 1 ship readiness.
Tests (Vitest, 8 tests — all pass)
queryEvents— correct URL + paramscontractIdandlimitappear in query stringqueryEvents— X-API-Key headerqueryEvents— snake→camelCase mappingSorobanEventqueryEvents— 401 throwsUNAUTHORIZEDTridentError.code === "UNAUTHORIZED"queryEvents— 429 throwsRATE_LIMITEDTridentError.code === "RATE_LIMITED"getEventById— 200 returns eventcontractIdmappedgetEventById— 404 throwsNOT_FOUNDTridentErrorinstance withNOT_FOUNDcodegetEventById— 401 throwsUNAUTHORIZEDAll tests use
vi.stubGlobal('fetch', ...)— no real network calls.Build
npm run build→dist/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.mdwith install, usage examples, and full API referencenpm pack --dry-runproducestrident-indexer-sdk-0.1.0.tgzwith 6 files (25.4 kB)Closes #20