Skip to content

feat: add TypeScript SDK source and build configuration#5

Open
Atharva0506 wants to merge 3 commits into
AOSSIE-Org:mainfrom
Atharva0506:feat/add-sdk-source
Open

feat: add TypeScript SDK source and build configuration#5
Atharva0506 wants to merge 3 commits into
AOSSIE-Org:mainfrom
Atharva0506:feat/add-sdk-source

Conversation

@Atharva0506

@Atharva0506 Atharva0506 commented Jul 13, 2026

Copy link
Copy Markdown
Member

Addressed Issues:

Fixes #(issue number)
Initializes the complete TypeScript SDK source code, build tooling, and project configuration aligned with AOSSIE npm package standards.

Screenshots/Recordings:

Additional Notes:

Commit 1 Build tooling & config:

  • package.json: Dual ESM/CJS, type: "module", publishConfig for npm, GPL-3.0 license
  • tsconfig.json: Strict mode with noUncheckedIndexedAccess, noUnusedLocals, noUnusedParameters
  • tsup.config.ts: ESM + CJS output, sourcemaps, ES2020 target
  • eslint.config.js: Flat config with typescript-eslint (matches IndexedDB-Import-Export)
  • .prettierrc: AOSSIE standard formatting rules
  • vitest.config.ts: Test runner configuration

Commit 2 SDK source code:

  • src/client.ts: RelayClient class (native fetch, auto-retry with exponential backoff)
  • src/errors.ts: Typed error hierarchy (RelayError, RateLimitError, PayloadTooLargeError, etc.)
  • src/types.ts: Message, ClientOptions, HealthResponse type definitions
  • src/index.ts: Public API barrel export
    Zero runtime dependencies. Works in Node.js 18+ and modern browsers.

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

Summary by CodeRabbit

  • New Features
    • Added a typed client for sending, receiving, deleting, and monitoring relay messages.
    • Added health checks, configurable polling, API key support, timeouts, and retries.
    • Added clear error types for authentication, rate limits, missing messages, oversized payloads, and network failures.
    • Added TypeScript types for messages, requests, configuration, polling, and health responses.
  • Developer Experience
    • Added package build, test, lint, formatting, and coverage tooling.
    • Added published ESM, CommonJS, and TypeScript declaration outputs.

Set up the TypeScript SDK build infrastructure, aligned with AOSSIE
npm package standards (IndexedDB-Import-Export reference):

- package.json: dual ESM/CJS, type:module, publishConfig for npm,
  bugs/homepage URLs, GPL-3.0 license, eslint + prettier deps
- tsconfig.json: strict mode with noUncheckedIndexedAccess,
  noUnusedLocals, noUnusedParameters
- tsup.config.ts: ESM + CJS output, sourcemaps, ES2020 target
- eslint.config.js: flat config with typescript-eslint
- .prettierrc: AOSSIE standard formatting rules
- vitest.config.ts: test runner configuration
Add the core SDK implementation — a zero-dependency TypeScript client
for the ThruBox Server relay:

- src/client.ts:  RelayClient class with send, receive, delete, poll,
                  health. Automatic retry with exponential backoff on
                  5xx/network errors. Configurable timeout via
                  AbortController.
- src/types.ts:   Message, CreateMessageParams, ClientOptions,
                  HealthResponse type definitions.
- src/errors.ts:  Typed error hierarchy (RelayError, NetworkError,
                  HttpError, RateLimitError, PayloadTooLargeError,
                  NotFoundError).
- src/index.ts:   Public API barrel export.
@github-actions github-actions Bot added no-issue-linked PR is not linked to any issue configuration Configuration file changes dependencies Dependency file changes javascript JavaScript/TypeScript code changes size/XL Extra large PR (>500 lines changed) repeat-contributor PR from an external contributor who already had PRs merged needs-review labels Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Atharva0506, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 317d78ad-5054-4ff6-95bd-eb8ff95693ab

📥 Commits

Reviewing files that changed from the base of the PR and between c58d70a and 6cda706.

📒 Files selected for processing (4)
  • package.json
  • src/client.ts
  • src/types.ts
  • vitest.config.ts

Walkthrough

Adds a typed AOSSIE Relay client SDK with message operations, polling, retries, timeouts, typed errors, public exports, package metadata, build settings, and development tooling.

Changes

Relay SDK

Layer / File(s) Summary
SDK contracts and typed errors
src/types.ts, src/errors.ts
Defines public message, request, client configuration, polling, health, and typed relay error contracts.
RelayClient request and polling flow
src/client.ts
Implements send, receive, delete, health, polling, API-key headers, timeouts, retries, and HTTP error mapping.
Public entrypoint and package build
src/index.ts, package.json, tsconfig.json, tsup.config.ts
Exports the SDK surface and configures ESM/CJS packaging, declarations, source maps, and published output.
Lint, format, and test configuration
eslint.config.js, .prettierrc, vitest.config.ts
Configures TypeScript linting, formatting rules, test discovery, and coverage reporters.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant RelayClient
  participant RelayServer
  Caller->>RelayClient: Send or poll messages
  RelayClient->>RelayServer: HTTP request with optional API key
  RelayServer-->>RelayClient: JSON response or HTTP error
  RelayClient-->>Caller: Result, callback, or typed error
Loading

Suggested labels: Typescript Lang

Poem

I’m a rabbit with a client in tow,
Through relay paths the messages go.
Errors wear names, retries hop bright,
Polling keeps watch through day and night.
Build and tests now bloom just right!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding the TypeScript SDK source and build/tooling configuration.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@socket-security

