From 872de7453368e05b55fb9b5baec714b08a830a14 Mon Sep 17 00:00:00 2001 From: gaspard Date: Thu, 19 Sep 2024 17:12:31 +0200 Subject: [PATCH] chore: reset runtime file --- src/generated/runtime.ts | 331 +++++++++++++++++++++++---------------- 1 file changed, 193 insertions(+), 138 deletions(-) diff --git a/src/generated/runtime.ts b/src/generated/runtime.ts index e3fee4f86..a00b562fa 100644 --- a/src/generated/runtime.ts +++ b/src/generated/runtime.ts @@ -1,134 +1,161 @@ // tslint:disable /** - * Open Hospital API Documentation - * Open Hospital API Documentation + * OH 2.0 Api Documentation + * OH 2.0 Api Documentation + * + * The version of the OpenAPI document: 1.0 * - * The version of the OpenAPI document: 0.1.0 - * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ -import { Observable, of, Subscriber } from 'rxjs'; -import { ajax, AjaxRequest, AjaxResponse } from 'rxjs/ajax'; -import { map, concatMap } from 'rxjs/operators'; +import { Observable, of, Subscriber } from "rxjs"; +import { ajax, AjaxRequest, AjaxResponse } from "rxjs/ajax"; +import { map, concatMap } from "rxjs/operators"; -export const BASE_PATH = 'http://localhost:8080'.replace(/\/+$/, ''); +export const BASE_PATH = "https://oh2.open-hospital.org".replace(/\/+$/, ""); export interface ConfigurationParameters { - basePath?: string; // override base path - middleware?: Middleware[]; // middleware to apply before/after rxjs requests - username?: string; // parameter for basic security - password?: string; // parameter for basic security - apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + basePath?: string; // override base path + middleware?: Middleware[]; // middleware to apply before/after rxjs requests + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security } export class Configuration { - constructor(private configuration: ConfigurationParameters = {}) {} - - get basePath(): string { - return this.configuration.basePath ?? BASE_PATH; - } - - get middleware(): Middleware[] { - return this.configuration.middleware ?? []; - } - - get username(): string | undefined { - return this.configuration.username; - } - - get password(): string | undefined { - return this.configuration.password; - } - - get apiKey(): ((name: string) => string) | undefined { - const { apiKey } = this.configuration; - return apiKey ? (typeof apiKey === 'string' ? () => apiKey : apiKey) : undefined; - } - - get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { - const { accessToken } = this.configuration; - return accessToken ? (typeof accessToken === 'string' ? () => accessToken : accessToken) : undefined; - } + constructor(private configuration: ConfigurationParameters = {}) {} + + get basePath(): string { + return this.configuration.basePath ?? BASE_PATH; + } + + get middleware(): Middleware[] { + return this.configuration.middleware ?? []; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const { apiKey } = this.configuration; + return apiKey + ? typeof apiKey === "string" + ? () => apiKey + : apiKey + : undefined; + } + + get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + const { accessToken } = this.configuration; + return accessToken + ? typeof accessToken === "string" + ? () => accessToken + : accessToken + : undefined; + } } /** * This is the base class for all generated API classes. */ export class BaseAPI { - private middleware: Middleware[] = []; - - constructor(protected configuration = new Configuration()) { - this.middleware = configuration.middleware; - } - - withMiddleware = (middlewares: Middleware[]): this => { - const next = this.clone(); - next.middleware = next.middleware.concat(middlewares); - return next; + private middleware: Middleware[] = []; + + constructor(protected configuration = new Configuration()) { + this.middleware = configuration.middleware; + } + + withMiddleware = (middlewares: Middleware[]): this => { + const next = this.clone(); + next.middleware = next.middleware.concat(middlewares); + return next; + }; + + withPreMiddleware = (preMiddlewares: Array) => + this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); + + withPostMiddleware = (postMiddlewares: Array) => + this.withMiddleware(postMiddlewares.map((post) => ({ post }))); + + protected request(requestOpts: RequestOpts): Observable; + protected request( + requestOpts: RequestOpts, + responseOpts?: ResponseOpts + ): Observable>; + protected request( + requestOpts: RequestOpts, + responseOpts?: ResponseOpts + ): Observable> { + return this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( + map((res) => { + const { status, response } = res; + if (status >= 200 && status < 300) { + return responseOpts?.respone === "raw" ? res : response; + } + throw res; + }) + ); + } + + private createRequestArgs = ({ + url: baseUrl, + query, + method, + headers, + body, + responseType, + }: RequestOpts): RequestArgs => { + // only add the queryString to the URL if there are query parameters. + // this is done to avoid urls ending with a '?' character which buggy webservers + // do not handle correctly sometimes. + const url = `${this.configuration.basePath}${baseUrl}${ + query && Object.keys(query).length ? `?${queryString(query)}` : "" + }`; + + return { + url, + method, + headers, + body: body instanceof FormData ? body : JSON.stringify(body), + responseType: responseType ?? "json", }; - - withPreMiddleware = (preMiddlewares: Array) => - this.withMiddleware(preMiddlewares.map((pre) => ({ pre }))); - - withPostMiddleware = (postMiddlewares: Array) => - this.withMiddleware(postMiddlewares.map((post) => ({ post }))); - - protected request(requestOpts: RequestOpts): Observable - protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> - protected request(requestOpts: RequestOpts, responseOpts?: ResponseOpts): Observable> { - return this.rxjsRequest(this.createRequestArgs(requestOpts)).pipe( - map((res) => { - const { status, response } = res; - if (status >= 200 && status < 300) { - return responseOpts?.respone === 'raw' ? res : response; - } - throw res; + }; + + private rxjsRequest = (params: RequestArgs): Observable => + of(params).pipe( + map((request) => { + this.middleware + .filter((item) => item.pre) + .forEach((mw) => (request = mw.pre!(request))); + return request; + }), + concatMap((args) => + ajax(args).pipe( + map((response) => { + this.middleware + .filter((item) => item.post) + .forEach((mw) => (response = mw.post!(response))); + return response; }) + ) ); - } - - private createRequestArgs = ({ url: baseUrl, query, method, headers, body, responseType }: RequestOpts): RequestArgs => { - // only add the queryString to the URL if there are query parameters. - // this is done to avoid urls ending with a '?' character which buggy webservers - // do not handle correctly sometimes. - const url = `${this.configuration.basePath}${baseUrl}${query && Object.keys(query).length ? `?${queryString(query)}`: ''}`; - - return { - url, - method, - headers, - body: body instanceof FormData ? body : JSON.stringify(body), - responseType: responseType ?? 'json', - }; - } - - private rxjsRequest = (params: RequestArgs): Observable => - of(params).pipe( - map((request) => { - this.middleware.filter((item) => item.pre).forEach((mw) => (request = mw.pre!(request))); - return request; - }), - concatMap((args) => - ajax(args).pipe( - map((response) => { - this.middleware.filter((item) => item.post).forEach((mw) => (response = mw.post!(response))); - return response; - }) - ) - ) - ); - - /** - * Create a shallow clone of `this` by constructing a new instance - * and then shallow cloning data members. - */ - private clone = (): this => - Object.assign(Object.create(Object.getPrototypeOf(this)), this); + ); + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone = (): this => + Object.assign(Object.create(Object.getPrototypeOf(this)), this); } /** @@ -136,52 +163,68 @@ export class BaseAPI { * export for not being a breaking change */ export class RequiredError extends Error { - name: 'RequiredError' = 'RequiredError'; + name: "RequiredError" = "RequiredError"; } export const COLLECTION_FORMATS = { - csv: ',', - ssv: ' ', - tsv: '\t', - pipes: '|', + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", }; export type Json = any; -export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HttpMethod = + | "GET" + | "POST" + | "PUT" + | "PATCH" + | "DELETE" + | "OPTIONS" + | "HEAD"; export type HttpHeaders = { [key: string]: string }; -export type HttpQuery = Partial<{ [key: string]: string | number | null | boolean | Array }>; // partial is needed for strict mode +export type HttpQuery = Partial<{ + [key: string]: + | string + | number + | null + | boolean + | Array; +}>; // partial is needed for strict mode export type HttpBody = Json | FormData; export interface RequestOpts extends AjaxRequest { - query?: HttpQuery; // additional prop - // the following props have improved types over AjaxRequest - method: HttpMethod; - headers?: HttpHeaders; - body?: HttpBody; - responseType?: 'json' | 'blob' | 'arraybuffer' | 'text'; + query?: HttpQuery; // additional prop + // the following props have improved types over AjaxRequest + method: HttpMethod; + headers?: HttpHeaders; + body?: HttpBody; + responseType?: "json" | "blob" | "arraybuffer" | "text"; } export interface ResponseOpts { - respone?: 'raw'; + respone?: "raw"; } export interface OperationOpts { - responseOpts?: ResponseOpts; + responseOpts?: ResponseOpts; } -// AjaxResponse with typed response +// AjaxResponse with typed response export interface RawAjaxResponse extends AjaxResponse { - response: T; + response: T; } export const encodeURI = (value: any) => encodeURIComponent(`${value}`); -const queryString = (params: HttpQuery): string => Object.entries(params) - .map(([key, value]) => value instanceof Array - ? value.map((val) => `${encodeURI(key)}=${encodeURI(val)}`).join('&') +const queryString = (params: HttpQuery): string => + Object.entries(params) + .map(([key, value]) => + value instanceof Array + ? value.map((val) => `${encodeURI(key)}=${encodeURI(val)}`).join("&") : `${encodeURI(key)}=${encodeURI(value)}` ) - .join('&'); + .join("&"); // alias fallback for not being a breaking change export const querystring = queryString; @@ -189,16 +232,28 @@ export const querystring = queryString; /** * @deprecated */ -export const throwIfRequired = (params: {[key: string]: any}, key: string, nickname: string) => { - if (!params || params[key] == null) { - throw new RequiredError(`Required parameter ${key} was null or undefined when calling ${nickname}.`); - } +export const throwIfRequired = ( + params: { [key: string]: any }, + key: string, + nickname: string +) => { + if (!params || params[key] == null) { + throw new RequiredError( + `Required parameter ${key} was null or undefined when calling ${nickname}.` + ); + } }; -export const throwIfNullOrUndefined = (value: any, paramName: string, nickname: string) => { - if (value == null) { - throw new Error(`Parameter "${paramName}" was null or undefined when calling "${nickname}".`); - } +export const throwIfNullOrUndefined = ( + value: any, + paramName: string, + nickname: string +) => { + if (value == null) { + throw new Error( + `Parameter "${paramName}" was null or undefined when calling "${nickname}".` + ); + } }; // alias for easier importing @@ -206,6 +261,6 @@ export interface RequestArgs extends AjaxRequest {} export interface ResponseArgs extends AjaxResponse {} export interface Middleware { - pre?(request: RequestArgs): RequestArgs; - post?(response: ResponseArgs): ResponseArgs; + pre?(request: RequestArgs): RequestArgs; + post?(response: ResponseArgs): ResponseArgs; }