@rimori/client 2.5.17-next.2 → 2.5.17-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,8 +45,9 @@ export declare class ExerciseModule {
|
|
|
45
45
|
*/
|
|
46
46
|
view(): Promise<Exercise[]>;
|
|
47
47
|
/**
|
|
48
|
-
* Creates
|
|
49
|
-
*
|
|
48
|
+
* Creates one or more exercises via the backend API.
|
|
49
|
+
* Multiple exercises are sent in a single bulk request to ensure atomicity —
|
|
50
|
+
* either all succeed or none are inserted.
|
|
50
51
|
* @param params Exercise creation parameters (single or array).
|
|
51
52
|
* @returns Created exercise objects.
|
|
52
53
|
*/
|
|
@@ -37,31 +37,30 @@ export class ExerciseModule {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Creates
|
|
41
|
-
*
|
|
40
|
+
* Creates one or more exercises via the backend API.
|
|
41
|
+
* Multiple exercises are sent in a single bulk request to ensure atomicity —
|
|
42
|
+
* either all succeed or none are inserted.
|
|
42
43
|
* @param params Exercise creation parameters (single or array).
|
|
43
44
|
* @returns Created exercise objects.
|
|
44
45
|
*/
|
|
45
46
|
add(params) {
|
|
46
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
48
|
const exercises = Array.isArray(params) ? params : [params];
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return yield response.json();
|
|
62
|
-
})));
|
|
49
|
+
const response = yield fetch(`${this.backendUrl}/exercises`, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
Authorization: `Bearer ${this.token}`,
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify({ exercises }),
|
|
56
|
+
});
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
const errorText = yield response.text();
|
|
59
|
+
throw new Error(`Failed to create exercises: ${errorText}`);
|
|
60
|
+
}
|
|
61
|
+
const data = yield response.json();
|
|
63
62
|
this.eventModule.emit('global.exercises.triggerChange');
|
|
64
|
-
return
|
|
63
|
+
return data;
|
|
65
64
|
});
|
|
66
65
|
}
|
|
67
66
|
/**
|