@smartico/public-api 0.0.363 → 0.0.364

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartico/public-api",
3
- "version": "0.0.363",
3
+ "version": "0.0.364",
4
4
  "description": "Smartico public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,6 +8,35 @@ import { BadgesTimeLimitStates } from "./BadgesTimeLimitStates";
8
8
  type UserStateParamsKeys = 'core_fav_game_top3' | 'core_fav_game_type_top3' | 'core_fav_game_provider_top3' | 'core_recommended_deposit_amount' | 'core_recommended_casino_bet_amount' | 'casino_last_bet_amount' | 'casino_last_bet_amount_real' | 'casino_last_bet_amount_bonus' | 'acc_last_deposit_amount';
9
9
  const USER_STATE_PARAMS_KEYS_GAMES: UserStateParamsKeys[] = ['core_fav_game_top3', 'core_fav_game_type_top3', 'core_fav_game_provider_top3'];
10
10
  const USER_STATE_PARAMS_KEYS_BET_AMOUNT: UserStateParamsKeys[] = ['core_recommended_deposit_amount', 'core_recommended_casino_bet_amount', 'casino_last_bet_amount', 'casino_last_bet_amount_real', 'casino_last_bet_amount_bonus', 'acc_last_deposit_amount'];
11
+
12
+ const MINOR_WORDS = new Set([
13
+ 'of', 'at', 'in', 'on', 'to', 'up', 'as', 'by', 'for',
14
+ 'from', 'into', 'onto', 'with', 'upon', 'via',
15
+ 'and', 'but', 'or', 'nor', 'so', 'yet',
16
+ 'vs', 'v',
17
+ 'a', 'an', 'the',
18
+ ]);
19
+
20
+ function toGameTitleCase(raw: string): string {
21
+ if (!raw) return raw;
22
+ const tokens = raw.toLowerCase().split(/(\b\w+\b)/);
23
+ const wordTokens = tokens.filter((t) => /^\w+$/.test(t));
24
+ const lastWordIdx = wordTokens.length - 1;
25
+ let wordIndex = 0;
26
+ return tokens
27
+ .map((token) => {
28
+ if (!/^\w+$/.test(token)) return token;
29
+ const isFirst = wordIndex === 0;
30
+ const isLast = wordIndex === lastWordIdx;
31
+ wordIndex++;
32
+ if (isFirst || isLast || !MINOR_WORDS.has(token)) {
33
+ return token.charAt(0).toUpperCase() + token.slice(1);
34
+ }
35
+ return token;
36
+ })
37
+ .join('');
38
+ }
39
+
11
40
  export class MissionUtils {
12
41
 
13
42
  public static getAvailabilityStatus = (mission: UserAchievement) => {
@@ -199,8 +228,8 @@ export class MissionUtils {
199
228
  const value = userStateParams[k]?.filter(v => Boolean(v));
200
229
  if (value && value.length > 0) {
201
230
  suggestedGames = value.map((v: string) => {
202
- const cleaned = v.replace(/_/g, ' ').toLowerCase();
203
- return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
231
+ const cleaned = v.replace(/_/g, ' ');
232
+ return toGameTitleCase(cleaned);
204
233
  }).join(', ');
205
234
  }
206
235
  }
@@ -213,8 +242,7 @@ export class MissionUtils {
213
242
  suggestedGames = value[pos];
214
243
 
215
244
  if (suggestedGames) {
216
- suggestedGames = suggestedGames.replace('_', ' ').toLowerCase();
217
- suggestedGames = suggestedGames.charAt(0).toUpperCase() + suggestedGames.slice(1);
245
+ suggestedGames = toGameTitleCase(suggestedGames.replace(/_/g, ' '));
218
246
  }
219
247
 
220
248
  }