@coffre/ui 0.1.17 → 0.2.0

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 (235) hide show
  1. package/README.md +23 -3
  2. package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
  3. package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
  4. package/dist/chunks/directory-CSjWWUQ1.js +370 -0
  5. package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
  6. package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
  7. package/dist/chunks/grants-saMQagmG.js.map +1 -0
  8. package/dist/chunks/icons-D-PfAfnH.js +203 -0
  9. package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
  10. package/dist/chunks/mounted-jJmqqV_n.js +17 -0
  11. package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
  12. package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
  13. package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
  14. package/dist/chunks/page-C5HcNqf2.js +190 -0
  15. package/dist/chunks/page-C5HcNqf2.js.map +1 -0
  16. package/dist/chunks/page-route-Drfw7lmn.js +20 -0
  17. package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
  18. package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
  19. package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
  20. package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
  21. package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
  22. package/dist/chunks/queries-CQ81o4so.js +376 -0
  23. package/dist/chunks/queries-CQ81o4so.js.map +1 -0
  24. package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
  25. package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
  26. package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
  27. package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
  28. package/dist/chunks/theme-B2vQolVR.js +86 -0
  29. package/dist/chunks/theme-B2vQolVR.js.map +1 -0
  30. package/dist/chunks/ui-DixXLQvQ.js +405 -0
  31. package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
  32. package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
  33. package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
  34. package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
  35. package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
  36. package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
  37. package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
  38. package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
  39. package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
  40. package/dist/index.d.ts +386 -18
  41. package/dist/index.js +1147 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/pages/account.d.ts +9 -0
  44. package/dist/pages/account.js +334 -0
  45. package/dist/pages/account.js.map +1 -0
  46. package/dist/pages/audit.d.ts +3 -0
  47. package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
  48. package/dist/pages/audit.js.map +1 -0
  49. package/dist/pages/device-login.d.ts +9 -0
  50. package/dist/pages/device-login.js +211 -0
  51. package/dist/pages/device-login.js.map +1 -0
  52. package/dist/pages/environment.d.ts +3 -0
  53. package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
  54. package/dist/pages/environment.js.map +1 -0
  55. package/dist/pages/login.d.ts +10 -0
  56. package/dist/pages/login.js +104 -0
  57. package/dist/pages/login.js.map +1 -0
  58. package/dist/pages/project.d.ts +2 -0
  59. package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
  60. package/dist/pages/project.js.map +1 -0
  61. package/dist/pages/projects.d.ts +3 -0
  62. package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
  63. package/dist/pages/projects.js.map +1 -0
  64. package/dist/pages/settings.d.ts +3 -0
  65. package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
  66. package/dist/pages/settings.js.map +1 -0
  67. package/dist/pages/token.d.ts +3 -0
  68. package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +195 -265
  69. package/dist/pages/token.js.map +1 -0
  70. package/dist/pages/tokens.d.ts +3 -0
  71. package/dist/pages/tokens.js +39 -0
  72. package/dist/pages/tokens.js.map +1 -0
  73. package/dist/pages/unregistered.d.ts +8 -0
  74. package/dist/pages/unregistered.js +54 -0
  75. package/dist/pages/unregistered.js.map +1 -0
  76. package/dist/pages/user.d.ts +3 -0
  77. package/dist/pages/user.js +16 -0
  78. package/dist/pages/user.js.map +1 -0
  79. package/dist/pages/users.d.ts +3 -0
  80. package/dist/pages/users.js +39 -0
  81. package/dist/pages/users.js.map +1 -0
  82. package/dist/project-BqIy8gYR.d.ts +5 -0
  83. package/dist/vite.d.ts +16 -0
  84. package/dist/vite.js +52 -0
  85. package/package.json +36 -21
  86. package/src/assets/icon.svg +1 -0
  87. package/src/components/affordances.ts +10 -4
  88. package/src/components/command-palette.tsx +229 -203
  89. package/src/components/directory.tsx +34 -38
  90. package/src/components/principal.tsx +7 -3
  91. package/src/components/shell.tsx +89 -127
  92. package/src/components/theme.tsx +14 -81
  93. package/src/components/ui.tsx +97 -68
  94. package/src/index.ts +29 -0
  95. package/src/layout.tsx +113 -0
  96. package/src/lib/coffre.ts +8 -4
  97. package/src/lib/mounted.ts +13 -0
  98. package/src/lib/page-context.ts +31 -0
  99. package/src/lib/page-route.ts +22 -0
  100. package/src/lib/preferences.tsx +46 -0
  101. package/src/options.ts +240 -0
  102. package/src/{routes → pages}/account.tsx +7 -24
  103. package/src/{routes → pages}/audit.tsx +5 -16
  104. package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
  105. package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
  106. package/src/{routes → pages}/login.tsx +5 -16
  107. package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
  108. package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
  109. package/src/{routes → pages}/settings.tsx +3 -10
  110. package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
  111. package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
  112. package/src/{routes → pages}/unregistered.tsx +1 -6
  113. package/src/pages/user.tsx +10 -0
  114. package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
  115. package/src/register.ts +55 -0
  116. package/src/router.tsx +31 -62
  117. package/src/styles/globals.css +104 -46
  118. package/src/vite.ts +78 -0
  119. package/dist/client/.assetsignore +0 -2
  120. package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
  121. package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
  122. package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
  123. package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
  124. package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
  125. package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
  126. package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
  127. package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
  128. package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
  129. package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
  130. package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
  131. package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
  132. package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
  133. package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  134. package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  135. package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  136. package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  137. package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  138. package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  139. package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  140. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  141. package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  142. package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  143. package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  144. package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  145. package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  146. package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
  147. package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
  148. package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
  149. package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
  150. package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
  151. package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
  152. package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
  153. package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
  154. package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
  155. package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
  156. package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
  157. package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
  158. package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
  159. package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
  160. package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
  161. package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
  162. package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
  163. package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
  164. package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
  165. package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
  166. package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
  167. package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
  168. package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
  169. package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
  170. package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
  171. package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
  172. package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
  173. package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
  174. package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
  175. package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
  176. package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
  177. package/dist/server/.vite/manifest.json +0 -668
  178. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
  179. package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
  180. package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
  181. package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
  182. package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
  183. package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
  184. package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
  185. package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
  186. package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
  187. package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
  188. package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
  189. package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
  190. package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
  191. package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
  192. package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
  193. package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
  194. package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
  195. package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
  196. package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
  197. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
  198. package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  199. package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  200. package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  201. package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  202. package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  203. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
  204. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
  205. package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
  206. package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
  207. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
  208. package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
  209. package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
  210. package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
  211. package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
  212. package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
  213. package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
  214. package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
  215. package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
  216. package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
  217. package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
  218. package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
  219. package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
  220. package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
  221. package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
  222. package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
  223. package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
  224. package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
  225. package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
  226. package/dist/server/index.js +0 -13911
  227. package/src/assets/favicon-32.png +0 -0
  228. package/src/components/agentation.tsx +0 -34
  229. package/src/entry.ts +0 -19
  230. package/src/routeTree.gen.ts +0 -367
  231. package/src/routes/__root.tsx +0 -169
  232. package/src/routes/access.tsx +0 -11
  233. package/src/routes/index.tsx +0 -15
  234. package/src/routes/users.$user.tsx +0 -13
  235. package/src/types.ts +0 -21
