@eightyfourthousand/data-access 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 (341) hide show
  1. package/{src/index.ts → index.d.ts} +1 -2
  2. package/index.js +18 -0
  3. package/index.js.map +1 -0
  4. package/lib/auth.d.ts +59 -0
  5. package/lib/auth.js +135 -0
  6. package/lib/auth.js.map +1 -0
  7. package/lib/bibliography.d.ts +9 -0
  8. package/lib/bibliography.js +31 -0
  9. package/lib/bibliography.js.map +1 -0
  10. package/lib/client-browser.d.ts +1 -0
  11. package/lib/client-browser.js +10 -0
  12. package/lib/client-browser.js.map +1 -0
  13. package/lib/client-server.d.ts +4 -0
  14. package/lib/client-server.js +19 -0
  15. package/lib/client-server.js.map +1 -0
  16. package/lib/client-ssr.d.ts +1 -0
  17. package/lib/client-ssr.js +24 -0
  18. package/lib/client-ssr.js.map +1 -0
  19. package/lib/client-token.d.ts +7 -0
  20. package/lib/client-token.js +21 -0
  21. package/lib/client-token.js.map +1 -0
  22. package/lib/feedback.d.ts +6 -0
  23. package/lib/feedback.js +50 -0
  24. package/lib/feedback.js.map +1 -0
  25. package/lib/folio.d.ts +11 -0
  26. package/lib/folio.js +32 -0
  27. package/lib/folio.js.map +1 -0
  28. package/lib/glossary/batch.d.ts +5 -0
  29. package/lib/glossary/batch.js +24 -0
  30. package/lib/glossary/batch.js.map +1 -0
  31. package/lib/glossary/index.d.ts +4 -0
  32. package/lib/glossary/index.js +5 -0
  33. package/lib/glossary/index.js.map +1 -0
  34. package/lib/glossary/instance.d.ts +10 -0
  35. package/lib/glossary/instance.js +29 -0
  36. package/lib/glossary/instance.js.map +1 -0
  37. package/lib/glossary/landing.d.ts +5 -0
  38. package/lib/glossary/landing.js +33 -0
  39. package/lib/glossary/landing.js.map +1 -0
  40. package/lib/glossary/pagination.d.ts +55 -0
  41. package/lib/glossary/pagination.js +255 -0
  42. package/lib/glossary/pagination.js.map +1 -0
  43. package/lib/imprint.d.ts +10 -0
  44. package/lib/imprint.js +24 -0
  45. package/lib/imprint.js.map +1 -0
  46. package/lib/library.d.ts +58 -0
  47. package/lib/library.js +119 -0
  48. package/lib/library.js.map +1 -0
  49. package/lib/local-storage.d.ts +10 -0
  50. package/lib/local-storage.js +25 -0
  51. package/lib/local-storage.js.map +1 -0
  52. package/lib/lookup-entity.d.ts +7 -0
  53. package/lib/lookup-entity.js +94 -0
  54. package/lib/lookup-entity.js.map +1 -0
  55. package/lib/panel-url.d.ts +10 -0
  56. package/lib/panel-url.js +23 -0
  57. package/lib/panel-url.js.map +1 -0
  58. package/lib/passage/batch.d.ts +17 -0
  59. package/lib/passage/batch.js +159 -0
  60. package/lib/passage/batch.js.map +1 -0
  61. package/lib/passage/index.d.ts +5 -0
  62. package/lib/passage/index.js +6 -0
  63. package/lib/passage/index.js.map +1 -0
  64. package/lib/passage/pagination.d.ts +43 -0
  65. package/lib/passage/pagination.js +170 -0
  66. package/lib/passage/pagination.js.map +1 -0
  67. package/lib/passage/read.d.ts +15 -0
  68. package/lib/passage/read.js +61 -0
  69. package/lib/passage/read.js.map +1 -0
  70. package/lib/passage/replace-persistence.d.ts +46 -0
  71. package/lib/passage/replace-persistence.js +94 -0
  72. package/lib/passage/replace-persistence.js.map +1 -0
  73. package/lib/passage/save.d.ts +16 -0
  74. package/lib/passage/save.js +231 -0
  75. package/lib/passage/save.js.map +1 -0
  76. package/lib/proxy.d.ts +7 -0
  77. package/lib/proxy.js +48 -0
  78. package/lib/proxy.js.map +1 -0
  79. package/lib/publications.d.ts +86 -0
  80. package/lib/publications.js +226 -0
  81. package/lib/publications.js.map +1 -0
  82. package/lib/replace.d.ts +31 -0
  83. package/lib/replace.js +134 -0
  84. package/lib/replace.js.map +1 -0
  85. package/lib/storage.d.ts +7 -0
  86. package/lib/storage.js +11 -0
  87. package/lib/storage.js.map +1 -0
  88. package/lib/types/alignment.d.ts +18 -0
  89. package/lib/types/alignment.js +13 -0
  90. package/lib/types/alignment.js.map +1 -0
  91. package/lib/types/annotation/abbreviation.d.ts +3 -0
  92. package/lib/types/annotation/abbreviation.js +20 -0
  93. package/lib/types/annotation/abbreviation.js.map +1 -0
  94. package/lib/types/annotation/annotation-type.d.ts +31 -0
  95. package/lib/types/annotation/annotation-type.js +81 -0
  96. package/lib/types/annotation/annotation-type.js.map +1 -0
  97. package/lib/types/annotation/annotation.d.ts +142 -0
  98. package/lib/types/annotation/annotation.js +23 -0
  99. package/lib/types/annotation/annotation.js.map +1 -0
  100. package/lib/types/annotation/audio.d.ts +3 -0
  101. package/lib/types/annotation/audio.js +24 -0
  102. package/lib/types/annotation/audio.js.map +1 -0
  103. package/lib/types/annotation/blockquote.d.ts +3 -0
  104. package/lib/types/annotation/blockquote.js +8 -0
  105. package/lib/types/annotation/blockquote.js.map +1 -0
  106. package/lib/types/annotation/code.d.ts +3 -0
  107. package/lib/types/annotation/code.js +8 -0
  108. package/lib/types/annotation/code.js.map +1 -0
  109. package/lib/types/annotation/deprecated.d.ts +3 -0
  110. package/lib/types/annotation/deprecated.js +8 -0
  111. package/lib/types/annotation/deprecated.js.map +1 -0
  112. package/lib/types/annotation/end-note-link.d.ts +3 -0
  113. package/lib/types/annotation/end-note-link.js +23 -0
  114. package/lib/types/annotation/end-note-link.js.map +1 -0
  115. package/lib/types/annotation/export.d.ts +3 -0
  116. package/{src/lib/types/annotation/export.ts → lib/types/annotation/export.js} +34 -36
  117. package/lib/types/annotation/export.js.map +1 -0
  118. package/lib/types/annotation/glossary-instance.d.ts +3 -0
  119. package/lib/types/annotation/glossary-instance.js +23 -0
  120. package/lib/types/annotation/glossary-instance.js.map +1 -0
  121. package/lib/types/annotation/has-abbreviation.d.ts +3 -0
  122. package/lib/types/annotation/has-abbreviation.js +20 -0
  123. package/lib/types/annotation/has-abbreviation.js.map +1 -0
  124. package/lib/types/annotation/heading.d.ts +3 -0
  125. package/lib/types/annotation/heading.js +23 -0
  126. package/lib/types/annotation/heading.js.map +1 -0
  127. package/lib/types/annotation/image.d.ts +3 -0
  128. package/lib/types/annotation/image.js +20 -0
  129. package/lib/types/annotation/image.js.map +1 -0
  130. package/lib/types/annotation/indent.d.ts +3 -0
  131. package/lib/types/annotation/indent.js +8 -0
  132. package/lib/types/annotation/indent.js.map +1 -0
  133. package/lib/types/annotation/index.js +5 -0
  134. package/lib/types/annotation/index.js.map +1 -0
  135. package/lib/types/annotation/inline-title.d.ts +3 -0
  136. package/lib/types/annotation/inline-title.js +21 -0
  137. package/lib/types/annotation/inline-title.js.map +1 -0
  138. package/lib/types/annotation/internal-link.d.ts +3 -0
  139. package/lib/types/annotation/internal-link.js +62 -0
  140. package/lib/types/annotation/internal-link.js.map +1 -0
  141. package/lib/types/annotation/leading-space.d.ts +3 -0
  142. package/lib/types/annotation/leading-space.js +8 -0
  143. package/lib/types/annotation/leading-space.js.map +1 -0
  144. package/lib/types/annotation/line-group.d.ts +3 -0
  145. package/lib/types/annotation/line-group.js +8 -0
  146. package/lib/types/annotation/line-group.js.map +1 -0
  147. package/lib/types/annotation/line.d.ts +3 -0
  148. package/lib/types/annotation/line.js +8 -0
  149. package/lib/types/annotation/line.js.map +1 -0
  150. package/lib/types/annotation/link.d.ts +3 -0
  151. package/lib/types/annotation/link.js +27 -0
  152. package/lib/types/annotation/link.js.map +1 -0
  153. package/lib/types/annotation/list-item.d.ts +3 -0
  154. package/lib/types/annotation/list-item.js +8 -0
  155. package/lib/types/annotation/list-item.js.map +1 -0
  156. package/lib/types/annotation/list.d.ts +3 -0
  157. package/lib/types/annotation/list.js +31 -0
  158. package/lib/types/annotation/list.js.map +1 -0
  159. package/lib/types/annotation/mantra.d.ts +3 -0
  160. package/lib/types/annotation/mantra.js +21 -0
  161. package/lib/types/annotation/mantra.js.map +1 -0
  162. package/lib/types/annotation/mention.d.ts +3 -0
  163. package/lib/types/annotation/mention.js +50 -0
  164. package/lib/types/annotation/mention.js.map +1 -0
  165. package/lib/types/annotation/paragraph.d.ts +3 -0
  166. package/lib/types/annotation/paragraph.js +8 -0
  167. package/lib/types/annotation/paragraph.js.map +1 -0
  168. package/lib/types/annotation/quote.d.ts +3 -0
  169. package/lib/types/annotation/quote.js +21 -0
  170. package/lib/types/annotation/quote.js.map +1 -0
  171. package/lib/types/annotation/quoted.d.ts +3 -0
  172. package/lib/types/annotation/quoted.js +21 -0
  173. package/lib/types/annotation/quoted.js.map +1 -0
  174. package/lib/types/annotation/reference.d.ts +3 -0
  175. package/lib/types/annotation/reference.js +8 -0
  176. package/lib/types/annotation/reference.js.map +1 -0
  177. package/lib/types/annotation/span.d.ts +3 -0
  178. package/lib/types/annotation/span.js +29 -0
  179. package/lib/types/annotation/span.js.map +1 -0
  180. package/lib/types/annotation/table-body-data.d.ts +3 -0
  181. package/lib/types/annotation/table-body-data.js +8 -0
  182. package/lib/types/annotation/table-body-data.js.map +1 -0
  183. package/lib/types/annotation/table-body-header.d.ts +3 -0
  184. package/lib/types/annotation/table-body-header.js +8 -0
  185. package/lib/types/annotation/table-body-header.js.map +1 -0
  186. package/lib/types/annotation/table-body-row.d.ts +3 -0
  187. package/lib/types/annotation/table-body-row.js +8 -0
  188. package/lib/types/annotation/table-body-row.js.map +1 -0
  189. package/lib/types/annotation/table.d.ts +3 -0
  190. package/lib/types/annotation/table.js +8 -0
  191. package/lib/types/annotation/table.js.map +1 -0
  192. package/lib/types/annotation/trailer.d.ts +3 -0
  193. package/lib/types/annotation/trailer.js +8 -0
  194. package/lib/types/annotation/trailer.js.map +1 -0
  195. package/lib/types/annotation/transform.d.ts +6 -0
  196. package/lib/types/annotation/transform.js +108 -0
  197. package/lib/types/annotation/transform.js.map +1 -0
  198. package/lib/types/annotation/unknown.d.ts +3 -0
  199. package/lib/types/annotation/unknown.js +8 -0
  200. package/lib/types/annotation/unknown.js.map +1 -0
  201. package/lib/types/bibliography.d.ts +41 -0
  202. package/lib/types/bibliography.js +30 -0
  203. package/lib/types/bibliography.js.map +1 -0
  204. package/{src/lib/types/client.ts → lib/types/client.d.ts} +0 -1
  205. package/lib/types/client.js +2 -0
  206. package/lib/types/client.js.map +1 -0
  207. package/{src/lib/types/editor-content.ts → lib/types/editor-content.d.ts} +7 -11
  208. package/lib/types/editor-content.js +2 -0
  209. package/lib/types/editor-content.js.map +1 -0
  210. package/lib/types/folio.d.ts +17 -0
  211. package/lib/types/folio.js +11 -0
  212. package/lib/types/folio.js.map +1 -0
  213. package/lib/types/glossary-page.d.ts +48 -0
  214. package/lib/types/glossary-page.js +21 -0
  215. package/lib/types/glossary-page.js.map +1 -0
  216. package/lib/types/glossary.d.ts +76 -0
  217. package/lib/types/glossary.js +32 -0
  218. package/lib/types/glossary.js.map +1 -0
  219. package/lib/types/imprint.d.ts +78 -0
  220. package/lib/types/imprint.js +71 -0
  221. package/lib/types/imprint.js.map +1 -0
  222. package/{src/lib/types/index.ts → lib/types/index.d.ts} +0 -3
  223. package/lib/types/index.js +20 -0
  224. package/lib/types/index.js.map +1 -0
  225. package/lib/types/language.d.ts +9 -0
  226. package/lib/types/language.js +41 -0
  227. package/lib/types/language.js.map +1 -0
  228. package/lib/types/layout.d.ts +5 -0
  229. package/lib/types/layout.js +23 -0
  230. package/lib/types/layout.js.map +1 -0
  231. package/lib/types/library.d.ts +19 -0
  232. package/lib/types/library.js +8 -0
  233. package/lib/types/library.js.map +1 -0
  234. package/lib/types/passage.d.ts +73 -0
  235. package/lib/types/passage.js +120 -0
  236. package/lib/types/passage.js.map +1 -0
  237. package/lib/types/semver.js +2 -0
  238. package/lib/types/semver.js.map +1 -0
  239. package/lib/types/title.d.ts +21 -0
  240. package/lib/types/title.js +22 -0
  241. package/lib/types/title.js.map +1 -0
  242. package/lib/types/toh.js +2 -0
  243. package/lib/types/toh.js.map +1 -0
  244. package/{src/lib/types/translation.ts → lib/types/translation.d.ts} +5 -7
  245. package/lib/types/translation.js +2 -0
  246. package/lib/types/translation.js.map +1 -0
  247. package/{src/lib/types/user.ts → lib/types/user.d.ts} +2 -11
  248. package/lib/types/user.js +9 -0
  249. package/lib/types/user.js.map +1 -0
  250. package/lib/types/work.d.ts +37 -0
  251. package/lib/types/work.js +15 -0
  252. package/lib/types/work.js.map +1 -0
  253. package/lib/use-bookmark.d.ts +10 -0
  254. package/lib/use-bookmark.js +31 -0
  255. package/lib/use-bookmark.js.map +1 -0
  256. package/package.json +25 -3
  257. package/ssr.js +6 -0
  258. package/ssr.js.map +1 -0
  259. package/.babelrc +0 -12
  260. package/.eslintrc.json +0 -18
  261. package/README.md +0 -9
  262. package/jest.config.ts +0 -10
  263. package/project.json +0 -21
  264. package/src/lib/auth.ts +0 -203
  265. package/src/lib/bibliography.ts +0 -57
  266. package/src/lib/canon.ts +0 -111
  267. package/src/lib/client-browser.ts +0 -12
  268. package/src/lib/client-server.ts +0 -30
  269. package/src/lib/client-ssr.ts +0 -24
  270. package/src/lib/client-token.ts +0 -24
  271. package/src/lib/feedback.ts +0 -71
  272. package/src/lib/folio.ts +0 -43
  273. package/src/lib/glossary.ts +0 -147
  274. package/src/lib/imprint.ts +0 -42
  275. package/src/lib/library.ts +0 -209
  276. package/src/lib/local-storage.ts +0 -33
  277. package/src/lib/lookup-entity.ts +0 -122
  278. package/src/lib/panel-url.ts +0 -43
  279. package/src/lib/passage.ts +0 -122
  280. package/src/lib/projects.ts +0 -107
  281. package/src/lib/proxy.ts +0 -68
  282. package/src/lib/publications.ts +0 -213
  283. package/src/lib/storage.ts +0 -23
  284. package/src/lib/types/alignment.ts +0 -32
  285. package/src/lib/types/annotation/abbreviation.ts +0 -30
  286. package/src/lib/types/annotation/annotation-type.ts +0 -219
  287. package/src/lib/types/annotation/annotation.ts +0 -244
  288. package/src/lib/types/annotation/audio.ts +0 -33
  289. package/src/lib/types/annotation/blockquote.ts +0 -18
  290. package/src/lib/types/annotation/code.ts +0 -16
  291. package/src/lib/types/annotation/deprecated.ts +0 -18
  292. package/src/lib/types/annotation/end-note-link.ts +0 -35
  293. package/src/lib/types/annotation/glossary-instance.ts +0 -34
  294. package/src/lib/types/annotation/has-abbreviation.ts +0 -30
  295. package/src/lib/types/annotation/heading.ts +0 -37
  296. package/src/lib/types/annotation/image.ts +0 -29
  297. package/src/lib/types/annotation/indent.ts +0 -16
  298. package/src/lib/types/annotation/inline-title.ts +0 -34
  299. package/src/lib/types/annotation/internal-link.ts +0 -86
  300. package/src/lib/types/annotation/leading-space.ts +0 -18
  301. package/src/lib/types/annotation/line-group.ts +0 -18
  302. package/src/lib/types/annotation/line.ts +0 -16
  303. package/src/lib/types/annotation/link.ts +0 -38
  304. package/src/lib/types/annotation/list-item.ts +0 -16
  305. package/src/lib/types/annotation/list.ts +0 -43
  306. package/src/lib/types/annotation/mantra.ts +0 -31
  307. package/src/lib/types/annotation/mention.ts +0 -64
  308. package/src/lib/types/annotation/paragraph.ts +0 -18
  309. package/src/lib/types/annotation/quote.ts +0 -30
  310. package/src/lib/types/annotation/quoted.ts +0 -30
  311. package/src/lib/types/annotation/reference.ts +0 -18
  312. package/src/lib/types/annotation/span.ts +0 -39
  313. package/src/lib/types/annotation/table-body-data.ts +0 -18
  314. package/src/lib/types/annotation/table-body-header.ts +0 -18
  315. package/src/lib/types/annotation/table-body-row.ts +0 -18
  316. package/src/lib/types/annotation/table.ts +0 -16
  317. package/src/lib/types/annotation/trailer.ts +0 -16
  318. package/src/lib/types/annotation/transform.ts +0 -140
  319. package/src/lib/types/annotation/unknown.ts +0 -16
  320. package/src/lib/types/bibliography.ts +0 -86
  321. package/src/lib/types/canon.ts +0 -148
  322. package/src/lib/types/contributor.ts +0 -84
  323. package/src/lib/types/folio.ts +0 -28
  324. package/src/lib/types/glossary-page.ts +0 -204
  325. package/src/lib/types/glossary.ts +0 -114
  326. package/src/lib/types/imprint.ts +0 -159
  327. package/src/lib/types/language.ts +0 -64
  328. package/src/lib/types/layout.ts +0 -37
  329. package/src/lib/types/library.ts +0 -29
  330. package/src/lib/types/passage.ts +0 -220
  331. package/src/lib/types/project.ts +0 -200
  332. package/src/lib/types/title.ts +0 -47
  333. package/src/lib/types/work.ts +0 -38
  334. package/src/lib/use-bookmark.ts +0 -45
  335. package/tsconfig.json +0 -20
  336. package/tsconfig.lib.json +0 -26
  337. package/tsconfig.spec.json +0 -22
  338. /package/{src/lib/types/annotation/index.ts → lib/types/annotation/index.d.ts} +0 -0
  339. /package/{src/lib/types/semver.ts → lib/types/semver.d.ts} +0 -0
  340. /package/{src/lib/types/toh.ts → lib/types/toh.d.ts} +0 -0
  341. /package/{src/ssr.ts → ssr.d.ts} +0 -0
