@smartico/public-api 0.0.362 → 0.0.363
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/dist/Avatars/GetAvatarPromptsResponse.d.ts +2 -0
- package/dist/Avatars/GetAvatarsCustomizedResponse.d.ts +2 -0
- package/dist/Avatars/GetAvatarsListResponse.d.ts +2 -0
- package/dist/SmarticoAPI.d.ts +8 -2
- package/dist/WSAPI/WSAPI.d.ts +2 -2
- package/dist/WSAPI/WSAPITypes.d.ts +14 -18
- package/dist/index.js +111 -57
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +56 -26
- package/dist/index.modern.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Avatars/GetAvatarPromptsResponse.ts +11 -0
- package/src/Avatars/GetAvatarsCustomizedResponse.ts +9 -0
- package/src/Avatars/GetAvatarsListResponse.ts +18 -0
- package/src/SmarticoAPI.ts +19 -1
- package/src/WSAPI/WSAPI.ts +5 -19
- package/src/WSAPI/WSAPITypes.ts +14 -18
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import { TAvatarPrompt } from '../WSAPI/WSAPITypes';
|
|
1
2
|
import { ProtocolResponse } from '../Base/ProtocolResponse';
|
|
2
3
|
import { AvatarPrompt } from './AvatarPrompt';
|
|
3
4
|
|
|
4
5
|
export interface GetAvatarPromptsResponse extends ProtocolResponse {
|
|
5
6
|
prompts: AvatarPrompt[];
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
export const avatarPromptTransform = (items: AvatarPrompt[], avatarDomain: string): TAvatarPrompt[] => {
|
|
10
|
+
return items.map((item) => ({
|
|
11
|
+
prompt_id: item.prompt_id,
|
|
12
|
+
name: item.public_meta.name,
|
|
13
|
+
icon_url: item.public_meta.icon_url && !item.public_meta.icon_url.startsWith('http') ? `${avatarDomain}${item.public_meta.icon_url}` : item.public_meta.icon_url,
|
|
14
|
+
cost_currency_type_id: item.cost_currency_type_id,
|
|
15
|
+
cost_value: item.cost_value,
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { TAvatarCustomized } from '../WSAPI/WSAPITypes';
|
|
1
2
|
import { ProtocolResponse } from '../Base/ProtocolResponse';
|
|
2
3
|
import { AvatarCustomized } from './AvatarCustomized';
|
|
3
4
|
|
|
4
5
|
export interface GetAvatarsCustomizedResponse extends ProtocolResponse {
|
|
5
6
|
avatars: AvatarCustomized[];
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
export const avatarCustomizedTransform = (items: AvatarCustomized[], avatarDomain: string): TAvatarCustomized[] => {
|
|
10
|
+
return items.map((item) => ({
|
|
11
|
+
avatar_real_id: item.avatar_real_id,
|
|
12
|
+
url: item.url && !item.url.startsWith('http') ? `${avatarDomain}${item.url}` : item.url,
|
|
13
|
+
dt_created: item.dt_created,
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
+
import { TAvatarDefinition } from '../WSAPI/WSAPITypes';
|
|
1
2
|
import { ProtocolResponse } from '../Base/ProtocolResponse';
|
|
2
3
|
import { AvatarDefinition } from './AvatarDefinition';
|
|
3
4
|
|
|
4
5
|
export interface GetAvatarsListResponse extends ProtocolResponse {
|
|
5
6
|
avatars: AvatarDefinition[];
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
export const avatarDefinitionTransform = (items: AvatarDefinition[], avatarDomain: string): TAvatarDefinition[] => {
|
|
10
|
+
return items.map((item) => ({
|
|
11
|
+
avatar_real_id: item.avatar_real_id,
|
|
12
|
+
is_default: item.is_default,
|
|
13
|
+
hide_until_achieved: item.hide_until_achieved,
|
|
14
|
+
priority: item.priority,
|
|
15
|
+
description: item.public_meta.description,
|
|
16
|
+
url: item.public_meta.url,
|
|
17
|
+
avatar_url: item.public_meta.url && !item.public_meta.url.startsWith('http') ? `${avatarDomain}${item.public_meta.url}` : item.public_meta.url,
|
|
18
|
+
avatar_source_type_id: item.avatar_source_type_id,
|
|
19
|
+
active_from_date: item.active_from_date,
|
|
20
|
+
active_till_date: item.active_till_date,
|
|
21
|
+
is_given: item.is_given,
|
|
22
|
+
is_in_use: item.is_in_use,
|
|
23
|
+
}));
|
|
24
|
+
};
|
package/src/SmarticoAPI.ts
CHANGED
|
@@ -100,6 +100,9 @@ import {
|
|
|
100
100
|
TLevelCurrent,
|
|
101
101
|
TActivityLog,
|
|
102
102
|
TRaffleDraw,
|
|
103
|
+
TAvatarDefinition,
|
|
104
|
+
TAvatarCustomized,
|
|
105
|
+
TAvatarPrompt,
|
|
103
106
|
} from './WSAPI/WSAPITypes';
|
|
104
107
|
import { getLeaderBoardTransform } from './Leaderboard/LeaderBoards';
|
|
105
108
|
import { GetAchievementsUserInfoResponse } from './Core/GetAchievementsUserInfoResponse';
|
|
@@ -129,7 +132,10 @@ import { GetRafflesRequest } from './Raffle/GetRafflesRequest';
|
|
|
129
132
|
import { GetActivityLogRequest, GetActivityLogResponse, ActivityLogTransform } from './ActivityLog';
|
|
130
133
|
import { InboxCategories } from './Inbox/InboxCategories';
|
|
131
134
|
import { GetDrawRunRequest, GetDrawRunResponse, GetRaffleDrawRunsHistoryRequest, GetRaffleDrawRunsHistoryResponse, RaffleClaimPrizeRequest, RaffleClaimPrizeResponse, RaffleOptinRequest, RaffleOptinResponse, drawRunTransform } from './Raffle';
|
|
132
|
-
import { GetAvatarsListResponse,
|
|
135
|
+
import { GetAvatarsListResponse, avatarDefinitionTransform } from './Avatars/GetAvatarsListResponse';
|
|
136
|
+
import { GetAvatarsCustomizedResponse, avatarCustomizedTransform } from './Avatars/GetAvatarsCustomizedResponse';
|
|
137
|
+
import { GetAvatarPromptsResponse, avatarPromptTransform } from './Avatars/GetAvatarPromptsResponse';
|
|
138
|
+
import { SetAvatarRequest, SetAvatarResponse } from './Avatars';
|
|
133
139
|
import { GetJackpotWinnersResponse, GetJackpotWinnersResponseTransform, JackpotWinnerHistory } from './Jackpots/GetJackpotWinnersResponse';
|
|
134
140
|
import { GetJackpotWinnersRequest } from './Jackpots/GetJackpotWinnersRequest';
|
|
135
141
|
import { GetJackpotEligibleGamesRequest } from './Jackpots/GetJackpotEligibleGamesRequest';
|
|
@@ -1443,6 +1449,18 @@ class SmarticoAPI {
|
|
|
1443
1449
|
return await this.send<SetAvatarResponse>(message, ClassId.CLIENT_SET_AVATAR_RESPONSE);
|
|
1444
1450
|
}
|
|
1445
1451
|
|
|
1452
|
+
public async avatarsGetListT(user_ext_id: string): Promise<TAvatarDefinition[]> {
|
|
1453
|
+
return avatarDefinitionTransform((await this.avatarsGetList(user_ext_id)).avatars ?? [], this.avatarDomain);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
public async avatarsGetCustomizedT(user_ext_id: string): Promise<TAvatarCustomized[]> {
|
|
1457
|
+
return avatarCustomizedTransform((await this.avatarsGetCustomized(user_ext_id)).avatars ?? [], this.avatarDomain);
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
public async avatarsGetPromptsT(user_ext_id: string): Promise<TAvatarPrompt[]> {
|
|
1461
|
+
return avatarPromptTransform((await this.avatarsGetPrompts(user_ext_id)).prompts ?? [], this.avatarDomain);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1446
1464
|
public getWSCalls(): WSAPI {
|
|
1447
1465
|
return new WSAPI(this);
|
|
1448
1466
|
}
|
package/src/WSAPI/WSAPI.ts
CHANGED
|
@@ -1471,15 +1471,7 @@ export class WSAPI {
|
|
|
1471
1471
|
return OCache.use(
|
|
1472
1472
|
onUpdateContextKey.AvatarsList,
|
|
1473
1473
|
ECacheContext.WSAPI,
|
|
1474
|
-
|
|
1475
|
-
const response = await this.api.avatarsGetList(this.userExtId);
|
|
1476
|
-
return (response.avatars || []).map((a) => ({
|
|
1477
|
-
...a,
|
|
1478
|
-
avatar_url: this.api.avatarDomain && a.public_meta?.url
|
|
1479
|
-
? (a.public_meta.url.startsWith('http') ? a.public_meta.url : `${this.api.avatarDomain}${a.public_meta.url}`)
|
|
1480
|
-
: (a.public_meta?.url || ''),
|
|
1481
|
-
}));
|
|
1482
|
-
},
|
|
1474
|
+
() => this.api.avatarsGetListT(this.userExtId),
|
|
1483
1475
|
CACHE_DATA_SEC,
|
|
1484
1476
|
);
|
|
1485
1477
|
}
|
|
@@ -1502,10 +1494,7 @@ export class WSAPI {
|
|
|
1502
1494
|
return OCache.use(
|
|
1503
1495
|
onUpdateContextKey.AvatarsCustomized,
|
|
1504
1496
|
ECacheContext.WSAPI,
|
|
1505
|
-
|
|
1506
|
-
const response = await this.api.avatarsGetCustomized(this.userExtId);
|
|
1507
|
-
return response.avatars || [];
|
|
1508
|
-
},
|
|
1497
|
+
() => this.api.avatarsGetCustomizedT(this.userExtId),
|
|
1509
1498
|
CACHE_DATA_SEC,
|
|
1510
1499
|
);
|
|
1511
1500
|
}
|
|
@@ -1528,17 +1517,14 @@ export class WSAPI {
|
|
|
1528
1517
|
return OCache.use(
|
|
1529
1518
|
onUpdateContextKey.AvatarPrompts,
|
|
1530
1519
|
ECacheContext.WSAPI,
|
|
1531
|
-
|
|
1532
|
-
const response = await this.api.avatarsGetPrompts(this.userExtId);
|
|
1533
|
-
return response.prompts || [];
|
|
1534
|
-
},
|
|
1520
|
+
() => this.api.avatarsGetPromptsT(this.userExtId),
|
|
1535
1521
|
CACHE_DATA_SEC,
|
|
1536
1522
|
);
|
|
1537
1523
|
}
|
|
1538
1524
|
|
|
1539
1525
|
/**
|
|
1540
1526
|
* Sets the specified avatar as the active avatar for the current user.
|
|
1541
|
-
* Pass `avatar_url` (the
|
|
1527
|
+
* Pass `avatar_url` (the `TAvatarDefinition.url` path or a CDN URL for AI-customized avatars)
|
|
1542
1528
|
* and `avatar_real_id` from the avatar catalog.
|
|
1543
1529
|
* After a successful call, the avatar list cache is cleared so the next `getAvatarsList()` call reflects `is_in_use`.
|
|
1544
1530
|
*
|
|
@@ -1548,7 +1534,7 @@ export class WSAPI {
|
|
|
1548
1534
|
* const avatar = avatars.find((a) => !a.hide_until_achieved || a.is_given);
|
|
1549
1535
|
* if (avatar) {
|
|
1550
1536
|
* _smartico.api.setAvatar({
|
|
1551
|
-
* avatar_url: avatar.
|
|
1537
|
+
* avatar_url: avatar.url,
|
|
1552
1538
|
* avatar_real_id: avatar.avatar_real_id,
|
|
1553
1539
|
* }).then((result) => {
|
|
1554
1540
|
* console.log(result);
|
package/src/WSAPI/WSAPITypes.ts
CHANGED
|
@@ -1881,7 +1881,8 @@ export interface GamePickRoundRequestParams extends GamePickRequestParams {
|
|
|
1881
1881
|
}
|
|
1882
1882
|
|
|
1883
1883
|
/**
|
|
1884
|
-
* TAvatarDefinition describes a single avatar available in the avatar catalog
|
|
1884
|
+
* TAvatarDefinition describes a single avatar available in the avatar catalog.
|
|
1885
|
+
* Fields from the raw `public_meta` object are flattened to the top level.
|
|
1885
1886
|
*/
|
|
1886
1887
|
export interface TAvatarDefinition {
|
|
1887
1888
|
/** Unique identifier of the avatar */
|
|
@@ -1892,13 +1893,12 @@ export interface TAvatarDefinition {
|
|
|
1892
1893
|
hide_until_achieved: boolean;
|
|
1893
1894
|
/** Display priority — lower value means higher position in the grid */
|
|
1894
1895
|
priority: number;
|
|
1895
|
-
/**
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
};
|
|
1896
|
+
/** Optional description of the avatar (from public_meta) */
|
|
1897
|
+
description?: string;
|
|
1898
|
+
/** Raw image path/URL of the avatar as returned by the server (from public_meta) */
|
|
1899
|
+
url: string;
|
|
1900
|
+
/** Full CDN URL of the avatar image, built from avatar_domain + url */
|
|
1901
|
+
avatar_url: string;
|
|
1902
1902
|
/**
|
|
1903
1903
|
* Source type of the avatar.
|
|
1904
1904
|
* 0 = free (always available to all users), other values = earned/purchased
|
|
@@ -1912,8 +1912,6 @@ export interface TAvatarDefinition {
|
|
|
1912
1912
|
is_given: boolean;
|
|
1913
1913
|
/** Whether this avatar is currently in use by the user */
|
|
1914
1914
|
is_in_use?: boolean;
|
|
1915
|
-
/** Full CDN URL of the avatar image, built from avatar_domain + public_meta.url */
|
|
1916
|
-
avatar_url: string;
|
|
1917
1915
|
}
|
|
1918
1916
|
|
|
1919
1917
|
/**
|
|
@@ -1929,18 +1927,16 @@ export interface TAvatarCustomized {
|
|
|
1929
1927
|
}
|
|
1930
1928
|
|
|
1931
1929
|
/**
|
|
1932
|
-
* TAvatarPrompt describes an AI style prompt available for avatar customization
|
|
1930
|
+
* TAvatarPrompt describes an AI style prompt available for avatar customization.
|
|
1931
|
+
* Fields from the raw `public_meta` object are flattened to the top level.
|
|
1933
1932
|
*/
|
|
1934
1933
|
export interface TAvatarPrompt {
|
|
1935
1934
|
/** Unique identifier of the AI customization prompt */
|
|
1936
1935
|
prompt_id: number;
|
|
1937
|
-
/**
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
/** URL of the prompt style icon image */
|
|
1942
|
-
icon_url: string;
|
|
1943
|
-
};
|
|
1936
|
+
/** Display name of the prompt style, e.g. "Cartoon", "Watercolor" (from public_meta) */
|
|
1937
|
+
name: string;
|
|
1938
|
+
/** Full CDN URL of the prompt style icon image (from public_meta) */
|
|
1939
|
+
icon_url: string;
|
|
1944
1940
|
/** Currency type used to pay for this customization (0=points, 1=gems, 2=diamonds) */
|
|
1945
1941
|
cost_currency_type_id: number;
|
|
1946
1942
|
/** Cost amount in the given currency */
|