@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.
- package/dist/migrations/20230206061925-stale.js +13 -0
- package/dist/migrations/20230206061925-stale.js.map +1 -0
- package/dist/migrations/20230313175015-league-user.js +29 -0
- package/dist/migrations/20230313175015-league-user.js.map +1 -0
- package/dist/migrations/20230330174702-extend-premium-content.js +35 -0
- package/dist/migrations/20230330174702-extend-premium-content.js.map +1 -0
- package/dist/migrations/20230405141245-deprecate-agencies.js +9 -0
- package/dist/migrations/20230405141245-deprecate-agencies.js.map +1 -0
- package/dist/migrations/20230405142440-deprecate-unused-tables.js +23 -0
- package/dist/migrations/20230405142440-deprecate-unused-tables.js.map +1 -0
- package/dist/migrations/20230410144940-deprecate-consent-people.js +9 -0
- package/dist/migrations/20230410144940-deprecate-consent-people.js.map +1 -0
- package/dist/migrations/20230410174328-deprecate-consent-people-table.js +9 -0
- package/dist/migrations/20230410174328-deprecate-consent-people-table.js.map +1 -0
- package/dist/migrations/20230410181920-migrate-credit-payments-to-transactions.js +9 -0
- package/dist/migrations/20230410181920-migrate-credit-payments-to-transactions.js.map +1 -0
- package/dist/migrations/20230410202433-migrate-credit-payments-fields.js +12 -0
- package/dist/migrations/20230410202433-migrate-credit-payments-fields.js.map +1 -0
- package/dist/migrations/20230410211059-deprecate-credit-purchases.js +9 -0
- package/dist/migrations/20230410211059-deprecate-credit-purchases.js.map +1 -0
- package/dist/migrations/20230410212035-deprecate-dashboard_user_permissions.js +10 -0
- package/dist/migrations/20230410212035-deprecate-dashboard_user_permissions.js.map +1 -0
- package/dist/migrations/20230410212324-deprecate-non-breaking-tables.js +34 -0
- package/dist/migrations/20230410212324-deprecate-non-breaking-tables.js.map +1 -0
- package/dist/migrations/20230411054826-create-users-table.js +141 -0
- package/dist/migrations/20230411054826-create-users-table.js.map +1 -0
- package/dist/migrations/20230411202848-migrate_transactions_table.js +24 -0
- package/dist/migrations/20230411202848-migrate_transactions_table.js.map +1 -0
- package/dist/migrations/20230411203543-migrate_league_users.js +9 -0
- package/dist/migrations/20230411203543-migrate_league_users.js.map +1 -0
- package/dist/migrations/20230411205324-migrate_league.js +13 -0
- package/dist/migrations/20230411205324-migrate_league.js.map +1 -0
- package/dist/migrations/20230411221159-migrate_media.js +9 -0
- package/dist/migrations/20230411221159-migrate_media.js.map +1 -0
- package/dist/migrations/20230411221327-migrate_media_asset.js +10 -0
- package/dist/migrations/20230411221327-migrate_media_asset.js.map +1 -0
- package/dist/migrations/20230411221842-migrate_media_asset_fields.js +10 -0
- package/dist/migrations/20230411221842-migrate_media_asset_fields.js.map +1 -0
- package/dist/migrations/20230411222018-migrate_notifications.js +25 -0
- package/dist/migrations/20230411222018-migrate_notifications.js.map +1 -0
- package/dist/scripts/bet-syncing/findGoodBets.js +238 -0
- package/dist/scripts/bet-syncing/findGoodBets.js.map +1 -0
- package/dist/scripts/bet-syncing/pullOdds.js +21 -8
- package/dist/scripts/bet-syncing/pullOdds.js.map +1 -1
- package/dist/scripts/bet-syncing/pullPlayerResults.js +47 -21
- package/dist/scripts/bet-syncing/pullPlayerResults.js.map +1 -1
- package/dist/scripts/bet-syncing/pullPlayers.js +1 -1
- package/dist/scripts/bet-syncing/pullPlayers.js.map +1 -1
- package/dist/scripts/bet-syncing/updateStaleOdds.js +34 -0
- package/dist/scripts/bet-syncing/updateStaleOdds.js.map +1 -0
- package/dist/scripts/cleanupRecurlyPlans.js +12 -5
- package/dist/scripts/cleanupRecurlyPlans.js.map +1 -1
- package/dist/scripts/mapCurrentPaymentsToInvoiceId.js +12 -5
- package/dist/scripts/mapCurrentPaymentsToInvoiceId.js.map +1 -1
- package/dist/src/index.js +1 -18
- package/dist/src/index.js.map +1 -1
- package/dist/typed-model/credit-payment.js +133 -82
- package/dist/typed-model/credit-payment.js.map +1 -1
- package/dist/typed-model/index.js +3 -81
- package/dist/typed-model/index.js.map +1 -1
- package/dist/typed-model/league-user.js +60 -0
- package/dist/typed-model/league-user.js.map +1 -0
- package/dist/typed-model/media-asset.js +0 -9
- package/dist/typed-model/media-asset.js.map +1 -1
- package/dist/typed-model/notification.js +34 -24
- package/dist/typed-model/notification.js.map +1 -1
- package/dist/typed-model/odds.js +5 -0
- package/dist/typed-model/odds.js.map +1 -1
- package/dist/typed-model/pb-sequelize.js +18 -4
- package/dist/typed-model/pb-sequelize.js.map +1 -1
- package/dist/typed-model/subscription-plan-on-premium-content.js +57 -0
- package/dist/typed-model/subscription-plan-on-premium-content.js.map +1 -0
- package/dist/typed-model/subscription-plan.js +0 -9
- package/dist/typed-model/subscription-plan.js.map +1 -1
- package/dist/typed-model/subscription.js +0 -14
- package/dist/typed-model/subscription.js.map +1 -1
- package/dist/typed-model/user.js +194 -0
- package/dist/typed-model/user.js.map +1 -0
- package/package.json +4 -3
- package/src/index.ts +0 -2
- package/typed-model/credit-payment.ts +124 -126
- package/typed-model/index.ts +1 -51
- package/typed-model/{list-member.ts → league-user.ts} +31 -19
- package/typed-model/media-asset.ts +0 -10
- package/typed-model/notification.ts +39 -44
- package/typed-model/pb-sequelize.ts +18 -4
- package/typed-model/subscription-plan.ts +0 -10
- package/typed-model/subscription.ts +1 -15
- package/typed-model/user.ts +248 -0
- package/dist/index.d.ts +0 -3
- package/dist/migrations/20220601151258-custom_name_describing_your_migration.d.ts +0 -6
- package/dist/migrations/20220605225655-create-dashboard-user-permissions.d.ts +0 -6
- package/dist/migrations/20220606001300-update-dashboard-user-permissions.d.ts +0 -6
- package/dist/migrations/20220607091109-add-read-date-for-message.d.ts +0 -6
- package/dist/migrations/20220616225456-add-delete-columns.d.ts +0 -6
- package/dist/migrations/20220709202211-disable-feed.d.ts +0 -6
- package/dist/migrations/20220723215213-limit-promotion-claims.d.ts +0 -6
- package/dist/migrations/20220723220233-num_claims.d.ts +0 -6
- package/dist/migrations/20220723221907-default_false_promos.d.ts +0 -6
- package/dist/migrations/20220724172559-default_zero_claims.d.ts +0 -6
- package/dist/migrations/20220724201419-pinned_post.d.ts +0 -6
- package/dist/migrations/20220729164625-unsend_mass.d.ts +0 -6
- package/dist/migrations/20220823033002-interval-unit.d.ts +0 -6
- package/dist/migrations/20220830193530-processorId.d.ts +0 -6
- package/dist/migrations/20220907121932-add-processor-to-sub.d.ts +0 -6
- package/dist/migrations/20220907212232-add-trans-id.d.ts +0 -6
- package/dist/migrations/20220907220423-big-int-trans.d.ts +0 -6
- package/dist/migrations/20220909161902-add-stale.d.ts +0 -6
- package/dist/migrations/20220922000225-verified-spender.d.ts +0 -6
- package/dist/migrations/20220922212108-verified-spender-2.d.ts +0 -6
- package/dist/migrations/20221013223648-product-subscription-list.d.ts +0 -6
- package/dist/migrations/20221014001037-product-subscription-list.d.ts +0 -6
- package/dist/migrations/20221026055245-update-type.d.ts +0 -6
- package/dist/migrations/20221108060019-recurly-sub.d.ts +0 -6
- package/dist/migrations/20221110170148-rename-recurly-account.d.ts +0 -6
- package/dist/migrations/20221112212510-archive-promo.d.ts +0 -6
- package/dist/migrations/20221117044529-sub-status.d.ts +0 -6
- package/dist/migrations/20221122051433-default-plan.d.ts +0 -6
- package/dist/migrations/20221128034620-invoice-id.d.ts +0 -6
- package/dist/scripts/bet-syncing/pullTeams.d.ts +0 -1
- package/dist/scripts/cleanupRecurlyPlans.d.ts +0 -1
- package/dist/scripts/createDashboardLink.d.ts +0 -1
- package/dist/scripts/createRecurlyPlans.d.ts +0 -1
- package/dist/scripts/deleteMalformedImages.d.ts +0 -1
- package/dist/scripts/fixSaltedPasswords.js +0 -40
- package/dist/scripts/fixSaltedPasswords.js.map +0 -1
- package/dist/scripts/mapCurrentPaymentsToInvoiceId.d.ts +0 -1
- package/dist/scripts/payoutRecurlySubs.d.ts +0 -1
- package/dist/scripts/payoutSubscriptions.d.ts +0 -1
- package/dist/scripts/removeUnreferenceSubs.d.ts +0 -1
- package/dist/scripts/test.d.ts +0 -1
- package/dist/slack/index.d.ts +0 -1
- package/dist/slack/v1/bypassCreator.d.ts +0 -8
- package/dist/slack/v1/cancelSubscription.d.ts +0 -6
- package/dist/slack/v1/changeName.d.ts +0 -8
- package/dist/slack/v1/checkAuthSub.d.ts +0 -6
- package/dist/slack/v1/dashboardLink.d.ts +0 -8
- package/dist/slack/v1/index.d.ts +0 -7
- package/dist/slack/v1/refund.d.ts +0 -6
- package/dist/slack/v1/searchUser.d.ts +0 -6
- package/dist/src/index.d.ts +0 -3
- package/dist/src/pk-client.d.ts +0 -151
- package/dist/src/pk-sub.d.ts +0 -77
- package/dist/src/recurlyInstance.d.ts +0 -3
- package/dist/src/types.d.ts +0 -30
- package/dist/support/index.d.ts +0 -2
- package/dist/support/slack-client.d.ts +0 -3
- package/dist/support/uploadcare.d.ts +0 -14
- package/dist/support/utils.d.ts +0 -2
- package/dist/typed-model/asset-category.d.ts +0 -9
- package/dist/typed-model/asset-constent-person.d.ts +0 -13
- package/dist/typed-model/bet.d.ts +0 -12
- package/dist/typed-model/blocked-ip.d.ts +0 -8
- package/dist/typed-model/category-tag.d.ts +0 -9
- package/dist/typed-model/consent-person.d.ts +0 -13
- package/dist/typed-model/content-category-tag.d.ts +0 -9
- package/dist/typed-model/content-like.d.ts +0 -10
- package/dist/typed-model/credit-payment.d.ts +0 -34
- package/dist/typed-model/credit-payout.d.ts +0 -10
- package/dist/typed-model/credit-purchase.d.ts +0 -10
- package/dist/typed-model/customer-profile.d.ts +0 -17
- package/dist/typed-model/dashboard-user-permissions.d.ts +0 -9
- package/dist/typed-model/dashboard-user.d.ts +0 -20
- package/dist/typed-model/fan-list.d.ts +0 -10
- package/dist/typed-model/fraud.d.ts +0 -9
- package/dist/typed-model/game.d.ts +0 -56
- package/dist/typed-model/index.d.ts +0 -46
- package/dist/typed-model/league.d.ts +0 -9
- package/dist/typed-model/list-member.d.ts +0 -9
- package/dist/typed-model/mass-message.d.ts +0 -11
- package/dist/typed-model/media-asset.d.ts +0 -15
- package/dist/typed-model/media-category.d.ts +0 -10
- package/dist/typed-model/media.d.ts +0 -14
- package/dist/typed-model/message-media.d.ts +0 -9
- package/dist/typed-model/message.d.ts +0 -27
- package/dist/typed-model/notification.d.ts +0 -18
- package/dist/typed-model/odds.d.ts +0 -30
- package/dist/typed-model/parlay.d.ts +0 -8
- package/dist/typed-model/pb-sequelize.d.ts +0 -3
- package/dist/typed-model/phone-chat-participation.d.ts +0 -20
- package/dist/typed-model/phone-chat.d.ts +0 -16
- package/dist/typed-model/phone-owner.d.ts +0 -53
- package/dist/typed-model/phone-user.d.ts +0 -21
- package/dist/typed-model/player.d.ts +0 -22
- package/dist/typed-model/premium-content.d.ts +0 -23
- package/dist/typed-model/purchased-content.d.ts +0 -11
- package/dist/typed-model/recurly-account.d.ts +0 -9
- package/dist/typed-model/short-url.d.ts +0 -12
- package/dist/typed-model/subscription-bundle.d.ts +0 -12
- package/dist/typed-model/subscription-category-tags.d.ts +0 -9
- package/dist/typed-model/subscription-plan.d.ts +0 -27
- package/dist/typed-model/subscription-promotion.d.ts +0 -19
- package/dist/typed-model/subscription.d.ts +0 -26
- package/dist/typed-model/team.d.ts +0 -16
- package/dist/typed-model/twilio-phone.d.ts +0 -17
- package/dist/typed-model/user-follow.d.ts +0 -13
- package/dist/typed-model/verification-code.d.ts +0 -11
- package/dist/webhooks/index.d.ts +0 -1
- package/dist/webhooks/payment/index.d.ts +0 -1
- package/dist/webhooks/payment/refund.d.ts +0 -2
- package/src/pk-client.ts +0 -1650
- package/src/pk-sub.ts +0 -455
- package/typed-model/asset-category.ts +0 -57
- package/typed-model/asset-constent-person.ts +0 -82
- package/typed-model/bet.ts +0 -84
- package/typed-model/blocked-ip.ts +0 -52
- package/typed-model/category-tag.ts +0 -66
- package/typed-model/consent-person.ts +0 -78
- package/typed-model/content-category-tag.ts +0 -79
- package/typed-model/credit-purchase.ts +0 -67
- package/typed-model/customer-profile.ts +0 -71
- package/typed-model/dashboard-user-permissions.ts +0 -51
- package/typed-model/dashboard-user.ts +0 -146
- package/typed-model/fan-list.ts +0 -68
- package/typed-model/fraud.ts +0 -62
- package/typed-model/game.ts +0 -311
- package/typed-model/market.ts +0 -54
- package/typed-model/mass-message.ts +0 -64
- package/typed-model/media-category.ts +0 -70
- package/typed-model/message-media.ts +0 -74
- package/typed-model/message.ts +0 -258
- package/typed-model/odds.ts +0 -232
- package/typed-model/parlay.ts +0 -47
- package/typed-model/phone-chat-participation.ts +0 -166
- package/typed-model/phone-chat.ts +0 -185
- package/typed-model/player-result.ts +0 -93
- package/typed-model/player.ts +0 -118
- package/typed-model/short-url.ts +0 -120
- package/typed-model/sportsbook.ts +0 -48
- package/typed-model/subscription-bundle.ts +0 -80
- package/typed-model/subscription-category-tags.ts +0 -79
- package/typed-model/subscription-promotion.ts +0 -134
- package/typed-model/team.ts +0 -91
- package/typed-model/twilio-phone.ts +0 -149
- package/typed-model/user-follow.ts +0 -141
- 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
|
-
|
251
|
-
|
252
|
-
|
253
|
-
type:
|
254
|
-
|
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
|
-
|
285
|
-
|
286
|
-
|
287
|
-
) => {
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
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
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
) => {
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
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: "
|
676
|
+
sourceKey: "transactionId",
|
679
677
|
constraints: false,
|
680
678
|
onDelete: "NO ACTION",
|
681
679
|
});
|
package/typed-model/index.ts
CHANGED
@@ -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
|
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";
|
@@ -4,27 +4,27 @@ import {
|
|
4
4
|
InferCreationAttributes,
|
5
5
|
CreationOptional,
|
6
6
|
DataTypes,
|
7
|
-
fn,
|
8
7
|
} from "sequelize";
|
8
|
+
import League from "./league";
|
9
9
|
|
10
10
|
import sequelize from "./pb-sequelize";
|
11
11
|
import PhoneUser from "./phone-user";
|
12
12
|
|
13
13
|
// order of InferAttributes & InferCreationAttributes is important.
|
14
|
-
class
|
15
|
-
InferAttributes<
|
16
|
-
InferCreationAttributes<
|
14
|
+
class LeagueUser extends Model<
|
15
|
+
InferAttributes<LeagueUser>,
|
16
|
+
InferCreationAttributes<LeagueUser>
|
17
17
|
> {
|
18
18
|
// 'CreationOptional' is a special type that marks the field as optional
|
19
19
|
// when creating an instance of the model (such as using Model.create()).
|
20
20
|
declare id: CreationOptional<string>;
|
21
|
+
declare leagueId: string;
|
21
22
|
declare userId: string;
|
22
|
-
declare fanListId: string;
|
23
23
|
declare createdAt: CreationOptional<Date>;
|
24
24
|
declare updatedAt: CreationOptional<Date>;
|
25
25
|
}
|
26
26
|
|
27
|
-
|
27
|
+
LeagueUser.init(
|
28
28
|
{
|
29
29
|
id: {
|
30
30
|
type: DataTypes.BIGINT,
|
@@ -32,36 +32,48 @@ ListMember.init(
|
|
32
32
|
allowNull: false,
|
33
33
|
defaultValue: sequelize.fn("next_id"),
|
34
34
|
},
|
35
|
-
|
35
|
+
leagueId: {
|
36
36
|
type: DataTypes.BIGINT,
|
37
|
-
field: "
|
37
|
+
field: "league_id",
|
38
|
+
allowNull: false,
|
38
39
|
},
|
39
|
-
|
40
|
+
userId: {
|
40
41
|
type: DataTypes.BIGINT,
|
41
|
-
field: "
|
42
|
+
field: "user_id",
|
43
|
+
allowNull: false,
|
42
44
|
},
|
43
45
|
createdAt: DataTypes.DATE,
|
44
46
|
updatedAt: DataTypes.DATE,
|
45
47
|
},
|
46
|
-
{
|
48
|
+
{
|
49
|
+
// Other model options go here
|
50
|
+
tableName: "league_users",
|
51
|
+
sequelize,
|
52
|
+
}
|
47
53
|
);
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
LeagueUser.hasOne(League, {
|
56
|
+
foreignKey: "id",
|
57
|
+
sourceKey: "leagueId",
|
58
|
+
onDelete: "NO ACTION",
|
59
|
+
constraints: false,
|
60
|
+
});
|
61
|
+
League.hasMany(LeagueUser, {
|
62
|
+
foreignKey: "leagueId",
|
63
|
+
onDelete: "NO ACTION",
|
64
|
+
constraints: false,
|
65
|
+
});
|
54
66
|
|
55
|
-
|
67
|
+
LeagueUser.hasOne(PhoneUser, {
|
56
68
|
foreignKey: "id",
|
57
69
|
sourceKey: "userId",
|
58
70
|
onDelete: "NO ACTION",
|
59
71
|
constraints: false,
|
60
72
|
});
|
61
|
-
PhoneUser.hasMany(
|
73
|
+
PhoneUser.hasMany(LeagueUser, {
|
62
74
|
foreignKey: "userId",
|
63
75
|
onDelete: "NO ACTION",
|
64
76
|
constraints: false,
|
65
77
|
});
|
66
78
|
|
67
|
-
export default
|
79
|
+
export default LeagueUser;
|
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
32
|
-
declare
|
30
|
+
declare recipientId: string;
|
31
|
+
declare senderId?: string;
|
33
32
|
declare isRead?: boolean;
|
34
33
|
declare type: NotificationType;
|
35
|
-
declare
|
36
|
-
declare
|
37
|
-
declare
|
38
|
-
declare
|
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
|
-
|
54
|
+
recipientId: {
|
57
55
|
type: DataTypes.BIGINT,
|
58
|
-
field: "
|
56
|
+
field: "recipient_id",
|
59
57
|
allowNull: false,
|
60
58
|
},
|
61
|
-
|
59
|
+
senderId: {
|
62
60
|
type: DataTypes.BIGINT,
|
63
|
-
field: "
|
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.
|
74
|
-
},
|
75
|
-
creditPaymentId: {
|
76
|
-
field: "credit_payment_id",
|
77
|
-
type: DataTypes.BIGINT,
|
71
|
+
type: DataTypes.ENUM(...Object.values(NotificationType)),
|
78
72
|
},
|
79
|
-
|
80
|
-
field: "
|
73
|
+
transactionId: {
|
74
|
+
field: "transaction_id",
|
81
75
|
type: DataTypes.BIGINT,
|
82
76
|
},
|
83
|
-
|
84
|
-
field: "
|
77
|
+
purchasedPostId: {
|
78
|
+
field: "purchased_post_id",
|
85
79
|
type: DataTypes.BIGINT,
|
86
80
|
},
|
87
|
-
|
88
|
-
field: "
|
81
|
+
postLikeId: {
|
82
|
+
field: "post_like_id",
|
89
83
|
type: DataTypes.BIGINT,
|
90
84
|
},
|
91
|
-
|
92
|
-
field: "
|
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
|
-
|
112
|
-
|
113
|
-
) => {
|
114
|
-
|
115
|
-
|
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(
|
113
|
+
Notification.hasOne(User, {
|
120
114
|
foreignKey: "id",
|
121
|
-
sourceKey: "
|
115
|
+
sourceKey: "recipientId",
|
122
116
|
constraints: false,
|
123
117
|
});
|
118
|
+
|
124
119
|
Notification.hasOne(ContentLike, {
|
125
120
|
foreignKey: "id",
|
126
|
-
sourceKey: "
|
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
|
-
|
18
|
-
|
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,
|
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;
|