@nirvana-labs/nirvana 1.95.3 → 1.96.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 (62) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/resources/organizations/billing/billing.d.mts +208 -0
  4. package/resources/organizations/billing/billing.d.mts.map +1 -0
  5. package/resources/organizations/billing/billing.d.ts +208 -0
  6. package/resources/organizations/billing/billing.d.ts.map +1 -0
  7. package/resources/organizations/billing/billing.js +112 -0
  8. package/resources/organizations/billing/billing.js.map +1 -0
  9. package/resources/organizations/billing/billing.mjs +107 -0
  10. package/resources/organizations/billing/billing.mjs.map +1 -0
  11. package/resources/organizations/billing/index.d.mts +3 -0
  12. package/resources/organizations/billing/index.d.mts.map +1 -0
  13. package/resources/organizations/billing/index.d.ts +3 -0
  14. package/resources/organizations/billing/index.d.ts.map +1 -0
  15. package/resources/organizations/billing/index.js +9 -0
  16. package/resources/organizations/billing/index.js.map +1 -0
  17. package/resources/organizations/billing/index.mjs +4 -0
  18. package/resources/organizations/billing/index.mjs.map +1 -0
  19. package/resources/organizations/billing/recharge-policy.d.mts +81 -0
  20. package/resources/organizations/billing/recharge-policy.d.mts.map +1 -0
  21. package/resources/organizations/billing/recharge-policy.d.ts +81 -0
  22. package/resources/organizations/billing/recharge-policy.d.ts.map +1 -0
  23. package/resources/organizations/billing/recharge-policy.js +45 -0
  24. package/resources/organizations/billing/recharge-policy.js.map +1 -0
  25. package/resources/organizations/billing/recharge-policy.mjs +41 -0
  26. package/resources/organizations/billing/recharge-policy.mjs.map +1 -0
  27. package/resources/organizations/billing.d.mts +1 -203
  28. package/resources/organizations/billing.d.mts.map +1 -1
  29. package/resources/organizations/billing.d.ts +1 -203
  30. package/resources/organizations/billing.d.ts.map +1 -1
  31. package/resources/organizations/billing.js +2 -100
  32. package/resources/organizations/billing.js.map +1 -1
  33. package/resources/organizations/billing.mjs +1 -98
  34. package/resources/organizations/billing.mjs.map +1 -1
  35. package/resources/organizations/index.d.mts +1 -1
  36. package/resources/organizations/index.d.mts.map +1 -1
  37. package/resources/organizations/index.d.ts +1 -1
  38. package/resources/organizations/index.d.ts.map +1 -1
  39. package/resources/organizations/index.js +2 -2
  40. package/resources/organizations/index.js.map +1 -1
  41. package/resources/organizations/index.mjs +1 -1
  42. package/resources/organizations/index.mjs.map +1 -1
  43. package/resources/organizations/organizations.d.mts +2 -2
  44. package/resources/organizations/organizations.d.mts.map +1 -1
  45. package/resources/organizations/organizations.d.ts +2 -2
  46. package/resources/organizations/organizations.d.ts.map +1 -1
  47. package/resources/organizations/organizations.js +2 -2
  48. package/resources/organizations/organizations.js.map +1 -1
  49. package/resources/organizations/organizations.mjs +2 -2
  50. package/resources/organizations/organizations.mjs.map +1 -1
  51. package/src/resources/organizations/api.md +23 -10
  52. package/src/resources/organizations/billing/billing.ts +301 -0
  53. package/src/resources/organizations/billing/index.ts +21 -0
  54. package/src/resources/organizations/billing/recharge-policy.ts +109 -0
  55. package/src/resources/organizations/billing.ts +1 -279
  56. package/src/resources/organizations/index.ts +1 -1
  57. package/src/resources/organizations/organizations.ts +11 -11
  58. package/src/version.ts +1 -1
  59. package/version.d.mts +1 -1
  60. package/version.d.ts +1 -1
  61. package/version.js +1 -1
  62. package/version.mjs +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.96.0](https://github.com/nirvana-labs/nirvana-typescript/compare/v1.95.3...v1.96.0) (2026-07-22)
4
+
5
+
6
+ ### Features
7
+
8
+ * **stainless:** add recharge_policy group to SDK config ([6f980be](https://github.com/nirvana-labs/nirvana-typescript/commit/6f980be1346829f1830b36100a6d20f2a4cb9f33))
9
+
3
10
  ## [1.95.3](https://github.com/nirvana-labs/nirvana-typescript/compare/v1.95.2...v1.95.3) (2026-07-22)
4
11
 
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nirvana-labs/nirvana",
3
- "version": "1.95.3",
3
+ "version": "1.96.0",
4
4
  "description": "The official TypeScript library for the Nirvana Labs API",
5
5
  "author": "Nirvana Labs <engineering@nirvanalabs.io>",
6
6
  "types": "./index.d.ts",
@@ -0,0 +1,208 @@
1
+ import { APIResource } from "../../../core/resource.mjs";
2
+ import * as Shared from "../../shared.mjs";
3
+ import * as RechargePolicyAPI from "./recharge-policy.mjs";
4
+ import { AutomaticPolicyArgs, OrganizationRechargePolicy, RechargePolicy, RechargePolicyMode, RechargePolicyUpdateParams } from "./recharge-policy.mjs";
5
+ import { APIPromise } from "../../../core/api-promise.mjs";
6
+ import { RequestOptions } from "../../../internal/request-options.mjs";
7
+ export declare class Billing extends APIResource {
8
+ rechargePolicy: RechargePolicyAPI.RechargePolicy;
9
+ /**
10
+ * Get the organization's billing summary: effective balance, monthly and daily
11
+ * run-rate cost, runway, and the projected next-recharge date. Costs are run-rate
12
+ * projections.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const organizationBillingSummary =
17
+ * await client.organizations.billing.summary(
18
+ * 'organization_id',
19
+ * );
20
+ * ```
21
+ */
22
+ summary(organizationID: string, options?: RequestOptions): APIPromise<Shared.OrganizationBillingSummary>;
23
+ /**
24
+ * Get the organization's total usage cost per UTC day over a date range (max 90
25
+ * days), summing open and closed resources. One entry per day, oldest first.
26
+ * Defaults to the last 30 days.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const organizationDailyCost =
31
+ * await client.organizations.billing.cost(
32
+ * 'organization_id',
33
+ * );
34
+ * ```
35
+ */
36
+ cost(organizationID: string, query?: BillingCostParams | null | undefined, options?: RequestOptions): APIPromise<OrganizationDailyCost>;
37
+ /**
38
+ * List the organization's billing history: prepaid credits, top-ups, and manual
39
+ * adjustments, newest first. Paginated with an opaque cursor.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const billingHistoryEntryList =
44
+ * await client.organizations.billing.history(
45
+ * 'organization_id',
46
+ * );
47
+ * ```
48
+ */
49
+ history(organizationID: string, query?: BillingHistoryParams | null | undefined, options?: RequestOptions): APIPromise<BillingHistoryEntryList>;
50
+ /**
51
+ * Charge the card on file and credit the prepaid balance. A unique Idempotency-Key
52
+ * header is required; reuse it across retries so a timed-out top-up is not charged
53
+ * twice.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const organizationBillingSummary =
58
+ * await client.organizations.billing.topUp(
59
+ * 'organization_id',
60
+ * {
61
+ * amount: '50.00',
62
+ * 'Idempotency-Key': 'Idempotency-Key',
63
+ * },
64
+ * );
65
+ * ```
66
+ */
67
+ topUp(organizationID: string, params: BillingTopUpParams, options?: RequestOptions): APIPromise<Shared.OrganizationBillingSummary>;
68
+ /**
69
+ * Charge the card on file up to the recharge target now instead of waiting for the
70
+ * scheduled retry. Automatic-policy prepaid organizations only. Idempotency-Key
71
+ * header required.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const organizationBillingSummary =
76
+ * await client.organizations.billing.recharge(
77
+ * 'organization_id',
78
+ * { 'Idempotency-Key': 'Idempotency-Key' },
79
+ * );
80
+ * ```
81
+ */
82
+ recharge(organizationID: string, params: BillingRechargeParams, options?: RequestOptions): APIPromise<Shared.OrganizationBillingSummary>;
83
+ }
84
+ /**
85
+ * A single billing history line item: a prepaid credit or a manual adjustment.
86
+ */
87
+ export interface BillingHistoryEntry {
88
+ /**
89
+ * Unique identifier for the entry.
90
+ */
91
+ id: string;
92
+ /**
93
+ * Arbitrary-precision decimal serialized as a string (e.g. "58.40").
94
+ */
95
+ amount: string;
96
+ /**
97
+ * When the entry was recorded.
98
+ */
99
+ created_at: string;
100
+ /**
101
+ * ISO 4217 currency code.
102
+ */
103
+ currency: string;
104
+ /**
105
+ * Kind of entry.
106
+ */
107
+ type: BillingHistoryEntryType;
108
+ /**
109
+ * Human-readable note describing the entry, when available.
110
+ */
111
+ description?: string | null;
112
+ /**
113
+ * Link to the hosted receipt for the payment behind this entry, when one is
114
+ * available. Present for prepaid credits funded by a card charge; absent for
115
+ * manual adjustments and while a payment's receipt is still being finalized.
116
+ */
117
+ receipt_url?: string | null;
118
+ }
119
+ export interface BillingHistoryEntryList {
120
+ items: Array<BillingHistoryEntry>;
121
+ /**
122
+ * Pagination response details.
123
+ */
124
+ pagination: Shared.Pagination;
125
+ }
126
+ /**
127
+ * Kind of entry.
128
+ */
129
+ export type BillingHistoryEntryType = 'grant' | 'adjustment';
130
+ /**
131
+ * Total usage cost for a single UTC day.
132
+ */
133
+ export interface DailyCostPoint {
134
+ /**
135
+ * Arbitrary-precision decimal serialized as a string (e.g. "58.40").
136
+ */
137
+ cost: string;
138
+ /**
139
+ * UTC calendar day (YYYY-MM-DD).
140
+ */
141
+ date: string;
142
+ }
143
+ /**
144
+ * Daily usage cost over a date range: one entry per UTC day (zero on idle days),
145
+ * summing open and closed resources. Suitable for a daily cost bar chart.
146
+ */
147
+ export interface OrganizationDailyCost {
148
+ /**
149
+ * ISO 4217 currency code.
150
+ */
151
+ currency: string;
152
+ /**
153
+ * One entry per UTC day in the range, oldest first.
154
+ */
155
+ days: Array<DailyCostPoint>;
156
+ /**
157
+ * Inclusive start of the range, as a UTC calendar day (YYYY-MM-DD).
158
+ */
159
+ from: string;
160
+ /**
161
+ * Inclusive end of the range, as a UTC calendar day (YYYY-MM-DD).
162
+ */
163
+ to: string;
164
+ }
165
+ export interface BillingCostParams {
166
+ /**
167
+ * Inclusive start day, YYYY-MM-DD (UTC). Defaults to 30 days before to.
168
+ */
169
+ from?: string;
170
+ /**
171
+ * Inclusive end day, YYYY-MM-DD (UTC). Defaults to today.
172
+ */
173
+ to?: string;
174
+ }
175
+ export interface BillingHistoryParams {
176
+ /**
177
+ * Pagination cursor returned by a previous request
178
+ */
179
+ cursor?: string;
180
+ /**
181
+ * Maximum number of items to return
182
+ */
183
+ limit?: number;
184
+ }
185
+ export interface BillingTopUpParams {
186
+ /**
187
+ * Body param: Amount to charge and credit, in USD. Must be greater than 0, at most
188
+ * two decimal places, and at most 10000.
189
+ */
190
+ amount: string;
191
+ /**
192
+ * Header param: Unique idempotency key scoping the charge; reuse the same value
193
+ * across retries so a timed-out top-up is not charged twice
194
+ */
195
+ 'Idempotency-Key': string;
196
+ }
197
+ export interface BillingRechargeParams {
198
+ /**
199
+ * Idempotency key scoping one charge attempt; reuse to retry it, but use a fresh
200
+ * key for a new attempt (e.g. after updating a declined card)
201
+ */
202
+ 'Idempotency-Key': string;
203
+ }
204
+ export declare namespace Billing {
205
+ export { type BillingHistoryEntry as BillingHistoryEntry, type BillingHistoryEntryList as BillingHistoryEntryList, type BillingHistoryEntryType as BillingHistoryEntryType, type DailyCostPoint as DailyCostPoint, type OrganizationDailyCost as OrganizationDailyCost, type BillingCostParams as BillingCostParams, type BillingHistoryParams as BillingHistoryParams, type BillingTopUpParams as BillingTopUpParams, type BillingRechargeParams as BillingRechargeParams, };
206
+ export { RechargePolicy as RechargePolicy, type AutomaticPolicyArgs as AutomaticPolicyArgs, type OrganizationRechargePolicy as OrganizationRechargePolicy, type RechargePolicyMode as RechargePolicyMode, type RechargePolicyUpdateParams as RechargePolicyUpdateParams, };
207
+ }
208
+ //# sourceMappingURL=billing.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.d.mts","sourceRoot":"","sources":["../../../src/resources/organizations/billing/billing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,mCAA+B;AACrD,OAAO,KAAK,MAAM,yBAAqB;AACvC,OAAO,KAAK,iBAAiB,8BAA0B;AACvD,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC3B,8BAA0B;AAC3B,OAAO,EAAE,UAAU,EAAE,sCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,8CAA0C;AAGnE,qBAAa,OAAQ,SAAQ,WAAW;IACtC,cAAc,EAAE,iBAAiB,CAAC,cAAc,CAAsD;IAEtG;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,cAAc,EAAE,MAAM,EA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KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;IAEF,OAAO,EACL,cAAc,IAAI,cAAc,EAChC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
@@ -0,0 +1,208 @@
1
+ import { APIResource } from "../../../core/resource.js";
2
+ import * as Shared from "../../shared.js";
3
+ import * as RechargePolicyAPI from "./recharge-policy.js";
4
+ import { AutomaticPolicyArgs, OrganizationRechargePolicy, RechargePolicy, RechargePolicyMode, RechargePolicyUpdateParams } from "./recharge-policy.js";
5
+ import { APIPromise } from "../../../core/api-promise.js";
6
+ import { RequestOptions } from "../../../internal/request-options.js";
7
+ export declare class Billing extends APIResource {
8
+ rechargePolicy: RechargePolicyAPI.RechargePolicy;
9
+ /**
10
+ * Get the organization's billing summary: effective balance, monthly and daily
11
+ * run-rate cost, runway, and the projected next-recharge date. Costs are run-rate
12
+ * projections.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const organizationBillingSummary =
17
+ * await client.organizations.billing.summary(
18
+ * 'organization_id',
19
+ * );
20
+ * ```
21
+ */
22
+ summary(organizationID: string, options?: RequestOptions): APIPromise<Shared.OrganizationBillingSummary>;
23
+ /**
24
+ * Get the organization's total usage cost per UTC day over a date range (max 90
25
+ * days), summing open and closed resources. One entry per day, oldest first.
26
+ * Defaults to the last 30 days.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const organizationDailyCost =
31
+ * await client.organizations.billing.cost(
32
+ * 'organization_id',
33
+ * );
34
+ * ```
35
+ */
36
+ cost(organizationID: string, query?: BillingCostParams | null | undefined, options?: RequestOptions): APIPromise<OrganizationDailyCost>;
37
+ /**
38
+ * List the organization's billing history: prepaid credits, top-ups, and manual
39
+ * adjustments, newest first. Paginated with an opaque cursor.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const billingHistoryEntryList =
44
+ * await client.organizations.billing.history(
45
+ * 'organization_id',
46
+ * );
47
+ * ```
48
+ */
49
+ history(organizationID: string, query?: BillingHistoryParams | null | undefined, options?: RequestOptions): APIPromise<BillingHistoryEntryList>;
50
+ /**
51
+ * Charge the card on file and credit the prepaid balance. A unique Idempotency-Key
52
+ * header is required; reuse it across retries so a timed-out top-up is not charged
53
+ * twice.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const organizationBillingSummary =
58
+ * await client.organizations.billing.topUp(
59
+ * 'organization_id',
60
+ * {
61
+ * amount: '50.00',
62
+ * 'Idempotency-Key': 'Idempotency-Key',
63
+ * },
64
+ * );
65
+ * ```
66
+ */
67
+ topUp(organizationID: string, params: BillingTopUpParams, options?: RequestOptions): APIPromise<Shared.OrganizationBillingSummary>;
68
+ /**
69
+ * Charge the card on file up to the recharge target now instead of waiting for the
70
+ * scheduled retry. Automatic-policy prepaid organizations only. Idempotency-Key
71
+ * header required.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const organizationBillingSummary =
76
+ * await client.organizations.billing.recharge(
77
+ * 'organization_id',
78
+ * { 'Idempotency-Key': 'Idempotency-Key' },
79
+ * );
80
+ * ```
81
+ */
82
+ recharge(organizationID: string, params: BillingRechargeParams, options?: RequestOptions): APIPromise<Shared.OrganizationBillingSummary>;
83
+ }
84
+ /**
85
+ * A single billing history line item: a prepaid credit or a manual adjustment.
86
+ */
87
+ export interface BillingHistoryEntry {
88
+ /**
89
+ * Unique identifier for the entry.
90
+ */
91
+ id: string;
92
+ /**
93
+ * Arbitrary-precision decimal serialized as a string (e.g. "58.40").
94
+ */
95
+ amount: string;
96
+ /**
97
+ * When the entry was recorded.
98
+ */
99
+ created_at: string;
100
+ /**
101
+ * ISO 4217 currency code.
102
+ */
103
+ currency: string;
104
+ /**
105
+ * Kind of entry.
106
+ */
107
+ type: BillingHistoryEntryType;
108
+ /**
109
+ * Human-readable note describing the entry, when available.
110
+ */
111
+ description?: string | null;
112
+ /**
113
+ * Link to the hosted receipt for the payment behind this entry, when one is
114
+ * available. Present for prepaid credits funded by a card charge; absent for
115
+ * manual adjustments and while a payment's receipt is still being finalized.
116
+ */
117
+ receipt_url?: string | null;
118
+ }
119
+ export interface BillingHistoryEntryList {
120
+ items: Array<BillingHistoryEntry>;
121
+ /**
122
+ * Pagination response details.
123
+ */
124
+ pagination: Shared.Pagination;
125
+ }
126
+ /**
127
+ * Kind of entry.
128
+ */
129
+ export type BillingHistoryEntryType = 'grant' | 'adjustment';
130
+ /**
131
+ * Total usage cost for a single UTC day.
132
+ */
133
+ export interface DailyCostPoint {
134
+ /**
135
+ * Arbitrary-precision decimal serialized as a string (e.g. "58.40").
136
+ */
137
+ cost: string;
138
+ /**
139
+ * UTC calendar day (YYYY-MM-DD).
140
+ */
141
+ date: string;
142
+ }
143
+ /**
144
+ * Daily usage cost over a date range: one entry per UTC day (zero on idle days),
145
+ * summing open and closed resources. Suitable for a daily cost bar chart.
146
+ */
147
+ export interface OrganizationDailyCost {
148
+ /**
149
+ * ISO 4217 currency code.
150
+ */
151
+ currency: string;
152
+ /**
153
+ * One entry per UTC day in the range, oldest first.
154
+ */
155
+ days: Array<DailyCostPoint>;
156
+ /**
157
+ * Inclusive start of the range, as a UTC calendar day (YYYY-MM-DD).
158
+ */
159
+ from: string;
160
+ /**
161
+ * Inclusive end of the range, as a UTC calendar day (YYYY-MM-DD).
162
+ */
163
+ to: string;
164
+ }
165
+ export interface BillingCostParams {
166
+ /**
167
+ * Inclusive start day, YYYY-MM-DD (UTC). Defaults to 30 days before to.
168
+ */
169
+ from?: string;
170
+ /**
171
+ * Inclusive end day, YYYY-MM-DD (UTC). Defaults to today.
172
+ */
173
+ to?: string;
174
+ }
175
+ export interface BillingHistoryParams {
176
+ /**
177
+ * Pagination cursor returned by a previous request
178
+ */
179
+ cursor?: string;
180
+ /**
181
+ * Maximum number of items to return
182
+ */
183
+ limit?: number;
184
+ }
185
+ export interface BillingTopUpParams {
186
+ /**
187
+ * Body param: Amount to charge and credit, in USD. Must be greater than 0, at most
188
+ * two decimal places, and at most 10000.
189
+ */
190
+ amount: string;
191
+ /**
192
+ * Header param: Unique idempotency key scoping the charge; reuse the same value
193
+ * across retries so a timed-out top-up is not charged twice
194
+ */
195
+ 'Idempotency-Key': string;
196
+ }
197
+ export interface BillingRechargeParams {
198
+ /**
199
+ * Idempotency key scoping one charge attempt; reuse to retry it, but use a fresh
200
+ * key for a new attempt (e.g. after updating a declined card)
201
+ */
202
+ 'Idempotency-Key': string;
203
+ }
204
+ export declare namespace Billing {
205
+ export { type BillingHistoryEntry as BillingHistoryEntry, type BillingHistoryEntryList as BillingHistoryEntryList, type BillingHistoryEntryType as BillingHistoryEntryType, type DailyCostPoint as DailyCostPoint, type OrganizationDailyCost as OrganizationDailyCost, type BillingCostParams as BillingCostParams, type BillingHistoryParams as BillingHistoryParams, type BillingTopUpParams as BillingTopUpParams, type BillingRechargeParams as BillingRechargeParams, };
206
+ export { RechargePolicy as RechargePolicy, type AutomaticPolicyArgs as AutomaticPolicyArgs, type OrganizationRechargePolicy as OrganizationRechargePolicy, type RechargePolicyMode as RechargePolicyMode, type RechargePolicyUpdateParams as RechargePolicyUpdateParams, };
207
+ }
208
+ //# sourceMappingURL=billing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.d.ts","sourceRoot":"","sources":["../../../src/resources/organizations/billing/billing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,kCAA+B;AACrD,OAAO,KAAK,MAAM,wBAAqB;AACvC,OAAO,KAAK,iBAAiB,6BAA0B;AACvD,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC3B,6BAA0B;AAC3B,OAAO,EAAE,UAAU,EAAE,qCAAkC;AAEvD,OAAO,EAAE,cAAc,EAAE,6CAA0C;AAGnE,qBAAa,OAAQ,SAAQ,W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c,EACrC,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;IAEF,OAAO,EACL,cAAc,IAAI,cAAc,EAChC,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,0BAA0B,IAAI,0BAA0B,EAC7D,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,0BAA0B,IAAI,0BAA0B,GAC9D,CAAC;CACH"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Billing = void 0;
5
+ const tslib_1 = require("../../../internal/tslib.js");
6
+ const resource_1 = require("../../../core/resource.js");
7
+ const RechargePolicyAPI = tslib_1.__importStar(require("./recharge-policy.js"));
8
+ const recharge_policy_1 = require("./recharge-policy.js");
9
+ const headers_1 = require("../../../internal/headers.js");
10
+ const path_1 = require("../../../internal/utils/path.js");
11
+ class Billing extends resource_1.APIResource {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.rechargePolicy = new RechargePolicyAPI.RechargePolicy(this._client);
15
+ }
16
+ /**
17
+ * Get the organization's billing summary: effective balance, monthly and daily
18
+ * run-rate cost, runway, and the projected next-recharge date. Costs are run-rate
19
+ * projections.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const organizationBillingSummary =
24
+ * await client.organizations.billing.summary(
25
+ * 'organization_id',
26
+ * );
27
+ * ```
28
+ */
29
+ summary(organizationID, options) {
30
+ return this._client.get((0, path_1.path) `/v1/organizations/${organizationID}/billing/summary`, options);
31
+ }
32
+ /**
33
+ * Get the organization's total usage cost per UTC day over a date range (max 90
34
+ * days), summing open and closed resources. One entry per day, oldest first.
35
+ * Defaults to the last 30 days.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const organizationDailyCost =
40
+ * await client.organizations.billing.cost(
41
+ * 'organization_id',
42
+ * );
43
+ * ```
44
+ */
45
+ cost(organizationID, query = {}, options) {
46
+ return this._client.get((0, path_1.path) `/v1/organizations/${organizationID}/billing/cost`, { query, ...options });
47
+ }
48
+ /**
49
+ * List the organization's billing history: prepaid credits, top-ups, and manual
50
+ * adjustments, newest first. Paginated with an opaque cursor.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const billingHistoryEntryList =
55
+ * await client.organizations.billing.history(
56
+ * 'organization_id',
57
+ * );
58
+ * ```
59
+ */
60
+ history(organizationID, query = {}, options) {
61
+ return this._client.get((0, path_1.path) `/v1/organizations/${organizationID}/billing/history`, { query, ...options });
62
+ }
63
+ /**
64
+ * Charge the card on file and credit the prepaid balance. A unique Idempotency-Key
65
+ * header is required; reuse it across retries so a timed-out top-up is not charged
66
+ * twice.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const organizationBillingSummary =
71
+ * await client.organizations.billing.topUp(
72
+ * 'organization_id',
73
+ * {
74
+ * amount: '50.00',
75
+ * 'Idempotency-Key': 'Idempotency-Key',
76
+ * },
77
+ * );
78
+ * ```
79
+ */
80
+ topUp(organizationID, params, options) {
81
+ const { 'Idempotency-Key': idempotencyKey, ...body } = params;
82
+ return this._client.post((0, path_1.path) `/v1/organizations/${organizationID}/billing/topup`, {
83
+ body,
84
+ ...options,
85
+ headers: (0, headers_1.buildHeaders)([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
86
+ });
87
+ }
88
+ /**
89
+ * Charge the card on file up to the recharge target now instead of waiting for the
90
+ * scheduled retry. Automatic-policy prepaid organizations only. Idempotency-Key
91
+ * header required.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const organizationBillingSummary =
96
+ * await client.organizations.billing.recharge(
97
+ * 'organization_id',
98
+ * { 'Idempotency-Key': 'Idempotency-Key' },
99
+ * );
100
+ * ```
101
+ */
102
+ recharge(organizationID, params, options) {
103
+ const { 'Idempotency-Key': idempotencyKey } = params;
104
+ return this._client.post((0, path_1.path) `/v1/organizations/${organizationID}/billing/recharge`, {
105
+ ...options,
106
+ headers: (0, headers_1.buildHeaders)([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
107
+ });
108
+ }
109
+ }
110
+ exports.Billing = Billing;
111
+ Billing.RechargePolicy = recharge_policy_1.RechargePolicy;
112
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../../src/resources/organizations/billing/billing.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AAErD,gFAAuD;AACvD,0DAM2B;AAE3B,0DAAyD;AAEzD,0DAAoD;AAEpD,MAAa,OAAQ,SAAQ,sBAAW;IAAxC;;QACE,mBAAc,GAAqC,IAAI,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAmHxG,CAAC;IAjHC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,cAAsB,EAAE,OAAwB;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,qBAAqB,cAAc,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAC9F,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,CACF,cAAsB,EACtB,QAA8C,EAAE,EAChD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,qBAAqB,cAAc,eAAe,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzG,CAAC;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CACL,cAAsB,EACtB,QAAiD,EAAE,EACnD,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,qBAAqB,cAAc,kBAAkB,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC5G,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CACH,cAAsB,EACtB,MAA0B,EAC1B,OAAwB;QAExB,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,qBAAqB,cAAc,gBAAgB,EAAE;YAChF,IAAI;YACJ,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACjF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,QAAQ,CACN,cAAsB,EACtB,MAA6B,EAC7B,OAAwB;QAExB,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,WAAI,EAAA,qBAAqB,cAAc,mBAAmB,EAAE;YACnF,GAAG,OAAO;YACV,OAAO,EAAE,IAAA,sBAAY,EAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;SACjF,CAAC,CAAC;IACL,CAAC;CACF;AApHD,0BAoHC;AAiJD,OAAO,CAAC,cAAc,GAAG,gCAAc,CAAC"}
@@ -0,0 +1,107 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../../../core/resource.mjs";
3
+ import * as RechargePolicyAPI from "./recharge-policy.mjs";
4
+ import { RechargePolicy, } from "./recharge-policy.mjs";
5
+ import { buildHeaders } from "../../../internal/headers.mjs";
6
+ import { path } from "../../../internal/utils/path.mjs";
7
+ export class Billing extends APIResource {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.rechargePolicy = new RechargePolicyAPI.RechargePolicy(this._client);
11
+ }
12
+ /**
13
+ * Get the organization's billing summary: effective balance, monthly and daily
14
+ * run-rate cost, runway, and the projected next-recharge date. Costs are run-rate
15
+ * projections.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const organizationBillingSummary =
20
+ * await client.organizations.billing.summary(
21
+ * 'organization_id',
22
+ * );
23
+ * ```
24
+ */
25
+ summary(organizationID, options) {
26
+ return this._client.get(path `/v1/organizations/${organizationID}/billing/summary`, options);
27
+ }
28
+ /**
29
+ * Get the organization's total usage cost per UTC day over a date range (max 90
30
+ * days), summing open and closed resources. One entry per day, oldest first.
31
+ * Defaults to the last 30 days.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const organizationDailyCost =
36
+ * await client.organizations.billing.cost(
37
+ * 'organization_id',
38
+ * );
39
+ * ```
40
+ */
41
+ cost(organizationID, query = {}, options) {
42
+ return this._client.get(path `/v1/organizations/${organizationID}/billing/cost`, { query, ...options });
43
+ }
44
+ /**
45
+ * List the organization's billing history: prepaid credits, top-ups, and manual
46
+ * adjustments, newest first. Paginated with an opaque cursor.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const billingHistoryEntryList =
51
+ * await client.organizations.billing.history(
52
+ * 'organization_id',
53
+ * );
54
+ * ```
55
+ */
56
+ history(organizationID, query = {}, options) {
57
+ return this._client.get(path `/v1/organizations/${organizationID}/billing/history`, { query, ...options });
58
+ }
59
+ /**
60
+ * Charge the card on file and credit the prepaid balance. A unique Idempotency-Key
61
+ * header is required; reuse it across retries so a timed-out top-up is not charged
62
+ * twice.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const organizationBillingSummary =
67
+ * await client.organizations.billing.topUp(
68
+ * 'organization_id',
69
+ * {
70
+ * amount: '50.00',
71
+ * 'Idempotency-Key': 'Idempotency-Key',
72
+ * },
73
+ * );
74
+ * ```
75
+ */
76
+ topUp(organizationID, params, options) {
77
+ const { 'Idempotency-Key': idempotencyKey, ...body } = params;
78
+ return this._client.post(path `/v1/organizations/${organizationID}/billing/topup`, {
79
+ body,
80
+ ...options,
81
+ headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
82
+ });
83
+ }
84
+ /**
85
+ * Charge the card on file up to the recharge target now instead of waiting for the
86
+ * scheduled retry. Automatic-policy prepaid organizations only. Idempotency-Key
87
+ * header required.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const organizationBillingSummary =
92
+ * await client.organizations.billing.recharge(
93
+ * 'organization_id',
94
+ * { 'Idempotency-Key': 'Idempotency-Key' },
95
+ * );
96
+ * ```
97
+ */
98
+ recharge(organizationID, params, options) {
99
+ const { 'Idempotency-Key': idempotencyKey } = params;
100
+ return this._client.post(path `/v1/organizations/${organizationID}/billing/recharge`, {
101
+ ...options,
102
+ headers: buildHeaders([{ 'Idempotency-Key': idempotencyKey }, options?.headers]),
103
+ });
104
+ }
105
+ }
106
+ Billing.RechargePolicy = RechargePolicy;
107
+ //# sourceMappingURL=billing.mjs.map