Skip to content

Type Alias: TermSetSelector

@kortexya/reasoninglayer


@kortexya/reasoninglayer / OsfDiff / TermSetSelector

Type Alias: TermSetSelector

TermSetSelector = { documentId: string; type: "document"; } | { documentId: string; type: "document_version"; } | { path: string; type: "collection"; } | { ids: string[]; type: "term_ids"; } | { includeDescendants?: boolean; sortName: string; type: "sort"; } | { osfql: string; type: "query"; } | { filter?: TermSetSelector; snapshotId: string; type: "snapshot"; } | { at: string; filter?: TermSetSelector; type: "as_of"; }

Defined in: src/types/osf-diff.ts:35

Selects a set of Psi-terms to diff.

Type Declaration

{ documentId: string; type: "document"; }

documentId

documentId: string

type

type: "document"

All terms extracted from one document.

{ documentId: string; type: "document_version"; }

documentId

documentId: string

type

type: "document_version"

Alias of document used by the version-chain endpoints.

{ path: string; type: "collection"; }

path

path: string

type

type: "collection"

Union of all documents in a collection path.

{ ids: string[]; type: "term_ids"; }

ids

ids: string[]

type

type: "term_ids"

An explicit list of term IDs.

{ includeDescendants?: boolean; sortName: string; type: "sort"; }

includeDescendants?

optional includeDescendants: boolean

sortName

sortName: string

type

type: "sort"

All terms of a sort (optionally including descendant sorts).

{ osfql: string; type: "query"; }

osfql

osfql: string

type

type: "query"

The result set of an OSFQL FINDALL/MATCH query.

{ filter?: TermSetSelector; snapshotId: string; type: "snapshot"; }

filter?

optional filter: TermSetSelector

snapshotId

snapshotId: string

type

type: "snapshot"

The set as captured in a tenant snapshot (optionally filtered).

{ at: string; filter?: TermSetSelector; type: "as_of"; }

at

at: string

filter?

optional filter: TermSetSelector

type

type: "as_of"

The set as of a timestamp (RFC 3339), optionally filtered.

Remarks

A union discriminated by type. The OSF diff engine compares any two sets of OSF terms — a document is just one way to select a set; others are collections, sorts, OSFQL query results, snapshots, or points in time. snapshot and as_of accept an optional nested filter, so selections compose recursively (e.g. “the terms of sort clause as of 2026-01-01”).

This is the canonical definition, mirroring the backend, where the enum lives in the OSF diff module (osfkb_domain::extraction::osf_diff::TermSetSelector) and is imported by the temporal-series and coherence endpoints. The temporal surface re-exports it — there is exactly one definition.

Serialized to the wire as a tagged snake_case object — for example {"type":"sort","sort_name":"clause","include_descendants":true}. This is a plain JSON tagged union, not the tagged ValueDto value format. The SDK surface is camelCase (sortName); the normalizer converts it at the boundary.

The backend publishes the selector as a free-form JSON object (#[schema(value_type = Object)]), which erases the union in the OpenAPI spec; the SDK hand-writes it against the Rust source, whose own doc comment states “the variants double as the wire format”.

Example

const byDocument: TermSetSelector = { type: 'document', documentId: '3f0c...' };
const bySort: TermSetSelector = { type: 'sort', sortName: 'clause', includeDescendants: true };
const historic: TermSetSelector = { type: 'as_of', at: '2026-01-01T00:00:00Z', filter: bySort };