@eightyfourthousand/data-access 2026.4.0 → 2026.4.2
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/index.js +18 -0
- package/index.js.map +1 -0
- package/lib/auth.d.ts +59 -0
- package/lib/auth.js +134 -0
- package/lib/auth.js.map +1 -0
- package/lib/bibliography.d.ts +9 -0
- package/lib/bibliography.js +30 -0
- package/lib/bibliography.js.map +1 -0
- package/lib/client-browser.d.ts +1 -0
- package/lib/client-browser.js +10 -0
- package/lib/client-browser.js.map +1 -0
- package/lib/client-server.d.ts +4 -0
- package/lib/client-server.js +19 -0
- package/lib/client-server.js.map +1 -0
- package/lib/client-ssr.d.ts +1 -0
- package/lib/client-ssr.js +23 -0
- package/lib/client-ssr.js.map +1 -0
- package/lib/client-token.d.ts +7 -0
- package/lib/client-token.js +21 -0
- package/lib/client-token.js.map +1 -0
- package/lib/feedback.d.ts +6 -0
- package/lib/feedback.js +45 -0
- package/lib/feedback.js.map +1 -0
- package/lib/folio.d.ts +11 -0
- package/lib/folio.js +31 -0
- package/lib/folio.js.map +1 -0
- package/lib/glossary/batch.d.ts +5 -0
- package/lib/glossary/batch.js +22 -0
- package/lib/glossary/batch.js.map +1 -0
- package/lib/glossary/index.js +5 -0
- package/lib/glossary/index.js.map +1 -0
- package/lib/glossary/instance.d.ts +10 -0
- package/lib/glossary/instance.js +28 -0
- package/lib/glossary/instance.js.map +1 -0
- package/lib/glossary/landing.d.ts +5 -0
- package/lib/glossary/landing.js +32 -0
- package/lib/glossary/landing.js.map +1 -0
- package/lib/glossary/pagination.d.ts +55 -0
- package/lib/glossary/pagination.js +254 -0
- package/lib/glossary/pagination.js.map +1 -0
- package/lib/imprint.d.ts +10 -0
- package/lib/imprint.js +23 -0
- package/lib/imprint.js.map +1 -0
- package/lib/library.d.ts +58 -0
- package/lib/library.js +118 -0
- package/lib/library.js.map +1 -0
- package/lib/local-storage.d.ts +10 -0
- package/lib/local-storage.js +25 -0
- package/lib/local-storage.js.map +1 -0
- package/lib/lookup-entity.d.ts +7 -0
- package/lib/lookup-entity.js +93 -0
- package/lib/lookup-entity.js.map +1 -0
- package/lib/panel-url.d.ts +10 -0
- package/lib/panel-url.js +23 -0
- package/lib/panel-url.js.map +1 -0
- package/lib/passage/batch.d.ts +17 -0
- package/lib/passage/batch.js +155 -0
- package/lib/passage/batch.js.map +1 -0
- package/lib/passage/index.js +6 -0
- package/lib/passage/index.js.map +1 -0
- package/lib/passage/pagination.d.ts +43 -0
- package/lib/passage/pagination.js +167 -0
- package/lib/passage/pagination.js.map +1 -0
- package/lib/passage/read.d.ts +15 -0
- package/lib/passage/read.js +59 -0
- package/lib/passage/read.js.map +1 -0
- package/lib/passage/replace-persistence.d.ts +46 -0
- package/lib/passage/replace-persistence.js +93 -0
- package/lib/passage/replace-persistence.js.map +1 -0
- package/lib/passage/save.d.ts +16 -0
- package/lib/passage/save.js +227 -0
- package/lib/passage/save.js.map +1 -0
- package/lib/proxy.d.ts +7 -0
- package/lib/proxy.js +45 -0
- package/lib/proxy.js.map +1 -0
- package/lib/publications.d.ts +86 -0
- package/lib/publications.js +223 -0
- package/lib/publications.js.map +1 -0
- package/lib/replace.d.ts +31 -0
- package/lib/replace.js +151 -0
- package/lib/replace.js.map +1 -0
- package/lib/storage.d.ts +7 -0
- package/lib/storage.js +10 -0
- package/lib/storage.js.map +1 -0
- package/lib/types/alignment.d.ts +18 -0
- package/lib/types/alignment.js +13 -0
- package/lib/types/alignment.js.map +1 -0
- package/lib/types/annotation/abbreviation.d.ts +3 -0
- package/lib/types/annotation/abbreviation.js +20 -0
- package/lib/types/annotation/abbreviation.js.map +1 -0
- package/lib/types/annotation/annotation-type.d.ts +31 -0
- package/lib/types/annotation/annotation-type.js +81 -0
- package/lib/types/annotation/annotation-type.js.map +1 -0
- package/lib/types/annotation/annotation.d.ts +142 -0
- package/lib/types/annotation/annotation.js +23 -0
- package/lib/types/annotation/annotation.js.map +1 -0
- package/lib/types/annotation/audio.d.ts +3 -0
- package/lib/types/annotation/audio.js +24 -0
- package/lib/types/annotation/audio.js.map +1 -0
- package/lib/types/annotation/blockquote.d.ts +3 -0
- package/lib/types/annotation/blockquote.js +8 -0
- package/lib/types/annotation/blockquote.js.map +1 -0
- package/lib/types/annotation/code.d.ts +3 -0
- package/lib/types/annotation/code.js +8 -0
- package/lib/types/annotation/code.js.map +1 -0
- package/lib/types/annotation/deprecated.d.ts +3 -0
- package/lib/types/annotation/deprecated.js +8 -0
- package/lib/types/annotation/deprecated.js.map +1 -0
- package/lib/types/annotation/end-note-link.d.ts +3 -0
- package/lib/types/annotation/end-note-link.js +23 -0
- package/lib/types/annotation/end-note-link.js.map +1 -0
- package/lib/types/annotation/export.d.ts +3 -0
- package/{src/lib/types/annotation/export.ts → lib/types/annotation/export.js} +34 -36
- package/lib/types/annotation/export.js.map +1 -0
- package/lib/types/annotation/glossary-instance.d.ts +3 -0
- package/lib/types/annotation/glossary-instance.js +23 -0
- package/lib/types/annotation/glossary-instance.js.map +1 -0
- package/lib/types/annotation/has-abbreviation.d.ts +3 -0
- package/lib/types/annotation/has-abbreviation.js +20 -0
- package/lib/types/annotation/has-abbreviation.js.map +1 -0
- package/lib/types/annotation/heading.d.ts +3 -0
- package/lib/types/annotation/heading.js +26 -0
- package/lib/types/annotation/heading.js.map +1 -0
- package/lib/types/annotation/image.d.ts +3 -0
- package/lib/types/annotation/image.js +20 -0
- package/lib/types/annotation/image.js.map +1 -0
- package/lib/types/annotation/indent.d.ts +3 -0
- package/lib/types/annotation/indent.js +8 -0
- package/lib/types/annotation/indent.js.map +1 -0
- package/lib/types/annotation/index.js +5 -0
- package/lib/types/annotation/index.js.map +1 -0
- package/lib/types/annotation/inline-title.d.ts +3 -0
- package/lib/types/annotation/inline-title.js +21 -0
- package/lib/types/annotation/inline-title.js.map +1 -0
- package/lib/types/annotation/internal-link.d.ts +3 -0
- package/lib/types/annotation/internal-link.js +62 -0
- package/lib/types/annotation/internal-link.js.map +1 -0
- package/lib/types/annotation/leading-space.d.ts +3 -0
- package/lib/types/annotation/leading-space.js +8 -0
- package/lib/types/annotation/leading-space.js.map +1 -0
- package/lib/types/annotation/line-group.d.ts +3 -0
- package/lib/types/annotation/line-group.js +8 -0
- package/lib/types/annotation/line-group.js.map +1 -0
- package/lib/types/annotation/line.d.ts +3 -0
- package/lib/types/annotation/line.js +8 -0
- package/lib/types/annotation/line.js.map +1 -0
- package/lib/types/annotation/link.d.ts +3 -0
- package/lib/types/annotation/link.js +27 -0
- package/lib/types/annotation/link.js.map +1 -0
- package/lib/types/annotation/list-item.d.ts +3 -0
- package/lib/types/annotation/list-item.js +8 -0
- package/lib/types/annotation/list-item.js.map +1 -0
- package/lib/types/annotation/list.d.ts +3 -0
- package/lib/types/annotation/list.js +31 -0
- package/lib/types/annotation/list.js.map +1 -0
- package/lib/types/annotation/mantra.d.ts +3 -0
- package/lib/types/annotation/mantra.js +21 -0
- package/lib/types/annotation/mantra.js.map +1 -0
- package/lib/types/annotation/mention.d.ts +3 -0
- package/lib/types/annotation/mention.js +50 -0
- package/lib/types/annotation/mention.js.map +1 -0
- package/lib/types/annotation/paragraph.d.ts +3 -0
- package/lib/types/annotation/paragraph.js +8 -0
- package/lib/types/annotation/paragraph.js.map +1 -0
- package/lib/types/annotation/quote.d.ts +3 -0
- package/lib/types/annotation/quote.js +21 -0
- package/lib/types/annotation/quote.js.map +1 -0
- package/lib/types/annotation/quoted.d.ts +3 -0
- package/lib/types/annotation/quoted.js +21 -0
- package/lib/types/annotation/quoted.js.map +1 -0
- package/lib/types/annotation/reference.d.ts +3 -0
- package/lib/types/annotation/reference.js +8 -0
- package/lib/types/annotation/reference.js.map +1 -0
- package/lib/types/annotation/span.d.ts +3 -0
- package/lib/types/annotation/span.js +29 -0
- package/lib/types/annotation/span.js.map +1 -0
- package/lib/types/annotation/table-body-data.d.ts +3 -0
- package/lib/types/annotation/table-body-data.js +8 -0
- package/lib/types/annotation/table-body-data.js.map +1 -0
- package/lib/types/annotation/table-body-header.d.ts +3 -0
- package/lib/types/annotation/table-body-header.js +8 -0
- package/lib/types/annotation/table-body-header.js.map +1 -0
- package/lib/types/annotation/table-body-row.d.ts +3 -0
- package/lib/types/annotation/table-body-row.js +8 -0
- package/lib/types/annotation/table-body-row.js.map +1 -0
- package/lib/types/annotation/table.d.ts +3 -0
- package/lib/types/annotation/table.js +8 -0
- package/lib/types/annotation/table.js.map +1 -0
- package/lib/types/annotation/trailer.d.ts +3 -0
- package/lib/types/annotation/trailer.js +8 -0
- package/lib/types/annotation/trailer.js.map +1 -0
- package/lib/types/annotation/transform.d.ts +6 -0
- package/lib/types/annotation/transform.js +109 -0
- package/lib/types/annotation/transform.js.map +1 -0
- package/lib/types/annotation/unknown.d.ts +3 -0
- package/lib/types/annotation/unknown.js +8 -0
- package/lib/types/annotation/unknown.js.map +1 -0
- package/lib/types/bibliography.d.ts +41 -0
- package/lib/types/bibliography.js +29 -0
- package/lib/types/bibliography.js.map +1 -0
- package/{src/lib/types/client.ts → lib/types/client.d.ts} +0 -1
- package/lib/types/client.js +2 -0
- package/lib/types/client.js.map +1 -0
- package/{src/lib/types/editor-content.ts → lib/types/editor-content.d.ts} +7 -11
- package/lib/types/editor-content.js +2 -0
- package/lib/types/editor-content.js.map +1 -0
- package/lib/types/folio.d.ts +17 -0
- package/lib/types/folio.js +11 -0
- package/lib/types/folio.js.map +1 -0
- package/lib/types/glossary-page.d.ts +48 -0
- package/lib/types/glossary-page.js +21 -0
- package/lib/types/glossary-page.js.map +1 -0
- package/lib/types/glossary.d.ts +76 -0
- package/lib/types/glossary.js +32 -0
- package/lib/types/glossary.js.map +1 -0
- package/lib/types/imprint.d.ts +78 -0
- package/lib/types/imprint.js +78 -0
- package/lib/types/imprint.js.map +1 -0
- package/lib/types/index.js +20 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/language.d.ts +9 -0
- package/lib/types/language.js +41 -0
- package/lib/types/language.js.map +1 -0
- package/lib/types/layout.d.ts +5 -0
- package/lib/types/layout.js +23 -0
- package/lib/types/layout.js.map +1 -0
- package/lib/types/library.d.ts +19 -0
- package/lib/types/library.js +8 -0
- package/lib/types/library.js.map +1 -0
- package/lib/types/passage.d.ts +73 -0
- package/lib/types/passage.js +123 -0
- package/lib/types/passage.js.map +1 -0
- package/lib/types/semver.js +2 -0
- package/lib/types/semver.js.map +1 -0
- package/lib/types/title.d.ts +21 -0
- package/lib/types/title.js +21 -0
- package/lib/types/title.js.map +1 -0
- package/lib/types/toh.js +2 -0
- package/lib/types/toh.js.map +1 -0
- package/{src/lib/types/translation.ts → lib/types/translation.d.ts} +5 -7
- package/lib/types/translation.js +2 -0
- package/lib/types/translation.js.map +1 -0
- package/{src/lib/types/user.ts → lib/types/user.d.ts} +2 -11
- package/lib/types/user.js +9 -0
- package/lib/types/user.js.map +1 -0
- package/lib/types/work.d.ts +37 -0
- package/lib/types/work.js +12 -0
- package/lib/types/work.js.map +1 -0
- package/lib/use-bookmark.d.ts +10 -0
- package/lib/use-bookmark.js +30 -0
- package/lib/use-bookmark.js.map +1 -0
- package/package.json +25 -3
- package/ssr.js +6 -0
- package/ssr.js.map +1 -0
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -18
- package/README.md +0 -9
- package/jest.config.ts +0 -10
- package/project.json +0 -21
- package/src/lib/auth.ts +0 -203
- package/src/lib/bibliography.ts +0 -57
- package/src/lib/client-browser.ts +0 -12
- package/src/lib/client-server.ts +0 -30
- package/src/lib/client-ssr.ts +0 -24
- package/src/lib/client-token.ts +0 -24
- package/src/lib/feedback.ts +0 -71
- package/src/lib/folio.ts +0 -57
- package/src/lib/glossary/batch.ts +0 -35
- package/src/lib/glossary/instance.ts +0 -54
- package/src/lib/glossary/landing.ts +0 -50
- package/src/lib/glossary/pagination.ts +0 -471
- package/src/lib/imprint.ts +0 -42
- package/src/lib/library.ts +0 -209
- package/src/lib/local-storage.ts +0 -33
- package/src/lib/lookup-entity.ts +0 -122
- package/src/lib/panel-url.ts +0 -43
- package/src/lib/passage/batch.ts +0 -229
- package/src/lib/passage/pagination.ts +0 -277
- package/src/lib/passage/read.ts +0 -100
- package/src/lib/passage/replace-persistence.ts +0 -153
- package/src/lib/passage/save.ts +0 -324
- package/src/lib/proxy.ts +0 -68
- package/src/lib/publications.ts +0 -381
- package/src/lib/replace.spec.ts +0 -154
- package/src/lib/replace.ts +0 -244
- package/src/lib/storage.ts +0 -23
- package/src/lib/types/alignment.ts +0 -32
- package/src/lib/types/annotation/abbreviation.ts +0 -30
- package/src/lib/types/annotation/annotation-type.ts +0 -219
- package/src/lib/types/annotation/annotation.ts +0 -244
- package/src/lib/types/annotation/audio.ts +0 -33
- package/src/lib/types/annotation/blockquote.ts +0 -18
- package/src/lib/types/annotation/code.ts +0 -16
- package/src/lib/types/annotation/deprecated.ts +0 -18
- package/src/lib/types/annotation/end-note-link.ts +0 -35
- package/src/lib/types/annotation/glossary-instance.ts +0 -34
- package/src/lib/types/annotation/has-abbreviation.ts +0 -30
- package/src/lib/types/annotation/heading.ts +0 -37
- package/src/lib/types/annotation/image.ts +0 -29
- package/src/lib/types/annotation/indent.ts +0 -16
- package/src/lib/types/annotation/inline-title.ts +0 -34
- package/src/lib/types/annotation/internal-link.ts +0 -86
- package/src/lib/types/annotation/leading-space.ts +0 -18
- package/src/lib/types/annotation/line-group.ts +0 -18
- package/src/lib/types/annotation/line.ts +0 -16
- package/src/lib/types/annotation/link.ts +0 -38
- package/src/lib/types/annotation/list-item.ts +0 -16
- package/src/lib/types/annotation/list.ts +0 -43
- package/src/lib/types/annotation/mantra.ts +0 -31
- package/src/lib/types/annotation/mention.ts +0 -64
- package/src/lib/types/annotation/paragraph.ts +0 -18
- package/src/lib/types/annotation/quote.ts +0 -30
- package/src/lib/types/annotation/quoted.ts +0 -30
- package/src/lib/types/annotation/reference.ts +0 -18
- package/src/lib/types/annotation/span.ts +0 -39
- package/src/lib/types/annotation/table-body-data.ts +0 -18
- package/src/lib/types/annotation/table-body-header.ts +0 -18
- package/src/lib/types/annotation/table-body-row.ts +0 -18
- package/src/lib/types/annotation/table.ts +0 -16
- package/src/lib/types/annotation/trailer.ts +0 -16
- package/src/lib/types/annotation/transform.ts +0 -140
- package/src/lib/types/annotation/unknown.ts +0 -16
- package/src/lib/types/bibliography.ts +0 -86
- package/src/lib/types/folio.ts +0 -28
- package/src/lib/types/glossary-page.ts +0 -86
- package/src/lib/types/glossary.ts +0 -115
- package/src/lib/types/imprint.ts +0 -159
- package/src/lib/types/language.ts +0 -64
- package/src/lib/types/layout.ts +0 -37
- package/src/lib/types/library.ts +0 -29
- package/src/lib/types/passage.ts +0 -220
- package/src/lib/types/title.ts +0 -47
- package/src/lib/types/work.ts +0 -38
- package/src/lib/use-bookmark.ts +0 -45
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -26
- package/tsconfig.spec.json +0 -22
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/lib/glossary/index.ts → lib/glossary/index.d.ts} +0 -0
- /package/{src/lib/passage/index.ts → lib/passage/index.d.ts} +0 -0
- /package/{src/lib/types/annotation/index.ts → lib/types/annotation/index.d.ts} +0 -0
- /package/{src/lib/types/index.ts → lib/types/index.d.ts} +0 -0
- /package/{src/lib/types/semver.ts → lib/types/semver.d.ts} +0 -0
- /package/{src/lib/types/toh.ts → lib/types/toh.d.ts} +0 -0
- /package/{src/ssr.ts → ssr.d.ts} +0 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { titlesFromDTO, workFromDTO, passagesPageFromDTO, passagesPageAroundFromDTO, } from './types';
|
|
2
|
+
export const getTranslationUuids = async ({ client, }) => {
|
|
3
|
+
const { data } = await client.rpc('get_static_translation_uuids');
|
|
4
|
+
return data?.map(({ uuid }) => uuid) || [];
|
|
5
|
+
};
|
|
6
|
+
export const getWorkUuidByToh = async ({ client, toh, }) => {
|
|
7
|
+
const { data, error } = await client
|
|
8
|
+
.from('work_toh')
|
|
9
|
+
.select('work_uuid')
|
|
10
|
+
.eq('toh_clean', toh)
|
|
11
|
+
.single();
|
|
12
|
+
if (error || !data) {
|
|
13
|
+
if (error) {
|
|
14
|
+
console.error('Error fetching work UUID by TOH:', error);
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return data.work_uuid ?? null;
|
|
19
|
+
};
|
|
20
|
+
export const getTranslationPassages = async ({ client, uuid, type, cursor, maxPassages, maxCharacters, direction, }) => {
|
|
21
|
+
const { data, error } = await client.rpc('get_passages_page', {
|
|
22
|
+
uuid_input: uuid,
|
|
23
|
+
passage_type_input: type,
|
|
24
|
+
cursor,
|
|
25
|
+
max_passages: maxPassages,
|
|
26
|
+
char_budget: maxCharacters,
|
|
27
|
+
direction,
|
|
28
|
+
});
|
|
29
|
+
if (error) {
|
|
30
|
+
console.error('Error fetching translation passages:', error);
|
|
31
|
+
return {
|
|
32
|
+
hasMoreAfter: false,
|
|
33
|
+
hasMoreBefore: false,
|
|
34
|
+
passages: [],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return passagesPageFromDTO(direction || 'forward', data);
|
|
38
|
+
};
|
|
39
|
+
export const getTranslationPassagesAround = async ({ client, uuid, passageUuid, type, maxPassages, maxCharacters, }) => {
|
|
40
|
+
const { data, error } = await client.rpc('get_passages_page_around', {
|
|
41
|
+
uuid_input: uuid,
|
|
42
|
+
cursor: passageUuid,
|
|
43
|
+
passage_type_input: type,
|
|
44
|
+
max_passages: maxPassages,
|
|
45
|
+
char_budget: maxCharacters,
|
|
46
|
+
});
|
|
47
|
+
if (error) {
|
|
48
|
+
console.error('Error fetching translation passages around:', error);
|
|
49
|
+
return {
|
|
50
|
+
hasMoreAfter: false,
|
|
51
|
+
hasMoreBefore: false,
|
|
52
|
+
passages: [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return passagesPageAroundFromDTO(data);
|
|
56
|
+
};
|
|
57
|
+
export const getTranslationTitles = async ({ client, uuid, }) => {
|
|
58
|
+
const { data } = await client.rpc('get_work_titles', {
|
|
59
|
+
work_uuid_input: uuid,
|
|
60
|
+
});
|
|
61
|
+
return titlesFromDTO(data);
|
|
62
|
+
};
|
|
63
|
+
export const getWorkTitles = async ({ client, uuid, }) => {
|
|
64
|
+
const { data, error } = await client.rpc('get_work_titles', {
|
|
65
|
+
work_uuid_input: uuid,
|
|
66
|
+
});
|
|
67
|
+
if (error) {
|
|
68
|
+
console.error('Error fetching work titles:', error);
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
return titlesFromDTO(data);
|
|
72
|
+
};
|
|
73
|
+
export const getWorkTitlesByUuids = async ({ client, uuids, }) => {
|
|
74
|
+
const titlesByUuid = new Map();
|
|
75
|
+
if (uuids.length === 0)
|
|
76
|
+
return titlesByUuid;
|
|
77
|
+
const { data, error } = await client
|
|
78
|
+
.from('works')
|
|
79
|
+
.select('uuid, title')
|
|
80
|
+
.in('uuid', uuids);
|
|
81
|
+
if (error) {
|
|
82
|
+
console.error('Error batch loading work titles:', error);
|
|
83
|
+
return titlesByUuid;
|
|
84
|
+
}
|
|
85
|
+
for (const work of data ?? []) {
|
|
86
|
+
if (work.title) {
|
|
87
|
+
titlesByUuid.set(work.uuid, work.title);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return titlesByUuid;
|
|
91
|
+
};
|
|
92
|
+
export const getTranslationMetadataByUuid = async ({ client, uuid, }) => {
|
|
93
|
+
const { data, error } = await client
|
|
94
|
+
.from('works')
|
|
95
|
+
.select(`
|
|
96
|
+
uuid,
|
|
97
|
+
title,
|
|
98
|
+
description,
|
|
99
|
+
tohs:work_toh!inner(toh:toh_clean),
|
|
100
|
+
publicationDate,
|
|
101
|
+
publicationVersion,
|
|
102
|
+
pages:source_pages,
|
|
103
|
+
restriction,
|
|
104
|
+
breadcrumb
|
|
105
|
+
`)
|
|
106
|
+
.eq('uuid', uuid)
|
|
107
|
+
.single();
|
|
108
|
+
if (error) {
|
|
109
|
+
throw new Error(`Error fetching translation metadata by UUID: ${error.message}`);
|
|
110
|
+
}
|
|
111
|
+
return workFromDTO(data);
|
|
112
|
+
};
|
|
113
|
+
export const getTranslationMetadataByToh = async ({ client, toh, }) => {
|
|
114
|
+
const { data, error } = await client
|
|
115
|
+
.from('work_toh')
|
|
116
|
+
.select(`
|
|
117
|
+
work_uuid,
|
|
118
|
+
works!inner(
|
|
119
|
+
uuid,
|
|
120
|
+
title,
|
|
121
|
+
description,
|
|
122
|
+
tohs:work_toh!inner(toh:toh_clean),
|
|
123
|
+
publicationDate,
|
|
124
|
+
publicationVersion,
|
|
125
|
+
pages:source_pages,
|
|
126
|
+
restriction,
|
|
127
|
+
breadcrumb
|
|
128
|
+
)
|
|
129
|
+
`)
|
|
130
|
+
.eq('toh_clean', toh)
|
|
131
|
+
.single();
|
|
132
|
+
// Extract the work data from the joined result
|
|
133
|
+
const workData = data?.works;
|
|
134
|
+
if (error || !workData) {
|
|
135
|
+
console.error('Error fetching translation metadata by TOH:', error);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return workFromDTO(workData);
|
|
139
|
+
};
|
|
140
|
+
export const getTranslationsMetadata = async ({ client, }) => {
|
|
141
|
+
const { data, error } = await client
|
|
142
|
+
.from('works')
|
|
143
|
+
.select(`
|
|
144
|
+
uuid,
|
|
145
|
+
title,
|
|
146
|
+
description,
|
|
147
|
+
tohs:work_toh!inner(toh:toh_clean),
|
|
148
|
+
publicationDate,
|
|
149
|
+
publicationVersion,
|
|
150
|
+
pages:source_pages,
|
|
151
|
+
restriction,
|
|
152
|
+
breadcrumb
|
|
153
|
+
`)
|
|
154
|
+
.not('toh', 'like', 'toh00%');
|
|
155
|
+
if (error) {
|
|
156
|
+
console.error('Error fetching translations metadata:', error);
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const dto = data;
|
|
160
|
+
return dto?.map((work) => workFromDTO(work)) || [];
|
|
161
|
+
};
|
|
162
|
+
export const getWorksPage = async ({ client, cursor, limit = 50, maxPages, }) => {
|
|
163
|
+
const clampedLimit = Math.min(limit, 200);
|
|
164
|
+
let query = client
|
|
165
|
+
.from('works')
|
|
166
|
+
.select(`
|
|
167
|
+
uuid,
|
|
168
|
+
title,
|
|
169
|
+
description,
|
|
170
|
+
tohs:work_toh!inner(toh:toh_clean),
|
|
171
|
+
publicationDate,
|
|
172
|
+
publicationVersion,
|
|
173
|
+
pages:source_pages,
|
|
174
|
+
restriction,
|
|
175
|
+
breadcrumb
|
|
176
|
+
`, { count: 'exact' })
|
|
177
|
+
.not('toh', 'like', 'toh00%')
|
|
178
|
+
.order('title', { ascending: true })
|
|
179
|
+
.limit(clampedLimit + 1);
|
|
180
|
+
if (maxPages) {
|
|
181
|
+
query = query.lt('source_pages', maxPages);
|
|
182
|
+
}
|
|
183
|
+
if (cursor) {
|
|
184
|
+
const { data: cursorWork } = await client
|
|
185
|
+
.from('works')
|
|
186
|
+
.select('title')
|
|
187
|
+
.eq('uuid', cursor)
|
|
188
|
+
.single();
|
|
189
|
+
if (cursorWork) {
|
|
190
|
+
query = query.gt('title', cursorWork.title);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const { data, error, count } = await query;
|
|
194
|
+
if (error) {
|
|
195
|
+
console.error('Error fetching works:', error);
|
|
196
|
+
return {
|
|
197
|
+
items: [],
|
|
198
|
+
pageInfo: {
|
|
199
|
+
nextCursor: null,
|
|
200
|
+
prevCursor: null,
|
|
201
|
+
hasMoreAfter: false,
|
|
202
|
+
hasMoreBefore: false,
|
|
203
|
+
},
|
|
204
|
+
totalCount: 0,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const hasMoreAfter = (data ?? []).length > clampedLimit;
|
|
208
|
+
const items = hasMoreAfter
|
|
209
|
+
? (data ?? []).slice(0, clampedLimit)
|
|
210
|
+
: (data ?? []);
|
|
211
|
+
const works = items.map((dto) => workFromDTO(dto));
|
|
212
|
+
return {
|
|
213
|
+
items: works,
|
|
214
|
+
pageInfo: {
|
|
215
|
+
nextCursor: hasMoreAfter ? (works[works.length - 1]?.uuid ?? null) : null,
|
|
216
|
+
prevCursor: cursor ?? null,
|
|
217
|
+
hasMoreAfter,
|
|
218
|
+
hasMoreBefore: Boolean(cursor),
|
|
219
|
+
},
|
|
220
|
+
totalCount: count ?? 0,
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
//# sourceMappingURL=publications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publications.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/publications.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,aAAa,EACb,WAAW,EACX,mBAAmB,EAInB,yBAAyB,GAG1B,MAAM,SAAS,CAAC;AAejB,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,MAAM,GAGP,EAAqB,EAAE;IACtB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAClE,OAAO,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,EACrC,MAAM,EACN,GAAG,GAIJ,EAA0B,EAAE;IAC3B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM;SACjC,IAAI,CAAC,UAAU,CAAC;SAChB,MAAM,CAAC,WAAW,CAAC;SACnB,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC;SACpB,MAAM,EAAE,CAAC;IAEZ,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC;AAChC,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AC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;YACzE,UAAU,EAAE,MAAM,IAAI,IAAI;YAC1B,YAAY;YACZ,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC;SAC/B;QACD,UAAU,EAAE,KAAK,IAAI,CAAC;KACvB,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/replace.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Passage } from './types';
|
|
2
|
+
export interface PassageOccurrence {
|
|
3
|
+
end: number;
|
|
4
|
+
index: number;
|
|
5
|
+
passageOccurrenceIndex: number;
|
|
6
|
+
passageUuid: string;
|
|
7
|
+
start: number;
|
|
8
|
+
type: 'passage' | 'alignment';
|
|
9
|
+
}
|
|
10
|
+
export interface PassageReplacementResult {
|
|
11
|
+
deletedAnnotationCount: number;
|
|
12
|
+
nextSearchStart?: number;
|
|
13
|
+
passage: Passage;
|
|
14
|
+
replacementsApplied: number;
|
|
15
|
+
updatedAnnotationCount: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const findLiteralOccurrences: (content: string, searchText: string) => Array<{
|
|
18
|
+
end: number;
|
|
19
|
+
start: number;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const getPassageOccurrences: (passages: {
|
|
22
|
+
content: string;
|
|
23
|
+
uuid: string;
|
|
24
|
+
type: "passage" | "alignment";
|
|
25
|
+
}[], searchText: string) => PassageOccurrence[];
|
|
26
|
+
export declare const replacePassageText: ({ occurrenceIndex, passage, replaceText, searchText, }: {
|
|
27
|
+
occurrenceIndex?: number;
|
|
28
|
+
passage: Passage;
|
|
29
|
+
replaceText: string;
|
|
30
|
+
searchText: string;
|
|
31
|
+
}) => PassageReplacementResult;
|
package/lib/replace.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const findLiteralOccurrences = (content, searchText) => {
|
|
2
|
+
if (!searchText) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
const matches = [];
|
|
6
|
+
let fromIndex = 0;
|
|
7
|
+
while (fromIndex <= content.length - searchText.length) {
|
|
8
|
+
const start = content.indexOf(searchText, fromIndex);
|
|
9
|
+
if (start === -1) {
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
matches.push({
|
|
13
|
+
start,
|
|
14
|
+
end: start + searchText.length,
|
|
15
|
+
});
|
|
16
|
+
fromIndex = start + searchText.length;
|
|
17
|
+
}
|
|
18
|
+
return matches;
|
|
19
|
+
};
|
|
20
|
+
export const getPassageOccurrences = (passages, searchText) => {
|
|
21
|
+
let index = 0;
|
|
22
|
+
return passages.flatMap((passage) => findLiteralOccurrences(passage.content, searchText).map((match, passageIndex) => ({
|
|
23
|
+
...match,
|
|
24
|
+
index: index++,
|
|
25
|
+
passageOccurrenceIndex: passageIndex,
|
|
26
|
+
passageUuid: passage.uuid,
|
|
27
|
+
type: passage.type,
|
|
28
|
+
})));
|
|
29
|
+
};
|
|
30
|
+
const mapEditPosition = ({ delta, editEnd, editStart, position, replacementLength, stickTo, }) => {
|
|
31
|
+
if (position <= editStart) {
|
|
32
|
+
return position;
|
|
33
|
+
}
|
|
34
|
+
if (position >= editEnd) {
|
|
35
|
+
return position + delta;
|
|
36
|
+
}
|
|
37
|
+
return stickTo === 'start' ? editStart : editStart + replacementLength;
|
|
38
|
+
};
|
|
39
|
+
const remapAnnotationsForEdit = ({ annotations, editEnd, editStart, replacementLength, }) => {
|
|
40
|
+
const delta = replacementLength - (editEnd - editStart);
|
|
41
|
+
const nextAnnotations = [];
|
|
42
|
+
let deletedAnnotationCount = 0;
|
|
43
|
+
let updatedAnnotationCount = 0;
|
|
44
|
+
for (const annotation of annotations) {
|
|
45
|
+
if (annotation.end <= editStart) {
|
|
46
|
+
nextAnnotations.push(annotation);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (annotation.start >= editEnd) {
|
|
50
|
+
nextAnnotations.push({
|
|
51
|
+
...annotation,
|
|
52
|
+
start: annotation.start + delta,
|
|
53
|
+
end: annotation.end + delta,
|
|
54
|
+
});
|
|
55
|
+
updatedAnnotationCount++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const nextStart = mapEditPosition({
|
|
59
|
+
delta,
|
|
60
|
+
editEnd,
|
|
61
|
+
editStart,
|
|
62
|
+
position: annotation.start,
|
|
63
|
+
replacementLength,
|
|
64
|
+
stickTo: 'start',
|
|
65
|
+
});
|
|
66
|
+
const nextEnd = mapEditPosition({
|
|
67
|
+
delta,
|
|
68
|
+
editEnd,
|
|
69
|
+
editStart,
|
|
70
|
+
position: annotation.end,
|
|
71
|
+
replacementLength,
|
|
72
|
+
stickTo: 'end',
|
|
73
|
+
});
|
|
74
|
+
if (nextStart === nextEnd && replacementLength === 0) {
|
|
75
|
+
deletedAnnotationCount++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (nextStart !== annotation.start || nextEnd !== annotation.end) {
|
|
79
|
+
updatedAnnotationCount++;
|
|
80
|
+
nextAnnotations.push({
|
|
81
|
+
...annotation,
|
|
82
|
+
start: nextStart,
|
|
83
|
+
end: nextEnd,
|
|
84
|
+
});
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
nextAnnotations.push(annotation);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
annotations: nextAnnotations,
|
|
91
|
+
deletedAnnotationCount,
|
|
92
|
+
updatedAnnotationCount,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
export const replacePassageText = ({ occurrenceIndex, passage, replaceText, searchText, }) => {
|
|
96
|
+
if (!searchText || occurrenceIndex === null) {
|
|
97
|
+
return {
|
|
98
|
+
passage,
|
|
99
|
+
replacementsApplied: 0,
|
|
100
|
+
updatedAnnotationCount: 0,
|
|
101
|
+
deletedAnnotationCount: 0,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const matches = findLiteralOccurrences(passage.content, searchText);
|
|
105
|
+
const matchesToApply = occurrenceIndex === undefined
|
|
106
|
+
? matches
|
|
107
|
+
: matches.filter((_, index) => index === occurrenceIndex);
|
|
108
|
+
if (matchesToApply.length === 0) {
|
|
109
|
+
return {
|
|
110
|
+
passage,
|
|
111
|
+
replacementsApplied: 0,
|
|
112
|
+
updatedAnnotationCount: 0,
|
|
113
|
+
deletedAnnotationCount: 0,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
let content = passage.content;
|
|
117
|
+
let annotations = passage.annotations.map((annotation) => ({ ...annotation }));
|
|
118
|
+
let cumulativeDelta = 0;
|
|
119
|
+
let updatedAnnotationCount = 0;
|
|
120
|
+
let deletedAnnotationCount = 0;
|
|
121
|
+
let nextSearchStart;
|
|
122
|
+
for (const match of matchesToApply) {
|
|
123
|
+
const editStart = match.start + cumulativeDelta;
|
|
124
|
+
const editEnd = match.end + cumulativeDelta;
|
|
125
|
+
content =
|
|
126
|
+
content.slice(0, editStart) + replaceText + content.slice(editEnd);
|
|
127
|
+
const remappedAnnotations = remapAnnotationsForEdit({
|
|
128
|
+
annotations,
|
|
129
|
+
editStart,
|
|
130
|
+
editEnd,
|
|
131
|
+
replacementLength: replaceText.length,
|
|
132
|
+
});
|
|
133
|
+
annotations = remappedAnnotations.annotations;
|
|
134
|
+
updatedAnnotationCount += remappedAnnotations.updatedAnnotationCount;
|
|
135
|
+
deletedAnnotationCount += remappedAnnotations.deletedAnnotationCount;
|
|
136
|
+
nextSearchStart = editStart + replaceText.length;
|
|
137
|
+
cumulativeDelta += replaceText.length - (match.end - match.start);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
passage: {
|
|
141
|
+
...passage,
|
|
142
|
+
content,
|
|
143
|
+
annotations,
|
|
144
|
+
},
|
|
145
|
+
nextSearchStart,
|
|
146
|
+
replacementsApplied: matchesToApply.length,
|
|
147
|
+
updatedAnnotationCount,
|
|
148
|
+
deletedAnnotationCount,
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=replace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/replace.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAe,EACf,UAAkB,EACqB,EAAE;IACzC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAA0C,EAAE,CAAC;IAC1D,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,OAAO,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACrD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM;QACR,CAAC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,KAAK;YACL,GAAG,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM;SAC/B,CAAC,CAAC;QACH,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC;IACxC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,QAA4E,EAC5E,UAAkB,EACG,EAAE;IACvB,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAClC,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;QAChF,GAAG,KAAK;QACR,KAAK,EAAE,KAAK,EAAE;QACd,sBAAsB,EAAE,YAAY;QACpC,WAAW,EAAE,OAAO,CAAC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,CAAC,sBAAsB,CAAC;QACrE,eAAe,GAAG,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC;QACjD,eAAe,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP,GAAG,OAAO;YACV,OAAO;YACP,WAAW;SACZ;QACD,eAAe;QACf,mBAAmB,EAAE,cAAc,CAAC,MAAM;QAC1C,sBAAsB;QACtB,sBAAsB;KACvB,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/storage.d.ts
ADDED
package/lib/storage.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const uploadToStorage = async ({ client, bucket, path, file, }) => {
|
|
2
|
+
const { error } = await client.storage.from(bucket).upload(path, file);
|
|
3
|
+
if (error) {
|
|
4
|
+
console.error('Error uploading to storage:', error);
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const { data } = client.storage.from(bucket).getPublicUrl(path);
|
|
8
|
+
return data.publicUrl;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/storage.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,MAAM,EACN,MAAM,EACN,IAAI,EACJ,IAAI,GAML,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEvE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAChE,OAAO,IAAI,CAAC,SAAS,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TohokuCatalogEntry } from './toh';
|
|
2
|
+
export type AlignmentDTO = {
|
|
3
|
+
passage_uuid: string;
|
|
4
|
+
folio_uuid: string;
|
|
5
|
+
toh: TohokuCatalogEntry;
|
|
6
|
+
tibetan: string;
|
|
7
|
+
folio_number: number;
|
|
8
|
+
volume_number: number;
|
|
9
|
+
};
|
|
10
|
+
export type Alignment = {
|
|
11
|
+
folioUuid: string;
|
|
12
|
+
toh: TohokuCatalogEntry;
|
|
13
|
+
tibetan: string;
|
|
14
|
+
folioNumber: number;
|
|
15
|
+
volumeNumber: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const alignmentFromDTO: (dto: AlignmentDTO) => Alignment;
|
|
18
|
+
export declare const alignmentsFromDTO: (dtos: AlignmentDTO[]) => Alignment[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const alignmentFromDTO = (dto) => {
|
|
2
|
+
return {
|
|
3
|
+
folioUuid: dto.folio_uuid,
|
|
4
|
+
toh: dto.toh,
|
|
5
|
+
tibetan: dto.tibetan,
|
|
6
|
+
folioNumber: dto.folio_number,
|
|
7
|
+
volumeNumber: dto.volume_number,
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export const alignmentsFromDTO = (dtos) => {
|
|
11
|
+
return dtos.map(alignmentFromDTO);
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=alignment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alignment.js","sourceRoot":"","sources":["../../../../../libs/data-access/src/lib/types/alignment.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAiB,EAAa,EAAE;IAC/D,OAAO;QACL,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,YAAY,EAAE,GAAG,CAAC,aAAa;KAChC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAoB,EAAe,EAAE;IACrE,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { baseAnnotationFromDTO, baseAnnotationToDto, } from './annotation';
|
|
2
|
+
export const transformer = (dto) => {
|
|
3
|
+
const baseAnnotation = baseAnnotationFromDTO(dto);
|
|
4
|
+
const abbreviation = baseAnnotation;
|
|
5
|
+
dto.content.forEach((content) => {
|
|
6
|
+
if (content.uuid) {
|
|
7
|
+
abbreviation.abbreviation = content.uuid;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
return abbreviation;
|
|
11
|
+
};
|
|
12
|
+
export const exporter = (annotation) => {
|
|
13
|
+
const { abbreviation: uuid } = annotation;
|
|
14
|
+
const dto = baseAnnotationToDto(annotation);
|
|
15
|
+
dto.content.push({
|
|
16
|
+
uuid,
|
|
17
|
+
});
|
|
18
|
+
return dto;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=abbreviation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abbreviation.js","sourceRoot":"","sources":["../../../../../../libs/data-access/src/lib/types/annotation/abbreviation.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,WAAW,GAA0B,CAChD,GAAG,EACqB,EAAE;IAC1B,MAAM,cAAc,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,cAAwC,CAAC;IAC9D,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,YAAY,CAAC,YAAY,GAAG,OAAO,CAAC,IAAc,CAAC;QACrD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAuB,CAAC,UAAU,EAAiB,EAAE;IACxE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,UAAoC,CAAC;IACpE,MAAM,GAAG,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;QACf,IAAI;KACmB,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TohokuCatalogEntry } from '../toh';
|
|
2
|
+
export type AnnotationDTOType = 'abbreviation' | 'audio' | 'blockquote' | 'code' | 'deprecated-internal-link' | 'end-note-link' | 'glossary-instance' | 'has-abbreviation' | 'heading' | 'image' | 'indent' | 'inline-title' | 'internal-link' | 'leading-space' | 'line' | 'line-group' | 'link' | 'list' | 'list-item' | 'mantra' | 'mention' | 'paragraph' | 'quote' | 'quoted' | 'reference' | 'span' | 'table' | 'table-body-data' | 'table-body-header' | 'table-body-row' | 'trailer' | 'unknown';
|
|
3
|
+
export type AnnotationType = 'abbreviation' | 'audio' | 'blockquote' | 'code' | 'deprecated' | 'endNoteLink' | 'glossaryInstance' | 'hasAbbreviation' | 'heading' | 'image' | 'indent' | 'inlineTitle' | 'internalLink' | 'leadingSpace' | 'line' | 'lineGroup' | 'link' | 'list' | 'listItem' | 'mantra' | 'mention' | 'paragraph' | 'quote' | 'quoted' | 'reference' | 'span' | 'table' | 'tableBodyData' | 'tableBodyHeader' | 'tableBodyRow' | 'trailer' | 'unknown';
|
|
4
|
+
export declare const ANNOTATION_TYPE_DTO_TO_TYPE: Record<AnnotationDTOType, AnnotationType>;
|
|
5
|
+
export declare const annotationTypeFromDTO: (type: AnnotationDTOType) => AnnotationType;
|
|
6
|
+
export declare const ANNOTATION_TYPE_TO_DTO: Record<AnnotationType, AnnotationDTOType>;
|
|
7
|
+
export type AnnotationDTOContentKey = 'authority' | 'endnote_xmlId' | 'glossary_xmlId' | 'heading-level' | 'heading-type' | 'href' | 'label' | 'lang' | 'link-text' | 'link-text-lookup' | 'link-type' | 'list-item-style' | 'list-spacing' | 'media-type' | 'nesting' | 'paragraph' | 'quote_xmlId' | 'src' | 'text-style' | 'text' | 'type' | 'title' | 'uuid' | 'same_work' | 'subtype' | 'toh';
|
|
8
|
+
export type AnnotationDTOContent = Partial<Record<AnnotationDTOContentKey, unknown>>;
|
|
9
|
+
export type AnnotationDTO = {
|
|
10
|
+
content: AnnotationDTOContent[];
|
|
11
|
+
end: number;
|
|
12
|
+
start: number;
|
|
13
|
+
type: AnnotationDTOType;
|
|
14
|
+
uuid: string;
|
|
15
|
+
passage_uuid?: string;
|
|
16
|
+
passageUuid?: string;
|
|
17
|
+
toh?: TohokuCatalogEntry;
|
|
18
|
+
};
|
|
19
|
+
export type AnnotationsDTO = AnnotationDTO[];
|
|
20
|
+
export declare const annotationTypeToDTO: (type: AnnotationType) => AnnotationDTOType;
|
|
21
|
+
export declare const ANNOTATIONS_TO_IGNORE: AnnotationDTOType[];
|
|
22
|
+
export type AnnotationsToIgnore = (typeof ANNOTATIONS_TO_IGNORE)[number];
|
|
23
|
+
export type AnnotationBase = {
|
|
24
|
+
end: number;
|
|
25
|
+
start: number;
|
|
26
|
+
type: AnnotationType;
|
|
27
|
+
uuid: string;
|
|
28
|
+
passageUuid: string;
|
|
29
|
+
validated?: boolean;
|
|
30
|
+
toh?: TohokuCatalogEntry;
|
|
31
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const ANNOTATION_TYPE_DTO_TO_TYPE = {
|
|
2
|
+
abbreviation: 'abbreviation',
|
|
3
|
+
audio: 'audio',
|
|
4
|
+
blockquote: 'blockquote',
|
|
5
|
+
code: 'code',
|
|
6
|
+
'deprecated-internal-link': 'deprecated',
|
|
7
|
+
'end-note-link': 'endNoteLink',
|
|
8
|
+
'glossary-instance': 'glossaryInstance',
|
|
9
|
+
'has-abbreviation': 'hasAbbreviation',
|
|
10
|
+
heading: 'heading',
|
|
11
|
+
image: 'image',
|
|
12
|
+
indent: 'indent',
|
|
13
|
+
'inline-title': 'inlineTitle',
|
|
14
|
+
'internal-link': 'internalLink',
|
|
15
|
+
'leading-space': 'leadingSpace',
|
|
16
|
+
line: 'line',
|
|
17
|
+
'line-group': 'lineGroup',
|
|
18
|
+
link: 'link',
|
|
19
|
+
list: 'list',
|
|
20
|
+
'list-item': 'listItem',
|
|
21
|
+
mantra: 'mantra',
|
|
22
|
+
mention: 'mention',
|
|
23
|
+
paragraph: 'paragraph',
|
|
24
|
+
quote: 'quote',
|
|
25
|
+
quoted: 'quoted',
|
|
26
|
+
reference: 'reference',
|
|
27
|
+
span: 'span',
|
|
28
|
+
table: 'table',
|
|
29
|
+
'table-body-data': 'tableBodyData',
|
|
30
|
+
'table-body-header': 'tableBodyHeader',
|
|
31
|
+
'table-body-row': 'tableBodyRow',
|
|
32
|
+
trailer: 'trailer',
|
|
33
|
+
unknown: 'unknown',
|
|
34
|
+
};
|
|
35
|
+
export const annotationTypeFromDTO = (type) => {
|
|
36
|
+
return ANNOTATION_TYPE_DTO_TO_TYPE[type] || 'unknown';
|
|
37
|
+
};
|
|
38
|
+
export const ANNOTATION_TYPE_TO_DTO = {
|
|
39
|
+
abbreviation: 'abbreviation',
|
|
40
|
+
audio: 'audio',
|
|
41
|
+
blockquote: 'blockquote',
|
|
42
|
+
code: 'code',
|
|
43
|
+
deprecated: 'deprecated-internal-link',
|
|
44
|
+
endNoteLink: 'end-note-link',
|
|
45
|
+
glossaryInstance: 'glossary-instance',
|
|
46
|
+
hasAbbreviation: 'has-abbreviation',
|
|
47
|
+
heading: 'heading',
|
|
48
|
+
image: 'image',
|
|
49
|
+
indent: 'indent',
|
|
50
|
+
inlineTitle: 'inline-title',
|
|
51
|
+
internalLink: 'internal-link',
|
|
52
|
+
leadingSpace: 'leading-space',
|
|
53
|
+
line: 'line',
|
|
54
|
+
lineGroup: 'line-group',
|
|
55
|
+
link: 'link',
|
|
56
|
+
list: 'list',
|
|
57
|
+
listItem: 'list-item',
|
|
58
|
+
mantra: 'mantra',
|
|
59
|
+
mention: 'mention',
|
|
60
|
+
paragraph: 'paragraph',
|
|
61
|
+
quote: 'quote',
|
|
62
|
+
quoted: 'quoted',
|
|
63
|
+
reference: 'reference',
|
|
64
|
+
span: 'span',
|
|
65
|
+
table: 'table',
|
|
66
|
+
tableBodyData: 'table-body-data',
|
|
67
|
+
tableBodyHeader: 'table-body-header',
|
|
68
|
+
tableBodyRow: 'table-body-row',
|
|
69
|
+
trailer: 'trailer',
|
|
70
|
+
unknown: 'unknown',
|
|
71
|
+
};
|
|
72
|
+
export const annotationTypeToDTO = (type) => {
|
|
73
|
+
return ANNOTATION_TYPE_TO_DTO[type] || 'unknown';
|
|
74
|
+
};
|
|
75
|
+
export const ANNOTATIONS_TO_IGNORE = [
|
|
76
|
+
'deprecated-internal-link',
|
|
77
|
+
'quoted',
|
|
78
|
+
'reference',
|
|
79
|
+
'unknown',
|
|
80
|
+
];
|
|
81
|
+
//# sourceMappingURL=annotation-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-type.js","sourceRoot":"","sources":["../../../../../../libs/data-access/src/lib/types/annotation/annotation-type.ts"],"names":[],"mappings":"AAsEA,MAAM,CAAC,MAAM,2BAA2B,GAGpC;IACF,YAAY,EAAE,cAAc;IAC5B,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;IACZ,0BAA0B,EA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