brass-runtime 1.17.0 → 1.18.0

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-GYM3LLGS.mjs → chunk-2QNREG6K.mjs} +188 -5
  10. package/dist/{chunk-4ROBZFL6.cjs → chunk-2SLT3X6G.cjs} +6 -8
  11. package/dist/{chunk-KZJQ723N.cjs → chunk-3PFZGP23.cjs} +13 -15
  12. package/dist/{chunk-VWIPB6I5.js → chunk-3PHU7FWS.js} +528 -23
  13. package/dist/{chunk-BKK77SBA.js → chunk-4YQHPIWJ.js} +32 -11
  14. package/dist/chunk-5XADBMSU.cjs +33 -0
  15. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  16. package/dist/chunk-7TKI527D.cjs +123 -0
  17. package/dist/{chunk-AGR5B2BC.cjs → chunk-7TXQJFZX.cjs} +564 -12
  18. package/dist/{chunk-RKGKFN2A.js → chunk-AADFFVYS.js} +1 -1
  19. package/dist/{chunk-52PPNNI4.cjs → chunk-AJMKZXRB.cjs} +2 -2
  20. package/dist/{chunk-3AYM6WPJ.js → chunk-BG5RNEA2.js} +20 -299
  21. package/dist/{chunk-2HQTDLHF.mjs → chunk-ELLF55ER.mjs} +555 -3
  22. package/dist/{chunk-EOC4UHBS.mjs → chunk-G5JTCFMI.mjs} +2 -2
  23. package/dist/chunk-H5GYX7RZ.js +6126 -0
  24. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  25. package/dist/{chunk-6IXXWIUM.js → chunk-IBRHSH5H.js} +555 -3
  26. package/dist/{chunk-Q2I37RP3.cjs → chunk-IFRBVMWJ.cjs} +44 -323
  27. package/dist/{chunk-52OB2ROS.js → chunk-ITG6I7ZS.js} +2 -4
  28. package/dist/chunk-ITZQ526U.mjs +33 -0
  29. package/dist/{chunk-7JIJOVCT.js → chunk-JH4GI3DW.js} +2 -4
  30. package/dist/{chunk-F6XWZQY4.cjs → chunk-KHACHFBQ.cjs} +583 -78
  31. package/dist/{chunk-4P2HHGAX.mjs → chunk-KRYP6CAE.mjs} +32 -11
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/{chunk-WBGRHGBP.cjs → chunk-LXBU5E77.cjs} +114 -93
  34. package/dist/{chunk-PD4EJTQC.cjs → chunk-N6QNSTWD.cjs} +5 -5
  35. package/dist/{chunk-6RY2FFN4.mjs → chunk-OI4ESUMC.mjs} +9 -11
  36. package/dist/{chunk-EJ6BPYVR.mjs → chunk-OT2TESZU.mjs} +1 -1
  37. package/dist/{chunk-7X3K5RMS.js → chunk-PSEU65ND.js} +9 -11
  38. package/dist/{chunk-SK7UZRNI.mjs → chunk-QCOLAHU3.mjs} +528 -23
  39. package/dist/{chunk-KH4SYAOS.mjs → chunk-QZ6QFJNM.mjs} +20 -299
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-R6WDSZA6.mjs} +2 -4
  41. package/dist/{chunk-FHQGHPMO.mjs → chunk-RREBJX2S.mjs} +2 -4
  42. package/dist/{chunk-5QC7LRZ3.js → chunk-S4HHFUYP.js} +2 -2
  43. package/dist/{chunk-GLE2WY7Z.cjs → chunk-SSQJKDN3.cjs} +194 -11
  44. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  45. package/dist/chunk-VIFA4DPN.cjs +6126 -0
  46. package/dist/chunk-W6WR37HN.js +33 -0
  47. package/dist/{chunk-FH2X7BVP.js → chunk-XSAHV5HQ.js} +188 -5
  48. package/dist/chunk-YM3EDNYD.js +123 -0
  49. package/dist/{chunk-7ZPEZ57L.cjs → chunk-YTX2JYYP.cjs} +18 -20
  50. package/dist/chunk-Z3PSSXP3.mjs +6126 -0
  51. package/dist/core/index.cjs +31 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +80 -58
  54. package/dist/core/index.mjs +80 -58
  55. package/dist/defaultClient-DhpCQW9m.d.ts +1623 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-CtUDl5M5.d.ts} +1 -1
  57. package/dist/http/index.cjs +202 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +216 -73
  60. package/dist/http/index.mjs +216 -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 +110 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +81 -59
  68. package/dist/index.mjs +81 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-BalPI6cN.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-C1zVmqE6.d.ts} +5 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-Bb4FTejt.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DzfuE6um.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-BABA5arE.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 +4 -1
  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,125 @@
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-KRYP6CAE.mjs";
9
+ import "../chunk-OT2TESZU.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
+ isRetryableHttpError,
56
+ isRetryableHttpStatus,
57
57
  isTaggedHttpError,
