@stigg/typescript 0.1.0-beta.61 → 0.1.0-beta.62

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 (57) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/package.json +1 -1
  3. package/resources/v1/addons/addons.d.mts +1 -1
  4. package/resources/v1/addons/addons.d.ts +1 -1
  5. package/resources/v1/credits/credits.d.mts +77 -2
  6. package/resources/v1/credits/credits.d.mts.map +1 -1
  7. package/resources/v1/credits/credits.d.ts +77 -2
  8. package/resources/v1/credits/credits.d.ts.map +1 -1
  9. package/resources/v1/credits/credits.js +4 -0
  10. package/resources/v1/credits/credits.js.map +1 -1
  11. package/resources/v1/credits/credits.mjs +4 -0
  12. package/resources/v1/credits/credits.mjs.map +1 -1
  13. package/resources/v1/credits/index.d.mts +1 -0
  14. package/resources/v1/credits/index.d.mts.map +1 -1
  15. package/resources/v1/credits/index.d.ts +1 -0
  16. package/resources/v1/credits/index.d.ts.map +1 -1
  17. package/resources/v1/credits/index.js +3 -1
  18. package/resources/v1/credits/index.js.map +1 -1
  19. package/resources/v1/credits/index.mjs +1 -0
  20. package/resources/v1/credits/index.mjs.map +1 -1
  21. package/resources/v1/credits/reservations.d.mts +128 -0
  22. package/resources/v1/credits/reservations.d.mts.map +1 -0
  23. package/resources/v1/credits/reservations.d.ts +128 -0
  24. package/resources/v1/credits/reservations.d.ts.map +1 -0
  25. package/resources/v1/credits/reservations.js +30 -0
  26. package/resources/v1/credits/reservations.js.map +1 -0
  27. package/resources/v1/credits/reservations.mjs +26 -0
  28. package/resources/v1/credits/reservations.mjs.map +1 -0
  29. package/resources/v1/customers/customers.d.mts +25 -0
  30. package/resources/v1/customers/customers.d.mts.map +1 -1
  31. package/resources/v1/customers/customers.d.ts +25 -0
  32. package/resources/v1/customers/customers.d.ts.map +1 -1
  33. package/resources/v1/customers/customers.js.map +1 -1
  34. package/resources/v1/customers/customers.mjs.map +1 -1
  35. package/resources/v1/plans/plans.d.mts +1 -1
  36. package/resources/v1/plans/plans.d.ts +1 -1
  37. package/resources/v1/usage.d.mts +8 -7
  38. package/resources/v1/usage.d.mts.map +1 -1
  39. package/resources/v1/usage.d.ts +8 -7
  40. package/resources/v1/usage.d.ts.map +1 -1
  41. package/resources/v2/usage.d.mts +4 -3
  42. package/resources/v2/usage.d.mts.map +1 -1
  43. package/resources/v2/usage.d.ts +4 -3
  44. package/resources/v2/usage.d.ts.map +1 -1
  45. package/src/resources/v1/addons/addons.ts +1 -1
  46. package/src/resources/v1/credits/credits.ts +109 -2
  47. package/src/resources/v1/credits/index.ts +1 -0
  48. package/src/resources/v1/credits/reservations.ts +172 -0
  49. package/src/resources/v1/customers/customers.ts +30 -0
  50. package/src/resources/v1/plans/plans.ts +1 -1
  51. package/src/resources/v1/usage.ts +8 -7
  52. package/src/resources/v2/usage.ts +4 -3
  53. package/src/version.ts +1 -1
  54. package/version.d.mts +1 -1
  55. package/version.d.ts +1 -1
  56. package/version.js +1 -1
  57. package/version.mjs +1 -1
@@ -33,6 +33,8 @@ import {
33
33
  GrantVoidParams,
34
34
  Grants,
35
35
  } from './grants';
36
+ import * as ReservationsAPI from './reservations';
37
+ import { ReservationReleaseParams, ReservationReleaseResponse, Reservations } from './reservations';
36
38
  import { APIPromise } from '../../../core/api-promise';
