@trpc/server 10.28.0 → 10.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/{TRPCError-61026c9a.js → TRPCError-7c3909ea.js} +47 -47
  2. package/dist/adapters/aws-lambda/index.d.ts +9 -9
  3. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  4. package/dist/adapters/aws-lambda/utils.d.ts +37 -37
  5. package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
  6. package/dist/adapters/express.d.ts +5 -5
  7. package/dist/adapters/express.d.ts.map +1 -1
  8. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +12 -12
  9. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  10. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +11 -11
  11. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  12. package/dist/adapters/fastify/index.d.ts +2 -2
  13. package/dist/adapters/fetch/fetchRequestHandler.d.ts +7 -7
  14. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  15. package/dist/adapters/fetch/index.d.ts +2 -2
  16. package/dist/adapters/fetch/types.d.ts +19 -19
  17. package/dist/adapters/fetch/types.d.ts.map +1 -1
  18. package/dist/adapters/lambda/index.d.ts +11 -11
  19. package/dist/adapters/lambda/index.d.ts.map +1 -1
  20. package/dist/adapters/next.d.ts +5 -5
  21. package/dist/adapters/next.d.ts.map +1 -1
  22. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts +69 -69
  23. package/dist/adapters/node-http/content-type/form-data/fileUploadHandler.d.ts.map +1 -1
  24. package/dist/adapters/node-http/content-type/form-data/index.d.ts +23 -23
  25. package/dist/adapters/node-http/content-type/form-data/index.js +1 -3
  26. package/dist/adapters/node-http/content-type/form-data/index.mjs +1 -3
  27. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts +30 -30
  28. package/dist/adapters/node-http/content-type/form-data/memoryUploadHandler.d.ts.map +1 -1
  29. package/dist/adapters/node-http/content-type/form-data/streamSlice.d.ts +10 -10
  30. package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts +40 -39
  31. package/dist/adapters/node-http/content-type/form-data/uploadHandler.d.ts.map +1 -1
  32. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +6 -6
  33. package/dist/adapters/node-http/content-type/json/index.d.ts +1 -1
  34. package/dist/adapters/node-http/index.d.ts +2 -2
  35. package/dist/adapters/node-http/internals/contentType.d.ts +8 -8
  36. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +3 -3
  37. package/dist/adapters/node-http/types.d.ts +63 -63
  38. package/dist/adapters/node-http/types.d.ts.map +1 -1
  39. package/dist/adapters/standalone.d.ts +13 -13
  40. package/dist/adapters/standalone.d.ts.map +1 -1
  41. package/dist/adapters/ws.d.ts +21 -21
  42. package/dist/adapters/ws.d.ts.map +1 -1
  43. package/dist/{codes-b3c262d8.js → codes-1c9ad84e.js} +44 -44
  44. package/dist/{config-1a5a494d.js → config-54786004.js} +168 -168
  45. package/dist/{contentType-f27e4bfc.js → contentType-24c44bba.js} +2 -2
  46. package/dist/{contentType-a75c990c.js → contentType-7354963c.js} +54 -54
  47. package/dist/core/index.d.ts +8 -8
  48. package/dist/core/initTRPC.d.ts +104 -104
  49. package/dist/core/initTRPC.d.ts.map +1 -1
  50. package/dist/core/internals/config.d.ts +74 -74
  51. package/dist/core/internals/config.d.ts.map +1 -1
  52. package/dist/core/internals/getParseFn.d.ts +8 -8
  53. package/dist/core/internals/getParseFn.d.ts.map +1 -1
  54. package/dist/core/internals/mergeRouters.d.ts +17 -17
  55. package/dist/core/internals/mergeRouters.d.ts.map +1 -1
  56. package/dist/core/internals/mergeWithoutOverrides.d.ts +4 -4
  57. package/dist/core/internals/omitPrototype.d.ts +5 -5
  58. package/dist/core/internals/procedureBuilder.d.ts +115 -115
  59. package/dist/core/internals/procedureBuilder.d.ts.map +1 -1
  60. package/dist/core/internals/utils.d.ts +51 -51
  61. package/dist/core/internals/utils.d.ts.map +1 -1
  62. package/dist/core/middleware.d.ts +127 -127
  63. package/dist/core/middleware.d.ts.map +1 -1
  64. package/dist/core/parser.d.ts +27 -27
  65. package/dist/core/parser.d.ts.map +1 -1
  66. package/dist/core/procedure.d.ts +72 -72
  67. package/dist/core/procedure.d.ts.map +1 -1
  68. package/dist/core/router.d.ts +111 -111
  69. package/dist/core/router.d.ts.map +1 -1
  70. package/dist/core/types.d.ts +28 -28
  71. package/dist/core/types.d.ts.map +1 -1
  72. package/dist/deprecated/internals/middlewares.d.ts +51 -51
  73. package/dist/deprecated/internals/middlewares.d.ts.map +1 -1
  74. package/dist/deprecated/internals/procedure.d.ts +95 -95
  75. package/dist/deprecated/internals/procedure.d.ts.map +1 -1
  76. package/dist/deprecated/interop.d.ts +43 -43
  77. package/dist/deprecated/interop.d.ts.map +1 -1
  78. package/dist/deprecated/router.d.ts +203 -203
  79. package/dist/deprecated/router.d.ts.map +1 -1
  80. package/dist/error/TRPCError.d.ts +11 -11
  81. package/dist/error/formatter.d.ts +32 -32
  82. package/dist/error/formatter.d.ts.map +1 -1
  83. package/dist/error/utils.d.ts +5 -5
  84. package/dist/http/contentType.d.ts +28 -28
  85. package/dist/http/contentType.d.ts.map +1 -1
  86. package/dist/http/getHTTPStatusCode.d.ts +23 -23
  87. package/dist/http/getHTTPStatusCode.d.ts.map +1 -1
  88. package/dist/http/index.d.ts +3 -3
  89. package/dist/http/internals/types.d.ts +24 -24
  90. package/dist/http/internals/types.d.ts.map +1 -1
  91. package/dist/http/resolveHTTPResponse.d.ts +16 -16
  92. package/dist/http/types.d.ts +24 -24
  93. package/dist/{index-6d5795e9.js → index-ca9a128e.js} +88 -88
  94. package/dist/index.d.ts +6 -6
  95. package/dist/internals/invert.d.ts +11 -11
  96. package/dist/internals/invert.d.ts.map +1 -1
  97. package/dist/internals/types.d.ts +25 -25
  98. package/dist/internals/types.d.ts.map +1 -1
  99. package/dist/internals.d.ts +9 -9
  100. package/dist/{nodeHTTPRequestHandler-e424955c.js → nodeHTTPRequestHandler-bd47641d.js} +62 -62
  101. package/dist/observable/index.d.ts +4 -4
  102. package/dist/observable/internals/identity.d.ts +1 -1
  103. package/dist/observable/internals/observableToPromise.d.ts +9 -9
  104. package/dist/observable/internals/pipe.d.ts +3 -3
  105. package/dist/observable/observable.d.ts +4 -4
  106. package/dist/observable/observable.d.ts.map +1 -1
  107. package/dist/observable/operators/index.d.ts +3 -3
  108. package/dist/observable/operators/map.d.ts +2 -2
  109. package/dist/observable/operators/share.d.ts +5 -5
  110. package/dist/observable/operators/tap.d.ts +2 -2
  111. package/dist/observable/types.d.ts +28 -28
  112. package/dist/observable/types.d.ts.map +1 -1
  113. package/dist/{observable-a1c2103f.js → observable-15588f28.js} +76 -76
  114. package/dist/{resolveHTTPResponse-4e05c4f8.js → resolveHTTPResponse-ba557d3e.js} +162 -162
  115. package/dist/rpc/codes.d.ts +52 -52
  116. package/dist/rpc/codes.d.ts.map +1 -1
  117. package/dist/rpc/envelopes.d.ts +98 -98
  118. package/dist/rpc/envelopes.d.ts.map +1 -1
  119. package/dist/rpc/index.d.ts +2 -2
  120. package/dist/shared/createProxy/index.d.ts +18 -18
  121. package/dist/shared/createProxy/index.d.ts.map +1 -1
  122. package/dist/shared/getErrorShape.d.ts +14 -14
  123. package/dist/shared/index.d.ts +5 -5
  124. package/dist/shared/internal/serialize.d.ts +29 -29
  125. package/dist/shared/internal/serialize.d.ts.map +1 -1
  126. package/dist/shared/jsonify.d.ts +9 -9
  127. package/dist/shared/jsonify.d.ts.map +1 -1
  128. package/dist/shared/transformTRPCResponse.d.ts +8 -8
  129. package/dist/shared/transformTRPCResponse.d.ts.map +1 -1
  130. package/dist/subscription.d.ts +12 -12
  131. package/dist/{transformTRPCResponse-64a4fd96.js → transformTRPCResponse-7fcbe472.js} +48 -48
  132. package/dist/transformer.d.ts +73 -73
  133. package/dist/transformer.d.ts.map +1 -1
  134. package/dist/types.d.ts +77 -77
  135. package/dist/types.d.ts.map +1 -1
  136. package/package.json +5 -5
  137. package/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts +3 -3
  138. package/src/adapters/node-http/content-type/form-data/uploadHandler.ts +3 -1
