brass-runtime 1.16.1 → 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.
- package/README.md +40 -8
- package/dist/agent/cli/main.cjs +31 -32
- package/dist/agent/cli/main.js +3 -4
- package/dist/agent/cli/main.mjs +3 -4
- package/dist/agent/index.cjs +4 -5
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +3 -4
- package/dist/agent/index.mjs +3 -4
- package/dist/{chunk-GYM3LLGS.mjs → chunk-2QNREG6K.mjs} +188 -5
- package/dist/{chunk-4ROBZFL6.cjs → chunk-2SLT3X6G.cjs} +6 -8
- package/dist/{chunk-KZJQ723N.cjs → chunk-3PFZGP23.cjs} +13 -15
- package/dist/{chunk-AVNQLJ5V.js → chunk-3PHU7FWS.js} +528 -23
- package/dist/{chunk-CIZFIMK5.js → chunk-4YQHPIWJ.js} +60 -11
- package/dist/chunk-5XADBMSU.cjs +33 -0
- package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
- package/dist/chunk-7TKI527D.cjs +123 -0
- package/dist/{chunk-AGR5B2BC.cjs → chunk-7TXQJFZX.cjs} +564 -12
- package/dist/{chunk-RKGKFN2A.js → chunk-AADFFVYS.js} +1 -1
- package/dist/{chunk-52PPNNI4.cjs → chunk-AJMKZXRB.cjs} +2 -2
- package/dist/{chunk-3AYM6WPJ.js → chunk-BG5RNEA2.js} +20 -299
- package/dist/{chunk-2HQTDLHF.mjs → chunk-ELLF55ER.mjs} +555 -3
- package/dist/{chunk-EOC4UHBS.mjs → chunk-G5JTCFMI.mjs} +2 -2
- package/dist/chunk-H5GYX7RZ.js +6126 -0
- package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
- package/dist/{chunk-6IXXWIUM.js → chunk-IBRHSH5H.js} +555 -3
- package/dist/{chunk-Q2I37RP3.cjs → chunk-IFRBVMWJ.cjs} +44 -323
- package/dist/{chunk-52OB2ROS.js → chunk-ITG6I7ZS.js} +2 -4
- package/dist/chunk-ITZQ526U.mjs +33 -0
- package/dist/{chunk-7JIJOVCT.js → chunk-JH4GI3DW.js} +2 -4
- package/dist/{chunk-76YMRMH2.cjs → chunk-KHACHFBQ.cjs} +583 -78
- package/dist/{chunk-MT3OWDPC.mjs → chunk-KRYP6CAE.mjs} +60 -11
- package/dist/chunk-KTGDLBLD.mjs +123 -0
- package/dist/{chunk-ENKODRU3.cjs → chunk-LXBU5E77.cjs} +143 -94
- package/dist/{chunk-PD4EJTQC.cjs → chunk-N6QNSTWD.cjs} +5 -5
- package/dist/{chunk-HLWLMW2F.mjs → chunk-OI4ESUMC.mjs} +9 -11
- package/dist/{chunk-EJ6BPYVR.mjs → chunk-OT2TESZU.mjs} +1 -1
- package/dist/{chunk-BABBZK4Y.js → chunk-PSEU65ND.js} +9 -11
- package/dist/{chunk-DNFO2EIZ.mjs → chunk-QCOLAHU3.mjs} +528 -23
- package/dist/{chunk-KH4SYAOS.mjs → chunk-QZ6QFJNM.mjs} +20 -299
- package/dist/{chunk-MBEJI5HF.mjs → chunk-R6WDSZA6.mjs} +2 -4
- package/dist/{chunk-FHQGHPMO.mjs → chunk-RREBJX2S.mjs} +2 -4
- package/dist/{chunk-5QC7LRZ3.js → chunk-S4HHFUYP.js} +2 -2
- package/dist/{chunk-GLE2WY7Z.cjs → chunk-SSQJKDN3.cjs} +194 -11
- package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
- package/dist/chunk-VIFA4DPN.cjs +6126 -0
- package/dist/chunk-W6WR37HN.js +33 -0
- package/dist/{chunk-FH2X7BVP.js → chunk-XSAHV5HQ.js} +188 -5
- package/dist/chunk-YM3EDNYD.js +123 -0
- package/dist/{chunk-VN44DYYT.cjs → chunk-YTX2JYYP.cjs} +18 -20
- package/dist/chunk-Z3PSSXP3.mjs +6126 -0
- package/dist/core/index.cjs +31 -9
- package/dist/core/index.d.ts +19 -152
- package/dist/core/index.js +80 -58
- package/dist/core/index.mjs +80 -58
- package/dist/defaultClient-DhpCQW9m.d.ts +1623 -0
- package/dist/{effect-DIUHZ9IN.d.ts → effect-CtUDl5M5.d.ts} +1 -1
- package/dist/http/index.cjs +202 -59
- package/dist/http/index.d.ts +55 -819
- package/dist/http/index.js +216 -73
- package/dist/http/index.mjs +216 -73
- package/dist/http/testing.cjs +31 -10
- package/dist/http/testing.d.ts +16 -5
- package/dist/http/testing.js +29 -8
- package/dist/http/testing.mjs +29 -8
- package/dist/index.cjs +110 -88
- package/dist/index.d.ts +9 -8
- package/dist/index.js +81 -59
- package/dist/index.mjs +81 -59
- package/dist/{schedule-CK3Ml_7p.d.ts → layer-BalPI6cN.d.ts} +176 -2
- package/dist/observability/index.cjs +22 -7
- package/dist/observability/index.d.ts +32 -8
- package/dist/observability/index.js +21 -6
- package/dist/observability/index.mjs +21 -6
- package/dist/perf/cli.cjs +26 -28
- package/dist/perf/cli.js +11 -13
- package/dist/perf/cli.mjs +11 -13
- package/dist/perf/index.cjs +13 -15
- package/dist/perf/index.js +11 -13
- package/dist/perf/index.mjs +11 -13
- package/dist/schema/index.cjs +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.mjs +1 -1
- package/dist/{server-GJPg8ZSG.d.ts → server-C1zVmqE6.d.ts} +16 -5
- package/dist/{stream-B4oK9JFP.d.ts → stream-Bb4FTejt.d.ts} +1 -1
- package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DzfuE6um.d.ts} +2 -2
- package/dist/{tracing-DqbTKGcf.d.ts → tracing-BABA5arE.d.ts} +1 -1
- package/docs/README.md +4 -0
- package/docs/ai/PUBLIC_API.md +31 -7
- package/docs/articles/brass-runtime-http-observability.md +467 -0
- package/docs/framework-integrations.md +38 -0
- package/docs/frameworks/angular.md +204 -0
- package/docs/frameworks/express.md +183 -0
- package/docs/frameworks/fastify.md +173 -0
- package/docs/frameworks/nestjs.md +335 -0
- package/docs/frameworks/nextjs.md +202 -0
- package/docs/frameworks/react.md +183 -0
- package/docs/frameworks/vanilla.md +280 -0
- package/docs/guides/layers.md +130 -0
- package/docs/http-recipes.md +31 -1
- package/docs/http.md +50 -1
- package/docs/nestjs.md +6 -0
- package/docs/observability-framework-examples.md +12 -0
- package/docs/observability.md +239 -0
- package/docs/performance-profiler.md +6 -2
- package/docs/recipes/layers.md +46 -2
- package/docs/recipes/testing.md +25 -0
- package/package.json +4 -1
- package/dist/chunk-3LOYJFRR.cjs +0 -300
- package/dist/chunk-3Y2RIUMM.js +0 -300
- package/dist/chunk-5EC274J5.cjs +0 -2874
- package/dist/chunk-5VRJNBLZ.mjs +0 -2874
- package/dist/chunk-62AZW6UT.cjs +0 -313
- package/dist/chunk-74ZTY6CP.js +0 -2871
- package/dist/chunk-7CMJS3QE.mjs +0 -2871
- package/dist/chunk-A2OM6NEH.mjs +0 -194
- package/dist/chunk-B33ICAKP.js +0 -313
- package/dist/chunk-JF5WGYJJ.cjs +0 -194
- package/dist/chunk-KN32XNTH.mjs +0 -313
- package/dist/chunk-KQLYONSE.cjs +0 -2871
- package/dist/chunk-L2SYFEBS.js +0 -194
- package/dist/chunk-MIIYDLGM.js +0 -2874
- package/dist/chunk-PWC3RBQE.mjs +0 -300
- package/dist/client-CZHU674n.d.ts +0 -820
package/dist/http/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { C as CompressionConfig, f as CompressionMiddlewareResult, R as RequestCompressionConfig, g as RequestCompressionMiddlewareResult, e as DefaultHttpClientConfig, h as HttpTransport, D as DefaultHttpClient, i as AdaptiveLimiter, H as HttpRequest, d as HttpMiddleware, L as LifecycleClientConfig, j as LifecycleClient, b as HttpWireResponse, c as HttpError, k as LifecycleEvent, l as HttpClientStats, m as LifecycleEventType, n as LifecycleStats, P as PrewarmResult, o as PrewarmStatusSnapshot, p as PrewarmConfig, q as HttpClientFn, r as PrewarmOriginState, s as HttpMethod, t as DefaultHttpClientPreset, u as DedupConfig$1, B as BatchConfig, v as CacheConfig$1, w as PriorityConfig$1, x as RetryPolicy, y as PrewarmLifecycleConfig, z as AdaptiveLimiterConfig, E as AdaptiveLimiterPreset, F as HttpPoolConfig } from '../defaultClient-DhpCQW9m.js';
|
|
2
|
+
export { G as AdaptiveAcquireOptions, I as AdaptiveBaselineStrategy, J as AdaptiveHeadroomContext, K as AdaptiveHeadroomMode, M as AdaptiveHeadroomStrategy, N as AdaptiveLease, O as AdaptiveLimiterDiagnostics, Q as AdaptiveLimiterKeySnapshot, A as AdaptiveLimiterStats, S as AdaptiveQueueLoadShedding, T as AdaptiveQueueStrategy, U as AdaptiveReleaseInfo, V as BatchFunction, W as CachePolicyResult, X as CompressionStats, Y as DecompressResult, Z as Decompressor, _ as DefaultGetJson, $ as DefaultHttpClientFeatures, a0 as DefaultPostJson, a1 as Dx, a2 as HttpBody, a as HttpClient, a3 as HttpClientStream, a4 as HttpClientStreamFn, a5 as HttpConcurrencyPool, a6 as HttpErrorHandlers, a7 as HttpInit, a8 as HttpJsonInit, a9 as HttpMeta, aa as HttpPolicyPreset, ab as HttpPolicyPresets, ac as HttpPoolKeyResolver, ad as HttpPoolKeyStats, ae as HttpPoolLease, af as HttpPoolStats, ag as HttpPostJsonBodyInit, ah as HttpPostJsonInit, ai as HttpPostJsonSchemaBodyInit, aj as HttpRequestPolicy, ak as HttpRequestPolicyRef, al as HttpRequestRetryOverride, am as HttpResponse, an as HttpResponseWithMeta, ao as HttpRetryScheduleInput, ap as HttpStreamTransport, aq as HttpTransportContext, ar as HttpTransportTiming, as as HttpWireResponseStream, at as HttpWireWithMeta, au as JsonDecodeResult, av as KnownHttpError, aw as KnownHttpErrorTag, ax as LifecycleRequestOptions, ay as LimitChangeEvent, az as MakeHttpConfig, aA as PerRequestRetryOverride, aB as PrewarmEvent, aC as PrewarmEventType, aD as PrewarmOriginStatus, aE as PrewarmResultStatus, aF as PromiseHttpTransportBodyBuilder, aG as PromiseHttpTransportBodySelector, aH as PromiseHttpTransportConfig, aI as PromiseHttpTransportConfigWithSignal, aJ as PromiseHttpTransportFluentResponseBuilder, aK as PromiseHttpTransportRequestConfigBuilder, aL as PromiseHttpTransportRequestConfigContext, aM as PromiseHttpTransportRequestConfigMapper, aN as PromiseHttpTransportResponse, aO as PromiseHttpTransportResponseInfo, aP as PromiseHttpTransportResponseInfoMapper, aQ as PromiseHttpTransportStartBuilder, aR as RequestCompressionStats, aS as ResolveHttpRequestPolicyOptions, aT as ResolvedConfig, aU as RetryEvent, aV as RetryScheduleInput, aW as RetryableHttpErrorOptions, aX as SUPPORTED_ENCODINGS, aY as SupportedEncoding, aZ as ToHttpErrorOptions, a_ as ValidationError, a$ as abortErrorForSignal, b0 as adaptiveLimiterPresets, b1 as backoffDelayMs, b2 as decodeJsonBody, b3 as decodeJsonBodyEffect, b4 as decorate, b5 as defaultHttpClientPreset, b6 as defaultRetryOnError, b7 as defaultRetryOnStatus, b8 as defaultRetryableMethods, b9 as defineHttpPolicyPresets, ba as encodeJsonBodyEffect, bb as formatHttpError, bc as getHttpRequestPolicy, bd as headersOf, be as httpClient, bf as httpClientStream, bg as httpClientWithMeta, bh as httpErrorStatus, bi as httpPolicy, bj as isAbortError, bk as isAbortHttpError, bl as isCircuitBreakerOpen, bm as isExternalAbortError, bn as isExternalTimeoutError, bo as isFetchHttpError, bp as isHttpError, bq as isKnownHttpError, br as isRetryableHttpError, bs as isRetryableHttpStatus, bt as isTaggedHttpError, bu as isTimeoutHttpError, bv as isValidationError, bw as linkAbortSignals, bx as makeAdaptiveLimiterConfig, by as makeDefaultHttpClient, bz as makeFetchStreamTransport, bA as makeFetchTransport, bB as makeHttp, bC as makeHttpStream, bD as makeJsonParseValidationError, bE as makePromiseHttpTransport, bF as matchHttpError, bG as normalizeHeadersInit, bH as normalizeHttpError, bI as normalizeHttpHeaders, bJ as normalizeRetryBudget, bK as promiseHttpTransport, bL as resolveConfig, bM as resolveHttpPoolKey, bN as resolveHttpRequestPolicyPresets, bO as retryAfterMs, bP as toHttpError, bQ as validateConfig, bR as validatedJson, bS as validatedJsonResponse, bT as withBatch, bU as withHttpPolicyPresets, bV as withHttpRequestPolicy, bW as withMiddleware, bX as withRetry, bY as withRetryStream } from '../defaultClient-DhpCQW9m.js';
|
|
3
|
+
import { Agent, Server } from 'node:http';
|
|
4
|
+
import { Agent as Agent$1 } from 'node:https';
|
|
5
|
+
import { c as CircuitBreakerConfig, l as Schedule, a as LayerContext, S as ServiceTag, L as Layer } from '../layer-BalPI6cN.js';
|
|
6
|
+
import { T as Tracer, R as Resource } from '../tracing-BABA5arE.js';
|
|
7
|
+
import { A as Async, b as Runtime, a as RuntimeOptions } from '../effect-CtUDl5M5.js';
|
|
8
|
+
import { AddressInfo } from 'node:net';
|
|
9
|
+
import { O as Observability, q as HttpServerObservabilityOptions, $ as RuntimeHealthOptions } from '../server-C1zVmqE6.js';
|
|
4
10
|
import { AnyJsonSchemaLike, InferJsonSchema } from '../schema/index.js';
|
|
5
11
|
export { AnySchema, ConfigValidationError, InferObject, InferSchema, JsonSchemaLike, JsonValidator, JsonValidatorResult, NumberSchemaOptions, ObjectSchemaOptions, Schema, SchemaIssue, SchemaPathPart, SchemaResult, SchemaShape, SchemaValidationException, StringSchemaOptions, formatConfigError, formatIssues, isConfigValidationError, isSchema, makeSchemaIssue, parseConfig, s, schema, validateValue } from '../schema/index.js';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Server } from 'node:http';
|
|
9
|
-
import { AddressInfo } from 'node:net';
|
|
10
|
-
import { O as Observability, p as HttpServerObservabilityOptions, Z as RuntimeHealthOptions } from '../server-GJPg8ZSG.js';
|
|
11
|
-
import '../stream-B4oK9JFP.js';
|
|
12
|
-
import '../tracer-Hwt1cl7h.js';
|
|
12
|
+
import '../stream-Bb4FTejt.js';
|
|
13
|
+
import '../tracer-DzfuE6um.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* A fixed-size circular buffer that stores latency samples and supports
|
|
@@ -104,150 +105,42 @@ declare function computeNewLimit(currentLimit: number, gradient: number, headroo
|
|
|
104
105
|
readonly maxDecreaseRatio?: number;
|
|
105
106
|
}): number;
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Creates the compression middleware with optional configuration.
|
|
110
|
+
*
|
|
111
|
+
* The middleware:
|
|
112
|
+
* 1. Injects Accept-Encoding header on outgoing requests (if missing)
|
|
113
|
+
* 2. Decompresses response bodies based on Content-Encoding header
|
|
114
|
+
* 3. Tracks compression statistics
|
|
115
|
+
*/
|
|
116
|
+
declare function makeCompressionMiddleware(config?: CompressionConfig): CompressionMiddlewareResult;
|
|
117
|
+
declare const makeResponseCompressionMiddleware: typeof makeCompressionMiddleware;
|
|
118
|
+
declare function makeRequestCompressionMiddleware(config?: RequestCompressionConfig): RequestCompressionMiddlewareResult;
|
|
114
119
|
|
|
115
|
-
type
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
type PostJsonInitWithSchema<Validator extends AnyJsonSchemaLike> = AnyInitWithHeaders & {
|
|
141
|
-
schema: Validator;
|
|
142
|
-
schemaName?: string;
|
|
143
|
-
bodySchema?: undefined;
|
|
144
|
-
bodySchemaName?: string;
|
|
145
|
-
};
|
|
146
|
-
type PostJsonInitWithSchemaAndBody<Validator extends AnyJsonSchemaLike, BodyValidator extends AnyJsonSchemaLike> = AnyInitWithHeaders & {
|
|
147
|
-
schema: Validator;
|
|
148
|
-
schemaName?: string;
|
|
149
|
-
bodySchema: BodyValidator;
|
|
150
|
-
bodySchemaName?: string;
|
|
151
|
-
};
|
|
152
|
-
type AnyJsonInit = InitNoMethodBody$1 & {
|
|
153
|
-
schema?: AnyJsonSchemaLike;
|
|
154
|
-
schemaName?: string;
|
|
155
|
-
};
|
|
156
|
-
type HttpMeta = {
|
|
157
|
-
request: HttpRequest;
|
|
158
|
-
urlFinal: string;
|
|
159
|
-
startedAt: number;
|
|
160
|
-
durationMs: number;
|
|
161
|
-
};
|
|
162
|
-
type HttpResponse<A> = {
|
|
163
|
-
status: number;
|
|
164
|
-
statusText: string;
|
|
165
|
-
headers: Record<string, string>;
|
|
166
|
-
body: A;
|
|
167
|
-
};
|
|
168
|
-
type HttpWireWithMeta = {
|
|
169
|
-
wire: HttpWireResponse;
|
|
170
|
-
meta: HttpMeta;
|
|
171
|
-
};
|
|
172
|
-
type HttpResponseWithMeta<A> = {
|
|
173
|
-
wire: HttpWireResponse;
|
|
174
|
-
response: HttpResponse<A>;
|
|
175
|
-
meta: HttpMeta;
|
|
176
|
-
};
|
|
177
|
-
type AnyInitWithHeaders = HttpRequestPolicyInit & {
|
|
178
|
-
headers?: any;
|
|
179
|
-
timeoutMs?: number;
|
|
180
|
-
poolKey?: string;
|
|
181
|
-
} & Record<string, any>;
|
|
182
|
-
type Dx = {
|
|
183
|
-
request: (req: HttpRequest) => AsyncWithPromise<unknown, HttpError, HttpWireResponse>;
|
|
184
|
-
get: (url: string, init?: AnyInitWithHeaders) => AsyncWithPromise<unknown, HttpError, HttpWireResponse>;
|
|
185
|
-
post: (url: string, body?: string, init?: AnyInitWithHeaders) => AsyncWithPromise<unknown, HttpError, HttpWireResponse>;
|
|
186
|
-
getText: (url: string, init?: InitNoMethodBody$1) => AsyncWithPromise<unknown, HttpError, HttpResponse<string>>;
|
|
187
|
-
getJson: {
|
|
188
|
-
<Validator extends AnyJsonSchemaLike>(url: string, init: JsonInitWithSchema<Validator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<InferJsonSchema<Validator>>>;
|
|
189
|
-
<A = unknown>(url: string, init?: JsonInitNoSchema$1): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<A>>;
|
|
190
|
-
};
|
|
191
|
-
postJson: {
|
|
192
|
-
<Validator extends AnyJsonSchemaLike, BodyValidator extends AnyJsonSchemaLike>(url: string, bodyObj: InferJsonSchema<BodyValidator>, init: PostJsonInitWithSchemaAndBody<Validator, BodyValidator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<InferJsonSchema<Validator>>>;
|
|
193
|
-
<BodyValidator extends AnyJsonSchemaLike, A = unknown>(url: string, bodyObj: InferJsonSchema<BodyValidator>, init: PostJsonInitWithBodySchema<BodyValidator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<A>>;
|
|
194
|
-
<Validator extends AnyJsonSchemaLike>(url: string, bodyObj: unknown, init: PostJsonInitWithSchema<Validator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<InferJsonSchema<Validator>>>;
|
|
195
|
-
<A = unknown>(url: string, bodyObj: unknown, init?: PostJsonInitNoSchema$1): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<A>>;
|
|
196
|
-
};
|
|
197
|
-
with: (mw: HttpMiddleware) => Dx;
|
|
198
|
-
withRetry: (p: RetryPolicy) => Dx;
|
|
199
|
-
wire: HttpClient;
|
|
200
|
-
stats: () => ReturnType<HttpClient["stats"]>;
|
|
201
|
-
};
|
|
202
|
-
declare function httpClient(cfg?: MakeHttpConfig): Dx;
|
|
203
|
-
declare function httpClientWithMeta(cfg?: MakeHttpConfig): {
|
|
204
|
-
request: (req: HttpRequest) => AsyncWithPromise<unknown, HttpError, {
|
|
205
|
-
wire: HttpWireResponse<unknown>;
|
|
206
|
-
meta: HttpMeta;
|
|
207
|
-
}>;
|
|
208
|
-
get: (url: string, init?: InitNoMethodBody$1) => AsyncWithPromise<unknown, HttpError, {
|
|
209
|
-
wire: HttpWireResponse<unknown>;
|
|
210
|
-
meta: HttpMeta;
|
|
211
|
-
}>;
|
|
212
|
-
getText: (url: string, init?: InitNoMethodBody$1) => AsyncWithPromise<unknown, HttpError, {
|
|
213
|
-
wire: HttpWireResponse<unknown>;
|
|
214
|
-
response: {
|
|
215
|
-
status: number;
|
|
216
|
-
statusText: string;
|
|
217
|
-
headers: Record<string, string>;
|
|
218
|
-
body: string;
|
|
219
|
-
};
|
|
220
|
-
meta: HttpMeta;
|
|
221
|
-
}>;
|
|
222
|
-
getJson: <A>(url: string, init?: AnyJsonInit) => AsyncWithPromise<unknown, HttpError | ValidationError, {
|
|
223
|
-
wire: HttpWireResponse<unknown>;
|
|
224
|
-
response: HttpResponse<A>;
|
|
225
|
-
meta: HttpMeta;
|
|
226
|
-
}>;
|
|
227
|
-
post: (url: string, body?: string, init?: InitNoMethodBody$1) => AsyncWithPromise<unknown, HttpError, {
|
|
228
|
-
wire: HttpWireResponse<unknown>;
|
|
229
|
-
meta: HttpMeta;
|
|
230
|
-
}>;
|
|
231
|
-
postJson: <A>(url: string, bodyObj: unknown, init?: AnyInitWithHeaders & {
|
|
232
|
-
schema?: AnyJsonSchemaLike;
|
|
233
|
-
schemaName?: string;
|
|
234
|
-
bodySchema?: AnyJsonSchemaLike;
|
|
235
|
-
bodySchemaName?: string;
|
|
236
|
-
}) => AsyncWithPromise<unknown, HttpError | ValidationError, {
|
|
237
|
-
wire: HttpWireResponse<unknown>;
|
|
238
|
-
response: HttpResponse<A>;
|
|
239
|
-
meta: HttpMeta;
|
|
240
|
-
}>;
|
|
241
|
-
};
|
|
242
|
-
declare function httpClientStream(cfg?: MakeHttpConfig): {
|
|
243
|
-
request: (req: HttpRequest) => AsyncWithPromise<unknown, HttpError, HttpWireResponseStream<unknown>>;
|
|
244
|
-
getStream: (url: string, init?: InitNoMethodBody$1) => AsyncWithPromise<unknown, HttpError, HttpWireResponseStream<unknown>>;
|
|
245
|
-
get: (url: string, init?: InitNoMethodBody$1) => AsyncWithPromise<unknown, HttpError, HttpWireResponseStream<unknown>>;
|
|
246
|
-
with: (mw: (n: HttpClientStream) => HttpClientStream) => /*elided*/ any;
|
|
247
|
-
withRetry: (p: RetryPolicy) => /*elided*/ any;
|
|
248
|
-
wire: HttpClientStream;
|
|
249
|
-
stats: () => HttpClientStats;
|
|
250
|
-
};
|
|
120
|
+
type NodeHttpTransportConfig = {
|
|
121
|
+
readonly keepAlive?: boolean;
|
|
122
|
+
readonly maxSockets?: number;
|
|
123
|
+
readonly maxFreeSockets?: number;
|
|
124
|
+
readonly httpAgent?: Agent;
|
|
125
|
+
readonly httpsAgent?: Agent$1;
|
|
126
|
+
readonly socketTimeoutMs?: number;
|
|
127
|
+
};
|
|
128
|
+
type NodeHttpTransport = HttpTransport & {
|
|
129
|
+
readonly destroy: () => void;
|
|
130
|
+
};
|
|
131
|
+
type NodeHttpProxyClientConfig = Omit<DefaultHttpClientConfig, "preset" | "transport"> & {
|
|
132
|
+
/**
|
|
133
|
+
* Defaults to the explicit hot proxy preset. Use `proxy` only when you need
|
|
134
|
+
* the shorter compatibility name in stats/config snapshots.
|
|
135
|
+
*/
|
|
136
|
+
readonly preset?: "highThroughputProxy" | "proxy";
|
|
137
|
+
/** Existing Node transport to use. When omitted, Brass creates owned keep-alive agents. */
|
|
138
|
+
readonly transport?: NodeHttpTransport;
|
|
139
|
+
/** Options for the owned Node transport when `transport` is omitted. */
|
|
140
|
+
readonly nodeTransport?: NodeHttpTransportConfig;
|
|
141
|
+
};
|
|
142
|
+
declare function makeNodeHttpTransport(config?: NodeHttpTransportConfig): NodeHttpTransport;
|
|
143
|
+
declare function makeNodeHttpProxyClient(config?: NodeHttpProxyClientConfig): DefaultHttpClient;
|
|
251
144
|
|
|
252
145
|
type HttpCircuitBreakerConfig = CircuitBreakerConfig & {
|
|
253
146
|
/** Key resolver for per-origin circuit breakers. Default: per-origin. */
|
|
@@ -268,459 +161,6 @@ declare function withCircuitBreaker(config?: HttpCircuitBreakerConfig): HttpMidd
|
|
|
268
161
|
*/
|
|
269
162
|
declare function withTracing(tracer: Tracer): HttpMiddleware;
|
|
270
163
|
|
|
271
|
-
/**
|
|
272
|
-
* Developer-provided function that defines how to combine multiple requests
|
|
273
|
-
* into one and split the response back.
|
|
274
|
-
*
|
|
275
|
-
* @typeParam K - The item type extracted from individual requests, ensuring
|
|
276
|
-
* type consistency between coalesce and split.
|
|
277
|
-
*/
|
|
278
|
-
type BatchFunction<K> = {
|
|
279
|
-
/**
|
|
280
|
-
* Combines multiple HttpRequest objects into a single batched HttpRequest.
|
|
281
|
-
* The items array corresponds 1:1 with the requests array.
|
|
282
|
-
*/
|
|
283
|
-
coalesce: (requests: readonly HttpRequest[]) => HttpRequest;
|
|
284
|
-
/**
|
|
285
|
-
* Splits the batched response back into individual responses.
|
|
286
|
-
* Must return an array of the same length as the original requests array.
|
|
287
|
-
*/
|
|
288
|
-
split: (response: HttpWireResponse, requests: readonly HttpRequest[]) => HttpWireResponse[];
|
|
289
|
-
};
|
|
290
|
-
/**
|
|
291
|
-
* Configuration for the Batch_Middleware.
|
|
292
|
-
*
|
|
293
|
-
* @typeParam K - The item type linking coalesce and split operations.
|
|
294
|
-
*/
|
|
295
|
-
type BatchConfig<K = unknown> = {
|
|
296
|
-
/** The batch function defining coalesce/split logic. Required. */
|
|
297
|
-
batch: BatchFunction<K>;
|
|
298
|
-
/**
|
|
299
|
-
* Time window in milliseconds to collect requests before dispatching.
|
|
300
|
-
* Valid range: [1, 5000]. Required.
|
|
301
|
-
*/
|
|
302
|
-
windowMs: number;
|
|
303
|
-
/**
|
|
304
|
-
* Maximum number of requests in a single batch.
|
|
305
|
-
* When reached, the batch dispatches immediately.
|
|
306
|
-
* Valid range: [2, 10000]. Required.
|
|
307
|
-
*/
|
|
308
|
-
maxBatchSize: number;
|
|
309
|
-
/**
|
|
310
|
-
* Computes the Batch_Key from a request.
|
|
311
|
-
* Requests with the same key are batched together.
|
|
312
|
-
* Return empty string to bypass batching for a request.
|
|
313
|
-
* Throwing bypasses batching for that request.
|
|
314
|
-
*/
|
|
315
|
-
batchKey: (req: HttpRequest) => string;
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* Optional observer callback for batch lifecycle events.
|
|
319
|
-
*/
|
|
320
|
-
type BatchEventCallback = (event: {
|
|
321
|
-
type: "batch-hit" | "batch-dispatch";
|
|
322
|
-
batchKey: string;
|
|
323
|
-
batchSize?: number;
|
|
324
|
-
}) => void;
|
|
325
|
-
/**
|
|
326
|
-
* Creates a Batch_Middleware that collects requests by Batch_Key during
|
|
327
|
-
* a time window and dispatches them as a single batched request.
|
|
328
|
-
*
|
|
329
|
-
* @typeParam K - Inferred from the provided BatchFunction.
|
|
330
|
-
* @param config - Batch configuration.
|
|
331
|
-
* @param onEvent - Optional lifecycle event observer.
|
|
332
|
-
* @returns An HttpMiddleware conforming to (next: HttpClientFn) => HttpClientFn.
|
|
333
|
-
*/
|
|
334
|
-
declare function withBatch<K>(config: BatchConfig<K>, onEvent?: BatchEventCallback): HttpMiddleware;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Status of a pre-warm probe result.
|
|
338
|
-
*/
|
|
339
|
-
type PrewarmResultStatus = "warmed" | "already-warm" | "failed" | "cancelled";
|
|
340
|
-
/**
|
|
341
|
-
* Result of a single pre-warm probe operation.
|
|
342
|
-
*/
|
|
343
|
-
type PrewarmResult = {
|
|
344
|
-
/** The origin that was probed. */
|
|
345
|
-
origin: string;
|
|
346
|
-
/** Outcome of the probe operation. */
|
|
347
|
-
status: PrewarmResultStatus;
|
|
348
|
-
/** Duration of the probe in milliseconds (0 for "already-warm"). */
|
|
349
|
-
durationMs: number;
|
|
350
|
-
/** Error information if status is "failed". */
|
|
351
|
-
error?: string;
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* Event types emitted by the PrewarmManager during connection state changes.
|
|
355
|
-
*/
|
|
356
|
-
type PrewarmEventType = "connection-warmed" | "connection-expired" | "connection-failed" | "connection-cancelled";
|
|
357
|
-
/**
|
|
358
|
-
* An event emitted by the PrewarmManager to notify observers of connection state changes.
|
|
359
|
-
*/
|
|
360
|
-
type PrewarmEvent = {
|
|
361
|
-
/** The type of prewarm event. */
|
|
362
|
-
type: PrewarmEventType;
|
|
363
|
-
/** The origin associated with the event. */
|
|
364
|
-
origin: string;
|
|
365
|
-
/** Timestamp (ms) when the event occurred. */
|
|
366
|
-
timestamp: number;
|
|
367
|
-
/** Duration of the probe in milliseconds, if applicable. */
|
|
368
|
-
durationMs?: number;
|
|
369
|
-
/** Error information, if applicable. */
|
|
370
|
-
error?: string;
|
|
371
|
-
};
|
|
372
|
-
/**
|
|
373
|
-
* Per-origin connection state in the state machine.
|
|
374
|
-
*/
|
|
375
|
-
type PrewarmOriginStatus = "idle" | "probing" | "warm" | "expired";
|
|
376
|
-
/**
|
|
377
|
-
* State information for a single managed origin.
|
|
378
|
-
*/
|
|
379
|
-
type PrewarmOriginState = {
|
|
380
|
-
/** The origin string. */
|
|
381
|
-
origin: string;
|
|
382
|
-
/** Current state of the origin. */
|
|
383
|
-
status: PrewarmOriginStatus;
|
|
384
|
-
/** Timestamp of the last successful probe, if any. */
|
|
385
|
-
lastProbeAt?: number;
|
|
386
|
-
/** Timestamp until which the connection is considered warm. */
|
|
387
|
-
warmUntil?: number;
|
|
388
|
-
};
|
|
389
|
-
/**
|
|
390
|
-
* Snapshot of all managed origins and their current states.
|
|
391
|
-
*/
|
|
392
|
-
type PrewarmStatusSnapshot = {
|
|
393
|
-
/** State of each managed origin. */
|
|
394
|
-
origins: PrewarmOriginState[];
|
|
395
|
-
};
|
|
396
|
-
/**
|
|
397
|
-
* Configuration for creating a PrewarmManager.
|
|
398
|
-
*/
|
|
399
|
-
type PrewarmConfig = {
|
|
400
|
-
/** Origins to pre-warm. Each must be a valid URL origin (scheme + host + optional port). */
|
|
401
|
-
origins: string[];
|
|
402
|
-
/** Keep-alive duration in ms. Default: 55000. */
|
|
403
|
-
keepAliveDurationMs?: number;
|
|
404
|
-
/** Max concurrent in-flight probes. Default: 4. */
|
|
405
|
-
budget?: number;
|
|
406
|
-
/** Probe timeout in ms. Default: 5000. */
|
|
407
|
-
probeTimeoutMs?: number;
|
|
408
|
-
/** Auto-refresh expired connections. Default: false. */
|
|
409
|
-
autoRefresh?: boolean;
|
|
410
|
-
/** Route probes through the Wire_Client pool. Default: false. */
|
|
411
|
-
useClientPool?: boolean;
|
|
412
|
-
/** Optional Wire_Client to use when useClientPool is true. */
|
|
413
|
-
client?: HttpClientFn;
|
|
414
|
-
/** Event observer callback. */
|
|
415
|
-
onEvent?: (event: PrewarmEvent) => void;
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Configuration for the prewarm layer within the lifecycle client.
|
|
420
|
-
*
|
|
421
|
-
* When provided to `makeLifecycleClient`, the lifecycle client creates and manages
|
|
422
|
-
* a PrewarmManager internally, triggering pre-warming based on the `afterResponse` hook.
|
|
423
|
-
*/
|
|
424
|
-
type PrewarmLifecycleConfig = {
|
|
425
|
-
/** Origins to pre-warm at client creation. */
|
|
426
|
-
origins?: string[];
|
|
427
|
-
/** Hook called after each successful response to determine origins to pre-warm. */
|
|
428
|
-
afterResponse?: (response: HttpWireResponse, request: HttpRequest) => string[];
|
|
429
|
-
/** Keep-alive duration in ms. Default: 55000. */
|
|
430
|
-
keepAliveDurationMs?: number;
|
|
431
|
-
/** Max concurrent in-flight probes. Default: 4. */
|
|
432
|
-
budget?: number;
|
|
433
|
-
/** Probe timeout in ms. Default: 5000. */
|
|
434
|
-
probeTimeoutMs?: number;
|
|
435
|
-
/** Auto-refresh expired connections. Default: false. */
|
|
436
|
-
autoRefresh?: boolean;
|
|
437
|
-
/** Route probes through the Wire_Client pool. Default: false. */
|
|
438
|
-
useClientPool?: boolean;
|
|
439
|
-
/** Event observer for prewarm events. */
|
|
440
|
-
onEvent?: (event: PrewarmEvent) => void;
|
|
441
|
-
};
|
|
442
|
-
/**
|
|
443
|
-
* Configuration for the deduplication layer.
|
|
444
|
-
*
|
|
445
|
-
* When enabled, the dedup layer collapses concurrent identical requests into a single
|
|
446
|
-
* in-flight Async_Effect, sharing the response across all callers with the same Cache_Key.
|
|
447
|
-
*
|
|
448
|
-
* @property {function} [dedupKey] - Custom key function that computes a dedup key from an HttpRequest.
|
|
449
|
-
* When provided, overrides the default Cache_Key computation. Default: undefined (uses default key derivation).
|
|
450
|
-
*/
|
|
451
|
-
type DedupConfig$1 = {
|
|
452
|
-
/** Custom key function. When provided, overrides default Cache_Key computation. */
|
|
453
|
-
dedupKey?: (req: HttpRequest) => string;
|
|
454
|
-
/** Internal lifecycle observer. Public callers should prefer LifecycleClientConfig.onEvent. */
|
|
455
|
-
onEvent?: (event: {
|
|
456
|
-
type: "dedup-hit" | "dedup-miss" | "dedup-active";
|
|
457
|
-
cacheKey?: string;
|
|
458
|
-
active?: number;
|
|
459
|
-
}) => void;
|
|
460
|
-
};
|
|
461
|
-
/**
|
|
462
|
-
* Configuration for the response cache layer.
|
|
463
|
-
*
|
|
464
|
-
* Controls how responses are stored and retrieved from the in-memory LRU cache.
|
|
465
|
-
* Each cached entry is keyed by its deterministic Cache_Key.
|
|
466
|
-
*
|
|
467
|
-
* @property {number} [ttlSeconds] - Time-to-live in seconds for cached entries. Default: 60. Valid range: [1, 86400].
|
|
468
|
-
* @property {number} [maxEntries] - Maximum number of cached entries before LRU eviction. Default: 1024. Valid range: >= 1.
|
|
469
|
-
* @property {boolean} [staleWhileRevalidate] - When true, serves stale cache entries while revalidating in the background. Default: false.
|
|
470
|
-
* @property {function} [cachePolicy] - Custom cache policy function that determines cacheability and optional TTL override for a given request/response pair. Default: undefined (uses built-in policy).
|
|
471
|
-
* @property {string[]} [cacheRelevantHeaders] - Additional HTTP headers to include in Cache_Key computation beyond the defaults. Default: undefined (uses DEFAULT_CACHE_RELEVANT_HEADERS).
|
|
472
|
-
*/
|
|
473
|
-
type CacheConfig$1 = {
|
|
474
|
-
/** Time-to-live in seconds. Default: 60. Range: [1, 86400]. */
|
|
475
|
-
ttlSeconds?: number;
|
|
476
|
-
/** Maximum number of cached entries. Default: 1024. Minimum: 1. */
|
|
477
|
-
maxEntries?: number;
|
|
478
|
-
/** Enable stale-while-revalidate. Default: false. */
|
|
479
|
-
staleWhileRevalidate?: boolean;
|
|
480
|
-
/** Custom cache policy function. */
|
|
481
|
-
cachePolicy?: (req: HttpRequest, res: HttpWireResponse) => CachePolicyResult$1;
|
|
482
|
-
/** Additional headers to include in Cache_Key computation. */
|
|
483
|
-
cacheRelevantHeaders?: string[];
|
|
484
|
-
/** Cache-specific observer for stale revalidation failures. */
|
|
485
|
-
onEvent?: (event: {
|
|
486
|
-
type: string;
|
|
487
|
-
cacheKey?: string;
|
|
488
|
-
error?: any;
|
|
489
|
-
}) => void;
|
|
490
|
-
/** Internal lifecycle observer. Public callers should prefer LifecycleClientConfig.onEvent. */
|
|
491
|
-
onLifecycleEvent?: (event: {
|
|
492
|
-
type: "cache-hit" | "cache-miss" | "cache-eviction";
|
|
493
|
-
cacheKey?: string;
|
|
494
|
-
count?: number;
|
|
495
|
-
}) => void;
|
|
496
|
-
};
|
|
497
|
-
/**
|
|
498
|
-
* Result of a custom cache policy evaluation.
|
|
499
|
-
*
|
|
500
|
-
* Returned by the `cachePolicy` function in {@link CacheConfig} to control
|
|
501
|
-
* whether a response should be stored in the cache and for how long.
|
|
502
|
-
*
|
|
503
|
-
* @property {boolean} cacheable - Whether the response should be cached. Required.
|
|
504
|
-
* @property {number} [ttlSeconds] - Optional TTL override in seconds. When provided, takes precedence over the global CacheConfig ttlSeconds. Valid range: [1, 86400].
|
|
505
|
-
*/
|
|
506
|
-
type CachePolicyResult$1 = {
|
|
507
|
-
/** Whether the response should be cached. */
|
|
508
|
-
cacheable: boolean;
|
|
509
|
-
/** Optional TTL override in seconds. */
|
|
510
|
-
ttlSeconds?: number;
|
|
511
|
-
};
|
|
512
|
-
/**
|
|
513
|
-
* Configuration for the priority scheduler layer.
|
|
514
|
-
*
|
|
515
|
-
* The priority scheduler orders outgoing requests by priority level and limits
|
|
516
|
-
* concurrency to prevent overwhelming the downstream Wire_Client.
|
|
517
|
-
*
|
|
518
|
-
* @property {number} [concurrency] - Maximum concurrent requests dispatched by the priority scheduler. Default: 32. Valid range: >= 1.
|
|
519
|
-
* @property {number} [queueTimeoutMs] - Queue timeout in milliseconds for priority-queued requests. When a request waits longer than this value, it is rejected. Default: undefined (no timeout).
|
|
520
|
-
*/
|
|
521
|
-
type PriorityConfig$1 = {
|
|
522
|
-
/** Maximum concurrent requests dispatched by the priority scheduler. Default: 32. Valid range: >= 1. */
|
|
523
|
-
concurrency?: number;
|
|
524
|
-
/** Queue timeout in ms for priority-queued requests. Default: no timeout. */
|
|
525
|
-
queueTimeoutMs?: number;
|
|
526
|
-
/** Internal lifecycle observer. Public callers should prefer LifecycleClientConfig.onEvent. */
|
|
527
|
-
onEvent?: (event: {
|
|
528
|
-
type: "queue-enqueue" | "queue-dispatch";
|
|
529
|
-
priority: number;
|
|
530
|
-
}) => void;
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* Configuration for creating a lifecycle client.
|
|
534
|
-
*
|
|
535
|
-
* Extends MakeHttpConfig with optional lifecycle layer configurations.
|
|
536
|
-
* Each layer (dedup, cache, priority) can be configured with an options object
|
|
537
|
-
* or explicitly disabled by setting it to `false`. When omitted, the layer is disabled
|
|
538
|
-
* (zero-cost when disabled).
|
|
539
|
-
*
|
|
540
|
-
* @property {DedupConfig | false} [dedup] - Dedup layer configuration. Set to an object to enable with options, or `false` to explicitly disable. Default: undefined (disabled).
|
|
541
|
-
* @property {CacheConfig | false} [cache] - Cache layer configuration. Set to an object to enable with options, or `false` to explicitly disable. Default: undefined (disabled).
|
|
542
|
-
* @property {PriorityConfig | false} [priority] - Priority scheduler configuration. Set to an object to enable with options, or `false` to explicitly disable. Default: undefined (disabled).
|
|
543
|
-
* @property {function} [onEvent] - Optional event observer callback invoked for each {@link LifecycleEvent} during request processing. Default: undefined.
|
|
544
|
-
*/
|
|
545
|
-
type LifecycleClientConfig = MakeHttpConfig & {
|
|
546
|
-
/** Dedup layer config. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
547
|
-
dedup?: DedupConfig$1 | false;
|
|
548
|
-
/** Batch layer config. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
549
|
-
batch?: BatchConfig | false;
|
|
550
|
-
/** Cache layer config. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
551
|
-
cache?: CacheConfig$1 | false;
|
|
552
|
-
/** Priority scheduler config. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
553
|
-
priority?: PriorityConfig$1 | false;
|
|
554
|
-
/** Retry policy. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
555
|
-
retry?: RetryPolicy | false;
|
|
556
|
-
/** Prewarm layer config. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
557
|
-
prewarm?: PrewarmLifecycleConfig | false;
|
|
558
|
-
/** Adaptive concurrency limiter config. Set to `false` to explicitly disable. Default: undefined (disabled). */
|
|
559
|
-
adaptiveLimiter?: AdaptiveLimiterConfig | false;
|
|
560
|
-
/** Optional event observer for lifecycle events. */
|
|
561
|
-
onEvent?: (event: LifecycleEvent) => void;
|
|
562
|
-
};
|
|
563
|
-
/**
|
|
564
|
-
* The lifecycle client interface.
|
|
565
|
-
*
|
|
566
|
-
* A callable HTTP client function (Wire_Client wrapper) with additional lifecycle
|
|
567
|
-
* management methods. Supports middleware composition via `.with()`, statistics
|
|
568
|
-
* via `.stats()`, and bulk cancellation via `.cancelAll()`.
|
|
569
|
-
*
|
|
570
|
-
* @property {function} with - Apply middleware, returning a new LifecycleClient with the middleware applied.
|
|
571
|
-
* @property {function} stats - Return a frozen snapshot of {@link LifecycleStats}.
|
|
572
|
-
* @property {function} cancelAll - Cancel all in-flight and queued requests, returning an Async_Effect that resolves when cancellation is complete.
|
|
573
|
-
* @property {object} cache - Cache management methods for manual invalidation.
|
|
574
|
-
* @property {function} cache.invalidate - Invalidate a specific cache entry by its Cache_Key.
|
|
575
|
-
* @property {function} cache.clear - Clear all cache entries.
|
|
576
|
-
*/
|
|
577
|
-
type LifecycleClient = HttpClientFn & {
|
|
578
|
-
/** Apply middleware, returning a new LifecycleClient with the middleware applied. */
|
|
579
|
-
with: (mw: HttpMiddleware) => LifecycleClient;
|
|
580
|
-
/** Return a frozen snapshot of lifecycle statistics. */
|
|
581
|
-
stats: () => LifecycleStats;
|
|
582
|
-
/** Cancel all in-flight and queued requests. Returns an Async_Effect that resolves when complete. */
|
|
583
|
-
cancelAll: () => Async<unknown, never, void>;
|
|
584
|
-
/** Cancel active work and release owned resources such as adaptive limiter timers. */
|
|
585
|
-
shutdown: () => Async<unknown, never, void>;
|
|
586
|
-
/** Adaptive limiter owned by the underlying wire client, when enabled. */
|
|
587
|
-
adaptiveLimiter?: AdaptiveLimiter;
|
|
588
|
-
/** Cache management methods. */
|
|
589
|
-
cache: {
|
|
590
|
-
/** Invalidate a specific cache entry by Cache_Key. */
|
|
591
|
-
invalidate: (key: string) => void;
|
|
592
|
-
/** Clear all cache entries. */
|
|
593
|
-
clear: () => void;
|
|
594
|
-
};
|
|
595
|
-
};
|
|
596
|
-
/**
|
|
597
|
-
* Lifecycle event types emitted during request processing.
|
|
598
|
-
*
|
|
599
|
-
* Each value represents a distinct point in the lifecycle pipeline:
|
|
600
|
-
* - `"request-start"` — Emitted when a request enters the lifecycle pipeline.
|
|
601
|
-
* - `"request-end"` — Emitted when a request completes (success or failure).
|
|
602
|
-
* - `"cache-hit"` — Emitted when a response is served from the cache.
|
|
603
|
-
* - `"cache-miss"` — Emitted when a request misses the cache and proceeds to the Wire_Client.
|
|
604
|
-
* - `"dedup-hit"` — Emitted when a request is collapsed into an existing in-flight Async_Effect.
|
|
605
|
-
* - `"dedup-miss"` — Emitted when a request initiates a new in-flight Async_Effect (no existing match).
|
|
606
|
-
* - `"queue-enqueue"` — Emitted when a request is enqueued in the priority scheduler.
|
|
607
|
-
* - `"queue-dispatch"` — Emitted when a queued request is dispatched to the Wire_Client.
|
|
608
|
-
* - `"retry"` — Emitted when the retry middleware schedules another attempt.
|
|
609
|
-
*/
|
|
610
|
-
type LifecycleEventType = "request-start" | "request-end" | "cache-hit" | "cache-miss" | "dedup-hit" | "dedup-miss" | "queue-enqueue" | "queue-dispatch" | "retry" | "batch-hit" | "batch-dispatch" | "limit-change";
|
|
611
|
-
/**
|
|
612
|
-
* A lifecycle event emitted to the onEvent observer.
|
|
613
|
-
*
|
|
614
|
-
* Provides observability into the lifecycle pipeline by reporting events
|
|
615
|
-
* as they occur during request processing.
|
|
616
|
-
*
|
|
617
|
-
* @property {LifecycleEventType} type - The type of lifecycle event. Required.
|
|
618
|
-
* @property {number} timestamp - Timestamp in milliseconds (from `Date.now()`) when the event occurred. Required.
|
|
619
|
-
* @property {string} [cacheKey] - The Cache_Key associated with the event, if applicable (present for cache and dedup events).
|
|
620
|
-
* @property {number} [priority] - Priority level associated with the event, if applicable (present for queue events). Valid range: 0-9.
|
|
621
|
-
* @property {number} [attempt] - Zero-based retry attempt, if applicable.
|
|
622
|
-
* @property {number} [delayMs] - Retry delay in milliseconds, if applicable.
|
|
623
|
-
* @property {number} [status] - HTTP status that triggered retry, if applicable.
|
|
624
|
-
* @property {string} [errorTag] - HttpError tag that triggered retry, if applicable.
|
|
625
|
-
*/
|
|
626
|
-
type LifecycleEvent = {
|
|
627
|
-
/** The type of lifecycle event. */
|
|
628
|
-
type: LifecycleEventType;
|
|
629
|
-
/** Timestamp (ms) when the event occurred. */
|
|
630
|
-
timestamp: number;
|
|
631
|
-
/** Cache_Key associated with the event, if applicable. */
|
|
632
|
-
cacheKey?: string;
|
|
633
|
-
/** Priority level associated with the event, if applicable. Valid range: 0-9. */
|
|
634
|
-
priority?: number;
|
|
635
|
-
/** Batch_Key associated with the event, if applicable. Present for batch events. */
|
|
636
|
-
batchKey?: string;
|
|
637
|
-
/** Number of requests in the batch, if applicable. Present for batch-dispatch events. */
|
|
638
|
-
batchSize?: number;
|
|
639
|
-
/** Zero-based retry attempt, if applicable. */
|
|
640
|
-
attempt?: number;
|
|
641
|
-
/** Retry delay in milliseconds, if applicable. */
|
|
642
|
-
delayMs?: number;
|
|
643
|
-
/** HTTP status that triggered retry, if applicable. */
|
|
644
|
-
status?: number;
|
|
645
|
-
/** HttpError tag that triggered retry, if applicable. */
|
|
646
|
-
errorTag?: string;
|
|
647
|
-
/** Previous concurrency limit, present for limit-change events. */
|
|
648
|
-
previousLimit?: number;
|
|
649
|
-
/** New concurrency limit, present for limit-change events. */
|
|
650
|
-
newLimit?: number;
|
|
651
|
-
/** Gradient value, present for limit-change events. */
|
|
652
|
-
gradient?: number;
|
|
653
|
-
/** Smoothed latency value, present for limit-change events. */
|
|
654
|
-
smoothedLatency?: number;
|
|
655
|
-
};
|
|
656
|
-
/**
|
|
657
|
-
* Lifecycle statistics snapshot.
|
|
658
|
-
*
|
|
659
|
-
* All counters start at zero and increase monotonically. Returned as a frozen
|
|
660
|
-
* object by {@link LifecycleClient.stats}.
|
|
661
|
-
*
|
|
662
|
-
* @property {number} cacheHits - Number of cache hits (responses served from cache). Default: 0.
|
|
663
|
-
* @property {number} cacheMisses - Number of cache misses (requests forwarded to Wire_Client). Default: 0.
|
|
664
|
-
* @property {number} cacheEvictions - Number of cache evictions triggered by LRU policy. Default: 0.
|
|
665
|
-
* @property {number} dedupHits - Number of dedup hits (requests collapsed into an existing in-flight Async_Effect). Default: 0.
|
|
666
|
-
* @property {number} dedupActive - Number of currently active dedup groups (in-flight unique Cache_Keys). Default: 0.
|
|
667
|
-
* @property {number} queueDepth - Current depth of the priority queue (requests waiting to be dispatched). Default: 0.
|
|
668
|
-
* @property {number} requestsStarted - Total number of requests that entered the lifecycle pipeline. Default: 0.
|
|
669
|
-
* @property {number} requestsCompleted - Total number of requests that completed successfully. Default: 0.
|
|
670
|
-
* @property {number} requestsFailed - Total number of requests that failed with an error. Default: 0.
|
|
671
|
-
* @property {number} retries - Total number of retry attempts scheduled. Default: 0.
|
|
672
|
-
* @property {HttpClientStats} wire - Underlying Wire_Client statistics snapshot.
|
|
673
|
-
*/
|
|
674
|
-
type LifecycleStats = {
|
|
675
|
-
/** Number of cache hits. */
|
|
676
|
-
cacheHits: number;
|
|
677
|
-
/** Number of cache misses. */
|
|
678
|
-
cacheMisses: number;
|
|
679
|
-
/** Number of cache evictions (LRU). */
|
|
680
|
-
cacheEvictions: number;
|
|
681
|
-
/** Number of dedup hits (requests collapsed into existing in-flight Async_Effect). */
|
|
682
|
-
dedupHits: number;
|
|
683
|
-
/** Number of currently active dedup groups. */
|
|
684
|
-
dedupActive: number;
|
|
685
|
-
/** Current depth of the priority queue. */
|
|
686
|
-
queueDepth: number;
|
|
687
|
-
/** Total number of requests started. */
|
|
688
|
-
requestsStarted: number;
|
|
689
|
-
/** Total number of requests completed successfully. */
|
|
690
|
-
requestsCompleted: number;
|
|
691
|
-
/** Total number of requests that failed. */
|
|
692
|
-
requestsFailed: number;
|
|
693
|
-
/** Total number of retry attempts scheduled. */
|
|
694
|
-
retries: number;
|
|
695
|
-
/** Total number of batch dispatches. */
|
|
696
|
-
batchDispatches: number;
|
|
697
|
-
/** Total number of individual requests that were coalesced into batches. */
|
|
698
|
-
batchedRequests: number;
|
|
699
|
-
/** Underlying Wire_Client stats. */
|
|
700
|
-
wire: HttpClientStats;
|
|
701
|
-
};
|
|
702
|
-
/**
|
|
703
|
-
* Per-request lifecycle options that can be passed alongside a request.
|
|
704
|
-
*
|
|
705
|
-
* Allows fine-grained control over lifecycle behavior on a per-request basis,
|
|
706
|
-
* overriding the client-level configuration for individual requests.
|
|
707
|
-
*
|
|
708
|
-
* @property {number} [priority] - Priority level for this request. Valid range: 0-9 (0 = highest priority). Default: 5.
|
|
709
|
-
* @property {string} [dedupKey] - Custom dedup key override for this request. When provided, overrides the computed Cache_Key for dedup purposes. Default: undefined.
|
|
710
|
-
* @property {boolean} [noCache] - When true, bypasses the cache layer for this request (neither reads from nor writes to cache). Default: false.
|
|
711
|
-
* @property {boolean} [noDedup] - When true, bypasses the dedup layer for this request (always creates a new in-flight Async_Effect). Default: false.
|
|
712
|
-
*/
|
|
713
|
-
type LifecycleRequestOptions = {
|
|
714
|
-
/** Priority level 0-9 (0 = highest). Default: 5. Valid range: 0-9. */
|
|
715
|
-
priority?: number;
|
|
716
|
-
/** Custom dedup key override for this request. */
|
|
717
|
-
dedupKey?: string;
|
|
718
|
-
/** Skip cache for this request. Default: false. */
|
|
719
|
-
noCache?: boolean;
|
|
720
|
-
/** Skip dedup for this request. Default: false. */
|
|
721
|
-
noDedup?: boolean;
|
|
722
|
-
};
|
|
723
|
-
|
|
724
164
|
/**
|
|
725
165
|
* Creates a lifecycle-aware HTTP client that composes deduplication, caching,
|
|
726
166
|
* and priority scheduling layers on top of the Wire_Client.
|
|
@@ -1735,106 +1175,6 @@ declare function withPriority(config?: PriorityConfig): HttpMiddleware & {
|
|
|
1735
1175
|
queueDepth: () => number;
|
|
1736
1176
|
};
|
|
1737
1177
|
|
|
1738
|
-
/**
|
|
1739
|
-
* Supported content encoding algorithms.
|
|
1740
|
-
*/
|
|
1741
|
-
type SupportedEncoding = "gzip" | "br" | "deflate";
|
|
1742
|
-
/**
|
|
1743
|
-
* All supported encodings in default preference order (Brotli first).
|
|
1744
|
-
*/
|
|
1745
|
-
declare const SUPPORTED_ENCODINGS: readonly SupportedEncoding[];
|
|
1746
|
-
/**
|
|
1747
|
-
* Configuration for the compression middleware.
|
|
1748
|
-
*/
|
|
1749
|
-
type CompressionConfig = {
|
|
1750
|
-
/**
|
|
1751
|
-
* Enabled encodings in preference order.
|
|
1752
|
-
* Default: ["br", "gzip", "deflate"]
|
|
1753
|
-
*/
|
|
1754
|
-
encodings?: SupportedEncoding[];
|
|
1755
|
-
};
|
|
1756
|
-
type RequestCompressionConfig = {
|
|
1757
|
-
/**
|
|
1758
|
-
* Encoding to apply to outbound request bodies.
|
|
1759
|
-
* Default: "gzip".
|
|
1760
|
-
*/
|
|
1761
|
-
encoding?: SupportedEncoding;
|
|
1762
|
-
/**
|
|
1763
|
-
* Minimum uncompressed body size in bytes before compression is attempted.
|
|
1764
|
-
* Default: 1024.
|
|
1765
|
-
*/
|
|
1766
|
-
minBytes?: number;
|
|
1767
|
-
/**
|
|
1768
|
-
* HTTP methods eligible for request compression.
|
|
1769
|
-
* Default: ["POST", "PUT", "PATCH"].
|
|
1770
|
-
*/
|
|
1771
|
-
methods?: readonly string[];
|
|
1772
|
-
};
|
|
1773
|
-
/**
|
|
1774
|
-
* Frozen snapshot of compression statistics.
|
|
1775
|
-
*/
|
|
1776
|
-
type CompressionStats = {
|
|
1777
|
-
/** Responses decompressed per encoding type */
|
|
1778
|
-
readonly decompressed: Readonly<Record<SupportedEncoding, number>>;
|
|
1779
|
-
/** Total compressed bytes received */
|
|
1780
|
-
readonly compressedBytes: number;
|
|
1781
|
-
/** Total decompressed bytes produced */
|
|
1782
|
-
readonly decompressedBytes: number;
|
|
1783
|
-
/** Responses that bypassed decompression */
|
|
1784
|
-
readonly passthroughCount: number;
|
|
1785
|
-
/** Decompression errors encountered */
|
|
1786
|
-
readonly errorCount: number;
|
|
1787
|
-
/** Unsupported encoding warnings */
|
|
1788
|
-
readonly unsupportedEncodingCount: number;
|
|
1789
|
-
};
|
|
1790
|
-
type RequestCompressionStats = {
|
|
1791
|
-
readonly compressedCount: number;
|
|
1792
|
-
readonly skippedCount: number;
|
|
1793
|
-
readonly errorCount: number;
|
|
1794
|
-
readonly originalBytes: number;
|
|
1795
|
-
readonly compressedBytes: number;
|
|
1796
|
-
};
|
|
1797
|
-
/**
|
|
1798
|
-
* Result of a decompression attempt.
|
|
1799
|
-
*/
|
|
1800
|
-
type DecompressResult = {
|
|
1801
|
-
ok: true;
|
|
1802
|
-
data: Buffer;
|
|
1803
|
-
} | {
|
|
1804
|
-
ok: false;
|
|
1805
|
-
error: string;
|
|
1806
|
-
};
|
|
1807
|
-
/**
|
|
1808
|
-
* Abstraction over zlib / noop decompression.
|
|
1809
|
-
*/
|
|
1810
|
-
interface Decompressor {
|
|
1811
|
-
readonly isPassthrough: boolean;
|
|
1812
|
-
decompress(data: Buffer | Uint8Array, encoding: SupportedEncoding): DecompressResult;
|
|
1813
|
-
}
|
|
1814
|
-
/**
|
|
1815
|
-
* Result of makeCompressionMiddleware — the middleware plus a stats accessor.
|
|
1816
|
-
*/
|
|
1817
|
-
type CompressionMiddlewareResult = {
|
|
1818
|
-
middleware: HttpMiddleware;
|
|
1819
|
-
stats: () => CompressionStats;
|
|
1820
|
-
};
|
|
1821
|
-
type RequestCompressionMiddlewareResult = {
|
|
1822
|
-
middleware: HttpMiddleware;
|
|
1823
|
-
stats: () => RequestCompressionStats;
|
|
1824
|
-
};
|
|
1825
|
-
|
|
1826
|
-
/**
|
|
1827
|
-
* Creates the compression middleware with optional configuration.
|
|
1828
|
-
*
|
|
1829
|
-
* The middleware:
|
|
1830
|
-
* 1. Injects Accept-Encoding header on outgoing requests (if missing)
|
|
1831
|
-
* 2. Decompresses response bodies based on Content-Encoding header
|
|
1832
|
-
* 3. Tracks compression statistics
|
|
1833
|
-
*/
|
|
1834
|
-
declare function makeCompressionMiddleware(config?: CompressionConfig): CompressionMiddlewareResult;
|
|
1835
|
-
declare const makeResponseCompressionMiddleware: typeof makeCompressionMiddleware;
|
|
1836
|
-
declare function makeRequestCompressionMiddleware(config?: RequestCompressionConfig): RequestCompressionMiddlewareResult;
|
|
1837
|
-
|
|
1838
1178
|
type RequestBatchingEvent = {
|
|
1839
1179
|
type: "batch-enqueue";
|
|
1840
1180
|
key: string;
|
|
@@ -2077,118 +1417,6 @@ declare function prewarmConnections(config?: ConnectionPrewarmConfig): Async<unk
|
|
|
2077
1417
|
declare const prewarmHttpConnections: typeof prewarmConnections;
|
|
2078
1418
|
declare function withConnectionPrewarming(config?: ConnectionPrewarmingMiddlewareConfig): HttpMiddleware;
|
|
2079
1419
|
|
|
2080
|
-
type InitNoMethodBody = Omit<RequestInit, "method" | "body"> & {
|
|
2081
|
-
timeoutMs?: number;
|
|
2082
|
-
poolKey?: string;
|
|
2083
|
-
headers?: unknown;
|
|
2084
|
-
} & HttpRequestPolicyInit;
|
|
2085
|
-
type InitWithHeaders = {
|
|
2086
|
-
headers?: unknown;
|
|
2087
|
-
timeoutMs?: number;
|
|
2088
|
-
poolKey?: string;
|
|
2089
|
-
} & HttpRequestPolicyInit & Record<string, unknown>;
|
|
2090
|
-
type HttpJsonInit<Validator extends AnyJsonSchemaLike> = InitNoMethodBody & {
|
|
2091
|
-
readonly schema: Validator;
|
|
2092
|
-
readonly schemaName?: string;
|
|
2093
|
-
};
|
|
2094
|
-
type HttpPostJsonInit<Validator extends AnyJsonSchemaLike> = InitWithHeaders & {
|
|
2095
|
-
readonly schema: Validator;
|
|
2096
|
-
readonly schemaName?: string;
|
|
2097
|
-
readonly bodySchema?: undefined;
|
|
2098
|
-
readonly bodySchemaName?: string;
|
|
2099
|
-
};
|
|
2100
|
-
type HttpPostJsonSchemaBodyInit<Validator extends AnyJsonSchemaLike, BodyValidator extends AnyJsonSchemaLike> = InitWithHeaders & {
|
|
2101
|
-
readonly schema: Validator;
|
|
2102
|
-
readonly schemaName?: string;
|
|
2103
|
-
readonly bodySchema: BodyValidator;
|
|
2104
|
-
readonly bodySchemaName?: string;
|
|
2105
|
-
};
|
|
2106
|
-
type HttpPostJsonBodyInit<BodyValidator extends AnyJsonSchemaLike> = InitWithHeaders & {
|
|
2107
|
-
readonly schema?: undefined;
|
|
2108
|
-
readonly schemaName?: string;
|
|
2109
|
-
readonly bodySchema: BodyValidator;
|
|
2110
|
-
readonly bodySchemaName?: string;
|
|
2111
|
-
};
|
|
2112
|
-
type JsonInitNoSchema = InitNoMethodBody & {
|
|
2113
|
-
readonly schema?: undefined;
|
|
2114
|
-
readonly schemaName?: string;
|
|
2115
|
-
};
|
|
2116
|
-
type PostJsonInitNoSchema = InitWithHeaders & {
|
|
2117
|
-
readonly schema?: undefined;
|
|
2118
|
-
readonly schemaName?: string;
|
|
2119
|
-
readonly bodySchema?: undefined;
|
|
2120
|
-
readonly bodySchemaName?: string;
|
|
2121
|
-
};
|
|
2122
|
-
type DefaultGetJson = {
|
|
2123
|
-
<Validator extends AnyJsonSchemaLike>(url: string, init: HttpJsonInit<Validator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<InferJsonSchema<Validator>>>;
|
|
2124
|
-
<A = unknown>(url: string, init?: JsonInitNoSchema): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<A>>;
|
|
2125
|
-
};
|
|
2126
|
-
type DefaultPostJson = {
|
|
2127
|
-
<Validator extends AnyJsonSchemaLike, BodyValidator extends AnyJsonSchemaLike>(url: string, bodyObj: InferJsonSchema<BodyValidator>, init: HttpPostJsonSchemaBodyInit<Validator, BodyValidator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<InferJsonSchema<Validator>>>;
|
|
2128
|
-
<BodyValidator extends AnyJsonSchemaLike, A = unknown>(url: string, bodyObj: InferJsonSchema<BodyValidator>, init: HttpPostJsonBodyInit<BodyValidator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<A>>;
|
|
2129
|
-
<Validator extends AnyJsonSchemaLike>(url: string, bodyObj: unknown, init: HttpPostJsonInit<Validator>): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<InferJsonSchema<Validator>>>;
|
|
2130
|
-
<A = unknown>(url: string, bodyObj: unknown, init?: PostJsonInitNoSchema): AsyncWithPromise<unknown, HttpError | ValidationError, HttpResponse<A>>;
|
|
2131
|
-
};
|
|
2132
|
-
type DefaultHttpClientPreset = "minimal" | "balanced" | "default" | "production";
|
|
2133
|
-
type DefaultHttpClientFeatures = {
|
|
2134
|
-
readonly dedup: boolean;
|
|
2135
|
-
readonly batch: boolean;
|
|
2136
|
-
readonly cache: boolean;
|
|
2137
|
-
readonly priority: boolean;
|
|
2138
|
-
readonly retry: boolean;
|
|
2139
|
-
readonly prewarm: boolean;
|
|
2140
|
-
readonly adaptiveLimiter: boolean;
|
|
2141
|
-
readonly compression: boolean;
|
|
2142
|
-
readonly middleware: number;
|
|
2143
|
-
};
|
|
2144
|
-
type DefaultHttpClientConfig = LifecycleClientConfig & {
|
|
2145
|
-
/**
|
|
2146
|
-
* Preset used as the baseline before caller overrides are applied.
|
|
2147
|
-
* - minimal: wire client + timeout only.
|
|
2148
|
-
* - balanced: retry, priority, dedup, adaptive limiter, response compression.
|
|
2149
|
-
* - default: balanced + short safe-method response cache.
|
|
2150
|
-
* - production: stable alias for the full production-ready default preset.
|
|
2151
|
-
*/
|
|
2152
|
-
readonly preset?: DefaultHttpClientPreset;
|
|
2153
|
-
/** Response decompression. Enabled by balanced/default presets; set false to disable. */
|
|
2154
|
-
readonly compression?: CompressionConfig | false;
|
|
2155
|
-
/** Extra middleware applied outermost after the preset stack, e.g. withHttpObservability(obs). */
|
|
2156
|
-
readonly middleware?: readonly HttpMiddleware[];
|
|
2157
|
-
/**
|
|
2158
|
-
* Named per-request policy presets. Requests can use `policy: "readModel"` or
|
|
2159
|
-
* `policy: { preset: "readModel", ...overrides }`.
|
|
2160
|
-
*/
|
|
2161
|
-
readonly policyPresets?: HttpPolicyPresets;
|
|
2162
|
-
};
|
|
2163
|
-
type DefaultHttpClient = {
|
|
2164
|
-
readonly request: (req: HttpRequest) => AsyncWithPromise<unknown, HttpError, HttpWireResponse>;
|
|
2165
|
-
readonly get: (url: string, init?: InitNoMethodBody) => AsyncWithPromise<unknown, HttpError, HttpWireResponse>;
|
|
2166
|
-
readonly post: (url: string, body?: string, init?: InitWithHeaders) => AsyncWithPromise<unknown, HttpError, HttpWireResponse>;
|
|
2167
|
-
readonly getText: (url: string, init?: InitNoMethodBody) => AsyncWithPromise<unknown, HttpError, HttpResponse<string>>;
|
|
2168
|
-
readonly getJson: DefaultGetJson;
|
|
2169
|
-
readonly postJson: DefaultPostJson;
|
|
2170
|
-
readonly with: (mw: HttpMiddleware) => DefaultHttpClient;
|
|
2171
|
-
readonly wire: LifecycleClient;
|
|
2172
|
-
readonly stats: () => LifecycleStats;
|
|
2173
|
-
readonly cache: LifecycleClient["cache"];
|
|
2174
|
-
readonly cancelAll: LifecycleClient["cancelAll"];
|
|
2175
|
-
readonly shutdown: LifecycleClient["shutdown"];
|
|
2176
|
-
readonly preset: DefaultHttpClientPreset;
|
|
2177
|
-
readonly features: DefaultHttpClientFeatures;
|
|
2178
|
-
readonly compression?: {
|
|
2179
|
-
readonly stats: () => CompressionStats;
|
|
2180
|
-
};
|
|
2181
|
-
};
|
|
2182
|
-
declare const defaultHttpClientPreset: DefaultHttpClientPreset;
|
|
2183
|
-
/**
|
|
2184
|
-
* Creates the recommended default HTTP client.
|
|
2185
|
-
*
|
|
2186
|
-
* The returned client has the easy JSON/text helpers from `httpClient`, but its
|
|
2187
|
-
* wire path is the full lifecycle stack: priority, retry, cache, batch, dedup,
|
|
2188
|
-
* adaptive concurrency, optional prewarm, compression, stats, and cancelAll.
|
|
2189
|
-
*/
|
|
2190
|
-
declare function makeDefaultHttpClient(config?: DefaultHttpClientConfig): DefaultHttpClient;
|
|
2191
|
-
|
|
2192
1420
|
type HttpClientBuilder = {
|
|
2193
1421
|
readonly config: () => DefaultHttpClientConfig;
|
|
2194
1422
|
readonly baseUrl: (baseUrl: string) => HttpClientBuilder;
|
|
@@ -2199,6 +1427,7 @@ type HttpClientBuilder = {
|
|
|
2199
1427
|
readonly transport: (transport: HttpTransport) => HttpClientBuilder;
|
|
2200
1428
|
readonly preset: (preset: DefaultHttpClientPreset) => HttpClientBuilder;
|
|
2201
1429
|
readonly minimal: () => HttpClientBuilder;
|
|
1430
|
+
readonly proxy: () => HttpClientBuilder;
|
|
2202
1431
|
readonly balanced: () => HttpClientBuilder;
|
|
2203
1432
|
readonly defaultPreset: () => HttpClientBuilder;
|
|
2204
1433
|
readonly production: () => HttpClientBuilder;
|
|
@@ -2380,4 +1609,11 @@ declare const HttpServer: Readonly<{
|
|
|
2380
1609
|
}>;
|
|
2381
1610
|
}>;
|
|
2382
1611
|
|
|
2383
|
-
|
|
1612
|
+
declare const HttpClientService: ServiceTag<DefaultHttpClient>;
|
|
1613
|
+
type DefaultHttpClientLayerConfig = DefaultHttpClientConfig | ((context: LayerContext) => DefaultHttpClientConfig);
|
|
1614
|
+
type DefaultHttpClientLayerOptions = {
|
|
1615
|
+
readonly tag?: ServiceTag<DefaultHttpClient>;
|
|
1616
|
+
};
|
|
1617
|
+
declare function makeDefaultHttpClientLayer(config?: DefaultHttpClientLayerConfig, options?: DefaultHttpClientLayerOptions): Layer<LayerContext, unknown, LayerContext>;
|
|
1618
|
+
|
|
1619
|
+
export { AdaptiveLimiter, AdaptiveLimiterConfig, AdaptiveLimiterPreset, AnyJsonSchemaLike, BatchConfig, type BudgetSemaphore, CacheConfig$1 as CacheConfig, type CacheKeyComponents, CompressionConfig, CompressionMiddlewareResult, type ConnectionPrewarmAttempt, type ConnectionPrewarmConfig, type ConnectionPrewarmEvent, type ConnectionPrewarmResult, type ConnectionPrewarmingMiddlewareConfig, type ConnectionStateMap, DEFAULT_CACHE_RELEVANT_HEADERS, DedupConfig$1 as DedupConfig, DefaultHttpClient, DefaultHttpClientConfig, type DefaultHttpClientLayerConfig, type DefaultHttpClientLayerOptions, DefaultHttpClientPreset, EmaComputer, type HttpCircuitBreakerConfig, type HttpClientBuilder, HttpClientFn, HttpClientService, HttpClientStats, HttpError, HttpMethod, HttpMiddleware, HttpPoolConfig, HttpRequest, type HttpRouteMatch, type HttpRouteOptions, type HttpRouteSchemas, type HttpRouter, type HttpRouterOptions, type HttpRuntimeHealthRouteOptions, HttpServer, type HttpServerBody, type HttpServerContext, type HttpServerHandler, type HttpServerHeaders, type HttpServerMethod, type HttpServerMiddleware, type HttpServerParams, type HttpServerQuery, type HttpServerRequest, type HttpServerResponse, type HttpServerRoute, HttpTransport, HttpWireResponse, InferJsonSchema, type InferServerPart, LRUCache, type LRUCacheConfig, LatencyWindow, LifecycleClient, LifecycleClientConfig, LifecycleEvent, LifecycleEventType, LifecycleStats, LifecycleStatsTracker, type LogEvent, type NodeHttpProxyClientConfig, type NodeHttpServerError, type NodeHttpServerHandle, type NodeHttpServerOptions, type NodeHttpServerShutdownState, type NodeHttpTransport, type NodeHttpTransportConfig, PrewarmConfig, PrewarmLifecycleConfig, type PrewarmManager, PrewarmOriginState, PrewarmResult, PrewarmStatusSnapshot, PriorityConfig$1 as PriorityConfig, PriorityQueue, type PriorityQueueEntry, type ProbeOutcome, type RequestBatchingConfig, type RequestBatchingEvent, RequestCompressionConfig, RequestCompressionMiddlewareResult, RetryPolicy, type RoutePathParamNames, type RoutePathParams, SEPARATOR, clampPriority, computeCacheKey, computeGradient, computeNewLimit, detectPlatform, empty, executeProbe, httpBuilder, httpClientBuilder, httpRoute, json, makeBudgetSemaphore, makeCompressionMiddleware, makeConnectionStateMap, makeDefaultHttpClientLayer, makeHttpClient, makeHttpClientBuilder, makeHttpRouter, makeHttpServerResource, makeLifecycleClient, makeNodeHttpProxyClient, makeNodeHttpServer, makeNodeHttpServerResource, makeNodeHttpTransport, makePrewarmManager, makeRequestCompressionMiddleware, makeResponseCompressionMiddleware, makeRuntimeHealthRoute, makeRuntimeReadinessRoute, nodeHttpServerResource, parseCacheKey, prewarmConnections, prewarmHttpConnections, route, runtimeHealthRoute, runtimeReadinessRoute, text, validateFetchAvailable, validateOrigin, withAuth, withCache, withCircuitBreaker, withConnectionPrewarming, withDedup, withLogging, withPriority, withRequestBatching, withResponseHeader, withResponseTransform, withTracing };
|