orb-billing 3.2.0 → 4.1.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 +21 -0
  2. package/package.json +2 -2
  3. package/resources/alerts.d.ts +9 -9
  4. package/resources/alerts.d.ts.map +1 -1
  5. package/resources/alerts.js.map +1 -1
  6. package/resources/alerts.mjs.map +1 -1
  7. package/resources/customers/customers.d.ts +0 -7
  8. package/resources/customers/customers.d.ts.map +1 -1
  9. package/resources/customers/customers.js +0 -3
  10. package/resources/customers/customers.js.map +1 -1
  11. package/resources/customers/customers.mjs +0 -3
  12. package/resources/customers/customers.mjs.map +1 -1
  13. package/resources/customers/index.d.ts +0 -1
  14. package/resources/customers/index.d.ts.map +1 -1
  15. package/resources/customers/index.js +1 -3
  16. package/resources/customers/index.js.map +1 -1
  17. package/resources/customers/index.mjs +0 -1
  18. package/resources/customers/index.mjs.map +1 -1
  19. package/resources/events/backfills.d.ts +42 -0
  20. package/resources/events/backfills.d.ts.map +1 -1
  21. package/resources/events/backfills.js +6 -0
  22. package/resources/events/backfills.js.map +1 -1
  23. package/resources/events/backfills.mjs +6 -0
  24. package/resources/events/backfills.mjs.map +1 -1
  25. package/resources/events/events.d.ts +11 -2
  26. package/resources/events/events.d.ts.map +1 -1
  27. package/resources/events/events.js +11 -2
  28. package/resources/events/events.js.map +1 -1
  29. package/resources/events/events.mjs +11 -2
  30. package/resources/events/events.mjs.map +1 -1
  31. package/resources/plans/plans.d.ts +15 -15
  32. package/resources/plans/plans.d.ts.map +1 -1
  33. package/resources/prices/prices.d.ts +108 -18
  34. package/resources/prices/prices.d.ts.map +1 -1
  35. package/resources/prices/prices.js.map +1 -1
  36. package/resources/prices/prices.mjs.map +1 -1
  37. package/resources/subscriptions.d.ts +20 -30
  38. package/resources/subscriptions.d.ts.map +1 -1
  39. package/resources/subscriptions.js.map +1 -1
  40. package/resources/subscriptions.mjs.map +1 -1
  41. package/src/resources/alerts.ts +24 -9
  42. package/src/resources/customers/customers.ts +0 -7
  43. package/src/resources/customers/index.ts +0 -7
  44. package/src/resources/events/backfills.ts +48 -0
  45. package/src/resources/events/events.ts +11 -2
  46. package/src/resources/plans/plans.ts +15 -15
  47. package/src/resources/prices/prices.ts +162 -18
  48. package/src/resources/subscriptions.ts +20 -32
  49. package/src/version.ts +1 -1
  50. package/version.d.ts +1 -1
  51. package/version.js +1 -1
  52. package/version.mjs +1 -1
  53. package/resources/customers/usage.d.ts +0 -326
  54. package/resources/customers/usage.d.ts.map +0 -1
  55. package/resources/customers/usage.js +0 -227
  56. package/resources/customers/usage.js.map +0 -1
  57. package/resources/customers/usage.mjs +0 -223
  58. package/resources/customers/usage.mjs.map +0 -1
  59. package/src/resources/customers/usage.ts +0 -372
