@rendobar/sdk 3.2.0 → 3.3.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.cjs +10 -3
- package/dist/index.d.cts +24 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.mjs +10 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -61,10 +61,10 @@ const RETRYABLE_STATUS_CODES = new Set([
|
|
|
61
61
|
504
|
|
62
62
|
]);
|
|
63
63
|
function createRequestFn(config) {
|
|
64
|
-
const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
|
|
64
|
+
const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, client = "sdk", timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
|
|
65
65
|
return async function request(path, options = {}) {
|
|
66
66
|
const url = buildUrl(baseUrl, path, options.query);
|
|
67
|
-
const init = buildInit(options, apiKey, accessToken, credentials, orgId);
|
|
67
|
+
const init = buildInit(options, apiKey, accessToken, credentials, orgId, client);
|
|
68
68
|
const combinedSignal = combineSignals(options.signal, timeout);
|
|
69
69
|
let lastError;
|
|
70
70
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
@@ -109,11 +109,12 @@ function buildUrl(baseUrl, path, query) {
|
|
|
109
109
|
}
|
|
110
110
|
return url;
|
|
111
111
|
}
|
|
112
|
-
function buildInit(options, apiKey, accessToken, credentials, orgId) {
|
|
112
|
+
function buildInit(options, apiKey, accessToken, credentials, orgId, client) {
|
|
113
113
|
const headers = { "Content-Type": "application/json" };
|
|
114
114
|
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
115
115
|
else if (accessToken) headers["Authorization"] = `Bearer ${accessToken}`;
|
|
116
116
|
if (orgId) headers["X-Org-Id"] = orgId;
|
|
117
|
+
if (client) headers["X-Rendobar-Client"] = client;
|
|
117
118
|
const init = {
|
|
118
119
|
method: options.method ?? "GET",
|
|
119
120
|
headers
|
|
@@ -292,6 +293,12 @@ function createBillingResource(request) {
|
|
|
292
293
|
signal: options?.signal
|
|
293
294
|
});
|
|
294
295
|
},
|
|
296
|
+
async usageByClient(params, options) {
|
|
297
|
+
return request("/billing/usage-by-client", {
|
|
298
|
+
query: params,
|
|
299
|
+
signal: options?.signal
|
|
300
|
+
});
|
|
301
|
+
},
|
|
295
302
|
async transactions(params, options) {
|
|
296
303
|
return request("/billing/transactions", {
|
|
297
304
|
query: params,
|
package/dist/index.d.cts
CHANGED
|
@@ -2610,6 +2610,12 @@ declare const usageSummarySchema: ZodObject<{
|
|
|
2610
2610
|
computeSeconds: ZodNumber;
|
|
2611
2611
|
}, $strip>>;
|
|
2612
2612
|
}, $strip>;
|
|
2613
|
+
declare const usageByClientSchema: ZodArray<ZodObject<{
|
|
2614
|
+
client: ZodString;
|
|
2615
|
+
jobCount: ZodNumber;
|
|
2616
|
+
amountCharged: ZodNumber;
|
|
2617
|
+
amountFormatted: ZodString;
|
|
2618
|
+
}, $strip>>;
|
|
2613
2619
|
declare const webhookEndpointSchema: ZodObject<{
|
|
2614
2620
|
id: ZodString;
|
|
2615
2621
|
name: ZodString;
|
|
@@ -2812,6 +2818,7 @@ type JobType = output<typeof jobTypeSchema>;
|
|
|
2812
2818
|
type BillingState = output<typeof billingStateSchema>;
|
|
2813
2819
|
type Transaction = output<typeof transactionSchema>;
|
|
2814
2820
|
type UsageSummary = output<typeof usageSummarySchema>;
|
|
2821
|
+
type UsageByClient = output<typeof usageByClientSchema>;
|
|
2815
2822
|
type WebhookEndpoint = output<typeof webhookEndpointSchema>;
|
|
2816
2823
|
type WebhookDelivery = output<typeof webhookDeliverySchema>;
|
|
2817
2824
|
type Organization = output<typeof organizationSchema>;
|
|
@@ -2840,6 +2847,12 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2840
2847
|
}, $strip>, ZodObject<{
|
|
2841
2848
|
type: ZodLiteral<"job.result">;
|
|
2842
2849
|
jobId: ZodString;
|
|
2850
|
+
}, $strip>, ZodObject<{
|
|
2851
|
+
type: ZodLiteral<"job.region_failover">;
|
|
2852
|
+
jobId: ZodString;
|
|
2853
|
+
fromRegion: ZodString;
|
|
2854
|
+
toRegion: ZodString;
|
|
2855
|
+
timestamp: ZodOptional<ZodNumber>;
|
|
2843
2856
|
}, $strip>, ZodObject<{
|
|
2844
2857
|
type: ZodLiteral<"balance.updated">;
|
|
2845
2858
|
balance: ZodNumber;
|
|
@@ -3011,6 +3024,12 @@ interface ClientConfig {
|
|
|
3011
3024
|
maxRetries?: number;
|
|
3012
3025
|
/** Default org ID (sent as X-Org-Id header). */
|
|
3013
3026
|
orgId?: string;
|
|
3027
|
+
/**
|
|
3028
|
+
* Client identifier sent as the X-Rendobar-Client header for usage
|
|
3029
|
+
* attribution. Defaults to "sdk". Wrappers built on this SDK should override
|
|
3030
|
+
* it (e.g. "cli", "n8n") so their traffic is attributed distinctly.
|
|
3031
|
+
*/
|
|
3032
|
+
client?: string;
|
|
3014
3033
|
/** Log request metadata to console.debug. Default: false */
|
|
3015
3034
|
debug?: boolean;
|
|
3016
3035
|
/** Custom fetch function for testing or special runtimes. */
|
|
@@ -3054,6 +3073,11 @@ declare function createClient(config?: ClientConfig): {
|
|
|
3054
3073
|
usage(params?: UsageParams, options?: {
|
|
3055
3074
|
signal?: AbortSignal;
|
|
3056
3075
|
}): Promise<UsageSummary>;
|
|
3076
|
+
usageByClient(params?: {
|
|
3077
|
+
days?: number;
|
|
3078
|
+
}, options?: {
|
|
3079
|
+
signal?: AbortSignal;
|
|
3080
|
+
}): Promise<UsageByClient>;
|
|
3057
3081
|
transactions(params?: TransactionListParams, options?: {
|
|
3058
3082
|
signal?: AbortSignal;
|
|
3059
3083
|
}): Promise<{
|
package/dist/index.d.mts
CHANGED
|
@@ -2610,6 +2610,12 @@ declare const usageSummarySchema: ZodObject<{
|
|
|
2610
2610
|
computeSeconds: ZodNumber;
|
|
2611
2611
|
}, $strip>>;
|
|
2612
2612
|
}, $strip>;
|
|
2613
|
+
declare const usageByClientSchema: ZodArray<ZodObject<{
|
|
2614
|
+
client: ZodString;
|
|
2615
|
+
jobCount: ZodNumber;
|
|
2616
|
+
amountCharged: ZodNumber;
|
|
2617
|
+
amountFormatted: ZodString;
|
|
2618
|
+
}, $strip>>;
|
|
2613
2619
|
declare const webhookEndpointSchema: ZodObject<{
|
|
2614
2620
|
id: ZodString;
|
|
2615
2621
|
name: ZodString;
|
|
@@ -2812,6 +2818,7 @@ type JobType = output<typeof jobTypeSchema>;
|
|
|
2812
2818
|
type BillingState = output<typeof billingStateSchema>;
|
|
2813
2819
|
type Transaction = output<typeof transactionSchema>;
|
|
2814
2820
|
type UsageSummary = output<typeof usageSummarySchema>;
|
|
2821
|
+
type UsageByClient = output<typeof usageByClientSchema>;
|
|
2815
2822
|
type WebhookEndpoint = output<typeof webhookEndpointSchema>;
|
|
2816
2823
|
type WebhookDelivery = output<typeof webhookDeliverySchema>;
|
|
2817
2824
|
type Organization = output<typeof organizationSchema>;
|
|
@@ -2840,6 +2847,12 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2840
2847
|
}, $strip>, ZodObject<{
|
|
2841
2848
|
type: ZodLiteral<"job.result">;
|
|
2842
2849
|
jobId: ZodString;
|
|
2850
|
+
}, $strip>, ZodObject<{
|
|
2851
|
+
type: ZodLiteral<"job.region_failover">;
|
|
2852
|
+
jobId: ZodString;
|
|
2853
|
+
fromRegion: ZodString;
|
|
2854
|
+
toRegion: ZodString;
|
|
2855
|
+
timestamp: ZodOptional<ZodNumber>;
|
|
2843
2856
|
}, $strip>, ZodObject<{
|
|
2844
2857
|
type: ZodLiteral<"balance.updated">;
|
|
2845
2858
|
balance: ZodNumber;
|
|
@@ -3011,6 +3024,12 @@ interface ClientConfig {
|
|
|
3011
3024
|
maxRetries?: number;
|
|
3012
3025
|
/** Default org ID (sent as X-Org-Id header). */
|
|
3013
3026
|
orgId?: string;
|
|
3027
|
+
/**
|
|
3028
|
+
* Client identifier sent as the X-Rendobar-Client header for usage
|
|
3029
|
+
* attribution. Defaults to "sdk". Wrappers built on this SDK should override
|
|
3030
|
+
* it (e.g. "cli", "n8n") so their traffic is attributed distinctly.
|
|
3031
|
+
*/
|
|
3032
|
+
client?: string;
|
|
3014
3033
|
/** Log request metadata to console.debug. Default: false */
|
|
3015
3034
|
debug?: boolean;
|
|
3016
3035
|
/** Custom fetch function for testing or special runtimes. */
|
|
@@ -3054,6 +3073,11 @@ declare function createClient(config?: ClientConfig): {
|
|
|
3054
3073
|
usage(params?: UsageParams, options?: {
|
|
3055
3074
|
signal?: AbortSignal;
|
|
3056
3075
|
}): Promise<UsageSummary>;
|
|
3076
|
+
usageByClient(params?: {
|
|
3077
|
+
days?: number;
|
|
3078
|
+
}, options?: {
|
|
3079
|
+
signal?: AbortSignal;
|
|
3080
|
+
}): Promise<UsageByClient>;
|
|
3057
3081
|
transactions(params?: TransactionListParams, options?: {
|
|
3058
3082
|
signal?: AbortSignal;
|
|
3059
3083
|
}): Promise<{
|
package/dist/index.mjs
CHANGED
|
@@ -60,10 +60,10 @@ const RETRYABLE_STATUS_CODES = new Set([
|
|
|
60
60
|
504
|
|
61
61
|
]);
|
|
62
62
|
function createRequestFn(config) {
|
|
63
|
-
const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
|
|
63
|
+
const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, client = "sdk", timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
|
|
64
64
|
return async function request(path, options = {}) {
|
|
65
65
|
const url = buildUrl(baseUrl, path, options.query);
|
|
66
|
-
const init = buildInit(options, apiKey, accessToken, credentials, orgId);
|
|
66
|
+
const init = buildInit(options, apiKey, accessToken, credentials, orgId, client);
|
|
67
67
|
const combinedSignal = combineSignals(options.signal, timeout);
|
|
68
68
|
let lastError;
|
|
69
69
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
@@ -108,11 +108,12 @@ function buildUrl(baseUrl, path, query) {
|
|
|
108
108
|
}
|
|
109
109
|
return url;
|
|
110
110
|
}
|
|
111
|
-
function buildInit(options, apiKey, accessToken, credentials, orgId) {
|
|
111
|
+
function buildInit(options, apiKey, accessToken, credentials, orgId, client) {
|
|
112
112
|
const headers = { "Content-Type": "application/json" };
|
|
113
113
|
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
114
114
|
else if (accessToken) headers["Authorization"] = `Bearer ${accessToken}`;
|
|
115
115
|
if (orgId) headers["X-Org-Id"] = orgId;
|
|
116
|
+
if (client) headers["X-Rendobar-Client"] = client;
|
|
116
117
|
const init = {
|
|
117
118
|
method: options.method ?? "GET",
|
|
118
119
|
headers
|
|
@@ -291,6 +292,12 @@ function createBillingResource(request) {
|
|
|
291
292
|
signal: options?.signal
|
|
292
293
|
});
|
|
293
294
|
},
|
|
295
|
+
async usageByClient(params, options) {
|
|
296
|
+
return request("/billing/usage-by-client", {
|
|
297
|
+
query: params,
|
|
298
|
+
signal: options?.signal
|
|
299
|
+
});
|
|
300
|
+
},
|
|
294
301
|
async transactions(params, options) {
|
|
295
302
|
return request("/billing/transactions", {
|
|
296
303
|
query: params,
|