@trpc/client 10.0.0-proxy-alpha.58 → 10.0.0-proxy-alpha.61

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
@@ -22,13 +22,13 @@ Full documentation for `@trpc/client` can be found [here](https://trpc.io/docs/v
22
22
 
23
23
  ```bash
24
24
  # npm
25
- npm install @trpc/client
25
+ npm install @trpc/client@next
26
26
 
27
27
  # Yarn
28
- yarn add @trpc/client
28
+ yarn add @trpc/client@next
29
29
 
30
30
  # pnpm
31
- pnpm add @trpc/client
31
+ pnpm add @trpc/client@next
32
32
  ```
33
33
 
34
34
  ## Basic Example
@@ -1 +1 @@
1
- {"version":3,"file":"createTRPCClientProxy.d.ts","sourceRoot":"","sources":["../src/createTRPCClientProxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,aAAa,EACb,qBAAqB,EAErB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAoB,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACL,UAAU,IAAI,MAAM,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,oBAAY,sBAAsB,CAAC,OAAO,SAAS,SAAS,IAC1D,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AAE/D,aAAK,QAAQ,CAAC,UAAU,SAAS,SAAS,CAAC,GAAG,CAAC,IAAI,CACjD,GAAG,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KACvC,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;AAE/C,aAAK,oBAAoB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CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EACnC,WAAW,CAAC,IAAI,CAAC,CAClB,GACD,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,GAC/D,KAAK,GACL,iBAAiB,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC;CACnE,CAAC,CAAC;AAWH;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,mCAWxB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC,mCAKvC"}
@@ -11,8 +11,7 @@ function arrayToDict(array) {
11
11
  }
12
12
  const METHOD = {
13
13
  query: 'GET',
14
- mutation: 'POST',
15
- subscription: 'PATCH'
14
+ mutation: 'POST'
16
15
  };
17
16
  function getInput(opts) {
18
17
  return 'input' in opts ? opts.runtime.transformer.serialize(opts.input) : arrayToDict(opts.inputs.map((_input)=>opts.runtime.transformer.serialize(_input)));
@@ -48,7 +47,11 @@ function httpRequest(opts) {
48
47
  const url = getUrl(opts);
49
48
  const body = getBody(opts);
50
49
  const meta = {};
51
- Promise.resolve(runtime.headers()).then((headers)=>runtime.fetch(url, {
50
+ Promise.resolve(runtime.headers()).then((headers)=>{
51
+ if (type === 'subscription') {
52
+ throw new Error('Subscriptions should use wsLink');
53
+ }
54
+ return runtime.fetch(url, {
52
55
  method: METHOD[type],
53
56
  signal: ac?.signal,
54
57
  body: body,
@@ -56,7 +59,8 @@ function httpRequest(opts) {
56
59
  'content-type': 'application/json',
57
60
  ...headers
58
61
  }
59
- })).then((_res)=>{
62
+ });
63
+ }).then((_res)=>{
60
64
  meta.response = _res;
61
65
  return _res.json();
62
66
  }).then((json)=>{
@@ -9,8 +9,7 @@ function arrayToDict(array) {
9
9
  }
10
10
  const METHOD = {
11
11
  query: 'GET',
12
- mutation: 'POST',
13
- subscription: 'PATCH'
12
+ mutation: 'POST'
14
13
  };
15
14
  function getInput(opts) {
16
15
  return 'input' in opts ? opts.runtime.transformer.serialize(opts.input) : arrayToDict(opts.inputs.map((_input)=>opts.runtime.transformer.serialize(_input)));
@@ -46,7 +45,11 @@ function httpRequest(opts) {
46
45
  const url = getUrl(opts);
47
46
  const body = getBody(opts);
48
47
  const meta = {};
49
- Promise.resolve(runtime.headers()).then((headers)=>runtime.fetch(url, {
48
+ Promise.resolve(runtime.headers()).then((headers)=>{
49
+ if (type === 'subscription') {
50
+ throw new Error('Subscriptions should use wsLink');
51
+ }
52
+ return runtime.fetch(url, {
50
53
  method: METHOD[type],
51
54
  signal: ac?.signal,
52
55
  body: body,
@@ -54,7 +57,8 @@ function httpRequest(opts) {
54
57
  'content-type': 'application/json',
55
58
  ...headers
56
59
  }
57
- })).then((_res)=>{
60
+ });
61
+ }).then((_res)=>{
58
62
  meta.response = _res;
59
63
  return _res.json();
60
64
  }).then((json)=>{
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ var shared = require('@trpc/server/shared');
10
10
  var links_httpLink = require('./links/httpLink.js');
11
11
  var links_loggerLink = require('./links/loggerLink.js');
12
12
  var links_wsLink = require('./links/wsLink.js');
13
- require('./httpUtils-801112a6.js');
13
+ require('./httpUtils-0961d5e3.js');
14
14
 
15
15
  function getWindow() {
16
16
  if (typeof window !== 'undefined') {
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import { createProxy } from '@trpc/server/shared';
9
9
  export { httpLink } from './links/httpLink.mjs';
10
10
  export { loggerLink } from './links/loggerLink.mjs';
11
11
  export { createWSClient, wsLink } from './links/wsLink.mjs';
12
- import './httpUtils-44781613.mjs';
12
+ import './httpUtils-ad4258b6.mjs';
13
13
 
14
14
  function getWindow() {
15
15
  if (typeof window !== 'undefined') {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
6
  var transformResult = require('../transformResult-e15ccdf6.js');
7
- var httpUtils = require('../httpUtils-801112a6.js');
7
+ var httpUtils = require('../httpUtils-0961d5e3.js');
8
8
 
9
9
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
10
10
  * A function that should never be called unless we messed something up.
@@ -1,6 +1,6 @@
1
1
  import { observable } from '@trpc/server/observable';
2
2
  import { t as transformResult, T as TRPCClientError } from '../transformResult-106791d7.mjs';
3
- import { g as getUrl, h as httpRequest } from '../httpUtils-44781613.mjs';
3
+ import { g as getUrl, h as httpRequest } from '../httpUtils-ad4258b6.mjs';
4
4
 
5
5
  /* eslint-disable @typescript-eslint/no-non-null-assertion */ /**
6
6
  * A function that should never be called unless we messed something up.
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var observable = require('@trpc/server/observable');
6
6
  var transformResult = require('../transformResult-e15ccdf6.js');
7
- var httpUtils = require('../httpUtils-801112a6.js');
7
+ var httpUtils = require('../httpUtils-0961d5e3.js');
8
8
 
9
9
  function httpLink(opts) {
10
10
  const { url } = opts;
@@ -1,6 +1,6 @@
1
1
  import { observable } from '@trpc/server/observable';
2
2
  import { t as transformResult, T as TRPCClientError } from '../transformResult-106791d7.mjs';
3
- import { h as httpRequest } from '../httpUtils-44781613.mjs';
3
+ import { h as httpRequest } from '../httpUtils-ad4258b6.mjs';
4
4
 
5
5
  function httpLink(opts) {
6
6
  const { url } = opts;
@@ -1 +1 @@
1
- {"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../../../../packages/client/src/links/internals/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE/D,MAAM,WAAW,eAAe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5B,GAAG,CAAC;IAAE,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAUjD,oBAAY,kBAAkB,GAAG,eAAe,GAC9C,eAAe,GAAG;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEJ,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,UAgB9C;AAED,aAAK,cAAc,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GAAG,eAAe,CAAC;AAEhE,wBAAgB,OAAO,CAAC,IAAI,EAAE,cAAc,sBAM3C;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,kBAAkB,GACvB,gBAAgB,CAAC,UAAU,CAAC,CAwC9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "10.0.0-proxy-alpha.58",
3
+ "version": "10.0.0-proxy-alpha.61",
4
4
  "description": "tRPC Client lib",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -63,13 +63,13 @@
63
63
  "ts-watch": "tsc --project tsconfig.watch.json"
64
64
  },
65
65
  "peerDependencies": {
66
- "@trpc/server": "10.0.0-proxy-alpha.58"
66
+ "@trpc/server": "10.0.0-proxy-alpha.61"
67
67
  },
68
68
  "devDependencies": {
69
- "@trpc/server": "10.0.0-proxy-alpha.58"
69
+ "@trpc/server": "10.0.0-proxy-alpha.61"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "2024f3e073f2ec3002f34d47d7f19df89ca2f478"
74
+ "gitHead": "2cfc6617c7ed6532a1870391824def1a4e8130ba"
75
75
  }
@@ -14,7 +14,6 @@ import type {
14
14
  Unsubscribable,
15
15
  inferObservableValue,
16
16
  } from '@trpc/server/observable';
17
- import type { TRPCResultMessage } from '@trpc/server/rpc';
18
17
  import { createProxy } from '@trpc/server/shared';
19
18
  import { TRPCClientError } from './TRPCClientError';
20
19
  import { CreateTRPCClientOptions, createTRPCClient } from './createTRPCClient';
@@ -19,7 +19,6 @@ function arrayToDict(array: unknown[]) {
19
19
  const METHOD = {
20
20
  query: 'GET',
21
21
  mutation: 'POST',
22
- subscription: 'PATCH',
23
22
  } as const;
24
23
 
25
24
  export interface HTTPResult {
@@ -87,8 +86,11 @@ export function httpRequest(
87
86
 
88
87
  const meta = {} as HTTPResult['meta'];
89
88
  Promise.resolve(runtime.headers())
90
- .then((headers) =>
91
- runtime.fetch(url, {
89
+ .then((headers) => {
90
+ if (type === 'subscription') {
91
+ throw new Error('Subscriptions should use wsLink');
92
+ }
93
+ return runtime.fetch(url, {
92
94
  method: METHOD[type],
93
95
  signal: ac?.signal,
94
96
  body: body,
@@ -96,8 +98,8 @@ export function httpRequest(
96
98
  'content-type': 'application/json',
97
99
  ...headers,
98
100
  },
99
- }),
100
- )
101
+ });
102
+ })
101
103
  .then((_res) => {
102
104
  meta.response = _res;
103
105
  return _res.json();