@winible/winible-typed 1.0.10 → 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 (224) hide show
  1. package/dist/migrations/20230330174702-extend-premium-content.js +35 -0
  2. package/dist/migrations/20230330174702-extend-premium-content.js.map +1 -0
  3. package/dist/migrations/20230405141245-deprecate-agencies.js +9 -0
  4. package/dist/migrations/20230405141245-deprecate-agencies.js.map +1 -0
  5. package/dist/migrations/20230405142440-deprecate-unused-tables.js +23 -0
  6. package/dist/migrations/20230405142440-deprecate-unused-tables.js.map +1 -0
  7. package/dist/migrations/20230410144940-deprecate-consent-people.js +9 -0
  8. package/dist/migrations/20230410144940-deprecate-consent-people.js.map +1 -0
  9. package/dist/migrations/20230410174328-deprecate-consent-people-table.js +9 -0
  10. package/dist/migrations/20230410174328-deprecate-consent-people-table.js.map +1 -0
  11. package/dist/migrations/20230410181920-migrate-credit-payments-to-transactions.js +9 -0
  12. package/dist/migrations/20230410181920-migrate-credit-payments-to-transactions.js.map +1 -0
  13. package/dist/migrations/20230410202433-migrate-credit-payments-fields.js +12 -0
  14. package/dist/migrations/20230410202433-migrate-credit-payments-fields.js.map +1 -0
  15. package/dist/migrations/20230410211059-deprecate-credit-purchases.js +9 -0
  16. package/dist/migrations/20230410211059-deprecate-credit-purchases.js.map +1 -0
  17. package/dist/migrations/20230410212035-deprecate-dashboard_user_permissions.js +10 -0
  18. package/dist/migrations/20230410212035-deprecate-dashboard_user_permissions.js.map +1 -0
  19. package/dist/migrations/20230410212324-deprecate-non-breaking-tables.js +34 -0
  20. package/dist/migrations/20230410212324-deprecate-non-breaking-tables.js.map +1 -0
  21. package/dist/migrations/20230411054826-create-users-table.js +141 -0
  22. package/dist/migrations/20230411054826-create-users-table.js.map +1 -0
  23. package/dist/migrations/20230411202848-migrate_transactions_table.js +24 -0
  24. package/dist/migrations/20230411202848-migrate_transactions_table.js.map +1 -0
  25. package/dist/migrations/20230411203543-migrate_league_users.js +9 -0
  26. package/dist/migrations/20230411203543-migrate_league_users.js.map +1 -0
  27. package/dist/migrations/20230411205324-migrate_league.js +13 -0
  28. package/dist/migrations/20230411205324-migrate_league.js.map +1 -0
  29. package/dist/migrations/20230411221159-migrate_media.js +9 -0
  30. package/dist/migrations/20230411221159-migrate_media.js.map +1 -0
  31. package/dist/migrations/20230411221327-migrate_media_asset.js +10 -0
  32. package/dist/migrations/20230411221327-migrate_media_asset.js.map +1 -0
  33. package/dist/migrations/20230411221842-migrate_media_asset_fields.js +10 -0
  34. package/dist/migrations/20230411221842-migrate_media_asset_fields.js.map +1 -0
  35. package/dist/migrations/20230411222018-migrate_notifications.js +25 -0
  36. package/dist/migrations/20230411222018-migrate_notifications.js.map +1 -0
  37. package/dist/scripts/cleanupRecurlyPlans.js +12 -5
  38. package/dist/scripts/cleanupRecurlyPlans.js.map +1 -1
  39. package/dist/scripts/mapCurrentPaymentsToInvoiceId.js +12 -5
  40. package/dist/scripts/mapCurrentPaymentsToInvoiceId.js.map +1 -1
  41. package/dist/src/index.js +1 -18
  42. package/dist/src/index.js.map +1 -1
  43. package/dist/typed-model/credit-payment.js +133 -82
  44. package/dist/typed-model/credit-payment.js.map +1 -1
  45. package/dist/typed-model/index.js +3 -81
  46. package/dist/typed-model/index.js.map +1 -1
  47. package/dist/typed-model/league-user.js +28 -4
  48. package/dist/typed-model/league-user.js.map +1 -1
  49. package/dist/typed-model/media-asset.js +0 -9
  50. package/dist/typed-model/media-asset.js.map +1 -1
  51. package/dist/typed-model/notification.js +34 -24
  52. package/dist/typed-model/notification.js.map +1 -1
  53. package/dist/typed-model/pb-sequelize.js +18 -4
  54. package/dist/typed-model/pb-sequelize.js.map +1 -1
  55. package/dist/typed-model/subscription-plan-on-premium-content.js +57 -0
  56. package/dist/typed-model/subscription-plan-on-premium-content.js.map +1 -0
  57. package/dist/typed-model/subscription-plan.js +0 -9
  58. package/dist/typed-model/subscription-plan.js.map +1 -1
  59. package/dist/typed-model/subscription.js +0 -14
  60. package/dist/typed-model/subscription.js.map +1 -1
  61. package/dist/typed-model/user.js +194 -0
  62. package/dist/typed-model/user.js.map +1 -0
  63. package/package.json +3 -2
  64. package/src/index.ts +0 -2
  65. package/typed-model/credit-payment.ts +124 -126
  66. package/typed-model/index.ts +1 -51
  67. package/typed-model/media-asset.ts +0 -10
  68. package/typed-model/notification.ts +39 -44
  69. package/typed-model/pb-sequelize.ts +18 -4
  70. package/typed-model/subscription-plan.ts +0 -10
  71. package/typed-model/subscription.ts +1 -15
  72. package/typed-model/user.ts +248 -0
  73. package/dist/index.d.ts +0 -3
  74. package/dist/migrations/20220601151258-custom_name_describing_your_migration.d.ts +0 -6
  75. package/dist/migrations/20220605225655-create-dashboard-user-permissions.d.ts +0 -6
  76. package/dist/migrations/20220606001300-update-dashboard-user-permissions.d.ts +0 -6
  77. package/dist/migrations/20220607091109-add-read-date-for-message.d.ts +0 -6
  78. package/dist/migrations/20220616225456-add-delete-columns.d.ts +0 -6
  79. package/dist/migrations/20220709202211-disable-feed.d.ts +0 -6
  80. package/dist/migrations/20220723215213-limit-promotion-claims.d.ts +0 -6
  81. package/dist/migrations/20220723220233-num_claims.d.ts +0 -6
  82. package/dist/migrations/20220723221907-default_false_promos.d.ts +0 -6
  83. package/dist/migrations/20220724172559-default_zero_claims.d.ts +0 -6
  84. package/dist/migrations/20220724201419-pinned_post.d.ts +0 -6
  85. package/dist/migrations/20220729164625-unsend_mass.d.ts +0 -6
  86. package/dist/migrations/20220823033002-interval-unit.d.ts +0 -6
  87. package/dist/migrations/20220830193530-processorId.d.ts +0 -6
  88. package/dist/migrations/20220907121932-add-processor-to-sub.d.ts +0 -6
  89. package/dist/migrations/20220907212232-add-trans-id.d.ts +0 -6
  90. package/dist/migrations/20220907220423-big-int-trans.d.ts +0 -6
  91. package/dist/migrations/20220909161902-add-stale.d.ts +0 -6
  92. package/dist/migrations/20220922000225-verified-spender.d.ts +0 -6
  93. package/dist/migrations/20220922212108-verified-spender-2.d.ts +0 -6
  94. package/dist/migrations/20221013223648-product-subscription-list.d.ts +0 -6
  95. package/dist/migrations/20221014001037-product-subscription-list.d.ts +0 -6
  96. package/dist/migrations/20221026055245-update-type.d.ts +0 -6
  97. package/dist/migrations/20221108060019-recurly-sub.d.ts +0 -6
  98. package/dist/migrations/20221110170148-rename-recurly-account.d.ts +0 -6
  99. package/dist/migrations/20221112212510-archive-promo.d.ts +0 -6
  100. package/dist/migrations/20221117044529-sub-status.d.ts +0 -6
  101. package/dist/migrations/20221122051433-default-plan.d.ts +0 -6
  102. package/dist/migrations/20221128034620-invoice-id.d.ts +0 -6
  103. package/dist/migrations/20230313175014-league-user.js +0 -27
  104. package/dist/migrations/20230313175014-league-user.js.map +0 -1
  105. package/dist/scripts/bet-syncing/checkForPrizePicks.js +0 -85
  106. package/dist/scripts/bet-syncing/checkForPrizePicks.js.map +0 -1
  107. package/dist/scripts/bet-syncing/pullTeams.d.ts +0 -1
  108. package/dist/scripts/cleanupRecurlyPlans.d.ts +0 -1
  109. package/dist/scripts/createDashboardLink.d.ts +0 -1
  110. package/dist/scripts/createRecurlyPlans.d.ts +0 -1
  111. package/dist/scripts/deleteMalformedImages.d.ts +0 -1
  112. package/dist/scripts/fixSaltedPasswords.js +0 -40
  113. package/dist/scripts/fixSaltedPasswords.js.map +0 -1
  114. package/dist/scripts/mapCurrentPaymentsToInvoiceId.d.ts +0 -1
  115. package/dist/scripts/payoutRecurlySubs.d.ts +0 -1
  116. package/dist/scripts/payoutSubscriptions.d.ts +0 -1
  117. package/dist/scripts/removeUnreferenceSubs.d.ts +0 -1
  118. package/dist/scripts/test.d.ts +0 -1
  119. package/dist/slack/index.d.ts +0 -1
  120. package/dist/slack/v1/bypassCreator.d.ts +0 -8
  121. package/dist/slack/v1/cancelSubscription.d.ts +0 -6
  122. package/dist/slack/v1/changeName.d.ts +0 -8
  123. package/dist/slack/v1/checkAuthSub.d.ts +0 -6
  124. package/dist/slack/v1/dashboardLink.d.ts +0 -8
  125. package/dist/slack/v1/index.d.ts +0 -7
  126. package/dist/slack/v1/refund.d.ts +0 -6
  127. package/dist/slack/v1/searchUser.d.ts +0 -6
  128. package/dist/src/index.d.ts +0 -3
  129. package/dist/src/pk-client.d.ts +0 -151
  130. package/dist/src/pk-sub.d.ts +0 -77
  131. package/dist/src/recurlyInstance.d.ts +0 -3
  132. package/dist/src/types.d.ts +0 -30
  133. package/dist/support/index.d.ts +0 -2
  134. package/dist/support/slack-client.d.ts +0 -3
  135. package/dist/support/uploadcare.d.ts +0 -14
  136. package/dist/support/utils.d.ts +0 -2
  137. package/dist/typed-model/asset-category.d.ts +0 -9
  138. package/dist/typed-model/asset-constent-person.d.ts +0 -13
  139. package/dist/typed-model/bet.d.ts +0 -12
  140. package/dist/typed-model/blocked-ip.d.ts +0 -8
  141. package/dist/typed-model/category-tag.d.ts +0 -9
  142. package/dist/typed-model/consent-person.d.ts +0 -13
  143. package/dist/typed-model/content-category-tag.d.ts +0 -9
  144. package/dist/typed-model/content-like.d.ts +0 -10
  145. package/dist/typed-model/credit-payment.d.ts +0 -34
  146. package/dist/typed-model/credit-payout.d.ts +0 -10
  147. package/dist/typed-model/credit-purchase.d.ts +0 -10
  148. package/dist/typed-model/customer-profile.d.ts +0 -17
  149. package/dist/typed-model/dashboard-user-permissions.d.ts +0 -9
  150. package/dist/typed-model/dashboard-user.d.ts +0 -20
  151. package/dist/typed-model/fan-list.d.ts +0 -10
  152. package/dist/typed-model/fraud.d.ts +0 -9
  153. package/dist/typed-model/game.d.ts +0 -56
  154. package/dist/typed-model/index.d.ts +0 -46
  155. package/dist/typed-model/league.d.ts +0 -9
  156. package/dist/typed-model/list-member.d.ts +0 -9
  157. package/dist/typed-model/mass-message.d.ts +0 -11
  158. package/dist/typed-model/media-asset.d.ts +0 -15
  159. package/dist/typed-model/media-category.d.ts +0 -10
  160. package/dist/typed-model/media.d.ts +0 -14
  161. package/dist/typed-model/message-media.d.ts +0 -9
  162. package/dist/typed-model/message.d.ts +0 -27
  163. package/dist/typed-model/notification.d.ts +0 -18
  164. package/dist/typed-model/odds.d.ts +0 -30
  165. package/dist/typed-model/parlay.d.ts +0 -8
  166. package/dist/typed-model/pb-sequelize.d.ts +0 -3
  167. package/dist/typed-model/phone-chat-participation.d.ts +0 -20
  168. package/dist/typed-model/phone-chat.d.ts +0 -16
  169. package/dist/typed-model/phone-owner.d.ts +0 -53
  170. package/dist/typed-model/phone-user.d.ts +0 -21
  171. package/dist/typed-model/player.d.ts +0 -22
  172. package/dist/typed-model/premium-content.d.ts +0 -23
  173. package/dist/typed-model/purchased-content.d.ts +0 -11
  174. package/dist/typed-model/recurly-account.d.ts +0 -9
  175. package/dist/typed-model/short-url.d.ts +0 -12
  176. package/dist/typed-model/subscription-bundle.d.ts +0 -12
  177. package/dist/typed-model/subscription-category-tags.d.ts +0 -9
  178. package/dist/typed-model/subscription-plan.d.ts +0 -27
  179. package/dist/typed-model/subscription-promotion.d.ts +0 -19
  180. package/dist/typed-model/subscription.d.ts +0 -26
  181. package/dist/typed-model/team.d.ts +0 -16
  182. package/dist/typed-model/twilio-phone.d.ts +0 -17
  183. package/dist/typed-model/user-follow.d.ts +0 -13
  184. package/dist/typed-model/verification-code.d.ts +0 -11
  185. package/dist/webhooks/index.d.ts +0 -1
  186. package/dist/webhooks/payment/index.d.ts +0 -1
  187. package/dist/webhooks/payment/refund.d.ts +0 -2
  188. package/src/pk-client.ts +0 -1650
  189. package/src/pk-sub.ts +0 -455
  190. package/typed-model/asset-category.ts +0 -57
  191. package/typed-model/asset-constent-person.ts +0 -82
  192. package/typed-model/bet.ts +0 -84
  193. package/typed-model/blocked-ip.ts +0 -52
  194. package/typed-model/category-tag.ts +0 -66
  195. package/typed-model/consent-person.ts +0 -78
  196. package/typed-model/content-category-tag.ts +0 -79
  197. package/typed-model/credit-purchase.ts +0 -67
  198. package/typed-model/customer-profile.ts +0 -71
  199. package/typed-model/dashboard-user-permissions.ts +0 -51
  200. package/typed-model/dashboard-user.ts +0 -146
  201. package/typed-model/fan-list.ts +0 -68
  202. package/typed-model/fraud.ts +0 -62
  203. package/typed-model/game.ts +0 -311
  204. package/typed-model/list-member.ts +0 -67
  205. package/typed-model/market.ts +0 -54
  206. package/typed-model/mass-message.ts +0 -64
  207. package/typed-model/media-category.ts +0 -70
  208. package/typed-model/message-media.ts +0 -74
  209. package/typed-model/message.ts +0 -258
  210. package/typed-model/odds.ts +0 -238
  211. package/typed-model/parlay.ts +0 -47
  212. package/typed-model/phone-chat-participation.ts +0 -166
  213. package/typed-model/phone-chat.ts +0 -185
  214. package/typed-model/player-result.ts +0 -93
  215. package/typed-model/player.ts +0 -118
  216. package/typed-model/short-url.ts +0 -120
  217. package/typed-model/sportsbook.ts +0 -48
  218. package/typed-model/subscription-bundle.ts +0 -80
  219. package/typed-model/subscription-category-tags.ts +0 -79
  220. package/typed-model/subscription-promotion.ts +0 -134
  221. package/typed-model/team.ts +0 -91
  222. package/typed-model/twilio-phone.ts +0 -149
  223. package/typed-model/user-follow.ts +0 -141
  224. package/typed-model/verification-code.ts +0 -74
