SPARQL 固体
Comunica SPARQL 光谱 Solid是用于 JavaScript 的 SPARQL 查询引擎, 可以向上查询 固态 数据舱.
这个软件包在Node.js和浏览器环境中都可以安全使用.
这个模块是 通信框架。 。 。 . 点击这里了解更多 Comunica 和 Solid。 。 。 .
已知问题
这个图书馆在某些情况下有下列已知问题,这些问题是我们无法控制的(但已经报告).
- 网络工人: 此库无法在 Web Workers 内部使用, 原因是其中存在一个未打开的问题 https://github.com/inrupt/solid-client-authn-js/issues/1657 (中文(简体) ) 在这个问题解决之前, https://github.com/rubensworks/soli-client-authn-js (中文(简体) ) 可改为使用.
- 企业固件服务器 (单位:千美元)https://pod.inrupt.com/ (中文(中国大陆) ):
- 补丁请求不被接受,因此只能创建新文档,而不能修改已存在的文档.
- 由于失踪
Accept-Patch,以及Accept-Put信头, 目标类型必须强制。这只有助于通过putLdp目标类型。 通过patchSparqlUpdate由于前一问题,目前不可能.
与 社区固件服务器
安装
$ yarn add @comunica/query-sparql-solid
或者说
$ npm install -g @comunica/query-sparql-solid
使用量
从私人资源显示 100 三重 通过 https://solidcommunity.net/ 页面存档备份,存于互联网档案馆 身份提供者(当使用时) https://pod.inrupt.com/ (中文(中国大陆) ),您的境内流离失所者将 https://broductor.pod.inrupt.com/ 互联网档案馆的存檔,存档日期2013-12-21:
$ comunica-sparql-solid --idp https://solidcommunity.net/ \
http://example.org/private-resource.ttl \
"SELECT * WHERE {
?s ?p ?o
} LIMIT 100"
此命令将连接到给定的身份提供者 , 并打开浏览器登录您的 WebID . 登录后,查询引擎将能够访问所有您访问的文件.
显示所有选项的帮助 :
$ comunica-sparql-solid --help
碞钩 Comunica SPARQL 光谱, (中文(简体) ),
(单位:千美元) 动态变量 (单位:千美元)comunica-dynamic-sparql-solid)也存在.
更多信息 关于从命令行查询。 。 。 .
应用中的使用
此引擎可用于JavaScript/TypeScript应用如下:
const QueryEngine = require('@comunica/query-sparql-solid').QueryEngine;
const { interactiveLogin } = require('solid-node-interactive-auth');
// This will open your Web browser to log in
const session = await interactiveLogin({ oidcIssuer: 'https://solidcommunity.net/' });
const myEngine = new QueryEngine();
const bindingsStream = await myEngine.queryBindings(`
SELECT * WHERE {
?s ?p ?o
} LIMIT 100`, {
sources: [session.info.webId], // Sets your profile as query source
'@comunica/actor-http-inrupt-solid-client-authn:session': session,
});
// Consume results as a stream (best performance)
bindingsStream.on('data', (binding) => {
console.log(binding.toString()); // Quick way to print bindings for testing
console.log(binding.has('s')); // Will be true
// Obtaining values
console.log(binding.get('s').value);
console.log(binding.get('s').termType);
console.log(binding.get('p').value);
console.log(binding.get('o').value);
});
bindingsStream.on('end', () => {
// The data-listener will not be called anymore once we get here.
});
bindingsStream.on('error', (error) => {
console.error(error);
});
// Consume results as an array (easier)
const bindings = await bindingsStream.toArray();
console.log(bindings[0].get('s').value);
console.log(bindings[0].get('s').termType);
请注意: solid-node-interactive-auth 只在Node.js应用程序内工作。 请参考 @inrupt/solid-client-authn-browser 如果你想通过浏览器应用程序登录.
更多信息 关于查询应用程序。 。 。 .
用作 SPARQL 端点
启动网络服务,通过 SPARQL 协议(即 a) 曝光私有资源 SPARQL 端点, (中文(简体) ), 通过 https://solidcommunity.net/ 页面存档备份,存于互联网档案馆 身份提供者.
$ comunica-sparql-solid-http --idp https://solidcommunity.net/ \
http://example.org/private-resource.ttl
显示所有选项的帮助 :
$ comunica-sparql-solid-http --help
SPARQL端点只能动态地启动.
一个替代配置文件可以通过 COMUNICA_CONFIG 环境变量.
使用 bin/http.js 在 Comunica 单列坡开发环境中运行时.
更多信息 关于设置 SPARQL 端点。 。 。 .