refactor(admin/invites): regenerate types; remove InviteListItem cast
All checks were successful
CI / Unit & Component Tests (push) Successful in 3m17s
CI / OCR Service Tests (push) Successful in 21s
CI / Backend Unit Tests (push) Successful in 3m24s
CI / fail2ban Regex (push) Successful in 42s
CI / Semgrep Security Scan (push) Successful in 19s
CI / Compose Bucket Idempotency (push) Successful in 1m1s

After adding @Schema(requiredMode=REQUIRED) to InviteListItemDTO.shareableUrl,
npm run generate:api now emits shareableUrl as required. Replace the hand-rolled
InviteListItem interface with a type alias to the generated InviteListItemDTO
and remove the two 'as unknown as InviteListItem' casts + TODO comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #623.
This commit is contained in:
Marcel
2026-05-19 13:22:32 +02:00
committed by marcel
parent 0cd9ea915e
commit 8fc32f18ce
2 changed files with 130 additions and 26 deletions

View File

@@ -4,21 +4,7 @@ import { getErrorMessage } from '$lib/shared/errors';
import type { Actions, PageServerLoad } from './$types';
import type { components } from '$lib/generated/api';
// The spec marks shareableUrl optional but the backend always populates it.
// Keeping the required shape here avoids null-guarding throughout the page component.
export interface InviteListItem {
id: string;
code: string;
displayCode: string;
label?: string;
useCount: number;
maxUses?: number;
expiresAt?: string;
revoked: boolean;
status: string;
createdAt: string;
shareableUrl: string;
}
export type InviteListItem = components['schemas']['InviteListItemDTO'];
export type UserGroup = components['schemas']['UserGroup'];
const VALID_STATUSES = ['ACTIVE', 'REVOKED', 'EXPIRED'] as const;
@@ -42,8 +28,7 @@ export const load: PageServerLoad = async ({ url, fetch }) => {
const code = (invitesResult.error as unknown as { code?: string })?.code;
loadError = code ?? 'INTERNAL_ERROR';
} else {
// TODO: remove cast after next npm run generate:api — shareableUrl is now @Schema(requiredMode=REQUIRED)
invites = (invitesResult.data ?? []) as unknown as InviteListItem[];
invites = (invitesResult.data ?? []) as InviteListItem[];
}
let groups: UserGroup[] = [];
@@ -81,8 +66,7 @@ export const actions = {
return fail(result.response.status, { createError: code ?? 'INTERNAL_ERROR' });
}
// TODO: remove cast after next npm run generate:api — shareableUrl is now @Schema(requiredMode=REQUIRED)
return { created: result.data! as unknown as InviteListItem };
return { created: result.data! as InviteListItem };
},
revoke: async ({ request, fetch }) => {