@solid-data-modules/rdflib-utils
Version:
Utility functions for the development of Solid Data Modules for RDFLib.js
37 lines • 1.14 kB
JavaScript
import { isNamedNode } from "rdflib";
import { pim, solid } from "../namespaces/index.js";
/**
* Used query data from a user's profile document
*/
export class ProfileQuery {
constructor(
/**
* The WebID of the user
*/
webIdNode, store) {
this.webIdNode = webIdNode;
this.store = store;
}
/**
* Look up the public type index. Returns null if none is found or if the predicated does not link to a proper named node
*/
queryPublicTypeIndex() {
const predicate = solid("publicTypeIndex");
return this.queryNamedNode(predicate);
}
/**
* Look up the preferences file. Returns null if none is found or if the predicated does not link to a proper named node
*/
queryPreferencesFile() {
const predicate = pim("preferencesFile");
return this.queryNamedNode(predicate);
}
queryNamedNode(predicate) {
const node = this.store.any(this.webIdNode, predicate, null, this.webIdNode.doc());
if (isNamedNode(node)) {
return node;
}
return null;
}
}
//# sourceMappingURL=ProfileQuery.js.map