From 2be63b77c66aae25f893c10443b9b966a9b343bf Mon Sep 17 00:00:00 2001 From: SaladTechnologies <415806+seniorquico@users.noreply.github.com> Date: Wed, 25 Sep 2024 03:54:21 +0000 Subject: [PATCH] liblab SDK update for version v0.9.0-alpha.4 --- .manifest.json | 14 ++++++++------ README.md | 4 ++-- examples/package.json | 2 +- package-lock.json | 10 +++++----- package.json | 2 +- src/http/handlers/hook-handler.ts | 4 +--- src/http/hooks/custom-hook.ts | 12 +++--------- src/http/transport/request-fetch-adapter.ts | 12 ++++-------- src/http/types.ts | 2 +- src/index.ts | 16 ++++++++-------- src/services/base-service.ts | 4 ++-- 11 files changed, 36 insertions(+), 46 deletions(-) diff --git a/.manifest.json b/.manifest.json index d453cb7..6b1f535 100644 --- a/.manifest.json +++ b/.manifest.json @@ -1,10 +1,10 @@ { - "liblabVersion": "2.4.0", - "date": "2024-09-17T04:02:32.183Z", + "liblabVersion": "2.4.1", + "date": "2024-09-25T03:53:32.630Z", "config": { "apiId": 1172, "sdkName": "salad-cloud-sdk", - "sdkVersion": "0.9.0-alpha.3", + "sdkVersion": "0.9.0-alpha.4", "liblabVersion": "2", "deliveryMethods": ["zip"], "languages": ["typescript"], @@ -58,7 +58,7 @@ "homepage": "https://github.com/saladtechnologies/salad-cloud-sdk-java", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.3", + "sdkVersion": "0.9.0-alpha.4", "targetBranch": "main" }, "python": { @@ -138,8 +138,9 @@ "homepage": "https://github.com/saladtechnologies/salad-cloud-sdk-javascript", "ignoreFiles": [".gitignore", "./LICENSE"], "liblabVersion": "2", - "sdkVersion": "0.9.0-alpha.3", - "targetBranch": "main" + "sdkVersion": "0.9.0-alpha.4", + "targetBranch": "main", + "generateEnumAs": "enum" } }, "publishing": { @@ -286,6 +287,7 @@ "homepage": "https://github.com/saladtechnologies/salad-cloud-sdk-javascript", "ignoreFiles": [".gitignore", "./LICENSE"], "targetBranch": "main", + "generateEnumAs": "enum", "typescriptVersion": "5.3.3", "zodVersion": "3.22.0", "compilerOptions": { diff --git a/README.md b/README.md index 015b729..666236d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# SaladCloudSdk TypeScript SDK 0.9.0-alpha.3 +# SaladCloudSdk TypeScript SDK 0.9.0-alpha.4 Welcome to the SaladCloudSdk SDK documentation. This guide will help you get started with integrating and using the SaladCloudSdk SDK in your project. ## Versions - API version: `0.9.0-alpha.3` -- SDK version: `0.9.0-alpha.3` +- SDK version: `0.9.0-alpha.4` ## About the API diff --git a/examples/package.json b/examples/package.json index d2af1b5..952ff57 100644 --- a/examples/package.json +++ b/examples/package.json @@ -1,6 +1,6 @@ { "name": "salad-cloud-sdk", - "version": "0.9.0-alpha.3", + "version": "0.9.0-alpha.4", "private": true, "dependencies": { "@saladtechnologies-oss/salad-cloud-sdk": "file:../", diff --git a/package-lock.json b/package-lock.json index c8e7333..6038408 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@saladtechnologies-oss/salad-cloud-sdk", - "version": "0.9.0-alpha.3", + "version": "0.9.0-alpha.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@saladtechnologies-oss/salad-cloud-sdk", - "version": "0.9.0-alpha.3", + "version": "0.9.0-alpha.4", "license": "MIT", "dependencies": { "zod": "3.22.0" @@ -1427,9 +1427,9 @@ } }, "node_modules/rollup": { - "version": "3.29.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", - "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", + "version": "3.29.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.5.tgz", + "integrity": "sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 3b7f626..03cd6d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@saladtechnologies-oss/salad-cloud-sdk", - "version": "0.9.0-alpha.3", + "version": "0.9.0-alpha.4", "description": "The SaladCloud REST API. Please refer to the [SaladCloud API Documentation](https://docs.salad.com/api-reference) for more details.", "source": "./src/index.ts", "main": "./dist/index.js", diff --git a/src/http/handlers/hook-handler.ts b/src/http/handlers/hook-handler.ts index 5638d3a..17f9935 100644 --- a/src/http/handlers/hook-handler.ts +++ b/src/http/handlers/hook-handler.ts @@ -26,9 +26,7 @@ export class HookHandler implements RequestHandler { return await hook.afterResponse(nextRequest, response, hookParams); } - const error = await hook.onError(nextRequest, response, hookParams); - - throw new HttpError(error.metadata, error.error); + throw await hook.onError(nextRequest, response, hookParams); } private getHookParams(_request: Request): Map { diff --git a/src/http/hooks/custom-hook.ts b/src/http/hooks/custom-hook.ts index c4dcf51..c266d7e 100644 --- a/src/http/hooks/custom-hook.ts +++ b/src/http/hooks/custom-hook.ts @@ -1,6 +1,7 @@ import { HttpMetadata } from '../types'; import { Hook } from './hook'; -import { HttpRequest, HttpResponse, HttpError } from './hook'; +import { HttpRequest, HttpResponse } from './hook'; +import { HttpError } from '../error'; export class CustomHook implements Hook { public async beforeRequest(request: HttpRequest, params: Map): Promise { @@ -20,13 +21,6 @@ export class CustomHook implements Hook { response: HttpResponse, params: Map, ): Promise { - return new CustomHttpError('a custom error message', response.metadata); + return new HttpError(response.metadata); } } - -class CustomHttpError implements HttpError { - constructor( - public error: string, - public metadata: HttpMetadata, - ) {} -} diff --git a/src/http/transport/request-fetch-adapter.ts b/src/http/transport/request-fetch-adapter.ts index dd248cd..f88dd14 100644 --- a/src/http/transport/request-fetch-adapter.ts +++ b/src/http/transport/request-fetch-adapter.ts @@ -13,7 +13,7 @@ export class RequestFetchAdapter implements HttpAdapter { this.setMethod(request.method); this.setHeaders(request.getHeaders()); this.setBody(request.body); - this.setTimeout(request.config.timeout); + this.setTimeout(request.config.timeoutMs); } public async send(): Promise> { @@ -25,10 +25,6 @@ export class RequestFetchAdapter implements HttpAdapter { headers: this.getHeaders(response), }; - if (metadata.status >= 400) { - throw new HttpError(metadata); - } - return { metadata, raw: await response.clone().arrayBuffer(), @@ -66,14 +62,14 @@ export class RequestFetchAdapter implements HttpAdapter { }; } - private setTimeout(timeout: number | undefined) { - if (!timeout) { + private setTimeout(timeoutMs: number | undefined) { + if (!timeoutMs) { return; } this.requestInit = { ...this.requestInit, - signal: AbortSignal.timeout(timeout), + signal: AbortSignal.timeout(timeoutMs), }; } diff --git a/src/http/types.ts b/src/http/types.ts index 21dcb18..7947fa9 100644 --- a/src/http/types.ts +++ b/src/http/types.ts @@ -7,7 +7,7 @@ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD'; export interface SdkConfig { baseUrl?: string; environment?: Environment; - timeout?: number; + timeoutMs?: number; apiKey?: string; apiKeyHeader?: string; retry?: RetryOptions; diff --git a/src/index.ts b/src/index.ts index b2b28b1..38356e0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -75,14 +75,14 @@ export class SaladCloudSdk { this.webhookSecretKey.baseUrl = environment; } - set timeout(timeout: number) { - this.containerGroups.timeout = timeout; - this.workloadErrors.timeout = timeout; - this.queues.timeout = timeout; - this.quotas.timeout = timeout; - this.inferenceEndpoints.timeout = timeout; - this.organizationData.timeout = timeout; - this.webhookSecretKey.timeout = timeout; + set timeoutMs(timeoutMs: number) { + this.containerGroups.timeoutMs = timeoutMs; + this.workloadErrors.timeoutMs = timeoutMs; + this.queues.timeoutMs = timeoutMs; + this.quotas.timeoutMs = timeoutMs; + this.inferenceEndpoints.timeoutMs = timeoutMs; + this.organizationData.timeoutMs = timeoutMs; + this.webhookSecretKey.timeoutMs = timeoutMs; } set apiKey(apiKey: string) { diff --git a/src/services/base-service.ts b/src/services/base-service.ts index 9cabaf4..a2b0a98 100644 --- a/src/services/base-service.ts +++ b/src/services/base-service.ts @@ -17,8 +17,8 @@ export class BaseService { this.config.environment = environment; } - set timeout(timeout: number) { - this.config.timeout = timeout; + set timeoutMs(timeoutMs: number) { + this.config.timeoutMs = timeoutMs; } set apiKey(apiKey: string) {