@orpc/standard-server-fetch 1.2.0 → 1.4.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 +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +6 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
49
49
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
50
50
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
51
51
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
|
|
52
53
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
53
54
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
|
54
55
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
|
|
2
2
|
|
|
3
|
-
declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncIteratorObject<unknown | void, unknown | void, void> & AsyncGenerator<unknown | void, unknown | void, void>;
|
|
3
|
+
declare function toEventIterator(stream: ReadableStream<Uint8Array> | null): AsyncIteratorObject<unknown | void, unknown | void, void> & AsyncGenerator<unknown | void, unknown | void, void>;
|
|
4
4
|
interface ToEventStreamOptions {
|
|
5
5
|
/**
|
|
6
6
|
* If true, a ping comment is sent periodically to keep the connection alive.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
|
|
2
2
|
|
|
3
|
-
declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncIteratorObject<unknown | void, unknown | void, void> & AsyncGenerator<unknown | void, unknown | void, void>;
|
|
3
|
+
declare function toEventIterator(stream: ReadableStream<Uint8Array> | null): AsyncIteratorObject<unknown | void, unknown | void, void> & AsyncGenerator<unknown | void, unknown | void, void>;
|
|
4
4
|
interface ToEventStreamOptions {
|
|
5
5
|
/**
|
|
6
6
|
* If true, a ping comment is sent periodically to keep the connection alive.
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,13 @@ import { createAsyncIteratorObject, parseEmptyableJSON, isTypescriptObject, stri
|
|
|
2
2
|
import { EventDecoderStream, withEventMeta, ErrorEvent, encodeEventMessage, getEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@orpc/standard-server';
|
|
3
3
|
|
|
4
4
|
function toEventIterator(stream) {
|
|
5
|
-
const eventStream = stream
|
|
6
|
-
const reader = eventStream
|
|
5
|
+
const eventStream = stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
6
|
+
const reader = eventStream?.getReader();
|
|
7
7
|
return createAsyncIteratorObject(async () => {
|
|
8
8
|
while (true) {
|
|
9
|
+
if (reader === void 0) {
|
|
10
|
+
return { done: true, value: void 0 };
|
|
11
|
+
}
|
|
9
12
|
const { done, value } = await reader.read();
|
|
10
13
|
if (done) {
|
|
11
14
|
return { done: true, value: void 0 };
|
|
@@ -35,7 +38,7 @@ function toEventIterator(stream) {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
}, async () => {
|
|
38
|
-
await reader
|
|
41
|
+
await reader?.cancel();
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
function toEventStream(iterator, options = {}) {
|
|
@@ -93,9 +96,6 @@ function toEventStream(iterator, options = {}) {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
async function toStandardBody(re) {
|
|
96
|
-
if (re.body === null) {
|
|
97
|
-
return void 0;
|
|
98
|
-
}
|
|
99
99
|
const contentDisposition = re.headers.get("content-disposition");
|
|
100
100
|
if (typeof contentDisposition === "string") {
|
|
101
101
|
const fileName = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
|
@@ -151,8 +151,6 @@ function toFetchBody(body, headers, options = {}) {
|
|
|
151
151
|
}
|
|
152
152
|
if (isAsyncIteratorObject(body)) {
|
|
153
153
|
headers.set("content-type", "text/event-stream");
|
|
154
|
-
headers.set("cache-control", "no-cache");
|
|
155
|
-
headers.set("connection", "keep-alive");
|
|
156
154
|
return toEventStream(body, options);
|
|
157
155
|
}
|
|
158
156
|
headers.set("content-type", "application/json");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@orpc/shared": "1.
|
|
27
|
-
"@orpc/standard-server": "1.
|
|
26
|
+
"@orpc/shared": "1.4.0",
|
|
27
|
+
"@orpc/standard-server": "1.4.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hono/node-server": "^1.14.1"
|