orb-billing 1.22.0 → 1.24.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 (107) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/core.d.ts.map +1 -1
  3. package/core.js +8 -10
  4. package/core.js.map +1 -1
  5. package/core.mjs +8 -10
  6. package/core.mjs.map +1 -1
  7. package/index.d.mts +2 -2
  8. package/index.d.ts +2 -2
  9. package/index.d.ts.map +1 -1
  10. package/index.js +4 -0
  11. package/index.js.map +1 -1
  12. package/index.mjs +4 -0
  13. package/index.mjs.map +1 -1
  14. package/package.json +3 -1
  15. package/resources/coupons/coupons.d.ts +60 -2
  16. package/resources/coupons/coupons.d.ts.map +1 -1
  17. package/resources/coupons/coupons.js.map +1 -1
  18. package/resources/coupons/coupons.mjs.map +1 -1
  19. package/resources/credit-notes.d.ts +57 -5
  20. package/resources/credit-notes.d.ts.map +1 -1
  21. package/resources/credit-notes.js.map +1 -1
  22. package/resources/credit-notes.mjs.map +1 -1
  23. package/resources/customers/balance-transactions.d.ts +2 -2
  24. package/resources/customers/balance-transactions.d.ts.map +1 -1
  25. package/resources/customers/balance-transactions.js.map +1 -1
  26. package/resources/customers/balance-transactions.mjs.map +1 -1
  27. package/resources/customers/customers.d.ts +696 -8
  28. package/resources/customers/customers.d.ts.map +1 -1
  29. package/resources/customers/customers.js.map +1 -1
  30. package/resources/customers/customers.mjs.map +1 -1
  31. package/resources/customers/usage.d.ts +74 -58
  32. package/resources/customers/usage.d.ts.map +1 -1
  33. package/resources/customers/usage.js +14 -14
  34. package/resources/customers/usage.js.map +1 -1
  35. package/resources/customers/usage.mjs +14 -14
  36. package/resources/customers/usage.mjs.map +1 -1
  37. package/resources/events/events.d.ts +40 -40
  38. package/resources/events/events.js +40 -40
  39. package/resources/events/events.mjs +40 -40
  40. package/resources/index.d.ts +4 -3
  41. package/resources/index.d.ts.map +1 -1
  42. package/resources/index.js +19 -4
  43. package/resources/index.js.map +1 -1
  44. package/resources/index.mjs +2 -1
  45. package/resources/index.mjs.map +1 -1
  46. package/resources/invoice-line-items.d.ts +2 -2
  47. package/resources/invoice-line-items.d.ts.map +1 -1
  48. package/resources/invoices.d.ts +358 -71
  49. package/resources/invoices.d.ts.map +1 -1
  50. package/resources/invoices.js.map +1 -1
  51. package/resources/invoices.mjs.map +1 -1
  52. package/resources/plans/plans.d.ts +648 -4
  53. package/resources/plans/plans.d.ts.map +1 -1
  54. package/resources/plans/plans.js.map +1 -1
  55. package/resources/plans/plans.mjs.map +1 -1
  56. package/resources/prices/index.d.ts +1 -1
  57. package/resources/prices/index.d.ts.map +1 -1
  58. package/resources/prices/index.js +3 -3
  59. package/resources/prices/index.js.map +1 -1
  60. package/resources/prices/index.mjs +1 -1
  61. package/resources/prices/index.mjs.map +1 -1
  62. package/resources/prices/prices.d.ts +56 -83
  63. package/resources/prices/prices.d.ts.map +1 -1
  64. package/resources/prices/prices.js.map +1 -1
  65. package/resources/prices/prices.mjs.map +1 -1
  66. package/resources/shared.d.ts +62 -0
  67. package/resources/shared.d.ts.map +1 -0
  68. package/resources/shared.js +4 -0
  69. package/resources/shared.js.map +1 -0
  70. package/resources/shared.mjs +3 -0
  71. package/resources/shared.mjs.map +1 -0
  72. package/resources/subscriptions.d.ts +1084 -241
  73. package/resources/subscriptions.d.ts.map +1 -1
  74. package/resources/subscriptions.js.map +1 -1
  75. package/resources/subscriptions.mjs.map +1 -1
  76. package/src/_shims/index.d.ts +1 -1
  77. package/src/_shims/index.mjs +1 -1
  78. package/src/core.ts +8 -12
  79. package/src/index.ts +8 -3
  80. package/src/resources/coupons/coupons.ts +82 -8
  81. package/src/resources/coupons/subscriptions.ts +7 -7
  82. package/src/resources/credit-notes.ts +86 -10
  83. package/src/resources/customers/balance-transactions.ts +23 -7
  84. package/src/resources/customers/costs.ts +5 -5
  85. package/src/resources/customers/credits/credits.ts +6 -6
  86. package/src/resources/customers/credits/ledger.ts +5 -5
  87. package/src/resources/customers/customers.ts +1153 -21
  88. package/src/resources/customers/usage.ts +83 -65
  89. package/src/resources/events/backfills.ts +5 -5
  90. package/src/resources/events/events.ts +45 -45
  91. package/src/resources/index.ts +3 -3
  92. package/src/resources/invoice-line-items.ts +6 -6
  93. package/src/resources/invoices.ts +604 -97
  94. package/src/resources/items.ts +5 -5
  95. package/src/resources/metrics.ts +5 -5
  96. package/src/resources/plans/external-plan-id.ts +5 -5
  97. package/src/resources/plans/plans.ts +817 -11
  98. package/src/resources/prices/external-price-id.ts +3 -3
  99. package/src/resources/prices/index.ts +1 -1
  100. package/src/resources/prices/prices.ts +73 -106
  101. package/src/resources/shared.ts +84 -0
  102. package/src/resources/subscriptions.ts +1299 -287
  103. package/src/resources/top-level.ts +3 -3
  104. package/src/version.ts +1 -1
  105. package/version.d.ts +1 -1
  106. package/version.js +1 -1
  107. package/version.mjs +1 -1
