Introspection
Explore domain structure and reverse tag lookup.
Record Tags
import { getRecordTags } from "@younndai/domains";
const tags = await getRecordTags("yon.health");
// → ['VITALS', 'DX', 'RX', 'LAB', ...]
Describe Record
import { describeRecord } from "@younndai/domains";
const summary = await describeRecord("yon.health", "VITALS");
// → { tag: 'VITALS', requiredFields: ['bp'], optionalFields: ['hr', ...], fieldCount: 7 }
Required / Optional Fields
import { getRequiredFields, getOptionalFields } from "@younndai/domains";
const required = await getRequiredFields("yon.health", "VITALS"); // ['bp']
const optional = await getOptionalFields("yon.health", "VITALS"); // ['hr', 'temp_c', ...]
Sync Variants
All functions have sync variants for pre-resolved domains:
import {
getRecordTagsSync,
describeRecordSync,
getBundledDomain,
} from "@younndai/domains";
const domain = getBundledDomain("yon.health")!;
const tags = getRecordTagsSync(domain);
const summary = describeRecordSync(domain, "VITALS");
Reverse Tag Lookup
Find all domains that define a given tag:
import { findDomainsByTag } from "@younndai/domains";
const result = findDomainsByTag("POSITION");
// → { tag: 'POSITION', matches: [
// { domainId: 'yon.hr', record: {...} },
// { domainId: 'yon.fintech', record: {...} },
// ] }
ℹ️Note
When multiple domains define the same tag, the consumer decides which is
authoritative. The parser knows from @DOC domain=, the validator receives
domainId as argument.
