omkit 0.2.1 → 0.2.2
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 +1 -0
- package/dist/core/ActionRun.js +5 -1
- package/dist/core/types.d.ts +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -197,6 +197,7 @@ An Activity exposes its declared events plus the lifecycle ones (`done`, `error`
|
|
|
197
197
|
|
|
198
198
|
- **`activity.on(event, handler)`** — subscribe to every emit.
|
|
199
199
|
- **`activity.once(event)`** — a **promise** for the next emit; resolves `undefined` if the Activity settles first, so an `await` never hangs. A retained snapshot (like `healthy`) is replayed immediately even if you subscribe late.
|
|
200
|
+
- **`activity.once("done")`** is the exception — it awaits the outcome itself: resolves the result on success, **rejects** on failure or cancellation (and observes the failure). That makes `await step().once("done")` a hard gate: a failed step throws at the `await`, in your body, instead of letting the orchestration sail past it. Use `.result` when a failure is an outcome you want to branch on rather than a stop.
|
|
200
201
|
|
|
201
202
|
```ts
|
|
202
203
|
const probe = healthcheck({ url: "http://localhost:3000" });
|
package/dist/core/ActionRun.js
CHANGED
|
@@ -114,7 +114,11 @@ export class ActionRun {
|
|
|
114
114
|
if (key === "error")
|
|
115
115
|
this.observed = true;
|
|
116
116
|
if (key === "done") {
|
|
117
|
-
|
|
117
|
+
// Awaiting completion IS observing the outcome: deliver a failure to the awaiter
|
|
118
|
+
// (reject, like `.ref`) instead of resolving `undefined` and letting the body
|
|
119
|
+
// sail past a failed step while the unobserved-failure teardown races it.
|
|
120
|
+
this.observed = true;
|
|
121
|
+
return this.settled.promise;
|
|
118
122
|
}
|
|
119
123
|
return new Promise((resolve) => {
|
|
120
124
|
let done = false;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -92,7 +92,12 @@ export interface Activity<Result = unknown, Events extends object = NoEvents, Ha
|
|
|
92
92
|
handleFailure(handler: (error: unknown) => void): this;
|
|
93
93
|
/** Subscribe to every emit of a declared/system event (`done`/`error`/`attached`). */
|
|
94
94
|
on<K extends keyof InstanceEvents<Events, Result>>(key: K, handler: EventHandler<InstanceEvents<Events, Result>[K]>): void;
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Next emit of `key`; resolves `undefined` if the node settles first (never rejects).
|
|
97
|
+
* Exception — `once("done")` awaits the outcome itself: it resolves the result on
|
|
98
|
+
* success and **rejects** on failure/cancellation (observing the failure), so
|
|
99
|
+
* `await activity.once("done")` is a hard step-gate the body cannot sail past.
|
|
100
|
+
*/
|
|
96
101
|
once<K extends keyof InstanceEvents<Events, Result>>(key: K): Promise<InstanceEvents<Events, Result>[K] | undefined>;
|
|
97
102
|
/** Tag this run; chainable. */
|
|
98
103
|
tag(name: string): this;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omkit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A tiny runtime for developer workflows: typed actions that pass runtime capabilities and emit typed events, under one run and one shared log. The operational/runtime layer to tskb's knowledge layer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|