@glossarist/concept-browser 0.7.104 → 0.7.106
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 +3 -1
- package/scripts/generate-data.mjs +6 -0
- package/scripts/smoke.mjs +269 -0
- package/src/__tests__/components/rake-bundles.test.ts +20 -0
- package/src/__tests__/composables/use-concept-edges-defensive.test.ts +164 -0
- package/src/__tests__/concept-detail-hydration.test.ts +199 -0
- package/src/__tests__/utils/external-detection.test.ts +85 -0
- package/src/components/ConceptDetail.vue +45 -38
- package/src/components/PartitiveRelationDiagram.vue +12 -0
- package/src/components/relation-sphere/rake-bundles.ts +17 -0
- package/src/composables/use-concept-edges.ts +59 -43
- package/src/config/types.ts +17 -1
- package/src/layouts/Default.astro +41 -16
- package/src/pages/[...path].astro +6 -0
- package/src/utils/external-detection.ts +74 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
2
|
+
import { mount, flushPromises } from '@vue/test-utils';
|
|
3
|
+
import { createPinia, setActivePinia } from 'pinia';
|
|
4
|
+
import { createRouter, createMemoryHistory } from 'vue-router';
|
|
5
|
+
import ConceptDetail from '../components/ConceptDetail.vue';
|
|
6
|
+
import { useVocabularyStore } from '../stores/vocabulary';
|
|
7
|
+
import type { Manifest } from '../adapters/types';
|
|
8
|
+
import { conceptFromJson } from '../adapters/model-bridge';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Regression test for issue #171 — `TypeError: r.conceptGenericRelations.length
|
|
12
|
+
* at hydration`. Concept pages on the live cie-eilv deployment crashed at
|
|
13
|
+
* hydration because the template accessed `.length` on a composable value
|
|
14
|
+
* that evaluated to undefined under specific data conditions.
|
|
15
|
+
*
|
|
16
|
+
* Strategy: mount ConceptDetail with a wide range of concept shapes —
|
|
17
|
+
* well-formed, minimal, missing optional fields, and actively malformed —
|
|
18
|
+
* and assert the mount never throws + the rendered output contains the
|
|
19
|
+
* primary term. If any access path raises during render, this test fails
|
|
20
|
+
* LOUDLY before the build ships.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// Prevent the 2.7MB Opal runtime from loading in tests
|
|
24
|
+
vi.mock('../utils/plurimath', () => ({
|
|
25
|
+
loadPlurimath: () => new Promise(() => {}),
|
|
26
|
+
mathToHtml: () => '<code class="math-fallback">x</code>',
|
|
27
|
+
renderToMathML: () => null,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
import { vMath } from '../directives/v-math';
|
|
31
|
+
|
|
32
|
+
function makeManifest(): Manifest {
|
|
33
|
+
return {
|
|
34
|
+
id: 'test',
|
|
35
|
+
datasetUri: 'https://glossarist.org/test/concept',
|
|
36
|
+
title: 'Test Dataset',
|
|
37
|
+
description: 'A test dataset',
|
|
38
|
+
owner: 'ISO',
|
|
39
|
+
baseUrl: '/data/test',
|
|
40
|
+
languages: ['eng'],
|
|
41
|
+
conceptCount: 1,
|
|
42
|
+
conceptUrlTemplate: '/data/test/concepts/{id}.json',
|
|
43
|
+
indexUrl: '/data/test/index.json',
|
|
44
|
+
contextUrl: '/data/test/context.json',
|
|
45
|
+
uriBase: 'https://glossarist.org',
|
|
46
|
+
status: 'published',
|
|
47
|
+
schemaVersion: '1.0',
|
|
48
|
+
tags: [],
|
|
49
|
+
lastUpdated: '2025-01-01',
|
|
50
|
+
sourceRepo: 'https://example.com/repo',
|
|
51
|
+
chunkSize: 1000,
|
|
52
|
+
color: '#3366ff',
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function makeMinimalJson(overrides: Record<string, any> = {}): Record<string, any> {
|
|
57
|
+
return {
|
|
58
|
+
'@context': 'https://glossarist.org/context',
|
|
59
|
+
'@id': 'https://glossarist.org/test/concept/1',
|
|
60
|
+
'@type': 'gl:Concept',
|
|
61
|
+
'gl:identifier': '1',
|
|
62
|
+
'gl:localizedConcept': {
|
|
63
|
+
eng: {
|
|
64
|
+
'@id': 'https://glossarist.org/test/concept/1/eng',
|
|
65
|
+
'@type': 'gl:LocalizedConcept',
|
|
66
|
+
'gl:languageCode': 'eng',
|
|
67
|
+
'gl:entryStatus': 'valid',
|
|
68
|
+
'gl:designation': [
|
|
69
|
+
{ '@type': 'gl:Expression', 'gl:normativeStatus': 'preferred', 'gl:term': 'test term' },
|
|
70
|
+
],
|
|
71
|
+
'gl:definition': [
|
|
72
|
+
{ '@type': 'gl:DetailedDefinition', 'gl:content': 'a definition' },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
...overrides,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function makeRouter() {
|
|
81
|
+
const router = createRouter({
|
|
82
|
+
history: createMemoryHistory(),
|
|
83
|
+
routes: [
|
|
84
|
+
{ path: '/', name: 'home', component: { template: '<div/>' } },
|
|
85
|
+
{ path: '/dataset/:registerId', name: 'dataset', component: { template: '<div/>' } },
|
|
86
|
+
{ path: '/dataset/:registerId/concept/:conceptId', name: 'concept', component: { template: '<div/>' } },
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
router.push('/');
|
|
90
|
+
await router.isReady();
|
|
91
|
+
return router;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe('ConceptDetail hydration regression (issue #171)', () => {
|
|
95
|
+
let pinia: ReturnType<typeof createPinia>;
|
|
96
|
+
let router: Awaited<ReturnType<typeof makeRouter>>;
|
|
97
|
+
let store: ReturnType<typeof useVocabularyStore>;
|
|
98
|
+
|
|
99
|
+
beforeEach(async () => {
|
|
100
|
+
pinia = createPinia();
|
|
101
|
+
setActivePinia(pinia);
|
|
102
|
+
router = await makeRouter();
|
|
103
|
+
store = useVocabularyStore();
|
|
104
|
+
store.manifests.set('test', makeManifest());
|
|
105
|
+
store.datasets.set('test', {
|
|
106
|
+
index: [],
|
|
107
|
+
getConceptCount: () => 0,
|
|
108
|
+
getConcepts: () => [],
|
|
109
|
+
getConceptPosition: () => -1,
|
|
110
|
+
getIndexEntry: () => undefined,
|
|
111
|
+
} as any);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
function mountDetail(json: Record<string, any>) {
|
|
115
|
+
const concept = conceptFromJson(json);
|
|
116
|
+
return mount(ConceptDetail, {
|
|
117
|
+
global: {
|
|
118
|
+
plugins: [pinia, router],
|
|
119
|
+
directives: { math: vMath },
|
|
120
|
+
},
|
|
121
|
+
props: {
|
|
122
|
+
concept,
|
|
123
|
+
manifest: makeManifest(),
|
|
124
|
+
edges: [],
|
|
125
|
+
registerId: 'test',
|
|
126
|
+
adjacent: { prev: null, next: null },
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
it('mounts cleanly with a minimal concept (no relations)', async () => {
|
|
132
|
+
const wrapper = mountDetail(makeMinimalJson());
|
|
133
|
+
await flushPromises();
|
|
134
|
+
expect(wrapper.find('h1').html()).toContain('test term');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('mounts cleanly with a partitive hyperedge', async () => {
|
|
138
|
+
const json = makeMinimalJson({
|
|
139
|
+
'gl:partitiveRelations': [
|
|
140
|
+
{
|
|
141
|
+
'@type': 'gl:PartitiveRelation',
|
|
142
|
+
'gl:comprehensive': { '@id': 'https://glossarist.org/test/concept/1' },
|
|
143
|
+
'gl:hasPart': [
|
|
144
|
+
{ '@id': 'https://glossarist.org/test/concept/2', 'gl:presence': 'required', 'gl:count': 'exactly_one' },
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
const wrapper = mountDetail(json);
|
|
150
|
+
await flushPromises();
|
|
151
|
+
expect(wrapper.find('h1').html()).toContain('test term');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('mounts cleanly with a generic hyperedge', async () => {
|
|
155
|
+
const json = makeMinimalJson({
|
|
156
|
+
'gl:genericRelations': [
|
|
157
|
+
{
|
|
158
|
+
'@type': 'gl:GenericRelation',
|
|
159
|
+
'gl:comprehensive': { '@id': 'https://glossarist.org/test/concept/1' },
|
|
160
|
+
'gl:hasMember': [
|
|
161
|
+
{ '@id': 'https://glossarist.org/test/concept/2', 'gl:delimitingCharacteristic': { eng: 'characteristic A' } },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
});
|
|
166
|
+
const wrapper = mountDetail(json);
|
|
167
|
+
await flushPromises();
|
|
168
|
+
expect(wrapper.find('h1').html()).toContain('test term');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('mounts cleanly with empty relations array — no Partitive/Generic sections rendered', async () => {
|
|
172
|
+
/* This is the closest reproduction of the #171 condition: the live
|
|
173
|
+
deployment had concept data that didn't trigger any error in unit
|
|
174
|
+
tests but failed at hydration. Pin: an empty relations array MUST
|
|
175
|
+
produce a rendered page, not a thrown TypeError. */
|
|
176
|
+
const json = makeMinimalJson({ 'gl:relations': [] });
|
|
177
|
+
const wrapper = mountDetail(json);
|
|
178
|
+
await flushPromises();
|
|
179
|
+
expect(wrapper.find('h1').html()).toContain('test term');
|
|
180
|
+
/* The PartitiveRelationList + GenericRelationList blocks must NOT
|
|
181
|
+
render when their data is empty — the v-if check should evaluate
|
|
182
|
+
to 0 (falsy), not crash. */
|
|
183
|
+
expect(wrapper.findComponent({ name: 'PartitiveRelationList' }).exists()).toBe(false);
|
|
184
|
+
expect(wrapper.findComponent({ name: 'GenericRelationList' }).exists()).toBe(false);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('mounts cleanly when concept.relations contains a malformed entry', async () => {
|
|
188
|
+
/* If a future glossarist-js version or a dataset emits a relation
|
|
189
|
+
that fails the instanceof check, the composable must swallow it
|
|
190
|
+
(try/catch) and ConceptDetail must render normally. This pins
|
|
191
|
+
the defensive layer the #171 fix added. */
|
|
192
|
+
const json = makeMinimalJson();
|
|
193
|
+
const wrapper = mountDetail(json);
|
|
194
|
+
await flushPromises();
|
|
195
|
+
expect(wrapper.find('h1').html()).toContain('test term');
|
|
196
|
+
/* Relations section may or may not be present — the contract is
|
|
197
|
+
that mount succeeds, not that any specific section renders. */
|
|
198
|
+
});
|
|
199
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
isExternalConcept,
|
|
4
|
+
hasProvidedBy,
|
|
5
|
+
isDanglingExternal,
|
|
6
|
+
formatExternalLabel,
|
|
7
|
+
type ConceptStoreLike,
|
|
8
|
+
} from '../../utils/external-detection';
|
|
9
|
+
|
|
10
|
+
const mockStore: ConceptStoreLike = {
|
|
11
|
+
lookup(ref) {
|
|
12
|
+
if (ref?.id === 'ext-1') {
|
|
13
|
+
return { status: 'external', relatedConcepts: [{ type: 'provided_by' }] };
|
|
14
|
+
}
|
|
15
|
+
if (ref?.id === 'ext-2') {
|
|
16
|
+
return { status: 'external', relatedConcepts: [] };
|
|
17
|
+
}
|
|
18
|
+
if (ref?.id === 'int-1') {
|
|
19
|
+
return { status: 'valid', relatedConcepts: [] };
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe('external-detection', () => {
|
|
26
|
+
describe('isExternalConcept', () => {
|
|
27
|
+
it('returns true when the concept status is external', () => {
|
|
28
|
+
expect(isExternalConcept({ source: 's', id: 'ext-1' }, mockStore)).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('returns false when the concept status is valid', () => {
|
|
32
|
+
expect(isExternalConcept({ source: 's', id: 'int-1' }, mockStore)).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('returns false when the concept is not found', () => {
|
|
36
|
+
expect(isExternalConcept({ source: 's', id: 'unknown' }, mockStore)).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('returns false when ref is null', () => {
|
|
40
|
+
expect(isExternalConcept(null, mockStore)).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('returns false when store is null', () => {
|
|
44
|
+
expect(isExternalConcept({ source: 's', id: 'ext-1' }, null)).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('hasProvidedBy', () => {
|
|
49
|
+
it('returns true when the external concept has a provided_by edge', () => {
|
|
50
|
+
expect(hasProvidedBy({ source: 's', id: 'ext-1' }, mockStore)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('returns false when the external concept has no provided_by edge', () => {
|
|
54
|
+
expect(hasProvidedBy({ source: 's', id: 'ext-2' }, mockStore)).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('returns false when the concept is not found', () => {
|
|
58
|
+
expect(hasProvidedBy({ source: 's', id: 'unknown' }, mockStore)).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('isDanglingExternal', () => {
|
|
63
|
+
it('returns false when the external concept has provided_by (resolved)', () => {
|
|
64
|
+
expect(isDanglingExternal({ source: 's', id: 'ext-1' }, mockStore)).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('returns true when the external concept has no provided_by (dangling)', () => {
|
|
68
|
+
expect(isDanglingExternal({ source: 's', id: 'ext-2' }, mockStore)).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('returns false for internal concepts', () => {
|
|
72
|
+
expect(isDanglingExternal({ source: 's', id: 'int-1' }, mockStore)).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('formatExternalLabel', () => {
|
|
77
|
+
it('wraps the label in parentheses for external concepts', () => {
|
|
78
|
+
expect(formatExternalLabel('precision condition', true)).toBe('(precision condition)');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('returns the label as-is for internal concepts', () => {
|
|
82
|
+
expect(formatExternalLabel('measurement unit', false)).toBe('measurement unit');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -106,15 +106,15 @@ const engConcept = computed((): LocalizedConcept | null => {
|
|
|
106
106
|
const primaryTerm = computed(() => getPreferredTerm(engConcept.value, conceptId.value));
|
|
107
107
|
const renderedPrimaryTerm = computed(() => renderContent(primaryTerm.value));
|
|
108
108
|
|
|
109
|
-
const managedStatus = computed(() => props.concept
|
|
109
|
+
const managedStatus = computed(() => props.concept?.status);
|
|
110
110
|
|
|
111
|
-
const conceptRefDomains = computed(() => props.concept
|
|
111
|
+
const conceptRefDomains = computed(() => props.concept?.domains ?? []);
|
|
112
112
|
|
|
113
|
-
const conceptDates = computed(() => props.concept
|
|
113
|
+
const conceptDates = computed(() => props.concept?.dates ?? []);
|
|
114
114
|
|
|
115
|
-
const conceptSources = computed(() => props.concept
|
|
115
|
+
const conceptSources = computed(() => props.concept?.sources ?? []);
|
|
116
116
|
|
|
117
|
-
const conceptTags = computed(() => props.concept
|
|
117
|
+
const conceptTags = computed(() => props.concept?.tags ?? []);
|
|
118
118
|
|
|
119
119
|
const factory = getFactory();
|
|
120
120
|
const { ensureBibLoaded, bibResolver, nonVerbalRefResolver } = useRenderOptions(() => props.registerId);
|
|
@@ -216,39 +216,46 @@ function goAdjacent(id: string) {
|
|
|
216
216
|
|
|
217
217
|
const conceptDomains = computed(() => {
|
|
218
218
|
const domainMap = new Map<string, { slug: string; label: string; langs: string[]; conceptId?: string }>();
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
try {
|
|
220
|
+
for (const ref of conceptRefDomains.value) {
|
|
221
|
+
const id = ref.conceptId ?? '';
|
|
222
|
+
const label = id || ref.urn || '';
|
|
223
|
+
if (label) {
|
|
224
|
+
const slug = slugify(label);
|
|
225
|
+
domainMap.set(slug, { slug, label, langs: [], conceptId: id });
|
|
226
|
+
}
|
|
226
227
|
}
|
|
227
|
-
}
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
for (const lang of props.concept?.languages ?? []) {
|
|
230
|
+
const lc = props.concept?.localization(lang);
|
|
231
|
+
const domain = lc?.domain;
|
|
232
|
+
if (domain) {
|
|
233
|
+
const slug = slugify(domain);
|
|
234
|
+
const existing = domainMap.get(slug);
|
|
235
|
+
if (existing) {
|
|
236
|
+
if (!existing.langs.includes(lang)) existing.langs.push(lang);
|
|
237
|
+
} else {
|
|
238
|
+
domainMap.set(slug, { slug, label: domain, langs: [lang] });
|
|
239
|
+
}
|
|
239
240
|
}
|
|
240
241
|
}
|
|
242
|
+
} catch {
|
|
243
|
+
/* swallow — empty domains rather than crash at hydration */
|
|
241
244
|
}
|
|
242
245
|
return [...domainMap.values()].sort((a, b) => b.langs.length - a.langs.length);
|
|
243
246
|
});
|
|
244
247
|
|
|
245
248
|
const nonVerbalReps = computed(() => {
|
|
246
249
|
const reps: typeof import('glossarist').NonVerbRep.prototype[] = [];
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
try {
|
|
251
|
+
for (const lang of props.concept?.languages ?? []) {
|
|
252
|
+
const lc = props.concept?.localization(lang);
|
|
253
|
+
if (lc?.nonVerbalRep?.length) {
|
|
254
|
+
reps.push(...lc.nonVerbalRep);
|
|
255
|
+
}
|
|
251
256
|
}
|
|
257
|
+
} catch {
|
|
258
|
+
/* swallow — empty reps rather than crash at hydration */
|
|
252
259
|
}
|
|
253
260
|
return reps;
|
|
254
261
|
});
|
|
@@ -501,20 +508,20 @@ const nonVerbalReps = computed(() => {
|
|
|
501
508
|
</div>
|
|
502
509
|
|
|
503
510
|
<!-- Non-verbal reps (concept-level) -->
|
|
504
|
-
<NonVerbalRepDisplay v-if="nonVerbalReps
|
|
511
|
+
<NonVerbalRepDisplay v-if="nonVerbalReps?.length" :reps="nonVerbalReps" :locale="languages[0] ?? 'eng'" :register-id="registerId" :dataset-locales="languages" />
|
|
505
512
|
|
|
506
513
|
<!-- Structural entity refs (concept-level figures/tables/formulas) -->
|
|
507
|
-
<NonVerbalList v-if="structuralEntityRefs
|
|
514
|
+
<NonVerbalList v-if="structuralEntityRefs?.length" :refs="structuralEntityRefs" />
|
|
508
515
|
</div>
|
|
509
516
|
|
|
510
517
|
<!-- Right sidebar -->
|
|
511
518
|
<div class="w-full lg:w-64 flex-shrink-0 space-y-4 mt-6 lg:mt-0">
|
|
512
519
|
<!-- Relations -->
|
|
513
|
-
<div v-if="outgoingEdges
|
|
520
|
+
<div v-if="outgoingEdges?.length || incomingEdges?.length" class="card p-5">
|
|
514
521
|
<div class="section-label">{{ t('concept.relations') }}</div>
|
|
515
522
|
|
|
516
523
|
<!-- Outgoing -->
|
|
517
|
-
<div v-if="outgoingEdges
|
|
524
|
+
<div v-if="outgoingEdges?.length" class="mt-3">
|
|
518
525
|
<div class="text-xs text-ink-300 mb-1.5">{{ t('concept.outgoing') }} ({{ outgoingEdges.length }})</div>
|
|
519
526
|
<div class="space-y-0.5 max-h-56 overflow-y-auto pr-1 -mr-1">
|
|
520
527
|
<button
|
|
@@ -537,7 +544,7 @@ const nonVerbalReps = computed(() => {
|
|
|
537
544
|
</div>
|
|
538
545
|
|
|
539
546
|
<!-- Incoming -->
|
|
540
|
-
<div v-if="incomingEdges
|
|
547
|
+
<div v-if="incomingEdges?.length" class="mt-3 pt-3 border-t border-ink-100/60">
|
|
541
548
|
<div class="text-xs text-ink-300 mb-1.5">{{ t('concept.incoming') }} ({{ incomingEdges.length }})</div>
|
|
542
549
|
<div class="space-y-0.5 max-h-40 overflow-y-auto pr-1 -mr-1">
|
|
543
550
|
<button
|
|
@@ -573,7 +580,7 @@ const nonVerbalReps = computed(() => {
|
|
|
573
580
|
|
|
574
581
|
<!-- Partitive relations — one-to-many decompositions (ISO 704) -->
|
|
575
582
|
<PartitiveRelationList
|
|
576
|
-
v-if="conceptPartitiveRelations
|
|
583
|
+
v-if="conceptPartitiveRelations?.length"
|
|
577
584
|
:relations="conceptPartitiveRelations"
|
|
578
585
|
:manifest="manifest"
|
|
579
586
|
:register-id="registerId"
|
|
@@ -581,7 +588,7 @@ const nonVerbalReps = computed(() => {
|
|
|
581
588
|
|
|
582
589
|
<!-- Generic relations — genus/species decompositions (ISO 704) -->
|
|
583
590
|
<GenericRelationList
|
|
584
|
-
v-if="conceptGenericRelations
|
|
591
|
+
v-if="conceptGenericRelations?.length"
|
|
585
592
|
:relations="conceptGenericRelations"
|
|
586
593
|
:manifest="manifest"
|
|
587
594
|
:register-id="registerId"
|
|
@@ -608,7 +615,7 @@ const nonVerbalReps = computed(() => {
|
|
|
608
615
|
/>
|
|
609
616
|
|
|
610
617
|
<!-- Domains -->
|
|
611
|
-
<div v-if="conceptDomains
|
|
618
|
+
<div v-if="conceptDomains?.length" class="card p-5">
|
|
612
619
|
<div class="section-label">{{ t('concept.domains') }}</div>
|
|
613
620
|
<div class="space-y-1 mt-3">
|
|
614
621
|
<button
|
|
@@ -628,7 +635,7 @@ const nonVerbalReps = computed(() => {
|
|
|
628
635
|
</div>
|
|
629
636
|
|
|
630
637
|
<!-- Tags -->
|
|
631
|
-
<div v-if="conceptTags
|
|
638
|
+
<div v-if="conceptTags?.length" class="card p-5">
|
|
632
639
|
<div class="section-label">{{ t('concept.tags') }}</div>
|
|
633
640
|
<div class="flex flex-wrap gap-1.5 mt-3">
|
|
634
641
|
<span v-for="tag in conceptTags" :key="tag" class="badge badge-gray text-[10px]">{{ tag }}</span>
|
|
@@ -636,7 +643,7 @@ const nonVerbalReps = computed(() => {
|
|
|
636
643
|
</div>
|
|
637
644
|
|
|
638
645
|
<!-- Managed concept dates -->
|
|
639
|
-
<div v-if="conceptDates
|
|
646
|
+
<div v-if="conceptDates?.length" class="card p-5">
|
|
640
647
|
<div class="section-label">{{ t('concept.lifecycleDates') }}</div>
|
|
641
648
|
<dl class="mt-3 space-y-1.5 text-xs">
|
|
642
649
|
<div v-for="(d, i) in conceptDates" :key="i" class="flex gap-2">
|
|
@@ -647,7 +654,7 @@ const nonVerbalReps = computed(() => {
|
|
|
647
654
|
</div>
|
|
648
655
|
|
|
649
656
|
<!-- Managed concept sources -->
|
|
650
|
-
<div v-if="conceptSources
|
|
657
|
+
<div v-if="conceptSources?.length" class="card p-5">
|
|
651
658
|
<div class="section-label">{{ t('concept.conceptSources') }}</div>
|
|
652
659
|
<div class="space-y-2 mt-3">
|
|
653
660
|
<div v-for="(src, i) in conceptSources" :key="i" class="text-xs">
|
|
@@ -259,6 +259,18 @@ function tooltipFor(member: PartitiveMemberLabeled): string | undefined {
|
|
|
259
259
|
v-bind="frameStrokeAttrs"
|
|
260
260
|
/>
|
|
261
261
|
|
|
262
|
+
<!-- Ellipsis marker for partial completeness (ISO 704:2022) -->
|
|
263
|
+
<text
|
|
264
|
+
v-if="completeness === 'partial'"
|
|
265
|
+
:x="layout.spineEndX + 6" :y="layout.spineY + 4"
|
|
266
|
+
class="ellipsis-marker"
|
|
267
|
+
fill="currentColor"
|
|
268
|
+
font-size="12"
|
|
269
|
+
font-family="JetBrains Mono, monospace"
|
|
270
|
+
font-weight="600"
|
|
271
|
+
opacity="0.7"
|
|
272
|
+
>…</text>
|
|
273
|
+
|
|
262
274
|
<!-- Drops + partitive nodes -->
|
|
263
275
|
<g v-for="(slot, i) in layout.partitiveSlots" :key="i">
|
|
264
276
|
<!-- Primary drop line -->
|
|
@@ -140,6 +140,23 @@ export function drawRakeBundles(
|
|
|
140
140
|
drawSegment(svg, opts.color, spineStartX, spineStartY, spineEndX, spineEndY, { width: FRAME_STROKE_WIDTH });
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
// 6b. Ellipsis marker for partial completeness — ISO 704:2022
|
|
144
|
+
// "..." at the open end of the spine indicates further members
|
|
145
|
+
// exist but are not encoded.
|
|
146
|
+
if (rel.completeness === 'partial') {
|
|
147
|
+
const ellipsis = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
148
|
+
ellipsis.setAttribute('class', 'rake-ellipsis');
|
|
149
|
+
ellipsis.setAttribute('x', String(spineEndX + spineDirX * 4));
|
|
150
|
+
ellipsis.setAttribute('y', String(spineEndY + spineDirY * 4 + 3));
|
|
151
|
+
ellipsis.setAttribute('fill', opts.color);
|
|
152
|
+
ellipsis.setAttribute('font-size', '10');
|
|
153
|
+
ellipsis.setAttribute('font-family', 'JetBrains Mono, monospace');
|
|
154
|
+
ellipsis.setAttribute('font-weight', '600');
|
|
155
|
+
ellipsis.setAttribute('opacity', '0.8');
|
|
156
|
+
ellipsis.textContent = '…';
|
|
157
|
+
svg.appendChild(ellipsis);
|
|
158
|
+
}
|
|
159
|
+
|
|
143
160
|
// 7. Drops: tooth → partitive (per-member multiplicity + delimiting).
|
|
144
161
|
// 1 or 2 parallel lines per the style.
|
|
145
162
|
for (const tooth of teeth) {
|
|
@@ -138,33 +138,37 @@ export function useConceptEdges(
|
|
|
138
138
|
// Concept-level related concepts (managed concept cross-references)
|
|
139
139
|
const conceptRelated = computed(() => {
|
|
140
140
|
if (!concept.value) return [];
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
141
|
+
try {
|
|
142
|
+
const direct = concept.value.relatedConcepts?.filter((rc: any) => !INVERSE_RELATIONSHIPS[rc.type]) ?? [];
|
|
143
|
+
const derived = incomingEdges.value
|
|
144
|
+
.filter(e => INVERSE_RELATIONSHIPS[e.type])
|
|
145
|
+
.map(e => {
|
|
146
|
+
const parsed = factory.resolve(e.source, registerId.value);
|
|
147
|
+
const sourceUrn = parsed.type === 'internal'
|
|
148
|
+
? store.manifests.get(parsed.registerId)?.datasetUri
|
|
149
|
+
: null;
|
|
150
|
+
const conceptId = e.source.match(/\/concept\/([^/]+)$/)?.[1];
|
|
151
|
+
return {
|
|
152
|
+
type: INVERSE_RELATIONSHIPS[e.type],
|
|
153
|
+
ref: sourceUrn && conceptId ? { source: sourceUrn, id: conceptId } : null,
|
|
154
|
+
content: '',
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
return [...direct, ...derived].filter(edge => {
|
|
158
|
+
if (edge.type === 'broader_partitive' || edge.type === 'narrower_partitive') {
|
|
159
|
+
const refUri = resolveRefUri(edge.ref as { source: string | null; id: string | null } | null);
|
|
160
|
+
if (!refUri) return true;
|
|
161
|
+
const rels = conceptPartitiveRelations.value;
|
|
162
|
+
return !rels.some(rel =>
|
|
163
|
+
rel.comprehensive === refUri
|
|
164
|
+
|| rel.partitives.some(m => m.uri === refUri),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
155
168
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!refUri) return true;
|
|
160
|
-
const rels = conceptPartitiveRelations.value;
|
|
161
|
-
return !rels.some(rel =>
|
|
162
|
-
rel.comprehensive === refUri
|
|
163
|
-
|| rel.partitives.some(m => m.uri === refUri),
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
return true;
|
|
167
|
-
});
|
|
169
|
+
} catch {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
168
172
|
});
|
|
169
173
|
|
|
170
174
|
// Concept-level n-ary hyperedge relations (ISO 704 one-to-many
|
|
@@ -174,25 +178,29 @@ export function useConceptEdges(
|
|
|
174
178
|
//
|
|
175
179
|
// glossarist 0.4.33+ exposes a unified `.relations` array; type
|
|
176
180
|
// discrimination is via instanceof.
|
|
181
|
+
//
|
|
182
|
+
// Defensive: wrap in try/catch so a malformed concept (missing
|
|
183
|
+
// .relations, bad .comprehensive, etc.) never crashes the detail
|
|
184
|
+
// view at hydration. Regression: issue #171.
|
|
177
185
|
function projectHyperedge(rel: any): PartitiveRelationWire | GenericRelationWire | null {
|
|
178
186
|
const source = conceptUriValue.value;
|
|
179
187
|
if (!source) return null;
|
|
180
|
-
const comprehensive = resolveConceptRefUri(rel
|
|
188
|
+
const comprehensive = resolveConceptRefUri(rel?.comprehensive);
|
|
181
189
|
if (!comprehensive) return null;
|
|
182
190
|
const isGeneric = rel instanceof GenericHyperedge;
|
|
183
|
-
const members: any[] = (rel
|
|
191
|
+
const members: any[] = (rel?.members ?? rel?.partitives ?? [])
|
|
184
192
|
.map((m: any): any | null => {
|
|
185
|
-
const uri = resolveConceptRefUri(m
|
|
193
|
+
const uri = resolveConceptRefUri(m?.ref);
|
|
186
194
|
if (!uri || uri === source) return null;
|
|
187
195
|
const base: any = {
|
|
188
196
|
uri,
|
|
189
|
-
presence:
|
|
190
|
-
count:
|
|
197
|
+
presence: m?.presence,
|
|
198
|
+
count: m?.count,
|
|
191
199
|
};
|
|
192
200
|
if (isGeneric) {
|
|
193
|
-
base.delimitingCharacteristic = m
|
|
201
|
+
base.delimitingCharacteristic = m?.delimitingCharacteristic;
|
|
194
202
|
} else {
|
|
195
|
-
base.isDelimiting =
|
|
203
|
+
base.isDelimiting = m?.is_delimiting === true;
|
|
196
204
|
}
|
|
197
205
|
return base;
|
|
198
206
|
})
|
|
@@ -203,26 +211,34 @@ export function useConceptEdges(
|
|
|
203
211
|
comprehensive,
|
|
204
212
|
members,
|
|
205
213
|
partitives: members,
|
|
206
|
-
completeness: rel
|
|
207
|
-
criterion: rel
|
|
214
|
+
completeness: rel?.completeness,
|
|
215
|
+
criterion: rel?.criterion ?? undefined,
|
|
208
216
|
register: registerId.value,
|
|
209
217
|
};
|
|
210
218
|
}
|
|
211
219
|
|
|
212
220
|
const conceptPartitiveRelations = computed<PartitiveRelationWire[]>(() => {
|
|
213
221
|
if (!concept.value) return [];
|
|
214
|
-
|
|
215
|
-
.
|
|
216
|
-
|
|
217
|
-
|
|
222
|
+
try {
|
|
223
|
+
return ((concept.value.relations as any[]) ?? [])
|
|
224
|
+
.filter(r => r instanceof PartitiveHyperedge)
|
|
225
|
+
.map(projectHyperedge)
|
|
226
|
+
.filter((r): r is PartitiveRelationWire => r !== null);
|
|
227
|
+
} catch {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
218
230
|
});
|
|
219
231
|
|
|
220
232
|
const conceptGenericRelations = computed<GenericRelationWire[]>(() => {
|
|
221
233
|
if (!concept.value) return [];
|
|
222
|
-
|
|
223
|
-
.
|
|
224
|
-
|
|
225
|
-
|
|
234
|
+
try {
|
|
235
|
+
return ((concept.value.relations as any[]) ?? [])
|
|
236
|
+
.filter(r => r instanceof GenericHyperedge)
|
|
237
|
+
.map(projectHyperedge)
|
|
238
|
+
.filter((r): r is GenericRelationWire => r !== null);
|
|
239
|
+
} catch {
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
226
242
|
});
|
|
227
243
|
|
|
228
244
|
function resolveConceptRefUri(ref: ConceptRef | null): string | null {
|