@smartico/public-api 0.0.386 → 0.0.387

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.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/dist/Avatars/AvatarCustomizeErrorCode.d.ts +7 -1
  3. package/dist/Avatars/AvatarCustomizeResponse.d.ts +16 -0
  4. package/dist/Avatars/index.d.ts +1 -0
  5. package/dist/Missions/UserAchievementTask.d.ts +4 -0
  6. package/dist/SmarticoAPI.d.ts +11 -0
  7. package/dist/WSAPI/WSAPIAvatars.d.ts +103 -0
  8. package/dist/WSAPI/WSAPITypes.d.ts +6 -2
  9. package/dist/index.js +260 -78
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.modern.mjs +168 -6
  12. package/dist/index.modern.mjs.map +1 -1
  13. package/docs/SmarticoObject.md +15 -0
  14. package/docs/api/README.md +2 -0
  15. package/docs/api/classes/WSAPIAvatars.md +135 -0
  16. package/docs/api/classes/WSAPIClans.md +3 -5
  17. package/docs/api/documents/SmarticoObject.md +15 -0
  18. package/docs/api/enumerations/AvatarCustomizeErrorCode.md +21 -0
  19. package/docs/api/enumerations/JoinClanErrorCode.md +16 -17
  20. package/docs/api/interfaces/AvatarCustomizeResponse.md +31 -0
  21. package/docs/api/interfaces/TAvatarPrompt.md +2 -2
  22. package/docs/api/interfaces/TMissionOrBadgeTask.md +16 -0
  23. package/docs/api/interfaces/UserAchievementTask.md +16 -0
  24. package/docs/native/PROTOCOL.md +3 -1
  25. package/docs/ui/avatars/UIGuide_avatarsCustomize.md +69 -0
  26. package/package.json +1 -1
  27. package/src/Avatars/AvatarCustomizeErrorCode.ts +7 -5
  28. package/src/Avatars/AvatarCustomizeResponse.ts +17 -0
  29. package/src/Avatars/index.ts +1 -0
  30. package/src/Missions/UserAchievement.ts +2 -0
  31. package/src/Missions/UserAchievementTask.ts +4 -0
  32. package/src/SmarticoAPI.ts +53 -0
  33. package/src/WSAPI/WSAPIAvatars.ts +121 -0
  34. package/src/WSAPI/WSAPITypes.ts +6 -2
  35. package/tsconfig.json +3 -1
package/README.md CHANGED
@@ -74,7 +74,7 @@ The SDK surface is split across one class per feature area, joined by an interna
74
74
  | **Jackpots** | [`WSAPIJackpots`](docs/api/classes/WSAPIJackpots.md) | `jackpotGet`, `jackpotOptIn`, `jackpotOptOut`, `getJackpotWinners`, `getJackpotEligibleGames` | [`jackpotGet`](docs/ui/jackpots/UIGuide_jackpotGet.md) · [`jackpotOptIn`](docs/ui/jackpots/UIGuide_jackpotOptIn.md) · [`jackpotOptOut`](docs/ui/jackpots/UIGuide_jackpotOptOut.md) · [`getJackpotWinners`](docs/ui/jackpots/UIGuide_getJackpotWinners.md) · [`getJackpotEligibleGames`](docs/ui/jackpots/UIGuide_getJackpotEligibleGames.md) |
75
75
  | **Raffles / Draws** | [`WSAPIRaffles`](docs/api/classes/WSAPIRaffles.md) | `getRaffles`, `getRaffleDrawRun`, `getRaffleDrawRunsHistory`, `claimRafflePrize`, `requestRaffleOptin`, `getRaffleWonPrizes` | [`getRaffles`](docs/ui/raffles/UIGuide_getRaffles.md) · [`getRaffleDrawRun`](docs/ui/raffles/UIGuide_getRaffleDrawRun.md) · [`getRaffleDrawRunsHistory`](docs/ui/raffles/UIGuide_getRaffleDrawRunsHistory.md) · [`claimRafflePrize`](docs/ui/raffles/UIGuide_claimRafflePrize.md) · [`requestRaffleOptin`](docs/ui/raffles/UIGuide_requestRaffleOptin.md) · [`getRaffleWonPrizes`](docs/ui/raffles/UIGuide_getRaffleWonPrizes.md) |
