brass-runtime 1.19.1 → 1.20.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.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9;
2
2
 
3
3
  var _chunkL6VB5N7Qcjs = require('./chunk-L6VB5N7Q.cjs');
4
4
 
@@ -14,6 +14,8 @@ var _chunkZZ2CMYJLcjs = require('./chunk-ZZ2CMYJL.cjs');
14
14
 
15
15
 
16
16
 
17
+
18
+
17
19
  var _chunkJKHBEWQAcjs = require('./chunk-JKHBEWQA.cjs');
18
20
 
19
21
 
@@ -3182,6 +3184,275 @@ var noopSignal = (() => {
3182
3184
  globalThis.__brassNoopSignal = s;
3183
3185
  return s;
3184
3186
  })();
3187
+ var PoolRequestState = (_class6 = class {
3188
+ constructor(req, url, transport, metrics, pool, adaptiveLimiter, timerWheel, timeoutMs, env, cb, previousSignal, controller, signal, label, startedAt) {;_class6.prototype.__init11.call(this);_class6.prototype.__init12.call(this);_class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this);_class6.prototype.__init15.call(this);_class6.prototype.__init16.call(this);
3189
+ this.req = req;
3190
+ this.url = url;
3191
+ this.transport = transport;
3192
+ this.metrics = metrics;
3193
+ this.pool = pool;
3194
+ this.adaptiveLimiter = adaptiveLimiter;
3195
+ this.timerWheel = timerWheel;
3196
+ this.timeoutMs = timeoutMs;
3197
+ this.env = env;
3198
+ this.cb = cb;
3199
+ this.previousSignal = previousSignal;
3200
+ this.controller = controller;
3201
+ this.signal = signal;
3202
+ this.label = label;
3203
+ this.startedAt = startedAt;
3204
+ }
3205
+
3206
+
3207
+
3208
+
3209
+
3210
+
3211
+
3212
+
3213
+
3214
+
3215
+
3216
+
3217
+
3218
+
3219
+
3220
+ __init11() {this.done = false}
3221
+ __init12() {this.cancelInner = void 0}
3222
+ __init13() {this.timerHandle = void 0}
3223
+ __init14() {this.timeoutHandle = void 0}
3224
+ __init15() {this.lease = void 0}
3225
+ finish(outcome, exit, error) {
3226
+ if (this.done) return;
3227
+ this.done = true;
3228
+ if (this.timerHandle) {
3229
+ this.timerHandle.cancel();
3230
+ this.timerHandle = void 0;
3231
+ }
3232
+ if (this.timeoutHandle !== void 0) {
3233
+ clearTimeout(this.timeoutHandle);
3234
+ this.timeoutHandle = void 0;
3235
+ }
3236
+ if (this.previousSignal) this.previousSignal.removeEventListener("abort", this.boundAbortFromPrevious);
3237
+ this.cancelInner = void 0;
3238
+ _chunkJKHBEWQAcjs.recordAbortablePromiseFinish.call(void 0, this.label, outcome);
3239
+ this.metrics.onFinish({
3240
+ label: this.label,
3241
+ outcome,
3242
+ durationMs: Math.round(performance.now() - this.startedAt),
3243
+ error
3244
+ });
3245
+ this.cb(exit);
3246
+ }
3247
+ finishFailure(error, outcome = "failure") {
3248
+ this.finish(outcome, { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail(error) }, error);
3249
+ }
3250
+ abortCurrent(reason) {
3251
+ if (!this.controller) return;
3252
+ try {
3253
+ this.controller.abort(reason);
3254
+ } catch (e7) {
3255
+ this.controller.abort();
3256
+ }
3257
+ }
3258
+ /**
3259
+ * Bound reference for addEventListener/removeEventListener.
3260
+ * Only allocated when previousSignal is present (not on the hot path).
3261
+ */
3262
+ __init16() {this.boundAbortFromPrevious = void 0}
3263
+ abortFromPrevious() {
3264
+ const error = this.previousSignal ? abortErrorForSignal(this.previousSignal) : { _tag: "Abort" };
3265
+ this.abortCurrent(_optionalChain([this, 'access', _78 => _78.previousSignal, 'optionalAccess', _79 => _79.reason]));
3266
+ const cancel = this.cancelInner;
3267
+ this.cancelInner = void 0;
3268
+ if (this.lease) {
3269
+ releaseFailure(this.lease, this.adaptiveLimiter);
3270
+ this.lease = void 0;
3271
+ }
3272
+ queueMicrotask(() => {
3273
+ this.finishFailure(error);
3274
+ _optionalChain([cancel, 'optionalCall', _80 => _80()]);
3275
+ });
3276
+ }
3277
+ runTransportInner() {
3278
+ const { transport, req, url, signal, env } = this;
3279
+ try {
3280
+ const effect = transport({ request: req, url, signal });
3281
+ if (effect._tag === "Succeed") {
3282
+ if (this.lease) releaseSuccess(this.lease, this.adaptiveLimiter, effect.value);
3283
+ this.finish("success", { _tag: "Success", value: effect.value });
3284
+ } else if (effect._tag === "Fail") {
3285
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3286
+ this.finishFailure(effect.error);
3287
+ } else if (effect._tag === "Async") {
3288
+ try {
3289
+ const cancel = effect.register(env, (exit) => {
3290
+ if (this.done) return;
3291
+ this.cancelInner = void 0;
3292
+ if (exit._tag === "Success") {
3293
+ if (this.lease) releaseSuccess(this.lease, this.adaptiveLimiter, exit.value);
3294
+ this.finish("success", exit);
3295
+ } else {
3296
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3297
+ this.finish("failure", exit, exitError(exit));
3298
+ }
3299
+ });
3300
+ if (!this.done) this.cancelInner = typeof cancel === "function" ? cancel : void 0;
3301
+ } catch (error) {
3302
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3303
+ this.finishFailure(normalizeHttpError(error));
3304
+ }
3305
+ } else {
3306
+ const innerCancel = _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0,
3307
+ effect,
3308
+ env,
3309
+ (exit) => {
3310
+ if (this.done) return;
3311
+ this.cancelInner = void 0;
3312
+ if (exit._tag === "Success") {
3313
+ if (this.lease) releaseSuccess(this.lease, this.adaptiveLimiter, exit.value);
3314
+ this.finish("success", exit);
3315
+ } else {
3316
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3317
+ this.finish("failure", exit, exitError(exit));
3318
+ }
3319
+ }
3320
+ );
3321
+ if (!this.done) this.cancelInner = innerCancel;
3322
+ }
3323
+ } catch (error) {
3324
+ if (this.lease) releaseFailure(this.lease, this.adaptiveLimiter);
3325
+ this.finishFailure(normalizeHttpError(error));
3326
+ }
3327
+ }
3328
+ }, _class6);
3329
+ var runPoolTransport = (req, url, transport, metrics, pool, adaptiveLimiter, timerWheel, timeoutMs) => ({
3330
+ _tag: "Async",
3331
+ register: (env, cb) => {
3332
+ const previousSignal = _optionalChain([req, 'access', _81 => _81.init, 'optionalAccess', _82 => _82.signal]);
3333
+ const controller = new AbortController();
3334
+ const signal = controller.signal;
3335
+ const label = fetchLabel(req, url);
3336
+ const startedAt = performance.now();
3337
+ const state = new PoolRequestState(
3338
+ req,
3339
+ url,
3340
+ transport,
3341
+ metrics,
3342
+ pool,
3343
+ adaptiveLimiter,
3344
+ timerWheel,
3345
+ timeoutMs,
3346
+ env,
3347
+ cb,
3348
+ previousSignal,
3349
+ controller,
3350
+ signal,
3351
+ label,
3352
+ startedAt
3353
+ );
3354
+ _chunkJKHBEWQAcjs.recordAbortablePromiseStart.call(void 0, label);
3355
+ metrics.onStart();
3356
+ if (previousSignal) {
3357
+ state.boundAbortFromPrevious = () => state.abortFromPrevious();
3358
+ if (previousSignal.aborted) {
3359
+ state.abortFromPrevious();
3360
+ return () => void 0;
3361
+ }
3362
+ previousSignal.addEventListener("abort", state.boundAbortFromPrevious, ONCE_OPTIONS);
3363
+ }
3364
+ if (timeoutMs !== void 0 && timeoutMs > 0) {
3365
+ const onTimeout = () => {
3366
+ const reason = timeoutReason(req, url, timeoutMs);
3367
+ if (state.lease) {
3368
+ releaseFailure(state.lease, adaptiveLimiter);
3369
+ state.lease = void 0;
3370
+ }
3371
+ const cancel = state.cancelInner;
3372
+ state.cancelInner = void 0;
3373
+ state.finishFailure(reason, "timeout");
3374
+ state.abortCurrent(reason);
3375
+ _optionalChain([cancel, 'optionalCall', _83 => _83()]);
3376
+ };
3377
+ if (timerWheel) {
3378
+ state.timerHandle = timerWheel.schedule(timeoutMs, onTimeout, startedAt);
3379
+ } else {
3380
+ state.timeoutHandle = setTimeout(onTimeout, timeoutMs);
3381
+ }
3382
+ }
3383
+ if (adaptiveLimiter) {
3384
+ const key = resolveHttpPoolKey(adaptiveLimiter.keyResolver, req, url);
3385
+ const syncLease = adaptiveLimiter.tryAcquireSync(key, signal);
3386
+ if (syncLease) {
3387
+ state.lease = syncLease;
3388
+ } else {
3389
+ adaptiveLimiter.acquire(key, signal, { priority: requestPriority(req) }).then(
3390
+ (asyncLease) => {
3391
+ if (state.done) {
3392
+ asyncLease.release(0);
3393
+ return;
3394
+ }
3395
+ state.lease = asyncLease;
3396
+ state.runTransportInner();
3397
+ },
3398
+ (err) => {
3399
+ if (state.done) return;
3400
+ state.finishFailure(normalizeHttpError(err));
3401
+ }
3402
+ );
3403
+ return () => {
3404
+ if (state.done) return;
3405
+ const cancel = state.cancelInner;
3406
+ state.cancelInner = void 0;
3407
+ state.abortCurrent();
3408
+ if (state.lease) releaseFailure(state.lease, adaptiveLimiter);
3409
+ state.finish("interrupt", { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.interrupt() });
3410
+ _optionalChain([cancel, 'optionalCall', _84 => _84()]);
3411
+ };
3412
+ }
3413
+ } else if (pool) {
3414
+ const key = resolveHttpPoolKey(pool.keyResolver, req, url);
3415
+ const syncLease = pool.tryAcquireSync(key, signal);
3416
+ if (syncLease) {
3417
+ state.lease = syncLease;
3418
+ } else {
3419
+ pool.acquire(key, signal).then(
3420
+ (asyncLease) => {
3421
+ if (state.done) {
3422
+ asyncLease.release();
3423
+ return;
3424
+ }
3425
+ state.lease = asyncLease;
3426
+ state.runTransportInner();
3427
+ },
3428
+ (err) => {
3429
+ if (state.done) return;
3430
+ state.finishFailure(normalizeHttpError(err));
3431
+ }
3432
+ );
3433
+ return () => {
3434
+ if (state.done) return;
3435
+ const cancel = state.cancelInner;
3436
+ state.cancelInner = void 0;
3437
+ state.abortCurrent();
3438
+ if (state.lease) releaseFailure(state.lease, void 0);
3439
+ state.finish("interrupt", { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.interrupt() });
3440
+ _optionalChain([cancel, 'optionalCall', _85 => _85()]);
3441
+ };
3442
+ }
3443
+ }
3444
+ state.runTransportInner();
3445
+ return () => {
3446
+ if (state.done) return;
3447
+ const cancel = state.cancelInner;
3448
+ state.cancelInner = void 0;
3449
+ state.abortCurrent();
3450
+ if (state.lease) releaseFailure(state.lease, adaptiveLimiter);
3451
+ state.finish("interrupt", { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.interrupt() });
3452
+ _optionalChain([cancel, 'optionalCall', _86 => _86()]);
3453
+ };
3454
+ }
3455
+ });
3185
3456
  function makeHttp(cfg = {}) {
3186
3457
  validateMakeHttpConfig(cfg);
3187
3458
  const baseUrl = _nullishCoalesce(cfg.baseUrl, () => ( ""));
@@ -3200,53 +3471,18 @@ function makeHttp(cfg = {}) {
3200
3471
  if (!adaptiveLimiter && !pool && timeoutMs === void 0) {
3201
3472
  return runDirectTransport(req, url, transport, metrics);
3202
3473
  }
3203
- return _chunkJKHBEWQAcjs.fromPromiseAbortable.call(void 0,
3204
- async (signal, env) => {
3205
- let lease;
3206
- const linkedSignal = linkAbortSignals(signal, _optionalChain([req, 'access', _78 => _78.init, 'optionalAccess', _79 => _79.signal]));
3207
- try {
3208
- if (linkedSignal.signal.aborted) throw abortErrorForSignal(linkedSignal.signal);
3209
- if (adaptiveLimiter) {
3210
- const key = resolveHttpPoolKey(adaptiveLimiter.keyResolver, req, url);
3211
- lease = await adaptiveLimiter.acquire(key, linkedSignal.signal, { priority: requestPriority(req) });
3212
- } else if (pool) {
3213
- const key = resolveHttpPoolKey(pool.keyResolver, req, url);
3214
- lease = await pool.acquire(key, linkedSignal.signal);
3215
- }
3216
- const response = await runTransportEffect(
3217
- transport({ request: req, url, signal: linkedSignal.signal }),
3218
- env,
3219
- linkedSignal.signal
3220
- );
3221
- lease = releaseSuccess(lease, adaptiveLimiter, response);
3222
- return response;
3223
- } finally {
3224
- linkedSignal.cleanup();
3225
- if (lease) {
3226
- releaseFailure(lease, adaptiveLimiter);
3227
- }
3228
- }
3229
- },
3230
- normalizeHttpError,
3231
- {
3232
- label: fetchLabel(req, url),
3233
- timeoutMs,
3234
- timeoutReason: timeoutMs ? () => timeoutReason(req, url, timeoutMs) : void 0,
3235
- onStart: metrics.onStart,
3236
- onFinish: metrics.onFinish
3237
- }
3238
- );
3474
+ return runPoolTransport(req, url, transport, metrics, pool, adaptiveLimiter, void 0, timeoutMs);
3239
3475
  };
3240
3476
  const metadata = {};
3241
3477
  if (adaptiveLimiter) metadata.adaptiveLimiter = adaptiveLimiter;
3242
3478
  if (adaptiveLimiter || destroyTransport) {
3243
3479
  metadata.destroy = () => {
3244
- _optionalChain([adaptiveLimiter, 'optionalAccess', _80 => _80.destroy, 'call', _81 => _81()]);
3245
- _optionalChain([destroyTransport, 'optionalCall', _82 => _82()]);
3480
+ _optionalChain([adaptiveLimiter, 'optionalAccess', _87 => _87.destroy, 'call', _88 => _88()]);
3481
+ _optionalChain([destroyTransport, 'optionalCall', _89 => _89()]);
3246
3482
  };
3247
3483
  metadata.shutdown = () => {
3248
- _optionalChain([adaptiveLimiter, 'optionalAccess', _83 => _83.shutdown, 'call', _84 => _84()]);
3249
- _optionalChain([destroyTransport, 'optionalCall', _85 => _85()]);
3484
+ _optionalChain([adaptiveLimiter, 'optionalAccess', _90 => _90.shutdown, 'call', _91 => _91()]);
3485
+ _optionalChain([destroyTransport, 'optionalCall', _92 => _92()]);
3250
3486
  };
3251
3487
  }
3252
3488
  return decorate(run, metrics.snapshot, metadata);
@@ -3269,7 +3505,7 @@ var withRetryStream = (p) => (next) => {
3269
3505
  if (!canRetry) return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, e);
3270
3506
  const d = delayWithinBudget(backoffDelayMs(attempt, p.baseDelayMs, p.maxDelayMs));
3271
3507
  if (d <= 0 && maxElapsedMs !== void 0) return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, e);
