Rebuild: Angular 22 shell with Material, Plotly and the generated API client
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/* eslint-disable */
|
||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
||||
import { Observable, firstValueFrom } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { ApiConfiguration } from './api-configuration';
|
||||
import { StrictHttpResponse } from './strict-http-response';
|
||||
|
||||
export type ApiFnOptional<P, R> = (http: HttpClient, rootUrl: string, params?: P, context?: HttpContext) => Observable<StrictHttpResponse<R>>;
|
||||
export type ApiFnRequired<P, R> = (http: HttpClient, rootUrl: string, params: P, context?: HttpContext) => Observable<StrictHttpResponse<R>>;
|
||||
|
||||
/**
|
||||
* Helper service to call API functions directly
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class Api {
|
||||
constructor(
|
||||
private config: ApiConfiguration,
|
||||
private http: HttpClient
|
||||
) {
|
||||
}
|
||||
|
||||
private _rootUrl?: string;
|
||||
|
||||
/**
|
||||
* Returns the root url for API operations. If not set directly here,
|
||||
* will fallback to `ApiConfiguration.rootUrl`.
|
||||
*/
|
||||
get rootUrl(): string {
|
||||
return this._rootUrl || this.config.rootUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the root URL for API operations
|
||||
*/
|
||||
set rootUrl(rootUrl: string) {
|
||||
this._rootUrl = rootUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes an API call, returning the response body only
|
||||
*/
|
||||
invoke<P, R>(fn: ApiFnRequired<P, R>, params: P, context?: HttpContext): Promise<R>;
|
||||
invoke<P, R>(fn: ApiFnOptional<P, R>, params?: P, context?: HttpContext): Promise<R>;
|
||||
async invoke<P, R>(fn: ApiFnRequired<P, R> | ApiFnOptional<P, R>, params: P, context?: HttpContext): Promise<R> {
|
||||
const resp = this.invoke$Response(fn, params, context);
|
||||
return (await resp).body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes an API call, returning the entire response
|
||||
*/
|
||||
invoke$Response<P, R>(fn: ApiFnRequired<P, R>, params: P, context?: HttpContext): Promise<StrictHttpResponse<R>>;
|
||||
invoke$Response<P, R>(fn: ApiFnOptional<P, R>, params?: P, context?: HttpContext): Promise<StrictHttpResponse<R>>;
|
||||
invoke$Response<P, R>(fn: ApiFnRequired<P, R> | ApiFnOptional<P, R>, params: P, context?: HttpContext): Promise<StrictHttpResponse<R>> {
|
||||
const obs = fn(this.http, this.rootUrl, params, context)
|
||||
.pipe(
|
||||
filter(r => r instanceof HttpResponse),
|
||||
map(r => r as StrictHttpResponse<R>));
|
||||
return firstValueFrom(obs);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user