@orpc/standard-server 0.0.0-next.cd121e3 → 0.0.0-next.cf06e99
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 +14 -1
- package/dist/batch/index.d.mts +23 -0
- package/dist/batch/index.d.ts +23 -0
- package/dist/batch/index.mjs +111 -0
- package/dist/index.d.mts +7 -27
- package/dist/index.d.ts +7 -27
- package/dist/index.mjs +40 -8
- package/dist/shared/standard-server.R_NaHlxw.d.mts +38 -0
- package/dist/shared/standard-server.R_NaHlxw.d.ts +38 -0
- package/package.json +7 -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), 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,16 +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).
|
|
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).
|
|
58
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
59
62
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
60
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/).
|
|
61
66
|
|
|
62
67
|
## `@orpc/standard-server`
|
|
63
68
|
|
|
64
69
|
This package is designed to be used as a base for other server implementations.
|
|
65
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
|
+
|
|
66
79
|
## License
|
|
67
80
|
|
|
68
81
|
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { S as StandardHeaders, b as StandardRequest, d as StandardResponse } from '../shared/standard-server.R_NaHlxw.mjs';
|
|
2
|
+
|
|
3
|
+
interface ToBatchRequestOptions {
|
|
4
|
+
url: URL;
|
|
5
|
+
method: 'GET' | 'POST';
|
|
6
|
+
headers: StandardHeaders;
|
|
7
|
+
requests: readonly StandardRequest[];
|
|
8
|
+
}
|
|
9
|
+
declare function toBatchRequest(options: ToBatchRequestOptions): StandardRequest;
|
|
10
|
+
declare function parseBatchRequest(request: StandardRequest): StandardRequest[];
|
|
11
|
+
|
|
12
|
+
interface BatchResponseBodyItem extends StandardResponse {
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
interface ToBatchResponseOptions extends StandardResponse {
|
|
16
|
+
body: AsyncIteratorObject<BatchResponseBodyItem>;
|
|
17
|
+
}
|
|
18
|
+
declare function toBatchResponse(options: ToBatchResponseOptions): StandardResponse;
|
|
19
|
+
declare function parseBatchResponse(response: StandardResponse): AsyncGenerator<BatchResponseBodyItem>;
|
|
20
|
+
|
|
21
|
+
declare function toBatchAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
|
|
22
|
+
|
|
23
|
+
export { type BatchResponseBodyItem, type ToBatchRequestOptions, type ToBatchResponseOptions, parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { S as StandardHeaders, b as StandardRequest, d as StandardResponse } from '../shared/standard-server.R_NaHlxw.js';
|
|
2
|
+
|
|
3
|
+
interface ToBatchRequestOptions {
|
|
4
|
+
url: URL;
|
|
5
|
+
method: 'GET' | 'POST';
|
|
6
|
+
headers: StandardHeaders;
|
|
7
|
+
requests: readonly StandardRequest[];
|
|
8
|
+
}
|
|
9
|
+
declare function toBatchRequest(options: ToBatchRequestOptions): StandardRequest;
|
|
10
|
+
declare function parseBatchRequest(request: StandardRequest): StandardRequest[];
|
|
11
|
+
|
|
12
|
+
interface BatchResponseBodyItem extends StandardResponse {
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
interface ToBatchResponseOptions extends StandardResponse {
|
|
16
|
+
body: AsyncIteratorObject<BatchResponseBodyItem>;
|
|
17
|
+
}
|
|
18
|
+
declare function toBatchResponse(options: ToBatchResponseOptions): StandardResponse;
|
|
19
|
+
declare function parseBatchResponse(response: StandardResponse): AsyncGenerator<BatchResponseBodyItem>;
|
|
20
|
+
|
|
21
|
+
declare function toBatchAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
|
|
22
|
+
|
|
23
|
+
export { type BatchResponseBodyItem, type ToBatchRequestOptions, type ToBatchResponseOptions, parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { stringifyJSON, parseEmptyableJSON, isAsyncIteratorObject, isObject } from '@orpc/shared';
|
|
2
|
+
|
|
3
|
+
function toBatchAbortSignal(signals) {
|
|
4
|
+
const realSignals = signals.filter((signal) => signal !== void 0);
|
|
5
|
+
if (realSignals.length === 0 || realSignals.length !== signals.length) {
|
|
6
|
+
return void 0;
|
|
7
|
+
}
|
|
8
|
+
const controller = new AbortController();
|
|
9
|
+
const abortIfAllInputsAborted = () => {
|
|
10
|
+
if (realSignals.every((signal) => signal.aborted)) {
|
|
11
|
+
controller.abort();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
abortIfAllInputsAborted();
|
|
15
|
+
for (const signal of realSignals) {
|
|
16
|
+
signal.addEventListener("abort", () => {
|
|
17
|
+
abortIfAllInputsAborted();
|
|
18
|
+
}, {
|
|
19
|
+
once: true,
|
|
20
|
+
signal: controller.signal
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return controller.signal;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toBatchRequest(options) {
|
|
27
|
+
const url = new URL(options.url);
|
|
28
|
+
let body;
|
|
29
|
+
const batchRequestItems = options.requests.map((request) => ({
|
|
30
|
+
body: request.body,
|
|
31
|
+
headers: Object.keys(request.headers).length ? request.headers : void 0,
|
|
32
|
+
method: request.method === options.method ? void 0 : request.method,
|
|
33
|
+
url: request.url
|
|
34
|
+
}));
|
|
35
|
+
if (options.method === "GET") {
|
|
36
|
+
url.searchParams.append("batch", stringifyJSON(batchRequestItems));
|
|
37
|
+
} else if (options.method === "POST") {
|
|
38
|
+
body = batchRequestItems;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
method: options.method,
|
|
42
|
+
url,
|
|
43
|
+
headers: options.headers,
|
|
44
|
+
body,
|
|
45
|
+
signal: toBatchAbortSignal(options.requests.map((request) => request.signal))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function parseBatchRequest(request) {
|
|
49
|
+
const items = request.method === "GET" ? parseEmptyableJSON(request.url.searchParams.getAll("batch").at(-1)) : request.body;
|
|
50
|
+
if (!Array.isArray(items)) {
|
|
51
|
+
throw new TypeError("Invalid batch request");
|
|
52
|
+
}
|
|
53
|
+
return items.map((item) => {
|
|
54
|
+
return {
|
|
55
|
+
method: item.method ?? request.method,
|
|
56
|
+
url: new URL(item.url),
|
|
57
|
+
headers: item.headers ?? {},
|
|
58
|
+
body: item.body,
|
|
59
|
+
signal: request.signal
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function toBatchResponse(options) {
|
|
65
|
+
return {
|
|
66
|
+
...options,
|
|
67
|
+
body: async function* () {
|
|
68
|
+
try {
|
|
69
|
+
for await (const item of options.body) {
|
|
70
|
+
yield {
|
|
71
|
+
index: item.index,
|
|
72
|
+
status: item.status === options.status ? void 0 : item.status,
|
|
73
|
+
headers: Object.keys(item.headers).length ? item.headers : void 0,
|
|
74
|
+
body: item.body
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
} finally {
|
|
78
|
+
options.body.return?.();
|
|
79
|
+
}
|
|
80
|
+
}()
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function parseBatchResponse(response) {
|
|
84
|
+
const body = response.body;
|
|
85
|
+
if (!isAsyncIteratorObject(body)) {
|
|
86
|
+
throw new TypeError("Invalid batch response", {
|
|
87
|
+
cause: response
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return async function* () {
|
|
91
|
+
try {
|
|
92
|
+
for await (const item of body) {
|
|
93
|
+
if (!isObject(item) || !("index" in item) || typeof item.index !== "number") {
|
|
94
|
+
throw new TypeError("Invalid batch response", {
|
|
95
|
+
cause: item
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
yield {
|
|
99
|
+
index: item.index,
|
|
100
|
+
status: item.status ?? response.status,
|
|
101
|
+
headers: item.headers ?? {},
|
|
102
|
+
body: item.body
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
await body.return?.();
|
|
107
|
+
}
|
|
108
|
+
}();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as StandardHeaders } from './shared/standard-server.R_NaHlxw.mjs';
|
|
2
|
+
export { a as StandardBody, c as StandardLazyRequest, e as StandardLazyResponse, b as StandardRequest, d as StandardResponse } from './shared/standard-server.R_NaHlxw.mjs';
|
|
2
3
|
|
|
3
4
|
interface EventMessage {
|
|
4
5
|
event: string | undefined;
|
|
5
6
|
id: string | undefined;
|
|
6
7
|
data: string | undefined;
|
|
7
8
|
/**
|
|
8
|
-
* The number of milliseconds to wait before retrying the event
|
|
9
|
+
* The number of milliseconds to wait before retrying the event iterator if error occurs.
|
|
9
10
|
*/
|
|
10
11
|
retry: number | undefined;
|
|
11
12
|
comments: string[];
|
|
@@ -51,29 +52,8 @@ type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
|
|
|
51
52
|
declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
|
52
53
|
declare function getEventMeta(container: unknown): EventMeta | undefined;
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
58
|
-
interface StandardRequest {
|
|
59
|
-
/**
|
|
60
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
|
61
|
-
*/
|
|
62
|
-
raw: Record<string, unknown>;
|
|
63
|
-
method: string;
|
|
64
|
-
url: URL;
|
|
65
|
-
headers: StandardHeaders;
|
|
66
|
-
/**
|
|
67
|
-
* The body has been parsed base on the content-type header.
|
|
68
|
-
* This method can safely call multiple times (cached).
|
|
69
|
-
*/
|
|
70
|
-
body: () => Promise<StandardBody>;
|
|
71
|
-
signal: AbortSignal | undefined;
|
|
72
|
-
}
|
|
73
|
-
interface StandardResponse {
|
|
74
|
-
status: number;
|
|
75
|
-
headers: StandardHeaders;
|
|
76
|
-
body: StandardBody;
|
|
77
|
-
}
|
|
55
|
+
declare function generateContentDisposition(filename: string): string;
|
|
56
|
+
declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
|
|
57
|
+
declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
|
|
78
58
|
|
|
79
|
-
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta,
|
|
59
|
+
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta, StandardHeaders, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as StandardHeaders } from './shared/standard-server.R_NaHlxw.js';
|
|
2
|
+
export { a as StandardBody, c as StandardLazyRequest, e as StandardLazyResponse, b as StandardRequest, d as StandardResponse } from './shared/standard-server.R_NaHlxw.js';
|
|
2
3
|
|
|
3
4
|
interface EventMessage {
|
|
4
5
|
event: string | undefined;
|
|
5
6
|
id: string | undefined;
|
|
6
7
|
data: string | undefined;
|
|
7
8
|
/**
|
|
8
|
-
* The number of milliseconds to wait before retrying the event
|
|
9
|
+
* The number of milliseconds to wait before retrying the event iterator if error occurs.
|
|
9
10
|
*/
|
|
10
11
|
retry: number | undefined;
|
|
11
12
|
comments: string[];
|
|
@@ -51,29 +52,8 @@ type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
|
|
|
51
52
|
declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
|
|
52
53
|
declare function getEventMeta(container: unknown): EventMeta | undefined;
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
58
|
-
interface StandardRequest {
|
|
59
|
-
/**
|
|
60
|
-
* Can be { request: Request } or { request: IncomingMessage, response: ServerResponse } based on the adapter.
|
|
61
|
-
*/
|
|
62
|
-
raw: Record<string, unknown>;
|
|
63
|
-
method: string;
|
|
64
|
-
url: URL;
|
|
65
|
-
headers: StandardHeaders;
|
|
66
|
-
/**
|
|
67
|
-
* The body has been parsed base on the content-type header.
|
|
68
|
-
* This method can safely call multiple times (cached).
|
|
69
|
-
*/
|
|
70
|
-
body: () => Promise<StandardBody>;
|
|
71
|
-
signal: AbortSignal | undefined;
|
|
72
|
-
}
|
|
73
|
-
interface StandardResponse {
|
|
74
|
-
status: number;
|
|
75
|
-
headers: StandardHeaders;
|
|
76
|
-
body: StandardBody;
|
|
77
|
-
}
|
|
55
|
+
declare function generateContentDisposition(filename: string): string;
|
|
56
|
+
declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
|
|
57
|
+
declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
|
|
78
58
|
|
|
79
|
-
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta,
|
|
59
|
+
export { ErrorEvent, type ErrorEventOptions, EventDecoder, EventDecoderError, type EventDecoderOptions, EventDecoderStream, EventEncoderError, type EventMessage, type EventMeta, StandardHeaders, 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
|
}
|
|
@@ -71,7 +70,7 @@ class EventDecoder {
|
|
|
71
70
|
}
|
|
72
71
|
end() {
|
|
73
72
|
if (this.incomplete) {
|
|
74
|
-
throw new EventDecoderError("
|
|
73
|
+
throw new EventDecoderError("Event Iterator ended before complete");
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
}
|
|
@@ -98,22 +97,22 @@ class EventDecoderStream extends TransformStream {
|
|
|
98
97
|
|
|
99
98
|
function assertEventId(id) {
|
|
100
99
|
if (id.includes("\n")) {
|
|
101
|
-
throw new EventEncoderError("Event
|
|
100
|
+
throw new EventEncoderError("Event's id must not contain a newline character");
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
function assertEventName(event) {
|
|
105
104
|
if (event.includes("\n")) {
|
|
106
|
-
throw new EventEncoderError("Event
|
|
105
|
+
throw new EventEncoderError("Event's event must not contain a newline character");
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
function assertEventRetry(retry) {
|
|
110
109
|
if (!Number.isInteger(retry) || retry < 0) {
|
|
111
|
-
throw new EventEncoderError("Event
|
|
110
|
+
throw new EventEncoderError("Event's retry must be a integer and >= 0");
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
function assertEventComment(comment) {
|
|
115
114
|
if (comment.includes("\n")) {
|
|
116
|
-
throw new EventEncoderError("Event
|
|
115
|
+
throw new EventEncoderError("Event's comment must not contain a newline character");
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
function encodeEventData(data) {
|
|
@@ -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 };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface StandardHeaders {
|
|
2
|
+
[key: string]: string | string[] | undefined;
|
|
3
|
+
}
|
|
4
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
5
|
+
interface StandardRequest {
|
|
6
|
+
method: string;
|
|
7
|
+
url: URL;
|
|
8
|
+
headers: StandardHeaders;
|
|
9
|
+
/**
|
|
10
|
+
* The body has been parsed based on the content-type header.
|
|
11
|
+
*/
|
|
12
|
+
body: StandardBody;
|
|
13
|
+
signal: AbortSignal | undefined;
|
|
14
|
+
}
|
|
15
|
+
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
16
|
+
/**
|
|
17
|
+
* The body has been parsed based on the content-type header.
|
|
18
|
+
* This method can safely call multiple times (cached).
|
|
19
|
+
*/
|
|
20
|
+
body: () => Promise<StandardBody>;
|
|
21
|
+
}
|
|
22
|
+
interface StandardResponse {
|
|
23
|
+
status: number;
|
|
24
|
+
headers: StandardHeaders;
|
|
25
|
+
/**
|
|
26
|
+
* The body has been parsed based on the content-type header.
|
|
27
|
+
*/
|
|
28
|
+
body: StandardBody;
|
|
29
|
+
}
|
|
30
|
+
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
31
|
+
/**
|
|
32
|
+
* The body has been parsed based on the content-type header.
|
|
33
|
+
* This method can safely call multiple times (cached).
|
|
34
|
+
*/
|
|
35
|
+
body: () => Promise<StandardBody>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { StandardHeaders as S, StandardBody as a, StandardRequest as b, StandardLazyRequest as c, StandardResponse as d, StandardLazyResponse as e };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface StandardHeaders {
|
|
2
|
+
[key: string]: string | string[] | undefined;
|
|
3
|
+
}
|
|
4
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
5
|
+
interface StandardRequest {
|
|
6
|
+
method: string;
|
|
7
|
+
url: URL;
|
|
8
|
+
headers: StandardHeaders;
|
|
9
|
+
/**
|
|
10
|
+
* The body has been parsed based on the content-type header.
|
|
11
|
+
*/
|
|
12
|
+
body: StandardBody;
|
|
13
|
+
signal: AbortSignal | undefined;
|
|
14
|
+
}
|
|
15
|
+
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
16
|
+
/**
|
|
17
|
+
* The body has been parsed based on the content-type header.
|
|
18
|
+
* This method can safely call multiple times (cached).
|
|
19
|
+
*/
|
|
20
|
+
body: () => Promise<StandardBody>;
|
|
21
|
+
}
|
|
22
|
+
interface StandardResponse {
|
|
23
|
+
status: number;
|
|
24
|
+
headers: StandardHeaders;
|
|
25
|
+
/**
|
|
26
|
+
* The body has been parsed based on the content-type header.
|
|
27
|
+
*/
|
|
28
|
+
body: StandardBody;
|
|
29
|
+
}
|
|
30
|
+
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
31
|
+
/**
|
|
32
|
+
* The body has been parsed based on the content-type header.
|
|
33
|
+
* This method can safely call multiple times (cached).
|
|
34
|
+
*/
|
|
35
|
+
body: () => Promise<StandardBody>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { StandardHeaders as S, StandardBody as a, StandardRequest as b, StandardLazyRequest as c, StandardResponse as d, StandardLazyResponse as e };
|
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.cf06e99",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -17,14 +17,18 @@
|
|
|
17
17
|
"types": "./dist/index.d.mts",
|
|
18
18
|
"import": "./dist/index.mjs",
|
|
19
19
|
"default": "./dist/index.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./batch": {
|
|
22
|
+
"types": "./dist/batch/index.d.mts",
|
|
23
|
+
"import": "./dist/batch/index.mjs",
|
|
24
|
+
"default": "./dist/batch/index.mjs"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"files": [
|
|
23
28
|
"dist"
|
|
24
29
|
],
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@orpc/shared": "0.0.0-next.cd121e3"
|
|
31
|
+
"@orpc/shared": "0.0.0-next.cf06e99"
|
|
28
32
|
},
|
|
29
33
|
"scripts": {
|
|
30
34
|
"build": "unbuild",
|