orb-billing 4.3.0 → 4.5.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/index.d.mts +4 -4
  3. package/index.d.ts +4 -4
  4. package/index.d.ts.map +1 -1
  5. package/index.js +1 -1
  6. package/index.js.map +1 -1
  7. package/index.mjs +1 -1
  8. package/index.mjs.map +1 -1
  9. package/package.json +1 -1
  10. package/resources/alerts.d.ts +25 -0
  11. package/resources/alerts.d.ts.map +1 -1
  12. package/resources/alerts.js +6 -0
  13. package/resources/alerts.js.map +1 -1
  14. package/resources/alerts.mjs +6 -0
  15. package/resources/alerts.mjs.map +1 -1
  16. package/resources/index.d.ts +2 -2
  17. package/resources/index.d.ts.map +1 -1
  18. package/resources/index.js +4 -4
  19. package/resources/index.js.map +1 -1
  20. package/resources/index.mjs +1 -1
  21. package/resources/index.mjs.map +1 -1
  22. package/resources/metrics.d.ts +24 -58
  23. package/resources/metrics.d.ts.map +1 -1
  24. package/resources/metrics.js +11 -5
  25. package/resources/metrics.js.map +1 -1
  26. package/resources/metrics.mjs +9 -3
  27. package/resources/metrics.mjs.map +1 -1
  28. package/resources/plans/plans.d.ts +55 -1
  29. package/resources/plans/plans.d.ts.map +1 -1
  30. package/resources/plans/plans.js.map +1 -1
  31. package/resources/plans/plans.mjs.map +1 -1
  32. package/resources/prices/prices.d.ts +124 -2
  33. package/resources/prices/prices.d.ts.map +1 -1
  34. package/resources/prices/prices.js.map +1 -1
  35. package/resources/prices/prices.mjs.map +1 -1
  36. package/resources/subscriptions.d.ts +54 -1
  37. package/resources/subscriptions.d.ts.map +1 -1
  38. package/resources/subscriptions.js.map +1 -1
  39. package/resources/subscriptions.mjs.map +1 -1
  40. package/src/index.ts +4 -4
  41. package/src/resources/alerts.ts +34 -0
  42. package/src/resources/index.ts +9 -9
  43. package/src/resources/metrics.ts +42 -72
  44. package/src/resources/plans/plans.ts +68 -0
  45. package/src/resources/prices/prices.ts +172 -2
  46. package/src/resources/subscriptions.ts +67 -0
  47. package/src/version.ts +1 -1
  48. package/version.d.ts +1 -1
  49. package/version.js +1 -1
  50. package/version.mjs +1 -1
