@orpc/standard-server-fetch 0.0.0-next.d5f6b77 → 0.0.0-next.d636350
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 +5 -6
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +37 -47
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
31
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
32
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
|
34
34
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
35
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
36
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -49,13 +49,12 @@ 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/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
53
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
52
54
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
53
|
-
- [@orpc/
|
|
54
|
-
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
55
|
-
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
56
|
-
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
55
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
57
56
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
58
|
-
- [@orpc/
|
|
57
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
59
58
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
60
59
|
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
61
60
|
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
|
|
2
|
+
import { AsyncIteratorClass } from '@orpc/shared';
|
|
2
3
|
|
|
3
|
-
declare function toEventIterator(stream: ReadableStream<Uint8Array>):
|
|
4
|
+
declare function toEventIterator(stream: ReadableStream<Uint8Array> | null): AsyncIteratorClass<unknown>;
|
|
4
5
|
interface ToEventStreamOptions {
|
|
5
6
|
/**
|
|
6
7
|
* If true, a ping comment is sent periodically to keep the connection alive.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
|
|
2
|
+
import { AsyncIteratorClass } from '@orpc/shared';
|
|
2
3
|
|
|
3
|
-
declare function toEventIterator(stream: ReadableStream<Uint8Array>):
|
|
4
|
+
declare function toEventIterator(stream: ReadableStream<Uint8Array> | null): AsyncIteratorClass<unknown>;
|
|
4
5
|
interface ToEventStreamOptions {
|
|
5
6
|
/**
|
|
6
7
|
* If true, a ping comment is sent periodically to keep the connection alive.
|
package/dist/index.mjs
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventDecoderStream,
|
|
1
|
+
import { AsyncIteratorClass, parseEmptyableJSON, isTypescriptObject, stringifyJSON, isAsyncIteratorObject, once } from '@orpc/shared';
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
case "error": {
|
|
24
|
-
let error = new ErrorEvent({
|
|
25
|
-
data: parseEmptyableJSON(value.data)
|
|
26
|
-
});
|
|
27
|
-
error = withEventMeta(error, value);
|
|
28
|
-
throw error;
|
|
5
|
+
const eventStream = stream?.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
6
|
+
const reader = eventStream?.getReader();
|
|
7
|
+
return new AsyncIteratorClass(async () => {
|
|
8
|
+
while (true) {
|
|
9
|
+
if (reader === void 0) {
|
|
10
|
+
return { done: true, value: void 0 };
|
|
11
|
+
}
|
|
12
|
+
const { done, value } = await reader.read();
|
|
13
|
+
if (done) {
|
|
14
|
+
return { done: true, value: void 0 };
|
|
15
|
+
}
|
|
16
|
+
switch (value.event) {
|
|
17
|
+
case "message": {
|
|
18
|
+
let message = parseEmptyableJSON(value.data);
|
|
19
|
+
if (isTypescriptObject(message)) {
|
|
20
|
+
message = withEventMeta(message, value);
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
return { done: false, value: message };
|
|
23
|
+
}
|
|
24
|
+
case "error": {
|
|
25
|
+
let error = new ErrorEvent({
|
|
26
|
+
data: parseEmptyableJSON(value.data)
|
|
27
|
+
});
|
|
28
|
+
error = withEventMeta(error, value);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
case "done": {
|
|
32
|
+
let done2 = parseEmptyableJSON(value.data);
|
|
33
|
+
if (isTypescriptObject(done2)) {
|
|
34
|
+
done2 = withEventMeta(done2, value);
|
|
36
35
|
}
|
|
36
|
+
return { done: true, value: done2 };
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
} finally {
|
|
40
|
-
await reader.cancel();
|
|
41
39
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
40
|
+
}, async () => {
|
|
41
|
+
await reader?.cancel();
|
|
42
|
+
});
|
|
44
43
|
}
|
|
45
44
|
function toEventStream(iterator, options = {}) {
|
|
46
45
|
const keepAliveEnabled = options.eventIteratorKeepAliveEnabled ?? true;
|
|
@@ -87,23 +86,16 @@ function toEventStream(iterator, options = {}) {
|
|
|
87
86
|
controller.close();
|
|
88
87
|
}
|
|
89
88
|
},
|
|
90
|
-
async cancel(
|
|
89
|
+
async cancel() {
|
|
91
90
|
cancelled = true;
|
|
92
91
|
clearInterval(timeout);
|
|
93
|
-
|
|
94
|
-
await iterator.throw?.(reason);
|
|
95
|
-
} else {
|
|
96
|
-
await iterator.return?.();
|
|
97
|
-
}
|
|
92
|
+
await iterator.return?.();
|
|
98
93
|
}
|
|
99
94
|
}).pipeThrough(new TextEncoderStream());
|
|
100
95
|
return stream;
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
async function toStandardBody(re) {
|
|
104
|
-
if (re.body === null) {
|
|
105
|
-
return void 0;
|
|
106
|
-
}
|
|
107
99
|
const contentDisposition = re.headers.get("content-disposition");
|
|
108
100
|
if (typeof contentDisposition === "string") {
|
|
109
101
|
const fileName = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
|
@@ -159,8 +151,6 @@ function toFetchBody(body, headers, options = {}) {
|
|
|
159
151
|
}
|
|
160
152
|
if (isAsyncIteratorObject(body)) {
|
|
161
153
|
headers.set("content-type", "text/event-stream");
|
|
162
|
-
headers.set("cache-control", "no-cache");
|
|
163
|
-
headers.set("connection", "keep-alive");
|
|
164
154
|
return toEventStream(body, options);
|
|
165
155
|
}
|
|
166
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": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.d636350",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@orpc/shared": "0.0.0-next.
|
|
27
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
26
|
+
"@orpc/shared": "0.0.0-next.d636350",
|
|
27
|
+
"@orpc/standard-server": "0.0.0-next.d636350"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@hono/node-server": "^1.14.
|
|
30
|
+
"@hono/node-server": "^1.14.4"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "unbuild",
|