Skip to content

Commit

Permalink
build(deps): many RDF/JS updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Apr 10, 2024
1 parent 9ec21fe commit 3f39b8e
Show file tree
Hide file tree
Showing 11 changed files with 773 additions and 1,323 deletions.
11 changes: 11 additions & 0 deletions .changeset/tall-actors-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@zazuko/spex": patch
---

Many dependency updates. Notably:

- `rdf-ext` replaced with `@zazuko/env`
- `@rdfjs/formats-common` replaced with `@rdfjs/formats`
- `@zazuko/rdf-vocabularies` replaced with `@zazuko/prefixes`
- updated `sparql-http-client` to v3
- `rdf-js` removed
1,994 changes: 719 additions & 1,275 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@
"dependencies": {
"@headlessui/vue": "^1.7.14",
"@heroicons/vue": "^2.0.18",
"@rdf-esm/formats-common": "^0.5.6",
"@rdfjs-elements/rdf-editor": "^0.5.5",
"@zazuko/rdf-vocabularies": "^2023.1.19",
"@rdfjs-elements/rdf-editor": "^0.5.7",
"@zazuko/env": "^2.1.1",
"@zazuko/prefixes": "^2.2.0",
"@zazuko/vue-graph-layout": "^0.1.4",
"buffer": "^6.0.3",
"bulma": "^0.9.4",
"core-js": "^3.30.2",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"n3": "^1.16.4",
"process": "^0.11.10",
"rdf-ext": "^2.2.0",
"register-service-worker": "^1.7.2",
"sparql-http-client": "^2.4.2",
"sparql-http-client": "^3.0.0",
"splitpanes": "^3.1.5",
"stream-browserify": "^3.0.0",
"vue": "^3.3.4",
Expand All @@ -43,9 +41,7 @@
"@babel/core": "^7.22.1",
"@babel/eslint-parser": "^7.21.8",
"@changesets/cli": "^2.26.1",
"@types/clownface": "^1.5.2",
"@types/rdf-ext": "^2.2.0",
"@types/sparql-http-client": "^2.2.8",
"@types/sparql-http-client": "^3",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@vue/cli-plugin-babel": "^5.0.8",
Expand Down Expand Up @@ -80,4 +76,4 @@
"publishConfig": {
"access": "public"
}
}
}
2 changes: 1 addition & 1 deletion src/components/Term.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script setup lang="ts">
import { Endpoint } from '@/endpoint'
import { Term } from 'rdf-js'
import { Term } from '@rdfjs/types'
import { ref } from 'vue'
import Tooltip from './common/tooltip.vue'
Expand Down
9 changes: 4 additions & 5 deletions src/components/shacl-dialog/modal-shacl-load.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
</template>