@@ -14,10 +14,32 @@ export class Metrics extends APIResource {
14
14
  * [SQL support](../guides/extensibility/advanced-metrics#sql-support) for a
15
15
  * description of constructing SQL queries with examples.
16
16
  */
17
- create(body: MetricCreateParams, options?: Core.RequestOptions): Core.APIPromise<MetricCreateResponse> {
17
+ create(body: MetricCreateParams, options?: Core.RequestOptions): Core.APIPromise<BillableMetric> {
18
18
  return this._client.post('/metrics', { body, ...options });
19
19
  }
20
20
 
21
+ /**
22
+ * This endpoint allows you to update the `metadata` property on a metric. If you
23
+ * pass `null` for the metadata value, it will clear any existing metadata for that
24
+ * invoice.
25
+ */
26
+ update(
27
+ metricId: string,
28
+ body?: MetricUpdateParams,
29
+ options?: Core.RequestOptions,
30
+ ): Core.APIPromise<BillableMetric>;
31
+ update(metricId: string, options?: Core.RequestOptions): Core.APIPromise<BillableMetric>;
32
+ update(
33
+ metricId: string,
34
+ body: MetricUpdateParams | Core.RequestOptions = {},
35
+ options?: Core.RequestOptions,
36
+ ): Core.APIPromise<BillableMetric> {
37
+ if (isRequestOptions(body)) {
38
+ return this.update(metricId, {}, body);
39
+ }
40
+ return this._client.put(`/metrics/${metricId}`, { body, ...options });
41
+ }
42
+
21
43
  /**
22
44
  * This endpoint is used to fetch [metric](../guides/concepts#metric) details given
23
45
  * a metric identifier. It returns information about the metrics including its
@@ -26,95 +48,35 @@ export class Metrics extends APIResource {
26
48
  list(
27
49
  query?: MetricListParams,
28
50
  options?: Core.RequestOptions,
29
- ): Core.PagePromise<MetricListResponsesPage, MetricListResponse>;
30
- list(options?: Core.RequestOptions): Core.PagePromise<MetricListResponsesPage, MetricListResponse>;
51
+ ): Core.PagePromise<BillableMetricsPage, BillableMetric>;
52
+ list(options?: Core.RequestOptions): Core.PagePromise<BillableMetricsPage, BillableMetric>;
31
53
  list(
32
54
  query: MetricListParams | Core.RequestOptions = {},
33
55
  options?: Core.RequestOptions,
34
- ): Core.PagePromise<MetricListResponsesPage, MetricListResponse> {
56
+ ): Core.PagePromise<BillableMetricsPage, BillableMetric> {
35
57
  if (isRequestOptions(query)) {
36
58
  return this.list({}, query);
37
59
  }
38
- return this._client.getAPIList('/metrics', MetricListResponsesPage, { query, ...options });
60
+ return this._client.getAPIList('/metrics', BillableMetricsPage, { query, ...options });
39
61
  }
40
62
 
41
63
  /**
42
64
  * This endpoint is used to list [metrics](../guides/concepts##metric). It returns
43
65
  * information about the metrics including its name, description, and item.
44
66
  */
45
- fetch(metricId: string, options?: Core.RequestOptions): Core.APIPromise<MetricFetchResponse> {
67
+ fetch(metricId: string, options?: Core.RequestOptions): Core.APIPromise<BillableMetric> {
46
68
  return this._client.get(`/metrics/${metricId}`, options);
47
69
  }
48
70
  }
49
71
 
50
- export class MetricListResponsesPage extends Page<MetricListResponse> {}
72
+ export class BillableMetricsPage extends Page<BillableMetric> {}
51
73
 
52
74
  /**
53
75
  * The Metric resource represents a calculation of a quantity based on events.
54
76
  * Metrics are defined by the query that transforms raw usage events into
55
77
  * meaningful values for your customers.
56
78
  */
57
- export interface MetricCreateResponse {
58
- id: string;
59
-
60
- description: string | null;
61
-
62
- /**
63
- * The Item resource represents a sellable product or good. Items are associated
64
- * with all line items, billable metrics, and prices and are used for defining
65
- * external sync behavior for invoices and tax calculation purposes.
66
- */
67
- item: ItemsAPI.Item;
68
-
69
- /**
70
- * User specified key-value pairs for the resource. If not present, this defaults
71
- * to an empty dictionary. Individual keys can be removed by setting the value to
72
- * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
73
- * `null`.
74
- */
75
- metadata: Record<string, string>;
76
-
77
- name: string;
78
-
79
- status: 'active' | 'draft' | 'archived';
80
- }
81
-
82
- /**
83
- * The Metric resource represents a calculation of a quantity based on events.
84
- * Metrics are defined by the query that transforms raw usage events into
85
- * meaningful values for your customers.
86
- */
87
- export interface MetricListResponse {
88
- id: string;
89
-
90
- description: string | null;
91
-
92
- /**
93
- * The Item resource represents a sellable product or good. Items are associated
94
- * with all line items, billable metrics, and prices and are used for defining
95
- * external sync behavior for invoices and tax calculation purposes.
96
- */
97
- item: ItemsAPI.Item;
98
-
99
- /**
100
- * User specified key-value pairs for the resource. If not present, this defaults
101
- * to an empty dictionary. Individual keys can be removed by setting the value to
102
- * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
103
- * `null`.
104
- */
105
- metadata: Record<string, string>;
106
-
107
- name: string;
108
-
109
- status: 'active' | 'draft' | 'archived';
110
- }
111
-
112
- /**
113
- * The Metric resource represents a calculation of a quantity based on events.
114
- * Metrics are defined by the query that transforms raw usage events into
115
- * meaningful values for your customers.
116
- */
117
- export interface MetricFetchResponse {
79
+ export interface BillableMetric {
118
80
  id: string;
119
81
 
120
82
  description: string | null;
@@ -168,6 +130,15 @@ export interface MetricCreateParams {
168
130
  metadata?: Record<string, string | null> | null;
169
131
  }
170
132
 
133
+ export interface MetricUpdateParams {
134
+ /**
135
+ * User-specified key/value pairs for the resource. Individual keys can be removed
136
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
137
+ * by setting `metadata` to `null`.
138
+ */
139
+ metadata?: Record<string, string | null> | null;
140
+ }
141
+
171
142
  export interface MetricListParams extends PageParams {
172
143
  'created_at[gt]'?: string | null;
173
144
 
@@ -179,10 +150,9 @@ export interface MetricListParams extends PageParams {
179
150
  }
180
151
 
181
152
  export namespace Metrics {
182
- export import MetricCreateResponse = MetricsAPI.MetricCreateResponse;
183
- export import MetricListResponse = MetricsAPI.MetricListResponse;
184
- export import MetricFetchResponse = MetricsAPI.MetricFetchResponse;
185
- export import MetricListResponsesPage = MetricsAPI.MetricListResponsesPage;
153
+ export import BillableMetric = MetricsAPI.BillableMetric;
154
+ export import BillableMetricsPage = MetricsAPI.BillableMetricsPage;
186
155
  export import MetricCreateParams = MetricsAPI.MetricCreateParams;
156
+ export import MetricUpdateParams = MetricsAPI.MetricUpdateParams;
187
157
  export import MetricListParams = MetricsAPI.MetricListParams;
188
158
  }
@@ -319,6 +319,7 @@ export interface PlanCreateParams {
319
319
  | PlanCreateParams.NewPlanTierWithProrationPrice
320
320
  | PlanCreateParams.NewPlanUnitWithProrationPrice
321
321
  | PlanCreateParams.NewPlanGroupedAllocationPrice
322
+ | PlanCreateParams.NewPlanBulkWithProrationPrice
322
323
  >;
323
324
 
324
325
  /**
@@ -1608,6 +1609,73 @@ export namespace PlanCreateParams {
1608
1609
  */
1609
1610
  metadata?: Record<string, string | null> | null;
1610
1611
  }
1612
+
1613
+ export interface NewPlanBulkWithProrationPrice {
1614
+ bulk_with_proration_config: Record<string, unknown>;
1615
+
1616
+ /**
1617
+ * The cadence to bill for this price on.
1618
+ */
1619
+ cadence: 'annual' | 'semi_annual' | 'monthly' | 'quarterly' | 'one_time' | 'custom';
1620
+
1621
+ /**
1622
+ * The id of the item the plan will be associated with.
1623
+ */
1624
+ item_id: string;
1625
+
1626
+ model_type: 'bulk_with_proration';
1627
+
1628
+ /**
1629
+ * The name of the price.
1630
+ */
1631
+ name: string;
1632
+
1633
+ /**
1634
+ * The id of the billable metric for the price. Only needed if the price is
1635
+ * usage-based.
1636
+ */
1637
+ billable_metric_id?: string | null;
1638
+
1639
+ /**
1640
+ * If the Price represents a fixed cost, the price will be billed in-advance if
1641
+ * this is true, and in-arrears if this is false.
1642
+ */
1643
+ billed_in_advance?: boolean | null;
1644
+
1645
+ /**
1646
+ * The per unit conversion rate of the price currency to the invoicing currency.
1647
+ */
1648
+ conversion_rate?: number | null;
1649
+
1650
+ /**
1651
+ * An ISO 4217 currency string, or custom pricing unit identifier, in which this
1652
+ * price is billed.
1653
+ */
1654
+ currency?: string | null;
1655
+
1656
+ /**
1657
+ * An alias for the price.
1658
+ */
1659
+ external_price_id?: string | null;
1660
+
1661
+ /**
1662
+ * If the Price represents a fixed cost, this represents the quantity of units
1663
+ * applied.
1664
+ */
1665
+ fixed_price_quantity?: number | null;
1666
+
1667
+ /**
1668
+ * The property used to group this price on an invoice
1669
+ */
1670
+ invoice_grouping_key?: string | null;
1671
+
1672
+ /**
1673
+ * User-specified key/value pairs for the resource. Individual keys can be removed
1674
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
1675
+ * by setting `metadata` to `null`.
1676
+ */
1677
+ metadata?: Record<string, string | null> | null;
1678
+ }
1611
1679
  }
1612
1680
 
1613
1681
  export interface PlanUpdateParams {
@@ -371,7 +371,8 @@ export type Price =
371
371
  | Price.MatrixWithAllocationPrice
372
372
  | Price.TieredWithProrationPrice
373
373
  | Price.UnitWithProrationPrice
374
- | Price.GroupedAllocationPrice;
374
+ | Price.GroupedAllocationPrice
375
+ | Price.BulkWithProrationPrice;
375
376
 
376
377
  export namespace Price {
377
378
  export interface UnitPrice {
@@ -2520,6 +2521,108 @@ export namespace Price {
2520
2521
  minimum_amount: string;
2521
2522
  }
2522
2523
  }
2524
+
2525
+ export interface BulkWithProrationPrice {
2526
+ id: string;
2527
+
2528
+ billable_metric: BulkWithProrationPrice.BillableMetric | null;
2529
+
2530
+ billing_cycle_configuration: BulkWithProrationPrice.BillingCycleConfiguration | null;
2531
+
2532
+ bulk_with_proration_config: Record<string, unknown>;
2533
+
2534
+ cadence: 'one_time' | 'monthly' | 'quarterly' | 'semi_annual' | 'annual' | 'custom';
2535
+
2536
+ conversion_rate: number | null;
2537
+
2538
+ created_at: string;
2539
+
2540
+ credit_allocation: BulkWithProrationPrice.CreditAllocation | null;
2541
+
2542
+ currency: string;
2543
+
2544
+ discount: Shared.Discount | null;
2545
+
2546
+ external_price_id: string | null;
2547
+
2548
+ fixed_price_quantity: number | null;
2549
+
2550
+ item: BulkWithProrationPrice.Item;
2551
+
2552
+ maximum: BulkWithProrationPrice.Maximum | null;
2553
+
2554
+ maximum_amount: string | null;
2555
+
2556
+ /**
2557
+ * User specified key-value pairs for the resource. If not present, this defaults
2558
+ * to an empty dictionary. Individual keys can be removed by setting the value to
2559
+ * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
2560
+ * `null`.
2561
+ */
2562
+ metadata: Record<string, string>;
2563
+
2564
+ minimum: BulkWithProrationPrice.Minimum | null;
2565
+
2566
+ minimum_amount: string | null;
2567
+
2568
+ model_type: 'bulk_with_proration';
2569
+
2570
+ name: string;
2571
+
2572
+ plan_phase_order: number | null;
2573
+
2574
+ price_type: 'usage_price' | 'fixed_price';
2575
+ }
2576
+
2577
+ export namespace BulkWithProrationPrice {
2578
+ export interface BillableMetric {
2579
+ id: string;
2580
+ }
2581
+
2582
+ export interface BillingCycleConfiguration {
2583
+ duration: number;
2584
+
2585
+ duration_unit: 'day' | 'month';
2586
+ }
2587
+
2588
+ export interface CreditAllocation {
2589
+ allows_rollover: boolean;
2590
+
2591
+ currency: string;
2592
+ }
2593
+
2594
+ export interface Item {
2595
+ id: string;
2596
+
2597
+ name: string;
2598
+ }
2599
+
2600
+ export interface Maximum {
2601
+ /**
2602
+ * List of price_ids that this maximum amount applies to. For plan/plan phase
2603
+ * maximums, this can be a subset of prices.
2604
+ */
2605
+ applies_to_price_ids: Array<string>;
2606
+
2607
+ /**
2608
+ * Maximum amount applied
2609
+ */
2610
+ maximum_amount: string;
2611
+ }
2612
+
2613
+ export interface Minimum {
2614
+ /**
2615
+ * List of price_ids that this minimum amount applies to. For plan/plan phase
2616
+ * minimums, this can be a subset of prices.
2617
+ */
2618
+ applies_to_price_ids: Array<string>;
2619
+
2620
+ /**
2621
+ * Minimum amount applied
2622
+ */
2623
+ minimum_amount: string;
2624
+ }
2625
+ }
2523
2626
  }
2524
2627
 
2525
2628
  export interface PriceEvaluateResponse {
@@ -2545,7 +2648,8 @@ export type PriceCreateParams =
2545
2648
  | PriceCreateParams.NewFloatingUnitWithPercentPrice
2546
2649
  | PriceCreateParams.NewFloatingTieredWithProrationPrice
2547
2650
  | PriceCreateParams.NewFloatingUnitWithProrationPrice
2548
- | PriceCreateParams.NewFloatingGroupedAllocationPrice;
2651
+ | PriceCreateParams.NewFloatingGroupedAllocationPrice
2652
+ | PriceCreateParams.NewFloatingBulkWithProrationPrice;
2549
2653
 
2550
2654
  export namespace PriceCreateParams {
2551
2655
  export interface NewFloatingUnitPrice {
@@ -4028,6 +4132,72 @@ export namespace PriceCreateParams {
4028
4132
  */
4029
4133
  metadata?: Record<string, string | null> | null;
4030
4134
  }
4135
+
4136
+ export interface NewFloatingBulkWithProrationPrice {
4137
+ bulk_with_proration_config: Record<string, unknown>;
4138
+
4139
+ /**
4140
+ * The cadence to bill for this price on.
4141
+ */
4142
+ cadence: 'annual' | 'semi_annual' | 'monthly' | 'quarterly' | 'one_time' | 'custom';
4143
+
4144
+ /**
4145
+ * An ISO 4217 currency string for which this price is billed in.
4146
+ */
4147
+ currency: string;
4148
+
4149
+ /**
4150
+ * The id of the item the plan will be associated with.
4151
+ */
4152
+ item_id: string;
4153
+
4154
+ model_type: 'bulk_with_proration';
4155
+
4156
+ /**
4157
+ * The name of the price.
4158
+ */
4159
+ name: string;
4160
+
4161
+ /**
4162
+ * The id of the billable metric for the price. Only needed if the price is
4163
+ * usage-based.
4164
+ */
4165
+ billable_metric_id?: string | null;
4166
+
4167
+ /**
4168
+ * If the Price represents a fixed cost, the price will be billed in-advance if
4169
+ * this is true, and in-arrears if this is false.
4170
+ */
4171
+ billed_in_advance?: boolean | null;
4172
+
4173
+ /**
4174
+ * The per unit conversion rate of the price currency to the invoicing currency.
4175
+ */
4176
+ conversion_rate?: number | null;
4177
+
4178
+ /**
4179
+ * An alias for the price.
4180
+ */
4181
+ external_price_id?: string | null;
4182
+
4183
+ /**
4184
+ * If the Price represents a fixed cost, this represents the quantity of units
4185
+ * applied.
4186
+ */
4187
+ fixed_price_quantity?: number | null;
4188
+
4189
+ /**
4190
+ * The property used to group this price on an invoice
4191
+ */
4192
+ invoice_grouping_key?: string | null;
4193
+
4194
+ /**
4195
+ * User-specified key/value pairs for the resource. Individual keys can be removed
4196
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
4197
+ * by setting `metadata` to `null`.
4198
+ */
4199
+ metadata?: Record<string, string | null> | null;
4200
+ }
4031
4201
  }
4032
4202
 
4033
4203
  export interface PriceUpdateParams {
@@ -3672,6 +3672,7 @@ export namespace SubscriptionPriceIntervalsParams {
3672
3672
  | Add.NewFloatingTieredWithProrationPrice
3673
3673
  | Add.NewFloatingUnitWithProrationPrice
3674
3674
  | Add.NewFloatingGroupedAllocationPrice
3675
+ | Add.NewFloatingBulkWithProrationPrice
3675
3676
  | null;
3676
3677
 
3677
3678
  /**
@@ -5229,6 +5230,72 @@ export namespace SubscriptionPriceIntervalsParams {
5229
5230
  */
5230
5231
  metadata?: Record<string, string | null> | null;
5231
5232
  }
5233
+
5234
+ export interface NewFloatingBulkWithProrationPrice {
5235
+ bulk_with_proration_config: Record<string, unknown>;
5236
+
5237
+ /**
5238
+ * The cadence to bill for this price on.
5239
+ */
5240
+ cadence: 'annual' | 'semi_annual' | 'monthly' | 'quarterly' | 'one_time' | 'custom';
5241
+
5242
+ /**
5243
+ * An ISO 4217 currency string for which this price is billed in.
5244
+ */
5245
+ currency: string;
5246
+
5247
+ /**
5248
+ * The id of the item the plan will be associated with.
5249
+ */
5250
+ item_id: string;
5251
+
5252
+ model_type: 'bulk_with_proration';
5253
+
5254
+ /**
5255
+ * The name of the price.
5256
+ */
5257
+ name: string;
5258
+
5259
+ /**
5260
+ * The id of the billable metric for the price. Only needed if the price is
5261
+ * usage-based.
5262
+ */
5263
+ billable_metric_id?: string | null;
5264
+
5265
+ /**
5266
+ * If the Price represents a fixed cost, the price will be billed in-advance if
5267
+ * this is true, and in-arrears if this is false.
5268
+ */
5269
+ billed_in_advance?: boolean | null;
5270
+
5271
+ /**
5272
+ * The per unit conversion rate of the price currency to the invoicing currency.
5273
+ */
5274
+ conversion_rate?: number | null;
5275
+
5276
+ /**
5277
+ * An alias for the price.
5278
+ */
5279
+ external_price_id?: string | null;
5280
+
5281
+ /**
5282
+ * If the Price represents a fixed cost, this represents the quantity of units
5283
+ * applied.
5284
+ */
5285
+ fixed_price_quantity?: number | null;
5286
+
5287
+ /**
5288
+ * The property used to group this price on an invoice
5289
+ */
5290
+ invoice_grouping_key?: string | null;
5291
+
5292
+ /**
5293
+ * User-specified key/value pairs for the resource. Individual keys can be removed
5294
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
5295
+ * by setting `metadata` to `null`.
5296
+ */
5297
+ metadata?: Record<string, string | null> | null;
5298
+ }
5232
5299
  }
5233
5300
 
5234
5301
  export interface AddAdjustment {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.3.0'; // x-release-please-version
1
+ export const VERSION = '4.5.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.3.0";
1
+ export declare const VERSION = "4.5.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '4.3.0'; // x-release-please-version
4
+ exports.VERSION = '4.5.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '4.3.0'; // x-release-please-version
1
+ export const VERSION = '4.5.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map