@coffre/ui 0.1.9 → 0.1.11

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 (168) hide show
  1. package/dist/client/_coffre/assets/account-BJAdDvZf.js +2 -0
  2. package/dist/client/_coffre/assets/account-D0jLpk5c.js +1 -0
  3. package/dist/client/_coffre/assets/affordances-Bq2-oUB5.js +1 -0
  4. package/dist/client/_coffre/assets/audit-C-pcBgKe.js +2 -0
  5. package/dist/client/_coffre/assets/audit-CHGlDeBB.js +1 -0
  6. package/dist/client/_coffre/assets/{auth.device--rDR2F8w.js → auth.device-BndOUjse.js} +1 -1
  7. package/dist/client/_coffre/assets/auth.device-CWHNQn9W.js +2 -0
  8. package/dist/client/_coffre/assets/directory-nDExpkAz.js +1 -0
  9. package/dist/client/_coffre/assets/dist-QVHMLatb.js +1 -0
  10. package/dist/client/_coffre/assets/globals-CKBoTlyH.css +1 -0
  11. package/dist/client/_coffre/assets/grants-CjoOnxzz.js +1 -0
  12. package/dist/client/_coffre/assets/icons-BQ27Ds9u.js +1 -0
  13. package/dist/client/_coffre/assets/index-CUGytaO3.js +12 -0
  14. package/dist/client/_coffre/assets/link-DP8SVWon.js +1 -0
  15. package/dist/client/_coffre/assets/login-CeaxDMcr.js +2 -0
  16. package/dist/client/_coffre/assets/login-DrMgvqZn.js +1 -0
  17. package/dist/client/_coffre/assets/offboarding-CNr_1tnl.js +1 -0
  18. package/dist/client/_coffre/assets/page-CGmvjSy4.js +1 -0
  19. package/dist/client/_coffre/assets/preload-helper-ClBkJ19f.js +1 -0
  20. package/dist/client/_coffre/assets/principal-page-DNLb_q_e.js +1 -0
  21. package/dist/client/_coffre/assets/projects._project._environment-CHzbboGp.js +3 -0
  22. package/dist/client/_coffre/assets/projects._project._environment-DDxu_HHD.js +2 -0
  23. package/dist/client/_coffre/assets/projects._project.index-CIAsjvg6.js +2 -0
  24. package/dist/client/_coffre/assets/projects._project.index-DZ9l6d-1.js +1 -0
  25. package/dist/client/_coffre/assets/projects.index-4eUXreE_.js +1 -0
  26. package/dist/client/_coffre/assets/row-state-ByET1OKX.js +1 -0
  27. package/dist/client/_coffre/assets/settings-D2zp1Ssu.js +1 -0
  28. package/dist/client/_coffre/assets/suspense-C7KwSnTG.js +1 -0
  29. package/dist/client/_coffre/assets/tokens._token-DWmbqzNk.js +2 -0
  30. package/dist/client/_coffre/assets/tokens._token-Dui_4KfS.js +1 -0
  31. package/dist/client/_coffre/assets/tokens.index-CSi5Wxwf.js +1 -0
  32. package/dist/client/_coffre/assets/ui-BdipqGpP.js +46 -0
  33. package/dist/client/_coffre/assets/unregistered-CA7B4C1m.js +1 -0
  34. package/dist/client/_coffre/assets/use-action-DRm9yVhV.js +1 -0
  35. package/dist/client/_coffre/assets/use-change-BRRMJocl.js +1 -0
  36. package/dist/client/_coffre/assets/use-shell-BMGlJ25Q.js +1 -0
  37. package/dist/client/_coffre/assets/useQuery-D__2KBOs.js +1 -0
  38. package/dist/client/_coffre/assets/useSuspenseQuery-CSXyDALB.js +1 -0
  39. package/dist/client/_coffre/assets/users._user-BkNrX7Qf.js +1 -0
  40. package/dist/client/_coffre/assets/users._user-jbSvtdOg.js +2 -0
  41. package/dist/client/_coffre/assets/users.index-CKnQ1G76.js +1 -0
  42. package/dist/server/.vite/manifest.json +343 -246
  43. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-Dx-c3XVk.js +162 -0
  44. package/dist/server/_coffre/assets/{account-CZgVVZTf.js → account-BocTPU1J.js} +150 -117
  45. package/dist/server/_coffre/assets/{account-D7-ZAE2T.js → account-CL8hOGhO.js} +10 -24
  46. package/dist/server/_coffre/assets/{affordances-BNaXjMOb.js → affordances-CKANXDTG.js} +2 -22
  47. package/dist/server/_coffre/assets/{async-local-storage-C0cwgkEr.js → async-local-storage-C10uQtMM.js} +3 -2
  48. package/dist/server/_coffre/assets/{audit-BEbhtsEp.js → audit-Bcka4vA6.js} +46 -16
  49. package/dist/server/_coffre/assets/audit-CSRQYIhu.js +31 -0
  50. package/dist/server/_coffre/assets/{auth.device-w9N3FlNk.js → auth.device-CMcUISZY.js} +7 -5
  51. package/dist/server/_coffre/assets/{auth.device-CMR3csAI.js → auth.device-DqO0T-rU.js} +5 -5
  52. package/dist/server/_coffre/assets/{directory-Dr5X9TB5.js → directory-CyYx6Jx1.js} +87 -112
  53. package/dist/server/_coffre/assets/{use-action-DQUmeH-5.js → dist-CnnV3t2g.js} +3 -48
  54. package/dist/server/_coffre/assets/globals-CKBoTlyH.css +1 -0
  55. package/dist/server/_coffre/assets/grants-CRijabX0.js +158 -0
  56. package/dist/server/_coffre/assets/{page-BdnhpwvH.js → icons-Dy-5ccDF.js} +3 -196
  57. package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +480 -0
  58. package/dist/server/_coffre/assets/link-42ZWdjzZ.js +422 -0
  59. package/dist/server/_coffre/assets/{login-DUtCQju5.js → login-BI9tzJEy.js} +7 -5
  60. package/dist/server/_coffre/assets/{login-B2njIq_o.js → login-C-v88YwP.js} +2 -2
  61. package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +56 -0
  62. package/dist/server/_coffre/assets/{offboarding-DY5MarpG.js → offboarding-1H0LavTd.js} +6 -4
  63. package/dist/server/_coffre/assets/page-D_mO0-sn.js +3592 -0
  64. package/dist/server/_coffre/assets/{principal-page-SdG8_zcu.js → principal-page-DQDoXute.js} +51 -42
  65. package/dist/server/_coffre/assets/{projects._project._environment-CUS0VFUe.js → projects._project._environment-C-yVwC92.js} +168 -248
  66. package/dist/server/_coffre/assets/{projects._project._environment-BQIrmE3r.js → projects._project._environment-D_5R40of.js} +4 -11
  67. package/dist/server/_coffre/assets/{projects._project.index-D1NxvBtZ.js → projects._project.index-A2BImFIT.js} +134 -96
  68. package/dist/server/_coffre/assets/{projects._project.index-BjNdR4KC.js → projects._project.index-BPPKxKrt.js} +5 -4
  69. package/dist/server/_coffre/assets/{projects.index-BQDuuh6t.js → projects.index-543IsPzY.js} +62 -54
  70. package/dist/server/_coffre/assets/{react-dom-qCTiwGGR.js → react-dom-bBoJXlK2.js} +417 -51
  71. package/dist/server/_coffre/assets/{router-BUwZOXEH.js → router-CM3vK8QO.js} +376 -92
  72. package/dist/server/_coffre/assets/row-state-XBtDoIA4.js +117 -0
  73. package/dist/server/_coffre/assets/{settings-HOErM3pd.js → settings-BLVU74ym.js} +8 -6
  74. package/dist/server/_coffre/assets/suspense-CzYTwxOj.js +602 -0
  75. package/dist/server/_coffre/assets/tokens._token-B-hBgwBW.js +10 -0
  76. package/dist/server/_coffre/assets/{tokens._token-BZUArbzi.js → tokens._token-aubAUonP.js} +97 -79
  77. package/dist/server/_coffre/assets/{tokens.index-BReCgoV9.js → tokens.index-4D3jwp5v.js} +9 -6
  78. package/dist/server/_coffre/assets/{ui-D_slKpSF.js → ui-BI3Bf72q.js} +7 -836
  79. package/dist/server/_coffre/assets/{unregistered-Z17da4Rc.js → unregistered-CagDxMyw.js} +5 -3
  80. package/dist/server/_coffre/assets/use-action-tzBZvjjQ.js +47 -0
  81. package/dist/server/_coffre/assets/use-change-Dggqxy5y.js +1212 -0
  82. package/dist/server/_coffre/assets/use-shell-CwStDfzX.js +462 -0
  83. package/dist/server/_coffre/assets/useQuery-C6_dBjem.js +8 -0
  84. package/dist/server/_coffre/assets/{useStore-DWGPqzXR.js → useRouter-CaUSUNsw.js} +1 -420
  85. package/dist/server/_coffre/assets/useSuspenseQuery-BuapQt_P.js +117 -0
  86. package/dist/server/_coffre/assets/{users._user-DHTNhQ9o.js → users._user-137WNyxn.js} +4 -5
  87. package/dist/server/_coffre/assets/users._user-C252Iilj.js +10 -0
  88. package/dist/server/_coffre/assets/{users.index-Cfo3ODpX.js → users.index-DQHsfnal.js} +9 -6
  89. package/dist/server/index.js +6 -5
  90. package/package.json +5 -3
  91. package/src/components/directory.tsx +75 -104
  92. package/src/components/grants.tsx +60 -112
  93. package/src/components/principal-page.tsx +54 -67
  94. package/src/components/principal-picker.tsx +7 -16
  95. package/src/components/row-state.tsx +95 -0
  96. package/src/components/service-tokens.tsx +75 -64
  97. package/src/components/shell.tsx +1 -1
  98. package/src/components/syncs.tsx +42 -26
  99. package/src/lib/announce.ts +36 -0
  100. package/src/lib/changes.ts +498 -0
  101. package/src/lib/coffre.ts +3 -2
  102. package/src/lib/optimistic.ts +233 -0
  103. package/src/lib/queries.ts +393 -0
  104. package/src/lib/use-action.ts +20 -15
  105. package/src/lib/use-change.ts +42 -0
  106. package/src/lib/use-shell.ts +17 -0
  107. package/src/router.tsx +17 -9
  108. package/src/routes/__root.tsx +8 -38
  109. package/src/routes/account.tsx +163 -154
  110. package/src/routes/audit.tsx +51 -72
  111. package/src/routes/auth.device.tsx +4 -2
  112. package/src/routes/login.tsx +3 -2
  113. package/src/routes/projects.$project.$environment.tsx +226 -231
  114. package/src/routes/projects.$project.index.tsx +136 -118
  115. package/src/routes/projects.index.tsx +125 -145
  116. package/src/routes/settings.tsx +7 -7
  117. package/src/routes/tokens.$token.tsx +14 -17
  118. package/src/routes/tokens.index.tsx +8 -4
  119. package/src/routes/unregistered.tsx +3 -2
  120. package/src/routes/users.$user.tsx +4 -4
  121. package/src/routes/users.index.tsx +8 -4
  122. package/src/styles/globals.css +78 -1
  123. package/dist/client/_coffre/assets/account-C3rBPdu6.js +0 -2
  124. package/dist/client/_coffre/assets/account-J194gi6l.js +0 -1
  125. package/dist/client/_coffre/assets/affordances-CmoY-8Xf.js +0 -1
  126. package/dist/client/_coffre/assets/audit-BtI9em7Q.js +0 -2
  127. package/dist/client/_coffre/assets/audit-jURfT8Km.js +0 -1
  128. package/dist/client/_coffre/assets/auth.device-viDUwZRT.js +0 -2
  129. package/dist/client/_coffre/assets/coffre-CXkp3Efg.js +0 -1
  130. package/dist/client/_coffre/assets/directory-PEjdb8PS.js +0 -1
  131. package/dist/client/_coffre/assets/globals-Bh2x1gBM.css +0 -1
  132. package/dist/client/_coffre/assets/grants-4mSkXPU4.js +0 -1
  133. package/dist/client/_coffre/assets/index-CD7bvUCb.js +0 -12
  134. package/dist/client/_coffre/assets/login-C-wTm_t1.js +0 -2
  135. package/dist/client/_coffre/assets/login-CLLv1om9.js +0 -1
  136. package/dist/client/_coffre/assets/offboarding-DQ-56W0H.js +0 -1
  137. package/dist/client/_coffre/assets/page-DbSS7pYH.js +0 -1
  138. package/dist/client/_coffre/assets/preload-helper-DduCCcmc.js +0 -46
  139. package/dist/client/_coffre/assets/principal-page-DjH1cUyz.js +0 -1
  140. package/dist/client/_coffre/assets/projects._project._environment-BZnNvENc.js +0 -3
  141. package/dist/client/_coffre/assets/projects._project._environment-CLUpTvi-.js +0 -2
  142. package/dist/client/_coffre/assets/projects._project.index-CWXRo307.js +0 -2
  143. package/dist/client/_coffre/assets/projects._project.index-Dzgf95zv.js +0 -1
  144. package/dist/client/_coffre/assets/projects.index-BG8W91BX.js +0 -2
  145. package/dist/client/_coffre/assets/projects.index-N_kCFBMq.js +0 -1
  146. package/dist/client/_coffre/assets/settings-CNIY0--5.js +0 -1
  147. package/dist/client/_coffre/assets/settings-EimGqlQL.js +0 -2
  148. package/dist/client/_coffre/assets/tokens._token-CkU4dCwo.js +0 -1
  149. package/dist/client/_coffre/assets/tokens._token-Df2R8TF_.js +0 -2
  150. package/dist/client/_coffre/assets/tokens.index-CSf5Mlz8.js +0 -2
  151. package/dist/client/_coffre/assets/tokens.index-DtiWrKVq.js +0 -1
  152. package/dist/client/_coffre/assets/unregistered-D5go1AfR.js +0 -1
  153. package/dist/client/_coffre/assets/use-action-CUvWPRTx.js +0 -1
  154. package/dist/client/_coffre/assets/users._user-CImGVpYj.js +0 -1
  155. package/dist/client/_coffre/assets/users._user-D0JK911L.js +0 -2
  156. package/dist/client/_coffre/assets/users.index-B-7o0KBD.js +0 -1
  157. package/dist/client/_coffre/assets/users.index-BoFWF3mF.js +0 -2
  158. package/dist/server/_coffre/assets/_tanstack-start-manifest_v-CrnrBINO.js +0 -133
  159. package/dist/server/_coffre/assets/audit-wjpo1BWg.js +0 -74
  160. package/dist/server/_coffre/assets/coffre-DMs96kfX.js +0 -280
  161. package/dist/server/_coffre/assets/globals-Bh2x1gBM.css +0 -1
  162. package/dist/server/_coffre/assets/grants-C6UmWE8b.js +0 -243
  163. package/dist/server/_coffre/assets/projects.index-ha7jO4nC.js +0 -54
  164. package/dist/server/_coffre/assets/settings-Cy__khNA.js +0 -18
  165. package/dist/server/_coffre/assets/tokens._token-CmpmtfB_.js +0 -18
  166. package/dist/server/_coffre/assets/tokens.index-B5-4dD4C.js +0 -10
  167. package/dist/server/_coffre/assets/users._user-BKdSQhIg.js +0 -10
  168. package/dist/server/_coffre/assets/users.index-dMn0tlmc.js +0 -10