@@ -1,8 +1,8 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from "../../ling/core";
4
- import { APIResource } from "../../ling/resource";
5
- import * as UsageAPI from "../../ling/resources/customers/usage";
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import * as UsageAPI from "./usage";
6
6
 
7
7
  export class Usage extends APIResource {
8
8
  /**
@@ -10,7 +10,7 @@ export class Usage extends APIResource {
10
10
  * an active subscription.
11
11
  *
12
12
  * This endpoint will mark _all_ existing events within
13
- * `[timeframe_start, timeframe_end)` as _ignored_ for billing purpo ses, and Orb
13
+ * `[timeframe_start, timeframe_end)` as _ignored_ for billing purposes, and Orb
14
14
  * will only use the _new_ events passed in the body of this request as the source
15
15
  * of truth for that timeframe moving forwards. Note that a given time period can
16
16
  * be amended any number of times, so events can be overwritten in subsequent calls
@@ -22,7 +22,7 @@ export class Usage extends APIResource {
22
22
  * - decrease historical usage consumption because of degraded service availability
23
23
  * in your systems
24
24
  * - account for gaps from your usage reporting mechanism
25
- * - make point-in-time fixes for specific event records, while ret aining the
25
+ * - make point-in-time fixes for specific event records, while retaining the
26
26
  * original time of usage and associated metadata. This amendment API is designed
27
27
  * with two explicit goals:
28
28
  *
@@ -30,10 +30,10 @@ export class Usage extends APIResource {
30
30
  * original events in the timeframe, though they will be ignored for billing
31
31
  * calculations. For auditing a nd data fidelity purposes, Orb never overwrites
32
32
  * or permanently deletes ingested usage data.
33
- * 2. Amendments always preser ve data **consistency**. In other words, either an
34
- * amendment is fully processed by the system (and the new events for th e
33
+ * 2. Amendments always preserve data **consistency**. In other words, either an
34
+ * amendment is fully processed by the system (and the new events for the
35
35
  * timeframe are honored rather than the existing ones) or the amendment request
36
- * fails. To maintain this important proper ty, Orb prevents _partial event
36
+ * fails. To maintain this important property, Orb prevents _partial event
37
37
  * ingestion_ on this endpoint.
38
38
  *
39
39
  * ## Response semantics
@@ -45,12 +45,12 @@ export class Usage extends APIResource {
45
45
  * also not deprecate existing events in the time period.
46
46
  * - You can assume that the amendment is successful on receipt of a `2xx`
47
47
  * response.While a successful response from this endpoint indicates that the new
48
- * events have been ingested, updati ng usage totals happens asynchronously and
48
+ * events have been ingested, updating usage totals happens asynchronously and
49
49
  * may be delayed by a few minutes.
50
50
  *
51
51
  * As emphasized above, Orb will never show an inconsistent state (e.g. in invoice
52
52
  * previews or dashboards); either it will show the existing state (before the
53
- * amend ment) or the new state (with new events in the requested timeframe).
53
+ * amendment) or the new state (with new events in the requested timeframe).
54
54
  *
55
55
  * ## Sample request body
56
56
  *
@@ -121,7 +121,7 @@ export class Usage extends APIResource {
121
121
  * an active subscription.
122
122
  *
123
123
  * This endpoint will mark _all_ existing events within
124
- * `[timeframe_start, timeframe_end)` as _ignored_ for billing purpo ses, and Orb
124
+ * `[timeframe_start, timeframe_end)` as _ignored_ for billing purposes, and Orb
125
125
  * will only use the _new_ events passed in the body of this request as the source
126
126
  * of truth for that timeframe moving forwards. Note that a given time period can
127
127
  * be amended any number of times, so events can be overwritten in subsequent calls
@@ -133,7 +133,7 @@ export class Usage extends APIResource {
133
133
  * - decrease historical usage consumption because of degraded service availability
134
134
  * in your systems
135
135
  * - account for gaps from your usage reporting mechanism
136
- * - make point-in-time fixes for specific event records, while ret aining the
136
+ * - make point-in-time fixes for specific event records, while retaining the
137
137
  * original time of usage and associated metadata. This amendment API is designed
138
138
  * with two explicit goals:
139
139
  *
@@ -141,10 +141,10 @@ export class Usage extends APIResource {
141
141
  * original events in the timeframe, though they will be ignored for billing
142
142
  * calculations. For auditing a nd data fidelity purposes, Orb never overwrites
143
143
  * or permanently deletes ingested usage data.
144
- * 2. Amendments always preser ve data **consistency**. In other words, either an
145
- * amendment is fully processed by the system (and the new events for th e
144
+ * 2. Amendments always preserve data **consistency**. In other words, either an
145
+ * amendment is fully processed by the system (and the new events for the
146
146
  * timeframe are honored rather than the existing ones) or the amendment request
147
- * fails. To maintain this important proper ty, Orb prevents _partial event
147
+ * fails. To maintain this important property, Orb prevents _partial event
148
148
  * ingestion_ on this endpoint.
149
149
  *
150
150
  * ## Response semantics
@@ -156,12 +156,12 @@ export class Usage extends APIResource {
156
156
  * also not deprecate existing events in the time period.
157
157
  * - You can assume that the amendment is successful on receipt of a `2xx`
158
158
  * response.While a successful response from this endpoint indicates that the new
159
- * events have been ingested, updati ng usage totals happens asynchronously and
159
+ * events have been ingested, updating usage totals happens asynchronously and
160
160
  * may be delayed by a few minutes.
161
161
  *
162
162
  * As emphasized above, Orb will never show an inconsistent state (e.g. in invoice
163
163
  * previews or dashboards); either it will show the existing state (before the
164
- * amend ment) or the new state (with new events in the requested timeframe).
164
+ * amendment) or the new state (with new events in the requested timeframe).
165
165
  *
166
166
  * ## Sample request body
167
167
  *
@@ -258,22 +258,9 @@ export interface UsageUpdateByExternalIDResponse {
258
258
 
259
259
  export interface UsageUpdateParams {
260
260
  /**
261
- * Body param: A name to meaningfully identify the action or event type.
261
+ * Body param: Events to update
262
262
  */
263
- event_name: string;
264
-
265
- /**
266
- * Body param: A dictionary of custom properties. Values in this dictionary must be
267
- * numeric, boolean, or strings. Nested dictionaries are disallowed.
268
- */
269
- properties: unknown;
270
-
271
- /**
272
- * Body param: An ISO 8601 format date with no timezone offset (i.e. UTC). This
273
- * should represent the time that usage was recorded, and is particularly important
274
- * to attribute usage to a given billing period.
275
- */
276
- timestamp: string;
263
+ events: Array<UsageUpdateParams.Event>;
277
264
 
278
265
  /**
279
266
  * Query param: This bound is exclusive (i.e. events before this timestamp will be
@@ -286,37 +273,46 @@ export interface UsageUpdateParams {
286
273
  * inclusive will be updated)
287
274
  */
288
275
  timeframe_start?: string;
276
+ }
289
277
 
