Skip to content

Commit

Permalink
Bump to Comunica v4 prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 11, 2024
1 parent 14e71f8 commit c235c37
Show file tree
Hide file tree
Showing 9 changed files with 1,823 additions and 1,842 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ jobs:
key: ${{ runner.os }}-lint-modules-${{ hashFiles('**/yarn.lock') }}
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 18.x
- run: yarn install
- run: yarn run lint

test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
os:
- macos-latest
- ubuntu-latest
- windows-latest
node-version:
- 14.x
- 16.x
- 18.x
- 20.x
- 22.x
Expand Down Expand Up @@ -62,3 +63,17 @@ jobs:
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

webpack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-webpack-modules-${{ hashFiles('**/yarn.lock') }}
- uses: actions/setup-node@v3
with:
node-version: 18.x
- run: yarn install
- run: yarn run browser
44 changes: 28 additions & 16 deletions config/config-browser.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/config-query-sparql/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/config-query-sparql/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/rdf-dereference/^3.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-http/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-fallback/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-http/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/mediator-number/^4.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-rdf-parse/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-http/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-fallback/^4.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-fetch/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-proxy/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-rdf-parse/^4.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-n3/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-jsonld/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-rdfxml/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-xml-rdfa/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-shaclc/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-fetch/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-http-proxy/^4.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-microdata/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-rdfa/^2.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^2.0.0/components/context.jsonld"
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-n3/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-jsonld/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-rdfxml/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-xml-rdfa/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-shaclc/^4.0.0/components/context.jsonld",

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-microdata/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-rdfa/^4.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^4.0.0/components/context.jsonld"
],
"import": [
"ccqs:config/dereference/mediators.json",
"ccqs:config/dereference-rdf/mediators.json",
"ccqs:config/http/mediators.json",
"ccqs:config/rdf-parse/mediators.json"
],
"@graph": [
{
"@id": "urn:comunica:default:http/mediators#main",
"@type": "MediatorNumber",
"type": "min",
"field": "time",
"ignoreFailures": true,
"bus": { "@id": "ActorHttp:_default_bus" }
}
],
"@id": "urn:comunica:default:Runner",
"@type": "RdfDereferencer",
"mediatorDereferenceRdf": { "@id": "urn:comunica:default:dereference-rdf/mediators#main" },
Expand Down
3 changes: 1 addition & 2 deletions config/config-default.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/rdf-dereference/^3.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-file/^2.0.0/components/context.jsonld"

