rategame-shared 1.1.243 → 1.1.244

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 @@
1
+ export * from "./leagueSupport";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./leagueSupport"), exports);
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+ import { leagueSlug } from "../schemas/sharedTypes";
3
+ export type LeagueSlug = z.infer<typeof leagueSlug>;
4
+ /**
5
+ * Leagues that support player voting functionality
6
+ */
7
+ export declare const SUPPORTED_LEAGUES: LeagueSlug[];
8
+ /**
9
+ * Leagues that do not support player voting functionality
10
+ */
11
+ export declare const UNSUPPORTED_LEAGUES: LeagueSlug[];
12
+ /**
13
+ * Configuration object for league-specific settings
14
+ */
15
+ export declare const LEAGUE_CONFIG: {
16
+ readonly nfl: {
17
+ readonly playersPath: "leagues/nfl/teams";
18
+ readonly votingEnabled: true;
19
+ readonly displayName: "NFL";
20
+ };
21
+ readonly nba: {
22
+ readonly playersPath: "leagues/nba/teams";
23
+ readonly votingEnabled: true;
24
+ readonly displayName: "NBA";
25
+ };
26
+ readonly nhl: {
27
+ readonly playersPath: "leagues/nhl/teams";
28
+ readonly votingEnabled: true;
29
+ readonly displayName: "NHL";
30
+ };
31
+ readonly mlb: {
32
+ readonly playersPath: "leagues/mlb/teams";
33
+ readonly votingEnabled: true;
34
+ readonly displayName: "MLB";
35
+ };
36
+ readonly mls: {
37
+ readonly playersPath: "leagues/mls/teams";
38
+ readonly votingEnabled: true;
39
+ readonly displayName: "MLS";
40
+ };
41
+ readonly epl: {
42
+ readonly playersPath: "leagues/epl/teams";
43
+ readonly votingEnabled: true;
44
+ readonly displayName: "EPL";
45
+ };
46
+ readonly cwc: {
47
+ readonly playersPath: "leagues/cwc/teams";
48
+ readonly votingEnabled: false;
49
+ readonly displayName: "Cricket World Cup";
50
+ };
51
+ readonly cbb: {
52
+ readonly playersPath: "leagues/cbb/teams";
53
+ readonly votingEnabled: false;
54
+ readonly displayName: "College Basketball";
55
+ };
56
+ readonly ncaa: {
57
+ readonly playersPath: "leagues/ncaa/teams";
58
+ readonly votingEnabled: false;
59
+ readonly displayName: "NCAA";
60
+ };
61
+ readonly cfb: {
62
+ readonly playersPath: "leagues/cfb/teams";
63
+ readonly votingEnabled: false;
64
+ readonly displayName: "College Football";
65
+ };
66
+ readonly wnba: {
67
+ readonly playersPath: "leagues/wnba/teams";
68
+ readonly votingEnabled: false;
69
+ readonly displayName: "WNBA";
70
+ };
71
+ readonly global: {
72
+ readonly playersPath: "";
73
+ readonly votingEnabled: false;
74
+ readonly displayName: "Global";
75
+ };
76
+ };
77
+ /**
78
+ * Check if a league supports player voting
79
+ * @param league - The league to check
80
+ * @returns true if the league supports player voting, false otherwise
81
+ */
82
+ export declare const isLeagueSupported: (league: LeagueSlug) => boolean;
83
+ /**
84
+ * Validate league support and throw error if unsupported
85
+ * @param league - The league to validate
86
+ * @throws Error if league is not supported for voting
87
+ */
88
+ export declare const validateLeagueSupport: (league: LeagueSlug) => void;
89
+ /**
90
+ * Get league configuration
91
+ * @param league - The league to get configuration for
92
+ * @returns League configuration object
93
+ */
94
+ export declare const getLeagueConfig: (league: LeagueSlug) => {
95
+ readonly playersPath: "leagues/nfl/teams";
96
+ readonly votingEnabled: true;
97
+ readonly displayName: "NFL";
98
+ } | {
99
+ readonly playersPath: "leagues/nba/teams";
100
+ readonly votingEnabled: true;
101
+ readonly displayName: "NBA";
102
+ } | {
103
+ readonly playersPath: "leagues/nhl/teams";
104
+ readonly votingEnabled: true;
105
+ readonly displayName: "NHL";
106
+ } | {
107
+ readonly playersPath: "leagues/mlb/teams";
108
+ readonly votingEnabled: true;
109
+ readonly displayName: "MLB";
110
+ } | {
111
+ readonly playersPath: "leagues/mls/teams";
112
+ readonly votingEnabled: true;
113
+ readonly displayName: "MLS";
114
+ } | {
115
+ readonly playersPath: "leagues/epl/teams";
116
+ readonly votingEnabled: true;
117
+ readonly displayName: "EPL";
118
+ } | {
119
+ readonly playersPath: "leagues/cwc/teams";
120
+ readonly votingEnabled: false;
121
+ readonly displayName: "Cricket World Cup";
122
+ } | {
123
+ readonly playersPath: "leagues/cbb/teams";
124
+ readonly votingEnabled: false;
125
+ readonly displayName: "College Basketball";
126
+ } | {
127
+ readonly playersPath: "leagues/ncaa/teams";
128
+ readonly votingEnabled: false;
129
+ readonly displayName: "NCAA";
130
+ } | {
131
+ readonly playersPath: "leagues/cfb/teams";
132
+ readonly votingEnabled: false;
133
+ readonly displayName: "College Football";
134
+ } | {
135
+ readonly playersPath: "leagues/wnba/teams";
136
+ readonly votingEnabled: false;
137
+ readonly displayName: "WNBA";
138
+ } | {
139
+ readonly playersPath: "";
140
+ readonly votingEnabled: false;
141
+ readonly displayName: "Global";
142
+ };
143
+ /**
144
+ * Get all supported leagues
145
+ * @returns Array of supported league slugs
146
+ */
147
+ export declare const getSupportedLeagues: () => LeagueSlug[];
148
+ /**
149
+ * Get all unsupported leagues
150
+ * @returns Array of unsupported league slugs
151
+ */
152
+ export declare const getUnsupportedLeagues: () => LeagueSlug[];
153
+ /**
154
+ * Check if league exists in the system
155
+ * @param league - The league to check
156
+ * @returns true if league exists, false otherwise
157
+ */
158
+ export declare const isValidLeague: (league: string) => league is "global" | "nba" | "ncaa" | "nfl" | "nhl" | "mlb" | "cbb" | "cfb" | "epl" | "mls" | "wnba" | "cwc";
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidLeague = exports.getUnsupportedLeagues = exports.getSupportedLeagues = exports.getLeagueConfig = exports.validateLeagueSupport = exports.isLeagueSupported = exports.LEAGUE_CONFIG = exports.UNSUPPORTED_LEAGUES = exports.SUPPORTED_LEAGUES = void 0;
4
+ /**
5
+ * Leagues that support player voting functionality
6
+ */
7
+ exports.SUPPORTED_LEAGUES = [
8
+ "nfl",
9
+ "nba",
10
+ "nhl",
11
+ "mlb",
12
+ "mls",
13
+ "epl",
14
+ ];
15
+ /**
16
+ * Leagues that do not support player voting functionality
17
+ */
18
+ exports.UNSUPPORTED_LEAGUES = [
19
+ "cwc",
20
+ "cbb",
21
+ "ncaa",
22
+ "cfb",
23
+ "wnba",
24
+ ];
25
+ /**
26
+ * Configuration object for league-specific settings
27
+ */
28
+ exports.LEAGUE_CONFIG = {
29
+ nfl: {
30
+ playersPath: "leagues/nfl/teams",
31
+ votingEnabled: true,
32
+ displayName: "NFL",
33
+ },
34
+ nba: {
35
+ playersPath: "leagues/nba/teams",
36
+ votingEnabled: true,
37
+ displayName: "NBA",
38
+ },
39
+ nhl: {
40
+ playersPath: "leagues/nhl/teams",
41
+ votingEnabled: true,
42
+ displayName: "NHL",
43
+ },
44
+ mlb: {
45
+ playersPath: "leagues/mlb/teams",
46
+ votingEnabled: true,
47
+ displayName: "MLB",
48
+ },
49
+ mls: {
50
+ playersPath: "leagues/mls/teams",
51
+ votingEnabled: true,
52
+ displayName: "MLS",
53
+ },
54
+ epl: {
55
+ playersPath: "leagues/epl/teams",
56
+ votingEnabled: true,
57
+ displayName: "EPL",
58
+ },
59
+ cwc: {
60
+ playersPath: "leagues/cwc/teams",
61
+ votingEnabled: false,
62
+ displayName: "Cricket World Cup",
63
+ },
64
+ cbb: {
65
+ playersPath: "leagues/cbb/teams",
66
+ votingEnabled: false,
67
+ displayName: "College Basketball",
68
+ },
69
+ ncaa: {
70
+ playersPath: "leagues/ncaa/teams",
71
+ votingEnabled: false,
72
+ displayName: "NCAA",
73
+ },
74
+ cfb: {
75
+ playersPath: "leagues/cfb/teams",
76
+ votingEnabled: false,
77
+ displayName: "College Football",
78
+ },
79
+ wnba: {
80
+ playersPath: "leagues/wnba/teams",
81
+ votingEnabled: false,
82
+ displayName: "WNBA",
83
+ },
84
+ global: {
85
+ playersPath: "",
86
+ votingEnabled: false,
87
+ displayName: "Global",
88
+ },
89
+ };
90
+ /**
91
+ * Check if a league supports player voting
92
+ * @param league - The league to check
93
+ * @returns true if the league supports player voting, false otherwise
94
+ */
95
+ const isLeagueSupported = (league) => {
96
+ return exports.SUPPORTED_LEAGUES.includes(league);
97
+ };
98
+ exports.isLeagueSupported = isLeagueSupported;
99
+ /**
100
+ * Validate league support and throw error if unsupported
101
+ * @param league - The league to validate
102
+ * @throws Error if league is not supported for voting
103
+ */
104
+ const validateLeagueSupport = (league) => {
105
+ if (!(0, exports.isLeagueSupported)(league)) {
106
+ throw new Error(`League ${league} does not support player voting`);
107
+ }
108
+ };
109
+ exports.validateLeagueSupport = validateLeagueSupport;
110
+ /**
111
+ * Get league configuration
112
+ * @param league - The league to get configuration for
113
+ * @returns League configuration object
114
+ */
115
+ const getLeagueConfig = (league) => {
116
+ return exports.LEAGUE_CONFIG[league];
117
+ };
118
+ exports.getLeagueConfig = getLeagueConfig;
119
+ /**
120
+ * Get all supported leagues
121
+ * @returns Array of supported league slugs
122
+ */
123
+ const getSupportedLeagues = () => {
124
+ return [...exports.SUPPORTED_LEAGUES];
125
+ };
126
+ exports.getSupportedLeagues = getSupportedLeagues;
127
+ /**
128
+ * Get all unsupported leagues
129
+ * @returns Array of unsupported league slugs
130
+ */
131
+ const getUnsupportedLeagues = () => {
132
+ return [...exports.UNSUPPORTED_LEAGUES];
133
+ };
134
+ exports.getUnsupportedLeagues = getUnsupportedLeagues;
135
+ /**
136
+ * Check if league exists in the system
137
+ * @param league - The league to check
138
+ * @returns true if league exists, false otherwise
139
+ */
140
+ const isValidLeague = (league) => {
141
+ return Object.keys(exports.LEAGUE_CONFIG).includes(league);
142
+ };
143
+ exports.isValidLeague = isValidLeague;
package/dist/index.d.ts CHANGED
@@ -23,3 +23,4 @@ export * from "./models/userEvent";
23
23
  export * from "./helpers/index";
