@trpc/server 11.0.0-rc.632 → 11.0.0-rc.637

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 (36) hide show
  1. package/dist/adapters/node-http/writeResponse.d.ts.map +1 -1
  2. package/dist/adapters/node-http/writeResponse.js +0 -5
  3. package/dist/adapters/node-http/writeResponse.mjs +0 -5
  4. package/dist/adapters/ws.js +1 -1
  5. package/dist/adapters/ws.mjs +1 -1
  6. package/dist/bundle-analysis.json +84 -84
  7. package/dist/index.js +1 -1
  8. package/dist/index.mjs +1 -1
  9. package/dist/unstable-core-do-not-import/clientish/serialize.d.ts +1 -1
  10. package/dist/unstable-core-do-not-import/clientish/serialize.d.ts.map +1 -1
  11. package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
  12. package/dist/unstable-core-do-not-import/http/resolveResponse.js +3 -3
  13. package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +3 -3
  14. package/dist/unstable-core-do-not-import/initTRPC.js +2 -2
  15. package/dist/unstable-core-do-not-import/initTRPC.mjs +2 -2
  16. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +2 -2
  17. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
  18. package/dist/unstable-core-do-not-import/rootConfig.d.ts +14 -14
  19. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
  20. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +7 -10
  21. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
  22. package/dist/unstable-core-do-not-import/stream/sse.d.ts +11 -1
  23. package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
  24. package/dist/unstable-core-do-not-import/stream/sse.js +129 -65
  25. package/dist/unstable-core-do-not-import/stream/sse.mjs +129 -65
  26. package/dist/unstable-core-do-not-import/transformer.d.ts +1 -4
  27. package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -1
  28. package/package.json +2 -2
  29. package/src/adapters/node-http/writeResponse.ts +0 -5
  30. package/src/unstable-core-do-not-import/clientish/serialize.ts +1 -1
  31. package/src/unstable-core-do-not-import/http/resolveResponse.ts +3 -4
  32. package/src/unstable-core-do-not-import/initTRPC.ts +1 -1
  33. package/src/unstable-core-do-not-import/procedureBuilder.ts +10 -9
  34. package/src/unstable-core-do-not-import/rootConfig.ts +17 -17
  35. package/src/unstable-core-do-not-import/rpc/envelopes.ts +7 -12
  36. package/src/unstable-core-do-not-import/stream/sse.ts +155 -67
