Skip to content

Commit

Permalink
liblab SDK update for version v0.9.0-alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
seniorquico committed Sep 25, 2024
1 parent b362fbc commit 2be63b7
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 46 deletions.
14 changes: 8 additions & 6 deletions .manifest.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
@@ -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:../",
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 1 addition & 3 deletions src/http/handlers/hook-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(_request: Request<T>): Map<string, string> {
Expand Down
12 changes: 3 additions & 9 deletions src/http/hooks/custom-hook.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>): Promise<HttpRequest> {
Expand All @@ -20,13 +21,6 @@ export class CustomHook implements Hook {
response: HttpResponse<any>,
params: Map<string, string>,
): Promise<HttpError> {
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,
) {}
}
12 changes: 4 additions & 8 deletions src/http/transport/request-fetch-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class RequestFetchAdapter<T> 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<HttpResponse<T>> {
Expand All @@ -25,10 +25,6 @@ export class RequestFetchAdapter<T> implements HttpAdapter {
headers: this.getHeaders(response),
};

if (metadata.status >= 400) {
throw new HttpError(metadata);
}

return {
metadata,
raw: await response.clone().arrayBuffer(),
Expand Down Expand Up @@ -66,14 +62,14 @@ export class RequestFetchAdapter<T> 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),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2be63b7

Please sign in to comment.