@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
package/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createGraphQLClient, resetGraphQLClient, setAccessTokenProvider, } from './lib/client';
|
|
2
|
+
export { getPassage, getTranslationBlocks, getTranslationBlocksAround, getTranslationTitles, getTranslationMetadataByUuid, getTranslationMetadataByToh, getTranslationsMetadata, getTranslationUuids, getTranslationToc, getTranslationImprint, getGlossaryInstance, getWorkGlossaryTerms, getWorkGlossaryTermsAround, type GlossaryTermsPage, getTermPassages, type GlossaryPassagesPage, getBibliographyEntry, getWorkBibliography, getWorkFolios, hasPermission, replace, savePassages, type TranslationBlocksPage, type Permission, type ReplaceType, type ReplacedPassage, } from './lib/functions';
|
|
3
|
+
export type { Passage, Passages, PassagesPage, PaginationDirection, BodyItemType, Annotation, Annotations, Alignment, Work, Title, Titles, TitleType, Toc, TocEntry, Imprint, GlossaryTermInstance, GlossaryLandingItem, GlossaryPageItem, BibliographyEntry, BibliographyEntryItem, BibliographyEntries, Folio, } from '@eightyfourthousand/data-access';
|
|
4
|
+
export { BODY_ITEM_TYPES, FRONT_MATTER, FRONT_MATTER_FILTER, BODY_MATTER, BODY_MATTER_FILTER, BACK_MATTER, BACK_MATTER_FILTER, COMPARE_MODE, COMPARE_MODE_FILTER, } from '@eightyfourthousand/data-access';
|
package/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Client
|
|
2
|
+
export { createGraphQLClient, resetGraphQLClient, setAccessTokenProvider, } from './lib/client';
|
|
3
|
+
// Functions
|
|
4
|
+
export { getPassage, getTranslationBlocks, getTranslationBlocksAround, getTranslationTitles, getTranslationMetadataByUuid, getTranslationMetadataByToh, getTranslationsMetadata, getTranslationUuids, getTranslationToc, getTranslationImprint, getGlossaryInstance, getWorkGlossaryTerms, getWorkGlossaryTermsAround, getTermPassages, getBibliographyEntry, getWorkBibliography, getWorkFolios, hasPermission, replace, savePassages, } from './lib/functions';
|
|
5
|
+
// Re-export constants for passage filters
|
|
6
|
+
export { BODY_ITEM_TYPES, FRONT_MATTER, FRONT_MATTER_FILTER, BODY_MATTER, BODY_MATTER_FILTER, BACK_MATTER, BACK_MATTER_FILTER, COMPARE_MODE, COMPARE_MODE_FILTER, } from '@eightyfourthousand/data-access';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/client-graphql/src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY;AACZ,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,2BAA2B,EAC3B,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAE1B,eAAe,EAEf,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,OAAO,EACP,YAAY,GAKb,MAAM,iBAAiB,CAAC;AA4BzB,0CAA0C;AAC1C,OAAO,EACL,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,GACpB,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
/**
|
|
4
|
+
* Create a GraphQL client for server-side requests (SSR/RSC).
|
|
5
|
+
* Reads auth cookies from the request and forwards them to the GraphQL API.
|
|
6
|
+
*
|
|
7
|
+
* Must be called within a Server Component or Server Action context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createServerGraphQLClient(): Promise<GraphQLClient>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a GraphQL client for build-time requests (generateStaticParams).
|
|
12
|
+
* Does not use cookies since there's no request context during builds.
|
|
13
|
+
*
|
|
14
|
+
* Use this in generateStaticParams and other build-time contexts.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createBuildGraphQLClient(): GraphQLClient;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import 'server-only';
|
|
3
|
+
import { GraphQLClient } from 'graphql-request';
|
|
4
|
+
import { cookies } from 'next/headers';
|
|
5
|
+
import { getGraphQLUrl } from './config';
|
|
6
|
+
/**
|
|
7
|
+
* Create a GraphQL client for server-side requests (SSR/RSC).
|
|
8
|
+
* Reads auth cookies from the request and forwards them to the GraphQL API.
|
|
9
|
+
*
|
|
10
|
+
* Must be called within a Server Component or Server Action context.
|
|
11
|
+
*/
|
|
12
|
+
export function createServerGraphQLClient() {
|
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
const url = getGraphQLUrl();
|
|
15
|
+
// Get all cookies from the request
|
|
16
|
+
const cookieStore = yield cookies();
|
|
17
|
+
const allCookies = cookieStore.getAll();
|
|
18
|
+
// Build cookie header string with encoded values to ensure HTTP header compatibility
|
|
19
|
+
// Cookie values may contain non-ASCII characters which are invalid in HTTP headers (ByteString)
|
|
20
|
+
const cookieHeader = allCookies
|
|
21
|
+
.map((cookie) => `${cookie.name}=${encodeURIComponent(cookie.value)}`)
|
|
22
|
+
.join('; ');
|
|
23
|
+
const client = new GraphQLClient(url, {
|
|
24
|
+
headers: Object.assign({}, (cookieHeader ? { cookie: cookieHeader } : {})),
|
|
25
|
+
});
|
|
26
|
+
return client;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a GraphQL client for build-time requests (generateStaticParams).
|
|
31
|
+
* Does not use cookies since there's no request context during builds.
|
|
32
|
+
*
|
|
33
|
+
* Use this in generateStaticParams and other build-time contexts.
|
|
34
|
+
*/
|
|
35
|
+
export function createBuildGraphQLClient() {
|
|
36
|
+
const url = getGraphQLUrl();
|
|
37
|
+
return new GraphQLClient(url);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=client-ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-ssr.js","sourceRoot":"","sources":["../../../../libs/client-graphql/src/lib/client-ssr.ts"],"names":[],"mappings":";AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAgB,yBAAyB;;QAC7C,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;QAE5B,mCAAmC;QACnC,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC;QAExC,qFAAqF;QACrF,gGAAgG;QAChG,MAAM,YAAY,GAAG,UAAU;aAC5B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;aACrE,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,EAAE;YACpC,OAAO,oBAEF,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAClD;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,OAAO,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
package/lib/client.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GraphQLClient } from 'graphql-request';
|
|
2
|
+
/**
|
|
3
|
+
* Set the access token provider function.
|
|
4
|
+
* This should be called once at app initialization.
|
|
5
|
+
*/
|
|
6
|
+
export declare function setAccessTokenProvider(provider: () => Promise<string | null>): void;
|
|
7
|
+
/**
|
|
8
|
+
* Create a GraphQL client for browser-side requests.
|
|
9
|
+
* Uses Authorization header with dynamic token retrieval for cross-domain requests.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createGraphQLClient(): GraphQLClient;
|
|
12
|
+
/**
|
|
13
|
+
* Reset the client instance (useful for testing)
|
|
14
|
+
*/
|
|
15
|
+
export declare function resetGraphQLClient(): void;
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
import { getGraphQLUrl } from './config';
|
|
4
|
+
let clientInstance = null;
|
|
5
|
+
let getAccessToken = null;
|
|
6
|
+
/**
|
|
7
|
+
* Set the access token provider function.
|
|
8
|
+
* This should be called once at app initialization.
|
|
9
|
+
*/
|
|
10
|
+
export function setAccessTokenProvider(provider) {
|
|
11
|
+
getAccessToken = provider;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a GraphQL client for browser-side requests.
|
|
15
|
+
* Uses Authorization header with dynamic token retrieval for cross-domain requests.
|
|
16
|
+
*/
|
|
17
|
+
export function createGraphQLClient() {
|
|
18
|
+
if (clientInstance) {
|
|
19
|
+
return clientInstance;
|
|
20
|
+
}
|
|
21
|
+
const url = getGraphQLUrl();
|
|
22
|
+
clientInstance = new GraphQLClient(url, {
|
|
23
|
+
// Dynamic headers - called on each request
|
|
24
|
+
requestMiddleware: (request) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const headers = {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'apollo-require-preflight': 'true',
|
|
28
|
+
};
|
|
29
|
+
if (getAccessToken) {
|
|
30
|
+
const token = yield getAccessToken();
|
|
31
|
+
if (token) {
|
|
32
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return Object.assign(Object.assign({}, request), { headers });
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
return clientInstance;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Reset the client instance (useful for testing)
|
|
42
|
+
*/
|
|
43
|
+
export function resetGraphQLClient() {
|
|
44
|
+
clientInstance = null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../libs/client-graphql/src/lib/client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,IAAI,cAAc,GAAyB,IAAI,CAAC;AAChD,IAAI,cAAc,GAA0C,IAAI,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAsC;IAEtC,cAAc,GAAG,QAAQ,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAE5B,cAAc,GAAG,IAAI,aAAa,CAAC,GAAG,EAAE;QACtC,2CAA2C;QAC3C,iBAAiB,EAAE,CAAO,OAAO,EAAE,EAAE;YACnC,MAAM,OAAO,GAA2B;gBACtC,cAAc,EAAE,kBAAkB;gBAClC,0BAA0B,EAAE,MAAM;aACnC,CAAC;YAEF,IAAI,cAAc,EAAE,CAAC;gBACnB,MAAM,KAAK,GAAG,MAAM,cAAc,EAAE,CAAC;gBACrC,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE,CAAC;gBAC/C,CAAC;YACH,CAAC;YAED,uCACK,OAAO,KACV,OAAO,IACP;QACJ,CAAC,CAAA;KACF,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
|
package/lib/config.d.ts
ADDED
package/lib/config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL API configuration
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get the GraphQL API URL from environment variables
|
|
6
|
+
* Falls back to localhost for development
|
|
7
|
+
*/
|
|
8
|
+
export function getGraphQLUrl() {
|
|
9
|
+
const url = process.env.NEXT_PUBLIC_GRAPHQL_URL;
|
|
10
|
+
if (!url) {
|
|
11
|
+
// Default to localhost in development
|
|
12
|
+
if (process.env.NODE_ENV === 'development') {
|
|
13
|
+
return 'http://localhost:3001/api/graphql';
|
|
14
|
+
}
|
|
15
|
+
throw new Error('NEXT_PUBLIC_GRAPHQL_URL environment variable is not set');
|
|
16
|
+
}
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../libs/client-graphql/src/lib/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IAEhD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,sCAAsC;QACtC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;YAC3C,OAAO,mCAAmC,CAAC;QAC7C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import type { BibliographyEntryItem } from '@eightyfourthousand/data-access';
|
|
3
|
+
/**
|
|
4
|
+
* Get a single bibliography entry by UUID.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getBibliographyEntry({ client, uuid, }: {
|
|
7
|
+
client: GraphQLClient;
|
|
8
|
+
uuid: string;
|
|
9
|
+
}): Promise<BibliographyEntryItem | null>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { gql } from 'graphql-request';
|
|
3
|
+
const GET_BIBLIOGRAPHY_ENTRY = gql `
|
|
4
|
+
query GetBibliographyEntry($uuid: ID!) {
|
|
5
|
+
bibliographyEntry(uuid: $uuid) {
|
|
6
|
+
uuid
|
|
7
|
+
html
|
|
8
|
+
workUuid
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
/**
|
|
13
|
+
* Get a single bibliography entry by UUID.
|
|
14
|
+
*/
|
|
15
|
+
export function getBibliographyEntry(_a) {
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* ({ client, uuid, }) {
|
|
17
|
+
try {
|
|
18
|
+
const response = yield client.request(GET_BIBLIOGRAPHY_ENTRY, { uuid });
|
|
19
|
+
return response.bibliographyEntry;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Error fetching bibliography entry:', error);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=get-bibliography-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-bibliography-entry.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/functions/get-bibliography-entry.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,MAAM,sBAAsB,GAAG,GAAG,CAAA;;;;;;;;CAQjC,CAAC;AAMF;;GAEG;AACH,MAAM,UAAgB,oBAAoB;yDAAC,EACzC,MAAM,EACN,IAAI,GAIL;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,sBAAsB,EACtB,EAAE,IAAI,EAAE,CACT,CAAC;YAEF,OAAO,QAAQ,CAAC,iBAAiB,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import type { GlossaryTermInstance } from '@eightyfourthousand/data-access';
|
|
3
|
+
/**
|
|
4
|
+
* Get a single glossary instance by UUID.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getGlossaryInstance({ client, uuid, }: {
|
|
7
|
+
client: GraphQLClient;
|
|
8
|
+
uuid: string;
|
|
9
|
+
}): Promise<GlossaryTermInstance | null>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { gql } from 'graphql-request';
|
|
3
|
+
const GET_GLOSSARY_INSTANCE = gql `
|
|
4
|
+
query GetGlossaryInstance($uuid: ID!) {
|
|
5
|
+
glossaryInstance(uuid: $uuid) {
|
|
6
|
+
uuid
|
|
7
|
+
authority
|
|
8
|
+
definition
|
|
9
|
+
names {
|
|
10
|
+
english
|
|
11
|
+
tibetan
|
|
12
|
+
sanskrit
|
|
13
|
+
pali
|
|
14
|
+
chinese
|
|
15
|
+
wylie
|
|
16
|
+
alternatives
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
/**
|
|
22
|
+
* Get a single glossary instance by UUID.
|
|
23
|
+
*/
|
|
24
|
+
export function getGlossaryInstance(_a) {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* ({ client, uuid, }) {
|
|
26
|
+
try {
|
|
27
|
+
const response = yield client.request(GET_GLOSSARY_INSTANCE, { uuid });
|
|
28
|
+
return response.glossaryInstance;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('Error fetching glossary instance:', error);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=get-glossary-instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-glossary-instance.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/functions/get-glossary-instance.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAGtC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;CAiBhC,CAAC;AAMF;;GAEG;AACH,MAAM,UAAgB,mBAAmB;yDAAC,EACxC,MAAM,EACN,IAAI,GAIL;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,qBAAqB,EACrB,EAAE,IAAI,EAAE,CACT,CAAC;YAEF,OAAO,QAAQ,CAAC,gBAAgB,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import type { Passage } from '@eightyfourthousand/data-access';
|
|
3
|
+
/**
|
|
4
|
+
* Get a single passage by UUID or XML ID.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPassage({ client, uuid, xmlId, }: {
|
|
7
|
+
client: GraphQLClient;
|
|
8
|
+
uuid?: string;
|
|
9
|
+
xmlId?: string;
|
|
10
|
+
}): Promise<Passage | undefined>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { gql } from 'graphql-request';
|
|
3
|
+
import { passageFromGraphQL } from '../mappers';
|
|
4
|
+
const GET_PASSAGE = gql `
|
|
5
|
+
fragment AnnotationFields on Annotation {
|
|
6
|
+
uuid
|
|
7
|
+
type
|
|
8
|
+
start
|
|
9
|
+
end
|
|
10
|
+
metadata
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
fragment AlignmentFields on Alignment {
|
|
14
|
+
folioUuid
|
|
15
|
+
toh
|
|
16
|
+
tibetan
|
|
17
|
+
folioNumber
|
|
18
|
+
volumeNumber
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fragment PassageFields on Passage {
|
|
22
|
+
uuid
|
|
23
|
+
workUuid
|
|
24
|
+
content
|
|
25
|
+
label
|
|
26
|
+
sort
|
|
27
|
+
type
|
|
28
|
+
xmlId
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
fragment PassageWithAnnotations on Passage {
|
|
32
|
+
...PassageFields
|
|
33
|
+
annotations {
|
|
34
|
+
...AnnotationFields
|
|
35
|
+
}
|
|
36
|
+
alignments {
|
|
37
|
+
...AlignmentFields
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
query GetPassage($uuid: ID, $xmlId: String) {
|
|
42
|
+
passage(uuid: $uuid, xmlId: $xmlId) {
|
|
43
|
+
...PassageWithAnnotations
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
/**
|
|
48
|
+
* Get a single passage by UUID or XML ID.
|
|
49
|
+
*/
|
|
50
|
+
export function getPassage(_a) {
|
|
51
|
+
return __awaiter(this, arguments, void 0, function* ({ client, uuid, xmlId, }) {
|
|
52
|
+
try {
|
|
53
|
+
const response = yield client.request(GET_PASSAGE, {
|
|
54
|
+
uuid,
|
|
55
|
+
xmlId,
|
|
56
|
+
});
|
|
57
|
+
if (!response.passage) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
return passageFromGraphQL(response.passage);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error('Error fetching passage:', error);
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=get-passage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-passage.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/functions/get-passage.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CtB,CAAC;AAMF;;GAEG;AACH,MAAM,UAAgB,UAAU;yDAAC,EAC/B,MAAM,EACN,IAAI,EACJ,KAAK,GAKN;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAqB,WAAW,EAAE;gBACrE,IAAI;gBACJ,KAAK;aACN,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACtB,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,OAAO,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;YAChD,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
export type GlossaryPassagesPage = {
|
|
3
|
+
items: Array<{
|
|
4
|
+
uuid: string;
|
|
5
|
+
type: string;
|
|
6
|
+
label: string;
|
|
7
|
+
sort: number;
|
|
8
|
+
}>;
|
|
9
|
+
nextCursor: string | null;
|
|
10
|
+
hasMore: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Fetch a page of passage references for a single glossary term instance.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getTermPassages({ client, uuid, first, after, }: {
|
|
16
|
+
client: GraphQLClient;
|
|
17
|
+
uuid: string;
|
|
18
|
+
first?: number;
|
|
19
|
+
after?: string;
|
|
20
|
+
}): Promise<GlossaryPassagesPage>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { gql } from 'graphql-request';
|
|
3
|
+
const GET_TERM_PASSAGES = gql `
|
|
4
|
+
query GetTermPassages($uuid: ID!, $first: Int, $after: String) {
|
|
5
|
+
glossaryTermPassages(uuid: $uuid, first: $first, after: $after) {
|
|
6
|
+
items {
|
|
7
|
+
uuid
|
|
8
|
+
type
|
|
9
|
+
label
|
|
10
|
+
sort
|
|
11
|
+
}
|
|
12
|
+
nextCursor
|
|
13
|
+
hasMore
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch a page of passage references for a single glossary term instance.
|
|
19
|
+
*/
|
|
20
|
+
export function getTermPassages(_a) {
|
|
21
|
+
return __awaiter(this, arguments, void 0, function* ({ client, uuid, first = 10, after, }) {
|
|
22
|
+
try {
|
|
23
|
+
const response = yield client.request(GET_TERM_PASSAGES, { uuid, first, after });
|
|
24
|
+
return response.glossaryTermPassages;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('Error fetching term passages:', error);
|
|
28
|
+
return { items: [], nextCursor: null, hasMore: false };
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=get-term-passages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-term-passages.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/functions/get-term-passages.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAa5B,CAAC;AAYF;;GAEG;AACH,MAAM,UAAgB,eAAe;yDAAC,EACpC,MAAM,EACN,IAAI,EACJ,KAAK,GAAG,EAAE,EACV,KAAK,GAMN;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,iBAAiB,EACjB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CACvB,CAAC;YACF,OAAO,QAAQ,CAAC,oBAAoB,CAAC;QACvC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import type { BodyItemType } from '@eightyfourthousand/data-access';
|
|
3
|
+
import type { TranslationBlocksPage } from './get-translation-blocks';
|
|
4
|
+
/**
|
|
5
|
+
* Get translation blocks (TipTap JSON) around a specific passage UUID.
|
|
6
|
+
*
|
|
7
|
+
* Returns pre-transformed TipTap editor blocks ready for rendering.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTranslationBlocksAround({ client, uuid, passageUuid, type, maxPassages, }: {
|
|
10
|
+
client: GraphQLClient;
|
|
11
|
+
uuid: string;
|
|
12
|
+
passageUuid: string;
|
|
13
|
+
type?: BodyItemType | string;
|
|
14
|
+
maxPassages?: number;
|
|
15
|
+
}): Promise<TranslationBlocksPage>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { gql } from 'graphql-request';
|
|
3
|
+
const GET_PASSAGES_AROUND_WITH_JSON = gql `
|
|
4
|
+
fragment PassageWithJson on Passage {
|
|
5
|
+
uuid
|
|
6
|
+
workUuid
|
|
7
|
+
label
|
|
8
|
+
sort
|
|
9
|
+
type
|
|
10
|
+
xmlId
|
|
11
|
+
json
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
query GetPassagesAroundWithJson(
|
|
15
|
+
$uuid: ID!
|
|
16
|
+
$cursor: String!
|
|
17
|
+
$limit: Int
|
|
18
|
+
$filter: PassageFilter
|
|
19
|
+
) {
|
|
20
|
+
work(uuid: $uuid) {
|
|
21
|
+
uuid
|
|
22
|
+
passages(
|
|
23
|
+
cursor: $cursor
|
|
24
|
+
limit: $limit
|
|
25
|
+
direction: AROUND
|
|
26
|
+
filter: $filter
|
|
27
|
+
) {
|
|
28
|
+
nodes {
|
|
29
|
+
...PassageWithJson
|
|
30
|
+
}
|
|
31
|
+
pageInfo {
|
|
32
|
+
nextCursor
|
|
33
|
+
prevCursor
|
|
34
|
+
hasMoreAfter
|
|
35
|
+
hasMoreBefore
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
/**
|
|
42
|
+
* Get translation blocks (TipTap JSON) around a specific passage UUID.
|
|
43
|
+
*
|
|
44
|
+
* Returns pre-transformed TipTap editor blocks ready for rendering.
|
|
45
|
+
*/
|
|
46
|
+
export function getTranslationBlocksAround(_a) {
|
|
47
|
+
return __awaiter(this, arguments, void 0, function* ({ client, uuid, passageUuid, type, maxPassages, }) {
|
|
48
|
+
var _b, _c;
|
|
49
|
+
try {
|
|
50
|
+
const response = yield client.request(GET_PASSAGES_AROUND_WITH_JSON, {
|
|
51
|
+
uuid,
|
|
52
|
+
cursor: passageUuid,
|
|
53
|
+
limit: maxPassages,
|
|
54
|
+
filter: type ? { type } : undefined,
|
|
55
|
+
});
|
|
56
|
+
if (!response.work) {
|
|
57
|
+
return {
|
|
58
|
+
blocks: [],
|
|
59
|
+
hasMoreAfter: false,
|
|
60
|
+
hasMoreBefore: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const { passages } = response.work;
|
|
64
|
+
// Extract the JSON blocks, filtering out any null values
|
|
65
|
+
const blocks = passages.nodes
|
|
66
|
+
.map((node) => node.json)
|
|
67
|
+
.filter((json) => json != null);
|
|
68
|
+
return {
|
|
69
|
+
blocks,
|
|
70
|
+
nextCursor: (_b = passages.pageInfo.nextCursor) !== null && _b !== void 0 ? _b : undefined,
|
|
71
|
+
prevCursor: (_c = passages.pageInfo.prevCursor) !== null && _c !== void 0 ? _c : undefined,
|
|
72
|
+
hasMoreAfter: passages.pageInfo.hasMoreAfter,
|
|
73
|
+
hasMoreBefore: passages.pageInfo.hasMoreBefore,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('Error fetching translation blocks around:', error);
|
|
78
|
+
return {
|
|
79
|
+
blocks: [],
|
|
80
|
+
hasMoreAfter: false,
|
|
81
|
+
hasMoreBefore: false,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=get-translation-blocks-around.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-translation-blocks-around.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/functions/get-translation-blocks-around.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAItC,MAAM,6BAA6B,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCxC,CAAC;AA2BF;;;;GAIG;AACH,MAAM,UAAgB,0BAA0B;yDAAC,EAC/C,MAAM,EACN,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,WAAW,GAOZ;;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,6BAA6B,EAC7B;gBACE,IAAI;gBACJ,MAAM,EAAE,WAAW;gBACnB,KAAK,EAAE,WAAW;gBAClB,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;aACpC,CACF,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnB,OAAO;oBACL,MAAM,EAAE,EAAE;oBACV,YAAY,EAAE,KAAK;oBACnB,aAAa,EAAE,KAAK;iBACrB,CAAC;YACJ,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC;YAEnC,yDAAyD;YACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK;iBAC1B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;iBACxB,MAAM,CAAC,CAAC,IAAI,EAAwC,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;YAExE,OAAO;gBACL,MAAM;gBACN,UAAU,EAAE,MAAA,QAAQ,CAAC,QAAQ,CAAC,UAAU,mCAAI,SAAS;gBACrD,UAAU,EAAE,MAAA,QAAQ,CAAC,QAAQ,CAAC,UAAU,mCAAI,SAAS;gBACrD,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,YAAY;gBAC5C,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,aAAa;aAC/C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAC;YAClE,OAAO;gBACL,MAAM,EAAE,EAAE;gBACV,YAAY,EAAE,KAAK;gBACnB,aAAa,EAAE,KAAK;aACrB,CAAC;QACJ,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GraphQLClient } from 'graphql-request';
|
|
2
|
+
import type { BodyItemType, PaginationDirection, TranslationEditorContent } from '@eightyfourthousand/data-access';
|
|
3
|
+
/**
|
|
4
|
+
* Result of fetching translation blocks with pagination info
|
|
5
|
+
*/
|
|
6
|
+
export type TranslationBlocksPage = {
|
|
7
|
+
blocks: TranslationEditorContent;
|
|
8
|
+
nextCursor?: string;
|
|
9
|
+
prevCursor?: string;
|
|
10
|
+
hasMoreAfter: boolean;
|
|
11
|
+
hasMoreBefore: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Get paginated translation blocks (TipTap JSON) for a work.
|
|
15
|
+
*
|
|
16
|
+
* Returns pre-transformed TipTap editor blocks ready for rendering.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getTranslationBlocks({ client, uuid, type, cursor, maxPassages, direction, }: {
|
|
19
|
+
client: GraphQLClient;
|
|
20
|
+
uuid: string;
|
|
21
|
+
type?: BodyItemType | string;
|
|
22
|
+
cursor?: string;
|
|
23
|
+
maxPassages?: number;
|
|
24
|
+
direction?: PaginationDirection;
|
|
25
|
+
}): Promise<TranslationBlocksPage>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { gql } from 'graphql-request';
|
|
3
|
+
const GET_PASSAGES_WITH_JSON = gql `
|
|
4
|
+
fragment PassageWithJson on Passage {
|
|
5
|
+
uuid
|
|
6
|
+
workUuid
|
|
7
|
+
label
|
|
8
|
+
sort
|
|
9
|
+
type
|
|
10
|
+
xmlId
|
|
11
|
+
json
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
query GetPassagesWithJson(
|
|
15
|
+
$uuid: ID!
|
|
16
|
+
$cursor: String
|
|
17
|
+
$limit: Int
|
|
18
|
+
$direction: PaginationDirection
|
|
19
|
+
$filter: PassageFilter
|
|
20
|
+
) {
|
|
21
|
+
work(uuid: $uuid) {
|
|
22
|
+
uuid
|
|
23
|
+
passages(
|
|
24
|
+
cursor: $cursor
|
|
25
|
+
limit: $limit
|
|
26
|
+
direction: $direction
|
|
27
|
+
filter: $filter
|
|
28
|
+
) {
|
|
29
|
+
nodes {
|
|
30
|
+
...PassageWithJson
|
|
31
|
+
}
|
|
32
|
+
pageInfo {
|
|
33
|
+
nextCursor
|
|
34
|
+
prevCursor
|
|
35
|
+
hasMoreAfter
|
|
36
|
+
hasMoreBefore
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
/**
|
|
43
|
+
* Map internal pagination direction to GraphQL enum
|
|
44
|
+
*/
|
|
45
|
+
function mapDirection(direction) {
|
|
46
|
+
if (!direction)
|
|
47
|
+
return undefined;
|
|
48
|
+
return direction === 'forward' ? 'FORWARD' : 'BACKWARD';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get paginated translation blocks (TipTap JSON) for a work.
|
|
52
|
+
*
|
|
53
|
+
* Returns pre-transformed TipTap editor blocks ready for rendering.
|
|
54
|
+
*/
|
|
55
|
+
export function getTranslationBlocks(_a) {
|
|
56
|
+
return __awaiter(this, arguments, void 0, function* ({ client, uuid, type, cursor, maxPassages = 100, direction, }) {
|
|
57
|
+
var _b, _c;
|
|
58
|
+
try {
|
|
59
|
+
const response = yield client.request(GET_PASSAGES_WITH_JSON, {
|
|
60
|
+
uuid,
|
|
61
|
+
cursor,
|
|
62
|
+
limit: maxPassages,
|
|
63
|
+
direction: mapDirection(direction),
|
|
64
|
+
filter: type ? { type } : undefined,
|
|
65
|
+
});
|
|
66
|
+
if (!response.work) {
|
|
67
|
+
return {
|
|
68
|
+
blocks: [],
|
|
69
|
+
hasMoreAfter: false,
|
|
70
|
+
hasMoreBefore: false,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const { passages } = response.work;
|
|
74
|
+
// Extract the JSON blocks, filtering out any null values
|
|
75
|
+
const blocks = passages.nodes
|
|
76
|
+
.map((node) => node.json)
|
|
77
|
+
.filter((json) => json != null);
|
|
78
|
+
return {
|
|
79
|
+
blocks,
|
|
80
|
+
nextCursor: (_b = passages.pageInfo.nextCursor) !== null && _b !== void 0 ? _b : undefined,
|
|
81
|
+
prevCursor: (_c = passages.pageInfo.prevCursor) !== null && _c !== void 0 ? _c : undefined,
|
|
82
|
+
hasMoreAfter: passages.pageInfo.hasMoreAfter,
|
|
83
|
+
hasMoreBefore: passages.pageInfo.hasMoreBefore,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error('Error fetching translation blocks:', error);
|
|
88
|
+
return {
|
|
89
|
+
blocks: [],
|
|
90
|
+
hasMoreAfter: false,
|
|
91
|
+
hasMoreBefore: false,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=get-translation-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-translation-blocks.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/functions/get-translation-blocks.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAQtC,MAAM,sBAAsB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCjC,CAAC;AAsCF;;GAEG;AACH,SAAS,YAAY,CACnB,SAA+B;IAE/B,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACjC,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAgB,oBAAoB;yDAAC,EACzC,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,WAAW,GAAG,GAAG,EACjB,SAAS,GAQV;;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,sBAAsB,EACtB;gBACE,IAAI;gBACJ,MAAM;gBACN,KAAK,EAAE,WAAW;gBAClB,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC;gBAClC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;aACpC,CACF,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnB,OAAO;oBACL,MAAM,EAAE,EAAE;oBACV,YAAY,EAAE,KAAK;oBACnB,aAAa,EAAE,KAAK;iBACrB,CAAC;YACJ,CAAC;YAED,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC;YAEnC,yDAAyD;YACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK;iBAC1B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;iBACxB,MAAM,CAAC,CAAC,IAAI,EAAwC,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;YAExE,OAAO;gBACL,MAAM;gBACN,UAAU,EAAE,MAAA,QAAQ,CAAC,QAAQ,CAAC,UAAU,mCAAI,SAAS;gBACrD,UAAU,EAAE,MAAA,QAAQ,CAAC,QAAQ,CAAC,UAAU,mCAAI,SAAS;gBACrD,YAAY,EAAE,QAAQ,CAAC,QAAQ,CAAC,YAAY;gBAC5C,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,aAAa;aAC/C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;YAC3D,OAAO;gBACL,MAAM,EAAE,EAAE;gBACV,YAAY,EAAE,KAAK;gBACnB,aAAa,EAAE,KAAK;aACrB,CAAC;QACJ,CAAC;IACH,CAAC;CAAA"}
|