3272
- _optionalChain([p, 'access', _86 => _86.onRetry, 'optionalCall', _87 => _87({
3508
+ _optionalChain([p, 'access', _93 => _93.onRetry, 'optionalCall', _94 => _94({
3273
3509
  attempt,
3274
3510
  delayMs: d,
3275
3511
  error: e,
@@ -3287,7 +3523,7 @@ var withRetryStream = (p) => (next) => {
3287
3523
  const rawDelay = ra === void 0 ? backoffDelayMs(attempt, p.baseDelayMs, p.maxDelayMs) : Math.min(ra, p.maxDelayMs);
3288
3524
  const d = delayWithinBudget(rawDelay);
3289
3525
  if (d <= 0 && maxElapsedMs !== void 0) return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, w);
3290
- _optionalChain([p, 'access', _88 => _88.onRetry, 'optionalCall', _89 => _89({
3526
+ _optionalChain([p, 'access', _95 => _95.onRetry, 'optionalCall', _96 => _96({
3291
3527
  attempt,
3292
3528
  delayMs: d,
3293
3529
  error: void 0,
@@ -3484,7 +3720,7 @@ function safeEmit(onEvent, event) {
3484
3720
  if (!onEvent) return;
3485
3721
  try {
3486
3722
  onEvent(event);
3487
- } catch (e7) {
3723
+ } catch (e8) {
3488
3724
  }
3489
3725
  }
3490
3726
  function causeDefectMessage(cause) {
@@ -3494,8 +3730,8 @@ function causeDefectMessage(cause) {
3494
3730
  }
3495
3731
  function withDedup(config) {
3496
3732
  const inFlight = /* @__PURE__ */ new Map();
3497
- const customKeyFn = _optionalChain([config, 'optionalAccess', _90 => _90.dedupKey]);
3498
- const onEvent = _optionalChain([config, 'optionalAccess', _91 => _91.onEvent]);
3733
+ const customKeyFn = _optionalChain([config, 'optionalAccess', _97 => _97.dedupKey]);
3734
+ const onEvent = _optionalChain([config, 'optionalAccess', _98 => _98.onEvent]);
3499
3735
  const dedupKeyCtx = makeDedupKeyContext("");
3500
3736
  return (next) => {
3501
3737
  return (req) => {
@@ -3512,7 +3748,7 @@ function withDedup(config) {
3512
3748
  } else if (customKeyFn) {
3513
3749
  try {
3514
3750
  key = customKeyFn(req);
3515
- } catch (e8) {
3751
+ } catch (e9) {
3516
3752
  return next(req);
3517
3753
  }
3518
3754
  if (!key) {
@@ -3639,7 +3875,7 @@ function safeEmitBatch(onEvent, event) {
3639
3875
  if (!onEvent) return;
3640
3876
  try {
3641
3877
  onEvent(event);
3642
- } catch (e9) {
3878
+ } catch (e10) {
3643
3879
  }
3644
3880
  }
3645
3881
  function causeDefectMessage2(cause) {
@@ -3722,7 +3958,7 @@ function withBatch(config, onEvent) {
3722
3958
  let key;
3723
3959
  try {
3724
3960
  key = batchKey(req);
3725
- } catch (e10) {
3961
+ } catch (e11) {
3726
3962
  return next(req);
3727
3963
  }
3728
3964
  if (!key) {
@@ -3823,10 +4059,10 @@ var now = typeof performance !== "undefined" && typeof performance.now === "func
3823
4059
  function isExpired(node) {
3824
4060
  return now() - node.storedAt >= node.ttlMs;
3825
4061
  }
3826
- var LRUCache = (_class6 = class {
3827
- __init11() {this.map = /* @__PURE__ */ new Map()}
3828
- __init12() {this.head = null}
3829
- __init13() {this.tail = null}
4062
+ var LRUCache = (_class7 = class {
4063
+ __init17() {this.map = /* @__PURE__ */ new Map()}
4064
+ __init18() {this.head = null}
4065
+ __init19() {this.tail = null}
3830
4066
 
3831
4067
 
3832
4068
  /**
@@ -3843,7 +4079,7 @@ var LRUCache = (_class6 = class {
3843
4079
  * const cache = new LRUCache<number>({ maxEntries: 50 });
3844
4080
  * ```
3845
4081
  */
3846
- constructor(config = {}) {;_class6.prototype.__init11.call(this);_class6.prototype.__init12.call(this);_class6.prototype.__init13.call(this);
4082
+ constructor(config = {}) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);
3847
4083
  const max = _nullishCoalesce(config.maxEntries, () => ( 1024));
3848
4084
  this.maxEntries = Math.max(1, Math.floor(max));
3849
4085
  this.onEvict = config.onEvict;
@@ -4025,7 +4261,7 @@ var LRUCache = (_class6 = class {
4025
4261
  this.onEvict(1);
4026
4262
  }
4027
4263
  }
4028
- }, _class6);
4264
+ }, _class7);
4029
4265
 
4030
4266
  // src/http/lifecycle/responseCache.ts
4031
4267
  function clamp3(n, min, max) {
@@ -4035,23 +4271,23 @@ function safeEmit2(onEvent, event) {
4035
4271
  if (!onEvent) return;
4036
4272
  try {
4037
4273
  onEvent(event);
4038
- } catch (e11) {
4274
+ } catch (e12) {
4039
4275
  }
4040
4276
  }
4041
4277
  function withCache(config) {
4042
- const ttlSeconds = clamp3(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _92 => _92.ttlSeconds]), () => ( 60)), 1, 86400);
4278
+ const ttlSeconds = clamp3(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _99 => _99.ttlSeconds]), () => ( 60)), 1, 86400);
4043
4279
  const ttlMs = ttlSeconds * 1e3;
4044
- const maxEntries = Math.max(1, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _93 => _93.maxEntries]), () => ( 1024))));
4045
- const staleWhileRevalidate = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _94 => _94.staleWhileRevalidate]), () => ( false));
4046
- const cachePolicy = _optionalChain([config, 'optionalAccess', _95 => _95.cachePolicy]);
4047
- const cacheRelevantHeaders = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _96 => _96.cacheRelevantHeaders]), () => ( []));
4048
- const baseUrl = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _97 => _97.baseUrl]), () => ( ""));
4049
- const onEvent = _optionalChain([config, 'optionalAccess', _98 => _98.onEvent]);
4050
- const onLifecycleEvent = _optionalChain([config, 'optionalAccess', _99 => _99.onLifecycleEvent]);
4280
+ const maxEntries = Math.max(1, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _100 => _100.maxEntries]), () => ( 1024))));
4281
+ const staleWhileRevalidate = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _101 => _101.staleWhileRevalidate]), () => ( false));
4282
+ const cachePolicy = _optionalChain([config, 'optionalAccess', _102 => _102.cachePolicy]);
4283
+ const cacheRelevantHeaders = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _103 => _103.cacheRelevantHeaders]), () => ( []));
4284
+ const baseUrl = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _104 => _104.baseUrl]), () => ( ""));
4285
+ const onEvent = _optionalChain([config, 'optionalAccess', _105 => _105.onEvent]);
4286
+ const onLifecycleEvent = _optionalChain([config, 'optionalAccess', _106 => _106.onLifecycleEvent]);
4051
4287
  const cacheKeyCtx = makeCacheKeyContext(baseUrl, cacheRelevantHeaders);