socket-security Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​vitest/​coverage-v8@​3.2.7991007299100
Addednpm/​typescript-eslint@​8.63.01001007498100
Addednpm/​vitest@​3.2.7981007999100
Addednpm/​tsup@​8.5.1981009583100
Addednpm/​typescript@​5.9.31001009010090
Addednpm/​@​eslint/​js@​10.0.110010010093100
Addednpm/​prettier@​3.9.5961009498100
Addednpm/​eslint@​10.7.09810010097100

View full report

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
Messages
📖

⚠️ PR Template Check

These are non-blocking, but please fix:

  • Please replace the placeholder Fixes #(issue number) with the actual issue number (e.g. Fixes #42).

  • Some required checklist items are not completed:

  • My PR addresses a single issue

Generated by 🚫 dangerJS against 6cda706

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/client.ts`:
- Around line 138-145: Update the polling flow around receive and callback
execution so only the request in receive is handled by the catch, reporting
failures through the existing typed error handler instead of silently ignoring
them. Move callback(messages) outside that catch so user callback exceptions
propagate normally, while preserving the stopped check.
- Around line 55-56: Validate the option assignments in the client
initialization and the polling configuration around the referenced code: require
timeout and interval values to be finite and strictly positive, and require
retries to be a finite non-negative integer. Reject invalid values before
storing or using them, while preserving the existing defaults when options are
omitted.
- Around line 180-189: Update the retry loop in the client send flow around
fetch so non-idempotent POST requests are not automatically retried after
timeout or failure. Restrict retries to idempotent HTTP methods, or use a
server-supported idempotency key for sends; preserve existing retry behavior for
safe methods and ensure the logic also covers the corresponding handling around
lines 230-257.
- Around line 182-199: Update the fetch attempt in the client method containing
the AbortController and response body parsing so the timeout remains active
through json()/text() consumption. Wrap the complete fetch, status handling, and
body-reading flow in try/finally, and clear timeoutId only in the finally block
so rejected fetches and body-read failures always clean up the timer.
- Around line 148-151: Update the polling flow around doPoll and intervalId to
prevent concurrent async requests: replace the recurring setInterval scheduling
with a self-scheduling setTimeout that starts the next poll only after doPoll()
settles, while preserving the immediate first poll and existing polling
interval.
- Around line 51-53: Update the Client constructor to parse baseUrl once with
URL, reject malformed values and any protocol other than http: or https:, and
store the normalized URL. In the request-building logic near the additional
occurrence, construct paths with new URL(path, baseUrl) rather than string
concatenation or direct interpolation, ensuring user input is not inserted
directly into URLs.
- Around line 170-172: Update the headers construction in the client request
flow to include Content-Type only when a JSON body is present. Ensure GET and
DELETE requests without bodies omit this header while preserving
application/json for requests that send JSON.
- Around line 216-221: Update the 429 handling near RelayRateLimitError to parse
Retry-After as either numeric delta-seconds or an HTTP-date converted to a
numeric delay in seconds. Use the existing 60-second fallback only when the
header is missing or invalid, ensuring retryAfter is always numeric.

In `@vitest.config.ts`:
- Around line 4-8: Update the test workflow associated with the Vitest
configuration so coverage collection is explicitly enabled, since
test.coverage.reporter only selects report formats. Modify the existing test
script or add a dedicated coverage script to invoke Vitest with the coverage
flag, ensuring CI runs generate the configured text and lcov reports.
- Around line 6-8: Add a supported Vitest coverage provider dependency and
configure the coverage settings in the Vitest configuration to use it, ensuring
the existing text and lcov reporters continue to work when running vitest
--coverage. Alternatively, remove the coverage block if coverage is not intended
to be supported.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b55a54bb-071f-4b15-ac4e-b02b72d33cfb

📥 Commits

Reviewing files that changed from the base of the PR and between b88e93d and c58d70a.

📒 Files selected for processing (10)
  • .prettierrc
  • eslint.config.js
  • package.json
  • src/client.ts
  • src/errors.ts
  • src/index.ts
  • src/types.ts
  • tsconfig.json
  • tsup.config.ts
  • vitest.config.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • AOSSIE-Org/ThruBox-Server (manual)

Comment thread src/client.ts Outdated
Comment thread src/client.ts
Comment thread src/client.ts
Comment thread src/client.ts Outdated
Comment thread src/client.ts Outdated
Comment thread src/client.ts Outdated
Comment thread src/client.ts Outdated
Comment thread src/client.ts Outdated
Comment thread vitest.config.ts
Comment thread vitest.config.ts
- client.ts: Validated and normalized baseUrl using URL parser
- client.ts: Rejected invalid timeout, retry, and polling values
- client.ts: Added onError callback to PollOptions to prevent swallowing errors
- client.ts: Used recursive setTimeout for polling to prevent overlapping requests
- client.ts: Fixed headers to only send application/json for POST/PUT/PATCH
- client.ts: Disabled automatic retries for non-idempotent POST requests
- client.ts: Wrapped fetch in try/finally to ensure timeout is cleared during body consumption
- client.ts: Added proper HTTP-date parsing for Retry-After headers
- vitest.config.ts / package.json: Added @vitest/coverage-v8 provider and coverage script
@Atharva0506
Atharva0506 force-pushed the feat/add-sdk-source branch from ca091a6 to 6cda706 Compare July 13, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Configuration file changes dependencies Dependency file changes javascript JavaScript/TypeScript code changes needs-review no-issue-linked PR is not linked to any issue repeat-contributor PR from an external contributor who already had PRs merged size/XL Extra large PR (>500 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant