@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 a new exercise or multiple exercises via the backend API.
49
- * When creating multiple exercises, all requests are made in parallel but only one event is emitted.
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 a new exercise or multiple exercises via the backend API.
41
- * When creating multiple exercises, all requests are made in parallel but only one event is emitted.
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 responses = yield Promise.all(exercises.map((exercise) => __awaiter(this, void 0, void 0, function* () {
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(exercise),
56
- });
57
- if (!response.ok) {
58
- const errorText = yield response.text();
59
- throw new Error(`Failed to create exercise: ${errorText}`);
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 responses;
63
+ return data;
65
64
  });
66
65
  }
67
66
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "2.5.17-next.2",
3
+ "version": "2.5.17-next.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {