@trpc/client 10.27.3 → 10.28.1
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/dist/TRPCClientError.d.ts +25 -25
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/createTRPCClient.d.ts +19 -19
- package/dist/createTRPCClientProxy.d.ts +38 -38
- package/dist/createTRPCClientProxy.d.ts.map +1 -1
- package/dist/createTRPCUntypedClient.d.ts +4 -4
- package/dist/getFetch.d.ts +2 -2
- package/dist/{httpUtils-1a07b2e6.js → httpUtils-00c8b54e.js} +125 -125
- package/dist/index.d.ts +6 -6
- package/dist/internals/TRPCUntypedClient.d.ts +61 -61
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/internals/dataLoader.d.ts +17 -17
- package/dist/internals/dataLoader.d.ts.map +1 -1
- package/dist/internals/getAbortController.d.ts +3 -3
- package/dist/internals/retryDelay.d.ts +1 -1
- package/dist/internals/types.d.ts +75 -102
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/links/dedupeLink.d.ts +3 -3
- package/dist/links/httpBatchLink.d.ts +15 -15
- package/dist/links/httpFormDataLink.d.ts +1 -1
- package/dist/links/httpLink.d.ts +16 -16
- package/dist/links/index.d.ts +7 -7
- package/dist/links/internals/createChain.d.ts +7 -7
- package/dist/links/internals/httpUtils.d.ts +59 -59
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/isObject.d.ts +1 -1
- package/dist/links/loggerLink.d.ts +39 -39
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/retryLink.d.ts +5 -5
- package/dist/links/splitLink.d.ts +13 -13
- package/dist/links/types.d.ts +69 -69
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink.d.ts +28 -28
- package/dist/links/wsLink.d.ts.map +1 -1
- package/dist/links/wsLink.js +9 -17
- package/dist/links/wsLink.mjs +9 -17
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/transformResult.d.ts +33 -33
- package/dist/{splitLink-aebd28df.js → splitLink-0df96fdc.js} +34 -34
- package/dist/{transformResult-fc4863b8.js → transformResult-ae8e970c.js} +80 -80
- package/package.json +11 -7
- package/src/internals/types.ts +0 -39
- package/src/links/wsLink.ts +10 -24
- package/src/internals/types.test.ts +0 -66
- package/src/links/dedupeLink.test.ts +0 -128
- package/src/links/internals/createChain.test.ts +0 -117
- package/src/links/splitLink.test.ts +0 -55
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { observable } from '@trpc/server/observable';
|
|
2
|
-
import { splitLink } from '../';
|
|
3
|
-
import { OperationLink, TRPCLink } from '../';
|
|
4
|
-
import { AnyRouter } from '../../../server/src';
|
|
5
|
-
import { createChain } from '../links/internals/createChain';
|
|
6
|
-
|
|
7
|
-
test('splitLink', () => {
|
|
8
|
-
const wsLinkSpy = vi.fn();
|
|
9
|
-
const wsLink: TRPCLink<any> = () => () =>
|
|
10
|
-
observable(() => {
|
|
11
|
-
wsLinkSpy();
|
|
12
|
-
});
|
|
13
|
-
const httpLinkSpy = vi.fn();
|
|
14
|
-
const httpLink: TRPCLink<any> = () => () =>
|
|
15
|
-
observable(() => {
|
|
16
|
-
httpLinkSpy();
|
|
17
|
-
});
|
|
18
|
-
const links: OperationLink<AnyRouter, any, any>[] = [
|
|
19
|
-
// "dedupe link"
|
|
20
|
-
splitLink({
|
|
21
|
-
condition(op) {
|
|
22
|
-
return op.type === 'subscription';
|
|
23
|
-
},
|
|
24
|
-
true: wsLink,
|
|
25
|
-
false: [httpLink],
|
|
26
|
-
})(null as any),
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
createChain({
|
|
30
|
-
links,
|
|
31
|
-
op: {
|
|
32
|
-
type: 'query',
|
|
33
|
-
input: null,
|
|
34
|
-
path: '.',
|
|
35
|
-
id: 0,
|
|
36
|
-
context: {},
|
|
37
|
-
},
|
|
38
|
-
}).subscribe({});
|
|
39
|
-
expect(httpLinkSpy).toHaveBeenCalledTimes(1);
|
|
40
|
-
expect(wsLinkSpy).toHaveBeenCalledTimes(0);
|
|
41
|
-
vi.resetAllMocks();
|
|
42
|
-
|
|
43
|
-
createChain({
|
|
44
|
-
links,
|
|
45
|
-
op: {
|
|
46
|
-
type: 'subscription',
|
|
47
|
-
input: null,
|
|
48
|
-
path: '.',
|
|
49
|
-
id: 0,
|
|
50
|
-
context: {},
|
|
51
|
-
},
|
|
52
|
-
}).subscribe({});
|
|
53
|
-
expect(httpLinkSpy).toHaveBeenCalledTimes(0);
|
|
54
|
-
expect(wsLinkSpy).toHaveBeenCalledTimes(1);
|
|
55
|
-
});
|