IAct
@rotorsoft/act-root / act/src / IAct
Interface: IAct<TEvents, TActions, TActor, TSchemaReg>
Defined in: libs/act/src/types/action.ts:1135
The reaction-scoped application surface โ what reaction handlers receive as their third argument, and the minimal contract host integrations can depend on.
Exampleโ
Typing a reaction handler without importing the app
import type { IAct, InferActions, InferEvents } from "@rotorsoft/act";
type App = IAct<
InferEvents<typeof StateA> & InferEvents<typeof StateB>,
InferActions<typeof StateA> & InferActions<typeof StateB>
>;
async function myReaction(event: ..., stream: string, app: App) {
await app.do("someAction", target, payload); // reactingTo is injected
const snapshot = await app.load(MyState, "stream-1");
}
Type Parametersโ
TEventsโ
TEvents extends Schemas = Schemas
Event schemas
TActionsโ
TActions extends Schemas = Schemas
Action schemas
TActorโ
Actor type extending base Actor
TSchemaRegโ
TSchemaReg extends SchemaRegister<TActions> = SchemaRegister<TActions>
Map of action name โ target state schema, threaded by
Act so do returns snapshots typed to the action's state. The
default collapses to Schema per action, so annotations written as
IAct<TEvents, TActions> keep compiling unchanged.
Methodsโ
do()โ
do<
TKey>(action,target,payload,options?):Promise<Snapshot<TSchemaReg[TKey],TEvents>[]>
Defined in: libs/act/src/types/action.ts:1141
Type Parametersโ
TKeyโ
TKey extends string
Parametersโ
actionโ
TKey
targetโ
Target<TActor>
payloadโ
Readonly<TActions[TKey]>
options?โ
DoOptions<TEvents>
Returnsโ
Promise<Snapshot<TSchemaReg[TKey], TEvents>[]>
forget()โ
forget(
stream):Promise<{eventCount:number; }>
Defined in: libs/act/src/types/action.ts:1213
Wipe the sensitive-data payload for every event on the stream.
Delegates to the Store's forget_pii(stream), invalidates the cache
entry for the stream, then emits the forgotten lifecycle event.
Throws when called if the configured Store does not implement
forget_pii (its adapter declares pii_isolation: false or omits the
method).
Idempotent: a second call on an already-wiped stream returns
eventCount: 0 and does NOT re-emit forgotten.
Parametersโ
streamโ
string
Target stream to wipe.
Returnsโ
Promise<{ eventCount: number; }>
Count of events whose PII column was set to NULL.
load()โ
Call Signatureโ
load<
S>(state,stream,callback?,asOf?):Promise<Snapshot<S,TEvents>>
Defined in: libs/act/src/types/action.ts:1164
Load a state snapshot for a stream. Two shapes:
Anonymous (bare stream) โ load(state, stream, callback?, asOf?).
The framework default-denies on every PII gate: sensitive event fields
come back as [REDACTED], state fields whose names match sensitive
event fields are also [REDACTED]. Use this when the caller has no
authorization context (background workers, observability probes, etc.).
Auth-aware (LoadTarget) โ load(state, {stream, actor, asOf?}, callback?). Symmetric with IAct.do(state, target, payload). The
read runs the state's .discloses(predicate) against the supplied
actor; sensitive fields come back as plaintext when the predicate
returns true, [REDACTED] otherwise. Forgotten events return
[SHREDDED] regardless of actor (data is gone, no auth question).
Type Parametersโ
Sโ
S extends Schema
Parametersโ
stateโ
State<S, any, any>
streamโ
string
callback?โ
(snapshot) => void
asOf?โ
Returnsโ
Promise<Snapshot<S, TEvents>>
Call Signatureโ
load<
S>(state,target,callback?):Promise<Snapshot<S,TEvents>>
Defined in: libs/act/src/types/action.ts:1170
Type Parametersโ
Sโ
S extends Schema
Parametersโ
stateโ
State<S, any, any>
targetโ
LoadTarget<TActor>
callback?โ
(snapshot) => void
Returnsโ
Promise<Snapshot<S, TEvents>>
Call Signatureโ
load(
state,stream,callback?,asOf?):Promise<Snapshot<Schema,TEvents>>
Defined in: libs/act/src/types/action.ts:1175
Parametersโ
stateโ
string
streamโ
string
callback?โ
(snapshot) => void
asOf?โ
Returnsโ
Promise<Snapshot<Schema, TEvents>>
Call Signatureโ
load(
state,target,callback?):Promise<Snapshot<Schema,TEvents>>
Defined in: libs/act/src/types/action.ts:1181
Parametersโ
stateโ
string
targetโ
LoadTarget<TActor>
callback?โ
(snapshot) => void
Returnsโ
Promise<Snapshot<Schema, TEvents>>
query()โ
query(
query,callback?):Promise<{count:number;first?:Committed<TEvents, keyofTEvents>;last?:Committed<TEvents, keyofTEvents>; }>
Defined in: libs/act/src/types/action.ts:1187
Parametersโ
queryโ
callback?โ
(event) => void
Returnsโ
Promise<{ count: number; first?: Committed<TEvents, keyof TEvents>; last?: Committed<TEvents, keyof TEvents>; }>
query_array()โ
query_array(
query):Promise<Committed<TEvents, keyofTEvents>[]>
Defined in: libs/act/src/types/action.ts:1196
Parametersโ
queryโ
Returnsโ
Promise<Committed<TEvents, keyof TEvents>[]>