@@ -1,7 +1,11 @@
1
- import { C as require_react, E as __toESM, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
- import { E as Link, d as Toggletip, i as EmptyState, l as Timestamp, p as breakAfterUnderscores, s as Notice } from "./ui-D_slKpSF.js";
3
- import { $ as X, H as ShieldCheck, S as Info, T as Ledger, W as SlashCircle, X as User, c as AlertTriangle, f as ChevronRight, i as PageHeader, m as Clock, n as ClosedDoor, o as Activity } from "./page-BdnhpwvH.js";
4
- import { t as Route } from "./audit-wjpo1BWg.js";
1
+ import { i as require_react, r as require_jsx_runtime, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
+ import { t as Link } from "./link-42ZWdjzZ.js";
3
+ import { C as useCoffre, h as queries, i as PageHeader, n as ClosedDoor } from "./page-D_mO0-sn.js";
4
+ import { t as useSuspenseQuery } from "./useSuspenseQuery-BuapQt_P.js";
5
+ import { t as useQuery } from "./useQuery-C6_dBjem.js";
6
+ import { c as Spinner, d as Toggletip, i as EmptyState, l as Timestamp, p as breakAfterUnderscores, s as Notice } from "./ui-BI3Bf72q.js";
7
+ import { G as User, J as X, L as ShieldCheck, _ as Info, b as Ledger, l as Clock, r as AlertTriangle, s as ChevronRight, t as Activity, z as SlashCircle } from "./icons-Dy-5ccDF.js";
8
+ import { t as Route } from "./audit-CSRQYIhu.js";
5
9
  //#region src/lib/audit-sentences.ts
6
10
  var import_react = /* @__PURE__ */ __toESM(require_react());
7
11
  var text = (value) => typeof value === "string" && value !== "" ? value : null;
@@ -475,8 +479,11 @@ function lines(entries) {
475
479
  //#region src/routes/audit.tsx?tsr-split=component
476
480
  var import_jsx_runtime = require_jsx_runtime();
477
481
  function AuditPage() {
478
- const { entries: result, chain } = Route.useLoaderData();
479
482
  const search = Route.useSearch();
483
+ const client = useCoffre();
484
+ const { data: result } = useSuspenseQuery(queries.auditEntries(client, search));
485
+ const verification = useQuery(queries.auditChain(client));
486
+ const chain = verification.data;
480
487
  const { decision, actorId } = search;
481
488
  const detail = search.detail === "1";
482
489
  const deniedOnly = decision === "deny";
@@ -486,7 +493,7 @@ function AuditPage() {
486
493
  title: "The audit log is closed to you",
487
494
  children: result.error
488
495
  });
489
- const broken = chain.integrity === "broken" ? chain : null;
496
+ const broken = chain?.integrity === "broken" ? chain : null;
490
497
  const breakAt = broken?.failedAtSeq ?? null;
491
498
  const shown = lines(result.entries);
492
499
  const filters = {
@@ -496,7 +503,15 @@ function AuditPage() {
496
503
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
497
504
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageHeader, {
498
505
  title: "Audit",
499
- actions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChainStatus, { chain })
506
+ actions: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
507
+ className: "chain-live",
508
+ "aria-live": "polite",
509
+ "aria-atomic": "true",
510
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChainStatus, {
511
+ chain,
512
+ onRetry: () => void verification.refetch()
513
+ })
514
+ })
500
515
  }),
