# velaux-typescript-sdk

> Typescript SDK for VelaUX

Latest version **1.0.2** (published 2023-07-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install velaux-typescript-sdk
pnpm add velaux-typescript-sdk
yarn add velaux-typescript-sdk
bun add velaux-typescript-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-07-28 |
| First published | 2023-07-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zuoning Zhang |
| Maintainers | zuoningz |

## Links

- npm: https://www.npmjs.com/package/velaux-typescript-sdk
- npm.io page: https://npm.io/package/velaux-typescript-sdk

## Recent versions

- 1.0.2 (latest) — 2023-07-28
- 1.0.1 — 2023-07-28
- 1.0.0 — 2023-07-28

## README

# velaux-typescript-sdk
Typescript SDK for VelaUX

# About This Repo

The typescript SDK is generated using OpenAPI generator from the [```swagger.json``` file](https://github.com/kubevela/velaux/blob/main/docs/apidoc/swagger.json) in the ```velaux``` repo.

# Usage
First, create a ```Configuration``` object to contain  information about the requests, such as access_token and base URL to send requests to

After creating the ```Configuration``` object, To use most of the SDK features, an access token is needed. To get an access token, log in and the response will contain access token. Then, set the ```access_token``` field in the ```Configuration``` object mentioned above.

Then, most of the SDK functionalities can be used after setting the access token, expected input formats for SDK functions can be found in the ```typescript/apis``` direcotry and tracing the type definition of the paramters of desired SDK function.

Example code to log in and list users:


```typescript
import { Configuration } from './typescript/runtime';
import { AuthenticationApi, LoginRequest } from './typescript/AuthenticationApi';
import { UsersApi } from './typescript/UsersApi';




const configuration = new Configuration({
    basePath: 'http://127.0.0.1:8000',
})

const authAPI = new AuthenticationApi(configuration)
const userAPI = new UsersApi(configuration)

const loginRequestParam: LoginRequest = {
    body: {
        "username": "admin",
        "password": "VelaUX12345"
    }
}

const loginRes = await authAPI.logi(loginRequestParam);
configuration.accessToken = loginRes.accessToken;
const listUsersRes = await userAPI.listUser();
```

Another example to create an application. this example creates an application called ```testapplication``` among with a basic component

```typescript
import { Configuration } from './typescript/runtime';
import { AuthenticationApi, LoginRequest } from './typescript/AuthenticationApi';
import { UsersApi } from './typescript/UsersApi';




const configuration = new Configuration({
    basePath: 'http://127.0.0.1:8000',
})
const authAPI = new AuthenticationApi(configuration)
const userAPI = new UsersApi(configuration)
const applicationAPI = new ApplicationApi(configuration)


const loginRequestParam: LoginRequest = {
    body: {
        "username": "admin",
        "password": "VelaUX12345"
    }
}


const loginRes = await authAPI.logi(loginRequestParam);
configuration.accessToken = loginRes.accessToken;

const req = {
    "body": {
    "name": 'testapplication',  // has to be all lower case
    "project": 'default',
    "component": {
        "name": 'express-server',
        "componentType": 'webservice',
    },
    "icon": 'https://www.svgrepo.com/show/513758/bookmark-check.svg',
    }
}
const res = await applicationAPI.createApplication(req)
console.log(res)


```

For more example code of using the SDK, please visit  https://github.com/kubevela-contrib/velaux-typescript-sdk/tree/main/examples

---
_Source: https://npm.io/package/velaux-typescript-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
