From e1f24345f507f1707587de91b02e23c1fc81cd9a Mon Sep 17 00:00:00 2001 From: Tomasz Pluskiewicz Date: Fri, 26 Jan 2024 14:31:40 +0100 Subject: [PATCH] build: update webpack loader --- apps/www/package.json | 9 +--- apps/www/src/automation.js | 9 ++-- apps/www/src/clownface.js | 8 ++-- apps/www/src/component/decorators.js | 6 +-- apps/www/src/element/ssz-notifications.js | 4 +- apps/www/src/element/ssz-shacl-report.js | 17 ++++--- apps/www/src/element/ssz-view-table.js | 10 ++-- apps/www/src/fetch.js | 5 +- apps/www/src/forms/config.js | 4 +- apps/www/src/forms/dynamicXone.js | 4 +- apps/www/src/forms/plugins/autoName.js | 18 +++---- apps/www/src/queries/dimensions.js | 10 ++-- apps/www/src/queries/index.js | 6 +-- apps/www/src/state/app/effects.js | 5 +- apps/www/src/state/app/index.js | 8 ++-- apps/www/src/state/plugin/operationAlerts.js | 4 +- apps/www/src/state/plugin/view.js | 3 +- apps/www/src/state/plugin/viewCollection.js | 8 ++-- .../state/plugin/viewForm/toggleButtons.js | 4 +- apps/www/src/state/plugins.js | 5 +- apps/www/src/view/searchForm.js | 10 ++-- apps/www/src/view/view.js | 10 ++-- apps/www/src/view/viewCollection.js | 10 ++-- apps/www/test/automation.test.js | 7 ++- apps/www/test/forms/dynamicXone.test.js | 9 ++-- packages/testing/index.js | 10 ++-- packages/testing/package.json | 6 +-- yarn.lock | 47 +++++++++---------- 28 files changed, 117 insertions(+), 139 deletions(-) diff --git a/apps/www/package.json b/apps/www/package.json index 268170b..40be835 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -22,13 +22,7 @@ "@rdfine/hydra": "^0.10.2", "@rdfjs-elements/lit-helpers": "^0.3.4", "@rdfjs-elements/formats-pretty": "^0.5.1", - "@rdfjs/data-model": "^2.0.1", - "@rdfjs/dataset": "^2.0.1", - "@rdfjs/term-map": "^2.0.0", - "@rdfjs/term-set": "^2.0.0", - "@rdfjs/traverser": "^0.1.0", "@shoelace-style/shoelace": "^2.0.0-beta.80", - "@tpluscode/rdf-ns-builders": "^4", "@tpluscode/rdf-string": "^1.0.3", "@tpluscode/sparql-builder": "^1.1.0", "content-disposition": "^0.5.4", @@ -38,7 +32,6 @@ "@zazuko/prefixes": "^2.0.0", "@zazuko/vocabulary-extras": "^2.0.1", "alcaeus": "^2.3.2", - "clownface": "^2", "clownface-shacl-path": "^2.0.2", "get-stream": "^6.0.1", "is-absolute-url": "^4.0.1", @@ -69,7 +62,7 @@ "webpack": "^4.46.0", "webpack-cli": "^3.3.12", "webpack-dev-server": "^3.11.2", - "webpack-loader-rdf": "^0.1.1", + "webpack-loader-rdf": "^0.2.0", "webpack-merge": "^5.8.0" } } diff --git a/apps/www/src/automation.js b/apps/www/src/automation.js index b369792..b845fa8 100644 --- a/apps/www/src/automation.js +++ b/apps/www/src/automation.js @@ -1,5 +1,4 @@ -import { rdfs, rdf } from '@tpluscode/rdf-ns-builders' -import TermMap from '@rdfjs/term-map' +import rdf from '@view-builder/core/env.js' import * as ns from '@view-builder/core/ns.js' import * as dimensionQueries from './queries/dimensions.js' import { deleteCbd, newReference } from './clownface.js' @@ -26,7 +25,7 @@ async function createKeyDimensions(view, pointer, client, { findKeyDimensions }) map.set(dimension, value) return map - }, new TermMap()) + }, rdf.termMap()) for (const [dimension, { label, sources }] of dimensions) { view.addOut(ns.view.dimension, (viewDim) => { @@ -39,7 +38,7 @@ async function createKeyDimensions(view, pointer, client, { findKeyDimensions }) }) if (label) { - viewDim.addOut(rdfs.label, `Key ${label.value}`) + viewDim.addOut(rdf.ns.rdfs.label, `Key ${label.value}`) } }) } @@ -68,7 +67,7 @@ async function createMeasureDimensions(view, sources, client, { findMeasureDimen }) if (label) { - viewDim.addOut(rdfs.label, `Measure ${label.value} (${source.out(rdfs.label).value})`) + viewDim.addOut(rdf.ns.rdfs.label, `Measure ${label.value} (${source.out(rdf.ns.rdfs.label).value})`) } }) } diff --git a/apps/www/src/clownface.js b/apps/www/src/clownface.js index c4f1bf2..88bbba3 100644 --- a/apps/www/src/clownface.js +++ b/apps/www/src/clownface.js @@ -1,6 +1,4 @@ import $rdf from '@view-builder/core/env.js' -import Traverser from '@rdfjs/traverser' -import TermSet from '@rdfjs/term-set' export function newReference(ptr) { return $rdf.clownface({ @@ -9,7 +7,7 @@ export function newReference(ptr) { }) } -const subgraph = new Traverser(({ level, quad }) => level === 0 || quad.subject.termType === 'BlankNode', { factory: $rdf }) +const subgraph = $rdf.traverser(({ level, quad }) => level === 0 || quad.subject.termType === 'BlankNode') export function deleteCbd(ptr) { for (const quad of subgraph.match(ptr)) { @@ -18,7 +16,7 @@ export function deleteCbd(ptr) { } export function getAllTriplesFromRoot(ptr) { - const visited = new TermSet() - const traverser = new Traverser(({ quad }) => !visited.has(quad.subject), { factory: $rdf }) + const visited = $rdf.termSet() + const traverser = $rdf.traverser(({ quad }) => !visited.has(quad.subject)) return traverser.match(ptr) } diff --git a/apps/www/src/component/decorators.js b/apps/www/src/component/decorators.js index 00bca4c..9d49d08 100644 --- a/apps/www/src/component/decorators.js +++ b/apps/www/src/component/decorators.js @@ -1,8 +1,8 @@ -import { dash, rdf } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' export const dataGraphInstanceSource = { applicableTo(component) { - return component.editor.equals(dash.InstancesSelectEditor) + return component.editor.equals($rdf.ns.dash.InstancesSelectEditor) }, decorate(component) { return { @@ -16,7 +16,7 @@ export const dataGraphInstanceSource = { return focusNode .any() - .has(rdf.type, clas.id) + .has($rdf.ns.rdf.type, clas.id) .toArray() }, } diff --git a/apps/www/src/element/ssz-notifications.js b/apps/www/src/element/ssz-notifications.js index d3405b5..7823689 100644 --- a/apps/www/src/element/ssz-notifications.js +++ b/apps/www/src/element/ssz-notifications.js @@ -1,10 +1,10 @@ import { css, html, LitElement, render } from 'lit' import { connect } from '@captaincodeman/rdx' +import $rdf from '@view-builder/core/env.js' import '@shoelace-style/shoelace/dist/components/dialog/dialog.js' import '@shoelace-style/shoelace/dist/components/icon/icon.js' import '@shoelace-style/shoelace/dist/components/progress-bar/progress-bar.js' import './ssz-shacl-report.js' -import { rdfs } from '@tpluscode/rdf-ns-builders' import { store } from '../state/store.js' export class SszNotifications extends connect(store, LitElement) { @@ -88,7 +88,7 @@ export class SszNotifications extends connect(store, LitElement) { renderError() { return html` ` diff --git a/apps/www/src/element/ssz-shacl-report.js b/apps/www/src/element/ssz-shacl-report.js index e680400..e1b8225 100644 --- a/apps/www/src/element/ssz-shacl-report.js +++ b/apps/www/src/element/ssz-shacl-report.js @@ -1,6 +1,5 @@ import { html, LitElement } from 'lit' -import TermMap from '@rdfjs/term-map' -import { sh } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' import '@shoelace-style/shoelace/dist/components/details/details.js' import { toSparql } from 'clownface-shacl-path' @@ -22,15 +21,15 @@ customElements.define('ssz-shacl-report', class extends LitElement { return [] } - const map = this.report.out(sh.result) + const map = this.report.out($rdf.ns.sh.result) .toArray() .reduce((previous, result) => { - const focusNode = result.out(sh.focusNode).term + const focusNode = result.out($rdf.ns.sh.focusNode).term const results = previous.get(focusNode) || [] results.push(result) previous.set(focusNode, results) return previous - }, new TermMap()) + }, $rdf.termMap()) return [...map] } @@ -41,7 +40,7 @@ customElements.define('ssz-shacl-report', class extends LitElement { renderFocusNodeResults([focusNode, results]) { const grouped = results.reduce(({ warnings, violations }, result) => { - if (result.out(sh.resultSeverity).term?.equals(sh.Warning)) { + if (result.out($rdf.ns.sh.resultSeverity).term?.equals($rdf.ns.sh.Warning)) { return { violations, warnings: [...warnings, result] } } @@ -78,9 +77,9 @@ customElements.define('ssz-shacl-report', class extends LitElement { // eslint-disable-next-line class-methods-use-this renderResult(result) { - const property = result.out(sh.sourceShape).out(sh.name).value || - toSparql(result.out(sh.resultPath)).toString({ prologue: false }) + const property = result.out($rdf.ns.sh.sourceShape).out($rdf.ns.sh.name).value || + toSparql(result.out($rdf.ns.sh.resultPath)).toString({ prologue: false }) - return html`
  • ${property}: ${result.out(sh.resultMessage)}
  • ` + return html`
  • ${property}: ${result.out($rdf.ns.sh.resultMessage)}
  • ` } }) diff --git a/apps/www/src/element/ssz-view-table.js b/apps/www/src/element/ssz-view-table.js index 4d21e79..0705139 100644 --- a/apps/www/src/element/ssz-view-table.js +++ b/apps/www/src/element/ssz-view-table.js @@ -1,6 +1,6 @@ import { css, html, LitElement } from 'lit' import { repeat } from 'lit/directives/repeat.js' -import { schema, vcard } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' import '@shoelace-style/shoelace/dist/components/icon-button/icon-button.js' import { ssz } from '@view-builder/core/ns.js' @@ -52,10 +52,10 @@ customElements.define('ssz-view-table', class extends LitElement { return html` - ${view.out(schema.alternateName).value} - ${view.out(schema.name).value} - ${metadataCreator.out(vcard.hasName).value || metadataCreator.value} - ${view.out(schema.author).out(vcard.hasName).value} + ${view.out($rdf.ns.schema.alternateName).value} + ${view.out($rdf.ns.schema.name).value} + ${metadataCreator.out($rdf.ns.vcard.hasName).value || metadataCreator.value} + ${view.out($rdf.ns.schema.author).out($rdf.ns.vcard.hasName).value} function dynamicXone(context, args) { return wrapped(context, args) }) -const { differentFrom } = owl +const { differentFrom } = $rdf.ns.owl function shouldDisplay(shape, value) { const discriminatorValue = shape.pointer.out(sh1.discriminatorValue) diff --git a/apps/www/src/forms/plugins/autoName.js b/apps/www/src/forms/plugins/autoName.js index 0d27d91..9b92711 100644 --- a/apps/www/src/forms/plugins/autoName.js +++ b/apps/www/src/forms/plugins/autoName.js @@ -1,9 +1,9 @@ import sh1 from '@hydrofoil/shaperone-core/ns.js' import { SELECT } from '@tpluscode/sparql-builder' -import { rdfs, rdf, schema } from '@tpluscode/rdf-ns-builders' import { isGraphPointer, isLiteral } from 'is-graph-pointer' import { findNodes, toSparql } from 'clownface-shacl-path' import { view, viewBuilder } from '@view-builder/core/ns.js' +import $rdf from '@view-builder/core/env.js' import { store } from '../../state/store.js' export const autoResourceLabel = { @@ -31,7 +31,7 @@ export const autoResourceLabel = { } const label = await loadResourceLabel(arg.newValue, labelPath) - focusNode.deleteOut(rdfs.label).addOut(rdfs.label, label) + focusNode.deleteOut($rdf.ns.rdfs.label).addOut($rdf.ns.rdfs.label, label) forms.updateComponentState({ ...arg, newState: { label } }) }, } @@ -51,7 +51,7 @@ export const filterLabel = { */ 'forms/setObjectValue': async (arg) => { const { focusNode, property } = arg - if (focusNode.has(rdf.type, view.Filter).terms.length === 0) { + if (focusNode.has($rdf.ns.rdf.type, view.Filter).terms.length === 0) { return } @@ -66,19 +66,19 @@ export const filterLabel = { const argument = focusNode.out(view.argument) if (isGraphPointer(filterTermSet)) { - const dimensionLabel = await loadResourceLabel(dimension.term, schema.name) - const termSetLabel = await loadResourceLabel(filterTermSet.term, schema.name) + const dimensionLabel = await loadResourceLabel(dimension.term, $rdf.ns.schema.name) + const termSetLabel = await loadResourceLabel(filterTermSet.term, $rdf.ns.schema.name) label = `${dimensionLabel} is one of "${termSetLabel}"` } else if (isGraphPointer(operator) && isGraphPointer(argument)) { - const dimensionLabel = await loadResourceLabel(dimension.term, schema.name) - const operatorLabel = property.pointer.node(operator).out(rdfs.label).value + const dimensionLabel = await loadResourceLabel(dimension.term, $rdf.ns.schema.name) + const operatorLabel = property.pointer.node(operator).out($rdf.ns.rdfs.label).value label = `${dimensionLabel} ${operatorLabel} "${argument.value}"` } } - focusNode.deleteOut(rdfs.label).addOut(rdfs.label, label) + focusNode.deleteOut($rdf.ns.rdfs.label).addOut($rdf.ns.rdfs.label, label) forms.updateComponentState({ ...arg, newState: { label } }) }, } @@ -86,7 +86,7 @@ export const filterLabel = { }, } -async function loadResourceLabel(id, labelPath = rdfs.label) { +async function loadResourceLabel(id, labelPath = $rdf.ns.rdfs.label) { try { const propertyPath = isGraphPointer(labelPath) ? toSparql(labelPath) diff --git a/apps/www/src/queries/dimensions.js b/apps/www/src/queries/dimensions.js index b289feb..124385e 100644 --- a/apps/www/src/queries/dimensions.js +++ b/apps/www/src/queries/dimensions.js @@ -1,5 +1,5 @@ import { SELECT } from '@tpluscode/sparql-builder' -import { schema, sh } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' import { VALUES } from '@tpluscode/sparql-builder/expressions' import * as ns from '@view-builder/core/ns.js' @@ -13,9 +13,9 @@ import * as ns from '@view-builder/core/ns.js' export function findMeasureDimensions(cube, client) { return SELECT.DISTINCT`?dimension ?label` .WHERE` - ${cube} ${ns.cube.observationConstraint}/${sh.property}/${sh.path} ?dimension . + ${cube} ${ns.cube.observationConstraint}/${$rdf.ns.sh.property}/${$rdf.ns.sh.path} ?dimension . - optional { ?dimension ${schema.name} ?label . } + optional { ?dimension ${$rdf.ns.schema.name} ?label . } ?dimension a ${ns.cube.MeasureDimension} `.execute(client.query) @@ -36,9 +36,9 @@ export function findKeyDimensions(cubes, client) { .WHERE` ${VALUES(...cubeValues)} - ?cube ${ns.cube.observationConstraint}/${sh.property}/${sh.path} ?dimension . + ?cube ${ns.cube.observationConstraint}/${$rdf.ns.sh.property}/${$rdf.ns.sh.path} ?dimension . - optional { ?dimension ${schema.name} ?label . } + optional { ?dimension ${$rdf.ns.schema.name} ?label . } ?dimension a ${ns.cube.KeyDimension} `.execute(client.query) diff --git a/apps/www/src/queries/index.js b/apps/www/src/queries/index.js index 4981fba..de94f7b 100644 --- a/apps/www/src/queries/index.js +++ b/apps/www/src/queries/index.js @@ -1,12 +1,12 @@ -import { hydra } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' export function getSparqlUrl({ query, template, client }) { const url = new URL(client.query.endpoint.endpointUrl) url.searchParams.append('query', query) return template - .out(hydra.mapping) - .out(hydra.variable) + .out($rdf.ns.hydra.mapping) + .out($rdf.ns.hydra.variable) .toArray() .reduce((encoded, { value }) => encoded.replace(new RegExp(`%7B${value}%7D`, 'g'), `{${value}}`), url.toString()) } diff --git a/apps/www/src/state/app/effects.js b/apps/www/src/state/app/effects.js index a48ad25..441b53e 100644 --- a/apps/www/src/state/app/effects.js +++ b/apps/www/src/state/app/effects.js @@ -1,5 +1,4 @@ -import { rdf } from '@tpluscode/rdf-ns-builders' -import TermSet from '@rdfjs/term-set' +import $rdf from '@view-builder/core/env.js' import url from 'url-state' import * as ns from '@view-builder/core/ns.js' import { viewBuilder } from '@view-builder/core/ns.js' @@ -49,7 +48,7 @@ export default function effects(store) { dispatch.app.setSparqlEndpoint(endpoint) const client = store.getState().app.sparqlClient - const types = new TermSet(pointer.out(rdf.type).terms) + const types = $rdf.termSet(pointer.out($rdf.ns.rdf.type).terms) if (types.has(ns.viewBuilder.ViewCollection)) { view = await import('../../view/viewCollection.js') } else if (types.has(ns.view.View)) { diff --git a/apps/www/src/state/app/index.js b/apps/www/src/state/app/index.js index 0161da0..3d36fa2 100644 --- a/apps/www/src/state/app/index.js +++ b/apps/www/src/state/app/index.js @@ -1,6 +1,6 @@ import { createModel } from '@captaincodeman/rdx' import ParsingClient from 'sparql-http-client/ParsingClient.js' -import { schema } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' import * as loadingView from '../../view/loading.js' import effects from './effects.js' @@ -34,11 +34,11 @@ export const app = createModel({ } const softwareComponents = api.pointer - .out(schema.application) + .out($rdf.ns.schema.application) .toArray() .map(arg => [ - arg.out(schema.name).value, - arg.out(schema.softwareVersion).value, + arg.out($rdf.ns.schema.name).value, + arg.out($rdf.ns.schema.softwareVersion).value, ]) return { diff --git a/apps/www/src/state/plugin/operationAlerts.js b/apps/www/src/state/plugin/operationAlerts.js index bfca5bd..fb5a688 100644 --- a/apps/www/src/state/plugin/operationAlerts.js +++ b/apps/www/src/state/plugin/operationAlerts.js @@ -1,4 +1,4 @@ -import { rdfs } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' import { html } from 'lit' import { hex } from '@hydrofoil/vocabularies/builders' @@ -19,7 +19,7 @@ export const operationAlerts = { const { pointer } = error dispatch.notifications.show({ content: html` - ${pointer.out(rdfs.label).value}
    + ${pointer.out($rdf.ns.rdfs.label).value}
    See details `, variant: 'danger', diff --git a/apps/www/src/state/plugin/view.js b/apps/www/src/state/plugin/view.js index 0e61ae5..06fd3fb 100644 --- a/apps/www/src/state/plugin/view.js +++ b/apps/www/src/state/plugin/view.js @@ -1,4 +1,3 @@ -import { rdf } from '@tpluscode/rdf-ns-builders' import { turtle } from '@tpluscode/rdf-string' import $rdf from '@view-builder/core/env.js' import * as ns from '@view-builder/core/ns.js' @@ -137,7 +136,7 @@ export const viewForm = { window.open(cubeViewerUrl, 'cubeViewer') }), 'core/setContentResource': ({ pointer }) => { - if (pointer.has(rdf.type, ns.view.View).term) { + if (pointer.has($rdf.ns.rdf.type, ns.view.View).term) { dispatch.viewForm.populateForm(pointer.term) } else { dispatch.viewForm.clearView() diff --git a/apps/www/src/state/plugin/viewCollection.js b/apps/www/src/state/plugin/viewCollection.js index 00be12a..71b4962 100644 --- a/apps/www/src/state/plugin/viewCollection.js +++ b/apps/www/src/state/plugin/viewCollection.js @@ -1,4 +1,4 @@ -import { hydra, schema } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' import * as ns from '@view-builder/core/ns.js' import { nanoid } from 'nanoid' @@ -33,7 +33,7 @@ export const viewCollection = { if (!newViewShape) { const operation = collection.findOperations({ - bySupportedOperation: schema.CreateAction, + bySupportedOperation: $rdf.ns.schema.CreateAction, }).shift() const promise = operation.expects.shift().load() @@ -69,14 +69,14 @@ export const viewCollection = { const viewResource = collection.member.find(member => member.id.equals(deleted)) const operation = viewResource.findOperations({ - bySupportedOperation: schema.DeleteAction, + bySupportedOperation: $rdf.ns.schema.DeleteAction, }).shift() const task = nanoid() dispatch.notifications.addTask(task) await operation.invoke() - pointer.deleteOut(hydra.member, deleted) + pointer.deleteOut($rdf.ns.hydra.member, deleted) dispatch.viewCollection.setPointer(pointer) dispatch.notifications.deleteTask(task) diff --git a/apps/www/src/state/plugin/viewForm/toggleButtons.js b/apps/www/src/state/plugin/viewForm/toggleButtons.js index bec960b..1c9d0ff 100644 --- a/apps/www/src/state/plugin/viewForm/toggleButtons.js +++ b/apps/www/src/state/plugin/viewForm/toggleButtons.js @@ -3,9 +3,9 @@ import viewValidationShapeQuads from '@view-builder/core/shape/ViewValidationSha import { prepareViewPointer } from '@view-builder/view-util' import $rdf from '@zazuko/env' -const GenerateDimensionsShapes = $rdf.dataset(generateDimensionsShapeQuads($rdf)) +const GenerateDimensionsShapes = $rdf.dataset(generateDimensionsShapeQuads({ factory: $rdf })) -const ViewValidationShapes = $rdf.dataset(viewValidationShapeQuads($rdf)) +const ViewValidationShapes = $rdf.dataset(viewValidationShapeQuads({ factory: $rdf })) export default function (store) { const dispatch = store.getDispatch().viewForm diff --git a/apps/www/src/state/plugins.js b/apps/www/src/state/plugins.js index 6c23946..e7f52e2 100644 --- a/apps/www/src/state/plugins.js +++ b/apps/www/src/state/plugins.js @@ -1,6 +1,5 @@ import * as shell from '@hydrofoil/shell' -import $rdf from '@rdfjs/data-model' -import { hydra } from '@tpluscode/rdf-ns-builders' +import $rdf from '@view-builder/core/env.js' export { viewForm } from './plugin/view.js' export { viewCollection } from './plugin/viewCollection.js' @@ -27,7 +26,7 @@ export const entrypointInit = { representations.get($rdf.namedNode(resource)) const newEntrypoint = representation - ?.root?.apiDocumentation?.getArray(hydra.entrypoint) + ?.root?.apiDocumentation?.getArray($rdf.ns.hydra.entrypoint) .shift() if (newEntrypoint && !newEntrypoint.equals(entrypoint)) { dispatch.core.setEntrypoint(newEntrypoint.pointer) diff --git a/apps/www/src/view/searchForm.js b/apps/www/src/view/searchForm.js index e0f9a7f..6646a96 100644 --- a/apps/www/src/view/searchForm.js +++ b/apps/www/src/view/searchForm.js @@ -1,12 +1,11 @@ import $rdf from '@view-builder/core/env.js' -import { dash, hydra, sh } from '@tpluscode/rdf-ns-builders' import { hyper_query as query } from '@hydrofoil/vocabularies/builders' import { html } from 'lit' export function searchForm(pointer) { const collection = $rdf.rdfine.hydra.Collection(pointer) const template = collection.search - const shape = template.get(dash.shape, { strict: false }) + const shape = template.get($rdf.ns.dash.shape, { strict: false }) const currentFilters = collection.get(query.templateMappings, { strict: false }) if (shape) { @@ -37,13 +36,14 @@ function doFilter(template) { } function searchHasMinLength(template, ptr) { - const { value } = ptr.out(hydra.freetextQuery) + const { value } = ptr.out($rdf.ns.hydra.freetextQuery) if (value === '') { return true } - const mapping = template.mapping.find(({ property }) => property.id.equals(hydra.freetextQuery)) - const minLength = mapping?.getNumber(sh.minLength) + const mapping = template.mapping + .find(({ property }) => property.id.equals($rdf.ns.hydra.freetextQuery)) + const minLength = mapping?.getNumber($rdf.ns.sh.minLength) return minLength && minLength <= value.length } diff --git a/apps/www/src/view/view.js b/apps/www/src/view/view.js index 22921b5..137eb82 100644 --- a/apps/www/src/view/view.js +++ b/apps/www/src/view/view.js @@ -1,9 +1,9 @@ import { html } from 'lit' -import { hydra, schema } from '@tpluscode/rdf-ns-builders' import { isBlankNode } from 'is-graph-pointer' import { code } from '@zazuko/vocabulary-extras/builders' import '../element/ssz-shacl-button.js' import '../forms/index.js' +import $rdf from '@view-builder/core/env.js' import { fetchQuery, fetchShapes } from '../fetch.js' import { getSparqlUrl } from '../queries/index.js' import * as loading from './loading.js' @@ -25,7 +25,7 @@ function content({ state, dispatch }) { } return html` -

    ${state.viewForm.pointer.out(schema.name).value || 'Unnamed view'}

    +

    ${state.viewForm.pointer.out($rdf.ns.schema.name).value || 'Unnamed view'}

    { - const iriTemplate = template.out(hydra.template) + const iriTemplate = template.out($rdf.ns.hydra.template) if (!isBlankNode(iriTemplate)) { return } @@ -74,7 +74,7 @@ async function loadShapes(client) { const sparqlUrl = getSparqlUrl({ query, template, client }) iriTemplate.deleteOut().deleteIn() - template.addOut(hydra.template, sparqlUrl) + template.addOut($rdf.ns.hydra.template, sparqlUrl) }) await Promise.all(queriesLoaded) diff --git a/apps/www/src/view/viewCollection.js b/apps/www/src/view/viewCollection.js index 1876fb9..6185041 100644 --- a/apps/www/src/view/viewCollection.js +++ b/apps/www/src/view/viewCollection.js @@ -1,10 +1,10 @@ import { html } from 'lit' -import { hydra, schema } from '@tpluscode/rdf-ns-builders' import '@shoelace-style/shoelace/dist/components/button/button.js' import '../element/ssz-view-table.js' import '../forms/index.js' import { viewBuilder } from '@view-builder/core/ns.js' import { fromRdf } from 'rdf-literal' +import $rdf from '@view-builder/core/env.js' import { searchForm } from './searchForm.js' export async function init() { @@ -37,11 +37,11 @@ function menu({ dispatch }) { function table({ state, dispatch }) { const views = state.viewCollection.pointer - ?.out(hydra.member) + ?.out($rdf.ns.hydra.member) .toArray() .sort((l, r) => { - const leftId = l.out(schema.alternateName).value || '' - const rightId = r.out(schema.alternateName).value || '' + const leftId = l.out($rdf.ns.schema.alternateName).value || '' + const rightId = r.out($rdf.ns.schema.alternateName).value || '' return leftId.localeCompare(rightId) }) || [] @@ -66,7 +66,7 @@ function publishForm({ state, dispatch }) { const datePublished = state.viewCollection.pointer .out(viewBuilder.publish) - .out(schema.datePublished) + .out($rdf.ns.schema.datePublished) .term function submit(e) { diff --git a/apps/www/test/automation.test.js b/apps/www/test/automation.test.js index ba1cfc2..9d20c56 100644 --- a/apps/www/test/automation.test.js +++ b/apps/www/test/automation.test.js @@ -1,7 +1,6 @@ import { expect } from 'chai' import sinon from 'sinon' import $rdf from '@zazuko/env' -import { rdfs, rdf } from '@tpluscode/rdf-ns-builders' import { viewBuilder, view } from '@view-builder/core/ns.js' import { ex, testData } from '@view-builder/testing' import { generateDimensions } from '../src/automation.js' @@ -40,7 +39,7 @@ describe('automation.js', () => { expect(dimensions.out(view.from).out(view.path).term).to.deep.eq(ex.Kennzahl) expect(dimensions.out(view.from).out(view.source).term) .to.deep.eq(before.out(viewBuilder.source).term) - expect(dimensions.out(rdfs.label).value).to.contain('KENNZAHL') + expect(dimensions.out($rdf.ns.rdfs.label).value).to.contain('KENNZAHL') }) it('generates a view dimension for key dimensions', async () => { @@ -125,12 +124,12 @@ describe('automation.js', () => { const after = await generateDimensions(before, { queries }) // then - const dimensions = after.any().has(rdf.type, view.Dimension) + const dimensions = after.any().has($rdf.ns.rdf.type, view.Dimension) expect(dimensions.terms).to.have.length(1) expect(dimensions.out(view.from).out(view.path).term).to.deep.eq(ex.Kennzahl) expect(dimensions.out(view.from).out(view.source).term) .to.deep.eq(before.out(viewBuilder.source).term) - expect(dimensions.out(rdfs.label).value).to.contain('KENNZAHL') + expect(dimensions.out($rdf.ns.rdfs.label).value).to.contain('KENNZAHL') }) }) }) diff --git a/apps/www/test/forms/dynamicXone.test.js b/apps/www/test/forms/dynamicXone.test.js index a0a3bf6..b2e8a39 100644 --- a/apps/www/test/forms/dynamicXone.test.js +++ b/apps/www/test/forms/dynamicXone.test.js @@ -1,7 +1,6 @@ import sinon from 'sinon' import { expect } from 'chai' import $rdf from '@view-builder/core/env.js' -import { owl, sh } from '@tpluscode/rdf-ns-builders' import sh1 from '@hydrofoil/shaperone-core/ns.js' import { ex, testData } from '@view-builder/testing' import dynamicXone from '../../src/forms/dynamicXone.js' @@ -25,17 +24,17 @@ describe('forms/dynamicXone.js', () => { ${sh1.discriminatorValue} "FOO" ; - ${sh.property} . + ${$rdf.ns.sh.property} . ${sh1.discriminatorValue} "BAR" ; - ${sh.property} . + ${$rdf.ns.sh.property} . ${sh1.discriminatorValue} [ - ${owl.differentFrom} "FOO", "BAR" ; + ${$rdf.ns.owl.differentFrom} "FOO", "BAR" ; ] ; - ${sh.property} . + ${$rdf.ns.sh.property} . ` xone = [{ shapes: shape.any().has(sh1.discriminatorValue).map($rdf.rdfine.sh.PropertyShape), diff --git a/packages/testing/index.js b/packages/testing/index.js index ae0f923..c59a8b4 100644 --- a/packages/testing/index.js +++ b/packages/testing/index.js @@ -1,17 +1,15 @@ import { turtle } from '@tpluscode/rdf-string' -import namespace from '@rdfjs/namespace' -import $rdf from 'rdf-ext' +import $rdf from '@zazuko/env' import toStream from 'string-to-stream' -import clownface from 'clownface' import { StreamParser } from 'n3' -export const ex = namespace('http://example.com/') -export const ssz = namespace('https://ld.stadt-zuerich.ch/statistics/') +export const ex = $rdf.namespace('http://example.com/') +export const ssz = $rdf.namespace('https://ld.stadt-zuerich.ch/statistics/') export async function testData(strings, ...values) { const turtleStream = toStream(turtle(strings, ...values).toString()) const quadStream = turtleStream.pipe(new StreamParser()) const dataset = await $rdf.dataset().import(quadStream) - return clownface({ dataset }).namedNode('') + return $rdf.clownface({ dataset }).namedNode('') } diff --git a/packages/testing/package.json b/packages/testing/package.json index aec18df..798f877 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -4,11 +4,9 @@ "type": "module", "main": "index.js", "dependencies": { - "@rdfjs/namespace": "^2.0.0", - "@tpluscode/rdf-string": "^0.2.26", - "clownface": "^1.5.1", + "@tpluscode/rdf-string": "^1.1.3", + "@zazuko/env": "^2", "n3": "^1.16.2", - "rdf-ext": "^2.0.1", "sinon": "^14.0.1", "sparql-http-client": "^2.4.1", "string-to-stream": "^3.0.1" diff --git a/yarn.lock b/yarn.lock index a23c5f4..2c7b692 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2835,16 +2835,15 @@ duplex-to "^2.0.0" readable-stream "^4.2.0" -"@rdfjs/serializer-rdfjs@^0.0.4": - version "0.0.4" - resolved "https://registry.yarnpkg.com/@rdfjs/serializer-rdfjs/-/serializer-rdfjs-0.0.4.tgz#cfe90a3351f934ce91f887e014d4976973618fe9" - integrity sha512-JcAfP5J9UWfd7zOLtMNO8ZZfJ4ox2umCN6fVGa7YKT3tqkYShIESmwOD2UUx/ISTUtO06gn+GQe/pnQP2AAjkg== +"@rdfjs/serializer-rdfjs@^0.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@rdfjs/serializer-rdfjs/-/serializer-rdfjs-0.1.1.tgz#7cd82dba18385211dbce65509aba9003f9f1bf79" + integrity sha512-1B8rDyzoYuKWreAMWkZmO6jYUc5qPxZJqKoRT2v6xeQxwILdCTq7FjWJq4IELhEbKecSgeFWqG5AaCYfn0CBmA== dependencies: - "@rdfjs/sink" "^1.0.3" - "@zazuko/rdf-vocabularies" latest - get-stream "^5.1.0" - readable-stream "^3.6.0" - safe-identifier "^0.4.1" + "@rdfjs/sink" "^2.0.0" + js-string-escape "^1.0.1" + readable-stream "^4.3.0" + stream-chunks "^1.0.0" "@rdfjs/serializer-turtle@^1.1.1": version "1.1.2" @@ -2927,7 +2926,7 @@ resolved "https://registry.yarnpkg.com/@rdfjs/to-ntriples/-/to-ntriples-2.0.0.tgz#ad70822e2ddf068fd1291b505e5c678c17af7a30" integrity sha512-nDhpfhx6W6HKsy4HjyLp3H1nbrX1CiUCWhWQwKcYZX1s9GOjcoQTwY7GUUbVec0hzdJDQBR6gnjxtENBDt482Q== -"@rdfjs/traverser@^0.1.0", "@rdfjs/traverser@^0.1.1", "@rdfjs/traverser@^0.1.2": +"@rdfjs/traverser@^0.1.1", "@rdfjs/traverser@^0.1.2": version "0.1.2" resolved "https://registry.yarnpkg.com/@rdfjs/traverser/-/traverser-0.1.2.tgz#19dfafbbdc37c04f1bd220319d2500af9f423551" integrity sha512-EBB/p9LrTMzupZ6VlxtBXyL0bdXFY7e5lAp2tHNwxOoe3kcR6hOJFVWdPT7pdWaSotyXbTIEQxG4PkXMw/OY7w== @@ -3115,7 +3114,7 @@ "@tpluscode/rdf-ns-builders" "^2" "@zazuko/rdf-vocabularies" "*" -"@tpluscode/rdf-string@^1.0.1", "@tpluscode/rdf-string@^1.0.3": +"@tpluscode/rdf-string@^1.0.1", "@tpluscode/rdf-string@^1.0.3", "@tpluscode/rdf-string@^1.1.3": version "1.1.3" resolved "https://registry.yarnpkg.com/@tpluscode/rdf-string/-/rdf-string-1.1.3.tgz#01d08ebec1c3bbfe9c2143640285e8042338ccba" integrity sha512-1jeS3jrcILQYNtjU6kYQ2wufdCgnDKrsVxcmszDh/RLRxqmrVDNnVdqErg3N2Gg5OR7n2vzC91M5XfNdPSsXAg== @@ -4045,7 +4044,7 @@ clownface "^2.0.1" rdf-dataset-ext "^1.1.0" -"@zazuko/env@^2.0.2", "@zazuko/env@^2.0.3": +"@zazuko/env@^2", "@zazuko/env@^2.0.2", "@zazuko/env@^2.0.3": version "2.0.3" resolved "https://registry.yarnpkg.com/@zazuko/env/-/env-2.0.3.tgz#d70afeaa6edf1ecea29eec2fecb62ef08d1d8f56" integrity sha512-KltMKz2WQs02gsDM5kJi1qI6ejejKjk1p7/tsNNaZM4Opd/5uxyDjsObt6WVbLsLrW2I7xNu31fdXzqfhpuRuA== @@ -4087,7 +4086,7 @@ dependencies: readable-stream ">=3.6.0" -"@zazuko/rdf-vocabularies@*", "@zazuko/rdf-vocabularies@>=2022.11.25", "@zazuko/rdf-vocabularies@latest": +"@zazuko/rdf-vocabularies@*", "@zazuko/rdf-vocabularies@>=2022.11.25": version "2022.11.28" resolved "https://registry.yarnpkg.com/@zazuko/rdf-vocabularies/-/rdf-vocabularies-2022.11.28.tgz#fa2adc7cffffac4673339805c871b7b1f6f8cadf" integrity sha512-fg3GwDMI2ooS6VA2C23hFy5BrY5WO4lwjwa0/jYLYUpEHorTk430X0MvKQcfEgyz6U4NO8QDS8jz1CGvC4YLAw== @@ -9006,6 +9005,11 @@ js-levenshtein-esm@^1.2.0: resolved "https://registry.yarnpkg.com/js-levenshtein-esm/-/js-levenshtein-esm-1.2.0.tgz#96532c34e0c90df198c9419963c64ca3cf43ae92" integrity sha512-fzreKVq1eD7eGcQr7MtRpQH94f8gIfhdrc7yeih38xh684TNMK9v5aAu2wxfIRMk/GpAJRrzcirMAPIaSDaByQ== +js-string-escape@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef" + integrity sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg== + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" @@ -11304,7 +11308,7 @@ rdf-ext@^1.3.0, rdf-ext@^1.3.1, rdf-ext@^1.3.5: rdf-normalize "^1.0.0" readable-stream "^3.6.0" -rdf-ext@^2.0.1, rdf-ext@^2.1.0, rdf-ext@^2.2.0: +rdf-ext@^2.1.0, rdf-ext@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/rdf-ext/-/rdf-ext-2.3.0.tgz#9161abb5695f28bc05dec075f26015bb6fa44407" integrity sha512-/2bPbKidKNBItZA/iYgQXMZncK2T9zCHkH+yFMCaRfOay0qmqo7yN7t+VIGObXimQ66EYNRQANo/EMXIPEz9eA== @@ -12007,11 +12011,6 @@ safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -safe-identifier@^0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/safe-identifier/-/safe-identifier-0.4.2.tgz#cf6bfca31c2897c588092d1750d30ef501d59fcb" - integrity sha512-6pNbSMW6OhAi9j+N8V+U715yBQsaWJ7eyEUaOrawX+isg5ZxhUlV1NipNtgaKHmFGiABwt+ZF04Ii+3Xjkg+8w== - safe-regex-test@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" @@ -13738,13 +13737,13 @@ webpack-dev-server@^3.11.2: ws "^6.2.1" yargs "^13.3.2" -webpack-loader-rdf@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/webpack-loader-rdf/-/webpack-loader-rdf-0.1.1.tgz#de83f0439a5113416a9189475c999d2c403b2859" - integrity sha512-hYrDKBUTzdz1hJkjRXon/AM9NoOAt8w27Cfu74wtTqMrY/8LxT45Id8Px/9zNJX6qH6e635KEMF0vPcKtxG9ew== +webpack-loader-rdf@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/webpack-loader-rdf/-/webpack-loader-rdf-0.2.0.tgz#cfe6dea5bc5df5e54eff555c50f206941bf204f5" + integrity sha512-o35jDpohUR+6eR1j2ul9AI5fNPwIjIakEaT74yWELGnWNFl5inGQg7U1iNojndLmMYTdN+bumicPUQGP5niTVQ== dependencies: "@rdfjs/formats-common" "^2.2.0" - "@rdfjs/serializer-rdfjs" "^0.0.4" + "@rdfjs/serializer-rdfjs" "^0.1" rdf-utils-fs "^2.2.0" string-to-stream "^3.0.1"