290
- /**
291
- * Body param: The Orb Customer identifier
292
- */
293
- customer_id?: string | null;
278
+ export namespace UsageUpdateParams {
279
+ export interface Event {
280
+ /**
281
+ * A name to meaningfully identify the action or event type.
282
+ */
283
+ event_name: string;
294
284
 
295
- /**
296
- * Body param: An alias for the Orb customer, whose mapping is specified when
297
- * creating the customer
298
- */
299
- external_customer_id?: string | null;
300
- }
285
+ /**
286
+ * A dictionary of custom properties. Values in this dictionary must be numeric,
287
+ * boolean, or strings. Nested dictionaries are disallowed.
288
+ */
289
+ properties: unknown;
301
290
 
302
- export interface UsageUpdateByExternalIDParams {
303
- /**
304
- * Body param: A name to meaningfully identify the action or event type.
305
- */
306
- event_name: string;
291
+ /**
292
+ * An ISO 8601 format date with no timezone offset (i.e. UTC). This should
293
+ * represent the time that usage was recorded, and is particularly important to
294
+ * attribute usage to a given billing period.
295
+ */
296
+ timestamp: string;
307
297
 
308
- /**
309
- * Body param: A dictionary of custom properties. Values in this dictionary must be
310
- * numeric, boolean, or strings. Nested dictionaries are disallowed.
311
- */
312
- properties: unknown;
298
+ /**
299
+ * The Orb Customer identifier
300
+ */
301
+ customer_id?: string | null;
302
+
303
+ /**
304
+ * An alias for the Orb customer, whose mapping is specified when creating the
305
+ * customer
306
+ */
307
+ external_customer_id?: string | null;
308
+ }
309
+ }
313
310
 
