Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(billing): read billing alert types from the billing product's generated files (#118765)

Jimmy Zhu52ca494b3d87
diff --git a/products/billing_alerts/frontend/BillingAlertHistory.test.ts b/products/billing_alerts/frontend/BillingAlertHistory.test.ts
index 96e027967b79..c0950a892426 100644
--- a/products/billing_alerts/frontend/BillingAlertHistory.test.ts
+++ b/products/billing_alerts/frontend/BillingAlertHistory.test.ts
@@ -1,5 +1,9 @@
+import type {
+ BillingAlertConfigurationApi,
+ BillingAlertEventApi,
+} from 'products/billing/frontend/generated/api.schemas'
+
import { eventValue, historyPoint, wouldFire } from './BillingAlertHistory'
-import type { BillingAlertConfigurationApi, BillingAlertEventApi } from './generated/api.schemas'
function alert(thresholdType: BillingAlertConfigurationApi['threshold_type']): BillingAlertConfigurationApi {
return {
diff --git a/products/billing_alerts/frontend/BillingAlertHistory.tsx b/products/billing_alerts/frontend/BillingAlertHistory.tsx
index 6d3df59de8e4..57166f8551e2 100644
--- a/products/billing_alerts/frontend/BillingAlertHistory.tsx
+++ b/products/billing_alerts/frontend/BillingAlertHistory.tsx
@@ -11,10 +11,13 @@ import {
AlertEvaluationHistoryPoint,
AlertEvaluationThreshold,
} from 'products/alerts/frontend/components/AlertEvaluationHistoryChart'
+import type {
+ BillingAlertConfigurationApi,
+ BillingAlertEventApi,
+} from 'products/billing/frontend/generated/api.schemas'
import { formatBillingValue, thresholdView } from './billingAlertDisplay'
import { billingAlertHistoryLogic, HISTORY_PAGE_SIZE } from './billingAlertHistoryLogic'
-import type { BillingAlertConfigurationApi, BillingAlertEventApi } from './generated/api.schemas'
export function eventValue(alert: BillingAlertConfigurationApi, event: BillingAlertEventApi): number | null {
return thresholdView(alert).pickEventValue(event)
diff --git a/products/billing_alerts/frontend/BillingAlertsList.tsx b/products/billing_alerts/frontend/BillingAlertsList.tsx
index 9788eacee316..8d93cc021a64 100644
--- a/products/billing_alerts/frontend/BillingAlertsList.tsx
+++ b/products/billing_alerts/frontend/BillingAlertsList.tsx
@@ -9,9 +9,10 @@ import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import type { LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
+import type { BillingAlertConfigurationApi } from 'products/billing/frontend/generated/api.schemas'
+
import { destinationLabel, metricLabel, stateLabel, stateTagType, thresholdDescription } from './billingAlertDisplay'
import { billingAlertsLogic } from './billingAlertsLogic'
-import type { BillingAlertConfigurationApi } from './generated/api.schemas'
export function BillingAlertsList(): JSX.Element {
const { alerts, alertsPage, alertsPageLoading, checkingAlertId, deletingAlertIds } = useValues(billingAlertsLogic)
diff --git a/products/billing_alerts/frontend/billingAlertDisplay.ts b/products/billing_alerts/frontend/billingAlertDisplay.ts
index dd1ffa7975e0..79e847dc88f3 100644
--- a/products/billing_alerts/frontend/billingAlertDisplay.ts
+++ b/products/billing_alerts/frontend/billingAlertDisplay.ts
@@ -1,17 +1,17 @@
import type {
BillingAlertConfigurationApi,
BillingAlertEventApi,
- BillingAlertMetricEnumApi,
+ BillingAlertConfigurationMetricEnumApi,
NotificationDestinationTypeEnumApi,
-} from './generated/api.schemas'
+} from 'products/billing/frontend/generated/api.schemas'
-export function metricLabel(metric: BillingAlertMetricEnumApi | undefined): string {
+export function metricLabel(metric: BillingAlertConfigurationMetricEnumApi | undefined): string {
return metric === 'projected_spend' ? 'Projected period spend' : 'Current period spend'
}
export function formatBillingValue(
value: string | number | null | undefined,
- metric: BillingAlertMetricEnumApi | undefined,
+ metric: BillingAlertConfigurationMetricEnumApi | undefined,
currency = 'USD'
): string {
if (value === null || value === undefined) {
diff --git a/products/billing_alerts/frontend/billingAlertFormLogic.ts b/products/billing_alerts/frontend/billingAlertFormLogic.ts
index d13085620414..b33b451699df 100644
--- a/products/billing_alerts/frontend/billingAlertFormLogic.ts
+++ b/products/billing_alerts/frontend/billingAlertFormLogic.ts
@@ -9,22 +9,23 @@ import { billingLogic } from 'scenes/billing/billingLogic'
import type { OrganizationType } from '~/types'
+import { billingAlertsCreate, billingAlertsPartialUpdate } from 'products/billing/frontend/generated/api'
+import type {
+ BillingAlertConfigurationApi,
+ BillingAlertConfigurationMetricEnumApi,
+ PatchedBillingAlertConfigurationApi,
+} from 'products/billing/frontend/generated/api.schemas'
+
import { billingAlertNotificationLogic } from './billingAlertNotificationLogic'
import type { PendingBillingAlertDestination } from './billingAlertNotificationLogic'
import { billingAlertsLogic } from './billingAlertsLogic'
import { billingAlertRequestError } from './billingAlertUtils'
-import { billingAlertsCreate, billingAlertsPartialUpdate } from './generated/api'
-import type {
- BillingAlertConfigurationApi,
- BillingAlertMetricEnumApi,
- PatchedBillingAlertConfigurationApi,
-} from './generated/api.schemas'
export interface BillingAlertFormValues {
name: string
description: string
enabled: boolean
- metric: BillingAlertMetricEnumApi
+ metric: BillingAlertConfigurationMetricEnumApi
/** null while the input is cleared, so an empty threshold fails validation instead of saving as 0. */
thresholdValue: number | null
}
diff --git a/products/billing_alerts/frontend/billingAlertHistoryLogic.ts b/products/billing_alerts/frontend/billingAlertHistoryLogic.ts
index 95b77a921f4c..f3699a7d37f7 100644
--- a/products/billing_alerts/frontend/billingAlertHistoryLogic.ts
+++ b/products/billing_alerts/frontend/billingAlertHistoryLogic.ts
@@ -5,9 +5,10 @@ import { billingLogic } from 'scenes/billing/billingLogic'
import type { OrganizationType } from '~/types'
+import { billingAlertsEventsList } from 'products/billing/frontend/generated/api'
+import type { PaginatedBillingAlertEventListApi } from 'products/billing/frontend/generated/api.schemas'
+
import { offsetFromPageLink } from './billingAlertUtils'
-import { billingAlertsEventsList } from './generated/api'
-import type { PaginatedBillingAlertEventListApi } from './generated/api.schemas'
export interface BillingAlertHistoryLogicProps {
alertId: string
diff --git a/products/billing_alerts/frontend/billingAlertNotificationLogic.ts b/products/billing_alerts/frontend/billingAlertNotificationLogic.ts
index 7d1245061d02..181c607f6592 100644
--- a/products/billing_alerts/frontend/billingAlertNotificationLogic.ts
+++ b/products/billing_alerts/frontend/billingAlertNotificationLogic.ts
@@ -9,14 +9,15 @@ import { teamLogic } from 'scenes/teamLogic'
import type { IntegrationType, OrganizationType } from '~/types'
-import { billingAlertsLogic } from './billingAlertsLogic'
-import { billingAlertRequestError, destinationKey } from './billingAlertUtils'
-import { billingAlertsDestinationsDeleteCreate } from './generated/api'
+import { billingAlertsDestinationsDeleteCreate } from 'products/billing/frontend/generated/api'
import type {
BillingAlertConfigurationApi,
BillingAlertDestinationCreateDataApi,
BillingAlertDestinationSummaryApi,
-} from './generated/api.schemas'
+} from 'products/billing/frontend/generated/api.schemas'
+
+import { billingAlertsLogic } from './billingAlertsLogic'
+import { billingAlertRequestError, destinationKey } from './billingAlertUtils'
export type BillingAlertNotificationType = 'slack' | 'teams' | 'webhook'
diff --git a/products/billing_alerts/frontend/billingAlertUtils.ts b/products/billing_alerts/frontend/billingAlertUtils.ts
index c738b00d8f0b..202f7812770b 100644
--- a/products/billing_alerts/frontend/billingAlertUtils.ts
+++ b/products/billing_alerts/frontend/billingAlertUtils.ts
@@ -1,6 +1,6 @@
import { ApiError } from 'lib/api'
-import type { BillingAlertDestinationSummaryApi } from './generated/api.schemas'
+import type { BillingAlertDestinationSummaryApi } from 'products/billing/frontend/generated/api.schemas'
export function offsetFromPageLink(link: string | null | undefined, fallback = 0): number {
if (!link) {
diff --git a/products/billing_alerts/frontend/billingAlertsLogic.test.ts b/products/billing_alerts/frontend/billingAlertsLogic.test.ts
index 97bc116fd980..4bd6f6fa7473 100644
--- a/products/billing_alerts/frontend/billingAlertsLogic.test.ts
+++ b/products/billing_alerts/frontend/billingAlertsLogic.test.ts
@@ -8,14 +8,18 @@ import { initKeaTests } from '~/test/init'
import { expectLogic } from '~/test/keaTestUtils'
import type { OrganizationType } from '~/types'
+import * as generatedApi from 'products/billing/frontend/generated/api'
+import type {
+ BillingAlertConfigurationApi,
+ PaginatedBillingAlertConfigurationListApi,
+} from 'products/billing/frontend/generated/api.schemas'
+
import {
CHECK_NOW_CONFIRMATION_DESCRIPTION,
billingAlertsLogic,
mergeUniqueAlerts,
openBillingAlertCheckNowConfirmation,
} from './billingAlertsLogic'
-import * as generatedApi from './generated/api'
-import type { BillingAlertConfigurationApi, PaginatedBillingAlertConfigurationListApi } from './generated/api.schemas'
const alert = (id: string): BillingAlertConfigurationApi => ({ id }) as BillingAlertConfigurationApi
const organization = (id: string): OrganizationType =>
diff --git a/products/billing_alerts/frontend/billingAlertsLogic.ts b/products/billing_alerts/frontend/billingAlertsLogic.ts
index 23095665f35e..b803406d14d7 100644
--- a/products/billing_alerts/frontend/billingAlertsLogic.ts
+++ b/products/billing_alerts/frontend/billingAlertsLogic.ts
@@ -8,10 +8,18 @@ import { organizationLogic } from 'scenes/organizationLogic'
import type { OrganizationType } from '~/types'
+import {
+ billingAlertsCheckNowCreate,
+ billingAlertsDestroy,
+ billingAlertsList,
+} from 'products/billing/frontend/generated/api'
+import type {
+ BillingAlertConfigurationApi,
+ PaginatedBillingAlertConfigurationListApi,
+} from 'products/billing/frontend/generated/api.schemas'
+
import { formatBillingValue, metricLabel } from './billingAlertDisplay'
import { billingAlertRequestError, offsetFromPageLink } from './billingAlertUtils'
-import { billingAlertsCheckNowCreate, billingAlertsDestroy, billingAlertsList } from './generated/api'
-import type { BillingAlertConfigurationApi, PaginatedBillingAlertConfigurationListApi } from './generated/api.schemas'
const EMPTY_ALERTS_PAGE: PaginatedBillingAlertConfigurationListApi = {
count: 0,
diff --git a/products/billing_alerts/frontend/generated/api.schemas.ts b/products/billing_alerts/frontend/generated/api.schemas.ts
deleted file mode 100644
index 5c685f937475..000000000000
--- a/products/billing_alerts/frontend/generated/api.schemas.ts
+++ /dev/null
@@ -1,560 +0,0 @@
-/**
- * Auto-generated from the Django backend OpenAPI schema.
- * To modify these types, update the Django serializers or views, then run:
- * hogli build:openapi
- * Questions or issues? #team-devex on Slack
- *
- * PostHog API - generated
- * OpenAPI spec version: 1.0.0
- */
-/**
- * * `spend` - Spend
- * * `projected_spend` - Projected spend
- */
-export type BillingAlertMetricEnumApi = (typeof BillingAlertMetricEnumApi)[keyof typeof BillingAlertMetricEnumApi]
-
-export const BillingAlertMetricEnumApi = {
- Spend: 'spend',
- ProjectedSpend: 'projected_spend',
-} as const
-
-/**
- * * `USD` - USD
- */
-export type CurrencyEnumApi = (typeof CurrencyEnumApi)[keyof typeof CurrencyEnumApi]
-
-export const CurrencyEnumApi = {
- Usd: 'USD',
-} as const
-
-/**
- * * `relative_increase` - Relative increase
- * * `absolute_value` - Absolute value
- * * `absolute_increase` - Absolute increase
- */
-export type ThresholdTypeEnumApi = (typeof ThresholdTypeEnumApi)[keyof typeof ThresholdTypeEnumApi]
-
-export const ThresholdTypeEnumApi = {
- RelativeIncrease: 'relative_increase',
- AbsoluteValue: 'absolute_value',
- AbsoluteIncrease: 'absolute_increase',
-} as const
-
-/**
- * * `not_firing` - Not firing
- * * `firing` - Firing
- * * `errored` - Errored
- * * `snoozed` - Snoozed
- * * `broken` - Broken
- */
-export type BillingAlertStateEnumApi = (typeof BillingAlertStateEnumApi)[keyof typeof BillingAlertStateEnumApi]
-
-export const BillingAlertStateEnumApi = {
- NotFiring: 'not_firing',
- Firing: 'firing',
- Errored: 'errored',
- Snoozed: 'snoozed',
- Broken: 'broken',
-} as const
-
-/**
- * * `slack` - slack
- * * `webhook` - webhook
- * * `teams` - teams
- */
-export type NotificationDestinationTypeEnumApi =
- (typeof NotificationDestinationTypeEnumApi)[keyof typeof NotificationDestinationTypeEnumApi]
-
-export const NotificationDestinationTypeEnumApi = {
- Slack: 'slack',
- Webhook: 'webhook',
- Teams: 'teams',
-} as const
-
-export interface BillingAlertDestinationSummaryApi {
- type: NotificationDestinationTypeEnumApi
- hog_function_ids: string[]
-}
-
-export interface BillingAlertDestinationCreateDataApi {
- /** Destination type.
- *
- * * `slack` - slack
- * * `webhook` - webhook
- * * `teams` - teams */
- type: NotificationDestinationTypeEnumApi
- /** Slack integration ID in the alert execution project. */
- slack_workspace_id?: number
- /** Slack channel ID for alert delivery. */
- slack_channel_id?: string
- /** Optional Slack channel name shown in the UI. */
- slack_channel_name?: string
- /** HTTPS webhook URL for webhook or Microsoft Teams delivery. */
- webhook_url?: string
-}
-
-export interface BillingAlertDestinationChangesApi {
- /**
- * @items.minItems 1
- * @items.maxItems 100
- */
- delete?: string[][]
- create?: BillingAlertDestinationCreateDataApi[]
-}
-
-export interface BillingAlertConfigurationApi {
- /** Unique identifier for this billing alert. */
- readonly id: string
- /** Organization this billing alert belongs to. */
- readonly organization_id: string
- /**
- * Team used as the execution context for internal notification destinations.
- * @nullable
- */
- readonly execution_team_id: number | null
- /**
- * User ID that created this alert.
- * @nullable
- */
- readonly created_by_id: number | null
- /**
- * User ID that last updated this alert.
- * @nullable
- */
- readonly updated_by_id: number | null
- /**
- * Display name for this billing alert.
- * @maxLength 160
- */
- name: string
- /** Optional internal description. */
- description?: string
- /** Whether scheduled checks should evaluate this alert. */
- enabled?: boolean
- /** Billing-period total to evaluate: current spend so far, or projected period-end spend.
- *
- * * `spend` - Spend
- * * `projected_spend` - Projected spend */
- metric?: BillingAlertMetricEnumApi
- /** Server-controlled currency for spend values.
- *
- * * `USD` - USD */
- readonly currency: CurrencyEnumApi
- /** Revision incremented whenever evaluation behavior changes. */
- readonly configuration_revision: number
- /** Threshold rule type. The first version supports absolute value only.
- *
- * * `relative_increase` - Relative increase
- * * `absolute_value` - Absolute value
- * * `absolute_increase` - Absolute increase */
- threshold_type?: ThresholdTypeEnumApi
- /**
- * Reserved for future increase-over-baseline rules. Not used by absolute value alerts.
- * @nullable
- * @pattern ^-?\d{0,6}(?:\.\d{0,2})?$
- */
- threshold_percentage?: string | null
- /**
- * Absolute value or absolute increase that triggers absolute threshold alerts.
- * @nullable
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- threshold_value?: string | null
- /**
- * Minimum current value before the alert can fire.
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- minimum_value?: string
- /**
- * Reserved for future increase-over-baseline rules. Not used by absolute value alerts.
- * @minimum 1
- * @maximum 90
- */
- baseline_window_days?: number
- /**
- * Hours after a UTC billing date ends before it becomes eligible for evaluation.
- * @minimum 0
- * @maximum 72
- */
- evaluation_delay_hours?: number
- /** Current lifecycle state of this alert.
- *
- * * `not_firing` - Not firing
- * * `firing` - Firing
- * * `errored` - Errored
- * * `snoozed` - Snoozed
- * * `broken` - Broken */
- readonly state: BillingAlertStateEnumApi
- /**
- * Minimum hours between repeated firing notifications.
- * @minimum 0
- * @maximum 720
- */
- cooldown_hours?: number
- /**
- * ISO 8601 timestamp until which evaluation and notifications are snoozed, or null to resume.
- * @nullable
- */
- snoozed_until?: string | null
- /**
- * When the next scheduled evaluation is due.
- * @nullable
- */
- readonly next_check_at: string | null
- /**
- * When this alert was last evaluated.
- * @nullable
- */
- readonly last_checked_at: string | null
- /**
- * When notifications were last delivered for this alert.
- * @nullable
- */
- readonly last_notified_at: string | null
- /** Number of consecutive failed evaluations. */
- readonly consecutive_failures: number
- /** Notification destination groups configured for this alert, including their shared HogFunctions. */
- readonly destinations: readonly BillingAlertDestinationSummaryApi[]
- /** Destination groups to create or delete in the same transaction as this configuration write. */
- destination_changes?: BillingAlertDestinationChangesApi
- /** When this alert was created. */
- readonly created_at: string
- /**
- * When this alert was last updated.
- * @nullable
- */
- readonly updated_at: string | null
-}
-
-export interface PaginatedBillingAlertConfigurationListApi {
- count: number
- /** @nullable */
- next?: string | null
- /** @nullable */
- previous?: string | null
- results: BillingAlertConfigurationApi[]
-}
-
-export interface PatchedBillingAlertConfigurationApi {
- /** Unique identifier for this billing alert. */
- readonly id?: string
- /** Organization this billing alert belongs to. */
- readonly organization_id?: string
- /**
- * Team used as the execution context for internal notification destinations.
- * @nullable
- */
- readonly execution_team_id?: number | null
- /**
- * User ID that created this alert.
- * @nullable
- */
- readonly created_by_id?: number | null
- /**
- * User ID that last updated this alert.
- * @nullable
- */
- readonly updated_by_id?: number | null
- /**
- * Display name for this billing alert.
- * @maxLength 160
- */
- name?: string
- /** Optional internal description. */
- description?: string
- /** Whether scheduled checks should evaluate this alert. */
- enabled?: boolean
- /** Billing-period total to evaluate: current spend so far, or projected period-end spend.
- *
- * * `spend` - Spend
- * * `projected_spend` - Projected spend */
- metric?: BillingAlertMetricEnumApi
- /** Server-controlled currency for spend values.
- *
- * * `USD` - USD */
- readonly currency?: CurrencyEnumApi
- /** Revision incremented whenever evaluation behavior changes. */
- readonly configuration_revision?: number
- /** Threshold rule type. The first version supports absolute value only.
- *
- * * `relative_increase` - Relative increase
- * * `absolute_value` - Absolute value
- * * `absolute_increase` - Absolute increase */
- threshold_type?: ThresholdTypeEnumApi
- /**
- * Reserved for future increase-over-baseline rules. Not used by absolute value alerts.
- * @nullable
- * @pattern ^-?\d{0,6}(?:\.\d{0,2})?$
- */
- threshold_percentage?: string | null
- /**
- * Absolute value or absolute increase that triggers absolute threshold alerts.
- * @nullable
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- threshold_value?: string | null
- /**
- * Minimum current value before the alert can fire.
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- minimum_value?: string
- /**
- * Reserved for future increase-over-baseline rules. Not used by absolute value alerts.
- * @minimum 1
- * @maximum 90
- */
- baseline_window_days?: number
- /**
- * Hours after a UTC billing date ends before it becomes eligible for evaluation.
- * @minimum 0
- * @maximum 72
- */
- evaluation_delay_hours?: number
- /** Current lifecycle state of this alert.
- *
- * * `not_firing` - Not firing
- * * `firing` - Firing
- * * `errored` - Errored
- * * `snoozed` - Snoozed
- * * `broken` - Broken */
- readonly state?: BillingAlertStateEnumApi
- /**
- * Minimum hours between repeated firing notifications.
- * @minimum 0
- * @maximum 720
- */
- cooldown_hours?: number
- /**
- * ISO 8601 timestamp until which evaluation and notifications are snoozed, or null to resume.
- * @nullable
- */
- snoozed_until?: string | null
- /**
- * When the next scheduled evaluation is due.
- * @nullable
- */
- readonly next_check_at?: string | null
- /**
- * When this alert was last evaluated.
- * @nullable
- */
- readonly last_checked_at?: string | null
- /**
- * When notifications were last delivered for this alert.
- * @nullable
- */
- readonly last_notified_at?: string | null
- /** Number of consecutive failed evaluations. */
- readonly consecutive_failures?: number
- /** Notification destination groups configured for this alert, including their shared HogFunctions. */
- readonly destinations?: readonly BillingAlertDestinationSummaryApi[]
- /** Destination groups to create or delete in the same transaction as this configuration write. */
- destination_changes?: BillingAlertDestinationChangesApi
- /** When this alert was created. */
- readonly created_at?: string
- /**
- * When this alert was last updated.
- * @nullable
- */
- readonly updated_at?: string | null
-}
-
-/**
- * * `check` - Check
- * * `firing` - Firing
- * * `resolved` - Resolved
- * * `errored` - Errored
- * * `broken_config` - Broken config
- */
-export type BillingAlertEventKindEnumApi =
- (typeof BillingAlertEventKindEnumApi)[keyof typeof BillingAlertEventKindEnumApi]
-
-export const BillingAlertEventKindEnumApi = {
- Check: 'check',
- Firing: 'firing',
- Resolved: 'resolved',
- Errored: 'errored',
- BrokenConfig: 'broken_config',
-} as const
-
-/**
- * * `scheduled` - Scheduled
- * * `manual` - Manual
- */
-export type BillingAlertEventSourceEnumApi =
- (typeof BillingAlertEventSourceEnumApi)[keyof typeof BillingAlertEventSourceEnumApi]
-
-export const BillingAlertEventSourceEnumApi = {
- Scheduled: 'scheduled',
- Manual: 'manual',
-} as const
-
-export interface BillingAlertEventApi {
- /** Unique identifier for this billing alert event. */
- readonly id: string
- /** Event kind for a check, state transition, or delivery-worthy alert event.
- *
- * * `check` - Check
- * * `firing` - Firing
- * * `resolved` - Resolved
- * * `errored` - Errored
- * * `broken_config` - Broken config */
- readonly kind: BillingAlertEventKindEnumApi
- /** Whether this evaluation was scheduled or manually requested.
- *
- * * `scheduled` - Scheduled
- * * `manual` - Manual */
- readonly source: BillingAlertEventSourceEnumApi
- /** Attempt number for this billing date and configuration revision. */
- readonly attempt_number: number
- /** When this event was recorded. */
- readonly created_at: string
- /**
- * Billing data date evaluated by this event.
- * @nullable
- */
- readonly evaluation_date: string | null
- /** Configuration revision used for this evaluation. */
- readonly configuration_revision: number
- /**
- * Start of the evaluated billing period.
- * @nullable
- */
- readonly period_start: string | null
- /**
- * End of the evaluated billing period.
- * @nullable
- */
- readonly period_end: string | null
- /** Billing metric evaluated by this event.
- *
- * * `spend` - Spend
- * * `projected_spend` - Projected spend */
- readonly metric: BillingAlertMetricEnumApi
- /**
- * Metric value for the evaluated billing date.
- * @nullable
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- readonly current_value: string | null
- /**
- * Average metric value across the baseline window.
- * @nullable
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- readonly baseline_value: string | null
- /**
- * Current value minus the baseline value.
- * @nullable
- * @pattern ^-?\d{0,14}(?:\.\d{0,6})?$
- */
- readonly absolute_delta: string | null
- /**
- * Percentage change against the baseline value.
- * @nullable
- * @pattern ^-?\d{0,22}(?:\.\d{0,6})?$
- */
- readonly relative_delta_percentage: string | null
- /** Whether the evaluated value breached the configured threshold. */
- readonly threshold_breached: boolean
- /** Alert state before this event was applied.
- *
- * * `not_firing` - Not firing
- * * `firing` - Firing
- * * `errored` - Errored
- * * `snoozed` - Snoozed
- * * `broken` - Broken */
- readonly state_before: BillingAlertStateEnumApi | null
- /** Alert state after this event was applied.
- *
- * * `not_firing` - Not firing
- * * `firing` - Firing
- * * `errored` - Errored
- * * `snoozed` - Snoozed
- * * `broken` - Broken */
- readonly state_after: BillingAlertStateEnumApi | null
- /**
- * When notifications for this event were delivered.
- * @nullable
- */
- readonly notification_sent_at: string | null
- /** Notification targets recorded for this event. */
- readonly targets_notified: unknown
- /**
- * Milliseconds spent fetching billing data for this evaluation.
- * @nullable
- */
- readonly query_duration_ms: number | null
- /**
- * Exception class name recorded when the evaluation failed.
- * @nullable
- */
- readonly error_code: string | null
- /**
- * Failure description recorded when the evaluation failed.
- * @nullable
- */
- readonly error_message: string | null
- /** Human-readable explanation of the evaluation outcome. */
- readonly reason: string
-}
-
-export interface BillingAlertCheckNowResponseApi {
- /** Evaluation event recorded by the manual check, or null for a paused preview. */
- event?: BillingAlertEventApi | null
- /** Number of destination HogFunctions queued. */
- dispatched_destinations: number
- /** True when the alert is paused: it was evaluated but no notifications were sent. */
- preview: boolean
- /** Whether the evaluated billing-period total breached the configured threshold. */
- threshold_breached: boolean
- /**
- * Evaluated billing-period total, or null when billing data was not available.
- * @nullable
- */
- current_value?: string | null
-}
-
-export interface BillingAlertDestinationResponseApi {
- hog_function_ids: string[]
-}
-
-export interface BillingAlertDeleteDestinationApi {
- /**
- * HogFunction IDs to delete as one atomic destination group.
- * @minItems 1
- * @maxItems 100
- */
- hog_function_ids: string[]
-}
-
-export interface PaginatedBillingAlertEventListApi {
- count: number
- /** @nullable */
- next?: string | null
- /** @nullable */
- previous?: string | null
- results: BillingAlertEventApi[]
-}
-
-export type BillingAlertsListParams = {
- /**
- * Number of results to return per page.
- */
- limit?: number
- /**
- * The initial index from which to return the results.
- */
- offset?: number
-}
-
-export type BillingAlertsEventsListParams = {
- /**
- * Number of results to return per page.
- */
- limit?: number
- /**
- * The initial index from which to return the results.
- */
- offset?: number
-}
diff --git a/products/billing_alerts/frontend/generated/api.ts b/products/billing_alerts/frontend/generated/api.ts
deleted file mode 100644
index 6e95a5594b52..000000000000
--- a/products/billing_alerts/frontend/generated/api.ts
+++ /dev/null
@@ -1,244 +0,0 @@
-import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
-/**
- * Auto-generated from the Django backend OpenAPI schema.
- * To modify these types, update the Django serializers or views, then run:
- * hogli build:openapi
- * Questions or issues? #team-devex on Slack
- *
- * PostHog API - generated
- * OpenAPI spec version: 1.0.0
- */
-import type {
- BillingAlertCheckNowResponseApi,
- BillingAlertConfigurationApi,
- BillingAlertDeleteDestinationApi,
- BillingAlertDestinationCreateDataApi,
- BillingAlertDestinationResponseApi,
- BillingAlertsEventsListParams,
- BillingAlertsListParams,
- PaginatedBillingAlertConfigurationListApi,
- PaginatedBillingAlertEventListApi,
- PatchedBillingAlertConfigurationApi,
-} from './api.schemas'
-
-// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
-type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B
-
-type WritableKeys<T> = {
- [P in keyof T]-?: IfEquals<{ [Q in P]: T[P] }, { -readonly [Q in P]: T[P] }, P>
-}[keyof T]
-
-type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
-type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never
-
-type Writable<T> = Pick<T, WritableKeys<T>>
-type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
- ? {
- [P in keyof Writable<T>]: T[P] extends object ? NonReadonly<NonNullable<T[P]>> : T[P]
- }
- : DistributeReadOnlyOverUnions<T>
-
-export const getBillingAlertsListUrl = (organizationId: string, params?: BillingAlertsListParams) => {
- const normalizedParams = new URLSearchParams()
-
- Object.entries(params || {}).forEach(([key, value]) => {
- if (value !== undefined) {
- normalizedParams.append(key, value === null ? 'null' : String(value))
- }
- })
-
- const stringifiedParams = normalizedParams.toString()
-
- return stringifiedParams.length > 0
- ? `/api/organizations/${organizationId}/billing/alerts/?${stringifiedParams}`
- : `/api/organizations/${organizationId}/billing/alerts/`
-}
-
-export const billingAlertsList = async (
- organizationId: string,
- params?: BillingAlertsListParams,
- options?: RequestInit
-): Promise<PaginatedBillingAlertConfigurationListApi> => {
- return apiMutator<PaginatedBillingAlertConfigurationListApi>(getBillingAlertsListUrl(organizationId, params), {
- ...options,
- method: 'GET',
- })
-}
-
-export const getBillingAlertsCreateUrl = (organizationId: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/`
-}
-
-export const billingAlertsCreate = async (
- organizationId: string,
- billingAlertConfigurationApi: NonReadonly<BillingAlertConfigurationApi>,
- options?: RequestInit
-): Promise<BillingAlertConfigurationApi> => {
- return apiMutator<BillingAlertConfigurationApi>(getBillingAlertsCreateUrl(organizationId), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(billingAlertConfigurationApi),
- })
-}
-
-export const getBillingAlertsRetrieveUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/`
-}
-
-export const billingAlertsRetrieve = async (
- organizationId: string,
- id: string,
- options?: RequestInit
-): Promise<BillingAlertConfigurationApi> => {
- return apiMutator<BillingAlertConfigurationApi>(getBillingAlertsRetrieveUrl(organizationId, id), {
- ...options,
- method: 'GET',
- })
-}
-
-export const getBillingAlertsUpdateUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/`
-}
-
-export const billingAlertsUpdate = async (
- organizationId: string,
- id: string,
- billingAlertConfigurationApi: NonReadonly<BillingAlertConfigurationApi>,
- options?: RequestInit
-): Promise<BillingAlertConfigurationApi> => {
- return apiMutator<BillingAlertConfigurationApi>(getBillingAlertsUpdateUrl(organizationId, id), {
- ...options,
- method: 'PUT',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(billingAlertConfigurationApi),
- })
-}
-
-export const getBillingAlertsPartialUpdateUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/`
-}
-
-export const billingAlertsPartialUpdate = async (
- organizationId: string,
- id: string,
- patchedBillingAlertConfigurationApi?: NonReadonly<PatchedBillingAlertConfigurationApi>,
- options?: RequestInit
-): Promise<BillingAlertConfigurationApi> => {
- return apiMutator<BillingAlertConfigurationApi>(getBillingAlertsPartialUpdateUrl(organizationId, id), {
- ...options,
- method: 'PATCH',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(patchedBillingAlertConfigurationApi),
- })
-}
-
-export const getBillingAlertsDestroyUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/`
-}
-
-export const billingAlertsDestroy = async (
- organizationId: string,
- id: string,
- options?: RequestInit
-): Promise<void> => {
- return apiMutator<void>(getBillingAlertsDestroyUrl(organizationId, id), {
- ...options,
- method: 'DELETE',
- })
-}
-
-export const getBillingAlertsCheckNowCreateUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/check_now/`
-}
-
-/**
- * Evaluate this billing alert immediately against real billing spend data. An enabled alert can send notifications when the evaluation records a dispatchable event. A paused alert is evaluated as a preview only: it reports the current spend and would-be outcome without sending notifications or recording an evaluation.
- */
-export const billingAlertsCheckNowCreate = async (
- organizationId: string,
- id: string,
- options?: RequestInit
-): Promise<BillingAlertCheckNowResponseApi> => {
- return apiMutator<BillingAlertCheckNowResponseApi>(getBillingAlertsCheckNowCreateUrl(organizationId, id), {
- ...options,
- method: 'POST',
- })
-}
-
-export const getBillingAlertsDestinationsCreateUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/destinations/`
-}
-
-/**
- * Create a notification destination for this alert. One HogFunction is created per alert event kind.
- */
-export const billingAlertsDestinationsCreate = async (
- organizationId: string,
- id: string,
- billingAlertDestinationCreateDataApi: BillingAlertDestinationCreateDataApi,
- options?: RequestInit
-): Promise<BillingAlertDestinationResponseApi> => {
- return apiMutator<BillingAlertDestinationResponseApi>(getBillingAlertsDestinationsCreateUrl(organizationId, id), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(billingAlertDestinationCreateDataApi),
- })
-}
-
-export const getBillingAlertsDestinationsDeleteCreateUrl = (organizationId: string, id: string) => {
- return `/api/organizations/${organizationId}/billing/alerts/${id}/destinations/delete/`
-}
-
-/**
- * Delete a notification destination by deleting its HogFunction group atomically.
- */
-export const billingAlertsDestinationsDeleteCreate = async (
- organizationId: string,
- id: string,
- billingAlertDeleteDestinationApi: BillingAlertDeleteDestinationApi,
- options?: RequestInit
-): Promise<void> => {
- return apiMutator<void>(getBillingAlertsDestinationsDeleteCreateUrl(organizationId, id), {
- ...options,
- method: 'POST',
- headers: { 'Content-Type': 'application/json', ...options?.headers },
- body: JSON.stringify(billingAlertDeleteDestinationApi),
- })
-}
-
-export const getBillingAlertsEventsListUrl = (
- organizationId: string,
- id: string,
- params?: BillingAlertsEventsListParams
-) => {
- const normalizedParams = new URLSearchParams()
-
- Object.entries(params || {}).forEach(([key, value]) => {
- if (value !== undefined) {
- normalizedParams.append(key, value === null ? 'null' : String(value))
- }
- })
-
- const stringifiedParams = normalizedParams.toString()
-
- return stringifiedParams.length > 0
- ? `/api/organizations/${organizationId}/billing/alerts/${id}/events/?${stringifiedParams}`
- : `/api/organizations/${organizationId}/billing/alerts/${id}/events/`
-}
-
-/**
- * List evaluation and notification events for this billing alert, newest first.
- */
-export const billingAlertsEventsList = async (
- organizationId: string,
- id: string,
- params?: BillingAlertsEventsListParams,
- options?: RequestInit
-): Promise<PaginatedBillingAlertEventListApi> => {
- return apiMutator<PaginatedBillingAlertEventListApi>(getBillingAlertsEventsListUrl(organizationId, id, params), {
- ...options,
- method: 'GET',
- })
-}
diff --git a/products/billing_alerts/frontend/generated/api.zod.ts b/products/billing_alerts/frontend/generated/api.zod.ts
deleted file mode 100644
index 05ebe2302ad6..000000000000
--- a/products/billing_alerts/frontend/generated/api.zod.ts
+++ /dev/null
@@ -1,355 +0,0 @@
-/**
- * Auto-generated Zod validation schemas from the Django backend OpenAPI schema.
- * To modify these schemas, update the Django serializers or views, then run:
- * hogli build:openapi
- * Questions or issues? #team-devex on Slack
- *
- * PostHog API - generated
- * OpenAPI spec version: 1.0.0
- */
-import * as zod from 'zod'
-
-export const billingAlertsCreateBodyNameMax = 160
-
-export const billingAlertsCreateBodyThresholdPercentageRegExp = new RegExp('^-?\\d{0,6}(?:\\.\\d{0,2})?$')
-export const billingAlertsCreateBodyThresholdValueRegExp = new RegExp('^-?\\d{0,14}(?:\\.\\d{0,6})?$')
-export const billingAlertsCreateBodyMinimumValueRegExp = new RegExp('^-?\\d{0,14}(?:\\.\\d{0,6})?$')
-export const billingAlertsCreateBodyBaselineWindowDaysMax = 90
-
-export const billingAlertsCreateBodyEvaluationDelayHoursMin = 0
-export const billingAlertsCreateBodyEvaluationDelayHoursMax = 72
-
-export const billingAlertsCreateBodyCooldownHoursMin = 0
-export const billingAlertsCreateBodyCooldownHoursMax = 720
-
-export const billingAlertsCreateBodyDestinationChangesOneDeleteItemMax = 100
-
-export const BillingAlertsCreateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(billingAlertsCreateBodyNameMax).describe('Display name for this billing alert.'),
- description: zod.string().optional().describe('Optional internal description.'),
- enabled: zod.boolean().optional().describe('Whether scheduled checks should evaluate this alert.'),
- metric: zod
- .enum(['spend', 'projected_spend'])
- .describe('\* `spend` - Spend\n\* `projected_spend` - Projected spend')
- .optional()
- .describe(
- 'Billing-period total to evaluate: current spend so far, or projected period-end spend.\n\n\* `spend` - Spend\n\* `projected_spend` - Projected spend'
- ),
- threshold_type: zod
- .enum(['relative_increase', 'absolute_value', 'absolute_increase'])
- .describe(
- '\* `relative_increase` - Relative increase\n\* `absolute_value` - Absolute value\n\* `absolute_increase` - Absolute increase'
- )
- .optional()
- .describe(
- 'Threshold rule type. The first version supports absolute value only.\n\n\* `relative_increase` - Relative increase\n\* `absolute_value` - Absolute value\n\* `absolute_increase` - Absolute increase'
- ),
- threshold_percentage: zod
- .stringFormat('decimal', billingAlertsCreateBodyThresholdPercentageRegExp)
- .nullish()
- .describe('Reserved for future increase-over-baseline rules. Not used by absolute value alerts.'),
- threshold_value: zod
- .stringFormat('decimal', billingAlertsCreateBodyThresholdValueRegExp)
- .nullish()
- .describe('Absolute value or absolute increase that triggers absolute threshold alerts.'),
- minimum_value: zod
- .stringFormat('decimal', billingAlertsCreateBodyMinimumValueRegExp)
- .optional()
- .describe('Minimum current value before the alert can fire.'),
- baseline_window_days: zod
- .number()
- .min(1)
- .max(billingAlertsCreateBodyBaselineWindowDaysMax)
- .optional()
- .describe('Reserved for future increase-over-baseline rules. Not used by absolute value alerts.'),
- evaluation_delay_hours: zod
- .number()
- .min(billingAlertsCreateBodyEvaluationDelayHoursMin)
- .max(billingAlertsCreateBodyEvaluationDelayHoursMax)
- .optional()
- .describe('Hours after a UTC billing date ends before it becomes eligible for evaluation.'),
- cooldown_hours: zod
- .number()
- .min(billingAlertsCreateBodyCooldownHoursMin)
- .max(billingAlertsCreateBodyCooldownHoursMax)
- .optional()
- .describe('Minimum hours between repeated firing notifications.'),
- snoozed_until: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe('ISO 8601 timestamp until which evaluation and notifications are snoozed, or null to resume.'),
- destination_changes: zod
- .object({
- delete: zod
- .array(zod.array(zod.uuid()).min(1).max(billingAlertsCreateBodyDestinationChangesOneDeleteItemMax))
- .optional(),
- create: zod
- .array(
- zod.object({
- type: zod
- .enum(['slack', 'webhook', 'teams'])
- .describe('\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams')
- .describe(
- 'Destination type.\n\n\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams'
- ),
- slack_workspace_id: zod
- .number()
- .optional()
- .describe('Slack integration ID in the alert execution project.'),
- slack_channel_id: zod.string().optional().describe('Slack channel ID for alert delivery.'),
- slack_channel_name: zod
- .string()
- .optional()
- .describe('Optional Slack channel name shown in the UI.'),
- webhook_url: zod
- .url()
- .optional()
- .describe('HTTPS webhook URL for webhook or Microsoft Teams delivery.'),
- })
- )
- .optional(),
- })
- .optional()
- .describe('Destination groups to create or delete in the same transaction as this configuration write.'),
-})
-
-export const billingAlertsUpdateBodyNameMax = 160
-
-export const billingAlertsUpdateBodyThresholdPercentageRegExp = new RegExp('^-?\\d{0,6}(?:\\.\\d{0,2})?$')
-export const billingAlertsUpdateBodyThresholdValueRegExp = new RegExp('^-?\\d{0,14}(?:\\.\\d{0,6})?$')
-export const billingAlertsUpdateBodyMinimumValueRegExp = new RegExp('^-?\\d{0,14}(?:\\.\\d{0,6})?$')
-export const billingAlertsUpdateBodyBaselineWindowDaysMax = 90
-
-export const billingAlertsUpdateBodyEvaluationDelayHoursMin = 0
-export const billingAlertsUpdateBodyEvaluationDelayHoursMax = 72
-
-export const billingAlertsUpdateBodyCooldownHoursMin = 0
-export const billingAlertsUpdateBodyCooldownHoursMax = 720
-
-export const billingAlertsUpdateBodyDestinationChangesOneDeleteItemMax = 100
-
-export const BillingAlertsUpdateBody = /* @__PURE__ */ zod.object({
- name: zod.string().max(billingAlertsUpdateBodyNameMax).describe('Display name for this billing alert.'),
- description: zod.string().optional().describe('Optional internal description.'),
- enabled: zod.boolean().optional().describe('Whether scheduled checks should evaluate this alert.'),
- metric: zod
- .enum(['spend', 'projected_spend'])
- .describe('\* `spend` - Spend\n\* `projected_spend` - Projected spend')
- .optional()
- .describe(
- 'Billing-period total to evaluate: current spend so far, or projected period-end spend.\n\n\* `spend` - Spend\n\* `projected_spend` - Projected spend'
- ),
- threshold_type: zod
- .enum(['relative_increase', 'absolute_value', 'absolute_increase'])
- .describe(
- '\* `relative_increase` - Relative increase\n\* `absolute_value` - Absolute value\n\* `absolute_increase` - Absolute increase'
- )
- .optional()
- .describe(
- 'Threshold rule type. The first version supports absolute value only.\n\n\* `relative_increase` - Relative increase\n\* `absolute_value` - Absolute value\n\* `absolute_increase` - Absolute increase'
- ),
- threshold_percentage: zod
- .stringFormat('decimal', billingAlertsUpdateBodyThresholdPercentageRegExp)
- .nullish()
- .describe('Reserved for future increase-over-baseline rules. Not used by absolute value alerts.'),
- threshold_value: zod
- .stringFormat('decimal', billingAlertsUpdateBodyThresholdValueRegExp)
- .nullish()
- .describe('Absolute value or absolute increase that triggers absolute threshold alerts.'),
- minimum_value: zod
- .stringFormat('decimal', billingAlertsUpdateBodyMinimumValueRegExp)
- .optional()
- .describe('Minimum current value before the alert can fire.'),
- baseline_window_days: zod
- .number()
- .min(1)
- .max(billingAlertsUpdateBodyBaselineWindowDaysMax)
- .optional()
- .describe('Reserved for future increase-over-baseline rules. Not used by absolute value alerts.'),
- evaluation_delay_hours: zod
- .number()
- .min(billingAlertsUpdateBodyEvaluationDelayHoursMin)
- .max(billingAlertsUpdateBodyEvaluationDelayHoursMax)
- .optional()
- .describe('Hours after a UTC billing date ends before it becomes eligible for evaluation.'),
- cooldown_hours: zod
- .number()
- .min(billingAlertsUpdateBodyCooldownHoursMin)
- .max(billingAlertsUpdateBodyCooldownHoursMax)
- .optional()
- .describe('Minimum hours between repeated firing notifications.'),
- snoozed_until: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe('ISO 8601 timestamp until which evaluation and notifications are snoozed, or null to resume.'),
- destination_changes: zod
- .object({
- delete: zod
- .array(zod.array(zod.uuid()).min(1).max(billingAlertsUpdateBodyDestinationChangesOneDeleteItemMax))
- .optional(),
- create: zod
- .array(
- zod.object({
- type: zod
- .enum(['slack', 'webhook', 'teams'])
- .describe('\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams')
- .describe(
- 'Destination type.\n\n\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams'
- ),
- slack_workspace_id: zod
- .number()
- .optional()
- .describe('Slack integration ID in the alert execution project.'),
- slack_channel_id: zod.string().optional().describe('Slack channel ID for alert delivery.'),
- slack_channel_name: zod
- .string()
- .optional()
- .describe('Optional Slack channel name shown in the UI.'),
- webhook_url: zod
- .url()
- .optional()
- .describe('HTTPS webhook URL for webhook or Microsoft Teams delivery.'),
- })
- )
- .optional(),
- })
- .optional()
- .describe('Destination groups to create or delete in the same transaction as this configuration write.'),
-})
-
-export const billingAlertsPartialUpdateBodyNameMax = 160
-
-export const billingAlertsPartialUpdateBodyThresholdPercentageRegExp = new RegExp('^-?\\d{0,6}(?:\\.\\d{0,2})?$')
-export const billingAlertsPartialUpdateBodyThresholdValueRegExp = new RegExp('^-?\\d{0,14}(?:\\.\\d{0,6})?$')
-export const billingAlertsPartialUpdateBodyMinimumValueRegExp = new RegExp('^-?\\d{0,14}(?:\\.\\d{0,6})?$')
-export const billingAlertsPartialUpdateBodyBaselineWindowDaysMax = 90
-
-export const billingAlertsPartialUpdateBodyEvaluationDelayHoursMin = 0
-export const billingAlertsPartialUpdateBodyEvaluationDelayHoursMax = 72
-
-export const billingAlertsPartialUpdateBodyCooldownHoursMin = 0
-export const billingAlertsPartialUpdateBodyCooldownHoursMax = 720
-
-export const billingAlertsPartialUpdateBodyDestinationChangesOneDeleteItemMax = 100
-
-export const BillingAlertsPartialUpdateBody = /* @__PURE__ */ zod.object({
- name: zod
- .string()
- .max(billingAlertsPartialUpdateBodyNameMax)
- .optional()
- .describe('Display name for this billing alert.'),
- description: zod.string().optional().describe('Optional internal description.'),
- enabled: zod.boolean().optional().describe('Whether scheduled checks should evaluate this alert.'),
- metric: zod
- .enum(['spend', 'projected_spend'])
- .describe('\* `spend` - Spend\n\* `projected_spend` - Projected spend')
- .optional()
- .describe(
- 'Billing-period total to evaluate: current spend so far, or projected period-end spend.\n\n\* `spend` - Spend\n\* `projected_spend` - Projected spend'
- ),
- threshold_type: zod
- .enum(['relative_increase', 'absolute_value', 'absolute_increase'])
- .describe(
- '\* `relative_increase` - Relative increase\n\* `absolute_value` - Absolute value\n\* `absolute_increase` - Absolute increase'
- )
- .optional()
- .describe(
- 'Threshold rule type. The first version supports absolute value only.\n\n\* `relative_increase` - Relative increase\n\* `absolute_value` - Absolute value\n\* `absolute_increase` - Absolute increase'
- ),
- threshold_percentage: zod
- .stringFormat('decimal', billingAlertsPartialUpdateBodyThresholdPercentageRegExp)
- .nullish()
- .describe('Reserved for future increase-over-baseline rules. Not used by absolute value alerts.'),
- threshold_value: zod
- .stringFormat('decimal', billingAlertsPartialUpdateBodyThresholdValueRegExp)
- .nullish()
- .describe('Absolute value or absolute increase that triggers absolute threshold alerts.'),
- minimum_value: zod
- .stringFormat('decimal', billingAlertsPartialUpdateBodyMinimumValueRegExp)
- .optional()
- .describe('Minimum current value before the alert can fire.'),
- baseline_window_days: zod
- .number()
- .min(1)
- .max(billingAlertsPartialUpdateBodyBaselineWindowDaysMax)
- .optional()
- .describe('Reserved for future increase-over-baseline rules. Not used by absolute value alerts.'),
- evaluation_delay_hours: zod
- .number()
- .min(billingAlertsPartialUpdateBodyEvaluationDelayHoursMin)
- .max(billingAlertsPartialUpdateBodyEvaluationDelayHoursMax)
- .optional()
- .describe('Hours after a UTC billing date ends before it becomes eligible for evaluation.'),
- cooldown_hours: zod
- .number()
- .min(billingAlertsPartialUpdateBodyCooldownHoursMin)
- .max(billingAlertsPartialUpdateBodyCooldownHoursMax)
- .optional()
- .describe('Minimum hours between repeated firing notifications.'),
- snoozed_until: zod.iso
- .datetime({ offset: true })
- .nullish()
- .describe('ISO 8601 timestamp until which evaluation and notifications are snoozed, or null to resume.'),
- destination_changes: zod
- .object({
- delete: zod
- .array(
- zod.array(zod.uuid()).min(1).max(billingAlertsPartialUpdateBodyDestinationChangesOneDeleteItemMax)
- )
- .optional(),
- create: zod
- .array(
- zod.object({
- type: zod
- .enum(['slack', 'webhook', 'teams'])
- .describe('\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams')
- .describe(
- 'Destination type.\n\n\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams'
- ),
- slack_workspace_id: zod
- .number()
- .optional()
- .describe('Slack integration ID in the alert execution project.'),
- slack_channel_id: zod.string().optional().describe('Slack channel ID for alert delivery.'),
- slack_channel_name: zod
- .string()
- .optional()
- .describe('Optional Slack channel name shown in the UI.'),
- webhook_url: zod
- .url()
- .optional()
- .describe('HTTPS webhook URL for webhook or Microsoft Teams delivery.'),
- })
- )
- .optional(),
- })
- .optional()
- .describe('Destination groups to create or delete in the same transaction as this configuration write.'),
-})
-
-/**
- * Create a notification destination for this alert. One HogFunction is created per alert event kind.
- */
-export const BillingAlertsDestinationsCreateBody = /* @__PURE__ */ zod.object({
- type: zod
- .enum(['slack', 'webhook', 'teams'])
- .describe('\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams')
- .describe('Destination type.\n\n\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams'),
- slack_workspace_id: zod.number().optional().describe('Slack integration ID in the alert execution project.'),
- slack_channel_id: zod.string().optional().describe('Slack channel ID for alert delivery.'),
- slack_channel_name: zod.string().optional().describe('Optional Slack channel name shown in the UI.'),
- webhook_url: zod.url().optional().describe('HTTPS webhook URL for webhook or Microsoft Teams delivery.'),
-})
-
-/**
- * Delete a notification destination by deleting its HogFunction group atomically.
- */
-export const billingAlertsDestinationsDeleteCreateBodyHogFunctionIdsMax = 100
-
-export const BillingAlertsDestinationsDeleteCreateBody = /* @__PURE__ */ zod.object({
- hog_function_ids: zod
- .array(zod.uuid())
- .min(1)
- .max(billingAlertsDestinationsDeleteCreateBodyHogFunctionIdsMax)
- .describe('HogFunction IDs to delete as one atomic destination group.'),
-})