Skip to main content
Version: 1.x

Interface: VocabularyService

Defined in: src/vocabulary/types.ts:166

The public interface of the vocabulary service.

Remarks

Use createVocabularyService to obtain an instance. The service is lazy: domains are loaded on demand via VocabularyService.loadDomain.

Example

const svc = createVocabularyService();
await svc.loadDomain('procurement');
const results = await svc.search('vendor', 'procurement');

Methods

getFieldSelector()

getFieldSelector(term, domain?): Promise<UI5Selector | undefined>

Defined in: src/vocabulary/types.ts:198

Resolve a term to its UI5 selector when confidence is high enough.

Parameters

term

string

Term to resolve.

domain?

SAPDomain

Optional domain to restrict resolution to.

Returns

Promise<UI5Selector | undefined>

UI5 selector or undefined.

Remarks

Returns undefined when:

  • No match reaches the 0.85 threshold.
  • Multiple matches score above 0.7 but below 0.85 (ambiguous).

Example

const selector = await svc.getFieldSelector('vendor', 'procurement');

getStats()

getStats(): VocabularyServiceStats

Defined in: src/vocabulary/types.ts:238

Return current service statistics.

Returns

VocabularyServiceStats

Snapshot of loaded domains, term counts, and cache performance.

Example

const stats = svc.getStats();
logger.info(stats.totalTerms);

getSuggestions()

getSuggestions(partial, maxResults?): Promise<string[]>

Defined in: src/vocabulary/types.ts:213

Return term name suggestions for a partial query.

Parameters

partial

string

Beginning of a term name to complete.

maxResults?

number

Maximum number of suggestions to return (default 10).

Returns

Promise<string[]>

Array of matching term names.

Example

const suggestions = await svc.getSuggestions('sup');
// ['supplier', 'supplierName', ...]

loadDomain()

loadDomain(domain): Promise<void>

Defined in: src/vocabulary/types.ts:225

Load a SAP domain into memory, enabling search within it.

Parameters

domain

SAPDomain

The SAP domain to load.

Returns

Promise<void>

Example

await svc.loadDomain('finance');

search(query, domain?): Promise<VocabularySearchResult[]>

Defined in: src/vocabulary/types.ts:179

Search vocabulary terms matching query.

Parameters

query

string

Natural-language search string.

domain?

SAPDomain

Optional domain to restrict search to.

Returns

Promise<VocabularySearchResult[]>

Matched terms sorted by confidence descending.

Example

const results = await svc.search('supplier');