@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.
- package/README.md +2 -5
- package/dist/templates.d.ts +1 -1
- package/dist/templates.js +121 -3
- package/package.json +1 -1
- package/templates/full/dashboard/src/components/notifications/NotificationDropdown.tsx +130 -0
- package/templates/full/dashboard/src/components/notifications/NotificationItem.tsx +264 -0
- package/templates/full/dashboard/src/components/patterns/PatternInfoButton.tsx +60 -0
- package/templates/full/dashboard/src/components/reports/FeatureUsageReport.tsx +339 -0
- package/templates/full/dashboard/src/components/search/SearchResultGroup.tsx +46 -0
- package/templates/full/dashboard/src/components/search/SearchResultItem.tsx +212 -0
- package/templates/full/dashboard/src/pages/api/patterns/[id]/approve.ts +49 -0
- package/templates/full/dashboard/src/pages/api/patterns/[id]/reject.ts +50 -0
- package/templates/full/dashboard/src/pages/api/reports/digests/stats.ts +38 -0
- package/templates/full/dashboard/src/pages/api/reports/digests.ts +39 -0
- package/templates/full/dashboard/src/pages/api/search/reindex/[type].ts +56 -0
- package/templates/full/dashboard/src/pages/api/test-reports/[id].ts +102 -0
- package/templates/full/dashboard/src/pages/feedback.astro +365 -0
- package/templates/full/dashboard/src/pages/kiosk.astro +206 -0
- package/templates/full/dashboard/src/pages/map.astro +561 -0
- package/templates/full/dashboard/src/pages/revenue.astro +72 -0
- package/templates/full/dashboard/src/pages/tests.astro +431 -0
- package/templates/full/scripts/ops/audit-cost-anomaly.ts +430 -0
- package/templates/full/scripts/ops/verify-account-total.ts +256 -0
- package/templates/full/tests/integration/feedback-schema.test.ts +361 -0
- package/templates/full/tests/integration/r2-archive.test.ts +108 -0
- package/templates/shared/.github/workflows/dependabot-automerge.yml +41 -0
- package/templates/shared/.github/workflows/validate-controls.yml +27 -0
- package/templates/shared/dashboard/src/components/Breadcrumbs.astro +101 -0
- package/templates/shared/dashboard/src/components/EmptyState.astro +46 -0
- package/templates/shared/dashboard/src/components/ErrorBoundary.astro +79 -0
- package/templates/shared/dashboard/src/components/LoadingSkeleton.astro +105 -0
- package/templates/shared/dashboard/src/components/PageShell.astro +72 -0
- package/templates/shared/dashboard/src/components/SkipLinks.astro +22 -0
- package/templates/shared/dashboard/src/components/Toast.astro +170 -0
- package/templates/shared/dashboard/src/components/ToastContainer.astro +156 -0
- package/templates/shared/dashboard/src/components/costs/ProviderCostsGrid.tsx +401 -0
- package/templates/shared/dashboard/src/components/costs/index.ts +4 -0
- package/templates/shared/dashboard/src/components/overview/AlertBanner.tsx +94 -0
- package/templates/shared/dashboard/src/components/overview/index.ts +9 -0
- package/templates/shared/dashboard/src/components/resources/CostChart.tsx +170 -0
- package/templates/shared/dashboard/src/components/resources/ProviderCard.tsx +272 -0
- package/templates/shared/dashboard/src/components/resources/ProviderDetail.tsx +293 -0
- package/templates/shared/dashboard/src/components/settings/SettingsCard.astro +102 -0
- package/templates/shared/dashboard/src/components/usage/AllowanceGauge.astro +170 -0
- package/templates/shared/dashboard/src/components/usage/AnomalyAlerts.astro +633 -0
- package/templates/shared/dashboard/src/components/usage/BillingCycleCountdown.astro +192 -0
- package/templates/shared/dashboard/src/components/usage/BurnRateHero.astro +539 -0
- package/templates/shared/dashboard/src/components/usage/CircuitBreakerEventLog.astro +542 -0
- package/templates/shared/dashboard/src/components/usage/CircuitBreakerPanel.tsx +292 -0
- package/templates/shared/dashboard/src/components/usage/CircuitBreakerStatus.astro +669 -0
- package/templates/shared/dashboard/src/components/usage/CompactThresholdBanner.astro +531 -0
- package/templates/shared/dashboard/src/components/usage/ComparisonModeSelector.astro +651 -0
- package/templates/shared/dashboard/src/components/usage/CostBreakdownChart.astro +381 -0
- package/templates/shared/dashboard/src/components/usage/CostBreakdownTable.astro +210 -0
- package/templates/shared/dashboard/src/components/usage/CostDataTable.astro +0 -0
- package/templates/shared/dashboard/src/components/usage/CostDonutChart.astro +311 -0
- package/templates/shared/dashboard/src/components/usage/DailyCostChart.astro +632 -0
- package/templates/shared/dashboard/src/components/usage/ExportButton.astro +114 -0
- package/templates/shared/dashboard/src/components/usage/FeatureBudgetsTable.astro +872 -0
- package/templates/shared/dashboard/src/components/usage/FilterBar.astro +190 -0
- package/templates/shared/dashboard/src/components/usage/FilterToggles.astro +175 -0
- package/templates/shared/dashboard/src/components/usage/GitHubUsageCard.astro +537 -0
- package/templates/shared/dashboard/src/components/usage/OverageCostCard.astro +212 -0
- package/templates/shared/dashboard/src/components/usage/PlanUtilizationCard.astro +193 -0
- package/templates/shared/dashboard/src/components/usage/ProjectCard.astro +640 -0
- package/templates/shared/dashboard/src/components/usage/ProjectCardsGrid.astro +272 -0
- package/templates/shared/dashboard/src/components/usage/ResourceSearch.astro +279 -0
- package/templates/shared/dashboard/src/components/usage/ServiceUtilizationList.astro +604 -0
- package/templates/shared/dashboard/src/components/usage/SparklineCard.astro +399 -0
- package/templates/shared/dashboard/src/components/usage/StatsHero.astro +600 -0
- package/templates/shared/dashboard/src/components/usage/TableFilters.astro +1033 -0
- package/templates/shared/dashboard/src/components/usage/ThresholdAlert.astro +271 -0
- package/templates/shared/dashboard/src/components/usage/ThresholdSettings.astro +618 -0
- package/templates/shared/dashboard/src/components/usage/TopSpenderCard.astro +170 -0
- package/templates/shared/dashboard/src/components/usage/UnifiedResourceTable.astro +1737 -0
- package/templates/shared/dashboard/src/components/usage/UsageCard.astro +135 -0
- package/templates/shared/dashboard/src/components/usage/UsageHealthBanner.astro +387 -0
- package/templates/shared/dashboard/src/components/usage/UtilizationBar.astro +159 -0
- package/templates/shared/dashboard/src/components/usage/WorkersBreakdownTable.astro +659 -0
- package/templates/shared/dashboard/src/components/usage/daily/CostChart.astro +461 -0
- package/templates/shared/dashboard/src/components/usage/daily/CostTable.astro +946 -0
- package/templates/shared/dashboard/src/components/usage/daily/DailyOverview.astro +1079 -0
- package/templates/shared/dashboard/src/components/usage/design-tokens.ts +187 -0
- package/templates/shared/dashboard/src/components/usage/filters/InlineDateRange.astro +285 -0
- package/templates/shared/dashboard/src/components/usage/filters/PeriodButtons.astro +157 -0
- package/templates/shared/dashboard/src/components/usage/filters/ProjectSelect.astro +284 -0
- package/templates/shared/dashboard/src/components/usage/scripts/ai-tab-controller.ts +419 -0
- package/templates/shared/dashboard/src/components/usage/scripts/constants.ts +60 -0
- package/templates/shared/dashboard/src/components/usage/scripts/formatters.ts +62 -0
- package/templates/shared/dashboard/src/components/usage/scripts/overview-controller.ts +1633 -0
- package/templates/shared/dashboard/src/components/usage/scripts/resource-table-builder.ts +294 -0
- package/templates/shared/dashboard/src/components/usage/scripts/tabs-filters-controller.ts +464 -0
- package/templates/shared/dashboard/src/components/usage/state/index.ts +55 -0
- package/templates/shared/dashboard/src/components/usage/state/usageActions.ts +439 -0
- package/templates/shared/dashboard/src/components/usage/state/usageStore.ts +376 -0
- package/templates/shared/dashboard/src/components/usage/types.ts +283 -0
- package/templates/shared/dashboard/src/components/usage/usage-colors.ts +292 -0
- package/templates/shared/dashboard/src/pages/api/usage/ai-models.ts +235 -0
- package/templates/shared/dashboard/src/pages/api/usage/billing-context.ts +296 -0
- package/templates/shared/scripts/test-telemetry-flow.ts +464 -0
- package/templates/shared/tests/e2e/usage-export.test.ts +784 -0
- package/templates/shared/tests/e2e/usage-mobile.test.ts +531 -0
- package/templates/standard/dashboard/src/components/errors/PriorityBadge.astro +27 -0
- package/templates/standard/dashboard/src/components/infrastructure/HealthchecksStatus.tsx +293 -0
- package/templates/standard/dashboard/src/components/infrastructure/InfrastructureTabs.tsx +268 -0
- package/templates/standard/dashboard/src/pages/analytics.astro +64 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/alerts.ts +85 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/healthchecks/[id]/flips.ts +110 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/healthchecks.ts +101 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/uptime/[id]/response-times.ts +121 -0
- package/templates/standard/dashboard/src/pages/api/infrastructure/uptime.ts +89 -0
- package/templates/standard/dashboard/src/pages/api/test/service-auth.ts +178 -0
- package/templates/standard/tests/integration/connectors.test.ts +241 -0
- package/templates/standard/tests/integration/github-monitor.test.ts +143 -0
- package/templates/standard/tests/integration/ingestion.test.ts +211 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* AllowanceGauge - Circular gauge showing allowance utilisation
|
|
4
|
+
*
|
|
5
|
+
* Displays "X% of Free Tier Used" with a circular progress gauge.
|
|
6
|
+
* Supports prorated allowances for sub-monthly query periods.
|
|
7
|
+
*
|
|
8
|
+
* @created 2026-01-22
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
/** Resource name (e.g., "Workers Requests", "D1 Reads") */
|
|
13
|
+
resourceName?: string;
|
|
14
|
+
/** ID for JavaScript updates */
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { resourceName = 'Allowance', id = 'allowance-gauge' } = Astro.props;
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
id={id}
|
|
23
|
+
class="bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-4 shadow-sm"
|
|
24
|
+
>
|
|
25
|
+
<!-- Header -->
|
|
26
|
+
<div class="flex items-center justify-between mb-3">
|
|
27
|
+
<h3 class="text-sm font-medium text-gray-500 dark:text-gray-400">{resourceName}</h3>
|
|
28
|
+
<span
|
|
29
|
+
id={`${id}-badge`}
|
|
30
|
+
class="px-2 py-0.5 text-xs font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400"
|
|
31
|
+
>
|
|
32
|
+
Within Limit
|
|
33
|
+
</span>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<!-- Circular Gauge -->
|
|
37
|
+
<div class="flex items-center justify-center mb-3">
|
|
38
|
+
<div class="relative w-28 h-28">
|
|
39
|
+
<!-- Background circle -->
|
|
40
|
+
<svg class="w-28 h-28 transform -rotate-90" viewBox="0 0 120 120">
|
|
41
|
+
<circle
|
|
42
|
+
cx="60"
|
|
43
|
+
cy="60"
|
|
44
|
+
r="50"
|
|
45
|
+
stroke="currentColor"
|
|
46
|
+
stroke-width="10"
|
|
47
|
+
fill="none"
|
|
48
|
+
class="text-gray-200 dark:text-gray-700"></circle>
|
|
49
|
+
<!-- Progress circle -->
|
|
50
|
+
<circle
|
|
51
|
+
id={`${id}-progress`}
|
|
52
|
+
cx="60"
|
|
53
|
+
cy="60"
|
|
54
|
+
r="50"
|
|
55
|
+
stroke="currentColor"
|
|
56
|
+
stroke-width="10"
|
|
57
|
+
fill="none"
|
|
58
|
+
stroke-linecap="round"
|
|
59
|
+
class="text-green-500 transition-all duration-700 ease-out"
|
|
60
|
+
stroke-dasharray="314"
|
|
61
|
+
stroke-dashoffset="314"></circle>
|
|
62
|
+
</svg>
|
|
63
|
+
<!-- Center text -->
|
|
64
|
+
<div class="absolute inset-0 flex flex-col items-center justify-center">
|
|
65
|
+
<span id={`${id}-pct`} class="text-2xl font-bold text-gray-900 dark:text-gray-100">
|
|
66
|
+
--%
|
|
67
|
+
</span>
|
|
68
|
+
<span class="text-xs text-gray-500 dark:text-gray-400">used</span>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<!-- Usage details -->
|
|
74
|
+
<div class="text-center text-sm">
|
|
75
|
+
<p id={`${id}-usage`} class="text-gray-600 dark:text-gray-300">-- / -- used</p>
|
|
76
|
+
<p id={`${id}-period`} class="text-xs text-gray-400 dark:text-gray-500 mt-1">
|
|
77
|
+
(prorated for period)
|
|
78
|
+
</p>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<script>
|
|
83
|
+
interface GaugeData {
|
|
84
|
+
used: number;
|
|
85
|
+
monthlyAllowance: number;
|
|
86
|
+
proratedAllowance: number;
|
|
87
|
+
pctUsed: number;
|
|
88
|
+
unit?: string;
|
|
89
|
+
periodLabel?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function formatNumber(num: number): string {
|
|
93
|
+
if (num >= 1_000_000_000) return `${(num / 1_000_000_000).toFixed(1)}B`;
|
|
94
|
+
if (num >= 1_000_000) return `${(num / 1_000_000).toFixed(1)}M`;
|
|
95
|
+
if (num >= 1_000) return `${(num / 1_000).toFixed(1)}K`;
|
|
96
|
+
return num.toFixed(0);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getGaugeColor(pct: number): string {
|
|
100
|
+
if (pct >= 100) return 'text-red-500';
|
|
101
|
+
if (pct >= 90) return 'text-orange-500';
|
|
102
|
+
if (pct >= 70) return 'text-yellow-500';
|
|
103
|
+
return 'text-green-500';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getBadgeClasses(pct: number): string {
|
|
107
|
+
if (pct >= 100) {
|
|
108
|
+
return 'bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400';
|
|
109
|
+
}
|
|
110
|
+
if (pct >= 90) {
|
|
111
|
+
return 'bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-400';
|
|
112
|
+
}
|
|
113
|
+
if (pct >= 70) {
|
|
114
|
+
return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400';
|
|
115
|
+
}
|
|
116
|
+
return 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getBadgeText(pct: number): string {
|
|
120
|
+
if (pct >= 100) return 'Over Limit!';
|
|
121
|
+
if (pct >= 90) return 'Critical';
|
|
122
|
+
if (pct >= 70) return 'High Usage';
|
|
123
|
+
return 'Within Limit';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function updateAllowanceGauge(gaugeId: string, data: GaugeData) {
|
|
127
|
+
const pctEl = document.getElementById(`${gaugeId}-pct`);
|
|
128
|
+
const progressEl = document.getElementById(`${gaugeId}-progress`);
|
|
129
|
+
const usageEl = document.getElementById(`${gaugeId}-usage`);
|
|
130
|
+
const periodEl = document.getElementById(`${gaugeId}-period`);
|
|
131
|
+
const badgeEl = document.getElementById(`${gaugeId}-badge`);
|
|
132
|
+
|
|
133
|
+
const displayPct = Math.min(data.pctUsed, 999);
|
|
134
|
+
|
|
135
|
+
// Update percentage display
|
|
136
|
+
if (pctEl) {
|
|
137
|
+
pctEl.textContent = `${displayPct.toFixed(0)}%`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Update circular progress (circumference = 2 * PI * r = 2 * 3.14159 * 50 = 314)
|
|
141
|
+
if (progressEl) {
|
|
142
|
+
const circumference = 314;
|
|
143
|
+
const offset = circumference - (Math.min(data.pctUsed, 100) / 100) * circumference;
|
|
144
|
+
progressEl.style.strokeDashoffset = String(offset);
|
|
145
|
+
progressEl.className = `${getGaugeColor(data.pctUsed)} transition-all duration-700 ease-out`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Update usage text
|
|
149
|
+
if (usageEl) {
|
|
150
|
+
const unit = data.unit ?? '';
|
|
151
|
+
usageEl.textContent = `${formatNumber(data.used)} / ${formatNumber(data.proratedAllowance)} ${unit}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Update period label
|
|
155
|
+
if (periodEl && data.periodLabel) {
|
|
156
|
+
periodEl.textContent = `(${data.periodLabel} allowance)`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Update badge
|
|
160
|
+
if (badgeEl) {
|
|
161
|
+
badgeEl.className = `px-2 py-0.5 text-xs font-medium rounded-full ${getBadgeClasses(data.pctUsed)}`;
|
|
162
|
+
badgeEl.textContent = getBadgeText(data.pctUsed);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Expose globally for page scripts
|
|
167
|
+
(
|
|
168
|
+
window as unknown as { updateAllowanceGauge: typeof updateAllowanceGauge }
|
|
169
|
+
).updateAllowanceGauge = updateAllowanceGauge;
|
|
170
|
+
</script>
|