glossarist 0.2.2 → 0.3.1

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,3 +1,42 @@
1
+ export const ORDERING_METHODS: readonly string[];
2
+ export class Section extends GlossaristModel {
3
+ readonly id: string | null;
4
+ readonly names: Record<string, string>;
5
+ readonly ordering: string | null;
6
+ readonly children: Section[];
7
+ name(lang: string): string | null;
8
+ descendantById(id: string): Section | null;
9
+ static fromJSON(data: Record<string, unknown>): Section;
10
+ }
11
+
12
+ export const REGISTER_STATUSES: readonly string[];
13
+ export class Register extends GlossaristModel {
14
+ readonly schemaVersion: string;
15
+ readonly id: string | null;
16
+ readonly ref: string | null;
17
+ readonly refAliases: string[];
18
+ readonly year: number | null;
19
+ readonly urn: string | null;
20
+ readonly urnAliases: string[];
21
+ readonly status: string | null;
22
+ readonly supersedes: string | null;
23
+ readonly owner: string | null;
24
+ readonly sourceRepo: string | null;
25
+ readonly tags: string[];
26
+ readonly languages: string[];
27
+ readonly languageOrder: string[];
28
+ readonly ordering: string | null;
29
+ readonly logo: { path?: string; alt?: string } | null;
30
+ readonly description: Record<string, string>;
31
+ readonly about: Record<string, string>;
32
+ readonly provenance: Record<string, unknown>[];
33
+ readonly contributors: Record<string, unknown>[];
34
+ readonly sections: Section[];
35
+ sectionById(id: string): Section | null;
36
+ sectionName(sectionId: string, lang: string): string | null;
37
+ static fromJSON(data: Record<string, unknown>): Register;
38
+ }
39
+
1
40
  export class GlossaristModel {
2
41
  toJSON(): Record<string, unknown>;
3
42
  static fromJSON(data: Record<string, unknown>): GlossaristModel;
@@ -8,15 +47,18 @@ export class GlossaristModel {
8
47
  export class Concept extends GlossaristModel {
9
48
  readonly id: string;
10
49
  readonly term: string | null;
50
+ readonly uri: string | null;
11
51
  readonly termid: string;
12
52
  readonly languages: string[];
13
53
  readonly localizations: Record<string, any>;
14
54
  readonly raw: Record<string, unknown> | null;
15
55
  readonly relatedConcepts: RelatedConcept[];
16
56
  readonly domains: ConceptReference[];
57
+ readonly tags: string[];
17
58
  readonly dates: ConceptDate[];
18
59
  readonly sources: ConceptSource[];
19
60
  readonly status: string | null;
61
+ readonly schemaVersion: string | null;
20
62
 
21
63
  localization(lang: string): LocalizedConcept | undefined;
22
64
  primaryDesignation(lang: string): string | null;
@@ -28,14 +70,29 @@ export class Concept extends GlossaristModel {
28
70
 
29
71
  export class LocalizedConcept extends GlossaristModel {
30
72
  readonly languageCode: string | null;
73
+ readonly script: string | null;
74
+ readonly system: string | null;
75
+ readonly entryStatus: string | null;
76
+ readonly classification: string | null;
77
+ readonly reviewType: string | null;
78
+ readonly domain: string | null;
79
+ readonly release: string | null;
80
+ readonly lineageSourceSimilarity: number | null;
81
+ readonly reviewDate: string | null;
82
+ readonly reviewDecisionDate: string | null;
83
+ readonly reviewDecisionEvent: string | null;
84
+ readonly reviewStatus: string | null;
85
+ readonly reviewDecision: string | null;
86
+ readonly reviewDecisionNotes: string | null;
31
87
  readonly terms: Designation[];
32
88
  readonly definitions: DetailedDefinition[];
33
89
  readonly definition: DetailedDefinition[];
34
- readonly notes: { content: string }[];
35
- readonly examples: { content: string }[];
90
+ readonly notes: DetailedDefinition[];
91
+ readonly examples: DetailedDefinition[];
36
92
  readonly sources: ConceptSource[];
37
- readonly entryStatus: string | null;
38
- readonly domain: string | null;
93
+ readonly dates: ConceptDate[];
94
+ readonly nonVerbalRep: NonVerbRep[];
95
+ readonly related: RelatedConcept[];
39
96
  readonly primaryDesignation: string | null;
40
97
  readonly primaryDefinition: string | null;
41
98
  static fromJSON(data: Record<string, unknown>): LocalizedConcept;
@@ -45,35 +102,100 @@ export class Designation extends GlossaristModel {
45
102
  readonly designation: string;
46
103
  readonly type: string;
47
104
  readonly normativeStatus: string | null;
105
+ readonly absent: boolean | null;
106
+ readonly fieldOfApplication: string | null;
107
+ readonly usageInfo: string | null;
108
+ readonly geographicalArea: string | null;
109
+ readonly language: string | null;
110
+ readonly script: string | null;
111
+ readonly system: string | null;
112
+ readonly international: boolean | null;
113
+ readonly termType: string | null;
114
+ readonly pronunciations: Pronunciation[];
115
+ readonly sources: ConceptSource[];
116
+ readonly related: RelatedConcept[];
48
117
  static register(type: string, cls: typeof Designation): void;
49
118
  static fromData(data: Record<string, unknown>): Designation;
50
119
  static fromJSON(data: Record<string, unknown>): Designation;
51
120
  }
52
121
 
53
122
  export class Expression extends Designation {
123
+ readonly prefix: string | null;
124
+ readonly grammarInfo: GrammarInfo[];
125
+ }
126
+
127
+ export class Abbreviation extends Expression {
128
+ readonly acronym: boolean;
129
+ readonly initialism: boolean;
130
+ readonly truncation: boolean;
131
+ }
132
+
133
+ export class Symbol extends Designation {}
134
+
135
+ export class LetterSymbol extends Symbol {
136
+ readonly text: string | null;
137
+ }
138
+
139
+ export class GraphicalSymbol extends Symbol {
140
+ readonly text: string | null;
141
+ readonly image: string | null;
142
+ }
143
+
144
+ export const GRAMMAR_GENDERS: readonly string[];
145
+ export const GRAMMAR_NUMBERS: readonly string[];
146
+ export const GRAMMAR_PARTS_OF_SPEECH: readonly string[];
147
+
148
+ export class GrammarInfo extends GlossaristModel {
54
149
  readonly gender: string | null;
55
- readonly plurality: string | null;
150
+ readonly number: string | null;
56
151
  readonly partOfSpeech: string | null;
57
- readonly geographicalArea: string | null;
152
+ readonly noun: boolean;
153
+ readonly verb: boolean;
154
+ readonly adj: boolean;
155
+ readonly adverb: boolean;
156
+ readonly preposition: boolean;
157
+ readonly participle: boolean;
58
158
  }
59
159
 
60
- export class Abbreviation extends Designation {}
61
- export class Symbol extends Designation {
62
- readonly international: string | null;
160
+ export class Pronunciation extends GlossaristModel {
161
+ readonly content: string | null;
162
+ readonly language: string | null;
163
+ readonly script: string | null;
164
+ readonly country: string | null;
165
+ readonly system: string | null;
63
166
  }
64
- export class GraphicalSymbol extends Designation {
65
- readonly image: string | null;
167
+
168
+ export class Locality extends GlossaristModel {
169
+ readonly type: string | null;
170
+ readonly referenceFrom: string | null;
171
+ readonly referenceTo: string | null;
66
172
  }
67
173
 
68
174
  export class Citation extends GlossaristModel {
69
- readonly source: string | Record<string, unknown> | null;
70
- readonly ref: string | null;
71
- readonly id: string | null;
72
- readonly version: string | null;
73
- readonly clause: string | null;
175
+ readonly ref: Citation.Ref | null;
176
+ readonly locality: Locality | null;
74
177
  readonly link: string | null;
75
- readonly isStructured: boolean;
178
+ readonly original: string | null;
179
+ readonly customLocality: unknown;
76
180
  toString(): string;
181
+ static fromJSON(data: Record<string, unknown>): Citation;
182
+ }
183
+
184
+ export namespace Citation {
185
+ class Ref extends GlossaristModel {
186
+ readonly source: string | null;
187
+ readonly id: string | null;
188
+ readonly version: string | null;
189
+ toString(): string;
190
+ static fromJSON(data: Record<string, unknown>): Ref;
191
+ }
192
+ }
193
+
194
+ export class ConceptRef extends GlossaristModel {
195
+ readonly source: string | null;
196
+ readonly id: string | null;
197
+ toString(): string;
198
+ static fromJSON(data: Record<string, unknown>): ConceptRef;
77
199
  }
78
200
 
79
201
  export class ConceptSource extends GlossaristModel {
@@ -87,7 +209,7 @@ export const RELATIONSHIP_TYPES: readonly string[];
87
209
  export class RelatedConcept extends GlossaristModel {
88
210
  readonly type: string;
89
211
  readonly content: string | null;
90
- readonly ref: Citation | null;
212
+ readonly ref: ConceptRef | null;
91
213
  }
92
214
 
93
215
  export class ConceptReference extends GlossaristModel {
@@ -110,14 +232,14 @@ export class ConceptDate extends GlossaristModel {
110
232
 
111
233
  export class DetailedDefinition extends GlossaristModel {
112
234
  readonly content: string;
113
- readonly sources: Citation[];
235
+ readonly sources: ConceptSource[];
114
236
  }
115
237
 
116
238
  export class NonVerbRep extends GlossaristModel {
117
- readonly image: string | null;
118
- readonly table: string | null;
119
- readonly formula: string | null;
120
- readonly sources: Citation[];
239
+ readonly type: string | null;
240
+ readonly ref: string | null;
241
+ readonly text: string | null;
242
+ readonly sources: ConceptSource[];
121
243
  }
122
244
 
123
245
  export class GcrStatistics extends GlossaristModel {
@@ -1,13 +1,19 @@
1
+ export { Register, REGISTER_STATUSES } from './register.js';
2
+ export { Section, ORDERING_METHODS } from './section.js';
1
3
  export { GlossaristModel } from './base.js';
2
4
  export { Concept } from './concept.js';
3
5
  export { LocalizedConcept } from './localized-concept.js';
4
- export { Designation, Expression, Abbreviation, Symbol, GraphicalSymbol } from './designation.js';
6
+ export { Designation, Expression, Abbreviation, Symbol, LetterSymbol, GraphicalSymbol } from './designation.js';
5
7
  export { Citation } from './citation.js';
8
+ export { ConceptRef } from './concept-ref.js';
6
9
  export { ConceptSource } from './concept-source.js';
7
10
  export { RelatedConcept, RELATIONSHIP_TYPES } from './related-concept.js';
8
11
  export { ConceptReference } from './concept-reference.js';
9
12
  export { ConceptDate, DATE_TYPES } from './concept-date.js';
10
13
  export { DetailedDefinition } from './detailed-definition.js';
11
14
  export { NonVerbRep } from './non-verb-rep.js';
15
+ export { Pronunciation } from './pronunciation.js';
16
+ export { GrammarInfo, GRAMMAR_GENDERS, GRAMMAR_NUMBERS, GRAMMAR_PARTS_OF_SPEECH } from './grammar-info.js';
17
+ export { Locality } from './locality.js';
12
18
  export { GcrMetadata } from './gcr-metadata.js';
13
- export { GcrStatistics } from './gcr-statistics.js';;
19
+ export { GcrStatistics } from './gcr-statistics.js';
@@ -0,0 +1,22 @@
1
+ import { GlossaristModel } from './base.js';
2
+
3
+ export class Locality extends GlossaristModel {
4
+ constructor(data = {}) {
5
+ super();
6
+ this.type = data.type ?? null;
7
+ this.referenceFrom = data.reference_from ?? data.referenceFrom ?? null;
8
+ this.referenceTo = data.reference_to ?? data.referenceTo ?? null;
9
+ }
10
+
11
+ toJSON() {
12
+ const obj = {};
13
+ if (this.type != null) obj.type = this.type;
14
+ if (this.referenceFrom != null) obj.reference_from = this.referenceFrom;
15
+ if (this.referenceTo != null) obj.reference_to = this.referenceTo;
16
+ return obj;
17
+ }
18
+
19
+ static fromJSON(data) {
20
+ return new Locality(data);
21
+ }
22
+ }
@@ -2,24 +2,47 @@ import { GlossaristModel } from './base.js';
2
2
  import { Designation } from './designation.js';
3
3
  import { DetailedDefinition } from './detailed-definition.js';
4
4
  import { ConceptSource } from './concept-source.js';
5
+ import { ConceptDate } from './concept-date.js';
6
+ import { NonVerbRep } from './non-verb-rep.js';
7
+ import { RelatedConcept } from './related-concept.js';
5
8
 
6
9
  export class LocalizedConcept extends GlossaristModel {
7
10
  constructor(data = {}) {
8
11
  super();
9
12
  this.languageCode = data.language_code ?? data.languageCode ?? null;
10
- this._rawTerms = data.terms ?? [];
11
- this._rawDefinition = data.definition ?? [];
12
- this._rawSources = data.sources ?? [];
13
- this.notes = data.notes ?? [];
14
- this.examples = data.examples ?? [];
13
+ this.script = data.script ?? null;
14
+ this.system = data.system ?? null;
15
15
  this.entryStatus = data.entry_status ?? data.entryStatus ?? null;
16
- this.reviewType = data.review_type ?? data.reviewType ?? null;
17
16
  this.classification = data.classification ?? null;
17
+ this.reviewType = data.review_type ?? data.reviewType ?? null;
18
18
  this.domain = data.domain ?? null;
19
+ this.release = data.release ?? null;
20
+ this.lineageSourceSimilarity = data.lineage_source_similarity ?? data.lineageSourceSimilarity ?? null;
21
+
22
+ this.reviewDate = data.review_date ?? data.reviewDate ?? null;
23
+ this.reviewDecisionDate = data.review_decision_date ?? data.reviewDecisionDate ?? null;
24
+ this.reviewDecisionEvent = data.review_decision_event ?? data.reviewDecisionEvent ?? null;
25
+ this.reviewStatus = data.review_status ?? data.reviewStatus ?? null;
26
+ this.reviewDecision = data.review_decision ?? data.reviewDecision ?? null;
27
+ this.reviewDecisionNotes = data.review_decision_notes ?? data.reviewDecisionNotes ?? null;
28
+
29
+ this._rawTerms = data.terms ?? [];
30
+ this._rawDefinition = data.definition ?? [];
31
+ this._rawSources = data.sources ?? [];
32
+ this._rawNotes = data.notes ?? [];
33
+ this._rawExamples = data.examples ?? [];
34
+ this._rawDates = data.dates ?? [];
35
+ this._rawNonVerbal = data.non_verbal_rep ?? data.non_verb ?? [];
36
+ this._rawRelated = data.related ?? [];
19
37
 
20
38
  this._terms = null;
21
39
  this._definitions = null;
22
40
  this._sources = null;
41
+ this._notes = null;
42
+ this._examples = null;
43
+ this._dates = null;
44
+ this._nonVerbal = null;
45
+ this._related = null;
23
46
  }
24
47
 
25
48
  get terms() {
@@ -51,6 +74,51 @@ export class LocalizedConcept extends GlossaristModel {
51
74
  return this._sources;
52
75
  }
53
76
 
77
+ get notes() {
78
+ if (this._notes === null) {
79
+ this._notes = this._rawNotes.map(
80
+ n => n instanceof DetailedDefinition ? n : new DetailedDefinition(n)
81
+ );
82
+ }
83
+ return this._notes;
84
+ }
85
+
86
+ get examples() {
87
+ if (this._examples === null) {
88
+ this._examples = this._rawExamples.map(
89
+ e => e instanceof DetailedDefinition ? e : new DetailedDefinition(e)
90
+ );
91
+ }
92
+ return this._examples;
93
+ }
94
+
95
+ get dates() {
96
+ if (this._dates === null) {
97
+ this._dates = this._rawDates.map(
98
+ d => d instanceof ConceptDate ? d : new ConceptDate(d)
99
+ );
100
+ }
101
+ return this._dates;
102
+ }
103
+
104
+ get nonVerbalRep() {
105
+ if (this._nonVerbal === null) {
106
+ this._nonVerbal = this._rawNonVerbal.map(
107
+ n => n instanceof NonVerbRep ? n : new NonVerbRep(n)
108
+ );
109
+ }
110
+ return this._nonVerbal;
111
+ }
112
+
113
+ get related() {
114
+ if (this._related === null) {
115
+ this._related = this._rawRelated.map(
116
+ r => r instanceof RelatedConcept ? r : new RelatedConcept(r)
117
+ );
118
+ }
119
+ return this._related;
120
+ }
121
+
54
122
  get primaryDesignation() {
55
123
  return this.terms[0]?.designation ?? null;
56
124
  }
@@ -62,6 +130,21 @@ export class LocalizedConcept extends GlossaristModel {
62
130
  toJSON() {
63
131
  const obj = {};
64
132
  if (this.languageCode) obj.language_code = this.languageCode;
133
+ if (this.script) obj.script = this.script;
134
+ if (this.system) obj.system = this.system;
135
+ if (this.entryStatus) obj.entry_status = this.entryStatus;
136
+ if (this.classification) obj.classification = this.classification;
137
+ if (this.reviewType) obj.review_type = this.reviewType;
138
+ if (this.domain) obj.domain = this.domain;
139
+ if (this.release) obj.release = this.release;
140
+ if (this.lineageSourceSimilarity != null) obj.lineage_source_similarity = this.lineageSourceSimilarity;
141
+
142
+ if (this.reviewDate) obj.review_date = this.reviewDate;
143
+ if (this.reviewDecisionDate) obj.review_decision_date = this.reviewDecisionDate;
144
+ if (this.reviewDecisionEvent) obj.review_decision_event = this.reviewDecisionEvent;
145
+ if (this.reviewStatus) obj.review_status = this.reviewStatus;
146
+ if (this.reviewDecision) obj.review_decision = this.reviewDecision;
147
+ if (this.reviewDecisionNotes) obj.review_decision_notes = this.reviewDecisionNotes;
65
148
 
66
149
  const terms = this._terms ?? this._rawTerms;
67
150
  if (terms.length > 0) {
@@ -73,18 +156,36 @@ export class LocalizedConcept extends GlossaristModel {
73
156
  obj.definition = defs.map(d => (typeof d.toJSON === 'function') ? d.toJSON() : d);
74
157
  }
75
158
 
76
- if (this.notes.length > 0) obj.notes = this.notes;
77
- if (this.examples.length > 0) obj.examples = this.examples;
159
+ const notes = this._notes ?? (this._rawNotes.length > 0 ? this._rawNotes : []);
160
+ if (notes.length > 0) {
161
+ obj.notes = notes.map(n => (typeof n.toJSON === 'function') ? n.toJSON() : n);
162
+ }
163
+
164
+ const examples = this._examples ?? (this._rawExamples.length > 0 ? this._rawExamples : []);
165
+ if (examples.length > 0) {
166
+ obj.examples = examples.map(e => (typeof e.toJSON === 'function') ? e.toJSON() : e);
167
+ }
78
168
 
79
169
  const sources = this._sources ?? (this._rawSources.length > 0 ? this._rawSources : []);
80
170
  if (sources.length > 0) {
81
171
  obj.sources = sources.map(s => (typeof s.toJSON === 'function') ? s.toJSON() : s);
82
172
  }
83
173
 
84
- if (this.entryStatus != null) obj.entry_status = this.entryStatus;
85
- if (this.reviewType != null) obj.review_type = this.reviewType;
86
- if (this.classification != null) obj.classification = this.classification;
87
- if (this.domain != null) obj.domain = this.domain;
174
+ const dates = this._dates ?? (this._rawDates.length > 0 ? this._rawDates : []);
175
+ if (dates.length > 0) {
176
+ obj.dates = dates.map(d => (typeof d.toJSON === 'function') ? d.toJSON() : d);
177
+ }
178
+
179
+ const nonVerbal = this._nonVerbal ?? (this._rawNonVerbal.length > 0 ? this._rawNonVerbal : []);
180
+ if (nonVerbal.length > 0) {
181
+ obj.non_verbal_rep = nonVerbal.map(n => (typeof n.toJSON === 'function') ? n.toJSON() : n);
182
+ }
183
+
184
+ const related = this._related ?? (this._rawRelated.length > 0 ? this._rawRelated : []);
185
+ if (related.length > 0) {
186
+ obj.related = related.map(r => (typeof r.toJSON === 'function') ? r.toJSON() : r);
187
+ }
188
+
88
189
  return obj;
89
190
  }
90
191
 
@@ -1,22 +1,22 @@
1
1
  import { GlossaristModel } from './base.js';
2
- import { Citation } from './citation.js';
2
+ import { ConceptSource } from './concept-source.js';
3
3
 
4
4
  export class NonVerbRep extends GlossaristModel {
5
5
  constructor(data = {}) {
6
6
  super();
7
- this.image = data.image ?? null;
8
- this.table = data.table ?? null;
9
- this.formula = data.formula ?? null;
7
+ this.type = data.type ?? null;
8
+ this.ref = data.ref ?? null;
9
+ this.text = data.text ?? null;
10
10
  this.sources = (data.sources ?? []).map(
11
- s => s instanceof Citation ? s : new Citation(s)
11
+ s => s instanceof ConceptSource ? s : new ConceptSource(s)
12
12
  );
13
13
  }
14
14
 
15
15
  toJSON() {
16
16
  const obj = {};
17
- if (this.image != null) obj.image = this.image;
18
- if (this.table != null) obj.table = this.table;
19
- if (this.formula != null) obj.formula = this.formula;
17
+ if (this.type != null) obj.type = this.type;
18
+ if (this.ref != null) obj.ref = this.ref;
19
+ if (this.text != null) obj.text = this.text;
20
20
  if (this.sources.length > 0) obj.sources = this.sources.map(s => s.toJSON());
21
21
  return obj;
22
22
  }
@@ -0,0 +1,26 @@
1
+ import { GlossaristModel } from './base.js';
2
+
3
+ export class Pronunciation extends GlossaristModel {
4
+ constructor(data = {}) {
5
+ super();
6
+ this.content = data.content ?? null;
7
+ this.language = data.language ?? null;
8
+ this.script = data.script ?? null;
9
+ this.system = data.system ?? null;
10
+ this.country = data.country ?? null;
11
+ }
12
+
13
+ toJSON() {
14
+ const obj = {};
15
+ if (this.content != null) obj.content = this.content;
16
+ if (this.language != null) obj.language = this.language;
17
+ if (this.script != null) obj.script = this.script;
18
+ if (this.system != null) obj.system = this.system;
19
+ if (this.country != null) obj.country = this.country;
20
+ return obj;
21
+ }
22
+
23
+ static fromJSON(data) {
24
+ return new Pronunciation(data);
25
+ }
26
+ }
@@ -0,0 +1,110 @@
1
+ import { GlossaristModel } from './base.js';
2
+ import { Section } from './section.js';
3
+
4
+ export const REGISTER_STATUSES = Object.freeze([
5
+ 'current',
6
+ 'superseded',
7
+ 'withdrawn',
8
+ 'draft',
9
+ ]);
10
+
11
+ export class Register extends GlossaristModel {
12
+ constructor(data = {}) {
13
+ super();
14
+ this.schemaVersion = data.schema_version ?? data.schemaVersion ?? '3';
15
+ this.id = data.id ?? null;
16
+ this.ref = data.ref ?? null;
17
+ this.refAliases = data.refAliases ?? data.ref_aliases ?? [];
18
+ this.year = data.year ?? null;
19
+ this.urn = data.urn ?? null;
20
+ this.urnAliases = data.urnAliases ?? data.urn_aliases ?? [];
21
+ this.status = data.status ?? null;
22
+ this.supersedes = data.supersedes ?? null;
23
+ this.owner = data.owner ?? null;
24
+ this.sourceRepo = data.sourceRepo ?? data.source_repo ?? null;
25
+ this.tags = data.tags ?? [];
26
+ this.languages = data.languages ?? [];
27
+ this.languageOrder = data.languageOrder ?? data.language_order ?? [];
28
+ this.ordering = data.ordering ?? null;
29
+ this.logo = data.logo ?? null;
30
+ this.description = data.description ?? {};
31
+ this.about = data.about ?? {};
32
+ this.provenance = data.provenance ?? [];
33
+ this.contributors = data.contributors ?? [];
34
+ this.sections = (data.sections ?? []).map(s =>
35
+ s instanceof Section ? s : new Section(s)
36
+ );
37
+ this._raw = this._extractRaw(data);
38
+ }
39
+
40
+ _extractRaw(data) {
41
+ const known = new Set([
42
+ 'schema_version', 'schemaVersion',
43
+ 'id', 'ref', 'refAliases', 'ref_aliases',
44
+ 'year', 'urn', 'urnAliases', 'urn_aliases',
45
+ 'status', 'supersedes', 'owner',
46
+ 'sourceRepo', 'source_repo', 'tags',
47
+ 'languages', 'languageOrder', 'language_order',
48
+ 'ordering', 'logo', 'description', 'about',
49
+ 'provenance', 'contributors', 'sections',
50
+ ]);
51
+ const extra = {};
52
+ for (const [k, v] of Object.entries(data)) {
53
+ if (!known.has(k)) extra[k] = v;
54
+ }
55
+ return extra;
56
+ }
57
+
58
+ sectionById(id) {
59
+ for (const section of this.sections) {
60
+ if (section.id === id) return section;
61
+ const found = section.descendantById(id);
62
+ if (found) return found;
63
+ }
64
+ return null;
65
+ }
66
+
67
+ sectionName(sectionId, lang) {
68
+ const section = this.sectionById(sectionId);
69
+ return section ? section.name(lang) : null;
70
+ }
71
+
72
+ toJSON() {
73
+ const obj = { ...this._raw, schema_version: this.schemaVersion };
74
+ if (this.id != null) obj.id = this.id;
75
+ if (this.ref != null) obj.ref = this.ref;
76
+ if (this.refAliases.length > 0) obj.refAliases = [...this.refAliases];
77
+ if (this.year != null) obj.year = this.year;
78
+ if (this.urn != null) obj.urn = this.urn;
79
+ if (this.urnAliases.length > 0) obj.urnAliases = [...this.urnAliases];
80
+ if (this.status != null) obj.status = this.status;
81
+ if (this.supersedes != null) obj.supersedes = this.supersedes;
82
+ if (this.owner != null) obj.owner = this.owner;
83
+ if (this.sourceRepo != null) obj.sourceRepo = this.sourceRepo;
84
+ if (this.tags.length > 0) obj.tags = [...this.tags];
85
+ if (this.languages.length > 0) obj.languages = [...this.languages];
86
+ if (this.languageOrder.length > 0) obj.languageOrder = [...this.languageOrder];
87
+ if (this.ordering != null) obj.ordering = this.ordering;
88
+ if (this.logo != null) obj.logo = { ...this.logo };
89
+ if (Object.keys(this.description).length > 0) obj.description = { ...this.description };
90
+ if (Object.keys(this.about).length > 0) obj.about = { ...this.about };
91
+ if (this.provenance.length > 0) obj.provenance = this.provenance.map(p => ({ ...p }));
92
+ if (this.contributors.length > 0) obj.contributors = this.contributors.map(c => ({ ...c }));
93
+ if (this.sections.length > 0) obj.sections = this.sections.map(s => s.toJSON());
94
+ return obj;
95
+ }
96
+
97
+ static fromJSON(data) {
98
+ const instance = new Register(data);
99
+ const snakeToCamel = k => k.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
100
+ return new Proxy(instance, {
101
+ get(target, prop) {
102
+ if (prop in target) return target[prop];
103
+ if (prop in target._raw) return target._raw[prop];
104
+ const camel = snakeToCamel(prop);
105
+ if (camel in target) return target[camel];
106
+ return undefined;
107
+ },
108
+ });
109
+ }
110
+ }
@@ -1,19 +1,38 @@
1
1
  import { GlossaristModel } from './base.js';
2
- import { Citation } from './citation.js';
2
+ import { ConceptRef } from './concept-ref.js';
3
3
 
4
4
  export const RELATIONSHIP_TYPES = Object.freeze([
5
- 'supersedes', 'superseded_by', 'extends', 'extended_by',
6
- 'narrower', 'broader', 'equivalent', 'compare', 'contrast',
7
- 'derived', 'deprecated', 'related',
5
+ // Lifecycle (ISO 10241-1)
6
+ 'deprecates', 'supersedes', 'superseded_by',
7
+ // Hierarchical (SKOS)
8
+ 'broader', 'narrower',
9
+ // ISO 25964 generic
10
+ 'broader_generic', 'narrower_generic',
11
+ // ISO 25964 partitive
12
+ 'broader_partitive', 'narrower_partitive',
13
+ // ISO 25964 instantial
14
+ 'broader_instantial', 'narrower_instantial',
15
+ // SKOS mapping
16
+ 'equivalent', 'close_match', 'broad_match', 'narrow_match', 'related_match',
17
+ // Associative (ISO 10241-1 / ISO 25964)
18
+ 'see', 'related_concept', 'related_concept_broader', 'related_concept_narrower',
19
+ // Comparative (ISO 10241-1)
20
+ 'compare', 'contrast',
21
+ // Spatiotemporal (ISO 25964 / TBX)
22
+ 'sequentially_related_concept', 'spatially_related_concept', 'temporally_related_concept',
23
+ // Lexical (ISO 12620 / TBX)
24
+ 'homograph', 'false_friend',
25
+ // Designation-level
26
+ 'abbreviated_form_for', 'short_form_for',
8
27
  ]);
9
28
 
10
29
  export class RelatedConcept extends GlossaristModel {
11
30
  constructor(data = {}) {
12
31
  super();
13
- this.type = data.type ?? 'related';
32
+ this.type = data.type ?? 'see';
14
33
  this.content = data.content ?? null;
15
34
  this.ref = data.ref
16
- ? (data.ref instanceof Citation ? data.ref : new Citation(data.ref))
35
+ ? (data.ref instanceof ConceptRef ? data.ref : new ConceptRef(data.ref))
17
36
  : null;
18
37
  }
19
38