@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.215 → 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 -12
- package/dist/adapters/aws-lambda/index.mjs +3 -8
- 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 -8
- package/dist/adapters/express.mjs +2 -8
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/index.js +4 -12
- package/dist/adapters/fastify/index.mjs +2 -10
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
- package/dist/adapters/fetch/index.js +4 -10
- package/dist/adapters/fetch/index.mjs +2 -8
- package/dist/adapters/fetch/types.d.ts +1 -1
- package/dist/adapters/next.d.ts +1 -1
- package/dist/adapters/next.js +5 -11
- package/dist/adapters/next.mjs +3 -9
- package/dist/adapters/node-http/content-type/json/index.js +3 -5
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
- package/dist/adapters/node-http/index.js +2 -8
- package/dist/adapters/node-http/index.mjs +2 -8
- 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 -8
- package/dist/adapters/standalone.mjs +2 -8
- package/dist/adapters/ws.d.ts +1 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -31
- package/dist/adapters/ws.mjs +1 -6
- package/dist/http.d.ts +6 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -12
- package/dist/http.mjs +1 -7
- package/dist/index.js +41 -15
- package/dist/index.mjs +1 -5
- package/dist/{nodeHTTPRequestHandler-257a3b5f.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -4
- package/dist/{nodeHTTPRequestHandler-f4b7e374.js → nodeHTTPRequestHandler-55f05150.js} +4 -6
- package/dist/{nodeHTTPRequestHandler-29178135.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
- package/dist/observable.d.ts +2 -2
- package/dist/observable.d.ts.map +1 -1
- package/dist/observable.js +25 -9
- package/dist/observable.mjs +1 -3
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -5
- package/dist/rpc.mjs +1 -2
- package/dist/shared.js +9 -4
- package/dist/shared.mjs +1 -2
- 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 +2 -2
- package/src/rpc.ts +2 -2
- package/dist/TRPCError-10da405a.js +0 -61
- package/dist/TRPCError-14edcf88.mjs +0 -63
- package/dist/TRPCError-e2c8eb77.js +0 -67
- 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 -767
- package/dist/contentType-2ed02bef.mjs +0 -52
- package/dist/contentType-3a829011.js +0 -54
- package/dist/contentType-e4a2373e.js +0 -59
- package/dist/createProxy-0306dcaa.mjs +0 -121
- package/dist/createProxy-7e413449.js +0 -127
- package/dist/createProxy-dce0c414.js +0 -116
- package/dist/initTRPC-2cef03ab.js +0 -384
- package/dist/initTRPC-38faa18f.js +0 -371
- package/dist/initTRPC-fa1b3d57.mjs +0 -376
- package/dist/observable-2a5a96d5.js +0 -125
- package/dist/observable-62674916.js +0 -125
- package/dist/observable-6d025a37.mjs +0 -121
- package/dist/operators-0cc4956a.js +0 -99
- package/dist/operators-b08617cb.js +0 -103
- package/dist/operators-d0c3e794.mjs +0 -99
- package/dist/parseTRPCMessage-6e6c204e.js +0 -65
- package/dist/parseTRPCMessage-8eb0bbe9.mjs +0 -62
- package/dist/parseTRPCMessage-ebdfe3ca.js +0 -67
- package/dist/resolveHTTPResponse-833ca2b8.js +0 -265
- package/dist/resolveHTTPResponse-9322334c.mjs +0 -291
- package/dist/resolveHTTPResponse-d64c48e1.js +0 -293
- package/dist/rootConfig-3371c473.js +0 -89
- package/dist/rootConfig-571c9267.js +0 -94
- package/dist/rootConfig-6b04a6b8.mjs +0 -81
- package/dist/router-3344b52a.js +0 -262
- package/dist/router-919c37eb.js +0 -259
- package/dist/router-d6789e4b.mjs +0 -252
- 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 -35
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -51
- package/dist/unstable-core-do-not-import/index.mjs +0 -11
- 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/observable/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/observable/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/observable.d.ts +0 -13
- package/dist/unstable-core-do-not-import/observable/observable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/operators.d.ts +0 -8
- package/dist/unstable-core-do-not-import/observable/operators.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/types.d.ts +0 -26
- package/dist/unstable-core-do-not-import/observable/types.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/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 -108
- 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/observable/index.ts +0 -10
- package/src/unstable-core-do-not-import/observable/observable.ts +0 -155
- package/src/unstable-core-do-not-import/observable/operators.ts +0 -119
- package/src/unstable-core-do-not-import/observable/types.ts +0 -76
- 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
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
import { d as createFlatProxy } from './createProxy-0306dcaa.mjs';
|
|
2
|
-
import { d as defaultFormatter, g as getDataTransformer, a as defaultTransformer, b as createRouterFactory, m as mergeRouters, e as createCallerFactory } from './router-d6789e4b.mjs';
|
|
3
|
-
import { T as TRPCError, g as getTRPCErrorFromUnknown } from './TRPCError-14edcf88.mjs';
|
|
4
|
-
import { i as isObject, m as mergeWithoutOverrides, c as isServerDefault } from './rootConfig-6b04a6b8.mjs';
|
|
5
|
-
|
|
6
|
-
/** @internal */ const middlewareMarker = 'middlewareMarker';
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/ function createMiddlewareFactory() {
|
|
10
|
-
function createMiddlewareInner(middlewares) {
|
|
11
|
-
return {
|
|
12
|
-
_middlewares: middlewares,
|
|
13
|
-
unstable_pipe (middlewareBuilderOrFn) {
|
|
14
|
-
const pipedMiddleware = '_middlewares' in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [
|
|
15
|
-
middlewareBuilderOrFn
|
|
16
|
-
];
|
|
17
|
-
return createMiddlewareInner([
|
|
18
|
-
...middlewares,
|
|
19
|
-
...pipedMiddleware
|
|
20
|
-
]);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function createMiddleware(fn) {
|
|
25
|
-
return createMiddlewareInner([
|
|
26
|
-
fn
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
return createMiddleware;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Create a standalone middleware
|
|
33
|
-
* @link https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
34
|
-
*/ const experimental_standaloneMiddleware = ()=>({
|
|
35
|
-
create: createMiddlewareFactory()
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* @internal
|
|
39
|
-
* Please note, `trpc-openapi` uses this function.
|
|
40
|
-
*/ function createInputMiddleware(parse) {
|
|
41
|
-
const inputMiddleware = async function inputValidatorMiddleware(opts) {
|
|
42
|
-
let parsedInput;
|
|
43
|
-
const rawInput = await opts.getRawInput();
|
|
44
|
-
try {
|
|
45
|
-
parsedInput = await parse(rawInput);
|
|
46
|
-
} catch (cause) {
|
|
47
|
-
throw new TRPCError({
|
|
48
|
-
code: 'BAD_REQUEST',
|
|
49
|
-
cause
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
// Multiple input parsers
|
|
53
|
-
const combinedInput = isObject(opts.input) && isObject(parsedInput) ? {
|
|
54
|
-
...opts.input,
|
|
55
|
-
...parsedInput
|
|
56
|
-
} : parsedInput;
|
|
57
|
-
return opts.next({
|
|
58
|
-
input: combinedInput
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
inputMiddleware._type = 'input';
|
|
62
|
-
return inputMiddleware;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/ function createOutputMiddleware(parse) {
|
|
67
|
-
const outputMiddleware = async function outputValidatorMiddleware({ next }) {
|
|
68
|
-
const result = await next();
|
|
69
|
-
if (!result.ok) {
|
|
70
|
-
// pass through failures without validating
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const data = await parse(result.data);
|
|
75
|
-
return {
|
|
76
|
-
...result,
|
|
77
|
-
data
|
|
78
|
-
};
|
|
79
|
-
} catch (cause) {
|
|
80
|
-
throw new TRPCError({
|
|
81
|
-
message: 'Output validation failed',
|
|
82
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
83
|
-
cause
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
outputMiddleware._type = 'output';
|
|
88
|
-
return outputMiddleware;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// zod / @decs/typeschema
|
|
92
|
-
function getParseFn(procedureParser) {
|
|
93
|
-
const parser = procedureParser;
|
|
94
|
-
if (typeof parser === 'function') {
|
|
95
|
-
// ParserCustomValidatorEsque
|
|
96
|
-
return parser;
|
|
97
|
-
}
|
|
98
|
-
if (typeof parser.parseAsync === 'function') {
|
|
99
|
-
// ParserZodEsque
|
|
100
|
-
return parser.parseAsync.bind(parser);
|
|
101
|
-
}
|
|
102
|
-
if (typeof parser.parse === 'function') {
|
|
103
|
-
// ParserZodEsque
|
|
104
|
-
// ParserValibotEsque (<= v0.12.X)
|
|
105
|
-
return parser.parse.bind(parser);
|
|
106
|
-
}
|
|
107
|
-
if (typeof parser.validateSync === 'function') {
|
|
108
|
-
// ParserYupEsque
|
|
109
|
-
return parser.validateSync.bind(parser);
|
|
110
|
-
}
|
|
111
|
-
if (typeof parser.create === 'function') {
|
|
112
|
-
// ParserSuperstructEsque
|
|
113
|
-
return parser.create.bind(parser);
|
|
114
|
-
}
|
|
115
|
-
if (typeof parser.assert === 'function') {
|
|
116
|
-
// ParserScaleEsque
|
|
117
|
-
return (value)=>{
|
|
118
|
-
parser.assert(value);
|
|
119
|
-
return value;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
throw new Error('Could not find a validator fn');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/** @internal */ const unsetMarker = Symbol('unsetMarker');
|
|
126
|
-
function createNewBuilder(def1, def2) {
|
|
127
|
-
const { middlewares =[] , inputs , meta , ...rest } = def2;
|
|
128
|
-
// TODO: maybe have a fn here to warn about calls
|
|
129
|
-
return createBuilder({
|
|
130
|
-
...mergeWithoutOverrides(def1, rest),
|
|
131
|
-
inputs: [
|
|
132
|
-
...def1.inputs,
|
|
133
|
-
...inputs ?? []
|
|
134
|
-
],
|
|
135
|
-
middlewares: [
|
|
136
|
-
...def1.middlewares,
|
|
137
|
-
...middlewares
|
|
138
|
-
],
|
|
139
|
-
meta: def1.meta && meta ? {
|
|
140
|
-
...def1.meta,
|
|
141
|
-
...meta
|
|
142
|
-
} : meta ?? def1.meta
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
function createBuilder(initDef = {}) {
|
|
146
|
-
const _def = {
|
|
147
|
-
procedure: true,
|
|
148
|
-
inputs: [],
|
|
149
|
-
middlewares: [],
|
|
150
|
-
...initDef
|
|
151
|
-
};
|
|
152
|
-
const builder = {
|
|
153
|
-
_def,
|
|
154
|
-
input (input) {
|
|
155
|
-
const parser = getParseFn(input);
|
|
156
|
-
return createNewBuilder(_def, {
|
|
157
|
-
inputs: [
|
|
158
|
-
input
|
|
159
|
-
],
|
|
160
|
-
middlewares: [
|
|
161
|
-
createInputMiddleware(parser)
|
|
162
|
-
]
|
|
163
|
-
});
|
|
164
|
-
},
|
|
165
|
-
output (output) {
|
|
166
|
-
const parser = getParseFn(output);
|
|
167
|
-
return createNewBuilder(_def, {
|
|
168
|
-
output,
|
|
169
|
-
middlewares: [
|
|
170
|
-
createOutputMiddleware(parser)
|
|
171
|
-
]
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
meta (meta) {
|
|
175
|
-
return createNewBuilder(_def, {
|
|
176
|
-
meta
|
|
177
|
-
});
|
|
178
|
-
},
|
|
179
|
-
use (middlewareBuilderOrFn) {
|
|
180
|
-
// Distinguish between a middleware builder and a middleware function
|
|
181
|
-
const middlewares = '_middlewares' in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [
|
|
182
|
-
middlewareBuilderOrFn
|
|
183
|
-
];
|
|
184
|
-
return createNewBuilder(_def, {
|
|
185
|
-
middlewares: middlewares
|
|
186
|
-
});
|
|
187
|
-
},
|
|
188
|
-
query (resolver) {
|
|
189
|
-
return createResolver({
|
|
190
|
-
..._def,
|
|
191
|
-
type: 'query'
|
|
192
|
-
}, resolver);
|
|
193
|
-
},
|
|
194
|
-
mutation (resolver) {
|
|
195
|
-
return createResolver({
|
|
196
|
-
..._def,
|
|
197
|
-
type: 'mutation'
|
|
198
|
-
}, resolver);
|
|
199
|
-
},
|
|
200
|
-
subscription (resolver) {
|
|
201
|
-
return createResolver({
|
|
202
|
-
..._def,
|
|
203
|
-
type: 'subscription'
|
|
204
|
-
}, resolver);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
return builder;
|
|
208
|
-
}
|
|
209
|
-
function createResolver(_def, resolver) {
|
|
210
|
-
const finalBuilder = createNewBuilder(_def, {
|
|
211
|
-
resolver,
|
|
212
|
-
middlewares: [
|
|
213
|
-
async function resolveMiddleware(opts) {
|
|
214
|
-
const data = await resolver(opts);
|
|
215
|
-
return {
|
|
216
|
-
marker: middlewareMarker,
|
|
217
|
-
ok: true,
|
|
218
|
-
data,
|
|
219
|
-
ctx: opts.ctx
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
]
|
|
223
|
-
});
|
|
224
|
-
return createProcedureCaller(finalBuilder._def);
|
|
225
|
-
}
|
|
226
|
-
const codeblock = `
|
|
227
|
-
This is a client-only function.
|
|
228
|
-
If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
|
|
229
|
-
`.trim();
|
|
230
|
-
function createProcedureCaller(_def) {
|
|
231
|
-
async function procedure(opts) {
|
|
232
|
-
// is direct server-side call
|
|
233
|
-
if (!opts || !('getRawInput' in opts)) {
|
|
234
|
-
throw new Error(codeblock);
|
|
235
|
-
}
|
|
236
|
-
// run the middlewares recursively with the resolver as the last one
|
|
237
|
-
async function callRecursive(callOpts = {
|
|
238
|
-
index: 0,
|
|
239
|
-
ctx: opts.ctx
|
|
240
|
-
}) {
|
|
241
|
-
try {
|
|
242
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
243
|
-
const middleware = _def.middlewares[callOpts.index];
|
|
244
|
-
const result = await middleware({
|
|
245
|
-
ctx: callOpts.ctx,
|
|
246
|
-
type: opts.type,
|
|
247
|
-
path: opts.path,
|
|
248
|
-
getRawInput: callOpts.getRawInput ?? opts.getRawInput,
|
|
249
|
-
meta: _def.meta,
|
|
250
|
-
input: callOpts.input,
|
|
251
|
-
next (_nextOpts) {
|
|
252
|
-
const nextOpts = _nextOpts;
|
|
253
|
-
return callRecursive({
|
|
254
|
-
index: callOpts.index + 1,
|
|
255
|
-
ctx: nextOpts && 'ctx' in nextOpts ? {
|
|
256
|
-
...callOpts.ctx,
|
|
257
|
-
...nextOpts.ctx
|
|
258
|
-
} : callOpts.ctx,
|
|
259
|
-
input: nextOpts && 'input' in nextOpts ? nextOpts.input : callOpts.input,
|
|
260
|
-
getRawInput: nextOpts && 'getRawInput' in nextOpts ? nextOpts.getRawInput : callOpts.getRawInput
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
return result;
|
|
265
|
-
} catch (cause) {
|
|
266
|
-
return {
|
|
267
|
-
ok: false,
|
|
268
|
-
error: getTRPCErrorFromUnknown(cause),
|
|
269
|
-
marker: middlewareMarker
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// there's always at least one "next" since we wrap this.resolver in a middleware
|
|
274
|
-
const result = await callRecursive();
|
|
275
|
-
if (!result) {
|
|
276
|
-
throw new TRPCError({
|
|
277
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
278
|
-
message: 'No result from middlewares - did you forget to `return next()`?'
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
if (!result.ok) {
|
|
282
|
-
// re-throw original error
|
|
283
|
-
throw result.error;
|
|
284
|
-
}
|
|
285
|
-
return result.data;
|
|
286
|
-
}
|
|
287
|
-
procedure._def = _def;
|
|
288
|
-
// FIXME typecast shouldn't be needed - fixittt
|
|
289
|
-
return procedure;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* TODO: This can be improved:
|
|
294
|
-
* - We should be able to chain `.meta()`/`.context()` only once
|
|
295
|
-
* - Simplify typings
|
|
296
|
-
* - Doesn't need to be a class but it doesn't really hurt either
|
|
297
|
-
*/ class TRPCBuilder {
|
|
298
|
-
/**
|
|
299
|
-
* Add a context shape as a generic to the root object
|
|
300
|
-
* @link https://trpc.io/docs/v11/server/context
|
|
301
|
-
*/ context() {
|
|
302
|
-
return new TRPCBuilder();
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Add a meta shape as a generic to the root object
|
|
306
|
-
* @link https://trpc.io/docs/v11/quickstart
|
|
307
|
-
*/ meta() {
|
|
308
|
-
return new TRPCBuilder();
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Create the root object
|
|
312
|
-
* @link https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
313
|
-
*/ create(options) {
|
|
314
|
-
return createTRPCInner()(options);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
319
|
-
* @link https://trpc.io/docs/v11/quickstart
|
|
320
|
-
*/ const initTRPC = new TRPCBuilder();
|
|
321
|
-
function createTRPCInner() {
|
|
322
|
-
return function initTRPCInner(runtime) {
|
|
323
|
-
const errorFormatter = runtime?.errorFormatter ?? defaultFormatter;
|
|
324
|
-
const transformer = getDataTransformer(runtime?.transformer ?? defaultTransformer);
|
|
325
|
-
const config = {
|
|
326
|
-
transformer,
|
|
327
|
-
isDev: runtime?.isDev ?? // eslint-disable-next-line @typescript-eslint/dot-notation
|
|
328
|
-
globalThis.process?.env?.['NODE_ENV'] !== 'production',
|
|
329
|
-
allowOutsideOfServer: runtime?.allowOutsideOfServer ?? false,
|
|
330
|
-
errorFormatter,
|
|
331
|
-
isServer: runtime?.isServer ?? isServerDefault,
|
|
332
|
-
/**
|
|
333
|
-
* @internal
|
|
334
|
-
*/ $types: createFlatProxy((key)=>{
|
|
335
|
-
throw new Error(`Tried to access "$types.${key}" which is not available at runtime`);
|
|
336
|
-
})
|
|
337
|
-
};
|
|
338
|
-
{
|
|
339
|
-
// Server check
|
|
340
|
-
const isServer = runtime?.isServer ?? isServerDefault;
|
|
341
|
-
if (!isServer && runtime?.allowOutsideOfServer !== true) {
|
|
342
|
-
throw new Error(`You're trying to use @trpc/server in a non-server environment. This is not supported by default.`);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return {
|
|
346
|
-
/**
|
|
347
|
-
* These are just types, they can't be used
|
|
348
|
-
* @internal
|
|
349
|
-
*/ _config: config,
|
|
350
|
-
/**
|
|
351
|
-
* Builder object for creating procedures
|
|
352
|
-
* @link https://trpc.io/docs/v11/server/procedures
|
|
353
|
-
*/ procedure: createBuilder({
|
|
354
|
-
meta: runtime?.defaultMeta
|
|
355
|
-
}),
|
|
356
|
-
/**
|
|
357
|
-
* Create reusable middlewares
|
|
358
|
-
* @link https://trpc.io/docs/v11/server/middlewares
|
|
359
|
-
*/ middleware: createMiddlewareFactory(),
|
|
360
|
-
/**
|
|
361
|
-
* Create a router
|
|
362
|
-
* @link https://trpc.io/docs/v11/server/routers
|
|
363
|
-
*/ router: createRouterFactory(config),
|
|
364
|
-
/**
|
|
365
|
-
* Merge Routers
|
|
366
|
-
* @link https://trpc.io/docs/v11/server/merging-routers
|
|
367
|
-
*/ mergeRouters,
|
|
368
|
-
/**
|
|
369
|
-
* Create a server-side caller for a router
|
|
370
|
-
* @link https://trpc.io/docs/v11/server/server-side-calls
|
|
371
|
-
*/ createCallerFactory: createCallerFactory()
|
|
372
|
-
};
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export { createOutputMiddleware as a, createBuilder as b, createInputMiddleware as c, experimental_standaloneMiddleware as e, initTRPC as i, middlewareMarker as m, unsetMarker as u };
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var rootConfig = require('./rootConfig-3371c473.js');
|
|
4
|
-
|
|
5
|
-
/** @public */ function isObservable(x) {
|
|
6
|
-
return typeof x === 'object' && x !== null && 'subscribe' in x;
|
|
7
|
-
}
|
|
8
|
-
/** @public */ function observable(subscribe) {
|
|
9
|
-
const self = {
|
|
10
|
-
subscribe (observer) {
|
|
11
|
-
let teardownRef = null;
|
|
12
|
-
let isDone = false;
|
|
13
|
-
let unsubscribed = false;
|
|
14
|
-
let teardownImmediately = false;
|
|
15
|
-
function unsubscribe() {
|
|
16
|
-
if (teardownRef === null) {
|
|
17
|
-
teardownImmediately = true;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (unsubscribed) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
unsubscribed = true;
|
|
24
|
-
if (typeof teardownRef === 'function') {
|
|
25
|
-
teardownRef();
|
|
26
|
-
} else if (teardownRef) {
|
|
27
|
-
teardownRef.unsubscribe();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
teardownRef = subscribe({
|
|
31
|
-
next (value) {
|
|
32
|
-
if (isDone) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
observer.next?.(value);
|
|
36
|
-
},
|
|
37
|
-
error (err) {
|
|
38
|
-
if (isDone) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
isDone = true;
|
|
42
|
-
observer.error?.(err);
|
|
43
|
-
unsubscribe();
|
|
44
|
-
},
|
|
45
|
-
complete () {
|
|
46
|
-
if (isDone) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
isDone = true;
|
|
50
|
-
observer.complete?.();
|
|
51
|
-
unsubscribe();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
if (teardownImmediately) {
|
|
55
|
-
unsubscribe();
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
unsubscribe
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
pipe (...operations) {
|
|
62
|
-
return pipeFromArray(operations)(self);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
return self;
|
|
66
|
-
}
|
|
67
|
-
function pipeFromArray(fns) {
|
|
68
|
-
if (fns.length === 0) {
|
|
69
|
-
return rootConfig.identity;
|
|
70
|
-
}
|
|
71
|
-
if (fns.length === 1) {
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
73
|
-
return fns[0];
|
|
74
|
-
}
|
|
75
|
-
return function piped(input) {
|
|
76
|
-
return fns.reduce((prev, fn)=>fn(prev), input);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
class ObservableAbortError extends Error {
|
|
80
|
-
constructor(message){
|
|
81
|
-
super(message);
|
|
82
|
-
this.name = 'ObservableAbortError';
|
|
83
|
-
Object.setPrototypeOf(this, ObservableAbortError.prototype);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/** @internal */ function observableToPromise(observable) {
|
|
87
|
-
let abort;
|
|
88
|
-
const promise = new Promise((resolve, reject)=>{
|
|
89
|
-
let isDone = false;
|
|
90
|
-
function onDone() {
|
|
91
|
-
if (isDone) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
isDone = true;
|
|
95
|
-
reject(new ObservableAbortError('This operation was aborted.'));
|
|
96
|
-
obs$.unsubscribe();
|
|
97
|
-
}
|
|
98
|
-
const obs$ = observable.subscribe({
|
|
99
|
-
next (data) {
|
|
100
|
-
isDone = true;
|
|
101
|
-
resolve(data);
|
|
102
|
-
onDone();
|
|
103
|
-
},
|
|
104
|
-
error (data) {
|
|
105
|
-
isDone = true;
|
|
106
|
-
reject(data);
|
|
107
|
-
onDone();
|
|
108
|
-
},
|
|
109
|
-
complete () {
|
|
110
|
-
isDone = true;
|
|
111
|
-
onDone();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
abort = onDone;
|
|
115
|
-
});
|
|
116
|
-
return {
|
|
117
|
-
promise,
|
|
118
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
119
|
-
abort: abort
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
exports.isObservable = isObservable;
|
|
124
|
-
exports.observable = observable;
|
|
125
|
-
exports.observableToPromise = observableToPromise;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { b as identity } from './rootConfig-571c9267.js';
|
|
2
|
-
|
|
3
|
-
/** @public */
|
|
4
|
-
function isObservable(x) {
|
|
5
|
-
return typeof x === 'object' && x !== null && 'subscribe' in x;
|
|
6
|
-
}
|
|
7
|
-
/** @public */
|
|
8
|
-
function observable(subscribe) {
|
|
9
|
-
const self = {
|
|
10
|
-
subscribe(observer) {
|
|
11
|
-
let teardownRef = null;
|
|
12
|
-
let isDone = false;
|
|
13
|
-
let unsubscribed = false;
|
|
14
|
-
let teardownImmediately = false;
|
|
15
|
-
function unsubscribe() {
|
|
16
|
-
if (teardownRef === null) {
|
|
17
|
-
teardownImmediately = true;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (unsubscribed) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
unsubscribed = true;
|
|
24
|
-
if (typeof teardownRef === 'function') {
|
|
25
|
-
teardownRef();
|
|
26
|
-
}
|
|
27
|
-
else if (teardownRef) {
|
|
28
|
-
teardownRef.unsubscribe();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
teardownRef = subscribe({
|
|
32
|
-
next(value) {
|
|
33
|
-
if (isDone) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
observer.next?.(value);
|
|
37
|
-
},
|
|
38
|
-
error(err) {
|
|
39
|
-
if (isDone) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
isDone = true;
|
|
43
|
-
observer.error?.(err);
|
|
44
|
-
unsubscribe();
|
|
45
|
-
},
|
|
46
|
-
complete() {
|
|
47
|
-
if (isDone) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
isDone = true;
|
|
51
|
-
observer.complete?.();
|
|
52
|
-
unsubscribe();
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
if (teardownImmediately) {
|
|
56
|
-
unsubscribe();
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
unsubscribe,
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
pipe(...operations) {
|
|
63
|
-
return pipeFromArray(operations)(self);
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
return self;
|
|
67
|
-
}
|
|
68
|
-
function pipeFromArray(fns) {
|
|
69
|
-
if (fns.length === 0) {
|
|
70
|
-
return identity;
|
|
71
|
-
}
|
|
72
|
-
if (fns.length === 1) {
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
74
|
-
return fns[0];
|
|
75
|
-
}
|
|
76
|
-
return function piped(input) {
|
|
77
|
-
return fns.reduce((prev, fn) => fn(prev), input);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
class ObservableAbortError extends Error {
|
|
81
|
-
constructor(message) {
|
|
82
|
-
super(message);
|
|
83
|
-
this.name = 'ObservableAbortError';
|
|
84
|
-
Object.setPrototypeOf(this, ObservableAbortError.prototype);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/** @internal */
|
|
88
|
-
function observableToPromise(observable) {
|
|
89
|
-
let abort;
|
|
90
|
-
const promise = new Promise((resolve, reject) => {
|
|
91
|
-
let isDone = false;
|
|
92
|
-
function onDone() {
|
|
93
|
-
if (isDone) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
isDone = true;
|
|
97
|
-
reject(new ObservableAbortError('This operation was aborted.'));
|
|
98
|
-
obs$.unsubscribe();
|
|
99
|
-
}
|
|
100
|
-
const obs$ = observable.subscribe({
|
|
101
|
-
next(data) {
|
|
102
|
-
isDone = true;
|
|
103
|
-
resolve(data);
|
|
104
|
-
onDone();
|
|
105
|
-
},
|
|
106
|
-
error(data) {
|
|
107
|
-
isDone = true;
|
|
108
|
-
reject(data);
|
|
109
|
-
onDone();
|
|
110
|
-
},
|
|
111
|
-
complete() {
|
|
112
|
-
isDone = true;
|
|
113
|
-
onDone();
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
abort = onDone;
|
|
117
|
-
});
|
|
118
|
-
return {
|
|
119
|
-
promise,
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
121
|
-
abort: abort,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export { observableToPromise as a, isObservable as i, observable as o };
|