Skip to content

Class: VocabularyApplicationService ​

Defined in: application/services/core/VocabularyService.ts:286

In-memory VocabularyService backed by a MaterializedVocabularyIndex. Schemes in the index that carry a url are lazy: their concepts are fetched on first use by VocabularyApplicationService.listConcepts, VocabularyApplicationService.searchConcepts (when the scheme is in schemeUris) or VocabularyApplicationService.resolveTerm. Scheme URIs are matched with and without a trailing slash and across the https://sidedoc.app/vocabs/ and https://vocab.sidedoc.app/schemes/ aliases.

Implements ​

Constructors ​

Constructor ​

ts
new VocabularyApplicationService(index?): VocabularyApplicationService;

Defined in: application/services/core/VocabularyService.ts:298

Parameters ​

ParameterTypeDescription
index?MaterializedVocabularyIndexIndex to serve; defaults to the index bundled with the package.

Returns ​

VocabularyApplicationService

Methods ​

getMaterializedIndex() ​

ts
getMaterializedIndex(): Promise<MaterializedVocabularyIndex>;

Defined in: application/services/core/VocabularyService.ts:320

Return the index the service was created with. Concepts loaded lazily are not added to it.

Returns ​

Promise<MaterializedVocabularyIndex>

Implementation of ​

VocabularyService.getMaterializedIndex


listConcepts() ​

ts
listConcepts(input): Promise<VocabularyListResult<VocabularyConceptSummary>>;

Defined in: application/services/core/VocabularyService.ts:357

List the concepts of one scheme sorted by label, loading a lazy scheme first. Defaults to locale en, page 1 and 50 items. parentUri and includeDescendants are currently ignored.

Parameters ​

ParameterType
input{ includeDescendants?: boolean; locale?: string; page?: number; pageSize?: number; parentUri?: string; schemeUri: string; }
input.includeDescendants?boolean
input.locale?string
input.page?number
input.pageSize?number
input.parentUri?string
input.schemeUristring

Returns ​

Promise<VocabularyListResult<VocabularyConceptSummary>>

Implementation of ​

VocabularyService.listConcepts


listSchemes() ​

ts
listSchemes(input?): Promise<VocabularyListResult<VocabularySchemeSummary>>;

Defined in: application/services/core/VocabularyService.ts:328

List schemes, optionally filtered by a case-insensitive substring of URI or English label, sorted by label. Defaults to page 1 with 25 items. conceptCount excludes lazy concepts not yet loaded.

Parameters ​

ParameterType
input?{ page?: number; pageSize?: number; query?: string; }
input.page?number
input.pageSize?number
input.query?string

Returns ​

Promise<VocabularyListResult<VocabularySchemeSummary>>

Implementation of ​

VocabularyService.listSchemes


resolveFieldVocabulary() ​

ts
resolveFieldVocabulary(input): Promise<
  | FieldVocabularyBinding
| null>;

Defined in: application/services/core/VocabularyService.ts:511

Return the vocabulary binding of a profile field with its scheme URIs normalized to the canonical URIs known to this service, or null when the field has no binding.

Parameters ​

ParameterType
input{ fieldPath: string; profile: DocumentProfile; }
input.fieldPathstring
input.profileDocumentProfile

Returns ​

Promise< | FieldVocabularyBinding | null>

Implementation of ​

VocabularyService.resolveFieldVocabulary


resolveTerm() ​

ts
resolveTerm(input): Promise<
  | VocabularyConceptSummary
| null>;

Defined in: application/services/core/VocabularyService.ts:482

Look up a concept by full or compact URI, loading the matching lazy scheme if needed. Returns null when the term is unknown.

Parameters ​

ParameterType
input{ locale?: string; term: string; }
input.locale?string
input.termstring

Returns ​

Promise< | VocabularyConceptSummary | null>

Implementation of ​

VocabularyService.resolveTerm


searchConcepts() ​

ts
searchConcepts(input): Promise<VocabularyListResult<VocabularyConceptSummary>>;

Defined in: application/services/core/VocabularyService.ts:386

Search concepts by label in the requested locale (English when no concept has a label in that locale), then by URI for concepts not matched by label. Results are ranked by match quality (exact URI, exact label, prefix, substring). An empty query returns no items. parentUri and includeDescendants are currently ignored.

Parameters ​

ParameterType
input{ includeDescendants?: boolean; locale?: string; page?: number; pageSize?: number; parentUri?: string; query: string; schemeUris?: string[]; }
input.includeDescendants?boolean
input.locale?string
input.page?number
input.pageSize?number
input.parentUri?string
input.querystring
input.schemeUris?string[]

Returns ​

Promise<VocabularyListResult<VocabularyConceptSummary>>

Implementation of ​

VocabularyService.searchConcepts


suggestConcepts() ​

ts
suggestConcepts(input): Promise<VocabularyConceptSummary[]>;

Defined in: application/services/core/VocabularyService.ts:457

Return the first limit (default 10) results of VocabularyApplicationService.searchConcepts.

Parameters ​

ParameterType
input{ includeDescendants?: boolean; limit?: number; locale?: string; parentUri?: string; query: string; schemeUris?: string[]; }
input.includeDescendants?boolean
input.limit?number
input.locale?string
input.parentUri?string
input.querystring
input.schemeUris?string[]

Returns ​

Promise<VocabularyConceptSummary[]>

Implementation of ​

VocabularyService.suggestConcepts


fromMaterializedIndex() ​

ts
static fromMaterializedIndex(index): VocabularyApplicationService;

Defined in: application/services/core/VocabularyService.ts:313

Create a service from an existing materialized index.

Parameters ​

ParameterType
indexMaterializedVocabularyIndex

Returns ​

VocabularyApplicationService


fromSkosDocuments() ​

ts
static fromSkosDocuments(documents): VocabularyApplicationService;

Defined in: application/services/core/VocabularyService.ts:306

Create a service from SKOS documents via materializeVocabularyIndexFromSkosDocuments.

Parameters ​

ParameterType
documentsobject[]

Returns ​

VocabularyApplicationService