@trpc/server 11.0.0-rc.432 → 11.0.0-rc.435

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.
Files changed (44) hide show
  1. package/dist/@trpc/server/http.d.ts +1 -2
  2. package/dist/@trpc/server/http.d.ts.map +1 -1
  3. package/dist/@trpc/server/rpc.d.ts +1 -1
  4. package/dist/@trpc/server/rpc.d.ts.map +1 -1
  5. package/dist/adapters/next.js +1 -1
  6. package/dist/adapters/next.mjs +1 -1
  7. package/dist/adapters/ws.d.ts +2 -2
  8. package/dist/adapters/ws.d.ts.map +1 -1
  9. package/dist/adapters/ws.js +76 -35
  10. package/dist/adapters/ws.mjs +77 -36
  11. package/dist/bundle-analysis.json +82 -62
  12. package/dist/http.js +3 -0
  13. package/dist/http.mjs +1 -0
  14. package/dist/index.js +2 -2
  15. package/dist/index.mjs +1 -1
  16. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
  17. package/dist/unstable-core-do-not-import/http/contentType.js +8 -3
  18. package/dist/unstable-core-do-not-import/http/contentType.mjs +8 -3
  19. package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts +4 -0
  20. package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts.map +1 -0
  21. package/dist/unstable-core-do-not-import/http/parseConnectionParams.js +42 -0
  22. package/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +39 -0
  23. package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
  24. package/dist/unstable-core-do-not-import/http/types.d.ts +9 -14
  25. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  26. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +7 -0
  27. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
  28. package/dist/unstable-core-do-not-import/rpc/index.d.ts +1 -1
  29. package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -1
  30. package/dist/unstable-core-do-not-import.d.ts +4 -3
  31. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  32. package/dist/unstable-core-do-not-import.js +16 -13
  33. package/dist/unstable-core-do-not-import.mjs +4 -3
  34. package/package.json +2 -2
  35. package/src/@trpc/server/http.ts +7 -2
  36. package/src/@trpc/server/rpc.ts +1 -0
  37. package/src/adapters/ws.ts +95 -35
  38. package/src/unstable-core-do-not-import/http/contentType.ts +12 -7
  39. package/src/unstable-core-do-not-import/http/parseConnectionParams.ts +49 -0
  40. package/src/unstable-core-do-not-import/http/resolveResponse.ts +8 -6
  41. package/src/unstable-core-do-not-import/http/types.ts +9 -17
  42. package/src/unstable-core-do-not-import/rpc/envelopes.ts +9 -0
  43. package/src/unstable-core-do-not-import/rpc/index.ts +1 -0
  44. package/src/unstable-core-do-not-import.ts +4 -3
@@ -0,0 +1,39 @@
1
+ import { TRPCError } from '../error/TRPCError.mjs';
2
+ import { isObject } from '../utils.mjs';
3
+
4
+ function parseConnectionParamsFromUnknown(parsed) {
5
+ try {
6
+ if (parsed === null) {
7
+ return null;
8
+ }
9
+ if (!isObject(parsed)) {
10
+ throw new Error('Expected object');
11
+ }
12
+ const nonStringValues = Object.entries(parsed).filter(([_key, value])=>typeof value !== 'string');
13
+ if (nonStringValues.length > 0) {
14
+ throw new Error(`Expected connectionParams to be string values. Got ${nonStringValues.map(([key, value])=>`${key}: ${typeof value}`).join(', ')}`);
15
+ }
16
+ return parsed;
17
+ } catch (cause) {
18
+ throw new TRPCError({
19
+ code: 'PARSE_ERROR',
20
+ message: 'Invalid connection params shape',
21
+ cause
22
+ });
23
+ }
24
+ }
25
+ function parseConnectionParamsFromString(str) {
26
+ let parsed;
27
+ try {
28
+ parsed = JSON.parse(str);
29
+ } catch (cause) {
30
+ throw new TRPCError({
31
+ code: 'PARSE_ERROR',
32
+ message: 'Not JSON-parsable query params',
33
+ cause
34
+ });
35
+ }
36
+ return parseConnectionParamsFromUnknown(parsed);
37
+ }
38
+
39
+ export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown };
@@ -1 +1 @@
1
- {"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA0BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAyID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CA8YnB"}
1
+ {"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA0BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAyID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAgZnB"}
@@ -58,7 +58,11 @@ interface TRPCRequestInfoProcedureCall {
58
58
  */
59
59
  procedure: AnyProcedure | null;
60
60
  }
