chatbot-template/lib/subscription/config.ts

28 lines
630 B
TypeScript
Raw Normal View History

export type Tier = "free" | "pro";
export type LimitKey = "chat_message" | "tool_call";
export type TierLimits = Record<LimitKey, number>;
export const LIMITS: Record<Tier, TierLimits> = {
free: {
chat_message: 10,
tool_call: 5,
},
pro: {
chat_message: 1000,
tool_call: 500,
},
};
export const TIER_LABELS: Record<Tier, string> = {
free: "Free",
pro: "Pro",
};
export function todayPeriodKey(now = new Date()): string {
const y = now.getUTCFullYear();
const m = String(now.getUTCMonth() + 1).padStart(2, "0");
const d = String(now.getUTCDate()).padStart(2, "0");
return `${y}-${m}-${d}`;
}