@glossarist/concept-browser 0.7.56 → 0.7.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glossarist/concept-browser",
3
- "version": "0.7.56",
3
+ "version": "0.7.58",
4
4
  "description": "Vue SPA for browsing Glossarist terminology datasets with cross-reference resolution, graph visualization, and multi-language support",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,7 +31,7 @@
31
31
  "autoprefixer": "^10.4.21",
32
32
  "d3": "^7.9.0",
33
33
  "favicons": "^7.2.0",
34
- "glossarist": "^0.4.2",
34
+ "glossarist": "^0.4.5",
35
35
  "js-yaml": "^4.1.0",
36
36
  "jszip": "^3.10.1",
37
37
  "pinia": "^2.3.1",
@@ -12,6 +12,7 @@ import { buildVocabularyTurtle } from './lib/vocab-turtle.mjs';
12
12
  import { buildAgentsTurtle } from './lib/agents-turtle.mjs';
13
13
  import { buildVersionHistoryTurtle } from './lib/version-turtle.mjs';
14
14
  import { buildBibliographyTurtle } from './lib/bibliography-turtle.mjs';
15
+ import { ttlLit } from './lib/turtle-escape.mjs';
15
16
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
16
17
  const ROOT = process.cwd();
17
18
  const PUBLIC = path.join(ROOT, 'public');
@@ -672,7 +673,7 @@ function getPrimaryDesignation(conceptYaml) {
672
673
  }
673
674
 
674
675
  function escapeTurtle(s) {
675
- return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
676
+ return ttlLit(s).slice(1, -1);
676
677
  }
677
678
 
