Scaffold libs/api-client (Nx Angular lib) and generate a typed HttpClient client from services/bff/openapi.json with orval (node-based; Angular target integrates with HttpClient interceptors for the S-08c auth token). A failing test drives the public API: it expects an injectable BffApiV1Service to POST /self-service/registrations and GET /openbaar/register (via HttpClientTesting), but the lib barrel doesn't export the client yet, so it fails. Normalise the vitest target to 'test'. Green exposes it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
217 lines
6.4 KiB
TypeScript
217 lines
6.4 KiB
TypeScript
/**
|
|
* Generated by orval v8.19.0 🍺
|
|
* Do not edit manually.
|
|
* Bff.Api | v1
|
|
* OpenAPI spec version: 1.0.0
|
|
*/
|
|
import {
|
|
HttpClient,
|
|
HttpHeaders,
|
|
HttpResponse as AngularHttpResponse
|
|
} from '@angular/common/http';
|
|
import type {
|
|
HttpContext,
|
|
HttpEvent,
|
|
HttpParams
|
|
} from '@angular/common/http';
|
|
|
|
import {
|
|
Injectable,
|
|
inject
|
|
} from '@angular/core';
|
|
|
|
import {
|
|
Observable
|
|
} from 'rxjs';
|
|
|
|
export interface OpenbaarEntry {
|
|
id: string;
|
|
status: string;
|
|
}
|
|
|
|
export interface SubmitAccepted {
|
|
registrationId: string;
|
|
status: string;
|
|
}
|
|
|
|
export type GetOpenbaarRegisterParams = {
|
|
q?: string;
|
|
};
|
|
|
|
interface HttpClientOptions {
|
|
readonly headers?: HttpHeaders | Record<string, string | string[]>;
|
|
readonly context?: HttpContext;
|
|
readonly params?:
|
|
| HttpParams
|
|
| Record<string, string | number | boolean | Array<string | number | boolean>>;
|
|
readonly reportProgress?: boolean;
|
|
readonly withCredentials?: boolean;
|
|
readonly credentials?: RequestCredentials;
|
|
readonly keepalive?: boolean;
|
|
readonly priority?: RequestPriority;
|
|
readonly cache?: RequestCache;
|
|
readonly mode?: RequestMode;
|
|
readonly redirect?: RequestRedirect;
|
|
readonly referrer?: string;
|
|
readonly integrity?: string;
|
|
readonly referrerPolicy?: ReferrerPolicy;
|
|
readonly transferCache?: {includeHeaders?: string[]} | boolean;
|
|
readonly timeout?: number;
|
|
}
|
|
|
|
type HttpClientBodyOptions = HttpClientOptions & {
|
|
readonly observe?: 'body';
|
|
};
|
|
|
|
type HttpClientEventOptions = HttpClientOptions & {
|
|
readonly observe: 'events';
|
|
};
|
|
|
|
type HttpClientResponseOptions = HttpClientOptions & {
|
|
readonly observe: 'response';
|
|
};
|
|
|
|
type HttpClientObserveOptions = HttpClientOptions & {
|
|
readonly observe?: 'body' | 'events' | 'response';
|
|
};
|
|
|
|
type AngularHttpParamValue = string | number | boolean | Array<string | number | boolean>;
|
|
type AngularHttpParamValueWithNullable = AngularHttpParamValue | null;
|
|
|
|
function filterParams(
|
|
params: Record<string, unknown>,
|
|
requiredNullableKeys?: ReadonlySet<string>,
|
|
preserveRequiredNullables?: false,
|
|
passthroughKeys?: undefined,
|
|
): Record<string, AngularHttpParamValue>;
|
|
function filterParams(
|
|
params: Record<string, unknown>,
|
|
requiredNullableKeys: ReadonlySet<string> | undefined,
|
|
preserveRequiredNullables: true,
|
|
passthroughKeys?: undefined,
|
|
): Record<string, AngularHttpParamValueWithNullable>;
|
|
function filterParams(
|
|
params: Record<string, unknown>,
|
|
requiredNullableKeys: ReadonlySet<string> | undefined,
|
|
preserveRequiredNullables: boolean | undefined,
|
|
passthroughKeys: ReadonlySet<string>,
|
|
): Record<string, unknown>;
|
|
function filterParams(
|
|
params: Record<string, unknown>,
|
|
requiredNullableKeys: ReadonlySet<string> = new Set(),
|
|
preserveRequiredNullables = false,
|
|
passthroughKeys: ReadonlySet<string> = new Set(),
|
|
): Record<string, unknown> {
|
|
const filteredParams: Record<string, unknown> = {};
|
|
for (const [key, value] of Object.entries(params)) {
|
|
if (passthroughKeys.has(key)) {
|
|
if (value !== undefined) {
|
|
filteredParams[key] = value;
|
|
}
|
|
continue;
|
|
}
|
|
if (Array.isArray(value)) {
|
|
const filtered = value.filter(
|
|
(item) =>
|
|
item != null &&
|
|
(typeof item === 'string' ||
|
|
typeof item === 'number' ||
|
|
typeof item === 'boolean'),
|
|
) as Array<string | number | boolean>;
|
|
if (filtered.length) {
|
|
filteredParams[key] = filtered;
|
|
}
|
|
} else if (
|
|
preserveRequiredNullables &&
|
|
value === null &&
|
|
requiredNullableKeys.has(key)
|
|
) {
|
|
filteredParams[key] = null;
|
|
} else if (
|
|
value != null &&
|
|
(typeof value === 'string' ||
|
|
typeof value === 'number' ||
|
|
typeof value === 'boolean')
|
|
) {
|
|
filteredParams[key] = value;
|
|
}
|
|
}
|
|
return filteredParams;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class BffApiV1Service {
|
|
private readonly http = inject(HttpClient);
|
|
postSelfServiceRegistrations<TData = SubmitAccepted>( options?: HttpClientBodyOptions): Observable<TData>;
|
|
postSelfServiceRegistrations<TData = SubmitAccepted>( options?: HttpClientEventOptions): Observable<HttpEvent<TData>>;
|
|
postSelfServiceRegistrations<TData = SubmitAccepted>( options?: HttpClientResponseOptions): Observable<AngularHttpResponse<TData>>;
|
|
postSelfServiceRegistrations<TData = SubmitAccepted>(
|
|
options?: HttpClientObserveOptions): Observable<TData | HttpEvent<TData> | AngularHttpResponse<TData>> {
|
|
if (options?.observe === 'events') {
|
|
return this.http.post<TData>(
|
|
`/self-service/registrations`,
|
|
undefined,{
|
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
|
observe: 'events',
|
|
}
|
|
);
|
|
}
|
|
|
|
if (options?.observe === 'response') {
|
|
return this.http.post<TData>(
|
|
`/self-service/registrations`,
|
|
undefined,{
|
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
|
observe: 'response',
|
|
}
|
|
);
|
|
}
|
|
|
|
return this.http.post<TData>(
|
|
`/self-service/registrations`,
|
|
undefined,{
|
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
|
observe: 'body',
|
|
}
|
|
);
|
|
}
|
|
|
|
getOpenbaarRegister<TData = OpenbaarEntry[]>(params?: GetOpenbaarRegisterParams, options?: HttpClientBodyOptions): Observable<TData>;
|
|
getOpenbaarRegister<TData = OpenbaarEntry[]>(params?: GetOpenbaarRegisterParams, options?: HttpClientEventOptions): Observable<HttpEvent<TData>>;
|
|
getOpenbaarRegister<TData = OpenbaarEntry[]>(params?: GetOpenbaarRegisterParams, options?: HttpClientResponseOptions): Observable<AngularHttpResponse<TData>>;
|
|
getOpenbaarRegister<TData = OpenbaarEntry[]>(
|
|
params?: GetOpenbaarRegisterParams, options?: HttpClientObserveOptions): Observable<TData | HttpEvent<TData> | AngularHttpResponse<TData>> {
|
|
const filteredParams = filterParams({...params, ...options?.params}, new Set<string>([]));
|
|
|
|
if (options?.observe === 'events') {
|
|
return this.http.get<TData>(
|
|
`/openbaar/register`,{
|
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
|
observe: 'events',
|
|
params: filteredParams,}
|
|
);
|
|
}
|
|
|
|
if (options?.observe === 'response') {
|
|
return this.http.get<TData>(
|
|
`/openbaar/register`,{
|
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
|
observe: 'response',
|
|
params: filteredParams,}
|
|
);
|
|
}
|
|
|
|
return this.http.get<TData>(
|
|
`/openbaar/register`,{
|
|
...(options as Omit<NonNullable<typeof options>, 'observe'>),
|
|
observe: 'body',
|
|
params: filteredParams,}
|
|
);
|
|
}
|
|
|
|
};
|