Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 17bda5b

Browse files
authored
refactor: standardize property naming conventions in backend schemas (#30)
* refactor: standardize property naming conventions in backend schemas and related components * chore: lint
1 parent 2873396 commit 17bda5b

File tree

12 files changed

+126
-128
lines changed

12 files changed

+126
-128
lines changed

.github/copilot-instructions.md

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -926,39 +926,39 @@ Forms containing `<input type="file">` must use `enctype="multipart/form-data"`.
926926

927927
# SVELTEKIT + TAILWIND + TYPESCRIPT OPERATIONAL GUIDELINES
928928

929-
## PRIME DIRECTIVE
930-
Always prioritize maintainability, accessibility, and clean developer ergonomics.
931-
Collaborate via conversation while coding — **explain what, how, and why**.
929+
## PRIME DIRECTIVE
930+
Always prioritize maintainability, accessibility, and clean developer ergonomics.
931+
Collaborate via conversation while coding — **explain what, how, and why**.
932932
Avoid making multiple concurrent changes to the same file to prevent conflict or corruption.
933933

934934
---
935935

936936
## LARGE FILE & COMPLEX CHANGE PROTOCOL
937937

938-
### MANDATORY PLANNING PHASE
939-
When editing files larger than 300 lines or implementing deeply integrated features:
938+
### MANDATORY PLANNING PHASE
939+
When editing files larger than 300 lines or implementing deeply integrated features:
940940

941-
1. **Always begin with a detailed, structured edit plan**
941+
1. **Always begin with a detailed, structured edit plan**
942942
2. The plan must include:
943943
- A breakdown of all affected components, stores, routes, or layouts
944944
- The order of operations for each edit
945945
- Dependencies and known side effects
946-
- An estimated count of isolated edits required
946+
- An estimated count of isolated edits required
947947

948-
**Plan format**:
948+
**Plan format**:
949949
```md
950-
## PROPOSED EDIT PLAN
951-
Working with: [filename or route]
952-
Total planned edits: [number]
950+
## PROPOSED EDIT PLAN
951+
Working with: [filename or route]
952+
Total planned edits: [number]
953953
```
954954

955955
---
956956

957-
### MAKING EDITS
958-
- Focus on **one conceptual change at a time**
959-
- Use "before/after" snippets to demonstrate changes
960-
- Explain the **purpose** and benefit of each change clearly
961-
- Ensure edits comply with the project’s structure and coding conventions
957+
### MAKING EDITS
958+
- Focus on **one conceptual change at a time**
959+
- Use "before/after" snippets to demonstrate changes
960+
- Explain the **purpose** and benefit of each change clearly
961+
- Ensure edits comply with the project’s structure and coding conventions
962962

963963
**Edit Sequence Template**:
964964
```md
@@ -969,9 +969,9 @@ Do you approve this plan? I will proceed with Edit [#] upon your confirmation.
969969

970970
---
971971

972-
### EXECUTION PHASE
973-
- After completing each step:
974-
✅ Completed edit [#] of [total]. Ready for next edit?
972+
### EXECUTION PHASE
973+
- After completing each step:
974+
✅ Completed edit [#] of [total]. Ready for next edit?
975975
- If additional issues arise, **pause**, revise the plan, and **seek user approval before continuing**
976976

977977
---
@@ -985,46 +985,46 @@ Use the following folder layout:
985985
messages/ # Paraglide translations
986986
src/
987987
├── lib/ # Reusable UI components and utilities
988-
│ ├── components/
988+
│ ├── components/
989989
├── routes/ # SvelteKit endpoints, pages, and layouts
990990
├── app.d.ts # App-wide type definitions
991991
└── hooks.server.ts # Server hooks for session/auth
992992
```
993993

994994
---
995995

996-
### TYPING & TOOLING
996+
### TYPING & TOOLING
997997
- Use **TypeScript 5.7+** syntax and features
998998
- Prefer **Zod** for runtime validation and schema definition
999999
- Ensure all components and functions are typed strictly
10001000
- Use `readonly` for immutable structures when possible
10011001

10021002
---
10031003

1004-
### UI COMPONENTS
1005-
- Use `bits-ui`, `lucide-svelte`, and `tailwind-variants` for consistent styling
1006-
- Create generic variants using **tailwind-variants** for composability
1007-
- Favor `clsx` for class merging where conditional logic is needed
1004+
### UI COMPONENTS
1005+
- Use `bits-ui`, `lucide-svelte`, and `tailwind-variants` for consistent styling
1006+
- Create generic variants using **tailwind-variants** for composability
1007+
- Favor `clsx` for class merging where conditional logic is needed
10081008

10091009
---
10101010

1011-
### STYLING
1012-
- Use **Tailwind CSS 3.4+**
1013-
- Leverage `tailwind-merge` to prevent class duplication
1014-
- Enable `prefers-color-scheme` dark mode
1015-
- Use `tailwindcss-animate` for smooth, native animations
1011+
### STYLING
1012+
- Use **Tailwind CSS 3.4+**
1013+
- Leverage `tailwind-merge` to prevent class duplication
1014+
- Enable `prefers-color-scheme` dark mode
1015+
- Use `tailwindcss-animate` for smooth, native animations
10161016
- Organize custom styles using component-scoped `<style>` blocks or utility classes
10171017

10181018
---
10191019

1020-
### FORM MANAGEMENT
1021-
- Use **sveltekit-superforms** with **Zod** for server-enhanced forms
1022-
- Apply `formsnap` components where structured UI patterns are needed
1023-
- Always display validation feedback using `aria-invalid`, `aria-describedby`, etc.
1020+
### FORM MANAGEMENT
1021+
- Use **sveltekit-superforms** with **Zod** for server-enhanced forms
1022+
- Apply `formsnap` components where structured UI patterns are needed
1023+
- Always display validation feedback using `aria-invalid`, `aria-describedby`, etc.
10241024

10251025
---
10261026

1027-
### ACCESSIBILITY
1027+
### ACCESSIBILITY
10281028
Always meet **WCAG 2.1 AA minimum**, AAA where feasible:
10291029
- Use semantic HTML tags (`<main>`, `<section>`, etc.)
10301030
- Add labels and `aria-*` attributes to interactive elements
@@ -1033,55 +1033,55 @@ Always meet **WCAG 2.1 AA minimum**, AAA where feasible:
10331033

10341034
---
10351035

1036-
### ESLINT & FORMATTER
1037-
- Use **ESLint 9+** and **Prettier 3+**
1038-
- Extend from `eslint-config-prettier` and `eslint-plugin-svelte`
1039-
- Auto-format with `prettier-plugin-svelte`
1036+
### ESLINT & FORMATTER
1037+
- Use **ESLint 9+** and **Prettier 3+**
1038+
- Extend from `eslint-config-prettier` and `eslint-plugin-svelte`
1039+
- Auto-format with `prettier-plugin-svelte`
10401040
- TypeScript rules managed via `typescript-eslint`
10411041

10421042
---
10431043

1044-
### TESTING
1045-
- Use **Vitest** for unit and integration testing
1046-
- Use **Playwright** (recommended, not listed but consider) for E2E
1047-
- Prefer `describe`, `test`, `expect` for clarity
1044+
### TESTING
1045+
- Use **Vitest** for unit and integration testing
1046+
- Use **Playwright** (recommended, not listed but consider) for E2E
1047+
- Prefer `describe`, `test`, `expect` for clarity
10481048
- Structure tests under `/tests` with a mirrored folder structure of `/src`
10491049

10501050
---
10511051

1052-
### PERFORMANCE & BUNDLING
1053-
- Use **Vite 5** with **@sveltejs/vite-plugin-svelte**
1054-
- Enable code-splitting via dynamic imports
1055-
- Optimize assets (use `WebP`, `AVIF`, lazy loading)
1056-
- Use `@iconify-json/flag` and `unplugin-icons` for scalable icon support
1052+
### PERFORMANCE & BUNDLING
1053+
- Use **Vite 5** with **@sveltejs/vite-plugin-svelte**
1054+
- Enable code-splitting via dynamic imports
1055+
- Optimize assets (use `WebP`, `AVIF`, lazy loading)
1056+
- Use `@iconify-json/flag` and `unplugin-icons` for scalable icon support
10571057

10581058
---
10591059

1060-
### ERROR HANDLING
1061-
- Use `try/catch` consistently in load functions and API calls
1062-
- Provide user-friendly messages via `svelte-sonner`
1063-
- Log dev details to the console or a remote logger when applicable
1060+
### ERROR HANDLING
1061+
- Use `try/catch` consistently in load functions and API calls
1062+
- Provide user-friendly messages via `svelte-sonner`
1063+
- Log dev details to the console or a remote logger when applicable
10641064
- Handle:
10651065
- Network errors
10661066
- Business logic errors
1067-
- Runtime exceptions
1067+
- Runtime exceptions
10681068
- Use global event handlers like `window.addEventListener('unhandledrejection')`
10691069

10701070
---
10711071

1072-
## SECURITY BEST PRACTICES
1073-
- Sanitize all form input using Zod schemas
1074-
- Avoid client-side secrets (e.g., in `.env`)
1075-
- Enforce proper CORS and CSP headers
1076-
- Store cookies securely: `SameSite=Strict`, `HttpOnly`, `Secure`
1072+
## SECURITY BEST PRACTICES
1073+
- Sanitize all form input using Zod schemas
1074+
- Avoid client-side secrets (e.g., in `.env`)
1075+
- Enforce proper CORS and CSP headers
1076+
- Store cookies securely: `SameSite=Strict`, `HttpOnly`, `Secure`
10771077
- Use role-based access control in hooks and endpoints
10781078

10791079
---
10801080

1081-
### DEPLOYMENT CONSIDERATIONS
1082-
- Use **adapter-auto** for portability
1083-
- Consider replacing it with `adapter-vercel` or `adapter-static` depending on target platform
1084-
- Ensure SSR + client hydration is functioning
1081+
### DEPLOYMENT CONSIDERATIONS
1082+
- Use **adapter-auto** for portability
1083+
- Consider replacing it with `adapter-vercel` or `adapter-static` depending on target platform
1084+
- Ensure SSR + client hydration is functioning
10851085
- Use `.env` and `config/` files for environment-specific settings
10861086

10871087
---

src/lib/backendSchemas.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ export interface LanguageConfig {
1717
id: number;
1818
language: string;
1919
version: string;
20-
file_extension: string;
20+
fileExtension: string;
2121
}
2222

2323
export interface TaskData {
2424
id: number;
2525
title: string;
26-
description_url: string;
27-
created_by: number;
26+
descriptionUrl: string;
27+
createdBy: number;
2828
}
2929

3030
interface LanguageData {
@@ -41,14 +41,14 @@ export enum SubmissionStatus {
4141

4242
export interface SubmissionData {
4343
id: number;
44-
task_id: number;
45-
user_id: number;
44+
taskId: number;
45+
userId: number;
4646
order: number;
47-
language_id: number;
47+
languageId: number;
4848
status: SubmissionStatus;
49-
status_message: string;
50-
submitted_at: string;
51-
checked_at: string;
49+
statusMessage: string;
50+
submittedAt: string;
51+
checkedAt: string;
5252
language: LanguageData;
5353
task: TaskData;
5454
user: UserData;
@@ -58,27 +58,27 @@ export interface SubmissionData {
5858
export interface GroupData {
5959
id: number;
6060
name: string;
61-
created_by: number;
62-
created_at: string;
63-
updated_at: string;
61+
createdBy: number;
62+
createdAt: string;
63+
updatedAt: string;
6464
tasks: TaskData[] | null;
6565
users: UserData[] | null;
6666
}
6767

6868
interface TestResultData {
6969
id: number;
70-
submission_result_id: number;
71-
input_output_id: number;
70+
submissionResultId: number;
71+
inputOutputId: number;
7272
passed: boolean;
7373
}
7474

7575
export interface SubmissionResultData {
7676
id: number;
77-
submission_id: number;
77+
submissionId: number;
7878
code: string;
7979
message: string;
80-
created_at: string;
81-
test_results: TestResultData[] | null;
80+
createdAt: string;
81+
testResults: TestResultData[] | null;
8282
}
8383

8484
interface ApiResponse {
@@ -106,10 +106,10 @@ export interface AuthSessionResponse extends ApiResponse {
106106

107107
export interface AuthUserResponse extends ApiResponse {
108108
data: {
109-
user_id: number;
110-
user_role: UserRole;
109+
userId: number;
110+
userRole: UserRole;
111111
session: string;
112-
expires_at: Date;
112+
expiresAt: Date;
113113
};
114114
}
115115

src/lib/components/tasks/EditTaskDialog.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
editTaskForm,
2626
assingTaskToGroupsForm
2727
}: {
28-
taskData: Omit<TaskData, 'description_url'>;
28+
taskData: Omit<TaskData, 'descriptionUrl'>;
2929
userGroups: GroupData[];
3030
editTaskForm: SuperValidated<Infer<EditTaskSchema>>;
3131
assingTaskToGroupsForm: SuperValidated<Infer<AssingTaskToGroupsSchema>>;

src/lib/components/tasks/TaskView.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import EditTaskDialog from './EditTaskDialog.svelte';
1414
import type { AssingTaskToGroupsSchema, EditTaskSchema } from './formSchemas';
1515
import Button from '$components/ui/button/button.svelte';
16-
import { page } from '$app/state';
16+
import { page } from '$app/stores';
1717
1818
let {
1919
localUser,
@@ -25,7 +25,7 @@
2525
availableLanguages
2626
}: {
2727
localUser: UserData;
28-
task: Omit<TaskData, 'description_url'> & {
28+
task: Omit<TaskData, 'descriptionUrl'> & {
2929
description_file: Promise<ArrayBuffer>;
3030
};
3131
editTaskForm: SuperValidated<Infer<EditTaskSchema>>;
@@ -41,11 +41,11 @@
4141
availableLanguages: availableLanguages
4242
};
4343
44-
const { taskId } = page.params;
44+
const taskId = $derived($page.params.taskId);
4545
4646
function isAllowed() {
4747
return (
48-
(localUser.role === UserRole.Teacher && task.created_by === localUser.id) ||
48+
(localUser.role === UserRole.Teacher && task.createdBy === localUser.id) ||
4949
localUser.role === UserRole.Admin
5050
);
5151
}

src/lib/components/tasks/submissions/TaskAllSubmissionsView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
>
4040
<Table.Cell>{submission.language.language}</Table.Cell>
4141
<Table.Cell>
42-
{new Date(submission.submitted_at).toLocaleString()}
42+
{new Date(submission.submittedAt).toLocaleString()}
4343
</Table.Cell>
4444
<Table.Cell class={get_submission_status_color(submission.status)}
4545
>{submission.status}</Table.Cell

src/lib/components/users/UserView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
>
9999
<Table.Cell>{submission.language.language}</Table.Cell>
100100
<Table.Cell>
101-
{new Date(submission.submitted_at).toLocaleString()}
101+
{new Date(submission.submittedAt).toLocaleString()}
102102
</Table.Cell>
103103
<Table.Cell class={get_submission_status_color(submission.status)}
104104
>{submission.status}</Table.Cell

src/lib/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export function get_submission_status_color(status: string) {
2222
export function get_submission_passed_color(result: SubmissionResultData | null) {
2323
if (!result) {
2424
return 'bg-white';
25-
} else if (!result.test_results) {
25+
} else if (!result.testResults) {
2626
return 'bg-red-200';
27-
} else if (result.test_results.every((test) => test.passed)) {
27+
} else if (result.testResults.every((test) => test.passed)) {
2828
return 'bg-green-200';
29-
} else if (result.test_results.some((test) => !test.passed)) {
29+
} else if (result.testResults.some((test) => !test.passed)) {
3030
return 'bg-orange-200';
3131
} else {
3232
return 'bg-red-200';
@@ -36,11 +36,11 @@ export function get_submission_passed_color(result: SubmissionResultData | null)
3636
export function get_submission_passed_text(result: SubmissionResultData | null) {
3737
if (!result) {
3838
return '-';
39-
} else if (!result.test_results) {
39+
} else if (!result.testResults) {
4040
return '0/0';
4141
} else {
42-
const countPassed = result.test_results.filter((test) => test.passed).length;
43-
const countTotal = result.test_results.length;
42+
const countPassed = result.testResults.filter((test) => test.passed).length;
43+
const countTotal = result.testResults.length;
4444
return `${countPassed}/${countTotal}`;
4545
}
4646
}

0 commit comments

Comments
 (0)