4052
4288
  const cache = new LRUCache({
4053
4289
  maxEntries,
4054
- onEvict: (count) => _optionalChain([onLifecycleEvent, 'optionalCall', _100 => _100({ type: "cache-eviction", count })])
4290
+ onEvict: (count) => _optionalChain([onLifecycleEvent, 'optionalCall', _107 => _107({ type: "cache-eviction", count })])
4055
4291
  });
4056
4292
  const revalidating = /* @__PURE__ */ new Set();
4057
4293
  const invalidate = (key) => {
@@ -4072,11 +4308,11 @@ function withCache(config) {
4072
4308
  register: (env, cb) => {
4073
4309
  const cached = cache.get(key);
4074
4310
  if (cached !== void 0) {
4075
- _optionalChain([onLifecycleEvent, 'optionalCall', _101 => _101({ type: "cache-hit", cacheKey: key })]);
4311
+ _optionalChain([onLifecycleEvent, 'optionalCall', _108 => _108({ type: "cache-hit", cacheKey: key })]);
4076
4312
  cb({ _tag: "Success", value: cached });
4077
4313
  return;
4078
4314
  }
4079
- _optionalChain([onLifecycleEvent, 'optionalCall', _102 => _102({ type: "cache-miss", cacheKey: key })]);
4315
+ _optionalChain([onLifecycleEvent, 'optionalCall', _109 => _109({ type: "cache-miss", cacheKey: key })]);
4080
4316
  const innerEffect = next(req);
4081
4317
  return _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, innerEffect, env, (exit) => {
4082
4318
  if (exit._tag === "Success") {
@@ -4133,16 +4369,16 @@ function withCache(config) {
4133
4369
  if (cached !== void 0) {
4134
4370
  const expiresAt = expirationMap.get(key);
4135
4371
  if (expiresAt !== void 0 && now() < expiresAt) {
4136
- _optionalChain([onLifecycleEvent, 'optionalCall', _103 => _103({ type: "cache-hit", cacheKey: key })]);
4372
+ _optionalChain([onLifecycleEvent, 'optionalCall', _110 => _110({ type: "cache-hit", cacheKey: key })]);
4137
4373
  cb({ _tag: "Success", value: cached });
4138
4374
  return;
4139
4375
  }
4140
- _optionalChain([onLifecycleEvent, 'optionalCall', _104 => _104({ type: "cache-hit", cacheKey: key })]);
4376
+ _optionalChain([onLifecycleEvent, 'optionalCall', _111 => _111({ type: "cache-hit", cacheKey: key })]);
4141
4377
  cb({ _tag: "Success", value: cached });
4142
4378
  triggerRevalidation(next, req, key);
4143
4379
  return;
4144
4380
  }
4145
- _optionalChain([onLifecycleEvent, 'optionalCall', _105 => _105({ type: "cache-miss", cacheKey: key })]);
4381
+ _optionalChain([onLifecycleEvent, 'optionalCall', _112 => _112({ type: "cache-miss", cacheKey: key })]);
4146
4382
  const innerEffect = next(req);
4147
4383
  const handleSuccess = (res) => {
4148
4384
  swrStoreIfCacheable(req, res, key);
@@ -4202,9 +4438,9 @@ function comparePriority(a, b) {
4202
4438
  if (a.priority !== b.priority) return a.priority - b.priority;
4203
4439
  return a.arrivalOrder - b.arrivalOrder;
4204
4440
  }
4205
- var PriorityQueue = (_class7 = class {constructor() { _class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this); }
4206
- __init14() {this.heap = []}
4207
- __init15() {this.counter = 0}
4441
+ var PriorityQueue = (_class8 = class {constructor() { _class8.prototype.__init20.call(this);_class8.prototype.__init21.call(this); }
4442
+ __init20() {this.heap = []}
4443
+ __init21() {this.counter = 0}
4208
4444
  /**
4209
4445
  * Returns the number of entries in the queue (including cancelled entries).
4210
4446
  *
@@ -4388,14 +4624,14 @@ var PriorityQueue = (_class7 = class {constructor() { _class7.prototype.__init14
4388
4624
  index = smallest;
4389
4625
  }
4390
4626
  }
4391
- }, _class7);
4627
+ }, _class8);
4392
4628
 
4393
4629
  // src/http/lifecycle/priorityScheduler.ts
4394
4630
  var DEFAULT_CONCURRENCY2 = 32;
4395
4631
  function extractPriority(req) {
4396
4632
  const fromPolicy = getHttpRequestPolicy(req).priority;
4397
4633
  if (fromPolicy !== void 0) return clampPriority2(fromPolicy);
4398
- const fromInit = _optionalChain([req, 'access', _106 => _106.init, 'optionalAccess', _107 => _107.priority]);
4634
+ const fromInit = _optionalChain([req, 'access', _113 => _113.init, 'optionalAccess', _114 => _114.priority]);
4399
4635
  if (fromInit !== void 0) return clampPriority2(fromInit);
4400
4636
  return 5;
4401
4637
  }
@@ -4403,13 +4639,13 @@ function safeEmit3(onEvent, event) {
4403
4639
  if (!onEvent) return;
4404
4640
  try {
4405
4641
  onEvent(event);
4406
- } catch (e12) {
4642
+ } catch (e13) {
4407
4643
  }
4408
4644
  }
4409
4645
  function withPriority(config) {
4410
- const concurrency = resolveConcurrency(_optionalChain([config, 'optionalAccess', _108 => _108.concurrency]));
4411
- const queueTimeoutMs = resolveQueueTimeout(_optionalChain([config, 'optionalAccess', _109 => _109.queueTimeoutMs]));
4412
- const onEvent = _optionalChain([config, 'optionalAccess', _110 => _110.onEvent]);
4646
+ const concurrency = resolveConcurrency(_optionalChain([config, 'optionalAccess', _115 => _115.concurrency]));
4647
+ const queueTimeoutMs = resolveQueueTimeout(_optionalChain([config, 'optionalAccess', _116 => _116.queueTimeoutMs]));
4648
+ const onEvent = _optionalChain([config, 'optionalAccess', _117 => _117.onEvent]);
4413
4649
  const queue = new PriorityQueue();
4414
4650
  let inFlight = 0;
4415
4651
  const queueDepth = () => {
@@ -4454,7 +4690,7 @@ function withPriority(config) {
4454
4690
  cb({ _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail({ _tag: "Abort" }) });
4455
4691
  };
4456
4692
  signal.addEventListener("abort", abortHandler, { once: true });
4457
- } else if (_optionalChain([signal, 'optionalAccess', _111 => _111.aborted])) {
4693
+ } else if (_optionalChain([signal, 'optionalAccess', _118 => _118.aborted])) {
4458
4694
  entry.cancelled = true;
4459
4695
  cb({ _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail({ _tag: "Abort" }) });
4460
4696
  return;
@@ -4500,7 +4736,7 @@ function withPriority(config) {
4500
4736
  clearTimeout(queued.timer);
4501
4737
  queued.timer = void 0;
4502
4738
  }
4503
- if (_optionalChain([queued, 'access', _112 => _112.signal, 'optionalAccess', _113 => _113.aborted])) {
4739
+ if (_optionalChain([queued, 'access', _119 => _119.signal, 'optionalAccess', _120 => _120.aborted])) {
4504
4740
  queued.cb({ _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail({ _tag: "Abort" }) });
4505
4741
  continue;
4506
4742
  }
@@ -4520,23 +4756,23 @@ function resolveQueueTimeout(value) {
4520
4756
  return n > 0 ? n : void 0;
4521
4757
  }
4522
4758
  function getSignal(req) {
4523
- return _optionalChain([req, 'access', _114 => _114.init, 'optionalAccess', _115 => _115.signal]);
4759
+ return _optionalChain([req, 'access', _121 => _121.init, 'optionalAccess', _122 => _122.signal]);
4524
4760
  }
4525
4761
 
4526
4762
  // src/http/lifecycle/stats.ts
4527
- var LifecycleStatsTracker = (_class8 = class {
4528
- __init16() {this._cacheHits = 0}
4529
- __init17() {this._cacheMisses = 0}
4530
- __init18() {this._cacheEvictions = 0}
4531
- __init19() {this._dedupHits = 0}
4532
- __init20() {this._dedupActive = 0}
4533
- __init21() {this._queueDepth = 0}
4534
- __init22() {this._requestsStarted = 0}
4535
- __init23() {this._requestsCompleted = 0}
4536
- __init24() {this._requestsFailed = 0}
4537
- __init25() {this._retries = 0}
4538
- __init26() {this._batchDispatches = 0}
4539
- __init27() {this._batchedRequests = 0}
4763
+ var LifecycleStatsTracker = (_class9 = class {
4764
+ __init22() {this._cacheHits = 0}
4765
+ __init23() {this._cacheMisses = 0}
4766
+ __init24() {this._cacheEvictions = 0}
4767
+ __init25() {this._dedupHits = 0}
4768
+ __init26() {this._dedupActive = 0}
4769
+ __init27() {this._queueDepth = 0}
4770
+ __init28() {this._requestsStarted = 0}
4771
+ __init29() {this._requestsCompleted = 0}
4772
+ __init30() {this._requestsFailed = 0}
4773
+ __init31() {this._retries = 0}
4774
+ __init32() {this._batchDispatches = 0}
4775
+ __init33() {this._batchedRequests = 0}
4540
4776
 
4541
4777
 
4542
4778
  /**
@@ -4556,7 +4792,7 @@ var LifecycleStatsTracker = (_class8 = class {
4556
4792
  * });
4557
4793
  * ```
4558
4794
  */
4559
- constructor(opts) {;_class8.prototype.__init16.call(this);_class8.prototype.__init17.call(this);_class8.prototype.__init18.call(this);_class8.prototype.__init19.call(this);_class8.prototype.__init20.call(this);_class8.prototype.__init21.call(this);_class8.prototype.__init22.call(this);_class8.prototype.__init23.call(this);_class8.prototype.__init24.call(this);_class8.prototype.__init25.call(this);_class8.prototype.__init26.call(this);_class8.prototype.__init27.call(this);
4795
+ constructor(opts) {;_class9.prototype.__init22.call(this);_class9.prototype.__init23.call(this);_class9.prototype.__init24.call(this);_class9.prototype.__init25.call(this);_class9.prototype.__init26.call(this);_class9.prototype.__init27.call(this);_class9.prototype.__init28.call(this);_class9.prototype.__init29.call(this);_class9.prototype.__init30.call(this);_class9.prototype.__init31.call(this);_class9.prototype.__init32.call(this);_class9.prototype.__init33.call(this);
4560
4796
  this._onEvent = opts.onEvent;
4561
4797
  this._wireStats = opts.wireStats;
4562
4798
  }
@@ -4741,7 +4977,7 @@ var LifecycleStatsTracker = (_class8 = class {
4741
4977
  ...extra
4742
4978
  };
4743
4979
  this._onEvent(event);
4744
- } catch (e13) {
4980
+ } catch (e14) {
4745
4981
  }
4746
4982
  }
4747
4983
  // --- Snapshot ---
@@ -4783,7 +5019,7 @@ var LifecycleStatsTracker = (_class8 = class {
4783
5019
  wire: this._wireStats()
4784
5020
  });
4785
5021
  }
4786
- }, _class8);
5022
+ }, _class9);
4787
5023
 
4788
5024
  // src/http/prewarm/validation.ts
4789
5025
  function validateOrigin(origin) {
@@ -4804,7 +5040,7 @@ function validateOrigin(origin) {
4804
5040
  let parsed;
4805
5041
  try {
4806
5042
  parsed = new URL(stripped);
4807
- } catch (e14) {
5043
+ } catch (e15) {
4808
5044
  throw new Error(
4809
5045
  `validateOrigin: invalid origin "${origin}" \u2014 must be a valid URL origin (scheme + host + optional port)`
4810
5046
  );
@@ -4909,9 +5145,9 @@ async function executeProbeViaClient(client, url, signal) {
4909
5145
  resolve({ ok: true });
4910
5146
  } else {
4911
5147
  const cause = exit.cause;
4912
- if (_optionalChain([cause, 'optionalAccess', _116 => _116._tag]) === "Fail") {
5148
+ if (_optionalChain([cause, 'optionalAccess', _123 => _123._tag]) === "Fail") {
4913
5149
  const err = cause.error;
4914
- resolve({ ok: false, error: _nullishCoalesce(_nullishCoalesce(_optionalChain([err, 'optionalAccess', _117 => _117.message]), () => ( _optionalChain([err, 'optionalAccess', _118 => _118._tag]))), () => ( "Unknown error")) });
5150
+ resolve({ ok: false, error: _nullishCoalesce(_nullishCoalesce(_optionalChain([err, 'optionalAccess', _124 => _124.message]), () => ( _optionalChain([err, 'optionalAccess', _125 => _125._tag]))), () => ( "Unknown error")) });
4915
5151
  } else {
4916
5152
  resolve({ ok: false, error: "cancelled" });
4917
5153
  }
@@ -5069,7 +5305,7 @@ function makePrewarmManager(config) {
5069
5305
  if (onEvent) {
5070
5306
  try {
5071
5307
  onEvent(event);
5072
- } catch (e15) {
5308
+ } catch (e16) {
5073
5309
  }
5074
5310
  }
5075
5311
  }
@@ -5287,7 +5523,7 @@ function makeLifecycleClient(config = {}) {
5287
5523
  priorityMiddleware = withPriority({
5288
5524
  ...priorityConfig2,
5289
5525
  onEvent: (event) => {
5290
- tracker.setQueueDepth(_nullishCoalesce(_optionalChain([priorityMiddleware, 'optionalAccess', _119 => _119.queueDepth, 'call', _120 => _120()]), () => ( 0)));
5526
+ tracker.setQueueDepth(_nullishCoalesce(_optionalChain([priorityMiddleware, 'optionalAccess', _126 => _126.queueDepth, 'call', _127 => _127()]), () => ( 0)));
5291
5527
  tracker.emit(event.type, { priority: event.priority });
5292
5528
  }
5293
5529
  });
@@ -5350,9 +5586,9 @@ function makeLifecycleClient(config = {}) {
5350
5586
  attempt: event.attempt,
5351
5587
  delayMs: event.delayMs,
5352
5588
  status: event.status,
5353
- errorTag: _optionalChain([event, 'access', _121 => _121.error, 'optionalAccess', _122 => _122._tag])
5589
+ errorTag: _optionalChain([event, 'access', _128 => _128.error, 'optionalAccess', _129 => _129._tag])
5354
5590
  });
5355
- _optionalChain([retryConfig2, 'access', _123 => _123.onRetry, 'optionalCall', _124 => _124(event)]);
5591
+ _optionalChain([retryConfig2, 'access', _130 => _130.onRetry, 'optionalCall', _131 => _131(event)]);
5356
5592
  }
5357
5593
  })(composedFn);
5358
5594
  }
@@ -5384,13 +5620,13 @@ function makeLifecycleClient(config = {}) {
5384
5620
  }
5385
5621
  }
5386
5622
  return buildLifecycleClient(composedFn, tracker, {
5387
- cacheInvalidate: _nullishCoalesce(_optionalChain([cacheLayer, 'optionalAccess', _125 => _125.invalidate]), () => ( noopInvalidate)),
5388
- cacheClear: _nullishCoalesce(_optionalChain([cacheLayer, 'optionalAccess', _126 => _126.clear]), () => ( noopClear)),
5623
+ cacheInvalidate: _nullishCoalesce(_optionalChain([cacheLayer, 'optionalAccess', _132 => _132.invalidate]), () => ( noopInvalidate)),
5624
+ cacheClear: _nullishCoalesce(_optionalChain([cacheLayer, 'optionalAccess', _133 => _133.clear]), () => ( noopClear)),
5389
5625
  cancelAll: () => cancelActiveRequests(activeCancelers, prewarmMgr),
5390
5626
  shutdown: () => shutdownClient(activeCancelers, prewarmMgr, wireClient.shutdown),
5391
5627
  activeCancelers,
5392
5628
  adaptiveLimiter: wireClient.adaptiveLimiter,
5393
- queueDepth: _optionalChain([priorityMiddleware, 'optionalAccess', _127 => _127.queueDepth]),
5629
+ queueDepth: _optionalChain([priorityMiddleware, 'optionalAccess', _134 => _134.queueDepth]),
5394
5630
  prewarmManager: prewarmMgr,
5395
5631
  afterResponse: hasPrewarm ? config.prewarm.afterResponse : void 0
5396
5632
  });
@@ -5402,14 +5638,14 @@ function noopInvalidate(_key) {
5402
5638
  }
5403
5639
  function noopClear() {
5404
5640
  }
5405
- function buildLifecycleClient(fn2, tracker, internals) {
5406
- const client = (req) => trackRequest(fn2, req, tracker, internals);
5641
+ function buildLifecycleClient(fn3, tracker, internals) {
5642
+ const client = (req) => trackRequest(fn3, req, tracker, internals);
5407
5643
  const stats = () => {
5408
- tracker.setQueueDepth(_nullishCoalesce(_optionalChain([internals, 'access', _128 => _128.queueDepth, 'optionalCall', _129 => _129()]), () => ( 0)));
5644
+ tracker.setQueueDepth(_nullishCoalesce(_optionalChain([internals, 'access', _135 => _135.queueDepth, 'optionalCall', _136 => _136()]), () => ( 0)));
5409
5645
  return tracker.snapshot();
5410
5646
  };
5411
5647
  const withMw = (mw) => {
5412
- const wrappedFn = mw(withLifecycleMetadata(fn2, internals));
5648
+ const wrappedFn = mw(withLifecycleMetadata(fn3, internals));
5413
5649
  return buildLifecycleClient(wrappedFn, tracker, internals);
5414
5650
  };
5415
5651
  const lifecycleClient = Object.assign(client, {
@@ -5425,9 +5661,9 @@ function buildLifecycleClient(fn2, tracker, internals) {
5425
5661
  });
5426
5662
  return lifecycleClient;
5427
5663
  }
5428
- function withLifecycleMetadata(fn2, internals) {
5429
- if (!internals.adaptiveLimiter) return fn2;
5430
- return Object.assign(((req) => fn2(req)), {
5664
+ function withLifecycleMetadata(fn3, internals) {
5665
+ if (!internals.adaptiveLimiter) return fn3;
5666
+ return Object.assign(((req) => fn3(req)), {
5431
5667
  adaptiveLimiter: internals.adaptiveLimiter
5432
5668
  });
5433
5669
  }
@@ -5435,7 +5671,7 @@ function cancelActiveRequests(activeCancelers, prewarmMgr) {
5435
5671
  for (const cancel of Array.from(activeCancelers).reverse()) {
5436
5672
  try {
5437
5673
  cancel();
5438
- } catch (e16) {
5674
+ } catch (e17) {
5439
5675
  }
5440
5676
  }
5441
5677
  if (prewarmMgr) {
@@ -5445,14 +5681,14 @@ function cancelActiveRequests(activeCancelers, prewarmMgr) {
5445
5681
  }
5446
5682
  function shutdownClient(activeCancelers, prewarmMgr, wireShutdown) {
5447
5683
  cancelActiveRequests(activeCancelers, prewarmMgr);
5448
- _optionalChain([wireShutdown, 'optionalCall', _130 => _130()]);
5684
+ _optionalChain([wireShutdown, 'optionalCall', _137 => _137()]);
5449
5685
  return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, void 0);
5450
5686
  }
5451
- function trackRequest(fn2, req, tracker, internals) {
5687
+ function trackRequest(fn3, req, tracker, internals) {
5452
5688
  return {
5453
5689
  _tag: "Async",
5454
5690
  register: (env, cb) => {
5455
- const previousSignal = _optionalChain([req, 'access', _131 => _131.init, 'optionalAccess', _132 => _132.signal]);
5691
+ const previousSignal = _optionalChain([req, 'access', _138 => _138.init, 'optionalAccess', _139 => _139.signal]);
5456
5692
  let done = false;
5457
5693
  let abortedByPreviousSignal = false;
5458
5694
  let abortedByLifecycle = false;
@@ -5461,7 +5697,7 @@ function trackRequest(fn2, req, tracker, internals) {
5461
5697
  if (done) return;
5462
5698
  done = true;
5463
5699
  const exit = (abortedByPreviousSignal || abortedByLifecycle) && exit0._tag === "Failure" && _chunkMVGUEJ5Zcjs.Cause.isInterruptedOnly(exit0.cause) ? { _tag: "Failure", cause: _chunkMVGUEJ5Zcjs.Cause.fail({ _tag: "Abort" }) } : exit0;
5464
- _optionalChain([previousSignal, 'optionalAccess', _133 => _133.removeEventListener, 'call', _134 => _134("abort", abortFromPrevious)]);
5700
+ _optionalChain([previousSignal, 'optionalAccess', _140 => _140.removeEventListener, 'call', _141 => _141("abort", abortFromPrevious)]);
5465
5701
  internals.activeCancelers.delete(cancelFromLifecycle);
5466
5702
  if (exit._tag === "Success") {
5467
5703
  tracker.requestCompleted();
@@ -5474,7 +5710,7 @@ function trackRequest(fn2, req, tracker, internals) {
5474
5710
  });
5475
5711
  }
5476
5712
  }
5477
- } catch (e17) {
5713
+ } catch (e18) {
5478
5714
  }
5479
5715
  }
5480
5716
  } else {
@@ -5499,18 +5735,18 @@ function trackRequest(fn2, req, tracker, internals) {
5499
5735
  abortedByPreviousSignal = true;
5500
5736
  cancelActive();
5501
5737
  };
5502
- if (!_optionalChain([previousSignal, 'optionalAccess', _135 => _135.aborted])) {
5503
- _optionalChain([previousSignal, 'optionalAccess', _136 => _136.addEventListener, 'call', _137 => _137("abort", abortFromPrevious, { once: true })]);
5738
+ if (!_optionalChain([previousSignal, 'optionalAccess', _142 => _142.aborted])) {
5739
+ _optionalChain([previousSignal, 'optionalAccess', _143 => _143.addEventListener, 'call', _144 => _144("abort", abortFromPrevious, { once: true })]);
5504
5740
  }
5505
5741
  internals.activeCancelers.add(cancelFromLifecycle);
5506
5742
  tracker.requestStarted();
5507
5743
  tracker.emit("request-start");
5508
- if (_optionalChain([previousSignal, 'optionalAccess', _138 => _138.aborted])) {
5744
+ if (_optionalChain([previousSignal, 'optionalAccess', _145 => _145.aborted])) {
5509
5745
  abortFromPrevious();
5510
5746
  return () => void 0;
5511
5747
  }
5512
5748
  try {
5513
- cancelInner = _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, fn2(req), env, finish);
5749
+ cancelInner = _chunkL6VB5N7Qcjs.registerHttpEffect.call(void 0, fn3(req), env, finish);
5514
5750
  } catch (error) {
5515
5751
  finish({
5516
5752
  _tag: "Failure",
@@ -5625,7 +5861,7 @@ function processResponse(res, decompressor, enabledEncodings, stats) {
5625
5861
  const contentEncodingKey = Object.keys(res.headers).find(
5626
5862
  (k) => k.toLowerCase() === "content-encoding"
5627
5863
  );
5628
- const contentEncodingValue = contentEncodingKey ? _optionalChain([res, 'access', _139 => _139.headers, 'access', _140 => _140[contentEncodingKey], 'optionalAccess', _141 => _141.trim, 'call', _142 => _142()]) : void 0;
5864
+ const contentEncodingValue = contentEncodingKey ? _optionalChain([res, 'access', _146 => _146.headers, 'access', _147 => _147[contentEncodingKey], 'optionalAccess', _148 => _148.trim, 'call', _149 => _149()]) : void 0;
5629
5865
  if (!contentEncodingValue || contentEncodingValue.toLowerCase() === "identity") {
5630
5866
  stats.passthroughCount++;
5631
5867
  return res;
@@ -5700,7 +5936,7 @@ function processResponse(res, decompressor, enabledEncodings, stats) {
5700
5936
  };
5701
5937
  }
5702
5938
  function makeCompressionMiddleware(config) {
5703
- const enabledEncodings = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _143 => _143.encodings]), () => ( [...SUPPORTED_ENCODINGS]));
5939
+ const enabledEncodings = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _150 => _150.encodings]), () => ( [...SUPPORTED_ENCODINGS]));
5704
5940
  const decompressor = createDecompressor();
5705
5941
  const mutableStats = emptyStats2();
5706
5942
  const middleware = (next) => {
@@ -5740,9 +5976,9 @@ function makeCompressionMiddleware(config) {
5740
5976
  var makeResponseCompressionMiddleware = makeCompressionMiddleware;
5741
5977
  var DEFAULT_REQUEST_COMPRESS_METHODS = ["POST", "PUT", "PATCH"];
5742
5978
  function makeRequestCompressionMiddleware(config) {
5743
- const encoding = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _144 => _144.encoding]), () => ( "gzip"));
5744
- const minBytes = Math.max(0, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _145 => _145.minBytes]), () => ( 1024))));
5745
- const methods = new Set((_nullishCoalesce(_optionalChain([config, 'optionalAccess', _146 => _146.methods]), () => ( DEFAULT_REQUEST_COMPRESS_METHODS))).map((m) => m.toUpperCase()));
5979
+ const encoding = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _151 => _151.encoding]), () => ( "gzip"));
5980
+ const minBytes = Math.max(0, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _152 => _152.minBytes]), () => ( 1024))));
5981
+ const methods = new Set((_nullishCoalesce(_optionalChain([config, 'optionalAccess', _153 => _153.methods]), () => ( DEFAULT_REQUEST_COMPRESS_METHODS))).map((m) => m.toUpperCase()));
5746
5982
  const mutableStats = emptyRequestCompressionStats();
5747
5983
  const middleware = (next) => {
5748
5984
  return (req) => {
@@ -5786,7 +6022,7 @@ function compressRequest(req, encoding, minBytes, methods, stats) {
5786
6022
  "Content-Length": String(compressed.byteLength)
5787
6023
  })
5788
6024
  };
5789
- } catch (e18) {
6025
+ } catch (e19) {
5790
6026
  stats.errorCount++;
5791
6027
  return req;
5792
6028
  }