76
76
  | **MiniGames / SAW** | [`WSAPIMiniGames`](docs/api/classes/WSAPIMiniGames.md) | `getMiniGames`, `getMiniGamesHistory`, `playMiniGame`, `miniGameWinAcknowledgeRequest`, `playMiniGameBatch` | [`getMiniGames`](docs/ui/minigames/UIGuide_getMiniGames.md) · [`getMiniGamesHistory`](docs/ui/minigames/UIGuide_getMiniGamesHistory.md) · [`playMiniGame`](docs/ui/minigames/UIGuide_playMiniGame.md) · [`playMiniGameBatch`](docs/ui/minigames/UIGuide_playMiniGameBatch.md) |
77
- | **Avatars** | [`WSAPIAvatars`](docs/api/classes/WSAPIAvatars.md) | `getAvatarsList`, `getAvatarsCustomized`, `getAvatarPrompts`, `setAvatar` | [`getAvatarsList`](docs/ui/avatars/UIGuide_getAvatarsList.md) · [`getAvatarsCustomized`](docs/ui/avatars/UIGuide_getAvatarsCustomized.md) · [`getAvatarPrompts`](docs/ui/avatars/UIGuide_getAvatarPrompts.md) · [`setAvatar`](docs/ui/avatars/UIGuide_setAvatar.md) |
77
+ | **Avatars** | [`WSAPIAvatars`](docs/api/classes/WSAPIAvatars.md) | `getAvatarsList`, `getAvatarsCustomized`, `getAvatarPrompts`, `setAvatar`, `avatarsCustomize` | [`getAvatarsList`](docs/ui/avatars/UIGuide_getAvatarsList.md) · [`getAvatarsCustomized`](docs/ui/avatars/UIGuide_getAvatarsCustomized.md) · [`getAvatarPrompts`](docs/ui/avatars/UIGuide_getAvatarPrompts.md) · [`setAvatar`](docs/ui/avatars/UIGuide_setAvatar.md) · [`avatarsCustomize`](docs/ui/avatars/UIGuide_avatarsCustomize.md) |
78
78
  | **Game Pick (sports / quiz)** | [`WSAPIGamePick`](docs/api/classes/WSAPIGamePick.md) | `gamePickGet*`, `gamePickSubmit*` (9 methods) | [`gamePickGetActiveRounds`](docs/ui/gamepick/UIGuide_gamePickGetActiveRounds.md) · [`gamePickGetActiveRound`](docs/ui/gamepick/UIGuide_gamePickGetActiveRound.md) · [`gamePickGetHistory`](docs/ui/gamepick/UIGuide_gamePickGetHistory.md) · [`gamePickGetBoard`](docs/ui/gamepick/UIGuide_gamePickGetBoard.md) · [`gamePickSubmitSelection`](docs/ui/gamepick/UIGuide_gamePickSubmitSelection.md) · [`gamePickSubmitSelectionQuiz`](docs/ui/gamepick/UIGuide_gamePickSubmitSelectionQuiz.md) · [`gamePickGetUserInfo`](docs/ui/gamepick/UIGuide_gamePickGetUserInfo.md) · [`gamePickGetGameInfo`](docs/ui/gamepick/UIGuide_gamePickGetGameInfo.md) · [`gamePickGetRoundInfoForUser`](docs/ui/gamepick/UIGuide_gamePickGetRoundInfoForUser.md) |
79
79
  | **Leaderboard** | [`WSAPILeaderBoard`](docs/api/classes/WSAPILeaderBoard.md) | `getLeaderBoard` | [`getLeaderBoard`](docs/ui/leaderboard/UIGuide_getLeaderBoard.md) |
80
80
  | **Inbox / Messages / Engagement** | [`WSAPIInbox`](docs/api/classes/WSAPIInbox.md) | `getInboxMessages`, `getInboxUnreadCount`, `getInboxMessageBody`, `markInboxMessageAsRead`, `markAllInboxMessagesAsRead`, `markUnmarkInboxMessageAsFavorite`, `deleteInboxMessage`, `deleteAllInboxMessages`, `reportImpressionEvent`, `reportClickEvent` | [`getInboxMessages`](docs/ui/inbox/UIGuide_getInboxMessages.md) · [`getInboxMessageBody`](docs/ui/inbox/UIGuide_getInboxMessageBody.md) · [`markInboxMessageAsRead`](docs/ui/inbox/UIGuide_markInboxMessageAsRead.md) · [`markUnmarkInboxMessageAsFavorite`](docs/ui/inbox/UIGuide_markUnmarkInboxMessageAsFavorite.md) · [`deleteInboxMessage`](docs/ui/inbox/UIGuide_deleteInboxMessage.md) |
