State
@rotorsoft/act-root / act/src / State
Type Alias: State<TState, TEvents, TActions, TName>
State<
TState,TEvents,TActions,TName> =StateSchemas<TState,TEvents,TActions> &object
Defined in: libs/act/src/types/action.ts:609
The full state definition, including schemas, handlers, and optional invariants and snapshot logic.
Type Declarationโ
given?โ
optionalgiven?:GivenHandlers<TState,TActions>
initโ
init: () =>
Readonly<TState>
Returnsโ
Readonly<TState>
nameโ
name:
TName
onโ
on:
ActionHandlers<TState,TEvents,TActions>
options?โ
optionaloptions?:{ [TKey in keyof TActions]?: ActionOptions }
Per-action retry policy keyed by action name. Set by
state.on(entry, options); consumed by the orchestrator's command
path. Actions without an entry behave as if { maxRetries: 0 } โ
ConcurrencyError surfaces on first conflict.
patchโ
patch:
PatchHandlers<TState,TEvents>
snap?โ
optionalsnap?: (snapshot) =>boolean
Parametersโ
snapshotโ
Snapshot<TState, TEvents>
Returnsโ
boolean
archive()?โ
optionalarchive(stream,head):Promise<void>
Archiver set by .archives(fn). The online close cycle threads
this into CloseTarget.archive for every truncate it
stages, so the existing close-cycle's archive-while-guarded
invariant carries over to the autoclose path. Absent โ the cycle
truncates without an archive step. Bivariant method-shorthand
for the same State<specific> โ State<any, any, any> reason
as disclose / autoclose.
Parametersโ
streamโ
string
headโ
Committed<TEvents, keyof TEvents>
Returnsโ
Promise<void>
autoclose()?โ
optionalautoclose(stream,head,count):boolean
Online close predicate set by .autocloses(predicate). The
orchestrator's autoclose cycle iterates this state's streams once
per tick and calls the predicate per candidate; truthy results are
scheduled for atomic truncate-and-seed via Store.truncate.
Absent โ the state opts out of online close entirely (zero
per-cycle cost).
Bivariant method-shorthand for the same reason as disclose โ
keeps State<specific> assignable to State<any, any, any>. The
.autocloses() builder method keeps the narrow signature.
Parametersโ
streamโ
string
headโ
Committed<TEvents, keyof TEvents>
countโ
number
Returnsโ
boolean
disclose()?โ
optionaldisclose(event,actor):boolean
Disclosure predicate set by .discloses(predicate). Gates external
reads of sensitive(...)-marked fields โ returning true allows the
actor to see plaintext, false redacts. When absent, the framework
default-denies on every external read (sensitive fields are always
substituted with "[REDACTED]"). See #855 / epic #566.
Parametersโ
eventโ
Committed<TEvents, keyof TEvents>
actorโ
Returnsโ
boolean
message()โ
message(
validated):Message<TEvents, keyofTEvents>
Parametersโ
validatedโ
Message<TEvents, keyof TEvents>
Returnsโ
Message<TEvents, keyof TEvents>
view()โ
view(
event,actor):Committed<TEvents, keyofTEvents>
Parametersโ
eventโ
Committed<TEvents, keyof TEvents>
actorโ
Readonly<{[key: string]: unknown; id: string; name: string; }> | undefined
Returnsโ
Committed<TEvents, keyof TEvents>
Type Parametersโ
TStateโ
TState extends Schema
State schema.
TEventsโ
TEvents extends Schemas
Event schemas.
TActionsโ
TActions extends Schemas
Action schemas.
TNameโ
TName extends string = string
State name literal.