@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.
- package/README.md +45 -2
- package/cli/index.mjs +10 -13
- package/cli/index.ts +9 -11
- package/data/concept-model/shapes/glossarist.concept.yaml.schema.json +255 -0
- package/package.json +18 -12
- package/scripts/__tests__/{bibliography.test.mjs → bibliography.test.ts} +1 -1
- package/scripts/__tests__/{cli-script-contract.test.mjs → cli-script-contract.test.ts} +3 -3
- package/scripts/__tests__/{concept-groups.test.mjs → concept-groups.test.ts} +1 -1
- package/scripts/__tests__/{doctor.test.mjs → doctor.test.ts} +1 -1
- package/scripts/__tests__/{fetch-datasets.test.mjs → fetch-datasets.test.ts} +1 -1
- package/scripts/__tests__/{first-non-empty.test.mjs → first-non-empty.test.ts} +1 -1
- package/scripts/__tests__/{process-about-pages.test.mjs → process-about-pages.test.ts} +1 -1
- package/scripts/bridge-to-astro.js +132 -0
- package/scripts/{bridge-to-astro.mjs → bridge-to-astro.ts} +2 -4
- package/scripts/build-edges.js +242 -336
- package/scripts/build-edges.ts +572 -0
- package/scripts/build-scripts.mjs +22 -0
- package/scripts/check-syntax.js +81 -0
- package/scripts/{check-syntax.mjs → check-syntax.ts} +20 -13
- package/scripts/doctor.js +278 -0
- package/scripts/extract-source-refs.js +16 -24
- package/scripts/extract-source-refs.ts +32 -0
- package/scripts/fetch-datasets.js +278 -0
- package/scripts/{fetch-datasets.mjs → fetch-datasets.ts} +2 -2
- package/scripts/generate-404.js +10 -11
- package/scripts/generate-404.ts +15 -0
- package/scripts/generate-data.js +2220 -0
- package/scripts/{generate-data.mjs → generate-data.ts} +73 -460
- package/scripts/generate-ontology-data.js +139 -0
- package/scripts/generate-ontology-schema.js +472 -0
- package/scripts/{generate-ontology-schema.mjs → generate-ontology-schema.ts} +2 -2
- package/scripts/lib/{build-cache.mjs → build-cache.ts} +3 -2
- package/scripts/lib/concept-formats.ts +206 -0
- package/scripts/lib/concept-uri.ts +14 -0
- package/scripts/lib/{dataset-turtle.mjs → dataset-turtle.ts} +4 -3
- package/scripts/lib/harmonize-concept.ts +86 -0
- package/scripts/lib/jsonld-emitter.ts +169 -0
- package/scripts/lib/{local-path-safety.mjs → local-path-safety.ts} +6 -2
- package/scripts/lib/yaml-types.ts +262 -0
- package/scripts/load-site-config.js +83 -0
- package/scripts/migrate-v1-to-v3.js +113 -0
- package/scripts/normalize-yaml.js +96 -0
- package/scripts/process-about-pages.js +241 -0
- package/scripts/{process-about-pages.mjs → process-about-pages.ts} +1 -1
- package/scripts/smoke.js +211 -0
- package/scripts/{smoke.mjs → smoke.ts} +4 -3
- package/scripts/sync-concept-model.js +63 -0
- package/scripts/validate-shacl.js +152 -0
- package/scripts/{validate-shacl.mjs → validate-shacl.ts} +5 -5
- package/scripts/validate-yaml.js +132 -0
- package/scripts/validate-yaml.ts +144 -0
- package/src/__tests__/extract-source-refs.test.ts +2 -3
- package/src/__tests__/perf/serialization-perf.test.ts +5 -5
- package/src/__tests__/published-package-contract.test.ts +84 -0
- package/src/__tests__/scripts/agents-turtle.test.ts +1 -1
- package/src/__tests__/scripts/bibliography-turtle.test.ts +1 -1
- package/src/__tests__/scripts/build-activity-turtle.test.ts +1 -1
- package/src/__tests__/scripts/build-cache.test.ts +1 -1
- package/src/__tests__/scripts/build-integration.test.ts +19 -19
- package/src/__tests__/scripts/dataset-turtle.test.ts +1 -1
- package/src/__tests__/scripts/migrate-v1-to-v3.test.ts +1 -1
- package/src/__tests__/scripts/normalize-yaml.test.ts +1 -1
- package/src/__tests__/scripts/turtle-escape.test.ts +1 -1
- package/src/__tests__/scripts/validate-yaml.test.ts +76 -0
- package/src/__tests__/scripts/version-turtle.test.ts +1 -1
- package/src/__tests__/scripts/vocab-turtle.test.ts +1 -1
- package/src/__tests__/scripts-syntax.test.ts +4 -4
- package/src/__tests__/use-rdf-document.test.ts +2 -3
- package/src/__tests__/utils/content-renderer-xss.test.ts +57 -0
- package/src/__tests__/validate-shacl.test.ts +3 -3
- package/src/adapters/wire/index.ts +69 -0
- package/src/data/ontology-schema.json +1336 -183
- package/src/utils/content-renderer.ts +7 -3
- package/src/utils/url-safety.ts +1 -5
- package/tsconfig.json +2 -2
- package/vite.config.ts +1 -1
- package/src/__tests__/composables/use-concept-edges-v2.test.ts +0 -167
- package/src/__tests__/composables/use-concept-edges-v2.test.ts.bak +0 -166
- package/src/types/agents-version-turtle.d.ts +0 -27
- package/src/types/bibliography-turtle.d.ts +0 -12
- package/src/types/build-activity-turtle.d.ts +0 -16
- package/src/types/build-cache.d.ts +0 -20
- package/src/types/dataset-turtle.d.ts +0 -32
- package/src/types/normalize-yaml.d.ts +0 -16
- package/src/types/turtle-escape.d.ts +0 -6
- package/src/types/vocab-turtle.d.ts +0 -13
- /package/scripts/{doctor.mjs → doctor.ts} +0 -0
- /package/scripts/{generate-ontology-data.mjs → generate-ontology-data.ts} +0 -0
- /package/scripts/lib/{agents-turtle.mjs → agents-turtle.ts} +0 -0
- /package/scripts/lib/{bibliography-turtle.mjs → bibliography-turtle.ts} +0 -0
- /package/scripts/lib/{bibliography.mjs → bibliography.ts} +0 -0
- /package/scripts/lib/build/{image-assets.mjs → image-assets.ts} +0 -0
- /package/scripts/lib/build/{non-verbal-consumer.mjs → non-verbal-consumer.ts} +0 -0
- /package/scripts/lib/{build-activity-turtle.mjs → build-activity-turtle.ts} +0 -0
- /package/scripts/lib/{concept-groups.mjs → concept-groups.ts} +0 -0
- /package/scripts/lib/{first-non-empty.mjs → first-non-empty.ts} +0 -0
- /package/scripts/lib/{turtle-escape.mjs → turtle-escape.ts} +0 -0
- /package/scripts/lib/{version-turtle.mjs → version-turtle.ts} +0 -0
- /package/scripts/lib/{vocab-turtle.mjs → vocab-turtle.ts} +0 -0
- /package/scripts/{load-site-config.mjs → load-site-config.ts} +0 -0
- /package/scripts/{migrate-v1-to-v3.mjs → migrate-v1-to-v3.ts} +0 -0
- /package/scripts/{normalize-yaml.mjs → normalize-yaml.ts} +0 -0
- /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
|
-
|
|
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),
|