24
24
  export * from "./models/player";
25
25
  export * from "./models/voting";
26
+ export * from "./constants";
package/dist/index.js CHANGED
@@ -39,3 +39,4 @@ __exportStar(require("./models/userEvent"), exports);
39
39
  __exportStar(require("./helpers/index"), exports);
40
40
  __exportStar(require("./models/player"), exports);
41
41
  __exportStar(require("./models/voting"), exports);
42
+ __exportStar(require("./constants"), exports);
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { playerVoteSchema, voteSubmissionDtoSchema, voteSubmissionResponseDtoSchema, mostVotedPlayerSchema, gameVoteResultsSchema, teamPlayersResponseDtoSchema, gamePlayersResponseDtoSchema, userVoteResponseDtoSchema, voteResultsResponseDtoSchema } from "../schemas/voting";
2
+ import { playerVoteSchema, voteSubmissionDtoSchema, voteSubmissionResponseDtoSchema, mostVotedPlayerSchema, gameVoteResultsSchema, teamPlayersResponseDtoSchema, gamePlayersResponseDtoSchema, userVoteResponseDtoSchema, voteResultsResponseDtoSchema, leagueSupportErrorSchema, apiErrorResponseSchema } from "../schemas/voting";
3
3
  export type PlayerVote = z.infer<typeof playerVoteSchema>;