37
39
  import { MyCursorIDPage, type MyCursorIDPageParams, PagePromise } from '../../../core/pagination';
38
40
  import { buildHeaders } from '../../../internal/headers';
@@ -44,6 +46,7 @@ export class Credits extends APIResource {
44
46
  this._client,
45
47
  );
46
48
  consumption: ConsumptionAPI.Consumption = new ConsumptionAPI.Consumption(this._client);
49
+ reservations: ReservationsAPI.Reservations = new ReservationsAPI.Reservations(this._client);
47
50
 
48
51
  /**
49
52
  * Retrieves the automatic recharge configuration for a customer and currency.
@@ -347,10 +350,17 @@ export namespace CreditGetUsageResponse {
347
350
  */
348
351
  export interface CreditListLedgerResponse {
349
352
  /**
350
- * The credit amount for this event
353
+ * The amount of the ledger event. Reservation events carry their net effect on the
354
+ * balance: a reserve is negative, and so is a release that consumed more than was
355
+ * held
351
356
  */
352
357
  amount: number;
353
358
 
359
+ /**
360
+ * On a released reservation, the credits consumed from each grant
361
+ */
362
+ breakdown: Array<CreditListLedgerResponse.Breakdown> | null;
363
+
354
364
  /**
355
365
  * The credit currency ID
356
366
  */
@@ -381,13 +391,32 @@ export interface CreditListLedgerResponse {
381
391
  | 'CREDITS_VOIDED'
382
392
  | 'CREDITS_UPDATED'
383
393
  | 'CREDITS_CONSUMPTION_TRANSFER_SOURCE'
384
- | 'CREDITS_CONSUMPTION_TRANSFER_TARGET';
394
+ | 'CREDITS_CONSUMPTION_TRANSFER_TARGET'
395
+ | 'CREDITS_RESERVED'
396
+ | 'CREDITS_RESERVATION_RELEASED'
397
+ | 'CREDITS_RESERVATION_EXPIRED';
385
398
 
386
399
  /**
387
400
  * The feature ID associated with this event
388
401
  */
389
402
  featureId: string | null;
390
403
 
404
+ /**
405
+ * On a released reservation, the held amount returned to the balance before
406
+ * consumed credits are deducted
407
+ */
408
+ holdReturnedAmount: number | null;
409
+
410
+ /**
411
+ * The metadata sent with the credit reservation
412
+ */
413
+ metadata: { [key: string]: string } | null;
414
+
415
+ /**
416
+ * The credit reservation this event belongs to
417
+ */
418
+ reservationId: string | null;
419
+
391
420
  /**
392
421
  * The resource ID this event is scoped to
393
422
  */
@@ -399,6 +428,72 @@ export interface CreditListLedgerResponse {
399
428
  timestamp: string;
400
429
  }
401
430
 
431
+ export namespace CreditListLedgerResponse {
432
+ export interface Breakdown {
433
+ /**
434
+ * The amount of the ledger event. Reservation events carry their net effect on the
435
+ * balance: a reserve is negative, and so is a release that consumed more than was
436
+ * held
437
+ */
438
+ amount: number;
439
+
440
+ /**
441
+ * The credit currency ID
442
+ */
443
+ creditCurrencyId: string;
444
+
445
+ /**
446
+ * The credit grant ID associated with this event
447
+ */
448
+ creditGrantId: string;
449
+
450
+ /**
451
+ * The customer ID this event belongs to
452
+ */
453
+ customerId: string;
454
+
455
+ /**
456
+ * The unique event identifier
457
+ */
458
+ eventId: string | null;
459
+
460
+ /**
461
+ * The type of credit event
462
+ */
463
+ eventType:
464
+ | 'CREDITS_GRANTED'
465
+ | 'CREDITS_EXPIRED'
466
+ | 'CREDITS_CONSUMED'
467
+ | 'CREDITS_VOIDED'
468
+ | 'CREDITS_UPDATED'
469
+ | 'CREDITS_CONSUMPTION_TRANSFER_SOURCE'
470
+ | 'CREDITS_CONSUMPTION_TRANSFER_TARGET'
471
+ | 'CREDITS_RESERVED'
472
+ | 'CREDITS_RESERVATION_RELEASED'
473
+ | 'CREDITS_RESERVATION_EXPIRED';
474
+
475
+ /**
476
+ * The feature ID associated with this event
477
+ */
478
+ featureId: string | null;
479
+
480
+ /**
481
+ * The credit reservation this event belongs to
482
+ */
483
+ reservationId: string | null;
484
+
485
+ /**
486
+ * The resource ID this event is scoped to
487
+ */
488
+ resourceId: string | null;
489
+
490
+ /**
491
+ * The timestamp when the event occurred
492
+ */
493
+ timestamp: string;
494
+ }
495
+ }
496
+
402
497
  export interface CreditGetAutoRechargeParams {
403
498
  /**
404
499
  * Query param: Filter by currency ID (required)
@@ -511,6 +606,11 @@ export interface CreditListLedgerParams extends MyCursorIDPageParams {
511
606
  */
512
607
  eventType?: string;
513
608
 
609
+ /**
610
+ * Query param: Filter by credit reservation ID
611
+ */
612
+ reservationId?: string;
613
+
514
614
  /**
515
615
  * Query param: Filter by resource ID
516
616
  */
@@ -533,6 +633,7 @@ export interface CreditListLedgerParams extends MyCursorIDPageParams {
533
633
  Credits.Grants = Grants;
534
634
  Credits.CustomCurrencies = CustomCurrencies;
535
635
  Credits.Consumption = Consumption;
636
+ Credits.Reservations = Reservations;
536
637
 
537
638
  export declare namespace Credits {
538
639
  export {
@@ -576,4 +677,10 @@ export declare namespace Credits {
576
677
  type ConsumptionConsumeParams as ConsumptionConsumeParams,
577
678
  type ConsumptionConsumeAsyncParams as ConsumptionConsumeAsyncParams,
578
679
  };
680
+
681
+ export {
682
+ Reservations as Reservations,
683
+ type ReservationReleaseResponse as ReservationReleaseResponse,
684
+ type ReservationReleaseParams as ReservationReleaseParams,
685
+ };
579
686
  }
@@ -39,3 +39,4 @@ export {
39
39
  type GrantVoidParams,
40
40
  type GrantListResponsesMyCursorIDPage,
41
41
  } from './grants';
42
+ export { Reservations, type ReservationReleaseResponse, type ReservationReleaseParams } from './reservations';
@@ -0,0 +1,172 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { buildHeaders } from '../../../internal/headers';
6
+ import { RequestOptions } from '../../../internal/request-options';
7
+ import { path } from '../../../internal/utils/path';
8
+
9
+ export class Reservations extends APIResource {
10
+ /**
11
+ * Releases a credit reservation, consuming the given amount and returning the rest
12
+ * of the held credits to the balance. Retry a failed release with the same
13
+ * reservation ID; it is applied once.
14
+ */
15
+ release(
16
+ reservationID: string,
17
+ params: ReservationReleaseParams,
18
+ options?: RequestOptions,
19
+ ): APIPromise<ReservationReleaseResponse> {
20
+ const { 'X-ACCOUNT-ID': xAccountID, 'X-ENVIRONMENT-ID': xEnvironmentID, ...body } = params;
21
+ return this._client.post(path`/api/v1/credits/reservations/${reservationID}/release`, {
22
+ body,
23
+ ...options,
24
+ headers: buildHeaders([
25
+ {
26
+ ...(xAccountID != null ? { 'X-ACCOUNT-ID': xAccountID } : undefined),
27
+ ...(xEnvironmentID != null ? { 'X-ENVIRONMENT-ID': xEnvironmentID } : undefined),
28
+ },
29
+ options?.headers,
30
+ ]),
31
+ });
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Response object
37
+ */
38
+ export interface ReservationReleaseResponse {
39
+ /**
40
+ * Result of releasing a credit reservation
41
+ */
42
+ data: ReservationReleaseResponse.Data;
43
+ }
44
+
45
+ export namespace ReservationReleaseResponse {
46
+ /**
47
+ * Result of releasing a credit reservation
48
+ */
49
+ export interface Data {
50
+ /**
51
+ * The optimistic credit balance after the release
52
+ */
53
+ credit: Data.Credit | null;
54
+
55
+ /**
56
+ * The released reservation
57
+ */
58
+ reservation: Data.Reservation;
59
+ }
60
+
61
+ export namespace Data {
62
+ /**
63
+ * The optimistic credit balance after the release
64
+ */
65
+ export interface Credit {
66
+ /**
67
+ * The credit currency identifier
68
+ */
69
+ currencyId: string;
70
+
71
+ /**
72
+ * The wallet's total consumed credits for this currency (optimistic — includes
73
+ * not-yet-reconciled usage), shared across every feature that draws on the
74
+ * currency. This is the running balance, not this call's deduction — see
75
+ * `consumed` for that.
76
+ */
77
+ currentUsage: number;
78
+
79
+ /**
80
+ * The grant-version timestamp of this balance, used by the SDK for last-write-wins
81
+ * reconciliation
82
+ */
83
+ timestamp: string;
84
+
85
+ /**
86
+ * The total credits granted
87
+ */
88
+ usageLimit: number;
89
+
90
+ /**
91
+ * End of the current credit grant period (when recurring credits reset), if
92
+ * applicable
93
+ */
94
+ usagePeriodEnd?: string | null;
95
+ }
96
+
97
+ /**
98
+ * The released reservation
99
+ */
100
+ export interface Reservation {
101
+ /**
102
+ * The client-provided reservation ID.
103
+ */
104
+ id: string;
105
+
106
+ /**
107
+ * The amount of credits held.
108
+ */
109
+ amount: number;
110
+
111
+ /**
112
+ * The amount consumed at release
113
+ */
114
+ consumedAmount: number | null;
115
+
116
+ /**
117
+ * When the reservation expires. Unreleased credits return to the balance at this
118
+ * time.
119
+ */
120
+ expiresAt: string;
121
+
122
+ /**
123
+ * The status of the reservation.
124
+ */
125
+ status: 'ACTIVE' | 'RELEASED';
126
+ }
127
+ }
128
+ }
129
+
130
+ export interface ReservationReleaseParams {
131
+ /**
132
+ * Body param: The amount of credits to consume at release. Up to the reserved
133
+ * amount is charged to the credits that backed the reservation; the rest returns
134
+ * to the balance, and any amount above the reservation is consumed normally.
135
+ */
136
+ consumedAmount: number;
137
+
138
+ /**
139
+ * Body param: The credit currency of the reservation
140
+ */
141
+ currencyId: string;
142
+
143
+ /**
144
+ * Body param: The customer the reservation was made for
145
+ */
146
+ customerId: string;
147
+
148
+ /**
149
+ * Body param: The resource the reservation was made for, if any
150
+ */
151
+ resourceId?: string;
152
+
153
+ /**
154
+ * Header param: Account ID — optional when authenticating with a user JWT (Bearer
155
+ * token); falls back to the user's first membership. Ignored for API-key auth.
156
+ */
157
+ 'X-ACCOUNT-ID'?: string;
158
+
159
+ /**
160
+ * Header param: Environment ID — required when authenticating with a user JWT
161
+ * (Bearer token) on environment-scoped endpoints. Ignored for API-key auth (env is
162
+ * intrinsic to the key).
163
+ */
164
+ 'X-ENVIRONMENT-ID'?: string;
165
+ }
166
+
167
+ export declare namespace Reservations {
168
+ export {
169
+ type ReservationReleaseResponse as ReservationReleaseResponse,
170
+ type ReservationReleaseParams as ReservationReleaseParams,
171
+ };
172
+ }
@@ -3294,6 +3294,36 @@ export interface CustomerCheckEntitlementParams {
3294
3294
  */
3295
3295
  requestedValues?: Array<string>;
3296
3296
 
3297
+ /**
3298
+ * Query param: When the reservation expires (ISO 8601, at most 24 hours ahead).
3299
+ * Mutually exclusive with `reservationTtlSeconds`.
3300
+ */
3301
+ reservationExpiresAt?: string;
3302
+
3303
+ /**
3304
+ * Query param: Client-provided reservation ID, required with `reserveAmount`.
3305
+ * Retry with the same ID to get the same result; reuse with different parameters
3306
+ * is a conflict.
3307
+ */
3308
+ reservationId?: string;
3309
+
3310
+ /**
3311
+ * Query param: JSON-encoded object of string values to attach to the reservation.
3312
+ */
3313
+ reservationMetadata?: string;
3314
+
3315
+ /**
3316
+ * Query param: How long the reservation holds the credits, in seconds (1–86400,
3317
+ * default 3600). Mutually exclusive with `reservationExpiresAt`.
3318
+ */
3319
+ reservationTtlSeconds?: number;
3320
+
3321
+ /**
3322
+ * Query param: Credits to reserve (credit entitlements only). The check is decided
3323
+ * and the credits held atomically; `requestedUsage` is ignored.
3324
+ */
3325
+ reserveAmount?: number;
3326
+
3297
3327
  /**
3298
3328
  * Query param: Resource ID to scope the entitlement check to a specific resource
3299
3329
  */
@@ -2692,7 +2692,7 @@ export namespace PlanUpdateParams {
2692
2692
  featureId?: string;
2693
2693
 
2694
2694
  /**
2695
- * Maximum number of units (max 999999)
2695
+ * Maximum number of units
2696
2696
  */
2697
2697
  maxUnitQuantity?: number;
2698
2698
 
@@ -391,10 +391,10 @@ export interface UsageEstimateParams {
391
391
  featureId: string;
392
392
 
393
393
  /**
394
- * Body param: The value to report for usage. Must be a whole number — the REST API
395
- * does not accept fractional (float) usage values; scale up (e.g. report cents
396
- * instead of dollars, or milliseconds instead of seconds) if you need sub-unit
397
- * precision.
394
+ * Body param: The value to report for usage. Fractional values are accepted and
395
+ * rounded half away from zero to 5 decimal places. A value with a fractional part
396
+ * must have an absolute value below 34,359,738,368 (2^35); whole numbers are
397
+ * accepted up to ±9,007,199,254,740,991.
398
398
  */
399
399
  value: number;
400
400
 
@@ -511,9 +511,10 @@ export namespace UsageReportParams {
511
511
  featureId: string;
512
512
 
513
513
  /**
514
- * The value to report for usage. Must be a whole number — the REST API does not
515
- * accept fractional (float) usage values; scale up (e.g. report cents instead of
516
- * dollars, or milliseconds instead of seconds) if you need sub-unit precision.
514
+ * The value to report for usage. Fractional values are accepted and rounded half
515
+ * away from zero to 5 decimal places. A value with a fractional part must have an
516
+ * absolute value below 34,359,738,368 (2^35); whole numbers are accepted up to
517
+ * ±9,007,199,254,740,991.
517
518
  */
518
519
  value: number;
519
520
 
@@ -299,9 +299,10 @@ export namespace UsageReportParams {
299
299
  featureId: string;
300
300
 
301
301
  /**
302
- * The value to report for usage. Must be a whole number — the REST API does not
303
- * accept fractional (float) usage values; scale up (e.g. report cents instead of
304
- * dollars, or milliseconds instead of seconds) if you need sub-unit precision.
302
+ * The value to report for usage. Fractional values are accepted and rounded half
303
+ * away from zero to 5 decimal places. A value with a fractional part must have an
304
+ * absolute value below 34,359,738,368 (2^35); whole numbers are accepted up to
305
+ * ±9,007,199,254,740,991.
305
306
  */
306
307
  value: number;
307
308
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.1.0-beta.61'; // x-release-please-version
1
+ export const VERSION = '0.1.0-beta.62'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.0-beta.61";
1
+ export declare const VERSION = "0.1.0-beta.62";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.0-beta.61";
1
+ export declare const VERSION = "0.1.0-beta.62";
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 = '0.1.0-beta.61'; // x-release-please-version
4
+ exports.VERSION = '0.1.0-beta.62'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.1.0-beta.61'; // x-release-please-version
1
+ export const VERSION = '0.1.0-beta.62'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map