@trpc/client 10.0.0-proxy-beta.5 → 10.0.0-proxy-beta.7

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 (37) hide show
  1. package/dist/{httpUtils-73a50af6.js → httpUtils-5f1164a9.js} +1 -1
  2. package/dist/{httpUtils-5b17f7da.mjs → httpUtils-d1885508.mjs} +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/dist/links/httpBatchLink.js +1 -1
  6. package/dist/links/httpBatchLink.mjs +1 -1
  7. package/dist/links/httpLink.js +1 -1
  8. package/dist/links/httpLink.mjs +1 -1
  9. package/dist/links/loggerLink.js +2 -2
  10. package/dist/links/loggerLink.mjs +2 -2
  11. package/package.json +5 -4
  12. package/src/links/dedupeLink.test.ts +2 -2
  13. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.d.ts +0 -1
  14. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.dev.js +0 -216
  15. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.js +0 -7
  16. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.cjs.prod.js +0 -216
  17. package/links/httpBatchLink/dist/trpc-client-links-httpBatchLink.esm.js +0 -212
  18. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.d.ts +0 -1
  19. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.dev.js +0 -67
  20. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.js +0 -7
  21. package/links/httpLink/dist/trpc-client-links-httpLink.cjs.prod.js +0 -67
  22. package/links/httpLink/dist/trpc-client-links-httpLink.esm.js +0 -63
  23. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.d.ts +0 -1
  24. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.dev.js +0 -89
  25. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.js +0 -7
  26. package/links/loggerLink/dist/trpc-client-links-loggerLink.cjs.prod.js +0 -89
  27. package/links/loggerLink/dist/trpc-client-links-loggerLink.esm.js +0 -85
  28. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.d.ts +0 -1
  29. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.dev.js +0 -19
  30. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.js +0 -7
  31. package/links/splitLink/dist/trpc-client-links-splitLink.cjs.prod.js +0 -19
  32. package/links/splitLink/dist/trpc-client-links-splitLink.esm.js +0 -15
  33. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.d.ts +0 -1
  34. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.dev.js +0 -397
  35. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.js +0 -7
  36. package/links/wsLink/dist/trpc-client-links-wsLink.cjs.prod.js +0 -397
  37. package/links/wsLink/dist/trpc-client-links-wsLink.esm.js +0 -392
@@ -7,7 +7,7 @@ function getWindow() {
7
7
  return globalThis;
8
8
  }
9
9
  function getAbortController(ac) {
10
- return (ac ?? getWindow().AbortController) ?? null;
10
+ return ac ?? getWindow().AbortController ?? null;
11
11
  }
12
12
 