4
4
  export type VoteSubmissionDto = z.infer<typeof voteSubmissionDtoSchema>;
5
5
  export type VoteSubmissionResponseDto = z.infer<typeof voteSubmissionResponseDtoSchema>;
@@ -9,3 +9,5 @@ export type TeamPlayersResponseDto = z.infer<typeof teamPlayersResponseDtoSchema
9
9
  export type GamePlayersResponseDto = z.infer<typeof gamePlayersResponseDtoSchema>;
10
10
  export type UserVoteResponseDto = z.infer<typeof userVoteResponseDtoSchema>;
11
11
  export type VoteResultsResponseDto = z.infer<typeof voteResultsResponseDtoSchema>;
12
+ export type LeagueSupportError = z.infer<typeof leagueSupportErrorSchema>;
13
+ export type ApiErrorResponse = z.infer<typeof apiErrorResponseSchema>;
@@ -3590,3 +3590,38 @@ export declare const voteResultsResponseDtoSchema: z.ZodObject<{
3590
3590
  } | null;
3591
3591
  };
3592
3592
  }>;
3593
+ export declare const leagueSupportErrorSchema: z.ZodObject<{
3594
+ statusCode: z.ZodNumber;
3595
+ message: z.ZodString;
3596
+ error: z.ZodString;
3597
+ league: z.ZodUnion<[z.ZodLiteral<"nba">, z.ZodLiteral<"ncaa">, z.ZodLiteral<"nfl">, z.ZodLiteral<"nhl">, z.ZodLiteral<"mlb">, z.ZodLiteral<"cbb">, z.ZodLiteral<"cfb">, z.ZodLiteral<"epl">, z.ZodLiteral<"mls">, z.ZodLiteral<"wnba">, z.ZodLiteral<"cwc">, z.ZodLiteral<"global">]>;
3598
+ supportedLeagues: z.ZodArray<z.ZodUnion<[z.ZodLiteral<"nba">, z.ZodLiteral<"ncaa">, z.ZodLiteral<"nfl">, z.ZodLiteral<"nhl">, z.ZodLiteral<"mlb">, z.ZodLiteral<"cbb">, z.ZodLiteral<"cfb">, z.ZodLiteral<"epl">, z.ZodLiteral<"mls">, z.ZodLiteral<"wnba">, z.ZodLiteral<"cwc">, z.ZodLiteral<"global">]>, "many">;
3599
+ }, "strip", z.ZodTypeAny, {
3600
+ error: string;
3601
+ message: string;
3602
+ statusCode: number;
3603
+ league: "global" | "nba" | "ncaa" | "nfl" | "nhl" | "mlb" | "cbb" | "cfb" | "epl" | "mls" | "wnba" | "cwc";
3604
+ supportedLeagues: ("global" | "nba" | "ncaa" | "nfl" | "nhl" | "mlb" | "cbb" | "cfb" | "epl" | "mls" | "wnba" | "cwc")[];
3605
+ }, {
3606
+ error: string;
3607
+ message: string;
3608
+ statusCode: number;
3609
+ league: "global" | "nba" | "ncaa" | "nfl" | "nhl" | "mlb" | "cbb" | "cfb" | "epl" | "mls" | "wnba" | "cwc";
3610
+ supportedLeagues: ("global" | "nba" | "ncaa" | "nfl" | "nhl" | "mlb" | "cbb" | "cfb" | "epl" | "mls" | "wnba" | "cwc")[];
3611
+ }>;
3612
+ export declare const apiErrorResponseSchema: z.ZodObject<{
3613
+ statusCode: z.ZodNumber;
3614
+ message: z.ZodString;
3615
+ error: z.ZodString;
3616
+ details: z.ZodOptional<z.ZodAny>;
3617
+ }, "strip", z.ZodTypeAny, {
3618
+ error: string;
3619
+ message: string;
3620
+ statusCode: number;
3621
+ details?: any;
3622
+ }, {
3623
+ error: string;
3624
+ message: string;
3625
+ statusCode: number;
3626
+ details?: any;
3627
+ }>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.voteResultsResponseDtoSchema = exports.userVoteResponseDtoSchema = exports.gamePlayersResponseDtoSchema = exports.teamPlayersResponseDtoSchema = exports.gameVoteResultsSchema = exports.mostVotedPlayerSchema = exports.voteSubmissionResponseDtoSchema = exports.voteSubmissionDtoSchema = exports.playerVoteSchema = void 0;
3
+ exports.apiErrorResponseSchema = exports.leagueSupportErrorSchema = exports.voteResultsResponseDtoSchema = exports.userVoteResponseDtoSchema = exports.gamePlayersResponseDtoSchema = exports.teamPlayersResponseDtoSchema = exports.gameVoteResultsSchema = exports.mostVotedPlayerSchema = exports.voteSubmissionResponseDtoSchema = exports.voteSubmissionDtoSchema = exports.playerVoteSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const sharedTypes_1 = require("./sharedTypes");
6
6
  const player_1 = require("./player");
@@ -66,3 +66,18 @@ exports.userVoteResponseDtoSchema = zod_1.z.object({
66
66
  exports.voteResultsResponseDtoSchema = zod_1.z.object({
67
67
  results: exports.gameVoteResultsSchema,
68
68
  });
69
+ // League Support Error Response
70
+ exports.leagueSupportErrorSchema = zod_1.z.object({
71
+ statusCode: zod_1.z.number(),
72
+ message: zod_1.z.string(),
73
+ error: zod_1.z.string(),
74
+ league: sharedTypes_1.leagueSlug,
75
+ supportedLeagues: zod_1.z.array(sharedTypes_1.leagueSlug),
76
+ });
77
+ // API Error Response (Generic)
78
+ exports.apiErrorResponseSchema = zod_1.z.object({
79
+ statusCode: zod_1.z.number(),
80
+ message: zod_1.z.string(),
81
+ error: zod_1.z.string(),
82
+ details: zod_1.z.any().optional(),
83
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rategame-shared",
3
- "version": "1.1.243",
3
+ "version": "1.1.244",
4
4
  "description": "This package contains shared resources for the Rate Game project.",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",