@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.
Files changed (154) hide show
  1. package/index.d.ts +4 -0
  2. package/index.js +7 -0
  3. package/index.js.map +1 -0
  4. package/lib/client-ssr.d.ts +16 -0
  5. package/lib/client-ssr.js +39 -0
  6. package/lib/client-ssr.js.map +1 -0
  7. package/lib/client.d.ts +15 -0
  8. package/lib/client.js +46 -0
  9. package/lib/client.js.map +1 -0
  10. package/lib/config.d.ts +8 -0
  11. package/lib/config.js +19 -0
  12. package/lib/config.js.map +1 -0
  13. package/lib/functions/get-bibliography-entry.d.ts +9 -0
  14. package/lib/functions/get-bibliography-entry.js +27 -0
  15. package/lib/functions/get-bibliography-entry.js.map +1 -0
  16. package/lib/functions/get-glossary-instance.d.ts +9 -0
  17. package/lib/functions/get-glossary-instance.js +36 -0
  18. package/lib/functions/get-glossary-instance.js.map +1 -0
  19. package/lib/functions/get-passage.d.ts +10 -0
  20. package/lib/functions/get-passage.js +68 -0
  21. package/lib/functions/get-passage.js.map +1 -0
  22. package/lib/functions/get-term-passages.d.ts +20 -0
  23. package/lib/functions/get-term-passages.js +32 -0
  24. package/lib/functions/get-term-passages.js.map +1 -0
  25. package/lib/functions/get-translation-blocks-around.d.ts +15 -0
  26. package/lib/functions/get-translation-blocks-around.js +86 -0
  27. package/lib/functions/get-translation-blocks-around.js.map +1 -0
  28. package/lib/functions/get-translation-blocks.d.ts +25 -0
  29. package/lib/functions/get-translation-blocks.js +96 -0
  30. package/lib/functions/get-translation-blocks.js.map +1 -0
  31. package/lib/functions/get-translation-imprint.d.ts +10 -0
  32. package/lib/functions/get-translation-imprint.js +68 -0
  33. package/lib/functions/get-translation-imprint.js.map +1 -0
  34. package/lib/functions/get-translation-metadata.d.ts +16 -0
  35. package/lib/functions/get-translation-metadata.js +72 -0
  36. package/lib/functions/get-translation-metadata.js.map +1 -0
  37. package/lib/functions/get-translation-titles.d.ts +9 -0
  38. package/lib/functions/get-translation-titles.js +34 -0
  39. package/lib/functions/get-translation-titles.js.map +1 -0
  40. package/lib/functions/get-translation-toc.d.ts +9 -0
  41. package/{src/lib/functions/get-translation-toc.ts → lib/functions/get-translation-toc.js} +18 -48
  42. package/lib/functions/get-translation-toc.js.map +1 -0
  43. package/lib/functions/get-translation-uuids.d.ts +16 -0
  44. package/lib/functions/get-translation-uuids.js +40 -0
  45. package/lib/functions/get-translation-uuids.js.map +1 -0
  46. package/lib/functions/get-translations-metadata.d.ts +9 -0
  47. package/lib/functions/get-translations-metadata.js +51 -0
  48. package/lib/functions/get-translations-metadata.js.map +1 -0
  49. package/lib/functions/get-work-bibliography.d.ts +9 -0
  50. package/lib/functions/get-work-bibliography.js +33 -0
  51. package/lib/functions/get-work-bibliography.js.map +1 -0
  52. package/lib/functions/get-work-folios.d.ts +12 -0
  53. package/lib/functions/get-work-folios.js +32 -0
  54. package/lib/functions/get-work-folios.js.map +1 -0
  55. package/lib/functions/get-work-glossary-terms-around.d.ts +13 -0
  56. package/lib/functions/get-work-glossary-terms-around.js +95 -0
  57. package/lib/functions/get-work-glossary-terms-around.js.map +1 -0
  58. package/lib/functions/get-work-glossary-terms.d.ts +24 -0
  59. package/lib/functions/get-work-glossary-terms.js +104 -0
  60. package/lib/functions/get-work-glossary-terms.js.map +1 -0
  61. package/lib/functions/has-permission.d.ts +9 -0
  62. package/lib/functions/has-permission.js +15 -0
  63. package/lib/functions/has-permission.js.map +1 -0
  64. package/{src/lib/functions/index.ts → lib/functions/index.d.ts} +4 -18
  65. package/lib/functions/index.js +20 -0
  66. package/lib/functions/index.js.map +1 -0
  67. package/lib/functions/replace.d.ts +27 -0
  68. package/lib/functions/replace.js +49 -0
  69. package/lib/functions/replace.js.map +1 -0
  70. package/lib/functions/save-passages.d.ts +16 -0
  71. package/lib/functions/save-passages.js +35 -0
  72. package/lib/functions/save-passages.js.map +1 -0
  73. package/lib/generated/graphql.d.ts +1062 -0
  74. package/lib/generated/graphql.js +357 -0
  75. package/lib/generated/graphql.js.map +1 -0
  76. package/lib/mappers/alignment.d.ts +19 -0
  77. package/lib/mappers/alignment.js +19 -0
  78. package/lib/mappers/alignment.js.map +1 -0
  79. package/lib/mappers/annotation.d.ts +19 -0
  80. package/lib/mappers/annotation.js +74 -0
  81. package/lib/mappers/annotation.js.map +1 -0
  82. package/lib/mappers/imprint.d.ts +37 -0
  83. package/lib/mappers/imprint.js +44 -0
  84. package/lib/mappers/imprint.js.map +1 -0
  85. package/lib/mappers/index.js +8 -0
  86. package/lib/mappers/index.js.map +1 -0
  87. package/lib/mappers/passage.d.ts +41 -0
  88. package/lib/mappers/passage.js +39 -0
  89. package/lib/mappers/passage.js.map +1 -0
  90. package/lib/mappers/title.d.ts +18 -0
  91. package/lib/mappers/title.js +18 -0
  92. package/lib/mappers/title.js.map +1 -0
  93. package/lib/mappers/toc.d.ts +25 -0
  94. package/lib/mappers/toc.js +25 -0
  95. package/lib/mappers/toc.js.map +1 -0
  96. package/lib/mappers/work.d.ts +22 -0
  97. package/lib/mappers/work.js +22 -0
  98. package/lib/mappers/work.js.map +1 -0
  99. package/package.json +25 -3
  100. package/ssr.d.ts +4 -0
  101. package/ssr.js +7 -0
  102. package/ssr.js.map +1 -0
  103. package/README.md +0 -9
  104. package/codegen.ts +0 -34
  105. package/project.json +0 -21
  106. package/src/index.ts +0 -79
  107. package/src/lib/client-ssr.ts +0 -44
  108. package/src/lib/client.ts +0 -58
  109. package/src/lib/config.ts +0 -21
  110. package/src/lib/functions/get-bibliography-entry.ts +0 -40
  111. package/src/lib/functions/get-glossary-entry.ts +0 -136
  112. package/src/lib/functions/get-glossary-instance.ts +0 -48
  113. package/src/lib/functions/get-glossary-terms.ts +0 -44
  114. package/src/lib/functions/get-passage.ts +0 -78
  115. package/src/lib/functions/get-term-passages.ts +0 -53
  116. package/src/lib/functions/get-translation-blocks-around.ts +0 -131
  117. package/src/lib/functions/get-translation-blocks.ts +0 -160
  118. package/src/lib/functions/get-translation-imprint.ts +0 -114
  119. package/src/lib/functions/get-translation-metadata.ts +0 -99
  120. package/src/lib/functions/get-translation-passages-around.ts +0 -153
  121. package/src/lib/functions/get-translation-passages.ts +0 -168
  122. package/src/lib/functions/get-translation-titles.ts +0 -55
  123. package/src/lib/functions/get-translation-uuids.ts +0 -63
  124. package/src/lib/functions/get-translations-metadata.ts +0 -81
  125. package/src/lib/functions/get-work-bibliography.ts +0 -47
  126. package/src/lib/functions/get-work-folios.ts +0 -52
  127. package/src/lib/functions/get-work-glossary-terms-around.ts +0 -126
  128. package/src/lib/functions/get-work-glossary-terms.ts +0 -150
  129. package/src/lib/functions/get-work-glossary.ts +0 -54
  130. package/src/lib/functions/get-works.ts +0 -111
  131. package/src/lib/functions/has-permission.ts +0 -38
  132. package/src/lib/functions/save-passages.ts +0 -76
  133. package/src/lib/generated/graphql.ts +0 -1318
  134. package/src/lib/graphql/fragments/alignment.graphql +0 -7
  135. package/src/lib/graphql/fragments/annotation.graphql +0 -7
  136. package/src/lib/graphql/fragments/imprint.graphql +0 -34
  137. package/src/lib/graphql/fragments/passage.graphql +0 -29
  138. package/src/lib/graphql/fragments/title.graphql +0 -6
  139. package/src/lib/graphql/fragments/toc.graphql +0 -40
  140. package/src/lib/graphql/fragments/work.graphql +0 -10
  141. package/src/lib/graphql/queries/passages.graphql +0 -116
  142. package/src/lib/graphql/queries/work.graphql +0 -38
  143. package/src/lib/graphql/queries/works.graphql +0 -23
  144. package/src/lib/mappers/alignment.ts +0 -34
  145. package/src/lib/mappers/annotation.ts +0 -204
  146. package/src/lib/mappers/imprint.ts +0 -79
  147. package/src/lib/mappers/passage.ts +0 -80
  148. package/src/lib/mappers/title.ts +0 -35
  149. package/src/lib/mappers/toc.ts +0 -49
  150. package/src/lib/mappers/work.ts +0 -38
  151. package/src/ssr.ts +0 -73
  152. package/tsconfig.json +0 -17
  153. package/tsconfig.lib.json +0 -14
  154. /package/{src/lib/mappers/index.ts → lib/mappers/index.d.ts} +0 -0