311
+ export interface UsageUpdateByExternalIDParams {
314
312
  /**
315
- * Body param: An ISO 8601 format date with no timezone offset (i.e. UTC). This
316
- * should represent the time that usage was recorded, and is particularly important
317
- * to attribute usage to a given billing period.
313
+ * Body param: Events to update
318
314
  */
319
- timestamp: string;
315
+ events: Array<UsageUpdateByExternalIDParams.Event>;
320
316
 
321
317
  /**
322
318
  * Query param: This bound is exclusive (i.e. events before this timestamp will be
@@ -329,17 +325,39 @@ export interface UsageUpdateByExternalIDParams {
329
325
  * inclusive will be updated)
330
326
  */
331
327
  timeframe_start?: string;
328
+ }
332
329
 
333
- /**
334
- * Body param: The Orb Customer identifier
335
- */
336
- customer_id?: string | null;
330
+ export namespace UsageUpdateByExternalIDParams {
331
+ export interface Event {
332
+ /**
333
+ * A name to meaningfully identify the action or event type.
334
+ */
335
+ event_name: string;
337
336
 
338
- /**
339
- * Body param: An alias for the Orb customer, whose mapping is specified when
340
- * creating the customer
341
- */
342
- external_customer_id?: string | null;
337
+ /**
338
+ * A dictionary of custom properties. Values in this dictionary must be numeric,
339
+ * boolean, or strings. Nested dictionaries are disallowed.
340
+ */
341
+ properties: unknown;
342
+
343
+ /**
344
+ * An ISO 8601 format date with no timezone offset (i.e. UTC). This should
345
+ * represent the time that usage was recorded, and is particularly important to
346
+ * attribute usage to a given billing period.
347
+ */
348
+ timestamp: string;
349
+
350
+ /**
351
+ * The Orb Customer identifier
352
+ */
353
+ customer_id?: string | null;
354
+
355
+ /**
356
+ * An alias for the Orb customer, whose mapping is specified when creating the
357
+ * customer
358
+ */
359
+ external_customer_id?: string | null;
360
+ }
343
361
  }
