@trpc/server 11.0.0-next-alpha.153 → 11.0.0-next-alpha.155
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/adapters/aws-lambda/index.d.ts +2 -2
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +6 -13
- package/dist/adapters/aws-lambda/index.mjs +2 -9
- package/dist/adapters/aws-lambda/utils.d.ts +2 -4
- package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +3 -11
- package/dist/adapters/express.mjs +3 -11
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +4 -4
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +4 -4
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/index.js +6 -14
- package/dist/adapters/fastify/index.mjs +4 -12
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/index.js +3 -12
- package/dist/adapters/fetch/index.mjs +1 -10
- package/dist/adapters/fetch/types.d.ts +2 -2
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.d.ts +4 -3
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +5 -13
- package/dist/adapters/next.mjs +3 -11
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts +1 -1
- package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/index.d.ts +2 -2
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +1 -1
- package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +2 -1
- package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts +1 -1
- package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +2 -2
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/index.js +4 -5
- package/dist/adapters/node-http/content-type/json/index.mjs +2 -3
- package/dist/adapters/node-http/index.js +3 -11
- package/dist/adapters/node-http/index.mjs +3 -11
- package/dist/adapters/node-http/internals/contentType.d.ts +3 -3
- package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +2 -2
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/types.d.ts +4 -5
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +2 -2
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +3 -11
- package/dist/adapters/standalone.mjs +3 -11
- package/dist/adapters/ws.d.ts +6 -6
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +25 -31
- package/dist/adapters/ws.mjs +3 -9
- package/dist/bundle-analysis.json +81 -611
- package/dist/http.d.ts +2 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +14 -0
- package/dist/http.mjs +1 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -95
- package/dist/index.mjs +1 -90
- package/dist/{nodeHTTPRequestHandler-a7049e69.js → nodeHTTPRequestHandler-30028c9a.js} +3 -5
- package/dist/{nodeHTTPRequestHandler-ca65b7c9.mjs → nodeHTTPRequestHandler-36974696.mjs} +1 -3
- package/dist/{nodeHTTPRequestHandler-abbfb330.js → nodeHTTPRequestHandler-640c1f60.js} +1 -3
- package/dist/observable.d.ts +2 -0
- package/dist/observable.d.ts.map +1 -0
- package/dist/observable.js +14 -0
- package/dist/observable.mjs +1 -0
- package/dist/rpc.d.ts +2 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +14 -0
- package/dist/rpc.mjs +1 -0
- package/dist/unstableDoNotImportThis.d.ts +9 -0
- package/dist/unstableDoNotImportThis.d.ts.map +1 -0
- package/package.json +32 -41
- package/src/adapters/aws-lambda/index.ts +8 -6
- package/src/adapters/aws-lambda/utils.ts +8 -5
- package/src/adapters/express.ts +3 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +7 -7
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +6 -5
- package/src/adapters/fetch/fetchRequestHandler.ts +6 -6
- package/src/adapters/fetch/types.ts +2 -2
- package/src/adapters/next.ts +5 -9
- package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +2 -1
- package/src/adapters/node-http/content-type/form-data/index.ts +4 -7
- package/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts +2 -1
- package/src/adapters/node-http/content-type/form-data/streamSlice.ts +2 -1
- package/src/adapters/node-http/content-type/form-data/uploadHandler.ts +1 -1
- package/src/adapters/node-http/content-type/json/getPostBody.ts +3 -3
- package/src/adapters/node-http/content-type/json/index.ts +1 -1
- package/src/adapters/node-http/internals/contentType.ts +3 -3
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +7 -7
- package/src/adapters/node-http/types.ts +4 -5
- package/src/adapters/standalone.ts +3 -3
- package/src/adapters/ws.ts +16 -12
- package/src/http.ts +2 -0
- package/src/index.ts +30 -14
- package/src/observable.ts +1 -0
- package/src/rpc.ts +2 -0
- package/src/unstableDoNotImportThis.ts +9 -0
- package/dist/TRPCError-0b220715.js +0 -42
- package/dist/TRPCError-2bb6a7d0.js +0 -37
- package/dist/TRPCError-7e8e2a1b.mjs +0 -39
- package/dist/batchStreamFormatter-2c1405a1.js +0 -31
- package/dist/batchStreamFormatter-93cdcdd4.js +0 -32
- package/dist/batchStreamFormatter-fc1ffb26.mjs +0 -30
- package/dist/codes-62b059d2.js +0 -48
- package/dist/codes-87f6824b.js +0 -48
- package/dist/codes-c924c3db.mjs +0 -44
- package/dist/config-50853f49.mjs +0 -6
- package/dist/config-774dae36.js +0 -8
- package/dist/config-e3dd843b.js +0 -11
- package/dist/contentType-0447b256.js +0 -58
- package/dist/contentType-31223e57.mjs +0 -52
- package/dist/contentType-a229790b.js +0 -54
- package/dist/core/index.d.ts +0 -9
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/initTRPC.d.ts +0 -84
- package/dist/core/initTRPC.d.ts.map +0 -1
- package/dist/core/internals/config.d.ts +0 -75
- package/dist/core/internals/config.d.ts.map +0 -1
- package/dist/core/internals/getParseFn.d.ts +0 -4
- package/dist/core/internals/getParseFn.d.ts.map +0 -1
- package/dist/core/internals/mergeRouters.d.ts +0 -15
- package/dist/core/internals/mergeRouters.d.ts.map +0 -1
- package/dist/core/internals/mergeWithoutOverrides.d.ts +0 -5
- package/dist/core/internals/mergeWithoutOverrides.d.ts.map +0 -1
- package/dist/core/internals/omitPrototype.d.ts +0 -6
- package/dist/core/internals/omitPrototype.d.ts.map +0 -1
- package/dist/core/internals/procedureBuilder.d.ts +0 -99
- package/dist/core/internals/procedureBuilder.d.ts.map +0 -1
- package/dist/core/internals/utils.d.ts +0 -50
- package/dist/core/internals/utils.d.ts.map +0 -1
- package/dist/core/middleware.d.ts +0 -106
- package/dist/core/middleware.d.ts.map +0 -1
- package/dist/core/parser.d.ts +0 -28
- package/dist/core/parser.d.ts.map +0 -1
- package/dist/core/procedure.d.ts +0 -54
- package/dist/core/procedure.d.ts.map +0 -1
- package/dist/core/router.d.ts +0 -64
- package/dist/core/router.d.ts.map +0 -1
- package/dist/core/types.d.ts +0 -24
- package/dist/core/types.d.ts.map +0 -1
- package/dist/error/TRPCError.d.ts +0 -12
- package/dist/error/TRPCError.d.ts.map +0 -1
- package/dist/error/formatter.d.ts +0 -33
- package/dist/error/formatter.d.ts.map +0 -1
- package/dist/error/utils.d.ts +0 -9
- package/dist/error/utils.d.ts.map +0 -1
- package/dist/getCauseFromUnknown-2d66414a.mjs +0 -33
- package/dist/getCauseFromUnknown-ac5f46a2.js +0 -34
- package/dist/getCauseFromUnknown-d535264a.js +0 -35
- package/dist/http/batchStreamFormatter.d.ts +0 -24
- package/dist/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/http/contentType.d.ts +0 -29
- package/dist/http/contentType.d.ts.map +0 -1
- package/dist/http/getHTTPStatusCode.d.ts +0 -24
- package/dist/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/http/index.d.ts +0 -5
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -22
- package/dist/http/index.mjs +0 -10
- package/dist/http/internals/types.d.ts +0 -32
- package/dist/http/internals/types.d.ts.map +0 -1
- package/dist/http/resolveHTTPResponse.d.ts +0 -52
- package/dist/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/http/types.d.ts +0 -46
- package/dist/http/types.d.ts.map +0 -1
- package/dist/index-8759c3db.js +0 -48
- package/dist/index-a496f86b.js +0 -52
- package/dist/index-a9e3e610.mjs +0 -49
- package/dist/internals/invert.d.ts +0 -12
- package/dist/internals/invert.d.ts.map +0 -1
- package/dist/internals/types.d.ts +0 -26
- package/dist/internals/types.d.ts.map +0 -1
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -156
- package/dist/observable/index.mjs +0 -147
- package/dist/observable/internals/identity.d.ts +0 -2
- package/dist/observable/internals/identity.d.ts.map +0 -1
- package/dist/observable/internals/observableToPromise.d.ts +0 -10
- package/dist/observable/internals/observableToPromise.d.ts.map +0 -1
- package/dist/observable/internals/pipe.d.ts +0 -4
- package/dist/observable/internals/pipe.d.ts.map +0 -1
- package/dist/observable/observable.d.ts +0 -5
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/operators/index.d.ts +0 -4
- package/dist/observable/operators/index.d.ts.map +0 -1
- package/dist/observable/operators/map.d.ts +0 -3
- package/dist/observable/operators/map.d.ts.map +0 -1
- package/dist/observable/operators/share.d.ts +0 -6
- package/dist/observable/operators/share.d.ts.map +0 -1
- package/dist/observable/operators/tap.d.ts +0 -3
- package/dist/observable/operators/tap.d.ts.map +0 -1
- package/dist/observable/types.d.ts +0 -29
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/observable-15588f28.js +0 -83
- package/dist/observable-464116ac.js +0 -84
- package/dist/observable-ade1bad8.mjs +0 -81
- package/dist/parseTRPCMessage-1377f305.js +0 -56
- package/dist/parseTRPCMessage-95955211.js +0 -63
- package/dist/parseTRPCMessage-a0f17853.mjs +0 -54
- package/dist/procedureBuilder-0446e596.js +0 -327
- package/dist/procedureBuilder-4b68e226.js +0 -349
- package/dist/procedureBuilder-cf58dadb.mjs +0 -340
- package/dist/resolveHTTPResponse-3ebaa4f6.mjs +0 -292
- package/dist/resolveHTTPResponse-7c84e387.js +0 -294
- package/dist/resolveHTTPResponse-fa37ffd7.js +0 -266
- package/dist/router-18d63731.js +0 -163
- package/dist/router-8dcebd61.js +0 -153
- package/dist/router-f9ce121f.mjs +0 -156
- package/dist/rpc/codes.d.ts +0 -51
- package/dist/rpc/codes.d.ts.map +0 -1
- package/dist/rpc/envelopes.d.ts +0 -95
- package/dist/rpc/envelopes.d.ts.map +0 -1
- package/dist/rpc/index.d.ts +0 -4
- package/dist/rpc/index.d.ts.map +0 -1
- package/dist/rpc/index.js +0 -12
- package/dist/rpc/index.mjs +0 -2
- package/dist/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/shared/createProxy/index.d.ts +0 -19
- package/dist/shared/createProxy/index.d.ts.map +0 -1
- package/dist/shared/getCauseFromUnknown.d.ts +0 -2
- package/dist/shared/getCauseFromUnknown.d.ts.map +0 -1
- package/dist/shared/getErrorShape.d.ts +0 -15
- package/dist/shared/getErrorShape.d.ts.map +0 -1
- package/dist/shared/index.d.ts +0 -8
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/index.js +0 -16
- package/dist/shared/index.mjs +0 -4
- package/dist/shared/internal/serialize.d.ts +0 -62
- package/dist/shared/internal/serialize.d.ts.map +0 -1
- package/dist/shared/jsonify.d.ts +0 -11
- package/dist/shared/jsonify.d.ts.map +0 -1
- package/dist/shared/transformTRPCResponse.d.ts +0 -9
- package/dist/shared/transformTRPCResponse.d.ts.map +0 -1
- package/dist/shared/types.d.ts +0 -6
- package/dist/shared/types.d.ts.map +0 -1
- package/dist/transformTRPCResponse-31040a38.mjs +0 -98
- package/dist/transformTRPCResponse-59486a84.js +0 -97
- package/dist/transformTRPCResponse-9f3b865f.js +0 -104
- package/dist/transformer.d.ts +0 -67
- package/dist/transformer.d.ts.map +0 -1
- package/dist/types.d.ts +0 -68
- package/dist/types.d.ts.map +0 -1
- package/dist/unstableInternalsExport.d.ts +0 -12
- package/dist/unstableInternalsExport.d.ts.map +0 -1
- package/dist/unstableInternalsExport.js +0 -16
- package/dist/unstableInternalsExport.mjs +0 -5
- package/src/core/index.ts +0 -28
- package/src/core/initTRPC.ts +0 -186
- package/src/core/internals/config.ts +0 -90
- package/src/core/internals/getParseFn.ts +0 -43
- package/src/core/internals/mergeRouters.ts +0 -90
- package/src/core/internals/mergeWithoutOverrides.ts +0 -19
- package/src/core/internals/omitPrototype.ts +0 -9
- package/src/core/internals/procedureBuilder.ts +0 -455
- package/src/core/internals/utils.ts +0 -79
- package/src/core/middleware.ts +0 -236
- package/src/core/parser.ts +0 -52
- package/src/core/procedure.ts +0 -68
- package/src/core/router.ts +0 -241
- package/src/core/types.ts +0 -67
- package/src/error/TRPCError.ts +0 -52
- package/src/error/formatter.ts +0 -54
- package/src/error/utils.ts +0 -23
- package/src/http/batchStreamFormatter.ts +0 -29
- package/src/http/contentType.ts +0 -99
- package/src/http/getHTTPStatusCode.ts +0 -61
- package/src/http/index.ts +0 -4
- package/src/http/internals/types.ts +0 -40
- package/src/http/resolveHTTPResponse.ts +0 -458
- package/src/http/types.ts +0 -51
- package/src/internals/invert.ts +0 -21
- package/src/internals/types.ts +0 -27
- package/src/observable/index.ts +0 -4
- package/src/observable/internals/identity.ts +0 -3
- package/src/observable/internals/observableToPromise.ts +0 -49
- package/src/observable/internals/pipe.ts +0 -23
- package/src/observable/observable.ts +0 -78
- package/src/observable/operators/index.ts +0 -3
- package/src/observable/operators/map.ts +0 -25
- package/src/observable/operators/share.ts +0 -65
- package/src/observable/operators/tap.ts +0 -26
- package/src/observable/types.ts +0 -80
- package/src/rpc/codes.ts +0 -44
- package/src/rpc/envelopes.ts +0 -136
- package/src/rpc/index.ts +0 -3
- package/src/rpc/parseTRPCMessage.ts +0 -84
- package/src/shared/createProxy/index.ts +0 -59
- package/src/shared/getCauseFromUnknown.ts +0 -31
- package/src/shared/getErrorShape.ts +0 -36
- package/src/shared/index.ts +0 -11
- package/src/shared/internal/serialize.ts +0 -122
- package/src/shared/jsonify.ts +0 -22
- package/src/shared/transformTRPCResponse.ts +0 -40
- package/src/shared/types.ts +0 -9
- package/src/transformer.ts +0 -84
- package/src/types.ts +0 -104
- package/src/unstableInternalsExport.ts +0 -13
- package/subscription/index.d.ts +0 -1
- package/subscription/index.js +0 -1
- package/unstableInternalsExport/index.d.ts +0 -1
- package/unstableInternalsExport/index.js +0 -1
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AnyRouter, inferRouterContext, inferRouterError, ProcedureType } from '../../core';
|
|
2
|
-
import { TRPCError } from '../../error/TRPCError';
|
|
3
|
-
import { TRPCResponse } from '../../rpc';
|
|
4
|
-
import { Dict } from '../../types';
|
|
5
|
-
import { ResponseMeta } from '../types';
|
|
6
|
-
export type HTTPHeaders = Dict<string[] | string>;
|
|
7
|
-
export interface HTTPResponse {
|
|
8
|
-
status: number;
|
|
9
|
-
headers?: HTTPHeaders;
|
|
10
|
-
body?: string;
|
|
11
|
-
}
|
|
12
|
-
export type ResponseChunk = [procedureIndex: number, responseBody: string];
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
|
|
17
|
-
data: TRPCResponse<unknown, inferRouterError<TRouter>>[];
|
|
18
|
-
ctx?: inferRouterContext<TRouter>;
|
|
19
|
-
/**
|
|
20
|
-
* The different tRPC paths requested
|
|
21
|
-
**/
|
|
22
|
-
paths?: string[];
|
|
23
|
-
type: ProcedureType | 'unknown';
|
|
24
|
-
errors: TRPCError[];
|
|
25
|
-
/**
|
|
26
|
-
* `true` if the `ResponseMeta` are being
|
|
27
|
-
* generated without knowing the response data
|
|
28
|
-
* (e.g. for streaming requests).
|
|
29
|
-
*/
|
|
30
|
-
eagerGeneration?: boolean;
|
|
31
|
-
}) => ResponseMeta;
|
|
32
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/http/internals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE;IAC7D,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IACzD,GAAG,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClC;;QAEI;IACJ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,KAAK,YAAY,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { AnyRouter } from '../core';
|
|
2
|
-
import { TRPCError } from '../error/TRPCError';
|
|
3
|
-
import { Maybe } from '../types';
|
|
4
|
-
import { BaseContentTypeHandler } from './contentType';
|
|
5
|
-
import { HTTPResponse, ResponseChunk } from './internals/types';
|
|
6
|
-
import { HTTPBaseHandlerOptions, HTTPRequest, ResolveHTTPRequestOptionsContextFn } from './types';
|
|
7
|
-
interface ResolveHTTPRequestOptions<TRouter extends AnyRouter, TRequest extends HTTPRequest> extends HTTPBaseHandlerOptions<TRouter, TRequest> {
|
|
8
|
-
createContext: ResolveHTTPRequestOptionsContextFn<TRouter>;
|
|
9
|
-
req: TRequest;
|
|
10
|
-
path: string;
|
|
11
|
-
error?: Maybe<TRPCError>;
|
|
12
|
-
contentTypeHandler?: BaseContentTypeHandler<any>;
|
|
13
|
-
preprocessedBody?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Called as soon as the response head is known.
|
|
16
|
-
* When streaming, headers will have been generated
|
|
17
|
-
* **without** knowing the response body.
|
|
18
|
-
*
|
|
19
|
-
* Without this callback, streaming is disabled.
|
|
20
|
-
*/
|
|
21
|
-
unstable_onHead: (headResponse: Omit<HTTPResponse, 'body'>, isStreaming: boolean) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Called for every procedure with `[index, result]`.
|
|
24
|
-
*
|
|
25
|
-
* Will be called a single time with `index = -1` if
|
|
26
|
-
* - response is an error
|
|
27
|
-
* - response is empty (HEAD request)
|
|
28
|
-
*
|
|
29
|
-
* Without this callback, streaming is disabled.
|
|
30
|
-
*/
|
|
31
|
-
unstable_onChunk: (chunk: ResponseChunk) => void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Since `resolveHTTPResponse` is a public API (community adapters),
|
|
35
|
-
* let's give it a strong type signature to increase discoverability.
|
|
36
|
-
*/
|
|
37
|
-
/**
|
|
38
|
-
* Non-streaming signature for `resolveHTTPResponse`:
|
|
39
|
-
* @param opts.unstable_onHead `undefined`
|
|
40
|
-
* @param opts.unstable_onChunk `undefined`
|
|
41
|
-
* @returns `Promise<HTTPResponse>`
|
|
42
|
-
*/
|
|
43
|
-
export declare function resolveHTTPResponse<TRouter extends AnyRouter, TRequest extends HTTPRequest>(opts: Omit<ResolveHTTPRequestOptions<TRouter, TRequest>, 'unstable_onChunk' | 'unstable_onHead'>): Promise<HTTPResponse>;
|
|
44
|
-
/**
|
|
45
|
-
* Streaming signature for `resolveHTTPResponse`:
|
|
46
|
-
* @param opts.unstable_onHead called as soon as the response head is known
|
|
47
|
-
* @param opts.unstable_onChunk called for every procedure with `[index, result]`
|
|
48
|
-
* @returns `Promise<void>` since the response is streamed
|
|
49
|
-
*/
|
|
50
|
-
export declare function resolveHTTPResponse<TRouter extends AnyRouter, TRequest extends HTTPRequest>(opts: ResolveHTTPRequestOptions<TRouter, TRequest>): Promise<void>;
|
|
51
|
-
export {};
|
|
52
|
-
//# sourceMappingURL=resolveHTTPResponse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveHTTPResponse.d.ts","sourceRoot":"","sources":["../../src/http/resolveHTTPResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAKV,MAAM,SAAS,CAAC;AACjB,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIxE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EACL,sBAAsB,EAEvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAe,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AAoBjB,UAAU,yBAAyB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,CAC5B,SAAQ,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC;IACjD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACzB,kBAAkB,CAAC,EAAE,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACjD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,eAAe,EAAE,CACf,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EACxC,WAAW,EAAE,OAAO,KACjB,IAAI,CAAC;IACV;;;;;;;;OAQG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAClD;AAyJD;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,IAAI,CACR,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC5C,kBAAkB,GAAG,iBAAiB,CACvC,GACA,OAAO,CAAC,YAAY,CAAC,CAAC;AACzB;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,WAAW,EAC5B,IAAI,EAAE,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/http/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { AnyRouter, inferRouterContext, ProcedureType } from '../core';
|
|
2
|
-
import { BaseHandlerOptions } from '../internals/types';
|
|
3
|
-
import { HTTPHeaders, ResponseMetaFn } from './internals/types';
|
|
4
|
-
export interface HTTPRequest {
|
|
5
|
-
method: string;
|
|
6
|
-
query: URLSearchParams;
|
|
7
|
-
headers: HTTPHeaders;
|
|
8
|
-
body: unknown;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Base interface for anything using HTTP
|
|
12
|
-
*/
|
|
13
|
-
export interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest> extends BaseHandlerOptions<TRouter, TRequest> {
|
|
14
|
-
/**
|
|
15
|
-
* Add handler to be called before response is sent to the user
|
|
16
|
-
* Useful for setting cache headers
|
|
17
|
-
* @link https://trpc.io/docs/caching
|
|
18
|
-
*/
|
|
19
|
-
responseMeta?: ResponseMetaFn<TRouter>;
|
|
20
|
-
}
|
|
21
|
-
export interface ResponseMeta {
|
|
22
|
-
status?: number;
|
|
23
|
-
headers?: HTTPHeaders;
|
|
24
|
-
}
|
|
25
|
-
/** @internal */
|
|
26
|
-
export type ProcedureCall = {
|
|
27
|
-
type: ProcedureType;
|
|
28
|
-
input?: unknown;
|
|
29
|
-
path: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Information about the incoming request
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export type TRPCRequestInfo = {
|
|
36
|
-
isBatchCall: boolean;
|
|
37
|
-
calls: ProcedureCall[];
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Inner createContext function for `resolveHTTPResponse` used to forward `TRPCRequestInfo` to `createContext`
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
export type ResolveHTTPRequestOptionsContextFn<TRouter extends AnyRouter> = (opts: {
|
|
44
|
-
info: TRPCRequestInfo;
|
|
45
|
-
}) => Promise<inferRouterContext<TRouter>>;
|
|
46
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/http/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,CACzE,SAAQ,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC7C;;;;OAIG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,gBAAgB;AAChB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kCAAkC,CAAC,OAAO,SAAS,SAAS,IACtE,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,KAAK,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
package/dist/index-8759c3db.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const noop = () => {
|
|
2
|
-
// noop
|
|
3
|
-
};
|
|
4
|
-
function createInnerProxy(callback, path) {
|
|
5
|
-
const proxy = new Proxy(noop, {
|
|
6
|
-
get(_obj, key) {
|
|
7
|
-
if (typeof key !== 'string' || key === 'then') {
|
|
8
|
-
// special case for if the proxy is accidentally treated
|
|
9
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return createInnerProxy(callback, [...path, key]);
|
|
13
|
-
},
|
|
14
|
-
apply(_1, _2, args) {
|
|
15
|
-
const isApply = path[path.length - 1] === 'apply';
|
|
16
|
-
return callback({
|
|
17
|
-
args: isApply ? (args.length >= 2 ? args[1] : []) : args,
|
|
18
|
-
path: isApply ? path.slice(0, -1) : path,
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
return proxy;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Creates a proxy that calls the callback with the path and arguments
|
|
26
|
-
*
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
const createRecursiveProxy = (callback) => createInnerProxy(callback, []);
|
|
30
|
-
/**
|
|
31
|
-
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
32
|
-
*
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
const createFlatProxy = (callback) => {
|
|
36
|
-
return new Proxy(noop, {
|
|
37
|
-
get(_obj, name) {
|
|
38
|
-
if (typeof name !== 'string' || name === 'then') {
|
|
39
|
-
// special case for if the proxy is accidentally treated
|
|
40
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
return callback(name);
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export { createRecursiveProxy as a, createFlatProxy as c };
|
package/dist/index-a496f86b.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const noop = ()=>{
|
|
4
|
-
// noop
|
|
5
|
-
};
|
|
6
|
-
function createInnerProxy(callback, path) {
|
|
7
|
-
const proxy = new Proxy(noop, {
|
|
8
|
-
get (_obj, key) {
|
|
9
|
-
if (typeof key !== 'string' || key === 'then') {
|
|
10
|
-
// special case for if the proxy is accidentally treated
|
|
11
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
return createInnerProxy(callback, [
|
|
15
|
-
...path,
|
|
16
|
-
key
|
|
17
|
-
]);
|
|
18
|
-
},
|
|
19
|
-
apply (_1, _2, args) {
|
|
20
|
-
const isApply = path[path.length - 1] === 'apply';
|
|
21
|
-
return callback({
|
|
22
|
-
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
23
|
-
path: isApply ? path.slice(0, -1) : path
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
return proxy;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Creates a proxy that calls the callback with the path and arguments
|
|
31
|
-
*
|
|
32
|
-
* @internal
|
|
33
|
-
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
34
|
-
/**
|
|
35
|
-
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
36
|
-
*
|
|
37
|
-
* @internal
|
|
38
|
-
*/ const createFlatProxy = (callback)=>{
|
|
39
|
-
return new Proxy(noop, {
|
|
40
|
-
get (_obj, name) {
|
|
41
|
-
if (typeof name !== 'string' || name === 'then') {
|
|
42
|
-
// special case for if the proxy is accidentally treated
|
|
43
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return callback(name);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports.createFlatProxy = createFlatProxy;
|
|
52
|
-
exports.createRecursiveProxy = createRecursiveProxy;
|
package/dist/index-a9e3e610.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const noop = ()=>{
|
|
2
|
-
// noop
|
|
3
|
-
};
|
|
4
|
-
function createInnerProxy(callback, path) {
|
|
5
|
-
const proxy = new Proxy(noop, {
|
|
6
|
-
get (_obj, key) {
|
|
7
|
-
if (typeof key !== 'string' || key === 'then') {
|
|
8
|
-
// special case for if the proxy is accidentally treated
|
|
9
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
return createInnerProxy(callback, [
|
|
13
|
-
...path,
|
|
14
|
-
key
|
|
15
|
-
]);
|
|
16
|
-
},
|
|
17
|
-
apply (_1, _2, args) {
|
|
18
|
-
const isApply = path[path.length - 1] === 'apply';
|
|
19
|
-
return callback({
|
|
20
|
-
args: isApply ? args.length >= 2 ? args[1] : [] : args,
|
|
21
|
-
path: isApply ? path.slice(0, -1) : path
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
return proxy;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Creates a proxy that calls the callback with the path and arguments
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
|
|
32
|
-
/**
|
|
33
|
-
* Used in place of `new Proxy` where each handler will map 1 level deep to another value.
|
|
34
|
-
*
|
|
35
|
-
* @internal
|
|
36
|
-
*/ const createFlatProxy = (callback)=>{
|
|
37
|
-
return new Proxy(noop, {
|
|
38
|
-
get (_obj, name) {
|
|
39
|
-
if (typeof name !== 'string' || name === 'then') {
|
|
40
|
-
// special case for if the proxy is accidentally treated
|
|
41
|
-
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
return callback(name);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export { createRecursiveProxy as a, createFlatProxy as c };
|
|
@@ -1,12 +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
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=invert.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invert.d.ts","sourceRoot":"","sources":["../../src/internals/invert.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;AAEF;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,EACrE,GAAG,EAAE,OAAO,GACX,MAAM,CAAC,OAAO,CAAC,CAOjB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { inferRouterContext, ProcedureType } from '../core';
|
|
2
|
-
import { AnyRouter } from '../core/router';
|
|
3
|
-
import { TRPCError } from '../error/TRPCError';
|
|
4
|
-
/**
|
|
5
|
-
* Base interface for any response handler
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
|
|
9
|
-
onError?: OnErrorFunction<TRouter, TRequest>;
|
|
10
|
-
batching?: {
|
|
11
|
-
enabled: boolean;
|
|
12
|
-
};
|
|
13
|
-
router: TRouter;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export type OnErrorFunction<TRouter extends AnyRouter, TRequest> = (opts: {
|
|
19
|
-
error: TRPCError;
|
|
20
|
-
type: ProcedureType | 'unknown';
|
|
21
|
-
path: string | undefined;
|
|
22
|
-
req: TRequest;
|
|
23
|
-
input: unknown;
|
|
24
|
-
ctx: inferRouterContext<TRouter> | undefined;
|
|
25
|
-
}) => void;
|
|
26
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,IAAI,CAAC,IAAI,EAAE;IACxE,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;CAC9C,KAAK,IAAI,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observable/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/observable/index.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var observable = require('../observable-464116ac.js');
|
|
6
|
-
|
|
7
|
-
function share(_opts) {
|
|
8
|
-
return (originalObserver)=>{
|
|
9
|
-
let refCount = 0;
|
|
10
|
-
let subscription = null;
|
|
11
|
-
const observers = [];
|
|
12
|
-
function startIfNeeded() {
|
|
13
|
-
if (subscription) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
subscription = originalObserver.subscribe({
|
|
17
|
-
next (value) {
|
|
18
|
-
for (const observer of observers){
|
|
19
|
-
observer.next?.(value);
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
error (error) {
|
|
23
|
-
for (const observer of observers){
|
|
24
|
-
observer.error?.(error);
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
complete () {
|
|
28
|
-
for (const observer of observers){
|
|
29
|
-
observer.complete?.();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function resetIfNeeded() {
|
|
35
|
-
// "resetOnRefCountZero"
|
|
36
|
-
if (refCount === 0 && subscription) {
|
|
37
|
-
const _sub = subscription;
|
|
38
|
-
subscription = null;
|
|
39
|
-
_sub.unsubscribe();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
subscribe (observer) {
|
|
44
|
-
refCount++;
|
|
45
|
-
observers.push(observer);
|
|
46
|
-
startIfNeeded();
|
|
47
|
-
return {
|
|
48
|
-
unsubscribe () {
|
|
49
|
-
refCount--;
|
|
50
|
-
resetIfNeeded();
|
|
51
|
-
const index = observers.findIndex((v)=>v === observer);
|
|
52
|
-
if (index > -1) {
|
|
53
|
-
observers.splice(index, 1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function map(project) {
|
|
63
|
-
return (originalObserver)=>{
|
|
64
|
-
return {
|
|
65
|
-
subscribe (observer) {
|
|
66
|
-
let index = 0;
|
|
67
|
-
const subscription = originalObserver.subscribe({
|
|
68
|
-
next (value) {
|
|
69
|
-
observer.next?.(project(value, index++));
|
|
70
|
-
},
|
|
71
|
-
error (error) {
|
|
72
|
-
observer.error?.(error);
|
|
73
|
-
},
|
|
74
|
-
complete () {
|
|
75
|
-
observer.complete?.();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return subscription;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function tap(observer) {
|
|
85
|
-
return (originalObserver)=>{
|
|
86
|
-
return {
|
|
87
|
-
subscribe (observer2) {
|
|
88
|
-
return originalObserver.subscribe({
|
|
89
|
-
next (v) {
|
|
90
|
-
observer.next?.(v);
|
|
91
|
-
observer2.next?.(v);
|
|
92
|
-
},
|
|
93
|
-
error (v) {
|
|
94
|
-
observer.error?.(v);
|
|
95
|
-
observer2.error?.(v);
|
|
96
|
-
},
|
|
97
|
-
complete () {
|
|
98
|
-
observer.complete?.();
|
|
99
|
-
observer2.complete?.();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
class ObservableAbortError extends Error {
|
|
108
|
-
constructor(message){
|
|
109
|
-
super(message);
|
|
110
|
-
this.name = 'ObservableAbortError';
|
|
111
|
-
Object.setPrototypeOf(this, ObservableAbortError.prototype);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/** @internal */ function observableToPromise(observable) {
|
|
115
|
-
let abort;
|
|
116
|
-
const promise = new Promise((resolve, reject)=>{
|
|
117
|
-
let isDone = false;
|
|
118
|
-
function onDone() {
|
|
119
|
-
if (isDone) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
isDone = true;
|
|
123
|
-
reject(new ObservableAbortError('This operation was aborted.'));
|
|
124
|
-
obs$.unsubscribe();
|
|
125
|
-
}
|
|
126
|
-
const obs$ = observable.subscribe({
|
|
127
|
-
next (data) {
|
|
128
|
-
isDone = true;
|
|
129
|
-
resolve(data);
|
|
130
|
-
onDone();
|
|
131
|
-
},
|
|
132
|
-
error (data) {
|
|
133
|
-
isDone = true;
|
|
134
|
-
reject(data);
|
|
135
|
-
onDone();
|
|
136
|
-
},
|
|
137
|
-
complete () {
|
|
138
|
-
isDone = true;
|
|
139
|
-
onDone();
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
abort = onDone;
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
promise,
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
147
|
-
abort: abort
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
exports.isObservable = observable.isObservable;
|
|
152
|
-
exports.observable = observable.observable;
|
|
153
|
-
exports.map = map;
|
|
154
|
-
exports.observableToPromise = observableToPromise;
|
|
155
|
-
exports.share = share;
|
|
156
|
-
exports.tap = tap;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
export { i as isObservable, o as observable } from '../observable-ade1bad8.mjs';
|
|
2
|
-
|
|
3
|
-
function share(_opts) {
|
|
4
|
-
return (originalObserver)=>{
|
|
5
|
-
let refCount = 0;
|
|
6
|
-
let subscription = null;
|
|
7
|
-
const observers = [];
|
|
8
|
-
function startIfNeeded() {
|
|
9
|
-
if (subscription) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
subscription = originalObserver.subscribe({
|
|
13
|
-
next (value) {
|
|
14
|
-
for (const observer of observers){
|
|
15
|
-
observer.next?.(value);
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
error (error) {
|
|
19
|
-
for (const observer of observers){
|
|
20
|
-
observer.error?.(error);
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
complete () {
|
|
24
|
-
for (const observer of observers){
|
|
25
|
-
observer.complete?.();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function resetIfNeeded() {
|
|
31
|
-
// "resetOnRefCountZero"
|
|
32
|
-
if (refCount === 0 && subscription) {
|
|
33
|
-
const _sub = subscription;
|
|
34
|
-
subscription = null;
|
|
35
|
-
_sub.unsubscribe();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
subscribe (observer) {
|
|
40
|
-
refCount++;
|
|
41
|
-
observers.push(observer);
|
|
42
|
-
startIfNeeded();
|
|
43
|
-
return {
|
|
44
|
-
unsubscribe () {
|
|
45
|
-
refCount--;
|
|
46
|
-
resetIfNeeded();
|
|
47
|
-
const index = observers.findIndex((v)=>v === observer);
|
|
48
|
-
if (index > -1) {
|
|
49
|
-
observers.splice(index, 1);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function map(project) {
|
|
59
|
-
return (originalObserver)=>{
|
|
60
|
-
return {
|
|
61
|
-
subscribe (observer) {
|
|
62
|
-
let index = 0;
|
|
63
|
-
const subscription = originalObserver.subscribe({
|
|
64
|
-
next (value) {
|
|
65
|
-
observer.next?.(project(value, index++));
|
|
66
|
-
},
|
|
67
|
-
error (error) {
|
|
68
|
-
observer.error?.(error);
|
|
69
|
-
},
|
|
70
|
-
complete () {
|
|
71
|
-
observer.complete?.();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return subscription;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function tap(observer) {
|
|
81
|
-
return (originalObserver)=>{
|
|
82
|
-
return {
|
|
83
|
-
subscribe (observer2) {
|
|
84
|
-
return originalObserver.subscribe({
|
|
85
|
-
next (v) {
|
|
86
|
-
observer.next?.(v);
|
|
87
|
-
observer2.next?.(v);
|
|
88
|
-
},
|
|
89
|
-
error (v) {
|
|
90
|
-
observer.error?.(v);
|
|
91
|
-
observer2.error?.(v);
|
|
92
|
-
},
|
|
93
|
-
complete () {
|
|
94
|
-
observer.complete?.();
|
|
95
|
-
observer2.complete?.();
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
class ObservableAbortError extends Error {
|
|
104
|
-
constructor(message){
|
|
105
|
-
super(message);
|
|
106
|
-
this.name = 'ObservableAbortError';
|
|
107
|
-
Object.setPrototypeOf(this, ObservableAbortError.prototype);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/** @internal */ function observableToPromise(observable) {
|
|
111
|
-
let abort;
|
|
112
|
-
const promise = new Promise((resolve, reject)=>{
|
|
113
|
-
let isDone = false;
|
|
114
|
-
function onDone() {
|
|
115
|
-
if (isDone) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
isDone = true;
|
|
119
|
-
reject(new ObservableAbortError('This operation was aborted.'));
|
|
120
|
-
obs$.unsubscribe();
|
|
121
|
-
}
|
|
122
|
-
const obs$ = observable.subscribe({
|
|
123
|
-
next (data) {
|
|
124
|
-
isDone = true;
|
|
125
|
-
resolve(data);
|
|
126
|
-
onDone();
|
|
127
|
-
},
|
|
128
|
-
error (data) {
|
|
129
|
-
isDone = true;
|
|
130
|
-
reject(data);
|
|
131
|
-
onDone();
|
|
132
|
-
},
|
|
133
|
-
complete () {
|
|
134
|
-
isDone = true;
|
|
135
|
-
onDone();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
abort = onDone;
|
|
139
|
-
});
|
|
140
|
-
return {
|
|
141
|
-
promise,
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
143
|
-
abort: abort
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export { map, observableToPromise, share, tap };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/observable/internals/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,KAAK,CAE/C"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Observable } from '../types';
|
|
2
|
-
export declare class ObservableAbortError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
/** @internal */
|
|
6
|
-
export declare function observableToPromise<TValue>(observable: Observable<TValue, unknown>): {
|
|
7
|
-
promise: Promise<TValue>;
|
|
8
|
-
abort: () => void;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=observableToPromise.d.ts.map
|