package/src/options.ts ADDED
@@ -0,0 +1,240 @@
1
+ // coffre's routes, as route options: what each layout and page does, its
2
+ // loader, search and redirects, but not where it goes. A deployment mounts
3
+ // them, as Start's file routes,
4
+ //
5
+ // // src/routes/_coffre.tsx
6
+ // export const Route = createFileRoute('/_coffre')({ ...shell });
7
+ //
8
+ // // src/routes/_coffre/projects.index.tsx
9
+ // import { ProjectsPage } from '@coffre/ui/pages/projects';
10
+ // export const Route = createFileRoute('/_coffre/projects/')({ ...projects, component: ProjectsPage });
11
+ //
12
+ // or in code, with TanStack's own `createRoute({ getParentRoute, path,
13
+ // ...projects, component: ProjectsPage })`. A layout's options hold its
14
+ // component. A page's do not: the route file names it, from its own module,
15
+ // so that Start's splitter puts each page in a chunk of its own, with its
16
+ // preload hints. Each page goes at the path coffre's links name; one at
17
+ // another path is one the links do not reach.
18
+ import { redirect, type ParsedLocation } from '@tanstack/react-router';
19
+ import type { QueryClient } from '@tanstack/react-query';
20
+ import type { CoffreClient } from '@coffre/client';
21
+
22
+ import { ShellLayout, SoloLayout } from './layout';
23
+ import { uiResult } from './lib/coffre';
24
+ import { loadDirectory, loadPrincipal, loadProject, loadShell, queries, type AuditSearch } from './lib/queries';
25
+ import type { ProjectTab } from './pages/project';
26
+
27
+ /**
28
+ * What coffre's routes read through the router: the API as the visitor
29
+ * (`coffre`), and the query cache the pages share. The deployment's root is
30
+ * created with it, `createRootRouteWithContext<CoffreContext>()`, and
31
+ * coffre's `createRouter` provides it.
32
+ */
33
+ export type CoffreContext = { coffre: CoffreClient; queryClient: QueryClient };
34
+
35
+ /**
36
+ * coffre's context, as a route's loader reads it. The options take any
37
+ * parent, whose context the types cannot follow; the root's is coffre's.
38
+ */
39
+ const coffreOf = (context: unknown) => context as CoffreContext;
40
+
41
+ type Loader<TParams = object> = { context: unknown; params: TParams; location: ParsedLocation };
42
+
43
+ // --- the layouts ------------------------------------------------------------------------
44
+
45
+ /** coffre's nav, around the signed-in pages: someone not signed in, or not yet registered, is sent to the page for it. */
46
+ export const shell = {
47
+ loader: async ({ context, location }: Loader) => {
48
+ const { coffre, queryClient } = coffreOf(context);
49
+ const shell = await loadShell(queryClient, coffre);
50
+ if (shell.registrationRequired) throw redirect({ to: '/unregistered' });
51
+ if (shell.principal === null) throw redirect({ to: '/login', search: { next: location.href } });
52
+ },
53
+ component: ShellLayout,
54
+ };
55
+
56
+ /** The bare frame of the sign-in pages. Each sends on whoever does not belong there. */
57
+ export const solo = { component: SoloLayout };
58
+
59
+ // --- under the shell ------------------------------------------------------------------
60
+
61
+ /** `/`, which sends to the projects. */
62
+ export const home = {
63
+ beforeLoad: () => {
64
+ throw redirect({ to: '/projects' });
65
+ },
66
+ };
67
+
68
+ /** `/projects`. */
69
+ export const projects = {
70
+ loader: ({ context }: Loader) => {
71
+ const { coffre, queryClient } = coffreOf(context);
72
+ return queryClient.fetchQuery(queries.projects(coffre));
73
+ },
74
+ };
75
+
76
+ /** `/projects/$project`. */
77
+ export const project = {
78
+ // The tab lives in the URL so a link can land on a project's access list.
79
+ // Environments is the default and so has no parameter.
80
+ validateSearch: (search: Record<string, unknown>): { tab?: Exclude<ProjectTab, 'environments'> } => ({
81
+ tab: search.tab === 'users' || search.tab === 'tokens' || search.tab === 'settings' ? search.tab : undefined,
82
+ }),
83
+ loader: ({ context, params }: Loader<{ project: string }>) => {
84
+ const { coffre, queryClient } = coffreOf(context);
85
+ return loadProject(queryClient, coffre, params.project);
86
+ },
87
+ };
88
+
89
+ /** `/projects/$project/$environment`. */
90
+ export const environment = {
91
+ // `?filter=KEY` opens the ledger narrowed to matching keys, for links to one secret.
92
+ validateSearch: (search: Record<string, unknown>): { filter?: string } => ({
93
+ filter: typeof search.filter === 'string' && search.filter !== '' ? search.filter : undefined,
94
+ }),
95
+ loader: ({ context, params }: Loader<{ project: string; environment: string }>) => {
96
+ const { coffre, queryClient } = coffreOf(context);
97
+ return queryClient.fetchQuery(queries.secrets(coffre, params));
98
+ },
99
+ };
100
+
101
+ /** `/audit`. */
102
+ export const audit = {
103
+ // Filters live in the URL so a finding can cite the exact view it came from.
104
+ validateSearch: (search: Record<string, unknown>): AuditSearch => ({
105
+ decision: search.decision === 'deny' ? 'deny' : undefined,
106
+ actorId: typeof search.actorId === 'string' && search.actorId !== '' ? search.actorId : undefined,
107
+ detail: search.detail === '1' || search.detail === 1 ? '1' : undefined,
108
+ }),
109
+ loaderDeps: ({ search }: { search: AuditSearch }) => search,
110
+ // The entries only: the verification is asked for once the page is up
111
+ // (`ChainStatus`), so the table never waits on it.
112
+ loader: ({ context, deps }: Loader & { deps: AuditSearch }) => {
113
+ const { coffre, queryClient } = coffreOf(context);
114
+ return queryClient.fetchQuery(queries.auditEntries(coffre, deps));
115
+ },
116
+ };
117
+
118
+ /** `/access`: the access page became the users page, and old links land there. */
119
+ export const access = {
120
+ beforeLoad: () => {
121
+ throw redirect({ to: '/users' });
122
+ },
123
+ };
124
+
125
+ /** `/users`. */
126
+ export const users = {
127
+ loader: ({ context }: Loader) => {
128
+ const { coffre, queryClient } = coffreOf(context);
129
+ return loadDirectory(queryClient, coffre);
130
+ },
131
+ };
132
+
133
+ /** `/users/$user`. */
134
+ export const user = {
135
+ loader: ({ context, params }: Loader<{ user: string }>) => {
136
+ const { coffre, queryClient } = coffreOf(context);
137
+ return loadPrincipal(queryClient, coffre, 'user', params.user);
138
+ },
139
+ };
140
+
141
+ /** `/tokens`. */
142
+ export const tokens = {
143
+ loader: ({ context }: Loader) => {
144
+ const { coffre, queryClient } = coffreOf(context);
145
+ return loadDirectory(queryClient, coffre);
146
+ },
147
+ };
148
+
149
+ /** `/tokens/$token`. */
150
+ export const token = {
151
+ loader: ({ context, params }: Loader<{ token: string }>) => {
152
+ const { coffre, queryClient } = coffreOf(context);
153
+ return loadPrincipal(queryClient, coffre, 'service', params.token);
154
+ },
155
+ };
156
+
157
+ /** `/settings`. */
158
+ export const settings = {
159
+ // Instance facts come from the directory, which only owners may list.
160
+ // Asking on everyone's behalf would write a refusal to the audit log for
161
+ // every user who opens the page, so it is only asked for them.
162
+ loader: ({ context }: Loader) => {
163
+ const { coffre, queryClient } = coffreOf(context);
164
+ return loadDirectory(queryClient, coffre);
165
+ },
166
+ };
167
+
168
+ type AccountSearch = { linked?: string; error?: string };
169
+
170
+ /** `/account`. */
171
+ export const account = {
172
+ validateSearch: (search: Record<string, unknown>): AccountSearch => {
173
+ const out: AccountSearch = {};
174
+ for (const name of ['linked', 'error'] as const) {
175
+ const value = search[name];
176
+ if (typeof value === 'string' && /^[a-z0-9_-]{1,40}$/.test(value)) out[name] = value;
177
+ }
178
+ return out;
179
+ },
180
+ // The sign-in half: which accounts you sign in with and where you are
181
+ // signed in. Absent behind Cloudflare Access, which owns sessions there.
182
+ loader: async ({ context }: Loader) => {
183
+ const { coffre, queryClient } = coffreOf(context);
184
+ const shell = await loadShell(queryClient, coffre);
185
+ if (shell.auth.signin === null || shell.principal?.type !== 'user') return;
186
+ await Promise.all([queryClient.fetchQuery(queries.identities(coffre)), queryClient.fetchQuery(queries.sessions(coffre))]);
187
+ },
188
+ };
189
+
190
+ // --- in the solo frame ----------------------------------------------------------------
191
+
192
+ /** `/login`. */
193
+ export const login = {
194
+ // Where to resume after signing in. Same-origin paths only: an absolute URL
195
+ // accepted here would make the sign-in page an open redirect.
196
+ validateSearch: (search: Record<string, unknown>): { next?: string; error?: string } => {
197
+ const out: { next?: string; error?: string } = {};
198
+ const { next, error } = search;
199
+ if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) out.next = next;
200
+ if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;
201
+ return out;
202
+ },
203
+ loader: async ({ context }: Loader) => {
204
+ const { coffre, queryClient } = coffreOf(context);
205
+ const shell = await loadShell(queryClient, coffre);
206
+ if (shell.registrationRequired) throw redirect({ to: '/unregistered' });
207
+ if (shell.principal !== null) throw redirect({ to: '/projects' });
208
+ },
209
+ };
210
+
211
+ /** `/unregistered`. */
212
+ export const unregistered = {
213
+ loader: async ({ context, location }: Loader) => {
214
+ const { coffre, queryClient } = coffreOf(context);
215
+ const shell = await loadShell(queryClient, coffre);
216
+ if (shell.registrationRequired) return;
217
+ if (shell.principal === null) throw redirect({ to: '/login', search: { next: location.href } });
218
+ throw redirect({ to: '/projects' });
219
+ },
220
+ };
221
+
222
+ /** `/auth/device`. */
223
+ export const deviceLogin = {
224
+ validateSearch: (search: Record<string, unknown>): { code?: string } => {
225
+ const code = search.code;
226
+ return typeof code === 'string' && code.length <= 16 ? { code } : {};
227
+ },
228
+ loaderDeps: ({ search }: { search: { code?: string } }) => ({ code: search.code }),
229
+ // Its own read, not a query: it is asked once, and nothing here refreshes it.
230
+ loader: async ({ context, deps, location }: Loader & { deps: { code?: string } }) => {
231
+ const { coffre, queryClient } = coffreOf(context);
232
+ const shell = await loadShell(queryClient, coffre);
233
+ if (shell.registrationRequired) throw redirect({ to: '/unregistered' });
234
+ if (shell.principal === null) throw redirect({ to: '/login', search: { next: location.href } });
235
+ if (deps.code === undefined) return null;
236
+ if (!shell.auth.signin) return { ok: false as const, error: 'This instance has no CLI sign-in.' };
237
+ const code = deps.code;
238
+ return uiResult(() => coffre.deviceLogins.get(code));
239
+ },
240
+ };
@@ -1,6 +1,6 @@
1
1
  import type { IdentityRow, SessionRow } from '@coffre/client';
