@eightyfourthousand/client-graphql 2026.3.1 → 2026.4.1
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.d.ts +4 -0
- package/index.js +7 -0
- package/index.js.map +1 -0
- package/lib/client-ssr.d.ts +16 -0
- package/lib/client-ssr.js +39 -0
- package/lib/client-ssr.js.map +1 -0
- package/lib/client.d.ts +15 -0
- package/lib/client.js +46 -0
- package/lib/client.js.map +1 -0
- package/lib/config.d.ts +8 -0
- package/lib/config.js +19 -0
- package/lib/config.js.map +1 -0
- package/lib/functions/get-bibliography-entry.d.ts +9 -0
- package/lib/functions/get-bibliography-entry.js +27 -0
- package/lib/functions/get-bibliography-entry.js.map +1 -0
- package/lib/functions/get-glossary-instance.d.ts +9 -0
- package/lib/functions/get-glossary-instance.js +36 -0
- package/lib/functions/get-glossary-instance.js.map +1 -0
- package/lib/functions/get-passage.d.ts +10 -0
- package/lib/functions/get-passage.js +68 -0
- package/lib/functions/get-passage.js.map +1 -0
- package/lib/functions/get-term-passages.d.ts +20 -0
- package/lib/functions/get-term-passages.js +32 -0
- package/lib/functions/get-term-passages.js.map +1 -0
- package/lib/functions/get-translation-blocks-around.d.ts +15 -0
- package/lib/functions/get-translation-blocks-around.js +86 -0
- package/lib/functions/get-translation-blocks-around.js.map +1 -0
- package/lib/functions/get-translation-blocks.d.ts +25 -0
- package/lib/functions/get-translation-blocks.js +96 -0
- package/lib/functions/get-translation-blocks.js.map +1 -0
- package/lib/functions/get-translation-imprint.d.ts +10 -0
- package/lib/functions/get-translation-imprint.js +68 -0
- package/lib/functions/get-translation-imprint.js.map +1 -0
- package/lib/functions/get-translation-metadata.d.ts +16 -0
- package/lib/functions/get-translation-metadata.js +72 -0
- package/lib/functions/get-translation-metadata.js.map +1 -0
- package/lib/functions/get-translation-titles.d.ts +9 -0
- package/lib/functions/get-translation-titles.js +34 -0
- package/lib/functions/get-translation-titles.js.map +1 -0
- package/lib/functions/get-translation-toc.d.ts +9 -0
- package/{src/lib/functions/get-translation-toc.ts → lib/functions/get-translation-toc.js} +18 -48
- package/lib/functions/get-translation-toc.js.map +1 -0
- package/lib/functions/get-translation-uuids.d.ts +16 -0
- package/lib/functions/get-translation-uuids.js +40 -0
- package/lib/functions/get-translation-uuids.js.map +1 -0
- package/lib/functions/get-translations-metadata.d.ts +9 -0
- package/lib/functions/get-translations-metadata.js +51 -0
- package/lib/functions/get-translations-metadata.js.map +1 -0
- package/lib/functions/get-work-bibliography.d.ts +9 -0
- package/lib/functions/get-work-bibliography.js +33 -0
- package/lib/functions/get-work-bibliography.js.map +1 -0
- package/lib/functions/get-work-folios.d.ts +12 -0
- package/lib/functions/get-work-folios.js +32 -0
- package/lib/functions/get-work-folios.js.map +1 -0
- package/lib/functions/get-work-glossary-terms-around.d.ts +13 -0
- package/lib/functions/get-work-glossary-terms-around.js +95 -0
- package/lib/functions/get-work-glossary-terms-around.js.map +1 -0
- package/lib/functions/get-work-glossary-terms.d.ts +24 -0
- package/lib/functions/get-work-glossary-terms.js +104 -0
- package/lib/functions/get-work-glossary-terms.js.map +1 -0
- package/lib/functions/has-permission.d.ts +9 -0
- package/lib/functions/has-permission.js +15 -0
- package/lib/functions/has-permission.js.map +1 -0
- package/{src/lib/functions/index.ts → lib/functions/index.d.ts} +4 -18
- package/lib/functions/index.js +20 -0
- package/lib/functions/index.js.map +1 -0
- package/lib/functions/replace.d.ts +27 -0
- package/lib/functions/replace.js +49 -0
- package/lib/functions/replace.js.map +1 -0
- package/lib/functions/save-passages.d.ts +16 -0
- package/lib/functions/save-passages.js +35 -0
- package/lib/functions/save-passages.js.map +1 -0
- package/lib/generated/graphql.d.ts +1062 -0
- package/lib/generated/graphql.js +357 -0
- package/lib/generated/graphql.js.map +1 -0
- package/lib/mappers/alignment.d.ts +19 -0
- package/lib/mappers/alignment.js +19 -0
- package/lib/mappers/alignment.js.map +1 -0
- package/lib/mappers/annotation.d.ts +19 -0
- package/lib/mappers/annotation.js +74 -0
- package/lib/mappers/annotation.js.map +1 -0
- package/lib/mappers/imprint.d.ts +37 -0
- package/lib/mappers/imprint.js +44 -0
- package/lib/mappers/imprint.js.map +1 -0
- package/lib/mappers/index.js +8 -0
- package/lib/mappers/index.js.map +1 -0
- package/lib/mappers/passage.d.ts +41 -0
- package/lib/mappers/passage.js +39 -0
- package/lib/mappers/passage.js.map +1 -0
- package/lib/mappers/title.d.ts +18 -0
- package/lib/mappers/title.js +18 -0
- package/lib/mappers/title.js.map +1 -0
- package/lib/mappers/toc.d.ts +25 -0
- package/lib/mappers/toc.js +25 -0
- package/lib/mappers/toc.js.map +1 -0
- package/lib/mappers/work.d.ts +22 -0
- package/lib/mappers/work.js +22 -0
- package/lib/mappers/work.js.map +1 -0
- package/package.json +25 -3
- package/ssr.d.ts +4 -0
- package/ssr.js +7 -0
- package/ssr.js.map +1 -0
- package/README.md +0 -9
- package/codegen.ts +0 -34
- package/project.json +0 -21
- package/src/index.ts +0 -79
- package/src/lib/client-ssr.ts +0 -44
- package/src/lib/client.ts +0 -58
- package/src/lib/config.ts +0 -21
- package/src/lib/functions/get-bibliography-entry.ts +0 -40
- package/src/lib/functions/get-glossary-entry.ts +0 -136
- package/src/lib/functions/get-glossary-instance.ts +0 -48
- package/src/lib/functions/get-glossary-terms.ts +0 -44
- package/src/lib/functions/get-passage.ts +0 -78
- package/src/lib/functions/get-term-passages.ts +0 -53
- package/src/lib/functions/get-translation-blocks-around.ts +0 -131
- package/src/lib/functions/get-translation-blocks.ts +0 -160
- package/src/lib/functions/get-translation-imprint.ts +0 -114
- package/src/lib/functions/get-translation-metadata.ts +0 -99
- package/src/lib/functions/get-translation-passages-around.ts +0 -153
- package/src/lib/functions/get-translation-passages.ts +0 -168
- package/src/lib/functions/get-translation-titles.ts +0 -55
- package/src/lib/functions/get-translation-uuids.ts +0 -63
- package/src/lib/functions/get-translations-metadata.ts +0 -81
- package/src/lib/functions/get-work-bibliography.ts +0 -47
- package/src/lib/functions/get-work-folios.ts +0 -52
- package/src/lib/functions/get-work-glossary-terms-around.ts +0 -126
- package/src/lib/functions/get-work-glossary-terms.ts +0 -150
- package/src/lib/functions/get-work-glossary.ts +0 -54
- package/src/lib/functions/get-works.ts +0 -111
- package/src/lib/functions/has-permission.ts +0 -38
- package/src/lib/functions/save-passages.ts +0 -76
- package/src/lib/generated/graphql.ts +0 -1318
- package/src/lib/graphql/fragments/alignment.graphql +0 -7
- package/src/lib/graphql/fragments/annotation.graphql +0 -7
- package/src/lib/graphql/fragments/imprint.graphql +0 -34
- package/src/lib/graphql/fragments/passage.graphql +0 -29
- package/src/lib/graphql/fragments/title.graphql +0 -6
- package/src/lib/graphql/fragments/toc.graphql +0 -40
- package/src/lib/graphql/fragments/work.graphql +0 -10
- package/src/lib/graphql/queries/passages.graphql +0 -116
- package/src/lib/graphql/queries/work.graphql +0 -38
- package/src/lib/graphql/queries/works.graphql +0 -23
- package/src/lib/mappers/alignment.ts +0 -34
- package/src/lib/mappers/annotation.ts +0 -204
- package/src/lib/mappers/imprint.ts +0 -79
- package/src/lib/mappers/passage.ts +0 -80
- package/src/lib/mappers/title.ts +0 -35
- package/src/lib/mappers/toc.ts +0 -49
- package/src/lib/mappers/work.ts +0 -38
- package/src/ssr.ts +0 -73
- package/tsconfig.json +0 -17
- package/tsconfig.lib.json +0 -14
- /package/{src/lib/mappers/index.ts → lib/mappers/index.d.ts} +0 -0
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
import type { GlossaryPageItem, TohokuCatalogEntry } from '@eightyfourthousand/data-access';
|
|
4
|
-
|
|
5
|
-
const GET_GLOSSARY_ENTRY = gql`
|
|
6
|
-
query GetGlossaryEntry($uuid: ID!) {
|
|
7
|
-
glossaryEntry(uuid: $uuid) {
|
|
8
|
-
authorityUuid
|
|
9
|
-
headword
|
|
10
|
-
language
|
|
11
|
-
classifications
|
|
12
|
-
definition
|
|
13
|
-
xmlId
|
|
14
|
-
english
|
|
15
|
-
tibetan
|
|
16
|
-
sanskrit
|
|
17
|
-
pali
|
|
18
|
-
chinese
|
|
19
|
-
relatedInstances {
|
|
20
|
-
workUuid
|
|
21
|
-
toh
|
|
22
|
-
definition
|
|
23
|
-
canon
|
|
24
|
-
english
|
|
25
|
-
tibetan
|
|
26
|
-
sanskrit
|
|
27
|
-
pali
|
|
28
|
-
chinese
|
|
29
|
-
creators
|
|
30
|
-
}
|
|
31
|
-
relatedEntities {
|
|
32
|
-
sourceHeadword
|
|
33
|
-
sourceUuid
|
|
34
|
-
targetHeadword
|
|
35
|
-
targetUuid
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
|
-
type GraphQLGlossaryEntry = {
|
|
42
|
-
authorityUuid: string;
|
|
43
|
-
headword: string;
|
|
44
|
-
language: string;
|
|
45
|
-
classifications: string[];
|
|
46
|
-
definition: string | null;
|
|
47
|
-
xmlId: string | null;
|
|
48
|
-
english: string[];
|
|
49
|
-
tibetan: string[];
|
|
50
|
-
sanskrit: string[];
|
|
51
|
-
pali: string[];
|
|
52
|
-
chinese: string[];
|
|
53
|
-
relatedInstances: Array<{
|
|
54
|
-
workUuid: string;
|
|
55
|
-
toh: string;
|
|
56
|
-
definition: string | null;
|
|
57
|
-
canon: string | null;
|
|
58
|
-
english: string[];
|
|
59
|
-
tibetan: string[];
|
|
60
|
-
sanskrit: string[];
|
|
61
|
-
pali: string[];
|
|
62
|
-
chinese: string[];
|
|
63
|
-
creators: string[];
|
|
64
|
-
}>;
|
|
65
|
-
relatedEntities: Array<{
|
|
66
|
-
sourceHeadword: string;
|
|
67
|
-
sourceUuid: string;
|
|
68
|
-
targetHeadword: string;
|
|
69
|
-
targetUuid: string;
|
|
70
|
-
}>;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
type GetGlossaryEntryResponse = {
|
|
74
|
-
glossaryEntry: GraphQLGlossaryEntry | null;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Map GraphQL glossary entry to the GlossaryPageItem type.
|
|
79
|
-
*/
|
|
80
|
-
function glossaryEntryFromGraphQL(
|
|
81
|
-
entry: GraphQLGlossaryEntry,
|
|
82
|
-
): GlossaryPageItem {
|
|
83
|
-
return {
|
|
84
|
-
authorityUuid: entry.authorityUuid,
|
|
85
|
-
headword: entry.headword,
|
|
86
|
-
language: entry.language as GlossaryPageItem['language'],
|
|
87
|
-
classifications: entry.classifications,
|
|
88
|
-
definition: entry.definition ?? undefined,
|
|
89
|
-
xmlId: entry.xmlId ?? undefined,
|
|
90
|
-
english: entry.english,
|
|
91
|
-
tibetan: entry.tibetan,
|
|
92
|
-
sanskrit: entry.sanskrit,
|
|
93
|
-
pali: entry.pali,
|
|
94
|
-
chinese: entry.chinese,
|
|
95
|
-
relatedInstances: entry.relatedInstances.map((instance) => ({
|
|
96
|
-
workUuid: instance.workUuid,
|
|
97
|
-
toh: instance.toh as TohokuCatalogEntry,
|
|
98
|
-
definition: instance.definition ?? undefined,
|
|
99
|
-
canon: instance.canon ?? undefined,
|
|
100
|
-
english: instance.english,
|
|
101
|
-
tibetan: instance.tibetan,
|
|
102
|
-
sanskrit: instance.sanskrit,
|
|
103
|
-
pali: instance.pali,
|
|
104
|
-
chinese: instance.chinese,
|
|
105
|
-
creators: instance.creators,
|
|
106
|
-
})),
|
|
107
|
-
relatedEntities: entry.relatedEntities,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get a single glossary entry by UUID (for the detail page).
|
|
113
|
-
*/
|
|
114
|
-
export async function getGlossaryEntry({
|
|
115
|
-
client,
|
|
116
|
-
uuid,
|
|
117
|
-
}: {
|
|
118
|
-
client: GraphQLClient;
|
|
119
|
-
uuid: string;
|
|
120
|
-
}): Promise<GlossaryPageItem | null> {
|
|
121
|
-
try {
|
|
122
|
-
const response = await client.request<GetGlossaryEntryResponse>(
|
|
123
|
-
GET_GLOSSARY_ENTRY,
|
|
124
|
-
{ uuid },
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
if (!response.glossaryEntry) {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return glossaryEntryFromGraphQL(response.glossaryEntry);
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error('Error fetching glossary entry:', error);
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
import type { GlossaryTermInstance } from '@eightyfourthousand/data-access';
|
|
4
|
-
|
|
5
|
-
const GET_GLOSSARY_INSTANCE = gql`
|
|
6
|
-
query GetGlossaryInstance($uuid: ID!) {
|
|
7
|
-
glossaryInstance(uuid: $uuid) {
|
|
8
|
-
uuid
|
|
9
|
-
authority
|
|
10
|
-
definition
|
|
11
|
-
names {
|
|
12
|
-
english
|
|
13
|
-
tibetan
|
|
14
|
-
sanskrit
|
|
15
|
-
pali
|
|
16
|
-
chinese
|
|
17
|
-
wylie
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
type GetGlossaryInstanceResponse = {
|
|
24
|
-
glossaryInstance: GlossaryTermInstance | null;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get a single glossary instance by UUID.
|
|
29
|
-
*/
|
|
30
|
-
export async function getGlossaryInstance({
|
|
31
|
-
client,
|
|
32
|
-
uuid,
|
|
33
|
-
}: {
|
|
34
|
-
client: GraphQLClient;
|
|
35
|
-
uuid: string;
|
|
36
|
-
}): Promise<GlossaryTermInstance | null> {
|
|
37
|
-
try {
|
|
38
|
-
const response = await client.request<GetGlossaryInstanceResponse>(
|
|
39
|
-
GET_GLOSSARY_INSTANCE,
|
|
40
|
-
{ uuid },
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return response.glossaryInstance;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Error fetching glossary instance:', error);
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
import type { GlossaryLandingItem } from '@eightyfourthousand/data-access';
|
|
4
|
-
|
|
5
|
-
const GET_GLOSSARY_TERMS = gql`
|
|
6
|
-
query GetGlossaryTerms($uuids: [ID!]) {
|
|
7
|
-
glossaryTerms(uuids: $uuids) {
|
|
8
|
-
uuid
|
|
9
|
-
headword
|
|
10
|
-
type
|
|
11
|
-
language
|
|
12
|
-
nameVariants
|
|
13
|
-
definition
|
|
14
|
-
numGlossaryEntries
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
type GetGlossaryTermsResponse = {
|
|
20
|
-
glossaryTerms: GlossaryLandingItem[];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get all glossary terms for the landing page, optionally filtered by UUIDs.
|
|
25
|
-
*/
|
|
26
|
-
export async function getGlossaryTerms({
|
|
27
|
-
client,
|
|
28
|
-
uuids,
|
|
29
|
-
}: {
|
|
30
|
-
client: GraphQLClient;
|
|
31
|
-
uuids?: string[];
|
|
32
|
-
}): Promise<GlossaryLandingItem[]> {
|
|
33
|
-
try {
|
|
34
|
-
const response = await client.request<GetGlossaryTermsResponse>(
|
|
35
|
-
GET_GLOSSARY_TERMS,
|
|
36
|
-
{ uuids },
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return response.glossaryTerms;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error('Error fetching glossary terms:', error);
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
import type { Passage } from '@eightyfourthousand/data-access';
|
|
4
|
-
import { passageFromGraphQL, type GraphQLPassage } from '../mappers';
|
|
5
|
-
|
|
6
|
-
const GET_PASSAGE = gql`
|
|
7
|
-
fragment AnnotationFields on Annotation {
|
|
8
|
-
uuid
|
|
9
|
-
type
|
|
10
|
-
start
|
|
11
|
-
end
|
|
12
|
-
metadata
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
fragment AlignmentFields on Alignment {
|
|
16
|
-
folioUuid
|
|
17
|
-
toh
|
|
18
|
-
tibetan
|
|
19
|
-
folioNumber
|
|
20
|
-
volumeNumber
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fragment PassageFields on Passage {
|
|
24
|
-
uuid
|
|
25
|
-
workUuid
|
|
26
|
-
content
|
|
27
|
-
label
|
|
28
|
-
sort
|
|
29
|
-
type
|
|
30
|
-
xmlId
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
fragment PassageWithAnnotations on Passage {
|
|
34
|
-
...PassageFields
|
|
35
|
-
annotations {
|
|
36
|
-
...AnnotationFields
|
|
37
|
-
}
|
|
38
|
-
alignments {
|
|
39
|
-
...AlignmentFields
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
query GetPassage($uuid: ID!) {
|
|
44
|
-
passage(uuid: $uuid) {
|
|
45
|
-
...PassageWithAnnotations
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
type GetPassageResponse = {
|
|
51
|
-
passage: GraphQLPassage | null;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get a single passage by UUID.
|
|
56
|
-
*/
|
|
57
|
-
export async function getPassage({
|
|
58
|
-
client,
|
|
59
|
-
uuid,
|
|
60
|
-
}: {
|
|
61
|
-
client: GraphQLClient;
|
|
62
|
-
uuid: string;
|
|
63
|
-
}): Promise<Passage | undefined> {
|
|
64
|
-
try {
|
|
65
|
-
const response = await client.request<GetPassageResponse>(GET_PASSAGE, {
|
|
66
|
-
uuid,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
if (!response.passage) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return passageFromGraphQL(response.passage);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error('Error fetching passage:', error);
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
|
|
4
|
-
const GET_TERM_PASSAGES = gql`
|
|
5
|
-
query GetTermPassages($uuid: ID!, $first: Int, $after: String) {
|
|
6
|
-
glossaryTermPassages(uuid: $uuid, first: $first, after: $after) {
|
|
7
|
-
items {
|
|
8
|
-
uuid
|
|
9
|
-
type
|
|
10
|
-
label
|
|
11
|
-
sort
|
|
12
|
-
}
|
|
13
|
-
nextCursor
|
|
14
|
-
hasMore
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
export type GlossaryPassagesPage = {
|
|
20
|
-
items: Array<{ uuid: string; type: string; label: string; sort: number }>;
|
|
21
|
-
nextCursor: string | null;
|
|
22
|
-
hasMore: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type GetTermPassagesResponse = {
|
|
26
|
-
glossaryTermPassages: GlossaryPassagesPage;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Fetch a page of passage references for a single glossary term instance.
|
|
31
|
-
*/
|
|
32
|
-
export async function getTermPassages({
|
|
33
|
-
client,
|
|
34
|
-
uuid,
|
|
35
|
-
first = 10,
|
|
36
|
-
after,
|
|
37
|
-
}: {
|
|
38
|
-
client: GraphQLClient;
|
|
39
|
-
uuid: string;
|
|
40
|
-
first?: number;
|
|
41
|
-
after?: string;
|
|
42
|
-
}): Promise<GlossaryPassagesPage> {
|
|
43
|
-
try {
|
|
44
|
-
const response = await client.request<GetTermPassagesResponse>(
|
|
45
|
-
GET_TERM_PASSAGES,
|
|
46
|
-
{ uuid, first, after },
|
|
47
|
-
);
|
|
48
|
-
return response.glossaryTermPassages;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error('Error fetching term passages:', error);
|
|
51
|
-
return { items: [], nextCursor: null, hasMore: false };
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
import type { BodyItemType, TranslationEditorContentItem } from '@eightyfourthousand/data-access';
|
|
4
|
-
import type { TranslationBlocksPage } from './get-translation-blocks';
|
|
5
|
-
|
|
6
|
-
const GET_PASSAGES_AROUND_WITH_JSON = gql`
|
|
7
|
-
fragment PassageWithJson on Passage {
|
|
8
|
-
uuid
|
|
9
|
-
workUuid
|
|
10
|
-
label
|
|
11
|
-
sort
|
|
12
|
-
type
|
|
13
|
-
xmlId
|
|
14
|
-
json
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
query GetPassagesAroundWithJson(
|
|
18
|
-
$uuid: ID!
|
|
19
|
-
$cursor: String!
|
|
20
|
-
$limit: Int
|
|
21
|
-
$filter: PassageFilter
|
|
22
|
-
) {
|
|
23
|
-
work(uuid: $uuid) {
|
|
24
|
-
uuid
|
|
25
|
-
passages(
|
|
26
|
-
cursor: $cursor
|
|
27
|
-
limit: $limit
|
|
28
|
-
direction: AROUND
|
|
29
|
-
filter: $filter
|
|
30
|
-
) {
|
|
31
|
-
nodes {
|
|
32
|
-
...PassageWithJson
|
|
33
|
-
}
|
|
34
|
-
pageInfo {
|
|
35
|
-
nextCursor
|
|
36
|
-
prevCursor
|
|
37
|
-
hasMoreAfter
|
|
38
|
-
hasMoreBefore
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
type PassageWithJson = {
|
|
46
|
-
uuid: string;
|
|
47
|
-
workUuid: string;
|
|
48
|
-
label: string;
|
|
49
|
-
sort: number;
|
|
50
|
-
type: string;
|
|
51
|
-
xmlId?: string | null;
|
|
52
|
-
json?: unknown | null;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
type GetPassagesAroundWithJsonResponse = {
|
|
56
|
-
work: {
|
|
57
|
-
uuid: string;
|
|
58
|
-
passages: {
|
|
59
|
-
nodes: PassageWithJson[];
|
|
60
|
-
pageInfo: {
|
|
61
|
-
nextCursor?: string | null;
|
|
62
|
-
prevCursor?: string | null;
|
|
63
|
-
hasMoreAfter: boolean;
|
|
64
|
-
hasMoreBefore: boolean;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
} | null;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get translation blocks (TipTap JSON) around a specific passage UUID.
|
|
72
|
-
*
|
|
73
|
-
* Unlike getTranslationPassagesAround which returns Passage objects,
|
|
74
|
-
* this function returns pre-transformed TipTap editor blocks
|
|
75
|
-
* ready for rendering.
|
|
76
|
-
*/
|
|
77
|
-
export async function getTranslationBlocksAround({
|
|
78
|
-
client,
|
|
79
|
-
uuid,
|
|
80
|
-
passageUuid,
|
|
81
|
-
type,
|
|
82
|
-
maxPassages,
|
|
83
|
-
}: {
|
|
84
|
-
client: GraphQLClient;
|
|
85
|
-
uuid: string;
|
|
86
|
-
passageUuid: string;
|
|
87
|
-
type?: BodyItemType | string;
|
|
88
|
-
maxPassages?: number;
|
|
89
|
-
}): Promise<TranslationBlocksPage> {
|
|
90
|
-
try {
|
|
91
|
-
const response = await client.request<GetPassagesAroundWithJsonResponse>(
|
|
92
|
-
GET_PASSAGES_AROUND_WITH_JSON,
|
|
93
|
-
{
|
|
94
|
-
uuid,
|
|
95
|
-
cursor: passageUuid,
|
|
96
|
-
limit: maxPassages,
|
|
97
|
-
filter: type ? { type } : undefined,
|
|
98
|
-
},
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
if (!response.work) {
|
|
102
|
-
return {
|
|
103
|
-
blocks: [],
|
|
104
|
-
hasMoreAfter: false,
|
|
105
|
-
hasMoreBefore: false,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const { passages } = response.work;
|
|
110
|
-
|
|
111
|
-
// Extract the JSON blocks, filtering out any null values
|
|
112
|
-
const blocks = passages.nodes
|
|
113
|
-
.map((node) => node.json)
|
|
114
|
-
.filter((json): json is TranslationEditorContentItem => json != null);
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
blocks,
|
|
118
|
-
nextCursor: passages.pageInfo.nextCursor ?? undefined,
|
|
119
|
-
prevCursor: passages.pageInfo.prevCursor ?? undefined,
|
|
120
|
-
hasMoreAfter: passages.pageInfo.hasMoreAfter,
|
|
121
|
-
hasMoreBefore: passages.pageInfo.hasMoreBefore,
|
|
122
|
-
};
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.error('Error fetching translation blocks around:', error);
|
|
125
|
-
return {
|
|
126
|
-
blocks: [],
|
|
127
|
-
hasMoreAfter: false,
|
|
128
|
-
hasMoreBefore: false,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { gql } from 'graphql-request';
|
|
3
|
-
import type {
|
|
4
|
-
BodyItemType,
|
|
5
|
-
PaginationDirection,
|
|
6
|
-
TranslationEditorContent,
|
|
7
|
-
TranslationEditorContentItem,
|
|
8
|
-
} from '@eightyfourthousand/data-access';
|
|
9
|
-
|
|
10
|
-
const GET_PASSAGES_WITH_JSON = gql`
|
|
11
|
-
fragment PassageWithJson on Passage {
|
|
12
|
-
uuid
|
|
13
|
-
workUuid
|
|
14
|
-
label
|
|
15
|
-
sort
|
|
16
|
-
type
|
|
17
|
-
xmlId
|
|
18
|
-
json
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
query GetPassagesWithJson(
|
|
22
|
-
$uuid: ID!
|
|
23
|
-
$cursor: String
|
|
24
|
-
$limit: Int
|
|
25
|
-
$direction: PaginationDirection
|
|
26
|
-
$filter: PassageFilter
|
|
27
|
-
) {
|
|
28
|
-
work(uuid: $uuid) {
|
|
29
|
-
uuid
|
|
30
|
-
passages(
|
|
31
|
-
cursor: $cursor
|
|
32
|
-
limit: $limit
|
|
33
|
-
direction: $direction
|
|
34
|
-
filter: $filter
|
|
35
|
-
) {
|
|
36
|
-
nodes {
|
|
37
|
-
...PassageWithJson
|
|
38
|
-
}
|
|
39
|
-
pageInfo {
|
|
40
|
-
nextCursor
|
|
41
|
-
prevCursor
|
|
42
|
-
hasMoreAfter
|
|
43
|
-
hasMoreBefore
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
|
|
50
|
-
type PassageWithJson = {
|
|
51
|
-
uuid: string;
|
|
52
|
-
workUuid: string;
|
|
53
|
-
label: string;
|
|
54
|
-
sort: number;
|
|
55
|
-
type: string;
|
|
56
|
-
xmlId?: string | null;
|
|
57
|
-
json?: unknown | null;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
type GetPassagesWithJsonResponse = {
|
|
61
|
-
work: {
|
|
62
|
-
uuid: string;
|
|
63
|
-
passages: {
|
|
64
|
-
nodes: PassageWithJson[];
|
|
65
|
-
pageInfo: {
|
|
66
|
-
nextCursor?: string | null;
|
|
67
|
-
prevCursor?: string | null;
|
|
68
|
-
hasMoreAfter: boolean;
|
|
69
|
-
hasMoreBefore: boolean;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
} | null;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Result of fetching translation blocks with pagination info
|
|
77
|
-
*/
|
|
78
|
-
export type TranslationBlocksPage = {
|
|
79
|
-
blocks: TranslationEditorContent;
|
|
80
|
-
nextCursor?: string;
|
|
81
|
-
prevCursor?: string;
|
|
82
|
-
hasMoreAfter: boolean;
|
|
83
|
-
hasMoreBefore: boolean;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Map internal pagination direction to GraphQL enum
|
|
88
|
-
*/
|
|
89
|
-
function mapDirection(
|
|
90
|
-
direction?: PaginationDirection,
|
|
91
|
-
): 'FORWARD' | 'BACKWARD' | undefined {
|
|
92
|
-
if (!direction) return undefined;
|
|
93
|
-
return direction === 'forward' ? 'FORWARD' : 'BACKWARD';
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Get paginated translation blocks (TipTap JSON) for a work.
|
|
98
|
-
*
|
|
99
|
-
* Unlike getTranslationPassages which returns Passage objects,
|
|
100
|
-
* this function returns pre-transformed TipTap editor blocks
|
|
101
|
-
* ready for rendering.
|
|
102
|
-
*/
|
|
103
|
-
export async function getTranslationBlocks({
|
|
104
|
-
client,
|
|
105
|
-
uuid,
|
|
106
|
-
type,
|
|
107
|
-
cursor,
|
|
108
|
-
maxPassages = 100,
|
|
109
|
-
direction,
|
|
110
|
-
}: {
|
|
111
|
-
client: GraphQLClient;
|
|
112
|
-
uuid: string;
|
|
113
|
-
type?: BodyItemType | string;
|
|
114
|
-
cursor?: string;
|
|
115
|
-
maxPassages?: number;
|
|
116
|
-
direction?: PaginationDirection;
|
|
117
|
-
}): Promise<TranslationBlocksPage> {
|
|
118
|
-
try {
|
|
119
|
-
const response = await client.request<GetPassagesWithJsonResponse>(
|
|
120
|
-
GET_PASSAGES_WITH_JSON,
|
|
121
|
-
{
|
|
122
|
-
uuid,
|
|
123
|
-
cursor,
|
|
124
|
-
limit: maxPassages,
|
|
125
|
-
direction: mapDirection(direction),
|
|
126
|
-
filter: type ? { type } : undefined,
|
|
127
|
-
},
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
if (!response.work) {
|
|
131
|
-
return {
|
|
132
|
-
blocks: [],
|
|
133
|
-
hasMoreAfter: false,
|
|
134
|
-
hasMoreBefore: false,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const { passages } = response.work;
|
|
139
|
-
|
|
140
|
-
// Extract the JSON blocks, filtering out any null values
|
|
141
|
-
const blocks = passages.nodes
|
|
142
|
-
.map((node) => node.json)
|
|
143
|
-
.filter((json): json is TranslationEditorContentItem => json != null);
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
blocks,
|
|
147
|
-
nextCursor: passages.pageInfo.nextCursor ?? undefined,
|
|
148
|
-
prevCursor: passages.pageInfo.prevCursor ?? undefined,
|
|
149
|
-
hasMoreAfter: passages.pageInfo.hasMoreAfter,
|
|
150
|
-
hasMoreBefore: passages.pageInfo.hasMoreBefore,
|
|
151
|
-
};
|
|
152
|
-
} catch (error) {
|
|
153
|
-
console.error('Error fetching translation blocks:', error);
|
|
154
|
-
return {
|
|
155
|
-
blocks: [],
|
|
156
|
-
hasMoreAfter: false,
|
|
157
|
-
hasMoreBefore: false,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|