<script>
import { Readable } from 'stream'
import { XMarkIcon } from '@heroicons/vue/24/solid'
import * as N3 from 'n3'
import rdfEnvironment from 'rdf-ext'
import rdfEnvironment from '@zazuko/env/web'
import { rdf, spex } from '@/namespace'
import SpexDialog from './dialog.vue'
Expand All @@ -53,10 +53,9 @@ export default {
return
}
const parser = new N3.Parser()
try {
const quads = parser.parse(this.data)
const dataset = rdfEnvironment.dataset(quads)
const quads = rdfEnvironment.formast.parsers.import('text/turtle', Readable.from(this.data))
const dataset = await rdfEnvironment.dataset().import(quads)
const pointer = rdfEnvironment.clownface({ dataset, term: spex.DefaultShapes })
.in(rdf.type)
.in(spex.shape)
Expand Down
43 changes: 22 additions & 21 deletions src/endpoint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { shrink } from '@zazuko/rdf-vocabularies/shrink'
import rdfEnvironment from 'rdf-ext'
import { shrink } from '@zazuko/prefixes'
import rdfEnvironment from '@zazuko/env/web.js'
import ParsingClient from 'sparql-http-client/ParsingClient'
import { dataModelFromSHACL, dataModelToSHACL } from '@/shacl'
import * as ns from './namespace'
Expand Down Expand Up @@ -54,13 +54,15 @@ export class Endpoint {
*/
public applySettings(settings: Settings) {
this._settings = settings
this._client = new ParsingClient(
{
endpointUrl: this._settings.sparqlEndpoint ?? '',
user: this._settings.username ?? undefined,
password: this._settings.password ?? undefined
}
)
if (this._settings.sparqlEndpoint) {
this._client = new ParsingClient(
{
endpointUrl: this._settings.sparqlEndpoint,
user: this._settings.username ?? undefined,
password: this._settings.password ?? undefined
}
)
}

// Reinitialize prefixes
Object.keys(_prefixes).forEach((prefix) => {
Expand Down Expand Up @@ -115,8 +117,8 @@ export class Endpoint {
if (dataModel !== null) {
return dataModel
}
const introspectedDataModel = this.fetchIntrospectDataModel()
return introspectedDataModel

return this.fetchIntrospectDataModel()
}

get datasetURI(): string {
Expand All @@ -141,17 +143,17 @@ export class Endpoint {
DESCRIBE <${this.datasetURI}>
${fromClause}
`
const quads = await this._client.query.construct(query)
const dataset = await this._client.query.construct(query)

if (quads.length === 0) {
if (dataset.size === 0) {
return null
}
const dataset = rdfEnvironment.clownface({
dataset: rdfEnvironment.dataset(quads),
const ptr = rdfEnvironment.clownface({
dataset,
term: rdfEnvironment.namedNode(this.datasetURI),
})

return this.dataModelFromSHACL(dataset)
return this.dataModelFromSHACL(ptr)
}

dataModelFromSHACL(dataset) {
Expand Down Expand Up @@ -258,12 +260,11 @@ export class Endpoint {
}
}
`
const results = await this._client.query.construct(query)
const dataset = rdfEnvironment.dataset(results)
const dataset = await this._client.query.construct(query)
const subjects = [...(dataset.match(null, ns.rdf.type, type) as any)]
const rows = rdfEnvironment.termMap(subjects.map(({ subject }) => [subject, { id: subject.value, term: subject }]))

results.forEach(({ subject, predicate: { value: predicate }, object }) => {
;[...dataset].forEach(({ subject, predicate: { value: predicate }, object }) => {
const row = rows.get(subject)

if (!row) return
Expand All @@ -289,7 +290,7 @@ export class Endpoint {
`
const quads = await this._client.query.construct(query)

const properties = quads.reduce((acc, { predicate, object }) => {
const properties = [...quads].reduce((acc, { predicate, object }) => {
if (!acc.has(predicate.value)) {
const property = {
id: predicate.value,
Expand Down Expand Up @@ -353,7 +354,7 @@ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?class (count(?x) as ?count) ${fromClause} WHERE {
?x a ?class .
?x a ?class .
} group by ?class
`
}
2 changes: 1 addition & 1 deletion src/model/resource.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Term } from 'rdf-js'
import { Term } from '@rdfjs/types'

export interface Resource {
id: string,
Expand Down
4 changes: 2 additions & 2 deletions src/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import prefixes from '@zazuko/rdf-vocabularies/prefixes'
import rdfEnvironment from 'rdf-ext'
import prefixes from '@zazuko/prefixes'
import rdfEnvironment from '@zazuko/env/web.js'

prefixes.spex = 'https://described.at/spex/'

Expand Down
2 changes: 1 addition & 1 deletion src/shacl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphPointer, MultiPointer } from 'clownface'
import rdfEnvironment from 'rdf-ext'
import rdfEnvironment from '@zazuko/env/web.js'
import { DataModel, Table, PropertyTerm } from './model/data-model.model'
import { rdf, schema, sh, spex } from './namespace'
import { Term } from '@rdfjs/types'
Expand Down
5 changes: 2 additions & 3 deletions src/views/ShaclEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@

<script>
import { ArrowPathIcon } from '@heroicons/vue/24/solid'
import { shrink as _shrink } from '@zazuko/rdf-vocabularies/shrink'
import { shrink as _shrink } from '@zazuko/prefixes'
import { GraphLayout } from '@zazuko/vue-graph-layout'
import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'
import '@rdfjs-elements/rdf-editor'
import { parsers } from '@rdf-esm/formats-common'
import rdfEnvironment from 'rdf-ext'
import rdfEnvironment from '@zazuko/env/web'
import { tablesFromSHACL } from '@/shacl'
import { rdf, sh } from '@/namespace'
import ResourceCard from '@/components/ResourceCard.vue'
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"compilerOptions": {
"noImplicitAny": false,
"target": "esnext",
"module": "esnext",
"target": "ES2022",
"module": "ES2022",
"strict": true,
"jsx": "preserve",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
Expand Down Expand Up @@ -39,4 +39,4 @@
"exclude": [
"node_modules"
]
}
}

0 comments on commit 3f39b8e

Please sign in to comment.