@trpc/server 10.0.0-alpha.36 → 10.0.0-alpha.39
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/README.md +79 -1
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.dev.js +20 -0
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.prod.js +20 -0
- package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.esm.js +20 -0
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.d.ts +4 -3
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/fastify/index.mjs +1 -1
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/initTRPC.d.ts +1 -1
- package/dist/core/internals/procedureBuilder.d.ts +37 -13
- package/dist/core/internals/procedureBuilder.d.ts.map +1 -1
- package/dist/core/middleware.d.ts +1 -1
- package/dist/core/procedure.d.ts +12 -8
- package/dist/core/procedure.d.ts.map +1 -1
- package/dist/core/router.d.ts +17 -3
- package/dist/core/router.d.ts.map +1 -1
- package/dist/core/types.d.ts +3 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/deprecated/router.d.ts.map +1 -1
- package/dist/index-1a25ccbd.js +33 -0
- package/dist/index-a3bd54c7.mjs +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +189 -194
- package/dist/index.mjs +188 -195
- package/dist/internals.d.ts +11 -0
- package/dist/internals.d.ts.map +1 -0
- package/dist/observable/index.js +1 -1
- package/dist/observable/index.mjs +1 -1
- package/dist/observable/internals/pipe.d.ts.map +1 -1
- package/dist/{observable-3aa4d911.js → observable-341a0506.js} +1 -0
- package/dist/{observable-137ea1bd.mjs → observable-cfedfa30.mjs} +1 -0
- package/dist/shared/index.js +2 -28
- package/dist/shared/index.mjs +1 -31
- package/dist/subscription.js +1 -1
- package/dist/subscription.mjs +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/adapters/aws-lambda/index.ts +17 -0
- package/src/adapters/aws-lambda/utils.ts +2 -1
- package/src/core/index.ts +2 -1
- package/src/core/internals/procedureBuilder.ts +264 -28
- package/src/core/procedure.ts +17 -10
- package/src/core/router.ts +79 -78
- package/src/core/types.ts +5 -1
- package/src/deprecated/internals/procedure.ts +1 -1
- package/src/deprecated/interop.ts +4 -4
- package/src/deprecated/router.ts +3 -4
- package/src/http/resolveHTTPResponse.ts +1 -1
- package/src/index.ts +1 -0
- package/src/internals.ts +14 -0
- package/src/observable/internals/pipe.ts +2 -1
- package/src/observable/observable.test.ts +3 -3
- package/src/observable/operators/share.test.ts +2 -2
- package/src/types.ts +12 -0
- package/dist/core/internals/internalProcedure.d.ts +0 -78
- package/dist/core/internals/internalProcedure.d.ts.map +0 -1
- package/src/core/internals/internalProcedure.ts +0 -296
package/src/core/router.ts
CHANGED
|
@@ -9,21 +9,21 @@ import {
|
|
|
9
9
|
} from '../error/formatter';
|
|
10
10
|
import { getHTTPStatusCodeFromError } from '../http/internals/getHTTPStatusCode';
|
|
11
11
|
import { TRPCErrorShape, TRPC_ERROR_CODES_BY_KEY } from '../rpc';
|
|
12
|
+
import { createProxy } from '../shared';
|
|
12
13
|
import { CombinedDataTransformer, defaultTransformer } from '../transformer';
|
|
13
14
|
import { RootConfig } from './internals/config';
|
|
14
|
-
import {
|
|
15
|
-
InternalProcedure,
|
|
16
|
-
InternalProcedureCallOptions,
|
|
17
|
-
} from './internals/internalProcedure';
|
|
18
15
|
import { mergeWithoutOverrides } from './internals/mergeWithoutOverrides';
|
|
19
16
|
import { omitPrototype } from './internals/omitPrototype';
|
|
17
|
+
import { ProcedureCallOptions } from './internals/procedureBuilder';
|
|
20
18
|
import {
|
|
19
|
+
AnyProcedure,
|
|
21
20
|
MutationProcedure,
|
|
22
21
|
Procedure,
|
|
22
|
+
ProcedureArgs,
|
|
23
23
|
QueryProcedure,
|
|
24
24
|
SubscriptionProcedure,
|
|
25
25
|
} from './procedure';
|
|
26
|
-
import { ProcedureType } from './types';
|
|
26
|
+
import { ProcedureType, procedureTypes } from './types';
|
|
27
27
|
|
|
28
28
|
type ProcedureRecord = Record<string, Procedure<any>>;
|
|
29
29
|
|
|
@@ -122,11 +122,24 @@ type inferHandlerFn<TProcedures extends Record<string, Procedure<any>>> = <
|
|
|
122
122
|
...args: inferHandlerInput<TProcedure>
|
|
123
123
|
) => Promise<inferProcedureOutput<TProcedure>>;
|
|
124
124
|
|
|
125
|
+
type DecorateProcedure<TProcedure extends Procedure<any>> = (
|
|
126
|
+
input: ProcedureArgs<TProcedure['_def']>[0],
|
|
127
|
+
) => Promise<TProcedure['_def']['_output_out']>;
|
|
128
|
+
|
|
129
|
+
type assertProcedure<T> = T extends Procedure<any> ? T : never;
|
|
130
|
+
|
|
125
131
|
/**
|
|
126
|
-
* This only exists b/c of interop mode
|
|
127
132
|
* @internal
|
|
128
133
|
*/
|
|
134
|
+
type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
|
|
135
|
+
[TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter
|
|
136
|
+
? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']>
|
|
137
|
+
: DecorateProcedure<assertProcedure<TProcedures[TKey]>>;
|
|
138
|
+
};
|
|
129
139
|
|
|
140
|
+
/**
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
130
143
|
type RouterCaller<TDef extends AnyRouterDef> = (ctx: TDef['_ctx']) => {
|
|
131
144
|
/**
|
|
132
145
|
* @deprecated
|
|
@@ -140,7 +153,7 @@ type RouterCaller<TDef extends AnyRouterDef> = (ctx: TDef['_ctx']) => {
|
|
|
140
153
|
* @deprecated
|
|
141
154
|
*/
|
|
142
155
|
subscription: inferHandlerFn<TDef['subscriptions']>;
|
|
143
|
-
}
|
|
156
|
+
} & DecoratedProcedureRecord<TDef['record']>;
|
|
144
157
|
|
|
145
158
|
export interface Router<TDef extends AnyRouterDef> {
|
|
146
159
|
_def: RouterDef<
|
|
@@ -153,8 +166,6 @@ export interface Router<TDef extends AnyRouterDef> {
|
|
|
153
166
|
errorFormatter: TDef['errorFormatter'];
|
|
154
167
|
/** @deprecated **/
|
|
155
168
|
transformer: TDef['transformer'];
|
|
156
|
-
|
|
157
|
-
// FIXME rename me and deprecate
|
|
158
169
|
createCaller: RouterCaller<TDef>;
|
|
159
170
|
// FIXME rename me and deprecate
|
|
160
171
|
getErrorShape(opts: {
|
|
@@ -183,13 +194,12 @@ export type RouterBuildOptions<TContext> = Partial<
|
|
|
183
194
|
|
|
184
195
|
export type AnyRouter = Router<any>;
|
|
185
196
|
|
|
186
|
-
function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
},
|
|
191
|
-
});
|
|
197
|
+
function isRouter(
|
|
198
|
+
procedureOrRouter: AnyProcedure | AnyRouter,
|
|
199
|
+
): procedureOrRouter is AnyRouter {
|
|
200
|
+
return 'router' in procedureOrRouter._def;
|
|
192
201
|
}
|
|
202
|
+
|
|
193
203
|
const emptyRouter = {
|
|
194
204
|
_ctx: null as any,
|
|
195
205
|
_errorShape: null as any,
|
|
@@ -226,9 +236,8 @@ export function createRouterFactory<TConfig extends RootConfig>(
|
|
|
226
236
|
for (const [key, procedureOrRouter] of Object.entries(procedures ?? {})) {
|
|
227
237
|
const newPath = `${path}${key}`;
|
|
228
238
|
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
recursiveGetPaths(router._def.procedures, `${newPath}.`);
|
|
239
|
+
if (isRouter(procedureOrRouter)) {
|
|
240
|
+
recursiveGetPaths(procedureOrRouter._def.procedures, `${newPath}.`);
|
|
232
241
|
continue;
|
|
233
242
|
}
|
|
234
243
|
|
|
@@ -268,74 +277,46 @@ export function createRouterFactory<TConfig extends RootConfig>(
|
|
|
268
277
|
.reduce((acc, [key, val]) => ({ ...acc, [key]: val }), {}),
|
|
269
278
|
};
|
|
270
279
|
|
|
271
|
-
function callProcedure(opts: InternalProcedureCallOptions) {
|
|
272
|
-
const { type, path } = opts;
|
|
273
|
-
|
|
274
|
-
if (!(path in _def.procedures) || !_def.procedures[path]['_def'][type]) {
|
|
275
|
-
throw new TRPCError({
|
|
276
|
-
code: 'NOT_FOUND',
|
|
277
|
-
message: `No "${type}"-procedure on path "${path}"`,
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const procedure = _def.procedures[path] as InternalProcedure;
|
|
282
|
-
|
|
283
|
-
return procedure(opts);
|
|
284
|
-
}
|
|
285
280
|
const router: AnyRouter = {
|
|
286
281
|
...opts,
|
|
287
282
|
_def,
|
|
288
283
|
transformer: _def.transformer,
|
|
289
284
|
errorFormatter: _def.errorFormatter,
|
|
290
285
|
createCaller(ctx) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
path,
|
|
302
|
-
rawInput: args[0],
|
|
286
|
+
const proxy = createProxy(({ path, args }) => {
|
|
287
|
+
// interop mode
|
|
288
|
+
if (
|
|
289
|
+
path.length === 1 &&
|
|
290
|
+
procedureTypes.includes(path[0] as ProcedureType)
|
|
291
|
+
) {
|
|
292
|
+
return callProcedure({
|
|
293
|
+
procedures: _def.procedures,
|
|
294
|
+
path: args[0] as string,
|
|
295
|
+
rawInput: args[1],
|
|
303
296
|
ctx,
|
|
304
|
-
type:
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
callProcedure({
|
|
308
|
-
path,
|
|
309
|
-
rawInput: args[0],
|
|
310
|
-
ctx,
|
|
311
|
-
type: 'subscription',
|
|
312
|
-
}) as any,
|
|
297
|
+
type: path[0] as ProcedureType,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
313
300
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
rawInput,
|
|
334
|
-
ctx,
|
|
335
|
-
type: 'subscription',
|
|
336
|
-
}),
|
|
337
|
-
),
|
|
338
|
-
};
|
|
301
|
+
const fullPath = path.join('.');
|
|
302
|
+
const procedure = _def.procedures[fullPath] as AnyProcedure;
|
|
303
|
+
|
|
304
|
+
let type: ProcedureType = 'query';
|
|
305
|
+
if (procedure._def.mutation) {
|
|
306
|
+
type = 'mutation';
|
|
307
|
+
} else if (procedure._def.subscription) {
|
|
308
|
+
type = 'subscription';
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return procedure({
|
|
312
|
+
path: fullPath,
|
|
313
|
+
rawInput: args[0],
|
|
314
|
+
ctx,
|
|
315
|
+
type,
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
return proxy as ReturnType<RouterCaller<any>>;
|
|
339
320
|
},
|
|
340
321
|
getErrorShape(opts) {
|
|
341
322
|
const { path, error } = opts;
|
|
@@ -363,3 +344,23 @@ export function createRouterFactory<TConfig extends RootConfig>(
|
|
|
363
344
|
return router as any;
|
|
364
345
|
};
|
|
365
346
|
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @internal
|
|
350
|
+
*/
|
|
351
|
+
export function callProcedure(
|
|
352
|
+
opts: ProcedureCallOptions & { procedures: ProcedureRouterRecord },
|
|
353
|
+
) {
|
|
354
|
+
const { type, path } = opts;
|
|
355
|
+
|
|
356
|
+
if (!(path in opts.procedures) || !opts.procedures[path]?._def[type]) {
|
|
357
|
+
throw new TRPCError({
|
|
358
|
+
code: 'NOT_FOUND',
|
|
359
|
+
message: `No "${type}"-procedure on path "${path}"`,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const procedure = opts.procedures[path] as AnyProcedure;
|
|
364
|
+
|
|
365
|
+
return procedure(opts);
|
|
366
|
+
}
|
package/src/core/types.ts
CHANGED
|
@@ -17,10 +17,11 @@ export type inferRouterError<TRouter extends AnyRouter> =
|
|
|
17
17
|
export type inferRouterMeta<TRouter extends AnyRouter> =
|
|
18
18
|
inferRouterDef<TRouter>['_meta'];
|
|
19
19
|
|
|
20
|
+
export const procedureTypes = ['query', 'mutation', 'subscription'] as const;
|
|
20
21
|
/**
|
|
21
22
|
* @public
|
|
22
23
|
*/
|
|
23
|
-
export type ProcedureType =
|
|
24
|
+
export type ProcedureType = typeof procedureTypes[number];
|
|
24
25
|
|
|
25
26
|
export type inferHandlerInput<TProcedure extends Procedure<any>> =
|
|
26
27
|
ProcedureArgs<inferProcedureParams<TProcedure>>;
|
|
@@ -52,3 +53,6 @@ export type inferSubscriptionOutput<
|
|
|
52
53
|
> = inferObservableValue<
|
|
53
54
|
inferProcedureOutput<TRouter['_def']['subscriptions'][TPath]>
|
|
54
55
|
>;
|
|
56
|
+
|
|
57
|
+
export type inferProcedureClientError<T extends Procedure<any>> =
|
|
58
|
+
inferProcedureParams<T>['_config']['errorShape'];
|
|
@@ -207,7 +207,7 @@ export class Procedure<
|
|
|
207
207
|
},
|
|
208
208
|
): Promise<MiddlewareResult<any>> => {
|
|
209
209
|
try {
|
|
210
|
-
const result = await middlewaresWithResolver[callOpts.index]({
|
|
210
|
+
const result = await middlewaresWithResolver[callOpts.index]!({
|
|
211
211
|
ctx: callOpts.ctx,
|
|
212
212
|
type: opts.type,
|
|
213
213
|
path: opts.path,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CombinedDataTransformer, ProcedureParams, ProcedureType } from '..';
|
|
2
2
|
import { CreateRootConfig, RootConfig } from '../core/internals/config';
|
|
3
3
|
import { getParseFnOrPassThrough } from '../core/internals/getParseFn';
|
|
4
|
+
import { mergeWithoutOverrides } from '../core/internals/mergeWithoutOverrides';
|
|
4
5
|
import {
|
|
6
|
+
createBuilder,
|
|
5
7
|
createInputMiddleware,
|
|
6
|
-
createInternalBuilder,
|
|
7
8
|
createOutputMiddleware,
|
|
8
|
-
} from '../core/internals/
|
|
9
|
-
import { mergeWithoutOverrides } from '../core/internals/mergeWithoutOverrides';
|
|
9
|
+
} from '../core/internals/procedureBuilder';
|
|
10
10
|
import {
|
|
11
11
|
MutationProcedure,
|
|
12
12
|
Procedure as NewProcedure,
|
|
@@ -175,7 +175,7 @@ function migrateProcedure<
|
|
|
175
175
|
|
|
176
176
|
const inputMiddleware = createInputMiddleware(inputParser);
|
|
177
177
|
|
|
178
|
-
const builder =
|
|
178
|
+
const builder = createBuilder({
|
|
179
179
|
input: def.inputParser,
|
|
180
180
|
middlewares: [
|
|
181
181
|
...(def.middlewares as any),
|
package/src/deprecated/router.ts
CHANGED
|
@@ -337,8 +337,8 @@ export class Router<
|
|
|
337
337
|
TPrefix extends string,
|
|
338
338
|
>(procedures: TProcedures, prefix: TPrefix): Prefixer<TProcedures, TPrefix> {
|
|
339
339
|
const eps: ProcedureRecord = safeObject();
|
|
340
|
-
for (const key
|
|
341
|
-
eps[prefix + key] =
|
|
340
|
+
for (const [key, procedure] of Object.entries(procedures)) {
|
|
341
|
+
eps[prefix + key] = procedure;
|
|
342
342
|
}
|
|
343
343
|
return eps as any;
|
|
344
344
|
}
|
|
@@ -658,8 +658,7 @@ export class Router<
|
|
|
658
658
|
|
|
659
659
|
const mergeProcedures = (defs: ProcedureRecord) => {
|
|
660
660
|
const newDefs = safeObject() as typeof defs;
|
|
661
|
-
for (const key
|
|
662
|
-
const procedure = defs[key];
|
|
661
|
+
for (const [key, procedure] of Object.entries(defs)) {
|
|
663
662
|
const newProcedure = procedure.inheritMiddlewares(
|
|
664
663
|
this._def.middlewares,
|
|
665
664
|
);
|
|
@@ -213,7 +213,7 @@ export async function resolveHTTPResponse<
|
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
-
const result = isBatchCall ? resultEnvelopes : resultEnvelopes[0]
|
|
216
|
+
const result = isBatchCall ? resultEnvelopes : resultEnvelopes[0]!;
|
|
217
217
|
return endResponse(result, errors);
|
|
218
218
|
} catch (cause) {
|
|
219
219
|
// we get here if
|
package/src/index.ts
CHANGED
package/src/internals.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These types have to be exported so users can generate their own types definitions files
|
|
3
|
+
*/
|
|
4
|
+
export type { DefaultErrorShape } from './error/formatter';
|
|
5
|
+
export type { mergeRoutersGeneric } from './core/internals/__generated__/mergeRoutersGeneric';
|
|
6
|
+
export type { ProcedureBuilder } from './core/internals/procedureBuilder';
|
|
7
|
+
export type { Overwrite, unsetMarker } from './core/internals/utils';
|
|
8
|
+
export type { MiddlewareFunction } from './core/middleware';
|
|
9
|
+
export type { Router, RouterDef } from './core/router';
|
|
10
|
+
export type {
|
|
11
|
+
MutationProcedure,
|
|
12
|
+
QueryProcedure,
|
|
13
|
+
SubscriptionProcedure,
|
|
14
|
+
} from './core/procedure';
|
|
@@ -18,7 +18,7 @@ test('vanilla observable - complete()', () => {
|
|
|
18
18
|
expect(next.mock.calls).toHaveLength(1);
|
|
19
19
|
expect(complete.mock.calls).toHaveLength(1);
|
|
20
20
|
expect(error.mock.calls).toHaveLength(0);
|
|
21
|
-
expect(next.mock.calls[0][0]).toBe(1);
|
|
21
|
+
expect(next.mock.calls[0]![0]!).toBe(1);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
test('vanilla observable - unsubscribe()', () => {
|
|
@@ -38,7 +38,7 @@ test('vanilla observable - unsubscribe()', () => {
|
|
|
38
38
|
expect(next.mock.calls).toHaveLength(1);
|
|
39
39
|
expect(complete.mock.calls).toHaveLength(0);
|
|
40
40
|
expect(error.mock.calls).toHaveLength(0);
|
|
41
|
-
expect(next.mock.calls[0][0]).toBe(1);
|
|
41
|
+
expect(next.mock.calls[0]![0]!).toBe(1);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
test('pipe - combine operators', () => {
|
|
@@ -66,7 +66,7 @@ test('pipe - combine operators', () => {
|
|
|
66
66
|
expect(next.mock.calls).toHaveLength(1);
|
|
67
67
|
expect(complete.mock.calls).toHaveLength(0);
|
|
68
68
|
expect(error.mock.calls).toHaveLength(0);
|
|
69
|
-
expect(next.mock.calls[0][0]).toBe(1);
|
|
69
|
+
expect(next.mock.calls[0]![0]!).toBe(1);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
{
|
|
@@ -21,7 +21,7 @@ test('share', () => {
|
|
|
21
21
|
expect(next.mock.calls).toHaveLength(1);
|
|
22
22
|
expect(complete.mock.calls).toHaveLength(0);
|
|
23
23
|
expect(error.mock.calls).toHaveLength(0);
|
|
24
|
-
expect(next.mock.calls[0][0]).toBe(1);
|
|
24
|
+
expect(next.mock.calls[0]![0]!).toBe(1);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
{
|
|
@@ -54,7 +54,7 @@ test('share', () => {
|
|
|
54
54
|
expect(next.mock.calls).toHaveLength(1);
|
|
55
55
|
expect(complete.mock.calls).toHaveLength(0);
|
|
56
56
|
expect(error.mock.calls).toHaveLength(0);
|
|
57
|
-
expect(next.mock.calls[0][0]).toBe(1);
|
|
57
|
+
expect(next.mock.calls[0]![0]!).toBe(1);
|
|
58
58
|
subscription3.unsubscribe();
|
|
59
59
|
}
|
|
60
60
|
});
|
package/src/types.ts
CHANGED
|
@@ -74,3 +74,15 @@ type FilterKeys<T extends object, K> = {
|
|
|
74
74
|
* @internal
|
|
75
75
|
*/
|
|
76
76
|
export type Filter<T extends object, K> = Pick<T, FilterKeys<T, K>>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
export type NeverKeys<T> = {
|
|
82
|
+
[TKey in keyof T]: T[TKey] extends never ? TKey : never;
|
|
83
|
+
}[keyof T];
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
export type OmitNeverKeys<T> = Omit<T, NeverKeys<T>>;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { MaybePromise } from '../../types';
|
|
2
|
-
import { MiddlewareFunction } from '../middleware';
|
|
3
|
-
import { Parser } from '../parser';
|
|
4
|
-
import { ProcedureType } from '../types';
|
|
5
|
-
import { ParseFn } from './getParseFn';
|
|
6
|
-
import { ResolveOptions } from './utils';
|
|
7
|
-
export interface InternalProcedureCallOptions {
|
|
8
|
-
ctx: unknown;
|
|
9
|
-
rawInput: unknown;
|
|
10
|
-
input?: unknown;
|
|
11
|
-
path: string;
|
|
12
|
-
type: ProcedureType;
|
|
13
|
-
}
|
|
14
|
-
export interface InternalProcedure {
|
|
15
|
-
_def: ProcedureBuilderInternal['_def'];
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated use `._def.meta` instead
|
|
18
|
-
*/
|
|
19
|
-
meta: ProcedureBuilderInternal['_def']['meta'];
|
|
20
|
-
mutation?: boolean;
|
|
21
|
-
query?: boolean;
|
|
22
|
-
subscription?: boolean;
|
|
23
|
-
(opts: InternalProcedureCallOptions): Promise<unknown>;
|
|
24
|
-
}
|
|
25
|
-
declare type ProcedureBuilderInternalResolver = (opts: ResolveOptions<any>) => Promise<unknown>;
|
|
26
|
-
export declare type ProcedureBuilderInternalMiddleware = MiddlewareFunction<any, any>;
|
|
27
|
-
declare type TResolver = (opts: ResolveOptions<any>) => MaybePromise<any>;
|
|
28
|
-
interface ProcedureBuilderInternal {
|
|
29
|
-
_def: {
|
|
30
|
-
input?: Parser;
|
|
31
|
-
output?: Parser;
|
|
32
|
-
meta?: Record<string, unknown>;
|
|
33
|
-
resolver?: ProcedureBuilderInternalResolver;
|
|
34
|
-
middlewares: ProcedureBuilderInternalMiddleware[];
|
|
35
|
-
mutation?: boolean;
|
|
36
|
-
query?: boolean;
|
|
37
|
-
subscription?: boolean;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
input: (parser: Parser) => ProcedureBuilderInternal;
|
|
43
|
-
/**
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
output: (parser: Parser) => ProcedureBuilderInternal;
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
unstable_concat: (proc: ProcedureBuilderInternal) => ProcedureBuilderInternal;
|
|
51
|
-
/**
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
use: (fn: MiddlewareFunction<any, any>) => ProcedureBuilderInternal;
|
|
55
|
-
/**
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
meta: (meta: Record<string, unknown>) => ProcedureBuilderInternal;
|
|
59
|
-
/** @deprecated **/
|
|
60
|
-
resolve: (resolver: TResolver) => InternalProcedure;
|
|
61
|
-
/**
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
query: (resolver: TResolver) => InternalProcedure;
|
|
65
|
-
/**
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
mutation: (resolver: TResolver) => InternalProcedure;
|
|
69
|
-
/**
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
subscription: (resolver: TResolver) => InternalProcedure;
|
|
73
|
-
}
|
|
74
|
-
export declare function createInputMiddleware<T>(parse: ParseFn<T>): ProcedureBuilderInternalMiddleware;
|
|
75
|
-
export declare function createOutputMiddleware<T>(parse: ParseFn<T>): ProcedureBuilderInternalMiddleware;
|
|
76
|
-
export declare function createInternalBuilder(initDef?: ProcedureBuilderInternal['_def']): ProcedureBuilderInternal;
|
|
77
|
-
export {};
|
|
78
|
-
//# sourceMappingURL=internalProcedure.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
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