@@ -1,372 +0,0 @@
1
- // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- import { APIResource } from '../../resource';
4
- import * as Core from '../../core';
5
- import * as UsageAPI from './usage';
6
-
7
- export class Usage extends APIResource {
8
- /**
9
- * This endpoint is used to amend usage within a timeframe for a customer that has
10
- * an active subscription.
11
- *
12
- * This endpoint will mark _all_ existing events within
13
- * `[timeframe_start, timeframe_end)` as _ignored_ for billing purposes, and Orb
14
- * will only use the _new_ events passed in the body of this request as the source
15
- * of truth for that timeframe moving forwards. Note that a given time period can
16
- * be amended any number of times, so events can be overwritten in subsequent calls
17
- * to th is endpoint.
18
- *
19
- * This is a powerful and audit-safe mechanism to retroactively change usage data
20
- * in cases where you need to:
21
- *
22
- * - decrease historical usage consumption because of degraded service availability
23
- * in your systems
24
- * - account for gaps from your usage reporting mechanism
25
- * - make point-in-time fixes for specific event records, while retaining the
26
- * original time of usage and associated metadata. This amendment API is designed
27
- * with two explicit goals:
28
- *
29
- * 1. Amendments are **always audit-safe**. The amendment process will still retain
30
- * original events in the timeframe, though they will be ignored for billing
31
- * calculations. For auditing a nd data fidelity purposes, Orb never overwrites
32
- * or permanently deletes ingested usage data.
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
- * timeframe are honored rather than the existing ones) or the amendment request
36
- * fails. To maintain this important property, Orb prevents _partial event
37
- * ingestion_ on this endpoint.
38
- *
39
- * ## Response semantics
40
- *
41
- * - Either all events are ingested successfully, or all fail to ingest (returning
42
- * a `4xx` or `5xx` response code).
43
- * - Any event that fails schema validation will lead to a `4xx` response. In this
44
- * case, to maintain data consistency, Orb will not ingest any events and will
45
- * also not deprecate existing events in the time period.
46
- * - You can assume that the amendment is successful on receipt of a `2xx`
47
- * response.While a successful response from this endpoint indicates that the new
48
- * events have been ingested, updating usage totals happens asynchronously and
49
- * may be delayed by a few minutes.
50
- *
51
- * As emphasized above, Orb will never show an inconsistent state (e.g. in invoice
52
- * previews or dashboards); either it will show the existing state (before the
53
- * amendment) or the new state (with new events in the requested timeframe).
54
- *
55
- * ## Sample request body
56
- *
57
- * ```json
58
- * {
59
- * "events": [
60
- * {
61
- * "event_name": "payment_processed",
62
- * "timestamp": "2022-03-24T07:15:00Z",
63
- * "properties": {
64
- * "amount": 100
65
- * }
66
- * },
67
- * {
68
- * "event_name": "payment_failed",
69
- * "timestamp": "2022-03-24T07:15:00Z",
70
- * "properties": {
71
- * "amount": 100
72
- * }
73
- * }
74
- * ]
75
- * }
76
- * ```
77
- *
78
- * ## Request Validation
79
- *
80
- * - The `timestamp` of each event reported must fall within the bounds of
81
- * `timeframe_start` and `timeframe_end`. As with ingestion, all timesta mps must
82
- * be sent in ISO8601 format with UTC timezone offset.
83
- * - Orb **does not accept an `idempotency_key`** with each event in this endpoint,
84
- * since the entirety of the event list must be ingested to ensure consistency.
85
- * On retryable errors , you should retry the request in its entirety, and assume
86
- * that the amendment operation has not succeeded until receipt of a `2xx`.
87
- *
88
- * - Both `timeframe_start` and `timeframe_end` must be timestamps in the past.
89
- * Furthermore, Orb will genera lly validate that the `timeframe_start` and
90
- * `timeframe_end` fall within the customer's _current_ subscription billing pe
91
- * riod. However, Orb does allow amendments while in the grace period of the
92
- * previous billing period; in this instance, the timeframe can start before the
93
- * current period.
94
- *
95
- * ## API Limits
96
- *
97
- * Note that Orb does not currently enforce a hard rate- limit for API usage or a
98
- * maximum request payload size. Similar to the event ingestion API, this API is
99
- * architected for h igh-throughput ingestion. It is also safe to
100
- * _programmatically_ call this endpoint if your system can automatically dete ct a
101
- * need for historical amendment.
102
- *
103
- * In order to overwrite timeframes with a very large number of events, we suggest
104
- * using multiple calls with small adjacent (e.g. every hour) timeframes.
105
- *
106
- * @deprecated This method will be removed in a future release. Please use the 'events.backfills.create' instead.
107
- */
108
- update(
109
- id: string,
110
- params: UsageUpdateParams,
111
- options?: Core.RequestOptions,
112
- ): Core.APIPromise<UsageUpdateResponse> {
113
- const { timeframe_end, timeframe_start, ...body } = params;
114
- return this._client.patch(`/customers/${id}/usage`, {
115
- query: { timeframe_end, timeframe_start },
116
- body,
117
- ...options,
118
- });
119
- }
120
-
121
- /**
122
- * This endpoint is used to amend usage within a timeframe for a customer that has
123
- * an active subscription.
124
- *
125
- * This endpoint will mark _all_ existing events within
126
- * `[timeframe_start, timeframe_end)` as _ignored_ for billing purposes, and Orb
127
- * will only use the _new_ events passed in the body of this request as the source
128
- * of truth for that timeframe moving forwards. Note that a given time period can
129
- * be amended any number of times, so events can be overwritten in subsequent calls
130
- * to th is endpoint.
131
- *
132
- * This is a powerful and audit-safe mechanism to retroactively change usage data
133
- * in cases where you need to:
134
- *
135
- * - decrease historical usage consumption because of degraded service availability
136
- * in your systems
137
- * - account for gaps from your usage reporting mechanism
138
- * - make point-in-time fixes for specific event records, while retaining the
139
- * original time of usage and associated metadata. This amendment API is designed
140
- * with two explicit goals:
141
- *
142
- * 1. Amendments are **always audit-safe**. The amendment process will still retain
143
- * original events in the timeframe, though they will be ignored for billing
144
- * calculations. For auditing a nd data fidelity purposes, Orb never overwrites
145
- * or permanently deletes ingested usage data.
146
- * 2. Amendments always preserve data **consistency**. In other words, either an
147
- * amendment is fully processed by the system (and the new events for the
148
- * timeframe are honored rather than the existing ones) or the amendment request
149
- * fails. To maintain this important property, Orb prevents _partial event
150
- * ingestion_ on this endpoint.
151
- *
152
- * ## Response semantics
153
- *
154
- * - Either all events are ingested successfully, or all fail to ingest (returning
155
- * a `4xx` or `5xx` response code).
156
- * - Any event that fails schema validation will lead to a `4xx` response. In this
157
- * case, to maintain data consistency, Orb will not ingest any events and will
158
- * also not deprecate existing events in the time period.
159
- * - You can assume that the amendment is successful on receipt of a `2xx`
160
- * response.While a successful response from this endpoint indicates that the new
161
- * events have been ingested, updating usage totals happens asynchronously and
162
- * may be delayed by a few minutes.
163
- *
164
- * As emphasized above, Orb will never show an inconsistent state (e.g. in invoice
165
- * previews or dashboards); either it will show the existing state (before the
166
- * amendment) or the new state (with new events in the requested timeframe).
167
- *
168
- * ## Sample request body
169
- *
170
- * ```json
171
- * {
172
- * "events": [
173
- * {
174
- * "event_name": "payment_processed",
175
- * "timestamp": "2022-03-24T07:15:00Z",
176
- * "properties": {
177
- * "amount": 100
178
- * }
179
- * },
180
- * {
181
- * "event_name": "payment_failed",
182
- * "timestamp": "2022-03-24T07:15:00Z",
183
- * "properties": {
184
- * "amount": 100
185
- * }
186
- * }
187
- * ]
188
- * }
189
- * ```
190
- *
191
- * ## Request Validation
192
- *
193
- * - The `timestamp` of each event reported must fall within the bounds of
194
- * `timeframe_start` and `timeframe_end`. As with ingestion, all timesta mps must
195
- * be sent in ISO8601 format with UTC timezone offset.
196
- * - Orb **does not accept an `idempotency_key`** with each event in this endpoint,
197
- * since the entirety of the event list must be ingested to ensure consistency.
198
- * On retryable errors , you should retry the request in its entirety, and assume
199
- * that the amendment operation has not succeeded until receipt of a `2xx`.
200
- *
201
- * - Both `timeframe_start` and `timeframe_end` must be timestamps in the past.
202
- * Furthermore, Orb will genera lly validate that the `timeframe_start` and
203
- * `timeframe_end` fall within the customer's _current_ subscription billing pe
204
- * riod. However, Orb does allow amendments while in the grace period of the
205
- * previous billing period; in this instance, the timeframe can start before the
206
- * current period.
207
- *
208
- * ## API Limits
209
- *
210
- * Note that Orb does not currently enforce a hard rate- limit for API usage or a
211
- * maximum request payload size. Similar to the event ingestion API, this API is
212
- * architected for h igh-throughput ingestion. It is also safe to
213
- * _programmatically_ call this endpoint if your system can automatically dete ct a
214
- * need for historical amendment.
215
- *
216
- * In order to overwrite timeframes with a very large number of events, we suggest
217
- * using multiple calls with small adjacent (e.g. every hour) timeframes.
218
- *
219
- * @deprecated This method will be removed in a future release. Please use the 'events.backfills.create' instead.
220
- */
221
- updateByExternalId(
222
- id: string,
223
- params: UsageUpdateByExternalIDParams,
224
- options?: Core.RequestOptions,
225
- ): Core.APIPromise<UsageUpdateByExternalIDResponse> {
226
- const { timeframe_end, timeframe_start, ...body } = params;
227
- return this._client.patch(`/customers/external_customer_id/${id}/usage`, {
228
- query: { timeframe_end, timeframe_start },
229
- body,
230
- ...options,
231
- });
232
- }
233
- }
234
-
235
- export interface UsageUpdateResponse {
236
- /**
237
- * An array of strings, corresponding to idempotency_key's marked as duplicates
238
- * (previously ingested)
239
- */
240
- duplicate: Array<string>;
241
-
242
- /**
243
- * An array of strings, corresponding to idempotency_key's which were successfully
244
- * ingested.
245
- */
246
- ingested: Array<string>;
247
- }
248
-
249
- export interface UsageUpdateByExternalIDResponse {
250
- /**
251
- * An array of strings, corresponding to idempotency_key's marked as duplicates
252
- * (previously ingested)
253
- */
254
- duplicate: Array<string>;
255
-
256
- /**
257
- * An array of strings, corresponding to idempotency_key's which were successfully
258
- * ingested.
259
- */
260
- ingested: Array<string>;
261
- }
262
-
263
- export interface UsageUpdateParams {
264
- /**
265
- * Body param: Events to update
266
- */
267
- events: Array<UsageUpdateParams.Event>;
268
-
269
- /**
270
- * Query param: This bound is exclusive (i.e. events before this timestamp will be
271
- * updated)
272
- */
273
- timeframe_end?: string;
274
-
275
- /**
276
- * Query param: This bound is inclusive (i.e. events with this timestamp onward,
277
- * inclusive will be updated)
278
- */
279
- timeframe_start?: string;
280
- }
281
-
282
- export namespace UsageUpdateParams {
283
- export interface Event {
284
- /**
285
- * A name to meaningfully identify the action or event type.
286
- */
287
- event_name: string;
288
-
289
- /**
290
- * A dictionary of custom properties. Values in this dictionary must be numeric,
291
- * boolean, or strings. Nested dictionaries are disallowed.
292
- */
293
- properties: unknown;
294
-
295
- /**
296
- * An ISO 8601 format date with no timezone offset (i.e. UTC). This should
297
- * represent the time that usage was recorded, and is particularly important to
298
- * attribute usage to a given billing period.
299
- */
300
- timestamp: string;
301
-
302
- /**
303
- * The Orb Customer identifier
304
- */
305
- customer_id?: string | null;
306
-
307
- /**
308
- * An alias for the Orb customer, whose mapping is specified when creating the
309
- * customer
310
- */
311
- external_customer_id?: string | null;
312
- }
313
- }
314
-
315
- export interface UsageUpdateByExternalIDParams {
316
- /**
317
- * Body param: Events to update
318
- */
319
- events: Array<UsageUpdateByExternalIDParams.Event>;
320
-
321
- /**
322
- * Query param: This bound is exclusive (i.e. events before this timestamp will be
323
- * updated)
324
- */
325
- timeframe_end?: string;
326
-
327
- /**
328
- * Query param: This bound is inclusive (i.e. events with this timestamp onward,
329
- * inclusive will be updated)
330
- */
331
- timeframe_start?: string;
332
- }
333
-
334
- export namespace UsageUpdateByExternalIDParams {
335
- export interface Event {
336
- /**
337
- * A name to meaningfully identify the action or event type.
338
- */
339
- event_name: string;
340
-
341
- /**
342
- * A dictionary of custom properties. Values in this dictionary must be numeric,
343
- * boolean, or strings. Nested dictionaries are disallowed.
344
- */
345
- properties: unknown;
346
-
347
- /**
348
- * An ISO 8601 format date with no timezone offset (i.e. UTC). This should
349
- * represent the time that usage was recorded, and is particularly important to
350
- * attribute usage to a given billing period.
351
- */
352
- timestamp: string;
353
-
354
- /**
355
- * The Orb Customer identifier
356
- */
357
- customer_id?: string | null;
358
-
359
- /**
360
- * An alias for the Orb customer, whose mapping is specified when creating the
361
- * customer
362
- */
363
- external_customer_id?: string | null;
364
- }
365
- }
366
-
367
- export namespace Usage {
368
- export import UsageUpdateResponse = UsageAPI.UsageUpdateResponse;
369
- export import UsageUpdateByExternalIDResponse = UsageAPI.UsageUpdateByExternalIDResponse;
370
- export import UsageUpdateParams = UsageAPI.UsageUpdateParams;
371
- export import UsageUpdateByExternalIDParams = UsageAPI.UsageUpdateByExternalIDParams;
372
- }