@algebrakit/sdk 1.0.0 → 1.1.0

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.
package/README.md CHANGED
@@ -1,142 +1,140 @@
1
- # Algebrakit Webservice API SDK
1
+ # Algebrakit SDK for Node.js and TypeScript
2
2
 
3
- Official Node.js/TypeScript SDK for the Algebrakit Webservice API. It provides methods for creating sessions, retrieving scores, locking/unlocking sessions, and fetching session information.
3
+ [![npm](https://img.shields.io/npm/v/@algebrakit/sdk)](https://www.npmjs.com/package/@algebrakit/sdk)
4
+ [![CI](https://github.com/algebrakit/sdk-typescript/actions/workflows/ci.yml/badge.svg)](https://github.com/algebrakit/sdk-typescript/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
6
 
5
- ## Installation
7
+ The official server-side SDK for the [Algebrakit](https://algebrakit.com) API. Your server uses it to create exercise sessions, get scores and manage sessions. Students then work on the exercises in your web page, through the Algebrakit widget.
8
+
9
+ For how Algebrakit works, the full API reference and the widget's options, see the [Algebrakit documentation](https://docs.algebrakit.com/).
10
+
11
+ > **Want to see it working first?** [algebrakit-examples](https://github.com/algebrakit/algebrakit-examples/tree/main/minimal/typescript) has a small web app built on this SDK that runs on localhost in a few minutes.
12
+
13
+ ## Before you start
14
+
15
+ - Node.js 18 or newer.
16
+ - An Algebrakit API key. Don't have one yet? [Contact Algebrakit](https://algebrakit.com/contact-us).
17
+
18
+ Keep the API key on your server. Never send it to the browser.
19
+
20
+ ## Install
6
21
 
7
22
  ```bash
8
23
  npm install @algebrakit/sdk
9
24
  ```
10
25
 
11
- Requires Node.js 18 or newer.
12
-
13
- ## Usage
26
+ ## Quick start
14
27
 
15
- ### Initialize the API Client
28
+ Create a client and a session for an exercise:
16
29
 
17
30
  ```typescript
18
31
  import { ApiClient } from '@algebrakit/sdk';
19
32
 
20
- const apiClient = new ApiClient('https://api.algebrakit.com', 'your-api-key');
21
- ```
22
-
23
- ### Create a Session
33
+ const client = new ApiClient({ apiKey: process.env.ALGEBRAKIT_API_KEY! });
24
34
 
25
- ```typescript
26
- import { CreateSessionRequest } from '@algebrakit/sdk';
27
-
28
- const request: CreateSessionRequest = {
29
- exercises: [
30
- { exerciseId: 'fa42e943-8213-41a6-8a91-8c22a929ffe9', version: 'latest' },
31
- ],
32
- apiVersion: 2,
33
- };
34
-
35
- apiClient.createSession(request).then(response => {
36
- console.log('Session created:', response);
37
- }).catch(error => {
38
- console.error('Error creating session:', error);
35
+ const [result] = await client.createSession({
36
+ exercises: [{ exerciseId: 'fa42e943-8213-41a6-8a91-8c22a929ffe9' }],
39
37
  });
38
+ const sessionId = result.sessions[0].sessionId;
40
39
  ```
41
40
 
42
- ### Retrieve Session Scores
41
+ A session holds one student's work on one exercise. Store its ID with the student, so they can continue later and you can get their score.
43
42
 
44
- ```typescript
45
- import { SessionScoreRequest } from '@algebrakit/sdk';
43
+ ### Show the session to a student
46
44
 
47
- const request: SessionScoreRequest = {
48
- sessionId: '0a405901-8b89-4665-9ea0-6dbdff3602fc',
49
- lockSession: true,
50
- };
45
+ In your web page, the Algebrakit widget shows the session:
51
46
 
52
- apiClient.getSessionScore(request).then(response => {
53
- console.log('Session scores:', response);
54
- }).catch(error => {
55
- console.error('Error retrieving scores:', error);
56
- });
47
+ ```html
48
+ <script>
49
+ AlgebraKIT = { config: { proxy: { url: '/proxy/algebrakit' } } };
50
+ </script>
51
+ <script src="https://widgets.algebrakit.com"></script>
52
+
53
+ <akit-exercise session-id="SESSION_ID"></akit-exercise>
57
54
  ```
58
55
 
59
- ### Lock or Unlock Sessions
56
+ The widget sends its API calls to `/proxy/algebrakit/*` on your server. Your server adds the API key and forwards them to the Algebrakit API. The [minimal TypeScript example](https://github.com/algebrakit/algebrakit-examples/tree/main/minimal/typescript) implements all of this; for production, see [Proxy setup](https://docs.algebrakit.com/pages/420-proxy-setup/).
60
57
 
61
- ```typescript
62
- import { SessionLockRequest } from '@algebrakit/sdk';
58
+ ## API
63
59
 
64
- const request: SessionLockRequest = {
65
- action: 'LOCK',
66
- sessionIds: ['f2f62104-3b5a-4156-aeaf-291167e5f9e3'],
67
- };
60
+ Every method takes one request object and returns a promise. The request and response types are exported, for example `CreateSessionRequest` and `SessionScoreResponse`.
68
61
 
69
- apiClient.lockSession(request).then(response => {
70
- console.log('Session locked:', response);
71
- }).catch(error => {
72
- console.error('Error locking session:', error);
73
- });
74
- ```
62
+ | Method | Endpoint | What it does |
63
+ |---|---|---|
64
+ | `createSession` | `POST /session/create` | Create sessions for one or more exercises: by `exerciseId`, by `exerciseSpec` (an exercise defined in code) or by `sessionId` (a copy of an existing session's exercise) |
65
+ | `getSessionScore` | `POST /session/score` | Get a session's score, and optionally lock it |
66
+ | `getSessionInfo` | `POST /session/info` | Get a session's details: its elements, the student's work and the scoring |
67
+ | `lockSession` | `POST /sessions/lock` | `LOCK`, `UNLOCK` or `FINALIZE` sessions |
68
+ | `retrieveSession` | `POST /session/retrieve` | Get existing sessions by ID |
69
+ | `validateExercise` | `POST /exercise/validate` | Check an exercise ID or specification before you use it |
70
+ | `getExercisePublishedInfo` | `POST /exercise/published-info` | Get the published versions and structure of an exercise |
75
71
 
76
- ### Retrieve Session Information
72
+ ### Get the score
77
73
 
78
74
  ```typescript
79
- import { SessionInfoRequest } from '@algebrakit/sdk';
80
-
81
- const request: SessionInfoRequest = {
82
- sessionId: '0a405901-8b89-4665-9ea0-6dbdff3602fc',
83
- };
84
-
85
- apiClient.getSessionInfo(request).then(response => {
86
- console.log('Session info:', response);
87
- }).catch(error => {
88
- console.error('Error retrieving session info:', error);
89
- });
75
+ const { scoring } = await client.getSessionScore({ sessionId, lockSession: true });
76
+ console.log(`${scoring.marksEarned} of ${scoring.marksTotal} marks`);
90
77
  ```
91
78
 
92
- ## Running the Demos
79
+ ### Lock a session
93
80
 
94
- Each demo lives in its own folder under `demo/` with its own configuration.
81
+ ```typescript
82
+ await client.lockSession({ action: 'LOCK', sessionIds: [sessionId] });
83
+ ```
95
84
 
96
- ### CLI Demo (`demo/cli/`)
85
+ ## Configuration
97
86
 
98
- Demonstrates SDK API calls with text output.
87
+ ```typescript
88
+ const client = new ApiClient({
89
+ apiKey: process.env.ALGEBRAKIT_API_KEY!,
90
+ baseUrl: 'https://prod.api.sg-1.algebrakit.com', // optional, see the regions below
91
+ timeout: 10_000, // optional, in milliseconds; the default is 30000
92
+ });
93
+ ```
99
94
 
100
- 1. Set up your API key:
101
- ```bash
102
- npm run demo:setup
103
- # Then edit demo/cli/.env with your actual API key
104
- ```
95
+ | Region | Base URL |
96
+ |---|---|
97
+ | EU (default) | `https://api.algebrakit.com` |
98
+ | Singapore | `https://prod.api.sg-1.algebrakit.com` |
105
99
 
106
- 2. Run the demo:
107
- ```bash
108
- npm run demo
109
- ```
100
+ The older form `new ApiClient(baseUrl, apiKey)` still works.
110
101
 
111
- ### Web Demo (`demo/play-exercise/`)
102
+ ## Error handling
112
103
 
113
- Renders a working Algebrakit exercise in the browser with learning event logging.
104
+ The methods throw when a request fails. `handleApiError` turns any error into a readable line:
114
105
 
115
- 1. Set up your API key:
116
- ```bash
117
- npm run play-exercise:setup
118
- # Then edit demo/play-exercise/.env with your actual API key
119
- ```
106
+ ```typescript
107
+ import { handleApiError } from '@algebrakit/sdk';
120
108
 
121
- 2. Run the web demo:
122
- ```bash
123
- npm run play-exercise
124
- ```
109
+ try {
110
+ await client.getSessionInfo({ sessionId });
111
+ } catch (error) {
112
+ console.error(handleApiError(error));
113
+ // API Error: 401 - Could not validate credentials: the provided api-key is not valid
114
+ }
115
+ ```
125
116
 
126
- 3. Open `http://localhost:3000` in your browser.
117
+ The thrown error is an [`AxiosError`](https://axios-http.com/docs/handling_errors), so `error.response.status` and `error.response.data` are available too.
127
118
 
128
- ## Error Handling
119
+ ## More
129
120
 
130
- Use the `handleApiError` utility to standardize error messages:
121
+ - [algebrakit-examples](https://github.com/algebrakit/algebrakit-examples): runnable examples in TypeScript, PHP and .NET
122
+ - [Documentation](https://docs.algebrakit.com/): [SDKs](https://docs.algebrakit.com/pages/320-SDK/), [API reference](https://docs.algebrakit.com/pages/310-API/), [web components](https://docs.algebrakit.com/pages/410-webcomponents/) and [learning events](https://docs.algebrakit.com/pages/450-learning-events/)
123
+ - [OpenAPI specification](https://api.algebrakit.com/openapi/yaml)
124
+ - SDKs for other languages: [PHP](https://github.com/algebrakit/sdk-php) and [.NET](https://github.com/algebrakit/sdk-dotnet)
125
+ - A tour of every API call: [`demo/cli`](demo/cli/demo.ts). Run `npm run demo:setup`, add your API key to `demo/cli/.env`, then run `npm run demo`.
131
126
 
132
- ```typescript
133
- import { handleApiError } from '@algebrakit/sdk';
127
+ ## Development
134
128
 
135
- apiClient.createSession(request).catch(error => {
136
- console.error(handleApiError(error));
137
- });
129
+ ```bash
130
+ npm install
131
+ npm test # unit tests, no API key needed
132
+ npm run typecheck
133
+ npm run build
138
134
  ```
139
135
 
136
+ To release: update the version in `package.json` and [CHANGELOG.md](CHANGELOG.md), then push a tag such as `v1.1.0`. GitHub Actions tests the package, publishes it to npm and creates a GitHub release.
137
+
140
138
  ## License
141
139
 
142
- Licensed under the [MIT License](LICENSE).
140
+ [MIT](LICENSE)
@@ -1,22 +1,38 @@
1
- import { CreateSessionRequest, CreateSessionResponse, SessionScoreRequest, SessionScoreResponse, SessionLockRequest, SessionLockResponse, SessionInfoRequest, SessionInfoResponse, SessionRetrieveRequest, ExerciseValidateRequest, ExerciseInfoRequest } from './types/ApiTypes';
2
- import { SessionRetrieveResponse, ExerciseValidateResponse, ExerciseInfoResponse } from './types/ApiTypes';
1
+ import { CreateSessionRequest, CreateSessionResponse, SessionScoreRequest, SessionScoreResponse, SessionLockRequest, SessionLockResponse, SessionInfoRequest, SessionInfoResponse, SessionRetrieveRequest, SessionRetrieveResponse, ExerciseValidateRequest, ExerciseValidateResponse, ExerciseInfoRequest, ExerciseInfoResponse } from './types/ApiTypes';
2
+ /** The Algebrakit API in the default region (Ireland). */
3
+ export declare const DEFAULT_BASE_URL = "https://api.algebrakit.com";
4
+ /** Options for creating an {@link ApiClient}. */
5
+ export interface ApiClientOptions {
6
+ /** Your Algebrakit API key. Keep it on your server; never send it to the browser. */
7
+ apiKey: string;
8
+ /** Base URL of the Algebrakit API. Defaults to {@link DEFAULT_BASE_URL}. */
9
+ baseUrl?: string;
10
+ /** Request timeout in milliseconds. Defaults to 30000. */
11
+ timeout?: number;
12
+ }
3
13
  /**
4
- * ApiClient is a wrapper around Axios to interact with the Algebrakit Webservice API.
14
+ * Client for the Algebrakit web service API.
15
+ *
16
+ * @example
17
+ * const client = new ApiClient({ apiKey: process.env.ALGEBRAKIT_API_KEY! });
5
18
  */
6
19
  export declare class ApiClient {
7
- private baseUrl;
8
- private apiKey;
9
20
  private axiosInstance;
10
21
  /**
11
- * Initialize the API client with a base URL and API key.
12
- * @param baseUrl The base URL of the Algebrakit Webservice API.
13
- * @param apiKey The API key for authentication.
22
+ * Creates a client for the Algebrakit API.
23
+ * @param options The API key and, optionally, the base URL and timeout.
24
+ */
25
+ constructor(options: ApiClientOptions);
26
+ /**
27
+ * Creates a client for the Algebrakit API.
28
+ * @param baseUrl The base URL of the Algebrakit API, for example {@link DEFAULT_BASE_URL}.
29
+ * @param apiKey Your Algebrakit API key.
14
30
  */
15
31
  constructor(baseUrl: string, apiKey: string);
16
32
  /**
17
33
  * Create new exercise sessions.
18
- * @param request The request payload for creating sessions.
19
- * @returns The response containing session creation results.
34
+ * @param request The exercises to create sessions for. `apiVersion` defaults to 2.
35
+ * @returns For each exercise, whether it succeeded and the created sessions.
20
36
  */
21
37
  createSession(request: CreateSessionRequest): Promise<CreateSessionResponse>;
22
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ApiClient.d.ts","sourceRoot":"","sources":["../src/ApiClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB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nB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAG1B,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAE7D,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,aAAa,CAAgB;IAErC;;;OAGG;gBACS,OAAO,EAAE,gBAAgB;IACrC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAwB3C;;;;OAIG;IACU,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMzF;;;;OAIG;IACU,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIzF;;;;OAIG;IACU,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAInF;;;;OAIG;IACU,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAItF;;;;OAIG;IACU,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAI/F;;;;OAIG;IACU,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAIlG;;;;OAIG;IACU,wBAAwB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAGnG"}
package/dist/ApiClient.js CHANGED
@@ -1,108 +1,97 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ApiClient = void 0;
6
+ exports.ApiClient = exports.DEFAULT_BASE_URL = void 0;
16
7
  const axios_1 = __importDefault(require("axios"));
8
+ const apiErrorMessage_1 = require("./utils/apiErrorMessage");
9
+ /** The Algebrakit API in the default region (Ireland). */
10
+ exports.DEFAULT_BASE_URL = 'https://api.algebrakit.com';
17
11
  /**
18
- * ApiClient is a wrapper around Axios to interact with the Algebrakit Webservice API.
12
+ * Client for the Algebrakit web service API.
13
+ *
14
+ * @example
15
+ * const client = new ApiClient({ apiKey: process.env.ALGEBRAKIT_API_KEY! });
19
16
  */
20
17
  class ApiClient {
21
- /**
22
- * Initialize the API client with a base URL and API key.
23
- * @param baseUrl The base URL of the Algebrakit Webservice API.
24
- * @param apiKey The API key for authentication.
25
- */
26
- constructor(baseUrl, apiKey) {
27
- this.baseUrl = baseUrl;
28
- this.apiKey = apiKey;
18
+ axiosInstance;
19
+ constructor(optionsOrBaseUrl, apiKey) {
20
+ const options = typeof optionsOrBaseUrl === 'string' ? { baseUrl: optionsOrBaseUrl, apiKey: apiKey ?? '' } : optionsOrBaseUrl;
29
21
  this.axiosInstance = axios_1.default.create({
30
- baseURL: baseUrl,
22
+ baseURL: options.baseUrl ?? exports.DEFAULT_BASE_URL,
23
+ timeout: options.timeout ?? 30000,
31
24
  headers: {
32
25
  'Content-Type': 'application/json',
33
- 'x-api-key': apiKey
26
+ 'x-api-key': options.apiKey,
34
27
  },
35
28
  });
29
+ // Put the API's own error message in the error, for example
30
+ // "Algebrakit API error 401: Could not validate credentials: the provided api-key is not valid"
31
+ this.axiosInstance.interceptors.response.use(undefined, (error) => {
32
+ if (axios_1.default.isAxiosError(error) && error.response) {
33
+ error.message = `Algebrakit API error ${error.response.status}: ${(0, apiErrorMessage_1.apiErrorMessage)(error.response.data)}`;
34
+ }
35
+ return Promise.reject(error);
36
+ });
36
37
  }
37
38
  /**
38
39
  * Create new exercise sessions.
39
- * @param request The request payload for creating sessions.
40
- * @returns The response containing session creation results.
40
+ * @param request The exercises to create sessions for. `apiVersion` defaults to 2.
41
+ * @returns For each exercise, whether it succeeded and the created sessions.
41
42
  */
42
- createSession(request) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return this.axiosInstance.post('/session/create', request).then(r => r.data);
45
- });
43
+ async createSession(request) {
44
+ return this.axiosInstance
45
+ .post('/session/create', { apiVersion: 2, ...request })
46
+ .then(r => r.data);
46
47
  }
47
48
  /**
48
49
  * Retrieve results from exercise sessions.
49
50
  * @param request The request payload for retrieving session scores.
50
51
  * @returns The response containing session scores.
51
52
  */
52
- getSessionScore(request) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- return this.axiosInstance.post('/session/score', request).then(r => r.data);
55
- });
53
+ async getSessionScore(request) {
54
+ return this.axiosInstance.post('/session/score', request).then(r => r.data);
56
55
  }
57
56
  /**
58
57
  * Lock or unlock exercise sessions.
59
58
  * @param request The request payload for locking/unlocking sessions.
60
59
  * @returns The response confirming the action.
61
60
  */
62
- lockSession(request) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- return this.axiosInstance.post('/sessions/lock', request).then(r => r.data);
65
- });
61
+ async lockSession(request) {
62
+ return this.axiosInstance.post('/sessions/lock', request).then(r => r.data);
66
63
  }
67
64
  /**
68
65
  * Retrieve detailed information about a session.
69
66
  * @param request The request payload for retrieving session information.
70
67
  * @returns The response containing session details.
71
68
  */
72
- getSessionInfo(request) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- return this.axiosInstance.post('/session/info', request).then(r => r.data);
75
- });
69
+ async getSessionInfo(request) {
70
+ return this.axiosInstance.post('/session/info', request).then(r => r.data);
76
71
  }
77
72
  /**
78
73
  * Retrieve existing sessions by their IDs.
79
74
  * @param request The request payload containing session IDs.
80
75
  * @returns The response containing session data for each ID.
81
76
  */
82
- retrieveSession(request) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- return this.axiosInstance.post('/session/retrieve', request).then(r => r.data);
85
- });
77
+ async retrieveSession(request) {
78
+ return this.axiosInstance.post('/session/retrieve', request).then(r => r.data);
86
79
  }
