diff --git a/api/client/javascript/src/client/common.ts b/api/client/javascript/src/client/common.ts index c2eb0c1b1..99633a660 100644 --- a/api/client/javascript/src/client/common.ts +++ b/api/client/javascript/src/client/common.ts @@ -9,13 +9,15 @@ export type RequestOptions = Pick * An error that occurred during an HTTP request */ export class HTTPError extends Error { - name = 'HTTPError' + public name = 'HTTPError' + public client = 'OpenMeter' constructor( public message: string, public type: string, public title: string, public status: number, + public url: string, protected __raw?: Record ) { super(message) @@ -31,19 +33,21 @@ export class HTTPError extends Error { resp.error ) { return new HTTPError( - resp.error.detail, + `Request failed (${resp.response.url}) [${resp.response.status}]: ${resp.error.detail}`, resp.error.type, resp.error.title, resp.error.status ?? resp.response.status, + resp.response.url, resp.error ) } return new HTTPError( - `Request failed: ${resp.response.statusText}`, + `Request failed (${resp.response.url}) [${resp.response.status}]: ${resp.response.statusText}`, resp.response.statusText, resp.response.statusText, - resp.response.status + resp.response.status, + resp.response.url ) } diff --git a/api/client/javascript/src/client/entitlements.ts b/api/client/javascript/src/client/entitlements.ts index f78728928..aab36e9d0 100644 --- a/api/client/javascript/src/client/entitlements.ts +++ b/api/client/javascript/src/client/entitlements.ts @@ -1,6 +1,7 @@ import { transformResponse } from './utils.js' import type { RequestOptions } from './common.js' import type { + Entitlement, EntitlementCreateInputs, EntitlementGrantCreateInput, operations, @@ -88,7 +89,10 @@ export class Entitlements { * @returns The entitlements */ public async list( - query?: operations['listEntitlements']['parameters']['query'], + query?: Omit< + operations['listEntitlements']['parameters']['query'], + 'page' | 'pageSize' + >, options?: RequestOptions ) { const resp = await this.client.GET('/api/v1/entitlements', { @@ -98,7 +102,7 @@ export class Entitlements { ...options, }) - return transformResponse(resp) + return transformResponse(resp) as Entitlement[] } /** diff --git a/api/client/javascript/src/client/features.ts b/api/client/javascript/src/client/features.ts index 4dda8166e..8d291fae8 100644 --- a/api/client/javascript/src/client/features.ts +++ b/api/client/javascript/src/client/features.ts @@ -1,6 +1,11 @@ import { transformResponse } from './utils.js' import type { RequestOptions } from './common.js' -import type { FeatureCreateInputs, operations, paths } from './schemas.js' +import type { + Feature, + FeatureCreateInputs, + operations, + paths, +} from './schemas.js' import type { Client } from 'openapi-fetch' /** @@ -54,7 +59,10 @@ export class Features { * @returns The features */ public async list( - query?: operations['listFeatures']['parameters']['query'], + query?: Omit< + operations['listFeatures']['parameters']['query'], + 'page' | 'pageSize' + >, options?: RequestOptions ) { const resp = await this.client.GET('/api/v1/features', { @@ -64,7 +72,7 @@ export class Features { ...options, }) - return transformResponse(resp) + return transformResponse(resp) as Feature[] } /**