rategame-shared 1.1.477 → 1.1.478

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.
@@ -0,0 +1,5 @@
1
+ export declare const FANCY_TEXT_ERROR_MESSAGE = "Fancy or styled characters are not allowed. Please use normal letters and numbers.";
2
+ /**
3
+ * Detects mathematical-alphanumeric, fullwidth, and similar disguised characters.
4
+ */
5
+ export declare function containsFancyText(value: string | null | undefined): boolean;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.containsFancyText = exports.FANCY_TEXT_ERROR_MESSAGE = void 0;
4
+ exports.FANCY_TEXT_ERROR_MESSAGE = 'Fancy or styled characters are not allowed. Please use normal letters and numbers.';
5
+ /** Unicode ranges used for disguised / styled text (not normal user input). */
6
+ const FANCY_CODE_POINT_RANGES = [
7
+ [0x1d400, 0x1d7ff],
8
+ [0x1d800, 0x1daff],
9
+ [0x1f100, 0x1f1ff],
10
+ [0x2100, 0x214f],
11
+ [0x2460, 0x24ff],
12
+ [0xff01, 0xff5e], // Fullwidth ASCII variants
13
+ ];
14
+ const isFancyCodePoint = (code) => FANCY_CODE_POINT_RANGES.some(([start, end]) => code >= start && code <= end);
15
+ /**
16
+ * Detects mathematical-alphanumeric, fullwidth, and similar disguised characters.
17
+ */
18
+ function containsFancyText(value) {
19
+ if (!value)
20
+ return false;
21
+ for (const char of value) {
22
+ const code = char.codePointAt(0);
23
+ if (code !== undefined && isFancyCodePoint(code)) {
24
+ return true;
25
+ }
26
+ }
27
+ return false;
28
+ }
29
+ exports.containsFancyText = containsFancyText;
@@ -0,0 +1,26 @@
1
+ export declare const DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER: readonly ["nba", "mlb", "wbc", "nfl", "nhl", "iho", "epl", "fifa", "cbb", "cfb", "mls", "wnba", "cwc"];
2
+ export type FavoriteTeamLookup = {
3
+ id?: string | number;
4
+ name?: string;
5
+ image?: string;
6
+ primaryColor?: string | null;
7
+ countryId?: string | number;
8
+ };
9
+ export type FavoriteTeamChip = {
10
+ key: string;
11
+ league: string;
12
+ teamImage: string;
13
+ teamId: string;
14
+ teamName: string;
15
+ primaryColor: string | null;
16
+ countryId?: string;
17
+ };
18
+ export declare function getFavoriteTeamChipKey({ league, teamId, countryId, }: {
19
+ league: string;
20
+ teamId: string;
21
+ countryId?: string;
22
+ }): string;
23
+ export declare function buildFavoriteTeamChips(favoriteTeamsPerLeague: Record<string, string> | undefined, allTeams: Record<string, FavoriteTeamLookup[] | undefined> | undefined): FavoriteTeamChip[];
24
+ export declare function sortFavoriteTeamChips(chips: FavoriteTeamChip[], favoriteTeamsOrder?: string[]): FavoriteTeamChip[];
25
+ export declare function buildFavoriteTeamsOrderFromChips(chips: FavoriteTeamChip[]): string[];
26
+ export declare function syncFavoriteTeamsOrder(favoriteTeamsOrder: string[] | undefined, chips: FavoriteTeamChip[]): string[];
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.syncFavoriteTeamsOrder = exports.buildFavoriteTeamsOrderFromChips = exports.sortFavoriteTeamChips = exports.buildFavoriteTeamChips = exports.getFavoriteTeamChipKey = exports.DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER = void 0;
4
+ exports.DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER = [
5
+ "nba",
6
+ "mlb",
7
+ "wbc",
8
+ "nfl",
9
+ "nhl",
10
+ "iho",
11
+ "epl",
12
+ "fifa",
13
+ "cbb",
14
+ "cfb",
15
+ "mls",
16
+ "wnba",
17
+ "cwc",
18
+ ];
19
+ function getFavoriteTeamChipKey({ league, teamId, countryId, }) {
20
+ return countryId ? `country-${countryId}` : `${league}-${teamId}`;
21
+ }
22
+ exports.getFavoriteTeamChipKey = getFavoriteTeamChipKey;
23
+ function buildFavoriteTeamChips(favoriteTeamsPerLeague, allTeams) {
24
+ if (!favoriteTeamsPerLeague)
25
+ return [];
26
+ const chipsByKey = new Map();
27
+ Object.entries(favoriteTeamsPerLeague).forEach(([league, teamId]) => {
28
+ var _a, _b, _c;
29
+ const leagueKey = league === "ncaa" ? "cbb" : league;
30
+ const favoriteTeam = (_a = allTeams === null || allTeams === void 0 ? void 0 : allTeams[leagueKey]) === null || _a === void 0 ? void 0 : _a.find(item => { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.id) === null || _a === void 0 ? void 0 : _a.toString()) === teamId; });
31
+ if (!(favoriteTeam === null || favoriteTeam === void 0 ? void 0 : favoriteTeam.image))
32
+ return;
33
+ const countryId = favoriteTeam.countryId
34
+ ? String(favoriteTeam.countryId)
35
+ : undefined;
36
+ const key = getFavoriteTeamChipKey({
37
+ league: leagueKey,
38
+ teamId,
39
+ countryId,
40
+ });
41
+ if (chipsByKey.has(key))
42
+ return;
43
+ chipsByKey.set(key, {
44
+ key,
45
+ league: leagueKey,
46
+ teamImage: favoriteTeam.image,
47
+ teamId,
48
+ teamName: (_b = favoriteTeam.name) !== null && _b !== void 0 ? _b : "",
49
+ primaryColor: (_c = favoriteTeam.primaryColor) !== null && _c !== void 0 ? _c : null,
50
+ countryId,
51
+ });
52
+ });
53
+ return Array.from(chipsByKey.values());
54
+ }
55
+ exports.buildFavoriteTeamChips = buildFavoriteTeamChips;
56
+ function sortFavoriteTeamChips(chips, favoriteTeamsOrder) {
57
+ if (!chips.length)
58
+ return chips;
59
+ const orderIndex = new Map((favoriteTeamsOrder !== null && favoriteTeamsOrder !== void 0 ? favoriteTeamsOrder : []).map((key, index) => [key, index]));
60
+ return [...chips].sort((a, b) => {
61
+ const aOrder = orderIndex.get(a.key);
62
+ const bOrder = orderIndex.get(b.key);
63
+ if (aOrder !== undefined && bOrder !== undefined) {
64
+ return aOrder - bOrder;
65
+ }
66
+ if (aOrder !== undefined)
67
+ return -1;
68
+ if (bOrder !== undefined)
69
+ return 1;
70
+ const aIndex = exports.DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER.indexOf(a.league);
71
+ const bIndex = exports.DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER.indexOf(b.league);
72
+ return ((aIndex === -1 ? exports.DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER.length : aIndex) -
73
+ (bIndex === -1 ? exports.DEFAULT_FAVORITE_TEAM_LEAGUE_ORDER.length : bIndex));
74
+ });
75
+ }
76
+ exports.sortFavoriteTeamChips = sortFavoriteTeamChips;
77
+ function buildFavoriteTeamsOrderFromChips(chips) {
78
+ return sortFavoriteTeamChips(chips).map(chip => chip.key);
79
+ }
80
+ exports.buildFavoriteTeamsOrderFromChips = buildFavoriteTeamsOrderFromChips;
81
+ function syncFavoriteTeamsOrder(favoriteTeamsOrder, chips) {
82
+ const chipKeys = new Set(chips.map(chip => chip.key));
83
+ const syncedOrder = (favoriteTeamsOrder !== null && favoriteTeamsOrder !== void 0 ? favoriteTeamsOrder : []).filter(key => chipKeys.has(key));
84
+ chips.forEach(chip => {
85
+ if (!syncedOrder.includes(chip.key)) {
86
+ syncedOrder.push(chip.key);
87
+ }
88
+ });
89
+ return syncedOrder;
90
+ }
91
+ exports.syncFavoriteTeamsOrder = syncFavoriteTeamsOrder;
@@ -1,11 +1,15 @@
1
1
  import { z } from "zod";
