Skip to content

Commit

Permalink
liblab SDK update for version v0.9.0-alpha.2
Browse files Browse the repository at this point in the history
  • Loading branch information
seniorquico committed Sep 11, 2024
1 parent 8d4c4a9 commit ddb3ca4
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 69 deletions.
20 changes: 10 additions & 10 deletions .manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"liblabVersion": "2.1.31",
"date": "2024-09-06T14:42:21.534Z",
"liblabVersion": "2.3.1",
"date": "2024-09-11T23:34:32.865Z",
"config": {
"apiId": 1126,
"sdkName": "salad-cloud-imds-sdk",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"liblabVersion": "2",
"deliveryMethods": ["zip"],
"languages": ["typescript"],
Expand All @@ -25,15 +25,15 @@
"homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-dotnet",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"targetBranch": "main"
},
"go": {
"goModuleName": "github.com/saladtechnologies/salad-cloud-imds-sdk-go",
"githubRepoName": "salad-cloud-imds-sdk-go",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"targetBranch": "main"
},
"java": {
Expand All @@ -57,7 +57,7 @@
"homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-java",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"targetBranch": "main"
},
"python": {
Expand Down Expand Up @@ -100,7 +100,7 @@
"githubRepoName": "salad-cloud-imds-sdk-python",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"targetBranch": "main"
},
"typescript": {
Expand All @@ -123,7 +123,7 @@
"homepage": "https://github.com/saladtechnologies/salad-cloud-imds-sdk-javascript",
"ignoreFiles": [".gitignore", "./LICENSE"],
"liblabVersion": "2",
"sdkVersion": "0.9.0-alpha.1",
"sdkVersion": "0.9.0-alpha.2",
"targetBranch": "main"
}
},
Expand Down Expand Up @@ -155,7 +155,7 @@
},
"multiTenant": true,
"hooksLocation": {
"bucketKey": "7034/hooks.zip",
"bucketKey": "7096/hooks.zip",
"bucketName": "prod-liblab-api-stack-hooks"
},
"includeWatermark": false,
Expand Down Expand Up @@ -189,7 +189,7 @@
"compilerOptions": {
"target": "es6",
"module": "Node16",
"lib": ["es2017", "dom"]
"lib": ["es2018", "dom"]
},
"usesFormData": false,
"authentication": {},
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SaladCloudImdsSdk TypeScript SDK 0.9.0-alpha.1
# SaladCloudImdsSdk TypeScript SDK 0.9.0-alpha.2

Welcome to the SaladCloudImdsSdk SDK documentation. This guide will help you get started with integrating and using the SaladCloudImdsSdk SDK in your project.

## Versions

- API version: `0.9.0-alpha.1`
- SDK version: `0.9.0-alpha.1`
- SDK version: `0.9.0-alpha.2`

## About the API

Expand Down
8 changes: 4 additions & 4 deletions documentation/models/ContainerStatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Represents the health statuses of the running container.

**Properties**

| Name | Type | Required | Description |
| :------ | :------ | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ready | boolean || `true` if the running container is ready. If a readiness probe is defined, this returns the latest result of the probe. If a readiness probe is not defined but a startup probe is defined, this returns the same value as the `started` property. If neither a readiness probe nor a startup probe are defined, returns `true`. |
| started | boolean || `true` if the running container is started. If a startup probe is defined, this returns the latest result of the probe. If a startup probe is not defined, returns `true`. |
| Name | Type | Required | Description |
| :------ | :-------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ready | `boolean` || `true` if the running container is ready. If a readiness probe is defined, this returns the latest result of the probe. If a readiness probe is not defined but a startup probe is defined, this returns the same value as the `started` property. If neither a readiness probe nor a startup probe are defined, returns `true`. |
| started | `boolean` || `true` if the running container is started. If a startup probe is defined, this returns the latest result of the probe. If a startup probe is not defined, returns `true`. |
6 changes: 3 additions & 3 deletions documentation/models/ContainerToken.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Represents the identity token of the running container.

**Properties**

| Name | Type | Required | Description |
| :--- | :----- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| jwt | string || The JSON Web Token (JWT) that may be used to identify the running container. The JWT may be verified using the JSON Web Key Set (JWKS) available at https://matrix-rest-api.salad.com/.well-known/stash-jwks.json. |
| Name | Type | Required | Description |
| :--- | :------- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| jwt | `string` || The JSON Web Token (JWT) that may be used to identify the running container. The JWT may be verified using the JSON Web Key Set (JWKS) available at https://matrix-rest-api.salad.com/.well-known/stash-jwks.json. |
6 changes: 3 additions & 3 deletions documentation/models/ReallocateContainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Represents a request to reallocate a container.

**Properties**

