Skip to content

Commit

Permalink
Replace previously forked quadStreamToStore method by upstream stream…
Browse files Browse the repository at this point in the history
…ToStore from rdf-dereference-store
  • Loading branch information
white-gecko committed Aug 23, 2024
1 parent 24f167a commit 548d33b
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 17 deletions.
167 changes: 167 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"lodash": "^4.17.21",
"n3": "^1.17.3",
"pinia": "^2.1.7",
"rdf-dereference-store": "^1.3.2",
"rdf-sparql-builder": "git+https://github.com/white-gecko/rdf-sparql-builder#feaature/smartAddPatternsWithQuads",
"rdf-string": "^1.6.3",
"rdf-transform-triple-to-quad": "^2.0.1",
Expand Down
8 changes: 0 additions & 8 deletions src/helpers/rdf-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,3 @@ export async function quadStreamToString(quadStream, options) {

return Buffer.concat(chunks).toString();
}

// from https://github.com/jeswr/rdf-dereference-store.js/blob/872301fefe1dfeafd6d5aacc12068966cb90e208/lib/index.ts#L14-L18
// Takes a Stream of Quads as first argument
export function quadStreamToStore(quadStream) {
const res = { store: new Store(), prefixes: {} }; // as Record<string, string>
quadStream.on('prefix', (prefix, ns) => { res.prefixes[prefix] = typeof ns === 'string' ? ns : ns.value; });
return promisifyEventEmitter(res.store.import(quadStream), res);
}
5 changes: 3 additions & 2 deletions src/views/FormDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { Store, StreamParser, Parser, Writer } from 'n3'
import { registerPlugin } from '@ulb-darmstadt/shacl-form'
import { getShapeQuery4Target, getShapeQuery4Instance } from '../helpers/queries'
import { defaultShape, defaultData } from '../helpers/rdf-data'
import { quadStreamToStore, quadStreamToString } from '../helpers/rdf-parse'
import { quadStreamToString } from '../helpers/rdf-parse'
import { streamToStore } from 'rdf-dereference-store';
import { Splitpanes, Pane } from 'splitpanes'
// import { LeafletPlugin } from '@ulb-darmstadt/shacl-form/plugins/leaflet.js'
// import * as jsonld from 'jsonld'
Expand Down Expand Up @@ -95,7 +96,7 @@ export default {
async getResource () {
this.subject = rdf.namedNode(this.resource_iri)
const resourceData = await this.store.getResource(this.resource_iri)
const originalData = (await quadStreamToStore(resourceData)).store
const originalData = (await streamToStore(resourceData)).store
return await quadStreamToString(originalData.match(), { format: 'application/n-triples', prefixes: this.prefixes_flat })
},
async getFormData () {
Expand Down
3 changes: 2 additions & 1 deletion src/views/Kanban.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import { useSelectionStore } from '../stores/selection'
import { useRdfStore } from '../stores/rdf'
import { cloneDeep } from 'lodash';
import draggable from "vuedraggable"
import { quadStreamToString, quadStreamToStore, stringToStore } from '../helpers/rdf-parse'
import { quadStreamToString, stringToStore } from '../helpers/rdf-parse'
import { streamToStore } from 'rdf-dereference-store';
import { diff_n3 } from '../helpers/n3-compare'
import rdf from '@rdfjs/data-model'
Expand Down
4 changes: 2 additions & 2 deletions src/views/PropertyView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Readable } from 'readable-stream'
import { mapState } from 'pinia'
import { useRdfStore } from '../stores/rdf'
import { useSelectionStore } from '../stores/selection'
import { quadStreamToStore } from '../helpers/rdf-parse'
import { streamToStore } from 'rdf-dereference-store';
import rdf from '@rdfjs/data-model'
export default {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default {
this.subject = rdf.namedNode(this.resource_iri)
console.log('get resource: ' + this.resource_iri)
const resourceData = await this.store.getResource(this.resource_iri)
this.dataModel = (await quadStreamToStore(resourceData)).store
this.dataModel = (await streamToStore(resourceData)).store
},
selectResource (resourceIri) {
this.selection.changeResourceIri(resourceIri)
Expand Down
5 changes: 3 additions & 2 deletions src/views/Source.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import { mapState } from 'pinia'
import { useRdfStore } from '../stores/rdf'
import { useSelectionStore } from '../stores/selection'
import { usePrefixesStore } from '../stores/prefixes'
import { quadStreamToString, quadStreamToStore, stringToStore } from '../helpers/rdf-parse'
import { quadStreamToString, stringToStore } from '../helpers/rdf-parse'
import { streamToStore } from 'rdf-dereference-store';
import { diff_n3 } from '../helpers/n3-compare'
export default {
Expand Down Expand Up @@ -54,7 +55,7 @@ export default {
async getResource () {
console.log('get resource')
const resourceData = await this.store.getResource(this.resource_iri)
this.originalData = (await quadStreamToStore(resourceData)).store
this.originalData = (await streamToStore(resourceData)).store
this.resourceSource = await quadStreamToString(this.originalData.match(), { format: 'text/turtle', prefixes: this.prefixes_flat })
},
async updateResource () {
Expand Down
Loading

0 comments on commit 548d33b

Please sign in to comment.