Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sFull = (id: NamedNode, attrs: Test) => {
return [
typeObject(id)[0],
new Statement(id, NS.schema("name"), new Literal(attrs.title || "title"), NS.example("default")),
new Statement(id, NS.schema("text"), new Literal(attrs.text || "text"), NS.example("default")),
new Statement(id, NS.schema("author"), new NamedNode(attrs.author || "http://example.org/people/0"), NS.example("default")),
new Statement(id, NS.schema("dateCreated"), Literal.fromDate(new Date("2019-01-01")), NS.example("default")),
new Statement(id, NS.ex("timesRead"), Literal.fromValue(5), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/0"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/1"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/2"), NS.example("default")),
new Statement(id, NS.example("tags"), NS.example("tag/3"), NS.example("default")),
];
};
const opts = ctx.fullCW(iri);
const comp = link({
author: defaultNS.schema("author"),
name: defaultNS.schema("name"),
tags: defaultNS.example("tags"),
text: defaultNS.schema("text"),
})(TestComponent);
opts.lrs.registerAll(LinkedRenderStore.registerRenderer(comp, defaultNS.schema("Thing")));
const elem = mount(opts.wrapComponent());
expect(elem.find(TestComponent)).toHaveLength(1);
expect(elem.find(TestComponent)).toHaveProp("name", new Literal("title"));
expect(elem.find(TestComponent)).toHaveProp("text", new Literal("text"));
expect(elem.find(TestComponent)).toHaveProp("author", new NamedNode("http://example.org/people/0"));
expect(elem.find(TestComponent)).toHaveProp("tags", defaultNS.example("tag/0"));
});
const sFull = (id, attrs) => {
const iri = exNS(id);
return [
typeObject(id)[0],
new rdf.Statement(iri, schema('name'), new rdf.Literal(attrs.title || 'title')),
new rdf.Statement(iri, schema('text'), new rdf.Literal(attrs.text || 'text')),
new rdf.Statement(iri, schema('author'), new rdf.NamedNode(attrs.author || 'http://example.org/people/0')),
];
};
return bookmarkStatements.map((statement) => {
const recalls = new $rdf.NamedNode('http://www.w3.org/2002/01/bookmark#recalls')
const bookmarkNode = statement.subject
const [ titleStatement ] = store.statementsMatching(bookmarkNode, ns.dct('title'), null, bookmarkRegistryInstance)
const [ urlStatement ] = store.statementsMatching(bookmarkNode, recalls, null, bookmarkRegistryInstance)
return {
title: titleStatement.object.value,
url: urlStatement.object.value
}
})
}
async function getBookmarks (store: $rdf.IndexedFormula, fetcher: $rdf.Fetcher, webId: string) {
const profile = $rdf.sym(webId)
const [ publicTypeIndexStatement ] = store.statementsMatching(profile, ns.solid('publicTypeIndex'), null, profile.doc(), true)
if (!publicTypeIndexStatement) {
return []
}
const publicTypeIndex = publicTypeIndexStatement.object
await fetcher.load(publicTypeIndex as any as $rdf.NamedNode)
const bookmarkClass = new $rdf.NamedNode('http://www.w3.org/2002/01/bookmark#Bookmark')
const [ bookmarkRegistryStatement ] = store.statementsMatching(null, ns.solid('forClass'), bookmarkClass, publicTypeIndex, true)
if (!bookmarkRegistryStatement) {
return []
}
const bookmarkRegistry = bookmarkRegistryStatement.subject
const [ bookmarkRegistryInstanceStatement ] = store.statementsMatching(bookmarkRegistry, ns.solid('instance'), null, publicTypeIndex, true)
const bookmarkRegistryInstance = bookmarkRegistryInstanceStatement.object
await fetcher.load(bookmarkRegistryInstance as any as $rdf.NamedNode)
const bookmarkStatements = store.statementsMatching(null, ns.rdf('type'), bookmarkClass, bookmarkRegistryInstance)
return bookmarkStatements.map((statement) => {
const recalls = new $rdf.NamedNode('http://www.w3.org/2002/01/bookmark#recalls')
const bookmarkNode = statement.subject
const [ titleStatement ] = store.statementsMatching(bookmarkNode, ns.dct('title'), null, bookmarkRegistryInstance)
const [ urlStatement ] = store.statementsMatching(bookmarkNode, recalls, null, bookmarkRegistryInstance)
return {
title: titleStatement.object.value,