LCOV - code coverage report
Current view: top level - packages/account-core/src/core/billing/telemetry - topupEvent.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 25.0 % 4 1
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { CreateTopupResponse } from '@comfyorg/ingest-types'
       2              : 
       3              : import type {
       4              :   BillingCheckoutReceived,
       5              :   BillingFailed,
       6              :   BillingIntent,
       7              :   BillingRequestSent,
       8              :   BillingStarted,
       9              :   BillingSucceeded
      10              : } from './stages'
      11              : import type { PaymentIntentSource } from './vocabulary'
      12              : 
      13              : /** The fixed amounts, in USD, a top-up dialog offers as one-click choices. */
      14         2356 : export const TOPUP_AMOUNT_PRESETS_USD = [10, 25, 50, 100] as const
      15              : 
      16              : /** The preset the customer picked, or `custom` for any typed amount. */
      17              : export type TopupAmountPreset =
      18              :   | `${(typeof TOPUP_AMOUNT_PRESETS_USD)[number]}`
      19              :   | 'custom'
      20              : 
      21            0 : export function getTopupAmountPreset(
      22              :   pickedPresetUsd: number | null
      23              : ): TopupAmountPreset {
      24            0 :   const preset = TOPUP_AMOUNT_PRESETS_USD.find((usd) => usd === pickedPresetUsd)
      25            0 :   return preset === undefined ? 'custom' : `${preset}`
      26              : }
      27              : 
      28              : type TopupStarted = BillingStarted & {
      29              :   /** The amount being bought, in whole cents. */
      30              :   amount_cents?: number
      31              :   amount_preset?: TopupAmountPreset
      32              : }
      33              : 
      34              : export type TopupBillingEvent = {
      35              :   operation: 'topup'
      36              :   billing_op_id?: string
      37              :   /**
      38              :    * Surface the top-up was opened from. Absent when the caller named none,
      39              :    * exactly as on the subscription rail's events — absent is no claim, never
      40              :    * an implied default. Named `payment_intent_source` to match its siblings
      41              :    * above; the journey's own `entry_source` is a separate, smaller enum.
      42              :    */
      43              :   payment_intent_source?: PaymentIntentSource
      44              :   /**
      45              :    * Client-observed end-to-end wall time from this attempt's canonical
      46              :    * `started` event through to this terminal event.
      47              :    */
      48              :   duration_ms?: number
      49              : } & (
      50              :   | BillingIntent
      51              :   | BillingCheckoutReceived<CreateTopupResponse['status']>
      52              :   | BillingRequestSent
      53              :   | TopupStarted
      54              :   | BillingSucceeded
      55              :   | BillingFailed
      56              : )
        

Generated by: LCOV version 2.0-1