87
80
  /**
88
81
  * Validate an exercise definition or ID.
89
82
  * @param request The request payload for exercise validation.
90
83
  * @returns The response containing validation results and details.
91
84
  */
92
- validateExercise(request) {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- return this.axiosInstance.post('/exercise/validate', request).then(r => r.data);
95
- });
85
+ async validateExercise(request) {
86
+ return this.axiosInstance.post('/exercise/validate', request).then(r => r.data);
96
87
  }
97
88
  /**
98
89
  * Retrieve published information about an exercise (structure, versions, history).
99
90
  * @param request The request payload containing the exercise ID.
100
91
  * @returns The response containing published info about the exercise.
101
92
  */
102
- getExercisePublishedInfo(request) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- return this.axiosInstance.post('/exercise/published-info', request).then(r => r.data);
105
- });
93
+ async getExercisePublishedInfo(request) {
94
+ return this.axiosInstance.post('/exercise/published-info', request).then(r => r.data);
106
95
  }
107
96
  }
108
97
  exports.ApiClient = ApiClient;
@@ -1 +1 @@
1
- {"version":3,"file":"ApiClient.js","sourceRoot":"","sources":["../src/ApiClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA6C;AAoB7C;;GAEG;AACH,MAAa,SAAS;IAGpB;;;;OAIG;IACH,YAAoB,OAAe,EAAU,MAAc;QAAvC,YAAO,GAAP,OAAO,CAAQ;QAAU,WAAM,GAAN,MAAM,CAAQ;QACzD,IAAI,CAAC,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AC,eAAe,CAAC,OAA+B;QAC1D,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAA0B,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1G,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,gBAAgB,CAAC,OAAgC;QAC5D,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAA2B,oBAAoB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC5G,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,wBAAwB,CAAC,OAA4B;QAChE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAuB,0BAA0B,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC9G,CAAC;CACF;AArGD,8BAqGC"}
@@ -1,27 +1,46 @@
1
1
  import { IAK_Exercise } from '../exercise/AK_ExerciseTypes';
2
+ /** How much feedback a student receives on their answers. */
2
3
  export type AK_StudentFeedbackType = 'ALL' | 'ICONS_ONLY' | 'ERRORS_ONLY' | 'NONE';
3
4
  export interface CreateSessionOptions {
4
5
  validate?: boolean;
5
6
  productionMode?: boolean;
7
+ /** Include debug information about the item in the response. */
6
8
  generateDebugInfo?: boolean;
7
9
  }
8
10
  export interface CreateSessionRequest {
11
+ /**
12
+ * The exercises to create sessions for. Identify each exercise in one of three ways:
13
+ * - `exerciseId` (and optionally `version`): an exercise created in the Algebrakit CMS;
14
+ * - `exerciseSpec`: a JSON specification of the exercise;
15
+ * - `sessionId`: reuse the exercise of an existing session, for example to create identical sessions from a random exercise.
16
+ */
9
17
  exercises: Array<{
18
+ /** Unique identifier of an exercise created in the Algebrakit CMS. */
10
19
  exerciseId?: string;
20
+ /** Version of the exercise, or `'latest'` (the default) for the most recent version. */
11
21
  version?: string;
22
+ /** JSON specification of the exercise, for example in the AK_Exercise format. */
12
23
  exerciseSpec?: IAK_Exercise | Record<string, unknown>;
24
+ /** Identifier of an existing session whose exercise to reuse. */
13
25
  sessionId?: string;
26
+ /** Number of sessions to create from `sessionId`. */
14
27
  nr?: number;
15
28
  }>;
16
29
  options?: CreateSessionOptions;
30
+ /** Reference to a predefined scoring model. */
17
31
  scoringModel?: string;
32
+ /** Turns off step-by-step evaluation, hints and feedback for the student. */
18
33
  assessmentMode?: boolean;
34
+ /** Prevents obtaining the solution before the session is locked. */
19
35
  requireLockForSolution?: boolean;
36
+ /** How much feedback the student receives on their answers. Defaults to `'ALL'`. */
20
37
  studentFeedbackType?: AK_StudentFeedbackType;
21
- apiVersion: 2;
38
+ /** API version. The SDK sets this to 2; you don't need to pass it. */
39
+ apiVersion?: 2;
22
40
  }
23
41
  export interface SessionScoreRequest {
24
42
  sessionId: string;
43
+ /** Lock the session, so that the student can't change it anymore. */
25
44
  lockSession?: boolean;
26
45
  }
27
46
  export interface SessionLockRequest {
@@ -1 +1 @@
1
- {"version":3,"file":"RequestTypes.d.ts","sourceRoot":"","sources":["../../../src/types/request/RequestTypes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;AAEnF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,KAAK,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA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MAAM,GAAG,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;CACZ"}
@@ -13,6 +13,7 @@ export interface SessionLockResponse {
13
13
  }
14
14
  export interface SessionInfoResponse {
15
15
  success?: boolean;
16
+ /** When the session was created, as a Unix timestamp in seconds. */
16
17
  creationTimestamp?: number;
17
18
  elements: Array<ElementInfo>;
18
19
  tagDescriptions: Record<string, TagDescription>;
@@ -1 +1 @@
1
- {"version":3,"file":"ResponseTypes.d.ts","sourceRoot":"","sources":["../../../src/types/response/ResponseTypes.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE9J,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC9B,CAAC,CAAC;AAEH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACjC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAChD,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;CAAG;AAEvC,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED,MA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;IACnC,aAAa,EAAE,sBAAsB,EAAE,CAAC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,iBAAiB,EAAE,4BAA4B,EAAE,CAAC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,uBAAuB,EAAE,CAAC;IACxC,SAAS,EAAE,oBAAoB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Extracts the error message from an Algebrakit API error response body,
3
+ * for example `{"success":false,"error":"Could not validate credentials: ..."}`.
4
+ */
5
+ export declare function apiErrorMessage(data: unknown): string;
6
+ //# sourceMappingURL=apiErrorMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiErrorMessage.d.ts","sourceRoot":"","sources":["../../src/utils/apiErrorMessage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAOrD"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiErrorMessage = apiErrorMessage;
4
+ /**
5
+ * Extracts the error message from an Algebrakit API error response body,
6
+ * for example `{"success":false,"error":"Could not validate credentials: ..."}`.
7
+ */
8
+ function apiErrorMessage(data) {
9
+ if (data && typeof data === 'object') {
10
+ const body = data;
11
+ const message = body.error ?? body.msg ?? body.message;
12
+ return typeof message === 'string' ? message : JSON.stringify(data);
13
+ }
14
+ return data === undefined || data === '' ? 'no response body' : String(data);
15
+ }
16
+ //# sourceMappingURL=apiErrorMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiErrorMessage.js","sourceRoot":"","sources":["../../src/utils/apiErrorMessage.ts"],"names":[],"mappings":";;AAIA,0CAOC;AAXD;;;GAGG;AACH,SAAgB,eAAe,CAAC,IAAa;IAC3C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAA6D,CAAC;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC;QACvD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/E,CAAC"}
@@ -1,8 +1,7 @@
1
- import { AxiosError } from 'axios';
2
1
  /**
3
- * Handles errors from Axios requests and provides a standardized error message.
4
- * @param error The Axios error object.
5
- * @returns A standardized error message.
2
+ * Turns an error from an {@link ApiClient} call into a readable message.
3
+ * @param error The error thrown by an `ApiClient` method.
4
+ * @returns A message such as `API Error: 401 - Could not validate credentials: the provided api-key is not valid`.
6
5
  */
7
- export declare function handleApiError(error: AxiosError): string;
6
+ export declare function handleApiError(error: unknown): string;
8
7
  //# sourceMappingURL=errorHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAWxD"}
1
+ {"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandler.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAarD"}