Skip to content

Commit

Permalink
Merge pull request #154 from zazuko/zazuko-env-2
Browse files Browse the repository at this point in the history
build(deps): use latest zazuko env
  • Loading branch information
tpluscode authored Jan 19, 2024
2 parents ce7f510 + fed992f commit 32d8702
Show file tree
Hide file tree
Showing 24 changed files with 397 additions and 364 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-lies-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rdfjs-elements/formats-pretty': patch
---

Support `@rdfjs/environment` v1
5 changes: 5 additions & 0 deletions .changeset/heavy-wolves-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rdfjs-elements/rdf-editor': patch
---

Update to `@rdfjs/environment` v1
5 changes: 5 additions & 0 deletions .changeset/spotty-crabs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rdfjs-elements/lit-helpers': patch
---

Update clownface
13 changes: 3 additions & 10 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@ jobs:

- uses: nelonoel/[email protected]

- run: npm i -g netlify-cli

- name: Publish preview
uses: jsmrcaga/[email protected]
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_DEPLOY_MESSAGE: Preview ${{ env.BRANCH_NAME }}
build_directory: dist
deploy_alias: ${{ env.BRANCH_NAME }}
NETLIFY_DEPLOY_TO_PROD: false
build_command: echo ""
monorepo_package: rdfjs-elements-demo
run: netlify deploy --dir dist -a ${{ secrets.NETLIFY_AUTH_TOKEN }} -s ${{ secrets.NETLIFY_SITE_ID }} --filter rdfjs-elements-demos -m "Preview ${{ env.BRANCH_NAME }}" --alias ${{ env.BRANCH_NAME }}

