@trpc/client 10.0.0-proxy-beta.14 → 10.0.0-proxy-beta.16
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 +1 -1
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/index.js +0 -101
- package/dist/index.mjs +2 -101
- package/dist/links/index.d.ts +0 -2
- package/dist/links/index.d.ts.map +1 -1
- package/dist/links/loggerLink.d.ts +5 -5
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/TRPCClientError.ts +1 -1
- package/src/links/index.ts +4 -2
- package/src/links/loggerLink.ts +11 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyProcedure, AnyRouter, DefaultErrorShape, Maybe, inferRouterError } from '@trpc/server';
|
|
2
2
|
import { TRPCErrorResponse } from '@trpc/server/rpc';
|
|
3
3
|
declare type RouterOrProcedure = AnyRouter | AnyProcedure;
|
|
4
|
-
declare type inferErrorShape<TRouterOrProcedure extends RouterOrProcedure> = TRouterOrProcedure extends AnyRouter ? inferRouterError<TRouterOrProcedure> : TRouterOrProcedure['_def']['_config']['errorShape'];
|
|
4
|
+
declare type inferErrorShape<TRouterOrProcedure extends RouterOrProcedure> = TRouterOrProcedure extends AnyRouter ? inferRouterError<TRouterOrProcedure> : TRouterOrProcedure['_def']['_config']['$types']['errorShape'];
|
|
5
5
|
export interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
|
6
6
|
readonly message: string;
|
|
7
7
|
readonly shape: Maybe<TShape>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCClientError.d.ts","sourceRoot":"","sources":["../src/TRPCClientError.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAA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oBAAC;IACtB,SAAgB,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAClE,SAAgB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,SAAgB,IAAI,sCAAC;gBAGnB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpD,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC;WAkBW,IAAI,CAAC,kBAAkB,SAAS,iBAAiB,EAC7D,KAAK,EAAE,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,EACrC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAO,GAC5C,eAAe,CAAC,kBAAkB,CAAC;CAqBvC"}
|
package/dist/index.js
CHANGED
|
@@ -103,105 +103,6 @@ class TRPCClient {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
function dedupeLink() {
|
|
107
|
-
// initialized config
|
|
108
|
-
return ()=>{
|
|
109
|
-
// initialized in app
|
|
110
|
-
const pending = {};
|
|
111
|
-
return ({ op , next })=>{
|
|
112
|
-
// initialized for request
|
|
113
|
-
if (op.type !== 'query') {
|
|
114
|
-
// pass through
|
|
115
|
-
return next(op);
|
|
116
|
-
}
|
|
117
|
-
const key = JSON.stringify([
|
|
118
|
-
op.path,
|
|
119
|
-
op.input
|
|
120
|
-
]);
|
|
121
|
-
const obs$ = pending[key];
|
|
122
|
-
if (obs$) {
|
|
123
|
-
// console.log('hooking into pending', { op });
|
|
124
|
-
return observable.observable((observer)=>obs$.subscribe(observer));
|
|
125
|
-
}
|
|
126
|
-
const shared$ = observable.observable((observer)=>{
|
|
127
|
-
function reset() {
|
|
128
|
-
delete pending[key];
|
|
129
|
-
}
|
|
130
|
-
const subscription = next(op).subscribe({
|
|
131
|
-
next (v) {
|
|
132
|
-
observer.next(v);
|
|
133
|
-
},
|
|
134
|
-
error (e) {
|
|
135
|
-
reset();
|
|
136
|
-
observer.error(e);
|
|
137
|
-
},
|
|
138
|
-
complete () {
|
|
139
|
-
reset();
|
|
140
|
-
observer.complete();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
return ()=>{
|
|
144
|
-
reset();
|
|
145
|
-
subscription.unsubscribe();
|
|
146
|
-
};
|
|
147
|
-
}).pipe(observable.share());
|
|
148
|
-
pending[key] = shared$;
|
|
149
|
-
return shared$;
|
|
150
|
-
};
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function retryLink(opts) {
|
|
155
|
-
// initialized config
|
|
156
|
-
return ()=>{
|
|
157
|
-
// initialized in app
|
|
158
|
-
return ({ op , next })=>{
|
|
159
|
-
// initialized for request
|
|
160
|
-
return observable.observable((observer)=>{
|
|
161
|
-
let next$ = null;
|
|
162
|
-
let attempts = 0;
|
|
163
|
-
let isDone = false;
|
|
164
|
-
function attempt() {
|
|
165
|
-
attempts++;
|
|
166
|
-
next$?.unsubscribe();
|
|
167
|
-
next$ = next(op).subscribe({
|
|
168
|
-
error (error) {
|
|
169
|
-
if (attempts >= opts.attempts) {
|
|
170
|
-
observer.error(error);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
attempt();
|
|
174
|
-
},
|
|
175
|
-
next (result) {
|
|
176
|
-
if ('result' in result.result) {
|
|
177
|
-
isDone = true;
|
|
178
|
-
observer.next(result);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (attempts >= opts.attempts) {
|
|
182
|
-
isDone = true;
|
|
183
|
-
observer.next(result);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
attempt();
|
|
187
|
-
},
|
|
188
|
-
complete () {
|
|
189
|
-
if (isDone) {
|
|
190
|
-
observer.complete();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
attempt();
|
|
196
|
-
return ()=>{
|
|
197
|
-
isDone = true;
|
|
198
|
-
next$?.unsubscribe();
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
106
|
/**
|
|
206
107
|
* @deprecated use `createTRPCProxyClient` instead
|
|
207
108
|
*/ function createTRPCClient(opts) {
|
|
@@ -257,5 +158,3 @@ exports.wsLink = links_wsLink.wsLink;
|
|
|
257
158
|
exports.createTRPCClient = createTRPCClient;
|
|
258
159
|
exports.createTRPCClientProxy = createTRPCClientProxy;
|
|
259
160
|
exports.createTRPCProxyClient = createTRPCProxyClient;
|
|
260
|
-
exports.dedupeLink = dedupeLink;
|
|
261
|
-
exports.retryLink = retryLink;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { share, observableToPromise
|
|
1
|
+
import { share, observableToPromise } from '@trpc/server/observable';
|
|
2
2
|
import { T as TRPCClientError } from './transformResult-106791d7.mjs';
|
|
3
3
|
export { T as TRPCClientError } from './transformResult-106791d7.mjs';
|
|
4
4
|
import { c as createChain } from './splitLink-ad44a55d.mjs';
|
|
@@ -102,105 +102,6 @@ class TRPCClient {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
function dedupeLink() {
|
|
106
|
-
// initialized config
|
|
107
|
-
return ()=>{
|
|
108
|
-
// initialized in app
|
|
109
|
-
const pending = {};
|
|
110
|
-
return ({ op , next })=>{
|
|
111
|
-
// initialized for request
|
|
112
|
-
if (op.type !== 'query') {
|
|
113
|
-
// pass through
|
|
114
|
-
return next(op);
|
|
115
|
-
}
|
|
116
|
-
const key = JSON.stringify([
|
|
117
|
-
op.path,
|
|
118
|
-
op.input
|
|
119
|
-
]);
|
|
120
|
-
const obs$ = pending[key];
|
|
121
|
-
if (obs$) {
|
|
122
|
-
// console.log('hooking into pending', { op });
|
|
123
|
-
return observable((observer)=>obs$.subscribe(observer));
|
|
124
|
-
}
|
|
125
|
-
const shared$ = observable((observer)=>{
|
|
126
|
-
function reset() {
|
|
127
|
-
delete pending[key];
|
|
128
|
-
}
|
|
129
|
-
const subscription = next(op).subscribe({
|
|
130
|
-
next (v) {
|
|
131
|
-
observer.next(v);
|
|
132
|
-
},
|
|
133
|
-
error (e) {
|
|
134
|
-
reset();
|
|
135
|
-
observer.error(e);
|
|
136
|
-
},
|
|
137
|
-
complete () {
|
|
138
|
-
reset();
|
|
139
|
-
observer.complete();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return ()=>{
|
|
143
|
-
reset();
|
|
144
|
-
subscription.unsubscribe();
|
|
145
|
-
};
|
|
146
|
-
}).pipe(share());
|
|
147
|
-
pending[key] = shared$;
|
|
148
|
-
return shared$;
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function retryLink(opts) {
|
|
154
|
-
// initialized config
|
|
155
|
-
return ()=>{
|
|
156
|
-
// initialized in app
|
|
157
|
-
return ({ op , next })=>{
|
|
158
|
-
// initialized for request
|
|
159
|
-
return observable((observer)=>{
|
|
160
|
-
let next$ = null;
|
|
161
|
-
let attempts = 0;
|
|
162
|
-
let isDone = false;
|
|
163
|
-
function attempt() {
|
|
164
|
-
attempts++;
|
|
165
|
-
next$?.unsubscribe();
|
|
166
|
-
next$ = next(op).subscribe({
|
|
167
|
-
error (error) {
|
|
168
|
-
if (attempts >= opts.attempts) {
|
|
169
|
-
observer.error(error);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
attempt();
|
|
173
|
-
},
|
|
174
|
-
next (result) {
|
|
175
|
-
if ('result' in result.result) {
|
|
176
|
-
isDone = true;
|
|
177
|
-
observer.next(result);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (attempts >= opts.attempts) {
|
|
181
|
-
isDone = true;
|
|
182
|
-
observer.next(result);
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
attempt();
|
|
186
|
-
},
|
|
187
|
-
complete () {
|
|
188
|
-
if (isDone) {
|
|
189
|
-
observer.complete();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
attempt();
|
|
195
|
-
return ()=>{
|
|
196
|
-
isDone = true;
|
|
197
|
-
next$?.unsubscribe();
|
|
198
|
-
};
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
105
|
/**
|
|
205
106
|
* @deprecated use `createTRPCProxyClient` instead
|
|
206
107
|
*/ function createTRPCClient(opts) {
|
|
@@ -245,4 +146,4 @@ function createTRPCProxyClient(opts) {
|
|
|
245
146
|
return proxy;
|
|
246
147
|
}
|
|
247
148
|
|
|
248
|
-
export { createTRPCClient, createTRPCClientProxy, createTRPCProxyClient
|
|
149
|
+
export { createTRPCClient, createTRPCClientProxy, createTRPCProxyClient };
|
package/dist/links/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/links/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/links/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -12,7 +12,7 @@ declare type EnableFnOptions<TRouter extends AnyRouter> = (Operation & {
|
|
|
12
12
|
result: OperationResultEnvelope<unknown> | TRPCClientError<TRouter>;
|
|
13
13
|
};
|
|
14
14
|
declare type EnabledFn<TRouter extends AnyRouter> = (opts: EnableFnOptions<TRouter>) => boolean;
|
|
15
|
-
declare type
|
|
15
|
+
declare type LoggerLinkFnOptions<TRouter extends AnyRouter> = Operation & ({
|
|
16
16
|
/**
|
|
17
17
|
* Request was just initialized
|
|
18
18
|
*/
|
|
@@ -25,15 +25,15 @@ declare type LogFnOptions<TRouter extends AnyRouter> = Operation & ({
|
|
|
25
25
|
result: OperationResultEnvelope<unknown> | TRPCClientError<TRouter>;
|
|
26
26
|
elapsedMs: number;
|
|
27
27
|
});
|
|
28
|
-
declare type
|
|
29
|
-
|
|
30
|
-
logger?:
|
|
28
|
+
declare type LoggerLinkFn<TRouter extends AnyRouter> = (opts: LoggerLinkFnOptions<TRouter>) => void;
|
|
29
|
+
export interface LoggerLinkOptions<TRouter extends AnyRouter> {
|
|
30
|
+
logger?: LoggerLinkFn<TRouter>;
|
|
31
31
|
enabled?: EnabledFn<TRouter>;
|
|
32
32
|
/**
|
|
33
33
|
* Used in the built-in defaultLogger
|
|
34
34
|
*/
|
|
35
35
|
console?: ConsoleEsque;
|
|
36
|
-
}
|
|
36
|
+
}
|
|
37
37
|
export declare function loggerLink<TRouter extends AnyRouter = AnyRouter>(opts?: LoggerLinkOptions<TRouter>): TRPCLink<TRouter>;
|
|
38
38
|
export {};
|
|
39
39
|
//# sourceMappingURL=loggerLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerLink.d.ts","sourceRoot":"","sources":["../../../../packages/client/src/links/loggerLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEvE,aAAK,YAAY,GAAG;IAClB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK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AC3B,OAAO,CAAC;AAEb,aAAK,mBAAmB,CAAC,OAAO,SAAS,SAAS,IAAI,SAAS,GAC7D,CACI;IACE;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;CACjB,GACD;IACE;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB,CACJ,CAAC;AAEJ,aAAK,YAAY,CAAC,OAAO,SAAS,SAAS,IAAI,CAC7C,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAC/B,IAAI,CAAC;AAOV,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,SAAS;IAC1D,MAAM,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAiDD,wBAAgB,UAAU,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAC9D,IAAI,GAAE,iBAAiB,CAAC,OAAO,CAAM,GACpC,QAAQ,CAAC,OAAO,CAAC,CA2CnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "10.0.0-proxy-beta.
|
|
3
|
+
"version": "10.0.0-proxy-beta.16",
|
|
4
4
|
"description": "tRPC Client lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"ts-watch": "tsc --project tsconfig.watch.json"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@trpc/server": "10.0.0-proxy-beta.
|
|
66
|
+
"@trpc/server": "10.0.0-proxy-beta.16"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@testing-library/dom": "^8.18.1",
|
|
70
|
-
"@trpc/server": "10.0.0-proxy-beta.
|
|
70
|
+
"@trpc/server": "10.0.0-proxy-beta.16",
|
|
71
71
|
"@types/node": "^18.7.20"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "4e001688fbdd7de848beb431a343a08c9659618a"
|
|
77
77
|
}
|
package/src/TRPCClientError.ts
CHANGED
|
@@ -12,7 +12,7 @@ type RouterOrProcedure = AnyRouter | AnyProcedure;
|
|
|
12
12
|
type inferErrorShape<TRouterOrProcedure extends RouterOrProcedure> =
|
|
13
13
|
TRouterOrProcedure extends AnyRouter
|
|
14
14
|
? inferRouterError<TRouterOrProcedure>
|
|
15
|
-
: TRouterOrProcedure['_def']['_config']['errorShape'];
|
|
15
|
+
: TRouterOrProcedure['_def']['_config']['$types']['errorShape'];
|
|
16
16
|
|
|
17
17
|
export interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
|
18
18
|
readonly message: string;
|
package/src/links/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export * from './dedupeLink';
|
|
2
1
|
export * from './httpBatchLink';
|
|
3
2
|
export * from './httpLink';
|
|
4
3
|
export * from './loggerLink';
|
|
5
|
-
export * from './retryLink';
|
|
6
4
|
export * from './splitLink';
|
|
7
5
|
export * from './wsLink';
|
|
8
6
|
export * from './types';
|
|
7
|
+
|
|
8
|
+
// These are not public (yet) as we get this functionality from tanstack query
|
|
9
|
+
// export * from './retryLink';
|
|
10
|
+
// export * from './dedupeLink';
|
package/src/links/loggerLink.ts
CHANGED
|
@@ -20,7 +20,7 @@ type EnabledFn<TRouter extends AnyRouter> = (
|
|
|
20
20
|
opts: EnableFnOptions<TRouter>,
|
|
21
21
|
) => boolean;
|
|
22
22
|
|
|
23
|
-
type
|
|
23
|
+
type LoggerLinkFnOptions<TRouter extends AnyRouter> = Operation &
|
|
24
24
|
(
|
|
25
25
|
| {
|
|
26
26
|
/**
|
|
@@ -37,25 +37,30 @@ type LogFnOptions<TRouter extends AnyRouter> = Operation &
|
|
|
37
37
|
elapsedMs: number;
|
|
38
38
|
}
|
|
39
39
|
);
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
type LoggerLinkFn<TRouter extends AnyRouter> = (
|
|
42
|
+
opts: LoggerLinkFnOptions<TRouter>,
|
|
43
|
+
) => void;
|
|
41
44
|
|
|
42
45
|
const palette = {
|
|
43
46
|
query: ['72e3ff', '3fb0d8'],
|
|
44
47
|
mutation: ['c5a3fc', '904dfc'],
|
|
45
48
|
subscription: ['ff49e1', 'd83fbe'],
|
|
46
49
|
};
|
|
47
|
-
|
|
48
|
-
logger?:
|
|
50
|
+
export interface LoggerLinkOptions<TRouter extends AnyRouter> {
|
|
51
|
+
logger?: LoggerLinkFn<TRouter>;
|
|
49
52
|
enabled?: EnabledFn<TRouter>;
|
|
50
53
|
/**
|
|
51
54
|
* Used in the built-in defaultLogger
|
|
52
55
|
*/
|
|
53
56
|
console?: ConsoleEsque;
|
|
54
|
-
}
|
|
57
|
+
}
|
|
55
58
|
|
|
56
59
|
// maybe this should be moved to it's own package
|
|
57
60
|
const defaultLogger =
|
|
58
|
-
<TRouter extends AnyRouter>(
|
|
61
|
+
<TRouter extends AnyRouter>(
|
|
62
|
+
c: ConsoleEsque = console,
|
|
63
|
+
): LoggerLinkFn<TRouter> =>
|
|
59
64
|
(props) => {
|
|
60
65
|
const { direction, input, type, path, context, id } = props;
|
|
61
66
|
const [light, dark] = palette[type];
|