13
13
  function getFetch(f) {
@@ -5,7 +5,7 @@ function getWindow() {
5
5
  return globalThis;
6
6
  }
7
7
  function getAbortController(ac) {
8
- return (ac ?? getWindow().AbortController) ?? null;
8
+ return ac ?? getWindow().AbortController ?? null;
9
9
  }
10
10
 
11
11
  function getFetch(f) {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var transformResult = require('./transformResult-e15ccdf6.js');
7
7
  var links_splitLink = require('./splitLink-695ae288.js');
8
8
  var links_httpBatchLink = require('./links/httpBatchLink.js');
9
9
  var shared = require('@trpc/server/shared');
10
- var httpUtils = require('./httpUtils-73a50af6.js');
10
+ var httpUtils = require('./httpUtils-5f1164a9.js');
11
11
  var links_httpLink = require('./links/httpLink.js');
12
12
  var links_loggerLink = require('./links/loggerLink.js');
13
13
  var links_wsLink = require('./links/wsLink.js');
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ export { s as splitLink } from './splitLink-ad44a55d.mjs';
6
6
  import { httpBatchLink } from './links/httpBatchLink.mjs';
7
7
  export { httpBatchLink } from './links/httpBatchLink.mjs';
8
8
  import { createProxy } from '@trpc/server/shared';
9
- export { g as getFetch } from './httpUtils-5b17f7da.mjs';
9
+ export { g as getFetch } from './httpUtils-d1885508.mjs';
10
10
  export { httpLink } from './links/httpLink.mjs';
11
11
  export { loggerLink } from './links/loggerLink.mjs';
12
12
  export { createWSClient, wsLink } from './links/wsLink.mjs';
@@ -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-73a50af6.js');
7
+ var httpUtils = require('../httpUtils-5f1164a9.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 { r as resolveHTTPLinkOptions, a as getUrl, h as httpRequest } from '../httpUtils-5b17f7da.mjs';
3
+ import { r as resolveHTTPLinkOptions, a as getUrl, h as httpRequest } from '../httpUtils-d1885508.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-73a50af6.js');
7
+ var httpUtils = require('../httpUtils-5f1164a9.js');
8
8
 
9
9
  function httpLink(opts) {
10
10
  const resolvedOpts = httpUtils.resolveHTTPLinkOptions(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 { r as resolveHTTPLinkOptions, h as httpRequest } from '../httpUtils-5b17f7da.mjs';
3
+ import { r as resolveHTTPLinkOptions, h as httpRequest } from '../httpUtils-d1885508.mjs';
4
4
 
5
5
  function httpLink(opts) {
6
6
  const resolvedOpts = resolveHTTPLinkOptions(opts);
@@ -33,12 +33,12 @@ const defaultLogger = (c = console)=>(props)=>{
33
33
  type,
34
34
  `#${id}`,
35
35
  `%c${path}%c`,
36
- '%O',
36
+ '%O'
37
37
  ];
38
38
  const args = [
39
39
  css,
40
40
  `${css}; font-weight: bold;`,
41
- `${css}; font-weight: normal;`,
41
+ `${css}; font-weight: normal;`
42
42
  ];
43
43
  if (props.direction === 'up') {
44
44
  args.push({
@@ -29,12 +29,12 @@ const defaultLogger = (c = console)=>(props)=>{
29
29
  type,
30
30
  `#${id}`,
31
31
  `%c${path}%c`,
32
- '%O',
32
+ '%O'
33
33
  ];
34
34
  const args = [
35
35
  css,
36
36
  `${css}; font-weight: bold;`,
37
- `${css}; font-weight: normal;`,
37
+ `${css}; font-weight: normal;`
38
38
  ];
39
39
  if (props.direction === 'up') {
40
40
  args.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "10.0.0-proxy-beta.5",
3
+ "version": "10.0.0-proxy-beta.7",
4
4
  "description": "tRPC Client lib",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -63,13 +63,14 @@
63
63
  "ts-watch": "tsc --project tsconfig.watch.json"
64
64
  },
65
65
  "peerDependencies": {
66
- "@trpc/server": "10.0.0-proxy-beta.5"
66
+ "@trpc/server": "10.0.0-proxy-beta.7"
67
67
  },
68
68
  "devDependencies": {
69
- "@trpc/server": "10.0.0-proxy-beta.5"
69
+ "@trpc/server": "10.0.0-proxy-beta.7",
70
+ "@types/node": "^18.7.20"
70
71
  },
71
72
  "publishConfig": {
72
73
  "access": "public"
73
74
  },
74
- "gitHead": "54b1938bdca755d2d8ff6e79712ba57d3e29edab"
75
+ "gitHead": "5e39af089a59fe695a38662cac7775b01c65a16e"
75
76
  }
@@ -1,7 +1,7 @@
1
1
  import { waitFor } from '@testing-library/dom';
2
- import { AnyRouter } from '@trpc/server';
3
- import { observable } from '@trpc/server/observable';
4
2
  import { OperationLink } from '..';
3
+ import { AnyRouter } from '../../../server/src';
4
+ import { observable } from '../../../server/src/observable';
5
5
  import { dedupeLink } from './dedupeLink';
6
6
  import { createChain } from './internals/createChain';
7
7
 
@@ -1 +0,0 @@
1
- export * from "../../../dist/declarations/src/links/httpBatchLink";
@@ -1,216 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var TRPCClientError = require('../../../dist/TRPCClientError-bfee2bf5.cjs.dev.js');
6
- var httpRequest = require('../../../dist/httpRequest-6b1f0c6f.cjs.dev.js');
7
- var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
8
- require('@babel/runtime/helpers/objectSpread2');
9
- require('@babel/runtime/helpers/classCallCheck');
10
- require('@babel/runtime/helpers/createClass');
11
- require('@babel/runtime/helpers/assertThisInitialized');
12
- require('@babel/runtime/helpers/inherits');
13
- require('@babel/runtime/helpers/createSuper');
14
- require('@babel/runtime/helpers/wrapNativeSuper');
15
-
16
- /**
17
- * Dataloader that's very inspired by https://github.com/graphql/dataloader
18
- * Less configuration, no caching, and allows you to cancel requests
19
- * When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
20
- */
21
- function dataLoader(fetchMany, opts) {
22
- var batch = null;
23
- var dispatchTimer = null;
24
-
25
- var destroyTimerAndBatch = function destroyTimerAndBatch() {
26
- clearTimeout(dispatchTimer);
27
- dispatchTimer = null;
28
- batch = null;
29
- };
30
-
31
- function dispatch() {
32
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
- var batchCopy = batch;
34
- destroyTimerAndBatch();
35
-
36
- var _fetchMany = fetchMany(batchCopy.items.map(function (v) {
37
- return v.key;
38
- })),
39
- promise = _fetchMany.promise,
40
- cancel = _fetchMany.cancel;
41
-
42
- batchCopy.cancel = cancel;
43
- promise.then(function (result) {
44
- for (var i = 0; i < result.length; i++) {
45
- var _value = result[i];
46
- batchCopy.items[i].resolve(_value);
47
- }
48
- }).catch(function (cause) {
49
- var _iterator = _createForOfIteratorHelper(batchCopy.items),
50
- _step;
51
-
52
- try {
53
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
54
- var item = _step.value;
55
- item.reject(cause);
56
- }
57
- } catch (err) {
58
- _iterator.e(err);
59
- } finally {
60
- _iterator.f();
61
- }
62
- });
63
- }
64
-
65
- function load(key) {
66
- var batchItem = {
67
- cancelled: false,
68
- key: key
69
- };
70
-
71
- if (!batch) {
72
- batch = {
73
- items: [],
74
- cancel: function cancel() {
75
- destroyTimerAndBatch();
76
- }
77
- };
78
- }
79
-
80
- var thisBatch = batch;
81
- var dispatchImmediately = false;
82
- var promise = new Promise(function (resolve, reject) {
83
- var item = batchItem;
84
- item.reject = reject;
85
- item.resolve = resolve;
86
- thisBatch.items.push(item);
87
-
88
- if (typeof (opts === null || opts === void 0 ? void 0 : opts.maxBatchSize) !== 'undefined' && thisBatch.items.length >= opts.maxBatchSize) {
89
- dispatchImmediately = true;
90
- }
91
- });
92
-
93
- var cancel = function cancel() {
94
- batchItem.cancelled = true;
95
-
96
- if (thisBatch.items.some(function (item) {
97
- return !item.cancelled;
98
- })) {
99
- // there are still things that can be resolved
100
- return;
101
- }
102
-
103
- thisBatch.cancel();
104
- };
105
-
106
- if (dispatchImmediately) {
107
- dispatch();
108
- } else if (!dispatchTimer) {
109
- dispatchTimer = setTimeout(dispatch);
110
- }
111
-
112
- return {
113
- promise: promise,
114
- cancel: cancel
115
- };
116
- }
117
-
118
- return {
119
- load: load
120
- };
121
- }
122
-
123
- function httpBatchLink(opts) {
124
- var url = opts.url,
125
- maxBatchSize = opts.maxBatchSize; // initialized config
126
-
127
- return function (runtime) {
128
- // initialized in app
129
- var fetcher = function fetcher(type) {
130
- return function (keyInputPairs) {
131
- var path = keyInputPairs.map(function (op) {
132
- return op.path;
133
- }).join(',');
134
- var inputs = keyInputPairs.map(function (op) {
135
- return op.input;
136
- });
137
-
138
- var _httpRequest = httpRequest.httpRequest({
139
- url: url,
140
- inputs: inputs,
141
- path: path,
142
- runtime: runtime,
143
- type: type
144
- }),
145
- promise = _httpRequest.promise,
146
- cancel = _httpRequest.cancel;
147
-
148
- return {
149
- promise: promise.then(function (res) {
150
- if (!Array.isArray(res)) {
151
- return keyInputPairs.map(function () {
152
- return res;
153
- });
154
- }
155
-
156
- return res;
157
- }),
158
- cancel: cancel
159
- };
160
- };
161
- };
162
-
163
- var query = dataLoader(fetcher('query'), {
164
- maxBatchSize: maxBatchSize
165
- });
166
- var mutation = dataLoader(fetcher('mutation'), {
167
- maxBatchSize: maxBatchSize
168
- });
169
- var subscription = dataLoader(fetcher('subscription'), {
170
- maxBatchSize: maxBatchSize
171
- });
172
- var loaders = {
173
- query: query,
174
- subscription: subscription,
175
- mutation: mutation
176
- };
177
- return function (_ref) {
178
- var op = _ref.op,
179
- prev = _ref.prev,
180
- onDestroy = _ref.onDestroy;
181
- var loader = loaders[op.type];
182
-
183
- var _loader$load = loader.load(op),
184
- promise = _loader$load.promise,
185
- cancel = _loader$load.cancel;
186
-
187
- var isDone = false;
188
-
189
- var prevOnce = function prevOnce(result) {
190
- if (isDone) {
191
- return;
192
- }
193
-
194
- isDone = true;
195
- prev(result);
196
- };
197
-
198
- onDestroy(function () {
199
- prevOnce(TRPCClientError.TRPCClientError.from(new httpRequest.TRPCAbortError(), {
200
- isDone: true
201
- }));
202
- cancel();
203
- });
204
- promise.then(function (envelope) {
205
- prevOnce(httpRequest.transformRPCResponse({
206
- envelope: envelope,
207
- runtime: runtime
208
- }));
209
- }).catch(function (cause) {
210
- prevOnce(TRPCClientError.TRPCClientError.from(cause));
211
- });
212
- };
213
- };
214
- }
215
-
216
- exports.httpBatchLink = httpBatchLink;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-client-links-httpBatchLink.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-client-links-httpBatchLink.cjs.dev.js");
7
- }
@@ -1,216 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var TRPCClientError = require('../../../dist/TRPCClientError-e9bf96e9.cjs.prod.js');
6
- var httpRequest = require('../../../dist/httpRequest-66400297.cjs.prod.js');
7
- var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
8
- require('@babel/runtime/helpers/objectSpread2');
9
- require('@babel/runtime/helpers/classCallCheck');
10
- require('@babel/runtime/helpers/createClass');
11
- require('@babel/runtime/helpers/assertThisInitialized');
12
- require('@babel/runtime/helpers/inherits');
13
- require('@babel/runtime/helpers/createSuper');
14
- require('@babel/runtime/helpers/wrapNativeSuper');
15
-
16
- /**
17
- * Dataloader that's very inspired by https://github.com/graphql/dataloader
18
- * Less configuration, no caching, and allows you to cancel requests
19
- * When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled
20
- */
21
- function dataLoader(fetchMany, opts) {
22
- var batch = null;
23
- var dispatchTimer = null;
24
-
25
- var destroyTimerAndBatch = function destroyTimerAndBatch() {
26
- clearTimeout(dispatchTimer);
27
- dispatchTimer = null;
28
- batch = null;
29
- };
30
-
31
- function dispatch() {
32
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
- var batchCopy = batch;
34
- destroyTimerAndBatch();
35
-
36
- var _fetchMany = fetchMany(batchCopy.items.map(function (v) {
37
- return v.key;
38
- })),
39
- promise = _fetchMany.promise,
40
- cancel = _fetchMany.cancel;
41
-
42
- batchCopy.cancel = cancel;
43
- promise.then(function (result) {
44
- for (var i = 0; i < result.length; i++) {
45
- var _value = result[i];
46
- batchCopy.items[i].resolve(_value);
47
- }
48
- }).catch(function (cause) {
49
- var _iterator = _createForOfIteratorHelper(batchCopy.items),
50
- _step;
51
-
52
- try {
53
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
54
- var item = _step.value;
55
- item.reject(cause);
56
- }
57
- } catch (err) {
58
- _iterator.e(err);
59
- } finally {
60
- _iterator.f();
61
- }
62
- });
63
- }
64
-
65
- function load(key) {
66
- var batchItem = {
67
- cancelled: false,
68
- key: key
69
- };
70
-
71
- if (!batch) {
72
- batch = {
73
- items: [],
74
- cancel: function cancel() {
75
- destroyTimerAndBatch();
76
- }
77
- };
78
- }
79
-
80
- var thisBatch = batch;
81
- var dispatchImmediately = false;
82
- var promise = new Promise(function (resolve, reject) {
83
- var item = batchItem;
84
- item.reject = reject;
85
- item.resolve = resolve;
86
- thisBatch.items.push(item);
87
-
88
- if (typeof (opts === null || opts === void 0 ? void 0 : opts.maxBatchSize) !== 'undefined' && thisBatch.items.length >= opts.maxBatchSize) {
89
- dispatchImmediately = true;
90
- }
91
- });
92
-
93
- var cancel = function cancel() {
94
- batchItem.cancelled = true;
95
-
96
- if (thisBatch.items.some(function (item) {
97
- return !item.cancelled;
98
- })) {
99
- // there are still things that can be resolved
100
- return;
101
- }
102
-
103
- thisBatch.cancel();
104
- };
105
-
106
- if (dispatchImmediately) {
107
- dispatch();
108
- } else if (!dispatchTimer) {
109
- dispatchTimer = setTimeout(dispatch);
110
- }
111
-
112
- return {
113
- promise: promise,
114
- cancel: cancel
115
- };
116
- }
117
-
118
- return {
119
- load: load
120
- };
121
- }
122
-
123
- function httpBatchLink(opts) {
124
- var url = opts.url,
125
- maxBatchSize = opts.maxBatchSize; // initialized config
126
-
127
- return function (runtime) {
128
- // initialized in app
129
- var fetcher = function fetcher(type) {
130
- return function (keyInputPairs) {
131
- var path = keyInputPairs.map(function (op) {
132
- return op.path;
133
- }).join(',');
134
- var inputs = keyInputPairs.map(function (op) {
135
- return op.input;
136
- });
137
-
138
- var _httpRequest = httpRequest.httpRequest({
139
- url: url,
140
- inputs: inputs,
141
- path: path,
142
- runtime: runtime,
143
- type: type
144
- }),
145
- promise = _httpRequest.promise,
146
- cancel = _httpRequest.cancel;
147
-
148
- return {
149
- promise: promise.then(function (res) {
150
- if (!Array.isArray(res)) {
151
- return keyInputPairs.map(function () {
152
- return res;
153
- });
154
- }
155
-
156
- return res;
157
- }),
158
- cancel: cancel
159
- };
160
- };
161
- };
162
-
163
- var query = dataLoader(fetcher('query'), {
164
- maxBatchSize: maxBatchSize
165
- });
166
- var mutation = dataLoader(fetcher('mutation'), {
167
- maxBatchSize: maxBatchSize
168
- });
169
- var subscription = dataLoader(fetcher('subscription'), {
170
- maxBatchSize: maxBatchSize
171
- });
172
- var loaders = {
173
- query: query,
174
- subscription: subscription,
175
- mutation: mutation
176
- };
177
- return function (_ref) {
178
- var op = _ref.op,
179
- prev = _ref.prev,
180
- onDestroy = _ref.onDestroy;
181
- var loader = loaders[op.type];
182
-
183
- var _loader$load = loader.load(op),
184
- promise = _loader$load.promise,
185
- cancel = _loader$load.cancel;
186
-
187
- var isDone = false;
188
-
189
- var prevOnce = function prevOnce(result) {
190
- if (isDone) {
191
- return;
192
- }
193
-
194
- isDone = true;
195
- prev(result);
196
- };
197
-
198
- onDestroy(function () {
199
- prevOnce(TRPCClientError.TRPCClientError.from(new httpRequest.TRPCAbortError(), {
200
- isDone: true
201
- }));
202
- cancel();
203
- });
204
- promise.then(function (envelope) {
205
- prevOnce(httpRequest.transformRPCResponse({
206
- envelope: envelope,
207
- runtime: runtime
208
- }));
209
- }).catch(function (cause) {
210
- prevOnce(TRPCClientError.TRPCClientError.from(cause));
211
- });
212
- };
213
- };
214
- }
215
-
216
- exports.httpBatchLink = httpBatchLink;