61
- export interface TRPCRequestInfoBase {
61
+ /**
62
+ * Information about the incoming request
63
+ * @public
64
+ */
65
+ export interface TRPCRequestInfo {
62
66
  /**
63
67
  * The `trpc-accept` header
64
68
  */
@@ -75,20 +79,11 @@ export interface TRPCRequestInfoBase {
75
79
  * The calls being made
76
80
  */
77
81
  calls: TRPCRequestInfoProcedureCall[];
82
+ /**
83
+ * Connection params when using `httpSubscriptionLink` or `createWSClient`
84
+ */
85
+ connectionParams: Dict<string> | null;
78
86
  }
79
- interface TRPCRequestInfoBatchCall extends TRPCRequestInfoBase {
80
- isBatchCall: true;
81
- calls: TRPCRequestInfoProcedureCall[];
82
- }
83
- interface TRPCRequestInfoSingleCall extends TRPCRequestInfoBase {
84
- isBatchCall: false;
85
- calls: [TRPCRequestInfoProcedureCall];
86
- }
87
- /**
88
- * Information about the incoming request
89
- * @public
90
- */
91
- export type TRPCRequestInfo = TRPCRequestInfoBatchCall | TRPCRequestInfoSingleCall;
92
87
  /**
93
88
  * Inner createContext function for `resolveResponse` used to forward `TRPCRequestInfo` to `createContext`
94
89
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EA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;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,KAAK,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE;IAC7D,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IACzD,GAAG,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClC;;;QAGI;IACJ,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,eAAe,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB;;OAEG;IACH,eA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AS,SAAS,EAAE,QAAQ,IAAI,CAClE,IAAI,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAC7C,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -1,3 +1,4 @@
1
+ import type { TRPCRequestInfo } from '../http/types';
1
2
  import type { ProcedureType } from '../procedure';
2
3
  import type { TRPC_ERROR_CODE_NUMBER } from './codes';
3
4
  /**
@@ -94,4 +95,10 @@ export type TRPCClientIncomingRequest = TRPCReconnectNotification;
94
95
  * The client's received messages shape
95
96
  */
96
97
  export type TRPCClientIncomingMessage<TResult = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = TRPCClientIncomingRequest | TRPCResponseMessage<TResult, TError>;
98
+ /**
99
+ * The client sends connection params - always sent as the first message
100
+ */
101
+ export interface TRPCConnectionParamsMessage extends JSONRPC2.BaseRequest<'connectionParams'> {
102
+ data: TRPCRequestInfo['connectionParams'];
103
+ }
97
104
  //# sourceMappingURL=envelopes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/rpc/envelopes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,KAA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_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER } from './codes';
2
2
  export type { TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER } from './codes';
3
- export type { JSONRPC2, TRPCClientIncomingMessage, TRPCClientIncomingRequest, TRPCClientOutgoingMessage, TRPCClientOutgoingRequest, TRPCErrorResponse, TRPCErrorShape, TRPCReconnectNotification, TRPCRequest, TRPCRequestMessage, TRPCResponse, TRPCResponseMessage, TRPCResult, TRPCResultMessage, TRPCSubscriptionStopNotification, TRPCSuccessResponse, } from './envelopes';
3
+ export type { JSONRPC2, TRPCClientIncomingMessage, TRPCClientIncomingRequest, TRPCClientOutgoingMessage, TRPCClientOutgoingRequest, TRPCErrorResponse, TRPCErrorShape, TRPCReconnectNotification, TRPCRequest, TRPCRequestMessage, TRPCResponse, TRPCResponseMessage, TRPCResult, TRPCResultMessage, TRPCSubscriptionStopNotification, TRPCSuccessResponse, TRPCConnectionParamsMessage, } from './envelopes';
4
4
  export { parseTRPCMessage } from './parseTRPCMessage';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC3E,YAAY,EACV,QAAQ,EACR,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC9E,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAC3E,YAAY,EACV,QAAQ,EACR,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -12,10 +12,11 @@ export * from './unstable-core-do-not-import/clientish/inference';
12
12
  export * from './unstable-core-do-not-import/clientish/inferrable';
13
13
  export * from './unstable-core-do-not-import/clientish/serialize';
14
14
  export * from './unstable-core-do-not-import/createProxy';
15
- export * from './unstable-core-do-not-import/error/TRPCError';
16
15
  export * from './unstable-core-do-not-import/error/formatter';
17
16
  export * from './unstable-core-do-not-import/error/getErrorShape';
17
+ export * from './unstable-core-do-not-import/error/TRPCError';
18
18
  export * from './unstable-core-do-not-import/http/batchStreamFormatter';
19
+ export * from './unstable-core-do-not-import/http/parseConnectionParams';
19
20
  export * from './unstable-core-do-not-import/http/contentType';
20
21
  export * from './unstable-core-do-not-import/http/contentTypeParsers';
21
22
  export * from './unstable-core-do-not-import/http/getHTTPStatusCode';
@@ -30,9 +31,9 @@ export * from './unstable-core-do-not-import/procedureBuilder';
30
31
  export * from './unstable-core-do-not-import/rootConfig';
31
32
  export * from './unstable-core-do-not-import/router';
32
33
  export * from './unstable-core-do-not-import/rpc';
34
+ export * from './unstable-core-do-not-import/stream/jsonl';
35
+ export * from './unstable-core-do-not-import/stream/sse';
33
36
  export * from './unstable-core-do-not-import/transformer';
34
37
  export * from './unstable-core-do-not-import/types';
35
38
  export * from './unstable-core-do-not-import/utils';
36
- export * from './unstable-core-do-not-import/stream/jsonl';
37
- export * from './unstable-core-do-not-import/stream/sse';
38
39
  //# sourceMappingURL=unstable-core-do-not-import.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unstable-core-do-not-import.d.ts","sourceRoot":"","sources":["../src/unstable-core-do-not-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,yDAAyD,CAAC;AACxE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC"}
1
+ {"version":3,"file":"unstable-core-do-not-import.d.ts","sourceRoot":"","sources":["../src/unstable-core-do-not-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,yDAAyD,CAAC;AACxE,cAAc,0DAA0D,CAAC;AACzE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC"}
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var createProxy = require('./unstable-core-do-not-import/createProxy.js');
4
- var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
5
4
  var formatter = require('./unstable-core-do-not-import/error/formatter.js');
6
5
  var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
6
+ var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
7
7
  var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
8
+ var parseConnectionParams = require('./unstable-core-do-not-import/http/parseConnectionParams.js');
8
9
  var contentType = require('./unstable-core-do-not-import/http/contentType.js');
9
10
  var contentTypeParsers = require('./unstable-core-do-not-import/http/contentTypeParsers.js');
10
11
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
@@ -19,22 +20,24 @@ var rootConfig = require('./unstable-core-do-not-import/rootConfig.js');
19
20
  var router = require('./unstable-core-do-not-import/router.js');
20
21
  var codes = require('./unstable-core-do-not-import/rpc/codes.js');
21
22
  var parseTRPCMessage = require('./unstable-core-do-not-import/rpc/parseTRPCMessage.js');
23
+ var jsonl = require('./unstable-core-do-not-import/stream/jsonl.js');
24
+ var sse = require('./unstable-core-do-not-import/stream/sse.js');
22
25
  var transformer = require('./unstable-core-do-not-import/transformer.js');
23
26
  var types = require('./unstable-core-do-not-import/types.js');
24
27
  var utils = require('./unstable-core-do-not-import/utils.js');
25
- var jsonl = require('./unstable-core-do-not-import/stream/jsonl.js');
26
- var sse = require('./unstable-core-do-not-import/stream/sse.js');
27
28
 
28
29
 
29
30
 
30
31
  exports.createFlatProxy = createProxy.createFlatProxy;
31
32
  exports.createRecursiveProxy = createProxy.createRecursiveProxy;
33
+ exports.defaultFormatter = formatter.defaultFormatter;
34
+ exports.getErrorShape = getErrorShape.getErrorShape;
32
35
  exports.TRPCError = TRPCError.TRPCError;
33
36
  exports.getCauseFromUnknown = TRPCError.getCauseFromUnknown;
34
37
  exports.getTRPCErrorFromUnknown = TRPCError.getTRPCErrorFromUnknown;
35
- exports.defaultFormatter = formatter.defaultFormatter;
36
- exports.getErrorShape = getErrorShape.getErrorShape;
37
38
  exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
39
+ exports.parseConnectionParamsFromString = parseConnectionParams.parseConnectionParamsFromString;
40
+ exports.parseConnectionParamsFromUnknown = parseConnectionParams.parseConnectionParamsFromUnknown;
38
41
  exports.getRequestInfo = contentType.getRequestInfo;
39
42
  exports.octetInputParser = contentTypeParsers.octetInputParser;
40
43
  exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
@@ -58,6 +61,14 @@ exports.mergeRouters = router.mergeRouters;
58
61
  exports.TRPC_ERROR_CODES_BY_KEY = codes.TRPC_ERROR_CODES_BY_KEY;
59
62
  exports.TRPC_ERROR_CODES_BY_NUMBER = codes.TRPC_ERROR_CODES_BY_NUMBER;
60
63
  exports.parseTRPCMessage = parseTRPCMessage.parseTRPCMessage;
64
+ exports.isPromise = jsonl.isPromise;
65
+ exports.jsonlStreamConsumer = jsonl.jsonlStreamConsumer;
66
+ exports.jsonlStreamProducer = jsonl.jsonlStreamProducer;
67
+ exports.isSSEMessageEnvelope = sse.isSSEMessageEnvelope;
68
+ exports.sse = sse.sse;
69
+ exports.sseHeaders = sse.sseHeaders;
70
+ exports.sseStreamConsumer = sse.sseStreamConsumer;
71
+ exports.sseStreamProducer = sse.sseStreamProducer;
61
72
  exports.defaultTransformer = transformer.defaultTransformer;
62
73
  exports.getDataTransformer = transformer.getDataTransformer;
63
74
  exports.transformResult = transformer.transformResult;
@@ -70,11 +81,3 @@ exports.mergeWithoutOverrides = utils.mergeWithoutOverrides;
70
81
  exports.omitPrototype = utils.omitPrototype;
71
82
  exports.run = utils.run;
72
83
  exports.unsetMarker = utils.unsetMarker;
73
- exports.isPromise = jsonl.isPromise;
74
- exports.jsonlStreamConsumer = jsonl.jsonlStreamConsumer;
75
- exports.jsonlStreamProducer = jsonl.jsonlStreamProducer;
76
- exports.isSSEMessageEnvelope = sse.isSSEMessageEnvelope;
77
- exports.sse = sse.sse;
78
- exports.sseHeaders = sse.sseHeaders;
79
- exports.sseStreamConsumer = sse.sseStreamConsumer;
80
- exports.sseStreamProducer = sse.sseStreamProducer;
@@ -1,8 +1,9 @@
1
1
  export { createFlatProxy, createRecursiveProxy } from './unstable-core-do-not-import/createProxy.mjs';
2
- export { TRPCError, getCauseFromUnknown, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
3
2
  export { defaultFormatter } from './unstable-core-do-not-import/error/formatter.mjs';
4
3
  export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
4
+ export { TRPCError, getCauseFromUnknown, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
5
5
  export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
6
+ export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown } from './unstable-core-do-not-import/http/parseConnectionParams.mjs';
6
7
  export { getRequestInfo } from './unstable-core-do-not-import/http/contentType.mjs';
7
8
  export { octetInputParser } from './unstable-core-do-not-import/http/contentTypeParsers.mjs';
8
9
  export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
@@ -17,8 +18,8 @@ export { isServerDefault } from './unstable-core-do-not-import/rootConfig.mjs';
17
18
  export { callProcedure, createCallerFactory, createRouterFactory, mergeRouters } from './unstable-core-do-not-import/router.mjs';
18
19
  export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER } from './unstable-core-do-not-import/rpc/codes.mjs';
19
20
  export { parseTRPCMessage } from './unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
21
+ export { isPromise, jsonlStreamConsumer, jsonlStreamProducer } from './unstable-core-do-not-import/stream/jsonl.mjs';
22
+ export { isSSEMessageEnvelope, sse, sseHeaders, sseStreamConsumer, sseStreamProducer } from './unstable-core-do-not-import/stream/sse.mjs';
20
23
  export { defaultTransformer, getDataTransformer, transformResult, transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
21
24
  export { ERROR_SYMBOL } from './unstable-core-do-not-import/types.mjs';
22
25
  export { isAsyncIterable, isFunction, isObject, mergeWithoutOverrides, omitPrototype, run, unsetMarker } from './unstable-core-do-not-import/utils.mjs';
23
- export { isPromise, jsonlStreamConsumer, jsonlStreamProducer } from './unstable-core-do-not-import/stream/jsonl.mjs';
24
- export { isSSEMessageEnvelope, sse, sseHeaders, sseStreamConsumer, sseStreamProducer } from './unstable-core-do-not-import/stream/sse.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.432+f9477e279",
3
+ "version": "11.0.0-rc.435+c14c98cad",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -149,5 +149,5 @@
149
149
  "funding": [
150
150
  "https://trpc.io/sponsor"
151
151
  ],
152
- "gitHead": "f9477e2791948cfb8adb052a1d47dace7f124d06"
152
+ "gitHead": "c14c98cad9298f0595a3e3dd0a1aebaf76490d14"
153
153
  }
@@ -17,5 +17,10 @@ export type {
17
17
  TRPCRequestInfo,
18
18
  } from '../../unstable-core-do-not-import';
19
19
 
20
- export { getBatchStreamFormatter } from '../../unstable-core-do-not-import';
21
- export { octetInputParser, toURL } from '../../unstable-core-do-not-import';
20
+ export {
21
+ getBatchStreamFormatter,
22
+ octetInputParser,
23
+ parseConnectionParamsFromUnknown,
24
+ parseConnectionParamsFromString,
25
+ toURL,
26
+ } from '../../unstable-core-do-not-import';
@@ -18,6 +18,7 @@ export type {
18
18
  TRPCSuccessResponse,
19
19
  TRPC_ERROR_CODE_KEY,
20
20
  TRPC_ERROR_CODE_NUMBER,
21
+ TRPCConnectionParamsMessage,
21
22
  } from '../../unstable-core-do-not-import';
22
23
  export {
23
24
  TRPC_ERROR_CODES_BY_KEY,
@@ -12,19 +12,23 @@ import {
12
12
  transformTRPCResponse,
13
13
  TRPCError,
14
14
  } from '../@trpc/server';
15
- import type { BaseHandlerOptions } from '../@trpc/server/http';
15
+ import type { TRPCRequestInfo } from '../@trpc/server/http';
16
+ import { toURL, type BaseHandlerOptions } from '../@trpc/server/http';
16
17
  import { parseTRPCMessage } from '../@trpc/server/rpc';
17
18
  // @trpc/server/rpc
18
19
  import type {
19
20
  TRPCClientOutgoingMessage,
21
+ TRPCConnectionParamsMessage,
20
22
  TRPCReconnectNotification,
21
23
  TRPCResponseMessage,
22
24
  } from '../@trpc/server/rpc';
25
+ import { parseConnectionParamsFromUnknown } from '../http';
23
26
  import { isObservable } from '../observable';
24
27
  import { observableToAsyncIterable } from '../observable/observable';
25
28
  // eslint-disable-next-line no-restricted-imports
26
29
  import {
27
30
  isAsyncIterable,
31
+ isObject,
28
32
  run,
29
33
  type MaybePromise,
30
34
  } from '../unstable-core-do-not-import';
@@ -39,9 +43,9 @@ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
39
43
  /**
40
44
  * @public
41
45
  */
42
- export type CreateWSSContextFnOptions = Omit<
43
- NodeHTTPCreateContextFnOptions<IncomingMessage, ws.WebSocket>,
44
- 'info'
46
+ export type CreateWSSContextFnOptions = NodeHTTPCreateContextFnOptions<
47
+ IncomingMessage,
48
+ ws.WebSocket
45
49
  >;
46
50
 
47
51
  /**
@@ -84,6 +88,7 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> =
84
88
  };
85
89
  };
86
90
 
91
+ const unsetContextSymbol = Symbol('unsetContext');
87
92
  export function getWSConnectionHandler<TRouter extends AnyRouter>(
88
93
  opts: WSConnectionHandlerOptions<TRouter>,
89
94
  ) {
@@ -101,7 +106,65 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
101
106
  );
102
107
  }
103
108
 
104
- const ctxPromise = createContext?.({ req, res: client });
109
+ function createCtxPromise(
110
+ getConnectionParams: () => TRPCRequestInfo['connectionParams'],
111
+ ): Promise<inferRouterContext<TRouter>> {
112
+ return run(async () => {
113
+ ctx = await createContext?.({
114
+ req,
115
+ res: client,
116
+ info: {
117
+ connectionParams: getConnectionParams(),
118
+ calls: [],
119
+ isBatchCall: false,
120
+ accept: null,
121
+ type: 'unknown',
122
+ },
123
+ });
124
+
125
+ return ctx;
126
+ }).catch((cause) => {
127
+ const error = getTRPCErrorFromUnknown(cause);
128
+ opts.onError?.({
129
+ error,
130
+ path: undefined,
131
+ type: 'unknown',
132
+ ctx,
133
+ req,
134
+ input: undefined,
135
+ });
136
+ respond({
137
+ id: null,
138
+ error: getErrorShape({
139
+ config: router._def._config,
140
+ error,
141
+ type: 'unknown',
142
+ path: undefined,
143
+ input: undefined,
144
+ ctx,
145
+ }),
146
+ });
147
+
148
+ // close in next tick
149
+ (global.setImmediate ?? global.setTimeout)(() => {
150
+ client.close();
151
+ });
152
+
153
+ throw error;
154
+ });
155
+ }
156
+
157
+ /**
158
+ * promise for initializing the context
159
+ *
160
+ * - the context promise will be created immediately on connection if no connectionParams are expected
161
+ * - if connection params are expected, they will be created once received
162
+ */
163
+ let ctxPromise =
164
+ toURL(req.url ?? '').searchParams.get('connectionParams') === '1'
165
+ ? unsetContextSymbol
166
+ : createCtxPromise(() => null);
167
+
105
168
  let ctx: inferRouterContext<TRouter> | undefined = undefined;
106
169
 
107
170
  async function handleRequest(msg: TRPCClientOutgoingMessage) {
@@ -276,6 +339,30 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
276
339
  }
277
340
  }
278
341
  client.on('message', async (message) => {
342
+ if (ctxPromise === unsetContextSymbol) {
343
+ // If the ctxPromise wasn't created immediately, we're expecting the first message to be a TRPCConnectionParamsMessage
344
+ ctxPromise = createCtxPromise(() => {
345
+ let msg;
346
+ try {
347
+ msg = JSON.parse(message.toString()) as TRPCConnectionParamsMessage;
348
+
349
+ if (!isObject(msg)) {
350
+ throw new Error('Message was not an object');
351
+ }
352
+ } catch (cause) {
353
+ throw new TRPCError({
354
+ code: 'PARSE_ERROR',
355
+ message: `Malformed TRPCConnectionParamsMessage`,
356
+ cause,
357
+ });
358
+ }
359
+
360
+ const connectionParams = parseConnectionParamsFromUnknown(msg.data);
361
+
362
+ return connectionParams;
363
+ });
364
+ return;
365
+ }
279
366
  try {
280
367
  const msgJSON: unknown = JSON.parse(message.toString());
281
368
  const msgs: unknown[] = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
@@ -324,38 +411,11 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
324
411
  }
325
412
  clientSubscriptions.clear();
326
413
  });
327
- async function createContextAsync() {
328
- try {
329
- ctx = await ctxPromise;
330
- } catch (cause) {
331
- const error = getTRPCErrorFromUnknown(cause);
332
- opts.onError?.({
333
- error,
334
- path: undefined,
335
- type: 'unknown',
336
- ctx,
337
- req,
338
- input: undefined,
339
- });
340
- respond({
341
- id: null,
342
- error: getErrorShape({
343
- config: router._def._config,
344
- error,
345
- type: 'unknown',
346
- path: undefined,
347
- input: undefined,
348
- ctx,
349
- }),
350
- });
351
414
 
352
- // close in next tick
353
- (global.setImmediate ?? global.setTimeout)(() => {
354
- client.close();
355
- });
356
- }
415
+ if (ctxPromise !== unsetContextSymbol) {
416
+ // prevent unhandled promise rejection errors
417
+ await ctxPromise.catch(() => null);
357
418
  }
358
- await createContextAsync();
359
419
  };
360
420
  }
361
421
 
@@ -2,11 +2,8 @@ import { TRPCError } from '../error/TRPCError';
2
2
  import type { AnyProcedure, ProcedureType } from '../procedure';
3
3
  import type { AnyRouter } from '../router';
4
4
  import { isObject, unsetMarker } from '../utils';
5
- import type {
6
- TRPCAcceptHeader,
7
- TRPCRequestInfo,
8
- TRPCRequestInfoBase,
9
- } from './types';
5
+ import { parseConnectionParamsFromString } from './parseConnectionParams';
6
+ import type { TRPCAcceptHeader, TRPCRequestInfo } from './types';
10
7
 
11
8
  type GetRequestInfoOptions = {
12
9
  path: string;
@@ -165,13 +162,19 @@ const jsonContentTypeHandler: ContentTypeHandler = {
165
162
  const type: ProcedureType | 'unknown' =
166
163
  types.values().next().value ?? 'unknown';
167
164
 
168
- const info: TRPCRequestInfoBase = {
165
+ const connectionParamsStr = opts.searchParams.get('connectionParams');
166
+
167
+ const info: TRPCRequestInfo = {
169
168
  isBatchCall,
170
169
  accept: req.headers.get('trpc-accept') as TRPCAcceptHeader | null,
171
170
  calls,
172
171
  type,
172
+ connectionParams:
173
+ connectionParamsStr === null
174
+ ? null
175
+ : parseConnectionParamsFromString(connectionParamsStr),
173
176
  };
174
- return info as TRPCRequestInfo;
177
+ return info;
175
178
  },
176
179
  };
177
180
 
@@ -204,6 +207,7 @@ const formDataContentTypeHandler: ContentTypeHandler = {
204
207
  ],
205
208
  isBatchCall: false,
206
209
  type: 'mutation',
210
+ connectionParams: null,
207
211
  };
208
212
  },
209
213
  };
