brass-runtime 1.17.0 → 1.18.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 (120) hide show
  1. package/README.md +36 -3
  2. package/dist/agent/cli/main.cjs +31 -32
  3. package/dist/agent/cli/main.js +3 -4
  4. package/dist/agent/cli/main.mjs +3 -4
  5. package/dist/agent/index.cjs +4 -5
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +3 -4
  8. package/dist/agent/index.mjs +3 -4
  9. package/dist/{chunk-7X3K5RMS.js → chunk-22HZQG5F.js} +9 -11
  10. package/dist/{chunk-GLE2WY7Z.cjs → chunk-2JHJ4YHS.cjs} +417 -124
  11. package/dist/{chunk-Q2I37RP3.cjs → chunk-2OW6IFY2.cjs} +44 -323
  12. package/dist/{chunk-7ZPEZ57L.cjs → chunk-5LC7V2OZ.cjs} +18 -20
  13. package/dist/{chunk-AGR5B2BC.cjs → chunk-5RZ7YITF.cjs} +564 -12
  14. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  15. package/dist/{chunk-EJ6BPYVR.mjs → chunk-6V2AWT4R.mjs} +1 -1
  16. package/dist/{chunk-3AYM6WPJ.js → chunk-7DU7IQHK.js} +20 -299
  17. package/dist/{chunk-SK7UZRNI.mjs → chunk-7GBJYOX7.mjs} +528 -23
  18. package/dist/chunk-7TKI527D.cjs +123 -0
  19. package/dist/{chunk-52OB2ROS.js → chunk-7VQLEN37.js} +2 -4
  20. package/dist/{chunk-KH4SYAOS.mjs → chunk-B5FKOLTB.mjs} +20 -299
  21. package/dist/{chunk-FHQGHPMO.mjs → chunk-BC6Q6BCO.mjs} +2 -4
  22. package/dist/{chunk-4P2HHGAX.mjs → chunk-COOW7BJX.mjs} +32 -11
  23. package/dist/{chunk-2HQTDLHF.mjs → chunk-EEN5OTCR.mjs} +555 -3
  24. package/dist/{chunk-KZJQ723N.cjs → chunk-EICAJDNX.cjs} +13 -15
  25. package/dist/chunk-ELIECDYN.cjs +33 -0
  26. package/dist/{chunk-GYM3LLGS.mjs → chunk-H626ZTDZ.mjs} +399 -106
  27. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  28. package/dist/{chunk-7JIJOVCT.js → chunk-IPSMXUWA.js} +2 -4
  29. package/dist/{chunk-4ROBZFL6.cjs → chunk-J6DUHITE.cjs} +6 -8
  30. package/dist/{chunk-6RY2FFN4.mjs → chunk-JWIEMBE6.mjs} +9 -11
  31. package/dist/{chunk-PD4EJTQC.cjs → chunk-KNTJ7FQB.cjs} +5 -5
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/chunk-LSYQ3C2M.js +33 -0
  34. package/dist/{chunk-RKGKFN2A.js → chunk-OW5VHAOE.js} +1 -1
  35. package/dist/{chunk-EOC4UHBS.mjs → chunk-RBHNOKH4.mjs} +2 -2
  36. package/dist/{chunk-6IXXWIUM.js → chunk-S4HXADU4.js} +555 -3
  37. package/dist/{chunk-FH2X7BVP.js → chunk-TTSPIU3U.js} +399 -106
  38. package/dist/{chunk-5QC7LRZ3.js → chunk-UAKAF32U.js} +2 -2
  39. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-WCBNXPN6.mjs} +2 -4
  41. package/dist/{chunk-52PPNNI4.cjs → chunk-WGE2FEZE.cjs} +2 -2
  42. package/dist/{chunk-WBGRHGBP.cjs → chunk-WI7GZF3B.cjs} +114 -93
  43. package/dist/chunk-WUDHOZIH.js +6234 -0
  44. package/dist/{chunk-F6XWZQY4.cjs → chunk-WVSZOPGQ.cjs} +583 -78
  45. package/dist/chunk-XPIMJQYS.cjs +6234 -0
  46. package/dist/{chunk-VWIPB6I5.js → chunk-YGR2IN4R.js} +528 -23
  47. package/dist/chunk-YM3EDNYD.js +123 -0
  48. package/dist/chunk-YWLLH27R.mjs +33 -0
  49. package/dist/{chunk-BKK77SBA.js → chunk-YZ5LQ32F.js} +32 -11
  50. package/dist/chunk-Z3ZZMQUZ.mjs +6234 -0
  51. package/dist/core/index.cjs +37 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +86 -58
  54. package/dist/core/index.mjs +86 -58
  55. package/dist/defaultClient-Cid0JoUR.d.ts +1648 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-DnGUuhw6.d.ts} +22 -1
  57. package/dist/http/index.cjs +206 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +220 -73
  60. package/dist/http/index.mjs +220 -73
  61. package/dist/http/testing.cjs +31 -10
  62. package/dist/http/testing.d.ts +16 -5
  63. package/dist/http/testing.js +29 -8
  64. package/dist/http/testing.mjs +29 -8
  65. package/dist/index.cjs +116 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +87 -59
  68. package/dist/index.mjs +87 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-D2LFcBVx.d.ts} +176 -2
  70. package/dist/observability/index.cjs +20 -7
  71. package/dist/observability/index.d.ts +32 -8
  72. package/dist/observability/index.js +19 -6
  73. package/dist/observability/index.mjs +19 -6
  74. package/dist/perf/cli.cjs +26 -28
  75. package/dist/perf/cli.js +11 -13
  76. package/dist/perf/cli.mjs +11 -13
  77. package/dist/perf/index.cjs +13 -15
  78. package/dist/perf/index.js +11 -13
  79. package/dist/perf/index.mjs +11 -13
  80. package/dist/schema/index.cjs +2 -2
  81. package/dist/schema/index.js +1 -1
  82. package/dist/schema/index.mjs +1 -1
  83. package/dist/{server-D6JZ15_e.d.ts → server-Bf1zNYZk.d.ts} +5 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-I7bkvF7a.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DF83nLn6.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-CWV4gT0u.d.ts} +1 -1
  87. package/docs/README.md +2 -0
  88. package/docs/ai/PUBLIC_API.md +28 -7
  89. package/docs/articles/brass-runtime-http-observability.md +467 -0
  90. package/docs/frameworks/angular.md +51 -0
  91. package/docs/frameworks/express.md +58 -0
  92. package/docs/frameworks/fastify.md +49 -0
  93. package/docs/frameworks/nestjs.md +53 -0
  94. package/docs/frameworks/nextjs.md +55 -0
  95. package/docs/frameworks/react.md +44 -0
  96. package/docs/frameworks/vanilla.md +56 -0
  97. package/docs/guides/layers.md +130 -0
  98. package/docs/http-recipes.md +31 -1
  99. package/docs/http.md +50 -1
  100. package/docs/observability.md +132 -0
  101. package/docs/performance-profiler.md +6 -2
  102. package/docs/recipes/layers.md +46 -2
  103. package/docs/recipes/testing.md +25 -0
  104. package/package.json +6 -2
  105. package/dist/chunk-3LOYJFRR.cjs +0 -300
  106. package/dist/chunk-3Y2RIUMM.js +0 -300
  107. package/dist/chunk-5EC274J5.cjs +0 -2874
  108. package/dist/chunk-5VRJNBLZ.mjs +0 -2874
  109. package/dist/chunk-62AZW6UT.cjs +0 -313
  110. package/dist/chunk-74ZTY6CP.js +0 -2871
  111. package/dist/chunk-7CMJS3QE.mjs +0 -2871
  112. package/dist/chunk-A2OM6NEH.mjs +0 -194
  113. package/dist/chunk-B33ICAKP.js +0 -313
  114. package/dist/chunk-JF5WGYJJ.cjs +0 -194
  115. package/dist/chunk-KN32XNTH.mjs +0 -313
  116. package/dist/chunk-KQLYONSE.cjs +0 -2871
  117. package/dist/chunk-L2SYFEBS.js +0 -194
  118. package/dist/chunk-MIIYDLGM.js +0 -2874
  119. package/dist/chunk-PWC3RBQE.mjs +0 -300
  120. package/dist/client-CZHU674n.d.ts +0 -820