@@ -1,67 +1,67 @@
1
- import { r as resolveHTTPResponse } from './resolveHTTPResponse-4e05c4f8.js';
1
+ import { r as resolveHTTPResponse } from './resolveHTTPResponse-ba557d3e.js';
2
2
  import { nodeHTTPJSONContentTypeHandler } from './adapters/node-http/content-type/json/index.js';
3
3
 
4
- const defaultJSONContentTypeHandler = nodeHTTPJSONContentTypeHandler();
5
- async function nodeHTTPRequestHandler(opts) {
6
- const handleViaMiddleware = opts.middleware ?? ((_req, _res, next) => next());
7
- return handleViaMiddleware(opts.req, opts.res, async (err) => {
8
- if (err)
9
- throw err;
10
- const createContext = async () => {
11
- return await opts.createContext?.(opts);
12
- };
13
- const query = opts.req.query
14
- ? new URLSearchParams(opts.req.query)
15
- : new URLSearchParams(opts.req.url.split('?')[1]);
16
- const jsonContentTypeHandler = defaultJSONContentTypeHandler;
17
- const contentTypeHandlers = opts.experimental_contentTypeHandlers ?? [
18
- jsonContentTypeHandler,
19
- ];
20
- const contentTypeHandler = contentTypeHandlers.find((handler) => handler.isMatch({
21
- ...opts,
22
- query,
23
- })) ??
24
- // fallback to json
25
- jsonContentTypeHandler;
26
- const bodyResult = await contentTypeHandler.getBody({
27
- ...opts,
28
- query,
29
- });
30
- const req = {
31
- method: opts.req.method,
32
- headers: opts.req.headers,
33
- query,
34
- body: bodyResult.ok ? bodyResult.data : undefined,
35
- };
36
- const result = await resolveHTTPResponse({
37
- batching: opts.batching,
38
- responseMeta: opts.responseMeta,
39
- path: opts.path,
40
- createContext,
41
- router: opts.router,
42
- req,
43
- error: bodyResult.ok ? null : bodyResult.error,
44
- preprocessedBody: bodyResult.ok ? bodyResult.preprocessed : false,
45
- onError(o) {
46
- opts?.onError?.({
47
- ...o,
48
- req: opts.req,
49
- });
50
- },
51
- contentTypeHandler,
52
- });
53
- const { res } = opts;
54
- if ('status' in result && (!res.statusCode || res.statusCode === 200)) {
55
- res.statusCode = result.status;
56
- }
57
- for (const [key, value] of Object.entries(result.headers ?? {})) {
58
- if (typeof value === 'undefined') {
59
- continue;
60
- }
61
- res.setHeader(key, value);
62
- }
63
- res.end(result.body);
64
- });
4
+ const defaultJSONContentTypeHandler = nodeHTTPJSONContentTypeHandler();
5
+ async function nodeHTTPRequestHandler(opts) {
6
+ const handleViaMiddleware = opts.middleware ?? ((_req, _res, next) => next());
7
+ return handleViaMiddleware(opts.req, opts.res, async (err) => {
8
+ if (err)
9
+ throw err;
10
+ const createContext = async () => {
11
+ return await opts.createContext?.(opts);
12
+ };
13
+ const query = opts.req.query
14
+ ? new URLSearchParams(opts.req.query)
15
+ : new URLSearchParams(opts.req.url.split('?')[1]);
16
+ const jsonContentTypeHandler = defaultJSONContentTypeHandler;
17
+ const contentTypeHandlers = opts.experimental_contentTypeHandlers ?? [
18
+ jsonContentTypeHandler,
19
+ ];
20
+ const contentTypeHandler = contentTypeHandlers.find((handler) => handler.isMatch({
21
+ ...opts,
22
+ query,
23
+ })) ??
24
+ // fallback to json
25
+ jsonContentTypeHandler;
26
+ const bodyResult = await contentTypeHandler.getBody({
27
+ ...opts,
28
+ query,
29
+ });
30
+ const req = {
31
+ method: opts.req.method,
32
+ headers: opts.req.headers,
33
+ query,
34
+ body: bodyResult.ok ? bodyResult.data : undefined,
35
+ };
36
+ const result = await resolveHTTPResponse({
37
+ batching: opts.batching,
38
+ responseMeta: opts.responseMeta,
39
+ path: opts.path,
40
+ createContext,
41
+ router: opts.router,
42
+ req,
43
+ error: bodyResult.ok ? null : bodyResult.error,
44
+ preprocessedBody: bodyResult.ok ? bodyResult.preprocessed : false,
45
+ onError(o) {
46
+ opts?.onError?.({
47
+ ...o,
48
+ req: opts.req,
49
+ });
50
+ },
51
+ contentTypeHandler,
52
+ });
53
+ const { res } = opts;
54
+ if ('status' in result && (!res.statusCode || res.statusCode === 200)) {
55
+ res.statusCode = result.status;
56
+ }
57
+ for (const [key, value] of Object.entries(result.headers ?? {})) {
58
+ if (typeof value === 'undefined') {
59
+ continue;
60
+ }
61
+ res.setHeader(key, value);
62
+ }
63
+ res.end(result.body);
64
+ });
65
65
  }
66
66
 
67
67
  export { nodeHTTPRequestHandler as n };
@@ -1,5 +1,5 @@
1
- export * from './observable';
2
- export * from './types';
3
- export * from './operators';
4
- export { observableToPromise } from './internals/observableToPromise';
1
+ export * from './observable';
2
+ export * from './types';
3
+ export * from './operators';
4
+ export { observableToPromise } from './internals/observableToPromise';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare function identity<TType>(x: TType): TType;
1
+ export declare function identity<TType>(x: TType): TType;
2
2
  //# sourceMappingURL=identity.d.ts.map
@@ -1,10 +1,10 @@
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
- };
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
10
  //# sourceMappingURL=observableToPromise.d.ts.map
