@btravstack/core 0.7.0 → 0.9.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/README.md CHANGED
@@ -44,7 +44,10 @@ class Greeter extends Port("Greeter")<{
44
44
 
45
45
  const AppModule = Module("App")({
46
46
  provides: [
47
- Provider(Greeter)({ value: { greet: (name: string) => `hello, ${name}` } }),
47
+ Provider(Greeter)({
48
+ inject: {},
49
+ value: { greet: (name: string) => `hello, ${name}` },
50
+ }),
48
51
  ],
49
52
  exports: [Greeter],
50
53
  });
@@ -94,7 +97,7 @@ class Ticker extends RuntimePort<Runtime<typeof Greeter>> {}
94
97
 
95
98
  const TickerApp = Module("TickerApp")({
96
99
  imports: [AppModule],
97
- provides: [Provider(Ticker)({ value: ticker })],
100
+ provides: [Provider(Ticker)({ inject: {}, value: ticker })],
98
101
  exports: [Greeter, Ticker],
99
102
  });
100
103
 
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. What
42
- * survives to `allAsync`'s error channel is a `Defect` alone — a check that
43
- * threw rather than answered, which is a bug in the check.
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
- }))))).map((components) => ({
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
  }));
@@ -478,7 +485,10 @@ const start = (module, options = {}) => {
478
485
  });
479
486
  const root = (0, _btravstack_di.Module)("Kernel")({
480
487
  imports: providesEnv(module) ? [module] : [module, (0, _btravstack_di.Module)("Environment")({
481
- provides: [(0, _btravstack_di.Provider)(_btravstack_config.Env)({ value: env })],
488
+ provides: [(0, _btravstack_di.Provider)(_btravstack_config.Env)({
489
+ inject: {},
490
+ value: env
491
+ })],
482
492
  exports: [_btravstack_config.Env]
483
493
  })],
484
494
  exports: [module]
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. What
78
- * survives to `allAsync`'s error channel is a `Defect` alone — a check that
79
- * threw rather than answered, which is a bug in the check.
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**: built as the unit opens, torn down
443
- * as it closes — while the unit's ambient record is still open — reading
444
- * anything the application context carries.
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. What
78
- * survives to `allAsync`'s error channel is a `Defect` alone — a check that
79
- * threw rather than answered, which is a bug in the check.
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**: built as the unit opens, torn down
443
- * as it closes — while the unit's ambient record is still open — reading
444
- * anything the application context carries.
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. What
41
- * survives to `allAsync`'s error channel is a `Defect` alone — a check that
42
- * threw rather than answered, which is a bug in the check.
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
- }))))).map((components) => ({
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
  }));
@@ -477,7 +484,10 @@ const start = (module, options = {}) => {
477
484
  });
478
485
  const root = Module("Kernel")({
479
486
  imports: providesEnv(module) ? [module] : [module, Module("Environment")({
480
- provides: [Provider(Env)({ value: env })],
487
+ provides: [Provider(Env)({
488
+ inject: {},
489
+ value: env
490
+ })],
481
491
  exports: [Env]
482
492
  })],
483
493
  exports: [module]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btravstack/core",
3
- "version": "0.7.0",
3
+ "version": "0.9.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.2.0",
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.7.0",
57
- "@btravstack/di": "0.7.0"
56
+ "@btravstack/config": "0.9.0",
57
+ "@btravstack/di": "0.9.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "unthrown": "^5.0.0",
61
- "@btravstack/config": "^0.7.0",
62
- "@btravstack/di": "^0.7.0"
61
+ "@btravstack/config": "^0.9.0",
62
+ "@btravstack/di": "^0.9.0"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=22"