brass-runtime 1.18.1 → 1.19.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 +65 -0
- package/dist/agent/cli/main.cjs +31 -31
- package/dist/agent/cli/main.js +3 -3
- package/dist/agent/cli/main.mjs +3 -3
- package/dist/agent/index.cjs +4 -4
- package/dist/agent/index.js +3 -3
- package/dist/agent/index.mjs +3 -3
- package/dist/{chunk-22HZQG5F.js → chunk-2R3RVNS2.js} +6 -6
- package/dist/{chunk-YWLLH27R.mjs → chunk-3NKXUX4T.mjs} +2 -2
- package/dist/{chunk-IPSMXUWA.js → chunk-4PKBNG2H.js} +38 -18
- package/dist/{chunk-Z3ZZMQUZ.mjs → chunk-5RVHSBJ6.mjs} +182 -34
- package/dist/{chunk-B5FKOLTB.mjs → chunk-5UBJT4RW.mjs} +4 -4
- package/dist/{chunk-5RZ7YITF.cjs → chunk-6STX4PS3.cjs} +13 -13
- package/dist/{chunk-XPIMJQYS.cjs → chunk-7FZUTJM3.cjs} +400 -252
- package/dist/{chunk-YZ5LQ32F.js → chunk-A6EG5WRL.js} +3 -3
- package/dist/{chunk-TTSPIU3U.js → chunk-APQBU7TM.js} +53 -32
- package/dist/{chunk-BC6Q6BCO.mjs → chunk-AQQQFNYD.mjs} +38 -18
- package/dist/{chunk-OW5VHAOE.js → chunk-B2VXVNIS.js} +1 -1
- package/dist/{chunk-WCBNXPN6.mjs → chunk-BLXBZ6RE.mjs} +1 -1
- package/dist/{chunk-7VQLEN37.js → chunk-C3CWI42G.js} +1 -1
- package/dist/{chunk-WI7GZF3B.cjs → chunk-DV644N7P.cjs} +85 -85
- package/dist/{chunk-RBHNOKH4.mjs → chunk-EKLEDIVJ.mjs} +2 -2
- package/dist/{chunk-S4HXADU4.js → chunk-EXBGIC66.js} +1 -1
- package/dist/{chunk-LSYQ3C2M.js → chunk-FC5N5QHJ.js} +2 -2
- package/dist/{chunk-6MLAZPBL.mjs → chunk-FNWOH2T2.js} +18 -6
- package/dist/{chunk-WGE2FEZE.cjs → chunk-FYWWU3Z7.cjs} +2 -2
- package/dist/{chunk-2OW6IFY2.cjs → chunk-GOEO763K.cjs} +21 -21
- package/dist/{chunk-UAKAF32U.js → chunk-GXOIUBKE.js} +2 -2
- package/dist/{chunk-7DU7IQHK.js → chunk-H4ZRUQZL.js} +4 -4
- package/dist/{chunk-JWIEMBE6.mjs → chunk-HW2CLRJ3.mjs} +6 -6
- package/dist/{chunk-YGR2IN4R.js → chunk-JWFOWPMB.js} +163 -155
- package/dist/{chunk-6V2AWT4R.mjs → chunk-KAPZHDO4.mjs} +1 -1
- package/dist/{chunk-EEN5OTCR.mjs → chunk-KDXNWGPB.mjs} +1 -1
- package/dist/{chunk-UUMKZJRJ.cjs → chunk-KPOL2YEO.cjs} +18 -6
- package/dist/{chunk-J6DUHITE.cjs → chunk-MA74OYCI.cjs} +6 -6
- package/dist/{chunk-H626ZTDZ.mjs → chunk-MUMBUXU6.mjs} +53 -32
- package/dist/{chunk-5LC7V2OZ.cjs → chunk-NQW3YUFN.cjs} +18 -18
- package/dist/{chunk-EICAJDNX.cjs → chunk-OO7BGCC3.cjs} +54 -34
- package/dist/{chunk-7GBJYOX7.mjs → chunk-OX6MF7SZ.mjs} +163 -155
- package/dist/{chunk-WVSZOPGQ.cjs → chunk-QBVS3UYN.cjs} +245 -237
- package/dist/{chunk-WUDHOZIH.js → chunk-RZGB3DXR.js} +182 -34
- package/dist/{chunk-COOW7BJX.mjs → chunk-URVS2OE2.mjs} +3 -3
- package/dist/{chunk-HCJ4S3YB.js → chunk-UZQ3BB6W.mjs} +18 -6
- package/dist/{chunk-KNTJ7FQB.cjs → chunk-YQWZ7FZX.cjs} +5 -5
- package/dist/{chunk-ELIECDYN.cjs → chunk-Z2YIDHRI.cjs} +5 -5
- package/dist/{chunk-2JHJ4YHS.cjs → chunk-ZDZNV6NA.cjs} +59 -38
- package/dist/core/index.cjs +8 -8
- package/dist/core/index.js +7 -7
- package/dist/core/index.mjs +7 -7
- package/dist/http/index.cjs +54 -54
- package/dist/http/index.js +7 -7
- package/dist/http/index.mjs +7 -7
- package/dist/http/testing.cjs +9 -9
- package/dist/http/testing.js +5 -5
- package/dist/http/testing.mjs +5 -5
- package/dist/index.cjs +86 -86
- package/dist/index.js +8 -8
- package/dist/index.mjs +8 -8
- package/dist/observability/index.cjs +10 -10
- package/dist/observability/index.js +9 -9
- package/dist/observability/index.mjs +9 -9
- package/dist/perf/cli.cjs +26 -26
- package/dist/perf/cli.js +11 -11
- package/dist/perf/cli.mjs +11 -11
- package/dist/perf/index.cjs +13 -13
- package/dist/perf/index.js +11 -11
- package/dist/perf/index.mjs +11 -11
- package/dist/schema/index.cjs +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
} from "./chunk-TRM4JUZQ.js";
|
|
4
4
|
import {
|
|
5
5
|
streamFromReadableStream
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4PKBNG2H.js";
|
|
7
7
|
import {
|
|
8
8
|
layerEffect,
|
|
9
9
|
makeScheduleDriver,
|
|
10
10
|
makeServiceTag,
|
|
11
11
|
sleep
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-EXBGIC66.js";
|
|
13
13
|
import {
|
|
14
14
|
fromPromiseAbortable,
|
|
15
15
|
resolveWasmModule,
|
|
16
16
|
toPromise
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-APQBU7TM.js";
|
|
18
18
|
import {
|
|
19
19
|
Cause,
|
|
20
20
|
asyncEffect,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
makeSchemaIssue,
|
|
34
34
|
parseConfig,
|
|
35
35
|
validateValue
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-FNWOH2T2.js";
|
|
37
37
|
import {
|
|
38
38
|
__require
|
|
39
39
|
} from "./chunk-3RG5ZIWI.js";
|
|
@@ -2314,6 +2314,7 @@ var linkAbortSignals = (...signals) => {
|
|
|
2314
2314
|
};
|
|
2315
2315
|
};
|
|
2316
2316
|
var nowMs = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
2317
|
+
var isThenable = (value) => value !== null && typeof value === "object" && typeof value.then === "function";
|
|
2317
2318
|
var hasMethod = (value, name) => typeof value === "object" && value !== null && typeof value[name] === "function";
|
|
2318
2319
|
var defaultPromiseBody = (response, mode) => {
|
|
2319
2320
|
if (mode === "json" && hasMethod(response, "json")) return response.json();
|
|
@@ -2360,45 +2361,89 @@ var toPromiseTransportResponse = (bodyText, info) => ({
|
|
|
2360
2361
|
function makePromiseHttpTransport(config) {
|
|
2361
2362
|
const transport = (context) => asyncEffect((_env, cb) => {
|
|
2362
2363
|
let done = false;
|
|
2364
|
+
const signal = context.signal;
|
|
2365
|
+
const needsAbortListener = signal !== globalThis.__brassNoopSignal;
|
|
2366
|
+
let abort;
|
|
2363
2367
|
const finish = (exit) => {
|
|
2364
2368
|
if (done) return;
|
|
2365
2369
|
done = true;
|
|
2366
|
-
|
|
2370
|
+
if (needsAbortListener && abort) signal.removeEventListener("abort", abort);
|
|
2367
2371
|
cb(exit);
|
|
2368
2372
|
};
|
|
2369
2373
|
const fail = (error) => finish({ _tag: "Failure", cause: Cause.fail(error) });
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
abort();
|
|
2374
|
+
if (signal.aborted) {
|
|
2375
|
+
fail(abortErrorForSignal(signal));
|
|
2373
2376
|
return;
|
|
2374
2377
|
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2378
|
+
if (needsAbortListener) {
|
|
2379
|
+
abort = () => fail(abortErrorForSignal(signal));
|
|
2380
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
2381
|
+
}
|
|
2382
|
+
const startedAt = nowMs();
|
|
2383
|
+
let requestPromise;
|
|
2384
|
+
try {
|
|
2385
|
+
const result = config.request(context);
|
|
2386
|
+
requestPromise = isThenable(result) ? result : Promise.resolve(result);
|
|
2387
|
+
} catch (error) {
|
|
2388
|
+
if (signal.aborted) {
|
|
2389
|
+
fail(abortErrorForSignal(signal));
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
fail(config.error?.(error, context) ?? normalizeHttpError(error, { signal }));
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
requestPromise.then(
|
|
2396
|
+
(raw) => {
|
|
2397
|
+
if (done) return;
|
|
2380
2398
|
const durationMs = Math.round(nowMs() - startedAt);
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2399
|
+
try {
|
|
2400
|
+
const r = config.response(raw, context, { startedAt, durationMs });
|
|
2401
|
+
if (!isThenable(r)) {
|
|
2402
|
+
const mapped = r;
|
|
2403
|
+
finish({
|
|
2404
|
+
_tag: "Success",
|
|
2405
|
+
value: mapped.ms !== void 0 ? mapped : { ...mapped, ms: durationMs }
|
|
2406
|
+
});
|
|
2407
|
+
return;
|
|
2387
2408
|
}
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2409
|
+
r.then(
|
|
2410
|
+
(m) => {
|
|
2411
|
+
if (done) return;
|
|
2412
|
+
finish({
|
|
2413
|
+
_tag: "Success",
|
|
2414
|
+
value: m.ms !== void 0 ? m : { ...m, ms: durationMs }
|
|
2415
|
+
});
|
|
2416
|
+
},
|
|
2417
|
+
(error) => {
|
|
2418
|
+
if (done) return;
|
|
2419
|
+
if (signal.aborted) {
|
|
2420
|
+
fail(abortErrorForSignal(signal));
|
|
2421
|
+
return;
|
|
2422
|
+
}
|
|
2423
|
+
fail(config.error?.(error, context) ?? normalizeHttpError(error, { signal }));
|
|
2424
|
+
}
|
|
2425
|
+
);
|
|
2426
|
+
} catch (error) {
|
|
2427
|
+
if (signal.aborted) {
|
|
2428
|
+
fail(abortErrorForSignal(signal));
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
fail(config.error?.(error, context) ?? normalizeHttpError(error, { signal }));
|
|
2432
|
+
}
|
|
2433
|
+
},
|
|
2434
|
+
(error) => {
|
|
2435
|
+
if (done) return;
|
|
2436
|
+
if (signal.aborted) {
|
|
2437
|
+
fail(abortErrorForSignal(signal));
|
|
2392
2438
|
return;
|
|
2393
2439
|
}
|
|
2394
|
-
fail(config.error?.(error, context) ?? normalizeHttpError(error, { signal
|
|
2440
|
+
fail(config.error?.(error, context) ?? normalizeHttpError(error, { signal }));
|
|
2395
2441
|
}
|
|
2396
|
-
|
|
2397
|
-
void run();
|
|
2442
|
+
);
|
|
2398
2443
|
return () => {
|
|
2399
2444
|
if (done) return;
|
|
2400
2445
|
done = true;
|
|
2401
|
-
|
|
2446
|
+
if (needsAbortListener && abort) signal.removeEventListener("abort", abort);
|
|
2402
2447
|
};
|
|
2403
2448
|
});
|
|
2404
2449
|
const marked = transport;
|
|
@@ -3280,6 +3325,53 @@ function httpBodyKeyPart(body) {
|
|
|
3280
3325
|
// src/http/lifecycle/cacheKey.ts
|
|
3281
3326
|
var SEPARATOR = "\0";
|
|
3282
3327
|
var DEFAULT_CACHE_RELEVANT_HEADERS = ["accept", "authorization", "content-type"];
|
|
3328
|
+
function makeCacheKeyContext(baseUrl, extraHeaders = []) {
|
|
3329
|
+
const relevantSet = new Set(DEFAULT_CACHE_RELEVANT_HEADERS);
|
|
3330
|
+
for (let i = 0; i < extraHeaders.length; i++) {
|
|
3331
|
+
relevantSet.add(extraHeaders[i].toLowerCase());
|
|
3332
|
+
}
|
|
3333
|
+
return {
|
|
3334
|
+
baseUrl,
|
|
3335
|
+
relevantSet,
|
|
3336
|
+
cachedOrigin: baseUrl ? absoluteOrigin(baseUrl) : void 0
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
function computeCacheKeyFast(req, ctx) {
|
|
3340
|
+
const m = req.method;
|
|
3341
|
+
const method = m === "GET" || m === "POST" || m === "PUT" || m === "DELETE" || m === "PATCH" || m === "HEAD" || m === "OPTIONS" ? m : m.toUpperCase();
|
|
3342
|
+
let resolvedUrl;
|
|
3343
|
+
const url = req.url;
|
|
3344
|
+
if (ctx.cachedOrigin && url.length > 0 && url.charCodeAt(0) === 47 && url.charCodeAt(1) !== 47) {
|
|
3345
|
+
resolvedUrl = ctx.cachedOrigin + url;
|
|
3346
|
+
} else {
|
|
3347
|
+
resolvedUrl = new URL(url, ctx.baseUrl || void 0).toString();
|
|
3348
|
+
}
|
|
3349
|
+
const headers = req.headers;
|
|
3350
|
+
let sortedHeaders = "";
|
|
3351
|
+
if (headers) {
|
|
3352
|
+
const keys = Object.keys(headers);
|
|
3353
|
+
if (keys.length > 0) {
|
|
3354
|
+
const matched = [];
|
|
3355
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3356
|
+
const k = keys[i];
|
|
3357
|
+
const lk = k.toLowerCase();
|
|
3358
|
+
if (ctx.relevantSet.has(lk)) {
|
|
3359
|
+
matched.push(`${lk}:${headers[k]}`);
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
if (matched.length > 0) {
|
|
3363
|
+
if (matched.length === 1) {
|
|
3364
|
+
sortedHeaders = matched[0];
|
|
3365
|
+
} else {
|
|
3366
|
+
matched.sort();
|
|
3367
|
+
sortedHeaders = matched.join(",");
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3372
|
+
const body = httpBodyKeyPart(req.body);
|
|
3373
|
+
return `${method}${SEPARATOR}${resolvedUrl}${SEPARATOR}${sortedHeaders}${SEPARATOR}${body}`;
|
|
3374
|
+
}
|
|
3283
3375
|
function computeCacheKey(req, baseUrl, extraHeaders = []) {
|
|
3284
3376
|
const method = req.method.toUpperCase();
|
|
3285
3377
|
const resolvedUrl = resolveKeyUrl(req.url, baseUrl);
|
|
@@ -3333,6 +3425,48 @@ var HOP_BY_HOP = /* @__PURE__ */ new Set([
|
|
|
3333
3425
|
"upgrade"
|
|
3334
3426
|
]);
|
|
3335
3427
|
var SAFE_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
3428
|
+
function makeDedupKeyContext(baseUrl) {
|
|
3429
|
+
return {
|
|
3430
|
+
baseUrl,
|
|
3431
|
+
cachedOrigin: baseUrl ? absoluteOrigin(baseUrl) : void 0
|
|
3432
|
+
};
|
|
3433
|
+
}
|
|
3434
|
+
function computeDedupKeyFast(req, ctx) {
|
|
3435
|
+
const m = req.method;
|
|
3436
|
+
const method = m === "GET" || m === "POST" || m === "PUT" || m === "DELETE" || m === "PATCH" || m === "HEAD" || m === "OPTIONS" ? m : m.toUpperCase();
|
|
3437
|
+
let resolvedUrl;
|
|
3438
|
+
const url = req.url;
|
|
3439
|
+
if (ctx.cachedOrigin && url.length > 0 && url.charCodeAt(0) === 47 && url.charCodeAt(1) !== 47) {
|
|
3440
|
+
resolvedUrl = ctx.cachedOrigin + url;
|
|
3441
|
+
} else {
|
|
3442
|
+
resolvedUrl = resolveKeyUrl(url, ctx.baseUrl);
|
|
3443
|
+
}
|
|
3444
|
+
const headers = req.headers;
|
|
3445
|
+
let sortedHeaders = "";
|
|
3446
|
+
if (headers) {
|
|
3447
|
+
const keys = Object.keys(headers);
|
|
3448
|
+
if (keys.length > 0) {
|
|
3449
|
+
const matched = [];
|
|
3450
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3451
|
+
const k = keys[i];
|
|
3452
|
+
const lk = k.toLowerCase();
|
|
3453
|
+
if (!HOP_BY_HOP.has(lk) && lk !== "authorization") {
|
|
3454
|
+
matched.push(`${lk}:${headers[k]}`);
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
if (matched.length > 0) {
|
|
3458
|
+
if (matched.length === 1) {
|
|
3459
|
+
sortedHeaders = matched[0];
|
|
3460
|
+
} else {
|
|
3461
|
+
matched.sort();
|
|
3462
|
+
sortedHeaders = matched.join(",");
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
const body = httpBodyKeyPart(req.body);
|
|
3468
|
+
return `${method}${SEPARATOR}${resolvedUrl}${SEPARATOR}${sortedHeaders}${SEPARATOR}${body}`;
|
|
3469
|
+
}
|
|
3336
3470
|
function computeDedupKey(req, baseUrl) {
|
|
3337
3471
|
const method = req.method.toUpperCase();
|
|
3338
3472
|
const resolvedUrl = resolveKeyUrl(req.url, baseUrl);
|
|
@@ -3362,6 +3496,7 @@ function withDedup(config) {
|
|
|
3362
3496
|
const inFlight = /* @__PURE__ */ new Map();
|
|
3363
3497
|
const customKeyFn = config?.dedupKey;
|
|
3364
3498
|
const onEvent = config?.onEvent;
|
|
3499
|
+
const dedupKeyCtx = makeDedupKeyContext("");
|
|
3365
3500
|
return (next) => {
|
|
3366
3501
|
return (req) => {
|
|
3367
3502
|
if (!SAFE_METHODS.has(req.method.toUpperCase())) {
|
|
@@ -3384,7 +3519,7 @@ function withDedup(config) {
|
|
|
3384
3519
|
return next(req);
|
|
3385
3520
|
}
|
|
3386
3521
|
} else {
|
|
3387
|
-
key =
|
|
3522
|
+
key = computeDedupKeyFast(req, dedupKeyCtx);
|
|
3388
3523
|
}
|
|
3389
3524
|
return {
|
|
3390
3525
|
_tag: "Async",
|
|
@@ -3913,6 +4048,7 @@ function withCache(config) {
|
|
|
3913
4048
|
const baseUrl = config?.baseUrl ?? "";
|
|
3914
4049
|
const onEvent = config?.onEvent;
|
|
3915
4050
|
const onLifecycleEvent = config?.onLifecycleEvent;
|
|
4051
|
+
const cacheKeyCtx = makeCacheKeyContext(baseUrl, cacheRelevantHeaders);
|
|
3916
4052
|
const cache = new LRUCache({
|
|
3917
4053
|
maxEntries,
|
|
3918
4054
|
onEvict: (count) => onLifecycleEvent?.({ type: "cache-eviction", count })
|
|
@@ -3930,7 +4066,7 @@ function withCache(config) {
|
|
|
3930
4066
|
if (!SAFE_METHODS.has(method) && !cachePolicy) {
|
|
3931
4067
|
return next(req);
|
|
3932
4068
|
}
|
|
3933
|
-
const key =
|
|
4069
|
+
const key = computeCacheKeyFast(req, cacheKeyCtx);
|
|
3934
4070
|
return {
|
|
3935
4071
|
_tag: "Async",
|
|
3936
4072
|
register: (env, cb) => {
|
|
@@ -3989,7 +4125,7 @@ function withCache(config) {
|
|
|
3989
4125
|
if (!SAFE_METHODS.has(method) && !cachePolicy) {
|
|
3990
4126
|
return next(req);
|
|
3991
4127
|
}
|
|
3992
|
-
const key =
|
|
4128
|
+
const key = computeCacheKeyFast(req, cacheKeyCtx);
|
|
3993
4129
|
return {
|
|
3994
4130
|
_tag: "Async",
|
|
3995
4131
|
register: (env, cb) => {
|
|
@@ -5703,16 +5839,21 @@ function decodeJsonBody(bodyText, validator, options = {}) {
|
|
|
5703
5839
|
};
|
|
5704
5840
|
}
|
|
5705
5841
|
if (!validator) return { success: true, data: parsed };
|
|
5842
|
+
let validation;
|
|
5706
5843
|
let legacyMessage;
|
|
5707
|
-
|
|
5844
|
+
if (isSchema(validator)) {
|
|
5845
|
+
validation = validator.safeParse(parsed);
|
|
5846
|
+
} else {
|
|
5708
5847
|
const result = validator(parsed);
|
|
5709
|
-
if (result.success)
|
|
5848
|
+
if (result.success) {
|
|
5849
|
+
return { success: true, data: result.data };
|
|
5850
|
+
}
|
|
5710
5851
|
legacyMessage = result.error;
|
|
5711
|
-
|
|
5852
|
+
validation = {
|
|
5712
5853
|
success: false,
|
|
5713
5854
|
issues: result.issues ?? [makeSchemaIssue([], "valid JSON shape", parsed, result.error)]
|
|
5714
5855
|
};
|
|
5715
|
-
}
|
|
5856
|
+
}
|
|
5716
5857
|
if (validation.success) return { success: true, data: validation.data };
|
|
5717
5858
|
return {
|
|
5718
5859
|
success: false,
|
|
@@ -5756,6 +5897,13 @@ function encodeJsonBodyEffect(bodyObj, validator, options = {}) {
|
|
|
5756
5897
|
}
|
|
5757
5898
|
}
|
|
5758
5899
|
function decodeJsonBodyEffect(bodyText, validator, options) {
|
|
5900
|
+
if (!validator) {
|
|
5901
|
+
try {
|
|
5902
|
+
return asyncSucceed(JSON.parse(bodyText));
|
|
5903
|
+
} catch (error) {
|
|
5904
|
+
return asyncFail(makeJsonParseValidationError(bodyText, error, options ?? {}));
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5759
5907
|
const result = decodeJsonBody(bodyText, validator, options);
|
|
5760
5908
|
return result.success ? asyncSucceed(result.data) : asyncFail(result.error);
|
|
5761
5909
|
}
|
|
@@ -2,14 +2,14 @@ import {
|
|
|
2
2
|
EventBus,
|
|
3
3
|
InMemoryTracer,
|
|
4
4
|
makeMetrics
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KAPZHDO4.mjs";
|
|
6
6
|
import {
|
|
7
7
|
Runtime,
|
|
8
8
|
ctxExtend,
|
|
9
9
|
ctxToObject,
|
|
10
10
|
emptyContext,
|
|
11
11
|
getCurrentFiber
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-MUMBUXU6.mjs";
|
|
13
13
|
import {
|
|
14
14
|
asyncFail,
|
|
15
15
|
asyncFlatMap,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import {
|
|
21
21
|
Schema,
|
|
22
22
|
parseConfig
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-UZQ3BB6W.mjs";
|
|
24
24
|
|
|
25
25
|
// src/observability/health.ts
|
|
26
26
|
function snapshotRuntimeHealth(options = {}) {
|
|
@@ -237,7 +237,14 @@ function arraySchema(item) {
|
|
|
237
237
|
function objectSchema(shape, options = {}) {
|
|
238
238
|
const unknownKeys = options.unknownKeys ?? "strip";
|
|
239
239
|
const shapeEntries = Object.entries(shape);
|
|
240
|
-
const
|
|
240
|
+
const fieldKeys = new Array(shapeEntries.length);
|
|
241
|
+
const fieldSchemas = new Array(shapeEntries.length);
|
|
242
|
+
for (let i = 0; i < shapeEntries.length; i++) {
|
|
243
|
+
fieldKeys[i] = shapeEntries[i][0];
|
|
244
|
+
fieldSchemas[i] = shapeEntries[i][1];
|
|
245
|
+
}
|
|
246
|
+
const fieldCount = fieldKeys.length;
|
|
247
|
+
const knownKeys = unknownKeys === "strict" ? new Set(fieldKeys) : void 0;
|
|
241
248
|
return makeSchema("object", false, (input, path) => {
|
|
242
249
|
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
243
250
|
return fail([makeSchemaIssue(path, options.name ?? "object", input)]);
|
|
@@ -246,11 +253,13 @@ function objectSchema(shape, options = {}) {
|
|
|
246
253
|
const out = unknownKeys === "passthrough" ? { ...source } : {};
|
|
247
254
|
const childPath = path.length === 0 ? [] : [...path];
|
|
248
255
|
let issues;
|
|
249
|
-
for (
|
|
256
|
+
for (let i = 0; i < fieldCount; i++) {
|
|
257
|
+
const key = fieldKeys[i];
|
|
258
|
+
const fieldSchema = fieldSchemas[i];
|
|
250
259
|
childPath.push(key);
|
|
251
260
|
if (!(key in source)) {
|
|
252
261
|
if (!fieldSchema.isOptional) {
|
|
253
|
-
issues
|
|
262
|
+
if (!issues) issues = [];
|
|
254
263
|
issues.push(makeSchemaIssue(childPath, fieldSchema.name ?? fieldSchema.kind, void 0, "Required field is missing"));
|
|
255
264
|
}
|
|
256
265
|
childPath.pop();
|
|
@@ -261,15 +270,18 @@ function objectSchema(shape, options = {}) {
|
|
|
261
270
|
if (result.success) {
|
|
262
271
|
out[key] = result.data;
|
|
263
272
|
} else {
|
|
264
|
-
issues
|
|
265
|
-
|
|
273
|
+
if (!issues) issues = [];
|
|
274
|
+
const resultIssues = result.issues;
|
|
275
|
+
for (let j = 0; j < resultIssues.length; j++) {
|
|
276
|
+
issues.push(resultIssues[j]);
|
|
277
|
+
}
|
|
266
278
|
}
|
|
267
279
|
}
|
|
268
280
|
if (knownKeys) {
|
|
269
281
|
for (const key of Object.keys(source)) {
|
|
270
282
|
if (!knownKeys.has(key)) {
|
|
271
283
|
childPath.push(key);
|
|
272
|
-
issues
|
|
284
|
+
if (!issues) issues = [];
|
|
273
285
|
issues.push(makeSchemaIssue(childPath, "known key", source[key], "Unknown key is not allowed"));
|
|
274
286
|
childPath.pop();
|
|
275
287
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkFYWWU3Z7cjs = require('./chunk-FYWWU3Z7.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -73,9 +73,9 @@ function fiberRefSnapshot() {
|
|
|
73
73
|
return new Map(currentFiberRefs(false));
|
|
74
74
|
}
|
|
75
75
|
function currentFiberRefs(create) {
|
|
76
|
-
const fiber =
|
|
76
|
+
const fiber = _chunkZDZNV6NAcjs.getCurrentFiber.call(void 0, );
|
|
77
77
|
if (!fiber) return void 0;
|
|
78
|
-
fiber.fiberContext ??= { log:
|
|
78
|
+
fiber.fiberContext ??= { log: _chunkZDZNV6NAcjs.emptyContext, trace: null };
|
|
79
79
|
if (!fiber.fiberContext.fiberRefs && create) fiber.fiberContext.fiberRefs = /* @__PURE__ */ new Map();
|
|
80
80
|
return fiber.fiberContext.fiberRefs;
|
|
81
81
|
}
|
|
@@ -98,7 +98,7 @@ function makeRuntimeRecorder(options = {}) {
|
|
|
98
98
|
return out;
|
|
99
99
|
};
|
|
100
100
|
const emit = (ev, ctx) => {
|
|
101
|
-
records[next] =
|
|
101
|
+
records[next] = _chunkFYWWU3Z7cjs.makeRuntimeEventRecord.call(void 0, ev, ctx, seq++);
|
|
102
102
|
next = (next + 1) % capacity;
|
|
103
103
|
if (size < capacity) size++;
|
|
104
104
|
else dropped++;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk6STX4PS3cjs = require('./chunk-6STX4PS3.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
|
|
11
11
|
|
|
12
12
|
// src/core/runtime/runtimeLayer.ts
|
|
13
|
-
var RuntimeService =
|
|
13
|
+
var RuntimeService = _chunk6STX4PS3cjs.makeServiceTag.call(void 0, "Runtime");
|
|
14
14
|
function makeRuntimeLayer(env = {}, options = {}) {
|
|
15
15
|
const { tag = RuntimeService, ...runtimeOptions } = options;
|
|
16
|
-
return
|
|
16
|
+
return _chunk6STX4PS3cjs.layerEffect.call(void 0,
|
|
17
17
|
tag,
|
|
18
18
|
(context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0,
|
|
19
|
-
() => new (0,
|
|
19
|
+
() => new (0, _chunkZDZNV6NAcjs.Runtime)({
|
|
20
20
|
...runtimeOptions,
|
|
21
21
|
env: resolveRuntimeLayerEnv(env, context)
|
|
22
22
|
})
|
|
@@ -10,7 +10,7 @@ var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkKPOL2YEOcjs = require('./chunk-KPOL2YEO.cjs');
|
|
14
14
|
|
|
15
15
|
// src/core/runtime/ringBuffer.ts
|
|
16
16
|
var PushStatus = /* @__PURE__ */ ((PushStatus3) => {
|
|
@@ -2827,11 +2827,11 @@ function normalizeRuntimeEngineMode(value) {
|
|
|
2827
2827
|
function unreachableEngine(value) {
|
|
2828
2828
|
throw new Error(`brass-runtime unsupported engine '${String(value)}'`);
|
|
2829
2829
|
}
|
|
2830
|
-
var runtimeOptionsSchema =
|
|
2831
|
-
env:
|
|
2832
|
-
lane:
|
|
2833
|
-
inferLane:
|
|
2834
|
-
engine:
|
|
2830
|
+
var runtimeOptionsSchema = _chunkKPOL2YEOcjs.Schema.object({
|
|
2831
|
+
env: _chunkKPOL2YEOcjs.Schema.any(),
|
|
2832
|
+
lane: _chunkKPOL2YEOcjs.Schema.string({ minLength: 1 }).optional(),
|
|
2833
|
+
inferLane: _chunkKPOL2YEOcjs.Schema.boolean().optional(),
|
|
2834
|
+
engine: _chunkKPOL2YEOcjs.Schema.enum(["ts", "wasm"]).optional()
|
|
2835
2835
|
}, { unknownKeys: "passthrough" });
|
|
2836
2836
|
var Runtime = class _Runtime {
|
|
2837
2837
|
|
|
@@ -2848,7 +2848,7 @@ var Runtime = class _Runtime {
|
|
|
2848
2848
|
// opcional: registry para observabilidad
|
|
2849
2849
|
|
|
2850
2850
|
constructor(args) {
|
|
2851
|
-
|
|
2851
|
+
_chunkKPOL2YEOcjs.parseConfig.call(void 0, "RuntimeOptions", runtimeOptionsSchema, args);
|
|
2852
2852
|
this.env = args.env;
|
|
2853
2853
|
this.scheduler = _nullishCoalesce(args.scheduler, () => ( globalScheduler));
|
|
2854
2854
|
this.lane = args.lane;
|
|
@@ -3029,32 +3029,43 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3029
3029
|
constructor(runtime, effect, cb) {;_class16.prototype.__init99.call(this);_class16.prototype.__init100.call(this);_class16.prototype.__init101.call(this);_class16.prototype.__init102.call(this);
|
|
3030
3030
|
this.runtime = runtime;
|
|
3031
3031
|
this.current = effect;
|
|
3032
|
-
this.
|
|
3033
|
-
this.frame = {
|
|
3034
|
-
id: 0,
|
|
3035
|
-
runtime,
|
|
3036
|
-
name: "native-fast-path",
|
|
3037
|
-
fiberContext: { trace: null },
|
|
3038
|
-
lane: runtime.lane,
|
|
3039
|
-
status: () => this.result ? "Done" : "Running",
|
|
3040
|
-
join: (joiner) => {
|
|
3041
|
-
if (this.result) joiner(this.result);
|
|
3042
|
-
else this.joiners.push(joiner);
|
|
3043
|
-
},
|
|
3044
|
-
interrupt: () => void 0,
|
|
3045
|
-
addFinalizer: (finalizer) => {
|
|
3046
|
-
this.finalizers.push(finalizer);
|
|
3047
|
-
}
|
|
3048
|
-
};
|
|
3032
|
+
this.firstJoiner = cb;
|
|
3049
3033
|
}
|
|
3050
3034
|
|
|
3051
3035
|
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3036
|
+
// Lazy-allocated — most requests don't need these
|
|
3037
|
+
|
|
3038
|
+
|
|
3055
3039
|
|
|
3056
|
-
__init102() {this.yielded = false}
|
|
3057
3040
|
|
|
3041
|
+
__init99() {this.yielded = false}
|
|
3042
|
+
|
|
3043
|
+
// Frame is now the runner itself — avoids allocating a separate frame object
|
|
3044
|
+
// with 4 closures per request. We implement the Fiber-like interface inline.
|
|
3045
|
+
__init100() {this.id = 0}
|
|
3046
|
+
__init101() {this.name = "native-fast-path"}
|
|
3047
|
+
__init102() {this.fiberContext = { trace: null }}
|
|
3048
|
+
get lane() {
|
|
3049
|
+
return this.runtime.lane;
|
|
3050
|
+
}
|
|
3051
|
+
// Fiber-like interface methods (used by frame consumers)
|
|
3052
|
+
status() {
|
|
3053
|
+
return this.result ? "Done" : "Running";
|
|
3054
|
+
}
|
|
3055
|
+
join(joiner) {
|
|
3056
|
+
if (this.result) {
|
|
3057
|
+
joiner(this.result);
|
|
3058
|
+
return;
|
|
3059
|
+
}
|
|
3060
|
+
if (!this.joiners) this.joiners = [];
|
|
3061
|
+
this.joiners.push(joiner);
|
|
3062
|
+
}
|
|
3063
|
+
interrupt() {
|
|
3064
|
+
}
|
|
3065
|
+
addFinalizer(finalizer) {
|
|
3066
|
+
if (!this.finalizers) this.finalizers = [];
|
|
3067
|
+
this.finalizers.push(finalizer);
|
|
3068
|
+
}
|
|
3058
3069
|
start() {
|
|
3059
3070
|
this.runLoop();
|
|
3060
3071
|
}
|
|
@@ -3079,10 +3090,12 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3079
3090
|
}
|
|
3080
3091
|
break;
|
|
3081
3092
|
case "FlatMap":
|
|
3093
|
+
if (!this.stack) this.stack = [];
|
|
3082
3094
|
this.stack.push({ _tag: "SuccessCont", k: current.andThen });
|
|
3083
3095
|
this.current = current.first;
|
|
3084
3096
|
break;
|
|
3085
3097
|
case "Fold":
|
|
3098
|
+
if (!this.stack) this.stack = [];
|
|
3086
3099
|
this.stack.push({
|
|
3087
3100
|
_tag: "FoldCont",
|
|
3088
3101
|
onFailure: current.onFailure,
|
|
@@ -3097,10 +3110,12 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3097
3110
|
this.onSuccess(this.runtime.fork(current.effect, current.scopeId));
|
|
3098
3111
|
break;
|
|
3099
3112
|
case "Interruptibility":
|
|
3113
|
+
if (!this.stack) this.stack = [];
|
|
3100
3114
|
this.stack.push({ _tag: "InterruptibilityCont" });
|
|
3101
3115
|
this.current = current.effect;
|
|
3102
3116
|
break;
|
|
3103
3117
|
case "InterruptibilityMask":
|
|
3118
|
+
if (!this.stack) this.stack = [];
|
|
3104
3119
|
this.stack.push({ _tag: "InterruptibilityCont" });
|
|
3105
3120
|
try {
|
|
3106
3121
|
this.current = current.body((effect) => ({
|
|
@@ -3113,6 +3128,7 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3113
3128
|
}
|
|
3114
3129
|
break;
|
|
3115
3130
|
case "InterruptibilityRestore":
|
|
3131
|
+
if (!this.stack) this.stack = [];
|
|
3116
3132
|
this.stack.push({ _tag: "InterruptibilityCont" });
|
|
3117
3133
|
this.current = current.effect;
|
|
3118
3134
|
break;
|
|
@@ -3121,6 +3137,7 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3121
3137
|
const hadValue = refs.has(current.refId);
|
|
3122
3138
|
const previousValue = refs.get(current.refId);
|
|
3123
3139
|
refs.set(current.refId, current.value);
|
|
3140
|
+
if (!this.stack) this.stack = [];
|
|
3124
3141
|
this.stack.push({
|
|
3125
3142
|
_tag: "FiberRefCont",
|
|
3126
3143
|
refId: current.refId,
|
|
@@ -3179,7 +3196,7 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3179
3196
|
onSuccess(value) {
|
|
3180
3197
|
let currentValue = value;
|
|
3181
3198
|
while (true) {
|
|
3182
|
-
const frame = this.stack.pop();
|
|
3199
|
+
const frame = this.stack ? this.stack.pop() : void 0;
|
|
3183
3200
|
if (!frame) {
|
|
3184
3201
|
this.notify(_chunkMVGUEJ5Zcjs.Exit.succeed(currentValue));
|
|
3185
3202
|
return;
|
|
@@ -3207,7 +3224,7 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3207
3224
|
}
|
|
3208
3225
|
onCause(cause) {
|
|
3209
3226
|
let currentCause = cause;
|
|
3210
|
-
while (this.stack.length > 0) {
|
|
3227
|
+
while (this.stack && this.stack.length > 0) {
|
|
3211
3228
|
const frame = this.stack.pop();
|
|
3212
3229
|
if (frame._tag === "InterruptibilityCont") continue;
|
|
3213
3230
|
if (frame._tag === "FiberRefCont") {
|
|
@@ -3232,13 +3249,17 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3232
3249
|
notify(exit) {
|
|
3233
3250
|
if (this.result) return;
|
|
3234
3251
|
this.result = exit;
|
|
3235
|
-
this.runFinalizers(exit);
|
|
3236
|
-
|
|
3237
|
-
this.joiners
|
|
3252
|
+
if (this.finalizers) this.runFinalizers(exit);
|
|
3253
|
+
this.firstJoiner(exit);
|
|
3254
|
+
if (this.joiners) {
|
|
3255
|
+
for (const joiner of this.joiners) joiner(exit);
|
|
3256
|
+
this.joiners.length = 0;
|
|
3257
|
+
}
|
|
3238
3258
|
}
|
|
3239
3259
|
runFinalizers(exit) {
|
|
3240
|
-
|
|
3241
|
-
|
|
3260
|
+
const finalizers = this.finalizers;
|
|
3261
|
+
while (finalizers.length > 0) {
|
|
3262
|
+
const finalizer = finalizers.pop();
|
|
3242
3263
|
try {
|
|
3243
3264
|
const result = finalizer(exit);
|
|
3244
3265
|
if (result && typeof result === "object" && "_tag" in result) {
|
|
@@ -3249,8 +3270,8 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3249
3270
|
}
|
|
3250
3271
|
}
|
|
3251
3272
|
fiberRefs() {
|
|
3252
|
-
this.
|
|
3253
|
-
return this.
|
|
3273
|
+
this.fiberContext.fiberRefs ??= /* @__PURE__ */ new Map();
|
|
3274
|
+
return this.fiberContext.fiberRefs;
|
|
3254
3275
|
}
|
|
3255
3276
|
restoreFiberRef(frame) {
|
|
3256
3277
|
const refs = this.fiberRefs();
|
|
@@ -3258,7 +3279,7 @@ var NativeTopLevelRunner = (_class16 = class {
|
|
|
3258
3279
|
else refs.delete(frame.refId);
|
|
3259
3280
|
}
|
|
3260
3281
|
withFrame(body) {
|
|
3261
|
-
return withCurrentFiber(this
|
|
3282
|
+
return withCurrentFiber(this, body);
|
|
3262
3283
|
}
|
|
3263
3284
|
}, _class16);
|
|
3264
3285
|
function fork(effect, env) {
|