@orpc/standard-server 0.0.0-next.05d8f9b → 0.0.0-next.08f0a9e

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.
@@ -20,4 +20,5 @@ declare function parseBatchResponse(response: StandardResponse): AsyncGenerator<
20
20
 
21
21
  declare function toBatchAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
22
22
 
23
- export { type BatchResponseBodyItem, type ToBatchRequestOptions, type ToBatchResponseOptions, parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
23
+ export { parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
24
+ export type { BatchResponseBodyItem, ToBatchRequestOptions, ToBatchResponseOptions };
@@ -20,4 +20,5 @@ declare function parseBatchResponse(response: StandardResponse): AsyncGenerator<
20
20
 
21
21
  declare function toBatchAbortSignal(signals: readonly (AbortSignal | undefined)[]): AbortSignal | undefined;
22
22
 
23
- export { type BatchResponseBodyItem, type ToBatchRequestOptions, type ToBatchResponseOptions, parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
23
+ export { parseBatchRequest, parseBatchResponse, toBatchAbortSignal, toBatchRequest, toBatchResponse };
24
+ export type { BatchResponseBodyItem, ToBatchRequestOptions, ToBatchResponseOptions };
@@ -62,7 +62,23 @@ function parseBatchRequest(request) {
62
62
  }
63
63
 
64
64
  function toBatchResponse(options) {
65
- return 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
+ };
66
82
  }
67
83
  function parseBatchResponse(response) {
68
84
  const body = response.body;
@@ -74,12 +90,17 @@ function parseBatchResponse(response) {
74
90
  return async function* () {
75
91
  try {
76
92
  for await (const item of body) {
77
- if (!isObject(item) || !("index" in item) || !("status" in item) || !("headers" in item)) {
93
+ if (!isObject(item) || !("index" in item) || typeof item.index !== "number") {
78
94
  throw new TypeError("Invalid batch response", {
79
95
  cause: item
80
96
  });
81
97
  }
82
- yield item;
98
+ yield {
99
+ index: item.index,
100
+ status: item.status ?? response.status,
101
+ headers: item.headers ?? {},
102
+ body: item.body
103
+ };
83
104
  }
84
105
  } finally {
85
106
  await body.return?.();
package/dist/index.d.mts CHANGED
@@ -56,4 +56,5 @@ declare function generateContentDisposition(filename: string): string;
56
56
  declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
57
57
  declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
58
58
 
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 };
59
+ export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, StandardHeaders, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
60
+ export type { ErrorEventOptions, EventDecoderOptions, EventMessage, EventMeta };
package/dist/index.d.ts CHANGED
@@ -56,4 +56,5 @@ declare function generateContentDisposition(filename: string): string;
56
56
  declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
57
57
  declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
58
58
 
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 };
59
+ export { ErrorEvent, EventDecoder, EventDecoderError, EventDecoderStream, EventEncoderError, StandardHeaders, assertEventComment, assertEventId, assertEventName, assertEventRetry, decodeEventMessage, encodeEventComments, encodeEventData, encodeEventMessage, generateContentDisposition, getEventMeta, getFilenameFromContentDisposition, mergeStandardHeaders, withEventMeta };
60
+ export type { ErrorEventOptions, EventDecoderOptions, EventMessage, EventMeta };
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.05d8f9b",
4
+ "version": "0.0.0-next.08f0a9e",
5
5
  "license": "MIT",
6
6
  "homepage": "https://unnoq.com",
7
7
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@orpc/shared": "0.0.0-next.05d8f9b"
31
+ "@orpc/shared": "0.0.0-next.08f0a9e"
32
32
  },
33
33
  "scripts": {
34
34
  "build": "unbuild",