Skip to content

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

Class: AnyPort

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:48

Concrete implementation of an Any Port.

This class extends BasePort using AnyPortConfig and AnyPortValue. It leverages the AnyPortPlugin to handle validation, serialization, and deserialization by delegating to the underlying port type's plugin.

The Any port acts as a wrapper around any other port type. Its configuration includes an underlyingType field that specifies which port type to use, and all operations are delegated to that type's plugin.

Example usage: const config: AnyPortConfig = { type: 'any', underlyingType: { type: 'string', minLength: 2, }, defaultValue: { type: 'any', value: { type: 'string', value: 'hello' }, }, }

const anyPort = new AnyPort(config) anyPort.setValue({ type: 'any', value: { type: 'string', value: 'world' }, }) console.log(anyPort.getValue()) // => { type: 'any', value: { type: 'string', value: 'world' } }

Extends

Constructors

Constructor

new AnyPort(config): AnyPort

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:49

Parameters

config

AnyPortConfig

Returns

AnyPort

Overrides

BasePort.constructor

Properties

config

protected config: AnyPortConfig

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

Inherited from

BasePort.config


value?

protected optional value: any

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<AnyPortConfig>

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

Clones the port instance.

Returns

IPort<AnyPortConfig>

A new port instance with the same configuration and value.

Inherited from

BasePort.clone


cloneWithNewId()

cloneWithNewId(): IPort<AnyPortConfig>

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:301

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

Returns

IPort<AnyPortConfig>

Overrides

BasePort.cloneWithNewId


deserialize()

deserialize(data): IPort<AnyPortConfig>

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<AnyPortConfig>

Inherited from

BasePort.deserialize


deserializeConfig()

deserializeConfig(data): AnyPortConfig

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:253

Deserializes JSON data into an AnyPortConfig. Delegates to AnyPortPlugin.deserializeConfig which handles deserializing both the any port config and the underlying type's config.

Parameters

data

unknown

The JSON data.

Returns

AnyPortConfig

The deserialized configuration.

Overrides

BasePort.deserializeConfig


deserializeValue()

deserializeValue(data): any

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:264

Deserializes JSON data into an AnyPortValue. Delegates to AnyPortPlugin.deserializeValue which handles deserializing both the any port value and the underlying value.

Parameters

data

unknown

The JSON data.

Returns

any

The deserialized port value.

Overrides

BasePort.deserializeValue


getConfig()

getConfig(): AnyPortConfig

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:59

Retrieves the current port configuration.

Returns

AnyPortConfig

The port configuration of type C.

Overrides

BasePort.getConfig


getDefaultValue()

getDefaultValue(): any

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:98

Returns the default value from the configuration.

Returns

any

The default AnyPortValue if specified; otherwise undefined.

Overrides

BasePort.getDefaultValue


getRawConfig()

getRawConfig(): AnyPortConfig

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:90

Returns

AnyPortConfig


getValue()

getValue(): any

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

Gets the current port value.

Returns

any

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/AnyPort.ts:231

Serializes the any port configuration. Delegates to AnyPortPlugin.serializeConfig which handles serializing both the any port config and the underlying type's config.

Parameters

config

AnyPortConfig

The any port configuration.

Returns

unknown

The serialized configuration.

Overrides

BasePort.serializeConfig


serializeValue()

serializeValue(value): unknown

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:242

Serializes the any port value. Delegates to AnyPortPlugin.serializeValue which handles serializing both the any port value and the underlying value.

Parameters

value

any

The any port value.

Returns

unknown

The serialized value.

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

AnyPortConfig

New configuration of type C.

Returns

void

Inherited from

BasePort.setConfig


setUnderlyingType()

setUnderlyingType(underlyingType): void

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:273

Sets the underlying type of the any port. This method allows changing the underlying type dynamically.

Parameters

underlyingType

The new underlying type configuration.

IPortConfig | undefined

Returns

void


setValue()

setValue(newValue): void

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:102

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

Parameters

newValue

any

The new value to set for the port.

Returns

void

Overrides

BasePort.setValue


unwrapUnderlyingType()

unwrapUnderlyingType(): IPortConfig | undefined

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:281

Unwraps the underlying type of the any port. It is iterates over the underlying types and while the underlying type is 'any' and has an underlyingType, it will return the actual underlying type.

Returns

IPortConfig | undefined


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/AnyPort.ts:219

Validates the any port configuration. Delegates to AnyPortPlugin.validateConfig which validates both the any port structure and the underlying type's configuration.

Parameters

config

AnyPortConfig

The any port configuration.

Returns

boolean

True if valid; otherwise false.

Overrides

BasePort.validateConfig


validateValue()

validateValue(value): boolean

Defined in: packages/fireflow-types/src/port/instances/AnyPort.ts:207

Validates the any port value. Delegates to AnyPortPlugin.validateValue which in turn delegates to the underlying type's plugin for value validation.

Parameters

value

any

The any port value to validate.

Returns

boolean

True if valid; otherwise false.

Overrides

BasePort.validateValue

Licensed under BUSL-1.1