diff --git a/Cargo.lock b/Cargo.lock index c13e742ee81..a3dd969cdc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,9 +222,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.1" +version = "3.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c764d619ca78fccbf3069b37bd7af92577f044bb15236036662d79b6559f25b7" +checksum = "a3b1be7772ee4501dba05acbe66bb1e8760f6a6c474a36035631638e4415f130" [[package]] name = "byteorder" @@ -353,10 +353,11 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "colored" -version = "2.1.0" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" dependencies = [ + "is-terminal", "lazy_static", "windows-sys 0.48.0", ] @@ -1000,6 +1001,17 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "isolang" version = "2.4.0" @@ -1133,16 +1145,6 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.20" @@ -1205,9 +1207,9 @@ dependencies = [ [[package]] name = "mockito" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8d3038e23466858569c2d30a537f691fa0d53b51626630ae08262943e3bbb8b" +checksum = "a8c84fe1f1d8c56dc157f79942056fad4b9efceebba374a01b222428b553facb" dependencies = [ "assert-json-diff", "colored", @@ -1372,29 +1374,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", -] - [[package]] name = "password-hash" version = "0.4.2" @@ -1762,12 +1741,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "sct" version = "0.7.1" @@ -1923,15 +1896,6 @@ dependencies = [ "regex", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "similar" version = "2.4.0" @@ -2502,25 +2466,11 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2", - "tokio-macros", "windows-sys 0.48.0", ] -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.50", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -2613,7 +2563,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "ts-rs" version = "7.1.1" -source = "git+https://github.com/Heliozoa/ts-rs.git?rev=ace53e13ecc871c68c4cd6c6a9d49e272e5823a9#ace53e13ecc871c68c4cd6c6a9d49e272e5823a9" +source = "git+https://github.com/Heliozoa/ts-rs.git?rev=272301ad9d63ae27fb86c225afffbf60f626527b#272301ad9d63ae27fb86c225afffbf60f626527b" dependencies = [ "chrono", "serde_json", @@ -2626,7 +2576,7 @@ dependencies = [ [[package]] name = "ts-rs-macros" version = "7.1.1" -source = "git+https://github.com/Heliozoa/ts-rs.git?rev=ace53e13ecc871c68c4cd6c6a9d49e272e5823a9#ace53e13ecc871c68c4cd6c6a9d49e272e5823a9" +source = "git+https://github.com/Heliozoa/ts-rs.git?rev=272301ad9d63ae27fb86c225afffbf60f626527b#272301ad9d63ae27fb86c225afffbf60f626527b" dependencies = [ "Inflector", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 113e938bfd6..ca4f4b78578 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ tmc-langs-util = { path = "crates/tmc-langs-util" } tmc-mooc-client = { path = "crates/tmc-mooc-client" } tmc-server-mock = { path = "crates/helpers/tmc-server-mock" } tmc-testmycode-client = { path = "crates/tmc-testmycode-client" } -ts-rs = { git = "https://github.com/Heliozoa/ts-rs.git", rev = "ace53e13ecc871c68c4cd6c6a9d49e272e5823a9" } +ts-rs = { git = "https://github.com/Heliozoa/ts-rs.git", rev = "272301ad9d63ae27fb86c225afffbf60f626527b" } # [patch.'https://github.com/Heliozoa/ts-rs.git'] # ts-rs = { path = "../ts-rs/ts-rs" } diff --git a/crates/tmc-langs-cli/bindings.d.ts b/crates/tmc-langs-cli/bindings.d.ts index f62b1008730..7f69c8ffda2 100644 --- a/crates/tmc-langs-cli/bindings.d.ts +++ b/crates/tmc-langs-cli/bindings.d.ts @@ -28,16 +28,15 @@ export type StyleValidationError = { column: number, line: number, message: stri export type StyleValidationStrategy = "FAIL" | "WARN" | "DISABLED"; -export type ExercisePackagingConfiguration = { - /** - * Student folders or files which are copied from submission. - */ - student_file_paths: Array, - /** - * Exercise folders or files which are copied from exercise template or clone. - */ - exercise_file_paths: Array, -} +export type ExercisePackagingConfiguration = { +/** + * Student folders or files which are copied from submission. + */ +student_file_paths: Array, +/** + * Exercise folders or files which are copied from exercise template or clone. + */ +exercise_file_paths: Array, } export type LocalExercise = { "exercise-slug": string, "exercise-path": string, } @@ -47,191 +46,175 @@ export type RefreshData = { "new-cache-path": string, "course-options": object, export type RefreshExercise = { name: string, checksum: string, points: Array, "sandbox-image": string, "tmcproject-yml": TmcProjectYml | null, } -export type TmcProjectYml = { - /** - * A list of files or directories that will always be considered student files. - */ - extra_student_files: Array, - /** - * A list of files or directories that will always be considered exercise files. - * `extra_student_files` takes precedence if a file is both an extra student file and an extra exercise file. - */ - extra_exercise_files: Array, - /** - * A list of files that should always be overwritten by updates even if they are student files. - */ - force_update: Array, - /** - * If set, tests are forcibly stopped after this duration. - */ - tests_timeout_ms?: number | null, - /** - * If set, Valgrind errors will be considered test errors. - */ - fail_on_valgrind_error?: boolean | null, - /** - * If set, will cause an error telling the student to update their Python if their version is older than the minimum. - */ - minimum_python_version?: PythonVer | null, - /** - * Overrides the default sandbox image. e.g. `eu.gcr.io/moocfi-public/tmc-sandbox-python:latest` - */ - sandbox_image?: string | null, -} +export type TmcProjectYml = { +/** + * A list of files or directories that will always be considered student files. + */ +extra_student_files: Array, +/** + * A list of files or directories that will always be considered exercise files. + * `extra_student_files` takes precedence if a file is both an extra student file and an extra exercise file. + */ +extra_exercise_files: Array, +/** + * A list of files that should always be overwritten by updates even if they are student files. + */ +force_update: Array, +/** + * If set, tests are forcibly stopped after this duration. + */ +tests_timeout_ms?: number, +/** + * If set, Valgrind errors will be considered test errors. + */ +fail_on_valgrind_error?: boolean, +/** + * If set, will cause an error telling the student to update their Python if their version is older than the minimum. + */ +minimum_python_version?: PythonVer, +/** + * Overrides the default sandbox image. e.g. `eu.gcr.io/moocfi-public/tmc-sandbox-python:latest` + */ +sandbox_image?: string, } export type PythonVer = { major: number, minor: number | null, patch: number | null, } -export type RunResult = { - /** - * The overall status of a test run. - */ - status: RunStatus, - /** - * Whether each test passed and which points were awarded. - */ - testResults: Array, - /** - * Logs from the test run. - * The key may be an arbitrary string identifying the type of log. - */ - logs: Record, -} +export type RunResult = { +/** + * The overall status of a test run. + */ +status: RunStatus, +/** + * Whether each test passed and which points were awarded. + */ +testResults: Array, +/** + * Logs from the test run. + * The key may be an arbitrary string identifying the type of log. + */ +logs: Record, } export type RunStatus = "PASSED" | "TESTS_FAILED" | "COMPILE_FAILED" | "TESTRUN_INTERRUPTED" | "GENERIC_ERROR"; -export type TestResult = { - name: string, successful: boolean, - /** - * List of points that were received from the exercise from passed tests. - */ - points: Array, message: string, exception: Array, -} - -export type ExerciseDesc = { - /** - * The name of the exercise to be shown to the user. - * Does not necessarily match or even contain the directory name. - */ - name: string, - /** - * Descriptions of the tests that will be run for this exercise. - */ - tests: Array, -} - -export type TestDesc = { - /** - * The full name of the test. - * - * If the language organises tests into suites or classes, it is customary - * to name the test as "class_name.method_name". - */ - name: string, - /** - * The list of point names that passing this test may give. - * - * To obtain a point X, the user must pass all exercises that require point X. - */ - points: Array, -} +export type TestResult = { name: string, successful: boolean, +/** + * List of points that were received from the exercise from passed tests. + */ +points: Array, message: string, exception: Array, } + +export type ExerciseDesc = { +/** + * The name of the exercise to be shown to the user. + * Does not necessarily match or even contain the directory name. + */ +name: string, +/** + * Descriptions of the tests that will be run for this exercise. + */ +tests: Array, } + +export type TestDesc = { +/** + * The full name of the test. + * + * If the language organises tests into suites or classes, it is customary + * to name the test as "class_name.method_name". + */ +name: string, +/** + * The list of point names that passing this test may give. + * + * To obtain a point X, the user must pass all exercises that require point X. + */ +points: Array, } export type UpdatedExercise = { id: number, } -export type DownloadOrUpdateCourseExercisesResult = { downloaded: Array, skipped: Array, failed?: Array<[ExerciseDownload, Array]> | null, } +export type DownloadOrUpdateCourseExercisesResult = { downloaded: Array, skipped: Array, failed?: Array<[ExerciseDownload, Array]>, } export type ExerciseDownload = { id: number, "course-slug": string, "exercise-slug": string, path: string, } export type CombinedCourseData = { details: CourseDetails, exercises: Array, settings: CourseData, } -export type CourseDetails = { - unlockables: Array, exercises: Array, id: number, name: string, title: string, description: string | null, - /** - * /api/v8/core/courses/{course_id} - */ - details_url: string, - /** - * /api/v8/core/courses/{course_id}/unlock - */ - unlock_url: string, - /** - * /api/v8/core/courses/{course_id}/reviews - */ - reviews_url: string, - /** - * Typically empty. - */ - comet_url: string, spyware_urls: Array, -} - -export type Exercise = { - id: number, name: string, locked: boolean, deadline_description: string | null, deadline: string | null, soft_deadline: string | null, soft_deadline_description: string | null, checksum: string, - /** - * /api/v8/core/exercises/{exercise_id}/submissions - */ - return_url: string, - /** - * /api/v8/core/exercises/{exercise_id}/download - */ - zip_url: string, returnable: boolean, requires_review: boolean, attempted: boolean, completed: boolean, reviewed: boolean, all_review_points_given: boolean, memory_limit: number | null, runtime_params: Array, valgrind_strategy: string | null, code_review_requests_enabled: boolean, run_tests_locally_action_enabled: boolean, - /** - * Typically null. - */ - latest_submission_url: string | null, latest_submission_id: number | null, - /** - * /api/v8/core/exercises/{exercise_id}/solution/download - */ - solution_zip_url: string | null, -} - -export type Course = { - id: number, name: string, title: string, description: string | null, - /** - * /api/v8/core/courses/{course_id} - */ - details_url: string, - /** - * /api/v8/core/courses/{course_id}/unlock - */ - unlock_url: string, - /** - * /api/v8/core/courses/{course_id}/reviews - */ - reviews_url: string, - /** - * Typically empty. - */ - comet_url: string, spyware_urls: Array, -} +export type CourseDetails = { unlockables: Array, exercises: Array, id: number, name: string, title: string, description: string | null, +/** + * /api/v8/core/courses/{course_id} + */ +details_url: string, +/** + * /api/v8/core/courses/{course_id}/unlock + */ +unlock_url: string, +/** + * /api/v8/core/courses/{course_id}/reviews + */ +reviews_url: string, +/** + * Typically empty. + */ +comet_url: string, spyware_urls: Array, } + +export type Exercise = { id: number, name: string, locked: boolean, deadline_description: string | null, deadline: string | null, soft_deadline: string | null, soft_deadline_description: string | null, checksum: string, +/** + * /api/v8/core/exercises/{exercise_id}/submissions + */ +return_url: string, +/** + * /api/v8/core/exercises/{exercise_id}/download + */ +zip_url: string, returnable: boolean, requires_review: boolean, attempted: boolean, completed: boolean, reviewed: boolean, all_review_points_given: boolean, memory_limit: number | null, runtime_params: Array, valgrind_strategy: string | null, code_review_requests_enabled: boolean, run_tests_locally_action_enabled: boolean, +/** + * Typically null. + */ +latest_submission_url: string | null, latest_submission_id: number | null, +/** + * /api/v8/core/exercises/{exercise_id}/solution/download + */ +solution_zip_url: string | null, } + +export type Course = { id: number, name: string, title: string, description: string | null, +/** + * /api/v8/core/courses/{course_id} + */ +details_url: string, +/** + * /api/v8/core/courses/{course_id}/unlock + */ +unlock_url: string, +/** + * /api/v8/core/courses/{course_id}/reviews + */ +reviews_url: string, +/** + * Typically empty. + */ +comet_url: string, spyware_urls: Array, } export type CourseExercise = { id: number, available_points: Array, awarded_points: Array, name: string, publish_time: string | null, solution_visible_after: string | null, deadline: string | null, soft_deadline: string | null, disabled: boolean, unlocked: boolean, } export type ExercisePoint = { id: number, exercise_id: number, name: string, requires_review: boolean, } -export type CourseData = { - name: string, hide_after: string | null, hidden: boolean, cache_version: number | null, spreadsheet_key: string | null, hidden_if_registered_after: string | null, refreshed_at: string | null, locked_exercise_points_visible: boolean, description: string | null, paste_visibility: number | null, formal_name: string | null, certificate_downloadable: boolean | null, certificate_unlock_spec: string | null, organization_id: number | null, disabled_status: string | null, title: string | null, - /** - * Typically empty. - */ - material_url: string | null, course_template_id: number | null, hide_submission_results: boolean, - /** - * Typically empty. - */ - external_scoreboard_url: string | null, organization_slug: string | null, -} +export type CourseData = { name: string, hide_after: string | null, hidden: boolean, cache_version: number | null, spreadsheet_key: string | null, hidden_if_registered_after: string | null, refreshed_at: string | null, locked_exercise_points_visible: boolean, description: string | null, paste_visibility: number | null, formal_name: string | null, certificate_downloadable: boolean | null, certificate_unlock_spec: string | null, organization_id: number | null, disabled_status: string | null, title: string | null, +/** + * Typically empty. + */ +material_url: string | null, course_template_id: number | null, hide_submission_results: boolean, +/** + * Typically empty. + */ +external_scoreboard_url: string | null, organization_slug: string | null, } export type ExerciseDetails = { course_name: string, course_id: number, code_review_requests_enabled: boolean, run_tests_locally_action_enabled: boolean, exercise_name: string, exercise_id: number, unlocked_at: string | null, deadline: string | null, submissions: Array, } -export type ExerciseSubmission = { - exercise_name: string, id: number, user_id: number, course_id: number, created_at: string, all_tests_passed: boolean, points: string | null, - /** - * /api/v8/core/submissions/{submission_id}/download - */ - submitted_zip_url: string, - /** - * https://tmc.mooc.fi/paste/{paste_code} - */ - paste_url: string | null, processing_time: number | null, reviewed: boolean, requests_review: boolean, -} +export type ExerciseSubmission = { exercise_name: string, id: number, user_id: number, course_id: number, created_at: string, all_tests_passed: boolean, points: string | null, +/** + * /api/v8/core/submissions/{submission_id}/download + */ +submitted_zip_url: string, +/** + * https://tmc.mooc.fi/paste/{paste_code} + */ +paste_url: string | null, processing_time: number | null, reviewed: boolean, requests_review: boolean, } export type Submission = { id: number, user_id: number, pretest_error: string | null, created_at: string, exercise_name: string, course_id: number, processed: boolean, all_tests_passed: boolean, points: string | null, processing_tried_at: string | null, processing_began_at: string | null, processing_completed_at: string | null, times_sent_to_sandbox: number, processing_attempts_started_at: string, params_json: string | null, requires_review: boolean, requests_review: boolean, reviewed: boolean, message_for_reviewer: string, newer_submission_reviewed: boolean, review_dismissed: boolean, paste_available: boolean, message_for_paste: string, paste_key: string | null, } @@ -239,32 +222,29 @@ export type UpdateResult = { created: Array, updated: Array, export type Organization = { name: string, information: string, slug: string, logo_path: string, pinned: boolean, } -export type Review = { - submission_id: number, exercise_name: string, id: number, marked_as_read: boolean, reviewer_name: string, review_body: string, points: Array, points_not_awarded: Array, - /** - * https://tmc.mooc.fi/submissions/{submission_id}/reviews - */ - url: string, - /** - * /api/v8/core/courses/{course_id}/reviews/{review_id} - */ - update_url: string, created_at: string, updated_at: string, -} - -export type NewSubmission = { - /** - * https://tmc.mooc.fi/api/v8/core/submissions/{submission_id} - */ - show_submission_url: string, - /** - * https://tmc.mooc.fi/paste/{paste_code} - */ - paste_url: string, - /** - * https://tmc.mooc.fi/submissions/{submission_id} - */ - submission_url: string, -} +export type Review = { submission_id: number, exercise_name: string, id: number, marked_as_read: boolean, reviewer_name: string, review_body: string, points: Array, points_not_awarded: Array, +/** + * https://tmc.mooc.fi/submissions/{submission_id}/reviews + */ +url: string, +/** + * /api/v8/core/courses/{course_id}/reviews/{review_id} + */ +update_url: string, created_at: string, updated_at: string, } + +export type NewSubmission = { +/** + * https://tmc.mooc.fi/api/v8/core/submissions/{submission_id} + */ +show_submission_url: string, +/** + * https://tmc.mooc.fi/paste/{paste_code} + */ +paste_url: string, +/** + * https://tmc.mooc.fi/submissions/{submission_id} + */ +submission_url: string, } export type SubmissionFeedbackResponse = { api_version: number, status: SubmissionStatus, } @@ -276,25 +256,23 @@ export type TmcStyleValidationError = { column: number, line: number, message: s export type TmcStyleValidationStrategy = "FAIL" | "WARN" | "DISABLED"; -export type SubmissionFinished = { - api_version: number, all_tests_passed: boolean | null, user_id: number, login: string, course: string, exercise_name: string, status: SubmissionStatus, points: Array, valgrind: string | null, - /** - * https://tmc.mooc.fi/submissions/{submission_id}} - */ - submission_url: string, - /** - * https://tmc.mooc.fi/exercises/{exercise_id}/solution - */ - solution_url: string | null, submitted_at: string, processing_time: number | null, reviewed: boolean, requests_review: boolean, - /** - * https://tmc.mooc.fi/paste/{paste_code} - */ - paste_url: string | null, message_for_paste: string | null, missing_review_points: Array, test_cases: Array | null, feedback_questions: Array | null, - /** - * /api/v8/core/submissions/{submission_id}/feedback - */ - feedback_answer_url: string | null, error: string | null, validations: TmcStyleValidationResult | null, -} +export type SubmissionFinished = { api_version: number, all_tests_passed: boolean | null, user_id: number, login: string, course: string, exercise_name: string, status: SubmissionStatus, points: Array, valgrind: string | null, +/** + * https://tmc.mooc.fi/submissions/{submission_id}} + */ +submission_url: string, +/** + * https://tmc.mooc.fi/exercises/{exercise_id}/solution + */ +solution_url: string | null, submitted_at: string, processing_time: number | null, reviewed: boolean, requests_review: boolean, +/** + * https://tmc.mooc.fi/paste/{paste_code} + */ +paste_url: string | null, message_for_paste: string | null, missing_review_points: Array, test_cases: Array | null, feedback_questions: Array | null, +/** + * /api/v8/core/submissions/{submission_id}/feedback + */ +feedback_answer_url: string | null, error: string | null, validations: TmcStyleValidationResult | null, } export type TestCase = { name: string, successful: boolean, message: string | null, exception: Array | null, detailed_message: string | null, }