@algebrakit/sdk 1.0.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/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/ApiClient.d.ts +59 -0
- package/dist/ApiClient.d.ts.map +1 -0
- package/dist/ApiClient.js +109 -0
- package/dist/ApiClient.js.map +1 -0
- package/dist/demo/config.js +63 -0
- package/dist/demo/demo.js +373 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/src/ApiClient.js +108 -0
- package/dist/src/index.js +18 -0
- package/dist/src/types/ApiTypes.js +23 -0
- package/dist/src/types/exercise/AK_ExerciseTypes.js +5 -0
- package/dist/src/types/request/RequestTypes.js +3 -0
- package/dist/src/types/response/ResponseTypes.js +2 -0
- package/dist/src/types/shared/SharedTypes.js +3 -0
- package/dist/src/utils/errorHandler.js +22 -0
- package/dist/types/ApiTypes.d.ts +8 -0
- package/dist/types/ApiTypes.d.ts.map +1 -0
- package/dist/types/ApiTypes.js +24 -0
- package/dist/types/ApiTypes.js.map +1 -0
- package/dist/types/exercise/AK_ExerciseTypes.d.ts +191 -0
- package/dist/types/exercise/AK_ExerciseTypes.d.ts.map +1 -0
- package/dist/types/exercise/AK_ExerciseTypes.js +6 -0
- package/dist/types/exercise/AK_ExerciseTypes.js.map +1 -0
- package/dist/types/request/RequestTypes.d.ts +45 -0
- package/dist/types/request/RequestTypes.d.ts.map +1 -0
- package/dist/types/request/RequestTypes.js +4 -0
- package/dist/types/request/RequestTypes.js.map +1 -0
- package/dist/types/response/ResponseTypes.d.ts +63 -0
- package/dist/types/response/ResponseTypes.d.ts.map +1 -0
- package/dist/types/response/ResponseTypes.js +3 -0
- package/dist/types/response/ResponseTypes.js.map +1 -0
- package/dist/types/shared/SharedTypes.d.ts +137 -0
- package/dist/types/shared/SharedTypes.d.ts.map +1 -0
- package/dist/types/shared/SharedTypes.js +4 -0
- package/dist/types/shared/SharedTypes.js.map +1 -0
- package/dist/utils/errorHandler.d.ts +8 -0
- package/dist/utils/errorHandler.d.ts.map +1 -0
- package/dist/utils/errorHandler.js +23 -0
- package/dist/utils/errorHandler.js.map +1 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Algebrakit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Algebrakit Webservice API SDK
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @algebrakit/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires Node.js 18 or newer.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Initialize the API Client
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { ApiClient } from '@algebrakit/sdk';
|
|
19
|
+
|
|
20
|
+
const apiClient = new ApiClient('https://api.algebrakit.com', 'your-api-key');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Create a Session
|
|
24
|
+
|
|
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);
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Retrieve Session Scores
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { SessionScoreRequest } from '@algebrakit/sdk';
|
|
46
|
+
|
|
47
|
+
const request: SessionScoreRequest = {
|
|
48
|
+
sessionId: '0a405901-8b89-4665-9ea0-6dbdff3602fc',
|
|
49
|
+
lockSession: true,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
apiClient.getSessionScore(request).then(response => {
|
|
53
|
+
console.log('Session scores:', response);
|
|
54
|
+
}).catch(error => {
|
|
55
|
+
console.error('Error retrieving scores:', error);
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Lock or Unlock Sessions
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { SessionLockRequest } from '@algebrakit/sdk';
|
|
63
|
+
|
|
64
|
+
const request: SessionLockRequest = {
|
|
65
|
+
action: 'LOCK',
|
|
66
|
+
sessionIds: ['f2f62104-3b5a-4156-aeaf-291167e5f9e3'],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
apiClient.lockSession(request).then(response => {
|
|
70
|
+
console.log('Session locked:', response);
|
|
71
|
+
}).catch(error => {
|
|
72
|
+
console.error('Error locking session:', error);
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Retrieve Session Information
|
|
77
|
+
|
|
78
|
+
```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
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Running the Demos
|
|
93
|
+
|
|
94
|
+
Each demo lives in its own folder under `demo/` with its own configuration.
|
|
95
|
+
|
|
96
|
+
### CLI Demo (`demo/cli/`)
|
|
97
|
+
|
|
98
|
+
Demonstrates SDK API calls with text output.
|
|
99
|
+
|
|
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
|
+
```
|
|
105
|
+
|
|
106
|
+
2. Run the demo:
|
|
107
|
+
```bash
|
|
108
|
+
npm run demo
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Web Demo (`demo/play-exercise/`)
|
|
112
|
+
|
|
113
|
+
Renders a working Algebrakit exercise in the browser with learning event logging.
|
|
114
|
+
|
|
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
|
+
```
|
|
120
|
+
|
|
121
|
+
2. Run the web demo:
|
|
122
|
+
```bash
|
|
123
|
+
npm run play-exercise
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
3. Open `http://localhost:3000` in your browser.
|
|
127
|
+
|
|
128
|
+
## Error Handling
|
|
129
|
+
|
|
130
|
+
Use the `handleApiError` utility to standardize error messages:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { handleApiError } from '@algebrakit/sdk';
|
|
134
|
+
|
|
135
|
+
apiClient.createSession(request).catch(error => {
|
|
136
|
+
console.error(handleApiError(error));
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## License
|
|
141
|
+
|
|
142
|
+
Licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { CreateSessionRequest, CreateSessionResponse, SessionScoreRequest, SessionScoreResponse, SessionLockRequest, SessionLockResponse, SessionInfoRequest, SessionInfoResponse, SessionRetrieveRequest, ExerciseValidateRequest, ExerciseInfoRequest } from './types/ApiTypes';
|
|
2
|
+
import { SessionRetrieveResponse, ExerciseValidateResponse, ExerciseInfoResponse } from './types/ApiTypes';
|
|
3
|
+
/**
|
|
4
|
+
* ApiClient is a wrapper around Axios to interact with the Algebrakit Webservice API.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ApiClient {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private apiKey;
|
|
9
|
+
private axiosInstance;
|
|
10
|
+
/**
|
|
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.
|
|
14
|
+
*/
|
|
15
|
+
constructor(baseUrl: string, apiKey: string);
|
|
16
|
+
/**
|
|
17
|
+
* Create new exercise sessions.
|
|
18
|
+
* @param request The request payload for creating sessions.
|
|
19
|
+
* @returns The response containing session creation results.
|
|
20
|
+
*/
|
|
21
|
+
createSession(request: CreateSessionRequest): Promise<CreateSessionResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve results from exercise sessions.
|
|
24
|
+
* @param request The request payload for retrieving session scores.
|
|
25
|
+
* @returns The response containing session scores.
|
|
26
|
+
*/
|
|
27
|
+
getSessionScore(request: SessionScoreRequest): Promise<SessionScoreResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Lock or unlock exercise sessions.
|
|
30
|
+
* @param request The request payload for locking/unlocking sessions.
|
|
31
|
+
* @returns The response confirming the action.
|
|
32
|
+
*/
|
|
33
|
+
lockSession(request: SessionLockRequest): Promise<SessionLockResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieve detailed information about a session.
|
|
36
|
+
* @param request The request payload for retrieving session information.
|
|
37
|
+
* @returns The response containing session details.
|
|
38
|
+
*/
|
|
39
|
+
getSessionInfo(request: SessionInfoRequest): Promise<SessionInfoResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve existing sessions by their IDs.
|
|
42
|
+
* @param request The request payload containing session IDs.
|
|
43
|
+
* @returns The response containing session data for each ID.
|
|
44
|
+
*/
|
|
45
|
+
retrieveSession(request: SessionRetrieveRequest): Promise<SessionRetrieveResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Validate an exercise definition or ID.
|
|
48
|
+
* @param request The request payload for exercise validation.
|
|
49
|
+
* @returns The response containing validation results and details.
|
|
50
|
+
*/
|
|
51
|
+
validateExercise(request: ExerciseValidateRequest): Promise<ExerciseValidateResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieve published information about an exercise (structure, versions, history).
|
|
54
|
+
* @param request The request payload containing the exercise ID.
|
|
55
|
+
* @returns The response containing published info about the exercise.
|
|
56
|
+
*/
|
|
57
|
+
getExercisePublishedInfo(request: ExerciseInfoRequest): Promise<ExerciseInfoResponse>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ApiClient.d.ts.map
|
|
@@ -0,0 +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,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,qBAAa,SAAS;IAQR,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,MAAM;IAPnD,OAAO,CAAC,aAAa,CAAgB;IAErC;;;;OAIG;gBACiB,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM;IAU3D;;;;OAIG;IACU,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIzF;;;;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"}
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ApiClient = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
/**
|
|
18
|
+
* ApiClient is a wrapper around Axios to interact with the Algebrakit Webservice API.
|
|
19
|
+
*/
|
|
20
|
+
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;
|
|
29
|
+
this.axiosInstance = axios_1.default.create({
|
|
30
|
+
baseURL: baseUrl,
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
'x-api-key': apiKey
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create new exercise sessions.
|
|
39
|
+
* @param request The request payload for creating sessions.
|
|
40
|
+
* @returns The response containing session creation results.
|
|
41
|
+
*/
|
|
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
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieve results from exercise sessions.
|
|
49
|
+
* @param request The request payload for retrieving session scores.
|
|
50
|
+
* @returns The response containing session scores.
|
|
51
|
+
*/
|
|
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
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Lock or unlock exercise sessions.
|
|
59
|
+
* @param request The request payload for locking/unlocking sessions.
|
|
60
|
+
* @returns The response confirming the action.
|
|
61
|
+
*/
|
|
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
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Retrieve detailed information about a session.
|
|
69
|
+
* @param request The request payload for retrieving session information.
|
|
70
|
+
* @returns The response containing session details.
|
|
71
|
+
*/
|
|
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
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve existing sessions by their IDs.
|
|
79
|
+
* @param request The request payload containing session IDs.
|
|
80
|
+
* @returns The response containing session data for each ID.
|
|
81
|
+
*/
|
|
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
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate an exercise definition or ID.
|
|
89
|
+
* @param request The request payload for exercise validation.
|
|
90
|
+
* @returns The response containing validation results and details.
|
|
91
|
+
*/
|
|
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
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve published information about an exercise (structure, versions, history).
|
|
99
|
+
* @param request The request payload containing the exercise ID.
|
|
100
|
+
* @returns The response containing published info about the exercise.
|
|
101
|
+
*/
|
|
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
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.ApiClient = ApiClient;
|
|
109
|
+
//# sourceMappingURL=ApiClient.js.map
|
|
@@ -0,0 +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,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,MAAM;aACpB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACU,aAAa,CAAC,OAA6B;;YACtD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAwB,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtG,CAAC;KAAA;IAED;;;;OAIG;IACU,eAAe,CAAC,OAA4B;;YACvD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAuB,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACpG,CAAC;KAAA;IAED;;;;OAIG;IACU,WAAW,CAAC,OAA2B;;YAClD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAsB,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACnG,CAAC;KAAA;IAED;;;;OAIG;IACU,cAAc,CAAC,OAA2B;;YACrD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAsB,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAClG,CAAC;KAAA;IAED;;;;OAIG;IACU,eAAe,CAAC,OAA+B;;YAC1D,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAA0B,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1G,CAAC;KAAA;IAED;;;;OAIG;IACU,gBAAgB,CAAC,OAAgC;;YAC5D,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAA2B,oBAAoB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC5G,CAAC;KAAA;IAED;;;;OAIG;IACU,wBAAwB,CAAC,OAA4B;;YAChE,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAuB,0BAA0B,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9G,CAAC;KAAA;CACF;AAhFD,8BAgFC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadConfig = loadConfig;
|
|
37
|
+
const dotenv = __importStar(require("dotenv"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
// Load environment variables from .env file
|
|
40
|
+
dotenv.config({ path: path.join(__dirname, '.env') });
|
|
41
|
+
/**
|
|
42
|
+
* Loads and validates configuration from environment variables
|
|
43
|
+
*/
|
|
44
|
+
function loadConfig() {
|
|
45
|
+
const apiKey = process.env.ALGEBRAKIT_API_KEY;
|
|
46
|
+
const apiUrl = process.env.ALGEBRAKIT_API_URL || 'https://api.algebrakit.com';
|
|
47
|
+
// Validate configuration
|
|
48
|
+
if (!apiKey) {
|
|
49
|
+
console.error('\n❌ Error: ALGEBRAKIT_API_KEY is not set');
|
|
50
|
+
console.error('Please create a .env file in the demo directory with your API key.');
|
|
51
|
+
console.error('You can copy .env.example to .env and add your key.\n');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
if (apiKey === 'your_api_key_here') {
|
|
55
|
+
console.error('\n❌ Error: Please replace the placeholder API key with your actual key');
|
|
56
|
+
console.error('Edit the .env file and add your real Algebrakit API key.\n');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
apiKey,
|
|
61
|
+
apiUrl
|
|
62
|
+
};
|
|
63
|
+
}
|