@orpc/standard-server-node 0.0.0-next.7e41bc4 → 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,16 +1,16 @@
|
|
|
1
1
|
// src/body.ts
|
|
2
2
|
import { Readable as Readable2 } from "node:stream";
|
|
3
|
-
import {
|
|
3
|
+
import { isAsyncIteratorObject, parseEmptyableJSON as parseEmptyableJSON2, stringifyJSON as stringifyJSON2 } from "@orpc/shared";
|
|
4
|
+
import { contentDisposition, parseContentDisposition } from "@orpc/standard-server";
|
|
4
5
|
|
|
5
6
|
// src/event-source.ts
|
|
6
7
|
import { Readable } from "node:stream";
|
|
8
|
+
import { isTypescriptObject, parseEmptyableJSON, stringifyJSON } from "@orpc/shared";
|
|
7
9
|
import {
|
|
8
10
|
encodeEventMessage,
|
|
9
11
|
ErrorEvent,
|
|
10
12
|
EventDecoderStream,
|
|
11
13
|
getEventMeta,
|
|
12
|
-
isEventMetaContainer,
|
|
13
|
-
parseEmptyableJSON,
|
|
14
14
|
UnknownEvent,
|
|
15
15
|
withEventMeta
|
|
16
16
|
} from "@orpc/standard-server";
|
|
@@ -27,7 +27,7 @@ function toEventIterator(stream) {
|
|
|
27
27
|
switch (value.event) {
|
|
28
28
|
case "message": {
|
|
29
29
|
let message = parseEmptyableJSON(value.data);
|
|
30
|
-
if (
|
|
30
|
+
if (isTypescriptObject(message)) {
|
|
31
31
|
message = withEventMeta(message, value);
|
|
32
32
|
}
|
|
33
33
|
yield message;
|
|
@@ -42,7 +42,7 @@ function toEventIterator(stream) {
|
|
|
42
42
|
}
|
|
43
43
|
case "done": {
|
|
44
44
|
let done2 = parseEmptyableJSON(value.data);
|
|
45
|
-
if (
|
|
45
|
+
if (isTypescriptObject(done2)) {
|
|
46
46
|
done2 = withEventMeta(done2, value);
|
|
47
47
|
}
|
|
48
48
|
return done2;
|
|
@@ -71,7 +71,7 @@ function toEventStream(iterator) {
|
|
|
71
71
|
controller.enqueue(encodeEventMessage({
|
|
72
72
|
...getEventMeta(value.value),
|
|
73
73
|
event: value.done ? "done" : "message",
|
|
74
|
-
data:
|
|
74
|
+
data: stringifyJSON(value.value)
|
|
75
75
|
}));
|
|
76
76
|
if (value.done) {
|
|
77
77
|
controller.close();
|
|
@@ -80,7 +80,7 @@ function toEventStream(iterator) {
|
|
|
80
80
|
controller.enqueue(encodeEventMessage({
|
|
81
81
|
...getEventMeta(err),
|
|
82
82
|
event: "error",
|
|
83
|
-
data: err instanceof ErrorEvent ?
|
|
83
|
+
data: err instanceof ErrorEvent ? stringifyJSON(err.data) : void 0
|
|
84
84
|
}));
|
|
85
85
|
controller.close();
|
|
86
86
|
}
|
|
@@ -124,7 +124,7 @@ async function toStandardBody(req) {
|
|
|
124
124
|
if (contentType.startsWith("text/event-stream")) {
|
|
125
125
|
return toEventIterator(req);
|
|
126
126
|
}
|
|
127
|
-
if (contentType.startsWith("text/")) {
|
|
127
|
+
if (contentType.startsWith("text/plain")) {
|
|
128
128
|
return _streamToString(req);
|
|
129
129
|
}
|
|
130
130
|
return _streamToFile(req, "blob", contentType);
|
|
@@ -160,7 +160,7 @@ function toNodeHttpBody(body, headers) {
|
|
|
160
160
|
return toEventStream(body);
|
|
161
161
|
}
|
|
162
162
|
headers["content-type"] = "application/json";
|
|
163
|
-
return
|
|
163
|
+
return stringifyJSON2(body);
|
|
164
164
|
}
|
|
165
165
|
function _streamToFormData(stream, contentType) {
|
|
166
166
|
const response = new Response(stream, {
|
|
@@ -186,7 +186,7 @@ async function _streamToFile(stream, fileName, contentType) {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
// src/request.ts
|
|
189
|
-
import { once } from "@orpc/
|
|
189
|
+
import { once } from "@orpc/shared";
|
|
190
190
|
|
|
191
191
|
// src/signal.ts
|
|
192
192
|
function toAbortSignal(res) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { JsonValue } from '@orpc/standard-server';
|
|
2
1
|
import { Readable } from 'node:stream';
|
|
3
|
-
export declare function toEventIterator(stream: Readable): AsyncGenerator<
|
|
4
|
-
export declare function toEventStream(iterator: AsyncIterator<
|
|
2
|
+
export declare function toEventIterator(stream: Readable): AsyncGenerator<unknown | void, unknown | void, void>;
|
|
3
|
+
export declare function toEventStream(iterator: AsyncIterator<unknown | void, unknown | void, void>): Readable;
|
|
5
4
|
//# sourceMappingURL=event-source.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-node",
|
|
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://orpc.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
|
"@types/node": "^22.13.1",
|