Skip to content

Commit 72a7d60

Browse files
committed
Fix bindings
1 parent 74bf2cf commit 72a7d60

File tree

17 files changed

+95
-27
lines changed

17 files changed

+95
-27
lines changed

Cargo.lock

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ tmc-langs-util = { path = "crates/tmc-langs-util" }
3939
tmc-mooc-client = { path = "crates/tmc-mooc-client" }
4040
tmc-server-mock = { path = "crates/helpers/tmc-server-mock" }
4141
tmc-testmycode-client = { path = "crates/tmc-testmycode-client" }
42-
ts-rs = { git = "https://github.com/Heliozoa/ts-rs.git", rev = "043c49c461543367d702e4db503f793f1ba801c2" }
42+
ts-rs = { git = "https://github.com/Heliozoa/ts-rs.git", rev = "07712bf04007472aeeb065091261b3b64c019381" }
4343

4444
# [patch.'https://github.com/Heliozoa/ts-rs.git']
4545
# ts-rs = { path = "../ts-rs/ts-rs" }
4646

47-
# [patch.'https://github.com/rage/secret-project-331.git']
48-
# mooc-langs-api = { path = "../secret-project-331/services/headless-lms/langs-api" }
47+
[patch.'https://github.com/rage/secret-project-331.git']
48+
mooc-langs-api = { path = "../secret-project-331/services/headless-lms/langs-api" }

crates/bindings/tmc-langs-node/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,3 @@ log = "0.4.14"
3131
once_cell = "1.9.0"
3232
simple_logger = "4.0.0"
3333
tmc-server-mock.workspace = true
34-
35-
[features]
36-
ts-rs = ["tmc-langs/ts-rs"]

crates/bindings/tmc-langs-node/src/bin/generate-bindings.rs renamed to crates/bindings/tmc-langs-node/src/bin/generate-node-bindings.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
use std::fs::File;
44