501
516
  broken !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
502
517
  style: { marginBottom: "1.25rem" },
@@ -806,8 +821,16 @@ function BreakMark() {
806
821
  * have to ask for is reassurance rather than evidence: it is checked when
807
822
  * someone is already feeling confident, and not on the morning it would have
808
823
  * mattered. Recomputing on load makes the claim continuous.
824
+ *
825
+ * It is not waited for, though: verifying re-reads the whole log, so until
826
+ * it answers the badge says it is verifying, and a check that could not run
827
+ * says so and offers to run again, rather than passing for a broken log.
809
828
  */
810
- function ChainStatus({ chain }) {
829
+ function ChainStatus({ chain, onRetry }) {
830
+ if (chain === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
831
+ className: "chain-note",
832
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, { size: 14 }), "Verifying…"]
833
+ });
811
834
  if (chain.integrity === "owners-only") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Toggletip, {
812
835
  align: "end",
813
836
  label: "Owners and root admins see whether the log is intact. Checking it means recomputing every entry, and you read only your projects' part of it.",
@@ -817,18 +840,25 @@ function ChainStatus({ chain }) {
817
840
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Info, { size: 14 }), "Verified by owners"]
818
841
  })
819
842
  });
820
- if (chain.integrity === "unknown") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Toggletip, {
821
- align: "end",
822
- label: `coffre could not check the log: ${chain.problem}. The entries below loaded, but whether they are intact is unknown until it can. Reload to try again.`,
823
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
843
+ if (chain.integrity === "unknown") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
844
+ className: "chain",
845
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Toggletip, {
846
+ align: "end",
847
+ label: `coffre could not check the log: ${chain.problem}. The entries below loaded, but whether they are intact is unknown until it can.`,
848
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
849
+ type: "button",
850
+ className: "chain-flag chain-flag-warn",
851
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTriangle, { size: 14 }), "Couldn’t verify"]
852
+ })
853
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
824
854
  type: "button",
