@lavapayments/nodejs 6.0.0 → 6.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.
package/README.md CHANGED
@@ -114,4 +114,4 @@ const url = `${lava.baseUrl}forward?u=https://api.yourprovider.com/endpoint`;
114
114
 
115
115
  ## Related Documentation
116
116
 
117
- For complete documentation on Lava's usage-based billing system and backend integration, visit [lavapayments.com](https://www.lavapayments.com).
117
+ For complete documentation on Lava's usage-based billing system and backend integration, visit [www.lava.so](https://www.lava.so).
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  interface CreateCheckoutSessionParams {
2
- checkout_mode: 'onboarding' | 'topup' | 'subscription';
2
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
3
3
  origin_url: string;
4
4
  reference_id?: string;
5
5
  connection_id?: string;
6
6
  subscription_config_id?: string;
7
+ credit_bundle_id?: string;
7
8
  }
8
9
  interface CheckoutSessionsListParams {
9
10
  cursor?: string;
@@ -64,7 +65,7 @@ interface UpdateSubscriptionConfigParams {
64
65
  type RestCheckoutSession = {
65
66
  checkout_session_id: string;
66
67
  checkout_session_token: string;
67
- checkout_mode: 'onboarding' | 'topup' | 'subscription';
68
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
68
69
  origin_url: string;
69
70
  connection_id?: string;
70
71
  reference_id?: string;
@@ -88,6 +89,37 @@ type RestConnection = {
88
89
  previous_usage_reset: string;
89
90
  created_at: string;
90
91
  };
92
+ type RestConnectionSubscriptionCredits = {
93
+ total_remaining: string;
94
+ cycle_remaining: string;
95
+ bundle_remaining: string;
96
+ cycle_rollover: 'full' | 'none';
97
+ bundle_rollover: 'full' | 'none';
98
+ };
99
+ type RestConnectionSubscriptionPendingChange = {
100
+ type: 'cancellation' | 'downgrade';
101
+ effective_at: string | null;
102
+ subscription_config_id?: string;
103
+ name?: string;
104
+ period_amount?: string;
105
+ included_credit?: string;
106
+ };
107
+ type RestConnectionSubscriptionDetails = {
108
+ active_subscription_id: string;
109
+ subscription_config_id: string;
110
+ name: string;
111
+ status: 'active' | 'cancelled';
112
+ billing_interval: 'month' | 'year';
113
+ period_amount: string;
114
+ included_credit: string;
115
+ cycle_start_at: string | null;
116
+ cycle_end_at: string | null;
117
+ credits: RestConnectionSubscriptionCredits;
118
+ pending_change: RestConnectionSubscriptionPendingChange | null;
119
+ };
120
+ type RestConnectionSubscription = {
121
+ subscription: RestConnectionSubscriptionDetails | null;
122
+ };
91
123
  type RestRequest = {
92
124
  request_id: string;
93
125
  status: 'pending' | 'completed' | 'error';
@@ -153,6 +185,8 @@ type RestUsage = {
153
185
  total_request_cost: string;
154
186
  total_wallet_cost: string;
155
187
  total_merchant_cost: string;
188
+ total_gross_volume: string;
189
+ total_net_volume: string;
156
190
  }[];
157
191
  totals: {
158
192
  total_requests: number;
@@ -163,6 +197,8 @@ type RestUsage = {
163
197
  total_request_cost: string;
164
198
  total_wallet_cost: string;
165
199
  total_merchant_cost: string;
200
+ total_gross_volume: string;
201
+ total_net_volume: string;
166
202
  };
167
203
  };
168
204
  type RestSubscriptionConfig = {
@@ -171,6 +207,7 @@ type RestSubscriptionConfig = {
171
207
  name: string;
172
208
  period_amount: string;
173
209
  rollover_type: 'full' | 'none';
210
+ bundle_rollover_type: 'full' | 'none';
174
211
  created_at: string;
175
212
  };
176
213
  type RestActiveSubscription = {
@@ -180,6 +217,7 @@ type RestActiveSubscription = {
180
217
  started_at: string;
181
218
  billing_anchor: number;
182
219
  cancelled_at?: string;
220
+ scheduled_cancellation_at: string | null;
183
221
  status: 'active' | 'cancelled';
184
222
  created_at: string;
185
223
  subscription_config: RestSubscriptionConfig;
@@ -240,6 +278,13 @@ declare namespace Resources {
240
278
  * @returns Connection details
241
279
  */
242
280
  retrieve(connectionId: string): Promise<RestConnection>;
281
+ /**
282
+ * Get subscription details for a connection.
283
+ * Returns plan info, current cycle credits, and any pending changes (cancellation or downgrade).
284
+ * @param connectionId Connection ID
285
+ * @returns Subscription details or null if no active subscription
286
+ */
287
+ getSubscription(connectionId: string): Promise<RestConnectionSubscription>;
243
288
  /**
244
289
  * Delete a connection
245
290
  * @param connectionId Connection ID
@@ -399,6 +444,7 @@ declare class Lava {
399
444
  gmicloud: string;
400
445
  chutes: string;
401
446
  baseten: string;
447
+ moonshot: string;
402
448
  };
403
449
  /**
404
450
  * Create a new Lava client
@@ -425,4 +471,4 @@ declare class Lava {
425
471
  generateForwardToken(options: ForwardTokenOptions): string;
426
472
  }
427
473
 
428
- export { type ApiVersion, type CheckoutSessionsListParams, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type CreateSubscriptionConfigParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestActiveSubscription, type RestCheckoutSession, type RestConnection, type RestRequest, type RestSubscriptionConfig, type RestUsage, type UpdateSubscriptionConfigParams, type UsageParams };
474
+ export { type ApiVersion, type CheckoutSessionsListParams, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type CreateSubscriptionConfigParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestActiveSubscription, type RestCheckoutSession, type RestConnection, type RestConnectionSubscription, type RestConnectionSubscriptionCredits, type RestConnectionSubscriptionDetails, type RestConnectionSubscriptionPendingChange, type RestRequest, type RestSubscriptionConfig, type RestUsage, type UpdateSubscriptionConfigParams, type UsageParams };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  interface CreateCheckoutSessionParams {
2
- checkout_mode: 'onboarding' | 'topup' | 'subscription';
2
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
3
3
  origin_url: string;
4
4
  reference_id?: string;
5
5
  connection_id?: string;
6
6
  subscription_config_id?: string;
7
+ credit_bundle_id?: string;
7
8
  }
8
9
  interface CheckoutSessionsListParams {
9
10
  cursor?: string;
@@ -64,7 +65,7 @@ interface UpdateSubscriptionConfigParams {
64
65
  type RestCheckoutSession = {
65
66
  checkout_session_id: string;
66
67
  checkout_session_token: string;
67
- checkout_mode: 'onboarding' | 'topup' | 'subscription';
68
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
68
69
  origin_url: string;
69
70
  connection_id?: string;
70
71
  reference_id?: string;
@@ -88,6 +89,37 @@ type RestConnection = {
88
89
  previous_usage_reset: string;
89
90
  created_at: string;
90
91
  };
92
+ type RestConnectionSubscriptionCredits = {
93
+ total_remaining: string;
94
+ cycle_remaining: string;
95
+ bundle_remaining: string;
96
+ cycle_rollover: 'full' | 'none';
97
+ bundle_rollover: 'full' | 'none';
98
+ };
99
+ type RestConnectionSubscriptionPendingChange = {
100
+ type: 'cancellation' | 'downgrade';
101
+ effective_at: string | null;
102
+ subscription_config_id?: string;
103
+ name?: string;
104
+ period_amount?: string;
105
+ included_credit?: string;
106
+ };
107
+ type RestConnectionSubscriptionDetails = {
108
+ active_subscription_id: string;
109
+ subscription_config_id: string;
110
+ name: string;
111
+ status: 'active' | 'cancelled';
112
+ billing_interval: 'month' | 'year';
113
+ period_amount: string;
114
+ included_credit: string;
115
+ cycle_start_at: string | null;
116
+ cycle_end_at: string | null;
117
+ credits: RestConnectionSubscriptionCredits;
118
+ pending_change: RestConnectionSubscriptionPendingChange | null;
119
+ };
120
+ type RestConnectionSubscription = {
121
+ subscription: RestConnectionSubscriptionDetails | null;
122
+ };
91
123
  type RestRequest = {
92
124
  request_id: string;
93
125
  status: 'pending' | 'completed' | 'error';
@@ -153,6 +185,8 @@ type RestUsage = {
153
185
  total_request_cost: string;
154
186
  total_wallet_cost: string;
155
187
  total_merchant_cost: string;
188
+ total_gross_volume: string;
189
+ total_net_volume: string;
156
190
  }[];
157
191
  totals: {
158
192
  total_requests: number;
@@ -163,6 +197,8 @@ type RestUsage = {
163
197
  total_request_cost: string;
164
198
  total_wallet_cost: string;
165
199
  total_merchant_cost: string;
200
+ total_gross_volume: string;
201
+ total_net_volume: string;
166
202
  };
167
203
  };
168
204
  type RestSubscriptionConfig = {
@@ -171,6 +207,7 @@ type RestSubscriptionConfig = {
171
207
  name: string;
172
208
  period_amount: string;
173
209
  rollover_type: 'full' | 'none';
210
+ bundle_rollover_type: 'full' | 'none';
174
211
  created_at: string;
175
212
  };
176
213
  type RestActiveSubscription = {
@@ -180,6 +217,7 @@ type RestActiveSubscription = {
180
217
  started_at: string;
181
218
  billing_anchor: number;
182
219
  cancelled_at?: string;
220
+ scheduled_cancellation_at: string | null;
183
221
  status: 'active' | 'cancelled';
184
222
  created_at: string;
185
223
  subscription_config: RestSubscriptionConfig;
@@ -240,6 +278,13 @@ declare namespace Resources {
240
278
  * @returns Connection details
241
279
  */
242
280
  retrieve(connectionId: string): Promise<RestConnection>;
281
+ /**
282
+ * Get subscription details for a connection.
283
+ * Returns plan info, current cycle credits, and any pending changes (cancellation or downgrade).
284
+ * @param connectionId Connection ID
285
+ * @returns Subscription details or null if no active subscription
286
+ */
287
+ getSubscription(connectionId: string): Promise<RestConnectionSubscription>;
243
288
  /**
244
289
  * Delete a connection
245
290
  * @param connectionId Connection ID
@@ -399,6 +444,7 @@ declare class Lava {
399
444
  gmicloud: string;
400
445
  chutes: string;
401
446
  baseten: string;
447
+ moonshot: string;
402
448
  };
403
449
  /**
404
450
  * Create a new Lava client
@@ -425,4 +471,4 @@ declare class Lava {
425
471
  generateForwardToken(options: ForwardTokenOptions): string;
426
472
  }
427
473
 
428
- export { type ApiVersion, type CheckoutSessionsListParams, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type CreateSubscriptionConfigParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestActiveSubscription, type RestCheckoutSession, type RestConnection, type RestRequest, type RestSubscriptionConfig, type RestUsage, type UpdateSubscriptionConfigParams, type UsageParams };
474
+ export { type ApiVersion, type CheckoutSessionsListParams, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type CreateSubscriptionConfigParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestActiveSubscription, type RestCheckoutSession, type RestConnection, type RestConnectionSubscription, type RestConnectionSubscriptionCredits, type RestConnectionSubscriptionDetails, type RestConnectionSubscriptionPendingChange, type RestRequest, type RestSubscriptionConfig, type RestUsage, type UpdateSubscriptionConfigParams, type UsageParams };
package/dist/index.js CHANGED
@@ -125,6 +125,18 @@ var Resources;
125
125
  `connections/${connectionId}`
126
126
  );
127
127
  }
128
+ /**
129
+ * Get subscription details for a connection.
130
+ * Returns plan info, current cycle credits, and any pending changes (cancellation or downgrade).
131
+ * @param connectionId Connection ID
132
+ * @returns Subscription details or null if no active subscription
133
+ */
134
+ getSubscription(connectionId) {
135
+ return this.lava.request(
136
+ "GET",
137
+ `connections/${connectionId}/subscription`
138
+ );
139
+ }
128
140
  /**
129
141
  * Delete a connection
130
142
  * @param connectionId Connection ID
@@ -338,7 +350,8 @@ var Lava = class {
338
350
  targon: `${this.baseUrl}forward?u=https://api.targon.com/v1`,
339
351
  gmicloud: `${this.baseUrl}forward?u=https://api.gmi-serving.com/v1`,
340
352
  chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`,
341
- baseten: `${this.baseUrl}forward?u=https://inference.baseten.co/v1`
353
+ baseten: `${this.baseUrl}forward?u=https://inference.baseten.co/v1`,
354
+ moonshot: `${this.baseUrl}forward?u=https://api.moonshot.ai/v1`
342
355
  };
343
356
  }
344
357
  /**
package/dist/index.mjs CHANGED
@@ -98,6 +98,18 @@ var Resources;
98
98
  `connections/${connectionId}`
99
99
  );
100
100
  }
101
+ /**
102
+ * Get subscription details for a connection.
103
+ * Returns plan info, current cycle credits, and any pending changes (cancellation or downgrade).
104
+ * @param connectionId Connection ID
105
+ * @returns Subscription details or null if no active subscription
106
+ */
107
+ getSubscription(connectionId) {
108
+ return this.lava.request(
109
+ "GET",
110
+ `connections/${connectionId}/subscription`
111
+ );
112
+ }
101
113
  /**
102
114
  * Delete a connection
103
115
  * @param connectionId Connection ID
@@ -311,7 +323,8 @@ var Lava = class {
311
323
  targon: `${this.baseUrl}forward?u=https://api.targon.com/v1`,
312
324
  gmicloud: `${this.baseUrl}forward?u=https://api.gmi-serving.com/v1`,
313
325
  chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`,
314
- baseten: `${this.baseUrl}forward?u=https://inference.baseten.co/v1`
326
+ baseten: `${this.baseUrl}forward?u=https://inference.baseten.co/v1`,
327
+ moonshot: `${this.baseUrl}forward?u=https://api.moonshot.ai/v1`
315
328
  };
316
329
  }
317
330
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavapayments/nodejs",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Backend SDK for Lava Payments API - enabling usage-based billing for AI services",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",