@loopstack/hub-client 0.13.0 → 0.13.1

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/base.ts CHANGED
@@ -5,31 +5,29 @@
5
5
  * Loopstack Hub Documentation
6
6
  *
7
7
  * The version of the OpenAPI document: 1.0
8
- *
8
+ *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
11
  * https://openapi-generator.tech
12
12
  * Do not edit the class manually.
13
13
  */
14
-
15
-
16
- import type { Configuration } from './configuration';
17
14
  // Some imports not used depending on template conditions
18
15
  // @ts-ignore
19
- import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
16
+ import type { AxiosInstance, AxiosPromise, RawAxiosRequestConfig } from 'axios';
20
17
  import globalAxios from 'axios';
18
+ import type { Configuration } from './configuration';
21
19
 
22
- export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
20
+ export const BASE_PATH = 'http://localhost'.replace(/\/+$/, '');
23
21
 
24
22
  /**
25
23
  *
26
24
  * @export
27
25
  */
28
26
  export const COLLECTION_FORMATS = {
29
- csv: ",",
30
- ssv: " ",
31
- tsv: "\t",
32
- pipes: "|",
27
+ csv: ',',
28
+ ssv: ' ',
29
+ tsv: '\t',
30
+ pipes: '|',
33
31
  };
34
32
 
35
33
  /**
@@ -38,8 +36,8 @@ export const COLLECTION_FORMATS = {
38
36
  * @interface RequestArgs
39
37
  */
40
38
  export interface RequestArgs {
41
- url: string;
42
- options: RawAxiosRequestConfig;
39
+ url: string;
40
+ options: RawAxiosRequestConfig;
43
41
  }
44
42
 
45
43
  /**
@@ -48,15 +46,19 @@ export interface RequestArgs {
48
46
  * @class BaseAPI
49
47
  */
50
48
  export class BaseAPI {
51
- protected configuration: Configuration | undefined;
49
+ protected configuration: Configuration | undefined;
52
50
 
53
- constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
54
- if (configuration) {
55
- this.configuration = configuration;
56
- this.basePath = configuration.basePath ?? basePath;
57
- }
51
+ constructor(
52
+ configuration?: Configuration,
53
+ protected basePath: string = BASE_PATH,
54
+ protected axios: AxiosInstance = globalAxios,
55
+ ) {
56
+ if (configuration) {
57
+ this.configuration = configuration;
58
+ this.basePath = configuration.basePath ?? basePath;
58
59
  }
59
- };
60
+ }
61
+ }
60
62
 
61
63
  /**
62
64
  *
@@ -65,22 +67,24 @@ export class BaseAPI {
65
67
  * @extends {Error}
66
68
  */
67
69
  export class RequiredError extends Error {
68
- constructor(public field: string, msg?: string) {
69
- super(msg);
70
- this.name = "RequiredError"
71
- }
70
+ constructor(
71
+ public field: string,
72
+ msg?: string,
73
+ ) {
74
+ super(msg);
75
+ this.name = 'RequiredError';
76
+ }
72
77
  }
73
78
 
74
79
  interface ServerMap {
75
- [key: string]: {
76
- url: string,
77
- description: string,
78
- }[];
80
+ [key: string]: {
81
+ url: string;
82
+ description: string;
83
+ }[];
79
84
  }
80
85
 
81
86
  /**
82
87
  *
83
88
  * @export
84
89
  */
85
- export const operationServerMap: ServerMap = {
86
- }
90
+ export const operationServerMap: ServerMap = {};
package/common.ts CHANGED
@@ -5,24 +5,22 @@
5
5
  * Loopstack Hub Documentation
6
6
  *
7
7
  * The version of the OpenAPI document: 1.0
8
- *
8
+ *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
11
  * https://openapi-generator.tech
12
12
  * Do not edit the class manually.
13
13
  */
14
-
15
-
16
- import type { Configuration } from "./configuration";
17
- import type { RequestArgs } from "./base";
18
14
  import type { AxiosInstance, AxiosResponse } from 'axios';
19
- import { RequiredError } from "./base";
15
+ import type { RequestArgs } from './base';
16
+ import { RequiredError } from './base';
17
+ import type { Configuration } from './configuration';
20
18
 
21
19
  /**
22
20
  *
23
21
  * @export
24
22
  */