825
- className: "chain-flag chain-flag-warn",
826
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTriangle, { size: 14 }), "Log not verified"]
827
- })
855
+ className: "btn btn-sm",
856
+ onClick: onRetry,
857
+ children: "Retry"
858
+ })]
828
859
  });
829
860
  if (chain.integrity === "broken") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
830
861
  className: "chain-flag chain-flag-bad",
831
- role: "status",
832
862
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertTriangle, { size: 14 }), chain.failedAtSeq === null ? "Log does not verify" : `Log broken at ${chain.failedAtSeq}`]
833
863
  });
834
864
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
@@ -0,0 +1,31 @@
1
+ import { n as createFileRoute, t as lazyRouteComponent } from "./lazyRouteComponent-CqBNCGuZ.js";
2
+ import { h as queries } from "./page-D_mO0-sn.js";
3
+ //#region src/routes/audit.tsx
4
+ var $$splitComponentImporter = () => import("./audit-Bcka4vA6.js");
5
+ var Route = createFileRoute("/audit")({
6
+ validateSearch: (search) => ({
7
+ decision: search.decision === "deny" ? "deny" : void 0,
8
+ actorId: typeof search.actorId === "string" && search.actorId !== "" ? search.actorId : void 0,
9
+ detail: search.detail === "1" || search.detail === 1 ? "1" : void 0
10
+ }),
11
+ loaderDeps: ({ search }) => search,
12
+ loader: ({ context: { client, queryClient }, deps }) => queryClient.fetchQuery(queries.auditEntries(client, deps)),
13
+ component: lazyRouteComponent($$splitComponentImporter, "component")
14
+ });
15
+ /** One action: an entry, or a batch of them under one operation, which opens to each. */
16
+ /** A sentence, its people and places links to their pages. */
17
+ /** The entry the log breaks at, said in words as well as in red. */
18
+ /**
19
+ * Whether the log still verifies, beside the title.
20
+ *
21
+ * This replaced a card with a "Verify chain" button on it. A green result you
22
+ * have to ask for is reassurance rather than evidence: it is checked when
23
+ * someone is already feeling confident, and not on the morning it would have
24
+ * mattered. Recomputing on load makes the claim continuous.
25
+ *
26
+ * It is not waited for, though: verifying re-reads the whole log, so until
27
+ * it answers the badge says it is verifying, and a check that could not run
28
+ * says so and offers to run again, rather than passing for a broken log.
29
+ */
30
+ //#endregion
31
+ export { Route as t };
@@ -1,8 +1,10 @@
1
- import { C as require_react, E as __toESM, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
- import { D as useNavigate, E as Link, a as ErrorLine, c as Spinner, l as Timestamp } from "./ui-D_slKpSF.js";
3
- import { J as Terminal, W as SlashCircle, d as CheckCircle, n as ClosedDoor } from "./page-BdnhpwvH.js";
4
- import { i as statusOf, n as failureMessage, s as useCoffre } from "./coffre-DMs96kfX.js";
5
- import { t as Route } from "./auth.device-CMR3csAI.js";
1
+ import { i as require_react, r as require_jsx_runtime, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
+ import { t as Link } from "./link-42ZWdjzZ.js";
3
+ import { i as useNavigate } from "./lazyRouteComponent-CqBNCGuZ.js";
4
+ import { C as useCoffre, n as ClosedDoor, x as statusOf, y as failureMessage } from "./page-D_mO0-sn.js";
5
+ import { a as ErrorLine, c as Spinner, l as Timestamp } from "./ui-BI3Bf72q.js";
6
+ import { U as Terminal, o as CheckCircle, z as SlashCircle } from "./icons-Dy-5ccDF.js";
7
+ import { t as Route } from "./auth.device-DqO0T-rU.js";
6
8
  //#region src/routes/auth.device.tsx?tsr-split=component
7
9
  /**
8
10
  * Where `coffre login` sends you: approve a terminal's sign-in with the
@@ -1,7 +1,7 @@
1
- import { C as lazyRouteComponent, w as createFileRoute } from "./ui-D_slKpSF.js";
2
- import { o as uiResult } from "./coffre-DMs96kfX.js";
1
+ import { n as createFileRoute, t as lazyRouteComponent } from "./lazyRouteComponent-CqBNCGuZ.js";
2
+ import { S as uiResult, f as loadShell } from "./page-D_mO0-sn.js";
3
3
  //#region src/routes/auth.device.tsx
4
- var $$splitComponentImporter = () => import("./auth.device-w9N3FlNk.js");
4
+ var $$splitComponentImporter = () => import("./auth.device-CMcUISZY.js");
5
5
  /**
6
6
  * Where `coffre login` sends you: approve a terminal's sign-in with the
7
7
  * session this browser already has. The terminal shows a code; this page
@@ -14,9 +14,9 @@ var Route = createFileRoute("/auth/device")({
14
14
  return typeof code === "string" && code.length <= 16 ? { code } : {};
15
15
  },
16
16
  loaderDeps: ({ search }) => ({ code: search.code }),
17
- loader: async ({ context: { client }, deps, parentMatchPromise }) => {
17
+ loader: async ({ context: { client, queryClient }, deps }) => {
18
18
  if (deps.code === void 0) return null;
19
- if (!(await parentMatchPromise).loaderData?.auth.signin) return {
19
+ if (!(await loadShell(queryClient, client)).auth.signin) return {
20
20
  ok: false,
21
21
  error: "This instance has no CLI sign-in."
22
22
  };
@@ -1,8 +1,10 @@
1
- import { C as require_react, E as __toESM, o as require_jsx_runtime } from "./useStore-DWGPqzXR.js";
2
- import { E as Link, a as ErrorLine, c as Spinner, d as Toggletip, h as dropdown_menu_exports, i as EmptyState, n as ConfirmDialog, o as Modal } from "./ui-D_slKpSF.js";
3
- import { $ as X, C as Key, D as Lock, F as Pencil, H as ShieldCheck, L as Plus, M as MoreHorizontal, X as User } from "./page-BdnhpwvH.js";
4
- import { o as uiResult, r as memberRef, s as useCoffre, t as Refusal } from "./coffre-DMs96kfX.js";
5
- import { r as toast, t as useAction } from "./use-action-DQUmeH-5.js";
1
+ import { i as require_react, r as require_jsx_runtime, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
+ import { t as Link } from "./link-42ZWdjzZ.js";
3
+ import { C as useCoffre, b as memberRef } from "./page-D_mO0-sn.js";
4
+ import { g as removeMember, l as directoryList, m as invite, n as useChangeStatus, o as changeRole, t as useChange } from "./use-change-Dggqxy5y.js";
5
+ import { c as Spinner, d as Toggletip, h as dropdown_menu_exports, i as EmptyState, n as ConfirmDialog, o as Modal } from "./ui-BI3Bf72q.js";
6
+ import { A as Pencil, D as MoreHorizontal, G as User, J as X, L as ShieldCheck, M as Plus, S as Lock, v as Key } from "./icons-Dy-5ccDF.js";
7
+ import { a as rowClass, i as RowPending, r as RowFailure } from "./row-state-XBtDoIA4.js";
6
8
  //#region src/components/principal.tsx
7
9
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
8
10
  var import_jsx_runtime = require_jsx_runtime();
@@ -40,30 +42,8 @@ function PrincipalLink({ type, id, stretch = false }) {
40
42
  }
41
43
  //#endregion
42
44
  //#region src/components/directory.tsx
43
- /**
44
- * Everyone in the directory, and who was removed. The API shows grant
45
- * managers the members of their projects; the directory pages stay the
46
- * owners' own, and asking for anyone else would only log a refusal.
47
- */
48
- async function loadDirectory(client, canManage) {
49
- if (!canManage) return {
50
- ok: false,
51
- error: "Only owners can manage users and service accounts."
52
- };
53
- return uiResult(async () => {
54
- const { members, removed } = await client.members.list();
55
- return {
56
- principals: members.map(({ principalType, principalId, instanceRole, isRootAdmin, tampered }) => ({
57
- principalType,
58
- principalId,
59
- instanceRole,
60
- isRootAdmin,
61
- tampered
62
- })),
63
- removed
64
- };
65
- });
66
- }
45
+ /** How the directory, and its changes, name someone: `user:…`, `token:…`. */
46
+ var memberOf = (principal) => memberRef(principal.principalType, principal.principalId);
67
47
  var ROLE_LABEL = {
68
48
  "root-admin": "Root admin",
69
49
  owner: "Owner",
@@ -76,10 +56,13 @@ var KIND = {
76
56
  };
77
57
  function DirectoryTable({ principalType, principals, hasRemoved = false }) {
78
58
  const users = principalType === "user";
59
+ const columns = users ? 4 : 3;
60
+ const { status, failedAdds, dismiss } = useChangeStatus(directoryList.queryKey);
61
+ const refused = failedAdds(principals.map(memberOf)).filter(({ vars }) => vars.principalType === principalType);
79
62
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", {
80
63
  className: "card",
81
64
  "aria-label": users ? "Users" : "Tokens",
82
- children: principals.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyState, {
65
+ children: principals.length === 0 && refused.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(EmptyState, {
83
66
  title: hasRemoved ? `No active ${KIND[principalType]}s` : users ? "Nobody is registered" : "No tokens yet",
84
67
  children: [hasRemoved ? `Add a ${KIND[principalType]}` : `Add the first ${KIND[principalType]}`, " to let it through the door. Project access is a separate step, granted from each project's page."]
85
68
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
@@ -112,33 +95,45 @@ function DirectoryTable({ principalType, principals, hasRemoved = false }) {
112
95
  children: "Actions"
113
96
  })
114
97
  })
115
- ] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: principals.map((principal, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
116
- className: "row-link",
117
- children: [
118
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
119
- className: "n",
120
- children: index + 1
121
- }),
122
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
123
- className: "col-lead",
124
- "data-label": principal.principalType === "user" ? "Email" : "Name",
125
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalLink, {
126
- type: principal.principalType,
127
- id: principal.principalId,
128
- stretch: true
98
+ ] }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tbody", { children: [principals.map((principal, index) => {
99
+ const state = status(memberOf(principal));
100
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
101
+ className: `row-link ${rowClass(state)}`,
102
+ children: [
103
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
104
+ className: "n",
105
+ children: index + 1
106
+ }),
107
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
108
+ className: "col-lead",
109
+ "data-label": principal.principalType === "user" ? "Email" : "Name",
110
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalLink, {
111
+ type: principal.principalType,
112
+ id: principal.principalId,
113
+ stretch: true
114
+ })
115
+ }),
116
+ users && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
117
+ className: "col-role",
118
+ "data-label": "Instance role",
119
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InstanceRole, { principal })
120
+ }),
121
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
122
+ className: "col-actions",
123
+ children: state.state === "pending" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowPending, { status: state }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalActions, { principal })
129
124
  })
