diff --git a/packages/utilities/src/config.ts b/packages/utilities/src/config.ts new file mode 100644 index 0000000..27a8e57 --- /dev/null +++ b/packages/utilities/src/config.ts @@ -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 = { + 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 +} diff --git a/packages/utilities/src/index.ts b/packages/utilities/src/index.ts index 7ad1509..35c04e1 100644 --- a/packages/utilities/src/index.ts +++ b/packages/utilities/src/index.ts @@ -1,3 +1,4 @@ export * from './date/dayjs' export * from './date/period' export * from './transactions' +export * from './config'