@glossarist/concept-browser 0.7.114 → 0.7.116

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 (103) hide show
  1. package/README.md +45 -2
  2. package/cli/index.mjs +10 -13
  3. package/cli/index.ts +9 -11
  4. package/data/concept-model/shapes/glossarist.concept.yaml.schema.json +255 -0
  5. package/package.json +18 -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.js +132 -0
  14. package/scripts/{bridge-to-astro.mjs → bridge-to-astro.ts} +2 -4
  15. package/scripts/build-edges.js +242 -336
  16. package/scripts/build-edges.ts +572 -0
  17. package/scripts/build-scripts.mjs +22 -0
  18. package/scripts/check-syntax.js +81 -0
  19. package/scripts/{check-syntax.mjs → check-syntax.ts} +20 -13
  20. package/scripts/doctor.js +278 -0
  21. package/scripts/extract-source-refs.js +16 -24
  22. package/scripts/extract-source-refs.ts +32 -0
  23. package/scripts/fetch-datasets.js +278 -0
  24. package/scripts/{fetch-datasets.mjs → fetch-datasets.ts} +2 -2
  25. package/scripts/generate-404.js +10 -11
  26. package/scripts/generate-404.ts +15 -0
  27. package/scripts/generate-data.js +2220 -0
  28. package/scripts/{generate-data.mjs → generate-data.ts} +73 -460
  29. package/scripts/generate-ontology-data.js +139 -0
  30. package/scripts/generate-ontology-schema.js +472 -0
  31. package/scripts/{generate-ontology-schema.mjs → generate-ontology-schema.ts} +2 -2
  32. package/scripts/lib/{build-cache.mjs → build-cache.ts} +3 -2
  33. package/scripts/lib/concept-formats.ts +206 -0
  34. package/scripts/lib/concept-uri.ts +14 -0
  35. package/scripts/lib/{dataset-turtle.mjs → dataset-turtle.ts} +4 -3
  36. package/scripts/lib/harmonize-concept.ts +86 -0
  37. package/scripts/lib/jsonld-emitter.ts +169 -0
  38. package/scripts/lib/{local-path-safety.mjs → local-path-safety.ts} +6 -2
  39. package/scripts/lib/yaml-types.ts +262 -0
  40. package/scripts/load-site-config.js +83 -0
  41. package/scripts/migrate-v1-to-v3.js +113 -0
  42. package/scripts/normalize-yaml.js +96 -0
  43. package/scripts/process-about-pages.js +241 -0
  44. package/scripts/{process-about-pages.mjs → process-about-pages.ts} +1 -1
  45. package/scripts/smoke.js +211 -0
  46. package/scripts/{smoke.mjs → smoke.ts} +4 -3
  47. package/scripts/sync-concept-model.js +63 -0
  48. package/scripts/validate-shacl.js +152 -0
  49. package/scripts/{validate-shacl.mjs → validate-shacl.ts} +5 -5
  50. package/scripts/validate-yaml.js +132 -0
  51. package/scripts/validate-yaml.ts +144 -0
  52. package/src/__tests__/extract-source-refs.test.ts +2 -3
  53. package/src/__tests__/perf/serialization-perf.test.ts +5 -5
  54. package/src/__tests__/published-package-contract.test.ts +84 -0
  55. package/src/__tests__/scripts/agents-turtle.test.ts +1 -1
  56. package/src/__tests__/scripts/bibliography-turtle.test.ts +1 -1
  57. package/src/__tests__/scripts/build-activity-turtle.test.ts +1 -1
  58. package/src/__tests__/scripts/build-cache.test.ts +1 -1
  59. package/src/__tests__/scripts/build-integration.test.ts +19 -19
  60. package/src/__tests__/scripts/dataset-turtle.test.ts +1 -1
  61. package/src/__tests__/scripts/migrate-v1-to-v3.test.ts +1 -1
  62. package/src/__tests__/scripts/normalize-yaml.test.ts +1 -1
  63. package/src/__tests__/scripts/turtle-escape.test.ts +1 -1
  64. package/src/__tests__/scripts/validate-yaml.test.ts +76 -0
  65. package/src/__tests__/scripts/version-turtle.test.ts +1 -1
  66. package/src/__tests__/scripts/vocab-turtle.test.ts +1 -1
  67. package/src/__tests__/scripts-syntax.test.ts +4 -4
  68. package/src/__tests__/use-rdf-document.test.ts +2 -3
  69. package/src/__tests__/utils/content-renderer-xss.test.ts +57 -0
  70. package/src/__tests__/validate-shacl.test.ts +3 -3
  71. package/src/adapters/wire/index.ts +69 -0
  72. package/src/data/ontology-schema.json +1336 -183
  73. package/src/utils/content-renderer.ts +7 -3
  74. package/src/utils/url-safety.ts +1 -5
  75. package/tsconfig.json +2 -2
  76. package/vite.config.ts +1 -1
  77. package/src/__tests__/composables/use-concept-edges-v2.test.ts +0 -167
  78. package/src/__tests__/composables/use-concept-edges-v2.test.ts.bak +0 -166
  79. package/src/types/agents-version-turtle.d.ts +0 -27
  80. package/src/types/bibliography-turtle.d.ts +0 -12
  81. package/src/types/build-activity-turtle.d.ts +0 -16
  82. package/src/types/build-cache.d.ts +0 -20
  83. package/src/types/dataset-turtle.d.ts +0 -32
  84. package/src/types/normalize-yaml.d.ts +0 -16
  85. package/src/types/turtle-escape.d.ts +0 -6
  86. package/src/types/vocab-turtle.d.ts +0 -13
  87. /package/scripts/{doctor.mjs → doctor.ts} +0 -0
  88. /package/scripts/{generate-ontology-data.mjs → generate-ontology-data.ts} +0 -0
  89. /package/scripts/lib/{agents-turtle.mjs → agents-turtle.ts} +0 -0
  90. /package/scripts/lib/{bibliography-turtle.mjs → bibliography-turtle.ts} +0 -0
  91. /package/scripts/lib/{bibliography.mjs → bibliography.ts} +0 -0
  92. /package/scripts/lib/build/{image-assets.mjs → image-assets.ts} +0 -0
  93. /package/scripts/lib/build/{non-verbal-consumer.mjs → non-verbal-consumer.ts} +0 -0
  94. /package/scripts/lib/{build-activity-turtle.mjs → build-activity-turtle.ts} +0 -0
  95. /package/scripts/lib/{concept-groups.mjs → concept-groups.ts} +0 -0
  96. /package/scripts/lib/{first-non-empty.mjs → first-non-empty.ts} +0 -0
  97. /package/scripts/lib/{turtle-escape.mjs → turtle-escape.ts} +0 -0
  98. /package/scripts/lib/{version-turtle.mjs → version-turtle.ts} +0 -0
  99. /package/scripts/lib/{vocab-turtle.mjs → vocab-turtle.ts} +0 -0
  100. /package/scripts/{load-site-config.mjs → load-site-config.ts} +0 -0
  101. /package/scripts/{migrate-v1-to-v3.mjs → migrate-v1-to-v3.ts} +0 -0
  102. /package/scripts/{normalize-yaml.mjs → normalize-yaml.ts} +0 -0
  103. /package/scripts/{sync-concept-model.mjs → sync-concept-model.ts} +0 -0
