@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,107 +0,0 @@
1
- import {
2
- DataClient,
3
- ProjectContributor,
4
- ProjectContributorsDTO,
5
- projectContributorsFromDTO,
6
- } from './types';
7
- import {
8
- Project,
9
- ProjectAsset,
10
- ProjectStageDetail,
11
- ProjectStageDetailsDTO,
12
- ProjectTableDTO,
13
- ProjectViewDTO,
14
- projectFromTableDTO,
15
- projectFromViewDTO,
16
- projectStageDetailsFromDTO,
17
- } from './types/project';
18
-
19
- export const getProjects = async ({ client }: { client: DataClient }) => {
20
- const { data } = await client.rpc('get_projects');
21
-
22
- const dtos = (data as ProjectViewDTO[]) || [];
23
- const projects = dtos.map(projectFromViewDTO);
24
-
25
- return { projects };
26
- };
27
-
28
- export const getProjectByUuid = async ({
29
- client,
30
- uuid,
31
- }: {
32
- client: DataClient;
33
- uuid: string;
34
- }): Promise<Project> => {
35
- const { data } = await client.rpc('get_project', { uuid_input: uuid });
36
-
37
- return projectFromTableDTO(data as ProjectTableDTO);
38
- };
39
-
40
- export const getProjectStages = async ({
41
- client,
42
- uuid,
43
- }: {
44
- client: DataClient;
45
- uuid: string;
46
- }): Promise<ProjectStageDetail[]> => {
47
- const { data } = await client.rpc('get_project_stages', { uuid_input: uuid });
48
- return projectStageDetailsFromDTO(data as ProjectStageDetailsDTO[]);
49
- };
50
-
51
- export const getProjectAssets = async ({
52
- client,
53
- projectUuid,
54
- stageUuid,
55
- }: {
56
- client: DataClient;
57
- projectUuid?: string;
58
- stageUuid?: string;
59
- }): Promise<ProjectAsset[]> => {
60
- if (!projectUuid && !stageUuid) {
61
- console.error('One of projectUuid or stageUuid is required');
62
- return [];
63
- }
64
-
65
- const { data } = await client.rpc('get_project_assets', {
66
- project_uuid_input: projectUuid,
67
- stage_uuid_input: stageUuid,
68
- });
69
- return data || [];
70
- };
71
-
72
- export const getProjectContributors = async ({
73
- client,
74
- projectUuid,
75
- stageUuid,
76
- }: {
77
- client: DataClient;
78
- projectUuid?: string;
79
- stageUuid?: string;
80
- }): Promise<ProjectContributor[]> => {
81
- if (!projectUuid && !stageUuid) {
82
- console.error('One of projectUuid or stageUuid is required');
83
- return [];
84
- }
85
-
86
- const uuid = stageUuid ? stageUuid : projectUuid;
87
- const key = stageUuid ? 'stage_uuid' : 'project_uuid';
88
-
89
- const { data } = await client
90
- .from('project_contributors')
91
- .select(
92
- `
93
- uuid,
94
- stageUuid:stage_uuid,
95
- projectUuid:project_uuid,
96
- ...authorities!contributor_uuid(
97
- contributorUuid:uuid,
98
- name:headword
99
- ),
100
- startDate:start_date,
101
- endDate:end_date,
102
- role:type
103
- `,
104
- )
105
- .eq(key, uuid);
106
- return projectContributorsFromDTO(data as ProjectContributorsDTO);
107
- };
package/src/lib/proxy.ts DELETED
@@ -1,68 +0,0 @@
1
- import { createServerClient } from '@supabase/ssr';
2
- import { jwtDecode } from 'jwt-decode';
3
- import { NextResponse, type NextRequest } from 'next/server';
4
- import { UserRole } from './types';
5
-
6
- export async function updateSession(request: NextRequest) {
7
- const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
8
- const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
9
-
10
- if (!supabaseUrl || !supabaseAnonKey) {
11
- throw new Error('Missing Supabase credentials');
12
- }
13
- let supabaseResponse = NextResponse.next({
14
- request,
15
- });
16
-
17
- const supabase = createServerClient(supabaseUrl, supabaseAnonKey, {
18
- cookies: {
19
- getAll() {
20
- return request.cookies.getAll();
21
- },
22
- setAll(
23
- cookiesToSet: Array<{
24
- name: string;
25
- value: string;
26
- options?: Record<string, unknown>;
27
- }>,
28
- ) {
29
- cookiesToSet.forEach(({ name, value }) =>
30
- request.cookies.set(name, value),
31
- );
32
- supabaseResponse = NextResponse.next({
33
- request,
34
- });
35
- cookiesToSet.forEach(({ name, value, options }) =>
36
- supabaseResponse.cookies.set(name, value, options),
37
- );
38
- },
39
- },
40
- });
41
-
42
- // Do not run code between update and
43
- // supabase.auth.getUser(). A simple mistake could make it very hard to debug
44
- // issues with users being randomly logged out.
45
-
46
- // IMPORTANT: DO NOT REMOVE auth.getUser()
47
-
48
- const {
49
- data: { user },
50
- } = await supabase.auth.getUser();
51
-
52
- const {
53
- data: { session },
54
- } = await supabase.auth.getSession();
55
- let role: UserRole = 'reader';
56
- if (session?.access_token) {
57
- try {
58
- const { user_role: userRole } = jwtDecode(session.access_token) as {
59
- user_role: string;
60
- };
61
- role = (userRole as UserRole) || 'reader';
62
- } catch (error) {
63
- console.error('Failed to decode JWT:', error);
64
- }
65
- }
66
-
67
- return { user, role, supabaseResponse };
68
- }
@@ -1,213 +0,0 @@
1
- import {
2
- BodyItemType,
3
- DataClient,
4
- TitlesDTO,
5
- WorkDTO,
6
- titlesFromDTO,
7
- workFromDTO,
8
- passagesPageFromDTO,
9
- PassagesPageDTO,
10
- PassagesPage,
11
- PaginationDirection,
12
- passagesPageAroundFromDTO,
13
- PassagesPageAroundDTO,
14
- Work,
15
- } from './types';
16
-
17
- export const getTranslationUuids = async ({
18
- client,
19
- }: {
20
- client: DataClient;
21
- }): Promise<string[]> => {
22
- const { data } = await client.rpc('get_static_translation_uuids');
23
- return data?.map(({ uuid }: { uuid: string }) => uuid) || [];
24
- };
25
-
26
- export const getTranslationPassages = async ({
27
- client,
28
- uuid,
29
- type,
30
- cursor,
31
- maxPassages,
32
- maxCharacters,
33
- direction,
34
- }: {
35
- client: DataClient;
36
- uuid: string;
37
- type?: BodyItemType;
38
- cursor?: string;
39
- maxPassages?: number;
40
- maxCharacters?: number;
41
- direction?: PaginationDirection;
42
- }): Promise<PassagesPage> => {
43
- const { data, error } = await client.rpc('get_passages_page', {
44
- uuid_input: uuid,
45
- passage_type_input: type,
46
- cursor,
47
- max_passages: maxPassages,
48
- char_budget: maxCharacters,
49
- direction,
50
- });
51
-
52
- if (error) {
53
- console.error('Error fetching translation passages:', error);
54
- return {
55
- hasMoreAfter: false,
56
- hasMoreBefore: false,
57
- passages: [],
58
- };
59
- }
60
-
61
- return passagesPageFromDTO(direction || 'forward', data as PassagesPageDTO);
62
- };
63
-
64
- export const getTranslationPassagesAround = async ({
65
- client,
66
- uuid,
67
- passageUuid,
68
- type,
69
- maxPassages,
70
- maxCharacters,
71
- }: {
72
- client: DataClient;
73
- uuid: string;
74
- passageUuid: string;
75
- type?: BodyItemType;
76
- maxPassages?: number;
77
- maxCharacters?: number;
78
- }): Promise<PassagesPage> => {
79
- const { data, error } = await client.rpc('get_passages_page_around', {
80
- uuid_input: uuid,
81
- cursor: passageUuid,
82
- passage_type_input: type,
83
- max_passages: maxPassages,
84
- char_budget: maxCharacters,
85
- });
86
-
87
- if (error) {
88
- console.error('Error fetching translation passages around:', error);
89
- return {
90
- hasMoreAfter: false,
91
- hasMoreBefore: false,
92
- passages: [],
93
- };
94
- }
95
-
96
- return passagesPageAroundFromDTO(data as PassagesPageAroundDTO);
97
- };
98
-
99
- export const getTranslationTitles = async ({
100
- client,
101
- uuid,
102
- }: {
103
- client: DataClient;
104
- uuid: string;
105
- }) => {
106
- const { data } = await client.rpc('get_work_titles', {
107
- work_uuid_input: uuid,
108
- });
109
-
110
- return titlesFromDTO(data as TitlesDTO);
111
- };
112
-
113
- export const getTranslationMetadataByUuid = async ({
114
- client,
115
- uuid,
116
- }: {
117
- client: DataClient;
118
- uuid: string;
119
- }) => {
120
- const { data, error } = await client
121
- .from('works')
122
- .select(
123
- `
124
- uuid,
125
- title,
126
- description,
127
- tohs:work_toh!inner(toh:toh_clean),
128
- publicationDate,
129
- publicationVersion,
130
- pages:source_pages,
131
- restriction,
132
- breadcrumb
133
- `,
134
- )
135
- .eq('uuid', uuid)
136
- .single();
137
-
138
- if (error) {
139
- throw new Error(
140
- `Error fetching translation metadata by UUID: ${error.message}`,
141
- );
142
- }
143
-
144
- return workFromDTO(data as WorkDTO);
145
- };
146
-
147
- export const getTranslationMetadataByToh = async ({
148
- client,
149
- toh,
150
- }: {
151
- client: DataClient;
152
- toh: string;
153
- }) => {
154
- const { data, error } = await client
155
- .from('work_toh')
156
- .select(
157
- `
158
- work_uuid,
159
- works!inner(
160
- uuid,
161
- title,
162
- description,
163
- tohs:work_toh!inner(toh:toh_clean),
164
- publicationDate,
165
- publicationVersion,
166
- pages:source_pages,
167
- restriction,
168
- breadcrumb
169
- )
170
- `,
171
- )
172
- .eq('toh_clean', toh)
173
- .single();
174
-
175
- // Extract the work data from the joined result
176
- const workData = data?.works as WorkDTO | undefined;
177
- if (error || !workData) {
178
- console.error('Error fetching translation metadata by TOH:', error);
179
- return null;
180
- }
181
-
182
- return workFromDTO(workData);
183
- };
184
-
185
- export const getTranslationsMetadata = async ({
186
- client,
187
- }: {
188
- client: DataClient;
189
- }): Promise<Work[]> => {
190
- const { data, error } = await client
191
- .from('works')
192
- .select(
193
- `
194
- uuid,
195
- title,
196
- description,
197
- tohs:work_toh!inner(toh:toh_clean),
198
- publicationDate,
199
- publicationVersion,
200
- pages:source_pages,
201
- restriction,
202
- breadcrumb
203
- `,
204
- )
205
- .not('toh', 'like', 'toh00%');
206
- if (error) {
207
- console.error('Error fetching translations metadata:', error);
208
- return [];
209
- }
210
-
211
- const dto = data as WorkDTO[];
212
- return dto?.map((work) => workFromDTO(work as WorkDTO)) || [];
213
- };
@@ -1,23 +0,0 @@
1
- import { DataClient } from './types';
2
-
3
- export const uploadToStorage = async ({
4
- client,
5
- bucket,
6
- path,
7
- file,
8
- }: {
9
- client: DataClient;
10
- bucket: string;
11
- path: string;
12
- file: File;
13
- }) => {
14
- const { error } = await client.storage.from(bucket).upload(path, file);
15
-
16
- if (error) {
17
- console.error('Error uploading to storage:', error);
18
- return null;
19
- }
20
-
21
- const { data } = client.storage.from(bucket).getPublicUrl(path);
22
- return data.publicUrl;
23
- };
@@ -1,32 +0,0 @@
1
- import { TohokuCatalogEntry } from './toh';
2
-
3
- export type AlignmentDTO = {
4
- passage_uuid: string;
5
- folio_uuid: string;
6
- toh: TohokuCatalogEntry;
7
- tibetan: string;
8
- folio_number: number;
9
- volume_number: number;
10
- };
11
-
12
- export type Alignment = {
13
- folioUuid: string;
14
- toh: TohokuCatalogEntry;
15
- tibetan: string;
16
- folioNumber: number;
17
- volumeNumber: number;
18
- };
19
-
20
- export const alignmentFromDTO = (dto: AlignmentDTO): Alignment => {
21
- return {
22
- folioUuid: dto.folio_uuid,
23
- toh: dto.toh,
24
- tibetan: dto.tibetan,
25
- folioNumber: dto.folio_number,
26
- volumeNumber: dto.volume_number,
27
- };
28
- };
29
-
30
- export const alignmentsFromDTO = (dtos: AlignmentDTO[]): Alignment[] => {
31
- return dtos.map(alignmentFromDTO);
32
- };
@@ -1,30 +0,0 @@
1
- import type { AnnotationDTO, AnnotationDTOContent } from './annotation-type';
2
- import {
3
- type AbbreviationAnnotation,
4
- type AnnotationExporter,
5
- type AnnotationTransformer,
6
- baseAnnotationFromDTO,
7
- baseAnnotationToDto,
8
- } from './annotation';
9
-
10
- export const transformer: AnnotationTransformer = (
11
- dto,
12
- ): AbbreviationAnnotation => {
13
- const baseAnnotation = baseAnnotationFromDTO(dto);
14
- const abbreviation = baseAnnotation as AbbreviationAnnotation;
15
- dto.content.forEach((content) => {
16
- if (content.uuid) {
17
- abbreviation.abbreviation = content.uuid as string;
18
- }
19
- });
20
- return abbreviation;
21
- };
22
-
23
- export const exporter: AnnotationExporter = (annotation): AnnotationDTO => {
24
- const { abbreviation: uuid } = annotation as AbbreviationAnnotation;
25
- const dto = baseAnnotationToDto(annotation);
26
- dto.content.push({
27
- uuid,
28
- } as AnnotationDTOContent);
29
- return dto;
30
- };
@@ -1,219 +0,0 @@
1
- import { TohokuCatalogEntry } from '../toh';
2
-
3
- export type AnnotationDTOType =
4
- | 'abbreviation'
5
- | 'audio'
6
- | 'blockquote'
7
- | 'code'
8
- | 'deprecated-internal-link'
9
- | 'end-note-link'
10
- | 'glossary-instance'
11
- | 'has-abbreviation'
12
- | 'heading'
13
- | 'image'
14
- | 'indent'
15
- | 'inline-title'
16
- | 'internal-link'
17
- | 'leading-space'
18
- | 'line'
19
- | 'line-group'
20
- | 'link'
21
- | 'list'
22
- | 'list-item'
23
- | 'mantra'
24
- | 'mention'
25
- | 'paragraph'
26
- | 'quote'
27
- | 'quoted'
28
- | 'reference'
29
- | 'span'
30
- | 'table'
31
- | 'table-body-data'
32
- | 'table-body-header'
33
- | 'table-body-row'
34
- | 'trailer'
35
- | 'unknown';
36
-
37
- export type AnnotationType =
38
- | 'abbreviation'
39
- | 'audio'
40
- | 'blockquote'
41
- | 'code'
42
- | 'deprecated'
43
- | 'endNoteLink'
44
- | 'glossaryInstance'
45
- | 'hasAbbreviation'
46
- | 'heading'
47
- | 'image'
48
- | 'indent'
49
- | 'inlineTitle'
50
- | 'internalLink'
51
- | 'leadingSpace'
52
- | 'line'
53
- | 'lineGroup'
54
- | 'link'
55
- | 'list'
56
- | 'listItem'
57
- | 'mantra'
58
- | 'mention'
59
- | 'paragraph'
60
- | 'quote'
61
- | 'quoted'
62
- | 'reference'
63
- | 'span'
64
- | 'table'
65
- | 'tableBodyData'
66
- | 'tableBodyHeader'
67
- | 'tableBodyRow'
68
- | 'trailer'
69
- | 'unknown';
70
-
71
- export const ANNOTATION_TYPE_DTO_TO_TYPE: Record<
72
- AnnotationDTOType,
73
- AnnotationType
74
- > = {
75
- abbreviation: 'abbreviation',
76
- audio: 'audio',
77
- blockquote: 'blockquote',
78
- code: 'code',
79
- 'deprecated-internal-link': 'deprecated',
80
- 'end-note-link': 'endNoteLink',
81
- 'glossary-instance': 'glossaryInstance',
82
- 'has-abbreviation': 'hasAbbreviation',
83
- heading: 'heading',
84
- image: 'image',
85
- indent: 'indent',
86
- 'inline-title': 'inlineTitle',
87
- 'internal-link': 'internalLink',
88
- 'leading-space': 'leadingSpace',
89
- line: 'line',
90
- 'line-group': 'lineGroup',
91
- link: 'link',
92
- list: 'list',
93
- 'list-item': 'listItem',
94
- mantra: 'mantra',
95
- mention: 'mention',
96
- paragraph: 'paragraph',
97
- quote: 'quote',
98
- quoted: 'quoted',
99
- reference: 'reference',
100
- span: 'span',
101
- table: 'table',
102
- 'table-body-data': 'tableBodyData',
103
- 'table-body-header': 'tableBodyHeader',
104
- 'table-body-row': 'tableBodyRow',
105
- trailer: 'trailer',
106
- unknown: 'unknown',
107
- } as const;
108
-
109
- export const annotationTypeFromDTO = (
110
- type: AnnotationDTOType,
111
- ): AnnotationType => {
112
- return ANNOTATION_TYPE_DTO_TO_TYPE[type] || 'unknown';
113
- };
114
-
115
- export const ANNOTATION_TYPE_TO_DTO: Record<AnnotationType, AnnotationDTOType> =
116
- {
117
- abbreviation: 'abbreviation',
118
- audio: 'audio',
119
- blockquote: 'blockquote',
120
- code: 'code',
121
- deprecated: 'deprecated-internal-link',
122
- endNoteLink: 'end-note-link',
123
- glossaryInstance: 'glossary-instance',
124
- hasAbbreviation: 'has-abbreviation',
125
- heading: 'heading',
126
- image: 'image',
127
- indent: 'indent',
128
- inlineTitle: 'inline-title',
129
- internalLink: 'internal-link',
130
- leadingSpace: 'leading-space',
131
- line: 'line',
132
- lineGroup: 'line-group',
133
- link: 'link',
134
- list: 'list',
135
- listItem: 'list-item',
136
- mantra: 'mantra',
137
- mention: 'mention',
138
- paragraph: 'paragraph',
139
- quote: 'quote',
140
- quoted: 'quoted',
141
- reference: 'reference',
142
- span: 'span',
143
- table: 'table',
144
- tableBodyData: 'table-body-data',
145
- tableBodyHeader: 'table-body-header',
146
- tableBodyRow: 'table-body-row',
147
- trailer: 'trailer',
148
- unknown: 'unknown',
149
- } as const;
150
-
151
- export type AnnotationDTOContentKey =
152
- | 'authority'
153
- | 'endnote_xmlId'
154
- | 'glossary_xmlId'
155
- | 'heading-level'
156
- | 'heading-type'
157
- | 'href'
158
- | 'label'
159
- | 'lang'
160
- | 'link-text'
161
- | 'link-text-lookup'
162
- | 'link-type'
163
- | 'list-item-style'
164
- | 'list-spacing'
165
- | 'media-type'
166
- | 'nesting'
167
- | 'paragraph'
168
- | 'quote_xmlId'
169
- | 'src'
170
- | 'text-style'
171
- | 'text'
172
- | 'type'
173
- | 'title'
174
- | 'uuid'
175
- | 'same_work'
176
- | 'subtype'
177
- | 'toh';
178
-
179
- export type AnnotationDTOContent = Partial<
180
- Record<AnnotationDTOContentKey, unknown>
181
- >;
182
-
183
- export type AnnotationDTO = {
184
- content: AnnotationDTOContent[];
185
- end: number;
186
- start: number;
187
- type: AnnotationDTOType;
188
- uuid: string;
189
- passage_uuid?: string;
190
- passageUuid?: string;
191
- toh?: TohokuCatalogEntry;
192
- };
193
-
194
- export type AnnotationsDTO = AnnotationDTO[];
195
-
196
- export const annotationTypeToDTO = (
197
- type: AnnotationType,
198
- ): AnnotationDTOType => {
199
- return ANNOTATION_TYPE_TO_DTO[type] || 'unknown';
200
- };
201
-
202
- export const ANNOTATIONS_TO_IGNORE: AnnotationDTOType[] = [
203
- 'deprecated-internal-link',
204
- 'quoted',
205
- 'reference',
206
- 'unknown',
207
- ];
208
-
209
- export type AnnotationsToIgnore = (typeof ANNOTATIONS_TO_IGNORE)[number];
210
-
211
- export type AnnotationBase = {
212
- end: number;
213
- start: number;
214
- type: AnnotationType;
215
- uuid: string;
216
- passageUuid: string;
217
- validated?: boolean;
218
- toh?: TohokuCatalogEntry;
219
- };