fix: resolve all 47 svelte-check errors and 10 a11y warnings
Root cause 1 — OpenAPI types: add @Schema(requiredMode=REQUIRED) to
non-nullable fields on Person, Tag, Document, AppUser, UserGroup;
regenerate api.ts so required fields are no longer optional.
Root cause 2 — Stale types: api.ts regenerated, picking up the Tag
endpoint fix from commit 62189d8 (List<Tag> instead of List<String>).
Root cause 3 — openapi-fetch error pattern: replace `if (apiError)`
(broken when error type is never/undefined) with `if (!result.response.ok)`
across all +page.server.ts files. Cast error via `unknown` to satisfy TS.
Root cause 4 — FormData casts: add `as string` / `as string[]` to
FormData.get() / FormData.getAll() calls in admin/+page.server.ts.
Standalone fixes:
- +page.server.ts: return error field so home page template compiles
- documents/[id]/+page.svelte: type loadFile param, remove invalid iframe `type`
- conversations: type documents as Document[] instead of unknown[]
- persons/[id]: non-null assert person data after ok-check
a11y: aria-label on all icon-only buttons in TagInput and admin page,
replace invalid <label> with <p> for compound controls, remove autofocus.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { getErrorMessage } from '$lib/errors';
|
||||
|
||||
export async function load({ fetch, locals }) {
|
||||
const user = locals.user;
|
||||
const hasAdmin = user?.groups.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN'));
|
||||
const hasAdmin = user?.groups?.some((g: { permissions: string[] }) => g.permissions.includes('ADMIN'));
|
||||
if (!hasAdmin) throw error(403, getErrorMessage('FORBIDDEN'));
|
||||
|
||||
const api = createApiClient(fetch);
|
||||
@@ -27,17 +27,17 @@ export const actions = {
|
||||
const data = await request.formData();
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.POST('/api/users', {
|
||||
const result = await api.POST('/api/users', {
|
||||
body: {
|
||||
username: data.get('username'),
|
||||
initialPassword: data.get('password'),
|
||||
groupIds: data.getAll('groupIds')
|
||||
username: data.get('username') as string,
|
||||
initialPassword: data.get('password') as string,
|
||||
groupIds: data.getAll('groupIds') as string[]
|
||||
}
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -47,13 +47,13 @@ export const actions = {
|
||||
const id = data.get('id') as string;
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.DELETE('/api/users/{id}', {
|
||||
const result = await api.DELETE('/api/users/{id}', {
|
||||
params: { path: { id } }
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -63,14 +63,14 @@ export const actions = {
|
||||
const id = data.get('id') as string;
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.PUT('/api/tags/{id}', {
|
||||
const result = await api.PUT('/api/tags/{id}', {
|
||||
params: { path: { id } },
|
||||
body: { name: data.get('name') }
|
||||
body: { name: data.get('name') as string }
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -80,13 +80,13 @@ export const actions = {
|
||||
const id = data.get('id') as string;
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.DELETE('/api/tags/{id}', {
|
||||
const result = await api.DELETE('/api/tags/{id}', {
|
||||
params: { path: { id } }
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -95,16 +95,16 @@ export const actions = {
|
||||
const data = await request.formData();
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.POST('/api/groups', {
|
||||
const result = await api.POST('/api/groups', {
|
||||
body: {
|
||||
name: data.get('name'),
|
||||
permissions: data.getAll('permissions')
|
||||
name: data.get('name') as string,
|
||||
permissions: data.getAll('permissions') as string[]
|
||||
}
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -114,17 +114,17 @@ export const actions = {
|
||||
const id = data.get('id') as string;
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.PATCH('/api/groups/{id}', {
|
||||
const result = await api.PATCH('/api/groups/{id}', {
|
||||
params: { path: { id } },
|
||||
body: {
|
||||
name: data.get('name'),
|
||||
permissions: data.getAll('permissions')
|
||||
name: data.get('name') as string,
|
||||
permissions: data.getAll('permissions') as string[]
|
||||
}
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
},
|
||||
@@ -134,13 +134,13 @@ export const actions = {
|
||||
const id = data.get('id') as string;
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { error: apiError, response } = await api.DELETE('/api/groups/{id}', {
|
||||
const result = await api.DELETE('/api/groups/{id}', {
|
||||
params: { path: { id } }
|
||||
});
|
||||
|
||||
if (apiError) {
|
||||
const code = (apiError as { code?: string })?.code;
|
||||
return fail(response.status, { success: false, message: getErrorMessage(code) });
|
||||
if (!result.response.ok) {
|
||||
const code = (result.error as unknown as { code?: string })?.code;
|
||||
return fail(result.response.status, { success: false, message: getErrorMessage(code) });
|
||||
}
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -319,9 +319,8 @@
|
||||
name="name"
|
||||
bind:value={editingTagName}
|
||||
class="flex-1 border-brand-mint ring-1 ring-brand-mint rounded px-2 py-1 text-sm"
|
||||
autofocus
|
||||
/>
|
||||
<button class="text-green-600 hover:text-green-800"
|
||||
<button aria-label="Speichern" class="text-green-600 hover:text-green-800"
|
||||
><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
><path
|
||||
stroke-linecap="round"
|
||||
@@ -334,7 +333,8 @@
|
||||
<button
|
||||
type="button"
|
||||
on:click={cancelEditTag}
|
||||
class="text-gray-400 hover:text-gray-600"
|
||||
aria-label="Abbrechen"
|
||||
class="text-gray-400 hover:text-gray-600"
|
||||
><svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
><path
|
||||
stroke-linecap="round"
|
||||
@@ -354,6 +354,7 @@
|
||||
>
|
||||
<button
|
||||
on:click={() => startEditTag(tag)}
|
||||
aria-label="Schlagwort bearbeiten"
|
||||
class="p-1 text-gray-400 hover:text-brand-navy"
|
||||
>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
@@ -386,7 +387,7 @@
|
||||
class="inline"
|
||||
>
|
||||
<input type="hidden" name="id" value={tag.id} />
|
||||
<button class="p-1 text-gray-400 hover:text-red-600">
|
||||
<button aria-label="Schlagwort löschen" class="p-1 text-gray-400 hover:text-red-600">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
><path
|
||||
stroke-linecap="round"
|
||||
@@ -473,7 +474,7 @@
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="flex gap-2 self-start sm:self-center">
|
||||
<button type="submit" class="text-green-600 hover:text-green-800 p-1">
|
||||
<button type="submit" aria-label="Speichern" class="text-green-600 hover:text-green-800 p-1">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
><path
|
||||
stroke-linecap="round"
|
||||
@@ -486,7 +487,8 @@
|
||||
<button
|
||||
type="button"
|
||||
on:click={cancelEditGroup}
|
||||
class="text-gray-400 hover:text-red-500 p-1"
|
||||
aria-label="Abbrechen"
|
||||
class="text-gray-400 hover:text-red-500 p-1"
|
||||
>
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
||||
><path
|
||||
|
||||
Reference in New Issue
Block a user