2
- import { miniLeagueSchema, miniLeagueMemberSchema, miniLeagueInvitationSchema, createMiniLeagueDtoSchema, updateMiniLeagueDtoSchema, createMiniLeagueInvitationDtoSchema, miniLeagueJoinResponseDtoSchema, miniLeagueInvitationActionResponseDtoSchema, miniLeagueListResponseDtoSchema, miniLeagueMembersResponseDtoSchema, miniLeagueInvitationsResponseDtoSchema, miniLeagueLeaderboardResponseDtoSchema, miniLeagueUpcomingGamesResponseDtoSchema, miniLeagueRecapResponseDtoSchema, miniLeagueVisibilitySchema, miniLeagueStatusSchema, miniLeagueMemberRoleSchema, miniLeagueInvitationStatusSchema } from "../schemas/miniLeague";
2
+ import { miniLeagueSchema, miniLeagueMemberSchema, miniLeagueInvitationSchema, createMiniLeagueDtoSchema, updateMiniLeagueDtoSchema, createMiniLeagueInvitationDtoSchema, miniLeagueInviteLinkSchema, miniLeagueInviteLinkResponseDtoSchema, miniLeagueInviteLinkPreviewDtoSchema, miniLeagueInviteLinkClaimResponseDtoSchema, miniLeagueJoinResponseDtoSchema, miniLeagueInvitationActionResponseDtoSchema, miniLeagueListResponseDtoSchema, miniLeagueMembersResponseDtoSchema, miniLeagueInvitationsResponseDtoSchema, miniLeagueLeaderboardResponseDtoSchema, miniLeagueUpcomingGamesResponseDtoSchema, miniLeagueRecapResponseDtoSchema, miniLeagueVisibilitySchema, miniLeagueStatusSchema, miniLeagueMemberRoleSchema, miniLeagueInvitationStatusSchema } from "../schemas/miniLeague";
3
3
  export type MiniLeague = z.infer<typeof miniLeagueSchema>;
