Skip to content

Commit 71a887f

Browse files
committed
Update client
1 parent ba50f32 commit 71a887f

File tree

5 files changed

+101
-41
lines changed

5 files changed

+101
-41
lines changed

.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.3.0-SNAPSHOT
1+
7.5.0-SNAPSHOT

api.ts

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515

1616
import type { Configuration } from './configuration';
17-
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
17+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
1818
import globalAxios from 'axios';
1919
// Some imports not used depending on template conditions
2020
// @ts-ignore
2121
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
2222
import type { RequestArgs } from './base';
2323
// @ts-ignore
24-
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError } from './base';
24+
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';
2525

2626
/**
2727
*
@@ -1131,10 +1131,10 @@ export interface Session {
11311131
'client'?: WebClient;
11321132
/**
11331133
* The custom attributes.
1134-
* @type {{ [key: string]: any | undefined; }}
1134+
* @type {{ [key: string]: any | undefined | null; }}
11351135
* @memberof Session
11361136
*/
1137-
'attributes'?: { [key: string]: any | undefined; };
1137+
'attributes'?: { [key: string]: any | undefined | null; };
11381138
/**
11391139
*
11401140
* @type {SessionStatistics}
@@ -1721,7 +1721,7 @@ export const ExportApiAxiosParamCreator = function (configuration?: Configuratio
17211721
* @param {*} [options] Override http request option.
17221722
* @throws {RequiredError}
17231723
*/
1724-
exportEvents: async (start?: number, end?: number, pageSize?: number, cursor?: string, events?: Array<EventType>, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
1724+
exportEvents: async (start?: number, end?: number, pageSize?: number, cursor?: string, events?: Array<EventType>, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
17251725
const localVarPath = `/events`;
17261726
// use dummy base URL string because the URL constructor only accepts absolute URLs.
17271727
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@@ -1777,7 +1777,7 @@ export const ExportApiAxiosParamCreator = function (configuration?: Configuratio
17771777
* @param {*} [options] Override http request option.
17781778
* @throws {RequiredError}
17791779
*/
1780-
exportSessions: async (start?: number, end?: number, pageSize?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
1780+
exportSessions: async (start?: number, end?: number, pageSize?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
17811781
const localVarPath = `/session`;
17821782
// use dummy base URL string because the URL constructor only accepts absolute URLs.
17831783
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@@ -1829,7 +1829,7 @@ export const ExportApiAxiosParamCreator = function (configuration?: Configuratio
18291829
* @param {*} [options] Override http request option.
18301830
* @throws {RequiredError}
18311831
*/
1832-
exportUsers: async (start?: number, end?: number, pageSize?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
1832+
exportUsers: async (start?: number, end?: number, pageSize?: number, cursor?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
18331833
const localVarPath = `/user`;
18341834
// use dummy base URL string because the URL constructor only accepts absolute URLs.
18351835
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
@@ -1892,9 +1892,11 @@ export const ExportApiFp = function(configuration?: Configuration) {
18921892
* @param {*} [options] Override http request option.
18931893
* @throws {RequiredError}
18941894
*/
1895-
async exportEvents(start?: number, end?: number, pageSize?: number, cursor?: string, events?: Array<EventType>, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EventResponse>> {
1895+
async exportEvents(start?: number, end?: number, pageSize?: number, cursor?: string, events?: Array<EventType>, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<EventResponse>> {
18961896
const localVarAxiosArgs = await localVarAxiosParamCreator.exportEvents(start, end, pageSize, cursor, events, options);
1897-
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1897+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
1898+
const localVarOperationServerBasePath = operationServerMap['ExportApi.exportEvents']?.[localVarOperationServerIndex]?.url;
1899+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
18981900
},
18991901
/**
19001902
*
@@ -1905,9 +1907,11 @@ export const ExportApiFp = function(configuration?: Configuration) {
19051907
* @param {*} [options] Override http request option.
19061908
* @throws {RequiredError}
19071909
*/
1908-
async exportSessions(start?: number, end?: number, pageSize?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SessionResponse>> {
1910+
async exportSessions(start?: number, end?: number, pageSize?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<SessionResponse>> {
19091911
const localVarAxiosArgs = await localVarAxiosParamCreator.exportSessions(start, end, pageSize, cursor, options);
1910-
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1912+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
1913+
const localVarOperationServerBasePath = operationServerMap['ExportApi.exportSessions']?.[localVarOperationServerIndex]?.url;
1914+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19111915
},
19121916
/**
19131917
*
@@ -1918,9 +1922,11 @@ export const ExportApiFp = function(configuration?: Configuration) {
19181922
* @param {*} [options] Override http request option.
19191923
* @throws {RequiredError}
19201924
*/
1921-
async exportUsers(start?: number, end?: number, pageSize?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserResponse>> {
1925+
async exportUsers(start?: number, end?: number, pageSize?: number, cursor?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<UserResponse>> {
19221926
const localVarAxiosArgs = await localVarAxiosParamCreator.exportUsers(start, end, pageSize, cursor, options);
1923-
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
1927+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
1928+
const localVarOperationServerBasePath = operationServerMap['ExportApi.exportUsers']?.[localVarOperationServerIndex]?.url;
1929+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
19241930
},
19251931
}
19261932
};
@@ -1934,40 +1940,30 @@ export const ExportApiFactory = function (configuration?: Configuration, basePat
19341940
return {
19351941
/**
19361942
*
1937-
* @param {number} [start]
1938-
* @param {number} [end]
1939-
* @param {number} [pageSize]
1940-
* @param {string} [cursor]
1941-
* @param {Array<EventType>} [events]
1943+
* @param {ExportApiExportEventsRequest} requestParameters Request parameters.
19421944
* @param {*} [options] Override http request option.
19431945
* @throws {RequiredError}
19441946
*/
1945-
exportEvents(start?: number, end?: number, pageSize?: number, cursor?: string, events?: Array<EventType>, options?: any): AxiosPromise<EventResponse> {
1946-
return localVarFp.exportEvents(start, end, pageSize, cursor, events, options).then((request) => request(axios, basePath));
1947+
exportEvents(requestParameters: ExportApiExportEventsRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<EventResponse> {
1948+
return localVarFp.exportEvents(requestParameters.start, requestParameters.end, requestParameters.pageSize, requestParameters.cursor, requestParameters.events, options).then((request) => request(axios, basePath));
19471949
},
19481950
/**
19491951
*
1950-
* @param {number} [start]
1951-
* @param {number} [end]
1952-
* @param {number} [pageSize]
1953-
* @param {string} [cursor]
1952+
* @param {ExportApiExportSessionsRequest} requestParameters Request parameters.
19541953
* @param {*} [options] Override http request option.
19551954
* @throws {RequiredError}
19561955
*/
1957-
exportSessions(start?: number, end?: number, pageSize?: number, cursor?: string, options?: any): AxiosPromise<SessionResponse> {
1958-
return localVarFp.exportSessions(start, end, pageSize, cursor, options).then((request) => request(axios, basePath));
1956+
exportSessions(requestParameters: ExportApiExportSessionsRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<SessionResponse> {
1957+
return localVarFp.exportSessions(requestParameters.start, requestParameters.end, requestParameters.pageSize, requestParameters.cursor, options).then((request) => request(axios, basePath));
19591958
},
19601959
/**
19611960
*
1962-
* @param {number} [start]
1963-
* @param {number} [end]
1964-
* @param {number} [pageSize]
1965-
* @param {string} [cursor]
1961+
* @param {ExportApiExportUsersRequest} requestParameters Request parameters.
19661962
* @param {*} [options] Override http request option.
19671963
* @throws {RequiredError}
19681964
*/
1969-
exportUsers(start?: number, end?: number, pageSize?: number, cursor?: string, options?: any): AxiosPromise<UserResponse> {
1970-
return localVarFp.exportUsers(start, end, pageSize, cursor, options).then((request) => request(axios, basePath));
1965+
exportUsers(requestParameters: ExportApiExportUsersRequest = {}, options?: RawAxiosRequestConfig): AxiosPromise<UserResponse> {
1966+
return localVarFp.exportUsers(requestParameters.start, requestParameters.end, requestParameters.pageSize, requestParameters.cursor, options).then((request) => request(axios, basePath));
19711967
},
19721968
};
19731969
};
@@ -2098,7 +2094,7 @@ export class ExportApi extends BaseAPI {
20982094
* @throws {RequiredError}
20992095
* @memberof ExportApi
21002096
*/
2101-
public exportEvents(requestParameters: ExportApiExportEventsRequest = {}, options?: AxiosRequestConfig) {
2097+
public exportEvents(requestParameters: ExportApiExportEventsRequest = {}, options?: RawAxiosRequestConfig) {
21022098
return ExportApiFp(this.configuration).exportEvents(requestParameters.start, requestParameters.end, requestParameters.pageSize, requestParameters.cursor, requestParameters.events, options).then((request) => request(this.axios, this.basePath));
21032099
}
21042100

@@ -2109,7 +2105,7 @@ export class ExportApi extends BaseAPI {
21092105
* @throws {RequiredError}
21102106
* @memberof ExportApi
21112107
*/
2112-
public exportSessions(requestParameters: ExportApiExportSessionsRequest = {}, options?: AxiosRequestConfig) {
2108+
public exportSessions(requestParameters: ExportApiExportSessionsRequest = {}, options?: RawAxiosRequestConfig) {
21132109
return ExportApiFp(this.configuration).exportSessions(requestParameters.start, requestParameters.end, requestParameters.pageSize, requestParameters.cursor, options).then((request) => request(this.axios, this.basePath));
21142110
}
21152111

@@ -2120,9 +2116,10 @@ export class ExportApi extends BaseAPI {
21202116
* @throws {RequiredError}
21212117
* @memberof ExportApi
21222118
*/
2123-
public exportUsers(requestParameters: ExportApiExportUsersRequest = {}, options?: AxiosRequestConfig) {
2119+
public exportUsers(requestParameters: ExportApiExportUsersRequest = {}, options?: RawAxiosRequestConfig) {
21242120
return ExportApiFp(this.configuration).exportUsers(requestParameters.start, requestParameters.end, requestParameters.pageSize, requestParameters.cursor, options).then((request) => request(this.axios, this.basePath));
21252121
}
21262122
}
21272123

21282124

2125+

base.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import type { Configuration } from './configuration';
1717
// Some imports not used depending on template conditions
1818
// @ts-ignore
19-
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
19+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
2020
import globalAxios from 'axios';
2121

2222
export const BASE_PATH = "https://api.croct.io/export".replace(/\/+$/, "");
@@ -39,7 +39,7 @@ export const COLLECTION_FORMATS = {
3939
*/
4040
export interface RequestArgs {
4141
url: string;
42-
options: AxiosRequestConfig;
42+
options: RawAxiosRequestConfig;
4343
}
4444

4545
/**
@@ -53,7 +53,7 @@ export class BaseAPI {
5353
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
5454
if (configuration) {
5555
this.configuration = configuration;
56-
this.basePath = configuration.basePath || this.basePath;
56+
this.basePath = configuration.basePath ?? basePath;
5757
}
5858
}
5959
};
@@ -70,3 +70,17 @@ export class RequiredError extends Error {
7070
this.name = "RequiredError"
7171
}
7272
}
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+
}

common.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,50 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
126126
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
127127
: nonString;
128128
return needsSerialization
129-
? JSON.stringify(value !== undefined ? value : {})
129+
? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {})
130130
: (value || "");
131131
}
132132

133+
function convertMapsAndSetsToPlain(value: any): any {
134+
if (typeof Set === "undefined") return value;
135+
if (typeof Map === "undefined") return value;
136+
if (typeof value !== "object" || !value) {
137+
return value;
138+
}
139+
if (value instanceof Set) {
140+
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
141+
}
142+
if (value instanceof Map) {
143+
const entries: Array<[string, any]> = [];
144+
value.forEach((value: any, key: any) => {
145+
entries.push([key, convertMapsAndSetsToPlain(value)])
146+
});
147+
return objectFromEntries(entries);
148+
}
149+
if (Array.isArray(value)) {
150+
return value.map(it => convertMapsAndSetsToPlain(it));
151+
}
152+
return objectFromEntries(objectEntries(value)
153+
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
154+
}
155+
156+
/**
157+
* Ponyfill for Object.entries
158+
*/
159+
function objectEntries(object: Record<string, any>): Array<[string, any]> {
160+
return Object.keys(object).map(key => [key, object[key]]);
161+
}
162+
163+
/**
164+
* Ponyfill for Object.fromEntries
165+
*/
166+
function objectFromEntries(entries: any): Record<string, any> {
167+
return [...entries].reduce((object, [key, val]) => {
168+
object[key] = val;
169+
return object;
170+
}, {});
171+
}
172+
133173
/**
134174
*
135175
* @export
@@ -144,7 +184,7 @@ export const toPathString = function (url: URL) {
144184
*/
145185
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
146186
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
147-
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
187+
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
148188
return axios.request<T, R>(axiosRequestArgs);
149189
};
150190
}

configuration.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface ConfigurationParameters {
1919
password?: string;
2020
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
2121
basePath?: string;
22+
serverIndex?: number;
2223
baseOptions?: any;
2324
formDataCtor?: new () => any;
2425
}
@@ -58,6 +59,13 @@ export class Configuration {
5859
* @memberof Configuration
5960
*/
6061
basePath?: string;
62+
/**
63+
* override server index
64+
*
65+
* @type {number}
66+
* @memberof Configuration
67+
*/
68+
serverIndex?: number;
6169
/**
6270
* base options for axios calls
6371
*
@@ -80,6 +88,7 @@ export class Configuration {
8088
this.password = param.password;
8189
this.accessToken = param.accessToken;
8290
this.basePath = param.basePath;
91+
this.serverIndex = param.serverIndex;
8392
this.baseOptions = param.baseOptions;
8493
this.formDataCtor = param.formDataCtor;
8594
}

0 commit comments

Comments
 (0)