@orpc/standard-server 0.0.0-next.546545e → 0.0.0-next.54a5576
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 +12 -8
- package/dist/batch/index.mjs +40 -30
- package/dist/index.mjs +4 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<image align="center" src="https://orpc.
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
5
|
<h1></h1>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://codecov.io/gh/
|
|
9
|
-
<img alt="codecov" src="https://codecov.io/gh/
|
|
8
|
+
<a href="https://codecov.io/gh/middleapi/orpc">
|
|
9
|
+
<img alt="codecov" src="https://codecov.io/gh/middleapi/orpc/branch/main/graph/badge.svg">
|
|
10
10
|
</a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/@orpc/standard-server">
|
|
12
12
|
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fstandard-server?logo=npm" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://github.com/
|
|
15
|
-
<img alt="MIT License" src="https://img.shields.io/github/license/
|
|
14
|
+
<a href="https://github.com/middleapi/orpc/blob/main/LICENSE">
|
|
15
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/middleapi/orpc?logo=open-source-initiative" />
|
|
16
16
|
</a>
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/middleapi/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -31,7 +34,7 @@
|
|
|
31
34
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
35
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
36
|
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
34
|
-
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
35
38
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
36
39
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
37
40
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
45
|
-
You can find the full documentation [here](https://orpc.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
46
49
|
|
|
47
50
|
## Packages
|
|
48
51
|
|
|
@@ -54,6 +57,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
54
57
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
55
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
56
59
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
57
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
58
62
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
59
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
@@ -74,4 +78,4 @@ This package is designed to be used as a base for other server implementations.
|
|
|
74
78
|
|
|
75
79
|
## License
|
|
76
80
|
|
|
77
|
-
Distributed under the MIT License. See [LICENSE](https://github.com/
|
|
81
|
+
Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/main/LICENSE) for more information.
|
package/dist/batch/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringifyJSON, parseEmptyableJSON, isAsyncIteratorObject, isObject } from '@orpc/shared';
|
|
1
|
+
import { stringifyJSON, parseEmptyableJSON, AsyncIteratorClass, isAsyncIteratorObject, isObject } from '@orpc/shared';
|
|
2
2
|
|
|
3
3
|
function toBatchAbortSignal(signals) {
|
|
4
4
|
const realSignals = signals.filter((signal) => signal !== void 0);
|
|
@@ -91,46 +91,56 @@ function toBatchResponse(options) {
|
|
|
91
91
|
return {
|
|
92
92
|
headers: options.headers,
|
|
93
93
|
status: options.status,
|
|
94
|
-
body:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
body: new AsyncIteratorClass(
|
|
95
|
+
async () => {
|
|
96
|
+
const { done, value } = await options.body.next();
|
|
97
|
+
if (done) {
|
|
98
|
+
return { done, value };
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
done,
|
|
102
|
+
value: {
|
|
103
|
+
index: value.index,
|
|
104
|
+
status: value.status === options.status ? void 0 : value.status,
|
|
105
|
+
headers: Object.keys(value.headers).length ? value.headers : void 0,
|
|
106
|
+
body: value.body
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
async (reason) => {
|
|
111
|
+
if (reason !== "next") {
|
|
112
|
+
await options.body.return?.();
|
|
103
113
|
}
|
|
104
|
-
} finally {
|
|
105
|
-
await options.body.return?.();
|
|
106
114
|
}
|
|
107
|
-
|
|
115
|
+
)
|
|
108
116
|
};
|
|
109
117
|
}
|
|
110
118
|
function parseBatchResponse(response) {
|
|
111
119
|
const body = response.body;
|
|
112
120
|
if (isAsyncIteratorObject(body) || Array.isArray(body)) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
yield {
|
|
122
|
-
index: item.index,
|
|
123
|
-
status: item.status ?? response.status,
|
|
124
|
-
headers: item.headers ?? {},
|
|
125
|
-
body: item.body
|
|
126
|
-
};
|
|
121
|
+
const iterator = (async function* () {
|
|
122
|
+
for await (const item of body) {
|
|
123
|
+
if (!isObject(item) || !("index" in item) || typeof item.index !== "number") {
|
|
124
|
+
throw new TypeError("Invalid batch response", {
|
|
125
|
+
cause: item
|
|
126
|
+
});
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
yield {
|
|
129
|
+
index: item.index,
|
|
130
|
+
status: item.status ?? response.status,
|
|
131
|
+
headers: item.headers ?? {},
|
|
132
|
+
body: item.body
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
return new AsyncIteratorClass(
|
|
137
|
+
() => iterator.next(),
|
|
138
|
+
async (reason) => {
|
|
139
|
+
if (reason !== "next" && isAsyncIteratorObject(body)) {
|
|
130
140
|
await body.return?.();
|
|
131
141
|
}
|
|
132
142
|
}
|
|
133
|
-
|
|
143
|
+
);
|
|
134
144
|
}
|
|
135
145
|
throw new TypeError("Invalid batch response", {
|
|
136
146
|
cause: response
|
package/dist/index.mjs
CHANGED
|
@@ -66,7 +66,6 @@ class EventDecoder {
|
|
|
66
66
|
this.options.onEvent(message);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
this.incomplete = "";
|
|
70
69
|
}
|
|
71
70
|
end() {
|
|
72
71
|
if (this.incomplete) {
|
|
@@ -158,6 +157,9 @@ function encodeEventMessage(message) {
|
|
|
158
157
|
|
|
159
158
|
const EVENT_SOURCE_META_SYMBOL = Symbol("ORPC_EVENT_SOURCE_META");
|
|
160
159
|
function withEventMeta(container, meta) {
|
|
160
|
+
if (meta.id === void 0 && meta.retry === void 0 && !meta.comments?.length) {
|
|
161
|
+
return container;
|
|
162
|
+
}
|
|
161
163
|
if (meta.id !== void 0) {
|
|
162
164
|
assertEventId(meta.id);
|
|
163
165
|
}
|
|
@@ -248,14 +250,11 @@ function replicateStandardLazyResponse(response, count) {
|
|
|
248
250
|
replicated.push({
|
|
249
251
|
...response,
|
|
250
252
|
body: once(async () => {
|
|
251
|
-
if (replicatedAsyncIteratorObjects) {
|
|
252
|
-
return replicatedAsyncIteratorObjects.shift();
|
|
253
|
-
}
|
|
254
253
|
const body = await (bodyPromise ??= response.body());
|
|
255
254
|
if (!isAsyncIteratorObject(body)) {
|
|
256
255
|
return body;
|
|
257
256
|
}
|
|
258
|
-
replicatedAsyncIteratorObjects
|
|
257
|
+
replicatedAsyncIteratorObjects ??= replicateAsyncIterator(body, count);
|
|
259
258
|
return replicatedAsyncIteratorObjects.shift();
|
|
260
259
|
})
|
|
261
260
|
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.54a5576",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://
|
|
6
|
+
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/middleapi/orpc.git",
|
|
10
10
|
"directory": "packages/standard-server"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@orpc/shared": "0.0.0-next.
|
|
31
|
+
"@orpc/shared": "0.0.0-next.54a5576"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "unbuild",
|