@littlebearapps/platform-admin-sdk 2.1.0 → 2.3.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/check-upgrade.d.ts +29 -0
- package/dist/check-upgrade.js +97 -0
- package/dist/index.js +59 -4
- package/dist/manifest.d.ts +2 -0
- package/dist/scaffold.js +5 -1
- package/dist/templates.d.ts +6 -1
- package/dist/templates.js +141 -3
- package/dist/upgrade.d.ts +1 -0
- package/dist/upgrade.js +21 -2
- 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,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
|
+
}
|