2
2
  import { useSuspenseQueries } from '@tanstack/react-query';
3
- import { createFileRoute } from '@tanstack/react-router';
3
+
4
4
  import { Fragment } from 'react';
5
5
  import { useShell } from '../lib/use-shell';
6
6
  import { Card, Fact, PageHeader } from '../components/page';
@@ -11,9 +11,13 @@ import { Monitor, ProviderMark, SignOut, Terminal, X } from '../components/icons
11
11
  import { signinErrorMessage } from '../lib/signin-errors';
12
12
  import { useCoffre } from '../lib/coffre';
13
13
  import { endSession, unlinkIdentity } from '../lib/changes';
14
- import { loadShell, queries } from '../lib/queries';
14
+ import { queries } from '../lib/queries';
15
15
  import { useChange, useChangeStatus } from '../lib/use-change';
16
16
  import { RowFailure, RowPending, rowClass } from '../components/row-state';
17
+ import { pageRoute } from '../lib/page-route';
18
+ import type { account } from '../options';
19
+
20
+ const Route = pageRoute<typeof account>();
17
21
 
18
22
  type Search = { linked?: string; error?: string };
19
23
 
@@ -23,29 +27,8 @@ type Search = { linked?: string; error?: string };
23
27
  * are signed in. The sidebar's Settings is the instance's; this page is