@@ -1,4 +1,4 @@
1
- import { UnaryFunction } from '../types';
2
- /** @internal */
3
- export declare function pipeFromArray<TSource, TReturn>(fns: Array<UnaryFunction<TSource, TReturn>>): UnaryFunction<TSource, TReturn>;
1
+ import { UnaryFunction } from '../types';
2
+ /** @internal */
3
+ export declare function pipeFromArray<TSource, TReturn>(fns: Array<UnaryFunction<TSource, TReturn>>): UnaryFunction<TSource, TReturn>;
4
4
  //# sourceMappingURL=pipe.d.ts.map
@@ -1,5 +1,5 @@
1
- import { Observable, Observer, TeardownLogic } from './types';
2
- export declare type inferObservableValue<TObservable> = TObservable extends Observable<infer TValue, unknown> ? TValue : never;
3
- export declare function isObservable(x: unknown): x is Observable<unknown, unknown>;
4
- export declare function observable<TValue, TError = unknown>(subscribe: (observer: Observer<TValue, TError>) => TeardownLogic): Observable<TValue, TError>;
1
+ import { Observable, Observer, TeardownLogic } from './types';
2
+ export type inferObservableValue<TObservable> = TObservable extends Observable<infer TValue, unknown> ? TValue : never;
3
+ export declare function isObservable(x: unknown): x is Observable<unknown, unknown>;
4
+ export declare function observable<TValue, TError = unknown>(subscribe: (observer: Observer<TValue, TError>) => TeardownLogic): Observable<TValue, TError>;
5
5
  //# sourceMappingURL=observable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/observable/observable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhF,oBAAY,oBAAoB,CAAC,WAAW,IAAI,WAAW,SAAS,UAAU,CAC5E,MAAM,MAAM,EACZ,OAAO,CACR,GACG,MAAM,GACN,KAAK,CAAC;AAEV,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAE1E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EACjD,SAAS,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,aAAa,GAC/D,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CA6D5B"}
