Skip to content

Class: SortBuilder

@kortexya/reasoninglayer


@kortexya/reasoninglayer / SortBuilder

Defined in: src/builders/sort.ts:36

Fluent builder for constructing CreateSortRequest objects.

The builder accumulates sort properties through a fluent chain and produces a CreateSortRequest when .build() is called.

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();

boundConstraint(constraint): this

Defined in: src/builders/sort.ts:154

Add an inter-feature bound constraint.

BoundConstraintDto

The bound constraint definition.

this

This builder instance for chaining.

builder.boundConstraint({
constraintType: "upper",
target: "end_date",
sourcePath: "company.dissolutionDate",
})

build(): CreateSortRequest

Defined in: src/builders/sort.ts:190

Build the final CreateSortRequest.

CreateSortRequest

The constructed CreateSortRequest ready to send to the API.

const request = SortBuilder.create("employee")
.parent(personSortId)
.feature({ name: "salary", required: true })
.build();
await client.sorts.createSort(request);

description(desc): this

Defined in: src/builders/sort.ts:170

Set a human-readable description for the sort.

string

The description text.

this

This builder instance for chaining.

builder.description("An employee at a company")

feature(descriptor): this

Defined in: src/builders/sort.ts:134

Add a feature descriptor to the sort.

FeatureDescriptorDto

The feature descriptor defining name, type, constraints, etc.

this

This builder instance for chaining.

builder.feature({
name: "salary",
required: true,
constraint: { type: "IntegerRange", value: { min: 0, max: 10000000 } },
})

parent(parentId): this

Defined in: src/builders/sort.ts:98

Add a parent sort by UUID.

string

The UUID of the parent sort.

this

This builder instance for chaining.

Can be called multiple times to add multiple parents (multiple inheritance). Uses sort UUIDs. For name-based parents, use BulkSortDefinition via bulk creation.

builder.parent(personSortId).parent(organizationMemberSortId)

parents(parentIds): this

Defined in: src/builders/sort.ts:114

Add multiple parent sorts by UUID.

string[]

The UUIDs of the parent sorts.

this

This builder instance for chaining.

builder.parents([personSortId, organizationMemberSortId])

withId(id): this

Defined in: src/builders/sort.ts:78

Set a deterministic UUID for the sort.

string

The UUID to use.

this

This builder instance for chaining.

If not set, the server generates a UUID automatically. Deterministic UUIDs are useful for homoiconic cross-references between sorts, rules, and facts.

builder.withId("550e8400-e29b-41d4-a716-446655440000")

static create(name): SortBuilder

Defined in: src/builders/sort.ts:59

Start building a new sort with the given name.

string

The sort name.

SortBuilder

A new SortBuilder instance.

const builder = SortBuilder.create("employee");