@lavapayments/nodejs 0.1.2 → 1.0.1
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 +1 -1
- package/dist/index.d.mts +87 -87
- package/dist/index.d.ts +87 -87
- package/dist/index.js +6 -4
- package/dist/index.mjs +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
+
type ApiVersion = "2025-03-10.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
|
+
};
|
|
14
|
+
declare class Lava {
|
|
15
|
+
private readonly secretKey;
|
|
16
|
+
private readonly baseUrl;
|
|
17
|
+
private readonly apiVersion;
|
|
18
|
+
/**
|
|
19
|
+
* The checkout resource
|
|
20
|
+
*/
|
|
21
|
+
readonly checkout: Resources.CheckoutResource;
|
|
22
|
+
/**
|
|
23
|
+
* The connections resource
|
|
24
|
+
*/
|
|
25
|
+
readonly connections: Resources.ConnectionsResource;
|
|
26
|
+
/**
|
|
27
|
+
* The requests resource
|
|
28
|
+
*/
|
|
29
|
+
readonly requests: Resources.RequestsResource;
|
|
30
|
+
/**
|
|
31
|
+
* The usage resource
|
|
32
|
+
*/
|
|
33
|
+
readonly usage: Resources.UsageResource;
|
|
34
|
+
/**
|
|
35
|
+
* OpenAI base URL for convenience
|
|
36
|
+
*/
|
|
37
|
+
readonly openaiUrl: string;
|
|
38
|
+
/**
|
|
39
|
+
* Anthropic base URL for convenience
|
|
40
|
+
*/
|
|
41
|
+
readonly anthropicUrl: string;
|
|
42
|
+
/**
|
|
43
|
+
* Mistral base URL for convenience
|
|
44
|
+
*/
|
|
45
|
+
readonly mistralUrl: string;
|
|
46
|
+
/**
|
|
47
|
+
* DeepSeek base URL for convenience
|
|
48
|
+
*/
|
|
49
|
+
readonly deepseekUrl: string;
|
|
50
|
+
/**
|
|
51
|
+
* xAI base URL for convenience
|
|
52
|
+
*/
|
|
53
|
+
readonly xaiUrl: string;
|
|
54
|
+
/**
|
|
55
|
+
* Google base URL for convenience
|
|
56
|
+
*/
|
|
57
|
+
readonly googleUrl: string;
|
|
58
|
+
/**
|
|
59
|
+
* Google OpenAI-compatible base URL for convenience
|
|
60
|
+
*/
|
|
61
|
+
readonly googleOpenaiCompatibleUrl: string;
|
|
62
|
+
/**
|
|
63
|
+
* Create a new Lava client
|
|
64
|
+
* @param secretKey Your Lava secret key
|
|
65
|
+
* @param config Configuration options
|
|
66
|
+
*/
|
|
67
|
+
constructor(secretKey: string, config: Config);
|
|
68
|
+
/**
|
|
69
|
+
* Make a request to the Lava API
|
|
70
|
+
* @param method HTTP method
|
|
71
|
+
* @param path API path
|
|
72
|
+
* @param options Request options
|
|
73
|
+
* @returns Response data
|
|
74
|
+
*/
|
|
75
|
+
request<T>(method: string, path: string, { data, query }?: {
|
|
76
|
+
data?: any;
|
|
77
|
+
query?: Record<string, string>;
|
|
78
|
+
}): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Generate a token for the forward endpoint
|
|
81
|
+
* @param options Token options
|
|
82
|
+
* @returns Base64 encoded token
|
|
83
|
+
*/
|
|
84
|
+
generateForwardToken(options: ForwardTokenOptions): string;
|
|
85
|
+
}
|
|
86
|
+
|
|
1
87
|
type CheckoutMode = "onboarding" | "topup";
|
|
2
88
|
interface CreateCheckoutSessionParams {
|
|
3
89
|
checkout_mode: CheckoutMode;
|
|
@@ -185,90 +271,4 @@ declare namespace Resources {
|
|
|
185
271
|
export { };
|
|
186
272
|
}
|
|
187
273
|
|
|
188
|
-
type ApiVersion
|
|
189
|
-
interface Config {
|
|
190
|
-
apiVersion: ApiVersion;
|
|
191
|
-
/**
|
|
192
|
-
* Base URL for the API.
|
|
193
|
-
* If not provided, it will be inferred from the secret key (production or sandbox).
|
|
194
|
-
*/
|
|
195
|
-
baseUrl?: string;
|
|
196
|
-
}
|
|
197
|
-
type ForwardTokenOptions = {
|
|
198
|
-
connection_secret: string;
|
|
199
|
-
product_secret: string;
|
|
200
|
-
};
|
|
201
|
-
declare class Lava {
|
|
202
|
-
private readonly secretKey;
|
|
203
|
-
private readonly baseUrl;
|
|
204
|
-
private readonly apiVersion;
|
|
205
|
-
/**
|
|
206
|
-
* The checkout resource
|
|
207
|
-
*/
|
|
208
|
-
readonly checkout: Resources.CheckoutResource;
|
|
209
|
-
/**
|
|
210
|
-
* The connections resource
|
|
211
|
-
*/
|
|
212
|
-
readonly connections: Resources.ConnectionsResource;
|
|
213
|
-
/**
|
|
214
|
-
* The requests resource
|
|
215
|
-
*/
|
|
216
|
-
readonly requests: Resources.RequestsResource;
|
|
217
|
-
/**
|
|
218
|
-
* The usage resource
|
|
219
|
-
*/
|
|
220
|
-
readonly usage: Resources.UsageResource;
|
|
221
|
-
/**
|
|
222
|
-
* OpenAI base URL for convenience
|
|
223
|
-
*/
|
|
224
|
-
readonly openaiUrl: string;
|
|
225
|
-
/**
|
|
226
|
-
* Anthropic base URL for convenience
|
|
227
|
-
*/
|
|
228
|
-
readonly anthropicUrl: string;
|
|
229
|
-
/**
|
|
230
|
-
* Mistral base URL for convenience
|
|
231
|
-
*/
|
|
232
|
-
readonly mistralUrl: string;
|
|
233
|
-
/**
|
|
234
|
-
* DeepSeek base URL for convenience
|
|
235
|
-
*/
|
|
236
|
-
readonly deepseekUrl: string;
|
|
237
|
-
/**
|
|
238
|
-
* xAI base URL for convenience
|
|
239
|
-
*/
|
|
240
|
-
readonly xaiUrl: string;
|
|
241
|
-
/**
|
|
242
|
-
* Google base URL for convenience
|
|
243
|
-
*/
|
|
244
|
-
readonly googleUrl: string;
|
|
245
|
-
/**
|
|
246
|
-
* Google OpenAI-compatible base URL for convenience
|
|
247
|
-
*/
|
|
248
|
-
readonly googleOpenaiCompatibleUrl: string;
|
|
249
|
-
/**
|
|
250
|
-
* Create a new Lava client
|
|
251
|
-
* @param secretKey Your Lava secret key
|
|
252
|
-
* @param config Configuration options
|
|
253
|
-
*/
|
|
254
|
-
constructor(secretKey: string, config: Config);
|
|
255
|
-
/**
|
|
256
|
-
* Make a request to the Lava API
|
|
257
|
-
* @param method HTTP method
|
|
258
|
-
* @param path API path
|
|
259
|
-
* @param options Request options
|
|
260
|
-
* @returns Response data
|
|
261
|
-
*/
|
|
262
|
-
request<T>(method: string, path: string, { data, query }?: {
|
|
263
|
-
data?: any;
|
|
264
|
-
query?: Record<string, string>;
|
|
265
|
-
}): Promise<T>;
|
|
266
|
-
/**
|
|
267
|
-
* Generate a token for the forward endpoint
|
|
268
|
-
* @param options Token options
|
|
269
|
-
* @returns Base64 encoded token
|
|
270
|
-
*/
|
|
271
|
-
generateForwardToken(options: ForwardTokenOptions): string;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet, Lava as default };
|
|
274
|
+
export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, Lava, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
+
type ApiVersion = "2025-03-10.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
|
+
};
|
|
14
|
+
declare class Lava {
|
|
15
|
+
private readonly secretKey;
|
|
16
|
+
private readonly baseUrl;
|
|
17
|
+
private readonly apiVersion;
|
|
18
|
+
/**
|
|
19
|
+
* The checkout resource
|
|
20
|
+
*/
|
|
21
|
+
readonly checkout: Resources.CheckoutResource;
|
|
22
|
+
/**
|
|
23
|
+
* The connections resource
|
|
24
|
+
*/
|
|
25
|
+
readonly connections: Resources.ConnectionsResource;
|
|
26
|
+
/**
|
|
27
|
+
* The requests resource
|
|
28
|
+
*/
|
|
29
|
+
readonly requests: Resources.RequestsResource;
|
|
30
|
+
/**
|
|
31
|
+
* The usage resource
|
|
32
|
+
*/
|
|
33
|
+
readonly usage: Resources.UsageResource;
|
|
34
|
+
/**
|
|
35
|
+
* OpenAI base URL for convenience
|
|
36
|
+
*/
|
|
37
|
+
readonly openaiUrl: string;
|
|
38
|
+
/**
|
|
39
|
+
* Anthropic base URL for convenience
|
|
40
|
+
*/
|
|
41
|
+
readonly anthropicUrl: string;
|
|
42
|
+
/**
|
|
43
|
+
* Mistral base URL for convenience
|
|
44
|
+
*/
|
|
45
|
+
readonly mistralUrl: string;
|
|
46
|
+
/**
|
|
47
|
+
* DeepSeek base URL for convenience
|
|
48
|
+
*/
|
|
49
|
+
readonly deepseekUrl: string;
|
|
50
|
+
/**
|
|
51
|
+
* xAI base URL for convenience
|
|
52
|
+
*/
|
|
53
|
+
readonly xaiUrl: string;
|
|
54
|
+
/**
|
|
55
|
+
* Google base URL for convenience
|
|
56
|
+
*/
|
|
57
|
+
readonly googleUrl: string;
|
|
58
|
+
/**
|
|
59
|
+
* Google OpenAI-compatible base URL for convenience
|
|
60
|
+
*/
|
|
61
|
+
readonly googleOpenaiCompatibleUrl: string;
|
|
62
|
+
/**
|
|
63
|
+
* Create a new Lava client
|
|
64
|
+
* @param secretKey Your Lava secret key
|
|
65
|
+
* @param config Configuration options
|
|
66
|
+
*/
|
|
67
|
+
constructor(secretKey: string, config: Config);
|
|
68
|
+
/**
|
|
69
|
+
* Make a request to the Lava API
|
|
70
|
+
* @param method HTTP method
|
|
71
|
+
* @param path API path
|
|
72
|
+
* @param options Request options
|
|
73
|
+
* @returns Response data
|
|
74
|
+
*/
|
|
75
|
+
request<T>(method: string, path: string, { data, query }?: {
|
|
76
|
+
data?: any;
|
|
77
|
+
query?: Record<string, string>;
|
|
78
|
+
}): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Generate a token for the forward endpoint
|
|
81
|
+
* @param options Token options
|
|
82
|
+
* @returns Base64 encoded token
|
|
83
|
+
*/
|
|
84
|
+
generateForwardToken(options: ForwardTokenOptions): string;
|
|
85
|
+
}
|
|
86
|
+
|
|
1
87
|
type CheckoutMode = "onboarding" | "topup";
|
|
2
88
|
interface CreateCheckoutSessionParams {
|
|
3
89
|
checkout_mode: CheckoutMode;
|
|
@@ -185,90 +271,4 @@ declare namespace Resources {
|
|
|
185
271
|
export { };
|
|
186
272
|
}
|
|
187
273
|
|
|
188
|
-
type ApiVersion
|
|
189
|
-
interface Config {
|
|
190
|
-
apiVersion: ApiVersion;
|
|
191
|
-
/**
|
|
192
|
-
* Base URL for the API.
|
|
193
|
-
* If not provided, it will be inferred from the secret key (production or sandbox).
|
|
194
|
-
*/
|
|
195
|
-
baseUrl?: string;
|
|
196
|
-
}
|
|
197
|
-
type ForwardTokenOptions = {
|
|
198
|
-
connection_secret: string;
|
|
199
|
-
product_secret: string;
|
|
200
|
-
};
|
|
201
|
-
declare class Lava {
|
|
202
|
-
private readonly secretKey;
|
|
203
|
-
private readonly baseUrl;
|
|
204
|
-
private readonly apiVersion;
|
|
205
|
-
/**
|
|
206
|
-
* The checkout resource
|
|
207
|
-
*/
|
|
208
|
-
readonly checkout: Resources.CheckoutResource;
|
|
209
|
-
/**
|
|
210
|
-
* The connections resource
|
|
211
|
-
*/
|
|
212
|
-
readonly connections: Resources.ConnectionsResource;
|
|
213
|
-
/**
|
|
214
|
-
* The requests resource
|
|
215
|
-
*/
|
|
216
|
-
readonly requests: Resources.RequestsResource;
|
|
217
|
-
/**
|
|
218
|
-
* The usage resource
|
|
219
|
-
*/
|
|
220
|
-
readonly usage: Resources.UsageResource;
|
|
221
|
-
/**
|
|
222
|
-
* OpenAI base URL for convenience
|
|
223
|
-
*/
|
|
224
|
-
readonly openaiUrl: string;
|
|
225
|
-
/**
|
|
226
|
-
* Anthropic base URL for convenience
|
|
227
|
-
*/
|
|
228
|
-
readonly anthropicUrl: string;
|
|
229
|
-
/**
|
|
230
|
-
* Mistral base URL for convenience
|
|
231
|
-
*/
|
|
232
|
-
readonly mistralUrl: string;
|
|
233
|
-
/**
|
|
234
|
-
* DeepSeek base URL for convenience
|
|
235
|
-
*/
|
|
236
|
-
readonly deepseekUrl: string;
|
|
237
|
-
/**
|
|
238
|
-
* xAI base URL for convenience
|
|
239
|
-
*/
|
|
240
|
-
readonly xaiUrl: string;
|
|
241
|
-
/**
|
|
242
|
-
* Google base URL for convenience
|
|
243
|
-
*/
|
|
244
|
-
readonly googleUrl: string;
|
|
245
|
-
/**
|
|
246
|
-
* Google OpenAI-compatible base URL for convenience
|
|
247
|
-
*/
|
|
248
|
-
readonly googleOpenaiCompatibleUrl: string;
|
|
249
|
-
/**
|
|
250
|
-
* Create a new Lava client
|
|
251
|
-
* @param secretKey Your Lava secret key
|
|
252
|
-
* @param config Configuration options
|
|
253
|
-
*/
|
|
254
|
-
constructor(secretKey: string, config: Config);
|
|
255
|
-
/**
|
|
256
|
-
* Make a request to the Lava API
|
|
257
|
-
* @param method HTTP method
|
|
258
|
-
* @param path API path
|
|
259
|
-
* @param options Request options
|
|
260
|
-
* @returns Response data
|
|
261
|
-
*/
|
|
262
|
-
request<T>(method: string, path: string, { data, query }?: {
|
|
263
|
-
data?: any;
|
|
264
|
-
query?: Record<string, string>;
|
|
265
|
-
}): Promise<T>;
|
|
266
|
-
/**
|
|
267
|
-
* Generate a token for the forward endpoint
|
|
268
|
-
* @param options Token options
|
|
269
|
-
* @returns Base64 encoded token
|
|
270
|
-
*/
|
|
271
|
-
generateForwardToken(options: ForwardTokenOptions): string;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet, Lava as default };
|
|
274
|
+
export { type ApiVersion, type CheckoutMode, type CheckoutSession, type Config, type Connection, type ConnectionsListParams, type ConnectionsListResponse, type CreateCheckoutSessionParams, type Fee, type FeeTierBreakdown, type ForwardTokenOptions, Lava, type ModelUsage, type Request, type RequestsListParams, type RequestsListResponse, Resources, type ServiceCharge, type Usage, type UsageData, type UsageParams, type Wallet };
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Lava: () => Lava,
|
|
24
|
+
Resources: () => Resources
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
@@ -149,7 +149,7 @@ var Resources;
|
|
|
149
149
|
Resources2.UsageResource = UsageResource;
|
|
150
150
|
})(Resources || (Resources = {}));
|
|
151
151
|
|
|
152
|
-
// src/
|
|
152
|
+
// src/client.ts
|
|
153
153
|
var Lava = class {
|
|
154
154
|
/**
|
|
155
155
|
* Create a new Lava client
|
|
@@ -202,8 +202,9 @@ var Lava = class {
|
|
|
202
202
|
const response = await fetch(url.toString(), requestOptions);
|
|
203
203
|
if (!response.ok) {
|
|
204
204
|
const errorJson = await response.json().catch(() => ({}));
|
|
205
|
+
const errorMessage = typeof errorJson.error === "object" ? JSON.stringify(errorJson.error) : errorJson.error || "Unknown error";
|
|
205
206
|
throw new Error(
|
|
206
|
-
`Lava API Error: ${response.status} ${response.statusText} - ${
|
|
207
|
+
`Lava API Error: ${response.status} ${response.statusText} - ${errorMessage}`
|
|
207
208
|
);
|
|
208
209
|
}
|
|
209
210
|
return response.json();
|
|
@@ -224,5 +225,6 @@ var Lava = class {
|
|
|
224
225
|
};
|
|
225
226
|
// Annotate the CommonJS export names for ESM import in node:
|
|
226
227
|
0 && (module.exports = {
|
|
228
|
+
Lava,
|
|
227
229
|
Resources
|
|
228
230
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -122,7 +122,7 @@ var Resources;
|
|
|
122
122
|
Resources2.UsageResource = UsageResource;
|
|
123
123
|
})(Resources || (Resources = {}));
|
|
124
124
|
|
|
125
|
-
// src/
|
|
125
|
+
// src/client.ts
|
|
126
126
|
var Lava = class {
|
|
127
127
|
/**
|
|
128
128
|
* Create a new Lava client
|
|
@@ -175,8 +175,9 @@ var Lava = class {
|
|
|
175
175
|
const response = await fetch(url.toString(), requestOptions);
|
|
176
176
|
if (!response.ok) {
|
|
177
177
|
const errorJson = await response.json().catch(() => ({}));
|
|
178
|
+
const errorMessage = typeof errorJson.error === "object" ? JSON.stringify(errorJson.error) : errorJson.error || "Unknown error";
|
|
178
179
|
throw new Error(
|
|
179
|
-
`Lava API Error: ${response.status} ${response.statusText} - ${
|
|
180
|
+
`Lava API Error: ${response.status} ${response.statusText} - ${errorMessage}`
|
|
180
181
|
);
|
|
181
182
|
}
|
|
182
183
|
return response.json();
|
|
@@ -196,6 +197,6 @@ var Lava = class {
|
|
|
196
197
|
}
|
|
197
198
|
};
|
|
198
199
|
export {
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
Lava,
|
|
201
|
+
Resources
|
|
201
202
|
};
|