Skip to content

Commit

Permalink
Merge pull request #1788 from openmeterio/feat/plan-api-types
Browse files Browse the repository at this point in the history
feat: add db schema and types for Plan API
  • Loading branch information
chrisgacsal authored Nov 5, 2024
2 parents 7008721 + a71553c commit 5e07c8b
Show file tree
Hide file tree
Showing 63 changed files with 21,589 additions and 716 deletions.
1,369 changes: 688 additions & 681 deletions api/api.gen.go

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12354,6 +12354,7 @@ components:
type: string
enum:
- key
- start_after
description: Order by options for plan phases.
Plan:
type: object
Expand Down Expand Up @@ -12450,9 +12451,10 @@ components:
description: |-
The status of the plan.
Computed based on the effective start and end dates:
- draft = no effectiveStartDate
- active = effectiveStartDate <= now < effectiveEndDate
- archived / inactive = effectiveEndDate <= now
- draft = no effectiveFrom
- active = effectiveFrom <= now < effectiveTo
- archived / inactive = effectiveTo <= now
- scheduled = now < effectiveFrom < effectiveTo
title: Status
readOnly: true
phases:
Expand Down Expand Up @@ -12529,6 +12531,9 @@ components:
enum:
- id
- key
- version
- create_at
- updated_at
description: Order by options for plans.
PlanPaginatedResponse:
type: object
Expand Down Expand Up @@ -12621,13 +12626,13 @@ components:
nullable: true
example: P1Y1D
description: The time after which the plan starts compared to subscription start
title: Duration
title: Start after
discounts:
type: array
items:
$ref: '#/components/schemas/AppliedDiscount'
description: The discounts on the plan.
title: Discount
title: Discounts
description: The plan phase or pricing ramp allows changing a plan's rate cards over time as a subscription progresses.
PlanPhaseCreate:
type: object
Expand Down Expand Up @@ -12671,13 +12676,13 @@ components:
nullable: true
example: P1Y1D
description: The time after which the plan starts compared to subscription start
title: Duration
title: Start after
discounts:
type: array
items:
$ref: '#/components/schemas/AppliedDiscount'
description: The discounts on the plan.
title: Discount
title: Discounts
description: Resource create operation model.
PlanPhasePaginatedResponse:
type: object
Expand Down Expand Up @@ -12742,13 +12747,13 @@ components:
nullable: true
example: P1Y1D
description: The time after which the plan starts compared to subscription start
title: Duration
title: Start after
discounts:
type: array
items:
$ref: '#/components/schemas/AppliedDiscount'
description: The discounts on the plan.
title: Discount
title: Discounts
description: Resource create or update operation model.
PlanReference:
type: object
Expand All @@ -12765,13 +12770,14 @@ components:
version:
type: integer
description: The plan version.
description: Referebces an exact plan.
description: References an exact plan.
PlanStatus:
type: string
enum:
- draft
- active
- archived
- scheduled
description: The status of a plan.
PlanUpdate:
type: object
Expand Down Expand Up @@ -13168,7 +13174,9 @@ components:
type: string
format: duration
nullable: true
description: The billing cadence of the rate card.
description: |-
The billing cadence of the rate card.
When null it means it is a one time fee.
title: Billing cadence
price:
type: object
Expand Down Expand Up @@ -13236,7 +13244,9 @@ components:
type: string
format: duration
nullable: true
description: The billing cadence of the rate card.
description: |-
The billing cadence of the rate card.
When null it means it is a one time fee.
title: Billing cadence
price:
type: object
Expand Down Expand Up @@ -13484,9 +13494,7 @@ components:
billingCadence:
type: string
format: duration
description: |-
The billing cadence of the rate card.
When null, the rate card is a one-time purchase.
description: The billing cadence of the rate card.
title: Billing cadence
price:
anyOf:
Expand Down Expand Up @@ -13562,9 +13570,7 @@ components:
billingCadence:
type: string
format: duration
description: |-
The billing cadence of the rate card.
When null, the rate card is a one-time purchase.
description: The billing cadence of the rate card.
title: Billing cadence
price:
anyOf:
Expand Down
18 changes: 12 additions & 6 deletions api/spec/src/productcatalog/plan.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ enum PlanStatus {
draft: "draft",
active: "active",
archived: "archived",
scheduled: "scheduled",
}

/**
* Referebces an exact plan.
* References an exact plan.
*/
@friendlyName("PlanReference")
model PlanReference {
Expand Down Expand Up @@ -69,9 +70,10 @@ model Plan {
/**
* The status of the plan.
* Computed based on the effective start and end dates:
* - draft = no effectiveStartDate
* - active = effectiveStartDate <= now < effectiveEndDate
* - archived / inactive = effectiveEndDate <= now
* - draft = no effectiveFrom
* - active = effectiveFrom <= now < effectiveTo
* - archived / inactive = effectiveTo <= now
* - scheduled = now < effectiveFrom < effectiveTo
*/
@summary("Status")
@visibility("read")
Expand Down Expand Up @@ -107,15 +109,15 @@ model PlanPhase {
/**
* The time after which the plan starts compared to subscription start
*/
@summary("Duration")
@summary("Start after")
@encode(DurationKnownEncoding.ISO8601)
@example(duration.fromISO("P1Y1D"))
startAfter: duration | null;

/**
* The discounts on the plan.
*/
@summary("Discount")
@summary("Discounts")
discounts?: AppliedDiscount[];

// /**
Expand Down Expand Up @@ -193,6 +195,9 @@ model PlanVariantOverridePreset {
enum PlanOrderBy {
id: "id",
key: "key",
version: "version",
createdAt: "create_at",
updatedAt: "updated_at",
}

/**
Expand All @@ -201,4 +206,5 @@ enum PlanOrderBy {
@friendlyName("PhasesOrderBy")
enum PhasesOrderBy {
key: "key",
startAfter: "start_after",
}
2 changes: 1 addition & 1 deletion api/spec/src/productcatalog/ratecards.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ model RateCardFlatFee {

/**
* The billing cadence of the rate card.
* When null it means it is a one time fee.
*/
@visibility("read", "create", "update")
@summary("Billing cadence")
Expand Down Expand Up @@ -103,7 +104,6 @@ model RateCardUsageBased {

/**
* The billing cadence of the rate card.
* When null, the rate card is a one-time purchase.
*/
@visibility("read", "create", "update")
@summary("Billing cadence")
Expand Down
Loading

0 comments on commit 5e07c8b

Please sign in to comment.