344
362
 
345
363
  export namespace Usage {
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from "../../ling/core";
4
- import { APIResource } from "../../ling/resource";
5
- import { isRequestOptions } from "../../ling/core";
6
- import * as BackfillsAPI from "../../ling/resources/events/backfills";
7
- import { Page, type PageParams } from "../../ling/pagination";
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import { isRequestOptions } from "../../core";
6
+ import * as BackfillsAPI from "./backfills";
7
+ import { Page, type PageParams } from "../../pagination";
8
8
 
9
9
  export class Backfills extends APIResource {
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from "../../ling/core";
4
- import { APIResource } from "../../ling/resource";
5
- import { isRequestOptions } from "../../ling/core";
6
- import * as EventsAPI from "../../ling/resources/events/events";
7
- import * as BackfillsAPI from "../../ling/resources/events/backfills";
3
+ import * as Core from "../../core";
4
+ import { APIResource } from "../../resource";
5
+ import { isRequestOptions } from "../../core";
6
+ import * as EventsAPI from "./events";
7
+ import * as BackfillsAPI from "./backfills";
8
8
 
9
9
  export class Events extends APIResource {
10
10
  backfills: BackfillsAPI.Backfills = new BackfillsAPI.Backfills(this.client);
@@ -120,47 +120,47 @@ export class Events extends APIResource {
120
120
  * Events are the starting point for all usage calculations in the system, and are
121
121
  * simple at their core:
122
122
  *
123
- * ```json
123
+ * ```ts
124
124
  * {
125
- * // customer_id and external_customer_id are used to
126
- * // attribute usage to a given Customer. Exactly one of these
127
- * // should be specified in a given ingestion event.
128
- *
129
- * // `customer_id` is the Orb generated identifier for the Customer,
130
- * // which is returned from the Create customer API call.
131
- * customer_id: string,
132
- *
133
- * // external_customer_id is an alternate identifier which is associated
134
- * // with a Customer at creation time. This is treated as an alias for
135
- * // customer_id, and is usually set to an identifier native to your system.
136
- * external_customer_id: string,
137
- *
138
- * // A string name identifying the event, usually a usage
139
- * // action. By convention, this should not contain any whitespace.
140
- * event_name: string,
141
- *
142
- * // An ISO 8601 format date with no timezone offset.
143
- * // This should represent the time that usage occurred
144
- * // and is important to attribute usage to a given
145
- * // billing period. See the notes below on determining the timestamp.
146
- * // e.g. 2020-12-09T16:09:53Z
147
- * timestamp: string,
148
- *
149
- * // A unique value, generated by the client, that is
150
- * // used to de-duplicate events.
151
- * // Exactly one event with a given
152
- * // idempotency key will be ingested, which allows for
153
- * // safe request retries.
154
- * idempotency_key: string
155
- *
156
- * // Optional custom metadata to attach to the event.
157
- * // This might include a numeric value used for aggregation,
158
- * // or a string/boolean value used for filtering.
159
- * // The schema of this dictionary need not be pre-declared, and
160
- * // properties can be added at any time.
161
- * properties: {
162
- * [key: string]?: string | number | boolean,
163
- * },
125
+ * // customer_id and external_customer_id are used to
126
+ * // attribute usage to a given Customer. Exactly one of these
127
+ * // should be specified in a given ingestion event.
128
+ *
129
+ * // `customer_id` is the Orb generated identifier for the Customer,
130
+ * // which is returned from the Create customer API call.
131
+ * customer_id: string,
132
+ *
133
+ * // external_customer_id is an alternate identifier which is associated
134
+ * // with a Customer at creation time. This is treated as an alias for
135
+ * // customer_id, and is usually set to an identifier native to your system.
136
+ * external_customer_id: string,
137
+ *
138
+ * // A string name identifying the event, usually a usage
139
+ * // action. By convention, this should not contain any whitespace.
140
+ * event_name: string,
141
+ *
142
+ * // An ISO 8601 format date with no timezone offset.
143
+ * // This should represent the time that usage occurred
144
+ * // and is important to attribute usage to a given
145
+ * // billing period. See the notes below on determining the timestamp.
146
+ * // e.g. 2020-12-09T16:09:53Z
147
+ * timestamp: string,
148
+ *
149
+ * // A unique value, generated by the client, that is
150
+ * // used to de-duplicate events.
151
+ * // Exactly one event with a given
152
+ * // idempotency key will be ingested, which allows for
153
+ * // safe request retries.
154
+ * idempotency_key: string
155
+ *
156
+ * // Optional custom metadata to attach to the event.
157
+ * // This might include a numeric value used for aggregation,
158
+ * // or a string/boolean value used for filtering.
159
+ * // The schema of this dictionary need not be pre-declared, and
160
+ * // properties can be added at any time.
161
+ * properties: {
162
+ * [key: string]?: string | number | boolean,
163
+ * },
164
164
  * }
165
165
  * ```
166
166
  *
@@ -1,5 +1,6 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
+ export * from './shared';
3
4
  export { Coupon, CouponCreateParams, CouponListParams, CouponsPage, Coupons } from './coupons/coupons';
4
5
  export { CreditNote, CreditNoteListParams, CreditNotesPage, CreditNotes } from './credit-notes';
5
6
  export {
@@ -11,7 +12,6 @@ export {
11
12
  CustomersPage,
12
13
  Customers,
13
14
  } from './customers/customers';
14
- export { Discount, Price, PriceCreateParams, PriceListParams, PricesPage, Prices } from './prices/prices';
15
15
  export {
16
16
  EventUpdateResponse,
17
17
  EventDeprecateResponse,
@@ -24,7 +24,6 @@ export {
24
24
  } from './events/events';
25
25
  export {
26
26
  Invoice,
27
- InvoiceDiscount,
28
27
  InvoiceFetchUpcomingResponse,
29
28
  InvoiceCreateParams,
30
29
  InvoiceListParams,
@@ -49,10 +48,11 @@ export {
49
48
  Metrics,
50
49
  } from './metrics';
51
50
  export { Plan, PlanCreateParams, PlanUpdateParams, PlanListParams, PlansPage, Plans } from './plans/plans';
51
+ export { Price, PriceCreateParams, PriceListParams, PricesPage, Prices } from './prices/prices';
52
52
  export {
53
53
  Subscription,
54
- Subscriptions,
55
54
  SubscriptionUsage,
55
+ Subscriptions,
56
56
  SubscriptionFetchCostsResponse,
57
57
  SubscriptionFetchScheduleResponse,
58
58
  SubscriptionCreateParams,
@@ -1,10 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
2
 
3
- import * as Core from "../ling/core";
4
- import { APIResource } from "../ling/resource";
5
- import * as InvoiceLineItemsAPI from "../ling/resources/invoice-line-items";
6
- import * as InvoicesAPI from "../ling/resources/invoices";
7
- import * as PricesAPI from "../ling/resources/prices/prices";
3
+ import * as Core from "../core";
4
+ import { APIResource } from "../resource";
5
+ import * as InvoiceLineItemsAPI from "./invoice-line-items";
6
+ import * as Shared from "./shared";
7
+ import * as PricesAPI from "./prices/prices";
8
8
 
9
9
  export class InvoiceLineItems extends APIResource {
10
10
  /**
@@ -30,7 +30,7 @@ export interface InvoiceLineItemCreateResponse {
30
30
  */
31
31
  amount: string;
32
32
 
33
- discount: InvoicesAPI.InvoiceDiscount | null;
33
+ discount: Shared.Discount | null;
34
34
 
35
35
  /**
36
36
  * The end date of the range of time applied for this line item's price.