Variable: Value
@kortexya/reasoninglayer / Value
Variable: Value
Section titled “Variable: Value”
constValue:object
Defined in: src/builders/value.ts:73
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
Section titled “Type Declaration”bigInteger()
Section titled “bigInteger()”
readonlybigInteger(value):BigIntegerValue
Create an arbitrary-precision integer.
Parameters
Section titled “Parameters”string | bigint
The integer, as a bigint or its decimal string.
Returns
Section titled “Returns”A tagged BigIntegerValue: {"type": "BigInteger", "value": "170141183460469231731687303715884105727"}.
Throws
Section titled “Throws”If a string is given that is not a decimal integer.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
The wire form is a string because JSON numbers are IEEE-754 doubles and
lose precision above 2^53. Passing such a number as a plain JS number
silently rounds it before the SDK ever sees it.
Example
Section titled “Example”Value.bigInteger(2n ** 127n - 1n)Value.bigInteger("170141183460469231731687303715884105727")choice()
Section titled “choice()”
readonlychoice(values):ChoiceValue
Create a disjunction of alternatives — {v1; v2; …}.
Parameters
Section titled “Parameters”values
Section titled “values”ValueDto[]
The alternatives.
Returns
Section titled “Returns”A tagged ChoiceValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
Unifies alternative-wise, so a choice narrows as information arrives rather than failing. Contrast Value.domain, which enumerates a finite domain for a solver to label.
Example
Section titled “Example”Value.choice([{ type: "String", value: "draft" }, { type: "String", value: "sent" }])dateTime()
Section titled “dateTime()”
readonlydateTime(value):DateTimeValue
Create an instant in time.
Parameters
Section titled “Parameters”string | Date
An RFC 3339 / ISO 8601 timestamp, or a Date.
Returns
Section titled “Returns”A tagged DateTimeValue: {"type": "DateTime", "value": "2026-01-15T10:30:00.000Z"}.
Throws
Section titled “Throws”If a string is given that is not a parsable timestamp.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
A feature declared DateTime refuses a String, so this is not
interchangeable with passing the timestamp as a plain string — a plain
string becomes {"type":"String"} and the write is refused.
A Date is emitted in UTC with millisecond precision. A string is passed
through as written, so an offset such as +01:00 is preserved; the engine
compares instants, so it means the same moment either way.
Example
Section titled “Example”Value.dateTime("2026-01-15T10:30:00Z")Value.dateTime(new Date())domain()
Section titled “domain()”
readonlydomain(values):DomainValue
Create a finite domain of candidate values.
Parameters
Section titled “Parameters”values
Section titled “values”ValueDto[]
The candidates. The value is one of them.
Returns
Section titled “Returns”A tagged DomainValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
Unifies by intersection — meeting two domains keeps the values in both, and an empty intersection is ⊥. This is what a solver labels over; a Value.choice is a disjunction that narrows, and a plain array is one value that happens to be a list.
Example
Section titled “Example”Value.domain([1, 2, 3].map((n) => ({ type: "Integer", value: n }) as const))externalRef()
Section titled “externalRef()”
readonlyexternalRef(sourceId,externalId,options?):ExternalRefValue
Create a reference to an entity in another system.
Parameters
Section titled “Parameters”sourceId
Section titled “sourceId”string
External source identifier.
externalId
Section titled “externalId”string
Entity id within that source.
options?
Section titled “options?”Optional scalar path within the entity, and the sort expected after resolution.
expectedSort?
Section titled “expectedSort?”string
fieldPath?
Section titled “fieldPath?”string
Returns
Section titled “Returns”A tagged ExternalRefValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
Unresolved by design: the engine holds the coordinates and resolves them through the source’s connector when a query needs the value.
Example
Section titled “Example”Value.externalRef("crm", "acct-4711", { fieldPath: "billing.country" })fuzzyNumber()
Section titled “fuzzyNumber()”
readonlyfuzzyNumber(shape):FuzzyNumberValue
Create a fuzzy number defined by a membership function shape.
Parameters
Section titled “Parameters”The fuzzy membership function shape (use FuzzyShape builders).
Returns
Section titled “Returns”A tagged FuzzyNumberValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
Note: The FuzzyShapeDto uses "kind" as its discriminator, NOT "type".
Example
Section titled “Example”Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24))// {"type": "FuzzyNumber", "value": {"shape": {"kind": "Triangular", "a": 20, "b": 22, "c": 24}}}fuzzyScalar()
Section titled “fuzzyScalar()”
readonlyfuzzyScalar(value,membership):FuzzyScalarValue
Create a fuzzy scalar with a value and membership degree.
Parameters
Section titled “Parameters”number
The scalar value.
membership
Section titled “membership”number
The membership degree (0.0 to 1.0).
Returns
Section titled “Returns”A tagged FuzzyScalarValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
Example
Section titled “Example”Value.fuzzyScalar(0.5, 0.8) // {"type": "FuzzyScalar", "value": {"value": 0.5, "membership": 0.8}}geometry()
Section titled “geometry()”
readonlygeometry(shape):GeometryValue
Create a geometric value.
Parameters
Section titled “Parameters”The shape, from the Geometry builder namespace.
Returns
Section titled “Returns”A tagged GeometryValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto), whose inner shape is tagged by
"kind" rather than "type".
Example
Section titled “Example”Value.geometry(Geometry.boundingBox(10, 20, 100, 50))measurement()
Section titled “measurement()”
readonlymeasurement(value,unit):MeasurementValue
Create a dimensioned quantity.
Parameters
Section titled “Parameters”number
The magnitude.
The unit it is measured in.
Returns
Section titled “Returns”A tagged MeasurementValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
The engine converts between units of the same dimension before comparing,
so 100 Centimeters equals 1 Meters. A bare Real carries no unit and
is not comparable to a measurement at all.
Example
Section titled “Example”Value.measurement(1.8, "Meters")psiTerm()
Section titled “psiTerm()”
readonlypsiTerm(sortId,features?):PsiTermValue
Create a nested Psi-term carried as a feature value.
Parameters
Section titled “Parameters”sortId
Section titled “sortId”string
Sort of the nested term (UUID).
features?
Section titled “features?”Record<string, ValueDto>
Named features of the nested term, already tagged.
Returns
Section titled “Returns”A tagged PsiTermValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
The nested term is structural — it is not stored separately and has no id of its own, so nothing can reference it later. Use Value.reference to point at a term that IS stored.
features is already in tagged form. To build it from plain JS values,
pass them through toTaggedFeatures.
Example
Section titled “Example”Value.psiTerm(addressSortId, toTaggedFeatures({ city: "Cairo", postcode: 11511 }))reference()
Section titled “reference()”
readonlyreference(target):ReferenceValue
Create a reference to another stored term — by its UUID, or by the @key
values that name it.
Parameters
Section titled “Parameters”target
Section titled “target”string | ReferenceDesignator
The referenced term’s UUID, or a ReferenceDesignator
naming it through the @key features of its sort.
Returns
Section titled “Returns”A tagged ReferenceValue: {"type": "Reference", "value": "uuid"}
for the id form, {"type":"Reference","value":{"sort_name":…,"features":…}}
for the designator form.
Throws
Section titled “Throws”ValidationError when the designator carries an empty
sortName, or names no feature — the engine refuses both, so the builder
refuses them before the round trip.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries
and fuzzy operations. The homoiconic inference endpoints take the untagged
format and have no designator form.
The two forms differ in what they can be used for:
- The UUID form is what a read answers, and the only form that can
point at a term whose sort declares no
@key. - The designator form is WRITE-side only. It RESOLVES to a term that
already exists and never mints one: measured on 2026-09-18, writing
a
paymentwhoseinvoicefeature wasValue.reference({ sortName: 'invoice', features: { number: { type: 'String', value: 'INV-1' } } })stored{"type":"Reference","value":"4641cbcb-…"}— the id of the single existing invoice — and the invoice extent still held exactly one term. A designator matching nothing is refused422 no term of sort 'invoice' carries @key 'number' = "INV-NOPE"; a reference designator names an existing term, it never creates one. The same refusal arrives fromPOST /api/v1/terms/bulkas aBulkRefusedErrornaming the entry index.
The designator’s features keys are OSF feature names — user data, not
schema — and survive the request bridge verbatim, so a feature declared
invoiceNumber must be spelled invoiceNumber here. Sending the
snake_cased spelling is refused: 422 feature 'invoice_number' of sort 'invoice' is not a @key feature; a designator addresses a term only through its @key.
Example
Section titled “Example”// By id:Value.reference("550e8400-e29b-41d4-a716-446655440000")
// By @key, when the caller has the business key and not the UUID:Value.reference({ sortName: 'invoice', features: { number: { type: 'String', value: 'INV-1' } },})
readonlyset(lower,upper,sortConstraint?):SetValue
Create a set value with lower and upper bounds and an optional sort constraint.
Parameters
Section titled “Parameters”string[]
Lower bound — definite members (term UUIDs).
string[]
Upper bound — possible members (term UUIDs).
sortConstraint?
Section titled “sortConstraint?”string
Optional sort constraint for set members.
Returns
Section titled “Returns”A tagged SetValue.
Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto). Use with term CRUD, queries, fuzzy operations.
Represents partial information about set membership using Smyth powerdomain semantics.
Example
Section titled “Example”Value.set(["uuid1"], ["uuid1", "uuid2", "uuid3"], "person_sort_id")sortId()
Section titled “sortId()”
readonlysortId(id):SortIdValue
Create a reference to a sort by UUID.
Parameters
Section titled “Parameters”string
The UUID of the sort.
Returns
Section titled “Returns”A tagged SortIdValue: {"type": "SortId", "value": "uuid"}.
Remarks
Section titled “Remarks”Used by homoiconic meta-constraints — primarily Constraint.typeOf(...)
— whose feature targets a sort as a first-class value. The chainer
dispatches this directly via Value::SortId.
Example
Section titled “Example”Value.sortId("550e8400-e29b-41d4-a716-446655440000")// { type: 'SortId', value: '550e8400-e29b-41d4-a716-446655440000' }Remarks
Section titled “Remarks”Serialization format: Tagged (ValueDto).
Example
Section titled “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"]);