@trpc/server 11.0.0-next-beta.264 → 11.0.0-next-beta.271

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.
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAKnE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAkC5B"}
1
+ {"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAKnE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAoC5B"}
@@ -20,6 +20,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
20
20
  _done(null, body);
21
21
  });
22
22
  let prefix = opts.prefix ?? '';
23
+ const websocketPrefix = prefix;
23
24
  // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
24
25
  // @ts-expect-error property 'default' does not exists on type ...
25
26
  if (typeof fastifyTRPCPlugin.default !== 'function') {
@@ -37,6 +38,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
37
38
  if (opts.useWSS) {
38
39
  ws.applyWSSHandler({
39
40
  ...opts.trpcOptions,
41
+ prefix: websocketPrefix,
40
42
  wss: fastify.websocketServer
41
43
  });
42
44
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -18,6 +18,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
18
18
  _done(null, body);
19
19
  });
20
20
  let prefix = opts.prefix ?? '';
21
+ const websocketPrefix = prefix;
21
22
  // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
22
23
  // @ts-expect-error property 'default' does not exists on type ...
23
24
  if (typeof fastifyTRPCPlugin.default !== 'function') {
@@ -35,6 +36,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
35
36
  if (opts.useWSS) {
36
37
  applyWSSHandler({
37
38
  ...opts.trpcOptions,
39
+ prefix: websocketPrefix,
38
40
  wss: fastify.websocketServer
39
41
  });
40
42
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -31,6 +31,7 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<TR
31
31
  }) & {
32
32
  wss: ws.WebSocketServer;
33
33
  process?: NodeJS.Process;
34
+ prefix?: string;
34
35
  };
35
36
  export declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
36
37
  broadcastReconnectNotification: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAQrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAY/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,8BAA8B,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,EAC7D,MAAM,CACP,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC1D,IAAI,EAAE,yBAAyB,KAC5B,YAAY,CAAC,kBAAkB,CAAC,OAAO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OAAO,CAAC,CAAC,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,kBAAkB,CAC3E,OAAO,EACP,eAAe,CAChB,GACC,CAAC,MAAM,SAAS,kBAAkB,CAAC,OAAO,CAAC,GACvC;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC7C,GACD;IACE;;QAEI;IACJ,aAAa,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC5C,CAAC,GAAG;IACP,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEJ,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EA4QjC"}
@@ -14,9 +14,12 @@ var observable = require('../observable/observable.js');
14
14
  * @link https://github.com/trpc/trpc/pull/5279
15
15
  */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
