@effectstream/sm 0.100.13 → 0.100.14
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/package.json +9 -8
- package/types.ts +27 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effectstream/sm",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://effectstream.github.io/docs/",
|
|
6
6
|
"repository": {
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
"./grammar": "./primitives/src/grammar.ts"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@effectstream/concise": "0.100.
|
|
21
|
-
"@effectstream/config": "0.100.
|
|
22
|
-
"@effectstream/coroutine": "0.100.
|
|
23
|
-
"@effectstream/crypto": "0.100.
|
|
24
|
-
"@effectstream/db": "0.100.
|
|
25
|
-
"@effectstream/
|
|
26
|
-
"@effectstream/
|
|
20
|
+
"@effectstream/concise": "0.100.14",
|
|
21
|
+
"@effectstream/config": "0.100.14",
|
|
22
|
+
"@effectstream/coroutine": "0.100.14",
|
|
23
|
+
"@effectstream/crypto": "0.100.14",
|
|
24
|
+
"@effectstream/db": "0.100.14",
|
|
25
|
+
"@effectstream/event-client": "0.100.14",
|
|
26
|
+
"@effectstream/log": "0.100.14",
|
|
27
|
+
"@effectstream/utils": "0.100.14",
|
|
27
28
|
"pg": "8.17.2",
|
|
28
29
|
"pg-tx": "^1.0.1",
|
|
29
30
|
"@sinclair/typebox": "0.34.41",
|
package/types.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
//import type { AppEvents } from "@effectstream/events";
|
|
2
|
-
|
|
3
1
|
import type { PreparedQuery } from "@pgtyped/runtime";
|
|
4
2
|
import type {
|
|
5
3
|
AddressType,
|
|
@@ -8,11 +6,27 @@ import type {
|
|
|
8
6
|
WalletAddress,
|
|
9
7
|
} from "@effectstream/utils";
|
|
10
8
|
import type { Prando } from "@effectstream/crypto";
|
|
9
|
+
import type { EventPathAndDef, ResolvedPath } from "@effectstream/event-client";
|
|
10
|
+
import type { Static } from "@sinclair/typebox";
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Closure passed to every state transition for emitting custom app events.
|
|
14
|
+
*
|
|
15
|
+
* - The runtime collects events into a per-input buffer during STF execution.
|
|
16
|
+
* - On STF success, events are promoted to the per-block buffer.
|
|
17
|
+
* - After the block's `COMMIT` succeeds, events are flushed to MQTT.
|
|
18
|
+
* - On STF failure or block-level `ROLLBACK`, events are dropped.
|
|
19
|
+
*
|
|
20
|
+
* `blockHeight` is auto-injected by `registerEvents` and auto-filled by the
|
|
21
|
+
* runtime — apps omit it from the payload.
|
|
22
|
+
*
|
|
23
|
+
* See plan: /Users/edwardalvarado/.claude/plans/wild-kindling-reddy.md
|
|
24
|
+
*/
|
|
25
|
+
export type EmitFn = <E extends EventPathAndDef>(
|
|
26
|
+
event: E,
|
|
27
|
+
payload: Omit<Static<E["type"]> & ResolvedPath<E["path"]>, "blockHeight">,
|
|
28
|
+
) => void;
|
|
14
29
|
|
|
15
|
-
// TODO: replace any
|
|
16
30
|
export type BaseStfInput = {
|
|
17
31
|
blockHeight: EffectstreamBlockNumber;
|
|
18
32
|
blockTimestamp: TimestampMs;
|
|
@@ -21,7 +35,15 @@ export type BaseStfInput = {
|
|
|
21
35
|
signerAddress?: WalletAddress;
|
|
22
36
|
signerAddressType?: AddressType;
|
|
23
37
|
randomGenerator: Prando;
|
|
38
|
+
/** Emit a custom app event. Delivered to MQTT after the block commits. */
|
|
39
|
+
emit: EmitFn;
|
|
24
40
|
};
|
|
41
|
+
|
|
42
|
+
// Retained for compatibility with the existing `Stm<Grammar, Events>` generic
|
|
43
|
+
// parameter. Future work: thread a real registered-events union through here so
|
|
44
|
+
// `data.emit` is restricted to the app's declared events.
|
|
45
|
+
export type AppEvents = any;
|
|
46
|
+
|
|
25
47
|
export type BaseStfOutput<Events extends AppEvents> = {
|
|
26
48
|
stateTransitions: [PreparedQuery<any, any>, any][];
|
|
27
49
|
events: Events[];
|