@@ -1,3 +1,4 @@
1
+ import { Unpromise } from '../../vendor/unpromise/unpromise.mjs';
1
2
  import { getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
2
3
  import { isAbortError } from '../http/isAbortError.mjs';
3
4
  import { run, identity } from '../utils.mjs';
@@ -6,6 +7,7 @@ import { takeWithGrace, withMaxDuration } from './utils/asyncIterable.mjs';
6
7
  import { createReadableStream } from './utils/createReadableStream.mjs';
7
8
  import { withPing, PING_SYM } from './utils/withPing.mjs';
8
9
 
10
+ const PING_EVENT = 'ping';
9
11
  const SERIALIZED_ERROR_EVENT = 'serialized-error';
10
12
  /**
11
13
  *
@@ -46,7 +48,8 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
46
48
  for await (value of iterable){
47
49
  if (value === PING_SYM) {
48
50
  stream.controller.enqueue({
49
- comment: 'ping'
51
+ event: PING_EVENT,
52
+ data: ''
50
53
  });
51
54
  continue;
52
55
  }
@@ -108,97 +111,158 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
108
111
  }
109
112
  }));
110
113
  }
114
+ async function withTimeout(opts) {
115
+ let timeoutId;
116
+ const timeoutPromise = new Promise((resolve)=>{
117
+ timeoutId = setTimeout(()=>{
118
+ resolve(null);
119
+ }, opts.timeoutMs);
120
+ });
121
+ let res;
122
+ try {
123
+ res = await Unpromise.race([
124
+ opts.promise,
125
+ timeoutPromise
126
+ ]);
127
+ } finally{
128
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
129
+ clearTimeout(timeoutId);
130
+ }
131
+ if (res === null) {
132
+ return await opts.onTimeout();
133
+ }
134
+ return res;
135
+ }
111
136
  /**
112
137
  * @see https://html.spec.whatwg.org/multipage/server-sent-events.html
113
138
  */ function sseStreamConsumer(opts) {
114
139
  const { deserialize = (v)=>v } = opts;
115
140
  const signal = opts.signal;
116
141
  let _es = null;
117
- const stream = new ReadableStream({
118
- async start (controller) {
119
- const [url, init] = await Promise.all([
120
- opts.url(),
121
- opts.init()
122
- ]);
123
- const eventSource = _es = new opts.EventSource(url, init);
124
- controller.enqueue({
125
- type: 'connecting',
126
- eventSource: _es,
127
- event: null
128
- });
129
- eventSource.addEventListener('open', ()=>{
142
+ const createStream = ()=>new ReadableStream({
143
+ async start (controller) {
144
+ const [url, init] = await Promise.all([
145
+ opts.url(),
146
+ opts.init()
147
+ ]);
148
+ const eventSource = _es = new opts.EventSource(url, init);
130
149
  controller.enqueue({
131
- type: 'opened',
132
- eventSource
150
+ type: 'connecting',
151
+ eventSource: _es,
152
+ event: null
133
153
  });
134
- });
135
- eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (_msg)=>{
136
- const msg = _msg;
137
- controller.enqueue({
138
- type: 'serialized-error',
139
- error: deserialize(JSON.parse(msg.data)),
140
- eventSource
154
+ eventSource.addEventListener('open', ()=>{
155
+ controller.enqueue({
156
+ type: 'opened',
157
+ eventSource
158
+ });
141
159
  });
142
- });
143
- eventSource.addEventListener('error', (event)=>{
144
- if (eventSource.readyState === EventSource.CLOSED) {
145
- controller.error(event);
146
- } else {
160
+ eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (_msg)=>{
161
+ const msg = _msg;
147
162
  controller.enqueue({
148
- type: 'connecting',
149
- eventSource,
150
- event
163
+ type: 'serialized-error',
164
+ error: deserialize(JSON.parse(msg.data)),
165
+ eventSource
151
166
  });
152
- }
153
- });
154
- eventSource.addEventListener('message', (_msg)=>{
155
- const msg = _msg;
156
- const chunk = deserialize(JSON.parse(msg.data));
157
- const def = {
158
- data: chunk
167
+ });
168
+ eventSource.addEventListener(PING_EVENT, ()=>{
169
+ controller.enqueue({
170
+ type: 'ping',
171
+ eventSource
172
+ });
173
+ });
174
+ eventSource.addEventListener('error', (event)=>{
175
+ if (eventSource.readyState === EventSource.CLOSED) {
176
+ controller.error(event);
177
+ } else {
178
+ controller.enqueue({
179
+ type: 'connecting',
180
+ eventSource,
181
+ event
182
+ });
183
+ }
184
+ });
185
+ eventSource.addEventListener('message', (_msg)=>{
186
+ const msg = _msg;
187
+ const chunk = deserialize(JSON.parse(msg.data));
188
+ const def = {
189
+ data: chunk
190
+ };
191
+ if (msg.lastEventId) {
192
+ def.id = msg.lastEventId;
193
+ }
194
+ controller.enqueue({
195
+ type: 'data',
196
+ data: def,
197
+ eventSource
198
+ });
199
+ });
200
+ const onAbort = ()=>{
201
+ controller.close();
202
+ eventSource.close();
159
203
  };
160
- if (msg.lastEventId) {
161
- def.id = msg.lastEventId;
204
+ if (signal.aborted) {
205
+ onAbort();
206
+ } else {
207
+ signal.addEventListener('abort', onAbort);
162
208
  }
163
- controller.enqueue({
164
- type: 'data',
165
- data: def,
166
- eventSource
167
- });
168
- });
169
- const onAbort = ()=>{
170
- controller.close();
171
- eventSource.close();
172
- };
173
- if (signal.aborted) {
174
- onAbort();
175
- } else {
176
- signal.addEventListener('abort', onAbort);
209
+ },
210
+ cancel () {
211
+ _es?.close();
177
212
  }
178
- },
179
- cancel () {
180
- _es?.close();
181
- }
182
- });
213
+ });
214
+ const getNewStreamAndReader = ()=>{
215
+ const stream = createStream();
216
+ const reader = stream.getReader();
217
+ return {
218
+ reader,
219
+ cancel: ()=>{
220
+ reader.releaseLock();
221
+ return stream.cancel();
222
+ }
223
+ };
224
+ };
183
225
  return {
184
226
  [Symbol.asyncIterator] () {
185
- const reader = stream.getReader();
227
+ let stream = getNewStreamAndReader();
186
228
  const iterator = {
187
229
  async next () {
188
- const value = await reader.read();
189
- if (value.done) {
230
+ let promise = stream.reader.read();
231
+ if (opts.reconnectAfterInactivityMs) {
232
+ promise = withTimeout({
233
+ promise,
234
+ timeoutMs: opts.reconnectAfterInactivityMs,
235
+ onTimeout: async ()=>{
236
+ // Close and release old reader
237
+ await stream.cancel();
238
+ // Create new reader
239
+ stream = getNewStreamAndReader();
240
+ return {
241
+ value: {
242
+ type: 'timeout',
243
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
244
+ eventSource: _es
245
+ },
246
+ done: false
247
+ };
248
+ }
249
+ });
250
+ }
251
+ const result = await promise;
252
+ // console.debug('result', result, 'done', result.done);
253
+ if (result.done) {
190
254
  return {
191
- value: undefined,
255
+ value: result.value,
192
256
  done: true
193
257
  };
194
258
  }
195
259
  return {
196
- value: value.value,
260
+ value: result.value,
197
261
  done: false
198
262
  };
199
263
  },
200
264
  async return () {
201
- reader.releaseLock();
265
+ await stream.cancel();
202
266
  return {
203
267
  value: undefined,
204
268
  done: true
@@ -87,10 +87,7 @@ declare function transformResultInner<TRouter extends AnyRouter, TOutput>(respon
87
87
  } | {
88
88
  type: "stopped";
89
89
  data?: never;
90
- } | (import("./rpc").TRPCResult<TOutput> & {
91
- type: "data";
92
- id?: string;
93
- });
90
+ } | import("./rpc").TRPCResult<TOutput>;
94
91
  readonly error?: undefined;
95
92
  };
96
93
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAGf;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;IACh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,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAChD,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAC3D,WAAW,EAAE,eAAe,GAC3B,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAqBzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.632+3df8b21be",
3
+ "version": "11.0.0-rc.637+19da060cb",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -156,5 +156,5 @@
156
156
  "next": "*",
157
157
  "ws": "*"
158
158
  },
159
- "gitHead": "3df8b21beb4925cf73194fc776d1a88603a3c420"
159
+ "gitHead": "19da060cb0e05c75682ec813c606b51c6c52ee19"
160
160
  }
@@ -42,11 +42,6 @@ export async function writeResponseBody(opts: {
42
42
  await writeResponseBodyChunk(res, chunk);
43
43
  res.flush?.();
44
44
  },
45
- abort() {
46
- if (!res.headersSent) {
47
- res.statusCode = 500;
48
- }
49
- },
50
45
  });
51
46
 
52
47
  await opts.body.pipeTo(writableStream, {
@@ -26,7 +26,7 @@ type IsRecord<T extends object> = keyof WithoutIndexSignature<T> extends never
26
26
  export type Serialize<T> =
27
27
  IsAny<T> extends true ? any :
28
28
  unknown extends T ? unknown :
29
- T extends AsyncGenerator<infer $T, infer $Return, infer $Next> ? AsyncGenerator<Serialize<$T>, Serialize<$Return>, Serialize<$Next>> :
29
+ T extends AsyncIterable<infer $T, infer $Return, infer $Next> ? AsyncIterable<Serialize<$T>, Serialize<$Return>, Serialize<$Next>> :
30
30
  T extends JsonReturnable ? T :
31
31
  T extends Map<any, any> | Set<any> ? object :
32
32
  T extends NonJsonPrimitive ? never :
@@ -300,9 +300,8 @@ export async function resolveResponse<TRouter extends AnyRouter>(
300
300
  const isStreamCall = req.headers.get('trpc-accept') === 'application/jsonl';
301
301
 
302
302
  const experimentalIterablesAndDeferreds =
303
- router._def._config.experimental?.iterablesAndDeferreds ?? true;
304
- const experimentalSSE =
305
- router._def._config.experimental?.sseSubscriptions?.enabled ?? true;
303
+ config.iterablesAndDeferreds ?? true;
304
+ const experimentalSSE = config.sse?.enabled ?? true;
306
305
  try {
307
306
  const [infoError, info] = infoTuple;
308
307
  if (infoError) {
@@ -465,7 +464,7 @@ export async function resolveResponse<TRouter extends AnyRouter>(
465
464
  });
466
465
 
467
466
  const stream = sseStreamProducer({
468
- ...config.experimental?.sseSubscriptions,
467
+ ...config.sse,
469
468
  data: iterable,
470
469
  abortCtrl: result?.abortCtrl ?? new AbortController(),
471
470
  serialize: (v) => config.transformer.output.serialize(v),
@@ -76,6 +76,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
76
76
  }>;
77
77
 
78
78
  const config: RootConfig<$Root> = {
79
+ ...opts,
79
80
  transformer: getDataTransformer(opts?.transformer ?? defaultTransformer),
80
81
  isDev:
81
82
  opts?.isDev ??
@@ -89,7 +90,6 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
89
90
  * @internal
90
91
  */
91
92
  $types: null as any,
92
- experimental: opts?.experimental ?? {},
93
93
  };
94
94
 
95
95
  {
@@ -44,21 +44,22 @@ type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker
44
44
  ? TFallback
45
45
  : TValue;
46
46
 
47
- type inferAsyncIterator<TOutput> =
48
- TOutput extends AsyncIterator<infer $Yield, infer $Return, infer $Next>
47
+ type inferAsyncIterable<TOutput> =
48
+ TOutput extends AsyncIterable<infer $Yield, infer $Return, infer $Next>
49
49
  ? {
50
50
  yield: $Yield;
51
51
  return: $Return;
52
52
  next: $Next;
53
53
  }
54
54
  : never;
55
- type inferSubscriptionOutput<TOutput> = TOutput extends AsyncGenerator
56
- ? AsyncGenerator<
57
- inferTrackedOutput<inferAsyncIterator<TOutput>['yield']>,
58
- inferAsyncIterator<TOutput>['return'],
59
- inferAsyncIterator<TOutput>['next']
60
- >
61
- : TypeError<'Subscription output could not be inferred'>;
55
+ type inferSubscriptionOutput<TOutput> =
56
+ TOutput extends AsyncIterable<any>
57
+ ? AsyncIterable<
58
+ inferTrackedOutput<inferAsyncIterable<TOutput>['yield']>,
59
+ inferAsyncIterable<TOutput>['return'],
60
+ inferAsyncIterable<TOutput>['next']
61
+ >
62
+ : TypeError<'Subscription output could not be inferred'>;
62
63
 
63
64
  export type CallerOverride<TContext> = (opts: {
64
65
  args: unknown[];
@@ -65,26 +65,26 @@ export interface RootConfig<TTypes extends RootTypes> {
65
65
 
66
66
  defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;
67
67
 
68
- experimental?: {
68
+ /**
69
+ * Enable support for returning async iterables and returning deferred promises when using `httpBatchStreamLink`
70
+ * @default true
71
+ */
72
+ iterablesAndDeferreds?: boolean;
73
+ /**
74
+ * Options for server-sent events (SSE) subscriptions
75
+ * @see https://trpc.io/docs/client/links/httpSubscriptionLink
76
+ */
77
+ sse?: {
69
78
  /**
70
- * Enable support for returning async iterables and returning deferred promises when using `httpBatchStreamLink`
79
+ * Enable server-sent events (SSE) subscriptions
71
80
  * @default true
72
81
  */
73
- iterablesAndDeferreds?: boolean;
74
- /**
75
- * Enable support for server-sent events (SSE) subscriptions
76
- */
77
- sseSubscriptions?: {
78
- /**
79
- * Enable server-sent events (SSE) subscriptions
80
- * @default true
81
- */
82
- enabled?: boolean;
83
- } & Pick<
84
- SSEStreamProducerOptions,
85
- 'ping' | 'emitAndEndImmediately' | 'maxDurationMs'
86
- >;
87
- };
82
+ enabled?: boolean;
83
+ } & Pick<
84
+ SSEStreamProducerOptions,
85
+ 'ping' | 'emitAndEndImmediately' | 'maxDurationMs'
86
+ >;
87
+ experimental?: {};
88
88
  }
89
89
 
90
90
  /**
@@ -63,14 +63,15 @@ export interface TRPCRequest
63
63
 
64
64
  export interface TRPCResult<TData = unknown> {
65
65
  data: TData;
66
+ type?: 'data';
67
+ /**
68
+ * The id of the message to keep track of in case of a reconnect
69
+ */
70
+ id?: string;
66
71
  }
67
72
 
68
73
  export interface TRPCSuccessResponse<TData>
69
- extends JSONRPC2.ResultResponse<
70
- TRPCResult<TData> & {
71
- type?: 'data';
72
- }
73
- > {}
74
+ extends JSONRPC2.ResultResponse<TRPCResult<TData>> {}
74
75
 
75
76
  export interface TRPCErrorResponse<
76
77
  TError extends TRPCErrorShape = TRPCErrorShape,
@@ -111,13 +112,7 @@ export interface TRPCResultMessage<TData>
111
112
  extends JSONRPC2.ResultResponse<
112
113
  | { type: 'started'; data?: never }
113
114
  | { type: 'stopped'; data?: never }
114
- | (TRPCResult<TData> & {
115
- type: 'data';
116
- /**
117
- * The id of the message to keep track of in case of a reconnect
118
- */
119
- id?: string;
120
- })
115
+ | TRPCResult<TData>
121
116
  > {}
122
117
 
123
118
  export type TRPCResponseMessage<