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

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.
@@ -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;IAC9B,GAAG,EAAE,MAAM,CAAC;CACb;AAkBD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE;QACJ,QAAQ,EAAE,QAAQ,CAAC;KACpB,CAAC;CACH;AAED,aAAK,eAAe,GAAG;IACrB,OAAO,EAAE,iBAAiB,CAAC;CAC5B,GAAG,CAAC;IAAE,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAUjD,oBAAY,kBAAkB,GAAG,e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Ae,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.59",
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.59"
67
67
  },
68
68
  "devDependencies": {
69
- "@trpc/server": "10.0.0-proxy-alpha.58"
69
+ "@trpc/server": "10.0.0-proxy-alpha.59"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "2024f3e073f2ec3002f34d47d7f19df89ca2f478"
74
+ "gitHead": "45d04747c5f1205b9e0037f888d9fefddea97768"
75
75
  }
@@ -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();