Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/dataset-registry-client/src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dcterms, foaf, xsd } from 'ldkit/namespaces';
import { dcterms, foaf, ldkit, xsd } from 'ldkit/namespaces';
import { dcat } from './dcat.js';

export const DatasetSchema = {
Expand All @@ -19,6 +19,7 @@ export const DatasetSchema = {
},
license: {
'@id': dcterms.license,
'@type': ldkit.IRI,
'@optional': true,
},
creator: {
Expand Down Expand Up @@ -47,9 +48,13 @@ export const DatasetSchema = {
'@array': true,
'@schema': {
'@type': dcat.Distribution,
accessURL: dcat.accessURL,
accessURL: {
'@id': dcat.accessURL,
'@type': ldkit.IRI,
},
mediaType: {
'@id': dcat.mediaType,
'@type': ldkit.IRI,
'@optional': true,
},
byteSize: {
Expand All @@ -59,10 +64,12 @@ export const DatasetSchema = {
},
compressFormat: {
'@id': dcat.compressFormat,
'@type': ldkit.IRI,
'@optional': true,
},
conformsTo: {
'@id': dcterms.conformsTo,
'@type': ldkit.IRI,
'@optional': true,
},
modified: {
Expand Down
20 changes: 20 additions & 0 deletions packages/dataset-registry-client/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ describe('Client', () => {
expect(count).toEqual(1);
});

it('reads back a distribution that declares no media type', async () => {
// Only reachable without media-type criteria: those narrow a dataset’s
// distributions to the matching ones, so a filtered query never returns
// this distribution.
const results = await client.query({
$id: 'http://bar.org/id/dataset/bar',
});

const mediaTypes = [];
for await (const dataset of results) {
mediaTypes.push(
...dataset.distributions.map(
(distribution) => distribution.mediaType,
),
);
}

expect(mediaTypes).toContain(undefined);
});

it('throws an error for non-CONSTRUCT queries', async () => {
const query = `
PREFIX dcat: <http://www.w3.org/ns/dcat#>
Expand Down