@trpc/server 10.0.0-alpha.20 → 10.0.0-alpha.23
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/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.d.ts +1 -0
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.dev.js +90 -0
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.js +7 -0
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.prod.js +90 -0
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.esm.js +86 -0
- package/adapters/express/dist/trpc-server-adapters-express.cjs.dev.js +4 -4
- package/adapters/express/dist/trpc-server-adapters-express.cjs.prod.js +4 -4
- package/adapters/express/dist/trpc-server-adapters-express.esm.js +4 -4
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.dev.js +5 -5
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.prod.js +5 -5
- package/adapters/fastify/dist/trpc-server-adapters-fastify.esm.js +5 -5
- package/adapters/fastify/index.js +1 -1
- package/adapters/fetch/index.d.ts +1 -0
- package/adapters/fetch/index.js +1 -0
- package/adapters/next/dist/trpc-server-adapters-next.cjs.dev.js +4 -4
- package/adapters/next/dist/trpc-server-adapters-next.cjs.prod.js +4 -4
- package/adapters/next/dist/trpc-server-adapters-next.esm.js +4 -4
- package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.dev.js +4 -4
- package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.prod.js +4 -4
- package/adapters/node-http/dist/trpc-server-adapters-node-http.esm.js +4 -4
- package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.dev.js +4 -4
- package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.prod.js +4 -4
- package/adapters/standalone/dist/trpc-server-adapters-standalone.esm.js +4 -4
- package/adapters/ws/dist/trpc-server-adapters-ws.cjs.dev.js +2 -2
- package/adapters/ws/dist/trpc-server-adapters-ws.cjs.prod.js +2 -2
- package/adapters/ws/dist/trpc-server-adapters-ws.esm.js +2 -2
- package/dist/TRPCError-7971540a.mjs +65 -0
- package/dist/{transformTRPCResponse-43a869de.js → TRPCError-ddec3395.js} +18 -59
- package/dist/TRPCError.d.ts +3 -3
- package/dist/TRPCError.d.ts.map +1 -1
- package/dist/adapters/express.js +5 -5
- package/dist/adapters/express.mjs +5 -5
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/index.js +7 -8
- package/dist/adapters/fastify/index.mjs +6 -7
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +8 -0
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -0
- package/dist/adapters/fetch/index.d.ts +3 -0
- package/dist/adapters/fetch/index.d.ts.map +1 -0
- package/dist/adapters/fetch/index.js +69 -0
- package/dist/adapters/fetch/index.mjs +65 -0
- package/dist/adapters/fetch/index.ts.js +1 -0
- package/dist/adapters/fetch/types.d.ts +21 -0
- package/dist/adapters/fetch/types.d.ts.map +1 -0
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +9 -10
- package/dist/adapters/next.mjs +8 -9
- package/dist/adapters/node-http/index.js +5 -5
- package/dist/adapters/node-http/index.mjs +5 -5
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/types.d.ts +9 -7
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +11 -8
- package/dist/adapters/standalone.mjs +11 -7
- package/dist/adapters/ws.d.ts +4 -4
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +117 -80
- package/dist/adapters/ws.mjs +112 -75
- package/dist/assertNotBrowser.d.ts.map +1 -1
- package/dist/{codes-7a3d4f65.mjs → envelopes-1deb2fa7.mjs} +19 -1
- package/dist/{codes-7f46544e.js → envelopes-a953b930.js} +18 -0
- package/dist/http/index.d.ts +1 -1
- package/dist/http/internals/getHTTPStatusCode.d.ts +1 -0
- package/dist/http/internals/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/http/internals/types.d.ts +5 -4
- package/dist/http/internals/types.d.ts.map +1 -1
- package/dist/http/resolveHTTPResponse.d.ts +1 -1
- package/dist/http/resolveHTTPResponse.d.ts.map +1 -1
- package/dist/http/{ResponseMeta.d.ts → responseMeta.d.ts} +1 -1
- package/dist/http/responseMeta.d.ts.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -54
- package/dist/index.mjs +40 -47
- package/dist/internals/{BaseHandlerOptions.d.ts → baseHandlerOptions.d.ts} +2 -2
- package/dist/internals/{BaseHandlerOptions.d.ts.map → baseHandlerOptions.d.ts.map} +1 -1
- package/dist/internals/callProcedure.d.ts +2 -2
- package/dist/internals/callProcedure.d.ts.map +1 -1
- package/dist/internals/errors.d.ts +1 -0
- package/dist/internals/errors.d.ts.map +1 -1
- package/dist/internals/middlewares.d.ts +5 -2
- package/dist/internals/middlewares.d.ts.map +1 -1
- package/dist/internals/{OnErrorFunction.d.ts → onErrorFunction.d.ts} +1 -1
- package/dist/internals/{OnErrorFunction.d.ts.map → onErrorFunction.d.ts.map} +1 -1
- package/dist/internals/procedure.d.ts +20 -14
- package/dist/internals/procedure.d.ts.map +1 -1
- package/dist/internals/transformTRPCResponse.d.ts +4 -2
- package/dist/internals/transformTRPCResponse.d.ts.map +1 -1
- package/dist/{nodeHTTPRequestHandler-5fccb3bb.mjs → nodeHTTPRequestHandler-1cdb6383.mjs} +2 -3
- package/dist/{nodeHTTPRequestHandler-7d71ac09.js → nodeHTTPRequestHandler-848f07b5.js} +4 -5
- package/dist/observable/index.d.ts +5 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/dist/observable/index.js +204 -0
- package/dist/observable/index.mjs +195 -0
- package/dist/observable/index.ts.js +1 -0
- package/dist/observable/internals/identity.d.ts +2 -0
- package/dist/observable/internals/identity.d.ts.map +1 -0
- package/dist/observable/internals/observableToPromise.d.ts +10 -0
- package/dist/observable/internals/observableToPromise.d.ts.map +1 -0
- package/dist/observable/internals/pipe.d.ts +4 -0
- package/dist/observable/internals/pipe.d.ts.map +1 -0
- package/dist/observable/observable.d.ts +5 -0
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/observable/operators/index.d.ts +4 -0
- package/dist/observable/operators/index.d.ts.map +1 -0
- package/dist/observable/operators/map.d.ts +3 -0
- package/dist/observable/operators/map.d.ts.map +1 -0
- package/dist/observable/operators/share.d.ts +6 -0
- package/dist/observable/operators/share.d.ts.map +1 -0
- package/dist/observable/operators/tap.d.ts +3 -0
- package/dist/observable/operators/tap.d.ts.map +1 -0
- package/dist/observable/types.d.ts +29 -0
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/observable-137ea1bd.mjs +105 -0
- package/dist/observable-3aa4d911.js +108 -0
- package/dist/{resolveHTTPResponse-3292a84a.mjs → resolveHTTPResponse-54a79e6c.mjs} +18 -23
- package/dist/{resolveHTTPResponse-c3777a47.js → resolveHTTPResponse-ec3dccaa.js} +24 -29
- package/dist/router.d.ts +31 -27
- package/dist/router.d.ts.map +1 -1
- package/dist/rpc/codes.d.ts +2 -0
- package/dist/rpc/codes.d.ts.map +1 -1
- package/dist/rpc/envelopes.d.ts +61 -39
- package/dist/rpc/envelopes.d.ts.map +1 -1
- package/dist/rpc/index.js +7 -3
- package/dist/rpc/index.mjs +1 -1
- package/dist/subscription.d.ts +3 -52
- package/dist/subscription.d.ts.map +1 -1
- package/dist/subscription.js +44 -0
- package/dist/subscription.mjs +40 -0
- package/dist/subscription.ts.js +1 -0
- package/dist/transformTRPCResponse-333bed6c.js +56 -0
- package/dist/transformTRPCResponse-e0cba527.mjs +53 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/observable/index.d.ts +1 -0
- package/observable/index.js +1 -0
- package/package.json +30 -8
- package/rpc/dist/trpc-server-rpc.cjs.dev.js +1 -1
- package/rpc/dist/trpc-server-rpc.cjs.prod.js +1 -1
- package/rpc/dist/trpc-server-rpc.esm.js +1 -1
- package/src/TRPCError.ts +2 -2
- package/src/adapters/fastify/fastifyRequestHandler.ts +0 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +61 -0
- package/src/adapters/fetch/index.ts +2 -0
- package/src/adapters/fetch/types.ts +28 -0
- package/src/adapters/next.ts +3 -5
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +0 -1
- package/src/adapters/node-http/types.ts +9 -7
- package/src/adapters/standalone.ts +10 -3
- package/src/adapters/ws.ts +115 -77
- package/src/assertNotBrowser.ts +1 -0
- package/src/http/index.ts +1 -1
- package/src/http/internals/getHTTPStatusCode.ts +1 -0
- package/src/http/internals/types.ts +5 -6
- package/src/http/resolveHTTPResponse.ts +20 -24
- package/src/http/{ResponseMeta.ts → responseMeta.ts} +0 -0
- package/src/index.ts +0 -1
- package/src/internals/{BaseHandlerOptions.ts → baseHandlerOptions.ts} +1 -1
- package/src/internals/callProcedure.ts +6 -3
- package/src/internals/errors.ts +20 -4
- package/src/internals/middlewares.ts +6 -2
- package/src/internals/{OnErrorFunction.ts → onErrorFunction.ts} +0 -0
- package/src/internals/procedure.ts +102 -42
- package/src/internals/transformTRPCResponse.ts +20 -15
- package/src/observable/index.ts +4 -0
- package/src/observable/internals/identity.ts +3 -0
- package/src/observable/internals/observableToPromise.ts +49 -0
- package/src/observable/internals/pipe.ts +22 -0
- package/src/observable/observable.test.ts +101 -0
- package/src/observable/observable.ts +75 -0
- package/src/observable/operators/index.ts +3 -0
- package/src/observable/operators/map.test.ts +92 -0
- package/src/observable/operators/map.ts +25 -0
- package/src/observable/operators/share.test.ts +60 -0
- package/src/observable/operators/share.ts +67 -0
- package/src/observable/operators/tap.ts +26 -0
- package/src/observable/types.ts +69 -0
- package/src/router.ts +96 -37
- package/src/rpc/codes.ts +1 -0
- package/src/rpc/envelopes.ts +87 -68
- package/src/subscription.ts +5 -123
- package/src/types.ts +7 -0
- package/dist/http/ResponseMeta.d.ts.map +0 -1
- package/dist/internals/wrapCallSafe.d.ts +0 -16
- package/dist/internals/wrapCallSafe.d.ts.map +0 -1
- package/dist/subscription-0d8a48ec.mjs +0 -133
- package/dist/subscription-41611bc2.js +0 -136
- package/dist/transformTRPCResponse-ff424ff4.mjs +0 -105
- package/src/internals/wrapCallSafe.ts +0 -19
- package/ws/dist/trpc-server-ws.cjs.d.ts +0 -1
- package/ws/dist/trpc-server-ws.cjs.dev.js +0 -15
- package/ws/dist/trpc-server-ws.cjs.js +0 -7
- package/ws/dist/trpc-server-ws.cjs.prod.js +0 -15
- package/ws/dist/trpc-server-ws.esm.js +0 -11
- package/ws/index.d.ts +0 -1
- package/ws/index.js +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var TRPCError = require('./TRPCError-ddec3395.js');
|
|
4
|
+
var transformTRPCResponse = require('./transformTRPCResponse-333bed6c.js');
|
|
5
|
+
var envelopes = require('./envelopes-a953b930.js');
|
|
5
6
|
|
|
6
7
|
/* istanbul ignore file */
|
|
7
8
|
function assertNotBrowser() {
|
|
8
|
-
if (typeof window !== 'undefined' && process.env.NODE_ENV !== 'test' && process.env.JEST_WORKER_ID === undefined) {
|
|
9
|
+
if (typeof window !== 'undefined' && !('Deno' in window) && process.env.NODE_ENV !== 'test' && process.env.JEST_WORKER_ID === undefined) {
|
|
9
10
|
throw new Error('Imported server-only code in the browser');
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const TRPC_ERROR_CODES_BY_NUMBER = /*#__PURE__*/
|
|
14
|
+
const TRPC_ERROR_CODES_BY_NUMBER = /*#__PURE__*/envelopes.invert(envelopes.TRPC_ERROR_CODES_BY_KEY);
|
|
14
15
|
const JSONRPC2_TO_HTTP_CODE = {
|
|
15
16
|
PARSE_ERROR: 400,
|
|
16
17
|
BAD_REQUEST: 400,
|
|
@@ -19,6 +20,7 @@ const JSONRPC2_TO_HTTP_CODE = {
|
|
|
19
20
|
UNAUTHORIZED: 401,
|
|
20
21
|
FORBIDDEN: 403,
|
|
21
22
|
TIMEOUT: 408,
|
|
23
|
+
CONFLICT: 409,
|
|
22
24
|
CLIENT_CLOSED_REQUEST: 499,
|
|
23
25
|
PRECONDITION_FAILED: 412,
|
|
24
26
|
PAYLOAD_TOO_LARGE: 413,
|
|
@@ -81,10 +83,10 @@ function getRawProcedureInputOrThrow(req) {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
return typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
|
|
84
|
-
} catch (
|
|
85
|
-
throw new
|
|
86
|
+
} catch (err) {
|
|
87
|
+
throw new TRPCError.TRPCError({
|
|
86
88
|
code: 'PARSE_ERROR',
|
|
87
|
-
cause
|
|
89
|
+
cause: TRPCError.getCauseFromUnknown(err)
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -156,7 +158,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
if (type === 'unknown' || type === 'subscription') {
|
|
159
|
-
throw new
|
|
161
|
+
throw new TRPCError.TRPCError({
|
|
160
162
|
message: `Unexpected request method ${req.method}`,
|
|
161
163
|
code: 'METHOD_NOT_SUPPORTED'
|
|
162
164
|
});
|
|
@@ -178,7 +180,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
|
|
181
|
-
throw new
|
|
183
|
+
throw new TRPCError.TRPCError({
|
|
182
184
|
code: 'BAD_REQUEST',
|
|
183
185
|
message: '"input" needs to be an object when doing a batch call'
|
|
184
186
|
});
|
|
@@ -214,7 +216,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
214
216
|
data: output
|
|
215
217
|
};
|
|
216
218
|
} catch (cause) {
|
|
217
|
-
const error =
|
|
219
|
+
const error = TRPCError.getErrorFromUnknown(cause);
|
|
218
220
|
onError === null || onError === void 0 ? void 0 : onError({
|
|
219
221
|
error,
|
|
220
222
|
path,
|
|
@@ -238,8 +240,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
238
240
|
} = obj;
|
|
239
241
|
|
|
240
242
|
if (obj.error) {
|
|
241
|
-
|
|
242
|
-
id: null,
|
|
243
|
+
return {
|
|
243
244
|
error: router.getErrorShape({
|
|
244
245
|
error: obj.error,
|
|
245
246
|
type,
|
|
@@ -248,16 +249,12 @@ async function resolveHTTPResponse(opts) {
|
|
|
248
249
|
ctx
|
|
249
250
|
})
|
|
250
251
|
};
|
|
251
|
-
return json;
|
|
252
252
|
} else {
|
|
253
|
-
|
|
254
|
-
id: null,
|
|
253
|
+
return {
|
|
255
254
|
result: {
|
|
256
|
-
type: 'data',
|
|
257
255
|
data: obj.data
|
|
258
256
|
}
|
|
259
257
|
};
|
|
260
|
-
return json;
|
|
261
258
|
}
|
|
262
259
|
});
|
|
263
260
|
const result = isBatchCall ? resultEnvelopes : resultEnvelopes[0];
|
|
@@ -268,17 +265,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
268
265
|
// - `createContext()` throws
|
|
269
266
|
// - post body is too large
|
|
270
267
|
// - input deserialization fails
|
|
271
|
-
const error =
|
|
272
|
-
const json = {
|
|
273
|
-
id: null,
|
|
274
|
-
error: router.getErrorShape({
|
|
275
|
-
error,
|
|
276
|
-
type,
|
|
277
|
-
path: undefined,
|
|
278
|
-
input: undefined,
|
|
279
|
-
ctx
|
|
280
|
-
})
|
|
281
|
-
};
|
|
268
|
+
const error = TRPCError.getErrorFromUnknown(cause);
|
|
282
269
|
onError === null || onError === void 0 ? void 0 : onError({
|
|
283
270
|
error,
|
|
284
271
|
path: undefined,
|
|
@@ -287,7 +274,15 @@ async function resolveHTTPResponse(opts) {
|
|
|
287
274
|
type: type,
|
|
288
275
|
req
|
|
289
276
|
});
|
|
290
|
-
return endResponse(
|
|
277
|
+
return endResponse({
|
|
278
|
+
error: router.getErrorShape({
|
|
279
|
+
error,
|
|
280
|
+
type,
|
|
281
|
+
path: undefined,
|
|
282
|
+
input: undefined,
|
|
283
|
+
ctx
|
|
284
|
+
})
|
|
285
|
+
}, [error]);
|
|
291
286
|
}
|
|
292
287
|
}
|
|
293
288
|
|
package/dist/router.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TRPCError } from './TRPCError';
|
|
2
2
|
import { MiddlewareFunction } from './internals/middlewares';
|
|
3
3
|
import { CreateProcedureWithInput, CreateProcedureWithInputOutputParser, CreateProcedureWithoutInput, Procedure, inferProcedureFromOptions } from './internals/procedure';
|
|
4
|
+
import { Observable, inferObservableValue } from './observable';
|
|
4
5
|
import { TRPCErrorShape, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER } from './rpc';
|
|
5
|
-
import { Subscription } from './subscription';
|
|
6
6
|
import { CombinedDataTransformer, DataTransformerOptions } from './transformer';
|
|
7
7
|
import { Prefixer, ThenArg, flatten } from './types';
|
|
8
8
|
/**
|
|
@@ -12,11 +12,11 @@ export declare type ProcedureType = 'query' | 'mutation' | 'subscription';
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
export declare type ProcedureRecord<TInputContext = any, TContext = any, TInput = any, TParsedInput = any, TOutput = any, TParsedOutput = any> = Record<string, Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput, TParsedOutput>>;
|
|
15
|
+
export declare type ProcedureRecord<TInputContext = any, TContext = any, TMeta = any, TInput = any, TParsedInput = any, TOutput = any, TParsedOutput = any> = Record<string, Procedure<TInputContext, TContext, TMeta, TInput, TParsedInput, TOutput, TParsedOutput>>;
|
|
16
16
|
/**
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer Input, any, any, any> ? undefined extends Input ? Input | null | void : Input : undefined;
|
|
19
|
+
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, any, infer Input, any, any, any> ? undefined extends Input ? Input | null | void : Input : undefined;
|
|
20
20
|
/**
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
@@ -24,25 +24,29 @@ export declare type inferAsyncReturnType<TFunction extends (...args: any) => any
|
|
|
24
24
|
/**
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
27
|
+
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
28
28
|
/**
|
|
29
29
|
* @public
|
|
30
30
|
* @beta
|
|
31
31
|
*/
|
|
32
|
-
export declare type inferSubscriptionOutput<TRouter extends AnyRouter, TPath extends keyof TRouter['_def']['subscriptions']> =
|
|
32
|
+
export declare type inferSubscriptionOutput<TRouter extends AnyRouter, TPath extends keyof TRouter['_def']['subscriptions']> = inferObservableValue<inferAsyncReturnType<TRouter['_def']['subscriptions'][TPath]['call']>>;
|
|
33
33
|
/**
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
|
-
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer TInput, any, any, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
36
|
+
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, any, infer TInput, any, any, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
37
37
|
declare type inferHandlerFn<TProcedures extends ProcedureRecord> = <TProcedure extends TProcedures[TPath], TPath extends keyof TProcedures & string>(path: TPath, ...args: inferHandlerInput<TProcedure>) => Promise<inferProcedureOutput<TProcedures[TPath]>>;
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
|
41
41
|
export declare type inferRouterContext<TRouter extends AnyRouter> = Parameters<TRouter['createCaller']>[0];
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare type inferRouterMeta<TRouter extends AnyRouter> = TRouter extends Router<any, any, infer TMeta, any, any, any, any> ? TMeta : {};
|
|
42
46
|
/**
|
|
43
47
|
* @public
|
|
44
48
|
*/
|
|
45
|
-
export declare type AnyRouter<TContext = any> = Router<any, TContext, any, any, any, any>;
|
|
49
|
+
export declare type AnyRouter<TContext = any> = Router<any, TContext, any, any, any, any, any>;
|
|
46
50
|
/**
|
|
47
51
|
* @internal
|
|
48
52
|
*/
|
|
@@ -71,19 +75,19 @@ export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER
|
|
|
71
75
|
message: string;
|
|
72
76
|
code: TRPC_ERROR_CODE_NUMBER;
|
|
73
77
|
}
|
|
74
|
-
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any, any, any>, TNewContext> = TProcedure extends Procedure<infer TInputContext, infer _TOldContext, infer TInput, infer TParsedInput, infer TOutput, infer TParsedOutput> ? Procedure<TInputContext, TNewContext, TInput, TParsedInput, TOutput, TParsedOutput> : never;
|
|
78
|
+
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any, any, any, any>, TNewContext> = TProcedure extends Procedure<infer TInputContext, infer _TOldContext, infer TMeta, infer TInput, infer TParsedInput, infer TOutput, infer TParsedOutput> ? Procedure<TInputContext, TNewContext, TMeta, TInput, TParsedInput, TOutput, TParsedOutput> : never;
|
|
75
79
|
declare type SwapContext<TObj extends ProcedureRecord<any, any, any, any, any, any>, TNewContext> = {
|
|
76
80
|
[P in keyof TObj]: SwapProcedureContext<TObj[P], TNewContext>;
|
|
77
81
|
};
|
|
78
82
|
/**
|
|
79
83
|
* @internal The type signature of this class may change without warning.
|
|
80
84
|
*/
|
|
81
|
-
export declare class Router<TInputContext, TContext, TQueries extends ProcedureRecord<TInputContext, TContext, any, any, any, any>, TMutations extends ProcedureRecord<TInputContext, TContext, any, any, any, any>, TSubscriptions extends ProcedureRecord<TInputContext, TContext, unknown, unknown,
|
|
85
|
+
export declare class Router<TInputContext, TContext, TMeta extends Record<string, any>, TQueries extends ProcedureRecord<TInputContext, TContext, any, any, any, any, any>, TMutations extends ProcedureRecord<TInputContext, TContext, any, any, any, any, any>, TSubscriptions extends ProcedureRecord<TInputContext, TContext, unknown, unknown, Observable<unknown, unknown>, unknown, unknown>, TErrorShape extends TRPCErrorShape<number>> {
|
|
82
86
|
readonly _def: {
|
|
83
87
|
queries: TQueries;
|
|
84
88
|
mutations: TMutations;
|
|
85
89
|
subscriptions: TSubscriptions;
|
|
86
|
-
middlewares: MiddlewareFunction<TInputContext, TContext>[];
|
|
90
|
+
middlewares: MiddlewareFunction<TInputContext, TContext, TMeta>[];
|
|
87
91
|
errorFormatter: ErrorFormatter<TContext, TErrorShape>;
|
|
88
92
|
transformer: CombinedDataTransformer;
|
|
89
93
|
};
|
|
@@ -91,40 +95,40 @@ export declare class Router<TInputContext, TContext, TQueries extends ProcedureR
|
|
|
91
95
|
queries?: TQueries;
|
|
92
96
|
mutations?: TMutations;
|
|
93
97
|
subscriptions?: TSubscriptions;
|
|
94
|
-
middlewares?: MiddlewareFunction<TInputContext, TContext>[];
|
|
98
|
+
middlewares?: MiddlewareFunction<TInputContext, TContext, TMeta>[];
|
|
95
99
|
errorFormatter?: ErrorFormatter<TContext, TErrorShape>;
|
|
96
100
|
transformer?: CombinedDataTransformer;
|
|
97
101
|
});
|
|
98
102
|
private static prefixProcedures;
|
|
99
|
-
query<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
100
|
-
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
101
|
-
query<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
102
|
-
mutation<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
103
|
-
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
104
|
-
mutation<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
103
|
+
query<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TMeta, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TMeta, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
104
|
+
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TMeta, TInput, TOutput>): Router<TInputContext, TContext, TMeta, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
105
|
+
query<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TMeta, TOutput, TParsedOutput>): Router<TInputContext, TContext, TMeta, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
106
|
+
mutation<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TMeta, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TMeta, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
107
|
+
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TMeta, TInput, TOutput>): Router<TInputContext, TContext, TMeta, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
108
|
+
mutation<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TMeta, TOutput, TParsedOutput>): Router<TInputContext, TContext, TMeta, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
105
109
|
/**
|
|
106
110
|
* @beta Might change without a major version bump
|
|
107
111
|
*/
|
|
108
|
-
subscription<TPath extends string, TInput, TParsedInput, TOutput extends
|
|
112
|
+
subscription<TPath extends string, TInput, TParsedInput, TOutput extends Observable<unknown, unknown>>(path: TPath, procedure: Omit<CreateProcedureWithInputOutputParser<TContext, TMeta, TInput, TParsedInput, TOutput, unknown>, 'output'>): Router<TInputContext, TContext, TMeta, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
109
113
|
/**
|
|
110
114
|
* @beta Might change without a major version bump
|
|
111
115
|
*/
|
|
112
|
-
subscription<TPath extends string, TInput, TOutput extends
|
|
116
|
+
subscription<TPath extends string, TInput, TOutput extends Observable<unknown, unknown>>(path: TPath, procedure: Omit<CreateProcedureWithInput<TContext, TMeta, TInput, TOutput>, 'output'>): Router<TInputContext, TContext, TMeta, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
113
117
|
/**
|
|
114
118
|
* @beta Might change without a major version bump
|
|
115
119
|
*/
|
|
116
|
-
subscription<TPath extends string, TOutput extends
|
|
120
|
+
subscription<TPath extends string, TOutput extends Observable<unknown, unknown>>(path: TPath, procedure: Omit<CreateProcedureWithoutInput<TContext, TMeta, TOutput, unknown>, 'output'>): Router<TInputContext, TContext, TMeta, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
117
121
|
/**
|
|
118
122
|
* Merge router with other router
|
|
119
123
|
* @param router
|
|
120
124
|
*/
|
|
121
|
-
merge<TChildRouter extends Router<TContext, any, any, any, any, any>>(router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TQueries & TChildRouter['_def']['queries'], TMutations & TChildRouter['_def']['mutations'], TSubscriptions & TChildRouter['_def']['subscriptions'], TErrorShape>;
|
|
125
|
+
merge<TChildRouter extends Router<TContext, any, TMeta, any, any, any, any>>(router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TMeta, TQueries & TChildRouter['_def']['queries'], TMutations & TChildRouter['_def']['mutations'], TSubscriptions & TChildRouter['_def']['subscriptions'], TErrorShape>;
|
|
122
126
|
/**
|
|
123
127
|
* Merge router with other router
|
|
124
128
|
* @param prefix Prefix that this router should live under
|
|
125
129
|
* @param router
|
|
126
130
|
*/
|
|
127
|
-
merge<TPath extends string, TChildRouter extends Router<TContext, any, any, any, any, any>>(prefix: TPath, router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TQueries & Prefixer<TChildRouter['_def']['queries'], `${TPath}`>, TMutations & Prefixer<TChildRouter['_def']['mutations'], `${TPath}`>, TSubscriptions & Prefixer<TChildRouter['_def']['subscriptions'], `${TPath}`>, TErrorShape>;
|
|
131
|
+
merge<TPath extends string, TChildRouter extends Router<TContext, any, TMeta, any, any, any, any>>(prefix: TPath, router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TMeta, TQueries & Prefixer<TChildRouter['_def']['queries'], `${TPath}`>, TMutations & Prefixer<TChildRouter['_def']['mutations'], `${TPath}`>, TSubscriptions & Prefixer<TChildRouter['_def']['subscriptions'], `${TPath}`>, TErrorShape>;
|
|
128
132
|
/**
|
|
129
133
|
* Invoke procedure. Only for internal use within library.
|
|
130
134
|
*/
|
|
@@ -138,12 +142,12 @@ export declare class Router<TInputContext, TContext, TQueries extends ProcedureR
|
|
|
138
142
|
* Function to be called before any procedure is invoked
|
|
139
143
|
* @link https://trpc.io/docs/middlewares
|
|
140
144
|
*/
|
|
141
|
-
middleware<TNewContext>(middleware: MiddlewareFunction<TContext, TNewContext>): Router<TInputContext, TNewContext, SwapContext<TQueries, TNewContext>, SwapContext<TMutations, TNewContext>, SwapContext<TSubscriptions, TNewContext>, TErrorShape>;
|
|
145
|
+
middleware<TNewContext>(middleware: MiddlewareFunction<TContext, TNewContext, TMeta>): Router<TInputContext, TNewContext, TMeta, SwapContext<TQueries, TNewContext>, SwapContext<TMutations, TNewContext>, SwapContext<TSubscriptions, TNewContext>, TErrorShape>;
|
|
142
146
|
/**
|
|
143
147
|
* Format errors
|
|
144
148
|
* @link https://trpc.io/docs/error-formatting
|
|
145
149
|
*/
|
|
146
|
-
formatError<TErrorFormatter extends ErrorFormatter<TContext, TRPCErrorShape<number>>>(errorFormatter: TErrorFormatter): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, ReturnType<TErrorFormatter>>;
|
|
150
|
+
formatError<TErrorFormatter extends ErrorFormatter<TContext, TRPCErrorShape<number>>>(errorFormatter: TErrorFormatter): Router<TInputContext, TContext, TMeta, TQueries, TMutations, TSubscriptions, ReturnType<TErrorFormatter>>;
|
|
147
151
|
getErrorShape(opts: {
|
|
148
152
|
error: TRPCError;
|
|
149
153
|
type: ProcedureType | 'unknown';
|
|
@@ -155,15 +159,15 @@ export declare class Router<TInputContext, TContext, TQueries extends ProcedureR
|
|
|
155
159
|
* Add data transformer to serialize/deserialize input args + output
|
|
156
160
|
* @link https://trpc.io/docs/data-transformers
|
|
157
161
|
*/
|
|
158
|
-
transformer(_transformer: DataTransformerOptions): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, TErrorShape>;
|
|
162
|
+
transformer(_transformer: DataTransformerOptions): Router<TInputContext, TContext, TMeta, TQueries, TMutations, TSubscriptions, TErrorShape>;
|
|
159
163
|
/**
|
|
160
164
|
* Flattens the generics of TQueries/TMutations/TSubscriptions.
|
|
161
165
|
* ⚠️ Experimental - might disappear. ⚠️
|
|
162
166
|
*
|
|
163
167
|
* @alpha
|
|
164
168
|
*/
|
|
165
|
-
flat(): Router<TInputContext, TContext, flatten<{}, TQueries>, flatten<{}, TMutations>, flatten<{}, TSubscriptions>, TErrorShape>;
|
|
169
|
+
flat(): Router<TInputContext, TContext, TMeta, flatten<{}, TQueries>, flatten<{}, TMutations>, flatten<{}, TSubscriptions>, TErrorShape>;
|
|
166
170
|
}
|
|
167
|
-
export declare function router<TContext>(): Router<TContext, TContext, {}, {}, {}, DefaultErrorShape>;
|
|
171
|
+
export declare function router<TContext, TMeta extends Record<string, any> = {}>(): Router<TContext, TContext, TMeta, {}, {}, {}, DefaultErrorShape>;
|
|
168
172
|
export {};
|
|
169
173
|
//# sourceMappingURL=router.d.ts.map
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAEL,wBAAwB,EACxB,oCAAoC,EACpC,2BAA2B,EAC3B,SAAS,EAGT,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EAEd,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAEL,wBAAwB,EACxB,oCAAoC,EACpC,2BAA2B,EAC3B,SAAS,EAGT,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,cAAc,EAEd,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIrD;;GAEG;AACH,oBAAY,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;AAElE;;GAEG;AACH,oBAAY,eAAe,CACzB,aAAa,GAAG,GAAG,EACnB,QAAQ,GAAG,GAAG,EACd,KAAK,GAAG,GAAG,EACX,MAAM,GAAG,GAAG,EACZ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BAAkB,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,GAC3D,MAAM,CACP,aAAa,EACb,WAAW,EACX,KAAK,EACL,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,EAClC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,EACpC,WAAW,CAAC,cAAc,EAAE,WAAW,CAAC,EACxC,WAAW,CACZ;IAOD;;;OAGG;IACI,WAAW,CAChB,eAAe,SAAS,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,EACxE,cAAc,EAAE,eAAe;IAoB1B,aAAa,CAAC,IAAI,EAAE;QACzB,KAAK,EAAE,SAAS,CAAC;QACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;QAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,KAAK,EAAE,OAAO,CAAC;QACf,GAAG,EAAE,SAAS,GAAG,QAAQ,CAAC;KAC3B,GAAG,WAAW;IAuBf;;;OAGG;IACH,WAAW,CAAC,YAAY,EAAE,sBAAsB;IAsBhD;;;;;OAKG;IACI,IAAI,IAAI,MAAM,CACnB,aAAa,EACb,QAAQ,EACR,KAAK,EACL,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,EACrB,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,EACvB,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,EAC3B,WAAW,CACZ;CAGF;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,sEAEtE"}
|
package/dist/rpc/codes.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const TRPC_ERROR_CODES_BY_KEY: {
|
|
|
23
23
|
readonly NOT_FOUND: -32004;
|
|
24
24
|
readonly METHOD_NOT_SUPPORTED: -32005;
|
|
25
25
|
readonly TIMEOUT: -32008;
|
|
26
|
+
readonly CONFLICT: -32009;
|
|
26
27
|
readonly PRECONDITION_FAILED: -32012;
|
|
27
28
|
readonly PAYLOAD_TOO_LARGE: -32013;
|
|
28
29
|
readonly CLIENT_CLOSED_REQUEST: -32099;
|
|
@@ -36,6 +37,7 @@ export declare const TRPC_ERROR_CODES_BY_NUMBER: {
|
|
|
36
37
|
[-32004]: "NOT_FOUND";
|
|
37
38
|
[-32005]: "METHOD_NOT_SUPPORTED";
|
|
38
39
|
[-32008]: "TIMEOUT";
|
|
40
|
+
[-32009]: "CONFLICT";
|
|
39
41
|
[-32012]: "PRECONDITION_FAILED";
|
|
40
42
|
[-32013]: "PAYLOAD_TOO_LARGE";
|
|
41
43
|
[-32099]: "CLIENT_CLOSED_REQUEST";
|
package/dist/rpc/codes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/rpc/codes.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/rpc/codes.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;;;;CAYK,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;CAAkC,CAAC;AAC1E,aAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7B,oBAAY,sBAAsB,GAAG,OAAO,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC7E,oBAAY,mBAAmB,GAAG,MAAM,OAAO,uBAAuB,CAAC"}
|
package/dist/rpc/envelopes.d.ts
CHANGED
|
@@ -1,65 +1,88 @@
|
|
|
1
1
|
import { ProcedureType } from '../router';
|
|
2
2
|
import { TRPC_ERROR_CODE_NUMBER } from './codes';
|
|
3
|
-
declare type JSONRPC2RequestId = number | string | null;
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Error response
|
|
6
5
|
*/
|
|
7
|
-
interface JSONRPC2BaseEnvelope {
|
|
8
|
-
id: JSONRPC2RequestId;
|
|
9
|
-
jsonrpc?: '2.0';
|
|
10
|
-
}
|
|
11
|
-
interface JSONRPC2BaseRequest<TMethod extends string = string> extends JSONRPC2BaseEnvelope {
|
|
12
|
-
method: TMethod;
|
|
13
|
-
}
|
|
14
|
-
interface JSONRPC2Request<TMethod extends string = string, TParams = unknown> extends JSONRPC2BaseRequest<TMethod> {
|
|
15
|
-
params: TParams;
|
|
16
|
-
}
|
|
17
|
-
interface JSONRPC2ResultResponse<TResult = unknown> extends JSONRPC2BaseEnvelope {
|
|
18
|
-
result: TResult;
|
|
19
|
-
}
|
|
20
6
|
export interface TRPCErrorShape<TCode extends number = TRPC_ERROR_CODE_NUMBER, TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
21
7
|
code: TCode;
|
|
22
8
|
message: string;
|
|
23
9
|
data: TData;
|
|
24
10
|
}
|
|
25
11
|
/**
|
|
26
|
-
*
|
|
12
|
+
* JSON-RPC 2.0 Specification
|
|
27
13
|
*/
|
|
28
|
-
export declare
|
|
29
|
-
type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
export declare namespace JSONRPC2 {
|
|
15
|
+
type RequestId = number | string | null;
|
|
16
|
+
/**
|
|
17
|
+
* All requests/responses extends this shape
|
|
18
|
+
*/
|
|
19
|
+
interface BaseEnvelope {
|
|
20
|
+
id?: RequestId;
|
|
21
|
+
jsonrpc?: '2.0';
|
|
22
|
+
}
|
|
23
|
+
interface BaseRequest<TMethod extends string = string> extends BaseEnvelope {
|
|
24
|
+
method: TMethod;
|
|
25
|
+
}
|
|
26
|
+
interface Request<TMethod extends string = string, TParams = unknown> extends BaseRequest<TMethod> {
|
|
27
|
+
params: TParams;
|
|
28
|
+
}
|
|
29
|
+
interface ResultResponse<TResult = unknown> extends BaseEnvelope {
|
|
30
|
+
result: TResult;
|
|
31
|
+
}
|
|
32
|
+
interface ErrorResponse<TError extends TRPCErrorShape = TRPCErrorShape> extends BaseEnvelope {
|
|
33
|
+
error: TError;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* TRPC HTTP Envelopes
|
|
38
38
|
*/
|
|
39
|
-
export declare type TRPCRequest =
|
|
39
|
+
export declare type TRPCRequest = JSONRPC2.Request<ProcedureType, {
|
|
40
40
|
path: string;
|
|
41
41
|
input: unknown;
|
|
42
42
|
}>;
|
|
43
|
+
export declare type TRPCResult<TData = unknown> = {
|
|
44
|
+
data: TData;
|
|
45
|
+
};
|
|
46
|
+
export declare type TRPCErrorResponse<TError extends TRPCErrorShape = TRPCErrorShape> = JSONRPC2.ErrorResponse<TError>;
|
|
47
|
+
export declare type TRPCResponse<TResult = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = JSONRPC2.ResultResponse<TRPCResult<TResult>> | TRPCErrorResponse<TError>;
|
|
43
48
|
/**
|
|
44
|
-
*
|
|
49
|
+
* HTTP WS Envelopes
|
|
45
50
|
*/
|
|
46
|
-
export declare type
|
|
51
|
+
export declare type TRPCRequestMessage = {
|
|
52
|
+
id: JSONRPC2.RequestId;
|
|
53
|
+
} & TRPCRequest;
|
|
47
54
|
/**
|
|
48
|
-
*
|
|
55
|
+
* The client asked the server to unsubscribe
|
|
49
56
|
*/
|
|
50
|
-
export declare type
|
|
57
|
+
export declare type TRPCSubscriptionStopNotification = {
|
|
58
|
+
id: null;
|
|
59
|
+
} & JSONRPC2.BaseRequest<'subscription.stop'>;
|
|
51
60
|
/**
|
|
52
|
-
*
|
|
61
|
+
* The client's outgoing request types
|
|
53
62
|
*/
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
export declare type TRPCClientOutgoingRequest = TRPCSubscriptionStopNotification;
|
|
64
|
+
/**
|
|
65
|
+
* The client's sent messages shape
|
|
66
|
+
*/
|
|
67
|
+
export declare type TRPCClientOutgoingMessage = TRPCRequestMessage | ({
|
|
68
|
+
id: JSONRPC2.RequestId;
|
|
69
|
+
} & JSONRPC2.BaseRequest<'subscription.stop'>);
|
|
70
|
+
export declare type TRPCResultMessage<TData = unknown> = ({
|
|
71
|
+
type: 'data';
|
|
72
|
+
} & TRPCResult<TData>) | {
|
|
73
|
+
type: 'started';
|
|
74
|
+
} | {
|
|
75
|
+
type: 'stopped';
|
|
76
|
+
};
|
|
77
|
+
export declare type TRPCResponseMessage<TResult = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = {
|
|
78
|
+
id: JSONRPC2.RequestId;
|
|
79
|
+
} & (JSONRPC2.ResultResponse<TRPCResultMessage<TResult>> | TRPCErrorResponse<TError>);
|
|
57
80
|
/**
|
|
58
81
|
* The server asked the client to reconnect - useful when restarting/redeploying service
|
|
59
82
|
*/
|
|
60
|
-
export
|
|
61
|
-
id:
|
|
62
|
-
}
|
|
83
|
+
export declare type TRPCReconnectNotification = {
|
|
84
|
+
id: JSONRPC2.RequestId;
|
|
85
|
+
} & JSONRPC2.BaseRequest<'reconnect'>;
|
|
63
86
|
/**
|
|
64
87
|
* The client's incoming request types
|
|
65
88
|
*/
|
|
@@ -67,6 +90,5 @@ export declare type TRPCClientIncomingRequest = TRPCReconnectNotification;
|
|
|
67
90
|
/**
|
|
68
91
|
* The client's received messages shape
|
|
69
92
|
*/
|
|
70
|
-
export declare type TRPCClientIncomingMessage =
|
|
71
|
-
export {};
|
|
93
|
+
export declare type TRPCClientIncomingMessage<TResult = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = TRPCResponseMessage<TResult, TError> | TRPCClientIncomingRequest;
|
|
72
94
|
//# sourceMappingURL=envelopes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/rpc/envelopes.ts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;IAAE,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAA;CAAE,GAAG,CAC7B,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,GACnD,iBAAiB,CAAC,MAAM,CAAC,CAC5B,CAAC;AAEF;;GAEG;AACH,oBAAY,yBAAyB,GAAG;IACtC,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC;CACxB,GAAG,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAEtC;;GAEG;AACH,oBAAY,yBAAyB,GAAG,yBAAyB,CAAC;AAElE;;GAEG;AACH,oBAAY,yBAAyB,CACnC,OAAO,GAAG,OAAO,EACjB,MAAM,SAAS,cAAc,GAAG,cAAc,IAC5C,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,yBAAyB,CAAC"}
|
package/dist/rpc/index.js
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var envelopes = require('../envelopes-a953b930.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports
|
|
10
|
-
|
|
9
|
+
Object.defineProperty(exports, 'JSONRPC2', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return envelopes.JSONRPC2; }
|
|
12
|
+
});
|
|
13
|
+
exports.TRPC_ERROR_CODES_BY_KEY = envelopes.TRPC_ERROR_CODES_BY_KEY;
|
|
14
|
+
exports.TRPC_ERROR_CODES_BY_NUMBER = envelopes.TRPC_ERROR_CODES_BY_NUMBER;
|
package/dist/rpc/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { T as TRPC_ERROR_CODES_BY_KEY, a as TRPC_ERROR_CODES_BY_NUMBER } from '../
|
|
1
|
+
export { J as JSONRPC2, T as TRPC_ERROR_CODES_BY_KEY, a as TRPC_ERROR_CODES_BY_NUMBER } from '../envelopes-1deb2fa7.mjs';
|
package/dist/subscription.d.ts
CHANGED
|
@@ -1,58 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
interface SubscriptionEvents<TOutput> {
|
|
4
|
-
data: (data: TOutput) => void;
|
|
5
|
-
destroy: () => void;
|
|
6
|
-
error: (error: Error) => void;
|
|
7
|
-
}
|
|
8
|
-
declare interface SubscriptionEventEmitter<TOutput> {
|
|
9
|
-
on<U extends keyof SubscriptionEvents<TOutput>>(event: U, listener: SubscriptionEvents<TOutput>[U]): this;
|
|
10
|
-
once<U extends keyof SubscriptionEvents<TOutput>>(event: U, listener: SubscriptionEvents<TOutput>[U]): this;
|
|
11
|
-
emit<U extends keyof SubscriptionEvents<TOutput>>(event: U, ...args: Parameters<SubscriptionEvents<TOutput>[U]>): boolean;
|
|
12
|
-
}
|
|
13
|
-
declare class SubscriptionEventEmitter<TOutput> extends EventEmitter {
|
|
14
|
-
}
|
|
15
|
-
declare type UnsubscribeFn = () => void;
|
|
16
|
-
declare type EmitFn<TOutput> = (data: TOutput) => void;
|
|
17
|
-
export declare type SubscriptionEmit<TOutput> = {
|
|
18
|
-
data: EmitFn<TOutput>;
|
|
19
|
-
error: EmitFn<Error>;
|
|
20
|
-
};
|
|
21
|
-
export declare type SubscriptionCallback<TOutput> = (emit: SubscriptionEmit<TOutput>) => UnsubscribeFn | Promise<UnsubscribeFn>;
|
|
22
|
-
/**
|
|
23
|
-
* @beta
|
|
24
|
-
*/
|
|
25
|
-
export declare class Subscription<TOutput = unknown> {
|
|
26
|
-
private readonly events;
|
|
27
|
-
private callback;
|
|
28
|
-
private isDestroyed;
|
|
29
|
-
constructor(callback: SubscriptionCallback<TOutput>);
|
|
30
|
-
destroy(): void;
|
|
31
|
-
start(): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated This method is just here to help with `inferSubscriptionOutput` which I can't get working without it
|
|
34
|
-
*/
|
|
35
|
-
output(): TOutput;
|
|
36
|
-
/**
|
|
37
|
-
* Emit data
|
|
38
|
-
*/
|
|
39
|
-
emitOutput(data: TOutput): void;
|
|
40
|
-
/**
|
|
41
|
-
* Emit error
|
|
42
|
-
*/
|
|
43
|
-
emitError(err: Error): void;
|
|
44
|
-
on(...args: Parameters<SubscriptionEventEmitter<TOutput>['on']>): SubscriptionEventEmitter<TOutput>;
|
|
45
|
-
off(...args: Parameters<SubscriptionEventEmitter<TOutput>['off']>): SubscriptionEventEmitter<TOutput>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @alpha Might be removed
|
|
49
|
-
*/
|
|
1
|
+
import { Observable, Observer } from './observable';
|
|
50
2
|
export declare function subscriptionPullFactory<TOutput>(opts: {
|
|
51
3
|
/**
|
|
52
4
|
* The interval of how often the function should run
|
|
53
5
|
*/
|
|
54
6
|
intervalMs: number;
|
|
55
|
-
pull(emit:
|
|
56
|
-
}):
|
|
57
|
-
export {};
|
|
7
|
+
pull(emit: Observer<TOutput, unknown>): void | Promise<void>;
|
|
8
|
+
}): Observable<TOutput, unknown>;
|
|
58
9
|
//# sourceMappingURL=subscription.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../src/subscription.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../src/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAc,MAAM,cAAc,CAAC;AAEhE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,IAAI,EAAE;IACrD;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CA4B/B"}
|