@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.
- package/README.md +87 -2
- package/cli/index.mjs +15 -15
- package/cli/index.ts +9 -11
- package/data/concept-model/shapes/glossarist.concept.yaml.schema.json +255 -0
- package/package.json +14 -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.mjs → bridge-to-astro.ts} +2 -4
- package/scripts/{build-edges.js → build-edges.ts} +11 -13
- package/scripts/{check-syntax.mjs → check-syntax.ts} +20 -13
- package/scripts/{fetch-datasets.mjs → fetch-datasets.ts} +2 -2
- package/scripts/{generate-data.mjs → generate-data.ts} +73 -460
- 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/{process-about-pages.mjs → process-about-pages.ts} +1 -1
- package/scripts/{smoke.mjs → smoke.ts} +4 -3
- package/scripts/{validate-shacl.mjs → validate-shacl.ts} +5 -5
- 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__/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 +2 -2
- package/src/__tests__/use-rdf-document.test.ts +2 -3
- package/src/__tests__/utils/content-renderer-xss.test.ts +57 -0
- package/src/__tests__/utils/inline-content-kinds.test.ts +139 -0
- package/src/__tests__/validate-shacl.test.ts +3 -3
- package/src/adapters/wire/index.ts +69 -0
- package/src/pages/[...path].astro +1 -0
- package/src/router/index.ts +5 -0
- package/src/utils/content-renderer.ts +106 -23
- package/src/utils/url-safety.ts +1 -5
- package/src/views/learn/LearnInlineContentView.vue +128 -0
- 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/{extract-source-refs.js → extract-source-refs.ts} +0 -0
- /package/scripts/{generate-404.js → generate-404.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
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
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 (
|
|
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
|
-
|
|
43
|
-
|
|
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
|
|
24
|
-
import { assertLocalPathSafe } from './lib/local-path-safety
|
|
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
|
|