130
- }),
131
- users && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
132
- className: "col-role",
133
- "data-label": "Instance role",
134
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InstanceRole, { principal })
135
- }),
136
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
137
- className: "col-actions",
138
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PrincipalActions, { principal })
139
- })
140
- ]
141
- }, principal.principalId)) })]
125
+ ]
126
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RowFailure, {
127
+ status: state,
128
+ columns,
129
+ onDismiss: () => state.state === "failed" && dismiss(state.mutationId)
130
+ })] }, principal.principalId);
131
+ }), refused.map(({ mutationId, vars, status: failed }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(RowFailure, {
132
+ status: failed,
133
+ columns,
134
+ onDismiss: () => dismiss(mutationId),
135
+ children: [vars.principalId, " was not added."]
136
+ }, mutationId))] })]
142
137
  })
143
138
  })
144
139
  });
@@ -178,16 +173,16 @@ function InstanceRole({ principal }) {
178
173
  * Change role and Remove, behind one menu. Root admins get none: the
179
174
  * deployment's configuration owns them.
180
175
  */
181
- function PrincipalActions({ principal, trigger = "act act-quiet act-menu", onRemoved }) {
176
+ function PrincipalActions({ principal, trigger = "act act-quiet act-menu" }) {
182
177
  const [editing, setEditing] = (0, import_react.useState)(false);
183
178
  const [confirming, setConfirming] = (0, import_react.useState)(false);
184
179
  const [instanceRole, setInstanceRole] = (0, import_react.useState)(principal.instanceRole === "owner" ? "owner" : "user");
185
180
  const coffre = useCoffre();
186
- const { pending, error, setError, run } = useAction();
181
+ const setRole = useChange(changeRole(coffre));
182
+ const remove = useChange(removeMember(coffre));
183
+ const { status } = useChangeStatus(directoryList.queryKey);
184
+ const pending = status(memberOf(principal)).state === "pending";
187
185
  const kind = KIND[principal.principalType];
188
- (0, import_react.useEffect)(() => {
189
- if (error !== null && !editing) toast.error(error);
190
- }, [editing, error]);
191
186
  if (principal.isRootAdmin) return null;
192
187
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
193
188
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(dropdown_menu_exports.Root, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(dropdown_menu_exports.Trigger, {
@@ -222,10 +217,7 @@ function PrincipalActions({ principal, trigger = "act act-quiet act-menu", onRem
222
217
  }) })] }),
223
218
  principal.principalType === "user" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Modal, {
224
219
  open: editing,
225
- onOpenChange: (open) => {
226
- setEditing(open);
227
- if (!open) setError(null);
228
- },
220
+ onOpenChange: setEditing,
229
221
  title: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: ["Role of ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
230
222
  className: "mono",
231
223
  children: principal.principalId
@@ -234,32 +226,28 @@ function PrincipalActions({ principal, trigger = "act act-quiet act-menu", onRem
234
226
  className: "form",
235
227
  onSubmit: (event) => {
236
228
  event.preventDefault();
237
- run(() => coffre.members.add(memberRef("user", principal.principalId), { owner: instanceRole === "owner" }), () => {
238
- toast.success(`${principal.principalId} is now ${ROLE_LABEL[instanceRole].toLowerCase()}`);
239
- setEditing(false);
229
+ setRole({
230
+ principalId: principal.principalId,
231
+ owner: instanceRole === "owner"
240
232
  });
233
+ setEditing(false);
241
234
  },
242
- children: [
243
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RoleField, {
244
- value: instanceRole,
245
- onChange: setInstanceRole
246
- }),
247
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
248
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
249
- className: "dialog-actions",
250
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
251
- className: "btn",
252
- type: "button",
253
- onClick: () => setEditing(false),
254
- children: "Cancel"
255
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
256
- className: "btn btn-primary",
257
- type: "submit",
258
- disabled: pending,
259
- children: [pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}), "Save"]
260
- })]
261
- })
262
- ]
235
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RoleField, {
236
+ value: instanceRole,
237
+ onChange: setInstanceRole
238
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
239
+ className: "dialog-actions",
240
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
241
+ className: "btn",
242
+ type: "button",
243
+ onClick: () => setEditing(false),
244
+ children: "Cancel"
245
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
246
+ className: "btn btn-primary",
247
+ type: "submit",
248
+ children: "Save"
249
+ })]
250
+ })]
263
251
  })
