@trpc/server 10.0.0-proxy-alpha.57 → 10.0.0-proxy-alpha.60

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 CHANGED
@@ -7,8 +7,7 @@
7
7
  </p>
8
8
 
9
9
  <p align="center">
10
- <!-- TODO: replace with new version GIF -->
11
- <img src="https://storage.googleapis.com/trpc/trpcgif.gif" alt="Demo" />
10
+ <img src="https://assets.trpc.io/www/v10/preview-dark.gif" alt="Demo" />
12
11
  </p>
13
12
 
14
13
  # `@trpc/server`
@@ -23,13 +22,13 @@ Full documentation for `@trpc/server` can be found [here](https://trpc.io/docs/r
23
22
 
24
23
  ```bash
25
24
  # npm
26
- npm install @trpc/server
25
+ npm install @trpc/server@next
27
26
 
28
27
  # Yarn
29
- yarn add @trpc/server
28
+ yarn add @trpc/server@next
30
29
 
31
30
  # pnpm
32
- pnpm add @trpc/server
31
+ pnpm add @trpc/server@next
33
32
  ```
34
33
 
35
34
  We also recommend installing `zod` to validate procedure inputs.
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('../../router-36801fd1.js');
5
+ require('../../router-77321794.js');
6
6
  var TRPCError = require('../../TRPCError-fe9113e5.js');
7
- var resolveHTTPResponse = require('../../resolveHTTPResponse-b12c934f.js');
7
+ var resolveHTTPResponse = require('../../resolveHTTPResponse-d7a8a210.js');
8
8
  require('../../codes-1c24d919.js');
9
9
  require('../../index-9d687d33.js');
10
10
  require('../../transformTRPCResponse-11ac69cc.js');
@@ -1,6 +1,6 @@
1
- import '../../router-dfb17a79.mjs';
1
+ import '../../router-f747db2b.mjs';
2
2
  import { T as TRPCError } from '../../TRPCError-281ac25a.mjs';
3
- import { r as resolveHTTPResponse } from '../../resolveHTTPResponse-87b3a1e6.mjs';
3
+ import { r as resolveHTTPResponse } from '../../resolveHTTPResponse-1b339cff.mjs';
4
4
  import '../../codes-aaa7d554.mjs';
5
5
  import '../../index-47817162.mjs';
6
6
  import '../../transformTRPCResponse-c8138d5f.mjs';
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-ea18179c.js');
6
- require('../resolveHTTPResponse-b12c934f.js');
5
+ var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-76f803a4.js');
6
+ require('../resolveHTTPResponse-d7a8a210.js');
7
7
  require('../TRPCError-fe9113e5.js');
8
8
  require('../transformTRPCResponse-11ac69cc.js');
9
9
  require('../codes-1c24d919.js');
@@ -1,5 +1,5 @@
1
- import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-eba995e5.mjs';
2
- import '../resolveHTTPResponse-87b3a1e6.mjs';
1
+ import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-e9fceef4.mjs';
2
+ import '../resolveHTTPResponse-1b339cff.mjs';
3
3
  import '../TRPCError-281ac25a.mjs';
4
4
  import '../transformTRPCResponse-c8138d5f.mjs';
5
5
  import '../codes-aaa7d554.mjs';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHTTPResponse = require('../../resolveHTTPResponse-b12c934f.js');
5
+ var resolveHTTPResponse = require('../../resolveHTTPResponse-d7a8a210.js');
6
6
  var adapters_ws = require('../ws.js');
7
7
  require('../../TRPCError-fe9113e5.js');
8
8
  require('../../transformTRPCResponse-11ac69cc.js');
@@ -1,4 +1,4 @@
1
- import { a as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-87b3a1e6.mjs';
1
+ import { a as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-1b339cff.mjs';
2
2
  import { applyWSSHandler } from '../ws.mjs';
3
3
  import '../../TRPCError-281ac25a.mjs';
4
4
  import '../../transformTRPCResponse-c8138d5f.mjs';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHTTPResponse = require('../../resolveHTTPResponse-b12c934f.js');
5
+ var resolveHTTPResponse = require('../../resolveHTTPResponse-d7a8a210.js');
6
6
  require('../../TRPCError-fe9113e5.js');
7
7
  require('../../transformTRPCResponse-11ac69cc.js');
8
8
  require('../../codes-1c24d919.js');
@@ -1,4 +1,4 @@
1
- import { a as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-87b3a1e6.mjs';
1
+ import { a as assertNotBrowser, r as resolveHTTPResponse } from '../../resolveHTTPResponse-1b339cff.mjs';
2
2
  import '../../TRPCError-281ac25a.mjs';
3
3
  import '../../transformTRPCResponse-c8138d5f.mjs';
4
4
  import '../../codes-aaa7d554.mjs';
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var TRPCError = require('../TRPCError-fe9113e5.js');
6
- var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-ea18179c.js');
7
- require('../resolveHTTPResponse-b12c934f.js');
6
+ var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-76f803a4.js');
7
+ require('../resolveHTTPResponse-d7a8a210.js');
8
8
  require('../transformTRPCResponse-11ac69cc.js');
9
9
  require('../codes-1c24d919.js');
10
10
 
@@ -1,6 +1,6 @@
1
1
  import { T as TRPCError } from '../TRPCError-281ac25a.mjs';
2
- import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-eba995e5.mjs';
3
- import '../resolveHTTPResponse-87b3a1e6.mjs';
2
+ import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-e9fceef4.mjs';
3
+ import '../resolveHTTPResponse-1b339cff.mjs';
4
4
  import '../transformTRPCResponse-c8138d5f.mjs';
5
5
  import '../codes-aaa7d554.mjs';
6
6
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var nodeHTTPRequestHandler = require('../../nodeHTTPRequestHandler-ea18179c.js');
6
- require('../../resolveHTTPResponse-b12c934f.js');
5
+ var nodeHTTPRequestHandler = require('../../nodeHTTPRequestHandler-76f803a4.js');
6
+ require('../../resolveHTTPResponse-d7a8a210.js');
7
7
  require('../../TRPCError-fe9113e5.js');
8
8
  require('../../transformTRPCResponse-11ac69cc.js');
9
9
  require('../../codes-1c24d919.js');
@@ -1,5 +1,5 @@
1
- export { n as nodeHTTPRequestHandler } from '../../nodeHTTPRequestHandler-eba995e5.mjs';
2
- import '../../resolveHTTPResponse-87b3a1e6.mjs';
1
+ export { n as nodeHTTPRequestHandler } from '../../nodeHTTPRequestHandler-e9fceef4.mjs';
2
+ import '../../resolveHTTPResponse-1b339cff.mjs';
3
3
  import '../../TRPCError-281ac25a.mjs';
4
4
  import '../../transformTRPCResponse-c8138d5f.mjs';
5
5
  import '../../codes-aaa7d554.mjs';
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var http = require('http');
6
- var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-ea18179c.js');
7
- require('../resolveHTTPResponse-b12c934f.js');
6
+ var nodeHTTPRequestHandler = require('../nodeHTTPRequestHandler-76f803a4.js');
7
+ require('../resolveHTTPResponse-d7a8a210.js');
8
8
  require('../TRPCError-fe9113e5.js');
9
9
  require('../transformTRPCResponse-11ac69cc.js');
10
10
  require('../codes-1c24d919.js');
@@ -1,6 +1,6 @@
1
1
  import http from 'http';
2
- import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-eba995e5.mjs';
3
- import '../resolveHTTPResponse-87b3a1e6.mjs';
2
+ import { n as nodeHTTPRequestHandler } from '../nodeHTTPRequestHandler-e9fceef4.mjs';
3
+ import '../resolveHTTPResponse-1b339cff.mjs';
4
4
  import '../TRPCError-281ac25a.mjs';
5
5
  import '../transformTRPCResponse-c8138d5f.mjs';
6
6
  import '../codes-aaa7d554.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"resolveHTTPResponse.d.ts","sourceRoot":"","sources":["../../../../packages/server/src/http/resolveHTTPResponse.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EAET,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EACL,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAgC3B,UAAU,yBAAyB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,CAC5B,SAAQ,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC1B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CA2L3E"}
1
+ {"version":3,"file":"resolveHTTPResponse.d.ts","sourceRoot":"","sources":["../../../../packages/server/src/http/resolveHTTPResponse.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EAET,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EACL,sBAAsB,EAEtB,WAAW,EACX,YAAY,EACb,MAAM,mBAAmB,CAAC;AA+B3B,UAAU,yBAAyB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,CAC5B,SAAQ,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1D,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC1B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAiM3E"}
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHTTPResponse = require('./resolveHTTPResponse-b12c934f.js');
6
- var router = require('./router-36801fd1.js');
5
+ var resolveHTTPResponse = require('./resolveHTTPResponse-d7a8a210.js');
6
+ var router = require('./router-77321794.js');
7
7
  var TRPCError = require('./TRPCError-fe9113e5.js');
8
8
  require('./transformTRPCResponse-11ac69cc.js');
9
9
  require('./codes-1c24d919.js');
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- export { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-87b3a1e6.mjs';
2
- import { m as mergeWithoutOverrides, d as defaultFormatter, a as defaultTransformer, c as createRouterFactory, g as getDataTransformer, b as createBuilder } from './router-dfb17a79.mjs';
3
- export { e as callProcedure, a as defaultTransformer, g as getDataTransformer, p as procedureTypes, r as router } from './router-dfb17a79.mjs';
1
+ export { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-1b339cff.mjs';
2
+ import { m as mergeWithoutOverrides, d as defaultFormatter, a as defaultTransformer, c as createRouterFactory, g as getDataTransformer, b as createBuilder } from './router-f747db2b.mjs';
3
+ export { e as callProcedure, a as defaultTransformer, g as getDataTransformer, p as procedureTypes, r as router } from './router-f747db2b.mjs';
4
4
  export { T as TRPCError } from './TRPCError-281ac25a.mjs';
5
5
  import './transformTRPCResponse-c8138d5f.mjs';
6
6
  import './codes-aaa7d554.mjs';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var resolveHTTPResponse = require('./resolveHTTPResponse-b12c934f.js');
3
+ var resolveHTTPResponse = require('./resolveHTTPResponse-d7a8a210.js');
4
4
  var TRPCError = require('./TRPCError-fe9113e5.js');
5
5
 
6
6
  async function getPostBody({ req , maxBodySize }) {
@@ -1,4 +1,4 @@
1
- import { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-87b3a1e6.mjs';
1
+ import { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-1b339cff.mjs';
2
2
  import { T as TRPCError } from './TRPCError-281ac25a.mjs';
3
3
 
4
4
  async function getPostBody({ req , maxBodySize }) {
@@ -63,8 +63,7 @@ function getHTTPStatusCodeFromError(error) {
63
63
 
64
64
  const HTTP_METHOD_PROCEDURE_TYPE_MAP = {
65
65
  GET: 'query',
66
- POST: 'mutation',
67
- PATCH: 'subscription'
66
+ POST: 'mutation'
68
67
  };
69
68
  function getRawProcedureInputOrThrow(req) {
70
69
  try {
@@ -135,7 +134,13 @@ async function resolveHTTPResponse(opts) {
135
134
  if (isBatchCall && !batchingEnabled) {
136
135
  throw new Error(`Batching is not enabled on the server`);
137
136
  }
138
- if (type === 'unknown' || type === 'subscription') {
137
+ if (type === 'subscription') {
138
+ throw new TRPCError({
139
+ message: 'Subscriptions should use wsLink',
140
+ code: 'METHOD_NOT_SUPPORTED'
141
+ });
142
+ }
143
+ if (type === 'unknown') {
139
144
  throw new TRPCError({
140
145
  message: `Unexpected request method ${req.method}`,
141
146
  code: 'METHOD_NOT_SUPPORTED'
@@ -65,8 +65,7 @@ function getHTTPStatusCodeFromError(error) {
65
65
 
66
66
  const HTTP_METHOD_PROCEDURE_TYPE_MAP = {
67
67
  GET: 'query',
68
- POST: 'mutation',
69
- PATCH: 'subscription'
68
+ POST: 'mutation'
70
69
  };
71
70
  function getRawProcedureInputOrThrow(req) {
72
71
  try {
@@ -137,7 +136,13 @@ async function resolveHTTPResponse(opts) {
137
136
  if (isBatchCall && !batchingEnabled) {
138
137
  throw new Error(`Batching is not enabled on the server`);
139
138
  }
140
- if (type === 'unknown' || type === 'subscription') {
139
+ if (type === 'subscription') {
140
+ throw new TRPCError.TRPCError({
141
+ message: 'Subscriptions should use wsLink',
142
+ code: 'METHOD_NOT_SUPPORTED'
143
+ });
144
+ }
145
+ if (type === 'unknown') {
141
146
  throw new TRPCError.TRPCError({
142
147
  message: `Unexpected request method ${req.method}`,
143
148
  code: 'METHOD_NOT_SUPPORTED'
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var resolveHTTPResponse = require('./resolveHTTPResponse-b12c934f.js');
3
+ var resolveHTTPResponse = require('./resolveHTTPResponse-d7a8a210.js');
4
4
  var TRPCError = require('./TRPCError-fe9113e5.js');
5
5
  var codes = require('./codes-1c24d919.js');
6
6
  var index = require('./index-9d687d33.js');
@@ -1,4 +1,4 @@
1
- import { a as assertNotBrowser, g as getHTTPStatusCodeFromError } from './resolveHTTPResponse-87b3a1e6.mjs';
1
+ import { a as assertNotBrowser, g as getHTTPStatusCodeFromError } from './resolveHTTPResponse-1b339cff.mjs';
2
2
  import { T as TRPCError, a as getCauseFromUnknown, g as getTRPCErrorFromUnknown } from './TRPCError-281ac25a.mjs';
3
3
  import { T as TRPC_ERROR_CODES_BY_KEY } from './codes-aaa7d554.mjs';
4
4
  import { c as createProxy } from './index-47817162.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "10.0.0-proxy-alpha.57",
3
+ "version": "10.0.0-proxy-alpha.60",
4
4
  "description": "tRPC Server",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -136,5 +136,5 @@
136
136
  "yup": "^0.32.8",
137
137
  "zod": "^3.0.0"
138
138
  },
139
- "gitHead": "e664229c3ffcfb1d6bccb890cbddebf3630fdd45"
139
+ "gitHead": "59424cddb6ac66a0ffafb66bf9e98d3cbfec09cf"
140
140
  }
@@ -60,7 +60,7 @@ export interface RouterDef<
60
60
  transformer: CombinedDataTransformer;
61
61
  // FIXME this is slow:
62
62
  // - I think this has to go & be replaced by something by only using `TRecord` without `& SimpleFlatten...`
63
- // - Potentially, we have a `legacyProcedures` record where we only register the old things that are availble by string path
63
+ // - Potentially, we have a `legacyProcedures` record where we only register the old things that are available by string path
64
64
  procedures: TRecord;
65
65
  /**
66
66
  * V9 procedures
@@ -24,7 +24,6 @@ const HTTP_METHOD_PROCEDURE_TYPE_MAP: Record<
24
24
  > = {
25
25
  GET: 'query',
26
26
  POST: 'mutation',
27
- PATCH: 'subscription',
28
27
  };
29
28
  function getRawProcedureInputOrThrow(req: HTTPRequest) {
30
29
  try {
@@ -124,7 +123,13 @@ export async function resolveHTTPResponse<
124
123
  if (isBatchCall && !batchingEnabled) {
125
124
  throw new Error(`Batching is not enabled on the server`);
126
125
  }
127
- if (type === 'unknown' || type === 'subscription') {
126
+ if (type === 'subscription') {
127
+ throw new TRPCError({
128
+ message: 'Subscriptions should use wsLink',
129
+ code: 'METHOD_NOT_SUPPORTED',
130
+ });
131
+ }
132
+ if (type === 'unknown') {
128
133
  throw new TRPCError({
129
134
  message: `Unexpected request method ${req.method}`,
130
135
  code: 'METHOD_NOT_SUPPORTED',