25
- export const DUMMY_BASE_URL = 'https://example.com'
23
+ export const DUMMY_BASE_URL = 'https://example.com';
26
24
 
27
25
  /**
28
26
  *
@@ -30,80 +28,88 @@ export const DUMMY_BASE_URL = 'https://example.com'
30
28
  * @export
31
29
  */
32
30
  export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
33
- if (paramValue === null || paramValue === undefined) {
34
- throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
35
- }
36
- }
31
+ if (paramValue === null || paramValue === undefined) {
32
+ throw new RequiredError(
33
+ paramName,
34
+ `Required parameter ${paramName} was null or undefined when calling ${functionName}.`,
35
+ );
36
+ }
37
+ };
37
38
 
38
39
  /**
39
40
  *
40
41
  * @export
41
42
  */
42
43
  export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
43
- if (configuration && configuration.apiKey) {
44
- const localVarApiKeyValue = typeof configuration.apiKey === 'function'
45
- ? await configuration.apiKey(keyParamName)
46
- : await configuration.apiKey;
47
- object[keyParamName] = localVarApiKeyValue;
48
- }
49
- }
44
+ if (configuration && configuration.apiKey) {
45
+ const localVarApiKeyValue =
46
+ typeof configuration.apiKey === 'function'
47
+ ? await configuration.apiKey(keyParamName)
48
+ : await configuration.apiKey;
49
+ object[keyParamName] = localVarApiKeyValue;
50
+ }
51
+ };
50
52
 
51
53
  /**
52
54
  *
53
55
  * @export
54
56
  */
55
57
  export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
56
- if (configuration && (configuration.username || configuration.password)) {
57
- object["auth"] = { username: configuration.username, password: configuration.password };
58
- }
59
- }
58
+ if (configuration && (configuration.username || configuration.password)) {
59
+ object['auth'] = { username: configuration.username, password: configuration.password };
60
+ }
61
+ };
60
62
 
61
63
  /**
62
64
  *
63
65
  * @export
64
66
  */
65
67
  export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
66
- if (configuration && configuration.accessToken) {
67
- const accessToken = typeof configuration.accessToken === 'function'
68
- ? await configuration.accessToken()
69
- : await configuration.accessToken;
70
- object["Authorization"] = "Bearer " + accessToken;
71
- }
72
- }
68
+ if (configuration && configuration.accessToken) {
69
+ const accessToken =
70
+ typeof configuration.accessToken === 'function'
71
+ ? await configuration.accessToken()
72
+ : await configuration.accessToken;
73
+ object['Authorization'] = 'Bearer ' + accessToken;
74
+ }
75
+ };
73
76
 
74
77
  /**
75
78
  *
76
79
  * @export
77
80
  */
