(subscription: CodingPlanSubscriptionRow)
| 104 | planId: coding_plan_subscriptions.plan_id, |
| 105 | providerId: coding_plan_subscriptions.provider_id, |
| 106 | keyInventoryId: coding_plan_subscriptions.key_inventory_id, |
| 107 | installedByokKeyId: coding_plan_subscriptions.installed_byok_key_id, |
| 108 | status: coding_plan_subscriptions.status, |
| 109 | costMicrodollars: coding_plan_subscriptions.cost_microdollars, |
| 110 | billingPeriodDays: coding_plan_subscriptions.billing_period_days, |
| 111 | currentPeriodStart: coding_plan_subscriptions.current_period_start, |
| 112 | currentPeriodEnd: coding_plan_subscriptions.current_period_end, |
| 113 | creditRenewalAt: coding_plan_subscriptions.credit_renewal_at, |
| 114 | cancelAtPeriodEnd: coding_plan_subscriptions.cancel_at_period_end, |
| 115 | paymentGraceExpiresAt: coding_plan_subscriptions.payment_grace_expires_at, |
| 116 | canceledAt: coding_plan_subscriptions.canceled_at, |
| 117 | cancellationReason: coding_plan_subscriptions.cancellation_reason, |
| 118 | createdAt: coding_plan_subscriptions.created_at, |
| 119 | hasAssignedInventory: sql<boolean>`coalesce( |
| 120 | ${coding_plan_key_inventory.status} = 'assigned' |
| 121 | AND ${coding_plan_key_inventory.assigned_to_user_id} = ${coding_plan_subscriptions.user_id} |
| 122 | AND ${coding_plan_key_inventory.plan_id} = ${coding_plan_subscriptions.plan_id} |
| 123 | AND ${coding_plan_key_inventory.provider_id} = ${coding_plan_subscriptions.provider_id}, |
| 124 | false |
| 125 | )`, |
| 126 | hasUpstreamUsageId: sql<boolean>`coalesce(${coding_plan_key_inventory.upstream_usage_id} IS NOT NULL, false)`, |
| 127 | }; |
| 128 | |
| 129 | type CodingPlanSubscriptionRow = Awaited<ReturnType<typeof listOwnedSubscriptions>>[number]; |
| 130 | |
| 131 | function inKiloCredits(microdollars: number): number { |
| 132 | return microdollars / 1_000_000; |
| 133 | } |
| 134 | |
| 135 | function toIsoTimestamp(value: string): string { |
no test coverage detected