glossarist 0.4.45 → 0.4.47
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 +2 -1
- package/src/compiled-format.ts +0 -1
- package/src/concept-diff.ts +0 -1
- package/src/dataset-asset.ts +0 -1
- package/src/diff/collection-diff.ts +2 -2
- package/src/diff/concept-diff.ts +6 -6
- package/src/diff/diff-patch.ts +1 -1
- package/src/diff/diff-renderer.ts +1 -1
- package/src/diff/index.ts +0 -1
- package/src/entity-directory.ts +0 -1
- package/src/index.ts +0 -1
- package/src/rdf/bnode-id.ts +4 -5
- package/src/rdf/curie.ts +4 -4
- package/src/rdf/deterministic-id.ts +6 -9
- package/src/rdf/gloss-detailed-definition.ts +0 -1
- package/src/rdf/gloss-generic-hyperedge.ts +0 -1
- package/src/rdf/gloss-localized-concept.ts +0 -1
- package/src/rdf/gloss-partitive-member.ts +0 -1
- package/src/rdf/gloss-partitive-relation.ts +0 -1
- package/src/rdf/gloss-source.ts +0 -1
- package/src/rdf/index.ts +0 -1
- package/src/rdf/normalize-enum.ts +3 -5
- package/src/rdf/prefixes.ts +0 -1
- package/src/rdf/shacl-entry.ts +0 -1
- package/src/rdf/terms.ts +0 -1
- package/src/rdf/version-emitter.ts +0 -1
- package/src/rdf/vocabulary-emitter.ts +0 -1
- package/src/reference-mention.ts +0 -1
- package/src/validators/binary-has-part-redundancy-rule.ts +0 -1
- package/src/validators/delimiting-coherence-rule.ts +0 -1
- package/src/validators/external-concept-shape-rule.ts +0 -1
- package/src/validators/hyperedge-coherence-rule.ts +0 -1
- package/src/validators/index.ts +0 -1
- package/src/validators/partitive-relation-coherence-rule.ts +0 -1
- package/src/validators/ref-keys.ts +0 -1
- package/src/validators/register-validator.ts +0 -1
- package/src/validators/relationship-type-rule.ts +0 -1
- package/src/validators/sourced-from-locality-rule.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glossarist",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.47",
|
|
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",
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@eslint/js": "^10.0.1",
|
|
113
113
|
"@rdfjs/types": "^2.0.1",
|
|
114
|
+
"@types/n3": "^1.26.1",
|
|
114
115
|
"@types/node": "^26.1.2",
|
|
115
116
|
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
116
117
|
"@typescript-eslint/parser": "^8.65.0",
|
package/src/compiled-format.ts
CHANGED
package/src/concept-diff.ts
CHANGED
package/src/dataset-asset.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY
|
|
1
|
+
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
2
|
import { GlossaristModel } from '../models/base.js';
|
|
3
3
|
import { Added, Removed, Matched, deserializeChange } from './change.js';
|
|
4
4
|
import { ConceptDiff, DiffStats, diffConcepts } from './concept-diff.js';
|
|
5
5
|
import { averageSimilarity } from './similarity.js';
|
|
6
6
|
|
|
7
7
|
export class ConceptCollectionDiff extends GlossaristModel {
|
|
8
|
-
constructor(data = {}) {
|
|
8
|
+
constructor(data: Record<string, unknown> = {}) {
|
|
9
9
|
super();
|
|
10
10
|
this.oldCount = data.oldCount ?? data.old_count ?? 0;
|
|
11
11
|
this.newCount = data.newCount ?? data.new_count ?? 0;
|
package/src/diff/concept-diff.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY
|
|
1
|
+
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
2
|
import { GlossaristModel } from '../models/base.js';
|
|
3
3
|
import { PartitiveHyperedge } from '../models/partitive-hyperedge.js';
|
|
4
4
|
import { GenericHyperedge } from '../models/generic-hyperedge.js';
|
|
@@ -33,7 +33,7 @@ const LOCALIZATION_METADATA_FIELDS = Object.freeze([
|
|
|
33
33
|
// (See file-top comment about why they're duplicated rather than imported.)
|
|
34
34
|
|
|
35
35
|
export class DiffStats extends GlossaristModel {
|
|
36
|
-
constructor(data = {}) {
|
|
36
|
+
constructor(data: Record<string, unknown> = {}) {
|
|
37
37
|
super();
|
|
38
38
|
this._added = data.added ?? 0;
|
|
39
39
|
this._removed = data.removed ?? 0;
|
|
@@ -55,7 +55,7 @@ export class DiffStats extends GlossaristModel {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export class MetadataDiff extends GlossaristModel {
|
|
58
|
-
constructor(data = {}) {
|
|
58
|
+
constructor(data: Record<string, unknown> = {}) {
|
|
59
59
|
super();
|
|
60
60
|
this._changes = {};
|
|
61
61
|
const raw = data.changes ?? data ?? {};
|
|
@@ -97,7 +97,7 @@ export class MetadataDiff extends GlossaristModel {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export class ConceptLevelDiff extends GlossaristModel {
|
|
100
|
-
constructor(data = {}) {
|
|
100
|
+
constructor(data: Record<string, unknown> = {}) {
|
|
101
101
|
super();
|
|
102
102
|
this._sources = wrapListDiff(data.sources);
|
|
103
103
|
this._dates = wrapListDiff(data.dates);
|
|
@@ -193,7 +193,7 @@ export class ConceptLevelDiff extends GlossaristModel {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
export class LocalizedConceptDiff extends GlossaristModel {
|
|
196
|
-
constructor(data = {}) {
|
|
196
|
+
constructor(data: Record<string, unknown> = {}) {
|
|
197
197
|
super();
|
|
198
198
|
this.languageCode = data.languageCode ?? data.language_code ?? null;
|
|
199
199
|
this._designations = wrapListDiff(data.designations);
|
|
@@ -279,7 +279,7 @@ export class LocalizedConceptDiff extends GlossaristModel {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
export class ConceptDiff extends GlossaristModel {
|
|
282
|
-
constructor(data = {}) {
|
|
282
|
+
constructor(data: Record<string, unknown> = {}) {
|
|
283
283
|
super();
|
|
284
284
|
this._oldId = data.oldId ?? data.old_id ?? null;
|
|
285
285
|
this._newId = data.newId ?? data.new_id ?? null;
|
package/src/diff/diff-patch.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY
|
|
1
|
+
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
2
|
import { Concept } from '../models/concept.js';
|
|
3
3
|
import { ConceptSource } from '../models/concept-source.js';
|
|
4
4
|
import { ConceptDate } from '../models/concept-date.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY
|
|
1
|
+
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
2
|
import { TextDiff } from './text-diff.js';
|
|
3
3
|
import { resolveMultiplicity } from '../models/multiplicity.js';
|
|
4
4
|
|
package/src/diff/index.ts
CHANGED
package/src/entity-directory.ts
CHANGED
package/src/index.ts
CHANGED
package/src/rdf/bnode-id.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Deterministic blank node ID strategy.
|
|
3
2
|
//
|
|
4
3
|
// Single source of truth for bnode IDs across all emitters. Previously
|
|
@@ -10,7 +9,7 @@
|
|
|
10
9
|
// Browser safety: node:crypto is loaded lazily via runtime check so
|
|
11
10
|
// bundlers don't tree-shake the import into the browser bundle.
|
|
12
11
|
|
|
13
|
-
let nodeCreateHash = null;
|
|
12
|
+
let nodeCreateHash: ((alg: string) => { update(data: string): { digest(enc: string): string } }) | null = null;
|
|
14
13
|
let nodeCryptoChecked = false;
|
|
15
14
|
|
|
16
15
|
function getNodeCreateHash() {
|
|
@@ -22,7 +21,7 @@ function getNodeCreateHash() {
|
|
|
22
21
|
const mod = (Function('m', 'return require(m)'))('node:module');
|
|
23
22
|
requireFn = mod.createRequire(import.meta.url);
|
|
24
23
|
} catch {
|
|
25
|
-
requireFn = (m) => (Function('m', 'return require(m)'))(m);
|
|
24
|
+
requireFn = (m: string) => (Function('m', 'return require(m)'))(m);
|
|
26
25
|
}
|
|
27
26
|
const crypto = requireFn('node:crypto');
|
|
28
27
|
nodeCreateHash = crypto.createHash.bind(crypto);
|
|
@@ -32,7 +31,7 @@ function getNodeCreateHash() {
|
|
|
32
31
|
return nodeCreateHash;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
function fnv1a(seed) {
|
|
34
|
+
function fnv1a(seed: string): string {
|
|
36
35
|
let h = 0x811c9dc5;
|
|
37
36
|
for (let i = 0; i < seed.length; i++) {
|
|
38
37
|
h ^= seed.charCodeAt(i);
|
|
@@ -41,7 +40,7 @@ function fnv1a(seed) {
|
|
|
41
40
|
return (h >>> 0).toString(16).padStart(8, '0');
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
export function deterministicBnodeId(...parts) {
|
|
43
|
+
export function deterministicBnodeId(...parts: ReadonlyArray<unknown>): string {
|
|
45
44
|
const seed = parts.filter(p => p != null && p !== '').join('|');
|
|
46
45
|
if (!seed) return `b${fnv1a('empty')}`;
|
|
47
46
|
const createHash = getNodeCreateHash();
|
package/src/rdf/curie.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { PREFIXES } from './prefixes.js';
|
|
|
9
9
|
|
|
10
10
|
const ABSOLUTE_SCHEMES = new Set(['http', 'https', 'urn', 'file', 'mailto', 'ftp']);
|
|
11
11
|
|
|
12
|
-
export function isAbsoluteIri(s) {
|
|
12
|
+
export function isAbsoluteIri(s: string): boolean {
|
|
13
13
|
if (typeof s !== 'string' || s.length === 0) return false;
|
|
14
14
|
if (s.startsWith('urn:')) return true;
|
|
15
15
|
const colon = s.indexOf(':');
|
|
@@ -17,17 +17,17 @@ export function isAbsoluteIri(s) {
|
|
|
17
17
|
return ABSOLUTE_SCHEMES.has(s.slice(0, colon));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function resolveIri(iri, prefixes = PREFIXES) {
|
|
20
|
+
export function resolveIri(iri: string, prefixes: Record<string, string> = PREFIXES): string {
|
|
21
21
|
if (isAbsoluteIri(iri)) return iri;
|
|
22
22
|
const colon = iri.indexOf(':');
|
|
23
23
|
if (colon < 1) return iri;
|
|
24
24
|
const prefix = iri.slice(0, colon);
|
|
25
25
|
const local = iri.slice(colon + 1);
|
|
26
|
-
const base = prefixes[prefix];
|
|
26
|
+
const base = prefixes[prefix as keyof typeof PREFIXES];
|
|
27
27
|
return base ? `${base}${local}` : iri;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function compactIri(iri, prefixes = PREFIXES) {
|
|
30
|
+
export function compactIri(iri: string, prefixes: Record<string, string> = PREFIXES): string {
|
|
31
31
|
let best = null;
|
|
32
32
|
let bestLen = 0;
|
|
33
33
|
for (const [prefix, base] of Object.entries(prefixes)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Stable ID helpers for RDF emission. Mirrors glossarist-ruby's
|
|
3
2
|
// Digest::MD5.hexdigest(content)[0..11] for cross-runtime stability.
|
|
4
3
|
//
|
|
@@ -7,7 +6,7 @@
|
|
|
7
6
|
// `createRequire` from `node:module` (also lazy) which is the
|
|
8
7
|
// documented way to use CommonJS `require` from ESM.
|
|
9
8
|
|
|
10
|
-
let nodeCreateHash = null;
|
|
9
|
+
let nodeCreateHash: ((alg: string) => { update(data: string): { digest(enc: string): string } }) | null = null;
|
|
11
10
|
let nodeCryptoChecked = false;
|
|
12
11
|
|
|
13
12
|
function getNodeCreateHash() {
|
|
@@ -23,7 +22,7 @@ function getNodeCreateHash() {
|
|
|
23
22
|
requireFn = mod.createRequire(import.meta.url);
|
|
24
23
|
} catch {
|
|
25
24
|
// CJS or already-require-available environment
|
|
26
|
-
requireFn = (m) => (Function('m', 'return require(m)'))(m);
|
|
25
|
+
requireFn = (m: string) => (Function('m', 'return require(m)'))(m);
|
|
27
26
|
}
|
|
28
27
|
const crypto = requireFn('node:crypto');
|
|
29
28
|
nodeCreateHash = crypto.createHash.bind(crypto);
|
|
@@ -37,7 +36,7 @@ function getNodeCreateHash() {
|
|
|
37
36
|
// `Digest::MD5.hexdigest(content)[0..11]`. Same content → same ID across
|
|
38
37
|
// processes, machines, and language runtimes (Ruby vs JS) when MD5 is
|
|
39
38
|
// available. Falls back to a 12-char FNV-1a hash in the browser.
|
|
40
|
-
export function deterministicId(...parts) {
|
|
39
|
+
export function deterministicId(...parts: ReadonlyArray<unknown>): string {
|
|
41
40
|
const seed = parts.filter(p => p !== null && p !== undefined).join('|');
|
|
42
41
|
const createHash = getNodeCreateHash();
|
|
43
42
|
if (createHash) {
|
|
@@ -48,14 +47,12 @@ export function deterministicId(...parts) {
|
|
|
48
47
|
|
|
49
48
|
// Stable blank-node label for an RDF fragment identified by its parent
|
|
50
49
|
// subject + role + index.
|
|
51
|
-
export function deterministicBnode(subject, role, index) {
|
|
50
|
+
export function deterministicBnode(subject: string, role: string, index: number): string {
|
|
52
51
|
return `_:b${deterministicId(subject, role, index)}`;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
// 12-char FNV-1a hash.
|
|
56
|
-
|
|
57
|
-
// single document. Used only when node:crypto is unavailable.
|
|
58
|
-
function fnv1a12(seed) {
|
|
54
|
+
// 12-char FNV-1a hash.
|
|
55
|
+
function fnv1a12(seed: string): string {
|
|
59
56
|
let h1 = 0x811c9dc5;
|
|
60
57
|
for (let i = 0; i < seed.length; i++) {
|
|
61
58
|
h1 ^= seed.charCodeAt(i);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// DetailedDefinition → RDF quads. Mirrors glossarist-ruby's
|
|
3
2
|
// `Rdf::GlossDetailedDefinition`. Used for definitions, notes, examples,
|
|
4
3
|
// and annotations — they all share the same shape (content + optional
|
package/src/rdf/gloss-source.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// ConceptSource → RDF quads. Mirrors glossarist-ruby's
|
|
3
2
|
// `Rdf::GlossConceptSource` + `Rdf::GlossCitation`. Sources are reified
|
|
4
3
|
// resources linked from their parent (concept or localized concept or
|
package/src/rdf/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Helpers for normalizing enumeration values that get interpolated into
|
|
3
2
|
// URIs. Source data may contain compound forms ("preferred/admitted") or
|
|
4
3
|
// path-like values that must be reduced to a single local name before
|
|
@@ -10,15 +9,14 @@
|
|
|
10
9
|
// 'preferred/admitted' → 'admitted'
|
|
11
10
|
// 'http://x/ns#preferred' → 'preferred'
|
|
12
11
|
// '' / null / undefined → '' (caller decides whether to skip emission)
|
|
13
|
-
export function normalizeEnum(value) {
|
|
12
|
+
export function normalizeEnum(value: string | null | undefined): string {
|
|
14
13
|
if (value == null) return '';
|
|
15
14
|
const s = String(value).trim();
|
|
16
15
|
if (!s) return '';
|
|
17
16
|
const parts = s.split(/[/#]/);
|
|
18
|
-
return parts[parts.length - 1];
|
|
17
|
+
return parts[parts.length - 1] ?? '';
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
export function hasEnumValue(value) {
|
|
20
|
+
export function hasEnumValue(value: string | null | undefined): boolean {
|
|
23
21
|
return normalizeEnum(value).length > 0;
|
|
24
22
|
}
|
package/src/rdf/prefixes.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Re-export prefix map and predicate constants generated from the vendored
|
|
3
2
|
// concept-model JSON-LD context. Downstream code should never duplicate
|
|
4
3
|
// prefix bindings — always import from here.
|
package/src/rdf/shacl-entry.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Node-only SHACL validator entry. Separated from glossarist/rdf so that
|
|
3
2
|
// browser bundles can import RDF emitters/writers without pulling in
|
|
4
3
|
// node:fs/promises, node:path, node:url.
|
package/src/rdf/terms.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Vocabulary graph emitter — emits SKOS ConceptSchemes for the
|
|
3
2
|
// enumeration IRIs that glossarist emits in instance data
|
|
4
3
|
// (gloss:status/*, gloss:entstatus/*, gloss:norm/*, gloss:srcstatus/*,
|
package/src/reference-mention.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Warns when binary `has_part` / `is_part_of` edges duplicate
|
|
3
2
|
// PartitiveHyperedge members, or when a concept has many binary
|
|
4
3
|
// has_part edges that should be consolidated into a PartitiveHyperedge.
|
package/src/validators/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Deprecated. This rule has been generalized and renamed to
|
|
3
2
|
// HyperedgeCoherenceRule (see ./hyperedge-coherence-rule.js). The
|
|
4
3
|
// new rule is type-blind — it validates every AbstractHyperedge
|
|
@@ -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 { RELATIONSHIP_TYPES } from '../models/related-concept.js';
|
|
4
3
|
import { DESIGNATION_RELATIONSHIP_TYPES } from '../models/designation-relationship.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck — TEMPORARY during TS migration. TODO(Phase 2e): remove and type fully.
|
|
2
1
|
// Validates that every ConceptSource#sourced_from Citation includes a
|
|
3
2
|
// locality. Per concept-model commit 9c065df ("sourced_from citations
|
|
4
3
|
// must include locality"), a sourced_from entry without a locality is
|