- name: Status check
uses: Sibz/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
"format": "npm run format:eslint && npm run format:prettier",
"release": "changeset publish",
"postinstall": "yarn-deduplicate",
"prepare": "husky install; wsrun -m patch-package"
"prepare": "husky install; patch-package"
},
"devDependencies": {
"@changesets/cli": "^2.24.0",
"@custom-elements-manifest/analyzer": "^0.6.3",
"@open-wc/building-webpack": "^2.13.46",
"@open-wc/eslint-config": "^7.0.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@web/dev-server-esbuild": "^0.4.1",
"@web/dev-server-rollup": "^0.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/formats/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Stream, Sink } from '@rdfjs/types'
import { EventEmitter } from 'events';
import type { Environment } from '@rdfjs/environment/Environment.js';
import type Formats from '@rdfjs/environment/lib/Formats.js';
import type { Formats } from '@rdfjs/formats';

export const mediaTypes: {
jsonLd: 'application/ld+json',
Expand Down
2 changes: 1 addition & 1 deletion packages/formats/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import formatsCommon from '@zazuko/formats-lazy'
import Formats from '@rdfjs/environment/lib/Formats.js'
import Formats from '@rdfjs/formats/lib/Formats.js'
import {
TurtleSerializer,
RdfXmlSerializer,
Expand Down
18 changes: 10 additions & 8 deletions packages/formats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"main": "index.js",
"module": "index.js",
"type": "module",
"scripts": {
"patch-package": "patch-package"
},
"files": [
"*.js",
"*.d.ts",
Expand All @@ -33,7 +30,8 @@
"@graphy/content.trig.write": "^4.3.7",
"@graphy/core.data.factory": "^4.3.7",
"@rdfjs/serializer-jsonld-ext": "^4.0.0",
"@rdfjs/environment": "^0.1.2",
"@rdfjs/environment": "0 - 1",
"@rdfjs/formats": "^4.0.0",
"@rdfjs/term-map": "^2.0.0",
"@tpluscode/rdf-ns-builders": ">=3.0.2",
"@zazuko/formats-lazy": "^1.0.1",
Expand All @@ -42,15 +40,19 @@
},
"devDependencies": {
"@rdfjs/namespace": "^2.0.0",
"@types/rdfjs__environment": "^0.1.9",
"@types/rdfjs__environment": "^1",
"@types/rdfjs__fetch-lite": "^3",
"@types/rdfjs__formats": "^4",
"@types/rdfjs__term-map": "^2",
"@types/rdfjs__term-set": "^2",
"@zazuko/env-node": "^2.1.1",
"@zazuko/prefixes": "^2.0.0",
"@zazuko/rdf-utils-fs": "^3.3.1",
"chai": "^4.3.4",
"clownface": "^1.2.0",
"clownface": "^2.0.2",
"get-stream": "^6.0.1",
"mocha": "^10.0.0",
"mocha-chai-jest-snapshot": "^1.1.4",
"rdf-ext": "^2.2.0",
"rdf-utils-fs": "^2.2.0",
"string-to-stream": "^3.0.1"
},
"publishConfig": {
Expand Down
5 changes: 2 additions & 3 deletions packages/formats/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import toStream from 'string-to-stream'
import clownface from 'clownface'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env-node'
import { expect } from 'chai'
import * as ns from '@tpluscode/rdf-ns-builders'
import getStream from 'get-stream'
import rdfUtil from 'rdf-utils-fs'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
import formats, { mediaTypes } from '../index.js'
Expand Down Expand Up @@ -71,7 +70,7 @@ describe('@rdfjs-elements/formats-pretty', () => {
// given
const graph = await $rdf
.dataset()
.import(rdfUtil.fromFile(join(__dirname, `graphs/${file}`)))
.import($rdf.fromFile(join(__dirname, `graphs/${file}`)))

// when
const serialized = await getStream(
Expand Down
54 changes: 35 additions & 19 deletions packages/formats/test/serializers/TransformToConsiseHash.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from 'chai'
import $rdf from 'rdf-ext'
import clownface from 'clownface'
import $rdf from '@zazuko/env-node'
import { rdf, schema, xsd, rdfs } from '@tpluscode/rdf-ns-builders'
import namespace from '@rdfjs/namespace'
import { TransformToConciseHash } from '../../serializers/TransformToConciseHash.js'
Expand All @@ -26,7 +25,8 @@ function transform(
describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', () => {
it('creates hash for default graph', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.john)
.addOut(rdf.type, schema.Person)

Expand All @@ -48,7 +48,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('creates hash for named graph', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset(), graph: ex.john })
const graph = $rdf
.clownface({ dataset: $rdf.dataset(), graph: ex.john })
.namedNode(ex.john)
.addOut(rdf.type, schema.Person)

Expand All @@ -70,7 +71,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('abbreviates terms in known namespaces', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset(), graph: ex.john })
const graph = $rdf
.clownface({ dataset: $rdf.dataset(), graph: ex.john })
.namedNode(ex.john)
.addOut(rdf.type, schema.Person)

Expand All @@ -95,7 +97,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('handles various literals', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset(), graph: ex.john })
const graph = $rdf
.clownface({ dataset: $rdf.dataset(), graph: ex.john })
.namedNode(ex.john)
.addOut(schema.name, 'John')
.addOut(schema.title, $rdf.literal('Phd', 'en'))
Expand Down Expand Up @@ -142,7 +145,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()
describe('strict mode', () => {
it('does not inline blank nodes', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset(), graph: ex.john })
const graph = $rdf
.clownface({ dataset: $rdf.dataset(), graph: ex.john })
.namedNode(ex.john)
.addOut(ex.foo, $rdf.blankNode('foo'), foo => {
foo.addOut(ex.bar, $rdf.blankNode('bar'), bar => {
Expand Down Expand Up @@ -180,7 +184,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('does not inline RDF Lists', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.hasList)
.addList(ex.list, ['A', 'B'])

Expand All @@ -203,7 +208,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('returns c4r event', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.john)
.addOut(rdf.type, schema.Person)

Expand All @@ -224,7 +230,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('inlines blank nodes', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset(), graph: ex.john })
const graph = $rdf
.clownface({ dataset: $rdf.dataset(), graph: ex.john })
.namedNode(ex.john)
.addOut(ex.foo, foo => {
foo.addOut(ex.bar, bar => {
Expand Down Expand Up @@ -260,7 +267,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('does not inline blank nodes if they are used twice', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.count)
.addOut(ex.one, $rdf.blankNode('mississippi'))
.addOut(ex.two, $rdf.blankNode('mississippi'))
Expand Down Expand Up @@ -294,7 +302,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('inlines RDF List', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.hasList)
.addList(ex.list, ['A', 'B', 'C'])

Expand All @@ -319,7 +328,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('inlines RDF List with blank nodes inlined', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.hasList)
.addList(ex.list, [
$rdf.blankNode('foo'),
Expand Down Expand Up @@ -366,7 +376,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('inlines RDF List with reused blank nodes', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.hasList)
.addList(ex.list, [
$rdf.blankNode('foo'),
Expand Down Expand Up @@ -402,7 +413,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('handles RDF lists shared by multiple subjects', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.foo)
.addList(ex.list, ['foo', 'bar', 'baz'])
graph.namedNode(ex.bar).addOut(ex.list, graph.out(ex.list))
Expand Down Expand Up @@ -440,7 +452,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('handles single-element RDF lists shared by multiple subjects', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.foo)
.addList(ex.list, ['a'])
graph.namedNode(ex.bar).addOut(ex.list, graph.out(ex.list))
Expand Down Expand Up @@ -478,7 +491,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('handles two-element RDF lists shared by multiple subjects', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.foo)
.addList(ex.list, ['foo', 'bar'])
graph.namedNode(ex.bar).addOut(ex.list, graph.out(ex.list))
Expand Down Expand Up @@ -516,7 +530,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('removes explicit rdf:type rdf:List', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.foo)
.addList(ex.list, ['a', 'b', 'c'])
graph.any().has(rdf.first).addOut(rdf.type, rdf.List)
Expand All @@ -542,7 +557,8 @@ describe('@rdfjs-elements/formats-pretty/serializers/TransformToConciseHash', ()

it('does not remove other properties from RDF List nodes', async () => {
// given
const graph = clownface({ dataset: $rdf.dataset() })
const graph = $rdf
.clownface({ dataset: $rdf.dataset() })
.namedNode(ex.foo)
.addList(ex.list, ['a', 'b'])
graph
Expand Down
18 changes: 11 additions & 7 deletions packages/formats/test/serializers/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import chai, { expect } from 'chai'
import { jestSnapshotPlugin } from 'mocha-chai-jest-snapshot'
import prefixes from '@zazuko/prefixes'
import * as ns from '@tpluscode/rdf-ns-builders'
import $rdf from 'rdf-ext'
import $rdf from '@zazuko/env-node'
import clownface from 'clownface'
import getStream from 'get-stream'
import rdfUtil from 'rdf-utils-fs'
import { fromFile } from '@zazuko/rdf-utils-fs'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
import JsonldSerializer from '../../serializers/jsonld.js'
Expand Down Expand Up @@ -44,7 +44,8 @@ describe('@rdfjs-elements/formats-pretty/serializers', () => {
it('removes excess rdf List node properties by default', async () => {
// given
const { owl, as } = prefixes
const graph = rdfUtil.fromFile(
const graph = fromFile(
$rdf,
join(__dirname, `../graphs/list-with-extras.ttl`)
)
const sink = new TurtleSerializer({
Expand All @@ -61,7 +62,8 @@ describe('@rdfjs-elements/formats-pretty/serializers', () => {
it('does not remove excess rdf List node properties when option set', async () => {
// given
const { owl, as, rdf, rdfs } = prefixes
const graph = rdfUtil.fromFile(
const graph = fromFile(
$rdf,
join(__dirname, `../graphs/list-with-extras.ttl`)
)
const sink = new TurtleSerializer({
Expand All @@ -85,7 +87,7 @@ describe('@rdfjs-elements/formats-pretty/serializers', () => {
it('serializes successfully a complex graph with reused nodes', async () => {
// given
const { owl, as, rdf, rdfs } = prefixes
const graph = rdfUtil.fromFile(join(__dirname, `../graphs/view.ttl`))
const graph = fromFile($rdf, join(__dirname, `../graphs/view.ttl`))
const sink = new TurtleSerializer({
prefixes: { owl, as, rdf, rdfs },
})
Expand All @@ -99,7 +101,8 @@ describe('@rdfjs-elements/formats-pretty/serializers', () => {

it('preserves line breaks in literals', async () => {
// given
const graph = rdfUtil.fromFile(
const graph = fromFile(
$rdf,
join(__dirname, `../graphs/multiline-literals.ttl`)
)
const sink = new TurtleSerializer()
Expand All @@ -113,7 +116,8 @@ describe('@rdfjs-elements/formats-pretty/serializers', () => {

it('preserves line breaks in literals when using prefixes', async () => {
// given
const graph = rdfUtil.fromFile(
const graph = fromFile(
$rdf,
join(__dirname, `../graphs/multiline-literals.ttl`)
)
const sink = new TurtleSerializer({
Expand Down
8 changes: 6 additions & 2 deletions packages/lit-helpers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ setLanguages('de-CH', 'de')
import { html } from 'lit'
import { localizedLabel } from '@rdfjs-elements/lit-helpers/localizedLabel.js'
import type { GraphPointer } from 'clownface'
import { fromPointer } from '@rdfine/shacl/lib/NodeShape'
import Environment from '@zazuko/env/Environment.js'
import RdfineEnv from '@rdfine/env'
import Shacl from '@rdfine/shacl/Factory'

const env = new Environment([Shacl], { parent: RdfineEnv })

let fruitPointer: GraphPointer
const fruit = fromPointer(fruitPointer)
const fruit = env.rdfine.sh.NodeShape(fruitPointer)

function render() {
// renders PropertyShape's sh:name property
Expand Down
Loading

0 comments on commit 32d8702

Please sign in to comment.