orb-billing 1.24.2 → 1.26.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 (59) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +40 -2
  3. package/core.d.ts +1 -0
  4. package/core.d.ts.map +1 -1
  5. package/core.js +5 -1
  6. package/core.js.map +1 -1
  7. package/core.mjs +5 -1
  8. package/core.mjs.map +1 -1
  9. package/error.d.ts +7 -0
  10. package/error.d.ts.map +1 -1
  11. package/error.js +15 -1
  12. package/error.js.map +1 -1
  13. package/error.mjs +13 -0
  14. package/error.mjs.map +1 -1
  15. package/index.d.mts +5 -4
  16. package/index.d.ts +5 -4
  17. package/index.d.ts.map +1 -1
  18. package/index.js +4 -3
  19. package/index.js.map +1 -1
  20. package/index.mjs +3 -2
  21. package/index.mjs.map +1 -1
  22. package/package.json +1 -1
  23. package/resources/customers/credits/ledger.d.ts +2 -2
  24. package/resources/events/events.d.ts +7 -49
  25. package/resources/events/events.d.ts.map +1 -1
  26. package/resources/events/events.js +23 -20
  27. package/resources/events/events.js.map +1 -1
  28. package/resources/events/events.mjs +23 -20
  29. package/resources/events/events.mjs.map +1 -1
  30. package/resources/index.d.ts +1 -1
  31. package/resources/index.d.ts.map +1 -1
  32. package/resources/index.js +2 -2
  33. package/resources/index.js.map +1 -1
  34. package/resources/index.mjs +1 -1
  35. package/resources/index.mjs.map +1 -1
  36. package/resources/items.d.ts +18 -25
  37. package/resources/items.d.ts.map +1 -1
  38. package/resources/items.js +11 -5
  39. package/resources/items.js.map +1 -1
  40. package/resources/items.mjs +9 -3
  41. package/resources/items.mjs.map +1 -1
  42. package/resources/metrics.d.ts +4 -60
  43. package/resources/metrics.d.ts.map +1 -1
  44. package/resources/metrics.js.map +1 -1
  45. package/resources/metrics.mjs.map +1 -1
  46. package/resources/subscriptions.d.ts +1 -1
  47. package/src/core.ts +11 -2
  48. package/src/error.ts +29 -0
  49. package/src/index.ts +5 -3
  50. package/src/resources/customers/credits/ledger.ts +2 -2
  51. package/src/resources/events/events.ts +8 -88
  52. package/src/resources/index.ts +1 -1
  53. package/src/resources/items.ts +23 -42
  54. package/src/resources/metrics.ts +4 -99
  55. package/src/resources/subscriptions.ts +1 -1
  56. package/src/version.ts +1 -1
  57. package/version.d.ts +1 -1
  58. package/version.js +1 -1
  59. package/version.mjs +1 -1
@@ -2,7 +2,6 @@
2
2
 
3
3
  import * as Core from "../../core";
4
4
  import { APIResource } from "../../resource";
5
- import { isRequestOptions } from "../../core";
6
5
  import * as EventsAPI from "./events";
7
6
  import * as BackfillsAPI from "./backfills";
8
7
 
