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-MOO4L7F4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
streamFromReadableStream
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AQQQFNYD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
layerEffect,
|
|
9
9
|
makeScheduleDriver,
|
|
10
10
|
makeServiceTag,
|
|
11
11
|
sleep
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KDXNWGPB.mjs";
|
|
13
13
|
import {
|
|
14
14
|
fromPromiseAbortable,
|
|
15
15
|
resolveWasmModule,
|
|
16
16
|
toPromise
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-MUMBUXU6.mjs";
|
|
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-UZQ3BB6W.mjs";
|
|
37
37
|
import {
|
|
38
38
|
__require
|
|
39
39
|
} from "./chunk-Y6FXYEAI.mjs";
|
|
@@ -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
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
makeRuntimeEventRecord
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KAPZHDO4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
layerEffect,
|
|
6
6
|
makeScheduleDriver
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KDXNWGPB.mjs";
|
|
8
8
|
import {
|
|
9
9
|
Runtime,
|
|
10
10
|
getCurrentFiber,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
runtimeClockFromEnv,
|
|
13
13
|
toPromise,
|
|
14
14
|
unsafeRunAsync
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MUMBUXU6.mjs";
|
|
16
16
|
import {
|
|
17
17
|
Cause,
|
|
18
18
|
Exit,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "./chunk-36I3M4UC.mjs";
|
|
27
27
|
import {
|
|
28
28
|
parseConfig
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-UZQ3BB6W.mjs";
|
|
30
30
|
|
|
31
31
|
// src/core/types/cancel.ts
|
|
32
32
|
function makeCancelToken() {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZDZNV6NAcjs = require('./chunk-ZDZNV6NA.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -20,14 +20,14 @@ var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
|
|
|
20
20
|
// src/core/runtime/combinators.ts
|
|
21
21
|
function sleep(ms) {
|
|
22
22
|
return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
23
|
-
const clock =
|
|
23
|
+
const clock = _chunkZDZNV6NAcjs.runtimeClockFromEnv.call(void 0, env);
|
|
24
24
|
const id = clock.setTimeout(() => cb({ _tag: "Success", value: void 0 }), ms);
|
|
25
25
|
return () => clock.clearTimeout(id);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
function timeout(effect, ms) {
|
|
29
29
|
return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
30
|
-
const clock =
|
|
30
|
+
const clock = _chunkZDZNV6NAcjs.runtimeClockFromEnv.call(void 0, env);
|
|
31
31
|
let done = false;
|
|
32
32
|
let timerId;
|
|
33
33
|
let fiber;
|
|
@@ -40,7 +40,7 @@ function timeout(effect, ms) {
|
|
|
40
40
|
cause: { _tag: "Fail", error: { _tag: "TimeoutError", ms } }
|
|
41
41
|
});
|
|
42
42
|
}, ms);
|
|
43
|
-
const runtime =
|
|
43
|
+
const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
|
|
44
44
|
fiber = runtime.fork(effect);
|
|
45
45
|
fiber.join((exit) => {
|
|
46
46
|
if (done) return;
|
|
@@ -82,7 +82,7 @@ function retry(effect, policy) {
|
|
|
82
82
|
);
|
|
83
83
|
return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
|
|
84
84
|
{ _tag: "Sync", thunk: (env) => {
|
|
85
|
-
const clock =
|
|
85
|
+
const clock = _chunkZDZNV6NAcjs.runtimeClockFromEnv.call(void 0, env);
|
|
86
86
|
return { clock, startedAt: clock.now() };
|
|
87
87
|
} },
|
|
88
88
|
({ clock, startedAt }) => loop(0, startedAt, clock)
|
|
@@ -110,8 +110,8 @@ function retryWithBackoff(effect, opts = {}) {
|
|
|
110
110
|
// src/core/runtime/resource.ts
|
|
111
111
|
function bracket(acquire, use, release) {
|
|
112
112
|
return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
113
|
-
const runtime =
|
|
114
|
-
const scope = new (0,
|
|
113
|
+
const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
|
|
114
|
+
const scope = new (0, _chunkZDZNV6NAcjs.Scope)(runtime);
|
|
115
115
|
const acquireFiber = scope.fork(acquire);
|
|
116
116
|
acquireFiber.join((acquireExit) => {
|
|
117
117
|
if (acquireExit._tag === "Failure") {
|
|
@@ -150,7 +150,7 @@ function safeRelease(release, resource2, exit) {
|
|
|
150
150
|
}
|
|
151
151
|
function ensuring(effect, finalizer) {
|
|
152
152
|
return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
153
|
-
const runtime =
|
|
153
|
+
const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
|
|
154
154
|
const fiber = runtime.fork(effect);
|
|
155
155
|
fiber.join((exit) => {
|
|
156
156
|
const fin = _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
|
|
@@ -224,7 +224,7 @@ function useManaged(m, body) {
|
|
|
224
224
|
}
|
|
225
225
|
function managedAll(manageds) {
|
|
226
226
|
const acquire = _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
|
|
227
|
-
const runtime =
|
|
227
|
+
const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
|
|
228
228
|
const resources = [];
|
|
229
229
|
let i = 0;
|
|
230
230
|
const acquireNext = () => {
|
|
@@ -250,7 +250,7 @@ function managedAll(manageds) {
|
|
|
250
250
|
});
|
|
251
251
|
const release = (resources, exit) => {
|
|
252
252
|
return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (_env, cb) => {
|
|
253
|
-
const runtime =
|
|
253
|
+
const runtime = _chunkZDZNV6NAcjs.unsafeGetCurrentRuntime.call(void 0, );
|
|
254
254
|
releaseAcquired(runtime, manageds, resources, exit).then(() => {
|
|
255
255
|
cb({ _tag: "Success", value: void 0 });
|
|
256
256
|
});
|
|
@@ -593,7 +593,7 @@ function union(left, right) {
|
|
|
593
593
|
};
|
|
594
594
|
}
|
|
595
595
|
function makeScheduleDriver(schedule, options = {}) {
|
|
596
|
-
const clock = _nullishCoalesce(options.clock, () => (
|
|
596
|
+
const clock = _nullishCoalesce(options.clock, () => ( _chunkZDZNV6NAcjs.liveClock));
|
|
597
597
|
let startedAtMs = _nullishCoalesce(options.startedAtMs, () => ( clock.now()));
|
|
598
598
|
let attempt = 0;
|
|
599
599
|
let lastDecision;
|
|
@@ -661,7 +661,7 @@ function runSchedule(schedule, inputs, options = {}) {
|
|
|
661
661
|
function driverFromRuntime(schedule, options = {}) {
|
|
662
662
|
return _chunkMVGUEJ5Zcjs.Async.sync((env) => makeScheduleDriver(schedule, {
|
|
663
663
|
...options,
|
|
664
|
-
clock: _nullishCoalesce(options.clock, () => (
|
|
664
|
+
clock: _nullishCoalesce(options.clock, () => ( _chunkZDZNV6NAcjs.runtimeClockFromEnv.call(void 0, env)))
|
|
665
665
|
}));
|
|
666
666
|
}
|
|
667
667
|
function retryWithSchedule(effect, schedule, options = {}) {
|
|
@@ -719,7 +719,7 @@ function normalizeCap(ms) {
|
|
|
719
719
|
return normalizeDelay(ms);
|
|
720
720
|
}
|
|
721
721
|
function defaultClock() {
|
|
722
|
-
return
|
|
722
|
+
return _chunkZDZNV6NAcjs.liveClock.now();
|
|
723
723
|
}
|
|
724
724
|
function nowFromContext(context) {
|
|
725
725
|
return _nullishCoalesce(_optionalChain([context, 'optionalAccess', _4 => _4.clock, 'access', _5 => _5.now, 'call', _6 => _6()]), () => ( defaultClock()));
|