@lavapayments/nodejs 5.3.1 → 6.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.
package/dist/index.d.mts CHANGED
@@ -1,101 +1,9 @@
1
- type ApiVersion = "2025-04-28.v1";
2
- interface Config {
3
- apiVersion: ApiVersion;
4
- /**
5
- * Base URL for the API.
6
- * If not provided, it will be inferred from the secret key (production or sandbox).
7
- */
8
- baseUrl?: string;
9
- }
10
- type ForwardTokenOptions = {
11
- connection_secret: string;
12
- product_secret: string;
13
- provider_key?: string;
14
- } | {
15
- connection_secret: null;
16
- product_secret: null;
17
- provider_key: string;
18
- };
19
- declare class Lava {
20
- private readonly secretKey;
21
- private readonly baseUrl;
22
- private readonly apiVersion;
23
- /**
24
- * The checkout sessions resource
25
- */
26
- readonly checkoutSessions: Resources.CheckoutSessionsResource;
27
- /**
28
- * The connections resource
29
- */
30
- readonly connections: Resources.ConnectionsResource;
31
- /**
32
- * The requests resource
33
- */
34
- readonly requests: Resources.RequestsResource;
35
- /**
36
- * The usage resource
37
- */
38
- readonly usage: Resources.UsageResource;
39
- /**
40
- * Provider URLs for convenience
41
- */
42
- readonly providers: {
43
- openai: string;
44
- anthropic: string;
45
- mistral: string;
46
- deepseek: string;
47
- xai: string;
48
- google: string;
49
- googleOpenaiCompatible: string;
50
- kluster: string;
51
- inference: string;
52
- groq: string;
53
- novita: string;
54
- vercel: string;
55
- together: string;
56
- hyperbolic: string;
57
- elevenlabs: string;
58
- sambanova: string;
59
- deepinfra: string;
60
- cohere: string;
61
- parasail: string;
62
- nebius: string;
63
- fireworks: string;
64
- cerebras: string;
65
- targon: string;
66
- gmicloud: string;
67
- chutes: string;
68
- };
69
- /**
70
- * Create a new Lava client
71
- * @param secretKey Your Lava secret key
72
- * @param config Configuration options
73
- */
74
- constructor(secretKey: string, config: Config);
75
- /**
76
- * Make a request to the Lava API
77
- * @param method HTTP method
78
- * @param path API path
79
- * @param options Request options
80
- * @returns Response data
81
- */
82
- request<T>(method: string, path: string, { data, query }?: {
83
- data?: any;
84
- query?: Record<string, string>;
85
- }): Promise<T>;
86
- /**
87
- * Generate a token for the forward endpoint
88
- * @param options Token options
89
- * @returns Base64 encoded token
90
- */
91
- generateForwardToken(options: ForwardTokenOptions): string;
92
- }
93
-
94
1
  interface CreateCheckoutSessionParams {
95
- checkout_mode: "onboarding" | "topup";
2
+ checkout_mode: 'onboarding' | 'topup' | 'subscription';
96
3
  origin_url: string;
97
4
  reference_id?: string;
98
5
  connection_id?: string;
6
+ subscription_config_id?: string;
99
7
  }
