diff --git a/Cargo.lock b/Cargo.lock index ad5ee1d4..e8698790 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -717,7 +717,7 @@ checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "sentry_protos" -version = "0.30.0" +version = "0.30.1" dependencies = [ "prost", "prost-types", diff --git a/proto/sentry_protos/billing/v1/services/charge/v1/endpoint_list_charges.proto b/proto/sentry_protos/billing/v1/services/charge/v1/endpoint_list_charges.proto index 4fa90da4..c6354302 100644 --- a/proto/sentry_protos/billing/v1/services/charge/v1/endpoint_list_charges.proto +++ b/proto/sentry_protos/billing/v1/services/charge/v1/endpoint_list_charges.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package sentry_protos.billing.v1.services.charge.v1; +import "sentry_protos/billing/v1/services/charge/v1/charge.proto"; + message Charge { uint64 amount_cents = 1; bool paid = 2; @@ -17,3 +19,22 @@ message ListChargesForInvoiceRequest { message ListChargesForInvoiceResponse { repeated Charge charges = 1; } + +// Batched variant for paginated invoice surfaces. Returns +// ``PlatformCharge`` (the canonical projection, with embedded refunds via +// ``PlatformCharge.refunds``) for every charge tied to any of the +// requested invoices, so callers get full per-invoice charge + refund +// state in one round trip. Avoids the N+1 of fetching refunds or +// charges per invoice when rendering paginated invoice lists. +message ListChargesForInvoiceIdsRequest { + repeated uint64 invoice_ids = 1; +} + +message ListChargesForInvoiceIdsResponse { + // Flat list of charges across all requested invoices, ordered by + // ``(invoice_id, date_added)`` ascending. Each ``PlatformCharge`` + // carries its ``invoice_id`` and embedded ``refunds``; group by + // ``charge.invoice_id`` to reconstruct per-invoice state. Invoices + // with no charges simply don't appear. + repeated PlatformCharge charges = 1; +} diff --git a/rust/src/sentry_protos.billing.v1.services.charge.v1.rs b/rust/src/sentry_protos.billing.v1.services.charge.v1.rs index 07f1219c..bc6c75c3 100644 --- a/rust/src/sentry_protos.billing.v1.services.charge.v1.rs +++ b/rust/src/sentry_protos.billing.v1.services.charge.v1.rs @@ -168,6 +168,27 @@ pub struct ListChargesForInvoiceResponse { #[prost(message, repeated, tag = "1")] pub charges: ::prost::alloc::vec::Vec, } +/// Batched variant for paginated invoice surfaces. Returns +/// `PlatformCharge` (the canonical projection, with embedded refunds via +/// `PlatformCharge.refunds`) for every charge tied to any of the +/// requested invoices, so callers get full per-invoice charge + refund +/// state in one round trip. Avoids the N+1 of fetching refunds or +/// charges per invoice when rendering paginated invoice lists. +#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] +pub struct ListChargesForInvoiceIdsRequest { + #[prost(uint64, repeated, tag = "1")] + pub invoice_ids: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListChargesForInvoiceIdsResponse { + /// Flat list of charges across all requested invoices, ordered by + /// `(invoice_id, date_added)` ascending. Each `PlatformCharge` + /// carries its `invoice_id` and embedded `refunds`; group by + /// `charge.invoice_id` to reconstruct per-invoice state. Invoices + /// with no charges simply don't appear. + #[prost(message, repeated, tag = "1")] + pub charges: ::prost::alloc::vec::Vec, +} /// Lists every recorded refund associated with the charges for a single /// platform invoice. Callers in the presentation layer use this to render /// invoice-level refund state without crossing the charge service boundary.