Skip to content

PersistentAI API Documentation / @persistentai/fireflow-types / NumberPort

Class: NumberPort

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:36

Concrete implementation of a Number Port.

This class extends the BasePort with NumberPortConfig and NumberPortValue. It leverages the NumberPortPlugin to handle validation, serialization, deserialization, and default value retrieval.

Example usage: const config: NumberPortConfig = { type: 'number', min: 0, max: 100, step: 2, integer: true, defaultValue: { type: 'number', value: 42 }, }

const numberPort = new NumberPort(config) numberPort.setValue({ type: 'number', value: 50 }) console.log(numberPort.getValue()) // => { type: 'number', value: 50 }

Extends

Constructors

Constructor

new NumberPort(config): NumberPort

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:37

Parameters

config

NumberPortConfig

Returns

NumberPort

Overrides

BasePort.constructor

Properties

config

protected config: NumberPortConfig

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:16

Inherited from

BasePort.config


value?

protected optional value: NumberPortValue

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:17

Inherited from

BasePort.value

Accessors

id

Get Signature

get id(): string

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:25

The unique identifier of the port.

Returns

string

Inherited from

BasePort.id


key

Get Signature

get key(): string

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:29

The key of the port.

Returns

string

Inherited from

BasePort.key

Methods

addConnection()

addConnection(nodeId, portId): void

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:153

Adds a connection to the port metadata.

Parameters

nodeId

string

The ID of the node to connect to.

portId

string

The ID of the port to connect to.

Returns

void

Inherited from

BasePort.addConnection


clone()

clone(): IPort<NumberPortConfig>

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:130

Clones the port instance.

Returns

IPort<NumberPortConfig>

A new port instance with the same configuration and value.

Inherited from

BasePort.clone


cloneWithNewId()

cloneWithNewId(): IPort<NumberPortConfig>

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:127

Clones the port with a new ID. Useful for creating copies of the port with a unique identifier.

Returns

IPort<NumberPortConfig>

Overrides

BasePort.cloneWithNewId


deserialize()

deserialize(data): IPort<NumberPortConfig>

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:79

Deserializes the given JSONValue (expected to hold { config, value }) and updates both the config and current value.

Parameters

data

unknown

Returns

IPort<NumberPortConfig>

Inherited from

BasePort.deserialize


deserializeConfig()

deserializeConfig(data): NumberPortConfig

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:108

Deserializes the provided JSON data into a number port configuration. Delegates the deserialization logic to the NumberPortPlugin.

Parameters

data

unknown

The JSON data representing the configuration.

Returns

NumberPortConfig

The deserialized NumberPortConfig.

Overrides

BasePort.deserializeConfig


deserializeValue()

deserializeValue(data): NumberPortValue

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:119

Deserializes the given JSON data into a number port value. Delegates this task to the NumberPortPlugin.

Parameters

data

unknown

The JSON data representing the value.

Returns

NumberPortValue

The deserialized NumberPortValue.

Overrides

BasePort.deserializeValue


getConfig()

getConfig(): NumberPortConfig

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:33

Retrieves the current port configuration.

Returns

NumberPortConfig

The port configuration of type C.

Inherited from

BasePort.getConfig


getDefaultValue()

getDefaultValue(): NumberPortValue

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:51

Retrieves the default value from the configuration.

Returns

NumberPortValue

The default number value if provided; otherwise, undefined.

Overrides

BasePort.getDefaultValue


getValue()

getValue(): NumberPortValue

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:42

Gets the current port value.

Returns

NumberPortValue

The port value, or undefined if none is set.

Inherited from

BasePort.getValue


isSystem()

isSystem(): boolean

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:138

Check if the port is a system port.

Returns

boolean

True if the port is a system port, otherwise false.

Inherited from

BasePort.isSystem


isSystemError()

isSystemError(): boolean

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:142

Check if the port is a system error port.

Returns

boolean

True if the port is a system error port, otherwise false.

Inherited from

BasePort.isSystemError


removeConnection()

removeConnection(nodeId, portId): void

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:179

Removes a connection from the port metadata.

Parameters

nodeId

string

The ID of the node to disconnect from.

portId

string

The ID of the port to disconnect from.

Returns

void

Inherited from

BasePort.removeConnection


reset()

reset(): void

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:50

Resets the port’s current value.

In typical implementations, this resets the value to a default (if available).

Returns

void

Inherited from

BasePort.reset


serialize()

serialize(): unknown

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:59

Serializes both config and value into a JSONValue–compatible object. It calls the abstract serializeConfig and serializeValue methods.

Returns

unknown

Inherited from

BasePort.serialize


serializeConfig()

serializeConfig(config): unknown

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:86

Serializes the current number port configuration into a JSON-compatible object. Delegates to the NumberPortPlugin.

Parameters

config

NumberPortConfig

The number port configuration to serialize.

Returns

unknown

The serialized configuration as a JSONValue.

Overrides

BasePort.serializeConfig


serializeValue()

serializeValue(value): unknown

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:97

Serializes the provided number port value into a JSON-compatible object. Delegates the serialization logic to the NumberPortPlugin.

Parameters

value

NumberPortValue

The number port value to serialize.

Returns

unknown

The serialized value as a JSONValue.

Overrides

BasePort.serializeValue


setConfig()

setConfig(newConfig): void

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:37

Updates the port configuration with a new configuration object.

Parameters

newConfig

NumberPortConfig

New configuration of type C.

Returns

void

Inherited from

BasePort.setConfig


setValue()

setValue(newValue): void

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:46

Sets or updates the port value. The value must be validated before being accepted.

Parameters

newValue

NumberPortValue

The new value to set for the port.

Returns

void

Inherited from

BasePort.setValue


validate()

validate(): boolean

Defined in: packages/fireflow-types/src/port/base/BasePort.ts:118

Validates both the current configuration and value. It defers to the abstract validateConfig and validateValue methods.

Returns

boolean

Inherited from

BasePort.validate


validateConfig()

validateConfig(config): boolean

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:74

Validates the number port configuration. Delegates configuration validation to the NumberPortPlugin.

Parameters

config

NumberPortConfig

The number port configuration.

Returns

boolean

True if the configuration is valid; otherwise, false.

Overrides

BasePort.validateConfig


validateValue()

validateValue(value): boolean

Defined in: packages/fireflow-types/src/port/instances/NumberPort.ts:62

Validates the provided number port value against the current configuration. Delegates the validation logic to the NumberPortPlugin.

Parameters

value

NumberPortValue

The number port value to validate.

Returns

boolean

True if the value is valid; otherwise, false.

Overrides

BasePort.validateValue

Licensed under BUSL-1.1