@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.219 → 11.0.0-alpha-tmp-export-from-main.211
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/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +9 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
- package/dist/@trpc-server/http.d.ts +1 -1
- package/dist/@trpc-server/http.d.ts.map +1 -1
- package/dist/@trpc-server.d.ts +3 -3
- package/dist/@trpc-server.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.ts +1 -1
- package/dist/adapters/aws-lambda/index.js +7 -13
- package/dist/adapters/aws-lambda/index.mjs +3 -9
- package/dist/adapters/aws-lambda/utils.d.ts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +2 -9
- package/dist/adapters/express.mjs +2 -9
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/index.js +4 -13
- package/dist/adapters/fastify/index.mjs +2 -11
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
- package/dist/adapters/fetch/index.js +4 -11
- package/dist/adapters/fetch/index.mjs +2 -9
- package/dist/adapters/fetch/types.d.ts +1 -1
- package/dist/adapters/next.d.ts +1 -1
- package/dist/adapters/next.js +5 -12
- package/dist/adapters/next.mjs +3 -10
- package/dist/adapters/node-http/content-type/json/index.js +3 -6
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -4
- package/dist/adapters/node-http/index.js +2 -9
- package/dist/adapters/node-http/index.mjs +2 -9
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/types.d.ts +2 -2
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -1
- package/dist/adapters/standalone.js +2 -9
- package/dist/adapters/standalone.mjs +2 -9
- package/dist/adapters/ws.d.ts +1 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -32
- package/dist/adapters/ws.mjs +1 -7
- package/dist/http.d.ts +6 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -13
- package/dist/http.mjs +1 -8
- package/dist/index.js +41 -16
- package/dist/index.mjs +1 -6
- package/dist/{nodeHTTPRequestHandler-d8558115.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -4
- package/dist/{nodeHTTPRequestHandler-0bc1dc41.js → nodeHTTPRequestHandler-55f05150.js} +4 -6
- package/dist/{nodeHTTPRequestHandler-c7d41cde.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
- package/dist/observable.d.ts +3 -0
- package/dist/observable.d.ts.map +1 -0
- package/dist/observable.js +32 -0
- package/dist/observable.mjs +1 -0
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -6
- package/dist/rpc.mjs +1 -3
- package/dist/shared.js +9 -5
- package/dist/shared.mjs +1 -3
- package/package.json +125 -53
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +9 -0
- package/src/@trpc-server/http.ts +1 -2
- package/src/@trpc-server.ts +3 -3
- package/src/adapters/aws-lambda/index.ts +1 -1
- package/src/adapters/aws-lambda/utils.ts +1 -1
- package/src/adapters/express.ts +2 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +1 -1
- package/src/adapters/fetch/types.ts +1 -1
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +1 -1
- package/src/adapters/node-http/types.ts +3 -2
- package/src/adapters/standalone.ts +1 -1
- package/src/adapters/ws.ts +10 -9
- package/src/http.ts +6 -6
- package/src/observable.ts +16 -0
- package/src/rpc.ts +2 -2
- package/dist/TRPCError-57838b33.js +0 -67
- package/dist/TRPCError-af754aba.mjs +0 -63
- package/dist/TRPCError-ebbde27d.js +0 -61
- package/dist/batchStreamFormatter-1971db27.js +0 -32
- package/dist/batchStreamFormatter-378277dc.mjs +0 -30
- package/dist/batchStreamFormatter-4375dc8b.js +0 -31
- package/dist/bundle-analysis.json +0 -770
- package/dist/contentType-9756da28.js +0 -59
- package/dist/contentType-b31eab56.js +0 -54
- package/dist/contentType-f93c6ba8.mjs +0 -52
- package/dist/createProxy-7293f632.mjs +0 -121
- package/dist/createProxy-c5cd21e8.js +0 -127
- package/dist/createProxy-f6960c7b.js +0 -116
- package/dist/initTRPC-6c16fa27.mjs +0 -377
- package/dist/initTRPC-8b5714ea.js +0 -385
- package/dist/initTRPC-b65b35e2.js +0 -372
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -111
- package/dist/observable/index.mjs +0 -102
- package/dist/observable/observable.d.ts +0 -13
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/operators.d.ts +0 -8
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/observable-7233bd21.mjs +0 -121
- package/dist/observable-7865c812.js +0 -125
- package/dist/observable-cbbc588a.js +0 -125
- package/dist/parseTRPCMessage-3ae1b295.js +0 -67
- package/dist/parseTRPCMessage-abbd6862.mjs +0 -62
- package/dist/parseTRPCMessage-c6022e94.js +0 -65
- package/dist/resolveHTTPResponse-3133d603.js +0 -265
- package/dist/resolveHTTPResponse-80c99f62.mjs +0 -291
- package/dist/resolveHTTPResponse-9e260431.js +0 -293
- package/dist/rootConfig-a1ad09d0.js +0 -48
- package/dist/rootConfig-db88d377.js +0 -44
- package/dist/rootConfig-f741a4e7.mjs +0 -40
- package/dist/router-68063d64.mjs +0 -252
- package/dist/router-7a7bb4fd.js +0 -262
- package/dist/router-c5bd7780.js +0 -259
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.d.ts +0 -34
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -44
- package/dist/unstable-core-do-not-import/index.mjs +0 -10
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.d.ts +0 -85
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/types.d.ts +0 -98
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -31
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/utils-42a3ba6d.js +0 -50
- package/dist/utils-cf6178ec.mjs +0 -44
- package/dist/utils-e1d51fac.js +0 -49
- package/src/observable/index.ts +0 -10
- package/src/observable/observable.ts +0 -155
- package/src/observable/operators.ts +0 -119
- package/src/observable/types.ts +0 -76
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
- package/src/unstable-core-do-not-import/createProxy.ts +0 -59
- package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
- package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
- package/src/unstable-core-do-not-import/http/index.ts +0 -23
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
- package/src/unstable-core-do-not-import/http/types.ts +0 -111
- package/src/unstable-core-do-not-import/index.ts +0 -107
- package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
- package/src/unstable-core-do-not-import/middleware.ts +0 -233
- package/src/unstable-core-do-not-import/parser.ts +0 -94
- package/src/unstable-core-do-not-import/procedure.ts +0 -108
- package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
- package/src/unstable-core-do-not-import/router.ts +0 -370
- package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
- package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
- package/src/unstable-core-do-not-import/serialize.ts +0 -122
- package/src/unstable-core-do-not-import/transformer.ts +0 -202
- package/src/unstable-core-do-not-import/types.ts +0 -151
- package/src/unstable-core-do-not-import/utils.ts +0 -66
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
package/dist/router-7a7bb4fd.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var createProxy = require('./createProxy-c5cd21e8.js');
|
|
4
|
-
var TRPCError = require('./TRPCError-57838b33.js');
|
|
5
|
-
var utils = require('./utils-42a3ba6d.js');
|
|
6
|
-
|
|
7
|
-
const defaultFormatter = ({ shape })=>{
|
|
8
|
-
return shape;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*/ function getDataTransformer(transformer) {
|
|
14
|
-
if ('input' in transformer) {
|
|
15
|
-
return transformer;
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
input: transformer,
|
|
19
|
-
output: transformer
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* @internal
|
|
24
|
-
*/ const defaultTransformer = {
|
|
25
|
-
_default: true,
|
|
26
|
-
input: {
|
|
27
|
-
serialize: (obj)=>obj,
|
|
28
|
-
deserialize: (obj)=>obj
|
|
29
|
-
},
|
|
30
|
-
output: {
|
|
31
|
-
serialize: (obj)=>obj,
|
|
32
|
-
deserialize: (obj)=>obj
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
function transformTRPCResponseItem(config, item) {
|
|
36
|
-
if ('error' in item) {
|
|
37
|
-
return {
|
|
38
|
-
...item,
|
|
39
|
-
error: config.transformer.output.serialize(item.error)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
if ('data' in item.result) {
|
|
43
|
-
return {
|
|
44
|
-
...item,
|
|
45
|
-
result: {
|
|
46
|
-
...item.result,
|
|
47
|
-
data: config.transformer.output.serialize(item.result.data)
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return item;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
55
|
-
**/ function transformTRPCResponse(config, itemOrItems) {
|
|
56
|
-
return Array.isArray(itemOrItems) ? itemOrItems.map((item)=>transformTRPCResponseItem(config, item)) : transformTRPCResponseItem(config, itemOrItems);
|
|
57
|
-
}
|
|
58
|
-
// FIXME:
|
|
59
|
-
// - the generics here are probably unnecessary
|
|
60
|
-
// - the RPC-spec could probably be simplified to combine HTTP + WS
|
|
61
|
-
/** @internal */ function transformResultInner(response, transformer) {
|
|
62
|
-
if ('error' in response) {
|
|
63
|
-
const error = transformer.deserialize(response.error);
|
|
64
|
-
return {
|
|
65
|
-
ok: false,
|
|
66
|
-
error: {
|
|
67
|
-
...response,
|
|
68
|
-
error
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const result = {
|
|
73
|
-
...response.result,
|
|
74
|
-
...(!response.result.type || response.result.type === 'data') && {
|
|
75
|
-
type: 'data',
|
|
76
|
-
data: transformer.deserialize(response.result.data)
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
ok: true,
|
|
81
|
-
result
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
class TransformResultError extends Error {
|
|
85
|
-
constructor(){
|
|
86
|
-
super('Unable to transform response from server');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Transforms and validates that the result is a valid TRPCResponse
|
|
91
|
-
* @internal
|
|
92
|
-
*/ function transformResult(response, transformer) {
|
|
93
|
-
let result;
|
|
94
|
-
try {
|
|
95
|
-
// Use the data transformers on the JSON-response
|
|
96
|
-
result = transformResultInner(response, transformer);
|
|
97
|
-
} catch (err) {
|
|
98
|
-
throw new TransformResultError();
|
|
99
|
-
}
|
|
100
|
-
// check that output of the transformers is a valid TRPCResponse
|
|
101
|
-
if (!result.ok && (!utils.isObject(result.error.error) || typeof result.error.error['code'] !== 'number')) {
|
|
102
|
-
throw new TransformResultError();
|
|
103
|
-
}
|
|
104
|
-
if (result.ok && !utils.isObject(result.result)) {
|
|
105
|
-
throw new TransformResultError();
|
|
106
|
-
}
|
|
107
|
-
return result;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function isRouter(procedureOrRouter) {
|
|
111
|
-
return 'router' in procedureOrRouter._def;
|
|
112
|
-
}
|
|
113
|
-
const emptyRouter = {
|
|
114
|
-
_ctx: null,
|
|
115
|
-
_errorShape: null,
|
|
116
|
-
_meta: null,
|
|
117
|
-
queries: {},
|
|
118
|
-
mutations: {},
|
|
119
|
-
subscriptions: {},
|
|
120
|
-
errorFormatter: defaultFormatter,
|
|
121
|
-
transformer: defaultTransformer
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Reserved words that can't be used as router or procedure names
|
|
125
|
-
*/ const reservedWords = [
|
|
126
|
-
/**
|
|
127
|
-
* Then is a reserved word because otherwise we can't return a promise that returns a Proxy
|
|
128
|
-
* since JS will think that `.then` is something that exists
|
|
129
|
-
*/ 'then'
|
|
130
|
-
];
|
|
131
|
-
/**
|
|
132
|
-
* @internal
|
|
133
|
-
*/ function createRouterFactory(config) {
|
|
134
|
-
return function createRouterInner(procedures) {
|
|
135
|
-
const reservedWordsUsed = new Set(Object.keys(procedures).filter((v)=>reservedWords.includes(v)));
|
|
136
|
-
if (reservedWordsUsed.size > 0) {
|
|
137
|
-
throw new Error('Reserved words used in `router({})` call: ' + Array.from(reservedWordsUsed).join(', '));
|
|
138
|
-
}
|
|
139
|
-
const routerProcedures = utils.omitPrototype({});
|
|
140
|
-
function recursiveGetPaths(procedures, path = '') {
|
|
141
|
-
for (const [key, procedureOrRouter] of Object.entries(procedures ?? {})){
|
|
142
|
-
const newPath = `${path}${key}`;
|
|
143
|
-
if (isRouter(procedureOrRouter)) {
|
|
144
|
-
recursiveGetPaths(procedureOrRouter._def.procedures, `${newPath}.`);
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (routerProcedures[newPath]) {
|
|
148
|
-
throw new Error(`Duplicate key: ${newPath}`);
|
|
149
|
-
}
|
|
150
|
-
routerProcedures[newPath] = procedureOrRouter;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
recursiveGetPaths(procedures);
|
|
154
|
-
const _def = {
|
|
155
|
-
_config: config,
|
|
156
|
-
router: true,
|
|
157
|
-
procedures: routerProcedures,
|
|
158
|
-
...emptyRouter,
|
|
159
|
-
record: procedures
|
|
160
|
-
};
|
|
161
|
-
const router = {
|
|
162
|
-
...procedures,
|
|
163
|
-
_def,
|
|
164
|
-
createCaller (ctx) {
|
|
165
|
-
const proxy = createProxy.createRecursiveProxy(({ path , args })=>{
|
|
166
|
-
const fullPath = path.join('.');
|
|
167
|
-
const procedure = _def.procedures[fullPath];
|
|
168
|
-
return procedure({
|
|
169
|
-
path: fullPath,
|
|
170
|
-
getRawInput: async ()=>args[0],
|
|
171
|
-
ctx,
|
|
172
|
-
type: procedure._def.type
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
return proxy;
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
return router;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function isProcedure(procedureOrRouter) {
|
|
182
|
-
return !!procedureOrRouter._def.procedure;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @internal
|
|
186
|
-
*/ function callProcedure(opts) {
|
|
187
|
-
const { type , path } = opts;
|
|
188
|
-
const proc = opts.procedures[path];
|
|
189
|
-
if (!proc || !isProcedure(proc) || proc._def.type !== type) {
|
|
190
|
-
throw new TRPCError.TRPCError({
|
|
191
|
-
code: 'NOT_FOUND',
|
|
192
|
-
message: `No "${type}"-procedure on path "${path}"`
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return proc(opts);
|
|
196
|
-
}
|
|
197
|
-
function createCallerFactory() {
|
|
198
|
-
return function createCallerInner(router) {
|
|
199
|
-
const _def = router._def;
|
|
200
|
-
return function createCaller(maybeContext) {
|
|
201
|
-
const proxy = createProxy.createRecursiveProxy(({ path , args })=>{
|
|
202
|
-
const fullPath = path.join('.');
|
|
203
|
-
const procedure = _def.procedures[fullPath];
|
|
204
|
-
const callProc = (ctx)=>procedure({
|
|
205
|
-
path: fullPath,
|
|
206
|
-
getRawInput: async ()=>args[0],
|
|
207
|
-
ctx,
|
|
208
|
-
type: procedure._def.type
|
|
209
|
-
});
|
|
210
|
-
if (typeof maybeContext === 'function') {
|
|
211
|
-
const context = maybeContext();
|
|
212
|
-
if (context instanceof Promise) {
|
|
213
|
-
return context.then(callProc);
|
|
214
|
-
}
|
|
215
|
-
return callProc(context);
|
|
216
|
-
}
|
|
217
|
-
return callProc(maybeContext);
|
|
218
|
-
});
|
|
219
|
-
return proxy;
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function mergeRouters(...routerList) {
|
|
224
|
-
const record = utils.mergeWithoutOverrides({}, ...routerList.map((r)=>r._def.record));
|
|
225
|
-
const errorFormatter = routerList.reduce((currentErrorFormatter, nextRouter)=>{
|
|
226
|
-
if (nextRouter._def._config.errorFormatter && nextRouter._def._config.errorFormatter !== defaultFormatter) {
|
|
227
|
-
if (currentErrorFormatter !== defaultFormatter && currentErrorFormatter !== nextRouter._def._config.errorFormatter) {
|
|
228
|
-
throw new Error('You seem to have several error formatters');
|
|
229
|
-
}
|
|
230
|
-
return nextRouter._def._config.errorFormatter;
|
|
231
|
-
}
|
|
232
|
-
return currentErrorFormatter;
|
|
233
|
-
}, defaultFormatter);
|
|
234
|
-
const transformer = routerList.reduce((prev, current)=>{
|
|
235
|
-
if (current._def._config.transformer && current._def._config.transformer !== defaultTransformer) {
|
|
236
|
-
if (prev !== defaultTransformer && prev !== current._def._config.transformer) {
|
|
237
|
-
throw new Error('You seem to have several transformers');
|
|
238
|
-
}
|
|
239
|
-
return current._def._config.transformer;
|
|
240
|
-
}
|
|
241
|
-
return prev;
|
|
242
|
-
}, defaultTransformer);
|
|
243
|
-
const router = createRouterFactory({
|
|
244
|
-
errorFormatter,
|
|
245
|
-
transformer,
|
|
246
|
-
isDev: routerList.some((r)=>r._def._config.isDev),
|
|
247
|
-
allowOutsideOfServer: routerList.some((r)=>r._def._config.allowOutsideOfServer),
|
|
248
|
-
isServer: routerList.some((r)=>r._def._config.isServer),
|
|
249
|
-
$types: routerList[0]?._def._config.$types
|
|
250
|
-
})(record);
|
|
251
|
-
return router;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
exports.callProcedure = callProcedure;
|
|
255
|
-
exports.createCallerFactory = createCallerFactory;
|
|
256
|
-
exports.createRouterFactory = createRouterFactory;
|
|
257
|
-
exports.defaultFormatter = defaultFormatter;
|
|
258
|
-
exports.defaultTransformer = defaultTransformer;
|
|
259
|
-
exports.getDataTransformer = getDataTransformer;
|
|
260
|
-
exports.mergeRouters = mergeRouters;
|
|
261
|
-
exports.transformResult = transformResult;
|
|
262
|
-
exports.transformTRPCResponse = transformTRPCResponse;
|
package/dist/router-c5bd7780.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { c as createRecursiveProxy } from './createProxy-f6960c7b.js';
|
|
2
|
-
import { T as TRPCError } from './TRPCError-ebbde27d.js';
|
|
3
|
-
import { a as isObject, m as mergeWithoutOverrides, o as omitPrototype } from './utils-e1d51fac.js';
|
|
4
|
-
|
|
5
|
-
const defaultFormatter = ({ shape }) => {
|
|
6
|
-
return shape;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
function getDataTransformer(transformer) {
|
|
13
|
-
if ('input' in transformer) {
|
|
14
|
-
return transformer;
|
|
15
|
-
}
|
|
16
|
-
return { input: transformer, output: transformer };
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
const defaultTransformer = {
|
|
22
|
-
_default: true,
|
|
23
|
-
input: { serialize: (obj) => obj, deserialize: (obj) => obj },
|
|
24
|
-
output: { serialize: (obj) => obj, deserialize: (obj) => obj },
|
|
25
|
-
};
|
|
26
|
-
function transformTRPCResponseItem(config, item) {
|
|
27
|
-
if ('error' in item) {
|
|
28
|
-
return {
|
|
29
|
-
...item,
|
|
30
|
-
error: config.transformer.output.serialize(item.error),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if ('data' in item.result) {
|
|
34
|
-
return {
|
|
35
|
-
...item,
|
|
36
|
-
result: {
|
|
37
|
-
...item.result,
|
|
38
|
-
data: config.transformer.output.serialize(item.result.data),
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return item;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
46
|
-
**/
|
|
47
|
-
function transformTRPCResponse(config, itemOrItems) {
|
|
48
|
-
return Array.isArray(itemOrItems)
|
|
49
|
-
? itemOrItems.map((item) => transformTRPCResponseItem(config, item))
|
|
50
|
-
: transformTRPCResponseItem(config, itemOrItems);
|
|
51
|
-
}
|
|
52
|
-
// FIXME:
|
|
53
|
-
// - the generics here are probably unnecessary
|
|
54
|
-
// - the RPC-spec could probably be simplified to combine HTTP + WS
|
|
55
|
-
/** @internal */
|
|
56
|
-
function transformResultInner(response, transformer) {
|
|
57
|
-
if ('error' in response) {
|
|
58
|
-
const error = transformer.deserialize(response.error);
|
|
59
|
-
return {
|
|
60
|
-
ok: false,
|
|
61
|
-
error: {
|
|
62
|
-
...response,
|
|
63
|
-
error,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const result = {
|
|
68
|
-
...response.result,
|
|
69
|
-
...((!response.result.type || response.result.type === 'data') && {
|
|
70
|
-
type: 'data',
|
|
71
|
-
data: transformer.deserialize(response.result.data),
|
|
72
|
-
}),
|
|
73
|
-
};
|
|
74
|
-
return { ok: true, result };
|
|
75
|
-
}
|
|
76
|
-
class TransformResultError extends Error {
|
|
77
|
-
constructor() {
|
|
78
|
-
super('Unable to transform response from server');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Transforms and validates that the result is a valid TRPCResponse
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
function transformResult(response, transformer) {
|
|
86
|
-
let result;
|
|
87
|
-
try {
|
|
88
|
-
// Use the data transformers on the JSON-response
|
|
89
|
-
result = transformResultInner(response, transformer);
|
|
90
|
-
}
|
|
91
|
-
catch (err) {
|
|
92
|
-
throw new TransformResultError();
|
|
93
|
-
}
|
|
94
|
-
// check that output of the transformers is a valid TRPCResponse
|
|
95
|
-
if (!result.ok &&
|
|
96
|
-
(!isObject(result.error.error) ||
|
|
97
|
-
typeof result.error.error['code'] !== 'number')) {
|
|
98
|
-
throw new TransformResultError();
|
|
99
|
-
}
|
|
100
|
-
if (result.ok && !isObject(result.result)) {
|
|
101
|
-
throw new TransformResultError();
|
|
102
|
-
}
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function isRouter(procedureOrRouter) {
|
|
107
|
-
return 'router' in procedureOrRouter._def;
|
|
108
|
-
}
|
|
109
|
-
const emptyRouter = {
|
|
110
|
-
_ctx: null,
|
|
111
|
-
_errorShape: null,
|
|
112
|
-
_meta: null,
|
|
113
|
-
queries: {},
|
|
114
|
-
mutations: {},
|
|
115
|
-
subscriptions: {},
|
|
116
|
-
errorFormatter: defaultFormatter,
|
|
117
|
-
transformer: defaultTransformer,
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Reserved words that can't be used as router or procedure names
|
|
121
|
-
*/
|
|
122
|
-
const reservedWords = [
|
|
123
|
-
/**
|
|
124
|
-
* Then is a reserved word because otherwise we can't return a promise that returns a Proxy
|
|
125
|
-
* since JS will think that `.then` is something that exists
|
|
126
|
-
*/
|
|
127
|
-
'then',
|
|
128
|
-
];
|
|
129
|
-
/**
|
|
130
|
-
* @internal
|
|
131
|
-
*/
|
|
132
|
-
function createRouterFactory(config) {
|
|
133
|
-
return function createRouterInner(procedures) {
|
|
134
|
-
const reservedWordsUsed = new Set(Object.keys(procedures).filter((v) => reservedWords.includes(v)));
|
|
135
|
-
if (reservedWordsUsed.size > 0) {
|
|
136
|
-
throw new Error('Reserved words used in `router({})` call: ' +
|
|
137
|
-
Array.from(reservedWordsUsed).join(', '));
|
|
138
|
-
}
|
|
139
|
-
const routerProcedures = omitPrototype({});
|
|
140
|
-
function recursiveGetPaths(procedures, path = '') {
|
|
141
|
-
for (const [key, procedureOrRouter] of Object.entries(procedures ?? {})) {
|
|
142
|
-
const newPath = `${path}${key}`;
|
|
143
|
-
if (isRouter(procedureOrRouter)) {
|
|
144
|
-
recursiveGetPaths(procedureOrRouter._def.procedures, `${newPath}.`);
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (routerProcedures[newPath]) {
|
|
148
|
-
throw new Error(`Duplicate key: ${newPath}`);
|
|
149
|
-
}
|
|
150
|
-
routerProcedures[newPath] = procedureOrRouter;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
recursiveGetPaths(procedures);
|
|
154
|
-
const _def = {
|
|
155
|
-
_config: config,
|
|
156
|
-
router: true,
|
|
157
|
-
procedures: routerProcedures,
|
|
158
|
-
...emptyRouter,
|
|
159
|
-
record: procedures,
|
|
160
|
-
};
|
|
161
|
-
const router = {
|
|
162
|
-
...procedures,
|
|
163
|
-
_def,
|
|
164
|
-
createCaller(ctx) {
|
|
165
|
-
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
166
|
-
const fullPath = path.join('.');
|
|
167
|
-
const procedure = _def.procedures[fullPath];
|
|
168
|
-
return procedure({
|
|
169
|
-
path: fullPath,
|
|
170
|
-
getRawInput: async () => args[0],
|
|
171
|
-
ctx,
|
|
172
|
-
type: procedure._def.type,
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
return proxy;
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
return router;
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function isProcedure(procedureOrRouter) {
|
|
182
|
-
return !!procedureOrRouter._def.procedure;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @internal
|
|
186
|
-
*/
|
|
187
|
-
function callProcedure(opts) {
|
|
188
|
-
const { type, path } = opts;
|
|
189
|
-
const proc = opts.procedures[path];
|
|
190
|
-
if (!proc || !isProcedure(proc) || proc._def.type !== type) {
|
|
191
|
-
throw new TRPCError({
|
|
192
|
-
code: 'NOT_FOUND',
|
|
193
|
-
message: `No "${type}"-procedure on path "${path}"`,
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
return proc(opts);
|
|
197
|
-
}
|
|
198
|
-
function createCallerFactory() {
|
|
199
|
-
return function createCallerInner(router) {
|
|
200
|
-
const _def = router._def;
|
|
201
|
-
return function createCaller(maybeContext) {
|
|
202
|
-
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
203
|
-
const fullPath = path.join('.');
|
|
204
|
-
const procedure = _def.procedures[fullPath];
|
|
205
|
-
const callProc = (ctx) => procedure({
|
|
206
|
-
path: fullPath,
|
|
207
|
-
getRawInput: async () => args[0],
|
|
208
|
-
ctx,
|
|
209
|
-
type: procedure._def.type,
|
|
210
|
-
});
|
|
211
|
-
if (typeof maybeContext === 'function') {
|
|
212
|
-
const context = maybeContext();
|
|
213
|
-
if (context instanceof Promise) {
|
|
214
|
-
return context.then(callProc);
|
|
215
|
-
}
|
|
216
|
-
return callProc(context);
|
|
217
|
-
}
|
|
218
|
-
return callProc(maybeContext);
|
|
219
|
-
});
|
|
220
|
-
return proxy;
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
function mergeRouters(...routerList) {
|
|
225
|
-
const record = mergeWithoutOverrides({}, ...routerList.map((r) => r._def.record));
|
|
226
|
-
const errorFormatter = routerList.reduce((currentErrorFormatter, nextRouter) => {
|
|
227
|
-
if (nextRouter._def._config.errorFormatter &&
|
|
228
|
-
nextRouter._def._config.errorFormatter !== defaultFormatter) {
|
|
229
|
-
if (currentErrorFormatter !== defaultFormatter &&
|
|
230
|
-
currentErrorFormatter !== nextRouter._def._config.errorFormatter) {
|
|
231
|
-
throw new Error('You seem to have several error formatters');
|
|
232
|
-
}
|
|
233
|
-
return nextRouter._def._config.errorFormatter;
|
|
234
|
-
}
|
|
235
|
-
return currentErrorFormatter;
|
|
236
|
-
}, defaultFormatter);
|
|
237
|
-
const transformer = routerList.reduce((prev, current) => {
|
|
238
|
-
if (current._def._config.transformer &&
|
|
239
|
-
current._def._config.transformer !== defaultTransformer) {
|
|
240
|
-
if (prev !== defaultTransformer &&
|
|
241
|
-
prev !== current._def._config.transformer) {
|
|
242
|
-
throw new Error('You seem to have several transformers');
|
|
243
|
-
}
|
|
244
|
-
return current._def._config.transformer;
|
|
245
|
-
}
|
|
246
|
-
return prev;
|
|
247
|
-
}, defaultTransformer);
|
|
248
|
-
const router = createRouterFactory({
|
|
249
|
-
errorFormatter,
|
|
250
|
-
transformer,
|
|
251
|
-
isDev: routerList.some((r) => r._def._config.isDev),
|
|
252
|
-
allowOutsideOfServer: routerList.some((r) => r._def._config.allowOutsideOfServer),
|
|
253
|
-
isServer: routerList.some((r) => r._def._config.isServer),
|
|
254
|
-
$types: routerList[0]?._def._config.$types,
|
|
255
|
-
})(record);
|
|
256
|
-
return router;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export { defaultTransformer as a, createRouterFactory as b, callProcedure as c, defaultFormatter as d, createCallerFactory as e, transformResult as f, getDataTransformer as g, mergeRouters as m, transformTRPCResponse as t };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { AnyRootConfig } from './rootConfig';
|
|
2
|
-
import type { AnyRouter } from './router';
|
|
3
|
-
export type TRPCInferrable = AnyRouter | AnyRootConfig;
|
|
4
|
-
export type inferConfig<TInferrable extends TRPCInferrable> = TInferrable extends AnyRouter ? TInferrable['_def']['_config'] : TInferrable;
|
|
5
|
-
export type inferErrorShape<TInferrable extends TRPCInferrable> = inferConfig<TInferrable>['$types']['errorShape'];
|
|
6
|
-
//# sourceMappingURL=TRPCInferrable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCInferrable.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/TRPCInferrable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;AACvD,MAAM,MAAM,WAAW,CAAC,WAAW,SAAS,cAAc,IACxD,WAAW,SAAS,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC;AAE/E,MAAM,MAAM,eAAe,CAAC,WAAW,SAAS,cAAc,IAC5D,WAAW,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
interface ProxyCallbackOptions {
|
|
2
|
-
path: string[];
|
|
3
|
-
args: unknown[];
|
|
4
|
-
}
|
|
5
|
-
type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a proxy that calls the callback with the path and arguments
|
|
8
|
-
*
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare const createRecursiveProxy: (callback: ProxyCallback) => unknown;
|
|
12
|
-
/**
|
|
13
|
-
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
14
|
-
*
|
|
15
|
-
* @internal
|
|
16
|
-
*/
|
|
17
|
-
export declare const createFlatProxy: <TFaux>(callback: (path: string & keyof TFaux) => any) => TFaux;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=createProxy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AA4B7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,aAAc,aAAa,YAC5B,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,eAAe,oDACgB,GAAG,UAY9C,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TRPC_ERROR_CODE_KEY } from '../rpc/codes';
|
|
2
|
-
export declare function getCauseFromUnknown(cause: unknown): Error | undefined;
|
|
3
|
-
export declare function getTRPCErrorFromUnknown(cause: unknown): TRPCError;
|
|
4
|
-
export declare class TRPCError extends Error {
|
|
5
|
-
readonly cause?: Error;
|
|
6
|
-
readonly code: "INTERNAL_SERVER_ERROR" | "PARSE_ERROR" | "BAD_REQUEST" | "NOT_IMPLEMENTED" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
|
|
7
|
-
constructor(opts: {
|
|
8
|
-
message?: string;
|
|
9
|
-
code: TRPC_ERROR_CODE_KEY;
|
|
10
|
-
cause?: unknown;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=TRPCError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCError.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/TRPCError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAyBrE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAoBjE;AAED,qBAAa,SAAU,SAAQ,KAAK;IAGlC,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,SAAgB,IAAI,qSAAC;gBAET,IAAI,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAgBF"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { ProcedureType } from '../procedure';
|
|
2
|
-
import type { TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER, TRPCErrorShape } from '../rpc';
|
|
3
|
-
import type { TRPCError } from './TRPCError';
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export type ErrorFormatter<TContext, TShape extends TRPCErrorShape<number>> = (args: {
|
|
8
|
-
error: TRPCError;
|
|
9
|
-
type: ProcedureType | 'unknown';
|
|
10
|
-
path: string | undefined;
|
|
11
|
-
input: unknown;
|
|
12
|
-
ctx: TContext | undefined;
|
|
13
|
-
shape: DefaultErrorShape;
|
|
14
|
-
}) => TShape;
|
|
15
|
-
export type ErrorFormatterShape<TType> = TType extends ErrorFormatter<any, infer TShape> ? TShape : DefaultErrorShape;
|
|
16
|
-
/**
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export type DefaultErrorData = {
|
|
20
|
-
code: TRPC_ERROR_CODE_KEY;
|
|
21
|
-
httpStatus: number;
|
|
22
|
-
path?: string;
|
|
23
|
-
stack?: string;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER, DefaultErrorData> {
|
|
29
|
-
message: string;
|
|
30
|
-
code: TRPC_ERROR_CODE_NUMBER;
|
|
31
|
-
}
|
|
32
|
-
export declare const defaultFormatter: ErrorFormatter<any, any>;
|
|
33
|
-
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACf,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,cAAc,CACxB,QAAQ,EACR,MAAM,SAAS,cAAc,CAAC,MAAM,CAAC,IACnC,CAAC,IAAI,EAAE;IACT,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC1B,KAAK,EAAE,iBAAiB,CAAC;CAC1B,KAAK,MAAM,CAAC;AAEb,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI,KAAK,SAAS,cAAc,CACnE,GAAG,EACH,MAAM,MAAM,CACb,GACG,MAAM,GACN,iBAAiB,CAAC;AACtB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBACf,SAAQ,cAAc,CAAC,sBAAsB,EAAE,gBAAgB,CAAC;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAErD,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ProcedureType } from '../procedure';
|
|
2
|
-
import type { AnyRootConfig } from '../rootConfig';
|
|
3
|
-
import type { TRPCError } from './TRPCError';
|
|
4
|
-
/**
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare function getErrorShape<TConfig extends AnyRootConfig>(opts: {
|
|
8
|
-
config: TConfig;
|
|
9
|
-
error: TRPCError;
|
|
10
|
-
type: ProcedureType | 'unknown';
|
|
11
|
-
path: string | undefined;
|
|
12
|
-
input: unknown;
|
|
13
|
-
ctx: TConfig['$types']['ctx'] | undefined;
|
|
14
|
-
}): TConfig['$types']['errorShape'];
|
|
15
|
-
//# sourceMappingURL=getErrorShape.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getErrorShape.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/getErrorShape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,aAAa,EAAE,IAAI,EAAE;IACjE,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;CAC3C,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAkBlC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a batch response as a line-delimited JSON stream
|
|
3
|
-
* that the `unstable_httpBatchStreamLink` can parse:
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const formatter = getBatchStreamFormatter();
|
|
8
|
-
* res.send(formatter(1, 'response #2'));
|
|
9
|
-
* res.send(formatter(0, 'response #1'));
|
|
10
|
-
* res.send(formatter.end());
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Expected format:
|
|
14
|
-
* ```json
|
|
15
|
-
* {"1":"response #2"
|
|
16
|
-
* ,"0":"response #1"
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function getBatchStreamFormatter(): {
|
|
21
|
-
(index: number, string: string): string;
|
|
22
|
-
end(): string;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=batchStreamFormatter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batchStreamFormatter.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/batchStreamFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB;YAEd,MAAM,UAAU,MAAM;;EAO9C"}
|