@operaide/aktor
This is the main library, providing the general interface for aktor and reaktor definitions.
It contains interfaces and functions to create Aktors and define Reaktors.
Take a look at the current set of Guides, to see how it can be used.
Available Aktors
Here's a short reference of the available aktors from the @operaide/aktor library:
Basic Aktors
- aktorConst: A constant Aktor that always returns the same value.
- aktorSetting: An Aktor for storing settings with type validation using Zod.
- aktorDefault: Returns a default value if the provided Aktor is undefined or returns undefined.
Control Flow Aktors
- aktorIf: Implements a conditional statement, returns the 'then' value if condition is true, otherwise null.
- aktorIfElse: Implements a conditional statement with an else clause, returns 'then' or 'else' value based on condition.
- aktorParallel: Executes multiple aktors in parallel and returns an array of their results.
- aktorSome: Checks if at least one of the provided aktors returns a truthy value.
Loop Aktors
- aktorDoWhile: Executes a block of aktors while a condition is true, returning the last value.
- aktorWhileDo: Executes a block of aktors at least once and continues while a condition is true, returning the last value or an else value if not present.
Array Operation Aktors
- aktorFilter: Filters an array of aktors based on a predicate function.
- aktorFind: Finds the first element in an array of aktors that satisfies a predicate function.
Function Aktors
- aktorFunction: Creates an aktor from a pure function.
- createAktorFunction: Creates an aktor factory function from a pure function.
- aktorFunctionAsync: Creates an aktor from an asynchronous pure function.
- createAktorFunctionAsync: Creates an aktor factory function from an asynchronous pure function.
Utility Aktors
- aktorJoinStrings: Joins an array of strings with newline characters.
- aktorRestCall: Makes HTTP requests using axios and returns the response data.
For more detailed information on each aktor, explore the Library using IntelliSense in your IDE!
To view the latest version, please take a look at the Registry
Polling Reaktors
Polling reaktors execute on a schedule and signal whether more work exists via a boolean return value.
API: registerPollingReaktor(config: PollingReaktorConfig)
Configuration:
reaktorDefinitionId- Unique identifierinterval- Execution interval ('2m','5s','1h', etc.)autoStart- Start automatically on server startup (default:false)label,description- Optional metadatacreateReaktor- ReturnsAktor<boolean>
Boolean Contract:
true= More work exists, execute again immediatelyfalse= No work, wait for interval
REST Endpoints (auto-generated per reaktor):
POST /api/v1/polling/{reaktorId}/startPOST /api/v1/polling/{reaktorId}/stopGET /api/v1/polling/{reaktorId}/status