Skip to content

Variable: Value

@kortexya/reasoninglayer


@kortexya/reasoninglayer / Value

Variable: Value

const Value: object

Defined in: src/builders/value.ts:55

Builder namespace for complex tagged ValueDto values that have no plain JS equivalent.

For simple types, pass plain JS values directly — the SDK auto-converts them:

  • "hello"{ type: "String", value: "hello" }
  • 42{ type: "Integer", value: 42 }
  • 3.14{ type: "Real", value: 3.14 }
  • true{ type: "Boolean", value: true }
  • null{ type: "Uninstantiated" }
  • [...]{ type: "List", value: [...] }

Use Value.* only for types that cannot be expressed as plain JS:

Type Declaration

fuzzyNumber()

readonly fuzzyNumber(shape): FuzzyNumberValue

Create a fuzzy number defined by a membership function shape.

Parameters

shape

FuzzyShapeDto

The fuzzy membership function shape (use FuzzyShape builders).

Returns

FuzzyNumberValue

A tagged FuzzyNumberValue.

Remarks

Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.

Note: The FuzzyShapeDto uses "kind" as its discriminator, NOT "type".

Example

Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24))
// {"type": "FuzzyNumber", "value": {"shape": {"kind": "Triangular", "a": 20, "b": 22, "c": 24}}}

fuzzyScalar()

readonly fuzzyScalar(value, membership): FuzzyScalarValue

Create a fuzzy scalar with a value and membership degree.

Parameters

value

number

The scalar value.

membership

number

The membership degree (0.0 to 1.0).

Returns

FuzzyScalarValue

A tagged FuzzyScalarValue.

Remarks

Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.

Example

Value.fuzzyScalar(0.5, 0.8) // {"type": "FuzzyScalar", "value": {"value": 0.5, "membership": 0.8}}

reference()

readonly reference(id): ReferenceValue

Create a reference to another term by UUID.

Parameters

id

string

The UUID of the referenced term.

Returns

ReferenceValue

A tagged ReferenceValue: {"type": "Reference", "value": "uuid"}.

Remarks

Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.

Example

Value.reference("550e8400-e29b-41d4-a716-446655440000")

set()

readonly set(lower, upper, sortConstraint?): SetValue

Create a set value with lower and upper bounds and an optional sort constraint.

Parameters

lower

string[]

Lower bound — definite members (term UUIDs).

upper

string[]

Upper bound — possible members (term UUIDs).

sortConstraint?

string

Optional sort constraint for set members.

Returns

SetValue

A tagged SetValue.

Remarks

Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.

Represents partial information about set membership using Smyth powerdomain semantics.

Example

Value.set(["uuid1"], ["uuid1", "uuid2", "uuid3"], "person_sort_id")

Remarks

Serialization format: Tagged (ValueDto).

Example

import { Value, FuzzyShape } from '@kortexya/reasoninglayer';
// Plain values (no builder needed):
const features = { name: "Alice", age: 30, active: true };
// Complex types (require Value.*):
const ref = Value.reference("term-uuid");
const fuzzy = Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24));
const membership = Value.fuzzyScalar(0.5, 0.8);
const group = Value.set(["uuid1"], ["uuid1", "uuid2"]);