@eightyfourthousand/client-graphql 2026.4.0 → 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 (149) 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} +3 -12
  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 -75
  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-instance.ts +0 -49
  112. package/src/lib/functions/get-passage.ts +0 -81
  113. package/src/lib/functions/get-term-passages.ts +0 -53
  114. package/src/lib/functions/get-translation-blocks-around.ts +0 -129
  115. package/src/lib/functions/get-translation-blocks.ts +0 -158
  116. package/src/lib/functions/get-translation-imprint.ts +0 -114
  117. package/src/lib/functions/get-translation-metadata.ts +0 -99
  118. package/src/lib/functions/get-translation-titles.ts +0 -55
  119. package/src/lib/functions/get-translation-uuids.ts +0 -63
  120. package/src/lib/functions/get-translations-metadata.ts +0 -81
  121. package/src/lib/functions/get-work-bibliography.ts +0 -47
  122. package/src/lib/functions/get-work-folios.ts +0 -52
  123. package/src/lib/functions/get-work-glossary-terms-around.ts +0 -127
  124. package/src/lib/functions/get-work-glossary-terms.ts +0 -154
  125. package/src/lib/functions/has-permission.ts +0 -38
  126. package/src/lib/functions/replace.ts +0 -91
  127. package/src/lib/functions/save-passages.ts +0 -76
  128. package/src/lib/generated/graphql.ts +0 -1297
  129. package/src/lib/graphql/fragments/alignment.graphql +0 -7
  130. package/src/lib/graphql/fragments/annotation.graphql +0 -7
  131. package/src/lib/graphql/fragments/imprint.graphql +0 -34
  132. package/src/lib/graphql/fragments/passage.graphql +0 -29
  133. package/src/lib/graphql/fragments/title.graphql +0 -6
  134. package/src/lib/graphql/fragments/toc.graphql +0 -40
  135. package/src/lib/graphql/fragments/work.graphql +0 -10
  136. package/src/lib/graphql/queries/passages.graphql +0 -116
  137. package/src/lib/graphql/queries/work.graphql +0 -38
  138. package/src/lib/graphql/queries/works.graphql +0 -23
  139. package/src/lib/mappers/alignment.ts +0 -34
  140. package/src/lib/mappers/annotation.ts +0 -204
  141. package/src/lib/mappers/imprint.ts +0 -79
  142. package/src/lib/mappers/passage.ts +0 -80
  143. package/src/lib/mappers/title.ts +0 -35
  144. package/src/lib/mappers/toc.ts +0 -49
  145. package/src/lib/mappers/work.ts +0 -38
  146. package/src/ssr.ts +0 -66
  147. package/tsconfig.json +0 -17
  148. package/tsconfig.lib.json +0 -14
  149. /package/{src/lib/mappers/index.ts → lib/mappers/index.d.ts} +0 -0