58
+ isTimeoutHttpError,
59
+ isValidationError,
58
60
  linkAbortSignals,
59
61
  makeAdaptiveLimiterConfig,
62
+ makeBudgetSemaphore,
63
+ makeCompressionMiddleware,
64
+ makeConnectionStateMap,
65
+ makeDefaultHttpClient,
66
+ makeDefaultHttpClientLayer,
60
67
  makeFetchStreamTransport,
61
68
  makeFetchTransport,
62
69
  makeHttp,
70
+ makeHttpClient,
63
71
  makeHttpStream,
72
+ makeJsonParseValidationError,
73
+ makeLifecycleClient,
74
+ makePrewarmManager,
64
75
  makePromiseHttpTransport,
76
+ makeRequestCompressionMiddleware,
77
+ makeResponseCompressionMiddleware,
78
+ matchHttpError,
65
79
  normalizeHeadersInit,
66
80
  normalizeHttpError,
67
81
  normalizeHttpHeaders,
68
82
  normalizeRetryBudget,
83
+ now,
84
+ parseCacheKey,
69
85
  promiseHttpTransport,
70
86
  resolveConfig,
71
87
  resolveHttpPoolKey,
88
+ resolveHttpRequestPolicyPresets,
72
89
  retryAfterMs,
73
90
  setHeaderIfMissing,
91
+ toHttpError,
74
92
  validateConfig,
93
+ validateFetchAvailable,
94
+ validateOrigin,
95
+ validatedJson,
96
+ validatedJsonResponse,
97
+ withBatch,
98
+ withCache,
99
+ withDedup,
100
+ withHttpPolicyPresets,
101
+ withHttpRequestPolicy,
75
102
  withMiddleware,
103
+ withPriority,
76
104
  withRetry,
77
105
  withRetryStream
78
- } from "../chunk-5VRJNBLZ.mjs";
106
+ } from "../chunk-Z3PSSXP3.mjs";
79
107
  import {
80
108
  registerHttpEffect
81
109
  } from "../chunk-MOO4L7F4.mjs";
82
- import "../chunk-FHQGHPMO.mjs";
110
+ import "../chunk-RREBJX2S.mjs";
83
111
  import "../chunk-B5JD23U7.mjs";
84
112
  import {
85
113
  fixed,
86
114
  makeScheduleDriver,
115
+ resource,
87
116
  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";
117
+ } from "../chunk-ELLF55ER.mjs";
119
118
  import {
120
119
  Runtime,
121
120
  fromPromiseAbortable,
122
121
  toPromise
123
- } from "../chunk-GYM3LLGS.mjs";
122
+ } from "../chunk-2QNREG6K.mjs";
124
123
  import {
125
124
  Cause,
126
125
  asyncEffect,
@@ -144,9 +143,142 @@ import {
144
143
  s,
145
144
  schema,
146
145
  validateValue
147
- } from "../chunk-DNFJLJMW.mjs";
146
+ } from "../chunk-6MLAZPBL.mjs";
148
147
  import "../chunk-Y6FXYEAI.mjs";
149
148
 
