@sportsbroker/firebase-structure 2.4.2 → 3.0.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.
@@ -3,6 +3,7 @@ import { Teams } from "./teams/_index";
3
3
  import { Matches } from "./matches/_index";
4
4
  import { Tables } from "./tables/_index";
5
5
  import { Ranking } from "./ranking/_index";
6
+ import { Seasons } from "./seasons/_index";
6
7
 
7
8
  export interface Details {
8
9
  users: Users;
@@ -10,4 +11,5 @@ export interface Details {
10
11
  matches: Matches;
11
12
  tables: Tables;
12
13
  ranking: Ranking;
14
+ seasons: Seasons;
13
15
  }
@@ -1,21 +1,23 @@
1
1
  import { MatchPeriod } from "../../global";
2
2
 
3
+ export interface Commentary {
4
+ period: MatchPeriod;
5
+ headline: string;
6
+ text: string;
7
+ time: {
8
+ minutes: number;
9
+ seconds: number;
10
+ additionalMinutes: number;
11
+ };
12
+ }
13
+
3
14
  /**
4
15
  * Not implemented yet
5
16
  */
6
17
  export interface Commentaries {
7
18
  [sportID: string]: {
8
19
  [matchID: string]: {
9
- [commentaryID: string]: {
10
- period: MatchPeriod;
11
- headline: string;
12
- text: string;
13
- time: {
14
- minutes: number;
15
- seconds: number;
16
- additionalMinutes: number;
17
- };
18
- };
20
+ [commentaryID: string]: Commentary;
19
21
  };
20
22
  };
21
23
  }
@@ -1,4 +1,4 @@
1
- import { Date, MatchPeriod, MatchStatus } from "../../global";
1
+ import { ISODate, MatchPeriod, MatchStatus } from "../../global";
2
2
 
3
3
  export interface MatchTime {
4
4
  minutes: number;
@@ -12,14 +12,16 @@ export interface EventStatus {
12
12
  matchTime?: MatchTime;
13
13
  }
14
14
 
15
+ export interface MatchOverview {
16
+ startDate: ISODate;
17
+ roundNb: number;
18
+ originalRoundNb: number;
19
+ isTba: boolean;
20
+ eventStatus: EventStatus;
21
+ }
22
+
15
23
  export interface Overviews {
16
24
  [sportId: string]: {
17
- [matchId: string]: {
18
- startDate: Date;
19
- roundNb: number;
20
- originalRoundNb: number;
21
- isTba: boolean;
22
- eventStatus: EventStatus;
23
- };
25
+ [matchId: string]: MatchOverview;
24
26
  };
25
27
  }
@@ -3,18 +3,22 @@ export interface Score {
3
3
  away: number;
4
4
  }
5
5
 
6
+ export interface MatchPeriods{
7
+ firstHalf: Score;
8
+ secondHalf?: Score;
9
+ firstOvertime?: Score;
10
+ secondOvertime?: Score;
11
+ }
12
+
13
+ export interface MatchScore {
14
+ home: number;
15
+ away: number;
16
+ periods: MatchPeriods;
17
+ shootoutPenalties?: Score;
18
+ }
19
+
6
20
  export interface Scores {
7
21
  [sportID: string]: {
8
- [matchID: string]: {
9
- home: number;
10
- away: number;
11
- periods: {
12
- firstHalf: Score;
13
- secondHalf?: Score;
14
- firstOvertime?: Score;
15
- secondOvertime?: Score;
16
- };
17
- shootoutPenalties?: Score;
18
- };
22
+ [matchID: string]: MatchScore;
19
23
  };
20
24
  }
@@ -1,14 +1,16 @@
1
- export interface MatchShares {
1
+ export interface MatchTeamShares {
2
2
  price: number;
3
3
  openingPrice: number;
4
4
  priceChangePercentage: number;
5
5
  }
6
6
 
7
+ export interface MatchShares {
8
+ home: MatchTeamShares;
9
+ away: MatchTeamShares;
10
+ }
11
+
7
12
  export interface Shares {
8
13
  [sportID: string]: {
9
- [matchID: string]: {
10
- home: MatchShares;
11
- away: MatchShares;
12
- };
14
+ [matchID: string]: MatchShares;
13
15
  };
14
16
  }
@@ -1,14 +1,16 @@
1
1
  export type VenueID = string;
2
2
 
3
+ export interface VenueOverview {
4
+ id: VenueID;
5
+ name: string;
6
+ city: string;
7
+ }
8
+
3
9
  /**
4
10
  * Not implemented yet
5
11
  */
6
12
  export interface VenueOverviews {
7
13
  [sportID: string]: {
8
- [matchID: string]: {
9
- id: VenueID;
10
- name: string;
11
- city: string;
12
- };
14
+ [matchID: string]: VenueOverview;
13
15
  };
14
16
  }
@@ -0,0 +1,7 @@
1
+ import { Overviews } from "./overviews";
2
+ import { TeamsInSeasons } from "./teams";
3
+
4
+ export interface Seasons {
5
+ overviews: Overviews;
6
+ teams: TeamsInSeasons;
7
+ }
@@ -0,0 +1,20 @@
1
+ import { ISODate, Image, SeasonID } from "../../global";
2
+
3
+ export interface SeasonOverview {
4
+ endDate: ISODate;
5
+ id: SeasonID; // "EPL2018" or similar used as reference
6
+ name: string; // examples: "English Premier League", "Major League Soccer", "Germany Bundesliga"
7
+ startDate: ISODate;
8
+ isActive: boolean; // indicate if season is currently active, or archival one
9
+ logo?: Image;
10
+ }
11
+
12
+ /**
13
+ * sportId: SportID
14
+ * seasonId: SeasonID
15
+ */
16
+ export interface Overviews {
17
+ [sportId: string]: {
18
+ [seasonId: string]: SeasonOverview;
19
+ };
20
+ }
@@ -0,0 +1,14 @@
1
+ import { TeamID, SportID, SeasonID } from "../../global";
2
+
3
+ /**
4
+ * sportId: SportID
5
+ * seasonId: SeasonID
6
+ * teamId: TeamID
7
+ */
8
+ export interface TeamsInSeasons {
9
+ [sportId: string]: {
10
+ [seasonId: string]: {
11
+ [teamId: string]: boolean;
12
+ };
13
+ };
14
+ }
@@ -1,14 +1,11 @@
1
- import { Image, TeamID } from "../../global";
1
+ import {Image, TeamID, WithSeasons} from "../../global";
2
2
 
3
- export interface TeamOverview {
3
+ export interface TeamOverview extends WithSeasons {
4
4
  name: string;
5
5
  abbreviation: string;
6
6
  id: TeamID;
7
7
  logo?: Image;
8
8
  isCurrentlyPlaying: boolean;
9
- seasons: {
10
- [seasonId: string]: boolean; // Firebase will treat it as an array. Available: "BUND2018" | "EPL2018"
11
- };
12
9
  }
13
10
 
14
11
  /**
@@ -1,4 +1,4 @@
1
- import { UserID, Language } from "../../global";
1
+ import {UserID, Language, ISODate} from "../../global";
2
2
 
3
3
  export type NotificationID = string;
4
4
 
@@ -8,6 +8,16 @@ export type NotificationType =
8
8
  | "TEAM_ELIMINATED"
9
9
  | "KICK_OFF";
10
10
 
11
+ export interface Notification {
12
+ type: NotificationType;
13
+ title: string;
14
+ description?: string;
15
+ shown: boolean;
16
+ createdAt: ISODate;
17
+ updatedAt: ISODate;
18
+ id: NotificationID;
19
+ }
20
+
11
21
  /**
12
22
  * notificationId: NotificationID
13
23
  * language: Language
@@ -18,15 +28,7 @@ export interface Notifications {
18
28
  unreadCount: number;
19
29
  [language: string]: {
20
30
  entries: {
21
- [notificationId: string]: {
22
- type: NotificationType;
23
- title: string;
24
- description?: string;
25
- shown: boolean;
26
- createdAt: Date;
27
- updatedAt: Date;
28
- id: NotificationID;
29
- };
31
+ [notificationId: string]: Notification;
30
32
  };
31
33
  };
32
34
  };
@@ -1,4 +1,4 @@
1
- import { SportID, TeamID } from "../../global";
1
+ import {ISODate, SportID, TeamID} from "../../global";
2
2
 
3
3
  export type OrderActionType = "BUY" | "SELL";
4
4
 
@@ -8,29 +8,31 @@ export type OrderStatus = "ACTIVE" | "COMPLETED" | "ABORTED" | "CANCELLED";
8
8
 
9
9
  type OrderID = string;
10
10
 
11
+ export interface Order {
12
+ action: OrderActionType;
13
+ allOrNothing: boolean;
14
+ amount: number;
15
+ createdAt: ISODate;
16
+ limit?: number;
17
+ processedAmount: number;
18
+ processedMoney: number;
19
+ processedFee: number;
20
+ processedTotalMoney: number; // processedMoney + processedFee
21
+ sportId: SportID;
22
+ teamId: TeamID;
23
+ transactionFee: number;
24
+ type: OrderTransactionType;
25
+ updatedAt: ISODate;
26
+ status: OrderStatus;
27
+ id: OrderID;
28
+ }
29
+
11
30
  /**
12
31
  * userID: UserID
13
32
  * orderID: OrderID
14
33
  */
15
34
  export interface Orders {
16
35
  [userID: string]: {
17
- [orderID: string]: {
18
- action: OrderActionType;
19
- allOrNothing: boolean;
20
- amount: number;
21
- createdAt: Date;
22
- limit?: number;
23
- processedAmount: number;
24
- processedMoney: number;
25
- processedFee: number;
26
- processedTotalMoney: number; // processedMoney + processedFee
27
- sportId: SportID;
28
- teamId: TeamID;
29
- transactionFee: number;
30
- type: OrderTransactionType;
31
- updatedAt: Date;
32
- status: OrderStatus;
33
- id: OrderID;
34
- };
36
+ [orderID: string]: Order;
35
37
  };
36
38
  }
@@ -1,19 +1,21 @@
1
1
  import { SportID } from "../../global";
2
2
 
3
+ export interface UserOwnedShares {
4
+ sportId: SportID;
5
+ amount: number;
6
+ availableAmount: number;
7
+ value: number;
8
+ profit: number;
9
+ invested: number;
10
+ averagePricePerShare: number;
11
+ }
12
+
3
13
  /**
4
14
  * teamID: TeamID
5
15
  * userID: userID
6
16
  */
7
17
  export interface OwnedShares {
8
18
  [userID: string]: {
9
- [teamID: string]: {
10
- sportId: SportID;
11
- amount: number;
12
- availableAmount: number;
13
- value: number;
14
- profit: number;
15
- invested: number;
16
- averagePricePerShare: number;
17
- };
19
+ [teamID: string]: UserOwnedShares;
18
20
  };
19
21
  }
@@ -1,11 +1,13 @@
1
1
  import { UserID } from "../../global";
2
2
 
3
+ export interface UserRanking {
4
+ change: number;
5
+ equity: number;
6
+ position: number;
7
+ username: string;
8
+ }
9
+
3
10
  //Restricted access only to own data
4
11
  export interface Ranking {
5
- [userId: UserID]: {
6
- change: number;
7
- equity: number;
8
- position: number;
9
- username: string;
10
- };
12
+ [userId: UserID]: UserRanking;
11
13
  }
@@ -1,4 +1,4 @@
1
- import { Date, SportID, UserID } from "../../global";
1
+ import { ISODate, SportID, UserID } from "../../global";
2
2
 
3
3
  type TransactionID = string;
4
4
 
@@ -25,23 +25,25 @@ export enum TransactionStatus {
25
25
  IN_REVIEW = "IN_REVIEW",
26
26
  }
27
27
 
28
+ export interface Transation {
29
+ createdAt: ISODate;
30
+ updatedAt: ISODate;
31
+ executedAt?: ISODate;
32
+ id: TransactionID,
33
+ status: TransactionStatus;
34
+ type: TransactionType;
35
+ paymentMethod: TransactionPaymentMethod;
36
+ amount: number;
37
+ fee?: number;
38
+ balance?: number; // an initialize transaction balance would be null, and after finished will be filled
39
+ }
40
+
28
41
  /**
29
42
  * userID: UserID
30
43
  * transactionID: TransactionID
31
44
  */
32
45
  export interface Transactions {
33
46
  [userID: string]: {
34
- [transactionID: string]: {
35
- createdAt: Date;
36
- updatedAt: Date;
37
- executedAt?: Date;
38
- id: TransactionID,
39
- status: TransactionStatus;
40
- type: TransactionType;
41
- paymentMethod: TransactionPaymentMethod;
42
- amount: number;
43
- fee?: number;
44
- balance?: number; // an initialize transaction balance would be null, and after finished will be filled
45
- };
47
+ [transactionID: string]: Transation;
46
48
  };
47
49
  }
@@ -1,13 +1,15 @@
1
1
  import { UserID } from "../../global";
2
2
 
3
+ export interface UserWallet {
4
+ available: number;
5
+ invested: number;
6
+ profit: number;
7
+ equity: number;
8
+ }
9
+
3
10
  /**
4
11
  * userID: UserID
5
12
  */
6
13
  export interface Wallet {
7
- [userId: string]: {
8
- available: number;
9
- invested: number;
10
- profit: number;
11
- equity: number;
12
- };
14
+ [userId: string]: UserWallet;
13
15
  }
@@ -8,9 +8,9 @@ export type UserID = MongoID;
8
8
  export type TeamID = MongoID;
9
9
 
10
10
  /**
11
- * @type ISO Date
11
+ * @type ISO ISODate
12
12
  */
13
- export type Date = string;
13
+ export type ISODate = string;
14
14
 
15
15
  /**
16
16
  * Currently support only soccer
@@ -42,3 +42,9 @@ export type MatchPeriod =
42
42
  * PENDING means that match hasn't started yet
43
43
  */
44
44
  export type MatchStatus = "PENDING" | "STARTED" | "FINISHED";
45
+
46
+ export interface WithSeasons {
47
+ seasons: {
48
+ [seasonsName: string]: boolean; // Firebase will treat it as an array. Available: "BUND2018" | "EPL2018"
49
+ };
50
+ }
@@ -1,9 +1,11 @@
1
1
  import { MatchesQueries } from "./matches";
2
2
  import { SharesQueries } from "./shares";
3
3
  import { OrdersQueries } from "./orders";
4
+ import { ActiveSeasonsQueries } from "./seasons";
4
5
 
5
6
  export interface Queries {
6
7
  matches: MatchesQueries;
7
8
  shares: SharesQueries;
8
9
  orders: OrdersQueries;
10
+ seasons: ActiveSeasonsQueries;
9
11
  }
@@ -1,10 +1,11 @@
1
- import { Date, MatchStatus } from "../global";
1
+ import { ISODate, MatchStatus } from "../global";
2
2
 
3
3
  interface MatchQueryData {
4
- startDate: Date; // "Official", planned time of start
5
- realStartDate: Date; // Real start time, f.e match was delayed
4
+ startDate: ISODate; // "Official", planned time of start
5
+ realStartDate: ISODate; // Real start time, f.e match was delayed
6
6
  roundNb: number;
7
7
  matchStatus: MatchStatus;
8
+ season: string;
8
9
  }
9
10
 
10
11
  interface Matches {
@@ -1,11 +1,11 @@
1
- import { Date } from "../global";
1
+ import { ISODate } from "../global";
2
2
  import { OrderStatus } from "../details/users/orders";
3
3
 
4
4
  interface OrderQueryData {
5
5
  status: OrderStatus;
6
- createdAt: Date;
7
- updatedAt: Date;
8
- executedAt?: Date;
6
+ createdAt: ISODate;
7
+ updatedAt: ISODate;
8
+ executedAt?: ISODate;
9
9
  id: string;
10
10
  }
11
11
 
@@ -0,0 +1,15 @@
1
+ import { SportID, SeasonID } from "../global";
2
+
3
+ /**
4
+ * sportId: SportID
5
+ * seasonId: SeasonID
6
+ */
7
+ export interface ActiveSeasons {
8
+ active: {
9
+ [sportId: string]: {
10
+ [seasonId: string]: true;
11
+ };
12
+ }
13
+ }
14
+
15
+ export { ActiveSeasons as ActiveSeasonsQueries };
@@ -1,3 +1,11 @@
1
+ import { WithSeasons } from "../global";
2
+
3
+ export interface ShareOfTeam extends WithSeasons {
4
+ id: string;
5
+ name: string;
6
+ abbreviation: string;
7
+ }
8
+
1
9
  interface Shares {
2
10
  of: {
3
11
  teams: {
@@ -5,10 +13,7 @@ interface Shares {
5
13
  /**
6
14
  * Sort by name / abbreviation, take team ID to access share
7
15
  */
8
- [teamID: string]: {
9
- name: string;
10
- abbreviation: string;
11
- };
16
+ [teamID: string]: ShareOfTeam;
12
17
  };
13
18
  };
14
19
  };
@@ -1,19 +1,19 @@
1
1
  import { Image, MatchPeriod, MatchStatus, TeamID } from "../global";
2
2
 
3
- interface Team {
3
+ export interface Team {
4
4
  id: TeamID;
5
5
  name: string;
6
6
  abbreviation: string;
7
7
  logo?: Image;
8
8
  }
9
9
 
10
- interface Share {
10
+ export interface Share {
11
11
  price: number;
12
12
  openingPrice: number;
13
13
  priceChangePercentage: number;
14
14
  }
15
15
 
16
- interface EventStatus {
16
+ export interface EventStatus {
17
17
  matchStatus: MatchStatus;
18
18
  period: MatchPeriod;
19
19
  isActive: boolean;
@@ -23,24 +23,27 @@ interface EventStatus {
23
23
  };
24
24
  }
25
25
 
26
+ export interface MatchOverviewSnapshot {
27
+ teams: {
28
+ home: Team;
29
+ away: Team;
30
+ };
31
+ score: {
32
+ home: number;
33
+ away: number;
34
+ };
35
+ share?: {
36
+ home: Share;
37
+ away: Share;
38
+ };
39
+ startDate: Date;
40
+ roundNb: number;
41
+ eventStatus: EventStatus;
42
+ season: string;
43
+ }
44
+
26
45
  export interface MatchOverviews {
27
46
  [sportID: string]: {
28
- [matchID: string]: {
29
- teams: {
30
- home: Team;
31
- away: Team;
32
- };
33
- score: {
34
- home: number;
35
- away: number;
36
- };
37
- share?: {
38
- home: Share;
39
- away: Share;
40
- };
41
- startDate: Date;
42
- roundNb: number;
43
- eventStatus: EventStatus;
44
- };
47
+ [matchID: string]: MatchOverviewSnapshot;
45
48
  };
46
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sportsbroker/firebase-structure",
3
- "version": "2.4.2",
3
+ "version": "3.0.0",
4
4
  "description": "Firebase structure typings",
5
5
  "main": "index.d.ts",
6
6
  "repository": {