@orpc/node 2.0.0-beta.46 → 2.0.0-beta.47

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
@@ -156,10 +156,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
156
156
  <td align="center"><a href="https://github.com/christ12938?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
157
157
  <td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&amp;v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
158
158
  <td align="center"><a href="https://github.com/itigoore01?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&amp;v=4" width="167" alt="shota"/><br />shota</a></td>
159
+ <td align="center"><a href="https://github.com/Nic13Gamer?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nicholas"><img src="https://avatars.githubusercontent.com/u/54724556?u=56a7ab430ce7a80d648ab6eba051d454a818ed0b&amp;v=4" width="167" alt="Nicholas"/><br />Nicholas</a></td>
159
160
  <td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&amp;v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
160
- <td align="center"><a href="https://github.com/hoangbn?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&amp;v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
161
161
  </tr>
162
162
  <tr>
163
+ <td align="center"><a href="https://github.com/hoangbn?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&amp;v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
163
164
  <td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
164
165
  <td align="center"><a href="https://automatio.ai/?ref=middleapi&amp;utm_source=middleapi&amp;utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&amp;v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
165
166
  </tr>
@@ -198,7 +199,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
198
199
  </tr>
199
200
  </table>
200
201
 
201
- With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
202
+ With thanks to [39 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
202
203
 
203
204
  ## Open Source Programs
204
205
 
@@ -206,7 +207,9 @@ With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who h
206
207
 
207
208
  <table>
208
209
  <tr>
209
- <td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude for Open Source</a></td>
210
+ <td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude</a></td>
211
+ <td align="center"><a href="https://pullfrog.com/for-oss" target="_blank" rel="noopener" title="Pullfrog for OSS"><img src="https://avatars.githubusercontent.com/in/1768019?s=128&amp;v=4" width="64" alt="Pullfrog"/><br />Pullfrog</a></td>
212
+ <td align="center"><a href="https://macroscope.com/open-source" target="_blank" rel="noopener" title="Macroscope for Open Source"><img src="https://avatars.githubusercontent.com/in/900172?s=128&amp;v=4" width="64" alt="Macroscope"/><br />Macroscope</a></td>
210
213
  </tr>
211
214
  </table>
212
215
 
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { Duplex } from 'node:stream';
2
2
  import { constants, createGzip, createDeflate, createDeflateRaw } from 'node:zlib';
3
3
  import { BATCH_HEADER, negotiateResponseCompressionEncoding, toCompressedHeaders } from '@orpc/server/plugins';
4
- import { toArray, stringifyJSON, mergeHttpPath, safeDecodeURIComponent, matchesHttpPathPrefix, safeEncodeURIComponent, isCompressibleContentType, parseAcceptEncodingQualities, isAcceptableEncoding, getTracer, value, isAsyncIteratorObject, override, wrapAsyncIterator, wrapReadableStream } from '@orpc/shared';
4
+ import { toArray, mergeHttpPath, safeDecodeURIComponent, matchesHttpPathPrefix, safeEncodeURIComponent, isCompressibleContentType, parseAcceptEncodingQualities, isAcceptableEncoding, getTracer, value, isAsyncIteratorObject, override, wrapAsyncIterator, wrapReadableStream } from '@orpc/shared';
5
5
  import { flattenStandardHeader, parseStandardUrl, resolveStandardBodyHint, getFilenameFromContentDisposition } from '@standard-server/core';
6
+ import { toFetchBody, toFetchHeaders, toStandardBody } from '@standard-server/fetch';
6
7
  import { createReadStream, openAsBlob } from 'node:fs';
7
8
  import { realpath, stat, mkdtemp, appendFile, rm } from 'node:fs/promises';
8
9
  import path from 'node:path';
@@ -11,7 +12,6 @@ import mime from 'mime';
11
12
  import { Buffer } from 'node:buffer';
12
13
  import { tmpdir } from 'node:os';
13
14
  import { ORPCError } from '@orpc/server';
14
- import { toFetchHeaders, toStandardBody } from '@standard-server/fetch';
15
15
 
16
16
  class BatchResponseCompressionHandlerPlugin {
17
17
  name = "~batch-response-compression";
@@ -48,32 +48,22 @@ class BatchResponseCompressionHandlerPlugin {
48
48
  let stream;
49
49
  let bodyHeaders;
50
50
  if (Array.isArray(body)) {
51
- const json = new Blob([stringifyJSON(body)]);
51
+ const [string, jsonHeaders] = toFetchBody(body, headers);
52
+ const json = new Blob([string]);
52
53
  if (json.size < this.threshold) {
53
54
  return result;
54
55
  }
55
56
  stream = json.stream();
56
57
  bodyHeaders = {
57
- // Serialized here rather than by the adapter, which no longer sees the array
58
- "content-type": "application/json",
59
- "standard-server": []
58
+ "content-type": jsonHeaders["content-type"],
59
+ // An empty hint rather than none, so the adapter does not hint the compressed stream as `octet-stream`
60
+ "standard-server": jsonHeaders["standard-server"] ?? []
60
61
  };
61
- } else if (body instanceof Blob) {
62
- if (Number.isFinite(body.size) && body.size < this.threshold) {
62
+ } else if (body instanceof Blob || body instanceof ReadableStream) {
63
+ if (body instanceof Blob && Number.isFinite(body.size) && body.size < this.threshold) {
63
64
  return result;
64
65
  }
65
- stream = body.stream();
66
- bodyHeaders = {
67
- /**
68
- * The blob is gone once it becomes a stream, so the type it carried is stated here. The
69
- * batch plugin puts it there rather than in the headers, because it builds the body
70
- * itself instead of leaving it to the adapter.
71
- */
72
- "content-type": body.type,
73
- "standard-server": "octet-stream"
74
- };
75
- } else if (body instanceof ReadableStream) {
76
- stream = body;
66
+ stream = body instanceof Blob ? body.stream() : body;
77
67
  bodyHeaders = { "standard-server": "octet-stream" };
78
68
  } else {
79
69
  return result;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/node",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.46",
4
+ "version": "2.0.0-beta.47",
5
5
  "description": "Node.js plugins for oRPC: static file serving, temporary file uploads, and batch response compression",
6
6
  "license": "MIT",
7
7
  "funding": [
@@ -36,15 +36,15 @@
36
36
  "dist"
37
37
  ],
38
38
  "dependencies": {
39
- "@orpc/server": "2.0.0-beta.46",
40
- "@orpc/shared": "2.0.0-beta.46",
41
- "@standard-server/core": "~0.11.0",
42
- "@standard-server/fetch": "~0.11.0",
43
- "@standard-server/node": "~0.11.0",
39
+ "@orpc/server": "2.0.0-beta.47",
40
+ "@orpc/shared": "2.0.0-beta.47",
41
+ "@standard-server/core": "~0.13.0",
42
+ "@standard-server/fetch": "~0.13.0",
43
+ "@standard-server/node": "~0.13.0",
44
44
  "mime": "^4.1.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@orpc/client": "2.0.0-beta.46",
47
+ "@orpc/client": "2.0.0-beta.47",
48
48
  "supertest": "^7.3.1"
49
49
  },
50
50
  "scripts": {