UNPKG

alcaeus

Version:

Hydra Core hypermedia-aware client library

23 lines (22 loc) 831 B
import { hydra, rdf } from '@tpluscode/rdf-ns-builders'; const propertyRangeMappings = [ [hydra.supportedClass, hydra.Class], [hydra.expects, hydra.Class], [hydra.returns, hydra.Class], [hydra.supportedOperation, hydra.Operation], [hydra.operation, hydra.Operation], [hydra.supportedProperty, hydra.SupportedProperty], [hydra.statusCode, hydra.Status], [hydra.property, rdf.Property], [hydra.mapping, hydra.IriTemplateMapping], ]; export function* inferTypesFromPropertyRanges(dataset, env) { const node = env.clownface({ dataset }); for (const mapping of propertyRangeMappings) { const [property, type] = mapping; const subjects = node.out(property); for (const subject of subjects.terms) { yield env.quad(subject, rdf.type, type); } } }