@connectv/core
Version:
agent-based reactive programming library for typescript/javascript
127 lines (126 loc) • 4.05 kB
TypeScript
import { PartialFlow } from '../pin/partial-flow';
import { Group } from '../pin/group';
import { PinMap } from '../pin/pin-map';
import { PinLike } from '../pin/pin-like';
import { Signature } from './signature';
import { AgentLike } from './agent-like';
/**
*
* The parent class for [agents](https://connective.dev/docs/agent).
*
*/
export declare class Agent extends PartialFlow implements AgentLike {
readonly signature: Signature;
private _inputs;
private _outputs;
private _entries;
private _exits;
/**
*
* @param signature the [signature](https://connective.dev/docs/agent#signature)
* of the agent. Must be determined either by instantiators or sub-classes.
*
*/
constructor(signature: Signature);
/**
*
* @param label
* @returns the input pin corresponding to given label
* @throws an error if given label is not allowed by the agent's
* [signature](https://connective.dev/docs/agent#signature).
*
*/
in(label: string | number): PinLike;
/**
*
* @param label
* @returns the output pin corresponding to given label
* @throws an error if given label is not allowed by the agent's
* [signature](https://connective.dev/docs/agent#signature).
*
*/
out(label: string | number): PinLike;
/**
*
* @returns the entry pins for this agent for it to behave as a partial flow.
* You can read more about partial flows [here](https://connective.dev/docs/agent#implicit-connection).
*
*/
get entries(): Group;
/**
*
* @returns the exit pins for this agent for it to behave as a partial flow.
* You can read more about partial flows [here](https://connective.dev/docs/agent#implicit-connection).
*
*/
get exits(): Group;
get inputs(): PinMap;
get outputs(): PinMap;
/**
*
* @note an Agent's `.clear()` also clears up
* input and output pins.
*
*/
clear(): this;
/**
*
* Checks if given input label matches the agent's
* [signature](https://connective.dev/docs/agent#signature).
*
* Override this to change how validation of input labels occurs.
*
* @param label the input label to be validated
*
*/
protected checkInput(label: string): void;
/**
*
* Checks if given output label matches the agent's
* [signature](https://connective.dev/docs/agent#signature).
*
* Override this to change how validation of output labels occurs.
*
*/
protected checkOutput(label: string): void;
/**
*
* Validates given label and creates the corresponding input pin.
*
* Override this to change how an input pin is created.
*
* @param label
* @returns the corresponding input pin.
*
*/
protected createInput(label: string): PinLike;
/**
*
* Validates given label and creates the corresponding output pin.
*
* Override this to change how an output pin is created.
*
* @param label
* @returns the corresponding output pin.
*
*/
protected createOutput(label: string): PinLike;
/**
*
* Override this to specify which pins should be considered as entries of this agent as a `PartialFlow`.
* You can read more about partial flows [here](https://connective.dev/docs/agent#implicit-connection).
* If not overriden, the agent will be considered an improper patial flow and an error will be thrown
* when used as one.
*
*/
protected createEntries(): PinLike[] | Group;
/**
*
* Override this to specify which pins should be considered as exits of this agent as a `PartialFlow`.
* You can read more about partial flows [here](https://connective.dev/docs/agent#implicit-connection).
* If not overriden, the agent will be considered an improper patial flow and an error will be thrown
* when used as one.
*
*/
protected createExits(): PinLike[] | Group;
}