@orpc/standard-server-fetch 0.0.0-next.370978b → 0.0.0-next.ac2a918
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/dist/index.js +10 -10
- package/dist/src/event-source.d.ts +2 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/body.ts
|
|
2
|
-
import {
|
|
2
|
+
import { isAsyncIteratorObject, parseEmptyableJSON as parseEmptyableJSON2, stringifyJSON as stringifyJSON2 } from "@orpc/shared";
|
|
3
|
+
import { contentDisposition, parseContentDisposition } from "@orpc/standard-server";
|
|
3
4
|
|
|
4
5
|
// src/event-source.ts
|
|
6
|
+
import { isTypescriptObject, parseEmptyableJSON, stringifyJSON } from "@orpc/shared";
|
|
5
7
|
import {
|
|
6
8
|
encodeEventMessage,
|
|
7
9
|
ErrorEvent,
|
|
8
10
|
EventDecoderStream,
|
|
9
11
|
getEventMeta,
|
|
10
|
-
isEventMetaContainer,
|
|
11
|
-
parseEmptyableJSON,
|
|
12
12
|
UnknownEvent,
|
|
13
13
|
withEventMeta
|
|
14
14
|
} from "@orpc/standard-server";
|
|
@@ -25,7 +25,7 @@ function toEventIterator(stream) {
|
|
|
25
25
|
switch (value.event) {
|
|
26
26
|
case "message": {
|
|
27
27
|
let message = parseEmptyableJSON(value.data);
|
|
28
|
-
if (
|
|
28
|
+
if (isTypescriptObject(message)) {
|
|
29
29
|
message = withEventMeta(message, value);
|
|
30
30
|
}
|
|
31
31
|
yield message;
|
|
@@ -40,7 +40,7 @@ function toEventIterator(stream) {
|
|
|
40
40
|
}
|
|
41
41
|
case "done": {
|
|
42
42
|
let done2 = parseEmptyableJSON(value.data);
|
|
43
|
-
if (
|
|
43
|
+
if (isTypescriptObject(done2)) {
|
|
44
44
|
done2 = withEventMeta(done2, value);
|
|
45
45
|
}
|
|
46
46
|
return done2;
|
|
@@ -69,7 +69,7 @@ function toEventStream(iterator) {
|
|
|
69
69
|
controller.enqueue(encodeEventMessage({
|
|
70
70
|
...getEventMeta(value.value),
|
|
71
71
|
event: value.done ? "done" : "message",
|
|
72
|
-
data:
|
|
72
|
+
data: stringifyJSON(value.value)
|
|
73
73
|
}));
|
|
74
74
|
if (value.done) {
|
|
75
75
|
controller.close();
|
|
@@ -78,7 +78,7 @@ function toEventStream(iterator) {
|
|
|
78
78
|
controller.enqueue(encodeEventMessage({
|
|
79
79
|
...getEventMeta(err),
|
|
80
80
|
event: "error",
|
|
81
|
-
data: err instanceof ErrorEvent ?
|
|
81
|
+
data: err instanceof ErrorEvent ? stringifyJSON(err.data) : void 0
|
|
82
82
|
}));
|
|
83
83
|
controller.close();
|
|
84
84
|
}
|
|
@@ -124,7 +124,7 @@ async function toStandardBody(re) {
|
|
|
124
124
|
if (contentType.startsWith("text/event-stream")) {
|
|
125
125
|
return toEventIterator(re.body);
|
|
126
126
|
}
|
|
127
|
-
if (contentType.startsWith("text/")) {
|
|
127
|
+
if (contentType.startsWith("text/plain")) {
|
|
128
128
|
return await re.text();
|
|
129
129
|
}
|
|
130
130
|
const blob = await re.blob();
|
|
@@ -160,7 +160,7 @@ function toFetchBody(body, headers) {
|
|
|
160
160
|
return toEventStream(body);
|
|
161
161
|
}
|
|
162
162
|
headers.set("content-type", "application/json");
|
|
163
|
-
return
|
|
163
|
+
return stringifyJSON2(body);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// src/headers.ts
|
|
@@ -190,7 +190,7 @@ function toFetchHeaders(headers, fetchHeaders = new Headers()) {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
// src/request.ts
|
|
193
|
-
import { once } from "@orpc/
|
|
193
|
+
import { once } from "@orpc/shared";
|
|
194
194
|
function toStandardRequest(request) {
|
|
195
195
|
return {
|
|
196
196
|
raw: { request },
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function toEventStream(iterator: AsyncIterator<JsonValue | void, JsonValue | void, void>): ReadableStream<Uint8Array>;
|
|
1
|
+
export declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncGenerator<unknown | void, unknown | void, void>;
|
|
2
|
+
export declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>): ReadableStream<Uint8Array>;
|
|
4
3
|
//# sourceMappingURL=event-source.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.ac2a918",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@orpc/
|
|
31
|
+
"@orpc/shared": "0.0.0-next.ac2a918",
|
|
32
|
+
"@orpc/standard-server": "0.0.0-next.ac2a918"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@hono/node-server": "^1.13.8"
|