@glossarist/concept-browser 0.7.113 → 0.7.115

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.
Files changed (86) hide show
  1. package/README.md +87 -2
  2. package/cli/index.mjs +15 -15
  3. package/cli/index.ts +9 -11
  4. package/data/concept-model/shapes/glossarist.concept.yaml.schema.json +255 -0
  5. package/package.json +14 -12
  6. package/scripts/__tests__/{bibliography.test.mjs → bibliography.test.ts} +1 -1
  7. package/scripts/__tests__/{cli-script-contract.test.mjs → cli-script-contract.test.ts} +3 -3
  8. package/scripts/__tests__/{concept-groups.test.mjs → concept-groups.test.ts} +1 -1
  9. package/scripts/__tests__/{doctor.test.mjs → doctor.test.ts} +1 -1
  10. package/scripts/__tests__/{fetch-datasets.test.mjs → fetch-datasets.test.ts} +1 -1
  11. package/scripts/__tests__/{first-non-empty.test.mjs → first-non-empty.test.ts} +1 -1
  12. package/scripts/__tests__/{process-about-pages.test.mjs → process-about-pages.test.ts} +1 -1
  13. package/scripts/{bridge-to-astro.mjs → bridge-to-astro.ts} +2 -4
  14. package/scripts/{build-edges.js → build-edges.ts} +11 -13
  15. package/scripts/{check-syntax.mjs → check-syntax.ts} +20 -13
  16. package/scripts/{fetch-datasets.mjs → fetch-datasets.ts} +2 -2
  17. package/scripts/{generate-data.mjs → generate-data.ts} +73 -460
  18. package/scripts/{generate-ontology-schema.mjs → generate-ontology-schema.ts} +2 -2
  19. package/scripts/lib/{build-cache.mjs → build-cache.ts} +3 -2
  20. package/scripts/lib/concept-formats.ts +206 -0
  21. package/scripts/lib/concept-uri.ts +14 -0
  22. package/scripts/lib/{dataset-turtle.mjs → dataset-turtle.ts} +4 -3
  23. package/scripts/lib/harmonize-concept.ts +86 -0
  24. package/scripts/lib/jsonld-emitter.ts +169 -0
  25. package/scripts/lib/{local-path-safety.mjs → local-path-safety.ts} +6 -2
  26. package/scripts/lib/yaml-types.ts +262 -0
  27. package/scripts/{process-about-pages.mjs → process-about-pages.ts} +1 -1
  28. package/scripts/{smoke.mjs → smoke.ts} +4 -3
  29. package/scripts/{validate-shacl.mjs → validate-shacl.ts} +5 -5
  30. package/scripts/validate-yaml.ts +144 -0
  31. package/src/__tests__/extract-source-refs.test.ts +2 -3
  32. package/src/__tests__/perf/serialization-perf.test.ts +5 -5
  33. package/src/__tests__/scripts/agents-turtle.test.ts +1 -1
  34. package/src/__tests__/scripts/bibliography-turtle.test.ts +1 -1
  35. package/src/__tests__/scripts/build-activity-turtle.test.ts +1 -1
  36. package/src/__tests__/scripts/build-cache.test.ts +1 -1
  37. package/src/__tests__/scripts/build-integration.test.ts +19 -19
  38. package/src/__tests__/scripts/dataset-turtle.test.ts +1 -1
  39. package/src/__tests__/scripts/migrate-v1-to-v3.test.ts +1 -1
  40. package/src/__tests__/scripts/normalize-yaml.test.ts +1 -1
  41. package/src/__tests__/scripts/turtle-escape.test.ts +1 -1
  42. package/src/__tests__/scripts/validate-yaml.test.ts +76 -0
  43. package/src/__tests__/scripts/version-turtle.test.ts +1 -1
  44. package/src/__tests__/scripts/vocab-turtle.test.ts +1 -1
  45. package/src/__tests__/scripts-syntax.test.ts +2 -2
  46. package/src/__tests__/use-rdf-document.test.ts +2 -3
  47. package/src/__tests__/utils/content-renderer-xss.test.ts +57 -0
  48. package/src/__tests__/utils/inline-content-kinds.test.ts +139 -0
  49. package/src/__tests__/validate-shacl.test.ts +3 -3
  50. package/src/adapters/wire/index.ts +69 -0
  51. package/src/pages/[...path].astro +1 -0
  52. package/src/router/index.ts +5 -0
  53. package/src/utils/content-renderer.ts +106 -23
  54. package/src/utils/url-safety.ts +1 -5
  55. package/src/views/learn/LearnInlineContentView.vue +128 -0
  56. package/tsconfig.json +2 -2
  57. package/vite.config.ts +1 -1
  58. package/src/__tests__/composables/use-concept-edges-v2.test.ts +0 -167
  59. package/src/__tests__/composables/use-concept-edges-v2.test.ts.bak +0 -166
  60. package/src/types/agents-version-turtle.d.ts +0 -27
  61. package/src/types/bibliography-turtle.d.ts +0 -12
  62. package/src/types/build-activity-turtle.d.ts +0 -16
  63. package/src/types/build-cache.d.ts +0 -20
  64. package/src/types/dataset-turtle.d.ts +0 -32
  65. package/src/types/normalize-yaml.d.ts +0 -16
  66. package/src/types/turtle-escape.d.ts +0 -6
  67. package/src/types/vocab-turtle.d.ts +0 -13
  68. /package/scripts/{doctor.mjs → doctor.ts} +0 -0
  69. /package/scripts/{extract-source-refs.js → extract-source-refs.ts} +0 -0
  70. /package/scripts/{generate-404.js → generate-404.ts} +0 -0
  71. /package/scripts/{generate-ontology-data.mjs → generate-ontology-data.ts} +0 -0
  72. /package/scripts/lib/{agents-turtle.mjs → agents-turtle.ts} +0 -0
  73. /package/scripts/lib/{bibliography-turtle.mjs → bibliography-turtle.ts} +0 -0
  74. /package/scripts/lib/{bibliography.mjs → bibliography.ts} +0 -0
  75. /package/scripts/lib/build/{image-assets.mjs → image-assets.ts} +0 -0
  76. /package/scripts/lib/build/{non-verbal-consumer.mjs → non-verbal-consumer.ts} +0 -0
  77. /package/scripts/lib/{build-activity-turtle.mjs → build-activity-turtle.ts} +0 -0
  78. /package/scripts/lib/{concept-groups.mjs → concept-groups.ts} +0 -0
  79. /package/scripts/lib/{first-non-empty.mjs → first-non-empty.ts} +0 -0
  80. /package/scripts/lib/{turtle-escape.mjs → turtle-escape.ts} +0 -0
  81. /package/scripts/lib/{version-turtle.mjs → version-turtle.ts} +0 -0
  82. /package/scripts/lib/{vocab-turtle.mjs → vocab-turtle.ts} +0 -0
  83. /package/scripts/{load-site-config.mjs → load-site-config.ts} +0 -0
  84. /package/scripts/{migrate-v1-to-v3.mjs → migrate-v1-to-v3.ts} +0 -0
  85. /package/scripts/{normalize-yaml.mjs → normalize-yaml.ts} +0 -0
  86. /package/scripts/{sync-concept-model.mjs → sync-concept-model.ts} +0 -0