@@ -5927,11 +6163,195 @@ function validatedJsonResponse(client, validator) {
5927
6163
  function previewJson(value) {
5928
6164
  try {
5929
6165
  return JSON.stringify(value);
5930
- } catch (e19) {
6166
+ } catch (e20) {
5931
6167
  return "[unserializable]";
5932
6168
  }
5933
6169
  }
5934
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
+
5935
6355
  // src/http/requestBuilder.ts
5936
6356
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
5937
6357
  function splitHttpRequestInit(init) {
@@ -6029,17 +6449,18 @@ var PRESET_CONFIGS = {
6029
6449
  highThroughputProxy: PROXY_PRESET_CONFIG,
6030
6450
  balanced: BALANCED_PRESET_CONFIG,
6031
6451
  default: DEFAULT_PRESET_CONFIG,
6032
- production: DEFAULT_PRESET_CONFIG
6452
+ production: DEFAULT_PRESET_CONFIG,
6453
+ bareMetal: {}
6033
6454
  };
6034
6455
  function isDefaultCacheableResponse(req, res) {
6035
6456
  if (!DEFAULT_CACHEABLE_METHODS.has(req.method)) return false;
6036
6457
  if (res.status < 200 || res.status >= 400) return false;
6037
- const cacheControl = _optionalChain([headerValue, 'call', _147 => _147(res.headers, "cache-control"), 'optionalAccess', _148 => _148.toLowerCase, 'call', _149 => _149()]);
6458
+ const cacheControl = _optionalChain([headerValue, 'call', _162 => _162(res.headers, "cache-control"), 'optionalAccess', _163 => _163.toLowerCase, 'call', _164 => _164()]);
6038
6459
  if (cacheControl) {
6039
6460
  const directives = cacheControl.split(",").map((part) => part.trim());
6040
6461
  if (directives.includes("no-store") || directives.includes("no-cache")) return false;
6041
6462
  }
6042
- if (_optionalChain([headerValue, 'call', _150 => _150(res.headers, "pragma"), 'optionalAccess', _151 => _151.toLowerCase, 'call', _152 => _152()]) === "no-cache") return false;
6463
+ if (_optionalChain([headerValue, 'call', _165 => _165(res.headers, "pragma"), 'optionalAccess', _166 => _166.toLowerCase, 'call', _167 => _167()]) === "no-cache") return false;
6043
6464
  if (headerValue(res.headers, "set-cookie") !== void 0) return false;
6044
6465
  return true;
6045
6466
  }
@@ -6056,6 +6477,9 @@ function makeDefaultHttpClient(config = {}) {
6056
6477
  policyPresets,
6057
6478
  ...lifecycleOverrides
6058
6479
  } = config;
6480
+ if (preset === "bareMetal") {
6481
+ return buildBareMetalBranch(lifecycleOverrides, middleware, config);
6482
+ }
6059
6483
  const lifecycleConfig2 = mergeLifecycleConfig(PRESET_CONFIGS[preset], lifecycleOverrides);
6060
6484
  let wire = makeLifecycleClient(lifecycleConfig2);
6061
6485
  const compressionResult = compression === false || compression === void 0 && isLeanPreset(preset) ? void 0 : makeCompressionMiddleware(compression === void 0 ? void 0 : compression);
@@ -6075,10 +6499,164 @@ function makeDefaultHttpClient(config = {}) {
6075
6499
  return buildDefaultClient(wire, {
6076
6500
  preset,
6077
6501
  features,
6078
- compressionStats: _optionalChain([compressionResult, 'optionalAccess', _153 => _153.stats]),
6502
+ compressionStats: _optionalChain([compressionResult, 'optionalAccess', _168 => _168.stats]),
6079
6503
  useInlineDecode
6080
6504
  });
6081
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
+ }
6082
6660
  function buildDefaultClient(wire, meta) {
6083
6661
  const withPromise = (eff) => _chunkMVGUEJ5Zcjs.withAsyncPromise.call(void 0, (e, env) => _chunkJKHBEWQAcjs.toPromise.call(void 0, e, env))(eff);
6084
6662
  const requestRaw = (req) => wire(req);
@@ -6097,24 +6675,24 @@ function buildDefaultClient(wire, meta) {
6097
6675
  );
6098
6676
  if (meta.useInlineDecode) {
6099
6677
  return withPromise(
6100
- fusedWireAndDecode(requestRaw(req), _optionalChain([init, 'optionalAccess', _154 => _154.schema]), _optionalChain([init, 'optionalAccess', _155 => _155.schemaName]))
6678
+ fusedWireAndDecode(requestRaw(req), _optionalChain([init, 'optionalAccess', _177 => _177.schema]), _optionalChain([init, 'optionalAccess', _178 => _178.schemaName]))
6101
6679
  );
6102
6680
  }
6103
6681
  return withPromise(
6104
- _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _156 => _156.schema]), _optionalChain([init, 'optionalAccess', _157 => _157.schemaName])))
6682
+ _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _179 => _179.schema]), _optionalChain([init, 'optionalAccess', _180 => _180.schemaName])))
6105
6683
  );
