@glossarist/concept-browser 0.7.85 → 0.7.86
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 -2
- package/scripts/build-edges.js +42 -26
- package/scripts/generate-data.mjs +45 -5
- package/scripts/migrate-v1-to-v3.d.mts +6 -0
- package/scripts/migrate-v1-to-v3.mjs +176 -0
- package/src/__tests__/components/PartitiveRelationDiagram.test.ts +92 -136
- package/src/__tests__/composables/use-concept-edges-v2.test.ts +115 -87
- package/src/__tests__/partitive-relation-styling.test.ts +12 -54
- package/src/__tests__/partitive-relation.test.ts +42 -90
- package/src/__tests__/scripts/migrate-v1-to-v3.d.mts +8 -0
- package/src/__tests__/scripts/migrate-v1-to-v3.test.ts +115 -0
- package/src/__tests__/utils/partitive-multiplicity.test.ts +113 -0
- package/src/adapters/model-bridge.ts +15 -19
- package/src/adapters/non-verbal/glossarist-augment.d.ts +34 -18
- package/src/adapters/types.ts +2 -8
- package/src/components/PartitiveRelationDiagram.vue +88 -76
- package/src/components/PartitiveRelationList.vue +26 -34
- package/src/components/RelationSphere.vue +57 -72
- package/src/composables/use-concept-edges.ts +21 -21
- package/src/utils/partitive-multiplicity.ts +106 -0
- package/src/utils/partitive-relation-styling.ts +29 -38
- package/src/views/ConceptView.vue +7 -13
- package/src/__tests__/model-bridge-partitive.test.ts +0 -146
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { conceptFromJson } from '../adapters/model-bridge';
|
|
3
|
-
|
|
4
|
-
describe('conceptFromJson — gl:partitiveRelations (v2)', () => {
|
|
5
|
-
function makeJson(overrides: Record<string, unknown> = {}) {
|
|
6
|
-
return {
|
|
7
|
-
'@type': 'gl:Concept',
|
|
8
|
-
'@id': 'https://example.org/test/concept/1.3',
|
|
9
|
-
'gl:identifier': '1.3',
|
|
10
|
-
'gl:localizedConcept': {},
|
|
11
|
-
...overrides,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
it('returns empty array when no partitiveRelations', () => {
|
|
16
|
-
const c = conceptFromJson(makeJson());
|
|
17
|
-
expect(c.partitiveRelations).toEqual([]);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('parses comprehensive + 2 partitives', () => {
|
|
21
|
-
const c = conceptFromJson(makeJson({
|
|
22
|
-
'gl:partitiveRelations': [{
|
|
23
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
24
|
-
'gl:hasPartitive': [
|
|
25
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
26
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.5' } },
|
|
27
|
-
],
|
|
28
|
-
}],
|
|
29
|
-
}));
|
|
30
|
-
expect(c.partitiveRelations).toHaveLength(1);
|
|
31
|
-
const r = c.partitiveRelations[0];
|
|
32
|
-
expect(r.comprehensive.source).toBe('urn:test');
|
|
33
|
-
expect(r.comprehensive.id).toBe('1.3');
|
|
34
|
-
expect(r.partitives).toHaveLength(2);
|
|
35
|
-
expect(r.partitives[0].ref.id).toBe('1.4');
|
|
36
|
-
expect(r.partitives[1].ref.id).toBe('1.5');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('parses completeness', () => {
|
|
40
|
-
const c = conceptFromJson(makeJson({
|
|
41
|
-
'gl:partitiveRelations': [{
|
|
42
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
43
|
-
'gl:hasPartitive': [
|
|
44
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
45
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.5' } },
|
|
46
|
-
],
|
|
47
|
-
'gl:completeness': 'partial',
|
|
48
|
-
}],
|
|
49
|
-
}));
|
|
50
|
-
expect(c.partitiveRelations[0].completeness).toBe('partial');
|
|
51
|
-
expect(c.partitiveRelations[0].isPartial).toBe(true);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('parses per-member certainty', () => {
|
|
55
|
-
const c = conceptFromJson(makeJson({
|
|
56
|
-
'gl:partitiveRelations': [{
|
|
57
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
58
|
-
'gl:hasPartitive': [
|
|
59
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
60
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.5' }, 'gl:certainty': 'possible' },
|
|
61
|
-
],
|
|
62
|
-
}],
|
|
63
|
-
}));
|
|
64
|
-
const members = c.partitiveRelations[0].partitives;
|
|
65
|
-
expect(members[0].certainty).toBe('confirmed');
|
|
66
|
-
expect(members[1].certainty).toBe('possible');
|
|
67
|
-
expect(members[1].isPossible).toBe(true);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('parses plurality block', () => {
|
|
71
|
-
const c = conceptFromJson(makeJson({
|
|
72
|
-
'gl:partitiveRelations': [{
|
|
73
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
74
|
-
'gl:hasPartitive': [
|
|
75
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
76
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.5' } },
|
|
77
|
-
],
|
|
78
|
-
'gl:hasPlurality': {
|
|
79
|
-
'gl:isShared': true,
|
|
80
|
-
'gl:isUncertain': true,
|
|
81
|
-
'gl:sharedType': { 'gl:source': 'urn:test', 'gl:id': '1.99' },
|
|
82
|
-
},
|
|
83
|
-
}],
|
|
84
|
-
}));
|
|
85
|
-
const p = c.partitiveRelations[0].plurality;
|
|
86
|
-
expect(p).not.toBeNull();
|
|
87
|
-
expect(p?.isShared).toBe(true);
|
|
88
|
-
expect(p?.isUncertain).toBe(true);
|
|
89
|
-
expect(p?.sharedType?.id).toBe('1.99');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('parses criterion as localized hash', () => {
|
|
93
|
-
const c = conceptFromJson(makeJson({
|
|
94
|
-
'gl:partitiveRelations': [{
|
|
95
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
96
|
-
'gl:hasPartitive': [
|
|
97
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
98
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.5' } },
|
|
99
|
-
],
|
|
100
|
-
'gl:criterion': { eng: 'physical structure', fra: 'structure physique' },
|
|
101
|
-
}],
|
|
102
|
-
}));
|
|
103
|
-
expect(c.partitiveRelations[0].criterion?.eng).toBe('physical structure');
|
|
104
|
-
expect(c.partitiveRelations[0].criterion?.fra).toBe('structure physique');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('parses criterion as plain string (normalized to default)', () => {
|
|
108
|
-
const c = conceptFromJson(makeJson({
|
|
109
|
-
'gl:partitiveRelations': [{
|
|
110
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
111
|
-
'gl:hasPartitive': [
|
|
112
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
113
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.5' } },
|
|
114
|
-
],
|
|
115
|
-
'gl:criterion': 'a bare criterion string',
|
|
116
|
-
}],
|
|
117
|
-
}));
|
|
118
|
-
expect(c.partitiveRelations[0].criterion?.default).toBe('a bare criterion string');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('skips relation with no comprehensive', () => {
|
|
122
|
-
const c = conceptFromJson(makeJson({
|
|
123
|
-
'gl:partitiveRelations': [{
|
|
124
|
-
'gl:hasPartitive': [
|
|
125
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
126
|
-
],
|
|
127
|
-
}],
|
|
128
|
-
}));
|
|
129
|
-
expect(c.partitiveRelations).toEqual([]);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('skips relation with < 2 valid partitives', () => {
|
|
133
|
-
const c = conceptFromJson(makeJson({
|
|
134
|
-
'gl:partitiveRelations': [{
|
|
135
|
-
'gl:comprehensive': { 'gl:source': 'urn:test', 'gl:id': '1.3' },
|
|
136
|
-
'gl:hasPartitive': [
|
|
137
|
-
{ 'gl:ref': { 'gl:source': 'urn:test', 'gl:id': '1.4' } },
|
|
138
|
-
// Single member — PartitiveRelation constructor throws
|
|
139
|
-
],
|
|
140
|
-
}],
|
|
141
|
-
}));
|
|
142
|
-
// The constructor throws before we catch it, so the relation is dropped
|
|
143
|
-
// via the runtime error path. conceptFromJson should not propagate.
|
|
144
|
-
expect(c.partitiveRelations).toEqual([]);
|
|
145
|
-
});
|
|
146
|
-
});
|