@cosmotech/api-ts 3.1.0-dev → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/api.ts +1781 -1900
- package/base.ts +21 -6
- package/common.ts +29 -17
- package/configuration.ts +10 -1
- package/dist/api.d.ts +1069 -1152
- package/dist/api.js +3650 -3847
- package/dist/base.d.ts +16 -5
- package/dist/base.js +12 -6
- package/dist/common.d.ts +5 -5
- package/dist/common.js +47 -28
- package/dist/configuration.d.ts +9 -1
- package/dist/configuration.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -3
- package/index.ts +1 -1
- package/package.json +8 -4
- package/tsconfig.json +1 -1
package/base.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Cosmo Tech Platform API
|
|
5
5
|
* Cosmo Tech Platform API
|
|
6
6
|
*
|
|
7
|
-
* The version of the OpenAPI document: 3.
|
|
7
|
+
* The version of the OpenAPI document: 3.2.0
|
|
8
8
|
* Contact: platform@cosmotech.com
|
|
9
9
|
*
|
|
10
10
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
import { Configuration } from
|
|
16
|
+
import type { Configuration } from './configuration';
|
|
17
17
|
// Some imports not used depending on template conditions
|
|
18
18
|
// @ts-ignore
|
|
19
|
-
import
|
|
19
|
+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
20
|
+
import globalAxios from 'axios';
|
|
20
21
|
|
|
21
22
|
export const BASE_PATH = "https://dev.api.cosmotech.com".replace(/\/+$/, "");
|
|
22
23
|
|
|
@@ -38,7 +39,7 @@ export const COLLECTION_FORMATS = {
|
|
|
38
39
|
*/
|
|
39
40
|
export interface RequestArgs {
|
|
40
41
|
url: string;
|
|
41
|
-
options:
|
|
42
|
+
options: RawAxiosRequestConfig;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -52,7 +53,7 @@ export class BaseAPI {
|
|
|
52
53
|
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
53
54
|
if (configuration) {
|
|
54
55
|
this.configuration = configuration;
|
|
55
|
-
this.basePath = configuration.basePath
|
|
56
|
+
this.basePath = configuration.basePath ?? basePath;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -64,8 +65,22 @@ export class BaseAPI {
|
|
|
64
65
|
* @extends {Error}
|
|
65
66
|
*/
|
|
66
67
|
export class RequiredError extends Error {
|
|
67
|
-
name: "RequiredError" = "RequiredError";
|
|
68
68
|
constructor(public field: string, msg?: string) {
|
|
69
69
|
super(msg);
|
|
70
|
+
this.name = "RequiredError"
|
|
70
71
|
}
|
|
71
72
|
}
|
|
73
|
+
|
|
74
|
+
interface ServerMap {
|
|
75
|
+
[key: string]: {
|
|
76
|
+
url: string,
|
|
77
|
+
description: string,
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @export
|
|
84
|
+
*/
|
|
85
|
+
export const operationServerMap: ServerMap = {
|
|
86
|
+
}
|
package/common.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Cosmo Tech Platform API
|
|
5
5
|
* Cosmo Tech Platform API
|
|
6
6
|
*
|
|
7
|
-
* The version of the OpenAPI document: 3.
|
|
7
|
+
* The version of the OpenAPI document: 3.2.0
|
|
8
8
|
* Contact: platform@cosmotech.com
|
|
9
9
|
*
|
|
10
10
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
import { Configuration } from "./configuration";
|
|
17
|
-
import {
|
|
18
|
-
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
16
|
+
import type { Configuration } from "./configuration";
|
|
17
|
+
import type { RequestArgs } from "./base";
|
|
18
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
19
|
+
import { RequiredError } from "./base";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
*
|
|
@@ -83,24 +84,35 @@ export const setOAuthToObject = async function (object: any, name: string, scope
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
|
88
|
+
if (parameter == null) return;
|
|
89
|
+
if (typeof parameter === "object") {
|
|
90
|
+
if (Array.isArray(parameter)) {
|
|
91
|
+
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
Object.keys(parameter).forEach(currentKey =>
|
|
95
|
+
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (urlSearchParams.has(key)) {
|
|
101
|
+
urlSearchParams.append(key, parameter);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
urlSearchParams.set(key, parameter);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
86
109
|
/**
|
|
87
110
|
*
|
|
88
111
|
* @export
|
|
89
112
|
*/
|
|
90
113
|
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
|
91
114
|
const searchParams = new URLSearchParams(url.search);
|
|
92
|
-
|
|
93
|
-
for (const key in object) {
|
|
94
|
-
if (Array.isArray(object[key])) {
|
|
95
|
-
searchParams.delete(key);
|
|
96
|
-
for (const item of object[key]) {
|
|
97
|
-
searchParams.append(key, item);
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
searchParams.set(key, object[key]);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
115
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
104
116
|
url.search = searchParams.toString();
|
|
105
117
|
}
|
|
106
118
|
|
|
@@ -132,7 +144,7 @@ export const toPathString = function (url: URL) {
|
|
|
132
144
|
*/
|
|
133
145
|
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
|
134
146
|
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
135
|
-
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath
|
|
147
|
+
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
|
|
136
148
|
return axios.request<T, R>(axiosRequestArgs);
|
|
137
149
|
};
|
|
138
150
|
}
|
package/configuration.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Cosmo Tech Platform API
|
|
5
5
|
* Cosmo Tech Platform API
|
|
6
6
|
*
|
|
7
|
-
* The version of the OpenAPI document: 3.
|
|
7
|
+
* The version of the OpenAPI document: 3.2.0
|
|
8
8
|
* Contact: platform@cosmotech.com
|
|
9
9
|
*
|
|
10
10
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -19,6 +19,7 @@ export interface ConfigurationParameters {
|
|
|
19
19
|
password?: string;
|
|
20
20
|
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
21
21
|
basePath?: string;
|
|
22
|
+
serverIndex?: number;
|
|
22
23
|
baseOptions?: any;
|
|
23
24
|
formDataCtor?: new () => any;
|
|
24
25
|
}
|
|
@@ -58,6 +59,13 @@ export class Configuration {
|
|
|
58
59
|
* @memberof Configuration
|
|
59
60
|
*/
|
|
60
61
|
basePath?: string;
|
|
62
|
+
/**
|
|
63
|
+
* override server index
|
|
64
|
+
*
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @memberof Configuration
|
|
67
|
+
*/
|
|
68
|
+
serverIndex?: number;
|
|
61
69
|
/**
|
|
62
70
|
* base options for axios calls
|
|
63
71
|
*
|
|
@@ -80,6 +88,7 @@ export class Configuration {
|
|
|
80
88
|
this.password = param.password;
|
|
81
89
|
this.accessToken = param.accessToken;
|
|
82
90
|
this.basePath = param.basePath;
|
|
91
|
+
this.serverIndex = param.serverIndex;
|
|
83
92
|
this.baseOptions = param.baseOptions;
|
|
84
93
|
this.formDataCtor = param.formDataCtor;
|
|
85
94
|
}
|