brass-runtime 1.19.2 → 1.21.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/CHANGELOG.md +88 -0
- package/dist/agent/cli/main.cjs +265 -43
- package/dist/agent/cli/main.d.ts +99 -0
- package/dist/agent/cli/main.js +238 -16
- package/dist/agent/cli/main.mjs +238 -16
- package/dist/agent/index.cjs +18 -2
- package/dist/agent/index.d.ts +60 -482
- package/dist/agent/index.js +17 -1
- package/dist/agent/index.mjs +17 -1
- package/dist/{chunk-QAHW7S3Q.cjs → chunk-62IBGQOU.cjs} +6 -6
- package/dist/{chunk-6AGAZD32.js → chunk-6LF3M4JC.js} +2 -2
- package/dist/{chunk-5X3MPWTR.mjs → chunk-6NXQL3IC.mjs} +370 -10
- package/dist/{chunk-J4F5KC3U.js → chunk-AI3M6624.js} +1260 -45
- package/dist/{chunk-TWEHIAUE.cjs → chunk-BDTBIYAM.cjs} +13 -13
- package/dist/{chunk-IA6BDGXW.mjs → chunk-D53GY2SZ.mjs} +2 -2
- package/dist/{chunk-IHY2EJTT.cjs → chunk-EX4VEKUF.cjs} +1340 -125
- package/dist/{chunk-UOKXJQAI.cjs → chunk-LA2PAO7J.cjs} +378 -18
- package/dist/{chunk-ZXXOXB3T.mjs → chunk-OS4F5HZE.mjs} +1 -1
- package/dist/{chunk-HKLZJ5UK.js → chunk-POH2WZBI.js} +370 -10
- package/dist/{chunk-6BNZS2A4.mjs → chunk-Q57ENQUW.mjs} +1260 -45
- package/dist/{chunk-BHX4MD35.js → chunk-VXZIP3IU.js} +1 -1
- package/dist/{defaultClient-hyVSNzSJ.d.ts → defaultClient-DLOa3gdw.d.ts} +101 -3
- package/dist/http/index.cjs +69 -33
- package/dist/http/index.d.ts +67 -4
- package/dist/http/index.js +37 -1
- package/dist/http/index.mjs +37 -1
- package/dist/http/testing.cjs +4 -4
- package/dist/http/testing.d.ts +1 -1
- package/dist/http/testing.js +1 -1
- package/dist/http/testing.mjs +1 -1
- package/dist/nodeWorkspaceDiscovery-Ami1UkMt.d.ts +631 -0
- package/dist/observability/index.cjs +3 -3
- package/dist/observability/index.d.ts +3 -3
- package/dist/observability/index.js +2 -2
- package/dist/observability/index.mjs +2 -2
- package/dist/perf/cli.cjs +18 -18
- package/dist/perf/cli.js +3 -3
- package/dist/perf/cli.mjs +3 -3
- package/dist/perf/index.cjs +5 -5
- package/dist/perf/index.js +3 -3
- package/dist/perf/index.mjs +3 -3
- package/dist/{server-BKKuzAW9.d.ts → server-BGXOabjo.d.ts} +1 -1
- package/package.json +1 -1
- package/wasm/pkg/package.json +1 -1
|
@@ -5638,14 +5638,14 @@ function noopInvalidate(_key) {
|
|
|
5638
5638
|
}
|
|
5639
5639
|
function noopClear() {
|
|
5640
5640
|
}
|
|
5641
|
-
function buildLifecycleClient(
|
|
5642
|
-
const client = (req) => trackRequest(
|
|
5641
|
+
function buildLifecycleClient(fn3, tracker, internals) {
|
|
5642
|
+
const client = (req) => trackRequest(fn3, req, tracker, internals);
|
|
5643
5643
|
const stats = () => {
|
|
5644
5644
|
tracker.setQueueDepth(_nullishCoalesce(_optionalChain([internals, 'access', _135 => _135.queueDepth, 'optionalCall', _136 => _136()]), () => ( 0)));
|
|
5645
5645
|
return tracker.snapshot();
|
|
5646
5646
|
};
|
|
5647
5647
|
const withMw = (mw) => {
|
|
5648
|
-
const wrappedFn = mw(withLifecycleMetadata(
|
|
5648
|
+
const wrappedFn = mw(withLifecycleMetadata(fn3, internals));
|
|
5649
5649
|
return buildLifecycleClient(wrappedFn, tracker, internals);
|
|
5650
5650
|
};
|
|
5651
5651
|
const lifecycleClient = Object.assign(client, {
|
|
@@ -5661,9 +5661,9 @@ function buildLifecycleClient(fn2, tracker, internals) {
|
|
|
5661
5661
|
});
|
|
5662
5662
|
return lifecycleClient;
|
|
5663
5663
|
}
|
|
5664
|
-
function withLifecycleMetadata(
|
|
5665
|
-
if (!internals.adaptiveLimiter) return
|
|
5666
|
-
return Object.assign(((req) =>
|
|
5664
|
+
function withLifecycleMetadata(fn3, internals) {
|
|
5665
|
+
if (!internals.adaptiveLimiter) return fn3;
|
|
5666
|
+
return Object.assign(((req) => fn3(req)), {
|
|
5667
5667
|
adaptiveLimiter: internals.adaptiveLimiter
|
|
5668
5668
|
});
|
|
5669
5669
|
}
|
|
@@ -5684,7 +5684,7 @@ function shutdownClient(activeCancelers, prewarmMgr, wireShutdown) {
|
|
|
5684
5684
|
_optionalChain([wireShutdown, 'optionalCall', _137 => _137()]);
|
|
5685
5685
|
return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
|
|
5686
5686
|
}
|
|
5687
|
-
function trackRequest(
|
|
5687
|
+
function trackRequest(fn3, req, tracker, internals) {
|
|
5688
5688
|
return {
|
|
5689
5689
|
_tag: "Async",
|
|
5690
5690
|
register: (env, cb) => {
|
|
@@ -5746,7 +5746,7 @@ function trackRequest(fn2, req, tracker, internals) {
|
|
|
5746
5746
|
return () => void 0;
|
|
5747
5747
|
}
|
|
5748
5748
|
try {
|
|
5749
|
-
cancelInner = _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0,
|
|
5749
|
+
cancelInner = _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, fn3(req), env, finish);
|
|
5750
5750
|
} catch (error) {
|
|
5751
5751
|
finish({
|
|
5752
5752
|
_tag: "Failure",
|
|
@@ -6168,6 +6168,190 @@ function previewJson(value) {
|
|
|
6168
6168
|
}
|
|
6169
6169
|
}
|
|
6170
6170
|
|
|
6171
|
+
// src/http/bareMetalClient.ts
|
|
6172
|
+
var fn2 = _chunkKPOL2YEOcjs.Schema.custom(
|
|
6173
|
+
(value) => typeof value === "function",
|
|
6174
|
+
"function"
|
|
6175
|
+
);
|
|
6176
|
+
var poolConfig2 = _chunkKPOL2YEOcjs.Schema.union([
|
|
6177
|
+
_chunkKPOL2YEOcjs.Schema.literal(false),
|
|
6178
|
+
_chunkKPOL2YEOcjs.Schema.object(
|
|
6179
|
+
{
|
|
6180
|
+
concurrency: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6181
|
+
maxQueue: _chunkKPOL2YEOcjs.Schema.number({ min: 0, int: true }).optional(),
|
|
6182
|
+
queueTimeoutMs: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6183
|
+
key: _chunkKPOL2YEOcjs.Schema.union([
|
|
6184
|
+
_chunkKPOL2YEOcjs.Schema.enum(["global", "origin", "host"]),
|
|
6185
|
+
fn2
|
|
6186
|
+
]).optional(),
|
|
6187
|
+
engine: _chunkKPOL2YEOcjs.Schema.enum(["ts", "wasm"]).optional(),
|
|
6188
|
+
wasm: _chunkKPOL2YEOcjs.Schema.boolean().optional()
|
|
6189
|
+
},
|
|
6190
|
+
{ unknownKeys: "passthrough" }
|
|
6191
|
+
)
|
|
6192
|
+
]);
|
|
6193
|
+
var adaptiveLimiterConfig2 = _chunkKPOL2YEOcjs.Schema.union([
|
|
6194
|
+
_chunkKPOL2YEOcjs.Schema.literal(false),
|
|
6195
|
+
_chunkKPOL2YEOcjs.Schema.object(
|
|
6196
|
+
{
|
|
6197
|
+
preset: _chunkKPOL2YEOcjs.Schema.enum(["conservative", "balanced", "aggressive"]).optional(),
|
|
6198
|
+
initialLimit: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6199
|
+
minLimit: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6200
|
+
maxLimit: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6201
|
+
smoothingFactor: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "smoothingFactor must be in (0, 1]").optional(),
|
|
6202
|
+
probeInterval: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6203
|
+
probeJitterRatio: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).optional(),
|
|
6204
|
+
windowSize: _chunkKPOL2YEOcjs.Schema.number({ min: 2, int: true }).optional(),
|
|
6205
|
+
minSamples: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6206
|
+
baselineStrategy: _chunkKPOL2YEOcjs.Schema.enum(["min", "p5", "ema-low"]).optional(),
|
|
6207
|
+
decreaseCooldownSamples: _chunkKPOL2YEOcjs.Schema.number({ min: 0, int: true }).optional(),
|
|
6208
|
+
historySize: _chunkKPOL2YEOcjs.Schema.number({ min: 0, int: true }).optional(),
|
|
6209
|
+
windowDecayFactor: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "windowDecayFactor must be in (0, 1]").optional(),
|
|
6210
|
+
errorWeight: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).optional(),
|
|
6211
|
+
errorSmoothingFactor: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "errorSmoothingFactor must be in (0, 1]").optional(),
|
|
6212
|
+
errorStatusThreshold: _chunkKPOL2YEOcjs.Schema.number({ min: 100, max: 599, int: true }).optional(),
|
|
6213
|
+
queueStrategy: _chunkKPOL2YEOcjs.Schema.enum(["fifo", "priority"]).optional(),
|
|
6214
|
+
queueLoadShedding: _chunkKPOL2YEOcjs.Schema.enum(["reject-new", "priority-evict"]).optional(),
|
|
6215
|
+
rejectionBackoffThreshold: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6216
|
+
rejectionBackoffMs: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6217
|
+
stateTtlMs: _chunkKPOL2YEOcjs.Schema.union([_chunkKPOL2YEOcjs.Schema.literal(false), _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true })]).optional(),
|
|
6218
|
+
warmupRequests: _chunkKPOL2YEOcjs.Schema.number({ min: 0, int: true }).optional(),
|
|
6219
|
+
decreaseThreshold: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "decreaseThreshold must be in (0, 1]").optional(),
|
|
6220
|
+
increaseThreshold: _chunkKPOL2YEOcjs.Schema.number({ min: 1 }).optional(),
|
|
6221
|
+
maxDecreaseRatio: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "maxDecreaseRatio must be in (0, 1]").optional(),
|
|
6222
|
+
headroomStrategy: _chunkKPOL2YEOcjs.Schema.union([
|
|
6223
|
+
_chunkKPOL2YEOcjs.Schema.number({ min: 1 }),
|
|
6224
|
+
_chunkKPOL2YEOcjs.Schema.enum(["fixed", "proportional"]),
|
|
6225
|
+
fn2,
|
|
6226
|
+
_chunkKPOL2YEOcjs.Schema.object({ type: _chunkKPOL2YEOcjs.Schema.literal("fixed"), value: _chunkKPOL2YEOcjs.Schema.number({ min: 1 }).optional() }, { unknownKeys: "passthrough" }),
|
|
6227
|
+
_chunkKPOL2YEOcjs.Schema.object({
|
|
6228
|
+
type: _chunkKPOL2YEOcjs.Schema.literal("proportional"),
|
|
6229
|
+
ratio: _chunkKPOL2YEOcjs.Schema.number({ min: 0 }).refine((n) => n > 0, "ratio must be > 0").optional(),
|
|
6230
|
+
min: _chunkKPOL2YEOcjs.Schema.number({ min: 1 }).optional(),
|
|
6231
|
+
max: _chunkKPOL2YEOcjs.Schema.number({ min: 1 }).optional()
|
|
6232
|
+
}, { unknownKeys: "passthrough" })
|
|
6233
|
+
]).optional(),
|
|
6234
|
+
slowStartRecovery: _chunkKPOL2YEOcjs.Schema.boolean().optional(),
|
|
6235
|
+
slowStartSaturationThreshold: _chunkKPOL2YEOcjs.Schema.number({ min: 0, max: 1 }).refine((n) => n > 0, "slowStartSaturationThreshold must be in (0, 1]").optional(),
|
|
6236
|
+
slowStartSaturationSamples: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6237
|
+
key: _chunkKPOL2YEOcjs.Schema.union([_chunkKPOL2YEOcjs.Schema.enum(["global", "origin", "host"]), fn2]).optional(),
|
|
6238
|
+
maxQueue: _chunkKPOL2YEOcjs.Schema.number({ min: 0, int: true }).optional(),
|
|
6239
|
+
queueTimeoutMs: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6240
|
+
onLimitChange: fn2.optional(),
|
|
6241
|
+
percentile: _chunkKPOL2YEOcjs.Schema.enum(["p50", "p99"]).optional()
|
|
6242
|
+
},
|
|
6243
|
+
{ unknownKeys: "passthrough" }
|
|
6244
|
+
)
|
|
6245
|
+
]);
|
|
6246
|
+
var bareMetalConfigSchema = _chunkKPOL2YEOcjs.Schema.object(
|
|
6247
|
+
{
|
|
6248
|
+
baseUrl: _chunkKPOL2YEOcjs.Schema.string().optional(),
|
|
6249
|
+
headers: _chunkKPOL2YEOcjs.Schema.record(_chunkKPOL2YEOcjs.Schema.string()).optional(),
|
|
6250
|
+
timeoutMs: _chunkKPOL2YEOcjs.Schema.number({ min: 1, int: true }).optional(),
|
|
6251
|
+
transport: fn2.optional(),
|
|
6252
|
+
streamTransport: fn2.optional(),
|
|
6253
|
+
pool: poolConfig2.optional(),
|
|
6254
|
+
adaptiveLimiter: adaptiveLimiterConfig2.optional(),
|
|
6255
|
+
onEvent: fn2.optional()
|
|
6256
|
+
},
|
|
6257
|
+
{ unknownKeys: "passthrough" }
|
|
6258
|
+
);
|
|
6259
|
+
function validateBareMetalConfig(config) {
|
|
6260
|
+
_chunkKPOL2YEOcjs.parseConfig.call(void 0, "BareMetalHttpConfig", bareMetalConfigSchema, config);
|
|
6261
|
+
}
|
|
6262
|
+
var transportDestroy2 = (transport) => {
|
|
6263
|
+
const destroy = transport.destroy;
|
|
6264
|
+
return typeof destroy === "function" ? () => destroy.call(transport) : void 0;
|
|
6265
|
+
};
|
|
6266
|
+
function makeBareMetalHttp(cfg = {}) {
|
|
6267
|
+
validateBareMetalConfig(cfg);
|
|
6268
|
+
const baseUrl = _nullishCoalesce(cfg.baseUrl, () => ( ""));
|
|
6269
|
+
const defaultHeaders = _nullishCoalesce(cfg.headers, () => ( {}));
|
|
6270
|
+
const normalize = normalizeRequest(defaultHeaders);
|
|
6271
|
+
const adaptiveLimiter = makeAdaptiveLimiter(cfg);
|
|
6272
|
+
const pool = adaptiveLimiter ? void 0 : makePool(cfg);
|
|
6273
|
+
const metrics = makeHttpStats(pool, adaptiveLimiter);
|
|
6274
|
+
const transport = _nullishCoalesce(cfg.transport, () => ( makeFetchTransport()));
|
|
6275
|
+
const destroyTransport = transportDestroy2(transport);
|
|
6276
|
+
const run = (req0) => {
|
|
6277
|
+
const req = normalize(req0);
|
|
6278
|
+
const url = resolveRequestUrl(req, baseUrl);
|
|
6279
|
+
if (!(url instanceof URL)) return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, url);
|
|
6280
|
+
const timeoutMs = resolvePositiveTimeout(_nullishCoalesce(req.timeoutMs, () => ( cfg.timeoutMs)));
|
|
6281
|
+
if (!adaptiveLimiter && !pool && timeoutMs === void 0) {
|
|
6282
|
+
return runDirectTransport(req, url, transport, metrics);
|
|
6283
|
+
}
|
|
6284
|
+
return runPoolTransport(req, url, transport, metrics, pool, adaptiveLimiter, void 0, timeoutMs);
|
|
6285
|
+
};
|
|
6286
|
+
const metadata = {};
|
|
6287
|
+
if (adaptiveLimiter) metadata.adaptiveLimiter = adaptiveLimiter;
|
|
6288
|
+
if (adaptiveLimiter || destroyTransport) {
|
|
6289
|
+
metadata.destroy = () => {
|
|
6290
|
+
_optionalChain([adaptiveLimiter, 'optionalAccess', _154 => _154.destroy, 'call', _155 => _155()]);
|
|
6291
|
+
_optionalChain([destroyTransport, 'optionalCall', _156 => _156()]);
|
|
6292
|
+
};
|
|
6293
|
+
metadata.shutdown = () => {
|
|
6294
|
+
_optionalChain([adaptiveLimiter, 'optionalAccess', _157 => _157.shutdown, 'call', _158 => _158()]);
|
|
6295
|
+
_optionalChain([destroyTransport, 'optionalCall', _159 => _159()]);
|
|
6296
|
+
};
|
|
6297
|
+
}
|
|
6298
|
+
return decorate(run, metrics.snapshot, metadata);
|
|
6299
|
+
}
|
|
6300
|
+
function makeBareMetalHttpStream(cfg = {}) {
|
|
6301
|
+
validateBareMetalConfig(cfg);
|
|
6302
|
+
const baseUrl = _nullishCoalesce(cfg.baseUrl, () => ( ""));
|
|
6303
|
+
const defaultHeaders = _nullishCoalesce(cfg.headers, () => ( {}));
|
|
6304
|
+
const normalize = normalizeRequest(defaultHeaders);
|
|
6305
|
+
const adaptiveLimiter = makeAdaptiveLimiter(cfg);
|
|
6306
|
+
const pool = adaptiveLimiter ? void 0 : makePool(cfg);
|
|
6307
|
+
const metrics = makeHttpStats(pool, adaptiveLimiter);
|
|
6308
|
+
const transport = _nullishCoalesce(cfg.streamTransport, () => ( makeFetchStreamTransport()));
|
|
6309
|
+
const run = (req0) => {
|
|
6310
|
+
const req = normalize(req0);
|
|
6311
|
+
const url = resolveRequestUrl(req, baseUrl);
|
|
6312
|
+
if (!(url instanceof URL)) return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, url);
|
|
6313
|
+
const timeoutMs = resolvePositiveTimeout(_nullishCoalesce(req.timeoutMs, () => ( cfg.timeoutMs)));
|
|
6314
|
+
return _chunkJKHBEWQAcjs.fromPromiseAbortable.call(void 0,
|
|
6315
|
+
async (signal, env) => {
|
|
6316
|
+
let lease;
|
|
6317
|
+
const linkedSignal = linkAbortSignals(signal, _optionalChain([req, 'access', _160 => _160.init, 'optionalAccess', _161 => _161.signal]));
|
|
6318
|
+
try {
|
|
6319
|
+
if (linkedSignal.signal.aborted) throw abortErrorForSignal(linkedSignal.signal);
|
|
6320
|
+
if (adaptiveLimiter) {
|
|
6321
|
+
const key = resolveHttpPoolKey(adaptiveLimiter.keyResolver, req, url);
|
|
6322
|
+
lease = await adaptiveLimiter.acquire(key, linkedSignal.signal, { priority: requestPriority(req) });
|
|
6323
|
+
} else if (pool) {
|
|
6324
|
+
const key = resolveHttpPoolKey(pool.keyResolver, req, url);
|
|
6325
|
+
lease = await pool.acquire(key, linkedSignal.signal);
|
|
6326
|
+
}
|
|
6327
|
+
const response = await runTransportEffect(
|
|
6328
|
+
transport({ request: req, url, signal: linkedSignal.signal }),
|
|
6329
|
+
env,
|
|
6330
|
+
linkedSignal.signal
|
|
6331
|
+
);
|
|
6332
|
+
releaseSuccess(lease, adaptiveLimiter, response);
|
|
6333
|
+
lease = void 0;
|
|
6334
|
+
return response;
|
|
6335
|
+
} finally {
|
|
6336
|
+
linkedSignal.cleanup();
|
|
6337
|
+
if (lease) {
|
|
6338
|
+
releaseFailure(lease, adaptiveLimiter);
|
|
6339
|
+
}
|
|
6340
|
+
}
|
|
6341
|
+
},
|
|
6342
|
+
normalizeHttpError,
|
|
6343
|
+
{
|
|
6344
|
+
label: fetchLabel(req, url),
|
|
6345
|
+
timeoutMs,
|
|
6346
|
+
timeoutReason: timeoutMs ? () => timeoutReason(req, url, timeoutMs) : void 0,
|
|
6347
|
+
onStart: metrics.onStart,
|
|
6348
|
+
onFinish: metrics.onFinish
|
|
6349
|
+
}
|
|
6350
|
+
);
|
|
6351
|
+
};
|
|
6352
|
+
return decorateStream(run, metrics.snapshot);
|
|
6353
|
+
}
|
|
6354
|
+
|
|
6171
6355
|
// src/http/requestBuilder.ts
|
|
6172
6356
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6173
6357
|
function splitHttpRequestInit(init) {
|
|
@@ -6265,17 +6449,18 @@ var PRESET_CONFIGS = {
|
|
|
6265
6449
|
highThroughputProxy: PROXY_PRESET_CONFIG,
|
|
6266
6450
|
balanced: BALANCED_PRESET_CONFIG,
|
|
6267
6451
|
default: DEFAULT_PRESET_CONFIG,
|
|
6268
|
-
production: DEFAULT_PRESET_CONFIG
|
|
6452
|
+
production: DEFAULT_PRESET_CONFIG,
|
|
6453
|
+
bareMetal: {}
|
|
6269
6454
|
};
|
|
6270
6455
|
function isDefaultCacheableResponse(req, res) {
|
|
6271
6456
|
if (!DEFAULT_CACHEABLE_METHODS.has(req.method)) return false;
|
|
6272
6457
|
if (res.status < 200 || res.status >= 400) return false;
|
|
6273
|
-
const cacheControl = _optionalChain([headerValue, 'call',
|
|
6458
|
+
const cacheControl = _optionalChain([headerValue, 'call', _162 => _162(res.headers, "cache-control"), 'optionalAccess', _163 => _163.toLowerCase, 'call', _164 => _164()]);
|
|
6274
6459
|
if (cacheControl) {
|
|
6275
6460
|
const directives = cacheControl.split(",").map((part) => part.trim());
|
|
6276
6461
|
if (directives.includes("no-store") || directives.includes("no-cache")) return false;
|
|
6277
6462
|
}
|
|
6278
|
-
if (_optionalChain([headerValue, 'call',
|
|
6463
|
+
if (_optionalChain([headerValue, 'call', _165 => _165(res.headers, "pragma"), 'optionalAccess', _166 => _166.toLowerCase, 'call', _167 => _167()]) === "no-cache") return false;
|
|
6279
6464
|
if (headerValue(res.headers, "set-cookie") !== void 0) return false;
|
|
6280
6465
|
return true;
|
|
6281
6466
|
}
|
|
@@ -6292,6 +6477,9 @@ function makeDefaultHttpClient(config = {}) {
|
|
|
6292
6477
|
policyPresets,
|
|
6293
6478
|
...lifecycleOverrides
|
|
6294
6479
|
} = config;
|
|
6480
|
+
if (preset === "bareMetal") {
|
|
6481
|
+
return buildBareMetalBranch(lifecycleOverrides, middleware, config);
|
|
6482
|
+
}
|
|
6295
6483
|
const lifecycleConfig2 = mergeLifecycleConfig(PRESET_CONFIGS[preset], lifecycleOverrides);
|
|
6296
6484
|
let wire = makeLifecycleClient(lifecycleConfig2);
|
|
6297
6485
|
const compressionResult = compression === false || compression === void 0 && isLeanPreset(preset) ? void 0 : makeCompressionMiddleware(compression === void 0 ? void 0 : compression);
|
|
@@ -6311,10 +6499,164 @@ function makeDefaultHttpClient(config = {}) {
|
|
|
6311
6499
|
return buildDefaultClient(wire, {
|
|
6312
6500
|
preset,
|
|
6313
6501
|
features,
|
|
6314
|
-
compressionStats: _optionalChain([compressionResult, 'optionalAccess',
|
|
6502
|
+
compressionStats: _optionalChain([compressionResult, 'optionalAccess', _168 => _168.stats]),
|
|
6315
6503
|
useInlineDecode
|
|
6316
6504
|
});
|
|
6317
6505
|
}
|
|
6506
|
+
var LIFECYCLE_KEYS = [
|
|
6507
|
+
"dedup",
|
|
6508
|
+
"batch",
|
|
6509
|
+
"cache",
|
|
6510
|
+
"priority",
|
|
6511
|
+
"retry",
|
|
6512
|
+
"prewarm",
|
|
6513
|
+
"adaptiveLimiter",
|
|
6514
|
+
"compression"
|
|
6515
|
+
];
|
|
6516
|
+
function findIgnoredLifecycleKeys(overrides) {
|
|
6517
|
+
const found = [];
|
|
6518
|
+
for (const key of LIFECYCLE_KEYS) {
|
|
6519
|
+
if (key in overrides && overrides[key] !== void 0 && overrides[key] !== false) {
|
|
6520
|
+
found.push(key);
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
return found;
|
|
6524
|
+
}
|
|
6525
|
+
function extractBareMetalConfig(config) {
|
|
6526
|
+
return {
|
|
6527
|
+
baseUrl: config.baseUrl,
|
|
6528
|
+
headers: config.headers,
|
|
6529
|
+
timeoutMs: config.timeoutMs,
|
|
6530
|
+
transport: config.transport,
|
|
6531
|
+
streamTransport: config.streamTransport,
|
|
6532
|
+
pool: config.pool,
|
|
6533
|
+
adaptiveLimiter: void 0,
|
|
6534
|
+
// bare-metal ignores adaptiveLimiter from lifecycle overrides
|
|
6535
|
+
onEvent: config.onEvent
|
|
6536
|
+
};
|
|
6537
|
+
}
|
|
6538
|
+
function buildBareMetalBranch(lifecycleOverrides, middleware, config) {
|
|
6539
|
+
const ignored = findIgnoredLifecycleKeys(lifecycleOverrides);
|
|
6540
|
+
if (ignored.length > 0 && config.onEvent) {
|
|
6541
|
+
config.onEvent({
|
|
6542
|
+
type: "warning",
|
|
6543
|
+
message: `bareMetal preset ignores: ${ignored.join(", ")}`
|
|
6544
|
+
});
|
|
6545
|
+
}
|
|
6546
|
+
let bareWire = makeBareMetalHttp(extractBareMetalConfig(config));
|
|
6547
|
+
for (const mw of middleware) {
|
|
6548
|
+
bareWire = bareWire.with(mw);
|
|
6549
|
+
}
|
|
6550
|
+
const features = Object.freeze({
|
|
6551
|
+
dedup: false,
|
|
6552
|
+
batch: false,
|
|
6553
|
+
cache: false,
|
|
6554
|
+
priority: false,
|
|
6555
|
+
retry: false,
|
|
6556
|
+
prewarm: false,
|
|
6557
|
+
adaptiveLimiter: false,
|
|
6558
|
+
compression: false,
|
|
6559
|
+
middleware: middleware.length
|
|
6560
|
+
});
|
|
6561
|
+
return buildBareMetalDefaultClient(bareWire, { preset: "bareMetal", features });
|
|
6562
|
+
}
|
|
6563
|
+
function buildBareMetalDefaultClient(bareWire, meta) {
|
|
6564
|
+
const withPromise = (eff) => _chunkMVGUEJ5Zcjs.withAsyncPromise.call(void 0, (e, env) => _chunkJKHBEWQAcjs.toPromise.call(void 0, e, env))(eff);
|
|
6565
|
+
const requestRaw = (req) => bareWire(req);
|
|
6566
|
+
const request = (req) => withPromise(requestRaw(req));
|
|
6567
|
+
const get = (url, init) => request(buildHttpRequest("GET", url, init));
|
|
6568
|
+
const post = (url, body, init) => request(buildHttpRequest("POST", url, init, body));
|
|
6569
|
+
const getText = (url, init) => {
|
|
6570
|
+
const req = buildHttpRequest("GET", url, init);
|
|
6571
|
+
return withPromise(
|
|
6572
|
+
_chunkMVGUEJ5Zcjs.mapTryAsync.call(void 0, requestRaw(req), (w) => toResponse(w, w.bodyText))
|
|
6573
|
+
);
|
|
6574
|
+
};
|
|
6575
|
+
const getJson = ((url, init) => {
|
|
6576
|
+
const req = setHeaderIfMissing("accept", "application/json")(
|
|
6577
|
+
buildHttpRequest("GET", url, init)
|
|
6578
|
+
);
|
|
6579
|
+
return withPromise(
|
|
6580
|
+
_chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _169 => _169.schema]), _optionalChain([init, 'optionalAccess', _170 => _170.schemaName])))
|
|
6581
|
+
);
|
|
6582
|
+
});
|
|
6583
|
+
const postJson = ((url, bodyObj, init) => {
|
|
6584
|
+
return withPromise(
|
|
6585
|
+
_chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
|
|
6586
|
+
encodeJsonBodyEffect(bodyObj, _optionalChain([init, 'optionalAccess', _171 => _171.bodySchema]), { schemaName: _optionalChain([init, 'optionalAccess', _172 => _172.bodySchemaName]) }),
|
|
6587
|
+
(bodyText) => {
|
|
6588
|
+
const req = setHeaderIfMissing("content-type", "application/json")(
|
|
6589
|
+
setHeaderIfMissing("accept", "application/json")(
|
|
6590
|
+
buildHttpRequest("POST", url, init, bodyText)
|
|
6591
|
+
)
|
|
6592
|
+
);
|
|
6593
|
+
return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _173 => _173.schema]), _optionalChain([init, 'optionalAccess', _174 => _174.schemaName])));
|
|
6594
|
+
}
|
|
6595
|
+
)
|
|
6596
|
+
);
|
|
6597
|
+
});
|
|
6598
|
+
const wireAsLifecycle = Object.assign(
|
|
6599
|
+
(req) => bareWire(req),
|
|
6600
|
+
{
|
|
6601
|
+
with: (mw) => {
|
|
6602
|
+
const newBare = bareWire.with(mw);
|
|
6603
|
+
return buildBareMetalDefaultClient(newBare, {
|
|
6604
|
+
...meta,
|
|
6605
|
+
features: { ...meta.features, middleware: meta.features.middleware + 1 }
|
|
6606
|
+
}).wire;
|
|
6607
|
+
},
|
|
6608
|
+
stats: () => ({
|
|
6609
|
+
cacheHits: 0,
|
|
6610
|
+
cacheMisses: 0,
|
|
6611
|
+
cacheEvictions: 0,
|
|
6612
|
+
dedupHits: 0,
|
|
6613
|
+
dedupActive: 0,
|
|
6614
|
+
queueDepth: 0,
|
|
6615
|
+
requestsStarted: 0,
|
|
6616
|
+
requestsCompleted: 0,
|
|
6617
|
+
requestsFailed: 0,
|
|
6618
|
+
retries: 0,
|
|
6619
|
+
batchDispatches: 0,
|
|
6620
|
+
batchedRequests: 0,
|
|
6621
|
+
wire: bareWire.stats()
|
|
6622
|
+
}),
|
|
6623
|
+
cancelAll: () => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0),
|
|
6624
|
+
shutdown: () => {
|
|
6625
|
+
_optionalChain([bareWire, 'access', _175 => _175.shutdown, 'optionalCall', _176 => _176()]);
|
|
6626
|
+
return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
|
|
6627
|
+
},
|
|
6628
|
+
cache: {
|
|
6629
|
+
invalidate: () => {
|
|
6630
|
+
},
|
|
6631
|
+
clear: () => {
|
|
6632
|
+
}
|
|
6633
|
+
},
|
|
6634
|
+
...bareWire.adaptiveLimiter ? { adaptiveLimiter: bareWire.adaptiveLimiter } : {}
|
|
6635
|
+
}
|
|
6636
|
+
);
|
|
6637
|
+
return {
|
|
6638
|
+
request,
|
|
6639
|
+
get,
|
|
6640
|
+
post,
|
|
6641
|
+
getText,
|
|
6642
|
+
getJson,
|
|
6643
|
+
postJson,
|
|
6644
|
+
with: (mw) => buildBareMetalDefaultClient(bareWire.with(mw), {
|
|
6645
|
+
...meta,
|
|
6646
|
+
features: {
|
|
6647
|
+
...meta.features,
|
|
6648
|
+
middleware: meta.features.middleware + 1
|
|
6649
|
+
}
|
|
6650
|
+
}),
|
|
6651
|
+
wire: wireAsLifecycle,
|
|
6652
|
+
stats: () => wireAsLifecycle.stats(),
|
|
6653
|
+
cache: wireAsLifecycle.cache,
|
|
6654
|
+
cancelAll: wireAsLifecycle.cancelAll,
|
|
6655
|
+
shutdown: wireAsLifecycle.shutdown,
|
|
6656
|
+
preset: meta.preset,
|
|
6657
|
+
features: meta.features
|
|
6658
|
+
};
|
|
6659
|
+
}
|
|
6318
6660
|
function buildDefaultClient(wire, meta) {
|
|
6319
6661
|
const withPromise = (eff) => _chunkMVGUEJ5Zcjs.withAsyncPromise.call(void 0, (e, env) => _chunkJKHBEWQAcjs.toPromise.call(void 0, e, env))(eff);
|
|
6320
6662
|
const requestRaw = (req) => wire(req);
|
|
@@ -6333,24 +6675,24 @@ function buildDefaultClient(wire, meta) {
|
|
|
6333
6675
|
);
|
|
6334
6676
|
if (meta.useInlineDecode) {
|
|
6335
6677
|
return withPromise(
|
|
6336
|
-
fusedWireAndDecode(requestRaw(req), _optionalChain([init, 'optionalAccess',
|
|
6678
|
+
fusedWireAndDecode(requestRaw(req), _optionalChain([init, 'optionalAccess', _177 => _177.schema]), _optionalChain([init, 'optionalAccess', _178 => _178.schemaName]))
|
|
6337
6679
|
);
|
|
6338
6680
|
}
|
|
6339
6681
|
return withPromise(
|
|
6340
|
-
_chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess',
|
|
6682
|
+
_chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _179 => _179.schema]), _optionalChain([init, 'optionalAccess', _180 => _180.schemaName])))
|
|
6341
6683
|
);
|
|
6342
6684
|
});
|
|
6343
6685
|
const postJson = ((url, bodyObj, init) => {
|
|
6344
6686
|
return withPromise(
|
|
6345
6687
|
_chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
|
|
6346
|
-
encodeJsonBodyEffect(bodyObj, _optionalChain([init, 'optionalAccess',
|
|
6688
|
+
encodeJsonBodyEffect(bodyObj, _optionalChain([init, 'optionalAccess', _181 => _181.bodySchema]), { schemaName: _optionalChain([init, 'optionalAccess', _182 => _182.bodySchemaName]) }),
|
|
6347
6689
|
(bodyText) => {
|
|
6348
6690
|
const req = setHeaderIfMissing("content-type", "application/json")(
|
|
6349
6691
|
setHeaderIfMissing("accept", "application/json")(
|
|
6350
6692
|
buildHttpRequest("POST", url, init, bodyText)
|
|
6351
6693
|
)
|
|
6352
6694
|
);
|
|
6353
|
-
return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess',
|
|
6695
|
+
return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _183 => _183.schema]), _optionalChain([init, 'optionalAccess', _184 => _184.schemaName])));
|
|
6354
6696
|
}
|
|
6355
6697
|
)
|
|
6356
6698
|
);
|
|
@@ -6495,7 +6837,7 @@ function isEnabled(value) {
|
|
|
6495
6837
|
return value !== void 0 && value !== false;
|
|
6496
6838
|
}
|
|
6497
6839
|
function isLeanPreset(preset) {
|
|
6498
|
-
return preset === "minimal" || preset === "proxy" || preset === "highThroughputProxy";
|
|
6840
|
+
return preset === "minimal" || preset === "proxy" || preset === "highThroughputProxy" || preset === "bareMetal";
|
|
6499
6841
|
}
|
|
6500
6842
|
|
|
6501
6843
|
// src/http/layer.ts
|
|
@@ -6615,4 +6957,22 @@ function shutdownDefaultHttpClient(client) {
|
|
|
6615
6957
|
|
|
6616
6958
|
|
|
6617
6959
|
|
|
6618
|
-
|
|
6960
|
+
|
|
6961
|
+
|
|
6962
|
+
|
|
6963
|
+
|
|
6964
|
+
|
|
6965
|
+
|
|
6966
|
+
|
|
6967
|
+
|
|
6968
|
+
|
|
6969
|
+
|
|
6970
|
+
|
|
6971
|
+
|
|
6972
|
+
|
|
6973
|
+
|
|
6974
|
+
|
|
6975
|
+
|
|
6976
|
+
|
|
6977
|
+
|
|
6978
|
+
exports.Request = Request; exports.setHeaderIfMissing = setHeaderIfMissing; exports.defineHttpPolicyPresets = defineHttpPolicyPresets; exports.httpPolicy = httpPolicy; exports.getHttpRequestPolicy = getHttpRequestPolicy; exports.withHttpRequestPolicy = withHttpRequestPolicy; exports.resolveHttpRequestPolicyPresets = resolveHttpRequestPolicyPresets; exports.withHttpPolicyPresets = withHttpPolicyPresets; exports.isHttpError = isHttpError; exports.isValidationError = isValidationError; exports.isCircuitBreakerOpen = isCircuitBreakerOpen; exports.isKnownHttpError = isKnownHttpError; exports.isAbortHttpError = isAbortHttpError; exports.isTimeoutHttpError = isTimeoutHttpError; exports.isFetchHttpError = isFetchHttpError; exports.httpErrorStatus = httpErrorStatus; exports.isRetryableHttpStatus = isRetryableHttpStatus; exports.isRetryableHttpError = isRetryableHttpError; exports.isExternalAbortError = isExternalAbortError; exports.isExternalTimeoutError = isExternalTimeoutError; exports.toHttpError = toHttpError; exports.matchHttpError = matchHttpError; exports.formatHttpError = formatHttpError; exports.defaultRetryableMethods = defaultRetryableMethods; exports.defaultRetryOnStatus = defaultRetryOnStatus; exports.defaultRetryOnError = defaultRetryOnError; exports.backoffDelayMs = backoffDelayMs; exports.retryAfterMs = retryAfterMs; exports.normalizeRetryBudget = normalizeRetryBudget; exports.withRetry = withRetry; exports.resolveHttpPoolKey = resolveHttpPoolKey; exports.HttpConcurrencyPool = HttpConcurrencyPool; exports.LatencyWindow = LatencyWindow; exports.EmaComputer = EmaComputer; exports.computeGradient = computeGradient; exports.computeNewLimit = computeNewLimit; exports.adaptiveLimiterPresets = adaptiveLimiterPresets; exports.makeAdaptiveLimiterConfig = makeAdaptiveLimiterConfig; exports.validateConfig = validateConfig; exports.resolveConfig = resolveConfig; exports.AdaptiveLimiter = AdaptiveLimiter; exports.isPromiseTransportDirect = isPromiseTransportDirect; exports.isTaggedHttpError = isTaggedHttpError; exports.isAbortError = isAbortError; exports.normalizeHttpError = normalizeHttpError; exports.headersOf = headersOf; exports.normalizeHttpHeaders = normalizeHttpHeaders; exports.abortErrorForSignal = abortErrorForSignal; exports.linkAbortSignals = linkAbortSignals; exports.makePromiseHttpTransport = makePromiseHttpTransport; exports.promiseHttpTransport = promiseHttpTransport; exports.makeFetchTransport = makeFetchTransport; exports.makeFetchStreamTransport = makeFetchStreamTransport; exports.decorate = decorate; exports.withMiddleware = withMiddleware; exports.decorateStream = decorateStream; exports.normalizeHeadersInit = normalizeHeadersInit; exports.normalizeRequest = normalizeRequest; exports.resolvePositiveTimeout = resolvePositiveTimeout; exports.makeHttpStats = makeHttpStats; exports.makePool = makePool; exports.makeAdaptiveLimiter = makeAdaptiveLimiter; exports.resolveRequestUrl = resolveRequestUrl; exports.fetchLabel = fetchLabel; exports.timeoutReason = timeoutReason; exports.requestPriority = requestPriority; exports.runTransportEffect = runTransportEffect; exports.runDirectTransport = runDirectTransport; exports.releaseSuccess = releaseSuccess; exports.releaseFailure = releaseFailure; exports.makeHttpStream = makeHttpStream; exports.noopSignal = noopSignal; exports.runPoolTransport = runPoolTransport; exports.makeHttp = makeHttp; exports.withRetryStream = withRetryStream; exports.SEPARATOR = SEPARATOR; exports.DEFAULT_CACHE_RELEVANT_HEADERS = DEFAULT_CACHE_RELEVANT_HEADERS; exports.computeCacheKey = computeCacheKey; exports.parseCacheKey = parseCacheKey; exports.withDedup = withDedup; exports.withBatch = withBatch; exports.now = now; exports.LRUCache = LRUCache; exports.withCache = withCache; exports.clampPriority = clampPriority2; exports.PriorityQueue = PriorityQueue; exports.withPriority = withPriority; exports.LifecycleStatsTracker = LifecycleStatsTracker; exports.validateOrigin = validateOrigin; exports.detectPlatform = detectPlatform; exports.validateFetchAvailable = validateFetchAvailable; exports.executeProbe = executeProbe; exports.makeConnectionStateMap = makeConnectionStateMap; exports.makeBudgetSemaphore = makeBudgetSemaphore; exports.makePrewarmManager = makePrewarmManager; exports.makeLifecycleClient = makeLifecycleClient; exports.makeHttpClient = makeHttpClient; exports.SUPPORTED_ENCODINGS = SUPPORTED_ENCODINGS; exports.makeCompressionMiddleware = makeCompressionMiddleware; exports.makeResponseCompressionMiddleware = makeResponseCompressionMiddleware; exports.makeRequestCompressionMiddleware = makeRequestCompressionMiddleware; exports.makeJsonParseValidationError = makeJsonParseValidationError; exports.decodeJsonBody = decodeJsonBody; exports.encodeJsonBodyEffect = encodeJsonBodyEffect; exports.decodeJsonBodyEffect = decodeJsonBodyEffect; exports.validatedJson = validatedJson; exports.validatedJsonResponse = validatedJsonResponse; exports.buildHttpRequest = buildHttpRequest; exports.validateBareMetalConfig = validateBareMetalConfig; exports.makeBareMetalHttp = makeBareMetalHttp; exports.makeBareMetalHttpStream = makeBareMetalHttpStream; exports.defaultHttpClientPreset = defaultHttpClientPreset; exports.makeDefaultHttpClient = makeDefaultHttpClient; exports.HttpClientService = HttpClientService; exports.makeDefaultHttpClientLayer = makeDefaultHttpClientLayer;
|