149
+ // src/http/nodeTransport.ts
150
+ import {
151
+ Agent as HttpAgent,
152
+ request as httpRequest
153
+ } from "http";
154
+ import {
155
+ Agent as HttpsAgent,
156
+ request as httpsRequest
157
+ } from "https";
158
+ var nowMs = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
159
+ var toAgentOptions = (config) => ({
160
+ keepAlive: config.keepAlive ?? true,
161
+ ...config.maxSockets !== void 0 ? { maxSockets: config.maxSockets } : {},
162
+ ...config.maxFreeSockets !== void 0 ? { maxFreeSockets: config.maxFreeSockets } : {}
163
+ });
164
+ var isError = (value) => value instanceof Error;
165
+ function unsupportedProtocol(url) {
166
+ return {
167
+ _tag: "BadUrl",
168
+ message: `Unsupported URL protocol for node HTTP transport: ${url.protocol}`
169
+ };
170
+ }
171
+ function runNodeRequest(context, config, httpAgent, httpsAgent) {
172
+ return asyncEffect((_env, cb) => {
173
+ const { request, url, signal } = context;
174
+ const isHttps = url.protocol === "https:";
175
+ const isHttp = url.protocol === "http:";
176
+ if (!isHttp && !isHttps) {
177
+ cb({ _tag: "Failure", cause: Cause.fail(unsupportedProtocol(url)) });
178
+ return;
179
+ }
180
+ if (signal.aborted) {
181
+ cb({ _tag: "Failure", cause: Cause.fail(abortErrorForSignal(signal)) });
182
+ return;
183
+ }
184
+ const started = nowMs();
185
+ const chunks = [];
186
+ let byteLength = 0;
187
+ let done = false;
188
+ let abort = () => void 0;
189
+ const finish = (exit) => {
190
+ if (done) return;
191
+ done = true;
192
+ signal.removeEventListener("abort", abort);
193
+ cb(exit);
194
+ };
195
+ const fail = (error) => {
196
+ finish({
197
+ _tag: "Failure",
198
+ cause: Cause.fail(normalizeHttpError(error, { signal }))
199
+ });
200
+ };
201
+ const options = {
202
+ method: request.method,
203
+ headers: Request.headers.get(request),
204
+ agent: isHttps ? httpsAgent : httpAgent,
205
+ signal
206
+ };
207
+ const nodeRequest = (isHttps ? httpsRequest : httpRequest)(url, options, (response) => {
208
+ response.on("data", (chunk) => {
209
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
210
+ chunks.push(buffer);
211
+ byteLength += buffer.length;
212
+ });
213
+ response.on("end", () => {
214
+ finish({
215
+ _tag: "Success",
216
+ value: {
217
+ status: response.statusCode ?? 0,
218
+ statusText: response.statusMessage ?? "",
219
+ headers: normalizeHttpHeaders(response.headers),
220
+ bodyText: Buffer.concat(chunks, byteLength).toString("utf8"),
221
+ ms: Math.round(nowMs() - started)
222
+ }
223
+ });
224
+ });
225
+ response.on("error", fail);
226
+ });
227
+ abort = () => {
228
+ nodeRequest.destroy(isError(signal.reason) ? signal.reason : void 0);
229
+ finish({ _tag: "Failure", cause: Cause.fail(abortErrorForSignal(signal)) });
230
+ };
231
+ signal.addEventListener("abort", abort, { once: true });
232
+ nodeRequest.on("error", fail);
233
+ if (config.socketTimeoutMs !== void 0 && config.socketTimeoutMs > 0) {
234
+ nodeRequest.setTimeout(config.socketTimeoutMs, () => {
235
+ nodeRequest.destroy(Object.assign(new Error("Node HTTP socket timed out"), {
236
+ code: "ETIMEDOUT"
237
+ }));
238
+ });
239
+ }
240
+ if (request.body !== void 0) {
241
+ nodeRequest.write(request.body);
242
+ }
243
+ nodeRequest.end();
244
+ return () => {
245
+ if (done) return;
246
+ nodeRequest.destroy(Object.assign(new Error("Node HTTP transport aborted"), {
247
+ name: "AbortError",
248
+ code: "ABORT_ERR"
249
+ }));
250
+ finish({ _tag: "Failure", cause: Cause.fail({ _tag: "Abort" }) });
251
+ };
252
+ });
253
+ }
254
+ function makeNodeHttpTransport(config = {}) {
255
+ const agentOptions = toAgentOptions(config);
256
+ const httpAgent = config.httpAgent ?? new HttpAgent(agentOptions);
257
+ const httpsAgent = config.httpsAgent ?? new HttpsAgent(agentOptions);
258
+ const ownsHttpAgent = config.httpAgent === void 0;
259
+ const ownsHttpsAgent = config.httpsAgent === void 0;
260
+ const transport = (context) => runNodeRequest(context, config, httpAgent, httpsAgent);
261
+ return Object.assign(transport, {
262
+ destroy: () => {
263
+ if (ownsHttpAgent) httpAgent.destroy();
264
+ if (ownsHttpsAgent) httpsAgent.destroy();
265
+ }
266
+ });
267
+ }
268
+ function makeNodeHttpProxyClient(config = {}) {
269
+ const {
270
+ preset = "highThroughputProxy",
271
+ transport,
272
+ nodeTransport,
273
+ ...clientConfig
274
+ } = config;
275
+ return makeDefaultHttpClient({
276
+ ...clientConfig,
277
+ preset,
278
+ transport: transport ?? makeNodeHttpTransport(nodeTransport)
279
+ });
280
+ }
281
+
150
282
  // src/http/httpClient.ts