6106
6684
  });
6107
6685
  const postJson = ((url, bodyObj, init) => {
6108
6686
  return withPromise(
6109
6687
  _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
6110
- encodeJsonBodyEffect(bodyObj, _optionalChain([init, 'optionalAccess', _158 => _158.bodySchema]), { schemaName: _optionalChain([init, 'optionalAccess', _159 => _159.bodySchemaName]) }),
6688
+ encodeJsonBodyEffect(bodyObj, _optionalChain([init, 'optionalAccess', _181 => _181.bodySchema]), { schemaName: _optionalChain([init, 'optionalAccess', _182 => _182.bodySchemaName]) }),
6111
6689
  (bodyText) => {
6112
6690
  const req = setHeaderIfMissing("content-type", "application/json")(
6113
6691
  setHeaderIfMissing("accept", "application/json")(
6114
6692
  buildHttpRequest("POST", url, init, bodyText)
6115
6693
  )
6116
6694
  );
6117
- return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _160 => _160.schema]), _optionalChain([init, 'optionalAccess', _161 => _161.schemaName])));
6695
+ return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, requestRaw(req), (w) => decodeResponse(w, _optionalChain([init, 'optionalAccess', _183 => _183.schema]), _optionalChain([init, 'optionalAccess', _184 => _184.schemaName])));
6118
6696
  }
6119
6697
  )
6120
6698
  );
@@ -6259,7 +6837,7 @@ function isEnabled(value) {
6259
6837
  return value !== void 0 && value !== false;
6260
6838
  }
6261
6839
  function isLeanPreset(preset) {
6262
- return preset === "minimal" || preset === "proxy" || preset === "highThroughputProxy";
6840
+ return preset === "minimal" || preset === "proxy" || preset === "highThroughputProxy" || preset === "bareMetal";
6263
6841
  }
6264
6842
 
6265
6843
  // src/http/layer.ts
@@ -6379,4 +6957,22 @@ function shutdownDefaultHttpClient(client) {
6379
6957
 
6380
6958
 
6381
6959
 
6382
- 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.normalizeHeadersInit = normalizeHeadersInit; exports.makeHttpStream = makeHttpStream; exports.noopSignal = noopSignal; 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.defaultHttpClientPreset = defaultHttpClientPreset; exports.makeDefaultHttpClient = makeDefaultHttpClient; exports.HttpClientService = HttpClientService; exports.makeDefaultHttpClientLayer = makeDefaultHttpClientLayer;
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;