@littlebearapps/platform-admin-sdk 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +2 -5
  2. package/dist/templates.d.ts +1 -1
  3. package/dist/templates.js +121 -3
  4. package/package.json +1 -1
  5. package/templates/full/dashboard/src/components/notifications/NotificationDropdown.tsx +130 -0
  6. package/templates/full/dashboard/src/components/notifications/NotificationItem.tsx +264 -0
  7. package/templates/full/dashboard/src/components/patterns/PatternInfoButton.tsx +60 -0
  8. package/templates/full/dashboard/src/components/reports/FeatureUsageReport.tsx +339 -0
  9. package/templates/full/dashboard/src/components/search/SearchResultGroup.tsx +46 -0
  10. package/templates/full/dashboard/src/components/search/SearchResultItem.tsx +212 -0
  11. package/templates/full/dashboard/src/pages/api/patterns/[id]/approve.ts +49 -0
  12. package/templates/full/dashboard/src/pages/api/patterns/[id]/reject.ts +50 -0
  13. package/templates/full/dashboard/src/pages/api/reports/digests/stats.ts +38 -0
  14. package/templates/full/dashboard/src/pages/api/reports/digests.ts +39 -0
  15. package/templates/full/dashboard/src/pages/api/search/reindex/[type].ts +56 -0
  16. package/templates/full/dashboard/src/pages/api/test-reports/[id].ts +102 -0
  17. package/templates/full/dashboard/src/pages/feedback.astro +365 -0
  18. package/templates/full/dashboard/src/pages/kiosk.astro +206 -0
  19. package/templates/full/dashboard/src/pages/map.astro +561 -0
  20. package/templates/full/dashboard/src/pages/revenue.astro +72 -0
  21. package/templates/full/dashboard/src/pages/tests.astro +431 -0
  22. package/templates/full/scripts/ops/audit-cost-anomaly.ts +430 -0
  23. package/templates/full/scripts/ops/verify-account-total.ts +256 -0
  24. package/templates/full/tests/integration/feedback-schema.test.ts +361 -0
  25. package/templates/full/tests/integration/r2-archive.test.ts +108 -0
  26. package/templates/shared/.github/workflows/dependabot-automerge.yml +41 -0
  27. package/templates/shared/.github/workflows/validate-controls.yml +27 -0
  28. package/templates/shared/dashboard/src/components/Breadcrumbs.astro +101 -0
  29. package/templates/shared/dashboard/src/components/EmptyState.astro +46 -0
  30. package/templates/shared/dashboard/src/components/ErrorBoundary.astro +79 -0
  31. package/templates/shared/dashboard/src/components/LoadingSkeleton.astro +105 -0
  32. package/templates/shared/dashboard/src/components/PageShell.astro +72 -0
  33. package/templates/shared/dashboard/src/components/SkipLinks.astro +22 -0
  34. package/templates/shared/dashboard/src/components/Toast.astro +170 -0
  35. package/templates/shared/dashboard/src/components/ToastContainer.astro +156 -0
  36. package/templates/shared/dashboard/src/components/costs/ProviderCostsGrid.tsx +401 -0
  37. package/templates/shared/dashboard/src/components/costs/index.ts +4 -0
  38. package/templates/shared/dashboard/src/components/overview/AlertBanner.tsx +94 -0
  39. package/templates/shared/dashboard/src/components/overview/index.ts +9 -0
  40. package/templates/shared/dashboard/src/components/resources/CostChart.tsx +170 -0
  41. package/templates/shared/dashboard/src/components/resources/ProviderCard.tsx +272 -0
  42. package/templates/shared/dashboard/src/components/resources/ProviderDetail.tsx +293 -0
  43. package/templates/shared/dashboard/src/components/settings/SettingsCard.astro +102 -0
  44. package/templates/shared/dashboard/src/components/usage/AllowanceGauge.astro +170 -0
  45. package/templates/shared/dashboard/src/components/usage/AnomalyAlerts.astro +633 -0
  46. package/templates/shared/dashboard/src/components/usage/BillingCycleCountdown.astro +192 -0
  47. package/templates/shared/dashboard/src/components/usage/BurnRateHero.astro +539 -0
  48. package/templates/shared/dashboard/src/components/usage/CircuitBreakerEventLog.astro +542 -0
  49. package/templates/shared/dashboard/src/components/usage/CircuitBreakerPanel.tsx +292 -0
  50. package/templates/shared/dashboard/src/components/usage/CircuitBreakerStatus.astro +669 -0
  51. package/templates/shared/dashboard/src/components/usage/CompactThresholdBanner.astro +531 -0
  52. package/templates/shared/dashboard/src/components/usage/ComparisonModeSelector.astro +651 -0
  53. package/templates/shared/dashboard/src/components/usage/CostBreakdownChart.astro +381 -0
  54. package/templates/shared/dashboard/src/components/usage/CostBreakdownTable.astro +210 -0
  55. package/templates/shared/dashboard/src/components/usage/CostDataTable.astro +0 -0
  56. package/templates/shared/dashboard/src/components/usage/CostDonutChart.astro +311 -0
  57. package/templates/shared/dashboard/src/components/usage/DailyCostChart.astro +632 -0
  58. package/templates/shared/dashboard/src/components/usage/ExportButton.astro +114 -0
  59. package/templates/shared/dashboard/src/components/usage/FeatureBudgetsTable.astro +872 -0
  60. package/templates/shared/dashboard/src/components/usage/FilterBar.astro +190 -0
  61. package/templates/shared/dashboard/src/components/usage/FilterToggles.astro +175 -0
  62. package/templates/shared/dashboard/src/components/usage/GitHubUsageCard.astro +537 -0
  63. package/templates/shared/dashboard/src/components/usage/OverageCostCard.astro +212 -0
  64. package/templates/shared/dashboard/src/components/usage/PlanUtilizationCard.astro +193 -0
  65. package/templates/shared/dashboard/src/components/usage/ProjectCard.astro +640 -0
  66. package/templates/shared/dashboard/src/components/usage/ProjectCardsGrid.astro +272 -0
  67. package/templates/shared/dashboard/src/components/usage/ResourceSearch.astro +279 -0
  68. package/templates/shared/dashboard/src/components/usage/ServiceUtilizationList.astro +604 -0
  69. package/templates/shared/dashboard/src/components/usage/SparklineCard.astro +399 -0
  70. package/templates/shared/dashboard/src/components/usage/StatsHero.astro +600 -0
  71. package/templates/shared/dashboard/src/components/usage/TableFilters.astro +1033 -0
  72. package/templates/shared/dashboard/src/components/usage/ThresholdAlert.astro +271 -0
  73. package/templates/shared/dashboard/src/components/usage/ThresholdSettings.astro +618 -0
  74. package/templates/shared/dashboard/src/components/usage/TopSpenderCard.astro +170 -0
  75. package/templates/shared/dashboard/src/components/usage/UnifiedResourceTable.astro +1737 -0
  76. package/templates/shared/dashboard/src/components/usage/UsageCard.astro +135 -0
  77. package/templates/shared/dashboard/src/components/usage/UsageHealthBanner.astro +387 -0
  78. package/templates/shared/dashboard/src/components/usage/UtilizationBar.astro +159 -0
  79. package/templates/shared/dashboard/src/components/usage/WorkersBreakdownTable.astro +659 -0
  80. package/templates/shared/dashboard/src/components/usage/daily/CostChart.astro +461 -0
  81. package/templates/shared/dashboard/src/components/usage/daily/CostTable.astro +946 -0
  82. package/templates/shared/dashboard/src/components/usage/daily/DailyOverview.astro +1079 -0
  83. package/templates/shared/dashboard/src/components/usage/design-tokens.ts +187 -0
  84. package/templates/shared/dashboard/src/components/usage/filters/InlineDateRange.astro +285 -0
  85. package/templates/shared/dashboard/src/components/usage/filters/PeriodButtons.astro +157 -0
  86. package/templates/shared/dashboard/src/components/usage/filters/ProjectSelect.astro +284 -0
  87. package/templates/shared/dashboard/src/components/usage/scripts/ai-tab-controller.ts +419 -0
  88. package/templates/shared/dashboard/src/components/usage/scripts/constants.ts +60 -0
  89. package/templates/shared/dashboard/src/components/usage/scripts/formatters.ts +62 -0
  90. package/templates/shared/dashboard/src/components/usage/scripts/overview-controller.ts +1633 -0
  91. package/templates/shared/dashboard/src/components/usage/scripts/resource-table-builder.ts +294 -0
  92. package/templates/shared/dashboard/src/components/usage/scripts/tabs-filters-controller.ts +464 -0
  93. package/templates/shared/dashboard/src/components/usage/state/index.ts +55 -0
  94. package/templates/shared/dashboard/src/components/usage/state/usageActions.ts +439 -0
  95. package/templates/shared/dashboard/src/components/usage/state/usageStore.ts +376 -0
  96. package/templates/shared/dashboard/src/components/usage/types.ts +283 -0
  97. package/templates/shared/dashboard/src/components/usage/usage-colors.ts +292 -0
  98. package/templates/shared/dashboard/src/pages/api/usage/ai-models.ts +235 -0
  99. package/templates/shared/dashboard/src/pages/api/usage/billing-context.ts +296 -0
  100. package/templates/shared/scripts/test-telemetry-flow.ts +464 -0
  101. package/templates/shared/tests/e2e/usage-export.test.ts +784 -0
  102. package/templates/shared/tests/e2e/usage-mobile.test.ts +531 -0
  103. package/templates/standard/dashboard/src/components/errors/PriorityBadge.astro +27 -0
  104. package/templates/standard/dashboard/src/components/infrastructure/HealthchecksStatus.tsx +293 -0
  105. package/templates/standard/dashboard/src/components/infrastructure/InfrastructureTabs.tsx +268 -0
  106. package/templates/standard/dashboard/src/pages/analytics.astro +64 -0
  107. package/templates/standard/dashboard/src/pages/api/infrastructure/alerts.ts +85 -0
  108. package/templates/standard/dashboard/src/pages/api/infrastructure/healthchecks/[id]/flips.ts +110 -0
  109. package/templates/standard/dashboard/src/pages/api/infrastructure/healthchecks.ts +101 -0
  110. package/templates/standard/dashboard/src/pages/api/infrastructure/uptime/[id]/response-times.ts +121 -0
  111. package/templates/standard/dashboard/src/pages/api/infrastructure/uptime.ts +89 -0
  112. package/templates/standard/dashboard/src/pages/api/test/service-auth.ts +178 -0
  113. package/templates/standard/tests/integration/connectors.test.ts +241 -0
  114. package/templates/standard/tests/integration/github-monitor.test.ts +143 -0
  115. package/templates/standard/tests/integration/ingestion.test.ts +211 -0
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Usage Dashboard Constants
3
+ *
4
+ * Static label mappings and configuration.
5
+ * Extracted from index.astro for task-22.5 (slim to <300 lines)
6
+ */
7
+
8
+ // Period display labels
9
+ export const PERIOD_LABELS: Record<string, string> = {
10
+ '24h': 'Last 24 Hours',
11
+ '7d': 'Last 7 Days',
12
+ '30d': 'Last 30 Days',
13
+ custom: 'Custom Range',
14
+ };
15
+
16
+ // Project display labels
17
+ export const PROJECT_LABELS: Record<string, string> = {
18
+ all: 'All Projects',
19
+ 'brand-copilot': 'Brand Copilot',
20
+ scout: 'Scout',
21
+ platform: 'Platform',
22
+ };
23
+
24
+ // Valid period values
25
+ export const VALID_PERIODS = ['24h', '7d', '30d', 'custom'] as const;
26
+ export type Period = (typeof VALID_PERIODS)[number];
27
+
28
+ // Valid project values
29
+ export const VALID_PROJECTS = ['all', 'brand-copilot', 'scout', 'platform'] as const;
30
+ export type Project = (typeof VALID_PROJECTS)[number];
31
+
32
+ // Valid compare mode values
33
+ export const VALID_COMPARE_MODES = ['none', 'lastMonth', 'custom'] as const;
34
+ export type CompareMode = (typeof VALID_COMPARE_MODES)[number];
35
+
36
+ // Get SSR config from data attributes (set by Astro template)
37
+ export function getSSRConfig(): { period: string; project: string; compare: CompareMode } {
38
+ const configEl = document.getElementById('usage-ssr-config');
39
+ if (!configEl) {
40
+ return { period: '30d', project: 'all', compare: 'none' };
41
+ }
42
+ const compareValue = configEl.dataset.compare || 'none';
43
+ return {
44
+ period: configEl.dataset.period || '30d',
45
+ project: configEl.dataset.project || 'all',
46
+ compare: (VALID_COMPARE_MODES.includes(compareValue as CompareMode)
47
+ ? compareValue
48
+ : 'none') as CompareMode,
49
+ };
50
+ }
51
+
52
+ // Get period label
53
+ export function getPeriodLabel(period: string): string {
54
+ return PERIOD_LABELS[period] || 'Last 30 Days';
55
+ }
56
+
57
+ // Get project label
58
+ export function getProjectLabel(project: string): string {
59
+ return PROJECT_LABELS[project] || 'All Projects';
60
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Usage Dashboard - Format Utilities
3
+ *
4
+ * Extracted from index.astro for task-22.5 (slim to <300 lines)
5
+ */
6
+
7
+ /**
8
+ * Format a number with K/M/B suffixes
9
+ */
10
+ export function formatNumber(num: number | undefined | null): string {
11
+ if (num === undefined || num === null || isNaN(num)) return '0';
12
+ if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(2)}B`;
13
+ if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(2)}M`;
14
+ if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
15
+ return num.toLocaleString();
16
+ }
17
+
18
+ /**
19
+ * Format bytes to human-readable string using decimal (SI) units.
20
+ *
21
+ * IMPORTANT: Uses decimal (SI) units because Cloudflare bills in decimal GB:
22
+ * - 1 GB = 1,000,000,000 bytes (decimal/SI - used for billing)
23
+ * - 1 GiB = 1,073,741,824 bytes (binary - NOT used by Cloudflare)
24
+ *
25
+ * This ensures displayed values match Cloudflare billing/CSV exports.
26
+ */
27
+ export function formatBytes(bytes: number): string {
28
+ if (bytes >= 1_000_000_000) return `${(bytes / 1_000_000_000).toFixed(2)} GB`;
29
+ if (bytes >= 1_000_000) return `${(bytes / 1_000_000).toFixed(2)} MB`;
30
+ if (bytes >= 1_000) return `${(bytes / 1_000).toFixed(2)} KB`;
31
+ return `${bytes} B`;
32
+ }
33
+
34
+ /**
35
+ * Format currency value
36
+ */
37
+ export function formatCurrency(amount: number, decimals = 2): string {
38
+ return '$' + amount.toFixed(decimals);
39
+ }
40
+
41
+ /**
42
+ * Format percentage
43
+ */
44
+ export function formatPercent(value: number): string {
45
+ return value.toFixed(1) + '%';
46
+ }
47
+
48
+ /**
49
+ * Format AI-specific numbers with appropriate precision
50
+ */
51
+ export function formatAINumber(num: number): string {
52
+ if (num >= 1_000_000) return (num / 1_000_000).toFixed(2) + 'M';
53
+ if (num >= 1_000) return (num / 1_000).toFixed(1) + 'K';
54
+ return num.toLocaleString();
55
+ }
56
+
57
+ /**
58
+ * Format AI currency (higher precision)
59
+ */
60
+ export function formatAICurrency(amount: number): string {
61
+ return '$' + amount.toFixed(4);
62
+ }