@@ -1,126 +1,127 @@
1
1
  import {
2
- makeCircuitBreaker,
3
- resource
4
- } from "../chunk-KN32XNTH.mjs";
2
+ makeCircuitBreaker
3
+ } from "../chunk-KTGDLBLD.mjs";
5
4
  import {
5
+ healthToHttpResponse,
6
+ makeRuntimeHealth,
7
+ runObservedHttpServerEffect
8
+ } from "../chunk-COOW7BJX.mjs";
9
+ import "../chunk-6V2AWT4R.mjs";
10
+ import {
11
+ AdaptiveLimiter,
6
12
  DEFAULT_CACHE_RELEVANT_HEADERS,
13
+ EmaComputer,
14
+ HttpClientService,
15
+ HttpConcurrencyPool,
7
16
  LRUCache,
17
+ LatencyWindow,
8
18
  LifecycleStatsTracker,
9
19
  PriorityQueue,
20
+ Request,
10
21
  SEPARATOR,
11
22
  SUPPORTED_ENCODINGS,
12
- buildHttpRequest,
13
- clampPriority,
14
- computeCacheKey,
15
- decodeJsonBody,
16
- decodeJsonBodyEffect,
17
- defaultHttpClientPreset,
18
- detectPlatform,
19
- encodeJsonBodyEffect,
20
- executeProbe,
21
- makeBudgetSemaphore,
22
- makeCompressionMiddleware,
23
- makeConnectionStateMap,
24
- makeDefaultHttpClient,
25
- makeHttpClient,
26
- makeLifecycleClient,
27
- makePrewarmManager,
28
- makeRequestCompressionMiddleware,
29
- makeResponseCompressionMiddleware,
30
- now,
31
- parseCacheKey,
32
- validateFetchAvailable,
33
- validateOrigin,
34
- validatedJson,
35
- validatedJsonResponse,
36
- withBatch,
37
- withCache,
38
- withDedup,
39
- withPriority
40
- } from "../chunk-7CMJS3QE.mjs";
41
- import {
42
- AdaptiveLimiter,
43
- EmaComputer,
44
- HttpConcurrencyPool,
45
- LatencyWindow,
46
23
  abortErrorForSignal,
47
24
  adaptiveLimiterPresets,
48
25
  backoffDelayMs,
26
+ buildHttpRequest,
27
+ clampPriority,
28
+ computeCacheKey,
49
29
  computeGradient,
50
30
  computeNewLimit,
31
+ decodeJsonBody,
32
+ decodeJsonBodyEffect,
51
33
  decorate,
34
+ defaultHttpClientPreset,
52
35
  defaultRetryOnError,
53
36
  defaultRetryOnStatus,
54
37
  defaultRetryableMethods,
38
+ defineHttpPolicyPresets,
39
+ detectPlatform,
40
+ encodeJsonBodyEffect,
41
+ executeProbe,
42
+ formatHttpError,
43
+ getHttpRequestPolicy,
55
44
  headersOf,
45
+ httpErrorStatus,
46
+ httpPolicy,
56
47
  isAbortError,
48
+ isAbortHttpError,
49
+ isCircuitBreakerOpen,
50
+ isExternalAbortError,
51
+ isExternalTimeoutError,
52
+ isFetchHttpError,
53
+ isHttpError,
54
+ isKnownHttpError,
55
+ isPromiseTransportDirect,
56
+ isRetryableHttpError,
57
+ isRetryableHttpStatus,
57
58
  isTaggedHttpError,
59
+ isTimeoutHttpError,
60
+ isValidationError,
58
61
  linkAbortSignals,
59
62
  makeAdaptiveLimiterConfig,
63
+ makeBudgetSemaphore,
64
+ makeCompressionMiddleware,
65
+ makeConnectionStateMap,
66
+ makeDefaultHttpClient,
67
+ makeDefaultHttpClientLayer,
60
68
  makeFetchStreamTransport,
61
69
  makeFetchTransport,
62
70
  makeHttp,
71
+ makeHttpClient,
63
72
  makeHttpStream,
73
+ makeJsonParseValidationError,
74
+ makeLifecycleClient,
75
+ makePrewarmManager,
64
76
  makePromiseHttpTransport,
77
+ makeRequestCompressionMiddleware,
78
+ makeResponseCompressionMiddleware,
79
+ matchHttpError,
80
+ noopSignal,
65
81
  normalizeHeadersInit,
66
82
  normalizeHttpError,
67
83
  normalizeHttpHeaders,
68
84
  normalizeRetryBudget,
85
+ now,
86
+ parseCacheKey,
69
87
  promiseHttpTransport,
70
88
  resolveConfig,
71
89
  resolveHttpPoolKey,
90
+ resolveHttpRequestPolicyPresets,
72
91
  retryAfterMs,
73
92
  setHeaderIfMissing,
93
+ toHttpError,
74
94
  validateConfig,
95
+ validateFetchAvailable,
96
+ validateOrigin,
97
+ validatedJson,
98
+ validatedJsonResponse,
99
+ withBatch,
100
+ withCache,
101
+ withDedup,
102
+ withHttpPolicyPresets,
103
+ withHttpRequestPolicy,
75
104
  withMiddleware,
105
+ withPriority,
76
106
  withRetry,
77
107
  withRetryStream
78
- } from "../chunk-5VRJNBLZ.mjs";
108
+ } from "../chunk-Z3ZZMQUZ.mjs";
79
109
  import {
80
110
  registerHttpEffect
81
111
  } from "../chunk-MOO4L7F4.mjs";
