@sportsbroker/firebase-structure 5.2.0 → 5.4.0

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.
Files changed (35) hide show
  1. package/firestore/bet-events/bet-events.d.ts +1 -0
  2. package/firestore/{b2b-bet-events/b2b-bet-events.model.ts → bet-events/bet-events.model.ts} +24 -27
  3. package/firestore/bet-events/index.ts +1 -0
  4. package/firestore/bets/bets.d.ts +1 -0
  5. package/firestore/bets/bets.model.ts +45 -0
  6. package/firestore/bets/index.ts +1 -0
  7. package/firestore/events/events.d.ts +1 -0
  8. package/firestore/{b2b-events/b2b-events.model.ts → events/events.model.ts} +6 -6
  9. package/firestore/events/index.ts +1 -0
  10. package/firestore/fixtures/fixtures.d.ts +1 -0
  11. package/firestore/{b2b-matches/b2b-match.model.ts → fixtures/fixtures.model.ts} +7 -7
  12. package/firestore/fixtures/index.ts +1 -0
  13. package/firestore/index.d.ts +1 -1
  14. package/firestore/pools/index.ts +1 -0
  15. package/firestore/{b2b-pools/b2b-pools.model.ts → pools/pools.model.ts} +7 -7
  16. package/firestore/question-sets/index.ts +2 -0
  17. package/firestore/question-sets/question-sets.d.ts +1 -0
  18. package/firestore/{b2b-question-sets/b2b-question-sets.model.ts → question-sets/question-sets.model.ts} +6 -6
  19. package/firestore/question-sets/question.d.ts +1 -0
  20. package/firestore/{match-predictor/match-predictor-question.d.ts → question-sets/question.model.ts} +5 -5
  21. package/package.json +1 -1
  22. package/firestore/b2b-bet-events/b2b-bet-events.d.ts +0 -1
  23. package/firestore/b2b-bet-events/index.ts +0 -1
  24. package/firestore/b2b-bets/b2b-bets.d.ts +0 -1
  25. package/firestore/b2b-bets/b2b-bets.model.ts +0 -87
  26. package/firestore/b2b-bets/index.ts +0 -1
  27. package/firestore/b2b-events/b2b-events.d.ts +0 -1
  28. package/firestore/b2b-events/index.ts +0 -1
  29. package/firestore/b2b-matches/b2b-match.d.ts +0 -1
  30. package/firestore/b2b-matches/index.ts +0 -1
  31. package/firestore/b2b-pools/index.ts +0 -1
  32. package/firestore/b2b-question-sets/b2b-question-sets.d.ts +0 -1
  33. package/firestore/b2b-question-sets/index.ts +0 -1
  34. package/firestore/match-predictor/index.ts +0 -2
  35. package/firestore/match-predictor/match-predictor.d.ts +0 -56
@@ -0,0 +1 @@
1
+ export * from "./bet-events.model";
@@ -1,31 +1,30 @@
1
- import { B2BPool } from "../b2b-pools";
1
+ import { Pool } from "../pools";
2
+ import { Question } from "../question-sets";
2
3
  import type { ISODate, UUID } from "../common";
3
- import type { MPQuestion } from "../match-predictor";
4
4
 
