@coffre/ui 0.6.2 → 0.7.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 (86) hide show
  1. package/dist/chunks/{audit-sentence-BVv_9_nq.js → audit-sentence-C1_gRxWW.js} +90 -25
  2. package/dist/chunks/audit-sentence-C1_gRxWW.js.map +1 -0
  3. package/dist/chunks/{connected-apps-rBF9XUob.js → connected-apps-Bn5rEoV2.js} +2 -2
  4. package/dist/chunks/{connected-apps-rBF9XUob.js.map → connected-apps-Bn5rEoV2.js.map} +1 -1
  5. package/dist/chunks/{delete-place-CkGezx5R.js → delete-place-CQCDHkne.js} +3 -3
  6. package/dist/chunks/{delete-place-CkGezx5R.js.map → delete-place-CQCDHkne.js.map} +1 -1
  7. package/dist/chunks/{directory-SRN01yP6.js → directory-BQNOdze_.js} +6 -5
  8. package/dist/chunks/{directory-SRN01yP6.js.map → directory-BQNOdze_.js.map} +1 -1
  9. package/dist/chunks/{grants-1E1vqkM0.js → grants-CJIBrkod.js} +3 -3
  10. package/dist/chunks/{grants-1E1vqkM0.js.map → grants-CJIBrkod.js.map} +1 -1
  11. package/dist/chunks/{offboarding-Bt7KSixm.js → offboarding-CrgwaetA.js} +3 -3
  12. package/dist/chunks/offboarding-CrgwaetA.js.map +1 -0
  13. package/dist/chunks/personal-tokens-B8rkT-DI.js +138 -0
  14. package/dist/chunks/personal-tokens-B8rkT-DI.js.map +1 -0
  15. package/dist/chunks/{principal-page-Cbx2l6XL.js → principal-page-DDmmV1KQ.js} +25 -12
  16. package/dist/chunks/principal-page-DDmmV1KQ.js.map +1 -0
  17. package/dist/chunks/{project-page-DKo2AFYg.js → project-page-BI--vjt3.js} +2 -2
  18. package/dist/chunks/{project-page-DKo2AFYg.js.map → project-page-BI--vjt3.js.map} +1 -1
  19. package/dist/chunks/{queries-BvSw1xBN.js → queries-epz4MIuW.js} +19 -5
  20. package/dist/chunks/queries-epz4MIuW.js.map +1 -0
  21. package/dist/chunks/{references-DCoSPtvw.js → references-DImfw0cz.js} +3 -3
  22. package/dist/chunks/{references-DCoSPtvw.js.map → references-DImfw0cz.js.map} +1 -1
  23. package/dist/chunks/{role-field-D98CvNEg.js → role-field-C1KhNaIR.js} +2 -2
  24. package/dist/chunks/{role-field-D98CvNEg.js.map → role-field-C1KhNaIR.js.map} +1 -1
  25. package/dist/chunks/{use-action-Bv7yQ0DW.js → use-action-BB-RcHo1.js} +2 -2
  26. package/dist/chunks/{use-action-Bv7yQ0DW.js.map → use-action-BB-RcHo1.js.map} +1 -1
  27. package/dist/chunks/{use-change-DIQTGXER.js → use-change-CQyDpCqw.js} +268 -17
  28. package/dist/chunks/use-change-CQyDpCqw.js.map +1 -0
  29. package/dist/chunks/{use-shell-DhFoHjDS.js → use-shell-C_NmvCt_.js} +2 -2
  30. package/dist/chunks/{use-shell-DhFoHjDS.js.map → use-shell-C_NmvCt_.js.map} +1 -1
  31. package/dist/index.d.ts +33 -0
  32. package/dist/index.js +4 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/pages/account.d.ts +1 -1
  35. package/dist/pages/account.js +26 -9
  36. package/dist/pages/account.js.map +1 -1
  37. package/dist/pages/audit.js +52 -32
  38. package/dist/pages/audit.js.map +1 -1
  39. package/dist/pages/environment.js +520 -192
  40. package/dist/pages/environment.js.map +1 -1
  41. package/dist/pages/login.js +1 -1
  42. package/dist/pages/project-access.js +8 -8
  43. package/dist/pages/project-access.js.map +1 -1
  44. package/dist/pages/project-environments.js +106 -19
  45. package/dist/pages/project-environments.js.map +1 -1
  46. package/dist/pages/project-settings.js +6 -6
  47. package/dist/pages/project.js +1 -1
  48. package/dist/pages/projects.js +4 -4
  49. package/dist/pages/service-account.js +278 -29
  50. package/dist/pages/service-account.js.map +1 -1
  51. package/dist/pages/service-accounts.js +4 -4
  52. package/dist/pages/settings.js +4 -4
  53. package/dist/pages/unregistered.js +1 -1
  54. package/dist/pages/user.js +5 -5
  55. package/dist/pages/users.js +4 -4
  56. package/package.json +3 -3
  57. package/src/components/actions-log.tsx +2 -1
  58. package/src/components/directory.tsx +1 -0
  59. package/src/components/generate-value.tsx +15 -7
  60. package/src/components/offboarding.tsx +1 -1
  61. package/src/components/personal-tokens.tsx +131 -0
  62. package/src/components/principal-page.tsx +20 -3
  63. package/src/components/regenerate.tsx +72 -0
  64. package/src/components/service-tokens.tsx +3 -3
  65. package/src/components/trusted-workloads.tsx +177 -8
  66. package/src/lib/audit-sentences.ts +100 -12
  67. package/src/lib/bindings.ts +41 -3
  68. package/src/lib/changes.ts +155 -20
  69. package/src/lib/generate.ts +3 -146
  70. package/src/lib/queries.ts +15 -4
  71. package/src/lib/recipes.ts +63 -0
  72. package/src/lib/reveal.ts +7 -1
  73. package/src/lib/secret-edit-batch.ts +64 -5
  74. package/src/options.ts +5 -1
  75. package/src/pages/account.tsx +27 -5
  76. package/src/pages/audit.tsx +23 -7
  77. package/src/pages/environment.tsx +357 -39
  78. package/src/pages/project-access.tsx +1 -1
  79. package/src/pages/project-environments.tsx +85 -12
  80. package/src/parity.ts +18 -2
  81. package/src/styles/globals.css +56 -3
  82. package/dist/chunks/audit-sentence-BVv_9_nq.js.map +0 -1
  83. package/dist/chunks/offboarding-Bt7KSixm.js.map +0 -1
  84. package/dist/chunks/principal-page-Cbx2l6XL.js.map +0 -1
  85. package/dist/chunks/queries-BvSw1xBN.js.map +0 -1
  86. package/dist/chunks/use-change-DIQTGXER.js.map +0 -1
@@ -1,9 +1,10 @@
1
- import { i as keys, t as affects, y as refresh } from "./queries-BvSw1xBN.js";
1
+ import { i as keys, t as affects, y as refresh } from "./queries-epz4MIuW.js";
2
2
  import { a as Refusal, o as failureMessage, s as memberRef } from "./page-JTORvh-N.js";
3
3
  import { o as announce } from "./row-state-BsIHspy4.js";
4
4
  import { useCallback } from "react";
5
5
  import { EVERYWHERE, ROLES, unscoped } from "@coffre/core/access";
6
6
  import { useMutation, useMutationState, useQueryClient } from "@tanstack/react-query";
7
+ import { regenerateWrite } from "@coffre/core/recipe";
7
8
  //#region src/lib/project-access.ts
8
9
  function projectAccessOptions(environments) {
9
10
  const options = [{
@@ -60,7 +61,102 @@ function accessRows(access) {
60
61
  }]);
61
62
  }
62
63
  //#endregion
64
+ //#region src/lib/recipes.ts
65
+ /**
66
+ * A listed key's recipe, as far as the page may act on it: a key pair's
67
+ * only while the list holds both its halves, live, each saying the same of
68
+ * the pair. The server lists a pair by that rule; this holds the page to it
69
+ * between a change shown at once and the list read back, while a value
70
+ * typed over one half, or an archive, has not reached the other half yet.
71
+ */
72
+ function liveGeneration(entry, entries) {
73
+ const { generated } = entry;
74
+ if (generated === null || generated.pair === void 0) return generated;
75
+ const { pair, recipe } = generated;
76
+ const holds = (key) => entries.some((each) => each.key === key && !each.archived && each.generated?.recipe === recipe && each.generated.pair?.private === pair.private && each.generated.pair.public === pair.public);
77
+ return holds(pair.private) && holds(pair.public) ? generated : null;
78
+ }
79
+ /**
80
+ * The list after keys were renamed, `from` to `to`: each pair names its
81
+ * halves as they are now, in both halves, as the server lists them.
82
+ */
83
+ function renamePairs(entries, renames) {
84
+ if (renames.size === 0) return [...entries];
85
+ const now = (key) => renames.get(key) ?? key;
86
+ return entries.map((entry) => entry.generated?.pair === void 0 ? entry : {
87
+ ...entry,
88
+ generated: {
89
+ ...entry.generated,
90
+ pair: {
91
+ private: now(entry.generated.pair.private),
92
+ public: now(entry.generated.pair.public)
93
+ }
94
+ }
95
+ });
96
+ }
97
+ /** The keys regenerating a key writes: itself, or a key pair's two halves. */
98
+ function regeneratedKeys(key, generated) {
99
+ return generated.pair === void 0 ? [key] : [generated.pair.private, generated.pair.public];
100
+ }
101
+ /**
102
+ * Whether a key's Regenerate waits: while the key, or either half of its
103
+ * pair, is busy, being edited or with a save on its way. A regenerate
104
+ * addresses keys by name, so one sent beside a rename of a half could land
105
+ * on either side of it: before, and the rename fails with the old name
106
+ * holding the old private key beside a new public key; after, and it
107
+ * writes the old name again. Regenerate's own save marks every key it
108
+ * writes busy (`regenerateSecret`), so neither half is edited meanwhile.
109
+ */
110
+ function regenerateWaits(key, generated, busy) {
111
+ return [key, ...regeneratedKeys(key, generated)].some(busy);
112
+ }
113
+ //#endregion
63
114
  //#region src/lib/secret-edit-batch.ts
115
+ /**
116
+ * How a row's generated value was made, as its write says it: its recipe,
117
+ * and for a key pair the names both halves are saved under.
118
+ */
119
+ function generationOf(key, edit) {
120
+ if (edit.recipe === void 0) return void 0;
121
+ return edit.companion === void 0 ? { recipe: edit.recipe } : {
122
+ recipe: edit.recipe,
123
+ pair: {
124
+ private: key,
125
+ public: edit.companion.key.trim()
126
+ }
127
+ };
128
+ }
129
+ /** What a row writes under each key: its value, and its companion's beside it. */
130
+ function rowPatch(key, value, edit) {
131
+ const generated = generationOf(key, edit);
132
+ const entry = (each) => generated === void 0 ? each : {
133
+ value: each,
134
+ generated
135
+ };
136
+ const patch = Object.create(null);
137
+ patch[key] = entry(value);
138
+ if (edit.companion !== void 0) patch[edit.companion.key.trim()] = entry(edit.companion.value);
139
+ return patch;
140
+ }
141
+ /**
142
+ * The recipe each key a save writes will hold, by its name after the save:
143
+ * what the list shows of it until it is read back.
144
+ */
145
+ function generationsOf(active, drafts, changes) {
146
+ const out = /* @__PURE__ */ new Map();
147
+ const add = (key, edit) => {
148
+ const generated = generationOf(key, edit);
149
+ if (generated === void 0) return;
150
+ out.set(key, generated);
151
+ if (edit.companion !== void 0) out.set(edit.companion.key.trim(), generated);
152
+ };
153
+ for (const draft of drafts) add(draft.key.trim(), draft);
154
+ for (const entry of active) {
155
+ const change = secretChangeFor(changes, entry.key);
156
+ if (change !== void 0 && !change.archived && change.value !== null) add(change.key.trim(), change);
157
+ }
158
+ return out;
159
+ }
64
160
  function secretChangeFor(changes, key) {
65
161
  return Object.hasOwn(changes, key) ? changes[key] : void 0;
66
162
  }