@@ -26,7 +25,7 @@ export class Events extends APIResource {
26
25
  * event in cases where you need to:
27
26
  *
28
27
  * - update an event with new metadata as you iterate on your pricing model
29
- * - update an event based on the result of an external API call (ex. call to a
28
+ * - update an event based on the result of an external API call (e.g. call to a
30
29
  * payment gateway succeeded or failed)
31
30
  *
32
31
  * This amendment API is always audit-safe. The process will still retain the
@@ -74,7 +73,7 @@ export class Events extends APIResource {
74
73
  * event in cases where you need to:
75
74
  *
76
75
  * - no longer bill for an event that was improperly reported
77
- * - no longer bill for an event based on the result of an external API call (ex.
76
+ * - no longer bill for an event based on the result of an external API call (e.g.
78
77
  * call to a payment gateway failed and the user should not be billed)
79
78
  *
80
79
  * If you want to only change specific properties of an event, but keep the event
@@ -323,46 +322,14 @@ export class Events extends APIResource {
323
322
  *
324
323
  * - `event_ids`: This is an explicit array of IDs to filter by. Note that an
325
324
  * event's ID is the `idempotency_key` that was originally used for ingestion.
326
- * - `invoice_id`: This is an issued Orb invoice ID (see also
327
- * [List Invoices](list-invoices)). Orb will fetch all events that were used to
328
- * calculate the invoice. In the common case, this will be a list of events whose
329
- * `timestamp` property falls within the billing period specified by the invoice.
330
325
  *
331
326
  * By default, Orb does not return _deprecated_ events in this endpoint.
332
327
  *
333
328
  * By default, Orb will not throw a `404` if no events matched, Orb will return an
334
329
  * empty array for `data` instead.
335
330
  */
336
- search(params?: EventSearchParams, options?: Core.RequestOptions): Core.APIPromise<EventSearchResponse>;
337
- search(options?: Core.RequestOptions): Core.APIPromise<EventSearchResponse>;
338
- search(
339
- params: EventSearchParams | Core.RequestOptions = {},
340
- options?: Core.RequestOptions,
341
- ): Core.APIPromise<EventSearchResponse> {
342
- if (isRequestOptions(params)) {
343
- return this.search({}, params);
344
- }
345
- const {
346
- cursor,
347
- limit,
348
- 'timestamp[gt]': timestampGt,
349
- 'timestamp[gte]': timestampGte,
350
- 'timestamp[lt]': timestampLt,
351
- 'timestamp[lte]': timestampLte,
352
- ...body
353
- } = params;
354
- return this.post('/events/search', {
355
- query: {
356
- cursor,
357
- limit,
358
- 'timestamp[gt]': timestampGt,
359
- 'timestamp[gte]': timestampGte,
360
- 'timestamp[lt]': timestampLt,
361
- 'timestamp[lte]': timestampLte,
362
- },
363
- body,
364
- ...options,
365
- });
331
+ search(body: EventSearchParams, options?: Core.RequestOptions): Core.APIPromise<EventSearchResponse> {
332
+ return this.post('/events/search', { body, ...options });
366
333
  }
367
334
  }
368
335
 
@@ -421,8 +388,6 @@ export namespace EventIngestResponse {
421
388
 
422
389
  export interface EventSearchResponse {
423
390
  data: Array<EventSearchResponse.Data>;
424
-
425
- pagination_metadata: EventSearchResponse.PaginationMetadata;
426
391
  }
427
392
 
428
393
  export namespace EventSearchResponse {
@@ -469,12 +434,6 @@ export namespace EventSearchResponse {
469
434
  */
470
435
  timestamp: string;
471
436
  }
472
-
473
- export interface PaginationMetadata {
474
- has_more: boolean;
475
-
476
- next_cursor: string | null;
477
- }
478
437
  }
479
438
 
480
439
  export interface EventUpdateParams {
@@ -569,50 +528,11 @@ export namespace EventIngestParams {
569
528
 
570
529
  export interface EventSearchParams {
571
530
  /**
572
- * Query param: Cursor for pagination. This can be populated by the `next_cursor`
573
- * value returned from the initial request.
574
- */
575
- cursor?: string | null;
576
-
577
- /**
578
- * Query param: The number of items to fetch. Defaults to 20.
579
- */
580
- limit?: number;
581
-
582
- /**
583
- * Query param:
584
- */
585
- 'timestamp[gt]'?: string | null;
586
-
587
- /**
588
- * Query param:
589
- */
590
- 'timestamp[gte]'?: string | null;
591
-
592
- /**
593
- * Query param:
594
- */
595
- 'timestamp[lt]'?: string | null;
596
-
597
- /**
598
- * Query param:
599
- */
600
- 'timestamp[lte]'?: string | null;
601
-
602
- /**
603
- * Body param: This is an explicit array of IDs to filter by. Note that an event's
604
- * ID is the idempotency_key that was originally used for ingestion. Values in this
605
- * array will be treated case sensitively.
606
- */
607
- event_ids?: Array<string> | null;
608
-
609
- /**
610
- * Body param: This is an issued Orb invoice ID (see also List Invoices). Orb will
611
- * fetch all events that were used to calculate the invoice. In the common case,
612
- * this will be a list of events whose timestamp property falls within the billing
613
- * period specified by the invoice.
531
+ * This is an explicit array of IDs to filter by. Note that an event's ID is the
532
+ * idempotency_key that was originally used for ingestion. Values in this array
533
+ * will be treated case sensitively.
614
534
  */
615
- invoice_id?: string | null;
535
+ event_ids: Array<string>;
616
536
  }
617
537
 
618
538
  export namespace Events {
@@ -37,7 +37,7 @@ export {
37
37
  InvoiceLineItemCreateParams,
38
38
  InvoiceLineItems,
39
39
  } from './invoice-line-items';
40
- export { ItemListResponse, ItemFetchResponse, ItemListParams, ItemListResponsesPage, Items } from './items';
40
+ export { Item, ItemCreateParams, ItemListParams, ItemsPage, Items } from './items';
41
41
  export {
42
42
  MetricCreateResponse,
43
43
  MetricListResponse,
@@ -7,51 +7,55 @@ import * as ItemsAPI from "./items";
7
7
  import { Page, type PageParams } from "../pagination";
8
8
 
9
9
  export class Items extends APIResource {
10
+ /**
11
+ * This endpoint is used to create an [Item](../guides/concepts#item).
12
+ */
13
+ create(body: ItemCreateParams, options?: Core.RequestOptions): Core.APIPromise<Item> {
14
+ return this.post('/items', { body, ...options });
15
+ }
16
+
10
17
  /**
11
18
  * This endpoint returns a list of all Items, ordered in descending order by
12
19
  * creation time.
13
20
  */
14
- list(
15
- query?: ItemListParams,
16
- options?: Core.RequestOptions,
17
- ): Core.PagePromise<ItemListResponsesPage, ItemListResponse>;
18
- list(options?: Core.RequestOptions): Core.PagePromise<ItemListResponsesPage, ItemListResponse>;
21
+ list(query?: ItemListParams, options?: Core.RequestOptions): Core.PagePromise<ItemsPage, Item>;
22
+ list(options?: Core.RequestOptions): Core.PagePromise<ItemsPage, Item>;
19
23
  list(
20
24
  query: ItemListParams | Core.RequestOptions = {},
21
25
  options?: Core.RequestOptions,
22
- ): Core.PagePromise<ItemListResponsesPage, ItemListResponse> {
26
+ ): Core.PagePromise<ItemsPage, Item> {
23
27
  if (isRequestOptions(query)) {
24
28
  return this.list({}, query);
25
29
  }
26
- return this.getAPIList('/items', ItemListResponsesPage, { query, ...options });
30
+ return this.getAPIList('/items', ItemsPage, { query, ...options });
27
31
  }
28
32
 
29
33
  /**
30
34
  * This endpoint returns an item identified by its item_id.
31
35
  */
32
- fetch(itemId: string, options?: Core.RequestOptions): Core.APIPromise<ItemFetchResponse> {
36
+ fetch(itemId: string, options?: Core.RequestOptions): Core.APIPromise<Item> {
33
37
  return this.get(`/items/${itemId}`, options);
34
38
  }
35
39
  }
36
40
 
37
- export class ItemListResponsesPage extends Page<ItemListResponse> {}
41
+ export class ItemsPage extends Page<Item> {}
38
42
 
39
43
  /**
40
44
  * The Item resource represents a sellable product or good. Items are associated
41
45
  * with all line items, billable metrics, and prices and are used for defining
42
46
  * external sync behavior for invoices and tax calculation purposes.
43
47
  */
44
- export interface ItemListResponse {
48
+ export interface Item {
45
49
  id: string;
46
50
 
47
51
  created_at: string;
48
52
 
49
- external_connections: Array<ItemListResponse.ExternalConnection>;
53
+ external_connections: Array<Item.ExternalConnection>;
50
54
 
51
55
  name: string;
52
56
  }
53
57
 
54
- export namespace ItemListResponse {
58
+ export namespace Item {
55
59
  export interface ExternalConnection {
56
60
  external_connection_name:
57
61
  | 'stripe'
@@ -66,41 +70,18 @@ export namespace ItemListResponse {
66
70
  }
67
71
  }
68
72
 
69
- /**
70
- * The Item resource represents a sellable product or good. Items are associated
71
- * with all line items, billable metrics, and prices and are used for defining
72
- * external sync behavior for invoices and tax calculation purposes.
73
- */
74
- export interface ItemFetchResponse {
75
- id: string;
76
-
77
- created_at: string;
78
-
79
- external_connections: Array<ItemFetchResponse.ExternalConnection>;
80
-
73
+ export interface ItemCreateParams {
74
+ /**
75
+ * The name of the item.
76
+ */
81
77
  name: string;
82
78
  }
83
79
 
84
- export namespace ItemFetchResponse {
85
- export interface ExternalConnection {
86
- external_connection_name:
87
- | 'stripe'
88
- | 'quickbooks'
89
- | 'bill.com'
90
- | 'netsuite'
91
- | 'taxjar'
92
- | 'avalara'
93
- | 'anrok';
94
-
95
- external_entity_id: string;
96
- }
97
- }
98
-
99
80
  export interface ItemListParams extends PageParams {}
100
81
 
101
82
  export namespace Items {
102
- export import ItemListResponse = ItemsAPI.ItemListResponse;
103
- export import ItemFetchResponse = ItemsAPI.ItemFetchResponse;
104
- export import ItemListResponsesPage = ItemsAPI.ItemListResponsesPage;
83
+ export import Item = ItemsAPI.Item;
84
+ export import ItemsPage = ItemsAPI.ItemsPage;
85
+ export import ItemCreateParams = ItemsAPI.ItemCreateParams;
105
86
  export import ItemListParams = ItemsAPI.ItemListParams;
106
87
  }
@@ -4,6 +4,7 @@ import * as Core from "../core";
4
4
  import { APIResource } from "../resource";
5
5
  import { isRequestOptions } from "../core";
6
6
  import * as MetricsAPI from "./metrics";
7
+ import * as ItemsAPI from "./items";
7
8
  import { Page, type PageParams } from "../pagination";
8
9
 
9
10
  export class Metrics extends APIResource {
@@ -63,7 +64,7 @@ export interface MetricCreateResponse {
63
64
  * with all line items, billable metrics, and prices and are used for defining
64
65
  * external sync behavior for invoices and tax calculation purposes.
65
66
  */
66
- item: MetricCreateResponse.Item;
67
+ item: ItemsAPI.Item;
67
68
 
68
69
  metadata: Record<string, string>;
69
70
 
@@ -72,38 +73,6 @@ export interface MetricCreateResponse {
72
73
  status: 'active' | 'draft' | 'archived';
73
74
  }
74
75
 
75
- export namespace MetricCreateResponse {
76
- /**
77
- * The Item resource represents a sellable product or good. Items are associated
78
- * with all line items, billable metrics, and prices and are used for defining
79
- * external sync behavior for invoices and tax calculation purposes.
80
- */
81
- export interface Item {
82
- id: string;
83
-
84
- created_at: string;
85
-
86
- external_connections: Array<Item.ExternalConnection>;
87
-
88
- name: string;
89
- }
90
-
91
- export namespace Item {
92
- export interface ExternalConnection {
93
- external_connection_name:
94
- | 'stripe'
95
- | 'quickbooks'
96
- | 'bill.com'
97
- | 'netsuite'
98
- | 'taxjar'
99
- | 'avalara'
100
- | 'anrok';
101
-
102
- external_entity_id: string;
103
- }
104
- }
105
- }
106
-
107
76
  /**
108
77
  * The Metric resource represents a calculation of a quantity based on events.
109
78
  * Metrics are defined by the query that transforms raw usage events into
@@ -119,7 +88,7 @@ export interface MetricListResponse {
119
88
  * with all line items, billable metrics, and prices and are used for defining
120
89
  * external sync behavior for invoices and tax calculation purposes.
121
90
  */
122
- item: MetricListResponse.Item;
91
+ item: ItemsAPI.Item;
123
92
 
124
93
  metadata: Record<string, string>;
125
94
 
@@ -128,38 +97,6 @@ export interface MetricListResponse {
128
97
  status: 'active' | 'draft' | 'archived';
129
98
  }
130
99
 
131
- export namespace MetricListResponse {
132
- /**
133
- * The Item resource represents a sellable product or good. Items are associated
134
- * with all line items, billable metrics, and prices and are used for defining
135
- * external sync behavior for invoices and tax calculation purposes.
136
- */
137
- export interface Item {
138
- id: string;
139
-
140
- created_at: string;
141
-
142
- external_connections: Array<Item.ExternalConnection>;
143
-
144
- name: string;
145
- }
146
-
147
- export namespace Item {
148
- export interface ExternalConnection {
149
- external_connection_name:
150
- | 'stripe'
151
- | 'quickbooks'
152
- | 'bill.com'
153
- | 'netsuite'
154
- | 'taxjar'
155
- | 'avalara'
156
- | 'anrok';
157
-
158
- external_entity_id: string;
159
- }
160
- }
161
- }
162
-
163
100
  /**
164
101
  * The Metric resource represents a calculation of a quantity based on events.
165
102
  * Metrics are defined by the query that transforms raw usage events into
@@ -175,7 +112,7 @@ export interface MetricFetchResponse {
175
112
  * with all line items, billable metrics, and prices and are used for defining
176
113
  * external sync behavior for invoices and tax calculation purposes.
177
114
  */
178
- item: MetricFetchResponse.Item;
115
+ item: ItemsAPI.Item;
179
116
 
180
117
  metadata: Record<string, string>;
181
118
 
@@ -184,38 +121,6 @@ export interface MetricFetchResponse {
184
121
  status: 'active' | 'draft' | 'archived';
185
122
  }
186
123
 
187
- export namespace MetricFetchResponse {
188
- /**
189
- * The Item resource represents a sellable product or good. Items are associated
190
- * with all line items, billable metrics, and prices and are used for defining
191
- * external sync behavior for invoices and tax calculation purposes.
192
- */
193
- export interface Item {
194
- id: string;
195
-
196
- created_at: string;
197
-
198
- external_connections: Array<Item.ExternalConnection>;
199
-
200
- name: string;
201
- }
202
-
203
- export namespace Item {
204
- export interface ExternalConnection {
205
- external_connection_name:
206
- | 'stripe'
207
- | 'quickbooks'
208
- | 'bill.com'
209
- | 'netsuite'
210
- | 'taxjar'
211
- | 'avalara'
212
- | 'anrok';
213
-
214
- external_entity_id: string;
215
- }
216
- }
217
- }
218
-
219
124
  export interface MetricCreateParams {
220
125
  /**
221
126
  * A description of the metric.
@@ -399,7 +399,7 @@ export class Subscriptions extends APIResource {
399
399
  * Orb supports invoicing for a subscription when a preconfigured usage threshold
400
400
  * is hit. To enable threshold billing, pass in an `invoicing_threshold`, which is
401
401
  * specified in the subscription's invoicing currency, when creating a
402
- * subscription. Ex. pass in `10.00` to issue an invoice when usage amounts hit
402
+ * subscription. E.g. pass in `10.00` to issue an invoice when usage amounts hit
403
403
  * $10.00 for a subscription that invoices in USD.
404
404
  */
405
405
  create(body?: SubscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Subscription>;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.24.2'; // x-release-please-version
1
+ export const VERSION = '1.26.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.24.2";
1
+ export declare const VERSION = "1.26.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 = '1.24.2'; // x-release-please-version
4
+ exports.VERSION = '1.26.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.24.2'; // x-release-please-version
1
+ export const VERSION = '1.26.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map