151
283
  var resolveFinalUrl = (baseUrl, url) => {
152
284
  try {
@@ -941,6 +1073,7 @@ function makeBuilder(config) {
941
1073
  transport: (transport) => replace({ transport }),
942
1074
  preset: (preset) => replace({ preset }),
943
1075
  minimal: () => replace({ preset: "minimal" }),
1076
+ proxy: () => replace({ preset: "proxy" }),
944
1077
  balanced: () => replace({ preset: "balanced" }),
945
1078
  defaultPreset: () => replace({ preset: "default" }),
946
1079
  production: () => replace({ preset: "production" }),
@@ -1504,7 +1637,12 @@ function normalizeRouteMethod(method) {
1504
1637
  function normalizeRoutePath(path) {
1505
1638
  if (!path || path === "*") return "/";
1506
1639
  const withSlash = path.startsWith("/") ? path : `/${path}`;
1507
- return withSlash.length > 1 ? withSlash.replace(/\/+$/, "") : withSlash;
1640
+ if (withSlash.length <= 1) return withSlash;
1641
+ let end = withSlash.length;
1642
+ while (end > 0 && withSlash.charCodeAt(end - 1) === 47) {
1643
+ end -= 1;
1644
+ }
1645
+ return withSlash.slice(0, end);
1508
1646
  }
1509
1647
  function parseRequestUrl(target, host) {
1510
1648
  try {
@@ -1569,6 +1707,7 @@ export {
1569
1707
  ConfigValidationError,
1570
1708
  DEFAULT_CACHE_RELEVANT_HEADERS,
1571
1709
  EmaComputer,
1710
+ HttpClientService,
1572
1711
  HttpConcurrencyPool,
1573
1712
  HttpServer,
1574
1713
  LRUCache,
@@ -1633,6 +1772,7 @@ export {
1633
1772
  makeCompressionMiddleware,
1634
1773
  makeConnectionStateMap,
1635
1774
  makeDefaultHttpClient,
1775
+ makeDefaultHttpClientLayer,
1636
1776
  makeFetchStreamTransport,
1637
1777
  makeFetchTransport,
1638
1778
  makeHttp,
@@ -1641,9 +1781,12 @@ export {
1641
1781
  makeHttpRouter,
1642
1782
  makeHttpServerResource,
1643
1783
  makeHttpStream,
1784
+ makeJsonParseValidationError,
1644
1785
  makeLifecycleClient,
1786
+ makeNodeHttpProxyClient,
1645
1787
  makeNodeHttpServer,
1646
1788
  makeNodeHttpServerResource,
1789
+ makeNodeHttpTransport,
1647
1790
  makePrewarmManager,
1648
1791
  makePromiseHttpTransport,
1649
1792
  makeRequestCompressionMiddleware,
@@ -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 _chunkVIFA4DPNcjs = require('../chunk-VIFA4DPN.cjs');
4
6
  require('../chunk-L6VB5N7Q.cjs');
5
- require('../chunk-KZJQ723N.cjs');
7
+ require('../chunk-3PFZGP23.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 _chunk7TXQJFZXcjs = require('../chunk-7TXQJFZX.cjs');
12
+
13
+
14
+ var _chunkSSQJKDN3cjs = require('../chunk-SSQJKDN3.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(_chunkVIFA4DPNcjs.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 = _chunkVIFA4DPNcjs.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 _chunk7TXQJFZXcjs.layerValue.call(void 0, _nullishCoalesce(options.tag, () => ( _chunkVIFA4DPNcjs.HttpClientService)), makeMockDefaultHttpClient(handler));
106
+ }
88
107
  function runHttpEffect(effect, env = {}) {
89
- return _chunkGLE2WY7Zcjs.toPromise.call(void 0, effect, env);
108
+ return _chunkSSQJKDN3cjs.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-BalPI6cN.js';
2
+ import { A as Async } from '../effect-CtUDl5M5.js';
3
+ import { D as DefaultHttpClient, H as HttpRequest, a as HttpClient, b as HttpWireResponse, c as HttpError } from '../defaultClient-DhpCQW9m.js';
4
+ import '../stream-Bb4FTejt.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-H5GYX7RZ.js";
4
6
  import "../chunk-TRM4JUZQ.js";
5
- import "../chunk-7JIJOVCT.js";
7
+ import "../chunk-JH4GI3DW.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-IBRHSH5H.js";
10
12
  import {
11
13
  toPromise
12
- } from "../chunk-FH2X7BVP.js";
14
+ } from "../chunk-XSAHV5HQ.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-Z3PSSXP3.mjs";
4
6
  import "../chunk-MOO4L7F4.mjs";
5
- import "../chunk-FHQGHPMO.mjs";
7
+ import "../chunk-RREBJX2S.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-ELLF55ER.mjs";
10
12
  import {
11
13
  toPromise
12
- } from "../chunk-GYM3LLGS.mjs";
14
+ } from "../chunk-2QNREG6K.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,