Class: SortBuilder
@kortexya/reasoninglayer / SortBuilder
Class: SortBuilder
Defined in: src/builders/sort.ts:36
Fluent builder for constructing CreateSortRequest objects.
Remarks
The builder accumulates sort properties through a fluent chain and produces
a CreateSortRequest when .build() is called.
Example
import { SortBuilder } from '@kortexya/reasoninglayer';
const request = SortBuilder.create("employee") .withId("550e8400-e29b-41d4-a716-446655440000") .parent(personSortId) .feature({ name: "salary", required: true, constraint: { type: "IntegerRange", value: { min: 0, max: 10000000 } }, }) .feature({ name: "department", required: true }) .boundConstraint({ constraintType: "upper", target: "end_date", sourcePath: "company.dissolutionDate", }) .description("An employee at a company") .build();Methods
boundConstraint()
boundConstraint(
constraint):this
Defined in: src/builders/sort.ts:154
Add an inter-feature bound constraint.
Parameters
constraint
The bound constraint definition.
Returns
this
This builder instance for chaining.
Example
builder.boundConstraint({ constraintType: "upper", target: "end_date", sourcePath: "company.dissolutionDate",})build()
build():
CreateSortRequest
Defined in: src/builders/sort.ts:190
Build the final CreateSortRequest.
Returns
The constructed CreateSortRequest ready to send to the API.
Example
const request = SortBuilder.create("employee") .parent(personSortId) .feature({ name: "salary", required: true }) .build();
await client.sorts.createSort(request);description()
description(
desc):this
Defined in: src/builders/sort.ts:170
Set a human-readable description for the sort.
Parameters
desc
string
The description text.
Returns
this
This builder instance for chaining.
Example
builder.description("An employee at a company")feature()
feature(
descriptor):this
Defined in: src/builders/sort.ts:134
Add a feature descriptor to the sort.
Parameters
descriptor
The feature descriptor defining name, type, constraints, etc.
Returns
this
This builder instance for chaining.
Example
builder.feature({ name: "salary", required: true, constraint: { type: "IntegerRange", value: { min: 0, max: 10000000 } },})parent()
parent(
parentId):this
Defined in: src/builders/sort.ts:98
Add a parent sort by UUID.
Parameters
parentId
string
The UUID of the parent sort.
Returns
this
This builder instance for chaining.
Remarks
Can be called multiple times to add multiple parents (multiple inheritance). Uses sort UUIDs. For name-based parents, use BulkSortDefinition via bulk creation.
Example
builder.parent(personSortId).parent(organizationMemberSortId)parents()
parents(
parentIds):this
Defined in: src/builders/sort.ts:114
Add multiple parent sorts by UUID.
Parameters
parentIds
string[]
The UUIDs of the parent sorts.
Returns
this
This builder instance for chaining.
Example
builder.parents([personSortId, organizationMemberSortId])withId()
withId(
id):this
Defined in: src/builders/sort.ts:78
Set a deterministic UUID for the sort.
Parameters
id
string
The UUID to use.
Returns
this
This builder instance for chaining.
Remarks
If not set, the server generates a UUID automatically. Deterministic UUIDs are useful for homoiconic cross-references between sorts, rules, and facts.
Example
builder.withId("550e8400-e29b-41d4-a716-446655440000")create()
staticcreate(name):SortBuilder
Defined in: src/builders/sort.ts:59
Start building a new sort with the given name.
Parameters
name
string
The sort name.
Returns
SortBuilder
A new SortBuilder instance.
Example
const builder = SortBuilder.create("employee");