82
- import "../chunk-FHQGHPMO.mjs";
112
+ import "../chunk-BC6Q6BCO.mjs";
83
113
  import "../chunk-B5JD23U7.mjs";
84
114
  import {
85
115
  fixed,
86
116
  makeScheduleDriver,
117
+ resource,
87
118
  take
88
- } from "../chunk-2HQTDLHF.mjs";
89
- import "../chunk-A2OM6NEH.mjs";
90
- import {
91
- healthToHttpResponse,
92
- makeRuntimeHealth,
93
- runObservedHttpServerEffect
94
- } from "../chunk-4P2HHGAX.mjs";
95
- import "../chunk-EJ6BPYVR.mjs";
96
- import {
97
- defineHttpPolicyPresets,
98
- formatHttpError,
99
- getHttpRequestPolicy,
100
- httpErrorStatus,
101
- httpPolicy,
102
- isAbortHttpError,
103
- isCircuitBreakerOpen,
104
- isExternalAbortError,
105
- isExternalTimeoutError,
106
- isFetchHttpError,
107
- isHttpError,
108
- isKnownHttpError,
109
- isRetryableHttpError,
110
- isRetryableHttpStatus,
111
- isTimeoutHttpError,
112
- isValidationError,
113
- matchHttpError,
114
- resolveHttpRequestPolicyPresets,
115
- toHttpError,
116
- withHttpPolicyPresets,
117
- withHttpRequestPolicy
118
- } from "../chunk-PWC3RBQE.mjs";
119
+ } from "../chunk-EEN5OTCR.mjs";
119
120
  import {
120
121
  Runtime,
121
122
  fromPromiseAbortable,
122
123
  toPromise
123
- } from "../chunk-GYM3LLGS.mjs";
124
+ } from "../chunk-H626ZTDZ.mjs";
124
125
  import {
125
126
  Cause,
126
127
  asyncEffect,
@@ -144,9 +145,142 @@ import {
144
145
  s,
145
146
  schema,
146
147
  validateValue
147
- } from "../chunk-DNFJLJMW.mjs";
148
+ } from "../chunk-6MLAZPBL.mjs";
148
149
  import "../chunk-Y6FXYEAI.mjs";
