@trpc/server 10.0.0-alpha.38 → 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.
Files changed (35) hide show
  1. package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.dev.js +20 -0
  2. package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.cjs.prod.js +20 -0
  3. package/adapters/aws-lambda/dist/trpc-server-adapters-aws-lambda.esm.js +20 -0
  4. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  5. package/dist/core/index.d.ts +2 -1
  6. package/dist/core/index.d.ts.map +1 -1
  7. package/dist/core/initTRPC.d.ts +1 -1
  8. package/dist/core/internals/procedureBuilder.d.ts +37 -13
  9. package/dist/core/internals/procedureBuilder.d.ts.map +1 -1
  10. package/dist/core/procedure.d.ts +12 -8
  11. package/dist/core/procedure.d.ts.map +1 -1
  12. package/dist/core/router.d.ts +17 -3
  13. package/dist/core/router.d.ts.map +1 -1
  14. package/dist/core/types.d.ts +3 -1
  15. package/dist/core/types.d.ts.map +1 -1
  16. package/dist/index-1a25ccbd.js +33 -0
  17. package/dist/index-a3bd54c7.mjs +31 -0
  18. package/dist/index.js +186 -191
  19. package/dist/index.mjs +185 -192
  20. package/dist/shared/index.js +2 -28
  21. package/dist/shared/index.mjs +1 -31
  22. package/dist/types.d.ts +10 -0
  23. package/dist/types.d.ts.map +1 -1
  24. package/package.json +2 -2
  25. package/src/adapters/aws-lambda/index.ts +17 -0
  26. package/src/core/index.ts +2 -1
  27. package/src/core/internals/procedureBuilder.ts +264 -28
  28. package/src/core/procedure.ts +17 -10
  29. package/src/core/router.ts +79 -78
  30. package/src/core/types.ts +5 -1
  31. package/src/deprecated/interop.ts +4 -4
  32. package/src/types.ts +12 -0
  33. package/dist/core/internals/internalProcedure.d.ts +0 -78
  34. package/dist/core/internals/internalProcedure.d.ts.map +0 -1
  35. package/src/core/internals/internalProcedure.ts +0 -297
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ export { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPRe
3
3
  import { T as TRPC_ERROR_CODES_BY_KEY } from './envelopes-af8c2959.mjs';
4
4
  import { T as TRPCError, g as getCauseFromUnknown, a as getErrorFromUnknown } from './TRPCError-b7fa0c31.mjs';
5
5
  export { T as TRPCError } from './TRPCError-b7fa0c31.mjs';
6
+ import { c as createProxy } from './index-a3bd54c7.mjs';
6
7
  import './transformTRPCResponse-747b9a68.mjs';
7
8
 
8
9
  assertNotBrowser();
@@ -361,97 +362,82 @@ const middlewareMarker = 'middlewareMarker';
361
362
  * @internal
362
363
  */
363
364
 
364
- /**
365
- * This is the actual internal representation of a builder
366
- * FIXME - I want to get rid of this and use the public API instead
367
- */
368
-
369
- function createNewInternalBuilder(def1, def2) {
365
+ function createNewBuilder(def1, def2) {
370
366
  const {
371
367
  middlewares = [],
372
368
  ...rest
373
369
  } = def2; // TODO: maybe have a fn here to warn about calls
374
370
 
375
- return createInternalBuilder({ ...mergeWithoutOverrides(def1, rest),
371
+ return createBuilder({ ...mergeWithoutOverrides(def1, rest),
376
372
  middlewares: [...def1.middlewares, ...middlewares]
377
373
  });
378
374
  }
379
375
 
380
- const codeblock = /*#__PURE__*/`
381
- If you want to call this function on the server, you do the following:
382
- This is a client-only function.
383
-
384
- const caller = appRouter.createCaller({
385
- /* ... your context */
386
- });
376
+ function createBuilder(initDef) {
377
+ const _def = initDef || {
378
+ middlewares: []
379
+ };
387
380
 
388
- const result = await caller.call('myProcedure', input);
389
- `.trim();
381
+ return {
382
+ _def,
390
383
 
391
- function createProcedureCaller(_def) {
392
- const procedure = async function resolve(opts) {
393
- if (!opts || !('rawInput' in opts)) {
394
- throw new Error(codeblock);
395
- } // run the middlewares recursively with the resolver as the last one
384
+ input(input) {
385
+ const parser = getParseFn(input);
386
+ return createNewBuilder(_def, {
387
+ input,
388
+ middlewares: [createInputMiddleware(parser)]
389
+ });
390
+ },
396
391
 
392
+ output(output) {
393
+ const parseOutput = getParseFn(output);
394
+ return createNewBuilder(_def, {
395
+ output,
396
+ middlewares: [createOutputMiddleware(parseOutput)]
397
+ });
398
+ },
397
399
 
398
- const callRecursive = async (callOpts = {
399
- index: 0,
400
- ctx: opts.ctx
401
- }) => {
402
- try {
403
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
404
- const middleware = _def.middlewares[callOpts.index];
405
- const result = await middleware({
406
- ctx: callOpts.ctx,
407
- type: opts.type,
408
- path: opts.path,
409
- rawInput: opts.rawInput,
410
- meta: _def.meta,
411
- input: callOpts.input,
412
- next: async nextOpts => {
413
- return await callRecursive({
414
- index: callOpts.index + 1,
415
- ctx: nextOpts && 'ctx' in nextOpts ? { ...callOpts.ctx,
416
- ...nextOpts.ctx
417
- } : callOpts.ctx,
418
- input: nextOpts && 'input' in nextOpts ? nextOpts.input : callOpts.input
419
- });
420
- }
421
- });
422
- return result;
423
- } catch (cause) {
424
- return {
425
- ok: false,
426
- error: getErrorFromUnknown(cause),
427
- marker: middlewareMarker
428
- };
429
- }
430
- }; // there's always at least one "next" since we wrap this.resolver in a middleware
400
+ meta(meta) {
401
+ return createNewBuilder(_def, {
402
+ meta: meta
403
+ });
404
+ },
431
405
 
406
+ /** @deprecated **/
407
+ resolve(resolver) {
408
+ return createResolver(_def, resolver);
409
+ },
432
410
 
433
- const result = await callRecursive();
411
+ unstable_concat(builder) {
412
+ return createNewBuilder(_def, builder._def);
413
+ },
434
414
 
435
- if (!result) {
436
- throw new TRPCError({
437
- code: 'INTERNAL_SERVER_ERROR',
438
- message: 'No result from middlewares - did you forget to `return next()`?'
415
+ use(middleware) {
416
+ return createNewBuilder(_def, {
417
+ middlewares: [middleware]
439
418
  });
440
- }
419
+ },
441
420
 
442
- if (!result.ok) {
443
- // re-throw original error
444
- throw result.error;
421
+ query(resolver) {
422
+ return createResolver({ ..._def,
423
+ query: true
424
+ }, resolver);
425
+ },
426
+
427
+ mutation(resolver) {
428
+ return createResolver({ ..._def,
429
+ mutation: true
430
+ }, resolver);
431
+ },
432
+
433
+ subscription(resolver) {
434
+ return createResolver({ ..._def,
435
+ subscription: true
436
+ }, resolver);
445
437
  }
446
438
 
447
- return result.data;
448
439
  };
449
-
450
- procedure._def = _def;
451
- procedure.meta = _def.meta;
452
- return procedure;
453
440
  }
454
-
455
441
  function createInputMiddleware(parse) {
456
442
  return async function inputMiddleware({
457
443
  next,
@@ -501,7 +487,7 @@ function createOutputMiddleware(parse) {
501
487
  }
502
488
 
503
489
  function createResolver(_def, resolver) {
504
- const finalBuilder = createNewInternalBuilder(_def, {
490
+ const finalBuilder = createNewBuilder(_def, {
505
491
  resolver,
506
492
  middlewares: [async function resolveMiddleware(opts) {
507
493
  const data = await resolver(opts);
@@ -515,72 +501,85 @@ function createResolver(_def, resolver) {
515
501
  });
516
502
  return createProcedureCaller(finalBuilder._def);
517
503
  }
504
+ /**
505
+ * @internal
506
+ */
518
507
 
519
- function createInternalBuilder(initDef) {
520
- const _def = initDef || {
521
- middlewares: []
522
- };
523
508
 
524
- return {
525
- _def,
509
+ const codeblock = /*#__PURE__*/`
510
+ If you want to call this function on the server, you do the following:
511
+ This is a client-only function.
526
512
 
527
- // _call: createProcedureCaller(_def),
528
- input(input) {
529
- const parser = getParseFn(input);
530
- return createNewInternalBuilder(_def, {
531
- input,
532
- middlewares: [createInputMiddleware(parser)]
533
- });
534
- },
513
+ const caller = appRouter.createCaller({
514
+ /* ... your context */
515
+ });
535
516
 
536
- output(output) {
537
- const parseOutput = getParseFn(output);
538
- return createNewInternalBuilder(_def, {
539
- output,
540
- middlewares: [createOutputMiddleware(parseOutput)]
541
- });
542
- },
517
+ const result = await caller.call('myProcedure', input);
518
+ `.trim();
543
519
 
544
- meta(meta) {
545
- return createNewInternalBuilder(_def, {
546
- meta
547
- });
548
- },
520
+ function createProcedureCaller(_def) {
521
+ const procedure = async function resolve(opts) {
522
+ // is direct server-side call
523
+ if (!opts || !('rawInput' in opts)) {
524
+ throw new Error(codeblock);
525
+ } // run the middlewares recursively with the resolver as the last one
549
526
 
550
- /** @deprecated **/
551
- resolve(resolver) {
552
- return createResolver(_def, resolver);
553
- },
554
527
 
555
- unstable_concat(builder) {
556
- return createNewInternalBuilder(_def, builder._def);
557
- },
528
+ const callRecursive = async (callOpts = {
529
+ index: 0,
530
+ ctx: opts.ctx
531
+ }) => {
532
+ try {
533
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
534
+ const middleware = _def.middlewares[callOpts.index];
535
+ const result = await middleware({
536
+ ctx: callOpts.ctx,
537
+ type: opts.type,
538
+ path: opts.path,
539
+ rawInput: opts.rawInput,
540
+ meta: _def.meta,
541
+ input: callOpts.input,
542
+ next: async nextOpts => {
543
+ return await callRecursive({
544
+ index: callOpts.index + 1,
545
+ ctx: nextOpts && 'ctx' in nextOpts ? { ...callOpts.ctx,
546
+ ...nextOpts.ctx
547
+ } : callOpts.ctx,
548
+ input: nextOpts && 'input' in nextOpts ? nextOpts.input : callOpts.input
549
+ });
550
+ }
551
+ });
552
+ return result;
553
+ } catch (cause) {
554
+ return {
555
+ ok: false,
556
+ error: getErrorFromUnknown(cause),
557
+ marker: middlewareMarker
558
+ };
559
+ }
560
+ }; // there's always at least one "next" since we wrap this.resolver in a middleware
558
561
 
559
- use(middleware) {
560
- return createNewInternalBuilder(_def, {
561
- middlewares: [middleware]
562
- });
563
- },
564
562
 
565
- query(resolver) {
566
- return createResolver({ ..._def,
567
- query: true
568
- }, resolver);
569
- },
563
+ const result = await callRecursive();
570
564
 
571
- mutation(resolver) {
572
- return createResolver({ ..._def,
573
- mutation: true
574
- }, resolver);
575
- },
565
+ if (!result) {
566
+ throw new TRPCError({
567
+ code: 'INTERNAL_SERVER_ERROR',
568
+ message: 'No result from middlewares - did you forget to `return next()`?'
569
+ });
570
+ }
576
571
 
577
- subscription(resolver) {
578
- return createResolver({ ..._def,
579
- subscription: true
580
- }, resolver);
572
+ if (!result.ok) {
573
+ // re-throw original error
574
+ throw result.error;
581
575
  }
582
576
 
577
+ return result.data;
583
578
  };
579
+
580
+ procedure._def = _def;
581
+ procedure.meta = _def.meta;
582
+ return procedure;
584
583
  }
585
584
 
586
585
  /**
@@ -591,15 +590,15 @@ function omitPrototype(obj1) {
591
590
  return Object.assign(Object.create(null), obj1);
592
591
  }
593
592
 
594
- /* eslint-disable @typescript-eslint/ban-types */
593
+ const procedureTypes = ['query', 'mutation', 'subscription'];
594
+ /**
595
+ * @public
596
+ */
595
597
 
596
- function createRouterProxy(callback) {
597
- return new Proxy({}, {
598
- get(_, path) {
599
- return (...args) => callback(path, ...args);
600
- }
598
+ /* eslint-disable @typescript-eslint/ban-types */
601
599
 
602
- });
600
+ function isRouter(procedureOrRouter) {
601
+ return 'router' in procedureOrRouter._def;
603
602
  }
604
603
 
605
604
  const emptyRouter = {
@@ -627,9 +626,8 @@ function createRouterFactory(defaults) {
627
626
  for (const [key, procedureOrRouter] of Object.entries(procedures !== null && procedures !== void 0 ? procedures : {})) {
628
627
  const newPath = `${path}${key}`;
629
628
 
630
- if (typeof procedureOrRouter === 'object') {
631
- const router = procedureOrRouter;
632
- recursiveGetPaths(router._def.procedures, `${newPath}.`);
629
+ if (isRouter(procedureOrRouter)) {
630
+ recursiveGetPaths(procedureOrRouter._def.procedures, `${newPath}.`);
633
631
  continue;
634
632
  }
635
633
 
@@ -663,68 +661,45 @@ function createRouterFactory(defaults) {
663
661
  [key]: val
664
662
  }), {})
665
663
  };
666
-
667
- function callProcedure(opts) {
668
- const {
669
- type,
670
- path
671
- } = opts;
672
-
673
- if (!(path in _def.procedures) || !_def.procedures[path]['_def'][type]) {
674
- throw new TRPCError({
675
- code: 'NOT_FOUND',
676
- message: `No "${type}"-procedure on path "${path}"`
677
- });
678
- }
679
-
680
- const procedure = _def.procedures[path];
681
- return procedure(opts);
682
- }
683
-
684
664
  const router = { ...opts,
685
665
  _def,
686
666
  transformer: _def.transformer,
687
667
  errorFormatter: _def.errorFormatter,
688
668
 
689
669
  createCaller(ctx) {
690
- return {
691
- query: (path, ...args) => callProcedure({
692
- path,
693
- rawInput: args[0],
694
- ctx,
695
- type: 'query'
696
- }),
697
- mutation: (path, ...args) => callProcedure({
698
- path,
699
- rawInput: args[0],
700
- ctx,
701
- type: 'mutation'
702
- }),
703
- subscription: (path, ...args) => callProcedure({
704
- path,
670
+ const proxy = createProxy(({
671
+ path,
672
+ args
673
+ }) => {
674
+ // interop mode
675
+ if (path.length === 1 && procedureTypes.includes(path[0])) {
676
+ return callProcedure({
677
+ procedures: _def.procedures,
678
+ path: args[0],
679
+ rawInput: args[1],
680
+ ctx,
681
+ type: path[0]
682
+ });
683
+ }
684
+
685
+ const fullPath = path.join('.');
686
+ const procedure = _def.procedures[fullPath];
687
+ let type = 'query';
688
+
689
+ if (procedure._def.mutation) {
690
+ type = 'mutation';
691
+ } else if (procedure._def.subscription) {
692
+ type = 'subscription';
693
+ }
694
+
695
+ return procedure({
696
+ path: fullPath,
705
697
  rawInput: args[0],
706
698
  ctx,
707
- type: 'subscription'
708
- }),
709
- queries: createRouterProxy((path, rawInput) => callProcedure({
710
- path,
711
- rawInput,
712
- ctx,
713
- type: 'query'
714
- })),
715
- mutations: createRouterProxy((path, rawInput) => callProcedure({
716
- path,
717
- rawInput,
718
- ctx,
719
- type: 'mutation'
720
- })),
721
- subscriptions: createRouterProxy((path, rawInput) => callProcedure({
722
- path,
723
- rawInput,
724
- ctx,
725
- type: 'subscription'
726
- }))
727
- };
699
+ type
700
+ });
701
+ });
702
+ return proxy;
728
703
  },
729
704
 
730
705
  getErrorShape(opts) {
@@ -761,6 +736,28 @@ function createRouterFactory(defaults) {
761
736
  return router;
762
737
  };
763
738
  }
739
+ /**
740
+ * @internal
741
+ */
742
+
743
+ function callProcedure(opts) {
744
+ var _opts$procedures$path;
745
+
746
+ const {
747
+ type,
748
+ path
749
+ } = opts;
750
+
751
+ if (!(path in opts.procedures) || !((_opts$procedures$path = opts.procedures[path]) !== null && _opts$procedures$path !== void 0 && _opts$procedures$path._def[type])) {
752
+ throw new TRPCError({
753
+ code: 'NOT_FOUND',
754
+ message: `No "${type}"-procedure on path "${path}"`
755
+ });
756
+ }
757
+
758
+ const procedure = opts.procedures[path];
759
+ return procedure(opts);
760
+ }
764
761
 
765
762
  function migrateProcedure(oldProc, type) {
766
763
  const def = oldProc._def();
@@ -768,7 +765,7 @@ function migrateProcedure(oldProc, type) {
768
765
  const inputParser = getParseFnOrPassThrough(def.inputParser);
769
766
  const outputParser = getParseFnOrPassThrough(def.outputParser);
770
767
  const inputMiddleware = createInputMiddleware(inputParser);
771
- const builder = createInternalBuilder({
768
+ const builder = createBuilder({
772
769
  input: def.inputParser,
773
770
  middlewares: [...def.middlewares, inputMiddleware, createOutputMiddleware(outputParser)],
774
771
  meta: def.meta,
@@ -1136,10 +1133,6 @@ function mergeRoutersGeneric(...args) {
1136
1133
  return mergeRouters(...args);
1137
1134
  }
1138
1135
 
1139
- function createBuilder() {
1140
- return createInternalBuilder();
1141
- }
1142
-
1143
1136
  /**
1144
1137
  * @internal
1145
1138
  */
@@ -1216,4 +1209,4 @@ function initTRPC() {
1216
1209
  };
1217
1210
  }
1218
1211
 
1219
- export { defaultTransformer, getDataTransformer$1 as getDataTransformer, initTRPC, router };
1212
+ export { callProcedure, defaultTransformer, getDataTransformer$1 as getDataTransformer, initTRPC, procedureTypes, router };
@@ -2,34 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function createProxyInner(callback, ...path) {
6
- const proxy = new Proxy(() => {// noop
7
- }, {
8
- get(_obj, name) {
9
- if (typeof name === 'string') {
10
- return createProxyInner(callback, ...path, name);
11
- }
5
+ var index = require('../index-1a25ccbd.js');
12
6
 
13
- throw new Error('Not supported');
14
- },
15
7
 
16
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- apply(_1, _2, args) {
18
- return callback({
19
- args,
20
- path
21
- });
22
- }
23
8
 
24
- });
25
- return proxy;
26
- }
27
- /**
28
- * Creates a proxy that calls the callback with the path and arguments
29
- * @internal
30
- */
31
-
32
-
33
- const createProxy = callback => createProxyInner(callback);
34
-
35
- exports.createProxy = createProxy;
9
+ exports.createProxy = index.createProxy;
@@ -1,31 +1 @@
1
- function createProxyInner(callback, ...path) {
2
- const proxy = new Proxy(() => {// noop
3
- }, {
4
- get(_obj, name) {
5
- if (typeof name === 'string') {
6
- return createProxyInner(callback, ...path, name);
7
- }
8
-
9
- throw new Error('Not supported');
10
- },
11
-
12
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
- apply(_1, _2, args) {
14
- return callback({
15
- args,
16
- path
17
- });
18
- }
19
-
20
- });
21
- return proxy;
22
- }
23
- /**
24
- * Creates a proxy that calls the callback with the path and arguments
25
- * @internal
26
- */
27
-
28
-
29
- const createProxy = callback => createProxyInner(callback);
30
-
31
- export { createProxy };
1
+ export { c as createProxy } from '../index-a3bd54c7.mjs';
package/dist/types.d.ts CHANGED
@@ -54,5 +54,15 @@ declare type FilterKeys<T extends object, K> = {
54
54
  * @internal
55
55
  */
56
56
  export declare type Filter<T extends object, K> = Pick<T, FilterKeys<T, K>>;
57
+ /**
58
+ * @internal
59
+ */
60
+ export declare type NeverKeys<T> = {
61
+ [TKey in keyof T]: T[TKey] extends never ? TKey : never;
62
+ }[keyof T];
63
+ /**
64
+ * @internal
65
+ */
66
+ export declare type OmitNeverKeys<T> = Omit<T, NeverKeys<T>>;
57
67
  export {};
58
68
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;AAEpE;;GAEG;AACH,oBAAY,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5B;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,QAA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
3
+ "version": "10.0.0-alpha.39",
4
4
  "description": "tRPC Server",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -139,5 +139,5 @@
139
139
  "dependencies": {
140
140
  "tslib": "^2.1.0"
141
141
  },
142
- "gitHead": "0c40cb7ebfd8762ef482ff72cc54c2cf3ef4a0a8"
142
+ "gitHead": "a9cde42919d1a6b761fe25f18410c7270cb2cc2e"
143
143
  }
@@ -50,11 +50,28 @@ function getHTTPMethod(event: APIGatewayEvent) {
50
50
  message: UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE,
51
51
  });
52
52
  }
53
+
53
54
  function getPath(event: APIGatewayEvent) {
54
55
  if (isPayloadV1(event)) {
56
+ const matches = event.resource.matchAll(/\{(.*?)\}/g);
57
+ for (const match of matches) {
58
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
59
+ const group = match[1]!;
60
+ if (group.includes('+') && event.pathParameters) {
61
+ return event.pathParameters[group.replace('+', '')] || '';
62
+ }
63
+ }
55
64
  return event.path.slice(1);
56
65
  }
57
66
  if (isPayloadV2(event)) {
67
+ const matches = event.routeKey.matchAll(/\{(.*?)\}/g);
68
+ for (const match of matches) {
69
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
70
+ const group = match[1]!;
71
+ if (group.includes('+') && event.pathParameters) {
72
+ return event.pathParameters[group.replace('+', '')] || '';
73
+ }
74
+ }
58
75
  return event.rawPath.slice(1);
59
76
  }
60
77
  throw new TRPCError({
package/src/core/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type { AnyRouter, ProcedureRouterRecord } from './router';
2
- export type { Procedure, ProcedureParams } from './procedure';
2
+ export { callProcedure } from './router';
3
+ export type { Procedure, ProcedureParams, ProcedureArgs } from './procedure';
3
4
 
4
5
  export { initTRPC } from './initTRPC';
5
6
  export * from './types';