@aphexcms/cms-core 11.3.0 → 12.0.0-next.20261109083516

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 (227) hide show
  1. package/dist/admin/client-auth.svelte.d.ts +120 -0
  2. package/dist/admin/client-auth.svelte.d.ts.map +1 -0
  3. package/dist/admin/client-auth.svelte.js +14 -0
  4. package/dist/admin/client-config.d.ts +72 -0
  5. package/dist/admin/client-config.d.ts.map +1 -0
  6. package/dist/admin/client-config.js +1 -0
  7. package/dist/admin/settings-header-actions.d.ts +12 -0
  8. package/dist/admin/settings-header-actions.d.ts.map +1 -0
  9. package/dist/admin/settings-header-actions.js +1 -0
  10. package/dist/admin/view-data.d.ts +189 -0
  11. package/dist/admin/view-data.d.ts.map +1 -0
  12. package/dist/admin/view-data.js +1 -0
  13. package/dist/admin.css +6 -0
  14. package/dist/api/invitations.d.ts +2 -2
  15. package/dist/api/invitations.d.ts.map +1 -1
  16. package/dist/api/organizations.d.ts +5 -4
  17. package/dist/api/organizations.d.ts.map +1 -1
  18. package/dist/api/organizations.js +2 -3
  19. package/dist/api/user.d.ts +6 -1
  20. package/dist/api/user.d.ts.map +1 -1
  21. package/dist/api/user.js +7 -0
  22. package/dist/app-augment.d.ts +2 -3
  23. package/dist/app-augment.d.ts.map +1 -1
  24. package/dist/app.d.ts +1 -1
  25. package/dist/auth/auth-errors.d.ts +6 -0
  26. package/dist/auth/auth-errors.d.ts.map +1 -1
  27. package/dist/auth/auth-errors.js +8 -0
  28. package/dist/auth/auth-hooks.d.ts.map +1 -1
  29. package/dist/auth/auth-hooks.js +36 -17
  30. package/dist/auth/invitation-email.d.ts +9 -0
  31. package/dist/auth/invitation-email.d.ts.map +1 -0
  32. package/dist/auth/invitation-email.js +49 -0
  33. package/dist/auth/pages.d.ts +16 -0
  34. package/dist/auth/pages.d.ts.map +1 -0
  35. package/dist/auth/pages.js +23 -0
  36. package/dist/auth/provider.d.ts +31 -1
  37. package/dist/auth/provider.d.ts.map +1 -1
  38. package/dist/client/index.d.ts +5 -0
  39. package/dist/client/index.d.ts.map +1 -1
  40. package/dist/client/index.js +9 -0
  41. package/dist/client/ui.d.ts +16 -0
  42. package/dist/client/ui.d.ts.map +1 -1
  43. package/dist/client/ui.js +26 -1
  44. package/dist/components/AphexStudio.svelte +268 -0
  45. package/dist/components/AphexStudio.svelte.d.ts +16 -0
  46. package/dist/components/AphexStudio.svelte.d.ts.map +1 -0
  47. package/dist/components/admin/AccountSettings.svelte +339 -0
  48. package/dist/components/admin/AccountSettings.svelte.d.ts +8 -0
  49. package/dist/components/admin/AccountSettings.svelte.d.ts.map +1 -0
  50. package/dist/components/admin/AccountSettingsView.svelte +61 -0
  51. package/dist/components/admin/AccountSettingsView.svelte.d.ts +19 -0
  52. package/dist/components/admin/AccountSettingsView.svelte.d.ts.map +1 -0
  53. package/dist/components/admin/ApiKeysSettings.svelte +435 -0
  54. package/dist/components/admin/ApiKeysSettings.svelte.d.ts +15 -0
  55. package/dist/components/admin/ApiKeysSettings.svelte.d.ts.map +1 -0
  56. package/dist/components/admin/AuthPageShell.svelte +32 -0
  57. package/dist/components/admin/AuthPageShell.svelte.d.ts +16 -0
  58. package/dist/components/admin/AuthPageShell.svelte.d.ts.map +1 -0
  59. package/dist/components/admin/CreateOrganization.svelte +158 -0
  60. package/dist/components/admin/CreateOrganization.svelte.d.ts +11 -0
  61. package/dist/components/admin/CreateOrganization.svelte.d.ts.map +1 -0
  62. package/dist/components/admin/DeleteAccountSettings.svelte +124 -0
  63. package/dist/components/admin/DeleteAccountSettings.svelte.d.ts +7 -0
  64. package/dist/components/admin/DeleteAccountSettings.svelte.d.ts.map +1 -0
  65. package/dist/components/admin/DeleteOrganizationSettings.svelte +123 -0
  66. package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts +11 -0
  67. package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts.map +1 -0
  68. package/dist/components/admin/DocumentEditor.svelte +92 -22
  69. package/dist/components/admin/DocumentEditor.svelte.d.ts.map +1 -1
  70. package/dist/components/admin/GeneralSettings.svelte +45 -0
  71. package/dist/components/admin/GeneralSettings.svelte.d.ts +10 -0
  72. package/dist/components/admin/GeneralSettings.svelte.d.ts.map +1 -0
  73. package/dist/components/admin/GodModeView.svelte +112 -0
  74. package/dist/components/admin/GodModeView.svelte.d.ts +9 -0
  75. package/dist/components/admin/GodModeView.svelte.d.ts.map +1 -0
  76. package/dist/components/admin/InvitationsView.svelte +277 -0
  77. package/dist/components/admin/InvitationsView.svelte.d.ts +11 -0
  78. package/dist/components/admin/InvitationsView.svelte.d.ts.map +1 -0
  79. package/dist/components/admin/InviteView.svelte +98 -0
  80. package/dist/components/admin/InviteView.svelte.d.ts +9 -0
  81. package/dist/components/admin/InviteView.svelte.d.ts.map +1 -0
  82. package/dist/components/admin/LoginView.svelte +478 -0
  83. package/dist/components/admin/LoginView.svelte.d.ts +5 -0
  84. package/dist/components/admin/LoginView.svelte.d.ts.map +1 -0
  85. package/dist/components/admin/MembersSettings.svelte +25 -3
  86. package/dist/components/admin/MembersSettings.svelte.d.ts +5 -1
  87. package/dist/components/admin/MembersSettings.svelte.d.ts.map +1 -1
  88. package/dist/components/admin/OrganizationSettings.svelte +367 -0
  89. package/dist/components/admin/OrganizationSettings.svelte.d.ts +9 -0
  90. package/dist/components/admin/OrganizationSettings.svelte.d.ts.map +1 -0
  91. package/dist/components/admin/OrganizationsList.svelte +92 -0
  92. package/dist/components/admin/OrganizationsList.svelte.d.ts +8 -0
  93. package/dist/components/admin/OrganizationsList.svelte.d.ts.map +1 -0
  94. package/dist/components/admin/OrganizationsView.svelte +31 -0
  95. package/dist/components/admin/OrganizationsView.svelte.d.ts +9 -0
  96. package/dist/components/admin/OrganizationsView.svelte.d.ts.map +1 -0
  97. package/dist/components/admin/PasswordInput.svelte +43 -0
  98. package/dist/components/admin/PasswordInput.svelte.d.ts +8 -0
  99. package/dist/components/admin/PasswordInput.svelte.d.ts.map +1 -0
  100. package/dist/components/admin/PasswordSettings.svelte +179 -0
  101. package/dist/components/admin/PasswordSettings.svelte.d.ts +4 -0
  102. package/dist/components/admin/PasswordSettings.svelte.d.ts.map +1 -0
  103. package/dist/components/admin/PreferencesSettings.svelte +80 -0
  104. package/dist/components/admin/PreferencesSettings.svelte.d.ts +20 -0
  105. package/dist/components/admin/PreferencesSettings.svelte.d.ts.map +1 -0
  106. package/dist/components/admin/ResetPasswordView.svelte +117 -0
  107. package/dist/components/admin/ResetPasswordView.svelte.d.ts +9 -0
  108. package/dist/components/admin/ResetPasswordView.svelte.d.ts.map +1 -0
  109. package/dist/components/admin/RolesSettings.svelte +360 -0
  110. package/dist/components/admin/RolesSettings.svelte.d.ts +11 -0
  111. package/dist/components/admin/RolesSettings.svelte.d.ts.map +1 -0
  112. package/dist/components/admin/SchemaField.svelte +2 -1
  113. package/dist/components/admin/SchemaField.svelte.d.ts.map +1 -1
  114. package/dist/components/admin/SettingsHeaderActions.svelte +25 -0
  115. package/dist/components/admin/SettingsHeaderActions.svelte.d.ts +8 -0
  116. package/dist/components/admin/SettingsHeaderActions.svelte.d.ts.map +1 -0
  117. package/dist/components/admin/SettingsShell.svelte +136 -0
  118. package/dist/components/admin/SettingsShell.svelte.d.ts +9 -0
  119. package/dist/components/admin/SettingsShell.svelte.d.ts.map +1 -0
  120. package/dist/components/admin/TwoFactorChallengeView.svelte +377 -0
  121. package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts +11 -0
  122. package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts.map +1 -0
  123. package/dist/components/admin/TwoFactorSettings.svelte +436 -0
  124. package/dist/components/admin/TwoFactorSettings.svelte.d.ts +7 -0
  125. package/dist/components/admin/TwoFactorSettings.svelte.d.ts.map +1 -0
  126. package/dist/components/admin/fields/ImageField.svelte +4 -2
  127. package/dist/components/admin/fields/richtext/PortableTextImageView.svelte +3 -2
  128. package/dist/components/admin/fields/richtext/RichtextField.svelte +48 -6
  129. package/dist/components/admin/fields/richtext/RichtextField.svelte.d.ts.map +1 -1
  130. package/dist/components/layout/sidebar/NavUser.svelte +2 -2
  131. package/dist/config.d.ts +2 -1
  132. package/dist/config.d.ts.map +1 -1
  133. package/dist/email/index.d.ts +1 -0
  134. package/dist/email/index.d.ts.map +1 -1
  135. package/dist/email/index.js +2 -0
  136. package/dist/email/interfaces/email.d.ts +2 -0
  137. package/dist/email/interfaces/email.d.ts.map +1 -1
  138. package/dist/email/link-email.d.ts +15 -0
  139. package/dist/email/link-email.d.ts.map +1 -0
  140. package/dist/email/link-email.js +30 -0
  141. package/dist/field-validation/utils.d.ts +29 -0
  142. package/dist/field-validation/utils.d.ts.map +1 -1
  143. package/dist/field-validation/utils.js +138 -5
  144. package/dist/graphql/index.d.ts.map +1 -1
  145. package/dist/graphql/index.js +1 -1
  146. package/dist/hooks.d.ts +6 -3
  147. package/dist/hooks.d.ts.map +1 -1
  148. package/dist/hooks.js +53 -17
  149. package/dist/jobs/recurring.d.ts +4 -1
  150. package/dist/jobs/recurring.d.ts.map +1 -1
  151. package/dist/jobs/recurring.js +28 -0
  152. package/dist/local-api/auth-helpers.d.ts +4 -4
  153. package/dist/local-api/auth-helpers.js +4 -4
  154. package/dist/local-api/collection-api.d.ts +10 -1
  155. package/dist/local-api/collection-api.d.ts.map +1 -1
  156. package/dist/local-api/collection-api.js +25 -7
  157. package/dist/local-api/index.d.ts +1 -1
  158. package/dist/local-api/index.d.ts.map +1 -1
  159. package/dist/local-api/index.js +7 -5
  160. package/dist/local-api/types.d.ts +1 -1
  161. package/dist/preview/perspective.d.ts +1 -1
  162. package/dist/preview/perspective.js +1 -1
  163. package/dist/resolve-config.d.ts +22 -0
  164. package/dist/resolve-config.d.ts.map +1 -0
  165. package/dist/resolve-config.js +106 -0
  166. package/dist/routes/assets-cdn.d.ts +7 -2
  167. package/dist/routes/assets-cdn.d.ts.map +1 -1
  168. package/dist/routes/assets-cdn.js +1 -1
  169. package/dist/server/api/index.d.ts +1 -2
  170. package/dist/server/api/index.d.ts.map +1 -1
  171. package/dist/server/api/index.js +10 -3
  172. package/dist/server/api/openapi/registry.d.ts.map +1 -1
  173. package/dist/server/api/openapi/registry.js +62 -0
  174. package/dist/server/api/routes/api-keys.d.ts +4 -0
  175. package/dist/server/api/routes/api-keys.d.ts.map +1 -0
  176. package/dist/server/api/routes/api-keys.js +88 -0
  177. package/dist/server/api/routes/documents-by-id.d.ts.map +1 -1
  178. package/dist/server/api/routes/documents-by-id.js +16 -1
  179. package/dist/server/api/routes/documents-publish.d.ts.map +1 -1
  180. package/dist/server/api/routes/documents-publish.js +11 -1
  181. package/dist/server/api/routes/documents.d.ts.map +1 -1
  182. package/dist/server/api/routes/documents.js +16 -2
  183. package/dist/server/api/routes/instance-settings.d.ts +4 -0
  184. package/dist/server/api/routes/instance-settings.d.ts.map +1 -0
  185. package/dist/server/api/routes/instance-settings.js +47 -0
  186. package/dist/server/api/routes/invitations.d.ts +9 -0
  187. package/dist/server/api/routes/invitations.d.ts.map +1 -0
  188. package/dist/server/api/routes/invitations.js +79 -0
  189. package/dist/server/api/routes/organizations-invitations.d.ts +0 -6
  190. package/dist/server/api/routes/organizations-invitations.d.ts.map +1 -1
  191. package/dist/server/api/routes/organizations-invitations.js +6 -7
  192. package/dist/server/api/routes/organizations-team.d.ts.map +1 -1
  193. package/dist/server/api/routes/organizations-team.js +2 -52
  194. package/dist/server/api/routes/organizations.d.ts.map +1 -1
  195. package/dist/server/api/routes/organizations.js +35 -9
  196. package/dist/server/core-routes.d.ts +8 -0
  197. package/dist/server/core-routes.d.ts.map +1 -0
  198. package/dist/server/core-routes.js +67 -0
  199. package/dist/server/index.d.ts +5 -1
  200. package/dist/server/index.d.ts.map +1 -1
  201. package/dist/server/index.js +7 -1
  202. package/dist/server/pages/admin.d.ts +24 -0
  203. package/dist/server/pages/admin.d.ts.map +1 -0
  204. package/dist/server/pages/admin.js +468 -0
  205. package/dist/server/queries/organization-team.d.ts +14 -0
  206. package/dist/server/queries/organization-team.d.ts.map +1 -0
  207. package/dist/server/queries/organization-team.js +65 -0
  208. package/dist/server/queries/pending-invitations.d.ts +8 -0
  209. package/dist/server/queries/pending-invitations.d.ts.map +1 -0
  210. package/dist/server/queries/pending-invitations.js +24 -0
  211. package/dist/types/api-key.d.ts +18 -0
  212. package/dist/types/api-key.d.ts.map +1 -0
  213. package/dist/types/api-key.js +1 -0
  214. package/dist/types/auth.d.ts +35 -0
  215. package/dist/types/auth.d.ts.map +1 -1
  216. package/dist/types/capabilities.d.ts +1 -2
  217. package/dist/types/capabilities.d.ts.map +1 -1
  218. package/dist/types/config.d.ts +124 -4
  219. package/dist/types/config.d.ts.map +1 -1
  220. package/dist/types/filters.d.ts +1 -1
  221. package/dist/types/index.d.ts +1 -0
  222. package/dist/types/index.d.ts.map +1 -1
  223. package/dist/types/index.js +1 -0
  224. package/dist/types/organization.d.ts +1 -1
  225. package/dist/vite/index.d.ts.map +1 -1
  226. package/dist/vite/index.js +46 -39
  227. package/package.json +19 -29
