1- import { Claims , UserFeatures , UserPlans } from "./ types" ;
1+ import { Claims , UserFeature , UserPlan } from './external/memex-common/ts/subscriptions/ types'
22
33export interface SusbcriptionQuery {
44 'customer_id[is]' : string ,
@@ -50,7 +50,7 @@ export const refreshUserSubscriptionStatus = async (userId: string, {getSubscrip
5050 // next_billing_at will be present when a subscription is active or in trial, and will
5151 // indicate up till when we can trust the the user is subscribed.
5252 const expiry = entry . subscription [ 'current_term_end' ] || entry . subscription [ 'next_billing_at' ]
53- const subPlanId = entry . subscription . plan_id
53+ const subPlanId = entry . subscription . plan_id as UserPlan
5454 // console.log(`Valid subscription for UserId:${userId}, planId:${subPlanId}, expiry:${expiry}`);
5555
5656 const existingSubscription = claims . subscriptions [ subPlanId ] ;
@@ -75,8 +75,8 @@ export const refreshUserSubscriptionStatus = async (userId: string, {getSubscrip
7575const setFeaturesFromSubscriptions = ( claims : Claims ) => {
7676 // For each subscription, add the corresponding feature
7777 for ( const subscriptionKey of Object . keys ( claims . subscriptions ) ) {
78- const subscription = claims . subscriptions [ subscriptionKey ]
79- const subscriptionFeatures = subscriptionToFeatures . get ( subscriptionKey as UserPlans )
78+ const subscription = claims . subscriptions [ subscriptionKey as UserPlan ]
79+ const subscriptionFeatures = subscriptionToFeatures . get ( subscriptionKey as UserPlan )
8080 if ( subscriptionFeatures != null && subscription != null ) {
8181 for ( const feature of subscriptionFeatures ) {
8282 claims . features [ feature ] = { expiry : subscription . expiry }
@@ -85,15 +85,8 @@ const setFeaturesFromSubscriptions = (claims: Claims) => {
8585 }
8686}
8787
88- export const subscriptionToFeatures = new Map < UserPlans , UserFeatures [ ] > ( [
89- [ "free" , [ ] ] ,
90- [ "pro-1-device" , [ 'backup' , 'sync' ] ] ,
91- [ "pro-2-devices" , [ 'backup' , 'sync' ] ] ,
92- [ "pro-3-devices" , [ 'backup' , 'sync' ] ] ,
93- [ "pro-4-devices" , [ 'backup' , 'sync' ] ] ,
94- [ "pro-1-device-yrl" , [ 'backup' , 'sync' ] ] ,
95- [ "pro-2-devices-yrl" , [ 'backup' , 'sync' ] ] ,
96- [ "pro-3-devices-yrl" , [ 'backup' , 'sync' ] ] ,
97- [ "pro-4-devices-yrl" , [ 'backup' , 'sync' ] ] ,
88+ export const subscriptionToFeatures = new Map < UserPlan , UserFeature [ ] > ( [
89+ [ "pro-yearly" , [ 'backup' , 'sync' ] ] ,
90+ [ "pro-monthly" , [ 'backup' , 'sync' ] ] ,
9891] )
9992
0 commit comments