(userId: string)
| 592 | * Check usage status with warning thresholds |
| 593 | */ |
| 594 | export async function checkUsageStatus(userId: string): Promise<{ |
| 595 | status: 'ok' | 'warning' | 'exceeded' |
| 596 | usageData: UsageData |
| 597 | }> { |
| 598 | try { |
| 599 | const usageData = await getUserUsageData(userId) |
| 600 | |
| 601 | let status: 'ok' | 'warning' | 'exceeded' = 'ok' |
| 602 | if (usageData.isExceeded) { |
| 603 | status = 'exceeded' |
| 604 | } else if (usageData.isWarning) { |
| 605 | status = 'warning' |
| 606 | } |
| 607 | |
| 608 | return { |
| 609 | status, |
| 610 | usageData, |
| 611 | } |
| 612 | } catch (error) { |
| 613 | logger.error('Failed to check usage status', { userId, error }) |
| 614 | throw error |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Sync usage limits based on subscription changes |
no test coverage detected