@glossarist/concept-browser 0.7.59 → 0.7.60

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.59",
3
+ "version": "0.7.60",
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.8",
34
+ "glossarist": "^0.4.9",
35
35
  "js-yaml": "^4.1.0",
36
36
  "jszip": "^3.10.1",
37
37
  "pinia": "^2.3.1",
@@ -1612,7 +1612,7 @@ for (const [id, count] of Object.entries(counts)) {
1612
1612
 
1613
1613
  writeBuildActivity(total, registry.map(r => r.id));
1614
1614
 
1615
- fs.writeFileSync(path.join(DATA, '_vocab.ttl'), buildVocabularyTurtle());
1615
+ fs.writeFileSync(path.join(DATA, '_vocab.ttl'), await buildVocabularyTurtle());
1616
1616
  console.log('Emitted vocabulary graph: data/_vocab.ttl');
1617
1617
 
1618
1618
  const contributors = config.contributors ?? [];
@@ -1,6 +1,21 @@
1
+ // Vocab turtle builder — emits SKOS ConceptSchemes for the
2
+ // glossarist enumeration IRIs.
3
+ //
4
+ // Delegates to glossarist-js's vocabulary emitter + writeTurtle so the
5
+ // canonical prefix list, CURIE handling, and serialization stay in one
6
+ // place. The output is byte-equivalent in semantics ( CURIEs resolved
7
+ // to absolute IRIs, then re-rendered via glossarist-js's n3 writer with
8
+ // the canonical prefix map ).
9
+
1
10
  import { readFileSync } from 'node:fs';
2
11
  import { join, dirname } from 'node:path';
3
12
  import { fileURLToPath } from 'node:url';
13
+ import {
14
+ vocabularyToQuads,
15
+ collectQuads,
16
+ writeTurtle,
17
+ PREFIXES,
18
+ } from 'glossarist/rdf';
4
19
 
5
20
  const __dirname = dirname(fileURLToPath(import.meta.url));
6
21
  const VOCAB_PATH = join(__dirname, '..', '..', 'data', 'glossarist-vocab.json');
@@ -9,54 +24,20 @@ function loadVocab(path = VOCAB_PATH) {
9
24
  return JSON.parse(readFileSync(path, 'utf8'));
10
25
  }
11
26
 
12
- function ttlLit(s) {
13
- if (s == null) return '""';
14
- const escaped = String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"')
15
- .replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t');
16
- return `"${escaped}"`;
17
- }
18
-
19
- function ttlPrefixed(qname) {
20
- const colonIdx = qname.indexOf(':');
21
- if (colonIdx < 0) return qname;
22
- const local = qname.slice(colonIdx + 1);
23
- const escaped = local.replace(/([/])/g, '\\$1');
24
- return `${qname.slice(0, colonIdx + 1)}${escaped}`;
27
+ // n3's writer prefixes must omit the trailing # or / — those go in
28
+ // the local name. Build the prefix-only map for writeTurtle.
29
+ function writerPrefixes() {
30
+ const out = {};
31
+ for (const [k, v] of Object.entries(PREFIXES)) {
32
+ out[k] = v;
33
+ }
34
+ return out;
25
35
  }
26
36
 
27
- export function buildVocabularyTurtle() {
37
+ export async function buildVocabularyTurtle() {
28
38
  const vocab = loadVocab();
29
- const lines = [
30
- '@prefix skos: <http://www.w3.org/2004/02/skos/core#> .',
31
- '@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .',
32
- '@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .',
33
- '@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .',
34
- '@prefix dcterms: <http://purl.org/dc/terms/> .',
35
- '@prefix gloss: <https://www.glossarist.org/ontologies/> .',
36
- '',
37
- ];
38
-
39
- for (const scheme of vocab.schemes) {
40
- const schemeLines = [
41
- `${ttlPrefixed(scheme.schemeIri)} a skos:ConceptScheme ;`,
42
- ` rdfs:label ${ttlLit(scheme.label)} ;`,
43
- ];
44
- for (const term of scheme.terms) {
45
- schemeLines.push(` skos:hasTopConcept ${ttlPrefixed(term.iri)} ;`);
46
- }
47
- schemeLines[schemeLines.length - 1] = schemeLines[schemeLines.length - 1].replace(/ ;$/, ' .');
48
- lines.push(...schemeLines);
49
-
50
- for (const term of scheme.terms) {
51
- lines.push(`${ttlPrefixed(term.iri)} a skos:Concept ;`);
52
- lines.push(` rdfs:label ${ttlLit(term.label)} ;`);
53
- lines.push(` skos:inScheme ${ttlPrefixed(scheme.schemeIri)} .`);
54
- lines.push('');
55
- }
56
- lines.push('');
57
- }
58
-
59
- return lines.join('\n') + '\n';
39
+ const quads = collectQuads(vocabularyToQuads(vocab.schemes));
40
+ return writeTurtle(quads, { prefixes: writerPrefixes() });
60
41
  }
61
42
 
62
43
  export function listVocabSchemes() {
@@ -15,7 +15,7 @@ function runInline(code: string): string {
15
15
 
16
16
  describe('WS F Layer 8 — build pipeline integration', () => {
17
17
  it('vocab-turtle.mjs produces parseable Turtle with 7 schemes', () => {
18
- const out = runInline(`import { buildVocabularyTurtle } from './scripts/lib/vocab-turtle.mjs'; console.log(buildVocabularyTurtle());`);
18
+ const out = runInline(`import { buildVocabularyTurtle } from './scripts/lib/vocab-turtle.mjs'; console.log(await buildVocabularyTurtle());`);
19
19
  const store = parseTurtle(out);
20
20
  const schemes = [...store].filter(q =>
21
21
  q.predicate.value === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' &&
@@ -119,7 +119,7 @@ describe('WS F Layer 8 — build pipeline integration', () => {
119
119
  import { buildBibliographyTurtle } from './scripts/lib/bibliography-turtle.mjs';
120
120
  import { buildVersionHistoryTurtle } from './scripts/lib/version-turtle.mjs';
121
121
  const parts = [
122
- buildVocabularyTurtle(),
122
+ await buildVocabularyTurtle(),
123
123
  buildDatasetTurtle({ datasetIri: 'https://glossarist.org/test/', registerId: 'test', title: 't', modified: '2026-01-01', languages: ['eng'], distributions: [], topConceptUris: [], sections: [] }),
124
124
  buildActivityTurtle({ runId: 'r', startedAt: '2026-01-01T00:00:00Z', endedAt: '2026-01-01T00:05:00Z', toolId: 'cb', toolVersion: '0', datasetRegisters: [], conceptCount: 0 }),
125
125
  buildAgentsTurtle([{ name: 'Ada' }]),
@@ -13,22 +13,22 @@ const SKOS = 'http://www.w3.org/2004/02/skos/core#';
13
13
  const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
14
14
 
15
15
  describe('buildVocabularyTurtle (mjs)', () => {
16
- it('parses without errors and produces a non-empty graph', () => {
17
- const ttl = buildVocabularyTurtle();
16
+ it('parses without errors and produces a non-empty graph', async () => {
17
+ const ttl = await buildVocabularyTurtle();
18
18
  const store = parse(ttl);
19
19
  expect(store.size).toBeGreaterThan(0);
20
20
  });
21
21
 
22
- it('declares at least one skos:ConceptScheme', () => {
23
- const store = parse(buildVocabularyTurtle());
22
+ it('declares at least one skos:ConceptScheme', async () => {
23
+ const store = parse(await buildVocabularyTurtle());
24
24
  const schemes = [...store].filter(q =>
25
25
  q.predicate.value === RDF_TYPE && q.object.value === `${SKOS}ConceptScheme`,
26
26
  );
27
27
  expect(schemes.length).toBeGreaterThan(0);
28
28
  });
29
29
 
30
- it('declares enumeration IRIs as skos:Concept instances', () => {
31
- const store = parse(buildVocabularyTurtle());
30
+ it('declares enumeration IRIs as skos:Concept instances', async () => {
31
+ const store = parse(await buildVocabularyTurtle());
32
32
  const concepts = [...store].filter(q =>
33
33
  q.predicate.value === RDF_TYPE && q.object.value === `${SKOS}Concept`,
34
34
  );
@@ -53,8 +53,8 @@ describe('buildVocabularyTurtle (mjs)', () => {
53
53
  expect(schemes.length).toBe(7);
54
54
  });
55
55
 
56
- it('emits skos:hasTopConcept and skos:inScheme bidirectionally', () => {
57
- const store = parse(buildVocabularyTurtle());
56
+ it('emits skos:hasTopConcept and skos:inScheme bidirectionally', async () => {
57
+ const store = parse(await buildVocabularyTurtle());
58
58
  const hasTopConcept = [...store].filter(q => q.predicate.value === `${SKOS}hasTopConcept`);
59
59
  const inScheme = [...store].filter(q => q.predicate.value === `${SKOS}inScheme`);
60
60
  expect(hasTopConcept.length).toBeGreaterThan(0);