@ts-pf/protocol 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/PROTOCOL.md CHANGED
@@ -730,7 +730,7 @@ The TypeScript client maps a local failure to a `PFError` with `code: 'INTERNAL'
730
730
  | `x-ts-pf-protocol: 1`, body does not decode | The codec's own `PFError` (`BAD_REQUEST` `Invalid JSON`, `Response body must be a JSON object`, `Invalid RPC envelope`, or `Unsupported content type` from the stream codecs), else `INTERNAL` `Invalid response` with the HTTP status |
731
731
  | Decoded failure envelope | code / message / data from the envelope, `status` = the HTTP status |
732
732
 
733
- `JSONCodec` does not look at the response `Content-Type`; `StreamCodec` and `SseCodec` accept `application/json` (or no content type), `application/jsonl`, and (SSE) `text/event-stream`, and reject others as `Unsupported content type`. A stream response resolves the call at once; a JSONL line or SSE event that does not decode makes the iterator throw the codec's `BAD_REQUEST`, an SSE `error` event whose `data` is a success envelope throws `INTERNAL` `Invalid error event`, and EOF without `event: close` throws `INTERNAL` `Stream truncated`. Unknown SSE event names and comments are skipped. JSONL EOF is success.
733
+ `JsonCodec` does not look at the response `Content-Type`; `StreamCodec` and `SseCodec` accept `application/json` (or no content type), `application/jsonl`, and (SSE) `text/event-stream`, and reject others as `Unsupported content type`. A stream response resolves the call at once; a JSONL line or SSE event that does not decode makes the iterator throw the codec's `BAD_REQUEST`, an SSE `error` event whose `data` is a success envelope throws `INTERNAL` `Invalid error event`, and EOF without `event: close` throws `INTERNAL` `Stream truncated`. Unknown SSE event names and comments are skipped. JSONL EOF is success.
734
734
 
735
735
  Retries are a `CallPlugin`: `createClient` retries nothing by default, and `RetryPlugin`'s default predicate is `isLocalFailure` (network errors and lost connections; never an abort), so it never retries a 5xx, 408, or 429 response unless you pass `retry`. Cross-origin browser clients read `x-ts-pf-protocol` only when the server exposes it (`CORSPlugin` `exposeHeaders: ['x-ts-pf-protocol']`).
736
736
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-pf/protocol",
3
- "version": "0.7.0",
3
+ "version": "1.0.0",
4
4
  "description": "Portable JSON RPC envelope, PFError, and PROTOCOL_VERSION",
5
5
  "keywords": [
6
6
  "ts-pf",
@@ -48,7 +48,7 @@ Writing a codec or transport adapter: `toWireError(error)` is the failure envelo
48
48
 
49
49
  ## Don't
50
50
 
51
- - `JSONCodec`, `RpcCodec`, `PROTOCOL_HEADER`, or `FetchHandler` here.
51
+ - `JsonCodec`, `RpcCodec`, `PROTOCOL_HEADER`, or `FetchHandler` here.
52
52
  - `instanceof PFError` to detect a failure (misses a second copy of the package); use `isPFError`.
53
53
  - Put `status`, `cause`, or `local` in the JSON envelope (`toJSON` omits them).
54
54
  - Redeclare `VALIDATION`, `INTERNAL`, `BAD_REQUEST`, `METHOD_NOT_ALLOWED`, `PAYLOAD_TOO_LARGE` on `.errors()`.