@@ -0,0 +1,179 @@
1
+ <script lang="ts">
2
+ import { Button } from '@aphexcms/ui/shadcn/button';
3
+ import PasswordInput from './PasswordInput.svelte';
4
+ import { Label } from '@aphexcms/ui/shadcn/label';
5
+ import { Checkbox } from '@aphexcms/ui/shadcn/checkbox';
6
+ import * as Card from '@aphexcms/ui/shadcn/card';
7
+ import * as Dialog from '@aphexcms/ui/shadcn/dialog';
8
+ import { KeyRound } from '@lucide/svelte';
9
+ import { toast } from 'svelte-sonner';
10
+ import { useAdminAuthClient } from '../../admin/client-auth.svelte';
11
+
12
+ /**
13
+ * Change your own password from inside the admin.
14
+ *
15
+ * Distinct from the /reset-password flow, which is for people who *can't* sign
16
+ * in and proves identity by email. Here the session already proves identity,
17
+ * so the current password is what stops someone walking up to an unlocked
18
+ * laptop and taking the account over.
19
+ *
20
+ * The actual mutation goes through the host-provided admin auth client (the
21
+ * provider-agnostic client-side seam), not a hard dependency on Better Auth.
22
+ */
23
+
24
+ const auth = useAdminAuthClient();
25
+
26
+ // The minimum better-auth enforces server-side; repeated here only so the user
27
+ // finds out before the round-trip, never as the only check.
28
+ const MIN_LENGTH = 8;
29
+
30
+ let open = $state(false);
31
+ let currentPassword = $state('');
32
+ let newPassword = $state('');
33
+ let confirmPassword = $state('');
34
+ // On by default: a password change usually means "someone may have had this",
35
+ // and leaving other sessions alive would defeat the point.
36
+ let revokeOtherSessions = $state(true);
37
+ let busy = $state(false);
38
+
39
+ const mismatch = $derived(confirmPassword.length > 0 && newPassword !== confirmPassword);
40
+ const tooShort = $derived(newPassword.length > 0 && newPassword.length < MIN_LENGTH);
41
+ const canSubmit = $derived(
42
+ Boolean(currentPassword) && newPassword.length >= MIN_LENGTH && newPassword === confirmPassword
43
+ );
44
+
45
+ function reset() {
46
+ currentPassword = '';
47
+ newPassword = '';
48
+ confirmPassword = '';
49
+ revokeOtherSessions = true;
50
+ }
51
+
52
+ /** Never leave typed passwords sitting in memory behind a closed dialog. */
53
+ function onOpenChange(next: boolean) {
54
+ if (busy) return;
55
+ open = next;
56
+ if (!next) reset();
57
+ }
58
+
59
+ async function changePassword(e: SubmitEvent) {
60
+ e.preventDefault();
61
+ if (!auth) {
62
+ toast.error('Password changes are unavailable');
63
+ return;
64
+ }
65
+ busy = true;
66
+ try {
67
+ const result = await auth.changePassword({
68
+ currentPassword,
69
+ newPassword,
70
+ revokeOtherSessions
71
+ });
72
+
73
+ if (result.error) {
74
+ toast.error(result.error.message || 'Could not change your password');
75
+ return;
76
+ }
77
+
78
+ reset();
79
+ open = false;
80
+ toast.success(
81
+ revokeOtherSessions
82
+ ? 'Password changed — other sessions have been signed out'
83
+ : 'Password changed'
84
+ );
85
+ } catch (error) {
86
+ toast.error(error instanceof Error ? error.message : 'Could not change your password');
87
+ } finally {
88
+ busy = false;
89
+ }
90
+ }
91
+ </script>
92
+
93
+ <Card.Root>
94
+ <Card.Header class="flex flex-row items-start justify-between gap-4">
95
+ <div class="space-y-1.5">
96
+ <Card.Title>Password</Card.Title>
97
+ <Card.Description>
98
+ Change the password you use to sign in. You'll need your current password, and you can sign
99
+ out everywhere else at the same time.
100
+ </Card.Description>
101
+ </div>
102
+ <Button variant="outline" class="shrink-0" onclick={() => (open = true)} disabled={!auth}>
103
+ <KeyRound class="mr-2 h-4 w-4" />
104
+ Change password
105
+ </Button>
106
+ </Card.Header>
107
+ </Card.Root>
108
+
109
+ <!--
110
+ Controlled rather than `bind:open` — the binding would apply the close before
111
+ `onOpenChange` could refuse it, so an in-flight request couldn't hold the
112
+ dialog open.
113
+ -->
114
+ <Dialog.Root {open} {onOpenChange}>
115
+ <Dialog.Content class="sm:max-w-md">
116
+ <Dialog.Header>
117
+ <Dialog.Title>Change password</Dialog.Title>
118
+ <Dialog.Description>Enter your current password, then choose a new one.</Dialog.Description>
119
+ </Dialog.Header>
120
+
121
+ <form id="change-password" onsubmit={changePassword} class="space-y-4">
122
+ <div class="space-y-2">
123
+ <Label for="current-password">Current password</Label>
124
+ <PasswordInput
125
+ id="current-password"
126
+ bind:value={currentPassword}
127
+ required
128
+ autocomplete="current-password"
129
+ disabled={busy}
130
+ />
131
+ </div>
132
+
133
+ <div class="space-y-2">
134
+ <Label for="new-password">New password</Label>
135
+ <PasswordInput
136
+ id="new-password"
137
+ bind:value={newPassword}
138
+ required
139
+ autocomplete="new-password"
140
+ disabled={busy}
141
+ />
142
+ <p class="text-xs {tooShort ? 'text-destructive' : 'text-muted-foreground'}">
143
+ Must be at least {MIN_LENGTH} characters long
144
+ </p>
145
+ </div>
146
+
147
+ <div class="space-y-2">
148
+ <Label for="confirm-password">Confirm new password</Label>
149
+ <PasswordInput
150
+ id="confirm-password"
151
+ bind:value={confirmPassword}
152
+ required
153
+ autocomplete="new-password"
154
+ disabled={busy}
155
+ />
156
+ {#if mismatch}
157
+ <p class="text-destructive text-xs">Passwords do not match</p>
158
+ {/if}
159
+ </div>
160
+
161
+ <div class="flex items-center gap-2">
162
+ <Checkbox
163
+ id="revoke-sessions"
164
+ checked={revokeOtherSessions}
165
+ onCheckedChange={(checked) => (revokeOtherSessions = checked === true)}
166
+ disabled={busy}
167
+ />
168
+ <Label for="revoke-sessions" class="text-sm font-normal">Sign out everywhere else</Label>
169
+ </div>
170
+ </form>
171
+
172
+ <Dialog.Footer>
173
+ <Button variant="ghost" onclick={() => onOpenChange(false)} disabled={busy}>Cancel</Button>
174
+ <Button type="submit" form="change-password" disabled={busy || !canSubmit}>
175
+ {busy ? 'Changing…' : 'Change password'}
176
+ </Button>
177
+ </Dialog.Footer>
178
+ </Dialog.Content>
179
+ </Dialog.Root>
@@ -0,0 +1,4 @@
1
+ declare const PasswordSettings: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type PasswordSettings = ReturnType<typeof PasswordSettings>;
3
+ export default PasswordSettings;
4
+ //# sourceMappingURL=PasswordSettings.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordSettings.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/PasswordSettings.svelte.ts"],"names":[],"mappings":"AAwKA,QAAA,MAAM,gBAAgB,2DAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,80 @@
1
+ <script lang="ts">
2
+ import { Label } from '@aphexcms/ui/shadcn/label';
3
+ import { Switch } from '@aphexcms/ui/shadcn/switch';
4
+ import * as Card from '@aphexcms/ui/shadcn/card';
5
+ import type { UserSessionPreferences } from '../../types/organization';
6
+ import { user as userApi } from '../../api';
7
+ import { Building2 } from '@lucide/svelte';
8
+ import { toast } from 'svelte-sonner';
9
+
10
+ /**
11
+ * Per-user workspace preferences.
12
+ *
13
+ * Split out of AccountSettings so the settings page can file it under its own
14
+ * heading — these change what you *see* in the CMS, not who you are, and
15
+ * grouping them with name and avatar made "Profile" mean two things.
16
+ *
17
+ * Preferences save immediately on toggle, with no Save button. They're
18
+ * per-user view settings, so the cost of a wrong one is seeing the wrong list
19
+ * for a moment, and an unsaved toggle is a worse failure than an instant one.
20
+ */
21
+
22
+ type Props = {
23
+ userPreferences?: UserSessionPreferences | null;
24
+ hasChildOrganizations?: boolean;
25
+ };
26
+
27
+ let { userPreferences = null, hasChildOrganizations = false }: Props = $props();
28
+
29
+ let includeChildOrganizations = $state(false);
30
+ let isUpdating = $state(false);
31
+
32
+ $effect(() => {
33
+ includeChildOrganizations = userPreferences?.includeChildOrganizations ?? false;
34
+ });
35
+
36
+ async function updatePreferences(prefs: Partial<UserSessionPreferences>) {
37
+ isUpdating = true;
38
+ try {
39
+ const result = await userApi.updatePreferences(prefs);
40
+
41
+ if (!result.success) {
42
+ throw new Error(result.error || result.message || 'Failed to update preferences');
43
+ }
44
+ } catch (error) {
45
+ toast.error(error instanceof Error ? error.message : 'Failed to update preferences');
46
+ // Revert on error
47
+ if (prefs.includeChildOrganizations !== undefined) {
48
+ includeChildOrganizations = !prefs.includeChildOrganizations;
49
+ }
50
+ } finally {
51
+ isUpdating = false;
52
+ }
53
+ }
54
+ </script>
55
+
56
+ {#if hasChildOrganizations}
57
+ <Card.Root>
58
+ <Card.Content>
59
+ <div class="flex items-center justify-between gap-4">
60
+ <div class="flex items-center gap-3">
61
+ <Building2 class="text-muted-foreground h-5 w-5 shrink-0" />
62
+ <div>
63
+ <Label class="text-base font-medium">Include child organizations</Label>
64
+ <p class="text-muted-foreground text-sm">
65
+ Show documents from child organizations in your content lists
66
+ </p>
67
+ </div>
68
+ </div>
69
+ <Switch
70
+ checked={includeChildOrganizations}
71
+ disabled={isUpdating}
72
+ onCheckedChange={(checked) => {
73
+ includeChildOrganizations = checked;
74
+ updatePreferences({ includeChildOrganizations: checked });
75
+ }}
76
+ />
77
+ </div>
78
+ </Card.Content>
79
+ </Card.Root>
80
+ {/if}
@@ -0,0 +1,20 @@
1
+ import type { UserSessionPreferences } from '../../types/organization.js';
2
+ /**
3
+ * Per-user workspace preferences.
4
+ *
5
+ * Split out of AccountSettings so the settings page can file it under its own
6
+ * heading — these change what you *see* in the CMS, not who you are, and
7
+ * grouping them with name and avatar made "Profile" mean two things.
8
+ *
9
+ * Preferences save immediately on toggle, with no Save button. They're
10
+ * per-user view settings, so the cost of a wrong one is seeing the wrong list
11
+ * for a moment, and an unsaved toggle is a worse failure than an instant one.
12
+ */
13
+ type Props = {
14
+ userPreferences?: UserSessionPreferences | null;
15
+ hasChildOrganizations?: boolean;
16
+ };
17
+ declare const PreferencesSettings: import("svelte").Component<Props, {}, "">;
18
+ type PreferencesSettings = ReturnType<typeof PreferencesSettings>;
19
+ export default PreferencesSettings;
20
+ //# sourceMappingURL=PreferencesSettings.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreferencesSettings.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/PreferencesSettings.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMtE;;;;;;;;;;GAUG;AAEH,KAAK,KAAK,GAAG;IACZ,eAAe,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAChD,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAgEH,QAAA,MAAM,mBAAmB,2CAAwC,CAAC;AAClE,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAClE,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,117 @@
1
+ <script lang="ts">
2
+ /** Someone following a password reset link. */
3
+ import { goto } from '$app/navigation';
4
+ import { Button } from '@aphexcms/ui/shadcn/button';
5
+ import { Label } from '@aphexcms/ui/shadcn/label';
6
+ import * as Card from '@aphexcms/ui/shadcn/card';
7
+ import { user } from '../../api/user';
8
+ import AuthPageShell from './AuthPageShell.svelte';
9
+ import PasswordInput from './PasswordInput.svelte';
10
+ import type { AdminResetPasswordData } from '../../admin/view-data';
11
+
12
+ let { data, title }: { data: AdminResetPasswordData; title: string } = $props();
13
+
14
+ let newPassword = $state('');
15
+ let confirmPassword = $state('');
16
+ let error = $state('');
17
+ let success = $state(false);
18
+ let loading = $state(false);
19
+
20
+ async function handleSubmit(e: SubmitEvent) {
21
+ e.preventDefault();
22
+ error = '';
23
+
24
+ if (newPassword !== confirmPassword) {
25
+ error = 'Passwords do not match';
26
+ return;
27
+ }
28
+ if (newPassword.length < 8) {
29
+ error = 'Password must be at least 8 characters long';
30
+ return;
31
+ }
32
+
33
+ loading = true;
34
+ try {
35
+ const result = await user.resetPassword({ token: data.token, newPassword });
36
+ if (!result.success) {
37
+ error = result.message || result.error || 'Failed to reset password';
38
+ return;
39
+ }
40
+ success = true;
41
+ setTimeout(() => goto('/admin/login'), 2000);
42
+ } catch (err) {
43
+ error = err instanceof Error ? err.message : 'An error occurred';
44
+ } finally {
45
+ loading = false;
46
+ }
47
+ }
48
+ </script>
49
+
50
+ <svelte:head>
51
+ <title>{title} — Reset Password</title>
52
+ <meta name="robots" content="noindex" />
53
+ </svelte:head>
54
+
55
+ <AuthPageShell branding={data.branding} {title}>
56
+ <Card.Root class="shadow-lg">
57
+ <Card.Header class="space-y-1">
58
+ <Card.Title class="text-center text-2xl font-bold">
59
+ {success ? 'Password Reset!' : 'Reset Your Password'}
60
+ </Card.Title>
61
+ <Card.Description class="text-center">
62
+ {success ? 'Redirecting to login...' : 'Enter your new password'}
63
+ </Card.Description>
64
+ </Card.Header>
65
+
66
+ <Card.Content>
67
+ {#if success}
68
+ <div class="rounded-lg border border-green-500/50 bg-green-500/10 p-4 text-center">
69
+ <p class="font-medium text-green-700 dark:text-green-400">
70
+ Your password has been reset successfully!
71
+ </p>
72
+ </div>
73
+ {:else}
74
+ <form onsubmit={handleSubmit} class="space-y-4">
75
+ {#if error}
76
+ <div class="border-destructive/50 bg-destructive/10 rounded-lg border p-3">
77
+ <p class="text-destructive text-sm font-medium">{error}</p>
78
+ </div>
79
+ {/if}
80
+
81
+ <div class="space-y-2">
82
+ <Label for="newPassword">New Password</Label>
83
+ <PasswordInput
84
+ id="newPassword"
85
+ placeholder="••••••••"
86
+ bind:value={newPassword}
87
+ required
88
+ autocomplete="new-password"
89
+ disabled={loading}
90
+ />
91
+ <p class="text-muted-foreground text-xs">Must be at least 8 characters long</p>
92
+ </div>
93
+
94
+ <div class="space-y-2">
95
+ <Label for="confirmPassword">Confirm Password</Label>
96
+ <PasswordInput
97
+ id="confirmPassword"
98
+ placeholder="••••••••"
99
+ bind:value={confirmPassword}
100
+ required
101
+ autocomplete="new-password"
102
+ disabled={loading}
103
+ />
104
+ </div>
105
+
106
+ <Button type="submit" class="w-full" disabled={loading}>
107
+ {loading ? 'Resetting…' : 'Reset Password'}
108
+ </Button>
109
+
110
+ <Button type="button" variant="ghost" class="w-full" onclick={() => goto('/admin/login')}>
111
+ ← Back to Login
112
+ </Button>
113
+ </form>
114
+ {/if}
115
+ </Card.Content>
116
+ </Card.Root>
117
+ </AuthPageShell>
@@ -0,0 +1,9 @@
1
+ import type { AdminResetPasswordData } from '../../admin/view-data.js';
2
+ type $$ComponentProps = {
3
+ data: AdminResetPasswordData;
4
+ title: string;
5
+ };
6
+ declare const ResetPasswordView: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type ResetPasswordView = ReturnType<typeof ResetPasswordView>;
8
+ export default ResetPasswordView;
9
+ //# sourceMappingURL=ResetPasswordView.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResetPasswordView.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/ResetPasswordView.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,KAAK,gBAAgB,GAAI;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA2G1E,QAAA,MAAM,iBAAiB,sDAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}