24
28
  * reached from your account at the sidebar's foot.
25
29
  */
26
- export const Route = createFileRoute('/account')({
27
- validateSearch: (search: Record<string, unknown>): Search => {
28
- const out: Search = {};
29
- for (const name of ['linked', 'error'] as const) {
30
- const value = search[name];
31
- if (typeof value === 'string' && /^[a-z0-9_-]{1,40}$/.test(value)) out[name] = value;
32
- }
33
- return out;
34
- },
35
- // The sign-in half: which accounts you sign in with and where you are
36
- // signed in. Absent behind Cloudflare Access, which owns sessions there.
37
- loader: async ({ context: { client, queryClient } }) => {
38
- const shell = await loadShell(queryClient, client);
39
- if (shell.auth.signin === null || shell.principal?.type !== 'user') return;
40
- await Promise.all([
41
- queryClient.fetchQuery(queries.identities(client)),
42
- queryClient.fetchQuery(queries.sessions(client)),
43
- ]);
44
- },
45
- component: AccountPage,
46
- });
47
30
 
48
- function AccountPage() {
31
+ export function AccountPage() {
49
32
  const { principal, instanceRole, auth } = useShell();
50
33
 
51
34
  return (
@@ -1,7 +1,7 @@
1
1
  import type { AuditEntryView } from '@coffre/client';
2
2
  import { Fragment, useState, type ReactNode } from 'react';
3
3
  import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
4
- import { createFileRoute, Link } from '@tanstack/react-router';
4
+ import { Link } from '@tanstack/react-router';
5
5
  import { useCoffre } from '../lib/coffre';
6
6
  import { queries, type AuditSearch, type ChainResult } from '../lib/queries';
7
7
  import {
@@ -26,23 +26,12 @@ import {
26
26
  User,
27
27
  X,
28
28
  } from '../components/icons';
29
+ import { pageRoute } from '../lib/page-route';
30
+ import type { audit } from '../options';
29
31
 
30
- export const Route = createFileRoute('/audit')({
31
- // Filters live in the URL so a finding can cite the exact view it came from.
32
- validateSearch: (search: Record<string, unknown>): AuditSearch => ({
33
- decision: search.decision === 'deny' ? 'deny' : undefined,
34
- actorId:
35
- typeof search.actorId === 'string' && search.actorId !== '' ? search.actorId : undefined,
36
- detail: search.detail === '1' || search.detail === 1 ? '1' : undefined,
37
- }),
38
- loaderDeps: ({ search }) => search,
39
- // The entries only: the verification is asked for once the page is up
40
- // (`ChainStatus`), so the table never waits on it.
41
- loader: ({ context: { client, queryClient }, deps }) => queryClient.fetchQuery(queries.auditEntries(client, deps)),
42
- component: AuditPage,
43
- });
32
+ const Route = pageRoute<typeof audit>();
44
33
 
45
- function AuditPage() {
34
+ export function AuditPage() {
46
35
  const search = Route.useSearch();
47
36
  const client = useCoffre();
48
37
  const { data: result } = useSuspenseQuery(queries.auditEntries(client, search));
@@ -1,10 +1,14 @@
1
1
  import { useState } from 'react';
2
- import { createFileRoute, Link, useNavigate } from '@tanstack/react-router';
3
- import { failureMessage, statusOf, uiResult, useCoffre } from '../lib/coffre';
4
- import { loadShell } from '../lib/queries';
2
+ import { Link, useNavigate } from '@tanstack/react-router';
3
+ import { failureMessage, statusOf, useCoffre } from '../lib/coffre';
4
+
5
5
  import { ClosedDoor } from '../components/page';
6
6
  import { ErrorLine, Spinner, Timestamp } from '../components/ui';
7
7
  import { CheckCircle, SlashCircle, Terminal } from '../components/icons';
8
+ import { pageRoute } from '../lib/page-route';
9
+ import type { deviceLogin } from '../options';
10
+
11
+ const Route = pageRoute<typeof deviceLogin>();
8
12
 
9
13
  /**
10
14
  * Where `coffre login` sends you: approve a terminal's sign-in with the
@@ -12,25 +16,8 @@ import { CheckCircle, SlashCircle, Terminal } from '../components/icons';
12
16
  * shows the same code and where the request came from, and nothing happens
13
17
  * until you press Approve.
14
18
  */
15
- export const Route = createFileRoute('/auth/device')({
16
- validateSearch: (search: Record<string, unknown>): { code?: string } => {
17
- const code = search.code;
18
- return typeof code === 'string' && code.length <= 16 ? { code } : {};
19
- },
20
- loaderDeps: ({ search }) => ({ code: search.code }),
21
- // Its own read, not a query: it is asked once, and nothing here refreshes it.
22
- loader: async ({ context: { client, queryClient }, deps }) => {
23
- if (deps.code === undefined) return null;
24
- if (!(await loadShell(queryClient, client)).auth.signin) {
25
- return { ok: false as const, error: 'This instance has no CLI sign-in.' };
26
- }
27
- const code = deps.code;
28
- return uiResult(() => client.deviceLogins.get(code));
29
- },
30
- component: DevicePage,
31
- });
32
19
 
33
- function DevicePage() {
20
+ export function DevicePage() {
34
21
  const loaded = Route.useLoaderData();
35
22
  const [decided, setDecided] = useState<'approved' | 'denied' | null>(null);
36
23
 
@@ -7,9 +7,9 @@ import {
7
7
  type InputHTMLAttributes,
8
8
  } from 'react';
9
9
  import { useSuspenseQuery } from '@tanstack/react-query';
10
- import { createFileRoute, Link } from '@tanstack/react-router';
10
+ import { Link } from '@tanstack/react-router';
11
11
  import { useShell } from '../lib/use-shell';
12
- import { DropdownMenu } from 'radix-ui';
12
+ import { Menu } from '@base-ui/react/menu';
13
13
  import { toast } from 'sonner';
14
14
  import { failureMessage, useCoffre } from '../lib/coffre';
15
15
  import { archiveSecret, restoreSecret, saveSecrets, UnsavedEdits } from '../lib/changes';
@@ -40,6 +40,7 @@ import {
40
40
  CopyButton,
41
41
  EmptyState,
42
42
  ErrorLine,
43
+ MenuPopup,
43
44
  Modal,
44
45
  Notice,
45
46
  Spinner,
@@ -67,6 +68,10 @@ import {
67
68
  Upload,
68
69
  X,
69
70
  } from '../components/icons';
71
+ import { pageRoute } from '../lib/page-route';
72
+ import type { environment } from '../options';
73
+
74
+ const Route = pageRoute<typeof environment>();
70
75
 
71
76
  /**
72
77
  * How long a revealed value stays on screen.
@@ -77,17 +82,7 @@ import {
77
82
  */
78
83
  const REVEAL_TTL_SECONDS = 45;
79
84
 
80
- export const Route = createFileRoute('/projects/$project/$environment')({
81
- // `?filter=KEY` opens the ledger narrowed to matching keys, for links to one secret.
82
- validateSearch: (search: Record<string, unknown>): { filter?: string } => ({
83
- filter: typeof search.filter === 'string' && search.filter !== '' ? search.filter : undefined,
84
- }),
85
- loader: ({ context: { client, queryClient }, params }) =>
86
- queryClient.fetchQuery(queries.secrets(client, params)),
87
- component: EnvironmentPage,
88
- });
89
-
90
- function EnvironmentPage() {
85
+ export function EnvironmentPage() {
91
86
  const { project, environment } = Route.useParams();
92
87
  const { data: result } = useSuspenseQuery(queries.secrets(useCoffre(), { project, environment }));
93
88
 
@@ -987,46 +982,42 @@ function SecretRow({
987
982
  </Tip>
988
983
  )}
989
984
  {(canReveal || canArchive) && (
990
- <DropdownMenu.Root>
991
- <DropdownMenu.Trigger asChild>
992
- <button
993
- className="act act-icon act-quiet"
994
- aria-label={`More for ${entry.key}`}
995
- disabled={disabled}
996
- >
997
- <MoreHorizontal size={16} />
998
- </button>
999
- </DropdownMenu.Trigger>
1000
- <DropdownMenu.Portal>
1001
- <DropdownMenu.Content className="menu" sideOffset={6} align="end">
1002
- <SecretReadOnly canReveal={canReveal}>
1003
- <DropdownMenu.Item
1004
- className="menu-item"
1005
- onSelect={() => setHistoryOpen((open) => !open)}
985
+ <Menu.Root>
986
+ <Menu.Trigger
987
+ className="act act-icon act-quiet"
988
+ aria-label={`More for ${entry.key}`}
989
+ disabled={disabled}
990
+ >
991
+ <MoreHorizontal size={16} />
992
+ </Menu.Trigger>
993
+ <MenuPopup align="end">
994
+ <SecretReadOnly canReveal={canReveal}>
995
+ <Menu.Item
996
+ className="menu-item"
997
+ onClick={() => setHistoryOpen((open) => !open)}
998
+ >
999
+ <History size={14} />
1000
+ {historyOpen ? 'Hide history' : 'Version history'}
1001
+ </Menu.Item>
1002
+ </SecretReadOnly>
1003
+ {canArchive && (
1004
+ <>
1005
+ {canReveal && <Menu.Separator className="menu-sep" />}
1006
+ <Menu.Item
1007
+ className="menu-item menu-item-danger"
1008
+ onClick={() => {
1009
+ setReveal(null);
1010
+ onMarkArchive();
1011
+ }}
1006
1012
  >
1007
- <History size={14} />
1008
- {historyOpen ? 'Hide history' : 'Version history'}
1009
- </DropdownMenu.Item>
1010
- </SecretReadOnly>
1011
- {canArchive && (
1012
- <>
1013
- {canReveal && <DropdownMenu.Separator className="menu-sep" />}
1014
- <DropdownMenu.Item
1015
- className="menu-item menu-item-danger"
1016
- onSelect={() => {
1017
- setReveal(null);
1018
- onMarkArchive();
1019
- }}
1020
- >
1021
- <Archive size={14} />
1022
- Archive
1023
- <span className="menu-hint">on save</span>
1024
- </DropdownMenu.Item>
1025
- </>
1026
- )}
1027
- </DropdownMenu.Content>
1028
- </DropdownMenu.Portal>
1029
- </DropdownMenu.Root>
1013
+ <Archive size={14} />
1014
+ Archive
1015
+ <span className="menu-hint">on save</span>
1016
+ </Menu.Item>
1017
+ </>
1018
+ )}
1019
+ </MenuPopup>
1020
+ </Menu.Root>
1030
1021
  )}
1031
1022
  </>
1032
1023
  )}
@@ -1,25 +1,14 @@
1
1
  import { useState } from 'react';
2
- import { createFileRoute } from '@tanstack/react-router';
2
+
3
3
  import { useShell } from '../lib/use-shell';
4
4
  import { signinErrorMessage } from '../lib/signin-errors';
5
5
  import { ErrorLine, Spinner } from '../components/ui';
6
6
  import { ClosedDoor } from '../components/page';
7
7
  import { Lock, ProviderMark, ShieldCheck } from '../components/icons';
8
+ import { pageRoute } from '../lib/page-route';
9
+ import type { login } from '../options';
8
10
 
9
- export const Route = createFileRoute('/login')({
10
- // Where to resume after signing in. Same-origin paths only: an absolute URL
11
- // accepted here would make the sign-in page an open redirect.
12
- validateSearch: (search: Record<string, unknown>): { next?: string; error?: string } => {
13
- const out: { next?: string; error?: string } = {};
14
- const { next, error } = search;
15
- if (typeof next === 'string' && next.startsWith('/') && !next.startsWith('//')) {
16
- out.next = next;
17
- }
18
- if (typeof error === 'string' && /^[a-z_]{1,40}$/.test(error)) out.error = error;
19
- return out;
20
- },
21
- component: LoginPage,
22
- });
11
+ const Route = pageRoute<typeof login>();
23
12
 
24
13
  /**
25
14
  * The front door, as `GET /api/auth` describes it.
@@ -28,7 +17,7 @@ export const Route = createFileRoute('/login')({
28
17
  * Access, Access authenticates people before any request arrives, so this
29
18
  * page only explains why it is showing at all.
30
19
  */
31
- function LoginPage() {
20
+ export function LoginPage() {
32
21
  const { signin, access } = useShell().auth;
33
22
  if (signin !== null) return <ProviderLoginPage {...signin} />;
34
23
  return access?.assertion ? <CloudflareAuthenticationFailed /> : <CloudflareAccessRequired />;