fix(client): Fix CI configuration, prevent socket hangs with auto-drain, and apply various client/core TypeScript fixes and test updates
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
# SmartRequest Architecture Hints
|
||||
|
||||
## Core Features
|
||||
|
||||
- supports http
|
||||
- supports https
|
||||
- supports https
|
||||
- supports unix socks
|
||||
- supports formData
|
||||
- supports file uploads
|
||||
@@ -15,17 +16,19 @@
|
||||
- used in modules like @push.rocks/smartproxy and @api.global/typedrequest
|
||||
|
||||
## Architecture Overview (as of v3.0.0 major refactoring)
|
||||
|
||||
- The project now has a multi-layer architecture with platform abstraction
|
||||
- Base layer (ts/core_base/) contains abstract classes and unified types
|
||||
- Node.js implementation (ts/core_node/) uses native http/https modules
|
||||
- Fetch implementation (ts/core_fetch/) uses Fetch API for browser compatibility
|
||||
- Core module (ts/core/) dynamically selects the appropriate implementation based on environment
|
||||
- Client API (ts/client/) provides a fluent, chainable interface
|
||||
- Client API (ts/client/) provides a fluent, chainable interface
|
||||
- Legacy API has been completely removed in v3.0.0
|
||||
|
||||
## Key Components
|
||||
|
||||
### Core Base Module (ts/core_base/)
|
||||
|
||||
- `request.ts`: Abstract CoreRequest class defining the request interface
|
||||
- `response.ts`: Abstract CoreResponse class with fetch-like API
|
||||
- Defines `stream()` method that always returns web-style ReadableStream
|
||||
@@ -35,6 +38,7 @@
|
||||
- Implementations handle unsupported options by throwing errors
|
||||
|
||||
### Core Node Module (ts/core_node/)
|
||||
|
||||
- `request.ts`: Node.js implementation using http/https modules
|
||||
- Supports unix socket connections and keep-alive agents
|
||||
- Converts Node.js specific options from unified interface
|
||||
@@ -44,6 +48,7 @@
|
||||
- Methods like `json()`, `text()`, `arrayBuffer()` handle parsing
|
||||
|
||||
### Core Fetch Module (ts/core_fetch/)
|
||||
|
||||
- `request.ts`: Fetch API implementation for browsers
|
||||
- Throws errors for Node.js specific options (agent, socketPath)
|
||||
- Native support for CORS, credentials, and other browser features
|
||||
@@ -52,27 +57,32 @@
|
||||
- `streamNode()` throws error explaining it's not available in browser
|
||||
|
||||
### Core Module (ts/core/)
|
||||
|
||||
- Dynamically loads appropriate implementation based on environment
|
||||
- Uses @push.rocks/smartenv for environment detection
|
||||
- Exports unified types from core_base
|
||||
|
||||
### Client API (ts/client/)
|
||||
|
||||
- SmartRequest: Fluent API with method chaining
|
||||
- Returns CoreResponse objects with fetch-like methods
|
||||
- Supports pagination, retries, timeouts, and various response types
|
||||
|
||||
### Stream Handling
|
||||
|
||||
- `stream()` method always returns web-style ReadableStream<Uint8Array>
|
||||
- In Node.js, converts native streams to web streams
|
||||
- `streamNode()` available only in Node.js environment for native streams
|
||||
- Consistent API across platforms while preserving platform-specific capabilities
|
||||
|
||||
### Binary Request Handling
|
||||
|
||||
- Binary requests handled through ArrayBuffer API
|
||||
- Response body kept as Buffer/ArrayBuffer without string conversion
|
||||
- No automatic transformations applied to binary data
|
||||
|
||||
## Testing
|
||||
|
||||
- Use `pnpm test` to run all tests
|
||||
- Tests use @git.zone/tstest/tapbundle for assertions
|
||||
- Separate test files for Node.js (test.node.ts) and browser (test.browser.ts)
|
||||
|
Reference in New Issue
Block a user