1
+ {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/observable/observable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhF,MAAM,MAAM,oBAAoB,CAAC,WAAW,IAAI,WAAW,SAAS,UAAU,CAC5E,MAAM,MAAM,EACZ,OAAO,CACR,GACG,MAAM,GACN,KAAK,CAAC;AAEV,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAE1E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EACjD,SAAS,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,aAAa,GAC/D,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CA6D5B"}
@@ -1,4 +1,4 @@
1
- export * from './share';
2
- export * from './map';
3
- export * from './tap';
1
+ export * from './share';
2
+ export * from './map';
3
+ export * from './tap';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
- import { OperatorFunction } from '../types';
2
- export declare function map<TValueBefore, TError, TValueAfter>(project: (value: TValueBefore, index: number) => TValueAfter): OperatorFunction<TValueBefore, TError, TValueAfter, TError>;
1
+ import { OperatorFunction } from '../types';
2
+ export declare function map<TValueBefore, TError, TValueAfter>(project: (value: TValueBefore, index: number) => TValueAfter): OperatorFunction<TValueBefore, TError, TValueAfter, TError>;
3
3
  //# sourceMappingURL=map.d.ts.map
@@ -1,6 +1,6 @@
1
- import { MonoTypeOperatorFunction } from '../types';
2
- interface ShareConfig {
3
- }
4
- export declare function share<TValue, TError>(_opts?: ShareConfig): MonoTypeOperatorFunction<TValue, TError>;
5
- export {};
1
+ import { MonoTypeOperatorFunction } from '../types';
2
+ interface ShareConfig {
3
+ }
4
+ export declare function share<TValue, TError>(_opts?: ShareConfig): MonoTypeOperatorFunction<TValue, TError>;
5
+ export {};
6
6
  //# sourceMappingURL=share.d.ts.map
@@ -1,3 +1,3 @@
1
- import { MonoTypeOperatorFunction, Observer } from '../types';
2
- export declare function tap<TValue, TError>(observer: Partial<Observer<TValue, TError>>): MonoTypeOperatorFunction<TValue, TError>;
1
+ import { MonoTypeOperatorFunction, Observer } from '../types';
2
+ export declare function tap<TValue, TError>(observer: Partial<Observer<TValue, TError>>): MonoTypeOperatorFunction<TValue, TError>;
3
3
  //# sourceMappingURL=tap.d.ts.map
@@ -1,29 +1,29 @@
1
- export interface Unsubscribable {
2
- unsubscribe(): void;
3
- }
4
- export declare type UnsubscribeFn = () => void;
5
- export interface Subscribable<TValue, TError> {
6
- subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
7
- }
8
- export interface Observable<TValue, TError> extends Subscribable<TValue, TError> {
9
- pipe(): Observable<TValue, TError>;
10
- pipe<TValue1, TError1>(op1: OperatorFunction<TValue, TError, TValue1, TError1>): Observable<TValue1, TError1>;
11
- pipe<TValue1, TError1, TValue2, TError2>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>): Observable<TValue2, TError2>;
12
- pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>): Observable<TValue2, TError2>;
13
- pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>): Observable<TValue2, TError2>;
14
- pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4, TValue5, TError5>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>, op5: OperatorFunction<TValue4, TError4, TValue5, TError5>): Observable<TValue2, TError2>;
15
- }
16
- export interface SubscriptionLike extends Unsubscribable {
17
- unsubscribe(): void;
18
- readonly closed: boolean;
19
- }
20
- export interface Observer<TValue, TError> {
21
- next: (value: TValue) => void;
22
- error: (err: TError) => void;
23
- complete: () => void;
24
- }
25
- export declare type TeardownLogic = Unsubscribable | UnsubscribeFn | void;
26
- export declare type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
27
- export declare type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
28
- export declare type MonoTypeOperatorFunction<TValue, TError> = OperatorFunction<TValue, TError, TValue, TError>;
1
+ export interface Unsubscribable {
2
+ unsubscribe(): void;
3
+ }
4
+ export type UnsubscribeFn = () => void;
5
+ export interface Subscribable<TValue, TError> {
6
+ subscribe(observer: Partial<Observer<TValue, TError>>): Unsubscribable;
7
+ }
8
+ export interface Observable<TValue, TError> extends Subscribable<TValue, TError> {
9
+ pipe(): Observable<TValue, TError>;
10
+ pipe<TValue1, TError1>(op1: OperatorFunction<TValue, TError, TValue1, TError1>): Observable<TValue1, TError1>;
11
+ pipe<TValue1, TError1, TValue2, TError2>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>): Observable<TValue2, TError2>;
12
+ pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>): Observable<TValue2, TError2>;
13
+ pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>): Observable<TValue2, TError2>;
14
+ pipe<TValue1, TError1, TValue2, TError2, TValue3, TError3, TValue4, TError4, TValue5, TError5>(op1: OperatorFunction<TValue, TError, TValue1, TError1>, op2: OperatorFunction<TValue1, TError1, TValue2, TError2>, op3: OperatorFunction<TValue2, TError2, TValue3, TError3>, op4: OperatorFunction<TValue3, TError3, TValue4, TError4>, op5: OperatorFunction<TValue4, TError4, TValue5, TError5>): Observable<TValue2, TError2>;
15
+ }
16
+ export interface SubscriptionLike extends Unsubscribable {
17
+ unsubscribe(): void;
18
+ readonly closed: boolean;
19
+ }
20
+ export interface Observer<TValue, TError> {
21
+ next: (value: TValue) => void;
22
+ error: (err: TError) => void;
23
+ complete: () => void;
24
+ }
25
+ export type TeardownLogic = Unsubscribable | UnsubscribeFn | void;
26
+ export type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
27
+ export type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
28
+ export type MonoTypeOperatorFunction<TValue, TError> = OperatorFunction<TValue, TError, TValue, TError>;
29
29
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/observable/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,WAAW,IAAI,IAAI,CAAC;CACrB;AACD,oBAAY,aAAa,GAAG,MAAM,IAAI,CAAC;AACvC,MAAM,WAAW,YAAY,CAAC,MAAM,EAAE,MAAM;IAC1C,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,cAAc,CAAC;CACxE;AACD,MAAM,WAAW,UAAU,CAAC,MAAM,EAAE,MAAM,CACxC,SAAQ,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;IACpC,IAAI,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,OAAO,EACnB,GAAG,EAAE,gBAAgB,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C,CAAC;CACjC;AACD,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,WAAW,IAAI,IAAI,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ,CAAC,MAAM,EAAE,MAAM;IACtC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,aAAa,GAEvB,cAAc,GAAG,aAAa,GAAG,IAAI,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;AAE3E,MAAM,MAAM,gBAAgB,CAC1B,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,IACT,aAAa,CACf,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,EACxC,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CACvC,CAAC;AAEF,MAAM,MAAM,wBAAwB,CAAC,MAAM,EAAE,MAAM,IAAI,gBAAgB,CACrE,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP,CAAC"}
@@ -1,83 +1,83 @@
1
- function identity(x) {
2
- return x;
1
+ function identity(x) {
2
+ return x;
3
3
  }
4
4
 
5
- /** @internal */
6
- function pipeFromArray(fns) {
7
- if (fns.length === 0) {
8
- return identity;
9
- }
10
- if (fns.length === 1) {
11
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12
- return fns[0];
13
- }
14
- return function piped(input) {
15
- return fns.reduce((prev, fn) => fn(prev), input);
16
- };
5
+ /** @internal */
6
+ function pipeFromArray(fns) {
7
+ if (fns.length === 0) {
8
+ return identity;
9
+ }
10
+ if (fns.length === 1) {
11
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
12
+ return fns[0];
13
+ }
14
+ return function piped(input) {
15
+ return fns.reduce((prev, fn) => fn(prev), input);
16
+ };
17
17
  }
18
18
 
19
- function isObservable(x) {
20
- return typeof x === 'object' && x !== null && 'subscribe' in x;
21
- }
22
- function observable(subscribe) {
23
- const self = {
24
- subscribe(observer) {
25
- let teardownRef = null;
26
- let isDone = false;
27
- let unsubscribed = false;
28
- let teardownImmediately = false;
29
- function unsubscribe() {
30
- if (teardownRef === null) {
31
- teardownImmediately = true;
32
- return;
33
- }
34
- if (unsubscribed) {
35
- return;
36
- }
37
- unsubscribed = true;
38
- if (typeof teardownRef === 'function') {
39
- teardownRef();
40
- }
41
- else if (teardownRef) {
42
- teardownRef.unsubscribe();
43
- }
44
- }
45
- teardownRef = subscribe({
46
- next(value) {
47
- if (isDone) {
48
- return;
49
- }
50
- observer.next?.(value);
51
- },
52
- error(err) {
53
- if (isDone) {
54
- return;
55
- }
56
- isDone = true;
57
- observer.error?.(err);
58
- unsubscribe();
59
- },
60
- complete() {
61
- if (isDone) {
62
- return;
63
- }
64
- isDone = true;
65
- observer.complete?.();
66
- unsubscribe();
67
- },
68
- });
69
- if (teardownImmediately) {
70
- unsubscribe();
71
- }
72
- return {
73
- unsubscribe,
74
- };
75
- },
76
- pipe(...operations) {
77
- return pipeFromArray(operations)(self);
78
- },
79
- };
80
- return self;
19
+ function isObservable(x) {
20
+ return typeof x === 'object' && x !== null && 'subscribe' in x;
21
+ }
22
+ function observable(subscribe) {
23
+ const self = {
24
+ subscribe(observer) {
25
+ let teardownRef = null;
26
+ let isDone = false;
27
+ let unsubscribed = false;
28
+ let teardownImmediately = false;
29
+ function unsubscribe() {
30
+ if (teardownRef === null) {
31
+ teardownImmediately = true;
32
+ return;
33
+ }
34
+ if (unsubscribed) {
35
+ return;
36
+ }
37
+ unsubscribed = true;
38
+ if (typeof teardownRef === 'function') {
39
+ teardownRef();
40
+ }
41
+ else if (teardownRef) {
42
+ teardownRef.unsubscribe();
43
+ }
44
+ }
45
+ teardownRef = subscribe({
46
+ next(value) {
47
+ if (isDone) {
48
+ return;
49
+ }
50
+ observer.next?.(value);
51
+ },
52
+ error(err) {
53
+ if (isDone) {
54
+ return;
55
+ }
56
+ isDone = true;
57
+ observer.error?.(err);
58
+ unsubscribe();
59
+ },
60
+ complete() {
61
+ if (isDone) {
62
+ return;
63
+ }
64
+ isDone = true;
65
+ observer.complete?.();
66
+ unsubscribe();
67
+ },
68
+ });
69
+ if (teardownImmediately) {
70
+ unsubscribe();
71
+ }
72
+ return {
73
+ unsubscribe,
74
+ };
75
+ },
76
+ pipe(...operations) {
77
+ return pipeFromArray(operations)(self);
78
+ },
79
+ };
80
+ return self;
81
81
  }
82
82
 
83
83
  export { isObservable as i, observable as o };