Skip to content

Commit b61a024

Browse files
committed
fix: resolve all svelte-check errors
- Fix db.execute to use sql tagged template with sql.raw for dynamic column - Replace parent() with locals.session in all portal form actions - Add yivi-css type declaration (src/yivi-css.d.ts) - Use any types for Yivi SDK callback parameters - Cast flag key in admin settings template - Use consistent Record<string, string> for register form errors - Use explicit FormResult interface in register page component 0 errors, 2 warnings (intentional state_referenced_locally)
1 parent 6d93e83 commit b61a024

11 files changed

Lines changed: 41 additions & 30 deletions

File tree

src/lib/components/YiviLogin.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
session: {
3939
url: '/irma',
4040
start: {
41-
url: (o: { url: string }) => `${o.url}/session`,
41+
url: (o: any) => `${o.url}/session`,
4242
method: 'POST',
4343
headers: { 'Content-Type': 'application/json' },
4444
body: JSON.stringify({
@@ -47,12 +47,12 @@
4747
})
4848
},
4949
mapping: {
50-
sessionPtr: (r: { sessionPtr: unknown }) => r.sessionPtr,
51-
sessionToken: (r: { token: string }) => {
50+
sessionPtr: (r: any) => r.sessionPtr,
51+
sessionToken: (r: any) => {
5252
irmaToken = r.token;
5353
return r.token;
5454
},
55-
frontendRequest: (r: { frontendRequest?: unknown }) => r.frontendRequest
55+
frontendRequest: (r: any) => r.frontendRequest
5656
}
5757
},
5858
state: {

src/lib/server/services/admin.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
apiKeys,
77
adminAccounts
88
} from '$lib/server/db/schema';
9-
import { eq, desc, and, isNull, or, count } from 'drizzle-orm';
9+
import { eq, desc, and, isNull, or, count, sql } from 'drizzle-orm';
1010

1111
export async function logAdminAction(
1212
adminId: string,
@@ -90,10 +90,7 @@ export async function approveChangeRequest(
9090

9191
if (fieldMap[req.fieldName]) {
9292
// Use raw SQL for dynamic column update
93-
await db.execute(
94-
`UPDATE organizations SET ${fieldMap[req.fieldName]} = $1, updated_at = NOW() WHERE id = $2`,
95-
[req.newValue, req.orgId]
96-
);
93+
await db.execute(sql`UPDATE organizations SET ${sql.raw(fieldMap[req.fieldName])} = ${req.newValue}, updated_at = NOW() WHERE id = ${req.orgId}`);
9794
}
9895

9996
await db

src/routes/(admin)/admin/settings/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
{#each Object.entries(flags) as [flag, info]}
4343
<div class="flag-row">
4444
<div class="flag-info">
45-
<span class="flag-label">{data.labels[flag]}</span>
45+
<span class="flag-label">{data.labels[flag as keyof typeof data.labels]}</span>
4646
<span class="flag-key">{flag}</span>
4747
</div>
4848
<div class="flag-controls">

src/routes/(marketing)/register/+page.server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export function load() {
1414
export const actions: Actions = {
1515
default: async ({ request }) => {
1616
if (!isEnabled('registration')) {
17-
return fail(404, { error: 'Not found' });
17+
return fail(404, {
18+
errors: { form: 'Not found' } as Record<string, string>,
19+
values: { name: '', domain: '', email: '', contactName: '', phone: null, kvkNumber: null }
20+
});
1821
}
1922

2023
const data = await request.formData();
@@ -63,12 +66,12 @@ export const actions: Actions = {
6366
} catch (err: unknown) {
6467
if (err instanceof Error && err.message.includes('unique')) {
6568
return fail(409, {
66-
errors: { domain: 'This domain is already registered' },
69+
errors: { domain: 'This domain is already registered' } as Record<string, string>,
6770
values: { name, domain, email, contactName, phone, kvkNumber }
6871
});
6972
}
7073
return fail(500, {
71-
errors: { form: 'An unexpected error occurred. Please try again.' },
74+
errors: { form: 'An unexpected error occurred. Please try again.' } as Record<string, string>,
7275
values: { name, domain, email, contactName, phone, kvkNumber }
7376
});
7477
}

src/routes/(marketing)/register/+page.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
import SEO from '$lib/components/SEO.svelte';
33
import { enhance } from '$app/forms';
44
import Icon from '@iconify/svelte';
5-
import type { ActionData } from './$types';
65
7-
let { form }: { form: ActionData } = $props();
6+
interface FormResult {
7+
success?: boolean;
8+
errors?: Record<string, string>;
9+
values?: Record<string, string | null | undefined>;
10+
}
11+
12+
let { form }: { form: FormResult | null } = $props();
813
</script>
914

1015
<SEO

src/routes/(portal)/portal/api-keys/+page.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ export const load: PageServerLoad = async ({ parent }) => {
1111
};
1212

1313
export const actions: Actions = {
14-
revoke: async ({ request, parent }) => {
15-
const { organization } = await parent();
14+
revoke: async ({ request, locals }) => {
15+
const orgId = locals.session?.orgId;
16+
if (!orgId) error(401, 'Not authenticated');
1617
const data = await request.formData();
1718
const keyId = data.get('keyId')?.toString();
1819

1920
if (!keyId) {
2021
return fail(400, { error: 'Missing key ID' });
2122
}
2223

23-
await revokeApiKey(keyId, organization.id);
24+
await revokeApiKey(keyId, orgId);
2425
return { revoked: true };
2526
}
2627
};

src/routes/(portal)/portal/api-keys/create/+page.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export function load() {
88
}
99

1010
export const actions: Actions = {
11-
default: async ({ request, parent }) => {
12-
const { organization } = await parent();
11+
default: async ({ request, locals }) => {
12+
const orgId = locals.session?.orgId;
13+
if (!orgId) error(401, 'Not authenticated');
1314
const data = await request.formData();
1415

1516
const name = data.get('name')?.toString().trim();
@@ -33,7 +34,7 @@ export const actions: Actions = {
3334
const expiresAt = new Date(Date.now() + expiryDays * 24 * 60 * 60 * 1000);
3435

3536
const rawKey = await createApiKey(
36-
organization.id,
37+
orgId,
3738
name,
3839
{
3940
orgName: signOrgName,

src/routes/(portal)/portal/dns/+page.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ export const load: PageServerLoad = async ({ parent }) => {
1414
};
1515

1616
export const actions: Actions = {
17-
verify: async ({ parent }) => {
18-
const { organization } = await parent();
19-
const result = await verifyDns(organization.id);
17+
verify: async ({ locals }) => {
18+
const orgId = locals.session?.orgId;
19+
if (!orgId) error(401, 'Not authenticated');
20+
const result = await verifyDns(orgId);
2021
return result;
2122
}
2223
};

src/routes/(portal)/portal/email-log/+page.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ export const load: PageServerLoad = async ({ parent, url }) => {
1414
};
1515

1616
export const actions: Actions = {
17-
revoke: async ({ request, parent, locals }) => {
18-
const { organization } = await parent();
17+
revoke: async ({ request, locals }) => {
18+
const orgId = locals.session?.orgId;
19+
if (!orgId) error(401, 'Not authenticated');
1920
const data = await request.formData();
2021
const emailId = data.get('emailId')?.toString();
2122

2223
if (!emailId) return fail(400, { error: 'Missing email ID' });
2324

24-
await revokeEmail(emailId, organization.id, locals.session?.id ?? 'unknown');
25+
await revokeEmail(emailId, orgId, locals.session?.id ?? 'unknown');
2526
return { revoked: true };
2627
}
2728
};

src/routes/(portal)/portal/organization/+page.server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export const load: PageServerLoad = async ({ parent }) => {
1111
};
1212

1313
export const actions: Actions = {
14-
requestChange: async ({ request, parent }) => {
15-
const { organization } = await parent();
14+
requestChange: async ({ request, locals }) => {
15+
const orgId = locals.session?.orgId;
16+
if (!orgId) error(401, 'Not authenticated');
1617
const data = await request.formData();
1718
const fieldName = data.get('fieldName')?.toString();
1819
const newValue = data.get('newValue')?.toString().trim();
@@ -22,7 +23,7 @@ export const actions: Actions = {
2223
return fail(400, { error: 'Field name and new value are required' });
2324
}
2425

25-
await createChangeRequest(organization.id, fieldName, oldValue, newValue);
26+
await createChangeRequest(orgId, fieldName, oldValue, newValue);
2627
return { submitted: true, fieldName };
2728
}
2829
};

0 commit comments

Comments
 (0)