264
252
  }),
265
253
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfirmDialog, {
@@ -275,10 +263,7 @@ function PrincipalActions({ principal, trigger = "act act-quiet act-menu", onRem
275
263
  ] }),
276
264
  body: principal.principalType === "user" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "They are signed out everywhere, and their CLI logins, linked sign-in accounts and project permissions are revoked at once. Their past actions stay in the audit log, and their page then lists the values they saw, to rotate." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "Every token issued to it stops working and its project permissions are revoked at once, including for anything running with it right now. Its past actions stay in the audit log, and its page then lists the values it read, to rotate." }),
277
265
  confirmLabel: `Remove ${kind}`,
278
- onConfirm: () => void run(() => coffre.members.remove(memberRef(principal.principalType, principal.principalId)), async () => {
279
- toast.success(`${principal.principalId} removed`);
280
- await onRemoved?.();
281
- })
266
+ onConfirm: () => remove(principal)
282
267
  })
283
268
  ] });
284
269
  }
@@ -286,14 +271,12 @@ function AddPrincipal({ principalType }) {
286
271
  const [open, setOpen] = (0, import_react.useState)(false);
287
272
  const [principalId, setPrincipalId] = (0, import_react.useState)("");
288
273
  const [instanceRole, setInstanceRole] = (0, import_react.useState)("user");
289
- const coffre = useCoffre();
290
- const { pending, error, setError, run } = useAction();
274
+ const add = useChange(invite(useCoffre()));
291
275
  const kind = KIND[principalType];
292
276
  function close() {
293
277
  setOpen(false);
294
278
  setPrincipalId("");
295
279
  setInstanceRole("user");
296
- setError(null);
297
280
  }
298
281
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
299
282
  className: "btn btn-primary",
@@ -312,15 +295,12 @@ function AddPrincipal({ principalType }) {
312
295
  className: "form",
313
296
  onSubmit: (event) => {
314
297
  event.preventDefault();
315
- run(async () => {
316
- const member = memberRef(principalType, principalId.trim());
317
- const { members } = await coffre.members.list();
318
- if (members.some((entry) => entry.member === member)) throw new Refusal("That principal already exists.");
319
- await coffre.members.add(member, { owner: principalType === "user" && instanceRole === "owner" });
320
- }, () => {
321
- toast.success(`${principalId.trim()} added`);
322
- close();
298
+ add({
299
+ principalType,
300
+ principalId: principalId.trim(),
301
+ owner: instanceRole === "owner"
323
302
  });
303
+ close();
324
304
  },
325
305
  children: [
326
306
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
@@ -342,7 +322,6 @@ function AddPrincipal({ principalType }) {
342
322
  value: instanceRole,
343
323
  onChange: setInstanceRole
344
324
  }),
345
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorLine, { error }),
346
325
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
347
326
  className: "dialog-actions",
348
327
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
@@ -353,12 +332,8 @@ function AddPrincipal({ principalType }) {
353
332
  }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
354
333
  className: "btn btn-primary",
355
334
  type: "submit",
356
- disabled: pending || principalId.trim() === "",
357
- children: [
358
- pending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {}),
359
- "Add ",
360
- kind
361
- ]
335
+ disabled: principalId.trim() === "",
336
+ children: ["Add ", kind]
362
337
  })]
