@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,18 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type TableBodyRowAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (
|
|
11
|
+
dto,
|
|
12
|
+
): TableBodyRowAnnotation => {
|
|
13
|
+
return baseAnnotationFromDTO(dto) as TableBodyRowAnnotation;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
17
|
+
return baseAnnotationToDto(annotation);
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type TableAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (dto): TableAnnotation => {
|
|
11
|
+
return baseAnnotationFromDTO(dto) as TableAnnotation;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
15
|
+
return baseAnnotationToDto(annotation);
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type TrailerAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (dto): TrailerAnnotation => {
|
|
11
|
+
return baseAnnotationFromDTO(dto) as TrailerAnnotation;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
15
|
+
return baseAnnotationToDto(annotation);
|
|
16
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import {
|
|
2
|
+
baseAnnotationFromDTO,
|
|
3
|
+
type UnknownAnnotation,
|
|
4
|
+
type Annotation,
|
|
5
|
+
type Annotations,
|
|
6
|
+
type AnnotationTransformer,
|
|
7
|
+
} from './annotation';
|
|
8
|
+
import type {
|
|
9
|
+
AnnotationDTO,
|
|
10
|
+
AnnotationsDTO,
|
|
11
|
+
AnnotationDTOType,
|
|
12
|
+
} from './annotation-type';
|
|
13
|
+
import { ANNOTATIONS_TO_IGNORE } from './annotation-type';
|
|
14
|
+
import { transformer as abbreviation } from './abbreviation';
|
|
15
|
+
import { transformer as audio } from './audio';
|
|
16
|
+
import { transformer as blockquote } from './blockquote';
|
|
17
|
+
import { transformer as code } from './code';
|
|
18
|
+
import { transformer as deprecated } from './deprecated';
|
|
19
|
+
import { transformer as endNoteLink } from './end-note-link';
|
|
20
|
+
import { transformer as glossaryInstance } from './glossary-instance';
|
|
21
|
+
import { transformer as hasAbbreviation } from './has-abbreviation';
|
|
22
|
+
import { transformer as heading } from './heading';
|
|
23
|
+
import { transformer as image } from './image';
|
|
24
|
+
import { transformer as indent } from './indent';
|
|
25
|
+
import { transformer as inlineTitle } from './inline-title';
|
|
26
|
+
import { transformer as internalLink } from './internal-link';
|
|
27
|
+
import { transformer as leadingSpace } from './leading-space';
|
|
28
|
+
import { transformer as line } from './line';
|
|
29
|
+
import { transformer as lineGroup } from './line-group';
|
|
30
|
+
import { transformer as link } from './link';
|
|
31
|
+
import { transformer as list } from './list';
|
|
32
|
+
import { transformer as listItem } from './list-item';
|
|
33
|
+
import { transformer as mantra } from './mantra';
|
|
34
|
+
import { transformer as mention } from './mention';
|
|
35
|
+
import { transformer as paragraph } from './paragraph';
|
|
36
|
+
import { transformer as quote } from './quote';
|
|
37
|
+
import { transformer as quoted } from './quoted';
|
|
38
|
+
import { transformer as reference } from './reference';
|
|
39
|
+
import { transformer as span } from './span';
|
|
40
|
+
import { transformer as trailer } from './trailer';
|
|
41
|
+
import { transformer as table } from './table';
|
|
42
|
+
import { transformer as tableBodyData } from './table-body-data';
|
|
43
|
+
import { transformer as tableBodyHeader } from './table-body-header';
|
|
44
|
+
import { transformer as tableBodyRow } from './table-body-row';
|
|
45
|
+
import { transformer as unknown } from './unknown';
|
|
46
|
+
import { annotationToDtoMap } from './export';
|
|
47
|
+
|
|
48
|
+
const dtoToAnnotationMap: Record<AnnotationDTOType, AnnotationTransformer> = {
|
|
49
|
+
abbreviation,
|
|
50
|
+
audio,
|
|
51
|
+
blockquote,
|
|
52
|
+
code,
|
|
53
|
+
'deprecated-internal-link': deprecated,
|
|
54
|
+
'end-note-link': endNoteLink,
|
|
55
|
+
'glossary-instance': glossaryInstance,
|
|
56
|
+
'has-abbreviation': hasAbbreviation,
|
|
57
|
+
heading,
|
|
58
|
+
image,
|
|
59
|
+
indent,
|
|
60
|
+
'inline-title': inlineTitle,
|
|
61
|
+
'internal-link': internalLink,
|
|
62
|
+
'leading-space': leadingSpace,
|
|
63
|
+
line,
|
|
64
|
+
'line-group': lineGroup,
|
|
65
|
+
link,
|
|
66
|
+
list,
|
|
67
|
+
'list-item': listItem,
|
|
68
|
+
mantra,
|
|
69
|
+
mention,
|
|
70
|
+
paragraph,
|
|
71
|
+
quote,
|
|
72
|
+
quoted,
|
|
73
|
+
reference,
|
|
74
|
+
span,
|
|
75
|
+
table,
|
|
76
|
+
'table-body-data': tableBodyData,
|
|
77
|
+
'table-body-header': tableBodyHeader,
|
|
78
|
+
'table-body-row': tableBodyRow,
|
|
79
|
+
trailer,
|
|
80
|
+
unknown,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const annotationFromDTO = (
|
|
84
|
+
dto: AnnotationDTO,
|
|
85
|
+
passageLength: number,
|
|
86
|
+
): Annotation => {
|
|
87
|
+
const annotation = dtoToAnnotationMap[dto.type]?.(dto);
|
|
88
|
+
if (!annotation) {
|
|
89
|
+
console.warn(`Unknown annotation type: ${dto.type}`);
|
|
90
|
+
console.warn(dto);
|
|
91
|
+
return {
|
|
92
|
+
...baseAnnotationFromDTO(dto),
|
|
93
|
+
type: 'unknown',
|
|
94
|
+
} as UnknownAnnotation;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (
|
|
98
|
+
annotation.start < 0 ||
|
|
99
|
+
annotation.start > passageLength ||
|
|
100
|
+
annotation.end < 0 ||
|
|
101
|
+
annotation.end > passageLength
|
|
102
|
+
) {
|
|
103
|
+
annotation.validated = false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!annotation.validated) {
|
|
107
|
+
console.warn(
|
|
108
|
+
`Invalid annotation range for annotation ${annotation.uuid} (${annotation.start}, ${annotation.end}) in passage of length ${passageLength}`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return annotation;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const annotationsFromDTO = (
|
|
116
|
+
dto?: AnnotationsDTO,
|
|
117
|
+
passageLength?: number,
|
|
118
|
+
): Annotations => {
|
|
119
|
+
const filtered =
|
|
120
|
+
dto?.filter((a) => !ANNOTATIONS_TO_IGNORE.includes(a.type)) || [];
|
|
121
|
+
return filtered.map((a) => annotationFromDTO(a, passageLength || 0));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const annotationToDTO = (
|
|
125
|
+
annotation: Annotation,
|
|
126
|
+
): AnnotationDTO | undefined => {
|
|
127
|
+
const dto = annotationToDtoMap[annotation.type]?.(annotation);
|
|
128
|
+
if (!dto) {
|
|
129
|
+
console.warn(`Unknown annotation type: ${annotation.type}`);
|
|
130
|
+
console.warn(annotation);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
return dto;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const annotationsToDTO = (annotations: Annotations): AnnotationsDTO => {
|
|
137
|
+
return annotations
|
|
138
|
+
.map(annotationToDTO)
|
|
139
|
+
.filter((a): a is AnnotationDTO => a !== undefined);
|
|
140
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type UnknownAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (dto): UnknownAnnotation => {
|
|
11
|
+
return baseAnnotationFromDTO(dto) as UnknownAnnotation;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
15
|
+
return baseAnnotationToDto(annotation);
|
|
16
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export type BibliographyItem = {
|
|
2
|
+
content?: string | null;
|
|
3
|
+
title: string;
|
|
4
|
+
uuid: string;
|
|
5
|
+
year: string;
|
|
6
|
+
publisher: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type Bibliography = BibliographyItem[];
|
|
10
|
+
|
|
11
|
+
export type BibliographyItemDTO = {
|
|
12
|
+
content?: string | null;
|
|
13
|
+
title: string;
|
|
14
|
+
uuid: string;
|
|
15
|
+
year: string;
|
|
16
|
+
publisher: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type BibliographyDTO = BibliographyItemDTO[];
|
|
20
|
+
|
|
21
|
+
export const bibliographyItemFromDTO = (
|
|
22
|
+
dto: BibliographyItemDTO,
|
|
23
|
+
): BibliographyItem => {
|
|
24
|
+
return {
|
|
25
|
+
content: dto.content,
|
|
26
|
+
title: dto.title,
|
|
27
|
+
uuid: dto.uuid,
|
|
28
|
+
year: dto.year,
|
|
29
|
+
publisher: dto.publisher,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type BibliographyEntryItemDTO = {
|
|
34
|
+
uuid: string;
|
|
35
|
+
bibl_html: string;
|
|
36
|
+
work_uuid?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type BibliographyEntryItem = {
|
|
40
|
+
uuid: string;
|
|
41
|
+
html: string;
|
|
42
|
+
workUuid?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type BlibliographyEntryDTO = {
|
|
46
|
+
heading?: string;
|
|
47
|
+
entries: BibliographyEntryItemDTO[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type BibliographyEntry = {
|
|
51
|
+
heading?: string;
|
|
52
|
+
entries: BibliographyEntryItem[];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type BibliographyEntriesDTO = BlibliographyEntryDTO[];
|
|
56
|
+
|
|
57
|
+
export type BibliographyEntries = BibliographyEntry[];
|
|
58
|
+
|
|
59
|
+
export const bibliographyEntryItemFromDTO = (
|
|
60
|
+
dto: BibliographyEntryItemDTO,
|
|
61
|
+
): BibliographyEntryItem => {
|
|
62
|
+
return {
|
|
63
|
+
uuid: dto.uuid,
|
|
64
|
+
html: dto.bibl_html,
|
|
65
|
+
workUuid: dto.work_uuid,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const bibliographyEntryFromDTO = (
|
|
70
|
+
dto: BlibliographyEntryDTO,
|
|
71
|
+
): BibliographyEntry => {
|
|
72
|
+
return {
|
|
73
|
+
heading: dto.heading,
|
|
74
|
+
entries: dto.entries?.map(bibliographyEntryItemFromDTO) || [],
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const bibliographyEntriesFromDTO = (
|
|
79
|
+
dtos: BibliographyEntriesDTO,
|
|
80
|
+
): BibliographyEntries => {
|
|
81
|
+
return dtos?.map(bibliographyEntryFromDTO) || [];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const bibliographyFromDTO = (dto?: BibliographyDTO): Bibliography => {
|
|
85
|
+
return dto?.map(bibliographyItemFromDTO) || [];
|
|
86
|
+
};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { TohokuCatalogEntry } from './toh';
|
|
2
|
+
import { ExtendedTranslationLanguage } from './language';
|
|
3
|
+
|
|
4
|
+
export type CanonNodeType =
|
|
5
|
+
| 'root'
|
|
6
|
+
| 'canonicalSection'
|
|
7
|
+
| 'nonCanonicalSection'
|
|
8
|
+
| 'textGrouping';
|
|
9
|
+
|
|
10
|
+
export type CanonDTO = {
|
|
11
|
+
uuid: string;
|
|
12
|
+
created_at: string;
|
|
13
|
+
label: string;
|
|
14
|
+
parent_uuid?: string;
|
|
15
|
+
xmlId: string;
|
|
16
|
+
parent_xmlId?: string;
|
|
17
|
+
sort: number;
|
|
18
|
+
description: string;
|
|
19
|
+
type: CanonNodeType;
|
|
20
|
+
public_description?: string;
|
|
21
|
+
article_uuid?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type CanonHead = {
|
|
25
|
+
children: CanonNode[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type CanonNode = {
|
|
29
|
+
uuid: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
xmlId?: string;
|
|
32
|
+
parentXmlId?: string;
|
|
33
|
+
parentUuid?: string;
|
|
34
|
+
sort: number;
|
|
35
|
+
description?: string;
|
|
36
|
+
type: CanonNodeType;
|
|
37
|
+
publicDescription?: string;
|
|
38
|
+
articleUuid?: string;
|
|
39
|
+
children?: CanonNode[];
|
|
40
|
+
createdAt?: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type CanonArticleDTO = {
|
|
44
|
+
uuid: string;
|
|
45
|
+
title: string;
|
|
46
|
+
body: string;
|
|
47
|
+
image?: string;
|
|
48
|
+
caption?: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type CanonArticle = CanonArticleDTO;
|
|
52
|
+
|
|
53
|
+
export type CanonArticleTitleDTO = {
|
|
54
|
+
title: string;
|
|
55
|
+
language: ExtendedTranslationLanguage;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type CanonArticleTitle = CanonArticleTitleDTO;
|
|
59
|
+
|
|
60
|
+
export type CanonDetailDTO = {
|
|
61
|
+
uuid: string;
|
|
62
|
+
label: string;
|
|
63
|
+
description: string;
|
|
64
|
+
type: CanonNodeType;
|
|
65
|
+
article?: CanonArticleDTO;
|
|
66
|
+
titles: CanonArticleTitleDTO[];
|
|
67
|
+
};
|
|
68
|
+
export type CanonDetail = CanonDetailDTO & {
|
|
69
|
+
article?: CanonArticle;
|
|
70
|
+
titles: CanonArticleTitle[];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type CanonWorkStatus = 'published' | 'in-progress' | 'not-started';
|
|
74
|
+
|
|
75
|
+
export type CanonWorkDTO = {
|
|
76
|
+
uuid: string;
|
|
77
|
+
toh: TohokuCatalogEntry;
|
|
78
|
+
title: string;
|
|
79
|
+
published: boolean;
|
|
80
|
+
status: CanonWorkStatus;
|
|
81
|
+
pages: number;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type CanonWork = CanonWorkDTO;
|
|
85
|
+
|
|
86
|
+
export type CanonWorksDTO = {
|
|
87
|
+
works: CanonWorkDTO[];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const canonNodeFromDTO = (dto: CanonDTO): CanonNode => {
|
|
91
|
+
return {
|
|
92
|
+
uuid: dto.uuid,
|
|
93
|
+
label: dto.label,
|
|
94
|
+
xmlId: dto.xmlId,
|
|
95
|
+
parentXmlId: dto.parent_xmlId,
|
|
96
|
+
parentUuid: dto.parent_uuid,
|
|
97
|
+
sort: dto.sort,
|
|
98
|
+
description: dto.description,
|
|
99
|
+
type: dto.type,
|
|
100
|
+
publicDescription: dto.public_description,
|
|
101
|
+
articleUuid: dto.article_uuid,
|
|
102
|
+
createdAt: dto.created_at,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const canonTreeFromDTOs = (dtos: CanonDTO[]): CanonHead => {
|
|
107
|
+
const nodes: Record<string, CanonNode> = {};
|
|
108
|
+
dtos.forEach((dto) => {
|
|
109
|
+
nodes[dto.uuid] = canonNodeFromDTO(dto);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const tree: CanonNode[] = [];
|
|
113
|
+
|
|
114
|
+
Object.values(nodes).forEach((node) => {
|
|
115
|
+
if (node.parentUuid) {
|
|
116
|
+
const parent = nodes[node.parentUuid];
|
|
117
|
+
if (parent) {
|
|
118
|
+
parent.children = parent.children || [];
|
|
119
|
+
parent.children.push(node);
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
tree.push(node);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Sort children by their sort order
|
|
127
|
+
const sortChildren = (children: CanonNode[]) => {
|
|
128
|
+
children.sort((a, b) => a.sort - b.sort);
|
|
129
|
+
children.forEach((child) => {
|
|
130
|
+
if (child.children) {
|
|
131
|
+
sortChildren(child.children);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
sortChildren(tree);
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
children: tree,
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const canonDetailFromDTO = (dto: CanonDetailDTO): CanonDetail => {
|
|
143
|
+
return dto as CanonDetail;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const caononWorksFromDTO = (dto: CanonWorksDTO): CanonWork[] => {
|
|
147
|
+
return dto.works as CanonWork[];
|
|
148
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type ContributorRole =
|
|
2
|
+
| 'englishAdvisor'
|
|
3
|
+
| 'englishAssociateEditor'
|
|
4
|
+
| 'englishCopyEditor'
|
|
5
|
+
| 'englishDharmaMaster'
|
|
6
|
+
| 'englishFinalReviewer'
|
|
7
|
+
| 'englishMarkup'
|
|
8
|
+
| 'englishProjectEditor'
|
|
9
|
+
| 'englishProjectManager'
|
|
10
|
+
| 'englishProofReader'
|
|
11
|
+
| 'englishReviser'
|
|
12
|
+
| 'englishTranslator'
|
|
13
|
+
| 'englishTranslationSponsor'
|
|
14
|
+
| 'englishTranslationTeam'
|
|
15
|
+
| 'tibetanTranslator';
|
|
16
|
+
|
|
17
|
+
export type Contributor = {
|
|
18
|
+
name: string;
|
|
19
|
+
role: ContributorRole;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ProjectContributor = Contributor & {
|
|
23
|
+
uuid: string;
|
|
24
|
+
contributorUuid: string;
|
|
25
|
+
startDate?: Date;
|
|
26
|
+
endDate?: Date;
|
|
27
|
+
projectUuid: string;
|
|
28
|
+
stageUuid?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type Contributors = Contributor[];
|
|
32
|
+
export type ProjectContributors = ProjectContributor[];
|
|
33
|
+
|
|
34
|
+
export type ContributorDTO = {
|
|
35
|
+
name: string;
|
|
36
|
+
role: ContributorRole;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type ContributorsDTO = ContributorDTO[];
|
|
40
|
+
|
|
41
|
+
export type ProjectContributorDTO = {
|
|
42
|
+
uuid: string;
|
|
43
|
+
projectUuid: string;
|
|
44
|
+
stageUuid?: string;
|
|
45
|
+
contributorUuid: string;
|
|
46
|
+
name: string;
|
|
47
|
+
role: ContributorRole;
|
|
48
|
+
startDate: string;
|
|
49
|
+
endDate: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type ProjectContributorsDTO = ProjectContributorDTO[];
|
|
53
|
+
|
|
54
|
+
export const contributorFromDTO = (dto: ContributorDTO): Contributor => {
|
|
55
|
+
return {
|
|
56
|
+
name: dto.name,
|
|
57
|
+
role: dto.role,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const contributorsFromDTO = (dto?: ContributorsDTO): Contributors => {
|
|
62
|
+
return dto?.map(contributorFromDTO) || [];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const projectContributorFromDTO = (
|
|
66
|
+
dto: ProjectContributorDTO,
|
|
67
|
+
): ProjectContributor => {
|
|
68
|
+
return {
|
|
69
|
+
uuid: dto.uuid,
|
|
70
|
+
name: dto.name,
|
|
71
|
+
contributorUuid: dto.contributorUuid,
|
|
72
|
+
role: dto.role,
|
|
73
|
+
startDate: new Date(dto.startDate),
|
|
74
|
+
endDate: new Date(dto.endDate),
|
|
75
|
+
projectUuid: dto.projectUuid,
|
|
76
|
+
stageUuid: dto.stageUuid,
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const projectContributorsFromDTO = (
|
|
81
|
+
dto?: ProjectContributorsDTO,
|
|
82
|
+
): ProjectContributors => {
|
|
83
|
+
return dto?.map(projectContributorFromDTO) || [];
|
|
84
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TipTap editor content item with 84000-specific attributes.
|
|
5
|
+
* Used for passage blocks in the translation editor and reader.
|
|
6
|
+
*/
|
|
7
|
+
export type TranslationEditorContentItem = JSONContent & {
|
|
8
|
+
attrs?: {
|
|
9
|
+
uuid?: string | null;
|
|
10
|
+
class?: string | null;
|
|
11
|
+
type?: string | null;
|
|
12
|
+
sort?: number | null;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* TipTap editor content - either a single item or array of items.
|
|
18
|
+
*/
|
|
19
|
+
export type TranslationEditorContent =
|
|
20
|
+
| TranslationEditorContentItem[]
|
|
21
|
+
| TranslationEditorContentItem;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const FOLIO_SIDES = ['a', 'b'] as const;
|
|
2
|
+
export type FolioSide = (typeof FOLIO_SIDES)[number];
|
|
3
|
+
|
|
4
|
+
export type FolioDTO = {
|
|
5
|
+
folio_uuid: string;
|
|
6
|
+
content: string;
|
|
7
|
+
volume_number: number;
|
|
8
|
+
folio_number: number;
|
|
9
|
+
side: FolioSide;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type Folio = {
|
|
13
|
+
uuid: string;
|
|
14
|
+
content: string;
|
|
15
|
+
volume: number;
|
|
16
|
+
folio: number;
|
|
17
|
+
side: FolioSide;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const folioFromDTO = (dto: FolioDTO): Folio => {
|
|
21
|
+
return {
|
|
22
|
+
uuid: dto.folio_uuid,
|
|
23
|
+
content: dto.content,
|
|
24
|
+
volume: dto.volume_number,
|
|
25
|
+
folio: dto.folio_number,
|
|
26
|
+
side: dto.side,
|
|
27
|
+
};
|
|
28
|
+
};
|