Skip to content

Commit 4752aa9

Browse files
committed
refactor: simplify invoicing api
1 parent e6e7c7e commit 4752aa9

File tree

12 files changed

+5465
-8859
lines changed

12 files changed

+5465
-8859
lines changed

api/api.gen.go

Lines changed: 1342 additions & 1930 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/client/go/client.gen.go

Lines changed: 1239 additions & 1829 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/client/javascript/src/client/schemas.ts

Lines changed: 253 additions & 495 deletions
Large diffs are not rendered by default.

api/client/javascript/src/zod/index.ts

Lines changed: 1660 additions & 2568 deletions
Large diffs are not rendered by default.

api/openapi.cloud.yaml

Lines changed: 377 additions & 678 deletions
Large diffs are not rendered by default.

api/openapi.yaml

Lines changed: 414 additions & 718 deletions
Large diffs are not rendered by default.

api/spec/src/billing/invoices.tsp

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -563,23 +563,13 @@ model InvoiceSimulationInput {
563563
}
564564

565565
/**
566-
* InvoiceSimulationInput represents a line item that can be input to the simulation endpoint.
566+
* InvoiceSimulationLine represents a usage-based line item that can be input to the simulation endpoint.
567567
*/
568568
@friendlyName("InvoiceSimulationLine")
569-
@discriminated(#{ envelope: "none", discriminatorPropertyName: "type" })
570-
union InvoiceSimulationLine {
571-
usage_based: InvoiceSimulationUsageBasedLine,
572-
flat_fee: InvoiceSimulationFlatFeeLine,
573-
}
574-
575-
/**
576-
* InvoiceSimulationUsageBasedLine represents a usage-based line item that can be input to the simulation endpoint.
577-
*/
578-
@friendlyName("InvoiceSimulationUsageBasedLine")
579-
model InvoiceSimulationUsageBasedLine {
569+
model InvoiceSimulationLine {
580570
...TypeSpec.Rest.Resource.ResourceCreateModel<OmitProperties<
581-
Invoice.InvoiceUsageBasedLine,
582-
"invoice" | "currency"
571+
Invoice.InvoiceLine,
572+
"invoice" | "currency" | "children"
583573
>>;
584574

585575
/**
@@ -603,25 +593,6 @@ model InvoiceSimulationUsageBasedLine {
603593
id?: ULID;
604594
}
605595

606-
/**
607-
* InvoiceSimulationFlatFeeLine represents a flat fee line item that can be input to the simulation endpoint.
608-
*/
609-
@friendlyName("InvoiceSimulationFlatFeeLine")
610-
model InvoiceSimulationFlatFeeLine {
611-
...TypeSpec.Rest.Resource.ResourceCreateModel<OmitProperties<
612-
Invoice.InvoiceFlatFeeLine,
613-
"invoice" | "currency"
614-
>>;
615-
616-
/**
617-
* ID of the line. If not specified it will be auto-generated.
618-
*
619-
* When discounts are specified, this must be provided, so that the discount can reference it.
620-
*/
621-
@visibility(Lifecycle.Create)
622-
id?: ULID;
623-
}
624-
625596
/**
626597
* InvoiceReplaceUpdate represents the update model for an invoice.
627598
*/

api/spec/src/billing/invoices/invoice.tsp

Lines changed: 39 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -420,54 +420,15 @@ enum InvoiceType {
420420
}
421421

422422
/**
423-
* BillingInvoiceLine represents a line item that is sold to the customer based on a specific (unit) price.
424-
*/
425-
@friendlyName("InvoiceLine")
426-
@discriminated(#{ envelope: "none", discriminatorPropertyName: "type" })
427-
union InvoiceLine {
428-
usage_based: InvoiceUsageBasedLine,
429-
flat_fee: InvoiceFlatFeeLine,
430-
}
431-
432-
/**
433-
* InvoiceLineReplaceUpdate represents the update model for an invoice line.
434-
*/
435-
@friendlyName("InvoiceLineReplaceUpdate")
436-
@discriminated(#{ envelope: "none", discriminatorPropertyName: "type" })
437-
union InvoiceLineReplaceUpdate {
438-
usage_based: InvoiceUsageBasedLineReplaceUpdate,
439-
flat_fee: InvoiceFlatFeeLineReplaceUpdate,
440-
}
441-
442-
/**
443-
* InvoiceUpdateUsageBasedLineReplaceUpdate represents the update model for an UBP invoice line.
444-
*
445-
* This type makes ID optional to allow for creating new lines as part of the update.
446-
*/
447-
@friendlyName("InvoiceUsageBasedLineReplaceUpdate")
448-
model InvoiceUsageBasedLineReplaceUpdate {
449-
...TypeSpec.Rest.Resource.ResourceReplaceModel<OmitProperties<
450-
InvoiceUsageBasedLine,
451-
"id"
452-
>>;
453-
454-
/**
455-
* The ID of the line.
456-
*/
457-
@visibility(Lifecycle.Update)
458-
id?: ULID;
459-
}
460-
461-
/**
462-
* InvoiceFlatFeeLineReplaceUpdate represents the update model for a flat fee invoice line.
423+
* InvoiceLineReplaceUpdate represents the update model for an UBP invoice line.
463424
*
464425
* This type makes ID optional to allow for creating new lines as part of the update.
465426
*/
466-
@friendlyName("InvoiceFlatFeeLineReplaceUpdate")
467-
model InvoiceFlatFeeLineReplaceUpdate {
427+
@friendlyName("InvoiceLineReplaceUpdate")
428+
model InvoiceLineReplaceUpdate {
468429
...TypeSpec.Rest.Resource.ResourceReplaceModel<OmitProperties<
469-
InvoiceFlatFeeLine,
470-
"id"
430+
InvoiceLine,
431+
"id" | "children"
471432
>>;
472433

473434
/**
@@ -478,42 +439,21 @@ model InvoiceFlatFeeLineReplaceUpdate {
478439
}
479440

480441
/**
481-
* InvoiceLineCreate represents the create model for an invoice line.
442+
* InvoicePendingLineCreate represents the create model for an invoice line that is sold to the customer based on usage.
482443
*/
483444
@friendlyName("InvoicePendingLineCreate")
484-
@discriminated(#{ envelope: "none", discriminatorPropertyName: "type" })
485-
union InvoicePendingLineCreate {
486-
usage_based: InvoiceUsageBasedPendingLineCreate,
487-
flat_fee: InvoiceFlatFeePendingLineCreate,
488-
}
489-
490-
/**
491-
* InvoiceUsageBasedLineCreateWithCustomer represents the create model for an invoice line that is sold to the customer based on usage.
492-
*/
493-
@friendlyName("InvoiceUsageBasedPendingLineCreate")
494-
model InvoiceUsageBasedPendingLineCreate {
495-
// Note: invoice is omitted as the line is assigned a new or existing gathering invoice
496-
...TypeSpec.Rest.Resource.ResourceCreateModel<OmitProperties<
497-
InvoiceUsageBasedLine,
498-
"invoice" | "currency"
499-
>>;
500-
}
501-
502-
/**
503-
* InvoiceFlatFeePendingLineCreate represents the create model for an invoice line that is sold to the customer as a manually added fee.
504-
*/
505-
@friendlyName("InvoiceFlatFeePendingLineCreate")
506-
model InvoiceFlatFeePendingLineCreate {
445+
model InvoicePendingLineCreate {
507446
// Note: invoice is omitted as the line is assigned a new or existing gathering invoice
508447
...TypeSpec.Rest.Resource.ResourceCreateModel<OmitProperties<
509-
InvoiceFlatFeeLine,
510-
"invoice" | "currency"
448+
InvoiceLine,
449+
"invoice" | "currency" | "children"
511450
>>;
512451
}
513452

514453
/**
515454
* LineTypes represents the different types of lines that can be used in an invoice.
516455
*/
456+
#deprecated "We are moving to a coherent invoice line structure"
517457
@friendlyName("InvoiceLineTypes")
518458
enum InvoiceLineTypes {
519459
flatFee: "flat_fee",
@@ -594,7 +534,8 @@ model InvoiceLineBase {
594534
*
595535
* A line's type cannot be changed after creation.
596536
*/
597-
@visibility(Lifecycle.Read, Lifecycle.Create)
537+
#deprecated "We are moving to a coherent invoice line structure"
538+
@visibility(Lifecycle.Read)
598539
type: InvoiceLineTypes;
599540

600541
/**
@@ -646,12 +587,6 @@ model InvoiceLineBase {
646587
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
647588
taxConfig?: OpenMeter.ProductCatalog.TaxConfig;
648589

649-
/**
650-
* The lines detailing the item or service sold.
651-
*/
652-
@visibility(Lifecycle.Read)
653-
children?: InvoiceLine[];
654-
655590
/**
656591
* Totals for this line.
657592
*/
@@ -723,19 +658,22 @@ model InvoiceUsageBasedRateCard {
723658

724659
/**
725660
* InvoiceUsageBasedLine represents a line item that is sold to the customer based on usage. */
726-
@friendlyName("InvoiceUsageBasedLine")
727-
model InvoiceUsageBasedLine {
661+
@friendlyName("InvoiceLine")
662+
model InvoiceLine {
728663
...OmitProperties<InvoiceLineBase, "type">;
729664

730665
/**
731666
* Type of the line.
732667
*/
668+
#deprecated "Invoice always has usage-based line children"
669+
@visibility(Lifecycle.Read)
733670
type: InvoiceLineTypes.usageBased;
734671

735672
/**
736673
* Price of the usage-based item being sold.
737674
*/
738675
#deprecated "Use rateCard.price instead"
676+
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
739677
price?: OpenMeter.ProductCatalog.RateCardUsageBasedPrice;
740678

741679
/**
@@ -745,6 +683,12 @@ model InvoiceUsageBasedLine {
745683
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
746684
featureKey?: Key;
747685

686+
/**
687+
* The lines detailing the item or service sold.
688+
*/
689+
@visibility(Lifecycle.Read)
690+
children?: InvoiceDetailedLine[];
691+
748692
/**
749693
* The rate card that is used for this line.
750694
*
@@ -788,11 +732,11 @@ model InvoiceUsageBasedLine {
788732
}
789733

790734
/**
791-
* InvoiceFlatFeeRateCard represents the rate card (intent) for a flat fee line.
735+
* InvoiceDetailedLineRateCard represents the rate card (intent) for a flat fee line.
792736
*/
793-
@friendlyName("InvoiceFlatFeeRateCard")
794-
model InvoiceFlatFeeRateCard {
795-
// TODO: Once the deprecation is done, let's make price required
737+
@friendlyName("InvoiceDetailedLineRateCard")
738+
model InvoiceDetailedLineRateCard {
739+
// TODO[v2]: Once the deprecation is done, let's make price required
796740
...PickProperties<
797741
OpenMeter.ProductCatalog.RateCardFlatFee,
798742
"taxConfig" | "price"
@@ -814,15 +758,17 @@ model InvoiceFlatFeeRateCard {
814758
}
815759

816760
/**
817-
* InvoiceFlatFeeLine represents a line item that is sold to the customer as a manually added fee.
761+
* InvoiceDetailedLine represents a line item that is sold to the customer as a manually added fee.
818762
*/
819-
@friendlyName("InvoiceFlatFeeLine")
820-
model InvoiceFlatFeeLine {
763+
@friendlyName("InvoiceDetailedLine")
764+
model InvoiceDetailedLine {
821765
...OmitProperties<InvoiceLineBase, "type">;
822766

823767
/**
824768
* Type of the line.
825769
*/
770+
#deprecated "Invoice line's children are always detailed lines"
771+
@visibility(Lifecycle.Read)
826772
type: InvoiceLineTypes.flatFee;
827773

828774
/**
@@ -849,23 +795,23 @@ model InvoiceFlatFeeLine {
849795
/**
850796
* The rate card that is used for this line.
851797
*/
852-
// TODO: Once the deprecation is done, let's make rateCard required
798+
// TODO[v2]: Once the deprecation is done, let's make rateCard required
853799
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
854-
rateCard?: InvoiceFlatFeeRateCard;
800+
rateCard?: InvoiceDetailedLineRateCard;
855801

856802
/**
857803
* Category of the flat fee.
858804
*/
859-
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
860-
category?: InvoiceFlatFeeCategory = InvoiceFlatFeeCategory.regular;
805+
@visibility(Lifecycle.Read)
806+
category?: InvoiceDetailedLineCostCategory = InvoiceDetailedLineCostCategory.regular;
861807
}
862808

863809
/**
864-
* InvoiceFlatFeeCategory determines if the flat fee is a regular fee due to use due to a
810+
* InvoiceDetailedLineCostCategory determines if the flat fee is a regular fee due to use due to a
865811
* commitment.
866812
*/
867-
@friendlyName("InvoiceFlatFeeCategory")
868-
union InvoiceFlatFeeCategory {
813+
@friendlyName("InvoiceDetailedLineCostCategory")
814+
union InvoiceDetailedLineCostCategory {
869815
/**
870816
* The fee is a regular fee due to usage.
871817
*/

0 commit comments

Comments
 (0)