@glossarist/concept-browser 0.7.57 → 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.57",
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",
@@ -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 });