Skip to content

Commit

Permalink
Auto-generated SDK v1.0.0-beta17
Browse files Browse the repository at this point in the history
  • Loading branch information
dahu33 committed Mar 14, 2024
1 parent d9b943d commit a3870fc
Show file tree
Hide file tree
Showing 14 changed files with 1,393 additions and 820 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

env:
# Go / Node / PostgreSQL version to use in the CI
NODE_VER: "18"
NODE_VER: "20"

jobs:
generate:
Expand All @@ -36,11 +36,11 @@ jobs:
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "${{ env.NODE_VER }}"
registry-url: https://registry.npmjs.org/
Expand Down
2 changes: 1 addition & 1 deletion .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.1
7.4.0
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## @curvegrid/multibaas-sdk@1.0.0-beta16
## @curvegrid/multibaas-sdk@1.0.0-beta17

This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:

Expand All @@ -15,7 +15,7 @@ Module system
* CommonJS
* ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html))

### Building

Expand All @@ -27,7 +27,7 @@ npm run build

### Publishing

First build the package then run ```npm publish```
First build the package then run `npm publish`

### Consuming

Expand All @@ -36,10 +36,11 @@ navigate to the folder of your consuming project and run one of the following co
_published:_

```
npm install @curvegrid/[email protected]beta16 --save
npm install @curvegrid/[email protected]beta17 --save
```

_unPublished (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE --save
```
1,667 changes: 1,230 additions & 437 deletions api.ts

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';

export const BASE_PATH = 'https://your_deployment.multibaas.com/api/v0'.replace(/\/+$/, '');
Expand All @@ -38,7 +38,7 @@ export const COLLECTION_FORMATS = {
*/
export interface RequestArgs {
url: string;
options: AxiosRequestConfig;
options: RawAxiosRequestConfig;
}

/**
Expand All @@ -56,7 +56,7 @@ export class BaseAPI {
) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath || this.basePath;
this.basePath = configuration.basePath ?? basePath;
}
}
}
Expand All @@ -73,3 +73,16 @@ export class RequiredError extends Error {
this.name = 'RequiredError';
}
}

interface ServerMap {
[key: string]: {
url: string;
description: string;
}[];
}

/**
*
* @export
*/
export const operationServerMap: ServerMap = {};
2 changes: 1 addition & 1 deletion common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const createRequestFunction = function (
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {
...axiosArgs.options,
url: (configuration?.basePath || axios.defaults.baseURL || basePath) + axiosArgs.url
url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url
};
return axios.request<T, R>(axiosRequestArgs);
};
Expand Down
9 changes: 9 additions & 0 deletions configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ConfigurationParameters {
| ((name?: string, scopes?: string[]) => string)
| ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
serverIndex?: number;
baseOptions?: any;
formDataCtor?: new () => any;
}
Expand Down Expand Up @@ -65,6 +66,13 @@ export class Configuration {
* @memberof Configuration
*/
basePath?: string;
/**
* override server index
*
* @type {number}
* @memberof Configuration
*/
serverIndex?: number;
/**
* base options for axios calls
*
Expand All @@ -87,6 +95,7 @@ export class Configuration {
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
Expand Down
7 changes: 5 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# MultiBaas Typescript SDK example

To run this code example you will first need to [generate an API key](https://docs.curvegrid.com/multibaas/api/generate-api-keys/) in the `DApp User` group for your MultiBaas deployment.
To run this code example you will first need to [generate an API key](https://docs.curvegrid.com/multibaas/api/generate-api-keys/) in the `DApp User` group for your MultiBaas deployment.

Once you have generated an API key you can export the key and the MultiBaas deployment URL into environment variables. Example:

```sh
export MB_BASE_URL="your_deployment.multibaas.com"
export MB_BASE_URL="https://your_deployment.multibaas.com"
export MB_API_KEY="secret"
```

Install the dependencies:

```sh
npm install
```

Run the example script:

```sh
npm run start
```
Loading

0 comments on commit a3870fc

Please sign in to comment.