@openmeter/client 1.0.0-beta-c39f92326e5b → 1.0.0-beta-75dd3b9ccc98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -610,6 +610,27 @@ export const featureLlmTokenType = z
610
610
  export const subscriptionEditTimingEnum = z
611
611
  .enum(['immediate', 'next_billing_cycle'])
612
612
  .describe('Subscription edit timing. When immediate, the requested changes take effect immediately. When next_billing_cycle, the requested changes take effect at the next billing cycle.');
613
+ export const subscriptionEditRemoveItem = z
614
+ .object({
615
+ type: z
616
+ .literal('remove_item')
617
+ .describe('Discriminator for the remove-item operation.'),
618
+ phaseKey: z
619
+ .string()
620
+ .describe('The key of the phase to remove the item from.'),
621
+ itemKey: z.string().describe('The key of the item to remove.'),
622
+ })
623
+ .describe('Remove a rate card from a phase.');
624
+ export const subscriptionRemovePhaseShifting = z
625
+ .enum(['next', 'prev'])
626
+ .describe("The direction to shift surrounding phases when a phase is removed. - `next`: Shift all subsequent phases to start sooner by the removed phase's length. - `prev`: Extend the previous phase to end later by the removed phase's length.");
627
+ export const subscriptionEditUnscheduleEdit = z
628
+ .object({
629
+ type: z
630
+ .literal('unschedule_edit')
631
+ .describe('Discriminator for the unschedule-edit operation.'),
632
+ })
633
+ .describe('Discard any scheduled edits on the current phase, reverting it to its previously persisted state.');
613
634
  export const appType = z
614
635
  .enum(['sandbox', 'stripe', 'external_invoicing'])
615
636
  .describe('The type of the app.');
@@ -991,6 +1012,16 @@ export const collectionAlignment = z
991
1012
  export const featureUnitCostType = z
992
1013
  .enum(['llm', 'manual'])
993
1014
  .describe('The type of unit cost.');
1015
+ export const subscriptionEditOperationType = z
1016
+ .enum([
1017
+ 'add_item',
1018
+ 'remove_item',
1019
+ 'add_phase',
1020
+ 'remove_phase',
1021
+ 'stretch_phase',
1022
+ 'unschedule_edit',
1023
+ ])
1024
+ .describe('The type of a subscription edit operation. - `add_item`: Add a rate card to a phase. - `remove_item`: Remove a rate card from a phase. - `add_phase`: Add a new phase to the subscription. - `remove_phase`: Remove a phase from the subscription. - `stretch_phase`: Extend the duration of a phase. - `unschedule_edit`: Discard scheduled edits on the current phase.');
994
1025
  export const systemAccountAccessToken = z
995
1026
  .object({
996
1027
  type: z.literal('http').describe('Http authentication'),
@@ -2114,6 +2145,29 @@ export const rateCardMeteredEntitlement = z
2114
2145
  usagePeriod: iso8601Duration.optional(),
2115
2146
  })
2116
2147
  .describe('The entitlement template of a metered entitlement.');
2148
+ export const subscriptionPhaseCreate = z
2149
+ .object({
2150
+ key: resourceKey,
2151
+ name: z.string().describe('The name of the phase.'),
2152
+ description: z
2153
+ .string()
2154
+ .optional()
2155
+ .describe('An optional description of the phase.'),
2156
+ startAfter: iso8601Duration
2157
+ .nullable()
2158
+ .describe('The ISO-8601 interval after the subscription start at which the phase begins. When null, the phase starts immediately after the subscription starts.'),
2159
+ duration: iso8601Duration.optional(),
2160
+ })
2161
+ .describe('The definition of a new subscription phase to add via an edit.');
2162
+ export const subscriptionEditStretchPhase = z
2163
+ .object({
2164
+ type: z
2165
+ .literal('stretch_phase')
2166
+ .describe('Discriminator for the stretch-phase operation.'),
2167
+ phaseKey: z.string().describe('The key of the phase to stretch.'),
2168
+ extendBy: iso8601Duration,
2169
+ })
2170
+ .describe('Extend the duration of a phase, shifting later phases by the same amount.');
2117
2171
  export const recurringPeriod = z
