glossarist 0.4.47 → 0.4.49
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 +1 -1
- package/src/concept-reader.ts +4 -3
- package/src/rdf/agents-emitter.ts +5 -5
- package/src/rdf/bibliography-emitter.ts +3 -4
- package/src/rdf/build-activity-emitter.ts +1 -2
- package/src/rdf/curie.ts +1 -0
- package/src/rdf/dataset-emitter.ts +1 -2
- package/src/rdf/document-writer.ts +2 -3
- package/src/rdf/gloss-concept.ts +2 -2
- package/src/rdf/gloss-designation.ts +2 -3
- package/src/rdf/group-emitter.ts +1 -2
- package/src/rdf/image-variant-emitter.ts +1 -2
- package/src/rdf/prefixes.ts +6 -2
- package/src/rdf/provenance-emitter.ts +1 -2
- package/src/rdf/sections-builder.ts +1 -1
- package/src/rdf/version-emitter.ts +1 -1
- package/src/rdf/vocabulary-emitter.ts +1 -1
- package/src/validators/concept-validator.ts +1 -0
package/package.json
CHANGED
package/src/concept-reader.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Concept } from './models/concept.js';
|
|
2
|
+
import type { RegisterJson } from './models/register.js';
|
|
2
3
|
import fs from 'fs';
|
|
3
4
|
import path from 'path';
|
|
4
5
|
import * as yaml from 'js-yaml';
|
|
@@ -38,7 +39,7 @@ export function readConcepts(dir) {
|
|
|
38
39
|
.filter(f => f.endsWith('.yaml') && f !== 'register.yaml')
|
|
39
40
|
.sort(naturalSort);
|
|
40
41
|
|
|
41
|
-
const concepts = [];
|
|
42
|
+
const concepts: Concept[] = [];
|
|
42
43
|
for (const file of files) {
|
|
43
44
|
const raw = fs.readFileSync(path.join(dir, file), 'utf8');
|
|
44
45
|
const concept = conceptParser.parse(raw, file);
|
|
@@ -150,5 +151,5 @@ export function readRegister(dir) {
|
|
|
150
151
|
const p = path.join(dir, 'register.yaml');
|
|
151
152
|
if (!fs.existsSync(p)) return null;
|
|
152
153
|
const raw = yaml.load(fs.readFileSync(p, 'utf8'));
|
|
153
|
-
return Register.fromJSON(raw);
|
|
154
|
+
return Register.fromJSON(raw as RegisterJson);
|
|
154
155
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// prov:Organization, and the person is linked via prov:actedOnBehalfOf.
|
|
9
9
|
|
|
10
10
|
import { namedNode, literal, quad } from './terms.js';
|
|
11
|
-
import { PREFIXES } from './
|
|
11
|
+
import { PREFIXES } from './prefixes.js';
|
|
12
12
|
import { RDF_TYPE } from './curie.js';
|
|
13
13
|
|
|
14
14
|
const PROV_NS = PREFIXES.prov;
|
|
@@ -94,7 +94,7 @@ export function agentsFromContributors(contributors, agentBase) {
|
|
|
94
94
|
* @param {string} [options.orgBase] — default https://glossarist.org/org
|
|
95
95
|
* @returns {Generator<Quad, void, unknown>}
|
|
96
96
|
*/
|
|
97
|
-
export function* agentsToQuads(agents, options = {}) {
|
|
97
|
+
export function* agentsToQuads(agents: Record<string, unknown>[], options: Record<string, unknown> = {}) {
|
|
98
98
|
const orgBase = options.orgBase;
|
|
99
99
|
if (!orgBase) throw new Error('agentsToQuads requires options.orgBase — the deployment canonical URI root for organizations.');
|
|
100
100
|
const emittedOrgs = new Set();
|
|
@@ -104,10 +104,10 @@ export function* agentsToQuads(agents, options = {}) {
|
|
|
104
104
|
yield quad(person, namedNode(RDF_TYPE), namedNode(FOAF.Person));
|
|
105
105
|
yield quad(person, namedNode(RDF_TYPE), namedNode(PROV.Person));
|
|
106
106
|
yield quad(person, namedNode(RDF_TYPE), namedNode(PROV.Agent));
|
|
107
|
-
yield quad(person, namedNode(FOAF.name), literal(a.name));
|
|
107
|
+
yield quad(person, namedNode(FOAF.name), literal((a as Record<string, unknown>).name as string));
|
|
108
108
|
|
|
109
|
-
if (a.email) {
|
|
110
|
-
yield quad(person, namedNode(FOAF.mbox), namedNode(`mailto:${a.email}`));
|
|
109
|
+
if ((a as Record<string, unknown>).email as string) {
|
|
110
|
+
yield quad(person, namedNode(FOAF.mbox), namedNode(`mailto:${(a as Record<string, unknown>).email as string}`));
|
|
111
111
|
}
|
|
112
112
|
if (a.url) {
|
|
113
113
|
yield quad(person, namedNode(RDFS.seeAlso), namedNode(a.url));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Bibliography emitter — emits dcterms:BibliographicResource per
|
|
3
2
|
// bibliography entry. Mirrors concept-browser's bibliography-emitter.ts.
|
|
4
3
|
//
|
|
@@ -11,7 +10,7 @@
|
|
|
11
10
|
// - dcterms:isPartOf (parent dataset)
|
|
12
11
|
|
|
13
12
|
import { namedNode, literal, quad } from './terms.js';
|
|
14
|
-
import { PREFIXES } from './
|
|
13
|
+
import { PREFIXES } from './prefixes.js';
|
|
15
14
|
import { RDF_TYPE } from './curie.js';
|
|
16
15
|
|
|
17
16
|
// Namespace IRIs from canonical PREFIXES. foaf is absent from the
|
|
@@ -106,9 +105,9 @@ export function* bibliographyToQuads(input) {
|
|
|
106
105
|
export function normalizeBibliographyData(raw) {
|
|
107
106
|
if (!raw || typeof raw !== 'object') return [];
|
|
108
107
|
if (Array.isArray(raw.bibliography)) {
|
|
109
|
-
return raw.bibliography.map(e => entryFromV3(e));
|
|
108
|
+
return raw.bibliography.map(e => entryFromV3(e, null));
|
|
110
109
|
}
|
|
111
|
-
const entries = [];
|
|
110
|
+
const entries: unknown[] = [];
|
|
112
111
|
for (const [id, value] of Object.entries(raw)) {
|
|
113
112
|
if (!value || typeof value !== 'object') continue;
|
|
114
113
|
entries.push(entryFromV3(value, id));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Build activity emitter — emits prov:Activity per build run.
|
|
3
2
|
// Mirrors concept-browser's build-activity-emitter.ts.
|
|
4
3
|
//
|
|
@@ -10,7 +9,7 @@
|
|
|
10
9
|
// - prov:wasAssociatedWith for the CI bot agent
|
|
11
10
|
|
|
12
11
|
import { namedNode, literal, quad } from './terms.js';
|
|
13
|
-
import { PREFIXES } from './
|
|
12
|
+
import { PREFIXES } from './prefixes.js';
|
|
14
13
|
import { RDF_TYPE } from './curie.js';
|
|
15
14
|
|
|
16
15
|
const PROV_NS = PREFIXES.prov;
|
package/src/rdf/curie.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
|
+
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
3
|
// CURIE helpers — resolve/compact IRIs against the canonical PREFIXES.
|
|
3
4
|
//
|
|
4
5
|
// Single source of truth for CURIE ↔ IRI conversion. Previously
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Dataset emitter — emits dcat:Dataset + skos:ConceptScheme per
|
|
3
2
|
// register. Mirrors concept-browser's dataset-emitter.ts.
|
|
4
3
|
//
|
|
@@ -12,7 +11,7 @@
|
|
|
12
11
|
// for cascading section membership).
|
|
13
12
|
|
|
14
13
|
import { namedNode, blankNode, literal, quad } from './terms.js';
|
|
15
|
-
import { PREFIXES } from './
|
|
14
|
+
import { PREFIXES } from './prefixes.js';
|
|
16
15
|
import { RDF_TYPE } from './curie.js';
|
|
17
16
|
import { deterministicBnodeId } from './bnode-id.js';
|
|
18
17
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Quads → canonical Turtle / N-Triples / JSON-LD document.
|
|
3
2
|
//
|
|
4
3
|
// Turtle is produced via N3.Writer. JSON-LD via the `jsonld` package
|
|
@@ -6,12 +5,12 @@
|
|
|
6
5
|
// as a stable fallback that doesn't depend on prefix maps.
|
|
7
6
|
import { Writer as N3Writer } from 'n3';
|
|
8
7
|
import jsonld from 'jsonld';
|
|
9
|
-
import { PREFIXES } from './
|
|
8
|
+
import { PREFIXES } from './prefixes.js';
|
|
10
9
|
|
|
11
10
|
// Collects all quads yielded by an emitter into an array. Useful for tests
|
|
12
11
|
// and for callers that want to inspect the quad stream directly.
|
|
13
12
|
export function collectQuads(quadsIterable) {
|
|
14
|
-
const out = [];
|
|
13
|
+
const out: unknown[] = [];
|
|
15
14
|
for (const q of quadsIterable) out.push(q);
|
|
16
15
|
return out;
|
|
17
16
|
}
|
package/src/rdf/gloss-concept.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { namedNode, literal, quad } from './terms.js';
|
|
|
19
19
|
// (2) add one entry here. Per TODO Phase 6e this should be a
|
|
20
20
|
// self-registering registry; for the two current types, the dispatch
|
|
21
21
|
// table is simpler and keeps the dependency graph acyclic.
|
|
22
|
-
const HYPEREDGE_EMITTERS = new Map([
|
|
22
|
+
const HYPEREDGE_EMITTERS: Map<unknown, Record<string, unknown>> = new Map([
|
|
23
23
|
[PartitiveHyperedge, {
|
|
24
24
|
linkPredicate: PRED.gloss.hasPartitiveRelation,
|
|
25
25
|
subjectUri: partitiveRelationSubjectUri,
|
|
@@ -97,7 +97,7 @@ export function* conceptToQuads(concept, options) {
|
|
|
97
97
|
// emitter table.
|
|
98
98
|
let relIdx = 0;
|
|
99
99
|
for (const relation of concept.relations ?? []) {
|
|
100
|
-
const emitter = HYPEREDGE_EMITTERS.get(relation.constructor);
|
|
100
|
+
const emitter = HYPEREDGE_EMITTERS.get(relation.constructor) as unknown as { linkPredicate: string; subjectUri: (a: string, b: unknown, c: number) => string; toQuads: (a: unknown, b: { parentUri: string; index: number }) => Iterable<unknown> } | undefined;
|
|
101
101
|
if (!emitter) {
|
|
102
102
|
// Unknown hyperedge type — skip rather than crash. The OCP
|
|
103
103
|
// contract (Phase 11) tests that new types register an emitter;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Designation → RDF quads. Mirrors glossarist-ruby's
|
|
3
2
|
// `Rdf::GlossDesignation` + the per-subtype classes (GlossExpression,
|
|
4
3
|
// GlossAbbreviation, etc.). The ontology class for each subtype is
|
|
@@ -66,8 +65,8 @@ export function* designationToQuads(designation, { subjectUri, language, index }
|
|
|
66
65
|
// backward compatibility with simpler designations.
|
|
67
66
|
const booleanType = namedNode(XSD_BOOLEAN);
|
|
68
67
|
for (const [field, predicate] of BOOLEAN_FLAGS) {
|
|
69
|
-
if (designation[field]) {
|
|
70
|
-
yield quad(namedNode(desigSubject), namedNode(predicate), literal('true', booleanType));
|
|
68
|
+
if (designation[field as string]) {
|
|
69
|
+
yield quad(namedNode(desigSubject), namedNode(predicate as string), literal('true', booleanType));
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
}
|
package/src/rdf/group-emitter.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Group emitter — emits dcat:DatasetSeries (lineage) or dcat:Catalog
|
|
3
2
|
// (topic/family/collection) for dataset groups. Mirrors concept-browser's
|
|
4
3
|
// group-emitter.ts.
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
// Both kinds are also typed as skos:ConceptScheme for SKOS interop.
|
|
14
13
|
|
|
15
14
|
import { namedNode, literal, quad } from './terms.js';
|
|
16
|
-
import { PREFIXES } from './
|
|
15
|
+
import { PREFIXES } from './prefixes.js';
|
|
17
16
|
import { RDF_TYPE } from './curie.js';
|
|
18
17
|
|
|
19
18
|
// Namespace IRIs from canonical PREFIXES.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Image variant emitter — emits foaf:Image per format/language variant
|
|
3
2
|
// of a dataset figure. Mirrors concept-browser's image-variant-emitter.ts.
|
|
4
3
|
//
|
|
@@ -9,7 +8,7 @@
|
|
|
9
8
|
// - dcat:downloadURL (canonical download)
|
|
10
9
|
|
|
11
10
|
import { namedNode, literal, quad } from './terms.js';
|
|
12
|
-
import { PREFIXES } from './
|
|
11
|
+
import { PREFIXES } from './prefixes.js';
|
|
13
12
|
import { RDF_TYPE } from './curie.js';
|
|
14
13
|
|
|
15
14
|
const FOAF_NS = PREFIXES.foaf ?? 'http://xmlns.com/foaf/0.1/';
|
package/src/rdf/prefixes.ts
CHANGED
|
@@ -6,9 +6,13 @@
|
|
|
6
6
|
// constants (`rdf:type`, `skos:Concept`) because JSON-LD handles them via
|
|
7
7
|
// the `@type` keyword. We construct those from the namespace URIs here so
|
|
8
8
|
// downstream emitters don't have to repeat the construction.
|
|
9
|
-
import { PRED, PREFIXES } from './predicates.js';
|
|
9
|
+
import { PRED, PREFIXES as _PREFIXES } from './predicates.js';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// Widen the type so emitters can access keys not in the JSON-LD context
|
|
12
|
+
// (foaf, dcat) via `PREFIXES.foaf ?? 'fallback'`. The runtime values
|
|
13
|
+
// are the same; the type just permits unknown-key access.
|
|
14
|
+
export const PREFIXES: Record<string, string> = _PREFIXES as Record<string, string>;
|
|
15
|
+
export { PRED };
|
|
12
16
|
|
|
13
17
|
// SKOS-XL label predicates — same local name as SKOS, so we construct them
|
|
14
18
|
// from the SKOS-XL namespace URI.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Provenance emitter — emits prov:wasGeneratedBy + prov:Activity quads
|
|
3
2
|
// for any resource that needs build/view-time provenance.
|
|
4
3
|
//
|
|
@@ -7,7 +6,7 @@
|
|
|
7
6
|
// on standard RDF/JS Quad[] (no RdfGraph abstraction).
|
|
8
7
|
|
|
9
8
|
import { namedNode, blankNode, literal, quad } from './terms.js';
|
|
10
|
-
import { PREFIXES } from './
|
|
9
|
+
import { PREFIXES } from './prefixes.js';
|
|
11
10
|
import { RDF_TYPE, RDFS_LABEL } from './curie.js';
|
|
12
11
|
import { deterministicBnodeId } from './bnode-id.js';
|
|
13
12
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// - prov:wasAssociatedWith (optional agent)
|
|
10
10
|
|
|
11
11
|
import { namedNode, literal, quad } from './terms.js';
|
|
12
|
-
import { PREFIXES } from './
|
|
12
|
+
import { PREFIXES } from './prefixes.js';
|
|
13
13
|
import { RDF_TYPE } from './curie.js';
|
|
14
14
|
|
|
15
15
|
const PROV_NS = PREFIXES.prov;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// PREFIXES.
|
|
14
14
|
|
|
15
15
|
import { namedNode, literal, quad } from './terms.js';
|
|
16
|
-
import { PREFIXES } from './
|
|
16
|
+
import { PREFIXES } from './prefixes.js';
|
|
17
17
|
import { resolveIri, RDF_TYPE, RDFS_LABEL } from './curie.js';
|
|
18
18
|
|
|
19
19
|
const SKOS_NS = PREFIXES.skos;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
|
+
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
3
|
import { ValidationRule } from './validation-rule.js';
|
|
3
4
|
import { ValidationResult } from './validation-result.js';
|
|
4
5
|
|