@orpc/standard-server 0.0.0-next.e98b833 → 0.0.0-next.f47352c
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 +13 -1
- package/dist/index.d.mts +5 -11
- package/dist/index.d.ts +5 -11
- package/dist/index.mjs +35 -3
- package/package.json +2 -3
package/README.md
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid), Pinia Colada, and more.
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
@@ -53,17 +53,29 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
53
53
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
54
54
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
56
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
56
57
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
57
58
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
58
59
|
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
60
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
59
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
60
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
61
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
62
66
|
|
63
67
|
## `@orpc/standard-server`
|
64
68
|
|
65
69
|
This package is designed to be used as a base for other server implementations.
|
66
70
|
|
71
|
+
## Sponsors
|
72
|
+
|
73
|
+
<p align="center">
|
74
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
75
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
76
|
+
</a>
|
77
|
+
</p>
|
78
|
+
|
67
79
|
## License
|
68
80
|
|
69
81
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
2
|
-
|
3
1
|
interface EventMessage {
|
4
2
|
event: string | undefined;
|
5
3
|
id: string | undefined;
|
@@ -66,10 +64,6 @@ interface StandardRequest {
|
|
66
64
|
signal: AbortSignal | undefined;
|
67
65
|
}
|
68
66
|
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
69
|
-
/**
|
70
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
71
|
-
*/
|
72
|
-
raw: Record<string, unknown>;
|
73
67
|
/**
|
74
68
|
* The body has been parsed based on the content-type header.
|
75
69
|
* This method can safely call multiple times (cached).
|
@@ -85,10 +79,6 @@ interface StandardResponse {
|
|
85
79
|
body: StandardBody;
|
86
80
|
}
|
87
81
|
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
88
|
-
/**
|
89
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
90
|
-
*/
|
91
|
-
raw: Record<string, unknown>;
|
92
82
|
/**
|
93
83
|
* The body has been parsed based on the content-type header.
|
94
84
|
* This method can safely call multiple times (cached).
|
@@ -96,4 +86,8 @@ interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
96
86
|
body: () => Promise<StandardBody>;
|
97
87
|
}
|
98
88
|
|
99
|
-
|
89
|
+
declare function generateContentDisposition(filename: string): string;
|
90
|
+
declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
|
91
|
+
declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
|
92
|
+
|
93
|
+
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta, type StandardBody, type StandardHeaders, type StandardLazyRequest, type StandardLazyResponse, type StandardRequest, type StandardResponse, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
2
|
-
|
3
1
|
interface EventMessage {
|
4
2
|
event: string | undefined;
|
5
3
|
id: string | undefined;
|
@@ -66,10 +64,6 @@ interface StandardRequest {
|
|
66
64
|
signal: AbortSignal | undefined;
|
67
65
|
}
|
68
66
|
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
69
|
-
/**
|
70
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
71
|
-
*/
|
72
|
-
raw: Record<string, unknown>;
|
73
67
|
/**
|
74
68
|
* The body has been parsed based on the content-type header.
|
75
69
|
* This method can safely call multiple times (cached).
|
@@ -85,10 +79,6 @@ interface StandardResponse {
|
|
85
79
|
body: StandardBody;
|
86
80
|
}
|
87
81
|
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
88
|
-
/**
|
89
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
90
|
-
*/
|
91
|
-
raw: Record<string, unknown>;
|
92
82
|
/**
|
93
83
|
* The body has been parsed based on the content-type header.
|
94
84
|
* This method can safely call multiple times (cached).
|
@@ -96,4 +86,8 @@ interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
96
86
|
body: () => Promise<StandardBody>;
|
97
87
|
}
|
98
88
|
|
99
|
-
|
89
|
+
declare function generateContentDisposition(filename: string): string;
|
90
|
+
declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
|
91
|
+
declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
|
92
|
+
|
93
|
+
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta, type StandardBody, type StandardHeaders, type StandardLazyRequest, type StandardLazyResponse, type StandardRequest, type StandardResponse, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
|
package/dist/index.mjs
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import { isTypescriptObject } from '@orpc/shared';
|
2
|
-
export { contentDisposition, parse as parseContentDisposition } from '@tinyhttp/content-disposition';
|
1
|
+
import { isTypescriptObject, toArray } from '@orpc/shared';
|
3
2
|
|
4
3
|
class EventEncoderError extends TypeError {
|
5
4
|
}
|
@@ -183,4 +182,37 @@ function getEventMeta(container) {
|
|
183
182
|
return isTypescriptObject(container) ? Reflect.get(container, EVENT_SOURCE_META_SYMBOL) : void 0;
|
184
183
|
}
|
185
184
|
|
186
|
-
|
185
|
+
function generateContentDisposition(filename) {
|
186
|
+
const escapedFileName = filename.replace(/"/g, '\\"');
|
187
|
+
const encodedFilenameStar = encodeURIComponent(filename).replace(/['()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g, (str, hex) => String.fromCharCode(Number.parseInt(hex, 16)));
|
188
|
+
return `inline; filename="${escapedFileName}"; filename*=utf-8''${encodedFilenameStar}`;
|
189
|
+
}
|
190
|
+
function getFilenameFromContentDisposition(contentDisposition) {
|
191
|
+
const encodedFilenameStarMatch = contentDisposition.match(/filename\*=(UTF-8'')?([^;]*)/i);
|
192
|
+
if (encodedFilenameStarMatch && typeof encodedFilenameStarMatch[2] === "string") {
|
193
|
+
return decodeURIComponent(encodedFilenameStarMatch[2]);
|
194
|
+
}
|
195
|
+
const encodedFilenameMatch = contentDisposition.match(/filename="((?:\\"|[^"])*)"/i);
|
196
|
+
if (encodedFilenameMatch && typeof encodedFilenameMatch[1] === "string") {
|
197
|
+
return encodedFilenameMatch[1].replace(/\\"/g, '"');
|
198
|
+
}
|
199
|
+
}
|
200
|
+
function mergeStandardHeaders(a, b) {
|
201
|
+
const merged = { ...a };
|
202
|
+
for (const key in b) {
|
203
|
+
if (Array.isArray(b[key])) {
|
204
|
+
merged[key] = [...toArray(merged[key]), ...b[key]];
|
205
|
+
} else if (b[key] !== void 0) {
|
206
|
+
if (Array.isArray(merged[key])) {
|
207
|
+
merged[key] = [...merged[key], b[key]];
|
208
|
+
} else if (merged[key] !== void 0) {
|
209
|
+
merged[key] = [merged[key], b[key]];
|
210
|
+
} else {
|
211
|
+
merged[key] = b[key];
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
return merged;
|
216
|
+
}
|
217
|
+
|
218
|
+
export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/standard-server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.f47352c",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://unnoq.com",
|
7
7
|
"repository": {
|
@@ -23,8 +23,7 @@
|
|
23
23
|
"dist"
|
24
24
|
],
|
25
25
|
"dependencies": {
|
26
|
-
"@
|
27
|
-
"@orpc/shared": "0.0.0-next.e98b833"
|
26
|
+
"@orpc/shared": "0.0.0-next.f47352c"
|
28
27
|
},
|
29
28
|
"scripts": {
|
30
29
|
"build": "unbuild",
|