@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
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
import { DataClient, Passage, PassageDTO, passageFromDTO } from '../types';
|
|
2
|
-
|
|
3
|
-
type ApiPaginationDirection = 'FORWARD' | 'BACKWARD' | 'AROUND';
|
|
4
|
-
|
|
5
|
-
type GlossaryTermNode = {
|
|
6
|
-
uuid: string;
|
|
7
|
-
authority: string;
|
|
8
|
-
definition: string | null;
|
|
9
|
-
termNumber: number;
|
|
10
|
-
names: {
|
|
11
|
-
english: string | null;
|
|
12
|
-
tibetan: string | null;
|
|
13
|
-
sanskrit: string | null;
|
|
14
|
-
pali: string | null;
|
|
15
|
-
chinese: string | null;
|
|
16
|
-
wylie: string | null;
|
|
17
|
-
alternatives: string | null;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type GlossaryTermIndexRow = {
|
|
22
|
-
glossary_uuid: string;
|
|
23
|
-
authority_uuid: string;
|
|
24
|
-
term_number: number | string;
|
|
25
|
-
definition: string | null;
|
|
26
|
-
english: string | null;
|
|
27
|
-
wylie: string | null;
|
|
28
|
-
tibetan: string | null;
|
|
29
|
-
sanskrit_plain: string | null;
|
|
30
|
-
sanskrit_attested: string | null;
|
|
31
|
-
chinese: string | null;
|
|
32
|
-
pali: string | null;
|
|
33
|
-
alternatives: string | null;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type GlossaryPageInfo = {
|
|
37
|
-
nextCursor: string | null;
|
|
38
|
-
prevCursor: string | null;
|
|
39
|
-
hasMoreAfter: boolean;
|
|
40
|
-
hasMoreBefore: boolean;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type GlossaryTermConnection = {
|
|
44
|
-
nodes: GlossaryTermNode[];
|
|
45
|
-
pageInfo: GlossaryPageInfo;
|
|
46
|
-
totalCount: number;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type GlossaryPassagesPage = {
|
|
50
|
-
items: Passage[];
|
|
51
|
-
nextCursor: string | null;
|
|
52
|
-
hasMore: boolean;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const DEFAULT_GLOSSARY_LIMIT = 50;
|
|
56
|
-
const MAX_GLOSSARY_LIMIT = 200;
|
|
57
|
-
const DEFAULT_GLOSSARY_PASSAGES_LIMIT = 10;
|
|
58
|
-
|
|
59
|
-
function buildGlossaryTermConnection(
|
|
60
|
-
nodes: GlossaryTermNode[],
|
|
61
|
-
nextCursor: string | null,
|
|
62
|
-
prevCursor: string | null,
|
|
63
|
-
hasMoreAfter: boolean,
|
|
64
|
-
hasMoreBefore: boolean,
|
|
65
|
-
totalCount: number,
|
|
66
|
-
): GlossaryTermConnection {
|
|
67
|
-
return {
|
|
68
|
-
nodes,
|
|
69
|
-
pageInfo: {
|
|
70
|
-
nextCursor,
|
|
71
|
-
prevCursor,
|
|
72
|
-
hasMoreAfter,
|
|
73
|
-
hasMoreBefore,
|
|
74
|
-
},
|
|
75
|
-
totalCount,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function parseOffsetCursor(after?: string) {
|
|
80
|
-
if (!after) return 0;
|
|
81
|
-
|
|
82
|
-
const parsed = Number.parseInt(after, 10);
|
|
83
|
-
return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function parseCount(value: number | string | null | undefined) {
|
|
87
|
-
if (typeof value === 'number') return value;
|
|
88
|
-
|
|
89
|
-
const parsed = Number.parseInt(value ?? '', 10);
|
|
90
|
-
return Number.isFinite(parsed) ? parsed : 0;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function rowToGlossaryTermNode(
|
|
94
|
-
row: Pick<
|
|
95
|
-
GlossaryTermIndexRow,
|
|
96
|
-
| 'glossary_uuid'
|
|
97
|
-
| 'authority_uuid'
|
|
98
|
-
| 'definition'
|
|
99
|
-
| 'term_number'
|
|
100
|
-
| 'english'
|
|
101
|
-
| 'wylie'
|
|
102
|
-
| 'tibetan'
|
|
103
|
-
| 'sanskrit_plain'
|
|
104
|
-
| 'sanskrit_attested'
|
|
105
|
-
| 'chinese'
|
|
106
|
-
| 'pali'
|
|
107
|
-
| 'alternatives'
|
|
108
|
-
> & { withAttestations: boolean },
|
|
109
|
-
): GlossaryTermNode {
|
|
110
|
-
return {
|
|
111
|
-
uuid: row.glossary_uuid,
|
|
112
|
-
authority: row.authority_uuid,
|
|
113
|
-
definition: row.definition,
|
|
114
|
-
termNumber: parseCount(row.term_number),
|
|
115
|
-
names: {
|
|
116
|
-
english: row.english,
|
|
117
|
-
alternatives: row.alternatives,
|
|
118
|
-
wylie: row.wylie,
|
|
119
|
-
tibetan: row.tibetan,
|
|
120
|
-
sanskrit: row.withAttestations
|
|
121
|
-
? row.sanskrit_attested
|
|
122
|
-
: row.sanskrit_plain,
|
|
123
|
-
chinese: row.chinese,
|
|
124
|
-
pali: row.pali,
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export const getGlossaryTermPassagesPage = async ({
|
|
130
|
-
client,
|
|
131
|
-
uuid,
|
|
132
|
-
first,
|
|
133
|
-
after,
|
|
134
|
-
}: {
|
|
135
|
-
client: DataClient;
|
|
136
|
-
uuid: string;
|
|
137
|
-
first?: number;
|
|
138
|
-
after?: string;
|
|
139
|
-
}): Promise<GlossaryPassagesPage> => {
|
|
140
|
-
const limit = Math.max(first ?? DEFAULT_GLOSSARY_PASSAGES_LIMIT, 1);
|
|
141
|
-
const offset = parseOffsetCursor(after);
|
|
142
|
-
|
|
143
|
-
const { data: annotations, error: annotationsError } = await client
|
|
144
|
-
.from('passage_annotations')
|
|
145
|
-
.select('passage_uuid')
|
|
146
|
-
.eq('type', 'glossary-instance')
|
|
147
|
-
.filter('content', 'cs', JSON.stringify([{ uuid }]));
|
|
148
|
-
|
|
149
|
-
if (annotationsError) {
|
|
150
|
-
console.error(
|
|
151
|
-
'Error fetching glossary passage annotations:',
|
|
152
|
-
annotationsError,
|
|
153
|
-
);
|
|
154
|
-
return { items: [], nextCursor: null, hasMore: false };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const passageUuids = (annotations ?? []).map(
|
|
158
|
-
(annotation: { passage_uuid: string }) => annotation.passage_uuid,
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
if (passageUuids.length === 0) {
|
|
162
|
-
return { items: [], nextCursor: null, hasMore: false };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const { data: passages, error: passagesError } = await client
|
|
166
|
-
.from('passages')
|
|
167
|
-
.select('uuid, content, label, sort, type, xmlId, work_uuid, toh')
|
|
168
|
-
.in('uuid', passageUuids)
|
|
169
|
-
.order('sort', { ascending: true })
|
|
170
|
-
.range(offset, offset + limit);
|
|
171
|
-
|
|
172
|
-
if (passagesError) {
|
|
173
|
-
console.error('Error fetching glossary passages:', passagesError);
|
|
174
|
-
return { items: [], nextCursor: null, hasMore: false };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const rows = passages ?? [];
|
|
178
|
-
const hasMore = rows.length > limit;
|
|
179
|
-
const items = hasMore ? rows.slice(0, limit) : rows;
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
items: items.map((passage: PassageDTO) => passageFromDTO(passage)),
|
|
183
|
-
nextCursor: hasMore ? String(offset + limit) : null,
|
|
184
|
-
hasMore,
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export const getWorkGlossaryTermsPage = async ({
|
|
189
|
-
client,
|
|
190
|
-
workUuid,
|
|
191
|
-
limit = DEFAULT_GLOSSARY_LIMIT,
|
|
192
|
-
cursor,
|
|
193
|
-
direction = 'FORWARD',
|
|
194
|
-
withAttestations = false,
|
|
195
|
-
}: {
|
|
196
|
-
client: DataClient;
|
|
197
|
-
workUuid: string;
|
|
198
|
-
limit?: number;
|
|
199
|
-
cursor?: string | null;
|
|
200
|
-
direction?: ApiPaginationDirection;
|
|
201
|
-
withAttestations?: boolean;
|
|
202
|
-
}): Promise<GlossaryTermConnection> => {
|
|
203
|
-
const clampedLimit = Math.min(Math.max(limit, 1), MAX_GLOSSARY_LIMIT);
|
|
204
|
-
|
|
205
|
-
if (direction === 'AROUND') {
|
|
206
|
-
return getWorkGlossaryTermsAround({
|
|
207
|
-
client,
|
|
208
|
-
workUuid,
|
|
209
|
-
limit: clampedLimit,
|
|
210
|
-
cursor,
|
|
211
|
-
withAttestations,
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const [
|
|
216
|
-
{ count, error: countError },
|
|
217
|
-
{ data: cursorRows, error: cursorError },
|
|
218
|
-
] = await Promise.all([
|
|
219
|
-
client
|
|
220
|
-
.from('glossary_term_index')
|
|
221
|
-
.select('authority_uuid', { count: 'exact', head: true })
|
|
222
|
-
.eq('work_uuid', workUuid),
|
|
223
|
-
cursor
|
|
224
|
-
? client
|
|
225
|
-
.from('glossary_term_index')
|
|
226
|
-
.select('authority_uuid, term_number')
|
|
227
|
-
.eq('work_uuid', workUuid)
|
|
228
|
-
.eq('authority_uuid', cursor)
|
|
229
|
-
.limit(1)
|
|
230
|
-
: Promise.resolve({ data: [], error: null }),
|
|
231
|
-
]);
|
|
232
|
-
|
|
233
|
-
if (countError) {
|
|
234
|
-
console.error('Error counting glossary terms:', countError);
|
|
235
|
-
return buildGlossaryTermConnection([], null, null, false, false, 0);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (cursorError) {
|
|
239
|
-
console.error('Error fetching glossary cursor term:', cursorError);
|
|
240
|
-
return buildGlossaryTermConnection([], null, null, false, false, 0);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const totalCount = count ?? 0;
|
|
244
|
-
if (totalCount === 0) {
|
|
245
|
-
return buildGlossaryTermConnection([], null, null, false, false, 0);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const cursorRow = cursor
|
|
249
|
-
? ((cursorRows ?? [])[0] as
|
|
250
|
-
| { authority_uuid: string; term_number: number | string }
|
|
251
|
-
| undefined)
|
|
252
|
-
: undefined;
|
|
253
|
-
|
|
254
|
-
if (cursor && !cursorRow) {
|
|
255
|
-
return buildGlossaryTermConnection(
|
|
256
|
-
[],
|
|
257
|
-
null,
|
|
258
|
-
null,
|
|
259
|
-
false,
|
|
260
|
-
false,
|
|
261
|
-
totalCount,
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const cursorTermNumber =
|
|
266
|
-
cursorRow !== undefined ? parseCount(cursorRow.term_number) : null;
|
|
267
|
-
let query = client
|
|
268
|
-
.from('glossary_term_index')
|
|
269
|
-
.select(
|
|
270
|
-
`glossary_uuid,
|
|
271
|
-
authority_uuid,
|
|
272
|
-
term_number,
|
|
273
|
-
definition,
|
|
274
|
-
english,
|
|
275
|
-
wylie,
|
|
276
|
-
tibetan,
|
|
277
|
-
sanskrit_plain,
|
|
278
|
-
sanskrit_attested,
|
|
279
|
-
chinese,
|
|
280
|
-
pali,
|
|
281
|
-
alternatives`,
|
|
282
|
-
)
|
|
283
|
-
.eq('work_uuid', workUuid);
|
|
284
|
-
|
|
285
|
-
if (cursorTermNumber !== null) {
|
|
286
|
-
query =
|
|
287
|
-
direction === 'FORWARD'
|
|
288
|
-
? query.gt('term_number', cursorTermNumber)
|
|
289
|
-
: query.lt('term_number', cursorTermNumber);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const ascending = direction === 'FORWARD';
|
|
293
|
-
const { data, error } = await query
|
|
294
|
-
.order('term_number', { ascending })
|
|
295
|
-
.limit(clampedLimit);
|
|
296
|
-
|
|
297
|
-
if (error) {
|
|
298
|
-
console.error('Error fetching paginated glossary terms:', error);
|
|
299
|
-
return buildGlossaryTermConnection(
|
|
300
|
-
[],
|
|
301
|
-
null,
|
|
302
|
-
null,
|
|
303
|
-
false,
|
|
304
|
-
false,
|
|
305
|
-
totalCount,
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
const pageRows = (data ?? []) as GlossaryTermIndexRow[];
|
|
310
|
-
const rows = ascending ? pageRows : [...pageRows].reverse();
|
|
311
|
-
if (rows.length === 0) {
|
|
312
|
-
return buildGlossaryTermConnection(
|
|
313
|
-
[],
|
|
314
|
-
null,
|
|
315
|
-
null,
|
|
316
|
-
false,
|
|
317
|
-
false,
|
|
318
|
-
totalCount,
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const nodes = rows.map((row) =>
|
|
323
|
-
rowToGlossaryTermNode({ ...row, withAttestations }),
|
|
324
|
-
);
|
|
325
|
-
const firstRow = rows[0];
|
|
326
|
-
const lastRow = rows[rows.length - 1];
|
|
327
|
-
const hasMoreBefore = parseCount(firstRow.term_number) > 1;
|
|
328
|
-
const hasMoreAfter = parseCount(lastRow.term_number) < totalCount;
|
|
329
|
-
|
|
330
|
-
return buildGlossaryTermConnection(
|
|
331
|
-
nodes,
|
|
332
|
-
hasMoreAfter ? lastRow.authority_uuid : null,
|
|
333
|
-
hasMoreBefore ? firstRow.authority_uuid : null,
|
|
334
|
-
hasMoreAfter,
|
|
335
|
-
hasMoreBefore,
|
|
336
|
-
totalCount,
|
|
337
|
-
);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
export const getWorkGlossaryTermsAround = async ({
|
|
341
|
-
client,
|
|
342
|
-
workUuid,
|
|
343
|
-
limit,
|
|
344
|
-
cursor,
|
|
345
|
-
withAttestations,
|
|
346
|
-
}: {
|
|
347
|
-
client: DataClient;
|
|
348
|
-
workUuid: string;
|
|
349
|
-
limit: number;
|
|
350
|
-
cursor?: string | null;
|
|
351
|
-
withAttestations: boolean;
|
|
352
|
-
}): Promise<GlossaryTermConnection> => {
|
|
353
|
-
if (!cursor) {
|
|
354
|
-
return getWorkGlossaryTermsPage({
|
|
355
|
-
client,
|
|
356
|
-
workUuid,
|
|
357
|
-
limit,
|
|
358
|
-
cursor: null,
|
|
359
|
-
direction: 'FORWARD',
|
|
360
|
-
withAttestations,
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
const [
|
|
365
|
-
{ count, error: countError },
|
|
366
|
-
{ data: cursorRows, error: cursorError },
|
|
367
|
-
] = await Promise.all([
|
|
368
|
-
client
|
|
369
|
-
.from('glossary_term_index')
|
|
370
|
-
.select('authority_uuid', { count: 'exact', head: true })
|
|
371
|
-
.eq('work_uuid', workUuid),
|
|
372
|
-
client
|
|
373
|
-
.from('glossary_term_index')
|
|
374
|
-
.select('authority_uuid, term_number')
|
|
375
|
-
.eq('work_uuid', workUuid)
|
|
376
|
-
.eq('authority_uuid', cursor)
|
|
377
|
-
.limit(1),
|
|
378
|
-
]);
|
|
379
|
-
|
|
380
|
-
if (countError) {
|
|
381
|
-
console.error('Error counting glossary terms:', countError);
|
|
382
|
-
return buildGlossaryTermConnection([], null, null, false, false, 0);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (cursorError) {
|
|
386
|
-
console.error('Error fetching glossary cursor term:', cursorError);
|
|
387
|
-
return getWorkGlossaryTermsPage({
|
|
388
|
-
client,
|
|
389
|
-
workUuid,
|
|
390
|
-
limit,
|
|
391
|
-
cursor: null,
|
|
392
|
-
direction: 'FORWARD',
|
|
393
|
-
withAttestations,
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const totalCount = count ?? 0;
|
|
398
|
-
const cursorRow = (cursorRows ?? [])[0] as
|
|
399
|
-
| { authority_uuid: string; term_number: number | string }
|
|
400
|
-
| undefined;
|
|
401
|
-
|
|
402
|
-
if (!cursorRow) {
|
|
403
|
-
return getWorkGlossaryTermsPage({
|
|
404
|
-
client,
|
|
405
|
-
workUuid,
|
|
406
|
-
limit,
|
|
407
|
-
cursor: null,
|
|
408
|
-
direction: 'FORWARD',
|
|
409
|
-
withAttestations,
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const cursorTermNumber = parseCount(cursorRow.term_number);
|
|
414
|
-
let startTerm = Math.max(1, cursorTermNumber - Math.floor(limit / 2));
|
|
415
|
-
let endTerm = startTerm + limit - 1;
|
|
416
|
-
|
|
417
|
-
if (endTerm > totalCount) {
|
|
418
|
-
endTerm = totalCount;
|
|
419
|
-
startTerm = Math.max(1, endTerm - limit + 1);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
const { data, error } = await client
|
|
423
|
-
.from('glossary_term_index')
|
|
424
|
-
.select(
|
|
425
|
-
`glossary_uuid,
|
|
426
|
-
authority_uuid,
|
|
427
|
-
term_number,
|
|
428
|
-
definition,
|
|
429
|
-
english,
|
|
430
|
-
wylie,
|
|
431
|
-
tibetan,
|
|
432
|
-
sanskrit_plain,
|
|
433
|
-
sanskrit_attested,
|
|
434
|
-
chinese,
|
|
435
|
-
pali`,
|
|
436
|
-
)
|
|
437
|
-
.eq('work_uuid', workUuid)
|
|
438
|
-
.gte('term_number', startTerm)
|
|
439
|
-
.lte('term_number', endTerm)
|
|
440
|
-
.order('term_number', { ascending: true });
|
|
441
|
-
|
|
442
|
-
if (error) {
|
|
443
|
-
console.error('Error fetching glossary terms around cursor:', error);
|
|
444
|
-
return buildGlossaryTermConnection(
|
|
445
|
-
[],
|
|
446
|
-
null,
|
|
447
|
-
null,
|
|
448
|
-
false,
|
|
449
|
-
false,
|
|
450
|
-
totalCount,
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
const rows = (data ?? []) as GlossaryTermIndexRow[];
|
|
455
|
-
const nodes = rows.map((row) =>
|
|
456
|
-
rowToGlossaryTermNode({ ...row, withAttestations }),
|
|
457
|
-
);
|
|
458
|
-
const hasMoreBefore = startTerm > 1;
|
|
459
|
-
const hasMoreAfter = endTerm < totalCount;
|
|
460
|
-
const firstRow = rows[0];
|
|
461
|
-
const lastRow = rows[rows.length - 1];
|
|
462
|
-
|
|
463
|
-
return buildGlossaryTermConnection(
|
|
464
|
-
nodes,
|
|
465
|
-
hasMoreAfter && lastRow ? lastRow.authority_uuid : null,
|
|
466
|
-
hasMoreBefore && firstRow ? firstRow.authority_uuid : null,
|
|
467
|
-
hasMoreAfter,
|
|
468
|
-
hasMoreBefore,
|
|
469
|
-
totalCount,
|
|
470
|
-
);
|
|
471
|
-
};
|
package/src/lib/imprint.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { DataClient, imprintFromDTO, tocFromDTO } from './types';
|
|
2
|
-
|
|
3
|
-
export const getTranslationToc = async ({
|
|
4
|
-
client,
|
|
5
|
-
uuid,
|
|
6
|
-
}: {
|
|
7
|
-
client: DataClient;
|
|
8
|
-
uuid: string;
|
|
9
|
-
}) => {
|
|
10
|
-
const { data, error } = await client.rpc('get_work_toc', {
|
|
11
|
-
work_uuid_input: uuid,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (error) {
|
|
15
|
-
console.error('Error fetching TOC:', error);
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return tocFromDTO(data || []);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const getTranslationImprint = async ({
|
|
23
|
-
client,
|
|
24
|
-
uuid,
|
|
25
|
-
toh,
|
|
26
|
-
}: {
|
|
27
|
-
client: DataClient;
|
|
28
|
-
uuid: string;
|
|
29
|
-
toh: string;
|
|
30
|
-
}) => {
|
|
31
|
-
const { data, error } = await client.rpc('get_imprint', {
|
|
32
|
-
work_uuid: uuid,
|
|
33
|
-
toh,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (error || !data) {
|
|
37
|
-
console.error('Error fetching imprint:', error);
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return imprintFromDTO(data);
|
|
42
|
-
};
|
package/src/lib/library.ts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DataClient,
|
|
3
|
-
LibraryItemType,
|
|
4
|
-
UserLibraryItem,
|
|
5
|
-
UserPassageItem,
|
|
6
|
-
} from './types';
|
|
7
|
-
|
|
8
|
-
export const updateUserProfile = async ({
|
|
9
|
-
client,
|
|
10
|
-
userId,
|
|
11
|
-
avatar,
|
|
12
|
-
name,
|
|
13
|
-
username,
|
|
14
|
-
subscriptions,
|
|
15
|
-
}: {
|
|
16
|
-
client: DataClient;
|
|
17
|
-
userId: string;
|
|
18
|
-
subscriptions: string[];
|
|
19
|
-
avatar?: string;
|
|
20
|
-
name?: string;
|
|
21
|
-
username?: string;
|
|
22
|
-
}): Promise<boolean> => {
|
|
23
|
-
const { error } = await client
|
|
24
|
-
.from('user_profiles')
|
|
25
|
-
.update({
|
|
26
|
-
avatar_url: avatar,
|
|
27
|
-
full_name: name,
|
|
28
|
-
username: username,
|
|
29
|
-
subscriptions,
|
|
30
|
-
updated_at: new Date().toISOString(),
|
|
31
|
-
})
|
|
32
|
-
.eq('id', userId);
|
|
33
|
-
|
|
34
|
-
if (error) {
|
|
35
|
-
console.error('Error updating user subscriptions:', error);
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return true;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const getUserLibrary = async ({
|
|
43
|
-
client,
|
|
44
|
-
userId,
|
|
45
|
-
}: {
|
|
46
|
-
client: DataClient;
|
|
47
|
-
userId: string;
|
|
48
|
-
}): Promise<UserLibraryItem[]> => {
|
|
49
|
-
const { data, error } = await client
|
|
50
|
-
.from('user_libraries')
|
|
51
|
-
.select(
|
|
52
|
-
`
|
|
53
|
-
uuid:entity_id::uuid,
|
|
54
|
-
type:entity_type::text,
|
|
55
|
-
createdAt:created_at::text,
|
|
56
|
-
featured::bool
|
|
57
|
-
`,
|
|
58
|
-
)
|
|
59
|
-
.eq('user_id', userId);
|
|
60
|
-
|
|
61
|
-
if (error) {
|
|
62
|
-
console.error('Error fetching user library:', error);
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (data || []) as UserLibraryItem[];
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const addUserLibraryItem = async ({
|
|
70
|
-
client,
|
|
71
|
-
userId,
|
|
72
|
-
type,
|
|
73
|
-
entityId,
|
|
74
|
-
}: {
|
|
75
|
-
client: DataClient;
|
|
76
|
-
userId: string;
|
|
77
|
-
type: LibraryItemType;
|
|
78
|
-
entityId: string;
|
|
79
|
-
}): Promise<boolean> => {
|
|
80
|
-
const { error } = await client.from('user_libraries').insert({
|
|
81
|
-
user_id: userId,
|
|
82
|
-
entity_id: entityId,
|
|
83
|
-
entity_type: type,
|
|
84
|
-
featured: true,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (error) {
|
|
88
|
-
console.error('Error adding to user library:', error);
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return true;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const removeUserLibraryItem = async ({
|
|
96
|
-
client,
|
|
97
|
-
entityId,
|
|
98
|
-
}: {
|
|
99
|
-
client: DataClient;
|
|
100
|
-
entityId: string;
|
|
101
|
-
}): Promise<boolean> => {
|
|
102
|
-
const { error } = await client
|
|
103
|
-
.from('user_libraries')
|
|
104
|
-
.delete()
|
|
105
|
-
.eq('entity_id', entityId);
|
|
106
|
-
|
|
107
|
-
if (error) {
|
|
108
|
-
console.error('Error removing from user library:', error);
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return true;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const getUserBibliographies = async ({
|
|
116
|
-
client,
|
|
117
|
-
uuids,
|
|
118
|
-
}: {
|
|
119
|
-
client: DataClient;
|
|
120
|
-
uuids: string[];
|
|
121
|
-
}) => {
|
|
122
|
-
const { data, error } = await client
|
|
123
|
-
.from('bibliographies')
|
|
124
|
-
.select(
|
|
125
|
-
`
|
|
126
|
-
uuid::text,
|
|
127
|
-
toh::text,
|
|
128
|
-
text:bibl_text::text
|
|
129
|
-
`,
|
|
130
|
-
)
|
|
131
|
-
.in('uuid', uuids);
|
|
132
|
-
|
|
133
|
-
if (error) {
|
|
134
|
-
console.error('Error fetching user bibliographies:', error);
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return data || [];
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export const getUserPassages = async ({
|
|
142
|
-
client,
|
|
143
|
-
uuids,
|
|
144
|
-
}: {
|
|
145
|
-
client: DataClient;
|
|
146
|
-
uuids: string[];
|
|
147
|
-
}) => {
|
|
148
|
-
const { data, error } = await client
|
|
149
|
-
.from('passages')
|
|
150
|
-
.select(
|
|
151
|
-
`
|
|
152
|
-
uuid::text,
|
|
153
|
-
content::text,
|
|
154
|
-
label::text,
|
|
155
|
-
work:works(
|
|
156
|
-
toh::text,
|
|
157
|
-
uuid::text
|
|
158
|
-
)
|
|
159
|
-
`,
|
|
160
|
-
)
|
|
161
|
-
.in('uuid', uuids);
|
|
162
|
-
if (error) {
|
|
163
|
-
console.error('Error fetching user passages:', error);
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// NOTE: Supabase incorrectly infers `work` as an array. We have to jump
|
|
168
|
-
// though the hoop of casting to inknown first.
|
|
169
|
-
return (data || []) as unknown as UserPassageItem[];
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export const getUserPublications = async ({
|
|
173
|
-
client,
|
|
174
|
-
uuids,
|
|
175
|
-
}: {
|
|
176
|
-
client: DataClient;
|
|
177
|
-
uuids: string[];
|
|
178
|
-
}) => {
|
|
179
|
-
const { data, error } = await client
|
|
180
|
-
.from('works')
|
|
181
|
-
.select(
|
|
182
|
-
`
|
|
183
|
-
uuid::text,
|
|
184
|
-
title::text,
|
|
185
|
-
toh::text,
|
|
186
|
-
titles(content::text,language::text),
|
|
187
|
-
sections:catalog_works(...catalogs(label::text))
|
|
188
|
-
`,
|
|
189
|
-
)
|
|
190
|
-
.like('titles.type', '%mainTitle')
|
|
191
|
-
.in('titles.language', ['bo', 'en'])
|
|
192
|
-
.in('uuid', uuids);
|
|
193
|
-
|
|
194
|
-
if (error) {
|
|
195
|
-
console.error('Error fetching user publications:', error);
|
|
196
|
-
return [];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return data || [];
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
export const getUserSearches = async (_: {
|
|
203
|
-
client: DataClient;
|
|
204
|
-
uuids: string[];
|
|
205
|
-
}) => {
|
|
206
|
-
// TODO: Support saving and retrieving user searches
|
|
207
|
-
console.warn('getUserSearches not implemented yet');
|
|
208
|
-
return [] as { uuid: string; name: string; query: string }[];
|
|
209
|
-
};
|