@winible/winible-typed 1.0.9 → 2.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.
Files changed (236) hide show
  1. package/dist/migrations/20230206061925-stale.js +13 -0
  2. package/dist/migrations/20230206061925-stale.js.map +1 -0
  3. package/dist/migrations/20230313175015-league-user.js +29 -0
  4. package/dist/migrations/20230313175015-league-user.js.map +1 -0
  5. package/dist/migrations/20230330174702-extend-premium-content.js +35 -0
  6. package/dist/migrations/20230330174702-extend-premium-content.js.map +1 -0
  7. package/dist/migrations/20230405141245-deprecate-agencies.js +9 -0
  8. package/dist/migrations/20230405141245-deprecate-agencies.js.map +1 -0
  9. package/dist/migrations/20230405142440-deprecate-unused-tables.js +23 -0
  10. package/dist/migrations/20230405142440-deprecate-unused-tables.js.map +1 -0
  11. package/dist/migrations/20230410144940-deprecate-consent-people.js +9 -0
  12. package/dist/migrations/20230410144940-deprecate-consent-people.js.map +1 -0
  13. package/dist/migrations/20230410174328-deprecate-consent-people-table.js +9 -0
  14. package/dist/migrations/20230410174328-deprecate-consent-people-table.js.map +1 -0
  15. package/dist/migrations/20230410181920-migrate-credit-payments-to-transactions.js +9 -0
  16. package/dist/migrations/20230410181920-migrate-credit-payments-to-transactions.js.map +1 -0
  17. package/dist/migrations/20230410202433-migrate-credit-payments-fields.js +12 -0
  18. package/dist/migrations/20230410202433-migrate-credit-payments-fields.js.map +1 -0
  19. package/dist/migrations/20230410211059-deprecate-credit-purchases.js +9 -0
  20. package/dist/migrations/20230410211059-deprecate-credit-purchases.js.map +1 -0
  21. package/dist/migrations/20230410212035-deprecate-dashboard_user_permissions.js +10 -0
  22. package/dist/migrations/20230410212035-deprecate-dashboard_user_permissions.js.map +1 -0
  23. package/dist/migrations/20230410212324-deprecate-non-breaking-tables.js +34 -0
  24. package/dist/migrations/20230410212324-deprecate-non-breaking-tables.js.map +1 -0
  25. package/dist/migrations/20230411054826-create-users-table.js +141 -0
  26. package/dist/migrations/20230411054826-create-users-table.js.map +1 -0
  27. package/dist/migrations/20230411202848-migrate_transactions_table.js +24 -0
  28. package/dist/migrations/20230411202848-migrate_transactions_table.js.map +1 -0
  29. package/dist/migrations/20230411203543-migrate_league_users.js +9 -0
  30. package/dist/migrations/20230411203543-migrate_league_users.js.map +1 -0
  31. package/dist/migrations/20230411205324-migrate_league.js +13 -0
  32. package/dist/migrations/20230411205324-migrate_league.js.map +1 -0
  33. package/dist/migrations/20230411221159-migrate_media.js +9 -0
  34. package/dist/migrations/20230411221159-migrate_media.js.map +1 -0
  35. package/dist/migrations/20230411221327-migrate_media_asset.js +10 -0
  36. package/dist/migrations/20230411221327-migrate_media_asset.js.map +1 -0
  37. package/dist/migrations/20230411221842-migrate_media_asset_fields.js +10 -0
  38. package/dist/migrations/20230411221842-migrate_media_asset_fields.js.map +1 -0
  39. package/dist/migrations/20230411222018-migrate_notifications.js +25 -0
  40. package/dist/migrations/20230411222018-migrate_notifications.js.map +1 -0
  41. package/dist/scripts/bet-syncing/findGoodBets.js +238 -0
  42. package/dist/scripts/bet-syncing/findGoodBets.js.map +1 -0
  43. package/dist/scripts/bet-syncing/pullOdds.js +21 -8
  44. package/dist/scripts/bet-syncing/pullOdds.js.map +1 -1
  45. package/dist/scripts/bet-syncing/pullPlayerResults.js +47 -21
  46. package/dist/scripts/bet-syncing/pullPlayerResults.js.map +1 -1
  47. package/dist/scripts/bet-syncing/pullPlayers.js +1 -1
  48. package/dist/scripts/bet-syncing/pullPlayers.js.map +1 -1
  49. package/dist/scripts/bet-syncing/updateStaleOdds.js +34 -0
  50. package/dist/scripts/bet-syncing/updateStaleOdds.js.map +1 -0
  51. package/dist/scripts/cleanupRecurlyPlans.js +12 -5
  52. package/dist/scripts/cleanupRecurlyPlans.js.map +1 -1
  53. package/dist/scripts/mapCurrentPaymentsToInvoiceId.js +12 -5
  54. package/dist/scripts/mapCurrentPaymentsToInvoiceId.js.map +1 -1
  55. package/dist/src/index.js +1 -18
  56. package/dist/src/index.js.map +1 -1
  57. package/dist/typed-model/credit-payment.js +133 -82
  58. package/dist/typed-model/credit-payment.js.map +1 -1
  59. package/dist/typed-model/index.js +3 -81
  60. package/dist/typed-model/index.js.map +1 -1
  61. package/dist/typed-model/league-user.js +60 -0
  62. package/dist/typed-model/league-user.js.map +1 -0
  63. package/dist/typed-model/media-asset.js +0 -9
  64. package/dist/typed-model/media-asset.js.map +1 -1
  65. package/dist/typed-model/notification.js +34 -24
  66. package/dist/typed-model/notification.js.map +1 -1
  67. package/dist/typed-model/odds.js +5 -0
  68. package/dist/typed-model/odds.js.map +1 -1
  69. package/dist/typed-model/pb-sequelize.js +18 -4
  70. package/dist/typed-model/pb-sequelize.js.map +1 -1
  71. package/dist/typed-model/subscription-plan-on-premium-content.js +57 -0
  72. package/dist/typed-model/subscription-plan-on-premium-content.js.map +1 -0
  73. package/dist/typed-model/subscription-plan.js +0 -9
  74. package/dist/typed-model/subscription-plan.js.map +1 -1
  75. package/dist/typed-model/subscription.js +0 -14
  76. package/dist/typed-model/subscription.js.map +1 -1
  77. package/dist/typed-model/user.js +194 -0
  78. package/dist/typed-model/user.js.map +1 -0
  79. package/package.json +4 -3
  80. package/src/index.ts +0 -2
  81. package/typed-model/credit-payment.ts +124 -126
  82. package/typed-model/index.ts +1 -51
  83. package/typed-model/{list-member.ts → league-user.ts} +31 -19
  84. package/typed-model/media-asset.ts +0 -10
  85. package/typed-model/notification.ts +39 -44
  86. package/typed-model/pb-sequelize.ts +18 -4
  87. package/typed-model/subscription-plan.ts +0 -10
  88. package/typed-model/subscription.ts +1 -15
  89. package/typed-model/user.ts +248 -0
  90. package/dist/index.d.ts +0 -3
  91. package/dist/migrations/20220601151258-custom_name_describing_your_migration.d.ts +0 -6
  92. package/dist/migrations/20220605225655-create-dashboard-user-permissions.d.ts +0 -6
  93. package/dist/migrations/20220606001300-update-dashboard-user-permissions.d.ts +0 -6
  94. package/dist/migrations/20220607091109-add-read-date-for-message.d.ts +0 -6
  95. package/dist/migrations/20220616225456-add-delete-columns.d.ts +0 -6
  96. package/dist/migrations/20220709202211-disable-feed.d.ts +0 -6
  97. package/dist/migrations/20220723215213-limit-promotion-claims.d.ts +0 -6
  98. package/dist/migrations/20220723220233-num_claims.d.ts +0 -6
  99. package/dist/migrations/20220723221907-default_false_promos.d.ts +0 -6
  100. package/dist/migrations/20220724172559-default_zero_claims.d.ts +0 -6
  101. package/dist/migrations/20220724201419-pinned_post.d.ts +0 -6
  102. package/dist/migrations/20220729164625-unsend_mass.d.ts +0 -6
  103. package/dist/migrations/20220823033002-interval-unit.d.ts +0 -6
  104. package/dist/migrations/20220830193530-processorId.d.ts +0 -6
  105. package/dist/migrations/20220907121932-add-processor-to-sub.d.ts +0 -6
  106. package/dist/migrations/20220907212232-add-trans-id.d.ts +0 -6
  107. package/dist/migrations/20220907220423-big-int-trans.d.ts +0 -6
  108. package/dist/migrations/20220909161902-add-stale.d.ts +0 -6
  109. package/dist/migrations/20220922000225-verified-spender.d.ts +0 -6
  110. package/dist/migrations/20220922212108-verified-spender-2.d.ts +0 -6
  111. package/dist/migrations/20221013223648-product-subscription-list.d.ts +0 -6
  112. package/dist/migrations/20221014001037-product-subscription-list.d.ts +0 -6
  113. package/dist/migrations/20221026055245-update-type.d.ts +0 -6
  114. package/dist/migrations/20221108060019-recurly-sub.d.ts +0 -6
  115. package/dist/migrations/20221110170148-rename-recurly-account.d.ts +0 -6
  116. package/dist/migrations/20221112212510-archive-promo.d.ts +0 -6
  117. package/dist/migrations/20221117044529-sub-status.d.ts +0 -6
  118. package/dist/migrations/20221122051433-default-plan.d.ts +0 -6
  119. package/dist/migrations/20221128034620-invoice-id.d.ts +0 -6
  120. package/dist/scripts/bet-syncing/pullTeams.d.ts +0 -1
  121. package/dist/scripts/cleanupRecurlyPlans.d.ts +0 -1
  122. package/dist/scripts/createDashboardLink.d.ts +0 -1
  123. package/dist/scripts/createRecurlyPlans.d.ts +0 -1
  124. package/dist/scripts/deleteMalformedImages.d.ts +0 -1
  125. package/dist/scripts/fixSaltedPasswords.js +0 -40
  126. package/dist/scripts/fixSaltedPasswords.js.map +0 -1
  127. package/dist/scripts/mapCurrentPaymentsToInvoiceId.d.ts +0 -1
  128. package/dist/scripts/payoutRecurlySubs.d.ts +0 -1
  129. package/dist/scripts/payoutSubscriptions.d.ts +0 -1
  130. package/dist/scripts/removeUnreferenceSubs.d.ts +0 -1
  131. package/dist/scripts/test.d.ts +0 -1
  132. package/dist/slack/index.d.ts +0 -1
  133. package/dist/slack/v1/bypassCreator.d.ts +0 -8
  134. package/dist/slack/v1/cancelSubscription.d.ts +0 -6
  135. package/dist/slack/v1/changeName.d.ts +0 -8
  136. package/dist/slack/v1/checkAuthSub.d.ts +0 -6
  137. package/dist/slack/v1/dashboardLink.d.ts +0 -8
  138. package/dist/slack/v1/index.d.ts +0 -7
  139. package/dist/slack/v1/refund.d.ts +0 -6
  140. package/dist/slack/v1/searchUser.d.ts +0 -6
  141. package/dist/src/index.d.ts +0 -3
  142. package/dist/src/pk-client.d.ts +0 -151
  143. package/dist/src/pk-sub.d.ts +0 -77
  144. package/dist/src/recurlyInstance.d.ts +0 -3
  145. package/dist/src/types.d.ts +0 -30
  146. package/dist/support/index.d.ts +0 -2
  147. package/dist/support/slack-client.d.ts +0 -3
  148. package/dist/support/uploadcare.d.ts +0 -14
  149. package/dist/support/utils.d.ts +0 -2
  150. package/dist/typed-model/asset-category.d.ts +0 -9
  151. package/dist/typed-model/asset-constent-person.d.ts +0 -13
  152. package/dist/typed-model/bet.d.ts +0 -12
  153. package/dist/typed-model/blocked-ip.d.ts +0 -8
  154. package/dist/typed-model/category-tag.d.ts +0 -9
  155. package/dist/typed-model/consent-person.d.ts +0 -13
  156. package/dist/typed-model/content-category-tag.d.ts +0 -9
  157. package/dist/typed-model/content-like.d.ts +0 -10
  158. package/dist/typed-model/credit-payment.d.ts +0 -34
  159. package/dist/typed-model/credit-payout.d.ts +0 -10
  160. package/dist/typed-model/credit-purchase.d.ts +0 -10
  161. package/dist/typed-model/customer-profile.d.ts +0 -17
  162. package/dist/typed-model/dashboard-user-permissions.d.ts +0 -9
  163. package/dist/typed-model/dashboard-user.d.ts +0 -20
  164. package/dist/typed-model/fan-list.d.ts +0 -10
  165. package/dist/typed-model/fraud.d.ts +0 -9
  166. package/dist/typed-model/game.d.ts +0 -56
  167. package/dist/typed-model/index.d.ts +0 -46
  168. package/dist/typed-model/league.d.ts +0 -9
  169. package/dist/typed-model/list-member.d.ts +0 -9
  170. package/dist/typed-model/mass-message.d.ts +0 -11
  171. package/dist/typed-model/media-asset.d.ts +0 -15
  172. package/dist/typed-model/media-category.d.ts +0 -10
  173. package/dist/typed-model/media.d.ts +0 -14
  174. package/dist/typed-model/message-media.d.ts +0 -9
  175. package/dist/typed-model/message.d.ts +0 -27
  176. package/dist/typed-model/notification.d.ts +0 -18
  177. package/dist/typed-model/odds.d.ts +0 -30
  178. package/dist/typed-model/parlay.d.ts +0 -8
  179. package/dist/typed-model/pb-sequelize.d.ts +0 -3
  180. package/dist/typed-model/phone-chat-participation.d.ts +0 -20
  181. package/dist/typed-model/phone-chat.d.ts +0 -16
  182. package/dist/typed-model/phone-owner.d.ts +0 -53
  183. package/dist/typed-model/phone-user.d.ts +0 -21
  184. package/dist/typed-model/player.d.ts +0 -22
  185. package/dist/typed-model/premium-content.d.ts +0 -23
  186. package/dist/typed-model/purchased-content.d.ts +0 -11
  187. package/dist/typed-model/recurly-account.d.ts +0 -9
  188. package/dist/typed-model/short-url.d.ts +0 -12
  189. package/dist/typed-model/subscription-bundle.d.ts +0 -12
  190. package/dist/typed-model/subscription-category-tags.d.ts +0 -9
  191. package/dist/typed-model/subscription-plan.d.ts +0 -27
  192. package/dist/typed-model/subscription-promotion.d.ts +0 -19
  193. package/dist/typed-model/subscription.d.ts +0 -26
  194. package/dist/typed-model/team.d.ts +0 -16
  195. package/dist/typed-model/twilio-phone.d.ts +0 -17
  196. package/dist/typed-model/user-follow.d.ts +0 -13
  197. package/dist/typed-model/verification-code.d.ts +0 -11
  198. package/dist/webhooks/index.d.ts +0 -1
  199. package/dist/webhooks/payment/index.d.ts +0 -1
  200. package/dist/webhooks/payment/refund.d.ts +0 -2
  201. package/src/pk-client.ts +0 -1650
  202. package/src/pk-sub.ts +0 -455
  203. package/typed-model/asset-category.ts +0 -57
  204. package/typed-model/asset-constent-person.ts +0 -82
  205. package/typed-model/bet.ts +0 -84
  206. package/typed-model/blocked-ip.ts +0 -52
  207. package/typed-model/category-tag.ts +0 -66
  208. package/typed-model/consent-person.ts +0 -78
  209. package/typed-model/content-category-tag.ts +0 -79
  210. package/typed-model/credit-purchase.ts +0 -67
  211. package/typed-model/customer-profile.ts +0 -71
  212. package/typed-model/dashboard-user-permissions.ts +0 -51
  213. package/typed-model/dashboard-user.ts +0 -146
  214. package/typed-model/fan-list.ts +0 -68
  215. package/typed-model/fraud.ts +0 -62
  216. package/typed-model/game.ts +0 -311
  217. package/typed-model/market.ts +0 -54
  218. package/typed-model/mass-message.ts +0 -64
  219. package/typed-model/media-category.ts +0 -70
  220. package/typed-model/message-media.ts +0 -74
  221. package/typed-model/message.ts +0 -258
  222. package/typed-model/odds.ts +0 -232
  223. package/typed-model/parlay.ts +0 -47
  224. package/typed-model/phone-chat-participation.ts +0 -166
  225. package/typed-model/phone-chat.ts +0 -185
  226. package/typed-model/player-result.ts +0 -93
  227. package/typed-model/player.ts +0 -118
  228. package/typed-model/short-url.ts +0 -120
  229. package/typed-model/sportsbook.ts +0 -48
  230. package/typed-model/subscription-bundle.ts +0 -80
  231. package/typed-model/subscription-category-tags.ts +0 -79
  232. package/typed-model/subscription-promotion.ts +0 -134
  233. package/typed-model/team.ts +0 -91
  234. package/typed-model/twilio-phone.ts +0 -149
  235. package/typed-model/user-follow.ts +0 -141
  236. package/typed-model/verification-code.ts +0 -74