149
150
 
151
+ // src/http/nodeTransport.ts
152
+ import {
153
+ Agent as HttpAgent,
154
+ request as httpRequest
155
+ } from "http";
156
+ import {
157
+ Agent as HttpsAgent,
158
+ request as httpsRequest
159
+ } from "https";
160
+ var nowMs = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
161
+ var toAgentOptions = (config) => ({
162
+ keepAlive: config.keepAlive ?? true,
163
+ ...config.maxSockets !== void 0 ? { maxSockets: config.maxSockets } : {},
164
+ ...config.maxFreeSockets !== void 0 ? { maxFreeSockets: config.maxFreeSockets } : {}
165
+ });
166
+ var isError = (value) => value instanceof Error;
167
+ function unsupportedProtocol(url) {
168
+ return {
169
+ _tag: "BadUrl",
170
+ message: `Unsupported URL protocol for node HTTP transport: ${url.protocol}`
171
+ };
172
+ }
173
+ function runNodeRequest(context, config, httpAgent, httpsAgent) {
174
+ return asyncEffect((_env, cb) => {
175
+ const { request, url, signal } = context;
176
+ const isHttps = url.protocol === "https:";
177
+ const isHttp = url.protocol === "http:";
178
+ if (!isHttp && !isHttps) {
179
+ cb({ _tag: "Failure", cause: Cause.fail(unsupportedProtocol(url)) });
180
+ return;
181
+ }
182
+ if (signal.aborted) {
183
+ cb({ _tag: "Failure", cause: Cause.fail(abortErrorForSignal(signal)) });
184
+ return;
185
+ }
186
+ const started = nowMs();
187
+ const chunks = [];
188
+ let byteLength = 0;
189
+ let done = false;
190
+ let abort = () => void 0;
191
+ const finish = (exit) => {
192
+ if (done) return;
193
+ done = true;
194
+ signal.removeEventListener("abort", abort);
195
+ cb(exit);
196
+ };
197
+ const fail = (error) => {
198
+ finish({
199
+ _tag: "Failure",
200
+ cause: Cause.fail(normalizeHttpError(error, { signal }))
201
+ });
202
+ };
203
+ const options = {
204
+ method: request.method,
205
+ headers: Request.headers.get(request),
206
+ agent: isHttps ? httpsAgent : httpAgent,
207
+ signal
208
+ };
209
+ const nodeRequest = (isHttps ? httpsRequest : httpRequest)(url, options, (response) => {
210
+ response.on("data", (chunk) => {
211
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
212
+ chunks.push(buffer);
213
+ byteLength += buffer.length;
214
+ });
215
+ response.on("end", () => {
216
+ finish({
217
+ _tag: "Success",
218
+ value: {
219
+ status: response.statusCode ?? 0,
220
+ statusText: response.statusMessage ?? "",
221
+ headers: normalizeHttpHeaders(response.headers),
222
+ bodyText: Buffer.concat(chunks, byteLength).toString("utf8"),
223
+ ms: Math.round(nowMs() - started)
224
+ }
225
+ });
226
+ });
227
+ response.on("error", fail);
228
+ });
229
+ abort = () => {
230
+ nodeRequest.destroy(isError(signal.reason) ? signal.reason : void 0);
231
+ finish({ _tag: "Failure", cause: Cause.fail(abortErrorForSignal(signal)) });
232
+ };
233
+ signal.addEventListener("abort", abort, { once: true });
234
+ nodeRequest.on("error", fail);
235
+ if (config.socketTimeoutMs !== void 0 && config.socketTimeoutMs > 0) {
236
+ nodeRequest.setTimeout(config.socketTimeoutMs, () => {
237
+ nodeRequest.destroy(Object.assign(new Error("Node HTTP socket timed out"), {
238
+ code: "ETIMEDOUT"
239
+ }));
240
+ });
241
+ }
242
+ if (request.body !== void 0) {
243
+ nodeRequest.write(request.body);
244
+ }
245
+ nodeRequest.end();
246
+ return () => {
247
+ if (done) return;
248
+ nodeRequest.destroy(Object.assign(new Error("Node HTTP transport aborted"), {
249
+ name: "AbortError",
250
+ code: "ABORT_ERR"
251
+ }));
252
+ finish({ _tag: "Failure", cause: Cause.fail({ _tag: "Abort" }) });
253
+ };
254
+ });
255
+ }
256
+ function makeNodeHttpTransport(config = {}) {
257
+ const agentOptions = toAgentOptions(config);
258
+ const httpAgent = config.httpAgent ?? new HttpAgent(agentOptions);
259
+ const httpsAgent = config.httpsAgent ?? new HttpsAgent(agentOptions);
260
+ const ownsHttpAgent = config.httpAgent === void 0;
261
+ const ownsHttpsAgent = config.httpsAgent === void 0;
262
+ const transport = (context) => runNodeRequest(context, config, httpAgent, httpsAgent);
263
+ return Object.assign(transport, {
264
+ destroy: () => {
265
+ if (ownsHttpAgent) httpAgent.destroy();
266
+ if (ownsHttpsAgent) httpsAgent.destroy();
267
+ }
268
+ });
269
+ }
270
+ function makeNodeHttpProxyClient(config = {}) {
271
+ const {
272
+ preset = "highThroughputProxy",
273
+ transport,
274
+ nodeTransport,
275
+ ...clientConfig
276
+ } = config;
277
+ return makeDefaultHttpClient({
278
+ ...clientConfig,
279
+ preset,
280
+ transport: transport ?? makeNodeHttpTransport(nodeTransport)
281
+ });
282
+ }
283
+
150
284
  // src/http/httpClient.ts
