{"id":13554464,"url":"https://github.com/LDflex/LDflex-Comunica","last_synced_at":"2025-04-03T07:31:30.073Z","repository":{"id":37444783,"uuid":"149039988","full_name":"LDflex/LDflex-Comunica","owner":"LDflex","description":"Comunica query engine support for the LDflex language","archived":false,"fork":false,"pushed_at":"2024-08-08T12:47:18.000Z","size":7826,"stargazers_count":16,"open_issues_count":8,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-17T13:41:22.756Z","etag":null,"topics":["comunica","ldflex","query"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LDflex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-16T22:10:35.000Z","updated_at":"2024-05-13T13:27:16.000Z","dependencies_parsed_at":"2024-11-04T02:31:39.245Z","dependency_job_id":null,"html_url":"https://github.com/LDflex/LDflex-Comunica","commit_stats":{"total_commits":164,"total_committers":5,"mean_commits":32.8,"dds":0.5792682926829269,"last_synced_commit":"f01ece6fa8cee720061efd5ddd23ed82921555e4"},"previous_names":["rubenverborgh/ldflex-comunica"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LDflex%2FLDflex-Comunica","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LDflex%2FLDflex-Comunica/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LDflex%2FLDflex-Comunica/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LDflex%2FLDflex-Comunica/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LDflex","download_url":"https://codeload.github.com/LDflex/LDflex-Comunica/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246956454,"owners_count":20860440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comunica","ldflex","query"],"created_at":"2024-08-01T12:02:48.353Z","updated_at":"2025-04-03T07:31:29.733Z","avatar_url":"https://github.com/LDflex.png","language":"TypeScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# Comunica for LDflex\nThis library lets you use\nthe [Comunica](https://github.com/comunica/comunica/) query engine\nwith the [LDflex](https://github.com/LDflex/LDflex) language.\n\n[![npm version](https://img.shields.io/npm/v/@ldflex/comunica.svg)](https://www.npmjs.com/package/@ldflex/comunica)\n[![build](https://img.shields.io/github/workflow/status/LDflex/LDflex-Comunica/Push%20Checks)](https://github.com/LDflex/LDflex-Comunica/tree/master/)\n[![Coverage Status](https://coveralls.io/repos/github/LDflex/LDflex-Comunica/badge.svg?branch=master)](https://coveralls.io/github/LDflex/LDflex-Comunica?branch=master)\n[![Dependency Status](https://david-dm.org/LDflex/LDflex-Comunica.svg)](https://david-dm.org/LDflex/LDflex-Comunica)\n\n## Installation\n```bash\nnpm install ldflex @ldflex/comunica\n```\n\n## Usage\n```JavaScript\nconst { PathFactory } = require('ldflex');\nconst { default: ComunicaEngine } = require('@ldflex/comunica');\nconst { namedNode } = require('@rdfjs/data-model');\n\n// The JSON-LD context for resolving properties\nconst context = {\n  \"@context\": {\n    \"@vocab\": \"http://xmlns.com/foaf/0.1/\",\n    \"friends\": \"knows\",\n  }\n};\n// The query engine and its source\nconst queryEngine = new ComunicaEngine('https://ruben.verborgh.org/profile/');\n// The object that can create new paths\nconst paths = new PathFactory({ context, queryEngine });\n\nasync function showPerson(person) {\n  console.log(`This person is ${await person.name}`);\n\n  console.log(`${await person.givenName} is friends with:`);\n  for await (const name of person.friends.givenName)\n    console.log(`- ${name}`);\n}\n\nconst ruben = paths.create({\n  subject: namedNode('https://ruben.verborgh.org/profile/#me'),\n});\nshowPerson(ruben);\n```\n\n## Features\n\n### Using a customised ComunicaEngine\n\nThis example uses the comunica engine for local file queries.\n\n```JavaScript\nconst { PathFactory } = require('ldflex');\nconst { default: ComunicaEngine } = require('@ldflex/comunica');\nconst { namedNode } = require('@rdfjs/data-model');\nconst { newEngine: localFileEngine } = require('@comunica/actor-init-sparql-file');\n\n// The JSON-LD context for resolving properties\nconst context = {\n  \"@context\": {\n    \"@vocab\": \"http://xmlns.com/foaf/0.1/\",\n    \"friends\": \"knows\",\n  }\n};\n// The query engine and its source\nconst queryEngine = new ComunicaEngine(\n    path.join(__dirname, 'ruben-verborgh.ttl'),\n    { engine: localFileEngine() }\n  );\n// The object that can create new paths\nconst paths = new PathFactory({ context, queryEngine });\n\nasync function showPerson(person) {\n  console.log(`This person is ${await person.name}`);\n\n  console.log(`${await person.givenName} is friends with:`);\n  for await (const name of person.friends.givenName)\n    console.log(`- ${name}`);\n}\n\nconst ruben = paths.create({\n  subject: namedNode('https://ruben.verborgh.org/profile/#me'),\n});\nshowPerson(ruben);\n```\n### Adding custom options to the ComunicaEngine\n\nAdd [comunica context options](https://comunica.dev/docs/query/advanced/context/) which are passed to the Comunica Engine. \n\n```JavaScript\nconst { PathFactory } = require('ldflex');\nconst { default: ComunicaEngine } = require('@ldflex/comunica');\nconst { namedNode } = require('@rdfjs/data-model');\n\n// The JSON-LD context for resolving properties\nconst context = {\n  \"@context\": {\n    \"@vocab\": \"http://xmlns.com/foaf/0.1/\",\n    \"friends\": \"knows\",\n  }\n};\n\n// The query engine and its source\nconst queryEngine = new ComunicaEngine(\n    'https://ruben.verborgh.org/profile/',\n    { options: {/* add options here */} },\n  );\n\n// The object that can create new paths\nconst paths = new PathFactory({ context, queryEngine });\n\nasync function showPerson(person) {\n  console.log(`This person is ${await person.name}`);\n\n  console.log(`${await person.givenName} is friends with:`);\n  for await (const name of person.friends.givenName)\n    console.log(`- ${name}`);\n}\n\nconst ruben = paths.create({\n  subject: namedNode('https://ruben.verborgh.org/profile/#me'),\n});\nshowPerson(ruben);\n```\n\n### Updating data\nBy default the source given is also used as the destination for updates (if multiple sources are given, then the first one is chosen).\n\nOptionally you can specify your own destination for updates as follows\n\n```JavaScript\n// The query engine and its source\nconst queryEngine = new ComunicaEngine(\n    'https://ruben.verborgh.org/profile/',\n    { destination: 'https://example.org/destination' },\n  );\n```\n\n## License\n©2018–present\n[Ruben Verborgh](https://ruben.verborgh.org/), Joachim Van Herwegen, [Jesse Wright](https://github.com/jeswr/). [MIT License](https://github.com/LDflex/LDflex-Comunica/blob/master/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLDflex%2FLDflex-Comunica","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLDflex%2FLDflex-Comunica","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLDflex%2FLDflex-Comunica/lists"}