@winible/winible-typed 2.70.5 → 2.71.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 (56) hide show
  1. package/dist/scripts/testModels.js +55 -45
  2. package/dist/scripts/testModels.js.map +1 -1
  3. package/dist/src/types.js +24 -1
  4. package/dist/src/types.js.map +1 -1
  5. package/dist/typed-model/affiliate-link.js +79 -0
  6. package/dist/typed-model/affiliate-link.js.map +1 -0
  7. package/dist/typed-model/bet-sport.js +42 -0
  8. package/dist/typed-model/bet-sport.js.map +1 -0
  9. package/dist/typed-model/bet.js +8 -66
  10. package/dist/typed-model/bet.js.map +1 -1
  11. package/dist/typed-model/{recurly-payment-monitoring-whitelist.js → featured-capper.js} +22 -16
  12. package/dist/typed-model/featured-capper.js.map +1 -0
  13. package/dist/typed-model/index.js +24 -6
  14. package/dist/typed-model/index.js.map +1 -1
  15. package/dist/typed-model/league.js +38 -5
  16. package/dist/typed-model/league.js.map +1 -1
  17. package/dist/typed-model/market-on-bet-sport.js +58 -0
  18. package/dist/typed-model/market-on-bet-sport.js.map +1 -0
  19. package/dist/typed-model/market.js +37 -0
  20. package/dist/typed-model/market.js.map +1 -0
  21. package/dist/typed-model/odd.js +129 -0
  22. package/dist/typed-model/odd.js.map +1 -0
  23. package/dist/typed-model/odds-on-bets.js +53 -0
  24. package/dist/typed-model/odds-on-bets.js.map +1 -0
  25. package/dist/typed-model/odds-on-parlays.js +53 -0
  26. package/dist/typed-model/odds-on-parlays.js.map +1 -0
  27. package/dist/typed-model/parlay.js +55 -0
  28. package/dist/typed-model/parlay.js.map +1 -0
  29. package/dist/typed-model/parlays-on-bets.js +53 -0
  30. package/dist/typed-model/parlays-on-bets.js.map +1 -0
  31. package/dist/typed-model/sportsbook.js +56 -0
  32. package/dist/typed-model/sportsbook.js.map +1 -0
  33. package/dist/utils/lambdaUtils/logger.js +90 -0
  34. package/dist/utils/lambdaUtils/logger.js.map +1 -0
  35. package/package.json +1 -1
  36. package/src/types.ts +46 -0
  37. package/typed-model/affiliate-link.ts +104 -0
  38. package/typed-model/bet-sport.ts +61 -0
  39. package/typed-model/bet.ts +10 -89
  40. package/typed-model/index.ts +11 -2
  41. package/typed-model/league.ts +46 -7
  42. package/typed-model/market-on-bet-sport.ts +76 -0
  43. package/typed-model/market.ts +55 -0
  44. package/typed-model/odd.ts +158 -0
  45. package/typed-model/odds-on-bets.ts +68 -0
  46. package/typed-model/odds-on-parlays.ts +68 -0
  47. package/typed-model/parlay.ts +74 -0
  48. package/typed-model/parlays-on-bets.ts +69 -0
  49. package/typed-model/sportsbook.ts +78 -0
  50. package/dist/event-collector-models/config/config.js +0 -30
  51. package/dist/event-collector-models/config/config.js.map +0 -1
  52. package/dist/migrations/20241123184623-recurly-payment-monitoring-whitelist.js +0 -33
  53. package/dist/migrations/20241123184623-recurly-payment-monitoring-whitelist.js.map +0 -1
  54. package/dist/typed-model/recurly-payment-monitoring-whitelist.js.map +0 -1
  55. package/event-collector-models/config/config.ts +0 -29
  56. package/typed-model/league-on-users.ts +0 -81