@@ -1,6 +1,4 @@
1
- function buildConceptUri(uriBase, registerId, conceptId) {
2
- return `${uriBase}/${registerId}/concept/${conceptId}`;
3
- }
1
+ import { buildConceptUri } from './lib/concept-uri';
4
2
 
5
3
  const VALID_COMPLETENESS = new Set(['complete', 'partial']);
6
4
 
@@ -97,14 +95,14 @@ function slugify(text) {
97
95
 
98
96
  // --- Extractors (open/closed: add new extractors to EXTRACTORS array) ---
99
97
 
100
- function extractReferences(concept, registerId) {
101
- const edges = [];
98
+ function extractReferences(concept: Record<string, any>, registerId: string) {
99
+ const edges: Record<string, any>[] = [];
102
100
  const sourceUri = concept['@id'];
103
- for (const [lang, lc] of Object.entries(concept['gl:localizedConcept'] || {})) {
101
+ for (const [lang, lc] of Object.entries(concept['gl:localizedConcept'] || {}) as [string, any][]) {
104
102
  if (lc['gl:references']) {
105
- for (const ref of lc['gl:references']) {
103
+ for (const ref of lc['gl:references'] as Record<string, any>[]) {
106
104
  if (ref['@id'] && ref['@id'] !== sourceUri) {
107
- const edge = {
105
+ const edge: Record<string, any> = {
108
106
  source: sourceUri,
109
107
  target: ref['@id'],
110
108
  type: ref['@id'].startsWith('cite:') ? 'citation' : 'references',
@@ -368,11 +366,11 @@ function buildEdgesForDataset(datasetDir, registerId, uriBase, urnMap, manifest)
368
366
  const uriBase = manifest.uriBase;
369
367
  if (!uriBase) throw new Error('build-edges: manifest.uriBase is required');
370
368
 
371
- function buildSectionNode(section, idx) {
369
+ function buildSectionNode(section: Record<string, any>, idx: number): Record<string, any> {
372
370
  const sectionId = `section-${section.id}`;
373
371
  const domainUri = `${uriBase}/${registerId}/domain/${sectionId}`;
374
372
  const domainLabel = section.names?.eng || section.id;
375
- const node = {
373
+ const node: Record<string, any> = {
376
374
  uri: domainUri,
377
375
  id: sectionId,
378
376
  names: section.names || {},
@@ -525,7 +523,7 @@ if (auditUnmatched.size > 0) {
525
523
 
526
524
  // Build cross-reference index: for each dataset, which other datasets'
527
525
  // edges.json contains edges targeting that dataset's URIs.
528
- const datasetUriPrefixes = new Map();
526
+ const datasetUriPrefixes = new Map<string, string>();
529
527
  for (const [ds, manifest] of manifestCache) {
530
528
  const uriBase = manifest.uriBase;
531
529
  if (!uriBase) throw new Error('build-edges: manifest.uriBase is required');
@@ -538,7 +536,7 @@ for (const ds of datasets) {
538
536
  }
539
537
 
540
538
  for (const [sourceDs, edges] of allDatasetEdges) {
541
- const targets = new Set();
539
+ const targets = new Set<string>();
542
540
  for (const edge of edges) {
543
541
  for (const [targetDs, prefix] of datasetUriPrefixes) {
544
542
  if (targetDs !== sourceDs && edge.target.startsWith(prefix)) {
@@ -561,7 +559,7 @@ for (const [sourceDs, edges] of allDatasetEdges) {
561
559
 
562
560
  const crossRefPath = join(DATA_DIR, 'cross-ref-index.json');
563
561
  writeFileSync(crossRefPath, JSON.stringify(crossRefIndex));
564
- const refCount = Object.values(crossRefIndex).reduce((sum, arr) => sum + arr.length, 0);
562
+ const refCount = Object.values(crossRefIndex).reduce((sum: number, arr: string[]) => sum + arr.length, 0);
565
563
  console.log(`Written cross-ref-index.json (${refCount} cross-references across ${datasets.length} datasets)`);
566
564
 
567
565
  console.log('Done.');
@@ -7,7 +7,8 @@ import process from "node:process";
7
7
  const ROOT = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
8
8
 
9
9
  const TARGET_DIRS = ["scripts", "cli"];
10
- const EXTENSIONS = new Set([".mjs", ".js", ".cjs"]);
10
+ const JS_EXTENSIONS = new Set([".mjs", ".js", ".cjs"]);
11
+ const ALL_EXTENSIONS = new Set([".ts", ...JS_EXTENSIONS]);
11
12
  const SKIP_DIRS = new Set(["__tests__", "node_modules"]);
12
13
 
13
14
  function walk(dir) {
@@ -18,7 +19,7 @@ function walk(dir) {
18
19
  const st = statSync(full);
19
20
  if (st.isDirectory()) {
20
21
  out.push(...walk(full));
21
- } else if (EXTENSIONS.has(path.extname(entry))) {
22
+ } else if (ALL_EXTENSIONS.has(path.extname(entry))) {
22
23
  out.push(full);
23
24
  }
24
25
  }
@@ -39,15 +40,24 @@ export function checkAllScripts({ root = ROOT } = {}) {
39
40
  files.sort();
40
41
 
41
42
  const failures = [];
42
- for (const file of files) {
43
- const result = spawnSync(process.execPath, ["--check", file], {
43
+
44
+ // JS files: syntax-check with node --check
45
+ for (const file of files.filter(f => JS_EXTENSIONS.has(path.extname(f)))) {
46
+ const result = spawnSync(process.execPath, ["--check", file], { encoding: "utf8" });
47
+ if (result.status !== 0) {
48
+ failures.push({ file: path.relative(root, file), stderr: result.stderr || "" });
49
+ }
50
+ }
51
+
52
+ // TS files: type-check with tsc (authoritative for TypeScript)
53
+ if (files.some(f => path.extname(f) === ".ts")) {
54
+ const tsconfig = path.join(root, "tsconfig.scripts.json");
55
+ const result = spawnSync("npx", ["tsc", "-p", tsconfig, "--noEmit"], {
44
56
  encoding: "utf8",
57
+ cwd: root,
45
58
  });
46
59
  if (result.status !== 0) {
47
- failures.push({
48
- file: path.relative(root, file),
49
- stderr: result.stderr || "",
50
- });
60
+ failures.push({ file: "tsconfig.scripts.json (tsc)", stderr: result.stdout || result.stderr || "" });
51
61
  }
52
62
  }
53
63
 
@@ -60,9 +70,7 @@ function main() {
60
70
  process.stdout.write(`syntax OK: ${files.length} file(s) checked\n`);
61
71
  return;
62
72
  }
63
- process.stderr.write(
64
- `syntax check failed: ${failures.length} of ${files.length} file(s)\n\n`,
65
- );
73
+ process.stderr.write(`syntax check failed: ${failures.length} of ${files.length} file(s)\n\n`);
66
74
  for (const { file, stderr } of failures) {
67
75
  process.stderr.write(`--- ${file} ---\n${stderr}\n`);
68
76
  }
@@ -70,8 +78,7 @@ function main() {
70
78
  }
71
79
 
72
80
  const isDirectEntry = process.argv[1] &&
73
- path.resolve(process.argv[1]) ===
74
- path.resolve(new URL(import.meta.url).pathname);
81
+ path.resolve(process.argv[1]) === path.resolve(new URL(import.meta.url).pathname);
75
82
 
76
83
  if (isDirectEntry) {
77
84
  main();
@@ -20,8 +20,8 @@ import JSZip from 'jszip';
20
20
  import { loadGcr } from 'glossarist';
21
21
  import { execFileSync } from 'child_process';
22
22
  import { fileURLToPath } from 'url';
23
- import { loadSiteConfig } from './load-site-config.mjs';
24
- import { assertLocalPathSafe } from './lib/local-path-safety.mjs';const ROOT = process.cwd();
23
+ import { loadSiteConfig } from './load-site-config';
24
+ import { assertLocalPathSafe } from './lib/local-path-safety';const ROOT = process.cwd();
25
25
  const DATASETS_DIR = path.join(ROOT, '.datasets');
26
26
  const GCR_DIR = path.join(ROOT, '.gcr');
27
27