363
338
  })
364
339
  ]
@@ -393,4 +368,4 @@ function RoleField({ value, onChange }) {
393
368
  });
394
369
  }
395
370
  //#endregion
396
- export { PrincipalActions as a, PrincipalLink as c, KIND as i, DirectoryTable as n, loadDirectory as o, InstanceRole as r, PrincipalAvatar as s, AddPrincipal as t };
371
+ export { PrincipalActions as a, KIND as i, DirectoryTable as n, PrincipalAvatar as o, InstanceRole as r, PrincipalLink as s, AddPrincipal as t };
@@ -1,6 +1,5 @@
1
- import { C as require_react, E as __toESM, i as useRouter } from "./useStore-DWGPqzXR.js";
2
- import { t as require_react_dom } from "./react-dom-qCTiwGGR.js";
3
- import { n as failureMessage } from "./coffre-DMs96kfX.js";
1
+ import { i as require_react, s as __toESM } from "./useRouter-CaUSUNsw.js";
2
+ import { t as require_react_dom } from "./react-dom-bBoJXlK2.js";
4
3
  //#region ../../node_modules/.pnpm/sonner@2.0.7_react-dom@19.2.7_react@19.2.7__react@19.2.7/node_modules/sonner/dist/index.mjs
5
4
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
6
5
  var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom(), 1);