"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-file/^4.0.0/components/context.jsonld"
],
"import": [
"rd:config/config-browser.json"
Expand Down
6 changes: 4 additions & 2 deletions lib/RdfDereferencerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {IActorDereferenceRdfOutput} from "@comunica/bus-dereference-rdf";
import { ActionContext, Actor } from "@comunica/core";
import * as RDF from "@rdfjs/types";
import { MediatorDereferenceRdf } from '@comunica/bus-dereference-rdf';
import { KeysHttp } from '@comunica/context-entries';
import { KeysHttp, KeysInitQuery } from '@comunica/context-entries';
import { DataFactory } from 'rdf-data-factory';

/**
* An RdfDerefencer can dereference URLs to RDF streams, using any RDF serialization.
Expand All @@ -22,7 +23,8 @@ export class RdfDereferencerBase<Q extends RDF.BaseQuad = RDF.Quad> {
* @return {IActorRdfDereferenceOutput} The dereference output.
*/
public dereference(url: string, options: IDereferenceOptions = {}): Promise<IActorDereferenceRdfOutput> {
const context = new ActionContext(options);
const context = new ActionContext(options)
.setDefault(KeysInitQuery.dataFactory, new DataFactory());
// Delegate dereferencing to the mediator
return this.mediatorDereferenceRdf.mediate({
context: typeof options.fetch === 'function' ? context.setDefault(KeysHttp.fetch, options.fetch) : context,
Expand Down
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import {RdfDereferencerBase} from './RdfDereferencerBase';

export * from "./RdfDereferencer";
export * from "./RdfDereferencerBase";
const rdfDereferencer = <RdfDereferencerBase>require('../engine-default');
const rdfDereferencerFactory = require('../engine-default');
const rdfDereferencer = <RdfDereferencerBase>(typeof rdfDereferencerFactory === 'function' ? rdfDereferencerFactory() : undefined);
export {rdfDereferencer};
72 changes: 36 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
"test"
],
"devDependencies": {
"@comunica/runner": "^2.0.3",
"@comunica/types": "^2.8.1",
"@comunica/runner": "^4.0.1-alpha.48.0",
"@comunica/types": "^4.0.1-alpha.48.0",
"@types/jest": "^27.0.0",
"@types/n3": "^1.10.3",
"arrayify-stream": "^1.0.0",
"componentsjs-generator": "^3.0.1",
"componentsjs-generator": "^4.2.0",
"jest": "^27.0.1",
"jest-rdf": "^1.7.0",
"manual-git-changelog": "^1.0.1",
"pre-commit": "^1.2.2",
"rdf-data-factory": "^1.1.0",
"rdf-data-factory": "^1.1.2",
"rdf-quad": "^1.5.0",
"streamify-string": "^1.0.1",
"ts-jest": "^27.0.1",
Expand Down Expand Up @@ -95,42 +95,42 @@
"build:components": "componentsjs-generator",
"validate": "npm ls",
"prepare": "npm run build && comunica-compile-config config/config-default.json urn:comunica:default:Runner > engine-default.js && comunica-compile-config config/config-browser.json urn:comunica:default:Runner > engine-browser.js",
"browser": "webpack index.js -o browser.js --mode development",
"browser": "webpack --config webpack.config.js --mode development",
"version": "manual-git-changelog onversion"
},
"dependencies": {
"@comunica/actor-dereference-fallback": "^2.0.2",
"@comunica/actor-dereference-file": "^2.0.2",
"@comunica/actor-dereference-http": "^2.0.2",
"@comunica/actor-dereference-rdf-parse": "^2.6.0",
"@comunica/actor-http-fetch": "^2.0.1",
"@comunica/actor-http-proxy": "^2.0.1",
"@comunica/actor-rdf-parse-html": "^2.0.1",
"@comunica/actor-rdf-parse-html-microdata": "^2.0.1",
"@comunica/actor-rdf-parse-html-rdfa": "^2.0.1",
"@comunica/actor-rdf-parse-html-script": "^2.0.1",
"@comunica/actor-rdf-parse-jsonld": "^2.0.1",
"@comunica/actor-rdf-parse-n3": "^2.0.1",
"@comunica/actor-rdf-parse-rdfxml": "^2.0.1",
"@comunica/actor-rdf-parse-shaclc": "^2.6.0",
"@comunica/actor-rdf-parse-xml-rdfa": "^2.0.1",
"@comunica/bus-dereference": "^2.0.2",
"@comunica/bus-dereference-rdf": "^2.0.2",
"@comunica/bus-http": "^2.0.1",
"@comunica/bus-init": "^2.0.1",
"@comunica/bus-rdf-parse": "^2.0.1",
"@comunica/bus-rdf-parse-html": "^2.0.1",
"@comunica/config-query-sparql": "^2.0.1",
"@comunica/context-entries": "^2.8.1",
"@comunica/core": "^2.0.1",
"@comunica/mediator-combine-pipeline": "^2.0.1",
"@comunica/mediator-combine-union": "^2.0.1",
"@comunica/mediator-number": "^2.0.1",
"@comunica/mediator-race": "^2.0.1",
"@comunica/actor-dereference-fallback": "^4.0.1-alpha.48.0",
"@comunica/actor-dereference-file": "^4.0.1-alpha.48.0",
"@comunica/actor-dereference-http": "^4.0.1-alpha.48.0",
"@comunica/actor-dereference-rdf-parse": "^4.0.1-alpha.48.0",
"@comunica/actor-http-fetch": "^4.0.1-alpha.48.0",
"@comunica/actor-http-proxy": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-html": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-html-microdata": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-html-rdfa": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-html-script": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-jsonld": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-n3": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-rdfxml": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-shaclc": "^4.0.1-alpha.48.0",
"@comunica/actor-rdf-parse-xml-rdfa": "^4.0.1-alpha.48.0",
"@comunica/bus-dereference": "^4.0.1-alpha.48.0",
"@comunica/bus-dereference-rdf": "^4.0.1-alpha.48.0",
"@comunica/bus-http": "^4.0.1-alpha.48.0",
"@comunica/bus-init": "^4.0.1-alpha.48.0",
"@comunica/bus-rdf-parse": "^4.0.1-alpha.48.0",
"@comunica/bus-rdf-parse-html": "^4.0.1-alpha.48.0",
"@comunica/config-query-sparql": "^4.0.1-alpha.48.0",
"@comunica/context-entries": "^4.0.1-alpha.48.0",
"@comunica/core": "^4.0.1-alpha.48.0",
"@comunica/mediator-combine-pipeline": "^4.0.1-alpha.48.0",
"@comunica/mediator-combine-union": "^4.0.1-alpha.48.0",
"@comunica/mediator-number": "^4.0.1-alpha.48.0",
"@comunica/mediator-race": "^4.0.1-alpha.48.0",
"@rdfjs/types": "*",
"process": "^0.11.10",
"rdf-string": "^1.6.0",
"stream-to-string": "^1.2.0"
"rdf-data-factory": "^1.1.2",
"rdf-string": "^1.6.3",
"stream-to-string": "^1.2.1"
},
"browser": {
"./engine-default.js": "./engine-browser.js",
Expand Down
12 changes: 8 additions & 4 deletions test/RdfDereferencer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {join} from "path";
import {Readable} from "stream";
import {RdfDereferencer} from "../lib/RdfDereferencer";
import 'cross-fetch';
import { Headers } from 'cross-fetch';

import {rdfDereferencer} from "..";
import { mocked } from 'ts-jest/utils';
Expand Down Expand Up @@ -95,7 +96,7 @@ describe('dereferencer', () => {
<http://ex.org/s> <http://ex.org/p> <http://ex.org/o1>, <http://ex.org/o2>.
`);
body.push(null);
mockSetup({ statusCode: 200, body, url: 'http://example.org/bla.ttl' });
mockSetup({ statusCode: 200, body, headers: {}, url: 'http://example.org/bla.ttl' });
const out = await rdfDereferencer.dereference('http://example.org/bla.ttl');
expect(out.metadata.triples).toBeTruthy();
expect(out.url).toEqual('http://example.org/bla.ttl');
Expand Down Expand Up @@ -182,6 +183,7 @@ describe('dereferencer', () => {
agent: expect.anything(),
headers: expect.anything(),
method: 'GET',
keepalive: true,
});
expect(out.headers).toEqual(new Headers({
'content-type': 'text/turtle',
Expand All @@ -200,6 +202,7 @@ describe('dereferencer', () => {
agent: expect.anything(),
headers: expect.anything(),
method: undefined,
keepalive: true,
});
expect((<any> mocked(fetch).mock.calls[0][1].headers).get('_a')).toEqual('A');
expect((<any> mocked(fetch).mock.calls[0][1].headers).get('_b')).toEqual('B');
Expand All @@ -220,6 +223,7 @@ describe('dereferencer', () => {
agent: expect.anything(),
headers: expect.anything(),
method: 'POST',
keepalive: true,
});
expect(out.headers).toEqual(new Headers({
'content-type': 'text/turtle',
Expand All @@ -229,7 +233,7 @@ describe('dereferencer', () => {
it('should handle relative local .ttl files', async () => {
const out = await rdfDereferencer.dereference('test/assets/example.ttl', { localFiles: true });
expect(out.metadata.triples).toBeTruthy();
expect(out.url).toEqual(join(process.cwd(), 'test/assets/example.ttl'));
expect(out.url).toEqual('file://' + join(process.cwd(), 'test/assets/example.ttl'));
return expect(arrayifyStream(out.data)).resolves.toBeRdfIsomorphic([
quad(out.url, 'http://ex.org/p', 'http://ex.org/o1'),
quad(out.url, 'http://ex.org/p', 'http://ex.org/o2'),
Expand All @@ -244,7 +248,7 @@ describe('dereferencer', () => {
it('should handle absolute local .ttl files', async () => {
const out = await rdfDereferencer.dereference(join(process.cwd(), 'test/assets/example.ttl'), { localFiles: true });
expect(out.metadata.triples).toBeTruthy();
expect(out.url).toEqual(join(process.cwd(), 'test/assets/example.ttl'));
expect(out.url).toEqual('file://' + join(process.cwd(), 'test/assets/example.ttl'));
return expect(arrayifyStream(out.data)).resolves.toBeRdfIsomorphic([
quad(out.url, 'http://ex.org/p', 'http://ex.org/o1'),
quad(out.url, 'http://ex.org/p', 'http://ex.org/o2'),
Expand All @@ -254,7 +258,7 @@ describe('dereferencer', () => {
it('should handle absolute local .shaclc files', async () => {
const out = await rdfDereferencer.dereference(join(process.cwd(), 'test/assets/example.shaclc'), { localFiles: true });
expect(out.metadata.triples).toBeTruthy();
expect(out.url).toEqual(join(process.cwd(), 'test/assets/example.shaclc'));
expect(out.url).toEqual('file://' + join(process.cwd(), 'test/assets/example.shaclc'));
return expect(arrayifyStream(out.data)).resolves.toBeRdfIsomorphic([
quad("http://localhost:3002/ContactsShape#ContactsShape", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/ns/shacl#NodeShape"),
quad("http://localhost:3002/ContactsShape", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://www.w3.org/2002/07/owl#Ontology"),
Expand Down
11 changes: 11 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

module.exports = {
entry: './lib/index.js',
output: {
filename: 'rdf-dereference-browser.js',
path: __dirname,
libraryTarget: 'var',
library: 'RdfDereference',
},
};
Loading

0 comments on commit c235c37

Please sign in to comment.