ChainGraph API Documentation / @badaitech/chaingraph-types / Predicates
Variable: Predicates
constPredicates: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
canReceiveSchema()
canReceiveSchema: (
targetPort) =>PortPredicate
Check if object port can receive schema updates This combines mutable check with schema compatibility
Parameters
targetPort
Returns
hasAnyItemType()
hasAnyItemType: (
port) =>boolean
Check if array has any item type
Parameters
port
Returns
boolean
hasAnyStreamItemType()
hasAnyStreamItemType: (
port) =>boolean
Check if stream has any item type
Parameters
port
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
target
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
targetConfig
Returns
boolean
hasCompatibleSecretTypes()
hasCompatibleSecretTypes: (
source,target) =>boolean
Check if two secret ports have compatible secret types
Parameters
source
target
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
target
Returns
boolean
hasEmptySchema()
hasEmptySchema: (
port) =>boolean
Check if object port has empty schema
Parameters
port
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
hasNoItemConfig()
hasNoItemConfig: (
port) =>boolean
Check if array has no item config
Parameters
port
Returns
boolean
hasNoStreamItemConfig()
hasNoStreamItemConfig: (
port) =>boolean
Check if stream has no item config
Parameters
port
Returns
boolean
hasNoUnderlyingType()
hasNoUnderlyingType: (
port) =>boolean
Check if any port has no underlying type
Parameters
port
Returns
boolean
hasProperty()
hasProperty: (
propertyName) =>PortPredicate
Check if object has specific property
Parameters
propertyName
string
Returns
hasSecretType()
hasSecretType: (
secretType) =>PortPredicate
Check if secret has specific secret type
Parameters
secretType
string
Returns
hasStreamItemType()
hasStreamItemType: (
type) =>PortPredicate
Check if stream has specific item type
Parameters
type
"string" | "number" | "boolean" | "object" | "array" | "stream" | "enum" | "secret" | "any"
Returns
hasUnderlyingArray()
hasUnderlyingArray: (
port) =>boolean
Check if any port has underlying array type
Parameters
port
Returns
boolean
hasUnderlyingEnum()
hasUnderlyingEnum: (
port) =>boolean
Check if any port has underlying enum type
Parameters
port
Returns
boolean
hasUnderlyingObject()
hasUnderlyingObject: (
port) =>boolean
Check if any port has underlying object type
Parameters
port
Returns
boolean
hasUnderlyingSecret()
hasUnderlyingSecret: (
port) =>boolean
Check if any port has underlying secret type
Parameters
port
Returns
boolean
hasUnderlyingStream()
hasUnderlyingStream: (
port) =>boolean
Check if any port has underlying stream type
Parameters
port
Returns
boolean
hasUnderlyingType()
hasUnderlyingType: (
port) =>boolean
Check if any port has underlying type
Parameters
port
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
isAny()
isAny: (
port) =>boolean
Check if port is any type
Parameters
port
Returns
boolean
isArray()
isArray: (
port) =>boolean
Check if port is array type
Parameters
port
Returns
boolean
isBoolean()
isBoolean: (
port) =>boolean
Check if port is boolean type
Parameters
port
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
Returns
isEnum()
isEnum: (
port) =>boolean
Check if port is enum type
Parameters
port
Returns
boolean
isImmutableObject()
isImmutableObject: (
port) =>boolean
Check if object port has immutable schema
Parameters
port
Returns
boolean
isMutableArray()
isMutableArray: (
port) =>boolean
Check if array has mutable item schema
Parameters
port
Returns
boolean
isMutableObject()
isMutableObject: (
port) =>boolean
Check if object port has mutable schema
Parameters
port
Returns
boolean
isMutableStream()
isMutableStream: (
port) =>boolean
Check if stream has mutable item schema
Parameters
port
Returns
boolean
isNumber()
isNumber: (
port) =>boolean
Check if port is number type
Parameters
port
Returns
boolean
isObject()
isObject: (
port) =>boolean
Check if port is object type
Parameters
port
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
Returns
isSecret()
isSecret: (
port) =>boolean
Check if port is secret type
Parameters
port
Returns
boolean
isStream()
isStream: (
port) =>boolean
Check if port is stream type
Parameters
port
Returns
boolean
isString()
isString: (
port) =>boolean
Check if port is string type
Parameters
port
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
never()
never: () =>
boolean
Always false predicate
Returns
boolean
not()
not: (
predicate) =>PortPredicate
Negate a predicate
Parameters
predicate
Returns
or()
or: (...
predicates) =>PortPredicate
Combine predicates with OR logic
Parameters
predicates
...PortPredicate[]