API Reference
Every exported function, type, and error class from @younndai/domains.
Constants
| Export | Type | Description |
|---|---|---|
VERSION | string | Package version |
Bundled Domains
| Function | Returns | Description |
|---|---|---|
getBundledDomain(id) | DomainSchema | null | Get bundled domain |
listBundledDomains() | string[] | List all bundled domain IDs |
isBundledDomain(id) | boolean | Check if domain is bundled |
Registry Client
| Function | Returns | Description |
|---|---|---|
getDomain(id, opts?) | Promise<DomainSchema | null> | Fetch single domain |
getDomains(ids[]) | Promise<Map> | Fetch multiple domains |
fetchDomainList(opts?) | Promise<{domains, total}> | List with filters |
searchDomains(query) | Promise<DomainSchema[]> | Full-text search |
getDomainVersions(id) | Promise<DomainVersion[]> | Version history |
getRegistryStats() | Promise<RegistryStats> | Aggregate stats |
listNamespaces(opts?) | Promise<Namespace[]> | List namespaces |
getNamespace(path) | Promise<Namespace> | Get namespace |
getNotices(opts?) | Promise<Notice[]> | Active notices |
getAnnouncements(opts?) | Promise<Announcement[]> | Announcements |
checkRegistryHealth() | Promise<RegistryHealthResult> | Health check |
Configuration
| Function | Description |
|---|---|
configureClient(config) | Full configuration |
setRegistryUrl(url) | Set base URL |
getRegistryUrl() | Get current URL |
setCacheAdapter(adapter) | Swap cache backend |
clearDomainCache() | Flush cache |
getDomainCacheStats() | Cache diagnostics |
resetCacheStats() | Zero stat counters |
Local Registry
| Function | Description |
|---|---|
registerDomain(schema) | Register locally (T3) |
unregisterDomain(id) | Remove local domain |
isOfficialDomain(id) | Check if bundled |
listDomains(filter?) | List loaded domains |
getDomainTags(domains[]) | Additive tag set |
getLocalDomain(id) | Get single local domain |
Resolution
| Function | Description |
|---|---|
resolveDomain(id, opts?) | T1→T3→T2 unified resolution |
Introspection
Async variants take a domain ID. Sync variants (add Sync suffix) take a DomainSchema object.
| Function | Description |
|---|---|
getRecordTags / getRecordTagsSync | All record tags |
getRecordSchema / getRecordSchemaSync | Record definition |
getRequiredFields / getRequiredFieldsSync | Required fields |
getOptionalFields / getOptionalFieldsSync | Optional fields |
getFieldConstraints / getFieldConstraintsSync | Field constraints |
describeRecord / describeRecordSync | Structured summary |
Lookup
| Function | Description |
|---|---|
findDomainsByTag(tag) | Reverse tag lookup |
buildTagIndex() | Force index rebuild |
Validation
| Function | Description |
|---|---|
validateRecord(domainId, tag, data) | Async validation |
validateRecordSync(tag, data, domain) | Sync validation |
validateRecords(entries[]) | Batch validation |
validateFields(data, constraints) | Low-level field check |
Offline Bundles
| Function | Description |
|---|---|
downloadRegistryBundle(opts?) | Download all domains |
serializeBundle(bundle) | Bundle → JSON string |
deserializeBundle(json) | JSON string → bundle |
loadBundleFromJSON(json) | Parse JSON → bundle |
applyBundle(bundle, registerFn) | Register all locally |
getBundleManifest(bundle) | Lightweight summary |
Error Classes
| Class | When Thrown |
|---|---|
DomainNotFoundError | API returns 404 |
RegistryUnavailableError | Network failure, timeout, 5xx |
AccessDeniedError | API returns 403 |
Taxonomy (@younndai/domains/taxonomy)
| Export | Description |
|---|---|
SET_TYPES | Domain set type data |
CONFORMANCE_LEVELS | Conformance tier data |
CONFORMANCE_ORDER | Ordered level keys |
VERIFICATION | Verification config data |
DOMAIN_STATES | Domain state definitions |
TRUST_LEVELS | Trust level definitions |
resolveSetType(path, tier) | Classify domain tier |
resolveConformanceLevel(score) | Score → conformance level |
isInstitutional(path) | Check institutional path |
resolveTrustLevel(verified, score, setType) | Composite trust signal |
getFreshnessLabel(date) | Freshness indicator |
JSON Schema (@younndai/domains/json-schema)
| Export | Description |
|---|---|
recordToJSONSchema(record, tag, domainId) | Single record → JSON Schema |
fieldToJSONSchema(constraint) | Single field |
domainToJSONSchemas(domain) | All records |
exportJSONSchemas(domainId) | Async full domain |
Adapter
| Export | Description |
|---|---|
loadDomainFromJSON(raw) | Convert raw JSON → DomainSchema |
Normalize
| Export | Description |
|---|---|
normalizeDomainId(id) | Normalize domain ID |
lookupWithFallback(id) | Lookup with alias fallback |