@@ -906,48 +905,4 @@ var Toaster = /*#__PURE__*/ import_react.forwardRef(function Toaster(props, ref)
906
905
  }));
907
906
  });
908
907
  //#endregion
909
- //#region src/lib/use-action.ts
910
- /**
911
- * Run a change against the API, then refresh what is on screen. A failed
912
- * call leaves the page as it was and says why, in `error`.
913
- *
914
- * `router.invalidate()` is this app's replacement for Next's
915
- * `revalidatePath`. The difference worth knowing: `revalidatePath` named the
916
- * routes to refresh and got it wrong quietly when a mutation touched more than
917
- * the page it was called from -- renaming a project had to remember to
918
- * revalidate both `/` and `/:project`. Invalidating refetches every mounted
919
- * loader instead, so the sidebar's project tree stays honest without anyone
920
- * having to remember it exists.
921
- */
922
- function useAction() {
923
- const router = useRouter();
924
- const [pending, setPending] = (0, import_react.useState)(false);
925
- const [error, setError] = (0, import_react.useState)(null);
926
- async function run(fn, onSuccess) {
927
- setPending(true);
928
- let result;
929
- try {
930
- result = await fn();
931
- } catch (failure) {
932
- setError(failureMessage(failure));
933
- setPending(false);
934
- return;
935
- }
936
- setError(null);
937
- try {
938
- await router.invalidate();
939
- await onSuccess?.(result);
940
- } catch {
941
- setError("The change was saved, but the page could not refresh. Reload before you retry.");
942
- }
943
- setPending(false);
944
- }
945
- return {
946
- pending,
947
- error,
948
- setError,
949
- run
950
- };
951
- }
952
- //#endregion
953
- export { Toaster as n, toast as r, useAction as t };
908
+ export { toast as n, Toaster as t };