@trpc/client 11.23.0 → 11.23.1-canary.14.507382d73
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-CxFRO7Js.mjs → TRPCClientError-Byo7P4QG.mjs} +14 -1
- package/dist/TRPCClientError-Byo7P4QG.mjs.map +1 -0
- package/dist/{TRPCClientError-CmHlBkPF.cjs → TRPCClientError-CPEwAI4E.cjs} +13 -0
- package/dist/{httpBatchLink-DPypDRI1.mjs → httpBatchLink-B-gQhW2d.mjs} +6 -3
- package/dist/httpBatchLink-B-gQhW2d.mjs.map +1 -0
- package/dist/httpBatchLink-CRRfyw0c.d.cts +46 -0
- package/dist/httpBatchLink-CRRfyw0c.d.cts.map +1 -0
- package/dist/httpBatchLink-DFDg8cHu.d.mts +46 -0
- package/dist/httpBatchLink-DFDg8cHu.d.mts.map +1 -0
- package/dist/{httpBatchLink-Cmao5uUF.cjs → httpBatchLink-DfpTwHVx.cjs} +5 -2
- package/dist/{httpLink-eSAq8J9S.d.mts → httpLink-Bc4oLWCJ.d.cts} +12 -5
- package/dist/httpLink-Bc4oLWCJ.d.cts.map +1 -0
- package/dist/{httpLink-B6E1HSLY.cjs → httpLink-CTrye8t0.cjs} +11 -2
- package/dist/{httpLink--yqaZ9lA.mjs → httpLink-D1jF9wdN.mjs} +12 -3
- package/dist/httpLink-D1jF9wdN.mjs.map +1 -0
- package/dist/{httpLink-D5FQijY2.d.cts → httpLink-yX9QPwni.d.mts} +12 -5
- package/dist/httpLink-yX9QPwni.d.mts.map +1 -0
- package/dist/httpUtils-j-oJ4G4z.d.cts +25 -0
- package/dist/httpUtils-j-oJ4G4z.d.cts.map +1 -0
- package/dist/{httpUtils-CrSF2CZF.cjs → httpUtils-os0q2Zvy.cjs} +4 -0
- package/dist/{httpUtils-CAZsqwOQ.mjs → httpUtils-ttfajAo5.mjs} +5 -1
- package/dist/httpUtils-ttfajAo5.mjs.map +1 -0
- package/dist/httpUtils-v7O5xeam.d.mts +25 -0
- package/dist/httpUtils-v7O5xeam.d.mts.map +1 -0
- package/dist/index.cjs +55 -16
- package/dist/index.d.cts +150 -26
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +150 -26
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +55 -16
- package/dist/index.mjs.map +1 -1
- package/dist/links/httpBatchLink.cjs +1 -1
- package/dist/links/httpBatchLink.d.cts +1 -1
- package/dist/links/httpBatchLink.d.mts +1 -1
- package/dist/links/httpBatchLink.mjs +1 -1
- package/dist/links/httpLink.cjs +1 -1
- package/dist/links/httpLink.d.cts +1 -1
- package/dist/links/httpLink.d.mts +1 -1
- package/dist/links/httpLink.mjs +1 -1
- package/dist/links/loggerLink.cjs +4 -1
- package/dist/links/loggerLink.d.cts +1 -1
- package/dist/links/loggerLink.d.mts +1 -1
- package/dist/links/loggerLink.mjs +4 -1
- package/dist/links/loggerLink.mjs.map +1 -1
- package/dist/links/splitLink.cjs +1 -1
- package/dist/links/splitLink.d.cts +1 -1
- package/dist/links/splitLink.d.mts +1 -1
- package/dist/links/splitLink.mjs +1 -1
- package/dist/links/wsLink/wsLink.cjs +1 -1
- package/dist/links/wsLink/wsLink.d.cts +1 -1
- package/dist/links/wsLink/wsLink.d.mts +1 -1
- package/dist/links/wsLink/wsLink.mjs +1 -1
- package/dist/{loggerLink-CFercTVc.d.mts → loggerLink-BEMtA7V5.d.cts} +20 -4
- package/dist/loggerLink-BEMtA7V5.d.cts.map +1 -0
- package/dist/{loggerLink-2o-uZ3r1.d.cts → loggerLink-Daki_B65.d.mts} +20 -4
- package/dist/loggerLink-Daki_B65.d.mts.map +1 -0
- package/dist/{splitLink-MXnaFlEb.cjs → splitLink-CL8W2Mit.cjs} +5 -0
- package/dist/{splitLink-BZPioDdG.mjs → splitLink-DcpFI5s5.mjs} +6 -1
- package/dist/splitLink-DcpFI5s5.mjs.map +1 -0
- package/dist/{splitLink-CJdcmEmS.d.cts → splitLink-i7EskO_m.d.cts} +10 -2
- package/dist/splitLink-i7EskO_m.d.cts.map +1 -0
- package/dist/{splitLink-CixmF14P.d.mts → splitLink-zyV5y7N1.d.mts} +10 -2
- package/dist/splitLink-zyV5y7N1.d.mts.map +1 -0
- package/dist/{types-BxbMkv6C.d.cts → types-BrCJd1zp.d.cts} +54 -6
- package/dist/types-BrCJd1zp.d.cts.map +1 -0
- package/dist/{types-CAPs7vhA.d.mts → types-DO-GCB2q.d.mts} +54 -6
- package/dist/types-DO-GCB2q.d.mts.map +1 -0
- package/dist/{unstable-internals-CE8gFBQ9.d.cts → unstable-internals-CNoyg7Yf.d.cts} +4 -4
- package/dist/{unstable-internals-CE8gFBQ9.d.cts.map → unstable-internals-CNoyg7Yf.d.cts.map} +1 -1
- package/dist/{unstable-internals-CE8gFBQ9.d.mts → unstable-internals-CNoyg7Yf.d.mts} +4 -4
- package/dist/{unstable-internals-CE8gFBQ9.d.mts.map → unstable-internals-CNoyg7Yf.d.mts.map} +1 -1
- package/dist/unstable-internals.d.cts +1 -1
- package/dist/unstable-internals.d.mts +1 -1
- package/dist/unstable-internals.mjs.map +1 -1
- package/dist/{wsLink-CQGBu_VZ.cjs → wsLink-Bl27m-y2.cjs} +18 -1
- package/dist/{wsLink--7trqYPG.mjs → wsLink-CDaUjHvu.mjs} +19 -2
- package/dist/wsLink-CDaUjHvu.mjs.map +1 -0
- package/dist/{wsLink-DnvK9sTv.d.mts → wsLink-CEgNu9Gj.d.mts} +39 -5
- package/dist/wsLink-CEgNu9Gj.d.mts.map +1 -0
- package/dist/{wsLink-C3hsDLsL.d.cts → wsLink-DZr_cFFg.d.cts} +39 -5
- package/dist/wsLink-DZr_cFFg.d.cts.map +1 -0
- package/package.json +4 -4
- package/skills/client-setup/SKILL.md +1 -1
- package/skills/links/SKILL.md +1 -1
- package/skills/superjson/SKILL.md +1 -1
- package/src/TRPCClientError.ts +27 -2
- package/src/createTRPCClient.ts +38 -7
- package/src/createTRPCUntypedClient.ts +4 -0
- package/src/getFetch.ts +4 -0
- package/src/internals/TRPCUntypedClient.ts +33 -2
- package/src/internals/transformer.ts +3 -3
- package/src/internals/types.ts +9 -1
- package/src/links/HTTPBatchLinkOptions.ts +17 -3
- package/src/links/httpBatchLink.ts +3 -0
- package/src/links/httpBatchStreamLink.ts +10 -1
- package/src/links/httpLink.ts +9 -2
- package/src/links/httpSubscriptionLink.ts +10 -3
- package/src/links/internals/contentTypes.ts +7 -0
- package/src/links/internals/httpUtils.ts +6 -4
- package/src/links/internals/urlWithConnectionParams.ts +1 -0
- package/src/links/localLink.ts +22 -3
- package/src/links/loggerLink.ts +18 -2
- package/src/links/retryLink.ts +4 -1
- package/src/links/splitLink.ts +8 -0
- package/src/links/types.ts +17 -2
- package/src/links/wsLink/createWsClient.ts +9 -0
- package/src/links/wsLink/wsClient/encoder.ts +3 -0
- package/src/links/wsLink/wsClient/options.ts +7 -2
- package/src/links/wsLink/wsClient/wsClient.ts +3 -0
- package/src/links/wsLink/wsLink.ts +13 -0
- package/src/safe.ts +11 -2
- package/dist/TRPCClientError-CxFRO7Js.mjs.map +0 -1
- package/dist/httpBatchLink-Br-pzPXf.d.cts +0 -29
- package/dist/httpBatchLink-Br-pzPXf.d.cts.map +0 -1
- package/dist/httpBatchLink-DPypDRI1.mjs.map +0 -1
- package/dist/httpBatchLink-nvc48L_N.d.mts +0 -29
- package/dist/httpBatchLink-nvc48L_N.d.mts.map +0 -1
- package/dist/httpLink--yqaZ9lA.mjs.map +0 -1
- package/dist/httpLink-D5FQijY2.d.cts.map +0 -1
- package/dist/httpLink-eSAq8J9S.d.mts.map +0 -1
- package/dist/httpUtils-C37jRVnj.d.mts +0 -23
- package/dist/httpUtils-C37jRVnj.d.mts.map +0 -1
- package/dist/httpUtils-CAZsqwOQ.mjs.map +0 -1
- package/dist/httpUtils-CUqAubVD.d.cts +0 -23
- package/dist/httpUtils-CUqAubVD.d.cts.map +0 -1
- package/dist/loggerLink-2o-uZ3r1.d.cts.map +0 -1
- package/dist/loggerLink-CFercTVc.d.mts.map +0 -1
- package/dist/splitLink-BZPioDdG.mjs.map +0 -1
- package/dist/splitLink-CJdcmEmS.d.cts.map +0 -1
- package/dist/splitLink-CixmF14P.d.mts.map +0 -1
- package/dist/types-BxbMkv6C.d.cts.map +0 -1
- package/dist/types-CAPs7vhA.d.mts.map +0 -1
- package/dist/wsLink--7trqYPG.mjs.map +0 -1
- package/dist/wsLink-C3hsDLsL.d.cts.map +0 -1
- package/dist/wsLink-DnvK9sTv.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitLink-DcpFI5s5.mjs","names":[],"sources":["../src/links/internals/createChain.ts","../src/links/splitLink.ts"],"sourcesContent":["import { observable } from '@trpc/server/observable';\nimport type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport type {\n Operation,\n OperationLink,\n OperationResultObservable,\n} from '../types';\n\n/** @internal */\nexport function createChain<\n TRouter extends AnyRouter,\n TInput = unknown,\n TOutput = unknown,\n>(opts: {\n links: OperationLink<TRouter, TInput, TOutput>[];\n op: Operation<TInput>;\n}): OperationResultObservable<TRouter, TOutput> {\n return observable((observer) => {\n function execute(index = 0, op = opts.op) {\n const next = opts.links[index];\n if (!next) {\n throw new Error(\n 'No more links to execute - did you forget to add an ending link?',\n );\n }\n const subscription = next({\n op,\n next(nextOp) {\n const nextObserver = execute(index + 1, nextOp);\n\n return nextObserver;\n },\n });\n return subscription;\n }\n\n const obs$ = execute();\n return obs$.subscribe(observer);\n });\n}\n","import { observable } from '@trpc/server/observable';\nimport type { AnyRouter } from '@trpc/server/unstable-core-do-not-import';\nimport { createChain } from './internals/createChain';\nimport type { Operation, TRPCLink } from './types';\n\nfunction asArray<TType>(value: TType | TType[]) {\n return Array.isArray(value) ? value : [value];\n}\n/**\n * Sends each operation down one of two link chains, based on `condition`.\n *\n * @see https://trpc.io/docs/client/links/splitLink\n */\nexport function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {\n /**\n * Picks the chain for an operation.\n */\n condition: (op: Operation) => boolean;\n /**\n * The link to execute next if the test function returns `true`.\n */\n true: TRPCLink<TRouter> | TRPCLink<TRouter>[];\n /**\n * The link to execute next if the test function returns `false`.\n */\n false: TRPCLink<TRouter> | TRPCLink<TRouter>[];\n}): TRPCLink<TRouter> {\n return (runtime) => {\n const yes = asArray(opts.true).map((link) => link(runtime));\n const no = asArray(opts.false).map((link) => link(runtime));\n return (props) => {\n return observable((observer) => {\n const links = opts.condition(props.op) ? yes : no;\n return createChain({ op: props.op, links }).subscribe(observer);\n });\n };\n };\n}\n"],"mappings":";;;AASA,SAAgB,YAId,MAG8C;CAC9C,OAAO,YAAY,aAAa;EAC9B,SAAS,QAAQ,QAAQ,GAAG,KAAK,KAAK,IAAI;GACxC,MAAM,OAAO,KAAK,MAAM;GACxB,IAAI,CAAC,MACH,MAAM,IAAI,MACR,kEACF;GAUF,OARqB,KAAK;IACxB;IACA,KAAK,QAAQ;KAGX,OAFqB,QAAQ,QAAQ,GAAG,MAEtB;IACpB;GACF,CACkB;EACpB;EAGA,OADa,QACH,CAAC,CAAC,UAAU,QAAQ;CAChC,CAAC;AACH;;;AClCA,SAAS,QAAe,OAAwB;CAC9C,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;;;;;;AAMA,SAAgB,UAAiD,MAa3C;CACpB,QAAQ,YAAY;EAClB,MAAM,MAAM,QAAQ,KAAK,IAAI,CAAC,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC;EAC1D,MAAM,KAAK,QAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC;EAC1D,QAAQ,UAAU;GAChB,OAAO,YAAY,aAAa;IAC9B,MAAM,QAAQ,KAAK,UAAU,MAAM,EAAE,IAAI,MAAM;IAC/C,OAAO,YAAY;KAAE,IAAI,MAAM;KAAI;IAAM,CAAC,CAAC,CAAC,UAAU,QAAQ;GAChE,CAAC;EACH;CACF;AACF"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { n as Operation, u as TRPCLink } from "./types-
|
|
1
|
+
import { n as Operation, u as TRPCLink } from "./types-BrCJd1zp.cjs";
|
|
2
2
|
import { AnyRouter } from "@trpc/server/unstable-core-do-not-import";
|
|
3
3
|
//#region src/links/splitLink.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Sends each operation down one of two link chains, based on `condition`.
|
|
6
|
+
*
|
|
7
|
+
* @see https://trpc.io/docs/client/links/splitLink
|
|
8
|
+
*/
|
|
4
9
|
declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
|
|
10
|
+
/**
|
|
11
|
+
* Picks the chain for an operation.
|
|
12
|
+
*/
|
|
5
13
|
condition: (op: Operation) => boolean;
|
|
6
14
|
/**
|
|
7
15
|
* The link to execute next if the test function returns `true`.
|
|
@@ -14,4 +22,4 @@ declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
|
|
|
14
22
|
}): TRPCLink<TRouter>;
|
|
15
23
|
//#endregion
|
|
16
24
|
export { splitLink as t };
|
|
17
|
-
//# sourceMappingURL=splitLink-
|
|
25
|
+
//# sourceMappingURL=splitLink-i7EskO_m.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitLink-i7EskO_m.d.cts","names":[],"sources":["../src/links/splitLink.ts"],"mappings":";;;;;;;;iBAagB,UAAU,gBAAgB,YAAY,WAAW;;;;EAI/D,YAAY,IAAI;;;;EAIhB,MAAM,SAAS,WAAW,SAAS;;;;EAInC,OAAO,SAAS,WAAW,SAAS;IAClC,SAAS"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { n as Operation, u as TRPCLink } from "./types-
|
|
1
|
+
import { n as Operation, u as TRPCLink } from "./types-DO-GCB2q.mjs";
|
|
2
2
|
import { AnyRouter } from "@trpc/server/unstable-core-do-not-import";
|
|
3
3
|
//#region src/links/splitLink.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Sends each operation down one of two link chains, based on `condition`.
|
|
6
|
+
*
|
|
7
|
+
* @see https://trpc.io/docs/client/links/splitLink
|
|
8
|
+
*/
|
|
4
9
|
declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
|
|
10
|
+
/**
|
|
11
|
+
* Picks the chain for an operation.
|
|
12
|
+
*/
|
|
5
13
|
condition: (op: Operation) => boolean;
|
|
6
14
|
/**
|
|
7
15
|
* The link to execute next if the test function returns `true`.
|
|
@@ -14,4 +22,4 @@ declare function splitLink<TRouter extends AnyRouter = AnyRouter>(opts: {
|
|
|
14
22
|
}): TRPCLink<TRouter>;
|
|
15
23
|
//#endregion
|
|
16
24
|
export { splitLink as t };
|
|
17
|
-
//# sourceMappingURL=splitLink-
|
|
25
|
+
//# sourceMappingURL=splitLink-zyV5y7N1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitLink-zyV5y7N1.d.mts","names":[],"sources":["../src/links/splitLink.ts"],"mappings":";;;;;;;;iBAagB,UAAU,gBAAgB,YAAY,WAAW;;;;EAI/D,YAAY,IAAI;;;;EAIhB,MAAM,SAAS,WAAW,SAAS;;;;EAInC,OAAO,SAAS,WAAW,SAAS;IAClC,SAAS"}
|
|
@@ -74,32 +74,61 @@ interface ResponseEsque {
|
|
|
74
74
|
type NonEmptyArray<TItem> = [TItem, ...TItem[]];
|
|
75
75
|
type ClientContext = Record<string, unknown>;
|
|
76
76
|
/**
|
|
77
|
+
* The options of a call made with the client, such as
|
|
78
|
+
* `client.post.byId.query(input, opts)`.
|
|
77
79
|
* @public
|
|
78
80
|
*/
|
|
79
81
|
interface TRPCProcedureOptions {
|
|
80
82
|
/**
|
|
81
|
-
*
|
|
83
|
+
* Context for the links, such as a flag a `splitLink` reads.
|
|
84
|
+
* @see https://trpc.io/docs/client/links#managing-context
|
|
82
85
|
*/
|
|
83
86
|
context?: ClientContext;
|
|
87
|
+
/**
|
|
88
|
+
* Aborts the call. With `httpBatchLink`, the request is only aborted once
|
|
89
|
+
* every call in its batch is, so an aborted call can still get a result.
|
|
90
|
+
* @see https://trpc.io/docs/client/vanilla/aborting-procedure-calls
|
|
91
|
+
*/
|
|
84
92
|
signal?: AbortSignal;
|
|
85
93
|
}
|
|
86
94
|
//#endregion
|
|
87
95
|
//#region src/TRPCClientError.d.ts
|
|
88
96
|
type inferErrorShape<TInferrable extends InferrableClientTypes> = inferClientTypes<TInferrable>['errorShape'];
|
|
97
|
+
/** What a client error has, whatever its router. */
|
|
89
98
|
interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
|
90
99
|
readonly message: string;
|
|
100
|
+
/** The error as the server's error formatter shaped it, if it came from the server. */
|
|
91
101
|
readonly shape: Maybe<TShape>;
|
|
102
|
+
/** The shape's `data`, such as the tRPC code and HTTP status. */
|
|
92
103
|
readonly data: Maybe<TShape['data']>;
|
|
93
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* The shape of a client error for a router or procedure, without the
|
|
107
|
+
* class. Use it to type errors you pass around, such as in React state.
|
|
108
|
+
* @see https://trpc.io/docs/client/vanilla/infer-types#infer-trpcclienterror-types
|
|
109
|
+
*/
|
|
94
110
|
type TRPCClientErrorLike<TInferrable extends InferrableClientTypes> = TRPCClientErrorBase<inferErrorShape<TInferrable>>;
|
|
111
|
+
/**
|
|
112
|
+
* Whether a value is a `TRPCClientError`, typed for a router or procedure.
|
|
113
|
+
* @see https://trpc.io/docs/client/vanilla/error-handling#catching-a-thrown-error
|
|
114
|
+
*/
|
|
95
115
|
declare function isTRPCClientError<TInferrable extends InferrableClientTypes>(cause: unknown): cause is TRPCClientError<TInferrable>;
|
|
116
|
+
/**
|
|
117
|
+
* The error a client call throws, whether the server sent an error or the
|
|
118
|
+
* request failed.
|
|
119
|
+
* @see https://trpc.io/docs/client/vanilla/error-handling
|
|
120
|
+
*/
|
|
96
121
|
declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes> extends Error implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>> {
|
|
122
|
+
/** The error this one wraps, such as a network error. */
|
|
97
123
|
readonly cause: Error | undefined;
|
|
124
|
+
/** The error as the server's error formatter shaped it, if it came from the server. */
|
|
98
125
|
readonly shape: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
|
126
|
+
/** The shape's `data`, such as the tRPC code and HTTP status. */
|
|
99
127
|
readonly data: Maybe<inferErrorShape<TRouterOrProcedure>['data']>;
|
|
100
128
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
129
|
+
* More about the error, if any. HTTP errors may have the `response` and
|
|
130
|
+
* its `responseJSON`; a failed fetch or unparsable response may have
|
|
131
|
+
* neither.
|
|
103
132
|
*/
|
|
104
133
|
meta: Record<string, unknown> | undefined;
|
|
105
134
|
constructor(message: string, opts?: {
|
|
@@ -107,6 +136,10 @@ declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes>
|
|
|
107
136
|
cause?: Error;
|
|
108
137
|
meta?: Record<string, unknown>;
|
|
109
138
|
});
|
|
139
|
+
/**
|
|
140
|
+
* Turns an error response, an `Error` or another object into a
|
|
141
|
+
* `TRPCClientError`. A `TRPCClientError` is returned as it is.
|
|
142
|
+
*/
|
|
110
143
|
static from<TRouterOrProcedure extends InferrableClientTypes>(_cause: Error | TRPCErrorResponse<any> | object, opts?: {
|
|
111
144
|
meta?: Record<string, unknown>;
|
|
112
145
|
cause?: Error;
|
|
@@ -115,13 +148,17 @@ declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes>
|
|
|
115
148
|
//#endregion
|
|
116
149
|
//#region src/links/types.d.ts
|
|
117
150
|
/**
|
|
151
|
+
* Context an operation carries through the links, set per call.
|
|
152
|
+
* @see https://trpc.io/docs/client/links#managing-context
|
|
118
153
|
* @internal
|
|
119
154
|
*/
|
|
120
155
|
interface OperationContext extends Record<string, unknown> {}
|
|
121
156
|
/**
|
|
157
|
+
* A procedure call as it goes through the links.
|
|
122
158
|
* @internal
|
|
123
159
|
*/
|
|
124
160
|
type Operation<TInput = unknown> = {
|
|
161
|
+
/** A number unique to the call within its client. */
|
|
125
162
|
id: number;
|
|
126
163
|
type: 'mutation' | 'query' | 'subscription';
|
|
127
164
|
input: TInput;
|
|
@@ -133,16 +170,19 @@ interface HeadersInitEsque {
|
|
|
133
170
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
134
171
|
}
|
|
135
172
|
/**
|
|
173
|
+
* Request headers: a `Headers`-like iterable, or an object.
|
|
136
174
|
* @internal
|
|
137
175
|
*/
|
|
138
176
|
type HTTPHeaders = HeadersInitEsque | Record<string, string[] | string | undefined>;
|
|
139
177
|
/**
|
|
140
|
-
* The
|
|
141
|
-
* only uses the overload taking a string and options object.
|
|
178
|
+
* The `fetch` the HTTP links call: only its `(url, options)` form.
|
|
142
179
|
*/
|
|
143
180
|
type TRPCFetch = (url: string, options?: RequestInit) => Promise<ResponseEsque>;
|
|
181
|
+
/** What a link gets when the client is created. Empty for now. */
|
|
144
182
|
interface TRPCClientRuntime {}
|
|
145
183
|
/**
|
|
184
|
+
* A result a link passes back: data, a subscription's `started` or
|
|
185
|
+
* `stopped` event, or a change of connection state.
|
|
146
186
|
* @internal
|
|
147
187
|
*/
|
|
148
188
|
interface OperationResultEnvelope<TOutput, TError> {
|
|
@@ -150,14 +190,19 @@ interface OperationResultEnvelope<TOutput, TError> {
|
|
|
150
190
|
context?: OperationContext;
|
|
151
191
|
}
|
|
152
192
|
/**
|
|
193
|
+
* The observable of results a link returns for an operation.
|
|
153
194
|
* @internal
|
|
154
195
|
*/
|
|
155
196
|
type OperationResultObservable<TInferrable extends InferrableClientTypes, TOutput> = Observable<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
|
156
197
|
/**
|
|
198
|
+
* An observer of a link's results.
|
|
157
199
|
* @internal
|
|
158
200
|
*/
|
|
159
201
|
type OperationResultObserver<TInferrable extends InferrableClientTypes, TOutput> = Observer<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
|
160
202
|
/**
|
|
203
|
+
* Handles one operation: pass it on with `next(op)`, or send it and
|
|
204
|
+
* return the results.
|
|
205
|
+
* @see https://trpc.io/docs/client/links#creating-a-custom-link
|
|
161
206
|
* @internal
|
|
162
207
|
*/
|
|
163
208
|
type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown, TOutput = unknown> = (opts: {
|
|
@@ -165,9 +210,12 @@ type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown,
|
|
|
165
210
|
next: (op: Operation<TInput>) => OperationResultObservable<TInferrable, TOutput>;
|
|
166
211
|
}) => OperationResultObservable<TInferrable, TOutput>;
|
|
167
212
|
/**
|
|
213
|
+
* A link: a step every call goes through, such as logging or sending it
|
|
214
|
+
* over HTTP. It's called once when the client is created.
|
|
215
|
+
* @see https://trpc.io/docs/client/links#creating-a-custom-link
|
|
168
216
|
* @public
|
|
169
217
|
*/
|
|
170
218
|
type TRPCLink<TInferrable extends InferrableClientTypes> = (opts: TRPCClientRuntime) => OperationLink<TInferrable>;
|
|
171
219
|
//#endregion
|
|
172
220
|
export { NonEmptyArray as _, OperationResultEnvelope as a, TRPCClientRuntime as c, TRPCClientError as d, TRPCClientErrorBase as f, NativeFetchEsque as g, FetchEsque as h, OperationLink as i, TRPCFetch as l, isTRPCClientError as m, Operation as n, OperationResultObservable as o, TRPCClientErrorLike as p, OperationContext as r, OperationResultObserver as s, HTTPHeaders as t, TRPCLink as u, TRPCProcedureOptions as v };
|
|
173
|
-
//# sourceMappingURL=types-
|
|
221
|
+
//# sourceMappingURL=types-BrCJd1zp.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BrCJd1zp.d.cts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/types.ts"],"mappings":";;;;;;;;;;;KAOY,cACV,OAAO,cAAc,cACrB,OAAO,cAAc,qBAClB,QAAQ;;;;;KAMD,oBACV,KAAK,cACL,OAAO,8BACJ,QAAQ;UAEI;EACf;;;;;;;;;UAUe;;;;EAIf,OAAO,2BAA2B,WAAW,eAAe,OAAO;;;;EAKnE,+BAA+B;;;;EAK/B;;;;EAKA,SAAS;;;;;;KAOC;EACV,iBAAiB,4BAA4B;;KAGnC;EACV,GACE,4BACA,cAAc,uBACb;;;;;;UAOY;WACN;WACA,OAAO,4BAA4B;;;;;;;EAO5C,QAAQ;;;;;KAME,cAAc,UAAU,UAAU;KAEzC,gBAAgB;;;;;;UAOJ;;;;;EAKf,UAAU;;;;;;EAMV,SAAS;;;;KCjGN,gBAAgB,oBAAoB,yBACvC,iBAAiB;;UAEF,oBAAoB,eAAe;WACzC;;WAEA,OAAO,MAAM;;WAEb,MAAM,MAAM;;;;;;;KAOX,oBAAoB,oBAAoB,yBAClD,oBAAoB,gBAAgB;;;;;iBAMtB,kBAAkB,oBAAoB,uBACpD,iBACC,SAAS,gBAAgB;;;;;;cA4Bf,gBAAgB,2BAA2B,+BAC9C,iBACG,oBAAoB,gBAAgB;;WAKtB,OAAK;;WAEd,OAAO,MAAM,gBAAgB;;WAE7B,MAAM,MAAM,gBAAgB;;;;;;EAOrC,MAAI;EAEX,YACE,iBACA;IACE,SAAS,MAAM,kBAAkB,gBAAgB;IACjD,QAAQ;IACR,OAAO;;;;;;SAuBG,KAAK,2BAA2B,uBAC5C,QAAQ,QAAQ,iCAChB;IAAQ,OAAO;IAAyB,QAAQ;MAC/C,gBAAgB;;;;;;;;;UC5FJ,yBAAyB;;;;;KAM9B,UAAU;;EAEpB;EACA;EACA,OAAO;EACP;EACA,SAAS;EACT,QAAQ,MAAM;;UAGN;GACP,OAAO,aAAa;;;;;;KAOX,cACR,mBACA;;;;KAKQ,aACV,aACA,UAAU,gBACP,QAAQ;;UAGI;;;;;;UASA,wBAAwB,SAAS;EAChD,QACI,kBAAkB,qBAClB,oBAAoB,qBACpB,oBAAoB;EACxB,UAAU;;;;;;KAOA,0BACV,oBAAoB,uBACpB,WACE,WACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;KAON,wBACV,oBAAoB,uBACpB,WACE,SACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;;;KASN,cACV,oBAAoB,uBACpB,kBACA,sBACG;EACH,IAAI,UAAU;EACd,OACE,IAAI,UAAU,YACX,0BAA0B,aAAa;MACxC,0BAA0B,aAAa;;;;;;;KAQjC,SAAS,oBAAoB,0BACvC,MAAM,sBACH,cAAc"}
|
|
@@ -74,32 +74,61 @@ interface ResponseEsque {
|
|
|
74
74
|
type NonEmptyArray<TItem> = [TItem, ...TItem[]];
|
|
75
75
|
type ClientContext = Record<string, unknown>;
|
|
76
76
|
/**
|
|
77
|
+
* The options of a call made with the client, such as
|
|
78
|
+
* `client.post.byId.query(input, opts)`.
|
|
77
79
|
* @public
|
|
78
80
|
*/
|
|
79
81
|
interface TRPCProcedureOptions {
|
|
80
82
|
/**
|
|
81
|
-
*
|
|
83
|
+
* Context for the links, such as a flag a `splitLink` reads.
|
|
84
|
+
* @see https://trpc.io/docs/client/links#managing-context
|
|
82
85
|
*/
|
|
83
86
|
context?: ClientContext;
|
|
87
|
+
/**
|
|
88
|
+
* Aborts the call. With `httpBatchLink`, the request is only aborted once
|
|
89
|
+
* every call in its batch is, so an aborted call can still get a result.
|
|
90
|
+
* @see https://trpc.io/docs/client/vanilla/aborting-procedure-calls
|
|
91
|
+
*/
|
|
84
92
|
signal?: AbortSignal;
|
|
85
93
|
}
|
|
86
94
|
//#endregion
|
|
87
95
|
//#region src/TRPCClientError.d.ts
|
|
88
96
|
type inferErrorShape<TInferrable extends InferrableClientTypes> = inferClientTypes<TInferrable>['errorShape'];
|
|
97
|
+
/** What a client error has, whatever its router. */
|
|
89
98
|
interface TRPCClientErrorBase<TShape extends DefaultErrorShape> {
|
|
90
99
|
readonly message: string;
|
|
100
|
+
/** The error as the server's error formatter shaped it, if it came from the server. */
|
|
91
101
|
readonly shape: Maybe<TShape>;
|
|
102
|
+
/** The shape's `data`, such as the tRPC code and HTTP status. */
|
|
92
103
|
readonly data: Maybe<TShape['data']>;
|
|
93
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* The shape of a client error for a router or procedure, without the
|
|
107
|
+
* class. Use it to type errors you pass around, such as in React state.
|
|
108
|
+
* @see https://trpc.io/docs/client/vanilla/infer-types#infer-trpcclienterror-types
|
|
109
|
+
*/
|
|
94
110
|
type TRPCClientErrorLike<TInferrable extends InferrableClientTypes> = TRPCClientErrorBase<inferErrorShape<TInferrable>>;
|
|
111
|
+
/**
|
|
112
|
+
* Whether a value is a `TRPCClientError`, typed for a router or procedure.
|
|
113
|
+
* @see https://trpc.io/docs/client/vanilla/error-handling#catching-a-thrown-error
|
|
114
|
+
*/
|
|
95
115
|
declare function isTRPCClientError<TInferrable extends InferrableClientTypes>(cause: unknown): cause is TRPCClientError<TInferrable>;
|
|
116
|
+
/**
|
|
117
|
+
* The error a client call throws, whether the server sent an error or the
|
|
118
|
+
* request failed.
|
|
119
|
+
* @see https://trpc.io/docs/client/vanilla/error-handling
|
|
120
|
+
*/
|
|
96
121
|
declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes> extends Error implements TRPCClientErrorBase<inferErrorShape<TRouterOrProcedure>> {
|
|
122
|
+
/** The error this one wraps, such as a network error. */
|
|
97
123
|
readonly cause: Error | undefined;
|
|
124
|
+
/** The error as the server's error formatter shaped it, if it came from the server. */
|
|
98
125
|
readonly shape: Maybe<inferErrorShape<TRouterOrProcedure>>;
|
|
126
|
+
/** The shape's `data`, such as the tRPC code and HTTP status. */
|
|
99
127
|
readonly data: Maybe<inferErrorShape<TRouterOrProcedure>['data']>;
|
|
100
128
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
129
|
+
* More about the error, if any. HTTP errors may have the `response` and
|
|
130
|
+
* its `responseJSON`; a failed fetch or unparsable response may have
|
|
131
|
+
* neither.
|
|
103
132
|
*/
|
|
104
133
|
meta: Record<string, unknown> | undefined;
|
|
105
134
|
constructor(message: string, opts?: {
|
|
@@ -107,6 +136,10 @@ declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes>
|
|
|
107
136
|
cause?: Error;
|
|
108
137
|
meta?: Record<string, unknown>;
|
|
109
138
|
});
|
|
139
|
+
/**
|
|
140
|
+
* Turns an error response, an `Error` or another object into a
|
|
141
|
+
* `TRPCClientError`. A `TRPCClientError` is returned as it is.
|
|
142
|
+
*/
|
|
110
143
|
static from<TRouterOrProcedure extends InferrableClientTypes>(_cause: Error | TRPCErrorResponse<any> | object, opts?: {
|
|
111
144
|
meta?: Record<string, unknown>;
|
|
112
145
|
cause?: Error;
|
|
@@ -115,13 +148,17 @@ declare class TRPCClientError<TRouterOrProcedure extends InferrableClientTypes>
|
|
|
115
148
|
//#endregion
|
|
116
149
|
//#region src/links/types.d.ts
|
|
117
150
|
/**
|
|
151
|
+
* Context an operation carries through the links, set per call.
|
|
152
|
+
* @see https://trpc.io/docs/client/links#managing-context
|
|
118
153
|
* @internal
|
|
119
154
|
*/
|
|
120
155
|
interface OperationContext extends Record<string, unknown> {}
|
|
121
156
|
/**
|
|
157
|
+
* A procedure call as it goes through the links.
|
|
122
158
|
* @internal
|
|
123
159
|
*/
|
|
124
160
|
type Operation<TInput = unknown> = {
|
|
161
|
+
/** A number unique to the call within its client. */
|
|
125
162
|
id: number;
|
|
126
163
|
type: 'mutation' | 'query' | 'subscription';
|
|
127
164
|
input: TInput;
|
|
@@ -133,16 +170,19 @@ interface HeadersInitEsque {
|
|
|
133
170
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
134
171
|
}
|
|
135
172
|
/**
|
|
173
|
+
* Request headers: a `Headers`-like iterable, or an object.
|
|
136
174
|
* @internal
|
|
137
175
|
*/
|
|
138
176
|
type HTTPHeaders = HeadersInitEsque | Record<string, string[] | string | undefined>;
|
|
139
177
|
/**
|
|
140
|
-
* The
|
|
141
|
-
* only uses the overload taking a string and options object.
|
|
178
|
+
* The `fetch` the HTTP links call: only its `(url, options)` form.
|
|
142
179
|
*/
|
|
143
180
|
type TRPCFetch = (url: string, options?: RequestInit) => Promise<ResponseEsque>;
|
|
181
|
+
/** What a link gets when the client is created. Empty for now. */
|
|
144
182
|
interface TRPCClientRuntime {}
|
|
145
183
|
/**
|
|
184
|
+
* A result a link passes back: data, a subscription's `started` or
|
|
185
|
+
* `stopped` event, or a change of connection state.
|
|
146
186
|
* @internal
|
|
147
187
|
*/
|
|
148
188
|
interface OperationResultEnvelope<TOutput, TError> {
|
|
@@ -150,14 +190,19 @@ interface OperationResultEnvelope<TOutput, TError> {
|
|
|
150
190
|
context?: OperationContext;
|
|
151
191
|
}
|
|
152
192
|
/**
|
|
193
|
+
* The observable of results a link returns for an operation.
|
|
153
194
|
* @internal
|
|
154
195
|
*/
|
|
155
196
|
type OperationResultObservable<TInferrable extends InferrableClientTypes, TOutput> = Observable<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
|
156
197
|
/**
|
|
198
|
+
* An observer of a link's results.
|
|
157
199
|
* @internal
|
|
158
200
|
*/
|
|
159
201
|
type OperationResultObserver<TInferrable extends InferrableClientTypes, TOutput> = Observer<OperationResultEnvelope<TOutput, TRPCClientError<TInferrable>>, TRPCClientError<TInferrable>>;
|
|
160
202
|
/**
|
|
203
|
+
* Handles one operation: pass it on with `next(op)`, or send it and
|
|
204
|
+
* return the results.
|
|
205
|
+
* @see https://trpc.io/docs/client/links#creating-a-custom-link
|
|
161
206
|
* @internal
|
|
162
207
|
*/
|
|
163
208
|
type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown, TOutput = unknown> = (opts: {
|
|
@@ -165,9 +210,12 @@ type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown,
|
|
|
165
210
|
next: (op: Operation<TInput>) => OperationResultObservable<TInferrable, TOutput>;
|
|
166
211
|
}) => OperationResultObservable<TInferrable, TOutput>;
|
|
167
212
|
/**
|
|
213
|
+
* A link: a step every call goes through, such as logging or sending it
|
|
214
|
+
* over HTTP. It's called once when the client is created.
|
|
215
|
+
* @see https://trpc.io/docs/client/links#creating-a-custom-link
|
|
168
216
|
* @public
|
|
169
217
|
*/
|
|
170
218
|
type TRPCLink<TInferrable extends InferrableClientTypes> = (opts: TRPCClientRuntime) => OperationLink<TInferrable>;
|
|
171
219
|
//#endregion
|
|
172
220
|
export { NonEmptyArray as _, OperationResultEnvelope as a, TRPCClientRuntime as c, TRPCClientError as d, TRPCClientErrorBase as f, NativeFetchEsque as g, FetchEsque as h, OperationLink as i, TRPCFetch as l, isTRPCClientError as m, Operation as n, OperationResultObservable as o, TRPCClientErrorLike as p, OperationContext as r, OperationResultObserver as s, HTTPHeaders as t, TRPCLink as u, TRPCProcedureOptions as v };
|
|
173
|
-
//# sourceMappingURL=types-
|
|
221
|
+
//# sourceMappingURL=types-DO-GCB2q.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DO-GCB2q.d.mts","names":[],"sources":["../src/internals/types.ts","../src/TRPCClientError.ts","../src/links/types.ts"],"mappings":";;;;;;;;;;;KAOY,cACV,OAAO,cAAc,cACrB,OAAO,cAAc,qBAClB,QAAQ;;;;;KAMD,oBACV,KAAK,cACL,OAAO,8BACJ,QAAQ;UAEI;EACf;;;;;;;;;UAUe;;;;EAIf,OAAO,2BAA2B,WAAW,eAAe,OAAO;;;;EAKnE,+BAA+B;;;;EAK/B;;;;EAKA,SAAS;;;;;;KAOC;EACV,iBAAiB,4BAA4B;;KAGnC;EACV,GACE,4BACA,cAAc,uBACb;;;;;;UAOY;WACN;WACA,OAAO,4BAA4B;;;;;;;EAO5C,QAAQ;;;;;KAME,cAAc,UAAU,UAAU;KAEzC,gBAAgB;;;;;;UAOJ;;;;;EAKf,UAAU;;;;;;EAMV,SAAS;;;;KCjGN,gBAAgB,oBAAoB,yBACvC,iBAAiB;;UAEF,oBAAoB,eAAe;WACzC;;WAEA,OAAO,MAAM;;WAEb,MAAM,MAAM;;;;;;;KAOX,oBAAoB,oBAAoB,yBAClD,oBAAoB,gBAAgB;;;;;iBAMtB,kBAAkB,oBAAoB,uBACpD,iBACC,SAAS,gBAAgB;;;;;;cA4Bf,gBAAgB,2BAA2B,+BAC9C,iBACG,oBAAoB,gBAAgB;;WAKtB,OAAK;;WAEd,OAAO,MAAM,gBAAgB;;WAE7B,MAAM,MAAM,gBAAgB;;;;;;EAOrC,MAAI;EAEX,YACE,iBACA;IACE,SAAS,MAAM,kBAAkB,gBAAgB;IACjD,QAAQ;IACR,OAAO;;;;;;SAuBG,KAAK,2BAA2B,uBAC5C,QAAQ,QAAQ,iCAChB;IAAQ,OAAO;IAAyB,QAAQ;MAC/C,gBAAgB;;;;;;;;;UC5FJ,yBAAyB;;;;;KAM9B,UAAU;;EAEpB;EACA;EACA,OAAO;EACP;EACA,SAAS;EACT,QAAQ,MAAM;;UAGN;GACP,OAAO,aAAa;;;;;;KAOX,cACR,mBACA;;;;KAKQ,aACV,aACA,UAAU,gBACP,QAAQ;;UAGI;;;;;;UASA,wBAAwB,SAAS;EAChD,QACI,kBAAkB,qBAClB,oBAAoB,qBACpB,oBAAoB;EACxB,UAAU;;;;;;KAOA,0BACV,oBAAoB,uBACpB,WACE,WACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;KAON,wBACV,oBAAoB,uBACpB,WACE,SACF,wBAAwB,SAAS,gBAAgB,eACjD,gBAAgB;;;;;;;KASN,cACV,oBAAoB,uBACpB,kBACA,sBACG;EACH,IAAI,UAAU;EACd,OACE,IAAI,UAAU,YACX,0BAA0B,aAAa;MACxC,0BAA0B,aAAa;;;;;;;KAQjC,SAAS,oBAAoB,0BACvC,MAAM,sBACH,cAAc"}
|
|
@@ -11,7 +11,7 @@ type TransformerOptionYes = {
|
|
|
11
11
|
* Data transformer
|
|
12
12
|
*
|
|
13
13
|
* You must use the same transformer on the backend and frontend
|
|
14
|
-
* @see https://trpc.io/docs/
|
|
14
|
+
* @see https://trpc.io/docs/server/data-transformers
|
|
15
15
|
**/
|
|
16
16
|
transformer: DataTransformerOptions;
|
|
17
17
|
};
|
|
@@ -20,9 +20,9 @@ type TransformerOptionNo = {
|
|
|
20
20
|
* Data transformer
|
|
21
21
|
*
|
|
22
22
|
* You must use the same transformer on the backend and frontend
|
|
23
|
-
* @see https://trpc.io/docs/
|
|
23
|
+
* @see https://trpc.io/docs/server/data-transformers
|
|
24
24
|
**/
|
|
25
|
-
transformer?: TypeError<'You must define a transformer on your
|
|
25
|
+
transformer?: TypeError<'You must define a transformer on your `initTRPC`-object first'>;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* @internal
|
|
@@ -41,4 +41,4 @@ declare function getTransformer(transformer: TransformerOptions<{
|
|
|
41
41
|
}>['transformer'] | undefined): CombinedDataTransformer;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { TransformerOptions as n, getTransformer as r, CoercedTransformerParameters as t };
|
|
44
|
-
//# sourceMappingURL=unstable-internals-
|
|
44
|
+
//# sourceMappingURL=unstable-internals-CNoyg7Yf.d.cts.map
|
package/dist/{unstable-internals-CE8gFBQ9.d.cts.map → unstable-internals-CNoyg7Yf.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-internals-
|
|
1
|
+
{"version":3,"file":"unstable-internals-CNoyg7Yf.d.cts","names":[],"sources":["../src/internals/transformer.ts"],"mappings":";;;;;KAUY;EACV,cAAc;;KAGX;;;;;;;EAOH,aAAa;;KAEV;;;;;;;EAOH,cAAc;;;;;KAMJ,mBACV,cAAc,KAAK,kCACjB,oCACA,uBACA;;;;;;;iBAQY,eACd,aACI;EAAqB;oBACrB;EAAqB;gCAExB"}
|
|
@@ -11,7 +11,7 @@ type TransformerOptionYes = {
|
|
|
11
11
|
* Data transformer
|
|
12
12
|
*
|
|
13
13
|
* You must use the same transformer on the backend and frontend
|
|
14
|
-
* @see https://trpc.io/docs/
|
|
14
|
+
* @see https://trpc.io/docs/server/data-transformers
|
|
15
15
|
**/
|
|
16
16
|
transformer: DataTransformerOptions;
|
|
17
17
|
};
|
|
@@ -20,9 +20,9 @@ type TransformerOptionNo = {
|
|
|
20
20
|
* Data transformer
|
|
21
21
|
*
|
|
22
22
|
* You must use the same transformer on the backend and frontend
|
|
23
|
-
* @see https://trpc.io/docs/
|
|
23
|
+
* @see https://trpc.io/docs/server/data-transformers
|
|
24
24
|
**/
|
|
25
|
-
transformer?: TypeError<'You must define a transformer on your
|
|
25
|
+
transformer?: TypeError<'You must define a transformer on your `initTRPC`-object first'>;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* @internal
|
|
@@ -41,4 +41,4 @@ declare function getTransformer(transformer: TransformerOptions<{
|
|
|
41
41
|
}>['transformer'] | undefined): CombinedDataTransformer;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { TransformerOptions as n, getTransformer as r, CoercedTransformerParameters as t };
|
|
44
|
-
//# sourceMappingURL=unstable-internals-
|
|
44
|
+
//# sourceMappingURL=unstable-internals-CNoyg7Yf.d.mts.map
|
package/dist/{unstable-internals-CE8gFBQ9.d.mts.map → unstable-internals-CNoyg7Yf.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-internals-
|
|
1
|
+
{"version":3,"file":"unstable-internals-CNoyg7Yf.d.mts","names":[],"sources":["../src/internals/transformer.ts"],"mappings":";;;;;KAUY;EACV,cAAc;;KAGX;;;;;;;EAOH,aAAa;;KAEV;;;;;;;EAOH,cAAc;;;;;KAMJ,mBACV,cAAc,KAAK,kCACjB,oCACA,uBACA;;;;;;;iBAQY,eACd,aACI;EAAqB;oBACrB;EAAqB;gCAExB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as TRPCConnectionState } from "./subscriptions-DcqRZc4h.cjs";
|
|
2
|
-
import { n as TransformerOptions, r as getTransformer, t as CoercedTransformerParameters } from "./unstable-internals-
|
|
2
|
+
import { n as TransformerOptions, r as getTransformer, t as CoercedTransformerParameters } from "./unstable-internals-CNoyg7Yf.cjs";
|
|
3
3
|
export { CoercedTransformerParameters, TRPCConnectionState, TransformerOptions, getTransformer };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as TRPCConnectionState } from "./subscriptions-DcqRZc4h.mjs";
|
|
2
|
-
import { n as TransformerOptions, r as getTransformer, t as CoercedTransformerParameters } from "./unstable-internals-
|
|
2
|
+
import { n as TransformerOptions, r as getTransformer, t as CoercedTransformerParameters } from "./unstable-internals-CNoyg7Yf.mjs";
|
|
3
3
|
export { CoercedTransformerParameters, TRPCConnectionState, TransformerOptions, getTransformer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-internals.mjs","names":[],"sources":["../src/internals/transformer.ts"],"sourcesContent":["import type {\n AnyClientTypes,\n CombinedDataTransformer,\n DataTransformerOptions,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\n\n/**\n * @internal\n */\nexport type CoercedTransformerParameters = {\n transformer?: DataTransformerOptions;\n};\n\ntype TransformerOptionYes = {\n /**\n * Data transformer\n *\n * You must use the same transformer on the backend and frontend\n * @see https://trpc.io/docs/
|
|
1
|
+
{"version":3,"file":"unstable-internals.mjs","names":[],"sources":["../src/internals/transformer.ts"],"sourcesContent":["import type {\n AnyClientTypes,\n CombinedDataTransformer,\n DataTransformerOptions,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\n\n/**\n * @internal\n */\nexport type CoercedTransformerParameters = {\n transformer?: DataTransformerOptions;\n};\n\ntype TransformerOptionYes = {\n /**\n * Data transformer\n *\n * You must use the same transformer on the backend and frontend\n * @see https://trpc.io/docs/server/data-transformers\n **/\n transformer: DataTransformerOptions;\n};\ntype TransformerOptionNo = {\n /**\n * Data transformer\n *\n * You must use the same transformer on the backend and frontend\n * @see https://trpc.io/docs/server/data-transformers\n **/\n transformer?: TypeError<'You must define a transformer on your `initTRPC`-object first'>;\n};\n\n/**\n * @internal\n */\nexport type TransformerOptions<\n TRoot extends Pick<AnyClientTypes, 'transformer'>,\n> = TRoot['transformer'] extends true\n ? TransformerOptionYes\n : TransformerOptionNo;\n/**\n * @internal\n */\n\n/**\n * @internal\n */\nexport function getTransformer(\n transformer:\n | TransformerOptions<{ transformer: false }>['transformer']\n | TransformerOptions<{ transformer: true }>['transformer']\n | undefined,\n): CombinedDataTransformer {\n const _transformer =\n transformer as CoercedTransformerParameters['transformer'];\n if (!_transformer) {\n return {\n input: {\n serialize: (data) => data,\n deserialize: (data) => data,\n },\n output: {\n serialize: (data) => data,\n deserialize: (data) => data,\n },\n };\n }\n if ('input' in _transformer) {\n return _transformer;\n }\n return {\n input: _transformer,\n output: _transformer,\n };\n}\n"],"mappings":";;;;;;;AAgDA,SAAgB,eACd,aAIyB;CACzB,MAAM,eACJ;CACF,IAAI,CAAC,cACH,OAAO;EACL,OAAO;GACL,YAAY,SAAS;GACrB,cAAc,SAAS;EACzB;EACA,QAAQ;GACN,YAAY,SAAS;GACrB,cAAc,SAAS;EACzB;CACF;CAEF,IAAI,WAAW,cACb,OAAO;CAET,OAAO;EACL,OAAO;EACP,QAAQ;CACV;AACF"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
const require_objectSpread2 = require("./objectSpread2-D-dJi1gK.cjs");
|
|
2
|
-
const require_TRPCClientError = require("./TRPCClientError-
|
|
2
|
+
const require_TRPCClientError = require("./TRPCClientError-CPEwAI4E.cjs");
|
|
3
3
|
const require_unstable_internals = require("./unstable-internals.cjs");
|
|
4
4
|
let _trpc_server_observable = require("@trpc/server/observable");
|
|
5
5
|
let _trpc_server_unstable_core_do_not_import = require("@trpc/server/unstable-core-do-not-import");
|
|
6
6
|
//#region src/links/wsLink/wsClient/encoder.ts
|
|
7
|
+
/**
|
|
8
|
+
* The default WebSocket encoder. Sends messages as JSON text frames.
|
|
9
|
+
*/
|
|
7
10
|
const jsonEncoder = {
|
|
8
11
|
encode: (data) => JSON.stringify(data),
|
|
9
12
|
decode: (data) => {
|
|
@@ -518,6 +521,9 @@ var WsClient = class {
|
|
|
518
521
|
};
|
|
519
522
|
});
|
|
520
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* The current WebSocket and its state, or `null` when there is no socket.
|
|
526
|
+
*/
|
|
521
527
|
get connection() {
|
|
522
528
|
return backwardCompatibility(this.activeConnection);
|
|
523
529
|
}
|
|
@@ -646,11 +652,22 @@ var WsClient = class {
|
|
|
646
652
|
};
|
|
647
653
|
//#endregion
|
|
648
654
|
//#region src/links/wsLink/createWsClient.ts
|
|
655
|
+
/**
|
|
656
|
+
* Opens and manages a WebSocket connection to a tRPC server. Pass it to
|
|
657
|
+
* `wsLink`.
|
|
658
|
+
*
|
|
659
|
+
* @see https://trpc.io/docs/client/links/wsLink#wslink--createwsclient-options
|
|
660
|
+
*/
|
|
649
661
|
function createWSClient(opts) {
|
|
650
662
|
return new WsClient(opts);
|
|
651
663
|
}
|
|
652
664
|
//#endregion
|
|
653
665
|
//#region src/links/wsLink/wsLink.ts
|
|
666
|
+
/**
|
|
667
|
+
* A terminating link that sends calls over a WebSocket.
|
|
668
|
+
*
|
|
669
|
+
* @see https://trpc.io/docs/client/links/wsLink
|
|
670
|
+
*/
|
|
654
671
|
function wsLink(opts) {
|
|
655
672
|
const { client } = opts;
|
|
656
673
|
const transformer = require_unstable_internals.getTransformer(opts.transformer);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { n as _defineProperty, t as _objectSpread2 } from "./objectSpread2-weooBxVk.mjs";
|
|
2
|
-
import { t as TRPCClientError } from "./TRPCClientError-
|
|
2
|
+
import { t as TRPCClientError } from "./TRPCClientError-Byo7P4QG.mjs";
|
|
3
3
|
import { getTransformer } from "./unstable-internals.mjs";
|
|
4
4
|
import { behaviorSubject, observable } from "@trpc/server/observable";
|
|
5
5
|
import { run, sleep, transformResult } from "@trpc/server/unstable-core-do-not-import";
|
|
6
6
|
//#region src/links/wsLink/wsClient/encoder.ts
|
|
7
|
+
/**
|
|
8
|
+
* The default WebSocket encoder. Sends messages as JSON text frames.
|
|
9
|
+
*/
|
|
7
10
|
const jsonEncoder = {
|
|
8
11
|
encode: (data) => JSON.stringify(data),
|
|
9
12
|
decode: (data) => {
|
|
@@ -518,6 +521,9 @@ var WsClient = class {
|
|
|
518
521
|
};
|
|
519
522
|
});
|
|
520
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* The current WebSocket and its state, or `null` when there is no socket.
|
|
526
|
+
*/
|
|
521
527
|
get connection() {
|
|
522
528
|
return backwardCompatibility(this.activeConnection);
|
|
523
529
|
}
|
|
@@ -646,11 +652,22 @@ var WsClient = class {
|
|
|
646
652
|
};
|
|
647
653
|
//#endregion
|
|
648
654
|
//#region src/links/wsLink/createWsClient.ts
|
|
655
|
+
/**
|
|
656
|
+
* Opens and manages a WebSocket connection to a tRPC server. Pass it to
|
|
657
|
+
* `wsLink`.
|
|
658
|
+
*
|
|
659
|
+
* @see https://trpc.io/docs/client/links/wsLink#wslink--createwsclient-options
|
|
660
|
+
*/
|
|
649
661
|
function createWSClient(opts) {
|
|
650
662
|
return new WsClient(opts);
|
|
651
663
|
}
|
|
652
664
|
//#endregion
|
|
653
665
|
//#region src/links/wsLink/wsLink.ts
|
|
666
|
+
/**
|
|
667
|
+
* A terminating link that sends calls over a WebSocket.
|
|
668
|
+
*
|
|
669
|
+
* @see https://trpc.io/docs/client/links/wsLink
|
|
670
|
+
*/
|
|
654
671
|
function wsLink(opts) {
|
|
655
672
|
const { client } = opts;
|
|
656
673
|
const transformer = getTransformer(opts.transformer);
|
|
@@ -678,4 +695,4 @@ function wsLink(opts) {
|
|
|
678
695
|
//#endregion
|
|
679
696
|
export { jsonEncoder as i, createWSClient as n, resultOf as r, wsLink as t };
|
|
680
697
|
|
|
681
|
-
//# sourceMappingURL=wsLink
|
|
698
|
+
//# sourceMappingURL=wsLink-CDaUjHvu.mjs.map
|