1. Script warning in layout.tsx - Use Next.js Script component instead of plain <script> 2. QUOTA_EXCEEDED bug for chart suggestions - Add 'suggest_charts' to VALID_FEATURES - Add 'suggest_charts' to TIER_LIMITS for all tiers - Fix route to use 'suggest_charts' instead of invalid 'ai' feature This fixes the issue where users with valid credit were getting QUOTA_EXCEEDED errors because 'ai' was not a valid feature name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
868 B
TypeScript
33 lines
868 B
TypeScript
export const VALID_FEATURES = [
|
|
'semantic_search',
|
|
'auto_tag',
|
|
'auto_title',
|
|
'reformulate',
|
|
'chat',
|
|
'brainstorm_create',
|
|
'brainstorm_expand',
|
|
'brainstorm_enrich',
|
|
'suggest_charts',
|
|
] as const;
|
|
|
|
export type FeatureName = (typeof VALID_FEATURES)[number];
|
|
|
|
export function getCurrentPeriodKey(): string {
|
|
return new Date().toISOString().slice(0, 7);
|
|
}
|
|
|
|
export function getRedisKey(userId: string, feature: string): string {
|
|
const period = getCurrentPeriodKey();
|
|
return `usage:${userId}:${feature}:${period}`;
|
|
}
|
|
|
|
export function parseRedisInt(value: string | number | null | undefined): number {
|
|
if (value == null) return 0;
|
|
const n = Number(value);
|
|
return Number.isFinite(n) ? Math.round(n) : 1;
|
|
}
|
|
|
|
export function isValidFeature(feature: string): feature is FeatureName {
|
|
return (VALID_FEATURES as readonly string[]).includes(feature);
|
|
}
|