16
16
  function applyWSSHandler(opts) {
17
- const { wss , createContext , router: router$1 } = opts;
17
+ const { wss , createContext , router: router$1 , prefix } = opts;
18
18
  const { transformer: transformer$1 } = router$1._def._config;
19
19
  wss.on('connection', async (client, req)=>{
20
+ if (prefix && !req.url?.startsWith(prefix)) {
21
+ return;
22
+ }
20
23
  const clientSubscriptions = new Map();
21
24
  function respond(untransformedJSON) {
22
25
  client.send(JSON.stringify(transformer.transformTRPCResponse(router$1._def._config, untransformedJSON)));
@@ -12,9 +12,12 @@ import { isObservable } from '../observable/observable.mjs';
12
12
  * @link https://github.com/trpc/trpc/pull/5279
13
13
  */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
14
14
  function applyWSSHandler(opts) {
15
- const { wss , createContext , router } = opts;
15
+ const { wss , createContext , router , prefix } = opts;
16
16
  const { transformer } = router._def._config;
17
17
  wss.on('connection', async (client, req)=>{
18
+ if (prefix && !req.url?.startsWith(prefix)) {
19
+ return;
20
+ }
18
21
  const clientSubscriptions = new Map();
19
22
  function respond(untransformedJSON) {
20
23
  client.send(JSON.stringify(transformTRPCResponse(router._def._config, untransformedJSON)));
@@ -1,12 +1,12 @@
1
1
  {
2
- "bundleSize": 92119,
3
- "bundleOrigSize": 145134,
4
- "bundleReduction": 36.53,
2
+ "bundleSize": 92285,
3
+ "bundleOrigSize": 145299,
4
+ "bundleReduction": 36.49,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/adapters/ws.ts",
8
- "size": 9877,
9
- "origSize": 9169,
8
+ "size": 9970,
9
+ "origSize": 9269,
10
10
  "renderedExports": [
11
11
  "applyWSSHandler"
12
12
  ],
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
16
16
  ],
17
- "percent": 10.72,
17
+ "percent": 10.8,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "removedExports": [],
28
28
  "dependents": [],
29
- "percent": 10.05,
29
+ "percent": 10.03,
30
30
  "reduction": 21.53
31
31
  },
32
32
  {
@@ -45,7 +45,7 @@
45
45
  "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
46
46
  "/src/unstable-core-do-not-import/initTRPC.ts"
47
47
  ],
48
- "percent": 6.56,
48
+ "percent": 6.54,
49
49
  "reduction": 37.21
50
50
  },
51
51
  {
@@ -61,7 +61,7 @@
61
61
  "/src/unstable-core-do-not-import.ts",
62
62
  "/src/unstable-core-do-not-import/initTRPC.ts"
63
63
  ],
64
- "percent": 6.08,
64
+ "percent": 6.07,
65
65
  "reduction": 52.05
66
66
  },
67
67
  {
@@ -77,7 +77,7 @@
77
77
  "dependents": [
78
78
  "/src/adapters/node-http/content-type/form-data/index.ts"
79
79
  ],
80
- "percent": 5.4,
80
+ "percent": 5.39,
81
81
  "reduction": 36.77
82
82
  },
83
83
  {
@@ -91,7 +91,7 @@
91
91
  ],
92
92
  "removedExports": [],
93
93
  "dependents": [],
94
- "percent": 4.8,
94
+ "percent": 4.79,
95
95
  "reduction": 32.71
96
96
  },
97
97
  {
@@ -119,7 +119,7 @@
119
119
  "dependents": [
120
120
  "/src/adapters/fetch/index.ts"
121
121
  ],
122
- "percent": 3.86,
122
+ "percent": 3.85,
123
123
  "reduction": 9.5
124
124
  },
125
125
  {
@@ -154,7 +154,7 @@
154
154
  "dependents": [
155
155
  "/src/adapters/aws-lambda/index.ts"
156
156
  ],
157
- "percent": 3.59,
157
+ "percent": 3.58,
158
158
  "reduction": 36.48
159
159
  },
160
160
  {
@@ -184,7 +184,7 @@
184
184
  "dependents": [
185
185
  "/src/unstable-core-do-not-import.ts"
186
186
  ],
187
- "percent": 3.13,
187
+ "percent": 3.12,
188
188
  "reduction": 38.95
189
189
  },
190
190
  {
@@ -204,7 +204,7 @@
204
204
  "/src/unstable-core-do-not-import/router.ts",
205
205
  "/src/unstable-core-do-not-import/initTRPC.ts"
206
206
  ],
207
- "percent": 2.98,
207
+ "percent": 2.97,
208
208
  "reduction": 45.94
209
209
  },
210
210
  {
@@ -239,7 +239,7 @@
239
239
  "/src/unstable-core-do-not-import/initTRPC.ts",
240
240
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
241
241
  ],
242
- "percent": 2.8,
242
+ "percent": 2.79,
243
243
  "reduction": 55.95
244
244
  },
245
245
  {
@@ -251,7 +251,7 @@
251
251
  ],
252
252
  "removedExports": [],
253
253
  "dependents": [],
254
- "percent": 2.76,
254
+ "percent": 2.75,
255
255
  "reduction": 31.37
256
256
  },
257
257
  {
@@ -289,6 +289,20 @@
289
289
  "percent": 1.78,
290
290
  "reduction": 34.79
291
291
  },
292
+ {
293
+ "id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
294
+ "size": 1603,
295
+ "origSize": 2343,
296
+ "renderedExports": [
297
+ "fastifyTRPCPlugin"
298
+ ],
299
+ "removedExports": [],
300
+ "dependents": [
301
+ "/src/adapters/fastify/index.ts"
302
+ ],
303
+ "percent": 1.74,
304
+ "reduction": 31.58
305
+ },
292
306
  {
293
307
  "id": "/src/adapters/next.ts",
294
308
  "size": 1602,
@@ -310,23 +324,9 @@
310
324
  ],
311
325
  "removedExports": [],
312
326
  "dependents": [],
313
- "percent": 1.72,
327
+ "percent": 1.71,
314
328
  "reduction": 21.04
315
329
  },
