orb-billing 3.1.0 → 4.0.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 (60) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/index.d.mts +1 -0
  3. package/index.d.ts +1 -0
  4. package/index.d.ts.map +1 -1
  5. package/index.js +1 -0
  6. package/index.js.map +1 -1
  7. package/index.mjs +1 -0
  8. package/index.mjs.map +1 -1
  9. package/package.json +2 -2
  10. package/resources/alerts.d.ts +9 -9
  11. package/resources/alerts.d.ts.map +1 -1
  12. package/resources/alerts.js.map +1 -1
  13. package/resources/alerts.mjs.map +1 -1
  14. package/resources/customers/customers.d.ts +0 -7
  15. package/resources/customers/customers.d.ts.map +1 -1
  16. package/resources/customers/customers.js +0 -3
  17. package/resources/customers/customers.js.map +1 -1
  18. package/resources/customers/customers.mjs +0 -3
  19. package/resources/customers/customers.mjs.map +1 -1
  20. package/resources/customers/index.d.ts +0 -1
  21. package/resources/customers/index.d.ts.map +1 -1
  22. package/resources/customers/index.js +1 -3
  23. package/resources/customers/index.js.map +1 -1
  24. package/resources/customers/index.mjs +0 -1
  25. package/resources/customers/index.mjs.map +1 -1
  26. package/resources/events/events.d.ts +11 -2
  27. package/resources/events/events.d.ts.map +1 -1
  28. package/resources/events/events.js +11 -2
  29. package/resources/events/events.js.map +1 -1
  30. package/resources/events/events.mjs +11 -2
  31. package/resources/events/events.mjs.map +1 -1
  32. package/resources/plans/plans.d.ts +15 -15
  33. package/resources/plans/plans.d.ts.map +1 -1
  34. package/resources/prices/prices.d.ts +108 -18
  35. package/resources/prices/prices.d.ts.map +1 -1
  36. package/resources/prices/prices.js.map +1 -1
  37. package/resources/prices/prices.mjs.map +1 -1
  38. package/resources/subscriptions.d.ts +18 -28
  39. package/resources/subscriptions.d.ts.map +1 -1
  40. package/resources/subscriptions.js.map +1 -1
  41. package/resources/subscriptions.mjs.map +1 -1
  42. package/src/index.ts +1 -0
  43. package/src/resources/alerts.ts +24 -9
  44. package/src/resources/customers/customers.ts +0 -7
  45. package/src/resources/customers/index.ts +0 -7
  46. package/src/resources/events/events.ts +11 -2
  47. package/src/resources/plans/plans.ts +15 -15
  48. package/src/resources/prices/prices.ts +162 -18
  49. package/src/resources/subscriptions.ts +18 -30
  50. package/src/version.ts +1 -1
  51. package/version.d.ts +1 -1
  52. package/version.js +1 -1
  53. package/version.mjs +1 -1
  54. package/resources/customers/usage.d.ts +0 -322
  55. package/resources/customers/usage.d.ts.map +0 -1
  56. package/resources/customers/usage.js +0 -223
  57. package/resources/customers/usage.js.map +0 -1
  58. package/resources/customers/usage.mjs +0 -219
  59. package/resources/customers/usage.mjs.map +0 -1
  60. package/src/resources/customers/usage.ts +0 -368
