Skip to content

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

Variable: Predicates ​

const Predicates: object

Defined in: packages/chaingraph-types/src/port/transfer-rules/predicates.ts:18

Library of reusable predicates for port matching

Type Declaration ​

always() ​

always: () => boolean

Always true predicate

Returns ​

boolean

and() ​

and: (...predicates) => PortPredicate

Combine predicates with AND logic

Parameters ​

predicates ​

...PortPredicate[]

Returns ​

PortPredicate

canReceiveSchema() ​

canReceiveSchema: (targetPort) => PortPredicate

Check if object port can receive schema updates This combines mutable check with schema compatibility

Parameters ​

targetPort ​

IPortConfig

Returns ​

PortPredicate

hasAnyItemType() ​

hasAnyItemType: (port) => boolean

Check if array has any item type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasAnyStreamItemType() ​

hasAnyStreamItemType: (port) => boolean

Check if stream has any item type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasCompatibleArrayItems() ​

hasCompatibleArrayItems: (source, target) => boolean

Check if two arrays have compatible item types Uses recursive schema checking for complex item types

Parameters ​

source ​

IPortConfig

target ​

IPortConfig

Returns ​

boolean

hasCompatibleSchemas() ​

hasCompatibleSchemas: (sourceConfig, targetConfig) => boolean

Check if source and target have compatible schemas This is for use in TransferContext where we have both configs

Parameters ​

sourceConfig ​

IPortConfig

targetConfig ​

IPortConfig

Returns ​

boolean

hasCompatibleSecretTypes() ​

hasCompatibleSecretTypes: (source, target) => boolean

Check if two secret ports have compatible secret types

Parameters ​

source ​

IPortConfig

target ​

IPortConfig

Returns ​

boolean

hasCompatibleStreamItems() ​

hasCompatibleStreamItems: (source, target) => boolean

Check if two streams have compatible item types Uses recursive schema checking for complex item types

Parameters ​

source ​

IPortConfig

target ​

IPortConfig

Returns ​

boolean

hasEmptySchema() ​

hasEmptySchema: (port) => boolean

Check if object port has empty schema

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasItemType() ​

hasItemType: (type) => PortPredicate

Check if array has specific item type

Parameters ​

type ​

"string" | "number" | "boolean" | "object" | "array" | "stream" | "enum" | "secret" | "any"

Returns ​

PortPredicate

hasNoItemConfig() ​

hasNoItemConfig: (port) => boolean

Check if array has no item config

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasNoStreamItemConfig() ​

hasNoStreamItemConfig: (port) => boolean

Check if stream has no item config

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasNoUnderlyingType() ​

hasNoUnderlyingType: (port) => boolean

Check if any port has no underlying type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasProperty() ​

hasProperty: (propertyName) => PortPredicate

Check if object has specific property

Parameters ​

propertyName ​

string

Returns ​

PortPredicate

hasSecretType() ​

hasSecretType: (secretType) => PortPredicate

Check if secret has specific secret type

Parameters ​

secretType ​

string

Returns ​

PortPredicate

hasStreamItemType() ​

hasStreamItemType: (type) => PortPredicate

Check if stream has specific item type

Parameters ​

type ​

"string" | "number" | "boolean" | "object" | "array" | "stream" | "enum" | "secret" | "any"

Returns ​

PortPredicate

hasUnderlyingArray() ​

hasUnderlyingArray: (port) => boolean

Check if any port has underlying array type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasUnderlyingEnum() ​

hasUnderlyingEnum: (port) => boolean

Check if any port has underlying enum type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasUnderlyingObject() ​

hasUnderlyingObject: (port) => boolean

Check if any port has underlying object type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasUnderlyingSecret() ​

hasUnderlyingSecret: (port) => boolean

Check if any port has underlying secret type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasUnderlyingStream() ​

hasUnderlyingStream: (port) => boolean

Check if any port has underlying stream type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasUnderlyingType() ​

hasUnderlyingType: (port) => boolean

Check if any port has underlying type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

hasUnderlyingType_() ​

hasUnderlyingType_: (type) => PortPredicate

Check if any port has specific underlying type

Parameters ​

type ​

"string" | "number" | "boolean" | "object" | "array" | "stream" | "enum" | "secret" | "any"

Returns ​

PortPredicate

isAny() ​

isAny: (port) => boolean

Check if port is any type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isArray() ​

isArray: (port) => boolean

Check if port is array type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isBoolean() ​

isBoolean: (port) => boolean

Check if port is boolean type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isEmptyOrCompatibleSchema() ​

isEmptyOrCompatibleSchema: (targetPort) => PortPredicate

Check if target has empty schema or source is compatible with target Useful for mutable objects that can receive any schema when empty

Parameters ​

targetPort ​

IPortConfig

Returns ​

PortPredicate

isEnum() ​

isEnum: (port) => boolean

Check if port is enum type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isImmutableObject() ​

isImmutableObject: (port) => boolean

Check if object port has immutable schema

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isMutableArray() ​

isMutableArray: (port) => boolean

Check if array has mutable item schema

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isMutableObject() ​

isMutableObject: (port) => boolean

Check if object port has mutable schema

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isMutableStream() ​

isMutableStream: (port) => boolean

Check if stream has mutable item schema

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isNumber() ​

isNumber: (port) => boolean

Check if port is number type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isObject() ​

isObject: (port) => boolean

Check if port is object type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isSchemaCompatible() ​

isSchemaCompatible: (targetPort) => PortPredicate

Check if source schema is compatible with target schema using deep recursive checking Compatible means source has all fields that target requires (source can have more) Handles nested objects, arrays, and all complex types This is used as a curried function: isSchemaCompatible(targetPort)(sourcePort)

Parameters ​

targetPort ​

IPortConfig

Returns ​

PortPredicate

isSecret() ​

isSecret: (port) => boolean

Check if port is secret type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isStream() ​

isStream: (port) => boolean

Check if port is stream type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isString() ​

isString: (port) => boolean

Check if port is string type

Parameters ​

port ​

IPortConfig

Returns ​

boolean

isType() ​

isType: (type) => PortPredicate

Check if port is of specific type

Parameters ​

type ​

"string" | "number" | "boolean" | "object" | "array" | "stream" | "enum" | "secret" | "any"

Returns ​

PortPredicate

never() ​

never: () => boolean

Always false predicate

Returns ​

boolean

not() ​

not: (predicate) => PortPredicate

Negate a predicate

Parameters ​

predicate ​

PortPredicate

Returns ​

PortPredicate

or() ​

or: (...predicates) => PortPredicate

Combine predicates with OR logic

Parameters ​

predicates ​

...PortPredicate[]

Returns ​

PortPredicate

Licensed under BUSL-1.1