@flow-state-dev/patterns/event-actors
Interfaces
ActorConfig
Properties
block
block: BlockDefinition<any, any>;
Block to execute when a matching entry is emitted. Receives the entry as input (NOT TaskWorkerInput — the wrapper unwraps it). Can be any block kind.
name
name: string;
Unique name for this actor — also the worker-registry key.
watch
watch: string[];
Glob patterns over ${type}:${topic} that this actor subscribes to.
Must have at least one pattern. * matches a single segment, **
matches any number of segments.
EventActorsConfig
Properties
actors
actors: Readonly<ActorConfig>[];
Actors to register. Each actor's watch patterns determine which
entries trigger its body block. Must have at least one actor.
concurrency?
concurrency?: number;
Maximum concurrent workers in the underlying taskBoard. Default: 16.
maxDepth?
maxDepth?: number;
Maximum re-emission depth. Only meaningful when reEmit is true.
At maxDepth, actor bodies still run but their output is appended
without further dispatch. Default: 3.
maxEnqueuedTasks?
maxEnqueuedTasks?: number | null;
maxTotalTasks?
maxTotalTasks?: number | null;
Creation bounds for the internal board. Defaults 500/100 —
unchanged behavior when unset. A long-running reactive chain can
legitimately exceed them, so both are reachable here: raise the number, or
pass null for explicitly unbounded on that axis.
name
name: string;
Pattern instance name. Block-name prefix and TaskCollection id.
reEmit?
reEmit?: boolean;
When true, actor body outputs that conform to the entry shape
({ type, topic, body }) are automatically appended to the
workspace and dispatched as new tasks to matching actors —
creating recursive reactive chains.
workspace
workspace: object;
Workspace — result of createEventActorsWorkspace(...).
workspace
workspace: DefinedResource;
EventActorsHandle
Properties
actors
actors: readonly Readonly<ActorConfig>[];
The registered actors (frozen).
emit
emit: SequencerDefinition<any, any>;
Sequencer block: appends entry + drains matching actors.
workspace
workspace: DefinedResource;
The workspace resource. Declare on your flow's resources.
EventActorsWorkspaceConfig
Properties
entries
entries: ZodTypeAny;
Zod schema describing entry shape. Stored as documentation; the
resource itself stores entries as z.any() to avoid generic depth
issues.
name
name: string;
Workspace name — used as resource-name prefix.
Type Aliases
Actor
type Actor = Readonly<ActorConfig>;
EventActorsWorkspaceState
type EventActorsWorkspaceState = z.infer<typeof eventActorsWorkspaceStateSchema>;
Variables
eventActorsWorkspaceStateSchema
const eventActorsWorkspaceStateSchema: z.ZodObject<{
entries: z.ZodDefault<z.ZodArray<z.ZodAny, "many">>;
}, "strip", z.ZodTypeAny, {
entries: any[];
}, {
entries?: any[];
}>;
Functions
actor()
function actor(config): Actor;
Frozen actor descriptor.
Parameters
config
Returns
compilePattern()
function compilePattern(pattern): RegExp;
Compiles a glob pattern into a RegExp. Results are cached for repeated use.
Parameters
pattern
string
Returns
RegExp
createAppendEntry()
function createAppendEntry(
name,
workspaceResource,
resourceKey?
): BlockDefinition<ZodAny, ZodTypeAny, any, void>;
State-only: writes the workspace resource and emits, returns nothing.
Parameters
name
string
workspaceResource
DefinedResource
resourceKey?
string
Returns
BlockDefinition<ZodAny, ZodTypeAny, any, void>
Remarks
Compose with .tap(createAppendEntry(...)), never .step() —
it returns nothing, so .step() hands undefined to the next step.
createEventActorsWorkspace()
function createEventActorsWorkspace(_config): object;
Creates an eventActors workspace — the writable resource that stores
the entry log. Pair with eventActors({ workspace, actors, ... }).
Parameters
_config
Returns
object
workspace
workspace: object & ResourceConfig<JsonObject> & object;
Type Declaration
client
readonly client: object;
client.expose
readonly expose: readonly ["entries"];
scope
readonly scope: "session";
stateSchema
readonly stateSchema: ZodObject<{
entries: ZodDefault<ZodArray<ZodAny, "many">>;
}, "strip", ZodTypeAny, {
entries: any[];
}, {
entries?: any[];
}>;
writable
readonly writable: true;
ClientType
ClientType: Pick<{
entries: any[];
}, "entries">;
ContextType
ContextType: ResourceContext<{
entries: any[];
}>;
StateType
StateType: object;
StateType.entries
entries: any[];
createEventActorsWorkspaceResource()
function createEventActorsWorkspaceResource(): object & ResourceConfig<JsonObject> & object;
Creates the entry-log workspace resource. Entries are stored as an
append-only array. The actual entry shape is user-defined via config;
the resource stores them as z.any() to avoid generic depth issues.
client.expose whitelists the entries field so UI components can read
the reactive chain in real time without drifting if the state schema
grows internal-only fields later.
Returns
object & ResourceConfig<JsonObject> & object
eventActors()
function eventActors(config): EventActorsHandle;
Wires actors to a workspace and returns the emit block. Internally
composes taskBoard for the concurrent drain.
Parameters
config
Returns
matchTopic()
function matchTopic(pattern, topicKey): boolean;
Tests whether a topic key matches a glob pattern.
Parameters
pattern
string
topicKey
string
Returns
boolean
normalizeToEntries()
function normalizeToEntries(output): EntryLike[];
Normalises actor body output into an array of entry objects suitable
for re-emission. Returns only objects that have type (string),
topic (string), and body fields. Non-entry values are dropped.
Parameters
output
unknown
Returns
EntryLike[]