100
8
  interface CheckoutSessionsListParams {
101
9
  cursor?: string;
@@ -143,13 +51,24 @@ interface ListResponse<T> {
143
51
  has_more: boolean;
144
52
  next_cursor?: string;
145
53
  }
54
+ interface CreateSubscriptionConfigParams {
55
+ name: string;
56
+ period_amount: string;
57
+ rollover_type: 'full' | 'none';
58
+ }
59
+ interface UpdateSubscriptionConfigParams {
60
+ name?: string;
61
+ period_amount?: string;
62
+ rollover_type?: 'full' | 'none';
63
+ }
146
64
  type RestCheckoutSession = {
147
65
  checkout_session_id: string;
148
66
  checkout_session_token: string;
149
- checkout_mode: "onboarding" | "topup";
67
+ checkout_mode: 'onboarding' | 'topup' | 'subscription';
150
68
  origin_url: string;
151
69
  connection_id?: string;
152
70
  reference_id?: string;
71
+ subscription_config_id?: string;
153
72
  created_at: string;
154
73
  completed_at?: string;
155
74
  };
@@ -171,11 +90,11 @@ type RestConnection = {
171
90
  };
172
91
  type RestRequest = {
173
92
  request_id: string;
174
- status: "pending" | "completed" | "error";
93
+ status: 'pending' | 'completed' | 'error';
175
94
  connection_id?: string;
176
95
  product_id?: string;
177
96
  provider: string;
178
- provider_key_type: "managed" | "unmanaged";
97
+ provider_key_type: 'managed' | 'unmanaged';
179
98
  model?: string;
180
99
  endpoint: string;
181
100
  response_id?: string;
@@ -192,17 +111,17 @@ type RestRequest = {
192
111
  input_cost: string;
193
112
  output_cost: string;
194
113
  total_cost: string;
195
- payer: "wallet" | "merchant";
114
+ payer: 'wallet' | 'merchant';
196
115
  };
197
116
  fee: {
198
117
  amount: string;
199
- rate_type: "fixed" | "percentage";
200
- token_basis: "input+output" | "output";
118
+ rate_type: 'fixed' | 'percentage';
119
+ token_basis: 'input+output' | 'output';
201
120
  breakdown: {
202
121
  tier: {
203
122
  start: number;
204
123
  rate: string;
205
- type: "tokens_1m" | "characters_1m" | "minutes" | "requests";
124
+ type: 'tokens_1m' | 'characters_1m' | 'minutes' | 'requests';
206
125
  };
207
126
  tokens: number;
208
127
  characters: number;
@@ -212,7 +131,7 @@ type RestRequest = {
212
131
  };
213
132
  service_charge: {
214
133
  amount: string;
215
- payer: "wallet" | "merchant";
134
+ payer: 'wallet' | 'merchant';
216
135
  };
217
136
  total_request_cost: string;
218
137
  total_wallet_cost: string;
@@ -246,6 +165,36 @@ type RestUsage = {
246
165
  total_merchant_cost: string;
247
166
  };
248
167
  };
168
+ type RestSubscriptionConfig = {
169
+ subscription_config_id: string;
170
+ merchant_id: string;
171
+ name: string;
172
+ period_amount: string;
173
+ rollover_type: 'full' | 'none';
174
+ created_at: string;
175
+ };
176
+ type RestActiveSubscription = {
177
+ active_subscription_id: string;
178
+ wallet_id: string;
179
+ subscription_config_id: string;
180
+ started_at: string;
181
+ billing_anchor: number;
182
+ cancelled_at?: string;
183
+ status: 'active' | 'cancelled';
184
+ created_at: string;
185
+ subscription_config: RestSubscriptionConfig;
186
+ wallet: {
187
+ wallet_id: string;
188
+ phone: string;
189
+ email?: string;
190
+ first_name?: string;
191
+ last_name?: string;
192
+ active_balance: string;
193
+ created_at: string;
194
+ };
195
+ };
196
+
197
+ /** biome-ignore-all lint/style/noNamespace: package uses namespace */
249
198
 
250
199
  declare namespace Resources {
251
200
  abstract class BaseResource {
@@ -334,7 +283,146 @@ declare namespace Resources {
334
283
  */
335
284
  retrieve(params: UsageParams): Promise<RestUsage>;
336
285
  }
286
+ export class SubscriptionsResource extends BaseResource {
287
+ /**
288
+ * List subscription configurations
289
+ * @returns List of subscription configurations
290
+ */
291
+ listConfigs(): Promise<RestSubscriptionConfig[]>;
292
+ /**
293
+ * Create a subscription configuration
294
+ * @param params Subscription configuration parameters
295
+ * @returns Created subscription configuration
296
+ */
297
+ createConfig(params: CreateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
298
+ /**
299
+ * Update a subscription configuration
300
+ * @param id Subscription configuration ID
301
+ * @param params Update parameters
302
+ * @returns Updated subscription configuration
303
+ */
304
+ updateConfig(id: string, params: UpdateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
305
+ /**
306
+ * Delete a subscription configuration
307
+ * @param id Subscription configuration ID
308
+ * @returns Success response
309
+ */
310
+ deleteConfig(id: string): Promise<{
311
+ success: boolean;
312
+ }>;
313
+ /**
314
+ * List active subscriptions for a merchant
315
+ * @returns List of active subscriptions
316
+ */
317
+ listActiveSubscriptions(): Promise<RestActiveSubscription[]>;
318
+ /**
319
+ * Cancel an active subscription
320
+ * @param id Active subscription ID
321
+ * @returns Success response
322
+ */
323
+ cancelActiveSubscription(id: string): Promise<{
324
+ success: boolean;
325
+ }>;
326
+ }
337
327
  export { };
338
328
  }
339
329
 
340
- 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 };
330
+ type ApiVersion = '2025-04-28.v1';
331
+ interface Config {
332
+ apiVersion: ApiVersion;
333
+ /**
334
+ * Base URL for the API.
335
+ * If not provided, it will be inferred from the secret key (production or sandbox).
336
+ */
337
+ baseUrl?: string;
338
+ }
339
+ type ForwardTokenOptions = {
340
+ connection_secret: string;
341
+ product_secret: string;
342
+ provider_key?: string;
343
+ } | {
344
+ connection_secret: null;
345
+ product_secret: null;
346
+ provider_key: string;
347
+ };
348
+ declare class Lava {
349
+ private readonly secretKey;
350
+ private readonly baseUrl;
351
+ private readonly apiVersion;
352
+ /**
353
+ * The checkout sessions resource
354
+ */
355
+ readonly checkoutSessions: Resources.CheckoutSessionsResource;
356
+ /**
357
+ * The connections resource
358
+ */
359
+ readonly connections: Resources.ConnectionsResource;
360
+ /**
361
+ * The requests resource
362
+ */
363
+ readonly requests: Resources.RequestsResource;
364
+ /**
365
+ * The usage resource
366
+ */
367
+ readonly usage: Resources.UsageResource;
368
+ /**
369
+ * The subscriptions resource
370
+ */
371
+ readonly subscriptions: Resources.SubscriptionsResource;
372
+ /**
373
+ * Provider URLs for convenience
374
+ */
375
+ readonly providers: {
376
+ openai: string;
377
+ anthropic: string;
378
+ mistral: string;
379
+ deepseek: string;
380
+ xai: string;
381
+ google: string;
382
+ googleOpenaiCompatible: string;
383
+ kluster: string;
384
+ inference: string;
385
+ groq: string;
386
+ novita: string;
387
+ vercel: string;
388
+ together: string;
389
+ hyperbolic: string;
390
+ elevenlabs: string;
391
+ sambanova: string;
392
+ deepinfra: string;
393
+ cohere: string;
394
+ parasail: string;
395
+ nebius: string;
396
+ fireworks: string;
397
+ cerebras: string;
398
+ targon: string;
399
+ gmicloud: string;
400
+ chutes: string;
401
+ baseten: string;
402
+ };
403
+ /**
404
+ * Create a new Lava client
405
+ * @param secretKey Your Lava secret key
406
+ * @param config Configuration options
407
+ */
408
+ constructor(secretKey: string, config: Config);
409
+ /**
410
+ * Make a request to the Lava API
411
+ * @param method HTTP method
412
+ * @param path API path
413
+ * @param options Request options
414
+ * @returns Response data
415
+ */
416
+ request<T>(method: string, path: string, { data, query }?: {
417
+ data?: unknown;
418
+ query?: Record<string, string>;
419
+ }): Promise<T>;
420
+ /**
421
+ * Generate a token for the forward endpoint
422
+ * @param options Token options
423
+ * @returns Base64 encoded token
424
+ */
425
+ generateForwardToken(options: ForwardTokenOptions): string;
426
+ }
427
+
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 };
package/dist/index.d.ts CHANGED
@@ -1,101 +1,9 @@
1
- type ApiVersion = "2025-04-28.v1";
2
- interface Config {
3
- apiVersion: ApiVersion;
4
- /**
5
- * Base URL for the API.
6
- * If not provided, it will be inferred from the secret key (production or sandbox).
7
- */
8
- baseUrl?: string;
9
- }
10
- type ForwardTokenOptions = {
11
- connection_secret: string;
12
- product_secret: string;
13
- provider_key?: string;
14
- } | {
15
- connection_secret: null;
16
- product_secret: null;
17
- provider_key: string;
18
- };
19
- declare class Lava {
20
- private readonly secretKey;
21
- private readonly baseUrl;
22
- private readonly apiVersion;
23
- /**
24
- * The checkout sessions resource
25
- */
26
- readonly checkoutSessions: Resources.CheckoutSessionsResource;
27
- /**
28
- * The connections resource
29
- */
30
- readonly connections: Resources.ConnectionsResource;
31
- /**
32
- * The requests resource
33
- */
34
- readonly requests: Resources.RequestsResource;
35
- /**
36
- * The usage resource
37
- */
38
- readonly usage: Resources.UsageResource;
39
- /**
40
- * Provider URLs for convenience
41
- */
42
- readonly providers: {
43
- openai: string;
44
- anthropic: string;
45
- mistral: string;
46
- deepseek: string;
47
- xai: string;
48
- google: string;
49
- googleOpenaiCompatible: string;
50
- kluster: string;
51
- inference: string;
52
- groq: string;
53
- novita: string;
54
- vercel: string;
55
- together: string;
56
- hyperbolic: string;
57
- elevenlabs: string;
58
- sambanova: string;
59
- deepinfra: string;
60
- cohere: string;
61
- parasail: string;
62
- nebius: string;
63
- fireworks: string;
64
- cerebras: string;
65
- targon: string;
66
- gmicloud: string;
67
- chutes: string;
68
- };
69
- /**
70
- * Create a new Lava client
71
- * @param secretKey Your Lava secret key
72
- * @param config Configuration options
73
- */
74
- constructor(secretKey: string, config: Config);
75
- /**
76
- * Make a request to the Lava API
77
- * @param method HTTP method
78
- * @param path API path
79
- * @param options Request options
80
- * @returns Response data
81
- */
82
- request<T>(method: string, path: string, { data, query }?: {
83
- data?: any;
84
- query?: Record<string, string>;
85
- }): Promise<T>;
86
- /**
87
- * Generate a token for the forward endpoint
88
- * @param options Token options
89
- * @returns Base64 encoded token
90
- */
91
- generateForwardToken(options: ForwardTokenOptions): string;
92
- }
93
-
94
1
  interface CreateCheckoutSessionParams {
95
- checkout_mode: "onboarding" | "topup";
2
+ checkout_mode: 'onboarding' | 'topup' | 'subscription';
96
3
  origin_url: string;
97
4
  reference_id?: string;
98
5
  connection_id?: string;
6
+ subscription_config_id?: string;
99
7
  }
100
8
  interface CheckoutSessionsListParams {
101
9
  cursor?: string;
@@ -143,13 +51,24 @@ interface ListResponse<T> {
143
51
  has_more: boolean;
144
52
  next_cursor?: string;
145
53
  }
54
+ interface CreateSubscriptionConfigParams {
55
+ name: string;
56
+ period_amount: string;
57
+ rollover_type: 'full' | 'none';
58
+ }
59
+ interface UpdateSubscriptionConfigParams {
60
+ name?: string;
61
+ period_amount?: string;
62
+ rollover_type?: 'full' | 'none';
63
+ }
146
64
  type RestCheckoutSession = {
147
65
  checkout_session_id: string;
148
66
  checkout_session_token: string;
149
- checkout_mode: "onboarding" | "topup";
67
+ checkout_mode: 'onboarding' | 'topup' | 'subscription';
150
68
  origin_url: string;
151
69
  connection_id?: string;
152
70
  reference_id?: string;
71
+ subscription_config_id?: string;
153
72
  created_at: string;
154
73
  completed_at?: string;
155
74
  };
@@ -171,11 +90,11 @@ type RestConnection = {
171
90
  };
172
91
  type RestRequest = {
173
92
  request_id: string;
174
- status: "pending" | "completed" | "error";
93
+ status: 'pending' | 'completed' | 'error';
175
94
  connection_id?: string;
176
95
  product_id?: string;
177
96
  provider: string;
178
- provider_key_type: "managed" | "unmanaged";
97
+ provider_key_type: 'managed' | 'unmanaged';
179
98
  model?: string;
180
99
  endpoint: string;
181
100
  response_id?: string;
@@ -192,17 +111,17 @@ type RestRequest = {
192
111
  input_cost: string;
193
112
  output_cost: string;
194
113
  total_cost: string;
195
- payer: "wallet" | "merchant";
114
+ payer: 'wallet' | 'merchant';
196
115
  };
197
116
  fee: {
198
117
  amount: string;
199
- rate_type: "fixed" | "percentage";
200
- token_basis: "input+output" | "output";
118
+ rate_type: 'fixed' | 'percentage';
119
+ token_basis: 'input+output' | 'output';
201
120
  breakdown: {
202
121
  tier: {
203
122
  start: number;
204
123
  rate: string;
205
- type: "tokens_1m" | "characters_1m" | "minutes" | "requests";
124
+ type: 'tokens_1m' | 'characters_1m' | 'minutes' | 'requests';
206
125
  };
207
126
  tokens: number;
208
127
  characters: number;
@@ -212,7 +131,7 @@ type RestRequest = {
212
131
  };
213
132
  service_charge: {
214
133
  amount: string;
215
- payer: "wallet" | "merchant";
134
+ payer: 'wallet' | 'merchant';
216
135
  };
217
136
  total_request_cost: string;
218
137
  total_wallet_cost: string;
@@ -246,6 +165,36 @@ type RestUsage = {
246
165
  total_merchant_cost: string;
247
166
  };
248
167
  };
168
+ type RestSubscriptionConfig = {
169
+ subscription_config_id: string;
170
+ merchant_id: string;
171
+ name: string;
172
+ period_amount: string;
173
+ rollover_type: 'full' | 'none';
174
+ created_at: string;
175
+ };
176
+ type RestActiveSubscription = {
177
+ active_subscription_id: string;
178
+ wallet_id: string;
179
+ subscription_config_id: string;
180
+ started_at: string;
181
+ billing_anchor: number;
182
+ cancelled_at?: string;
183
+ status: 'active' | 'cancelled';
184
+ created_at: string;
185
+ subscription_config: RestSubscriptionConfig;
186
+ wallet: {
187
+ wallet_id: string;
188
+ phone: string;
189
+ email?: string;
190
+ first_name?: string;
191
+ last_name?: string;
192
+ active_balance: string;
193
+ created_at: string;
194
+ };
195
+ };
196
+
197
+ /** biome-ignore-all lint/style/noNamespace: package uses namespace */
249
198
 
250
199
  declare namespace Resources {
251
200
  abstract class BaseResource {
@@ -334,7 +283,146 @@ declare namespace Resources {
334
283
  */
335
284
  retrieve(params: UsageParams): Promise<RestUsage>;
336
285
  }
286
+ export class SubscriptionsResource extends BaseResource {
287
+ /**
288
+ * List subscription configurations
289
+ * @returns List of subscription configurations
290
+ */
291
+ listConfigs(): Promise<RestSubscriptionConfig[]>;
292
+ /**
293
+ * Create a subscription configuration
294
+ * @param params Subscription configuration parameters
295
+ * @returns Created subscription configuration
296
+ */
297
+ createConfig(params: CreateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
298
+ /**
299
+ * Update a subscription configuration
300
+ * @param id Subscription configuration ID
301
+ * @param params Update parameters
302
+ * @returns Updated subscription configuration
303
+ */
304
+ updateConfig(id: string, params: UpdateSubscriptionConfigParams): Promise<RestSubscriptionConfig>;
305
+ /**
306
+ * Delete a subscription configuration
307
+ * @param id Subscription configuration ID
308
+ * @returns Success response
309
+ */
310
+ deleteConfig(id: string): Promise<{
311
+ success: boolean;
312
+ }>;
313
+ /**
314
+ * List active subscriptions for a merchant
315
+ * @returns List of active subscriptions
316
+ */
317
+ listActiveSubscriptions(): Promise<RestActiveSubscription[]>;
318
+ /**
319
+ * Cancel an active subscription
320
+ * @param id Active subscription ID
321
+ * @returns Success response
322
+ */
323
+ cancelActiveSubscription(id: string): Promise<{
324
+ success: boolean;
325
+ }>;
326
+ }
337
327
  export { };
338
328
  }
339
329
 
340
- 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 };
330
+ type ApiVersion = '2025-04-28.v1';
331
+ interface Config {
332
+ apiVersion: ApiVersion;
333
+ /**
334
+ * Base URL for the API.
335
+ * If not provided, it will be inferred from the secret key (production or sandbox).
336
+ */
337
+ baseUrl?: string;
338
+ }
339
+ type ForwardTokenOptions = {
340
+ connection_secret: string;
341
+ product_secret: string;
342
+ provider_key?: string;
343
+ } | {
344
+ connection_secret: null;
345
+ product_secret: null;
346
+ provider_key: string;
347
+ };
348
+ declare class Lava {
349
+ private readonly secretKey;
350
+ private readonly baseUrl;
351
+ private readonly apiVersion;
352
+ /**
353
+ * The checkout sessions resource
354
+ */
355
+ readonly checkoutSessions: Resources.CheckoutSessionsResource;
356
+ /**
357
+ * The connections resource
358
+ */
359
+ readonly connections: Resources.ConnectionsResource;
360
+ /**
361
+ * The requests resource
362
+ */
363
+ readonly requests: Resources.RequestsResource;
364
+ /**
365
+ * The usage resource
366
+ */
367
+ readonly usage: Resources.UsageResource;
368
+ /**
369
+ * The subscriptions resource
370
+ */
371
+ readonly subscriptions: Resources.SubscriptionsResource;
372
+ /**
373
+ * Provider URLs for convenience
374
+ */
375
+ readonly providers: {
376
+ openai: string;
377
+ anthropic: string;
378
+ mistral: string;
379
+ deepseek: string;
380
+ xai: string;
381
+ google: string;
382
+ googleOpenaiCompatible: string;
383
+ kluster: string;
384
+ inference: string;
385
+ groq: string;
386
+ novita: string;
387
+ vercel: string;
388
+ together: string;
389
+ hyperbolic: string;
390
+ elevenlabs: string;
391
+ sambanova: string;
392
+ deepinfra: string;
393
+ cohere: string;
394
+ parasail: string;
395
+ nebius: string;
396
+ fireworks: string;
397
+ cerebras: string;
398
+ targon: string;
399
+ gmicloud: string;
400
+ chutes: string;
401
+ baseten: string;
402
+ };
403
+ /**
404
+ * Create a new Lava client
405
+ * @param secretKey Your Lava secret key
406
+ * @param config Configuration options
407
+ */
408
+ constructor(secretKey: string, config: Config);
409
+ /**
410
+ * Make a request to the Lava API
411
+ * @param method HTTP method
412
+ * @param path API path
413
+ * @param options Request options
414
+ * @returns Response data
415
+ */
416
+ request<T>(method: string, path: string, { data, query }?: {
417
+ data?: unknown;
418
+ query?: Record<string, string>;
419
+ }): Promise<T>;
420
+ /**
421
+ * Generate a token for the forward endpoint
422
+ * @param options Token options
423
+ * @returns Base64 encoded token
424
+ */
425
+ generateForwardToken(options: ForwardTokenOptions): string;
426
+ }
427
+
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 };
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var Resources;
39
39
  * @param params Checkout session parameters
40
40
  * @returns Created checkout session
41
41
  */
42
- async create(params) {
42
+ create(params) {
43
43
  return this.lava.request(
44
44
  "POST",
45
45
  "checkout_sessions",
@@ -53,12 +53,18 @@ var Resources;
53
53
  * @param params List parameters
54
54
  * @returns Paginated list of checkout sessions
55
55
  */
56
- async list(params) {
56
+ list(params) {
57
57
  const queryParams = {};
58
58
  if (params) {
59
- if (params.cursor) queryParams.cursor = params.cursor;
60
- if (params.limit) queryParams.limit = params.limit.toString();
61
- if (params.reference_id) queryParams.reference_id = params.reference_id;
59
+ if (params.cursor) {
60
+ queryParams.cursor = params.cursor;
61
+ }
62
+ if (params.limit) {
63
+ queryParams.limit = params.limit.toString();
64
+ }
65
+ if (params.reference_id) {
66
+ queryParams.reference_id = params.reference_id;
67
+ }
62
68
  }
63
69
  return this.lava.request(
64
70
  "GET",
@@ -73,7 +79,7 @@ var Resources;
73
79
  * @param checkoutSessionId Checkout session ID
74
80
  * @returns Checkout session details
75
81
  */
76
- async retrieve(checkoutSessionId) {
82
+ retrieve(checkoutSessionId) {
77
83
  return this.lava.request(
78
84
  "GET",
79
85
  `checkout_sessions/${checkoutSessionId}`
@@ -87,12 +93,18 @@ var Resources;
87
93
  * @param params List parameters
88
94
  * @returns Paginated list of connections
89
95
  */
90
- async list(params) {
96
+ list(params) {
91
97
  const queryParams = {};
92
98
  if (params) {
93
- if (params.cursor) queryParams.cursor = params.cursor;
94
- if (params.limit) queryParams.limit = params.limit.toString();
95
- if (params.reference_id) queryParams.reference_id = params.reference_id;
99
+ if (params.cursor) {
100
+ queryParams.cursor = params.cursor;
101
+ }
102
+ if (params.limit) {
103
+ queryParams.limit = params.limit.toString();
104
+ }
105
+ if (params.reference_id) {
106
+ queryParams.reference_id = params.reference_id;
107
+ }
96
108
  }
97
109
  return this.lava.request(
98
110
  "GET",
@@ -107,7 +119,7 @@ var Resources;
107
119
  * @param connectionId Connection ID
108
120
  * @returns Connection details
109
121
  */
110
- async retrieve(connectionId) {
122
+ retrieve(connectionId) {
111
123
  return this.lava.request(
112
124
  "GET",
113
125
  `connections/${connectionId}`
@@ -118,7 +130,7 @@ var Resources;
118
130
  * @param connectionId Connection ID
119
131
  * @returns Success status
120
132
  */
121
- async delete(connectionId) {
133
+ delete(connectionId) {
122
134
  return this.lava.request(
123
135
  "DELETE",
124
136
  `connections/${connectionId}`
@@ -132,18 +144,26 @@ var Resources;
132
144
  * @param params List parameters
133
145
  * @returns Paginated list of requests
134
146
  */
135
- async list(params) {
147
+ list(params) {
136
148
  const queryParams = {};
137
149
  if (params) {
138
- if (params.cursor) queryParams.cursor = params.cursor;
139
- if (params.limit) queryParams.limit = params.limit.toString();
140
- if (params.connection_id)
150
+ if (params.cursor) {
151
+ queryParams.cursor = params.cursor;
152
+ }
153
+ if (params.limit) {
154
+ queryParams.limit = params.limit.toString();
155
+ }
156
+ if (params.connection_id) {
141
157
  queryParams.connection_id = params.connection_id;
142
- if (params.product_id) queryParams.product_id = params.product_id;
143
- if (params.metadata_filters)
158
+ }
159
+ if (params.product_id) {
160
+ queryParams.product_id = params.product_id;
161
+ }
162
+ if (params.metadata_filters) {
144
163
  queryParams.metadata_filters = JSON.stringify(
145
164
  Object.entries(params.metadata_filters)
146
165
  );
166
+ }
147
167
  }
148
168
  return this.lava.request("GET", "requests", {
149
169
  query: queryParams
@@ -154,7 +174,7 @@ var Resources;
154
174
  * @param params Request parameters
155
175
  * @returns Created request details
156
176
  */
157
- async create(params) {
177
+ create(params) {
158
178
  return this.lava.request("POST", "requests", {
159
179
  data: params
160
180
  });
@@ -164,7 +184,7 @@ var Resources;
164
184
  * @param requestId Request ID
165
185
  * @returns Request details
166
186
  */
167
- async retrieve(requestId) {
187
+ retrieve(requestId) {
168
188
  return this.lava.request("GET", `requests/${requestId}`);
169
189
  }
170
190
  }
@@ -175,24 +195,104 @@ var Resources;
175
195
  * @param params Usage parameters
176
196
  * @returns Usage data
177
197
  */
178
- async retrieve(params) {
198
+ retrieve(params) {
179
199
  const queryParams = {
180
200
  start: params.start
181
201
  };
182
- if (params.end) queryParams.end = params.end;
183
- if (params.connection_id)
202
+ if (params.end) {
203
+ queryParams.end = params.end;
204
+ }
205
+ if (params.connection_id) {
184
206
  queryParams.connection_id = params.connection_id;
185
- if (params.product_id) queryParams.product_id = params.product_id;
186
- if (params.metadata_filters)
207
+ }
208
+ if (params.product_id) {
209
+ queryParams.product_id = params.product_id;
210
+ }
211
+ if (params.metadata_filters) {
187
212
  queryParams.metadata_filters = JSON.stringify(
188
213
  Object.entries(params.metadata_filters)
189
214
  );
215
+ }
190
216
  return this.lava.request("GET", "usage", {
191
217
  query: queryParams
192
218
  });
193
219
  }
194
220
  }
195
221
  Resources2.UsageResource = UsageResource;
222
+ class SubscriptionsResource extends BaseResource {
223
+ /**
224
+ * List subscription configurations
225
+ * @returns List of subscription configurations
226
+ */
227
+ listConfigs() {
228
+ return this.lava.request(
229
+ "GET",
230
+ "subscription-configs"
231
+ );
232
+ }
233
+ /**
234
+ * Create a subscription configuration
235
+ * @param params Subscription configuration parameters
236
+ * @returns Created subscription configuration
237
+ */
238
+ createConfig(params) {
239
+ return this.lava.request(
240
+ "POST",
241
+ "subscription-configs",
242
+ {
243
+ data: params
244
+ }
245
+ );
246
+ }
247
+ /**
248
+ * Update a subscription configuration
249
+ * @param id Subscription configuration ID
250
+ * @param params Update parameters
251
+ * @returns Updated subscription configuration
252
+ */
253
+ updateConfig(id, params) {
254
+ return this.lava.request(
255
+ "PUT",
256
+ `subscription-configs/${id}`,
257
+ {
258
+ data: params
259
+ }
260
+ );
261
+ }
262
+ /**
263
+ * Delete a subscription configuration
264
+ * @param id Subscription configuration ID
265
+ * @returns Success response
266
+ */
267
+ deleteConfig(id) {
268
+ return this.lava.request(
269
+ "DELETE",
270
+ `subscription-configs/${id}`
271
+ );
272
+ }
273
+ /**
274
+ * List active subscriptions for a merchant
275
+ * @returns List of active subscriptions
276
+ */
277
+ listActiveSubscriptions() {
278
+ return this.lava.request(
279
+ "GET",
280
+ "active-subscriptions"
281
+ );
282
+ }
283
+ /**
284
+ * Cancel an active subscription
285
+ * @param id Active subscription ID
286
+ * @returns Success response
287
+ */
288
+ cancelActiveSubscription(id) {
289
+ return this.lava.request(
290
+ "DELETE",
291
+ `active-subscriptions/${id}`
292
+ );
293
+ }
294
+ }
295
+ Resources2.SubscriptionsResource = SubscriptionsResource;
196
296
  })(Resources || (Resources = {}));
197
297
 
198
298
  // src/client.ts
@@ -211,6 +311,7 @@ var Lava = class {
211
311
  this.connections = new Resources.ConnectionsResource(this);
212
312
  this.requests = new Resources.RequestsResource(this);
213
313
  this.usage = new Resources.UsageResource(this);
314
+ this.subscriptions = new Resources.SubscriptionsResource(this);
214
315
  this.providers = {
215
316
  openai: `${this.baseUrl}forward?u=https://api.openai.com/v1`,
216
317
  anthropic: `${this.baseUrl}forward?u=https://api.anthropic.com/v1`,
@@ -236,7 +337,8 @@ var Lava = class {
236
337
  cerebras: `${this.baseUrl}forward?u=https://api.cerebras.ai/v1`,
237
338
  targon: `${this.baseUrl}forward?u=https://api.targon.com/v1`,
238
339
  gmicloud: `${this.baseUrl}forward?u=https://api.gmi-serving.com/v1`,
239
- chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`
340
+ chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`,
341
+ baseten: `${this.baseUrl}forward?u=https://inference.baseten.co/v1`
240
342
  };
241
343
  }
242
344
  /**
@@ -249,11 +351,11 @@ var Lava = class {
249
351
  async request(method, path, { data, query } = {}) {
250
352
  const url = new URL(path, this.baseUrl);
251
353
  if (query) {
252
- Object.entries(query).forEach(([key, value]) => {
354
+ for (const [key, value] of Object.entries(query)) {
253
355
  if (value !== void 0) {
254
356
  url.searchParams.append(key, value.toString());
255
357
  }
256
- });
358
+ }
257
359
  }
258
360
  const headers = {
259
361
  Authorization: `Bearer ${this.secretKey}`,
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ var Resources;
12
12
  * @param params Checkout session parameters
13
13
  * @returns Created checkout session
14
14
  */
15
- async create(params) {
15
+ create(params) {
16
16
  return this.lava.request(
17
17
  "POST",
18
18
  "checkout_sessions",
@@ -26,12 +26,18 @@ var Resources;
26
26
  * @param params List parameters
27
27
  * @returns Paginated list of checkout sessions
28
28
  */
29
- async list(params) {
29
+ list(params) {
30
30
  const queryParams = {};
31
31
  if (params) {
32
- if (params.cursor) queryParams.cursor = params.cursor;
33
- if (params.limit) queryParams.limit = params.limit.toString();
34
- if (params.reference_id) queryParams.reference_id = params.reference_id;
32
+ if (params.cursor) {
33
+ queryParams.cursor = params.cursor;
34
+ }
35
+ if (params.limit) {
36
+ queryParams.limit = params.limit.toString();
37
+ }
38
+ if (params.reference_id) {
39
+ queryParams.reference_id = params.reference_id;
40
+ }
35
41
  }
36
42
  return this.lava.request(
37
43
  "GET",
@@ -46,7 +52,7 @@ var Resources;
46
52
  * @param checkoutSessionId Checkout session ID
47
53
  * @returns Checkout session details
48
54
  */
49
- async retrieve(checkoutSessionId) {
55
+ retrieve(checkoutSessionId) {
50
56
  return this.lava.request(
51
57
  "GET",
52
58
  `checkout_sessions/${checkoutSessionId}`
@@ -60,12 +66,18 @@ var Resources;
60
66
  * @param params List parameters
61
67
  * @returns Paginated list of connections
62
68
  */
63
- async list(params) {
69
+ list(params) {
64
70
  const queryParams = {};
65
71
  if (params) {
66
- if (params.cursor) queryParams.cursor = params.cursor;
67
- if (params.limit) queryParams.limit = params.limit.toString();
68
- if (params.reference_id) queryParams.reference_id = params.reference_id;
72
+ if (params.cursor) {
73
+ queryParams.cursor = params.cursor;
74
+ }
75
+ if (params.limit) {
76
+ queryParams.limit = params.limit.toString();
77
+ }
78
+ if (params.reference_id) {
79
+ queryParams.reference_id = params.reference_id;
80
+ }
69
81
  }
70
82
  return this.lava.request(
71
83
  "GET",
@@ -80,7 +92,7 @@ var Resources;
80
92
  * @param connectionId Connection ID
81
93
  * @returns Connection details
82
94
  */
83
- async retrieve(connectionId) {
95
+ retrieve(connectionId) {
84
96
  return this.lava.request(
85
97
  "GET",
86
98
  `connections/${connectionId}`
@@ -91,7 +103,7 @@ var Resources;
91
103
  * @param connectionId Connection ID
92
104
  * @returns Success status
93
105
  */
94
- async delete(connectionId) {
106
+ delete(connectionId) {
95
107
  return this.lava.request(
96
108
  "DELETE",
97
109
  `connections/${connectionId}`
@@ -105,18 +117,26 @@ var Resources;
105
117
  * @param params List parameters
106
118
  * @returns Paginated list of requests
107
119
  */
108
- async list(params) {
120
+ list(params) {
109
121
  const queryParams = {};
110
122
  if (params) {
111
- if (params.cursor) queryParams.cursor = params.cursor;
112
- if (params.limit) queryParams.limit = params.limit.toString();
113
- if (params.connection_id)
123
+ if (params.cursor) {
124
+ queryParams.cursor = params.cursor;
125
+ }
126
+ if (params.limit) {
127
+ queryParams.limit = params.limit.toString();
128
+ }
129
+ if (params.connection_id) {
114
130
  queryParams.connection_id = params.connection_id;
115
- if (params.product_id) queryParams.product_id = params.product_id;
116
- if (params.metadata_filters)
131
+ }
132
+ if (params.product_id) {
133
+ queryParams.product_id = params.product_id;
134
+ }
135
+ if (params.metadata_filters) {
117
136
  queryParams.metadata_filters = JSON.stringify(
118
137
  Object.entries(params.metadata_filters)
119
138
  );
139
+ }
120
140
  }
121
141
  return this.lava.request("GET", "requests", {
122
142
  query: queryParams
@@ -127,7 +147,7 @@ var Resources;
127
147
  * @param params Request parameters
128
148
  * @returns Created request details
129
149
  */
130
- async create(params) {
150
+ create(params) {
131
151
  return this.lava.request("POST", "requests", {
132
152
  data: params
133
153
  });
@@ -137,7 +157,7 @@ var Resources;
137
157
  * @param requestId Request ID
138
158
  * @returns Request details
139
159
  */
140
- async retrieve(requestId) {
160
+ retrieve(requestId) {
141
161
  return this.lava.request("GET", `requests/${requestId}`);
142
162
  }
143
163
  }
@@ -148,24 +168,104 @@ var Resources;
148
168
  * @param params Usage parameters
149
169
  * @returns Usage data
150
170
  */
151
- async retrieve(params) {
171
+ retrieve(params) {
152
172
  const queryParams = {
153
173
  start: params.start
154
174
  };
155
- if (params.end) queryParams.end = params.end;
156
- if (params.connection_id)
175
+ if (params.end) {
176
+ queryParams.end = params.end;
177
+ }
178
+ if (params.connection_id) {
157
179
  queryParams.connection_id = params.connection_id;
158
- if (params.product_id) queryParams.product_id = params.product_id;
159
- if (params.metadata_filters)
180
+ }
181
+ if (params.product_id) {
182
+ queryParams.product_id = params.product_id;
183
+ }
184
+ if (params.metadata_filters) {
160
185
  queryParams.metadata_filters = JSON.stringify(
161
186
  Object.entries(params.metadata_filters)
162
187
  );
188
+ }
163
189
  return this.lava.request("GET", "usage", {
164
190
  query: queryParams
165
191
  });
166
192
  }
167
193
  }
168
194
  Resources2.UsageResource = UsageResource;
195
+ class SubscriptionsResource extends BaseResource {
196
+ /**
197
+ * List subscription configurations
198
+ * @returns List of subscription configurations
199
+ */
200
+ listConfigs() {
201
+ return this.lava.request(
202
+ "GET",
203
+ "subscription-configs"
204
+ );
205
+ }
206
+ /**
207
+ * Create a subscription configuration
208
+ * @param params Subscription configuration parameters
209
+ * @returns Created subscription configuration
210
+ */
211
+ createConfig(params) {
212
+ return this.lava.request(
213
+ "POST",
214
+ "subscription-configs",
215
+ {
216
+ data: params
217
+ }
218
+ );
219
+ }
220
+ /**
221
+ * Update a subscription configuration
222
+ * @param id Subscription configuration ID
223
+ * @param params Update parameters
224
+ * @returns Updated subscription configuration
225
+ */
226
+ updateConfig(id, params) {
227
+ return this.lava.request(
228
+ "PUT",
229
+ `subscription-configs/${id}`,
230
+ {
231
+ data: params
232
+ }
233
+ );
234
+ }
235
+ /**
236
+ * Delete a subscription configuration
237
+ * @param id Subscription configuration ID
238
+ * @returns Success response
239
+ */
240
+ deleteConfig(id) {
241
+ return this.lava.request(
242
+ "DELETE",
243
+ `subscription-configs/${id}`
244
+ );
245
+ }
246
+ /**
247
+ * List active subscriptions for a merchant
248
+ * @returns List of active subscriptions
249
+ */
250
+ listActiveSubscriptions() {
251
+ return this.lava.request(
252
+ "GET",
253
+ "active-subscriptions"
254
+ );
255
+ }
256
+ /**
257
+ * Cancel an active subscription
258
+ * @param id Active subscription ID
259
+ * @returns Success response
260
+ */
261
+ cancelActiveSubscription(id) {
262
+ return this.lava.request(
263
+ "DELETE",
264
+ `active-subscriptions/${id}`
265
+ );
266
+ }
267
+ }
268
+ Resources2.SubscriptionsResource = SubscriptionsResource;
169
269
  })(Resources || (Resources = {}));
170
270
 
171
271
  // src/client.ts
@@ -184,6 +284,7 @@ var Lava = class {
184
284
  this.connections = new Resources.ConnectionsResource(this);
185
285
  this.requests = new Resources.RequestsResource(this);
186
286
  this.usage = new Resources.UsageResource(this);
287
+ this.subscriptions = new Resources.SubscriptionsResource(this);
187
288
  this.providers = {
188
289
  openai: `${this.baseUrl}forward?u=https://api.openai.com/v1`,
189
290
  anthropic: `${this.baseUrl}forward?u=https://api.anthropic.com/v1`,
@@ -209,7 +310,8 @@ var Lava = class {
209
310
  cerebras: `${this.baseUrl}forward?u=https://api.cerebras.ai/v1`,
210
311
  targon: `${this.baseUrl}forward?u=https://api.targon.com/v1`,
211
312
  gmicloud: `${this.baseUrl}forward?u=https://api.gmi-serving.com/v1`,
212
- chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`
313
+ chutes: `${this.baseUrl}forward?u=https://llm.chutes.ai/v1`,
314
+ baseten: `${this.baseUrl}forward?u=https://inference.baseten.co/v1`
213
315
  };
214
316
  }
215
317
  /**
@@ -222,11 +324,11 @@ var Lava = class {
222
324
  async request(method, path, { data, query } = {}) {
223
325
  const url = new URL(path, this.baseUrl);
224
326
  if (query) {
225
- Object.entries(query).forEach(([key, value]) => {
327
+ for (const [key, value] of Object.entries(query)) {
226
328
  if (value !== void 0) {
227
329
  url.searchParams.append(key, value.toString());
228
330
  }
229
- });
331
+ }
230
332
  }
231
333
  const headers = {
232
334
  Authorization: `Bearer ${this.secretKey}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavapayments/nodejs",
3
- "version": "5.3.1",
3
+ "version": "6.0.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",
@@ -11,8 +11,6 @@
11
11
  "scripts": {
12
12
  "build": "tsup --dts --format cjs,esm src/index.ts",
13
13
  "typecheck": "tsc --noEmit",
14
- "lint": "eslint src/",
15
- "format": "prettier --write \"src/**/*.ts\"",
16
14
  "prepublishOnly": "npm run build",
17
15
  "clean": "rm -rf dist"
18
16
  },
@@ -37,11 +35,6 @@
37
35
  "homepage": "https://github.com/lavapayments/nodejs",
38
36
  "devDependencies": {
39
37
  "@types/node": "^20.0.0",
40
- "@types/eslint": "^8.0.0",
41
- "@typescript-eslint/eslint-plugin": "^6.0.0",
42
- "@typescript-eslint/parser": "^6.0.0",
43
- "eslint": "^8.0.0",
44
- "prettier": "^3.0.0",
45
38
  "tsup": "^8.0.0",
46
39
  "typescript": "^5.0.0"
47
40
  },