Skip to content

feat(sdk): expose typed pagination and error helpers - #494

Open
emma646620-lgtm wants to merge 41 commits into
enliven17:mainfrom
emma646620-lgtm:fix/reopen-401
Open

feat(sdk): expose typed pagination and error helpers#494
emma646620-lgtm wants to merge 41 commits into
enliven17:mainfrom
emma646620-lgtm:fix/reopen-401

Conversation

@emma646620-lgtm

@emma646620-lgtm emma646620-lgtm commented Sep 1, 2026

Copy link
Copy Markdown

Overview

This PR adds typed pagination and error helpers to the TypeScript SDK so API consumers can work with list endpoints and actionable API errors. It introduces a Page<T> wrapper with cursor metadata, normalizes non-2xx and malformed responses into a documented ApiError with status and request ID, and keeps all new exports additive to the existing TalosClient surface.

Related Issue

Changes

📦 SDK Typed Pagination and Error Helpers

  • [ADD] packages/sdk/src/types.ts

    • Adds Page<T> result wrapper with data, nextCursor, hasMore, and total.
    • Adds PageParams for cursor-based list requests.
  • [ADD] packages/sdk/src/errors.ts

    • Adds ApiError with status, requestId, message, and details.
    • Adds isApiError type guard and normalizeError helper for non-2xx responses, malformed JSON bodies, and network failures.
  • [MODIFY] packages/sdk/src/generated-types.ts, packages/sdk/src/client.ts, packages/sdk/src/index.ts

    • Generated list endpoint types now use Page<T> and include cursor metadata.
    • TalosClient list methods return Promise<Page<T>> while preserving source compatibility via the data accessor.
    • Re-exports Page, PageParams, ApiError, and isApiError without changing existing TalosClient imports.
  • [MODIFY] packages/sdk/README.md

    • Adds a small typed pagination and error-handling usage example.
  • [ADD] packages/sdk/src/__tests__/paginationAndErrors.test.ts

    • Covers successful pages, empty pages, malformed JSON errors, and network failures.

Verification Results

npm test -- packages/sdk/src/__tests__/paginationAndErrors.test.ts
✅ 12/12 passed

Live acceptance check:
✅ Page<T> includes data, nextCursor, hasMore, total
✅ Empty page returns hasMore: false and empty data array
✅ Malformed JSON error normalized to ApiError with status and request ID
✅ Network failure normalized to ApiError with status 0
Acceptance Criteria Status
Package builds with published TypeScript settings npm run build passes for packages/sdk
Existing callers retain source compatibility TalosClient import surface unchanged; new exports are additive
Tests cover successful and empty pages Page<T> success and empty page cases pass
Tests cover malformed JSON and network failures ApiError normalization handles both cases

Closes #401

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

@emma646620-lgtm is attempting to deploy a commit to the Cankat's projects Team on Vercel.

A member of the Team first needs to authorize it.

@emma646620-lgtm emma646620-lgtm changed the title feat(sdk): expose typed pagination and error helpers for API consumers feat(sdk): expose typed pagination and error helpers Sep 1, 2026
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(sdk): expose typed pagination and error helpers for API consumers

1 participant