Skip to content

Commit

Permalink
feat(utils): add PLAN_CONFIG
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdev committed Sep 22, 2024
1 parent 0575612 commit 34c562e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
57 changes: 57 additions & 0 deletions packages/utilities/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export enum UserEntitlement {
Saver = 'saver',
Growth = 'growth',
Wealth = 'wealth',
}

export type PlanConfig = {
maxTransactions: number
maxBudgets: number
maxWallets: number
canCreateCategories: boolean
maxAiTransactionPerDay: number
maxJoinableBudgets: number
maxOwnedBudgets: number
transactionRetentionDays: number
}

/** Follows [[RFC] Monetization #132](https://github.com/get6pm/6pm/issues/132). */
export const PLAN_CONFIG: Record<UserEntitlement, PlanConfig> = {
saver: {
maxTransactions: Infinity,
maxBudgets: 3,
maxWallets: 3,
canCreateCategories: false,
maxAiTransactionPerDay: 2,
maxJoinableBudgets: Infinity,
maxOwnedBudgets: 1,
transactionRetentionDays: 60,
},
growth: {
maxTransactions: Infinity,
maxBudgets: 6,
maxWallets: 6,
canCreateCategories: true,
maxAiTransactionPerDay: 10,
maxJoinableBudgets: Infinity,
maxOwnedBudgets: 5,
transactionRetentionDays: 180,
},
wealth: {
maxTransactions: Infinity,
maxBudgets: Infinity,
maxWallets: Infinity,
canCreateCategories: true,
maxAiTransactionPerDay: 25,
maxJoinableBudgets: Infinity,
maxOwnedBudgets: Infinity,
transactionRetentionDays: Infinity,
},
}

export function getPlanConfig<
P extends UserEntitlement,
K extends keyof PlanConfig,
>(plan: P, key: K): PlanConfig[K] | null {
return PLAN_CONFIG[plan][key] ?? null
}
1 change: 1 addition & 0 deletions packages/utilities/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './date/dayjs'
export * from './date/period'
export * from './transactions'
export * from './config'

0 comments on commit 34c562e

Please sign in to comment.