rategame-shared 1.1.556 → 1.1.557
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/constants/leagueSupport.d.ts +2 -2
- package/dist/constants/miniLeague.d.ts +35 -0
- package/dist/constants/miniLeague.js +138 -0
- package/dist/constants/pollPredictionLeagues.d.ts +1 -0
- package/dist/constants/pollPredictionLeagues.js +4 -0
- package/dist/helpers/achievements.d.ts +4 -0
- package/dist/helpers/achievements.js +849 -0
- package/dist/helpers/articleBody.d.ts +23 -0
- package/dist/helpers/articleBody.js +56 -0
- package/dist/helpers/index.d.ts +4 -26
- package/dist/helpers/index.js +9 -907
- package/dist/helpers/milestones.d.ts +2 -0
- package/dist/helpers/milestones.js +10 -0
- package/dist/helpers/urlPrefix.d.ts +21 -0
- package/dist/helpers/urlPrefix.js +56 -0
- package/dist/schemas/article.d.ts +2 -23
- package/dist/schemas/article.js +15 -59
- package/dist/schemas/miniLeague.d.ts +36 -69
- package/dist/schemas/miniLeague.js +22 -144
- package/dist/schemas/pollPrediction.d.ts +1 -0
- package/dist/schemas/pollPrediction.js +5 -2
- package/package.json +75 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { leagueSlug } from "../schemas/sharedTypes";
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { leagueSlug } from "../schemas/sharedTypes";
|
|
3
3
|
export type LeagueSlug = z.infer<typeof leagueSlug>;
|
|
4
4
|
/**
|
|
5
5
|
* Leagues that support player voting functionality
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const isCollegePlatform: (league: string) => boolean;
|
|
2
|
+
export declare const CFB_CONFERENCES: string[];
|
|
3
|
+
export declare const WCBB_CONFERENCES: string[];
|
|
4
|
+
export declare const CBB_CONFERENCES: string[];
|
|
5
|
+
/** Max sports/platform leagues selectable when creating a mini league. */
|
|
6
|
+
export declare const MINI_LEAGUE_MAX_PLATFORM_LEAGUES = 2;
|
|
7
|
+
/** Max active mini leagues a user can create (own) at once. */
|
|
8
|
+
export declare const MINI_LEAGUE_MAX_CREATED_PER_USER = 10;
|
|
9
|
+
/** Max active mini leagues a user can join (not own) at once. */
|
|
10
|
+
export declare const MINI_LEAGUE_MAX_JOINED_PER_USER = 20;
|
|
11
|
+
/** Combined cap when both create and join allotments are full. */
|
|
12
|
+
export declare const MINI_LEAGUE_MAX_MEMBERSHIPS_PER_USER: number;
|
|
13
|
+
export type MiniLeagueAllotmentCounts = {
|
|
14
|
+
created: number;
|
|
15
|
+
joined: number;
|
|
16
|
+
};
|
|
17
|
+
type MiniLeagueAllotmentLeague = {
|
|
18
|
+
ownerId?: string | null;
|
|
19
|
+
status?: string | null;
|
|
20
|
+
endAt?: number | null;
|
|
21
|
+
};
|
|
22
|
+
export declare const countMiniLeagueAllotments: (leagues: MiniLeagueAllotmentLeague[], userId?: string | null, now?: number) => MiniLeagueAllotmentCounts;
|
|
23
|
+
export declare const isAtMiniLeagueCreateLimit: (counts: MiniLeagueAllotmentCounts) => boolean;
|
|
24
|
+
export declare const isAtMiniLeagueJoinLimit: (counts: MiniLeagueAllotmentCounts) => boolean;
|
|
25
|
+
/** Resolve platform leagues for a mini league doc (legacy-safe). */
|
|
26
|
+
export declare const getMiniLeaguePlatformLeagues: (league: {
|
|
27
|
+
platformLeague?: string;
|
|
28
|
+
platformLeagues?: string[] | null;
|
|
29
|
+
}) => string[];
|
|
30
|
+
/** True while the challenge is still running (status + calendar end). */
|
|
31
|
+
export declare const isMiniLeagueOngoing: (league: {
|
|
32
|
+
status?: string | null;
|
|
33
|
+
endAt?: number | null;
|
|
34
|
+
}, now?: number) => boolean;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMiniLeagueOngoing = exports.getMiniLeaguePlatformLeagues = exports.isAtMiniLeagueJoinLimit = exports.isAtMiniLeagueCreateLimit = exports.countMiniLeagueAllotments = exports.MINI_LEAGUE_MAX_MEMBERSHIPS_PER_USER = exports.MINI_LEAGUE_MAX_JOINED_PER_USER = exports.MINI_LEAGUE_MAX_CREATED_PER_USER = exports.MINI_LEAGUE_MAX_PLATFORM_LEAGUES = exports.CBB_CONFERENCES = exports.WCBB_CONFERENCES = exports.CFB_CONFERENCES = exports.isCollegePlatform = void 0;
|
|
4
|
+
const earnedTags_1 = require("./earnedTags");
|
|
5
|
+
const isCollegePlatform = (league) => earnedTags_1.COLLEGE_LEAGUES.has(league);
|
|
6
|
+
exports.isCollegePlatform = isCollegePlatform;
|
|
7
|
+
exports.CFB_CONFERENCES = [
|
|
8
|
+
"American Athletic",
|
|
9
|
+
"Atlantic Coast",
|
|
10
|
+
"Big 12",
|
|
11
|
+
"Big Ten",
|
|
12
|
+
"Conference USA",
|
|
13
|
+
"FBS Independents",
|
|
14
|
+
"Mid-American",
|
|
15
|
+
"Mountain West",
|
|
16
|
+
"Pac-12",
|
|
17
|
+
"Southeastern",
|
|
18
|
+
"Sun Belt - East",
|
|
19
|
+
"Sun Belt - West",
|
|
20
|
+
];
|
|
21
|
+
exports.WCBB_CONFERENCES = [
|
|
22
|
+
"ASUN Conference",
|
|
23
|
+
"America East Conference",
|
|
24
|
+
"American Conference",
|
|
25
|
+
"Atlantic 10 Conference",
|
|
26
|
+
"Atlantic Coast Conference",
|
|
27
|
+
"Big 12 Conference",
|
|
28
|
+
"Big East Conference",
|
|
29
|
+
"Big Sky Conference",
|
|
30
|
+
"Big South Conference",
|
|
31
|
+
"Big Ten Conference",
|
|
32
|
+
"Big West Conference",
|
|
33
|
+
"Coastal Athletic Association",
|
|
34
|
+
"Conference USA",
|
|
35
|
+
"Division I Independents",
|
|
36
|
+
"Great West",
|
|
37
|
+
"Horizon League",
|
|
38
|
+
"Ivy League",
|
|
39
|
+
"Metro Atlantic Athletic Conference",
|
|
40
|
+
"Mid-American Conference",
|
|
41
|
+
"Mid-Eastern Athletic Conference",
|
|
42
|
+
"Missouri Valley Conference",
|
|
43
|
+
"Mountain West Conference",
|
|
44
|
+
"Northeast Conference",
|
|
45
|
+
"Ohio Valley Conference",
|
|
46
|
+
"Pac-12 Conference",
|
|
47
|
+
"Patriot League",
|
|
48
|
+
"Southeastern Conference",
|
|
49
|
+
"Southern Conference",
|
|
50
|
+
"Southland Conference",
|
|
51
|
+
"Southwestern Athletic Conference",
|
|
52
|
+
"Summit League",
|
|
53
|
+
"Sun Belt Conference",
|
|
54
|
+
"West Coast Conference",
|
|
55
|
+
"Western Athletic Conference",
|
|
56
|
+
];
|
|
57
|
+
exports.CBB_CONFERENCES = [
|
|
58
|
+
"America East",
|
|
59
|
+
"American Athletic",
|
|
60
|
+
"Atlantic 10",
|
|
61
|
+
"Atlantic Coast",
|
|
62
|
+
"Atlantic Sun",
|
|
63
|
+
"Big 12",
|
|
64
|
+
"Big East",
|
|
65
|
+
"Big Sky",
|
|
66
|
+
"Big South",
|
|
67
|
+
"Big Ten",
|
|
68
|
+
"Big West",
|
|
69
|
+
"Coastal Athletic Association",
|
|
70
|
+
"Conference USA",
|
|
71
|
+
"Horizon League",
|
|
72
|
+
"Ivy League",
|
|
73
|
+
"Metro Atlantic Athletic",
|
|
74
|
+
"Mid-American",
|
|
75
|
+
"Mid-Eastern",
|
|
76
|
+
"Missouri Valley",
|
|
77
|
+
"Mountain West",
|
|
78
|
+
"Northeast",
|
|
79
|
+
"Ohio Valley",
|
|
80
|
+
"Pac-12",
|
|
81
|
+
"Patriot League",
|
|
82
|
+
"Southeastern",
|
|
83
|
+
"Southern",
|
|
84
|
+
"Southland",
|
|
85
|
+
"Southwestern Athletic",
|
|
86
|
+
"Summit",
|
|
87
|
+
"Sun Belt",
|
|
88
|
+
"West Coast",
|
|
89
|
+
"Western Athletic",
|
|
90
|
+
];
|
|
91
|
+
/** Max sports/platform leagues selectable when creating a mini league. */
|
|
92
|
+
exports.MINI_LEAGUE_MAX_PLATFORM_LEAGUES = 2;
|
|
93
|
+
/** Max active mini leagues a user can create (own) at once. */
|
|
94
|
+
exports.MINI_LEAGUE_MAX_CREATED_PER_USER = 10;
|
|
95
|
+
/** Max active mini leagues a user can join (not own) at once. */
|
|
96
|
+
exports.MINI_LEAGUE_MAX_JOINED_PER_USER = 20;
|
|
97
|
+
/** Combined cap when both create and join allotments are full. */
|
|
98
|
+
exports.MINI_LEAGUE_MAX_MEMBERSHIPS_PER_USER = exports.MINI_LEAGUE_MAX_CREATED_PER_USER + exports.MINI_LEAGUE_MAX_JOINED_PER_USER;
|
|
99
|
+
const countMiniLeagueAllotments = (leagues, userId, now = Date.now()) => {
|
|
100
|
+
if (!userId) {
|
|
101
|
+
return { created: 0, joined: 0 };
|
|
102
|
+
}
|
|
103
|
+
let created = 0;
|
|
104
|
+
let joined = 0;
|
|
105
|
+
for (const league of leagues) {
|
|
106
|
+
if (!(0, exports.isMiniLeagueOngoing)(league, now))
|
|
107
|
+
continue;
|
|
108
|
+
if (league.ownerId === userId) {
|
|
109
|
+
created += 1;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
joined += 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return { created, joined };
|
|
116
|
+
};
|
|
117
|
+
exports.countMiniLeagueAllotments = countMiniLeagueAllotments;
|
|
118
|
+
const isAtMiniLeagueCreateLimit = (counts) => counts.created >= exports.MINI_LEAGUE_MAX_CREATED_PER_USER;
|
|
119
|
+
exports.isAtMiniLeagueCreateLimit = isAtMiniLeagueCreateLimit;
|
|
120
|
+
const isAtMiniLeagueJoinLimit = (counts) => counts.joined >= exports.MINI_LEAGUE_MAX_JOINED_PER_USER;
|
|
121
|
+
exports.isAtMiniLeagueJoinLimit = isAtMiniLeagueJoinLimit;
|
|
122
|
+
/** Resolve platform leagues for a mini league doc (legacy-safe). */
|
|
123
|
+
const getMiniLeaguePlatformLeagues = (league) => {
|
|
124
|
+
if (league.platformLeagues && league.platformLeagues.length > 0) {
|
|
125
|
+
return league.platformLeagues;
|
|
126
|
+
}
|
|
127
|
+
return league.platformLeague ? [league.platformLeague] : [];
|
|
128
|
+
};
|
|
129
|
+
exports.getMiniLeaguePlatformLeagues = getMiniLeaguePlatformLeagues;
|
|
130
|
+
/** True while the challenge is still running (status + calendar end). */
|
|
131
|
+
const isMiniLeagueOngoing = (league, now = Date.now()) => {
|
|
132
|
+
if (league.status === "ended")
|
|
133
|
+
return false;
|
|
134
|
+
if (typeof league.endAt === "number" && league.endAt < now)
|
|
135
|
+
return false;
|
|
136
|
+
return true;
|
|
137
|
+
};
|
|
138
|
+
exports.isMiniLeagueOngoing = isMiniLeagueOngoing;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const POLL_PREDICTION_LEAGUES: readonly ["cfb", "cbb"];
|