151
285
  var resolveFinalUrl = (baseUrl, url) => {
152
286
  try {
@@ -941,6 +1075,7 @@ function makeBuilder(config) {
941
1075
  transport: (transport) => replace({ transport }),
942
1076
  preset: (preset) => replace({ preset }),
943
1077
  minimal: () => replace({ preset: "minimal" }),
1078
+ proxy: () => replace({ preset: "proxy" }),
944
1079
  balanced: () => replace({ preset: "balanced" }),
945
1080
  defaultPreset: () => replace({ preset: "default" }),
946
1081
  production: () => replace({ preset: "production" }),
@@ -1504,7 +1639,12 @@ function normalizeRouteMethod(method) {
1504
1639
  function normalizeRoutePath(path) {
1505
1640
  if (!path || path === "*") return "/";
1506
1641
  const withSlash = path.startsWith("/") ? path : `/${path}`;
1507
- return withSlash.length > 1 ? withSlash.replace(/\/+$/, "") : withSlash;
1642
+ if (withSlash.length <= 1) return withSlash;
1643
+ let end = withSlash.length;
1644
+ while (end > 0 && withSlash.charCodeAt(end - 1) === 47) {
1645
+ end -= 1;
1646
+ }
1647
+ return withSlash.slice(0, end);
1508
1648
  }
1509
1649
  function parseRequestUrl(target, host) {
1510
1650
  try {
@@ -1569,6 +1709,7 @@ export {
1569
1709
  ConfigValidationError,
1570
1710
  DEFAULT_CACHE_RELEVANT_HEADERS,
1571
1711
  EmaComputer,
1712
+ HttpClientService,
1572
1713
  HttpConcurrencyPool,
1573
1714
  HttpServer,
1574
1715
  LRUCache,
@@ -1620,6 +1761,7 @@ export {
1620
1761
  isFetchHttpError,
1621
1762
  isHttpError,
1622
1763
  isKnownHttpError,
1764
+ isPromiseTransportDirect,
1623
1765
  isRetryableHttpError,
1624
1766
  isRetryableHttpStatus,
1625
1767
  isSchema,
@@ -1633,6 +1775,7 @@ export {
1633
1775
  makeCompressionMiddleware,
1634
1776
  makeConnectionStateMap,
1635
1777
  makeDefaultHttpClient,
1778
+ makeDefaultHttpClientLayer,
1636
1779
  makeFetchStreamTransport,
1637
1780
  makeFetchTransport,
1638
1781
  makeHttp,
@@ -1641,9 +1784,12 @@ export {
1641
1784
  makeHttpRouter,
1642
1785
  makeHttpServerResource,
1643
1786
  makeHttpStream,
1787
+ makeJsonParseValidationError,
1644
1788
  makeLifecycleClient,
1789
+ makeNodeHttpProxyClient,
1645
1790
  makeNodeHttpServer,
1646
1791
  makeNodeHttpServerResource,
1792
+ makeNodeHttpTransport,
1647
1793
  makePrewarmManager,
1648
1794
  makePromiseHttpTransport,
1649
1795
  makeRequestCompressionMiddleware,
@@ -1653,6 +1799,7 @@ export {
1653
1799
  makeSchemaIssue,
1654
1800
  matchHttpError,
1655
1801
  nodeHttpServerResource,
1802
+ noopSignal,
1656
1803
  normalizeHeadersInit,
1657
1804
  normalizeHttpError,
1658
1805
  normalizeHttpHeaders,
@@ -1,20 +1,22 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunk5EC274J5cjs = require('../chunk-5EC274J5.cjs');
3
+
4
+
5
+ var _chunkXPIMJQYScjs = require('../chunk-XPIMJQYS.cjs');
4
6
  require('../chunk-L6VB5N7Q.cjs');
5
- require('../chunk-KZJQ723N.cjs');
7
+ require('../chunk-EICAJDNX.cjs');
6
8
  require('../chunk-SA6HUJVI.cjs');
7
- require('../chunk-AGR5B2BC.cjs');
8
- require('../chunk-JF5WGYJJ.cjs');
9
- require('../chunk-3LOYJFRR.cjs');
10
9
 
11
10
 
12
- var _chunkGLE2WY7Zcjs = require('../chunk-GLE2WY7Z.cjs');
11
+ var _chunk5RZ7YITFcjs = require('../chunk-5RZ7YITF.cjs');
12
+
13
+
14
+ var _chunk2JHJ4YHScjs = require('../chunk-2JHJ4YHS.cjs');
13
15
 
14
16
 
15
17
 
16
18
  var _chunkMVGUEJ5Zcjs = require('../chunk-MVGUEJ5Z.cjs');
17
- require('../chunk-CZIVE6NT.cjs');
19
+ require('../chunk-UUMKZJRJ.cjs');
18
20
  require('../chunk-OBGZSXTJ.cjs');
19
21
 
20
22
  // src/http/testing.ts
@@ -64,7 +66,7 @@ function makeMockHttpClient(handler = () => makeHttpResponse()) {
64
66
  return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, toHttpError(error));
65
67
  }
66
68
  };
67
- return Object.assign(_chunk5EC274J5cjs.decorate.call(void 0, run, () => ({ ...stats })), {
69
+ return Object.assign(_chunkXPIMJQYScjs.decorate.call(void 0, run, () => ({ ...stats })), {
68
70
  calls: () => [...calls],
69
71
  calledTimes: () => calls.length,
70
72
  lastRequest: () => calls.at(-1),
@@ -85,8 +87,25 @@ function makeMockHttpClient(handler = () => makeHttpResponse()) {
85
87
  function makeSequenceHttpClient(responses, fallback = makeHttpResponse()) {
86
88
  return makeMockHttpClient((_req, index) => _nullishCoalesce(responses[index], () => ( fallback)));
87
89
  }
90
+ function makeMockDefaultHttpClient(handler = () => makeHttpResponse()) {
91
+ const wire = makeMockHttpClient(handler);
92
+ const client = _chunkXPIMJQYScjs.makeDefaultHttpClient.call(void 0, {
93
+ baseUrl: "http://brass.test",
94
+ preset: "minimal",
95
+ transport: ({ request }) => wire(request)
96
+ });
97
+ return Object.assign(client, {
98
+ calls: wire.calls,
99
+ calledTimes: wire.calledTimes,
100
+ lastRequest: wire.lastRequest,
101
+ reset: wire.reset
102
+ });
103
+ }
104
+ function makeMockDefaultHttpClientLayer(handler = () => makeHttpResponse(), options = {}) {
105
+ return _chunk5RZ7YITFcjs.layerValue.call(void 0, _nullishCoalesce(options.tag, () => ( _chunkXPIMJQYScjs.HttpClientService)), makeMockDefaultHttpClient(handler));
106
+ }
88
107
  function runHttpEffect(effect, env = {}) {
89
- return _chunkGLE2WY7Zcjs.toPromise.call(void 0, effect, env);
108
+ return _chunk2JHJ4YHScjs.toPromise.call(void 0, effect, env);
90
109
  }
91
110
  function makeFetchResponse(body = null, init = {}) {
92
111
  assertResponseAvailable();
@@ -158,4 +177,6 @@ function assertResponseAvailable() {
158
177
 
159
178
 
160
179
 
161
- exports.installMockFetch = installMockFetch; exports.makeFetchResponse = makeFetchResponse; exports.makeHttpResponse = makeHttpResponse; exports.makeJsonFetchResponse = makeJsonFetchResponse; exports.makeJsonHttpResponse = makeJsonHttpResponse; exports.makeMockHttpClient = makeMockHttpClient; exports.makeSequenceHttpClient = makeSequenceHttpClient; exports.makeTextHttpResponse = makeTextHttpResponse; exports.runHttpEffect = runHttpEffect; exports.withMockFetch = withMockFetch;
180
+
181
+
182
+ exports.installMockFetch = installMockFetch; exports.makeFetchResponse = makeFetchResponse; exports.makeHttpResponse = makeHttpResponse; exports.makeJsonFetchResponse = makeJsonFetchResponse; exports.makeJsonHttpResponse = makeJsonHttpResponse; exports.makeMockDefaultHttpClient = makeMockDefaultHttpClient; exports.makeMockDefaultHttpClientLayer = makeMockDefaultHttpClientLayer; exports.makeMockHttpClient = makeMockHttpClient; exports.makeSequenceHttpClient = makeSequenceHttpClient; exports.makeTextHttpResponse = makeTextHttpResponse; exports.runHttpEffect = runHttpEffect; exports.withMockFetch = withMockFetch;
@@ -1,7 +1,7 @@
1
- import { A as Async } from '../effect-DIUHZ9IN.js';
2
- import { H as HttpClient, a as HttpRequest, b as HttpWireResponse, c as HttpError } from '../client-CZHU674n.js';
3
- import '../stream-B4oK9JFP.js';
4
- import '../schedule-CK3Ml_7p.js';
1
+ import { S as ServiceTag, L as Layer, a as LayerContext } from '../layer-D2LFcBVx.js';
2
+ import { A as Async } from '../effect-DnGUuhw6.js';
3
+ import { D as DefaultHttpClient, H as HttpRequest, a as HttpClient, b as HttpWireResponse, c as HttpError } from '../defaultClient-Cid0JoUR.js';
4
+ import '../stream-I7bkvF7a.js';
5
5
  import '../schema/index.js';
6
6
 
7
7
  type HttpTestResponseInit = {
@@ -17,6 +17,15 @@ type MockHttpClient = HttpClient & {
17
17
  readonly lastRequest: () => HttpRequest | undefined;
18
18
  readonly reset: () => void;
19
19
  };
20
+ type MockDefaultHttpClient = DefaultHttpClient & {
21
+ readonly calls: () => readonly HttpRequest[];
22
+ readonly calledTimes: () => number;
23
+ readonly lastRequest: () => HttpRequest | undefined;
24
+ readonly reset: () => void;
25
+ };
26
+ type MockDefaultHttpClientLayerOptions = {
27
+ readonly tag?: ServiceTag<DefaultHttpClient>;
28
+ };
20
29
  type MockFetchCall = {
21
30
  readonly input: RequestInfo | URL;
22
31
  readonly init?: RequestInit;
@@ -34,10 +43,12 @@ declare function makeTextHttpResponse(bodyText: string, init?: HttpTestResponseI
34
43
  declare function makeJsonHttpResponse(body: unknown, init?: HttpTestResponseInit): HttpWireResponse;
35
44
  declare function makeMockHttpClient(handler?: MockHttpHandler): MockHttpClient;
36
45
  declare function makeSequenceHttpClient(responses: readonly HttpWireResponse[], fallback?: HttpWireResponse): MockHttpClient;
46
+ declare function makeMockDefaultHttpClient(handler?: MockHttpHandler): MockDefaultHttpClient;
47
+ declare function makeMockDefaultHttpClientLayer(handler?: MockHttpHandler, options?: MockDefaultHttpClientLayerOptions): Layer<LayerContext, never, LayerContext>;
37
48
  declare function runHttpEffect<E, A>(effect: Async<unknown, E, A>, env?: unknown): Promise<A>;
38
49
  declare function makeFetchResponse(body?: BodyInit | null, init?: ResponseInit): Response;
39
50
  declare function makeJsonFetchResponse(body: unknown, init?: ResponseInit): Response;
40
51
  declare function installMockFetch(handler: MockFetchHandler): MockFetchController;
41
52
  declare function withMockFetch<A>(handler: MockFetchHandler, run: (mock: MockFetchController) => Promise<A> | A): Promise<A>;
42
53
 
43
- export { type HttpTestResponseInit, type MockFetchCall, type MockFetchController, type MockFetchHandler, type MockHttpClient, type MockHttpHandler, installMockFetch, makeFetchResponse, makeHttpResponse, makeJsonFetchResponse, makeJsonHttpResponse, makeMockHttpClient, makeSequenceHttpClient, makeTextHttpResponse, runHttpEffect, withMockFetch };
54
+ export { type HttpTestResponseInit, type MockDefaultHttpClient, type MockDefaultHttpClientLayerOptions, type MockFetchCall, type MockFetchController, type MockFetchHandler, type MockHttpClient, type MockHttpHandler, installMockFetch, makeFetchResponse, makeHttpResponse, makeJsonFetchResponse, makeJsonHttpResponse, makeMockDefaultHttpClient, makeMockDefaultHttpClientLayer, makeMockHttpClient, makeSequenceHttpClient, makeTextHttpResponse, runHttpEffect, withMockFetch };
@@ -1,20 +1,22 @@
1
1
  import {
2
- decorate
3
- } from "../chunk-MIIYDLGM.js";
2
+ HttpClientService,
3
+ decorate,
4
+ makeDefaultHttpClient
5
+ } from "../chunk-WUDHOZIH.js";
4
6
  import "../chunk-TRM4JUZQ.js";
5
- import "../chunk-7JIJOVCT.js";
7
+ import "../chunk-IPSMXUWA.js";
6
8
  import "../chunk-UCUBNWM2.js";
7
- import "../chunk-6IXXWIUM.js";
8
- import "../chunk-L2SYFEBS.js";
9
- import "../chunk-3Y2RIUMM.js";
9
+ import {
10
+ layerValue
11
+ } from "../chunk-S4HXADU4.js";
10
12
  import {
11
13
  toPromise
12
- } from "../chunk-FH2X7BVP.js";
14
+ } from "../chunk-TTSPIU3U.js";
13
15
  import {
14
16
  asyncFail,
15
17
  asyncSucceed
16
18
  } from "../chunk-UB4B6OFY.js";
17
- import "../chunk-C3MDXTRZ.js";
19
+ import "../chunk-HCJ4S3YB.js";
18
20
  import "../chunk-3RG5ZIWI.js";
19
21
 
20
22
  // src/http/testing.ts
@@ -85,6 +87,23 @@ function makeMockHttpClient(handler = () => makeHttpResponse()) {
85
87
  function makeSequenceHttpClient(responses, fallback = makeHttpResponse()) {
86
88
  return makeMockHttpClient((_req, index) => responses[index] ?? fallback);
87
89
  }
90
+ function makeMockDefaultHttpClient(handler = () => makeHttpResponse()) {
91
+ const wire = makeMockHttpClient(handler);
92
+ const client = makeDefaultHttpClient({
93
+ baseUrl: "http://brass.test",
94
+ preset: "minimal",
95
+ transport: ({ request }) => wire(request)
96
+ });
97
+ return Object.assign(client, {
98
+ calls: wire.calls,
99
+ calledTimes: wire.calledTimes,
100
+ lastRequest: wire.lastRequest,
101
+ reset: wire.reset
102
+ });
103
+ }
104
+ function makeMockDefaultHttpClientLayer(handler = () => makeHttpResponse(), options = {}) {
105
+ return layerValue(options.tag ?? HttpClientService, makeMockDefaultHttpClient(handler));
106
+ }
88
107
  function runHttpEffect(effect, env = {}) {
89
108
  return toPromise(effect, env);
90
109
  }
@@ -153,6 +172,8 @@ export {
153
172
  makeHttpResponse,
154
173
  makeJsonFetchResponse,
155
174
  makeJsonHttpResponse,
175
+ makeMockDefaultHttpClient,
176
+ makeMockDefaultHttpClientLayer,
156
177
  makeMockHttpClient,
157
178
  makeSequenceHttpClient,
158
179
  makeTextHttpResponse,
@@ -1,20 +1,22 @@
1
1
  import {
2
- decorate
3
- } from "../chunk-5VRJNBLZ.mjs";
2
+ HttpClientService,
3
+ decorate,
4
+ makeDefaultHttpClient
5
+ } from "../chunk-Z3ZZMQUZ.mjs";
4
6
  import "../chunk-MOO4L7F4.mjs";
5
- import "../chunk-FHQGHPMO.mjs";
7
+ import "../chunk-BC6Q6BCO.mjs";
6
8
  import "../chunk-B5JD23U7.mjs";
7
- import "../chunk-2HQTDLHF.mjs";
8
- import "../chunk-A2OM6NEH.mjs";
9
- import "../chunk-PWC3RBQE.mjs";
9
+ import {
10
+ layerValue
11
+ } from "../chunk-EEN5OTCR.mjs";
10
12
  import {
11
13
  toPromise
12
- } from "../chunk-GYM3LLGS.mjs";
14
+ } from "../chunk-H626ZTDZ.mjs";
13
15
  import {
14
16
  asyncFail,
15
17
  asyncSucceed
16
18
  } from "../chunk-36I3M4UC.mjs";
17
- import "../chunk-DNFJLJMW.mjs";
19
+ import "../chunk-6MLAZPBL.mjs";
18
20
  import "../chunk-Y6FXYEAI.mjs";
19
21
 
20
22
  // src/http/testing.ts
@@ -85,6 +87,23 @@ function makeMockHttpClient(handler = () => makeHttpResponse()) {
85
87
  function makeSequenceHttpClient(responses, fallback = makeHttpResponse()) {
86
88
  return makeMockHttpClient((_req, index) => responses[index] ?? fallback);
87
89
  }
90
+ function makeMockDefaultHttpClient(handler = () => makeHttpResponse()) {
91
+ const wire = makeMockHttpClient(handler);
92
+ const client = makeDefaultHttpClient({
93
+ baseUrl: "http://brass.test",
94
+ preset: "minimal",
95
+ transport: ({ request }) => wire(request)
96
+ });
97
+ return Object.assign(client, {
98
+ calls: wire.calls,
99
+ calledTimes: wire.calledTimes,
100
+ lastRequest: wire.lastRequest,
101
+ reset: wire.reset
102
+ });
103
+ }
104
+ function makeMockDefaultHttpClientLayer(handler = () => makeHttpResponse(), options = {}) {
105
+ return layerValue(options.tag ?? HttpClientService, makeMockDefaultHttpClient(handler));
106
+ }
88
107
  function runHttpEffect(effect, env = {}) {
89
108
  return toPromise(effect, env);
90
109
  }
@@ -153,6 +172,8 @@ export {
153
172
  makeHttpResponse,
154
173
  makeJsonFetchResponse,
155
174
  makeJsonHttpResponse,
175
+ makeMockDefaultHttpClient,
176
+ makeMockDefaultHttpClientLayer,
156
177
  makeMockHttpClient,
157
178
  makeSequenceHttpClient,
158
179
  makeTextHttpResponse,