678
679
  function conceptJsonToTurtle(concept) {
@@ -66,6 +66,7 @@ function fetchAny(ref, candidates) {
66
66
  const targets = {
67
67
  'glossarist.context.jsonld': ['ontologies/glossarist.context.jsonld', 'glossarist.context.jsonld'],
68
68
  'glossarist.ttl': ['ontologies/glossarist.ttl', 'glossarist.ttl'],
69
+ 'prefixes.ttl': ['ontologies/prefixes.ttl'],
69
70
  'shapes/glossarist.shacl.ttl': ['ontologies/shapes/glossarist.shacl.ttl', 'shapes/glossarist.shacl.ttl'],
70
71
  };
71
72
 
@@ -15,29 +15,23 @@
15
15
  // `data/concept-model/shapes/glossarist.shacl.ttl` (synced from
16
16
  // glossarist/concept-model via `npm run sync:model`). Pass --shapes <path>
17
17
  // or set SHAPES_PATH to override.
18
+ //
19
+ // Delegates the actual validation to glossarist-js's validateShacl
20
+ // wrapper, which handles factory aggregation and shapes caching. The
21
+ // directory walk + CLI parsing stay here because they're build-pipeline
22
+ // specific.
18
23
 
19
24
  import { readFileSync, readdirSync, statSync } from 'node:fs';
20
25
  import { join, extname, dirname, resolve } from 'node:path';
21
26
  import { fileURLToPath } from 'node:url';
22
- import { Parser as N3Parser, DataFactory } from 'n3';
27
+ import { Parser as N3Parser } from 'n3';
23
28
  import rdfDataset from '@rdfjs/dataset';
24
- import ShaclValidator from 'rdf-validate-shacl';
29
+ import { validateShacl, quadsToDataset } from 'glossarist/rdf';
25
30
 
26
31
  const __dirname = dirname(fileURLToPath(import.meta.url));
27
32
  const VENDORED_SHAPES = resolve(__dirname, '..', 'data', 'concept-model', 'shapes', 'glossarist.shacl.ttl');
28
33
 
29
- const COMBINED_FACTORY = {
30
- namedNode: DataFactory.namedNode,
31
- blankNode: DataFactory.blankNode,
32
- literal: DataFactory.literal,
33
- defaultGraph: DataFactory.defaultGraph,
34
- quad: DataFactory.quad,
35
- fromTerm: DataFactory.fromTerm,
36
- fromQuad: DataFactory.fromQuad,
37
- dataset: rdfDataset.dataset.bind(rdfDataset),
38
- };
39
- const createDataset = COMBINED_FACTORY.dataset;
40
- const ShaclValidatorCtor = ShaclValidator.default ?? ShaclValidator;
34
+ const createDataset = rdfDataset.dataset.bind(rdfDataset);
41
35
 
42
36
  function parseArgs(argv) {
43
37
  const out = { dataRoot: 'public/data', shapesPath: null };
@@ -119,6 +113,10 @@ async function main() {
119
113
  const args = parseArgs(process.argv);
120
114
  const shapesPath = resolveShapesPath(args.shapesPath);
121
115
 
116
+ // Pre-parse the shapes file once so we can pass it explicitly via the
117
+ // { shapes } option. glossarist-js caches by path internally, but
118
+ // passing the dataset directly avoids a re-read of the file when the
119
+ // same path is reused for every validation call.
122
120
  let shapesDataset;
123
121
  try {
124
122
  const shapesText = readFileSync(shapesPath, 'utf8');
@@ -128,8 +126,6 @@ async function main() {
128
126
  process.exit(2);
129
127
  }
130
128
 
131
- const validator = new ShaclValidatorCtor(shapesDataset, { factory: COMBINED_FACTORY });
132
-
133
129
  let statDir;
134
130
  try {
135
131
  statDir = statSync(args.dataRoot);
@@ -158,7 +154,7 @@ async function main() {
158
154
  violations.push({ path, parseError: e.message });
159
155
  continue;
160
156
  }
161
- const report = validator.validate(graph);
157
+ const report = await validateShacl(graph, { shapes: shapesDataset });
162
158
  if (!report.conforms) {
163
159
  for (const v of report.results) {
164
160
  violations.push({ path, result: v });
@@ -1,3 +1,10 @@
1
+ // Prefix bindings for concept-browser's RDF emission.
2
+ //
3
+ // The canonical SSOT for prefix bindings is `data/concept-model/prefixes.ttl`
4
+ // (vendored from glossarist/concept-model). This list is the runtime subset
5
+ // actually emitted by concept-browser. Keep it aligned with prefixes.ttl
6
+ // whenever the upstream file changes.
7
+
1
8
  export interface PrefixEntry {
2
9
  prefix: string;
3
10
  iri: string;
@@ -5,17 +12,20 @@ export interface PrefixEntry {
5
12
  }
6
13
 
7
14
  export const RDF_PREFIXES: readonly PrefixEntry[] = [
8
- { prefix: 'gloss', iri: 'https://www.glossarist.org/ontologies/', description: 'Glossarist ontology' },
9
- { prefix: 'skos', iri: 'http://www.w3.org/2004/02/skos/core#', description: 'Simple Knowledge Organization System' },
10
- { prefix: 'skosxl', iri: 'http://www.w3.org/2008/05/skos-xl#', description: 'SKOS eXtension for Labels' },
11
- { prefix: 'rdf', iri: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', description: 'RDF core vocabulary' },
12
- { prefix: 'rdfs', iri: 'http://www.w3.org/2000/01/rdf-schema#', description: 'RDF Schema' },
13
- { prefix: 'owl', iri: 'http://www.w3.org/2002/07/owl#', description: 'Web Ontology Language' },
14
- { prefix: 'dcterms', iri: 'http://purl.org/dc/terms/', description: 'Dublin Core terms' },
15
- { prefix: 'prov', iri: 'http://www.w3.org/ns/prov#', description: 'PROV-O provenance' },
16
- { prefix: 'dcat', iri: 'http://www.w3.org/ns/dcat#', description: 'Data Catalog vocabulary' },
17
- { prefix: 'foaf', iri: 'http://xmlns.com/foaf/0.1/', description: 'Friend-of-a-Friend agents' },
18
- { prefix: 'xsd', iri: 'http://www.w3.org/2001/XMLSchema#', description: 'XML Schema datatypes' },
15
+ { prefix: 'gloss', iri: 'https://www.glossarist.org/ontologies/', description: 'Glossarist ontology' },
16
+ { prefix: 'skos', iri: 'http://www.w3.org/2004/02/skos/core#', description: 'Simple Knowledge Organization System' },
17
+ { prefix: 'skosxl', iri: 'http://www.w3.org/2008/05/skos-xl#', description: 'SKOS eXtension for Labels' },
18
+ { prefix: 'iso-thes', iri: 'http://purl.org/iso25964/skos-thes#', description: 'ISO 25964 SKOS thesaurus extensions' },
19
+ { prefix: 'rdf', iri: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', description: 'RDF core vocabulary' },
20
+ { prefix: 'rdfs', iri: 'http://www.w3.org/2000/01/rdf-schema#', description: 'RDF Schema' },
21
+ { prefix: 'owl', iri: 'http://www.w3.org/2002/07/owl#', description: 'Web Ontology Language' },
22
+ { prefix: 'dcterms', iri: 'http://purl.org/dc/terms/', description: 'Dublin Core terms' },
23
+ { prefix: 'prov', iri: 'http://www.w3.org/ns/prov#', description: 'PROV-O provenance' },
24
+ { prefix: 'dcat', iri: 'http://www.w3.org/ns/dcat#', description: 'Data Catalog vocabulary' },
25
+ { prefix: 'foaf', iri: 'http://xmlns.com/foaf/0.1/', description: 'Friend-of-a-Friend agents' },
26
+ { prefix: 'vann', iri: 'http://purl.org/vocab/vann/', description: 'Vocabulary annotations' },
27
+ { prefix: 'xsd', iri: 'http://www.w3.org/2001/XMLSchema#', description: 'XML Schema datatypes' },
28
+ { prefix: 'sh', iri: 'http://www.w3.org/ns/shacl#', description: 'SHACL shapes vocabulary' },
19
29
  ] as const;
20
30
 
21
31
  export function findPrefix(prefix: string): PrefixEntry | undefined {