78
- export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
79
- if (configuration && configuration.accessToken) {
80
- const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
81
- ? await configuration.accessToken(name, scopes)
82
- : await configuration.accessToken;
83
- object["Authorization"] = "Bearer " + localVarAccessTokenValue;
84
- }
85
- }
81
+ export const setOAuthToObject = async function (
82
+ object: any,
83
+ name: string,
84
+ scopes: string[],
85
+ configuration?: Configuration,
86
+ ) {
87
+ if (configuration && configuration.accessToken) {
88
+ const localVarAccessTokenValue =
89
+ typeof configuration.accessToken === 'function'
90
+ ? await configuration.accessToken(name, scopes)
91
+ : await configuration.accessToken;
92
+ object['Authorization'] = 'Bearer ' + localVarAccessTokenValue;
93
+ }
94
+ };
86
95
 
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
- }
96
+ function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ''): void {
97
+ if (parameter == null) return;
98
+ if (typeof parameter === 'object') {
99
+ if (Array.isArray(parameter)) {
100
+ (parameter as any[]).forEach((item) => setFlattenedQueryParams(urlSearchParams, item, key));
101
+ } else {
102
+ Object.keys(parameter).forEach((currentKey) =>
103
+ setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`),
104
+ );
105
+ }
106
+ } else {
107
+ if (urlSearchParams.has(key)) {
108
+ urlSearchParams.append(key, parameter);
109
+ } else {
110
+ urlSearchParams.set(key, parameter);
106
111
  }
112
+ }
107
113
  }
108
114
 
109
115
  /**
@@ -111,40 +117,47 @@ function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: an
111
117
  * @export
112
118
  */
113
119
  export const setSearchParams = function (url: URL, ...objects: any[]) {
114
- const searchParams = new URLSearchParams(url.search);
115
- setFlattenedQueryParams(searchParams, objects);
116
- url.search = searchParams.toString();
117
- }
120
+ const searchParams = new URLSearchParams(url.search);
121
+ setFlattenedQueryParams(searchParams, objects);
122
+ url.search = searchParams.toString();
123
+ };
118
124
 
119
125
  /**
120
126
  *
121
127
  * @export
122
128
  */
123
129
  export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
124
- const nonString = typeof value !== 'string';
125
- const needsSerialization = nonString && configuration && configuration.isJsonMime
126
- ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
127
- : nonString;
128
- return needsSerialization
129
- ? JSON.stringify(value !== undefined ? value : {})
130
- : (value || "");
131
- }
130
+ const nonString = typeof value !== 'string';
131
+ const needsSerialization =
132
+ nonString && configuration && configuration.isJsonMime
133
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
134
+ : nonString;
135
+ return needsSerialization ? JSON.stringify(value !== undefined ? value : {}) : value || '';
136
+ };
132
137
 
133
138
  /**
134
139
  *
135
140
  * @export
136
141
  */
137
142
  export const toPathString = function (url: URL) {
138
- return url.pathname + url.search + url.hash
139
- }
143
+ return url.pathname + url.search + url.hash;
144
+ };
140
145
 
141
146
  /**
142
147
  *
143
148
  * @export
144
149
  */
145
- export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
146
- return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
147
- const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
148
- return axios.request<T, R>(axiosRequestArgs);
150
+ export const createRequestFunction = function (
151
+ axiosArgs: RequestArgs,
152
+ globalAxios: AxiosInstance,
153
+ BASE_PATH: string,
154
+ configuration?: Configuration,
155
+ ) {
156
+ return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
157
+ const axiosRequestArgs = {
158
+ ...axiosArgs.options,
159
+ url: (axios.defaults.baseURL ? '' : (configuration?.basePath ?? basePath)) + axiosArgs.url,
149
160
  };
150
- }
161
+ return axios.request<T, R>(axiosRequestArgs);
162
+ };
163
+ };
package/configuration.ts CHANGED
@@ -5,112 +5,119 @@
5
5
  * Loopstack Hub Documentation
6
6
  *
7
7
  * The version of the OpenAPI document: 1.0
8
- *
8
+ *
9
9
  *
10
10
  * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
11
  * https://openapi-generator.tech
12
12
  * Do not edit the class manually.
13
13
  */
14
14
 
15
-
16
15
  export interface ConfigurationParameters {
17
- apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
18
- username?: string;
19
- password?: string;
20
- accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
21
- basePath?: string;
22
- serverIndex?: number;
23
- baseOptions?: any;
24
- formDataCtor?: new () => any;
16
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
17
+ username?: string;
18
+ password?: string;
19
+ accessToken?:
20
+ | string
21
+ | Promise<string>
22
+ | ((name?: string, scopes?: string[]) => string)
23
+ | ((name?: string, scopes?: string[]) => Promise<string>);
24
+ basePath?: string;
25
+ serverIndex?: number;
26
+ baseOptions?: any;
27
+ formDataCtor?: new () => any;
25
28
  }
26
29
 
27
30
  export class Configuration {
28
- /**
29
- * parameter for apiKey security
30
- * @param name security name
31
- * @memberof Configuration
32
- */
33
- apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
34
- /**
35
- * parameter for basic security
36
- *
37
- * @type {string}
38
- * @memberof Configuration
39
- */
40
- username?: string;
41
- /**
42
- * parameter for basic security
43
- *
44
- * @type {string}
45
- * @memberof Configuration
46
- */
47
- password?: string;
48
- /**
49
- * parameter for oauth2 security
50
- * @param name security name
51
- * @param scopes oauth2 scope
52
- * @memberof Configuration
53
- */
54
- accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
55
- /**
56
- * override base path
57
- *
58
- * @type {string}
59
- * @memberof Configuration
60
- */
61
- basePath?: string;
62
- /**
63
- * override server index
64
- *
65
- * @type {number}
66
- * @memberof Configuration
67
- */
68
- serverIndex?: number;
69
- /**
70
- * base options for axios calls
71
- *
72
- * @type {any}
73
- * @memberof Configuration
74
- */
75
- baseOptions?: any;
76
- /**
77
- * The FormData constructor that will be used to create multipart form data
78
- * requests. You can inject this here so that execution environments that
79
- * do not support the FormData class can still run the generated client.
80
- *
81
- * @type {new () => FormData}
82
- */
83
- formDataCtor?: new () => any;
31
+ /**
32
+ * parameter for apiKey security
33
+ * @param name security name
34
+ * @memberof Configuration
35
+ */
36
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
37
+ /**
38
+ * parameter for basic security
39
+ *
40
+ * @type {string}
41
+ * @memberof Configuration
42
+ */
43
+ username?: string;
44
+ /**
45
+ * parameter for basic security
46
+ *
47
+ * @type {string}
48
+ * @memberof Configuration
49
+ */
50
+ password?: string;
51
+ /**
52
+ * parameter for oauth2 security
53
+ * @param name security name
54
+ * @param scopes oauth2 scope
55
+ * @memberof Configuration
56
+ */
57
+ accessToken?:
58
+ | string
59
+ | Promise<string>
60
+ | ((name?: string, scopes?: string[]) => string)
61
+ | ((name?: string, scopes?: string[]) => Promise<string>);
62
+ /**
63
+ * override base path
64
+ *
65
+ * @type {string}
66
+ * @memberof Configuration
67
+ */
68
+ basePath?: string;
69
+ /**
70
+ * override server index
71
+ *
72
+ * @type {number}
73
+ * @memberof Configuration
74
+ */
75
+ serverIndex?: number;
76
+ /**
77
+ * base options for axios calls
78
+ *
79
+ * @type {any}
80
+ * @memberof Configuration
81
+ */
82
+ baseOptions?: any;
83
+ /**
84
+ * The FormData constructor that will be used to create multipart form data
85
+ * requests. You can inject this here so that execution environments that
86
+ * do not support the FormData class can still run the generated client.
87
+ *
88
+ * @type {new () => FormData}
89
+ */
90
+ formDataCtor?: new () => any;
84
91
 
85
- constructor(param: ConfigurationParameters = {}) {
86
- this.apiKey = param.apiKey;
87
- this.username = param.username;
88
- this.password = param.password;
89
- this.accessToken = param.accessToken;
90
- this.basePath = param.basePath;
91
- this.serverIndex = param.serverIndex;
92
- this.baseOptions = {
93
- headers: {
94
- ...param.baseOptions?.headers,
95
- 'User-Agent': "OpenAPI-Generator/0.0.6/typescript-axios"
96
- },
97
- ...param.baseOptions
98
- };
99
- this.formDataCtor = param.formDataCtor;
100
- }
92
+ constructor(param: ConfigurationParameters = {}) {
93
+ this.apiKey = param.apiKey;
94
+ this.username = param.username;
95
+ this.password = param.password;
96
+ this.accessToken = param.accessToken;
97
+ this.basePath = param.basePath;
98
+ this.serverIndex = param.serverIndex;
99
+ this.baseOptions = {
100
+ headers: {
101
+ ...param.baseOptions?.headers,
102
+ 'User-Agent': 'OpenAPI-Generator/1.0/typescript-axios',
103
+ },
104
+ ...param.baseOptions,
105
+ };
106
+ this.formDataCtor = param.formDataCtor;
107
+ }
101
108
 
102
- /**
103
- * Check if the given MIME is a JSON MIME.
104
- * JSON MIME examples:
105
- * application/json
106
- * application/json; charset=UTF8
107
- * APPLICATION/JSON
108
- * application/vnd.company+json
109
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
110
- * @return True if the given MIME is JSON, false otherwise.
111
- */
112
- public isJsonMime(mime: string): boolean {
113
- const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
114
- return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
115
- }
109
+ /**
110
+ * Check if the given MIME is a JSON MIME.
111
+ * JSON MIME examples:
112
+ * application/json
113
+ * application/json; charset=UTF8
114
+ * APPLICATION/JSON
115
+ * application/vnd.company+json
116
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
117
+ * @return True if the given MIME is JSON, false otherwise.
118
+ */
119
+ public isJsonMime(mime: string): boolean {
120
+ const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
121
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
122
+ }
116
123
  }