| Name | Type | Required | Description |
| :----- | :----- | :------- | :---------------------------------------------------------------------------------------------------------------------------- |
| reason | string || The reason for reallocating the container. This value is reported to SaladCloud support for quality assurance of Salad Nodes. |
| Name | Type | Required | Description |
| :----- | :------- | :------- | :---------------------------------------------------------------------------------------------------------------------------- |
| reason | `string` || The reason for reallocating the container. This value is reported to SaladCloud support for quality assurance of Salad Nodes. |
8 changes: 4 additions & 4 deletions documentation/services/MetadataService.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Reallocates the running container to another Salad Node

**Parameters**

| Name | Type | Required | Description |
| :--- | :------------------------------------------------------ | :------- | :---------------- |
| body | [ReallocateContainer](../models/ReallocateContainer.md) || The request body. |
| Name | Type | Required | Description |
| :--- | :-------------------------------------------------------- | :------- | :---------------- |
| body | `[ReallocateContainer](../models/ReallocateContainer.md)` || The request body. |

**Example Usage Code Snippet**

Expand All @@ -30,7 +30,7 @@ import { ReallocateContainer, SaladCloudImdsSdk } from '@saladtechnologies-oss/s
const saladCloudImdsSdk = new SaladCloudImdsSdk({});

const reallocateContainer: ReallocateContainer = {
reason: 'aliqua ad dolor officia',
reason: 'laborum culpa',
};

const { data } = await saladCloudImdsSdk.metadata.reallocateContainer(input);
Expand Down
2 changes: 1 addition & 1 deletion documentation/snippets/v1-reallocate-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReallocateContainer, SaladCloudImdsSdk } from '@saladtechnologies-oss/s
const saladCloudImdsSdk = new SaladCloudImdsSdk({});

const reallocateContainer: ReallocateContainer = {
reason: 'aliqua ad dolor officia',
reason: 'laborum culpa',
};

const { data } = await saladCloudImdsSdk.metadata.reallocateContainer(input);
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-imds-sdk",
"version": "0.9.0-alpha.1",
"version": "0.9.0-alpha.2",
"private": true,
"dependencies": {
"@saladtechnologies-oss/salad-cloud-imds-sdk": "file:../",
Expand Down
2 changes: 1 addition & 1 deletion examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"declarationMap": true,
"lib": ["es2017", "dom"],
"lib": ["es2018", "dom"],
"sourceMap": true
},
"include": ["src/"]
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.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@saladtechnologies-oss/salad-cloud-imds-sdk",
"version": "0.9.0-alpha.1",
"version": "0.9.0-alpha.2",
"description": "The SaladCloud Instance Metadata Service (IMDS). Please refer to the [SaladCloud API Documentation](https://docs.salad.com/api-reference) for more details.",
"source": "./src/index.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"browser": "./dist/index.umd.js",
"unpkg": "./dist/index.umd.js",
"types": "./dist/commonjs/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"browser": "./dist/index.js",
"unpkg": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"test": "tsc --noEmit",
"build": "tsup-node src/index.ts --format cjs,esm --dts --clean",
Expand Down
32 changes: 32 additions & 0 deletions src/http/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,43 @@ export class HttpClient {
return this.requestHandlerChain.callChain(request);
}

public async callPaginated<FullResponse, Page>(request: Request<FullResponse, Page>): Promise<HttpResponse<Page>> {
const response = await this.call<FullResponse>(request as any);

if (!response.data) {
throw new Error('now response data to paginate through');
}

return {
...response,
data: this.getPage<FullResponse, Page>(request, response.data),
};
}

setBaseUrl(url: string): void {
this.config.baseUrl = url;
}

setConfig(config: SdkConfig): void {
this.config = config;
}

private getPage<FullResponse, Page>(request: Request<FullResponse, Page>, data: FullResponse): Page {
if (!request.pagination) {
throw new Error('getPage called for request without pagination property');
}

let curr: any = data;
for (const segment of request.pagination?.pagePath || []) {
curr = curr[segment];
}

const page = request.pagination?.pageSchema?.parse(curr);
if (!page) {
throw new Error(
`error getting page data. Curr: ${JSON.stringify(curr)}. PagePath: ${request.pagination?.pagePath}. Data: ${JSON.stringify(data)}`,
);
}
return page;
}
}
10 changes: 9 additions & 1 deletion src/http/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
export type { SdkConfig, RequestConfig, RetryOptions, ValidationOptions } from './types.ts';
export type {
SdkConfig,
RequestConfig,
RetryOptions,
ValidationOptions,
HttpMetadata,
HttpMethod,
HttpResponse,
} from './types.ts';
Loading

0 comments on commit ddb3ca4

Please sign in to comment.