@yorun-ai/vrpc 0.10.0 → 0.11.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/README.md +15 -5
- package/README.zh-CN.md +15 -5
- package/dist/client.cjs +21 -291
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.es.js +4 -274
- package/dist/data-DOZk_tFi.js +395 -0
- package/dist/data-pemgw5-O.cjs +526 -0
- package/dist/error-payload-MmlaZW_V.js +15 -0
- package/dist/error-payload-dL9RvdTy.cjs +26 -0
- package/dist/http.cjs +1 -1
- package/dist/http.es.js +1 -1
- package/dist/protocol.cjs +18 -0
- package/dist/protocol.d.cts +127 -0
- package/dist/protocol.d.ts +127 -0
- package/dist/protocol.es.js +2 -0
- package/dist/{request-options-gljZwoeI.cjs → request-options-B_uQsyrU.cjs} +5 -16
- package/dist/{request-options-2g2EJjOi.js → request-options-CV6EPON5.js} +1 -12
- package/docs/examples/taro/taro-client.ts +159 -0
- package/docs/examples/taro/taro-transport.ts +77 -0
- package/docs/guides/protocol.md +77 -0
- package/docs/guides/taro.md +145 -0
- package/docs/guides/upgrading-0.11.md +45 -0
- package/docs/guides/usage.md +2 -0
- package/docs/maintainers/architecture.md +7 -1
- package/docs/reference/README.md +27 -5
- package/package.json +11 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Taro integration
|
|
2
|
+
|
|
3
|
+
Use `Taro.request` for network I/O and `@yorun-ai/vrpc/protocol` for encoding, response validation and result handling. The protocol entry is available starting in 0.11.0. The existing browser clients and skelc-generated factories do not change.
|
|
4
|
+
|
|
5
|
+
The package does not export a Taro client factory or Taro-specific types. This guide provides a complete **application-owned** wrapper with data response hooks. Copy it into your application and maintain it there. See [Protocol helpers](./protocol.md) for the shared protocol boundary and [Upgrading to 0.11.0](./upgrading-0.11.md) for migration details.
|
|
6
|
+
|
|
7
|
+
## Copy the adapter
|
|
8
|
+
|
|
9
|
+
Copy both files into the same application directory, for example `src/lib/`:
|
|
10
|
+
|
|
11
|
+
| File | Responsibility |
|
|
12
|
+
| ------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| [taro-client.ts](../examples/taro/taro-client.ts) | Default/per-call options, protocol headers and body, decoded responses, hooks and protocol errors. |
|
|
14
|
+
| [taro-transport.ts](../examples/taro/taro-transport.ts) | `Taro.request`, raw response bytes, native timeout/cancellation and network errors. |
|
|
15
|
+
|
|
16
|
+
Install the dependencies in your existing Taro application:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm add --save-exact @yorun-ai/vrpc@0.11.0 fast-text-encoding@1.0.6
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Taro remains an application dependency. `fast-text-encoding` supplies UTF-8 decoding where the runtime lacks it; it is independent of Fetch compatibility. The wrapper does not create or install `fetch`, `Headers` or `Response`, including in error handlers and response hooks.
|
|
23
|
+
|
|
24
|
+
The official `@tarojs/taro-h5@4.3.3` package itself depends on and imports `whatwg-fetch`. **Leave that official H5 dependency unchanged.** Removing the wrapper's direct dependency does not remove the H5 transitive dependency from the lockfile. Do not replace it with an empty package or modify the official Taro runtime to hide it.
|
|
25
|
+
|
|
26
|
+
## Create one application client
|
|
27
|
+
|
|
28
|
+
The application owns its API URL, authentication and instance-ID storage:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import Taro from "@tarojs/taro";
|
|
32
|
+
import { generateClientInstanceId } from "@yorun-ai/vrpc/protocol";
|
|
33
|
+
import { createTaroVrpcClient } from "./taro-client";
|
|
34
|
+
|
|
35
|
+
function clientInstanceId(): string {
|
|
36
|
+
const key = "demo.vrpc.clientInstanceId";
|
|
37
|
+
const existing = Taro.getStorageSync<string>(key);
|
|
38
|
+
if (existing) return existing;
|
|
39
|
+
const value = generateClientInstanceId();
|
|
40
|
+
Taro.setStorageSync(key, value);
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function createApiClient(prefixUrl: string, accessToken?: string) {
|
|
45
|
+
return createTaroVrpcClient(Taro.request, {
|
|
46
|
+
prefixUrl,
|
|
47
|
+
clientInfo: {
|
|
48
|
+
clientName: "demo.miniapp",
|
|
49
|
+
clientVersion: "1.0.0",
|
|
50
|
+
clientInstanceId: clientInstanceId(),
|
|
51
|
+
},
|
|
52
|
+
timeoutMs: 15_000,
|
|
53
|
+
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Use a complete HTTP(S) invoke prefix without a query or fragment, such as `https://api.example.com/invoke`. The example wrapper defaults to 15 seconds; this is its application policy, not a new default in `createVrpcClient`. Create the client once per application/authentication lifecycle and reuse it. Never place a server secret in a client URL, environment variable or request header.
|
|
59
|
+
|
|
60
|
+
## Use the generated service factory unchanged
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { createItemService } from "./api/catalog/service";
|
|
64
|
+
import { createApiClient } from "./lib/api-client";
|
|
65
|
+
|
|
66
|
+
const client = createApiClient("https://api.example.com/invoke");
|
|
67
|
+
const items = createItemService(client);
|
|
68
|
+
|
|
69
|
+
const list = await items.listItems(null);
|
|
70
|
+
const detail = await items.getItem({ id: "example" });
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Replace the illustrative service import and method names with your generated SDK. Generated methods still call `client.invoke()` with their service/method names, parameters, per-call options and wire schemas. Do not edit generated factories, cast the client, copy DTOs or hard-code business request envelopes.
|
|
74
|
+
|
|
75
|
+
The example's `TaroVrpcClient` and `TaroVrpcInterceptor` types are declared **in the copied file**, not exported by `@yorun-ai/vrpc`. The wrapper implements the unchanged invocation boundary and retains a working `use()` for request/error hooks. Its browser Response hooks are intentionally unsupported; use the local data API below.
|
|
76
|
+
|
|
77
|
+
## Register data hooks
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { isVrpcError } from "@yorun-ai/vrpc/client";
|
|
81
|
+
import { VrpcResponseError } from "@yorun-ai/vrpc/protocol";
|
|
82
|
+
import type { TaroVrpcClient } from "./taro-client";
|
|
83
|
+
|
|
84
|
+
export function installHooks(client: TaroVrpcClient) {
|
|
85
|
+
client.useData({
|
|
86
|
+
beforeRequest(context) {
|
|
87
|
+
console.log(context.request.serviceName, context.request.methodName);
|
|
88
|
+
},
|
|
89
|
+
afterResponse(response) {
|
|
90
|
+
console.log(response.status, response.headers["vrpc-status"]);
|
|
91
|
+
// Already decoded: response.payload, response.result and response.error.
|
|
92
|
+
},
|
|
93
|
+
onError(error, context) {
|
|
94
|
+
if (isVrpcError(error) && error.kind === "abort") return;
|
|
95
|
+
if (error instanceof VrpcResponseError) {
|
|
96
|
+
console.error(error.kind, error.vrpcStatus, error.code, error.message);
|
|
97
|
+
} else {
|
|
98
|
+
console.error(error);
|
|
99
|
+
}
|
|
100
|
+
if (!context.options.suppressGlobalToast) {
|
|
101
|
+
// The application owns its error UI; the request still rejects.
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The wrapper's constructor `interceptors` option uses the same data-hook contract as `useData`. Registering `use({ beforeRequest, onError })` also works. Registering the old `use({ afterResponse })` throws immediately with a migration message, before registering any hook from that object. Nothing is silently ignored and no plain object is passed off as a Fetch `Response`.
|
|
109
|
+
|
|
110
|
+
Data response hooks read the parsed result directly. Use `response.headers["content-type"]`, not `headers.get()`; use `response.result` or `response.payload`, not `response.json()` or `clone()`. This behavior is the same on Taro H5 and native miniapps.
|
|
111
|
+
|
|
112
|
+
The lifecycle is:
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
merge options -> encode with /protocol -> beforeRequest
|
|
116
|
+
-> Taro.request -> decodeVrpcResponseData
|
|
117
|
+
-> data afterResponse hooks -> result or VrpcResponseError
|
|
118
|
+
-> onError on failure -> rejected promise
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
A decoded invocation failure reaches data response hooks before it is thrown. Malformed responses skip response hooks and go directly to error handling. Request-construction failures before a context exists reject directly. A normally completed `onError` hook does not recover the failed request or suppress its rejection.
|
|
122
|
+
|
|
123
|
+
## Errors, cancellation and CBOR
|
|
124
|
+
|
|
125
|
+
The protocol entry's `VrpcResponseError` carries `kind: "protocol" | "invoke"`, status, plain `responseHeaders`, `vrpcStatus`, payload and optional server error fields. Handle it with `instanceof VrpcResponseError`. It is intentionally separate from the browser client's `VrpcInvokeError` / `VrpcProtocolError` and is not recognized by `isVrpcError`.
|
|
126
|
+
|
|
127
|
+
Native cancellation, timeout and network failures are normalized to the existing `HttpAbortError`, `HttpTimeoutError` and `HttpTransportError`; `isVrpcError` continues to recognize these shared lifecycle errors. Old browser errors and their guard remain unchanged.
|
|
128
|
+
|
|
129
|
+
Supply a platform-supported `AbortSignal` through per-call `requestInit.signal`. The transport connects it to `RequestTask.abort()`, handles already-aborted signals and removes listeners after completion. Requests use the resolved timeout both locally and in `vrpc-options`. If the target runtime lacks `AbortController`, the application must supply a compatible implementation when it needs caller cancellation. See the official [request API](https://docs.taro.zone/docs/apis/network/request/) and [RequestTask API](https://docs.taro.zone/docs/apis/network/request/RequestTask).
|
|
130
|
+
|
|
131
|
+
For generated Binary methods, provide `cborCodec` to `createTaroVrpcClient`. The generated SDK supplies `options.wire`; the wrapper forwards its schemas to protocol encoding/decoding. Do not send wire metadata to the server or implement a second binary conversion layer. Requests preserve strings/ArrayBuffers and responses preserve bytes before UTF-8/CBOR decoding.
|
|
132
|
+
|
|
133
|
+
## Migrate an existing Taro wrapper
|
|
134
|
+
|
|
135
|
+
1. Upgrade to the published 0.11.0 package, copy both adapter files and run application type checks.
|
|
136
|
+
2. Move old Response hooks to `useData` or the wrapper's data `interceptors` option. Change response/header reads as described above.
|
|
137
|
+
3. Handle protocol/business errors with `VrpcResponseError`; retain the shared lifecycle-error handling.
|
|
138
|
+
4. Delete the application-owned Response conversion module, its `whatwg-fetch` import/type declarations and the **direct** dependency. Update the lockfile; preserve Taro H5's transitive dependency.
|
|
139
|
+
5. Keep generated SDK files unchanged. Test each target before delivering the updated application.
|
|
140
|
+
|
|
141
|
+
This wrapper is an opt-in Taro usage change, not a drop-in implementation of every browser Response callback. Existing browser applications can keep `createVrpcClient` and their existing hooks without any migration.
|
|
142
|
+
|
|
143
|
+
## Platform verification
|
|
144
|
+
|
|
145
|
+
Verify H5, WeChat and Lark separately: success, decoded failures, malformed responses, Chinese/emoji text, binary schemas, timeout, cancellation, hook order and generated-SDK type checking. H5 success does not establish native miniapp compatibility. For H5 cross-origin requests, allow request vRPC headers and expose response vRPC headers through CORS. Miniapp devices need a reachable API URL and configured request-domain permissions; a device's localhost is not the development computer.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Upgrading to 0.11.0
|
|
2
|
+
|
|
3
|
+
This release adds `@yorun-ai/vrpc/protocol` for runtimes that own their network I/O. Existing root, `/client` and `/http` entrypoints keep their behavior. The wire protocol and skelc-generated service factories are unchanged.
|
|
4
|
+
|
|
5
|
+
## Why this upgrade exists
|
|
6
|
+
|
|
7
|
+
In 0.10.0, replacing the network transport does not remove the client's dependency on Fetch objects. The core still creates `Headers` and `Response`, and the existing protocol helpers accept or construct those objects too. A miniapp using `Taro.request` therefore still needs browser-object compatibility just to reuse protocol rules.
|
|
8
|
+
|
|
9
|
+
The new entry separates protocol processing from those browser objects. It constructs plain header records, encodes JSON/CBOR requests, validates response metadata and bodies, and resolves vRPC status using adapter-provided body readers. The browser helpers share the underlying protocol logic, keeping one source for wire behavior. The new entry installs no globals, performs no network I/O and requires no DOM or Node type library.
|
|
10
|
+
|
|
11
|
+
## What changes in the package
|
|
12
|
+
|
|
13
|
+
- New `./protocol` entry with ESM, CommonJS and matching declarations.
|
|
14
|
+
- Plain-data header/response helpers, existing pure encoding/path/ID helpers, and the separate `VrpcResponseError` contract. See the [API reference](../reference/README.md#runtime-independent-protocol-entry).
|
|
15
|
+
- No Taro runtime dependency, Taro client factory, new generated-client interface or replacement for `VrpcClient`.
|
|
16
|
+
- No new behavior in `createVrpcClient`, `createHttpClient`, the existing browser helpers or their error guards.
|
|
17
|
+
|
|
18
|
+
Existing browser consumers only need the version update; their imports, client creation, `use()` hooks, response objects and error handling do not need migration.
|
|
19
|
+
|
|
20
|
+
## Opting in from Taro
|
|
21
|
+
|
|
22
|
+
The [Taro guide](./taro.md) includes a complete application-owned client/transport example. This wrapper uses the new protocol entry and keeps the generated SDK unchanged. It intentionally changes the Taro response-hook and error contract to avoid creating Fetch objects:
|
|
23
|
+
|
|
24
|
+
| Existing Taro wrapper behavior | Data-based wrapper behavior |
|
|
25
|
+
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| Response hooks registered with `use({ afterResponse })` | Local `useData({ afterResponse })` or the wrapper's constructor data interceptors. |
|
|
27
|
+
| `response.json()` / `response.clone()` | Read the already decoded `response.payload` / `response.result`. |
|
|
28
|
+
| `response.headers.get("vrpc-status")` | `response.headers["vrpc-status"]`. |
|
|
29
|
+
| Browser `VrpcInvokeError` / `VrpcProtocolError` | `VrpcResponseError` from `/protocol`, checked with `instanceof`. |
|
|
30
|
+
| `isVrpcError` for every failure | Use `VrpcResponseError` for protocol/business failures; keep `isVrpcError` for native lifecycle errors. |
|
|
31
|
+
| Application-owned Fetch response conversion | Remove the conversion module and its direct polyfill dependency. |
|
|
32
|
+
|
|
33
|
+
The local `use()` still registers request/error hooks. Attempting to register a browser Response callback throws a clear migration error before installing any part of that registration. The runtime package does not change its existing `use()` behavior, and no dummy method or forced client cast is needed.
|
|
34
|
+
|
|
35
|
+
Copy and maintain the adapter in the application. Configure the API URL, identity, authentication, UTF-8 decoding and optional CBOR codec there. Do not edit skelc or generated SDK files.
|
|
36
|
+
|
|
37
|
+
## Keep the official H5 dependency
|
|
38
|
+
|
|
39
|
+
The application adapter no longer needs to import or construct objects from `whatwg-fetch`. However, official `@tarojs/taro-h5@4.3.3` still depends on and imports that package. Leave this upstream dependency unchanged; it will remain in a Taro H5 lockfile. This release does not remove it from Taro's dependency tree or alter Taro's browser support.
|
|
40
|
+
|
|
41
|
+
UTF-8 decoding support and optional caller cancellation support are separate platform concerns. Removing a Fetch polyfill does not automatically provide `TextDecoder` or `AbortController` in a miniapp runtime.
|
|
42
|
+
|
|
43
|
+
## Upgrade verification
|
|
44
|
+
|
|
45
|
+
After 0.11.0 is published, replace local test tarballs with the exact registry version and regenerate the application lockfile. Verify frozen installation and type checking against the unchanged generated SDK, then check hooks and errors on success, business failure, malformed responses, cancellation and timeout. Build and exercise H5 and each native target independently. Protocol/package tests and local simulator checks do not replace device testing or platform release validation.
|
package/docs/guides/usage.md
CHANGED
|
@@ -416,6 +416,8 @@ const body = buildVrpcRequestBody({ userId: 1 });
|
|
|
416
416
|
|
|
417
417
|
`parseVrpcResponse` returns a normalized result without throwing; `unwrapVrpcResponse` throws `VrpcInvokeError` on failure. A fully custom HTTP client is responsible for JSON/CBOR decoding of the response body; `createVrpcClient` handles it when using a runtime transport.
|
|
418
418
|
|
|
419
|
+
The helpers above retain their browser-oriented `Headers`/`Response` contracts. For runtimes without those objects, use the additive [`@yorun-ai/vrpc/protocol` entry](protocol.md). The [Taro integration guide](taro.md) covers native requests and retaining compatibility objects only where the existing client contract needs them.
|
|
420
|
+
|
|
419
421
|
## 7. Custom transport
|
|
420
422
|
|
|
421
423
|
A transport performs I/O only, and the response body must remain raw bytes:
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
- `src/core/`: protocol-independent lifecycle and HTTP/vRPC client assembly, without runtime network I/O.
|
|
14
14
|
- `src/transports/`: network I/O, `AbortController`, and raw-byte responses.
|
|
15
15
|
- `src/protocol/`: Vine headers, paths, envelopes, wire-schema conversion, and response parsing.
|
|
16
|
-
- `src/entrypoints/`: public exports for `./client
|
|
16
|
+
- `src/entrypoints/`: public exports for `./client`, `./http`, and `./protocol`.
|
|
17
17
|
|
|
18
18
|
A transport response must preserve the original `Uint8Array | null`. The generic HTTP core parses JSON, text, or empty responses, while the vRPC core selects JSON or a user-provided CBOR codec according to `content-type`.
|
|
19
19
|
|
|
@@ -55,6 +55,12 @@ The vRPC protocol layer owns path construction, request and response envelopes,
|
|
|
55
55
|
|
|
56
56
|
The complete wire contract and the requirements for generated clients are documented in [vRPC protocol](protocol.md). Changes to that contract must be reviewed across the runtime, protocol tests, generated-code consumers, and documentation.
|
|
57
57
|
|
|
58
|
+
## Runtime-independent protocol entry
|
|
59
|
+
|
|
60
|
+
`./protocol` exposes plain header records and structural body readers. It neither imports a network transport nor installs globals. Its declarations compile with only the ECMAScript library (no DOM or Node types). Shared header construction, body decoding, wire conversion and envelope status evaluation are used by the browser API too. Browser wrappers retain their existing signatures and error classes.
|
|
61
|
+
|
|
62
|
+
The new `VrpcResponseError` uses plain `responseHeaders`; it deliberately does not masquerade as the existing browser errors, whose header contract is `Headers`. Use the protocol error class for pure adapters. `VrpcClient` and its required `use()` method remain unchanged. Platform adapters must make supported hooks explicit. An application-local data-hook API can avoid Fetch objects while preserving the generated invocation boundary; unsupported legacy Response hooks must fail at registration, not be ignored. This is an opt-in platform usage change. The runtime does not add native client factories or change the existing browser interface.
|
|
63
|
+
|
|
58
64
|
## Verification
|
|
59
65
|
|
|
60
66
|
Run after behavioral or public-contract changes:
|
package/docs/reference/README.md
CHANGED
|
@@ -9,11 +9,12 @@ is internal and may change in any release.
|
|
|
9
9
|
|
|
10
10
|
## Package entry points
|
|
11
11
|
|
|
12
|
-
| Import
|
|
13
|
-
|
|
|
14
|
-
| `@yorun-ai/vrpc`
|
|
15
|
-
| `@yorun-ai/vrpc/client`
|
|
16
|
-
| `@yorun-ai/vrpc/http`
|
|
12
|
+
| Import | Contents |
|
|
13
|
+
| ------------------------- | ------------------------------------------------------------------------ |
|
|
14
|
+
| `@yorun-ai/vrpc` | Identical to `@yorun-ai/vrpc/client`. |
|
|
15
|
+
| `@yorun-ai/vrpc/client` | vRPC client, protocol helpers, id helpers, transport, errors, and types. |
|
|
16
|
+
| `@yorun-ai/vrpc/http` | Generic HTTP client, Fetch transport, HTTP errors, and HTTP types. |
|
|
17
|
+
| `@yorun-ai/vrpc/protocol` | Runtime-independent protocol helpers and plain response data. |
|
|
17
18
|
|
|
18
19
|
Each entry point publishes an ESM build (`import`), a CommonJS build
|
|
19
20
|
(`require`), and matching type declarations.
|
|
@@ -238,3 +239,24 @@ Exported from `@yorun-ai/vrpc` and `@yorun-ai/vrpc/client`:
|
|
|
238
239
|
The package is in the `0.x` line. The public API is not yet covered by a stable
|
|
239
240
|
`1.x` compatibility commitment, and a breaking change may ship in a new `0.x`
|
|
240
241
|
minor release with migration guidance.
|
|
242
|
+
|
|
243
|
+
## Runtime-independent protocol entry
|
|
244
|
+
|
|
245
|
+
`@yorun-ai/vrpc/protocol` has no Fetch/DOM runtime or type-library requirement. See [the adapter guide](../guides/protocol.md).
|
|
246
|
+
|
|
247
|
+
| Export | Purpose |
|
|
248
|
+
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
249
|
+
| `buildVrpcHeaderRecord(options)` | Validated protocol headers as `Record<string, string>`; takes the same `BuildVrpcHeadersOptions` as the existing browser builder. |
|
|
250
|
+
| `normalizeVrpcHeaderRecord(headers)` | Case-insensitive response headers, including array values. Rejects invalid names and newline/NUL values. |
|
|
251
|
+
| `mergeVrpcApplicationHeaders(...headers)` | Case-insensitive application overrides; rejects reserved protocol headers. |
|
|
252
|
+
| `decodeVrpcResponse<T>(source, options?)` | Full response metadata/body validation and result unwrapping; accepts optional `cborCodec` and `resultSchema`. |
|
|
253
|
+
| `decodeVrpcResponseData<T>(source, options?)` | Full decoding before unwrapping an invocation failure; returns `VrpcResponseResult<T>`. |
|
|
254
|
+
| `parseVrpcResponseData<T>(metadata, payload)` | Inspect the outcome of an already decoded envelope; does not validate media type or server identity. |
|
|
255
|
+
| `unwrapVrpcResponseData<T>(metadata, payload)` | Return an already decoded result or throw `VrpcResponseError` for an invocation failure. |
|
|
256
|
+
| `VrpcResponseError` | `kind: "protocol" \| "invoke"`, status, plain `responseHeaders`, `vrpcStatus`, URL/method, payload, code/reason/detail and optional cause. |
|
|
257
|
+
|
|
258
|
+
The entry also exports the existing pure path/body builders, request encoding, ID generation, content-type constants, and client-info/trace/wire/codec types. `VrpcResponseSource` contains status, headers, optional statusText/URL/method and `text()` / `arrayBuffer()` readers, which may return values or Promises. Body reading and UTF-8 decoding belong to the adapter.
|
|
259
|
+
|
|
260
|
+
`VrpcResponseError` is a separate additive error contract. It is not recognized by the browser-oriented `isVrpcError` guard and has no `Headers` methods. Existing browser errors, guards, and protocol helper signatures are unchanged.
|
|
261
|
+
|
|
262
|
+
`VrpcClient` remains unchanged and continues to require `invoke()` and `use()`. Generated SDKs require no changes. `decodeVrpcResponseData<T>(source, options?)` returns a fully decoded `VrpcResponseResult<T>` before unwrapping a business failure, allowing adapters to preserve interceptor ordering and existing error classes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yorun-ai/vrpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "vRPC and HTTP request library",
|
|
5
5
|
"homepage": "https://github.com/yorun-ai/vrpc-ts#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -55,6 +55,16 @@
|
|
|
55
55
|
"types": "./dist/http.d.cts",
|
|
56
56
|
"default": "./dist/http.cjs"
|
|
57
57
|
}
|
|
58
|
+
},
|
|
59
|
+
"./protocol": {
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./dist/protocol.d.ts",
|
|
62
|
+
"default": "./dist/protocol.es.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./dist/protocol.d.cts",
|
|
66
|
+
"default": "./dist/protocol.cjs"
|
|
67
|
+
}
|
|
58
68
|
}
|
|
59
69
|
},
|
|
60
70
|
"publishConfig": {
|