@@ -1,185 +0,0 @@
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 PhoneChatParticipant from "./phone-chat-participation";
12
- import PhoneOwner from "./phone-owner";
13
- import PhoneUser from "./phone-user";
14
- import TwilioPhone from "./twilio-phone";
15
-
16
- // order of InferAttributes & InferCreationAttributes is important.
17
- class PhoneChat extends Model<
18
- InferAttributes<PhoneChat>,
19
- InferCreationAttributes<PhoneChat>
20
- > {
21
- // 'CreationOptional' is a special type that marks the field as optional
22
- // when creating an instance of the model (such as using Model.create()).
23
- declare id: CreationOptional<string>;
24
- declare twilioPhoneId: string;
25
- declare ownerId: string;
26
- declare status?: string;
27
- declare chatRateInCents?: number;
28
- declare audioRateInCents?: number;
29
- declare createdAt: CreationOptional<Date>;
30
- declare updatedAt: CreationOptional<Date>;
31
- static getParticipationByUserIdAndOwnerId: (
32
- userId: string,
33
- ownerId: string
34
- ) => Promise<PhoneChat>;
35
- static createChatForUserAndOwner: (
36
- user: PhoneUser,
37
- owner: PhoneOwner
38
- ) => Promise<any>;
39
- }
40
-
41
- PhoneChat.init(
42
- {
43
- id: {
44
- type: DataTypes.BIGINT,
45
- primaryKey: true,
46
- allowNull: false,
47
- defaultValue: sequelize.fn("next_id"),
48
- },
49
- twilioPhoneId: {
50
- type: DataTypes.BIGINT,
51
- allowNull: false,
52
- field: "twilio_phone_id",
53
- },
54
- ownerId: {
55
- type: DataTypes.BIGINT,
56
- allowNull: false,
57
- field: "owner_id",
58
- },
59
- chatRateInCents: {
60
- type: DataTypes.INTEGER,
61
- field: "chat_rate_in_cents",
62
- },
63
- audioRateInCents: {
64
- type: DataTypes.INTEGER,
65
- field: "audio_rate_in_cents",
66
- },
67
- status: {
68
- type: DataTypes.STRING,
69
- field: "status",
70
- },
71
- createdAt: DataTypes.DATE,
72
- updatedAt: DataTypes.DATE,
73
- },
74
- {
75
- // Other model options go here
76
- tableName: "chats",
77
- sequelize,
78
- }
79
- );
80
-
81
- /*
82
- ====================================================================
83
- Class functions
84
- ====================================================================
85
- */
86
-
87
- PhoneChat.getParticipationByUserIdAndOwnerId = async (
88
- userId: string,
89
- ownerId: string
90
- ) => {
91
- console.log(userId, ownerId);
92
- let response = await PhoneChat.findAll({
93
- where: {
94
- ownerId,
95
- },
96
- include: [
97
- {
98
- model: PhoneChatParticipant,
99
- required: true,
100
- where: { userId, isActive: true },
101
- },
102
- ],
103
- });
104
- return response && response[0];
105
- };
106
-
107
- PhoneChat.createChatForUserAndOwner = async (
108
- user: PhoneUser,
109
- owner: PhoneOwner
110
- ) => {
111
- let phone;
112
- let chat = await PhoneChat.getParticipationByUserIdAndOwnerId(
113
- user.id,
114
- owner.id
115
- );
116
-
117
- if (chat) {
118
- phone = await TwilioPhone.getById(chat.twilioPhoneId);
119
- } else {
120
- phone = await TwilioPhone.getAvailableChatPhone(user.id, owner.id);
121
- if (!phone) {
122
- throw Error(
123
- "There are no available phone numbers for this host or user."
124
- );
125
- }
126
- chat = await PhoneChat.create({
127
- ownerId: owner.id,
128
- chatRateInCents: owner.defaultChatRateInCents,
129
- audioRateInCents: owner.defaultAudioRateInCents,
130
- twilioPhoneId: phone.id,
131
- });
132
-
133
- let chatParticipation = await PhoneChatParticipant.create({
134
- chatId: chat.id,
135
- userId: user.id,
136
- });
137
-
138
- await TwilioPhone.sendMessageToPhone(
139
- phone,
140
- owner.phone!,
141
- `Woo! ${
142
- user.name || "Someone"
143
- } wants to message you! Start chatting with them 1:1 below! 💬\n\nFans can respond with TIP to send you tips\n\nReply with LOCK to send a locked image or link\n\nWatch this video to learn how to use Paychat SMS: https://www.youtube.com/watch?v=1JLhgFxyhdI`
144
- );
145
- }
146
-
147
- let contactCardUrl;
148
- // try {
149
- // contactCardUrl = await ContactWrapper.createOwnerChatContactCard(chat, owner, phone, host);
150
- // chat.contactCardUrl = contactCardUrl;
151
- // } catch(err) {
152
- // console.log("Failed to attach contact card");
153
- // console.log(err);
154
- // }
155
-
156
- if (owner.chatMessage) {
157
- await TwilioPhone.sendMessageToPhone(
158
- phone!,
159
- user.phone!,
160
- owner.chatMessage,
161
- owner.chatImageUrl!
162
- );
163
- }
164
- await TwilioPhone.sendMessageToPhone(
165
- phone!,
166
- user.phone!,
167
- `Hey, this is ${owner.name}! We can chat over this phone number now. Add this as my contact in your phone! 🙂\n\nReply with TIP if you ever want to send me something extra.`,
168
- undefined
169
- );
170
-
171
- return chat;
172
- };
173
-
174
- PhoneChat.hasMany(PhoneChatParticipant, {
175
- foreignKey: "chat_id",
176
- onDelete: "NO ACTION",
177
- constraints: false,
178
- });
179
- PhoneChatParticipant.belongsTo(PhoneChat, {
180
- foreignKey: "chat_id",
181
- onDelete: "NO ACTION",
182
- constraints: false,
183
- });
184
-
185
- export default PhoneChat;
@@ -1,93 +0,0 @@
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 PlayerResult extends Model<
14
- InferAttributes<PlayerResult>,
15
- InferCreationAttributes<PlayerResult>
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 oddsJamId?: string;
21
- declare oddsJamPlayerId?: string;
22
- declare playerName?: string;
23
- declare stats?: { [key: string]: number };
24
- declare sport?: string;
25
- declare league?: string;
26
- declare oddsJamGameId?: string;
27
- declare leagueId: string;
28
- declare gameId: string;
29
- declare playerId: string;
30
- declare createdAt: CreationOptional<Date>;
31
- declare updatedAt: CreationOptional<Date>;
32
- }
33
-
34
- PlayerResult.init(
35
- {
36
- id: {
37
- type: DataTypes.BIGINT,
38
- primaryKey: true,
39
- allowNull: false,
40
- defaultValue: sequelize.fn("next_id"),
41
- },
42
- oddsJamId: {
43
- type: DataTypes.STRING,
44
- unique: true,
45
- field: "odds_jam_id",
46
- },
47
- oddsJamPlayerId: {
48
- type: DataTypes.STRING,
49
- field: "odds_jam_player_id",
50
- },
51
- playerName: {
52
- type: DataTypes.STRING,
53
- field: "player_name",
54
- },
55
- stats: {
56
- type: DataTypes.JSONB,
57
- field: "stats",
58
- },
59
- sport: {
60
- type: DataTypes.STRING,
61
- field: "sport",
62
- },
63
- league: {
64
- type: DataTypes.STRING,
65
- field: "league",
66
- },
67
- oddsJamGameId: {
68
- type: DataTypes.STRING,
69
- field: "odds_jam_game_id",
70
- },
71
- leagueId: {
72
- type: DataTypes.BIGINT,
73
- field: "league_id",
74
- },
75
- gameId: {
76
- type: DataTypes.BIGINT,
77
- field: "game_id",
78
- },
79
- playerId: {
80
- type: DataTypes.BIGINT,
81
- field: "player_id",
82
- },
83
- createdAt: DataTypes.DATE,
84
- updatedAt: DataTypes.DATE,
85
- },
86
- {
87
- // Other model options go here
88
- tableName: "player_results",
89
- sequelize,
90
- }
91
- );
92
-
93
- export default PlayerResult;
@@ -1,118 +0,0 @@
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 Player extends Model<
14
- InferAttributes<Player>,
15
- InferCreationAttributes<Player>
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 oddsJamId: string;
21
- declare playerName: string;
22
- declare sport: string;
23
- declare league: string;
24
- declare firstName?: string;
25
- declare lastName?: string;
26
- declare teamName?: string;
27
- declare oddsJamTeamId?: string;
28
- declare number?: string;
29
- declare position?: string;
30
- declare age?: string;
31
- declare height?: string;
32
- declare weight?: number;
33
- declare teamId?: string;
34
- declare leagueId: string;
35
- declare createdAt: CreationOptional<Date>;
36
- declare updatedAt: CreationOptional<Date>;
37
- }
38
-
39
- Player.init(
40
- {
41
- id: {
42
- type: DataTypes.BIGINT,
43
- primaryKey: true,
44
- allowNull: false,
45
- defaultValue: sequelize.fn("next_id"),
46
- },
47
- oddsJamId: {
48
- type: DataTypes.STRING,
49
- field: "odds_jam_id",
50
- unique: true,
51
- },
52
- playerName: {
53
- type: DataTypes.STRING,
54
- field: "player_name",
55
- },
56
- sport: {
57
- type: DataTypes.STRING,
58
- field: "sport",
59
- },
60
- league: {
61
- type: DataTypes.STRING,
62
- field: "league",
63
- },
64
- firstName: {
65
- type: DataTypes.STRING,
66
- field: "first_name",
67
- },
68
- lastName: {
69
- type: DataTypes.STRING,
70
- field: "last_name",
71
- },
72
- teamName: {
73
- type: DataTypes.STRING,
74
- field: "team_name",
75
- },
76
- oddsJamTeamId: {
77
- type: DataTypes.STRING,
78
- field: "odds_jam_team_id",
79
- },
80
- number: {
81
- type: DataTypes.STRING,
82
- field: "number",
83
- },
84
- position: {
85
- type: DataTypes.STRING,
86
- field: "position",
87
- },
88
- age: {
89
- type: DataTypes.STRING,
90
- field: "age",
91
- },
92
- height: {
93
- type: DataTypes.STRING,
94
- field: "height",
95
- },
96
- weight: {
97
- type: DataTypes.STRING,
98
- field: "weight",
99
- },
100
- teamId: {
101
- type: DataTypes.BIGINT,
102
- field: "team_id",
103
- },
104
- leagueId: {
105
- type: DataTypes.BIGINT,
106
- field: "league_id",
107
- },
108
- createdAt: DataTypes.DATE,
109
- updatedAt: DataTypes.DATE,
110
- },
111
- {
112
- // Other model options go here
113
- tableName: "players",
114
- sequelize,
115
- }
116
- );
117
-
118
- export default Player;
@@ -1,120 +0,0 @@
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 ShortUrl extends Model<
14
- InferAttributes<ShortUrl>,
15
- InferCreationAttributes<ShortUrl>
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 shortCode: string;
21
- declare longUrl: string;
22
- declare createdAt: CreationOptional<Date>;
23
- declare updatedAt: CreationOptional<Date>;
24
- static createShortUrl: (longUrl: string) => Promise<string>;
25
- static customShortUrl: (
26
- longUrl: string,
27
- shortCode: string
28
- ) => Promise<string>;
29
- static getByShortCode: (shortCode: string) => Promise<ShortUrl | null>;
30
- }
31
-
32
- ShortUrl.init(
33
- {
34
- id: {
35
- type: DataTypes.BIGINT,
36
- primaryKey: true,
37
- allowNull: false,
38
- defaultValue: sequelize.fn("next_id"),
39
- },
40
- shortCode: {
41
- type: DataTypes.STRING,
42
- allowNull: false,
43
- field: "short_code",
44
- unique: true,
45
- },
46
- longUrl: {
47
- type: DataTypes.STRING(500),
48
- allowNull: false,
49
- field: "long_url",
50
- },
51
- createdAt: DataTypes.DATE,
52
- updatedAt: DataTypes.DATE,
53
- },
54
- {
55
- // Other model options go here
56
- tableName: "short_urls",
57
- sequelize,
58
- }
59
- );
60
-
61
- /*
62
- ====================================================================
63
- Class functions
64
- ====================================================================
65
- */
66
-
67
- function randomString(length: number, chars: string) {
68
- var result = "";
69
- for (var i = length; i > 0; --i)
70
- result += chars[Math.floor(Math.random() * chars.length)];
71
- return result;
72
- }
73
-
74
- ShortUrl.createShortUrl = async (longUrl: string) => {
75
- const shortCode = randomString(
76
- 7,
77
- "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
78
- );
79
-
80
- if (!process.env.SHORT_URL) {
81
- return longUrl;
82
- }
83
-
84
- try {
85
- await ShortUrl.create({
86
- shortCode,
87
- longUrl,
88
- });
89
- return process.env.SHORT_URL + shortCode;
90
- } catch (err) {
91
- console.log(err);
92
- return longUrl;
93
- }
94
- };
95
-
96
- ShortUrl.customShortUrl = async (longUrl: string, shortCode: string) => {
97
- if (!process.env.SHORT_URL) {
98
- return longUrl;
99
- }
100
-
101
- try {
102
- await ShortUrl.create({
103
- shortCode,
104
- longUrl,
105
- });
106
- return process.env.SHORT_URL + shortCode;
107
- } catch (err) {
108
- console.log(err);
109
- return longUrl;
110
- }
111
- };
112
-
113
- ShortUrl.getByShortCode = async (shortCode: string) => {
114
- return await ShortUrl.findOne({
115
- where: {
116
- shortCode,
117
- },
118
- });
119
- };
120
- export default ShortUrl;
@@ -1,48 +0,0 @@
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 Sportsbook extends Model<
14
- InferAttributes<Sportsbook>,
15
- InferCreationAttributes<Sportsbook>
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 createdAt: CreationOptional<Date>;
22
- declare updatedAt: CreationOptional<Date>;
23
- }
24
-
25
- Sportsbook.init(
26
- {
27
- id: {
28
- type: DataTypes.BIGINT,
29
- primaryKey: true,
30
- allowNull: false,
31
- defaultValue: sequelize.fn("next_id"),
32
- },
33
- name: {
34
- type: DataTypes.STRING,
35
- field: "name",
36
- unique: true,
37
- },
38
- createdAt: DataTypes.DATE,
39
- updatedAt: DataTypes.DATE,
40
- },
41
- {
42
- // Other model options go here
43
- tableName: "sportsbooks",
44
- sequelize,
45
- }
46
- );
47
-
48
- export default Sportsbook;
@@ -1,80 +0,0 @@
1
- import {
2
- Model,
3
- InferAttributes,
4
- InferCreationAttributes,
5
- CreationOptional,
6
- DataTypes,
7
- fn,
8
- NOW,
9
- } from "sequelize";
10
-
11
- import sequelize from "./pb-sequelize";
12
- import SubscriptionPlan from "./subscription-plan";
13
-
14
- // order of InferAttributes & InferCreationAttributes is important.
15
- class SubscriptionBundle extends Model<
16
- InferAttributes<SubscriptionBundle>,
17
- InferCreationAttributes<SubscriptionBundle>
18
- > {
19
- // 'CreationOptional' is a special type that marks the field as optional
20
- // when creating an instance of the model (such as using Model.create()).
21
- declare id: CreationOptional<string>;
22
- declare subscriptionPlanId: string;
23
- declare bundleIntervalCount?: number;
24
- declare bundleDiscountPercentage?: number;
25
- declare isActive?: boolean;
26
- declare recurlyPlanId?: string;
27
- declare createdAt: CreationOptional<Date>;
28
- declare updatedAt: CreationOptional<Date>;
29
- }
30
-
31
- SubscriptionBundle.init(
32
- {
33
- id: {
34
- type: DataTypes.BIGINT,
35
- primaryKey: true,
36
- allowNull: false,
37
- defaultValue: sequelize.fn("next_id"),
38
- },
39
- subscriptionPlanId: {
40
- type: DataTypes.BIGINT,
41
- allowNull: false,
42
- field: "subscription_plan_id",
43
- },
44
- bundleIntervalCount: {
45
- type: DataTypes.INTEGER,
46
- field: "bundle_interval_count",
47
- defaultValue: 0,
48
- },
49
- bundleDiscountPercentage: {
50
- type: DataTypes.FLOAT,
51
- field: "bundle_discount_percentage",
52
- },
53
- isActive: {
54
- type: DataTypes.BOOLEAN,
55
- field: "is_active",
56
- defaultValue: true,
57
- },
58
- recurlyPlanId: {
59
- type: DataTypes.STRING,
60
- field: "recurly_plan_id",
61
- },
62
- createdAt: DataTypes.DATE,
63
- updatedAt: DataTypes.DATE,
64
- },
65
- {
66
- tableName: "subscription_bundles",
67
- sequelize,
68
- }
69
- );
70
-
71
- SubscriptionBundle.hasOne(SubscriptionPlan, {
72
- foreignKey: "id",
73
- sourceKey: "subscriptionPlanId",
74
- });
75
- SubscriptionPlan.hasMany(SubscriptionBundle, {
76
- foreignKey: "subscription_plan_id",
77
- sourceKey: "id",
78
- });
79
-
80
- export default SubscriptionBundle;