package/src/types.ts CHANGED
@@ -164,3 +164,49 @@ export interface TemplatePrompt {
164
164
  export interface ComplianceStatus {
165
165
  [key: string]: any;
166
166
  }
167
+
168
+ export enum StatusType {
169
+ ACTIVE = "active",
170
+ INACTIVE = "inactive",
171
+ }
172
+
173
+ export enum BetType {
174
+ STRAIGHT = "straight",
175
+ PARLAY = "parlay",
176
+ }
177
+
178
+ export enum BetStatusType {
179
+ WON = "won",
180
+ LOST = "lost",
181
+ OPEN = "open",
182
+ VOID = "void",
183
+ }
184
+
185
+ export enum AffiliateLinkLinkTypes {
186
+ WINIBLE = "winible",
187
+ CREATOR = "creator",
188
+ WINIBLE_CREATOR = "winible_creator",
189
+ }
190
+
191
+ export type OddDeepLinkType = {
192
+ ios?: string;
193
+ android?: string;
194
+ desktop?: string;
195
+ };
196
+
197
+ export type OddAssetsType = {
198
+ home_competitor?: {
199
+ name: string;
200
+ abbreviation: string;
201
+ logo: string;
202
+ };
203
+ away_competitor?: {
204
+ name: string;
205
+ abbreviation: string;
206
+ logo: string;
207
+ };
208
+ player?: {
209
+ name: string;
210
+ logo: string;
211
+ };
212
+ };
@@ -0,0 +1,104 @@
1
+ import {
2
+ Model,
3
+ InferAttributes,
4
+ InferCreationAttributes,
5
+ CreationOptional,
6
+ DataTypes,
7
+ fn,
8
+ } from "sequelize";
9
+
10
+ import sequelize from "./pb-sequelize";
11
+ import { AffiliateLinkLinkTypes, StatusType } from "../src/types";
12
+ import User from "./user";
13
+ import Sportsbook from "./sportsbook";
14
+
15
+ // order of InferAttributes & InferCreationAttributes is important.
16
+ class AffiliateLinks extends Model<
17
+ InferAttributes<AffiliateLinks>,
18
+ InferCreationAttributes<AffiliateLinks>
19
+ > {
20
+ // 'CreationOptional' is a special type that marks the field as optional
21
+ // when creating an instance of the model (such as using Model.create()).
22
+ declare id: CreationOptional<string>;
23
+ declare creatorId: string;
24
+ declare sportsbookId: string;
25
+ declare type: AffiliateLinkLinkTypes;
26
+ declare cta: string;
27
+ declare affiliateCode: string;
28
+ declare affiliateLink: string;
29
+ declare createdAt: CreationOptional<Date>;
30
+ declare updatedAt: CreationOptional<Date>;
31
+ }
32
+
33
+ AffiliateLinks.init(
34
+ {
35
+ id: {
36
+ type: DataTypes.BIGINT,
37
+ primaryKey: true,
38
+ allowNull: false,
39
+ defaultValue: sequelize.fn("next_id"),
40
+ },
41
+ creatorId: {
42
+ type: DataTypes.BIGINT,
43
+ allowNull: false,
44
+ references: {
45
+ model: User,
46
+ key: "id",
47
+ },
48
+ field: "creator_id",
49
+ },
50
+ sportsbookId: {
51
+ type: DataTypes.BIGINT,
52
+ allowNull: false,
53
+ references: {
54
+ model: Sportsbook,
55
+ key: "id",
56
+ },
57
+ field: "sportsbook_id",
58
+ },
59
+ type: {
60
+ type: DataTypes.ENUM(...Object.values(AffiliateLinkLinkTypes)),
61
+ allowNull: false,
62
+ },
63
+ cta: {
64
+ type: DataTypes.STRING,
65
+ allowNull: false,
66
+ },
67
+ affiliateCode: {
68
+ type: DataTypes.STRING,
69
+ allowNull: false,
70
+ field: "affiliate_code",
71
+ },
72
+ affiliateLink: {
73
+ type: DataTypes.STRING,
74
+ allowNull: false,
75
+ field: "affiliate_link",
76
+ },
77
+ createdAt: DataTypes.DATE,
78
+ updatedAt: DataTypes.DATE,
79
+ },
80
+ {
81
+ // Other model options go here
82
+ tableName: "affiliate_links",
83
+ comment: "Affiliate Links table, belongs to a user (creator_id)",
84
+ sequelize,
85
+ }
86
+ );
87
+
88
+ User.hasMany(AffiliateLinks, {
89
+ foreignKey: "creatorId",
90
+ sourceKey: "id",
91
+ onDelete: "NO ACTION",
92
+ constraints: false,
93
+ });
94
+
95
+ AffiliateLinks.belongsTo(User, { foreignKey: "creatorId" });
96
+
97
+ Sportsbook.hasMany(AffiliateLinks, {
98
+ foreignKey: "sportsbookId",
99
+ sourceKey: "id",
100
+ onDelete: "NO ACTION",
101
+ constraints: false,
102
+ });
103
+
104
+ export default AffiliateLinks;
@@ -0,0 +1,61 @@
1
+ import {
2
+ Model,
3
+ InferAttributes,
4
+ InferCreationAttributes,
5
+ CreationOptional,
6
+ DataTypes,
7
+ fn,
8
+ } from "sequelize";
9
+
10
+ import sequelize from "./pb-sequelize";
11
+ import { StatusType } from "../src/types";
12
+
13
+ // order of InferAttributes & InferCreationAttributes is important.
14
+ class BetSport extends Model<
15
+ InferAttributes<BetSport>,
16
+ InferCreationAttributes<BetSport>
17
+ > {
18
+ // 'CreationOptional' is a special type that marks the field as optional
19
+ // when creating an instance of the model (such as using Model.create()).
20
+ declare id: CreationOptional<string>;
21
+ declare name: string;
22
+ declare status: StatusType;
23
+ declare numericalId: number;
24
+ declare createdAt: CreationOptional<Date>;
25
+ declare updatedAt: CreationOptional<Date>;
26
+ }
27
+
28
+ BetSport.init(
29
+ {
30
+ id: {
31
+ type: DataTypes.BIGINT,
32
+ primaryKey: true,
33
+ allowNull: false,
34
+ defaultValue: sequelize.fn("next_id"),
35
+ },
36
+ name: {
37
+ type: DataTypes.STRING,
38
+ allowNull: false,
39
+ },
40
+ status: {
41
+ type: DataTypes.ENUM(...Object.values(StatusType)),
42
+ allowNull: false,
43
+ },
44
+ numericalId: {
45
+ type: DataTypes.INTEGER,
46
+ allowNull: false,
47
+ comment: "Numerical ID provided by Odds Jam",
48
+ field: "numerical_id",
49
+ },
50
+ createdAt: DataTypes.DATE,
51
+ updatedAt: DataTypes.DATE,
52
+ },
53
+ {
54
+ // Other model options go here
55
+ tableName: "bet_sports",
56
+ comment: "Bet sports synched from Odds Jam",
57
+ sequelize,
58
+ }
59
+ );
60
+
61
+ export default BetSport;
@@ -7,37 +7,15 @@ import {
7
7
  } from "sequelize";
8
8
 
9
9
  import sequelize from "./pb-sequelize";
10
- import User from "./user";
11
10
  import Post from "./post";
12
-
13
- type BetType = "same-game parlay" | "parlay" | "single";
14
- type ResultType = "pending" | "won" | "lost" | "push";
11
+ import { BetStatusType, BetType } from "../src/types";
15
12
 
16
13
  // order of InferAttributes & InferCreationAttributes is important.
17
14
  class Bet extends Model<InferAttributes<Bet>, InferCreationAttributes<Bet>> {
18
15
  declare id: CreationOptional<string>;
19
- declare userId: string;
20
16
  declare postId: string;
17
+ declare status: BetStatusType;
21
18
  declare type: BetType;
22
- declare stakeInCents?: number;
23
- declare returnInCents?: number;
24
- declare stakeInUnits?: number;
25
- declare returnInUnits?: number;
26
- declare settled: boolean;
27
- declare result?: ResultType;
28
- declare events?: {
29
- sport: string;
30
- homeTeam: string;
31
- awayTeam?: string;
32
- league?: string;
33
- odds: {
34
- value: number | null;
35
- market: string;
36
- title: string;
37
- }[];
38
- }[];
39
- declare metadata?: any;
40
-
41
19
  declare createdAt: CreationOptional<Date>;
42
20
  declare updatedAt: CreationOptional<Date>;
43
21
  }
@@ -50,14 +28,6 @@ Bet.init(
50
28
  allowNull: false,
51
29
  defaultValue: sequelize.fn("next_id"),
52
30
  },
53
- userId: {
54
- type: DataTypes.BIGINT,
55
- allowNull: false,
56
- field: "user_id",
57
- references: {
58
- model: User,
59
- },
60
- },
61
31
  postId: {
62
32
  type: DataTypes.BIGINT,
63
33
  allowNull: false,
@@ -66,70 +36,21 @@ Bet.init(
66
36
  model: Post,
67
37
  },
68
38
  },
69
- type: {
70
- type: DataTypes.STRING,
71
- allowNull: false,
72
- field: "type",
73
- },
74
- stakeInCents: {
75
- type: DataTypes.INTEGER,
76
- allowNull: true,
77
- field: "stake_in_cents",
78
- comment: "The amount of stake in cents (e.g., 5000 for $50)",
79
- },
80
- returnInCents: {
81
- type: DataTypes.INTEGER,
82
- allowNull: true,
83
- field: "return_in_cents",
84
- comment: "The potential return amount in cents",
85
- },
86
- stakeInUnits: {
87
- type: DataTypes.FLOAT,
88
- allowNull: true,
89
- field: "stake_in_units",
90
- comment: "The amount of stake in units (e.g., 1.0 for 1 unit)",
91
- },
92
- returnInUnits: {
93
- type: DataTypes.FLOAT,
94
- allowNull: true,
95
- field: "return_in_units",
96
- comment: "The potential return amount in units",
97
- },
98
- settled: {
99
- type: DataTypes.BOOLEAN,
100
- allowNull: false,
101
- defaultValue: false,
102
- field: "settled",
103
- },
104
- result: {
105
- type: DataTypes.STRING,
106
- allowNull: true,
107
- field: "result",
108
- comment: "Result of the bet: pending, won, lost, push",
109
- },
110
- events: {
111
- type: DataTypes.JSONB,
112
- allowNull: true,
113
- field: "events",
114
- },
115
- metadata: {
116
- type: DataTypes.JSONB,
117
- allowNull: true,
118
- field: "metadata",
119
- },
120
- createdAt: {
121
- type: DataTypes.DATE,
39
+ status: {
40
+ type: DataTypes.ENUM(...Object.values(BetStatusType)),
122
41
  allowNull: false,
123
- field: "created_at",
124
42
  },
125
- updatedAt: {
126
- type: DataTypes.DATE,
43
+ type: {
44
+ type: DataTypes.ENUM(...Object.values(BetType)),
127
45
  allowNull: false,
128
- field: "updated_at",
129
46
  },
47
+ createdAt: DataTypes.DATE,
48
+ updatedAt: DataTypes.DATE,
130
49
  },
131
50
  {
132
51
  tableName: "bets",
52
+ comment:
53
+ "Bets table, relates a post to a bet and it's available odds or parlays",
133
54
  sequelize,
134
55
  }
135
56
  );
@@ -14,8 +14,6 @@ export { default as SubscriptionPricingOption } from "./subscription-pricing-opt
14
14
  export { default as FreeSubscriptionPlan } from "./free-subscription-plan";
15
15
  export { default as RecurlyAccount } from "./recurly-account";
16
16
  export { default as Withdrawal } from "./withdrawal";
17
- export { default as League } from "./league";
18
- export { default as LeagueOnUsers } from "./league-on-users";
19
17
  export { default as User } from "./user";
20
18
  export { default as SubscriptionPricingOptionOnCoupons } from "./subscription-pricing-option-on-coupons";
21
19
  export { default as SubscribersOnCreators } from "./subscribers-on-creators";
@@ -69,5 +67,16 @@ export { default as PhoneNumberAssignment } from "./phone-number-assignment";
69
67
  export { default as SendgridEmailSubAccount } from "./sendgrid-email-sub-account";
70
68
  export { default as SendgridIpPool } from "./sendgrid-ip-pool";
71
69
  export { default as SendgridDomain } from "./sendgrid-domain";
70
+ export { default as BetSport } from "./bet-sport";
71
+ export { default as Market } from "./market";
72
+ export { default as League } from "./league";
73
+ export { default as MarketOnBetSport } from "./market-on-bet-sport";
74
+ export { default as AffiliateLink } from "./affiliate-link";
75
+ export { default as Sportsbook } from "./sportsbook";
76
+ export { default as Odd } from "./odd";
77
+ export { default as Parlay } from "./parlay";
78
+ export { default as OddsOnBets } from "./odds-on-bets";
79
+ export { default as OddsOnParlays } from "./odds-on-parlays";
80
+ export { default as ParlaysOnBets } from "./parlays-on-bets";
72
81
 
73
82
  export { default as pbSequelize } from "./pb-sequelize";
@@ -8,6 +8,8 @@ import {
8
8
  } from "sequelize";
9
9
 
10
10
  import sequelize from "./pb-sequelize";
11
+ import { StatusType } from "../src/types";
12
+ import BetSport from "./bet-sport";
11
13
 
12
14
  // order of InferAttributes & InferCreationAttributes is important.
13
15
  class League extends Model<
@@ -17,8 +19,12 @@ class League extends Model<
17
19
  // 'CreationOptional' is a special type that marks the field as optional
18
20
  // when creating an instance of the model (such as using Model.create()).
19
21
  declare id: CreationOptional<string>;
20
- declare sport: string;
21
- declare leagueName: string;
22
+ declare name: string;
23
+ declare status: StatusType;
24
+ declare numericalId: number;
25
+ declare region: string;
26
+ declare regionCode: string;
27
+ declare betSportsId: string;
22
28
  declare createdAt: CreationOptional<Date>;
23
29
  declare updatedAt: CreationOptional<Date>;
24
30
  }