@@ -238,6 +242,7 @@ const octetStreamContentTypeHandler: ContentTypeHandler = {
238
242
  isBatchCall: false,
239
243
  accept: null,
240
244
  type: 'mutation',
245
+ connectionParams: null,
241
246
  };
242
247
  },
243
248
  };
@@ -0,0 +1,49 @@
1
+ import { TRPCError } from '../error/TRPCError';
2
+ import { isObject } from '../utils';
3
+ import type { TRPCRequestInfo } from './types';
4
+
5
+ export function parseConnectionParamsFromUnknown(
6
+ parsed: unknown,
7
+ ): TRPCRequestInfo['connectionParams'] {
8
+ try {
9
+ if (parsed === null) {
10
+ return null;
11
+ }
12
+ if (!isObject(parsed)) {
13
+ throw new Error('Expected object');
14
+ }
15
+ const nonStringValues = Object.entries(parsed).filter(
16
+ ([_key, value]) => typeof value !== 'string',
17
+ );
18
+
19
+ if (nonStringValues.length > 0) {
20
+ throw new Error(
21
+ `Expected connectionParams to be string values. Got ${nonStringValues
22
+ .map(([key, value]) => `${key}: ${typeof value}`)
23
+ .join(', ')}`,
24
+ );
25
+ }
26
+ return parsed as Record<string, string>;
27
+ } catch (cause) {
28
+ throw new TRPCError({
29
+ code: 'PARSE_ERROR',
30
+ message: 'Invalid connection params shape',
31
+ cause,
32
+ });
33
+ }
34
+ }
35
+ export function parseConnectionParamsFromString(
36
+ str: string,
37
+ ): TRPCRequestInfo['connectionParams'] {
38
+ let parsed: unknown;
39
+ try {
40
+ parsed = JSON.parse(str);
41
+ } catch (cause) {
42
+ throw new TRPCError({
43
+ code: 'PARSE_ERROR',
44
+ message: 'Not JSON-parsable query params',
45
+ cause,
46
+ });
47
+ }
48
+ return parseConnectionParamsFromUnknown(parsed);
49
+ }
@@ -335,8 +335,8 @@ export async function resolveResponse<TRouter extends AnyRouter>(
335
335
  config,
336
336
  ctx,
337
337
  error,
338
- input: call.result(),
339
- path: call.path,
338
+ input: call!.result(),
339
+ path: call!.path,
340
340
  type: info.type,
341
341
  }),
342
342
  }
@@ -370,7 +370,9 @@ export async function resolveResponse<TRouter extends AnyRouter>(
370
370
 
371
371
  if (!isObservable(data) && !isAsyncIterable(data)) {
372
372
  throw new TRPCError({
373
- message: `Subscription ${call.path} did not return an observable or a AsyncGenerator`,
373
+ message: `Subscription ${
374
+ call!.path
375
+ } did not return an observable or a AsyncGenerator`,
374
376
  code: 'INTERNAL_SERVER_ERROR',
375
377
  });
376
378
  }
@@ -440,9 +442,9 @@ export async function resolveResponse<TRouter extends AnyRouter>(
440
442
  config,
441
443
  ctx,
442
444
  error,
443
- input: call.result(),
444
- path: call.path,
445
- type: call.procedure?._def.type ?? 'unknown',
445
+ input: call!.result(),
446
+ path: call!.path,
447
+ type: call!.procedure?._def.type ?? 'unknown',
446
448
  }),
447
449
  };
448
450
  }