@openmeter/client 1.0.0-beta-c39f92326e5b → 1.0.0-beta-471c6cd3d433

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,
@@ -2175,31 +2229,6 @@ export const rateCardProrationConfiguration = z
2175
2229
  mode: rateCardProrationMode,
2176
2230
  })
2177
2231
  .describe('The proration configuration of the rate card.');
2178
- export const subscriptionCreate = z
2179
- .object({
2180
- labels: labels.optional(),
2181
- settlementMode: settlementMode.optional(),
2182
- customer: z
2183
- .object({
2184
- id: ulid.optional(),
2185
- key: externalResourceKey.optional(),
2186
- })
2187
- .describe('The customer to create the subscription for.'),
2188
- plan: z
2189
- .object({
2190
- id: ulid.optional(),
2191
- key: resourceKey.optional(),
2192
- version: z
2193
- .number()
2194
- .int()
2195
- .optional()
2196
- .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
2197
- })
2198
- .describe('The plan reference of the subscription.'),
2199
- billingAnchor: dateTime.optional(),
2200
- costBasisMode: subscriptionCostBasisMode.optional().default('dynamic'),
2201
- })
2202
- .describe('Subscription create request.');
2203
2232
  export const unitConfig = z
2204
2233
  .object({
2205
2234
  operation: unitConfigOperation,
@@ -2265,6 +2294,15 @@ export const chargeRealizationPayment = z
2265
2294
  export const subscriptionEditTiming = z
2266
2295
  .union([subscriptionEditTimingEnum, dateTime])
2267
2296
  .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.');
2297
+ export const subscriptionEditRemovePhase = z
2298
+ .object({
2299
+ type: z
2300
+ .literal('remove_phase')
2301
+ .describe('Discriminator for the remove-phase operation.'),
2302
+ phaseKey: z.string().describe('The key of the phase to remove.'),
2303
+ shift: subscriptionRemovePhaseShifting,
2304
+ })
2305
+ .describe('Remove a phase from the subscription.');
2268
2306
  export const taxCodeAppMapping = z
2269
2307
  .object({
2270
2308
  appType: appType,
@@ -3114,6 +3152,14 @@ export const rateCardEntitlement = z
3114
3152
  rateCardBooleanEntitlement,
3115
3153
  ])
3116
3154
  .describe('Entitlement template configured on a rate card. The feature is taken from the rate card itself, so it is omitted here.');
3155
+ export const subscriptionEditAddPhase = z
3156
+ .object({
3157
+ type: z
3158
+ .literal('add_phase')
3159
+ .describe('Discriminator for the add-phase operation.'),
3160
+ phase: subscriptionPhaseCreate,
3161
+ })
3162
+ .describe('Add a new phase to the subscription. The phase is created without items; use add-item operations to populate it.');
3117
3163
  export const workflowCollectionAlignmentAnchored = z
3118
3164
  .object({
3119
3165
  type: z.literal('anchored').describe('The type of alignment.'),
@@ -3143,32 +3189,6 @@ export const subscriptionCancel = z
3143
3189
  timing: subscriptionEditTiming.optional().default('immediate'),
3144
3190
  })
3145
3191
  .describe('Request for canceling a subscription.');
3146
- export const subscriptionChange = z
3147
- .object({
3148
- labels: labels.optional(),
3149
- settlementMode: settlementMode.optional(),
3150
- customer: z
3151
- .object({
3152
- id: ulid.optional(),
3153
- key: externalResourceKey.optional(),
3154
- })
3155
- .describe('The customer to create the subscription for.'),
3156
- plan: z
3157
- .object({
3158
- id: ulid.optional(),
3159
- key: resourceKey.optional(),
3160
- version: z
3161
- .number()
3162
- .int()
3163
- .optional()
3164
- .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
3165
- })
3166
- .describe('The plan reference of the subscription.'),
3167
- billingAnchor: dateTime.optional(),
3168
- costBasisMode: subscriptionCostBasisMode.optional().default('dynamic'),
3169
- timing: subscriptionEditTiming,
3170
- })
3171
- .describe('Request for changing a subscription.');
3172
3192
  export const createSubscriptionAddonRequest = z
3173
3193
  .object({
3174
3194
  labels: labels.optional(),
@@ -4200,14 +4220,6 @@ export const subscriptionItem = z
4200
4220
  rateCard: rateCard,
4201
4221
  })
4202
4222
  .describe('A subscription item pins a rate card to a cadence within a subscription phase.');
4203
- export const subscriptionAddonRateCard = z
4204
- .object({
4205
- rateCard: rateCard,
4206
- affectedSubscriptionItemIds: z
4207
- .array(ulid)
4208
- .describe('The IDs of the subscription items that this rate card belongs to.'),
4209
- })
4210
- .describe('A rate card for a subscription add-on.');
4211
4223
  export const planPhase = z
4212
4224
  .object({
4213
4225
  name: z
@@ -4226,6 +4238,23 @@ export const planPhase = z
4226
4238
  rateCards: z.array(rateCard).describe('The rate cards of the plan.'),
4227
4239
  })
4228
4240
  .describe("The plan phase or pricing ramp allows changing a plan's rate cards over time as a subscription progresses.");
4241
+ export const subscriptionEditAddItem = z
4242
+ .object({
4243
+ type: z
4244
+ .literal('add_item')
4245
+ .describe('Discriminator for the add-item operation.'),
4246
+ phaseKey: z.string().describe('The key of the phase to add the item to.'),
4247
+ rateCard: rateCard,
4248
+ })
4249
+ .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.');
4250
+ export const subscriptionAddonRateCard = z
4251
+ .object({
4252
+ rateCard: rateCard,
4253
+ affectedSubscriptionItemIds: z
4254
+ .array(ulid)
4255
+ .describe('The IDs of the subscription items that this rate card belongs to.'),
4256
+ })
4257
+ .describe('A rate card for a subscription add-on.');
4229
4258
  export const addon = z
4230
4259
  .object({
4231
4260
  id: ulid,
@@ -4470,13 +4499,8 @@ export const subscriptionPhase = z
4470
4499
  .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
4500
  })
4472
4501
  .describe("A subscription phase groups the rate cards in effect for a segment of the subscription's lifetime. Analogous to plan phases.");
4473
- export const subscriptionAddon = z
4502
+ export const subscriptionCustomPlan = z
4474
4503
  .object({
4475
- id: ulid,
4476
- labels: labels.optional(),
4477
- createdAt: dateTime,
4478
- updatedAt: dateTime,
4479
- deletedAt: dateTime.optional(),
4480
4504
  name: z
4481
4505
  .string()
4482
4506
  .min(1)
@@ -4487,23 +4511,20 @@ export const subscriptionAddon = z
4487
4511
  .max(1024)
4488
4512
  .optional()
4489
4513
  .describe('Optional description of the resource. Maximum 1024 characters.'),
4490
- addon: addonReference,
4491
- quantity: z
4492
- .number()
4493
- .int()
4494
- .gte(1)
4495
- .describe('The quantity of the add-on. Always 1 for single instance add-ons.'),
4496
- quantityAt: dateTime,
4497
- activeFrom: dateTime,
4498
- activeTo: dateTime.optional(),
4499
- timeline: z
4500
- .array(subscriptionAddonTimelineSegment)
4501
- .describe('The timeline of the add-on. The returned periods are sorted and continuous.'),
4502
- rateCards: z
4503
- .array(subscriptionAddonRateCard)
4504
- .describe('The rate cards of the add-on.'),
4514
+ labels: labels.optional(),
4515
+ currency: billingCurrencyCode,
4516
+ billingCadence: iso8601Duration,
4517
+ proRatingEnabled: z
4518
+ .boolean()
4519
+ .optional()
4520
+ .default(true)
4521
+ .describe('Whether pro-rating is enabled for this plan.'),
4522
+ phases: z
4523
+ .array(planPhase)
4524
+ .min(1)
4525
+ .describe('The plan phases define the pricing ramp for a subscription. A phase switch occurs only at the end of a billing period. At least one phase is required.'),
4505
4526
  })
4506
- .describe('Addon purchased with a subscription.');
4527
+ .describe('An inline (custom) plan definition used to create or change a subscription without referencing a published plan. Mirrors the plan create shape without a key or version, since a custom plan is not persisted or versioned on its own.');
4507
4528
  export const plan = z
4508
4529
  .object({
4509
4530
  id: ulid,
@@ -4600,6 +4621,50 @@ export const upsertPlanRequest = z
4600
4621
  .describe('The plan phases define the pricing ramp for a subscription. A phase switch occurs only at the end of a billing period. At least one phase is required.'),
4601
4622
  })
4602
4623
  .describe('Plan upsert request.');
4624
+ export const subscriptionEditOperation = z
4625
+ .discriminatedUnion('type', [
4626
+ subscriptionEditAddItem,
4627
+ subscriptionEditRemoveItem,
4628
+ subscriptionEditAddPhase,
4629
+ subscriptionEditRemovePhase,
4630
+ subscriptionEditStretchPhase,
4631
+ subscriptionEditUnscheduleEdit,
4632
+ ])
4633
+ .describe('A single customization to apply to a running subscription. The `type` field discriminates which operation is performed.');
4634
+ export const subscriptionAddon = z
4635
+ .object({
4636
+ id: ulid,
4637
+ labels: labels.optional(),
4638
+ createdAt: dateTime,
4639
+ updatedAt: dateTime,
4640
+ deletedAt: dateTime.optional(),
4641
+ name: z
4642
+ .string()
4643
+ .min(1)
4644
+ .max(256)
4645
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
4646
+ description: z
4647
+ .string()
4648
+ .max(1024)
4649
+ .optional()
4650
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
4651
+ addon: addonReference,
4652
+ quantity: z
4653
+ .number()
4654
+ .int()
4655
+ .gte(1)
4656
+ .describe('The quantity of the add-on. Always 1 for single instance add-ons.'),
4657
+ quantityAt: dateTime,
4658
+ activeFrom: dateTime,
4659
+ activeTo: dateTime.optional(),
4660
+ timeline: z
4661
+ .array(subscriptionAddonTimelineSegment)
4662
+ .describe('The timeline of the add-on. The returned periods are sorted and continuous.'),
4663
+ rateCards: z
4664
+ .array(subscriptionAddonRateCard)
4665
+ .describe('The rate cards of the add-on.'),
4666
+ })
4667
+ .describe('Addon purchased with a subscription.');
4603
4668
  export const addonPagePaginatedResponse = z
4604
4669
  .object({
4605
4670
  data: z.array(addon),
@@ -4656,18 +4721,80 @@ export const subscription = z
4656
4721
  .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
4722
  })
4658
4723
  .describe('Subscription.');
4659
- export const subscriptionAddonPagePaginatedResponse = z
4724
+ export const subscriptionCreate = z.object({
4725
+ labels: labels.optional(),
4726
+ settlementMode: settlementMode.optional(),
4727
+ customer: z
4728
+ .object({
4729
+ id: ulid.optional(),
4730
+ key: externalResourceKey.optional(),
4731
+ })
4732
+ .describe('The customer to create the subscription for.'),
4733
+ plan: z
4734
+ .object({
4735
+ id: ulid.optional(),
4736
+ key: resourceKey.optional(),
4737
+ version: z
4738
+ .number()
4739
+ .int()
4740
+ .optional()
4741
+ .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
4742
+ })
4743
+ .optional()
4744
+ .describe('A reference to a published plan the subscription is created from. Exactly one of `plan` or `custom_plan` must be provided. Use `plan` to base the subscription on an existing published plan; use `custom_plan` to define the plan inline.'),
4745
+ customPlan: subscriptionCustomPlan.optional(),
4746
+ billingAnchor: dateTime.optional(),
4747
+ costBasisMode: subscriptionCostBasisMode.optional().default('dynamic'),
4748
+ });
4749
+ export const subscriptionChange = z
4660
4750
  .object({
4661
- data: z.array(subscriptionAddon),
4662
- meta: paginatedMeta,
4751
+ labels: labels.optional(),
4752
+ settlementMode: settlementMode.optional(),
4753
+ customer: z
4754
+ .object({
4755
+ id: ulid.optional(),
4756
+ key: externalResourceKey.optional(),
4757
+ })
4758
+ .describe('The customer to create the subscription for.'),
4759
+ plan: z
4760
+ .object({
4761
+ id: ulid.optional(),
4762
+ key: resourceKey.optional(),
4763
+ version: z
4764
+ .number()
4765
+ .int()
4766
+ .optional()
4767
+ .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
4768
+ })
4769
+ .optional()
4770
+ .describe('A reference to a published plan the subscription is created from. Exactly one of `plan` or `custom_plan` must be provided. Use `plan` to base the subscription on an existing published plan; use `custom_plan` to define the plan inline.'),
4771
+ customPlan: subscriptionCustomPlan.optional(),
4772
+ billingAnchor: dateTime.optional(),
4773
+ costBasisMode: subscriptionCostBasisMode.optional().default('dynamic'),
4774
+ timing: subscriptionEditTiming,
4663
4775
  })
4664
- .describe('Page paginated response.');
4776
+ .describe('Request for changing a subscription.');
4665
4777
  export const planPagePaginatedResponse = z
4666
4778
  .object({
4667
4779
  data: z.array(plan),
4668
4780
  meta: paginatedMeta,
4669
4781
  })
4670
4782
  .describe('Page paginated response.');
4783
+ export const subscriptionEdit = z
4784
+ .object({
4785
+ customizations: z
4786
+ .array(subscriptionEditOperation)
4787
+ .max(100)
4788
+ .describe('The ordered batch of customizations to apply to the running subscription.'),
4789
+ timing: subscriptionEditTiming.optional().default('immediate'),
4790
+ })
4791
+ .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.");
4792
+ export const subscriptionAddonPagePaginatedResponse = z
4793
+ .object({
4794
+ data: z.array(subscriptionAddon),
4795
+ meta: paginatedMeta,
4796
+ })
4797
+ .describe('Page paginated response.');
4671
4798
  export const invoiceStandard = z
4672
4799
  .object({
4673
4800
  id: ulid,
@@ -5111,6 +5238,11 @@ export const changeSubscriptionPathParams = z.object({
5111
5238
  });
5112
5239
  export const changeSubscriptionBody = subscriptionChange;
5113
5240
  export const changeSubscriptionResponse = subscriptionChangeResponse;
5241
+ export const editSubscriptionPathParams = z.object({
5242
+ subscriptionId: ulid,
5243
+ });
5244
+ export const editSubscriptionBody = subscriptionEdit;
5245
+ export const editSubscriptionResponse = subscription;
5114
5246
  export const createSubscriptionAddonPathParams = z.object({
5115
5247
  subscriptionId: ulid,
5116
5248
  });
@@ -6184,6 +6316,27 @@ export const featureLlmTokenTypeWire = z
6184
6316
  export const subscriptionEditTimingEnumWire = z
6185
6317
  .enum(['immediate', 'next_billing_cycle'])
6186
6318
  .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.');
6319
+ export const subscriptionEditRemoveItemWire = z
6320
+ .strictObject({
6321
+ type: z
6322
+ .literal('remove_item')
6323
+ .describe('Discriminator for the remove-item operation.'),
6324
+ phase_key: z
6325
+ .string()
6326
+ .describe('The key of the phase to remove the item from.'),
6327
+ item_key: z.string().describe('The key of the item to remove.'),
6328
+ })
6329
+ .describe('Remove a rate card from a phase.');
6330
+ export const subscriptionRemovePhaseShiftingWire = z
6331
+ .enum(['next', 'prev'])
6332
+ .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.");
6333
+ export const subscriptionEditUnscheduleEditWire = z
6334
+ .strictObject({
6335
+ type: z
6336
+ .literal('unschedule_edit')
6337
+ .describe('Discriminator for the unschedule-edit operation.'),
6338
+ })
6339
+ .describe('Discard any scheduled edits on the current phase, reverting it to its previously persisted state.');
6187
6340
  export const appTypeWire = z
6188
6341
  .enum(['sandbox', 'stripe', 'external_invoicing'])
6189
6342
  .describe('The type of the app.');
@@ -6562,6 +6715,16 @@ export const collectionAlignmentWire = z
6562
6715
  export const featureUnitCostTypeWire = z
6563
6716
  .enum(['llm', 'manual'])
6564
6717
  .describe('The type of unit cost.');
6718
+ export const subscriptionEditOperationTypeWire = z
6719
+ .enum([
6720
+ 'add_item',
6721
+ 'remove_item',
6722
+ 'add_phase',
6723
+ 'remove_phase',
6724
+ 'stretch_phase',
6725
+ 'unschedule_edit',
6726
+ ])
6727
+ .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
6728
  export const systemAccountAccessTokenWire = z
6566
6729
  .strictObject({
6567
6730
  type: z.literal('http').describe('Http authentication'),
@@ -7672,6 +7835,29 @@ export const rateCardMeteredEntitlementWire = z
7672
7835
  usage_period: iso8601DurationWire.optional(),
7673
7836
  })
7674
7837
  .describe('The entitlement template of a metered entitlement.');
7838
+ export const subscriptionPhaseCreateWire = z
7839
+ .strictObject({
7840
+ key: resourceKeyWire,
7841
+ name: z.string().describe('The name of the phase.'),
7842
+ description: z
7843
+ .string()
7844
+ .optional()
7845
+ .describe('An optional description of the phase.'),
7846
+ start_after: iso8601DurationWire
7847
+ .nullable()
7848
+ .describe('The ISO-8601 interval after the subscription start at which the phase begins. When null, the phase starts immediately after the subscription starts.'),
7849
+ duration: iso8601DurationWire.optional(),
7850
+ })
7851
+ .describe('The definition of a new subscription phase to add via an edit.');
7852
+ export const subscriptionEditStretchPhaseWire = z
7853
+ .strictObject({
7854
+ type: z
7855
+ .literal('stretch_phase')
7856
+ .describe('Discriminator for the stretch-phase operation.'),
7857
+ phase_key: z.string().describe('The key of the phase to stretch.'),
7858
+ extend_by: iso8601DurationWire,
7859
+ })
7860
+ .describe('Extend the duration of a phase, shifting later phases by the same amount.');
7675
7861
  export const recurringPeriodWire = z
7676
7862
  .strictObject({
7677
7863
  anchor: dateTimeWire,
@@ -7729,31 +7915,6 @@ export const rateCardProrationConfigurationWire = z
7729
7915
  mode: rateCardProrationModeWire,
7730
7916
  })
7731
7917
  .describe('The proration configuration of the rate card.');
7732
- export const subscriptionCreateWire = z
7733
- .strictObject({
7734
- labels: labelsWire.optional(),
7735
- settlement_mode: settlementModeWire.optional(),
7736
- customer: z
7737
- .strictObject({
7738
- id: ulidWire.optional(),
7739
- key: externalResourceKeyWire.optional(),
7740
- })
7741
- .describe('The customer to create the subscription for.'),
7742
- plan: z
7743
- .strictObject({
7744
- id: ulidWire.optional(),
7745
- key: resourceKeyWire.optional(),
7746
- version: z
7747
- .number()
7748
- .int()
7749
- .optional()
7750
- .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
7751
- })
7752
- .describe('The plan reference of the subscription.'),
7753
- billing_anchor: dateTimeWire.optional(),
7754
- cost_basis_mode: subscriptionCostBasisModeWire.optional(),
7755
- })
7756
- .describe('Subscription create request.');
7757
7918
  export const unitConfigWire = z
7758
7919
  .strictObject({
7759
7920
  operation: unitConfigOperationWire,
@@ -7818,6 +7979,15 @@ export const chargeRealizationPaymentWire = z
7818
7979
  export const subscriptionEditTimingWire = z
7819
7980
  .union([subscriptionEditTimingEnumWire, dateTimeWire])
7820
7981
  .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.');
7982
+ export const subscriptionEditRemovePhaseWire = z
7983
+ .strictObject({
7984
+ type: z
7985
+ .literal('remove_phase')
7986
+ .describe('Discriminator for the remove-phase operation.'),
7987
+ phase_key: z.string().describe('The key of the phase to remove.'),
7988
+ shift: subscriptionRemovePhaseShiftingWire,
7989
+ })
7990
+ .describe('Remove a phase from the subscription.');
7821
7991
  export const taxCodeAppMappingWire = z
7822
7992
  .strictObject({
7823
7993
  app_type: appTypeWire,
@@ -8661,6 +8831,14 @@ export const rateCardEntitlementWire = z
8661
8831
  rateCardBooleanEntitlementWire,
8662
8832
  ])
8663
8833
  .describe('Entitlement template configured on a rate card. The feature is taken from the rate card itself, so it is omitted here.');
8834
+ export const subscriptionEditAddPhaseWire = z
8835
+ .strictObject({
8836
+ type: z
8837
+ .literal('add_phase')
8838
+ .describe('Discriminator for the add-phase operation.'),
8839
+ phase: subscriptionPhaseCreateWire,
8840
+ })
8841
+ .describe('Add a new phase to the subscription. The phase is created without items; use add-item operations to populate it.');
8664
8842
  export const workflowCollectionAlignmentAnchoredWire = z
8665
8843
  .strictObject({
8666
8844
  type: z.literal('anchored').describe('The type of alignment.'),
@@ -8690,32 +8868,6 @@ export const subscriptionCancelWire = z
8690
8868
  timing: subscriptionEditTimingWire.optional(),
8691
8869
  })
8692
8870
  .describe('Request for canceling a subscription.');
8693
- export const subscriptionChangeWire = z
8694
- .strictObject({
8695
- labels: labelsWire.optional(),
8696
- settlement_mode: settlementModeWire.optional(),
8697
- customer: z
8698
- .strictObject({
8699
- id: ulidWire.optional(),
8700
- key: externalResourceKeyWire.optional(),
8701
- })
8702
- .describe('The customer to create the subscription for.'),
8703
- plan: z
8704
- .strictObject({
8705
- id: ulidWire.optional(),
8706
- key: resourceKeyWire.optional(),
8707
- version: z
8708
- .number()
8709
- .int()
8710
- .optional()
8711
- .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
8712
- })
8713
- .describe('The plan reference of the subscription.'),
8714
- billing_anchor: dateTimeWire.optional(),
8715
- cost_basis_mode: subscriptionCostBasisModeWire.optional(),
8716
- timing: subscriptionEditTimingWire,
8717
- })
8718
- .describe('Request for changing a subscription.');
8719
8871
  export const createSubscriptionAddonRequestWire = z
8720
8872
  .strictObject({
8721
8873
  labels: labelsWire.optional(),
@@ -9752,14 +9904,6 @@ export const subscriptionItemWire = z
9752
9904
  rate_card: rateCardWire,
9753
9905
  })
9754
9906
  .describe('A subscription item pins a rate card to a cadence within a subscription phase.');
9755
- export const subscriptionAddonRateCardWire = z
9756
- .strictObject({
9757
- rate_card: rateCardWire,
9758
- affected_subscription_item_ids: z
9759
- .array(ulidWire)
9760
- .describe('The IDs of the subscription items that this rate card belongs to.'),
9761
- })
9762
- .describe('A rate card for a subscription add-on.');
9763
9907
  export const planPhaseWire = z
9764
9908
  .strictObject({
9765
9909
  name: z
@@ -9778,6 +9922,23 @@ export const planPhaseWire = z
9778
9922
  rate_cards: z.array(rateCardWire).describe('The rate cards of the plan.'),
9779
9923
  })
9780
9924
  .describe("The plan phase or pricing ramp allows changing a plan's rate cards over time as a subscription progresses.");
9925
+ export const subscriptionEditAddItemWire = z
9926
+ .strictObject({
9927
+ type: z
9928
+ .literal('add_item')
9929
+ .describe('Discriminator for the add-item operation.'),
9930
+ phase_key: z.string().describe('The key of the phase to add the item to.'),
9931
+ rate_card: rateCardWire,
9932
+ })
9933
+ .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.');
9934
+ export const subscriptionAddonRateCardWire = z
9935
+ .strictObject({
9936
+ rate_card: rateCardWire,
9937
+ affected_subscription_item_ids: z
9938
+ .array(ulidWire)
9939
+ .describe('The IDs of the subscription items that this rate card belongs to.'),
9940
+ })
9941
+ .describe('A rate card for a subscription add-on.');
9781
9942
  export const addonWire = z
9782
9943
  .strictObject({
9783
9944
  id: ulidWire,
@@ -10021,13 +10182,8 @@ export const subscriptionPhaseWire = z
10021
10182
  .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
10183
  })
10023
10184
  .describe("A subscription phase groups the rate cards in effect for a segment of the subscription's lifetime. Analogous to plan phases.");
10024
- export const subscriptionAddonWire = z
10185
+ export const subscriptionCustomPlanWire = z
10025
10186
  .strictObject({
10026
- id: ulidWire,
10027
- labels: labelsWire.optional(),
10028
- created_at: dateTimeWire,
10029
- updated_at: dateTimeWire,
10030
- deleted_at: dateTimeWire.optional(),
10031
10187
  name: z
10032
10188
  .string()
10033
10189
  .min(1)
@@ -10038,23 +10194,19 @@ export const subscriptionAddonWire = z
10038
10194
  .max(1024)
10039
10195
  .optional()
10040
10196
  .describe('Optional description of the resource. Maximum 1024 characters.'),
10041
- addon: addonReferenceWire,
10042
- quantity: z
10043
- .number()
10044
- .int()
10045
- .gte(1)
10046
- .describe('The quantity of the add-on. Always 1 for single instance add-ons.'),
10047
- quantity_at: dateTimeWire,
10048
- active_from: dateTimeWire,
10049
- active_to: dateTimeWire.optional(),
10050
- timeline: z
10051
- .array(subscriptionAddonTimelineSegmentWire)
10052
- .describe('The timeline of the add-on. The returned periods are sorted and continuous.'),
10053
- rate_cards: z
10054
- .array(subscriptionAddonRateCardWire)
10055
- .describe('The rate cards of the add-on.'),
10197
+ labels: labelsWire.optional(),
10198
+ currency: billingCurrencyCodeWire,
10199
+ billing_cadence: iso8601DurationWire,
10200
+ pro_rating_enabled: z
10201
+ .boolean()
10202
+ .optional()
10203
+ .describe('Whether pro-rating is enabled for this plan.'),
10204
+ phases: z
10205
+ .array(planPhaseWire)
10206
+ .min(1)
10207
+ .describe('The plan phases define the pricing ramp for a subscription. A phase switch occurs only at the end of a billing period. At least one phase is required.'),
10056
10208
  })
10057
- .describe('Addon purchased with a subscription.');
10209
+ .describe('An inline (custom) plan definition used to create or change a subscription without referencing a published plan. Mirrors the plan create shape without a key or version, since a custom plan is not persisted or versioned on its own.');
10058
10210
  export const planWire = z
10059
10211
  .strictObject({
10060
10212
  id: ulidWire,
@@ -10147,6 +10299,50 @@ export const upsertPlanRequestWire = z
10147
10299
  .describe('The plan phases define the pricing ramp for a subscription. A phase switch occurs only at the end of a billing period. At least one phase is required.'),
10148
10300
  })
10149
10301
  .describe('Plan upsert request.');
10302
+ export const subscriptionEditOperationWire = z
10303
+ .discriminatedUnion('type', [
10304
+ subscriptionEditAddItemWire,
10305
+ subscriptionEditRemoveItemWire,
10306
+ subscriptionEditAddPhaseWire,
10307
+ subscriptionEditRemovePhaseWire,
10308
+ subscriptionEditStretchPhaseWire,
10309
+ subscriptionEditUnscheduleEditWire,
10310
+ ])
10311
+ .describe('A single customization to apply to a running subscription. The `type` field discriminates which operation is performed.');
10312
+ export const subscriptionAddonWire = z
10313
+ .strictObject({
10314
+ id: ulidWire,
10315
+ labels: labelsWire.optional(),
10316
+ created_at: dateTimeWire,
10317
+ updated_at: dateTimeWire,
10318
+ deleted_at: dateTimeWire.optional(),
10319
+ name: z
10320
+ .string()
10321
+ .min(1)
10322
+ .max(256)
10323
+ .describe('Display name of the resource. Between 1 and 256 characters.'),
10324
+ description: z
10325
+ .string()
10326
+ .max(1024)
10327
+ .optional()
10328
+ .describe('Optional description of the resource. Maximum 1024 characters.'),
10329
+ addon: addonReferenceWire,
10330
+ quantity: z
10331
+ .number()
10332
+ .int()
10333
+ .gte(1)
10334
+ .describe('The quantity of the add-on. Always 1 for single instance add-ons.'),
10335
+ quantity_at: dateTimeWire,
10336
+ active_from: dateTimeWire,
10337
+ active_to: dateTimeWire.optional(),
10338
+ timeline: z
10339
+ .array(subscriptionAddonTimelineSegmentWire)
10340
+ .describe('The timeline of the add-on. The returned periods are sorted and continuous.'),
10341
+ rate_cards: z
10342
+ .array(subscriptionAddonRateCardWire)
10343
+ .describe('The rate cards of the add-on.'),
10344
+ })
10345
+ .describe('Addon purchased with a subscription.');
10150
10346
  export const addonPagePaginatedResponseWire = z
10151
10347
  .strictObject({
10152
10348
  data: z.array(addonWire),
@@ -10203,18 +10399,80 @@ export const subscriptionWire = z
10203
10399
  .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
10400
  })
10205
10401
  .describe('Subscription.');
10206
- export const subscriptionAddonPagePaginatedResponseWire = z
10402
+ export const subscriptionCreateWire = z.strictObject({
10403
+ labels: labelsWire.optional(),
10404
+ settlement_mode: settlementModeWire.optional(),
10405
+ customer: z
10406
+ .strictObject({
10407
+ id: ulidWire.optional(),
10408
+ key: externalResourceKeyWire.optional(),
10409
+ })
10410
+ .describe('The customer to create the subscription for.'),
10411
+ plan: z
10412
+ .strictObject({
10413
+ id: ulidWire.optional(),
10414
+ key: resourceKeyWire.optional(),
10415
+ version: z
10416
+ .number()
10417
+ .int()
10418
+ .optional()
10419
+ .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
10420
+ })
10421
+ .optional()
10422
+ .describe('A reference to a published plan the subscription is created from. Exactly one of `plan` or `custom_plan` must be provided. Use `plan` to base the subscription on an existing published plan; use `custom_plan` to define the plan inline.'),
10423
+ custom_plan: subscriptionCustomPlanWire.optional(),
10424
+ billing_anchor: dateTimeWire.optional(),
10425
+ cost_basis_mode: subscriptionCostBasisModeWire.optional(),
10426
+ });
10427
+ export const subscriptionChangeWire = z
10207
10428
  .strictObject({
10208
- data: z.array(subscriptionAddonWire),
10209
- meta: paginatedMetaWire,
10429
+ labels: labelsWire.optional(),
10430
+ settlement_mode: settlementModeWire.optional(),
10431
+ customer: z
10432
+ .strictObject({
10433
+ id: ulidWire.optional(),
10434
+ key: externalResourceKeyWire.optional(),
10435
+ })
10436
+ .describe('The customer to create the subscription for.'),
10437
+ plan: z
10438
+ .strictObject({
10439
+ id: ulidWire.optional(),
10440
+ key: resourceKeyWire.optional(),
10441
+ version: z
10442
+ .number()
10443
+ .int()
10444
+ .optional()
10445
+ .describe('The plan version of the subscription, if any. If not provided, the latest version of the plan will be used.'),
10446
+ })
10447
+ .optional()
10448
+ .describe('A reference to a published plan the subscription is created from. Exactly one of `plan` or `custom_plan` must be provided. Use `plan` to base the subscription on an existing published plan; use `custom_plan` to define the plan inline.'),
10449
+ custom_plan: subscriptionCustomPlanWire.optional(),
10450
+ billing_anchor: dateTimeWire.optional(),
10451
+ cost_basis_mode: subscriptionCostBasisModeWire.optional(),
10452
+ timing: subscriptionEditTimingWire,
10210
10453
  })
10211
- .describe('Page paginated response.');
10454
+ .describe('Request for changing a subscription.');
10212
10455
  export const planPagePaginatedResponseWire = z
10213
10456
  .strictObject({
10214
10457
  data: z.array(planWire),
10215
10458
  meta: paginatedMetaWire,
10216
10459
  })
10217
10460
  .describe('Page paginated response.');
10461
+ export const subscriptionEditWire = z
10462
+ .strictObject({
10463
+ customizations: z
10464
+ .array(subscriptionEditOperationWire)
10465
+ .max(100)
10466
+ .describe('The ordered batch of customizations to apply to the running subscription.'),
10467
+ timing: subscriptionEditTimingWire.optional(),
10468
+ })
10469
+ .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.");
10470
+ export const subscriptionAddonPagePaginatedResponseWire = z
10471
+ .strictObject({
10472
+ data: z.array(subscriptionAddonWire),
10473
+ meta: paginatedMetaWire,
10474
+ })
10475
+ .describe('Page paginated response.');
10218
10476
  export const invoiceStandardWire = z
10219
10477
  .strictObject({
10220
10478
  id: ulidWire,
@@ -10676,6 +10934,11 @@ export const changeSubscriptionPathParamsWire = z.object({
10676
10934
  });
10677
10935
  export const changeSubscriptionBodyWire = subscriptionChangeWire;
10678
10936
  export const changeSubscriptionResponseWire = subscriptionChangeResponseWire;
10937
+ export const editSubscriptionPathParamsWire = z.object({
10938
+ subscriptionId: ulidWire,
10939
+ });
10940
+ export const editSubscriptionBodyWire = subscriptionEditWire;
10941
+ export const editSubscriptionResponseWire = subscriptionWire;
10679
10942
  export const createSubscriptionAddonPathParamsWire = z.object({
10680
10943
  subscriptionId: ulidWire,
10681
10944
  });