@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.
Files changed (91) hide show
  1. package/.babelrc +12 -0
  2. package/.eslintrc.json +18 -0
  3. package/README.md +7 -0
  4. package/jest.config.ts +10 -0
  5. package/package.json +30 -0
  6. package/project.json +21 -0
  7. package/src/index.ts +18 -0
  8. package/src/lib/auth.ts +203 -0
  9. package/src/lib/bibliography.ts +57 -0
  10. package/src/lib/canon.ts +111 -0
  11. package/src/lib/client-browser.ts +12 -0
  12. package/src/lib/client-server.ts +30 -0
  13. package/src/lib/client-ssr.ts +24 -0
  14. package/src/lib/client-token.ts +24 -0
  15. package/src/lib/feedback.ts +71 -0
  16. package/src/lib/folio.ts +43 -0
  17. package/src/lib/glossary.ts +147 -0
  18. package/src/lib/imprint.ts +42 -0
  19. package/src/lib/library.ts +209 -0
  20. package/src/lib/local-storage.ts +33 -0
  21. package/src/lib/lookup-entity.ts +122 -0
  22. package/src/lib/panel-url.ts +43 -0
  23. package/src/lib/passage.ts +122 -0
  24. package/src/lib/projects.ts +107 -0
  25. package/src/lib/proxy.ts +68 -0
  26. package/src/lib/publications.ts +213 -0
  27. package/src/lib/storage.ts +23 -0
  28. package/src/lib/types/alignment.ts +32 -0
  29. package/src/lib/types/annotation/abbreviation.ts +30 -0
  30. package/src/lib/types/annotation/annotation-type.ts +219 -0
  31. package/src/lib/types/annotation/annotation.ts +244 -0
  32. package/src/lib/types/annotation/audio.ts +33 -0
  33. package/src/lib/types/annotation/blockquote.ts +18 -0
  34. package/src/lib/types/annotation/code.ts +16 -0
  35. package/src/lib/types/annotation/deprecated.ts +18 -0
  36. package/src/lib/types/annotation/end-note-link.ts +35 -0
  37. package/src/lib/types/annotation/export.ts +69 -0
  38. package/src/lib/types/annotation/glossary-instance.ts +34 -0
  39. package/src/lib/types/annotation/has-abbreviation.ts +30 -0
  40. package/src/lib/types/annotation/heading.ts +37 -0
  41. package/src/lib/types/annotation/image.ts +29 -0
  42. package/src/lib/types/annotation/indent.ts +16 -0
  43. package/src/lib/types/annotation/index.ts +4 -0
  44. package/src/lib/types/annotation/inline-title.ts +34 -0
  45. package/src/lib/types/annotation/internal-link.ts +86 -0
  46. package/src/lib/types/annotation/leading-space.ts +18 -0
  47. package/src/lib/types/annotation/line-group.ts +18 -0
  48. package/src/lib/types/annotation/line.ts +16 -0
  49. package/src/lib/types/annotation/link.ts +38 -0
  50. package/src/lib/types/annotation/list-item.ts +16 -0
  51. package/src/lib/types/annotation/list.ts +43 -0
  52. package/src/lib/types/annotation/mantra.ts +31 -0
  53. package/src/lib/types/annotation/mention.ts +64 -0
  54. package/src/lib/types/annotation/paragraph.ts +18 -0
  55. package/src/lib/types/annotation/quote.ts +30 -0
  56. package/src/lib/types/annotation/quoted.ts +30 -0
  57. package/src/lib/types/annotation/reference.ts +18 -0
  58. package/src/lib/types/annotation/span.ts +39 -0
  59. package/src/lib/types/annotation/table-body-data.ts +18 -0
  60. package/src/lib/types/annotation/table-body-header.ts +18 -0
  61. package/src/lib/types/annotation/table-body-row.ts +18 -0
  62. package/src/lib/types/annotation/table.ts +16 -0
  63. package/src/lib/types/annotation/trailer.ts +16 -0
  64. package/src/lib/types/annotation/transform.ts +140 -0
  65. package/src/lib/types/annotation/unknown.ts +16 -0
  66. package/src/lib/types/bibliography.ts +86 -0
  67. package/src/lib/types/canon.ts +148 -0
  68. package/src/lib/types/client.ts +3 -0
  69. package/src/lib/types/contributor.ts +84 -0
  70. package/src/lib/types/editor-content.ts +21 -0
  71. package/src/lib/types/folio.ts +28 -0
  72. package/src/lib/types/glossary-page.ts +204 -0
  73. package/src/lib/types/glossary.ts +114 -0
  74. package/src/lib/types/imprint.ts +159 -0
  75. package/src/lib/types/index.ts +22 -0
  76. package/src/lib/types/language.ts +64 -0
  77. package/src/lib/types/layout.ts +37 -0
  78. package/src/lib/types/library.ts +29 -0
  79. package/src/lib/types/passage.ts +220 -0
  80. package/src/lib/types/project.ts +200 -0
  81. package/src/lib/types/semver.ts +1 -0
  82. package/src/lib/types/title.ts +47 -0
  83. package/src/lib/types/toh.ts +1 -0
  84. package/src/lib/types/translation.ts +15 -0
  85. package/src/lib/types/user.ts +15 -0
  86. package/src/lib/types/work.ts +38 -0
  87. package/src/lib/use-bookmark.ts +45 -0
  88. package/src/ssr.ts +5 -0
  89. package/tsconfig.json +20 -0
  90. package/tsconfig.lib.json +26 -0
  91. package/tsconfig.spec.json +22 -0
