@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,219 @@
|
|
|
1
|
+
import { TohokuCatalogEntry } from '../toh';
|
|
2
|
+
|
|
3
|
+
export type AnnotationDTOType =
|
|
4
|
+
| 'abbreviation'
|
|
5
|
+
| 'audio'
|
|
6
|
+
| 'blockquote'
|
|
7
|
+
| 'code'
|
|
8
|
+
| 'deprecated-internal-link'
|
|
9
|
+
| 'end-note-link'
|
|
10
|
+
| 'glossary-instance'
|
|
11
|
+
| 'has-abbreviation'
|
|
12
|
+
| 'heading'
|
|
13
|
+
| 'image'
|
|
14
|
+
| 'indent'
|
|
15
|
+
| 'inline-title'
|
|
16
|
+
| 'internal-link'
|
|
17
|
+
| 'leading-space'
|
|
18
|
+
| 'line'
|
|
19
|
+
| 'line-group'
|
|
20
|
+
| 'link'
|
|
21
|
+
| 'list'
|
|
22
|
+
| 'list-item'
|
|
23
|
+
| 'mantra'
|
|
24
|
+
| 'mention'
|
|
25
|
+
| 'paragraph'
|
|
26
|
+
| 'quote'
|
|
27
|
+
| 'quoted'
|
|
28
|
+
| 'reference'
|
|
29
|
+
| 'span'
|
|
30
|
+
| 'table'
|
|
31
|
+
| 'table-body-data'
|
|
32
|
+
| 'table-body-header'
|
|
33
|
+
| 'table-body-row'
|
|
34
|
+
| 'trailer'
|
|
35
|
+
| 'unknown';
|
|
36
|
+
|
|
37
|
+
export type AnnotationType =
|
|
38
|
+
| 'abbreviation'
|
|
39
|
+
| 'audio'
|
|
40
|
+
| 'blockquote'
|
|
41
|
+
| 'code'
|
|
42
|
+
| 'deprecated'
|
|
43
|
+
| 'endNoteLink'
|
|
44
|
+
| 'glossaryInstance'
|
|
45
|
+
| 'hasAbbreviation'
|
|
46
|
+
| 'heading'
|
|
47
|
+
| 'image'
|
|
48
|
+
| 'indent'
|
|
49
|
+
| 'inlineTitle'
|
|
50
|
+
| 'internalLink'
|
|
51
|
+
| 'leadingSpace'
|
|
52
|
+
| 'line'
|
|
53
|
+
| 'lineGroup'
|
|
54
|
+
| 'link'
|
|
55
|
+
| 'list'
|
|
56
|
+
| 'listItem'
|
|
57
|
+
| 'mantra'
|
|
58
|
+
| 'mention'
|
|
59
|
+
| 'paragraph'
|
|
60
|
+
| 'quote'
|
|
61
|
+
| 'quoted'
|
|
62
|
+
| 'reference'
|
|
63
|
+
| 'span'
|
|
64
|
+
| 'table'
|
|
65
|
+
| 'tableBodyData'
|
|
66
|
+
| 'tableBodyHeader'
|
|
67
|
+
| 'tableBodyRow'
|
|
68
|
+
| 'trailer'
|
|
69
|
+
| 'unknown';
|
|
70
|
+
|
|
71
|
+
export const ANNOTATION_TYPE_DTO_TO_TYPE: Record<
|
|
72
|
+
AnnotationDTOType,
|
|
73
|
+
AnnotationType
|
|
74
|
+
> = {
|
|
75
|
+
abbreviation: 'abbreviation',
|
|
76
|
+
audio: 'audio',
|
|
77
|
+
blockquote: 'blockquote',
|
|
78
|
+
code: 'code',
|
|
79
|
+
'deprecated-internal-link': 'deprecated',
|
|
80
|
+
'end-note-link': 'endNoteLink',
|
|
81
|
+
'glossary-instance': 'glossaryInstance',
|
|
82
|
+
'has-abbreviation': 'hasAbbreviation',
|
|
83
|
+
heading: 'heading',
|
|
84
|
+
image: 'image',
|
|
85
|
+
indent: 'indent',
|
|
86
|
+
'inline-title': 'inlineTitle',
|
|
87
|
+
'internal-link': 'internalLink',
|
|
88
|
+
'leading-space': 'leadingSpace',
|
|
89
|
+
line: 'line',
|
|
90
|
+
'line-group': 'lineGroup',
|
|
91
|
+
link: 'link',
|
|
92
|
+
list: 'list',
|
|
93
|
+
'list-item': 'listItem',
|
|
94
|
+
mantra: 'mantra',
|
|
95
|
+
mention: 'mention',
|
|
96
|
+
paragraph: 'paragraph',
|
|
97
|
+
quote: 'quote',
|
|
98
|
+
quoted: 'quoted',
|
|
99
|
+
reference: 'reference',
|
|
100
|
+
span: 'span',
|
|
101
|
+
table: 'table',
|
|
102
|
+
'table-body-data': 'tableBodyData',
|
|
103
|
+
'table-body-header': 'tableBodyHeader',
|
|
104
|
+
'table-body-row': 'tableBodyRow',
|
|
105
|
+
trailer: 'trailer',
|
|
106
|
+
unknown: 'unknown',
|
|
107
|
+
} as const;
|
|
108
|
+
|
|
109
|
+
export const annotationTypeFromDTO = (
|
|
110
|
+
type: AnnotationDTOType,
|
|
111
|
+
): AnnotationType => {
|
|
112
|
+
return ANNOTATION_TYPE_DTO_TO_TYPE[type] || 'unknown';
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const ANNOTATION_TYPE_TO_DTO: Record<AnnotationType, AnnotationDTOType> =
|
|
116
|
+
{
|
|
117
|
+
abbreviation: 'abbreviation',
|
|
118
|
+
audio: 'audio',
|
|
119
|
+
blockquote: 'blockquote',
|
|
120
|
+
code: 'code',
|
|
121
|
+
deprecated: 'deprecated-internal-link',
|
|
122
|
+
endNoteLink: 'end-note-link',
|
|
123
|
+
glossaryInstance: 'glossary-instance',
|
|
124
|
+
hasAbbreviation: 'has-abbreviation',
|
|
125
|
+
heading: 'heading',
|
|
126
|
+
image: 'image',
|
|
127
|
+
indent: 'indent',
|
|
128
|
+
inlineTitle: 'inline-title',
|
|
129
|
+
internalLink: 'internal-link',
|
|
130
|
+
leadingSpace: 'leading-space',
|
|
131
|
+
line: 'line',
|
|
132
|
+
lineGroup: 'line-group',
|
|
133
|
+
link: 'link',
|
|
134
|
+
list: 'list',
|
|
135
|
+
listItem: 'list-item',
|
|
136
|
+
mantra: 'mantra',
|
|
137
|
+
mention: 'mention',
|
|
138
|
+
paragraph: 'paragraph',
|
|
139
|
+
quote: 'quote',
|
|
140
|
+
quoted: 'quoted',
|
|
141
|
+
reference: 'reference',
|
|
142
|
+
span: 'span',
|
|
143
|
+
table: 'table',
|
|
144
|
+
tableBodyData: 'table-body-data',
|
|
145
|
+
tableBodyHeader: 'table-body-header',
|
|
146
|
+
tableBodyRow: 'table-body-row',
|
|
147
|
+
trailer: 'trailer',
|
|
148
|
+
unknown: 'unknown',
|
|
149
|
+
} as const;
|
|
150
|
+
|
|
151
|
+
export type AnnotationDTOContentKey =
|
|
152
|
+
| 'authority'
|
|
153
|
+
| 'endnote_xmlId'
|
|
154
|
+
| 'glossary_xmlId'
|
|
155
|
+
| 'heading-level'
|
|
156
|
+
| 'heading-type'
|
|
157
|
+
| 'href'
|
|
158
|
+
| 'label'
|
|
159
|
+
| 'lang'
|
|
160
|
+
| 'link-text'
|
|
161
|
+
| 'link-text-lookup'
|
|
162
|
+
| 'link-type'
|
|
163
|
+
| 'list-item-style'
|
|
164
|
+
| 'list-spacing'
|
|
165
|
+
| 'media-type'
|
|
166
|
+
| 'nesting'
|
|
167
|
+
| 'paragraph'
|
|
168
|
+
| 'quote_xmlId'
|
|
169
|
+
| 'src'
|
|
170
|
+
| 'text-style'
|
|
171
|
+
| 'text'
|
|
172
|
+
| 'type'
|
|
173
|
+
| 'title'
|
|
174
|
+
| 'uuid'
|
|
175
|
+
| 'same_work'
|
|
176
|
+
| 'subtype'
|
|
177
|
+
| 'toh';
|
|
178
|
+
|
|
179
|
+
export type AnnotationDTOContent = Partial<
|
|
180
|
+
Record<AnnotationDTOContentKey, unknown>
|
|
181
|
+
>;
|
|
182
|
+
|
|
183
|
+
export type AnnotationDTO = {
|
|
184
|
+
content: AnnotationDTOContent[];
|
|
185
|
+
end: number;
|
|
186
|
+
start: number;
|
|
187
|
+
type: AnnotationDTOType;
|
|
188
|
+
uuid: string;
|
|
189
|
+
passage_uuid?: string;
|
|
190
|
+
passageUuid?: string;
|
|
191
|
+
toh?: TohokuCatalogEntry;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export type AnnotationsDTO = AnnotationDTO[];
|
|
195
|
+
|
|
196
|
+
export const annotationTypeToDTO = (
|
|
197
|
+
type: AnnotationType,
|
|
198
|
+
): AnnotationDTOType => {
|
|
199
|
+
return ANNOTATION_TYPE_TO_DTO[type] || 'unknown';
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const ANNOTATIONS_TO_IGNORE: AnnotationDTOType[] = [
|
|
203
|
+
'deprecated-internal-link',
|
|
204
|
+
'quoted',
|
|
205
|
+
'reference',
|
|
206
|
+
'unknown',
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
export type AnnotationsToIgnore = (typeof ANNOTATIONS_TO_IGNORE)[number];
|
|
210
|
+
|
|
211
|
+
export type AnnotationBase = {
|
|
212
|
+
end: number;
|
|
213
|
+
start: number;
|
|
214
|
+
type: AnnotationType;
|
|
215
|
+
uuid: string;
|
|
216
|
+
passageUuid: string;
|
|
217
|
+
validated?: boolean;
|
|
218
|
+
toh?: TohokuCatalogEntry;
|
|
219
|
+
};
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { ExtendedTranslationLanguage } from '../language';
|
|
2
|
+
import {
|
|
3
|
+
AnnotationBase,
|
|
4
|
+
AnnotationDTO,
|
|
5
|
+
annotationTypeFromDTO,
|
|
6
|
+
annotationTypeToDTO,
|
|
7
|
+
} from './annotation-type';
|
|
8
|
+
|
|
9
|
+
export type AbbreviationAnnotation = AnnotationBase & {
|
|
10
|
+
type: 'abbreviation';
|
|
11
|
+
abbreviation: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type AudioAnnotation = AnnotationBase & {
|
|
15
|
+
type: 'audio';
|
|
16
|
+
src: string;
|
|
17
|
+
mediaType: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type BlockquoteAnnotation = AnnotationBase & {
|
|
21
|
+
type: 'blockquote';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type CodeAnnotation = AnnotationBase & {
|
|
25
|
+
type: 'code';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type DeprecatedAnnotation = AnnotationBase & {
|
|
29
|
+
type: 'deprecated';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type EndNoteLinkAnnotation = AnnotationBase & {
|
|
33
|
+
type: 'endNoteLink';
|
|
34
|
+
endNote: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type GlossaryInstanceAnnotation = AnnotationBase & {
|
|
39
|
+
type: 'glossaryInstance';
|
|
40
|
+
glossary: string;
|
|
41
|
+
authority: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type HasAbbreviationAnnotation = AnnotationBase & {
|
|
45
|
+
type: 'hasAbbreviation';
|
|
46
|
+
abbreviation: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type HeadingClass =
|
|
50
|
+
| 'section-label'
|
|
51
|
+
| 'section-title'
|
|
52
|
+
| 'supplementary'
|
|
53
|
+
| 'table-label';
|
|
54
|
+
|
|
55
|
+
export type HeadingAnnotation = AnnotationBase & {
|
|
56
|
+
type: 'heading';
|
|
57
|
+
level: number;
|
|
58
|
+
class?: HeadingClass;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type ImageAnnotation = AnnotationBase & {
|
|
62
|
+
type: 'image';
|
|
63
|
+
src: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type IndentAnnotation = AnnotationBase & {
|
|
67
|
+
type: 'indent';
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type InlineTitleAnnotation = AnnotationBase & {
|
|
71
|
+
type: 'inlineTitle';
|
|
72
|
+
lang: ExtendedTranslationLanguage;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type InternalLinkAnnotation = AnnotationBase & {
|
|
76
|
+
type: 'internalLink';
|
|
77
|
+
linkType: string;
|
|
78
|
+
href?: string;
|
|
79
|
+
label?: string;
|
|
80
|
+
entity?: string;
|
|
81
|
+
isPending?: boolean;
|
|
82
|
+
isSameWork?: boolean;
|
|
83
|
+
subtype?: string;
|
|
84
|
+
linkToh?: string;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type LeadingSpaceAnnotation = AnnotationBase & {
|
|
88
|
+
type: 'leadingSpace';
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type LineGroupAnnotation = AnnotationBase & {
|
|
92
|
+
type: 'lineGroup';
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type LineAnnotation = AnnotationBase & {
|
|
96
|
+
type: 'line';
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type LinkAnnotation = AnnotationBase & {
|
|
100
|
+
type: 'link';
|
|
101
|
+
href: string;
|
|
102
|
+
text: string;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type ListItemAnnotation = AnnotationBase & {
|
|
106
|
+
type: 'listItem';
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type ListAnnotation = AnnotationBase & {
|
|
110
|
+
type: 'list';
|
|
111
|
+
spacing?: string;
|
|
112
|
+
nesting?: number;
|
|
113
|
+
itemStyle?: string;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type MantraAnnotation = AnnotationBase & {
|
|
117
|
+
type: 'mantra';
|
|
118
|
+
lang: ExtendedTranslationLanguage;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export type MentionAnnotation = AnnotationBase & {
|
|
122
|
+
type: 'mention';
|
|
123
|
+
entity: string;
|
|
124
|
+
linkType: string;
|
|
125
|
+
text?: string;
|
|
126
|
+
displayText?: string;
|
|
127
|
+
isSameWork?: boolean;
|
|
128
|
+
subtype?: string;
|
|
129
|
+
linkToh?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type ParagraphAnnotation = AnnotationBase & {
|
|
133
|
+
type: 'paragraph';
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export type QuoteAnnotation = AnnotationBase & {
|
|
137
|
+
type: 'quote';
|
|
138
|
+
quote?: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type QuotedAnnotation = AnnotationBase & {
|
|
142
|
+
type: 'quoted';
|
|
143
|
+
quote?: string;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type ReferenceAnnotation = AnnotationBase & {
|
|
147
|
+
type: 'reference';
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type SpanAnnotation = AnnotationBase & {
|
|
151
|
+
type: 'span';
|
|
152
|
+
textStyle?: string;
|
|
153
|
+
lang?: ExtendedTranslationLanguage;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export type TableAnnotation = AnnotationBase & {
|
|
157
|
+
type: 'table';
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export type TableBodyDataAnnotation = AnnotationBase & {
|
|
161
|
+
type: 'tableBodyData';
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export type TableBodyHeaderAnnotation = AnnotationBase & {
|
|
165
|
+
type: 'tableBodyHeader';
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export type TableBodyRowAnnotation = AnnotationBase & {
|
|
169
|
+
type: 'tableBodyRow';
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type TrailerAnnotation = AnnotationBase & {
|
|
173
|
+
type: 'trailer';
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export type UnknownAnnotation = AnnotationBase & {
|
|
177
|
+
type: 'unknown';
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type Annotation =
|
|
181
|
+
| AbbreviationAnnotation
|
|
182
|
+
| AudioAnnotation
|
|
183
|
+
| BlockquoteAnnotation
|
|
184
|
+
| CodeAnnotation
|
|
185
|
+
| DeprecatedAnnotation
|
|
186
|
+
| EndNoteLinkAnnotation
|
|
187
|
+
| GlossaryInstanceAnnotation
|
|
188
|
+
| HasAbbreviationAnnotation
|
|
189
|
+
| HeadingAnnotation
|
|
190
|
+
| ImageAnnotation
|
|
191
|
+
| IndentAnnotation
|
|
192
|
+
| InlineTitleAnnotation
|
|
193
|
+
| InternalLinkAnnotation
|
|
194
|
+
| LeadingSpaceAnnotation
|
|
195
|
+
| LineAnnotation
|
|
196
|
+
| LineGroupAnnotation
|
|
197
|
+
| LinkAnnotation
|
|
198
|
+
| ListAnnotation
|
|
199
|
+
| ListItemAnnotation
|
|
200
|
+
| MantraAnnotation
|
|
201
|
+
| MentionAnnotation
|
|
202
|
+
| ParagraphAnnotation
|
|
203
|
+
| QuoteAnnotation
|
|
204
|
+
| QuotedAnnotation
|
|
205
|
+
| ReferenceAnnotation
|
|
206
|
+
| SpanAnnotation
|
|
207
|
+
| TableAnnotation
|
|
208
|
+
| TableBodyDataAnnotation
|
|
209
|
+
| TableBodyHeaderAnnotation
|
|
210
|
+
| TableBodyRowAnnotation
|
|
211
|
+
| TrailerAnnotation
|
|
212
|
+
| UnknownAnnotation;
|
|
213
|
+
|
|
214
|
+
export type Annotations = Annotation[];
|
|
215
|
+
|
|
216
|
+
export type AnnotationTransformer = (dto: AnnotationDTO) => Annotation;
|
|
217
|
+
|
|
218
|
+
export const baseAnnotationFromDTO = (dto: AnnotationDTO): AnnotationBase => {
|
|
219
|
+
const passageUuid = dto.passage_uuid || dto.passageUuid || '';
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
uuid: dto.uuid,
|
|
223
|
+
start: dto.start,
|
|
224
|
+
end: dto.end,
|
|
225
|
+
type: annotationTypeFromDTO(dto.type),
|
|
226
|
+
toh: dto.toh,
|
|
227
|
+
passageUuid,
|
|
228
|
+
validated: true,
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export type AnnotationExporter = (annotation: Annotation) => AnnotationDTO;
|
|
233
|
+
|
|
234
|
+
export const baseAnnotationToDto = (
|
|
235
|
+
annotation: AnnotationBase,
|
|
236
|
+
): AnnotationDTO => ({
|
|
237
|
+
end: annotation.end,
|
|
238
|
+
start: annotation.start,
|
|
239
|
+
type: annotationTypeToDTO(annotation.type),
|
|
240
|
+
uuid: annotation.uuid,
|
|
241
|
+
passage_uuid: annotation.passageUuid,
|
|
242
|
+
toh: annotation.toh,
|
|
243
|
+
content: [],
|
|
244
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AnnotationExporter,
|
|
3
|
+
type AnnotationTransformer,
|
|
4
|
+
type AudioAnnotation,
|
|
5
|
+
baseAnnotationFromDTO,
|
|
6
|
+
baseAnnotationToDto,
|
|
7
|
+
} from './annotation';
|
|
8
|
+
import { AnnotationDTO, AnnotationDTOContent } from './annotation-type';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (dto): AudioAnnotation => {
|
|
11
|
+
const baseAnnotation = baseAnnotationFromDTO(dto);
|
|
12
|
+
const audio = baseAnnotation as AudioAnnotation;
|
|
13
|
+
dto.content.forEach((content) => {
|
|
14
|
+
if (content.src) {
|
|
15
|
+
audio.src = content.src as string;
|
|
16
|
+
}
|
|
17
|
+
if (content['media-type']) {
|
|
18
|
+
audio.mediaType = content['media-type'] as string;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return audio;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
26
|
+
const { src, mediaType } = annotation as AudioAnnotation;
|
|
27
|
+
const dto = baseAnnotationToDto(annotation);
|
|
28
|
+
dto.content.push({
|
|
29
|
+
src,
|
|
30
|
+
'media-type': mediaType,
|
|
31
|
+
} as AnnotationDTOContent);
|
|
32
|
+
return dto;
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type BlockquoteAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (
|
|
11
|
+
dto,
|
|
12
|
+
): BlockquoteAnnotation => {
|
|
13
|
+
return baseAnnotationFromDTO(dto) as BlockquoteAnnotation;
|
|
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 CodeAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (dto): CodeAnnotation => {
|
|
11
|
+
return baseAnnotationFromDTO(dto) as CodeAnnotation;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
15
|
+
return baseAnnotationToDto(annotation);
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type DeprecatedAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (
|
|
11
|
+
dto,
|
|
12
|
+
): DeprecatedAnnotation => {
|
|
13
|
+
return baseAnnotationFromDTO(dto) as DeprecatedAnnotation;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
17
|
+
return baseAnnotationToDto(annotation);
|
|
18
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type EndNoteLinkAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (
|
|
11
|
+
dto,
|
|
12
|
+
): EndNoteLinkAnnotation => {
|
|
13
|
+
const baseAnnotation = baseAnnotationFromDTO(dto);
|
|
14
|
+
const endNote = baseAnnotation as EndNoteLinkAnnotation;
|
|
15
|
+
dto.content.forEach((content) => {
|
|
16
|
+
if (content.uuid) {
|
|
17
|
+
endNote.endNote = content.uuid as string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (content.label) {
|
|
21
|
+
endNote.label = content.label as string;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return endNote;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
29
|
+
const { endNote: uuid } = annotation as EndNoteLinkAnnotation;
|
|
30
|
+
const dto = baseAnnotationToDto(annotation);
|
|
31
|
+
dto.content.push({
|
|
32
|
+
uuid,
|
|
33
|
+
});
|
|
34
|
+
return dto;
|
|
35
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AnnotationType } from './annotation-type';
|
|
2
|
+
import { AnnotationExporter } from './annotation';
|
|
3
|
+
import { exporter as abbreviation } from './abbreviation';
|
|
4
|
+
import { exporter as audio } from './audio';
|
|
5
|
+
import { exporter as blockquote } from './blockquote';
|
|
6
|
+
import { exporter as code } from './code';
|
|
7
|
+
import { exporter as deprecated } from './deprecated';
|
|
8
|
+
import { exporter as endNoteLink } from './end-note-link';
|
|
9
|
+
import { exporter as glossaryInstance } from './glossary-instance';
|
|
10
|
+
import { exporter as hasAbbreviation } from './has-abbreviation';
|
|
11
|
+
import { exporter as heading } from './heading';
|
|
12
|
+
import { exporter as image } from './image';
|
|
13
|
+
import { exporter as indent } from './indent';
|
|
14
|
+
import { exporter as inlineTitle } from './inline-title';
|
|
15
|
+
import { exporter as internalLink } from './internal-link';
|
|
16
|
+
import { exporter as leadingSpace } from './leading-space';
|
|
17
|
+
import { exporter as line } from './line';
|
|
18
|
+
import { exporter as lineGroup } from './line-group';
|
|
19
|
+
import { exporter as link } from './link';
|
|
20
|
+
import { exporter as list } from './list';
|
|
21
|
+
import { exporter as listItem } from './list-item';
|
|
22
|
+
import { exporter as mantra } from './mantra';
|
|
23
|
+
import { exporter as mention } from './mention';
|
|
24
|
+
import { exporter as paragraph } from './paragraph';
|
|
25
|
+
import { exporter as quote } from './quote';
|
|
26
|
+
import { exporter as quoted } from './quoted';
|
|
27
|
+
import { exporter as reference } from './reference';
|
|
28
|
+
import { exporter as span } from './span';
|
|
29
|
+
import { exporter as table } from './table';
|
|
30
|
+
import { exporter as tableBodyData } from './table-body-data';
|
|
31
|
+
import { exporter as tableBodyHeader } from './table-body-header';
|
|
32
|
+
import { exporter as tableBodyRow } from './table-body-row';
|
|
33
|
+
import { exporter as trailer } from './trailer';
|
|
34
|
+
import { exporter as unknown } from './unknown';
|
|
35
|
+
|
|
36
|
+
export const annotationToDtoMap: Record<AnnotationType, AnnotationExporter> = {
|
|
37
|
+
abbreviation,
|
|
38
|
+
audio,
|
|
39
|
+
blockquote,
|
|
40
|
+
code,
|
|
41
|
+
deprecated,
|
|
42
|
+
endNoteLink,
|
|
43
|
+
glossaryInstance,
|
|
44
|
+
hasAbbreviation,
|
|
45
|
+
heading,
|
|
46
|
+
image,
|
|
47
|
+
indent,
|
|
48
|
+
inlineTitle,
|
|
49
|
+
internalLink,
|
|
50
|
+
leadingSpace,
|
|
51
|
+
line,
|
|
52
|
+
lineGroup,
|
|
53
|
+
link,
|
|
54
|
+
list,
|
|
55
|
+
listItem,
|
|
56
|
+
mantra,
|
|
57
|
+
mention,
|
|
58
|
+
paragraph,
|
|
59
|
+
quote,
|
|
60
|
+
quoted,
|
|
61
|
+
reference,
|
|
62
|
+
span,
|
|
63
|
+
table,
|
|
64
|
+
tableBodyData,
|
|
65
|
+
tableBodyHeader,
|
|
66
|
+
tableBodyRow,
|
|
67
|
+
trailer,
|
|
68
|
+
unknown,
|
|
69
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AnnotationDTO } from './annotation-type';
|
|
2
|
+
import {
|
|
3
|
+
type AnnotationExporter,
|
|
4
|
+
type AnnotationTransformer,
|
|
5
|
+
type GlossaryInstanceAnnotation,
|
|
6
|
+
baseAnnotationFromDTO,
|
|
7
|
+
baseAnnotationToDto,
|
|
8
|
+
} from './annotation';
|
|
9
|
+
|
|
10
|
+
export const transformer: AnnotationTransformer = (
|
|
11
|
+
dto,
|
|
12
|
+
): GlossaryInstanceAnnotation => {
|
|
13
|
+
const baseAnnotation = baseAnnotationFromDTO(dto);
|
|
14
|
+
const glossaryInstance = baseAnnotation as GlossaryInstanceAnnotation;
|
|
15
|
+
dto.content.forEach((content) => {
|
|
16
|
+
if (content.uuid) {
|
|
17
|
+
glossaryInstance.glossary = content.uuid as string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (content.authority) {
|
|
21
|
+
glossaryInstance.authority = content.authority as string
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return glossaryInstance;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
|
|
28
|
+
const { glossary: uuid } = annotation as GlossaryInstanceAnnotation;
|
|
29
|
+
const dto = baseAnnotationToDto(annotation);
|
|
30
|
+
dto.content.push({
|
|
31
|
+
uuid,
|
|
32
|
+
});
|
|
33
|
+
return dto;
|
|
34
|
+
};
|