Skip to content

dx: Create shared types package to eliminate type duplication #206

@Xhristin3

Description

@Xhristin3

Problem Statement

Types are duplicated across SDK, app, and API layers:

  • xstreamroll-sdk/src/types.ts — Stream, StreamEvent, AuthTokens, etc.
  • app/lib/api/tags.ts — Tag, PagedTags
  • app/lib/api/admin-stats.ts — AdminStats
  • app/lib/api/notifications.ts — Notification
  • api/src/streams/stream.entity.ts — Stream
  • api/src/tags/tag.entity.ts — Tag

A change to Stream structure requires updates in 3+ files across 3 packages.

Evidence

Type definitions for Tag, Stream, PaginationParams, etc. exist independently in SDK, API, and app.

Impact

Type drift between packages. If the API changes a field, the SDK and app types may go out of sync silently. High maintenance overhead for any schema change.

Proposed Solution

Extract shared types into a new packages/types/ (or @xstreamroll/types) package:

  • packages/types/src/stream.ts
  • packages/types/src/auth.ts
  • packages/types/src/tag.ts
  • packages/types/src/pagination.ts
  • packages/types/src/errors.ts

All three consuming packages import from @xstreamroll/types.

Acceptance Criteria

  • Types package exists with all shared interfaces
  • SDK imports types from shared package
  • API imports types from shared package
  • App imports types from shared package
  • No type duplication remains
  • All existing tests pass

File Map

  • packages/types/package.json — new
  • packages/types/src/*.ts — new type files
  • packages/types/tsconfig.json — new
  • root package.json — add workspace
  • xstreamroll-sdk/src/types.ts — replace with re-exports
  • app/lib/api/*.ts — import from @xstreamroll/types

Dependencies

  • Blocked by: Requires monorepo workspace configuration

Labels: dx, refactoring
Priority: Medium | Difficulty: Advanced | Estimated Effort: 2d


Labels: dx,refactoring
Priority: Medium | Difficulty: Advanced | Estimated Effort: 2d
Backlog ID: REPO-023

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions