Publication IA: - 4 templates (magazine, brief, essay, simple) avec CSS riche - Rewrite IA (article/exercises/tutorial/reference/mixed) - Modération avec timeout 12s + fallback safe - Quotas publish_enhance par tier (basic=2, pro=15, business=100) - Détection contenu stale (hash) - Migration DB publishedContent/publishedTemplate/publishedSourceHash Fixes: - cheerio v1.2: Element -> AnyNode (domhandler), decodeEntities cast - _isShared ajouté au type Note (champ virtuel serveur) - callout colors PDF export: extraction fonction pure testable - admin/published: guard note.userId null - Cmd+S fonctionne en mode dialog (pas seulement fullPage) i18n: - 23 clés publish* traduites dans les 15 locales - Extension Web Clipper: 13 locales mise à jour Tests: - callout-colors.test.ts (6 tests) - note-visible-in-view.test.ts (5 tests) - entitlements.test.ts + byok-entitlements.test.ts: mock usageLog + unstubAllEnvs - 199/199 tests passent Tracker: user-stories.md sync avec sprint-status.yaml
38 lines
974 B
TypeScript
38 lines
974 B
TypeScript
export const VALID_FEATURES = [
|
|
'semantic_search',
|
|
'auto_tag',
|
|
'auto_title',
|
|
'reformulate',
|
|
'chat',
|
|
'brainstorm_create',
|
|
'brainstorm_expand',
|
|
'brainstorm_enrich',
|
|
'suggest_charts',
|
|
'slide_generate',
|
|
'excalidraw_generate',
|
|
'ai_flashcard',
|
|
'voice_transcribe',
|
|
'publish_enhance',
|
|
] 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);
|
|
}
|