@@ -1,368 +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
- update(
107
- id: string,
108
- params: UsageUpdateParams,
109
- options?: Core.RequestOptions,
110
- ): Core.APIPromise<UsageUpdateResponse> {
111
- const { timeframe_end, timeframe_start, ...body } = params;
112
- return this._client.patch(`/customers/${id}/usage`, {
113
- query: { timeframe_end, timeframe_start },
114
- body,
115
- ...options,
116
- });
117
- }
118
-
119
- /**
120
- * This endpoint is used to amend usage within a timeframe for a customer that has
121
- * an active subscription.
122
- *
123
- * This endpoint will mark _all_ existing events within
124
- * `[timeframe_start, timeframe_end)` as _ignored_ for billing purposes, and Orb
125
- * will only use the _new_ events passed in the body of this request as the source
126
- * of truth for that timeframe moving forwards. Note that a given time period can
127
- * be amended any number of times, so events can be overwritten in subsequent calls
128
- * to th is endpoint.
129
- *
130
- * This is a powerful and audit-safe mechanism to retroactively change usage data
131
- * in cases where you need to:
132
- *
133
- * - decrease historical usage consumption because of degraded service availability
134
- * in your systems
135
- * - account for gaps from your usage reporting mechanism
136
- * - make point-in-time fixes for specific event records, while retaining the
137
- * original time of usage and associated metadata. This amendment API is designed
138
- * with two explicit goals:
139
- *
140
- * 1. Amendments are **always audit-safe**. The amendment process will still retain
141
- * original events in the timeframe, though they will be ignored for billing
142
- * calculations. For auditing a nd data fidelity purposes, Orb never overwrites
143
- * or permanently deletes ingested usage data.
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
- * timeframe are honored rather than the existing ones) or the amendment request
147
- * fails. To maintain this important property, Orb prevents _partial event
148
- * ingestion_ on this endpoint.
149
- *
150
- * ## Response semantics
151
- *
152
- * - Either all events are ingested successfully, or all fail to ingest (returning
153
- * a `4xx` or `5xx` response code).
154
- * - Any event that fails schema validation will lead to a `4xx` response. In this
155
- * case, to maintain data consistency, Orb will not ingest any events and will
156
- * also not deprecate existing events in the time period.
157
- * - You can assume that the amendment is successful on receipt of a `2xx`
158
- * response.While a successful response from this endpoint indicates that the new
159
- * events have been ingested, updating usage totals happens asynchronously and
160
- * may be delayed by a few minutes.
161
- *
162
- * As emphasized above, Orb will never show an inconsistent state (e.g. in invoice
163
- * previews or dashboards); either it will show the existing state (before the
164
- * amendment) or the new state (with new events in the requested timeframe).
165
- *
166
- * ## Sample request body
167
- *
168
- * ```json
169
- * {
170
- * "events": [
171
- * {
172
- * "event_name": "payment_processed",
173
- * "timestamp": "2022-03-24T07:15:00Z",
174
- * "properties": {
175
- * "amount": 100
176
- * }
177
- * },
178
- * {
179
- * "event_name": "payment_failed",
180
- * "timestamp": "2022-03-24T07:15:00Z",
181
- * "properties": {
182
- * "amount": 100
183
- * }
184
- * }
185
- * ]
186
- * }
187
- * ```
188
- *
189
- * ## Request Validation
190
- *
191
- * - The `timestamp` of each event reported must fall within the bounds of
192
- * `timeframe_start` and `timeframe_end`. As with ingestion, all timesta mps must
193
- * be sent in ISO8601 format with UTC timezone offset.
194
- * - Orb **does not accept an `idempotency_key`** with each event in this endpoint,
195
- * since the entirety of the event list must be ingested to ensure consistency.
196
- * On retryable errors , you should retry the request in its entirety, and assume
197
- * that the amendment operation has not succeeded until receipt of a `2xx`.
198
- *
199
- * - Both `timeframe_start` and `timeframe_end` must be timestamps in the past.
200
- * Furthermore, Orb will genera lly validate that the `timeframe_start` and
201
- * `timeframe_end` fall within the customer's _current_ subscription billing pe
202
- * riod. However, Orb does allow amendments while in the grace period of the
203
- * previous billing period; in this instance, the timeframe can start before the
204
- * current period.
205
- *
206
- * ## API Limits
207
- *
208
- * Note that Orb does not currently enforce a hard rate- limit for API usage or a
209
- * maximum request payload size. Similar to the event ingestion API, this API is
210
- * architected for h igh-throughput ingestion. It is also safe to
211
- * _programmatically_ call this endpoint if your system can automatically dete ct a
212
- * need for historical amendment.
213
- *
214
- * In order to overwrite timeframes with a very large number of events, we suggest
215
- * using multiple calls with small adjacent (e.g. every hour) timeframes.
216
- */
217
- updateByExternalId(
218
- id: string,
219
- params: UsageUpdateByExternalIDParams,
220
- options?: Core.RequestOptions,
221
- ): Core.APIPromise<UsageUpdateByExternalIDResponse> {
222
- const { timeframe_end, timeframe_start, ...body } = params;
223
- return this._client.patch(`/customers/external_customer_id/${id}/usage`, {
224
- query: { timeframe_end, timeframe_start },
225
- body,
226
- ...options,
227
- });
228
- }
229
- }
230
-
231
- export interface UsageUpdateResponse {
232
- /**
233
- * An array of strings, corresponding to idempotency_key's marked as duplicates
234
- * (previously ingested)
235
- */
236
- duplicate: Array<string>;
237
-
238
- /**
239
- * An array of strings, corresponding to idempotency_key's which were successfully
240
- * ingested.
241
- */
242
- ingested: Array<string>;
243
- }
244
-
245
- export interface UsageUpdateByExternalIDResponse {
246
- /**
247
- * An array of strings, corresponding to idempotency_key's marked as duplicates
248
- * (previously ingested)
249
- */
250
- duplicate: Array<string>;
251
-
252
- /**
253
- * An array of strings, corresponding to idempotency_key's which were successfully
254
- * ingested.
255
- */
256
- ingested: Array<string>;
257
- }
258
-
259
- export interface UsageUpdateParams {
260
- /**
261
- * Body param: Events to update
262
- */
263
- events: Array<UsageUpdateParams.Event>;
264
-
265
- /**
266
- * Query param: This bound is exclusive (i.e. events before this timestamp will be
267
- * updated)
268
- */
269
- timeframe_end?: string;
270
-
271
- /**
272
- * Query param: This bound is inclusive (i.e. events with this timestamp onward,
273
- * inclusive will be updated)
274
- */
275
- timeframe_start?: string;
276
- }
277
-
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;
284
-
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;
290
-
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;
297
-
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
- }
310
-
311
- export interface UsageUpdateByExternalIDParams {
312
- /**
313
- * Body param: Events to update
314
- */
315
- events: Array<UsageUpdateByExternalIDParams.Event>;
316
-
317
- /**
318
- * Query param: This bound is exclusive (i.e. events before this timestamp will be
319
- * updated)
320
- */
321
- timeframe_end?: string;
322
-
323
- /**
324
- * Query param: This bound is inclusive (i.e. events with this timestamp onward,
325
- * inclusive will be updated)
326
- */
327
- timeframe_start?: string;
328
- }
329
-
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;
336
-
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
- }
361
- }
362
-
363
- export namespace Usage {
364
- export import UsageUpdateResponse = UsageAPI.UsageUpdateResponse;
365
- export import UsageUpdateByExternalIDResponse = UsageAPI.UsageUpdateByExternalIDResponse;
366
- export import UsageUpdateParams = UsageAPI.UsageUpdateParams;
367
- export import UsageUpdateByExternalIDParams = UsageAPI.UsageUpdateByExternalIDParams;
368
- }