@@ -0,0 +1,39 @@
1
+ import { annotationsFromGraphQL } from './annotation';
2
+ import { alignmentsFromGraphQL } from './alignment';
3
+ /**
4
+ * Convert a GraphQL passage to the internal Passage type
5
+ */
6
+ export function passageFromGraphQL(gqlPassage, workUuid) {
7
+ var _a, _b, _c;
8
+ const annotations = gqlPassage.annotations
9
+ ? annotationsFromGraphQL(gqlPassage.annotations, gqlPassage.uuid)
10
+ : [];
11
+ const alignments = gqlPassage.alignments
12
+ ? alignmentsFromGraphQL(gqlPassage.alignments)
13
+ : [];
14
+ return {
15
+ uuid: gqlPassage.uuid,
16
+ content: gqlPassage.content,
17
+ label: gqlPassage.label,
18
+ sort: gqlPassage.sort,
19
+ type: gqlPassage.type,
20
+ xmlId: (_a = gqlPassage.xmlId) !== null && _a !== void 0 ? _a : undefined,
21
+ workUuid: (_c = (_b = gqlPassage.workUuid) !== null && _b !== void 0 ? _b : workUuid) !== null && _c !== void 0 ? _c : '',
22
+ annotations,
23
+ alignments,
24
+ };
25
+ }
26
+ /**
27
+ * Convert a GraphQL PassageConnection to internal PassagesPage type
28
+ */
29
+ export function passagesPageFromGraphQL(connection, workUuid) {
30
+ var _a, _b;
31
+ return {
32
+ passages: connection.nodes.map((p) => passageFromGraphQL(p, workUuid)),
33
+ nextCursor: (_a = connection.pageInfo.nextCursor) !== null && _a !== void 0 ? _a : undefined,
34
+ prevCursor: (_b = connection.pageInfo.prevCursor) !== null && _b !== void 0 ? _b : undefined,
35
+ hasMoreAfter: connection.pageInfo.hasMoreAfter,
36
+ hasMoreBefore: connection.pageInfo.hasMoreBefore,
37
+ };
38
+ }
39
+ //# sourceMappingURL=passage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passage.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/mappers/passage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAA0B,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAyB,MAAM,aAAa,CAAC;AAmC3E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA0B,EAC1B,QAAiB;;IAEjB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW;QACxC,CAAC,CAAC,sBAAsB,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC;QACjE,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU;QACtC,CAAC,CAAC,qBAAqB,CAAC,UAAU,CAAC,UAAU,CAAC;QAC9C,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,UAAU,CAAC,IAAoB;QACrC,KAAK,EAAE,MAAA,UAAU,CAAC,KAAK,mCAAI,SAAS;QACpC,QAAQ,EAAE,MAAA,MAAA,UAAU,CAAC,QAAQ,mCAAI,QAAQ,mCAAI,EAAE;QAC/C,WAAW;QACX,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAAoC,EACpC,QAAgB;;IAEhB,OAAO;QACL,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QACtE,UAAU,EAAE,MAAA,UAAU,CAAC,QAAQ,CAAC,UAAU,mCAAI,SAAS;QACvD,UAAU,EAAE,MAAA,UAAU,CAAC,QAAQ,CAAC,UAAU,mCAAI,SAAS;QACvD,YAAY,EAAE,UAAU,CAAC,QAAQ,CAAC,YAAY;QAC9C,aAAa,EAAE,UAAU,CAAC,QAAQ,CAAC,aAAa;KACjD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Title, Titles } from '@eightyfourthousand/data-access';
2
+ /**
3
+ * GraphQL Title type
4
+ */
5
+ export type GraphQLTitle = {
6
+ uuid: string;
7
+ content: string;
8
+ language: string;
9
+ type: string;
10
+ };
11
+ /**
12
+ * Convert a GraphQL title to the internal Title type
13
+ */
14
+ export declare function titleFromGraphQL(gqlTitle: GraphQLTitle): Title;
15
+ /**
16
+ * Convert an array of GraphQL titles to internal Title types
17
+ */
18
+ export declare function titlesFromGraphQL(gqlTitles: GraphQLTitle[]): Titles;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Convert a GraphQL title to the internal Title type
3
+ */
4
+ export function titleFromGraphQL(gqlTitle) {
5
+ return {
6
+ uuid: gqlTitle.uuid,
7
+ title: gqlTitle.content,
8
+ language: gqlTitle.language,
9
+ type: gqlTitle.type,
10
+ };
11
+ }
12
+ /**
13
+ * Convert an array of GraphQL titles to internal Title types
14
+ */
15
+ export function titlesFromGraphQL(gqlTitles) {
16
+ return gqlTitles.map(titleFromGraphQL);
17
+ }
18
+ //# sourceMappingURL=title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/mappers/title.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAsB;IACrD,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,OAAO;QACvB,QAAQ,EAAE,QAAQ,CAAC,QAAuC;QAC1D,IAAI,EAAE,QAAQ,CAAC,IAAiB;KACjC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAyB;IACzD,OAAO,SAAS,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { Toc } from '@eightyfourthousand/data-access';
2
+ /**
3
+ * GraphQL TocEntry type
4
+ */
5
+ export type GraphQLTocEntry = {
6
+ uuid: string;
7
+ content: string;
8
+ label?: string | null;
9
+ sort: number;
10
+ level: number;
11
+ section: string;
12
+ children?: GraphQLTocEntry[] | null;
13
+ };
14
+ /**
15
+ * GraphQL Toc type
16
+ */
17
+ export type GraphQLToc = {
18
+ frontMatter: GraphQLTocEntry[];
19
+ body: GraphQLTocEntry[];
20
+ backMatter: GraphQLTocEntry[];
21
+ };
22
+ /**
23
+ * Convert a GraphQL Toc to the internal Toc type
24
+ */
25
+ export declare function tocFromGraphQL(gqlToc: GraphQLToc): Toc;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Convert a GraphQL TocEntry to the internal TocEntry type
3
+ */
4
+ function tocEntryFromGraphQL(gqlEntry) {
5
+ return {
6
+ uuid: gqlEntry.uuid,
7
+ content: gqlEntry.content,
8
+ label: gqlEntry.label || undefined,
9
+ sort: gqlEntry.sort,
10
+ level: gqlEntry.level,
11
+ section: gqlEntry.section,
12
+ children: (gqlEntry.children || []).map(tocEntryFromGraphQL),
13
+ };
14
+ }
15
+ /**
16
+ * Convert a GraphQL Toc to the internal Toc type
17
+ */
18
+ export function tocFromGraphQL(gqlToc) {
19
+ return {
20
+ frontMatter: gqlToc.frontMatter.map(tocEntryFromGraphQL),
21
+ body: gqlToc.body.map(tocEntryFromGraphQL),
22
+ backMatter: gqlToc.backMatter.map(tocEntryFromGraphQL),
23
+ };
24
+ }
25
+ //# sourceMappingURL=toc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/mappers/toc.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAyB;IACpD,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,SAAS;QAClC,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,OAAO,EAAE,QAAQ,CAAC,OAA6B;QAC/C,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAkB;IAC/C,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,mBAAmB,CAAC;QACxD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAC1C,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,mBAAmB,CAAC;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Work } from '@eightyfourthousand/data-access';
2
+ /**
3
+ * GraphQL Work type
4
+ */
5
+ export type GraphQLWork = {
6
+ uuid: string;
7
+ title: string;
8
+ toh: string[];
9
+ publicationDate: string;
10
+ publicationVersion: string;
11
+ pages: number;
12
+ restriction: boolean;
13
+ section: string;
14
+ };
15
+ /**
16
+ * Convert a GraphQL work to the internal Work type
17
+ */
18
+ export declare function workFromGraphQL(gqlWork: GraphQLWork): Work;
19
+ /**
20
+ * Convert an array of GraphQL works to internal Work types
21
+ */
22
+ export declare function worksFromGraphQL(gqlWorks: GraphQLWork[]): Work[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Convert a GraphQL work to the internal Work type
3
+ */
4
+ export function workFromGraphQL(gqlWork) {
5
+ return {
6
+ uuid: gqlWork.uuid,
7
+ title: gqlWork.title,
8
+ toh: gqlWork.toh,
9
+ publicationDate: new Date(gqlWork.publicationDate),
10
+ publicationVersion: gqlWork.publicationVersion,
11
+ pages: gqlWork.pages,
12
+ restriction: gqlWork.restriction,
13
+ section: gqlWork.section,
14
+ };
15
+ }
16
+ /**
17
+ * Convert an array of GraphQL works to internal Work types
18
+ */
19
+ export function worksFromGraphQL(gqlWorks) {
20
+ return gqlWorks.map(workFromGraphQL);
21
+ }
22
+ //# sourceMappingURL=work.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"work.js","sourceRoot":"","sources":["../../../../../libs/client-graphql/src/lib/mappers/work.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAAoB;IAClD,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,GAAG,EAAE,OAAO,CAAC,GAA2B;QACxC,eAAe,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClD,kBAAkB,EAAE,OAAO,CAAC,kBAA4B;QACxD,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAuB;IACtD,OAAO,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eightyfourthousand/client-graphql",
3
- "version": "2026.4.0",
3
+ "version": "2026.4.1",
4
4
  "description": "GraphQL client helpers and typed query functions for 84000 applications.",
5
5
  "private": false,
6
6
  "repository": {
@@ -17,9 +17,31 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@eightyfourthousand/data-access": "^2026.3.1"
20
+ "@eightyfourthousand/data-access": "^2026.4.1",
21
+ "graphql-request": "^7.1.2",
22
+ "graphql-tag": "^2.12.6"
23
+ },
24
+ "peerDependencies": {
25
+ "next": "^16.0.0"
26
+ },
27
+ "type": "module",
28
+ "main": "./index.js",
29
+ "module": "./index.js",
30
+ "types": "./index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./index.d.ts",
34
+ "import": "./index.js",
35
+ "default": "./index.js"
36
+ },
37
+ "./ssr": {
38
+ "types": "./ssr.d.ts",
39
+ "import": "./ssr.js",
40
+ "default": "./ssr.js"
41
+ },
42
+ "./package.json": "./package.json"
21
43
  },
