@orpc/standard-server 0.0.0-next.eae6003 → 0.0.0-next.eaec0b2

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 CHANGED
@@ -1,22 +1,25 @@
1
1
  <div align="center">
2
- <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
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/unnoq/orpc">
9
- <img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
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/unnoq/orpc/blob/main/LICENSE">
15
- <img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
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>
@@ -30,7 +33,8 @@
30
33
  - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
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
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
+ - **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
37
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
34
38
  - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
39
  - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
40
  - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
@@ -38,25 +42,24 @@
38
42
  - **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
39
43
  - **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
40
44
  - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
41
- - **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
42
45
 
43
46
  ## Documentation
44
47
 
45
- You can find the full documentation [here](https://orpc.unnoq.com).
48
+ You can find the full documentation [here](https://orpc.dev).
46
49
 
47
50
  ## Packages
48
51
 
49
52
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
53
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
54
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
- - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
55
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
56
+ - [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
57
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
53
58
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
54
- - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
55
- - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
56
- - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
57
- - [@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
+ - [@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.
58
61
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
- - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
62
+ - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
60
63
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
61
64
  - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
62
65
  - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
@@ -75,4 +78,4 @@ This package is designed to be used as a base for other server implementations.
75
78
 
76
79
  ## License
77
80
 
78
- Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
81
+ Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/main/LICENSE) for more information.
@@ -1,4 +1,5 @@
1
- import { S as StandardHeaders, b as StandardRequest, d as StandardResponse } from '../shared/standard-server.R_NaHlxw.mjs';
1
+ import { S as StandardHeaders, c as StandardRequest, e as StandardResponse } from '../shared/standard-server.BD8Sg1A5.mjs';
2
+ import { Promisable } from '@orpc/shared';
2
3
 
3
4
  interface ToBatchRequestOptions {
4
5
  url: URL;
@@ -9,16 +10,21 @@ interface ToBatchRequestOptions {
9
10
  declare function toBatchRequest(options: ToBatchRequestOptions): StandardRequest;
10
11
  declare function parseBatchRequest(request: StandardRequest): StandardRequest[];
11
12
 
13
+ type BatchResponseMode = 'streaming' | 'buffered';
12
14
  interface BatchResponseBodyItem extends StandardResponse {
13
15
  index: number;
14
16
  }
15
17
  interface ToBatchResponseOptions extends StandardResponse {
16
18
  body: AsyncIteratorObject<BatchResponseBodyItem>;
19
+ /**
20
+ * @default 'streaming'
21
+ */
22
+ mode?: BatchResponseMode;
17
23
  }
18
- declare function toBatchResponse(options: ToBatchResponseOptions): StandardResponse;
24
+ declare function toBatchResponse(options: ToBatchResponseOptions): Promisable<StandardResponse>;
19
25
  declare function parseBatchResponse(response: StandardResponse): AsyncGenerator<BatchResponseBodyItem>;
20
26
 
21
27
  declare function toBatchAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
22
28
 
23
29
  export { parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
24
- export type { BatchResponseBodyItem, ToBatchRequestOptions, ToBatchResponseOptions };
30
+ export type { BatchResponseBodyItem, BatchResponseMode, ToBatchRequestOptions, ToBatchResponseOptions };
@@ -1,4 +1,5 @@
1
- import { S as StandardHeaders, b as StandardRequest, d as StandardResponse } from '../shared/standard-server.R_NaHlxw.js';
1
+ import { S as StandardHeaders, c as StandardRequest, e as StandardResponse } from '../shared/standard-server.BD8Sg1A5.js';
2
+ import { Promisable } from '@orpc/shared';
2
3
 
3
4
  interface ToBatchRequestOptions {
4
5
  url: URL;
@@ -9,16 +10,21 @@ interface ToBatchRequestOptions {
9
10
  declare function toBatchRequest(options: ToBatchRequestOptions): StandardRequest;
10
11
  declare function parseBatchRequest(request: StandardRequest): StandardRequest[];
11
12
 
13
+ type BatchResponseMode = 'streaming' | 'buffered';
12
14
  interface BatchResponseBodyItem extends StandardResponse {
13
15
  index: number;
14
16
  }
15
17
  interface ToBatchResponseOptions extends StandardResponse {
16
18
  body: AsyncIteratorObject<BatchResponseBodyItem>;
19
+ /**
20
+ * @default 'streaming'
21
+ */
22
+ mode?: BatchResponseMode;
17
23
  }
18
- declare function toBatchResponse(options: ToBatchResponseOptions): StandardResponse;
24
+ declare function toBatchResponse(options: ToBatchResponseOptions): Promisable<StandardResponse>;
19
25
  declare function parseBatchResponse(response: StandardResponse): AsyncGenerator<BatchResponseBodyItem>;
20
26
 
21
27
  declare function toBatchAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
22
28
 
23
29
  export { parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
24
- export type { BatchResponseBodyItem, ToBatchRequestOptions, ToBatchResponseOptions };
30
+ export type { BatchResponseBodyItem, BatchResponseMode, ToBatchRequestOptions, ToBatchResponseOptions };
@@ -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);
@@ -62,33 +62,63 @@ function parseBatchRequest(request) {
62
62
  }
63
63
 
64
64
  function toBatchResponse(options) {
65
- return {
66
- ...options,
67
- body: async function* () {
65
+ const mode = options.mode ?? "streaming";
66
+ const minifyResponseItem = (item) => {
67
+ return {
68
+ index: item.index,
69
+ status: item.status === options.status ? void 0 : item.status,
70
+ headers: Object.keys(item.headers).length ? item.headers : void 0,
71
+ body: item.body
72
+ };
73
+ };
74
+ if (mode === "buffered") {
75
+ return (async () => {
68
76
  try {
77
+ const body = [];
69
78
  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
- };
79
+ body.push(minifyResponseItem(item));
76
80
  }
81
+ return {
82
+ headers: options.headers,
83
+ status: options.status,
84
+ body
85
+ };
77
86
  } finally {
78
- options.body.return?.();
87
+ await options.body.return?.();
79
88
  }
80
- }()
89
+ })();
90
+ }
91
+ return {
92
+ headers: options.headers,
93
+ status: options.status,
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?.();
113
+ }
114
+ }
115
+ )
81
116
  };
82
117
  }
83
118
  function parseBatchResponse(response) {
84
119
  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 {
120
+ if (isAsyncIteratorObject(body) || Array.isArray(body)) {
121
+ const iterator = (async function* () {
92
122
  for await (const item of body) {
93
123
  if (!isObject(item) || !("index" in item) || typeof item.index !== "number") {
94
124
  throw new TypeError("Invalid batch response", {
@@ -102,10 +132,19 @@ function parseBatchResponse(response) {
102
132
  body: item.body
103
133
  };
104
134
  }
105
- } finally {
106
- await body.return?.();
107
- }
108
- }();
135
+ })();
136
+ return new AsyncIteratorClass(
137
+ () => iterator.next(),
138
+ async (reason) => {
139
+ if (reason !== "next" && isAsyncIteratorObject(body)) {
140
+ await body.return?.();
141
+ }
142
+ }
143
+ );
144
+ }
145
+ throw new TypeError("Invalid batch response", {
146
+ cause: response
147
+ });
109
148
  }
110
149
 
111
150
  export { parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
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';
1
+ import { AsyncIteratorClass } from '@orpc/shared';
2
+ import { S as StandardHeaders, a as StandardLazyResponse } from './shared/standard-server.BD8Sg1A5.mjs';
3
+ export { b as StandardBody, d as StandardLazyRequest, c as StandardRequest, e as StandardResponse } from './shared/standard-server.BD8Sg1A5.mjs';
3
4
 
4
5
  interface EventMessage {
5
6
  event: string | undefined;
@@ -52,10 +53,23 @@ type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
52
53
  declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
53
54
  declare function getEventMeta(container: unknown): EventMeta | undefined;
54
55
 
56
+ interface HibernationEventIteratorCallback {
57
+ (id: string): void;
58
+ }
59
+ declare class HibernationEventIterator<T, TReturn = unknown, TNext = unknown> extends AsyncIteratorClass<T, TReturn, TNext> {
60
+ /**
61
+ * this property is not transferred to the client, so it should be optional for type safety
62
+ */
63
+ readonly hibernationCallback?: HibernationEventIteratorCallback;
64
+ constructor(hibernationCallback: HibernationEventIteratorCallback);
65
+ }
66
+
55
67
  declare function generateContentDisposition(filename: string): string;
56
68
  declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
57
69
  declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
58
70
  declare function flattenHeader(header: string | readonly string[] | undefined): string | undefined;
71
+ declare function replicateStandardLazyResponse(response: StandardLazyResponse, count: number): StandardLazyResponse[];
72
+ declare function isEventIteratorHeaders(headers: StandardHeaders): boolean;
59
73
 
60
- export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, StandardHeaders, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
61
- export type { ErrorEventOptions, EventDecoderOptions, EventMessage, EventMeta };
74
+ export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, HibernationEventIterator, StandardHeaders, StandardLazyResponse, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isEventIteratorHeaders, mergeStandardHeaders, replicateStandardLazyResponse, withEventMeta };
75
+ export type { ErrorEventOptions, EventDecoderOptions, EventMessage, EventMeta, HibernationEventIteratorCallback };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
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';
1
+ import { AsyncIteratorClass } from '@orpc/shared';
2
+ import { S as StandardHeaders, a as StandardLazyResponse } from './shared/standard-server.BD8Sg1A5.js';
3
+ export { b as StandardBody, d as StandardLazyRequest, c as StandardRequest, e as StandardResponse } from './shared/standard-server.BD8Sg1A5.js';
3
4
 
4
5
  interface EventMessage {
5
6
  event: string | undefined;
@@ -52,10 +53,23 @@ type EventMeta = Partial<Pick<EventMessage, 'retry' | 'id' | 'comments'>>;
52
53
  declare function withEventMeta<T extends object>(container: T, meta: EventMeta): T;
53
54
  declare function getEventMeta(container: unknown): EventMeta | undefined;
54
55
 
56
+ interface HibernationEventIteratorCallback {
57
+ (id: string): void;
58
+ }
59
+ declare class HibernationEventIterator<T, TReturn = unknown, TNext = unknown> extends AsyncIteratorClass<T, TReturn, TNext> {
60
+ /**
61
+ * this property is not transferred to the client, so it should be optional for type safety
62
+ */
63
+ readonly hibernationCallback?: HibernationEventIteratorCallback;
64
+ constructor(hibernationCallback: HibernationEventIteratorCallback);
65
+ }
66
+
55
67
  declare function generateContentDisposition(filename: string): string;
56
68
  declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
57
69
  declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
58
70
  declare function flattenHeader(header: string | readonly string[] | undefined): string | undefined;
71
+ declare function replicateStandardLazyResponse(response: StandardLazyResponse, count: number): StandardLazyResponse[];
72
+ declare function isEventIteratorHeaders(headers: StandardHeaders): boolean;
59
73
 
60
- export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, StandardHeaders, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
61
- export type { ErrorEventOptions, EventDecoderOptions, EventMessage, EventMeta };
74
+ export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, HibernationEventIterator, StandardHeaders, StandardLazyResponse, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isEventIteratorHeaders, mergeStandardHeaders, replicateStandardLazyResponse, withEventMeta };
75
+ export type { ErrorEventOptions, EventDecoderOptions, EventMessage, EventMeta, HibernationEventIteratorCallback };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { isTypescriptObject, toArray } from '@orpc/shared';
1
+ import { isTypescriptObject, AsyncIteratorClass, tryDecodeURIComponent, toArray, once, isAsyncIteratorObject, replicateAsyncIterator } from '@orpc/shared';
2
2
 
3
3
  class EventEncoderError extends TypeError {
4
4
  }
@@ -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
  }
@@ -182,6 +184,23 @@ function getEventMeta(container) {
182
184
  return isTypescriptObject(container) ? Reflect.get(container, EVENT_SOURCE_META_SYMBOL) : void 0;
183
185
  }
184
186
 
187
+ class HibernationEventIterator extends AsyncIteratorClass {
188
+ /**
189
+ * this property is not transferred to the client, so it should be optional for type safety
190
+ */
191
+ hibernationCallback;
192
+ constructor(hibernationCallback) {
193
+ super(async () => {
194
+ throw new Error("Cannot iterate over hibernating iterator directly");
195
+ }, async (reason) => {
196
+ if (reason !== "next") {
197
+ throw new Error("Cannot cleanup hibernating iterator directly");
198
+ }
199
+ });
200
+ this.hibernationCallback = hibernationCallback;
201
+ }
202
+ }
203
+
185
204
  function generateContentDisposition(filename) {
186
205
  const escapedFileName = filename.replace(/"/g, '\\"');
187
206
  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)));
@@ -190,7 +209,7 @@ function generateContentDisposition(filename) {
190
209
  function getFilenameFromContentDisposition(contentDisposition) {
191
210
  const encodedFilenameStarMatch = contentDisposition.match(/filename\*=(UTF-8'')?([^;]*)/i);
192
211
  if (encodedFilenameStarMatch && typeof encodedFilenameStarMatch[2] === "string") {
193
- return decodeURIComponent(encodedFilenameStarMatch[2]);
212
+ return tryDecodeURIComponent(encodedFilenameStarMatch[2]);
194
213
  }
195
214
  const encodedFilenameMatch = contentDisposition.match(/filename="((?:\\"|[^"])*)"/i);
196
215
  if (encodedFilenameMatch && typeof encodedFilenameMatch[1] === "string") {
@@ -223,5 +242,27 @@ function flattenHeader(header) {
223
242
  }
224
243
  return header.join(", ");
225
244
  }
245
+ function replicateStandardLazyResponse(response, count) {
246
+ const replicated = [];
247
+ let bodyPromise;
248
+ let replicatedAsyncIteratorObjects;
249
+ for (let i = 0; i < count; i++) {
250
+ replicated.push({
251
+ ...response,
252
+ body: once(async () => {
253
+ const body = await (bodyPromise ??= response.body());
254
+ if (!isAsyncIteratorObject(body)) {
255
+ return body;
256
+ }
257
+ replicatedAsyncIteratorObjects ??= replicateAsyncIterator(body, count);
258
+ return replicatedAsyncIteratorObjects.shift();
259
+ })
260
+ });
261
+ }
262
+ return replicated;
263
+ }
264
+ function isEventIteratorHeaders(headers) {
265
+ return Boolean(flattenHeader(headers["content-type"])?.startsWith("text/event-stream") && flattenHeader(headers["content-disposition"]) === void 0);
266
+ }
226
267
 
227
- export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
268
+ export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, HibernationEventIterator, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, flattenHeader, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, isEventIteratorHeaders, mergeStandardHeaders, replicateStandardLazyResponse, withEventMeta };
@@ -35,4 +35,4 @@ interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
35
35
  body: () => Promise<StandardBody>;
36
36
  }
37
37
 
38
- export type { StandardHeaders as S, StandardBody as a, StandardRequest as b, StandardLazyRequest as c, StandardResponse as d, StandardLazyResponse as e };
38
+ export type { StandardHeaders as S, StandardLazyResponse as a, StandardBody as b, StandardRequest as c, StandardLazyRequest as d, StandardResponse as e };
@@ -35,4 +35,4 @@ interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
35
35
  body: () => Promise<StandardBody>;
36
36
  }
37
37
 
38
- export type { StandardHeaders as S, StandardBody as a, StandardRequest as b, StandardLazyRequest as c, StandardResponse as d, StandardLazyResponse as e };
38
+ export type { StandardHeaders as S, StandardLazyResponse as a, StandardBody as b, StandardRequest as c, StandardLazyRequest as d, StandardResponse as e };
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.eae6003",
4
+ "version": "0.0.0-next.eaec0b2",
5
5
  "license": "MIT",
6
- "homepage": "https://unnoq.com",
6
+ "homepage": "https://orpc.dev",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/unnoq/orpc.git",
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.eae6003"
31
+ "@orpc/shared": "0.0.0-next.eaec0b2"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "unbuild",