@smartico/public-api 0.0.46 → 0.0.47
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/.nvmrc +1 -1
- package/README.md +4 -1
- package/dist/SmarticoAPI.d.ts +4 -2
- package/dist/WSAPI/WSAPI.d.ts +9 -0
- package/dist/WSAPI/WSAPITypes.d.ts +13 -0
- package/dist/index.js +38 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +31 -2
- package/dist/index.modern.mjs.map +1 -1
- package/docs_test/.nojekyll +1 -0
- package/docs_test/README_TWO.md +57 -0
- package/docs_test/classes/WSAPI.md +19 -0
- package/docs_test/interfaces/GetLevelMapClearedResponse.md +57 -0
- package/docs_test/modules.md +13 -0
- package/package.json +7 -3
- package/src/SmarticoAPI.ts +9 -5
- package/src/WSAPI/WSAPI.ts +18 -0
- package/src/WSAPI/WSAPITypes.ts +29 -0
- package/tsconfig.json +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartico/public-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"description": "Smartico public API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"bump-tracker": "cd ../tracker && npm install @smartico/public-api@latest --legacy-peer-deps",
|
|
24
24
|
"bump-ach": "cd ../tracker/ach && npm install @smartico/public-api@latest --legacy-peer-deps",
|
|
25
25
|
"bump-bo-server": "cd ../bo_server/server && source ~/.nvm/nvm.sh && nvm use v13.13.0 && npm install @smartico/public-api@latest",
|
|
26
|
-
"bump-bo-client": "cd ../bo_server/client && source ~/.nvm/nvm.sh && nvm use v13.13.0 && npm install @smartico/public-api@latest"
|
|
26
|
+
"bump-bo-client": "cd ../bo_server/client && source ~/.nvm/nvm.sh && nvm use v13.13.0 && npm install @smartico/public-api@latest",
|
|
27
|
+
"doc": "typedoc"
|
|
27
28
|
},
|
|
28
29
|
"author": "",
|
|
29
30
|
"license": "ISC",
|
|
@@ -34,6 +35,9 @@
|
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/node-fetch": "^2.6.2",
|
|
36
37
|
"microbundle": "0.15.0",
|
|
37
|
-
"npm-run-all": "4.1.5"
|
|
38
|
+
"npm-run-all": "4.1.5",
|
|
39
|
+
"typedoc": "^0.24.8",
|
|
40
|
+
"typedoc-plugin-markdown": "^3.15.4",
|
|
41
|
+
"typedoc-plugin-merge-modules": "^5.0.1"
|
|
38
42
|
}
|
|
39
43
|
}
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { AchievementType, GetAchievementMapRequest, GetAchievementMapResponse }
|
|
|
16
16
|
import { GetTournamentInfoRequest, GetTournamentInfoResponse, GetTournamentsRequest, GetTournamentsResponse } from './Tournaments';
|
|
17
17
|
import { GetLeaderBoardsRequest, GetLeaderBoardsResponse, LeaderBoardDetails, LeaderBoardPeriodType } from "./Leaderboard";
|
|
18
18
|
import { GetLevelMapResponse } from "./Level";
|
|
19
|
-
|
|
19
|
+
import { WSAPI } from "./WSAPI/WSAPI";
|
|
20
20
|
|
|
21
21
|
const PUBLIC_API_URL = 'https://papi{ENV_ID}.smartico.ai/services/public';
|
|
22
22
|
const C_SOCKET_PROD = 'wss://api{ENV_ID}.smartico.ai/websocket/services';
|
|
@@ -29,7 +29,7 @@ interface IOptions {
|
|
|
29
29
|
logHTTPTiming?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
type MessageSender = (message: any, publicApuUrl
|
|
32
|
+
type MessageSender = (message: any, publicApuUrl?: string, expectCID?: ClassId) => Promise<any>;
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class SmarticoAPI {
|
|
@@ -101,7 +101,7 @@ class SmarticoAPI {
|
|
|
101
101
|
|
|
102
102
|
try {
|
|
103
103
|
const timeStart = new Date().getTime();
|
|
104
|
-
result = await this.messageSender(message, this.publicUrl);
|
|
104
|
+
result = await this.messageSender(message, this.publicUrl, expectCID);
|
|
105
105
|
const timeEnd = new Date().getTime();
|
|
106
106
|
|
|
107
107
|
if (this.logHTTPTiming) {
|
|
@@ -410,9 +410,13 @@ class SmarticoAPI {
|
|
|
410
410
|
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
public async levelsGet(user_ext_id
|
|
413
|
+
public async levelsGet(user_ext_id?: string ): Promise<GetLevelMapResponse> {
|
|
414
414
|
const message = this.buildMessage<any, GetLevelMapResponse>(user_ext_id, ClassId.GET_LEVEL_MAP_REQUEST);
|
|
415
|
-
return await this.send<GetLevelMapResponse>(message);
|
|
415
|
+
return await this.send<GetLevelMapResponse>(message, ClassId.GET_LEVEL_MAP_RESPONSE);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
public getWSCalls(): WSAPI {
|
|
419
|
+
return new WSAPI(this);
|
|
416
420
|
}
|
|
417
421
|
|
|
418
422
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SmarticoAPI } from "../SmarticoAPI";
|
|
2
|
+
|
|
3
|
+
import { GetLevelMapClearedResponse, levelCleaner } from "./WSAPITypes";
|
|
4
|
+
|
|
5
|
+
/** @group General API */
|
|
6
|
+
export class WSAPI {
|
|
7
|
+
private static api: SmarticoAPI;
|
|
8
|
+
|
|
9
|
+
/** @private */
|
|
10
|
+
constructor(api: SmarticoAPI) {
|
|
11
|
+
WSAPI.api = api;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public async getLevelsTransformed(): Promise<GetLevelMapClearedResponse[]> {
|
|
15
|
+
const levels = await WSAPI.api.levelsGet(null);
|
|
16
|
+
return levelCleaner(levels);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GetLevelMapResponse } from "../Level"
|
|
2
|
+
|
|
3
|
+
// Levels
|
|
4
|
+
|
|
5
|
+
/** @group Levels response */
|
|
6
|
+
export interface GetLevelMapClearedResponse {
|
|
7
|
+
|
|
8
|
+
id: number,
|
|
9
|
+
name: string,
|
|
10
|
+
description: string,
|
|
11
|
+
image: string,
|
|
12
|
+
required_points: number,
|
|
13
|
+
required_level_counter_1: number,
|
|
14
|
+
required_level_counter_2: number,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @hidden */
|
|
18
|
+
export const levelCleaner = (levels: GetLevelMapResponse): GetLevelMapClearedResponse[] => {
|
|
19
|
+
|
|
20
|
+
return levels?.levels.map((l => ({
|
|
21
|
+
id: l.level_id,
|
|
22
|
+
name: l.level_public_meta.name,
|
|
23
|
+
description: l.level_public_meta.description,
|
|
24
|
+
image: l.level_public_meta.image_url,
|
|
25
|
+
required_points: l.required_points,
|
|
26
|
+
required_level_counter_1: l.required_level_counter_1,
|
|
27
|
+
required_level_counter_2: l.required_level_counter_2,
|
|
28
|
+
})));
|
|
29
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
},
|
|
13
13
|
"include": [
|
|
14
14
|
"src/**/*"
|
|
15
|
-
]
|
|
15
|
+
],
|
|
16
|
+
"typedocOptions": {
|
|
17
|
+
"name": "Smartico API documentation",
|
|
18
|
+
"entryPoints": ["src/WSAPI/WSAPI.ts", "src/WSAPI/WSAPITypes.ts"],
|
|
19
|
+
"out": "docs_test",
|
|
20
|
+
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-merge-modules"],
|
|
21
|
+
"entryDocument": "README_TWO.md",
|
|
22
|
+
"disableSources": true,
|
|
23
|
+
"excludePrivate": true,
|
|
24
|
+
}
|
|
16
25
|
}
|
|
17
26
|
|