@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.239 → 11.0.0-alpha-tmp-export-from-main.219
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/@trpc-server/http.d.ts +2 -0
- package/dist/@trpc-server/http.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.ts +2 -1
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +4 -6
- package/dist/adapters/aws-lambda/index.mjs +2 -4
- package/dist/adapters/aws-lambda/utils.d.ts +3 -2
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/utils.js +4 -5
- package/dist/adapters/aws-lambda/utils.mjs +2 -3
- package/dist/adapters/express.d.ts +2 -1
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +3 -6
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +1 -4
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +2 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -0
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -1
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +4 -6
- package/dist/adapters/fetch/fetchRequestHandler.mjs +2 -4
- package/dist/adapters/fetch/types.d.ts +3 -2
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +3 -1
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +4 -6
- package/dist/adapters/next.mjs +2 -4
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +2 -4
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +1 -3
- package/dist/adapters/node-http/content-type/json/index.js +2 -4
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
- package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +2 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +4 -6
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +2 -4
- package/dist/adapters/node-http/types.d.ts +4 -3
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +2 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +0 -1
- package/dist/adapters/standalone.mjs +0 -1
- package/dist/adapters/ws.d.ts +2 -3
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -33
- package/dist/adapters/ws.mjs +1 -8
- package/dist/http.d.ts +6 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -11
- package/dist/http.mjs +1 -6
- package/dist/index.d.ts +68 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -18
- package/dist/index.mjs +1 -8
- package/dist/observable.d.ts +3 -0
- package/dist/observable.d.ts.map +1 -0
- package/dist/observable.js +30 -0
- package/dist/observable.mjs +1 -0
- package/dist/rpc.d.ts +2 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -6
- package/dist/rpc.mjs +1 -3
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +9 -6
- package/dist/shared.mjs +1 -4
- package/dist/unstableDontImportMe.d.ts +10 -0
- package/dist/unstableDontImportMe.d.ts.map +1 -0
- package/dist/unstableDontImportMe.js +142 -0
- package/dist/unstableDontImportMe.mjs +1 -0
- package/package.json +135 -52
- package/src/@trpc-server/http.ts +2 -0
- package/src/adapters/aws-lambda/index.ts +5 -4
- package/src/adapters/aws-lambda/utils.ts +4 -3
- package/src/adapters/express.ts +3 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +4 -6
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +2 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +4 -6
- package/src/adapters/fetch/types.ts +3 -2
- package/src/adapters/next.ts +4 -2
- package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
- package/src/adapters/node-http/content-type/json/index.ts +1 -1
- package/src/adapters/node-http/internals/contentType.ts +2 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -6
- package/src/adapters/node-http/types.ts +5 -4
- package/src/adapters/standalone.ts +2 -2
- package/src/adapters/ws.ts +13 -14
- package/src/http.ts +26 -1
- package/src/index.ts +105 -1
- package/src/observable.ts +16 -0
- package/src/rpc.ts +26 -1
- package/src/shared.ts +1 -1
- package/src/unstableDontImportMe.ts +146 -0
- package/unstableDontImportMe/index.d.ts +1 -0
- package/unstableDontImportMe/index.js +1 -0
- package/dist/@trpc/server/http.d.ts +0 -7
- package/dist/@trpc/server/http.d.ts.map +0 -1
- package/dist/@trpc/server/index.d.ts +0 -69
- package/dist/@trpc/server/index.d.ts.map +0 -1
- package/dist/@trpc/server/rpc.d.ts +0 -3
- package/dist/@trpc/server/rpc.d.ts.map +0 -1
- package/dist/bundle-analysis.json +0 -757
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -13
- package/dist/observable/index.mjs +0 -2
- package/dist/observable/observable.d.ts +0 -13
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/observable.js +0 -126
- package/dist/observable/observable.mjs +0 -122
- package/dist/observable/operators.d.ts +0 -8
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/operators.js +0 -103
- package/dist/observable/operators.mjs +0 -99
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.js +0 -52
- package/dist/unstable-core-do-not-import/createProxy.mjs +0 -49
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +0 -67
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +0 -63
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +0 -7
- package/dist/unstable-core-do-not-import/error/formatter.mjs +0 -5
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +0 -31
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +0 -29
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.js +0 -32
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.mjs +0 -30
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +0 -54
- package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -52
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +0 -51
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +0 -48
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +0 -295
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +0 -293
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.d.ts +0 -37
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -48
- package/dist/unstable-core-do-not-import/index.mjs +0 -16
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +0 -95
- package/dist/unstable-core-do-not-import/initTRPC.mjs +0 -93
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.js +0 -95
- package/dist/unstable-core-do-not-import/middleware.mjs +0 -89
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.js +0 -37
- package/dist/unstable-core-do-not-import/parser.mjs +0 -35
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.js +0 -9
- package/dist/unstable-core-do-not-import/procedure.mjs +0 -7
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -176
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +0 -173
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.js +0 -8
- package/dist/unstable-core-do-not-import/rootConfig.mjs +0 -6
- package/dist/unstable-core-do-not-import/router.d.ts +0 -85
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.js +0 -156
- package/dist/unstable-core-do-not-import/router.mjs +0 -151
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.js +0 -38
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +0 -35
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +0 -59
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +0 -57
- package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.js +0 -107
- package/dist/unstable-core-do-not-import/transformer.mjs +0 -102
- package/dist/unstable-core-do-not-import/types.d.ts +0 -98
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -27
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.js +0 -44
- package/dist/unstable-core-do-not-import/utils.mjs +0 -39
- package/src/@trpc/server/http.ts +0 -26
- package/src/@trpc/server/index.ts +0 -105
- package/src/@trpc/server/rpc.ts +0 -26
- package/src/observable/index.ts +0 -10
- package/src/observable/observable.ts +0 -158
- package/src/observable/operators.ts +0 -119
- package/src/observable/types.ts +0 -76
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
- package/src/unstable-core-do-not-import/createProxy.ts +0 -59
- package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
- package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
- package/src/unstable-core-do-not-import/http/index.ts +0 -23
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
- package/src/unstable-core-do-not-import/http/types.ts +0 -111
- package/src/unstable-core-do-not-import/index.ts +0 -110
- package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
- package/src/unstable-core-do-not-import/middleware.ts +0 -233
- package/src/unstable-core-do-not-import/parser.ts +0 -94
- package/src/unstable-core-do-not-import/procedure.ts +0 -108
- package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
- package/src/unstable-core-do-not-import/router.ts +0 -370
- package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
- package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
- package/src/unstable-core-do-not-import/serialize.ts +0 -122
- package/src/unstable-core-do-not-import/transformer.ts +0 -202
- package/src/unstable-core-do-not-import/types.ts +0 -151
- package/src/unstable-core-do-not-import/utils.ts +0 -59
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { Simplify, WithoutIndexSignature } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @link https://github.com/remix-run/remix/blob/2248669ed59fd716e267ea41df5d665d4781f4a9/packages/remix-server-runtime/serialize.ts
|
|
4
|
-
*/
|
|
5
|
-
type JsonPrimitive = boolean | number | string | null;
|
|
6
|
-
type NonJsonPrimitive = Function | symbol | undefined;
|
|
7
|
-
type IsAny<T> = 0 extends T & 1 ? true : false;
|
|
8
|
-
type JsonReturnable = JsonPrimitive | undefined;
|
|
9
|
-
type IsRecord<T extends object> = keyof WithoutIndexSignature<T> extends never ? true : false;
|
|
10
|
-
export type Serialize<T> = IsAny<T> extends true ? any : unknown extends T ? unknown : T extends JsonReturnable ? T : T extends Map<any, any> | Set<any> ? object : T extends NonJsonPrimitive ? never : T extends {
|
|
11
|
-
toJSON(): infer U;
|
|
12
|
-
} ? U : T extends [] ? [] : T extends [unknown, ...unknown[]] ? SerializeTuple<T> : T extends readonly (infer U)[] ? (U extends NonJsonPrimitive ? null : Serialize<U>)[] : T extends object ? IsRecord<T> extends true ? Record<keyof T, Serialize<T[keyof T]>> : Simplify<SerializeObject<UndefinedToOptional<T>>> : never;
|
|
13
|
-
/** JSON serialize [tuples](https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types) */
|
|
14
|
-
type SerializeTuple<T extends [unknown, ...unknown[]]> = {
|
|
15
|
-
[K in keyof T]: T[K] extends NonJsonPrimitive ? null : Serialize<T[K]>;
|
|
16
|
-
};
|
|
17
|
-
type SerializeObjectKey<T extends Record<any, any>, K> = K extends symbol ? never : IsAny<T[K]> extends true ? K : unknown extends T[K] ? K : T[K] extends NonJsonPrimitive ? never : K;
|
|
18
|
-
/**
|
|
19
|
-
* JSON serialize objects (not including arrays) and classes
|
|
20
|
-
* @internal
|
|
21
|
-
**/
|
|
22
|
-
export type SerializeObject<T extends object> = {
|
|
23
|
-
[K in keyof T as SerializeObjectKey<T, K>]: Serialize<T[K]>;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Extract keys from T where the value dosen't extend undefined
|
|
27
|
-
* Note: Can't parse IndexSignature or Record types
|
|
28
|
-
*/
|
|
29
|
-
type FilterDefinedKeys<T extends object> = Exclude<{
|
|
30
|
-
[K in keyof T]: undefined extends T[K] ? never : K;
|
|
31
|
-
}[keyof T], undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Get value of exactOptionalPropertyTypes config
|
|
34
|
-
*/
|
|
35
|
-
type ExactOptionalPropertyTypes = {
|
|
36
|
-
a?: 0 | undefined;
|
|
37
|
-
} extends {
|
|
38
|
-
a?: 0;
|
|
39
|
-
} ? false : true;
|
|
40
|
-
/**
|
|
41
|
-
* Check if T has an index signature
|
|
42
|
-
*/
|
|
43
|
-
type HasIndexSignature<T extends object> = string extends keyof T ? true : false;
|
|
44
|
-
/**
|
|
45
|
-
* { [key: string]: number | undefined } --> { [key: string]: number }
|
|
46
|
-
*/
|
|
47
|
-
type HandleIndexSignature<T extends object> = {
|
|
48
|
-
[K in keyof Omit<T, keyof WithoutIndexSignature<T>>]: Exclude<T[K], undefined>;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* { a: number | undefined } --> { a?: number }
|
|
52
|
-
* Note: Can't parse IndexSignature or Record types
|
|
53
|
-
*/
|
|
54
|
-
type HandleUndefined<T extends object> = {
|
|
55
|
-
[K in keyof Omit<T, FilterDefinedKeys<T>>]?: Exclude<T[K], undefined>;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Handle undefined, index signature and records
|
|
59
|
-
*/
|
|
60
|
-
type UndefinedToOptional<T extends object> = Pick<WithoutIndexSignature<T>, FilterDefinedKeys<WithoutIndexSignature<T>>> & (ExactOptionalPropertyTypes extends true ? HandleIndexSignature<T> & HandleUndefined<WithoutIndexSignature<T>> : HasIndexSignature<T> extends true ? HandleIndexSignature<T> : HandleUndefined<T>);
|
|
61
|
-
export {};
|
|
62
|
-
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/serialize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE/D;;GAEG;AACH,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEtD,KAAK,gBAAgB,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAKtD,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAK/C,KAAK,cAAc,GAAG,aAAa,GAAG,SAAS,CAAC;AAEhD,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,MAAM,qBAAqB,CAAC,CAAC,CAAC,SAAS,KAAK,GAC1E,IAAI,GACJ,KAAK,CAAC;AAGV,MAAM,MAAM,SAAS,CAAC,CAAC,IACrB,KAAK,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,GAAG,GAC3B,OAAO,SAAS,CAAC,GAAG,OAAO,GAC3B,CAAC,SAAS,cAAc,GAAG,CAAC,GAC5B,CAAC,SAAS,GAAG,CAAC,GAAG,EA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AAM,IAEvC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,GAEzE,CAAC,0BAA0B,SAAS,IAAI,GACpC,oBAAoB,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,GACnE,iBAAiB,CAAC,CAAC,CAAC,SAAS,IAAI,GACjC,oBAAoB,CAAC,CAAC,CAAC,GACvB,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { AnyRootConfig } from './rootConfig';
|
|
2
|
-
import type { AnyRouter, inferRouterError } from './router';
|
|
3
|
-
import type { TRPCResponse, TRPCResponseMessage, TRPCResultMessage } from './rpc';
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export interface DataTransformer {
|
|
8
|
-
serialize: (object: any) => any;
|
|
9
|
-
deserialize: (object: any) => any;
|
|
10
|
-
}
|
|
11
|
-
interface InputDataTransformer extends DataTransformer {
|
|
12
|
-
/**
|
|
13
|
-
* This function runs **on the client** before sending the data to the server.
|
|
14
|
-
*/
|
|
15
|
-
serialize: (object: any) => any;
|
|
16
|
-
/**
|
|
17
|
-
* This function runs **on the server** to transform the data before it is passed to the resolver
|
|
18
|
-
*/
|
|
19
|
-
deserialize: (object: any) => any;
|
|
20
|
-
}
|
|
21
|
-
interface OutputDataTransformer extends DataTransformer {
|
|
22
|
-
/**
|
|
23
|
-
* This function runs **on the server** before sending the data to the client.
|
|
24
|
-
*/
|
|
25
|
-
serialize: (object: any) => any;
|
|
26
|
-
/**
|
|
27
|
-
* This function runs **only on the client** to transform the data sent from the server.
|
|
28
|
-
*/
|
|
29
|
-
deserialize: (object: any) => any;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export interface CombinedDataTransformer {
|
|
35
|
-
/**
|
|
36
|
-
* Specify how the data sent from the client to the server should be transformed.
|
|
37
|
-
*/
|
|
38
|
-
input: InputDataTransformer;
|
|
39
|
-
/**
|
|
40
|
-
* Specify how the data sent from the server to the client should be transformed.
|
|
41
|
-
*/
|
|
42
|
-
output: OutputDataTransformer;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
export type CombinedDataTransformerClient = {
|
|
48
|
-
input: Pick<CombinedDataTransformer['input'], 'serialize'>;
|
|
49
|
-
output: Pick<CombinedDataTransformer['output'], 'deserialize'>;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* @public
|
|
53
|
-
*/
|
|
54
|
-
export type DataTransformerOptions = CombinedDataTransformer | DataTransformer;
|
|
55
|
-
/**
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
export declare function getDataTransformer(transformer: DataTransformerOptions): CombinedDataTransformer;
|
|
59
|
-
/**
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
export type DefaultDataTransformer = CombinedDataTransformer & {
|
|
63
|
-
_default: true;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* @internal
|
|
67
|
-
*/
|
|
68
|
-
export declare const defaultTransformer: DefaultDataTransformer;
|
|
69
|
-
/**
|
|
70
|
-
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
71
|
-
**/
|
|
72
|
-
export declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[] | TRPCResponseMessage | TRPCResponseMessage[]>(config: AnyRootConfig, itemOrItems: TResponse): import("./rpc").TRPCErrorResponse<import("./rpc").TRPCErrorShape<import("./rpc").TRPC_ERROR_CODE_NUMBER, Record<string, unknown>>> | import("./rpc").TRPCSuccessResponse<unknown> | ({
|
|
73
|
-
id: import("./rpc").JSONRPC2.RequestId;
|
|
74
|
-
} & TRPCResultMessage<unknown>) | (TRPCResponse | TRPCResponseMessage)[];
|
|
75
|
-
/** @internal */
|
|
76
|
-
declare function transformResultInner<TRouter extends AnyRouter, TOutput>(response: TRPCResponse<TOutput, inferRouterError<TRouter>> | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>, transformer: DataTransformer): {
|
|
77
|
-
readonly ok: false;
|
|
78
|
-
readonly error: {
|
|
79
|
-
readonly error: inferRouterError<TRouter>;
|
|
80
|
-
readonly id?: import("./rpc").JSONRPC2.RequestId | undefined;
|
|
81
|
-
readonly jsonrpc?: "2.0" | undefined;
|
|
82
|
-
} | {
|
|
83
|
-
readonly error: inferRouterError<TRouter>;
|
|
84
|
-
readonly id: string | number | null;
|
|
85
|
-
readonly jsonrpc?: "2.0" | undefined;
|
|
86
|
-
};
|
|
87
|
-
readonly result?: undefined;
|
|
88
|
-
} | {
|
|
89
|
-
readonly ok: true;
|
|
90
|
-
readonly result: {
|
|
91
|
-
type: "started";
|
|
92
|
-
data?: undefined;
|
|
93
|
-
} | {
|
|
94
|
-
type: "stopped";
|
|
95
|
-
data?: undefined;
|
|
96
|
-
} | (import("./rpc").TRPCResult<TOutput> & {
|
|
97
|
-
type: "data";
|
|
98
|
-
});
|
|
99
|
-
readonly error?: undefined;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Transforms and validates that the result is a valid TRPCResponse
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
105
|
-
export declare function transformResult<TRouter extends AnyRouter, TOutput>(response: TRPCResponse<TOutput, inferRouterError<TRouter>> | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>, transformer: DataTransformer): ReturnType<typeof transformResultInner>;
|
|
106
|
-
export {};
|
|
107
|
-
//# sourceMappingURL=transformer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO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GAAG;IAC7D,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,sBAIhC,CAAC;AAyBF;;IAEI;AACJ,wBAAgB,qBAAqB,CACnC,SAAS,SACL,YAAY,GACZ,YAAY,EAAE,GACd,mBAAmB,GACnB,mBAAmB,EAAE,EACzB,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS;;yEAI9C;AAKD,gBAAgB;AAChB,iBAAS,oBAAoB,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,EAC9D,QAAQ,EACJ,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAChD,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAC3D,WAAW,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;EAuB7B;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,EAChE,QAAQ,EACJ,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAChD,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAC3D,WAAW,EAAE,eAAe,GAC3B,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAqBzC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var utils = require('./utils.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/ function getDataTransformer(transformer) {
|
|
8
|
-
if ('input' in transformer) {
|
|
9
|
-
return transformer;
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
input: transformer,
|
|
13
|
-
output: transformer
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @internal
|
|
18
|
-
*/ const defaultTransformer = {
|
|
19
|
-
_default: true,
|
|
20
|
-
input: {
|
|
21
|
-
serialize: (obj)=>obj,
|
|
22
|
-
deserialize: (obj)=>obj
|
|
23
|
-
},
|
|
24
|
-
output: {
|
|
25
|
-
serialize: (obj)=>obj,
|
|
26
|
-
deserialize: (obj)=>obj
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
function transformTRPCResponseItem(config, item) {
|
|
30
|
-
if ('error' in item) {
|
|
31
|
-
return {
|
|
32
|
-
...item,
|
|
33
|
-
error: config.transformer.output.serialize(item.error)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if ('data' in item.result) {
|
|
37
|
-
return {
|
|
38
|
-
...item,
|
|
39
|
-
result: {
|
|
40
|
-
...item.result,
|
|
41
|
-
data: config.transformer.output.serialize(item.result.data)
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return item;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
49
|
-
**/ function transformTRPCResponse(config, itemOrItems) {
|
|
50
|
-
return Array.isArray(itemOrItems) ? itemOrItems.map((item)=>transformTRPCResponseItem(config, item)) : transformTRPCResponseItem(config, itemOrItems);
|
|
51
|
-
}
|
|
52
|
-
// FIXME:
|
|
53
|
-
// - the generics here are probably unnecessary
|
|
54
|
-
// - the RPC-spec could probably be simplified to combine HTTP + WS
|
|
55
|
-
/** @internal */ function transformResultInner(response, transformer) {
|
|
56
|
-
if ('error' in response) {
|
|
57
|
-
const error = transformer.deserialize(response.error);
|
|
58
|
-
return {
|
|
59
|
-
ok: false,
|
|
60
|
-
error: {
|
|
61
|
-
...response,
|
|
62
|
-
error
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const result = {
|
|
67
|
-
...response.result,
|
|
68
|
-
...(!response.result.type || response.result.type === 'data') && {
|
|
69
|
-
type: 'data',
|
|
70
|
-
data: transformer.deserialize(response.result.data)
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
return {
|
|
74
|
-
ok: true,
|
|
75
|
-
result
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
class TransformResultError extends Error {
|
|
79
|
-
constructor(){
|
|
80
|
-
super('Unable to transform response from server');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Transforms and validates that the result is a valid TRPCResponse
|
|
85
|
-
* @internal
|
|
86
|
-
*/ function transformResult(response, transformer) {
|
|
87
|
-
let result;
|
|
88
|
-
try {
|
|
89
|
-
// Use the data transformers on the JSON-response
|
|
90
|
-
result = transformResultInner(response, transformer);
|
|
91
|
-
} catch (err) {
|
|
92
|
-
throw new TransformResultError();
|
|
93
|
-
}
|
|
94
|
-
// check that output of the transformers is a valid TRPCResponse
|
|
95
|
-
if (!result.ok && (!utils.isObject(result.error.error) || typeof result.error.error['code'] !== 'number')) {
|
|
96
|
-
throw new TransformResultError();
|
|
97
|
-
}
|
|
98
|
-
if (result.ok && !utils.isObject(result.result)) {
|
|
99
|
-
throw new TransformResultError();
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exports.defaultTransformer = defaultTransformer;
|
|
105
|
-
exports.getDataTransformer = getDataTransformer;
|
|
106
|
-
exports.transformResult = transformResult;
|
|
107
|
-
exports.transformTRPCResponse = transformTRPCResponse;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { isObject } from './utils.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/ function getDataTransformer(transformer) {
|
|
6
|
-
if ('input' in transformer) {
|
|
7
|
-
return transformer;
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
input: transformer,
|
|
11
|
-
output: transformer
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
*/ const defaultTransformer = {
|
|
17
|
-
_default: true,
|
|
18
|
-
input: {
|
|
19
|
-
serialize: (obj)=>obj,
|
|
20
|
-
deserialize: (obj)=>obj
|
|
21
|
-
},
|
|
22
|
-
output: {
|
|
23
|
-
serialize: (obj)=>obj,
|
|
24
|
-
deserialize: (obj)=>obj
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
function transformTRPCResponseItem(config, item) {
|
|
28
|
-
if ('error' in item) {
|
|
29
|
-
return {
|
|
30
|
-
...item,
|
|
31
|
-
error: config.transformer.output.serialize(item.error)
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
if ('data' in item.result) {
|
|
35
|
-
return {
|
|
36
|
-
...item,
|
|
37
|
-
result: {
|
|
38
|
-
...item.result,
|
|
39
|
-
data: config.transformer.output.serialize(item.result.data)
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return item;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
|
|
47
|
-
**/ function transformTRPCResponse(config, itemOrItems) {
|
|
48
|
-
return Array.isArray(itemOrItems) ? itemOrItems.map((item)=>transformTRPCResponseItem(config, item)) : transformTRPCResponseItem(config, itemOrItems);
|
|
49
|
-
}
|
|
50
|
-
// FIXME:
|
|
51
|
-
// - the generics here are probably unnecessary
|
|
52
|
-
// - the RPC-spec could probably be simplified to combine HTTP + WS
|
|
53
|
-
/** @internal */ function transformResultInner(response, transformer) {
|
|
54
|
-
if ('error' in response) {
|
|
55
|
-
const error = transformer.deserialize(response.error);
|
|
56
|
-
return {
|
|
57
|
-
ok: false,
|
|
58
|
-
error: {
|
|
59
|
-
...response,
|
|
60
|
-
error
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const result = {
|
|
65
|
-
...response.result,
|
|
66
|
-
...(!response.result.type || response.result.type === 'data') && {
|
|
67
|
-
type: 'data',
|
|
68
|
-
data: transformer.deserialize(response.result.data)
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
return {
|
|
72
|
-
ok: true,
|
|
73
|
-
result
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
class TransformResultError extends Error {
|
|
77
|
-
constructor(){
|
|
78
|
-
super('Unable to transform response from server');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Transforms and validates that the result is a valid TRPCResponse
|
|
83
|
-
* @internal
|
|
84
|
-
*/ function transformResult(response, transformer) {
|
|
85
|
-
let result;
|
|
86
|
-
try {
|
|
87
|
-
// Use the data transformers on the JSON-response
|
|
88
|
-
result = transformResultInner(response, transformer);
|
|
89
|
-
} catch (err) {
|
|
90
|
-
throw new TransformResultError();
|
|
91
|
-
}
|
|
92
|
-
// check that output of the transformers is a valid TRPCResponse
|
|
93
|
-
if (!result.ok && (!isObject(result.error.error) || typeof result.error.error['code'] !== 'number')) {
|
|
94
|
-
throw new TransformResultError();
|
|
95
|
-
}
|
|
96
|
-
if (result.ok && !isObject(result.result)) {
|
|
97
|
-
throw new TransformResultError();
|
|
98
|
-
}
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { defaultTransformer, getDataTransformer, transformResult, transformTRPCResponse };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ================================
|
|
3
|
-
* Useful utility types that doesn't have anything to do with tRPC in particular
|
|
4
|
-
* ================================
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export type Maybe<TType> = TType | null | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
* @link https://github.com/ianstormtaylor/superstruct/blob/7973400cd04d8ad92bbdc2b6f35acbfb3c934079/src/utils.ts#L323-L325
|
|
13
|
-
*/
|
|
14
|
-
export type Simplify<TType> = TType extends any[] | Date ? TType : {
|
|
15
|
-
[K in keyof TType]: TType[K];
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export type Dict<TType> = Record<string, TType | undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export type MaybePromise<TType> = Promise<TType> | TType;
|
|
25
|
-
export type FilterKeys<TObj extends object, TFilter> = {
|
|
26
|
-
[TKey in keyof TObj]: TObj[TKey] extends TFilter ? TKey : never;
|
|
27
|
-
}[keyof TObj];
|
|
28
|
-
/**
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
export type Filter<TObj extends object, TFilter> = Pick<TObj, FilterKeys<TObj, TFilter>>;
|
|
32
|
-
/**
|
|
33
|
-
* Unwrap return type if the type is a function (sync or async), else use the type as is
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export type Unwrap<TType> = TType extends (...args: any[]) => infer R ? Awaited<R> : TType;
|
|
37
|
-
/**
|
|
38
|
-
* Makes the object recursively optional
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export type DeepPartial<TObject> = TObject extends object ? {
|
|
42
|
-
[P in keyof TObject]?: DeepPartial<TObject[P]>;
|
|
43
|
-
} : TObject;
|
|
44
|
-
/**
|
|
45
|
-
* Omits the key without removing a potential union
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
export type DistributiveOmit<TObj, TKey extends keyof any> = TObj extends any ? Omit<TObj, TKey> : never;
|
|
49
|
-
/**
|
|
50
|
-
* See https://github.com/microsoft/TypeScript/issues/41966#issuecomment-758187996
|
|
51
|
-
* Fixes issues with iterating over keys of objects with index signatures.
|
|
52
|
-
* Without this, iterations over keys of objects with index signatures will lose
|
|
53
|
-
* type information about the keys and only the index signature will remain.
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
56
|
-
export type WithoutIndexSignature<TObj> = {
|
|
57
|
-
[K in keyof TObj as string extends K ? never : number extends K ? never : K]: TObj[K];
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* @internal
|
|
61
|
-
* Overwrite properties in `TType` with properties in `TWith`
|
|
62
|
-
* Only overwrites properties when the type to be overwritten
|
|
63
|
-
* is an object. Otherwise it will just use the type from `TWith`.
|
|
64
|
-
*/
|
|
65
|
-
export type Overwrite<TType, TWith> = TWith extends any ? TType extends object ? {
|
|
66
|
-
[K in keyof WithoutIndexSignature<TType> | keyof WithoutIndexSignature<TWith>]: K extends keyof TWith ? TWith[K] : K extends keyof TType ? TType[K] : never;
|
|
67
|
-
} & (string extends keyof TWith ? {
|
|
68
|
-
[key: string]: TWith[string];
|
|
69
|
-
} : number extends keyof TWith ? {
|
|
70
|
-
[key: number]: TWith[number];
|
|
71
|
-
} : {}) : TWith : never;
|
|
72
|
-
/**
|
|
73
|
-
* @internal
|
|
74
|
-
*/
|
|
75
|
-
export type ValidateShape<TActualShape, TExpectedShape> = TActualShape extends TExpectedShape ? Exclude<keyof TActualShape, keyof TExpectedShape> extends never ? TActualShape : TExpectedShape : never;
|
|
76
|
-
/**
|
|
77
|
-
* @internal
|
|
78
|
-
*/
|
|
79
|
-
export type PickFirstDefined<TType, TPick> = undefined extends TType ? undefined extends TPick ? never : TPick : TType;
|
|
80
|
-
/**
|
|
81
|
-
* ================================
|
|
82
|
-
* tRPC specific types
|
|
83
|
-
* ================================
|
|
84
|
-
*/
|
|
85
|
-
/**
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
export type IntersectionError<TKey extends string> = `The property '${TKey}' in your router collides with a built-in method, rename this router or procedure on your backend.`;
|
|
89
|
-
/**
|
|
90
|
-
* @internal
|
|
91
|
-
*/
|
|
92
|
-
export type ProtectedIntersection<TType, TWith> = keyof TType & keyof TWith extends never ? TType & TWith : IntersectionError<string & keyof TType & keyof TWith>;
|
|
93
|
-
/**
|
|
94
|
-
* @internal
|
|
95
|
-
* Returns the raw input type of a procedure
|
|
96
|
-
*/
|
|
97
|
-
export type GetRawInputFn = () => Promise<unknown>;
|
|
98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,MAAM,cAAc,CAAC,SAAS,KAAK,GAC7D,YAAY,GACZ,cAAc,GAChB,KAAK,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,KAAK,IAAI,SAAS,SAAS,KAAK,GAChE,SAAS,SAAS,KAAK,GACrB,KAAK,GACL,KAAK,GACP,KAAK,CAAC;AAEV;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,IAAI,SAAS,MAAM,IAC/C,iBAAiB,IAAI,oGAAoG,CAAC;AAE5H;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,KAAK,EAAE,KAAK,IAAI,MAAM,KAAK,GAC3D,MAAM,KAAK,SAAS,KAAK,GACvB,KAAK,GAAG,KAAK,GACb,iBAAiB,CAAC,MAAM,GAAG,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
|
|
2
|
-
[K in keyof TType]: TValue extends TType[K] ? K : never;
|
|
3
|
-
}[keyof TType];
|
|
4
|
-
type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
|
|
5
|
-
[TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare function invert<TRecord extends Record<PropertyKey, PropertyKey>>(obj: TRecord): Invert<TRecord>;
|
|
11
|
-
/**
|
|
12
|
-
* Ensures there are no duplicate keys when building a procedure.
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare function mergeWithoutOverrides<TType extends Record<string, unknown>>(obj1: TType, ...objs: Partial<TType>[]): TType;
|
|
16
|
-
/**
|
|
17
|
-
* Check that value is object
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* Create an object without inheriting anything from `Object.prototype`
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export declare function omitPrototype<TObj extends Record<string, unknown>>(obj: TObj): TObj;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,MAAM,EAAE,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KACzE,CAAC,IAAI,MAAM,KAAK,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACxD,CAAC,MAAM,KAAK,CAAC,CAAC;AAEf,KAAK,MAAM,CAAC,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KAC3D,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;CAC5D,CAAC;AACF;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,EACrE,GAAG,EAAE,OAAO,GACX,MAAM,CAAC,OAAO,CAAC,CAOjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/ function invert(obj) {
|
|
6
|
-
const newObj = Object.create(null);
|
|
7
|
-
for(const key in obj){
|
|
8
|
-
const v = obj[key];
|
|
9
|
-
newObj[v] = key;
|
|
10
|
-
}
|
|
11
|
-
return newObj;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Ensures there are no duplicate keys when building a procedure.
|
|
15
|
-
* @internal
|
|
16
|
-
*/ function mergeWithoutOverrides(obj1, ...objs) {
|
|
17
|
-
const newObj = Object.assign(Object.create(null), obj1);
|
|
18
|
-
for (const overrides of objs){
|
|
19
|
-
for(const key in overrides){
|
|
20
|
-
if (key in newObj && newObj[key] !== overrides[key]) {
|
|
21
|
-
throw new Error(`Duplicate key ${key}`);
|
|
22
|
-
}
|
|
23
|
-
newObj[key] = overrides[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return newObj;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Check that value is object
|
|
30
|
-
* @internal
|
|
31
|
-
*/ function isObject(value) {
|
|
32
|
-
return !!value && !Array.isArray(value) && typeof value === 'object';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create an object without inheriting anything from `Object.prototype`
|
|
36
|
-
* @internal
|
|
37
|
-
*/ function omitPrototype(obj) {
|
|
38
|
-
return Object.assign(Object.create(null), obj);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.invert = invert;
|
|
42
|
-
exports.isObject = isObject;
|
|
43
|
-
exports.mergeWithoutOverrides = mergeWithoutOverrides;
|
|
44
|
-
exports.omitPrototype = omitPrototype;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/ function invert(obj) {
|
|
4
|
-
const newObj = Object.create(null);
|
|
5
|
-
for(const key in obj){
|
|
6
|
-
const v = obj[key];
|
|
7
|
-
newObj[v] = key;
|
|
8
|
-
}
|
|
9
|
-
return newObj;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Ensures there are no duplicate keys when building a procedure.
|
|
13
|
-
* @internal
|
|
14
|
-
*/ function mergeWithoutOverrides(obj1, ...objs) {
|
|
15
|
-
const newObj = Object.assign(Object.create(null), obj1);
|
|
16
|
-
for (const overrides of objs){
|
|
17
|
-
for(const key in overrides){
|
|
18
|
-
if (key in newObj && newObj[key] !== overrides[key]) {
|
|
19
|
-
throw new Error(`Duplicate key ${key}`);
|
|
20
|
-
}
|
|
21
|
-
newObj[key] = overrides[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return newObj;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Check that value is object
|
|
28
|
-
* @internal
|
|
29
|
-
*/ function isObject(value) {
|
|
30
|
-
return !!value && !Array.isArray(value) && typeof value === 'object';
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create an object without inheriting anything from `Object.prototype`
|
|
34
|
-
* @internal
|
|
35
|
-
*/ function omitPrototype(obj) {
|
|
36
|
-
return Object.assign(Object.create(null), obj);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { invert, isObject, mergeWithoutOverrides, omitPrototype };
|
package/src/@trpc/server/http.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
getHTTPStatusCode,
|
|
3
|
-
getHTTPStatusCodeFromError,
|
|
4
|
-
} from '../../unstable-core-do-not-import';
|
|
5
|
-
export { resolveHTTPResponse } from '../../unstable-core-do-not-import';
|
|
6
|
-
export type {
|
|
7
|
-
BaseHandlerOptions,
|
|
8
|
-
HTTPBaseHandlerOptions,
|
|
9
|
-
HTTPHeaders,
|
|
10
|
-
HTTPRequest,
|
|
11
|
-
HTTPResponse,
|
|
12
|
-
OnErrorFunction,
|
|
13
|
-
ProcedureCall,
|
|
14
|
-
ResolveHTTPRequestOptionsContextFn,
|
|
15
|
-
ResponseChunk,
|
|
16
|
-
ResponseMeta,
|
|
17
|
-
ResponseMetaFn,
|
|
18
|
-
TRPCRequestInfo,
|
|
19
|
-
} from '../../unstable-core-do-not-import';
|
|
20
|
-
|
|
21
|
-
export { getBatchStreamFormatter } from '../../unstable-core-do-not-import';
|
|
22
|
-
export type {
|
|
23
|
-
BaseContentTypeHandler,
|
|
24
|
-
BodyResult,
|
|
25
|
-
} from '../../unstable-core-do-not-import';
|
|
26
|
-
export { getJsonContentTypeInputs } from '../../unstable-core-do-not-import';
|