@@ -1,159 +0,0 @@
1
- import { TranslationLanguage } from './language';
2
- import { BACK_MATTER, BODY_MATTER, FRONT_MATTER } from './passage';
3
- import { SemVer } from './semver';
4
-
5
- export type Imprint = {
6
- uuid: string;
7
- toh: string;
8
- section?: string;
9
- version?: SemVer;
10
- restriction?: boolean;
11
- publishYear?: string;
12
- tibetanAuthors?: string[];
13
- isAuthorContested: boolean;
14
- sourceDescription?: string;
15
- publisherStatement?: string;
16
- tibetanTranslators?: string;
17
- license: {
18
- link?: string;
19
- name?: string;
20
- description?: string;
21
- };
22
- mainTitles?: Partial<{ [key in TranslationLanguage]: string }>;
23
- longTitles?: Partial<{ [key in TranslationLanguage]: string }>;
24
- };
25
-
26
- export type ImprintDTO = {
27
- work_uuid: string;
28
- toh: string;
29
- section?: string;
30
- version?: SemVer;
31
- restriction?: boolean;
32
- publishYear?: string;
33
- tibetanAuthors?: string;
34
- isAuthorContested?: boolean;
35
- sourceDescription?: string;
36
- publisherStatement?: string;
37
- tibetanTranslators?: string;
38
- license: {
39
- link?: string;
40
- name?: string;
41
- description?: string;
42
- };
43
- mainTitles?: Partial<{ [key in TranslationLanguage]: string }>;
44
- longTitles?: Partial<{ [key in TranslationLanguage]: string }>;
45
- };
46
-
47
- export const imprintFromDTO = (dto: ImprintDTO): Imprint => {
48
- return {
49
- uuid: dto.work_uuid,
50
- toh: dto.toh,
51
- section: dto.section,
52
- version: dto.version,
53
- restriction: dto.restriction,
54
- publishYear: dto.publishYear,
55
- tibetanAuthors: dto.tibetanAuthors
56
- ?.split(',')
57
- .map((author) => author.trim())
58
- .filter((author) => author.length > 0),
59
- isAuthorContested: dto.isAuthorContested || false,
60
- sourceDescription: dto.sourceDescription,
61
- publisherStatement: dto.publisherStatement,
62
- tibetanTranslators: dto.tibetanTranslators,
63
- license: {
64
- ...dto.license,
65
- },
66
- mainTitles: dto.mainTitles,
67
- longTitles: dto.longTitles,
68
- };
69
- };
70
-
71
- const ALL_SECTIONS = [...FRONT_MATTER, ...BODY_MATTER, ...BACK_MATTER];
72
- export type TranslationSection = (typeof ALL_SECTIONS)[number];
73
-
74
- export type TocEntryDTO = {
75
- uuid: string;
76
- content: string;
77
- label?: string;
78
- sort: number;
79
- section: TranslationSection;
80
- level: number;
81
- };
82
-
83
- export type TocDTO = TocEntryDTO[];
84
-
85
- export type TocEntry = {
86
- uuid: string;
87
- content: string;
88
- label?: string;
89
- sort: number;
90
- level: number;
91
- section: TranslationSection;
92
- children: TocEntry[];
93
- };
94
-
95
- export type Toc = {
96
- frontMatter: TocEntry[];
97
- body: TocEntry[];
98
- backMatter: TocEntry[];
99
- };
100
-
101
- export const tocFromDTO = (dto: TocDTO): Toc => {
102
- // map by front matter, body matter, back matter based on constants above
103
- const frontMatter: TocEntry[] = [];
104
- const bodyMatter: TocEntry[] = [];
105
- const backMatter: TocEntry[] = [];
106
-
107
- const sectionMap: { [key in TranslationSection]: TocEntry[] } = {
108
- abbreviations: backMatter,
109
- acknowledgment: frontMatter,
110
- appendix: bodyMatter,
111
- colophon: bodyMatter,
112
- endnotes: backMatter,
113
- homage: bodyMatter,
114
- introduction: frontMatter,
115
- prelude: bodyMatter,
116
- prologue: bodyMatter,
117
- summary: frontMatter,
118
- translation: bodyMatter,
119
- };
120
-
121
- dto.forEach((entry) => {
122
- const tocEntry: TocEntry = {
123
- ...entry,
124
- children: [],
125
- };
126
- sectionMap[entry.section].push(tocEntry);
127
- });
128
-
129
- // within each section, create a hierarchy based on level from low to high
130
- const buildHierarchy = (entries: TocEntry[]): TocEntry[] => {
131
- const root: TocEntry = {
132
- uuid: 'root',
133
- content: '',
134
- sort: 0,
135
- level: 0,
136
- section: 'introduction',
137
- children: [],
138
- };
139
- const stack: TocEntry[] = [root];
140
-
141
- entries.sort((a, b) => a.sort - b.sort);
142
-
143
- entries.forEach((entry) => {
144
- while (stack.length > 1 && entry.level <= stack[stack.length - 1].level) {
145
- stack.pop();
146
- }
147
- stack[stack.length - 1].children.push(entry);
148
- stack.push(entry);
149
- });
150
-
151
- return root.children;
152
- };
153
-
154
- return {
155
- frontMatter: buildHierarchy(frontMatter),
156
- body: buildHierarchy(bodyMatter),
157
- backMatter: buildHierarchy(backMatter),
158
- };
159
- };
@@ -1,64 +0,0 @@
1
- export const LANGUAGES = ['bo', 'en', 'Bo-Ltn', 'Sa-Ltn'] as const;
2
- export type TranslationLanguage = (typeof LANGUAGES)[number];
3
- export type ExtendedTranslationLanguage =
4
- | TranslationLanguage
5
- | 'zh'
6
- | 'ja'
7
- | 'Mt-Ltn'
8
- | 'Pi-Ltn'
9
- | 'Zh-Ltn';
10
-
11
- export const DISPLAY_LANGUAGES = [
12
- 'tibetan',
13
- 'english',
14
- 'wylie',
15
- 'sanskrit',
16
- 'chinese',
17
- 'japanese',
18
- 'mongolian',
19
- 'pali',
20
- 'pinyin',
21
- ] as const;
22
- export type DisplayLanguage = (typeof DISPLAY_LANGUAGES)[number];
23
-
24
- export const LANGUAGE_MAP: Record<
25
- ExtendedTranslationLanguage,
26
- DisplayLanguage
27
- > = {
28
- bo: 'tibetan',
29
- en: 'english',
30
- 'Bo-Ltn': 'tibetan',
31
- 'Sa-Ltn': 'sanskrit',
32
- zh: 'chinese',
33
- ja: 'japanese',
34
- 'Mt-Ltn': 'mongolian',
35
- 'Pi-Ltn': 'pali',
36
- 'Zh-Ltn': 'pinyin',
37
- };
38
-
39
- export const REVERSE_LANGUAGE_MAP: Record<
40
- DisplayLanguage,
41
- ExtendedTranslationLanguage
42
- > = {
43
- tibetan: 'bo',
44
- english: 'en',
45
- wylie: 'Bo-Ltn',
46
- sanskrit: 'Sa-Ltn',
47
- chinese: 'zh',
48
- japanese: 'ja',
49
- mongolian: 'Mt-Ltn',
50
- pinyin: 'Zh-Ltn',
51
- pali: 'Pi-Ltn',
52
- };
53
-
54
- export const displayLanguageForTranslationLanguage = (
55
- language: ExtendedTranslationLanguage,
56
- ): DisplayLanguage => {
57
- return LANGUAGE_MAP[language];
58
- };
59
-
60
- export const translationLanguageForDisplayLanguage = (
61
- language: DisplayLanguage,
62
- ): ExtendedTranslationLanguage => {
63
- return REVERSE_LANGUAGE_MAP[language];
64
- };
@@ -1,37 +0,0 @@
1
- import { BodyItemType } from './passage';
2
-
3
- export type PanelContentType =
4
- | BodyItemType
5
- | 'glossary'
6
- | 'bibliography'
7
- | 'source';
8
-
9
- // NOTE: default to 'translation' (or 'compare') for content types not listed here
10
- export const TAB_FOR_CONTENT_SECTION: Partial<
11
- Record<PanelContentType, string>
12
- > = {
13
- abbreviations: 'abbreviations',
14
- acknowledgment: 'front',
15
- bibliography: 'bibliography',
16
- glossary: 'glossary',
17
- endnotes: 'endnotes',
18
- introduction: 'front',
19
- summary: 'front',
20
- } as const;
21
-
22
- // NOTE: default to 'main' for content types not listed here
23
- export const PANEL_FOR_CONTENT_SECTION: Partial<
24
- Record<PanelContentType, string>
25
- > = {
26
- abbreviations: 'right',
27
- bibliography: 'right',
28
- endnotes: 'right',
29
- glossary: 'right',
30
- source: 'main',
31
- } as const;
32
-
33
- // Support different tabs for some content
34
- export const VARIANT_TABS_FOR_TAB: Partial<Record<PanelContentType, string[]>> =
35
- {
36
- translation: ['compare'],
37
- } as const;
@@ -1,29 +0,0 @@
1
- export const LIBRARY_ITEMS = [
2
- 'publications',
3
- 'passages',
4
- 'glossaries',
5
- 'bibliographies',
6
- 'searches',
7
- ] as const;
8
-
9
- export type LibraryItemType = (typeof LIBRARY_ITEMS)[number];
10
-
11
- export type UserLibraryItem = {
12
- uuid: string;
13
- type: LibraryItemType;
14
- createdAt: string;
15
- featured: boolean;
16
- };
17
-
18
- export type UserPassageWork = {
19
- uuid: string;
20
- toh: string;
21
- };
22
-
23
- export type UserPassageItem = {
24
- uuid: string;
25
- toh: string;
26
- label: string;
27
- content: string;
28
- work: UserPassageWork;
29
- };
@@ -1,220 +0,0 @@
1
- import { Alignment, AlignmentDTO, alignmentsFromDTO } from './alignment';
2
- import {
3
- Annotations,
4
- AnnotationsDTO,
5
- annotationsFromDTO,
6
- annotationsToDTO,
7
- } from './annotation';
8
- import { TohokuCatalogEntry } from './toh';
9
-
10
- export const BODY_ITEM_TYPES = [
11
- 'abbreviations',
12
- 'abbreviationsHeader',
13
- 'acknowledgment',
14
- 'acknowledgmentHeader',
15
- 'appendix',
16
- 'appendixHeader',
17
- 'colophon',
18
- 'colophonHeader',
19
- 'endnotes',
20
- 'endnotesHeader',
21
- 'homage',
22
- 'homageHeader',
23
- 'introduction',
24
- 'introductionHeader',
25
- 'prelude',
26
- 'preludeHeader',
27
- 'prologue',
28
- 'prologueHeader',
29
- 'summary',
30
- 'summaryHeader',
31
- 'translation',
32
- 'translationHeader',
33
- ];
34
-
35
- export type BodyItemType = (typeof BODY_ITEM_TYPES)[number] | 'unknown';
36
-
37
- export const FRONT_MATTER: BodyItemType[] = [
38
- 'acknowledgment',
39
- 'summary',
40
- 'introduction',
41
- ];
42
- export const FRONT_MATTER_FILTER = `(${FRONT_MATTER.join('|')})`;
43
- export const BODY_MATTER: BodyItemType[] = [
44
- 'prelude',
45
- 'prologue',
46
- 'translation',
47
- 'appendix',
48
- 'colophon',
49
- 'homage',
50
- ];
51
- export const BODY_MATTER_FILTER = `(${BODY_MATTER.join('|')})`;
52
- export const BACK_MATTER: BodyItemType[] = ['abbreviations', 'endnotes'];
53
- export const BACK_MATTER_FILTER = `(${BACK_MATTER.join('|')})`;
54
- export const COMPARE_MODE = BODY_MATTER;
55
- export const COMPARE_MODE_FILTER = `(${COMPARE_MODE.join('|')})`;
56
-
57
- export const PANEL_FILTERS = [
58
- FRONT_MATTER_FILTER,
59
- BODY_MATTER_FILTER,
60
- BACK_MATTER_FILTER,
61
- COMPARE_MODE_FILTER,
62
- ] as const;
63
-
64
- export type PanelFilter = (typeof PANEL_FILTERS)[number];
65
-
66
- export type Passage = {
67
- alignments?: Alignment[];
68
- annotations: Annotations;
69
- content: string;
70
- label: string;
71
- sort: number;
72
- type: BodyItemType;
73
- uuid: string;
74
- workUuid: string;
75
- xmlId?: string;
76
- parent?: string;
77
- toh?: TohokuCatalogEntry;
78
- references?: Passages;
79
- };
80
-
81
- export type Passages = Passage[];
82
-
83
- export type PassageRowDTO = {
84
- content: string;
85
- label: string;
86
- sort: number;
87
- type: BodyItemType;
88
- uuid: string;
89
- work_uuid: string;
90
- xmlId?: string;
91
- parent?: string;
92
- toh?: TohokuCatalogEntry;
93
- };
94
-
95
- export type PassageDTO = PassageRowDTO & {
96
- alignments?: AlignmentDTO[];
97
- annotations?: AnnotationsDTO | null;
98
- };
99
-
100
- export type PaginationDirection = 'forward' | 'backward';
101
-
102
- export type PassagesPageDTO = {
103
- passages: PassageDTO[];
104
- nextCursor?: string;
105
- hasMore: boolean;
106
- };
107
-
108
- export type PassagesPageAroundDTO = {
109
- passages: PassageDTO[];
110
- prevCursor?: string;
111
- nextCursor?: string;
112
- hasMoreBefore: boolean;
113
- hasMoreAfter: boolean;
114
- };
115
-
116
- export type PassagesPage = {
117
- passages: Passage[];
118
- prevCursor?: string;
119
- nextCursor?: string;
120
- hasMoreAfter: boolean;
121
- hasMoreBefore: boolean;
122
- };
123
-
124
- export const passageFromDTO = (
125
- dto: PassageDTO,
126
- annotations: Annotations = [],
127
- alignments: Alignment[] = [],
128
- ): Passage => {
129
- return {
130
- content: dto.content,
131
- label: dto.label,
132
- sort: dto.sort,
133
- type: dto.type,
134
- uuid: dto.uuid,
135
- workUuid: dto.work_uuid,
136
- xmlId: dto.xmlId,
137
- parent: dto.parent,
138
- toh: dto.toh,
139
- alignments,
140
- annotations,
141
- };
142
- };
143
-
144
- export const passagesFromDTO = (dto: PassageDTO[]): Passage[] => {
145
- return dto.map((p) =>
146
- passageFromDTO(
147
- p,
148
- annotationsFromDTO(p.annotations || [], p.content.length),
149
- alignmentsFromDTO(p.alignments || []),
150
- ),
151
- );
152
- };
153
-
154
- export const passageToRowDTO = (passage: Passage): PassageRowDTO => {
155
- const dto: PassageRowDTO = {
156
- content: passage.content,
157
- label: passage.label,
158
- sort: passage.sort,
159
- type: passage.type,
160
- uuid: passage.uuid,
161
- work_uuid: passage.workUuid,
162
- };
163
-
164
- // NOTE: only include xmlId and parent if they exist, otherwise an upsert
165
- // will set them to null in the database.
166
- if (passage.xmlId) {
167
- dto.xmlId = passage.xmlId;
168
- }
169
-
170
- if (passage.parent) {
171
- dto.parent = passage.parent;
172
- }
173
-
174
- if (passage.toh) {
175
- dto.toh = passage.toh;
176
- }
177
-
178
- return dto;
179
- };
180
-
181
- export const passageToDTO = (passage: Passage): PassageDTO => {
182
- // NOTE: ignore alignments
183
- return {
184
- ...passageToRowDTO(passage),
185
- annotations: annotationsToDTO(passage.annotations) || [],
186
- };
187
- };
188
-
189
- export const passagesToDTO = (passages: Passage[]): PassageDTO[] => {
190
- return passages.map(passageToDTO);
191
- };
192
-
193
- export const passagesToRowDTO = (passages: Passage[]): PassageRowDTO[] => {
194
- return passages.map(passageToRowDTO);
195
- };
196
-
197
- export const passagesPageFromDTO = (
198
- direction: PaginationDirection,
199
- dto: PassagesPageDTO,
200
- ): PassagesPage => {
201
- return {
202
- passages: passagesFromDTO(dto.passages),
203
- nextCursor: direction === 'forward' ? dto.nextCursor : undefined,
204
- prevCursor: direction === 'backward' ? dto.nextCursor : undefined,
205
- hasMoreAfter: direction === 'forward' && dto.hasMore,
206
- hasMoreBefore: direction === 'backward' && dto.hasMore,
207
- };
208
- };
209
-
210
- export const passagesPageAroundFromDTO = (
211
- dto: PassagesPageAroundDTO,
212
- ): PassagesPage => {
213
- return {
214
- passages: passagesFromDTO(dto.passages),
215
- nextCursor: dto.nextCursor,
216
- prevCursor: dto.prevCursor,
217
- hasMoreAfter: dto.hasMoreAfter,
218
- hasMoreBefore: dto.hasMoreBefore,
219
- };
220
- };
@@ -1,200 +0,0 @@
1
- import { SemVer } from './semver';
2
-
3
- export const PROJECT_STAGE_LABELS = [
4
- '1',
5
- '1.a',
6
- '2',
7
- '2.a',
8
- '2.b',
9
- '2.c',
10
- '2.d',
11
- '2.e',
12
- '2.f',
13
- '2.g',
14
- '2.h',
15
- '3',
16
- '4',
17
- '0',
18
- ];
19
-
20
- export const STAGE_DESCRIPTIONS: Record<ProjectStageLabel, string> = {
21
- '1': 'Published and in app',
22
- '1.a': 'Published',
23
- '2': 'Marked up and awaiting final proofing',
24
- '2.a': 'Markup in progress',
25
- '2.b': 'Awaiting markup',
26
- '2.c': "Awaiting editor's OK form markup",
27
- '2.d': 'Copy editing complete',
28
- '2.e': 'Copy editing in progress',
29
- '2.f': 'Review complete',
30
- '2.g': 'In editorial review',
31
- '2.h': 'Awaiting editorial review',
32
- '3': 'In translation',
33
- '4': 'Application pending',
34
- '0': 'Not started',
35
- };
36
-
37
- export const STAGE_COLORS: Record<ProjectStageLabel, string> = {
38
- '1': 'emerald',
39
- '1.a': 'emerald',
40
- '2': 'ochre',
41
- '2.a': 'ochre',
42
- '2.b': 'ochre',
43
- '2.c': 'ochre',
44
- '2.d': 'ochre',
45
- '2.e': 'ochre',
46
- '2.f': 'ochre',
47
- '2.g': 'ochre',
48
- '2.h': 'ochre',
49
- '3': 'navy',
50
- '4': 'brick',
51
- '0': 'muted text-muted-foreground',
52
- };
53
-
54
- export const CANON_TYPES = ['kangyur', 'tengyur'];
55
-
56
- export type ProjectStageLabel = (typeof PROJECT_STAGE_LABELS)[number];
57
-
58
- export type CanonType = (typeof CANON_TYPES)[number];
59
-
60
- export type ProjectStage = {
61
- label: ProjectStageLabel;
62
- description: string;
63
- date: Date;
64
- targetDate?: Date;
65
- color: string;
66
- };
67
-
68
- export type ProjectViewDTO = {
69
- uuid: string;
70
- toh: string;
71
- title: string;
72
- translator: string;
73
- stage: ProjectStageLabel;
74
- stage_date: string;
75
- pages: number;
76
- type?: string;
77
- };
78
-
79
- export type ProjectTableDTO = {
80
- uuid: string;
81
- notes: string;
82
- contractDate: string;
83
- contractId: string;
84
- workUuid: string;
85
- pages: number;
86
- publicationDate: string;
87
- version: string;
88
- stage: ProjectStageLabel;
89
- restriction: boolean;
90
- title: string;
91
- toh: string;
92
- mainTranslator: string;
93
- translationGroup: string;
94
- };
95
-
96
- export type Project = {
97
- uuid: string;
98
- toh: string;
99
- title: string;
100
- translator?: string;
101
- translationGroup?: string;
102
- stage: ProjectStage;
103
- pages: number;
104
- notes?: string;
105
- contractDate?: Date;
106
- contractId?: string;
107
- workUuid?: string;
108
- version?: SemVer;
109
- canons?: string;
110
- };
111
-
112
- export type ProjectStageDetailsDTO = {
113
- uuid: string;
114
- stage: ProjectStageLabel;
115
- stageDate: string;
116
- targetDate?: string;
117
- };
118
-
119
- export type ProjectStageDetail = {
120
- uuid: string;
121
- stage: ProjectStage;
122
- targetDate?: Date;
123
- };
124
-
125
- export type ProjectStageDetails = ProjectStageDetail[];
126
-
127
- export type ProjectAssetDTO = {
128
- uuid: string;
129
- projectUuid: string;
130
- stageUuid?: string;
131
- filename: string;
132
- url: string;
133
- note?: string;
134
- };
135
-
136
- export type ProjectAsset = ProjectAssetDTO;
137
-
138
- export function projectStageDetailFromDTO(
139
- dto: ProjectStageDetailsDTO,
140
- ): ProjectStageDetail {
141
- return {
142
- uuid: dto.uuid,
143
- stage: {
144
- label: dto.stage,
145
- description: STAGE_DESCRIPTIONS[dto.stage] || '',
146
- date: new Date(dto.stageDate),
147
- targetDate: dto.targetDate ? new Date(dto.targetDate) : undefined,
148
- color: STAGE_COLORS[dto.stage] || 'grey',
149
- },
150
- };
151
- }
152
-
153
- export function projectStageDetailsFromDTO(
154
- dto?: ProjectStageDetailsDTO[],
155
- ): ProjectStageDetails {
156
- return dto?.map(projectStageDetailFromDTO) || [];
157
- }
158
-
159
- export function projectFromViewDTO(dto: ProjectViewDTO): Project {
160
- return {
161
- uuid: dto.uuid,
162
- toh: dto.toh,
163
- title: dto.title,
164
- translator: dto.translator,
165
- stage: {
166
- label: dto.stage,
167
- description: STAGE_DESCRIPTIONS[dto.stage] || '',
168
- date: new Date(dto.stage_date),
169
- color: STAGE_COLORS[dto.stage] || 'grey',
170
- },
171
- pages: dto.pages,
172
- canons: dto.type,
173
- };
174
- }
175
-
176
- export function projectFromTableDTO(dto: ProjectTableDTO): Project {
177
- const stage = dto.stage;
178
- const contractDate = dto.contractDate
179
- ? new Date(dto.contractDate)
180
- : undefined;
181
- return {
182
- uuid: dto.uuid,
183
- toh: dto.toh,
184
- title: dto.title,
185
- stage: {
186
- label: stage,
187
- description: STAGE_DESCRIPTIONS[stage] || '',
188
- date: new Date(dto.publicationDate),
189
- color: STAGE_COLORS[stage] || 'grey',
190
- },
191
- pages: dto.pages,
192
- notes: dto.notes,
193
- contractId: dto.contractId,
194
- contractDate,
195
- workUuid: dto.workUuid,
196
- version: dto.version as SemVer,
197
- translator: dto.mainTranslator,
198
- translationGroup: dto.translationGroup,
199
- };
200
- }