@aphexcms/cms-core 11.2.1 → 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.
- package/dist/admin/client-auth.svelte.d.ts +120 -0
- package/dist/admin/client-auth.svelte.d.ts.map +1 -0
- package/dist/admin/client-auth.svelte.js +14 -0
- package/dist/admin/client-config.d.ts +72 -0
- package/dist/admin/client-config.d.ts.map +1 -0
- package/dist/admin/client-config.js +1 -0
- package/dist/admin/settings-header-actions.d.ts +12 -0
- package/dist/admin/settings-header-actions.d.ts.map +1 -0
- package/dist/admin/settings-header-actions.js +1 -0
- package/dist/admin/view-data.d.ts +189 -0
- package/dist/admin/view-data.d.ts.map +1 -0
- package/dist/admin/view-data.js +1 -0
- package/dist/admin.css +6 -0
- package/dist/api/invitations.d.ts +2 -2
- package/dist/api/invitations.d.ts.map +1 -1
- package/dist/api/organizations.d.ts +13 -3
- package/dist/api/organizations.d.ts.map +1 -1
- package/dist/api/organizations.js +11 -1
- package/dist/api/user.d.ts +6 -1
- package/dist/api/user.d.ts.map +1 -1
- package/dist/api/user.js +7 -0
- package/dist/app-augment.d.ts +2 -3
- package/dist/app-augment.d.ts.map +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/auth/auth-errors.d.ts +6 -0
- package/dist/auth/auth-errors.d.ts.map +1 -1
- package/dist/auth/auth-errors.js +8 -0
- package/dist/auth/auth-hooks.d.ts.map +1 -1
- package/dist/auth/auth-hooks.js +36 -17
- package/dist/auth/invitation-email.d.ts +9 -0
- package/dist/auth/invitation-email.d.ts.map +1 -0
- package/dist/auth/invitation-email.js +49 -0
- package/dist/auth/pages.d.ts +16 -0
- package/dist/auth/pages.d.ts.map +1 -0
- package/dist/auth/pages.js +23 -0
- package/dist/auth/provider.d.ts +31 -1
- package/dist/auth/provider.d.ts.map +1 -1
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +9 -0
- package/dist/client/ui.d.ts +17 -0
- package/dist/client/ui.d.ts.map +1 -1
- package/dist/client/ui.js +27 -0
- package/dist/components/AdminApp.svelte +7 -4
- package/dist/components/AdminApp.svelte.d.ts.map +1 -1
- package/dist/components/AphexStudio.svelte +268 -0
- package/dist/components/AphexStudio.svelte.d.ts +16 -0
- package/dist/components/AphexStudio.svelte.d.ts.map +1 -0
- package/dist/components/admin/AccountSettings.svelte +339 -0
- package/dist/components/admin/AccountSettings.svelte.d.ts +8 -0
- package/dist/components/admin/AccountSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/AccountSettingsView.svelte +61 -0
- package/dist/components/admin/AccountSettingsView.svelte.d.ts +19 -0
- package/dist/components/admin/AccountSettingsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/ApiKeysSettings.svelte +435 -0
- package/dist/components/admin/ApiKeysSettings.svelte.d.ts +15 -0
- package/dist/components/admin/ApiKeysSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/AuthPageShell.svelte +32 -0
- package/dist/components/admin/AuthPageShell.svelte.d.ts +16 -0
- package/dist/components/admin/AuthPageShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/CreateOrganization.svelte +158 -0
- package/dist/components/admin/CreateOrganization.svelte.d.ts +11 -0
- package/dist/components/admin/CreateOrganization.svelte.d.ts.map +1 -0
- package/dist/components/admin/DeleteAccountSettings.svelte +124 -0
- package/dist/components/admin/DeleteAccountSettings.svelte.d.ts +7 -0
- package/dist/components/admin/DeleteAccountSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte +123 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts +11 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/DocumentEditor.svelte +108 -36
- package/dist/components/admin/DocumentEditor.svelte.d.ts.map +1 -1
- package/dist/components/admin/GeneralSettings.svelte +45 -0
- package/dist/components/admin/GeneralSettings.svelte.d.ts +10 -0
- package/dist/components/admin/GeneralSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/GodModeView.svelte +112 -0
- package/dist/components/admin/GodModeView.svelte.d.ts +9 -0
- package/dist/components/admin/GodModeView.svelte.d.ts.map +1 -0
- package/dist/components/admin/InvitationsView.svelte +277 -0
- package/dist/components/admin/InvitationsView.svelte.d.ts +11 -0
- package/dist/components/admin/InvitationsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/InviteView.svelte +98 -0
- package/dist/components/admin/InviteView.svelte.d.ts +9 -0
- package/dist/components/admin/InviteView.svelte.d.ts.map +1 -0
- package/dist/components/admin/LoginView.svelte +478 -0
- package/dist/components/admin/LoginView.svelte.d.ts +5 -0
- package/dist/components/admin/LoginView.svelte.d.ts.map +1 -0
- package/dist/components/admin/MembersSettings.svelte +661 -0
- package/dist/components/admin/MembersSettings.svelte.d.ts +8 -0
- package/dist/components/admin/MembersSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationSettings.svelte +367 -0
- package/dist/components/admin/OrganizationSettings.svelte.d.ts +9 -0
- package/dist/components/admin/OrganizationSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationsList.svelte +92 -0
- package/dist/components/admin/OrganizationsList.svelte.d.ts +8 -0
- package/dist/components/admin/OrganizationsList.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationsView.svelte +31 -0
- package/dist/components/admin/OrganizationsView.svelte.d.ts +9 -0
- package/dist/components/admin/OrganizationsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/PasswordInput.svelte +43 -0
- package/dist/components/admin/PasswordInput.svelte.d.ts +8 -0
- package/dist/components/admin/PasswordInput.svelte.d.ts.map +1 -0
- package/dist/components/admin/PasswordSettings.svelte +179 -0
- package/dist/components/admin/PasswordSettings.svelte.d.ts +4 -0
- package/dist/components/admin/PasswordSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/PreferencesSettings.svelte +80 -0
- package/dist/components/admin/PreferencesSettings.svelte.d.ts +20 -0
- package/dist/components/admin/PreferencesSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/ResetPasswordView.svelte +117 -0
- package/dist/components/admin/ResetPasswordView.svelte.d.ts +9 -0
- package/dist/components/admin/ResetPasswordView.svelte.d.ts.map +1 -0
- package/dist/components/admin/RolesSettings.svelte +360 -0
- package/dist/components/admin/RolesSettings.svelte.d.ts +11 -0
- package/dist/components/admin/RolesSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/SchemaField.svelte +12 -2
- package/dist/components/admin/SchemaField.svelte.d.ts.map +1 -1
- package/dist/components/admin/SettingsHeaderActions.svelte +25 -0
- package/dist/components/admin/SettingsHeaderActions.svelte.d.ts +8 -0
- package/dist/components/admin/SettingsHeaderActions.svelte.d.ts.map +1 -0
- package/dist/components/admin/SettingsShell.svelte +136 -0
- package/dist/components/admin/SettingsShell.svelte.d.ts +9 -0
- package/dist/components/admin/SettingsShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte +377 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts +11 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts.map +1 -0
- package/dist/components/admin/TwoFactorSettings.svelte +436 -0
- package/dist/components/admin/TwoFactorSettings.svelte.d.ts +7 -0
- package/dist/components/admin/TwoFactorSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ImageField.svelte +4 -2
- package/dist/components/admin/fields/SlugField.svelte +3 -1
- package/dist/components/admin/fields/SlugField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/richtext/PortableTextImageView.svelte +3 -2
- package/dist/components/admin/fields/richtext/RichtextField.svelte +54 -7
- package/dist/components/admin/fields/richtext/RichtextField.svelte.d.ts.map +1 -1
- package/dist/components/layout/sidebar/NavUser.svelte +2 -2
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/db/interfaces/document.d.ts +15 -2
- package/dist/db/interfaces/document.d.ts.map +1 -1
- package/dist/db/interfaces/index.d.ts +1 -1
- package/dist/db/interfaces/index.d.ts.map +1 -1
- package/dist/email/index.d.ts +1 -0
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +2 -0
- package/dist/email/interfaces/email.d.ts +2 -0
- package/dist/email/interfaces/email.d.ts.map +1 -1
- package/dist/email/link-email.d.ts +15 -0
- package/dist/email/link-email.d.ts.map +1 -0
- package/dist/email/link-email.js +30 -0
- package/dist/field-validation/date-utils.d.ts.map +1 -1
- package/dist/field-validation/date-utils.js +4 -2
- package/dist/field-validation/utils.d.ts +42 -2
- package/dist/field-validation/utils.d.ts.map +1 -1
- package/dist/field-validation/utils.js +176 -14
- package/dist/graphql/index.d.ts.map +1 -1
- package/dist/graphql/index.js +1 -1
- package/dist/hooks.d.ts +6 -3
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +53 -17
- package/dist/jobs/recurring.d.ts +4 -1
- package/dist/jobs/recurring.d.ts.map +1 -1
- package/dist/jobs/recurring.js +28 -0
- package/dist/local-api/auth-helpers.d.ts +4 -4
- package/dist/local-api/auth-helpers.js +4 -4
- package/dist/local-api/collection-api.d.ts +10 -1
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +40 -12
- package/dist/local-api/index.d.ts +1 -1
- package/dist/local-api/index.d.ts.map +1 -1
- package/dist/local-api/index.js +12 -6
- package/dist/local-api/types.d.ts +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +3 -1
- package/dist/preview/perspective.d.ts +1 -1
- package/dist/preview/perspective.js +1 -1
- package/dist/resolve-config.d.ts +22 -0
- package/dist/resolve-config.d.ts.map +1 -0
- package/dist/resolve-config.js +106 -0
- package/dist/routes/assets-cdn.d.ts +7 -2
- package/dist/routes/assets-cdn.d.ts.map +1 -1
- package/dist/routes/assets-cdn.js +11 -5
- package/dist/server/api/index.d.ts +1 -2
- package/dist/server/api/index.d.ts.map +1 -1
- package/dist/server/api/index.js +12 -3
- package/dist/server/api/openapi/registry.d.ts.map +1 -1
- package/dist/server/api/openapi/registry.js +70 -0
- package/dist/server/api/routes/api-keys.d.ts +4 -0
- package/dist/server/api/routes/api-keys.d.ts.map +1 -0
- package/dist/server/api/routes/api-keys.js +88 -0
- package/dist/server/api/routes/documents-by-id.d.ts.map +1 -1
- package/dist/server/api/routes/documents-by-id.js +16 -1
- package/dist/server/api/routes/documents-publish.d.ts.map +1 -1
- package/dist/server/api/routes/documents-publish.js +11 -1
- package/dist/server/api/routes/documents.d.ts.map +1 -1
- package/dist/server/api/routes/documents.js +16 -2
- package/dist/server/api/routes/instance-settings.d.ts +4 -0
- package/dist/server/api/routes/instance-settings.d.ts.map +1 -0
- package/dist/server/api/routes/instance-settings.js +47 -0
- package/dist/server/api/routes/invitations.d.ts +9 -0
- package/dist/server/api/routes/invitations.d.ts.map +1 -0
- package/dist/server/api/routes/invitations.js +79 -0
- package/dist/server/api/routes/organizations-invitations.d.ts +0 -6
- package/dist/server/api/routes/organizations-invitations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations-invitations.js +6 -7
- package/dist/server/api/routes/organizations-team.d.ts +14 -0
- package/dist/server/api/routes/organizations-team.d.ts.map +1 -0
- package/dist/server/api/routes/organizations-team.js +36 -0
- package/dist/server/api/routes/organizations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations.js +35 -9
- package/dist/server/core-routes.d.ts +8 -0
- package/dist/server/core-routes.d.ts.map +1 -0
- package/dist/server/core-routes.js +67 -0
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +7 -1
- package/dist/server/pages/admin.d.ts +24 -0
- package/dist/server/pages/admin.d.ts.map +1 -0
- package/dist/server/pages/admin.js +468 -0
- package/dist/server/queries/organization-team.d.ts +14 -0
- package/dist/server/queries/organization-team.d.ts.map +1 -0
- package/dist/server/queries/organization-team.js +65 -0
- package/dist/server/queries/pending-invitations.d.ts +8 -0
- package/dist/server/queries/pending-invitations.d.ts.map +1 -0
- package/dist/server/queries/pending-invitations.js +24 -0
- package/dist/types/api-key.d.ts +18 -0
- package/dist/types/api-key.d.ts.map +1 -0
- package/dist/types/api-key.js +1 -0
- package/dist/types/auth.d.ts +35 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/capabilities.d.ts +1 -2
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/config.d.ts +124 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/filters.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/organization.d.ts +30 -0
- package/dist/types/organization.d.ts.map +1 -1
- package/dist/utils/preview.d.ts +8 -1
- package/dist/utils/preview.d.ts.map +1 -1
- package/dist/utils/preview.js +35 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +46 -39
- package/package.json +19 -29
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { goto, invalidateAll } from '$app/navigation';
|
|
3
|
+
import { Button } from '@aphexcms/ui/shadcn/button';
|
|
4
|
+
import { Input } from '@aphexcms/ui/shadcn/input';
|
|
5
|
+
import { Label } from '@aphexcms/ui/shadcn/label';
|
|
6
|
+
import * as Dialog from '@aphexcms/ui/shadcn/dialog';
|
|
7
|
+
import { organizations } from '../../api/organizations';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
startOpen = false,
|
|
11
|
+
parentOption = null
|
|
12
|
+
}: { startOpen?: boolean; parentOption?: { id: string; name: string } | null } = $props();
|
|
13
|
+
|
|
14
|
+
// The organization switcher links here with `?action=create`. Only the first value
|
|
15
|
+
// counts: after that the dialog's own open and close state decides.
|
|
16
|
+
// svelte-ignore state_referenced_locally
|
|
17
|
+
let open = $state(startOpen);
|
|
18
|
+
let name = $state('');
|
|
19
|
+
let insideParent = $state(false);
|
|
20
|
+
let slug = $state('');
|
|
21
|
+
let isSubmitting = $state(false);
|
|
22
|
+
let error = $state<string | null>(null);
|
|
23
|
+
|
|
24
|
+
function generateSlug(text: string): string {
|
|
25
|
+
return text
|
|
26
|
+
.toLowerCase()
|
|
27
|
+
.trim()
|
|
28
|
+
.replace(/[^\w\s-]/g, '')
|
|
29
|
+
.replace(/[\s_-]+/g, '-')
|
|
30
|
+
.replace(/^-+|-+$/g, '');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function handleNameInput(event: Event) {
|
|
34
|
+
const target = event.target as HTMLInputElement;
|
|
35
|
+
name = target.value;
|
|
36
|
+
if (!slug || slug === generateSlug(name.slice(0, -1))) {
|
|
37
|
+
slug = generateSlug(name);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function handleSlugInput(event: Event) {
|
|
42
|
+
const target = event.target as HTMLInputElement;
|
|
43
|
+
slug = target.value.toLowerCase().replace(/[^a-z0-9-]/g, '');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function resetForm() {
|
|
47
|
+
name = '';
|
|
48
|
+
slug = '';
|
|
49
|
+
insideParent = false;
|
|
50
|
+
error = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function handleSubmit(event: Event) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
error = null;
|
|
56
|
+
|
|
57
|
+
if (!name.trim() || !slug.trim()) {
|
|
58
|
+
error = 'Name and slug are required';
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
isSubmitting = true;
|
|
63
|
+
try {
|
|
64
|
+
const result = await organizations.create({
|
|
65
|
+
name: name.trim(),
|
|
66
|
+
slug: slug.trim(),
|
|
67
|
+
...(insideParent && parentOption ? { parentOrganizationId: parentOption.id } : {})
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (!result.success || !result.data) {
|
|
71
|
+
throw new Error('Failed to create organization');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
resetForm();
|
|
75
|
+
open = false;
|
|
76
|
+
await invalidateAll();
|
|
77
|
+
await goto(`/admin?orgId=${result.data.id}`);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
error = err instanceof Error ? err.message : 'Failed to create organization';
|
|
80
|
+
} finally {
|
|
81
|
+
isSubmitting = false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<Dialog.Root bind:open onOpenChange={(v) => !v && resetForm()}>
|
|
87
|
+
<Dialog.Trigger>
|
|
88
|
+
{#snippet child({ props })}
|
|
89
|
+
<Button {...props}>Create Organization</Button>
|
|
90
|
+
{/snippet}
|
|
91
|
+
</Dialog.Trigger>
|
|
92
|
+
<Dialog.Content class="sm:max-w-[480px]">
|
|
93
|
+
<Dialog.Header>
|
|
94
|
+
<Dialog.Title>Create Organization</Dialog.Title>
|
|
95
|
+
<Dialog.Description>You'll be its owner, and can invite people to it.</Dialog.Description>
|
|
96
|
+
</Dialog.Header>
|
|
97
|
+
<form onsubmit={handleSubmit} class="grid gap-4 py-4">
|
|
98
|
+
<div>
|
|
99
|
+
<Label for="org-name">Organization name</Label>
|
|
100
|
+
<Input
|
|
101
|
+
id="org-name"
|
|
102
|
+
value={name}
|
|
103
|
+
oninput={handleNameInput}
|
|
104
|
+
placeholder="My Organization"
|
|
105
|
+
disabled={isSubmitting}
|
|
106
|
+
class="mt-1"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
<div>
|
|
110
|
+
<Label for="org-slug">Slug</Label>
|
|
111
|
+
<div class="mt-1 flex gap-2">
|
|
112
|
+
<Input
|
|
113
|
+
id="org-slug"
|
|
114
|
+
value={slug}
|
|
115
|
+
oninput={handleSlugInput}
|
|
116
|
+
placeholder="my-organization"
|
|
117
|
+
disabled={isSubmitting}
|
|
118
|
+
class="flex-1"
|
|
119
|
+
/>
|
|
120
|
+
<Button
|
|
121
|
+
type="button"
|
|
122
|
+
variant="outline"
|
|
123
|
+
size="sm"
|
|
124
|
+
onclick={() => (slug = generateSlug(name))}
|
|
125
|
+
disabled={!name.trim() || isSubmitting}
|
|
126
|
+
>
|
|
127
|
+
Generate
|
|
128
|
+
</Button>
|
|
129
|
+
</div>
|
|
130
|
+
<p class="text-muted-foreground mt-1 text-xs">
|
|
131
|
+
Lowercase letters, numbers, and hyphens only.
|
|
132
|
+
</p>
|
|
133
|
+
</div>
|
|
134
|
+
{#if parentOption}
|
|
135
|
+
<label class="flex items-center gap-2 text-sm">
|
|
136
|
+
<input type="checkbox" bind:checked={insideParent} disabled={isSubmitting} />
|
|
137
|
+
Create inside {parentOption.name}
|
|
138
|
+
</label>
|
|
139
|
+
{/if}
|
|
140
|
+
{#if error}
|
|
141
|
+
<p class="text-destructive text-sm">{error}</p>
|
|
142
|
+
{/if}
|
|
143
|
+
<Dialog.Footer>
|
|
144
|
+
<Button
|
|
145
|
+
type="button"
|
|
146
|
+
variant="outline"
|
|
147
|
+
onclick={() => (open = false)}
|
|
148
|
+
disabled={isSubmitting}
|
|
149
|
+
>
|
|
150
|
+
Cancel
|
|
151
|
+
</Button>
|
|
152
|
+
<Button type="submit" disabled={isSubmitting || !name.trim()}>
|
|
153
|
+
{isSubmitting ? 'Creating...' : 'Create'}
|
|
154
|
+
</Button>
|
|
155
|
+
</Dialog.Footer>
|
|
156
|
+
</form>
|
|
157
|
+
</Dialog.Content>
|
|
158
|
+
</Dialog.Root>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
startOpen?: boolean;
|
|
3
|
+
parentOption?: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
} | null;
|
|
7
|
+
};
|
|
8
|
+
declare const CreateOrganization: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type CreateOrganization = ReturnType<typeof CreateOrganization>;
|
|
10
|
+
export default CreateOrganization;
|
|
11
|
+
//# sourceMappingURL=CreateOrganization.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateOrganization.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/CreateOrganization.svelte.ts"],"names":[],"mappings":"AAUC,KAAK,gBAAgB,GAAI;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,CAAC;AAyItG,QAAA,MAAM,kBAAkB,sDAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button } from '@aphexcms/ui/shadcn/button';
|
|
3
|
+
import { Label } from '@aphexcms/ui/shadcn/label';
|
|
4
|
+
import { Input } from '@aphexcms/ui/shadcn/input';
|
|
5
|
+
import * as Card from '@aphexcms/ui/shadcn/card';
|
|
6
|
+
import * as Dialog from '@aphexcms/ui/shadcn/dialog';
|
|
7
|
+
import { toast } from 'svelte-sonner';
|
|
8
|
+
import { goto } from '$app/navigation';
|
|
9
|
+
import PasswordInput from './PasswordInput.svelte';
|
|
10
|
+
import { useAdminAuthClient } from '../../admin/client-auth.svelte';
|
|
11
|
+
|
|
12
|
+
type Props = { email: string };
|
|
13
|
+
let { email }: Props = $props();
|
|
14
|
+
|
|
15
|
+
const auth = useAdminAuthClient();
|
|
16
|
+
|
|
17
|
+
let open = $state(false);
|
|
18
|
+
let confirmation = $state('');
|
|
19
|
+
let password = $state('');
|
|
20
|
+
let isDeleting = $state(false);
|
|
21
|
+
|
|
22
|
+
// Typing the address is the whole safeguard: it's the one field that can't be
|
|
23
|
+
// satisfied by clicking through, which is how an irreversible action gets taken
|
|
24
|
+
// by accident. The password is proof of identity, not of intent — a borrowed
|
|
25
|
+
// session has the button but not the words.
|
|
26
|
+
const canDelete = $derived(confirmation.trim().toLowerCase() === email.toLowerCase());
|
|
27
|
+
|
|
28
|
+
function onOpenChange(next: boolean) {
|
|
29
|
+
// Refuse to close mid-request; the dialog is the only thing reporting progress.
|
|
30
|
+
if (isDeleting) return;
|
|
31
|
+
open = next;
|
|
32
|
+
if (!next) {
|
|
33
|
+
confirmation = '';
|
|
34
|
+
password = '';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function deleteAccount() {
|
|
39
|
+
if (!canDelete || isDeleting) return;
|
|
40
|
+
if (!auth) {
|
|
41
|
+
toast.error('Account deletion is unavailable');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
isDeleting = true;
|
|
46
|
+
try {
|
|
47
|
+
const result = await auth.deleteUser({ password });
|
|
48
|
+
if (result.error) {
|
|
49
|
+
// The server refuses when you're the last owner of an organization that
|
|
50
|
+
// still has members — surface its message rather than a generic failure,
|
|
51
|
+
// because it names what to fix.
|
|
52
|
+
throw new Error(result.error.message || 'Could not delete your account');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Straight out, no toast: the session is gone and the admin shell would only
|
|
56
|
+
// render a flash of a workspace this account no longer belongs to.
|
|
57
|
+
await goto('/admin/login?deleted=1');
|
|
58
|
+
} catch (error) {
|
|
59
|
+
toast.error(error instanceof Error ? error.message : 'Could not delete your account');
|
|
60
|
+
isDeleting = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<Card.Root class="border-destructive/40">
|
|
66
|
+
<Card.Content class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
|
67
|
+
<div class="space-y-1">
|
|
68
|
+
<p class="text-sm font-medium">Delete account</p>
|
|
69
|
+
<p class="text-muted-foreground max-w-prose text-sm">
|
|
70
|
+
Permanently deletes your account, your profile picture, and your membership of every
|
|
71
|
+
workspace. Content you created stays where it is. This can't be undone.
|
|
72
|
+
</p>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<Button variant="destructive" class="shrink-0" onclick={() => (open = true)} disabled={!auth}>
|
|
76
|
+
Delete account
|
|
77
|
+
</Button>
|
|
78
|
+
</Card.Content>
|
|
79
|
+
</Card.Root>
|
|
80
|
+
|
|
81
|
+
<Dialog.Root {open} {onOpenChange}>
|
|
82
|
+
<Dialog.Content class="sm:max-w-md">
|
|
83
|
+
<Dialog.Header>
|
|
84
|
+
<Dialog.Title>Delete your account?</Dialog.Title>
|
|
85
|
+
<Dialog.Description>
|
|
86
|
+
This is permanent. Your profile and profile picture are erased and you're removed from every
|
|
87
|
+
workspace you belong to.
|
|
88
|
+
</Dialog.Description>
|
|
89
|
+
</Dialog.Header>
|
|
90
|
+
|
|
91
|
+
<div class="grid gap-4 py-2">
|
|
92
|
+
<div class="grid gap-2">
|
|
93
|
+
<Label for="delete-confirmation">
|
|
94
|
+
Type <span class="font-mono font-medium">{email}</span> to confirm
|
|
95
|
+
</Label>
|
|
96
|
+
<Input
|
|
97
|
+
id="delete-confirmation"
|
|
98
|
+
bind:value={confirmation}
|
|
99
|
+
autocomplete="off"
|
|
100
|
+
disabled={isDeleting}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<div class="grid gap-2">
|
|
105
|
+
<Label for="delete-password">Your password</Label>
|
|
106
|
+
<PasswordInput
|
|
107
|
+
id="delete-password"
|
|
108
|
+
bind:value={password}
|
|
109
|
+
autocomplete="current-password"
|
|
110
|
+
disabled={isDeleting}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<Dialog.Footer>
|
|
116
|
+
<Button variant="outline" onclick={() => onOpenChange(false)} disabled={isDeleting}>
|
|
117
|
+
Cancel
|
|
118
|
+
</Button>
|
|
119
|
+
<Button variant="destructive" onclick={deleteAccount} disabled={!canDelete || isDeleting}>
|
|
120
|
+
{isDeleting ? 'Deleting…' : 'Delete account'}
|
|
121
|
+
</Button>
|
|
122
|
+
</Dialog.Footer>
|
|
123
|
+
</Dialog.Content>
|
|
124
|
+
</Dialog.Root>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
email: string;
|
|
3
|
+
};
|
|
4
|
+
declare const DeleteAccountSettings: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type DeleteAccountSettings = ReturnType<typeof DeleteAccountSettings>;
|
|
6
|
+
export default DeleteAccountSettings;
|
|
7
|
+
//# sourceMappingURL=DeleteAccountSettings.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteAccountSettings.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/DeleteAccountSettings.svelte.ts"],"names":[],"mappings":"AAcC,KAAK,KAAK,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAqHhC,QAAA,MAAM,qBAAqB,2CAAwC,CAAC;AACpE,KAAK,qBAAqB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACtE,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Danger-zone card for deleting the active organization. Core-owned. Member
|
|
4
|
+
* count arrives as a prop (no join); the server re-enforces that only an owner
|
|
5
|
+
* may delete and refuses to strand members.
|
|
6
|
+
*/
|
|
7
|
+
import { Button } from '@aphexcms/ui/shadcn/button';
|
|
8
|
+
import { Label } from '@aphexcms/ui/shadcn/label';
|
|
9
|
+
import { Input } from '@aphexcms/ui/shadcn/input';
|
|
10
|
+
import * as Card from '@aphexcms/ui/shadcn/card';
|
|
11
|
+
import * as Dialog from '@aphexcms/ui/shadcn/dialog';
|
|
12
|
+
import { toast } from 'svelte-sonner';
|
|
13
|
+
import { goto } from '$app/navigation';
|
|
14
|
+
import { organizations } from '../../api';
|
|
15
|
+
import type { Organization } from '../../types/organization';
|
|
16
|
+
|
|
17
|
+
type Props = {
|
|
18
|
+
organization: Organization;
|
|
19
|
+
memberCount: number;
|
|
20
|
+
/** Only owners may delete; the server enforces this too. */
|
|
21
|
+
canDelete: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
let { organization, memberCount, canDelete }: Props = $props();
|
|
25
|
+
|
|
26
|
+
let open = $state(false);
|
|
27
|
+
let confirmation = $state('');
|
|
28
|
+
let isDeleting = $state(false);
|
|
29
|
+
|
|
30
|
+
const confirmed = $derived(confirmation.trim() === organization.name);
|
|
31
|
+
|
|
32
|
+
function onOpenChange(next: boolean) {
|
|
33
|
+
if (isDeleting) return;
|
|
34
|
+
open = next;
|
|
35
|
+
if (!next) confirmation = '';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function deleteOrganization() {
|
|
39
|
+
if (!confirmed || isDeleting) return;
|
|
40
|
+
|
|
41
|
+
// Read before navigating. Props read through to the page data, and once the
|
|
42
|
+
// navigation lands on /admin that data has no `organization`, so reading
|
|
43
|
+
// `organization.name` afterwards throws even though the delete worked.
|
|
44
|
+
const { id, name } = organization;
|
|
45
|
+
isDeleting = true;
|
|
46
|
+
try {
|
|
47
|
+
const result = await organizations.remove(id);
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
throw new Error(result.error || result.message || 'Could not delete this workspace');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The server moves everyone still signed in onto another workspace, or clears
|
|
53
|
+
// their active one. Reload from the server rather than patching local state —
|
|
54
|
+
// which workspace you land in is its decision, not something to guess at here.
|
|
55
|
+
await goto('/admin', { invalidateAll: true });
|
|
56
|
+
toast.success(`${name} was deleted`);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
toast.error(error instanceof Error ? error.message : 'Could not delete this workspace');
|
|
59
|
+
isDeleting = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<Card.Root class="border-destructive/40">
|
|
65
|
+
<Card.Content class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
|
66
|
+
<div class="space-y-1">
|
|
67
|
+
<p class="text-sm font-medium">Delete workspace</p>
|
|
68
|
+
<p class="text-muted-foreground max-w-prose text-sm">
|
|
69
|
+
Permanently deletes <span class="font-medium">{organization.name}</span> along with every document,
|
|
70
|
+
uploaded file, role and invitation in it. This can't be undone.
|
|
71
|
+
</p>
|
|
72
|
+
{#if !canDelete}
|
|
73
|
+
<p class="text-muted-foreground text-sm">Only owners can delete a workspace.</p>
|
|
74
|
+
{/if}
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<Button
|
|
78
|
+
variant="destructive"
|
|
79
|
+
class="shrink-0"
|
|
80
|
+
disabled={!canDelete}
|
|
81
|
+
onclick={() => (open = true)}
|
|
82
|
+
>
|
|
83
|
+
Delete workspace
|
|
84
|
+
</Button>
|
|
85
|
+
</Card.Content>
|
|
86
|
+
</Card.Root>
|
|
87
|
+
|
|
88
|
+
<Dialog.Root {open} {onOpenChange}>
|
|
89
|
+
<Dialog.Content class="sm:max-w-md">
|
|
90
|
+
<Dialog.Header>
|
|
91
|
+
<Dialog.Title>Delete {organization.name}?</Dialog.Title>
|
|
92
|
+
<Dialog.Description>
|
|
93
|
+
Every document, uploaded file, role and invitation in this workspace is erased, and
|
|
94
|
+
{memberCount === 1 ? 'its member is' : `all ${memberCount} members are`} removed. This is permanent.
|
|
95
|
+
</Dialog.Description>
|
|
96
|
+
</Dialog.Header>
|
|
97
|
+
|
|
98
|
+
<div class="grid gap-2 py-2">
|
|
99
|
+
<Label for="delete-org-confirmation">
|
|
100
|
+
Type <span class="font-mono font-medium">{organization.name}</span> to confirm
|
|
101
|
+
</Label>
|
|
102
|
+
<Input
|
|
103
|
+
id="delete-org-confirmation"
|
|
104
|
+
bind:value={confirmation}
|
|
105
|
+
autocomplete="off"
|
|
106
|
+
disabled={isDeleting}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<Dialog.Footer>
|
|
111
|
+
<Button variant="outline" onclick={() => onOpenChange(false)} disabled={isDeleting}>
|
|
112
|
+
Cancel
|
|
113
|
+
</Button>
|
|
114
|
+
<Button
|
|
115
|
+
variant="destructive"
|
|
116
|
+
onclick={deleteOrganization}
|
|
117
|
+
disabled={!confirmed || isDeleting}
|
|
118
|
+
>
|
|
119
|
+
{isDeleting ? 'Deleting…' : 'Delete workspace'}
|
|
120
|
+
</Button>
|
|
121
|
+
</Dialog.Footer>
|
|
122
|
+
</Dialog.Content>
|
|
123
|
+
</Dialog.Root>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Organization } from '../../types/organization.js';
|
|
2
|
+
type Props = {
|
|
3
|
+
organization: Organization;
|
|
4
|
+
memberCount: number;
|
|
5
|
+
/** Only owners may delete; the server enforces this too. */
|
|
6
|
+
canDelete: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const DeleteOrganizationSettings: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type DeleteOrganizationSettings = ReturnType<typeof DeleteOrganizationSettings>;
|
|
10
|
+
export default DeleteOrganizationSettings;
|
|
11
|
+
//# sourceMappingURL=DeleteOrganizationSettings.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeleteOrganizationSettings.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/DeleteOrganizationSettings.svelte.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG5D,KAAK,KAAK,GAAG;IACZ,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,SAAS,EAAE,OAAO,CAAC;CACnB,CAAC;AAuGH,QAAA,MAAM,0BAA0B,2CAAwC,CAAC;AACzE,KAAK,0BAA0B,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAChF,eAAe,0BAA0B,CAAC"}
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
import { findOrphanedFields, type OrphanedField } from '../../schema-utils/cleanup';
|
|
10
10
|
import type { SchemaType } from '../../types/schemas.js';
|
|
11
11
|
import { Rule } from '../../field-validation/rule';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
humanizeValidationMessage,
|
|
14
|
+
validateDocumentData,
|
|
15
|
+
type FieldErrors
|
|
16
|
+
} from '../../field-validation/utils';
|
|
13
17
|
import { hasUnpublishedChanges } from '../../utils/content-hash';
|
|
14
18
|
import { setSchemaContext } from '../../schema-context.svelte';
|
|
15
19
|
import { setSaveStateContext } from '../../save-state-context.svelte';
|
|
@@ -1051,7 +1055,10 @@
|
|
|
1051
1055
|
|
|
1052
1056
|
let orphanedFields = $state<OrphanedField[]>([]);
|
|
1053
1057
|
let showOrphanedFields = $state(false);
|
|
1054
|
-
|
|
1058
|
+
// Field components by name, so validation results can be pushed into them
|
|
1059
|
+
// after a load/autosave. Keyed by name rather than index: only the active
|
|
1060
|
+
// group's fields are rendered, so positions never line up with schema.fields.
|
|
1061
|
+
let schemaFields: Record<string, SchemaField | undefined> = $state({});
|
|
1055
1062
|
|
|
1056
1063
|
// Track previous document to detect actual switches (not create→edit transitions)
|
|
1057
1064
|
// Plain lets (not $state) — only read/written inside the clearing effect; no need for reactivity
|
|
@@ -1235,14 +1242,14 @@
|
|
|
1235
1242
|
cmsLogger.debug('[Document Editor]', '📄 Keys in documentData:', Object.keys(documentData));
|
|
1236
1243
|
hasUnsavedChanges = false; // Just loaded, so no unsaved changes
|
|
1237
1244
|
|
|
1238
|
-
// Run validation on loaded document to show any existing errors
|
|
1245
|
+
// Run validation on loaded document to show any existing errors, and
|
|
1246
|
+
// settle hasValidationErrors now rather than after the first autosave —
|
|
1247
|
+
// otherwise Publish is enabled after a refresh until it's clicked.
|
|
1239
1248
|
await tick(); // Wait for DOM to update with new data
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1245
|
-
});
|
|
1249
|
+
for (const [name, fieldComponent] of Object.entries(schemaFields)) {
|
|
1250
|
+
fieldComponent?.performValidation(documentData[name], documentData);
|
|
1251
|
+
}
|
|
1252
|
+
validateAllFields();
|
|
1246
1253
|
} else {
|
|
1247
1254
|
cmsLogger.debug('[Document Editor]', '❌ Failed to load document data:', response.error);
|
|
1248
1255
|
saveError = response.error || 'Failed to load document';
|
|
@@ -1458,12 +1465,11 @@
|
|
|
1458
1465
|
'Conflict: this document was updated by someone else. Reload the page to continue editing.'
|
|
1459
1466
|
};
|
|
1460
1467
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
return { success: false, error: `Validation failed: ${errorMessages}` };
|
|
1468
|
+
// The server calls this `issues`. `validationErrors` was never sent, so a
|
|
1469
|
+
// rejected save used to show its raw technical message.
|
|
1470
|
+
const issues = responseIssues(err);
|
|
1471
|
+
if (issues.length > 0) {
|
|
1472
|
+
return { success: false, error: `Couldn't save. ${describeIssues(issues).join(' ')}` };
|
|
1467
1473
|
}
|
|
1468
1474
|
return {
|
|
1469
1475
|
success: false,
|
|
@@ -1496,12 +1502,10 @@
|
|
|
1496
1502
|
if (isAutoSave) {
|
|
1497
1503
|
// Trigger validation on all fields after auto-save
|
|
1498
1504
|
validateAllFields(); // Update validation status
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1504
|
-
}); // Notify parent of autosave with current title
|
|
1505
|
+
for (const [name, fieldComponent] of Object.entries(schemaFields)) {
|
|
1506
|
+
fieldComponent?.performValidation(documentData[name], documentData);
|
|
1507
|
+
}
|
|
1508
|
+
// Notify parent of autosave with current title
|
|
1505
1509
|
if (onAutoSaved && documentId) {
|
|
1506
1510
|
onAutoSaved(documentId, getPreviewTitle());
|
|
1507
1511
|
}
|
|
@@ -1536,8 +1540,15 @@
|
|
|
1536
1540
|
if (saveError) return;
|
|
1537
1541
|
}
|
|
1538
1542
|
|
|
1539
|
-
// Check for validation errors before publishing (Sanity-style)
|
|
1540
|
-
|
|
1543
|
+
// Check for validation errors before publishing (Sanity-style).
|
|
1544
|
+
// validateAllFields stays top-level because it drives the Publish button:
|
|
1545
|
+
// counting nested problems there would grey the button out with nothing on
|
|
1546
|
+
// screen saying why. This also runs the validator the server is about to
|
|
1547
|
+
// run, so a problem deep inside a block is named here instead of rejected.
|
|
1548
|
+
const topLevel = await validateAllFields();
|
|
1549
|
+
const deep = await findPublishProblems();
|
|
1550
|
+
const invalid: Array<{ title: string; messages: string[]; detailed?: boolean }> =
|
|
1551
|
+
deep.length > 0 ? deep : topLevel;
|
|
1541
1552
|
|
|
1542
1553
|
if (invalid.length > 0) {
|
|
1543
1554
|
// Show up to three field titles in the toast so the user doesn't
|
|
@@ -1547,11 +1558,16 @@
|
|
|
1547
1558
|
.map((f) => f.title)
|
|
1548
1559
|
.join(', ');
|
|
1549
1560
|
const remainder = invalid.length > 3 ? ` and ${invalid.length - 3} more` : '';
|
|
1550
|
-
const
|
|
1561
|
+
const lines = invalid.flatMap((f) =>
|
|
1562
|
+
f.messages.map((m) => (f.detailed ? m : `${f.title}: ${m}`))
|
|
1563
|
+
);
|
|
1564
|
+
const shown = lines.slice(0, 5);
|
|
1565
|
+
if (lines.length > shown.length) shown.push(`And ${lines.length - shown.length} more.`);
|
|
1551
1566
|
|
|
1552
|
-
saveError = `
|
|
1553
|
-
toast.error(`Fix ${
|
|
1554
|
-
description:
|
|
1567
|
+
saveError = `Can't publish yet. Check: ${preview}${remainder}`;
|
|
1568
|
+
toast.error(`Fix ${lines.length} thing${lines.length === 1 ? '' : 's'} to publish`, {
|
|
1569
|
+
description: shown.join('\n'),
|
|
1570
|
+
duration: 15000
|
|
1555
1571
|
});
|
|
1556
1572
|
return;
|
|
1557
1573
|
}
|
|
@@ -1634,17 +1650,17 @@
|
|
|
1634
1650
|
saveError =
|
|
1635
1651
|
'Conflict: this document was updated by someone else. Reload the page to continue editing.';
|
|
1636
1652
|
} else {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
saveError = `Cannot publish - Validation failed: ${errorMessages}`;
|
|
1653
|
+
const issues = responseIssues(err);
|
|
1654
|
+
if (issues.length > 0) {
|
|
1655
|
+
const lines = describeIssues(issues);
|
|
1656
|
+
saveError = `Can't publish yet. ${lines.join(' ')}`;
|
|
1657
|
+
toast.error(`Fix ${lines.length} thing${lines.length === 1 ? '' : 's'} to publish`, {
|
|
1658
|
+
description: lines.slice(0, 5).join('\n'),
|
|
1659
|
+
duration: 15000
|
|
1660
|
+
});
|
|
1646
1661
|
} else {
|
|
1647
1662
|
saveError = err instanceof ApiError ? err.message : 'Failed to publish document';
|
|
1663
|
+
toast.error(saveError);
|
|
1648
1664
|
}
|
|
1649
1665
|
}
|
|
1650
1666
|
} finally {
|
|
@@ -1735,6 +1751,61 @@
|
|
|
1735
1751
|
}
|
|
1736
1752
|
}
|
|
1737
1753
|
|
|
1754
|
+
type ReportedIssue = { field: string; path?: string; errors: string[] };
|
|
1755
|
+
|
|
1756
|
+
/** The `issues` a rejected save or publish carries, if the response has them. */
|
|
1757
|
+
function responseIssues(err: unknown): ReportedIssue[] {
|
|
1758
|
+
const issues: unknown = err instanceof ApiError ? err.response?.issues : undefined;
|
|
1759
|
+
if (!Array.isArray(issues)) return [];
|
|
1760
|
+
return issues.filter(
|
|
1761
|
+
(issue): issue is ReportedIssue =>
|
|
1762
|
+
typeof issue === 'object' &&
|
|
1763
|
+
issue !== null &&
|
|
1764
|
+
typeof issue.field === 'string' &&
|
|
1765
|
+
Array.isArray(issue.errors) &&
|
|
1766
|
+
issue.errors.every((message: unknown) => typeof message === 'string')
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
/** Field problems, in words an editor can act on. */
|
|
1771
|
+
function describeIssues(issues: Array<ReportedIssue | FieldErrors>): string[] {
|
|
1772
|
+
return issues.flatMap((issue) => {
|
|
1773
|
+
const field = schema?.fields.find((f) => f.name === issue.field);
|
|
1774
|
+
const path = 'path' in issue ? issue.path : undefined;
|
|
1775
|
+
return issue.errors.map((message) =>
|
|
1776
|
+
humanizeValidationMessage(path ? `Field "${path}" ${message}` : message, {
|
|
1777
|
+
field,
|
|
1778
|
+
fieldName: issue.field,
|
|
1779
|
+
value: documentData[issue.field],
|
|
1780
|
+
schemas,
|
|
1781
|
+
includeRoot: true
|
|
1782
|
+
})
|
|
1783
|
+
);
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Everything the server would refuse at publish, nested fields included.
|
|
1789
|
+
* Advisory: if the check itself throws, publish goes ahead and the server
|
|
1790
|
+
* remains the authority.
|
|
1791
|
+
*/
|
|
1792
|
+
async function findPublishProblems(): Promise<
|
|
1793
|
+
Array<{ name: string; title: string; messages: string[]; detailed?: boolean }>
|
|
1794
|
+
> {
|
|
1795
|
+
if (!schema) return [];
|
|
1796
|
+
try {
|
|
1797
|
+
const { errors } = await validateDocumentData(schema, documentData, { schemas });
|
|
1798
|
+
return errors.map((issue) => ({
|
|
1799
|
+
name: issue.field,
|
|
1800
|
+
title: schema?.fields.find((f) => f.name === issue.field)?.title ?? issue.field,
|
|
1801
|
+
messages: describeIssues([issue]),
|
|
1802
|
+
detailed: true
|
|
1803
|
+
}));
|
|
1804
|
+
} catch {
|
|
1805
|
+
return [];
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1738
1809
|
// Validate all fields before publishing
|
|
1739
1810
|
async function validateAllFields(): Promise<
|
|
1740
1811
|
Array<{ name: string; title: string; messages: string[] }>
|
|
@@ -2363,6 +2434,7 @@
|
|
|
2363
2434
|
: ''}"
|
|
2364
2435
|
>
|
|
2365
2436
|
<SchemaField
|
|
2437
|
+
bind:this={schemaFields[field.name]}
|
|
2366
2438
|
{field}
|
|
2367
2439
|
value={viewData[field.name]}
|
|
2368
2440
|
documentData={viewData}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentEditor.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/DocumentEditor.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"DocumentEditor.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/DocumentEditor.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAczD,OAAO,KAAK,EAAE,SAAS,EAAuB,MAAM,qBAAqB,CAAC;AAqCzE,UAAU,KAAK;IACd,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;kDAE8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,oBAAoB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,sBAAsB,CAAC,EAAE;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI,CAAC;IACT,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;kEAI8D;IAC9D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,yGAAyG;IACzG,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACtB;AAwnFF,QAAA,MAAM,cAAc,2CAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
|