@lavapayments/nodejs 5.3.2 → 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,8 +1,10 @@
1
1
  interface CreateCheckoutSessionParams {
2
- checkout_mode: 'onboarding' | 'topup';
2
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
3
3
  origin_url: string;
4
4
  reference_id?: string;
5
5
  connection_id?: string;
6
+ subscription_config_id?: string;
7
+ credit_bundle_id?: string;
6
8
  }
7
9
  interface CheckoutSessionsListParams {
8
10
  cursor?: string;
@@ -50,13 +52,24 @@ interface ListResponse<T> {
50
52
  has_more: boolean;
51
53
  next_cursor?: string;
52
54
  }
55
+ interface CreateSubscriptionConfigParams {
56
+ name: string;
57
+ period_amount: string;
58
+ rollover_type: 'full' | 'none';
59
+ }
60
+ interface UpdateSubscriptionConfigParams {
61
+ name?: string;
62
+ period_amount?: string;
63
+ rollover_type?: 'full' | 'none';
64
+ }
53
65
  type RestCheckoutSession = {
54
66
  checkout_session_id: string;
55
67
  checkout_session_token: string;
56
- checkout_mode: 'onboarding' | 'topup';
68
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
57
69
  origin_url: string;
58
70
  connection_id?: string;
59
71
  reference_id?: string;
72
+ subscription_config_id?: string;
60
73
  created_at: string;
61
74
  completed_at?: string;
62
75
  };
@@ -76,6 +89,37 @@ type RestConnection = {
76
89
  previous_usage_reset: string;
77
90
  created_at: string;
78
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
+ };
79
123
  type RestRequest = {
80
124
  request_id: string;
81
125
  status: 'pending' | 'completed' | 'error';
@@ -141,6 +185,8 @@ type RestUsage = {
141
185
  total_request_cost: string;
142
186
  total_wallet_cost: string;
143
187
  total_merchant_cost: string;
188
+ total_gross_volume: string;
189
+ total_net_volume: string;
144
190
  }[];
145
191
  totals: {
146
192
  total_requests: number;
@@ -151,10 +197,42 @@ type RestUsage = {
151
197
  total_request_cost: string;
152
198
  total_wallet_cost: string;
153
199
  total_merchant_cost: string;
200
+ total_gross_volume: string;
201
+ total_net_volume: string;
202
+ };
203
+ };
204
+ type RestSubscriptionConfig = {
205
+ subscription_config_id: string;
206
+ merchant_id: string;
207
+ name: string;
208
+ period_amount: string;
209
+ rollover_type: 'full' | 'none';
210
+ bundle_rollover_type: 'full' | 'none';
211
+ created_at: string;
212
+ };
213
+ type RestActiveSubscription = {
214
+ active_subscription_id: string;
215
+ wallet_id: string;
216
+ subscription_config_id: string;
217
+ started_at: string;
218
+ billing_anchor: number;
219
+ cancelled_at?: string;
220
+ scheduled_cancellation_at: string | null;
221
+ status: 'active' | 'cancelled';
222
+ created_at: string;
223
+ subscription_config: RestSubscriptionConfig;
224
+ wallet: {
225
+ wallet_id: string;
226
+ phone: string;
227
+ email?: string;
228
+ first_name?: string;
229
+ last_name?: string;
230
+ active_balance: string;
231
+ created_at: string;
154
232
  };
155
233
  };
156
234
 
157
- /** biome-ignore-all lint/style/noNamespace: <explanation> */
235
+ /** biome-ignore-all lint/style/noNamespace: package uses namespace */
158
236
 
159
237
  declare namespace Resources {
160
238
  abstract class BaseResource {
@@ -200,6 +278,13 @@ declare namespace Resources {
200
278
  * @returns Connection details
201
279
  */
202
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>;
203
288
  /**
204
289
  * Delete a connection
205
290
  * @param connectionId Connection ID
@@ -243,6 +328,47 @@ declare namespace Resources {
243
328
  */
244
329
  retrieve(params: UsageParams): Promise<RestUsage>;
245
330
  }
331
+ export class SubscriptionsResource extends BaseResource {
332
+ /**
333
+ * List subscription configurations
334
+ * @returns List of subscription configurations
335
+ */
336
+ listConfigs(): Promise<RestSubscriptionConfig[]>;
337
+ /**
338
+ * Create a subscription configuration
339
+ * @param params Subscription configuration parameters
340
+ * @returns Created subscription configuration
341
+ */
342
+ createConfig(params: CreateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
343
+ /**
344
+ * Update a subscription configuration
345
+ * @param id Subscription configuration ID
346
+ * @param params Update parameters
347
+ * @returns Updated subscription configuration
348
+ */
349
+ updateConfig(id: string, params: UpdateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
350
+ /**
351
+ * Delete a subscription configuration
352
+ * @param id Subscription configuration ID
353
+ * @returns Success response
354
+ */
355
+ deleteConfig(id: string): Promise<{
356
+ success: boolean;
357
+ }>;
358
+ /**
359
+ * List active subscriptions for a merchant
360
+ * @returns List of active subscriptions
361
+ */
362
+ listActiveSubscriptions(): Promise<RestActiveSubscription[]>;
363
+ /**
364
+ * Cancel an active subscription
365
+ * @param id Active subscription ID
366
+ * @returns Success response
367
+ */
368
+ cancelActiveSubscription(id: string): Promise<{
369
+ success: boolean;
370
+ }>;
371
+ }
246
372
  export { };
247
373
  }
248
374
 
@@ -284,6 +410,10 @@ declare class Lava {
284
410
  * The usage resource
285
411
  */
286
412
  readonly usage: Resources.UsageResource;
413
+ /**
414
+ * The subscriptions resource
415
+ */
416
+ readonly subscriptions: Resources.SubscriptionsResource;
287
417
  /**
288
418
  * Provider URLs for convenience
289
419
  */
@@ -314,6 +444,7 @@ declare class Lava {
314
444
  gmicloud: string;
315
445
  chutes: string;
316
446
  baseten: string;
447
+ moonshot: string;
317
448
  };
318
449
  /**
319
450
  * Create a new Lava client
@@ -329,7 +460,7 @@ declare class Lava {
329
460
  * @returns Response data
330
461
  */
331
462
  request<T>(method: string, path: string, { data, query }?: {
332
- data?: any;
463
+ data?: unknown;
333
464
  query?: Record<string, string>;
334
465
  }): Promise<T>;
335
466
  /**
@@ -340,4 +471,4 @@ declare class Lava {
340
471
  generateForwardToken(options: ForwardTokenOptions): string;
341
472
  }
342
473
 
343
- export { type ApiVersion, type CheckoutSessionsListParams, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestCheckoutSession, type RestConnection, type RestRequest, type RestUsage, 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,8 +1,10 @@
1
1
  interface CreateCheckoutSessionParams {
2
- checkout_mode: 'onboarding' | 'topup';
2
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
3
3
  origin_url: string;
4
4
  reference_id?: string;
5
5
  connection_id?: string;
6
+ subscription_config_id?: string;
7
+ credit_bundle_id?: string;
6
8
  }
7
9
  interface CheckoutSessionsListParams {
8
10
  cursor?: string;
@@ -50,13 +52,24 @@ interface ListResponse<T> {
50
52
  has_more: boolean;
51
53
  next_cursor?: string;
52
54
  }
55
+ interface CreateSubscriptionConfigParams {
56
+ name: string;
57
+ period_amount: string;
58
+ rollover_type: 'full' | 'none';
59
+ }
60
+ interface UpdateSubscriptionConfigParams {
61
+ name?: string;
62
+ period_amount?: string;
63
+ rollover_type?: 'full' | 'none';
64
+ }
53
65
  type RestCheckoutSession = {
54
66
  checkout_session_id: string;
55
67
  checkout_session_token: string;
56
- checkout_mode: 'onboarding' | 'topup';
68
+ checkout_mode: 'onboarding' | 'topup' | 'subscription' | 'credit_bundle';
57
69
  origin_url: string;
58
70
  connection_id?: string;
59
71
  reference_id?: string;
72
+ subscription_config_id?: string;
60
73
  created_at: string;
61
74
  completed_at?: string;
62
75
  };
@@ -76,6 +89,37 @@ type RestConnection = {
76
89
  previous_usage_reset: string;
77
90
  created_at: string;
78
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
+ };
79
123
  type RestRequest = {
80
124
  request_id: string;
81
125
  status: 'pending' | 'completed' | 'error';
@@ -141,6 +185,8 @@ type RestUsage = {
141
185
  total_request_cost: string;
142
186
  total_wallet_cost: string;
143
187
  total_merchant_cost: string;
188
+ total_gross_volume: string;
189
+ total_net_volume: string;
144
190
  }[];
145
191
  totals: {
146
192
  total_requests: number;
@@ -151,10 +197,42 @@ type RestUsage = {
151
197
  total_request_cost: string;
152
198
  total_wallet_cost: string;
153
199
  total_merchant_cost: string;
200
+ total_gross_volume: string;
201
+ total_net_volume: string;
202
+ };
203
+ };
204
+ type RestSubscriptionConfig = {
205
+ subscription_config_id: string;
206
+ merchant_id: string;
207
+ name: string;
208
+ period_amount: string;
209
+ rollover_type: 'full' | 'none';
210
+ bundle_rollover_type: 'full' | 'none';
211
+ created_at: string;
212
+ };
213
+ type RestActiveSubscription = {
214
+ active_subscription_id: string;
215
+ wallet_id: string;
216
+ subscription_config_id: string;
217
+ started_at: string;
218
+ billing_anchor: number;
219
+ cancelled_at?: string;
220
+ scheduled_cancellation_at: string | null;
221
+ status: 'active' | 'cancelled';
222
+ created_at: string;
223
+ subscription_config: RestSubscriptionConfig;
224
+ wallet: {
225
+ wallet_id: string;
226
+ phone: string;
227
+ email?: string;
228
+ first_name?: string;
229
+ last_name?: string;
230
+ active_balance: string;
231
+ created_at: string;
154
232
  };
155
233
  };
156
234
 
157
- /** biome-ignore-all lint/style/noNamespace: <explanation> */
235
+ /** biome-ignore-all lint/style/noNamespace: package uses namespace */
158
236
 
159
237
  declare namespace Resources {
160
238
  abstract class BaseResource {
@@ -200,6 +278,13 @@ declare namespace Resources {
200
278
  * @returns Connection details
201
279
  */
202
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>;
203
288
  /**
204
289
  * Delete a connection
205
290
  * @param connectionId Connection ID
@@ -243,6 +328,47 @@ declare namespace Resources {
243
328
  */
244
329
  retrieve(params: UsageParams): Promise<RestUsage>;
245
330
  }
331
+ export class SubscriptionsResource extends BaseResource {
332
+ /**
333
+ * List subscription configurations
334
+ * @returns List of subscription configurations
335
+ */
336
+ listConfigs(): Promise<RestSubscriptionConfig[]>;
337
+ /**
338
+ * Create a subscription configuration
339
+ * @param params Subscription configuration parameters
340
+ * @returns Created subscription configuration
341
+ */
342
+ createConfig(params: CreateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
343
+ /**
344
+ * Update a subscription configuration
345
+ * @param id Subscription configuration ID
346
+ * @param params Update parameters
347
+ * @returns Updated subscription configuration
348
+ */
349
+ updateConfig(id: string, params: UpdateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
350
+ /**
351
+ * Delete a subscription configuration
352
+ * @param id Subscription configuration ID
353
+ * @returns Success response
354
+ */
355
+ deleteConfig(id: string): Promise<{
356
+ success: boolean;
357
+ }>;
358
+ /**
359
+ * List active subscriptions for a merchant
360
+ * @returns List of active subscriptions
361
+ */
362
+ listActiveSubscriptions(): Promise<RestActiveSubscription[]>;
363
+ /**
364
+ * Cancel an active subscription
365
+ * @param id Active subscription ID
366
+ * @returns Success response
367
+ */
368
+ cancelActiveSubscription(id: string): Promise<{
369
+ success: boolean;
370
+ }>;
371
+ }
246
372
  export { };
247
373
  }
248
374
 
@@ -284,6 +410,10 @@ declare class Lava {
284
410
  * The usage resource
285
411
  */
286
412
  readonly usage: Resources.UsageResource;
413
+ /**
414
+ * The subscriptions resource
415
+ */
416
+ readonly subscriptions: Resources.SubscriptionsResource;
287
417
  /**
288
418
  * Provider URLs for convenience
289
419
  */
@@ -314,6 +444,7 @@ declare class Lava {
314
444
  gmicloud: string;
315
445
  chutes: string;
316
446
  baseten: string;
447
+ moonshot: string;
317
448
  };
318
449
  /**
319
450
  * Create a new Lava client
@@ -329,7 +460,7 @@ declare class Lava {
329
460
  * @returns Response data
330
461
  */
331
462
  request<T>(method: string, path: string, { data, query }?: {
332
- data?: any;
463
+ data?: unknown;
333
464
  query?: Record<string, string>;
334
465
  }): Promise<T>;
335
466
  /**
@@ -340,4 +471,4 @@ declare class Lava {
340
471
  generateForwardToken(options: ForwardTokenOptions): string;
341
472
  }
342
473
 
343
- export { type ApiVersion, type CheckoutSessionsListParams, type Config, type ConnectionsListParams, type CreateCheckoutSessionParams, type CreateRequestParams, type ForwardTokenOptions, Lava, type ListResponse, type RequestsListParams, type RequestsListResponse, Resources, type RestCheckoutSession, type RestConnection, type RestRequest, type RestUsage, 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
@@ -219,6 +231,80 @@ var Resources;
219
231
  }
220
232
  }
221
233
  Resources2.UsageResource = UsageResource;
234
+ class SubscriptionsResource extends BaseResource {
235
+ /**
236
+ * List subscription configurations
237
+ * @returns List of subscription configurations
238
+ */
239
+ listConfigs() {
240
+ return this.lava.request(
241
+ "GET",
242
+ "subscription-configs"
243
+ );
244
+ }
245
+ /**
246
+ * Create a subscription configuration
247
+ * @param params Subscription configuration parameters
248
+ * @returns Created subscription configuration
249
+ */
250
+ createConfig(params) {
251
+ return this.lava.request(
252
+ "POST",
253
+ "subscription-configs",
254
+ {
255
+ data: params
256
+ }
257
+ );
258
+ }
259
+ /**
260
+ * Update a subscription configuration
261
+ * @param id Subscription configuration ID
262
+ * @param params Update parameters
263
+ * @returns Updated subscription configuration
264
+ */
265
+ updateConfig(id, params) {
266
+ return this.lava.request(
267
+ "PUT",
268
+ `subscription-configs/${id}`,
269
+ {
270
+ data: params
271
+ }
272
+ );
273
+ }
274
+ /**
275
+ * Delete a subscription configuration
276
+ * @param id Subscription configuration ID
277
+ * @returns Success response
278
+ */
279
+ deleteConfig(id) {
280
+ return this.lava.request(
281
+ "DELETE",
282
+ `subscription-configs/${id}`
283
+ );
284
+ }
285
+ /**
286
+ * List active subscriptions for a merchant
287
+ * @returns List of active subscriptions
288
+ */
289
+ listActiveSubscriptions() {
290
+ return this.lava.request(
291
+ "GET",
292
+ "active-subscriptions"
293
+ );
294
+ }
295
+ /**
296
+ * Cancel an active subscription
297
+ * @param id Active subscription ID
298
+ * @returns Success response
299
+ */
300
+ cancelActiveSubscription(id) {
301
+ return this.lava.request(
302
+ "DELETE",
303
+ `active-subscriptions/${id}`
304
+ );
305
+ }
306
+ }
307
+ Resources2.SubscriptionsResource = SubscriptionsResource;
222
308
  })(Resources || (Resources = {}));
223
309
 
224
310
  // src/client.ts
@@ -237,6 +323,7 @@ var Lava = class {
237
323
  this.connections = new Resources.ConnectionsResource(this);
238
324
  this.requests = new Resources.RequestsResource(this);
239
325
  this.usage = new Resources.UsageResource(this);
326
+ this.subscriptions = new Resources.SubscriptionsResource(this);
240
327
  this.providers = {
241
328
  openai: `${this.baseUrl}forward?u=https://api.openai.com/v1`,
242
329
  anthropic: `${this.baseUrl}forward?u=https://api.anthropic.com/v1`,
@@ -263,7 +350,8 @@ var Lava = class {
263
350
  targon: `${this.baseUrl}forward?u=https://api.targon.com/v1`,
264
351
  gmicloud: `${this.baseUrl}forward?u=https://api.gmi-serving.com/v1`,
265
352
  chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`,
266
- 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`
267
355
  };
268
356
  }
269
357
  /**
@@ -276,11 +364,11 @@ var Lava = class {
276
364
  async request(method, path, { data, query } = {}) {
277
365
  const url = new URL(path, this.baseUrl);
278
366
  if (query) {
279
- Object.entries(query).forEach(([key, value]) => {
367
+ for (const [key, value] of Object.entries(query)) {
280
368
  if (value !== void 0) {
281
369
  url.searchParams.append(key, value.toString());
282
370
  }
283
- });
371
+ }
284
372
  }
285
373
  const headers = {
286
374
  Authorization: `Bearer ${this.secretKey}`,
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
@@ -192,6 +204,80 @@ var Resources;
192
204
  }
193
205
  }
194
206
  Resources2.UsageResource = UsageResource;
207
+ class SubscriptionsResource extends BaseResource {
208
+ /**
209
+ * List subscription configurations
210
+ * @returns List of subscription configurations
211
+ */
212
+ listConfigs() {
213
+ return this.lava.request(
214
+ "GET",
215
+ "subscription-configs"
216
+ );
217
+ }
218
+ /**
219
+ * Create a subscription configuration
220
+ * @param params Subscription configuration parameters
221
+ * @returns Created subscription configuration
222
+ */
223
+ createConfig(params) {
224
+ return this.lava.request(
225
+ "POST",
226
+ "subscription-configs",
227
+ {
228
+ data: params
229
+ }
230
+ );
231
+ }
232
+ /**
233
+ * Update a subscription configuration
234
+ * @param id Subscription configuration ID
235
+ * @param params Update parameters
236
+ * @returns Updated subscription configuration
237
+ */
238
+ updateConfig(id, params) {
239
+ return this.lava.request(
240
+ "PUT",
241
+ `subscription-configs/${id}`,
242
+ {
243
+ data: params
244
+ }
245
+ );
246
+ }
247
+ /**
248
+ * Delete a subscription configuration
249
+ * @param id Subscription configuration ID
250
+ * @returns Success response
251
+ */
252
+ deleteConfig(id) {
253
+ return this.lava.request(
254
+ "DELETE",
255
+ `subscription-configs/${id}`
256
+ );
257
+ }
258
+ /**
259
+ * List active subscriptions for a merchant
260
+ * @returns List of active subscriptions
261
+ */
262
+ listActiveSubscriptions() {
263
+ return this.lava.request(
264
+ "GET",
265
+ "active-subscriptions"
266
+ );
267
+ }
268
+ /**
269
+ * Cancel an active subscription
270
+ * @param id Active subscription ID
271
+ * @returns Success response
272
+ */
273
+ cancelActiveSubscription(id) {
274
+ return this.lava.request(
275
+ "DELETE",
276
+ `active-subscriptions/${id}`
277
+ );
278
+ }
279
+ }
280
+ Resources2.SubscriptionsResource = SubscriptionsResource;
195
281
  })(Resources || (Resources = {}));
196
282
 
197
283
  // src/client.ts
@@ -210,6 +296,7 @@ var Lava = class {
210
296
  this.connections = new Resources.ConnectionsResource(this);
211
297
  this.requests = new Resources.RequestsResource(this);
212
298
  this.usage = new Resources.UsageResource(this);
299
+ this.subscriptions = new Resources.SubscriptionsResource(this);
213
300
  this.providers = {
214
301
  openai: `${this.baseUrl}forward?u=https://api.openai.com/v1`,
215
302
  anthropic: `${this.baseUrl}forward?u=https://api.anthropic.com/v1`,
@@ -236,7 +323,8 @@ var Lava = class {
236
323
  targon: `${this.baseUrl}forward?u=https://api.targon.com/v1`,
237
324
  gmicloud: `${this.baseUrl}forward?u=https://api.gmi-serving.com/v1`,
238
325
  chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`,
239
- 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`
240
328
  };
241
329
  }
242
330
  /**
@@ -249,11 +337,11 @@ var Lava = class {
249
337
  async request(method, path, { data, query } = {}) {
250
338
  const url = new URL(path, this.baseUrl);
251
339
  if (query) {
252
- Object.entries(query).forEach(([key, value]) => {
340
+ for (const [key, value] of Object.entries(query)) {
253
341
  if (value !== void 0) {
254
342
  url.searchParams.append(key, value.toString());
255
343
  }
256
- });
344
+ }
257
345
  }
258
346
  const headers = {
259
347
  Authorization: `Bearer ${this.secretKey}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavapayments/nodejs",
3
- "version": "5.3.2",
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",