55
fn main() {
6-
let mut file = File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/ts/generated.d.ts")).unwrap();
6+
println!("Generating node bindings");
7+
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/ts/generated.d.ts");
8+
let mut file = File::create(path).unwrap();
79
ts_rs::export_to! {
810
&mut file,
911
// checkstyle
@@ -71,5 +73,6 @@ fn main() {
7173
// listSettings
7274
tmc_langs::TmcConfig,
7375
}
74-
.unwrap()
76+
.unwrap();
77+
println!("Wrote bindings to `{path}`");
7578
}

crates/bindings/tmc-langs-node/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn make_testmycode_client(
3838
client_name: impl AsRef<str>,
3939
client_version: impl AsRef<str>,
4040
) -> Result<(TestMyCodeClient, Option<Credentials>), LangsError> {
41-
let root_url = env::var("TMC_LANGS_ROOT_URL")
41+
let root_url = env::var("TMC_LANGS_TMC_ROOT_URL")
4242
.unwrap_or_else(|_| "https://tmc.mooc.fi/".to_string())
4343
.parse()
4444
.expect("Invalid TMC root url");

crates/bindings/tmc-langs-node/ts/generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface RefreshData { "new-cache-path": string, "course-options": objec
1414

1515
export interface RefreshExercise { name: string, checksum: string, points: Array<string>, "sandbox-image": string, "tmcproject-yml": TmcProjectYml | null, }
1616

17-
export interface TmcProjectYml { extra_student_files: Array<string>, extra_exercise_files: Array<string>, force_update: Array<string>, tests_timeout_ms?: bigint, fail_on_valgrind_error?: boolean, minimum_python_version?: PythonVer, sandbox_image?: string, }
17+
export interface TmcProjectYml { extra_student_files: Array<string>, extra_exercise_files: Array<string>, force_update: Array<string>, tests_timeout_ms?: number, fail_on_valgrind_error?: boolean, minimum_python_version?: PythonVer, sandbox_image?: string, }
1818

1919
export interface PythonVer { major: number, minor: number | null, patch: number | null, }
2020

crates/bindings/tmc-langs-node/ts/tmc.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class Tmc {
2121
this.clientVersion = clientVersion;
2222
if (rootUrl) {
2323
this.rootUrl = rootUrl;
24-
tmc.setEnv("TMC_LANGS_ROOT_URL", rootUrl);
24+
tmc.setEnv("TMC_LANGS_TMC_ROOT_URL", rootUrl);
2525
}
2626
if (configDir) {
2727
this.configDir = configDir;
@@ -49,9 +49,15 @@ export class Tmc {
4949
outputPath: string,
5050
compression: Compression,
5151
deterministic: boolean,
52-
naive: boolean,
52+
naive: boolean
5353
): void {
54-
return tmc.compressProject(exercisePath, outputPath, compression, deterministic, naive);
54+
return tmc.compressProject(
55+
exercisePath,
56+
outputPath,
57+
compression,
58+
deterministic,
59+
naive
60+
);
5561
}
5662

5763
extractProject(

crates/tmc-langs-cli/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CLI interface for tmc-langs. The documentation for the various commands and para
33
## Running the CLI
44

55
Running the project with Cargo from the repository root:
6+
67
```bash
78
cargo run -p tmc-langs-cli help
89
```
@@ -21,7 +22,7 @@ Binaries for the supported targets are built and the binaries deployed to Google
2122

2223
| var name | usage |
2324
| -------------------------------- | -------------------------------------------------------------- |
24-
| `TMC_LANGS_ROOT_URL` | Sets the TMC server url. |
25+
| `TMC_LANGS_TMC_ROOT_URL` | Sets the TMC server url. |
2526
| `TMC_LANGS_CONFIG_DIR` | Sets the config directory. |
2627
| `TMC_LANGS_DEFAULT_PROJECTS_DIR` | Sets the default projects directory. |
2728
| `TMC_SANDBOX` | If set, the CLI considers itself to be running in tmc-sandbox. |

crates/tmc-langs-cli/bindings.d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface StatusUpdate<T> { finished: boolean, message: string, "percent-
2020

2121
export type NotificationKind = "warning" | "info";
2222

23-
export type DataKind = { "output-data-kind": "error", "output-data": { kind: Kind, trace: Array<string>, } } | { "output-data-kind": "validation", "output-data": StyleValidationResult } | { "output-data-kind": "available-points", "output-data": Array<string> } | { "output-data-kind": "exercises", "output-data": Array<string> } | { "output-data-kind": "exercise-packaging-configuration", "output-data": ExercisePackagingConfiguration } | { "output-data-kind": "local-exercises", "output-data": Array<LocalExercise> } | { "output-data-kind": "refresh-result", "output-data": RefreshData } | { "output-data-kind": "test-result", "output-data": RunResult } | { "output-data-kind": "exercise-desc", "output-data": ExerciseDesc } | { "output-data-kind": "updated-exercises", "output-data": Array<UpdatedExercise> } | { "output-data-kind": "exercise-download", "output-data": DownloadOrUpdateCourseExercisesResult } | { "output-data-kind": "combined-course-data", "output-data": CombinedCourseData } | { "output-data-kind": "course-details", "output-data": CourseDetails } | { "output-data-kind": "course-exercises", "output-data": Array<CourseExercise> } | { "output-data-kind": "course-data", "output-data": CourseData } | { "output-data-kind": "courses", "output-data": Array<Course> } | { "output-data-kind": "exercise-details", "output-data": ExerciseDetails } | { "output-data-kind": "submissions", "output-data": Array<Submission> } | { "output-data-kind": "update-result", "output-data": UpdateResult } | { "output-data-kind": "organization", "output-data": Organization } | { "output-data-kind": "organizations", "output-data": Array<Organization> } | { "output-data-kind": "reviews", "output-data": Array<Review> } | { "output-data-kind": "token", "output-data": unknown } | { "output-data-kind": "new-submission", "output-data": NewSubmission } | { "output-data-kind": "submission-feedback-response", "output-data": SubmissionFeedbackResponse } | { "output-data-kind": "submission-finished", "output-data": SubmissionFinished } | { "output-data-kind": "config-value", "output-data": ConfigValue } | { "output-data-kind": "tmc-config", "output-data": TmcConfig } | { "output-data-kind": "compressed-project-hash", "output-data": string } | { "output-data-kind": "submission-sandbox", "output-data": string };
23+
export type DataKind = { "output-data-kind": "error", "output-data": { kind: Kind, trace: Array<string>, } } | { "output-data-kind": "validation", "output-data": StyleValidationResult } | { "output-data-kind": "available-points", "output-data": Array<string> } | { "output-data-kind": "exercises", "output-data": Array<string> } | { "output-data-kind": "exercise-packaging-configuration", "output-data": ExercisePackagingConfiguration } | { "output-data-kind": "local-exercises", "output-data": Array<LocalExercise> } | { "output-data-kind": "refresh-result", "output-data": RefreshData } | { "output-data-kind": "test-result", "output-data": RunResult } | { "output-data-kind": "exercise-desc", "output-data": ExerciseDesc } | { "output-data-kind": "updated-exercises", "output-data": Array<UpdatedExercise> } | { "output-data-kind": "exercise-download", "output-data": DownloadOrUpdateCourseExercisesResult } | { "output-data-kind": "combined-course-data", "output-data": CombinedCourseData } | { "output-data-kind": "course-details", "output-data": CourseDetails } | { "output-data-kind": "course-exercises", "output-data": Array<CourseExercise> } | { "output-data-kind": "course-data", "output-data": CourseData } | { "output-data-kind": "courses", "output-data": Array<Course> } | { "output-data-kind": "exercise-details", "output-data": ExerciseDetails } | { "output-data-kind": "submissions", "output-data": Array<Submission> } | { "output-data-kind": "update-result", "output-data": UpdateResult } | { "output-data-kind": "organization", "output-data": Organization } | { "output-data-kind": "organizations", "output-data": Array<Organization> } | { "output-data-kind": "reviews", "output-data": Array<Review> } | { "output-data-kind": "token", "output-data": unknown } | { "output-data-kind": "new-submission", "output-data": NewSubmission } | { "output-data-kind": "submission-feedback-response", "output-data": SubmissionFeedbackResponse } | { "output-data-kind": "submission-finished", "output-data": SubmissionFinished } | { "output-data-kind": "config-value", "output-data": ConfigValue } | { "output-data-kind": "tmc-config", "output-data": TmcConfig } | { "output-data-kind": "compressed-project-hash", "output-data": string } | { "output-data-kind": "submission-sandbox", "output-data": string } | { "output-data-kind": "mooc-course-instances", "output-data": Array<CourseInstance> } | { "output-data-kind": "mooc-exercise-slides", "output-data": Array<TmcExerciseSlide> } | { "output-data-kind": "mooc-exercise-slide", "output-data": TmcExerciseSlide } | { "output-data-kind": "mooc-submission-finished", "output-data": ExerciseTaskSubmissionResult };
2424

2525
export interface NewSubmission { show_submission_url: string, paste_url: string, submission_url: string, }
2626

@@ -102,3 +102,17 @@ export interface TestCase { name: string, successful: boolean, message: string |
102102

103103
export type SubmissionFeedbackKind = "Text" | { "IntRange": { lower: number, upper: number, } };
104104

105+
export interface CourseInstance { id: string, course_id: string, course_slug: string, course_name: string, course_description: string | null, instance_name: string | null, instance_description: string | null, }
106+
107+
export interface TmcExerciseSlide { slide_id: string, exercise_id: string, exercise_name: string, exercise_order_number: number, deadline: Date | null, tasks: Array<TmcExerciseTask>, }
108+
109+
export interface TmcExerciseTask { task_id: string, order_number: number, assignment: unknown, public_spec: PublicSpec | null, model_solution_spec: ModelSolutionSpec | null, }
110+
111+
export type PublicSpec = { "type": "browser", files: Array<ExerciseFile>, } | { "type": "editor", archiveName: string, archiveDownloadUrl: string, checksum: string, };
112+
113+
export type ModelSolutionSpec = { "type": "browser", solutionFiles: Array<ExerciseFile>, } | { "type": "editor", archiveDownloadUrl: string, };
114+
115+
export interface ExerciseFile { filepath: string, contents: string, }
116+
117+
export interface ExerciseTaskSubmissionResult { submission_id: string, }
118+

crates/tmc-langs-cli/src/app.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ pub enum MoocCommand {
560560
#[clap(long)]
561561
exercise_id: Uuid,
562562
#[clap(long)]
563+
slide_id: Uuid,
564+
#[clap(long)]
565+
task_id: Uuid,
566+
#[clap(long)]
563567
submission_path: PathBuf,
564568
},
565569
}
@@ -1222,6 +1226,13 @@ fn generate_cli_bindings() {
12221226
tmc::response::SubmissionFeedbackQuestion,
12231227
tmc::response::TestCase,
12241228
tmc::response::SubmissionFeedbackKind,
1229+
mooc::CourseInstance,
1230+
mooc::TmcExerciseSlide,
1231+
mooc::TmcExerciseTask,
1232+
mooc::PublicSpec,
1233+
mooc::ModelSolutionSpec,
1234+
mooc::ExerciseFile,
1235+
mooc::ExerciseTaskSubmissionResult,
12251236
)
12261237
.unwrap();
12271238
}

0 commit comments

Comments
 (0)