overtime-utils 0.1.41 → 0.1.43

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": "overtime-utils",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "",
5
5
  "main": "main.js",
6
6
  "scripts": {
@@ -34,4 +34,11 @@ export const DARTS_LEAGUES: Partial<Record<League, LeagueInfo>> = {
34
34
  opticOddsName: 'PDC - World Grand Prix',
35
35
  priority: 2003,
36
36
  },
37
+ [League.PDC_GRAND_SLAM_OF_DARTS]: {
38
+ ...DARTS_DEFAULTS,
39
+ id: League.PDC_GRAND_SLAM_OF_DARTS,
40
+ label: 'PDC Grand Slam of Darts',
41
+ opticOddsName: 'PDC - Grand Slam of Darts',
42
+ priority: 2004,
43
+ },
37
44
  };
@@ -1,5 +1,6 @@
1
1
  import { MarketType, ResultType } from '../enums/marketTypes';
2
2
  import { MarketTypeInfo } from '../types/marketTypes';
3
+ import { computeOutcomesForMarket } from '../utils/outcomes';
3
4
 
4
5
  export const MarketTypeMap: Record<MarketType, MarketTypeInfo> = {
5
6
  [MarketType.EMPTY]: {
@@ -3349,3 +3350,22 @@ export const COMBINED_POSITIONS_MARKET_TYPES = [
3349
3350
  MarketType.HALFTIME_FULLTIME_GOALS,
3350
3351
  ...SGP_BUILDER_MARKET_TYPES,
3351
3352
  ];
3353
+
3354
+ export const YES_NO_OUTCOME_MARKET_TYPES = new Set<MarketType>([
3355
+ ...ONE_SIDE_PLAYER_PROPS_MARKET_TYPES,
3356
+ ...YES_NO_PLAYER_PROPS_MARKET_TYPES,
3357
+ ...BOTH_TEAMS_TO_SCORE_MARKET_TYPES,
3358
+ ...OTHER_YES_NO_MARKET_TYPES,
3359
+ ]);
3360
+
3361
+ Object.keys(MarketTypeMap).forEach((key) => {
3362
+ const keyNum = Number(key);
3363
+ if (Number.isNaN(keyNum)) return;
3364
+ const mt = keyNum as MarketType;
3365
+ const info = MarketTypeMap[mt];
3366
+ if (!info) return;
3367
+ const outcomes = computeOutcomesForMarket(mt, info.resultType);
3368
+ if (outcomes) {
3369
+ info.outcomes = outcomes;
3370
+ }
3371
+ });
@@ -283,6 +283,7 @@ export enum League {
283
283
  ENGLAND_PREMIER_LEAGUE_DARTS = 20320,
284
284
  PDC_WORLD_CUP_OF_DARTS = 20321,
285
285
  PDC_WORLD_GRAND_PRIX = 20324,
286
+ PDC_GRAND_SLAM_OF_DARTS = 20325,
286
287
  ARGENTINA_LIGA_ARGENTINA = 20400,
287
288
  ARGENTINA_LIGA_ARGENTINA_WOMEN = 20401,
288
289
  AUSTRIA_AVL = 20402,
@@ -8,4 +8,5 @@ export type MarketTypeInfo = {
8
8
  description?: string;
9
9
  tooltipKey?: string;
10
10
  resultType?: ResultType;
11
+ outcomes?: string[];
11
12
  };
@@ -0,0 +1,367 @@
1
+ import {
2
+ AWAY_TEAM_MARKET_TYPES,
3
+ CORRECT_SCORE_MARKET_TYPES,
4
+ DOUBLE_CHANCE_MARKET_TYPES,
5
+ DRAW_NO_BET_MARKET_TYPES,
6
+ HOME_TEAM_MARKET_TYPES,
7
+ SCORE_MARKET_TYPES,
8
+ TOTAL_EXACT_MARKET_TYPES,
9
+ TOTAL_ODD_EVEN_MARKET_TYPES,
10
+ WINNER_MARKET_TYPES,
11
+ YES_NO_OUTCOME_MARKET_TYPES,
12
+ } from '../constants/marketTypes';
13
+ import { MarketType, ResultType } from '../enums/marketTypes';
14
+
15
+ // Outcome grouping enum
16
+ export enum OutcomeGroup {
17
+ YES_NO = 'YES_NO',
18
+ ODD_EVEN = 'ODD_EVEN',
19
+ SCORE_HOME_AWAY_NO = 'SCORE_HOME_AWAY_NO',
20
+ DOUBLE_CHANCE = 'DOUBLE_CHANCE',
21
+ HALFTIME_FULLTIME = 'HALFTIME_FULLTIME',
22
+ WINNING_ROUND = 'WINNING_ROUND',
23
+ ENDING_METHOD = 'ENDING_METHOD',
24
+ METHOD_OF_VICTORY = 'METHOD_OF_VICTORY',
25
+ WINNER_THREE_WAY = 'WINNER_THREE_WAY',
26
+ WINNER_TWO_WAY = 'WINNER_TWO_WAY',
27
+ TOTAL_EXACT_HOME = 'TOTAL_EXACT_HOME',
28
+ TOTAL_EXACT_AWAY = 'TOTAL_EXACT_AWAY',
29
+ CORRECT_SCORE = 'CORRECT_SCORE',
30
+ OVER_UNDER = 'OVER_UNDER',
31
+ OVER_UNDER_HOME = 'OVER_UNDER_HOME',
32
+ OVER_UNDER_AWAY = 'OVER_UNDER_AWAY',
33
+ SPREAD_TWO_WAY = 'SPREAD_TWO_WAY',
34
+ }
35
+
36
+ const makeExactTotals = (prefix: 'home' | 'away'): string[] => [
37
+ `${prefix} 0`,
38
+ `${prefix} 1`,
39
+ `${prefix} 2`,
40
+ `${prefix} 3`,
41
+ `${prefix} 4`,
42
+ `${prefix} 5`,
43
+ `${prefix} 3+`,
44
+ `${prefix} 4+`,
45
+ `${prefix} 5+`,
46
+ ];
47
+
48
+ // Exhaustive correct score outcomes
49
+ const CORRECT_SCORE_OUTCOMES: string[] = [
50
+ 'draw 0:0',
51
+ 'draw 1:1',
52
+ 'draw 2:2',
53
+ 'draw 3:3',
54
+ 'draw 4:4',
55
+ 'home 1:0',
56
+ 'home 2:0',
57
+ 'home 2:1',
58
+ 'home 3:0',
59
+ 'home 3:1',
60
+ 'home 3:2',
61
+ 'home 4:0',
62
+ 'home 4:1',
63
+ 'home 4:2',
64
+ 'home 4:3',
65
+ 'away 1:0',
66
+ 'away 2:0',
67
+ 'away 2:1',
68
+ 'away 3:0',
69
+ 'away 3:1',
70
+ 'away 3:2',
71
+ 'away 4:0',
72
+ 'away 4:1',
73
+ 'away 4:2',
74
+ 'away 4:3',
75
+ 'draw 5:5',
76
+ 'draw 6:6',
77
+ 'draw 7:7',
78
+ 'draw 8:8',
79
+ 'draw 9:9',
80
+ 'draw 10:10',
81
+ 'draw 11:11',
82
+ 'draw 12:12',
83
+ 'draw 13:13',
84
+ 'draw 14:14',
85
+ 'home 5:0',
86
+ 'home 5:1',
87
+ 'home 5:2',
88
+ 'home 5:3',
89
+ 'home 5:4',
90
+ 'home 6:0',
91
+ 'home 6:1',
92
+ 'home 6:2',
93
+ 'home 6:3',
94
+ 'home 6:4',
95
+ 'home 6:5',
96
+ 'home 7:0',
97
+ 'home 7:1',
98
+ 'home 7:2',
99
+ 'home 7:3',
100
+ 'home 7:4',
101
+ 'home 7:5',
102
+ 'home 7:6',
103
+ 'home 8:0',
104
+ 'home 8:1',
105
+ 'home 8:2',
106
+ 'home 8:3',
107
+ 'home 8:4',
108
+ 'home 8:5',
109
+ 'home 8:6',
110
+ 'home 8:7',
111
+ 'home 9:0',
112
+ 'home 9:1',
113
+ 'home 9:2',
114
+ 'home 9:3',
115
+ 'home 9:4',
116
+ 'home 9:5',
117
+ 'home 9:6',
118
+ 'home 9:7',
119
+ 'home 9:8',
120
+ 'home 10:0',
121
+ 'home 10:1',
122
+ 'home 10:2',
123
+ 'home 10:3',
124
+ 'home 10:4',
125
+ 'home 10:5',
126
+ 'home 10:6',
127
+ 'home 10:7',
128
+ 'home 10:8',
129
+ 'home 10:9',
130
+ 'home 11:0',
131
+ 'home 11:1',
132
+ 'home 11:2',
133
+ 'home 11:3',
134
+ 'home 11:4',
135
+ 'home 11:5',
136
+ 'home 11:6',
137
+ 'home 11:7',
138
+ 'home 11:8',
139
+ 'home 11:9',
140
+ 'home 11:10',
141
+ 'home 12:0',
142
+ 'home 12:1',
143
+ 'home 12:2',
144
+ 'home 12:3',
145
+ 'home 12:4',
146
+ 'home 12:5',
147
+ 'home 12:6',
148
+ 'home 12:7',
149
+ 'home 12:8',
150
+ 'home 12:9',
151
+ 'home 12:10',
152
+ 'home 12:11',
153
+ 'home 13:0',
154
+ 'home 13:1',
155
+ 'home 13:2',
156
+ 'home 13:3',
157
+ 'home 13:4',
158
+ 'home 13:5',
159
+ 'home 13:6',
160
+ 'home 13:7',
161
+ 'home 13:8',
162
+ 'home 13:9',
163
+ 'home 13:10',
164
+ 'home 13:11',
165
+ 'home 13:12',
166
+ 'home 14:0',
167
+ 'home 14:1',
168
+ 'home 14:2',
169
+ 'home 14:3',
170
+ 'home 14:4',
171
+ 'home 14:5',
172
+ 'home 14:6',
173
+ 'home 14:7',
174
+ 'home 14:8',
175
+ 'home 14:9',
176
+ 'home 14:10',
177
+ 'home 14:11',
178
+ 'home 14:12',
179
+ 'home 14:13',
180
+ 'away 5:0',
181
+ 'away 5:1',
182
+ 'away 5:2',
183
+ 'away 5:3',
184
+ 'away 5:4',
185
+ 'away 6:0',
186
+ 'away 6:1',
187
+ 'away 6:2',
188
+ 'away 6:3',
189
+ 'away 6:4',
190
+ 'away 6:5',
191
+ 'away 7:0',
192
+ 'away 7:1',
193
+ 'away 7:2',
194
+ 'away 7:3',
195
+ 'away 7:4',
196
+ 'away 7:5',
197
+ 'away 7:6',
198
+ 'away 8:0',
199
+ 'away 8:1',
200
+ 'away 8:2',
201
+ 'away 8:3',
202
+ 'away 8:4',
203
+ 'away 8:5',
204
+ 'away 8:6',
205
+ 'away 8:7',
206
+ 'away 9:0',
207
+ 'away 9:1',
208
+ 'away 9:2',
209
+ 'away 9:3',
210
+ 'away 9:4',
211
+ 'away 9:5',
212
+ 'away 9:6',
213
+ 'away 9:7',
214
+ 'away 9:8',
215
+ 'away 10:0',
216
+ 'away 10:1',
217
+ 'away 10:2',
218
+ 'away 10:3',
219
+ 'away 10:4',
220
+ 'away 10:5',
221
+ 'away 10:6',
222
+ 'away 10:7',
223
+ 'away 10:8',
224
+ 'away 10:9',
225
+ 'away 11:0',
226
+ 'away 11:1',
227
+ 'away 11:2',
228
+ 'away 11:3',
229
+ 'away 11:4',
230
+ 'away 11:5',
231
+ 'away 11:6',
232
+ 'away 11:7',
233
+ 'away 11:8',
234
+ 'away 11:9',
235
+ 'away 11:10',
236
+ 'away 12:0',
237
+ 'away 12:1',
238
+ 'away 12:2',
239
+ 'away 12:3',
240
+ 'away 12:4',
241
+ 'away 12:5',
242
+ 'away 12:6',
243
+ 'away 12:7',
244
+ 'away 12:8',
245
+ 'away 12:9',
246
+ 'away 12:10',
247
+ 'away 12:11',
248
+ 'away 13:0',
249
+ 'away 13:1',
250
+ 'away 13:2',
251
+ 'away 13:3',
252
+ 'away 13:4',
253
+ 'away 13:5',
254
+ 'away 13:6',
255
+ 'away 13:7',
256
+ 'away 13:8',
257
+ 'away 13:9',
258
+ 'away 13:10',
259
+ 'away 13:11',
260
+ 'away 13:12',
261
+ 'away 14:0',
262
+ 'away 14:1',
263
+ 'away 14:2',
264
+ 'away 14:3',
265
+ 'away 14:4',
266
+ 'away 14:5',
267
+ 'away 14:6',
268
+ 'away 14:7',
269
+ 'away 14:8',
270
+ 'away 14:9',
271
+ 'away 14:10',
272
+ 'away 14:11',
273
+ 'away 14:12',
274
+ 'away 14:13',
275
+ 'other',
276
+ ];
277
+
278
+ export const OUTCOMES_BY_GROUP: Record<OutcomeGroup, string[]> = {
279
+ [OutcomeGroup.YES_NO]: ['yes', 'no'],
280
+ [OutcomeGroup.ODD_EVEN]: ['odd', 'even'],
281
+ [OutcomeGroup.SCORE_HOME_AWAY_NO]: ['home', 'away', 'no'],
282
+ [OutcomeGroup.DOUBLE_CHANCE]: ['home or draw', 'home or away', 'away or draw'],
283
+ [OutcomeGroup.HALFTIME_FULLTIME]: [
284
+ 'home/home',
285
+ 'home/away',
286
+ 'home/draw',
287
+ 'away/home',
288
+ 'away/away',
289
+ 'away/draw',
290
+ 'draw/home',
291
+ 'draw/away',
292
+ 'draw/draw',
293
+ ],
294
+ [OutcomeGroup.WINNING_ROUND]: [
295
+ 'draw',
296
+ 'by decision',
297
+ 'round 1',
298
+ 'round 2',
299
+ 'round 3',
300
+ 'round 4',
301
+ 'round 5',
302
+ 'round 6',
303
+ 'round 7',
304
+ 'round 8',
305
+ 'round 9',
306
+ 'round 10',
307
+ ],
308
+ [OutcomeGroup.ENDING_METHOD]: ['draw', 'by decision', 'KO/TKO/DQ', 'submission'],
309
+ [OutcomeGroup.METHOD_OF_VICTORY]: [
310
+ 'draw',
311
+ 'home (decision)',
312
+ 'home (KO/TKO/DQ)',
313
+ 'home (submission)',
314
+ 'away (decision)',
315
+ 'away (KO/TKO/DQ)',
316
+ 'away (submission)',
317
+ ],
318
+ [OutcomeGroup.WINNER_THREE_WAY]: ['home', 'away', 'draw'],
319
+ [OutcomeGroup.WINNER_TWO_WAY]: ['home', 'away'],
320
+ [OutcomeGroup.TOTAL_EXACT_HOME]: makeExactTotals('home'),
321
+ [OutcomeGroup.TOTAL_EXACT_AWAY]: makeExactTotals('away'),
322
+ [OutcomeGroup.CORRECT_SCORE]: CORRECT_SCORE_OUTCOMES,
323
+ [OutcomeGroup.OVER_UNDER]: ['over', 'under'],
324
+ [OutcomeGroup.OVER_UNDER_HOME]: ['home over', 'home under'],
325
+ [OutcomeGroup.OVER_UNDER_AWAY]: ['away over', 'away under'],
326
+ [OutcomeGroup.SPREAD_TWO_WAY]: ['home', 'away'],
327
+ };
328
+
329
+ // Select an outcome group using market grouping arrays and result type
330
+ const getOutcomeGroup = (marketType: MarketType, resultType?: ResultType): OutcomeGroup | undefined => {
331
+ if (YES_NO_OUTCOME_MARKET_TYPES.has(marketType)) return OutcomeGroup.YES_NO;
332
+ if (TOTAL_ODD_EVEN_MARKET_TYPES.includes(marketType)) return OutcomeGroup.ODD_EVEN;
333
+ if (SCORE_MARKET_TYPES.includes(marketType)) return OutcomeGroup.SCORE_HOME_AWAY_NO;
334
+ if (DOUBLE_CHANCE_MARKET_TYPES.includes(marketType)) return OutcomeGroup.DOUBLE_CHANCE;
335
+ if (WINNER_MARKET_TYPES.includes(marketType)) {
336
+ if (DRAW_NO_BET_MARKET_TYPES.includes(marketType)) return OutcomeGroup.WINNER_TWO_WAY;
337
+ return OutcomeGroup.WINNER_THREE_WAY;
338
+ }
339
+ if (TOTAL_EXACT_MARKET_TYPES.includes(marketType)) {
340
+ if (HOME_TEAM_MARKET_TYPES.includes(marketType)) return OutcomeGroup.TOTAL_EXACT_HOME;
341
+ if (AWAY_TEAM_MARKET_TYPES.includes(marketType)) return OutcomeGroup.TOTAL_EXACT_AWAY;
342
+ }
343
+ if (CORRECT_SCORE_MARKET_TYPES.includes(marketType)) return OutcomeGroup.CORRECT_SCORE;
344
+ if (marketType === MarketType.HALFTIME_FULLTIME) return OutcomeGroup.HALFTIME_FULLTIME;
345
+ if (marketType === MarketType.WINNING_ROUND) return OutcomeGroup.WINNING_ROUND;
346
+ if (marketType === MarketType.ENDING_METHOD) return OutcomeGroup.ENDING_METHOD;
347
+ if (marketType === MarketType.METHOD_OF_VICTORY) return OutcomeGroup.METHOD_OF_VICTORY;
348
+ if (!resultType) return undefined;
349
+ switch (resultType) {
350
+ case ResultType.OVER_UNDER: {
351
+ if (HOME_TEAM_MARKET_TYPES.includes(marketType)) return OutcomeGroup.OVER_UNDER_HOME;
352
+ if (AWAY_TEAM_MARKET_TYPES.includes(marketType)) return OutcomeGroup.OVER_UNDER_AWAY;
353
+ return OutcomeGroup.OVER_UNDER;
354
+ }
355
+ case ResultType.SPREAD: {
356
+ return OutcomeGroup.SPREAD_TWO_WAY;
357
+ }
358
+ default:
359
+ return undefined;
360
+ }
361
+ };
362
+
363
+ export const computeOutcomesForMarket = (marketType: MarketType, resultType?: ResultType): string[] | undefined => {
364
+ const group = getOutcomeGroup(marketType, resultType);
365
+ if (!group) return undefined;
366
+ return OUTCOMES_BY_GROUP[group];
367
+ };
File without changes
File without changes
File without changes