@@ -13,10 +13,9 @@ import sequelize from "./pb-sequelize";
13
13
  import PhoneOwner from "./phone-owner";
14
14
  import PhoneUser from "./phone-user";
15
15
  import PremiumContent from "./premium-content";
16
- import Message from "./message";
17
16
  import Subscription from "./subscription";
18
17
  import PurchasedContent from "./purchased-content";
19
- import Notification from "./notification";
18
+ import Notification, { NotificationType } from "./notification";
20
19
 
21
20
  type InteractionType =
22
21
  | "subscription"
@@ -94,7 +93,6 @@ class CreditPayments extends Model<
94
93
  static logUnlockMessage: (
95
94
  user: PhoneUser,
96
95
  owner: PhoneOwner,
97
- message: Message,
98
96
  alreadyPaid?: boolean,
99
97
  transaction?: Transaction,
100
98
  invoiceId?: string
@@ -247,11 +245,11 @@ CreditPayments.logContentPurchase = async (
247
245
  try {
248
246
  await Notification.create(
249
247
  {
250
- ownerId: content.ownerId,
251
- userId: user.id,
252
- creditPaymentId: creditPayment.id,
253
- type: "content",
254
- purchasedContentId: purchasedContent.id,
248
+ recipientId: user.id,
249
+ senderId: content.ownerId,
250
+ transactionId: creditPayment.id,
251
+ type: NotificationType.PURCHASED_POST,
252
+ purchasedPostId: purchasedContent.id,
255
253
  },
256
254
  { transaction }
257
255
  );
@@ -280,57 +278,57 @@ CreditPayments.logContentPurchase = async (
280
278
  return creditPayment;
281
279
  };
282
280
 
283
- CreditPayments.logTip = async (
284
- user: PhoneUser,
285
- owner: PhoneOwner,
286
- tipAmountInCents: number
287
- ) => {
288
- if (tipAmountInCents > user.creditsInCents!) {
289
- let url = await getPaymentUrl(user, owner);
290
- throw new Error(
291
- `Sorry, it looks like you've run out of credits. To send a tip, add more credits here: ${url}`
292
- );
293
- }
294
-
295
- if (tipAmountInCents < 0) {
296
- throw new Error("Cannot be less than 0");
297
- }
298
-
299
- user.creditsInCents = user.creditsInCents! - tipAmountInCents;
300
- await user.save();
301
-
302
- let creditPayment = await CreditPayments.create({
303
- userId: user.id,
304
- ownerId: owner.id,
305
- creditAmountInCents: tipAmountInCents,
306
- earningAmountInCents: earningsAmount(
307
- tipAmountInCents,
308
- owner.serviceFeePercentage
309
- ),
310
- interactionType: INTERACTION_TYPES.TIP,
311
- });
312
-
313
- if (owner.referringOwnerId) {
314
- await createReferralPayment(owner, creditPayment, tipAmountInCents);
315
- }
316
-
317
- if (user.referringOwnerId) {
318
- await createUserReferralPayment(user, creditPayment, tipAmountInCents);
319
- }
320
-
321
- try {
322
- await Notification.create({
323
- ownerId: owner.id,
324
- userId: user.id,
325
- creditPaymentId: creditPayment.id,
326
- type: "tip",
327
- });
328
- } catch (err) {
329
- console.log(err);
330
- }
331
-
332
- return creditPayment;
333
- };
281
+ // CreditPayments.logTip = async (
282
+ // user: PhoneUser,
283
+ // owner: PhoneOwner,
284
+ // tipAmountInCents: number
285
+ // ) => {
286
+ // if (tipAmountInCents > user.creditsInCents!) {
287
+ // let url = await getPaymentUrl(user, owner);
288
+ // throw new Error(
289
+ // `Sorry, it looks like you've run out of credits. To send a tip, add more credits here: ${url}`
290
+ // );
291
+ // }
292
+
293
+ // if (tipAmountInCents < 0) {
294
+ // throw new Error("Cannot be less than 0");
295
+ // }
296
+
297
+ // user.creditsInCents = user.creditsInCents! - tipAmountInCents;
298
+ // await user.save();
299
+
300
+ // let creditPayment = await CreditPayments.create({
301
+ // userId: user.id,
302
+ // ownerId: owner.id,
303
+ // creditAmountInCents: tipAmountInCents,
304
+ // earningAmountInCents: earningsAmount(
305
+ // tipAmountInCents,
306
+ // owner.serviceFeePercentage
307
+ // ),
308
+ // interactionType: INTERACTION_TYPES.TIP,
309
+ // });
310
+
311
+ // if (owner.referringOwnerId) {
312
+ // await createReferralPayment(owner, creditPayment, tipAmountInCents);
313
+ // }
314
+
315
+ // if (user.referringOwnerId) {
316
+ // await createUserReferralPayment(user, creditPayment, tipAmountInCents);
317
+ // }
318
+
319
+ // try {
320
+ // await Notification.create({
321
+ // ownerId: owner.id,
322
+ // userId: user.id,
323
+ // creditPaymentId: creditPayment.id,
324
+ // type: "tip",
325
+ // });
326
+ // } catch (err) {
327
+ // console.log(err);
328
+ // }
329
+
330
+ // return creditPayment;
331
+ // };
334
332
 
335
333
  CreditPayments.logMessage = async (
336
334
  user: PhoneUser,
@@ -438,72 +436,72 @@ CreditPayments.logVideoCall = async (
438
436
  return creditPayment;
439
437
  };
440
438
 
441
- CreditPayments.logUnlockMessage = async (
442
- user: PhoneUser,
443
- owner: PhoneOwner,
444
- message: Message,
445
- alreadyPaid?: boolean,
446
- transaction?: Transaction,
447
- invoiceId?: string
448
- ) => {
449
- if (message.amountInCents! > user.creditsInCents! && !alreadyPaid) {
450
- throw new Error(`Sorry, it looks like you've run out of credits`);
451
- }
452
-
453
- if (!message.amountInCents) {
454
- throw new Error("Must contain message amount");
455
- }
456
-
457
- if (message.amountInCents! < 0) {
458
- throw new Error("Cannot be less than 0");
459
- }
460
-
461
- if (!alreadyPaid) {
462
- user.creditsInCents = user.creditsInCents! - message.amountInCents!;
463
- await user.save({ transaction });
464
- }
465
-
466
- let creditPayment = await CreditPayments.create(
467
- {
468
- userId: user.id,
469
- ownerId: owner.id,
470
- creditAmountInCents: message.amountInCents!,
471
- earningAmountInCents: earningsAmount(
472
- message.amountInCents!,
473
- owner.serviceFeePercentage
474
- ),
475
- invoiceId,
476
- interactionType: INTERACTION_TYPES.UNLOCK_MESSAGE,
477
- },
478
- { transaction }
479
- );
480
-
481
- try {
482
- await Notification.create(
483
- {
484
- ownerId: owner.id,
485
- userId: user.id,
486
- creditPaymentId: creditPayment.id,
487
- type: "unlock_message",
488
- messageId: message.id,
489
- },
490
- { transaction }
491
- );
492
- } catch (err) {
493
- console.log(err);
494
- }
495
-
496
- if (owner.referringOwnerId) {
497
- await createReferralPayment(
498
- owner,
499
- creditPayment,
500
- message.amountInCents!,
501
- transaction
502
- );
503
- }
504
-
505
- return creditPayment;
506
- };
439
+ // CreditPayments.logUnlockMessage = async (
440
+ // user: PhoneUser,
441
+ // owner: PhoneOwner,
442
+ // message: Message,
443
+ // alreadyPaid?: boolean,
444
+ // transaction?: Transaction,
445
+ // invoiceId?: string
446
+ // ) => {
447
+ // if (message.amountInCents! > user.creditsInCents! && !alreadyPaid) {
448
+ // throw new Error(`Sorry, it looks like you've run out of credits`);
449
+ // }
450
+
451
+ // if (!message.amountInCents) {
452
+ // throw new Error("Must contain message amount");
453
+ // }
454
+
455
+ // if (message.amountInCents! < 0) {
456
+ // throw new Error("Cannot be less than 0");
457
+ // }
458
+
459
+ // if (!alreadyPaid) {
460
+ // user.creditsInCents = user.creditsInCents! - message.amountInCents!;
461
+ // await user.save({ transaction });
462
+ // }
463
+
464
+ // let creditPayment = await CreditPayments.create(
465
+ // {
466
+ // userId: user.id,
467
+ // ownerId: owner.id,
468
+ // creditAmountInCents: message.amountInCents!,
469
+ // earningAmountInCents: earningsAmount(
470
+ // message.amountInCents!,
471
+ // owner.serviceFeePercentage
472
+ // ),
473
+ // invoiceId,
474
+ // interactionType: INTERACTION_TYPES.UNLOCK_MESSAGE,
475
+ // },
476
+ // { transaction }
477
+ // );
478
+
479
+ // try {
480
+ // await Notification.create(
481
+ // {
482
+ // ownerId: owner.id,
483
+ // userId: user.id,
484
+ // creditPaymentId: creditPayment.id,
485
+ // type: "unlock_message",
486
+ // messageId: message.id,
487
+ // },
488
+ // { transaction }
489
+ // );
490
+ // } catch (err) {
491
+ // console.log(err);
492
+ // }
493
+
494
+ // if (owner.referringOwnerId) {
495
+ // await createReferralPayment(
496
+ // owner,
497
+ // creditPayment,
498
+ // message.amountInCents!,
499
+ // transaction
500
+ // );
501
+ // }
502
+
503
+ // return creditPayment;
504
+ // };
507
505
 
508
506
  CreditPayments.logUnlockedContent = async (
509
507
  user: PhoneUser,
@@ -675,7 +673,7 @@ CreditPayments.hasOne(PhoneUser, {
675
673
  });
676
674
  Notification.hasOne(CreditPayments, {
677
675
  foreignKey: "id",
678
- sourceKey: "creditPaymentId",
676
+ sourceKey: "transactionId",
679
677
  constraints: false,
680
678
  onDelete: "NO ACTION",
681
679
  });
@@ -1,66 +1,16 @@
1
- // let models = {
2
- // DashboardUserPermissions: require("./dashboard-user-permissions"),
3
- // PhoneUser: require("./phone-user"),
4
- // PhoneOwner: require("./phone-owner"),
5
- // DashboardUser: require("./dashboard-user"),
6
- // };
7
-
8
- // export sequelize from "./pb-sequelize";
9
-
10
- // const sync = async () => {
11
- // console.log("Syncing type models...");
12
- // await sequelize.sync({ alter: true });
13
- // console.log("Sync done");
14
- // };
15
-
16
- // if (process.env.SYNC_TABLES) {
17
- // sync();
18
- // }
19
-
20
- export { default as AssetCategory } from "./asset-category";
21
- export { default as AssetConsentPerson } from "./asset-constent-person";
22
- export { default as PhoneChat } from "./phone-chat";
23
- export { default as PhoneChatParticipant } from "./phone-chat-participation";
24
- export { default as ConsentPerson } from "./consent-person";
25
1
  export { default as ContentLike } from "./content-like";
26
2
  export { default as CreditPayments } from "./credit-payment";
27
- export { default as CreditPurchase } from "./credit-purchase";
28
- export { default as BlockedIP } from "./blocked-ip";
29
- export { default as CustomerProfile, ProcessorId } from "./customer-profile";
30
- export { default as DashboardUserPermissions } from "./dashboard-user-permissions";
31
- export { default as DashboardUser } from "./dashboard-user";
32
- export { default as FanList } from "./fan-list";
33
- export { default as Fraud } from "./fraud";
34
- export { default as ListMember } from "./list-member";
35
- export { default as MassMessage } from "./mass-message";
36
3
  export { default as MediaAsset } from "./media-asset";
37
- export { default as MediaCategory } from "./media-category";
38
4
  export { default as Media } from "./media";
39
- export { default as MessageMedia } from "./message-media";
40
- export { default as Message } from "./message";
41
5
  export { default as Notification } from "./notification";
42
6
  export { default as pbSequelize } from "./pb-sequelize";
43
7
  export { default as PhoneOwner } from "./phone-owner";
44
8
  export { default as PhoneUser } from "./phone-user";
45
9
  export { default as PremiumContent } from "./premium-content";
46
10
  export { default as PurchasedContent } from "./purchased-content";
47
- export { default as SubscriptionBundle } from "./subscription-bundle";
48
11
  export { default as SubscriptionPlan } from "./subscription-plan";
49
- export { default as SubscriptionPromotion } from "./subscription-promotion";
50
12
  export { default as Subscription } from "./subscription";
51
- export { default as UserFollow } from "./user-follow";
52
- export { default as TwilioPhone } from "./twilio-phone";
53
13
  export { default as RecurlyAccount } from "./recurly-account";
54
- export { default as ShortUrl } from "./short-url";
55
14
  export { default as CreditPayout } from "./credit-payout";
56
- export { default as VerificationCode } from "./verification-code";
57
- export { default as CategoryTag } from "./category-tag";
58
- export { default as SubscriptionCategoryTag } from "./subscription-category-tags";
59
- export { default as ContentCategoryTag } from "./content-category-tag";
60
- export { default as Team } from "./team";
61
15
  export { default as League } from "./league";
62
- export { default as Game } from "./game";
63
- export { default as Odds } from "./odds";
64
- export { default as Bet } from "./bet";
65
- export { default as Parlay } from "./parlay";
66
- export { default as Player } from "./player";
16
+ export { default as User } from "./user";
@@ -8,7 +8,6 @@ import {
8
8
  } from "sequelize";
9
9
 
10
10
  import sequelize from "./pb-sequelize";
11
- import AssetCategory from "./asset-category";
12
11
 
13
12
  // order of InferAttributes & InferCreationAttributes is important.
14
13
  class MediaAsset extends Model<
@@ -87,13 +86,4 @@ Class functions
87
86
  ====================================================================
88
87
  */
89
88
 
90
- AssetCategory.hasOne(MediaAsset, {
91
- foreignKey: "id",
92
- sourceKey: "mediaAssetId",
93
- });
94
- MediaAsset.hasMany(AssetCategory, {
95
- foreignKey: "media_asset_id",
96
- sourceKey: "id",
97
- });
98
-
99
89
  export default MediaAsset;
@@ -5,20 +5,19 @@ import {
5
5
  CreationOptional,
6
6
  DataTypes,
7
7
  fn,
8
- NOW,
9
8
  } from "sequelize";
10
9
 
11
10
  import sequelize from "./pb-sequelize";
12
- import PhoneUser from "./phone-user";
13
11
  import ContentLike from "./content-like";
12
+ import User from "./user";
14
13
 
15
- type NotificationType =
16
- | "unlock_message"
17
- | "follow"
18
- | "like"
19
- | "tip"
20
- | "subscription"
21
- | "content";
14
+ export enum NotificationType {
15
+ VIEWED = "VIEWED",
16
+ PURCHASED_PLAN = "PURCHASED_PLAN",
17
+ PURCHASED_POST = "PURCHASED_POST",
18
+ SUBSCRIBED = "SUBSCRIBED",
19
+ VIEWED_PROFILE = "VIEWED_PROFILE",
20
+ }
22
21
 
23
22
  // order of InferAttributes & InferCreationAttributes is important.
24
23
  class Notification extends Model<
@@ -28,15 +27,14 @@ class Notification extends Model<
28
27
  // 'CreationOptional' is a special type that marks the field as optional
29
28
  // when creating an instance of the model (such as using Model.create()).
30
29
  declare id: CreationOptional<string>;
31
- declare ownerId: string;
32
- declare userId?: string;
30
+ declare recipientId: string;
31
+ declare senderId?: string;
33
32
  declare isRead?: boolean;
34
33
  declare type: NotificationType;
35
- declare creditPaymentId?: string;
36
- declare purchasedContentId?: string;
37
- declare userFollowId?: string;
38
- declare contentLikeId?: string;
39
- declare messageId?: string;
34
+ declare transactionId?: string;
35
+ declare purchasedPostId?: string;
36
+ declare postLikeId?: string;
37
+ declare subscriptionPlanId?: string;
40
38
  declare createdAt: CreationOptional<Date>;
41
39
  declare updatedAt: CreationOptional<Date>;
42
40
  static readNotifications: (
@@ -53,14 +51,14 @@ Notification.init(
53
51
  allowNull: false,
54
52
  primaryKey: true,
55
53
  },
56
- ownerId: {
54
+ recipientId: {
57
55
  type: DataTypes.BIGINT,
58
- field: "owner_id",
56
+ field: "recipient_id",
59
57
  allowNull: false,
60
58
  },
61
- userId: {
59
+ senderId: {
62
60
  type: DataTypes.BIGINT,
63
- field: "user_id",
61
+ field: "sender_id",
64
62
  allowNull: false,
65
63
  },
66
64
  isRead: {
@@ -70,26 +68,22 @@ Notification.init(
70
68
  },
71
69
  type: {
72
70
  field: "type",
73
- type: DataTypes.STRING,
74
- },
75
- creditPaymentId: {
76
- field: "credit_payment_id",
77
- type: DataTypes.BIGINT,
71
+ type: DataTypes.ENUM(...Object.values(NotificationType)),
78
72
  },
79
- purchasedContentId: {
80
- field: "purchased_content_id",
73
+ transactionId: {
74
+ field: "transaction_id",
81
75
  type: DataTypes.BIGINT,
82
76
  },
83
- userFollowId: {
84
- field: "user_follow_id",
77
+ purchasedPostId: {
78
+ field: "purchased_post_id",
85
79
  type: DataTypes.BIGINT,
86
80
  },
87
- contentLikeId: {
88
- field: "content_like_id",
81
+ postLikeId: {
82
+ field: "post_like_id",
89
83
  type: DataTypes.BIGINT,
90
84
  },
91
- messageId: {
92
- field: "messageId",
85
+ subscriptionPlanId: {
86
+ field: "subscription_plan_id",
93
87
  type: DataTypes.BIGINT,
94
88
  },
95
89
  createdAt: DataTypes.DATE,
@@ -107,23 +101,24 @@ Class functions
107
101
  ====================================================================
108
102
  */
109
103
 
110
- Notification.readNotifications = async (
111
- ownerId: string,
112
- type: NotificationType
113
- ) => {
114
- await sequelize.query(
115
- `UPDATE notifications SET is_read=true WHERE owner_id=${ownerId} AND type=${type}`
116
- );
117
- };
104
+ // Notification.readNotifications = async (
105
+ // ownerId: string,
106
+ // type: NotificationType
107
+ // ) => {
108
+ // await sequelize.query(
109
+ // `UPDATE notifications SET is_read=true WHERE owner_id=${ownerId} AND type=${type}`
110
+ // );
111
+ // };
118
112
 
119
- Notification.hasOne(PhoneUser, {
113
+ Notification.hasOne(User, {
120
114
  foreignKey: "id",
121
- sourceKey: "userId",
115
+ sourceKey: "recipientId",
122
116
  constraints: false,
123
117
  });
118
+
124
119
  Notification.hasOne(ContentLike, {
125
120
  foreignKey: "id",
126
- sourceKey: "contentLikeId",
121
+ sourceKey: "postLikeId",
127
122
  constraints: false,
128
123
  });
129
124
 
@@ -13,13 +13,27 @@ const dbUrl =
13
13
  process.env.ENVIRONMENT === "test"
14
14
  ? process.env.TESTING_DATABASE_URL
15
15
  : process.env.DATABASE_URL;
16
- export default new Sequelize(dbUrl!, {
17
- logging: false,
18
- minifyAliases: true,
16
+ // export default new Sequelize(dbUrl!, {
17
+ // logging: false,
18
+ // minifyAliases: true,
19
+ // dialectOptions: {
20
+ // ssl: {
21
+ // require: true,
22
+ // rejectUnauthorized: false, // <<<<<<< YOU NEED THIS
23
+ // },
24
+ // },
25
+ // });
26
+ export default new Sequelize({
27
+ username: "postgres",
28
+ password: "l5WFq6a50%m4",
29
+ database: "winible",
30
+ host: "winible-v2-staging.cd9ez5rrajpu.us-east-1.rds.amazonaws.com",
31
+ dialect: "postgres",
32
+ ssl: false,
19
33
  dialectOptions: {
20
34
  ssl: {
21
35
  require: true,
22
- rejectUnauthorized: false, // <<<<<<< YOU NEED THIS
36
+ rejectUnauthorized: false,
23
37
  },
24
38
  },
25
39
  });
@@ -12,7 +12,6 @@ import {
12
12
  import sequelize from "./pb-sequelize";
13
13
  import PhoneOwner from "./phone-owner";
14
14
  import Subscription from "./subscription";
15
- import SubscriptionPromotion from "./subscription-promotion";
16
15
 
17
16
  // order of InferAttributes & InferCreationAttributes is important.
18
17
  class SubscriptionPlan extends Model<
@@ -170,13 +169,4 @@ PhoneOwner.hasMany(SubscriptionPlan, {
170
169
  constraints: false,
171
170
  });
172
171
 
173
- SubscriptionPromotion.hasOne(SubscriptionPlan, {
174
- foreignKey: "id",
175
- sourceKey: "subscriptionPlanId",
176
- });
177
- SubscriptionPlan.hasMany(SubscriptionPromotion, {
178
- foreignKey: "subscription_plan_id",
179
- sourceKey: "id",
180
- });
181
-
182
172
  export default SubscriptionPlan;
@@ -7,12 +7,10 @@ import {
7
7
  fn,
8
8
  NOW,
9
9
  } from "sequelize";
10
- import { ProcessorId } from "./customer-profile";
11
10
 
12
11
  import sequelize from "./pb-sequelize";
13
12
  import PhoneOwner from "./phone-owner";
14
13
  import PhoneUser from "./phone-user";
15
- import SubscriptionPromotion from "./subscription-promotion";
16
14
 
17
15
  // order of InferAttributes & InferCreationAttributes is important.
18
16
  class Subscription extends Model<
@@ -24,7 +22,7 @@ class Subscription extends Model<
24
22
  declare id: CreationOptional<string>;
25
23
  declare userId: string;
26
24
  declare subscriptionPlanId: string;
27
- declare processorId: ProcessorId;
25
+
28
26
  declare paypalSubscriptionId?: string;
29
27
  declare paypalOrderId?: string;
30
28
  declare paypalBillingToken?: string;
@@ -106,11 +104,6 @@ Subscription.init(
106
104
  type: DataTypes.BIGINT,
107
105
  field: "subscription_promotion_id",
108
106
  },
109
- processorId: {
110
- type: DataTypes.STRING,
111
- field: "processor_id",
112
- defaultValue: ProcessorId.HUMBOLDT,
113
- },
114
107
  stale: {
115
108
  type: DataTypes.BOOLEAN,
116
109
  field: "stale",
@@ -175,13 +168,6 @@ Subscription.getByPaypalSubscriptionId = async (
175
168
  });
176
169
  };
177
170
 
178
- Subscription.hasOne(SubscriptionPromotion, {
179
- foreignKey: "id",
180
- sourceKey: "subscriptionPromotionId",
181
- });
182
- SubscriptionPromotion.hasMany(Subscription, {
183
- foreignKey: "subscription_plan_id",
184
- });
185
171
  Subscription.hasOne(PhoneUser, { foreignKey: "id", sourceKey: "userId" });
186
172
  PhoneUser.hasMany(Subscription, { foreignKey: "user_id", sourceKey: "id" });
187
173