glossarist 0.4.48 → 0.4.50

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.
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  // NonVerbal entity → RDF quads. Mirrors the v3.1.0 concept-model
3
2
  // NonVerbal class hierarchy. Two distinct shapes:
4
3
  //
@@ -46,12 +45,15 @@ export function* nonVerbalRepToQuads(nvr, { parentUri, index, language = null })
46
45
  }
47
46
  }
48
47
  if (nvr.caption) {
48
+ // @ts-expect-error TODO(Phase 2e): type this fully
49
49
  yield quad(namedNode(subject), namedNode(PRED.gloss.caption), literal(nvr.caption, language));
50
50
  }
51
51
  if (nvr.description) {
52
+ // @ts-expect-error TODO(Phase 2e): type this fully
52
53
  yield quad(namedNode(subject), namedNode(DCTERMS_DESCRIPTION), literal(nvr.description, language));
53
54
  }
54
55
  if (nvr.alt) {
56
+ // @ts-expect-error TODO(Phase 2e): type this fully
55
57
  yield quad(namedNode(subject), namedNode(PRED.gloss.altText), literal(nvr.alt, language));
56
58
  }
57
59
 
@@ -85,12 +87,15 @@ export function* nonVerbalEntityToQuads(entity, options) {
85
87
  yield quad(s, namedNode(WELL_KNOWN.rdfType), namedNode(`${PRED.gloss.$ns}${entity.rdfClass()}`));
86
88
 
87
89
  if (entity.caption) {
90
+ // @ts-expect-error TODO(Phase 2e): type this fully
88
91
  yield quad(s, namedNode(PRED.gloss.caption), literal(entity.caption, null));
89
92
  }
90
93
  if (entity.description) {
94
+ // @ts-expect-error TODO(Phase 2e): type this fully
91
95
  yield quad(s, namedNode(DCTERMS_DESCRIPTION), literal(entity.description, null));
92
96
  }
93
97
  if (entity.alt) {
98
+ // @ts-expect-error TODO(Phase 2e): type this fully
94
99
  yield quad(s, namedNode(PRED.gloss.altText), literal(entity.alt, null));
95
100
  }
96
101
 
@@ -152,12 +157,15 @@ function* subfigureQuads(figure, subjectUri, _options) {
152
157
  yield quad(s, namedNode(WELL_KNOWN.rdfType), namedNode(`${PRED.gloss.$ns}${figure.rdfClass()}`));
153
158
 
154
159
  if (figure.caption) {
160
+ // @ts-expect-error TODO(Phase 2e): type this fully
155
161
  yield quad(s, namedNode(PRED.gloss.caption), literal(figure.caption, null));
156
162
  }
157
163
  if (figure.description) {
164
+ // @ts-expect-error TODO(Phase 2e): type this fully
158
165
  yield quad(s, namedNode(DCTERMS_DESCRIPTION), literal(figure.description, null));
159
166
  }
160
167
  if (figure.alt) {
168
+ // @ts-expect-error TODO(Phase 2e): type this fully
161
169
  yield quad(s, namedNode(PRED.gloss.altText), literal(figure.alt, null));
162
170
  }
163
171
 
@@ -175,6 +183,7 @@ function* subfigureQuads(figure, subjectUri, _options) {
175
183
 
176
184
  function* tableQuads(table, s) {
177
185
  if (table.content) {
186
+ // @ts-expect-error TODO(Phase 2e): type this fully
178
187
  yield quad(s, namedNode(PRED.gloss.content), literal(table.content, null));
179
188
  }
180
189
  if (table.format) {
@@ -184,6 +193,7 @@ function* tableQuads(table, s) {
184
193
 
185
194
  function* formulaQuads(formula, s) {
186
195
  if (formula.expression) {
196
+ // @ts-expect-error TODO(Phase 2e): type this fully
187
197
  yield quad(s, namedNode(PRED.gloss.expression), literal(formula.expression, null));
188
198
  }
189
199
  if (formula.notation) {
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  // Sections builder — transforms a Quad[] into the ClassInstance[]
3
2
  // shape consumed by Vue UI components (RdfInstanceSection,
4
3
  // RdfInstanceHeader, RdfSourcePanel).
@@ -51,6 +50,7 @@ const SKOS_PREF_LABEL = `${PREFIXES.skos}prefLabel`;
51
50
  * @returns {ClassInstance[]}
52
51
  */
53
52
  export function quadSectionsToClassInstances(quads, options = {}) {
53
+ // @ts-expect-error TODO(Phase 2e): type this fully
54
54
  const language = options.language ?? 'eng';
55
55
  if (!quads || quads.length === 0) return [];
56
56
 
@@ -66,6 +66,7 @@ export function quadSectionsToClassInstances(quads, options = {}) {
66
66
  const target = isBnode ? bnodeQuads : bySubject;
67
67
  if (!target.has(key)) {
68
68
  target.set(key, { subject: subj, quads: [] });
69
+ // @ts-expect-error TODO(Phase 2e): type this fully
69
70
  if (!isBnode) order.push(key);
70
71
  }
71
72
  target.get(key).quads.push(q);
@@ -74,6 +75,7 @@ export function quadSectionsToClassInstances(quads, options = {}) {
74
75
  const result = [];
75
76
  for (const key of order) {
76
77
  const entry = bySubject.get(key);
78
+ // @ts-expect-error TODO(Phase 2e): type this fully
77
79
  result.push(resourceToClassInstance(entry.subject, entry.quads, bnodeQuads, language));
78
80
  }
79
81
  return result;
@@ -87,15 +89,19 @@ function resourceToClassInstance(subject, quads, bnodeQuads, language) {
87
89
 
88
90
  for (const q of quads) {
89
91
  if (q.predicate.value === RDF_TYPE) {
92
+ // @ts-expect-error TODO(Phase 2e): type this fully
90
93
  types.push(q.object.value);
91
94
  } else if (q.predicate.value === SKOS_PREF_LABEL) {
92
95
  // Prefer prefLabel in the requested language; first one wins per lang
96
+ // @ts-expect-error TODO(Phase 2e): type this fully
93
97
  if (!prefLabel || (q.object.language === language && prefLabel.language !== language)) {
98
+ // @ts-expect-error TODO(Phase 2e): type this fully
94
99
  prefLabel = { value: q.object.value, language: q.object.language };
95
100
  }
96
101
  } else if (q.predicate.value === RDFS_LABEL && !rdfsLabel) {
97
102
  rdfsLabel = q.object.value;
98
103
  } else {
104
+ // @ts-expect-error TODO(Phase 2e): type this fully
99
105
  otherQuads.push(q);
100
106
  }
101
107
  }
@@ -107,6 +113,7 @@ function resourceToClassInstance(subject, quads, bnodeQuads, language) {
107
113
  const rawClassId = types.length > 0 ? types[0] : '';
108
114
  const classId = rawClassId ? compactIri(rawClassId) : '';
109
115
  const classLabel = deriveClassLabel(rawClassId);
116
+ // @ts-expect-error TODO(Phase 2e): type this fully
110
117
  const label = prefLabel?.value ?? rdfsLabel ?? deriveSubjectLabel(subjectStr);
111
118
 
112
119
  // Group predicates (preserve insertion order). Compact IRIs to CURIEs
@@ -116,16 +123,21 @@ function resourceToClassInstance(subject, quads, bnodeQuads, language) {
116
123
  const seenPredKeys = new Set();
117
124
 
118
125
  for (const q of otherQuads) {
126
+ // @ts-expect-error TODO(Phase 2e): type this fully
119
127
  const isBnodeObj = q.object.termType === 'BlankNode';
128
+ // @ts-expect-error TODO(Phase 2e): type this fully
120
129
  const formatted = formatTerm(q.object, bnodeQuads);
121
130
  if (formatted === '') continue;
131
+ // @ts-expect-error TODO(Phase 2e): type this fully
122
132
  const predicate = compactIri(q.predicate.value);
123
133
  const dedupKey = `${predicate}#${isBnodeObj ? 'n' : 'f'}#${formatted}`;
124
134
  if (seenPredKeys.has(dedupKey)) continue;
125
135
  seenPredKeys.add(dedupKey);
126
136
 
127
137
  const prop = { predicate, values: [formatted] };
138
+ // @ts-expect-error TODO(Phase 2e): type this fully
128
139
  if (isBnodeObj) prop.nested = true;
140
+ // @ts-expect-error TODO(Phase 2e): type this fully
129
141
  props.push(prop);
130
142
  }
131
143
 
package/src/rdf/shacl.ts CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  // SHACL validator wrapper. Loads vendored concept-model shapes once and
3
2
  // validates any RDFJS Dataset against them. Mirrors the mechanics of
4
3
  // glossarist-ruby's `Glossarist::Validation::ShaclValidator`.
@@ -29,6 +28,7 @@ const FACTORY = {
29
28
  dataset: rdfDatasetFactory.dataset.bind(rdfDatasetFactory),
30
29
  };
31
30
  const createDataset = FACTORY.dataset;
31
+ // @ts-expect-error TODO(Phase 2e): type this fully
32
32
  const ShaclValidatorCtor = ShaclValidator.default ?? ShaclValidator;
33
33
 
34
34
  // Path to the vendored SHACL shapes (synced from glossarist/concept-model
@@ -82,6 +82,7 @@ export async function loadShapes({ shapesPath = SHAPES_PATH } = {}) {
82
82
  // library's default env (from defaultEnv.js) provides one — we no longer
83
83
  // pass a custom factory. Callers still control Dataset creation via
84
84
  // quadsToDataset below.
85
+ // @ts-expect-error TODO(Phase 2e): type this fully
85
86
  export async function validateShacl(dataDataset, { shapes, shapesPath } = {}) {
86
87
  const shapesDataset = shapes ?? await loadShapes({ shapesPath });
87
88
  const validator = new ShaclValidatorCtor(shapesDataset);
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  // Sync Turtle writer — produces Turtle from RDF/JS Quads without
3
2
  // n3's callback API. Designed for UI use cases (Vue computed, React
4
3
  // render) that need synchronous output.
@@ -20,6 +19,7 @@ const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
20
19
  * @returns {string}
21
20
  */
22
21
  export function writeTurtleSync(quads, options = {}) {
22
+ // @ts-expect-error TODO(Phase 2e): type this fully
23
23
  const prefixes = options.prefixes ?? {};
24
24
  const sorted = [...quads].sort(compareQuadSync);
25
25
  const grouped = groupBySubject(sorted);
@@ -28,11 +28,14 @@ export function writeTurtleSync(quads, options = {}) {
28
28
 
29
29
  // Prefix declarations — sorted by prefix name for deterministic output.
30
30
  for (const [prefix, iri] of Object.entries(prefixes).sort(([a], [b]) => a.localeCompare(b))) {
31
+ // @ts-expect-error TODO(Phase 2e): type this fully
31
32
  lines.push(`@prefix ${prefix}: <${iri}> .`);
32
33
  }
33
34
 
34
35
  for (const { subject, triples } of grouped) {
36
+ // @ts-expect-error TODO(Phase 2e): type this fully
35
37
  lines.push('');
38
+ // @ts-expect-error TODO(Phase 2e): type this fully
36
39
  lines.push(...writeResource(subject, triples, prefixes));
37
40
  }
38
41
 
@@ -53,6 +56,7 @@ function writeResource(subject, triples, prefixes) {
53
56
 
54
57
  if (types.length > 0) {
55
58
  const typeStrs = types.map(t => formatTermSync(t.object, prefixes));
59
+ // @ts-expect-error TODO(Phase 2e): type this fully
56
60
  allPredObjs.push({ predStr: 'a', objStrs: typeStrs });
57
61
  }
58
62
 
@@ -65,14 +69,18 @@ function writeResource(subject, triples, prefixes) {
65
69
  byPredicate.get(predStr).push(formatTermSync(t.object, prefixes));
66
70
  }
67
71
  for (const [predStr, objStrs] of byPredicate) {
72
+ // @ts-expect-error TODO(Phase 2e): type this fully
68
73
  allPredObjs.push({ predStr, objStrs });
69
74
  }
70
75
 
76
+ // @ts-expect-error TODO(Phase 2e): type this fully
71
77
  lines.push(`${subjectStr} ${allPredObjs[0].predStr} ${allPredObjs[0].objStrs.join(', ')} ;`);
72
78
  for (let i = 1; i < allPredObjs.length; i++) {
79
+ // @ts-expect-error TODO(Phase 2e): type this fully
73
80
  lines.push(` ${allPredObjs[i].predStr} ${allPredObjs[i].objStrs.join(', ')} ;`);
74
81
  }
75
82
  // Replace trailing ; with .
83
+ // @ts-expect-error TODO(Phase 2e): type this fully
76
84
  lines[lines.length - 1] = lines[lines.length - 1].replace(/ ;$/, ' .');
77
85
  return lines;
78
86
  }
@@ -120,13 +128,17 @@ function compactIriSync(iri, prefixes) {
120
128
  let bestPrefix = null;
121
129
  let bestLen = 0;
122
130
  for (const [prefix, base] of Object.entries(prefixes)) {
131
+ // @ts-expect-error TODO(Phase 2e): type this fully
123
132
  if (iri.startsWith(base) && base.length > bestLen) {
124
133
  // Reject if local part contains characters that can't appear in a
125
134
  // Turtle pname-local (e.g. leading digit is fine per Turtle 1.1,
126
135
  // but // is not).
136
+ // @ts-expect-error TODO(Phase 2e): type this fully
127
137
  const local = iri.slice(base.length);
128
138
  if (!local.startsWith('//')) {
139
+ // @ts-expect-error TODO(Phase 2e): type this fully
129
140
  bestPrefix = prefix;
141
+ // @ts-expect-error TODO(Phase 2e): type this fully
130
142
  bestLen = base.length;
131
143
  }
132
144
  }
@@ -1,32 +1,47 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import { ConceptRef } from './models/concept-ref.js';
3
2
  import { parseMention } from './reference-mention.js';
4
3
 
5
4
  export class Reference {
6
5
  constructor(type, target, relationship, source, extras = {}) {
6
+ // @ts-expect-error TODO(Phase 2e): type this fully
7
7
  this.type = type;
8
+ // @ts-expect-error TODO(Phase 2e): type this fully
8
9
  this.target = target;
10
+ // @ts-expect-error TODO(Phase 2e): type this fully
9
11
  this.relationship = relationship ?? null;
12
+ // @ts-expect-error TODO(Phase 2e): type this fully
10
13
  this.source = source ?? null;
14
+ // @ts-expect-error TODO(Phase 2e): type this fully
11
15
  this.uri = extras.uri ?? null;
16
+ // @ts-expect-error TODO(Phase 2e): type this fully
12
17
  this.citation = extras.citation ?? null;
18
+ // @ts-expect-error TODO(Phase 2e): type this fully
13
19
  this.sourceId = extras.sourceId ?? null;
20
+ // @ts-expect-error TODO(Phase 2e): type this fully
14
21
  this.resolution = extras.resolution ?? null;
22
+ // @ts-expect-error TODO(Phase 2e): type this fully
15
23
  this.lookupKey = extras.lookupKey ?? null;
16
24
  }
17
25
 
18
26
  get dedupKey() {
27
+ // @ts-expect-error TODO(Phase 2e): type this fully
19
28
  if (this.type === 'bibliography') {
20
29
  return ['bibliography',
30
+ // @ts-expect-error TODO(Phase 2e): type this fully
21
31
  this.sourceId ?? this.citation?.ref?.id ?? this.target];
22
32
  }
33
+ // @ts-expect-error TODO(Phase 2e): type this fully
23
34
  if (this.type === 'figure' || this.type === 'table' || this.type === 'formula') {
35
+ // @ts-expect-error TODO(Phase 2e): type this fully
24
36
  return [this.type, this.lookupKey?.entityId ?? this.target];
25
37
  }
38
+ // @ts-expect-error TODO(Phase 2e): type this fully
26
39
  if (this.type === 'concept') {
27
40
  return ['concept',
41
+ // @ts-expect-error TODO(Phase 2e): type this fully
28
42
  this.lookupKey?.id ?? this.lookupKey?.designation ?? this.target];
29
43
  }
44
+ // @ts-expect-error TODO(Phase 2e): type this fully
30
45
  return [this.type, this.target];
31
46
  }
32
47
  }
@@ -79,6 +94,7 @@ export class ReferenceResolver {
79
94
  for (const rc of concept.relatedConcepts) {
80
95
  const target = refTarget(rc);
81
96
  if (target) {
97
+ // @ts-expect-error TODO(Phase 2e): type this fully
82
98
  refs.push(new Reference('concept', target, rc.type, 'relatedConcepts', {
83
99
  lookupKey: { id: target },
84
100
  }));
@@ -97,6 +113,7 @@ export class ReferenceResolver {
97
113
 
98
114
  const compTarget = hyperedgeRefTarget(rel.comprehensive);
99
115
  if (compTarget) {
116
+ // @ts-expect-error TODO(Phase 2e): type this fully
100
117
  refs.push(new Reference(
101
118
  'concept',
102
119
  compTarget,
@@ -115,6 +132,7 @@ export class ReferenceResolver {
115
132
  const memberRef = m?.ref ?? m;
116
133
  const pTarget = hyperedgeRefTarget(memberRef);
117
134
  if (!pTarget) continue;
135
+ // @ts-expect-error TODO(Phase 2e): type this fully
118
136
  refs.push(new Reference(
119
137
  'concept',
120
138
  pTarget,
@@ -126,16 +144,19 @@ export class ReferenceResolver {
126
144
  }
127
145
 
128
146
  for (const ref of concept.figures) {
147
+ // @ts-expect-error TODO(Phase 2e): type this fully
129
148
  refs.push(new Reference('figure', ref.display ?? ref.entityId, 'structural', 'figures', {
130
149
  lookupKey: { entityType: 'figure', entityId: ref.entityId },
131
150
  }));
132
151
  }
133
152
  for (const ref of concept.tables) {
153
+ // @ts-expect-error TODO(Phase 2e): type this fully
134
154
  refs.push(new Reference('table', ref.display ?? ref.entityId, 'structural', 'tables', {
135
155
  lookupKey: { entityType: 'table', entityId: ref.entityId },
136
156
  }));
137
157
  }
138
158
  for (const ref of concept.formulas) {
159
+ // @ts-expect-error TODO(Phase 2e): type this fully
139
160
  refs.push(new Reference('formula', ref.display ?? ref.entityId, 'structural', 'formulas', {
140
161
  lookupKey: { entityType: 'formula', entityId: ref.entityId },
141
162
  }));
@@ -149,6 +170,7 @@ export class ReferenceResolver {
149
170
  const src = lc.sources[i];
150
171
  const ref = src.origin?.toString() ?? '';
151
172
  if (ref) {
173
+ // @ts-expect-error TODO(Phase 2e): type this fully
152
174
  refs.push(new Reference('standard', ref, src.type, `localizations.${lang}.sources[${i}]`));
153
175
  }
154
176
  }
@@ -181,35 +203,42 @@ export class ReferenceResolver {
181
203
  const parsed = parseMention(m[1]);
182
204
  switch (parsed.kind) {
183
205
  case 'cite-ref':
206
+ // @ts-expect-error TODO(Phase 2e): type this fully
184
207
  refs.push(this._resolveCiteRef(parsed, source, concept));
185
208
  break;
186
209
  case 'urn-ref':
210
+ // @ts-expect-error TODO(Phase 2e): type this fully
187
211
  refs.push(new Reference('concept', parsed.label ?? parsed.uri, 'embedded', source, {
188
212
  uri: parsed.uri,
189
213
  resolution: null,
190
214
  }));
191
215
  break;
192
216
  case 'fig-ref':
217
+ // @ts-expect-error TODO(Phase 2e): type this fully
193
218
  refs.push(new Reference('figure', parsed.label ?? parsed.key, 'embedded', source, {
194
219
  lookupKey: { entityType: 'figure', entityId: parsed.key },
195
220
  }));
196
221
  break;
197
222
  case 'table-ref':
223
+ // @ts-expect-error TODO(Phase 2e): type this fully
198
224
  refs.push(new Reference('table', parsed.label ?? parsed.key, 'embedded', source, {
199
225
  lookupKey: { entityType: 'table', entityId: parsed.key },
200
226
  }));
201
227
  break;
202
228
  case 'formula-ref':
229
+ // @ts-expect-error TODO(Phase 2e): type this fully
203
230
  refs.push(new Reference('formula', parsed.label ?? parsed.key, 'embedded', source, {
204
231
  lookupKey: { entityType: 'formula', entityId: parsed.key },
205
232
  }));
206
233
  break;
207
234
  case 'numeric':
235
+ // @ts-expect-error TODO(Phase 2e): type this fully
208
236
  refs.push(new Reference('concept', parsed.label ?? parsed.id, 'embedded', source, {
209
237
  lookupKey: { id: parsed.id },
210
238
  }));
211
239
  break;
212
240
  case 'designation':
241
+ // @ts-expect-error TODO(Phase 2e): type this fully
213
242
  refs.push(new Reference('concept', parsed.label ?? parsed.id, 'embedded', source, {
214
243
  lookupKey: { designation: parsed.id },
215
244
  }));
@@ -279,6 +308,7 @@ export class ReferenceResolver {
279
308
  return registry[dataset]?.concepts?.byId(ref.lookupKey.id) ?? null;
280
309
  }
281
310
  for (const entry of Object.values(registry)) {
311
+ // @ts-expect-error TODO(Phase 2e): type this fully
282
312
  const found = entry?.concepts?.byId(ref.lookupKey.id);
283
313
  if (found) return found;
284
314
  }
@@ -1,10 +1,12 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import { resolveBibliographyRecord, findNonVerbalEntity } from './reference-resolver.js';
3
2
 
4
3
  export class ReferenceClassifier {
5
4
  constructor(registry = {}, sourceDatasetId = null, options = {}) {
5
+ // @ts-expect-error TODO(Phase 2e): type this fully
6
6
  this.registry = registry;
7
+ // @ts-expect-error TODO(Phase 2e): type this fully
7
8
  this.sourceDatasetId = sourceDatasetId;
9
+ // @ts-expect-error TODO(Phase 2e): type this fully
8
10
  this.options = options;
9
11
  }
10
12
 
@@ -28,7 +30,9 @@ export class ReferenceClassifier {
28
30
  if (ref.uri) {
29
31
  const dsId = ref.resolution?.datasetId;
30
32
  if (!dsId) return 'unresolved';
33
+ // @ts-expect-error TODO(Phase 2e): type this fully
31
34
  if (!this.registry[dsId]) return 'external-citation';
35
+ // @ts-expect-error TODO(Phase 2e): type this fully
32
36
  if (dsId === this.sourceDatasetId) return 'same-dataset';
33
37
  return 'cross-dataset';
34
38
  }
@@ -37,7 +41,9 @@ export class ReferenceClassifier {
37
41
  }
38
42
  if (ref.lookupKey?.id) {
39
43
  const dsId = ref.lookupKey.dataset;
44
+ // @ts-expect-error TODO(Phase 2e): type this fully
40
45
  if (!this.registry[dsId]) return 'unresolved';
46
+ // @ts-expect-error TODO(Phase 2e): type this fully
41
47
  if (dsId === this.sourceDatasetId) return 'same-dataset';
42
48
  return 'cross-dataset';
43
49
  }
@@ -52,11 +58,13 @@ export class ReferenceClassifier {
52
58
 
53
59
  _classifyBibliography(ref) {
54
60
  if (ref.citation) {
61
+ // @ts-expect-error TODO(Phase 2e): type this fully
55
62
  return resolveBibliographyRecord(ref.citation.ref, this.registry)
56
63
  ? 'internal-citation'
57
64
  : 'self-contained-citation';
58
65
  }
59
66
  if (ref.uri) {
67
+ // @ts-expect-error TODO(Phase 2e): type this fully
60
68
  return resolveBibliographyRecord(ref.resolution, this.registry)
61
69
  ? 'internal-citation'
62
70
  : 'external-citation';
@@ -69,6 +77,7 @@ export class ReferenceClassifier {
69
77
  }
70
78
 
71
79
  _classifyNonVerbal(ref) {
80
+ // @ts-expect-error TODO(Phase 2e): type this fully
72
81
  return findNonVerbalEntity(ref, this.registry)
73
82
  ? 'internal-citation'
74
83
  : 'external-citation';
package/src/v1-reader.ts CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import fs from 'fs';
3
2
  import path from 'path';
4
3
  import * as yaml from 'js-yaml';
@@ -29,7 +28,9 @@ export class V1Reader {
29
28
  }
30
29
 
31
30
  return new Concept({
31
+ // @ts-expect-error TODO(Phase 2e): type this fully
32
32
  id: String(data.termid ?? data.data?.identifier ?? path.basename(conceptDir)),
33
+ // @ts-expect-error TODO(Phase 2e): type this fully
33
34
  term: data.term ?? null,
34
35
  localizations,
35
36
  raw: data,
@@ -45,6 +46,7 @@ export class V1Reader {
45
46
  const conceptDir = path.join(dir, entry.name);
46
47
  if (!fs.existsSync(path.join(conceptDir, 'concept.yaml'))) continue;
47
48
  try {
49
+ // @ts-expect-error TODO(Phase 2e): type this fully
48
50
  concepts.push(V1Reader.readConcept(conceptDir));
49
51
  } catch { /* skip unreadable concepts */ }
50
52
  }
@@ -1,30 +1,35 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import { DATASET_ASSETS } from '../dataset-asset.js';
3
2
 
4
3
  export class AssetIndex {
5
4
  constructor() {
5
+ // @ts-expect-error TODO(Phase 2e): type this fully
6
6
  this._paths = new Set();
7
7
  }
8
8
 
9
9
  get paths() {
10
+ // @ts-expect-error TODO(Phase 2e): type this fully
10
11
  return [...this._paths].sort();
11
12
  }
12
13
 
13
14
  get size() {
15
+ // @ts-expect-error TODO(Phase 2e): type this fully
14
16
  return this._paths.size;
15
17
  }
16
18
 
17
19
  register(path) {
18
20
  if (path == null) return;
21
+ // @ts-expect-error TODO(Phase 2e): type this fully
19
22
  this._paths.add(this._normalize(path));
20
23
  }
21
24
 
22
25
  has(path) {
23
26
  if (path == null) return false;
27
+ // @ts-expect-error TODO(Phase 2e): type this fully
24
28
  return this._paths.has(this._normalize(path));
25
29
  }
26
30
 
27
31
  [Symbol.iterator]() {
32
+ // @ts-expect-error TODO(Phase 2e): type this fully
28
33
  return this._paths[Symbol.iterator]();
29
34
  }
30
35
 
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import { ValidationRule } from './validation-rule.js';
3
2
  import { ValidationResult } from './validation-result.js';
4
3
 
@@ -60,6 +59,7 @@ export class ConceptValidator {
60
59
  _rules = [];
61
60
 
62
61
  addRule(rule) {
62
+ // @ts-expect-error TODO(Phase 2e): type this fully
63
63
  this._rules.push(rule);
64
64
  return this;
65
65
  }
@@ -84,6 +84,7 @@ export class ConceptValidator {
84
84
  }
85
85
 
86
86
  for (const rule of this._rules) {
87
+ // @ts-expect-error TODO(Phase 2e): type this fully
87
88
  rule.validate(concept, '', result);
88
89
  }
89
90
 
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import * as yaml from 'js-yaml';
3
2
  import { DATASET_ASSETS } from '../dataset-asset.js';
4
3
  import { ValidationResult } from './validation-result.js';
@@ -23,6 +22,7 @@ export class GcrValidator {
23
22
  try {
24
23
  meta = yaml.load(raw);
25
24
  } catch (e) {
25
+ // @ts-expect-error TODO(Phase 2e): type this fully
26
26
  result.addError(`metadata.yaml: invalid YAML: ${e.message}`);
27
27
  return;
28
28
  }
@@ -55,6 +55,7 @@ export class GcrValidator {
55
55
  try {
56
56
  yaml.load(raw);
57
57
  } catch (e) {
58
+ // @ts-expect-error TODO(Phase 2e): type this fully
58
59
  result.addError(`${path}: invalid YAML at line ${e.mark?.line ?? '?'}: ${e.message}`);
59
60
  }
60
61
  }
@@ -1,4 +1,3 @@
1
- // @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
2
1
  import { ValidationRule } from './validation-rule.js';
3
2
  import { parseMention } from '../reference-mention.js';
4
3
  import { GraphicalSymbol } from '../models/designation.js';
@@ -168,6 +167,7 @@ function _findCiteMentions(concept) {
168
167
  CITE_MENTION_RE.lastIndex = 0;
169
168
  let m;
170
169
  while ((m = CITE_MENTION_RE.exec(text)) !== null) {
170
+ // @ts-expect-error TODO(Phase 2e): type this fully
171
171
  mentions.push({ key: m[1].trim(), source });
172
172
  }
173
173
  }
@@ -271,6 +271,7 @@ function _findNvrMentions(concept) {
271
271
  if (parsed.kind === 'fig-ref' ||
272
272
  parsed.kind === 'table-ref' ||
273
273
  parsed.kind === 'formula-ref') {
274
+ // @ts-expect-error TODO(Phase 2e): type this fully
274
275
  mentions.push({ key: parsed.key, source });
275
276
  }
276
277
  }
@@ -327,7 +328,9 @@ export class NonVerbalRefIntegrityRule extends ValidationRule {
327
328
 
328
329
  export class OrphanedImagesRule {
329
330
  constructor() {
331
+ // @ts-expect-error TODO(Phase 2e): type this fully
330
332
  this.name = 'orphaned-images';
333
+ // @ts-expect-error TODO(Phase 2e): type this fully
331
334
  this.severity = 'warning';
332
335
  }
333
336
 
@@ -366,6 +369,7 @@ export class OrphanedImagesRule {
366
369
  const issues = [];
367
370
  for (const imgPath of assetIndex.paths) {
368
371
  if (!referenced.has(imgPath)) {
372
+ // @ts-expect-error TODO(Phase 2e): type this fully
369
373
  issues.push({
370
374
  path: imgPath,
371
375
  severity: 'warning',