Skip to content

ChainGraph API Documentation / @badaitech/chaingraph-types / StringPort

Class: StringPort

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:39

Concrete StringPort implementation that extends BasePort.

This implementation reuses the validation, serialization, and deserialization logic available in the StringPortPlugin.

The plugin functions are used to: • Create a default value – if a defaultValue is provided in the config. • Validate the value using the plugin's validate function (if available). • Serialize and deserialize both the configuration and value.

Example

ts
const config: StringPortConfig = {
  type: 'string',
  minLength: 3,
  maxLength: 50,
  pattern: '^[A-Za-z ]+$',
  defaultValue: 'Hello',
}

const port = new StringPort(config)
port.setValue('John Doe')
console.log(port.getValue()) // => 'John Doe'

Extends

Implements

Constructors

Constructor

new StringPort(config): StringPort

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:42

Parameters

config

StringPortConfig

Returns

StringPort

Overrides

BasePort.constructor

Properties

config

protected config: StringPortConfig

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

Inherited from

BasePort.config


value?

protected optional value: StringPortValue

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

Inherited from

BasePort.value

Accessors

id

Get Signature

get id(): string

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

The unique identifier of the port.

Returns

string

Implementation of

IPort.id

Inherited from

BasePort.id


key

Get Signature

get key(): string

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

The key of the port.

Returns

string

Implementation of

IPort.key

Inherited from

BasePort.key

Methods

addConnection()

addConnection(nodeId, portId): void

Defined in: packages/chaingraph-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

Implementation of

IPort.addConnection

Inherited from

BasePort.addConnection


clone()

clone(): IPort<StringPortConfig>

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

Clones the port instance.

Returns

IPort<StringPortConfig>

A new port instance with the same configuration and value.

Implementation of

IPort.clone

Inherited from

BasePort.clone


cloneWithNewId()

cloneWithNewId(): IPort<StringPortConfig>

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:108

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

Returns

IPort<StringPortConfig>

Implementation of

IPort.cloneWithNewId

Overrides

BasePort.cloneWithNewId


deserialize()

deserialize(data): IPort<StringPortConfig>

Defined in: packages/chaingraph-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<StringPortConfig>

Implementation of

IPort.deserialize

Inherited from

BasePort.deserialize


deserializeConfig()

deserializeConfig(data): StringPortConfig

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:93

Deserializes the configuration using the StringPortPlugin.deserializeConfig.

Parameters

data

unknown

Returns

StringPortConfig

Implementation of

IPort.deserializeConfig

Overrides

BasePort.deserializeConfig


deserializeValue()

deserializeValue(data): StringPortValue

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:100

Deserializes the string port value using the StringPortPlugin.deserializeValue.

Parameters

data

unknown

Returns

StringPortValue

Implementation of

IPort.deserializeValue

Overrides

BasePort.deserializeValue


getConfig()

getConfig(): StringPortConfig

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

Retrieves the current port configuration.

Returns

StringPortConfig

The port configuration of type C.

Implementation of

IPort.getConfig

Inherited from

BasePort.getConfig


getDefaultValue()

getDefaultValue(): StringPortValue

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:55

Returns the default value using the plugin's helper.

Returns

StringPortValue

Implementation of

IPort.getDefaultValue

Overrides

BasePort.getDefaultValue


getValue()

getValue(): StringPortValue

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

Gets the current port value.

Returns

StringPortValue

The port value, or undefined if none is set.

Implementation of

IPort.getValue

Inherited from

BasePort.getValue


isSystem()

isSystem(): boolean

Defined in: packages/chaingraph-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.

Implementation of

IPort.isSystem

Inherited from

BasePort.isSystem


isSystemError()

isSystemError(): boolean

Defined in: packages/chaingraph-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.

Implementation of

IPort.isSystemError

Inherited from

BasePort.isSystemError


removeConnection()

removeConnection(nodeId, portId): void

Defined in: packages/chaingraph-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

Implementation of

IPort.removeConnection

Inherited from

BasePort.removeConnection


reset()

reset(): void

Defined in: packages/chaingraph-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

Implementation of

IPort.reset

Inherited from

BasePort.reset


serialize()

serialize(): unknown

Defined in: packages/chaingraph-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

Implementation of

IPort.serialize

Inherited from

BasePort.serialize


serializeConfig()

serializeConfig(config): unknown

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:79

Serializes the configuration by delegating to the StringPortPlugin's serializeConfig.

Parameters

config

StringPortConfig

Returns

unknown

Implementation of

IPort.serializeConfig

Overrides

BasePort.serializeConfig


serializeValue()

serializeValue(value): unknown

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:86

Serializes the string port value by delegating to the StringPortPlugin.serializeValue.

Parameters

value

StringPortValue

Returns

unknown

Implementation of

IPort.serializeValue

Overrides

BasePort.serializeValue


setConfig()

setConfig(newConfig): void

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

Updates the port configuration with a new configuration object.

Parameters

newConfig

StringPortConfig

New configuration of type C.

Returns

void

Implementation of

IPort.setConfig

Inherited from

BasePort.setConfig


setValue()

setValue(newValue): void

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

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

Parameters

newValue

StringPortValue

The new value to set for the port.

Returns

void

Implementation of

IPort.setValue

Inherited from

BasePort.setValue


unwrap()

unwrap(): IPort<StringPortConfig>

Defined in: packages/chaingraph-types/src/port/base/BasePort.ts:237

Unwrap to get underlying port instance For regular ports, returns this (already unwrapped)

Returns

IPort<StringPortConfig>

Implementation of

IPort.unwrap

Inherited from

BasePort.unwrap


validate()

validate(): boolean

Defined in: packages/chaingraph-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

Implementation of

IPort.validate

Inherited from

BasePort.validate


validateConfig()

validateConfig(config): boolean

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:71

Validates the string port configuration.

Parameters

config

StringPortConfig

Returns

boolean

Implementation of

IPort.validateConfig

Overrides

BasePort.validateConfig


validateValue()

validateValue(value): boolean

Defined in: packages/chaingraph-types/src/port/instances/StringPort.ts:63

Validates the string port value. Delegates to the StringPortPlugin.validateValue method

Parameters

value

StringPortValue

Returns

boolean

Implementation of

IPort.validateValue

Overrides

BasePort.validateValue

Licensed under BUSL-1.1