@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.229 → 11.0.0-alpha-tmp-export-from-main.212

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 (234) hide show
  1. package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +10 -0
  2. package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
  3. package/dist/@trpc-server/http.d.ts +2 -0
  4. package/dist/@trpc-server/http.d.ts.map +1 -0
  5. package/dist/{@trpc/server/index.d.ts → @trpc-server.d.ts} +4 -4
  6. package/dist/@trpc-server.d.ts.map +1 -0
  7. package/dist/adapters/aws-lambda/index.d.ts +2 -1
  8. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  9. package/dist/adapters/aws-lambda/index.js +7 -10
  10. package/dist/adapters/aws-lambda/index.mjs +3 -6
  11. package/dist/adapters/aws-lambda/utils.d.ts +3 -2
  12. package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
  13. package/dist/adapters/express.d.ts +2 -1
  14. package/dist/adapters/express.d.ts.map +1 -1
  15. package/dist/adapters/express.js +2 -8
  16. package/dist/adapters/express.mjs +2 -8
  17. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
  18. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  19. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +2 -1
  20. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  21. package/dist/adapters/fastify/index.js +4 -11
  22. package/dist/adapters/fastify/index.mjs +2 -9
  23. package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -1
  24. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  25. package/dist/adapters/fetch/index.js +4 -9
  26. package/dist/adapters/fetch/index.mjs +2 -7
  27. package/dist/adapters/fetch/types.d.ts +3 -2
  28. package/dist/adapters/fetch/types.d.ts.map +1 -1
  29. package/dist/adapters/next.d.ts +2 -1
  30. package/dist/adapters/next.d.ts.map +1 -1
  31. package/dist/adapters/next.js +5 -10
  32. package/dist/adapters/next.mjs +3 -8
  33. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
  34. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  35. package/dist/adapters/node-http/content-type/json/index.js +3 -5
  36. package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
  37. package/dist/adapters/node-http/index.js +2 -8
  38. package/dist/adapters/node-http/index.mjs +2 -8
  39. package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
  40. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +2 -1
  41. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  42. package/dist/adapters/node-http/types.d.ts +4 -3
  43. package/dist/adapters/node-http/types.d.ts.map +1 -1
  44. package/dist/adapters/standalone.d.ts +2 -1
  45. package/dist/adapters/standalone.d.ts.map +1 -1
  46. package/dist/adapters/standalone.js +2 -9
  47. package/dist/adapters/standalone.mjs +2 -9
  48. package/dist/adapters/ws.d.ts +2 -3
  49. package/dist/adapters/ws.d.ts.map +1 -1
  50. package/dist/adapters/ws.js +26 -31
  51. package/dist/adapters/ws.mjs +1 -6
  52. package/dist/http.d.ts +6 -1
  53. package/dist/http.d.ts.map +1 -1
  54. package/dist/http.js +21 -12
  55. package/dist/http.mjs +1 -7
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +41 -15
  58. package/dist/index.mjs +1 -5
  59. package/dist/{nodeHTTPRequestHandler-c5d1d163.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -3
  60. package/dist/{nodeHTTPRequestHandler-71a3f758.js → nodeHTTPRequestHandler-55f05150.js} +4 -5
  61. package/dist/{nodeHTTPRequestHandler-f60f0b99.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
  62. package/dist/observable.d.ts +3 -0
  63. package/dist/observable.d.ts.map +1 -0
  64. package/dist/observable.js +32 -0
  65. package/dist/observable.mjs +1 -0
  66. package/dist/rpc.d.ts +2 -1
  67. package/dist/rpc.d.ts.map +1 -1
  68. package/dist/rpc.js +13 -5
  69. package/dist/rpc.mjs +1 -2
  70. package/dist/shared.d.ts +1 -1
  71. package/dist/shared.js +9 -4
  72. package/dist/shared.mjs +1 -2
  73. package/package.json +125 -53
  74. package/src/@trpc-core-unstable-do-not-import-this-please.ts +146 -0
  75. package/src/@trpc-server/http.ts +2 -0
  76. package/src/{@trpc/server/index.ts → @trpc-server.ts} +3 -3
  77. package/src/adapters/aws-lambda/index.ts +5 -4
  78. package/src/adapters/aws-lambda/utils.ts +4 -3
  79. package/src/adapters/express.ts +3 -1
  80. package/src/adapters/fastify/fastifyRequestHandler.ts +4 -6
  81. package/src/adapters/fastify/fastifyTRPCPlugin.ts +2 -1
  82. package/src/adapters/fetch/fetchRequestHandler.ts +4 -6
  83. package/src/adapters/fetch/types.ts +3 -2
  84. package/src/adapters/next.ts +3 -2
  85. package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
  86. package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
  87. package/src/adapters/node-http/content-type/json/index.ts +1 -1
  88. package/src/adapters/node-http/internals/contentType.ts +2 -2
  89. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -6
  90. package/src/adapters/node-http/types.ts +5 -4
  91. package/src/adapters/standalone.ts +2 -2
  92. package/src/adapters/ws.ts +13 -14
  93. package/src/http.ts +26 -1
  94. package/src/index.ts +1 -1
  95. package/src/observable.ts +16 -0
  96. package/src/rpc.ts +26 -1
  97. package/src/shared.ts +1 -1
  98. package/dist/@trpc/server/http.d.ts +0 -7
  99. package/dist/@trpc/server/http.d.ts.map +0 -1
  100. package/dist/@trpc/server/index.d.ts.map +0 -1
  101. package/dist/@trpc/server/rpc.d.ts +0 -3
  102. package/dist/@trpc/server/rpc.d.ts.map +0 -1
  103. package/dist/TRPCError-54f51dec.mjs +0 -63
  104. package/dist/TRPCError-6f02e18d.js +0 -67
  105. package/dist/TRPCError-792b0901.js +0 -61
  106. package/dist/batchStreamFormatter-1971db27.js +0 -32
  107. package/dist/batchStreamFormatter-378277dc.mjs +0 -30
  108. package/dist/batchStreamFormatter-4375dc8b.js +0 -31
  109. package/dist/bundle-analysis.json +0 -757
  110. package/dist/contentType-19471015.js +0 -59
  111. package/dist/contentType-2e62862d.mjs +0 -52
  112. package/dist/contentType-4cd0be82.js +0 -54
  113. package/dist/createProxy-562377d3.js +0 -127
  114. package/dist/createProxy-72161f42.js +0 -116
  115. package/dist/createProxy-f7ba8b4d.mjs +0 -121
  116. package/dist/initTRPC-12d9099b.js +0 -371
  117. package/dist/initTRPC-69a60dfb.js +0 -384
  118. package/dist/initTRPC-dcdfb896.mjs +0 -376
  119. package/dist/observable/index.d.ts +0 -5
  120. package/dist/observable/index.d.ts.map +0 -1
  121. package/dist/observable/index.js +0 -110
  122. package/dist/observable/index.mjs +0 -101
  123. package/dist/observable/observable.d.ts +0 -13
  124. package/dist/observable/observable.d.ts.map +0 -1
  125. package/dist/observable/operators.d.ts +0 -8
  126. package/dist/observable/operators.d.ts.map +0 -1
  127. package/dist/observable/types.d.ts +0 -26
  128. package/dist/observable/types.d.ts.map +0 -1
  129. package/dist/observable-25f4098f.js +0 -126
  130. package/dist/observable-bf75028f.mjs +0 -122
  131. package/dist/observable-e837fe43.js +0 -126
  132. package/dist/parseTRPCMessage-aeb00dbd.js +0 -67
  133. package/dist/parseTRPCMessage-ddbcc719.mjs +0 -62
  134. package/dist/parseTRPCMessage-ee50b281.js +0 -65
  135. package/dist/resolveHTTPResponse-104460bf.js +0 -293
  136. package/dist/resolveHTTPResponse-6a85f0a7.js +0 -265
  137. package/dist/resolveHTTPResponse-eb29e5cf.mjs +0 -291
  138. package/dist/rootConfig-52aed7d7.js +0 -88
  139. package/dist/rootConfig-7d3e1fc8.mjs +0 -76
  140. package/dist/rootConfig-ccd626d6.js +0 -83
  141. package/dist/router-5a3e1181.mjs +0 -252
  142. package/dist/router-5e93cd14.js +0 -259
  143. package/dist/router-d9e22315.js +0 -262
  144. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
  145. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
  146. package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
  147. package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
  148. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
  149. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
  150. package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
  151. package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
  152. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
  153. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
  154. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
  155. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
  156. package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
  157. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
  158. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
  159. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
  160. package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
  161. package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
  162. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
  163. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
  164. package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
  165. package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
  166. package/dist/unstable-core-do-not-import/index.d.ts +0 -37
  167. package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
  168. package/dist/unstable-core-do-not-import/index.js +0 -43
  169. package/dist/unstable-core-do-not-import/index.mjs +0 -9
  170. package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
  171. package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
  172. package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
  173. package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
  174. package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
  175. package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
  176. package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
  177. package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
  178. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
  179. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
  180. package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
  181. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
  182. package/dist/unstable-core-do-not-import/router.d.ts +0 -85
  183. package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
  184. package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
  185. package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
  186. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
  187. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
  188. package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
  189. package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
  190. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
  191. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
  192. package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
  193. package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
  194. package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
  195. package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
  196. package/dist/unstable-core-do-not-import/types.d.ts +0 -98
  197. package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
  198. package/dist/unstable-core-do-not-import/utils.d.ts +0 -27
  199. package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
  200. package/src/@trpc/server/http.ts +0 -26
  201. package/src/@trpc/server/rpc.ts +0 -26
  202. package/src/observable/index.ts +0 -10
  203. package/src/observable/observable.ts +0 -158
  204. package/src/observable/operators.ts +0 -119
  205. package/src/observable/types.ts +0 -76
  206. package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
  207. package/src/unstable-core-do-not-import/createProxy.ts +0 -59
  208. package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
  209. package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
  210. package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
  211. package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
  212. package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
  213. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
  214. package/src/unstable-core-do-not-import/http/index.ts +0 -23
  215. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
  216. package/src/unstable-core-do-not-import/http/types.ts +0 -111
  217. package/src/unstable-core-do-not-import/index.ts +0 -110
  218. package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
  219. package/src/unstable-core-do-not-import/middleware.ts +0 -233
  220. package/src/unstable-core-do-not-import/parser.ts +0 -94
  221. package/src/unstable-core-do-not-import/procedure.ts +0 -108
  222. package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
  223. package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
  224. package/src/unstable-core-do-not-import/router.ts +0 -370
  225. package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
  226. package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
  227. package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
  228. package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
  229. package/src/unstable-core-do-not-import/serialize.ts +0 -122
  230. package/src/unstable-core-do-not-import/transformer.ts +0 -202
  231. package/src/unstable-core-do-not-import/types.ts +0 -151
  232. package/src/unstable-core-do-not-import/utils.ts +0 -59
  233. package/unstable-core-do-not-import/index.d.ts +0 -1
  234. package/unstable-core-do-not-import/index.js +0 -1
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- function identity(x) {
4
- return x;
5
- }
6
- /** @public */ function isObservable(x) {
7
- return typeof x === 'object' && x !== null && 'subscribe' in x;
8
- }
9
- /** @public */ function observable(subscribe) {
10
- const self = {
11
- subscribe (observer) {
12
- let teardownRef = null;
13
- let isDone = false;
14
- let unsubscribed = false;
15
- let teardownImmediately = false;
16
- function unsubscribe() {
17
- if (teardownRef === null) {
18
- teardownImmediately = true;
19
- return;
20
- }
21
- if (unsubscribed) {
22
- return;
23
- }
24
- unsubscribed = true;
25
- if (typeof teardownRef === 'function') {
26
- teardownRef();
27
- } else if (teardownRef) {
28
- teardownRef.unsubscribe();
29
- }
30
- }
31
- teardownRef = subscribe({
32
- next (value) {
33
- if (isDone) {
34
- return;
35
- }
36
- observer.next?.(value);
37
- },
38
- error (err) {
39
- if (isDone) {
40
- return;
41
- }
42
- isDone = true;
43
- observer.error?.(err);
44
- unsubscribe();
45
- },
46
- complete () {
47
- if (isDone) {
48
- return;
49
- }
50
- isDone = true;
51
- observer.complete?.();
52
- unsubscribe();
53
- }
54
- });
55
- if (teardownImmediately) {
56
- unsubscribe();
57
- }
58
- return {
59
- unsubscribe
60
- };
61
- },
62
- pipe (...operations) {
63
- return pipeFromArray(operations)(self);
64
- }
65
- };
66
- return self;
67
- }
68
- function pipeFromArray(fns) {
69
- if (fns.length === 0) {
70
- return identity;
71
- }
72
- if (fns.length === 1) {
73
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74
- return fns[0];
75
- }
76
- return function piped(input) {
77
- return fns.reduce((prev, fn)=>fn(prev), input);
78
- };
79
- }
80
- class ObservableAbortError extends Error {
81
- constructor(message){
82
- super(message);
83
- this.name = 'ObservableAbortError';
84
- Object.setPrototypeOf(this, ObservableAbortError.prototype);
85
- }
86
- }
87
- /** @internal */ function observableToPromise(observable) {
88
- let abort;
89
- const promise = new Promise((resolve, reject)=>{
90
- let isDone = false;
91
- function onDone() {
92
- if (isDone) {
93
- return;
94
- }
95
- isDone = true;
96
- reject(new ObservableAbortError('This operation was aborted.'));
97
- obs$.unsubscribe();
98
- }
99
- const obs$ = observable.subscribe({
100
- next (data) {
101
- isDone = true;
102
- resolve(data);
103
- onDone();
104
- },
105
- error (data) {
106
- isDone = true;
107
- reject(data);
108
- onDone();
109
- },
110
- complete () {
111
- isDone = true;
112
- onDone();
113
- }
114
- });
115
- abort = onDone;
116
- });
117
- return {
118
- promise,
119
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
120
- abort: abort
121
- };
122
- }
123
-
124
- exports.isObservable = isObservable;
125
- exports.observable = observable;
126
- exports.observableToPromise = observableToPromise;
@@ -1,122 +0,0 @@
1
- function identity(x) {
2
- return x;
3
- }
4
- /** @public */ function isObservable(x) {
5
- return typeof x === 'object' && x !== null && 'subscribe' in x;
6
- }
7
- /** @public */ function observable(subscribe) {
8
- const self = {
9
- subscribe (observer) {
10
- let teardownRef = null;
11
- let isDone = false;
12
- let unsubscribed = false;
13
- let teardownImmediately = false;
14
- function unsubscribe() {
15
- if (teardownRef === null) {
16
- teardownImmediately = true;
17
- return;
18
- }
19
- if (unsubscribed) {
20
- return;
21
- }
22
- unsubscribed = true;
23
- if (typeof teardownRef === 'function') {
24
- teardownRef();
25
- } else if (teardownRef) {
26
- teardownRef.unsubscribe();
27
- }
28
- }
29
- teardownRef = subscribe({
30
- next (value) {
31
- if (isDone) {
32
- return;
33
- }
34
- observer.next?.(value);
35
- },
36
- error (err) {
37
- if (isDone) {
38
- return;
39
- }
40
- isDone = true;
41
- observer.error?.(err);
42
- unsubscribe();
43
- },
44
- complete () {
45
- if (isDone) {
46
- return;
47
- }
48
- isDone = true;
49
- observer.complete?.();
50
- unsubscribe();
51
- }
52
- });
53
- if (teardownImmediately) {
54
- unsubscribe();
55
- }
56
- return {
57
- unsubscribe
58
- };
59
- },
60
- pipe (...operations) {
61
- return pipeFromArray(operations)(self);
62
- }
63
- };
64
- return self;
65
- }
66
- function pipeFromArray(fns) {
67
- if (fns.length === 0) {
68
- return identity;
69
- }
70
- if (fns.length === 1) {
71
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
72
- return fns[0];
73
- }
74
- return function piped(input) {
75
- return fns.reduce((prev, fn)=>fn(prev), input);
76
- };
77
- }
78
- class ObservableAbortError extends Error {
79
- constructor(message){
80
- super(message);
81
- this.name = 'ObservableAbortError';
82
- Object.setPrototypeOf(this, ObservableAbortError.prototype);
83
- }
84
- }
85
- /** @internal */ function observableToPromise(observable) {
86
- let abort;
87
- const promise = new Promise((resolve, reject)=>{
88
- let isDone = false;
89
- function onDone() {
90
- if (isDone) {
91
- return;
92
- }
93
- isDone = true;
94
- reject(new ObservableAbortError('This operation was aborted.'));
95
- obs$.unsubscribe();
96
- }
97
- const obs$ = observable.subscribe({
98
- next (data) {
99
- isDone = true;
100
- resolve(data);
101
- onDone();
102
- },
103
- error (data) {
104
- isDone = true;
105
- reject(data);
106
- onDone();
107
- },
108
- complete () {
109
- isDone = true;
110
- onDone();
111
- }
112
- });
113
- abort = onDone;
114
- });
115
- return {
116
- promise,
117
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
118
- abort: abort
119
- };
120
- }
121
-
122
- export { observableToPromise as a, isObservable as i, observable as o };
@@ -1,126 +0,0 @@
1
- function identity(x) {
2
- return x;
3
- }
4
- /** @public */
5
- function isObservable(x) {
6
- return typeof x === 'object' && x !== null && 'subscribe' in x;
7
- }
8
- /** @public */
9
- function observable(subscribe) {
10
- const self = {
11
- subscribe(observer) {
12
- let teardownRef = null;
13
- let isDone = false;
14
- let unsubscribed = false;
15
- let teardownImmediately = false;
16
- function unsubscribe() {
17
- if (teardownRef === null) {
18
- teardownImmediately = true;
19
- return;
20
- }
21
- if (unsubscribed) {
22
- return;
23
- }
24
- unsubscribed = true;
25
- if (typeof teardownRef === 'function') {
26
- teardownRef();
27
- }
28
- else if (teardownRef) {
29
- teardownRef.unsubscribe();
30
- }
31
- }
32
- teardownRef = subscribe({
33
- next(value) {
34
- if (isDone) {
35
- return;
36
- }
37
- observer.next?.(value);
38
- },
39
- error(err) {
40
- if (isDone) {
41
- return;
42
- }
43
- isDone = true;
44
- observer.error?.(err);
45
- unsubscribe();
46
- },
47
- complete() {
48
- if (isDone) {
49
- return;
50
- }
51
- isDone = true;
52
- observer.complete?.();
53
- unsubscribe();
54
- },
55
- });
56
- if (teardownImmediately) {
57
- unsubscribe();
58
- }
59
- return {
60
- unsubscribe,
61
- };
62
- },
63
- pipe(...operations) {
64
- return pipeFromArray(operations)(self);
65
- },
66
- };
67
- return self;
68
- }
69
- function pipeFromArray(fns) {
70
- if (fns.length === 0) {
71
- return identity;
72
- }
73
- if (fns.length === 1) {
74
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
75
- return fns[0];
76
- }
77
- return function piped(input) {
78
- return fns.reduce((prev, fn) => fn(prev), input);
79
- };
80
- }
81
- class ObservableAbortError extends Error {
82
- constructor(message) {
83
- super(message);
84
- this.name = 'ObservableAbortError';
85
- Object.setPrototypeOf(this, ObservableAbortError.prototype);
86
- }
87
- }
88
- /** @internal */
89
- function observableToPromise(observable) {
90
- let abort;
91
- const promise = new Promise((resolve, reject) => {
92
- let isDone = false;
93
- function onDone() {
94
- if (isDone) {
95
- return;
96
- }
97
- isDone = true;
98
- reject(new ObservableAbortError('This operation was aborted.'));
99
- obs$.unsubscribe();
100
- }
101
- const obs$ = observable.subscribe({
102
- next(data) {
103
- isDone = true;
104
- resolve(data);
105
- onDone();
106
- },
107
- error(data) {
108
- isDone = true;
109
- reject(data);
110
- onDone();
111
- },
112
- complete() {
113
- isDone = true;
114
- onDone();
115
- },
116
- });
117
- abort = onDone;
118
- });
119
- return {
120
- promise,
121
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
122
- abort: abort,
123
- };
124
- }
125
-
126
- export { observableToPromise as a, isObservable as i, observable as o };
@@ -1,67 +0,0 @@
1
- import { i as isObject } from './rootConfig-52aed7d7.js';
2
-
3
- const procedureTypes = ['query', 'mutation', 'subscription'];
4
-
5
- /* istanbul ignore next -- @preserve */
6
- function assertIsObject(obj) {
7
- if (!isObject(obj)) {
8
- throw new Error('Not an object');
9
- }
10
- }
11
- /* istanbul ignore next -- @preserve */
12
- function assertIsProcedureType(obj) {
13
- if (!procedureTypes.includes(obj)) {
14
- throw new Error('Invalid procedure type');
15
- }
16
- }
17
- /* istanbul ignore next -- @preserve */
18
- function assertIsRequestId(obj) {
19
- if (obj !== null &&
20
- typeof obj === 'number' &&
21
- isNaN(obj) &&
22
- typeof obj !== 'string') {
23
- throw new Error('Invalid request id');
24
- }
25
- }
26
- /* istanbul ignore next -- @preserve */
27
- function assertIsString(obj) {
28
- if (typeof obj !== 'string') {
29
- throw new Error('Invalid string');
30
- }
31
- }
32
- /* istanbul ignore next -- @preserve */
33
- function assertIsJSONRPC2OrUndefined(obj) {
34
- if (typeof obj !== 'undefined' && obj !== '2.0') {
35
- throw new Error('Must be JSONRPC 2.0');
36
- }
37
- }
38
- /** @public */
39
- function parseTRPCMessage(obj, transformer) {
40
- assertIsObject(obj);
41
- const { id, jsonrpc, method, params } = obj;
42
- assertIsRequestId(id);
43
- assertIsJSONRPC2OrUndefined(jsonrpc);
44
- if (method === 'subscription.stop') {
45
- return {
46
- id,
47
- jsonrpc,
48
- method,
49
- };
50
- }
51
- assertIsProcedureType(method);
52
- assertIsObject(params);
53
- const { input: rawInput, path } = params;
54
- assertIsString(path);
55
- const input = transformer.input.deserialize(rawInput);
56
- return {
57
- id,
58
- jsonrpc,
59
- method,
60
- params: {
61
- input,
62
- path,
63
- },
64
- };
65
- }
66
-
67
- export { procedureTypes as a, parseTRPCMessage as p };
@@ -1,62 +0,0 @@
1
- import { i as isObject } from './rootConfig-7d3e1fc8.mjs';
2
-
3
- const procedureTypes = [
4
- 'query',
5
- 'mutation',
6
- 'subscription'
7
- ];
8
-
9
- /* istanbul ignore next -- @preserve */ function assertIsObject(obj) {
10
- if (!isObject(obj)) {
11
- throw new Error('Not an object');
12
- }
13
- }
14
- /* istanbul ignore next -- @preserve */ function assertIsProcedureType(obj) {
15
- if (!procedureTypes.includes(obj)) {
16
- throw new Error('Invalid procedure type');
17
- }
18
- }
19
- /* istanbul ignore next -- @preserve */ function assertIsRequestId(obj) {
20
- if (obj !== null && typeof obj === 'number' && isNaN(obj) && typeof obj !== 'string') {
21
- throw new Error('Invalid request id');
22
- }
23
- }
24
- /* istanbul ignore next -- @preserve */ function assertIsString(obj) {
25
- if (typeof obj !== 'string') {
26
- throw new Error('Invalid string');
27
- }
28
- }
29
- /* istanbul ignore next -- @preserve */ function assertIsJSONRPC2OrUndefined(obj) {
30
- if (typeof obj !== 'undefined' && obj !== '2.0') {
31
- throw new Error('Must be JSONRPC 2.0');
32
- }
33
- }
34
- /** @public */ function parseTRPCMessage(obj, transformer) {
35
- assertIsObject(obj);
36
- const { id , jsonrpc , method , params } = obj;
37
- assertIsRequestId(id);
38
- assertIsJSONRPC2OrUndefined(jsonrpc);
39
- if (method === 'subscription.stop') {
40
- return {
41
- id,
42
- jsonrpc,
43
- method
44
- };
45
- }
46
- assertIsProcedureType(method);
47
- assertIsObject(params);
48
- const { input: rawInput , path } = params;
49
- assertIsString(path);
50
- const input = transformer.input.deserialize(rawInput);
51
- return {
52
- id,
53
- jsonrpc,
54
- method,
55
- params: {
56
- input,
57
- path
58
- }
59
- };
60
- }
61
-
62
- export { procedureTypes as a, parseTRPCMessage as p };
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- var rootConfig = require('./rootConfig-ccd626d6.js');
4
-
5
- const procedureTypes = [
6
- 'query',
7
- 'mutation',
8
- 'subscription'
9
- ];
10
-
11
- /* istanbul ignore next -- @preserve */ function assertIsObject(obj) {
12
- if (!rootConfig.isObject(obj)) {
13
- throw new Error('Not an object');
14
- }
15
- }
16
- /* istanbul ignore next -- @preserve */ function assertIsProcedureType(obj) {
17
- if (!procedureTypes.includes(obj)) {
18
- throw new Error('Invalid procedure type');
19
- }
20
- }
21
- /* istanbul ignore next -- @preserve */ function assertIsRequestId(obj) {
22
- if (obj !== null && typeof obj === 'number' && isNaN(obj) && typeof obj !== 'string') {
23
- throw new Error('Invalid request id');
24
- }
25
- }
26
- /* istanbul ignore next -- @preserve */ function assertIsString(obj) {
27
- if (typeof obj !== 'string') {
28
- throw new Error('Invalid string');
29
- }
30
- }
31
- /* istanbul ignore next -- @preserve */ function assertIsJSONRPC2OrUndefined(obj) {
32
- if (typeof obj !== 'undefined' && obj !== '2.0') {
33
- throw new Error('Must be JSONRPC 2.0');
34
- }
35
- }
36
- /** @public */ function parseTRPCMessage(obj, transformer) {
37
- assertIsObject(obj);
38
- const { id , jsonrpc , method , params } = obj;
39
- assertIsRequestId(id);
40
- assertIsJSONRPC2OrUndefined(jsonrpc);
41
- if (method === 'subscription.stop') {
42
- return {
43
- id,
44
- jsonrpc,
45
- method
46
- };
47
- }
48
- assertIsProcedureType(method);
49
- assertIsObject(params);
50
- const { input: rawInput , path } = params;
51
- assertIsString(path);
52
- const input = transformer.input.deserialize(rawInput);
53
- return {
54
- id,
55
- jsonrpc,
56
- method,
57
- params: {
58
- input,
59
- path
60
- }
61
- };
62
- }
63
-
64
- exports.parseTRPCMessage = parseTRPCMessage;
65
- exports.procedureTypes = procedureTypes;