22
44
  "sideEffects": false,
23
45
  "keywords": [],
24
46
  "author": ""
25
- }
47
+ }
package/ssr.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { createServerGraphQLClient, createBuildGraphQLClient, } from './lib/client-ssr';
2
+ export { getPassage, getTranslationBlocks, getTranslationBlocksAround, getTranslationTitles, getTranslationMetadataByUuid, getTranslationMetadataByToh, getTranslationsMetadata, getTranslationUuids, getTranslationToc, getTranslationImprint, getGlossaryInstance, getWorkGlossaryTerms, getWorkGlossaryTermsAround, type GlossaryTermsPage, getBibliographyEntry, getWorkBibliography, getWorkFolios, type TranslationBlocksPage, } 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/ssr.js ADDED
@@ -0,0 +1,7 @@
1
+ // SSR Client
2
+ export { createServerGraphQLClient, createBuildGraphQLClient, } from './lib/client-ssr';
3
+ // Functions (same as browser)
4
+ export { getPassage, getTranslationBlocks, getTranslationBlocksAround, getTranslationTitles, getTranslationMetadataByUuid, getTranslationMetadataByToh, getTranslationsMetadata, getTranslationUuids, getTranslationToc, getTranslationImprint, getGlossaryInstance, getWorkGlossaryTerms, getWorkGlossaryTermsAround, getBibliographyEntry, getWorkBibliography, getWorkFolios, } 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=ssr.js.map
package/ssr.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr.js","sourceRoot":"","sources":["../../../libs/client-graphql/src/ssr.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,8BAA8B;AAC9B,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,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,GAEd,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"}
package/README.md DELETED
@@ -1,9 +0,0 @@
1
- # @eightyfourthousand/client-graphql
2
-
3
- GraphQL client helpers and typed query functions for 84000 applications.
4
-
5
- Use this package for shared GraphQL request helpers, typed query access, and response mappers used by the frontend apps.
6
-
7
- ## Running unit tests
8
-
9
- Run `nx test client-graphql` to execute the unit tests via [Jest](https://jestjs.io).
package/codegen.ts DELETED
@@ -1,34 +0,0 @@
1
- import type { CodegenConfig } from '@graphql-codegen/cli';
2
- import { join } from 'path';
3
-
4
- // Resolve paths from repo root
5
- const repoRoot = join(__dirname, '../..');
6
- const schemaPath = join(repoRoot, 'apps/api-graphql/src/graphql/schema/**/*.graphql');
7
- const documentsPath = join(__dirname, 'src/lib/graphql/**/*.graphql');
8
- const outputPath = join(__dirname, 'src/lib/generated/graphql.ts');
9
-
10
- const config: CodegenConfig = {
11
- schema: schemaPath,
12
- documents: documentsPath,
13
- generates: {
14
- [outputPath]: {
15
- plugins: [
16
- 'typescript',
17
- 'typescript-operations',
18
- 'typescript-graphql-request',
19
- ],
20
- config: {
21
- rawRequest: false,
22
- inlineFragmentTypes: 'combine',
23
- skipTypename: false,
24
- exportFragmentSpreadSubTypes: true,
25
- dedupeFragments: true,
26
- enumsAsTypes: true,
27
- useTypeImports: true,
28
- },
29
- },
30
- },
31
- ignoreNoDocuments: false,
32
- };
33
-
34
- export default config;
package/project.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "name": "client-graphql",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "libs/client-graphql/src",
5
- "projectType": "library",
6
- "tags": [],
7
- "targets": {
8
- "build": {
9
- "executor": "@nx/js:tsc",
10
- "outputs": ["{options.outputPath}"],
11
- "options": {
12
- "outputPath": "dist/libs/client-graphql",
13
- "main": "libs/client-graphql/src/index.ts",
14
- "tsConfig": "libs/client-graphql/tsconfig.lib.json",
15
- "rootDir": "libs/client-graphql/src",
16
- "generateExportsField": true,
17
- "additionalEntryPoints": ["libs/client-graphql/src/ssr.ts"]
18
- }
19
- }
20
- }
21
- }
package/src/index.ts DELETED
@@ -1,75 +0,0 @@
1
- // Client
2
- export {
3
- createGraphQLClient,
4
- resetGraphQLClient,
5
- setAccessTokenProvider,
6
- } from './lib/client';
7
-
8
- // Functions
9
- export {
10
- getPassage,
11
- getTranslationBlocks,
12
- getTranslationBlocksAround,
13
- getTranslationTitles,
14
- getTranslationMetadataByUuid,
15
- getTranslationMetadataByToh,
16
- getTranslationsMetadata,
17
- getTranslationUuids,
18
- getTranslationToc,
19
- getTranslationImprint,
20
- getGlossaryInstance,
21
- getWorkGlossaryTerms,
22
- getWorkGlossaryTermsAround,
23
- type GlossaryTermsPage,
24
- getTermPassages,
25
- type GlossaryPassagesPage,
26
- getBibliographyEntry,
27
- getWorkBibliography,
28
- getWorkFolios,
29
- hasPermission,
30
- replace,
31
- savePassages,
32
- type TranslationBlocksPage,
33
- type Permission,
34
- type ReplaceType,
35
- type ReplacedPassage,
36
- } from './lib/functions';
37
-
38
- // Re-export types from @eightyfourthousand/data-access for convenience
39
- export type {
40
- Passage,
41
- Passages,
42
- PassagesPage,
43
- PaginationDirection,
44
- BodyItemType,
45
- Annotation,
46
- Annotations,
47
- Alignment,
48
- Work,
49
- Title,
50
- Titles,
51
- TitleType,
52
- Toc,
53
- TocEntry,
54
- Imprint,
55
- GlossaryTermInstance,
56
- GlossaryLandingItem,
57
- GlossaryPageItem,
58
- BibliographyEntry,
59
- BibliographyEntryItem,
60
- BibliographyEntries,
61
- Folio,
62
- } from '@eightyfourthousand/data-access';
63
-
64
- // Re-export constants for passage filters
65
- export {
66
- BODY_ITEM_TYPES,
67
- FRONT_MATTER,
68
- FRONT_MATTER_FILTER,
69
- BODY_MATTER,
70
- BODY_MATTER_FILTER,
71
- BACK_MATTER,
72
- BACK_MATTER_FILTER,
73
- COMPARE_MODE,
74
- COMPARE_MODE_FILTER,
75
- } from '@eightyfourthousand/data-access';
@@ -1,44 +0,0 @@
1
- import 'server-only';
2
- import { GraphQLClient } from 'graphql-request';
3
- import { cookies } from 'next/headers';
4
- import { getGraphQLUrl } from './config';
5
-
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 async function createServerGraphQLClient(): Promise<GraphQLClient> {
13
- const url = getGraphQLUrl();
14
-
15
- // Get all cookies from the request
16
- const cookieStore = await cookies();
17
- const allCookies = cookieStore.getAll();
18
-
19
- // Build cookie header string with encoded values to ensure HTTP header compatibility
20
- // Cookie values may contain non-ASCII characters which are invalid in HTTP headers (ByteString)
21
- const cookieHeader = allCookies
22
- .map((cookie) => `${cookie.name}=${encodeURIComponent(cookie.value)}`)
23
- .join('; ');
24
-
25
- const client = new GraphQLClient(url, {
26
- headers: {
27
- // Forward cookies for authentication
28
- ...(cookieHeader ? { cookie: cookieHeader } : {}),
29
- },
30
- });
31
-
32
- return client;
33
- }
34
-
35
- /**
36
- * Create a GraphQL client for build-time requests (generateStaticParams).
37
- * Does not use cookies since there's no request context during builds.
38
- *
39
- * Use this in generateStaticParams and other build-time contexts.
40
- */
41
- export function createBuildGraphQLClient(): GraphQLClient {
42
- const url = getGraphQLUrl();
43
- return new GraphQLClient(url);
44
- }
package/src/lib/client.ts DELETED
@@ -1,58 +0,0 @@
1
- import { GraphQLClient } from 'graphql-request';
2
- import { getGraphQLUrl } from './config';
3
-
4
- let clientInstance: GraphQLClient | null = null;
5
- let getAccessToken: (() => Promise<string | null>) | null = null;
6
-
7
- /**
8
- * Set the access token provider function.
9
- * This should be called once at app initialization.
10
- */
11
- export function setAccessTokenProvider(
12
- provider: () => Promise<string | null>
13
- ): void {
14
- getAccessToken = provider;
15
- }
16
-
17
- /**
18
- * Create a GraphQL client for browser-side requests.
19
- * Uses Authorization header with dynamic token retrieval for cross-domain requests.
20
- */
21
- export function createGraphQLClient(): GraphQLClient {
22
- if (clientInstance) {
23
- return clientInstance;
24
- }
25
-
26
- const url = getGraphQLUrl();
27
-
28
- clientInstance = new GraphQLClient(url, {
29
- // Dynamic headers - called on each request
30
- requestMiddleware: async (request) => {
31
- const headers: Record<string, string> = {
32
- 'Content-Type': 'application/json',
33
- 'apollo-require-preflight': 'true',
34
- };
35
-
36
- if (getAccessToken) {
37
- const token = await getAccessToken();
38
- if (token) {
39
- headers['Authorization'] = `Bearer ${token}`;
40
- }
41
- }
42
-
43
- return {
44
- ...request,
45
- headers,
46
- };
47
- },
48
- });
49
-
50
- return clientInstance;
51
- }
52
-
53
- /**
54
- * Reset the client instance (useful for testing)
55
- */
56
- export function resetGraphQLClient(): void {
57
- clientInstance = null;
58
- }
package/src/lib/config.ts DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * GraphQL API configuration
3
- */
4
-
5
- /**
6
- * Get the GraphQL API URL from environment variables
7
- * Falls back to localhost for development
8
- */
9
- export function getGraphQLUrl(): string {
10
- const url = process.env.NEXT_PUBLIC_GRAPHQL_URL;
11
-
12
- if (!url) {
13
- // Default to localhost in development
14
- if (process.env.NODE_ENV === 'development') {
15
- return 'http://localhost:3001/api/graphql';
16
- }
17
- throw new Error('NEXT_PUBLIC_GRAPHQL_URL environment variable is not set');
18
- }
19
-
20
- return url;
21
- }
@@ -1,40 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
- import { gql } from 'graphql-request';
3
- import type { BibliographyEntryItem } from '@eightyfourthousand/data-access';
4
-
5
- const GET_BIBLIOGRAPHY_ENTRY = gql`
6
- query GetBibliographyEntry($uuid: ID!) {
7
- bibliographyEntry(uuid: $uuid) {
8
- uuid
9
- html
10
- workUuid
11
- }
12
- }
13
- `;
14
-
15
- type GetBibliographyEntryResponse = {
16
- bibliographyEntry: BibliographyEntryItem | null;
17
- };
18
-
19
- /**
20
- * Get a single bibliography entry by UUID.
21
- */
22
- export async function getBibliographyEntry({
23
- client,
24
- uuid,
25
- }: {
26
- client: GraphQLClient;
27
- uuid: string;
28
- }): Promise<BibliographyEntryItem | null> {
29
- try {
30
- const response = await client.request<GetBibliographyEntryResponse>(
31
- GET_BIBLIOGRAPHY_ENTRY,
32
- { uuid },
33
- );
34
-
35
- return response.bibliographyEntry;
36
- } catch (error) {
37
- console.error('Error fetching bibliography entry:', error);
38
- return null;
39
- }
40
- }
@@ -1,49 +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
- alternatives
19
- }
20
- }
21
- }
22
- `;
23
-
24
- type GetGlossaryInstanceResponse = {
25
- glossaryInstance: GlossaryTermInstance | null;
26
- };
27
-
28
- /**
29
- * Get a single glossary instance by UUID.
30
- */
31
- export async function getGlossaryInstance({
32
- client,
33
- uuid,
34
- }: {
35
- client: GraphQLClient;
36
- uuid: string;
37
- }): Promise<GlossaryTermInstance | null> {
38
- try {
39
- const response = await client.request<GetGlossaryInstanceResponse>(
40
- GET_GLOSSARY_INSTANCE,
41
- { uuid },
42
- );
43
-
44
- return response.glossaryInstance;
45
- } catch (error) {
46
- console.error('Error fetching glossary instance:', error);
47
- return null;
48
- }
49
- }