@eightyfourthousand/data-access 2026.3.0
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/.babelrc +12 -0
- package/.eslintrc.json +18 -0
- package/README.md +7 -0
- package/jest.config.ts +10 -0
- package/package.json +30 -0
- package/project.json +21 -0
- package/src/index.ts +18 -0
- package/src/lib/auth.ts +203 -0
- package/src/lib/bibliography.ts +57 -0
- package/src/lib/canon.ts +111 -0
- package/src/lib/client-browser.ts +12 -0
- package/src/lib/client-server.ts +30 -0
- package/src/lib/client-ssr.ts +24 -0
- package/src/lib/client-token.ts +24 -0
- package/src/lib/feedback.ts +71 -0
- package/src/lib/folio.ts +43 -0
- package/src/lib/glossary.ts +147 -0
- package/src/lib/imprint.ts +42 -0
- package/src/lib/library.ts +209 -0
- package/src/lib/local-storage.ts +33 -0
- package/src/lib/lookup-entity.ts +122 -0
- package/src/lib/panel-url.ts +43 -0
- package/src/lib/passage.ts +122 -0
- package/src/lib/projects.ts +107 -0
- package/src/lib/proxy.ts +68 -0
- package/src/lib/publications.ts +213 -0
- package/src/lib/storage.ts +23 -0
- package/src/lib/types/alignment.ts +32 -0
- package/src/lib/types/annotation/abbreviation.ts +30 -0
- package/src/lib/types/annotation/annotation-type.ts +219 -0
- package/src/lib/types/annotation/annotation.ts +244 -0
- package/src/lib/types/annotation/audio.ts +33 -0
- package/src/lib/types/annotation/blockquote.ts +18 -0
- package/src/lib/types/annotation/code.ts +16 -0
- package/src/lib/types/annotation/deprecated.ts +18 -0
- package/src/lib/types/annotation/end-note-link.ts +35 -0
- package/src/lib/types/annotation/export.ts +69 -0
- package/src/lib/types/annotation/glossary-instance.ts +34 -0
- package/src/lib/types/annotation/has-abbreviation.ts +30 -0
- package/src/lib/types/annotation/heading.ts +37 -0
- package/src/lib/types/annotation/image.ts +29 -0
- package/src/lib/types/annotation/indent.ts +16 -0
- package/src/lib/types/annotation/index.ts +4 -0
- package/src/lib/types/annotation/inline-title.ts +34 -0
- package/src/lib/types/annotation/internal-link.ts +86 -0
- package/src/lib/types/annotation/leading-space.ts +18 -0
- package/src/lib/types/annotation/line-group.ts +18 -0
- package/src/lib/types/annotation/line.ts +16 -0
- package/src/lib/types/annotation/link.ts +38 -0
- package/src/lib/types/annotation/list-item.ts +16 -0
- package/src/lib/types/annotation/list.ts +43 -0
- package/src/lib/types/annotation/mantra.ts +31 -0
- package/src/lib/types/annotation/mention.ts +64 -0
- package/src/lib/types/annotation/paragraph.ts +18 -0
- package/src/lib/types/annotation/quote.ts +30 -0
- package/src/lib/types/annotation/quoted.ts +30 -0
- package/src/lib/types/annotation/reference.ts +18 -0
- package/src/lib/types/annotation/span.ts +39 -0
- package/src/lib/types/annotation/table-body-data.ts +18 -0
- package/src/lib/types/annotation/table-body-header.ts +18 -0
- package/src/lib/types/annotation/table-body-row.ts +18 -0
- package/src/lib/types/annotation/table.ts +16 -0
- package/src/lib/types/annotation/trailer.ts +16 -0
- package/src/lib/types/annotation/transform.ts +140 -0
- package/src/lib/types/annotation/unknown.ts +16 -0
- package/src/lib/types/bibliography.ts +86 -0
- package/src/lib/types/canon.ts +148 -0
- package/src/lib/types/client.ts +3 -0
- package/src/lib/types/contributor.ts +84 -0
- package/src/lib/types/editor-content.ts +21 -0
- package/src/lib/types/folio.ts +28 -0
- package/src/lib/types/glossary-page.ts +204 -0
- package/src/lib/types/glossary.ts +114 -0
- package/src/lib/types/imprint.ts +159 -0
- package/src/lib/types/index.ts +22 -0
- package/src/lib/types/language.ts +64 -0
- package/src/lib/types/layout.ts +37 -0
- package/src/lib/types/library.ts +29 -0
- package/src/lib/types/passage.ts +220 -0
- package/src/lib/types/project.ts +200 -0
- package/src/lib/types/semver.ts +1 -0
- package/src/lib/types/title.ts +47 -0
- package/src/lib/types/toh.ts +1 -0
- package/src/lib/types/translation.ts +15 -0
- package/src/lib/types/user.ts +15 -0
- package/src/lib/types/work.ts +38 -0
- package/src/lib/use-bookmark.ts +45 -0
- package/src/ssr.ts +5 -0
- package/tsconfig.json +20 -0
- package/tsconfig.lib.json +26 -0
- package/tsconfig.spec.json +22 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { removeHtmlTags } from '@eightyfourthousand/lib-utils';
|
|
2
|
+
import { TohokuCatalogEntry } from './toh';
|
|
3
|
+
import {
|
|
4
|
+
ExtendedTranslationLanguage,
|
|
5
|
+
displayLanguageForTranslationLanguage,
|
|
6
|
+
} from './language';
|
|
7
|
+
|
|
8
|
+
export type GlossaryPageLanguage =
|
|
9
|
+
| 'english'
|
|
10
|
+
| 'tibetan'
|
|
11
|
+
| 'sanskrit'
|
|
12
|
+
| 'pali'
|
|
13
|
+
| 'chinese';
|
|
14
|
+
|
|
15
|
+
export type GlossaryLandingItem = {
|
|
16
|
+
uuid: string;
|
|
17
|
+
headword: string;
|
|
18
|
+
type: string;
|
|
19
|
+
language: string;
|
|
20
|
+
nameVariants: string;
|
|
21
|
+
definition: string;
|
|
22
|
+
numGlossaryEntries: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type LanguageRecord = Record<GlossaryPageLanguage, string[]>;
|
|
26
|
+
|
|
27
|
+
export type GlossaryDetailItem = LanguageRecord & {
|
|
28
|
+
authorityUuid: string;
|
|
29
|
+
headword: string;
|
|
30
|
+
language: GlossaryPageLanguage;
|
|
31
|
+
classifications: string[];
|
|
32
|
+
definition?: string;
|
|
33
|
+
xmlId?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type GlossaryPageItem = GlossaryDetailItem & {
|
|
37
|
+
relatedInstances: GlossaryInstance[];
|
|
38
|
+
relatedEntities: GlossaryEntity[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type GlossaryInstance = LanguageRecord & {
|
|
42
|
+
workUuid: string;
|
|
43
|
+
toh: TohokuCatalogEntry;
|
|
44
|
+
definition?: string;
|
|
45
|
+
canon?: string;
|
|
46
|
+
creators: string[];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type GlossaryEntity = {
|
|
50
|
+
sourceHeadword: string;
|
|
51
|
+
sourceUuid: string;
|
|
52
|
+
targetHeadword: string;
|
|
53
|
+
targetUuid: string;
|
|
54
|
+
};
|
|
55
|
+
export type GlossaryLandingItemDTO = {
|
|
56
|
+
authority_uuid: string;
|
|
57
|
+
headword: string;
|
|
58
|
+
type: string;
|
|
59
|
+
headword_language?: ExtendedTranslationLanguage;
|
|
60
|
+
name_variants?: string;
|
|
61
|
+
definition?: string;
|
|
62
|
+
num_glossary_entries?: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type GlossaryDetailDTO = {
|
|
66
|
+
authority_uuid: string;
|
|
67
|
+
xmlId?: string;
|
|
68
|
+
headword: string;
|
|
69
|
+
headword_language?: GlossaryPageLanguage | null;
|
|
70
|
+
classifications?: string[] | null;
|
|
71
|
+
definition?: string | null;
|
|
72
|
+
tibetan_names?: string[] | null;
|
|
73
|
+
sanskrit_names?: string[] | null;
|
|
74
|
+
pali_names?: string[] | null;
|
|
75
|
+
chinese_names?: string[] | null;
|
|
76
|
+
english_names?: string[] | null;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type GlossaryEntityDTO = {
|
|
80
|
+
related_entity_object_headword: string;
|
|
81
|
+
related_entity_object_uuid: string;
|
|
82
|
+
related_entity_subject_headword: string;
|
|
83
|
+
related_entity_subject_uuid: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type GlossaryInstanceDTO = {
|
|
87
|
+
glossary_entry_work_uuid: string;
|
|
88
|
+
glossary_entry_toh: TohokuCatalogEntry;
|
|
89
|
+
glossary_entry_english?: string | null;
|
|
90
|
+
glossary_entry_tibetan?: string | null;
|
|
91
|
+
glossary_entry_sanskrit?: string | null;
|
|
92
|
+
glossary_entry_chinese?: string | null;
|
|
93
|
+
glossary_entry_pali?: string | null;
|
|
94
|
+
glossary_entry_definition?: string | null;
|
|
95
|
+
glossary_entry_canon?: string | null;
|
|
96
|
+
glossary_entry_creators?: string[] | null;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const glossaryLandingItemFromDTO = (
|
|
100
|
+
dto?: GlossaryLandingItemDTO,
|
|
101
|
+
): GlossaryLandingItem | null => {
|
|
102
|
+
if (!dto) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const definition = removeHtmlTags(dto.definition || '');
|
|
107
|
+
const language = dto.headword_language
|
|
108
|
+
? displayLanguageForTranslationLanguage(dto.headword_language)
|
|
109
|
+
: '';
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
uuid: dto.authority_uuid,
|
|
113
|
+
headword: dto.headword,
|
|
114
|
+
type: dto.type.replace('Authority > ', ''),
|
|
115
|
+
language,
|
|
116
|
+
nameVariants: dto.name_variants || '',
|
|
117
|
+
definition,
|
|
118
|
+
numGlossaryEntries: dto.num_glossary_entries || 0,
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const glossaryDetailFromDTO = (
|
|
123
|
+
dto?: GlossaryDetailDTO,
|
|
124
|
+
): GlossaryDetailItem | null => {
|
|
125
|
+
if (!dto) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
authorityUuid: dto.authority_uuid,
|
|
131
|
+
headword: dto.headword,
|
|
132
|
+
language: dto.headword_language as GlossaryPageLanguage,
|
|
133
|
+
classifications: dto.classifications || [],
|
|
134
|
+
definition: dto.definition || undefined,
|
|
135
|
+
xmlId: dto.xmlId,
|
|
136
|
+
english: dto.english_names || [],
|
|
137
|
+
tibetan: dto.tibetan_names || [],
|
|
138
|
+
sanskrit: dto.sanskrit_names || [],
|
|
139
|
+
pali: dto.pali_names || [],
|
|
140
|
+
chinese: dto.chinese_names || [],
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const glossaryInstanceFromDTO = (
|
|
145
|
+
dto?: GlossaryInstanceDTO,
|
|
146
|
+
): GlossaryInstance | null => {
|
|
147
|
+
if (!dto) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
workUuid: dto.glossary_entry_work_uuid,
|
|
153
|
+
toh: dto.glossary_entry_toh,
|
|
154
|
+
definition: dto.glossary_entry_definition || undefined,
|
|
155
|
+
canon: dto.glossary_entry_canon || undefined,
|
|
156
|
+
english: dto.glossary_entry_english ? [dto.glossary_entry_english] : [],
|
|
157
|
+
tibetan: dto.glossary_entry_tibetan ? [dto.glossary_entry_tibetan] : [],
|
|
158
|
+
sanskrit: dto.glossary_entry_sanskrit ? [dto.glossary_entry_sanskrit] : [],
|
|
159
|
+
pali: dto.glossary_entry_pali ? [dto.glossary_entry_pali] : [],
|
|
160
|
+
chinese: dto.glossary_entry_chinese ? [dto.glossary_entry_chinese] : [],
|
|
161
|
+
creators: dto.glossary_entry_creators || [],
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const glossaryEntityFromDTO = (
|
|
166
|
+
dto?: GlossaryEntityDTO,
|
|
167
|
+
): GlossaryEntity | null => {
|
|
168
|
+
if (!dto) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
sourceHeadword: dto.related_entity_subject_headword,
|
|
174
|
+
sourceUuid: dto.related_entity_subject_uuid,
|
|
175
|
+
targetHeadword: dto.related_entity_object_headword,
|
|
176
|
+
targetUuid: dto.related_entity_object_uuid,
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const glossaryPageItemFromDTO = (
|
|
181
|
+
detail: GlossaryDetailDTO,
|
|
182
|
+
instances: GlossaryInstanceDTO[],
|
|
183
|
+
entities: GlossaryEntityDTO[],
|
|
184
|
+
): GlossaryPageItem => {
|
|
185
|
+
const detailItem = glossaryDetailFromDTO(detail);
|
|
186
|
+
if (!detailItem) {
|
|
187
|
+
throw new Error('Invalid glossary detail item');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const relatedInstances =
|
|
191
|
+
instances
|
|
192
|
+
.map(glossaryInstanceFromDTO)
|
|
193
|
+
.filter((i): i is GlossaryInstance => i !== null) || [];
|
|
194
|
+
const relatedEntities =
|
|
195
|
+
entities
|
|
196
|
+
.map(glossaryEntityFromDTO)
|
|
197
|
+
.filter((e): e is GlossaryEntity => e !== null) || [];
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
...detailItem,
|
|
201
|
+
relatedInstances,
|
|
202
|
+
relatedEntities,
|
|
203
|
+
};
|
|
204
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
export type GlossaryItem = {
|
|
3
|
+
authorityUuid: string;
|
|
4
|
+
definition?: string | null;
|
|
5
|
+
names: GlossaryNames;
|
|
6
|
+
nameUuid?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type Glossary = GlossaryItem[];
|
|
10
|
+
|
|
11
|
+
export type GlossaryName = {
|
|
12
|
+
content: string;
|
|
13
|
+
definition?: string | null;
|
|
14
|
+
nameUuid: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type GlossaryNames = GlossaryName[];
|
|
18
|
+
|
|
19
|
+
export type GlossaryItemDTO = {
|
|
20
|
+
authority_uuid: string;
|
|
21
|
+
definition?: string | null;
|
|
22
|
+
names: GlossaryNamesDTO;
|
|
23
|
+
name_uuid: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type GlossaryDTO = GlossaryItemDTO[];
|
|
27
|
+
|
|
28
|
+
export type GlossaryNameDTO = {
|
|
29
|
+
content: string;
|
|
30
|
+
definition?: string | null;
|
|
31
|
+
name_uuid: string;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type GlossaryNamesDTO = GlossaryNameDTO[];
|
|
35
|
+
|
|
36
|
+
export type GlossaryTermInstance = {
|
|
37
|
+
uuid: string;
|
|
38
|
+
authority: string;
|
|
39
|
+
workUuid: string;
|
|
40
|
+
definition?: string | null;
|
|
41
|
+
termNumber: number;
|
|
42
|
+
names: {
|
|
43
|
+
chinese?: string;
|
|
44
|
+
english?: string;
|
|
45
|
+
pali?: string;
|
|
46
|
+
sanskrit?: string;
|
|
47
|
+
tibetan?: string;
|
|
48
|
+
wylie?: string;
|
|
49
|
+
};
|
|
50
|
+
passages?: {
|
|
51
|
+
items: Array<{ uuid: string; type: string; label: string }>;
|
|
52
|
+
nextCursor: string | null;
|
|
53
|
+
hasMore: boolean;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type GlossaryTermInstances = GlossaryTermInstance[];
|
|
58
|
+
|
|
59
|
+
export type GlossaryTermInstanceDTO = {
|
|
60
|
+
uuid: string;
|
|
61
|
+
authority_uuid: string;
|
|
62
|
+
work_uuid: string;
|
|
63
|
+
definition?: string;
|
|
64
|
+
names: {
|
|
65
|
+
chinese?: string;
|
|
66
|
+
english?: string;
|
|
67
|
+
pali?: string;
|
|
68
|
+
sanskrit?: string;
|
|
69
|
+
tibetan?: string;
|
|
70
|
+
wylie?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type GlossaryTermInstancesDTO = {
|
|
75
|
+
work_uuid: string;
|
|
76
|
+
glossary_entries: GlossaryTermInstanceDTO[];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const glossaryNameFromDTO = (dto: GlossaryNameDTO): GlossaryName => {
|
|
80
|
+
return {
|
|
81
|
+
content: dto.content,
|
|
82
|
+
definition: dto.definition,
|
|
83
|
+
nameUuid: dto.name_uuid,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const glossaryNamesFromDTO = (dto?: GlossaryNamesDTO): GlossaryNames => {
|
|
88
|
+
return dto?.map(glossaryNameFromDTO) || [];
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const glossaryItemFromDTO = (dto: GlossaryItemDTO): GlossaryItem => {
|
|
92
|
+
return {
|
|
93
|
+
authorityUuid: dto.authority_uuid,
|
|
94
|
+
definition: dto.definition,
|
|
95
|
+
names: glossaryNamesFromDTO(dto.names),
|
|
96
|
+
nameUuid: dto.name_uuid,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export const glossaryFromDTO = (dto?: GlossaryDTO): Glossary => {
|
|
100
|
+
return dto?.map(glossaryItemFromDTO) || [];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const glossaryTermInstanceFromDTO = (
|
|
104
|
+
dto: GlossaryTermInstanceDTO,
|
|
105
|
+
): GlossaryTermInstance => {
|
|
106
|
+
return {
|
|
107
|
+
uuid: dto.uuid,
|
|
108
|
+
authority: dto.authority_uuid,
|
|
109
|
+
workUuid: dto.work_uuid,
|
|
110
|
+
definition: dto.definition,
|
|
111
|
+
termNumber: 0,
|
|
112
|
+
names: dto.names,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { TranslationLanguage } from './language';
|
|
2
|
+
import { BACK_MATTER, BODY_MATTER, FRONT_MATTER } from './passage';
|
|
3
|
+
import { SemVer } from './semver';
|
|
4
|
+
|
|
5
|
+
export type Imprint = {
|
|
6
|
+
uuid: string;
|
|
7
|
+
toh: string;
|
|
8
|
+
section?: string;
|
|
9
|
+
version?: SemVer;
|
|
10
|
+
restriction?: boolean;
|
|
11
|
+
publishYear?: string;
|
|
12
|
+
tibetanAuthors?: string[];
|
|
13
|
+
isAuthorContested: boolean;
|
|
14
|
+
sourceDescription?: string;
|
|
15
|
+
publisherStatement?: string;
|
|
16
|
+
tibetanTranslators?: string;
|
|
17
|
+
license: {
|
|
18
|
+
link?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
};
|
|
22
|
+
mainTitles?: Partial<{ [key in TranslationLanguage]: string }>;
|
|
23
|
+
longTitles?: Partial<{ [key in TranslationLanguage]: string }>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ImprintDTO = {
|
|
27
|
+
work_uuid: string;
|
|
28
|
+
toh: string;
|
|
29
|
+
section?: string;
|
|
30
|
+
version?: SemVer;
|
|
31
|
+
restriction?: boolean;
|
|
32
|
+
publishYear?: string;
|
|
33
|
+
tibetanAuthors?: string;
|
|
34
|
+
isAuthorContested?: boolean;
|
|
35
|
+
sourceDescription?: string;
|
|
36
|
+
publisherStatement?: string;
|
|
37
|
+
tibetanTranslators?: string;
|
|
38
|
+
license: {
|
|
39
|
+
link?: string;
|
|
40
|
+
name?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
};
|
|
43
|
+
mainTitles?: Partial<{ [key in TranslationLanguage]: string }>;
|
|
44
|
+
longTitles?: Partial<{ [key in TranslationLanguage]: string }>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const imprintFromDTO = (dto: ImprintDTO): Imprint => {
|
|
48
|
+
return {
|
|
49
|
+
uuid: dto.work_uuid,
|
|
50
|
+
toh: dto.toh,
|
|
51
|
+
section: dto.section,
|
|
52
|
+
version: dto.version,
|
|
53
|
+
restriction: dto.restriction,
|
|
54
|
+
publishYear: dto.publishYear,
|
|
55
|
+
tibetanAuthors: dto.tibetanAuthors
|
|
56
|
+
?.split(',')
|
|
57
|
+
.map((author) => author.trim())
|
|
58
|
+
.filter((author) => author.length > 0),
|
|
59
|
+
isAuthorContested: dto.isAuthorContested || false,
|
|
60
|
+
sourceDescription: dto.sourceDescription,
|
|
61
|
+
publisherStatement: dto.publisherStatement,
|
|
62
|
+
tibetanTranslators: dto.tibetanTranslators,
|
|
63
|
+
license: {
|
|
64
|
+
...dto.license,
|
|
65
|
+
},
|
|
66
|
+
mainTitles: dto.mainTitles,
|
|
67
|
+
longTitles: dto.longTitles,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const ALL_SECTIONS = [...FRONT_MATTER, ...BODY_MATTER, ...BACK_MATTER];
|
|
72
|
+
export type TranslationSection = (typeof ALL_SECTIONS)[number];
|
|
73
|
+
|
|
74
|
+
export type TocEntryDTO = {
|
|
75
|
+
uuid: string;
|
|
76
|
+
content: string;
|
|
77
|
+
label?: string;
|
|
78
|
+
sort: number;
|
|
79
|
+
section: TranslationSection;
|
|
80
|
+
level: number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type TocDTO = TocEntryDTO[];
|
|
84
|
+
|
|
85
|
+
export type TocEntry = {
|
|
86
|
+
uuid: string;
|
|
87
|
+
content: string;
|
|
88
|
+
label?: string;
|
|
89
|
+
sort: number;
|
|
90
|
+
level: number;
|
|
91
|
+
section: TranslationSection;
|
|
92
|
+
children: TocEntry[];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type Toc = {
|
|
96
|
+
frontMatter: TocEntry[];
|
|
97
|
+
body: TocEntry[];
|
|
98
|
+
backMatter: TocEntry[];
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const tocFromDTO = (dto: TocDTO): Toc => {
|
|
102
|
+
// map by front matter, body matter, back matter based on constants above
|
|
103
|
+
const frontMatter: TocEntry[] = [];
|
|
104
|
+
const bodyMatter: TocEntry[] = [];
|
|
105
|
+
const backMatter: TocEntry[] = [];
|
|
106
|
+
|
|
107
|
+
const sectionMap: { [key in TranslationSection]: TocEntry[] } = {
|
|
108
|
+
abbreviations: backMatter,
|
|
109
|
+
acknowledgment: frontMatter,
|
|
110
|
+
appendix: bodyMatter,
|
|
111
|
+
colophon: bodyMatter,
|
|
112
|
+
endnotes: backMatter,
|
|
113
|
+
homage: bodyMatter,
|
|
114
|
+
introduction: frontMatter,
|
|
115
|
+
prelude: bodyMatter,
|
|
116
|
+
prologue: bodyMatter,
|
|
117
|
+
summary: frontMatter,
|
|
118
|
+
translation: bodyMatter,
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
dto.forEach((entry) => {
|
|
122
|
+
const tocEntry: TocEntry = {
|
|
123
|
+
...entry,
|
|
124
|
+
children: [],
|
|
125
|
+
};
|
|
126
|
+
sectionMap[entry.section].push(tocEntry);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// within each section, create a hierarchy based on level from low to high
|
|
130
|
+
const buildHierarchy = (entries: TocEntry[]): TocEntry[] => {
|
|
131
|
+
const root: TocEntry = {
|
|
132
|
+
uuid: 'root',
|
|
133
|
+
content: '',
|
|
134
|
+
sort: 0,
|
|
135
|
+
level: 0,
|
|
136
|
+
section: 'introduction',
|
|
137
|
+
children: [],
|
|
138
|
+
};
|
|
139
|
+
const stack: TocEntry[] = [root];
|
|
140
|
+
|
|
141
|
+
entries.sort((a, b) => a.sort - b.sort);
|
|
142
|
+
|
|
143
|
+
entries.forEach((entry) => {
|
|
144
|
+
while (stack.length > 1 && entry.level <= stack[stack.length - 1].level) {
|
|
145
|
+
stack.pop();
|
|
146
|
+
}
|
|
147
|
+
stack[stack.length - 1].children.push(entry);
|
|
148
|
+
stack.push(entry);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return root.children;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
frontMatter: buildHierarchy(frontMatter),
|
|
156
|
+
body: buildHierarchy(bodyMatter),
|
|
157
|
+
backMatter: buildHierarchy(backMatter),
|
|
158
|
+
};
|
|
159
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './alignment';
|
|
2
|
+
export * from './annotation';
|
|
3
|
+
export * from './bibliography';
|
|
4
|
+
export * from './canon';
|
|
5
|
+
export * from './client';
|
|
6
|
+
export * from './contributor';
|
|
7
|
+
export * from './editor-content';
|
|
8
|
+
export * from './toh';
|
|
9
|
+
export * from './folio';
|
|
10
|
+
export * from './glossary';
|
|
11
|
+
export * from './glossary-page';
|
|
12
|
+
export * from './imprint';
|
|
13
|
+
export * from './language';
|
|
14
|
+
export * from './layout';
|
|
15
|
+
export * from './library';
|
|
16
|
+
export * from './passage';
|
|
17
|
+
export * from './project';
|
|
18
|
+
export * from './semver';
|
|
19
|
+
export * from './title';
|
|
20
|
+
export * from './translation';
|
|
21
|
+
export * from './user';
|
|
22
|
+
export * from './work';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const LANGUAGES = ['bo', 'en', 'Bo-Ltn', 'Sa-Ltn'] as const;
|
|
2
|
+
export type TranslationLanguage = (typeof LANGUAGES)[number];
|
|
3
|
+
export type ExtendedTranslationLanguage =
|
|
4
|
+
| TranslationLanguage
|
|
5
|
+
| 'zh'
|
|
6
|
+
| 'ja'
|
|
7
|
+
| 'Mt-Ltn'
|
|
8
|
+
| 'Pi-Ltn'
|
|
9
|
+
| 'Zh-Ltn';
|
|
10
|
+
|
|
11
|
+
export const DISPLAY_LANGUAGES = [
|
|
12
|
+
'tibetan',
|
|
13
|
+
'english',
|
|
14
|
+
'wylie',
|
|
15
|
+
'sanskrit',
|
|
16
|
+
'chinese',
|
|
17
|
+
'japanese',
|
|
18
|
+
'mongolian',
|
|
19
|
+
'pali',
|
|
20
|
+
'pinyin',
|
|
21
|
+
] as const;
|
|
22
|
+
export type DisplayLanguage = (typeof DISPLAY_LANGUAGES)[number];
|
|
23
|
+
|
|
24
|
+
export const LANGUAGE_MAP: Record<
|
|
25
|
+
ExtendedTranslationLanguage,
|
|
26
|
+
DisplayLanguage
|
|
27
|
+
> = {
|
|
28
|
+
bo: 'tibetan',
|
|
29
|
+
en: 'english',
|
|
30
|
+
'Bo-Ltn': 'tibetan',
|
|
31
|
+
'Sa-Ltn': 'sanskrit',
|
|
32
|
+
zh: 'chinese',
|
|
33
|
+
ja: 'japanese',
|
|
34
|
+
'Mt-Ltn': 'mongolian',
|
|
35
|
+
'Pi-Ltn': 'pali',
|
|
36
|
+
'Zh-Ltn': 'pinyin',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const REVERSE_LANGUAGE_MAP: Record<
|
|
40
|
+
DisplayLanguage,
|
|
41
|
+
ExtendedTranslationLanguage
|
|
42
|
+
> = {
|
|
43
|
+
tibetan: 'bo',
|
|
44
|
+
english: 'en',
|
|
45
|
+
wylie: 'Bo-Ltn',
|
|
46
|
+
sanskrit: 'Sa-Ltn',
|
|
47
|
+
chinese: 'zh',
|
|
48
|
+
japanese: 'ja',
|
|
49
|
+
mongolian: 'Mt-Ltn',
|
|
50
|
+
pinyin: 'Zh-Ltn',
|
|
51
|
+
pali: 'Pi-Ltn',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const displayLanguageForTranslationLanguage = (
|
|
55
|
+
language: ExtendedTranslationLanguage,
|
|
56
|
+
): DisplayLanguage => {
|
|
57
|
+
return LANGUAGE_MAP[language];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const translationLanguageForDisplayLanguage = (
|
|
61
|
+
language: DisplayLanguage,
|
|
62
|
+
): ExtendedTranslationLanguage => {
|
|
63
|
+
return REVERSE_LANGUAGE_MAP[language];
|
|
64
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BodyItemType } from './passage';
|
|
2
|
+
|
|
3
|
+
export type PanelContentType =
|
|
4
|
+
| BodyItemType
|
|
5
|
+
| 'glossary'
|
|
6
|
+
| 'bibliography'
|
|
7
|
+
| 'source';
|
|
8
|
+
|
|
9
|
+
// NOTE: default to 'translation' (or 'compare') for content types not listed here
|
|
10
|
+
export const TAB_FOR_CONTENT_SECTION: Partial<
|
|
11
|
+
Record<PanelContentType, string>
|
|
12
|
+
> = {
|
|
13
|
+
abbreviations: 'abbreviations',
|
|
14
|
+
acknowledgment: 'front',
|
|
15
|
+
bibliography: 'bibliography',
|
|
16
|
+
glossary: 'glossary',
|
|
17
|
+
endnotes: 'endnotes',
|
|
18
|
+
introduction: 'front',
|
|
19
|
+
summary: 'front',
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
// NOTE: default to 'main' for content types not listed here
|
|
23
|
+
export const PANEL_FOR_CONTENT_SECTION: Partial<
|
|
24
|
+
Record<PanelContentType, string>
|
|
25
|
+
> = {
|
|
26
|
+
abbreviations: 'right',
|
|
27
|
+
bibliography: 'right',
|
|
28
|
+
endnotes: 'right',
|
|
29
|
+
glossary: 'right',
|
|
30
|
+
source: 'main',
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
// Support different tabs for some content
|
|
34
|
+
export const VARIANT_TABS_FOR_TAB: Partial<Record<PanelContentType, string[]>> =
|
|
35
|
+
{
|
|
36
|
+
translation: ['compare'],
|
|
37
|
+
} as const;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const LIBRARY_ITEMS = [
|
|
2
|
+
'publications',
|
|
3
|
+
'passages',
|
|
4
|
+
'glossaries',
|
|
5
|
+
'bibliographies',
|
|
6
|
+
'searches',
|
|
7
|
+
] as const;
|
|
8
|
+
|
|
9
|
+
export type LibraryItemType = (typeof LIBRARY_ITEMS)[number];
|
|
10
|
+
|
|
11
|
+
export type UserLibraryItem = {
|
|
12
|
+
uuid: string;
|
|
13
|
+
type: LibraryItemType;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
featured: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type UserPassageWork = {
|
|
19
|
+
uuid: string;
|
|
20
|
+
toh: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type UserPassageItem = {
|
|
24
|
+
uuid: string;
|
|
25
|
+
toh: string;
|
|
26
|
+
label: string;
|
|
27
|
+
content: string;
|
|
28
|
+
work: UserPassageWork;
|
|
29
|
+
};
|