@@ -31,14 +37,37 @@ League.init(
31
37
  allowNull: false,
32
38
  defaultValue: sequelize.fn("next_id"),
33
39
  },
34
- sport: {
40
+ name: {
35
41
  type: DataTypes.STRING,
36
- field: "sport",
42
+ allowNull: false,
43
+ },
44
+ status: {
45
+ type: DataTypes.ENUM(...Object.values(StatusType)),
46
+ allowNull: false,
47
+ },
48
+ numericalId: {
49
+ type: DataTypes.INTEGER,
50
+ allowNull: false,
51
+ comment: "Numerical ID provided by Odds Jam",
52
+ field: "numerical_id",
53
+ },
54
+ region: {
55
+ type: DataTypes.STRING,
56
+ allowNull: false,
37
57
  },
38
- leagueName: {
58
+ regionCode: {
39
59
  type: DataTypes.STRING,
40
- field: "league_name",
41
- unique: true,
60
+ allowNull: false,
61
+ field: "region_code",
62
+ },
63
+ betSportsId: {
64
+ type: DataTypes.BIGINT,
65
+ allowNull: false,
66
+ references: {
67
+ model: BetSport,
68
+ key: "id",
69
+ },
70
+ field: "bet_sports_id",
42
71
  },
43
72
  createdAt: DataTypes.DATE,
44
73
  updatedAt: DataTypes.DATE,
@@ -46,8 +75,18 @@ League.init(
46
75
  {
47
76
  // Other model options go here
48
77
  tableName: "leagues",
78
+ comment: "Leagues synched from Odds Jam",
49
79
  sequelize,
50
80
  }
51
81
  );
52
82
 
83
+ BetSport.hasMany(League, {
84
+ foreignKey: "betSportsId",
85
+ sourceKey: "id",
86
+ onDelete: "NO ACTION",
87
+ constraints: false,
88
+ });
89
+
90
+ League.belongsTo(BetSport, { foreignKey: "betSportsId" });
91
+
53
92
  export default League;
@@ -0,0 +1,76 @@
1
+ import {
2
+ Model,
3
+ InferAttributes,
4
+ InferCreationAttributes,
5
+ CreationOptional,
6
+ DataTypes,
7
+ fn,
8
+ } from "sequelize";
9
+
10
+ import sequelize from "./pb-sequelize";
11
+ import { StatusType } from "../src/types";
12
+ import BetSport from "./bet-sport";
13
+ import Market from "./market";
14
+
15
+ // order of InferAttributes & InferCreationAttributes is important.
16
+ class MarketOnBetSport extends Model<
17
+ InferAttributes<MarketOnBetSport>,
18
+ InferCreationAttributes<MarketOnBetSport>
19
+ > {
20
+ // 'CreationOptional' is a special type that marks the field as optional
21
+ // when creating an instance of the model (such as using Model.create()).
22
+ declare betSportId: string;
23
+ declare marketId: string;
24
+ declare status: StatusType;
25
+ }
26
+
27
+ MarketOnBetSport.init(
28
+ {
29
+ betSportId: {
30
+ type: DataTypes.BIGINT,
31
+ allowNull: false,
32
+ references: {
33
+ model: BetSport,
34
+ key: "id",
35
+ },
36
+ field: "bet_sport_id",
37
+ },
38
+ marketId: {
39
+ type: DataTypes.BIGINT,
40
+ allowNull: false,
41
+ references: {
42
+ model: Market,
43
+ key: "id",
44
+ },
45
+ field: "market_id",
46
+ },
47
+ status: {
48
+ type: DataTypes.ENUM(...Object.values(StatusType)),
49
+ allowNull: false,
50
+ },
51
+ },
52
+ {
53
+ tableName: "markets_on_bet_sports",
54
+ comment: "Junction table that relates a bet_sport to a market",
55
+ timestamps: false,
56
+ sequelize,
57
+ }
58
+ );
59
+
60
+ BetSport.belongsToMany(Market, {
61
+ through: MarketOnBetSport,
62
+ foreignKey: "betSportId",
63
+ sourceKey: "id",
64
+ onDelete: "NO ACTION",
65
+ constraints: false,
66
+ });
67
+
68
+ Market.belongsToMany(BetSport, {
69
+ through: MarketOnBetSport,
70
+ foreignKey: "marketId",
71
+ sourceKey: "id",
72
+ onDelete: "NO ACTION",
73
+ constraints: false,
74
+ });
75
+
76
+ export default MarketOnBetSport;
@@ -0,0 +1,55 @@
1
+ import {
2
+ Model,
3
+ InferAttributes,
4
+ InferCreationAttributes,
5
+ CreationOptional,
6
+ DataTypes,
7
+ fn,
8
+ } from "sequelize";
9
+
10
+ import sequelize from "./pb-sequelize";
11
+
12
+ // order of InferAttributes & InferCreationAttributes is important.
13
+ class Market extends Model<
14
+ InferAttributes<Market>,
15
+ InferCreationAttributes<Market>
16
+ > {
17
+ // 'CreationOptional' is a special type that marks the field as optional
18
+ // when creating an instance of the model (such as using Model.create()).
19
+ declare id: CreationOptional<string>;
20
+ declare name: string;
21
+ declare numericalId: number;
22
+ declare createdAt: CreationOptional<Date>;
23
+ declare updatedAt: CreationOptional<Date>;
24
+ }
25
+
26
+ Market.init(
27
+ {
28
+ id: {
29
+ type: DataTypes.BIGINT,
30
+ primaryKey: true,
31
+ allowNull: false,
32
+ defaultValue: sequelize.fn("next_id"),
33
+ },
34
+ name: {
35
+ type: DataTypes.STRING,
36
+ allowNull: false,
37
+ },
38
+ numericalId: {
39
+ type: DataTypes.INTEGER,
40
+ allowNull: false,
41
+ comment: "Numerical ID provided by Odds Jam",
42
+ field: "numerical_id",
43
+ },
44
+ createdAt: DataTypes.DATE,
45
+ updatedAt: DataTypes.DATE,
46
+ },
47
+ {
48
+ // Other model options go here
49
+ tableName: "markets",
50
+ comment: "Markets synched from Odds Jam",
51
+ sequelize,
52
+ }
53
+ );
54
+
55
+ export default Market;