@btravstack/core 0.7.0 → 0.8.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/dist/index.cjs +12 -5
- package/dist/index.d.cts +11 -6
- package/dist/index.d.mts +11 -6
- package/dist/index.mjs +12 -5
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -38,18 +38,25 @@ var HealthChecks = class extends _btravstack_di.Port.many("HealthChecks") {};
|
|
|
38
38
|
*
|
|
39
39
|
* Each check's failure is recovered into a component line BEFORE `allAsync`
|
|
40
40
|
* sees it, so a failing dependency cannot short-circuit the others: a report
|
|
41
|
-
* naming one component is worth less than one naming all of them.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* naming one component is worth less than one naming all of them. A check
|
|
42
|
+
* that throws rather than answers is a bug in the check, and it is folded in
|
|
43
|
+
* too: each check is STARTED inside the pipeline, so a synchronous throw and
|
|
44
|
+
* a defecting `AsyncResult` alike are recovered into an unhealthy line —
|
|
45
|
+
* escaped, the first would reach the kernel's own `uncaughtException` handler
|
|
46
|
+
* and the second would leave `/healthz` hanging with nothing written.
|
|
44
47
|
*/
|
|
45
|
-
const runHealthChecks = (checks) => (0, unthrown.allAsync)(checks.map((health) => health.check().map(() => ({
|
|
48
|
+
const runHealthChecks = (checks) => (0, unthrown.allAsync)(checks.map((health) => (0, unthrown.OkAsync)().flatMap(() => health.check()).map(() => ({
|
|
46
49
|
name: health.name,
|
|
47
50
|
status: "healthy"
|
|
48
51
|
})).recoverErrCases((matcher) => matcher.with(unthrown.P.tag("HealthCheckFailed"), (error) => ({
|
|
49
52
|
name: health.name,
|
|
50
53
|
status: "unhealthy",
|
|
51
54
|
reason: error.reason
|
|
52
|
-
})))
|
|
55
|
+
}))).recoverDefect((cause) => (0, unthrown.Ok)({
|
|
56
|
+
name: health.name,
|
|
57
|
+
status: "unhealthy",
|
|
58
|
+
reason: String(cause)
|
|
59
|
+
})))).map((components) => ({
|
|
53
60
|
status: components.every((c) => c.status === "healthy") ? "healthy" : "unhealthy",
|
|
54
61
|
components
|
|
55
62
|
}));
|
package/dist/index.d.cts
CHANGED
|
@@ -74,9 +74,12 @@ type HealthReport = {
|
|
|
74
74
|
*
|
|
75
75
|
* Each check's failure is recovered into a component line BEFORE `allAsync`
|
|
76
76
|
* sees it, so a failing dependency cannot short-circuit the others: a report
|
|
77
|
-
* naming one component is worth less than one naming all of them.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* naming one component is worth less than one naming all of them. A check
|
|
78
|
+
* that throws rather than answers is a bug in the check, and it is folded in
|
|
79
|
+
* too: each check is STARTED inside the pipeline, so a synchronous throw and
|
|
80
|
+
* a defecting `AsyncResult` alike are recovered into an unhealthy line —
|
|
81
|
+
* escaped, the first would reach the kernel's own `uncaughtException` handler
|
|
82
|
+
* and the second would leave `/healthz` hanging with nothing written.
|
|
80
83
|
*/
|
|
81
84
|
declare const runHealthChecks: (checks: readonly HealthCheck[]) => AsyncResult<HealthReport, never>;
|
|
82
85
|
//#endregion
|
|
@@ -439,9 +442,11 @@ type StartOptions<UnitX = never, UnitNeeds = never> = {
|
|
|
439
442
|
*/
|
|
440
443
|
readonly env?: Environment;
|
|
441
444
|
/**
|
|
442
|
-
* A module forked around **every unit
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
+
* A module forked around **every unit** — a unit being one bounded piece of
|
|
446
|
+
* work, whatever the transport calls it: an HTTP request, a Temporal
|
|
447
|
+
* activity, an AMQP delivery. Built as the unit opens, torn down as it
|
|
448
|
+
* closes — while the unit's ambient record is still open — reading anything
|
|
449
|
+
* the application context carries.
|
|
445
450
|
*
|
|
446
451
|
* A failing unit finaliser is reported as a `teardownError` event and never
|
|
447
452
|
* in `ExitReport.teardownErrors`. With this option the unit's work runs only
|
package/dist/index.d.mts
CHANGED
|
@@ -74,9 +74,12 @@ type HealthReport = {
|
|
|
74
74
|
*
|
|
75
75
|
* Each check's failure is recovered into a component line BEFORE `allAsync`
|
|
76
76
|
* sees it, so a failing dependency cannot short-circuit the others: a report
|
|
77
|
-
* naming one component is worth less than one naming all of them.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* naming one component is worth less than one naming all of them. A check
|
|
78
|
+
* that throws rather than answers is a bug in the check, and it is folded in
|
|
79
|
+
* too: each check is STARTED inside the pipeline, so a synchronous throw and
|
|
80
|
+
* a defecting `AsyncResult` alike are recovered into an unhealthy line —
|
|
81
|
+
* escaped, the first would reach the kernel's own `uncaughtException` handler
|
|
82
|
+
* and the second would leave `/healthz` hanging with nothing written.
|
|
80
83
|
*/
|
|
81
84
|
declare const runHealthChecks: (checks: readonly HealthCheck[]) => AsyncResult<HealthReport, never>;
|
|
82
85
|
//#endregion
|
|
@@ -439,9 +442,11 @@ type StartOptions<UnitX = never, UnitNeeds = never> = {
|
|
|
439
442
|
*/
|
|
440
443
|
readonly env?: Environment;
|
|
441
444
|
/**
|
|
442
|
-
* A module forked around **every unit
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
+
* A module forked around **every unit** — a unit being one bounded piece of
|
|
446
|
+
* work, whatever the transport calls it: an HTTP request, a Temporal
|
|
447
|
+
* activity, an AMQP delivery. Built as the unit opens, torn down as it
|
|
448
|
+
* closes — while the unit's ambient record is still open — reading anything
|
|
449
|
+
* the application context carries.
|
|
445
450
|
*
|
|
446
451
|
* A failing unit finaliser is reported as a `teardownError` event and never
|
|
447
452
|
* in `ExitReport.teardownErrors`. With this option the unit's work runs only
|
package/dist/index.mjs
CHANGED
|
@@ -37,18 +37,25 @@ var HealthChecks = class extends Port.many("HealthChecks") {};
|
|
|
37
37
|
*
|
|
38
38
|
* Each check's failure is recovered into a component line BEFORE `allAsync`
|
|
39
39
|
* sees it, so a failing dependency cannot short-circuit the others: a report
|
|
40
|
-
* naming one component is worth less than one naming all of them.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
40
|
+
* naming one component is worth less than one naming all of them. A check
|
|
41
|
+
* that throws rather than answers is a bug in the check, and it is folded in
|
|
42
|
+
* too: each check is STARTED inside the pipeline, so a synchronous throw and
|
|
43
|
+
* a defecting `AsyncResult` alike are recovered into an unhealthy line —
|
|
44
|
+
* escaped, the first would reach the kernel's own `uncaughtException` handler
|
|
45
|
+
* and the second would leave `/healthz` hanging with nothing written.
|
|
43
46
|
*/
|
|
44
|
-
const runHealthChecks = (checks) => allAsync(checks.map((health) => health.check().map(() => ({
|
|
47
|
+
const runHealthChecks = (checks) => allAsync(checks.map((health) => OkAsync().flatMap(() => health.check()).map(() => ({
|
|
45
48
|
name: health.name,
|
|
46
49
|
status: "healthy"
|
|
47
50
|
})).recoverErrCases((matcher) => matcher.with(P.tag("HealthCheckFailed"), (error) => ({
|
|
48
51
|
name: health.name,
|
|
49
52
|
status: "unhealthy",
|
|
50
53
|
reason: error.reason
|
|
51
|
-
})))
|
|
54
|
+
}))).recoverDefect((cause) => Ok({
|
|
55
|
+
name: health.name,
|
|
56
|
+
status: "unhealthy",
|
|
57
|
+
reason: String(cause)
|
|
58
|
+
})))).map((components) => ({
|
|
52
59
|
status: components.every((c) => c.status === "healthy") ? "healthy" : "unhealthy",
|
|
53
60
|
components
|
|
54
61
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btravstack/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "The application kernel: boot a di module into a running process, and stop it without losing work",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"application",
|
|
@@ -46,20 +46,20 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@btravstack/tsconfig": "0.2.0",
|
|
49
|
-
"@types/node": "26.
|
|
49
|
+
"@types/node": "26.4.0",
|
|
50
50
|
"@unthrown/vitest": "5.7.0",
|
|
51
51
|
"@vitest/coverage-v8": "4.1.11",
|
|
52
52
|
"tsdown": "0.22.14",
|
|
53
53
|
"typescript": "7.0.2",
|
|
54
54
|
"unthrown": "5.7.0",
|
|
55
55
|
"vitest": "4.1.11",
|
|
56
|
-
"@btravstack/config": "0.
|
|
57
|
-
"@btravstack/di": "0.
|
|
56
|
+
"@btravstack/config": "0.8.0",
|
|
57
|
+
"@btravstack/di": "0.8.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"unthrown": "^5.0.0",
|
|
61
|
-
"@btravstack/config": "^0.
|
|
62
|
-
"@btravstack/di": "^0.
|
|
61
|
+
"@btravstack/config": "^0.8.0",
|
|
62
|
+
"@btravstack/di": "^0.8.0"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=22"
|