2118
2172
  .object({
2119
2173
  anchor: dateTime,
@@ -2265,6 +2319,15 @@ export const chargeRealizationPayment = z
2265
2319
  export const subscriptionEditTiming = z
2266
2320
  .union([subscriptionEditTimingEnum, dateTime])
2267
2321
  .describe('Subscription edit timing defined when the changes should take effect. If the provided configuration is not supported by the subscription, an error will be returned.');
2322
+ export const subscriptionEditRemovePhase = z
2323
+ .object({
2324
+ type: z
2325
+ .literal('remove_phase')
2326
+ .describe('Discriminator for the remove-phase operation.'),
2327
+ phaseKey: z.string().describe('The key of the phase to remove.'),
2328
+ shift: subscriptionRemovePhaseShifting,
2329
+ })
2330
+ .describe('Remove a phase from the subscription.');
2268
2331
  export const taxCodeAppMapping = z
2269
2332
  .object({
2270
2333
  appType: appType,
@@ -3114,6 +3177,14 @@ export const rateCardEntitlement = z
3114
3177
  rateCardBooleanEntitlement,
3115
3178
  ])
3116
3179
  .describe('Entitlement template configured on a rate card. The feature is taken from the rate card itself, so it is omitted here.');
3180
+ export const subscriptionEditAddPhase = z
3181
+ .object({
3182
+ type: z
3183
+ .literal('add_phase')
3184
+ .describe('Discriminator for the add-phase operation.'),
3185
+ phase: subscriptionPhaseCreate,
3186
+ })
3187
+ .describe('Add a new phase to the subscription. The phase is created without items; use add-item operations to populate it.');
3117
3188
  export const workflowCollectionAlignmentAnchored = z
3118
3189
  .object({
3119
3190
  type: z.literal('anchored').describe('The type of alignment.'),
@@ -4200,6 +4271,15 @@ export const subscriptionItem = z
4200
4271
  rateCard: rateCard,
4201
4272
  })
4202
4273
  .describe('A subscription item pins a rate card to a cadence within a subscription phase.');
4274
+ export const subscriptionEditAddItem = z
4275
+ .object({
4276
+ type: z
4277
+ .literal('add_item')
4278
+ .describe('Discriminator for the add-item operation.'),
4279
+ phaseKey: z.string().describe('The key of the phase to add the item to.'),
4280
+ rateCard: rateCard,
4281
+ })
4282
+ .describe('Add a new rate card to a phase. Adding an item to the current phase closes the active version of the same item key and appends a new version.');
4203
4283
  export const subscriptionAddonRateCard = z
4204
4284
  .object({
4205
4285
  rateCard: rateCard,
@@ -4470,6 +4550,16 @@ export const subscriptionPhase = z
4470
4550
  .describe('The rate cards in effect for this phase, resolved to the version active at the queried time (the currently active version for the current phase, the first version for future phases, and the last version for past phases).'),
4471
4551
  })
4472
4552
  .describe("A subscription phase groups the rate cards in effect for a segment of the subscription's lifetime. Analogous to plan phases.");
4553
+ export const subscriptionEditOperation = z
4554
+ .discriminatedUnion('type', [
4555
+ subscriptionEditAddItem,
4556
+ subscriptionEditRemoveItem,
4557
+ subscriptionEditAddPhase,
4558
+ subscriptionEditRemovePhase,
4559
+ subscriptionEditStretchPhase,
4560
+ subscriptionEditUnscheduleEdit,
4561
+ ])
4562
+ .describe('A single customization to apply to a running subscription. The `type` field discriminates which operation is performed.');
4473
4563
  export const subscriptionAddon = z
4474
4564
  .object({
4475
4565
  id: ulid,
@@ -4656,6 +4746,15 @@ export const subscription = z
4656
4746
  .describe("The phases of the subscription in chronological order. A phase groups the rate cards that are in effect for a segment of the subscription's lifetime."),
4657
4747
  })
4658
4748
  .describe('Subscription.');
4749
+ export const subscriptionEdit = z
4750
+ .object({
4751
+ customizations: z
4752
+ .array(subscriptionEditOperation)
4753
+ .max(100)
4754
+ .describe('The ordered batch of customizations to apply to the running subscription.'),
4755
+ timing: subscriptionEditTiming.optional().default('immediate'),
4756
+ })
4757
+ .describe("Request for editing a running subscription. Applies an ordered batch of customizations to the subscription's phases and items. A later customization observes the state produced by earlier ones.");
4659
4758
  export const subscriptionAddonPagePaginatedResponse = z
4660
4759
  .object({
4661
4760
  data: z.array(subscriptionAddon),
@@ -5111,6 +5210,11 @@ export const changeSubscriptionPathParams = z.object({
5111
5210
  });
5112
5211
  export const changeSubscriptionBody = subscriptionChange;
5113
5212
  export const changeSubscriptionResponse = subscriptionChangeResponse;
5213
+ export const editSubscriptionPathParams = z.object({
5214
+ subscriptionId: ulid,
5215
+ });
5216
+ export const editSubscriptionBody = subscriptionEdit;
5217
+ export const editSubscriptionResponse = subscription;
5114
5218
  export const createSubscriptionAddonPathParams = z.object({
5115
5219
  subscriptionId: ulid,
5116
5220
  });
@@ -6184,6 +6288,27 @@ export const featureLlmTokenTypeWire = z
6184
6288
  export const subscriptionEditTimingEnumWire = z
6185
6289
  .enum(['immediate', 'next_billing_cycle'])
6186
6290
  .describe('Subscription edit timing. When immediate, the requested changes take effect immediately. When next_billing_cycle, the requested changes take effect at the next billing cycle.');
6291
+ export const subscriptionEditRemoveItemWire = z
6292
+ .strictObject({
6293
+ type: z
6294
+ .literal('remove_item')
6295
+ .describe('Discriminator for the remove-item operation.'),
6296
+ phase_key: z
6297
+ .string()
6298
+ .describe('The key of the phase to remove the item from.'),
6299
+ item_key: z.string().describe('The key of the item to remove.'),
6300
+ })
6301
+ .describe('Remove a rate card from a phase.');
6302
+ export const subscriptionRemovePhaseShiftingWire = z
6303
+ .enum(['next', 'prev'])
6304
+ .describe("The direction to shift surrounding phases when a phase is removed. - `next`: Shift all subsequent phases to start sooner by the removed phase's length. - `prev`: Extend the previous phase to end later by the removed phase's length.");
6305
+ export const subscriptionEditUnscheduleEditWire = z
6306
+ .strictObject({
6307
+ type: z
6308
+ .literal('unschedule_edit')
6309
+ .describe('Discriminator for the unschedule-edit operation.'),
6310
+ })
6311
+ .describe('Discard any scheduled edits on the current phase, reverting it to its previously persisted state.');
6187
6312
  export const appTypeWire = z
6188
6313
  .enum(['sandbox', 'stripe', 'external_invoicing'])
6189
6314
  .describe('The type of the app.');
@@ -6562,6 +6687,16 @@ export const collectionAlignmentWire = z
6562
6687
  export const featureUnitCostTypeWire = z
6563
6688
  .enum(['llm', 'manual'])
6564
6689
  .describe('The type of unit cost.');
6690
+ export const subscriptionEditOperationTypeWire = z
6691
+ .enum([
6692
+ 'add_item',
6693
+ 'remove_item',
6694
+ 'add_phase',
6695
+ 'remove_phase',
6696
+ 'stretch_phase',
6697
+ 'unschedule_edit',
6698
+ ])
6699
+ .describe('The type of a subscription edit operation. - `add_item`: Add a rate card to a phase. - `remove_item`: Remove a rate card from a phase. - `add_phase`: Add a new phase to the subscription. - `remove_phase`: Remove a phase from the subscription. - `stretch_phase`: Extend the duration of a phase. - `unschedule_edit`: Discard scheduled edits on the current phase.');
6565
6700
  export const systemAccountAccessTokenWire = z
6566
6701
  .strictObject({
6567
6702
  type: z.literal('http').describe('Http authentication'),
@@ -7672,6 +7807,29 @@ export const rateCardMeteredEntitlementWire = z
7672
7807
  usage_period: iso8601DurationWire.optional(),
7673
7808
  })
7674
7809
  .describe('The entitlement template of a metered entitlement.');
7810
+ export const subscriptionPhaseCreateWire = z
7811
+ .strictObject({
7812
+ key: resourceKeyWire,
7813
+ name: z.string().describe('The name of the phase.'),
7814
+ description: z
7815
+ .string()
7816
+ .optional()
7817
+ .describe('An optional description of the phase.'),
7818
+ start_after: iso8601DurationWire
7819
+ .nullable()
7820
+ .describe('The ISO-8601 interval after the subscription start at which the phase begins. When null, the phase starts immediately after the subscription starts.'),
7821
+ duration: iso8601DurationWire.optional(),
7822
+ })
7823
+ .describe('The definition of a new subscription phase to add via an edit.');
7824
+ export const subscriptionEditStretchPhaseWire = z
7825
+ .strictObject({
7826
+ type: z
7827
+ .literal('stretch_phase')
7828
+ .describe('Discriminator for the stretch-phase operation.'),
7829
+ phase_key: z.string().describe('The key of the phase to stretch.'),
7830
+ extend_by: iso8601DurationWire,
7831
+ })
7832
+ .describe('Extend the duration of a phase, shifting later phases by the same amount.');
7675
7833
  export const recurringPeriodWire = z
7676
7834
  .strictObject({
7677
7835
  anchor: dateTimeWire,
@@ -7818,6 +7976,15 @@ export const chargeRealizationPaymentWire = z
7818
7976
  export const subscriptionEditTimingWire = z
7819
7977
  .union([subscriptionEditTimingEnumWire, dateTimeWire])
7820
7978
  .describe('Subscription edit timing defined when the changes should take effect. If the provided configuration is not supported by the subscription, an error will be returned.');
7979
+ export const subscriptionEditRemovePhaseWire = z
7980
+ .strictObject({
7981
+ type: z
7982
+ .literal('remove_phase')
7983
+ .describe('Discriminator for the remove-phase operation.'),
7984
+ phase_key: z.string().describe('The key of the phase to remove.'),
7985
+ shift: subscriptionRemovePhaseShiftingWire,
7986
+ })
7987
+ .describe('Remove a phase from the subscription.');
7821
7988
  export const taxCodeAppMappingWire = z
7822
7989
  .strictObject({
7823
7990
  app_type: appTypeWire,
@@ -8661,6 +8828,14 @@ export const rateCardEntitlementWire = z
8661
8828
  rateCardBooleanEntitlementWire,
8662
8829
  ])
8663
8830
  .describe('Entitlement template configured on a rate card. The feature is taken from the rate card itself, so it is omitted here.');
8831
+ export const subscriptionEditAddPhaseWire = z
8832
+ .strictObject({
8833
+ type: z
8834
+ .literal('add_phase')
8835
+ .describe('Discriminator for the add-phase operation.'),
8836
+ phase: subscriptionPhaseCreateWire,
8837
+ })
8838
+ .describe('Add a new phase to the subscription. The phase is created without items; use add-item operations to populate it.');
8664
8839
  export const workflowCollectionAlignmentAnchoredWire = z
8665
8840
  .strictObject({
8666
8841
  type: z.literal('anchored').describe('The type of alignment.'),
@@ -9752,6 +9927,15 @@ export const subscriptionItemWire = z
9752
9927
  rate_card: rateCardWire,
9753
9928
  })
9754
9929
  .describe('A subscription item pins a rate card to a cadence within a subscription phase.');
9930
+ export const subscriptionEditAddItemWire = z
9931
+ .strictObject({
9932
+ type: z
9933
+ .literal('add_item')
9934
+ .describe('Discriminator for the add-item operation.'),
9935
+ phase_key: z.string().describe('The key of the phase to add the item to.'),
9936
+ rate_card: rateCardWire,
9937
+ })
9938
+ .describe('Add a new rate card to a phase. Adding an item to the current phase closes the active version of the same item key and appends a new version.');
9755
9939
  export const subscriptionAddonRateCardWire = z
9756
9940
  .strictObject({
9757
9941
  rate_card: rateCardWire,
@@ -10021,6 +10205,16 @@ export const subscriptionPhaseWire = z
10021
10205
  .describe('The rate cards in effect for this phase, resolved to the version active at the queried time (the currently active version for the current phase, the first version for future phases, and the last version for past phases).'),
10022
10206
  })
10023
10207
  .describe("A subscription phase groups the rate cards in effect for a segment of the subscription's lifetime. Analogous to plan phases.");
10208
+ export const subscriptionEditOperationWire = z
10209
+ .discriminatedUnion('type', [
10210
+ subscriptionEditAddItemWire,
10211
+ subscriptionEditRemoveItemWire,
10212
+ subscriptionEditAddPhaseWire,
10213
+ subscriptionEditRemovePhaseWire,
10214
+ subscriptionEditStretchPhaseWire,
10215
+ subscriptionEditUnscheduleEditWire,
10216
+ ])
10217
+ .describe('A single customization to apply to a running subscription. The `type` field discriminates which operation is performed.');
10024
10218
  export const subscriptionAddonWire = z
10025
10219
  .strictObject({
10026
10220
  id: ulidWire,
@@ -10203,6 +10397,15 @@ export const subscriptionWire = z
10203
10397
  .describe("The phases of the subscription in chronological order. A phase groups the rate cards that are in effect for a segment of the subscription's lifetime."),
10204
10398
  })
10205
10399
  .describe('Subscription.');
10400
+ export const subscriptionEditWire = z
10401
+ .strictObject({
10402
+ customizations: z
10403
+ .array(subscriptionEditOperationWire)
10404
+ .max(100)
10405
+ .describe('The ordered batch of customizations to apply to the running subscription.'),
10406
+ timing: subscriptionEditTimingWire.optional(),
10407
+ })
10408
+ .describe("Request for editing a running subscription. Applies an ordered batch of customizations to the subscription's phases and items. A later customization observes the state produced by earlier ones.");
10206
10409
  export const subscriptionAddonPagePaginatedResponseWire = z
10207
10410
  .strictObject({
10208
10411
  data: z.array(subscriptionAddonWire),
@@ -10676,6 +10879,11 @@ export const changeSubscriptionPathParamsWire = z.object({
10676
10879
  });
10677
10880
  export const changeSubscriptionBodyWire = subscriptionChangeWire;
10678
10881
  export const changeSubscriptionResponseWire = subscriptionChangeResponseWire;
10882
+ export const editSubscriptionPathParamsWire = z.object({
10883
+ subscriptionId: ulidWire,
10884
+ });
10885
+ export const editSubscriptionBodyWire = subscriptionEditWire;
10886
+ export const editSubscriptionResponseWire = subscriptionWire;
10679
10887
  export const createSubscriptionAddonPathParamsWire = z.object({
10680
10888
  subscriptionId: ulidWire,
10681
10889
  });
@@ -236,6 +236,23 @@ export interface ChargeFlatFeeDiscounts {
236
236
  /** Percentage discount applied to the price (0–100). */
237
237
  percentage?: number;
238
238
  }
239
+ /** Remove a rate card from a phase. */
240
+ export interface SubscriptionEditRemoveItem {
241
+ /** Discriminator for the remove-item operation. */
242
+ type: 'remove_item';
243
+ /** The key of the phase to remove the item from. */
244
+ phaseKey: string;
245
+ /** The key of the item to remove. */
246
+ itemKey: string;
247
+ }
248
+ /**
249
+ * Discard any scheduled edits on the current phase, reverting it to its previously
250
+ * persisted state.
251
+ */
252
+ export interface SubscriptionEditUnscheduleEdit {
253
+ /** Discriminator for the unschedule-edit operation. */
254
+ type: 'unschedule_edit';
255
+ }
239
256
  /**
240
257
  * Labels store metadata of an entity that can be used for filtering an entity list
241
258
  * or for searching across entity types.
@@ -1782,6 +1799,34 @@ export interface RateCardMeteredEntitlement {
1782
1799
  */
1783
1800
  usagePeriod?: string;
1784
1801
  }
1802
+ /** The definition of a new subscription phase to add via an edit. */
1803
+ export interface SubscriptionPhaseCreate {
1804
+ /** A locally unique identifier for the phase. */
1805
+ key: string;
1806
+ /** The name of the phase. */
1807
+ name: string;
1808
+ /** An optional description of the phase. */
1809
+ description?: string;
1810
+ /**
1811
+ * The ISO-8601 interval after the subscription start at which the phase begins.
1812
+ * When null, the phase starts immediately after the subscription starts.
1813
+ */
1814
+ startAfter: string | null;
1815
+ /**
1816
+ * The intended ISO-8601 duration of the phase. Required unless the phase will be
1817
+ * the last phase of the subscription.
1818
+ */
1819
+ duration?: string;
1820
+ }
1821
+ /** Extend the duration of a phase, shifting later phases by the same amount. */
1822
+ export interface SubscriptionEditStretchPhase {
1823
+ /** Discriminator for the stretch-phase operation. */
1824
+ type: 'stretch_phase';
1825
+ /** The key of the phase to stretch. */
1826
+ phaseKey: string;
1827
+ /** The ISO-8601 duration to extend the phase by. */
1828
+ extendBy: string;
1829
+ }
1785
1830
  /** Recurring period with an anchor and an interval. */
1786
1831
  export interface RecurringPeriod {
1787
1832
  /** A date-time anchor to base the recurring period on. */
@@ -2032,6 +2077,15 @@ export interface ChargeRealizationPayment {
2032
2077
  /** The settlement status of the payment. */
2033
2078
  status: 'authorized' | 'settled';
2034
2079
  }
2080
+ /** Remove a phase from the subscription. */
2081
+ export interface SubscriptionEditRemovePhase {
2082
+ /** Discriminator for the remove-phase operation. */
2083
+ type: 'remove_phase';
2084
+ /** The key of the phase to remove. */
2085
+ phaseKey: string;
2086
+ /** The direction to shift surrounding phases to fill the removed phase's span. */
2087
+ shift: 'next' | 'prev';
2088
+ }
2035
2089
  /** Mapping of app types to tax codes. */
2036
2090
  export interface TaxCodeAppMapping {
2037
2091
  /** The app type that the tax code is associated with. */
@@ -3114,6 +3168,16 @@ export interface ListCustomerEntitlementAccessResponseData {
3114
3168
  /** The list of entitlement access results. */
3115
3169
  data: EntitlementAccessResult[];
3116
3170
  }
3171
+ /**
3172
+ * Add a new phase to the subscription. The phase is created without items; use
3173
+ * add-item operations to populate it.
3174
+ */
3175
+ export interface SubscriptionEditAddPhase {
3176
+ /** Discriminator for the add-phase operation. */
3177
+ type: 'add_phase';
3178
+ /** The phase to add. */
3179
+ phase: SubscriptionPhaseCreate;
3180
+ }
3117
3181
  /**
3118
3182
  * BillingWorkflowCollectionAlignmentAnchored specifies the alignment for
3119
3183
  * collecting the pending line items into an invoice.
@@ -4745,6 +4809,18 @@ export interface SubscriptionItem {
4745
4809
  /** The rate card describing what the customer gets and pays for this item. */
4746
4810
  rateCard: RateCard;
4747
4811
  }
4812
+ /**
4813
+ * Add a new rate card to a phase. Adding an item to the current phase closes the
4814
+ * active version of the same item key and appends a new version.
4815
+ */
4816
+ export interface SubscriptionEditAddItem {
4817
+ /** Discriminator for the add-item operation. */
4818
+ type: 'add_item';
4819
+ /** The key of the phase to add the item to. */
4820
+ phaseKey: string;
4821
+ /** The rate card describing what the customer gets and pays for the new item. */
4822
+ rateCard: RateCard;
4823
+ }
4748
4824
  /** A rate card for a subscription add-on. */
4749
4825
  export interface SubscriptionAddonRateCard {
4750
4826
  /** The rate card. */
@@ -5468,6 +5544,17 @@ export interface Subscription {
5468
5544
  */
5469
5545
  phases: SubscriptionPhase[];
5470
5546
  }
5547
+ /**
5548
+ * Request for editing a running subscription. Applies an ordered batch of
5549
+ * customizations to the subscription's phases and items. A later customization
5550
+ * observes the state produced by earlier ones.
5551
+ */
5552
+ export interface SubscriptionEdit {
5553
+ /** The ordered batch of customizations to apply to the running subscription. */
5554
+ customizations: SubscriptionEditOperation[];
5555
+ /** When the requested changes should take effect. Defaults to immediate. */
5556
+ timing: SubscriptionEditTiming;
5557
+ }
5471
5558
  /** Page paginated response. */
5472
5559
  export interface SubscriptionAddonPagePaginatedResponse {
5473
5560
  data: SubscriptionAddon[];
@@ -5953,6 +6040,11 @@ export type FeatureOrReference = Feature | FeatureReference;
5953
6040
  export type ChargeRealizationInvoiceOrReference = ChargeRealizationInvoice | ChargeRealizationInvoiceReference;
5954
6041
  /** Customer charge. */
5955
6042
  export type CreateChargeRequest = CreateChargeFlatFeeRequest | CreateChargeUsageBasedRequest;
6043
+ /**
6044
+ * A single customization to apply to a running subscription. The `type` field
6045
+ * discriminates which operation is performed.
6046
+ */
6047
+ export type SubscriptionEditOperation = SubscriptionEditAddItem | SubscriptionEditRemoveItem | SubscriptionEditAddPhase | SubscriptionEditRemovePhase | SubscriptionEditStretchPhase | SubscriptionEditUnscheduleEdit;
5956
6048
  /**
5957
6049
  * A top-level line item on an invoice.
5958
6050
  *
@@ -7146,6 +7238,18 @@ export interface SubscriptionItemInput {
7146
7238
  /** The rate card describing what the customer gets and pays for this item. */
7147
7239
  rateCard: RateCardInput;
7148
7240
  }
7241
+ /**
7242
+ * Add a new rate card to a phase. Adding an item to the current phase closes the
7243
+ * active version of the same item key and appends a new version.
7244
+ */
7245
+ export interface SubscriptionEditAddItemInput {
7246
+ /** Discriminator for the add-item operation. */
7247
+ type: 'add_item';
7248
+ /** The key of the phase to add the item to. */
7249
+ phaseKey: string;
7250
+ /** The rate card describing what the customer gets and pays for the new item. */
7251
+ rateCard: RateCardInput;
7252
+ }
7149
7253
  /** A rate card for a subscription add-on. */
7150
7254
  export interface SubscriptionAddonRateCardInput {
7151
7255
  /** The rate card. */
@@ -7827,6 +7931,17 @@ export interface SubscriptionInput {
7827
7931
  */
7828
7932
  phases: SubscriptionPhaseInput[];
7829
7933
  }
7934
+ /**
7935
+ * Request for editing a running subscription. Applies an ordered batch of
7936
+ * customizations to the subscription's phases and items. A later customization
7937
+ * observes the state produced by earlier ones.
7938
+ */
7939
+ export interface SubscriptionEditInput {
7940
+ /** The ordered batch of customizations to apply to the running subscription. */
7941
+ customizations: SubscriptionEditOperationInput[];
7942
+ /** When the requested changes should take effect. Defaults to immediate. */
7943
+ timing?: SubscriptionEditTiming;
7944
+ }
7830
7945
  /** Page paginated response. */
7831
7946
  export interface SubscriptionAddonPagePaginatedResponseInput {
7832
7947
  data: SubscriptionAddonInput[];
@@ -8193,6 +8308,11 @@ export type RateCardEntitlementInput = RateCardMeteredEntitlementInput | RateCar
8193
8308
  export type ChargeRealizationInvoiceOrReferenceInput = ChargeRealizationInvoiceInput | ChargeRealizationInvoiceReference;
8194
8309
  /** Customer charge. */
8195
8310
  export type CreateChargeRequestInput = CreateChargeFlatFeeRequest | CreateChargeUsageBasedRequestInput;
8311
+ /**
8312
+ * A single customization to apply to a running subscription. The `type` field
8313
+ * discriminates which operation is performed.
8314
+ */
8315
+ export type SubscriptionEditOperationInput = SubscriptionEditAddItemInput | SubscriptionEditRemoveItem | SubscriptionEditAddPhase | SubscriptionEditRemovePhase | SubscriptionEditStretchPhase | SubscriptionEditUnscheduleEdit;
8196
8316
  /**
8197
8317
  * A top-level line item on an invoice.
8198
8318
  *
@@ -1,6 +1,6 @@
1
1
  import { type Client } from '../core.js';
2
2
  import { type RequestOptions } from '../lib/types.js';
3
- import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
3
+ import type { CreateSubscriptionRequest, CreateSubscriptionResponse, ListSubscriptionsRequest, ListSubscriptionsResponse, GetSubscriptionRequest, GetSubscriptionResponse, CancelSubscriptionRequest, CancelSubscriptionResponse, UnscheduleCancelationRequest, UnscheduleCancelationResponse, ChangeSubscriptionRequest, ChangeSubscriptionResponse, EditSubscriptionRequest, EditSubscriptionResponse, ListSubscriptionAddonsRequest, ListSubscriptionAddonsResponse, GetSubscriptionAddonRequest, GetSubscriptionAddonResponse } from '../models/operations/subscriptions.js';
4
4
  import type { Subscription, SubscriptionAddon } from '../models/types.js';
5
5
  export declare class Subscriptions {
6
6
  private readonly _client;
@@ -57,6 +57,17 @@ export declare class Subscriptions {
57
57
  * POST /openmeter/subscriptions/{subscriptionId}/change
58
58
  */
59
59
  change(request: ChangeSubscriptionRequest, options?: RequestOptions): Promise<ChangeSubscriptionResponse>;
60
+ /**
61
+ * Edit subscription
62
+ *
63
+ * Edits a running subscription by applying an ordered batch of customizations
64
+ * (adding or removing items, adding, removing, or stretching phases, or
65
+ * unscheduling a pending edit). The changes may take effect immediately or at the
66
+ * next billing cycle. Subscriptions that have add-ons cannot be edited.
67
+ *
68
+ * POST /openmeter/subscriptions/{subscriptionId}/edit
69
+ */
70
+ edit(request: EditSubscriptionRequest, options?: RequestOptions): Promise<EditSubscriptionResponse>;
60
71
  /**
61
72
  * List subscription addons
62
73
  *
@@ -1,7 +1,7 @@
1
1
  // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
2
2
  import { unwrap } from '../lib/types.js';
3
3
  import { paginatePages } from '../lib/paginate.js';
4
- import { createSubscription, listSubscriptions, getSubscription, cancelSubscription, unscheduleCancelation, changeSubscription, listSubscriptionAddons, getSubscriptionAddon, } from '../funcs/subscriptions.js';
4
+ import { createSubscription, listSubscriptions, getSubscription, cancelSubscription, unscheduleCancelation, changeSubscription, editSubscription, listSubscriptionAddons, getSubscriptionAddon, } from '../funcs/subscriptions.js';
5
5
  export class Subscriptions {
6
6
  _client;
7
7
  constructor(_client) {
@@ -73,6 +73,19 @@ export class Subscriptions {
73
73
  async change(request, options) {
74
74
  return unwrap(await changeSubscription(this._client, request, options));
75
75
  }
76
+ /**
77
+ * Edit subscription
78
+ *
79
+ * Edits a running subscription by applying an ordered batch of customizations
80
+ * (adding or removing items, adding, removing, or stretching phases, or
81
+ * unscheduling a pending edit). The changes may take effect immediately or at the
82
+ * next billing cycle. Subscriptions that have add-ons cannot be edited.
83
+ *
84
+ * POST /openmeter/subscriptions/{subscriptionId}/edit
85
+ */
86
+ async edit(request, options) {
87
+ return unwrap(await editSubscription(this._client, request, options));
88
+ }
76
89
  /**
77
90
  * List subscription addons
78
91
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmeter/client",
3
- "version": "1.0.0-beta-c39f92326e5b",
3
+ "version": "1.0.0-beta-75dd3b9ccc98",
4
4
  "description": "Official TypeScript SDK for the OpenMeter API — usage metering and billing",
5
5
  "keywords": [
6
6
  "openmeter",