@@ -0,0 +1,132 @@
1
+ // scripts/lib/concept-uri.ts
2
+ function buildConceptUri(uriBase, registerId, conceptId) {
3
+ return `${uriBase}/${registerId}/concept/${conceptId}`;
4
+ }
5
+
6
+ // scripts/bridge-to-astro.ts
7
+ import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from "fs";
8
+ import { join } from "path";
9
+ var CWD = process.cwd();
10
+ var PUBLIC_DATA = join(CWD, "public", "data");
11
+ var PUBLIC_ROOT = join(CWD, "public");
12
+ var CONTENT_DIR = join(CWD, ".cb-content");
13
+ function readJson(p) {
14
+ if (!existsSync(p)) return null;
15
+ return JSON.parse(readFileSync(p, "utf-8"));
16
+ }
17
+ function writeJson(dir, name, data) {
18
+ mkdirSync(dir, { recursive: true });
19
+ writeFileSync(join(dir, name), JSON.stringify(data, null, 2));
20
+ }
21
+ var registryPath = join(PUBLIC_ROOT, "datasets.json");
22
+ var siteConfigPath = join(PUBLIC_ROOT, "site-config.json");
23
+ var registry = readJson(registryPath) || [];
24
+ var siteConfig = readJson(siteConfigPath) || {};
25
+ console.log(`Bridging ${registry.length} datasets to content collections...`);
26
+ for (const reg of registry) {
27
+ const id = reg.id;
28
+ const manifestPath = join(PUBLIC_DATA, id, "manifest.json");
29
+ const manifest = readJson(manifestPath);
30
+ if (!manifest) {
31
+ console.warn(` Skipping ${id}: no manifest.json`);
32
+ continue;
33
+ }
34
+ const summary = reg.summary || {};
35
+ const entry = {
36
+ id: manifest.id || id,
37
+ title: summary.title || manifest.title || id,
38
+ description: summary.description || manifest.description || "",
39
+ uri: manifest.datasetUri || reg.datasetUri || "",
40
+ uriBase: manifest.uriBase || reg.uriBase || "",
41
+ year: manifest.year ?? summary.year ?? void 0,
42
+ status: manifest.status || summary.status || "valid",
43
+ ref: manifest.ref || reg.ref || void 0,
44
+ refAliases: manifest.refAliases || reg.refAliases || void 0,
45
+ owner: summary.owner || manifest.owner || "",
46
+ languages: manifest.languages || summary.languages || ["eng"],
47
+ conceptCount: manifest.conceptCount || summary.conceptCount || 0,
48
+ color: summary.color || manifest.color || void 0,
49
+ tags: summary.tags || manifest.tags || [],
50
+ sections: manifest.sections || [],
51
+ sourceRepo: manifest.sourceRepo || "",
52
+ lastUpdated: manifest.lastUpdated || ""
53
+ };
54
+ Object.keys(entry).forEach((k) => entry[k] === void 0 && delete entry[k]);
55
+ writeJson(join(CONTENT_DIR, "datasets"), `${id}.json`, entry);
56
+ console.log(` Dataset: ${id} (${entry.conceptCount} concepts)`);
57
+ const indexPath = join(PUBLIC_DATA, id, "index.json");
58
+ const index = readJson(indexPath);
59
+ if (index && index.concepts) {
60
+ for (const concept of index.concepts) {
61
+ if (!concept) continue;
62
+ const conceptEntry = {
63
+ registerId: id,
64
+ conceptId: concept.id,
65
+ uri: buildConceptUri(entry.uriBase || "", id, concept.id),
66
+ status: concept.status || "valid",
67
+ designations: concept.designations || {},
68
+ eng: concept.eng || concept.designations?.eng || "",
69
+ groups: concept.groups || [],
70
+ tags: []
71
+ };
72
+ const fullConceptPath = join(PUBLIC_DATA, id, "concepts", `${concept.id}.json`);
73
+ const fullConcept = readJson(fullConceptPath);
74
+ if (fullConcept) {
75
+ const lc = fullConcept["gl:localizedConcept"] || fullConcept.localizedConcept || {};
76
+ const localizations = {};
77
+ for (const [lang, loc] of Object.entries(lc)) {
78
+ localizations[lang] = {
79
+ languageCode: loc["gl:languageCode"] || lang,
80
+ terms: (loc["gl:designation"] || []).map((d) => ({ designation: d["gl:term"] || d.term || "", normativeStatus: d["gl:normativeStatus"] || d.normativeStatus })).filter((d) => d.designation),
81
+ definitions: (loc["gl:definition"] || []).map((d) => ({ content: d["gl:content"] || d.content || "" })).filter((d) => d.content),
82
+ notes: (loc["gl:notes"] || []).map((n) => ({ content: n["gl:content"] || n.content || "" })).filter((n) => n.content),
83
+ examples: (loc["gl:examples"] || []).map((e) => ({ content: e["gl:content"] || e.content || "" })).filter((e) => e.content)
84
+ };
85
+ }
86
+ conceptEntry.localizations = localizations;
87
+ conceptEntry.languages = Object.keys(localizations);
88
+ }
89
+ writeJson(
90
+ join(CONTENT_DIR, "concepts", id),
91
+ `${concept.id}.json`,
92
+ conceptEntry
93
+ );
94
+ }
95
+ console.log(` ${index.concepts.filter(Boolean).length} concepts bridged`);
96
+ }
97
+ }
98
+ var groups = siteConfig.datasetGroups || [];
99
+ for (const g of groups) {
100
+ const entry = {
101
+ id: g.id,
102
+ label: g.label || g.id,
103
+ kind: g.kind || (g.series ? "lineage" : "default"),
104
+ description: g.description || "",
105
+ current: g.current || void 0,
106
+ datasets: g.datasets || [],
107
+ color: g.color || void 0
108
+ };
109
+ Object.keys(entry).forEach((k) => entry[k] === void 0 && delete entry[k]);
110
+ writeJson(join(CONTENT_DIR, "groups"), `${g.id}.json`, entry);
111
+ console.log(` Group: ${g.id} (${entry.datasets.length} datasets)`);
112
+ }
113
+ var pagesDir = join(CWD, "public", "pages");
114
+ if (existsSync(pagesDir)) {
115
+ mkdirSync(join(CONTENT_DIR, "pages"), { recursive: true });
116
+ for (const file of readdirSync(pagesDir)) {
117
+ if (!file.endsWith(".json")) continue;
118
+ const page = readJson(join(pagesDir, file));
119
+ if (!page) continue;
120
+ const slug = file.replace(".json", "");
121
+ const md = `---
122
+ title: "${page.title || slug}"
123
+ type: "page"
124
+ ---
125
+
126
+ ${page.html || ""}
127
+ `;
128
+ writeFileSync(join(CONTENT_DIR, "pages", `${slug}.md`), md);
129
+ }
130
+ console.log(" Pages bridged from public/pages/");
131
+ }
132
+ console.log("Data bridge complete.");
@@ -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
 
6
4
  /**
@@ -79,7 +77,7 @@ for (const reg of registry) {
79
77
  if (index && index.concepts) {
80
78
  for (const concept of index.concepts) {
81
79
  if (!concept) continue;
82
- const conceptEntry = {
80
+ const conceptEntry: Record<string, any> = {
83
81
  registerId: id,
84
82
  conceptId: concept.id,
85
83
  uri: buildConceptUri(entry.uriBase || '', id, concept.id),