316
- {
317
- "id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
318
- "size": 1530,
319
- "origSize": 2278,
320
- "renderedExports": [
321
- "fastifyTRPCPlugin"
322
- ],
323
- "removedExports": [],
324
- "dependents": [
325
- "/src/adapters/fastify/index.ts"
326
- ],
327
- "percent": 1.66,
328
- "reduction": 32.84
329
- },
330
330
  {
331
331
  "id": "/src/unstable-core-do-not-import/createProxy.ts",
332
332
  "size": 1507,
@@ -341,7 +341,7 @@
341
341
  "/src/unstable-core-do-not-import/router.ts",
342
342
  "/src/unstable-core-do-not-import/initTRPC.ts"
343
343
  ],
344
- "percent": 1.64,
344
+ "percent": 1.63,
345
345
  "reduction": 5.58
346
346
  },
347
347
  {
@@ -716,9 +716,9 @@
716
716
  "renderedExports": [],
717
717
  "removedExports": [],
718
718
  "dependents": [
719
- "/src/adapters/standalone.ts",
720
719
  "/src/adapters/express.ts",
721
- "/src/adapters/next.ts"
720
+ "/src/adapters/next.ts",
721
+ "/src/adapters/standalone.ts"
722
722
  ],
723
723
  "percent": 0,
724
724
  "reduction": 100
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-next-beta.264+f5f08f35d",
3
+ "version": "11.0.0-next-beta.271+79f6b3399",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -148,7 +148,7 @@
148
148
  "tslib": "^2.5.0",
149
149
  "tsx": "^4.0.0",
150
150
  "typescript": "^5.3.3",
151
- "valibot": "^0.27.0",
151
+ "valibot": "^0.28.0",
152
152
  "vitest": "^0.32.0",
153
153
  "ws": "^8.0.0",
154
154
  "yup": "^1.0.0",
@@ -157,5 +157,5 @@
157
157
  "funding": [
158
158
  "https://trpc.io/sponsor"
159
159
  ],
160
- "gitHead": "f5f08f35d0fce8eba59e4db2daed36b184f737a4"
160
+ "gitHead": "79f6b3399c69a3e47a881947db9b44ee51a1f6b4"
161
161
  }
@@ -43,6 +43,7 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
43
43
  );
44
44
 
45
45
  let prefix = opts.prefix ?? '';
46
+ const websocketPrefix = prefix;
46
47
 
47
48
  // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
48
49
  // @ts-expect-error property 'default' does not exists on type ...
@@ -58,6 +59,7 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
58
59
  if (opts.useWSS) {
59
60
  applyWSSHandler<TRouter>({
60
61
  ...(opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>),
62
+ prefix: websocketPrefix,
61
63
  wss: fastify.websocketServer,
62
64
  });
63
65
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -66,15 +66,20 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
66
66
  }) & {
67
67
  wss: ws.WebSocketServer;
68
68
  process?: NodeJS.Process;
69
+ prefix?: string;
69
70
  };
70
71
 
71
72
  export function applyWSSHandler<TRouter extends AnyRouter>(
72
73
  opts: WSSHandlerOptions<TRouter>,
73
74
  ) {
74
- const { wss, createContext, router } = opts;
75
+ const { wss, createContext, router, prefix } = opts;
75
76
 
76
77
  const { transformer } = router._def._config;
77
78
  wss.on('connection', async (client, req) => {
79
+ if (prefix && !req.url?.startsWith(prefix)) {
80
+ return;
81
+ }
82
+
78
83
  const clientSubscriptions = new Map<number | string, Unsubscribable>();
79
84
 
80
85
  function respond(untransformedJSON: TRPCResponseMessage) {