Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): add PLAN_CONFIG #361

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Loading