Files
Momento/memento-note/lib/brainstorm-quota-client.ts
Antigravity bd495be965
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 12s
feat: design system overhaul — sidebar, AI chats, settings, brainstorm, color cleanup
- Sidebar: dynamic brand-accent colors, brainstorm section restyled
- AI chat general: popup panel with expand/collapse, hides when contextual AI open
- AI chat contextual: tabs reordered (Actions first), X close button, height fix
- Settings: all tabs restyled, 6 new color presets (sage, terracotta, iron, etc.)
- Global color cleanup: emerald/orange hardcoded → brand-accent dynamic
- Brainstorm page: orange → brand-accent throughout
- PageEntry animation component added to key pages
- Floating AI button: bg-brand-accent instead of hardcoded black
- i18n: all 15 locales updated with new AI/billing keys
- Billing: freemium quota tracking, BYOK, stripe subscription scaffolding
- Admin: integrated into new design
- AGENTS.md + CLAUDE.md project rules added
2026-05-16 12:59:30 +00:00

36 lines
1.0 KiB
TypeScript

/** Client-side parsing for brainstorm host-pays quota responses (Story 3.4). */
export type BrainstormQuotaPayload = {
error: string
feature?: string
upgradeTier?: string
byokConfigured?: boolean
billingOwnerId?: string
triggeredByUserId?: string
isGuestActor?: boolean
}
export class BrainstormQuotaError extends Error {
readonly code = 'QUOTA_EXCEEDED'
readonly isGuestActor: boolean
readonly payload: BrainstormQuotaPayload
constructor(payload: BrainstormQuotaPayload, message: string) {
super(message)
this.name = 'BrainstormQuotaError'
this.isGuestActor = Boolean(payload.isGuestActor)
this.payload = payload
}
}
export function throwIfBrainstormQuota(
res: Response,
data: BrainstormQuotaPayload & { success?: boolean; error?: string },
guestMessage: string,
hostMessage: string,
): void {
if (res.status !== 402 || data?.error !== 'QUOTA_EXCEEDED') return
const message = data.isGuestActor ? guestMessage : hostMessage
throw new BrainstormQuotaError(data, message)
}