fix: repair defects surfaced by gating CI on lint and typecheck

`npm run check` reported 15 errors and `npm run lint` 20, all pre-existing, so
neither gate could pass. Fixing them turned up three real bugs:

- SignOut destructured `{ error }` off `.then(() => {})`, which resolves to
  undefined, so every sign-out threw a TypeError - after the signed-out event had
  already been emitted. Sign-out also left the user on the protected page they
  were on, still showing its content; it now returns them to the home page and
  re-runs the server loads.

- SignUp passed `redirectTo`, which is not a signUp option and was silently
  ignored, so the confirmation link has always used Supabase's configured site
  URL. Documented rather than changed, since pointing it elsewhere needs an
  absolute allow-listed URL.

- The Pokédex page tracked totalRecordsCreated but never passed it to the box
  view, so the "Processed N entries so far" progress message never rendered.

The rest is typing and dead code: cookie callback parameters in hooks.server.ts
and +layout.ts, the untyped supabase props, a query-builder type that made
PostgREST rows untyped downstream, an unused session destructure, and
`while (true)` paging loops rewritten as `for (;;)`.
This commit is contained in:
Josh Creek
2026-09-13 17:36:14 +01:00
parent 92d6460765
commit 3a2c18bbeb
13 changed files with 60 additions and 60 deletions
@@ -4,6 +4,10 @@ import type {
PokedexExportIntegrationDB
} from '$lib/models/PokedexExportIntegration';
// `from()` returns a table builder; only `select()` yields the filter builder that `eq`/`is`
// live on. Typing the scope helper with the table builder made `data` untyped downstream.
type IntegrationQuery = ReturnType<ReturnType<SupabaseClient['from']>['select']>;
class PokedexExportIntegrationRepository {
constructor(
private supabase: SupabaseClient,
@@ -34,7 +38,7 @@ class PokedexExportIntegrationRepository {
return this.supabase.from('pokedex_export_integrations').select('*').eq('userId', this.userId);
}
private addPokedexScope(query: ReturnType<SupabaseClient['from']>) {
private addPokedexScope(query: IntegrationQuery): IntegrationQuery {
if (this.pokedexId) {
return query.eq('pokedexId', this.pokedexId);
}
@@ -49,7 +53,8 @@ class PokedexExportIntegrationRepository {
throw new Error(`Failed to load export integrations: ${error.message}`);
}
if (!data) return [];
return data.map((row) => this.transform(row));
// PostgREST rows are untyped without generated database types.
return (data as PokedexExportIntegrationDB[]).map((row) => this.transform(row));
}
async listAll(): Promise<PokedexExportIntegration[]> {
@@ -60,12 +65,12 @@ class PokedexExportIntegrationRepository {
throw new Error(`Failed to load export integrations: ${error.message}`);
}
if (!data) return [];
return data.map((row) => this.transform(row));
// PostgREST rows are untyped without generated database types.
return (data as PokedexExportIntegrationDB[]).map((row) => this.transform(row));
}
async upsert(
data: Partial<PokedexExportIntegrationDB> &
Pick<PokedexExportIntegrationDB, 'provider'>
data: Partial<PokedexExportIntegrationDB> & Pick<PokedexExportIntegrationDB, 'provider'>
): Promise<PokedexExportIntegration> {
const payload: Partial<PokedexExportIntegrationDB> = {
userId: this.userId,
@@ -105,7 +110,8 @@ class PokedexExportIntegrationRepository {
throw new Error(`Failed to load export integrations: ${error.message}`);
}
if (!data) return [];
return data.map((row) => this.transform(row));
// PostgREST rows are untyped without generated database types.
return (data as PokedexExportIntegrationDB[]).map((row) => this.transform(row));
}
async updateTokens(