@@ -1,5 +1,11 @@
1
+ /**
2
+ * Limit error codes returned in `errCode` by the `avatarsCustomize` method.
3
+ * See the `avatarsCustomize` TSDoc for the full table (including the generic
4
+ * `-1` failure, which has no named member here).
5
+ */
1
6
  export declare enum AvatarCustomizeErrorCode {
7
+ /** The user has reached the operator-configured per-user monthly cap on custom-avatar generations. */
2
8
  AVATAR_USER_LIMIT = 12001,
9
+ /** The brand's operator-configured shared monthly pool of custom-avatar generations is exhausted. */
3
10
  AVATAR_LABEL_LIMIT = 12002
4
11
  }
5
- export declare const AvatarCustomizeErrorMessage: Record<AvatarCustomizeErrorCode, string>;
@@ -0,0 +1,16 @@
1
+ import { AvatarCustomizeErrorCode } from './AvatarCustomizeErrorCode';
2
+ /**
3
+ * Result of `_smartico.api.avatarsCustomize()`. On success only `cdn_url` is
4
+ * set; on failure only `errCode` / `errMessage`.
5
+ */
6
+ export interface AvatarCustomizeResponse {
7
+ /** CDN URL of the generated avatar variant. Present on success. */
8
+ cdn_url?: string;
9
+ /** Error code. Present on failure. Typed values are members of
10
+ * {@link AvatarCustomizeErrorCode}; `-1` is a generic failure. See the
11
+ * `avatarsCustomize` TSDoc for the full table. */
12
+ errCode?: AvatarCustomizeErrorCode | number;
13
+ /** Optional error message. Present on failure; the generic (`-1`) message
14
+ * is fixed text, so branch on `errCode`, not this string. */
15
+ errMessage?: string;
16
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './AvatarCustomizeErrorCode';
2
+ export * from './AvatarCustomizeResponse';
2
3
  export * from './AvatarDefinition';
3
4
  export * from './AvatarCustomized';
4
5
  export * from './AvatarPrompt';
@@ -5,6 +5,10 @@ export interface UserAchievementTask {
5
5
  task_id?: number;
6
6
  task_public_meta?: AchievementTaskPublicMeta;
7
7
  points_reward?: number;
8
+ /** Gems awarded when this task is completed. */
9
+ gems_reward?: number;
10
+ /** Diamonds awarded when this task is completed. */
11
+ diamonds_reward?: number;
8
12
  task_type_id: AchievementTaskType;
9
13
  isCompleted?: boolean;
10
14
  userExecutedCount?: number;
@@ -28,6 +28,7 @@ import { GetAvatarsListResponse } from './Avatars/GetAvatarsListResponse';
28
28
  import { GetAvatarsCustomizedResponse } from './Avatars/GetAvatarsCustomizedResponse';
29
29
  import { GetAvatarPromptsResponse } from './Avatars/GetAvatarPromptsResponse';
30
30
  import { SetAvatarResponse } from './Avatars';
31
+ import { AvatarCustomizeResponse } from './Avatars/AvatarCustomizeResponse';
31
32
  import { GetJackpotWinnersResponse, JackpotWinnerHistory } from './Jackpots/GetJackpotWinnersResponse';
32
33
  import { GetJackpotEligibleGamesResponse, TGetJackpotEligibleGamesResponse } from './Jackpots/GetJackpotEligibleGamesResponse';
33
34
  import { GamePickGameInfo, GamePickRound, GamePickRoundBoard, GamePickUserInfo, GamesApiResponse } from './GamePick';
@@ -61,6 +62,7 @@ declare class SmarticoAPI {
61
62
  private gamesApiUrl;
62
63
  private baseRgApiParams;
63
64
  avatarDomain: string;
65
+ private avatarOriginDomain;
64
66
  private envId;
65
67
  private logger;
66
68
  private logCIDs;
@@ -76,6 +78,7 @@ declare class SmarticoAPI {
76
78
  static getPublicUrl(label_api_key: string): string;
77
79
  static getPublicWsUrl(label_api_key: string): string;
78
80
  static getAvatarUrl(label_api_key: string): string;
81
+ static getAvatarOriginUrl(label_api_key: string): string;
79
82
  private send;
80
83
  private buildMessage;
81
84
  coreReportCustomEvent(user_ext_id: string, eventType: string, payload?: any): Promise<any>;
@@ -175,6 +178,7 @@ declare class SmarticoAPI {
175
178
  deleteAllInboxMessages(user_ext_id: string): Promise<MarkInboxMessageDeletedResponse>;
176
179
  private buildGamesApiParams;
177
180
  private sendGamesApi;
181
+ private sendAvatarApi;
178
182
  gpGetActiveRounds(saw_template_id: number): Promise<GamesApiResponse<GamePickRound[]>>;
179
183
  gpGetActiveRound(saw_template_id: number, round_id?: number): Promise<GamesApiResponse<GamePickRound>>;
180
184
  gpGetGamesHistory(saw_template_id: number): Promise<GamesApiResponse<GamePickRound[]>>;
@@ -188,6 +192,13 @@ declare class SmarticoAPI {
188
192
  avatarsGetCustomized(user_ext_id: string): Promise<GetAvatarsCustomizedResponse>;
189
193
  avatarsGetPrompts(user_ext_id: string): Promise<GetAvatarPromptsResponse>;
190
194
  avatarSetAvatar(user_ext_id: string, avatar_id: string, avatar_real_id: number): Promise<SetAvatarResponse>;
195
+ avatarsCustomize(params: {
196
+ label_id: number;
197
+ user_id: number;
198
+ prompt_id: number;
199
+ avatar_url: string;
200
+ avatar_real_id: number;
201
+ }): Promise<AvatarCustomizeResponse>;
191
202
  avatarsGetListT(user_ext_id: string): Promise<TAvatarDefinition[]>;
192
203
  avatarsGetCustomizedT(user_ext_id: string): Promise<TAvatarCustomized[]>;
193
204
  avatarsGetPromptsT(user_ext_id: string): Promise<TAvatarPrompt[]>;
@@ -1,5 +1,6 @@
1
1
  import { TAvatarDefinition, TAvatarCustomized, TAvatarPrompt, TSetAvatarResult } from './WSAPITypes';
2
2
  import { WSAPIMiniGames } from './WSAPIMiniGames';
3
+ import { AvatarCustomizeResponse } from '../Avatars/AvatarCustomizeResponse';
3
4
  /** @group Avatars */
4
5
  export declare class WSAPIAvatars extends WSAPIMiniGames {
5
6
  /**
@@ -293,4 +294,106 @@ export declare class WSAPIAvatars extends WSAPIMiniGames {
293
294
  avatar_url: string;
294
295
  avatar_real_id: number;
295
296
  }): Promise<TSetAvatarResult>;
297
+ /**
298
+ * Generates an AI-customized variant of a base avatar by applying an
299
+ * operator-defined style prompt, returning the CDN URL of the result.
300
+ * This is a paid, generate-only step: it does NOT change the user's
301
+ * active avatar — pass the returned `cdn_url` to {@link setAvatar} to
302
+ * activate it.
303
+ *
304
+ * @remarks
305
+ * **Preconditions**
306
+ * - Authenticated session required; not available in visitor mode (throws).
307
+ * - All five fields are mandatory — the SDK throws synchronously
308
+ * (`Error("<field> is required")`) if any is missing or zero.
309
+ * - `prompt_id` must be one of the prompts from {@link getAvatarPrompts};
310
+ * `avatar_url` / `avatar_real_id` identify the base avatar to style.
311
+ *
312
+ * **Cost**
313
+ * Each generation costs the currency the operator configured on the
314
+ * chosen prompt (points, gems, or diamonds — some prompts are free; read
315
+ * `cost_currency_type_id` / `cost_value` from the {@link getAvatarPrompts}
316
+ * entry to gate the UI before calling). The cost is charged only on
317
+ * success; if the user can't afford it the call fails with `errCode -1`
318
+ * and nothing is generated or charged.
319
+ *
320
+ * **Latency**
321
+ * Generation runs server-side AI image synthesis and is synchronous from
322
+ * the caller's side — expect several seconds (roughly 5–20 s) before the
323
+ * promise resolves. There is no SDK cache and no push/subscription; show
324
+ * a loading state for the full duration and disable the trigger to
325
+ * prevent duplicate submissions.
326
+ *
327
+ * **Result & error codes**
328
+ * On success the result has `cdn_url` set; on failure it has `errCode` /
329
+ * `errMessage` set and no `cdn_url`. Branch on `errCode` — the generic
330
+ * message is fixed text, not cause-specific:
331
+ * - `12001` (`AvatarCustomizeErrorCode.AVATAR_USER_LIMIT`) — the user hit
332
+ * their monthly per-user generation cap. Nothing is generated or charged.
333
+ * - `12002` (`AvatarCustomizeErrorCode.AVATAR_LABEL_LIMIT`) — the brand's
334
+ * shared monthly pool is exhausted. Nothing is generated or charged;
335
+ * surface a "try again later" message.
336
+ * - `-1` — generic failure: insufficient balance, an unavailable prompt,
337
+ * or a generation error. Nothing is charged. Allow the user to retry.
338
+ *
339
+ * Both monthly caps are operator-configured and reset at the start of
340
+ * each calendar month.
341
+ *
342
+ * **Side effects (on success)**
343
+ * The generated variant is persisted to the user's customization history
344
+ * and counts toward the monthly caps **whether or not** it is later
345
+ * activated — generation is not reversible. The SDK clears the
346
+ * {@link getAvatarsCustomized} cache so the next call surfaces the new
347
+ * variant. The user's active avatar is unchanged until you call
348
+ * {@link setAvatar} with the returned `cdn_url`.
349
+ *
350
+ * **Idempotency**: not idempotent — each successful call generates (and
351
+ * charges for) a new variant. Guard the call site against double-clicks.
352
+ *
353
+ * **UI guidance**: see [UI Guide — `avatarsCustomize`](../../docs/ui/avatars/UIGuide_avatarsCustomize.md).
354
+ *
355
+ * **Visitor mode**: not supported (throws).
356
+ *
357
+ * @param props.label_id Numeric Smartico label (brand) ID the user belongs to.
358
+ * @param props.user_id Numeric Smartico user ID.
359
+ * @param props.prompt_id Style-prompt ID (`prompt_id`) from {@link getAvatarPrompts}.
360
+ * @param props.avatar_url CDN URL of the base avatar to customize.
361
+ * @param props.avatar_real_id `avatar_real_id` of the base avatar.
362
+ * @returns {@link AvatarCustomizeResponse} — `cdn_url` set on success;
363
+ * `errCode` / `errMessage` set on failure.
364
+ *
365
+ * @example
366
+ * ```ts
367
+ * // label_id / user_id identify the Smartico user being customized.
368
+ * const prompts = await window._smartico.api.getAvatarPrompts();
369
+ * const prompt = prompts[0];
370
+ *
371
+ * console.log('[smartico] generating avatar — show a spinner for ~5-20s and disable the Generate button');
372
+ * const result = await window._smartico.api.avatarsCustomize({
373
+ * label_id,
374
+ * user_id,
375
+ * prompt_id: prompt.prompt_id,
376
+ * avatar_url: baseAvatar.avatar_url,
377
+ * avatar_real_id: baseAvatar.avatar_real_id,
378
+ * });
379
+ *
380
+ * if (result.cdn_url) {
381
+ * console.log('[smartico] generation succeeded — preview this URL, then call setAvatar to apply it:', result.cdn_url);
382
+ * // await window._smartico.api.setAvatar({ avatar_url: result.cdn_url, avatar_real_id: baseAvatar.avatar_real_id });
383
+ * } else if (result.errCode === 12001) {
384
+ * console.error('[smartico] user monthly limit reached — show "you have used all your custom avatars this month"');
385
+ * } else if (result.errCode === 12002) {
386
+ * console.error('[smartico] brand monthly pool exhausted — show "custom avatars are unavailable right now, try later"');
387
+ * } else {
388
+ * console.error('[smartico] generation failed (e.g. not enough balance) — let the user retry:', result.errMessage);
389
+ * }
390
+ * ```
391
+ */
392
+ avatarsCustomize(props: {
393
+ label_id: number;
394
+ user_id: number;
395
+ prompt_id: number;
396
+ avatar_url: string;
397
+ avatar_real_id: number;
398
+ }): Promise<AvatarCustomizeResponse>;
296
399
  }
@@ -899,6 +899,10 @@ export interface TMissionOrBadgeTask {
899
899
  progress: number;
900
900
  /** Reward for completing the task in points */
901
901
  points_reward: number;
902
+ /** Reward for completing the task in gems */
903
+ gems_reward?: number;
904
+ /** Reward for completing the task in diamonds */
905
+ diamonds_reward?: number;
902
906
  /** This is the total number of times the user needs to execute to complete task. e.g. he needs to bet 100 times. Here will be 100 */
903
907
  execution_count_expected?: number;
904
908
  /** This is the number of times the user has executed 'activity' of the task. e.g. he bet 5 times out of 100. Here will be 5 */
@@ -1675,9 +1679,9 @@ export interface TAvatarPrompt {
1675
1679
  name: string;
1676
1680
  /** Absolute CDN URL of the prompt's preview icon. */
1677
1681
  icon_url: string;
1678
- /** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds. */
1682
+ /** Currency used to pay for the customization. `0` = points, `1` = gems, `2` = diamonds, `3` = free. A `cost_value` of `0` is also free. */
1679
1683
  cost_currency_type_id: number;
1680
- /** Cost amount in the currency named by `cost_currency_type_id`. */
1684
+ /** Cost amount in the currency named by `cost_currency_type_id`. `0` = free. */
1681
1685
  cost_value: number;
1682
1686
  }
1683
1687
  /**