@@ -0,0 +1,30 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type HasAbbreviationAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): HasAbbreviationAnnotation => {
13
+ const baseAnnotation = baseAnnotationFromDTO(dto);
14
+ const hasAbbreviation = baseAnnotation as HasAbbreviationAnnotation;
15
+ dto.content.forEach((content) => {
16
+ if (content.uuid) {
17
+ hasAbbreviation.abbreviation = content.uuid as string;
18
+ }
19
+ });
20
+ return hasAbbreviation;
21
+ };
22
+
23
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
24
+ const { abbreviation: uuid } = annotation as HasAbbreviationAnnotation;
25
+ const dto = baseAnnotationToDto(annotation);
26
+ dto.content.push({
27
+ uuid,
28
+ });
29
+ return dto;
30
+ };
@@ -0,0 +1,37 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type HeadingAnnotation,
6
+ HeadingClass,
7
+ baseAnnotationFromDTO,
8
+ baseAnnotationToDto,
9
+ } from './annotation';
10
+
11
+ export const transformer: AnnotationTransformer = (dto): HeadingAnnotation => {
12
+ const heading = baseAnnotationFromDTO(dto) as HeadingAnnotation;
13
+ dto.content.forEach((content) => {
14
+ if (content['heading-level']) {
15
+ const headerStr = content['heading-level'] as string;
16
+ const levelStr = headerStr.replace('h', '');
17
+ const level = parseInt(levelStr, 10);
18
+ heading.level = level;
19
+ }
20
+
21
+ if (content['heading-type']) {
22
+ heading.class = content['heading-type'] as HeadingClass;
23
+ }
24
+ });
25
+
26
+ return heading;
27
+ };
28
+
29
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
30
+ const { level, class: headingClass } = annotation as HeadingAnnotation;
31
+ const dto = baseAnnotationToDto(annotation);
32
+ dto.content.push({
33
+ 'heading-level': `h${level}`,
34
+ ...(headingClass ? { 'heading-type': headingClass } : {}),
35
+ });
36
+ return dto;
37
+ };
@@ -0,0 +1,29 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type ImageAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): ImageAnnotation => {
11
+ const baseAnnotation = baseAnnotationFromDTO(dto);
12
+ const image = baseAnnotation as ImageAnnotation;
13
+ dto.content.forEach((content) => {
14
+ if (content.src) {
15
+ image.src = content.src as string;
16
+ }
17
+ });
18
+
19
+ return image;
20
+ };
21
+
22
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
23
+ const { src } = annotation as ImageAnnotation;
24
+ const dto = baseAnnotationToDto(annotation);
25
+ dto.content.push({
26
+ src,
27
+ });
28
+ return dto;
29
+ };
@@ -0,0 +1,16 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type IndentAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): IndentAnnotation => {
11
+ return baseAnnotationFromDTO(dto) as IndentAnnotation;
12
+ };
13
+
14
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
15
+ return baseAnnotationToDto(annotation);
16
+ };
@@ -0,0 +1,4 @@
1
+ export * from './annotation';
2
+ export * from './annotation-type';
3
+ export * from './export';
4
+ export * from './transform';
@@ -0,0 +1,34 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type InlineTitleAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+ import { TranslationLanguage } from '../language';
10
+
11
+ export const transformer: AnnotationTransformer = (
12
+ dto,
13
+ ): InlineTitleAnnotation => {
14
+ const inlineTitle = baseAnnotationFromDTO(dto) as InlineTitleAnnotation;
15
+ dto.content.forEach((content) => {
16
+ if (content.lang) {
17
+ inlineTitle.lang = content.lang as TranslationLanguage;
18
+ }
19
+ });
20
+
21
+ return inlineTitle;
22
+ };
23
+
24
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
25
+ const { lang } = annotation as InlineTitleAnnotation;
26
+ const dto = baseAnnotationToDto(annotation);
27
+
28
+ if (lang) {
29
+ dto.content.push({
30
+ lang,
31
+ });
32
+ }
33
+ return dto;
34
+ };
@@ -0,0 +1,86 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type InternalLinkAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): InternalLinkAnnotation => {
13
+ const internalLink = baseAnnotationFromDTO(dto) as InternalLinkAnnotation;
14
+ dto.content.forEach((content) => {
15
+ if (content.href) {
16
+ internalLink.href = content.href as string;
17
+ }
18
+
19
+ if (content['link-type']) {
20
+ internalLink.isPending = true;
21
+ }
22
+
23
+ if (content.type) {
24
+ internalLink.linkType = content['type'] as string;
25
+ }
26
+
27
+ if (content.label) {
28
+ internalLink.label = content.label as string;
29
+ }
30
+
31
+ if (content.uuid) {
32
+ internalLink.entity = content.uuid as string;
33
+ }
34
+
35
+ if (content.same_work !== undefined) {
36
+ internalLink.isSameWork = !!content.same_work;
37
+ }
38
+
39
+ if (content.subtype) {
40
+ internalLink.subtype = content.subtype as string;
41
+ }
42
+
43
+ if (content.toh) {
44
+ internalLink.linkToh = content.toh as string;
45
+ }
46
+ });
47
+
48
+ return internalLink;
49
+ };
50
+
51
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
52
+ const { entity, linkType, href, label, isPending } =
53
+ annotation as InternalLinkAnnotation;
54
+ const dto = baseAnnotationToDto(annotation);
55
+ dto.content = [
56
+ {
57
+ href,
58
+ },
59
+ ];
60
+
61
+ if (isPending) {
62
+ dto.content.push({
63
+ 'link-type': 'pending',
64
+ });
65
+ }
66
+
67
+ if (label) {
68
+ dto.content.push({
69
+ label,
70
+ });
71
+ }
72
+
73
+ if (entity) {
74
+ dto.content.push({
75
+ uuid: entity,
76
+ });
77
+ }
78
+
79
+ if (linkType) {
80
+ dto.content.push({
81
+ type: linkType,
82
+ });
83
+ }
84
+
85
+ return dto;
86
+ };
@@ -0,0 +1,18 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type LeadingSpaceAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): LeadingSpaceAnnotation => {
13
+ return baseAnnotationFromDTO(dto) as LeadingSpaceAnnotation;
14
+ };
15
+
16
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
17
+ return baseAnnotationToDto(annotation);
18
+ };
@@ -0,0 +1,18 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type LineGroupAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): LineGroupAnnotation => {
13
+ return baseAnnotationFromDTO(dto) as LineGroupAnnotation;
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 LineAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): LineAnnotation => {
11
+ return baseAnnotationFromDTO(dto) as LineAnnotation;
12
+ };
13
+
14
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
15
+ return baseAnnotationToDto(annotation);
16
+ };
@@ -0,0 +1,38 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type LinkAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): LinkAnnotation => {
11
+ const linkAnnotation = baseAnnotationFromDTO(dto) as LinkAnnotation;
12
+ dto.content.forEach((content) => {
13
+ if (content.title) {
14
+ linkAnnotation.text = content.title as string;
15
+ }
16
+
17
+ if (content.href) {
18
+ linkAnnotation.href = content.href as string;
19
+ }
20
+ });
21
+
22
+ return linkAnnotation;
23
+ };
24
+
25
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
26
+ const { href, text } = annotation as LinkAnnotation;
27
+ const dto = baseAnnotationToDto(annotation);
28
+ dto.content.push({
29
+ href,
30
+ });
31
+
32
+ if (text) {
33
+ dto.content.push({
34
+ title: text,
35
+ });
36
+ }
37
+ return dto;
38
+ };
@@ -0,0 +1,16 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type ListItemAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): ListItemAnnotation => {
11
+ return baseAnnotationFromDTO(dto) as ListItemAnnotation;
12
+ };
13
+
14
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
15
+ return baseAnnotationToDto(annotation);
16
+ };
@@ -0,0 +1,43 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type ListAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): ListAnnotation => {
11
+ const listAnnotation = baseAnnotationFromDTO(dto) as ListAnnotation;
12
+ dto.content.forEach((content) => {
13
+ if (content['list-spacing']) {
14
+ listAnnotation.spacing = content['list-spacing'] as string;
15
+ }
16
+
17
+ if (content['list-item-style']) {
18
+ listAnnotation.itemStyle = content['list-item-style'] as string;
19
+ }
20
+
21
+ if (content.nesting) {
22
+ listAnnotation.nesting = Number.parseInt(content.nesting as string);
23
+ }
24
+ });
25
+
26
+ return listAnnotation;
27
+ };
28
+
29
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
30
+ const { spacing, nesting, itemStyle } = annotation as ListAnnotation;
31
+ const dto = baseAnnotationToDto(annotation);
32
+ if (spacing) {
33
+ dto.content.push({ 'list-spacing': spacing });
34
+ }
35
+ if (nesting) {
36
+ dto.content.push({ nesting });
37
+ }
38
+ if (itemStyle) {
39
+ dto.content.push({ 'list-item-style': itemStyle });
40
+ }
41
+
42
+ return dto;
43
+ };
@@ -0,0 +1,31 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type MantraAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+ import type { ExtendedTranslationLanguage } from '../language';
10
+
11
+ export const transformer: AnnotationTransformer = (dto): MantraAnnotation => {
12
+ const mantraAnnotation = baseAnnotationFromDTO(dto) as MantraAnnotation;
13
+ dto.content.forEach((content) => {
14
+ if (content.lang) {
15
+ mantraAnnotation.lang = content.lang as ExtendedTranslationLanguage;
16
+ }
17
+ });
18
+ return mantraAnnotation;
19
+ };
20
+
21
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
22
+ const { lang } = annotation as MantraAnnotation;
23
+ const dto = baseAnnotationToDto(annotation);
24
+
25
+ if (lang) {
26
+ dto.content.push({
27
+ lang,
28
+ });
29
+ }
30
+ return dto;
31
+ };
@@ -0,0 +1,64 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type MentionAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): MentionAnnotation => {
13
+ const mention = baseAnnotationFromDTO(dto) as MentionAnnotation;
14
+ dto.content.forEach((content) => {
15
+ if (content.uuid) {
16
+ mention.entity = content.uuid as string;
17
+ }
18
+ if (content.type) {
19
+ mention.linkType = content.type as string;
20
+ }
21
+ if (content.text) {
22
+ mention.text = content.text as string;
23
+ }
24
+ if (content.same_work !== undefined) {
25
+ mention.isSameWork = !!content.same_work;
26
+ }
27
+ if (content.subtype) {
28
+ mention.subtype = content.subtype as string;
29
+ }
30
+ if (content.toh) {
31
+ mention.linkToh = content.toh as string;
32
+ }
33
+ });
34
+
35
+ return mention;
36
+ };
37
+
38
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
39
+ const { entity, linkType, text, isSameWork, subtype, linkToh } =
40
+ annotation as MentionAnnotation;
41
+ const dto = baseAnnotationToDto(annotation);
42
+
43
+ if (entity) {
44
+ dto.content.push({ uuid: entity });
45
+ }
46
+ if (linkType) {
47
+ dto.content.push({ type: linkType });
48
+ }
49
+ // Persist custom override text, but NEVER persist displayText
50
+ if (text) {
51
+ dto.content.push({ text });
52
+ }
53
+ if (isSameWork !== undefined) {
54
+ dto.content.push({ same_work: isSameWork });
55
+ }
56
+ if (subtype) {
57
+ dto.content.push({ subtype });
58
+ }
59
+ if (linkToh) {
60
+ dto.content.push({ toh: linkToh });
61
+ }
62
+
63
+ return dto;
64
+ };
@@ -0,0 +1,18 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type ParagraphAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): ParagraphAnnotation => {
13
+ return baseAnnotationFromDTO(dto) as ParagraphAnnotation;
14
+ };
15
+
16
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
17
+ return baseAnnotationToDto(annotation);
18
+ };
@@ -0,0 +1,30 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type QuoteAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): QuoteAnnotation => {
11
+ const quoteAnnotation = baseAnnotationFromDTO(dto) as QuoteAnnotation;
12
+ dto.content.forEach((content) => {
13
+ if (content.uuid) {
14
+ quoteAnnotation.quote = content.uuid as string;
15
+ }
16
+ });
17
+
18
+ return quoteAnnotation;
19
+ };
20
+
21
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
22
+ const { quote } = annotation as QuoteAnnotation;
23
+ const dto = baseAnnotationToDto(annotation);
24
+ if (quote) {
25
+ dto.content.push({
26
+ uuid: quote,
27
+ });
28
+ }
29
+ return dto;
30
+ };
@@ -0,0 +1,30 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type QuotedAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (dto): QuotedAnnotation => {
11
+ const quotedAnnotation = baseAnnotationFromDTO(dto) as QuotedAnnotation;
12
+ dto.content.forEach((content) => {
13
+ if (content.uuid) {
14
+ quotedAnnotation.quote = content.uuid as string;
15
+ }
16
+ });
17
+
18
+ return quotedAnnotation;
19
+ };
20
+
21
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
22
+ const { quote } = annotation as QuotedAnnotation;
23
+ const dto = baseAnnotationToDto(annotation);
24
+ if (quote) {
25
+ dto.content.push({
26
+ uuid: quote,
27
+ });
28
+ }
29
+ return dto;
30
+ };
@@ -0,0 +1,18 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type ReferenceAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): ReferenceAnnotation => {
13
+ return baseAnnotationFromDTO(dto) as ReferenceAnnotation;
14
+ };
15
+
16
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
17
+ return baseAnnotationToDto(annotation);
18
+ };
@@ -0,0 +1,39 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type SpanAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+ import type { ExtendedTranslationLanguage } from '../language';
10
+
11
+ export const transformer: AnnotationTransformer = (dto): SpanAnnotation => {
12
+ const spanAnnotation = baseAnnotationFromDTO(dto) as SpanAnnotation;
13
+ dto.content.forEach((content) => {
14
+ if (content['text-style']) {
15
+ spanAnnotation.textStyle = content['text-style'] as string;
16
+ }
17
+
18
+ if (content.lang) {
19
+ spanAnnotation.lang = content.lang as ExtendedTranslationLanguage;
20
+ }
21
+ });
22
+ return spanAnnotation;
23
+ };
24
+
25
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
26
+ const { textStyle, lang } = annotation as SpanAnnotation;
27
+ const dto = baseAnnotationToDto(annotation);
28
+ if (textStyle) {
29
+ dto.content.push({
30
+ 'text-style': textStyle,
31
+ });
32
+ }
33
+ if (lang) {
34
+ dto.content.push({
35
+ lang,
36
+ });
37
+ }
38
+ return dto;
39
+ };
@@ -0,0 +1,18 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type TableBodyDataAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): TableBodyDataAnnotation => {
13
+ return baseAnnotationFromDTO(dto) as TableBodyDataAnnotation;
14
+ };
15
+
16
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
17
+ return baseAnnotationToDto(annotation);
18
+ };
@@ -0,0 +1,18 @@
1
+ import type { AnnotationDTO } from './annotation-type';
2
+ import {
3
+ type AnnotationExporter,
4
+ type AnnotationTransformer,
5
+ type TableBodyHeaderAnnotation,
6
+ baseAnnotationFromDTO,
7
+ baseAnnotationToDto,
8
+ } from './annotation';
9
+
10
+ export const transformer: AnnotationTransformer = (
11
+ dto,
12
+ ): TableBodyHeaderAnnotation => {
13
+ return baseAnnotationFromDTO(dto) as TableBodyHeaderAnnotation;
14
+ };
15
+
16
+ export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
17
+ return baseAnnotationToDto(annotation);
18
+ };