4
4
  export type MiniLeagueMember = z.infer<typeof miniLeagueMemberSchema>;
5
5
  export type MiniLeagueInvitation = z.infer<typeof miniLeagueInvitationSchema>;
6
6
  export type CreateMiniLeagueDto = z.infer<typeof createMiniLeagueDtoSchema>;
7
7
  export type UpdateMiniLeagueDto = z.infer<typeof updateMiniLeagueDtoSchema>;
8
8
  export type CreateMiniLeagueInvitationDto = z.infer<typeof createMiniLeagueInvitationDtoSchema>;
9
+ export type MiniLeagueInviteLink = z.infer<typeof miniLeagueInviteLinkSchema>;
10
+ export type MiniLeagueInviteLinkResponseDto = z.infer<typeof miniLeagueInviteLinkResponseDtoSchema>;
11
+ export type MiniLeagueInviteLinkPreviewDto = z.infer<typeof miniLeagueInviteLinkPreviewDtoSchema>;
12
+ export type MiniLeagueInviteLinkClaimResponseDto = z.infer<typeof miniLeagueInviteLinkClaimResponseDtoSchema>;
9
13
  export type MiniLeagueJoinResponseDto = z.infer<typeof miniLeagueJoinResponseDtoSchema>;
10
14
  export type MiniLeagueInvitationActionResponseDto = z.infer<typeof miniLeagueInvitationActionResponseDtoSchema>;
11
15
  export type MiniLeagueListResponseDto = z.infer<typeof miniLeagueListResponseDtoSchema>;