@@ -1,114 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
- import type { Imprint } from '@eightyfourthousand/data-access';
4
- import { imprintFromGraphQL } from '../mappers';
5
-
6
- const GET_WORK_WITH_IMPRINT = gql`
7
- fragment LicenseFields on License {
8
- name
9
- link
10
- description
11
- }
12
-
13
- fragment TitlesByLanguageFields on TitlesByLanguage {
14
- tibetan
15
- english
16
- wylie
17
- sanskrit
18
- }
19
-
20
- fragment ImprintFields on Imprint {
21
- toh
22
- section
23
- version
24
- restriction
25
- publishYear
26
- tibetanAuthors
27
- isAuthorContested
28
- sourceDescription
29
- publisherStatement
30
- tibetanTranslators
31
- license {
32
- ...LicenseFields
33
- }
34
- mainTitles {
35
- ...TitlesByLanguageFields
36
- }
37
- longTitles {
38
- ...TitlesByLanguageFields
39
- }
40
- }
41
-
42
- query GetWorkWithImprint($uuid: ID!, $toh: String) {
43
- work(uuid: $uuid, toh: $toh) {
44
- uuid
45
- imprint {
46
- ...ImprintFields
47
- }
48
- }
49
- }
50
- `;
51
-
52
- type GetWorkWithImprintResponse = {
53
- work: {
54
- uuid: string;
55
- imprint: {
56
- toh: string;
57
- section?: string | null;
58
- version?: string | null;
59
- restriction?: boolean | null;
60
- publishYear?: string | null;
61
- tibetanAuthors?: string[] | null;
62
- isAuthorContested: boolean;
63
- sourceDescription?: string | null;
64
- publisherStatement?: string | null;
65
- tibetanTranslators?: string | null;
66
- license: {
67
- name?: string | null;
68
- link?: string | null;
69
- description?: string | null;
70
- } | null;
71
- mainTitles?: {
72
- tibetan?: string | null;
73
- english?: string | null;
74
- wylie?: string | null;
75
- sanskrit?: string | null;
76
- } | null;
77
- longTitles?: {
78
- tibetan?: string | null;
79
- english?: string | null;
80
- wylie?: string | null;
81
- sanskrit?: string | null;
82
- } | null;
83
- } | null;
84
- } | null;
85
- };
86
-
87
- /**
88
- * Get the imprint for a translation work.
89
- */
90
- export async function getTranslationImprint({
91
- client,
92
- uuid,
93
- toh,
94
- }: {
95
- client: GraphQLClient;
96
- uuid: string;
97
- toh: string;
98
- }): Promise<Imprint | undefined> {
99
- try {
100
- const response = await client.request<GetWorkWithImprintResponse>(
101
- GET_WORK_WITH_IMPRINT,
102
- { uuid, toh },
103
- );
104
-
105
- if (!response.work?.imprint) {
106
- return undefined;
107
- }
108
-
109
- return imprintFromGraphQL(response.work.imprint, response.work.uuid);
110
- } catch (error) {
111
- console.error('Error fetching translation imprint:', error);
112
- return undefined;
113
- }
114
- }
@@ -1,99 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
- import type { Work } from '@eightyfourthousand/data-access';
4
- import { workFromGraphQL } from '../mappers';
5
-
6
- const GET_WORK_BY_UUID = gql`
7
- query GetWorkByUuid($uuid: ID!) {
8
- work(uuid: $uuid) {
9
- uuid
10
- title
11
- toh
12
- publicationDate
13
- publicationVersion
14
- pages
15
- restriction
16
- section
17
- }
18
- }
19
- `;
20
-
21
- const GET_WORK_BY_TOH = gql`
22
- query GetWorkByToh($toh: String!) {
23
- work(toh: $toh) {
24
- uuid
25
- title
26
- toh
27
- publicationDate
28
- publicationVersion
29
- pages
30
- restriction
31
- section
32
- }
33
- }
34
- `;
35
-
36
- type GetWorkResponse = {
37
- work: {
38
- uuid: string;
39
- title: string;
40
- toh: string[];
41
- publicationDate: string;
42
- publicationVersion: string;
43
- pages: number;
44
- restriction: boolean;
45
- section: string;
46
- } | null;
47
- };
48
-
49
- /**
50
- * Get work metadata by UUID.
51
- */
52
- export async function getTranslationMetadataByUuid({
53
- client,
54
- uuid,
55
- }: {
56
- client: GraphQLClient;
57
- uuid: string;
58
- }): Promise<Work | null> {
59
- try {
60
- const response = await client.request<GetWorkResponse>(GET_WORK_BY_UUID, {
61
- uuid,
62
- });
63
-
64
- if (!response.work) {
65
- return null;
66
- }
67
-
68
- return workFromGraphQL(response.work);
69
- } catch (error) {
70
- console.error('Error fetching translation metadata by UUID:', error);
71
- return null;
72
- }
73
- }
74
-
75
- /**
76
- * Get work metadata by Tohoku catalog number.
77
- */
78
- export async function getTranslationMetadataByToh({
79
- client,
80
- toh,
81
- }: {
82
- client: GraphQLClient;
83
- toh: string;
84
- }): Promise<Work | null> {
85
- try {
86
- const response = await client.request<GetWorkResponse>(GET_WORK_BY_TOH, {
87
- toh,
88
- });
89
-
90
- if (!response.work) {
91
- return null;
92
- }
93
-
94
- return workFromGraphQL(response.work);
95
- } catch (error) {
96
- console.error('Error fetching translation metadata by toh:', error);
97
- return null;
98
- }
99
- }
@@ -1,153 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
- import type { BodyItemType, PassagesPage } from '@eightyfourthousand/data-access';
4
- import { passagesPageFromGraphQL } from '../mappers';
5
-
6
- const GET_PASSAGES_AROUND = 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 PassageWithAnnotations on Passage {
24
- uuid
25
- workUuid
26
- content
27
- label
28
- sort
29
- type
30
- xmlId
31
- annotations {
32
- ...AnnotationFields
33
- }
34
- alignments {
35
- ...AlignmentFields
36
- }
37
- }
38
-
39
- query GetPassagesAround(
40
- $uuid: ID!
41
- $cursor: String!
42
- $limit: Int
43
- $filter: PassageFilter
44
- ) {
45
- work(uuid: $uuid) {
46
- uuid
47
- passages(
48
- cursor: $cursor
49
- limit: $limit
50
- direction: AROUND
51
- filter: $filter
52
- ) {
53
- nodes {
54
- ...PassageWithAnnotations
55
- }
56
- pageInfo {
57
- nextCursor
58
- prevCursor
59
- hasMoreAfter
60
- hasMoreBefore
61
- }
62
- }
63
- }
64
- }
65
- `;
66
-
67
- type GetPassagesAroundResponse = {
68
- work: {
69
- uuid: string;
70
- passages: {
71
- nodes: Array<{
72
- uuid: string;
73
- workUuid: string;
74
- content: string;
75
- label: string;
76
- sort: number;
77
- type: string;
78
- xmlId?: string | null;
79
- annotations: Array<{
80
- uuid: string;
81
- type: string;
82
- start: number;
83
- end: number;
84
- metadata?: Record<string, unknown> | null;
85
- }>;
86
- alignments: Array<{
87
- folioUuid: string;
88
- toh: string;
89
- tibetan: string;
90
- folioNumber: number;
91
- volumeNumber: number;
92
- }>;
93
- }>;
94
- pageInfo: {
95
- nextCursor?: string | null;
96
- prevCursor?: string | null;
97
- hasMoreAfter: boolean;
98
- hasMoreBefore: boolean;
99
- };
100
- };
101
- } | null;
102
- };
103
-
104
- /**
105
- * Get passages around a specific passage UUID.
106
- *
107
- * NOTE: maxCharacters is not supported by the GraphQL API yet.
108
- * This parameter is accepted for API compatibility but is ignored.
109
- */
110
- export async function getTranslationPassagesAround({
111
- client,
112
- uuid,
113
- passageUuid,
114
- type,
115
- maxPassages,
116
- maxCharacters: _maxCharacters,
117
- }: {
118
- client: GraphQLClient;
119
- uuid: string;
120
- passageUuid: string;
121
- type?: BodyItemType;
122
- maxPassages?: number;
123
- maxCharacters?: number;
124
- }): Promise<PassagesPage> {
125
- try {
126
- const response = await client.request<GetPassagesAroundResponse>(
127
- GET_PASSAGES_AROUND,
128
- {
129
- uuid,
130
- cursor: passageUuid,
131
- limit: maxPassages,
132
- filter: type ? { type } : undefined,
133
- },
134
- );
135
-
136
- if (!response.work) {
137
- return {
138
- passages: [],
139
- hasMoreAfter: false,
140
- hasMoreBefore: false,
141
- };
142
- }
143
-
144
- return passagesPageFromGraphQL(response.work.passages, response.work.uuid);
145
- } catch (error) {
146
- console.error('Error fetching translation passages around:', error);
147
- return {
148
- passages: [],
149
- hasMoreAfter: false,
150
- hasMoreBefore: false,
151
- };
152
- }
153
- }
@@ -1,168 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
- import type {
4
- BodyItemType,
5
- PaginationDirection,
6
- PassagesPage,
7
- } from '@eightyfourthousand/data-access';
8
- import { passagesPageFromGraphQL } from '../mappers';
9
-
10
- const GET_PASSAGES = gql`
11
- fragment AnnotationFields on Annotation {
12
- uuid
13
- type
14
- start
15
- end
16
- metadata
17
- }
18
-
19
- fragment AlignmentFields on Alignment {
20
- folioUuid
21
- toh
22
- tibetan
23
- folioNumber
24
- volumeNumber
25
- }
26
-
27
- fragment PassageWithAnnotations on Passage {
28
- uuid
29
- workUuid
30
- content
31
- label
32
- sort
33
- type
34
- xmlId
35
- annotations {
36
- ...AnnotationFields
37
- }
38
- alignments {
39
- ...AlignmentFields
40
- }
41
- }
42
-
43
- query GetPassages(
44
- $uuid: ID!
45
- $cursor: String
46
- $limit: Int
47
- $direction: PaginationDirection
48
- $filter: PassageFilter
49
- ) {
50
- work(uuid: $uuid) {
51
- uuid
52
- passages(
53
- cursor: $cursor
54
- limit: $limit
55
- direction: $direction
56
- filter: $filter
57
- ) {
58
- nodes {
59
- ...PassageWithAnnotations
60
- }
61
- pageInfo {
62
- nextCursor
63
- prevCursor
64
- hasMoreAfter
65
- hasMoreBefore
66
- }
67
- }
68
- }
69
- }
70
- `;
71
-
72
- type GetPassagesResponse = {
73
- work: {
74
- uuid: string;
75
- passages: {
76
- nodes: Array<{
77
- uuid: string;
78
- workUuid: string;
79
- content: string;
80
- label: string;
81
- sort: number;
82
- type: string;
83
- xmlId?: string | null;
84
- annotations: Array<{
85
- uuid: string;
86
- type: string;
87
- start: number;
88
- end: number;
89
- metadata?: Record<string, unknown> | null;
90
- }>;
91
- alignments: Array<{
92
- folioUuid: string;
93
- toh: string;
94
- tibetan: string;
95
- folioNumber: number;
96
- volumeNumber: number;
97
- }>;
98
- }>;
99
- pageInfo: {
100
- nextCursor?: string | null;
101
- prevCursor?: string | null;
102
- hasMoreAfter: boolean;
103
- hasMoreBefore: boolean;
104
- };
105
- };
106
- } | null;
107
- };
108
-
109
- /**
110
- * Map internal pagination direction to GraphQL enum
111
- */
112
- function mapDirection(
113
- direction?: PaginationDirection,
114
- ): 'FORWARD' | 'BACKWARD' | undefined {
115
- if (!direction) return undefined;
116
- return direction === 'forward' ? 'FORWARD' : 'BACKWARD';
117
- }
118
-
119
- /**
120
- * Get paginated passages for a translation work.
121
- *
122
- * NOTE: maxCharacters is not supported by the GraphQL API yet.
123
- * This parameter is accepted for API compatibility but is ignored.
124
- */
125
- export async function getTranslationPassages({
126
- client,
127
- uuid,
128
- type,
129
- cursor,
130
- maxPassages = 100,
131
- maxCharacters: _maxCharacters,
132
- direction,
133
- }: {
134
- client: GraphQLClient;
135
- uuid: string;
136
- type?: BodyItemType;
137
- cursor?: string;
138
- maxPassages?: number;
139
- maxCharacters?: number;
140
- direction?: PaginationDirection;
141
- }): Promise<PassagesPage> {
142
- try {
143
- const response = await client.request<GetPassagesResponse>(GET_PASSAGES, {
144
- uuid,
145
- cursor,
146
- limit: maxPassages,
147
- direction: mapDirection(direction),
148
- filter: type ? { type } : undefined,
149
- });
150
-
151
- if (!response.work) {
152
- return {
153
- passages: [],
154
- hasMoreAfter: false,
155
- hasMoreBefore: false,
156
- };
157
- }
158
-
159
- return passagesPageFromGraphQL(response.work.passages, response.work.uuid);
160
- } catch (error) {
161
- console.error('Error fetching translation passages:', error);
162
- return {
163
- passages: [],
164
- hasMoreAfter: false,
165
- hasMoreBefore: false,
166
- };
167
- }
168
- }
@@ -1,55 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
- import type { Titles } from '@eightyfourthousand/data-access';
4
- import { titlesFromGraphQL } from '../mappers';
5
-
6
- const GET_WORK_TITLES = gql`
7
- query GetWorkWithTitles($uuid: ID!) {
8
- work(uuid: $uuid) {
9
- titles {
10
- uuid
11
- content
12
- language
13
- type
14
- }
15
- }
16
- }
17
- `;
18
-
19
- type GetWorkTitlesResponse = {
20
- work: {
21
- titles: Array<{
22
- uuid: string;
23
- content: string;
24
- language: string;
25
- type: string;
26
- }>;
27
- } | null;
28
- };
29
-
30
- /**
31
- * Get all titles for a work.
32
- */
33
- export async function getTranslationTitles({
34
- client,
35
- uuid,
36
- }: {
37
- client: GraphQLClient;
38
- uuid: string;
39
- }): Promise<Titles> {
40
- try {
41
- const response = await client.request<GetWorkTitlesResponse>(
42
- GET_WORK_TITLES,
43
- { uuid },
44
- );
45
-
46
- if (!response.work) {
47
- return [];
48
- }
49
-
50
- return titlesFromGraphQL(response.work.titles);
51
- } catch (error) {
52
- console.error('Error fetching translation titles:', error);
53
- return [];
54
- }
55
- }
@@ -1,63 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
-
4
- const DEFAULT_PAGE_SIZE = 200;
5
-
6
- const GET_WORK_UUIDS = gql`
7
- query GetWorkUuids($cursor: String, $limit: Int, $filter: WorkFilter) {
8
- works(cursor: $cursor, limit: $limit, filter: $filter) {
9
- items {
10
- uuid
11
- }
12
- pageInfo {
13
- nextCursor
14
- hasMoreAfter
15
- }
16
- }
17
- }
18
- `;
19
-
20
- type GetWorkUuidsResponse = {
21
- works: {
22
- items: Array<{ uuid: string }>;
23
- pageInfo: {
24
- nextCursor: string | null;
25
- hasMoreAfter: boolean;
26
- };
27
- };
28
- };
29
-
30
- type WorkFilter = {
31
- maxPages?: number;
32
- };
33
-
34
- /**
35
- * Get work UUIDs with optional filtering.
36
- * @param client - GraphQL client
37
- * @param filter - Optional filter criteria (e.g., maxPages)
38
- * @param limit - Optional limit on total results (fetches all pages if not specified)
39
- */
40
- export async function getTranslationUuids({
41
- client,
42
- filter,
43
- limit,
44
- }: {
45
- client: GraphQLClient;
46
- filter?: WorkFilter;
47
- limit?: number;
48
- }): Promise<string[]> {
49
- try {
50
- // Single request - no pagination needed for static params
51
- const response: GetWorkUuidsResponse =
52
- await client.request<GetWorkUuidsResponse>(GET_WORK_UUIDS, {
53
- cursor: null,
54
- limit: limit ?? DEFAULT_PAGE_SIZE,
55
- filter,
56
- });
57
-
58
- return response.works.items.map((w) => w.uuid);
59
- } catch (error) {
60
- console.error('Error fetching translation UUIDs:', error);
61
- return [];
62
- }
63
- }