Skip to content

Commit d58212d

Browse files
committed
feat(subscription_addon): assign addon to a subscription endpoint
fix: copy-paste issue feat: throw conflict error if addon is already assigned to the subscription fix: remove double conflict checks and remove unused params from the request feat: introduce rate cards and timeline into the v3 subscription addon response refactor: make subscriptionWorkflowService name consistent fix: review chore: e2e chore: update Signed-off-by: Andras Toth <4157749+tothandras@users.noreply.github.com> fix: linter issue fix: omit get view call if no items present fix: double check the constraint error if save failed
1 parent 5b9c743 commit d58212d

31 files changed

Lines changed: 2284 additions & 1110 deletions

api/spec/packages/aip-client-javascript/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ The full call path, HTTP route, and a short description are listed below.
171171
| `client.subscriptions.cancel` | `POST /openmeter/subscriptions/{subscriptionId}/cancel` | Cancels the subscription. Will result in a scheduling conflict if there are other subscriptions scheduled to start after the cancelation time. |
172172
| `client.subscriptions.unscheduleCancelation` | `POST /openmeter/subscriptions/{subscriptionId}/unschedule-cancelation` | Unschedules the subscription cancelation. |
173173
| `client.subscriptions.change` | `POST /openmeter/subscriptions/{subscriptionId}/change` | Closes a running subscription and starts a new one according to the specification. Can be used for upgrades, downgrades, and plan changes. |
174-
| `client.subscriptions.listAddons` | `GET /openmeter/subscriptions/{subscriptionId}/addons` | List the addons of a subscription. |
174+
| `client.subscriptions.createAddon` | `POST /openmeter/subscriptions/{subscriptionId}/addons` | Add add-on to a subscription. |
175+
| `client.subscriptions.listAddons` | `GET /openmeter/subscriptions/{subscriptionId}/addons` | List the add-ons of a subscription. |
175176
| `client.subscriptions.getAddon` | `GET /openmeter/subscriptions/{subscriptionId}/addons/{subscriptionAddonId}` | Get an add-on association for a subscription. |
176177

177178
### Apps

api/spec/packages/aip-client-javascript/src/funcs/subscriptions.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import type {
1515
UnscheduleCancelationResponse,
1616
ChangeSubscriptionRequest,
1717
ChangeSubscriptionResponse,
18+
CreateSubscriptionAddonRequest,
19+
CreateSubscriptionAddonResponse,
1820
ListSubscriptionAddonsRequest,
1921
ListSubscriptionAddonsResponse,
2022
GetSubscriptionAddonRequest,
@@ -107,6 +109,21 @@ export function changeSubscription(
107109
)
108110
}
109111

