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