Overview
Implement a type-safe function for converting strongly typed subtitle data objects into multiple output formats (SRT, VTT, plain text). The function should be built using EffectTS and be completely environment agnostic, supporting browser, Node.js, Bun, Cloudflare Workers, and AWS Lambda environments.
Business Context
Our API currently returns subtitle data in raw JSON format. We need to provide users with flexibility to choose their preferred output format(s) when consuming our API. This will improve user experience and reduce client-side processing requirements.
Requirements
Core Functionality
- Accept strongly typed subtitle data object as input
- Support multiple output format conversions from a single source object
- Provide type-safe error handling throughout the conversion process
- Enable users to request one or multiple output formats in a single API call
- Integrate seamlessly with existing codebase architecture
Supported Output Formats
- JSON - Serialized JSON string from the typed object (current default)
- SRT - SubRip subtitle format
- VTT - WebVTT (Web Video Text Tracks) format
- Plain Text - Formatted as readable sentences with logical paragraph breaks
Technical Constraints
- Must use EffectTS for implementation
- Must be environment agnostic (no environment-specific APIs)
- All errors must be type-safe and properly typed
- Input is strongly typed object, output is string
- No dependencies on Node.js-specific modules, browser-specific APIs, or any environment-specific features
Acceptance Criteria
Function Implementation
Format Conversions
API Integration
Error Handling
Type Safety
Testing
Documentation
Implementation Notes
- Define clear interface/type for the subtitle data object
- Follow existing codebase patterns for Effect usage
- Place function in appropriate utility module following project structure
- Ensure function signature aligns with existing use-case layer expectations
- Consider performance implications when multiple formats are requested
Success Metrics
- Users can successfully convert subtitle data to their preferred format(s)
- Zero runtime errors due to type mismatches
- Function works identically across all target environments
- API response time remains consistent regardless of output format
- Seamless integration with no breaking changes to existing functionality
Overview
Implement a type-safe function for converting strongly typed subtitle data objects into multiple output formats (SRT, VTT, plain text). The function should be built using EffectTS and be completely environment agnostic, supporting browser, Node.js, Bun, Cloudflare Workers, and AWS Lambda environments.
Business Context
Our API currently returns subtitle data in raw JSON format. We need to provide users with flexibility to choose their preferred output format(s) when consuming our API. This will improve user experience and reduce client-side processing requirements.
Requirements
Core Functionality
Supported Output Formats
Technical Constraints
Acceptance Criteria
Function Implementation
Format Conversions
API Integration
Error Handling
Type Safety
Testing
Documentation
Implementation Notes
Success Metrics