112+
export function createSubscriptionAddon(
113+
client: Client,
114+
req: CreateSubscriptionAddonRequest,
115+
options?: RequestOptions,
116+
): Promise<Result<CreateSubscriptionAddonResponse>> {
117+
const path = encodePath('openmeter/subscriptions/{subscriptionId}/addons', {
118+
subscriptionId: req.subscriptionId,
119+
})
120+
return request(() =>
121+
http(client)
122+
.post(path, { ...options, json: req.body })
123+
.json<CreateSubscriptionAddonResponse>(),
124+
)
125+
}
126+
110127
export function listSubscriptionAddons(
111128
client: Client,
112129
req: ListSubscriptionAddonsRequest,

api/spec/packages/aip-client-javascript/src/index.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export type {
6666
TaxConfigExternalInvoicing,
6767
ChargeFlatFeeDiscounts,
6868
PriceFree,
69+
RateCardStaticEntitlement,
70+
RateCardBooleanEntitlement,
6971
WorkflowCollectionAlignmentSubscription,
7072
WorkflowPaymentChargeAutomaticallySettings,
7173
WorkflowPaymentSendInvoiceSettings,
@@ -75,8 +77,6 @@ export type {
7577
InvoiceLineExternalReferences,
7678
LlmCostProvider,
7779
LlmCostModel,
78-
RateCardStaticEntitlement,
79-
RateCardBooleanEntitlement,
8080
ProductCatalogValidationError,
8181
GovernanceQueryRequestCustomers,
8282
GovernanceQueryRequestFeatures,
@@ -97,11 +97,11 @@ export type {
9797
PriceUnit,
9898
RateCardDiscounts,
9999
Totals,
100+
SpendCommitments,
100101
InvoiceLineCreditsApplied,
101102
FeatureManualUnitCost,
102103
FeatureLlmUnitCostPricing,
103104
LlmCostModelPricing,
104-
SpendCommitments,
105105
QueryFilterNumeric,
106106
CursorPaginationQuery,
107107
ListMetersParamsFilter,
@@ -115,14 +115,15 @@ export type {
115115
BillingCustomerReference,
116116
SubscriptionReference,
117117
AddonReference,
118+
FeatureReference,
118119
AppReference,
119120
ChargeReference,
120121
CurrencyFiat,
121-
FeatureReference,
122122
Event,
123123
MeterQueryRow,
124124
AppStripeCreateCustomerPortalSessionResult,
125125
ClosedPeriod,
126+
SubscriptionAddonTimelineSegment,
126127
CostBasis,
127128
CreateCostBasisRequest,
128129
FeatureCostQueryRow,
@@ -165,8 +166,8 @@ export type {
165166
CustomerStripeCreateCustomerPortalSessionRequest,
166167
EntitlementAccessResult,
167168
CreateCreditGrantPurchase,
168-
RecurringPeriod,
169169
RateCardMeteredEntitlement,
170+
RecurringPeriod,
170171
CreditGrantPurchase,
171172
UpdateCreditGrantExternalSettlementRequest,
172173
ListCreditGrantsParamsFilter,
@@ -176,6 +177,7 @@ export type {
176177
SubscriptionCreate,
177178
RateCardProrationConfiguration,
178179
Subscription,
180+
UnitConfig,
179181
AppCatalogItem,
180182
TaxCodeAppMapping,
181183
PartyTaxIdentity,
@@ -188,7 +190,6 @@ export type {
188190
ListCurrenciesParamsFilter,
189191
CurrencyCustom,
190192
CreateCurrencyCustomRequest,
191-
UnitConfig,
192193
GovernanceQueryRequest,
193194
GovernanceFeatureAccessReason,
194195
GovernanceQueryError,
@@ -214,7 +215,6 @@ export type {
214215
RateCardTaxConfig,
215216
OrganizationDefaultTaxCodes,
216217
UpdateOrganizationDefaultTaxCodesRequest,
217-
SubscriptionAddon,
218218
PlanAddon,
219219
CreatePlanAddonRequest,
220220
ProfileAppReferences,
@@ -241,6 +241,8 @@ export type {
241241
SubscriptionChangeResponse,
242242
SubscriptionCancel,
243243
SubscriptionChange,
244+
CreateSubscriptionAddonRequest,
245+
InvoiceUsageQuantityDetail,
244246
AppStripe,
245247
AppSandbox,
246248
AppExternalInvoicing,
@@ -250,7 +252,6 @@ export type {
250252
InvoiceWorkflow,
251253
InvoiceStatusDetails,
252254
InvoiceLineDiscounts,
253-
InvoiceUsageQuantityDetail,
254255
GovernanceFeatureAccess,
255256
CustomerData,
256257
UpsertCustomerBillingDataRequest,
@@ -263,7 +264,6 @@ export type {
263264
CreditGrant,
264265
CreateChargeFlatFeeRequest,
265266
WorkflowTaxSettings,
266-
SubscriptionAddonPagePaginatedResponse,
267267
PlanAddonPagePaginatedResponse,
268268
IngestedEventPaginatedResponse,
269269
InvalidParameters,
@@ -291,26 +291,29 @@ export type {
291291
ChargeFlatFee,
292292
ChargeUsageBased,
293293
CreateChargeUsageBasedRequest,
294-
InvoiceLineRateCard,
295294
RateCard,
295+
InvoiceLineRateCard,
296296
FeaturePagePaginatedResponse,
297297
Workflow,
298-
InvoiceStandardLine,
298+
SubscriptionAddonRateCard,
299299
PlanPhase,
300300
Addon,
301301
CreateAddonRequest,
302302
UpsertAddonRequest,
303+
InvoiceStandardLine,
303304
Profile,
304305
CreateBillingProfileRequest,
305306
UpsertBillingProfileRequest,
306307
ChargePagePaginatedResponse,
308+
SubscriptionAddon,
307309
Plan,
308310
CreatePlanRequest,
309311
UpsertPlanRequest,
310312
AddonPagePaginatedResponse,
311313
ProfilePagePaginatedResponse,
312-
InvoiceStandard,
314+
SubscriptionAddonPagePaginatedResponse,
313315
PlanPagePaginatedResponse,
316+
InvoiceStandard,
314317
SortQueryInput,
315318
BaseErrorInput,
316319
WorkflowPaymentSendInvoiceSettingsInput,
@@ -333,13 +336,13 @@ export type {
333336
CreateCreditGrantPurchaseInput,
334337
RateCardMeteredEntitlementInput,
335338
CreditGrantPurchaseInput,
336-
WorkflowInvoicingSettingsInput,
337339
UnitConfigInput,
340+
WorkflowInvoicingSettingsInput,
338341
GovernanceQueryRequestInput,
339342
IngestedEventInput,
340343
SubscriptionCancelInput,
341-
InvoiceWorkflowInput,
342344
InvoiceUsageQuantityDetailInput,
345+
InvoiceWorkflowInput,
343346
CreateCreditGrantRequestInput,
344347
CreditGrantInput,
345348
WorkflowTaxSettingsInput,
@@ -354,19 +357,22 @@ export type {
354357
WorkflowCollectionSettingsInput,
355358
RateCardInput,
356359
WorkflowInput,
357-
InvoiceStandardLineInput,
360+
SubscriptionAddonRateCardInput,
358361
PlanPhaseInput,
359362
AddonInput,
360363
CreateAddonRequestInput,
361364
UpsertAddonRequestInput,
365+
InvoiceStandardLineInput,
362366
ProfileInput,
363367
CreateBillingProfileRequestInput,
364368
UpsertBillingProfileRequestInput,
369+
SubscriptionAddonInput,
365370
PlanInput,
366371
CreatePlanRequestInput,
367372
UpsertPlanRequestInput,
368373
AddonPagePaginatedResponseInput,
369374
ProfilePagePaginatedResponseInput,
370-
InvoiceStandardInput,
375+
SubscriptionAddonPagePaginatedResponseInput,
371376
PlanPagePaginatedResponseInput,
377+
InvoiceStandardInput,
372378
} from './models/types.js'

api/spec/packages/aip-client-javascript/src/models/operations/subscriptions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { z } from 'zod'
22
import * as schemas from '../schemas.js'
33
import type {
4+
CreateSubscriptionAddonRequest as CreateSubscriptionAddonRequestBody,
45
ListSubscriptionsParamsFilter,
56
SortQueryInput,
67
Subscription,
@@ -59,6 +60,12 @@ export type ChangeSubscriptionRequest = {
5960
}
6061
export type ChangeSubscriptionResponse = SubscriptionChangeResponse
6162

63+
export type CreateSubscriptionAddonRequest = {
64+
subscriptionId: string
65+
body: CreateSubscriptionAddonRequestBody
66+
}
67+
export type CreateSubscriptionAddonResponse = SubscriptionAddon
68+
6269
export interface ListSubscriptionAddonsQuery {
6370
/** Determines which page of the collection to retrieve. */
6471
page?: { size?: number; number?: number }

0 commit comments

Comments
 (0)