5
- export type B2BBetEvent = {
5
+ export type BetEvent = {
6
6
  id: string;
7
7
  startDate: ISODate;
8
- status: B2BBetEventStatusType;
9
- bettingStatus: B2BBetEventBettingStatusType;
8
+ status: BetEventStatusType;
9
+ bettingStatus: BetEventBettingStatusType;
10
10
  engine: GameEngineEnum;
11
- gameSpecificData: B2BMPEventGameSpecificData;
11
+ gameSpecificData: EventGameSpecificData;
12
12
  resultsData: ResultsData;
13
- poolData: B2BPool;
13
+ poolData: Pool;
14
14
  createdAt: ISODate;
15
15
  updatedAt: ISODate;
16
16
  };
17
17
 
18
- export type ResultsData = B2BMPEventResultsData;
18
+ export type ResultsData = EventResultsData;
19
19
 
20
20
  export enum GameEngineEnum {
21
21
  MATCH_PREDICTOR = "match-predictor",
22
- SCORE_PREDICTOR = "score-predictor",
23
22
  EDGE = "edge"
24
23
  }
25
24
 
26
- export type B2BBetEventBettingStatusType = "locked" | "unlocked" | "settled";
25
+ export type BetEventBettingStatusType = "locked" | "unlocked" | "settled";
27
26
 
28
- export type B2BBetEventStatusType =
27
+ export type BetEventStatusType =
29
28
  | "pending" // before we start display event ald at this time betting is locked
30
29
  | "open" // now we can place bets on event but match did not start yet
31
30
  | "event-in-progress" // match already started betting is locked again
@@ -34,20 +33,18 @@ export type B2BBetEventStatusType =
34
33
  | "finished" // event is finished and settled
35
34
  | "cancelled"; // event is cancelled
36
35
 
37
- ////////////////////////////////////// MATCH PREDICTOR SPECIFIC TYPES //////////////////////////////////////
38
-
39
- export type B2BMPEventGameSpecificData = {
36
+ export type EventGameSpecificData = {
40
37
  matchId: UUID;
41
- questions: MPQuestion[];
38
+ questions: Question[];
42
39
  };
43
40
 
44
- export type B2BMPEventResultsData = {
45
- [mpQuestionKey: MPQuestionKeyType]: B2BMPEventResultData;
41
+ export type EventResultsData = {
42
+ [questionKey: QuestionKey]: EventResultData;
46
43
  };
47
44
 
48
- export type MPQuestionKeyType = `${MPQuestionKeyEnum}` | string;
45
+ export type QuestionKey = `${QuestionKeyEnum}` | string;
49
46
 
50
- export enum MPQuestionKeyEnum {
47
+ export enum QuestionKeyEnum {
51
48
  MATCH_SCORE = "match-score",
52
49
  TOTAL_SHOTS_ON_TARGET = "total-shots-on-target",
53
50
  TOTAL_CARDS = "total-cards",
@@ -61,18 +58,18 @@ export enum MPQuestionKeyEnum {
61
58
  CORNERS_10_OR_MORE = "corners-10-or-more",
62
59
  }
63
60
 
64
- export type B2BMPEventResultData = MPQuestion & {
61
+ export type EventResultData = Question & {
65
62
  result: {
66
63
  isFinal: boolean;
67
- value: MPQuestionResultTypeValueType[MPQuestionResultTypeEnum];
64
+ value: QuestionResultTypeValueType[QuestionResultTypeEnum];
68
65
  };
69
66
  };
70
67
 
71
- export type MPQuestionResultTypeValueType = {
72
- [MPQuestionResultTypeEnum.BOTH_SIDES_POSITIVE_INTEGER]: BothSidesPositiveInteger;
73
- [MPQuestionResultTypeEnum.POSITIVE_INTEGER]: PositiveInteger;
74
- [MPQuestionResultTypeEnum.MATCH_SIDE_RESULT]: MatchSideResultEnum;
75
- [MPQuestionResultTypeEnum.YES_NO]: YesNoResultEnum;
68
+ export type QuestionResultTypeValueType = {
69
+ [QuestionResultTypeEnum.BOTH_SIDES_POSITIVE_INTEGER]: BothSidesPositiveInteger;
70
+ [QuestionResultTypeEnum.POSITIVE_INTEGER]: PositiveInteger;
71
+ [QuestionResultTypeEnum.MATCH_SIDE_RESULT]: MatchSideResultEnum;
72
+ [QuestionResultTypeEnum.YES_NO]: YesNoResultEnum;
76
73
  };
77
74
 
78
75
  export enum MatchSideResultEnum {
@@ -87,7 +84,7 @@ export enum YesNoResultEnum {
87
84
  export type BothSidesPositiveInteger = { home: number; away: number };
88
85
  export type PositiveInteger = number;
89
86
 
90
- export enum MPQuestionResultTypeEnum {
87
+ export enum QuestionResultTypeEnum {
91
88
  BOTH_SIDES_POSITIVE_INTEGER = "both-sides-positive-integer",
92
89
  POSITIVE_INTEGER = "positive-integer",
93
90
  MATCH_SIDE_RESULT = "match-side-result",
@@ -0,0 +1 @@
1
+ export * from "./bet-events.model";
@@ -0,0 +1 @@
1
+ export * from "./bets.model";
@@ -0,0 +1,45 @@
1
+ import type { GameEngineEnum } from "../bet-events";
2
+ import type { QuestionResultValue } from "../events";
3
+ import type { ISODate, UUID } from "../common";
4
+
5
+ export type Bet = {
6
+ id: string;
7
+ userId: UUID;
8
+ engine: GameEngineEnum;
9
+ questionSetId: UUID;
10
+ status: BetStatusEnum;
11
+ betEventId: UUID;
12
+ predictions: BetPredictionType[];
13
+ createdAt: ISODate;
14
+ updatedAt: ISODate;
15
+ };
16
+
17
+ export enum BetStatusEnum {
18
+ OPEN = "open",
19
+ PENDING = "pending",
20
+ WON = "won",
21
+ LOST = "lost",
22
+ CANCELLED = "cancelled",
23
+ LOCKED = "locked",
24
+ }
25
+
26
+ export type BetPredictionType = Prediction;
27
+
28
+ export type Prediction = {
29
+ eventQuestionId: UUID;
30
+ predictionValue: QuestionResultValue;
31
+ };
32
+
33
+ export enum MatchSideResultEnum {
34
+ HOME = "home",
35
+ AWAY = "away",
36
+ DRAW = "draw",
37
+ }
38
+ export enum YesNoResultEnum {
39
+ YES = "yes",
40
+ NO = "no",
41
+ }
42
+ export type BothSidesPositiveInteger = { home: number; away: number };
43
+ export type PositiveInteger = number;
44
+
45
+
@@ -0,0 +1 @@
1
+ export * from "./bets.model";
@@ -0,0 +1 @@
1
+ export * from "./events.model";
@@ -1,15 +1,15 @@
1
1
  import type {
2
- B2BBetEventBettingStatusType,
3
- B2BBetEventStatusType,
2
+ BetEventBettingStatusType,
3
+ BetEventStatusType,
4
4
  GameEngineEnum,
5
- } from "../b2b-bet-events";
5
+ } from "../bet-events";
6
6
  import type { ISODate, UUID } from "../common";
7
7
 
8
- export type B2BEvent = {
8
+ export type Event = {
9
9
  id: UUID;
10
10
  startDate: ISODate;
11
- status: B2BBetEventStatusType;
12
- bettingStatus: B2BBetEventBettingStatusType;
11
+ status: BetEventStatusType;
12
+ bettingStatus: BetEventBettingStatusType;
13
13
  engine: GameEngineEnum;
14
14
  questionSetId: UUID;
15
15
  name: string;
@@ -0,0 +1 @@
1
+ export * from "./events.model";
@@ -0,0 +1 @@
1
+ export * from "./fixtures.model";
@@ -1,11 +1,11 @@
1
1
  import type { ISODate, UUID } from "../common";
2
2
 
3
- export type B2BMatch = {
3
+ export type Fixture = {
4
4
  id: UUID;
5
5
  startDate: ISODate;
6
6
  homeTeam: MatchTeam;
7
7
  awayTeam: MatchTeam;
8
- status: B2BMatchStatus;
8
+ status: FixtureStatus;
9
9
  createdAt: ISODate;
10
10
  updatedAt: ISODate;
11
11
  };
@@ -17,17 +17,17 @@ export type MatchTeam = {
17
17
  score: number;
18
18
  };
19
19
 
20
- export type B2BMatchStatus = {
21
- matchStatus: B2BMatchStatusType;
20
+ export type FixtureStatus = {
21
+ matchStatus: FixtureStatusType;
22
22
  isActive: boolean;
23
- period: B2BMatchPeriod;
23
+ period: FixturePeriod;
24
24
  periodId: number;
25
25
  minutes: number;
26
26
  additionalMinutes: number;
27
27
  fullTimeFinished: boolean;
28
28
  };
29
29
 
30
- export type B2BMatchPeriod =
30
+ export type FixturePeriod =
31
31
  | "PRE_MATCH"
32
32
  | "FIRST_HALF"
33
33
  | "SECOND_HALF"
@@ -35,7 +35,7 @@ export type B2BMatchPeriod =
35
35
  | "SECOND_OVERTIME_HALF"
36
36
  | "SHOOTOUT";
37
37
 
38
- export type B2BMatchStatusType =
38
+ export type FixtureStatusType =
39
39
  | "finished"
40
40
  | "preMatch"
41
41
  | "live"
@@ -0,0 +1 @@
1
+ export * from "./fixtures.model";
@@ -1,3 +1,3 @@
1
1
  export * from "./common";
2
2
  export * from "./user-status";
3
- export * from "./b2b-pools";
3
+ export * from "./pools";
@@ -0,0 +1 @@
1
+ export * from "./pools.model";
@@ -1,4 +1,4 @@
1
- import { B2BBetEventStatusType, GameEngineEnum } from "../b2b-bet-events";
1
+ import { BetEventStatusType, GameEngineEnum } from "../bet-events";
2
2
  import type { ISODate, UUID } from "../common";
3
3
 
4
4
  export type PoolPayoutStructure = { [position: string]: number };
@@ -9,9 +9,9 @@ export enum PrizeDistributionStrategyEnum {
9
9
  TOP_5 = "top-5",
10
10
  }
11
11
 
12
- export type B2BPoolEvent = {
12
+ export type PoolEvent = {
13
13
  questionSetId: UUID;
14
- status: B2BBetEventStatusType;
14
+ status: BetEventStatusType;
15
15
  engine: GameEngineEnum;
16
16
  startDate?: ISODate;
17
17
  matchIds?: UUID[];
@@ -19,7 +19,7 @@ export type B2BPoolEvent = {
19
19
  countryCodes?: string[];
20
20
  };
21
21
 
22
- export type B2BPoolLeaderboard = {
22
+ export type PoolLeaderboard = {
23
23
  entries: {
24
24
  userId: UUID;
25
25
  displayName: string;
@@ -29,7 +29,7 @@ export type B2BPoolLeaderboard = {
29
29
  }[];
30
30
  };
31
31
 
32
- export type B2BPool = {
32
+ export type Pool = {
33
33
  id: UUID;
34
34
  betEventId: UUID;
35
35
  operatorId: UUID;
@@ -38,8 +38,8 @@ export type B2BPool = {
38
38
  participants: number; // active bets count
39
39
  entryFee: number;
40
40
  currency: string;
41
- event: B2BPoolEvent;
42
- leaderboard: B2BPoolLeaderboard;
41
+ event: PoolEvent;
42
+ leaderboard: PoolLeaderboard;
43
43
  payoutStructure: PoolPayoutStructure;
44
44
  prizeDistributionStrategy: PrizeDistributionStrategyEnum;
45
45
  createdAt: ISODate;
@@ -0,0 +1,2 @@
1
+ export * from "./question-sets.model";
2
+ export * from "./question.model";
@@ -0,0 +1 @@
1
+ export * from "./question-sets.model";
@@ -1,17 +1,17 @@
1
1
  import type { ISODate, UUID } from "../common";
2
- import type { InGameEventKey, QuestionTypeEnum } from "../b2b-events";
2
+ import type { InGameEventKey, QuestionTypeEnum } from "../events";
3
3
 
4
- export type B2BQuestionSet = {
4
+ export type QuestionSet = {
5
5
  id: UUID;
6
6
  displayName: string;
7
- questions: B2BQuestionTemplate[];
7
+ questions: QuestionTemplate[];
8
8
  rules: string;
9
- status: B2BQuestionSetStatusEnum;
9
+ status: QuestionSetStatusEnum;
10
10
  createdAt: ISODate;
11
11
  updatedAt: ISODate;
12
12
  };
13
13
 
14
- export type B2BQuestionTemplate = {
14
+ export type QuestionTemplate = {
15
15
  id: UUID;
16
16
  providerKey: string;
17
17
  displayOrder: number;
@@ -25,7 +25,7 @@ export type B2BQuestionTemplate = {
25
25
  pointsForWrongAnswer: number;
26
26
  };
27
27
 
28
- export enum B2BQuestionSetStatusEnum {
28
+ export enum QuestionSetStatusEnum {
29
29
  DRAFT = "draft",
30
30
  PUBLISHED = "published",
31
31
  ARCHIVED = "archived",
@@ -0,0 +1 @@
1
+ export * from "./question.model";
@@ -1,11 +1,11 @@
1
- export type MPQuestion = {
2
- key: MPQuestionKey;
1
+ export type Question = {
2
+ key: QuestionKey;
3
3
  points: number;
4
- resultValueType: MPQuestionResultType;
4
+ resultValueType: QuestionResultType;
5
5
  displayOrder: number;
6
6
  };
7
7
 
8
- export type MPQuestionKey =
8
+ export type QuestionKey =
9
9
  | "match-score"
10
10
  | "total-shots-on-target"
11
11
  | "total-cards"
@@ -18,7 +18,7 @@ export type MPQuestionKey =
18
18
  | "most-tackles-won"
19
19
  | "corners-10-or-more";
20
20
 
21
- export type MPQuestionResultType =
21
+ export type QuestionResultType =
22
22
  | "both-sides-positive-integer"
23
23
  | "positive-integer"
24
24
  | "match-side-result"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sportsbroker/firebase-structure",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "Firebase structure typings",
5
5
  "main": "index.d.ts",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- export * from "./b2b-bet-events.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-bet-events.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-bets.model";
@@ -1,87 +0,0 @@
1
- import type { GameEngineEnum } from "../b2b-bet-events";
2
- import type { QuestionResultValue } from "../b2b-events";
3
- import type { ISODate, UUID } from "../common";
4
-
5
- export type B2BBet = {
6
- id: string;
7
- userId: UUID;
8
- engine: GameEngineEnum;
9
- questionSetId: UUID;
10
- status: BetStatusEnum;
11
- betEventId: UUID;
12
- predictions: BetPredictionType[];
13
- createdAt: ISODate;
14
- updatedAt: ISODate;
15
- };
16
-
17
- export enum BetStatusEnum {
18
- OPEN = "open",
19
- PENDING = "pending",
20
- WON = "won",
21
- LOST = "lost",
22
- CANCELLED = "cancelled",
23
- LOCKED = "locked",
24
- }
25
-
26
- export type BetPredictionType = MPPrediction | Prediction;
27
-
28
- export type MPPrediction = {
29
- questionKey: MPQuestionKeyEnum;
30
- predictionValue: MPQuestionResultTypeValueType[MPQuestionResultTypeEnum];
31
- };
32
-
33
- export type Prediction = {
34
- eventQuestionId: UUID;
35
- predictionValue: QuestionResultValue;
36
- };
37
-
38
- export enum MPQuestionKeyEnum {
39
- MATCH_SCORE = "match-score",
40
- TOTAL_SHOTS_ON_TARGET = "total-shots-on-target",
41
- TOTAL_CARDS = "total-cards",
42
- // MATCH_RESULT = 'match-result',
43
- RED_CARD_IS_GIVEN = "red-card-is-given",
44
- PENALTY_AWARDED = "penalty-awarded",
45
- // BOTH_TEAM_SCORE = 'both-team-score',
46
- // GOAL_IN_BOTH_HALVES = 'goal-in-both-halves',
47
- GOAL_IN_FIRST_15 = "goal-in-first-15",
48
- MOST_TACKLES_WON = "most-tackles-won",
49
- CORNERS_10_OR_MORE = "corners-10-or-more",
50
- }
51
-
52
- // export type MPQuestionKeyType = keyof typeof MPQuestionKeyEnum;
53
-
54
- export enum MatchSideResultEnum {
55
- HOME = "home",
56
- AWAY = "away",
57
- DRAW = "draw",
58
- }
59
- export enum YesNoResultEnum {
60
- YES = "yes",
61
- NO = "no",
62
- }
63
- export type BothSidesPositiveInteger = { home: number; away: number };
64
- export type PositiveInteger = number;
65
-
66
- export enum MPQuestionResultTypeEnum {
67
- BOTH_SIDES_POSITIVE_INTEGER = "both-sides-positive-integer",
68
- POSITIVE_INTEGER = "positive-integer",
69
- MATCH_SIDE_RESULT = "match-side-result",
70
- YES_NO = "yes-no",
71
- }
72
-
73
- export type MPQuestionResultTypeType = keyof typeof MPQuestionResultTypeEnum;
74
-
75
- export type MPQuestion = {
76
- key: MPQuestionKeyEnum;
77
- points: number;
78
- resultValueType: MPQuestionResultTypeEnum;
79
- displayOrder: number;
80
- };
81
-
82
- export type MPQuestionResultTypeValueType = {
83
- [MPQuestionResultTypeEnum.BOTH_SIDES_POSITIVE_INTEGER]: BothSidesPositiveInteger;
84
- [MPQuestionResultTypeEnum.POSITIVE_INTEGER]: PositiveInteger;
85
- [MPQuestionResultTypeEnum.MATCH_SIDE_RESULT]: MatchSideResultEnum;
86
- [MPQuestionResultTypeEnum.YES_NO]: YesNoResultEnum;
87
- };
@@ -1 +0,0 @@
1
- export * from "./b2b-bets.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-events.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-events.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-match.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-match.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-pools.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-question-sets.model";
@@ -1 +0,0 @@
1
- export * from "./b2b-question-sets.model";
@@ -1,2 +0,0 @@
1
- export * from "./match-predictor";
2
- export * from "./match-predictor-question";
@@ -1,56 +0,0 @@
1
- import { Doc, ISODate, UUID } from "../common";
2
- import { MatchTime } from "../matches";
3
- import { MPQuestion } from "./match-predictor-question";
4
-
5
- export type MPEventDoc = MPEvent & Doc;
6
-
7
- export interface MPEvent {
8
- id: UUID;
9
- status: MPEventStatusType;
10
- startDate: string; // ISO DATE STRING
11
- matchData: MPMatchData;
12
- questions: MPQuestion[];
13
- pools: { [key: string]: MPEventPool };
14
- createdAt: ISODate;
15
- updatedAt: ISODate;
16
- }
17
-
18
- export type MPEventMatchStatusType =
19
- | "pre-event"
20
- | "live"
21
- | "finished"
22
- | "cancelled";
23
-
24
- export type MPMatchData = {
25
- matchId: UUID;
26
- status: MPEventMatchStatusType;
27
- startDate: ISODate;
28
- homeTeamName: string;
29
- homeTeamId: UUID | null;
30
- awayTeamName: string;
31
- awayTeamId: UUID | null;
32
- score: { home: number; away: number };
33
- isActive: boolean;
34
- isPostponed?: boolean;
35
- matchTime: MatchTime;
36
- };
37
-
38
- export type MPEventStatusType =
39
- | "pending"
40
- | "open"
41
- | "event-in-progress"
42
- | "waiting-for-results-approval"
43
- | "results-approved"
44
- | "finished"
45
- | "cancelled";
46
-
47
- export type MPEventPool = {
48
- id: UUID;
49
- potAmount: number; // gross pool entries sum aka prize pool
50
- participants: number; // active bets count
51
- entryFee: number;
52
- leaderboardId: UUID;
53
- payoutStructure: MPPoolPayoutStructure;
54
- };
55
-
56
- export type MPPoolPayoutStructure = { [position: string]: number };