glossarist 0.4.48 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glossarist",
3
- "version": "0.4.48",
3
+ "version": "0.4.49",
4
4
  "description": "JavaScript SDK for Glossarist GCR packages — read, write, validate, and manage terminology concepts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -1,4 +1,5 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
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
  }
@@ -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
  //
@@ -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));
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
  // Quads → canonical Turtle / N-Triples / JSON-LD document.
3
2
  //
4
3
  // Turtle is produced via N3.Writer. JSON-LD via the `jsonld` package
@@ -11,7 +10,7 @@ import { PREFIXES } from './prefixes.js';
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
  }
@@ -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
  }
@@ -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