@@ -126,9 +222,9 @@ async function applySecretEditBatch({ active, drafts, changes, operations }) {
126
222
  key
127
223
  };
128
224
  }
129
- if (change.value !== null) patch[key] = change.value;
225
+ if (change.value !== null) Object.assign(patch, rowPatch(key, change.value, change));
130
226
  }
131
- for (const draft of [...drafts, ...companionsOf(active, drafts, changes)]) patch[draft.key.trim()] = draft.value;
227
+ for (const draft of drafts) Object.assign(patch, rowPatch(draft.key.trim(), draft.value, draft));
132
228
  const written = Object.keys(patch).length;
133
229
  if (written > 0) await operations.write({ ...patch });
134
230
  return {
@@ -222,6 +318,11 @@ var MOVING = {
222
318
  done: "moved",
223
319
  failed: "Not moved."
224
320
  };
321
+ var REGENERATING = {
322
+ pending: "Regenerating…",
323
+ done: "regenerated",
324
+ failed: "Not regenerated."
325
+ };
225
326
  var saving = (id) => ({
226
327
  id,
227
328
  kind: "saving"
@@ -347,8 +448,8 @@ function removeMember(client) {
347
448
  run: (principal) => client.members.remove(principalId(principal))
348
449
  };
349
450
  }
350
- function revokeCredential(client, serviceId) {
351
- const member = memberRef("service", serviceId);
451
+ /** Revoking a member's token: a service account's bearer token, on its page, or a personal token of your own, on your account. */
452
+ function revokeCredential(client, member) {
352
453
  return {
353
454
  list: listOf([...keys.credentials(member), { allowed: true }], "tokens", (token) => token.id),
354
455
  label: (token) => `token ${token.hint}`,
@@ -398,6 +499,28 @@ function disconnectApp(client) {
398
499
  run: (app) => client.apps.disconnect(app.id)
399
500
  };
400
501
  }
502
+ /** Whoever runs the instance revoking someone's personal token, on their page: their report lists it, as they read it. */
503
+ function revokeMemberToken(client, member) {
504
+ return {
505
+ list: {
506
+ queryKey: [...keys.report(member), { owner: true }],
507
+ items: (data) => data?.ok === true ? data.report?.personalTokens ?? [] : [],
508
+ withItems: (data, personalTokens) => data?.ok === true && data.report !== null ? {
509
+ ...data,
510
+ report: {
511
+ ...data.report,
512
+ personalTokens
513
+ }
514
+ } : data,
515
+ id: (token) => token.id
516
+ },
517
+ label: (token) => `token ${token.hint}`,
518
+ targets: (token) => [removing(token.id)],
519
+ removing: REVOKING,
520
+ affects: () => [keys.report(member), keys.credentials(member)],
521
+ run: (token) => client.tokens.revoke(member, token.id)
522
+ };
523
+ }
401
524
  /** An owner disconnecting someone's app, on their page: their report lists it, as the owner reads it. */
402
525
  function disconnectMemberApp(client, member) {
403
526
  return {
@@ -489,6 +612,8 @@ function createEnvironment(client, project) {
489
612
  slug: vars.slug,
490
613
  name: vars.slug,
491
614
  accessible: false,
615
+ parent: vars.inherit === true ? vars.from ?? null : null,
616
+ personal: false,
492
617
  details: {
493
618
  archivedAt: null,
494
619
  secretCount: 0
@@ -498,7 +623,8 @@ function createEnvironment(client, project) {
498
623
  run: async (vars) => {
499
624
  const { created } = await client.environments.create(`${project}/${vars.slug}`, {
500
625
  ...vars.from === void 0 ? {} : { from: vars.from },
501
- ...vars.references === true ? { references: true } : {}
626
+ ...vars.references === true ? { references: true } : {},
627
+ ...vars.inherit === true ? { inherit: true } : {}
502
628
  });
503
629
  if (!created) throw new Refusal(`An environment named "${vars.slug}" already exists.`);
504
630
  }
@@ -579,24 +705,39 @@ function saveSecrets(client, place, author) {
579
705
  removing: ARCHIVING,
580
706
  apply: (entries, vars) => {
581
707
  const now = (/* @__PURE__ */ new Date()).toISOString();
582
- const bumped = (entry, key) => ({
583
- key,
584
- folder: entry?.folder ?? null,
585
- reference: null,
586
- archived: false,
587
- version: (entry?.version ?? 0) + 1,
588
- updatedAt: now,
589
- updatedBy: author
590
- });
708
+ const generations = generationsOf(vars.active, vars.drafts, vars.changes);
709
+ const bumped = (entry, key) => {
710
+ const inherited = entry?.parent != null && entry.parent.state !== "overridden" && entry.key === key;
711
+ return {
712
+ key,
713
+ folder: entry?.folder ?? null,
714
+ reference: null,
715
+ archived: false,
716
+ version: inherited ? null : (entry?.version ?? 0) + 1,
717
+ versionId: null,
718
+ updatedAt: now,
719
+ updatedBy: author,
720
+ generated: generations.get(key) ?? null,
721
+ parent: entry?.parent == null || entry.key !== key ? null : {
722
+ ...entry.parent,
723
+ state: "overridden",
724
+ changed: false,
725
+ reset: false
726
+ }
727
+ };
728
+ };
729
+ const renames = /* @__PURE__ */ new Map();
591
730
  let next = entries.map((entry) => {
592
731
  const change = vars.changes[entry.key];
593
732
  if (change === void 0 || change.archived) return entry;
594
733
  const key = change.key.trim();
734
+ if (key !== entry.key) renames.set(entry.key, key);
595
735
  return change.value === null ? {
596
736
  ...entry,
597
737
  key
598
738
  } : bumped(entry, key);
599
739
  });
740
+ next = renamePairs(next, renames);
600
741
  for (const draft of written(vars)) {
601
742
  const key = draft.key.trim();
602
743
  next = next.find((entry) => entry.key === key) === void 0 ? [bumped(void 0, key), ...next] : next.map((entry) => entry.key === key ? bumped(entry, key) : entry);
@@ -650,6 +791,47 @@ function moveSecret(client, place) {
650
791
  run: (vars) => client.secrets.update(`${place.project}/${place.environment}/${vars.key}`, { folder: vars.folder })
651
792
  };
652
793
  }
794
+ /**
795
+ * Regenerate a key by its recipe: the value made in this browser as the
796
+ * change runs, and sent at once, never on the page. Each key it writes, a
797
+ * key pair's two halves, shows it pending, so neither is edited, renamed
798
+ * or regenerated again until it lands. The server holds it to the versions
799
+ * listed, which settles a race with any other write.
800
+ */
801
+ function regenerateSecret(client, place, author) {
802
+ const path = `${place.project}/${place.environment}`;
803
+ return {
804
+ list: secretsList(place),
805
+ saving: REGENERATING,
806
+ label: (vars) => regeneratedKeys(vars.key, vars.generated).join(" and "),
807
+ targets: (vars) => regeneratedKeys(vars.key, vars.generated).map(saving),
808
+ apply: (entries, vars) => {
809
+ const keys = new Set(regeneratedKeys(vars.key, vars.generated));
810
+ const now = (/* @__PURE__ */ new Date()).toISOString();
811
+ return entries.map((entry) => {
812
+ if (!keys.has(entry.key)) return entry;
813
+ const inherited = entry.parent != null && entry.parent.state !== "overridden";
814
+ return {
815
+ ...entry,
816
+ reference: null,
817
+ version: inherited ? null : (entry.version ?? 0) + 1,
818
+ versionId: null,
819
+ updatedAt: now,
820
+ updatedBy: author,
821
+ generated: vars.generated,
822
+ parent: entry.parent == null ? null : {
823
+ ...entry.parent,
824
+ state: "overridden",
825
+ changed: false,
826
+ reset: false
827
+ }
828
+ };
829
+ });
830
+ },
831
+ affects: () => affects.secrets(place),
832
+ run: async (vars) => client.secrets.set(path, await regenerateWrite(vars.key, vars.generated, (key) => Object.hasOwn(vars.versions, key) ? vars.versions[key] : null))
833
+ };
834
+ }
653
835
  /** Restore an archived secret, from the Archived list. */
654
836
  function restoreSecret(client, place) {
655
837
  return {
@@ -679,6 +861,75 @@ function archiveSecret(client, place) {
679
861
  run: (vars) => client.secrets.update(`${place.project}/${place.environment}/${vars.key}`, { archived: true })
680
862
  };
681
863
  }
864
+ var FORK_WORDS = {
865
+ remove: {
866
+ pending: "Removing…",
867
+ done: "removed",
868
+ failed: "Not removed."
869
+ },
870
+ restore: {
871
+ pending: "Restoring…",
872
+ done: "restored",
873
+ failed: "Not restored."
874
+ },
875
+ reset: {
876
+ pending: "Resetting…",
877
+ done: "reset",
878
+ failed: "Not reset."
879
+ },
880
+ override: {
881
+ pending: "Overriding…",
882
+ done: "overridden",
883
+ failed: "Not overridden."
884
+ }
885
+ };
886
+ function forkKey(client, place, action) {
887
+ const path = `${place.project}/${place.environment}`;
888
+ const standing = (entry) => {
889
+ if (entry.parent === null) return entry;
890
+ switch (action) {
891
+ case "remove": return {
892
+ ...entry,
893
+ reference: null,
894
+ version: null,
895
+ updatedAt: null,
896
+ updatedBy: null,
897
+ parent: {
898
+ ...entry.parent,
899
+ state: "removed"
900
+ }
901
+ };
902
+ case "restore":
903
+ case "reset": return {
904
+ ...entry,
905
+ parent: {
906
+ ...entry.parent,
907
+ state: "inherited",
908
+ changed: false,
909
+ reset: action === "reset" || entry.parent.reset
910
+ }
911
+ };
912
+ case "override": return {
913
+ ...entry,
914
+ parent: {
915
+ ...entry.parent,
916
+ state: "overridden",
917
+ changed: false,
918
+ reset: false
919
+ }
920
+ };
921
+ }
922
+ };
923
+ return {
924
+ list: secretsList(place),
925
+ saving: FORK_WORDS[action],
926
+ label: (vars) => vars.key,
927
+ targets: (vars) => [saving(vars.key)],
928
+ apply: (entries, vars) => entries.flatMap((entry) => entry.key !== vars.key ? [entry] : action === "restore" && entry.parent?.held === false ? [] : [standing(entry)]),
929
+ affects: () => affects.secrets(place),
930
+ run: (vars) => action === "remove" || action === "restore" ? client.environments.dismiss(path, { [vars.key]: action === "remove" ? true : null }) : client.secrets.inherit(`${path}/${vars.key}`, action === "reset")
931
+ };
932
+ }
682
933
  function missingList(place) {
683
934
  return listOf(keys.missing(place), "missing", (entry) => entry.key);
684
935
  }
@@ -892,6 +1143,6 @@ function useChangeStatus(list) {
892
1143
  };
893
1144
  }
894
1145
  //#endregion
895
- export { saveSecrets as A, removeBinding as C, restoreSecret as D, restoreMissing as E, accessRows as F, parseProjectAccess as I, projectAccessLabel as L, companionsOf as M, hasSecretEditConflict as N, revokeCredential as O, secretChangeFor as P, projectAccessOptions as R, projectsList as S, renameEnvironment as T, grantAccess as _, UnsavedEdits as a, missingList as b, changeRole as c, directoryList as d, disconnectApp as f, environmentId as g, endSession as h, changeOptions as i, unlinkIdentity as j, revokeGrant as k, createEnvironment as l, dismissMissing as m, useChangeStatus as n, archiveEnvironment as o, disconnectMemberApp as p, changeKey as r, archiveSecret as s, useChange as t, createProject as u, grantId as v, removeMember as w, moveSecret as x, invite as y };
1146
+ export { revokeCredential as A, regeneratedKeys as B, projectsList as C, renameEnvironment as D, removeMember as E, companionsOf as F, parseProjectAccess as H, hasSecretEditConflict as I, secretChangeFor as L, revokeMemberToken as M, saveSecrets as N, restoreMissing as O, unlinkIdentity as P, liveGeneration as R, moveSecret as S, removeBinding as T, projectAccessLabel as U, accessRows as V, projectAccessOptions as W, forkKey as _, UnsavedEdits as a, invite as b, changeRole as c, directoryList as d, disconnectApp as f, environmentId as g, endSession as h, changeOptions as i, revokeGrant as j, restoreSecret as k, createEnvironment as l, dismissMissing as m, useChangeStatus as n, archiveEnvironment as o, disconnectMemberApp as p, changeKey as r, archiveSecret as s, useChange as t, createProject as u, grantAccess as v, regenerateSecret as w, missingList as x, grantId as y, regenerateWaits as z };
896
1147
 
897
- //# sourceMappingURL=use-change-DIQTGXER.js.map
1148
+ //# sourceMappingURL=use-change-CQyDpCqw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-change-CQyDpCqw.js","names":[],"sources":["../../src/lib/project-access.ts","../../src/lib/recipes.ts","../../src/lib/secret-edit-batch.ts","../../src/lib/changes.ts","../../src/lib/optimistic.ts","../../src/lib/use-change.ts"],"sourcesContent":["import { ROLES, type Role } from '@coffre/core/access';\n\nimport type { GrantRow, ProjectSummary, RoleRow } from '../shared/models';\n\n/** The roles the project's access picker offers, a product choice; others show by their names. */\nexport type ProjectAccessRole = Extract<Role, 'owner' | 'viewer' | 'developer'>;\n\nexport type ProjectAccessOption = {\n value: string;\n role: ProjectAccessRole;\n environmentSlug: string | null;\n label: string;\n};\n\nexport function projectAccessOptions(\n environments: ProjectSummary['environments'],\n): ProjectAccessOption[] {\n const options: ProjectAccessOption[] = [\n {\n value: 'owner:',\n role: 'owner',\n environmentSlug: null,\n label: ROLES.owner.name,\n },\n ];\n\n for (const role of ['viewer', 'developer'] as const) {\n options.push({\n value: `${role}:`,\n role,\n environmentSlug: null,\n label: `${ROLES[role].name}: all`,\n });\n }\n\n for (const environment of environments) {\n if (environment.details === null || environment.details.archivedAt !== null) continue;\n for (const role of ['viewer', 'developer'] as const) {\n options.push({\n value: `${role}:${environment.slug}`,\n role,\n environmentSlug: environment.slug,\n label: `${ROLES[role].name}: ${environment.slug}`,\n });\n }\n }\n\n return options;\n}\n\nexport function parseProjectAccess(value: string): {\n role: ProjectAccessRole;\n environmentSlug: string | null;\n} {\n const [role, environmentSlug = ''] = value.split(':', 2);\n if (role !== 'owner' && role !== 'viewer' && role !== 'developer') {\n throw new Error('unknown project access level');\n }\n return { role, environmentSlug: environmentSlug || null };\n}\n\n/** \"Owner\", \"Viewer: all\" or \"Developer: prod\": a grant by its role's name, and where. */\nexport function projectAccessLabel(\n grant: Pick<GrantRow, 'role' | 'roleName' | 'environmentSlug'>,\n): string {\n const name = Object.hasOwn(ROLES, grant.role) ? ROLES[grant.role as Role].name : grant.roleName;\n if (grant.role === 'owner') return name;\n return `${name}: ${grant.environmentSlug ?? 'all'}`;\n}\n\nexport function projectAccessRoles(\n roles: RoleRow[],\n environmentSlug: string | null,\n currentRole?: string,\n): RoleRow[] {\n const allowed = new Set(\n environmentSlug === null\n ? ['owner', 'viewer', 'developer']\n : ['viewer', 'developer'],\n );\n if (currentRole) allowed.add(currentRole);\n return roles.filter((role) => allowed.has(role.slug));\n}\n\n/** A project on someone's Access tab: their grants there, or why those could not be read. */\nexport type ProjectAccess = { project: ProjectSummary; grants: GrantRow[]; grantsError: string | null };\n\n/** A row of the Access tab: one of their grants, or a project whose grants could not be read. */\nexport type AccessRow =\n | { project: ProjectSummary; grant: GrantRow; error: null }\n | { project: ProjectSummary; grant: null; error: string };\n\n/**\n * The Access tab's rows, project by project: a row per grant, and a project\n * whose read failed keeps a row of its own that says why, so a failure\n * never reads as no access.\n */\nexport function accessRows(access: ProjectAccess[]): AccessRow[] {\n return access.flatMap(({ project, grants, grantsError }): AccessRow[] =>\n grantsError === null\n ? grants.map((grant) => ({ project, grant, error: null }))\n : [{ project, grant: null, error: grantsError }],\n );\n}\n","import type { SecretKey } from '@coffre/client';\nimport type { Generation } from '@coffre/core/recipe';\n\n/**\n * A listed key's recipe, as far as the page may act on it: a key pair's\n * only while the list holds both its halves, live, each saying the same of\n * the pair. The server lists a pair by that rule; this holds the page to it\n * between a change shown at once and the list read back, while a value\n * typed over one half, or an archive, has not reached the other half yet.\n */\nexport function liveGeneration(entry: SecretKey, entries: readonly SecretKey[]): Generation | null {\n const { generated } = entry;\n if (generated === null || generated.pair === undefined) return generated;\n const { pair, recipe } = generated;\n const holds = (key: string) =>\n entries.some(\n (each) =>\n each.key === key &&\n !each.archived &&\n each.generated?.recipe === recipe &&\n each.generated.pair?.private === pair.private &&\n each.generated.pair.public === pair.public,\n );\n return holds(pair.private) && holds(pair.public) ? generated : null;\n}\n\n/**\n * The list after keys were renamed, `from` to `to`: each pair names its\n * halves as they are now, in both halves, as the server lists them.\n */\nexport function renamePairs(entries: readonly SecretKey[], renames: ReadonlyMap<string, string>): SecretKey[] {\n if (renames.size === 0) return [...entries];\n const now = (key: string) => renames.get(key) ?? key;\n return entries.map((entry) =>\n entry.generated?.pair === undefined\n ? entry\n : {\n ...entry,\n generated: {\n ...entry.generated,\n pair: { private: now(entry.generated.pair.private), public: now(entry.generated.pair.public) },\n },\n },\n );\n}\n\n/** The keys regenerating a key writes: itself, or a key pair's two halves. */\nexport function regeneratedKeys(key: string, generated: Generation): string[] {\n return generated.pair === undefined ? [key] : [generated.pair.private, generated.pair.public];\n}\n\n/**\n * Whether a key's Regenerate waits: while the key, or either half of its\n * pair, is busy, being edited or with a save on its way. A regenerate\n * addresses keys by name, so one sent beside a rename of a half could land\n * on either side of it: before, and the rename fails with the old name\n * holding the old private key beside a new public key; after, and it\n * writes the old name again. Regenerate's own save marks every key it\n * writes busy (`regenerateSecret`), so neither half is edited meanwhile.\n */\nexport function regenerateWaits(key: string, generated: Generation, busy: (key: string) => boolean): boolean {\n return [key, ...regeneratedKeys(key, generated)].some(busy);\n}\n","import type { Generation } from '@coffre/core/recipe';\n\n/**\n * A second secret a row writes with its own value, in the same patch: a\n * generated key pair's public key, beside its private key. It is part of\n * the row's edit, so saving, undoing or retrying the row takes both.\n */\nexport type Companion = { key: string; value: string };\n\nexport type SecretDraft = {\n id: number;\n key: string;\n value: string;\n companion?: Companion;\n /** The recipe a generated value was made by, saved with it; typing over the value drops it. */\n recipe?: string;\n};\n\nexport type SecretChange = {\n key: string;\n value: string | null;\n archived: boolean;\n /** Only beside a new value. */\n companion?: Companion;\n /** Only beside a generated value. */\n recipe?: string;\n};\n\ntype ActiveSecret = { key: string };\n\n/**\n * A merge patch: a string sets a key, adding it if it is new; a value with\n * how it was generated sets it with its recipe; `null` archives it.\n */\nexport type SecretPatch = Record<string, string | { value: string; generated: Generation } | null>;\n\n/**\n * How a row's generated value was made, as its write says it: its recipe,\n * and for a key pair the names both halves are saved under.\n */\nfunction generationOf(key: string, edit: { recipe?: string; companion?: Companion }): Generation | undefined {\n if (edit.recipe === undefined) return undefined;\n return edit.companion === undefined\n ? { recipe: edit.recipe }\n : { recipe: edit.recipe, pair: { private: key, public: edit.companion.key.trim() } };\n}\n\n/** What a row writes under each key: its value, and its companion's beside it. */\nfunction rowPatch(key: string, value: string, edit: { recipe?: string; companion?: Companion }): SecretPatch {\n const generated = generationOf(key, edit);\n const entry = (each: string) => (generated === undefined ? each : { value: each, generated });\n const patch: SecretPatch = Object.create(null);\n patch[key] = entry(value);\n if (edit.companion !== undefined) patch[edit.companion.key.trim()] = entry(edit.companion.value);\n return patch;\n}\n\n/**\n * The recipe each key a save writes will hold, by its name after the save:\n * what the list shows of it until it is read back.\n */\nexport function generationsOf(\n active: readonly ActiveSecret[],\n drafts: readonly SecretDraft[],\n changes: Readonly<Record<string, SecretChange>>,\n): Map<string, Generation> {\n const out = new Map<string, Generation>();\n const add = (key: string, edit: { recipe?: string; companion?: Companion }) => {\n const generated = generationOf(key, edit);\n if (generated === undefined) return;\n out.set(key, generated);\n if (edit.companion !== undefined) out.set(edit.companion.key.trim(), generated);\n };\n for (const draft of drafts) add(draft.key.trim(), draft);\n for (const entry of active) {\n const change = secretChangeFor(changes, entry.key);\n if (change !== undefined && !change.archived && change.value !== null) add(change.key.trim(), change);\n }\n return out;\n}\n\ntype SecretEditOperations = {\n rename: (key: string, nextKey: string) => Promise<void>;\n /** One transaction: every key in it lands, or none does. */\n write: (patch: SecretPatch) => Promise<void>;\n};\n\ntype PlannedEdit = { sourceKey: string; change: SecretChange };\n\nexport function secretChangeFor(\n changes: Readonly<Record<string, SecretChange>>,\n key: string,\n): SecretChange | undefined {\n return Object.hasOwn(changes, key) ? changes[key] : undefined;\n}\n\nexport type SecretEditBatchResult = {\n applied: number;\n drafts: SecretDraft[];\n changes: Record<string, SecretChange>;\n error: unknown | null;\n};\n\n/**\n * The companions a save writes: those of new rows, and of value edits to keys\n * still listed. An edit whose key went from the list (renamed or archived\n * elsewhere, then refreshed) writes nothing, its companion included.\n */\nexport function companionsOf(\n active: readonly ActiveSecret[],\n drafts: readonly SecretDraft[],\n changes: Readonly<Record<string, SecretChange>>,\n): Companion[] {\n return [\n ...drafts.flatMap((draft) => (draft.companion === undefined ? [] : [draft.companion])),\n ...active.flatMap((entry) => {\n const change = secretChangeFor(changes, entry.key);\n return change === undefined || change.archived || change.value === null || change.companion === undefined\n ? []\n : [change.companion];\n }),\n ];\n}\n\n/** Return true when one save would give two pending edits the same target. */\nexport function hasSecretEditConflict(\n active: readonly ActiveSecret[],\n drafts: readonly SecretDraft[],\n changes: Readonly<Record<string, SecretChange>>,\n): boolean {\n const finalActiveKeys = active\n .filter((entry) => !secretChangeFor(changes, entry.key)?.archived)\n .map((entry) => secretChangeFor(changes, entry.key)?.key.trim() ?? entry.key);\n if (new Set(finalActiveKeys).size !== finalActiveKeys.length) return true;\n\n // A companion writes its key as a new row does.\n const draftKeys = [...drafts, ...companionsOf(active, drafts, changes)].map((draft) => draft.key.trim());\n if (new Set(draftKeys).size !== draftKeys.length) return true;\n\n const valueEditTargets = new Set(\n active.flatMap((entry) => {\n const change = secretChangeFor(changes, entry.key);\n return change !== undefined && !change.archived && change.value !== null\n ? [change.key.trim()]\n : [];\n }),\n );\n if (draftKeys.some((key) => valueEditTargets.has(key))) return true;\n\n const archivedKeys = new Set(\n active\n .filter((entry) => secretChangeFor(changes, entry.key)?.archived)\n .map((entry) => entry.key),\n );\n return draftKeys.some((key) => archivedKeys.has(key));\n}\n\n/**\n * Save every pending edit: renames first, one call each, then everything else\n * as one merge patch.\n *\n * The patch is a single transaction, so values, new keys and archives land\n * together or not at all. Renames cannot join it: a merge patch names keys and\n * has no way to move one with its history. A failed rename therefore stops the\n * save before the patch. The renames before it stay done, and every other edit\n * is kept for the retry, a value following its key to the new name.\n */\nexport async function applySecretEditBatch({\n active,\n drafts,\n changes,\n operations,\n}: {\n active: readonly ActiveSecret[];\n drafts: readonly SecretDraft[];\n changes: Readonly<Record<string, SecretChange>>;\n operations: SecretEditOperations;\n}): Promise<SecretEditBatchResult> {\n const remainingChanges = { ...changes };\n const plan = planEdits(active, drafts, changes);\n if (plan instanceof Error) {\n return { applied: 0, drafts: [...drafts], changes: remainingChanges, error: plan };\n }\n\n let applied = 0;\n // A key named `__proto__` is a key like any other.\n const patch: SecretPatch = Object.create(null);\n try {\n for (const { sourceKey, change } of plan) {\n if (change.archived) {\n patch[sourceKey] = null;\n continue;\n }\n const key = change.key.trim();\n if (key !== sourceKey) {\n await operations.rename(sourceKey, key);\n delete remainingChanges[sourceKey];\n applied += 1;\n if (change.value !== null) remainingChanges[key] = { ...change, key };\n }\n if (change.value !== null) Object.assign(patch, rowPatch(key, change.value, change));\n }\n for (const draft of drafts) Object.assign(patch, rowPatch(draft.key.trim(), draft.value, draft));\n\n const written = Object.keys(patch).length;\n if (written > 0) await operations.write({ ...patch });\n return { applied: applied + written, drafts: [], changes: {}, error: null };\n } catch (error) {\n return { applied, drafts: [...drafts], changes: remainingChanges, error };\n }\n}\n\n/**\n * Put dependent renames in an order that frees each destination first.\n * Cycles and archive-then-restore plans fail before the first mutation.\n */\nfunction planEdits(\n active: readonly ActiveSecret[],\n drafts: readonly SecretDraft[],\n changes: Readonly<Record<string, SecretChange>>,\n): PlannedEdit[] | Error {\n const activeKeys = new Set(active.map((entry) => entry.key));\n const archivedKeys = new Set(\n active\n .filter((entry) => secretChangeFor(changes, entry.key)?.archived)\n .map((entry) => entry.key),\n );\n const restoredByDraft = [...drafts, ...companionsOf(active, drafts, changes)].find((draft) =>\n archivedKeys.has(draft.key.trim()),\n );\n if (restoredByDraft) {\n return new Error(\n `${restoredByDraft.key.trim()}: cannot archive and write the same key in one save`,\n );\n }\n\n const renames = new Map<string, SecretChange>();\n const otherEdits: PlannedEdit[] = [];\n for (const entry of active) {\n const change = secretChangeFor(changes, entry.key);\n if (change === undefined) continue;\n if (!change.archived && change.key.trim() !== entry.key) {\n renames.set(entry.key, change);\n } else {\n otherEdits.push({ sourceKey: entry.key, change });\n }\n }\n\n for (const [sourceKey, change] of renames) {\n const destination = change.key.trim();\n if (activeKeys.has(destination) && !renames.has(destination)) {\n return new Error(`${sourceKey}: ${destination} is already in use`);\n }\n }\n\n const orderedRenames: PlannedEdit[] = [];\n const freedKeys = new Set<string>();\n while (renames.size > 0) {\n const ready = [...renames].find(([, change]) => {\n const destination = change.key.trim();\n return !activeKeys.has(destination) || freedKeys.has(destination);\n });\n if (!ready) {\n return new Error('Secret renames contain a cycle. Save them in separate steps.');\n }\n const [sourceKey, change] = ready;\n renames.delete(sourceKey);\n freedKeys.add(sourceKey);\n orderedRenames.push({ sourceKey, change });\n }\n\n return [...orderedRenames, ...otherEdits];\n}\n","import type { CoffreClient, ConnectedApp, IdentityRow, MissingKey, OffboardingReport, SecretKey, SessionRow, TokenRow } from '@coffre/client';\nimport { EVERYWHERE, unscoped, type InstanceRole, type Role, type Scope } from '@coffre/core/access';\nimport type { QueryKey } from '@tanstack/react-query';\n\nimport { failureMessage, memberRef, Refusal } from './coffre.ts';\nimport { projectAccessLabel } from './project-access.ts';\nimport type { Change, ListShape, Target, Words } from './optimistic.ts';\nimport { affects, keys } from './queries.ts';\nimport { regenerateWrite, type Generation } from '@coffre/core/recipe';\nimport { regeneratedKeys, renamePairs } from './recipes.ts';\nimport { applySecretEditBatch, companionsOf, generationsOf, type SecretChange, type SecretDraft, type SecretEditBatchResult } from './secret-edit-batch.ts';\nimport type { DirectoryPrincipal, GrantRow, ProjectSummary } from '../shared/models.ts';\n\n/**\n * Every change the pages make before the server answers, one per kind, each\n * with the list it shows in (`lib/optimistic.ts`). Issuing a token is not\n * here: only the server can show what it issued.\n */\n\ntype Failure = { ok: false; error: string };\n\n/** A list held in a read's `field`, when the read answered. */\nfunction listOf<TItem, TData extends { ok: boolean } | null>(\n queryKey: QueryKey,\n field: string,\n id: (item: TItem) => string,\n): ListShape<TData, TItem> {\n return {\n queryKey,\n items: (data) => (data?.ok === true ? ((data as unknown as Record<string, TItem[]>)[field] ?? []) : []),\n withItems: (data, items) => (data?.ok === true ? { ...data, [field]: items } : data),\n id,\n };\n}\n\nconst ARCHIVING: Words = { pending: 'Archiving…', done: 'archived', failed: 'Not archived.' };\nconst REVOKING: Words = { pending: 'Revoking…', done: 'revoked', failed: 'Not revoked.' };\nconst DISCONNECTING: Words = { pending: 'Disconnecting…', done: 'disconnected', failed: 'Not disconnected.' };\nconst MOVING: Words = { pending: 'Moving…', done: 'moved', failed: 'Not moved.' };\nconst REGENERATING: Words = { pending: 'Regenerating…', done: 'regenerated', failed: 'Not regenerated.' };\n\nconst saving = (id: string): Target => ({ id, kind: 'saving' });\nconst removing = (id: string): Target => ({ id, kind: 'removing' });\n\n// --- access --------------------------------------------------------------------\n\ntype Grants = ({ ok: true; grants: GrantRow[] } | Failure);\n\n/** A grant's identity, before the server has given it an id: who, and where; or who, by their instance role. */\nexport function grantId(grant: Pick<GrantRow, 'principalType' | 'principalId' | 'environmentSlug'> & { scope?: GrantRow['scope'] }): string {\n const member = memberRef(grant.principalType, grant.principalId);\n return grant.scope === 'instance-role' ? `${member}#role` : `${member}@${grant.environmentSlug ?? ''}`;\n}\n\nexport function grantsList(project: string) {\n return listOf<GrantRow, Grants>(keys.grants(project), 'grants', grantId);\n}\n\n/** Where a grant applies, as the API names it: `market`, or `market/prod`. */\nexport function grantPlace(project: string, environmentSlug: string | null): string {\n return environmentSlug === null ? project : `${project}/${environmentSlug}`;\n}\n\nexport type GrantVars = {\n principalType: GrantRow['principalType'];\n principalId: string;\n role: string;\n /** How the role is shown while it saves. */\n roleName: string;\n environmentSlug: string | null;\n expiresAt: string | null;\n /** A new service account, which the grant makes in the same call: refused, neither is made. */\n admit?: boolean;\n};\n\n/**\n * Give someone a role at one place. Access is declarative, so asking for what\n * they already hold is not an error, whoever asked first: `existed` says so.\n */\nexport function grantAccess(client: CoffreClient, project: string): Change<Grants, GrantRow, GrantVars, { existed: boolean }> {\n const list = grantsList(project);\n return {\n list,\n label: (vars) => `${vars.roleName} for ${vars.principalId}`,\n targets: (vars) => [saving(grantId(vars))],\n apply: (grants, vars) => {\n const row: GrantRow = {\n id: `pending:${grantId(vars)}`,\n principalType: vars.principalType,\n principalId: vars.principalId,\n role: vars.role,\n roleName: vars.roleName,\n permissions: [],\n scope: vars.environmentSlug === null ? 'project' : 'environment',\n environmentSlug: vars.environmentSlug,\n expiresAt: vars.expiresAt,\n };\n const id = grantId(vars);\n return grants.some((grant) => grantId(grant) === id)\n ? grants.map((grant) => (grantId(grant) === id ? { ...row, id: grant.id } : grant))\n : [...grants, row];\n },\n affects: (vars) => [\n ...affects.access(project, memberRef(vars.principalType, vars.principalId)),\n ...(vars.admit === true ? affects.admission(memberRef(vars.principalType, vars.principalId)) : []),\n ],\n run: async (vars) => {\n const place = grantPlace(project, vars.environmentSlug);\n const role = vars.role as Role;\n const member = memberRef(vars.principalType, vars.principalId);\n const access = { [place]: vars.expiresAt === null ? role : { role, until: vars.expiresAt } };\n const { changes } = vars.admit === true ? await client.members.add(member, { access }) : await client.access.set(member, access);\n return { existed: changes?.[place] === 'unchanged' };\n },\n };\n}\n\nexport function revokeGrant(client: CoffreClient, project: string): Change<Grants, GrantRow, GrantRow, unknown> {\n return {\n list: grantsList(project),\n label: (grant) => `${projectAccessLabel(grant)} for ${grant.principalId}`,\n targets: (grant) => [removing(grantId(grant))],\n removing: REVOKING,\n affects: (grant) => affects.access(project, memberRef(grant.principalType, grant.principalId)),\n run: (grant) =>\n client.access.set(memberRef(grant.principalType, grant.principalId), {\n [grantPlace(project, grant.environmentSlug)]: null,\n }),\n };\n}\n\n// --- the directory -------------------------------------------------------------\n\ntype Directory = ({ ok: true; principals: DirectoryPrincipal[] } | Failure);\n\nconst principalId = (principal: Pick<DirectoryPrincipal, 'principalType' | 'principalId'>) =>\n memberRef(principal.principalType, principal.principalId);\n\n/** The directory as admins and owners read it: the only ones who change it. */\nexport const directoryList = listOf<DirectoryPrincipal, Directory>([...keys.directory, { owner: true }], 'principals', principalId);\n\n/** A person's instance role and where it applies, projects by slug: what Add and Change role set. */\nexport type RoleVars = { role: InstanceRole; scope: Scope };\n\nexport type InviteVars = { principalType: DirectoryPrincipal['principalType']; principalId: string } & RoleVars;\n\n/** What the API takes for a role: the scope only when it narrows anything. */\nfunction roleInput({ role, scope }: RoleVars): RoleVars | { role: InstanceRole } {\n return role === 'member' || unscoped(scope) ? { role } : { role, scope };\n}\n\nexport function invite(client: CoffreClient): Change<Directory, DirectoryPrincipal, InviteVars, void> {\n return {\n list: directoryList,\n label: (vars) => vars.principalId,\n targets: (vars) => [saving(principalId(vars))],\n // Someone already listed is not added twice: the server will say they exist.\n apply: (principals, vars) =>\n principals.some((principal) => principalId(principal) === principalId(vars)) ? principals : [\n ...principals,\n {\n principalType: vars.principalType,\n principalId: vars.principalId,\n instanceRole: vars.principalType === 'user' ? vars.role : 'member',\n scope: vars.principalType === 'user' ? vars.scope : EVERYWHERE,\n },\n ],\n affects: (vars) => affects.admission(principalId(vars)),\n run: async (vars) => {\n // Adding is an idempotent PUT that would also set the role of someone\n // already here; this is only for someone new.\n const member = memberRef(vars.principalType, vars.principalId);\n const { members } = await client.members.list();\n if (members.some((entry) => entry.member === member)) throw new Refusal('That principal already exists.');\n await client.members.add(member, vars.principalType === 'user' ? roleInput(vars) : {});\n },\n };\n}\n\nexport function changeRole(client: CoffreClient): Change<Directory, DirectoryPrincipal, { principalId: string } & RoleVars, unknown> {\n const id = (vars: { principalId: string }) => memberRef('user', vars.principalId);\n return {\n list: directoryList,\n label: (vars) => `the role of ${vars.principalId}`,\n targets: (vars) => [saving(id(vars))],\n apply: (principals, vars) =>\n principals.map((principal) =>\n principalId(principal) === id(vars) ? { ...principal, instanceRole: vars.role, scope: vars.scope } : principal,\n ),\n affects: (vars) => affects.role(id(vars)),\n run: (vars) => client.members.add(id(vars), roleInput(vars)),\n };\n}\n\nexport function removeMember(client: CoffreClient): Change<Directory, DirectoryPrincipal, DirectoryPrincipal, unknown> {\n return {\n list: directoryList,\n label: (principal) => principal.principalId,\n targets: (principal) => [removing(principalId(principal))],\n affects: (principal) => affects.removal(principalId(principal)),\n run: (principal) => client.members.remove(principalId(principal)),\n };\n}\n\n// --- credentials, sessions, linked accounts --------------------------------------\n\ntype Credentials = ({ ok: true; tokens: TokenRow[] } | Failure) | null;\n\n/** Revoking a member's token: a service account's bearer token, on its page, or a personal token of your own, on your account. */\nexport function revokeCredential(client: CoffreClient, member: string): Change<Credentials, TokenRow, TokenRow, unknown> {\n return {\n list: listOf<TokenRow, Credentials>([...keys.credentials(member), { allowed: true }], 'tokens', (token) => token.id),\n label: (token) => `token ${token.hint}`,\n targets: (token) => [removing(token.id)],\n removing: REVOKING,\n affects: () => affects.credentials(member),\n run: (token) => client.tokens.revoke(member, token.id),\n };\n}\n\ntype Binding = { id: string; label: string | null };\ntype Bindings = ({ ok: true; bindings: Binding[] } | Failure) | null;\n\n/** Removing a trust binding: its tombstone, as far as the page goes, is the row leaving. */\nexport function removeBinding(client: CoffreClient, serviceId: string): Change<Bindings, Binding, Binding, unknown> {\n const member = memberRef('service', serviceId);\n return {\n list: listOf<Binding, Bindings>([...keys.bindings(member), { allowed: true }], 'bindings', (binding) => binding.id),\n label: (binding) => (binding.label === null ? 'the binding' : `binding ${binding.label}`),\n targets: (binding) => [removing(binding.id)],\n removing: { pending: 'Removing…', done: 'removed', failed: 'Not removed.' },\n affects: () => affects.bindings(member),\n run: (binding) => client.bindings.remove(member, binding.id),\n };\n}\n\ntype Sessions = ({ ok: true; sessions: SessionRow[] } | Failure);\n\nexport function endSession(client: CoffreClient): Change<Sessions, SessionRow, SessionRow, unknown> {\n return {\n list: listOf<SessionRow, Sessions>(keys.sessions, 'sessions', (session) => session.id),\n label: () => 'the session',\n targets: (session) => [removing(session.id)],\n removing: { pending: 'Ending…', done: 'ended', failed: 'Not ended.' },\n affects: () => affects.sessions(),\n run: (session) => client.sessions.revoke(session.id),\n };\n}\n\ntype Apps = ({ ok: true; apps: ConnectedApp[] } | Failure);\n\nexport function disconnectApp(client: CoffreClient): Change<Apps, ConnectedApp, ConnectedApp, unknown> {\n return {\n list: listOf<ConnectedApp, Apps>(keys.apps, 'apps', (app) => app.id),\n label: (app) => app.name,\n targets: (app) => [removing(app.id)],\n removing: DISCONNECTING,\n affects: () => affects.apps(),\n run: (app) => client.apps.disconnect(app.id),\n };\n}\n\ntype Report = { ok: true; report: OffboardingReport | null } | Failure | null;\n\n/** Whoever runs the instance revoking someone's personal token, on their page: their report lists it, as they read it. */\nexport function revokeMemberToken(client: CoffreClient, member: string): Change<Report, TokenRow, TokenRow, unknown> {\n return {\n list: {\n queryKey: [...keys.report(member), { owner: true }],\n items: (data) => (data?.ok === true ? (data.report?.personalTokens ?? []) : []),\n withItems: (data, personalTokens) => (data?.ok === true && data.report !== null ? { ...data, report: { ...data.report, personalTokens } } : data),\n id: (token) => token.id,\n },\n label: (token) => `token ${token.hint}`,\n targets: (token) => [removing(token.id)],\n removing: REVOKING,\n // Their report counts what removing them would end; the list on their account is theirs to read again.\n affects: () => [keys.report(member), keys.credentials(member)],\n run: (token) => client.tokens.revoke(member, token.id),\n };\n}\n\n/** An owner disconnecting someone's app, on their page: their report lists it, as the owner reads it. */\nexport function disconnectMemberApp(client: CoffreClient, member: string): Change<Report, ConnectedApp, ConnectedApp, unknown> {\n return {\n list: {\n queryKey: [...keys.report(member), { owner: true }],\n items: (data) => (data?.ok === true ? (data.report?.apps ?? []) : []),\n withItems: (data, apps) => (data?.ok === true && data.report !== null ? { ...data, report: { ...data.report, apps } } : data),\n id: (app) => app.id,\n },\n label: (app) => app.name,\n targets: (app) => [removing(app.id)],\n removing: DISCONNECTING,\n // Their report counts what removing them would end; an owner's own apps may be among them.\n affects: () => [keys.report(member), ...affects.apps()],\n run: (app) => client.apps.disconnect(app.id),\n };\n}\n\ntype Identities = ({ ok: true; identities: IdentityRow[] } | Failure);\n\nexport function unlinkIdentity(client: CoffreClient): Change<Identities, IdentityRow, IdentityRow & { label: string }, unknown> {\n return {\n list: listOf<IdentityRow, Identities>(keys.identities, 'identities', (identity) => identity.id),\n label: (identity) => `the ${identity.label} account`,\n targets: (identity) => [removing(identity.id)],\n removing: { pending: 'Unlinking…', done: 'unlinked', failed: 'Not unlinked.' },\n affects: () => affects.identities(),\n run: (identity) => client.identities.unlink(identity.id),\n };\n}\n\n// --- projects and environments ---------------------------------------------------\n\ntype Projects = ({ ok: true; projects: ProjectSummary[] } | Failure);\n\nexport const projectsList = listOf<ProjectSummary, Projects>(keys.projects, 'projects', (project) => project.slug);\n\nexport function createProject(client: CoffreClient): Change<Projects, ProjectSummary, { slug: string }, void> {\n return {\n list: projectsList,\n label: (vars) => `project ${vars.slug}`,\n targets: (vars) => [saving(vars.slug)],\n apply: (projects, vars) => [\n ...projects,\n {\n slug: vars.slug,\n name: vars.slug,\n archivedAt: null,\n folder: null,\n // Its maker manages it by their instance role, an Admin's or an Owner's.\n permissions: ['audit.read', 'environment.manage', 'grant.manage', 'project.manage'],\n environments: [],\n secretCount: null,\n },\n ],\n affects: () => affects.places(),\n run: async (vars) => {\n // Creating is an idempotent PUT; a slug that is taken is refused here.\n const { created } = await client.projects.create(vars.slug);\n if (!created) throw new Refusal(`A project named \"${vars.slug}\" already exists.`);\n },\n };\n}\n\ntype Environment = ProjectSummary['environments'][number];\n\n/** One project's environments, held in the project list. */\n/** File a project in a folder, or in none: shown at once, under its new heading. */\nexport function moveProject(client: CoffreClient): Change<Projects, ProjectSummary, { slug: string; folder: string | null }, unknown> {\n return {\n list: projectsList,\n label: (vars) => `project ${vars.slug}`,\n targets: (vars) => [saving(vars.slug)],\n apply: (projects, vars) => projects.map((project) => (project.slug === vars.slug ? { ...project, folder: vars.folder } : project)),\n affects: () => affects.places(),\n run: (vars) => client.projects.update(vars.slug, { folder: vars.folder }),\n };\n}\n\nexport function environmentsList(project: string): ListShape<Projects, Environment> {\n const environmentsOf = (data: Projects) =>\n data.ok ? (data.projects.find((entry) => entry.slug === project)?.environments ?? []) : [];\n return {\n queryKey: keys.projects,\n items: environmentsOf,\n withItems: (data, environments) =>\n data.ok\n ? { ...data, projects: data.projects.map((entry) => (entry.slug === project ? { ...entry, environments } : entry)) }\n : data,\n // Under the project's name: the projects list, in the same read, uses bare slugs.\n id: (environment) => environmentId(project, environment.slug),\n };\n}\n\nexport function environmentId(project: string, environment: string): string {\n return `${project}/${environment}`;\n}\n\n/** A new environment, empty or, `from` a sibling, forked: each of its keys copied. */\nexport function createEnvironment(client: CoffreClient, project: string): Change<Projects, Environment, { slug: string; from?: string; references?: boolean; inherit?: boolean }, void> {\n return {\n list: environmentsList(project),\n label: (vars) => `environment ${vars.slug}`,\n targets: (vars) => [saving(environmentId(project, vars.slug))],\n apply: (environments, vars) => [\n ...environments,\n { slug: vars.slug, name: vars.slug, accessible: false, parent: vars.inherit === true ? (vars.from ?? null) : null, personal: false, details: { archivedAt: null, secretCount: 0 } },\n ],\n affects: () => affects.places(),\n run: async (vars) => {\n const { created } = await client.environments.create(`${project}/${vars.slug}`, {\n ...(vars.from === undefined ? {} : { from: vars.from }),\n ...(vars.references === true ? { references: true } : {}),\n ...(vars.inherit === true ? { inherit: true } : {}),\n });\n if (!created) throw new Refusal(`An environment named \"${vars.slug}\" already exists.`);\n },\n };\n}\n\nexport type RenameVars = { from: string; slug: string };\n\nexport function renameEnvironment(client: CoffreClient, project: string): Change<Projects, Environment, RenameVars, unknown> {\n return {\n list: environmentsList(project),\n label: (vars) => `environment ${vars.from}`,\n targets: (vars) =>\n vars.slug === vars.from\n ? [saving(environmentId(project, vars.from))]\n : [saving(environmentId(project, vars.from)), saving(environmentId(project, vars.slug))],\n apply: (environments, vars) =>\n environments.map((environment) =>\n environment.slug === vars.from ? { ...environment, slug: vars.slug } : environment,\n ),\n affects: () => affects.places(),\n run: (vars) => client.environments.update(`${project}/${vars.from}`, { slug: vars.slug }),\n };\n}\n\n/**\n * Archive an environment or bring it back. Archiving ends every read of it,\n * so it waits for the server, as a removal does; restoring shows at once.\n */\nexport function archiveEnvironment(client: CoffreClient, project: string): Change<Projects, Environment, { slug: string; archived: boolean }, unknown> {\n const archivedAt = (archived: boolean) => (archived ? new Date().toISOString() : null);\n const withArchived = (environment: Environment, archived: boolean): Environment =>\n environment.details === null\n ? environment\n : { ...environment, details: { ...environment.details, archivedAt: archivedAt(archived) } };\n return {\n list: environmentsList(project),\n label: (vars) => `environment ${vars.slug}`,\n targets: (vars) => [\n vars.archived ? removing(environmentId(project, vars.slug)) : saving(environmentId(project, vars.slug)),\n ],\n removing: ARCHIVING,\n apply: (environments, vars) =>\n vars.archived\n ? environments\n : environments.map((environment) => (environment.slug === vars.slug ? withArchived(environment, false) : environment)),\n confirmed: (environments, _vars, archived) =>\n environments.map((environment) =>\n archived.has(environmentId(project, environment.slug)) ? withArchived(environment, true) : environment,\n ),\n affects: () => affects.places(),\n run: (vars) => client.environments.update(`${project}/${vars.slug}`, { archived: vars.archived }),\n };\n}\n\n// --- secrets ---------------------------------------------------------------------\n\ntype Secrets = ({ ok: true; keys: SecretKey[] } | Failure);\n\nexport function secretsList(place: { project: string; environment: string }) {\n return listOf<SecretKey, Secrets>(keys.secrets(place), 'keys', (entry) => entry.key);\n}\n\n/** A save that stopped partway: what is left to retry, as the ledger holds it. */\nexport class UnsavedEdits extends Refusal {\n readonly outcome: SecretEditBatchResult;\n\n constructor(outcome: SecretEditBatchResult) {\n const message = outcome.error instanceof Error ? outcome.error.message : failureMessage(outcome.error);\n // Only renames can have landed before a failure: the patch is all or nothing.\n super(\n outcome.applied === 0\n ? message\n : `${message} The renames before it were saved; nothing else was, and the rest is ready to retry.`,\n );\n this.outcome = outcome;\n }\n}\n\nexport type SaveSecretsVars = {\n active: SecretKey[];\n drafts: SecretDraft[];\n changes: Record<string, SecretChange>;\n};\n\n/**\n * Write the ledger's pending edits, as `applySecretEditBatch` does: renames\n * one by one, then the rest as one patch that lands whole or not at all.\n * New and edited secrets show at once; archived ones stay, struck through,\n * until the server confirms.\n */\nexport function saveSecrets(\n client: CoffreClient,\n place: { project: string; environment: string },\n /** Who is saving, shown as the author until the list is read back. */\n author: string | null,\n): Change<Secrets, SecretKey, SaveSecretsVars, number> {\n const path = `${place.project}/${place.environment}`;\n const edits = (vars: SaveSecretsVars) =>\n vars.active.flatMap((entry) => {\n const change = vars.changes[entry.key];\n return change === undefined ? [] : [{ entry, change }];\n });\n // A key pair's public key lands as a new row would, beside its private key.\n const written = (vars: SaveSecretsVars) => [...vars.drafts, ...companionsOf(vars.active, vars.drafts, vars.changes)];\n return {\n list: secretsList(place),\n label: (vars) => {\n const named = [...vars.drafts.map((draft) => draft.key.trim()), ...edits(vars).map(({ entry }) => entry.key)];\n return named.length === 1 ? named[0]! : `${named.length} changes`;\n },\n targets: (vars) => [\n ...written(vars).map((draft) => saving(draft.key.trim())),\n ...edits(vars).flatMap(({ entry, change }) =>\n change.archived\n ? [removing(entry.key)]\n : change.key.trim() === entry.key\n ? [saving(entry.key)]\n : [saving(entry.key), saving(change.key.trim())],\n ),\n ],\n removing: ARCHIVING,\n apply: (entries, vars) => {\n const now = new Date().toISOString();\n // A value typed by hand has no recipe; a generated one has the one it was made by.\n const generations = generationsOf(vars.active, vars.drafts, vars.changes);\n const bumped = (entry: SecretKey | undefined, key: string): SecretKey => {\n // In a fork, a value written over the parent's is an override, whose own version the list read back says.\n const inherited = entry?.parent != null && entry.parent.state !== 'overridden' && entry.key === key;\n return {\n key,\n // A rename keeps its folder; a new secret is in none.\n folder: entry?.folder ?? null,\n // A value of its own: no longer a reference.\n reference: null,\n archived: false,\n version: inherited ? null : (entry?.version ?? 0) + 1,\n // Known once the list is read back: until then, nothing regenerates it.\n versionId: null,\n updatedAt: now,\n updatedBy: author,\n generated: generations.get(key) ?? null,\n parent: entry?.parent == null || entry.key !== key ? null : { ...entry.parent, state: 'overridden', changed: false, reset: false },\n };\n };\n const renames = new Map<string, string>();\n let next = entries.map((entry) => {\n const change = vars.changes[entry.key];\n if (change === undefined || change.archived) return entry;\n const key = change.key.trim();\n if (key !== entry.key) renames.set(entry.key, key);\n return change.value === null ? { ...entry, key } : bumped(entry, key);\n });\n // A rename moves no value: a pair it touches names the new key, in both halves.\n next = renamePairs(next, renames);\n for (const draft of written(vars)) {\n const key = draft.key.trim();\n const existing = next.find((entry) => entry.key === key);\n next = existing === undefined ? [bumped(undefined, key), ...next] : next.map((entry) => (entry.key === key ? bumped(entry, key) : entry));\n }\n return next;\n },\n confirmed: (entries, _vars, archived) =>\n entries.map((entry) => (archived.has(entry.key) ? { ...entry, archived: true } : entry)),\n affects: () => affects.secrets(place),\n run: async (vars) => {\n const outcome = await applySecretEditBatch({\n active: vars.active,\n drafts: vars.drafts,\n changes: vars.changes,\n operations: {\n rename: async (key, nextKey) => {\n try {\n await client.secrets.rename(`${path}/${key}`, nextKey);\n } catch (error) {\n // A refused rename names the key it stopped at.\n throw new Refusal(`${key}: ${failureMessage(error)}`);\n }\n },\n write: async (patch) => {\n try {\n await client.secrets.set(path, patch);\n } catch (error) {\n throw new Refusal(failureMessage(error));\n }\n },\n },\n });\n if (outcome.error !== null) throw new UnsavedEdits(outcome);\n return outcome.applied;\n },\n };\n}\n\n/** File a secret in a folder, or in none: shown at once, under its new heading. */\nexport function moveSecret(\n client: CoffreClient,\n place: { project: string; environment: string },\n): Change<Secrets, SecretKey, { key: string; folder: string | null }, unknown> {\n return {\n list: secretsList(place),\n saving: MOVING,\n label: (vars) => vars.key,\n targets: (vars) => [saving(vars.key)],\n apply: (entries, vars) => entries.map((entry) => (entry.key === vars.key ? { ...entry, folder: vars.folder } : entry)),\n affects: () => affects.secrets(place),\n run: (vars) => client.secrets.update(`${place.project}/${place.environment}/${vars.key}`, { folder: vars.folder }),\n };\n}\n\n/** What Regenerate is asked: the key, its recipe, and the version id of each key it writes, as listed. */\nexport type RegenerateVars = { key: string; generated: Generation; versions: Readonly<Record<string, string>> };\n\n/**\n * Regenerate a key by its recipe: the value made in this browser as the\n * change runs, and sent at once, never on the page. Each key it writes, a\n * key pair's two halves, shows it pending, so neither is edited, renamed\n * or regenerated again until it lands. The server holds it to the versions\n * listed, which settles a race with any other write.\n */\nexport function regenerateSecret(\n client: CoffreClient,\n place: { project: string; environment: string },\n /** Who is regenerating, shown as the author until the list is read back. */\n author: string | null,\n): Change<Secrets, SecretKey, RegenerateVars, unknown> {\n const path = `${place.project}/${place.environment}`;\n return {\n list: secretsList(place),\n saving: REGENERATING,\n label: (vars) => regeneratedKeys(vars.key, vars.generated).join(' and '),\n targets: (vars) => regeneratedKeys(vars.key, vars.generated).map(saving),\n apply: (entries, vars) => {\n const keys = new Set(regeneratedKeys(vars.key, vars.generated));\n const now = new Date().toISOString();\n return entries.map((entry) => {\n if (!keys.has(entry.key)) return entry;\n // In a fork, regenerating a key it inherits writes an override here, never the parent:\n // its own version is the one the list read back says.\n const inherited = entry.parent != null && entry.parent.state !== 'overridden';\n return {\n ...entry,\n reference: null,\n version: inherited ? null : (entry.version ?? 0) + 1,\n versionId: null,\n updatedAt: now,\n updatedBy: author,\n generated: vars.generated,\n parent: entry.parent == null ? null : { ...entry.parent, state: 'overridden', changed: false, reset: false },\n };\n });\n },\n affects: () => affects.secrets(place),\n // Each key replaces the version the page listed, or the server refuses the write.\n run: async (vars) => client.secrets.set(path, await regenerateWrite(vars.key, vars.generated, (key) => (Object.hasOwn(vars.versions, key) ? vars.versions[key]! : null))),\n };\n}\n\n/** Restore an archived secret, from the Archived list. */\nexport function restoreSecret(\n client: CoffreClient,\n place: { project: string; environment: string },\n): Change<Secrets, SecretKey, { key: string }, unknown> {\n return {\n list: secretsList(place),\n label: (vars) => vars.key,\n targets: (vars) => [saving(vars.key)],\n apply: (entries, vars) => entries.map((entry) => (entry.key === vars.key ? { ...entry, archived: false } : entry)),\n affects: () => affects.secrets(place),\n run: (vars) => client.secrets.update(`${place.project}/${place.environment}/${vars.key}`, { archived: false }),\n };\n}\n\n/** Archive one secret, as Undo after a restore does: it stays, struck through, until confirmed. */\nexport function archiveSecret(\n client: CoffreClient,\n place: { project: string; environment: string },\n): Change<Secrets, SecretKey, { key: string }, unknown> {\n return {\n list: secretsList(place),\n label: (vars) => vars.key,\n targets: (vars) => [removing(vars.key)],\n removing: ARCHIVING,\n confirmed: (entries, _vars, archived) =>\n entries.map((entry) => (archived.has(entry.key) ? { ...entry, archived: true } : entry)),\n affects: () => affects.secrets(place),\n run: (vars) => client.secrets.update(`${place.project}/${place.environment}/${vars.key}`, { archived: true }),\n };\n}\n\n/**\n * In a fork, a key's standing to its parent's (docs/design/forking.md):\n * `remove` does without the parent's key and `restore` inherits it again,\n * a dismissal and its end; `reset` drops an override for the parent's\n * value, its own kept, and `override` serves its own again. Each shows at\n * once, and is undone by its opposite.\n */\nexport type ForkAction = 'remove' | 'restore' | 'reset' | 'override';\n\nconst FORK_WORDS: Record<ForkAction, Words> = {\n remove: { pending: 'Removing…', done: 'removed', failed: 'Not removed.' },\n restore: { pending: 'Restoring…', done: 'restored', failed: 'Not restored.' },\n reset: { pending: 'Resetting…', done: 'reset', failed: 'Not reset.' },\n override: { pending: 'Overriding…', done: 'overridden', failed: 'Not overridden.' },\n};\n\nexport function forkKey(\n client: CoffreClient,\n place: { project: string; environment: string },\n action: ForkAction,\n): Change<Secrets, SecretKey, { key: string }, unknown> {\n const path = `${place.project}/${place.environment}`;\n const standing = (entry: SecretKey): SecretKey => {\n if (entry.parent === null) return entry;\n switch (action) {\n // Not served: nothing of the parent's value is shown for it.\n case 'remove':\n return { ...entry, reference: null, version: null, updatedAt: null, updatedBy: null, parent: { ...entry.parent, state: 'removed' } };\n // The parent's value, which the list read back brings.\n case 'restore':\n case 'reset':\n return { ...entry, parent: { ...entry.parent, state: 'inherited', changed: false, reset: action === 'reset' || entry.parent.reset } };\n case 'override':\n return { ...entry, parent: { ...entry.parent, state: 'overridden', changed: false, reset: false } };\n }\n };\n return {\n list: secretsList(place),\n saving: FORK_WORDS[action],\n label: (vars) => vars.key,\n targets: (vars) => [saving(vars.key)],\n // A removal of a key the parent archived since, restored, leaves nothing to list.\n apply: (entries, vars) => entries.flatMap((entry) =>\n entry.key !== vars.key ? [entry] : action === 'restore' && entry.parent?.held === false ? [] : [standing(entry)]),\n affects: () => affects.secrets(place),\n run: (vars) =>\n action === 'remove' || action === 'restore'\n ? client.environments.dismiss(path, { [vars.key]: action === 'remove' ? true : null })\n : client.secrets.inherit(`${path}/${vars.key}`, action === 'reset'),\n };\n}\n\n// --- missing keys ----------------------------------------------------------------\n\ntype Missing = ({ ok: true; missing: MissingKey[] } | Failure);\n\nexport function missingList(place: { project: string; environment: string }) {\n return listOf<MissingKey, Missing>(keys.missing(place), 'missing', (entry) => entry.key);\n}\n\nconst DISMISSING: Words = { pending: 'Dismissing…', done: 'dismissed', failed: 'Not dismissed.' };\nconst RESTORING: Words = { pending: 'Restoring…', done: 'restored', failed: 'Not restored.' };\n\n/**\n * Dismiss missing keys for the whole team. It shows at once: a dismissal\n * hides nothing anyone may read, so it need not wait for the server, and a\n * refusal puts the keys back.\n */\nexport function dismissMissing(client: CoffreClient, place: { project: string; environment: string }) {\n return missingChange(client, place, true);\n}\n\n/** Bring dismissed keys back, as Undo after a dismissal does: listed again at once. */\nexport function restoreMissing(client: CoffreClient, place: { project: string; environment: string }) {\n return missingChange(client, place, false);\n}\n\nfunction missingChange(\n client: CoffreClient,\n place: { project: string; environment: string },\n dismissed: boolean,\n): Change<Missing, MissingKey, MissingKey[], unknown> {\n return {\n list: missingList(place),\n saving: dismissed ? DISMISSING : RESTORING,\n label: (entries) => (entries.length === 1 ? entries[0]!.key : `${entries.length} missing keys`),\n targets: (entries) => entries.map((entry) => saving(entry.key)),\n apply: (entries, named) => {\n const names = new Set(named.map((entry) => entry.key));\n const others = entries.filter((entry) => !names.has(entry.key));\n // Listed by name, as the server lists them.\n return dismissed ? others : [...others, ...named].sort((a, b) => (a.key < b.key ? -1 : 1));\n },\n affects: () => [],\n run: (entries) =>\n client.environments.dismiss(\n `${place.project}/${place.environment}`,\n Object.fromEntries(entries.map((entry) => [entry.key, dismissed ? true : null])),\n ),\n };\n}\n","import type { Mutation, MutationOptions, QueryClient, QueryKey } from '@tanstack/react-query';\n\nimport { announce } from './announce.ts';\nimport { failureMessage } from './coffre.ts';\nimport { refresh } from './queries.ts';\n\n/**\n * Changes that show before the server answers.\n *\n * An add or an edit shows at once, as it will be, marked as saving; a removal\n * keeps its row, struck through, until the server confirms it, since access\n * must never look gone while it still holds. Either way, if the server\n * refuses, the list goes back to what it was and the row says why\n * (`failureMessage`: the API's own sentence where it gives one), until\n * dismissed or retried.\n *\n * Several changes can be in flight at once, so a failure undoes its own\n * items only, not the whole list as it was when it started; and the list is\n * read back from the server once the last change to it has landed, so one\n * landing does not erase another still on its way.\n */\n\n/** What a row is waiting for. */\nexport type Pending = 'saving' | 'removing';\n\n/** One item a change touches, and how. */\nexport type Target = { id: string; kind: Pending };\n\n/** How a change is worded on its row: \"Archiving…\", \"Not archived.\" */\nexport type Words = { pending: string; done: string; failed: string };\n\nconst WORDS: Record<Pending, Words> = {\n saving: { pending: 'Saving…', done: 'saved', failed: 'Not saved.' },\n removing: { pending: 'Removing…', done: 'removed', failed: 'Not removed.' },\n};\n\n/** How one cached query holds a list of items, each with an identity. */\nexport type ListShape<TData, TItem> = {\n queryKey: QueryKey;\n items: (data: TData) => TItem[];\n withItems: (data: TData, items: TItem[]) => TData;\n id: (item: TItem) => string;\n};\n\nexport type Change<TData, TItem, TVars, TResult> = {\n list: ListShape<TData, TItem>;\n /** What the change is called, for the screen reader: \"access for dev@acme.example\". */\n label: (vars: TVars) => string;\n /**\n * The items it touches, whose rows show it: saved ones as they will be,\n * removed ones as they are until confirmed. A rename touches both names.\n */\n targets: (vars: TVars) => Target[];\n /** How saves are worded, when not as saves: dismissing. */\n saving?: Words;\n /** How removals are worded, when not as removals: archiving, revoking. */\n removing?: Words;\n /** The items as they will be once the saves land; removals are left for the server. */\n apply?: (items: TItem[], vars: TVars) => TItem[];\n /** The items once the server confirms; by default, without those removed. Archiving keeps them, archived. */\n confirmed?: (items: TItem[], vars: TVars, removed: ReadonlySet<string>) => TItem[];\n /** Anything else it touches, refetched once it lands (`affects` in `queries.ts`). */\n affects: (vars: TVars, result: TResult | undefined) => QueryKey[];\n run: (vars: TVars) => Promise<TResult>;\n};\n\n/** What `onMutate` keeps: the list as it was, and what the rows should show. */\nexport type ChangeContext = { previous: unknown; targets: Target[]; words: Record<Pending, Words> };\n\n/** Every optimistic change is keyed under this, then its list's key. */\nexport const CHANGE = 'change';\n\nexport function changeKey(list: QueryKey): QueryKey {\n return [CHANGE, ...list];\n}\n\nexport function changeOptions<TData, TItem, TVars, TResult>(\n queryClient: QueryClient,\n change: Change<TData, TItem, TVars, TResult>,\n): MutationOptions<TResult, unknown, TVars, ChangeContext> {\n const { list } = change;\n const mutationKey = changeKey(list.queryKey);\n return {\n mutationKey,\n mutationFn: change.run,\n onMutate: async (vars) => {\n const targets = change.targets(vars);\n const words = { saving: change.saving ?? WORDS.saving, removing: change.removing ?? WORDS.removing };\n announce(`${change.label(vars)}: ${words[mainKind(targets)].pending}`);\n // A read already on its way would land over the change.\n await queryClient.cancelQueries({ queryKey: list.queryKey });\n const previous = queryClient.getQueryData<TData>(list.queryKey);\n if (change.apply !== undefined && previous !== undefined) {\n const apply = change.apply;\n queryClient.setQueryData<TData>(list.queryKey, (current) =>\n current === undefined ? current : list.withItems(current, apply(list.items(current), vars)),\n );\n }\n return { previous, targets, words };\n },\n onError: (error, vars, context) => {\n if (context === undefined) return;\n announce(\n `${change.label(vars)}: ${context.words[mainKind(context.targets)].failed} ${failureMessage(error)}`,\n { urgent: true },\n );\n if (context.previous === undefined || change.apply === undefined) return;\n const previous = context.previous as TData;\n const saved = context.targets.filter((target) => target.kind === 'saving').map((target) => target.id);\n queryClient.setQueryData<TData>(list.queryKey, (current) =>\n current === undefined ? current : revert(list, current, previous, saved),\n );\n },\n onSuccess: (_result, vars, context) => {\n if (context === undefined) return;\n announce(`${capitalize(change.label(vars))} ${context.words[mainKind(context.targets)].done}`);\n // Confirmed: the rows removed can go now, before the list is read back.\n const gone = new Set(\n context.targets.filter((target) => target.kind === 'removing').map((target) => target.id),\n );\n if (gone.size > 0) {\n const confirmed =\n change.confirmed ?? ((items: TItem[]) => items.filter((item) => !gone.has(list.id(item))));\n queryClient.setQueryData<TData>(list.queryKey, (current) =>\n current === undefined ? current : list.withItems(current, confirmed(list.items(current), vars, gone)),\n );\n }\n },\n onSettled: (result, _error, vars) => {\n // This one still counts as in flight here.\n if (queryClient.isMutating({ mutationKey }) > 1) return;\n // Not awaited: the row settles when the server answers, and the list\n // is read back behind it.\n void refresh(queryClient, [list.queryKey, ...change.affects(vars, result)]);\n },\n };\n}\n\n/**\n * The list with one change undone: each target as it was before, wherever\n * it now is, and gone if it was not there. Everything else stays as it is,\n * including other changes still in flight.\n */\nexport function revert<TData, TItem>(\n list: ListShape<TData, TItem>,\n current: TData,\n previous: TData,\n targets: string[],\n): TData {\n const before = list.items(previous);\n let items = list.items(current).filter((item) => !targets.includes(list.id(item)));\n for (const id of targets) {\n const index = before.findIndex((item) => list.id(item) === id);\n if (index === -1) continue;\n // Back where it was, counting only what is still there before it.\n const after = before\n .slice(0, index)\n .filter((item) => items.some((kept) => list.id(kept) === list.id(item))).length;\n items = [...items.slice(0, after), before[index]!, ...items.slice(after)];\n }\n return list.withItems(current, items);\n}\n\n/** What a change mostly does, to word it as a whole: a save, unless it only removes. */\nfunction mainKind(targets: Target[]): Pending {\n return targets.length > 0 && targets.every((target) => target.kind === 'removing') ? 'removing' : 'saving';\n}\n\n/** What a row shows: nothing, a change on its way, or one the server refused. */\nexport type ItemStatus =\n | { state: 'idle' }\n | { state: 'pending'; kind: Pending; words: Words }\n | { state: 'failed'; kind: Pending; words: Words; error: string; mutationId: number };\n\ntype Tracked = Pick<Mutation<unknown, unknown, unknown, ChangeContext>, 'mutationId' | 'state'>;\n\n/**\n * An item's status, from the changes to its list: the latest one that\n * touches it decides, so retrying clears an old failure.\n */\nexport function itemStatus(changes: readonly Tracked[], id: string): ItemStatus {\n let latest: Tracked | undefined;\n for (const change of changes) {\n if (change.state.context?.targets.some((target) => target.id === id) !== true) continue;\n if (latest === undefined || change.state.submittedAt >= latest.state.submittedAt) latest = change;\n }\n const context = latest?.state.context;\n if (latest === undefined || context === undefined) return { state: 'idle' };\n const kind = context.targets.find((target) => target.id === id)!.kind;\n const words = context.words[kind];\n if (latest.state.status === 'pending') return { state: 'pending', kind, words };\n if (latest.state.status === 'error') {\n const error = failureMessage(latest.state.error);\n return { state: 'failed', kind, words, error, mutationId: latest.mutationId };\n }\n return { state: 'idle' };\n}\n\n/** A refused add: no row is left to say so, so it gets one of its own. */\nexport type FailedAdd<TVars> = {\n mutationId: number;\n vars: TVars;\n /** The ids it would have added. */\n ids: string[];\n status: Extract<ItemStatus, { state: 'failed' }>;\n};\n\n/**\n * The adds the server refused whose items are not listed: each is shown as\n * a row of its own. Asked again and refused again, an add is listed once,\n * as the latest refusal.\n */\nexport function failedAdds<TVars>(changes: readonly Tracked[], present: readonly string[]): FailedAdd<TVars>[] {\n return changes.flatMap((change) => {\n const context = change.state.context;\n if (change.state.status !== 'error' || context === undefined) return [];\n const added = context.targets.filter((target) => target.kind === 'saving' && !present.includes(target.id));\n if (added.length === 0 || added.length < context.targets.length) return [];\n const status = itemStatus(changes, added[0]!.id);\n if (status.state !== 'failed' || status.mutationId !== change.mutationId) return [];\n const ids = added.map((target) => target.id);\n return [{ mutationId: change.mutationId, vars: change.state.variables as TVars, ids, status }];\n });\n}\n\n/** Forget a failure once its row has said so and been dismissed. */\nexport function dismiss(queryClient: QueryClient, mutationId: number): void {\n const cache = queryClient.getMutationCache();\n const mutation = cache.getAll().find((entry) => entry.mutationId === mutationId);\n if (mutation !== undefined) cache.remove(mutation);\n}\n\nfunction capitalize(text: string): string {\n return text.charAt(0).toUpperCase() + text.slice(1);\n}\n","import { useMutation, useMutationState, useQueryClient, type QueryKey } from '@tanstack/react-query';\nimport { useCallback } from 'react';\n\nimport {\n changeKey,\n changeOptions,\n dismiss,\n failedAdds,\n itemStatus,\n type Change,\n type ChangeContext,\n} from './optimistic';\n\n/** Make a change that shows before the server answers (`lib/optimistic.ts`). */\nexport function useChange<TData, TItem, TVars, TResult>(change: Change<TData, TItem, TVars, TResult>) {\n const queryClient = useQueryClient();\n return useMutation(changeOptions(queryClient, change)).mutate;\n}\n\n/** How each item of a list stands, from the changes made to it here. */\nexport function useChangeStatus(list: QueryKey) {\n const queryClient = useQueryClient();\n const changes = useMutationState({\n filters: { mutationKey: changeKey(list) },\n select: (mutation) => ({\n mutationId: mutation.mutationId,\n state: mutation.state as typeof mutation.state & { context: ChangeContext | undefined },\n }),\n });\n\n const status = useCallback((id: string) => itemStatus(changes, id), [changes]);\n\n /** Adds the server refused, whose items are not in `present`: rendered as rows of their own. */\n const refusedAdds = useCallback(\n <TVars,>(present: readonly string[]) => failedAdds<TVars>(changes, present),\n [changes],\n );\n\n const forget = useCallback((mutationId: number) => dismiss(queryClient, mutationId), [queryClient]);\n\n return { status, failedAdds: refusedAdds, dismiss: forget };\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,qBACd,cACuB;CACvB,MAAM,UAAiC,CACrC;EACE,OAAO;EACP,MAAM;EACN,iBAAiB;EACjB,OAAO,MAAM,MAAM;CACrB,CACF;CAEA,KAAK,MAAM,QAAQ,CAAC,UAAU,WAAW,GACvC,QAAQ,KAAK;EACX,OAAO,GAAG,KAAK;EACf;EACA,iBAAiB;EACjB,OAAO,GAAG,MAAM,KAAK,CAAC,KAAK;CAC7B,CAAC;CAGH,KAAK,MAAM,eAAe,cAAc;EACtC,IAAI,YAAY,YAAY,QAAQ,YAAY,QAAQ,eAAe,MAAM;EAC7E,KAAK,MAAM,QAAQ,CAAC,UAAU,WAAW,GACvC,QAAQ,KAAK;GACX,OAAO,GAAG,KAAK,GAAG,YAAY;GAC9B;GACA,iBAAiB,YAAY;GAC7B,OAAO,GAAG,MAAM,KAAK,CAAC,KAAK,IAAI,YAAY;EAC7C,CAAC;CAEL;CAEA,OAAO;AACT;AAEA,SAAgB,mBAAmB,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;GAAE,YAAY,OAAO;GAAY,MAAM,OAAO,MAAM;GAAoB;GAAK;EAAO,CAAC;CAC/F,CAAC;AACH;;AAGA,SAAgB,QAAQ,aAA0B,YAA0B;CAC1E,MAAM,QAAQ,YAAY,iBAAiB;CAC3C,MAAM,WAAW,MAAM,OAAO,CAAC,CAAC,MAAM,UAAU,MAAM,eAAe,UAAU;CAC/E,IAAI,aAAa,KAAA,GAAW,MAAM,OAAO,QAAQ;AACnD;AAEA,SAAS,WAAW,MAAsB;CACxC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC;AACpD;;;;AC5NA,SAAgB,UAAwC,QAA8C;CAEpG,OAAO,YAAY,cADC,eACa,GAAa,MAAM,CAAC,CAAC,CAAC;AACzD;;AAGA,SAAgB,gBAAgB,MAAgB;CAC9C,MAAM,cAAc,eAAe;CACnC,MAAM,UAAU,iBAAiB;EAC/B,SAAS,EAAE,aAAa,UAAU,IAAI,EAAE;EACxC,SAAS,cAAc;GACrB,YAAY,SAAS;GACrB,OAAO,SAAS;EAClB;CACF,CAAC;CAYD,OAAO;EAAE,QAVM,aAAa,OAAe,WAAW,SAAS,EAAE,GAAG,CAAC,OAAO,CAUnE;EAAQ,YAPG,aACT,YAA+B,WAAkB,SAAS,OAAO,GAC1E,CAAC,OAAO,CAKmB;EAAa,SAF3B,aAAa,eAAuB,QAAQ,aAAa,UAAU,GAAG,CAAC,WAAW,CAE9C;CAAO;AAC5D"}
@@ -1,4 +1,4 @@
1
- import { b as shellOf, v as queries } from "./queries-BvSw1xBN.js";
1
+ import { b as shellOf, v as queries } from "./queries-epz4MIuW.js";
2
2
  import { u as useCoffre } from "./page-JTORvh-N.js";
3
3
  import { useMemo } from "react";
4
4
  import { useSuspenseQueries } from "@tanstack/react-query";
@@ -23,4 +23,4 @@ function useShell() {
23
23
  //#endregion
24
24
  export { useShell as t };
25
25
 
26
- //# sourceMappingURL=use-shell-DhFoHjDS.js.map
26
+ //# sourceMappingURL=use-shell-C_NmvCt_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-shell-DhFoHjDS.js","names":[],"sources":["../../src/lib/use-shell.ts"],"sourcesContent":["import { useSuspenseQueries } from '@tanstack/react-query';\nimport { useMemo } from 'react';\n\nimport { useCoffre } from './coffre';\nimport { queries, shellOf, type Shell } from './queries';\n\n/**\n * The shell as a component reads it: from the same queries the root loader\n * fetched, so it follows any change that refetches them.\n */\nexport function useShell(): Shell {\n const client = useCoffre();\n const [auth, me, projects] = useSuspenseQueries({\n queries: [queries.auth(client), queries.me(client), queries.projects(client)],\n });\n return useMemo(() => shellOf(auth.data, me.data, projects.data), [auth.data, me.data, projects.data]);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,WAAkB;CAChC,MAAM,SAAS,UAAU;CACzB,MAAM,CAAC,MAAM,IAAI,YAAY,mBAAmB,EAC9C,SAAS;EAAC,QAAQ,KAAK,MAAM;EAAG,QAAQ,GAAG,MAAM;EAAG,QAAQ,SAAS,MAAM;CAAC,EAC9E,CAAC;CACD,OAAO,cAAc,QAAQ,KAAK,MAAM,GAAG,MAAM,SAAS,IAAI,GAAG;EAAC,KAAK;EAAM,GAAG;EAAM,SAAS;CAAI,CAAC;AACtG"}
1
+ {"version":3,"file":"use-shell-C_NmvCt_.js","names":[],"sources":["../../src/lib/use-shell.ts"],"sourcesContent":["import { useSuspenseQueries } from '@tanstack/react-query';\nimport { useMemo } from 'react';\n\nimport { useCoffre } from './coffre';\nimport { queries, shellOf, type Shell } from './queries';\n\n/**\n * The shell as a component reads it: from the same queries the root loader\n * fetched, so it follows any change that refetches them.\n */\nexport function useShell(): Shell {\n const client = useCoffre();\n const [auth, me, projects] = useSuspenseQueries({\n queries: [queries.auth(client), queries.me(client), queries.projects(client)],\n });\n return useMemo(() => shellOf(auth.data, me.data, projects.data), [auth.data, me.data, projects.data]);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,WAAkB;CAChC,MAAM,SAAS,UAAU;CACzB,MAAM,CAAC,MAAM,IAAI,YAAY,mBAAmB,EAC9C,SAAS;EAAC,QAAQ,KAAK,MAAM;EAAG,QAAQ,GAAG,MAAM;EAAG,QAAQ,SAAS,MAAM;CAAC,EAC9E,CAAC;CACD,OAAO,cAAc,QAAQ,KAAK,MAAM,GAAG,MAAM,SAAS,IAAI,GAAG;EAAC,KAAK;EAAM,GAAG;EAAM,SAAS;CAAI,CAAC;AACtG"}